!function(t,e){for(var r in e)t[r]=e[r]}(window,function(t){var e={};function r(n){if(e[n])return e[n].exports;var o=e[n]={i:n,l:!1,exports:{}};return t[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)r.d(n,o,function(e){return t[e]}.bind(null,o));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=12)}([function(t,e,r){t.exports=r(7)},function(t,e){t.exports=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}},function(t,e){function r(t,e,r,n,o,i,a){try{var s=t[i](a),c=s.value}catch(t){return void r(t)}s.done?e(c):Promise.resolve(c).then(n,o)}t.exports=function(t){return function(){var e=this,n=arguments;return new Promise((function(o,i){var a=t.apply(e,n);function s(t){r(a,o,i,s,c,"next",t)}function c(t){r(a,o,i,s,c,"throw",t)}s(void 0)}))}}},function(t,e){t.exports=function(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}},function(t,e){function r(t,e){for(var r=0;rt.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var s=r.call(i,"catchLoc"),c=r.call(i,"finallyLoc");if(s&&c){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),b(r),u}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;b(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:E(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),u}},t}(t.exports);try{regeneratorRuntime=n}catch(t){Function("r","regeneratorRuntime = r")(n)}},function(t,e,r){var n=r(5);t.exports=function(t){if(Array.isArray(t))return n(t)}},function(t,e){t.exports=function(t){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(t))return Array.from(t)}},function(t,e,r){var n=r(5);t.exports=function(t,e){if(t){if("string"==typeof t)return n(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?n(t,e):void 0}}},function(t,e){t.exports=function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}},function(t,e,r){"use strict";r.r(e),r.d(e,"process",(function(){return ot})),r.d(e,"getSignature",(function(){return at})),r.d(e,"cancel",(function(){return ct}));var n=r(0),o=r.n(n),i=r(2),a=r.n(i),s=r(3),c=r.n(s),u=r(1),h=r.n(u),f=r(4),l=r.n(f),p=r(6),m=r.n(p),d="",v="";function g(t){if("string"==typeof t)return(new TextDecoder).decode(g("string"!=typeof(e=t)?null:(new TextEncoder).encode(e)));var e;if(t.length<0)return t;var r=[2];r.push.apply(r,m()(t)),r.push(3);var n=function(t){for(var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,n=0,o=e;o-1))if("0,65535"===n[o]){var i=new A(n[o+1]);r.moveTo(i.x-1,i.y-1)}else{var a=new A(n[o]);r.lineTo(a.x,a.y)}return r.stroke(),e.toDataURL("image/png").replace("data:image/png;base64,","")}}]),t}(),A=function t(e){h()(this,t),c()(this,"x",0),c()(this,"y",0),e.indexOf(",")>=0&&(this.x=e.split(",")[0],this.y=e.split(",")[1])},L="cc:sale",C="cc:credit",k="cc:authonly",T="cc:capture",O="cc:postauth",j="cc:void",N="cc:voidrelease",R="cc:voidrefund",D="cc:balance",P="ebtfs:sale",_="ebtfs:credit",M="ebtfs:balance",B="ebtcb:sale",F="ebtcb:balance",G="gift:redeem",U="gift:issue",H="gift:balance";function Z(t){var e,r,n,o,i,a,s,c,u,h,f,l,p,m,y=function(t,e){var r=t.xCommand;if(r.toLowerCase().indexOf("cc")>=0)return e?"T02":"T00";if(r.toLowerCase().indexOf("ebt")>=0)return"T04";if(r.toLowerCase().indexOf("gift")>=0)return"T06";throw"Unsupported command: "+r}(t),w=function(t){var e=t.xCommand;switch(e){case L:case P:case B:case G:return"01";case C:case _:return"02";case k:return"03";case T:return"04";case O:return"05";case U:return"10";case j:case N:case R:return"16";case D:case M:case F:case H:return"23"}throw"Unsupported command: "+e}(t),b=[y,"1.28",w,function(t,e){var r=t.xAmount,n=t.xTax;switch(e){case"01":case"04":case"05":return[W(r),"","","",W(n)].join(v);case"03":case"02":case"06":case"10":return W(r);case"16":case"18":case"19":case"20":case"21":case"23":case"24":default:return""}}(t,w),(r=(e=t).xExp,n=e.xCommand,o=e.xAllowDuplicate,i=e.xBillFirstName,a=e.xBillLastName,s=e.xCity,c=e.xEmail,["",r,"",Y(n),"",o?1:"",i,a,"","",s,c].join(v)),(h=(u=t).xInvoice,f=u.xRefnum,l=u.xZip,p=u.xStreet,[f,h,"",f,(m=new Date,"".concat(m.getFullYear()).concat(x(m.getMonth()+1,2)).concat(x(m.getDate(),2)).concat(x(m.getHours(),2)).concat(x(m.getMinutes(),2)).concat(x(m.getSeconds(),2))),"",l,p,v].join(v))];return["T00","T06"].includes(y)?b.push(function(t){var e=t.xZip,r=t.xStreet;return[e,r].join(v)}(t)+d+d+d+d):b.push(""),g(b.join(d))}function Y(t){if(t.toLowerCase().indexOf("ebt")<0)return"";if(t.toLowerCase().indexOf("ebtfs")>=0)return"F";if(t.toLowerCase().indexOf("ebtcb")>=0)return"C";throw"Unsupported EBT Type: "+t}function W(t){return Math.round(100*t)}var q=function t(e){h()(this,t),c()(this,"hostInformation",{}),c()(this,"amountInformation",{}),c()(this,"accountInformation",{}),c()(this,"traceInformation",{}),c()(this,"avsInformation",{});var r=(e=e.substr(0,e.length-2)).split(d);r.length<1||(this.status=r[0].trim(),r.length<2||(this.command=r[1].trim(),r.length<4||(this.responseCode=r[3].trim(),r.length<5||(this.responseMessage=r[4].trim(),r.length<6||(this.hostInformation=new z(r[5].trim()),r.length<7||(this.transactionType=r[6].trim(),r.length<8||(this.amountInformation=new $(r[7].trim()),r.length<9||(this.accountInformation=new J(r[8].trim()),r.length<10||(this.traceInformation=new K(r[9].trim()),r.length<11||(this.avsInformation=new Q(r[10].trim()),r.length<14||(this.additionalInformation=r[13].trim())))))))))))},z=function t(e){h()(this,t);var r=e.split(v);r.length<1||(this.hostResponseCode=r[0].trim(),r.length<2||(this.hostResponseMessage=r[1].trim(),r.length<3||(this.authCode=r[2].trim(),r.length<4||(this.hostReferenceNumber=r[3].trim(),r.length<5||(this.traceNumber=r[4].trim(),r.length<6||(this.batchNumber=r[5].trim(),r.length<7||(this.transactionIdentifier=r[6].trim(),r.length<8||(this.gatewayTransactionID=r[7].trim()))))))))},$=function t(e){h()(this,t);var r=e.split(v);r.length<1||(this.approveAmount=r[0].trim(),r.length<2||(this.amountDue=r[1].trim(),r.length<3||(this.tipAmount=r[2].trim(),r.length<4||(this.cashbackAmount=r[3].trim(),r.length<5||(this.fee=r[4].trim(),r.length<6||(this.taxAmount=r[5].trim(),r.length<7||(this.balance1=r[6].trim(),r.length<8||(this.balance2=r[7].trim(),r.length<9||(this.serviceFee=r[8].trim())))))))))},J=function t(e){h()(this,t);var r=e.split(v);r.length<1||(this.account=r[0].trim(),r.length<2||(this.entryMode=r[1].trim(),r.length<3||(this.expDate=r[2].trim(),r.length<8||(this.cardHolder=r[7].trim()))))},K=function t(e){h()(this,t);var r=e.split(v);r.length<1||(this.transactionNumber=r[0].trim(),r.length<2||(this.referenceNumber=r[1].trim(),r.length<3||(this.timeStamp=r[2].trim(),r.length<4||(this.invoiceNumber=r[3].trim()))))},Q=function t(e){h()(this,t);var r=e.split(v);r.length<1||(this.approvalCode=r[0].trim(),r.length<2||(this.message=r[1].trim(),r.length<3||(this.zipCode=r[2].trim(),r.length<4||(this.address1=r[3].trim(),r.length<5||(this.approvalCode=r[4].trim())))))};function V(t,e){return"000000"!==e.responseCode?{xResult:"E",xStatus:"Error",xError:e.responseMessage}:{xResult:"A",xStatus:"Approved",xAuthCode:e.hostInformation.authCode,xCommand:t.xCommand,xAuthAmount:(e.amountInformation.approveAmount||0)/100,xRefNum:e.hostInformation.hostReferenceNumber,xBatch:e.hostInformation.batchNumber,xAvsResult:e.avsInformation.message,xAvsResultCode:e.avsInformation.approvalCode,xMaskedCardNumber:e.accountInformation.account,xName:e.accountInformation.cardHolder,xRemainingBalance:(e.amountInformation.balance1||0)/100,xRemainingBalanceEBTCB:t.xCommand.startsWith("ebt")?(e.amountInformation.balance1||0)/100:"",xRemainingBalanceEBTFS:t.xCommand.startsWith("ebt")?(e.amountInformation.balance2||0)/100:"",xConvenienceFee:(e.amountInformation.serviceFee||0)/100,xCashbackAmount:(e.amountInformation.cashbackAmount||0)/100,xTip:(e.amountInformation.tipAmount||0)/100,xExp:e.accountInformation.expDate,xInvoice:e.traceInformation.invoiceNumber}}var X=function(){function t(e){h()(this,t),this.ipDeviceCommunicator=e}var e;return l()(t,[{key:"process",value:(e=a()(o.a.mark((function t(e){var r,n,i;return o.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,this.validate(e),r=Z(e),t.next=5,this.ipDeviceCommunicator.getData(btoa(r));case 5:if(n=t.sent,"000000"===(i=new q(n)).responseCode){t.next=9;break}throw i.responseMessage;case 9:return t.abrupt("return",V(e,i));case 12:return t.prev=12,t.t0=t.catch(0),t.abrupt("return",{xResult:"E",xStatus:"Error",xError:t.t0.toString()});case 15:case"end":return t.stop()}}),t,this,[[0,12]])}))),function(t){return e.apply(this,arguments)})},{key:"validate",value:function(t){t.xInvoice=t.xInvoice||"",t.xStreet=t.xStreet||"",t.xZip=t.xZip||"",t.xTip=t.xTip||"",t.xTax=t.xTax||"",t.xExp=t.xExp||"",t.xAllowDuplicate=!!t.xAllowDuplicate,t.xBillFirstName=t.xBillFirstName||"",t.xBillLastName=t.xBillLastName||"",t.xCity=t.xCity||"",t.xEmail=t.xEmail||"",t.xRefnum=t.xRefnum||0}}]),t}(),tt=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};h()(this,t),this.signatureReader=e.signatureReader,this.cardReader=e.cardReader}var e,r;return l()(t,[{key:"getSignature",value:(r=a()(o.a.mark((function t(){return o.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.signatureReader.getSignature();case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t,this)}))),function(){return r.apply(this,arguments)})},{key:"process",value:(e=a()(o.a.mark((function t(e){return o.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.cardReader.process(e);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t,this)}))),function(t){return e.apply(this,arguments)})}]),t}(),et="",rt=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(h()(this,t),e.deviceIpAddress)et=e.deviceIpAddress;else if(!e.deviceSerialNumber)throw"Device serial number required";this.serialNumber=e.deviceSerialNumber}return l()(t,[{key:"getIP",value:function(){return et}}]),t}(),nt=function t(e,r,n){var i=this;h()(this,t),c()(this,"getData",function(){var t=a()(o.a.mark((function t(e){var r,n,a;return o.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,fetch("".concat(i.protocol,"//").concat(i.ip,":").concat(i.port,"?").concat(e));case 3:if((r=t.sent).ok){t.next=6;break}throw r;case 6:return n=r.body.getReader(),t.next=9,y(n,new Uint8Array);case 9:return a=(a=t.sent)?new TextDecoder("utf-8").decode(a):"",t.abrupt("return",a);case 14:throw t.prev=14,t.t0=t.catch(0),console.error(t.t0),t.t0;case 18:case"end":return t.stop()}}),t,null,[[0,14]])})));return function(e){return t.apply(this,arguments)}}()),this.ip=e,this.port=r,this.protocol=n};function ot(t){return it.apply(this,arguments)}function it(){return(it=a()(o.a.mark((function t(e){var r,n;return o.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,r=new rt(e.settings),n=new tt({cardReader:new X(new nt(r.getIP(),e.settings.deviceIpPort,e.settings.deviceIpProtocol||location.protocol))}),ht(e.settings.deviceIpAddress,n),t.next=6,n.process(e);case 6:return t.abrupt("return",t.sent);case 9:return t.prev=9,t.t0=t.catch(0),t.abrupt("return",{xResult:"E",xStatus:"Error",xError:t.t0.toString()});case 12:return t.prev=12,ut[e.settings.deviceIpAddress]=void 0,t.finish(12);case 15:case"end":return t.stop()}}),t,null,[[0,9,12,15]])})))).apply(this,arguments)}function at(t){return st.apply(this,arguments)}function st(){return(st=a()(o.a.mark((function t(e){var r,n;return o.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,r=new rt(e),n=new tt({signatureReader:new S(new nt(r.getIP(),e.deviceIpPort,e.deviceIpProtocol||location.protocol))}),ht(e.deviceIpAddress,n),t.next=6,n.getSignature();case 6:return t.abrupt("return",t.sent);case 9:return t.prev=9,t.t0=t.catch(0),t.abrupt("return",{xResult:"E",xStatus:"Error",xError:t.t0.toString()});case 12:return t.prev=12,ut[e.deviceIpAddress]=void 0,t.finish(12);case 15:case"end":return t.stop()}}),t,null,[[0,9,12,15]])})))).apply(this,arguments)}function ct(t){try{var e=new rt(t);(new tt).cancel(new nt(e.getIP(),t.deviceIpPort,"http"))}catch(t){throw console.error(t),t}}var ut={};function ht(t,e){if(ut[t])throw"Transaction in progress";ut[t]=e}}]));