@danidoble/webserial 4.1.2 → 4.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/webserial.js +448 -416
- package/dist/webserial.umd.cjs +13 -13
- package/package.json +8 -8
package/dist/webserial.umd.cjs
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
(function(I,x){typeof exports=="object"&&typeof module<"u"?x(exports):typeof define=="function"&&define.amd?define(["exports"],x):(I=typeof globalThis<"u"?globalThis:I||self,x(I.WebSerial={}))})(this,function(I){"use strict";var yc=Object.defineProperty;var Ki=I=>{throw TypeError(I)};var wc=(I,x,X)=>x in I?yc(I,x,{enumerable:!0,configurable:!0,writable:!0,value:X}):I[x]=X;var Z=(I,x,X)=>wc(I,typeof x!="symbol"?x+"":x,X),gn=(I,x,X)=>x.has(I)||Ki("Cannot "+X);var O=(I,x,X)=>(gn(I,x,"read from private field"),X?X.call(I):x.get(I)),$=(I,x,X)=>x.has(I)?Ki("Cannot add the same private member more than once"):x instanceof WeakSet?x.add(I):x.set(I,X),L=(I,x,X,Vt)=>(gn(I,x,"write to private field"),Vt?Vt.call(I,X):x.set(I,X),X),o=(I,x,X)=>(gn(I,x,"access private method"),X);var st,ht,d,Wi,zi,T,bn,U,F,Be,E,mn,se,B,Xi,yn,Mt,Gi,Ji,$i,Qi,Zi,Yi,tr,er,nr,ir,rr,sr,re,Ie,ar,nt,G,Pt,R,or,cr,lr,hr,wn,ur,Ft,Ut,Ne,Me,Fe,p,dr,pr,fr,vn,_r,gr,br,mr,yr,wr,vr,Pr,Er,Tr,ae,oe,Cr,ce,Sr,Lt,kr,J,xr,Ar,Pn,Dr,Rr,Ir,En,Tn,le,Cn,Or,mt,yt,Ue,Sn,he,kn,xn,Br,An,Dn,Nr,Mr,Qt,Rn,Fr,Ur,Lr,Le,Vr,qr,In,jr,Hr,Kr,Wr,zr,Xr,Gr,Jr,$r,On,Bn,Qr,Zr,Yr,g,ts,es,ns,ot,Ve,is,rs,ss,as,os,cs,ls,hs,us,ds,ps,fs,_s,gs,bs,ms,ys,ws,vs,Ps,Es,Ts,Cs,Ss,ks,xs,ft,Y,qe,tt,wt,As,Ds,Rs,Is,ue,Nn,Mn,je,He,Os,Gt,Nt,Jt,w,Bs,Ns,Ke,Ms,Fs,Us,Ls,Vs,qs,js,Hs,Fn,Ks,Ws,zs,Xs,Gs,Js,$s,Qs,Zs,Ys,ta,ea,na,ia,ct,We,ra,sa,aa,oa,Un,ze,ca,la,Ln,Vn,qn,$t,ha,ua;const x=[];for(let r=0;r<256;++r)x.push((r+256).toString(16).slice(1));function X(r,i=0){return(x[r[i+0]]+x[r[i+1]]+x[r[i+2]]+x[r[i+3]]+"-"+x[r[i+4]]+x[r[i+5]]+"-"+x[r[i+6]]+x[r[i+7]]+"-"+x[r[i+8]]+x[r[i+9]]+"-"+x[r[i+10]]+x[r[i+11]]+x[r[i+12]]+x[r[i+13]]+x[r[i+14]]+x[r[i+15]]).toLowerCase()}let Vt;const da=new Uint8Array(16);function pa(){if(!Vt){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");Vt=crypto.getRandomValues.bind(crypto)}return Vt(da)}const jn={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function fa(r,i,t){var n;if(jn.randomUUID&&!r)return jn.randomUUID();r=r||{};const e=r.random??((n=r.rng)==null?void 0:n.call(r))??pa();if(e.length<16)throw new Error("Random bytes length must be >= 16");return e[6]=e[6]&15|64,e[8]=e[8]&63|128,X(e)}class Hn extends EventTarget{constructor(){super(...arguments);Z(this,"__listeners__",{});Z(this,"__debug__",!1)}dispatch(t,e=null){const n=new Kn(t,{detail:e});this.dispatchEvent(n),this.__debug__&&this.dispatchEvent(new Kn("debug",{detail:{type:t,data:e}}))}dispatchAsync(t,e=null,n=100){const s=this;setTimeout(()=>{s.dispatch(t,e)},n)}on(t,e){typeof this.__listeners__[t]<"u"&&this.__listeners__[t]===!1&&(this.__listeners__[t]=!0),this.addEventListener(t,e)}off(t,e){this.removeEventListener(t,e)}serialRegisterAvailableListener(t){this.__listeners__[t]||(this.__listeners__[t]=!1)}get availableListeners(){return Object.keys(this.__listeners__).sort().map(e=>({type:e,listening:this.__listeners__[e]}))}}class Kn extends CustomEvent{constructor(i,t){super(i,t)}}function dt(r=100){return new Promise(i=>setTimeout(()=>i(),r))}function Wn(){return"serial"in navigator}function zn(){return"geolocation"in navigator}function _a(){return"crypto"in window}function Xe(r=1){return r*1e3}function Ct(r){return r==null||r===""}const u=class u{static status(i=null){var e,n;if(!o(e=u,d,T).call(e,i))return!1;let t=[];switch(O(u,st)){case"locker":t=["0","8"];break;case"boardroid":t=["2",(5+O(u,ht)).toString(16).toUpperCase()];break;case"jofemar":t=["6"];break;default:return!1}o(n=u,d,E).call(n,t)}static dispensed(i=null){var e,n;if(!o(e=u,d,T).call(e,i))return!1;let t=[];switch(O(u,st)){case"locker":t=["0","7","4","4","4"];break;case"boardroid":t=["2","D7","A","0","0","0","0","0","0","0","0","0","F2"];break;case"jofemar":t=["6","30"];break;default:return!1}o(n=u,d,E).call(n,t)}static notDispensed(i=null){var e,n;if(!o(e=u,d,T).call(e,i))return!1;let t=[];switch(O(u,st)){case"locker":t=["0","7","5","5","5"];break;case"boardroid":t=["2","D7","A","0","0","1","0","0","0","0","0","0","F2"];break;case"jofemar":t=["6","34"];break;default:return!1}o(n=u,d,E).call(n,t)}static gateInactive(i=null){var t;if(!o(t=u,d,T).call(t,i)||!o(this,d,bn).call(this))return!1;o(this,d,E).call(this,["0","7","5","5","5"])}static gateConfigured(i=null){var t;if(!o(t=u,d,T).call(t,i)||!o(this,d,bn).call(this))return!1;o(this,d,E).call(this,["0","6"])}static keyPressed(i=null){var s,a,c;if(!o(s=u,d,T).call(s,i)||!o(a=u,d,F).call(a))return!1;const t=["30","31","32","33","34","35","36","37","38","39","2A","23","41","42","43","44"],e=(128+O(u,ht)).toString(16),n=Math.floor(Math.random()*15);o(c=u,d,E).call(c,["2",e,"54",t[n]])}static doorOpened(i=null){var n,s;if(!o(n=u,d,T).call(n,i)||!o(this,d,Be).call(this))return!1;let t=[];const e=(128+O(u,ht)).toString(16);switch(O(u,st)){case"boardroid":t=["2","D8","dc"];break;case"jofemar":t=["2",e,"50","4F"];break}o(s=u,d,E).call(s,t)}static doorClosed(i=null){var n,s;if(!o(n=u,d,T).call(n,i)||!o(this,d,Be).call(this))return!1;let t=[];const e=(128+O(u,ht)).toString(16);switch(O(u,st)){case"boardroid":t=["2","D8","db"];break;case"jofemar":t=["2",e,"50","43"];break}o(s=u,d,E).call(s,t)}static channelDisconnected(i=null){var e,n,s;if(!o(e=u,d,T).call(e,i)||!o(n=u,d,F).call(n))return!1;const t=(128+O(u,ht)).toString(16);o(s=u,d,E).call(s,["2",t,"43","43","43","FD"])}static channelConnected(i=null){var e,n,s;if(!o(e=u,d,T).call(e,i)||!o(n=u,d,F).call(n))return!1;const t=(128+O(u,ht)).toString(16);o(s=u,d,E).call(s,["2",t,"43","43","43","FC"])}static channelEmpty(i=null){var e,n,s;if(!o(e=u,d,T).call(e,i)||!o(n=u,d,F).call(n))return!1;const t=(128+O(u,ht)).toString(16);o(s=u,d,E).call(s,["2",t,"43","43","43","FF"])}static workingTemperature(i=null){var e,n,s;if(!o(e=u,d,T).call(e,i)||!o(n=u,d,F).call(n))return!1;const t=(128+O(u,ht)).toString(16);o(s=u,d,E).call(s,["2",t,"43","54","16"])}static currentTemperature(i=null){var n,s,a;if(!o(n=u,d,T).call(n,i)||!o(s=u,d,Be).call(s))return!1;let t=[];const e=(128+O(u,ht)).toString(16);switch(O(u,st)){case"boardroid":t=["2","D9","44","30"];break;case"jofemar":t=["2",e,"43","74","2B","30","39","2E","31","7F","43"];break}o(a=u,d,E).call(a,t)}static ready(i=null){var t,e,n;if(!o(t=u,d,T).call(t,i)||!o(e=u,d,F).call(e))return!1;o(n=u,d,E).call(n,["6","30"])}static busy(i=null){var t,e,n;if(!o(t=u,d,T).call(t,i)||!o(e=u,d,F).call(e))return!1;o(n=u,d,E).call(n,["6","31"])}static invalidTray(i=null){var t,e,n;if(!o(t=u,d,T).call(t,i)||!o(e=u,d,F).call(e))return!1;o(n=u,d,E).call(n,["6","32"])}static invalidChannel(i=null){var t,e,n;if(!o(t=u,d,T).call(t,i)||!o(e=u,d,F).call(e))return!1;o(n=u,d,E).call(n,["6","33"])}static emptyChannel(i=null){var t,e,n;if(!o(t=u,d,T).call(t,i)||!o(e=u,d,F).call(e))return!1;o(n=u,d,E).call(n,["6","34"])}static elevatorJam(i=null){var t,e,n;if(!o(t=u,d,T).call(t,i)||!o(e=u,d,F).call(e))return!1;o(n=u,d,E).call(n,["6","35"])}static elevatorMalfunction(i=null){var t,e,n;if(!o(t=u,d,T).call(t,i)||!o(e=u,d,F).call(e))return!1;o(n=u,d,E).call(n,["6","36"])}static phototransistorFailure(i=null){var t,e,n;if(!o(t=u,d,T).call(t,i)||!o(e=u,d,F).call(e))return!1;o(n=u,d,E).call(n,["6","37"])}static allChannelsEmpty(i=null){var t,e,n;if(!o(t=u,d,T).call(t,i)||!o(e=u,d,F).call(e))return!1;o(n=u,d,E).call(n,["6","38"])}static productDetectorFailure(i=null){var t,e,n;if(!o(t=u,d,T).call(t,i)||!o(e=u,d,F).call(e))return!1;o(n=u,d,E).call(n,["6","39"])}static displayDisconnected(i=null){var t,e,n;if(!o(t=u,d,T).call(t,i)||!o(e=u,d,F).call(e))return!1;o(n=u,d,E).call(n,["6","41"])}static productUnderElevator(i=null){var t,e,n;if(!o(t=u,d,T).call(t,i)||!o(e=u,d,F).call(e))return!1;o(n=u,d,E).call(n,["6","42"])}static elevatorSettingAlarm(i=null){var t,e,n;if(!o(t=u,d,T).call(t,i)||!o(e=u,d,F).call(e))return!1;o(n=u,d,E).call(n,["6","43"])}static buttonPanelFailure(i=null){var t,e,n;if(!o(t=u,d,T).call(t,i)||!o(e=u,d,F).call(e))return!1;o(n=u,d,E).call(n,["6","44"])}static errorWritingEeprom(i=null){var t,e,n;if(!o(t=u,d,T).call(t,i)||!o(e=u,d,F).call(e))return!1;o(n=u,d,E).call(n,["6","45"])}static errorControlTemperature(i=null){var t,e,n;if(!o(t=u,d,T).call(t,i)||!o(e=u,d,F).call(e))return!1;o(n=u,d,E).call(n,["6","46"])}static thermometerDisconnected(i=null){var t,e,n;if(!o(t=u,d,T).call(t,i)||!o(e=u,d,F).call(e))return!1;o(n=u,d,E).call(n,["6","47"])}static thermometerMisconfigured(i=null){var t,e,n;if(!o(t=u,d,T).call(t,i)||!o(e=u,d,F).call(e))return!1;o(n=u,d,E).call(n,["6","48"])}static thermometerFailure(i=null){var t,e,n;if(!o(t=u,d,T).call(t,i)||!o(e=u,d,F).call(e))return!1;o(n=u,d,E).call(n,["6","49"])}static errorExtractorConsumption(i=null){var t,e,n;if(!o(t=u,d,T).call(t,i)||!o(e=u,d,F).call(e))return!1;o(n=u,d,E).call(n,["6","4A"])}static channelSearchError(i=null){var t,e,n;if(!o(t=u,d,T).call(t,i)||!o(e=u,d,F).call(e))return!1;o(n=u,d,E).call(n,["6","4B"])}static productExitMouthSearchError(i=null){var t,e,n;if(!o(t=u,d,T).call(t,i)||!o(e=u,d,F).call(e))return!1;o(n=u,d,E).call(n,["6","4C"])}static elevatorInteriorLocked(i=null){var t,e,n;if(!o(t=u,d,T).call(t,i)||!o(e=u,d,F).call(e))return!1;o(n=u,d,E).call(n,["6","4D"])}static productDetectorVerifierError(i=null){var t,e,n;if(!o(t=u,d,T).call(t,i)||!o(e=u,d,F).call(e))return!1;o(n=u,d,E).call(n,["6","4E"])}static waitingForProductRecall(i=null){var t,e,n;if(!o(t=u,d,T).call(t,i)||!o(e=u,d,F).call(e))return!1;o(n=u,d,E).call(n,["6","4F"])}static productExpiredByTemperature(i=null){var t,e,n;if(!o(t=u,d,T).call(t,i)||!o(e=u,d,F).call(e))return!1;o(n=u,d,E).call(n,["6","50"])}static faultyAutomaticDoor(i=null){var t,e,n;if(!o(t=u,d,T).call(t,i)||!o(e=u,d,F).call(e))return!1;o(n=u,d,E).call(n,["6","51"])}static rejectLever(i=null){var t,e,n;if(!o(t=u,d,T).call(t,i)||!o(e=u,d,U).call(e))return!1;o(n=u,d,E).call(n,["2","A0","1"])}static resetCoinPurse(i=null){var t,e,n;if(!o(t=u,d,T).call(t,i)||!o(e=u,d,U).call(e))return!1;o(n=u,d,E).call(n,["2","A0","2"])}static coinInsertedBox(i=null,t=null){var s,a,c,l;if(!o(s=u,d,T).call(s,i)||!o(a=u,d,U).call(a))return!1;const e=["40","41","42","43","44","45"],n=o(c=u,d,mn).call(c,e,t);o(l=u,d,E).call(l,["2","A0",n])}static coinInsertedTube(i=null,t=null){var s,a,c,l;if(!o(s=u,d,T).call(s,i)||!o(a=u,d,U).call(a))return!1;const e=["50","51","52","53","54","55"],n=o(c=u,d,mn).call(c,e,t);o(l=u,d,E).call(l,["2","A0",n])}static banknoteInsertedStacker(i=null,t=null){var s,a,c,l;if(!o(s=u,d,T).call(s,i)||!o(a=u,d,U).call(a))return!1;const e=["80","81","82","83","84"],n=o(c=u,d,se).call(c,e,t);o(l=u,d,E).call(l,["2","B0",n])}static banknoteInsertedEscrow(i=null,t=null){var s,a,c,l;if(!o(s=u,d,T).call(s,i)||!o(a=u,d,U).call(a))return!1;const e=["90","91","92","93","94"],n=o(c=u,d,se).call(c,e,t);o(l=u,d,E).call(l,["2","B0",n])}static banknoteEjected(i=null,t=null){var s,a,c,l;if(!o(s=u,d,T).call(s,i)||!o(a=u,d,U).call(a))return!1;const e=["A0","A1","A2","A3","A4"],n=o(c=u,d,se).call(c,e,t);o(l=u,d,E).call(l,["2","B0",n])}static banknoteInsertedRecycler(i=null,t=null){var s,a,c,l;if(!o(s=u,d,T).call(s,i)||!o(a=u,d,U).call(a))return!1;const e=["B0","B1","B2","B3","B4"],n=o(c=u,d,se).call(c,e,t);o(l=u,d,E).call(l,["2","B0",n])}static banknoteTaken(i=null){var t,e,n;if(!o(t=u,d,T).call(t,i)||!o(e=u,d,U).call(e))return!1;o(n=u,d,E).call(n,["2","B0","2a"])}static coinPurseEnabled(i=null){var t,e,n;if(!o(t=u,d,T).call(t,i)||!o(e=u,d,U).call(e))return!1;o(n=u,d,E).call(n,["2","D0","1"])}static coinPurseDisabled(i=null){var t,e,n;if(!o(t=u,d,T).call(t,i)||!o(e=u,d,U).call(e))return!1;o(n=u,d,E).call(n,["2","D0","0"])}static billPurseDisabled(i=null){var t,e,n;if(!o(t=u,d,T).call(t,i)||!o(e=u,d,U).call(e))return!1;o(n=u,d,E).call(n,["2","D1","0","0"])}static billPurseEnabled(i=null){var t,e,n;if(!o(t=u,d,T).call(t,i)||!o(e=u,d,U).call(e))return!1;o(n=u,d,E).call(n,["2","D1","1","1"])}static readTubes(i=null){var h,f,_;if(!o(h=u,d,T).call(h,i)||!o(f=u,d,U).call(f))return!1;const t=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f"],[e,n,s,a,c,l]=[t[Math.floor(Math.random()*30)],t[Math.floor(Math.random()*30)],t[Math.floor(Math.random()*30)],t[Math.floor(Math.random()*30)],t[Math.floor(Math.random()*30)],t[Math.floor(Math.random()*30)]];o(_=u,d,E).call(_,["2","D2",e,n,s,a,c,l])}static readBillPurse(i=null,t=null){var n,s,a,c;if(!o(n=u,d,T).call(n,i)||!o(s=u,d,U).call(s))return!1;let e=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c"];if(i._recycler.ict){const l=e[Math.floor(Math.random()*31)];let h="0",f="0",_="0",m="0",P="0";if(t!==null&&!isNaN(parseInt(t)))switch(t.toString()){case"20":h=l;break;case"50":f=l;break;case"100":_=l;break;case"200":m=l;break;case"500":P=l;break}else switch(i._recycler.bill){case 0:h=l;break;case 1:f=l;break;case 2:_=l;break;case 3:m=l;break;case 4:P=l;break}o(a=u,d,E).call(a,["2","D3",h,f,_,m,P,"0"])}else{const[l,h,f,_,m,P]=[e[Math.floor(Math.random()*30)],e[Math.floor(Math.random()*30)],e[Math.floor(Math.random()*30)],e[Math.floor(Math.random()*2)],e[Math.floor(Math.random())],e[Math.floor(Math.random())]];o(c=u,d,E).call(c,["2","D3",l,h,f,_,m,P])}}static banknoteAccepted(i=null){var t,e,n;if(!o(t=u,d,T).call(t,i)||!o(e=u,d,U).call(e))return!1;o(n=u,d,E).call(n,["2","D4","1"])}static banknoteRejected(i=null){var t,e,n;if(!o(t=u,d,T).call(t,i)||!o(e=u,d,U).call(e))return!1;o(n=u,d,E).call(n,["2","D4","0"])}static banknotesDispensed(i=null){var e,n,s,a;if(!o(e=u,d,T).call(e,i)||!o(n=u,d,U).call(n))return!1;let t=["1","2","3","4","5","6","7","8","9","a","b","c","d","e","f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c"];if(i._recycler.ict){const c=t[Math.floor(Math.random()*30)];let l="0",h="0",f="0",_="0",m="0";switch(i._recycler.bill){case 0:l=c;break;case 1:h=c;break;case 2:f=c;break;case 3:_=c;break;case 4:m=c;break}o(s=u,d,E).call(s,["2","D5",l,h,f,_,m,"0"])}else{const[c,l,h,f,_,m]=[t[Math.floor(Math.random()*30)],t[Math.floor(Math.random()*30)],t[Math.floor(Math.random()*30)],t[Math.floor(Math.random()*2)],t[Math.floor(Math.random())],t[Math.floor(Math.random())]];o(a=u,d,E).call(a,["2","D5",c,l,h,f,_,m])}}static coinsDispensed(i=null){var t,e,n;if(!o(t=u,d,T).call(t,i)||!o(e=u,d,U).call(e))return!1;o(n=u,d,E).call(n,["2","D6"])}static relayOn(i=null){var t,e,n;if(!o(t=u,d,T).call(t,i)||!o(e=u,d,U).call(e))return!1;o(n=u,d,E).call(n,["2","DA","1"])}static relayOff(i=null){var t,e,n;if(!o(t=u,d,T).call(t,i)||!o(e=u,d,U).call(e))return!1;o(n=u,d,E).call(n,["2","DA","0"])}static nayaxEnabled(i=null){var t,e,n;if(!o(t=u,d,T).call(t,i)||!o(e=u,d,U).call(e))return!1;o(n=u,d,E).call(n,["2","DD","1"])}static nayaxDisabled(i=null){var t,e,n;if(!o(t=u,d,T).call(t,i)||!o(e=u,d,U).call(e))return!1;o(n=u,d,E).call(n,["2","DD","0"])}static nayaxPreCreditAuthorized(i=null){var t,e,n;if(!o(t=u,d,T).call(t,i)||!o(e=u,d,U).call(e))return!1;o(n=u,d,E).call(n,["2","DD","3"])}static nayaxCancelRequest(i=null){var t,e,n;if(!o(t=u,d,T).call(t,i)||!o(e=u,d,U).call(e))return!1;o(n=u,d,E).call(n,["2","DD","4"])}static nayaxSellApproved(i=null){var t,e,n;if(!o(t=u,d,T).call(t,i)||!o(e=u,d,U).call(e))return!1;o(n=u,d,E).call(n,["2","DD","5"])}static nayaxSellDenied(i=null){var t,e,n;if(!o(t=u,d,T).call(t,i)||!o(e=u,d,U).call(e))return!1;o(n=u,d,E).call(n,["2","DD","6"])}static nayaxEndSession(i=null){var t,e,n;if(!o(t=u,d,T).call(t,i)||!o(e=u,d,U).call(e))return!1;o(n=u,d,E).call(n,["2","DD","7"])}static nayaxCancelled(i=null){var t,e,n;if(!o(t=u,d,T).call(t,i)||!o(e=u,d,U).call(e))return!1;o(n=u,d,E).call(n,["2","DD","8"])}static nayaxDispensed(i=null){var t,e,n;if(!o(t=u,d,T).call(t,i)||!o(e=u,d,U).call(e))return!1;o(n=u,d,E).call(n,["2","DD","A","0"])}static nayaxNotDispensed(i=null){var t,e,n;if(!o(t=u,d,T).call(t,i)||!o(e=u,d,U).call(e))return!1;o(n=u,d,E).call(n,["2","DD","A","1"])}static fullTray(i=null){var t,e,n;if(!o(t=u,d,T).call(t,i)||!o(e=u,d,F).call(e))return!1;o(n=u,d,E).call(n,["6","4F"])}static setConnection(i=null){var t;if(!o(t=u,d,T).call(t,i))return!1;i.__internal__.serial.connected=!0}};st=new WeakMap,ht=new WeakMap,d=new WeakSet,Wi=function(){if(u.enable===!1)throw new Error("Emulator is disabled");return u.enable},zi=function(i){if(typeof i!="object"||!(i instanceof kt))throw new Error(`Type ${i.typeDevice} is not supported`);return u.instance=i,L(u,st,i.typeDevice),L(u,ht,i.deviceNumber),!0},T=function(i=null){var t,e;return!o(t=u,d,Wi).call(t)||i===null&&u.instance===null?!1:(u.instance===null&&o(e=u,d,zi).call(e,i),!0)},bn=function(){if(O(u,st)!=="locker")throw new Error("This function is only available for Locker devices");return!0},U=function(){if(O(u,st)!=="boardroid")throw new Error("This function is only available for Boardroid devices");return!0},F=function(){if(O(u,st)!=="jofemar")throw new Error("This function is only available for Jofemar devices");return!0},Be=function(){if(O(u,st)==="locker")throw new Error("This function is not available for Locker devices");return!0},E=function(i){u.instance.__emulate({code:i})},mn=function(i,t=null){let e=i[Math.floor(Math.random()*5)];if(t!==null&&!isNaN(parseFloat(t)))switch(t.toString()){case"0.5":e=i[1];break;case"1":e=i[2];break;case"2":e=i[3];break;case"5":e=i[4];break;case"10":e=i[5];break}return e},se=function(i,t=null){let e=i[Math.floor(Math.random()*4)];if(t!==null&&!isNaN(parseFloat(t)))switch(t.toString()){case"20":e=i[0];break;case"50":e=i[1];break;case"100":e=i[2];break;case"200":e=i[3];break;case"500":e=i[4];break}return e},$(u,d),Z(u,"enable",!1),Z(u,"instance",null),$(u,st,null),$(u,ht,1);let Zt=u;const M=class M extends Hn{static typeError(i){const t=new Error;throw t.message=`Type ${i} is not supported`,t.name="DeviceTypeError",t}static addCustom(i,t){typeof M.devices[i]>"u"&&(M.devices[i]=[]),M.add(t)}static add(i){const t=i.typeDevice,e=i.uuid;if(typeof M.devices[t]>"u")return M.typeError(t);if(this.instance.dispatch("change",M.devices),!M.devices[t][e])return M.devices[t][e]=i,this.instance.dispatch("change",M.devices),M.devices[t].indexOf(i)}static get(i,t){return typeof M.devices[i]>"u"?M.typeError(i):M.devices[i][t]}static getJofemarByUuid(i){return M.get("jofemar",i)}static getLockerByUuid(i){return M.get("locker",i)}static getRelayByUuid(i){return M.get("relay",i)}static getBoardroidByUuid(i){return M.get("boardroid",i)}static getArduinoByUuid(i){return M.get("arduino",i)}static getPinPadByUuid(i){return M.get("pinpad",i)}static getAll(i=null){return i===null?M.devices:typeof M.devices[i]>"u"?M.typeError(i):M.devices[i]}static getList(){return Object.values(M.devices).map(t=>Object.values(t)).flat()}static getJofemar(i=1){return Object.values(M.devices.jofemar).find(e=>e.deviceNumber===i)??null}static getBoardroid(i=1){return Object.values(M.devices.boardroid).find(e=>e.deviceNumber===i)??null}static getLocker(i=1){return Object.values(M.devices.locker).find(e=>e.deviceNumber===i)??null}static getRelay(i=1){return Object.values(M.devices.relay).find(e=>e.deviceNumber===i)??null}static getArduino(i=1){return Object.values(M.devices.arduino).find(e=>e.deviceNumber===i)??null}static getPinPad(i=1){return Object.values(M.devices.pinpad).find(e=>e.deviceNumber===i)??null}static getCustom(i,t=1){return typeof M.devices[i]>"u"?M.typeError(i):Object.values(M.devices[i]).find(n=>n.deviceNumber===t)??null}};Z(M,"instance",null),Z(M,"devices",{relay:[],locker:[],jofemar:[],boardroid:[],arduino:[],pinpad:[]});let K=M;K.instance||(K.instance=new K);class kt extends Hn{constructor({filters:t=null,config_port:e=null,no_device:n=1,device_listen_on_port:s=1}={}){super();$(this,B);Z(this,"__internal__",{device_number:1,aux_port_connector:0,last_error:{message:null,action:null,code:null,no_code:0},serial:{connected:!1,port:null,last_action:null,response:{length:null,buffer:new Uint8Array([])},reader:null,input_done:null,output_done:null,input_stream:null,output_stream:null,keep_reading:!0,time_until_send_bytes:void 0,delay_first_connection:200,bytes_connection:null,filters:[],config_port:{baudRate:9600,dataBits:8,stopBits:1,parity:"none",bufferSize:32768,flowControl:"none"},queue:[]},device:{type:"unknown",id:fa(),listen_on_port:null,door_open:!1},time:{response_connection:500,response_general:2e3,response_engines:2e3,sense:100},timeout:{until_response:0},interval:{reconnection:0,waiting_sense:0},dispense:{must_response:!1,dispensing:!1,status:null,counter:0,limit_counter:20,custom_limit_counter:null,backup_dispense:{}}});t&&(this.serialFilters=t),e&&(this.serialConfigPort=e),n&&o(this,B,rr).call(this,n),s&&(typeof s=="number"||typeof s=="string")&&(this.listenOnPort=s),o(this,B,tr).call(this),o(this,B,er).call(this)}set listenOnPort(t){if(t=parseInt(t),isNaN(t)||t<1||t>255)throw new Error("Invalid port number");this.__internal__.device.listen_on_port=t,this.__internal__.serial.bytes_connection=this.serialSetConnectionConstant(t)}get isDoorOpen(){return this.__internal__.device.door_open}get lastAction(){return this.__internal__.serial.last_action}get listenOnPort(){return this.__internal__.device.listen_on_port??1}set serialFilters(t){this.__internal__.serial.filters=t}get serialFilters(){return this.__internal__.serial.filters}set serialConfigPort(t){this.__internal__.serial.config_port=t}get serialConfigPort(){return this.__internal__.serial.config_port}get isConnected(){return this.__internal__.serial.connected}get isDisconnected(){return!this.__internal__.serial.connected}get deviceNumber(){return this.__internal__.device_number}get uuid(){return this.__internal__.device.id}get typeDevice(){return this.__internal__.device.type}get queue(){return this.__internal__.serial.queue}get isDispensing(){return this.__internal__.interval.waiting_sense||this.__internal__.dispense.dispensing}async timeout(t,e){this.__internal__.last_error.message="Operation response timed out.",this.__internal__.last_error.action=e,this.__internal__.last_error.code=t,this.__internal__.timeout.until_response&&(clearTimeout(this.__internal__.timeout.until_response),this.__internal__.timeout.until_response=0),e==="connect"?(this.__internal__.serial.connected=!1,this.dispatch("serial:reconnect",{})):e==="connection:start"?(await this.serialDisconnect(),this.__internal__.serial.connected=!1,this.__internal__.aux_port_connector+=1,await this.serialConnect()):e==="dispense"&&(this.__internal__.dispense.status="no-response"),this.dispatch("serial:timeout",{...this.__internal__.last_error,bytes:t,action:e})}async disconnect(t=null){await this.serialDisconnect(),this.__internal__.serial.connected=!1,this.__internal__.aux_port_connector=0,this.dispatch("serial:disconnected",t),K.instance.dispatch("change")}async connect(){return new Promise((t,e)=>{Wn()||e("Web Serial not supported"),setTimeout(async()=>{await dt(499),await this.serialConnect(),this.isConnected?t(`${this.typeDevice} device ${this.deviceNumber} connected`):e(`${this.typeDevice} device ${this.deviceNumber} not connected`)},1)})}async serialDisconnect(){try{const t=this.__internal__.serial.reader,e=this.__internal__.serial.output_stream;t&&(await t.cancel().catch(s=>this.serialErrors(s)),await this.__internal__.serial.input_done),e&&(await e.getWriter().close(),await this.__internal__.serial.output_done),this.__internal__.serial.connected&&this.__internal__.serial&&await this.__internal__.serial.port.close()}catch(t){this.serialErrors(t)}finally{this.__internal__.serial.reader=null,this.__internal__.serial.input_done=null,this.__internal__.serial.output_stream=null,this.__internal__.serial.output_done=null,this.__internal__.serial.connected=!1,this.__internal__.serial.port=null}}async serialPortsSaved(t){const e=this.serialFilters;if(this.__internal__.aux_port_connector<t.length){const n=this.__internal__.aux_port_connector;this.__internal__.serial.port=t[n]}else this.__internal__.aux_port_connector=0,this.__internal__.serial.port=await navigator.serial.requestPort({filters:e});if(!this.__internal__.serial.port)throw new Error("Select another port please")}serialErrors(t){const e=t.toString().toLowerCase();switch(!0){case e.includes("must be handling a user gesture to show a permission request"):case e.includes("the port is closed."):case e.includes("select another port please"):case e.includes("no port selected by the user"):case e.includes("this readable stream reader has been released and cannot be used to cancel its previous owner stream"):this.dispatch("serial:need-permission",{}),K.instance.dispatch("change");break;case e.includes("the port is already open."):case e.includes("failed to open serial port"):this.serialDisconnect().then(async()=>{this.__internal__.aux_port_connector+=1,await this.serialConnect()});break;case e.includes("cannot read properties of undefined (reading 'writable')"):case e.includes("cannot read properties of null (reading 'writable')"):case e.includes("cannot read property 'writable' of null"):case e.includes("cannot read property 'writable' of undefined"):this.serialDisconnect().then(async()=>{await this.serialConnect()});break;case e.includes("'close' on 'serialport': a call to close() is already in progress."):break;case e.includes("failed to execute 'open' on 'serialport': a call to open() is already in progress."):break;case e.includes("the port is already closed."):break;case e.includes("the device has been lost"):this.dispatch("serial:lost",{}),K.instance.dispatch("change");break;case e.includes("navigator.serial is undefined"):this.dispatch("serial:unsupported",{});break;default:console.error(t);break}this.dispatch("serial:error",t)}async serialConnect(){try{this.dispatch("serial:connecting",{});const t=await o(this,B,Gi).call(this);if(t.length>0)await this.serialPortsSaved(t);else{const s=this.serialFilters;this.__internal__.serial.port=await navigator.serial.requestPort({filters:s})}const e=this.__internal__.serial.port;await e.open(this.serialConfigPort);const n=this;e.onconnect=s=>{n.dispatch("serial:connected",s.detail),K.instance.dispatch("change"),n.__internal__.serial.queue.length>0&&n.dispatch("internal:queue",{})},e.ondisconnect=async s=>{await n.disconnect(s.detail??null)},await dt(this.__internal__.serial.delay_first_connection),this.__internal__.timeout.until_response=setTimeout(async()=>{await n.timeout(n.__internal__.serial.bytes_connection,"connection:start")},this.__internal__.time.response_connection),this.__internal__.serial.last_action="connect",await o(this,B,yn).call(this,this.__internal__.serial.bytes_connection),this.dispatch("serial:sent",{action:"connect",bytes:this.__internal__.serial.bytes_connection}),this.typeDevice==="relay"&&o(this,B,Mt).call(this,["DD","DD"],null),await o(this,B,Zi).call(this)}catch(t){this.serialErrors(t)}}async serialForget(){return await o(this,B,Yi).call(this)}decToHex(t){return parseInt(t,10).toString(16)}hexToDec(t){return parseInt(t,16)}hexMaker(t="00",e=2){return t.toString().padStart(e,"0").toLowerCase()}add0x(t){let e=[];return t.forEach((n,s)=>{e[s]="0x"+n}),e}bytesToHex(t){return this.add0x(Array.from(t,e=>this.hexMaker(e)))}async appendToQueue(t,e){const n=this.bytesToHex(t);if(["connect","connection:start"].includes(e)){if(this.__internal__.serial.connected)return;await this.serialConnect();return}this.__internal__.serial.queue.push({bytes:n,action:e}),this.dispatch("internal:queue",{})}serialSetConnectionConstant(t=1){throw new Error("Method not implemented")}serialMessage(t){throw new Error("Method not implemented")}serialCorruptMessage(t,e){throw new Error("Method not implemented")}clearSerialQueue(){this.__internal__.serial.queue=[]}sumHex(t){let e=0;return t.forEach(n=>{e+=parseInt(n,16)}),e.toString(16)}internalClearSensing(){this.__internal__.interval.waiting_sense&&clearInterval(this.__internal__.interval.waiting_sense),this.__internal__.interval.waiting_sense=0,this.__internal__.dispense.status=null,this.__internal__.dispense.counter=0,this.__internal__.dispense.dispensing=!1}internalDispensingProcess(){let t=this.__internal__.dispense.limit_counter;return this.__internal__.dispense.custom_limit_counter&&(t=this.__internal__.dispense.custom_limit_counter),t+=Math.ceil(t*.6),this.__internal__.dispense.counter>=t?(this.internalClearSensing(),this.__internal__.dispense.status=!1,this.__internal__.dispense.dispensing=!1,!1):(this.__internal__.dispense.counter=parseFloat((.1+this.__internal__.dispense.counter).toFixed(1)),this.__internal__.dispense.counter%1===0&&this.dispatch("dispensing",{status:this.__internal__.dispense.status,counter:this.__internal__.dispense.counter,limit:t}),null)}async internalDispenseStatus(){if(this.__internal__.dispense.must_response&&(await dt(this.__internal__.time.response_engines+10),this.__internal__.dispense.status==="no-response"))return this.internalClearSensing(),this.__internal__.dispense.status=!1,this.dispatch("not-dispensed",{reason:"no-response"}),{status:!1,error:"no-response"};this.__internal__.dispense.status=null,this.__internal__.dispense.dispensing=!0,this.dispatch("internal:dispense:running",{});const t=this;return new Promise(e=>{this.__internal__.interval.waiting_sense=setInterval(()=>{switch(t.__internal__.dispense.status){case null:t.internalDispensingProcess()===!1&&(t.internalClearSensing(),t.dispatch("not-dispensed",{reason:"timeout"}),e({status:!1,error:"timeout"}));break;case!0:t.internalClearSensing(),t.__internal__.dispense.status=!0,t.dispatch("dispensed",{}),e({status:!0,error:null});break;case!1:t.internalClearSensing(),t.__internal__.dispense.status=!1,t.dispatch("not-dispensed",{reason:"no-stock"}),e({status:!1,error:null});break;case"elevator-locked":t.internalClearSensing(),t.__internal__.dispense.status=!1,t.dispatch("not-dispensed",{reason:"elevator-locked"}),e({status:!1,error:"elevator-locked"});break;case"no-response":t.internalClearSensing(),t.__internal__.dispense.status=!1,t.dispatch("not-dispensed",{reason:"no-response"}),e({status:!1,error:"no-response"});break}},this.__internal__.time.sense)})}async internalDispense(t){if(this.isDispensing)throw new Error("Another dispensing process is running");if(!Zt.enable&&!this.__internal__.serial.connected&&(await this.serialConnect(),!this.__internal__.serial.connected))throw new Error("Serial device not connected");return this.__internal__.serial.queue.length===0?(await this.appendToQueue(t,"dispense"),await this.internalDispenseStatus()):new Promise(e=>{const n=setInterval(async()=>{if(this.__internal__.serial.queue.length>0)return;clearInterval(n),await this.appendToQueue(t,"dispense");const s=await this.internalDispenseStatus();e(s)},100)})}__emulate(t){if(typeof t.code!="object"){console.error("Invalid data to make an emulation");return}this.__internal__.serial.connected||(this.__internal__.serial.connected=!0,this.dispatch("serial:connected"),K.instance.dispatch("change"),this.__internal__.interval.reconnection&&(clearInterval(this.__internal__.interval.reconnection),this.__internal__.interval.reconnection=0)),this.__internal__.timeout.until_response&&(clearTimeout(this.__internal__.timeout.until_response),this.__internal__.timeout.until_response=0);const e=[];for(const n in t.code)e.push(t.code[n].toString().padStart(2,"0").toLowerCase());this.serialMessage(e)}toString(){return JSON.stringify({__class:this.typeDevice,device_number:this.deviceNumber,uuid:this.uuid,connected:this.isConnected,connection:this.__internal__.serial.bytes_connection})}softReload(){o(this,B,sr).call(this),this.dispatch("serial:soft-reload",{})}async sendConnect(){await this.appendToQueue(this.__internal__.serial.bytes_connection,"connect")}async sendCustomCode({code:t=[]}={}){await this.appendToQueue(t,"custom")}stringToArrayBuffer(t,e=`
|
|
1
|
+
(function(I,x){typeof exports=="object"&&typeof module<"u"?x(exports):typeof define=="function"&&define.amd?define(["exports"],x):(I=typeof globalThis<"u"?globalThis:I||self,x(I.WebSerial={}))})(this,function(I){"use strict";var wc=Object.defineProperty;var Hi=I=>{throw TypeError(I)};var vc=(I,x,X)=>x in I?wc(I,x,{enumerable:!0,configurable:!0,writable:!0,value:X}):I[x]=X;var Z=(I,x,X)=>vc(I,typeof x!="symbol"?x+"":x,X),_n=(I,x,X)=>x.has(I)||Hi("Cannot "+X);var O=(I,x,X)=>(_n(I,x,"read from private field"),X?X.call(I):x.get(I)),J=(I,x,X)=>x.has(I)?Hi("Cannot add the same private member more than once"):x instanceof WeakSet?x.add(I):x.set(I,X),L=(I,x,X,Vt)=>(_n(I,x,"write to private field"),Vt?Vt.call(I,X):x.set(I,X),X),o=(I,x,X)=>(_n(I,x,"access private method"),X);var st,ht,d,Ki,Wi,T,gn,U,F,Be,E,bn,se,B,zi,mn,Mt,Xi,Gi,$i,Ji,Qi,Zi,Yi,tr,er,nr,ir,rr,re,Ie,sr,nt,G,Pt,R,ar,or,cr,lr,yn,hr,Ft,Ut,Ne,Me,Fe,p,dr,pr,fr,wn,_r,gr,br,mr,yr,wr,vr,Pr,Er,Tr,ae,oe,Cr,ce,Sr,Lt,kr,$,xr,Ar,vn,Dr,Rr,Ir,Pn,En,le,Tn,Or,mt,yt,Ue,Cn,he,Sn,kn,Br,xn,An,Nr,Mr,Qt,Dn,Fr,Ur,Lr,Le,Vr,qr,Rn,jr,Hr,Kr,Wr,zr,Xr,Gr,$r,Jr,In,On,Qr,Zr,Yr,g,ts,es,ns,ot,Ve,is,rs,ss,as,os,cs,ls,hs,us,ds,ps,fs,_s,gs,bs,ms,ys,ws,vs,Ps,Es,Ts,Cs,Ss,ks,xs,ft,Y,qe,tt,wt,As,Ds,Rs,Is,ue,Bn,Nn,je,He,Os,Gt,Nt,$t,w,Bs,Ns,Ke,Ms,Fs,Us,Ls,Vs,qs,js,Hs,Mn,Ks,Ws,zs,Xs,Gs,$s,Js,Qs,Zs,Ys,ta,ea,na,ia,ct,We,ra,sa,aa,oa,Fn,ze,ca,la,Un,Ln,Vn,Jt,ha,ua;const x=[];for(let r=0;r<256;++r)x.push((r+256).toString(16).slice(1));function X(r,i=0){return(x[r[i+0]]+x[r[i+1]]+x[r[i+2]]+x[r[i+3]]+"-"+x[r[i+4]]+x[r[i+5]]+"-"+x[r[i+6]]+x[r[i+7]]+"-"+x[r[i+8]]+x[r[i+9]]+"-"+x[r[i+10]]+x[r[i+11]]+x[r[i+12]]+x[r[i+13]]+x[r[i+14]]+x[r[i+15]]).toLowerCase()}let Vt;const da=new Uint8Array(16);function pa(){if(!Vt){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");Vt=crypto.getRandomValues.bind(crypto)}return Vt(da)}const qn={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function fa(r,i,t){var n;if(qn.randomUUID&&!r)return qn.randomUUID();r=r||{};const e=r.random??((n=r.rng)==null?void 0:n.call(r))??pa();if(e.length<16)throw new Error("Random bytes length must be >= 16");return e[6]=e[6]&15|64,e[8]=e[8]&63|128,X(e)}class jn extends EventTarget{constructor(){super(...arguments);Z(this,"__listeners__",{});Z(this,"__debug__",!1)}dispatch(t,e=null){const n=new Hn(t,{detail:e});this.dispatchEvent(n),this.__debug__&&this.dispatchEvent(new Hn("debug",{detail:{type:t,data:e}}))}dispatchAsync(t,e=null,n=100){const s=this;setTimeout(()=>{s.dispatch(t,e)},n)}on(t,e){typeof this.__listeners__[t]<"u"&&this.__listeners__[t]===!1&&(this.__listeners__[t]=!0),this.addEventListener(t,e)}off(t,e){this.removeEventListener(t,e)}serialRegisterAvailableListener(t){this.__listeners__[t]||(this.__listeners__[t]=!1)}get availableListeners(){return Object.keys(this.__listeners__).sort().map(e=>({type:e,listening:this.__listeners__[e]}))}}class Hn extends CustomEvent{constructor(i,t){super(i,t)}}function dt(r=100){return new Promise(i=>setTimeout(()=>i(),r))}function Kn(){return"serial"in navigator}function Wn(){return"geolocation"in navigator}function _a(){return"crypto"in window}function Xe(r=1){return r*1e3}function Ct(r){return r==null||r===""}const u=class u{static status(i=null){var e,n;if(!o(e=u,d,T).call(e,i))return!1;let t=[];switch(O(u,st)){case"locker":t=["0","8"];break;case"boardroid":t=["2",(5+O(u,ht)).toString(16).toUpperCase()];break;case"jofemar":t=["6"];break;default:return!1}o(n=u,d,E).call(n,t)}static dispensed(i=null){var e,n;if(!o(e=u,d,T).call(e,i))return!1;let t=[];switch(O(u,st)){case"locker":t=["0","7","4","4","4"];break;case"boardroid":t=["2","D7","A","0","0","0","0","0","0","0","0","0","F2"];break;case"jofemar":t=["6","30"];break;default:return!1}o(n=u,d,E).call(n,t)}static notDispensed(i=null){var e,n;if(!o(e=u,d,T).call(e,i))return!1;let t=[];switch(O(u,st)){case"locker":t=["0","7","5","5","5"];break;case"boardroid":t=["2","D7","A","0","0","1","0","0","0","0","0","0","F2"];break;case"jofemar":t=["6","34"];break;default:return!1}o(n=u,d,E).call(n,t)}static gateInactive(i=null){var t;if(!o(t=u,d,T).call(t,i)||!o(this,d,gn).call(this))return!1;o(this,d,E).call(this,["0","7","5","5","5"])}static gateConfigured(i=null){var t;if(!o(t=u,d,T).call(t,i)||!o(this,d,gn).call(this))return!1;o(this,d,E).call(this,["0","6"])}static keyPressed(i=null){var s,a,c;if(!o(s=u,d,T).call(s,i)||!o(a=u,d,F).call(a))return!1;const t=["30","31","32","33","34","35","36","37","38","39","2A","23","41","42","43","44"],e=(128+O(u,ht)).toString(16),n=Math.floor(Math.random()*15);o(c=u,d,E).call(c,["2",e,"54",t[n]])}static doorOpened(i=null){var n,s;if(!o(n=u,d,T).call(n,i)||!o(this,d,Be).call(this))return!1;let t=[];const e=(128+O(u,ht)).toString(16);switch(O(u,st)){case"boardroid":t=["2","D8","dc"];break;case"jofemar":t=["2",e,"50","4F"];break}o(s=u,d,E).call(s,t)}static doorClosed(i=null){var n,s;if(!o(n=u,d,T).call(n,i)||!o(this,d,Be).call(this))return!1;let t=[];const e=(128+O(u,ht)).toString(16);switch(O(u,st)){case"boardroid":t=["2","D8","db"];break;case"jofemar":t=["2",e,"50","43"];break}o(s=u,d,E).call(s,t)}static channelDisconnected(i=null){var e,n,s;if(!o(e=u,d,T).call(e,i)||!o(n=u,d,F).call(n))return!1;const t=(128+O(u,ht)).toString(16);o(s=u,d,E).call(s,["2",t,"43","43","43","FD"])}static channelConnected(i=null){var e,n,s;if(!o(e=u,d,T).call(e,i)||!o(n=u,d,F).call(n))return!1;const t=(128+O(u,ht)).toString(16);o(s=u,d,E).call(s,["2",t,"43","43","43","FC"])}static channelEmpty(i=null){var e,n,s;if(!o(e=u,d,T).call(e,i)||!o(n=u,d,F).call(n))return!1;const t=(128+O(u,ht)).toString(16);o(s=u,d,E).call(s,["2",t,"43","43","43","FF"])}static workingTemperature(i=null){var e,n,s;if(!o(e=u,d,T).call(e,i)||!o(n=u,d,F).call(n))return!1;const t=(128+O(u,ht)).toString(16);o(s=u,d,E).call(s,["2",t,"43","54","16"])}static currentTemperature(i=null){var n,s,a;if(!o(n=u,d,T).call(n,i)||!o(s=u,d,Be).call(s))return!1;let t=[];const e=(128+O(u,ht)).toString(16);switch(O(u,st)){case"boardroid":t=["2","D9","44","30"];break;case"jofemar":t=["2",e,"43","74","2B","30","39","2E","31","7F","43"];break}o(a=u,d,E).call(a,t)}static ready(i=null){var t,e,n;if(!o(t=u,d,T).call(t,i)||!o(e=u,d,F).call(e))return!1;o(n=u,d,E).call(n,["6","30"])}static busy(i=null){var t,e,n;if(!o(t=u,d,T).call(t,i)||!o(e=u,d,F).call(e))return!1;o(n=u,d,E).call(n,["6","31"])}static invalidTray(i=null){var t,e,n;if(!o(t=u,d,T).call(t,i)||!o(e=u,d,F).call(e))return!1;o(n=u,d,E).call(n,["6","32"])}static invalidChannel(i=null){var t,e,n;if(!o(t=u,d,T).call(t,i)||!o(e=u,d,F).call(e))return!1;o(n=u,d,E).call(n,["6","33"])}static emptyChannel(i=null){var t,e,n;if(!o(t=u,d,T).call(t,i)||!o(e=u,d,F).call(e))return!1;o(n=u,d,E).call(n,["6","34"])}static elevatorJam(i=null){var t,e,n;if(!o(t=u,d,T).call(t,i)||!o(e=u,d,F).call(e))return!1;o(n=u,d,E).call(n,["6","35"])}static elevatorMalfunction(i=null){var t,e,n;if(!o(t=u,d,T).call(t,i)||!o(e=u,d,F).call(e))return!1;o(n=u,d,E).call(n,["6","36"])}static phototransistorFailure(i=null){var t,e,n;if(!o(t=u,d,T).call(t,i)||!o(e=u,d,F).call(e))return!1;o(n=u,d,E).call(n,["6","37"])}static allChannelsEmpty(i=null){var t,e,n;if(!o(t=u,d,T).call(t,i)||!o(e=u,d,F).call(e))return!1;o(n=u,d,E).call(n,["6","38"])}static productDetectorFailure(i=null){var t,e,n;if(!o(t=u,d,T).call(t,i)||!o(e=u,d,F).call(e))return!1;o(n=u,d,E).call(n,["6","39"])}static displayDisconnected(i=null){var t,e,n;if(!o(t=u,d,T).call(t,i)||!o(e=u,d,F).call(e))return!1;o(n=u,d,E).call(n,["6","41"])}static productUnderElevator(i=null){var t,e,n;if(!o(t=u,d,T).call(t,i)||!o(e=u,d,F).call(e))return!1;o(n=u,d,E).call(n,["6","42"])}static elevatorSettingAlarm(i=null){var t,e,n;if(!o(t=u,d,T).call(t,i)||!o(e=u,d,F).call(e))return!1;o(n=u,d,E).call(n,["6","43"])}static buttonPanelFailure(i=null){var t,e,n;if(!o(t=u,d,T).call(t,i)||!o(e=u,d,F).call(e))return!1;o(n=u,d,E).call(n,["6","44"])}static errorWritingEeprom(i=null){var t,e,n;if(!o(t=u,d,T).call(t,i)||!o(e=u,d,F).call(e))return!1;o(n=u,d,E).call(n,["6","45"])}static errorControlTemperature(i=null){var t,e,n;if(!o(t=u,d,T).call(t,i)||!o(e=u,d,F).call(e))return!1;o(n=u,d,E).call(n,["6","46"])}static thermometerDisconnected(i=null){var t,e,n;if(!o(t=u,d,T).call(t,i)||!o(e=u,d,F).call(e))return!1;o(n=u,d,E).call(n,["6","47"])}static thermometerMisconfigured(i=null){var t,e,n;if(!o(t=u,d,T).call(t,i)||!o(e=u,d,F).call(e))return!1;o(n=u,d,E).call(n,["6","48"])}static thermometerFailure(i=null){var t,e,n;if(!o(t=u,d,T).call(t,i)||!o(e=u,d,F).call(e))return!1;o(n=u,d,E).call(n,["6","49"])}static errorExtractorConsumption(i=null){var t,e,n;if(!o(t=u,d,T).call(t,i)||!o(e=u,d,F).call(e))return!1;o(n=u,d,E).call(n,["6","4A"])}static channelSearchError(i=null){var t,e,n;if(!o(t=u,d,T).call(t,i)||!o(e=u,d,F).call(e))return!1;o(n=u,d,E).call(n,["6","4B"])}static productExitMouthSearchError(i=null){var t,e,n;if(!o(t=u,d,T).call(t,i)||!o(e=u,d,F).call(e))return!1;o(n=u,d,E).call(n,["6","4C"])}static elevatorInteriorLocked(i=null){var t,e,n;if(!o(t=u,d,T).call(t,i)||!o(e=u,d,F).call(e))return!1;o(n=u,d,E).call(n,["6","4D"])}static productDetectorVerifierError(i=null){var t,e,n;if(!o(t=u,d,T).call(t,i)||!o(e=u,d,F).call(e))return!1;o(n=u,d,E).call(n,["6","4E"])}static waitingForProductRecall(i=null){var t,e,n;if(!o(t=u,d,T).call(t,i)||!o(e=u,d,F).call(e))return!1;o(n=u,d,E).call(n,["6","4F"])}static productExpiredByTemperature(i=null){var t,e,n;if(!o(t=u,d,T).call(t,i)||!o(e=u,d,F).call(e))return!1;o(n=u,d,E).call(n,["6","50"])}static faultyAutomaticDoor(i=null){var t,e,n;if(!o(t=u,d,T).call(t,i)||!o(e=u,d,F).call(e))return!1;o(n=u,d,E).call(n,["6","51"])}static rejectLever(i=null){var t,e,n;if(!o(t=u,d,T).call(t,i)||!o(e=u,d,U).call(e))return!1;o(n=u,d,E).call(n,["2","A0","1"])}static resetCoinPurse(i=null){var t,e,n;if(!o(t=u,d,T).call(t,i)||!o(e=u,d,U).call(e))return!1;o(n=u,d,E).call(n,["2","A0","2"])}static coinInsertedBox(i=null,t=null){var s,a,c,l;if(!o(s=u,d,T).call(s,i)||!o(a=u,d,U).call(a))return!1;const e=["40","41","42","43","44","45"],n=o(c=u,d,bn).call(c,e,t);o(l=u,d,E).call(l,["2","A0",n])}static coinInsertedTube(i=null,t=null){var s,a,c,l;if(!o(s=u,d,T).call(s,i)||!o(a=u,d,U).call(a))return!1;const e=["50","51","52","53","54","55"],n=o(c=u,d,bn).call(c,e,t);o(l=u,d,E).call(l,["2","A0",n])}static banknoteInsertedStacker(i=null,t=null){var s,a,c,l;if(!o(s=u,d,T).call(s,i)||!o(a=u,d,U).call(a))return!1;const e=["80","81","82","83","84"],n=o(c=u,d,se).call(c,e,t);o(l=u,d,E).call(l,["2","B0",n])}static banknoteInsertedEscrow(i=null,t=null){var s,a,c,l;if(!o(s=u,d,T).call(s,i)||!o(a=u,d,U).call(a))return!1;const e=["90","91","92","93","94"],n=o(c=u,d,se).call(c,e,t);o(l=u,d,E).call(l,["2","B0",n])}static banknoteEjected(i=null,t=null){var s,a,c,l;if(!o(s=u,d,T).call(s,i)||!o(a=u,d,U).call(a))return!1;const e=["A0","A1","A2","A3","A4"],n=o(c=u,d,se).call(c,e,t);o(l=u,d,E).call(l,["2","B0",n])}static banknoteInsertedRecycler(i=null,t=null){var s,a,c,l;if(!o(s=u,d,T).call(s,i)||!o(a=u,d,U).call(a))return!1;const e=["B0","B1","B2","B3","B4"],n=o(c=u,d,se).call(c,e,t);o(l=u,d,E).call(l,["2","B0",n])}static banknoteTaken(i=null){var t,e,n;if(!o(t=u,d,T).call(t,i)||!o(e=u,d,U).call(e))return!1;o(n=u,d,E).call(n,["2","B0","2a"])}static coinPurseEnabled(i=null){var t,e,n;if(!o(t=u,d,T).call(t,i)||!o(e=u,d,U).call(e))return!1;o(n=u,d,E).call(n,["2","D0","1"])}static coinPurseDisabled(i=null){var t,e,n;if(!o(t=u,d,T).call(t,i)||!o(e=u,d,U).call(e))return!1;o(n=u,d,E).call(n,["2","D0","0"])}static billPurseDisabled(i=null){var t,e,n;if(!o(t=u,d,T).call(t,i)||!o(e=u,d,U).call(e))return!1;o(n=u,d,E).call(n,["2","D1","0","0"])}static billPurseEnabled(i=null){var t,e,n;if(!o(t=u,d,T).call(t,i)||!o(e=u,d,U).call(e))return!1;o(n=u,d,E).call(n,["2","D1","1","1"])}static readTubes(i=null){var h,f,_;if(!o(h=u,d,T).call(h,i)||!o(f=u,d,U).call(f))return!1;const t=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f"],[e,n,s,a,c,l]=[t[Math.floor(Math.random()*30)],t[Math.floor(Math.random()*30)],t[Math.floor(Math.random()*30)],t[Math.floor(Math.random()*30)],t[Math.floor(Math.random()*30)],t[Math.floor(Math.random()*30)]];o(_=u,d,E).call(_,["2","D2",e,n,s,a,c,l])}static readBillPurse(i=null,t=null){var n,s,a,c;if(!o(n=u,d,T).call(n,i)||!o(s=u,d,U).call(s))return!1;let e=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c"];if(i._recycler.ict){const l=e[Math.floor(Math.random()*31)];let h="0",f="0",_="0",m="0",P="0";if(t!==null&&!isNaN(parseInt(t)))switch(t.toString()){case"20":h=l;break;case"50":f=l;break;case"100":_=l;break;case"200":m=l;break;case"500":P=l;break}else switch(i._recycler.bill){case 0:h=l;break;case 1:f=l;break;case 2:_=l;break;case 3:m=l;break;case 4:P=l;break}o(a=u,d,E).call(a,["2","D3",h,f,_,m,P,"0"])}else{const[l,h,f,_,m,P]=[e[Math.floor(Math.random()*30)],e[Math.floor(Math.random()*30)],e[Math.floor(Math.random()*30)],e[Math.floor(Math.random()*2)],e[Math.floor(Math.random())],e[Math.floor(Math.random())]];o(c=u,d,E).call(c,["2","D3",l,h,f,_,m,P])}}static banknoteAccepted(i=null){var t,e,n;if(!o(t=u,d,T).call(t,i)||!o(e=u,d,U).call(e))return!1;o(n=u,d,E).call(n,["2","D4","1"])}static banknoteRejected(i=null){var t,e,n;if(!o(t=u,d,T).call(t,i)||!o(e=u,d,U).call(e))return!1;o(n=u,d,E).call(n,["2","D4","0"])}static banknotesDispensed(i=null){var e,n,s,a;if(!o(e=u,d,T).call(e,i)||!o(n=u,d,U).call(n))return!1;let t=["1","2","3","4","5","6","7","8","9","a","b","c","d","e","f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c"];if(i._recycler.ict){const c=t[Math.floor(Math.random()*30)];let l="0",h="0",f="0",_="0",m="0";switch(i._recycler.bill){case 0:l=c;break;case 1:h=c;break;case 2:f=c;break;case 3:_=c;break;case 4:m=c;break}o(s=u,d,E).call(s,["2","D5",l,h,f,_,m,"0"])}else{const[c,l,h,f,_,m]=[t[Math.floor(Math.random()*30)],t[Math.floor(Math.random()*30)],t[Math.floor(Math.random()*30)],t[Math.floor(Math.random()*2)],t[Math.floor(Math.random())],t[Math.floor(Math.random())]];o(a=u,d,E).call(a,["2","D5",c,l,h,f,_,m])}}static coinsDispensed(i=null){var t,e,n;if(!o(t=u,d,T).call(t,i)||!o(e=u,d,U).call(e))return!1;o(n=u,d,E).call(n,["2","D6"])}static relayOn(i=null){var t,e,n;if(!o(t=u,d,T).call(t,i)||!o(e=u,d,U).call(e))return!1;o(n=u,d,E).call(n,["2","DA","1"])}static relayOff(i=null){var t,e,n;if(!o(t=u,d,T).call(t,i)||!o(e=u,d,U).call(e))return!1;o(n=u,d,E).call(n,["2","DA","0"])}static nayaxEnabled(i=null){var t,e,n;if(!o(t=u,d,T).call(t,i)||!o(e=u,d,U).call(e))return!1;o(n=u,d,E).call(n,["2","DD","1"])}static nayaxDisabled(i=null){var t,e,n;if(!o(t=u,d,T).call(t,i)||!o(e=u,d,U).call(e))return!1;o(n=u,d,E).call(n,["2","DD","0"])}static nayaxPreCreditAuthorized(i=null){var t,e,n;if(!o(t=u,d,T).call(t,i)||!o(e=u,d,U).call(e))return!1;o(n=u,d,E).call(n,["2","DD","3"])}static nayaxCancelRequest(i=null){var t,e,n;if(!o(t=u,d,T).call(t,i)||!o(e=u,d,U).call(e))return!1;o(n=u,d,E).call(n,["2","DD","4"])}static nayaxSellApproved(i=null){var t,e,n;if(!o(t=u,d,T).call(t,i)||!o(e=u,d,U).call(e))return!1;o(n=u,d,E).call(n,["2","DD","5"])}static nayaxSellDenied(i=null){var t,e,n;if(!o(t=u,d,T).call(t,i)||!o(e=u,d,U).call(e))return!1;o(n=u,d,E).call(n,["2","DD","6"])}static nayaxEndSession(i=null){var t,e,n;if(!o(t=u,d,T).call(t,i)||!o(e=u,d,U).call(e))return!1;o(n=u,d,E).call(n,["2","DD","7"])}static nayaxCancelled(i=null){var t,e,n;if(!o(t=u,d,T).call(t,i)||!o(e=u,d,U).call(e))return!1;o(n=u,d,E).call(n,["2","DD","8"])}static nayaxDispensed(i=null){var t,e,n;if(!o(t=u,d,T).call(t,i)||!o(e=u,d,U).call(e))return!1;o(n=u,d,E).call(n,["2","DD","A","0"])}static nayaxNotDispensed(i=null){var t,e,n;if(!o(t=u,d,T).call(t,i)||!o(e=u,d,U).call(e))return!1;o(n=u,d,E).call(n,["2","DD","A","1"])}static fullTray(i=null){var t,e,n;if(!o(t=u,d,T).call(t,i)||!o(e=u,d,F).call(e))return!1;o(n=u,d,E).call(n,["6","4F"])}static setConnection(i=null){var t;if(!o(t=u,d,T).call(t,i))return!1;i.__internal__.serial.connected=!0}};st=new WeakMap,ht=new WeakMap,d=new WeakSet,Ki=function(){if(u.enable===!1)throw new Error("Emulator is disabled");return u.enable},Wi=function(i){if(typeof i!="object"||!(i instanceof kt))throw new Error(`Type ${i.typeDevice} is not supported`);return u.instance=i,L(u,st,i.typeDevice),L(u,ht,i.deviceNumber),!0},T=function(i=null){var t,e;return!o(t=u,d,Ki).call(t)||i===null&&u.instance===null?!1:(u.instance===null&&o(e=u,d,Wi).call(e,i),!0)},gn=function(){if(O(u,st)!=="locker")throw new Error("This function is only available for Locker devices");return!0},U=function(){if(O(u,st)!=="boardroid")throw new Error("This function is only available for Boardroid devices");return!0},F=function(){if(O(u,st)!=="jofemar")throw new Error("This function is only available for Jofemar devices");return!0},Be=function(){if(O(u,st)==="locker")throw new Error("This function is not available for Locker devices");return!0},E=function(i){u.instance.__emulate({code:i})},bn=function(i,t=null){let e=i[Math.floor(Math.random()*5)];if(t!==null&&!isNaN(parseFloat(t)))switch(t.toString()){case"0.5":e=i[1];break;case"1":e=i[2];break;case"2":e=i[3];break;case"5":e=i[4];break;case"10":e=i[5];break}return e},se=function(i,t=null){let e=i[Math.floor(Math.random()*4)];if(t!==null&&!isNaN(parseFloat(t)))switch(t.toString()){case"20":e=i[0];break;case"50":e=i[1];break;case"100":e=i[2];break;case"200":e=i[3];break;case"500":e=i[4];break}return e},J(u,d),Z(u,"enable",!1),Z(u,"instance",null),J(u,st,null),J(u,ht,1);let Zt=u;const M=class M extends jn{static typeError(i){const t=new Error;throw t.message=`Type ${i} is not supported`,t.name="DeviceTypeError",t}static addCustom(i,t){typeof M.devices[i]>"u"&&(M.devices[i]=[]),M.add(t)}static add(i){const t=i.typeDevice,e=i.uuid;if(typeof M.devices[t]>"u")return M.typeError(t);if(this.instance.dispatch("change",M.devices),!M.devices[t][e])return M.devices[t][e]=i,this.instance.dispatch("change",M.devices),M.devices[t].indexOf(i)}static get(i,t){return typeof M.devices[i]>"u"?M.typeError(i):M.devices[i][t]}static getJofemarByUuid(i){return M.get("jofemar",i)}static getLockerByUuid(i){return M.get("locker",i)}static getRelayByUuid(i){return M.get("relay",i)}static getBoardroidByUuid(i){return M.get("boardroid",i)}static getArduinoByUuid(i){return M.get("arduino",i)}static getPinPadByUuid(i){return M.get("pinpad",i)}static getAll(i=null){return i===null?M.devices:typeof M.devices[i]>"u"?M.typeError(i):M.devices[i]}static getList(){return Object.values(M.devices).map(t=>Object.values(t)).flat()}static getJofemar(i=1){return Object.values(M.devices.jofemar).find(e=>e.deviceNumber===i)??null}static getBoardroid(i=1){return Object.values(M.devices.boardroid).find(e=>e.deviceNumber===i)??null}static getLocker(i=1){return Object.values(M.devices.locker).find(e=>e.deviceNumber===i)??null}static getRelay(i=1){return Object.values(M.devices.relay).find(e=>e.deviceNumber===i)??null}static getArduino(i=1){return Object.values(M.devices.arduino).find(e=>e.deviceNumber===i)??null}static getPinPad(i=1){return Object.values(M.devices.pinpad).find(e=>e.deviceNumber===i)??null}static getCustom(i,t=1){return typeof M.devices[i]>"u"?M.typeError(i):Object.values(M.devices[i]).find(n=>n.deviceNumber===t)??null}};Z(M,"instance",null),Z(M,"devices",{relay:[],locker:[],jofemar:[],boardroid:[],arduino:[],pinpad:[]});let K=M;K.instance||(K.instance=new K);class kt extends jn{constructor({filters:t=null,config_port:e=null,no_device:n=1,device_listen_on_port:s=1}={}){super();J(this,B);Z(this,"__internal__",{device_number:1,aux_port_connector:0,last_error:{message:null,action:null,code:null,no_code:0},serial:{connected:!1,port:null,last_action:null,response:{length:null,buffer:new Uint8Array([])},reader:null,input_done:null,output_done:null,input_stream:null,output_stream:null,keep_reading:!0,time_until_send_bytes:void 0,delay_first_connection:200,bytes_connection:null,filters:[],config_port:{baudRate:9600,dataBits:8,stopBits:1,parity:"none",bufferSize:32768,flowControl:"none"},queue:[]},device:{type:"unknown",id:fa(),listen_on_port:null,door_open:!1},time:{response_connection:500,response_general:2e3,response_engines:2e3,sense:100},timeout:{until_response:0},interval:{reconnection:0,waiting_sense:0},dispense:{must_response:!1,dispensing:!1,status:null,counter:0,limit_counter:20,custom_limit_counter:null,backup_dispense:{}}});if(!("serial"in navigator))throw new Error("Web Serial not supported");t&&(this.serialFilters=t),e&&(this.serialConfigPort=e),n&&o(this,B,ir).call(this,n),s&&(typeof s=="number"||typeof s=="string")&&(this.listenOnPort=s),o(this,B,Yi).call(this),o(this,B,tr).call(this)}set listenOnPort(t){if(t=parseInt(t),isNaN(t)||t<1||t>255)throw new Error("Invalid port number");this.__internal__.device.listen_on_port=t,this.__internal__.serial.bytes_connection=this.serialSetConnectionConstant(t)}get isDoorOpen(){return this.__internal__.device.door_open}get lastAction(){return this.__internal__.serial.last_action}get listenOnPort(){return this.__internal__.device.listen_on_port??1}set serialFilters(t){this.__internal__.serial.filters=t}get serialFilters(){return this.__internal__.serial.filters}set serialConfigPort(t){this.__internal__.serial.config_port=t}get serialConfigPort(){return this.__internal__.serial.config_port}get isConnected(){return this.__internal__.serial.connected}get isDisconnected(){return!this.__internal__.serial.connected}get deviceNumber(){return this.__internal__.device_number}get uuid(){return this.__internal__.device.id}get typeDevice(){return this.__internal__.device.type}get queue(){return this.__internal__.serial.queue}get isDispensing(){return this.__internal__.interval.waiting_sense||this.__internal__.dispense.dispensing}async timeout(t,e){this.__internal__.last_error.message="Operation response timed out.",this.__internal__.last_error.action=e,this.__internal__.last_error.code=t,this.__internal__.timeout.until_response&&(clearTimeout(this.__internal__.timeout.until_response),this.__internal__.timeout.until_response=0),e==="connect"?(this.__internal__.serial.connected=!1,this.dispatch("serial:reconnect",{})):e==="connection:start"?(await this.serialDisconnect(),this.__internal__.serial.connected=!1,this.__internal__.aux_port_connector+=1,await this.serialConnect()):e==="dispense"&&(this.__internal__.dispense.status="no-response"),this.dispatch("serial:timeout",{...this.__internal__.last_error,bytes:t,action:e})}async disconnect(t=null){await this.serialDisconnect(),this.__internal__.serial.connected=!1,this.__internal__.aux_port_connector=0,this.dispatch("serial:disconnected",t),K.instance.dispatch("change")}async connect(){return new Promise((t,e)=>{Kn()||e("Web Serial not supported"),setTimeout(async()=>{await dt(499),await this.serialConnect(),this.isConnected?t(`${this.typeDevice} device ${this.deviceNumber} connected`):e(`${this.typeDevice} device ${this.deviceNumber} not connected`)},1)})}async serialDisconnect(){try{const t=this.__internal__.serial.reader,e=this.__internal__.serial.output_stream;t&&(await t.cancel().catch(s=>this.serialErrors(s)),await this.__internal__.serial.input_done),e&&(await e.getWriter().close(),await this.__internal__.serial.output_done),this.__internal__.serial.connected&&this.__internal__.serial&&await this.__internal__.serial.port.close()}catch(t){this.serialErrors(t)}finally{this.__internal__.serial.reader=null,this.__internal__.serial.input_done=null,this.__internal__.serial.output_stream=null,this.__internal__.serial.output_done=null,this.__internal__.serial.connected=!1,this.__internal__.serial.port=null}}async serialPortsSaved(t){const e=this.serialFilters;if(this.__internal__.aux_port_connector<t.length){const n=this.__internal__.aux_port_connector;this.__internal__.serial.port=t[n]}else this.__internal__.aux_port_connector=0,this.__internal__.serial.port=await navigator.serial.requestPort({filters:e});if(!this.__internal__.serial.port)throw new Error("Select another port please")}serialErrors(t){const e=t.toString().toLowerCase();switch(!0){case e.includes("must be handling a user gesture to show a permission request"):case e.includes("the port is closed."):case e.includes("select another port please"):case e.includes("no port selected by the user"):case e.includes("this readable stream reader has been released and cannot be used to cancel its previous owner stream"):this.dispatch("serial:need-permission",{}),K.instance.dispatch("change");break;case e.includes("the port is already open."):case e.includes("failed to open serial port"):this.serialDisconnect().then(async()=>{this.__internal__.aux_port_connector+=1,await this.serialConnect()});break;case e.includes("cannot read properties of undefined (reading 'writable')"):case e.includes("cannot read properties of null (reading 'writable')"):case e.includes("cannot read property 'writable' of null"):case e.includes("cannot read property 'writable' of undefined"):this.serialDisconnect().then(async()=>{await this.serialConnect()});break;case e.includes("'close' on 'serialport': a call to close() is already in progress."):break;case e.includes("failed to execute 'open' on 'serialport': a call to open() is already in progress."):break;case e.includes("the port is already closed."):break;case e.includes("the device has been lost"):this.dispatch("serial:lost",{}),K.instance.dispatch("change");break;case e.includes("navigator.serial is undefined"):this.dispatch("serial:unsupported",{});break;default:console.error(t);break}this.dispatch("serial:error",t)}async serialConnect(){try{this.dispatch("serial:connecting",{});const t=await o(this,B,Xi).call(this);if(t.length>0)await this.serialPortsSaved(t);else{const s=this.serialFilters;this.__internal__.serial.port=await navigator.serial.requestPort({filters:s})}const e=this.__internal__.serial.port;await e.open(this.serialConfigPort);const n=this;e.onconnect=s=>{n.dispatch("serial:connected",s.detail),K.instance.dispatch("change"),n.__internal__.serial.queue.length>0&&n.dispatch("internal:queue",{})},e.ondisconnect=async s=>{await n.disconnect(s.detail??null)},await dt(this.__internal__.serial.delay_first_connection),this.__internal__.timeout.until_response=setTimeout(async()=>{await n.timeout(n.__internal__.serial.bytes_connection,"connection:start")},this.__internal__.time.response_connection),this.__internal__.serial.last_action="connect",await o(this,B,mn).call(this,this.__internal__.serial.bytes_connection),this.dispatch("serial:sent",{action:"connect",bytes:this.__internal__.serial.bytes_connection}),this.typeDevice==="relay"&&o(this,B,Mt).call(this,["DD","DD"],null),await o(this,B,Qi).call(this)}catch(t){this.serialErrors(t)}}async serialForget(){return await o(this,B,Zi).call(this)}decToHex(t){return parseInt(t,10).toString(16)}hexToDec(t){return parseInt(t,16)}hexMaker(t="00",e=2){return t.toString().padStart(e,"0").toLowerCase()}add0x(t){let e=[];return t.forEach((n,s)=>{e[s]="0x"+n}),e}bytesToHex(t){return this.add0x(Array.from(t,e=>this.hexMaker(e)))}async appendToQueue(t,e){const n=this.bytesToHex(t);if(["connect","connection:start"].includes(e)){if(this.__internal__.serial.connected)return;await this.serialConnect();return}this.__internal__.serial.queue.push({bytes:n,action:e}),this.dispatch("internal:queue",{})}serialSetConnectionConstant(t=1){throw new Error("Method not implemented")}serialMessage(t){throw new Error("Method not implemented")}serialCorruptMessage(t,e){throw new Error("Method not implemented")}clearSerialQueue(){this.__internal__.serial.queue=[]}sumHex(t){let e=0;return t.forEach(n=>{e+=parseInt(n,16)}),e.toString(16)}internalClearSensing(){this.__internal__.interval.waiting_sense&&clearInterval(this.__internal__.interval.waiting_sense),this.__internal__.interval.waiting_sense=0,this.__internal__.dispense.status=null,this.__internal__.dispense.counter=0,this.__internal__.dispense.dispensing=!1}internalDispensingProcess(){let t=this.__internal__.dispense.limit_counter;return this.__internal__.dispense.custom_limit_counter&&(t=this.__internal__.dispense.custom_limit_counter),t+=Math.ceil(t*.6),this.__internal__.dispense.counter>=t?(this.internalClearSensing(),this.__internal__.dispense.status=!1,this.__internal__.dispense.dispensing=!1,!1):(this.__internal__.dispense.counter=parseFloat((.1+this.__internal__.dispense.counter).toFixed(1)),this.__internal__.dispense.counter%1===0&&this.dispatch("dispensing",{status:this.__internal__.dispense.status,counter:this.__internal__.dispense.counter,limit:t}),null)}async internalDispenseStatus(){if(this.__internal__.dispense.must_response&&(await dt(this.__internal__.time.response_engines+10),this.__internal__.dispense.status==="no-response"))return this.internalClearSensing(),this.__internal__.dispense.status=!1,this.dispatch("not-dispensed",{reason:"no-response"}),{status:!1,error:"no-response"};this.__internal__.dispense.status=null,this.__internal__.dispense.dispensing=!0,this.dispatch("internal:dispense:running",{});const t=this;return new Promise(e=>{this.__internal__.interval.waiting_sense=setInterval(()=>{switch(t.__internal__.dispense.status){case null:t.internalDispensingProcess()===!1&&(t.internalClearSensing(),t.dispatch("not-dispensed",{reason:"timeout"}),e({status:!1,error:"timeout"}));break;case!0:t.internalClearSensing(),t.__internal__.dispense.status=!0,t.dispatch("dispensed",{}),e({status:!0,error:null});break;case!1:t.internalClearSensing(),t.__internal__.dispense.status=!1,t.dispatch("not-dispensed",{reason:"no-stock"}),e({status:!1,error:null});break;case"elevator-locked":t.internalClearSensing(),t.__internal__.dispense.status=!1,t.dispatch("not-dispensed",{reason:"elevator-locked"}),e({status:!1,error:"elevator-locked"});break;case"no-response":t.internalClearSensing(),t.__internal__.dispense.status=!1,t.dispatch("not-dispensed",{reason:"no-response"}),e({status:!1,error:"no-response"});break}},this.__internal__.time.sense)})}async internalDispense(t){if(this.isDispensing)throw new Error("Another dispensing process is running");if(!Zt.enable&&!this.__internal__.serial.connected&&(await this.serialConnect(),!this.__internal__.serial.connected))throw new Error("Serial device not connected");return this.__internal__.serial.queue.length===0?(await this.appendToQueue(t,"dispense"),await this.internalDispenseStatus()):new Promise(e=>{const n=setInterval(async()=>{if(this.__internal__.serial.queue.length>0)return;clearInterval(n),await this.appendToQueue(t,"dispense");const s=await this.internalDispenseStatus();e(s)},100)})}__emulate(t){if(typeof t.code!="object"){console.error("Invalid data to make an emulation");return}this.__internal__.serial.connected||(this.__internal__.serial.connected=!0,this.dispatch("serial:connected"),K.instance.dispatch("change"),this.__internal__.interval.reconnection&&(clearInterval(this.__internal__.interval.reconnection),this.__internal__.interval.reconnection=0)),this.__internal__.timeout.until_response&&(clearTimeout(this.__internal__.timeout.until_response),this.__internal__.timeout.until_response=0);const e=[];for(const n in t.code)e.push(t.code[n].toString().padStart(2,"0").toLowerCase());this.serialMessage(e)}toString(){return JSON.stringify({__class:this.typeDevice,device_number:this.deviceNumber,uuid:this.uuid,connected:this.isConnected,connection:this.__internal__.serial.bytes_connection})}softReload(){o(this,B,rr).call(this),this.dispatch("serial:soft-reload",{})}async sendConnect(){await this.appendToQueue(this.__internal__.serial.bytes_connection,"connect")}async sendCustomCode({code:t=[]}={}){await this.appendToQueue(t,"custom")}stringToArrayBuffer(t,e=`
|
|
2
2
|
`){return this.parseStringToTextEncoder(t,e).buffer}parseStringToTextEncoder(t="",e=`
|
|
3
3
|
`){const n=new TextEncoder;return t+=e,n.encode(t)}parseStringToBytes(t="",e=`
|
|
4
|
-
`){const n=this.parseStringToTextEncoder(t,e);return Array.from(n).map(s=>s.toString(16))}parseUint8ToHex(t){return Array.from(t).map(e=>e.toString(16))}parseHexToUint8(t){return new Uint8Array(t.map(e=>parseInt(e,16)))}parseUint8ArrayToString(t){t=new Uint8Array(t),t=this.parseUint8ToHex(t);const e=t.map(n=>parseInt(n,16));return String.fromCharCode(...e).replace(/[\n\r]+/g,"")}hexToAscii(t){let e=t.toString(),n="";for(let s=0;s<e.length;s+=2)n+=String.fromCharCode(parseInt(e.substring(s,2),16));return n}asciiToHex(t){const e=[];for(let n=0,s=t.length;n<s;n++){const a=Number(t.charCodeAt(n)).toString(16);e.push(a)}return e.join("")}}B=new WeakSet,Xi=function(t){return!!(t.readable&&t.writable)},yn=async function(t){const e=this.__internal__.serial.port;if(!e){if(Zt.enable)return;throw new Error("The port is closed.")}const n=new Uint8Array(t),s=e.writable.getWriter();await s.write(n),s.releaseLock()},Mt=function(t=[],e=null){if(t&&t.length>0){this.__internal__.serial.connected||(this.dispatch("serial:connected"),K.instance.dispatch("change")),this.__internal__.serial.connected=!0,this.__internal__.interval.reconnection&&(clearInterval(this.__internal__.interval.reconnection),this.__internal__.interval.reconnection=0),this.__internal__.timeout.until_response&&(clearTimeout(this.__internal__.timeout.until_response),this.__internal__.timeout.until_response=0);const n=[];for(const s in t)n.push(t[s].toString().padStart(2,"0").toLowerCase());this.serialMessage(n)}else this.serialCorruptMessage(t,e);this.__internal__.serial.queue.length!==0&&this.dispatch("internal:queue",{})},Gi=async function(){const t=this.serialFilters,e=await navigator.serial.getPorts({filters:t});return t.length===0?e:e.filter(s=>{const a=s.getInfo();return t.some(c=>a.usbProductId===c.usbProductId&&a.usbVendorId===c.usbVendorId)}).filter(s=>!o(this,B,Xi).call(this,s))},Ji=function(t){if(t){const e=this.__internal__.serial.response.buffer;let n=new Uint8Array(e.length+t.byteLength);n.set(e,0),n.set(new Uint8Array(t),e.length),this.__internal__.serial.response.buffer=n}},$i=async function(){this.__internal__.serial.time_until_send_bytes&&(clearTimeout(this.__internal__.serial.time_until_send_bytes),this.__internal__.serial.time_until_send_bytes=0),this.__internal__.serial.time_until_send_bytes=setTimeout(()=>{let t=[];for(const e in this.__internal__.serial.response.buffer)t.push(this.__internal__.serial.response.buffer[e].toString(16));this.__internal__.serial.response.buffer&&o(this,B,Mt).call(this,t),this.__internal__.serial.response.buffer=new Uint8Array(0)},400)},Qi=async function(){if(this.__internal__.serial.response.length===this.__internal__.serial.response.buffer.length){const t=[];for(const e in this.__internal__.serial.response.buffer)t.push(this.__internal__.serial.response.buffer[e].toString(16));await o(this,B,Mt).call(this,t),this.__internal__.serial.response.buffer=new Uint8Array(0)}else if(this.__internal__.serial.response.length<this.__internal__.serial.response.buffer.length){let t=[];for(let n=0;n<this.__internal__.serial.response.length;n++)t[n]=this.__internal__.serial.response.buffer[n];if(t.length===this.__internal__.serial.response.length){const n=[];for(const s in t)n.push(t[s].toString(16));await o(this,B,Mt).call(this,n),this.__internal__.serial.response.buffer=new Uint8Array(0);return}t=[];const e=this.__internal__.serial.response.length*2;if(this.__internal__.serial.response.buffer.length===e){for(let n=14;n<e;n++)t[n-this.__internal__.serial.response.length]=this.__internal__.serial.response.buffer[n];if(t.length===this.__internal__.serial.response.length){const n=[];for(const s in t)n.push(t[s].toString(16));await o(this,B,Mt).call(this,n),this.__internal__.serial.response.buffer=new Uint8Array(0)}}}},Zi=async function(){const t=this.__internal__.serial.port;for(;t.readable&&this.__internal__.serial.keep_reading;){const e=t.readable.getReader();this.__internal__.serial.reader=e;try{let n=!0;for(;n;){const{value:s,done:a}=await e.read();if(a){e.releaseLock(),this.__internal__.serial.keep_reading=!1,n=!1;break}o(this,B,Ji).call(this,s),this.__internal__.serial.response.length===null?await o(this,B,$i).call(this):await o(this,B,Qi).call(this)}}catch(n){this.serialErrors(n)}finally{e.releaseLock()}}this.__internal__.serial.keep_reading=!0,await this.__internal__.serial.port.close()},Yi=async function(){return typeof window>"u"?!1:"serial"in navigator&&"forget"in window.SerialPort.prototype?(await this.__internal__.serial.port.forget(),!0):!1},tr=function(){["serial:connected","serial:connecting","serial:reconnect","serial:timeout","serial:disconnected","serial:sent","serial:soft-reload","serial:message","dispensed","not-dispensed","dispensing","unknown","serial:need-permission","serial:lost","serial:unsupported","serial:error","debug"].forEach(e=>{this.serialRegisterAvailableListener(e)})},er=function(){const t=this;this.on("internal:queue",async()=>{var e;await o(e=t,B,ir).call(e)}),o(this,B,nr).call(this)},nr=function(){const t=this;navigator.serial.addEventListener("connect",async()=>{t.isDisconnected&&await t.serialConnect().catch(()=>{})})},ir=async function(){if(!this.__internal__.serial.connected){await this.serialConnect();return}if(this.__internal__.timeout.until_response||this.__internal__.serial.queue.length===0)return;const t=this.__internal__.serial.queue[0];let e=this.__internal__.time.response_general;t.action==="connect"?e=this.__internal__.time.response_connection:t.action==="dispense"&&(e=this.__internal__.time.response_engines),this.__internal__.timeout.until_response=setTimeout(async()=>{await this.timeout(t.bytes,t.action)},e),this.__internal__.serial.last_action=t.action??"unknown",await o(this,B,yn).call(this,t.bytes),this.dispatch("serial:sent",{action:t.action,bytes:t.bytes}),this.typeDevice==="relay"&&o(this,B,Mt).call(this,["DD","DD"],null);const n=[...this.__internal__.serial.queue];this.__internal__.serial.queue=n.splice(1)},rr=function(t=1){this.__internal__.device_number=t,this.__internal__.serial.bytes_connection=this.serialSetConnectionConstant(t)},sr=function(){this.__internal__.last_error={message:null,action:null,code:null,no_code:0}};class ga extends kt{constructor({filters:t=null,config_port:e=null,no_device:n=1}={}){super({filters:t,config_port:e,no_device:n});$(this,Ie);$(this,re,{activate:["A0","01","01","A2"],deactivate:["A0","01","00","A1"]});if(this.__internal__.device.type="relay",K.getCustom(this.typeDevice,n))throw new Error(`Device ${this.typeDevice} ${n} already exists`);o(this,Ie,ar).call(this)}serialMessage(t){const e={code:t,name:null,description:null,request:null,no_code:0};switch(t[1].toString()){case"dd":e.name="Connection with the serial device completed.",e.description="Your connection with the serial device was successfully completed.",e.request="connect",e.no_code=100;break;case"de":break;default:e.name="Unrecognized response",e.description="The response of application was received, but dont identify with any of current parameters",e.request="undefined",e.no_code=400;break}this.dispatch("serial:message",e)}serialRelaySumHex(t){let e=0;return t.forEach((n,s)=>{s!==3&&(e+=parseInt(n,16))}),e.toString(16).toUpperCase()}serialSetConnectionConstant(t=1){const e=["A0","01","00","A1"];return e[1]=this.hexMaker(this.decToHex(t.toString())),e[3]=this.serialRelaySumHex(e),this.add0x(e)}async turnOn(){const t=O(this,re).activate;t[3]=this.serialRelaySumHex(t),await this.appendToQueue(t,"relay:turn-on")}async turnOff(){const t=O(this,re).deactivate;t[3]=this.serialRelaySumHex(t),await this.appendToQueue(t,"relay:turn-off")}async toggle({inverse:t=!1,ms:e=300}={}){const n=this;t?(await n.turnOff(),await dt(e),await n.turnOn()):(await n.turnOn(),await dt(e),await n.turnOff())}}re=new WeakMap,Ie=new WeakSet,ar=function(){K.add(this)};class ba extends kt{constructor({filters:t=null,config_port:e=null,no_device:n=1,device_listen_on_port:s=3}={}){super({filters:t,config_port:e,no_device:n,device_listen_on_port:s});$(this,R);$(this,nt,!1);$(this,G,0);$(this,Pt,0);if(this.__internal__.device.type="locker",K.getCustom(this.typeDevice,n))throw new Error(`Device ${this.typeDevice} ${n} already exists`);this.__internal__.device.milliseconds=666,this.__internal__.dispense.limit_counter=1,o(this,R,cr).call(this),o(this,R,or).call(this)}serialMessage(t){const e={code:t,name:null,description:null,request:null,no_code:0};switch(t[1]){case"08":e.name="Connection with the serial device completed.",e.description="Your connection with the serial device was successfully completed.",e.request="connect",e.no_code=100;break;case"07":switch(t[4]){case"00":e.name="Cell closed.",e.description="The selected cell is closed.",e.request="dispense",e.no_code=1102,this.__internal__.dispense.status=!1,this.dispatch("dispensed",{}),O(this,nt)&&O(this,G)>=89?(e.finished_test=!0,L(this,nt,!1),L(this,G,0)):O(this,nt)&&(e.finished_test=!1);break;case"01":case"04":e.name="Cell open.",e.description="The selected cell was open successfully.",e.request="dispense",e.no_code=102,this.__internal__.dispense.status=!0,this.dispatch("dispensed",{}),O(this,nt)&&O(this,G)>=89?(e.finished_test=!0,L(this,nt,!1),L(this,G,0)):O(this,nt)&&(e.finished_test=!1);break;case"05":e.name="Cell inactive.",e.description="The selected cell is inactive or doesn't exist.",e.request="dispense",e.no_code=101,this.__internal__.dispense.status=!1,this.dispatch("not-dispensed",{}),O(this,nt)&&O(this,G)>=89?(e.finished_test=!0,L(this,nt,!1),L(this,G,0)):O(this,nt)&&(e.finished_test=!1);break}break;case"06":e.name="Configuration applied.",e.description="The configuration was successfully applied.",e.request="configure cell",e.no_code=103;break;default:e.request="undefined",e.name="Response unrecognized",e.description="The response of application was received, but dont identify with any of current parameters",e.no_code=400;break}this.dispatch("serial:message",e)}serialSetConnectionConstant(t=3){return this.add0x(this.serialLockerGetConnectionCmd(t))}serialLockerCmdMaker(t){const e=this.__internal__.device.milliseconds;let n=null;try{n=new Uint8Array(t.length+8),n.set(t,2),n[0]=2,n[1]=t.length+4,n[n.length-2]=3;let s=0;for(let l=1;l<t.length;l++)s+=t[l],s*=parseInt(Math.pow(2,l-1).toString());n[t.length+2]=s%256,n[t.length+3]=e*3%256,n[t.length+4]=e*8%256;let a=0;for(let l=3;l<t.length+5;l++)a+=n[l];n[t.length+5]=a%256;let c=0;for(let l=0;l<n.length-1;l++)c^=n[l];n[n.length-1]=c}catch(s){this.serialErrors(`Error generating command: ${s.message}`),n=null}return n}serialLockerHexCmd(t){const e=this.serialLockerCmdMaker(t),n=[];for(let s=0;s<e.length;s++)n.push(this.decToHex(e[s]));return n}serialLockerGetConnectionCmd(t=3){if(t<1||t>255)throw new Error("Invalid port number");return this.serialLockerHexCmd(new Uint8Array([0,t]))}parseCellToColumnRow(t){const e=Math.floor((t-1)/10)+1;let n=t%8;return n===0&&(n=8),[e,n]}async dispense({cell:t=1}={}){t=o(this,R,Ft).call(this,t);const e=o(this,R,ur).call(this,t);return await this.internalDispense(e)}async status({cell:t=1}={}){t=o(this,R,Ft).call(this,t);const e=o(this,R,lr).call(this,t);return await this.appendToQueue(e,"status")}async lightScan({since:t=0,until:e=10}={}){if(t<0||t>10)throw new Error("Invalid since number");if(e<0||e>10)throw new Error("Invalid until number");const n=o(this,R,hr).call(this,t,e);return await this.appendToQueue(n,"light-scan")}async enable({cell:t=1}={}){t=o(this,R,Ft).call(this,t);const[e,n]=this.parseCellToColumnRow(t),s=o(this,R,wn).call(this,{enable:!0,column:e,row:n});await this.appendToQueue(s,"activate")}async disable({cell:t=1}={}){t=o(this,R,Ft).call(this,t);const[e,n]=this.parseCellToColumnRow(t),s=o(this,R,wn).call(this,{enable:!1,column:e,row:n});await this.appendToQueue(s,"disable")}async openAll(){if(this.isDispensing)throw new Error("Another dispensing process is running");o(this,R,Ut).call(this),L(this,nt,!0),o(this,R,Ne).call(this);const t=[];for(let e=1;e<=90;e++){const n=await this.dispense(e);t.push(n),L(this,G,e),o(this,R,Ne).call(this)}L(this,G,90),o(this,R,Ne).call(this,t),o(this,R,Ut).call(this)}async enableAll(){o(this,R,Ut).call(this),L(this,nt,!0),o(this,R,Me).call(this);for(let t=1;t<=90;t++)await this.enable(t),L(this,G,t),o(this,R,Me).call(this);L(this,G,90),o(this,R,Me).call(this),o(this,R,Ut).call(this)}async disableAll(){o(this,R,Ut).call(this),L(this,nt,!0),o(this,R,Fe).call(this);for(let t=1;t<=90;t++)await this.enable(t),L(this,G,t),o(this,R,Fe).call(this);L(this,G,90),o(this,R,Fe).call(this),o(this,R,Ut).call(this)}}nt=new WeakMap,G=new WeakMap,Pt=new WeakMap,R=new WeakSet,or=function(){const t=["percentage:disable","percentage:enable","percentage:open"];for(const e of t)this.serialRegisterAvailableListener(e)},cr=function(){K.add(this)},lr=function(t=1){return t=o(this,R,Ft).call(this,t),this.serialLockerHexCmd(new Uint8Array([16,this.__internal__.device.listen_on_port,t]))},hr=function(t=0,e=10){return this.serialLockerHexCmd(new Uint8Array([32,this.__internal__.device.listen_on_port,t,e]))},wn=function({enable:t=!0,column:e=0,row:n=10}={}){if(e<0||e>8)throw new Error("Invalid column number");if(n<0||n>10)throw new Error("Invalid row number");let s=1;return t||(s=0),this.serialLockerHexCmd(new Uint8Array([48,this.__internal__.device.listen_on_port,e,n,s]))},ur=function(t=1){t=o(this,R,Ft).call(this,t);const e=this.__internal__.device.milliseconds,n=e%256,s=Math.floor(e/3)%256;return this.serialLockerHexCmd(new Uint8Array([64,this.__internal__.device.listen_on_port,t,n,s]))},Ft=function(t){const e=parseInt(t);if(isNaN(e)||e<1||e>90)throw new Error("Invalid cell number");return e},Ut=function(){L(this,nt,!1),L(this,G,0),L(this,Pt,0)},Ne=function(t=null){L(this,Pt,Math.round(O(this,G)*100/90)),this.dispatch("percentage:open",{percentage:O(this,Pt),dispensed:t})},Me=function(){L(this,Pt,Math.round(O(this,G)*100/90)),this.dispatch("percentage:enable",{percentage:O(this,Pt)})},Fe=function(){L(this,Pt,Math.round(O(this,G)*100/90)),this.dispatch("percentage:disable",{percentage:O(this,Pt)})};var ma="0123456789abcdefghijklmnopqrstuvwxyz";function St(r){return ma.charAt(r)}function ya(r,i){return r&i}function de(r,i){return r|i}function Xn(r,i){return r^i}function Gn(r,i){return r&~i}function wa(r){if(r==0)return-1;var i=0;return r&65535||(r>>=16,i+=16),r&255||(r>>=8,i+=8),r&15||(r>>=4,i+=4),r&3||(r>>=2,i+=2),r&1||++i,i}function va(r){for(var i=0;r!=0;)r&=r-1,++i;return i}var qt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Jn="=";function pe(r){var i,t,e="";for(i=0;i+3<=r.length;i+=3)t=parseInt(r.substring(i,i+3),16),e+=qt.charAt(t>>6)+qt.charAt(t&63);for(i+1==r.length?(t=parseInt(r.substring(i,i+1),16),e+=qt.charAt(t<<2)):i+2==r.length&&(t=parseInt(r.substring(i,i+2),16),e+=qt.charAt(t>>2)+qt.charAt((t&3)<<4));(e.length&3)>0;)e+=Jn;return e}function $n(r){var i="",t,e=0,n=0;for(t=0;t<r.length&&r.charAt(t)!=Jn;++t){var s=qt.indexOf(r.charAt(t));s<0||(e==0?(i+=St(s>>2),n=s&3,e=1):e==1?(i+=St(n<<2|s>>4),n=s&15,e=2):e==2?(i+=St(n),i+=St(s>>2),n=s&3,e=3):(i+=St(n<<2|s>>4),i+=St(s&15),e=0))}return e==1&&(i+=St(n<<2)),i}var jt,Pa={decode:function(r){var i;if(jt===void 0){var t="0123456789ABCDEF",e=` \f
|
|
4
|
+
`){const n=this.parseStringToTextEncoder(t,e);return Array.from(n).map(s=>s.toString(16))}parseUint8ToHex(t){return Array.from(t).map(e=>e.toString(16))}parseHexToUint8(t){return new Uint8Array(t.map(e=>parseInt(e,16)))}parseUint8ArrayToString(t){t=new Uint8Array(t),t=this.parseUint8ToHex(t);const e=t.map(n=>parseInt(n,16));return String.fromCharCode(...e).replace(/[\n\r]+/g,"")}hexToAscii(t){let e=t.toString(),n="";for(let s=0;s<e.length;s+=2)n+=String.fromCharCode(parseInt(e.substring(s,2),16));return n}asciiToHex(t){const e=[];for(let n=0,s=t.length;n<s;n++){const a=Number(t.charCodeAt(n)).toString(16);e.push(a)}return e.join("")}}B=new WeakSet,zi=function(t){return!!(t.readable&&t.writable)},mn=async function(t){const e=this.__internal__.serial.port;if(!e){if(Zt.enable)return;throw new Error("The port is closed.")}const n=new Uint8Array(t),s=e.writable.getWriter();await s.write(n),s.releaseLock()},Mt=function(t=[],e=null){if(t&&t.length>0){this.__internal__.serial.connected||(this.dispatch("serial:connected"),K.instance.dispatch("change")),this.__internal__.serial.connected=!0,this.__internal__.interval.reconnection&&(clearInterval(this.__internal__.interval.reconnection),this.__internal__.interval.reconnection=0),this.__internal__.timeout.until_response&&(clearTimeout(this.__internal__.timeout.until_response),this.__internal__.timeout.until_response=0);const n=[];for(const s in t)n.push(t[s].toString().padStart(2,"0").toLowerCase());this.serialMessage(n)}else this.serialCorruptMessage(t,e);this.__internal__.serial.queue.length!==0&&this.dispatch("internal:queue",{})},Xi=async function(){const t=this.serialFilters,e=await navigator.serial.getPorts({filters:t});return t.length===0?e:e.filter(s=>{const a=s.getInfo();return t.some(c=>a.usbProductId===c.usbProductId&&a.usbVendorId===c.usbVendorId)}).filter(s=>!o(this,B,zi).call(this,s))},Gi=function(t){if(t){const e=this.__internal__.serial.response.buffer;let n=new Uint8Array(e.length+t.byteLength);n.set(e,0),n.set(new Uint8Array(t),e.length),this.__internal__.serial.response.buffer=n}},$i=async function(){this.__internal__.serial.time_until_send_bytes&&(clearTimeout(this.__internal__.serial.time_until_send_bytes),this.__internal__.serial.time_until_send_bytes=0),this.__internal__.serial.time_until_send_bytes=setTimeout(()=>{let t=[];for(const e in this.__internal__.serial.response.buffer)t.push(this.__internal__.serial.response.buffer[e].toString(16));this.__internal__.serial.response.buffer&&o(this,B,Mt).call(this,t),this.__internal__.serial.response.buffer=new Uint8Array(0)},400)},Ji=async function(){if(this.__internal__.serial.response.length===this.__internal__.serial.response.buffer.length){const t=[];for(const e in this.__internal__.serial.response.buffer)t.push(this.__internal__.serial.response.buffer[e].toString(16));await o(this,B,Mt).call(this,t),this.__internal__.serial.response.buffer=new Uint8Array(0)}else if(this.__internal__.serial.response.length<this.__internal__.serial.response.buffer.length){let t=[];for(let n=0;n<this.__internal__.serial.response.length;n++)t[n]=this.__internal__.serial.response.buffer[n];if(t.length===this.__internal__.serial.response.length){const n=[];for(const s in t)n.push(t[s].toString(16));await o(this,B,Mt).call(this,n),this.__internal__.serial.response.buffer=new Uint8Array(0);return}t=[];const e=this.__internal__.serial.response.length*2;if(this.__internal__.serial.response.buffer.length===e){for(let n=14;n<e;n++)t[n-this.__internal__.serial.response.length]=this.__internal__.serial.response.buffer[n];if(t.length===this.__internal__.serial.response.length){const n=[];for(const s in t)n.push(t[s].toString(16));await o(this,B,Mt).call(this,n),this.__internal__.serial.response.buffer=new Uint8Array(0)}}}},Qi=async function(){const t=this.__internal__.serial.port;for(;t.readable&&this.__internal__.serial.keep_reading;){const e=t.readable.getReader();this.__internal__.serial.reader=e;try{let n=!0;for(;n;){const{value:s,done:a}=await e.read();if(a){e.releaseLock(),this.__internal__.serial.keep_reading=!1,n=!1;break}o(this,B,Gi).call(this,s),this.__internal__.serial.response.length===null?await o(this,B,$i).call(this):await o(this,B,Ji).call(this)}}catch(n){this.serialErrors(n)}finally{e.releaseLock()}}this.__internal__.serial.keep_reading=!0,await this.__internal__.serial.port.close()},Zi=async function(){return typeof window>"u"?!1:"serial"in navigator&&"forget"in window.SerialPort.prototype?(await this.__internal__.serial.port.forget(),!0):!1},Yi=function(){["serial:connected","serial:connecting","serial:reconnect","serial:timeout","serial:disconnected","serial:sent","serial:soft-reload","serial:message","dispensed","not-dispensed","dispensing","unknown","serial:need-permission","serial:lost","serial:unsupported","serial:error","debug"].forEach(e=>{this.serialRegisterAvailableListener(e)})},tr=function(){const t=this;this.on("internal:queue",async()=>{var e;await o(e=t,B,nr).call(e)}),o(this,B,er).call(this)},er=function(){const t=this;navigator.serial.addEventListener("connect",async()=>{t.isDisconnected&&await t.serialConnect().catch(()=>{})})},nr=async function(){if(!this.__internal__.serial.connected){await this.serialConnect();return}if(this.__internal__.timeout.until_response||this.__internal__.serial.queue.length===0)return;const t=this.__internal__.serial.queue[0];let e=this.__internal__.time.response_general;t.action==="connect"?e=this.__internal__.time.response_connection:t.action==="dispense"&&(e=this.__internal__.time.response_engines),this.__internal__.timeout.until_response=setTimeout(async()=>{await this.timeout(t.bytes,t.action)},e),this.__internal__.serial.last_action=t.action??"unknown",await o(this,B,mn).call(this,t.bytes),this.dispatch("serial:sent",{action:t.action,bytes:t.bytes}),this.typeDevice==="relay"&&o(this,B,Mt).call(this,["DD","DD"],null);const n=[...this.__internal__.serial.queue];this.__internal__.serial.queue=n.splice(1)},ir=function(t=1){this.__internal__.device_number=t,this.__internal__.serial.bytes_connection=this.serialSetConnectionConstant(t)},rr=function(){this.__internal__.last_error={message:null,action:null,code:null,no_code:0}};class ga extends kt{constructor({filters:t=null,config_port:e=null,no_device:n=1}={}){super({filters:t,config_port:e,no_device:n});J(this,Ie);J(this,re,{activate:["A0","01","01","A2"],deactivate:["A0","01","00","A1"]});if(this.__internal__.device.type="relay",K.getCustom(this.typeDevice,n))throw new Error(`Device ${this.typeDevice} ${n} already exists`);o(this,Ie,sr).call(this)}serialMessage(t){const e={code:t,name:null,description:null,request:null,no_code:0};switch(t[1].toString()){case"dd":e.name="Connection with the serial device completed.",e.description="Your connection with the serial device was successfully completed.",e.request="connect",e.no_code=100;break;case"de":break;default:e.name="Unrecognized response",e.description="The response of application was received, but dont identify with any of current parameters",e.request="undefined",e.no_code=400;break}this.dispatch("serial:message",e)}serialRelaySumHex(t){let e=0;return t.forEach((n,s)=>{s!==3&&(e+=parseInt(n,16))}),e.toString(16).toUpperCase()}serialSetConnectionConstant(t=1){const e=["A0","01","00","A1"];return e[1]=this.hexMaker(this.decToHex(t.toString())),e[3]=this.serialRelaySumHex(e),this.add0x(e)}async turnOn(){const t=O(this,re).activate;t[3]=this.serialRelaySumHex(t),await this.appendToQueue(t,"relay:turn-on")}async turnOff(){const t=O(this,re).deactivate;t[3]=this.serialRelaySumHex(t),await this.appendToQueue(t,"relay:turn-off")}async toggle({inverse:t=!1,ms:e=300}={}){const n=this;t?(await n.turnOff(),await dt(e),await n.turnOn()):(await n.turnOn(),await dt(e),await n.turnOff())}}re=new WeakMap,Ie=new WeakSet,sr=function(){K.add(this)};class ba extends kt{constructor({filters:t=null,config_port:e=null,no_device:n=1,device_listen_on_port:s=3}={}){super({filters:t,config_port:e,no_device:n,device_listen_on_port:s});J(this,R);J(this,nt,!1);J(this,G,0);J(this,Pt,0);if(this.__internal__.device.type="locker",K.getCustom(this.typeDevice,n))throw new Error(`Device ${this.typeDevice} ${n} already exists`);this.__internal__.device.milliseconds=666,this.__internal__.dispense.limit_counter=1,o(this,R,or).call(this),o(this,R,ar).call(this)}serialMessage(t){const e={code:t,name:null,description:null,request:null,no_code:0};switch(t[1]){case"08":e.name="Connection with the serial device completed.",e.description="Your connection with the serial device was successfully completed.",e.request="connect",e.no_code=100;break;case"07":switch(t[4]){case"00":e.name="Cell closed.",e.description="The selected cell is closed.",e.request="dispense",e.no_code=1102,this.__internal__.dispense.status=!1,this.dispatch("dispensed",{}),O(this,nt)&&O(this,G)>=89?(e.finished_test=!0,L(this,nt,!1),L(this,G,0)):O(this,nt)&&(e.finished_test=!1);break;case"01":case"04":e.name="Cell open.",e.description="The selected cell was open successfully.",e.request="dispense",e.no_code=102,this.__internal__.dispense.status=!0,this.dispatch("dispensed",{}),O(this,nt)&&O(this,G)>=89?(e.finished_test=!0,L(this,nt,!1),L(this,G,0)):O(this,nt)&&(e.finished_test=!1);break;case"05":e.name="Cell inactive.",e.description="The selected cell is inactive or doesn't exist.",e.request="dispense",e.no_code=101,this.__internal__.dispense.status=!1,this.dispatch("not-dispensed",{}),O(this,nt)&&O(this,G)>=89?(e.finished_test=!0,L(this,nt,!1),L(this,G,0)):O(this,nt)&&(e.finished_test=!1);break}break;case"06":e.name="Configuration applied.",e.description="The configuration was successfully applied.",e.request="configure cell",e.no_code=103;break;default:e.request="undefined",e.name="Response unrecognized",e.description="The response of application was received, but dont identify with any of current parameters",e.no_code=400;break}this.dispatch("serial:message",e)}serialSetConnectionConstant(t=3){return this.add0x(this.serialLockerGetConnectionCmd(t))}serialLockerCmdMaker(t){const e=this.__internal__.device.milliseconds;let n=null;try{n=new Uint8Array(t.length+8),n.set(t,2),n[0]=2,n[1]=t.length+4,n[n.length-2]=3;let s=0;for(let l=1;l<t.length;l++)s+=t[l],s*=parseInt(Math.pow(2,l-1).toString());n[t.length+2]=s%256,n[t.length+3]=e*3%256,n[t.length+4]=e*8%256;let a=0;for(let l=3;l<t.length+5;l++)a+=n[l];n[t.length+5]=a%256;let c=0;for(let l=0;l<n.length-1;l++)c^=n[l];n[n.length-1]=c}catch(s){this.serialErrors(`Error generating command: ${s.message}`),n=null}return n}serialLockerHexCmd(t){const e=this.serialLockerCmdMaker(t),n=[];for(let s=0;s<e.length;s++)n.push(this.decToHex(e[s]));return n}serialLockerGetConnectionCmd(t=3){if(t<1||t>255)throw new Error("Invalid port number");return this.serialLockerHexCmd(new Uint8Array([0,t]))}parseCellToColumnRow(t){const e=Math.floor((t-1)/10)+1;let n=t%8;return n===0&&(n=8),[e,n]}async dispense({cell:t=1}={}){t=o(this,R,Ft).call(this,t);const e=o(this,R,hr).call(this,t);return await this.internalDispense(e)}async status({cell:t=1}={}){t=o(this,R,Ft).call(this,t);const e=o(this,R,cr).call(this,t);return await this.appendToQueue(e,"status")}async lightScan({since:t=0,until:e=10}={}){if(t<0||t>10)throw new Error("Invalid since number");if(e<0||e>10)throw new Error("Invalid until number");const n=o(this,R,lr).call(this,t,e);return await this.appendToQueue(n,"light-scan")}async enable({cell:t=1}={}){t=o(this,R,Ft).call(this,t);const[e,n]=this.parseCellToColumnRow(t),s=o(this,R,yn).call(this,{enable:!0,column:e,row:n});await this.appendToQueue(s,"activate")}async disable({cell:t=1}={}){t=o(this,R,Ft).call(this,t);const[e,n]=this.parseCellToColumnRow(t),s=o(this,R,yn).call(this,{enable:!1,column:e,row:n});await this.appendToQueue(s,"disable")}async openAll(){if(this.isDispensing)throw new Error("Another dispensing process is running");o(this,R,Ut).call(this),L(this,nt,!0),o(this,R,Ne).call(this);const t=[];for(let e=1;e<=90;e++){const n=await this.dispense(e);t.push(n),L(this,G,e),o(this,R,Ne).call(this)}L(this,G,90),o(this,R,Ne).call(this,t),o(this,R,Ut).call(this)}async enableAll(){o(this,R,Ut).call(this),L(this,nt,!0),o(this,R,Me).call(this);for(let t=1;t<=90;t++)await this.enable(t),L(this,G,t),o(this,R,Me).call(this);L(this,G,90),o(this,R,Me).call(this),o(this,R,Ut).call(this)}async disableAll(){o(this,R,Ut).call(this),L(this,nt,!0),o(this,R,Fe).call(this);for(let t=1;t<=90;t++)await this.enable(t),L(this,G,t),o(this,R,Fe).call(this);L(this,G,90),o(this,R,Fe).call(this),o(this,R,Ut).call(this)}}nt=new WeakMap,G=new WeakMap,Pt=new WeakMap,R=new WeakSet,ar=function(){const t=["percentage:disable","percentage:enable","percentage:open"];for(const e of t)this.serialRegisterAvailableListener(e)},or=function(){K.add(this)},cr=function(t=1){return t=o(this,R,Ft).call(this,t),this.serialLockerHexCmd(new Uint8Array([16,this.__internal__.device.listen_on_port,t]))},lr=function(t=0,e=10){return this.serialLockerHexCmd(new Uint8Array([32,this.__internal__.device.listen_on_port,t,e]))},yn=function({enable:t=!0,column:e=0,row:n=10}={}){if(e<0||e>8)throw new Error("Invalid column number");if(n<0||n>10)throw new Error("Invalid row number");let s=1;return t||(s=0),this.serialLockerHexCmd(new Uint8Array([48,this.__internal__.device.listen_on_port,e,n,s]))},hr=function(t=1){t=o(this,R,Ft).call(this,t);const e=this.__internal__.device.milliseconds,n=e%256,s=Math.floor(e/3)%256;return this.serialLockerHexCmd(new Uint8Array([64,this.__internal__.device.listen_on_port,t,n,s]))},Ft=function(t){const e=parseInt(t);if(isNaN(e)||e<1||e>90)throw new Error("Invalid cell number");return e},Ut=function(){L(this,nt,!1),L(this,G,0),L(this,Pt,0)},Ne=function(t=null){L(this,Pt,Math.round(O(this,G)*100/90)),this.dispatch("percentage:open",{percentage:O(this,Pt),dispensed:t})},Me=function(){L(this,Pt,Math.round(O(this,G)*100/90)),this.dispatch("percentage:enable",{percentage:O(this,Pt)})},Fe=function(){L(this,Pt,Math.round(O(this,G)*100/90)),this.dispatch("percentage:disable",{percentage:O(this,Pt)})};var ma="0123456789abcdefghijklmnopqrstuvwxyz";function St(r){return ma.charAt(r)}function ya(r,i){return r&i}function de(r,i){return r|i}function zn(r,i){return r^i}function Xn(r,i){return r&~i}function wa(r){if(r==0)return-1;var i=0;return r&65535||(r>>=16,i+=16),r&255||(r>>=8,i+=8),r&15||(r>>=4,i+=4),r&3||(r>>=2,i+=2),r&1||++i,i}function va(r){for(var i=0;r!=0;)r&=r-1,++i;return i}var qt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Gn="=";function pe(r){var i,t,e="";for(i=0;i+3<=r.length;i+=3)t=parseInt(r.substring(i,i+3),16),e+=qt.charAt(t>>6)+qt.charAt(t&63);for(i+1==r.length?(t=parseInt(r.substring(i,i+1),16),e+=qt.charAt(t<<2)):i+2==r.length&&(t=parseInt(r.substring(i,i+2),16),e+=qt.charAt(t>>2)+qt.charAt((t&3)<<4));(e.length&3)>0;)e+=Gn;return e}function $n(r){var i="",t,e=0,n=0;for(t=0;t<r.length&&r.charAt(t)!=Gn;++t){var s=qt.indexOf(r.charAt(t));s<0||(e==0?(i+=St(s>>2),n=s&3,e=1):e==1?(i+=St(n<<2|s>>4),n=s&15,e=2):e==2?(i+=St(n),i+=St(s>>2),n=s&3,e=3):(i+=St(n<<2|s>>4),i+=St(s&15),e=0))}return e==1&&(i+=St(n<<2)),i}var jt,Pa={decode:function(r){var i;if(jt===void 0){var t="0123456789ABCDEF",e=` \f
|
|
5
5
|
\r \u2028\u2029`;for(jt={},i=0;i<16;++i)jt[t.charAt(i)]=i;for(t=t.toLowerCase(),i=10;i<16;++i)jt[t.charAt(i)]=i;for(i=0;i<e.length;++i)jt[e.charAt(i)]=-1}var n=[],s=0,a=0;for(i=0;i<r.length;++i){var c=r.charAt(i);if(c=="=")break;if(c=jt[c],c!=-1){if(c===void 0)throw new Error("Illegal character at offset "+i);s|=c,++a>=2?(n[n.length]=s,s=0,a=0):s<<=4}}if(a)throw new Error("Hex encoding incomplete: 4 bits missing");return n}},Rt,Ge={decode:function(r){var i;if(Rt===void 0){var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",e=`= \f
|
|
6
|
-
\r \u2028\u2029`;for(Rt=Object.create(null),i=0;i<64;++i)Rt[t.charAt(i)]=i;for(Rt["-"]=62,Rt._=63,i=0;i<e.length;++i)Rt[e.charAt(i)]=-1}var n=[],s=0,a=0;for(i=0;i<r.length;++i){var c=r.charAt(i);if(c=="=")break;if(c=Rt[c],c!=-1){if(c===void 0)throw new Error("Illegal character at offset "+i);s|=c,++a>=4?(n[n.length]=s>>16,n[n.length]=s>>8&255,n[n.length]=s&255,s=0,a=0):s<<=6}}switch(a){case 1:throw new Error("Base64 encoding incomplete: at least 2 bits missing");case 2:n[n.length]=s>>10;break;case 3:n[n.length]=s>>16,n[n.length]=s>>8&255;break}return n},re:/-----BEGIN [^-]+-----([A-Za-z0-9+\/=\s]+)-----END [^-]+-----|begin-base64[^\n]+\n([A-Za-z0-9+\/=\s]+)====/,unarmor:function(r){var i=Ge.re.exec(r);if(i)if(i[1])r=i[1];else if(i[2])r=i[2];else throw new Error("RegExp out of sync");return Ge.decode(r)}},Ht=1e13,Yt=function(){function r(i){this.buf=[+i||0]}return r.prototype.mulAdd=function(i,t){var e=this.buf,n=e.length,s,a;for(s=0;s<n;++s)a=e[s]*i+t,a<Ht?t=0:(t=0|a/Ht,a-=t*Ht),e[s]=a;t>0&&(e[s]=t)},r.prototype.sub=function(i){var t=this.buf,e=t.length,n,s;for(n=0;n<e;++n)s=t[n]-i,s<0?(s+=Ht,i=1):i=0,t[n]=s;for(;t[t.length-1]===0;)t.pop()},r.prototype.toString=function(i){if((i||10)!=10)throw new Error("only base 10 is supported");for(var t=this.buf,e=t[t.length-1].toString(),n=t.length-2;n>=0;--n)e+=(Ht+t[n]).toString().substring(1);return e},r.prototype.valueOf=function(){for(var i=this.buf,t=0,e=i.length-1;e>=0;--e)t=t*Ht+i[e];return t},r.prototype.simplify=function(){var i=this.buf;return i.length==1?i[0]:this},r}(),
|
|
6
|
+
\r \u2028\u2029`;for(Rt=Object.create(null),i=0;i<64;++i)Rt[t.charAt(i)]=i;for(Rt["-"]=62,Rt._=63,i=0;i<e.length;++i)Rt[e.charAt(i)]=-1}var n=[],s=0,a=0;for(i=0;i<r.length;++i){var c=r.charAt(i);if(c=="=")break;if(c=Rt[c],c!=-1){if(c===void 0)throw new Error("Illegal character at offset "+i);s|=c,++a>=4?(n[n.length]=s>>16,n[n.length]=s>>8&255,n[n.length]=s&255,s=0,a=0):s<<=6}}switch(a){case 1:throw new Error("Base64 encoding incomplete: at least 2 bits missing");case 2:n[n.length]=s>>10;break;case 3:n[n.length]=s>>16,n[n.length]=s>>8&255;break}return n},re:/-----BEGIN [^-]+-----([A-Za-z0-9+\/=\s]+)-----END [^-]+-----|begin-base64[^\n]+\n([A-Za-z0-9+\/=\s]+)====/,unarmor:function(r){var i=Ge.re.exec(r);if(i)if(i[1])r=i[1];else if(i[2])r=i[2];else throw new Error("RegExp out of sync");return Ge.decode(r)}},Ht=1e13,Yt=function(){function r(i){this.buf=[+i||0]}return r.prototype.mulAdd=function(i,t){var e=this.buf,n=e.length,s,a;for(s=0;s<n;++s)a=e[s]*i+t,a<Ht?t=0:(t=0|a/Ht,a-=t*Ht),e[s]=a;t>0&&(e[s]=t)},r.prototype.sub=function(i){var t=this.buf,e=t.length,n,s;for(n=0;n<e;++n)s=t[n]-i,s<0?(s+=Ht,i=1):i=0,t[n]=s;for(;t[t.length-1]===0;)t.pop()},r.prototype.toString=function(i){if((i||10)!=10)throw new Error("only base 10 is supported");for(var t=this.buf,e=t[t.length-1].toString(),n=t.length-2;n>=0;--n)e+=(Ht+t[n]).toString().substring(1);return e},r.prototype.valueOf=function(){for(var i=this.buf,t=0,e=i.length-1;e>=0;--e)t=t*Ht+i[e];return t},r.prototype.simplify=function(){var i=this.buf;return i.length==1?i[0]:this},r}(),Jn="…",Ea=/^(\d\d)(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])([01]\d|2[0-3])(?:([0-5]\d)(?:([0-5]\d)(?:[.,](\d{1,3}))?)?)?(Z|[-+](?:[0]\d|1[0-2])([0-5]\d)?)?$/,Ta=/^(\d\d\d\d)(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])([01]\d|2[0-3])(?:([0-5]\d)(?:([0-5]\d)(?:[.,](\d{1,3}))?)?)?(Z|[-+](?:[0]\d|1[0-2])([0-5]\d)?)?$/;function Kt(r,i){return r.length>i&&(r=r.substring(0,i)+Jn),r}var $e=function(){function r(i,t){this.hexDigits="0123456789ABCDEF",i instanceof r?(this.enc=i.enc,this.pos=i.pos):(this.enc=i,this.pos=t)}return r.prototype.get=function(i){if(i===void 0&&(i=this.pos++),i>=this.enc.length)throw new Error("Requesting byte offset ".concat(i," on a stream of length ").concat(this.enc.length));return typeof this.enc=="string"?this.enc.charCodeAt(i):this.enc[i]},r.prototype.hexByte=function(i){return this.hexDigits.charAt(i>>4&15)+this.hexDigits.charAt(i&15)},r.prototype.hexDump=function(i,t,e){for(var n="",s=i;s<t;++s)if(n+=this.hexByte(this.get(s)),e!==!0)switch(s&15){case 7:n+=" ";break;case 15:n+=`
|
|
7
7
|
`;break;default:n+=" "}return n},r.prototype.isASCII=function(i,t){for(var e=i;e<t;++e){var n=this.get(e);if(n<32||n>176)return!1}return!0},r.prototype.parseStringISO=function(i,t){for(var e="",n=i;n<t;++n)e+=String.fromCharCode(this.get(n));return e},r.prototype.parseStringUTF=function(i,t){for(var e="",n=i;n<t;){var s=this.get(n++);s<128?e+=String.fromCharCode(s):s>191&&s<224?e+=String.fromCharCode((s&31)<<6|this.get(n++)&63):e+=String.fromCharCode((s&15)<<12|(this.get(n++)&63)<<6|this.get(n++)&63)}return e},r.prototype.parseStringBMP=function(i,t){for(var e="",n,s,a=i;a<t;)n=this.get(a++),s=this.get(a++),e+=String.fromCharCode(n<<8|s);return e},r.prototype.parseTime=function(i,t,e){var n=this.parseStringISO(i,t),s=(e?Ea:Ta).exec(n);return s?(e&&(s[1]=+s[1],s[1]+=+s[1]<70?2e3:1900),n=s[1]+"-"+s[2]+"-"+s[3]+" "+s[4],s[5]&&(n+=":"+s[5],s[6]&&(n+=":"+s[6],s[7]&&(n+="."+s[7]))),s[8]&&(n+=" UTC",s[8]!="Z"&&(n+=s[8],s[9]&&(n+=":"+s[9]))),n):"Unrecognized time: "+n},r.prototype.parseInteger=function(i,t){for(var e=this.get(i),n=e>127,s=n?255:0,a,c="";e==s&&++i<t;)e=this.get(i);if(a=t-i,a===0)return n?-1:0;if(a>4){for(c=e,a<<=3;!((+c^s)&128);)c=+c<<1,--a;c="("+a+` bit)
|
|
8
8
|
`}n&&(e=e-256);for(var l=new Yt(e),h=i+1;h<t;++h)l.mulAdd(256,this.get(h));return c+l.toString()},r.prototype.parseBitString=function(i,t,e){for(var n=this.get(i),s=(t-i-1<<3)-n,a="("+s+` bit)
|
|
9
9
|
`,c="",l=i+1;l<t;++l){for(var h=this.get(l),f=l==t-1?n:0,_=7;_>=f;--_)c+=h>>_&1?"1":"0";if(c.length>e)return a+Kt(c,e)}return a+c},r.prototype.parseOctetString=function(i,t,e){if(this.isASCII(i,t))return Kt(this.parseStringISO(i,t),e);var n=t-i,s="("+n+` byte)
|
|
10
|
-
`;e/=2,n>e&&(t=i+e);for(var a=i;a<t;++a)s+=this.hexByte(this.get(a));return n>e&&(s+=
|
|
11
|
-
`,this.sub!==null){i+=" ";for(var e=0,n=this.sub.length;e<n;++e)t+=this.sub[e].toPrettyString(i)}return t},r.prototype.posStart=function(){return this.stream.pos},r.prototype.posContent=function(){return this.stream.pos+this.header},r.prototype.posEnd=function(){return this.stream.pos+this.header+Math.abs(this.length)},r.prototype.toHexString=function(){return this.stream.hexDump(this.posStart(),this.posEnd(),!0)},r.decodeLength=function(i){var t=i.get(),e=t&127;if(e==t)return e;if(e>6)throw new Error("Length over 48 bits not supported at position "+(i.pos-1));if(e===0)return null;t=0;for(var n=0;n<e;++n)t=t*256+i.get();return t},r.prototype.getHexStringValue=function(){var i=this.toHexString(),t=this.header*2,e=this.length*2;return i.substr(t,e)},r.decode=function(i){var t;i instanceof Je?t=i:t=new Je(i,0);var e=new Je(t),n=new Zn(t),s=r.decodeLength(t),a=t.pos,c=a-e.pos,l=null,h=function(){var _=[];if(s!==null){for(var m=a+s;t.pos<m;)_[_.length]=r.decode(t);if(t.pos!=m)throw new Error("Content size is not correct for container starting at offset "+a)}else try{for(;;){var P=r.decode(t);if(P.tag.isEOC())break;_[_.length]=P}s=a-t.pos}catch(v){throw new Error("Exception while decoding undefined length content: "+v)}return _};if(n.tagConstructed)l=h();else if(n.isUniversal()&&(n.tagNumber==3||n.tagNumber==4))try{if(n.tagNumber==3&&t.get()!=0)throw new Error("BIT STRINGs with unused bits cannot encapsulate.");l=h();for(var f=0;f<l.length;++f)if(l[f].tag.isEOC())throw new Error("EOC is not supposed to be actual content.")}catch{l=null}if(l===null){if(s===null)throw new Error("We can't skip over an invalid tag with undefined length at offset "+a);t.pos=a+Math.abs(s)}return new r(e,c,s,n,l)},r}(),Zn=function(){function r(i){var t=i.get();if(this.tagClass=t>>6,this.tagConstructed=(t&32)!==0,this.tagNumber=t&31,this.tagNumber==31){var e=new Yt;do t=i.get(),e.mulAdd(128,t&127);while(t&128);this.tagNumber=e.simplify()}}return r.prototype.isUniversal=function(){return this.tagClass===0},r.prototype.isEOC=function(){return this.tagClass===0&&this.tagNumber===0},r}(),xt,Sa=0xdeadbeefcafe,Yn=(Sa&16777215)==15715070,it=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997],ka=(1<<26)/it[it.length-1],D=function(){function r(i,t,e){i!=null&&(typeof i=="number"?this.fromNumber(i,t,e):t==null&&typeof i!="string"?this.fromString(i,256):this.fromString(i,t))}return r.prototype.toString=function(i){if(this.s<0)return"-"+this.negate().toString(i);var t;if(i==16)t=4;else if(i==8)t=3;else if(i==2)t=1;else if(i==32)t=5;else if(i==4)t=2;else return this.toRadix(i);var e=(1<<t)-1,n,s=!1,a="",c=this.t,l=this.DB-c*this.DB%t;if(c-- >0)for(l<this.DB&&(n=this[c]>>l)>0&&(s=!0,a=St(n));c>=0;)l<t?(n=(this[c]&(1<<l)-1)<<t-l,n|=this[--c]>>(l+=this.DB-t)):(n=this[c]>>(l-=t)&e,l<=0&&(l+=this.DB,--c)),n>0&&(s=!0),s&&(a+=St(n));return s?a:"0"},r.prototype.negate=function(){var i=N();return r.ZERO.subTo(this,i),i},r.prototype.abs=function(){return this.s<0?this.negate():this},r.prototype.compareTo=function(i){var t=this.s-i.s;if(t!=0)return t;var e=this.t;if(t=e-i.t,t!=0)return this.s<0?-t:t;for(;--e>=0;)if((t=this[e]-i[e])!=0)return t;return 0},r.prototype.bitLength=function(){return this.t<=0?0:this.DB*(this.t-1)+_e(this[this.t-1]^this.s&this.DM)},r.prototype.mod=function(i){var t=N();return this.abs().divRemTo(i,null,t),this.s<0&&t.compareTo(r.ZERO)>0&&i.subTo(t,t),t},r.prototype.modPowInt=function(i,t){var e;return i<256||t.isEven()?e=new ti(t):e=new ei(t),this.exp(i,e)},r.prototype.clone=function(){var i=N();return this.copyTo(i),i},r.prototype.intValue=function(){if(this.s<0){if(this.t==1)return this[0]-this.DV;if(this.t==0)return-1}else{if(this.t==1)return this[0];if(this.t==0)return 0}return(this[1]&(1<<32-this.DB)-1)<<this.DB|this[0]},r.prototype.byteValue=function(){return this.t==0?this.s:this[0]<<24>>24},r.prototype.shortValue=function(){return this.t==0?this.s:this[0]<<16>>16},r.prototype.signum=function(){return this.s<0?-1:this.t<=0||this.t==1&&this[0]<=0?0:1},r.prototype.toByteArray=function(){var i=this.t,t=[];t[0]=this.s;var e=this.DB-i*this.DB%8,n,s=0;if(i-- >0)for(e<this.DB&&(n=this[i]>>e)!=(this.s&this.DM)>>e&&(t[s++]=n|this.s<<this.DB-e);i>=0;)e<8?(n=(this[i]&(1<<e)-1)<<8-e,n|=this[--i]>>(e+=this.DB-8)):(n=this[i]>>(e-=8)&255,e<=0&&(e+=this.DB,--i)),n&128&&(n|=-256),s==0&&(this.s&128)!=(n&128)&&++s,(s>0||n!=this.s)&&(t[s++]=n);return t},r.prototype.equals=function(i){return this.compareTo(i)==0},r.prototype.min=function(i){return this.compareTo(i)<0?this:i},r.prototype.max=function(i){return this.compareTo(i)>0?this:i},r.prototype.and=function(i){var t=N();return this.bitwiseTo(i,ya,t),t},r.prototype.or=function(i){var t=N();return this.bitwiseTo(i,de,t),t},r.prototype.xor=function(i){var t=N();return this.bitwiseTo(i,Xn,t),t},r.prototype.andNot=function(i){var t=N();return this.bitwiseTo(i,Gn,t),t},r.prototype.not=function(){for(var i=N(),t=0;t<this.t;++t)i[t]=this.DM&~this[t];return i.t=this.t,i.s=~this.s,i},r.prototype.shiftLeft=function(i){var t=N();return i<0?this.rShiftTo(-i,t):this.lShiftTo(i,t),t},r.prototype.shiftRight=function(i){var t=N();return i<0?this.lShiftTo(-i,t):this.rShiftTo(i,t),t},r.prototype.getLowestSetBit=function(){for(var i=0;i<this.t;++i)if(this[i]!=0)return i*this.DB+wa(this[i]);return this.s<0?this.t*this.DB:-1},r.prototype.bitCount=function(){for(var i=0,t=this.s&this.DM,e=0;e<this.t;++e)i+=va(this[e]^t);return i},r.prototype.testBit=function(i){var t=Math.floor(i/this.DB);return t>=this.t?this.s!=0:(this[t]&1<<i%this.DB)!=0},r.prototype.setBit=function(i){return this.changeBit(i,de)},r.prototype.clearBit=function(i){return this.changeBit(i,Gn)},r.prototype.flipBit=function(i){return this.changeBit(i,Xn)},r.prototype.add=function(i){var t=N();return this.addTo(i,t),t},r.prototype.subtract=function(i){var t=N();return this.subTo(i,t),t},r.prototype.multiply=function(i){var t=N();return this.multiplyTo(i,t),t},r.prototype.divide=function(i){var t=N();return this.divRemTo(i,t,null),t},r.prototype.remainder=function(i){var t=N();return this.divRemTo(i,null,t),t},r.prototype.divideAndRemainder=function(i){var t=N(),e=N();return this.divRemTo(i,t,e),[t,e]},r.prototype.modPow=function(i,t){var e=i.bitLength(),n,s=At(1),a;if(e<=0)return s;e<18?n=1:e<48?n=3:e<144?n=4:e<768?n=5:n=6,e<8?a=new ti(t):t.isEven()?a=new Aa(t):a=new ei(t);var c=[],l=3,h=n-1,f=(1<<n)-1;if(c[1]=a.convert(this),n>1){var _=N();for(a.sqrTo(c[1],_);l<=f;)c[l]=N(),a.mulTo(_,c[l-2],c[l]),l+=2}var m=i.t-1,P,v=!0,S=N(),C;for(e=_e(i[m])-1;m>=0;){for(e>=h?P=i[m]>>e-h&f:(P=(i[m]&(1<<e+1)-1)<<h-e,m>0&&(P|=i[m-1]>>this.DB+e-h)),l=n;!(P&1);)P>>=1,--l;if((e-=l)<0&&(e+=this.DB,--m),v)c[P].copyTo(s),v=!1;else{for(;l>1;)a.sqrTo(s,S),a.sqrTo(S,s),l-=2;l>0?a.sqrTo(s,S):(C=s,s=S,S=C),a.mulTo(S,c[P],s)}for(;m>=0&&!(i[m]&1<<e);)a.sqrTo(s,S),C=s,s=S,S=C,--e<0&&(e=this.DB-1,--m)}return a.revert(s)},r.prototype.modInverse=function(i){var t=i.isEven();if(this.isEven()&&t||i.signum()==0)return r.ZERO;for(var e=i.clone(),n=this.clone(),s=At(1),a=At(0),c=At(0),l=At(1);e.signum()!=0;){for(;e.isEven();)e.rShiftTo(1,e),t?((!s.isEven()||!a.isEven())&&(s.addTo(this,s),a.subTo(i,a)),s.rShiftTo(1,s)):a.isEven()||a.subTo(i,a),a.rShiftTo(1,a);for(;n.isEven();)n.rShiftTo(1,n),t?((!c.isEven()||!l.isEven())&&(c.addTo(this,c),l.subTo(i,l)),c.rShiftTo(1,c)):l.isEven()||l.subTo(i,l),l.rShiftTo(1,l);e.compareTo(n)>=0?(e.subTo(n,e),t&&s.subTo(c,s),a.subTo(l,a)):(n.subTo(e,n),t&&c.subTo(s,c),l.subTo(a,l))}if(n.compareTo(r.ONE)!=0)return r.ZERO;if(l.compareTo(i)>=0)return l.subtract(i);if(l.signum()<0)l.addTo(i,l);else return l;return l.signum()<0?l.add(i):l},r.prototype.pow=function(i){return this.exp(i,new xa)},r.prototype.gcd=function(i){var t=this.s<0?this.negate():this.clone(),e=i.s<0?i.negate():i.clone();if(t.compareTo(e)<0){var n=t;t=e,e=n}var s=t.getLowestSetBit(),a=e.getLowestSetBit();if(a<0)return t;for(s<a&&(a=s),a>0&&(t.rShiftTo(a,t),e.rShiftTo(a,e));t.signum()>0;)(s=t.getLowestSetBit())>0&&t.rShiftTo(s,t),(s=e.getLowestSetBit())>0&&e.rShiftTo(s,e),t.compareTo(e)>=0?(t.subTo(e,t),t.rShiftTo(1,t)):(e.subTo(t,e),e.rShiftTo(1,e));return a>0&&e.lShiftTo(a,e),e},r.prototype.isProbablePrime=function(i){var t,e=this.abs();if(e.t==1&&e[0]<=it[it.length-1]){for(t=0;t<it.length;++t)if(e[0]==it[t])return!0;return!1}if(e.isEven())return!1;for(t=1;t<it.length;){for(var n=it[t],s=t+1;s<it.length&&n<ka;)n*=it[s++];for(n=e.modInt(n);t<s;)if(n%it[t++]==0)return!1}return e.millerRabin(i)},r.prototype.copyTo=function(i){for(var t=this.t-1;t>=0;--t)i[t]=this[t];i.t=this.t,i.s=this.s},r.prototype.fromInt=function(i){this.t=1,this.s=i<0?-1:0,i>0?this[0]=i:i<-1?this[0]=i+this.DV:this.t=0},r.prototype.fromString=function(i,t){var e;if(t==16)e=4;else if(t==8)e=3;else if(t==256)e=8;else if(t==2)e=1;else if(t==32)e=5;else if(t==4)e=2;else{this.fromRadix(i,t);return}this.t=0,this.s=0;for(var n=i.length,s=!1,a=0;--n>=0;){var c=e==8?+i[n]&255:ii(i,n);if(c<0){i.charAt(n)=="-"&&(s=!0);continue}s=!1,a==0?this[this.t++]=c:a+e>this.DB?(this[this.t-1]|=(c&(1<<this.DB-a)-1)<<a,this[this.t++]=c>>this.DB-a):this[this.t-1]|=c<<a,a+=e,a>=this.DB&&(a-=this.DB)}e==8&&+i[0]&128&&(this.s=-1,a>0&&(this[this.t-1]|=(1<<this.DB-a)-1<<a)),this.clamp(),s&&r.ZERO.subTo(this,this)},r.prototype.clamp=function(){for(var i=this.s&this.DM;this.t>0&&this[this.t-1]==i;)--this.t},r.prototype.dlShiftTo=function(i,t){var e;for(e=this.t-1;e>=0;--e)t[e+i]=this[e];for(e=i-1;e>=0;--e)t[e]=0;t.t=this.t+i,t.s=this.s},r.prototype.drShiftTo=function(i,t){for(var e=i;e<this.t;++e)t[e-i]=this[e];t.t=Math.max(this.t-i,0),t.s=this.s},r.prototype.lShiftTo=function(i,t){for(var e=i%this.DB,n=this.DB-e,s=(1<<n)-1,a=Math.floor(i/this.DB),c=this.s<<e&this.DM,l=this.t-1;l>=0;--l)t[l+a+1]=this[l]>>n|c,c=(this[l]&s)<<e;for(var l=a-1;l>=0;--l)t[l]=0;t[a]=c,t.t=this.t+a+1,t.s=this.s,t.clamp()},r.prototype.rShiftTo=function(i,t){t.s=this.s;var e=Math.floor(i/this.DB);if(e>=this.t){t.t=0;return}var n=i%this.DB,s=this.DB-n,a=(1<<n)-1;t[0]=this[e]>>n;for(var c=e+1;c<this.t;++c)t[c-e-1]|=(this[c]&a)<<s,t[c-e]=this[c]>>n;n>0&&(t[this.t-e-1]|=(this.s&a)<<s),t.t=this.t-e,t.clamp()},r.prototype.subTo=function(i,t){for(var e=0,n=0,s=Math.min(i.t,this.t);e<s;)n+=this[e]-i[e],t[e++]=n&this.DM,n>>=this.DB;if(i.t<this.t){for(n-=i.s;e<this.t;)n+=this[e],t[e++]=n&this.DM,n>>=this.DB;n+=this.s}else{for(n+=this.s;e<i.t;)n-=i[e],t[e++]=n&this.DM,n>>=this.DB;n-=i.s}t.s=n<0?-1:0,n<-1?t[e++]=this.DV+n:n>0&&(t[e++]=n),t.t=e,t.clamp()},r.prototype.multiplyTo=function(i,t){var e=this.abs(),n=i.abs(),s=e.t;for(t.t=s+n.t;--s>=0;)t[s]=0;for(s=0;s<n.t;++s)t[s+e.t]=e.am(0,n[s],t,s,0,e.t);t.s=0,t.clamp(),this.s!=i.s&&r.ZERO.subTo(t,t)},r.prototype.squareTo=function(i){for(var t=this.abs(),e=i.t=2*t.t;--e>=0;)i[e]=0;for(e=0;e<t.t-1;++e){var n=t.am(e,t[e],i,2*e,0,1);(i[e+t.t]+=t.am(e+1,2*t[e],i,2*e+1,n,t.t-e-1))>=t.DV&&(i[e+t.t]-=t.DV,i[e+t.t+1]=1)}i.t>0&&(i[i.t-1]+=t.am(e,t[e],i,2*e,0,1)),i.s=0,i.clamp()},r.prototype.divRemTo=function(i,t,e){var n=i.abs();if(!(n.t<=0)){var s=this.abs();if(s.t<n.t){t!=null&&t.fromInt(0),e!=null&&this.copyTo(e);return}e==null&&(e=N());var a=N(),c=this.s,l=i.s,h=this.DB-_e(n[n.t-1]);h>0?(n.lShiftTo(h,a),s.lShiftTo(h,e)):(n.copyTo(a),s.copyTo(e));var f=a.t,_=a[f-1];if(_!=0){var m=_*(1<<this.F1)+(f>1?a[f-2]>>this.F2:0),P=this.FV/m,v=(1<<this.F1)/m,S=1<<this.F2,C=e.t,q=C-f,V=t??N();for(a.dlShiftTo(q,V),e.compareTo(V)>=0&&(e[e.t++]=1,e.subTo(V,e)),r.ONE.dlShiftTo(f,V),V.subTo(a,a);a.t<f;)a[a.t++]=0;for(;--q>=0;){var H=e[--C]==_?this.DM:Math.floor(e[C]*P+(e[C-1]+S)*v);if((e[C]+=a.am(0,H,e,q,0,f))<H)for(a.dlShiftTo(q,V),e.subTo(V,e);e[C]<--H;)e.subTo(V,e)}t!=null&&(e.drShiftTo(f,t),c!=l&&r.ZERO.subTo(t,t)),e.t=f,e.clamp(),h>0&&e.rShiftTo(h,e),c<0&&r.ZERO.subTo(e,e)}}},r.prototype.invDigit=function(){if(this.t<1)return 0;var i=this[0];if(!(i&1))return 0;var t=i&3;return t=t*(2-(i&15)*t)&15,t=t*(2-(i&255)*t)&255,t=t*(2-((i&65535)*t&65535))&65535,t=t*(2-i*t%this.DV)%this.DV,t>0?this.DV-t:-t},r.prototype.isEven=function(){return(this.t>0?this[0]&1:this.s)==0},r.prototype.exp=function(i,t){if(i>4294967295||i<1)return r.ONE;var e=N(),n=N(),s=t.convert(this),a=_e(i)-1;for(s.copyTo(e);--a>=0;)if(t.sqrTo(e,n),(i&1<<a)>0)t.mulTo(n,s,e);else{var c=e;e=n,n=c}return t.revert(e)},r.prototype.chunkSize=function(i){return Math.floor(Math.LN2*this.DB/Math.log(i))},r.prototype.toRadix=function(i){if(i==null&&(i=10),this.signum()==0||i<2||i>36)return"0";var t=this.chunkSize(i),e=Math.pow(i,t),n=At(e),s=N(),a=N(),c="";for(this.divRemTo(n,s,a);s.signum()>0;)c=(e+a.intValue()).toString(i).substr(1)+c,s.divRemTo(n,s,a);return a.intValue().toString(i)+c},r.prototype.fromRadix=function(i,t){this.fromInt(0),t==null&&(t=10);for(var e=this.chunkSize(t),n=Math.pow(t,e),s=!1,a=0,c=0,l=0;l<i.length;++l){var h=ii(i,l);if(h<0){i.charAt(l)=="-"&&this.signum()==0&&(s=!0);continue}c=t*c+h,++a>=e&&(this.dMultiply(n),this.dAddOffset(c,0),a=0,c=0)}a>0&&(this.dMultiply(Math.pow(t,a)),this.dAddOffset(c,0)),s&&r.ZERO.subTo(this,this)},r.prototype.fromNumber=function(i,t,e){if(typeof t=="number")if(i<2)this.fromInt(1);else for(this.fromNumber(i,e),this.testBit(i-1)||this.bitwiseTo(r.ONE.shiftLeft(i-1),de,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(t);)this.dAddOffset(2,0),this.bitLength()>i&&this.subTo(r.ONE.shiftLeft(i-1),this);else{var n=[],s=i&7;n.length=(i>>3)+1,t.nextBytes(n),s>0?n[0]&=(1<<s)-1:n[0]=0,this.fromString(n,256)}},r.prototype.bitwiseTo=function(i,t,e){var n,s,a=Math.min(i.t,this.t);for(n=0;n<a;++n)e[n]=t(this[n],i[n]);if(i.t<this.t){for(s=i.s&this.DM,n=a;n<this.t;++n)e[n]=t(this[n],s);e.t=this.t}else{for(s=this.s&this.DM,n=a;n<i.t;++n)e[n]=t(s,i[n]);e.t=i.t}e.s=t(this.s,i.s),e.clamp()},r.prototype.changeBit=function(i,t){var e=r.ONE.shiftLeft(i);return this.bitwiseTo(e,t,e),e},r.prototype.addTo=function(i,t){for(var e=0,n=0,s=Math.min(i.t,this.t);e<s;)n+=this[e]+i[e],t[e++]=n&this.DM,n>>=this.DB;if(i.t<this.t){for(n+=i.s;e<this.t;)n+=this[e],t[e++]=n&this.DM,n>>=this.DB;n+=this.s}else{for(n+=this.s;e<i.t;)n+=i[e],t[e++]=n&this.DM,n>>=this.DB;n+=i.s}t.s=n<0?-1:0,n>0?t[e++]=n:n<-1&&(t[e++]=this.DV+n),t.t=e,t.clamp()},r.prototype.dMultiply=function(i){this[this.t]=this.am(0,i-1,this,0,0,this.t),++this.t,this.clamp()},r.prototype.dAddOffset=function(i,t){if(i!=0){for(;this.t<=t;)this[this.t++]=0;for(this[t]+=i;this[t]>=this.DV;)this[t]-=this.DV,++t>=this.t&&(this[this.t++]=0),++this[t]}},r.prototype.multiplyLowerTo=function(i,t,e){var n=Math.min(this.t+i.t,t);for(e.s=0,e.t=n;n>0;)e[--n]=0;for(var s=e.t-this.t;n<s;++n)e[n+this.t]=this.am(0,i[n],e,n,0,this.t);for(var s=Math.min(i.t,t);n<s;++n)this.am(0,i[n],e,n,0,t-n);e.clamp()},r.prototype.multiplyUpperTo=function(i,t,e){--t;var n=e.t=this.t+i.t-t;for(e.s=0;--n>=0;)e[n]=0;for(n=Math.max(t-this.t,0);n<i.t;++n)e[this.t+n-t]=this.am(t-n,i[n],e,0,0,this.t+n-t);e.clamp(),e.drShiftTo(1,e)},r.prototype.modInt=function(i){if(i<=0)return 0;var t=this.DV%i,e=this.s<0?i-1:0;if(this.t>0)if(t==0)e=this[0]%i;else for(var n=this.t-1;n>=0;--n)e=(t*e+this[n])%i;return e},r.prototype.millerRabin=function(i){var t=this.subtract(r.ONE),e=t.getLowestSetBit();if(e<=0)return!1;var n=t.shiftRight(e);i=i+1>>1,i>it.length&&(i=it.length);for(var s=N(),a=0;a<i;++a){s.fromInt(it[Math.floor(Math.random()*it.length)]);var c=s.modPow(n,this);if(c.compareTo(r.ONE)!=0&&c.compareTo(t)!=0){for(var l=1;l++<e&&c.compareTo(t)!=0;)if(c=c.modPowInt(2,this),c.compareTo(r.ONE)==0)return!1;if(c.compareTo(t)!=0)return!1}}return!0},r.prototype.square=function(){var i=N();return this.squareTo(i),i},r.prototype.gcda=function(i,t){var e=this.s<0?this.negate():this.clone(),n=i.s<0?i.negate():i.clone();if(e.compareTo(n)<0){var s=e;e=n,n=s}var a=e.getLowestSetBit(),c=n.getLowestSetBit();if(c<0){t(e);return}a<c&&(c=a),c>0&&(e.rShiftTo(c,e),n.rShiftTo(c,n));var l=function(){(a=e.getLowestSetBit())>0&&e.rShiftTo(a,e),(a=n.getLowestSetBit())>0&&n.rShiftTo(a,n),e.compareTo(n)>=0?(e.subTo(n,e),e.rShiftTo(1,e)):(n.subTo(e,n),n.rShiftTo(1,n)),e.signum()>0?setTimeout(l,0):(c>0&&n.lShiftTo(c,n),setTimeout(function(){t(n)},0))};setTimeout(l,10)},r.prototype.fromNumberAsync=function(i,t,e,n){if(typeof t=="number")if(i<2)this.fromInt(1);else{this.fromNumber(i,e),this.testBit(i-1)||this.bitwiseTo(r.ONE.shiftLeft(i-1),de,this),this.isEven()&&this.dAddOffset(1,0);var s=this,a=function(){s.dAddOffset(2,0),s.bitLength()>i&&s.subTo(r.ONE.shiftLeft(i-1),s),s.isProbablePrime(t)?setTimeout(function(){n()},0):setTimeout(a,0)};setTimeout(a,0)}else{var c=[],l=i&7;c.length=(i>>3)+1,t.nextBytes(c),l>0?c[0]&=(1<<l)-1:c[0]=0,this.fromString(c,256)}},r}(),xa=function(){function r(){}return r.prototype.convert=function(i){return i},r.prototype.revert=function(i){return i},r.prototype.mulTo=function(i,t,e){i.multiplyTo(t,e)},r.prototype.sqrTo=function(i,t){i.squareTo(t)},r}(),ti=function(){function r(i){this.m=i}return r.prototype.convert=function(i){return i.s<0||i.compareTo(this.m)>=0?i.mod(this.m):i},r.prototype.revert=function(i){return i},r.prototype.reduce=function(i){i.divRemTo(this.m,null,i)},r.prototype.mulTo=function(i,t,e){i.multiplyTo(t,e),this.reduce(e)},r.prototype.sqrTo=function(i,t){i.squareTo(t),this.reduce(t)},r}(),ei=function(){function r(i){this.m=i,this.mp=i.invDigit(),this.mpl=this.mp&32767,this.mph=this.mp>>15,this.um=(1<<i.DB-15)-1,this.mt2=2*i.t}return r.prototype.convert=function(i){var t=N();return i.abs().dlShiftTo(this.m.t,t),t.divRemTo(this.m,null,t),i.s<0&&t.compareTo(D.ZERO)>0&&this.m.subTo(t,t),t},r.prototype.revert=function(i){var t=N();return i.copyTo(t),this.reduce(t),t},r.prototype.reduce=function(i){for(;i.t<=this.mt2;)i[i.t++]=0;for(var t=0;t<this.m.t;++t){var e=i[t]&32767,n=e*this.mpl+((e*this.mph+(i[t]>>15)*this.mpl&this.um)<<15)&i.DM;for(e=t+this.m.t,i[e]+=this.m.am(0,n,i,t,0,this.m.t);i[e]>=i.DV;)i[e]-=i.DV,i[++e]++}i.clamp(),i.drShiftTo(this.m.t,i),i.compareTo(this.m)>=0&&i.subTo(this.m,i)},r.prototype.mulTo=function(i,t,e){i.multiplyTo(t,e),this.reduce(e)},r.prototype.sqrTo=function(i,t){i.squareTo(t),this.reduce(t)},r}(),Aa=function(){function r(i){this.m=i,this.r2=N(),this.q3=N(),D.ONE.dlShiftTo(2*i.t,this.r2),this.mu=this.r2.divide(i)}return r.prototype.convert=function(i){if(i.s<0||i.t>2*this.m.t)return i.mod(this.m);if(i.compareTo(this.m)<0)return i;var t=N();return i.copyTo(t),this.reduce(t),t},r.prototype.revert=function(i){return i},r.prototype.reduce=function(i){for(i.drShiftTo(this.m.t-1,this.r2),i.t>this.m.t+1&&(i.t=this.m.t+1,i.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);i.compareTo(this.r2)<0;)i.dAddOffset(1,this.m.t+1);for(i.subTo(this.r2,i);i.compareTo(this.m)>=0;)i.subTo(this.m,i)},r.prototype.mulTo=function(i,t,e){i.multiplyTo(t,e),this.reduce(e)},r.prototype.sqrTo=function(i,t){i.squareTo(t),this.reduce(t)},r}();function N(){return new D(null)}function W(r,i){return new D(r,i)}var ni=typeof navigator<"u";ni&&Yn&&navigator.appName=="Microsoft Internet Explorer"?(D.prototype.am=function(i,t,e,n,s,a){for(var c=t&32767,l=t>>15;--a>=0;){var h=this[i]&32767,f=this[i++]>>15,_=l*h+f*c;h=c*h+((_&32767)<<15)+e[n]+(s&1073741823),s=(h>>>30)+(_>>>15)+l*f+(s>>>30),e[n++]=h&1073741823}return s},xt=30):ni&&Yn&&navigator.appName!="Netscape"?(D.prototype.am=function(i,t,e,n,s,a){for(;--a>=0;){var c=t*this[i++]+e[n]+s;s=Math.floor(c/67108864),e[n++]=c&67108863}return s},xt=26):(D.prototype.am=function(i,t,e,n,s,a){for(var c=t&16383,l=t>>14;--a>=0;){var h=this[i]&16383,f=this[i++]>>14,_=l*h+f*c;h=c*h+((_&16383)<<14)+e[n]+s,s=(h>>28)+(_>>14)+l*f,e[n++]=h&268435455}return s},xt=28),D.prototype.DB=xt,D.prototype.DM=(1<<xt)-1,D.prototype.DV=1<<xt;var $e=52;D.prototype.FV=Math.pow(2,$e),D.prototype.F1=$e-xt,D.prototype.F2=2*xt-$e;var fe=[],Wt,pt;for(Wt=48,pt=0;pt<=9;++pt)fe[Wt++]=pt;for(Wt=97,pt=10;pt<36;++pt)fe[Wt++]=pt;for(Wt=65,pt=10;pt<36;++pt)fe[Wt++]=pt;function ii(r,i){var t=fe[r.charCodeAt(i)];return t??-1}function At(r){var i=N();return i.fromInt(r),i}function _e(r){var i=1,t;return(t=r>>>16)!=0&&(r=t,i+=16),(t=r>>8)!=0&&(r=t,i+=8),(t=r>>4)!=0&&(r=t,i+=4),(t=r>>2)!=0&&(r=t,i+=2),(t=r>>1)!=0&&(r=t,i+=1),i}D.ZERO=At(0),D.ONE=At(1);var Da=function(){function r(){this.i=0,this.j=0,this.S=[]}return r.prototype.init=function(i){var t,e,n;for(t=0;t<256;++t)this.S[t]=t;for(e=0,t=0;t<256;++t)e=e+this.S[t]+i[t%i.length]&255,n=this.S[t],this.S[t]=this.S[e],this.S[e]=n;this.i=0,this.j=0},r.prototype.next=function(){var i;return this.i=this.i+1&255,this.j=this.j+this.S[this.i]&255,i=this.S[this.i],this.S[this.i]=this.S[this.j],this.S[this.j]=i,this.S[i+this.S[this.i]&255]},r}();function Ra(){return new Da}var ri=256,ge,Dt=null,_t;if(Dt==null){Dt=[],_t=0;var be=void 0;if(typeof window<"u"&&window.crypto&&window.crypto.getRandomValues){var Qe=new Uint32Array(256);for(window.crypto.getRandomValues(Qe),be=0;be<Qe.length;++be)Dt[_t++]=Qe[be]&255}var me=0,ye=function(r){if(me=me||0,me>=256||_t>=ri){window.removeEventListener?window.removeEventListener("mousemove",ye,!1):window.detachEvent&&window.detachEvent("onmousemove",ye);return}try{var i=r.x+r.y;Dt[_t++]=i&255,me+=1}catch{}};typeof window<"u"&&(window.addEventListener?window.addEventListener("mousemove",ye,!1):window.attachEvent&&window.attachEvent("onmousemove",ye))}function Ia(){if(ge==null){for(ge=Ra();_t<ri;){var r=Math.floor(65536*Math.random());Dt[_t++]=r&255}for(ge.init(Dt),_t=0;_t<Dt.length;++_t)Dt[_t]=0;_t=0}return ge.next()}var Ze=function(){function r(){}return r.prototype.nextBytes=function(i){for(var t=0;t<i.length;++t)i[t]=Ia()},r}();function Oa(r,i){if(i<r.length+22)return console.error("Message too long for RSA"),null;for(var t=i-r.length-6,e="",n=0;n<t;n+=2)e+="ff";var s="0001"+e+"00"+r;return W(s,16)}function Ba(r,i){if(i<r.length+11)return console.error("Message too long for RSA"),null;for(var t=[],e=r.length-1;e>=0&&i>0;){var n=r.charCodeAt(e--);n<128?t[--i]=n:n>127&&n<2048?(t[--i]=n&63|128,t[--i]=n>>6|192):(t[--i]=n&63|128,t[--i]=n>>6&63|128,t[--i]=n>>12|224)}t[--i]=0;for(var s=new Ze,a=[];i>2;){for(a[0]=0;a[0]==0;)s.nextBytes(a);t[--i]=a[0]}return t[--i]=2,t[--i]=0,new D(t)}var Na=function(){function r(){this.n=null,this.e=0,this.d=null,this.p=null,this.q=null,this.dmp1=null,this.dmq1=null,this.coeff=null}return r.prototype.doPublic=function(i){return i.modPowInt(this.e,this.n)},r.prototype.doPrivate=function(i){if(this.p==null||this.q==null)return i.modPow(this.d,this.n);for(var t=i.mod(this.p).modPow(this.dmp1,this.p),e=i.mod(this.q).modPow(this.dmq1,this.q);t.compareTo(e)<0;)t=t.add(this.p);return t.subtract(e).multiply(this.coeff).mod(this.p).multiply(this.q).add(e)},r.prototype.setPublic=function(i,t){i!=null&&t!=null&&i.length>0&&t.length>0?(this.n=W(i,16),this.e=parseInt(t,16)):console.error("Invalid RSA public key")},r.prototype.encrypt=function(i){var t=this.n.bitLength()+7>>3,e=Ba(i,t);if(e==null)return null;var n=this.doPublic(e);if(n==null)return null;for(var s=n.toString(16),a=s.length,c=0;c<t*2-a;c++)s="0"+s;return s},r.prototype.setPrivate=function(i,t,e){i!=null&&t!=null&&i.length>0&&t.length>0?(this.n=W(i,16),this.e=parseInt(t,16),this.d=W(e,16)):console.error("Invalid RSA private key")},r.prototype.setPrivateEx=function(i,t,e,n,s,a,c,l){i!=null&&t!=null&&i.length>0&&t.length>0?(this.n=W(i,16),this.e=parseInt(t,16),this.d=W(e,16),this.p=W(n,16),this.q=W(s,16),this.dmp1=W(a,16),this.dmq1=W(c,16),this.coeff=W(l,16)):console.error("Invalid RSA private key")},r.prototype.generate=function(i,t){var e=new Ze,n=i>>1;this.e=parseInt(t,16);for(var s=new D(t,16);;){for(;this.p=new D(i-n,1,e),!(this.p.subtract(D.ONE).gcd(s).compareTo(D.ONE)==0&&this.p.isProbablePrime(10)););for(;this.q=new D(n,1,e),!(this.q.subtract(D.ONE).gcd(s).compareTo(D.ONE)==0&&this.q.isProbablePrime(10)););if(this.p.compareTo(this.q)<=0){var a=this.p;this.p=this.q,this.q=a}var c=this.p.subtract(D.ONE),l=this.q.subtract(D.ONE),h=c.multiply(l);if(h.gcd(s).compareTo(D.ONE)==0){this.n=this.p.multiply(this.q),this.d=s.modInverse(h),this.dmp1=this.d.mod(c),this.dmq1=this.d.mod(l),this.coeff=this.q.modInverse(this.p);break}}},r.prototype.decrypt=function(i){var t=W(i,16),e=this.doPrivate(t);return e==null?null:Ma(e,this.n.bitLength()+7>>3)},r.prototype.generateAsync=function(i,t,e){var n=new Ze,s=i>>1;this.e=parseInt(t,16);var a=new D(t,16),c=this,l=function(){var h=function(){if(c.p.compareTo(c.q)<=0){var m=c.p;c.p=c.q,c.q=m}var P=c.p.subtract(D.ONE),v=c.q.subtract(D.ONE),S=P.multiply(v);S.gcd(a).compareTo(D.ONE)==0?(c.n=c.p.multiply(c.q),c.d=a.modInverse(S),c.dmp1=c.d.mod(P),c.dmq1=c.d.mod(v),c.coeff=c.q.modInverse(c.p),setTimeout(function(){e()},0)):setTimeout(l,0)},f=function(){c.q=N(),c.q.fromNumberAsync(s,1,n,function(){c.q.subtract(D.ONE).gcda(a,function(m){m.compareTo(D.ONE)==0&&c.q.isProbablePrime(10)?setTimeout(h,0):setTimeout(f,0)})})},_=function(){c.p=N(),c.p.fromNumberAsync(i-s,1,n,function(){c.p.subtract(D.ONE).gcda(a,function(m){m.compareTo(D.ONE)==0&&c.p.isProbablePrime(10)?setTimeout(f,0):setTimeout(_,0)})})};setTimeout(_,0)};setTimeout(l,0)},r.prototype.sign=function(i,t,e){var n=Fa(e),s=n+t(i).toString(),a=Oa(s,this.n.bitLength()/4);if(a==null)return null;var c=this.doPrivate(a);if(c==null)return null;var l=c.toString(16);return l.length&1?"0"+l:l},r.prototype.verify=function(i,t,e){var n=W(t,16),s=this.doPublic(n);if(s==null)return null;var a=s.toString(16).replace(/^1f+00/,""),c=Ua(a);return c==e(i).toString()},r}();function Ma(r,i){for(var t=r.toByteArray(),e=0;e<t.length&&t[e]==0;)++e;if(t.length-e!=i-1||t[e]!=2)return null;for(++e;t[e]!=0;)if(++e>=t.length)return null;for(var n="";++e<t.length;){var s=t[e]&255;s<128?n+=String.fromCharCode(s):s>191&&s<224?(n+=String.fromCharCode((s&31)<<6|t[e+1]&63),++e):(n+=String.fromCharCode((s&15)<<12|(t[e+1]&63)<<6|t[e+2]&63),e+=2)}return n}var we={md2:"3020300c06082a864886f70d020205000410",md5:"3020300c06082a864886f70d020505000410",sha1:"3021300906052b0e03021a05000414",sha224:"302d300d06096086480165030402040500041c",sha256:"3031300d060960864801650304020105000420",sha384:"3041300d060960864801650304020205000430",sha512:"3051300d060960864801650304020305000440",ripemd160:"3021300906052b2403020105000414"};function Fa(r){return we[r]||""}function Ua(r){for(var i in we)if(we.hasOwnProperty(i)){var t=we[i],e=t.length;if(r.substr(0,e)==t)return r.substr(e)}return r}/*!
|
|
10
|
+
`;e/=2,n>e&&(t=i+e);for(var a=i;a<t;++a)s+=this.hexByte(this.get(a));return n>e&&(s+=Jn),s},r.prototype.parseOID=function(i,t,e){for(var n="",s=new Yt,a=0,c=i;c<t;++c){var l=this.get(c);if(s.mulAdd(128,l&127),a+=7,!(l&128)){if(n==="")if(s=s.simplify(),s instanceof Yt)s.sub(80),n="2."+s.toString();else{var h=s<80?s<40?0:1:2;n=h+"."+(s-h*40)}else n+="."+s.toString();if(n.length>e)return Kt(n,e);s=new Yt,a=0}}return a>0&&(n+=".incomplete"),n},r}(),Ca=function(){function r(i,t,e,n,s){if(!(n instanceof Qn))throw new Error("Invalid tag value.");this.stream=i,this.header=t,this.length=e,this.tag=n,this.sub=s}return r.prototype.typeName=function(){switch(this.tag.tagClass){case 0:switch(this.tag.tagNumber){case 0:return"EOC";case 1:return"BOOLEAN";case 2:return"INTEGER";case 3:return"BIT_STRING";case 4:return"OCTET_STRING";case 5:return"NULL";case 6:return"OBJECT_IDENTIFIER";case 7:return"ObjectDescriptor";case 8:return"EXTERNAL";case 9:return"REAL";case 10:return"ENUMERATED";case 11:return"EMBEDDED_PDV";case 12:return"UTF8String";case 16:return"SEQUENCE";case 17:return"SET";case 18:return"NumericString";case 19:return"PrintableString";case 20:return"TeletexString";case 21:return"VideotexString";case 22:return"IA5String";case 23:return"UTCTime";case 24:return"GeneralizedTime";case 25:return"GraphicString";case 26:return"VisibleString";case 27:return"GeneralString";case 28:return"UniversalString";case 30:return"BMPString"}return"Universal_"+this.tag.tagNumber.toString();case 1:return"Application_"+this.tag.tagNumber.toString();case 2:return"["+this.tag.tagNumber.toString()+"]";case 3:return"Private_"+this.tag.tagNumber.toString()}},r.prototype.content=function(i){if(this.tag===void 0)return null;i===void 0&&(i=1/0);var t=this.posContent(),e=Math.abs(this.length);if(!this.tag.isUniversal())return this.sub!==null?"("+this.sub.length+" elem)":this.stream.parseOctetString(t,t+e,i);switch(this.tag.tagNumber){case 1:return this.stream.get(t)===0?"false":"true";case 2:return this.stream.parseInteger(t,t+e);case 3:return this.sub?"("+this.sub.length+" elem)":this.stream.parseBitString(t,t+e,i);case 4:return this.sub?"("+this.sub.length+" elem)":this.stream.parseOctetString(t,t+e,i);case 6:return this.stream.parseOID(t,t+e,i);case 16:case 17:return this.sub!==null?"("+this.sub.length+" elem)":"(no elem)";case 12:return Kt(this.stream.parseStringUTF(t,t+e),i);case 18:case 19:case 20:case 21:case 22:case 26:return Kt(this.stream.parseStringISO(t,t+e),i);case 30:return Kt(this.stream.parseStringBMP(t,t+e),i);case 23:case 24:return this.stream.parseTime(t,t+e,this.tag.tagNumber==23)}return null},r.prototype.toString=function(){return this.typeName()+"@"+this.stream.pos+"[header:"+this.header+",length:"+this.length+",sub:"+(this.sub===null?"null":this.sub.length)+"]"},r.prototype.toPrettyString=function(i){i===void 0&&(i="");var t=i+this.typeName()+" @"+this.stream.pos;if(this.length>=0&&(t+="+"),t+=this.length,this.tag.tagConstructed?t+=" (constructed)":this.tag.isUniversal()&&(this.tag.tagNumber==3||this.tag.tagNumber==4)&&this.sub!==null&&(t+=" (encapsulates)"),t+=`
|
|
11
|
+
`,this.sub!==null){i+=" ";for(var e=0,n=this.sub.length;e<n;++e)t+=this.sub[e].toPrettyString(i)}return t},r.prototype.posStart=function(){return this.stream.pos},r.prototype.posContent=function(){return this.stream.pos+this.header},r.prototype.posEnd=function(){return this.stream.pos+this.header+Math.abs(this.length)},r.prototype.toHexString=function(){return this.stream.hexDump(this.posStart(),this.posEnd(),!0)},r.decodeLength=function(i){var t=i.get(),e=t&127;if(e==t)return e;if(e>6)throw new Error("Length over 48 bits not supported at position "+(i.pos-1));if(e===0)return null;t=0;for(var n=0;n<e;++n)t=t*256+i.get();return t},r.prototype.getHexStringValue=function(){var i=this.toHexString(),t=this.header*2,e=this.length*2;return i.substr(t,e)},r.decode=function(i){var t;i instanceof $e?t=i:t=new $e(i,0);var e=new $e(t),n=new Qn(t),s=r.decodeLength(t),a=t.pos,c=a-e.pos,l=null,h=function(){var _=[];if(s!==null){for(var m=a+s;t.pos<m;)_[_.length]=r.decode(t);if(t.pos!=m)throw new Error("Content size is not correct for container starting at offset "+a)}else try{for(;;){var P=r.decode(t);if(P.tag.isEOC())break;_[_.length]=P}s=a-t.pos}catch(v){throw new Error("Exception while decoding undefined length content: "+v)}return _};if(n.tagConstructed)l=h();else if(n.isUniversal()&&(n.tagNumber==3||n.tagNumber==4))try{if(n.tagNumber==3&&t.get()!=0)throw new Error("BIT STRINGs with unused bits cannot encapsulate.");l=h();for(var f=0;f<l.length;++f)if(l[f].tag.isEOC())throw new Error("EOC is not supposed to be actual content.")}catch{l=null}if(l===null){if(s===null)throw new Error("We can't skip over an invalid tag with undefined length at offset "+a);t.pos=a+Math.abs(s)}return new r(e,c,s,n,l)},r}(),Qn=function(){function r(i){var t=i.get();if(this.tagClass=t>>6,this.tagConstructed=(t&32)!==0,this.tagNumber=t&31,this.tagNumber==31){var e=new Yt;do t=i.get(),e.mulAdd(128,t&127);while(t&128);this.tagNumber=e.simplify()}}return r.prototype.isUniversal=function(){return this.tagClass===0},r.prototype.isEOC=function(){return this.tagClass===0&&this.tagNumber===0},r}(),xt,Sa=0xdeadbeefcafe,Zn=(Sa&16777215)==15715070,it=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997],ka=(1<<26)/it[it.length-1],D=function(){function r(i,t,e){i!=null&&(typeof i=="number"?this.fromNumber(i,t,e):t==null&&typeof i!="string"?this.fromString(i,256):this.fromString(i,t))}return r.prototype.toString=function(i){if(this.s<0)return"-"+this.negate().toString(i);var t;if(i==16)t=4;else if(i==8)t=3;else if(i==2)t=1;else if(i==32)t=5;else if(i==4)t=2;else return this.toRadix(i);var e=(1<<t)-1,n,s=!1,a="",c=this.t,l=this.DB-c*this.DB%t;if(c-- >0)for(l<this.DB&&(n=this[c]>>l)>0&&(s=!0,a=St(n));c>=0;)l<t?(n=(this[c]&(1<<l)-1)<<t-l,n|=this[--c]>>(l+=this.DB-t)):(n=this[c]>>(l-=t)&e,l<=0&&(l+=this.DB,--c)),n>0&&(s=!0),s&&(a+=St(n));return s?a:"0"},r.prototype.negate=function(){var i=N();return r.ZERO.subTo(this,i),i},r.prototype.abs=function(){return this.s<0?this.negate():this},r.prototype.compareTo=function(i){var t=this.s-i.s;if(t!=0)return t;var e=this.t;if(t=e-i.t,t!=0)return this.s<0?-t:t;for(;--e>=0;)if((t=this[e]-i[e])!=0)return t;return 0},r.prototype.bitLength=function(){return this.t<=0?0:this.DB*(this.t-1)+_e(this[this.t-1]^this.s&this.DM)},r.prototype.mod=function(i){var t=N();return this.abs().divRemTo(i,null,t),this.s<0&&t.compareTo(r.ZERO)>0&&i.subTo(t,t),t},r.prototype.modPowInt=function(i,t){var e;return i<256||t.isEven()?e=new Yn(t):e=new ti(t),this.exp(i,e)},r.prototype.clone=function(){var i=N();return this.copyTo(i),i},r.prototype.intValue=function(){if(this.s<0){if(this.t==1)return this[0]-this.DV;if(this.t==0)return-1}else{if(this.t==1)return this[0];if(this.t==0)return 0}return(this[1]&(1<<32-this.DB)-1)<<this.DB|this[0]},r.prototype.byteValue=function(){return this.t==0?this.s:this[0]<<24>>24},r.prototype.shortValue=function(){return this.t==0?this.s:this[0]<<16>>16},r.prototype.signum=function(){return this.s<0?-1:this.t<=0||this.t==1&&this[0]<=0?0:1},r.prototype.toByteArray=function(){var i=this.t,t=[];t[0]=this.s;var e=this.DB-i*this.DB%8,n,s=0;if(i-- >0)for(e<this.DB&&(n=this[i]>>e)!=(this.s&this.DM)>>e&&(t[s++]=n|this.s<<this.DB-e);i>=0;)e<8?(n=(this[i]&(1<<e)-1)<<8-e,n|=this[--i]>>(e+=this.DB-8)):(n=this[i]>>(e-=8)&255,e<=0&&(e+=this.DB,--i)),n&128&&(n|=-256),s==0&&(this.s&128)!=(n&128)&&++s,(s>0||n!=this.s)&&(t[s++]=n);return t},r.prototype.equals=function(i){return this.compareTo(i)==0},r.prototype.min=function(i){return this.compareTo(i)<0?this:i},r.prototype.max=function(i){return this.compareTo(i)>0?this:i},r.prototype.and=function(i){var t=N();return this.bitwiseTo(i,ya,t),t},r.prototype.or=function(i){var t=N();return this.bitwiseTo(i,de,t),t},r.prototype.xor=function(i){var t=N();return this.bitwiseTo(i,zn,t),t},r.prototype.andNot=function(i){var t=N();return this.bitwiseTo(i,Xn,t),t},r.prototype.not=function(){for(var i=N(),t=0;t<this.t;++t)i[t]=this.DM&~this[t];return i.t=this.t,i.s=~this.s,i},r.prototype.shiftLeft=function(i){var t=N();return i<0?this.rShiftTo(-i,t):this.lShiftTo(i,t),t},r.prototype.shiftRight=function(i){var t=N();return i<0?this.lShiftTo(-i,t):this.rShiftTo(i,t),t},r.prototype.getLowestSetBit=function(){for(var i=0;i<this.t;++i)if(this[i]!=0)return i*this.DB+wa(this[i]);return this.s<0?this.t*this.DB:-1},r.prototype.bitCount=function(){for(var i=0,t=this.s&this.DM,e=0;e<this.t;++e)i+=va(this[e]^t);return i},r.prototype.testBit=function(i){var t=Math.floor(i/this.DB);return t>=this.t?this.s!=0:(this[t]&1<<i%this.DB)!=0},r.prototype.setBit=function(i){return this.changeBit(i,de)},r.prototype.clearBit=function(i){return this.changeBit(i,Xn)},r.prototype.flipBit=function(i){return this.changeBit(i,zn)},r.prototype.add=function(i){var t=N();return this.addTo(i,t),t},r.prototype.subtract=function(i){var t=N();return this.subTo(i,t),t},r.prototype.multiply=function(i){var t=N();return this.multiplyTo(i,t),t},r.prototype.divide=function(i){var t=N();return this.divRemTo(i,t,null),t},r.prototype.remainder=function(i){var t=N();return this.divRemTo(i,null,t),t},r.prototype.divideAndRemainder=function(i){var t=N(),e=N();return this.divRemTo(i,t,e),[t,e]},r.prototype.modPow=function(i,t){var e=i.bitLength(),n,s=At(1),a;if(e<=0)return s;e<18?n=1:e<48?n=3:e<144?n=4:e<768?n=5:n=6,e<8?a=new Yn(t):t.isEven()?a=new Aa(t):a=new ti(t);var c=[],l=3,h=n-1,f=(1<<n)-1;if(c[1]=a.convert(this),n>1){var _=N();for(a.sqrTo(c[1],_);l<=f;)c[l]=N(),a.mulTo(_,c[l-2],c[l]),l+=2}var m=i.t-1,P,v=!0,S=N(),C;for(e=_e(i[m])-1;m>=0;){for(e>=h?P=i[m]>>e-h&f:(P=(i[m]&(1<<e+1)-1)<<h-e,m>0&&(P|=i[m-1]>>this.DB+e-h)),l=n;!(P&1);)P>>=1,--l;if((e-=l)<0&&(e+=this.DB,--m),v)c[P].copyTo(s),v=!1;else{for(;l>1;)a.sqrTo(s,S),a.sqrTo(S,s),l-=2;l>0?a.sqrTo(s,S):(C=s,s=S,S=C),a.mulTo(S,c[P],s)}for(;m>=0&&!(i[m]&1<<e);)a.sqrTo(s,S),C=s,s=S,S=C,--e<0&&(e=this.DB-1,--m)}return a.revert(s)},r.prototype.modInverse=function(i){var t=i.isEven();if(this.isEven()&&t||i.signum()==0)return r.ZERO;for(var e=i.clone(),n=this.clone(),s=At(1),a=At(0),c=At(0),l=At(1);e.signum()!=0;){for(;e.isEven();)e.rShiftTo(1,e),t?((!s.isEven()||!a.isEven())&&(s.addTo(this,s),a.subTo(i,a)),s.rShiftTo(1,s)):a.isEven()||a.subTo(i,a),a.rShiftTo(1,a);for(;n.isEven();)n.rShiftTo(1,n),t?((!c.isEven()||!l.isEven())&&(c.addTo(this,c),l.subTo(i,l)),c.rShiftTo(1,c)):l.isEven()||l.subTo(i,l),l.rShiftTo(1,l);e.compareTo(n)>=0?(e.subTo(n,e),t&&s.subTo(c,s),a.subTo(l,a)):(n.subTo(e,n),t&&c.subTo(s,c),l.subTo(a,l))}if(n.compareTo(r.ONE)!=0)return r.ZERO;if(l.compareTo(i)>=0)return l.subtract(i);if(l.signum()<0)l.addTo(i,l);else return l;return l.signum()<0?l.add(i):l},r.prototype.pow=function(i){return this.exp(i,new xa)},r.prototype.gcd=function(i){var t=this.s<0?this.negate():this.clone(),e=i.s<0?i.negate():i.clone();if(t.compareTo(e)<0){var n=t;t=e,e=n}var s=t.getLowestSetBit(),a=e.getLowestSetBit();if(a<0)return t;for(s<a&&(a=s),a>0&&(t.rShiftTo(a,t),e.rShiftTo(a,e));t.signum()>0;)(s=t.getLowestSetBit())>0&&t.rShiftTo(s,t),(s=e.getLowestSetBit())>0&&e.rShiftTo(s,e),t.compareTo(e)>=0?(t.subTo(e,t),t.rShiftTo(1,t)):(e.subTo(t,e),e.rShiftTo(1,e));return a>0&&e.lShiftTo(a,e),e},r.prototype.isProbablePrime=function(i){var t,e=this.abs();if(e.t==1&&e[0]<=it[it.length-1]){for(t=0;t<it.length;++t)if(e[0]==it[t])return!0;return!1}if(e.isEven())return!1;for(t=1;t<it.length;){for(var n=it[t],s=t+1;s<it.length&&n<ka;)n*=it[s++];for(n=e.modInt(n);t<s;)if(n%it[t++]==0)return!1}return e.millerRabin(i)},r.prototype.copyTo=function(i){for(var t=this.t-1;t>=0;--t)i[t]=this[t];i.t=this.t,i.s=this.s},r.prototype.fromInt=function(i){this.t=1,this.s=i<0?-1:0,i>0?this[0]=i:i<-1?this[0]=i+this.DV:this.t=0},r.prototype.fromString=function(i,t){var e;if(t==16)e=4;else if(t==8)e=3;else if(t==256)e=8;else if(t==2)e=1;else if(t==32)e=5;else if(t==4)e=2;else{this.fromRadix(i,t);return}this.t=0,this.s=0;for(var n=i.length,s=!1,a=0;--n>=0;){var c=e==8?+i[n]&255:ni(i,n);if(c<0){i.charAt(n)=="-"&&(s=!0);continue}s=!1,a==0?this[this.t++]=c:a+e>this.DB?(this[this.t-1]|=(c&(1<<this.DB-a)-1)<<a,this[this.t++]=c>>this.DB-a):this[this.t-1]|=c<<a,a+=e,a>=this.DB&&(a-=this.DB)}e==8&&+i[0]&128&&(this.s=-1,a>0&&(this[this.t-1]|=(1<<this.DB-a)-1<<a)),this.clamp(),s&&r.ZERO.subTo(this,this)},r.prototype.clamp=function(){for(var i=this.s&this.DM;this.t>0&&this[this.t-1]==i;)--this.t},r.prototype.dlShiftTo=function(i,t){var e;for(e=this.t-1;e>=0;--e)t[e+i]=this[e];for(e=i-1;e>=0;--e)t[e]=0;t.t=this.t+i,t.s=this.s},r.prototype.drShiftTo=function(i,t){for(var e=i;e<this.t;++e)t[e-i]=this[e];t.t=Math.max(this.t-i,0),t.s=this.s},r.prototype.lShiftTo=function(i,t){for(var e=i%this.DB,n=this.DB-e,s=(1<<n)-1,a=Math.floor(i/this.DB),c=this.s<<e&this.DM,l=this.t-1;l>=0;--l)t[l+a+1]=this[l]>>n|c,c=(this[l]&s)<<e;for(var l=a-1;l>=0;--l)t[l]=0;t[a]=c,t.t=this.t+a+1,t.s=this.s,t.clamp()},r.prototype.rShiftTo=function(i,t){t.s=this.s;var e=Math.floor(i/this.DB);if(e>=this.t){t.t=0;return}var n=i%this.DB,s=this.DB-n,a=(1<<n)-1;t[0]=this[e]>>n;for(var c=e+1;c<this.t;++c)t[c-e-1]|=(this[c]&a)<<s,t[c-e]=this[c]>>n;n>0&&(t[this.t-e-1]|=(this.s&a)<<s),t.t=this.t-e,t.clamp()},r.prototype.subTo=function(i,t){for(var e=0,n=0,s=Math.min(i.t,this.t);e<s;)n+=this[e]-i[e],t[e++]=n&this.DM,n>>=this.DB;if(i.t<this.t){for(n-=i.s;e<this.t;)n+=this[e],t[e++]=n&this.DM,n>>=this.DB;n+=this.s}else{for(n+=this.s;e<i.t;)n-=i[e],t[e++]=n&this.DM,n>>=this.DB;n-=i.s}t.s=n<0?-1:0,n<-1?t[e++]=this.DV+n:n>0&&(t[e++]=n),t.t=e,t.clamp()},r.prototype.multiplyTo=function(i,t){var e=this.abs(),n=i.abs(),s=e.t;for(t.t=s+n.t;--s>=0;)t[s]=0;for(s=0;s<n.t;++s)t[s+e.t]=e.am(0,n[s],t,s,0,e.t);t.s=0,t.clamp(),this.s!=i.s&&r.ZERO.subTo(t,t)},r.prototype.squareTo=function(i){for(var t=this.abs(),e=i.t=2*t.t;--e>=0;)i[e]=0;for(e=0;e<t.t-1;++e){var n=t.am(e,t[e],i,2*e,0,1);(i[e+t.t]+=t.am(e+1,2*t[e],i,2*e+1,n,t.t-e-1))>=t.DV&&(i[e+t.t]-=t.DV,i[e+t.t+1]=1)}i.t>0&&(i[i.t-1]+=t.am(e,t[e],i,2*e,0,1)),i.s=0,i.clamp()},r.prototype.divRemTo=function(i,t,e){var n=i.abs();if(!(n.t<=0)){var s=this.abs();if(s.t<n.t){t!=null&&t.fromInt(0),e!=null&&this.copyTo(e);return}e==null&&(e=N());var a=N(),c=this.s,l=i.s,h=this.DB-_e(n[n.t-1]);h>0?(n.lShiftTo(h,a),s.lShiftTo(h,e)):(n.copyTo(a),s.copyTo(e));var f=a.t,_=a[f-1];if(_!=0){var m=_*(1<<this.F1)+(f>1?a[f-2]>>this.F2:0),P=this.FV/m,v=(1<<this.F1)/m,S=1<<this.F2,C=e.t,q=C-f,V=t??N();for(a.dlShiftTo(q,V),e.compareTo(V)>=0&&(e[e.t++]=1,e.subTo(V,e)),r.ONE.dlShiftTo(f,V),V.subTo(a,a);a.t<f;)a[a.t++]=0;for(;--q>=0;){var H=e[--C]==_?this.DM:Math.floor(e[C]*P+(e[C-1]+S)*v);if((e[C]+=a.am(0,H,e,q,0,f))<H)for(a.dlShiftTo(q,V),e.subTo(V,e);e[C]<--H;)e.subTo(V,e)}t!=null&&(e.drShiftTo(f,t),c!=l&&r.ZERO.subTo(t,t)),e.t=f,e.clamp(),h>0&&e.rShiftTo(h,e),c<0&&r.ZERO.subTo(e,e)}}},r.prototype.invDigit=function(){if(this.t<1)return 0;var i=this[0];if(!(i&1))return 0;var t=i&3;return t=t*(2-(i&15)*t)&15,t=t*(2-(i&255)*t)&255,t=t*(2-((i&65535)*t&65535))&65535,t=t*(2-i*t%this.DV)%this.DV,t>0?this.DV-t:-t},r.prototype.isEven=function(){return(this.t>0?this[0]&1:this.s)==0},r.prototype.exp=function(i,t){if(i>4294967295||i<1)return r.ONE;var e=N(),n=N(),s=t.convert(this),a=_e(i)-1;for(s.copyTo(e);--a>=0;)if(t.sqrTo(e,n),(i&1<<a)>0)t.mulTo(n,s,e);else{var c=e;e=n,n=c}return t.revert(e)},r.prototype.chunkSize=function(i){return Math.floor(Math.LN2*this.DB/Math.log(i))},r.prototype.toRadix=function(i){if(i==null&&(i=10),this.signum()==0||i<2||i>36)return"0";var t=this.chunkSize(i),e=Math.pow(i,t),n=At(e),s=N(),a=N(),c="";for(this.divRemTo(n,s,a);s.signum()>0;)c=(e+a.intValue()).toString(i).substr(1)+c,s.divRemTo(n,s,a);return a.intValue().toString(i)+c},r.prototype.fromRadix=function(i,t){this.fromInt(0),t==null&&(t=10);for(var e=this.chunkSize(t),n=Math.pow(t,e),s=!1,a=0,c=0,l=0;l<i.length;++l){var h=ni(i,l);if(h<0){i.charAt(l)=="-"&&this.signum()==0&&(s=!0);continue}c=t*c+h,++a>=e&&(this.dMultiply(n),this.dAddOffset(c,0),a=0,c=0)}a>0&&(this.dMultiply(Math.pow(t,a)),this.dAddOffset(c,0)),s&&r.ZERO.subTo(this,this)},r.prototype.fromNumber=function(i,t,e){if(typeof t=="number")if(i<2)this.fromInt(1);else for(this.fromNumber(i,e),this.testBit(i-1)||this.bitwiseTo(r.ONE.shiftLeft(i-1),de,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(t);)this.dAddOffset(2,0),this.bitLength()>i&&this.subTo(r.ONE.shiftLeft(i-1),this);else{var n=[],s=i&7;n.length=(i>>3)+1,t.nextBytes(n),s>0?n[0]&=(1<<s)-1:n[0]=0,this.fromString(n,256)}},r.prototype.bitwiseTo=function(i,t,e){var n,s,a=Math.min(i.t,this.t);for(n=0;n<a;++n)e[n]=t(this[n],i[n]);if(i.t<this.t){for(s=i.s&this.DM,n=a;n<this.t;++n)e[n]=t(this[n],s);e.t=this.t}else{for(s=this.s&this.DM,n=a;n<i.t;++n)e[n]=t(s,i[n]);e.t=i.t}e.s=t(this.s,i.s),e.clamp()},r.prototype.changeBit=function(i,t){var e=r.ONE.shiftLeft(i);return this.bitwiseTo(e,t,e),e},r.prototype.addTo=function(i,t){for(var e=0,n=0,s=Math.min(i.t,this.t);e<s;)n+=this[e]+i[e],t[e++]=n&this.DM,n>>=this.DB;if(i.t<this.t){for(n+=i.s;e<this.t;)n+=this[e],t[e++]=n&this.DM,n>>=this.DB;n+=this.s}else{for(n+=this.s;e<i.t;)n+=i[e],t[e++]=n&this.DM,n>>=this.DB;n+=i.s}t.s=n<0?-1:0,n>0?t[e++]=n:n<-1&&(t[e++]=this.DV+n),t.t=e,t.clamp()},r.prototype.dMultiply=function(i){this[this.t]=this.am(0,i-1,this,0,0,this.t),++this.t,this.clamp()},r.prototype.dAddOffset=function(i,t){if(i!=0){for(;this.t<=t;)this[this.t++]=0;for(this[t]+=i;this[t]>=this.DV;)this[t]-=this.DV,++t>=this.t&&(this[this.t++]=0),++this[t]}},r.prototype.multiplyLowerTo=function(i,t,e){var n=Math.min(this.t+i.t,t);for(e.s=0,e.t=n;n>0;)e[--n]=0;for(var s=e.t-this.t;n<s;++n)e[n+this.t]=this.am(0,i[n],e,n,0,this.t);for(var s=Math.min(i.t,t);n<s;++n)this.am(0,i[n],e,n,0,t-n);e.clamp()},r.prototype.multiplyUpperTo=function(i,t,e){--t;var n=e.t=this.t+i.t-t;for(e.s=0;--n>=0;)e[n]=0;for(n=Math.max(t-this.t,0);n<i.t;++n)e[this.t+n-t]=this.am(t-n,i[n],e,0,0,this.t+n-t);e.clamp(),e.drShiftTo(1,e)},r.prototype.modInt=function(i){if(i<=0)return 0;var t=this.DV%i,e=this.s<0?i-1:0;if(this.t>0)if(t==0)e=this[0]%i;else for(var n=this.t-1;n>=0;--n)e=(t*e+this[n])%i;return e},r.prototype.millerRabin=function(i){var t=this.subtract(r.ONE),e=t.getLowestSetBit();if(e<=0)return!1;var n=t.shiftRight(e);i=i+1>>1,i>it.length&&(i=it.length);for(var s=N(),a=0;a<i;++a){s.fromInt(it[Math.floor(Math.random()*it.length)]);var c=s.modPow(n,this);if(c.compareTo(r.ONE)!=0&&c.compareTo(t)!=0){for(var l=1;l++<e&&c.compareTo(t)!=0;)if(c=c.modPowInt(2,this),c.compareTo(r.ONE)==0)return!1;if(c.compareTo(t)!=0)return!1}}return!0},r.prototype.square=function(){var i=N();return this.squareTo(i),i},r.prototype.gcda=function(i,t){var e=this.s<0?this.negate():this.clone(),n=i.s<0?i.negate():i.clone();if(e.compareTo(n)<0){var s=e;e=n,n=s}var a=e.getLowestSetBit(),c=n.getLowestSetBit();if(c<0){t(e);return}a<c&&(c=a),c>0&&(e.rShiftTo(c,e),n.rShiftTo(c,n));var l=function(){(a=e.getLowestSetBit())>0&&e.rShiftTo(a,e),(a=n.getLowestSetBit())>0&&n.rShiftTo(a,n),e.compareTo(n)>=0?(e.subTo(n,e),e.rShiftTo(1,e)):(n.subTo(e,n),n.rShiftTo(1,n)),e.signum()>0?setTimeout(l,0):(c>0&&n.lShiftTo(c,n),setTimeout(function(){t(n)},0))};setTimeout(l,10)},r.prototype.fromNumberAsync=function(i,t,e,n){if(typeof t=="number")if(i<2)this.fromInt(1);else{this.fromNumber(i,e),this.testBit(i-1)||this.bitwiseTo(r.ONE.shiftLeft(i-1),de,this),this.isEven()&&this.dAddOffset(1,0);var s=this,a=function(){s.dAddOffset(2,0),s.bitLength()>i&&s.subTo(r.ONE.shiftLeft(i-1),s),s.isProbablePrime(t)?setTimeout(function(){n()},0):setTimeout(a,0)};setTimeout(a,0)}else{var c=[],l=i&7;c.length=(i>>3)+1,t.nextBytes(c),l>0?c[0]&=(1<<l)-1:c[0]=0,this.fromString(c,256)}},r}(),xa=function(){function r(){}return r.prototype.convert=function(i){return i},r.prototype.revert=function(i){return i},r.prototype.mulTo=function(i,t,e){i.multiplyTo(t,e)},r.prototype.sqrTo=function(i,t){i.squareTo(t)},r}(),Yn=function(){function r(i){this.m=i}return r.prototype.convert=function(i){return i.s<0||i.compareTo(this.m)>=0?i.mod(this.m):i},r.prototype.revert=function(i){return i},r.prototype.reduce=function(i){i.divRemTo(this.m,null,i)},r.prototype.mulTo=function(i,t,e){i.multiplyTo(t,e),this.reduce(e)},r.prototype.sqrTo=function(i,t){i.squareTo(t),this.reduce(t)},r}(),ti=function(){function r(i){this.m=i,this.mp=i.invDigit(),this.mpl=this.mp&32767,this.mph=this.mp>>15,this.um=(1<<i.DB-15)-1,this.mt2=2*i.t}return r.prototype.convert=function(i){var t=N();return i.abs().dlShiftTo(this.m.t,t),t.divRemTo(this.m,null,t),i.s<0&&t.compareTo(D.ZERO)>0&&this.m.subTo(t,t),t},r.prototype.revert=function(i){var t=N();return i.copyTo(t),this.reduce(t),t},r.prototype.reduce=function(i){for(;i.t<=this.mt2;)i[i.t++]=0;for(var t=0;t<this.m.t;++t){var e=i[t]&32767,n=e*this.mpl+((e*this.mph+(i[t]>>15)*this.mpl&this.um)<<15)&i.DM;for(e=t+this.m.t,i[e]+=this.m.am(0,n,i,t,0,this.m.t);i[e]>=i.DV;)i[e]-=i.DV,i[++e]++}i.clamp(),i.drShiftTo(this.m.t,i),i.compareTo(this.m)>=0&&i.subTo(this.m,i)},r.prototype.mulTo=function(i,t,e){i.multiplyTo(t,e),this.reduce(e)},r.prototype.sqrTo=function(i,t){i.squareTo(t),this.reduce(t)},r}(),Aa=function(){function r(i){this.m=i,this.r2=N(),this.q3=N(),D.ONE.dlShiftTo(2*i.t,this.r2),this.mu=this.r2.divide(i)}return r.prototype.convert=function(i){if(i.s<0||i.t>2*this.m.t)return i.mod(this.m);if(i.compareTo(this.m)<0)return i;var t=N();return i.copyTo(t),this.reduce(t),t},r.prototype.revert=function(i){return i},r.prototype.reduce=function(i){for(i.drShiftTo(this.m.t-1,this.r2),i.t>this.m.t+1&&(i.t=this.m.t+1,i.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);i.compareTo(this.r2)<0;)i.dAddOffset(1,this.m.t+1);for(i.subTo(this.r2,i);i.compareTo(this.m)>=0;)i.subTo(this.m,i)},r.prototype.mulTo=function(i,t,e){i.multiplyTo(t,e),this.reduce(e)},r.prototype.sqrTo=function(i,t){i.squareTo(t),this.reduce(t)},r}();function N(){return new D(null)}function W(r,i){return new D(r,i)}var ei=typeof navigator<"u";ei&&Zn&&navigator.appName=="Microsoft Internet Explorer"?(D.prototype.am=function(i,t,e,n,s,a){for(var c=t&32767,l=t>>15;--a>=0;){var h=this[i]&32767,f=this[i++]>>15,_=l*h+f*c;h=c*h+((_&32767)<<15)+e[n]+(s&1073741823),s=(h>>>30)+(_>>>15)+l*f+(s>>>30),e[n++]=h&1073741823}return s},xt=30):ei&&Zn&&navigator.appName!="Netscape"?(D.prototype.am=function(i,t,e,n,s,a){for(;--a>=0;){var c=t*this[i++]+e[n]+s;s=Math.floor(c/67108864),e[n++]=c&67108863}return s},xt=26):(D.prototype.am=function(i,t,e,n,s,a){for(var c=t&16383,l=t>>14;--a>=0;){var h=this[i]&16383,f=this[i++]>>14,_=l*h+f*c;h=c*h+((_&16383)<<14)+e[n]+s,s=(h>>28)+(_>>14)+l*f,e[n++]=h&268435455}return s},xt=28),D.prototype.DB=xt,D.prototype.DM=(1<<xt)-1,D.prototype.DV=1<<xt;var Je=52;D.prototype.FV=Math.pow(2,Je),D.prototype.F1=Je-xt,D.prototype.F2=2*xt-Je;var fe=[],Wt,pt;for(Wt=48,pt=0;pt<=9;++pt)fe[Wt++]=pt;for(Wt=97,pt=10;pt<36;++pt)fe[Wt++]=pt;for(Wt=65,pt=10;pt<36;++pt)fe[Wt++]=pt;function ni(r,i){var t=fe[r.charCodeAt(i)];return t??-1}function At(r){var i=N();return i.fromInt(r),i}function _e(r){var i=1,t;return(t=r>>>16)!=0&&(r=t,i+=16),(t=r>>8)!=0&&(r=t,i+=8),(t=r>>4)!=0&&(r=t,i+=4),(t=r>>2)!=0&&(r=t,i+=2),(t=r>>1)!=0&&(r=t,i+=1),i}D.ZERO=At(0),D.ONE=At(1);var Da=function(){function r(){this.i=0,this.j=0,this.S=[]}return r.prototype.init=function(i){var t,e,n;for(t=0;t<256;++t)this.S[t]=t;for(e=0,t=0;t<256;++t)e=e+this.S[t]+i[t%i.length]&255,n=this.S[t],this.S[t]=this.S[e],this.S[e]=n;this.i=0,this.j=0},r.prototype.next=function(){var i;return this.i=this.i+1&255,this.j=this.j+this.S[this.i]&255,i=this.S[this.i],this.S[this.i]=this.S[this.j],this.S[this.j]=i,this.S[i+this.S[this.i]&255]},r}();function Ra(){return new Da}var ii=256,ge,Dt=null,_t;if(Dt==null){Dt=[],_t=0;var be=void 0;if(typeof window<"u"&&window.crypto&&window.crypto.getRandomValues){var Qe=new Uint32Array(256);for(window.crypto.getRandomValues(Qe),be=0;be<Qe.length;++be)Dt[_t++]=Qe[be]&255}var me=0,ye=function(r){if(me=me||0,me>=256||_t>=ii){window.removeEventListener?window.removeEventListener("mousemove",ye,!1):window.detachEvent&&window.detachEvent("onmousemove",ye);return}try{var i=r.x+r.y;Dt[_t++]=i&255,me+=1}catch{}};typeof window<"u"&&(window.addEventListener?window.addEventListener("mousemove",ye,!1):window.attachEvent&&window.attachEvent("onmousemove",ye))}function Ia(){if(ge==null){for(ge=Ra();_t<ii;){var r=Math.floor(65536*Math.random());Dt[_t++]=r&255}for(ge.init(Dt),_t=0;_t<Dt.length;++_t)Dt[_t]=0;_t=0}return ge.next()}var Ze=function(){function r(){}return r.prototype.nextBytes=function(i){for(var t=0;t<i.length;++t)i[t]=Ia()},r}();function Oa(r,i){if(i<r.length+22)return console.error("Message too long for RSA"),null;for(var t=i-r.length-6,e="",n=0;n<t;n+=2)e+="ff";var s="0001"+e+"00"+r;return W(s,16)}function Ba(r,i){if(i<r.length+11)return console.error("Message too long for RSA"),null;for(var t=[],e=r.length-1;e>=0&&i>0;){var n=r.charCodeAt(e--);n<128?t[--i]=n:n>127&&n<2048?(t[--i]=n&63|128,t[--i]=n>>6|192):(t[--i]=n&63|128,t[--i]=n>>6&63|128,t[--i]=n>>12|224)}t[--i]=0;for(var s=new Ze,a=[];i>2;){for(a[0]=0;a[0]==0;)s.nextBytes(a);t[--i]=a[0]}return t[--i]=2,t[--i]=0,new D(t)}var Na=function(){function r(){this.n=null,this.e=0,this.d=null,this.p=null,this.q=null,this.dmp1=null,this.dmq1=null,this.coeff=null}return r.prototype.doPublic=function(i){return i.modPowInt(this.e,this.n)},r.prototype.doPrivate=function(i){if(this.p==null||this.q==null)return i.modPow(this.d,this.n);for(var t=i.mod(this.p).modPow(this.dmp1,this.p),e=i.mod(this.q).modPow(this.dmq1,this.q);t.compareTo(e)<0;)t=t.add(this.p);return t.subtract(e).multiply(this.coeff).mod(this.p).multiply(this.q).add(e)},r.prototype.setPublic=function(i,t){i!=null&&t!=null&&i.length>0&&t.length>0?(this.n=W(i,16),this.e=parseInt(t,16)):console.error("Invalid RSA public key")},r.prototype.encrypt=function(i){var t=this.n.bitLength()+7>>3,e=Ba(i,t);if(e==null)return null;var n=this.doPublic(e);if(n==null)return null;for(var s=n.toString(16),a=s.length,c=0;c<t*2-a;c++)s="0"+s;return s},r.prototype.setPrivate=function(i,t,e){i!=null&&t!=null&&i.length>0&&t.length>0?(this.n=W(i,16),this.e=parseInt(t,16),this.d=W(e,16)):console.error("Invalid RSA private key")},r.prototype.setPrivateEx=function(i,t,e,n,s,a,c,l){i!=null&&t!=null&&i.length>0&&t.length>0?(this.n=W(i,16),this.e=parseInt(t,16),this.d=W(e,16),this.p=W(n,16),this.q=W(s,16),this.dmp1=W(a,16),this.dmq1=W(c,16),this.coeff=W(l,16)):console.error("Invalid RSA private key")},r.prototype.generate=function(i,t){var e=new Ze,n=i>>1;this.e=parseInt(t,16);for(var s=new D(t,16);;){for(;this.p=new D(i-n,1,e),!(this.p.subtract(D.ONE).gcd(s).compareTo(D.ONE)==0&&this.p.isProbablePrime(10)););for(;this.q=new D(n,1,e),!(this.q.subtract(D.ONE).gcd(s).compareTo(D.ONE)==0&&this.q.isProbablePrime(10)););if(this.p.compareTo(this.q)<=0){var a=this.p;this.p=this.q,this.q=a}var c=this.p.subtract(D.ONE),l=this.q.subtract(D.ONE),h=c.multiply(l);if(h.gcd(s).compareTo(D.ONE)==0){this.n=this.p.multiply(this.q),this.d=s.modInverse(h),this.dmp1=this.d.mod(c),this.dmq1=this.d.mod(l),this.coeff=this.q.modInverse(this.p);break}}},r.prototype.decrypt=function(i){var t=W(i,16),e=this.doPrivate(t);return e==null?null:Ma(e,this.n.bitLength()+7>>3)},r.prototype.generateAsync=function(i,t,e){var n=new Ze,s=i>>1;this.e=parseInt(t,16);var a=new D(t,16),c=this,l=function(){var h=function(){if(c.p.compareTo(c.q)<=0){var m=c.p;c.p=c.q,c.q=m}var P=c.p.subtract(D.ONE),v=c.q.subtract(D.ONE),S=P.multiply(v);S.gcd(a).compareTo(D.ONE)==0?(c.n=c.p.multiply(c.q),c.d=a.modInverse(S),c.dmp1=c.d.mod(P),c.dmq1=c.d.mod(v),c.coeff=c.q.modInverse(c.p),setTimeout(function(){e()},0)):setTimeout(l,0)},f=function(){c.q=N(),c.q.fromNumberAsync(s,1,n,function(){c.q.subtract(D.ONE).gcda(a,function(m){m.compareTo(D.ONE)==0&&c.q.isProbablePrime(10)?setTimeout(h,0):setTimeout(f,0)})})},_=function(){c.p=N(),c.p.fromNumberAsync(i-s,1,n,function(){c.p.subtract(D.ONE).gcda(a,function(m){m.compareTo(D.ONE)==0&&c.p.isProbablePrime(10)?setTimeout(f,0):setTimeout(_,0)})})};setTimeout(_,0)};setTimeout(l,0)},r.prototype.sign=function(i,t,e){var n=Fa(e),s=n+t(i).toString(),a=Oa(s,this.n.bitLength()/4);if(a==null)return null;var c=this.doPrivate(a);if(c==null)return null;var l=c.toString(16);return l.length&1?"0"+l:l},r.prototype.verify=function(i,t,e){var n=W(t,16),s=this.doPublic(n);if(s==null)return null;var a=s.toString(16).replace(/^1f+00/,""),c=Ua(a);return c==e(i).toString()},r}();function Ma(r,i){for(var t=r.toByteArray(),e=0;e<t.length&&t[e]==0;)++e;if(t.length-e!=i-1||t[e]!=2)return null;for(++e;t[e]!=0;)if(++e>=t.length)return null;for(var n="";++e<t.length;){var s=t[e]&255;s<128?n+=String.fromCharCode(s):s>191&&s<224?(n+=String.fromCharCode((s&31)<<6|t[e+1]&63),++e):(n+=String.fromCharCode((s&15)<<12|(t[e+1]&63)<<6|t[e+2]&63),e+=2)}return n}var we={md2:"3020300c06082a864886f70d020205000410",md5:"3020300c06082a864886f70d020505000410",sha1:"3021300906052b0e03021a05000414",sha224:"302d300d06096086480165030402040500041c",sha256:"3031300d060960864801650304020105000420",sha384:"3041300d060960864801650304020205000430",sha512:"3051300d060960864801650304020305000440",ripemd160:"3021300906052b2403020105000414"};function Fa(r){return we[r]||""}function Ua(r){for(var i in we)if(we.hasOwnProperty(i)){var t=we[i],e=t.length;if(r.substr(0,e)==t)return r.substr(e)}return r}/*!
|
|
12
12
|
Copyright (c) 2011, Yahoo! Inc. All rights reserved.
|
|
13
13
|
Code licensed under the BSD License:
|
|
14
14
|
http://developer.yahoo.com/yui/license.html
|
|
@@ -20,18 +20,18 @@ version: 2.9.0
|
|
|
20
20
|
* @version asn1 1.0.13 (2017-Jun-02)
|
|
21
21
|
* @since jsrsasign 2.1
|
|
22
22
|
* @license <a href="https://kjur.github.io/jsrsasign/license/">MIT License</a>
|
|
23
|
-
*/var y={};(typeof y.asn1>"u"||!y.asn1)&&(y.asn1={}),y.asn1.ASN1Util=new function(){this.integerToByteHex=function(r){var i=r.toString(16);return i.length%2==1&&(i="0"+i),i},this.bigIntToMinTwosComplementsHex=function(r){var i=r.toString(16);if(i.substr(0,1)!="-")i.length%2==1?i="0"+i:i.match(/^[0-7]/)||(i="00"+i);else{var t=i.substr(1),e=t.length;e%2==1?e+=1:i.match(/^[0-7]/)||(e+=2);for(var n="",s=0;s<e;s++)n+="f";var a=new D(n,16),c=a.xor(r).add(D.ONE);i=c.toString(16).replace(/^-/,"")}return i},this.getPEMStringFromHex=function(r,i){return hextopem(r,i)},this.newObject=function(r){var i=y,t=i.asn1,e=t.DERBoolean,n=t.DERInteger,s=t.DERBitString,a=t.DEROctetString,c=t.DERNull,l=t.DERObjectIdentifier,h=t.DEREnumerated,f=t.DERUTF8String,_=t.DERNumericString,m=t.DERPrintableString,P=t.DERTeletexString,v=t.DERIA5String,S=t.DERUTCTime,C=t.DERGeneralizedTime,q=t.DERSequence,V=t.DERSet,H=t.DERTaggedObject,at=t.ASN1Util.newObject,Q=Object.keys(r);if(Q.length!=1)throw"key of param shall be only one.";var k=Q[0];if(":bool:int:bitstr:octstr:null:oid:enum:utf8str:numstr:prnstr:telstr:ia5str:utctime:gentime:seq:set:tag:".indexOf(":"+k+":")==-1)throw"undefined key: "+k;if(k=="bool")return new e(r[k]);if(k=="int")return new n(r[k]);if(k=="bitstr")return new s(r[k]);if(k=="octstr")return new a(r[k]);if(k=="null")return new c(r[k]);if(k=="oid")return new l(r[k]);if(k=="enum")return new h(r[k]);if(k=="utf8str")return new f(r[k]);if(k=="numstr")return new _(r[k]);if(k=="prnstr")return new m(r[k]);if(k=="telstr")return new P(r[k]);if(k=="ia5str")return new v(r[k]);if(k=="utctime")return new S(r[k]);if(k=="gentime")return new C(r[k]);if(k=="seq"){for(var ut=r[k],Et=[],Tt=0;Tt<ut.length;Tt++){var _n=at(ut[Tt]);Et.push(_n)}return new q({array:Et})}if(k=="set"){for(var ut=r[k],Et=[],Tt=0;Tt<ut.length;Tt++){var _n=at(ut[Tt]);Et.push(_n)}return new V({array:Et})}if(k=="tag"){var bt=r[k];if(Object.prototype.toString.call(bt)==="[object Array]"&&bt.length==3){var mc=at(bt[2]);return new H({tag:bt[0],explicit:bt[1],obj:mc})}else{var Oe={};if(bt.explicit!==void 0&&(Oe.explicit=bt.explicit),bt.tag!==void 0&&(Oe.tag=bt.tag),bt.obj===void 0)throw"obj shall be specified for 'tag'.";return Oe.obj=at(bt.obj),new H(Oe)}}},this.jsonToASN1HEX=function(r){var i=this.newObject(r);return i.getEncodedHex()}},y.asn1.ASN1Util.oidHexToInt=function(r){for(var n="",i=parseInt(r.substr(0,2),16),t=Math.floor(i/40),e=i%40,n=t+"."+e,s="",a=2;a<r.length;a+=2){var c=parseInt(r.substr(a,2),16),l=("00000000"+c.toString(2)).slice(-8);if(s=s+l.substr(1,7),l.substr(0,1)=="0"){var h=new D(s,2);n=n+"."+h.toString(10),s=""}}return n},y.asn1.ASN1Util.oidIntToHex=function(r){var i=function(c){var l=c.toString(16);return l.length==1&&(l="0"+l),l},t=function(c){var l="",h=new D(c,10),f=h.toString(2),_=7-f.length%7;_==7&&(_=0);for(var m="",P=0;P<_;P++)m+="0";f=m+f;for(var P=0;P<f.length-1;P+=7){var v=f.substr(P,7);P!=f.length-7&&(v="1"+v),l+=i(parseInt(v,2))}return l};if(!r.match(/^[0-9.]+$/))throw"malformed oid string: "+r;var e="",n=r.split("."),s=parseInt(n[0])*40+parseInt(n[1]);e+=i(s),n.splice(0,2);for(var a=0;a<n.length;a++)e+=t(n[a]);return e},y.asn1.ASN1Object=function(){var r="";this.getLengthHexFromValue=function(){if(typeof this.hV>"u"||this.hV==null)throw"this.hV is null or undefined.";if(this.hV.length%2==1)throw"value hex must be even length: n="+r.length+",v="+this.hV;var i=this.hV.length/2,t=i.toString(16);if(t.length%2==1&&(t="0"+t),i<128)return t;var e=t.length/2;if(e>15)throw"ASN.1 length too long to represent by 8x: n = "+i.toString(16);var n=128+e;return n.toString(16)+t},this.getEncodedHex=function(){return(this.hTLV==null||this.isModified)&&(this.hV=this.getFreshValueHex(),this.hL=this.getLengthHexFromValue(),this.hTLV=this.hT+this.hL+this.hV,this.isModified=!1),this.hTLV},this.getValueHex=function(){return this.getEncodedHex(),this.hV},this.getFreshValueHex=function(){return""}},y.asn1.DERAbstractString=function(r){y.asn1.DERAbstractString.superclass.constructor.call(this),this.getString=function(){return this.s},this.setString=function(i){this.hTLV=null,this.isModified=!0,this.s=i,this.hV=stohex(this.s)},this.setStringHex=function(i){this.hTLV=null,this.isModified=!0,this.s=null,this.hV=i},this.getFreshValueHex=function(){return this.hV},typeof r<"u"&&(typeof r=="string"?this.setString(r):typeof r.str<"u"?this.setString(r.str):typeof r.hex<"u"&&this.setStringHex(r.hex))},z.lang.extend(y.asn1.DERAbstractString,y.asn1.ASN1Object),y.asn1.DERAbstractTime=function(r){y.asn1.DERAbstractTime.superclass.constructor.call(this),this.localDateToUTC=function(i){utc=i.getTime()+i.getTimezoneOffset()*6e4;var t=new Date(utc);return t},this.formatDate=function(i,t,e){var n=this.zeroPadding,s=this.localDateToUTC(i),a=String(s.getFullYear());t=="utc"&&(a=a.substr(2,2));var c=n(String(s.getMonth()+1),2),l=n(String(s.getDate()),2),h=n(String(s.getHours()),2),f=n(String(s.getMinutes()),2),_=n(String(s.getSeconds()),2),m=a+c+l+h+f+_;if(e===!0){var P=s.getMilliseconds();if(P!=0){var v=n(String(P),3);v=v.replace(/[0]+$/,""),m=m+"."+v}}return m+"Z"},this.zeroPadding=function(i,t){return i.length>=t?i:new Array(t-i.length+1).join("0")+i},this.getString=function(){return this.s},this.setString=function(i){this.hTLV=null,this.isModified=!0,this.s=i,this.hV=stohex(i)},this.setByDateValue=function(i,t,e,n,s,a){var c=new Date(Date.UTC(i,t-1,e,n,s,a,0));this.setByDate(c)},this.getFreshValueHex=function(){return this.hV}},z.lang.extend(y.asn1.DERAbstractTime,y.asn1.ASN1Object),y.asn1.DERAbstractStructured=function(r){y.asn1.DERAbstractString.superclass.constructor.call(this),this.setByASN1ObjectArray=function(i){this.hTLV=null,this.isModified=!0,this.asn1Array=i},this.appendASN1Object=function(i){this.hTLV=null,this.isModified=!0,this.asn1Array.push(i)},this.asn1Array=new Array,typeof r<"u"&&typeof r.array<"u"&&(this.asn1Array=r.array)},z.lang.extend(y.asn1.DERAbstractStructured,y.asn1.ASN1Object),y.asn1.DERBoolean=function(){y.asn1.DERBoolean.superclass.constructor.call(this),this.hT="01",this.hTLV="0101ff"},z.lang.extend(y.asn1.DERBoolean,y.asn1.ASN1Object),y.asn1.DERInteger=function(r){y.asn1.DERInteger.superclass.constructor.call(this),this.hT="02",this.setByBigInteger=function(i){this.hTLV=null,this.isModified=!0,this.hV=y.asn1.ASN1Util.bigIntToMinTwosComplementsHex(i)},this.setByInteger=function(i){var t=new D(String(i),10);this.setByBigInteger(t)},this.setValueHex=function(i){this.hV=i},this.getFreshValueHex=function(){return this.hV},typeof r<"u"&&(typeof r.bigint<"u"?this.setByBigInteger(r.bigint):typeof r.int<"u"?this.setByInteger(r.int):typeof r=="number"?this.setByInteger(r):typeof r.hex<"u"&&this.setValueHex(r.hex))},z.lang.extend(y.asn1.DERInteger,y.asn1.ASN1Object),y.asn1.DERBitString=function(r){if(r!==void 0&&typeof r.obj<"u"){var i=y.asn1.ASN1Util.newObject(r.obj);r.hex="00"+i.getEncodedHex()}y.asn1.DERBitString.superclass.constructor.call(this),this.hT="03",this.setHexValueIncludingUnusedBits=function(t){this.hTLV=null,this.isModified=!0,this.hV=t},this.setUnusedBitsAndHexValue=function(t,e){if(t<0||7<t)throw"unused bits shall be from 0 to 7: u = "+t;var n="0"+t;this.hTLV=null,this.isModified=!0,this.hV=n+e},this.setByBinaryString=function(t){t=t.replace(/0+$/,"");var e=8-t.length%8;e==8&&(e=0);for(var n=0;n<=e;n++)t+="0";for(var s="",n=0;n<t.length-1;n+=8){var a=t.substr(n,8),c=parseInt(a,2).toString(16);c.length==1&&(c="0"+c),s+=c}this.hTLV=null,this.isModified=!0,this.hV="0"+e+s},this.setByBooleanArray=function(t){for(var e="",n=0;n<t.length;n++)t[n]==!0?e+="1":e+="0";this.setByBinaryString(e)},this.newFalseArray=function(t){for(var e=new Array(t),n=0;n<t;n++)e[n]=!1;return e},this.getFreshValueHex=function(){return this.hV},typeof r<"u"&&(typeof r=="string"&&r.toLowerCase().match(/^[0-9a-f]+$/)?this.setHexValueIncludingUnusedBits(r):typeof r.hex<"u"?this.setHexValueIncludingUnusedBits(r.hex):typeof r.bin<"u"?this.setByBinaryString(r.bin):typeof r.array<"u"&&this.setByBooleanArray(r.array))},z.lang.extend(y.asn1.DERBitString,y.asn1.ASN1Object),y.asn1.DEROctetString=function(r){if(r!==void 0&&typeof r.obj<"u"){var i=y.asn1.ASN1Util.newObject(r.obj);r.hex=i.getEncodedHex()}y.asn1.DEROctetString.superclass.constructor.call(this,r),this.hT="04"},z.lang.extend(y.asn1.DEROctetString,y.asn1.DERAbstractString),y.asn1.DERNull=function(){y.asn1.DERNull.superclass.constructor.call(this),this.hT="05",this.hTLV="0500"},z.lang.extend(y.asn1.DERNull,y.asn1.ASN1Object),y.asn1.DERObjectIdentifier=function(r){var i=function(e){var n=e.toString(16);return n.length==1&&(n="0"+n),n},t=function(e){var n="",s=new D(e,10),a=s.toString(2),c=7-a.length%7;c==7&&(c=0);for(var l="",h=0;h<c;h++)l+="0";a=l+a;for(var h=0;h<a.length-1;h+=7){var f=a.substr(h,7);h!=a.length-7&&(f="1"+f),n+=i(parseInt(f,2))}return n};y.asn1.DERObjectIdentifier.superclass.constructor.call(this),this.hT="06",this.setValueHex=function(e){this.hTLV=null,this.isModified=!0,this.s=null,this.hV=e},this.setValueOidString=function(e){if(!e.match(/^[0-9.]+$/))throw"malformed oid string: "+e;var n="",s=e.split("."),a=parseInt(s[0])*40+parseInt(s[1]);n+=i(a),s.splice(0,2);for(var c=0;c<s.length;c++)n+=t(s[c]);this.hTLV=null,this.isModified=!0,this.s=null,this.hV=n},this.setValueName=function(e){var n=y.asn1.x509.OID.name2oid(e);if(n!=="")this.setValueOidString(n);else throw"DERObjectIdentifier oidName undefined: "+e},this.getFreshValueHex=function(){return this.hV},r!==void 0&&(typeof r=="string"?r.match(/^[0-2].[0-9.]+$/)?this.setValueOidString(r):this.setValueName(r):r.oid!==void 0?this.setValueOidString(r.oid):r.hex!==void 0?this.setValueHex(r.hex):r.name!==void 0&&this.setValueName(r.name))},z.lang.extend(y.asn1.DERObjectIdentifier,y.asn1.ASN1Object),y.asn1.DEREnumerated=function(r){y.asn1.DEREnumerated.superclass.constructor.call(this),this.hT="0a",this.setByBigInteger=function(i){this.hTLV=null,this.isModified=!0,this.hV=y.asn1.ASN1Util.bigIntToMinTwosComplementsHex(i)},this.setByInteger=function(i){var t=new D(String(i),10);this.setByBigInteger(t)},this.setValueHex=function(i){this.hV=i},this.getFreshValueHex=function(){return this.hV},typeof r<"u"&&(typeof r.int<"u"?this.setByInteger(r.int):typeof r=="number"?this.setByInteger(r):typeof r.hex<"u"&&this.setValueHex(r.hex))},z.lang.extend(y.asn1.DEREnumerated,y.asn1.ASN1Object),y.asn1.DERUTF8String=function(r){y.asn1.DERUTF8String.superclass.constructor.call(this,r),this.hT="0c"},z.lang.extend(y.asn1.DERUTF8String,y.asn1.DERAbstractString),y.asn1.DERNumericString=function(r){y.asn1.DERNumericString.superclass.constructor.call(this,r),this.hT="12"},z.lang.extend(y.asn1.DERNumericString,y.asn1.DERAbstractString),y.asn1.DERPrintableString=function(r){y.asn1.DERPrintableString.superclass.constructor.call(this,r),this.hT="13"},z.lang.extend(y.asn1.DERPrintableString,y.asn1.DERAbstractString),y.asn1.DERTeletexString=function(r){y.asn1.DERTeletexString.superclass.constructor.call(this,r),this.hT="14"},z.lang.extend(y.asn1.DERTeletexString,y.asn1.DERAbstractString),y.asn1.DERIA5String=function(r){y.asn1.DERIA5String.superclass.constructor.call(this,r),this.hT="16"},z.lang.extend(y.asn1.DERIA5String,y.asn1.DERAbstractString),y.asn1.DERUTCTime=function(r){y.asn1.DERUTCTime.superclass.constructor.call(this,r),this.hT="17",this.setByDate=function(i){this.hTLV=null,this.isModified=!0,this.date=i,this.s=this.formatDate(this.date,"utc"),this.hV=stohex(this.s)},this.getFreshValueHex=function(){return typeof this.date>"u"&&typeof this.s>"u"&&(this.date=new Date,this.s=this.formatDate(this.date,"utc"),this.hV=stohex(this.s)),this.hV},r!==void 0&&(r.str!==void 0?this.setString(r.str):typeof r=="string"&&r.match(/^[0-9]{12}Z$/)?this.setString(r):r.hex!==void 0?this.setStringHex(r.hex):r.date!==void 0&&this.setByDate(r.date))},z.lang.extend(y.asn1.DERUTCTime,y.asn1.DERAbstractTime),y.asn1.DERGeneralizedTime=function(r){y.asn1.DERGeneralizedTime.superclass.constructor.call(this,r),this.hT="18",this.withMillis=!1,this.setByDate=function(i){this.hTLV=null,this.isModified=!0,this.date=i,this.s=this.formatDate(this.date,"gen",this.withMillis),this.hV=stohex(this.s)},this.getFreshValueHex=function(){return this.date===void 0&&this.s===void 0&&(this.date=new Date,this.s=this.formatDate(this.date,"gen",this.withMillis),this.hV=stohex(this.s)),this.hV},r!==void 0&&(r.str!==void 0?this.setString(r.str):typeof r=="string"&&r.match(/^[0-9]{14}Z$/)?this.setString(r):r.hex!==void 0?this.setStringHex(r.hex):r.date!==void 0&&this.setByDate(r.date),r.millis===!0&&(this.withMillis=!0))},z.lang.extend(y.asn1.DERGeneralizedTime,y.asn1.DERAbstractTime),y.asn1.DERSequence=function(r){y.asn1.DERSequence.superclass.constructor.call(this,r),this.hT="30",this.getFreshValueHex=function(){for(var i="",t=0;t<this.asn1Array.length;t++){var e=this.asn1Array[t];i+=e.getEncodedHex()}return this.hV=i,this.hV}},z.lang.extend(y.asn1.DERSequence,y.asn1.DERAbstractStructured),y.asn1.DERSet=function(r){y.asn1.DERSet.superclass.constructor.call(this,r),this.hT="31",this.sortFlag=!0,this.getFreshValueHex=function(){for(var i=new Array,t=0;t<this.asn1Array.length;t++){var e=this.asn1Array[t];i.push(e.getEncodedHex())}return this.sortFlag==!0&&i.sort(),this.hV=i.join(""),this.hV},typeof r<"u"&&typeof r.sortflag<"u"&&r.sortflag==!1&&(this.sortFlag=!1)},z.lang.extend(y.asn1.DERSet,y.asn1.DERAbstractStructured),y.asn1.DERTaggedObject=function(r){y.asn1.DERTaggedObject.superclass.constructor.call(this),this.hT="a0",this.hV="",this.isExplicit=!0,this.asn1Object=null,this.setASN1Object=function(i,t,e){this.hT=t,this.isExplicit=i,this.asn1Object=e,this.isExplicit?(this.hV=this.asn1Object.getEncodedHex(),this.hTLV=null,this.isModified=!0):(this.hV=null,this.hTLV=e.getEncodedHex(),this.hTLV=this.hTLV.replace(/^../,t),this.isModified=!1)},this.getFreshValueHex=function(){return this.hV},typeof r<"u"&&(typeof r.tag<"u"&&(this.hT=r.tag),typeof r.explicit<"u"&&(this.isExplicit=r.explicit),typeof r.obj<"u"&&(this.asn1Object=r.obj,this.setASN1Object(this.isExplicit,this.hT,this.asn1Object)))},z.lang.extend(y.asn1.DERTaggedObject,y.asn1.ASN1Object);var La=function(){var r=function(i,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(e[s]=n[s])},r(i,t)};return function(i,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");r(i,t);function e(){this.constructor=i}i.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}}(),si=function(r){La(i,r);function i(t){var e=r.call(this)||this;return t&&(typeof t=="string"?e.parseKey(t):(i.hasPrivateKeyProperty(t)||i.hasPublicKeyProperty(t))&&e.parsePropertiesFrom(t)),e}return i.prototype.parseKey=function(t){try{var e=0,n=0,s=/^\s*(?:[0-9A-Fa-f][0-9A-Fa-f]\s*)+$/,a=s.test(t)?Pa.decode(t):Ge.unarmor(t),c=Ca.decode(a);if(c.sub.length===3&&(c=c.sub[2].sub[0]),c.sub.length===9){e=c.sub[1].getHexStringValue(),this.n=W(e,16),n=c.sub[2].getHexStringValue(),this.e=parseInt(n,16);var l=c.sub[3].getHexStringValue();this.d=W(l,16);var h=c.sub[4].getHexStringValue();this.p=W(h,16);var f=c.sub[5].getHexStringValue();this.q=W(f,16);var _=c.sub[6].getHexStringValue();this.dmp1=W(_,16);var m=c.sub[7].getHexStringValue();this.dmq1=W(m,16);var P=c.sub[8].getHexStringValue();this.coeff=W(P,16)}else if(c.sub.length===2)if(c.sub[0].sub){var v=c.sub[1],S=v.sub[0];e=S.sub[0].getHexStringValue(),this.n=W(e,16),n=S.sub[1].getHexStringValue(),this.e=parseInt(n,16)}else e=c.sub[0].getHexStringValue(),this.n=W(e,16),n=c.sub[1].getHexStringValue(),this.e=parseInt(n,16);else return!1;return!0}catch{return!1}},i.prototype.getPrivateBaseKey=function(){var t={array:[new y.asn1.DERInteger({int:0}),new y.asn1.DERInteger({bigint:this.n}),new y.asn1.DERInteger({int:this.e}),new y.asn1.DERInteger({bigint:this.d}),new y.asn1.DERInteger({bigint:this.p}),new y.asn1.DERInteger({bigint:this.q}),new y.asn1.DERInteger({bigint:this.dmp1}),new y.asn1.DERInteger({bigint:this.dmq1}),new y.asn1.DERInteger({bigint:this.coeff})]},e=new y.asn1.DERSequence(t);return e.getEncodedHex()},i.prototype.getPrivateBaseKeyB64=function(){return pe(this.getPrivateBaseKey())},i.prototype.getPublicBaseKey=function(){var t=new y.asn1.DERSequence({array:[new y.asn1.DERObjectIdentifier({oid:"1.2.840.113549.1.1.1"}),new y.asn1.DERNull]}),e=new y.asn1.DERSequence({array:[new y.asn1.DERInteger({bigint:this.n}),new y.asn1.DERInteger({int:this.e})]}),n=new y.asn1.DERBitString({hex:"00"+e.getEncodedHex()}),s=new y.asn1.DERSequence({array:[t,n]});return s.getEncodedHex()},i.prototype.getPublicBaseKeyB64=function(){return pe(this.getPublicBaseKey())},i.wordwrap=function(t,e){if(e=e||64,!t)return t;var n="(.{1,"+e+`})( +|$
|
|
23
|
+
*/var y={};(typeof y.asn1>"u"||!y.asn1)&&(y.asn1={}),y.asn1.ASN1Util=new function(){this.integerToByteHex=function(r){var i=r.toString(16);return i.length%2==1&&(i="0"+i),i},this.bigIntToMinTwosComplementsHex=function(r){var i=r.toString(16);if(i.substr(0,1)!="-")i.length%2==1?i="0"+i:i.match(/^[0-7]/)||(i="00"+i);else{var t=i.substr(1),e=t.length;e%2==1?e+=1:i.match(/^[0-7]/)||(e+=2);for(var n="",s=0;s<e;s++)n+="f";var a=new D(n,16),c=a.xor(r).add(D.ONE);i=c.toString(16).replace(/^-/,"")}return i},this.getPEMStringFromHex=function(r,i){return hextopem(r,i)},this.newObject=function(r){var i=y,t=i.asn1,e=t.DERBoolean,n=t.DERInteger,s=t.DERBitString,a=t.DEROctetString,c=t.DERNull,l=t.DERObjectIdentifier,h=t.DEREnumerated,f=t.DERUTF8String,_=t.DERNumericString,m=t.DERPrintableString,P=t.DERTeletexString,v=t.DERIA5String,S=t.DERUTCTime,C=t.DERGeneralizedTime,q=t.DERSequence,V=t.DERSet,H=t.DERTaggedObject,at=t.ASN1Util.newObject,Q=Object.keys(r);if(Q.length!=1)throw"key of param shall be only one.";var k=Q[0];if(":bool:int:bitstr:octstr:null:oid:enum:utf8str:numstr:prnstr:telstr:ia5str:utctime:gentime:seq:set:tag:".indexOf(":"+k+":")==-1)throw"undefined key: "+k;if(k=="bool")return new e(r[k]);if(k=="int")return new n(r[k]);if(k=="bitstr")return new s(r[k]);if(k=="octstr")return new a(r[k]);if(k=="null")return new c(r[k]);if(k=="oid")return new l(r[k]);if(k=="enum")return new h(r[k]);if(k=="utf8str")return new f(r[k]);if(k=="numstr")return new _(r[k]);if(k=="prnstr")return new m(r[k]);if(k=="telstr")return new P(r[k]);if(k=="ia5str")return new v(r[k]);if(k=="utctime")return new S(r[k]);if(k=="gentime")return new C(r[k]);if(k=="seq"){for(var ut=r[k],Et=[],Tt=0;Tt<ut.length;Tt++){var fn=at(ut[Tt]);Et.push(fn)}return new q({array:Et})}if(k=="set"){for(var ut=r[k],Et=[],Tt=0;Tt<ut.length;Tt++){var fn=at(ut[Tt]);Et.push(fn)}return new V({array:Et})}if(k=="tag"){var bt=r[k];if(Object.prototype.toString.call(bt)==="[object Array]"&&bt.length==3){var yc=at(bt[2]);return new H({tag:bt[0],explicit:bt[1],obj:yc})}else{var Oe={};if(bt.explicit!==void 0&&(Oe.explicit=bt.explicit),bt.tag!==void 0&&(Oe.tag=bt.tag),bt.obj===void 0)throw"obj shall be specified for 'tag'.";return Oe.obj=at(bt.obj),new H(Oe)}}},this.jsonToASN1HEX=function(r){var i=this.newObject(r);return i.getEncodedHex()}},y.asn1.ASN1Util.oidHexToInt=function(r){for(var n="",i=parseInt(r.substr(0,2),16),t=Math.floor(i/40),e=i%40,n=t+"."+e,s="",a=2;a<r.length;a+=2){var c=parseInt(r.substr(a,2),16),l=("00000000"+c.toString(2)).slice(-8);if(s=s+l.substr(1,7),l.substr(0,1)=="0"){var h=new D(s,2);n=n+"."+h.toString(10),s=""}}return n},y.asn1.ASN1Util.oidIntToHex=function(r){var i=function(c){var l=c.toString(16);return l.length==1&&(l="0"+l),l},t=function(c){var l="",h=new D(c,10),f=h.toString(2),_=7-f.length%7;_==7&&(_=0);for(var m="",P=0;P<_;P++)m+="0";f=m+f;for(var P=0;P<f.length-1;P+=7){var v=f.substr(P,7);P!=f.length-7&&(v="1"+v),l+=i(parseInt(v,2))}return l};if(!r.match(/^[0-9.]+$/))throw"malformed oid string: "+r;var e="",n=r.split("."),s=parseInt(n[0])*40+parseInt(n[1]);e+=i(s),n.splice(0,2);for(var a=0;a<n.length;a++)e+=t(n[a]);return e},y.asn1.ASN1Object=function(){var r="";this.getLengthHexFromValue=function(){if(typeof this.hV>"u"||this.hV==null)throw"this.hV is null or undefined.";if(this.hV.length%2==1)throw"value hex must be even length: n="+r.length+",v="+this.hV;var i=this.hV.length/2,t=i.toString(16);if(t.length%2==1&&(t="0"+t),i<128)return t;var e=t.length/2;if(e>15)throw"ASN.1 length too long to represent by 8x: n = "+i.toString(16);var n=128+e;return n.toString(16)+t},this.getEncodedHex=function(){return(this.hTLV==null||this.isModified)&&(this.hV=this.getFreshValueHex(),this.hL=this.getLengthHexFromValue(),this.hTLV=this.hT+this.hL+this.hV,this.isModified=!1),this.hTLV},this.getValueHex=function(){return this.getEncodedHex(),this.hV},this.getFreshValueHex=function(){return""}},y.asn1.DERAbstractString=function(r){y.asn1.DERAbstractString.superclass.constructor.call(this),this.getString=function(){return this.s},this.setString=function(i){this.hTLV=null,this.isModified=!0,this.s=i,this.hV=stohex(this.s)},this.setStringHex=function(i){this.hTLV=null,this.isModified=!0,this.s=null,this.hV=i},this.getFreshValueHex=function(){return this.hV},typeof r<"u"&&(typeof r=="string"?this.setString(r):typeof r.str<"u"?this.setString(r.str):typeof r.hex<"u"&&this.setStringHex(r.hex))},z.lang.extend(y.asn1.DERAbstractString,y.asn1.ASN1Object),y.asn1.DERAbstractTime=function(r){y.asn1.DERAbstractTime.superclass.constructor.call(this),this.localDateToUTC=function(i){utc=i.getTime()+i.getTimezoneOffset()*6e4;var t=new Date(utc);return t},this.formatDate=function(i,t,e){var n=this.zeroPadding,s=this.localDateToUTC(i),a=String(s.getFullYear());t=="utc"&&(a=a.substr(2,2));var c=n(String(s.getMonth()+1),2),l=n(String(s.getDate()),2),h=n(String(s.getHours()),2),f=n(String(s.getMinutes()),2),_=n(String(s.getSeconds()),2),m=a+c+l+h+f+_;if(e===!0){var P=s.getMilliseconds();if(P!=0){var v=n(String(P),3);v=v.replace(/[0]+$/,""),m=m+"."+v}}return m+"Z"},this.zeroPadding=function(i,t){return i.length>=t?i:new Array(t-i.length+1).join("0")+i},this.getString=function(){return this.s},this.setString=function(i){this.hTLV=null,this.isModified=!0,this.s=i,this.hV=stohex(i)},this.setByDateValue=function(i,t,e,n,s,a){var c=new Date(Date.UTC(i,t-1,e,n,s,a,0));this.setByDate(c)},this.getFreshValueHex=function(){return this.hV}},z.lang.extend(y.asn1.DERAbstractTime,y.asn1.ASN1Object),y.asn1.DERAbstractStructured=function(r){y.asn1.DERAbstractString.superclass.constructor.call(this),this.setByASN1ObjectArray=function(i){this.hTLV=null,this.isModified=!0,this.asn1Array=i},this.appendASN1Object=function(i){this.hTLV=null,this.isModified=!0,this.asn1Array.push(i)},this.asn1Array=new Array,typeof r<"u"&&typeof r.array<"u"&&(this.asn1Array=r.array)},z.lang.extend(y.asn1.DERAbstractStructured,y.asn1.ASN1Object),y.asn1.DERBoolean=function(){y.asn1.DERBoolean.superclass.constructor.call(this),this.hT="01",this.hTLV="0101ff"},z.lang.extend(y.asn1.DERBoolean,y.asn1.ASN1Object),y.asn1.DERInteger=function(r){y.asn1.DERInteger.superclass.constructor.call(this),this.hT="02",this.setByBigInteger=function(i){this.hTLV=null,this.isModified=!0,this.hV=y.asn1.ASN1Util.bigIntToMinTwosComplementsHex(i)},this.setByInteger=function(i){var t=new D(String(i),10);this.setByBigInteger(t)},this.setValueHex=function(i){this.hV=i},this.getFreshValueHex=function(){return this.hV},typeof r<"u"&&(typeof r.bigint<"u"?this.setByBigInteger(r.bigint):typeof r.int<"u"?this.setByInteger(r.int):typeof r=="number"?this.setByInteger(r):typeof r.hex<"u"&&this.setValueHex(r.hex))},z.lang.extend(y.asn1.DERInteger,y.asn1.ASN1Object),y.asn1.DERBitString=function(r){if(r!==void 0&&typeof r.obj<"u"){var i=y.asn1.ASN1Util.newObject(r.obj);r.hex="00"+i.getEncodedHex()}y.asn1.DERBitString.superclass.constructor.call(this),this.hT="03",this.setHexValueIncludingUnusedBits=function(t){this.hTLV=null,this.isModified=!0,this.hV=t},this.setUnusedBitsAndHexValue=function(t,e){if(t<0||7<t)throw"unused bits shall be from 0 to 7: u = "+t;var n="0"+t;this.hTLV=null,this.isModified=!0,this.hV=n+e},this.setByBinaryString=function(t){t=t.replace(/0+$/,"");var e=8-t.length%8;e==8&&(e=0);for(var n=0;n<=e;n++)t+="0";for(var s="",n=0;n<t.length-1;n+=8){var a=t.substr(n,8),c=parseInt(a,2).toString(16);c.length==1&&(c="0"+c),s+=c}this.hTLV=null,this.isModified=!0,this.hV="0"+e+s},this.setByBooleanArray=function(t){for(var e="",n=0;n<t.length;n++)t[n]==!0?e+="1":e+="0";this.setByBinaryString(e)},this.newFalseArray=function(t){for(var e=new Array(t),n=0;n<t;n++)e[n]=!1;return e},this.getFreshValueHex=function(){return this.hV},typeof r<"u"&&(typeof r=="string"&&r.toLowerCase().match(/^[0-9a-f]+$/)?this.setHexValueIncludingUnusedBits(r):typeof r.hex<"u"?this.setHexValueIncludingUnusedBits(r.hex):typeof r.bin<"u"?this.setByBinaryString(r.bin):typeof r.array<"u"&&this.setByBooleanArray(r.array))},z.lang.extend(y.asn1.DERBitString,y.asn1.ASN1Object),y.asn1.DEROctetString=function(r){if(r!==void 0&&typeof r.obj<"u"){var i=y.asn1.ASN1Util.newObject(r.obj);r.hex=i.getEncodedHex()}y.asn1.DEROctetString.superclass.constructor.call(this,r),this.hT="04"},z.lang.extend(y.asn1.DEROctetString,y.asn1.DERAbstractString),y.asn1.DERNull=function(){y.asn1.DERNull.superclass.constructor.call(this),this.hT="05",this.hTLV="0500"},z.lang.extend(y.asn1.DERNull,y.asn1.ASN1Object),y.asn1.DERObjectIdentifier=function(r){var i=function(e){var n=e.toString(16);return n.length==1&&(n="0"+n),n},t=function(e){var n="",s=new D(e,10),a=s.toString(2),c=7-a.length%7;c==7&&(c=0);for(var l="",h=0;h<c;h++)l+="0";a=l+a;for(var h=0;h<a.length-1;h+=7){var f=a.substr(h,7);h!=a.length-7&&(f="1"+f),n+=i(parseInt(f,2))}return n};y.asn1.DERObjectIdentifier.superclass.constructor.call(this),this.hT="06",this.setValueHex=function(e){this.hTLV=null,this.isModified=!0,this.s=null,this.hV=e},this.setValueOidString=function(e){if(!e.match(/^[0-9.]+$/))throw"malformed oid string: "+e;var n="",s=e.split("."),a=parseInt(s[0])*40+parseInt(s[1]);n+=i(a),s.splice(0,2);for(var c=0;c<s.length;c++)n+=t(s[c]);this.hTLV=null,this.isModified=!0,this.s=null,this.hV=n},this.setValueName=function(e){var n=y.asn1.x509.OID.name2oid(e);if(n!=="")this.setValueOidString(n);else throw"DERObjectIdentifier oidName undefined: "+e},this.getFreshValueHex=function(){return this.hV},r!==void 0&&(typeof r=="string"?r.match(/^[0-2].[0-9.]+$/)?this.setValueOidString(r):this.setValueName(r):r.oid!==void 0?this.setValueOidString(r.oid):r.hex!==void 0?this.setValueHex(r.hex):r.name!==void 0&&this.setValueName(r.name))},z.lang.extend(y.asn1.DERObjectIdentifier,y.asn1.ASN1Object),y.asn1.DEREnumerated=function(r){y.asn1.DEREnumerated.superclass.constructor.call(this),this.hT="0a",this.setByBigInteger=function(i){this.hTLV=null,this.isModified=!0,this.hV=y.asn1.ASN1Util.bigIntToMinTwosComplementsHex(i)},this.setByInteger=function(i){var t=new D(String(i),10);this.setByBigInteger(t)},this.setValueHex=function(i){this.hV=i},this.getFreshValueHex=function(){return this.hV},typeof r<"u"&&(typeof r.int<"u"?this.setByInteger(r.int):typeof r=="number"?this.setByInteger(r):typeof r.hex<"u"&&this.setValueHex(r.hex))},z.lang.extend(y.asn1.DEREnumerated,y.asn1.ASN1Object),y.asn1.DERUTF8String=function(r){y.asn1.DERUTF8String.superclass.constructor.call(this,r),this.hT="0c"},z.lang.extend(y.asn1.DERUTF8String,y.asn1.DERAbstractString),y.asn1.DERNumericString=function(r){y.asn1.DERNumericString.superclass.constructor.call(this,r),this.hT="12"},z.lang.extend(y.asn1.DERNumericString,y.asn1.DERAbstractString),y.asn1.DERPrintableString=function(r){y.asn1.DERPrintableString.superclass.constructor.call(this,r),this.hT="13"},z.lang.extend(y.asn1.DERPrintableString,y.asn1.DERAbstractString),y.asn1.DERTeletexString=function(r){y.asn1.DERTeletexString.superclass.constructor.call(this,r),this.hT="14"},z.lang.extend(y.asn1.DERTeletexString,y.asn1.DERAbstractString),y.asn1.DERIA5String=function(r){y.asn1.DERIA5String.superclass.constructor.call(this,r),this.hT="16"},z.lang.extend(y.asn1.DERIA5String,y.asn1.DERAbstractString),y.asn1.DERUTCTime=function(r){y.asn1.DERUTCTime.superclass.constructor.call(this,r),this.hT="17",this.setByDate=function(i){this.hTLV=null,this.isModified=!0,this.date=i,this.s=this.formatDate(this.date,"utc"),this.hV=stohex(this.s)},this.getFreshValueHex=function(){return typeof this.date>"u"&&typeof this.s>"u"&&(this.date=new Date,this.s=this.formatDate(this.date,"utc"),this.hV=stohex(this.s)),this.hV},r!==void 0&&(r.str!==void 0?this.setString(r.str):typeof r=="string"&&r.match(/^[0-9]{12}Z$/)?this.setString(r):r.hex!==void 0?this.setStringHex(r.hex):r.date!==void 0&&this.setByDate(r.date))},z.lang.extend(y.asn1.DERUTCTime,y.asn1.DERAbstractTime),y.asn1.DERGeneralizedTime=function(r){y.asn1.DERGeneralizedTime.superclass.constructor.call(this,r),this.hT="18",this.withMillis=!1,this.setByDate=function(i){this.hTLV=null,this.isModified=!0,this.date=i,this.s=this.formatDate(this.date,"gen",this.withMillis),this.hV=stohex(this.s)},this.getFreshValueHex=function(){return this.date===void 0&&this.s===void 0&&(this.date=new Date,this.s=this.formatDate(this.date,"gen",this.withMillis),this.hV=stohex(this.s)),this.hV},r!==void 0&&(r.str!==void 0?this.setString(r.str):typeof r=="string"&&r.match(/^[0-9]{14}Z$/)?this.setString(r):r.hex!==void 0?this.setStringHex(r.hex):r.date!==void 0&&this.setByDate(r.date),r.millis===!0&&(this.withMillis=!0))},z.lang.extend(y.asn1.DERGeneralizedTime,y.asn1.DERAbstractTime),y.asn1.DERSequence=function(r){y.asn1.DERSequence.superclass.constructor.call(this,r),this.hT="30",this.getFreshValueHex=function(){for(var i="",t=0;t<this.asn1Array.length;t++){var e=this.asn1Array[t];i+=e.getEncodedHex()}return this.hV=i,this.hV}},z.lang.extend(y.asn1.DERSequence,y.asn1.DERAbstractStructured),y.asn1.DERSet=function(r){y.asn1.DERSet.superclass.constructor.call(this,r),this.hT="31",this.sortFlag=!0,this.getFreshValueHex=function(){for(var i=new Array,t=0;t<this.asn1Array.length;t++){var e=this.asn1Array[t];i.push(e.getEncodedHex())}return this.sortFlag==!0&&i.sort(),this.hV=i.join(""),this.hV},typeof r<"u"&&typeof r.sortflag<"u"&&r.sortflag==!1&&(this.sortFlag=!1)},z.lang.extend(y.asn1.DERSet,y.asn1.DERAbstractStructured),y.asn1.DERTaggedObject=function(r){y.asn1.DERTaggedObject.superclass.constructor.call(this),this.hT="a0",this.hV="",this.isExplicit=!0,this.asn1Object=null,this.setASN1Object=function(i,t,e){this.hT=t,this.isExplicit=i,this.asn1Object=e,this.isExplicit?(this.hV=this.asn1Object.getEncodedHex(),this.hTLV=null,this.isModified=!0):(this.hV=null,this.hTLV=e.getEncodedHex(),this.hTLV=this.hTLV.replace(/^../,t),this.isModified=!1)},this.getFreshValueHex=function(){return this.hV},typeof r<"u"&&(typeof r.tag<"u"&&(this.hT=r.tag),typeof r.explicit<"u"&&(this.isExplicit=r.explicit),typeof r.obj<"u"&&(this.asn1Object=r.obj,this.setASN1Object(this.isExplicit,this.hT,this.asn1Object)))},z.lang.extend(y.asn1.DERTaggedObject,y.asn1.ASN1Object);var La=function(){var r=function(i,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(e[s]=n[s])},r(i,t)};return function(i,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");r(i,t);function e(){this.constructor=i}i.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}}(),ri=function(r){La(i,r);function i(t){var e=r.call(this)||this;return t&&(typeof t=="string"?e.parseKey(t):(i.hasPrivateKeyProperty(t)||i.hasPublicKeyProperty(t))&&e.parsePropertiesFrom(t)),e}return i.prototype.parseKey=function(t){try{var e=0,n=0,s=/^\s*(?:[0-9A-Fa-f][0-9A-Fa-f]\s*)+$/,a=s.test(t)?Pa.decode(t):Ge.unarmor(t),c=Ca.decode(a);if(c.sub.length===3&&(c=c.sub[2].sub[0]),c.sub.length===9){e=c.sub[1].getHexStringValue(),this.n=W(e,16),n=c.sub[2].getHexStringValue(),this.e=parseInt(n,16);var l=c.sub[3].getHexStringValue();this.d=W(l,16);var h=c.sub[4].getHexStringValue();this.p=W(h,16);var f=c.sub[5].getHexStringValue();this.q=W(f,16);var _=c.sub[6].getHexStringValue();this.dmp1=W(_,16);var m=c.sub[7].getHexStringValue();this.dmq1=W(m,16);var P=c.sub[8].getHexStringValue();this.coeff=W(P,16)}else if(c.sub.length===2)if(c.sub[0].sub){var v=c.sub[1],S=v.sub[0];e=S.sub[0].getHexStringValue(),this.n=W(e,16),n=S.sub[1].getHexStringValue(),this.e=parseInt(n,16)}else e=c.sub[0].getHexStringValue(),this.n=W(e,16),n=c.sub[1].getHexStringValue(),this.e=parseInt(n,16);else return!1;return!0}catch{return!1}},i.prototype.getPrivateBaseKey=function(){var t={array:[new y.asn1.DERInteger({int:0}),new y.asn1.DERInteger({bigint:this.n}),new y.asn1.DERInteger({int:this.e}),new y.asn1.DERInteger({bigint:this.d}),new y.asn1.DERInteger({bigint:this.p}),new y.asn1.DERInteger({bigint:this.q}),new y.asn1.DERInteger({bigint:this.dmp1}),new y.asn1.DERInteger({bigint:this.dmq1}),new y.asn1.DERInteger({bigint:this.coeff})]},e=new y.asn1.DERSequence(t);return e.getEncodedHex()},i.prototype.getPrivateBaseKeyB64=function(){return pe(this.getPrivateBaseKey())},i.prototype.getPublicBaseKey=function(){var t=new y.asn1.DERSequence({array:[new y.asn1.DERObjectIdentifier({oid:"1.2.840.113549.1.1.1"}),new y.asn1.DERNull]}),e=new y.asn1.DERSequence({array:[new y.asn1.DERInteger({bigint:this.n}),new y.asn1.DERInteger({int:this.e})]}),n=new y.asn1.DERBitString({hex:"00"+e.getEncodedHex()}),s=new y.asn1.DERSequence({array:[t,n]});return s.getEncodedHex()},i.prototype.getPublicBaseKeyB64=function(){return pe(this.getPublicBaseKey())},i.wordwrap=function(t,e){if(e=e||64,!t)return t;var n="(.{1,"+e+`})( +|$
|
|
24
24
|
?)|(.{1,`+e+"})";return t.match(RegExp(n,"g")).join(`
|
|
25
25
|
`)},i.prototype.getPrivateKey=function(){var t=`-----BEGIN RSA PRIVATE KEY-----
|
|
26
26
|
`;return t+=i.wordwrap(this.getPrivateBaseKeyB64())+`
|
|
27
27
|
`,t+="-----END RSA PRIVATE KEY-----",t},i.prototype.getPublicKey=function(){var t=`-----BEGIN PUBLIC KEY-----
|
|
28
28
|
`;return t+=i.wordwrap(this.getPublicBaseKeyB64())+`
|
|
29
|
-
`,t+="-----END PUBLIC KEY-----",t},i.hasPublicKeyProperty=function(t){return t=t||{},t.hasOwnProperty("n")&&t.hasOwnProperty("e")},i.hasPrivateKeyProperty=function(t){return t=t||{},t.hasOwnProperty("n")&&t.hasOwnProperty("e")&&t.hasOwnProperty("d")&&t.hasOwnProperty("p")&&t.hasOwnProperty("q")&&t.hasOwnProperty("dmp1")&&t.hasOwnProperty("dmq1")&&t.hasOwnProperty("coeff")},i.prototype.parsePropertiesFrom=function(t){this.n=t.n,this.e=t.e,t.hasOwnProperty("d")&&(this.d=t.d,this.p=t.p,this.q=t.q,this.dmp1=t.dmp1,this.dmq1=t.dmq1,this.coeff=t.coeff)},i}(Na),Ye,Va=typeof process<"u"?(Ye=process.env)===null||Ye===void 0?void 0:Ye.npm_package_version:void 0,qa=function(){function r(i){i===void 0&&(i={}),i=i||{},this.default_key_size=i.default_key_size?parseInt(i.default_key_size,10):1024,this.default_public_exponent=i.default_public_exponent||"010001",this.log=i.log||!1,this.key=null}return r.prototype.setKey=function(i){this.log&&this.key&&console.warn("A key was already set, overriding existing."),this.key=new si(i)},r.prototype.setPrivateKey=function(i){this.setKey(i)},r.prototype.setPublicKey=function(i){this.setKey(i)},r.prototype.decrypt=function(i){try{return this.getKey().decrypt($n(i))}catch{return!1}},r.prototype.encrypt=function(i){try{return pe(this.getKey().encrypt(i))}catch{return!1}},r.prototype.sign=function(i,t,e){try{return pe(this.getKey().sign(i,t,e))}catch{return!1}},r.prototype.verify=function(i,t,e){try{return this.getKey().verify(i,$n(t),e)}catch{return!1}},r.prototype.getKey=function(i){if(!this.key){if(this.key=new si,i&&{}.toString.call(i)==="[object Function]"){this.key.generateAsync(this.default_key_size,this.default_public_exponent,i);return}this.key.generate(this.default_key_size,this.default_public_exponent)}return this.key},r.prototype.getPrivateKey=function(){return this.getKey().getPrivateKey()},r.prototype.getPrivateKeyB64=function(){return this.getKey().getPrivateBaseKeyB64()},r.prototype.getPublicKey=function(){return this.getKey().getPublicKey()},r.prototype.getPublicKeyB64=function(){return this.getKey().getPublicBaseKeyB64()},r.version=Va,r}();function ai(r,i){return function(){return r.apply(i,arguments)}}const{toString:ja}=Object.prototype,{getPrototypeOf:tn}=Object,ve=(r=>i=>{const t=ja.call(i);return r[t]||(r[t]=t.slice(8,-1).toLowerCase())})(Object.create(null)),gt=r=>(r=r.toLowerCase(),i=>ve(i)===r),Pe=r=>i=>typeof i===r,{isArray:zt}=Array,te=Pe("undefined");function Ha(r){return r!==null&&!te(r)&&r.constructor!==null&&!te(r.constructor)&<(r.constructor.isBuffer)&&r.constructor.isBuffer(r)}const oi=gt("ArrayBuffer");function Ka(r){let i;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?i=ArrayBuffer.isView(r):i=r&&r.buffer&&oi(r.buffer),i}const Wa=Pe("string"),lt=Pe("function"),ci=Pe("number"),Ee=r=>r!==null&&typeof r=="object",za=r=>r===!0||r===!1,Te=r=>{if(ve(r)!=="object")return!1;const i=tn(r);return(i===null||i===Object.prototype||Object.getPrototypeOf(i)===null)&&!(Symbol.toStringTag in r)&&!(Symbol.iterator in r)},Xa=gt("Date"),Ga=gt("File"),Ja=gt("Blob"),$a=gt("FileList"),Qa=r=>Ee(r)&<(r.pipe),Za=r=>{let i;return r&&(typeof FormData=="function"&&r instanceof FormData||lt(r.append)&&((i=ve(r))==="formdata"||i==="object"&<(r.toString)&&r.toString()==="[object FormData]"))},Ya=gt("URLSearchParams"),[to,eo,no,io]=["ReadableStream","Request","Response","Headers"].map(gt),ro=r=>r.trim?r.trim():r.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function ee(r,i,{allOwnKeys:t=!1}={}){if(r===null||typeof r>"u")return;let e,n;if(typeof r!="object"&&(r=[r]),zt(r))for(e=0,n=r.length;e<n;e++)i.call(null,r[e],e,r);else{const s=t?Object.getOwnPropertyNames(r):Object.keys(r),a=s.length;let c;for(e=0;e<a;e++)c=s[e],i.call(null,r[c],c,r)}}function li(r,i){i=i.toLowerCase();const t=Object.keys(r);let e=t.length,n;for(;e-- >0;)if(n=t[e],i===n.toLowerCase())return n;return null}const It=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,hi=r=>!te(r)&&r!==It;function en(){const{caseless:r}=hi(this)&&this||{},i={},t=(e,n)=>{const s=r&&li(i,n)||n;Te(i[s])&&Te(e)?i[s]=en(i[s],e):Te(e)?i[s]=en({},e):zt(e)?i[s]=e.slice():i[s]=e};for(let e=0,n=arguments.length;e<n;e++)arguments[e]&&ee(arguments[e],t);return i}const so=(r,i,t,{allOwnKeys:e}={})=>(ee(i,(n,s)=>{t&<(n)?r[s]=ai(n,t):r[s]=n},{allOwnKeys:e}),r),ao=r=>(r.charCodeAt(0)===65279&&(r=r.slice(1)),r),oo=(r,i,t,e)=>{r.prototype=Object.create(i.prototype,e),r.prototype.constructor=r,Object.defineProperty(r,"super",{value:i.prototype}),t&&Object.assign(r.prototype,t)},co=(r,i,t,e)=>{let n,s,a;const c={};if(i=i||{},r==null)return i;do{for(n=Object.getOwnPropertyNames(r),s=n.length;s-- >0;)a=n[s],(!e||e(a,r,i))&&!c[a]&&(i[a]=r[a],c[a]=!0);r=t!==!1&&tn(r)}while(r&&(!t||t(r,i))&&r!==Object.prototype);return i},lo=(r,i,t)=>{r=String(r),(t===void 0||t>r.length)&&(t=r.length),t-=i.length;const e=r.indexOf(i,t);return e!==-1&&e===t},ho=r=>{if(!r)return null;if(zt(r))return r;let i=r.length;if(!ci(i))return null;const t=new Array(i);for(;i-- >0;)t[i]=r[i];return t},uo=(r=>i=>r&&i instanceof r)(typeof Uint8Array<"u"&&tn(Uint8Array)),po=(r,i)=>{const e=(r&&r[Symbol.iterator]).call(r);let n;for(;(n=e.next())&&!n.done;){const s=n.value;i.call(r,s[0],s[1])}},fo=(r,i)=>{let t;const e=[];for(;(t=r.exec(i))!==null;)e.push(t);return e},_o=gt("HTMLFormElement"),go=r=>r.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(t,e,n){return e.toUpperCase()+n}),ui=(({hasOwnProperty:r})=>(i,t)=>r.call(i,t))(Object.prototype),bo=gt("RegExp"),di=(r,i)=>{const t=Object.getOwnPropertyDescriptors(r),e={};ee(t,(n,s)=>{let a;(a=i(n,s,r))!==!1&&(e[s]=a||n)}),Object.defineProperties(r,e)},mo=r=>{di(r,(i,t)=>{if(lt(r)&&["arguments","caller","callee"].indexOf(t)!==-1)return!1;const e=r[t];if(lt(e)){if(i.enumerable=!1,"writable"in i){i.writable=!1;return}i.set||(i.set=()=>{throw Error("Can not rewrite read-only method '"+t+"'")})}})},yo=(r,i)=>{const t={},e=n=>{n.forEach(s=>{t[s]=!0})};return zt(r)?e(r):e(String(r).split(i)),t},wo=()=>{},vo=(r,i)=>r!=null&&Number.isFinite(r=+r)?r:i,nn="abcdefghijklmnopqrstuvwxyz",pi="0123456789",fi={DIGIT:pi,ALPHA:nn,ALPHA_DIGIT:nn+nn.toUpperCase()+pi},Po=(r=16,i=fi.ALPHA_DIGIT)=>{let t="";const{length:e}=i;for(;r--;)t+=i[Math.random()*e|0];return t};function Eo(r){return!!(r&<(r.append)&&r[Symbol.toStringTag]==="FormData"&&r[Symbol.iterator])}const To=r=>{const i=new Array(10),t=(e,n)=>{if(Ee(e)){if(i.indexOf(e)>=0)return;if(!("toJSON"in e)){i[n]=e;const s=zt(e)?[]:{};return ee(e,(a,c)=>{const l=t(a,n+1);!te(l)&&(s[c]=l)}),i[n]=void 0,s}}return e};return t(r,0)},Co=gt("AsyncFunction"),So=r=>r&&(Ee(r)||lt(r))&<(r.then)&<(r.catch),_i=((r,i)=>r?setImmediate:i?((t,e)=>(It.addEventListener("message",({source:n,data:s})=>{n===It&&s===t&&e.length&&e.shift()()},!1),n=>{e.push(n),It.postMessage(t,"*")}))(`axios@${Math.random()}`,[]):t=>setTimeout(t))(typeof setImmediate=="function",lt(It.postMessage)),ko=typeof queueMicrotask<"u"?queueMicrotask.bind(It):typeof process<"u"&&process.nextTick||_i,b={isArray:zt,isArrayBuffer:oi,isBuffer:Ha,isFormData:Za,isArrayBufferView:Ka,isString:Wa,isNumber:ci,isBoolean:za,isObject:Ee,isPlainObject:Te,isReadableStream:to,isRequest:eo,isResponse:no,isHeaders:io,isUndefined:te,isDate:Xa,isFile:Ga,isBlob:Ja,isRegExp:bo,isFunction:lt,isStream:Qa,isURLSearchParams:Ya,isTypedArray:uo,isFileList:$a,forEach:ee,merge:en,extend:so,trim:ro,stripBOM:ao,inherits:oo,toFlatObject:co,kindOf:ve,kindOfTest:gt,endsWith:lo,toArray:ho,forEachEntry:po,matchAll:fo,isHTMLForm:_o,hasOwnProperty:ui,hasOwnProp:ui,reduceDescriptors:di,freezeMethods:mo,toObjectSet:yo,toCamelCase:go,noop:wo,toFiniteNumber:vo,findKey:li,global:It,isContextDefined:hi,ALPHABET:fi,generateString:Po,isSpecCompliantForm:Eo,toJSONObject:To,isAsyncFn:Co,isThenable:So,setImmediate:_i,asap:ko};function A(r,i,t,e,n){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=r,this.name="AxiosError",i&&(this.code=i),t&&(this.config=t),e&&(this.request=e),n&&(this.response=n,this.status=n.status?n.status:null)}b.inherits(A,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:b.toJSONObject(this.config),code:this.code,status:this.status}}});const gi=A.prototype,bi={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(r=>{bi[r]={value:r}}),Object.defineProperties(A,bi),Object.defineProperty(gi,"isAxiosError",{value:!0}),A.from=(r,i,t,e,n,s)=>{const a=Object.create(gi);return b.toFlatObject(r,a,function(l){return l!==Error.prototype},c=>c!=="isAxiosError"),A.call(a,r.message,i,t,e,n),a.cause=r,a.name=r.name,s&&Object.assign(a,s),a};const xo=null;function rn(r){return b.isPlainObject(r)||b.isArray(r)}function mi(r){return b.endsWith(r,"[]")?r.slice(0,-2):r}function yi(r,i,t){return r?r.concat(i).map(function(n,s){return n=mi(n),!t&&s?"["+n+"]":n}).join(t?".":""):i}function Ao(r){return b.isArray(r)&&!r.some(rn)}const Do=b.toFlatObject(b,{},null,function(i){return/^is[A-Z]/.test(i)});function Ce(r,i,t){if(!b.isObject(r))throw new TypeError("target must be an object");i=i||new FormData,t=b.toFlatObject(t,{metaTokens:!0,dots:!1,indexes:!1},!1,function(S,C){return!b.isUndefined(C[S])});const e=t.metaTokens,n=t.visitor||f,s=t.dots,a=t.indexes,l=(t.Blob||typeof Blob<"u"&&Blob)&&b.isSpecCompliantForm(i);if(!b.isFunction(n))throw new TypeError("visitor must be a function");function h(v){if(v===null)return"";if(b.isDate(v))return v.toISOString();if(!l&&b.isBlob(v))throw new A("Blob is not supported. Use a Buffer instead.");return b.isArrayBuffer(v)||b.isTypedArray(v)?l&&typeof Blob=="function"?new Blob([v]):Buffer.from(v):v}function f(v,S,C){let q=v;if(v&&!C&&typeof v=="object"){if(b.endsWith(S,"{}"))S=e?S:S.slice(0,-2),v=JSON.stringify(v);else if(b.isArray(v)&&Ao(v)||(b.isFileList(v)||b.endsWith(S,"[]"))&&(q=b.toArray(v)))return S=mi(S),q.forEach(function(H,at){!(b.isUndefined(H)||H===null)&&i.append(a===!0?yi([S],at,s):a===null?S:S+"[]",h(H))}),!1}return rn(v)?!0:(i.append(yi(C,S,s),h(v)),!1)}const _=[],m=Object.assign(Do,{defaultVisitor:f,convertValue:h,isVisitable:rn});function P(v,S){if(!b.isUndefined(v)){if(_.indexOf(v)!==-1)throw Error("Circular reference detected in "+S.join("."));_.push(v),b.forEach(v,function(q,V){(!(b.isUndefined(q)||q===null)&&n.call(i,q,b.isString(V)?V.trim():V,S,m))===!0&&P(q,S?S.concat(V):[V])}),_.pop()}}if(!b.isObject(r))throw new TypeError("data must be an object");return P(r),i}function wi(r){const i={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(r).replace(/[!'()~]|%20|%00/g,function(e){return i[e]})}function sn(r,i){this._pairs=[],r&&Ce(r,this,i)}const vi=sn.prototype;vi.append=function(i,t){this._pairs.push([i,t])},vi.toString=function(i){const t=i?function(e){return i.call(this,e,wi)}:wi;return this._pairs.map(function(n){return t(n[0])+"="+t(n[1])},"").join("&")};function Ro(r){return encodeURIComponent(r).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function Pi(r,i,t){if(!i)return r;const e=t&&t.encode||Ro;b.isFunction(t)&&(t={serialize:t});const n=t&&t.serialize;let s;if(n?s=n(i,t):s=b.isURLSearchParams(i)?i.toString():new sn(i,t).toString(e),s){const a=r.indexOf("#");a!==-1&&(r=r.slice(0,a)),r+=(r.indexOf("?")===-1?"?":"&")+s}return r}class Ei{constructor(){this.handlers=[]}use(i,t,e){return this.handlers.push({fulfilled:i,rejected:t,synchronous:e?e.synchronous:!1,runWhen:e?e.runWhen:null}),this.handlers.length-1}eject(i){this.handlers[i]&&(this.handlers[i]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(i){b.forEach(this.handlers,function(e){e!==null&&i(e)})}}const Ti={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},Io={isBrowser:!0,classes:{URLSearchParams:typeof URLSearchParams<"u"?URLSearchParams:sn,FormData:typeof FormData<"u"?FormData:null,Blob:typeof Blob<"u"?Blob:null},protocols:["http","https","file","blob","url","data"]},an=typeof window<"u"&&typeof document<"u",on=typeof navigator=="object"&&navigator||void 0,Oo=an&&(!on||["ReactNative","NativeScript","NS"].indexOf(on.product)<0),Bo=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",No=an&&window.location.href||"http://localhost",et={...Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:an,hasStandardBrowserEnv:Oo,hasStandardBrowserWebWorkerEnv:Bo,navigator:on,origin:No},Symbol.toStringTag,{value:"Module"})),...Io};function Mo(r,i){return Ce(r,new et.classes.URLSearchParams,Object.assign({visitor:function(t,e,n,s){return et.isNode&&b.isBuffer(t)?(this.append(e,t.toString("base64")),!1):s.defaultVisitor.apply(this,arguments)}},i))}function Fo(r){return b.matchAll(/\w+|\[(\w*)]/g,r).map(i=>i[0]==="[]"?"":i[1]||i[0])}function Uo(r){const i={},t=Object.keys(r);let e;const n=t.length;let s;for(e=0;e<n;e++)s=t[e],i[s]=r[s];return i}function Ci(r){function i(t,e,n,s){let a=t[s++];if(a==="__proto__")return!0;const c=Number.isFinite(+a),l=s>=t.length;return a=!a&&b.isArray(n)?n.length:a,l?(b.hasOwnProp(n,a)?n[a]=[n[a],e]:n[a]=e,!c):((!n[a]||!b.isObject(n[a]))&&(n[a]=[]),i(t,e,n[a],s)&&b.isArray(n[a])&&(n[a]=Uo(n[a])),!c)}if(b.isFormData(r)&&b.isFunction(r.entries)){const t={};return b.forEachEntry(r,(e,n)=>{i(Fo(e),n,t,0)}),t}return null}function Lo(r,i,t){if(b.isString(r))try{return(i||JSON.parse)(r),b.trim(r)}catch(e){if(e.name!=="SyntaxError")throw e}return(0,JSON.stringify)(r)}const ne={transitional:Ti,adapter:["xhr","http","fetch"],transformRequest:[function(i,t){const e=t.getContentType()||"",n=e.indexOf("application/json")>-1,s=b.isObject(i);if(s&&b.isHTMLForm(i)&&(i=new FormData(i)),b.isFormData(i))return n?JSON.stringify(Ci(i)):i;if(b.isArrayBuffer(i)||b.isBuffer(i)||b.isStream(i)||b.isFile(i)||b.isBlob(i)||b.isReadableStream(i))return i;if(b.isArrayBufferView(i))return i.buffer;if(b.isURLSearchParams(i))return t.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),i.toString();let c;if(s){if(e.indexOf("application/x-www-form-urlencoded")>-1)return Mo(i,this.formSerializer).toString();if((c=b.isFileList(i))||e.indexOf("multipart/form-data")>-1){const l=this.env&&this.env.FormData;return Ce(c?{"files[]":i}:i,l&&new l,this.formSerializer)}}return s||n?(t.setContentType("application/json",!1),Lo(i)):i}],transformResponse:[function(i){const t=this.transitional||ne.transitional,e=t&&t.forcedJSONParsing,n=this.responseType==="json";if(b.isResponse(i)||b.isReadableStream(i))return i;if(i&&b.isString(i)&&(e&&!this.responseType||n)){const a=!(t&&t.silentJSONParsing)&&n;try{return JSON.parse(i)}catch(c){if(a)throw c.name==="SyntaxError"?A.from(c,A.ERR_BAD_RESPONSE,this,null,this.response):c}}return i}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:et.classes.FormData,Blob:et.classes.Blob},validateStatus:function(i){return i>=200&&i<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};b.forEach(["delete","get","head","post","put","patch"],r=>{ne.headers[r]={}});const Vo=b.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),qo=r=>{const i={};let t,e,n;return r&&r.split(`
|
|
30
|
-
`).forEach(function(a){n=a.indexOf(":"),t=a.substring(0,n).trim().toLowerCase(),e=a.substring(n+1).trim(),!(!t||i[t]&&Vo[t])&&(t==="set-cookie"?i[t]?i[t].push(e):i[t]=[e]:i[t]=i[t]?i[t]+", "+e:e)}),i},
|
|
31
|
-
`)}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(i){return i instanceof this?i:new this(i)}static concat(i,...t){const e=new this(i);return t.forEach(n=>e.set(n)),e}static accessor(i){const e=(this[Si]=this[Si]={accessors:{}}).accessors,n=this.prototype;function s(a){const c=ie(a);e[c]||(Wo(n,a),e[c]=!0)}return b.isArray(i)?i.forEach(s):s(i),this}}rt.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),b.reduceDescriptors(rt.prototype,({value:r},i)=>{let t=i[0].toUpperCase()+i.slice(1);return{get:()=>r,set(e){this[t]=e}}}),b.freezeMethods(rt);function ln(r,i){const t=this||ne,e=i||t,n=rt.from(e.headers);let s=e.data;return b.forEach(r,function(c){s=c.call(t,s,n.normalize(),i?i.status:void 0)}),n.normalize(),s}function ki(r){return!!(r&&r.__CANCEL__)}function Xt(r,i,t){A.call(this,r??"canceled",A.ERR_CANCELED,i,t),this.name="CanceledError"}b.inherits(Xt,A,{__CANCEL__:!0});function xi(r,i,t){const e=t.config.validateStatus;!t.status||!e||e(t.status)?r(t):i(new A("Request failed with status code "+t.status,[A.ERR_BAD_REQUEST,A.ERR_BAD_RESPONSE][Math.floor(t.status/100)-4],t.config,t.request,t))}function zo(r){const i=/^([-+\w]{1,25})(:?\/\/|:)/.exec(r);return i&&i[1]||""}function Xo(r,i){r=r||10;const t=new Array(r),e=new Array(r);let n=0,s=0,a;return i=i!==void 0?i:1e3,function(l){const h=Date.now(),f=e[s];a||(a=h),t[n]=l,e[n]=h;let _=s,m=0;for(;_!==n;)m+=t[_++],_=_%r;if(n=(n+1)%r,n===s&&(s=(s+1)%r),h-a<i)return;const P=f&&h-f;return P?Math.round(m*1e3/P):void 0}}function Go(r,i){let t=0,e=1e3/i,n,s;const a=(h,f=Date.now())=>{t=f,n=null,s&&(clearTimeout(s),s=null),r.apply(null,h)};return[(...h)=>{const f=Date.now(),_=f-t;_>=e?a(h,f):(n=h,s||(s=setTimeout(()=>{s=null,a(n)},e-_)))},()=>n&&a(n)]}const ke=(r,i,t=3)=>{let e=0;const n=Xo(50,250);return Go(s=>{const a=s.loaded,c=s.lengthComputable?s.total:void 0,l=a-e,h=n(l),f=a<=c;e=a;const _={loaded:a,total:c,progress:c?a/c:void 0,bytes:l,rate:h||void 0,estimated:h&&c&&f?(c-a)/h:void 0,event:s,lengthComputable:c!=null,[i?"download":"upload"]:!0};r(_)},t)},Ai=(r,i)=>{const t=r!=null;return[e=>i[0]({lengthComputable:t,total:r,loaded:e}),i[1]]},Di=r=>(...i)=>b.asap(()=>r(...i)),Jo=et.hasStandardBrowserEnv?((r,i)=>t=>(t=new URL(t,et.origin),r.protocol===t.protocol&&r.host===t.host&&(i||r.port===t.port)))(new URL(et.origin),et.navigator&&/(msie|trident)/i.test(et.navigator.userAgent)):()=>!0,$o=et.hasStandardBrowserEnv?{write(r,i,t,e,n,s){const a=[r+"="+encodeURIComponent(i)];b.isNumber(t)&&a.push("expires="+new Date(t).toGMTString()),b.isString(e)&&a.push("path="+e),b.isString(n)&&a.push("domain="+n),s===!0&&a.push("secure"),document.cookie=a.join("; ")},read(r){const i=document.cookie.match(new RegExp("(^|;\\s*)("+r+")=([^;]*)"));return i?decodeURIComponent(i[3]):null},remove(r){this.write(r,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};function Qo(r){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(r)}function Zo(r,i){return i?r.replace(/\/?\/$/,"")+"/"+i.replace(/^\/+/,""):r}function Ri(r,i){return r&&!Qo(i)?Zo(r,i):i}const Ii=r=>r instanceof rt?{...r}:r;function Ot(r,i){i=i||{};const t={};function e(h,f,_,m){return b.isPlainObject(h)&&b.isPlainObject(f)?b.merge.call({caseless:m},h,f):b.isPlainObject(f)?b.merge({},f):b.isArray(f)?f.slice():f}function n(h,f,_,m){if(b.isUndefined(f)){if(!b.isUndefined(h))return e(void 0,h,_,m)}else return e(h,f,_,m)}function s(h,f){if(!b.isUndefined(f))return e(void 0,f)}function a(h,f){if(b.isUndefined(f)){if(!b.isUndefined(h))return e(void 0,h)}else return e(void 0,f)}function c(h,f,_){if(_ in i)return e(h,f);if(_ in r)return e(void 0,h)}const l={url:s,method:s,data:s,baseURL:a,transformRequest:a,transformResponse:a,paramsSerializer:a,timeout:a,timeoutMessage:a,withCredentials:a,withXSRFToken:a,adapter:a,responseType:a,xsrfCookieName:a,xsrfHeaderName:a,onUploadProgress:a,onDownloadProgress:a,decompress:a,maxContentLength:a,maxBodyLength:a,beforeRedirect:a,transport:a,httpAgent:a,httpsAgent:a,cancelToken:a,socketPath:a,responseEncoding:a,validateStatus:c,headers:(h,f,_)=>n(Ii(h),Ii(f),_,!0)};return b.forEach(Object.keys(Object.assign({},r,i)),function(f){const _=l[f]||n,m=_(r[f],i[f],f);b.isUndefined(m)&&_!==c||(t[f]=m)}),t}const Oi=r=>{const i=Ot({},r);let{data:t,withXSRFToken:e,xsrfHeaderName:n,xsrfCookieName:s,headers:a,auth:c}=i;i.headers=a=rt.from(a),i.url=Pi(Ri(i.baseURL,i.url),r.params,r.paramsSerializer),c&&a.set("Authorization","Basic "+btoa((c.username||"")+":"+(c.password?unescape(encodeURIComponent(c.password)):"")));let l;if(b.isFormData(t)){if(et.hasStandardBrowserEnv||et.hasStandardBrowserWebWorkerEnv)a.setContentType(void 0);else if((l=a.getContentType())!==!1){const[h,...f]=l?l.split(";").map(_=>_.trim()).filter(Boolean):[];a.setContentType([h||"multipart/form-data",...f].join("; "))}}if(et.hasStandardBrowserEnv&&(e&&b.isFunction(e)&&(e=e(i)),e||e!==!1&&Jo(i.url))){const h=n&&s&&$o.read(s);h&&a.set(n,h)}return i},Yo=typeof XMLHttpRequest<"u"&&function(r){return new Promise(function(t,e){const n=Oi(r);let s=n.data;const a=rt.from(n.headers).normalize();let{responseType:c,onUploadProgress:l,onDownloadProgress:h}=n,f,_,m,P,v;function S(){P&&P(),v&&v(),n.cancelToken&&n.cancelToken.unsubscribe(f),n.signal&&n.signal.removeEventListener("abort",f)}let C=new XMLHttpRequest;C.open(n.method.toUpperCase(),n.url,!0),C.timeout=n.timeout;function q(){if(!C)return;const H=rt.from("getAllResponseHeaders"in C&&C.getAllResponseHeaders()),Q={data:!c||c==="text"||c==="json"?C.responseText:C.response,status:C.status,statusText:C.statusText,headers:H,config:r,request:C};xi(function(ut){t(ut),S()},function(ut){e(ut),S()},Q),C=null}"onloadend"in C?C.onloadend=q:C.onreadystatechange=function(){!C||C.readyState!==4||C.status===0&&!(C.responseURL&&C.responseURL.indexOf("file:")===0)||setTimeout(q)},C.onabort=function(){C&&(e(new A("Request aborted",A.ECONNABORTED,r,C)),C=null)},C.onerror=function(){e(new A("Network Error",A.ERR_NETWORK,r,C)),C=null},C.ontimeout=function(){let at=n.timeout?"timeout of "+n.timeout+"ms exceeded":"timeout exceeded";const Q=n.transitional||Ti;n.timeoutErrorMessage&&(at=n.timeoutErrorMessage),e(new A(at,Q.clarifyTimeoutError?A.ETIMEDOUT:A.ECONNABORTED,r,C)),C=null},s===void 0&&a.setContentType(null),"setRequestHeader"in C&&b.forEach(a.toJSON(),function(at,Q){C.setRequestHeader(Q,at)}),b.isUndefined(n.withCredentials)||(C.withCredentials=!!n.withCredentials),c&&c!=="json"&&(C.responseType=n.responseType),h&&([m,v]=ke(h,!0),C.addEventListener("progress",m)),l&&C.upload&&([_,P]=ke(l),C.upload.addEventListener("progress",_),C.upload.addEventListener("loadend",P)),(n.cancelToken||n.signal)&&(f=H=>{C&&(e(!H||H.type?new Xt(null,r,C):H),C.abort(),C=null)},n.cancelToken&&n.cancelToken.subscribe(f),n.signal&&(n.signal.aborted?f():n.signal.addEventListener("abort",f)));const V=zo(n.url);if(V&&et.protocols.indexOf(V)===-1){e(new A("Unsupported protocol "+V+":",A.ERR_BAD_REQUEST,r));return}C.send(s||null)})},tc=(r,i)=>{const{length:t}=r=r?r.filter(Boolean):[];if(i||t){let e=new AbortController,n;const s=function(h){if(!n){n=!0,c();const f=h instanceof Error?h:this.reason;e.abort(f instanceof A?f:new Xt(f instanceof Error?f.message:f))}};let a=i&&setTimeout(()=>{a=null,s(new A(`timeout ${i} of ms exceeded`,A.ETIMEDOUT))},i);const c=()=>{r&&(a&&clearTimeout(a),a=null,r.forEach(h=>{h.unsubscribe?h.unsubscribe(s):h.removeEventListener("abort",s)}),r=null)};r.forEach(h=>h.addEventListener("abort",s));const{signal:l}=e;return l.unsubscribe=()=>b.asap(c),l}},ec=function*(r,i){let t=r.byteLength;if(t<i){yield r;return}let e=0,n;for(;e<t;)n=e+i,yield r.slice(e,n),e=n},nc=async function*(r,i){for await(const t of ic(r))yield*ec(t,i)},ic=async function*(r){if(r[Symbol.asyncIterator]){yield*r;return}const i=r.getReader();try{for(;;){const{done:t,value:e}=await i.read();if(t)break;yield e}}finally{await i.cancel()}},Bi=(r,i,t,e)=>{const n=nc(r,i);let s=0,a,c=l=>{a||(a=!0,e&&e(l))};return new ReadableStream({async pull(l){try{const{done:h,value:f}=await n.next();if(h){c(),l.close();return}let _=f.byteLength;if(t){let m=s+=_;t(m)}l.enqueue(new Uint8Array(f))}catch(h){throw c(h),h}},cancel(l){return c(l),n.return()}},{highWaterMark:2})},xe=typeof fetch=="function"&&typeof Request=="function"&&typeof Response=="function",Ni=xe&&typeof ReadableStream=="function",rc=xe&&(typeof TextEncoder=="function"?(r=>i=>r.encode(i))(new TextEncoder):async r=>new Uint8Array(await new Response(r).arrayBuffer())),Mi=(r,...i)=>{try{return!!r(...i)}catch{return!1}},sc=Ni&&Mi(()=>{let r=!1;const i=new Request(et.origin,{body:new ReadableStream,method:"POST",get duplex(){return r=!0,"half"}}).headers.has("Content-Type");return r&&!i}),Fi=64*1024,hn=Ni&&Mi(()=>b.isReadableStream(new Response("").body)),Ae={stream:hn&&(r=>r.body)};xe&&(r=>{["text","arrayBuffer","blob","formData","stream"].forEach(i=>{!Ae[i]&&(Ae[i]=b.isFunction(r[i])?t=>t[i]():(t,e)=>{throw new A(`Response type '${i}' is not supported`,A.ERR_NOT_SUPPORT,e)})})})(new Response);const ac=async r=>{if(r==null)return 0;if(b.isBlob(r))return r.size;if(b.isSpecCompliantForm(r))return(await new Request(et.origin,{method:"POST",body:r}).arrayBuffer()).byteLength;if(b.isArrayBufferView(r)||b.isArrayBuffer(r))return r.byteLength;if(b.isURLSearchParams(r)&&(r=r+""),b.isString(r))return(await rc(r)).byteLength},oc=async(r,i)=>{const t=b.toFiniteNumber(r.getContentLength());return t??ac(i)},un={http:xo,xhr:Yo,fetch:xe&&(async r=>{let{url:i,method:t,data:e,signal:n,cancelToken:s,timeout:a,onDownloadProgress:c,onUploadProgress:l,responseType:h,headers:f,withCredentials:_="same-origin",fetchOptions:m}=Oi(r);h=h?(h+"").toLowerCase():"text";let P=tc([n,s&&s.toAbortSignal()],a),v;const S=P&&P.unsubscribe&&(()=>{P.unsubscribe()});let C;try{if(l&&sc&&t!=="get"&&t!=="head"&&(C=await oc(f,e))!==0){let Q=new Request(i,{method:"POST",body:e,duplex:"half"}),k;if(b.isFormData(e)&&(k=Q.headers.get("content-type"))&&f.setContentType(k),Q.body){const[ut,Et]=Ai(C,ke(Di(l)));e=Bi(Q.body,Fi,ut,Et)}}b.isString(_)||(_=_?"include":"omit");const q="credentials"in Request.prototype;v=new Request(i,{...m,signal:P,method:t.toUpperCase(),headers:f.normalize().toJSON(),body:e,duplex:"half",credentials:q?_:void 0});let V=await fetch(v);const H=hn&&(h==="stream"||h==="response");if(hn&&(c||H&&S)){const Q={};["status","statusText","headers"].forEach(Tt=>{Q[Tt]=V[Tt]});const k=b.toFiniteNumber(V.headers.get("content-length")),[ut,Et]=c&&Ai(k,ke(Di(c),!0))||[];V=new Response(Bi(V.body,Fi,ut,()=>{Et&&Et(),S&&S()}),Q)}h=h||"text";let at=await Ae[b.findKey(Ae,h)||"text"](V,r);return!H&&S&&S(),await new Promise((Q,k)=>{xi(Q,k,{data:at,headers:rt.from(V.headers),status:V.status,statusText:V.statusText,config:r,request:v})})}catch(q){throw S&&S(),q&&q.name==="TypeError"&&/fetch/i.test(q.message)?Object.assign(new A("Network Error",A.ERR_NETWORK,r,v),{cause:q.cause||q}):A.from(q,q&&q.code,r,v)}})};b.forEach(un,(r,i)=>{if(r){try{Object.defineProperty(r,"name",{value:i})}catch{}Object.defineProperty(r,"adapterName",{value:i})}});const Ui=r=>`- ${r}`,cc=r=>b.isFunction(r)||r===null||r===!1,Li={getAdapter:r=>{r=b.isArray(r)?r:[r];const{length:i}=r;let t,e;const n={};for(let s=0;s<i;s++){t=r[s];let a;if(e=t,!cc(t)&&(e=un[(a=String(t)).toLowerCase()],e===void 0))throw new A(`Unknown adapter '${a}'`);if(e)break;n[a||"#"+s]=e}if(!e){const s=Object.entries(n).map(([c,l])=>`adapter ${c} `+(l===!1?"is not supported by the environment":"is not available in the build"));let a=i?s.length>1?`since :
|
|
32
|
-
`+s.map(
|
|
33
|
-
`):" "+
|
|
34
|
-
`+s):e.stack=s}catch{}}throw e}}_request(i,t){typeof i=="string"?(t=t||{},t.url=i):t=i||{},t=Ot(this.defaults,t);const{transitional:e,paramsSerializer:n,headers:s}=t;e!==void 0&&Re.assertOptions(e,{silentJSONParsing:vt.transitional(vt.boolean),forcedJSONParsing:vt.transitional(vt.boolean),clarifyTimeoutError:vt.transitional(vt.boolean)},!1),n!=null&&(b.isFunction(n)?t.paramsSerializer={serialize:n}:Re.assertOptions(n,{encode:vt.function,serialize:vt.function},!0)),Re.assertOptions(t,{baseUrl:vt.spelling("baseURL"),withXsrfToken:vt.spelling("withXSRFToken")},!0),t.method=(t.method||this.defaults.method||"get").toLowerCase();let a=s&&b.merge(s.common,s[t.method]);s&&b.forEach(["delete","get","head","post","put","patch","common"],v=>{delete s[v]}),t.headers=rt.concat(a,s);const c=[];let l=!0;this.interceptors.request.forEach(function(S){typeof S.runWhen=="function"&&S.runWhen(t)===!1||(l=l&&S.synchronous,c.unshift(S.fulfilled,S.rejected))});const h=[];this.interceptors.response.forEach(function(S){h.push(S.fulfilled,S.rejected)});let f,_=0,m;if(!l){const v=[Vi.bind(this),void 0];for(v.unshift.apply(v,c),v.push.apply(v,h),m=v.length,f=Promise.resolve(t);_<m;)f=f.then(v[_++],v[_++]);return f}m=c.length;let P=t;for(_=0;_<m;){const v=c[_++],S=c[_++];try{P=v(P)}catch(C){S.call(this,C);break}}try{f=Vi.call(this,P)}catch(v){return Promise.reject(v)}for(_=0,m=h.length;_<m;)f=f.then(h[_++],h[_++]);return f}getUri(i){i=Ot(this.defaults,i);const t=Ri(i.baseURL,i.url);return Pi(t,i.params,i.paramsSerializer)}}b.forEach(["delete","get","head","options"],function(i){Bt.prototype[i]=function(t,e){return this.request(Ot(e||{},{method:i,url:t,data:(e||{}).data}))}}),b.forEach(["post","put","patch"],function(i){function t(e){return function(s,a,c){return this.request(Ot(c||{},{method:i,headers:e?{"Content-Type":"multipart/form-data"}:{},url:s,data:a}))}}Bt.prototype[i]=t(),Bt.prototype[i+"Form"]=t(!0)});class pn{constructor(i){if(typeof i!="function")throw new TypeError("executor must be a function.");let t;this.promise=new Promise(function(s){t=s});const e=this;this.promise.then(n=>{if(!e._listeners)return;let s=e._listeners.length;for(;s-- >0;)e._listeners[s](n);e._listeners=null}),this.promise.then=n=>{let s;const a=new Promise(c=>{e.subscribe(c),s=c}).then(n);return a.cancel=function(){e.unsubscribe(s)},a},i(function(s,a,c){e.reason||(e.reason=new Xt(s,a,c),t(e.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(i){if(this.reason){i(this.reason);return}this._listeners?this._listeners.push(i):this._listeners=[i]}unsubscribe(i){if(!this._listeners)return;const t=this._listeners.indexOf(i);t!==-1&&this._listeners.splice(t,1)}toAbortSignal(){const i=new AbortController,t=e=>{i.abort(e)};return this.subscribe(t),i.signal.unsubscribe=()=>this.unsubscribe(t),i.signal}static source(){let i;return{token:new pn(function(n){i=n}),cancel:i}}}function hc(r){return function(t){return r.apply(null,t)}}function uc(r){return b.isObject(r)&&r.isAxiosError===!0}const fn={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(fn).forEach(([r,i])=>{fn[i]=r});function Hi(r){const i=new Bt(r),t=ai(Bt.prototype.request,i);return b.extend(t,Bt.prototype,i,{allOwnKeys:!0}),b.extend(t,i,null,{allOwnKeys:!0}),t.create=function(n){return Hi(Ot(r,n))},t}const j=Hi(ne);j.Axios=Bt,j.CanceledError=Xt,j.CancelToken=pn,j.isCancel=ki,j.VERSION=qi,j.toFormData=Ce,j.AxiosError=A,j.Cancel=j.CanceledError,j.all=function(i){return Promise.all(i)},j.spread=hc,j.isAxiosError=uc,j.mergeConfig=Ot,j.AxiosHeaders=rt,j.formToJSON=r=>Ci(b.isHTMLForm(r)?new FormData(r):r),j.getAdapter=Li.getAdapter,j.HttpStatusCode=fn,j.default=j;class dc extends kt{constructor({filters:t=null,config_port:e=null,no_device:n=1,username:s=null,password:a=null,environment:c="production"}={}){super({filters:t,config_port:e,no_device:n});$(this,p);Z(this,"__pinPad__",{buffer:null,about:{EMV:null,model:null,serial:null,brand:null,appVersion:null,printer:null,hasCashback:!1,supportInjection:!1,supportSign:!1,supportContactlessCollisionCard:!1,supportContactless:!1,supportDUKPT:"",injectedValues:!1,pp:null},config:{defaultEnvironment:"production",environment:"production",currency:"MXN",currencyCode:"0484",timeoutPinPad:"100",signSupport:"1",CTLSSupport:"1",userTRX:"userPinpadWeb",tp_operation:"29",requireCVVAmex:"1",forceOnline:"00",emvCard:"0",validateQPS:"1",username:null,password:null,country:null,idBranch:null,idCompany:null,latitude:null,longitude:null,publicKeyRSA:null,publicIP:null,internal:{stTokenization:!1,qpsDomestic:"",qpsInternational:"",cvmlVMCDomestic:"",cvmlVMCInternational:"",cvmlAmex:"",translimitCTLSVMC:"",translimitCTLSAmex:"",emv:{}},terminal:{},loginResponse:null,otherLogin:{},RC4Key:"KEY CREDIT CARD KEY",read:{EMV:"",PIN:"",POSEM:"",AppId:"",AppIdLabel:"",Arqc:"",Chip:"",ChipName:"",ChipNameEnc:"",ReadCTLS:"",NB_Data:"",NB_ksn:"",Tags:"",Type:""},tokenizeTRX:!1},constants:{appVersion:"1.0.16",appName:"pinpapWebApp ",STX:"",ETX:"",FS:"",getNULL:"\0",appChannel:"3",typeChannel:"11",urls:{development:"https://fcdev.mitec.com.mx",qa:"https://fcqa.mitec.com.mx",production:"https://m.mit.com.mx",productionAlternative:"https://m2.mit.com.mx"},uris:{login:"/pinpadWeb/login",RSAKey:"/pinpadWeb/getDataCrypt",merchant:"/pinpadWeb/getAfiliaciones",consult:"/pinpadWeb/queryTrx",keysDUKPT:"/pinpadWeb/getKeysDUKPT",reverse:"/pinpadWeb/executeBackSale",rePrint:"/pinpadWeb/reprint",checkInMoto:"/pinpadWeb/checkin",checkOutMoto:"/pinpadWeb/checkout",reAuthorizationMoto:"/pinpadWeb/reAuthorization",cancellation:"/pinpadWeb/executeVoid",sale:"/pinpadWeb/executeSale"}},operation:{amount:0,reference:null,folio:null,authorization:null,errors:0,last_error:null,commerceVoucher:"",clientVoucher:"",consultDate:null,ignore:{counter:!1,counterSale:!1,isError92TRX:!1,C93Global:!1,error:""},finalResult:{},moto:{ccType:"",ccName:"",ccNumber:"",ccExpMonth:"",ccExpYear:"",ccCvvCsc:"",txRoom:""},bin:"",bin8:"",hasQPS:!1,onlyMerchant:"",merchant:null,typeOperation:"29",typeResponse:"",responseMit:{},applyReverse:!1},finishCommand:{A:"",B:"",C:"",D:"",E:"",F:"",G:"",H:"",I:"",J:"",K:""},waiting:{statusAboutWaiting:null,statusInjectWaiting:null,statusReadCardWaiting:null,statusSecondGenerateWaiting:null}});if(this.__internal__.device.type="pinpad",!_a())throw new Error("Crypto not supported in this browser");if(K.getCustom(this.typeDevice,n))throw new Error(`Device ${this.typeDevice} ${n} already exists`);this.__internal__.time.response_connection=3e3,this.__internal__.time.response_general=5e3,this.__internal__.serial.delay_first_connection=1e3,this.__internal__.serial.config_port.baudRate=19200,this.environment=c,s&&(this.username=s),a&&(this.password=a),o(this,p,pr).call(this),o(this,p,dr).call(this)}async timeout(t,e){await super.timeout(t,e),this.__pinPad__.waiting.statusAboutWaiting&&e==="about"?this.__pinPad__.waiting.statusAboutWaiting="rejected":this.__pinPad__.waiting.statusInjectWaiting&&e==="inject"?this.__pinPad__.waiting.statusInjectWaiting="rejected":this.__pinPad__.waiting.statusinitDUKPTWaiting&&e==="init-dukpt"?this.__pinPad__.waiting.statusinitDUKPTWaiting="rejected":this.__pinPad__.waiting.statuswritingDUKPTWaiting&&e==="dukpt"?this.__pinPad__.waiting.statuswritingDUKPTWaiting="rejected":this.__pinPad__.waiting.statusReadCardWaiting&&e==="read-card"?this.__pinPad__.waiting.statusReadCardWaiting="rejected":this.__pinPad__.waiting.statusSecondGenerateWaiting&&e==="second-generate"&&(this.__pinPad__.waiting.statusSecondGenerateWaiting="rejected")}serialMessage(t){const e={original_code:t,code:null,name:null,description:null,request:this.lastAction,no_code:0,parsed:null},n=this.parseHexToUint8(t),s=this.parseUint8ArrayToString(n);let a=o(this,p,fr).call(this,s);switch(this.__pinPad__.buffer=s,e.parsed=a,e.code=s,e.request){case"connect":e.name="connected",e.description="Connection established",e.no_code=100,o(this,p,vn).call(this,a,s);break;case"about":e.name="About PinPad",e.description="Response of about",e.no_code=101,o(this,p,vn).call(this,a,s);break;case"inject":e.name="Inject",e.description="Response of inject values",e.no_code=102,o(this,p,_r).call(this,a,s);break;case"init-dukpt":e.name="Init DUKPT",e.description="Response of init DUKPT",e.no_code=103,o(this,p,gr).call(this,a,s);break;case"dukpt":e.name="Write DUKPT",e.description="Response of write DUKPT",e.no_code=104,o(this,p,br).call(this,a,s);break;case"read-card":e.name="read card",e.description="response of read card",e.no_code=105,o(this,p,mr).call(this,a,s);break;case"second-generate":e.name="second generate",e.description="response of second generate",e.no_code=106,o(this,p,yr).call(this,a,s);break;case"cancel":e.name="cancel pinpad",e.description="response of cancel",e.no_code=107;break;case"print":o(this,p,Pr).call(this,a,s),e.name="print voucher",e.description="response of print",e.no_code=108;break;case"cancel-read-card":o(this,p,vr).call(this,a,s),e.name="cancel read card",e.description="response of cancel read card",e.no_code=109;break;case"code93":o(this,p,Er).call(this,a,s),e.name="code 93",e.description="response of code 93",e.no_code=110;break;case"finish-emv-end":o(this,p,Tr).call(this,a,s),e.name="Finish EMV End",e.description="response of finish EMV End",e.no_code=111;break;default:e.name="unknown",e.description="Unknown command",e.no_code=400;break}this.dispatch("serial:message",e)}serialSetConnectionConstant(t=1){const e="",n="";let s="C56AABOUT";s=e+s.length.toString().padStart(3,"0")+s+n;let a=0;for(let l=0;l<s.length;l++)a^=s.charCodeAt(l);s=s+String.fromCharCode(a);const c=this.parseStringToBytes(s,"");return this.add0x(c)}async sendCustomCode({code:t=""}={}){if(typeof t!="string")throw new Error("Invalid string");const e=this.parseStringToBytes(t);await this.appendToQueue(e,"custom")}set username(t){this.__pinPad__.config.username=t}get username(){return this.__pinPad__.config.username}set password(t){if(typeof t!="string")throw new Error("Invalid password");this.__pinPad__.config.password=t.toUpperCase()}get password(){return this.__pinPad__.config.password}set amount(t){if(t=parseFloat(t),isNaN(t)||t<=0)throw new Error("Invalid amount");this.__pinPad__.operation.amount=t.toFixed(2).toString()}get amount(){return parseFloat(this.__pinPad__.operation.amount)||0}set reference(t){if(!o(this,p,Cn).call(this,t.trim()))throw new Error("Invalid reference");this.__pinPad__.operation.reference=t.trim().toString().replaceAll(" ","").toUpperCase()}get reference(){return this.__pinPad__.operation.reference}get url(){const t=this.environment;return this.__pinPad__.constants.urls[t]}get version(){return{name:this.__pinPad__.constants.appName,version:this.__pinPad__.constants.appVersion,environment:this.environment,type:this.typeDevice}}set environment(t){const e=["development","qa","production","productionAlternative"];if(typeof t!="string"||!e.includes(t.toLowerCase()))throw new Error("The environment must be a string, in: "+e.join(", "));this.__pinPad__.config.defaultEnvironment=t.toLowerCase(),this.__pinPad__.config.environment=t.toLowerCase()}get defaultEnvironment(){return this.__pinPad__.config.defaultEnvironment}get environment(){return this.__pinPad__.config.environment}get latitudeLongitude(){return{latitude:this.__pinPad__.config.latitude,longitude:this.__pinPad__.config.longitude}}set timeoutPinPad(t){if(t=parseInt(t),isNaN(t)||t<=10||t>=300)throw new Error("Invalid timeout please use a number between 10 and 300 seconds");this.__pinPad__.config.timeoutPinPad=t.toString()}get timeoutPinPad(){return parseInt(this.__pinPad__.config.timeoutPinPad)}async login({force:t=!1}={}){return await o(this,p,Ar).call(this,t)}clearSession(){localStorage.removeItem("ppLoginResponse"),localStorage.removeItem("ppRSAKey"),localStorage.removeItem("ppPublicIP")}async checkPositionPermission(){if(!zn())throw new Error("Geolocation not supported");return new Promise((t,e)=>{navigator.permissions.query({name:"geolocation"}).then(n=>{n.state==="granted"?t(!0):t(!1)}).catch(()=>e(!1))})}async cancelReadCard(){let t="012VXVCANCELl";this.__pinPad__.about.model.toLowerCase()==="ingenico"&&(t="029C50AOPERACION CANCELADA");const e=this.parseStringToBytes(t,"");await this.appendToQueue(e,"cancel-read-card")}async print(t="client"){this.__pinPad__.operation.errors=0;const e=this.__pinPad__.constants.STX,n=this.__pinPad__.constants.ETX;this.__pinPad__.operation.commerceVoucher.includes(":")||(this.__pinPad__.operation.commerceVoucher=o(this,p,Lt).call(this,this.__pinPad__.config.RC4Key,this.__pinPad__.operation.commerceVoucher)),this.__pinPad__.operation.clientVoucher.includes(":")||(this.__pinPad__.operation.clientVoucher=o(this,p,Lt).call(this,this.__pinPad__.config.RC4Key,this.__pinPad__.operation.clientVoucher));let s=t==="client"?this.__pinPad__.operation.clientVoucher:this.__pinPad__.operation.commerceVoucher;if(s.length===0){this.dispatch("pp:print",{error:!0,code:"001",message:"Without information to print"});return}s=o(this,p,kr).call(this,s),s=o(this,p,xr).call(this,s,this.__pinPad__.constants.appName+this.__pinPad__.constants.appVersion);let a="C59A"+s;a=e+o(this,p,mt).call(this,a)+a+n,a=a+o(this,p,yt).call(this,a),t==="client"?this.__pinPad__.operation.clientVoucher="":t==="commerce"&&(this.__pinPad__.operation.commerceVoucher="");const c=this.parseStringToBytes(a,"");await this.appendToQueue(c,"print")}getClientVoucher(){return this.__pinPad__.operation.clientVoucher}getCommerceVoucher(){return this.__pinPad__.operation.commerceVoucher}async consult({reference:t=null}){return t||(t=this.reference),Ct(t)&&(t="--",this.reference=t),o(this,p,Or).call(this,this.reference),this.__pinPad__.operation.consultDate=new Date().toLocaleDateString("en-GB"),await o(this,p,he).call(this,{Ambiente:this.environment,User:this.username,Pwd:this.password,IdBranch:this.__pinPad__.config.idBranch,IdCompany:this.__pinPad__.config.idCompany,Country:this.__pinPad__.config.country,Tx_Date:this.__pinPad__.operation.consultDate}),o(this,p,Qt).call(this,this.url+this.__pinPad__.constants.uris.consult,{user:this.username.toUpperCase(),pwd:this.password.toUpperCase(),id_branch:this.__pinPad__.config.idBranch.toUpperCase(),id_company:this.__pinPad__.config.idCompany.toUpperCase(),date:this.__pinPad__.operation.consultDate,reference:this.reference})}async rePrint({folio:t=null}={}){t===null&&(t=this.__pinPad__.operation.folio||""),o(this,p,kn).call(this,t),await o(this,p,he).call(this,{Ambiente:this.environment,User:this.username,Pwd:this.password,IdBranch:this.__pinPad__.config.idBranch,IdCompany:this.__pinPad__.config.idCompany,Country:this.__pinPad__.config.country,Tx_OperationNumber:t});const e=await o(this,p,Qt).call(this,this.url+this.__pinPad__.constants.uris.rePrint,{REPRINTVOUCHER:{business:{country:this.__pinPad__.config.country.toUpperCase(),id_branch:this.__pinPad__.config.idBranch.toUpperCase(),id_company:this.__pinPad__.config.idCompany.toUpperCase(),pwd:this.password.toUpperCase(),user:this.username.toUpperCase()},no_operacion:t,crypto:"2"}});let n=e.voucher_comercio;return this.__pinPad__.operation.commerceVoucher="",n&&(e.voucher_comercio.includes(":")?this.__pinPad__.operation.commerceVoucher=e.voucher_comercio:this.__pinPad__.operation.commerceVoucher=o(this,p,Lt).call(this,this.__pinPad__.config.RC4Key,e.voucher_comercio)),n=e.voucher_cliente,this.__pinPad__.operation.clientVoucher="",n&&(e.voucher_cliente.includes(":")?this.__pinPad__.operation.clientVoucher=e.voucher_cliente:this.__pinPad__.operation.clientVoucher=o(this,p,Lt).call(this,this.__pinPad__.config.RC4Key,e.voucher_cliente)),e}async cancelPurchase({amount:t=0,authorization:e="",folio:n=""}={}){if(!o(this,p,Sn).call(this,t))throw new Error("Invalid amount");if(!o(this,p,zr).call(this,e))throw new Error("Invalid authorization");if(!o(this,p,kn).call(this,n))throw new Error("Invalid folio");t=o(this,p,In).call(this,t,2);const s={Ambiente:this.environment,User:this.username,Pwd:this.password,IdBranch:this.__pinPad__.config.idBranch,IdCompany:this.__pinPad__.config.idCompany,Country:this.__pinPad__.config.country,UserTRX:"userPinpadWeb",Tx_OperationNumber:n,Tx_Auth:e,Amount:t};await o(this,p,he).call(this,s);const a=o(this,p,Qt).call(this,this.url+this.__pinPad__.constants.uris.cancellation,{VMCAMEXMCANCELACION:{business:{country:this.__pinPad__.config.country.toUpperCase(),id_branch:this.__pinPad__.config.idBranch.toUpperCase(),id_company:this.__pinPad__.config.idCompany.toUpperCase(),pwd:this.password.toUpperCase(),user:this.username.toUpperCase()},transacction:{amount:t,auth:e.toUpperCase(),crypto:"2",no_operacion:n,usrtransacction:this.username.toUpperCase(),version:this.__pinPad__.constants.appName+this.__pinPad__.constants.appVersion}}});return this.__pinPad__.operation.commerceVoucher="",a.voucher_comercio&&(a.voucher_comercio.includes(":")?this.__pinPad__.operation.commerceVoucher=a.voucher_comercio:this.__pinPad__.operation.commerceVoucher=o(this,p,Lt).call(this,this.__pinPad__.config.RC4Key,a.voucher_comercio)),this.__pinPad__.operation.clientVoucher="",a.voucher_cliente&&(a.voucher_cliente.includes(":")?this.__pinPad__.operation.clientVoucher=a.voucher_cliente:this.__pinPad__.operation.clientVoucher=o(this,p,Lt).call(this,this.__pinPad__.config.RC4Key,a.voucher_cliente)),JSON.stringify(a)}async makeSale({amount:t=0,reference:e=null}={}){if(t=parseFloat(t.toString()),isNaN(t)||t<=0)throw new Error("Amount is required and must be greater than 0");if(this.amount=t,!e||Ct(e)||!o(this,p,Cn).call(this,e))throw new Error("Reference is required and must be alphanumeric");if(this.reference=e,/^[A-Z-a-z\s]+$/g.test(this.__pinPad__.config.currency)===!1)throw new Error("Invalid currency");let n={error:!1,message:null,approved:!1,object:{}};try{return await this.login(),await o(this,p,qr).call(this),!await o(this,p,jr).call(this)||!await o(this,p,Ur).call(this)?n:await o(this,p,Gr).call(this)}catch(s){console.warn(s),n.error=!0,n.message=s.message,n.approved=!1,n.object=s}return n}}p=new WeakSet,dr=function(){K.addCustom("pinpad",this)},pr=function(){const t=["pp:processing-card","pp:read-card","pp:error","pp:print","pp:merchant-moto","pp:dukpt","pp:finish-emv","pp:response","pp:error","pp:finish-emv"];for(const e of t)this.serialRegisterAvailableListener(e)},fr=function(t){const e=this.__pinPad__.constants.STX,n=this.__pinPad__.constants.ETX,s=this.__pinPad__.constants.FS,a=this.__pinPad__.constants.getNULL;t=t.replace(new RegExp(e,"g"),"");const c=t.split(n);t=c[0];const l=t.split(s);l.push(...c[1].split(s));const h={};return l.map((f,_)=>{const m=_>0?f.substring(0,1):"A",P=_>0?f.substring(1):f;return{[m]:P.replace(new RegExp(a,"g"),"")}}).forEach(f=>Object.assign(h,f)),h},vn=function(t,e){const n=this.__pinPad__.constants.ETX,s=e.substring(e.indexOf("D")+2,e.indexOf("E"));let a=0;const c=e.indexOf("N")>0,l=e.substring(e.indexOf("A00")+3,e.indexOf("B"));if(l&&l!=="undefined"&&l.toUpperCase()==="VERIFONE"){const f=s.replace("MITP_1.00.","").replace("MITP_01.00.","").replace("MITD_1.00.","").replace("MITD_01.00.","");a=parseInt(f),a>=15&&(this.__pinPad__.about.hasCashback=!0)}this.__pinPad__.about.supportInjection=c,e.indexOf("M")>0?(this.__pinPad__.about.supportSign=e.substring(e.indexOf("L")+2,e.indexOf("M")),this.__pinPad__.about.supportInjection?this.__pinPad__.about.supportContactlessCollisionCard=e.substring(e.indexOf("M")+2,e.indexOf("N")):(this.__pinPad__.about.supportContactlessCollisionCard=e.substring(e.indexOf("M")+2,e.indexOf(n)),this.__pinPad__.about.supportContactless=!0)):(this.__pinPad__.about.supportSign=e.substring(e.indexOf("L")+2,e.indexOf(n)),this.__pinPad__.about.supportContactless=!1),this.__pinPad__.about.supportDUKPT=e.substring(e.indexOf("J")+2,e.indexOf("K")),this.__pinPad__.about.EMV=e.substring(e.indexOf("E")+2,e.indexOf("F")),this.__pinPad__.about.serial=e.substring(e.indexOf("C")+2,e.indexOf("D")),this.__pinPad__.about.printer=e.substring(e.indexOf("F")+2,e.indexOf("G")),this.__pinPad__.about.model=e.substring(e.indexOf("B")+2,e.indexOf("C")),this.__pinPad__.about.brand=l,this.__pinPad__.about.appVersion=s;const h=e.substring(e.indexOf("K")+2,e.indexOf("L"));this.__pinPad__.about.pp={brand:l,appVersion:s,versionInt:a,hasCashback:this.__pinPad__.about.hasCashback,supportInjection:this.__pinPad__.about.supportInjection,supportSign:this.__pinPad__.about.supportSign,supportContactlessCollisionCard:this.__pinPad__.about.supportContactlessCollisionCard,supportContactless:this.__pinPad__.about.supportContactless,supportDUKPT:this.__pinPad__.about.supportDUKPT,hasDUKPTKeys:h,EMV:this.__pinPad__.about.EMV,serial:this.__pinPad__.about.serial,printer:this.__pinPad__.about.printer,model:this.__pinPad__.about.model},this.__pinPad__.waiting.statusAboutWaiting&&(this.__pinPad__.waiting.statusAboutWaiting="resolved")},_r=function(t,e){this.__pinPad__.waiting.statusInjectWaiting="resolved"},gr=function(t,e){e=e.replace("010P93A00B01t036P81AACERQUE, INSERTE CHIP O DESLICE*",""),this.__pinPad__.config.terminal={nb_kcv:e.substring(e.indexOf("E")+2,e.indexOf("F")),nb_marca_terminal:e.substring(e.indexOf("P91A")+4,e.indexOf("B")),nb_modelo_terminal:e.substring(e.indexOf("B")+2,e.indexOf("C")),nb_serie_lector:e.substring(e.indexOf("C")+2,e.indexOf("D")),nb_tk:e.substring(e.indexOf("F")+2,e.length-2),nb_version_terminal:e.substring(e.indexOf("D")+2,e.indexOf("E"))},this.__pinPad__.waiting.statusinitDUKPTWaiting="resolved"},br=function(t,e){this.__pinPad__.waiting.statuswritingDUKPTWaiting="resolved"},mr=function(t,e){const n=this.__pinPad__.about.brand.toLowerCase(),s=this.__pinPad__.about.model.toLowerCase(),a=n==="ingenico"&&s==="ipp320"?500:350;if(e.length<a){e=e.replace("006P93A00.","").replace("006P93A00,",""),e.includes("E93")?this.__pinPad__.operation.ignore.error=e.substring(e.indexOf("E93")+3,e.indexOf("E93")+6):e.includes("E71")&&(this.__pinPad__.operation.ignore.error=e.substring(e.indexOf("E71")+3,e.indexOf("E71")+6)),this.__pinPad__.operation.ignore.error!==""&&e.indexOf("OPERACION CANCELADA")===-1&&e.indexOf("TIEMPO EXCEDIDO")===-1&&this.__pinPad__.operation.ignore.error.length===3&&(this.__pinPad__.operation.last_error=o(this,p,Bn).call(this,this.__pinPad__.operation.ignore.error),this.__pinPad__.waiting.statusReadCardWaiting="rejected");return}if(e.includes("M1")||e.includes("M0")||e.includes("M1")||e.includes("N1")||e.includes("N1")||e.includes("P93A022")&&e.substring(e.length-24).includes("I")&&e.substring(e.length-1).includes("")||e.includes("P93A800")&&e.substring(e.length-24).includes("I")&&e.substring(e.length-1).includes("")||e.includes("P93A022")&&e.length>=406&&s==="vx820"||e.includes("P93A022")&&e.length>=406&&s==="vx520"||e.includes("P93A800")&&e.length>=406&&s==="vx520"||e.includes("P93A800")&&e.length>=406&&s==="vx820"||e.includes("P93A022")&&e.length>=406&&s==="p400"||e.includes("P93A800")&&e.length>=406&&s==="p400"||e.includes("P93A022")&&e.length>=406&&s==="v205c"||e.includes("P93A800")&&e.length>=406&&s==="v205c"||e.includes("P93A022")&&e.length>=406&&s==="move2500"||e.includes("P93A800")&&e.length>=406&&s==="move2500"||e.includes("P93A022")&&e.length>=406&&s==="lane3000"||e.includes("P93A800")&&e.length>=406&&s==="lane3000"){let c=e;n==="verifone"&&(c=e.replace("006P93A00.","").substring(e.indexOf("P93A"),e.indexOf("P93A")+7)),e.includes("P81APROCESANDO, NO RETIRE TARJETA")||e.includes("P81APROCESANDO TARJETA")||c.includes("P93A022")||c.includes("P81AINSERTE CHIP O DESLICE TARJETA")||c.includes("ACERQUE, INSERTE CHIP O DESLICE")||c.includes("P81AACERQUE, INSERTE CHIP O DESLICE TARJETA")?this.dispatch("pp:processing-card",{waiting:!0}):e.length>a&&o(this,p,wr).call(this,e)}},yr=function(t,e){const n=this.__pinPad__.constants.ETX;let s=e.replace("023P81AFAVOR RETIRAR TARJ.","").replace("020P81A DECLINADA EMV ","").replace("020P81A DECLINADA EMV ","");s=s.substring(s.indexOf("B")+2,s.indexOf(n)),s.includes("006E93A16")&&(s="01"),this.__pinPad__.operation.applyReverse=s==="01"&&this.__pinPad__.operation.responseMit._approved&&this.__pinPad__.config.otherLogin.executeReverse==="1",this.__pinPad__.waiting.statusSecondGenerateWaiting="resolved"},wr=function(t){const e=this.__pinPad__.constants.ETX,n=this.__pinPad__.about.brand.toLowerCase();let s,a,c,l,h;n==="verifone"?t=t.replace("006P93A00.","").replace("009P93A00","").replace("010P93A00B01v",""):t=t.replace("006P93A00,",""),this.__pinPad__.config.read.POSEM=t.substring(t.indexOf("P93A")+4,t.indexOf("B"));const f=this.__pinPad__.config.read.POSEM;if(f==="051"||f==="071"){if(this.__pinPad__.config.read.Chip="1",this.__pinPad__.config.read.PIN=t.substring(t.indexOf("C")+2,t.indexOf("D")),this.__pinPad__.config.read.AppId=t.substring(t.indexOf("G")+2,t.indexOf("H")),this.__pinPad__.config.read.AppIdLabel=t.substring(t.indexOf("H")+2,t.indexOf("I")),this.__pinPad__.config.read.Arqc=t.substring(t.indexOf("F")+2,t.indexOf("G")),t.includes("O")){const _=t.substring(t.indexOf("P93A"));this.__pinPad__.config.read.ReadCTLS=_.substring(_.indexOf("M")+2,_.indexOf("N")),this.__pinPad__.operation.hasQPS=_.substring(_.indexOf("N")+2,_.indexOf("O"))==="1",this.__pinPad__.operation.bin8=_.substring(_.indexOf("O")+2,_.indexOf(e))}else if(t.includes("N")){const _=t.substring(t.indexOf("P93A"));this.__pinPad__.config.read.ReadCTLS=_.substring(_.indexOf("M")+2,_.indexOf("N")),this.__pinPad__.operation.hasQPS=_.substring(_.indexOf("N")+2,_.indexOf(e))==="1"}else{const _=t.substring(t.indexOf("P93A"),t.indexOf("M")+5);this.__pinPad__.config.read.ReadCTLS=_.substring(_.indexOf("M")+2,_.indexOf(e)),this.__pinPad__.operation.hasQPS=!1}this.__pinPad__.config.read.Tags=t.substring(t.indexOf("B")+2,t.indexOf("C")),this.__pinPad__.config.read.NB_ksn=t.substring(t.indexOf("K")+2,t.indexOf("M")),this.__pinPad__.config.read.NB_Data=t.substring(t.indexOf("D")+2,t.indexOf("E")),a=t.substring(t.indexOf("I")+2,t.indexOf("J")),c=t.substring(t.indexOf("E")+2,t.indexOf("F")),this.__pinPad__.config.read.ChipName=c,s=t.substring(t.indexOf("J")+2,t.indexOf("K"))}else{let _;if(this.__pinPad__.config.read.Chip="0",this.__pinPad__.config.read.PIN="",this.__pinPad__.config.read.AppId="",this.__pinPad__.config.read.Arqc="",this.__pinPad__.config.read.ReadCTLS="0",this.__pinPad__.config.read.AppIdLabel=t.substring(t.indexOf("H")+2,t.indexOf("I")),this.__pinPad__.config.read.Tags=t.substring(t.indexOf("B")+2,t.indexOf("C")),f==="022")if(t.includes("O")){const m=t.substring(t.indexOf("P93A"));this.__pinPad__.operation.bin8=m.substring(m.indexOf("O")+2,m.indexOf(e)),_=t.substring(t.indexOf("P93A022"),t.indexOf("I")+23),_=_.substring(_.indexOf("I")+2,_.lastIndexOf(""))}else _=t.substring(t.indexOf("P93A022"),t.indexOf("I")+23),_=_.substring(_.indexOf("I")+2,_.indexOf(e));else _=t.substring(t.indexOf("P93A800"),t.indexOf("I")+23),_=_.substring(_.indexOf("I")+2,_.indexOf(e));this.__pinPad__.config.read.NB_ksn=_,this.__pinPad__.config.read.NB_Data=t.substring(t.indexOf("B")+2,t.indexOf("C")),a=t.substring(t.indexOf("F")+2,t.indexOf("G")),s=t.substring(t.indexOf("G")+2,t.indexOf("H")),this.__pinPad__.about.model.toLowerCase()==="vx520"?(c=t.substring(t.indexOf("H")+2,t.indexOf("I")),this.__pinPad__.config.read.ChipName=c):(c=t.substring(t.indexOf("H")+2,t.indexOf("I")),this.__pinPad__.config.read.ChipName=c)}s.includes("/")&&(s=s.replace("/","")),s.toString().length===4?(h=s.toString().substring(0,2),l=s.toString().substring(2)):(h="",l=""),this.__pinPad__.config.read.Chip==="1"?(this.__pinPad__.config.read.EMV="3",this.__pinPad__.config.read.ChipNameEnc="1"):(this.__pinPad__.config.read.ChipNameEnc="",this.__pinPad__.config.read.EMV="2"),this.__pinPad__.config.read.AppIdLabel.toLowerCase().includes("american")||this.__pinPad__.config.read.AppIdLabel.toLowerCase().includes("amex")?this.__pinPad__.config.read.Type="AMEX":this.__pinPad__.config.read.Type="V/MC",this.__pinPad__.operation.bin=a,a.length>6&&(this.__pinPad__.operation.bin=a.substring(0,6)),this.__pinPad__.waiting.statusReadCardWaiting="resolved",this.dispatch("pp:read-card",{ERROR:"",maskPan:a,name:c,month:h,year:l})},vr=function(t,e){e.length>10&&e.includes("E93A10")&&(this.__pinPad__.waiting.statusReadCardWaiting==="pending"&&(this.__pinPad__.waiting.statusReadCardWaiting="rejected"),this.dispatch("pp:error",{message:"Operation cancelled by user."}))},Pr=function(t,e){const n=this;if(this.__pinPad__.about.model.toLowerCase()==="vx520"){if(e.length>11)if(e.includes("P59A00"))this.__pinPad__.operation.clientVoucher!==""?setTimeout(function(){n.print("client").then(()=>{}).catch(s=>{console.error(s)})},1e3):this.dispatch("pp:print",{type:"success"});else{const s=e.includes("E17")||e.includes("A17")?{type:"warning",message:"printer without paper"}:{type:"error",message:"The voucher could not be printed"};this.dispatch("pp:print",s)}}else if(e.includes("P59A00"))this.__pinPad__.operation.clientVoucher!==""?setTimeout(function(){n.print("client").then(()=>{}).catch(s=>{console.error(s)})},1e3):this.dispatch("pp:print",{type:"success"});else{const s=e.includes("E17")||e.includes("A17")?{type:"warning",message:"printer without paper"}:{type:"error",message:"The voucher could not be printed"};this.dispatch("pp:print",s)}},Er=function(t,e){},Tr=function(t,e){},ae=function(t,e){const n=new qa;return n.setPublicKey(t),n.encrypt(e)},oe=function(t){const e="0123456789ABCDEF";let n="";for(let s=0;s<t;s++){const a=Math.floor(Math.random()*e.length);n+=e.substring(a,a+1)}return n},Cr=function(t){const e="0123456789abcdef",n=[],s=[];for(let a=0;a<256;a++)n[a]=e.charAt(a>>4)+e.charAt(a&15);for(let a=0;a<t.length;a++)s[a]=n[t.charCodeAt(a)];return s.join("")},ce=async function(t,e){const n=new Uint8Array(t.match(/.{1,2}/g).map(m=>parseInt(m,16))),s=crypto.getRandomValues(new Uint8Array(16)),c=new TextEncoder().encode(e),l=await crypto.subtle.importKey("raw",n,{name:"AES-CBC"},!1,["encrypt"]),h=await crypto.subtle.encrypt({name:"AES-CBC",iv:s},l,c),f=btoa(String.fromCharCode(...s)),_=btoa(String.fromCharCode(...new Uint8Array(h)));return f+_},Sr=function(t,e,n=!1){const s=[];for(let f=0;f<256;f++)s[f]=f;let a=0;for(let f=0;f<256;f++)a=(a+s[f]+t.charCodeAt(f%t.length))%256,[s[f],s[a]]=[s[a],s[f]];let c=0,l=0,h="";for(const f of e){c=(c+1)%256,l=(l+s[c])%256,[s[c],s[l]]=[s[l],s[c]];let _=s[(s[c]+s[l])%256];h+=String.fromCharCode(f.charCodeAt(0)^_)}return n?o(this,p,Cr).call(this,h).toUpperCase():h},Lt=function(t,e){return o(this,p,Sr).call(this,t,this.hexToAscii(e))},kr=function(t){return t.replaceAll("Á","A"),t.replaceAll("É","E"),t.replaceAll("Í","I"),t.replaceAll("Ó","O"),t.replaceAll("Ú","U"),t.replaceAll("á","a"),t.replaceAll("é","e"),t.replaceAll("í","i"),t.replaceAll("ó","o"),t.replaceAll("ú","u"),t.replaceAll("ñ","n"),t.replaceAll("Ñ","N"),t.replaceAll('Electr?a"',"Electronica"),t},J=function(t,e,n){if(t=t.replace("@cnb logo_cpagos",e),t=t.replace("@cnn ver_app",n),t=t.replace(/@/g," @"),t=t.replace(/ {2}@/g," @"),t=t.replace(/ {3}@/g," @"),t=t.replace(/\r/g,""),t=t.replace(/\n/g,""),t.includes("@lsn POR ESTE PAGARE ME OBLIGO INCONDI")){const s=t.indexOf("@lsn POR ESTE PAGARE ME OBLIGO INCONDI");t=t.substring(0,s)}return t.trim()+"@br @br @br @br @br"},xr=function(t,e){const n="@logo3 @br",s="@cnn "+e;return t.includes("@cnb Santander")?(t=t.replace("@cnb Santander","@logo1@br"),o(this,p,J).call(this,t,n,s)):t.includes("@cnb American Express")?(t=t.replace("@cnb American Express","@logo2@br"),o(this,p,J).call(this,t,n,s)):t.includes("@cnb HSBC")?(t=t.replace("@cnb HSBC","@logo7@br"),o(this,p,J).call(this,t,n,s)):t.includes("@cnb IXE")?(t=t.replace("@cnb IXE","@logo11@br"),o(this,p,J).call(this,t,n,s)):t.includes("@cnb MULTIVA")?(t=t.replace("@cnb MULTIVA","@logo15@br"),o(this,p,J).call(this,t,n,s)):t.includes("@cnb Multiva")?(t=t.replace("@cnb Multiva","@logo15@br"),o(this,p,J).call(this,t,n,s)):t.includes("@cnb SCOTIA BANK")?(t=t.replace("@cnb SCOTIA BANK","@logo16@br"),o(this,p,J).call(this,t,n,s)):t.includes("@cnb SCOTIABANK")?(t=t.replace("@cnb SCOTIABANK","@logo16@br"),o(this,p,J).call(this,t,n,s)):t.includes("@cnb BANCOMER")?(t=t.replace("@cnb BANCOMER","@logo17@br"),o(this,p,J).call(this,t,n,s)):t.includes("@cnb Bancomer")?(t=t.replace("@cnb Bancomer","@logo17@br"),o(this,p,J).call(this,t,n,s)):t.includes("@cnb BBVA")?(t=t.replace("@cnb BBVA","@logo17@br"),o(this,p,J).call(this,t,n,s)):t.includes("@cnb BANORTE")?(t=t.replace("@cnb BANORTE","@logo18@br"),o(this,p,J).call(this,t,n,s)):t.includes("@cnb Banorte")?(t=t.replace("@cnb Banorte","@logo18@br"),o(this,p,J).call(this,t,n,s)):t.includes("@cnb BANREGIO")?(t=t.replace("@cnb BANREGIO","@logo19@br"),o(this,p,J).call(this,t,n,s)):t.includes("@cnb Banregio")?(t=t.replace("@cnb Banregio","@logo19@br"),o(this,p,J).call(this,t,n,s)):t.includes("@cnb GETNET")?(t=t.replace("@cnb GETNET","@logo20@br"),o(this,p,J).call(this,t,n,s)):t.includes("@cnb GetNET")?(t=t.replace("@cnb GetNET","@logo20@br"),o(this,p,J).call(this,t,n,s)):o(this,p,J).call(this,t,n,s)},Ar=async function(t=!1){if(o(this,p,Rr).call(this),this.__pinPad__.config.loginResponse&&!t)return await o(this,p,Pn).call(this);const e=this.url+this.__pinPad__.constants.uris.login,n={usuario:this.username,password:this.password,crypto:"",version:this.__pinPad__.constants.appVersion,serieLector:"",canal:this.__pinPad__.constants.appChannel};if(await o(this,p,le).call(this),o(this,p,En).call(this))throw new Error("Empty RSA Key");const s=o(this,p,oe).call(this,32),a=o(this,p,ae).call(this,this.__pinPad__.config.publicKeyRSA,s),c=await o(this,p,ce).call(this,s,JSON.stringify(n)),l=await j.post(e,c,{headers:{"Content-Type":"application/json","cache-control":"no-cache, must-revalidate, post-check=0, pre-check=0, max-age=0",data:a||""}}).catch(f=>{var _;throw new Error(`Error in request, verify internet connection: ${(_=f.response)==null?void 0:_.status} ${f.message}`)});let h=o(this,p,xn).call(this,JSON.stringify(l.data));if(typeof h=="string"&&(h=JSON.parse(h)),!h)throw new Error("Invalid response JSON");if(h.RESPUESTA==="error")throw new Error(h);return this.__pinPad__.config.loginResponse=h,localStorage.setItem("ppLoginResponse",JSON.stringify({timestamp:new Date().getTime(),data:h})),await o(this,p,Pn).call(this)},Pn=async function(){await o(this,p,Mr).call(this);try{await o(this,p,Nr).call(this)}catch(t){console.log("Error getting position",t)}return this.__pinPad__.config.otherLogin={},o(this,p,Dr).call(this,this.__pinPad__.config.loginResponse),this.__pinPad__.config.otherLogin},Dr=function(t){var a,c,l,h,f,_;let e="",n="";(c=(a=t.xml)==null?void 0:a.ventaspropias)!=null&&c.merchant_currencyb&&(e=t.xml.ventaspropias.merchant_currencyb),(h=(l=t.xml)==null?void 0:l.ventaspropias)!=null&&h.merchant_currencym&&(n=t.xml.ventaspropias.merchant_currencym);let s=(f=t.xml)==null?void 0:f.emvReverso;s||(s="0"),this.__pinPad__.config.internal.stTokenization=(_=t.xml)==null?void 0:_.st_tokenizacion,!this.__pinPad__.config.internal.stTokenization||this.__pinPad__.config.internal.stTokenization==="false"||this.__pinPad__.config.internal.stTokenization==="0"?this.__pinPad__.config.internal.stTokenization=!1:this.__pinPad__.config.internal.stTokenization&&(this.__pinPad__.config.internal.stTokenization=!0),this.__pinPad__.config.internal.emv=t.xml.importesPGS,this.__pinPad__.config.internal.qpsDomestic=this.__pinPad__.config.internal.emv.qps_dom,this.__pinPad__.config.internal.qpsInternational=this.__pinPad__.config.internal.emv.qps_il,this.__pinPad__.config.internal.cvmlVMCDomestic=this.__pinPad__.config.internal.emv.cvml_vm_dom,this.__pinPad__.config.internal.cvmlVMCInternational=this.__pinPad__.config.internal.emv.cvml_vm_il,this.__pinPad__.config.internal.cvmlAmex=this.__pinPad__.config.internal.emv.cvml_amex,this.__pinPad__.config.internal.translimitCTLSVMC=this.__pinPad__.config.internal.emv.tl_mc,this.__pinPad__.config.internal.translimitCTLSAmex=this.__pinPad__.config.internal.emv.tl_amex,this.__pinPad__.config.country=t.country.toUpperCase(),this.__pinPad__.config.idBranch=t.id_branch.toUpperCase(),this.__pinPad__.config.idCompany=t.id_company.toUpperCase(),this.__pinPad__.config.otherLogin={bsUser:t.user,nbUser:t.nb_user,bsCompany:t.id_company,nbCompany:t.nb_company,nbStreetCompany:t.nb_companystreet,bsBranch:t.id_branch,nbBranch:t.nb_branch,bsCountry:t.country,coins:e,coinsMOTO:n,executeReverse:s}},Rr=function(){let t=localStorage.getItem("ppLoginResponse");t&&(t=JSON.parse(t),this.__pinPad__.config.loginResponse||(this.__pinPad__.config.loginResponse=t.data),new Date().getTime()-t.timestamp>=864e5&&(this.__pinPad__.config.loginResponse=null))},Ir=async function(){const t=this.url+this.__pinPad__.constants.uris.RSAKey,e=await j.get(t).catch(n=>{throw new Error(`Error in request, verify internet connection: ${n.response.status} ${n.message}`)});if(e.headers.get("content-type").indexOf("application/json")===-1)throw new Error("Fail to fetch RSA public key");return this.__pinPad__.config.publicKeyRSA=e.data.key_public,localStorage.setItem("ppRSAKey",JSON.stringify({timestamp:new Date().getTime(),data:e.data.key_public})),this.__pinPad__.config.publicKeyRSA},En=function(){let t=localStorage.getItem("ppRSAKey");return!t||(t=JSON.parse(t),this.__pinPad__.config.publicKeyRSA=t.data,new Date().getTime()-t.timestamp>=864e5)?!0:!this.__pinPad__.config.publicKeyRSA},Tn=async function(){return o(this,p,En).call(this)?await o(this,p,Ir).call(this):this.__pinPad__.config.publicKeyRSA},le=async function(){if(!await o(this,p,Tn).call(this))throw new Error("RSA public key is empty")},Cn=function(t){return/^[A-Z-a-z0-9\s]+$/g.test(t)},Or=function(t){if(Ct(t))return!0;const e=/^[A-Z-a-z0-9\s]+$/g.test(t)===!0;if(!e)throw new Error("Invalid reference");return e},mt=function(t){return t.length.toString().padStart(3,"0")},yt=function(t){let e=0;for(let n=0;n<t.length;n++)e^=t.charCodeAt(n);return String.fromCharCode(e)},Ue=function(t,e=0){return t=parseFloat(t.toString().replace(/[^0-9.-]/g,"")),isNaN(t)?0 .toFixed(e):t.toFixed(e).replace(/,/g,"")},Sn=function(t){return t=parseFloat(t.toString()),!(isNaN(t)||t<0)},he=async function(t){for(const e in t)if(typeof t[e]>"u"||t[e]===null||t[e]==="")throw new Error("Object incomplete to process");return t},kn=function(t){if(!t||isNaN(parseInt(t))||t.toString().length!==9)throw new Error("Number of operation must be number of 9 digits");return t},xn=function(t){if(typeof t!="string")throw new Error("Invalid string");return!t||/<html(?:\s+lang=["'][^"']*["'])?>/i.test(t)||(t=t.replace(/aaa/g,"á"),t=t.replace(/eee/g,"é"),t=t.replace(/iii/g,"í"),t=t.replace(/ooo/g,"ó"),t=t.replace(/uuu/g,"ú"),t=t.replace(/NNN/g,"Ñ"),t=t.replace(/nnn/g,"ñ"),t=t.replace(/á/g,"á")),t},Br=async function(){const t=this.__pinPad__.constants.STX,e=this.__pinPad__.constants.ETX;let n="C55ACANCEL";n=t+o(this,p,mt).call(this,n)+n+e,n=n+o(this,p,yt).call(this,n);const s=this.parseStringToBytes(n,"");await this.appendToQueue(s,"cancel")},An=function(){const t=new Date,e=t.getDate().toString().padStart(2,"0"),n=(t.getMonth()+1).toString().padStart(2,"0"),s=t.getFullYear().toString().substring(2);return e+n+s},Dn=function(){const t=new Date,e=t.getHours().toString().padStart(2,"0"),n=t.getMinutes().toString().padStart(2,"0");return e+n},Nr=async function(){return this.__pinPad__.config.latitude&&this.__pinPad__.config.longitude?this.latitudeLongitude:(this.__pinPad__.config.latitude=null,this.__pinPad__.config.longitude=null,zn()?new Promise(t=>{navigator.geolocation.getCurrentPosition(e=>{this.__pinPad__.config.latitude=e.coords.latitude,this.__pinPad__.config.longitude=e.coords.longitude,t(this.latitudeLongitude)},()=>{t(this.latitudeLongitude)})}):this.latitudeLongitude)},Mr=async function(){let t=localStorage.getItem("ppPublicIP");if(t&&(t=JSON.parse(t),this.__pinPad__.config.publicIP=t.data,new Date().getTime()-t.timestamp>=864e5&&(this.__pinPad__.config.publicIP=null)),this.__pinPad__.config.publicIP)return this.__pinPad__.config.publicIP;this.__pinPad__.config.publicIP=null;let e=!1;const n=await j.get("https://api.ipify.org?format=json").catch(()=>e=!0);return e?null:(this.__pinPad__.config.publicIP=n.data.ip||null,localStorage.setItem("ppPublicIP",JSON.stringify({timestamp:new Date().getTime(),data:n.data.ip})),this.__pinPad__.config.publicIP)},Qt=async function(t,e){await o(this,p,le).call(this);const n=o(this,p,oe).call(this,32);let s=o(this,p,ae).call(this,this.__pinPad__.config.publicKeyRSA,n),a=await o(this,p,ce).call(this,n,JSON.stringify(e));return(await j.post(t,a,{headers:{"Content-Type":"application/json","cache-control":"no-cache",data:s||""}}).catch(l=>{var h;throw l.response.data.includes("Ha ocurrido un error al procesar su solicitud.")?new Error("It was not possible to obtain the affiliations."):l.response.status>=500&&l.response.status<=599?new Error(`Service Temporarily Unavailable ${l.message}`):new Error(`Error in request, verify internet connection: ${(h=l.response)==null?void 0:h.status} ${l.message}`)})).data},Rn=async function({data:t,url:e,cancelable:n=!1}={}){await o(this,p,le).call(this);const s=o(this,p,oe).call(this,32),a=o(this,p,ae).call(this,this.__pinPad__.config.publicKeyRSA,s),c=await o(this,p,ce).call(this,s,JSON.stringify(t)),l=this;return(await j.post(e,c,{headers:{"Content-Type":"application/json","cache-control":"no-cache",data:a||""}}).catch(async f=>{var m;let _=`Error in request, verify internet connection: ${f.status} ${f.message}`;throw f.response.status>=500&&f.response.status<=599?_="Service Temporarily Unavailable":f.response.status>=400&&f.response.status<=499&&(_="Bad Request"),n&&await o(m=l,p,Br).call(m),new Error(_)})).data},Fr=async function(){const t=this.__pinPad__.constants.FS,e=this.__pinPad__.constants.ETX,n=this.__pinPad__.constants.STX;let s="C57A"+this.__pinPad__.config.internal.qpsDomestic;if(s=s+t+"B"+this.__pinPad__.config.internal.qpsInternational,s=s+t+"C"+this.__pinPad__.config.internal.cvmlVMCDomestic,s=s+t+"D"+this.__pinPad__.config.internal.cvmlVMCInternational,s=s+t+"E"+this.__pinPad__.config.internal.cvmlAmex,s=s+t+"F"+this.__pinPad__.config.internal.translimitCTLSVMC,s=s+t+"G"+this.__pinPad__.config.internal.translimitCTLSAmex,s=n+o(this,p,mt).call(this,s)+s+e,s=s+o(this,p,yt).call(this,s),!this.__pinPad__.about.injectedValues){const a=this.parseStringToBytes(s,"");await this.appendToQueue(a,"inject")}},Ur=async function(){this.__pinPad__.operation.bin8&&(this.__pinPad__.operation.bin=this.__pinPad__.operation.bin8),this.__pinPad__.operation.bin8="";const t=await o(this,p,Rn).call(this,{data:{accion:"tipoPagoInfo",cc_num:this.__pinPad__.operation.bin,usuario:this.username.toUpperCase(),canal:this.__pinPad__.constants.typeChannel,tp_canal:"1",tp_moneda:this.__pinPad__.config.currency.toUpperCase()},url:this.url+this.__pinPad__.constants.uris.merchant,cancelable:!0});if(!t.respuesta||t.respuesta==="0"){let e="C55ACANCEL";const n=this.__pinPad__.constants.STX,s=this.__pinPad__.constants.ETX;e=n+o(this,p,mt).call(this,e)+e+s,e=e+o(this,p,yt).call(this,e);const a=this.parseStringToBytes(e,"");return await this.appendToQueue(a,"cancel"),!1}return this.__pinPad__.operation.merchant=t,this.__pinPad__.operation.onlyMerchant=t.contado.af.length>1?t.contado.af[0].merchant:t.contado.af.merchant,!0},Lr=async function(t=null){if(this.__pinPad__.waiting.statusAboutWaiting)throw new Error("AboutPP is already running");const e=this.__pinPad__.constants.STX,n=this.__pinPad__.constants.ETX;let s="C56AABOUT";if(s=e+o(this,p,mt).call(this,s)+s+n,s=s+o(this,p,yt).call(this,s),Ct(this.__pinPad__.about.pp)){this.__pinPad__.waiting.statusAboutWaiting="pending";const l=this.parseStringToBytes(s,"");await this.appendToQueue(l,"about")}else return t?t(this.__pinPad__.about.pp.supportDUKPT,this.__pinPad__.about.pp.hasDUKPTKeys):!0;const a=this;let c=0;return new Promise((l,h)=>{c=setInterval(()=>{if(a.__pinPad__.waiting.statusAboutWaiting==="resolved"){if(clearInterval(c),a.__pinPad__.waiting.statusAboutWaiting=null,Ct(a.__pinPad__.about.pp))return;t||l(!0),l(t(a.__pinPad__.about.pp.supportDUKPT,a.__pinPad__.about.pp.hasDUKPTKeys))}else a.__pinPad__.waiting.statusAboutWaiting==="rejected"&&(clearInterval(c),a.__pinPad__.waiting.statusAboutWaiting=null,h("Error"))},500)})},Le=async function(t,e){if(t=t?t.toString():"",e=e?e.toString():"",Ct(t)||t==="0"){this.dispatch("pp:dukpt",{status:"unsupported",already:!1});return}if(Ct(e)||e==="1"){this.dispatch("pp:dukpt",{status:"charged",already:!0});return}const n=o(this,p,An).call(this),s=o(this,p,Dn).call(this),a=this.__pinPad__.constants.FS,c=this.__pinPad__.constants.ETX,l=this.__pinPad__.constants.STX;let h="C91A"+n+a+"B"+s;h=l+o(this,p,mt).call(this,h)+h+c,h=h+o(this,p,yt).call(this,h);const f=this.parseStringToBytes(h,"");await this.appendToQueue(f,"init-dukpt");let _=0;this.__pinPad__.waiting.statusinitDUKPTWaiting="pending";const m=this;return new Promise((P,v)=>{_=setInterval(async()=>{var S;m.__pinPad__.waiting.statusinitDUKPTWaiting==="resolved"?(clearInterval(_),m.__pinPad__.waiting.statusinitDUKPTWaiting=null,m.dispatch("pp:dukpt",{status:"charged",already:!1}),await o(S=m,p,Vr).call(S),P(!0)):m.__pinPad__.waiting.statusinitDUKPTWaiting==="rejected"&&(clearInterval(_),m.__pinPad__.waiting.statusinitDUKPTWaiting=null,v("Error"))},500)})},Vr=async function(){const t={IPEK_REQUESTType:{business:{country:this.__pinPad__.config.country.toUpperCase(),id_branch:this.__pinPad__.config.idBranch.toUpperCase(),id_company:this.__pinPad__.config.idCompany.toUpperCase(),pwd:this.password.toUpperCase(),user:this.username.toUpperCase()},terminal:this.__pinPad__.config.terminal}},e=await o(this,p,Rn).call(this,{data:t,url:this.url+this.__pinPad__.constants.uris.keysDUKPT});await o(this,p,Zr).call(this,e)},qr=async function(){if(!await o(this,p,Tn).call(this))throw new Error("RSA public key is empty");const e=this;await o(this,p,Lr).call(this,async function(s,a){var l,h;if(e.__pinPad__.about.supportInjection&&e.__pinPad__.config.internal.emv&&e.__pinPad__.about.injectedValues)return await o(l=e,p,Le).call(l,s,a),!0;let c=0;return e.__pinPad__.waiting.statusInjectWaiting="pending",await o(h=e,p,Fr).call(h),new Promise((f,_)=>{c=setInterval(async()=>{var m;e.__pinPad__.waiting.statusInjectWaiting==="resolved"?(clearInterval(c),e.__pinPad__.waiting.statusInjectWaiting=null,await o(m=e,p,Le).call(m,s,a),f(!0)):e.__pinPad__.waiting.statusInjectWaiting==="rejected"&&(clearInterval(c),e.__pinPad__.waiting.statusInjectWaiting=null,_("Error"))},500)})})},In=function(t,e=0){if(t=parseFloat(t.toString().replace(/[^0-9.-]/g,"")),isNaN(t)||t===0)return parseFloat("0").toFixed(e);t=t.toFixed(e);let n=t.split(".");return n[0]=n[0].replace(/\B(?=(\d{3})+(?!\d))/g,""),n.join(".")},jr=async function(){this.__pinPad__.operation.errors=0;let t="ACERQUE, INSERTE CHIP O DESLICE TARJETA";if(this.__pinPad__.about.supportContactless||(t="INSERTE CHIP O DESLICE TARJETA"),this.__pinPad__.about.model.toUpperCase().includes("UX300")&&(t="ACERQUE O INSERTE TARJETA"),Ct(this.amount)||this.amount<=0)throw new Error("Amount required");if(o(this,p,Sn).call(this,this.amount)===!1)throw new Error("Invalid amount required");if(o(this,p,Ue).call(this,this.amount,2)<=0)throw new Error("Amount must be greater than 0");const e=this.__pinPad__.constants.FS,n=this.__pinPad__.constants.STX,s=this.__pinPad__.constants.ETX;let a="C93A"+t;a=a+e+"B"+o(this,p,An).call(this),a=a+e+"C"+o(this,p,Dn).call(this),a=a+e+"D"+o(this,p,Ue).call(this,this.amount,2),a=a+e+"E0.00",a=a+e+"F"+this.__pinPad__.config.currencyCode,this.__pinPad__.about.supportDUKPT&&this.__pinPad__.about.supportDUKPT!=="0"&&this.__pinPad__.about.supportDUKPT!=="false"&&(this.__pinPad__.about.supportContactless?(a=a+e+"G"+this.timeoutPinPad,a=a+e+"HTAGS",a=a+e+"I"+this.__pinPad__.config.requireCVVAmex,a=a+e+"J"+this.__pinPad__.config.forceOnline,a=a+e+"K"+this.__pinPad__.about.supportContactless,a=a+e+"L"+this.__pinPad__.config.emvCard,this.__pinPad__.about.hasCashback&&(a=a+e+"M0",a=a+e+"N00")):(a=a+e+"G"+this.timeoutPinPad,a=a+e+"HTAGS",a=a+e+"I"+this.__pinPad__.config.requireCVVAmex,a=a+e+"L"+this.__pinPad__.config.emvCard),this.__pinPad__.about.supportInjection&&(a=a+e+"O"+this.__pinPad__.config.validateQPS)),a=n+o(this,p,mt).call(this,a)+a+s,a=a+o(this,p,yt).call(this,a),o(this,p,Yr).call(this);const c=this.parseStringToBytes(a,"");await this.appendToQueue(c,"read-card");let l=0;const h=this;return this.__pinPad__.waiting.statusReadCardWaiting="pending",new Promise((f,_)=>{l=setInterval(()=>{if(h.__pinPad__.waiting.statusReadCardWaiting==="resolved")clearInterval(l),h.__pinPad__.waiting.statusReadCardWaiting=null,f(!0);else if(h.__pinPad__.waiting.statusReadCardWaiting==="rejected"){clearInterval(l),h.__pinPad__.waiting.statusReadCardWaiting=null;const m=h.__pinPad__.operation.last_error;_(m??"Error reading card")}},500)})},Hr=async function(t){return await dt(t*1e3)},Kr=async function(t){let e=this.url+this.__pinPad__.constants.uris.consult;return t>1&&this.environment==="production"&&(e=e.replace(this.__pinPad__.constants.urls.production,this.__pinPad__.constants.urls.productionAlternative)),this.__pinPad__.operation.consultDate=new Date().toLocaleDateString("en-GB"),await o(this,p,Qt).call(this,e,{user:this.username.toUpperCase(),pwd:this.password.toUpperCase(),id_branch:this.__pinPad__.config.idBranch.toUpperCase(),id_company:this.__pinPad__.config.idCompany.toUpperCase(),date:this.__pinPad__.operation.consultDate,reference:this.reference})},Wr=async function(t="",e={}){let n=1,s=null;do{n>1&&this.environment==="production"&&(t=t.replace(this.__pinPad__.constants.urls.production,this.__pinPad__.constants.urls.productionAlternative),await o(this,p,Hr).call(this,5)),await o(this,p,le).call(this);const a=o(this,p,oe).call(this,32),c=o(this,p,ae).call(this,this.__pinPad__.config.publicKeyRSA,a),l=await o(this,p,ce).call(this,a,JSON.stringify(e));let h=!1;const f=await j.post(t,l,{headers:{"Content-Type":"application/json",data:c||""}}).catch(async _=>{let m=`Error in request, verify internet connection: ${_.status} ${_.message}`;_.response.status>=500&&_.response.status<=599?m="Service Temporarily Unavailable":_.response.status>=400&&_.response.status<=499&&(m="Bad Request"),console.warn(_),s=m;const P=await o(this,p,Kr).call(this,n);P&&P!=="{}"&&!P.includes('"transacciones":""')&&P.includes("nu_operaion")&&(n=5,s="EE32"),h=!0});if(!h)return f.data}while(n++<=3);return s?Promise.reject(s):Promise.reject("Communication error with CDP. IL/MTY")},zr=function(t){if(Ct(t))throw new Error("Number of authorization invalid");if(/^[A-Za-z0-9]+$/g.test(t)!==!0)throw new Error("Number of authorization invalid");if(t.length!==6)throw new Error("Number of authorization invalid");return!0},Xr=function(t){var s,a;const e=this;this.__pinPad__.operation.responseMit._approved=t.response==="approved",this.__pinPad__.operation.responseMit._status=t.response,this.__pinPad__.operation.responseMit._originalToken=t.number_tkn??"",this.__pinPad__.operation.folio=t.foliocpagos,this.__pinPad__.operation.authorization=t.auth;let n=(s=t.cd_response)==null?void 0:s.toUpperCase();return n.toUpperCase()==="0C"||this.__pinPad__.operation.responseMit._approved?n="00":(n!=="Z3"&&n!=="05"||t.cd_error==="92")&&(n="01"),this.__pinPad__.operation.responseMit._cdResponse=n,this.__pinPad__.finishCommand.A=n,this.__pinPad__.finishCommand.B="",this.__pinPad__.finishCommand.C="",this.__pinPad__.finishCommand.D="",this.__pinPad__.finishCommand.E=t.emv_key_date?t.emv_key_date:"",this.__pinPad__.finishCommand.F=t.icc_csn?t.icc_csn:"",this.__pinPad__.finishCommand.G=t.icc_atc?t.icc_atc:"",this.__pinPad__.finishCommand.H=t.icc_arpc?t.icc_arpc:"",this.__pinPad__.finishCommand.I=t.icc_issuer_script?t.icc_issuer_script:"",this.__pinPad__.finishCommand.J=t.authorized_amount?t.authorized_amount:"",this.__pinPad__.finishCommand.K=t.account_balance_1?t.account_balance_1:"",{reference:t.reference,response:t.response,foliocpagos:t.foliocpagos,auth:t.auth,cd_response:n,cd_error:t.cd_error,nb_error:o(a=e,p,xn).call(a,t.nb_error??""),time:t.time,date:t.date,nb_company:t.nb_company,nb_merchant:t.nb_merchant,nb_street:t.nb_street,cc_type:t.cc_type,tp_operation:t.tp_operation,cc_name:t.cc_name,cc_number:t.cc_number,cc_expmonth:t.cc_expmonth,cc_expyear:t.cc_expyear,amount:t.amount,voucher_comercio:t.voucher_comercio,voucher_cliente:t.voucher_cliente,friendly_response:t.friendly_response,appid:t.appid,appidlabel:t.appidlabel,arqc:t.arqc}},Gr=async function(){var s,a;const t=this;this.__pinPad__.operation.errors=0,this.__pinPad__.operation.ignore.counterSale=!1;const e=this.__pinPad__.operation.onlyMerchant;if(/^[0-9]+$/.test(e)===!1)throw new Error("Invalid merchant");this.__pinPad__.operation.typeOperation="29";let n={error:!1,message:null,approved:!1,object:{}};try{const c=await o(this,p,In).call(this,this.amount,2);await o(this,p,he).call(this,{Ambiente:this.environment,Country:this.__pinPad__.config.country,IdBranch:this.__pinPad__.config.idBranch,IdCompany:this.__pinPad__.config.idCompany,pwd:this.password,User:this.username,UserTRX:"userPinpadWeb",EMV:this.__pinPad__.config.read.EMV,ModeloTerminal:this.__pinPad__.about.model,SerieTerminal:this.__pinPad__.about.serial,Contactless:this.__pinPad__.about.supportContactless,Printer:this.__pinPad__.about.printer,VersionTerminal:this.__pinPad__.about.appVersion,TpOperation:this.__pinPad__.operation.typeOperation,Reference:this.reference,Amount:c,Currency:this.__pinPad__.config.currency,Merchant:e,Reverse:this.__pinPad__.config.otherLogin.executeReverse});const l=this.__pinPad__.about.supportContactless&&this.__pinPad__.about.supportContactless!=="0"?"1":"0",h=await o(this,p,Wr).call(this,this.url+this.__pinPad__.constants.uris.sale,{VMCAMEXB:{business:{country:this.__pinPad__.config.country.toUpperCase(),id_branch:this.__pinPad__.config.idBranch.toUpperCase(),id_company:this.__pinPad__.config.idCompany.toUpperCase(),pwd:this.password.toUpperCase(),user:this.username.toUpperCase()},dcc:{dcc_amount:"0",dcc_status:"0"},transacction:{amount:c,creditcard:{appid:this.__pinPad__.config.read.AppId,appidlabel:this.__pinPad__.config.read.AppIdLabel,arqc:this.__pinPad__.config.read.Arqc,chip:this.__pinPad__.config.read.Chip,chipname:this.__pinPad__.config.read.ChipName,chipnameenc:this.__pinPad__.config.read.ChipNameEnc,contactless:this.__pinPad__.config.read.ReadCTLS,crypto:"4",dukpt:{nb_data:this.__pinPad__.config.read.NB_Data,nb_ksn:this.__pinPad__.config.read.NB_ksn,tp_dukpt:"1"},pin:this.__pinPad__.config.read.PIN,posentrymode:this.__pinPad__.config.read.POSEM,tags:this.__pinPad__.config.read.Tags,type:this.__pinPad__.config.read.Type},currency:this.__pinPad__.config.currency.toUpperCase(),emv:this.__pinPad__.config.read.EMV,merchant:this.__pinPad__.operation.onlyMerchant,modelo_terminal:this.__pinPad__.about.model,reference:this.reference,serie:this.__pinPad__.about.serial,terminal:{display:"1",is_contactless:l,is_mobile:"0",printer:this.__pinPad__.about.printer},tp_operation:this.__pinPad__.operation.typeOperation,tp_resp:this.__pinPad__.operation.typeResponse,usrtransacction:this.username.toUpperCase(),version:this.__pinPad__.constants.appName+this.__pinPad__.constants.appVersion,version_terminal:this.__pinPad__.about.appVersion},geolocation:{latitude:this.__pinPad__.config.latitude,longitude:this.__pinPad__.config.longitude,ip:this.__pinPad__.config.publicIP}}});h.response==="error"&&(n.error=!0,n.message=h.nb_error||"Error in response");const f=o(this,p,Xr).call(this,h);return n.object=f,await o(this,p,Jr).call(this,f),n.approved=this.__pinPad__.operation.responseMit._approved,this.__pinPad__.operation.finalResult=f,n}catch(c){throw t.__pinPad__.finishCommand.A="01",t.__pinPad__.finishCommand.B="",t.__pinPad__.finishCommand.C="",t.__pinPad__.finishCommand.D="",t.__pinPad__.finishCommand.E="",t.__pinPad__.finishCommand.F="",t.__pinPad__.finishCommand.G="",t.__pinPad__.finishCommand.H="",t.__pinPad__.finishCommand.I="",t.__pinPad__.finishCommand.J="",t.__pinPad__.finishCommand.K="",await o(a=t,p,Qr).call(a,o(s=t,p,Bn).call(s,c)),c}},Jr=async function(t){if(this.__pinPad__.config.read.POSEM==="022"||this.__pinPad__.config.read.POSEM==="800"||this.__pinPad__.config.read.ReadCTLS==="1")return this.dispatch("pp:finish-emv",t),!0;const e=this.__pinPad__.constants.FS,n=this.__pinPad__.constants.STX,s=this.__pinPad__.constants.ETX;let a="C93A"+this.__pinPad__.finishCommand.A;a=a+e+"B"+this.__pinPad__.finishCommand.B,a=a+e+"C"+this.__pinPad__.finishCommand.C,a=a+e+"D"+this.__pinPad__.finishCommand.D,a=a+e+"E"+this.__pinPad__.finishCommand.E,a=a+e+"F"+this.__pinPad__.finishCommand.F,a=a+e+"G"+this.__pinPad__.finishCommand.G,a=a+e+"H"+this.__pinPad__.finishCommand.H,a=a+e+"I"+this.__pinPad__.finishCommand.I,a=a+e+"J"+this.__pinPad__.finishCommand.J,a=a+e+"K"+this.__pinPad__.finishCommand.K,a=n+o(this,p,mt).call(this,a)+a+s,a=a+o(this,p,yt).call(this,a);const c=this.parseStringToBytes(a,"");this.__pinPad__.waiting.statusSecondGenerateWaiting="pending",await this.appendToQueue(c,"second-generate");let l=0;const h=this;return new Promise((f,_)=>{l=setInterval(async()=>{var m,P;if(h.__pinPad__.waiting.statusSecondGenerateWaiting==="resolved"){if(clearInterval(l),h.__pinPad__.waiting.statusSecondGenerateWaiting=null,h.__pinPad__.operation.applyReverse){const v=await o(m=h,p,Qt).call(m,h.url+h.__pinPad__.constants.uris.reverse,{VMCAMEXMREVERSO:{business:{id_company:this.__pinPad__.config.idCompany.toUpperCase(),id_branch:this.__pinPad__.config.idBranch.toUpperCase(),country:this.__pinPad__.config.country.toUpperCase(),user:this.username.toUpperCase(),pwd:this.password.toUpperCase()},transacction:{amount:o(this,p,Ue).call(this,this.amount,2),no_operacion:this.__pinPad__.operation.folio,auth:this.__pinPad__.operation.authorization.toUpperCase(),tracks:"",usrtransacction:this.username.toUpperCase(),crypto:"2",version:this.__pinPad__.constants.appName+this.__pinPad__.constants.appVersion}}}),S=JSON.parse(v);let C;S.response==="approved"?C={message:"Transaction rejected by PinPad."}:C={message:"No communication, please check your report."},h.__pinPad__.operation.ignore.counterSale||(h.dispatch("pp:finish-emv",C),h.__pinPad__.operation.ignore.counterSale=!0)}else h.__pinPad__.operation.ignore.counterSale||(h.dispatch("pp:finish-emv",t),h.__pinPad__.operation.ignore.counterSale=!0);t.cd_error==="92"&&await o(P=h,p,$r).call(P,t,a),f(!0)}else h.__pinPad__.waiting.statusSecondGenerateWaiting==="rejected"&&(clearInterval(l),h.__pinPad__.waiting.statusSecondGenerateWaiting=null,_("There is no response from the reader, check that it is connected."))},500)})},$r=async function(t,e){this.__pinPad__.operation.ignore.responseGlobal=t,this.__pinPad__.operation.ignore.C93Global=e,this.__pinPad__.operation.ignore.isError92TRX=!0,await o(this,p,Le).call(this,1,0)},On=async function(){if(this.__pinPad__.operation.ignore.isError92TRX=!1,this.__pinPad__.config.read.POSEM==="022"||this.__pinPad__.config.read.POSEM==="800"||this.__pinPad__.config.read.ReadCTLS==="1")this.dispatch("pp:response",this.__pinPad__.operation.ignore.responseGlobal);else{const t=this.parseStringToBytes(this.__pinPad__.operation.ignore.C93Global,"");await this.appendToQueue(t,"code93"),await dt(1400),this.dispatch("pp:response",this.__pinPad__.operation.ignore.responseGlobal)}},Bn=function(t){const e={PPE02:"Importe Incorrecto.",A02:"Importe Incorrecto.",PPE03:"No hay respuesta del lector, verifique que se encuentra conectado.",A03:"No hay respuesta del lector, verifique que se encuentra conectado.",PP18:"Sin comunicación, por favor verifique su reporte.",PP24:"Transacción declinada por la PinPad.",A01:"Tarjeta Ilegible.",A04:"No hay planes de pago para esta tarjeta, por favor cambie la tarjeta.",A10:"Operación cancelada por el usuario.",A11:"Proceso cancelado por timeout.",A12:"Lectura errónea de banda/chip.",A13:"Carga de llave fallida.",A14:"Error de lectura de PIN.",A15:"Tarjeta Vencida.",A16:"Problemas al leer el chip.",A17:"Impresora sin Papel.",E17:"Impresora sin Papel.",A21:"Información no almacenada correctamente.",A22:"Tarjeta bloqueada.",A23:"Sin llave de cifrado DUKPT.",A28:"Fallback no soportado.",EE19:"Error de conexión, verifique su reporte.",EE21:"Ha ocurrido un error al procesar su solicitud.",EE22:"Ha ocurrido un error de conexión al servidor.",EE23:"El número de operación no puede ir vacío.",EE24:"El número de operación debe ser de 9 dígitos.",EE25:"El número de operación debe ser numérico.",EE26:"La información enviada al servicio está incompleta.",EE27:"La referencia contiene caracteres inválidos o está vacía.",EE28:"Número de autorización inválido.",EE29:"Importe inválido.",EE30:"La información enviada al servicio no es válida.",EE31:"No fue posible obtener las afiliaciones.",EE32:"Error de conexión, existe una o más transacciones en el servidor , Favor de validar su reporte y en su caso reimprimir el voucher.",EE33:"Error de comunicacion con CDP. IL/MTY",EE20:"La Referencia contiene caracteres inválidos",EE99:"Error código 99."};let n=e[t]?{error:t,message:e[t]}:{error:t,message:"Error desconocido"};return this.dispatch("pp:error",n),n},Qr=async function(t){const e=this.__pinPad__.constants.FS,n=this.__pinPad__.constants.STX,s=this.__pinPad__.constants.ETX;let a="C93A"+this.__pinPad__.finishCommand.A;if(a=a+e+"B"+this.__pinPad__.finishCommand.B,a=a+e+"C"+this.__pinPad__.finishCommand.C,a=a+e+"D"+this.__pinPad__.finishCommand.D,a=a+e+"E"+this.__pinPad__.finishCommand.E,a=a+e+"F"+this.__pinPad__.finishCommand.F,a=a+e+"G"+this.__pinPad__.finishCommand.G,a=a+e+"H"+this.__pinPad__.finishCommand.H,a=a+e+"I"+this.__pinPad__.finishCommand.I,a=a+e+"J"+this.__pinPad__.finishCommand.J,a=a+e+"K"+this.__pinPad__.finishCommand.K,a=n+o(this,p,mt).call(this,a)+a+s,a=a+o(this,p,yt).call(this,a),this.__pinPad__.config.read.POSEM==="022"||this.__pinPad__.config.read.POSEM==="800"||this.__pinPad__.config.read.ReadCTLS==="1"){this.dispatch("pp:finish-emv",t);return}const c=this.parseStringToBytes(a,"");await this.appendToQueue(c,"finish-emv-end")},Zr=async function(t){if(t.cd_estatus=t.cd_estatus?t.cd_estatus:"0",t.cd_estatus!=="1"){this.__pinPad__.operation.ignore.isError92TRX&&await o(this,p,On).call(this);return}const e=this.__pinPad__.constants.FS,n=this.__pinPad__.constants.ETX,s=this.__pinPad__.constants.STX,a=t.nb_ksn,c=t.nb_kcv||"",l=t.nb_ipek||"";let h="C92A"+a+e+"B"+c+e+"C"+l;h=s+o(this,p,mt).call(this,h)+h+n,h=h+o(this,p,yt).call(this,h);const f=this.parseStringToBytes(h,"");await this.appendToQueue(f,"dukpt");let _=0;this.__pinPad__.waiting.statuswritingDUKPTWaiting="pending";const m=this;return new Promise((P,v)=>{_=setInterval(async()=>{var S;m.__pinPad__.waiting.statuswritingDUKPTWaiting==="resolved"?(clearInterval(_),m.__pinPad__.waiting.statuswritingDUKPTWaiting=null,this.__pinPad__.operation.ignore.isError92TRX&&await o(S=m,p,On).call(S),P(!0)):m.__pinPad__.waiting.statuswritingDUKPTWaiting==="rejected"&&(clearInterval(_),m.__pinPad__.waiting.statuswritingDUKPTWaiting=null,v("Error writing DUKPT keys"))},500)})},Yr=function(){this.__pinPad__.config.read.AppId="",this.__pinPad__.config.read.AppIdLabel="",this.__pinPad__.config.read.Arqc="",this.__pinPad__.config.read.ChipName="",this.__pinPad__.config.read.ReadCTLS="",this.__pinPad__.config.read.NB_Data="",this.__pinPad__.config.read.NB_ksn="",this.__pinPad__.config.read.PIN="",this.__pinPad__.config.read.POSEM="",this.__pinPad__.config.read.Tags="",this.__pinPad__.config.read.Type="",this.__pinPad__.config.read.Chip="",this.__pinPad__.config.read.ChipNameEnc="",this.__pinPad__.operation.ignore.error="",this.__pinPad__.operation.ignore.C93Global="",this.__pinPad__.operation.folio="",this.__pinPad__.operation.authorization="",this.__pinPad__.config.tokenizeTRX=!1};class pc extends kt{constructor({filters:t=null,config_port:e=null,no_device:n=1,device_listen_on_port:s=1,type:a="esplus",support_cart:c=!0}={}){super({filters:t,config_port:e,no_device:n,device_listen_on_port:s});$(this,g);Z(this,"__device",{type:"esplus",support_cart:!1,withdraw:{in_process:!1,seconds:60,interval:0},cart:{in_process:!1},channels:{verification:{clear(){this.running=!1,this.current=1,this.channels=[]},running:!1,start:1,end:80,current:1,channels:[]}}});if(this.__internal__.device.type="jofemar",K.getCustom(this.typeDevice,n))throw new Error(`Device ${this.typeDevice} ${n} already exists`);this.__internal__.dispense.must_response=!0,this.__internal__.time.response_general=800,this.__internal__.time.response_engines=800,this.__internal__.dispense.limit_counter=40,this.__internal__.dispense.timeout=0,this.__internal__.dispense.timeout_time=4e3,this.__internal__.dispense.interval=0,this.__internal__.dispense.interval_time=1e3,this.__internal__.device.hex_number=(128+this.listenOnPort).toString(16),this.__internal__.device.door_open=!1,this.__internal__.dispense.elevator={locking_time:60,locking_interval:0,need_reset:!1},this.deviceType=a,this.supportCart=c,o(this,g,ts).call(this),o(this,g,ns).call(this),o(this,g,es).call(this)}set startChannelVerification(t){const e=parseInt(t);if(isNaN(e))throw new Error("Invalid start channel verification, must be a number");if(e<1||e>126)throw new Error("Invalid start channel verification, valid range is 1 to 126");this.__device.channels.verification.start=e}set endChannelVerification(t){const e=parseInt(t);if(isNaN(e))throw new Error("Invalid end channel verification, must be a number");if(e<1||e>126)throw new Error("Invalid end channel verification, valid range is 1 to 126");this.__device.channels.verification.end=e}set listenOnPort(t){if(t=parseInt(t),isNaN(t)||t<1||t>31)throw new Error("Invalid port number, valid range is 1 to 31");this.__internal__.device.listen_on_port=t,this.__internal__.serial.bytes_connection=this.serialSetConnectionConstant(t),this.__internal__.device.hex_number=(128+t).toString(16)}set deviceType(t){if(typeof t!="string")throw new Error("Invalid device type, must be a string");this.__device.type=t}set supportCart(t){if(typeof t!="boolean")throw new Error("Invalid support cart, must be a boolean");this.__device.support_cart=t}get listenOnPort(){return this.__internal__.device.listen_on_port??1}serialJofemarMakeBytes(t){let e=this.hexToDec(this.sumHex(t)),n=this.calcCheckSums(e.toString());for(let s=0;s<2;s++)t.push(this.hexMaker(n[s]));return t.push("03"),this.add0x(t)}calcCheckSums(t){t=this.add0x([this.decToHex(parseInt(t).toString())]);let e=[];return e.push((t&255|240).toString(16).toUpperCase()),e.push((t&255|15).toString(16).toUpperCase()),e}serialSetConnectionConstant(t=1){let e=["02","30","30",(128+t).toString(16),"53","FF","FF"],n=[];return e.forEach(s=>{n.push(this.hexMaker(s))}),this.serialJofemarMakeBytes(n)}serialMessage(t){let n={code:t,name:null,description:null,request:"unknown",no_code:0,additional:{machine:{hex:null,dec:null}}};switch(t[0]){case"02":n=o(this,g,xs).call(this,t,n,128);break;case"06":n=o(this,g,As).call(this,t,n);break;case"15":n.name="Checksum error",n.description="The calculated checksum does not match the received checksum",n.no_code=38,o(this,g,Y).call(this);break;default:n.name="unknown",n.description="The message received is unknown",n.no_code=404;break}this.dispatch("serial:message",n)}productRemovedContinueDispensing(){this.__internal__.dispense.elevator.locking_interval&&(this.__internal__.dispense.elevator.locking_time=0)}async dispense({selection:t=1,cart:e=!1}={}){if(t=parseInt(t),isNaN(t)||t<1||t>130)throw new Error("Invalid selection");const{channel:n,tray:s}=o(this,g,Ds).call(this,t);this.__internal__.dispense.backup_dispense={selection:t,cart:e,channel:n,tray:s};let c=["02","30","30",this.__internal__.device.hex_number,"56",s,n];e&&(c[4]="4D"),c=o(this,g,Ve).call(this,c);let l;do l=await this.internalDispense(c),o(this,g,Rs).call(this),l.error==="elevator-locked"?await o(this,g,is).call(this):l.error==="no-response"&&await dt(1e3);while(["elevator-locked","no-response"].includes(l.error));return this.__internal__.dispense.backup_dispense={},l}internalClearSensing(){super.internalClearSensing(),this.__internal__.dispense.timeout&&clearTimeout(this.__internal__.dispense.timeout),this.__internal__.dispense.interval&&clearInterval(this.__internal__.dispense.interval),this.__internal__.serial.queue.length>0&&(this.__internal__.serial.queue=this.__internal__.serial.queue.filter(t=>t.type!=="status"))}async endDispense(){let e=["02","30","30",this.__internal__.device.hex_number,"4D","80","80"];return e=o(this,g,Ve).call(this,e),await this.internalDispense(e)}async collect(){const t=["02","30","30","81","4E","FF","FF"];return await o(this,g,ot).call(this,t,"collect")}async resetSoldOutErrors(){return await o(this,g,ue).call(this,"80")}async resetWaitingProductRemovedError(){return await o(this,g,ue).call(this,"81")}async resetMachineErrors(){return this.__internal__.serial.queue.length===0?(o(this,g,Nn).call(this),await o(this,g,ue).call(this,"FF")):new Promise(t=>{const e=setInterval(async()=>{this.__internal__.serial.queue.length>0||(clearInterval(e),await o(this,g,ue).call(this,"FF"),o(this,g,Nn).call(this),t(!0))},100)})}async resetAllErrors(){return await this.resetSoldOutErrors(),await dt(100),await this.resetWaitingProductRemovedError(),await dt(100),await this.resetMachineErrors()}async status(){const t=["02","30","30","81","53","FF","FF"];return await o(this,g,ot).call(this,t,"status")}async lightsOn(){return await o(this,g,Mn).call(this,"81")}async lightsOff(){return await o(this,g,Mn).call(this,"80")}async program(t,e){const n=["02","30","30","81","50",t,e];return await o(this,g,ot).call(this,n,"program")}async programDisplayLanguage({language:t="spanish"}={}){const e={spanish:"30",english:"31",french:"32"};if(!e[t])throw new Error("Invalid language");return await this.program("49",e[t])}async programBeeper({enable:t=!0}={}){const e=t?"31":"30";return await this.program("5A",e)}async programDisableWorkingTemperature(){if(this.__device.type==="iceplus")throw new Error("IcePlus does not support disable working temperature");return await this.program("54","80")}async programDisableThermometer(){return await this.programDisableWorkingTemperature()}async programWorkingTemperature({degrees:t=.5}={}){t=parseFloat(t);const e=this.__device.type==="iceplus"?6.5:32,n=this.__device.type==="iceplus"?-25:.5;if(isNaN(t)||t<n||t>e||t%.5!==0)throw new Error("Invalid degrees, must be a multiple of 0.5 and between 0.5 and 32");let s=t*2+128;return this.__device.type==="iceplus"&&(s+=51),s=Math.ceil(s),await this.program("54",s.toString(16))}async programIsolationTray({tray:t=0}={}){if(t=parseInt(t),isNaN(t)||t<0||t>12)throw new Error("Invalid tray, valid range is 0 to 12");const e=t===0?"80":(t+139).toString(16);return this.program("42",e)}async programTimeToStandbyAfterCollect({seconds:t=15}={}){if(t=parseInt(t),isNaN(t)||t<15||t>120)throw new Error("Invalid seconds, valid range is 15 to 120");const e=(128+t).toString(16);return await this.program("46",e)}async programTimeToStandbyWithoutCollect({minutes:t=1}={}){if(t=parseInt(t),isNaN(t)||t<1||t>10)throw new Error("Invalid minutes, valid range is 1 to 10");const e=(128+t).toString(16);return await this.program("48",e)}async programElevatorSpeed({speed:t="high"}={}){const e={high:"31",low:"30"};if(!e[t])throw new Error("Invalid speed, valid speeds are 'high' and 'low'");return await this.program("76",e[t])}async programTemperatureExpiration({enable:t=!1}={}){const e=t?"31":"30";return await this.program("63",e)}async programEnableTemperatureExpiration(){return await this.programTemperatureExpiration({enable:!0})}async programDisableTemperatureExpiration(){return await this.programTemperatureExpiration({enable:!1})}async programMachineAddress({address:t=1}={}){if(t=parseInt(t),isNaN(t)||t<1||t>31)throw new Error("Invalid address, valid range is 1 to 31");const e=(128+t).toString(16);return await this.program("64",e)}async programTemperatureBeforeExpiration({degrees:t=.5}={}){if(t=parseFloat(t),isNaN(t)||t<.5||t>30||t%.5!==0)throw new Error("Invalid degrees, must be a multiple of 0.5 and valid range is 0.5 to 30");const e=(128+t*2).toString(16);return await this.program("65",e)}async programTimeBeforeExpirationByTemperature({minutes:t=1}={}){if(t=parseInt(t),isNaN(t)||t<1||t>120)throw new Error("Invalid minutes, valid range is 1 to 120");const e=(128+t).toString(16);return await this.program("66",e)}async programTemperatureScale({scale:t="c"}={}){const e={c:"43",f:"46"};if(!e[t])throw new Error("Invalid scale, valid scales are 'c' for celsius and 'f' for fahrenheit");return await this.program("67",e[t])}async programVoltageEngine({selection:t=1,voltage:e=5}={}){if(e=parseFloat(e),t=parseInt(t),isNaN(t)||t<1||t>this.__device.channels.verification.end)throw new Error(`Invalid selection, valid range is 1 to ${this.__device.channels.verification.end}`);if(isNaN(e)||e<5||e>9.5||e%.5!==0)throw new Error("Invalid voltage, valid range is 5 to 9.5");const n=109+t,a=(128+(e-5)*2).toString(16),c=["02","30","30","81","47",n,a];return await o(this,g,ot).call(this,c,"voltage-engine")}async programPushOverProducts({selection:t=1,enable:e=!0}={}){if(t=parseInt(t),isNaN(t)||t<1||t>this.__device.channels.verification.end)throw new Error(`Invalid selection, valid range is 1 to ${this.__device.channels.verification.end}`);const a=["02","30","30","81","4F",109+t,e?"31":"30"];return await o(this,g,ot).call(this,a,"push-over-products")}async programChannelRunningAfterDispense({selection:t=1,seconds:e=0}={}){if(t=parseInt(t),e=parseFloat(e),isNaN(t)||t<1||t>this.__device.channels.verification.end)throw new Error(`Invalid selection, valid range is 1 to ${this.__device.channels.verification.end}`);if(isNaN(e)||e<0||e>10||e%.1!==0)throw new Error("Invalid seconds, valid range is 0.0 to 10.0 with a step of 0.1");const n=109+t;e=e.toFixed(1);const s=128+e*10,a=["02","30","30","81","45",n,s];return await o(this,g,ot).call(this,a,"channel-running-after-dispense")}async checkData(t,e="FF"){const n=["02","30","30","81","43",t,e];return await o(this,g,ot).call(this,n,"check-data")}async getDisplayLanguage(){return await this.checkData("49")}async getBeeper(){return await this.checkData("5A")}async getWorkingTemperature(){return await this.checkData("54")}async getIsolationTray(){return await this.checkData("42")}async getProgramVersion(){return await this.checkData("50")}async getFaults(){return await this.checkData("53")}async getMachineId(){return await this.checkData("4E")}async getCurrentTemperature(){return await this.checkData("74")}async getTimeToStandbyAfterCollect(){return await this.checkData("46")}async getTimeToStandbyWithoutCollect(){return await this.checkData("48")}async getElevatorSpeed(){return await this.checkData("76")}async getTemperatureExpiration(){return await this.checkData("63")}async getTemperatureBeforeExpiration(){return await this.checkData("65")}async getTimeBeforeExpirationByTemperature(){return await this.checkData("66")}async getTemperatureScale(){return await this.checkData("67")}async getClockRegisters(){return await this.checkData("72")}async getMachineActivity(){return await this.checkData("41")}async getVoltageEngine({selection:t=1}={}){if(t=parseInt(t),isNaN(t)||t<1||t>126)throw new Error("Invalid selection, valid range is 1 to 126");const e=(109+t).toString(16);return await this.checkData("47",e)}async getChannelPresence({selection:t=1}={}){if(t=parseInt(t),isNaN(t)||t<1||t>126)throw new Error("Invalid selection, valid range is 1 to 126");const e=(109+t).toString(16);return await this.checkData("43",e)}async getPushOverProducts({selection:t=1}={}){if(t=parseInt(t),isNaN(t)||t<1||t>126)throw new Error("Invalid selection, valid range is 1 to 126");const e=(109+t).toString(16);return await this.checkData("4F",e)}async getChannelRunningAfterDispense({selection:t=1}={}){if(t=parseInt(t),isNaN(t)||t<1||t>126)throw new Error("Invalid selection, valid range is 1 to 126");const e=(109+t).toString(16);return await this.checkData("45",e)}async setDisplayStandbyMessage({message:t=""}={}){t=t.substring(0,32);const e=o(this,g,He).call(this,t);return await o(this,g,je).call(this,"80",e)}async setDisplayMessageTemporarily({message:t="",seconds:e=1}){if(t=t.substring(0,32),e=parseInt(e),isNaN(e)||e<1||e>125)throw new Error("Invalid seconds, valid range is 1 to 125");const n=o(this,g,He).call(this,t),s=(128+e).toString(16);return await o(this,g,je).call(this,s,n)}async setDisplayMessageUnlimited({message:t=""}){t=t.substring(0,32);const e=o(this,g,He).call(this,t);return await o(this,g,je).call(this,"FF",e)}async programClock({date:t=new Date}={}){if(!(t instanceof Date))throw new Error("Invalid date, must be an instance of Date");const e=["02","30","30","81","72",...o(this,g,Os).call(this,t)];return await o(this,g,ot).call(this,e,"clock")}async eventsConfig({event:t=null,enable:e=!0}={}){if(t===null)throw new Error("Invalid event");const s=["02","30","30","81","41",t,e?"31":"30"];return await o(this,g,ot).call(this,s,"events-config")}async eventEnable({event:t=null}={}){if(t===null)throw new Error("Invalid event");const e=parseInt(t,16);if(isNaN(e)||e<38||e>100)throw new Error("Invalid event");return await this.eventsConfig({event:t,enable:!0})}async eventDisable({event:t=null}={}){if(t===null)throw new Error("Invalid event");const e=parseInt(t,16);if(isNaN(e)||e<38||e>100)throw new Error("Invalid event");return await this.eventsConfig({event:t,enable:!1})}async sendCustomCode({code:t=[]}={}){if(t.length<5)throw new Error("Invalid code, minimum length is 5");return await o(this,g,ot).call(this,t,"custom")}async assignChannels(){const t=this.__device.channels.verification.start,e=this.__device.channels.verification.end;if(t>e)throw new Error("Invalid range, start must be less than end");this.__device.channels.verification.clear(),this.__device.channels.verification.running=!0;for(let n=t;n<=e;n++)this.__device.channels.verification.current=n,await this.getChannelPresence({selection:n});return new Promise(n=>{let s=setInterval(()=>{this.__device.channels.verification.channels.length===e-t+1&&(clearInterval(s),this.dispatch("channels",{channels:this.__device.channels.verification.channels}),this.__device.channels.verification.clear(),n(!0))},500)})}}g=new WeakSet,ts=function(){const t=["dispensing:withdrawal","command-executed","keyboard:pressed","door:event","program:version","machine:faults","clock:registers","machine:activity","check:language","check:beeper","check:isolation-tray","check:engine-voltage","check:push-over","check:extractor-after-dispense","check:standby-after-collect","check:standby-without-collect","check:elevator-speed","check:expiration-by-temperature","check:temperature-before-expiration","check:expiration-after","check:temperature-scale","check:machine-id","temperature:working","temperature:current","jofemar:warning","jofemar:error","serial:message","reset:errors","channels","channel:status","machine:status"];for(const e of t)this.serialRegisterAvailableListener(e)},es=function(){this.on("internal:dispense:running",o(this,g,Is).bind(this))},ns=function(){K.add(this)},ot=function(t,e){return t[3]=this.__internal__.device.hex_number,this.appendToQueue(o(this,g,Ve).call(this,t),e)},Ve=function(t){let e=this.hexToDec(this.sumHex(t)),n=this.calcCheckSums(e.toString());for(let s=0;s<2;s++)t.push(this.hexMaker(n[s]));return t.push("03"),t},is=async function(){if(this.__internal__.dispense.elevator.locking_interval)return;this.__internal__.dispense.elevator.need_reset&&(this.__internal__.dispense.elevator.need_reset=!1,await this.resetWaitingProductRemovedError(),await dt(500));const t=this;return this.__internal__.dispense.status="elevator-locked",this.__internal__.dispense.elevator.locking_time=60,new Promise(e=>{t.__internal__.dispense.elevator.locking_interval=setInterval(()=>{t.dispatch("dispensing:withdrawal",{elevator:!0,seconds:t.__internal__.dispense.elevator.locking_time,description:"Please recall products from the elevator"}),t.__internal__.dispense.elevator.locking_time-=1,t.__internal__.dispense.elevator.locking_time<=0&&(clearInterval(t.__internal__.dispense.elevator.locking_interval),t.__internal__.dispense.elevator.locking_interval=0,e(!0))},1e3)})},rs=function(t,e){return e.name="ok",e.description="The last command was executed successfully",e.no_code=1,this.dispatch("command-executed",e),e},ss=function(t,e){e.additional={hex:t,dec:this.hexToDec(t),ascii:null};const n={30:"0",31:"1",32:"2",33:"3",34:"4",35:"5",36:"6",37:"7",38:"8",39:"9","2a":"*",23:"#",41:"A",42:"B",43:"C",44:"D"};return e.additional.ascii=n[t]??null,e.name="Key pressed",e.description=`The key ${e.additional.ascii} was pressed`,e.no_code=2,this.dispatch("keyboard:pressed",e.additional),e},as=function(t,e){return e.additional={open:!1},e.no_code=3,t==="4f"?(e.name="door open",e.description="The door was opened",e.additional.open=!0,this.__internal__.device.door_open=!0,this.dispatch("door:event",e.additional)):t==="43"?(e.name="door close",e.description="The door was closed",e.additional.open=!1,this.__internal__.device.door_open=!1,this.dispatch("door:event",e.additional)):(e.name="door event",e.description="The door event received is unknown",this.dispatch("door:event",{open:e.additional.open,message:e})),e},os=function(t,e){e.no_code=404;let n=t[5]??null;return n&&this.listenOnPort>1&&(n=this.hexToDec(n)-this.listenOnPort+1,n=this.decToHex(n)),n&&(n==="FD"?(e.no_code=4,e.name="channel disconnected",e.description="The channel is disconnected",e.additional={active:!1}):n==="FC"?(e.no_code=5,e.name="channel connected",e.description="The channel is connected",e.additional={active:!0}):(e.no_code=6,e.name="channel sold out",e.description="The channel is empty",e.additional={active:!0}),this.__device.channels.verification.running&&(this.__device.channels.verification.channels.push({selection:this.__device.channels.verification.current,active:e.additional.active}),e.additional.selection=this.__device.channels.verification.current),this.dispatch("channel:status",e.additional)),e},cs=function(t,e){e.no_code=39,e.name="Program version";const n=t.slice(4,12),s=n.map(a=>String.fromCharCode(this.hexToDec(a))).join("");return e.additional={version:s,hex:n},e.description=`The program version is ${s}`,this.dispatch("program:version",e.additional),e},ls=function(t,e){e.no_code=39,e.name="Machine faults",e.description="No faults detected",e.additional={no_faults:0,faults:[]};const n=t.slice(4,-3);if(n.length>1&&n[0]!=="30"){e.description="Machine has faults";const s={31:"Busy",32:"Invalid tray",33:"Invalid channel",34:"Empty channel",35:"Jam in elevator engine",36:"Malfunction in the elevator belt or product detector",37:"Failure in one of the photo transistors in the cabinet",38:"No channels detected",39:"Product detector fault",41:"Machine display is disconnected",42:"Product alarm under elevator",43:"Error when elevator approaching to a position",44:"Fault in keyboard",45:"Eeprom writing error",46:"Fault communicating with temperature control",47:"The thermometer is disconnected",48:"Thermometer programming lost",49:"Thermometer faulty","4a":"Channels power consumption detector faulty","4b":"Elevator does not find channel or tray","4c":"Elevator does not find delivery product position","4d":"Interior of elevator blocked","4e":"Error in tester of product detector","4f":"Waiting for product to be removed",50:"Product expired by temperature reasons",51:"Automatic door faulty",59:"Product is expired","5a":"Product is expired",61:"Product is expired",62:"Product is expired",63:"Product is expired",64:"Product detector didn't change during its verification test"};for(const a of n)s[a]&&(e.additional.faults.push(s[a]),e.additional.no_faults++)}return this.dispatch("machine:faults",e.additional),e},hs=function(t,e){e.no_code=40,e.name="Clock registers",e.description="Clock registers";const n=t.slice(4,-3),s=n.map(v=>String.fromCharCode(this.hexToDec(v))).join(""),[a,c]=s.split(" "),[l,h]=a.split(":"),[f,_,m]=c.split("-"),P=new Date(2e3+parseInt(m),parseInt(_)-1,parseInt(f),parseInt(l),parseInt(h));return e.additional={day:f,month:_,year:m,hours:l,minutes:h,formatted:s,date:P,hex:n},this.dispatch("clock:registers",e.additional),e},us=function(t,e){e.no_code=41,e.name="Machine activity",e.description="Events from read machine activity";const n=String.fromCharCode(this.hexToDec(t[4]));if(n!=="0"){const s=t.slice(5,-3);if(n==="T"&&s.length===4){const a=String.fromCharCode(this.hexToDec(s[0])),c=String.fromCharCode(this.hexToDec(s[1])),l=String.fromCharCode(this.hexToDec(s[3]));e.additional={ascii:n,type:"DU.d",dozens:a,units:c,decimals:l,time:parseFloat(`${a}${c}.${l}`),meaning:"Extraction time (in seconds)"}}else if(["B","D","E","F","G"].includes(n)&&s.length===3){const a=String.fromCharCode(this.hexToDec(s[0])),c=String.fromCharCode(this.hexToDec(s[1])),l=String.fromCharCode(this.hexToDec(s[2])),h=parseInt(`${a}${c}${l}`),f={B:"Error on going to tray channel",D:"Error on product detector",E:"Extraction of channel ok",F:"Error on engine intensity detection",G:"Error on product exit door"};e.additional={type:"HDU",hundreds:a,dozens:c,decimals:l,channel:h,selection:h-109,ascii:n,meaning:f[n]??"Unknown"}}else if(s.length===13){const a=s.map(S=>String.fromCharCode(this.hexToDec(S))).join(""),c=parseInt(a.slice(0,2)),l=parseInt(a.slice(2,4)),h=parseInt(a.slice(4,6)),f=parseInt(a.slice(7,9)),_=parseInt(a.slice(9,11))-1,m=2e3+parseInt(a.slice(11,13)),P=new Date(m,_,f,c,l,h),v={A:"Attempt to close product exit door",C:"Closing of exterior door",H:"Error on opening of product exit door",I:"New attempt to arrive at product exit position after an error on first attempt",J:"Power on cooling unit",K:"Power off cooling unit",L:"Start of defrosting",M:"End of defrosting",O:"Opening of exterior door",R:"Memory reset",S:"Error on going to product exit position",Y:"Power on machine",Z:"Power off machine",c:"Closing of inner door",e:"New attempt to extract from channel due no product detection when elevator arrived to product exit position",o:"Opening of inner door"};e.additional={type:"hhmmssWddMMAA",date:P,hex:s,formatted:P.toLocaleString(),ascii:n,meaning:v[n]??"Unknown"}}}return this.dispatch("machine:activity",e.additional),e},ds=function(t,e){const n={30:"Spanish",31:"English",32:"French"};return e.no_code=42,e.name="Language",e.description=`The language is ${n[t]??"unknown"}`,e.additional={hex:t,language:n[t]??"unknown"},this.dispatch("check:language",e.additional),e},ps=function(t,e){return e.no_code=43,e.name="Beeper",e.description=`The beeper is ${t==="30"?"on":"off"}`,e.additional={hex:t,beeper:t==="30"},this.dispatch("check:beeper",e.additional),e},fs=function(t,e){e.no_code=44,e.name="Isolation tray",e.description="Isolation tray";const n=this.hexToDec(t)-139;return e.additional={hex:t,tray:n},this.dispatch("check:isolation-tray",e.additional),e},_s=function(t,e){e.no_code=45,e.name="Engine voltage",e.description="Engine voltage";const n=(this.hexToDec(t)-128)/2+5;return e.additional={hex:t,voltage:n},this.dispatch("check:engine-voltage",e.additional),e},gs=function(t,e){e.no_code=46,e.name="Push over",e.description="Push over";const n=t==="30";return e.additional={hex:t,push:n},this.dispatch("check:push-over",e.additional),e},bs=function(t,e){e.no_code=47,e.name="Extractor after dispense",e.description="Extractor after dispense";const n=(this.hexToDec(t)-128)/10;return e.additional={hex:t,seconds:n},this.dispatch("check:extractor-after-dispense",e.additional),e},ms=function(t,e){e.no_code=48,e.name="Standby after collect",e.description="Time to standby after collect product";const n=this.hexToDec(t)-128;return e.additional={hex:t,seconds:n},this.dispatch("check:standby-after-collect",e.additional),e},ys=function(t,e){e.no_code=49,e.name="Standby without collect",e.description="Time to standby when product delivery is not collected";const n=this.hexToDec(t)-128;return e.additional={hex:t,minutes:n},this.dispatch("check:standby-without-collect",e.additional),e},ws=function(t,e){e.no_code=50,e.name="Elevator speed",e.description="Elevator speed";const n=t==="30"?"low":"high";return e.additional={hex:t,speed:n},this.dispatch("check:elevator-speed",e.additional),e},vs=function(t,e){e.no_code=51,e.name="Temperature expiration",e.description="Temperature expiration";const n=t==="31";return e.additional={hex:t,enabled:n},this.dispatch("check:expiration-by-temperature",e.additional),e},Ps=function(t,e){e.no_code=52,e.name="Temperature before expiration",e.description="Temperature before expiration";const n=(this.hexToDec(t)-128)/2;return e.additional={hex:t,temperature:n},this.dispatch("check:temperature-before-expiration",e.additional),e},Es=function(t,e){e.no_code=53,e.name="Time before expiration",e.description="Time before expiration";const n=this.hexToDec(t)-128;return e.additional={hex:t,minutes:n},this.dispatch("check:expiration-after",e.additional),e},Ts=function(t,e){e.no_code=54,e.name="Temperature scale",e.description="Temperature scale";const n=t==="43"?"Celsius":"Fahrenheit";return e.additional={hex:t,scale:n},this.dispatch("check:temperature-scale",e.additional),e},Cs=function(t,e){return e.no_code=54,e.name="Machine ID",e.description="Machine ID",e.additional={hex:t[4],full_hex:t},this.dispatch("check:machine-id",e.additional),e},Ss=function(t,e){return e.no_code=7,e.name="working temperature",e.description=`The working temperature is ${t}`,e.additional={hex:t,temperature:{traditional:(this.hexToDec(t)-this.hexToDec("80"))/2,ice_plus:(this.hexToDec(t)-this.hexToDec("80"))/2-25.5}},this.dispatch("temperature:working",e.additional),e},ks=function(t,e){return e.no_code=8,e.name="current temperature",e.additional={sign:null,tens:null,units:null,decimals:null,type_degrees:null,formatted:null,decimal_point:t[7]==="2e"?".":null,degrees:t[9]==="7f"?"°":null,error:null},t[4]==="2b"?e.additional.sign=t[4]="+":["2e","2d"].includes(t[4])?e.additional.sign=t[4]="-":t[4]==="20"&&(e.additional.error="Error in thermometer"),this.hexToDec(t[5])>=48&&this.hexToDec(t[5])<=57?e.additional.tens=this.hexToDec(t[5])-48:t[5]==="2a"&&(e.additional.error="Error in thermometer"),this.hexToDec(t[6])>=48&&this.hexToDec(t[6])<=57?e.additional.units=this.hexToDec(t[6])-48:t[6]==="2a"&&(e.additional.error="Error in thermometer"),this.hexToDec(t[8])>=48&&this.hexToDec(t[8])<=57?e.additional.decimals=this.hexToDec(t[8])-48:t[8]==="2a"&&(e.additional.error="Error in thermometer"),t[10]==="43"?e.additional.type_degrees="C":t[10]==="46"&&(e.additional.type_degrees="F"),e.additional.error==="Error in thermometer"?(e.additional.formatted="Error in thermometer",e.description="The current temperature cannot be read because there is an error in the thermometer"):(e.additional.formatted=(e.additional.sign??"")+(e.additional.tens??"")+(e.additional.units??"")+(e.additional.decimal_point??"")+(e.additional.decimals??"")+(e.additional.degrees??"")+(e.additional.type_degrees??""),e.description=`The current temperature is ${e.additional.formatted}`),this.dispatch("temperature:current",e.additional),e},xs=function(t,e,n=128){if(t[1]&&(e.additional.machine.hex=t[1],e.additional.machine.dec=this.hexToDec(t[1])-n),!(t[1]&&t[2]))e=o(this,g,rs).call(this,t,e);else switch(t[2]){case"54":e.request="--automatic",e=o(this,g,ss).call(this,t[3],e);break;case"50":e.request="--automatic",e=o(this,g,as).call(this,t[3],e);break;case"43":switch(e.request="check-data",t[3]){case"41":e=o(this,g,us).call(this,t,e);break;case"43":e.request="channel-status",e=o(this,g,os).call(this,t,e);break;case"50":e=o(this,g,cs).call(this,t,e);break;case"53":e=o(this,g,ls).call(this,t,e);break;case"54":e.request="working-temperature",e=o(this,g,Ss).call(this,t[4],e);break;case"72":e=o(this,g,hs).call(this,t,e);break;case"74":e.request="current-temperature",e=o(this,g,ks).call(this,t,e);break;case"49":e=o(this,g,ds).call(this,t[4],e);break;case"5a":e=o(this,g,ps).call(this,t[4],e);break;case"42":e=o(this,g,fs).call(this,t[4],e);break;case"47":e=o(this,g,_s).call(this,t[4],e);break;case"4e":e=o(this,g,Cs).call(this,t,e);break;case"4f":e=o(this,g,gs).call(this,t[4],e);break;case"45":e=o(this,g,bs).call(this,t[4],e);break;case"46":e=o(this,g,ms).call(this,t[4],e);break;case"48":e=o(this,g,ys).call(this,t[4],e);break;case"76":e=o(this,g,ws).call(this,t[4],e);break;case"63":e=o(this,g,vs).call(this,t[4],e);break;case"65":e=o(this,g,Ps).call(this,t[4],e);break;case"66":e=o(this,g,Es).call(this,t[4],e);break;case"67":e=o(this,g,Ts).call(this,t[4],e);break}break}return e},ft=function(){this.__internal__.dispense.dispensing&&(this.__internal__.dispense.status=!0)},Y=function(){this.__internal__.dispense.dispensing&&(this.__internal__.dispense.status=!1)},qe=function(){this.__internal__.dispense.dispensing&&(this.__internal__.dispense.status="elevator-locked")},tt=function({type:t=null,severity:e="low"}={}){this.dispatch("jofemar:warning",{type:t,severity:e})},wt=function({type:t=null,severity:e="high"}={}){this.dispatch("jofemar:error",{type:t,severity:e})},As=function(t,e){if(e.request="status",t[1]&&!t[2]){switch(t[1]){case"30":e.name="Machine ready",e.description="The machine is ready for instructions",e.no_code=9,o(this,g,ft).call(this);break;case"31":e.name="Machine busy",e.description="The machine is busy right now",e.no_code=10;break;case"32":e.name="Invalid tray",e.description="The tray requested is invalid",e.no_code=11,o(this,g,Y).call(this),o(this,g,tt).call(this,{type:"invalid-tray"});break;case"33":e.name="Invalid channel",e.description="The channel requested is invalid",e.no_code=12,o(this,g,Y).call(this),o(this,g,tt).call(this,{type:"invalid-channel"});break;case"34":e.name="Empty channel",e.description="The channel requested is empty",e.no_code=13,o(this,g,Y).call(this),o(this,g,tt).call(this,{type:"empty-channel"});break;case"35":e.name="Jam",e.description="Jam in elevator engine",e.no_code=14,o(this,g,Y).call(this),o(this,g,wt).call(this,{type:"jam"});break;case"36":e.name="Malfunction",e.description="Malfunction in the elevator belt or product detector",e.no_code=15,o(this,g,Y).call(this),o(this,g,wt).call(this,{type:"malfunction"});break;case"37":e.name="Photo transistors",e.description="Failure in one of the photo transistors in the cabinet",e.no_code=16,o(this,g,Y).call(this),o(this,g,wt).call(this,{type:"photo-transistors"});break;case"38":e.name="Without channels",e.description="No channels detected",e.no_code=17,o(this,g,Y).call(this),o(this,g,wt).call(this,{type:"without-channels"});break;case"39":e.name="Product detector fault",e.description="Product detector fault",e.no_code=18,o(this,g,qe).call(this),o(this,g,tt).call(this,{type:"fault-product-detector"});break;case"41":e.name="Fault in 485 BUS",e.description="Machine display is disconnected",e.no_code=19,o(this,g,ft).call(this),o(this,g,tt).call(this,{type:"display-disconnected"});break;case"42":e.name="Product under elevator",e.description="Product alarm under elevator",e.no_code=20,o(this,g,Y).call(this),o(this,g,tt).call(this,{type:"product-under-elevator"});break;case"43":e.name="Error when elevator approaching to a position",e.description="Error when elevator approaching to a position",e.no_code=21,o(this,g,ft).call(this),o(this,g,tt).call(this,{type:"error-approaching-position",severity:"high"});break;case"44":e.name="Fault in keyboard",e.description="Fault in keyboard",e.no_code=22,o(this,g,Y).call(this),o(this,g,wt).call(this,{type:"fault-keyboard"});break;case"45":e.name="Eeprom writing error",e.description="Eeprom writing error",e.no_code=23,o(this,g,Y).call(this),o(this,g,wt).call(this,{type:"eeprom-writing-error",severity:"critical"});break;case"46":e.name="Fault communicating with temperature control",e.description="Fault communicating with temperature control",e.no_code=24,o(this,g,ft).call(this),o(this,g,tt).call(this,{type:"fault-temperature-control"});break;case"47":e.name="Thermometer disconnected",e.description="The thermometer is disconnected",e.no_code=25,o(this,g,ft).call(this),o(this,g,tt).call(this,{type:"thermometer-disconnected"});break;case"48":e.name="Thermometer programming lost",e.description="Thermometer programming lost",e.no_code=26,o(this,g,ft).call(this),o(this,g,tt).call(this,{type:"thermometer-programming-lost"});break;case"49":e.name="Thermometer faulty",e.description="Thermometer faulty",e.no_code=27,o(this,g,ft).call(this),o(this,g,tt).call(this,{type:"thermometer-faulty"});break;case"4a":e.name="Channels power consumption detector faulty",e.description="Channels power consumption detector faulty",e.no_code=28,o(this,g,Y).call(this),o(this,g,wt).call(this,{type:"channels-power-consumption-detector-faulty",severity:"critical"});break;case"4b":e.name="Elevator does not find channel or tray",e.description="Elevator does not find channel or tray",e.no_code=29,o(this,g,Y).call(this),o(this,g,tt).call(this,{type:"elevator-not-find-channel-tray"});break;case"4c":e.name="Elevator does not find delivery product position",e.description="Elevator does not find delivery product position",e.no_code=30,o(this,g,Y).call(this),o(this,g,wt).call(this,{type:"elevator-not-find-delivery-position"});break;case"4d":e.name="Interior of elevator blocked",e.description="Interior of elevator blocked",e.no_code=31,o(this,g,qe).call(this),this.__internal__.dispense.elevator.need_reset||(this.__internal__.dispense.elevator.need_reset=!0),o(this,g,wt).call(this,{type:"interior-elevator-blocked",severity:"low"});break;case"4e":e.name="Error in tester of product detector",e.description="Error in tester of product detector",e.no_code=32,o(this,g,Y).call(this),o(this,g,wt).call(this,{type:"error-tester-product-detector"});break;case"4f":e.name="Waiting for product to be removed",e.description="Waiting for product to be removed",e.no_code=33,o(this,g,qe).call(this);break;case"50":e.name="Product expired by temperature reasons",e.description="Product expired by temperature reasons",e.no_code=34,o(this,g,ft).call(this),o(this,g,tt).call(this,{type:"product-expired-temperature"});break;case"51":e.name="Automatic door faulty",e.description="Automatic door faulty",e.no_code=35,o(this,g,ft).call(this),o(this,g,tt).call(this,{type:"automatic-door-faulty"});break;case"59":case"5a":case"61":case"62":case"63":switch(e.name="Product is expired",e.description="Product is expired",e.additional={nsf_alarm:1},t[1]){case"5a":e.additional.nsf_alarm=2;break;case"61":e.additional.nsf_alarm=3;break;case"62":e.additional.nsf_alarm=4;break;case"63":e.additional.nsf_alarm=5;break}e.no_code=36,o(this,g,ft).call(this),o(this,g,tt).call(this,{type:"product-expired"});break;case"64":e.name="Product detector didn't change during its verification test",e.description="Product detector didn't change during its verification test",e.no_code=37,o(this,g,ft).call(this),o(this,g,tt).call(this,{type:"automatic-door-faulty"});break}this.dispatch("machine:status",e)}else e.name="executed",e.description="The last command was executed successfully",e.no_code=8,!t[1]&&this.__internal__.dispense.dispensing&&o(this,g,Y).call(this);return e},Ds=function(t){if(t=parseInt(t)+109,t=t.toString(),t.length!==3)throw new Error("Invalid selection");const e=(parseInt(t.substring(0,2))+128).toString(16).padStart(2,"0");return{channel:(parseInt(t.substring(2,3))+128).toString(16).padStart(2,"0"),tray:e}},Rs=function(){this.__internal__.dispense.timeout&&clearTimeout(this.__internal__.dispense.timeout),this.__internal__.dispense.interval&&clearInterval(this.__internal__.dispense.interval),this.__internal__.dispense.timeout=0,this.__internal__.dispense.interval=0},Is=function(){this.__internal__.dispense.timeout&&clearTimeout(this.__internal__.dispense.timeout),this.__internal__.dispense.interval&&clearInterval(this.__internal__.dispense.interval);const t=this;t.__internal__.dispense.timeout=setTimeout(()=>{t.__internal__.dispense.interval=setInterval(()=>{t.status().then(()=>{})},t.__internal__.dispense.interval_time)},t.__internal__.dispense.timeout_time)},ue=async function(t){const e=["02","30","30","81","52",t,"FF"];return await o(this,g,ot).call(this,e,"reset")},Nn=function(){const t=this.__device.type==="iceplus"?Xe(40):Xe(25),e=new Date,n=1e3*t+e.getTime(),s=new Date(n);this.dispatch("reset:errors",{description:"Resetting machine errors",duration:t,started_at:e,finished_at:s})},Mn=async function(t){const e=["02","30","30","81","4C",t,"FF"];return await o(this,g,ot).call(this,e,"lights")},je=async function(t="80",e=[]){const n=["02","30","30","81","44",t,...e];return await o(this,g,ot).call(this,n,"display")},He=function(t=""){t=t.padEnd(32," ");const e=[];for(let n=0;n<32;n++)e.push(t.charCodeAt(n).toString(16));return e},Os=function(t){if(!(t instanceof Date))throw new Error("Invalid date, must be an instance of Date");const e=t.getHours().toString().padStart(2,"0"),n=t.getMinutes().toString().padStart(2,"0"),s=t.getDate().toString().padStart(2,"0"),a=(t.getMonth()+1).toString().padStart(2,"0"),c=t.getFullYear().toString().substring(2,4),l=`${e}:${n} ${s}-${a}-${c}`,h=[];for(let f=0;f<14;f++)h.push(l.charCodeAt(f).toString(16));return h};class fc extends kt{constructor({filters:t=null,config_port:e=null,no_device:n=1}={}){super({filters:t,config_port:e,no_device:n});$(this,w);Z(this,"__coin_purse",{available:!0});Z(this,"__banknote_purse",{available:!0,isRecycler:!0,recycler:{ict:!0,banknote:1}});Z(this,"__sale",{price:0,change:0,change_verified:0,dispense_all:!0,last_change:0,clear(){this.price=0,this.change=0,this.change_verified=0,this.dispense_all=!0,this.last_change=0}});Z(this,"__money_session",{inserted:0,retired:0,clear(){this.inserted=0,this.retired=0}});Z(this,"coins",{tubes:{g50:0,c50:0,p1:0,p2:0,p5:0,p10:0},box:{g50:0,c50:0,p1:0,p2:0,p5:0,p10:0},totals:{g50:0,c50:0,p1:0,p2:0,p5:0,p10:0},total:0});Z(this,"banknotes",{stacker:{p20:0,p50:0,p100:0,p200:0,p500:0,p1000:0},recycler:{p20:0,p50:0,p100:0,p200:0,p500:0,p1000:0},out:{p20:0,p50:0,p100:0,p200:0,p500:0,p1000:0},totals:{p20:0,p50:0,p100:0,p200:0,p500:0,p1000:0},total:0});Z(this,"card_reader",{available:!1,max_pre_credit:0});$(this,Gt,!1);$(this,Nt,0);$(this,Jt,0);if(this.__internal__.device.type="boardroid",K.getCustom(this.typeDevice,n))throw new Error(`Device ${this.typeDevice} ${n} already exists`);this.__internal__.serial.config_port.baudRate=115200,this.__internal__.serial.response.length=14,this.__internal__.time.response_connection=600,this.__internal__.time.response_general=4e3,this.__internal__.time.response_engines=15e3,this.__internal__.dispense.limit_counter=15,this.__internal__.dispense.custom_limit_counter=null,this.__internal__.dispense.backup_dispense={channel:1,second_channel:null,sensor:!0,seconds:null},o(this,w,Bs).call(this),o(this,w,Ns).call(this)}get totalInTubes(){return this.coins.tubes.g50*.5+this.coins.tubes.c50*.5+this.coins.tubes.p1+this.coins.tubes.p2*2+this.coins.tubes.p5*5+this.coins.tubes.p10*10}get totalInRecycler(){return this.banknotes.recycler.p20*20+this.banknotes.recycler.p50*50+this.banknotes.recycler.p100*100+this.banknotes.recycler.p200*200+this.banknotes.recycler.p500*500+this.banknotes.recycler.p1000*1e3}get hasRecycler(){return this.__banknote_purse.available&&this.__banknote_purse.isRecycler}set hasRecycler(t){this.__banknote_purse.isRecycler=t}get hasICT(){return this.hasRecycler&&this.__banknote_purse.recycler.ict}set hasICT(t){this.__banknote_purse.recycler.ict=t}set banknoteICT(t){if(![20,50,100,200,500].includes(t))throw new Error(`Invalid banknote value: ${t}`);t=[20,50,100,200,500].indexOf(t),this.__banknote_purse.recycler.banknote=t}get banknoteICT(){return[20,50,100,200,500][this.__banknote_purse.recycler.banknote]}get hasCoinPurse(){return this.__coin_purse.available}set price(t){let e=parseFloat(t);(isNaN(e)||e<0)&&(e=0),this.__sale.price=e}get price(){return this.__sale.price}get change(){return this.__sale.price<=0||this.__money_session.inserted<=this.__sale.price?0:this.__money_session.inserted-this.__sale.price}softReload(){super.softReload(),this.__sale.clear(),this.__money_session.clear()}serialBoardroidSumHex(t){let e=0;return t.forEach((n,s)=>{s!==0&&s!==11&&(e+=parseInt(n,16))}),e.toString(16).toUpperCase()}serialMessage(t){let e={code:t,name:null,description:null,request:null,no_code:0};const n=(5+this.deviceNumber).toString(16).padStart(2,"0").toLowerCase();switch(t[1]){case n:e.request="connect",e=o(this,w,Fs).call(this,e);break;case"a0":e.request="--automatic",e=o(this,w,Ks).call(this,t,e);break;case"b0":e.request="--automatic",e=o(this,w,Ws).call(this,t,e);break;case"d0":e.request="coin-purse:config",e=o(this,w,zs).call(this,t[2],e);break;case"d1":e.request="banknote-purse:config",e.additional={scrow:null},e=o(this,w,Xs).call(this,t,e);break;case"d2":e.request="coin-purse:read-tubes",e=o(this,w,Gs).call(this,t,e);break;case"d3":e.request="banknote-purse:read-recycler",e=o(this,w,Js).call(this,t,e);break;case"d4":e.request="banknote-purse:banknote-scrow-status",e=o(this,w,$s).call(this,t[2],e);break;case"d5":e.request="banknote-purse:dispense",e=o(this,w,Qs).call(this,t,e);break;case"d6":e.request="coin-purse:dispense",e=o(this,w,Zs).call(this,t,e);break;case"d7":e.request="dispense",e=o(this,w,Ys).call(this,t[5],e);break;case"d8":e.request="--automatic",e=o(this,w,ta).call(this,t[13],e);break;case"d9":e.request="status:temperature",e=o(this,w,ea).call(this,t,e);break;case"da":e.request="status:relay",e=o(this,w,na).call(this,t[2],e);break;case"db":e.request="banknote-purse:save-memory",e.no_code=18,e.name="Bill purse memory saved?",e.description="The memory of bill purse was saved successfully?",this.dispatch("banknote-purse:save-memory",{message:e});break;case"dc":e.request="coin-purse:read-memory",e.no_code=19,e.name="Coin purse memory read?",e.description="The memory of coin purse was read successfully?",this.dispatch("banknote-purse:read-memory",{message:e});break;case"dd":e.request="card-reader",o(this,w,ia).call(this,t,e);break;default:e.request="--unknown",e.name="Response unrecognized",e.description="The response of application was received, but dont identify with any of current parameters",e.no_code=400,this.dispatch("unknown",e);break}this.dispatch("serial:message",e)}serialSetConnectionConstant(t=1){let e=["F1","06","00","00","00","00","00","00","00","00","F2","F8"];return e[1]=this.hexMaker(this.decToHex((5+t).toString())),e[11]=this.serialBoardroidSumHex(e),this.add0x(e)}async coinPurseConfigure({enable:t=!1,high:e="FF",low:n="FF"}={}){if(!this.__coin_purse.available)throw new Error("Coin purse not available");const a=["F1","C1",t?"01":"00",e,n,"00","00","00","00","00","F2","00"];await o(this,w,ct).call(this,a,"coin-purse:config")}async coinPurseEnable(){await this.coinPurseConfigure({enable:!0})}async coinPurseDisable(){await this.coinPurseConfigure({enable:!1})}async coinPurseDispense({$_50c:t=0,$_1:e=0,$_2:n=0,$_5:s=0,$_10:a=0}={}){if(!this.__coin_purse.available)throw new Error("Coin purse not available");if([t,e,n,s,a].some(l=>isNaN(l)||typeof l=="string"))throw new Error("One of the values is not a number");if(t<1&&e<1&&n<1&&s<1&&a<1)throw new Error("No coins to dispense");[t,e,n,s,a]=[this.decToHex(t),this.decToHex(e),this.decToHex(n),this.decToHex(s),this.decToHex(a)];let c=["F1","C6",t,e,n,s,a,"00","00","00","F2","00"];await o(this,w,ct).call(this,c,"coin-purse:dispense")}async coinPurseReadTubes(){const t=["F1","C2","00","00","00","00","00","00","00","00","F2","00"];await o(this,w,ct).call(this,t,"coin-purse:read-tubes")}async banknotePurseConfigure({enable:t=!1,scrow:e=!1}={}){if(!this.__banknote_purse.available)throw new Error("Banknote purse not available");let n;return o(this,w,Ke).call(this)?n=o(this,w,ra).call(this,{enable:t,scrow:e}):n=o(this,w,sa).call(this,{enable:t,scrow:e}),await o(this,w,ct).call(this,n,"banknote-purse:config")}async banknotePurseDispense({$_20:t=0,$_50:e=0,$_100:n=0,$_200:s=0,$_500:a=0,$_1000:c=0}={}){if(!this.__banknote_purse.available)throw new Error("Banknote purse not available");if(!this.__banknote_purse.isRecycler)throw new Error("Banknote purse is not recycler");let l;if(o(this,w,Ke).call(this)){const h=[t,e,n,s,a];l=o(this,w,aa).call(this,h[this.__banknote_purse.recycler.banknote])}else l=o(this,w,oa).call(this,{$_20:t,$_50:e,$_100:n,$_200:s,$_500:a,$_1000:c});await o(this,w,ct).call(this,l,"banknote-purse:dispense")}async banknotePurseEnable({scrow:t=!1}){return await this.banknotePurseConfigure({enable:!0,scrow:t})}async banknotePurseDisable(){return await this.banknotePurseConfigure({enable:!1})}async banknotePurseAcceptInScrow(){if(!this.__banknote_purse.available)throw new Error("Banknote purse not available");const t=["F1","C4","01","00","00","00","00","00","00","00","F2","00"];await o(this,w,ct).call(this,t,"banknote-purse:banknote-scrow-status")}async banknotePurseRejectInScrow(){if(!this.__banknote_purse.available)throw new Error("Banknote purse not available");const t=["F1","C4","00","00","00","00","00","00","00","00","F2","00"];await o(this,w,ct).call(this,t,"banknote-purse:banknote-scrow-status")}async banknotePurseSaveMemory({channel:t=null,$_20:e=null,$_50:n=null,$_100:s=null,$_200:a=null,$_500:c=null,$_1000:l=null}={}){if(!this.__banknote_purse.available)throw new Error("Banknote purse not available");if(t===null||e===null||n===null||s===null||a===null||c===null||l===null)throw new Error("One of the values is not defined");const h=["F1","C8",this.decToHex(t),"00",this.decToHex(e),this.decToHex(n),this.decToHex(s),this.decToHex(a),this.decToHex(c),this.decToHex(l),"F2","00"];await o(this,w,ct).call(this,h,"banknote-purse:save-memory")}async banknotePurseReadRecycler(){if(!this.__banknote_purse.available)throw new Error("Banknote purse not available");if(!this.__banknote_purse.isRecycler)throw new Error("Banknote purse is not recycler");const t=["F1","C3","00","00","00","00","00","00","00","00","F2","B5"];return await o(this,w,ct).call(this,t,"banknote-purse:read-recycler")}async cardReaderDisable(){if(!this.card_reader.available)throw new Error("Card reader not available");const t=["F1","CD","00","00","00","00","00","00","00","00","F2","00"];return await o(this,w,ct).call(this,t,"card-reader:disable")}async cardReaderDispense({channel:t=1,second_channel:e=null,sensor:n=!0,seconds:s=null,price:a=0}={}){if(!this.card_reader.available)throw new Error("Card reader not available");if(isNaN(this.card_reader.max_pre_credit)||this.card_reader.max_pre_credit===0)throw new Error("Card reader pre-credit not configured");if(isNaN(a)||a<=0)throw new Error("Price must be greater than 0");if(a>this.card_reader.max_pre_credit)throw new Error("Price is greater than pre-credit configured");if(!n&&(s===null||s<=0||s>40))throw new Error("Invalid time to dispense without sensor, must be between 0.1 and 40.0 seconds");const c=this.decToHex(a/256),l=this.decToHex(a%256),h=this.decToHex(t+9);let f="00";e&&(f=this.decToHex(e+9));let _="00";n||(_=this.decToHex(s*10));const m=["F1","CD","01",h,f,_,c,l,"00","00","F2","00"];await o(this,w,ct).call(this,m,"card-reader:dispense")}async paymentPursesDisable({coin:t=!0,banknote:e=!0,cardReader:n=!1}={}){t&&await this.coinPurseDisable(),e&&await this.banknotePurseDisable(),n&&await this.cardReaderDisable()}async paymentPursesEnable({coin:t=!0,banknote:e=!0,scrowBanknote:n=!1}={}){t&&await this.coinPurseEnable(),e&&await this.banknotePurseEnable({scrow:n})}async coolingRelayConfigure({enable:t=!1}={}){const n=["F1","CC",t?"01":"00","00","00","00","00","00","00","00","F2","00"];return await o(this,w,ct).call(this,n,"status:relay")}async coolingRelayEnable(){return await this.coolingRelayConfigure({enable:!0})}async coolingRelayDisable(){return await this.coolingRelayConfigure({enable:!1})}async readTemperature(){const t=["F1","CB","00","00","00","00","00","00","00","00","F2","00"];return await o(this,w,ct).call(this,t,"status:temperature")}async dispense({selection:t=1,second_selection:e=null,sensor:n=!0,seconds:s=null,retry:a=!0}={}){if(t=parseInt(t),isNaN(t)||t<1||t>80)throw new Error("Invalid channel number");if(e!==null&&(e<1||e>80||e===t))throw new Error("Invalid second channel number");if(!n&&(s===null||s<=0||s>40))throw new Error("Invalid time to dispense without sensor, must be between 0.1 and 40.0 seconds");a&&(this.__internal__.dispense.backup_dispense={selection:t,second_selection:e,sensor:n,seconds:s}),t+=9;const c=this.decToHex(t);let l="00";e&&(e+=9,l=this.decToHex(e));let h="00";n||(h=this.decToHex(Math.round(s*6.2)),this.__internal__.dispense.custom_limit_counter=s);const f=o(this,w,We).call(this,["F1","C7",c,l,h,"00","00","00","00","00","F2","00"]);let _=await this.internalDispense(f);return!_.dispensed&&a&&(_=await this.internalDispense(f)),this.__internal__.dispense.custom_limit_counter=null,_}async testEngines({singleEngine:t=!1}={}){if(this.isDispensing)throw new Error("Another dispensing process is running");if(O(this,Gt))throw new Error("Another test is running");o(this,w,Un).call(this),L(this,Gt,!0);const e=[];o(this,w,ze).call(this);for(let n=1;n<=80;n++){const s=await this.dispense({selection:n,second_selection:t?null:n+1,sensor:!1,seconds:.4,retry:!1});e.push(s),L(this,Nt,n),o(this,w,ze).call(this),t||n++}L(this,Nt,80),o(this,w,ze).call(this,{dispensed:e}),o(this,w,Un).call(this)}async sendCustomCode({code:t=[]}={}){if(t.length===0)throw new Error("Invalid code");const e=o(this,w,We).call(this,t);await this.appendToQueue(e,"custom")}hasToReturnChange(t=0){let e=t;return e<=0?!0:(e=o(this,w,Ln).call(this,e).pending,e=o(this,w,Vn).call(this,e).pending,!(e>0))}async returnChange(){return await o(this,w,qn).call(this)}async returnInsertedMoney(){return this.__money_session.inserted<=0?!1:await o(this,w,qn).call(this,this.__money_session.inserted)}async serialCorruptMessage(t,e){this.dispatch("corrupt:message",{data:t,message:e})}}Gt=new WeakMap,Nt=new WeakMap,Jt=new WeakMap,w=new WeakSet,Bs=function(){const t=["banknote-purse:banknote-scrow-status","banknote-purse:config","banknote-purse:event-banknote","banknote-purse:read-memory","banknote-purse:recycler","banknote-purse:save-memory","card-reader:event","change:pending","coin-purse:coin-event","coin-purse:config","coin-purse:reject-lever","coin-purse:reset","coin-purse:tubes","percentage:test","run:default-load","session:money-dispensed","session:money-request","event:door","door:event","status:relay","status:temperature"];for(const e of t)this.serialRegisterAvailableListener(e)},Ns=function(){K.add(this)},Ke=function(){return this.__banknote_purse.isRecycler&&this.__banknote_purse.recycler.ict},Ms=function(){return this.hasCoinPurse||this.hasRecycler},Fs=function(t){return t.name="Connection with the serial device completed.",t.description="Your connection with the serial device was successfully completed.",t.no_code=1,this.dispatch("run:default-load",{}),t},Us=function(t){const e={g50:["40","50","60","70","90"],c50:["41","51","61","71","91"],p1:["42","52","62","72","92"],p2:["43","53","63","73","93"],p5:["44","54","64","74","94"],p10:["45","55","65","75","95"],p20:["47","57","67","77","97"]};let n=null;for(let a in e)if(e[a].includes(t)){n=a;break}return n?[{g50:"50 pennies (the big one)",c0:"50 pennies (the little one)",p1:"1 peso",p2:"2 pesos",p5:"5 pesos",p10:"10 pesos",p20:"20 pesos"}[n],n]:[`Undefined value: ¿${t}?`,null]},Ls=function(t){return["g50","c50","p1","p2","p5","p10","p20"].includes(t)},Vs=function(t){const e={p20:["80","90","a0","b0"],p50:["81","91","a1","b1"],p100:["82","92","a2","b2"],p200:["83","93","a3","b3"],p500:["84","94","a4","b4"],p1000:["85","95","a5","b5"]};let n=null;for(let a in e)if(e[a].includes(t)){n=a;break}return n?[{p20:"20 pesos",p50:"50 pesos",p100:"100 pesos",p200:"200 pesos",p500:"500 pesos",p1000:"1000 pesos"}[n],n]:[`Undefined value: ¿${t}?`,null]},qs=function(t){return["p20","p50","p100","p200","p500","p1000"].includes(t)},js=function(t){return["r20","r50","r100"].includes(t)},Hs=function(){return["r20","r50","r100","r200","r500"][this.__banknote_purse.recycler.banknote]},Fn=function(t,e){if(!t)return;let n=!0;if(o(this,w,Ls).call(this,t)){if(typeof this.coins.tubes[t]>"u")return;e==="tube"?this.coins.tubes[t]+=1:e==="box"&&(this.coins.box[t]+=1);let s=0;["g50","c50"].includes(t)?s=.5:s+=parseInt(t.slice(1)),this.coins.totals[t]+=s,this.__money_session.inserted+=s,this.coins.total+=s}else if(o(this,w,qs).call(this,t)){if(typeof this.banknotes.tubes[t]>"u")return;e==="recycler"?this.banknotes.recycler[t]+=1:e==="stacker"&&(this.banknotes.stacker[t]+=1);let s=parseInt(t.slice(1));this.banknotes.totals[t]+=s,this.__money_session.inserted+=s,this.banknotes.total+=s}else if(o(this,w,js).call(this,t)&&e==="out"){if(typeof this.banknotes.out[t]>"u")return;this.banknotes.out[t]+=1;let s=parseInt(t.slice(1));this.__money_session.retired+=s,this.banknotes.recycler[t]-=1,this.banknotes.total-=s,n=!1,this.dispatch("session:money-dispensed",{type_money:t,retired:s,finish:!1,type:"banknotes"})}n&&this.dispatch("session:money-request",{})},Ks=function(t,e){const n=parseInt(t[2],16);return e.name="Coin Inserted",e.no_code=2,e.additional={where:null,coin:null},n===1?(e.name="Lever pressed",e.description="Reject lever",e.no_code=100,this.dispatch("coin-purse:reject-lever",{})):n===2?(e.name="Reset coin purse",e.description="The configuration of coin purse was reset",e.no_code=101,this.dispatch("coin-purse:reset",{})):n>=64&&n<=79?(e.name="Coin inserted in profit box",e.additional.where="box"):n>=80&&n<=95?(e.name="Coin inserted in tube",e.additional.where="tube"):n>=96&&n<=111?(e.name="Unused coin",e.description="Something come from coin changer but in MDB Docs is unused",e.additional.where="unused"):n>=112&&n<=127?(e.name="Coin rejected",e.additional.where="rejected"):n>=144&&n<=159?(e.name="Coin dispensed",e.additional.where="out",e.description=`Undefined value: ¿${t[2]}?`):(e.name="Coin inserted",e.description="Undefined status. Without information of this",e.no_code=400),n===1||n===2||n>=160||n>=128&&n<=143||([e.description,e.additional.coin]=o(this,w,Us).call(this,t[2]),e.no_code=38+n,o(this,w,Fn).call(this,e.additional.coin,e.additional.where),["tube","out"].includes(e.additional.where)&&this.dispatch("coin-purse:tubes",this.coins.tubes),this.dispatch("coin-purse:coin-event",this.coins)),e},Ws=function(t,e){const n=parseInt(t[2],16);return e.name="Banknote Inserted",e.no_code=2,e.additional={where:null,banknote:null},n===42?(e.name="Banknote dispensed",e.description="Banknote dispensed by request.",e.additional.banknote=o(this,w,Hs).call(this),e.additional.where="out",e.no_code=200):n>=128&&n<=143?(e.name="Banknote inserted",e.additional.where="stacker"):n>=144&&n<=159?(e.name="Banknote inserted in pre stacker",e.additional.where="tmp"):n>=160&&n<=175?(e.name="Banknote rejected",e.additional.where="nothing"):n>=176&&n<=191&&(e.name="Banknote inserted",e.additional.where="recycler"),n>=128&&n<=191&&([e.description,e.additional.banknote]=o(this,w,Vs).call(this,t[2]),e.no_code=74+n),o(this,w,Fn).call(this,e.additional.banknote,e.additional.where),this.dispatch("banknote-purse:event-banknote",this.banknotes),e},zs=function(t,e){const n=parseInt(t,16);return n===1?(e.name="Coin purse enabled",e.description="Configuration complete, enabled",e.no_code=3):n===0?(e.name="Coin purse disabled",e.description="Disabled by system request",e.no_code=4):(e.name="Status unknown",e.description="The response of coin purse doesn't identify successfully",e.no_code=400),this.dispatch("coin-purse:config",{enabled:n===1}),e},Xs=function(t,e){const n=parseInt(t[2],16),s=parseInt(t[3],16);return n===0?(e.name="Bill purse disabled",e.description="Configuration complete, disabled"):n===1&&(e.name="Bill purse enabled",e.description="Configuration complete, enabled"),s===0?e.additional.scrow="Scrow disabled, banknote received automatic":s===1&&(e.additional.scrow="Scrow enabled, require manual action"),e.no_code=5,this.dispatch("banknote-purse:config",{enabled:n===1,scrow:s===1}),e},Gs=function(t,e){e.no_code=6;const[n,s,a,c,l,h]=[parseInt(t[2],16),parseInt(t[3],16),parseInt(t[4],16),parseInt(t[5],16),parseInt(t[6],16),parseInt(t[7],16)];return e.additional={coins:{g50:n,c50:s,p1:a,p2:c,p5:l,p10:h}},this.coins.tubes.g50=n,this.coins.tubes.c50=s,this.coins.tubes.p1=a,this.coins.tubes.p2=c,this.coins.tubes.p5=l,this.coins.tubes.p10=h,this.coins.totals.g50=(this.coins.box.g50+n)*.5,this.coins.totals.c50=(this.coins.box.c50+s)*.5,this.coins.totals.p1=this.coins.box.p1+a,this.coins.totals.p2=(this.coins.box.p2+c)*2,this.coins.totals.p5=(this.coins.box.p5+l)*5,this.coins.totals.p10=(this.coins.box.p10+h)*10,this.coins.total=this.coins.totals.g50+this.coins.totals.c50+this.coins.totals.p1+this.coins.totals.p2+this.coins.totals.p5+this.coins.totals.p10,e.name="Read tubes",e.description="Quantity of coins approximated",this.dispatch("coin-purse:tubes",this.coins.tubes),e},Js=function(t,e){e.no_code=7;const[n,s,a,c,l,h]=[parseInt(t[2],16),parseInt(t[3],16),parseInt(t[4],16),parseInt(t[5],16),parseInt(t[6],16),parseInt(t[7],16)];return e.additional={banknotes:{b20:n,b50:s,b100:a,b200:c,b500:l,b1000:h}},this.banknotes.recycler.p20=n,this.banknotes.recycler.p50=s,this.banknotes.recycler.p100=a,this.banknotes.recycler.p200=c,this.banknotes.recycler.p500=l,this.banknotes.recycler.p1000=h,this.banknotes.totals.p20=(this.banknotes.stacker.p20+n)*20,this.banknotes.totals.p50=(this.banknotes.stacker.p50+s)*50,this.banknotes.totals.p100=(this.banknotes.stacker.p100+a)*100,this.banknotes.totals.p200=(this.banknotes.stacker.p200+c)*200,this.banknotes.totals.p500=(this.banknotes.stacker.p500+l)*500,this.banknotes.totals.p1000=(this.banknotes.stacker.p1000+h)*1e3,this.banknotes.total=this.banknotes.totals.p20+this.banknotes.totals.p50+this.banknotes.totals.p100+this.banknotes.totals.p200+this.banknotes.totals.p500+this.banknotes.totals.p1000,e.name="Read recycler",e.description="Quantity of banknotes approximated",this.dispatch("banknote-purse:recycler",this.banknotes.recycler),e},$s=function(t,e){const n=parseInt(t,16);return n===1?e.name="Banknote accepted":n===0?e.name="Banknote rejected":e.name="Unknown status banknote",e.no_code=8,this.dispatch("banknote-purse:banknote-scrow-status",{status:n===1}),e},Qs=function(t,e){const[n,s,a,c,l,h]=[parseInt(t[2],16),parseInt(t[3],16),parseInt(t[4],16),parseInt(t[5],16),parseInt(t[6],16),parseInt(t[7],16)],f=n*20+s*50+a*100+c*200+l*500+h*1e3;return e.name="Banknotes dispensed",e.description=f>0?"Banknotes dispensed by request":"No banknotes dispensed, recycler empty",e.no_code=9,e.additional={banknotes:{b20:n,b50:s,b100:a,b200:c,b500:l,b1000:h},total_dispensed:f},this.dispatch("session:money-dispensed",{type_money:null,retired:null,finish:!1,type:"banknotes",data:e}),e},Zs=function(t,e){return e.name="Coins dispensed",e.no_code=10,e.description="Coins dispensed by request",isNaN(this.__sale.last_change)&&(this.__sale.last_change=0),this.__money_session.retired+=this.__sale.last_change,this.dispatchAsync("session:money-dispensed",{type_money:null,retired:null,finish:!1,type:"coins"},500),e},Ys=function(t,e){const n=parseInt(t,16);return n===1?(e.name="Product not delivered",e.description="The product requested wasn't delivered",e.no_code=11,this.__internal__.dispense.status=!1):n===0?(e.name="Product delivered",e.description="The product requested was delivered",e.no_code=12,this.__internal__.dispense.status=!0):(e.name="Unknown status product",e.description="The response of product doesn't identify successfully",e.no_code=400,this.__internal__.dispense.status=!1),this.dispatch("dispensed",{}),e},ta=function(t,e){let n="closed";return t==="db"?(e.name="Door closed",e.no_code=13):t==="dc"?(e.name="Door open",e.no_code=14,n="open"):(e.name="Unknown status door",e.description="The response of door doesn't identify successfully",e.no_code=400,n="unknown"),this.__internal__.device.door_open=n==="open",this.dispatch("event:door",{open:n==="open"}),this.dispatch("door:event",{open:n==="open"}),e},ea=function(t,e){const n=parseInt(t[2],16)*255,s=parseInt(t[3],16),a=(n+s)*.1;return e.no_code=15,e.name="Temperature status",e.description=`Temperature: ${a}`,e.additional={high:n,low:s,temperature:parseFloat(a.toString())},this.dispatch("status:temperature",e.additional),e},na=function(t,e){const n=parseInt(t,16);let s="unknown";return n===1?(e.name="Relay on",e.description="Relay on",e.no_code=16,s="on"):n===0?(e.name="Relay off",e.description="Relay off",e.no_code=17,s="off"):(e.name="Status unknown",e.description="Status unknown",e.no_code=400),this.dispatch("status:relay",{enabled:s==="on"}),e},ia=function(t,e){const n=parseInt(t[2],16);if(e.no_code=20+n,e.name="Status unknown",e.description="The status of card reader does not identified correctly",e.no_code=400,n===0)e.request+=":disable",e.name="Card reader disabled",e.description="Card reader device was disabled successfully";else if(n===1||n===2)e.request+=":dispense",e.name="Card reader enabled",e.description="Card reader device is now enabled";else if(n===3)e.request+=":pre-authorize",e.name="Pre-authorized credit",e.description="The pre credit was authorized successfully";else if(n===4)e.request+=":cancel",e.name="Cancellation in progress",e.description="Cancellation request done successfully";else if(n===5)e.request+=":sell",e.name="Sell approved",e.description="Sell approved, starting dispense product";else if(n===6)e.request+=":sell",e.name="Sell denied",e.description="This sell was denied, try again";else if(n===7)e.request+=":end",e.name="Session ended",e.description="The session ended";else if(n===8)e.request+=":cancel",e.name="Cancelled",e.description="Cancellation complete";else if(n===10){const s=parseInt(t[8],16);s===0?(e.no_code=30,e.name="product not dispensed",e.description="The product requested wasn't delivered"):s===1&&(e.no_code=31,e.name="product dispensed",e.description="The product requested was delivered")}return this.dispatch("card-reader:event",e),e},ct=function(t,e){return this.appendToQueue(o(this,w,We).call(this,t),e)},We=function(t){return t[11]=this.serialBoardroidSumHex(t),t.map((e,n)=>{t[n]=this.hexMaker(e)}),t},ra=function({enable:t=!1,scrow:e=!1}={}){const n=t?"FF":"00",s=e?"FF":"00";return["F1","C0",n,n,s,s,"00","00","00","00","F2","00"]},sa=function({enable:t=!1,scrow:e=!1}={}){return["F1","C0",t?"01":"00",e?"01":"00","00","00","00","00","00","00","F2","00"]},aa=function(t=1){if(t<1)throw new Error("No banknotes to dispense");return t=this.decToHex(t),["F1","C5",this.decToHex(this.__banknote_purse.recycler.banknote.toString()),t,"00","00","00","00","00","00","F2","00"]},oa=function({$_20:t=0,$_50:e=0,$_100:n=0,$_200:s=0,$_500:a=0,$_1000:c=0}={}){if([t,e,n,s,a,c].some(l=>isNaN(l)||typeof l=="string"))throw new Error("One of the values is not a number");if(t<1&&e<1&&n<1&&s<1&&a<1&&c<1)throw new Error("No banknotes to dispense");return[t,e,n,s,a,c]=[this.decToHex(t),this.decToHex(e),this.decToHex(n),this.decToHex(s),this.decToHex(a),this.decToHex(c)],["F1","C5",t,e,n,s,a,c,"00","00","F2","00"]},Un=function(){L(this,Gt,!1),L(this,Nt,0),L(this,Jt,0)},ze=function({dispensed:t=null,limit:e=80}={}){L(this,Jt,Math.round(O(this,Nt)*100/e)),this.dispatch("percentage:test",{percentage:O(this,Jt),dispensed:t})},ca=function(t){const e=["20","50","100","200","500"],n=this.__banknote_purse.recycler.banknote,s="$_"+e[n],a=parseInt(e[n]),c=this.banknotes.recycler[`p${e[n]}`],l=Math.min(Math.floor(t/a),c),h={banknotes:{$_20:0,$_50:0,$_100:0,$_200:0,$_500:0,$_1000:0},pending:t,will_dispense:l>0};return this.totalInRecycler===0||l<1||t===0||(h.banknotes[s]=l,h.pending=parseFloat((t-l*a).toFixed(2))),h},la=function(t){const e={banknotes:{$_20:0,$_50:0,$_100:0,$_200:0,$_500:0,$_1000:0},pending:t,will_dispense:!1};if(this.totalInRecycler===0||t===0)return e;const n=(s,a)=>{if(this.banknotes.recycler[a]>0){const c=Math.floor(e.pending/s),l=Math.min(c,this.banknotes.recycler[a]);e.banknotes[`$_${s}`]=l,e.pending=parseFloat((e.pending-l*s).toFixed(2))}};return n(1e3,"p1000"),n(500,"p500"),n(200,"p200"),n(100,"p100"),n(50,"p50"),n(20,"p20"),e.will_dispense=Object.values(e.banknotes).some(s=>s>0),e},Ln=function(t){return o(this,w,Ke).call(this)?o(this,w,ca).call(this,t):o(this,w,la).call(this,t)},Vn=function(t){const e={coins:{$_50c:0,$_1:0,$_2:0,$_5:0,$_10:0},pending:t,will_dispense:!1};if(t<=0||this.totalInTubes===0)return e;const n=(s,a,c=null)=>{if(this.coins.tubes[a]>0){c===null&&(c="$_"+s);const l=Math.floor(e.pending/s),h=Math.min(l,this.coins.tubes[a]);e.coins[c]=h,e.pending=parseFloat((e.pending-h*s).toFixed(2))}};return n(10,"p10"),n(5,"p5"),n(2,"p2"),n(1,"p1"),n(.5,"g50","$_50c"),e.will_dispense=Object.values(e.coins).some(s=>s>0),e},qn=async function(t=null){if(!o(this,w,Ms).call(this))throw new Error("Change not available");let e=this.change,n=this.change;if(t!==null&&(e=t,n=t),n<=0)return!1;const s=o(this,w,Ln).call(this,n);n=s.pending;const a=o(this,w,Vn).call(this,n);return n=a.pending,n>0&&this.dispatch("change:pending",{pending:n}),n===e?!1:(s.will_dispense&&await this.banknotePurseDispense(s.banknotes),a.will_dispense&&await this.coinPurseDispense(a.coins),!0)};class _c extends kt{constructor({filters:t=null,config_port:e=null,no_device:n=1}={}){super({filters:t,config_port:e,no_device:n});$(this,$t);if(this.__internal__.device.type="arduino",K.getCustom(this.typeDevice,n))throw new Error(`Device ${this.typeDevice} ${n} already exists`);this.__internal__.time.response_connection=2e3,this.__internal__.time.response_general=2e3,this.__internal__.serial.delay_first_connection=1e3,o(this,$t,ua).call(this),o(this,$t,ha).call(this)}serialMessage(t){const e={original_code:t,code:null,name:null,description:null,request:null,no_code:0},n=this.parseHexToUint8(t),s=this.parseUint8ArrayToString(n);switch(e.code=s,s){case"connected":e.name="connected",e.description="Connection established",e.request="connect",e.no_code=100;break;case"created by danidoble":e.name="thanks",e.description="thanks for using this software",e.request="credits",e.no_code=101;break;case"hello there":e.name="hello there",e.description="hi human",e.request="hi",e.no_code=102;break;case"ara ara":e.name="ara ara",e.description="troll",e.request="ara ara",e.no_code=404;break;default:e.name="unknown",e.description="Unknown command",e.request="unknown",e.no_code=400;break}this.dispatch("serial:message",e)}serialSetConnectionConstant(t=1){return this.add0x(this.parseStringToBytes("CONNECT"))}async sayCredits(){const t=this.parseStringToBytes("CREDITS");await this.appendToQueue(t,"credits")}async sayHi(){const t=this.parseStringToBytes("HI");await this.appendToQueue(t,"hi")}async sayAra(){const t=this.parseStringToBytes("OTHER");await this.appendToQueue(t,"ara")}async sendCustomCode({code:t=""}={}){if(typeof t!="string")throw new Error("Invalid string");const e=this.parseStringToBytes(t);await this.appendToQueue(e,"custom")}async doSomething(){await this.sayCredits(),await this.sayAra(),await this.sayHi()}}$t=new WeakSet,ha=function(){K.addCustom("arduino",this)},ua=function(){};/**
|
|
29
|
+
`,t+="-----END PUBLIC KEY-----",t},i.hasPublicKeyProperty=function(t){return t=t||{},t.hasOwnProperty("n")&&t.hasOwnProperty("e")},i.hasPrivateKeyProperty=function(t){return t=t||{},t.hasOwnProperty("n")&&t.hasOwnProperty("e")&&t.hasOwnProperty("d")&&t.hasOwnProperty("p")&&t.hasOwnProperty("q")&&t.hasOwnProperty("dmp1")&&t.hasOwnProperty("dmq1")&&t.hasOwnProperty("coeff")},i.prototype.parsePropertiesFrom=function(t){this.n=t.n,this.e=t.e,t.hasOwnProperty("d")&&(this.d=t.d,this.p=t.p,this.q=t.q,this.dmp1=t.dmp1,this.dmq1=t.dmq1,this.coeff=t.coeff)},i}(Na),Ye,Va=typeof process<"u"?(Ye=process.env)===null||Ye===void 0?void 0:Ye.npm_package_version:void 0,qa=function(){function r(i){i===void 0&&(i={}),i=i||{},this.default_key_size=i.default_key_size?parseInt(i.default_key_size,10):1024,this.default_public_exponent=i.default_public_exponent||"010001",this.log=i.log||!1,this.key=null}return r.prototype.setKey=function(i){this.log&&this.key&&console.warn("A key was already set, overriding existing."),this.key=new ri(i)},r.prototype.setPrivateKey=function(i){this.setKey(i)},r.prototype.setPublicKey=function(i){this.setKey(i)},r.prototype.decrypt=function(i){try{return this.getKey().decrypt($n(i))}catch{return!1}},r.prototype.encrypt=function(i){try{return pe(this.getKey().encrypt(i))}catch{return!1}},r.prototype.sign=function(i,t,e){try{return pe(this.getKey().sign(i,t,e))}catch{return!1}},r.prototype.verify=function(i,t,e){try{return this.getKey().verify(i,$n(t),e)}catch{return!1}},r.prototype.getKey=function(i){if(!this.key){if(this.key=new ri,i&&{}.toString.call(i)==="[object Function]"){this.key.generateAsync(this.default_key_size,this.default_public_exponent,i);return}this.key.generate(this.default_key_size,this.default_public_exponent)}return this.key},r.prototype.getPrivateKey=function(){return this.getKey().getPrivateKey()},r.prototype.getPrivateKeyB64=function(){return this.getKey().getPrivateBaseKeyB64()},r.prototype.getPublicKey=function(){return this.getKey().getPublicKey()},r.prototype.getPublicKeyB64=function(){return this.getKey().getPublicBaseKeyB64()},r.version=Va,r}();function si(r,i){return function(){return r.apply(i,arguments)}}const{toString:ja}=Object.prototype,{getPrototypeOf:tn}=Object,ve=(r=>i=>{const t=ja.call(i);return r[t]||(r[t]=t.slice(8,-1).toLowerCase())})(Object.create(null)),gt=r=>(r=r.toLowerCase(),i=>ve(i)===r),Pe=r=>i=>typeof i===r,{isArray:zt}=Array,te=Pe("undefined");function Ha(r){return r!==null&&!te(r)&&r.constructor!==null&&!te(r.constructor)&<(r.constructor.isBuffer)&&r.constructor.isBuffer(r)}const ai=gt("ArrayBuffer");function Ka(r){let i;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?i=ArrayBuffer.isView(r):i=r&&r.buffer&&ai(r.buffer),i}const Wa=Pe("string"),lt=Pe("function"),oi=Pe("number"),Ee=r=>r!==null&&typeof r=="object",za=r=>r===!0||r===!1,Te=r=>{if(ve(r)!=="object")return!1;const i=tn(r);return(i===null||i===Object.prototype||Object.getPrototypeOf(i)===null)&&!(Symbol.toStringTag in r)&&!(Symbol.iterator in r)},Xa=gt("Date"),Ga=gt("File"),$a=gt("Blob"),Ja=gt("FileList"),Qa=r=>Ee(r)&<(r.pipe),Za=r=>{let i;return r&&(typeof FormData=="function"&&r instanceof FormData||lt(r.append)&&((i=ve(r))==="formdata"||i==="object"&<(r.toString)&&r.toString()==="[object FormData]"))},Ya=gt("URLSearchParams"),[to,eo,no,io]=["ReadableStream","Request","Response","Headers"].map(gt),ro=r=>r.trim?r.trim():r.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function ee(r,i,{allOwnKeys:t=!1}={}){if(r===null||typeof r>"u")return;let e,n;if(typeof r!="object"&&(r=[r]),zt(r))for(e=0,n=r.length;e<n;e++)i.call(null,r[e],e,r);else{const s=t?Object.getOwnPropertyNames(r):Object.keys(r),a=s.length;let c;for(e=0;e<a;e++)c=s[e],i.call(null,r[c],c,r)}}function ci(r,i){i=i.toLowerCase();const t=Object.keys(r);let e=t.length,n;for(;e-- >0;)if(n=t[e],i===n.toLowerCase())return n;return null}const It=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,li=r=>!te(r)&&r!==It;function en(){const{caseless:r}=li(this)&&this||{},i={},t=(e,n)=>{const s=r&&ci(i,n)||n;Te(i[s])&&Te(e)?i[s]=en(i[s],e):Te(e)?i[s]=en({},e):zt(e)?i[s]=e.slice():i[s]=e};for(let e=0,n=arguments.length;e<n;e++)arguments[e]&&ee(arguments[e],t);return i}const so=(r,i,t,{allOwnKeys:e}={})=>(ee(i,(n,s)=>{t&<(n)?r[s]=si(n,t):r[s]=n},{allOwnKeys:e}),r),ao=r=>(r.charCodeAt(0)===65279&&(r=r.slice(1)),r),oo=(r,i,t,e)=>{r.prototype=Object.create(i.prototype,e),r.prototype.constructor=r,Object.defineProperty(r,"super",{value:i.prototype}),t&&Object.assign(r.prototype,t)},co=(r,i,t,e)=>{let n,s,a;const c={};if(i=i||{},r==null)return i;do{for(n=Object.getOwnPropertyNames(r),s=n.length;s-- >0;)a=n[s],(!e||e(a,r,i))&&!c[a]&&(i[a]=r[a],c[a]=!0);r=t!==!1&&tn(r)}while(r&&(!t||t(r,i))&&r!==Object.prototype);return i},lo=(r,i,t)=>{r=String(r),(t===void 0||t>r.length)&&(t=r.length),t-=i.length;const e=r.indexOf(i,t);return e!==-1&&e===t},ho=r=>{if(!r)return null;if(zt(r))return r;let i=r.length;if(!oi(i))return null;const t=new Array(i);for(;i-- >0;)t[i]=r[i];return t},uo=(r=>i=>r&&i instanceof r)(typeof Uint8Array<"u"&&tn(Uint8Array)),po=(r,i)=>{const e=(r&&r[Symbol.iterator]).call(r);let n;for(;(n=e.next())&&!n.done;){const s=n.value;i.call(r,s[0],s[1])}},fo=(r,i)=>{let t;const e=[];for(;(t=r.exec(i))!==null;)e.push(t);return e},_o=gt("HTMLFormElement"),go=r=>r.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(t,e,n){return e.toUpperCase()+n}),hi=(({hasOwnProperty:r})=>(i,t)=>r.call(i,t))(Object.prototype),bo=gt("RegExp"),ui=(r,i)=>{const t=Object.getOwnPropertyDescriptors(r),e={};ee(t,(n,s)=>{let a;(a=i(n,s,r))!==!1&&(e[s]=a||n)}),Object.defineProperties(r,e)},mo=r=>{ui(r,(i,t)=>{if(lt(r)&&["arguments","caller","callee"].indexOf(t)!==-1)return!1;const e=r[t];if(lt(e)){if(i.enumerable=!1,"writable"in i){i.writable=!1;return}i.set||(i.set=()=>{throw Error("Can not rewrite read-only method '"+t+"'")})}})},yo=(r,i)=>{const t={},e=n=>{n.forEach(s=>{t[s]=!0})};return zt(r)?e(r):e(String(r).split(i)),t},wo=()=>{},vo=(r,i)=>r!=null&&Number.isFinite(r=+r)?r:i,nn="abcdefghijklmnopqrstuvwxyz",di="0123456789",pi={DIGIT:di,ALPHA:nn,ALPHA_DIGIT:nn+nn.toUpperCase()+di},Po=(r=16,i=pi.ALPHA_DIGIT)=>{let t="";const{length:e}=i;for(;r--;)t+=i[Math.random()*e|0];return t};function Eo(r){return!!(r&<(r.append)&&r[Symbol.toStringTag]==="FormData"&&r[Symbol.iterator])}const To=r=>{const i=new Array(10),t=(e,n)=>{if(Ee(e)){if(i.indexOf(e)>=0)return;if(!("toJSON"in e)){i[n]=e;const s=zt(e)?[]:{};return ee(e,(a,c)=>{const l=t(a,n+1);!te(l)&&(s[c]=l)}),i[n]=void 0,s}}return e};return t(r,0)},Co=gt("AsyncFunction"),So=r=>r&&(Ee(r)||lt(r))&<(r.then)&<(r.catch),fi=((r,i)=>r?setImmediate:i?((t,e)=>(It.addEventListener("message",({source:n,data:s})=>{n===It&&s===t&&e.length&&e.shift()()},!1),n=>{e.push(n),It.postMessage(t,"*")}))(`axios@${Math.random()}`,[]):t=>setTimeout(t))(typeof setImmediate=="function",lt(It.postMessage)),ko=typeof queueMicrotask<"u"?queueMicrotask.bind(It):typeof process<"u"&&process.nextTick||fi,b={isArray:zt,isArrayBuffer:ai,isBuffer:Ha,isFormData:Za,isArrayBufferView:Ka,isString:Wa,isNumber:oi,isBoolean:za,isObject:Ee,isPlainObject:Te,isReadableStream:to,isRequest:eo,isResponse:no,isHeaders:io,isUndefined:te,isDate:Xa,isFile:Ga,isBlob:$a,isRegExp:bo,isFunction:lt,isStream:Qa,isURLSearchParams:Ya,isTypedArray:uo,isFileList:Ja,forEach:ee,merge:en,extend:so,trim:ro,stripBOM:ao,inherits:oo,toFlatObject:co,kindOf:ve,kindOfTest:gt,endsWith:lo,toArray:ho,forEachEntry:po,matchAll:fo,isHTMLForm:_o,hasOwnProperty:hi,hasOwnProp:hi,reduceDescriptors:ui,freezeMethods:mo,toObjectSet:yo,toCamelCase:go,noop:wo,toFiniteNumber:vo,findKey:ci,global:It,isContextDefined:li,ALPHABET:pi,generateString:Po,isSpecCompliantForm:Eo,toJSONObject:To,isAsyncFn:Co,isThenable:So,setImmediate:fi,asap:ko};function A(r,i,t,e,n){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=r,this.name="AxiosError",i&&(this.code=i),t&&(this.config=t),e&&(this.request=e),n&&(this.response=n,this.status=n.status?n.status:null)}b.inherits(A,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:b.toJSONObject(this.config),code:this.code,status:this.status}}});const _i=A.prototype,gi={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(r=>{gi[r]={value:r}}),Object.defineProperties(A,gi),Object.defineProperty(_i,"isAxiosError",{value:!0}),A.from=(r,i,t,e,n,s)=>{const a=Object.create(_i);return b.toFlatObject(r,a,function(l){return l!==Error.prototype},c=>c!=="isAxiosError"),A.call(a,r.message,i,t,e,n),a.cause=r,a.name=r.name,s&&Object.assign(a,s),a};const xo=null;function rn(r){return b.isPlainObject(r)||b.isArray(r)}function bi(r){return b.endsWith(r,"[]")?r.slice(0,-2):r}function mi(r,i,t){return r?r.concat(i).map(function(n,s){return n=bi(n),!t&&s?"["+n+"]":n}).join(t?".":""):i}function Ao(r){return b.isArray(r)&&!r.some(rn)}const Do=b.toFlatObject(b,{},null,function(i){return/^is[A-Z]/.test(i)});function Ce(r,i,t){if(!b.isObject(r))throw new TypeError("target must be an object");i=i||new FormData,t=b.toFlatObject(t,{metaTokens:!0,dots:!1,indexes:!1},!1,function(S,C){return!b.isUndefined(C[S])});const e=t.metaTokens,n=t.visitor||f,s=t.dots,a=t.indexes,l=(t.Blob||typeof Blob<"u"&&Blob)&&b.isSpecCompliantForm(i);if(!b.isFunction(n))throw new TypeError("visitor must be a function");function h(v){if(v===null)return"";if(b.isDate(v))return v.toISOString();if(!l&&b.isBlob(v))throw new A("Blob is not supported. Use a Buffer instead.");return b.isArrayBuffer(v)||b.isTypedArray(v)?l&&typeof Blob=="function"?new Blob([v]):Buffer.from(v):v}function f(v,S,C){let q=v;if(v&&!C&&typeof v=="object"){if(b.endsWith(S,"{}"))S=e?S:S.slice(0,-2),v=JSON.stringify(v);else if(b.isArray(v)&&Ao(v)||(b.isFileList(v)||b.endsWith(S,"[]"))&&(q=b.toArray(v)))return S=bi(S),q.forEach(function(H,at){!(b.isUndefined(H)||H===null)&&i.append(a===!0?mi([S],at,s):a===null?S:S+"[]",h(H))}),!1}return rn(v)?!0:(i.append(mi(C,S,s),h(v)),!1)}const _=[],m=Object.assign(Do,{defaultVisitor:f,convertValue:h,isVisitable:rn});function P(v,S){if(!b.isUndefined(v)){if(_.indexOf(v)!==-1)throw Error("Circular reference detected in "+S.join("."));_.push(v),b.forEach(v,function(q,V){(!(b.isUndefined(q)||q===null)&&n.call(i,q,b.isString(V)?V.trim():V,S,m))===!0&&P(q,S?S.concat(V):[V])}),_.pop()}}if(!b.isObject(r))throw new TypeError("data must be an object");return P(r),i}function yi(r){const i={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(r).replace(/[!'()~]|%20|%00/g,function(e){return i[e]})}function sn(r,i){this._pairs=[],r&&Ce(r,this,i)}const wi=sn.prototype;wi.append=function(i,t){this._pairs.push([i,t])},wi.toString=function(i){const t=i?function(e){return i.call(this,e,yi)}:yi;return this._pairs.map(function(n){return t(n[0])+"="+t(n[1])},"").join("&")};function Ro(r){return encodeURIComponent(r).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function vi(r,i,t){if(!i)return r;const e=t&&t.encode||Ro;b.isFunction(t)&&(t={serialize:t});const n=t&&t.serialize;let s;if(n?s=n(i,t):s=b.isURLSearchParams(i)?i.toString():new sn(i,t).toString(e),s){const a=r.indexOf("#");a!==-1&&(r=r.slice(0,a)),r+=(r.indexOf("?")===-1?"?":"&")+s}return r}class Pi{constructor(){this.handlers=[]}use(i,t,e){return this.handlers.push({fulfilled:i,rejected:t,synchronous:e?e.synchronous:!1,runWhen:e?e.runWhen:null}),this.handlers.length-1}eject(i){this.handlers[i]&&(this.handlers[i]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(i){b.forEach(this.handlers,function(e){e!==null&&i(e)})}}const Ei={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},Io={isBrowser:!0,classes:{URLSearchParams:typeof URLSearchParams<"u"?URLSearchParams:sn,FormData:typeof FormData<"u"?FormData:null,Blob:typeof Blob<"u"?Blob:null},protocols:["http","https","file","blob","url","data"]},an=typeof window<"u"&&typeof document<"u",on=typeof navigator=="object"&&navigator||void 0,Oo=an&&(!on||["ReactNative","NativeScript","NS"].indexOf(on.product)<0),Bo=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",No=an&&window.location.href||"http://localhost",et={...Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:an,hasStandardBrowserEnv:Oo,hasStandardBrowserWebWorkerEnv:Bo,navigator:on,origin:No},Symbol.toStringTag,{value:"Module"})),...Io};function Mo(r,i){return Ce(r,new et.classes.URLSearchParams,Object.assign({visitor:function(t,e,n,s){return et.isNode&&b.isBuffer(t)?(this.append(e,t.toString("base64")),!1):s.defaultVisitor.apply(this,arguments)}},i))}function Fo(r){return b.matchAll(/\w+|\[(\w*)]/g,r).map(i=>i[0]==="[]"?"":i[1]||i[0])}function Uo(r){const i={},t=Object.keys(r);let e;const n=t.length;let s;for(e=0;e<n;e++)s=t[e],i[s]=r[s];return i}function Ti(r){function i(t,e,n,s){let a=t[s++];if(a==="__proto__")return!0;const c=Number.isFinite(+a),l=s>=t.length;return a=!a&&b.isArray(n)?n.length:a,l?(b.hasOwnProp(n,a)?n[a]=[n[a],e]:n[a]=e,!c):((!n[a]||!b.isObject(n[a]))&&(n[a]=[]),i(t,e,n[a],s)&&b.isArray(n[a])&&(n[a]=Uo(n[a])),!c)}if(b.isFormData(r)&&b.isFunction(r.entries)){const t={};return b.forEachEntry(r,(e,n)=>{i(Fo(e),n,t,0)}),t}return null}function Lo(r,i,t){if(b.isString(r))try{return(i||JSON.parse)(r),b.trim(r)}catch(e){if(e.name!=="SyntaxError")throw e}return(t||JSON.stringify)(r)}const ne={transitional:Ei,adapter:["xhr","http","fetch"],transformRequest:[function(i,t){const e=t.getContentType()||"",n=e.indexOf("application/json")>-1,s=b.isObject(i);if(s&&b.isHTMLForm(i)&&(i=new FormData(i)),b.isFormData(i))return n?JSON.stringify(Ti(i)):i;if(b.isArrayBuffer(i)||b.isBuffer(i)||b.isStream(i)||b.isFile(i)||b.isBlob(i)||b.isReadableStream(i))return i;if(b.isArrayBufferView(i))return i.buffer;if(b.isURLSearchParams(i))return t.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),i.toString();let c;if(s){if(e.indexOf("application/x-www-form-urlencoded")>-1)return Mo(i,this.formSerializer).toString();if((c=b.isFileList(i))||e.indexOf("multipart/form-data")>-1){const l=this.env&&this.env.FormData;return Ce(c?{"files[]":i}:i,l&&new l,this.formSerializer)}}return s||n?(t.setContentType("application/json",!1),Lo(i)):i}],transformResponse:[function(i){const t=this.transitional||ne.transitional,e=t&&t.forcedJSONParsing,n=this.responseType==="json";if(b.isResponse(i)||b.isReadableStream(i))return i;if(i&&b.isString(i)&&(e&&!this.responseType||n)){const a=!(t&&t.silentJSONParsing)&&n;try{return JSON.parse(i)}catch(c){if(a)throw c.name==="SyntaxError"?A.from(c,A.ERR_BAD_RESPONSE,this,null,this.response):c}}return i}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:et.classes.FormData,Blob:et.classes.Blob},validateStatus:function(i){return i>=200&&i<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};b.forEach(["delete","get","head","post","put","patch"],r=>{ne.headers[r]={}});const Vo=b.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),qo=r=>{const i={};let t,e,n;return r&&r.split(`
|
|
30
|
+
`).forEach(function(a){n=a.indexOf(":"),t=a.substring(0,n).trim().toLowerCase(),e=a.substring(n+1).trim(),!(!t||i[t]&&Vo[t])&&(t==="set-cookie"?i[t]?i[t].push(e):i[t]=[e]:i[t]=i[t]?i[t]+", "+e:e)}),i},Ci=Symbol("internals");function ie(r){return r&&String(r).trim().toLowerCase()}function Se(r){return r===!1||r==null?r:b.isArray(r)?r.map(Se):String(r)}function jo(r){const i=Object.create(null),t=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let e;for(;e=t.exec(r);)i[e[1]]=e[2];return i}const Ho=r=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(r.trim());function cn(r,i,t,e,n){if(b.isFunction(e))return e.call(this,i,t);if(n&&(i=t),!!b.isString(i)){if(b.isString(e))return i.indexOf(e)!==-1;if(b.isRegExp(e))return e.test(i)}}function Ko(r){return r.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(i,t,e)=>t.toUpperCase()+e)}function Wo(r,i){const t=b.toCamelCase(" "+i);["get","set","has"].forEach(e=>{Object.defineProperty(r,e+t,{value:function(n,s,a){return this[e].call(this,i,n,s,a)},configurable:!0})})}let rt=class{constructor(i){i&&this.set(i)}set(i,t,e){const n=this;function s(c,l,h){const f=ie(l);if(!f)throw new Error("header name must be a non-empty string");const _=b.findKey(n,f);(!_||n[_]===void 0||h===!0||h===void 0&&n[_]!==!1)&&(n[_||l]=Se(c))}const a=(c,l)=>b.forEach(c,(h,f)=>s(h,f,l));if(b.isPlainObject(i)||i instanceof this.constructor)a(i,t);else if(b.isString(i)&&(i=i.trim())&&!Ho(i))a(qo(i),t);else if(b.isHeaders(i))for(const[c,l]of i.entries())s(l,c,e);else i!=null&&s(t,i,e);return this}get(i,t){if(i=ie(i),i){const e=b.findKey(this,i);if(e){const n=this[e];if(!t)return n;if(t===!0)return jo(n);if(b.isFunction(t))return t.call(this,n,e);if(b.isRegExp(t))return t.exec(n);throw new TypeError("parser must be boolean|regexp|function")}}}has(i,t){if(i=ie(i),i){const e=b.findKey(this,i);return!!(e&&this[e]!==void 0&&(!t||cn(this,this[e],e,t)))}return!1}delete(i,t){const e=this;let n=!1;function s(a){if(a=ie(a),a){const c=b.findKey(e,a);c&&(!t||cn(e,e[c],c,t))&&(delete e[c],n=!0)}}return b.isArray(i)?i.forEach(s):s(i),n}clear(i){const t=Object.keys(this);let e=t.length,n=!1;for(;e--;){const s=t[e];(!i||cn(this,this[s],s,i,!0))&&(delete this[s],n=!0)}return n}normalize(i){const t=this,e={};return b.forEach(this,(n,s)=>{const a=b.findKey(e,s);if(a){t[a]=Se(n),delete t[s];return}const c=i?Ko(s):String(s).trim();c!==s&&delete t[s],t[c]=Se(n),e[c]=!0}),this}concat(...i){return this.constructor.concat(this,...i)}toJSON(i){const t=Object.create(null);return b.forEach(this,(e,n)=>{e!=null&&e!==!1&&(t[n]=i&&b.isArray(e)?e.join(", "):e)}),t}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([i,t])=>i+": "+t).join(`
|
|
31
|
+
`)}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(i){return i instanceof this?i:new this(i)}static concat(i,...t){const e=new this(i);return t.forEach(n=>e.set(n)),e}static accessor(i){const e=(this[Ci]=this[Ci]={accessors:{}}).accessors,n=this.prototype;function s(a){const c=ie(a);e[c]||(Wo(n,a),e[c]=!0)}return b.isArray(i)?i.forEach(s):s(i),this}};rt.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),b.reduceDescriptors(rt.prototype,({value:r},i)=>{let t=i[0].toUpperCase()+i.slice(1);return{get:()=>r,set(e){this[t]=e}}}),b.freezeMethods(rt);function ln(r,i){const t=this||ne,e=i||t,n=rt.from(e.headers);let s=e.data;return b.forEach(r,function(c){s=c.call(t,s,n.normalize(),i?i.status:void 0)}),n.normalize(),s}function Si(r){return!!(r&&r.__CANCEL__)}function Xt(r,i,t){A.call(this,r??"canceled",A.ERR_CANCELED,i,t),this.name="CanceledError"}b.inherits(Xt,A,{__CANCEL__:!0});function ki(r,i,t){const e=t.config.validateStatus;!t.status||!e||e(t.status)?r(t):i(new A("Request failed with status code "+t.status,[A.ERR_BAD_REQUEST,A.ERR_BAD_RESPONSE][Math.floor(t.status/100)-4],t.config,t.request,t))}function zo(r){const i=/^([-+\w]{1,25})(:?\/\/|:)/.exec(r);return i&&i[1]||""}function Xo(r,i){r=r||10;const t=new Array(r),e=new Array(r);let n=0,s=0,a;return i=i!==void 0?i:1e3,function(l){const h=Date.now(),f=e[s];a||(a=h),t[n]=l,e[n]=h;let _=s,m=0;for(;_!==n;)m+=t[_++],_=_%r;if(n=(n+1)%r,n===s&&(s=(s+1)%r),h-a<i)return;const P=f&&h-f;return P?Math.round(m*1e3/P):void 0}}function Go(r,i){let t=0,e=1e3/i,n,s;const a=(h,f=Date.now())=>{t=f,n=null,s&&(clearTimeout(s),s=null),r.apply(null,h)};return[(...h)=>{const f=Date.now(),_=f-t;_>=e?a(h,f):(n=h,s||(s=setTimeout(()=>{s=null,a(n)},e-_)))},()=>n&&a(n)]}const ke=(r,i,t=3)=>{let e=0;const n=Xo(50,250);return Go(s=>{const a=s.loaded,c=s.lengthComputable?s.total:void 0,l=a-e,h=n(l),f=a<=c;e=a;const _={loaded:a,total:c,progress:c?a/c:void 0,bytes:l,rate:h||void 0,estimated:h&&c&&f?(c-a)/h:void 0,event:s,lengthComputable:c!=null,[i?"download":"upload"]:!0};r(_)},t)},xi=(r,i)=>{const t=r!=null;return[e=>i[0]({lengthComputable:t,total:r,loaded:e}),i[1]]},Ai=r=>(...i)=>b.asap(()=>r(...i)),$o=et.hasStandardBrowserEnv?((r,i)=>t=>(t=new URL(t,et.origin),r.protocol===t.protocol&&r.host===t.host&&(i||r.port===t.port)))(new URL(et.origin),et.navigator&&/(msie|trident)/i.test(et.navigator.userAgent)):()=>!0,Jo=et.hasStandardBrowserEnv?{write(r,i,t,e,n,s){const a=[r+"="+encodeURIComponent(i)];b.isNumber(t)&&a.push("expires="+new Date(t).toGMTString()),b.isString(e)&&a.push("path="+e),b.isString(n)&&a.push("domain="+n),s===!0&&a.push("secure"),document.cookie=a.join("; ")},read(r){const i=document.cookie.match(new RegExp("(^|;\\s*)("+r+")=([^;]*)"));return i?decodeURIComponent(i[3]):null},remove(r){this.write(r,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};function Qo(r){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(r)}function Zo(r,i){return i?r.replace(/\/?\/$/,"")+"/"+i.replace(/^\/+/,""):r}function Di(r,i){return r&&!Qo(i)?Zo(r,i):i}const Ri=r=>r instanceof rt?{...r}:r;function Ot(r,i){i=i||{};const t={};function e(h,f,_,m){return b.isPlainObject(h)&&b.isPlainObject(f)?b.merge.call({caseless:m},h,f):b.isPlainObject(f)?b.merge({},f):b.isArray(f)?f.slice():f}function n(h,f,_,m){if(b.isUndefined(f)){if(!b.isUndefined(h))return e(void 0,h,_,m)}else return e(h,f,_,m)}function s(h,f){if(!b.isUndefined(f))return e(void 0,f)}function a(h,f){if(b.isUndefined(f)){if(!b.isUndefined(h))return e(void 0,h)}else return e(void 0,f)}function c(h,f,_){if(_ in i)return e(h,f);if(_ in r)return e(void 0,h)}const l={url:s,method:s,data:s,baseURL:a,transformRequest:a,transformResponse:a,paramsSerializer:a,timeout:a,timeoutMessage:a,withCredentials:a,withXSRFToken:a,adapter:a,responseType:a,xsrfCookieName:a,xsrfHeaderName:a,onUploadProgress:a,onDownloadProgress:a,decompress:a,maxContentLength:a,maxBodyLength:a,beforeRedirect:a,transport:a,httpAgent:a,httpsAgent:a,cancelToken:a,socketPath:a,responseEncoding:a,validateStatus:c,headers:(h,f,_)=>n(Ri(h),Ri(f),_,!0)};return b.forEach(Object.keys(Object.assign({},r,i)),function(f){const _=l[f]||n,m=_(r[f],i[f],f);b.isUndefined(m)&&_!==c||(t[f]=m)}),t}const Ii=r=>{const i=Ot({},r);let{data:t,withXSRFToken:e,xsrfHeaderName:n,xsrfCookieName:s,headers:a,auth:c}=i;i.headers=a=rt.from(a),i.url=vi(Di(i.baseURL,i.url),r.params,r.paramsSerializer),c&&a.set("Authorization","Basic "+btoa((c.username||"")+":"+(c.password?unescape(encodeURIComponent(c.password)):"")));let l;if(b.isFormData(t)){if(et.hasStandardBrowserEnv||et.hasStandardBrowserWebWorkerEnv)a.setContentType(void 0);else if((l=a.getContentType())!==!1){const[h,...f]=l?l.split(";").map(_=>_.trim()).filter(Boolean):[];a.setContentType([h||"multipart/form-data",...f].join("; "))}}if(et.hasStandardBrowserEnv&&(e&&b.isFunction(e)&&(e=e(i)),e||e!==!1&&$o(i.url))){const h=n&&s&&Jo.read(s);h&&a.set(n,h)}return i},Yo=typeof XMLHttpRequest<"u"&&function(r){return new Promise(function(t,e){const n=Ii(r);let s=n.data;const a=rt.from(n.headers).normalize();let{responseType:c,onUploadProgress:l,onDownloadProgress:h}=n,f,_,m,P,v;function S(){P&&P(),v&&v(),n.cancelToken&&n.cancelToken.unsubscribe(f),n.signal&&n.signal.removeEventListener("abort",f)}let C=new XMLHttpRequest;C.open(n.method.toUpperCase(),n.url,!0),C.timeout=n.timeout;function q(){if(!C)return;const H=rt.from("getAllResponseHeaders"in C&&C.getAllResponseHeaders()),Q={data:!c||c==="text"||c==="json"?C.responseText:C.response,status:C.status,statusText:C.statusText,headers:H,config:r,request:C};ki(function(ut){t(ut),S()},function(ut){e(ut),S()},Q),C=null}"onloadend"in C?C.onloadend=q:C.onreadystatechange=function(){!C||C.readyState!==4||C.status===0&&!(C.responseURL&&C.responseURL.indexOf("file:")===0)||setTimeout(q)},C.onabort=function(){C&&(e(new A("Request aborted",A.ECONNABORTED,r,C)),C=null)},C.onerror=function(){e(new A("Network Error",A.ERR_NETWORK,r,C)),C=null},C.ontimeout=function(){let at=n.timeout?"timeout of "+n.timeout+"ms exceeded":"timeout exceeded";const Q=n.transitional||Ei;n.timeoutErrorMessage&&(at=n.timeoutErrorMessage),e(new A(at,Q.clarifyTimeoutError?A.ETIMEDOUT:A.ECONNABORTED,r,C)),C=null},s===void 0&&a.setContentType(null),"setRequestHeader"in C&&b.forEach(a.toJSON(),function(at,Q){C.setRequestHeader(Q,at)}),b.isUndefined(n.withCredentials)||(C.withCredentials=!!n.withCredentials),c&&c!=="json"&&(C.responseType=n.responseType),h&&([m,v]=ke(h,!0),C.addEventListener("progress",m)),l&&C.upload&&([_,P]=ke(l),C.upload.addEventListener("progress",_),C.upload.addEventListener("loadend",P)),(n.cancelToken||n.signal)&&(f=H=>{C&&(e(!H||H.type?new Xt(null,r,C):H),C.abort(),C=null)},n.cancelToken&&n.cancelToken.subscribe(f),n.signal&&(n.signal.aborted?f():n.signal.addEventListener("abort",f)));const V=zo(n.url);if(V&&et.protocols.indexOf(V)===-1){e(new A("Unsupported protocol "+V+":",A.ERR_BAD_REQUEST,r));return}C.send(s||null)})},tc=(r,i)=>{const{length:t}=r=r?r.filter(Boolean):[];if(i||t){let e=new AbortController,n;const s=function(h){if(!n){n=!0,c();const f=h instanceof Error?h:this.reason;e.abort(f instanceof A?f:new Xt(f instanceof Error?f.message:f))}};let a=i&&setTimeout(()=>{a=null,s(new A(`timeout ${i} of ms exceeded`,A.ETIMEDOUT))},i);const c=()=>{r&&(a&&clearTimeout(a),a=null,r.forEach(h=>{h.unsubscribe?h.unsubscribe(s):h.removeEventListener("abort",s)}),r=null)};r.forEach(h=>h.addEventListener("abort",s));const{signal:l}=e;return l.unsubscribe=()=>b.asap(c),l}},ec=function*(r,i){let t=r.byteLength;if(t<i){yield r;return}let e=0,n;for(;e<t;)n=e+i,yield r.slice(e,n),e=n},nc=async function*(r,i){for await(const t of ic(r))yield*ec(t,i)},ic=async function*(r){if(r[Symbol.asyncIterator]){yield*r;return}const i=r.getReader();try{for(;;){const{done:t,value:e}=await i.read();if(t)break;yield e}}finally{await i.cancel()}},Oi=(r,i,t,e)=>{const n=nc(r,i);let s=0,a,c=l=>{a||(a=!0,e&&e(l))};return new ReadableStream({async pull(l){try{const{done:h,value:f}=await n.next();if(h){c(),l.close();return}let _=f.byteLength;if(t){let m=s+=_;t(m)}l.enqueue(new Uint8Array(f))}catch(h){throw c(h),h}},cancel(l){return c(l),n.return()}},{highWaterMark:2})},xe=typeof fetch=="function"&&typeof Request=="function"&&typeof Response=="function",Bi=xe&&typeof ReadableStream=="function",rc=xe&&(typeof TextEncoder=="function"?(r=>i=>r.encode(i))(new TextEncoder):async r=>new Uint8Array(await new Response(r).arrayBuffer())),Ni=(r,...i)=>{try{return!!r(...i)}catch{return!1}},sc=Bi&&Ni(()=>{let r=!1;const i=new Request(et.origin,{body:new ReadableStream,method:"POST",get duplex(){return r=!0,"half"}}).headers.has("Content-Type");return r&&!i}),Mi=64*1024,hn=Bi&&Ni(()=>b.isReadableStream(new Response("").body)),Ae={stream:hn&&(r=>r.body)};xe&&(r=>{["text","arrayBuffer","blob","formData","stream"].forEach(i=>{!Ae[i]&&(Ae[i]=b.isFunction(r[i])?t=>t[i]():(t,e)=>{throw new A(`Response type '${i}' is not supported`,A.ERR_NOT_SUPPORT,e)})})})(new Response);const ac=async r=>{if(r==null)return 0;if(b.isBlob(r))return r.size;if(b.isSpecCompliantForm(r))return(await new Request(et.origin,{method:"POST",body:r}).arrayBuffer()).byteLength;if(b.isArrayBufferView(r)||b.isArrayBuffer(r))return r.byteLength;if(b.isURLSearchParams(r)&&(r=r+""),b.isString(r))return(await rc(r)).byteLength},oc=async(r,i)=>{const t=b.toFiniteNumber(r.getContentLength());return t??ac(i)},un={http:xo,xhr:Yo,fetch:xe&&(async r=>{let{url:i,method:t,data:e,signal:n,cancelToken:s,timeout:a,onDownloadProgress:c,onUploadProgress:l,responseType:h,headers:f,withCredentials:_="same-origin",fetchOptions:m}=Ii(r);h=h?(h+"").toLowerCase():"text";let P=tc([n,s&&s.toAbortSignal()],a),v;const S=P&&P.unsubscribe&&(()=>{P.unsubscribe()});let C;try{if(l&&sc&&t!=="get"&&t!=="head"&&(C=await oc(f,e))!==0){let Q=new Request(i,{method:"POST",body:e,duplex:"half"}),k;if(b.isFormData(e)&&(k=Q.headers.get("content-type"))&&f.setContentType(k),Q.body){const[ut,Et]=xi(C,ke(Ai(l)));e=Oi(Q.body,Mi,ut,Et)}}b.isString(_)||(_=_?"include":"omit");const q="credentials"in Request.prototype;v=new Request(i,{...m,signal:P,method:t.toUpperCase(),headers:f.normalize().toJSON(),body:e,duplex:"half",credentials:q?_:void 0});let V=await fetch(v);const H=hn&&(h==="stream"||h==="response");if(hn&&(c||H&&S)){const Q={};["status","statusText","headers"].forEach(Tt=>{Q[Tt]=V[Tt]});const k=b.toFiniteNumber(V.headers.get("content-length")),[ut,Et]=c&&xi(k,ke(Ai(c),!0))||[];V=new Response(Oi(V.body,Mi,ut,()=>{Et&&Et(),S&&S()}),Q)}h=h||"text";let at=await Ae[b.findKey(Ae,h)||"text"](V,r);return!H&&S&&S(),await new Promise((Q,k)=>{ki(Q,k,{data:at,headers:rt.from(V.headers),status:V.status,statusText:V.statusText,config:r,request:v})})}catch(q){throw S&&S(),q&&q.name==="TypeError"&&/fetch/i.test(q.message)?Object.assign(new A("Network Error",A.ERR_NETWORK,r,v),{cause:q.cause||q}):A.from(q,q&&q.code,r,v)}})};b.forEach(un,(r,i)=>{if(r){try{Object.defineProperty(r,"name",{value:i})}catch{}Object.defineProperty(r,"adapterName",{value:i})}});const Fi=r=>`- ${r}`,cc=r=>b.isFunction(r)||r===null||r===!1,Ui={getAdapter:r=>{r=b.isArray(r)?r:[r];const{length:i}=r;let t,e;const n={};for(let s=0;s<i;s++){t=r[s];let a;if(e=t,!cc(t)&&(e=un[(a=String(t)).toLowerCase()],e===void 0))throw new A(`Unknown adapter '${a}'`);if(e)break;n[a||"#"+s]=e}if(!e){const s=Object.entries(n).map(([c,l])=>`adapter ${c} `+(l===!1?"is not supported by the environment":"is not available in the build"));let a=i?s.length>1?`since :
|
|
32
|
+
`+s.map(Fi).join(`
|
|
33
|
+
`):" "+Fi(s[0]):"as no adapter specified";throw new A("There is no suitable adapter to dispatch the request "+a,"ERR_NOT_SUPPORT")}return e},adapters:un};function dn(r){if(r.cancelToken&&r.cancelToken.throwIfRequested(),r.signal&&r.signal.aborted)throw new Xt(null,r)}function Li(r){return dn(r),r.headers=rt.from(r.headers),r.data=ln.call(r,r.transformRequest),["post","put","patch"].indexOf(r.method)!==-1&&r.headers.setContentType("application/x-www-form-urlencoded",!1),Ui.getAdapter(r.adapter||ne.adapter)(r).then(function(e){return dn(r),e.data=ln.call(r,r.transformResponse,e),e.headers=rt.from(e.headers),e},function(e){return Si(e)||(dn(r),e&&e.response&&(e.response.data=ln.call(r,r.transformResponse,e.response),e.response.headers=rt.from(e.response.headers))),Promise.reject(e)})}const Vi="1.7.9",De={};["object","boolean","number","function","string","symbol"].forEach((r,i)=>{De[r]=function(e){return typeof e===r||"a"+(i<1?"n ":" ")+r}});const qi={};De.transitional=function(i,t,e){function n(s,a){return"[Axios v"+Vi+"] Transitional option '"+s+"'"+a+(e?". "+e:"")}return(s,a,c)=>{if(i===!1)throw new A(n(a," has been removed"+(t?" in "+t:"")),A.ERR_DEPRECATED);return t&&!qi[a]&&(qi[a]=!0,console.warn(n(a," has been deprecated since v"+t+" and will be removed in the near future"))),i?i(s,a,c):!0}},De.spelling=function(i){return(t,e)=>(console.warn(`${e} is likely a misspelling of ${i}`),!0)};function lc(r,i,t){if(typeof r!="object")throw new A("options must be an object",A.ERR_BAD_OPTION_VALUE);const e=Object.keys(r);let n=e.length;for(;n-- >0;){const s=e[n],a=i[s];if(a){const c=r[s],l=c===void 0||a(c,s,r);if(l!==!0)throw new A("option "+s+" must be "+l,A.ERR_BAD_OPTION_VALUE);continue}if(t!==!0)throw new A("Unknown option "+s,A.ERR_BAD_OPTION)}}const Re={assertOptions:lc,validators:De},vt=Re.validators;let Bt=class{constructor(i){this.defaults=i,this.interceptors={request:new Pi,response:new Pi}}async request(i,t){try{return await this._request(i,t)}catch(e){if(e instanceof Error){let n={};Error.captureStackTrace?Error.captureStackTrace(n):n=new Error;const s=n.stack?n.stack.replace(/^.+\n/,""):"";try{e.stack?s&&!String(e.stack).endsWith(s.replace(/^.+\n.+\n/,""))&&(e.stack+=`
|
|
34
|
+
`+s):e.stack=s}catch{}}throw e}}_request(i,t){typeof i=="string"?(t=t||{},t.url=i):t=i||{},t=Ot(this.defaults,t);const{transitional:e,paramsSerializer:n,headers:s}=t;e!==void 0&&Re.assertOptions(e,{silentJSONParsing:vt.transitional(vt.boolean),forcedJSONParsing:vt.transitional(vt.boolean),clarifyTimeoutError:vt.transitional(vt.boolean)},!1),n!=null&&(b.isFunction(n)?t.paramsSerializer={serialize:n}:Re.assertOptions(n,{encode:vt.function,serialize:vt.function},!0)),Re.assertOptions(t,{baseUrl:vt.spelling("baseURL"),withXsrfToken:vt.spelling("withXSRFToken")},!0),t.method=(t.method||this.defaults.method||"get").toLowerCase();let a=s&&b.merge(s.common,s[t.method]);s&&b.forEach(["delete","get","head","post","put","patch","common"],v=>{delete s[v]}),t.headers=rt.concat(a,s);const c=[];let l=!0;this.interceptors.request.forEach(function(S){typeof S.runWhen=="function"&&S.runWhen(t)===!1||(l=l&&S.synchronous,c.unshift(S.fulfilled,S.rejected))});const h=[];this.interceptors.response.forEach(function(S){h.push(S.fulfilled,S.rejected)});let f,_=0,m;if(!l){const v=[Li.bind(this),void 0];for(v.unshift.apply(v,c),v.push.apply(v,h),m=v.length,f=Promise.resolve(t);_<m;)f=f.then(v[_++],v[_++]);return f}m=c.length;let P=t;for(_=0;_<m;){const v=c[_++],S=c[_++];try{P=v(P)}catch(C){S.call(this,C);break}}try{f=Li.call(this,P)}catch(v){return Promise.reject(v)}for(_=0,m=h.length;_<m;)f=f.then(h[_++],h[_++]);return f}getUri(i){i=Ot(this.defaults,i);const t=Di(i.baseURL,i.url);return vi(t,i.params,i.paramsSerializer)}};b.forEach(["delete","get","head","options"],function(i){Bt.prototype[i]=function(t,e){return this.request(Ot(e||{},{method:i,url:t,data:(e||{}).data}))}}),b.forEach(["post","put","patch"],function(i){function t(e){return function(s,a,c){return this.request(Ot(c||{},{method:i,headers:e?{"Content-Type":"multipart/form-data"}:{},url:s,data:a}))}}Bt.prototype[i]=t(),Bt.prototype[i+"Form"]=t(!0)});let hc=class ur{constructor(i){if(typeof i!="function")throw new TypeError("executor must be a function.");let t;this.promise=new Promise(function(s){t=s});const e=this;this.promise.then(n=>{if(!e._listeners)return;let s=e._listeners.length;for(;s-- >0;)e._listeners[s](n);e._listeners=null}),this.promise.then=n=>{let s;const a=new Promise(c=>{e.subscribe(c),s=c}).then(n);return a.cancel=function(){e.unsubscribe(s)},a},i(function(s,a,c){e.reason||(e.reason=new Xt(s,a,c),t(e.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(i){if(this.reason){i(this.reason);return}this._listeners?this._listeners.push(i):this._listeners=[i]}unsubscribe(i){if(!this._listeners)return;const t=this._listeners.indexOf(i);t!==-1&&this._listeners.splice(t,1)}toAbortSignal(){const i=new AbortController,t=e=>{i.abort(e)};return this.subscribe(t),i.signal.unsubscribe=()=>this.unsubscribe(t),i.signal}static source(){let i;return{token:new ur(function(n){i=n}),cancel:i}}};function uc(r){return function(t){return r.apply(null,t)}}function dc(r){return b.isObject(r)&&r.isAxiosError===!0}const pn={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(pn).forEach(([r,i])=>{pn[i]=r});function ji(r){const i=new Bt(r),t=si(Bt.prototype.request,i);return b.extend(t,Bt.prototype,i,{allOwnKeys:!0}),b.extend(t,i,null,{allOwnKeys:!0}),t.create=function(n){return ji(Ot(r,n))},t}const j=ji(ne);j.Axios=Bt,j.CanceledError=Xt,j.CancelToken=hc,j.isCancel=Si,j.VERSION=Vi,j.toFormData=Ce,j.AxiosError=A,j.Cancel=j.CanceledError,j.all=function(i){return Promise.all(i)},j.spread=uc,j.isAxiosError=dc,j.mergeConfig=Ot,j.AxiosHeaders=rt,j.formToJSON=r=>Ti(b.isHTMLForm(r)?new FormData(r):r),j.getAdapter=Ui.getAdapter,j.HttpStatusCode=pn,j.default=j;const{Axios:Ac,AxiosError:Dc,CanceledError:Rc,isCancel:Ic,CancelToken:Oc,VERSION:Bc,all:Nc,Cancel:Mc,isAxiosError:Fc,spread:Uc,toFormData:Lc,AxiosHeaders:Vc,HttpStatusCode:qc,formToJSON:jc,getAdapter:Hc,mergeConfig:Kc}=j;class pc extends kt{constructor({filters:t=null,config_port:e=null,no_device:n=1,username:s=null,password:a=null,environment:c="production"}={}){super({filters:t,config_port:e,no_device:n});J(this,p);Z(this,"__pinPad__",{buffer:null,about:{EMV:null,model:null,serial:null,brand:null,appVersion:null,printer:null,hasCashback:!1,supportInjection:!1,supportSign:!1,supportContactlessCollisionCard:!1,supportContactless:!1,supportDUKPT:"",injectedValues:!1,pp:null},config:{defaultEnvironment:"production",environment:"production",currency:"MXN",currencyCode:"0484",timeoutPinPad:"100",signSupport:"1",CTLSSupport:"1",userTRX:"userPinpadWeb",tp_operation:"29",requireCVVAmex:"1",forceOnline:"00",emvCard:"0",validateQPS:"1",username:null,password:null,country:null,idBranch:null,idCompany:null,latitude:null,longitude:null,publicKeyRSA:null,publicIP:null,internal:{stTokenization:!1,qpsDomestic:"",qpsInternational:"",cvmlVMCDomestic:"",cvmlVMCInternational:"",cvmlAmex:"",translimitCTLSVMC:"",translimitCTLSAmex:"",emv:{}},terminal:{},loginResponse:null,otherLogin:{},RC4Key:"KEY CREDIT CARD KEY",read:{EMV:"",PIN:"",POSEM:"",AppId:"",AppIdLabel:"",Arqc:"",Chip:"",ChipName:"",ChipNameEnc:"",ReadCTLS:"",NB_Data:"",NB_ksn:"",Tags:"",Type:""},tokenizeTRX:!1},constants:{appVersion:"1.0.16",appName:"pinpapWebApp ",STX:"",ETX:"",FS:"",getNULL:"\0",appChannel:"3",typeChannel:"11",urls:{development:"https://fcdev.mitec.com.mx",qa:"https://fcqa.mitec.com.mx",production:"https://m.mit.com.mx",productionAlternative:"https://m2.mit.com.mx"},uris:{login:"/pinpadWeb/login",RSAKey:"/pinpadWeb/getDataCrypt",merchant:"/pinpadWeb/getAfiliaciones",consult:"/pinpadWeb/queryTrx",keysDUKPT:"/pinpadWeb/getKeysDUKPT",reverse:"/pinpadWeb/executeBackSale",rePrint:"/pinpadWeb/reprint",checkInMoto:"/pinpadWeb/checkin",checkOutMoto:"/pinpadWeb/checkout",reAuthorizationMoto:"/pinpadWeb/reAuthorization",cancellation:"/pinpadWeb/executeVoid",sale:"/pinpadWeb/executeSale"}},operation:{amount:0,reference:null,folio:null,authorization:null,errors:0,last_error:null,commerceVoucher:"",clientVoucher:"",consultDate:null,ignore:{counter:!1,counterSale:!1,isError92TRX:!1,C93Global:!1,error:""},finalResult:{},moto:{ccType:"",ccName:"",ccNumber:"",ccExpMonth:"",ccExpYear:"",ccCvvCsc:"",txRoom:""},bin:"",bin8:"",hasQPS:!1,onlyMerchant:"",merchant:null,typeOperation:"29",typeResponse:"",responseMit:{},applyReverse:!1},finishCommand:{A:"",B:"",C:"",D:"",E:"",F:"",G:"",H:"",I:"",J:"",K:""},waiting:{statusAboutWaiting:null,statusInjectWaiting:null,statusReadCardWaiting:null,statusSecondGenerateWaiting:null}});if(this.__internal__.device.type="pinpad",!_a())throw new Error("Crypto not supported in this browser");if(K.getCustom(this.typeDevice,n))throw new Error(`Device ${this.typeDevice} ${n} already exists`);this.__internal__.time.response_connection=3e3,this.__internal__.time.response_general=5e3,this.__internal__.serial.delay_first_connection=1e3,this.__internal__.serial.config_port.baudRate=19200,this.environment=c,s&&(this.username=s),a&&(this.password=a),o(this,p,pr).call(this),o(this,p,dr).call(this)}async timeout(t,e){await super.timeout(t,e),this.__pinPad__.waiting.statusAboutWaiting&&e==="about"?this.__pinPad__.waiting.statusAboutWaiting="rejected":this.__pinPad__.waiting.statusInjectWaiting&&e==="inject"?this.__pinPad__.waiting.statusInjectWaiting="rejected":this.__pinPad__.waiting.statusinitDUKPTWaiting&&e==="init-dukpt"?this.__pinPad__.waiting.statusinitDUKPTWaiting="rejected":this.__pinPad__.waiting.statuswritingDUKPTWaiting&&e==="dukpt"?this.__pinPad__.waiting.statuswritingDUKPTWaiting="rejected":this.__pinPad__.waiting.statusReadCardWaiting&&e==="read-card"?this.__pinPad__.waiting.statusReadCardWaiting="rejected":this.__pinPad__.waiting.statusSecondGenerateWaiting&&e==="second-generate"&&(this.__pinPad__.waiting.statusSecondGenerateWaiting="rejected")}serialMessage(t){const e={original_code:t,code:null,name:null,description:null,request:this.lastAction,no_code:0,parsed:null},n=this.parseHexToUint8(t),s=this.parseUint8ArrayToString(n);let a=o(this,p,fr).call(this,s);switch(this.__pinPad__.buffer=s,e.parsed=a,e.code=s,e.request){case"connect":e.name="connected",e.description="Connection established",e.no_code=100,o(this,p,wn).call(this,a,s);break;case"about":e.name="About PinPad",e.description="Response of about",e.no_code=101,o(this,p,wn).call(this,a,s);break;case"inject":e.name="Inject",e.description="Response of inject values",e.no_code=102,o(this,p,_r).call(this,a,s);break;case"init-dukpt":e.name="Init DUKPT",e.description="Response of init DUKPT",e.no_code=103,o(this,p,gr).call(this,a,s);break;case"dukpt":e.name="Write DUKPT",e.description="Response of write DUKPT",e.no_code=104,o(this,p,br).call(this,a,s);break;case"read-card":e.name="read card",e.description="response of read card",e.no_code=105,o(this,p,mr).call(this,a,s);break;case"second-generate":e.name="second generate",e.description="response of second generate",e.no_code=106,o(this,p,yr).call(this,a,s);break;case"cancel":e.name="cancel pinpad",e.description="response of cancel",e.no_code=107;break;case"print":o(this,p,Pr).call(this,a,s),e.name="print voucher",e.description="response of print",e.no_code=108;break;case"cancel-read-card":o(this,p,vr).call(this,a,s),e.name="cancel read card",e.description="response of cancel read card",e.no_code=109;break;case"code93":o(this,p,Er).call(this,a,s),e.name="code 93",e.description="response of code 93",e.no_code=110;break;case"finish-emv-end":o(this,p,Tr).call(this,a,s),e.name="Finish EMV End",e.description="response of finish EMV End",e.no_code=111;break;default:e.name="unknown",e.description="Unknown command",e.no_code=400;break}this.dispatch("serial:message",e)}serialSetConnectionConstant(t=1){const e="",n="";let s="C56AABOUT";s=e+s.length.toString().padStart(3,"0")+s+n;let a=0;for(let l=0;l<s.length;l++)a^=s.charCodeAt(l);s=s+String.fromCharCode(a);const c=this.parseStringToBytes(s,"");return this.add0x(c)}async sendCustomCode({code:t=""}={}){if(typeof t!="string")throw new Error("Invalid string");const e=this.parseStringToBytes(t);await this.appendToQueue(e,"custom")}set username(t){this.__pinPad__.config.username=t}get username(){return this.__pinPad__.config.username}set password(t){if(typeof t!="string")throw new Error("Invalid password");this.__pinPad__.config.password=t.toUpperCase()}get password(){return this.__pinPad__.config.password}set amount(t){if(t=parseFloat(t),isNaN(t)||t<=0)throw new Error("Invalid amount");this.__pinPad__.operation.amount=t.toFixed(2).toString()}get amount(){return parseFloat(this.__pinPad__.operation.amount)||0}set reference(t){if(!o(this,p,Tn).call(this,t.trim()))throw new Error("Invalid reference");this.__pinPad__.operation.reference=t.trim().toString().replaceAll(" ","").toUpperCase()}get reference(){return this.__pinPad__.operation.reference}get url(){const t=this.environment;return this.__pinPad__.constants.urls[t]}get version(){return{name:this.__pinPad__.constants.appName,version:this.__pinPad__.constants.appVersion,environment:this.environment,type:this.typeDevice}}set environment(t){const e=["development","qa","production","productionAlternative"];if(typeof t!="string"||!e.includes(t.toLowerCase()))throw new Error("The environment must be a string, in: "+e.join(", "));this.__pinPad__.config.defaultEnvironment=t.toLowerCase(),this.__pinPad__.config.environment=t.toLowerCase()}get defaultEnvironment(){return this.__pinPad__.config.defaultEnvironment}get environment(){return this.__pinPad__.config.environment}get latitudeLongitude(){return{latitude:this.__pinPad__.config.latitude,longitude:this.__pinPad__.config.longitude}}set timeoutPinPad(t){if(t=parseInt(t),isNaN(t)||t<=10||t>=300)throw new Error("Invalid timeout please use a number between 10 and 300 seconds");this.__pinPad__.config.timeoutPinPad=t.toString()}get timeoutPinPad(){return parseInt(this.__pinPad__.config.timeoutPinPad)}async login({force:t=!1}={}){return await o(this,p,Ar).call(this,t)}clearSession(){localStorage.removeItem("ppLoginResponse"),localStorage.removeItem("ppRSAKey"),localStorage.removeItem("ppPublicIP")}async checkPositionPermission(){if(!Wn())throw new Error("Geolocation not supported");return new Promise((t,e)=>{navigator.permissions.query({name:"geolocation"}).then(n=>{n.state==="granted"?t(!0):t(!1)}).catch(()=>e(!1))})}async cancelReadCard(){let t="012VXVCANCELl";this.__pinPad__.about.model.toLowerCase()==="ingenico"&&(t="029C50AOPERACION CANCELADA");const e=this.parseStringToBytes(t,"");await this.appendToQueue(e,"cancel-read-card")}async print(t="client"){this.__pinPad__.operation.errors=0;const e=this.__pinPad__.constants.STX,n=this.__pinPad__.constants.ETX;this.__pinPad__.operation.commerceVoucher.includes(":")||(this.__pinPad__.operation.commerceVoucher=o(this,p,Lt).call(this,this.__pinPad__.config.RC4Key,this.__pinPad__.operation.commerceVoucher)),this.__pinPad__.operation.clientVoucher.includes(":")||(this.__pinPad__.operation.clientVoucher=o(this,p,Lt).call(this,this.__pinPad__.config.RC4Key,this.__pinPad__.operation.clientVoucher));let s=t==="client"?this.__pinPad__.operation.clientVoucher:this.__pinPad__.operation.commerceVoucher;if(s.length===0){this.dispatch("pp:print",{error:!0,code:"001",message:"Without information to print"});return}s=o(this,p,kr).call(this,s),s=o(this,p,xr).call(this,s,this.__pinPad__.constants.appName+this.__pinPad__.constants.appVersion);let a="C59A"+s;a=e+o(this,p,mt).call(this,a)+a+n,a=a+o(this,p,yt).call(this,a),t==="client"?this.__pinPad__.operation.clientVoucher="":t==="commerce"&&(this.__pinPad__.operation.commerceVoucher="");const c=this.parseStringToBytes(a,"");await this.appendToQueue(c,"print")}getClientVoucher(){return this.__pinPad__.operation.clientVoucher}getCommerceVoucher(){return this.__pinPad__.operation.commerceVoucher}async consult({reference:t=null}){return t||(t=this.reference),Ct(t)&&(t="--",this.reference=t),o(this,p,Or).call(this,this.reference),this.__pinPad__.operation.consultDate=new Date().toLocaleDateString("en-GB"),await o(this,p,he).call(this,{Ambiente:this.environment,User:this.username,Pwd:this.password,IdBranch:this.__pinPad__.config.idBranch,IdCompany:this.__pinPad__.config.idCompany,Country:this.__pinPad__.config.country,Tx_Date:this.__pinPad__.operation.consultDate}),o(this,p,Qt).call(this,this.url+this.__pinPad__.constants.uris.consult,{user:this.username.toUpperCase(),pwd:this.password.toUpperCase(),id_branch:this.__pinPad__.config.idBranch.toUpperCase(),id_company:this.__pinPad__.config.idCompany.toUpperCase(),date:this.__pinPad__.operation.consultDate,reference:this.reference})}async rePrint({folio:t=null}={}){t===null&&(t=this.__pinPad__.operation.folio||""),o(this,p,Sn).call(this,t),await o(this,p,he).call(this,{Ambiente:this.environment,User:this.username,Pwd:this.password,IdBranch:this.__pinPad__.config.idBranch,IdCompany:this.__pinPad__.config.idCompany,Country:this.__pinPad__.config.country,Tx_OperationNumber:t});const e=await o(this,p,Qt).call(this,this.url+this.__pinPad__.constants.uris.rePrint,{REPRINTVOUCHER:{business:{country:this.__pinPad__.config.country.toUpperCase(),id_branch:this.__pinPad__.config.idBranch.toUpperCase(),id_company:this.__pinPad__.config.idCompany.toUpperCase(),pwd:this.password.toUpperCase(),user:this.username.toUpperCase()},no_operacion:t,crypto:"2"}});let n=e.voucher_comercio;return this.__pinPad__.operation.commerceVoucher="",n&&(e.voucher_comercio.includes(":")?this.__pinPad__.operation.commerceVoucher=e.voucher_comercio:this.__pinPad__.operation.commerceVoucher=o(this,p,Lt).call(this,this.__pinPad__.config.RC4Key,e.voucher_comercio)),n=e.voucher_cliente,this.__pinPad__.operation.clientVoucher="",n&&(e.voucher_cliente.includes(":")?this.__pinPad__.operation.clientVoucher=e.voucher_cliente:this.__pinPad__.operation.clientVoucher=o(this,p,Lt).call(this,this.__pinPad__.config.RC4Key,e.voucher_cliente)),e}async cancelPurchase({amount:t=0,authorization:e="",folio:n=""}={}){if(!o(this,p,Cn).call(this,t))throw new Error("Invalid amount");if(!o(this,p,zr).call(this,e))throw new Error("Invalid authorization");if(!o(this,p,Sn).call(this,n))throw new Error("Invalid folio");t=o(this,p,Rn).call(this,t,2);const s={Ambiente:this.environment,User:this.username,Pwd:this.password,IdBranch:this.__pinPad__.config.idBranch,IdCompany:this.__pinPad__.config.idCompany,Country:this.__pinPad__.config.country,UserTRX:"userPinpadWeb",Tx_OperationNumber:n,Tx_Auth:e,Amount:t};await o(this,p,he).call(this,s);const a=o(this,p,Qt).call(this,this.url+this.__pinPad__.constants.uris.cancellation,{VMCAMEXMCANCELACION:{business:{country:this.__pinPad__.config.country.toUpperCase(),id_branch:this.__pinPad__.config.idBranch.toUpperCase(),id_company:this.__pinPad__.config.idCompany.toUpperCase(),pwd:this.password.toUpperCase(),user:this.username.toUpperCase()},transacction:{amount:t,auth:e.toUpperCase(),crypto:"2",no_operacion:n,usrtransacction:this.username.toUpperCase(),version:this.__pinPad__.constants.appName+this.__pinPad__.constants.appVersion}}});return this.__pinPad__.operation.commerceVoucher="",a.voucher_comercio&&(a.voucher_comercio.includes(":")?this.__pinPad__.operation.commerceVoucher=a.voucher_comercio:this.__pinPad__.operation.commerceVoucher=o(this,p,Lt).call(this,this.__pinPad__.config.RC4Key,a.voucher_comercio)),this.__pinPad__.operation.clientVoucher="",a.voucher_cliente&&(a.voucher_cliente.includes(":")?this.__pinPad__.operation.clientVoucher=a.voucher_cliente:this.__pinPad__.operation.clientVoucher=o(this,p,Lt).call(this,this.__pinPad__.config.RC4Key,a.voucher_cliente)),JSON.stringify(a)}async makeSale({amount:t=0,reference:e=null}={}){if(t=parseFloat(t.toString()),isNaN(t)||t<=0)throw new Error("Amount is required and must be greater than 0");if(this.amount=t,!e||Ct(e)||!o(this,p,Tn).call(this,e))throw new Error("Reference is required and must be alphanumeric");if(this.reference=e,/^[A-Z-a-z\s]+$/g.test(this.__pinPad__.config.currency)===!1)throw new Error("Invalid currency");let n={error:!1,message:null,approved:!1,object:{}};try{return await this.login(),await o(this,p,qr).call(this),!await o(this,p,jr).call(this)||!await o(this,p,Ur).call(this)?n:await o(this,p,Gr).call(this)}catch(s){console.warn(s),n.error=!0,n.message=s.message,n.approved=!1,n.object=s}return n}}p=new WeakSet,dr=function(){K.addCustom("pinpad",this)},pr=function(){const t=["pp:processing-card","pp:read-card","pp:error","pp:print","pp:merchant-moto","pp:dukpt","pp:finish-emv","pp:response","pp:error","pp:finish-emv"];for(const e of t)this.serialRegisterAvailableListener(e)},fr=function(t){const e=this.__pinPad__.constants.STX,n=this.__pinPad__.constants.ETX,s=this.__pinPad__.constants.FS,a=this.__pinPad__.constants.getNULL;t=t.replace(new RegExp(e,"g"),"");const c=t.split(n);t=c[0];const l=t.split(s);l.push(...c[1].split(s));const h={};return l.map((f,_)=>{const m=_>0?f.substring(0,1):"A",P=_>0?f.substring(1):f;return{[m]:P.replace(new RegExp(a,"g"),"")}}).forEach(f=>Object.assign(h,f)),h},wn=function(t,e){const n=this.__pinPad__.constants.ETX,s=e.substring(e.indexOf("D")+2,e.indexOf("E"));let a=0;const c=e.indexOf("N")>0,l=e.substring(e.indexOf("A00")+3,e.indexOf("B"));if(l&&l!=="undefined"&&l.toUpperCase()==="VERIFONE"){const f=s.replace("MITP_1.00.","").replace("MITP_01.00.","").replace("MITD_1.00.","").replace("MITD_01.00.","");a=parseInt(f),a>=15&&(this.__pinPad__.about.hasCashback=!0)}this.__pinPad__.about.supportInjection=c,e.indexOf("M")>0?(this.__pinPad__.about.supportSign=e.substring(e.indexOf("L")+2,e.indexOf("M")),this.__pinPad__.about.supportInjection?this.__pinPad__.about.supportContactlessCollisionCard=e.substring(e.indexOf("M")+2,e.indexOf("N")):(this.__pinPad__.about.supportContactlessCollisionCard=e.substring(e.indexOf("M")+2,e.indexOf(n)),this.__pinPad__.about.supportContactless=!0)):(this.__pinPad__.about.supportSign=e.substring(e.indexOf("L")+2,e.indexOf(n)),this.__pinPad__.about.supportContactless=!1),this.__pinPad__.about.supportDUKPT=e.substring(e.indexOf("J")+2,e.indexOf("K")),this.__pinPad__.about.EMV=e.substring(e.indexOf("E")+2,e.indexOf("F")),this.__pinPad__.about.serial=e.substring(e.indexOf("C")+2,e.indexOf("D")),this.__pinPad__.about.printer=e.substring(e.indexOf("F")+2,e.indexOf("G")),this.__pinPad__.about.model=e.substring(e.indexOf("B")+2,e.indexOf("C")),this.__pinPad__.about.brand=l,this.__pinPad__.about.appVersion=s;const h=e.substring(e.indexOf("K")+2,e.indexOf("L"));this.__pinPad__.about.pp={brand:l,appVersion:s,versionInt:a,hasCashback:this.__pinPad__.about.hasCashback,supportInjection:this.__pinPad__.about.supportInjection,supportSign:this.__pinPad__.about.supportSign,supportContactlessCollisionCard:this.__pinPad__.about.supportContactlessCollisionCard,supportContactless:this.__pinPad__.about.supportContactless,supportDUKPT:this.__pinPad__.about.supportDUKPT,hasDUKPTKeys:h,EMV:this.__pinPad__.about.EMV,serial:this.__pinPad__.about.serial,printer:this.__pinPad__.about.printer,model:this.__pinPad__.about.model},this.__pinPad__.waiting.statusAboutWaiting&&(this.__pinPad__.waiting.statusAboutWaiting="resolved")},_r=function(t,e){this.__pinPad__.waiting.statusInjectWaiting="resolved"},gr=function(t,e){e=e.replace("010P93A00B01t036P81AACERQUE, INSERTE CHIP O DESLICE*",""),this.__pinPad__.config.terminal={nb_kcv:e.substring(e.indexOf("E")+2,e.indexOf("F")),nb_marca_terminal:e.substring(e.indexOf("P91A")+4,e.indexOf("B")),nb_modelo_terminal:e.substring(e.indexOf("B")+2,e.indexOf("C")),nb_serie_lector:e.substring(e.indexOf("C")+2,e.indexOf("D")),nb_tk:e.substring(e.indexOf("F")+2,e.length-2),nb_version_terminal:e.substring(e.indexOf("D")+2,e.indexOf("E"))},this.__pinPad__.waiting.statusinitDUKPTWaiting="resolved"},br=function(t,e){this.__pinPad__.waiting.statuswritingDUKPTWaiting="resolved"},mr=function(t,e){const n=this.__pinPad__.about.brand.toLowerCase(),s=this.__pinPad__.about.model.toLowerCase(),a=n==="ingenico"&&s==="ipp320"?500:350;if(e.length<a){e=e.replace("006P93A00.","").replace("006P93A00,",""),e.includes("E93")?this.__pinPad__.operation.ignore.error=e.substring(e.indexOf("E93")+3,e.indexOf("E93")+6):e.includes("E71")&&(this.__pinPad__.operation.ignore.error=e.substring(e.indexOf("E71")+3,e.indexOf("E71")+6)),this.__pinPad__.operation.ignore.error!==""&&e.indexOf("OPERACION CANCELADA")===-1&&e.indexOf("TIEMPO EXCEDIDO")===-1&&this.__pinPad__.operation.ignore.error.length===3&&(this.__pinPad__.operation.last_error=o(this,p,On).call(this,this.__pinPad__.operation.ignore.error),this.__pinPad__.waiting.statusReadCardWaiting="rejected");return}if(e.includes("M1")||e.includes("M0")||e.includes("M1")||e.includes("N1")||e.includes("N1")||e.includes("P93A022")&&e.substring(e.length-24).includes("I")&&e.substring(e.length-1).includes("")||e.includes("P93A800")&&e.substring(e.length-24).includes("I")&&e.substring(e.length-1).includes("")||e.includes("P93A022")&&e.length>=406&&s==="vx820"||e.includes("P93A022")&&e.length>=406&&s==="vx520"||e.includes("P93A800")&&e.length>=406&&s==="vx520"||e.includes("P93A800")&&e.length>=406&&s==="vx820"||e.includes("P93A022")&&e.length>=406&&s==="p400"||e.includes("P93A800")&&e.length>=406&&s==="p400"||e.includes("P93A022")&&e.length>=406&&s==="v205c"||e.includes("P93A800")&&e.length>=406&&s==="v205c"||e.includes("P93A022")&&e.length>=406&&s==="move2500"||e.includes("P93A800")&&e.length>=406&&s==="move2500"||e.includes("P93A022")&&e.length>=406&&s==="lane3000"||e.includes("P93A800")&&e.length>=406&&s==="lane3000"){let c=e;n==="verifone"&&(c=e.replace("006P93A00.","").substring(e.indexOf("P93A"),e.indexOf("P93A")+7)),e.includes("P81APROCESANDO, NO RETIRE TARJETA")||e.includes("P81APROCESANDO TARJETA")||c.includes("P93A022")||c.includes("P81AINSERTE CHIP O DESLICE TARJETA")||c.includes("ACERQUE, INSERTE CHIP O DESLICE")||c.includes("P81AACERQUE, INSERTE CHIP O DESLICE TARJETA")?this.dispatch("pp:processing-card",{waiting:!0}):e.length>a&&o(this,p,wr).call(this,e)}},yr=function(t,e){const n=this.__pinPad__.constants.ETX;let s=e.replace("023P81AFAVOR RETIRAR TARJ.","").replace("020P81A DECLINADA EMV ","").replace("020P81A DECLINADA EMV ","");s=s.substring(s.indexOf("B")+2,s.indexOf(n)),s.includes("006E93A16")&&(s="01"),this.__pinPad__.operation.applyReverse=s==="01"&&this.__pinPad__.operation.responseMit._approved&&this.__pinPad__.config.otherLogin.executeReverse==="1",this.__pinPad__.waiting.statusSecondGenerateWaiting="resolved"},wr=function(t){const e=this.__pinPad__.constants.ETX,n=this.__pinPad__.about.brand.toLowerCase();let s,a,c,l,h;n==="verifone"?t=t.replace("006P93A00.","").replace("009P93A00","").replace("010P93A00B01v",""):t=t.replace("006P93A00,",""),this.__pinPad__.config.read.POSEM=t.substring(t.indexOf("P93A")+4,t.indexOf("B"));const f=this.__pinPad__.config.read.POSEM;if(f==="051"||f==="071"){if(this.__pinPad__.config.read.Chip="1",this.__pinPad__.config.read.PIN=t.substring(t.indexOf("C")+2,t.indexOf("D")),this.__pinPad__.config.read.AppId=t.substring(t.indexOf("G")+2,t.indexOf("H")),this.__pinPad__.config.read.AppIdLabel=t.substring(t.indexOf("H")+2,t.indexOf("I")),this.__pinPad__.config.read.Arqc=t.substring(t.indexOf("F")+2,t.indexOf("G")),t.includes("O")){const _=t.substring(t.indexOf("P93A"));this.__pinPad__.config.read.ReadCTLS=_.substring(_.indexOf("M")+2,_.indexOf("N")),this.__pinPad__.operation.hasQPS=_.substring(_.indexOf("N")+2,_.indexOf("O"))==="1",this.__pinPad__.operation.bin8=_.substring(_.indexOf("O")+2,_.indexOf(e))}else if(t.includes("N")){const _=t.substring(t.indexOf("P93A"));this.__pinPad__.config.read.ReadCTLS=_.substring(_.indexOf("M")+2,_.indexOf("N")),this.__pinPad__.operation.hasQPS=_.substring(_.indexOf("N")+2,_.indexOf(e))==="1"}else{const _=t.substring(t.indexOf("P93A"),t.indexOf("M")+5);this.__pinPad__.config.read.ReadCTLS=_.substring(_.indexOf("M")+2,_.indexOf(e)),this.__pinPad__.operation.hasQPS=!1}this.__pinPad__.config.read.Tags=t.substring(t.indexOf("B")+2,t.indexOf("C")),this.__pinPad__.config.read.NB_ksn=t.substring(t.indexOf("K")+2,t.indexOf("M")),this.__pinPad__.config.read.NB_Data=t.substring(t.indexOf("D")+2,t.indexOf("E")),a=t.substring(t.indexOf("I")+2,t.indexOf("J")),c=t.substring(t.indexOf("E")+2,t.indexOf("F")),this.__pinPad__.config.read.ChipName=c,s=t.substring(t.indexOf("J")+2,t.indexOf("K"))}else{let _;if(this.__pinPad__.config.read.Chip="0",this.__pinPad__.config.read.PIN="",this.__pinPad__.config.read.AppId="",this.__pinPad__.config.read.Arqc="",this.__pinPad__.config.read.ReadCTLS="0",this.__pinPad__.config.read.AppIdLabel=t.substring(t.indexOf("H")+2,t.indexOf("I")),this.__pinPad__.config.read.Tags=t.substring(t.indexOf("B")+2,t.indexOf("C")),f==="022")if(t.includes("O")){const m=t.substring(t.indexOf("P93A"));this.__pinPad__.operation.bin8=m.substring(m.indexOf("O")+2,m.indexOf(e)),_=t.substring(t.indexOf("P93A022"),t.indexOf("I")+23),_=_.substring(_.indexOf("I")+2,_.lastIndexOf(""))}else _=t.substring(t.indexOf("P93A022"),t.indexOf("I")+23),_=_.substring(_.indexOf("I")+2,_.indexOf(e));else _=t.substring(t.indexOf("P93A800"),t.indexOf("I")+23),_=_.substring(_.indexOf("I")+2,_.indexOf(e));this.__pinPad__.config.read.NB_ksn=_,this.__pinPad__.config.read.NB_Data=t.substring(t.indexOf("B")+2,t.indexOf("C")),a=t.substring(t.indexOf("F")+2,t.indexOf("G")),s=t.substring(t.indexOf("G")+2,t.indexOf("H")),this.__pinPad__.about.model.toLowerCase()==="vx520"?(c=t.substring(t.indexOf("H")+2,t.indexOf("I")),this.__pinPad__.config.read.ChipName=c):(c=t.substring(t.indexOf("H")+2,t.indexOf("I")),this.__pinPad__.config.read.ChipName=c)}s.includes("/")&&(s=s.replace("/","")),s.toString().length===4?(h=s.toString().substring(0,2),l=s.toString().substring(2)):(h="",l=""),this.__pinPad__.config.read.Chip==="1"?(this.__pinPad__.config.read.EMV="3",this.__pinPad__.config.read.ChipNameEnc="1"):(this.__pinPad__.config.read.ChipNameEnc="",this.__pinPad__.config.read.EMV="2"),this.__pinPad__.config.read.AppIdLabel.toLowerCase().includes("american")||this.__pinPad__.config.read.AppIdLabel.toLowerCase().includes("amex")?this.__pinPad__.config.read.Type="AMEX":this.__pinPad__.config.read.Type="V/MC",this.__pinPad__.operation.bin=a,a.length>6&&(this.__pinPad__.operation.bin=a.substring(0,6)),this.__pinPad__.waiting.statusReadCardWaiting="resolved",this.dispatch("pp:read-card",{ERROR:"",maskPan:a,name:c,month:h,year:l})},vr=function(t,e){e.length>10&&e.includes("E93A10")&&(this.__pinPad__.waiting.statusReadCardWaiting==="pending"&&(this.__pinPad__.waiting.statusReadCardWaiting="rejected"),this.dispatch("pp:error",{message:"Operation cancelled by user."}))},Pr=function(t,e){const n=this;if(this.__pinPad__.about.model.toLowerCase()==="vx520"){if(e.length>11)if(e.includes("P59A00"))this.__pinPad__.operation.clientVoucher!==""?setTimeout(function(){n.print("client").then(()=>{}).catch(s=>{console.error(s)})},1e3):this.dispatch("pp:print",{type:"success"});else{const s=e.includes("E17")||e.includes("A17")?{type:"warning",message:"printer without paper"}:{type:"error",message:"The voucher could not be printed"};this.dispatch("pp:print",s)}}else if(e.includes("P59A00"))this.__pinPad__.operation.clientVoucher!==""?setTimeout(function(){n.print("client").then(()=>{}).catch(s=>{console.error(s)})},1e3):this.dispatch("pp:print",{type:"success"});else{const s=e.includes("E17")||e.includes("A17")?{type:"warning",message:"printer without paper"}:{type:"error",message:"The voucher could not be printed"};this.dispatch("pp:print",s)}},Er=function(t,e){},Tr=function(t,e){},ae=function(t,e){const n=new qa;return n.setPublicKey(t),n.encrypt(e)},oe=function(t){const e="0123456789ABCDEF";let n="";for(let s=0;s<t;s++){const a=Math.floor(Math.random()*e.length);n+=e.substring(a,a+1)}return n},Cr=function(t){const e="0123456789abcdef",n=[],s=[];for(let a=0;a<256;a++)n[a]=e.charAt(a>>4)+e.charAt(a&15);for(let a=0;a<t.length;a++)s[a]=n[t.charCodeAt(a)];return s.join("")},ce=async function(t,e){const n=new Uint8Array(t.match(/.{1,2}/g).map(m=>parseInt(m,16))),s=crypto.getRandomValues(new Uint8Array(16)),c=new TextEncoder().encode(e),l=await crypto.subtle.importKey("raw",n,{name:"AES-CBC"},!1,["encrypt"]),h=await crypto.subtle.encrypt({name:"AES-CBC",iv:s},l,c),f=btoa(String.fromCharCode(...s)),_=btoa(String.fromCharCode(...new Uint8Array(h)));return f+_},Sr=function(t,e,n=!1){const s=[];for(let f=0;f<256;f++)s[f]=f;let a=0;for(let f=0;f<256;f++)a=(a+s[f]+t.charCodeAt(f%t.length))%256,[s[f],s[a]]=[s[a],s[f]];let c=0,l=0,h="";for(const f of e){c=(c+1)%256,l=(l+s[c])%256,[s[c],s[l]]=[s[l],s[c]];let _=s[(s[c]+s[l])%256];h+=String.fromCharCode(f.charCodeAt(0)^_)}return n?o(this,p,Cr).call(this,h).toUpperCase():h},Lt=function(t,e){return o(this,p,Sr).call(this,t,this.hexToAscii(e))},kr=function(t){return t.replaceAll("Á","A"),t.replaceAll("É","E"),t.replaceAll("Í","I"),t.replaceAll("Ó","O"),t.replaceAll("Ú","U"),t.replaceAll("á","a"),t.replaceAll("é","e"),t.replaceAll("í","i"),t.replaceAll("ó","o"),t.replaceAll("ú","u"),t.replaceAll("ñ","n"),t.replaceAll("Ñ","N"),t.replaceAll('Electr?a"',"Electronica"),t},$=function(t,e,n){if(t=t.replace("@cnb logo_cpagos",e),t=t.replace("@cnn ver_app",n),t=t.replace(/@/g," @"),t=t.replace(/ {2}@/g," @"),t=t.replace(/ {3}@/g," @"),t=t.replace(/\r/g,""),t=t.replace(/\n/g,""),t.includes("@lsn POR ESTE PAGARE ME OBLIGO INCONDI")){const s=t.indexOf("@lsn POR ESTE PAGARE ME OBLIGO INCONDI");t=t.substring(0,s)}return t.trim()+"@br @br @br @br @br"},xr=function(t,e){const n="@logo3 @br",s="@cnn "+e;return t.includes("@cnb Santander")?(t=t.replace("@cnb Santander","@logo1@br"),o(this,p,$).call(this,t,n,s)):t.includes("@cnb American Express")?(t=t.replace("@cnb American Express","@logo2@br"),o(this,p,$).call(this,t,n,s)):t.includes("@cnb HSBC")?(t=t.replace("@cnb HSBC","@logo7@br"),o(this,p,$).call(this,t,n,s)):t.includes("@cnb IXE")?(t=t.replace("@cnb IXE","@logo11@br"),o(this,p,$).call(this,t,n,s)):t.includes("@cnb MULTIVA")?(t=t.replace("@cnb MULTIVA","@logo15@br"),o(this,p,$).call(this,t,n,s)):t.includes("@cnb Multiva")?(t=t.replace("@cnb Multiva","@logo15@br"),o(this,p,$).call(this,t,n,s)):t.includes("@cnb SCOTIA BANK")?(t=t.replace("@cnb SCOTIA BANK","@logo16@br"),o(this,p,$).call(this,t,n,s)):t.includes("@cnb SCOTIABANK")?(t=t.replace("@cnb SCOTIABANK","@logo16@br"),o(this,p,$).call(this,t,n,s)):t.includes("@cnb BANCOMER")?(t=t.replace("@cnb BANCOMER","@logo17@br"),o(this,p,$).call(this,t,n,s)):t.includes("@cnb Bancomer")?(t=t.replace("@cnb Bancomer","@logo17@br"),o(this,p,$).call(this,t,n,s)):t.includes("@cnb BBVA")?(t=t.replace("@cnb BBVA","@logo17@br"),o(this,p,$).call(this,t,n,s)):t.includes("@cnb BANORTE")?(t=t.replace("@cnb BANORTE","@logo18@br"),o(this,p,$).call(this,t,n,s)):t.includes("@cnb Banorte")?(t=t.replace("@cnb Banorte","@logo18@br"),o(this,p,$).call(this,t,n,s)):t.includes("@cnb BANREGIO")?(t=t.replace("@cnb BANREGIO","@logo19@br"),o(this,p,$).call(this,t,n,s)):t.includes("@cnb Banregio")?(t=t.replace("@cnb Banregio","@logo19@br"),o(this,p,$).call(this,t,n,s)):t.includes("@cnb GETNET")?(t=t.replace("@cnb GETNET","@logo20@br"),o(this,p,$).call(this,t,n,s)):t.includes("@cnb GetNET")?(t=t.replace("@cnb GetNET","@logo20@br"),o(this,p,$).call(this,t,n,s)):o(this,p,$).call(this,t,n,s)},Ar=async function(t=!1){if(o(this,p,Rr).call(this),this.__pinPad__.config.loginResponse&&!t)return await o(this,p,vn).call(this);const e=this.url+this.__pinPad__.constants.uris.login,n={usuario:this.username,password:this.password,crypto:"",version:this.__pinPad__.constants.appVersion,serieLector:"",canal:this.__pinPad__.constants.appChannel};if(await o(this,p,le).call(this),o(this,p,Pn).call(this))throw new Error("Empty RSA Key");const s=o(this,p,oe).call(this,32),a=o(this,p,ae).call(this,this.__pinPad__.config.publicKeyRSA,s),c=await o(this,p,ce).call(this,s,JSON.stringify(n)),l=await j.post(e,c,{headers:{"Content-Type":"application/json","cache-control":"no-cache, must-revalidate, post-check=0, pre-check=0, max-age=0",data:a||""}}).catch(f=>{var _;throw new Error(`Error in request, verify internet connection: ${(_=f.response)==null?void 0:_.status} ${f.message}`)});let h=o(this,p,kn).call(this,JSON.stringify(l.data));if(typeof h=="string"&&(h=JSON.parse(h)),!h)throw new Error("Invalid response JSON");if(h.RESPUESTA==="error")throw new Error(h);return this.__pinPad__.config.loginResponse=h,localStorage.setItem("ppLoginResponse",JSON.stringify({timestamp:new Date().getTime(),data:h})),await o(this,p,vn).call(this)},vn=async function(){await o(this,p,Mr).call(this);try{await o(this,p,Nr).call(this)}catch(t){console.log("Error getting position",t)}return this.__pinPad__.config.otherLogin={},o(this,p,Dr).call(this,this.__pinPad__.config.loginResponse),this.__pinPad__.config.otherLogin},Dr=function(t){var a,c,l,h,f,_;let e="",n="";(c=(a=t.xml)==null?void 0:a.ventaspropias)!=null&&c.merchant_currencyb&&(e=t.xml.ventaspropias.merchant_currencyb),(h=(l=t.xml)==null?void 0:l.ventaspropias)!=null&&h.merchant_currencym&&(n=t.xml.ventaspropias.merchant_currencym);let s=(f=t.xml)==null?void 0:f.emvReverso;s||(s="0"),this.__pinPad__.config.internal.stTokenization=(_=t.xml)==null?void 0:_.st_tokenizacion,!this.__pinPad__.config.internal.stTokenization||this.__pinPad__.config.internal.stTokenization==="false"||this.__pinPad__.config.internal.stTokenization==="0"?this.__pinPad__.config.internal.stTokenization=!1:this.__pinPad__.config.internal.stTokenization&&(this.__pinPad__.config.internal.stTokenization=!0),this.__pinPad__.config.internal.emv=t.xml.importesPGS,this.__pinPad__.config.internal.qpsDomestic=this.__pinPad__.config.internal.emv.qps_dom,this.__pinPad__.config.internal.qpsInternational=this.__pinPad__.config.internal.emv.qps_il,this.__pinPad__.config.internal.cvmlVMCDomestic=this.__pinPad__.config.internal.emv.cvml_vm_dom,this.__pinPad__.config.internal.cvmlVMCInternational=this.__pinPad__.config.internal.emv.cvml_vm_il,this.__pinPad__.config.internal.cvmlAmex=this.__pinPad__.config.internal.emv.cvml_amex,this.__pinPad__.config.internal.translimitCTLSVMC=this.__pinPad__.config.internal.emv.tl_mc,this.__pinPad__.config.internal.translimitCTLSAmex=this.__pinPad__.config.internal.emv.tl_amex,this.__pinPad__.config.country=t.country.toUpperCase(),this.__pinPad__.config.idBranch=t.id_branch.toUpperCase(),this.__pinPad__.config.idCompany=t.id_company.toUpperCase(),this.__pinPad__.config.otherLogin={bsUser:t.user,nbUser:t.nb_user,bsCompany:t.id_company,nbCompany:t.nb_company,nbStreetCompany:t.nb_companystreet,bsBranch:t.id_branch,nbBranch:t.nb_branch,bsCountry:t.country,coins:e,coinsMOTO:n,executeReverse:s}},Rr=function(){let t=localStorage.getItem("ppLoginResponse");t&&(t=JSON.parse(t),this.__pinPad__.config.loginResponse||(this.__pinPad__.config.loginResponse=t.data),new Date().getTime()-t.timestamp>=864e5&&(this.__pinPad__.config.loginResponse=null))},Ir=async function(){const t=this.url+this.__pinPad__.constants.uris.RSAKey,e=await j.get(t).catch(n=>{throw new Error(`Error in request, verify internet connection: ${n.response.status} ${n.message}`)});if(e.headers.get("content-type").indexOf("application/json")===-1)throw new Error("Fail to fetch RSA public key");return this.__pinPad__.config.publicKeyRSA=e.data.key_public,localStorage.setItem("ppRSAKey",JSON.stringify({timestamp:new Date().getTime(),data:e.data.key_public})),this.__pinPad__.config.publicKeyRSA},Pn=function(){let t=localStorage.getItem("ppRSAKey");return!t||(t=JSON.parse(t),this.__pinPad__.config.publicKeyRSA=t.data,new Date().getTime()-t.timestamp>=864e5)?!0:!this.__pinPad__.config.publicKeyRSA},En=async function(){return o(this,p,Pn).call(this)?await o(this,p,Ir).call(this):this.__pinPad__.config.publicKeyRSA},le=async function(){if(!await o(this,p,En).call(this))throw new Error("RSA public key is empty")},Tn=function(t){return/^[A-Z-a-z0-9\s]+$/g.test(t)},Or=function(t){if(Ct(t))return!0;const e=/^[A-Z-a-z0-9\s]+$/g.test(t)===!0;if(!e)throw new Error("Invalid reference");return e},mt=function(t){return t.length.toString().padStart(3,"0")},yt=function(t){let e=0;for(let n=0;n<t.length;n++)e^=t.charCodeAt(n);return String.fromCharCode(e)},Ue=function(t,e=0){return t=parseFloat(t.toString().replace(/[^0-9.-]/g,"")),isNaN(t)?0 .toFixed(e):t.toFixed(e).replace(/,/g,"")},Cn=function(t){return t=parseFloat(t.toString()),!(isNaN(t)||t<0)},he=async function(t){for(const e in t)if(typeof t[e]>"u"||t[e]===null||t[e]==="")throw new Error("Object incomplete to process");return t},Sn=function(t){if(!t||isNaN(parseInt(t))||t.toString().length!==9)throw new Error("Number of operation must be number of 9 digits");return t},kn=function(t){if(typeof t!="string")throw new Error("Invalid string");return!t||/<html(?:\s+lang=["'][^"']*["'])?>/i.test(t)||(t=t.replace(/aaa/g,"á"),t=t.replace(/eee/g,"é"),t=t.replace(/iii/g,"í"),t=t.replace(/ooo/g,"ó"),t=t.replace(/uuu/g,"ú"),t=t.replace(/NNN/g,"Ñ"),t=t.replace(/nnn/g,"ñ"),t=t.replace(/á/g,"á")),t},Br=async function(){const t=this.__pinPad__.constants.STX,e=this.__pinPad__.constants.ETX;let n="C55ACANCEL";n=t+o(this,p,mt).call(this,n)+n+e,n=n+o(this,p,yt).call(this,n);const s=this.parseStringToBytes(n,"");await this.appendToQueue(s,"cancel")},xn=function(){const t=new Date,e=t.getDate().toString().padStart(2,"0"),n=(t.getMonth()+1).toString().padStart(2,"0"),s=t.getFullYear().toString().substring(2);return e+n+s},An=function(){const t=new Date,e=t.getHours().toString().padStart(2,"0"),n=t.getMinutes().toString().padStart(2,"0");return e+n},Nr=async function(){return this.__pinPad__.config.latitude&&this.__pinPad__.config.longitude?this.latitudeLongitude:(this.__pinPad__.config.latitude=null,this.__pinPad__.config.longitude=null,Wn()?new Promise(t=>{navigator.geolocation.getCurrentPosition(e=>{this.__pinPad__.config.latitude=e.coords.latitude,this.__pinPad__.config.longitude=e.coords.longitude,t(this.latitudeLongitude)},()=>{t(this.latitudeLongitude)})}):this.latitudeLongitude)},Mr=async function(){let t=localStorage.getItem("ppPublicIP");if(t&&(t=JSON.parse(t),this.__pinPad__.config.publicIP=t.data,new Date().getTime()-t.timestamp>=864e5&&(this.__pinPad__.config.publicIP=null)),this.__pinPad__.config.publicIP)return this.__pinPad__.config.publicIP;this.__pinPad__.config.publicIP=null;let e=!1;const n=await j.get("https://api.ipify.org?format=json").catch(()=>e=!0);return e?null:(this.__pinPad__.config.publicIP=n.data.ip||null,localStorage.setItem("ppPublicIP",JSON.stringify({timestamp:new Date().getTime(),data:n.data.ip})),this.__pinPad__.config.publicIP)},Qt=async function(t,e){await o(this,p,le).call(this);const n=o(this,p,oe).call(this,32);let s=o(this,p,ae).call(this,this.__pinPad__.config.publicKeyRSA,n),a=await o(this,p,ce).call(this,n,JSON.stringify(e));return(await j.post(t,a,{headers:{"Content-Type":"application/json","cache-control":"no-cache",data:s||""}}).catch(l=>{var h;throw l.response.data.includes("Ha ocurrido un error al procesar su solicitud.")?new Error("It was not possible to obtain the affiliations."):l.response.status>=500&&l.response.status<=599?new Error(`Service Temporarily Unavailable ${l.message}`):new Error(`Error in request, verify internet connection: ${(h=l.response)==null?void 0:h.status} ${l.message}`)})).data},Dn=async function({data:t,url:e,cancelable:n=!1}={}){await o(this,p,le).call(this);const s=o(this,p,oe).call(this,32),a=o(this,p,ae).call(this,this.__pinPad__.config.publicKeyRSA,s),c=await o(this,p,ce).call(this,s,JSON.stringify(t)),l=this;return(await j.post(e,c,{headers:{"Content-Type":"application/json","cache-control":"no-cache",data:a||""}}).catch(async f=>{var m;let _=`Error in request, verify internet connection: ${f.status} ${f.message}`;throw f.response.status>=500&&f.response.status<=599?_="Service Temporarily Unavailable":f.response.status>=400&&f.response.status<=499&&(_="Bad Request"),n&&await o(m=l,p,Br).call(m),new Error(_)})).data},Fr=async function(){const t=this.__pinPad__.constants.FS,e=this.__pinPad__.constants.ETX,n=this.__pinPad__.constants.STX;let s="C57A"+this.__pinPad__.config.internal.qpsDomestic;if(s=s+t+"B"+this.__pinPad__.config.internal.qpsInternational,s=s+t+"C"+this.__pinPad__.config.internal.cvmlVMCDomestic,s=s+t+"D"+this.__pinPad__.config.internal.cvmlVMCInternational,s=s+t+"E"+this.__pinPad__.config.internal.cvmlAmex,s=s+t+"F"+this.__pinPad__.config.internal.translimitCTLSVMC,s=s+t+"G"+this.__pinPad__.config.internal.translimitCTLSAmex,s=n+o(this,p,mt).call(this,s)+s+e,s=s+o(this,p,yt).call(this,s),!this.__pinPad__.about.injectedValues){const a=this.parseStringToBytes(s,"");await this.appendToQueue(a,"inject")}},Ur=async function(){this.__pinPad__.operation.bin8&&(this.__pinPad__.operation.bin=this.__pinPad__.operation.bin8),this.__pinPad__.operation.bin8="";const t=await o(this,p,Dn).call(this,{data:{accion:"tipoPagoInfo",cc_num:this.__pinPad__.operation.bin,usuario:this.username.toUpperCase(),canal:this.__pinPad__.constants.typeChannel,tp_canal:"1",tp_moneda:this.__pinPad__.config.currency.toUpperCase()},url:this.url+this.__pinPad__.constants.uris.merchant,cancelable:!0});if(!t.respuesta||t.respuesta==="0"){let e="C55ACANCEL";const n=this.__pinPad__.constants.STX,s=this.__pinPad__.constants.ETX;e=n+o(this,p,mt).call(this,e)+e+s,e=e+o(this,p,yt).call(this,e);const a=this.parseStringToBytes(e,"");return await this.appendToQueue(a,"cancel"),!1}return this.__pinPad__.operation.merchant=t,this.__pinPad__.operation.onlyMerchant=t.contado.af.length>1?t.contado.af[0].merchant:t.contado.af.merchant,!0},Lr=async function(t=null){if(this.__pinPad__.waiting.statusAboutWaiting)throw new Error("AboutPP is already running");const e=this.__pinPad__.constants.STX,n=this.__pinPad__.constants.ETX;let s="C56AABOUT";if(s=e+o(this,p,mt).call(this,s)+s+n,s=s+o(this,p,yt).call(this,s),Ct(this.__pinPad__.about.pp)){this.__pinPad__.waiting.statusAboutWaiting="pending";const l=this.parseStringToBytes(s,"");await this.appendToQueue(l,"about")}else return t?t(this.__pinPad__.about.pp.supportDUKPT,this.__pinPad__.about.pp.hasDUKPTKeys):!0;const a=this;let c=0;return new Promise((l,h)=>{c=setInterval(()=>{if(a.__pinPad__.waiting.statusAboutWaiting==="resolved"){if(clearInterval(c),a.__pinPad__.waiting.statusAboutWaiting=null,Ct(a.__pinPad__.about.pp))return;t||l(!0),l(t(a.__pinPad__.about.pp.supportDUKPT,a.__pinPad__.about.pp.hasDUKPTKeys))}else a.__pinPad__.waiting.statusAboutWaiting==="rejected"&&(clearInterval(c),a.__pinPad__.waiting.statusAboutWaiting=null,h("Error"))},500)})},Le=async function(t,e){if(t=t?t.toString():"",e=e?e.toString():"",Ct(t)||t==="0"){this.dispatch("pp:dukpt",{status:"unsupported",already:!1});return}if(Ct(e)||e==="1"){this.dispatch("pp:dukpt",{status:"charged",already:!0});return}const n=o(this,p,xn).call(this),s=o(this,p,An).call(this),a=this.__pinPad__.constants.FS,c=this.__pinPad__.constants.ETX,l=this.__pinPad__.constants.STX;let h="C91A"+n+a+"B"+s;h=l+o(this,p,mt).call(this,h)+h+c,h=h+o(this,p,yt).call(this,h);const f=this.parseStringToBytes(h,"");await this.appendToQueue(f,"init-dukpt");let _=0;this.__pinPad__.waiting.statusinitDUKPTWaiting="pending";const m=this;return new Promise((P,v)=>{_=setInterval(async()=>{var S;m.__pinPad__.waiting.statusinitDUKPTWaiting==="resolved"?(clearInterval(_),m.__pinPad__.waiting.statusinitDUKPTWaiting=null,m.dispatch("pp:dukpt",{status:"charged",already:!1}),await o(S=m,p,Vr).call(S),P(!0)):m.__pinPad__.waiting.statusinitDUKPTWaiting==="rejected"&&(clearInterval(_),m.__pinPad__.waiting.statusinitDUKPTWaiting=null,v("Error"))},500)})},Vr=async function(){const t={IPEK_REQUESTType:{business:{country:this.__pinPad__.config.country.toUpperCase(),id_branch:this.__pinPad__.config.idBranch.toUpperCase(),id_company:this.__pinPad__.config.idCompany.toUpperCase(),pwd:this.password.toUpperCase(),user:this.username.toUpperCase()},terminal:this.__pinPad__.config.terminal}},e=await o(this,p,Dn).call(this,{data:t,url:this.url+this.__pinPad__.constants.uris.keysDUKPT});await o(this,p,Zr).call(this,e)},qr=async function(){if(!await o(this,p,En).call(this))throw new Error("RSA public key is empty");const e=this;await o(this,p,Lr).call(this,async function(s,a){var l,h;if(e.__pinPad__.about.supportInjection&&e.__pinPad__.config.internal.emv&&e.__pinPad__.about.injectedValues)return await o(l=e,p,Le).call(l,s,a),!0;let c=0;return e.__pinPad__.waiting.statusInjectWaiting="pending",await o(h=e,p,Fr).call(h),new Promise((f,_)=>{c=setInterval(async()=>{var m;e.__pinPad__.waiting.statusInjectWaiting==="resolved"?(clearInterval(c),e.__pinPad__.waiting.statusInjectWaiting=null,await o(m=e,p,Le).call(m,s,a),f(!0)):e.__pinPad__.waiting.statusInjectWaiting==="rejected"&&(clearInterval(c),e.__pinPad__.waiting.statusInjectWaiting=null,_("Error"))},500)})})},Rn=function(t,e=0){if(t=parseFloat(t.toString().replace(/[^0-9.-]/g,"")),isNaN(t)||t===0)return parseFloat("0").toFixed(e);t=t.toFixed(e);let n=t.split(".");return n[0]=n[0].replace(/\B(?=(\d{3})+(?!\d))/g,""),n.join(".")},jr=async function(){this.__pinPad__.operation.errors=0;let t="ACERQUE, INSERTE CHIP O DESLICE TARJETA";if(this.__pinPad__.about.supportContactless||(t="INSERTE CHIP O DESLICE TARJETA"),this.__pinPad__.about.model.toUpperCase().includes("UX300")&&(t="ACERQUE O INSERTE TARJETA"),Ct(this.amount)||this.amount<=0)throw new Error("Amount required");if(o(this,p,Cn).call(this,this.amount)===!1)throw new Error("Invalid amount required");if(o(this,p,Ue).call(this,this.amount,2)<=0)throw new Error("Amount must be greater than 0");const e=this.__pinPad__.constants.FS,n=this.__pinPad__.constants.STX,s=this.__pinPad__.constants.ETX;let a="C93A"+t;a=a+e+"B"+o(this,p,xn).call(this),a=a+e+"C"+o(this,p,An).call(this),a=a+e+"D"+o(this,p,Ue).call(this,this.amount,2),a=a+e+"E0.00",a=a+e+"F"+this.__pinPad__.config.currencyCode,this.__pinPad__.about.supportDUKPT&&this.__pinPad__.about.supportDUKPT!=="0"&&this.__pinPad__.about.supportDUKPT!=="false"&&(this.__pinPad__.about.supportContactless?(a=a+e+"G"+this.timeoutPinPad,a=a+e+"HTAGS",a=a+e+"I"+this.__pinPad__.config.requireCVVAmex,a=a+e+"J"+this.__pinPad__.config.forceOnline,a=a+e+"K"+this.__pinPad__.about.supportContactless,a=a+e+"L"+this.__pinPad__.config.emvCard,this.__pinPad__.about.hasCashback&&(a=a+e+"M0",a=a+e+"N00")):(a=a+e+"G"+this.timeoutPinPad,a=a+e+"HTAGS",a=a+e+"I"+this.__pinPad__.config.requireCVVAmex,a=a+e+"L"+this.__pinPad__.config.emvCard),this.__pinPad__.about.supportInjection&&(a=a+e+"O"+this.__pinPad__.config.validateQPS)),a=n+o(this,p,mt).call(this,a)+a+s,a=a+o(this,p,yt).call(this,a),o(this,p,Yr).call(this);const c=this.parseStringToBytes(a,"");await this.appendToQueue(c,"read-card");let l=0;const h=this;return this.__pinPad__.waiting.statusReadCardWaiting="pending",new Promise((f,_)=>{l=setInterval(()=>{if(h.__pinPad__.waiting.statusReadCardWaiting==="resolved")clearInterval(l),h.__pinPad__.waiting.statusReadCardWaiting=null,f(!0);else if(h.__pinPad__.waiting.statusReadCardWaiting==="rejected"){clearInterval(l),h.__pinPad__.waiting.statusReadCardWaiting=null;const m=h.__pinPad__.operation.last_error;_(m??"Error reading card")}},500)})},Hr=async function(t){return await dt(t*1e3)},Kr=async function(t){let e=this.url+this.__pinPad__.constants.uris.consult;return t>1&&this.environment==="production"&&(e=e.replace(this.__pinPad__.constants.urls.production,this.__pinPad__.constants.urls.productionAlternative)),this.__pinPad__.operation.consultDate=new Date().toLocaleDateString("en-GB"),await o(this,p,Qt).call(this,e,{user:this.username.toUpperCase(),pwd:this.password.toUpperCase(),id_branch:this.__pinPad__.config.idBranch.toUpperCase(),id_company:this.__pinPad__.config.idCompany.toUpperCase(),date:this.__pinPad__.operation.consultDate,reference:this.reference})},Wr=async function(t="",e={}){let n=1,s=null;do{n>1&&this.environment==="production"&&(t=t.replace(this.__pinPad__.constants.urls.production,this.__pinPad__.constants.urls.productionAlternative),await o(this,p,Hr).call(this,5)),await o(this,p,le).call(this);const a=o(this,p,oe).call(this,32),c=o(this,p,ae).call(this,this.__pinPad__.config.publicKeyRSA,a),l=await o(this,p,ce).call(this,a,JSON.stringify(e));let h=!1;const f=await j.post(t,l,{headers:{"Content-Type":"application/json",data:c||""}}).catch(async _=>{let m=`Error in request, verify internet connection: ${_.status} ${_.message}`;_.response.status>=500&&_.response.status<=599?m="Service Temporarily Unavailable":_.response.status>=400&&_.response.status<=499&&(m="Bad Request"),console.warn(_),s=m;const P=await o(this,p,Kr).call(this,n);P&&P!=="{}"&&!P.includes('"transacciones":""')&&P.includes("nu_operaion")&&(n=5,s="EE32"),h=!0});if(!h)return f.data}while(n++<=3);return s?Promise.reject(s):Promise.reject("Communication error with CDP. IL/MTY")},zr=function(t){if(Ct(t))throw new Error("Number of authorization invalid");if(/^[A-Za-z0-9]+$/g.test(t)!==!0)throw new Error("Number of authorization invalid");if(t.length!==6)throw new Error("Number of authorization invalid");return!0},Xr=function(t){var s,a;const e=this;this.__pinPad__.operation.responseMit._approved=t.response==="approved",this.__pinPad__.operation.responseMit._status=t.response,this.__pinPad__.operation.responseMit._originalToken=t.number_tkn??"",this.__pinPad__.operation.folio=t.foliocpagos,this.__pinPad__.operation.authorization=t.auth;let n=(s=t.cd_response)==null?void 0:s.toUpperCase();return n.toUpperCase()==="0C"||this.__pinPad__.operation.responseMit._approved?n="00":(n!=="Z3"&&n!=="05"||t.cd_error==="92")&&(n="01"),this.__pinPad__.operation.responseMit._cdResponse=n,this.__pinPad__.finishCommand.A=n,this.__pinPad__.finishCommand.B="",this.__pinPad__.finishCommand.C="",this.__pinPad__.finishCommand.D="",this.__pinPad__.finishCommand.E=t.emv_key_date?t.emv_key_date:"",this.__pinPad__.finishCommand.F=t.icc_csn?t.icc_csn:"",this.__pinPad__.finishCommand.G=t.icc_atc?t.icc_atc:"",this.__pinPad__.finishCommand.H=t.icc_arpc?t.icc_arpc:"",this.__pinPad__.finishCommand.I=t.icc_issuer_script?t.icc_issuer_script:"",this.__pinPad__.finishCommand.J=t.authorized_amount?t.authorized_amount:"",this.__pinPad__.finishCommand.K=t.account_balance_1?t.account_balance_1:"",{reference:t.reference,response:t.response,foliocpagos:t.foliocpagos,auth:t.auth,cd_response:n,cd_error:t.cd_error,nb_error:o(a=e,p,kn).call(a,t.nb_error??""),time:t.time,date:t.date,nb_company:t.nb_company,nb_merchant:t.nb_merchant,nb_street:t.nb_street,cc_type:t.cc_type,tp_operation:t.tp_operation,cc_name:t.cc_name,cc_number:t.cc_number,cc_expmonth:t.cc_expmonth,cc_expyear:t.cc_expyear,amount:t.amount,voucher_comercio:t.voucher_comercio,voucher_cliente:t.voucher_cliente,friendly_response:t.friendly_response,appid:t.appid,appidlabel:t.appidlabel,arqc:t.arqc}},Gr=async function(){var s,a;const t=this;this.__pinPad__.operation.errors=0,this.__pinPad__.operation.ignore.counterSale=!1;const e=this.__pinPad__.operation.onlyMerchant;if(/^[0-9]+$/.test(e)===!1)throw new Error("Invalid merchant");this.__pinPad__.operation.typeOperation="29";let n={error:!1,message:null,approved:!1,object:{}};try{const c=await o(this,p,Rn).call(this,this.amount,2);await o(this,p,he).call(this,{Ambiente:this.environment,Country:this.__pinPad__.config.country,IdBranch:this.__pinPad__.config.idBranch,IdCompany:this.__pinPad__.config.idCompany,pwd:this.password,User:this.username,UserTRX:"userPinpadWeb",EMV:this.__pinPad__.config.read.EMV,ModeloTerminal:this.__pinPad__.about.model,SerieTerminal:this.__pinPad__.about.serial,Contactless:this.__pinPad__.about.supportContactless,Printer:this.__pinPad__.about.printer,VersionTerminal:this.__pinPad__.about.appVersion,TpOperation:this.__pinPad__.operation.typeOperation,Reference:this.reference,Amount:c,Currency:this.__pinPad__.config.currency,Merchant:e,Reverse:this.__pinPad__.config.otherLogin.executeReverse});const l=this.__pinPad__.about.supportContactless&&this.__pinPad__.about.supportContactless!=="0"?"1":"0",h=await o(this,p,Wr).call(this,this.url+this.__pinPad__.constants.uris.sale,{VMCAMEXB:{business:{country:this.__pinPad__.config.country.toUpperCase(),id_branch:this.__pinPad__.config.idBranch.toUpperCase(),id_company:this.__pinPad__.config.idCompany.toUpperCase(),pwd:this.password.toUpperCase(),user:this.username.toUpperCase()},dcc:{dcc_amount:"0",dcc_status:"0"},transacction:{amount:c,creditcard:{appid:this.__pinPad__.config.read.AppId,appidlabel:this.__pinPad__.config.read.AppIdLabel,arqc:this.__pinPad__.config.read.Arqc,chip:this.__pinPad__.config.read.Chip,chipname:this.__pinPad__.config.read.ChipName,chipnameenc:this.__pinPad__.config.read.ChipNameEnc,contactless:this.__pinPad__.config.read.ReadCTLS,crypto:"4",dukpt:{nb_data:this.__pinPad__.config.read.NB_Data,nb_ksn:this.__pinPad__.config.read.NB_ksn,tp_dukpt:"1"},pin:this.__pinPad__.config.read.PIN,posentrymode:this.__pinPad__.config.read.POSEM,tags:this.__pinPad__.config.read.Tags,type:this.__pinPad__.config.read.Type},currency:this.__pinPad__.config.currency.toUpperCase(),emv:this.__pinPad__.config.read.EMV,merchant:this.__pinPad__.operation.onlyMerchant,modelo_terminal:this.__pinPad__.about.model,reference:this.reference,serie:this.__pinPad__.about.serial,terminal:{display:"1",is_contactless:l,is_mobile:"0",printer:this.__pinPad__.about.printer},tp_operation:this.__pinPad__.operation.typeOperation,tp_resp:this.__pinPad__.operation.typeResponse,usrtransacction:this.username.toUpperCase(),version:this.__pinPad__.constants.appName+this.__pinPad__.constants.appVersion,version_terminal:this.__pinPad__.about.appVersion},geolocation:{latitude:this.__pinPad__.config.latitude,longitude:this.__pinPad__.config.longitude,ip:this.__pinPad__.config.publicIP}}});h.response==="error"&&(n.error=!0,n.message=h.nb_error||"Error in response");const f=o(this,p,Xr).call(this,h);return n.object=f,await o(this,p,$r).call(this,f),n.approved=this.__pinPad__.operation.responseMit._approved,this.__pinPad__.operation.finalResult=f,n}catch(c){throw t.__pinPad__.finishCommand.A="01",t.__pinPad__.finishCommand.B="",t.__pinPad__.finishCommand.C="",t.__pinPad__.finishCommand.D="",t.__pinPad__.finishCommand.E="",t.__pinPad__.finishCommand.F="",t.__pinPad__.finishCommand.G="",t.__pinPad__.finishCommand.H="",t.__pinPad__.finishCommand.I="",t.__pinPad__.finishCommand.J="",t.__pinPad__.finishCommand.K="",await o(a=t,p,Qr).call(a,o(s=t,p,On).call(s,c)),c}},$r=async function(t){if(this.__pinPad__.config.read.POSEM==="022"||this.__pinPad__.config.read.POSEM==="800"||this.__pinPad__.config.read.ReadCTLS==="1")return this.dispatch("pp:finish-emv",t),!0;const e=this.__pinPad__.constants.FS,n=this.__pinPad__.constants.STX,s=this.__pinPad__.constants.ETX;let a="C93A"+this.__pinPad__.finishCommand.A;a=a+e+"B"+this.__pinPad__.finishCommand.B,a=a+e+"C"+this.__pinPad__.finishCommand.C,a=a+e+"D"+this.__pinPad__.finishCommand.D,a=a+e+"E"+this.__pinPad__.finishCommand.E,a=a+e+"F"+this.__pinPad__.finishCommand.F,a=a+e+"G"+this.__pinPad__.finishCommand.G,a=a+e+"H"+this.__pinPad__.finishCommand.H,a=a+e+"I"+this.__pinPad__.finishCommand.I,a=a+e+"J"+this.__pinPad__.finishCommand.J,a=a+e+"K"+this.__pinPad__.finishCommand.K,a=n+o(this,p,mt).call(this,a)+a+s,a=a+o(this,p,yt).call(this,a);const c=this.parseStringToBytes(a,"");this.__pinPad__.waiting.statusSecondGenerateWaiting="pending",await this.appendToQueue(c,"second-generate");let l=0;const h=this;return new Promise((f,_)=>{l=setInterval(async()=>{var m,P;if(h.__pinPad__.waiting.statusSecondGenerateWaiting==="resolved"){if(clearInterval(l),h.__pinPad__.waiting.statusSecondGenerateWaiting=null,h.__pinPad__.operation.applyReverse){const v=await o(m=h,p,Qt).call(m,h.url+h.__pinPad__.constants.uris.reverse,{VMCAMEXMREVERSO:{business:{id_company:this.__pinPad__.config.idCompany.toUpperCase(),id_branch:this.__pinPad__.config.idBranch.toUpperCase(),country:this.__pinPad__.config.country.toUpperCase(),user:this.username.toUpperCase(),pwd:this.password.toUpperCase()},transacction:{amount:o(this,p,Ue).call(this,this.amount,2),no_operacion:this.__pinPad__.operation.folio,auth:this.__pinPad__.operation.authorization.toUpperCase(),tracks:"",usrtransacction:this.username.toUpperCase(),crypto:"2",version:this.__pinPad__.constants.appName+this.__pinPad__.constants.appVersion}}}),S=JSON.parse(v);let C;S.response==="approved"?C={message:"Transaction rejected by PinPad."}:C={message:"No communication, please check your report."},h.__pinPad__.operation.ignore.counterSale||(h.dispatch("pp:finish-emv",C),h.__pinPad__.operation.ignore.counterSale=!0)}else h.__pinPad__.operation.ignore.counterSale||(h.dispatch("pp:finish-emv",t),h.__pinPad__.operation.ignore.counterSale=!0);t.cd_error==="92"&&await o(P=h,p,Jr).call(P,t,a),f(!0)}else h.__pinPad__.waiting.statusSecondGenerateWaiting==="rejected"&&(clearInterval(l),h.__pinPad__.waiting.statusSecondGenerateWaiting=null,_("There is no response from the reader, check that it is connected."))},500)})},Jr=async function(t,e){this.__pinPad__.operation.ignore.responseGlobal=t,this.__pinPad__.operation.ignore.C93Global=e,this.__pinPad__.operation.ignore.isError92TRX=!0,await o(this,p,Le).call(this,1,0)},In=async function(){if(this.__pinPad__.operation.ignore.isError92TRX=!1,this.__pinPad__.config.read.POSEM==="022"||this.__pinPad__.config.read.POSEM==="800"||this.__pinPad__.config.read.ReadCTLS==="1")this.dispatch("pp:response",this.__pinPad__.operation.ignore.responseGlobal);else{const t=this.parseStringToBytes(this.__pinPad__.operation.ignore.C93Global,"");await this.appendToQueue(t,"code93"),await dt(1400),this.dispatch("pp:response",this.__pinPad__.operation.ignore.responseGlobal)}},On=function(t){const e={PPE02:"Importe Incorrecto.",A02:"Importe Incorrecto.",PPE03:"No hay respuesta del lector, verifique que se encuentra conectado.",A03:"No hay respuesta del lector, verifique que se encuentra conectado.",PP18:"Sin comunicación, por favor verifique su reporte.",PP24:"Transacción declinada por la PinPad.",A01:"Tarjeta Ilegible.",A04:"No hay planes de pago para esta tarjeta, por favor cambie la tarjeta.",A10:"Operación cancelada por el usuario.",A11:"Proceso cancelado por timeout.",A12:"Lectura errónea de banda/chip.",A13:"Carga de llave fallida.",A14:"Error de lectura de PIN.",A15:"Tarjeta Vencida.",A16:"Problemas al leer el chip.",A17:"Impresora sin Papel.",E17:"Impresora sin Papel.",A21:"Información no almacenada correctamente.",A22:"Tarjeta bloqueada.",A23:"Sin llave de cifrado DUKPT.",A28:"Fallback no soportado.",EE19:"Error de conexión, verifique su reporte.",EE21:"Ha ocurrido un error al procesar su solicitud.",EE22:"Ha ocurrido un error de conexión al servidor.",EE23:"El número de operación no puede ir vacío.",EE24:"El número de operación debe ser de 9 dígitos.",EE25:"El número de operación debe ser numérico.",EE26:"La información enviada al servicio está incompleta.",EE27:"La referencia contiene caracteres inválidos o está vacía.",EE28:"Número de autorización inválido.",EE29:"Importe inválido.",EE30:"La información enviada al servicio no es válida.",EE31:"No fue posible obtener las afiliaciones.",EE32:"Error de conexión, existe una o más transacciones en el servidor , Favor de validar su reporte y en su caso reimprimir el voucher.",EE33:"Error de comunicacion con CDP. IL/MTY",EE20:"La Referencia contiene caracteres inválidos",EE99:"Error código 99."};let n=e[t]?{error:t,message:e[t]}:{error:t,message:"Error desconocido"};return this.dispatch("pp:error",n),n},Qr=async function(t){const e=this.__pinPad__.constants.FS,n=this.__pinPad__.constants.STX,s=this.__pinPad__.constants.ETX;let a="C93A"+this.__pinPad__.finishCommand.A;if(a=a+e+"B"+this.__pinPad__.finishCommand.B,a=a+e+"C"+this.__pinPad__.finishCommand.C,a=a+e+"D"+this.__pinPad__.finishCommand.D,a=a+e+"E"+this.__pinPad__.finishCommand.E,a=a+e+"F"+this.__pinPad__.finishCommand.F,a=a+e+"G"+this.__pinPad__.finishCommand.G,a=a+e+"H"+this.__pinPad__.finishCommand.H,a=a+e+"I"+this.__pinPad__.finishCommand.I,a=a+e+"J"+this.__pinPad__.finishCommand.J,a=a+e+"K"+this.__pinPad__.finishCommand.K,a=n+o(this,p,mt).call(this,a)+a+s,a=a+o(this,p,yt).call(this,a),this.__pinPad__.config.read.POSEM==="022"||this.__pinPad__.config.read.POSEM==="800"||this.__pinPad__.config.read.ReadCTLS==="1"){this.dispatch("pp:finish-emv",t);return}const c=this.parseStringToBytes(a,"");await this.appendToQueue(c,"finish-emv-end")},Zr=async function(t){if(t.cd_estatus=t.cd_estatus?t.cd_estatus:"0",t.cd_estatus!=="1"){this.__pinPad__.operation.ignore.isError92TRX&&await o(this,p,In).call(this);return}const e=this.__pinPad__.constants.FS,n=this.__pinPad__.constants.ETX,s=this.__pinPad__.constants.STX,a=t.nb_ksn,c=t.nb_kcv||"",l=t.nb_ipek||"";let h="C92A"+a+e+"B"+c+e+"C"+l;h=s+o(this,p,mt).call(this,h)+h+n,h=h+o(this,p,yt).call(this,h);const f=this.parseStringToBytes(h,"");await this.appendToQueue(f,"dukpt");let _=0;this.__pinPad__.waiting.statuswritingDUKPTWaiting="pending";const m=this;return new Promise((P,v)=>{_=setInterval(async()=>{var S;m.__pinPad__.waiting.statuswritingDUKPTWaiting==="resolved"?(clearInterval(_),m.__pinPad__.waiting.statuswritingDUKPTWaiting=null,this.__pinPad__.operation.ignore.isError92TRX&&await o(S=m,p,In).call(S),P(!0)):m.__pinPad__.waiting.statuswritingDUKPTWaiting==="rejected"&&(clearInterval(_),m.__pinPad__.waiting.statuswritingDUKPTWaiting=null,v("Error writing DUKPT keys"))},500)})},Yr=function(){this.__pinPad__.config.read.AppId="",this.__pinPad__.config.read.AppIdLabel="",this.__pinPad__.config.read.Arqc="",this.__pinPad__.config.read.ChipName="",this.__pinPad__.config.read.ReadCTLS="",this.__pinPad__.config.read.NB_Data="",this.__pinPad__.config.read.NB_ksn="",this.__pinPad__.config.read.PIN="",this.__pinPad__.config.read.POSEM="",this.__pinPad__.config.read.Tags="",this.__pinPad__.config.read.Type="",this.__pinPad__.config.read.Chip="",this.__pinPad__.config.read.ChipNameEnc="",this.__pinPad__.operation.ignore.error="",this.__pinPad__.operation.ignore.C93Global="",this.__pinPad__.operation.folio="",this.__pinPad__.operation.authorization="",this.__pinPad__.config.tokenizeTRX=!1};class fc extends kt{constructor({filters:t=null,config_port:e=null,no_device:n=1,device_listen_on_port:s=1,type:a="esplus",support_cart:c=!0}={}){super({filters:t,config_port:e,no_device:n,device_listen_on_port:s});J(this,g);Z(this,"__device",{type:"esplus",support_cart:!1,withdraw:{in_process:!1,seconds:60,interval:0},cart:{in_process:!1},channels:{verification:{clear(){this.running=!1,this.current=1,this.channels=[]},running:!1,start:1,end:80,current:1,channels:[]}}});if(this.__internal__.device.type="jofemar",K.getCustom(this.typeDevice,n))throw new Error(`Device ${this.typeDevice} ${n} already exists`);this.__internal__.dispense.must_response=!0,this.__internal__.time.response_general=800,this.__internal__.time.response_engines=800,this.__internal__.dispense.limit_counter=40,this.__internal__.dispense.timeout=0,this.__internal__.dispense.timeout_time=4e3,this.__internal__.dispense.interval=0,this.__internal__.dispense.interval_time=1e3,this.__internal__.device.hex_number=(128+this.listenOnPort).toString(16),this.__internal__.device.door_open=!1,this.__internal__.dispense.elevator={locking_time:60,locking_interval:0,need_reset:!1},this.deviceType=a,this.supportCart=c,o(this,g,ts).call(this),o(this,g,ns).call(this),o(this,g,es).call(this)}set startChannelVerification(t){const e=parseInt(t);if(isNaN(e))throw new Error("Invalid start channel verification, must be a number");if(e<1||e>126)throw new Error("Invalid start channel verification, valid range is 1 to 126");this.__device.channels.verification.start=e}set endChannelVerification(t){const e=parseInt(t);if(isNaN(e))throw new Error("Invalid end channel verification, must be a number");if(e<1||e>126)throw new Error("Invalid end channel verification, valid range is 1 to 126");this.__device.channels.verification.end=e}set listenOnPort(t){if(t=parseInt(t),isNaN(t)||t<1||t>31)throw new Error("Invalid port number, valid range is 1 to 31");this.__internal__.device.listen_on_port=t,this.__internal__.serial.bytes_connection=this.serialSetConnectionConstant(t),this.__internal__.device.hex_number=(128+t).toString(16)}set deviceType(t){if(typeof t!="string")throw new Error("Invalid device type, must be a string");this.__device.type=t}set supportCart(t){if(typeof t!="boolean")throw new Error("Invalid support cart, must be a boolean");this.__device.support_cart=t}get listenOnPort(){return this.__internal__.device.listen_on_port??1}serialJofemarMakeBytes(t){let e=this.hexToDec(this.sumHex(t)),n=this.calcCheckSums(e.toString());for(let s=0;s<2;s++)t.push(this.hexMaker(n[s]));return t.push("03"),this.add0x(t)}calcCheckSums(t){t=this.add0x([this.decToHex(parseInt(t).toString())]);let e=[];return e.push((t&255|240).toString(16).toUpperCase()),e.push((t&255|15).toString(16).toUpperCase()),e}serialSetConnectionConstant(t=1){let e=["02","30","30",(128+t).toString(16),"53","FF","FF"],n=[];return e.forEach(s=>{n.push(this.hexMaker(s))}),this.serialJofemarMakeBytes(n)}serialMessage(t){let n={code:t,name:null,description:null,request:"unknown",no_code:0,additional:{machine:{hex:null,dec:null}}};switch(t[0]){case"02":n=o(this,g,xs).call(this,t,n,128);break;case"06":n=o(this,g,As).call(this,t,n);break;case"15":n.name="Checksum error",n.description="The calculated checksum does not match the received checksum",n.no_code=38,o(this,g,Y).call(this);break;default:n.name="unknown",n.description="The message received is unknown",n.no_code=404;break}this.dispatch("serial:message",n)}productRemovedContinueDispensing(){this.__internal__.dispense.elevator.locking_interval&&(this.__internal__.dispense.elevator.locking_time=0)}async dispense({selection:t=1,cart:e=!1}={}){if(t=parseInt(t),isNaN(t)||t<1||t>130)throw new Error("Invalid selection");const{channel:n,tray:s}=o(this,g,Ds).call(this,t);this.__internal__.dispense.backup_dispense={selection:t,cart:e,channel:n,tray:s};let c=["02","30","30",this.__internal__.device.hex_number,"56",s,n];e&&(c[4]="4D"),c=o(this,g,Ve).call(this,c);let l;do l=await this.internalDispense(c),o(this,g,Rs).call(this),l.error==="elevator-locked"?await o(this,g,is).call(this):l.error==="no-response"&&await dt(1e3);while(["elevator-locked","no-response"].includes(l.error));return this.__internal__.dispense.backup_dispense={},l}internalClearSensing(){super.internalClearSensing(),this.__internal__.dispense.timeout&&clearTimeout(this.__internal__.dispense.timeout),this.__internal__.dispense.interval&&clearInterval(this.__internal__.dispense.interval),this.__internal__.serial.queue.length>0&&(this.__internal__.serial.queue=this.__internal__.serial.queue.filter(t=>t.type!=="status"))}async endDispense(){let e=["02","30","30",this.__internal__.device.hex_number,"4D","80","80"];return e=o(this,g,Ve).call(this,e),await this.internalDispense(e)}async collect(){const t=["02","30","30","81","4E","FF","FF"];return await o(this,g,ot).call(this,t,"collect")}async resetSoldOutErrors(){return await o(this,g,ue).call(this,"80")}async resetWaitingProductRemovedError(){return await o(this,g,ue).call(this,"81")}async resetMachineErrors(){return this.__internal__.serial.queue.length===0?(o(this,g,Bn).call(this),await o(this,g,ue).call(this,"FF")):new Promise(t=>{const e=setInterval(async()=>{this.__internal__.serial.queue.length>0||(clearInterval(e),await o(this,g,ue).call(this,"FF"),o(this,g,Bn).call(this),t(!0))},100)})}async resetAllErrors(){return await this.resetSoldOutErrors(),await dt(100),await this.resetWaitingProductRemovedError(),await dt(100),await this.resetMachineErrors()}async status(){const t=["02","30","30","81","53","FF","FF"];return await o(this,g,ot).call(this,t,"status")}async lightsOn(){return await o(this,g,Nn).call(this,"81")}async lightsOff(){return await o(this,g,Nn).call(this,"80")}async program(t,e){const n=["02","30","30","81","50",t,e];return await o(this,g,ot).call(this,n,"program")}async programDisplayLanguage({language:t="spanish"}={}){const e={spanish:"30",english:"31",french:"32"};if(!e[t])throw new Error("Invalid language");return await this.program("49",e[t])}async programBeeper({enable:t=!0}={}){const e=t?"31":"30";return await this.program("5A",e)}async programDisableWorkingTemperature(){if(this.__device.type==="iceplus")throw new Error("IcePlus does not support disable working temperature");return await this.program("54","80")}async programDisableThermometer(){return await this.programDisableWorkingTemperature()}async programWorkingTemperature({degrees:t=.5}={}){t=parseFloat(t);const e=this.__device.type==="iceplus"?6.5:32,n=this.__device.type==="iceplus"?-25:.5;if(isNaN(t)||t<n||t>e||t%.5!==0)throw new Error("Invalid degrees, must be a multiple of 0.5 and between 0.5 and 32");let s=t*2+128;return this.__device.type==="iceplus"&&(s+=51),s=Math.ceil(s),await this.program("54",s.toString(16))}async programIsolationTray({tray:t=0}={}){if(t=parseInt(t),isNaN(t)||t<0||t>12)throw new Error("Invalid tray, valid range is 0 to 12");const e=t===0?"80":(t+139).toString(16);return this.program("42",e)}async programTimeToStandbyAfterCollect({seconds:t=15}={}){if(t=parseInt(t),isNaN(t)||t<15||t>120)throw new Error("Invalid seconds, valid range is 15 to 120");const e=(128+t).toString(16);return await this.program("46",e)}async programTimeToStandbyWithoutCollect({minutes:t=1}={}){if(t=parseInt(t),isNaN(t)||t<1||t>10)throw new Error("Invalid minutes, valid range is 1 to 10");const e=(128+t).toString(16);return await this.program("48",e)}async programElevatorSpeed({speed:t="high"}={}){const e={high:"31",low:"30"};if(!e[t])throw new Error("Invalid speed, valid speeds are 'high' and 'low'");return await this.program("76",e[t])}async programTemperatureExpiration({enable:t=!1}={}){const e=t?"31":"30";return await this.program("63",e)}async programEnableTemperatureExpiration(){return await this.programTemperatureExpiration({enable:!0})}async programDisableTemperatureExpiration(){return await this.programTemperatureExpiration({enable:!1})}async programMachineAddress({address:t=1}={}){if(t=parseInt(t),isNaN(t)||t<1||t>31)throw new Error("Invalid address, valid range is 1 to 31");const e=(128+t).toString(16);return await this.program("64",e)}async programTemperatureBeforeExpiration({degrees:t=.5}={}){if(t=parseFloat(t),isNaN(t)||t<.5||t>30||t%.5!==0)throw new Error("Invalid degrees, must be a multiple of 0.5 and valid range is 0.5 to 30");const e=(128+t*2).toString(16);return await this.program("65",e)}async programTimeBeforeExpirationByTemperature({minutes:t=1}={}){if(t=parseInt(t),isNaN(t)||t<1||t>120)throw new Error("Invalid minutes, valid range is 1 to 120");const e=(128+t).toString(16);return await this.program("66",e)}async programTemperatureScale({scale:t="c"}={}){const e={c:"43",f:"46"};if(!e[t])throw new Error("Invalid scale, valid scales are 'c' for celsius and 'f' for fahrenheit");return await this.program("67",e[t])}async programVoltageEngine({selection:t=1,voltage:e=5}={}){if(e=parseFloat(e),t=parseInt(t),isNaN(t)||t<1||t>this.__device.channels.verification.end)throw new Error(`Invalid selection, valid range is 1 to ${this.__device.channels.verification.end}`);if(isNaN(e)||e<5||e>9.5||e%.5!==0)throw new Error("Invalid voltage, valid range is 5 to 9.5");const n=109+t,a=(128+(e-5)*2).toString(16),c=["02","30","30","81","47",n,a];return await o(this,g,ot).call(this,c,"voltage-engine")}async programPushOverProducts({selection:t=1,enable:e=!0}={}){if(t=parseInt(t),isNaN(t)||t<1||t>this.__device.channels.verification.end)throw new Error(`Invalid selection, valid range is 1 to ${this.__device.channels.verification.end}`);const a=["02","30","30","81","4F",109+t,e?"31":"30"];return await o(this,g,ot).call(this,a,"push-over-products")}async programChannelRunningAfterDispense({selection:t=1,seconds:e=0}={}){if(t=parseInt(t),e=parseFloat(e),isNaN(t)||t<1||t>this.__device.channels.verification.end)throw new Error(`Invalid selection, valid range is 1 to ${this.__device.channels.verification.end}`);if(isNaN(e)||e<0||e>10||e%.1!==0)throw new Error("Invalid seconds, valid range is 0.0 to 10.0 with a step of 0.1");const n=109+t;e=e.toFixed(1);const s=128+e*10,a=["02","30","30","81","45",n,s];return await o(this,g,ot).call(this,a,"channel-running-after-dispense")}async checkData(t,e="FF"){const n=["02","30","30","81","43",t,e];return await o(this,g,ot).call(this,n,"check-data")}async getDisplayLanguage(){return await this.checkData("49")}async getBeeper(){return await this.checkData("5A")}async getWorkingTemperature(){return await this.checkData("54")}async getIsolationTray(){return await this.checkData("42")}async getProgramVersion(){return await this.checkData("50")}async getFaults(){return await this.checkData("53")}async getMachineId(){return await this.checkData("4E")}async getCurrentTemperature(){return await this.checkData("74")}async getTimeToStandbyAfterCollect(){return await this.checkData("46")}async getTimeToStandbyWithoutCollect(){return await this.checkData("48")}async getElevatorSpeed(){return await this.checkData("76")}async getTemperatureExpiration(){return await this.checkData("63")}async getTemperatureBeforeExpiration(){return await this.checkData("65")}async getTimeBeforeExpirationByTemperature(){return await this.checkData("66")}async getTemperatureScale(){return await this.checkData("67")}async getClockRegisters(){return await this.checkData("72")}async getMachineActivity(){return await this.checkData("41")}async getVoltageEngine({selection:t=1}={}){if(t=parseInt(t),isNaN(t)||t<1||t>126)throw new Error("Invalid selection, valid range is 1 to 126");const e=(109+t).toString(16);return await this.checkData("47",e)}async getChannelPresence({selection:t=1}={}){if(t=parseInt(t),isNaN(t)||t<1||t>126)throw new Error("Invalid selection, valid range is 1 to 126");const e=(109+t).toString(16);return await this.checkData("43",e)}async getPushOverProducts({selection:t=1}={}){if(t=parseInt(t),isNaN(t)||t<1||t>126)throw new Error("Invalid selection, valid range is 1 to 126");const e=(109+t).toString(16);return await this.checkData("4F",e)}async getChannelRunningAfterDispense({selection:t=1}={}){if(t=parseInt(t),isNaN(t)||t<1||t>126)throw new Error("Invalid selection, valid range is 1 to 126");const e=(109+t).toString(16);return await this.checkData("45",e)}async setDisplayStandbyMessage({message:t=""}={}){t=t.substring(0,32);const e=o(this,g,He).call(this,t);return await o(this,g,je).call(this,"80",e)}async setDisplayMessageTemporarily({message:t="",seconds:e=1}){if(t=t.substring(0,32),e=parseInt(e),isNaN(e)||e<1||e>125)throw new Error("Invalid seconds, valid range is 1 to 125");const n=o(this,g,He).call(this,t),s=(128+e).toString(16);return await o(this,g,je).call(this,s,n)}async setDisplayMessageUnlimited({message:t=""}){t=t.substring(0,32);const e=o(this,g,He).call(this,t);return await o(this,g,je).call(this,"FF",e)}async programClock({date:t=new Date}={}){if(!(t instanceof Date))throw new Error("Invalid date, must be an instance of Date");const e=["02","30","30","81","72",...o(this,g,Os).call(this,t)];return await o(this,g,ot).call(this,e,"clock")}async eventsConfig({event:t=null,enable:e=!0}={}){if(t===null)throw new Error("Invalid event");const s=["02","30","30","81","41",t,e?"31":"30"];return await o(this,g,ot).call(this,s,"events-config")}async eventEnable({event:t=null}={}){if(t===null)throw new Error("Invalid event");const e=parseInt(t,16);if(isNaN(e)||e<38||e>100)throw new Error("Invalid event");return await this.eventsConfig({event:t,enable:!0})}async eventDisable({event:t=null}={}){if(t===null)throw new Error("Invalid event");const e=parseInt(t,16);if(isNaN(e)||e<38||e>100)throw new Error("Invalid event");return await this.eventsConfig({event:t,enable:!1})}async sendCustomCode({code:t=[]}={}){if(t.length<5)throw new Error("Invalid code, minimum length is 5");return await o(this,g,ot).call(this,t,"custom")}async assignChannels(){const t=this.__device.channels.verification.start,e=this.__device.channels.verification.end;if(t>e)throw new Error("Invalid range, start must be less than end");this.__device.channels.verification.clear(),this.__device.channels.verification.running=!0;for(let n=t;n<=e;n++)this.__device.channels.verification.current=n,await this.getChannelPresence({selection:n});return new Promise(n=>{let s=setInterval(()=>{this.__device.channels.verification.channels.length===e-t+1&&(clearInterval(s),this.dispatch("channels",{channels:this.__device.channels.verification.channels}),this.__device.channels.verification.clear(),n(!0))},500)})}}g=new WeakSet,ts=function(){const t=["dispensing:withdrawal","command-executed","keyboard:pressed","door:event","program:version","machine:faults","clock:registers","machine:activity","check:language","check:beeper","check:isolation-tray","check:engine-voltage","check:push-over","check:extractor-after-dispense","check:standby-after-collect","check:standby-without-collect","check:elevator-speed","check:expiration-by-temperature","check:temperature-before-expiration","check:expiration-after","check:temperature-scale","check:machine-id","temperature:working","temperature:current","jofemar:warning","jofemar:error","serial:message","reset:errors","channels","channel:status","machine:status"];for(const e of t)this.serialRegisterAvailableListener(e)},es=function(){this.on("internal:dispense:running",o(this,g,Is).bind(this))},ns=function(){K.add(this)},ot=function(t,e){return t[3]=this.__internal__.device.hex_number,this.appendToQueue(o(this,g,Ve).call(this,t),e)},Ve=function(t){let e=this.hexToDec(this.sumHex(t)),n=this.calcCheckSums(e.toString());for(let s=0;s<2;s++)t.push(this.hexMaker(n[s]));return t.push("03"),t},is=async function(){if(this.__internal__.dispense.elevator.locking_interval)return;this.__internal__.dispense.elevator.need_reset&&(this.__internal__.dispense.elevator.need_reset=!1,await this.resetWaitingProductRemovedError(),await dt(500));const t=this;return this.__internal__.dispense.status="elevator-locked",this.__internal__.dispense.elevator.locking_time=60,new Promise(e=>{t.__internal__.dispense.elevator.locking_interval=setInterval(()=>{t.dispatch("dispensing:withdrawal",{elevator:!0,seconds:t.__internal__.dispense.elevator.locking_time,description:"Please recall products from the elevator"}),t.__internal__.dispense.elevator.locking_time-=1,t.__internal__.dispense.elevator.locking_time<=0&&(clearInterval(t.__internal__.dispense.elevator.locking_interval),t.__internal__.dispense.elevator.locking_interval=0,e(!0))},1e3)})},rs=function(t,e){return e.name="ok",e.description="The last command was executed successfully",e.no_code=1,this.dispatch("command-executed",e),e},ss=function(t,e){e.additional={hex:t,dec:this.hexToDec(t),ascii:null};const n={30:"0",31:"1",32:"2",33:"3",34:"4",35:"5",36:"6",37:"7",38:"8",39:"9","2a":"*",23:"#",41:"A",42:"B",43:"C",44:"D"};return e.additional.ascii=n[t]??null,e.name="Key pressed",e.description=`The key ${e.additional.ascii} was pressed`,e.no_code=2,this.dispatch("keyboard:pressed",e.additional),e},as=function(t,e){return e.additional={open:!1},e.no_code=3,t==="4f"?(e.name="door open",e.description="The door was opened",e.additional.open=!0,this.__internal__.device.door_open=!0,this.dispatch("door:event",e.additional)):t==="43"?(e.name="door close",e.description="The door was closed",e.additional.open=!1,this.__internal__.device.door_open=!1,this.dispatch("door:event",e.additional)):(e.name="door event",e.description="The door event received is unknown",this.dispatch("door:event",{open:e.additional.open,message:e})),e},os=function(t,e){e.no_code=404;let n=t[5]??null;return n&&this.listenOnPort>1&&(n=this.hexToDec(n)-this.listenOnPort+1,n=this.decToHex(n)),n&&(n==="FD"?(e.no_code=4,e.name="channel disconnected",e.description="The channel is disconnected",e.additional={active:!1}):n==="FC"?(e.no_code=5,e.name="channel connected",e.description="The channel is connected",e.additional={active:!0}):(e.no_code=6,e.name="channel sold out",e.description="The channel is empty",e.additional={active:!0}),this.__device.channels.verification.running&&(this.__device.channels.verification.channels.push({selection:this.__device.channels.verification.current,active:e.additional.active}),e.additional.selection=this.__device.channels.verification.current),this.dispatch("channel:status",e.additional)),e},cs=function(t,e){e.no_code=39,e.name="Program version";const n=t.slice(4,12),s=n.map(a=>String.fromCharCode(this.hexToDec(a))).join("");return e.additional={version:s,hex:n},e.description=`The program version is ${s}`,this.dispatch("program:version",e.additional),e},ls=function(t,e){e.no_code=39,e.name="Machine faults",e.description="No faults detected",e.additional={no_faults:0,faults:[]};const n=t.slice(4,-3);if(n.length>1&&n[0]!=="30"){e.description="Machine has faults";const s={31:"Busy",32:"Invalid tray",33:"Invalid channel",34:"Empty channel",35:"Jam in elevator engine",36:"Malfunction in the elevator belt or product detector",37:"Failure in one of the photo transistors in the cabinet",38:"No channels detected",39:"Product detector fault",41:"Machine display is disconnected",42:"Product alarm under elevator",43:"Error when elevator approaching to a position",44:"Fault in keyboard",45:"Eeprom writing error",46:"Fault communicating with temperature control",47:"The thermometer is disconnected",48:"Thermometer programming lost",49:"Thermometer faulty","4a":"Channels power consumption detector faulty","4b":"Elevator does not find channel or tray","4c":"Elevator does not find delivery product position","4d":"Interior of elevator blocked","4e":"Error in tester of product detector","4f":"Waiting for product to be removed",50:"Product expired by temperature reasons",51:"Automatic door faulty",59:"Product is expired","5a":"Product is expired",61:"Product is expired",62:"Product is expired",63:"Product is expired",64:"Product detector didn't change during its verification test"};for(const a of n)s[a]&&(e.additional.faults.push(s[a]),e.additional.no_faults++)}return this.dispatch("machine:faults",e.additional),e},hs=function(t,e){e.no_code=40,e.name="Clock registers",e.description="Clock registers";const n=t.slice(4,-3),s=n.map(v=>String.fromCharCode(this.hexToDec(v))).join(""),[a,c]=s.split(" "),[l,h]=a.split(":"),[f,_,m]=c.split("-"),P=new Date(2e3+parseInt(m),parseInt(_)-1,parseInt(f),parseInt(l),parseInt(h));return e.additional={day:f,month:_,year:m,hours:l,minutes:h,formatted:s,date:P,hex:n},this.dispatch("clock:registers",e.additional),e},us=function(t,e){e.no_code=41,e.name="Machine activity",e.description="Events from read machine activity";const n=String.fromCharCode(this.hexToDec(t[4]));if(n!=="0"){const s=t.slice(5,-3);if(n==="T"&&s.length===4){const a=String.fromCharCode(this.hexToDec(s[0])),c=String.fromCharCode(this.hexToDec(s[1])),l=String.fromCharCode(this.hexToDec(s[3]));e.additional={ascii:n,type:"DU.d",dozens:a,units:c,decimals:l,time:parseFloat(`${a}${c}.${l}`),meaning:"Extraction time (in seconds)"}}else if(["B","D","E","F","G"].includes(n)&&s.length===3){const a=String.fromCharCode(this.hexToDec(s[0])),c=String.fromCharCode(this.hexToDec(s[1])),l=String.fromCharCode(this.hexToDec(s[2])),h=parseInt(`${a}${c}${l}`),f={B:"Error on going to tray channel",D:"Error on product detector",E:"Extraction of channel ok",F:"Error on engine intensity detection",G:"Error on product exit door"};e.additional={type:"HDU",hundreds:a,dozens:c,decimals:l,channel:h,selection:h-109,ascii:n,meaning:f[n]??"Unknown"}}else if(s.length===13){const a=s.map(S=>String.fromCharCode(this.hexToDec(S))).join(""),c=parseInt(a.slice(0,2)),l=parseInt(a.slice(2,4)),h=parseInt(a.slice(4,6)),f=parseInt(a.slice(7,9)),_=parseInt(a.slice(9,11))-1,m=2e3+parseInt(a.slice(11,13)),P=new Date(m,_,f,c,l,h),v={A:"Attempt to close product exit door",C:"Closing of exterior door",H:"Error on opening of product exit door",I:"New attempt to arrive at product exit position after an error on first attempt",J:"Power on cooling unit",K:"Power off cooling unit",L:"Start of defrosting",M:"End of defrosting",O:"Opening of exterior door",R:"Memory reset",S:"Error on going to product exit position",Y:"Power on machine",Z:"Power off machine",c:"Closing of inner door",e:"New attempt to extract from channel due no product detection when elevator arrived to product exit position",o:"Opening of inner door"};e.additional={type:"hhmmssWddMMAA",date:P,hex:s,formatted:P.toLocaleString(),ascii:n,meaning:v[n]??"Unknown"}}}return this.dispatch("machine:activity",e.additional),e},ds=function(t,e){const n={30:"Spanish",31:"English",32:"French"};return e.no_code=42,e.name="Language",e.description=`The language is ${n[t]??"unknown"}`,e.additional={hex:t,language:n[t]??"unknown"},this.dispatch("check:language",e.additional),e},ps=function(t,e){return e.no_code=43,e.name="Beeper",e.description=`The beeper is ${t==="30"?"on":"off"}`,e.additional={hex:t,beeper:t==="30"},this.dispatch("check:beeper",e.additional),e},fs=function(t,e){e.no_code=44,e.name="Isolation tray",e.description="Isolation tray";const n=this.hexToDec(t)-139;return e.additional={hex:t,tray:n},this.dispatch("check:isolation-tray",e.additional),e},_s=function(t,e){e.no_code=45,e.name="Engine voltage",e.description="Engine voltage";const n=(this.hexToDec(t)-128)/2+5;return e.additional={hex:t,voltage:n},this.dispatch("check:engine-voltage",e.additional),e},gs=function(t,e){e.no_code=46,e.name="Push over",e.description="Push over";const n=t==="30";return e.additional={hex:t,push:n},this.dispatch("check:push-over",e.additional),e},bs=function(t,e){e.no_code=47,e.name="Extractor after dispense",e.description="Extractor after dispense";const n=(this.hexToDec(t)-128)/10;return e.additional={hex:t,seconds:n},this.dispatch("check:extractor-after-dispense",e.additional),e},ms=function(t,e){e.no_code=48,e.name="Standby after collect",e.description="Time to standby after collect product";const n=this.hexToDec(t)-128;return e.additional={hex:t,seconds:n},this.dispatch("check:standby-after-collect",e.additional),e},ys=function(t,e){e.no_code=49,e.name="Standby without collect",e.description="Time to standby when product delivery is not collected";const n=this.hexToDec(t)-128;return e.additional={hex:t,minutes:n},this.dispatch("check:standby-without-collect",e.additional),e},ws=function(t,e){e.no_code=50,e.name="Elevator speed",e.description="Elevator speed";const n=t==="30"?"low":"high";return e.additional={hex:t,speed:n},this.dispatch("check:elevator-speed",e.additional),e},vs=function(t,e){e.no_code=51,e.name="Temperature expiration",e.description="Temperature expiration";const n=t==="31";return e.additional={hex:t,enabled:n},this.dispatch("check:expiration-by-temperature",e.additional),e},Ps=function(t,e){e.no_code=52,e.name="Temperature before expiration",e.description="Temperature before expiration";const n=(this.hexToDec(t)-128)/2;return e.additional={hex:t,temperature:n},this.dispatch("check:temperature-before-expiration",e.additional),e},Es=function(t,e){e.no_code=53,e.name="Time before expiration",e.description="Time before expiration";const n=this.hexToDec(t)-128;return e.additional={hex:t,minutes:n},this.dispatch("check:expiration-after",e.additional),e},Ts=function(t,e){e.no_code=54,e.name="Temperature scale",e.description="Temperature scale";const n=t==="43"?"Celsius":"Fahrenheit";return e.additional={hex:t,scale:n},this.dispatch("check:temperature-scale",e.additional),e},Cs=function(t,e){return e.no_code=54,e.name="Machine ID",e.description="Machine ID",e.additional={hex:t[4],full_hex:t},this.dispatch("check:machine-id",e.additional),e},Ss=function(t,e){return e.no_code=7,e.name="working temperature",e.description=`The working temperature is ${t}`,e.additional={hex:t,temperature:{traditional:(this.hexToDec(t)-this.hexToDec("80"))/2,ice_plus:(this.hexToDec(t)-this.hexToDec("80"))/2-25.5}},this.dispatch("temperature:working",e.additional),e},ks=function(t,e){return e.no_code=8,e.name="current temperature",e.additional={sign:null,tens:null,units:null,decimals:null,type_degrees:null,formatted:null,decimal_point:t[7]==="2e"?".":null,degrees:t[9]==="7f"?"°":null,error:null},t[4]==="2b"?e.additional.sign=t[4]="+":["2e","2d"].includes(t[4])?e.additional.sign=t[4]="-":t[4]==="20"&&(e.additional.error="Error in thermometer"),this.hexToDec(t[5])>=48&&this.hexToDec(t[5])<=57?e.additional.tens=this.hexToDec(t[5])-48:t[5]==="2a"&&(e.additional.error="Error in thermometer"),this.hexToDec(t[6])>=48&&this.hexToDec(t[6])<=57?e.additional.units=this.hexToDec(t[6])-48:t[6]==="2a"&&(e.additional.error="Error in thermometer"),this.hexToDec(t[8])>=48&&this.hexToDec(t[8])<=57?e.additional.decimals=this.hexToDec(t[8])-48:t[8]==="2a"&&(e.additional.error="Error in thermometer"),t[10]==="43"?e.additional.type_degrees="C":t[10]==="46"&&(e.additional.type_degrees="F"),e.additional.error==="Error in thermometer"?(e.additional.formatted="Error in thermometer",e.description="The current temperature cannot be read because there is an error in the thermometer"):(e.additional.formatted=(e.additional.sign??"")+(e.additional.tens??"")+(e.additional.units??"")+(e.additional.decimal_point??"")+(e.additional.decimals??"")+(e.additional.degrees??"")+(e.additional.type_degrees??""),e.description=`The current temperature is ${e.additional.formatted}`),this.dispatch("temperature:current",e.additional),e},xs=function(t,e,n=128){if(t[1]&&(e.additional.machine.hex=t[1],e.additional.machine.dec=this.hexToDec(t[1])-n),!(t[1]&&t[2]))e=o(this,g,rs).call(this,t,e);else switch(t[2]){case"54":e.request="--automatic",e=o(this,g,ss).call(this,t[3],e);break;case"50":e.request="--automatic",e=o(this,g,as).call(this,t[3],e);break;case"43":switch(e.request="check-data",t[3]){case"41":e=o(this,g,us).call(this,t,e);break;case"43":e.request="channel-status",e=o(this,g,os).call(this,t,e);break;case"50":e=o(this,g,cs).call(this,t,e);break;case"53":e=o(this,g,ls).call(this,t,e);break;case"54":e.request="working-temperature",e=o(this,g,Ss).call(this,t[4],e);break;case"72":e=o(this,g,hs).call(this,t,e);break;case"74":e.request="current-temperature",e=o(this,g,ks).call(this,t,e);break;case"49":e=o(this,g,ds).call(this,t[4],e);break;case"5a":e=o(this,g,ps).call(this,t[4],e);break;case"42":e=o(this,g,fs).call(this,t[4],e);break;case"47":e=o(this,g,_s).call(this,t[4],e);break;case"4e":e=o(this,g,Cs).call(this,t,e);break;case"4f":e=o(this,g,gs).call(this,t[4],e);break;case"45":e=o(this,g,bs).call(this,t[4],e);break;case"46":e=o(this,g,ms).call(this,t[4],e);break;case"48":e=o(this,g,ys).call(this,t[4],e);break;case"76":e=o(this,g,ws).call(this,t[4],e);break;case"63":e=o(this,g,vs).call(this,t[4],e);break;case"65":e=o(this,g,Ps).call(this,t[4],e);break;case"66":e=o(this,g,Es).call(this,t[4],e);break;case"67":e=o(this,g,Ts).call(this,t[4],e);break}break}return e},ft=function(){this.__internal__.dispense.dispensing&&(this.__internal__.dispense.status=!0)},Y=function(){this.__internal__.dispense.dispensing&&(this.__internal__.dispense.status=!1)},qe=function(){this.__internal__.dispense.dispensing&&(this.__internal__.dispense.status="elevator-locked")},tt=function({type:t=null,severity:e="low"}={}){this.dispatch("jofemar:warning",{type:t,severity:e})},wt=function({type:t=null,severity:e="high"}={}){this.dispatch("jofemar:error",{type:t,severity:e})},As=function(t,e){if(e.request="status",t[1]&&!t[2]){switch(t[1]){case"30":e.name="Machine ready",e.description="The machine is ready for instructions",e.no_code=9,o(this,g,ft).call(this);break;case"31":e.name="Machine busy",e.description="The machine is busy right now",e.no_code=10;break;case"32":e.name="Invalid tray",e.description="The tray requested is invalid",e.no_code=11,o(this,g,Y).call(this),o(this,g,tt).call(this,{type:"invalid-tray"});break;case"33":e.name="Invalid channel",e.description="The channel requested is invalid",e.no_code=12,o(this,g,Y).call(this),o(this,g,tt).call(this,{type:"invalid-channel"});break;case"34":e.name="Empty channel",e.description="The channel requested is empty",e.no_code=13,o(this,g,Y).call(this),o(this,g,tt).call(this,{type:"empty-channel"});break;case"35":e.name="Jam",e.description="Jam in elevator engine",e.no_code=14,o(this,g,Y).call(this),o(this,g,wt).call(this,{type:"jam"});break;case"36":e.name="Malfunction",e.description="Malfunction in the elevator belt or product detector",e.no_code=15,o(this,g,Y).call(this),o(this,g,wt).call(this,{type:"malfunction"});break;case"37":e.name="Photo transistors",e.description="Failure in one of the photo transistors in the cabinet",e.no_code=16,o(this,g,Y).call(this),o(this,g,wt).call(this,{type:"photo-transistors"});break;case"38":e.name="Without channels",e.description="No channels detected",e.no_code=17,o(this,g,Y).call(this),o(this,g,wt).call(this,{type:"without-channels"});break;case"39":e.name="Product detector fault",e.description="Product detector fault",e.no_code=18,o(this,g,qe).call(this),o(this,g,tt).call(this,{type:"fault-product-detector"});break;case"41":e.name="Fault in 485 BUS",e.description="Machine display is disconnected",e.no_code=19,o(this,g,ft).call(this),o(this,g,tt).call(this,{type:"display-disconnected"});break;case"42":e.name="Product under elevator",e.description="Product alarm under elevator",e.no_code=20,o(this,g,Y).call(this),o(this,g,tt).call(this,{type:"product-under-elevator"});break;case"43":e.name="Error when elevator approaching to a position",e.description="Error when elevator approaching to a position",e.no_code=21,o(this,g,ft).call(this),o(this,g,tt).call(this,{type:"error-approaching-position",severity:"high"});break;case"44":e.name="Fault in keyboard",e.description="Fault in keyboard",e.no_code=22,o(this,g,Y).call(this),o(this,g,wt).call(this,{type:"fault-keyboard"});break;case"45":e.name="Eeprom writing error",e.description="Eeprom writing error",e.no_code=23,o(this,g,Y).call(this),o(this,g,wt).call(this,{type:"eeprom-writing-error",severity:"critical"});break;case"46":e.name="Fault communicating with temperature control",e.description="Fault communicating with temperature control",e.no_code=24,o(this,g,ft).call(this),o(this,g,tt).call(this,{type:"fault-temperature-control"});break;case"47":e.name="Thermometer disconnected",e.description="The thermometer is disconnected",e.no_code=25,o(this,g,ft).call(this),o(this,g,tt).call(this,{type:"thermometer-disconnected"});break;case"48":e.name="Thermometer programming lost",e.description="Thermometer programming lost",e.no_code=26,o(this,g,ft).call(this),o(this,g,tt).call(this,{type:"thermometer-programming-lost"});break;case"49":e.name="Thermometer faulty",e.description="Thermometer faulty",e.no_code=27,o(this,g,ft).call(this),o(this,g,tt).call(this,{type:"thermometer-faulty"});break;case"4a":e.name="Channels power consumption detector faulty",e.description="Channels power consumption detector faulty",e.no_code=28,o(this,g,Y).call(this),o(this,g,wt).call(this,{type:"channels-power-consumption-detector-faulty",severity:"critical"});break;case"4b":e.name="Elevator does not find channel or tray",e.description="Elevator does not find channel or tray",e.no_code=29,o(this,g,Y).call(this),o(this,g,tt).call(this,{type:"elevator-not-find-channel-tray"});break;case"4c":e.name="Elevator does not find delivery product position",e.description="Elevator does not find delivery product position",e.no_code=30,o(this,g,Y).call(this),o(this,g,wt).call(this,{type:"elevator-not-find-delivery-position"});break;case"4d":e.name="Interior of elevator blocked",e.description="Interior of elevator blocked",e.no_code=31,o(this,g,qe).call(this),this.__internal__.dispense.elevator.need_reset||(this.__internal__.dispense.elevator.need_reset=!0),o(this,g,wt).call(this,{type:"interior-elevator-blocked",severity:"low"});break;case"4e":e.name="Error in tester of product detector",e.description="Error in tester of product detector",e.no_code=32,o(this,g,Y).call(this),o(this,g,wt).call(this,{type:"error-tester-product-detector"});break;case"4f":e.name="Waiting for product to be removed",e.description="Waiting for product to be removed",e.no_code=33,o(this,g,qe).call(this);break;case"50":e.name="Product expired by temperature reasons",e.description="Product expired by temperature reasons",e.no_code=34,o(this,g,ft).call(this),o(this,g,tt).call(this,{type:"product-expired-temperature"});break;case"51":e.name="Automatic door faulty",e.description="Automatic door faulty",e.no_code=35,o(this,g,ft).call(this),o(this,g,tt).call(this,{type:"automatic-door-faulty"});break;case"59":case"5a":case"61":case"62":case"63":switch(e.name="Product is expired",e.description="Product is expired",e.additional={nsf_alarm:1},t[1]){case"5a":e.additional.nsf_alarm=2;break;case"61":e.additional.nsf_alarm=3;break;case"62":e.additional.nsf_alarm=4;break;case"63":e.additional.nsf_alarm=5;break}e.no_code=36,o(this,g,ft).call(this),o(this,g,tt).call(this,{type:"product-expired"});break;case"64":e.name="Product detector didn't change during its verification test",e.description="Product detector didn't change during its verification test",e.no_code=37,o(this,g,ft).call(this),o(this,g,tt).call(this,{type:"automatic-door-faulty"});break}this.dispatch("machine:status",e)}else e.name="executed",e.description="The last command was executed successfully",e.no_code=8,!t[1]&&this.__internal__.dispense.dispensing&&o(this,g,Y).call(this);return e},Ds=function(t){if(t=parseInt(t)+109,t=t.toString(),t.length!==3)throw new Error("Invalid selection");const e=(parseInt(t.substring(0,2))+128).toString(16).padStart(2,"0");return{channel:(parseInt(t.substring(2,3))+128).toString(16).padStart(2,"0"),tray:e}},Rs=function(){this.__internal__.dispense.timeout&&clearTimeout(this.__internal__.dispense.timeout),this.__internal__.dispense.interval&&clearInterval(this.__internal__.dispense.interval),this.__internal__.dispense.timeout=0,this.__internal__.dispense.interval=0},Is=function(){this.__internal__.dispense.timeout&&clearTimeout(this.__internal__.dispense.timeout),this.__internal__.dispense.interval&&clearInterval(this.__internal__.dispense.interval);const t=this;t.__internal__.dispense.timeout=setTimeout(()=>{t.__internal__.dispense.interval=setInterval(()=>{t.status().then(()=>{})},t.__internal__.dispense.interval_time)},t.__internal__.dispense.timeout_time)},ue=async function(t){const e=["02","30","30","81","52",t,"FF"];return await o(this,g,ot).call(this,e,"reset")},Bn=function(){const t=this.__device.type==="iceplus"?Xe(40):Xe(25),e=new Date,n=1e3*t+e.getTime(),s=new Date(n);this.dispatch("reset:errors",{description:"Resetting machine errors",duration:t,started_at:e,finished_at:s})},Nn=async function(t){const e=["02","30","30","81","4C",t,"FF"];return await o(this,g,ot).call(this,e,"lights")},je=async function(t="80",e=[]){const n=["02","30","30","81","44",t,...e];return await o(this,g,ot).call(this,n,"display")},He=function(t=""){t=t.padEnd(32," ");const e=[];for(let n=0;n<32;n++)e.push(t.charCodeAt(n).toString(16));return e},Os=function(t){if(!(t instanceof Date))throw new Error("Invalid date, must be an instance of Date");const e=t.getHours().toString().padStart(2,"0"),n=t.getMinutes().toString().padStart(2,"0"),s=t.getDate().toString().padStart(2,"0"),a=(t.getMonth()+1).toString().padStart(2,"0"),c=t.getFullYear().toString().substring(2,4),l=`${e}:${n} ${s}-${a}-${c}`,h=[];for(let f=0;f<14;f++)h.push(l.charCodeAt(f).toString(16));return h};class _c extends kt{constructor({filters:t=null,config_port:e=null,no_device:n=1}={}){super({filters:t,config_port:e,no_device:n});J(this,w);Z(this,"__coin_purse",{available:!0});Z(this,"__banknote_purse",{available:!0,isRecycler:!0,recycler:{ict:!0,banknote:1}});Z(this,"__sale",{price:0,change:0,change_verified:0,dispense_all:!0,last_change:0,clear(){this.price=0,this.change=0,this.change_verified=0,this.dispense_all=!0,this.last_change=0}});Z(this,"__money_session",{inserted:0,retired:0,clear(){this.inserted=0,this.retired=0}});Z(this,"coins",{tubes:{g50:0,c50:0,p1:0,p2:0,p5:0,p10:0},box:{g50:0,c50:0,p1:0,p2:0,p5:0,p10:0},totals:{g50:0,c50:0,p1:0,p2:0,p5:0,p10:0},total:0});Z(this,"banknotes",{stacker:{p20:0,p50:0,p100:0,p200:0,p500:0,p1000:0},recycler:{p20:0,p50:0,p100:0,p200:0,p500:0,p1000:0},out:{p20:0,p50:0,p100:0,p200:0,p500:0,p1000:0},totals:{p20:0,p50:0,p100:0,p200:0,p500:0,p1000:0},total:0});Z(this,"card_reader",{available:!1,max_pre_credit:0});J(this,Gt,!1);J(this,Nt,0);J(this,$t,0);if(this.__internal__.device.type="boardroid",K.getCustom(this.typeDevice,n))throw new Error(`Device ${this.typeDevice} ${n} already exists`);this.__internal__.serial.config_port.baudRate=115200,this.__internal__.serial.response.length=14,this.__internal__.time.response_connection=600,this.__internal__.time.response_general=4e3,this.__internal__.time.response_engines=15e3,this.__internal__.dispense.limit_counter=15,this.__internal__.dispense.custom_limit_counter=null,this.__internal__.dispense.backup_dispense={channel:1,second_channel:null,sensor:!0,seconds:null},o(this,w,Bs).call(this),o(this,w,Ns).call(this)}get totalInTubes(){return this.coins.tubes.g50*.5+this.coins.tubes.c50*.5+this.coins.tubes.p1+this.coins.tubes.p2*2+this.coins.tubes.p5*5+this.coins.tubes.p10*10}get totalInRecycler(){return this.banknotes.recycler.p20*20+this.banknotes.recycler.p50*50+this.banknotes.recycler.p100*100+this.banknotes.recycler.p200*200+this.banknotes.recycler.p500*500+this.banknotes.recycler.p1000*1e3}get hasRecycler(){return this.__banknote_purse.available&&this.__banknote_purse.isRecycler}set hasRecycler(t){this.__banknote_purse.isRecycler=t}get hasICT(){return this.hasRecycler&&this.__banknote_purse.recycler.ict}set hasICT(t){this.__banknote_purse.recycler.ict=t}set banknoteICT(t){if(![20,50,100,200,500].includes(t))throw new Error(`Invalid banknote value: ${t}`);t=[20,50,100,200,500].indexOf(t),this.__banknote_purse.recycler.banknote=t}get banknoteICT(){return[20,50,100,200,500][this.__banknote_purse.recycler.banknote]}get hasCoinPurse(){return this.__coin_purse.available}set hasCoinPurse(t){if(typeof t!="boolean")throw new Error(`Invalid value: ${t}`);this.__coin_purse.available=t}set price(t){let e=parseFloat(t);(isNaN(e)||e<0)&&(e=0),this.__sale.price=e}get price(){return this.__sale.price}get change(){return this.__sale.price<=0||this.__money_session.inserted<=this.__sale.price?0:this.__money_session.inserted-this.__sale.price}softReload(){super.softReload(),this.__sale.clear(),this.__money_session.clear()}serialBoardroidSumHex(t){let e=0;return t.forEach((n,s)=>{s!==0&&s!==11&&(e+=parseInt(n,16))}),e.toString(16).toUpperCase()}serialMessage(t){let e={code:t,name:null,description:null,request:null,no_code:0};const n=(5+this.deviceNumber).toString(16).padStart(2,"0").toLowerCase();switch(t[1]){case n:e.request="connect",e=o(this,w,Fs).call(this,e);break;case"a0":e.request="--automatic",e=o(this,w,Ks).call(this,t,e);break;case"b0":e.request="--automatic",e=o(this,w,Ws).call(this,t,e);break;case"d0":e.request="coin-purse:config",e=o(this,w,zs).call(this,t[2],e);break;case"d1":e.request="banknote-purse:config",e.additional={scrow:null},e=o(this,w,Xs).call(this,t,e);break;case"d2":e.request="coin-purse:read-tubes",e=o(this,w,Gs).call(this,t,e);break;case"d3":e.request="banknote-purse:read-recycler",e=o(this,w,$s).call(this,t,e);break;case"d4":e.request="banknote-purse:banknote-scrow-status",e=o(this,w,Js).call(this,t[2],e);break;case"d5":e.request="banknote-purse:dispense",e=o(this,w,Qs).call(this,t,e);break;case"d6":e.request="coin-purse:dispense",e=o(this,w,Zs).call(this,t,e);break;case"d7":e.request="dispense",e=o(this,w,Ys).call(this,t[5],e);break;case"d8":e.request="--automatic",e=o(this,w,ta).call(this,t[13],e);break;case"d9":e.request="status:temperature",e=o(this,w,ea).call(this,t,e);break;case"da":e.request="status:relay",e=o(this,w,na).call(this,t[2],e);break;case"db":e.request="banknote-purse:save-memory",e.no_code=18,e.name="Bill purse memory saved?",e.description="The memory of bill purse was saved successfully?",this.dispatch("banknote-purse:save-memory",{message:e});break;case"dc":e.request="coin-purse:read-memory",e.no_code=19,e.name="Coin purse memory read?",e.description="The memory of coin purse was read successfully?",this.dispatch("banknote-purse:read-memory",{message:e});break;case"dd":e.request="card-reader",o(this,w,ia).call(this,t,e);break;default:e.request="--unknown",e.name="Response unrecognized",e.description="The response of application was received, but dont identify with any of current parameters",e.no_code=400,this.dispatch("unknown",e);break}this.dispatch("serial:message",e)}serialSetConnectionConstant(t=1){let e=["F1","06","00","00","00","00","00","00","00","00","F2","F8"];return e[1]=this.hexMaker(this.decToHex((5+t).toString())),e[11]=this.serialBoardroidSumHex(e),this.add0x(e)}async coinPurseConfigure({enable:t=!1,high:e="FF",low:n="FF"}={}){if(!this.__coin_purse.available)throw new Error("Coin purse not available");const a=["F1","C1",t?"01":"00",e,n,"00","00","00","00","00","F2","00"];await o(this,w,ct).call(this,a,"coin-purse:config")}async coinPurseEnable(){await this.coinPurseConfigure({enable:!0})}async coinPurseDisable(){await this.coinPurseConfigure({enable:!1})}async coinPurseDispense({$_50c:t=0,$_1:e=0,$_2:n=0,$_5:s=0,$_10:a=0}={}){if(!this.__coin_purse.available)throw new Error("Coin purse not available");if([t,e,n,s,a].some(l=>isNaN(l)||typeof l=="string"))throw new Error("One of the values is not a number");if(t<1&&e<1&&n<1&&s<1&&a<1)throw new Error("No coins to dispense");[t,e,n,s,a]=[this.decToHex(t),this.decToHex(e),this.decToHex(n),this.decToHex(s),this.decToHex(a)];let c=["F1","C6",t,e,n,s,a,"00","00","00","F2","00"];await o(this,w,ct).call(this,c,"coin-purse:dispense")}async coinPurseReadTubes(){const t=["F1","C2","00","00","00","00","00","00","00","00","F2","00"];await o(this,w,ct).call(this,t,"coin-purse:read-tubes")}async banknotePurseConfigure({enable:t=!1,scrow:e=!1}={}){if(!this.__banknote_purse.available)throw new Error("Banknote purse not available");let n;return o(this,w,Ke).call(this)?n=o(this,w,ra).call(this,{enable:t,scrow:e}):n=o(this,w,sa).call(this,{enable:t,scrow:e}),await o(this,w,ct).call(this,n,"banknote-purse:config")}async banknotePurseDispense({$_20:t=0,$_50:e=0,$_100:n=0,$_200:s=0,$_500:a=0,$_1000:c=0}={}){if(!this.__banknote_purse.available)throw new Error("Banknote purse not available");if(!this.__banknote_purse.isRecycler)throw new Error("Banknote purse is not recycler");let l;if(o(this,w,Ke).call(this)){const h=[t,e,n,s,a];l=o(this,w,aa).call(this,h[this.__banknote_purse.recycler.banknote])}else l=o(this,w,oa).call(this,{$_20:t,$_50:e,$_100:n,$_200:s,$_500:a,$_1000:c});await o(this,w,ct).call(this,l,"banknote-purse:dispense")}async banknotePurseEnable({scrow:t=!1}){return await this.banknotePurseConfigure({enable:!0,scrow:t})}async banknotePurseDisable(){return await this.banknotePurseConfigure({enable:!1})}async banknotePurseAcceptInScrow(){if(!this.__banknote_purse.available)throw new Error("Banknote purse not available");const t=["F1","C4","01","00","00","00","00","00","00","00","F2","00"];await o(this,w,ct).call(this,t,"banknote-purse:banknote-scrow-status")}async banknotePurseRejectInScrow(){if(!this.__banknote_purse.available)throw new Error("Banknote purse not available");const t=["F1","C4","00","00","00","00","00","00","00","00","F2","00"];await o(this,w,ct).call(this,t,"banknote-purse:banknote-scrow-status")}async banknotePurseSaveMemory({channel:t=null,$_20:e=null,$_50:n=null,$_100:s=null,$_200:a=null,$_500:c=null,$_1000:l=null}={}){if(!this.__banknote_purse.available)throw new Error("Banknote purse not available");if(t===null||e===null||n===null||s===null||a===null||c===null||l===null)throw new Error("One of the values is not defined");const h=["F1","C8",this.decToHex(t),"00",this.decToHex(e),this.decToHex(n),this.decToHex(s),this.decToHex(a),this.decToHex(c),this.decToHex(l),"F2","00"];await o(this,w,ct).call(this,h,"banknote-purse:save-memory")}async banknotePurseReadRecycler(){if(!this.__banknote_purse.available)throw new Error("Banknote purse not available");if(!this.__banknote_purse.isRecycler)throw new Error("Banknote purse is not recycler");const t=["F1","C3","00","00","00","00","00","00","00","00","F2","B5"];return await o(this,w,ct).call(this,t,"banknote-purse:read-recycler")}async cardReaderDisable(){if(!this.card_reader.available)throw new Error("Card reader not available");const t=["F1","CD","00","00","00","00","00","00","00","00","F2","00"];return await o(this,w,ct).call(this,t,"card-reader:disable")}async cardReaderDispense({channel:t=1,second_channel:e=null,sensor:n=!0,seconds:s=null,price:a=0}={}){if(!this.card_reader.available)throw new Error("Card reader not available");if(isNaN(this.card_reader.max_pre_credit)||this.card_reader.max_pre_credit===0)throw new Error("Card reader pre-credit not configured");if(isNaN(a)||a<=0)throw new Error("Price must be greater than 0");if(a>this.card_reader.max_pre_credit)throw new Error("Price is greater than pre-credit configured");if(!n&&(s===null||s<=0||s>40))throw new Error("Invalid time to dispense without sensor, must be between 0.1 and 40.0 seconds");const c=this.decToHex(a/256),l=this.decToHex(a%256),h=this.decToHex(t+9);let f="00";e&&(f=this.decToHex(e+9));let _="00";n||(_=this.decToHex(s*10));const m=["F1","CD","01",h,f,_,c,l,"00","00","F2","00"];await o(this,w,ct).call(this,m,"card-reader:dispense")}async paymentPursesDisable({coin:t=!0,banknote:e=!0,cardReader:n=!1}={}){t&&await this.coinPurseDisable(),e&&await this.banknotePurseDisable(),n&&await this.cardReaderDisable()}async paymentPursesEnable({coin:t=!0,banknote:e=!0,scrowBanknote:n=!1}={}){t&&await this.coinPurseEnable(),e&&await this.banknotePurseEnable({scrow:n})}async coolingRelayConfigure({enable:t=!1}={}){const n=["F1","CC",t?"01":"00","00","00","00","00","00","00","00","F2","00"];return await o(this,w,ct).call(this,n,"status:relay")}async coolingRelayEnable(){return await this.coolingRelayConfigure({enable:!0})}async coolingRelayDisable(){return await this.coolingRelayConfigure({enable:!1})}async readTemperature(){const t=["F1","CB","00","00","00","00","00","00","00","00","F2","00"];return await o(this,w,ct).call(this,t,"status:temperature")}async dispense({selection:t=1,second_selection:e=null,sensor:n=!0,seconds:s=null,retry:a=!0}={}){if(t=parseInt(t),isNaN(t)||t<1||t>80)throw new Error("Invalid channel number");if(e!==null&&(e<1||e>80||e===t))throw new Error("Invalid second channel number");if(!n&&(s===null||s<=0||s>40))throw new Error("Invalid time to dispense without sensor, must be between 0.1 and 40.0 seconds");a&&(this.__internal__.dispense.backup_dispense={selection:t,second_selection:e,sensor:n,seconds:s}),t+=9;const c=this.decToHex(t);let l="00";e&&(e+=9,l=this.decToHex(e));let h="00";n||(h=this.decToHex(Math.round(s*6.2)),this.__internal__.dispense.custom_limit_counter=s);const f=o(this,w,We).call(this,["F1","C7",c,l,h,"00","00","00","00","00","F2","00"]);let _=await this.internalDispense(f);return!_.dispensed&&a&&(_=await this.internalDispense(f)),this.__internal__.dispense.custom_limit_counter=null,_}async testEngines({singleEngine:t=!1}={}){if(this.isDispensing)throw new Error("Another dispensing process is running");if(O(this,Gt))throw new Error("Another test is running");o(this,w,Fn).call(this),L(this,Gt,!0);const e=[];o(this,w,ze).call(this);for(let n=1;n<=80;n++){const s=await this.dispense({selection:n,second_selection:t?null:n+1,sensor:!1,seconds:.4,retry:!1});e.push(s),L(this,Nt,n),o(this,w,ze).call(this),t||n++}L(this,Nt,80),o(this,w,ze).call(this,{dispensed:e}),o(this,w,Fn).call(this)}async sendCustomCode({code:t=[]}={}){if(t.length===0)throw new Error("Invalid code");const e=o(this,w,We).call(this,t);await this.appendToQueue(e,"custom")}hasToReturnChange(t=0){let e=t;return e<=0?!0:(e=o(this,w,Un).call(this,e).pending,e=o(this,w,Ln).call(this,e).pending,!(e>0))}async returnChange(){return await o(this,w,Vn).call(this)}async returnInsertedMoney(){return this.__money_session.inserted<=0?!1:await o(this,w,Vn).call(this,this.__money_session.inserted)}async serialCorruptMessage(t,e){this.dispatch("corrupt:message",{data:t,message:e})}}Gt=new WeakMap,Nt=new WeakMap,$t=new WeakMap,w=new WeakSet,Bs=function(){const t=["banknote-purse:banknote-scrow-status","banknote-purse:config","banknote-purse:event-banknote","banknote-purse:read-memory","banknote-purse:recycler","banknote-purse:save-memory","card-reader:event","change:pending","change:dispense","coin-purse:coin-event","coin-purse:config","coin-purse:reject-lever","coin-purse:reset","coin-purse:tubes","percentage:test","run:default-load","session:money-dispensed","session:money-request","event:door","door:event","status:relay","status:temperature"];for(const e of t)this.serialRegisterAvailableListener(e)},Ns=function(){K.add(this)},Ke=function(){return this.__banknote_purse.isRecycler&&this.__banknote_purse.recycler.ict},Ms=function(){return this.hasCoinPurse||this.hasRecycler},Fs=function(t){return t.name="Connection with the serial device completed.",t.description="Your connection with the serial device was successfully completed.",t.no_code=1,this.dispatch("run:default-load",{}),t},Us=function(t){const e={g50:["40","50","60","70","90"],c50:["41","51","61","71","91"],p1:["42","52","62","72","92"],p2:["43","53","63","73","93"],p5:["44","54","64","74","94"],p10:["45","55","65","75","95"],p20:["47","57","67","77","97"]};let n=null;for(let a in e)if(e[a].includes(t)){n=a;break}return n?[{g50:"50 pennies (the big one)",c0:"50 pennies (the little one)",p1:"1 peso",p2:"2 pesos",p5:"5 pesos",p10:"10 pesos",p20:"20 pesos"}[n],n]:[`Undefined value: ¿${t}?`,null]},Ls=function(t){return["g50","c50","p1","p2","p5","p10","p20"].includes(t)},Vs=function(t){const e={p20:["80","90","a0","b0"],p50:["81","91","a1","b1"],p100:["82","92","a2","b2"],p200:["83","93","a3","b3"],p500:["84","94","a4","b4"],p1000:["85","95","a5","b5"]};let n=null;for(let a in e)if(e[a].includes(t)){n=a;break}return n?[{p20:"20 pesos",p50:"50 pesos",p100:"100 pesos",p200:"200 pesos",p500:"500 pesos",p1000:"1000 pesos"}[n],n]:[`Undefined value: ¿${t}?`,null]},qs=function(t){return["p20","p50","p100","p200","p500","p1000"].includes(t)},js=function(t){return["r20","r50","r100"].includes(t)},Hs=function(){return["r20","r50","r100","r200","r500"][this.__banknote_purse.recycler.banknote]},Mn=function(t,e,n){if(!t)return;let s=!0;if(o(this,w,Ls).call(this,t)&&n==="coin"){if(typeof this.coins.tubes[t]>"u")return;e==="tube"?this.coins.tubes[t]+=1:e==="box"&&(this.coins.box[t]+=1);let a=0;["g50","c50"].includes(t)?a=.5:a+=parseInt(t.slice(1)),this.coins.totals[t]+=a,this.__money_session.inserted+=a,this.coins.total+=a}else if(o(this,w,qs).call(this,t)&&n==="banknote"){if(typeof this.banknotes.recycler[t]>"u")return;e==="recycler"?this.banknotes.recycler[t]+=1:e==="stacker"&&(this.banknotes.stacker[t]+=1);let a=parseInt(t.slice(1));this.banknotes.totals[t]+=a,this.__money_session.inserted+=a,this.banknotes.total+=a}else if(o(this,w,js).call(this,t)&&e==="out"&&n==="banknote"){if(typeof this.banknotes.out[t.replace("r","p")]>"u")return;this.banknotes.out[t.replace("r","p")]+=1;let a=parseInt(t.slice(1));this.__money_session.retired+=a,this.banknotes.recycler[t.replace("r","p")]-=1,this.banknotes.total-=a,s=!1,this.dispatch("session:money-dispensed",{type_money:t,retired:a,finish:!1,type:"banknotes"})}s&&this.dispatch("session:money-request",{})},Ks=function(t,e){const n=parseInt(t[2],16);return e.name="Coin Inserted",e.no_code=2,e.additional={where:null,coin:null},n===1?(e.name="Lever pressed",e.description="Reject lever",e.no_code=100,this.dispatch("coin-purse:reject-lever",{})):n===2?(e.name="Reset coin purse",e.description="The configuration of coin purse was reset",e.no_code=101,this.dispatch("coin-purse:reset",{})):n>=64&&n<=79?(e.name="Coin inserted in profit box",e.additional.where="box"):n>=80&&n<=95?(e.name="Coin inserted in tube",e.additional.where="tube"):n>=96&&n<=111?(e.name="Unused coin",e.description="Something come from coin changer but in MDB Docs is unused",e.additional.where="unused"):n>=112&&n<=127?(e.name="Coin rejected",e.additional.where="rejected"):n>=144&&n<=159?(e.name="Coin dispensed",e.additional.where="out",e.description=`Undefined value: ¿${t[2]}?`):(e.name="Coin inserted",e.description="Undefined status. Without information of this",e.no_code=400),n===1||n===2||n>=160||n>=128&&n<=143||([e.description,e.additional.coin]=o(this,w,Us).call(this,t[2]),e.no_code=38+n,o(this,w,Mn).call(this,e.additional.coin,e.additional.where,"coin"),["tube","out"].includes(e.additional.where)&&this.dispatch("coin-purse:tubes",this.coins.tubes),this.dispatch("coin-purse:coin-event",this.coins)),e},Ws=function(t,e){const n=parseInt(t[2],16);return e.name="Banknote Inserted",e.no_code=2,e.additional={where:null,banknote:null},n===42?(e.name="Banknote dispensed",e.description="Banknote dispensed by request.",e.additional.banknote=o(this,w,Hs).call(this),e.additional.where="out",e.no_code=200):n>=128&&n<=143?(e.name="Banknote inserted",e.additional.where="stacker"):n>=144&&n<=159?(e.name="Banknote inserted in pre stacker",e.additional.where="tmp"):n>=160&&n<=175?(e.name="Banknote rejected",e.additional.where="nothing"):n>=176&&n<=191&&(e.name="Banknote inserted",e.additional.where="recycler"),n>=128&&n<=191&&([e.description,e.additional.banknote]=o(this,w,Vs).call(this,t[2]),e.no_code=74+n),o(this,w,Mn).call(this,e.additional.banknote,e.additional.where,"banknote"),this.dispatch("banknote-purse:event-banknote",this.banknotes),e},zs=function(t,e){const n=parseInt(t,16);return n===1?(e.name="Coin purse enabled",e.description="Configuration complete, enabled",e.no_code=3):n===0?(e.name="Coin purse disabled",e.description="Disabled by system request",e.no_code=4):(e.name="Status unknown",e.description="The response of coin purse doesn't identify successfully",e.no_code=400),this.dispatch("coin-purse:config",{enabled:n===1}),e},Xs=function(t,e){const n=parseInt(t[2],16),s=parseInt(t[3],16);return n===0?(e.name="Bill purse disabled",e.description="Configuration complete, disabled"):n===1&&(e.name="Bill purse enabled",e.description="Configuration complete, enabled"),s===0?e.additional.scrow="Scrow disabled, banknote received automatic":s===1&&(e.additional.scrow="Scrow enabled, require manual action"),e.no_code=5,this.dispatch("banknote-purse:config",{enabled:n===1,scrow:s===1}),e},Gs=function(t,e){e.no_code=6;const[n,s,a,c,l,h]=[parseInt(t[2],16),parseInt(t[3],16),parseInt(t[4],16),parseInt(t[5],16),parseInt(t[6],16),parseInt(t[7],16)];return e.additional={coins:{g50:n,c50:s,p1:a,p2:c,p5:l,p10:h}},this.coins.tubes.g50=n,this.coins.tubes.c50=s,this.coins.tubes.p1=a,this.coins.tubes.p2=c,this.coins.tubes.p5=l,this.coins.tubes.p10=h,this.coins.totals.g50=(this.coins.box.g50+n)*.5,this.coins.totals.c50=(this.coins.box.c50+s)*.5,this.coins.totals.p1=this.coins.box.p1+a,this.coins.totals.p2=(this.coins.box.p2+c)*2,this.coins.totals.p5=(this.coins.box.p5+l)*5,this.coins.totals.p10=(this.coins.box.p10+h)*10,this.coins.total=this.coins.totals.g50+this.coins.totals.c50+this.coins.totals.p1+this.coins.totals.p2+this.coins.totals.p5+this.coins.totals.p10,e.name="Read tubes",e.description="Quantity of coins approximated",this.dispatch("coin-purse:tubes",this.coins.tubes),e},$s=function(t,e){e.no_code=7;const[n,s,a,c,l,h]=[parseInt(t[2],16),parseInt(t[3],16),parseInt(t[4],16),parseInt(t[5],16),parseInt(t[6],16),parseInt(t[7],16)];return e.additional={banknotes:{b20:n,b50:s,b100:a,b200:c,b500:l,b1000:h}},this.banknotes.recycler.p20=n,this.banknotes.recycler.p50=s,this.banknotes.recycler.p100=a,this.banknotes.recycler.p200=c,this.banknotes.recycler.p500=l,this.banknotes.recycler.p1000=h,this.banknotes.totals.p20=(this.banknotes.stacker.p20+n)*20,this.banknotes.totals.p50=(this.banknotes.stacker.p50+s)*50,this.banknotes.totals.p100=(this.banknotes.stacker.p100+a)*100,this.banknotes.totals.p200=(this.banknotes.stacker.p200+c)*200,this.banknotes.totals.p500=(this.banknotes.stacker.p500+l)*500,this.banknotes.totals.p1000=(this.banknotes.stacker.p1000+h)*1e3,this.banknotes.total=this.banknotes.totals.p20+this.banknotes.totals.p50+this.banknotes.totals.p100+this.banknotes.totals.p200+this.banknotes.totals.p500+this.banknotes.totals.p1000,e.name="Read recycler",e.description="Quantity of banknotes approximated",this.dispatch("banknote-purse:recycler",this.banknotes.recycler),e},Js=function(t,e){const n=parseInt(t,16);return n===1?e.name="Banknote accepted":n===0?e.name="Banknote rejected":e.name="Unknown status banknote",e.no_code=8,this.dispatch("banknote-purse:banknote-scrow-status",{status:n===1}),e},Qs=function(t,e){const[n,s,a,c,l,h]=[parseInt(t[2],16),parseInt(t[3],16),parseInt(t[4],16),parseInt(t[5],16),parseInt(t[6],16),parseInt(t[7],16)],f=n*20+s*50+a*100+c*200+l*500+h*1e3;return e.name="Banknotes dispensed",e.description=f>0?"Banknotes dispensed by request":"No banknotes dispensed, recycler empty",e.no_code=9,e.additional={banknotes:{b20:n,b50:s,b100:a,b200:c,b500:l,b1000:h},total_dispensed:f},this.dispatch("session:money-dispensed",{type_money:null,retired:null,finish:!1,type:"banknotes",data:e}),e},Zs=function(t,e){return e.name="Coins dispensed",e.no_code=10,e.description="Coins dispensed by request",isNaN(this.__sale.last_change)&&(this.__sale.last_change=0),this.__money_session.retired+=this.__sale.last_change,this.dispatchAsync("session:money-dispensed",{type_money:null,retired:null,finish:!1,type:"coins"},500),e},Ys=function(t,e){const n=parseInt(t,16);return n===1?(e.name="Product not delivered",e.description="The product requested wasn't delivered",e.no_code=11,this.__internal__.dispense.status=!1):n===0?(e.name="Product delivered",e.description="The product requested was delivered",e.no_code=12,this.__internal__.dispense.status=!0):(e.name="Unknown status product",e.description="The response of product doesn't identify successfully",e.no_code=400,this.__internal__.dispense.status=!1),this.dispatch("dispensed",{}),e},ta=function(t,e){let n="closed";return t==="db"?(e.name="Door closed",e.no_code=13):t==="dc"?(e.name="Door open",e.no_code=14,n="open"):(e.name="Unknown status door",e.description="The response of door doesn't identify successfully",e.no_code=400,n="unknown"),this.__internal__.device.door_open=n==="open",this.dispatch("event:door",{open:n==="open"}),this.dispatch("door:event",{open:n==="open"}),e},ea=function(t,e){const n=parseInt(t[2],16)*255,s=parseInt(t[3],16),a=(n+s)*.1;return e.no_code=15,e.name="Temperature status",e.description=`Temperature: ${a}`,e.additional={high:n,low:s,temperature:parseFloat(a.toString())},this.dispatch("status:temperature",e.additional),e},na=function(t,e){const n=parseInt(t,16);let s="unknown";return n===1?(e.name="Relay on",e.description="Relay on",e.no_code=16,s="on"):n===0?(e.name="Relay off",e.description="Relay off",e.no_code=17,s="off"):(e.name="Status unknown",e.description="Status unknown",e.no_code=400),this.dispatch("status:relay",{enabled:s==="on"}),e},ia=function(t,e){const n=parseInt(t[2],16);if(e.no_code=20+n,e.name="Status unknown",e.description="The status of card reader does not identified correctly",n===0)e.request+=":disable",e.name="Card reader disabled",e.description="Card reader device was disabled successfully";else if(n===1||n===2)e.request+=":dispense",e.name="Card reader enabled",e.description="Card reader device is now enabled";else if(n===3)e.request+=":pre-authorize",e.name="Pre-authorized credit",e.description="The pre credit was authorized successfully";else if(n===4)e.request+=":cancel",e.name="Cancellation in progress",e.description="Cancellation request done successfully";else if(n===5)e.request+=":sell",e.name="Sell approved",e.description="Sell approved, starting dispense product";else if(n===6)e.request+=":sell",e.name="Sell denied",e.description="This sell was denied, try again";else if(n===7)e.request+=":end",e.name="Session ended",e.description="The session ended";else if(n===8)e.request+=":cancel",e.name="Cancelled",e.description="Cancellation complete";else if(n===10){const s=parseInt(t[8],16);s===0?(e.no_code=30,e.name="product not dispensed",e.description="The product requested wasn't delivered"):s===1&&(e.no_code=31,e.name="product dispensed",e.description="The product requested was delivered")}else e.no_code=400;return this.dispatch("card-reader:event",e),e},ct=function(t,e){return this.appendToQueue(o(this,w,We).call(this,t),e)},We=function(t){return t[11]=this.serialBoardroidSumHex(t),t.map((e,n)=>{t[n]=this.hexMaker(e)}),t},ra=function({enable:t=!1,scrow:e=!1}={}){const n=t?"FF":"00",s=e?"FF":"00";return["F1","C0",n,n,s,s,"00","00","00","00","F2","00"]},sa=function({enable:t=!1,scrow:e=!1}={}){return["F1","C0",t?"01":"00",e?"01":"00","00","00","00","00","00","00","F2","00"]},aa=function(t=1){if(t<1)throw new Error("No banknotes to dispense");return t=this.decToHex(t),["F1","C5",this.decToHex(this.__banknote_purse.recycler.banknote.toString()),t,"00","00","00","00","00","00","F2","00"]},oa=function({$_20:t=0,$_50:e=0,$_100:n=0,$_200:s=0,$_500:a=0,$_1000:c=0}={}){if([t,e,n,s,a,c].some(l=>isNaN(l)||typeof l=="string"))throw new Error("One of the values is not a number");if(t<1&&e<1&&n<1&&s<1&&a<1&&c<1)throw new Error("No banknotes to dispense");return[t,e,n,s,a,c]=[this.decToHex(t),this.decToHex(e),this.decToHex(n),this.decToHex(s),this.decToHex(a),this.decToHex(c)],["F1","C5",t,e,n,s,a,c,"00","00","F2","00"]},Fn=function(){L(this,Gt,!1),L(this,Nt,0),L(this,$t,0)},ze=function({dispensed:t=null,limit:e=80}={}){L(this,$t,Math.round(O(this,Nt)*100/e)),this.dispatch("percentage:test",{percentage:O(this,$t),dispensed:t})},ca=function(t){const e=["20","50","100","200","500"],n=this.__banknote_purse.recycler.banknote,s="$_"+e[n],a=parseInt(e[n]),c=this.banknotes.recycler[`p${e[n]}`],l=Math.min(Math.floor(t/a),c),h={banknotes:{$_20:0,$_50:0,$_100:0,$_200:0,$_500:0,$_1000:0},pending:t,will_dispense:l>0};return this.totalInRecycler===0||l<1||t===0||(h.banknotes[s]=l,h.pending=parseFloat((t-l*a).toFixed(2))),h},la=function(t){const e={banknotes:{$_20:0,$_50:0,$_100:0,$_200:0,$_500:0,$_1000:0},pending:t,will_dispense:!1};if(this.totalInRecycler===0||t===0)return e;const n=(s,a)=>{if(this.banknotes.recycler[a]>0){const c=Math.floor(e.pending/s),l=Math.min(c,this.banknotes.recycler[a]);e.banknotes[`$_${s}`]=l,e.pending=parseFloat((e.pending-l*s).toFixed(2))}};return n(1e3,"p1000"),n(500,"p500"),n(200,"p200"),n(100,"p100"),n(50,"p50"),n(20,"p20"),e.will_dispense=Object.values(e.banknotes).some(s=>s>0),e},Un=function(t){return o(this,w,Ke).call(this)?o(this,w,ca).call(this,t):o(this,w,la).call(this,t)},Ln=function(t){const e={coins:{$_50c:0,$_1:0,$_2:0,$_5:0,$_10:0},pending:t,will_dispense:!1};if(t<=0||this.totalInTubes===0)return e;const n=(s,a,c=null)=>{if(this.coins.tubes[a]>0){c===null&&(c="$_"+s);const l=Math.floor(e.pending/s),h=Math.min(l,this.coins.tubes[a]);e.coins[c]=h,e.pending=parseFloat((e.pending-h*s).toFixed(2))}};return n(10,"p10"),n(5,"p5"),n(2,"p2"),n(1,"p1"),n(.5,"g50","$_50c"),e.will_dispense=Object.values(e.coins).some(s=>s>0),e},Vn=async function(t=null){if(!o(this,w,Ms).call(this))throw new Error("Change not available");let e=this.change,n=this.change;if(t!==null&&(e=t,n=t),n<=0)return!1;const s=o(this,w,Un).call(this,n);n=s.pending;const a=o(this,w,Ln).call(this,n);return n=a.pending,n>0&&this.dispatch("change:pending",{pending:n}),this.dispatch("change:dispense",{recycler:s.banknotes,coins:a.coins,pending:n,delivery:e-n}),n===e?!1:(s.will_dispense&&await this.banknotePurseDispense(s.banknotes),a.will_dispense&&await this.coinPurseDispense(a.coins),!0)};class gc extends kt{constructor({filters:t=null,config_port:e=null,no_device:n=1}={}){super({filters:t,config_port:e,no_device:n});J(this,Jt);if(this.__internal__.device.type="arduino",K.getCustom(this.typeDevice,n))throw new Error(`Device ${this.typeDevice} ${n} already exists`);this.__internal__.time.response_connection=2e3,this.__internal__.time.response_general=2e3,this.__internal__.serial.delay_first_connection=1e3,o(this,Jt,ua).call(this),o(this,Jt,ha).call(this)}serialMessage(t){const e={original_code:t,code:null,name:null,description:null,request:null,no_code:0},n=this.parseHexToUint8(t),s=this.parseUint8ArrayToString(n);switch(e.code=s,s){case"connected":e.name="connected",e.description="Connection established",e.request="connect",e.no_code=100;break;case"created by danidoble":e.name="thanks",e.description="thanks for using this software",e.request="credits",e.no_code=101;break;case"hello there":e.name="hello there",e.description="hi human",e.request="hi",e.no_code=102;break;case"ara ara":e.name="ara ara",e.description="troll",e.request="ara ara",e.no_code=404;break;default:e.name="unknown",e.description="Unknown command",e.request="unknown",e.no_code=400;break}this.dispatch("serial:message",e)}serialSetConnectionConstant(t=1){return this.add0x(this.parseStringToBytes("CONNECT"))}async sayCredits(){const t=this.parseStringToBytes("CREDITS");await this.appendToQueue(t,"credits")}async sayHi(){const t=this.parseStringToBytes("HI");await this.appendToQueue(t,"hi")}async sayAra(){const t=this.parseStringToBytes("OTHER");await this.appendToQueue(t,"ara")}async sendCustomCode({code:t=""}={}){if(typeof t!="string")throw new Error("Invalid string");const e=this.parseStringToBytes(t);await this.appendToQueue(e,"custom")}async doSomething(){await this.sayCredits(),await this.sayAra(),await this.sayHi()}}Jt=new WeakSet,ha=function(){K.addCustom("arduino",this)},ua=function(){};/**
|
|
35
35
|
* @license Webserial
|
|
36
36
|
* webserial
|
|
37
37
|
*
|
|
@@ -39,4 +39,4 @@ version: 2.9.0
|
|
|
39
39
|
*
|
|
40
40
|
* This source code is licensed under the MIT license found in the
|
|
41
41
|
* LICENSE file in the root directory of this source tree.
|
|
42
|
-
*/const
|
|
42
|
+
*/const bc={wait:dt,getSeconds:Xe,supportWebSerial:Kn},mc="4.1.3";I.Arduino=gc,I.Boardroid=_c,I.Devices=K,I.Emulator=Zt,I.Jofemar=fc,I.Kernel=kt,I.Locker=ba,I.PinPad=pc,I.Relay=ga,I.utils=bc,I.version=mc,Object.defineProperty(I,Symbol.toStringTag,{value:"Module"})});
|