@danidoble/webserial 4.2.5 → 4.2.7

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.
@@ -1 +1 @@
1
- "use strict";var oe=Object.defineProperty;var x=c=>{throw TypeError(c)};var le=(c,u,n)=>u in c?oe(c,u,{enumerable:!0,configurable:!0,writable:!0,value:n}):c[u]=n;var h=(c,u,n)=>le(c,typeof u!="symbol"?u+"":u,n),I=(c,u,n)=>u.has(c)||x("Cannot "+n);var w=(c,u,n)=>(I(c,u,"read from private field"),n?n.call(c):u.get(c)),y=(c,u,n)=>u.has(c)?x("Cannot add the same private member more than once"):u instanceof WeakSet?u.add(c):u.set(c,n),b=(c,u,n,e)=>(I(c,u,"write to private field"),e?e.call(c,n):u.set(c,n),n),a=(c,u,n)=>(I(c,u,"access private method"),n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const T=require("./kernel-DSUxKxea.cjs"),d=require("./relay-BsUsBpOv.cjs");var f,_,k,i,E,M,v,S,Q,N,j,F,O,U,A,R,L,z,W,V,Y,G,H,J,K,X,Z,m,g,ee,ne,te,ie,se,P,C,re,ae,$,q,B;class ce extends T.Kernel{constructor({filters:n=null,config_port:e=null,no_device:t=1}={}){super({filters:n,config_port:e,no_device:t});y(this,i);h(this,"__coin_purse",{available:!0});h(this,"__banknote_purse",{available:!0,isRecycler:!0,recycler:{ict:!0,banknote:1}});h(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}});h(this,"__money_session",{inserted:0,retired:0,clear(){this.inserted=0,this.retired=0}});h(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});h(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});h(this,"card_reader",{available:!1,max_pre_credit:0});y(this,f,!1);y(this,_,0);y(this,k,0);if(this.__internal__.device.type="boardroid",T._.getCustom(this.typeDevice,t))throw new Error(`Device ${this.typeDevice} ${t} 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},a(this,i,E).call(this),a(this,i,M).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(n){this.__banknote_purse.isRecycler=n}get hasICT(){return this.hasRecycler&&this.__banknote_purse.recycler.ict}set hasICT(n){this.__banknote_purse.recycler.ict=n}set banknoteICT(n){if(![20,50,100,200,500].includes(n))throw new Error(`Invalid banknote value: ${n}`);n=[20,50,100,200,500].indexOf(n),this.__banknote_purse.recycler.banknote=n}get banknoteICT(){return[20,50,100,200,500][this.__banknote_purse.recycler.banknote]}get hasCoinPurse(){return this.__coin_purse.available}set hasCoinPurse(n){if(typeof n!="boolean")throw new Error(`Invalid value: ${n}`);this.__coin_purse.available=n}set price(n){let e=parseFloat(n);(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()}serialMessage(n){let e={code:n,name:null,description:null,request:null,no_code:0};const t=(5+this.deviceNumber).toString(16).padStart(2,"0").toLowerCase();switch(n[1]){case t:e.request="connect",e=a(this,i,Q).call(this,e);break;case"a0":e.request="--automatic",e=a(this,i,L).call(this,n,e);break;case"b0":e.request="--automatic",e=a(this,i,z).call(this,n,e);break;case"d0":e.request="coin-purse:config",e=a(this,i,W).call(this,n[2],e);break;case"d1":e.request="banknote-purse:config",e.additional={scrow:null},e=a(this,i,V).call(this,n,e);break;case"d2":e.request="coin-purse:read-tubes",e=a(this,i,Y).call(this,n,e);break;case"d3":e.request="banknote-purse:read-recycler",e=a(this,i,G).call(this,n,e);break;case"d4":e.request="banknote-purse:banknote-scrow-status",e=a(this,i,H).call(this,n[2],e);break;case"d5":e.request="banknote-purse:dispense",e=a(this,i,J).call(this,n,e);break;case"d6":e.request="coin-purse:dispense",e=a(this,i,K).call(this,n,e);break;case"d7":e.request="dispense",e=a(this,i,X).call(this,n[5],e);break;case"d8":e.request="--automatic",e=a(this,i,Z).call(this,n[13],e);break;case"d9":e.request="status:temperature",e=a(this,i,m).call(this,n,e);break;case"da":e.request="status:relay",e=a(this,i,g).call(this,n[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",a(this,i,ee).call(this,n,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(n=1){return d.l.connection({channel:n})}async coinPurseConfigure({enable:n=!1,high:e="FF",low:t="FF"}={}){if(!this.__coin_purse.available)throw new Error("Coin purse not available");return e=this.hexToDec(e),t=this.hexToDec(t),await this.appendToQueue(d.l.coinPurseConfiguration({enable:n,high:e,low:t}),"coin-purse:config")}async coinPurseEnable(){await this.coinPurseConfigure({enable:!0})}async coinPurseDisable(){await this.coinPurseConfigure({enable:!1})}async coinPurseDispense({$_50c:n=0,$_1:e=0,$_2:t=0,$_5:s=0,$_10:r=0}={}){if(!this.__coin_purse.available)throw new Error("Coin purse not available");return await this.appendToQueue(d.l.coinPurseDispense({$50c:n,$1:e,$2:t,$5:s,$10:r}),"coin-purse:dispense")}async coinPurseReadTubes(){return await this.appendToQueue(d.l.coinPurseReadTubes(),"coin-purse:read-tubes")}async banknotePurseConfigure({enable:n=!1,scrow:e=!1}={}){if(!this.__banknote_purse.available)throw new Error("Banknote purse not available");let t;return a(this,i,v).call(this)?t=a(this,i,ne).call(this,{enable:n,scrow:e}):t=a(this,i,te).call(this,{enable:n,scrow:e}),await this.appendToQueue(t,"banknote-purse:config")}async banknotePurseDispense({$_20:n=0,$_50:e=0,$_100:t=0,$_200:s=0,$_500:r=0,$_1000:l=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 o;if(a(this,i,v).call(this)){const p=[n,e,t,s,r];o=a(this,i,ie).call(this,p[this.__banknote_purse.recycler.banknote])}else o=a(this,i,se).call(this,{$_20:n,$_50:e,$_100:t,$_200:s,$_500:r,$_1000:l});await this.appendToQueue(o,"banknote-purse:dispense")}async banknotePurseEnable({scrow:n=!1}){return await this.banknotePurseConfigure({enable:!0,scrow:n})}async banknotePurseDisable(){return await this.banknotePurseConfigure({enable:!1})}async banknotePurseAcceptInScrow(){if(!this.__banknote_purse.available)throw new Error("Banknote purse not available");return await this.appendToQueue(d.l.banknotePurseAcceptInScrow(),"banknote-purse:banknote-scrow-status")}async banknotePurseRejectInScrow(){if(!this.__banknote_purse.available)throw new Error("Banknote purse not available");return await this.appendToQueue(d.l.banknotePurseRejectInScrow(),"banknote-purse:banknote-scrow-status")}async banknotePurseSaveMemory({channel:n=null,$_20:e=null,$_50:t=null,$_100:s=null,$_200:r=null,$_500:l=null,$_1000:o=null}={}){if(!this.__banknote_purse.available)throw new Error("Banknote purse not available");return await this.appendToQueue(d.l.banknotePurseSaveMemory({channel:n,$20:e,$50:t,$100:s,$200:r,$500:l,$1000:o}),"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");return await this.appendToQueue(d.l.banknotePurseReadRecycler(),"banknote-purse:read-recycler")}async cardReaderDisable(){if(!this.card_reader.available)throw new Error("Card reader not available");return await this.appendToQueue(d.l.cardReaderDisable(),"card-reader:disable")}async cardReaderDispense({channel:n=1,second_channel:e=null,sensor:t=!0,seconds:s=null,price:r=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)&&(this.card_reader.max_pre_credit=r),isNaN(r)||r<=0)throw new Error("Price must be greater than 0");if(r>this.card_reader.max_pre_credit)throw new Error("Price is greater than pre-credit configured");if(!t&&(s===null||s<=0||s>40))throw new Error("Invalid time to dispense without sensor, must be between 0.1 and 40.0 seconds");return this.appendToQueue(d.l.cardReaderDispense({selection:n,second_selection:e,sensor:t,seconds:s,price:r}),"card-reader:dispense")}async paymentPursesDisable({coin:n=!0,banknote:e=!0,cardReader:t=!1}={}){n&&this.__coin_purse.available&&await this.coinPurseDisable(),e&&this.__banknote_purse.available&&await this.banknotePurseDisable(),t&&this.card_reader.available&&await this.cardReaderDisable()}async paymentPursesEnable({coin:n=!0,banknote:e=!0,scrowBanknote:t=!1}={}){n&&this.__coin_purse.available&&await this.coinPurseEnable(),e&&this.__banknote_purse.available&&await this.banknotePurseEnable({scrow:t})}async coolingRelayConfigure({enable:n=!1}={}){return await this.appendToQueue(d.l.coolingRelayConfigure({enable:n}),"status:relay")}async coolingRelayEnable(){return await this.coolingRelayConfigure({enable:!0})}async coolingRelayDisable(){return await this.coolingRelayConfigure({enable:!1})}async readTemperature(){return await this.appendToQueue(d.l.readTemperature(),"status:temperature")}async dispense({selection:n=1,second_selection:e=null,sensor:t=!0,seconds:s=null,retry:r=!0}={}){if(n=parseInt(n),isNaN(n)||n<1||n>80)throw new Error("Invalid channel number");if(e!==null&&(e<1||e>80||e===n))throw new Error("Invalid second channel number");if(!t&&(s===null||s<=0||s>40))throw new Error("Invalid time to dispense without sensor, must be between 0.1 and 40.0 seconds");r&&(this.__internal__.dispense.backup_dispense={selection:n,second_selection:e,sensor:t,seconds:s});const l=d.l.dispense({selection:n,second_selection:e,sensor:t,seconds:s});t||(s||(s=1.5),this.__internal__.dispense.custom_limit_counter=s+.2);let o=await this.internalDispense(l);return!o.dispensed&&r&&(o=await this.internalDispense(l)),this.__internal__.dispense.custom_limit_counter=null,o}async testEngines({singleEngine:n=!1}={}){if(this.isDispensing)throw new Error("Another dispensing process is running");if(w(this,f))throw new Error("Another test is running");a(this,i,P).call(this),b(this,f,!0);const e=[];a(this,i,C).call(this);for(let t=1;t<=80;t++){const s=await this.dispense({selection:t,second_selection:n?null:t+1,sensor:!1,seconds:.4,retry:!1});e.push(s),b(this,_,t),a(this,i,C).call(this),n||t++}b(this,_,80),a(this,i,C).call(this,{dispensed:e}),a(this,i,P).call(this)}async sendCustomCode({code:n=[]}={}){if(n.length===0)throw new Error("Invalid code");return await this.appendToQueue(d.l.customCode(n),"custom")}hasToReturnChange(n=0){let e=n;return e<=0?!0:(e=a(this,i,$).call(this,e).pending,e=a(this,i,q).call(this,e).pending,!(e>0))}async returnChange(){return await a(this,i,B).call(this)}async returnInsertedMoney(){return this.__money_session.inserted<=0?!1:await a(this,i,B).call(this,this.__money_session.inserted)}async serialCorruptMessage(n,e){this.dispatch("corrupt:message",{data:n,message:e})}}f=new WeakMap,_=new WeakMap,k=new WeakMap,i=new WeakSet,E=function(){const n=["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 n)this.serialRegisterAvailableListener(e)},M=function(){T._.add(this)},v=function(){return this.__banknote_purse.isRecycler&&this.__banknote_purse.recycler.ict},S=function(){return this.hasCoinPurse||this.hasRecycler},Q=function(n){return n.name="Connection with the serial device completed.",n.description="Your connection with the serial device was successfully completed.",n.no_code=1,this.dispatch("run:default-load",{}),n},N=function(n){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 t=null;for(let r in e)if(e[r].includes(n)){t=r;break}return t?[{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"}[t],t]:[`Undefined value: ¿${n}?`,null]},j=function(n){return["g50","c50","p1","p2","p5","p10","p20"].includes(n)},F=function(n){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 t=null;for(let r in e)if(e[r].includes(n)){t=r;break}return t?[{p20:"20 pesos",p50:"50 pesos",p100:"100 pesos",p200:"200 pesos",p500:"500 pesos",p1000:"1000 pesos"}[t],t]:[`Undefined value: ¿${n}?`,null]},O=function(n){return["p20","p50","p100","p200","p500","p1000"].includes(n)},U=function(n){return["r20","r50","r100"].includes(n)},A=function(){return["r20","r50","r100","r200","r500"][this.__banknote_purse.recycler.banknote]},R=function(n,e,t){if(!n)return;let s=!0;if(a(this,i,j).call(this,n)&&t==="coin"){if(typeof this.coins.tubes[n]>"u")return;e==="tube"?this.coins.tubes[n]+=1:e==="box"&&(this.coins.box[n]+=1);let r=0;["g50","c50"].includes(n)?r=.5:r+=parseInt(n.slice(1)),this.coins.totals[n]+=r,this.__money_session.inserted+=r,this.coins.total+=r}else if(a(this,i,O).call(this,n)&&t==="banknote"){if(typeof this.banknotes.recycler[n]>"u")return;e==="recycler"?this.banknotes.recycler[n]+=1:e==="stacker"&&(this.banknotes.stacker[n]+=1);let r=parseInt(n.slice(1));this.banknotes.totals[n]+=r,this.__money_session.inserted+=r,this.banknotes.total+=r}else if(a(this,i,U).call(this,n)&&e==="out"&&t==="banknote"){if(typeof this.banknotes.out[n.replace("r","p")]>"u")return;this.banknotes.out[n.replace("r","p")]+=1;let r=parseInt(n.slice(1));this.__money_session.retired+=r,this.banknotes.recycler[n.replace("r","p")]-=1,this.banknotes.total-=r,s=!1,this.dispatch("session:money-dispensed",{type_money:n,retired:r,finish:!1,type:"banknotes"})}s&&this.dispatch("session:money-request",{})},L=function(n,e){const t=parseInt(n[2],16);return e.name="Coin Inserted",e.no_code=2,e.additional={where:null,coin:null},t===1?(e.name="Lever pressed",e.description="Reject lever",e.no_code=100,this.dispatch("coin-purse:reject-lever",{})):t===2?(e.name="Reset coin purse",e.description="The configuration of coin purse was reset",e.no_code=101,this.dispatch("coin-purse:reset",{})):t>=64&&t<=79?(e.name="Coin inserted in profit box",e.additional.where="box"):t>=80&&t<=95?(e.name="Coin inserted in tube",e.additional.where="tube"):t>=96&&t<=111?(e.name="Unused coin",e.description="Something come from coin changer but in MDB Docs is unused",e.additional.where="unused"):t>=112&&t<=127?(e.name="Coin rejected",e.additional.where="rejected"):t>=144&&t<=159?(e.name="Coin dispensed",e.additional.where="out",e.description=`Undefined value: ¿${n[2]}?`):(e.name="Coin inserted",e.description="Undefined status. Without information of this",e.no_code=400),t===1||t===2||t>=160||t>=128&&t<=143||([e.description,e.additional.coin]=a(this,i,N).call(this,n[2]),e.no_code=38+t,a(this,i,R).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},z=function(n,e){const t=parseInt(n[2],16);return e.name="Banknote Inserted",e.no_code=2,e.additional={where:null,banknote:null},t===42?(e.name="Banknote dispensed",e.description="Banknote dispensed by request.",e.additional.banknote=a(this,i,A).call(this),e.additional.where="out",e.no_code=200):t>=128&&t<=143?(e.name="Banknote inserted",e.additional.where="stacker"):t>=144&&t<=159?(e.name="Banknote inserted in pre stacker",e.additional.where="tmp"):t>=160&&t<=175?(e.name="Banknote rejected",e.additional.where="nothing"):t>=176&&t<=191&&(e.name="Banknote inserted",e.additional.where="recycler"),t>=128&&t<=191&&([e.description,e.additional.banknote]=a(this,i,F).call(this,n[2]),e.no_code=74+t),a(this,i,R).call(this,e.additional.banknote,e.additional.where,"banknote"),this.dispatch("banknote-purse:event-banknote",this.banknotes),e},W=function(n,e){const t=parseInt(n,16);return t===1?(e.name="Coin purse enabled",e.description="Configuration complete, enabled",e.no_code=3):t===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:t===1}),e},V=function(n,e){const t=parseInt(n[2],16),s=parseInt(n[3],16);return t===0?(e.name="Bill purse disabled",e.description="Configuration complete, disabled"):t===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:t===1,scrow:s===1}),e},Y=function(n,e){e.no_code=6;const[t,s,r,l,o,p]=[parseInt(n[2],16),parseInt(n[3],16),parseInt(n[4],16),parseInt(n[5],16),parseInt(n[6],16),parseInt(n[7],16)];return e.additional={coins:{g50:t,c50:s,p1:r,p2:l,p5:o,p10:p}},this.coins.tubes.g50=t,this.coins.tubes.c50=s,this.coins.tubes.p1=r,this.coins.tubes.p2=l,this.coins.tubes.p5=o,this.coins.tubes.p10=p,this.coins.totals.g50=(this.coins.box.g50+t)*.5,this.coins.totals.c50=(this.coins.box.c50+s)*.5,this.coins.totals.p1=this.coins.box.p1+r,this.coins.totals.p2=(this.coins.box.p2+l)*2,this.coins.totals.p5=(this.coins.box.p5+o)*5,this.coins.totals.p10=(this.coins.box.p10+p)*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},G=function(n,e){e.no_code=7;const[t,s,r,l,o,p]=[parseInt(n[2],16),parseInt(n[3],16),parseInt(n[4],16),parseInt(n[5],16),parseInt(n[6],16),parseInt(n[7],16)];return e.additional={banknotes:{b20:t,b50:s,b100:r,b200:l,b500:o,b1000:p}},this.banknotes.recycler.p20=t,this.banknotes.recycler.p50=s,this.banknotes.recycler.p100=r,this.banknotes.recycler.p200=l,this.banknotes.recycler.p500=o,this.banknotes.recycler.p1000=p,this.banknotes.totals.p20=(this.banknotes.stacker.p20+t)*20,this.banknotes.totals.p50=(this.banknotes.stacker.p50+s)*50,this.banknotes.totals.p100=(this.banknotes.stacker.p100+r)*100,this.banknotes.totals.p200=(this.banknotes.stacker.p200+l)*200,this.banknotes.totals.p500=(this.banknotes.stacker.p500+o)*500,this.banknotes.totals.p1000=(this.banknotes.stacker.p1000+p)*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},H=function(n,e){const t=parseInt(n,16);return t===1?e.name="Banknote accepted":t===0?e.name="Banknote rejected":e.name="Unknown status banknote",e.no_code=8,this.dispatch("banknote-purse:banknote-scrow-status",{status:t===1}),e},J=function(n,e){const[t,s,r,l,o,p]=[parseInt(n[2],16),parseInt(n[3],16),parseInt(n[4],16),parseInt(n[5],16),parseInt(n[6],16),parseInt(n[7],16)],D=t*20+s*50+r*100+l*200+o*500+p*1e3;return e.name="Banknotes dispensed",e.description=D>0?"Banknotes dispensed by request":"No banknotes dispensed, recycler empty",e.no_code=9,e.additional={banknotes:{b20:t,b50:s,b100:r,b200:l,b500:o,b1000:p},total_dispensed:D},this.dispatch("session:money-dispensed",{type_money:null,retired:null,finish:!1,type:"banknotes",data:e}),e},K=function(n,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},X=function(n,e){const t=parseInt(n,16);return t===1?(e.name="Product not delivered",e.description="The product requested wasn't delivered",e.no_code=11,this.__internal__.dispense.status=!1):t===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},Z=function(n,e){let t="closed";return n==="db"?(e.name="Door closed",e.no_code=13):n==="dc"?(e.name="Door open",e.no_code=14,t="open"):(e.name="Unknown status door",e.description="The response of door doesn't identify successfully",e.no_code=400,t="unknown"),this.__internal__.device.door_open=t==="open",this.dispatch("event:door",{open:t==="open"}),this.dispatch("door:event",{open:t==="open"}),e},m=function(n,e){const t=parseInt(n[2],16)*255,s=parseInt(n[3],16),r=(t+s)*.1;return e.no_code=15,e.name="Temperature status",e.description=`Temperature: ${r}`,e.additional={high:t,low:s,temperature:parseFloat(r.toString())},this.dispatch("status:temperature",e.additional),e},g=function(n,e){const t=parseInt(n,16);let s="unknown";return t===1?(e.name="Relay on",e.description="Relay on",e.no_code=16,s="on"):t===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},ee=function(n,e){const t=parseInt(n[2],16);if(e.no_code=20+t,e.name="Status unknown",e.description="The status of card reader does not identified correctly",t===0)e.request+=":disable",e.name="Card reader disabled",e.description="Card reader device was disabled successfully";else if(t===1||t===2)e.request+=":dispense",e.name="Card reader enabled",e.description="Card reader device is now enabled";else if(t===3)e.request+=":pre-authorize",e.name="Pre-authorized credit",e.description="The pre credit was authorized successfully";else if(t===4)e.request+=":cancel",e.name="Cancellation in progress",e.description="Cancellation request done successfully";else if(t===5)e.request+=":sell",e.name="Sell approved",e.description="Sell approved, starting dispense product";else if(t===6)e.request+=":sell",e.name="Sell denied",e.description="This sell was denied, try again";else if(t===7)e.request+=":end",e.name="Session ended",e.description="The session ended";else if(t===8)e.request+=":cancel",e.name="Cancelled",e.description="Cancellation complete";else if(t===10){const s=parseInt(n[8],16);s===1?(e.no_code=30,e.name="product not dispensed",e.description="The product requested wasn't delivered"):s===0?(e.no_code=31,e.name="product dispensed",e.description="The product requested was delivered"):(e.name="finished-unknown",e.no_code=400)}else e.no_code=400;return this.dispatch("card-reader:event",e),e},ne=function({enable:n=!1,scrow:e=!1}={}){return d.l.banknotePurseICTConfigure({enable:n,scrow:e})},te=function({enable:n=!1,scrow:e=!1}={}){return d.l.banknotePurseOtherConfigure({enable:n,scrow:e})},ie=function(n=1){if(n<1)throw new Error("No banknotes to dispense");const e=[20,50,100,200,500][this.__banknote_purse.recycler.banknote];return d.l.banknotePurseICTDispense({quantity:n,denomination:e})},se=function({$_20:n=0,$_50:e=0,$_100:t=0,$_200:s=0,$_500:r=0,$_1000:l=0}={}){return d.l.banknotePurseOtherDispense({$20:n,$50:e,$100:t,$200:s,$500:r,$1000:l})},P=function(){b(this,f,!1),b(this,_,0),b(this,k,0)},C=function({dispensed:n=null,limit:e=80}={}){b(this,k,Math.round(w(this,_)*100/e)),this.dispatch("percentage:test",{percentage:w(this,k),dispensed:n})},re=function(n){const e=["20","50","100","200","500"],t=this.__banknote_purse.recycler.banknote,s="$_"+e[t],r=parseInt(e[t]),l=this.banknotes.recycler[`p${e[t]}`],o=Math.min(Math.floor(n/r),l),p={banknotes:{$_20:0,$_50:0,$_100:0,$_200:0,$_500:0,$_1000:0},pending:n,will_dispense:o>0};return this.totalInRecycler===0||o<1||n===0||(p.banknotes[s]=o,p.pending=parseFloat((n-o*r).toFixed(2))),p},ae=function(n){const e={banknotes:{$_20:0,$_50:0,$_100:0,$_200:0,$_500:0,$_1000:0},pending:n,will_dispense:!1};if(this.totalInRecycler===0||n===0)return e;const t=(s,r)=>{if(this.banknotes.recycler[r]>0){const l=Math.floor(e.pending/s),o=Math.min(l,this.banknotes.recycler[r]);e.banknotes[`$_${s}`]=o,e.pending=parseFloat((e.pending-o*s).toFixed(2))}};return t(1e3,"p1000"),t(500,"p500"),t(200,"p200"),t(100,"p100"),t(50,"p50"),t(20,"p20"),e.will_dispense=Object.values(e.banknotes).some(s=>s>0),e},$=function(n){return this.hasRecycler?a(this,i,v).call(this)?a(this,i,re).call(this,n):a(this,i,ae).call(this,n):{banknotes:{$_20:0,$_50:0,$_100:0,$_200:0,$_500:0,$_1000:0},pending:n,will_dispense:!1}},q=function(n){const e={coins:{$_50c:0,$_1:0,$_2:0,$_5:0,$_10:0},pending:n,will_dispense:!1};if(!this.hasCoinPurse||n<=0||this.totalInTubes===0)return e;const t=(s,r,l=null)=>{if(this.coins.tubes[r]>0){l===null&&(l="$_"+s);const o=Math.floor(e.pending/s),p=Math.min(o,this.coins.tubes[r]);e.coins[l]=p,e.pending=parseFloat((e.pending-p*s).toFixed(2))}};return t(10,"p10"),t(5,"p5"),t(2,"p2"),t(1,"p1"),t(.5,"g50","$_50c"),e.will_dispense=Object.values(e.coins).some(s=>s>0),e},B=async function(n=null){if(!a(this,i,S).call(this))throw new Error("Change not available");let e=this.change,t=this.change;if(n!==null&&(e=n,t=n),t<=0)return!1;const s=a(this,i,$).call(this,t);t=s.pending;const r=a(this,i,q).call(this,t);return t=r.pending,t>0&&this.dispatch("change:pending",{pending:t}),this.dispatch("change:dispense",{recycler:s.banknotes,coins:r.coins,pending:t,delivery:e-t}),t===e?!1:(s.will_dispense&&await this.banknotePurseDispense(s.banknotes),r.will_dispense&&await this.coinPurseDispense(r.coins),!0)};exports.Boardroid=ce;
1
+ "use strict";var ce=Object.defineProperty;var x=c=>{throw TypeError(c)};var pe=(c,p,n)=>p in c?ce(c,p,{enumerable:!0,configurable:!0,writable:!0,value:n}):c[p]=n;var h=(c,p,n)=>pe(c,typeof p!="symbol"?p+"":p,n),I=(c,p,n)=>p.has(c)||x("Cannot "+n);var w=(c,p,n)=>(I(c,p,"read from private field"),n?n.call(c):p.get(c)),y=(c,p,n)=>p.has(c)?x("Cannot add the same private member more than once"):p instanceof WeakSet?p.add(c):p.set(c,n),b=(c,p,n,e)=>(I(c,p,"write to private field"),e?e.call(c,n):p.set(c,n),n),a=(c,p,n)=>(I(c,p,"access private method"),n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const T=require("./kernel-DSUxKxea.cjs"),d=require("./relay-BsUsBpOv.cjs");var f,_,k,s,E,M,v,S,Q,N,m,j,F,O,U,A,L,R,V,z,W,Y,G,H,J,K,X,Z,g,ee,ne,te,se,ie,re,ae,P,C,oe,le,$,B,q;class ue extends T.Kernel{constructor({filters:n=null,config_port:e=null,no_device:t=1}={}){super({filters:n,config_port:e,no_device:t});y(this,s);h(this,"__coin_purse",{available:!0});h(this,"__banknote_purse",{available:!0,isRecycler:!0,recycler:{ict:!0,banknote:1}});h(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}});h(this,"__money_session",{inserted:0,retired:0,clear(){this.inserted=0,this.retired=0}});h(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});h(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});h(this,"card_reader",{available:!1,max_pre_credit:0});y(this,f,!1);y(this,_,0);y(this,k,0);if(this.__internal__.device.type="boardroid",T._.getCustom(this.typeDevice,t))throw new Error(`Device ${this.typeDevice} ${t} 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},a(this,s,E).call(this),a(this,s,M).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(n){this.__banknote_purse.isRecycler=n}get hasICT(){return this.hasRecycler&&this.__banknote_purse.recycler.ict}set hasICT(n){this.__banknote_purse.recycler.ict=n}set banknoteICT(n){if(![20,50,100,200,500].includes(n))throw new Error(`Invalid banknote value: ${n}`);n=[20,50,100,200,500].indexOf(n),this.__banknote_purse.recycler.banknote=n}get banknoteICT(){return[20,50,100,200,500][this.__banknote_purse.recycler.banknote]}get hasCoinPurse(){return this.__coin_purse.available}set hasCoinPurse(n){if(typeof n!="boolean")throw new Error(`Invalid value: ${n}`);this.__coin_purse.available=n}set price(n){let e=parseFloat(n);(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()}serialMessage(n){let e={code:n,name:null,description:null,request:null,no_code:0};const t=(5+this.deviceNumber).toString(16).padStart(2,"0").toLowerCase();switch(n[1]){case t:e.request="connect",e=a(this,s,Q).call(this,e);break;case"a0":e.request="--automatic",e=a(this,s,V).call(this,n,e);break;case"b0":e.request="--automatic",e=a(this,s,z).call(this,n,e);break;case"d0":e.request="coin-purse:config",e=a(this,s,W).call(this,n[2],e);break;case"d1":e.request="banknote-purse:config",e.additional={scrow:null},e=a(this,s,Y).call(this,n,e);break;case"d2":e.request="coin-purse:read-tubes",e=a(this,s,G).call(this,n,e);break;case"d3":e.request="banknote-purse:read-recycler",e=a(this,s,H).call(this,n,e);break;case"d4":e.request="banknote-purse:banknote-scrow-status",e=a(this,s,J).call(this,n[2],e);break;case"d5":e.request="banknote-purse:dispense",e=a(this,s,K).call(this,n,e);break;case"d6":e.request="coin-purse:dispense",e=a(this,s,X).call(this,n,e);break;case"d7":e.request="dispense",e=a(this,s,Z).call(this,n[5],e);break;case"d8":e.request="--automatic",e=a(this,s,g).call(this,n[13],e);break;case"d9":e.request="status:temperature",e=a(this,s,ee).call(this,n,e);break;case"da":e.request="status:relay",e=a(this,s,ne).call(this,n[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",a(this,s,te).call(this,n,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(n=1){return d.l.connection({channel:n})}async coinPurseConfigure({enable:n=!1,high:e="FF",low:t="FF"}={}){if(!this.__coin_purse.available)throw new Error("Coin purse not available");return e=this.hexToDec(e),t=this.hexToDec(t),await this.appendToQueue(d.l.coinPurseConfiguration({enable:n,high:e,low:t}),"coin-purse:config")}async coinPurseEnable(){await this.coinPurseConfigure({enable:!0})}async coinPurseDisable(){await this.coinPurseConfigure({enable:!1})}async coinPurseDispense({$_50c:n=0,$_1:e=0,$_2:t=0,$_5:i=0,$_10:r=0}={}){if(!this.__coin_purse.available)throw new Error("Coin purse not available");return await this.appendToQueue(d.l.coinPurseDispense({$50c:n,$1:e,$2:t,$5:i,$10:r}),"coin-purse:dispense")}async coinPurseReadTubes(){return await this.appendToQueue(d.l.coinPurseReadTubes(),"coin-purse:read-tubes")}async banknotePurseConfigure({enable:n=!1,scrow:e=!1}={}){if(!this.__banknote_purse.available)throw new Error("Banknote purse not available");let t;return a(this,s,v).call(this)?t=a(this,s,se).call(this,{enable:n,scrow:e}):t=a(this,s,ie).call(this,{enable:n,scrow:e}),await this.appendToQueue(t,"banknote-purse:config")}async banknotePurseDispense({$_20:n=0,$_50:e=0,$_100:t=0,$_200:i=0,$_500:r=0,$_1000:o=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(a(this,s,v).call(this)){const u=[n,e,t,i,r];l=a(this,s,re).call(this,u[this.__banknote_purse.recycler.banknote])}else l=a(this,s,ae).call(this,{$_20:n,$_50:e,$_100:t,$_200:i,$_500:r,$_1000:o});await this.appendToQueue(l,"banknote-purse:dispense")}async banknotePurseEnable({scrow:n=!1}){return await this.banknotePurseConfigure({enable:!0,scrow:n})}async banknotePurseDisable(){return await this.banknotePurseConfigure({enable:!1})}async banknotePurseAcceptInScrow(){if(!this.__banknote_purse.available)throw new Error("Banknote purse not available");return await this.appendToQueue(d.l.banknotePurseAcceptInScrow(),"banknote-purse:banknote-scrow-status")}async banknotePurseRejectInScrow(){if(!this.__banknote_purse.available)throw new Error("Banknote purse not available");return await this.appendToQueue(d.l.banknotePurseRejectInScrow(),"banknote-purse:banknote-scrow-status")}async banknotePurseSaveMemory({channel:n=null,$_20:e=null,$_50:t=null,$_100:i=null,$_200:r=null,$_500:o=null,$_1000:l=null}={}){if(!this.__banknote_purse.available)throw new Error("Banknote purse not available");return await this.appendToQueue(d.l.banknotePurseSaveMemory({channel:n,$20:e,$50:t,$100:i,$200:r,$500:o,$1000:l}),"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");return await this.appendToQueue(d.l.banknotePurseReadRecycler(),"banknote-purse:read-recycler")}async cardReaderDisable(){if(!this.card_reader.available)throw new Error("Card reader not available");return await this.appendToQueue(d.l.cardReaderDisable(),"card-reader:disable")}async cardReaderDispense({channel:n=1,second_channel:e=null,sensor:t=!0,seconds:i=null,price:r=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)&&(this.card_reader.max_pre_credit=r),isNaN(r)||r<=0)throw new Error("Price must be greater than 0");if(r>this.card_reader.max_pre_credit)throw new Error("Price is greater than pre-credit configured");if(!t&&(i===null||i<=0||i>40))throw new Error("Invalid time to dispense without sensor, must be between 0.1 and 40.0 seconds");return this.appendToQueue(d.l.cardReaderDispense({selection:n,second_selection:e,sensor:t,seconds:i,price:r}),"card-reader:dispense")}async paymentPursesDisable({coin:n=!0,banknote:e=!0,cardReader:t=!1}={}){n&&this.__coin_purse.available&&await this.coinPurseDisable(),e&&this.__banknote_purse.available&&await this.banknotePurseDisable(),t&&this.card_reader.available&&await this.cardReaderDisable()}async paymentPursesEnable({coin:n=!0,banknote:e=!0,scrowBanknote:t=!1}={}){n&&this.__coin_purse.available&&await this.coinPurseEnable(),e&&this.__banknote_purse.available&&await this.banknotePurseEnable({scrow:t})}async coolingRelayConfigure({enable:n=!1}={}){return await this.appendToQueue(d.l.coolingRelayConfigure({enable:n}),"status:relay")}async coolingRelayEnable(){return await this.coolingRelayConfigure({enable:!0})}async coolingRelayDisable(){return await this.coolingRelayConfigure({enable:!1})}async readTemperature(){return await this.appendToQueue(d.l.readTemperature(),"status:temperature")}async dispense({selection:n=1,second_selection:e=null,sensor:t=!0,seconds:i=null,retry:r=!0}={}){if(n=parseInt(n),isNaN(n)||n<1||n>80)throw new Error("Invalid channel number");if(e!==null&&(e<1||e>80||e===n))throw new Error("Invalid second channel number");if(!t&&(i===null||i<=0||i>40))throw new Error("Invalid time to dispense without sensor, must be between 0.1 and 40.0 seconds");r&&(this.__internal__.dispense.backup_dispense={selection:n,second_selection:e,sensor:t,seconds:i});const o=d.l.dispense({selection:n,second_selection:e,sensor:t,seconds:i});t||(i||(i=1.5),this.__internal__.dispense.custom_limit_counter=i+.2);let l=await this.internalDispense(o);return!l.dispensed&&r&&(l=await this.internalDispense(o)),this.__internal__.dispense.custom_limit_counter=null,l}async testEngines({singleEngine:n=!1}={}){if(this.isDispensing)throw new Error("Another dispensing process is running");if(w(this,f))throw new Error("Another test is running");a(this,s,P).call(this),b(this,f,!0);const e=[];a(this,s,C).call(this);for(let t=1;t<=80;t++){const i=await this.dispense({selection:t,second_selection:n?null:t+1,sensor:!1,seconds:.4,retry:!1});e.push(i),b(this,_,t),a(this,s,C).call(this),n||t++}b(this,_,80),a(this,s,C).call(this,{dispensed:e}),a(this,s,P).call(this)}async sendCustomCode({code:n=[]}={}){if(n.length===0)throw new Error("Invalid code");return await this.appendToQueue(d.l.customCode(n),"custom")}hasToReturnChange(n=0){let e=n;return e<=0?!0:(e=a(this,s,$).call(this,e).pending,e=a(this,s,B).call(this,e).pending,!(e>0))}async returnChange(){return await a(this,s,q).call(this)}async returnInsertedMoney(){return this.__money_session.inserted<=0?!1:await a(this,s,q).call(this,this.__money_session.inserted)}async serialCorruptMessage(n,e){this.dispatch("corrupt:message",{data:n,message:e})}}f=new WeakMap,_=new WeakMap,k=new WeakMap,s=new WeakSet,E=function(){const n=["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","money:inserted"];for(const e of n)this.serialRegisterAvailableListener(e)},M=function(){T._.add(this)},v=function(){return this.__banknote_purse.isRecycler&&this.__banknote_purse.recycler.ict},S=function(){return this.hasCoinPurse||this.hasRecycler},Q=function(n){return n.name="Connection with the serial device completed.",n.description="Your connection with the serial device was successfully completed.",n.no_code=1,this.dispatch("run:default-load",{}),n},N=function(n){const e={g50:{value:.5,name:"50 pennies (the big one)"},c0:{value:.5,name:"50 pennies (the little one)"},p1:{value:1,name:"1 peso"},p2:{value:2,name:"2 pesos"},p5:{value:5,name:"5 pesos"},p10:{value:10,name:"10 pesos"},p20:{value:20,name:"20 pesos"}};return e[n]?e[n]:!1},m=function(n){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 t=null;for(let r in e)if(e[r].includes(n)){t=r;break}return t?[{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"}[t],t]:[`Undefined value: ¿${n}?`,null]},j=function(n){return["g50","c50","p1","p2","p5","p10","p20"].includes(n)},F=function(n){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 t=null;for(let r in e)if(e[r].includes(n)){t=r;break}return t?[{p20:"20 pesos",p50:"50 pesos",p100:"100 pesos",p200:"200 pesos",p500:"500 pesos",p1000:"1000 pesos"}[t],t]:[`Undefined value: ¿${n}?`,null]},O=function(n){const e={p20:{value:20,name:"20 pesos"},p50:{value:50,name:"50 pesos"},p100:{value:100,name:"100 pesos"},p200:{value:200,name:"200 pesos"},p500:{value:500,name:"500 pesos"},p1000:{value:1e3,name:"1000 pesos"}};return e[n]?e[n]:!1},U=function(n){return["p20","p50","p100","p200","p500","p1000"].includes(n)},A=function(n){return["r20","r50","r100"].includes(n)},L=function(){return["r20","r50","r100","r200","r500"][this.__banknote_purse.recycler.banknote]},R=function(n,e,t){if(!n)return;let i=!0;if(a(this,s,j).call(this,n)&&t==="coin"){if(typeof this.coins.tubes[n]>"u")return;e==="tube"?this.coins.tubes[n]+=1:e==="box"&&(this.coins.box[n]+=1);let r=0;["g50","c50"].includes(n)?r=.5:r+=parseInt(n.slice(1)),this.coins.totals[n]+=r,this.__money_session.inserted+=r,this.coins.total+=r;const o=a(this,s,N).call(this,n);o&&this.dispatch("money:inserted",{type:"coin",money:o,where:e})}else if(a(this,s,U).call(this,n)&&t==="banknote"){if(typeof this.banknotes.recycler[n]>"u")return;e==="recycler"?this.banknotes.recycler[n]+=1:e==="stacker"&&(this.banknotes.stacker[n]+=1);let r=parseInt(n.slice(1));this.banknotes.totals[n]+=r,this.__money_session.inserted+=r,this.banknotes.total+=r;const o=a(this,s,O).call(this,n);o&&this.dispatch("money:inserted",{type:"banknote",money:o,where:e})}else if(a(this,s,A).call(this,n)&&e==="out"&&t==="banknote"){if(typeof this.banknotes.out[n.replace("r","p")]>"u")return;this.banknotes.out[n.replace("r","p")]+=1;let r=parseInt(n.slice(1));this.__money_session.retired+=r,this.banknotes.recycler[n.replace("r","p")]-=1,this.banknotes.total-=r,i=!1,this.dispatch("session:money-dispensed",{type_money:n,retired:r,finish:!1,type:"banknotes"})}i&&this.dispatch("session:money-request",{})},V=function(n,e){const t=parseInt(n[2],16);return e.name="Coin Inserted",e.no_code=2,e.additional={where:null,coin:null},t===1?(e.name="Lever pressed",e.description="Reject lever",e.no_code=100,this.dispatch("coin-purse:reject-lever",{})):t===2?(e.name="Reset coin purse",e.description="The configuration of coin purse was reset",e.no_code=101,this.dispatch("coin-purse:reset",{})):t>=64&&t<=79?(e.name="Coin inserted in profit box",e.additional.where="box"):t>=80&&t<=95?(e.name="Coin inserted in tube",e.additional.where="tube"):t>=96&&t<=111?(e.name="Unused coin",e.description="Something come from coin changer but in MDB Docs is unused",e.additional.where="unused"):t>=112&&t<=127?(e.name="Coin rejected",e.additional.where="rejected"):t>=144&&t<=159?(e.name="Coin dispensed",e.additional.where="out",e.description=`Undefined value: ¿${n[2]}?`):(e.name="Coin inserted",e.description="Undefined status. Without information of this",e.no_code=400),t===1||t===2||t>=160||t>=128&&t<=143||([e.description,e.additional.coin]=a(this,s,m).call(this,n[2]),e.no_code=38+t,a(this,s,R).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},z=function(n,e){const t=parseInt(n[2],16);return e.name="Banknote Inserted",e.no_code=2,e.additional={where:null,banknote:null},t===42?(e.name="Banknote dispensed",e.description="Banknote dispensed by request.",e.additional.banknote=a(this,s,L).call(this),e.additional.where="out",e.no_code=200):t>=128&&t<=143?(e.name="Banknote inserted",e.additional.where="stacker"):t>=144&&t<=159?(e.name="Banknote inserted in pre stacker",e.additional.where="tmp"):t>=160&&t<=175?(e.name="Banknote rejected",e.additional.where="nothing"):t>=176&&t<=191&&(e.name="Banknote inserted",e.additional.where="recycler"),t>=128&&t<=191&&([e.description,e.additional.banknote]=a(this,s,F).call(this,n[2]),e.no_code=74+t),a(this,s,R).call(this,e.additional.banknote,e.additional.where,"banknote"),this.dispatch("banknote-purse:event-banknote",this.banknotes),e},W=function(n,e){const t=parseInt(n,16);return t===1?(e.name="Coin purse enabled",e.description="Configuration complete, enabled",e.no_code=3):t===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:t===1}),e},Y=function(n,e){const t=parseInt(n[2],16),i=parseInt(n[3],16);return t===0?(e.name="Bill purse disabled",e.description="Configuration complete, disabled"):t===1&&(e.name="Bill purse enabled",e.description="Configuration complete, enabled"),i===0?e.additional.scrow="Scrow disabled, banknote received automatic":i===1&&(e.additional.scrow="Scrow enabled, require manual action"),e.no_code=5,this.dispatch("banknote-purse:config",{enabled:t===1,scrow:i===1}),e},G=function(n,e){e.no_code=6;const[t,i,r,o,l,u]=[parseInt(n[2],16),parseInt(n[3],16),parseInt(n[4],16),parseInt(n[5],16),parseInt(n[6],16),parseInt(n[7],16)];return e.additional={coins:{g50:t,c50:i,p1:r,p2:o,p5:l,p10:u}},this.coins.tubes.g50=t,this.coins.tubes.c50=i,this.coins.tubes.p1=r,this.coins.tubes.p2=o,this.coins.tubes.p5=l,this.coins.tubes.p10=u,this.coins.totals.g50=(this.coins.box.g50+t)*.5,this.coins.totals.c50=(this.coins.box.c50+i)*.5,this.coins.totals.p1=this.coins.box.p1+r,this.coins.totals.p2=(this.coins.box.p2+o)*2,this.coins.totals.p5=(this.coins.box.p5+l)*5,this.coins.totals.p10=(this.coins.box.p10+u)*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},H=function(n,e){e.no_code=7;const[t,i,r,o,l,u]=[parseInt(n[2],16),parseInt(n[3],16),parseInt(n[4],16),parseInt(n[5],16),parseInt(n[6],16),parseInt(n[7],16)];return e.additional={banknotes:{b20:t,b50:i,b100:r,b200:o,b500:l,b1000:u}},this.banknotes.recycler.p20=t,this.banknotes.recycler.p50=i,this.banknotes.recycler.p100=r,this.banknotes.recycler.p200=o,this.banknotes.recycler.p500=l,this.banknotes.recycler.p1000=u,this.banknotes.totals.p20=(this.banknotes.stacker.p20+t)*20,this.banknotes.totals.p50=(this.banknotes.stacker.p50+i)*50,this.banknotes.totals.p100=(this.banknotes.stacker.p100+r)*100,this.banknotes.totals.p200=(this.banknotes.stacker.p200+o)*200,this.banknotes.totals.p500=(this.banknotes.stacker.p500+l)*500,this.banknotes.totals.p1000=(this.banknotes.stacker.p1000+u)*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},J=function(n,e){const t=parseInt(n,16);return t===1?e.name="Banknote accepted":t===0?e.name="Banknote rejected":e.name="Unknown status banknote",e.no_code=8,this.dispatch("banknote-purse:banknote-scrow-status",{status:t===1}),e},K=function(n,e){const[t,i,r,o,l,u]=[parseInt(n[2],16),parseInt(n[3],16),parseInt(n[4],16),parseInt(n[5],16),parseInt(n[6],16),parseInt(n[7],16)],D=t*20+i*50+r*100+o*200+l*500+u*1e3;return e.name="Banknotes dispensed",e.description=D>0?"Banknotes dispensed by request":"No banknotes dispensed, recycler empty",e.no_code=9,e.additional={banknotes:{b20:t,b50:i,b100:r,b200:o,b500:l,b1000:u},total_dispensed:D},this.dispatch("session:money-dispensed",{type_money:null,retired:null,finish:!1,type:"banknotes",data:e}),e},X=function(n,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},Z=function(n,e){const t=parseInt(n,16);return t===1?(e.name="Product not delivered",e.description="The product requested wasn't delivered",e.no_code=11,this.__internal__.dispense.status=!1):t===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},g=function(n,e){let t="closed";return n==="db"?(e.name="Door closed",e.no_code=13):n==="dc"?(e.name="Door open",e.no_code=14,t="open"):(e.name="Unknown status door",e.description="The response of door doesn't identify successfully",e.no_code=400,t="unknown"),this.__internal__.device.door_open=t==="open",this.dispatch("event:door",{open:t==="open"}),this.dispatch("door:event",{open:t==="open"}),e},ee=function(n,e){const t=parseInt(n[2],16)*255,i=parseInt(n[3],16),r=(t+i)*.1;return e.no_code=15,e.name="Temperature status",e.description=`Temperature: ${r}`,e.additional={high:t,low:i,temperature:parseFloat(r.toString())},this.dispatch("status:temperature",e.additional),e},ne=function(n,e){const t=parseInt(n,16);let i="unknown";return t===1?(e.name="Relay on",e.description="Relay on",e.no_code=16,i="on"):t===0?(e.name="Relay off",e.description="Relay off",e.no_code=17,i="off"):(e.name="Status unknown",e.description="Status unknown",e.no_code=400),this.dispatch("status:relay",{enabled:i==="on"}),e},te=function(n,e){const t=parseInt(n[2],16);if(e.no_code=20+t,e.name="Status unknown",e.description="The status of card reader does not identified correctly",t===0)e.request+=":disable",e.name="Card reader disabled",e.description="Card reader device was disabled successfully";else if(t===1||t===2)e.request+=":dispense",e.name="Card reader enabled",e.description="Card reader device is now enabled";else if(t===3)e.request+=":pre-authorize",e.name="Pre-authorized credit",e.description="The pre credit was authorized successfully";else if(t===4)e.request+=":cancel",e.name="Cancellation in progress",e.description="Cancellation request done successfully";else if(t===5)e.request+=":sell",e.name="Sell approved",e.description="Sell approved, starting dispense product";else if(t===6)e.request+=":sell",e.name="Sell denied",e.description="This sell was denied, try again";else if(t===7)e.request+=":end",e.name="Session ended",e.description="The session ended";else if(t===8)e.request+=":cancel",e.name="Cancelled",e.description="Cancellation complete";else if(t===10){const i=parseInt(n[8],16);i===1?(e.no_code=30,e.name="product not dispensed",e.description="The product requested wasn't delivered"):i===0?(e.no_code=31,e.name="product dispensed",e.description="The product requested was delivered"):(e.name="finished-unknown",e.no_code=400)}else e.no_code=400;return this.dispatch("card-reader:event",e),e},se=function({enable:n=!1,scrow:e=!1}={}){return d.l.banknotePurseICTConfigure({enable:n,scrow:e})},ie=function({enable:n=!1,scrow:e=!1}={}){return d.l.banknotePurseOtherConfigure({enable:n,scrow:e})},re=function(n=1){if(n<1)throw new Error("No banknotes to dispense");const e=[20,50,100,200,500][this.__banknote_purse.recycler.banknote];return d.l.banknotePurseICTDispense({quantity:n,denomination:e})},ae=function({$_20:n=0,$_50:e=0,$_100:t=0,$_200:i=0,$_500:r=0,$_1000:o=0}={}){return d.l.banknotePurseOtherDispense({$20:n,$50:e,$100:t,$200:i,$500:r,$1000:o})},P=function(){b(this,f,!1),b(this,_,0),b(this,k,0)},C=function({dispensed:n=null,limit:e=80}={}){b(this,k,Math.round(w(this,_)*100/e)),this.dispatch("percentage:test",{percentage:w(this,k),dispensed:n})},oe=function(n){const e=["20","50","100","200","500"],t=this.__banknote_purse.recycler.banknote,i="$_"+e[t],r=parseInt(e[t]),o=this.banknotes.recycler[`p${e[t]}`],l=Math.min(Math.floor(n/r),o),u={banknotes:{$_20:0,$_50:0,$_100:0,$_200:0,$_500:0,$_1000:0},pending:n,will_dispense:l>0};return this.totalInRecycler===0||l<1||n===0||(u.banknotes[i]=l,u.pending=parseFloat((n-l*r).toFixed(2))),u},le=function(n){const e={banknotes:{$_20:0,$_50:0,$_100:0,$_200:0,$_500:0,$_1000:0},pending:n,will_dispense:!1};if(this.totalInRecycler===0||n===0)return e;const t=(i,r)=>{if(this.banknotes.recycler[r]>0){const o=Math.floor(e.pending/i),l=Math.min(o,this.banknotes.recycler[r]);e.banknotes[`$_${i}`]=l,e.pending=parseFloat((e.pending-l*i).toFixed(2))}};return t(1e3,"p1000"),t(500,"p500"),t(200,"p200"),t(100,"p100"),t(50,"p50"),t(20,"p20"),e.will_dispense=Object.values(e.banknotes).some(i=>i>0),e},$=function(n){return this.hasRecycler?a(this,s,v).call(this)?a(this,s,oe).call(this,n):a(this,s,le).call(this,n):{banknotes:{$_20:0,$_50:0,$_100:0,$_200:0,$_500:0,$_1000:0},pending:n,will_dispense:!1}},B=function(n){const e={coins:{$_50c:0,$_1:0,$_2:0,$_5:0,$_10:0},pending:n,will_dispense:!1};if(!this.hasCoinPurse||n<=0||this.totalInTubes===0)return e;const t=(i,r,o=null)=>{if(this.coins.tubes[r]>0){o===null&&(o="$_"+i);const l=Math.floor(e.pending/i),u=Math.min(l,this.coins.tubes[r]);e.coins[o]=u,e.pending=parseFloat((e.pending-u*i).toFixed(2))}};return t(10,"p10"),t(5,"p5"),t(2,"p2"),t(1,"p1"),t(.5,"g50","$_50c"),e.will_dispense=Object.values(e.coins).some(i=>i>0),e},q=async function(n=null){if(!a(this,s,S).call(this))throw new Error("Change not available");let e=this.change,t=this.change;if(n!==null&&(e=n,t=n),t<=0)return!1;const i=a(this,s,$).call(this,t);t=i.pending;const r=a(this,s,B).call(this,t);return t=r.pending,t>0&&this.dispatch("change:pending",{pending:t}),this.dispatch("change:dispense",{recycler:i.banknotes,coins:r.coins,pending:t,delivery:e-t}),t===e?!1:(i.will_dispense&&await this.banknotePurseDispense(i.banknotes),r.will_dispense&&await this.coinPurseDispense(r.coins),!0)};exports.Boardroid=ue;
package/dist/boardroid.js CHANGED
@@ -1,17 +1,17 @@
1
- var oe = Object.defineProperty;
2
- var D = (l) => {
3
- throw TypeError(l);
1
+ var ce = Object.defineProperty;
2
+ var D = (c) => {
3
+ throw TypeError(c);
4
4
  };
5
- var ce = (l, p, n) => p in l ? oe(l, p, { enumerable: !0, configurable: !0, writable: !0, value: n }) : l[p] = n;
6
- var h = (l, p, n) => ce(l, typeof p != "symbol" ? p + "" : p, n), I = (l, p, n) => p.has(l) || D("Cannot " + n);
7
- var y = (l, p, n) => (I(l, p, "read from private field"), n ? n.call(l) : p.get(l)), w = (l, p, n) => p.has(l) ? D("Cannot add the same private member more than once") : p instanceof WeakSet ? p.add(l) : p.set(l, n), b = (l, p, n, e) => (I(l, p, "write to private field"), e ? e.call(l, n) : p.set(l, n), n), a = (l, p, n) => (I(l, p, "access private method"), n);
8
- import { K as le, _ as x } from "./kernel-Bquzoyqh.js";
5
+ var pe = (c, p, n) => p in c ? ce(c, p, { enumerable: !0, configurable: !0, writable: !0, value: n }) : c[p] = n;
6
+ var h = (c, p, n) => pe(c, typeof p != "symbol" ? p + "" : p, n), I = (c, p, n) => p.has(c) || D("Cannot " + n);
7
+ var w = (c, p, n) => (I(c, p, "read from private field"), n ? n.call(c) : p.get(c)), y = (c, p, n) => p.has(c) ? D("Cannot add the same private member more than once") : p instanceof WeakSet ? p.add(c) : p.set(c, n), b = (c, p, n, e) => (I(c, p, "write to private field"), e ? e.call(c, n) : p.set(c, n), n), a = (c, p, n) => (I(c, p, "access private method"), n);
8
+ import { K as ue, _ as x } from "./kernel-Bquzoyqh.js";
9
9
  import { l as d } from "./relay-Dop4mFk-.js";
10
- var f, _, k, i, E, M, v, S, Q, N, F, j, O, U, A, T, L, z, W, K, V, Y, m, G, H, J, X, Z, g, ee, ne, te, ie, se, R, C, re, ae, P, $, B;
11
- class he extends le {
10
+ var f, _, k, s, E, M, v, S, m, Q, N, F, j, O, U, A, L, T, V, z, W, K, Y, G, H, J, X, Z, g, ee, ne, te, se, ie, re, ae, R, C, oe, le, P, $, B;
11
+ class _e extends ue {
12
12
  constructor({ filters: n = null, config_port: e = null, no_device: t = 1 } = {}) {
13
13
  super({ filters: n, config_port: e, no_device: t });
14
- w(this, i);
14
+ y(this, s);
15
15
  h(this, "__coin_purse", {
16
16
  available: !0
17
17
  });
@@ -58,9 +58,9 @@ class he extends le {
58
58
  available: !1,
59
59
  max_pre_credit: 0
60
60
  });
61
- w(this, f, !1);
62
- w(this, _, 0);
63
- w(this, k, 0);
61
+ y(this, f, !1);
62
+ y(this, _, 0);
63
+ y(this, k, 0);
64
64
  if (this.__internal__.device.type = "boardroid", x.getCustom(this.typeDevice, t))
65
65
  throw new Error(`Device ${this.typeDevice} ${t} already exists`);
66
66
  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 = {
@@ -68,7 +68,7 @@ class he extends le {
68
68
  second_channel: null,
69
69
  sensor: !0,
70
70
  seconds: null
71
- }, a(this, i, E).call(this), a(this, i, M).call(this);
71
+ }, a(this, s, E).call(this), a(this, s, M).call(this);
72
72
  }
73
73
  get totalInTubes() {
74
74
  return this.coins.tubes.g50 * 0.5 + this.coins.tubes.c50 * 0.5 + this.coins.tubes.p1 + this.coins.tubes.p2 * 2 + this.coins.tubes.p5 * 5 + this.coins.tubes.p10 * 10;
@@ -127,46 +127,46 @@ class he extends le {
127
127
  const t = (5 + this.deviceNumber).toString(16).padStart(2, "0").toLowerCase();
128
128
  switch (n[1]) {
129
129
  case t:
130
- e.request = "connect", e = a(this, i, Q).call(this, e);
130
+ e.request = "connect", e = a(this, s, m).call(this, e);
131
131
  break;
132
132
  case "a0":
133
- e.request = "--automatic", e = a(this, i, L).call(this, n, e);
133
+ e.request = "--automatic", e = a(this, s, V).call(this, n, e);
134
134
  break;
135
135
  case "b0":
136
- e.request = "--automatic", e = a(this, i, z).call(this, n, e);
136
+ e.request = "--automatic", e = a(this, s, z).call(this, n, e);
137
137
  break;
138
138
  case "d0":
139
- e.request = "coin-purse:config", e = a(this, i, W).call(this, n[2], e);
139
+ e.request = "coin-purse:config", e = a(this, s, W).call(this, n[2], e);
140
140
  break;
141
141
  case "d1":
142
- e.request = "banknote-purse:config", e.additional = { scrow: null }, e = a(this, i, K).call(this, n, e);
142
+ e.request = "banknote-purse:config", e.additional = { scrow: null }, e = a(this, s, K).call(this, n, e);
143
143
  break;
144
144
  case "d2":
145
- e.request = "coin-purse:read-tubes", e = a(this, i, V).call(this, n, e);
145
+ e.request = "coin-purse:read-tubes", e = a(this, s, Y).call(this, n, e);
146
146
  break;
147
147
  case "d3":
148
- e.request = "banknote-purse:read-recycler", e = a(this, i, Y).call(this, n, e);
148
+ e.request = "banknote-purse:read-recycler", e = a(this, s, G).call(this, n, e);
149
149
  break;
150
150
  case "d4":
151
- e.request = "banknote-purse:banknote-scrow-status", e = a(this, i, m).call(this, n[2], e);
151
+ e.request = "banknote-purse:banknote-scrow-status", e = a(this, s, H).call(this, n[2], e);
152
152
  break;
153
153
  case "d5":
154
- e.request = "banknote-purse:dispense", e = a(this, i, G).call(this, n, e);
154
+ e.request = "banknote-purse:dispense", e = a(this, s, J).call(this, n, e);
155
155
  break;
156
156
  case "d6":
157
- e.request = "coin-purse:dispense", e = a(this, i, H).call(this, n, e);
157
+ e.request = "coin-purse:dispense", e = a(this, s, X).call(this, n, e);
158
158
  break;
159
159
  case "d7":
160
- e.request = "dispense", e = a(this, i, J).call(this, n[5], e);
160
+ e.request = "dispense", e = a(this, s, Z).call(this, n[5], e);
161
161
  break;
162
162
  case "d8":
163
- e.request = "--automatic", e = a(this, i, X).call(this, n[13], e);
163
+ e.request = "--automatic", e = a(this, s, g).call(this, n[13], e);
164
164
  break;
165
165
  case "d9":
166
- e.request = "status:temperature", e = a(this, i, Z).call(this, n, e);
166
+ e.request = "status:temperature", e = a(this, s, ee).call(this, n, e);
167
167
  break;
168
168
  case "da":
169
- e.request = "status:relay", e = a(this, i, g).call(this, n[2], e);
169
+ e.request = "status:relay", e = a(this, s, ne).call(this, n[2], e);
170
170
  break;
171
171
  case "db":
172
172
  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 });
@@ -175,7 +175,7 @@ class he extends le {
175
175
  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 });
176
176
  break;
177
177
  case "dd":
178
- e.request = "card-reader", a(this, i, ee).call(this, n, e);
178
+ e.request = "card-reader", a(this, s, te).call(this, n, e);
179
179
  break;
180
180
  default:
181
181
  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);
@@ -199,14 +199,14 @@ class he extends le {
199
199
  async coinPurseDisable() {
200
200
  await this.coinPurseConfigure({ enable: !1 });
201
201
  }
202
- async coinPurseDispense({ $_50c: n = 0, $_1: e = 0, $_2: t = 0, $_5: s = 0, $_10: r = 0 } = {}) {
202
+ async coinPurseDispense({ $_50c: n = 0, $_1: e = 0, $_2: t = 0, $_5: i = 0, $_10: r = 0 } = {}) {
203
203
  if (!this.__coin_purse.available) throw new Error("Coin purse not available");
204
204
  return await this.appendToQueue(
205
205
  d.coinPurseDispense({
206
206
  $50c: n,
207
207
  $1: e,
208
208
  $2: t,
209
- $5: s,
209
+ $5: i,
210
210
  $10: r
211
211
  }),
212
212
  "coin-purse:dispense"
@@ -218,18 +218,18 @@ class he extends le {
218
218
  async banknotePurseConfigure({ enable: n = !1, scrow: e = !1 } = {}) {
219
219
  if (!this.__banknote_purse.available) throw new Error("Banknote purse not available");
220
220
  let t;
221
- return a(this, i, v).call(this) ? t = a(this, i, ne).call(this, { enable: n, scrow: e }) : t = a(this, i, te).call(this, { enable: n, scrow: e }), await this.appendToQueue(t, "banknote-purse:config");
221
+ return a(this, s, v).call(this) ? t = a(this, s, se).call(this, { enable: n, scrow: e }) : t = a(this, s, ie).call(this, { enable: n, scrow: e }), await this.appendToQueue(t, "banknote-purse:config");
222
222
  }
223
- async banknotePurseDispense({ $_20: n = 0, $_50: e = 0, $_100: t = 0, $_200: s = 0, $_500: r = 0, $_1000: c = 0 } = {}) {
223
+ async banknotePurseDispense({ $_20: n = 0, $_50: e = 0, $_100: t = 0, $_200: i = 0, $_500: r = 0, $_1000: o = 0 } = {}) {
224
224
  if (!this.__banknote_purse.available) throw new Error("Banknote purse not available");
225
225
  if (!this.__banknote_purse.isRecycler) throw new Error("Banknote purse is not recycler");
226
- let o;
227
- if (a(this, i, v).call(this)) {
228
- const u = [n, e, t, s, r];
229
- o = a(this, i, ie).call(this, u[this.__banknote_purse.recycler.banknote]);
226
+ let l;
227
+ if (a(this, s, v).call(this)) {
228
+ const u = [n, e, t, i, r];
229
+ l = a(this, s, re).call(this, u[this.__banknote_purse.recycler.banknote]);
230
230
  } else
231
- o = a(this, i, se).call(this, { $_20: n, $_50: e, $_100: t, $_200: s, $_500: r, $_1000: c });
232
- await this.appendToQueue(o, "banknote-purse:dispense");
231
+ l = a(this, s, ae).call(this, { $_20: n, $_50: e, $_100: t, $_200: i, $_500: r, $_1000: o });
232
+ await this.appendToQueue(l, "banknote-purse:dispense");
233
233
  }
234
234
  async banknotePurseEnable({ scrow: n = !1 }) {
235
235
  return await this.banknotePurseConfigure({ enable: !0, scrow: n });
@@ -255,10 +255,10 @@ class he extends le {
255
255
  channel: n = null,
256
256
  $_20: e = null,
257
257
  $_50: t = null,
258
- $_100: s = null,
258
+ $_100: i = null,
259
259
  $_200: r = null,
260
- $_500: c = null,
261
- $_1000: o = null
260
+ $_500: o = null,
261
+ $_1000: l = null
262
262
  } = {}) {
263
263
  if (!this.__banknote_purse.available) throw new Error("Banknote purse not available");
264
264
  return await this.appendToQueue(
@@ -266,10 +266,10 @@ class he extends le {
266
266
  channel: n,
267
267
  $20: e,
268
268
  $50: t,
269
- $100: s,
269
+ $100: i,
270
270
  $200: r,
271
- $500: c,
272
- $1000: o
271
+ $500: o,
272
+ $1000: l
273
273
  }),
274
274
  "banknote-purse:save-memory"
275
275
  );
@@ -283,18 +283,18 @@ class he extends le {
283
283
  if (!this.card_reader.available) throw new Error("Card reader not available");
284
284
  return await this.appendToQueue(d.cardReaderDisable(), "card-reader:disable");
285
285
  }
286
- async cardReaderDispense({ channel: n = 1, second_channel: e = null, sensor: t = !0, seconds: s = null, price: r = 0 } = {}) {
286
+ async cardReaderDispense({ channel: n = 1, second_channel: e = null, sensor: t = !0, seconds: i = null, price: r = 0 } = {}) {
287
287
  if (!this.card_reader.available) throw new Error("Card reader not available");
288
288
  if ((isNaN(this.card_reader.max_pre_credit) || this.card_reader.max_pre_credit === 0) && (this.card_reader.max_pre_credit = r), isNaN(r) || r <= 0) throw new Error("Price must be greater than 0");
289
289
  if (r > this.card_reader.max_pre_credit) throw new Error("Price is greater than pre-credit configured");
290
- if (!t && (s === null || s <= 0 || s > 40))
290
+ if (!t && (i === null || i <= 0 || i > 40))
291
291
  throw new Error("Invalid time to dispense without sensor, must be between 0.1 and 40.0 seconds");
292
292
  return this.appendToQueue(
293
293
  d.cardReaderDispense({
294
294
  selection: n,
295
295
  second_selection: e,
296
296
  sensor: t,
297
- seconds: s,
297
+ seconds: i,
298
298
  price: r
299
299
  }),
300
300
  "card-reader:dispense"
@@ -327,45 +327,45 @@ class he extends le {
327
327
  * @param {boolean} retry
328
328
  * @return {Promise<unknown>}
329
329
  */
330
- async dispense({ selection: n = 1, second_selection: e = null, sensor: t = !0, seconds: s = null, retry: r = !0 } = {}) {
330
+ async dispense({ selection: n = 1, second_selection: e = null, sensor: t = !0, seconds: i = null, retry: r = !0 } = {}) {
331
331
  if (n = parseInt(n), isNaN(n) || n < 1 || n > 80) throw new Error("Invalid channel number");
332
332
  if (e !== null && (e < 1 || e > 80 || e === n))
333
333
  throw new Error("Invalid second channel number");
334
- if (!t && (s === null || s <= 0 || s > 40))
334
+ if (!t && (i === null || i <= 0 || i > 40))
335
335
  throw new Error("Invalid time to dispense without sensor, must be between 0.1 and 40.0 seconds");
336
336
  r && (this.__internal__.dispense.backup_dispense = {
337
337
  selection: n,
338
338
  second_selection: e,
339
339
  sensor: t,
340
- seconds: s
340
+ seconds: i
341
341
  });
342
- const c = d.dispense({
342
+ const o = d.dispense({
343
343
  selection: n,
344
344
  second_selection: e,
345
345
  sensor: t,
346
- seconds: s
346
+ seconds: i
347
347
  });
348
- t || (s || (s = 1.5), this.__internal__.dispense.custom_limit_counter = s + 0.2);
349
- let o = await this.internalDispense(c);
350
- return !o.dispensed && r && (o = await this.internalDispense(c)), this.__internal__.dispense.custom_limit_counter = null, o;
348
+ t || (i || (i = 1.5), this.__internal__.dispense.custom_limit_counter = i + 0.2);
349
+ let l = await this.internalDispense(o);
350
+ return !l.dispensed && r && (l = await this.internalDispense(o)), this.__internal__.dispense.custom_limit_counter = null, l;
351
351
  }
352
352
  async testEngines({ singleEngine: n = !1 } = {}) {
353
353
  if (this.isDispensing) throw new Error("Another dispensing process is running");
354
- if (y(this, f)) throw new Error("Another test is running");
355
- a(this, i, R).call(this), b(this, f, !0);
354
+ if (w(this, f)) throw new Error("Another test is running");
355
+ a(this, s, R).call(this), b(this, f, !0);
356
356
  const e = [];
357
- a(this, i, C).call(this);
357
+ a(this, s, C).call(this);
358
358
  for (let t = 1; t <= 80; t++) {
359
- const s = await this.dispense({
359
+ const i = await this.dispense({
360
360
  selection: t,
361
361
  second_selection: n ? null : t + 1,
362
362
  sensor: !1,
363
363
  seconds: 0.4,
364
364
  retry: !1
365
365
  });
366
- e.push(s), b(this, _, t), a(this, i, C).call(this), n || t++;
366
+ e.push(i), b(this, _, t), a(this, s, C).call(this), n || t++;
367
367
  }
368
- b(this, _, 80), a(this, i, C).call(this, { dispensed: e }), a(this, i, R).call(this);
368
+ b(this, _, 80), a(this, s, C).call(this, { dispensed: e }), a(this, s, R).call(this);
369
369
  }
370
370
  async sendCustomCode({ code: n = [] } = {}) {
371
371
  if (n.length === 0) throw new Error("Invalid code");
@@ -373,19 +373,19 @@ class he extends le {
373
373
  }
374
374
  hasToReturnChange(n = 0) {
375
375
  let e = n;
376
- return e <= 0 ? !0 : (e = a(this, i, P).call(this, e).pending, e = a(this, i, $).call(this, e).pending, !(e > 0));
376
+ return e <= 0 ? !0 : (e = a(this, s, P).call(this, e).pending, e = a(this, s, $).call(this, e).pending, !(e > 0));
377
377
  }
378
378
  async returnChange() {
379
- return await a(this, i, B).call(this);
379
+ return await a(this, s, B).call(this);
380
380
  }
381
381
  async returnInsertedMoney() {
382
- return this.__money_session.inserted <= 0 ? !1 : await a(this, i, B).call(this, this.__money_session.inserted);
382
+ return this.__money_session.inserted <= 0 ? !1 : await a(this, s, B).call(this, this.__money_session.inserted);
383
383
  }
384
384
  async serialCorruptMessage(n, e) {
385
385
  this.dispatch("corrupt:message", { data: n, message: e });
386
386
  }
387
387
  }
388
- f = new WeakMap(), _ = new WeakMap(), k = new WeakMap(), i = new WeakSet(), E = function() {
388
+ f = new WeakMap(), _ = new WeakMap(), k = new WeakMap(), s = new WeakSet(), E = function() {
389
389
  const n = [
390
390
  "banknote-purse:banknote-scrow-status",
391
391
  "banknote-purse:config",
@@ -408,7 +408,8 @@ f = new WeakMap(), _ = new WeakMap(), k = new WeakMap(), i = new WeakSet(), E =
408
408
  "event:door",
409
409
  "door:event",
410
410
  "status:relay",
411
- "status:temperature"
411
+ "status:temperature",
412
+ "money:inserted"
412
413
  ];
413
414
  for (const e of n)
414
415
  this.serialRegisterAvailableListener(e);
@@ -418,8 +419,19 @@ f = new WeakMap(), _ = new WeakMap(), k = new WeakMap(), i = new WeakSet(), E =
418
419
  return this.__banknote_purse.isRecycler && this.__banknote_purse.recycler.ict;
419
420
  }, S = function() {
420
421
  return this.hasCoinPurse || this.hasRecycler;
421
- }, Q = function(n) {
422
+ }, m = function(n) {
422
423
  return n.name = "Connection with the serial device completed.", n.description = "Your connection with the serial device was successfully completed.", n.no_code = 1, this.dispatch("run:default-load", {}), n;
424
+ }, Q = function(n) {
425
+ const e = {
426
+ g50: { value: 0.5, name: "50 pennies (the big one)" },
427
+ c0: { value: 0.5, name: "50 pennies (the little one)" },
428
+ p1: { value: 1, name: "1 peso" },
429
+ p2: { value: 2, name: "2 pesos" },
430
+ p5: { value: 5, name: "5 pesos" },
431
+ p10: { value: 10, name: "10 pesos" },
432
+ p20: { value: 20, name: "20 pesos" }
433
+ };
434
+ return e[n] ? e[n] : !1;
423
435
  }, N = function(n) {
424
436
  const e = {
425
437
  g50: ["40", "50", "60", "70", "90"],
@@ -471,46 +483,70 @@ f = new WeakMap(), _ = new WeakMap(), k = new WeakMap(), i = new WeakSet(), E =
471
483
  p1000: "1000 pesos"
472
484
  }[t], t] : [`Undefined value: ¿${n}?`, null];
473
485
  }, O = function(n) {
474
- return ["p20", "p50", "p100", "p200", "p500", "p1000"].includes(n);
486
+ const e = {
487
+ p20: { value: 20, name: "20 pesos" },
488
+ p50: { value: 50, name: "50 pesos" },
489
+ p100: { value: 100, name: "100 pesos" },
490
+ p200: { value: 200, name: "200 pesos" },
491
+ p500: { value: 500, name: "500 pesos" },
492
+ p1000: { value: 1e3, name: "1000 pesos" }
493
+ };
494
+ return e[n] ? e[n] : !1;
475
495
  }, U = function(n) {
496
+ return ["p20", "p50", "p100", "p200", "p500", "p1000"].includes(n);
497
+ }, A = function(n) {
476
498
  return ["r20", "r50", "r100"].includes(n);
477
- }, A = function() {
499
+ }, L = function() {
478
500
  return ["r20", "r50", "r100", "r200", "r500"][this.__banknote_purse.recycler.banknote];
479
501
  }, T = function(n, e, t) {
480
502
  if (!n) return;
481
- let s = !0;
482
- if (a(this, i, F).call(this, n) && t === "coin") {
503
+ let i = !0;
504
+ if (a(this, s, F).call(this, n) && t === "coin") {
483
505
  if (typeof this.coins.tubes[n] > "u") return;
484
506
  e === "tube" ? this.coins.tubes[n] += 1 : e === "box" && (this.coins.box[n] += 1);
485
507
  let r = 0;
486
508
  ["g50", "c50"].includes(n) ? r = 0.5 : r += parseInt(n.slice(1)), this.coins.totals[n] += r, this.__money_session.inserted += r, this.coins.total += r;
487
- } else if (a(this, i, O).call(this, n) && t === "banknote") {
509
+ const o = a(this, s, Q).call(this, n);
510
+ o && this.dispatch("money:inserted", {
511
+ type: "coin",
512
+ money: o,
513
+ // {value:number,name:string}
514
+ where: e
515
+ });
516
+ } else if (a(this, s, U).call(this, n) && t === "banknote") {
488
517
  if (typeof this.banknotes.recycler[n] > "u") return;
489
518
  e === "recycler" ? this.banknotes.recycler[n] += 1 : e === "stacker" && (this.banknotes.stacker[n] += 1);
490
519
  let r = parseInt(n.slice(1));
491
520
  this.banknotes.totals[n] += r, this.__money_session.inserted += r, this.banknotes.total += r;
492
- } else if (a(this, i, U).call(this, n) && e === "out" && t === "banknote") {
521
+ const o = a(this, s, O).call(this, n);
522
+ o && this.dispatch("money:inserted", {
523
+ type: "banknote",
524
+ money: o,
525
+ // {value:number,name:string}
526
+ where: e
527
+ });
528
+ } else if (a(this, s, A).call(this, n) && e === "out" && t === "banknote") {
493
529
  if (typeof this.banknotes.out[n.replace("r", "p")] > "u") return;
494
530
  this.banknotes.out[n.replace("r", "p")] += 1;
495
531
  let r = parseInt(n.slice(1));
496
- this.__money_session.retired += r, this.banknotes.recycler[n.replace("r", "p")] -= 1, this.banknotes.total -= r, s = !1, this.dispatch("session:money-dispensed", { type_money: n, retired: r, finish: !1, type: "banknotes" });
532
+ this.__money_session.retired += r, this.banknotes.recycler[n.replace("r", "p")] -= 1, this.banknotes.total -= r, i = !1, this.dispatch("session:money-dispensed", { type_money: n, retired: r, finish: !1, type: "banknotes" });
497
533
  }
498
- s && this.dispatch("session:money-request", {});
499
- }, L = function(n, e) {
534
+ i && this.dispatch("session:money-request", {});
535
+ }, V = function(n, e) {
500
536
  const t = parseInt(n[2], 16);
501
- return e.name = "Coin Inserted", e.no_code = 2, e.additional = { where: null, coin: null }, t === 1 ? (e.name = "Lever pressed", e.description = "Reject lever", e.no_code = 100, this.dispatch("coin-purse:reject-lever", {})) : t === 2 ? (e.name = "Reset coin purse", e.description = "The configuration of coin purse was reset", e.no_code = 101, this.dispatch("coin-purse:reset", {})) : t >= 64 && t <= 79 ? (e.name = "Coin inserted in profit box", e.additional.where = "box") : t >= 80 && t <= 95 ? (e.name = "Coin inserted in tube", e.additional.where = "tube") : t >= 96 && t <= 111 ? (e.name = "Unused coin", e.description = "Something come from coin changer but in MDB Docs is unused", e.additional.where = "unused") : t >= 112 && t <= 127 ? (e.name = "Coin rejected", e.additional.where = "rejected") : t >= 144 && t <= 159 ? (e.name = "Coin dispensed", e.additional.where = "out", e.description = `Undefined value: ¿${n[2]}?`) : (e.name = "Coin inserted", e.description = "Undefined status. Without information of this", e.no_code = 400), t === 1 || t === 2 || t >= 160 || t >= 128 && t <= 143 || ([e.description, e.additional.coin] = a(this, i, N).call(this, n[2]), e.no_code = 38 + t, a(this, i, T).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;
537
+ return e.name = "Coin Inserted", e.no_code = 2, e.additional = { where: null, coin: null }, t === 1 ? (e.name = "Lever pressed", e.description = "Reject lever", e.no_code = 100, this.dispatch("coin-purse:reject-lever", {})) : t === 2 ? (e.name = "Reset coin purse", e.description = "The configuration of coin purse was reset", e.no_code = 101, this.dispatch("coin-purse:reset", {})) : t >= 64 && t <= 79 ? (e.name = "Coin inserted in profit box", e.additional.where = "box") : t >= 80 && t <= 95 ? (e.name = "Coin inserted in tube", e.additional.where = "tube") : t >= 96 && t <= 111 ? (e.name = "Unused coin", e.description = "Something come from coin changer but in MDB Docs is unused", e.additional.where = "unused") : t >= 112 && t <= 127 ? (e.name = "Coin rejected", e.additional.where = "rejected") : t >= 144 && t <= 159 ? (e.name = "Coin dispensed", e.additional.where = "out", e.description = `Undefined value: ¿${n[2]}?`) : (e.name = "Coin inserted", e.description = "Undefined status. Without information of this", e.no_code = 400), t === 1 || t === 2 || t >= 160 || t >= 128 && t <= 143 || ([e.description, e.additional.coin] = a(this, s, N).call(this, n[2]), e.no_code = 38 + t, a(this, s, T).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;
502
538
  }, z = function(n, e) {
503
539
  const t = parseInt(n[2], 16);
504
- return e.name = "Banknote Inserted", e.no_code = 2, e.additional = { where: null, banknote: null }, t === 42 ? (e.name = "Banknote dispensed", e.description = "Banknote dispensed by request.", e.additional.banknote = a(this, i, A).call(this), e.additional.where = "out", e.no_code = 200) : t >= 128 && t <= 143 ? (e.name = "Banknote inserted", e.additional.where = "stacker") : t >= 144 && t <= 159 ? (e.name = "Banknote inserted in pre stacker", e.additional.where = "tmp") : t >= 160 && t <= 175 ? (e.name = "Banknote rejected", e.additional.where = "nothing") : t >= 176 && t <= 191 && (e.name = "Banknote inserted", e.additional.where = "recycler"), t >= 128 && t <= 191 && ([e.description, e.additional.banknote] = a(this, i, j).call(this, n[2]), e.no_code = 74 + t), a(this, i, T).call(this, e.additional.banknote, e.additional.where, "banknote"), this.dispatch("banknote-purse:event-banknote", this.banknotes), e;
540
+ return e.name = "Banknote Inserted", e.no_code = 2, e.additional = { where: null, banknote: null }, t === 42 ? (e.name = "Banknote dispensed", e.description = "Banknote dispensed by request.", e.additional.banknote = a(this, s, L).call(this), e.additional.where = "out", e.no_code = 200) : t >= 128 && t <= 143 ? (e.name = "Banknote inserted", e.additional.where = "stacker") : t >= 144 && t <= 159 ? (e.name = "Banknote inserted in pre stacker", e.additional.where = "tmp") : t >= 160 && t <= 175 ? (e.name = "Banknote rejected", e.additional.where = "nothing") : t >= 176 && t <= 191 && (e.name = "Banknote inserted", e.additional.where = "recycler"), t >= 128 && t <= 191 && ([e.description, e.additional.banknote] = a(this, s, j).call(this, n[2]), e.no_code = 74 + t), a(this, s, T).call(this, e.additional.banknote, e.additional.where, "banknote"), this.dispatch("banknote-purse:event-banknote", this.banknotes), e;
505
541
  }, W = function(n, e) {
506
542
  const t = parseInt(n, 16);
507
543
  return t === 1 ? (e.name = "Coin purse enabled", e.description = "Configuration complete, enabled", e.no_code = 3) : t === 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: t === 1 }), e;
508
544
  }, K = function(n, e) {
509
- const t = parseInt(n[2], 16), s = parseInt(n[3], 16);
510
- return t === 0 ? (e.name = "Bill purse disabled", e.description = "Configuration complete, disabled") : t === 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: t === 1, scrow: s === 1 }), e;
511
- }, V = function(n, e) {
545
+ const t = parseInt(n[2], 16), i = parseInt(n[3], 16);
546
+ return t === 0 ? (e.name = "Bill purse disabled", e.description = "Configuration complete, disabled") : t === 1 && (e.name = "Bill purse enabled", e.description = "Configuration complete, enabled"), i === 0 ? e.additional.scrow = "Scrow disabled, banknote received automatic" : i === 1 && (e.additional.scrow = "Scrow enabled, require manual action"), e.no_code = 5, this.dispatch("banknote-purse:config", { enabled: t === 1, scrow: i === 1 }), e;
547
+ }, Y = function(n, e) {
512
548
  e.no_code = 6;
513
- const [t, s, r, c, o, u] = [
549
+ const [t, i, r, o, l, u] = [
514
550
  parseInt(n[2], 16),
515
551
  parseInt(n[3], 16),
516
552
  parseInt(n[4], 16),
@@ -519,11 +555,11 @@ f = new WeakMap(), _ = new WeakMap(), k = new WeakMap(), i = new WeakSet(), E =
519
555
  parseInt(n[7], 16)
520
556
  ];
521
557
  return e.additional = {
522
- coins: { g50: t, c50: s, p1: r, p2: c, p5: o, p10: u }
523
- }, this.coins.tubes.g50 = t, this.coins.tubes.c50 = s, this.coins.tubes.p1 = r, this.coins.tubes.p2 = c, this.coins.tubes.p5 = o, this.coins.tubes.p10 = u, this.coins.totals.g50 = (this.coins.box.g50 + t) * 0.5, this.coins.totals.c50 = (this.coins.box.c50 + s) * 0.5, this.coins.totals.p1 = this.coins.box.p1 + r, this.coins.totals.p2 = (this.coins.box.p2 + c) * 2, this.coins.totals.p5 = (this.coins.box.p5 + o) * 5, this.coins.totals.p10 = (this.coins.box.p10 + u) * 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;
524
- }, Y = function(n, e) {
558
+ coins: { g50: t, c50: i, p1: r, p2: o, p5: l, p10: u }
559
+ }, this.coins.tubes.g50 = t, this.coins.tubes.c50 = i, this.coins.tubes.p1 = r, this.coins.tubes.p2 = o, this.coins.tubes.p5 = l, this.coins.tubes.p10 = u, this.coins.totals.g50 = (this.coins.box.g50 + t) * 0.5, this.coins.totals.c50 = (this.coins.box.c50 + i) * 0.5, this.coins.totals.p1 = this.coins.box.p1 + r, this.coins.totals.p2 = (this.coins.box.p2 + o) * 2, this.coins.totals.p5 = (this.coins.box.p5 + l) * 5, this.coins.totals.p10 = (this.coins.box.p10 + u) * 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;
560
+ }, G = function(n, e) {
525
561
  e.no_code = 7;
526
- const [t, s, r, c, o, u] = [
562
+ const [t, i, r, o, l, u] = [
527
563
  parseInt(n[2], 16),
528
564
  parseInt(n[3], 16),
529
565
  parseInt(n[4], 16),
@@ -532,22 +568,22 @@ f = new WeakMap(), _ = new WeakMap(), k = new WeakMap(), i = new WeakSet(), E =
532
568
  parseInt(n[7], 16)
533
569
  ];
534
570
  return e.additional = {
535
- banknotes: { b20: t, b50: s, b100: r, b200: c, b500: o, b1000: u }
536
- }, this.banknotes.recycler.p20 = t, this.banknotes.recycler.p50 = s, this.banknotes.recycler.p100 = r, this.banknotes.recycler.p200 = c, this.banknotes.recycler.p500 = o, this.banknotes.recycler.p1000 = u, this.banknotes.totals.p20 = (this.banknotes.stacker.p20 + t) * 20, this.banknotes.totals.p50 = (this.banknotes.stacker.p50 + s) * 50, this.banknotes.totals.p100 = (this.banknotes.stacker.p100 + r) * 100, this.banknotes.totals.p200 = (this.banknotes.stacker.p200 + c) * 200, this.banknotes.totals.p500 = (this.banknotes.stacker.p500 + o) * 500, this.banknotes.totals.p1000 = (this.banknotes.stacker.p1000 + u) * 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;
537
- }, m = function(n, e) {
571
+ banknotes: { b20: t, b50: i, b100: r, b200: o, b500: l, b1000: u }
572
+ }, this.banknotes.recycler.p20 = t, this.banknotes.recycler.p50 = i, this.banknotes.recycler.p100 = r, this.banknotes.recycler.p200 = o, this.banknotes.recycler.p500 = l, this.banknotes.recycler.p1000 = u, this.banknotes.totals.p20 = (this.banknotes.stacker.p20 + t) * 20, this.banknotes.totals.p50 = (this.banknotes.stacker.p50 + i) * 50, this.banknotes.totals.p100 = (this.banknotes.stacker.p100 + r) * 100, this.banknotes.totals.p200 = (this.banknotes.stacker.p200 + o) * 200, this.banknotes.totals.p500 = (this.banknotes.stacker.p500 + l) * 500, this.banknotes.totals.p1000 = (this.banknotes.stacker.p1000 + u) * 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;
573
+ }, H = function(n, e) {
538
574
  const t = parseInt(n, 16);
539
575
  return t === 1 ? e.name = "Banknote accepted" : t === 0 ? e.name = "Banknote rejected" : e.name = "Unknown status banknote", e.no_code = 8, this.dispatch("banknote-purse:banknote-scrow-status", { status: t === 1 }), e;
540
- }, G = function(n, e) {
541
- const [t, s, r, c, o, u] = [
576
+ }, J = function(n, e) {
577
+ const [t, i, r, o, l, u] = [
542
578
  parseInt(n[2], 16),
543
579
  parseInt(n[3], 16),
544
580
  parseInt(n[4], 16),
545
581
  parseInt(n[5], 16),
546
582
  parseInt(n[6], 16),
547
583
  parseInt(n[7], 16)
548
- ], q = t * 20 + s * 50 + r * 100 + c * 200 + o * 500 + u * 1e3;
584
+ ], q = t * 20 + i * 50 + r * 100 + o * 200 + l * 500 + u * 1e3;
549
585
  return e.name = "Banknotes dispensed", e.description = q > 0 ? "Banknotes dispensed by request" : "No banknotes dispensed, recycler empty", e.no_code = 9, e.additional = {
550
- banknotes: { b20: t, b50: s, b100: r, b200: c, b500: o, b1000: u },
586
+ banknotes: { b20: t, b50: i, b100: r, b200: o, b500: l, b1000: u },
551
587
  total_dispensed: q
552
588
  }, this.dispatch("session:money-dispensed", {
553
589
  type_money: null,
@@ -556,7 +592,7 @@ f = new WeakMap(), _ = new WeakMap(), k = new WeakMap(), i = new WeakSet(), E =
556
592
  type: "banknotes",
557
593
  data: e
558
594
  }), e;
559
- }, H = function(n, e) {
595
+ }, X = function(n, e) {
560
596
  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(
561
597
  "session:money-dispensed",
562
598
  {
@@ -567,24 +603,24 @@ f = new WeakMap(), _ = new WeakMap(), k = new WeakMap(), i = new WeakSet(), E =
567
603
  },
568
604
  500
569
605
  ), e;
570
- }, J = function(n, e) {
606
+ }, Z = function(n, e) {
571
607
  const t = parseInt(n, 16);
572
608
  return t === 1 ? (e.name = "Product not delivered", e.description = "The product requested wasn't delivered", e.no_code = 11, this.__internal__.dispense.status = !1) : t === 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;
573
- }, X = function(n, e) {
609
+ }, g = function(n, e) {
574
610
  let t = "closed";
575
611
  return n === "db" ? (e.name = "Door closed", e.no_code = 13) : n === "dc" ? (e.name = "Door open", e.no_code = 14, t = "open") : (e.name = "Unknown status door", e.description = "The response of door doesn't identify successfully", e.no_code = 400, t = "unknown"), this.__internal__.device.door_open = t === "open", this.dispatch("event:door", { open: t === "open" }), this.dispatch("door:event", { open: t === "open" }), e;
576
- }, Z = function(n, e) {
577
- const t = parseInt(n[2], 16) * 255, s = parseInt(n[3], 16), r = (t + s) * 0.1;
612
+ }, ee = function(n, e) {
613
+ const t = parseInt(n[2], 16) * 255, i = parseInt(n[3], 16), r = (t + i) * 0.1;
578
614
  return e.no_code = 15, e.name = "Temperature status", e.description = `Temperature: ${r}`, e.additional = {
579
615
  high: t,
580
- low: s,
616
+ low: i,
581
617
  temperature: parseFloat(r.toString())
582
618
  }, this.dispatch("status:temperature", e.additional), e;
583
- }, g = function(n, e) {
619
+ }, ne = function(n, e) {
584
620
  const t = parseInt(n, 16);
585
- let s = "unknown";
586
- return t === 1 ? (e.name = "Relay on", e.description = "Relay on", e.no_code = 16, s = "on") : t === 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;
587
- }, ee = function(n, e) {
621
+ let i = "unknown";
622
+ return t === 1 ? (e.name = "Relay on", e.description = "Relay on", e.no_code = 16, i = "on") : t === 0 ? (e.name = "Relay off", e.description = "Relay off", e.no_code = 17, i = "off") : (e.name = "Status unknown", e.description = "Status unknown", e.no_code = 400), this.dispatch("status:relay", { enabled: i === "on" }), e;
623
+ }, te = function(n, e) {
588
624
  const t = parseInt(n[2], 16);
589
625
  if (e.no_code = 20 + t, e.name = "Status unknown", e.description = "The status of card reader does not identified correctly", t === 0)
590
626
  e.request += ":disable", e.name = "Card reader disabled", e.description = "Card reader device was disabled successfully";
@@ -603,27 +639,27 @@ f = new WeakMap(), _ = new WeakMap(), k = new WeakMap(), i = new WeakSet(), E =
603
639
  else if (t === 8)
604
640
  e.request += ":cancel", e.name = "Cancelled", e.description = "Cancellation complete";
605
641
  else if (t === 10) {
606
- const s = parseInt(n[8], 16);
607
- s === 1 ? (e.no_code = 30, e.name = "product not dispensed", e.description = "The product requested wasn't delivered") : s === 0 ? (e.no_code = 31, e.name = "product dispensed", e.description = "The product requested was delivered") : (e.name = "finished-unknown", e.no_code = 400);
642
+ const i = parseInt(n[8], 16);
643
+ i === 1 ? (e.no_code = 30, e.name = "product not dispensed", e.description = "The product requested wasn't delivered") : i === 0 ? (e.no_code = 31, e.name = "product dispensed", e.description = "The product requested was delivered") : (e.name = "finished-unknown", e.no_code = 400);
608
644
  } else
609
645
  e.no_code = 400;
610
646
  return this.dispatch("card-reader:event", e), e;
611
- }, ne = function({ enable: n = !1, scrow: e = !1 } = {}) {
647
+ }, se = function({ enable: n = !1, scrow: e = !1 } = {}) {
612
648
  return d.banknotePurseICTConfigure({ enable: n, scrow: e });
613
- }, te = function({ enable: n = !1, scrow: e = !1 } = {}) {
649
+ }, ie = function({ enable: n = !1, scrow: e = !1 } = {}) {
614
650
  return d.banknotePurseOtherConfigure({ enable: n, scrow: e });
615
- }, ie = function(n = 1) {
651
+ }, re = function(n = 1) {
616
652
  if (n < 1) throw new Error("No banknotes to dispense");
617
653
  const e = [20, 50, 100, 200, 500][this.__banknote_purse.recycler.banknote];
618
654
  return d.banknotePurseICTDispense({ quantity: n, denomination: e });
619
- }, se = function({ $_20: n = 0, $_50: e = 0, $_100: t = 0, $_200: s = 0, $_500: r = 0, $_1000: c = 0 } = {}) {
655
+ }, ae = function({ $_20: n = 0, $_50: e = 0, $_100: t = 0, $_200: i = 0, $_500: r = 0, $_1000: o = 0 } = {}) {
620
656
  return d.banknotePurseOtherDispense({
621
657
  $20: n,
622
658
  $50: e,
623
659
  $100: t,
624
- $200: s,
660
+ $200: i,
625
661
  $500: r,
626
- $1000: c
662
+ $1000: o
627
663
  });
628
664
  }, R = function() {
629
665
  b(this, f, !1), b(this, _, 0), b(this, k, 0);
@@ -633,30 +669,30 @@ f = new WeakMap(), _ = new WeakMap(), k = new WeakMap(), i = new WeakSet(), E =
633
669
  * @param {number} limit
634
670
  */
635
671
  C = function({ dispensed: n = null, limit: e = 80 } = {}) {
636
- b(this, k, Math.round(y(this, _) * 100 / e)), this.dispatch("percentage:test", { percentage: y(this, k), dispensed: n });
637
- }, re = function(n) {
638
- const e = ["20", "50", "100", "200", "500"], t = this.__banknote_purse.recycler.banknote, s = "$_" + e[t], r = parseInt(e[t]), c = this.banknotes.recycler[`p${e[t]}`], o = Math.min(Math.floor(n / r), c), u = {
672
+ b(this, k, Math.round(w(this, _) * 100 / e)), this.dispatch("percentage:test", { percentage: w(this, k), dispensed: n });
673
+ }, oe = function(n) {
674
+ const e = ["20", "50", "100", "200", "500"], t = this.__banknote_purse.recycler.banknote, i = "$_" + e[t], r = parseInt(e[t]), o = this.banknotes.recycler[`p${e[t]}`], l = Math.min(Math.floor(n / r), o), u = {
639
675
  banknotes: { $_20: 0, $_50: 0, $_100: 0, $_200: 0, $_500: 0, $_1000: 0 },
640
676
  pending: n,
641
- will_dispense: o > 0
677
+ will_dispense: l > 0
642
678
  };
643
- return this.totalInRecycler === 0 || o < 1 || n === 0 || (u.banknotes[s] = o, u.pending = parseFloat((n - o * r).toFixed(2))), u;
644
- }, ae = function(n) {
679
+ return this.totalInRecycler === 0 || l < 1 || n === 0 || (u.banknotes[i] = l, u.pending = parseFloat((n - l * r).toFixed(2))), u;
680
+ }, le = function(n) {
645
681
  const e = {
646
682
  banknotes: { $_20: 0, $_50: 0, $_100: 0, $_200: 0, $_500: 0, $_1000: 0 },
647
683
  pending: n,
648
684
  will_dispense: !1
649
685
  };
650
686
  if (this.totalInRecycler === 0 || n === 0) return e;
651
- const t = (s, r) => {
687
+ const t = (i, r) => {
652
688
  if (this.banknotes.recycler[r] > 0) {
653
- const c = Math.floor(e.pending / s), o = Math.min(c, this.banknotes.recycler[r]);
654
- e.banknotes[`$_${s}`] = o, e.pending = parseFloat((e.pending - o * s).toFixed(2));
689
+ const o = Math.floor(e.pending / i), l = Math.min(o, this.banknotes.recycler[r]);
690
+ e.banknotes[`$_${i}`] = l, e.pending = parseFloat((e.pending - l * i).toFixed(2));
655
691
  }
656
692
  };
657
- return t(1e3, "p1000"), t(500, "p500"), t(200, "p200"), t(100, "p100"), t(50, "p50"), t(20, "p20"), e.will_dispense = Object.values(e.banknotes).some((s) => s > 0), e;
693
+ return t(1e3, "p1000"), t(500, "p500"), t(200, "p200"), t(100, "p100"), t(50, "p50"), t(20, "p20"), e.will_dispense = Object.values(e.banknotes).some((i) => i > 0), e;
658
694
  }, P = function(n) {
659
- return this.hasRecycler ? a(this, i, v).call(this) ? a(this, i, re).call(this, n) : a(this, i, ae).call(this, n) : {
695
+ return this.hasRecycler ? a(this, s, v).call(this) ? a(this, s, oe).call(this, n) : a(this, s, le).call(this, n) : {
660
696
  banknotes: { $_20: 0, $_50: 0, $_100: 0, $_200: 0, $_500: 0, $_1000: 0 },
661
697
  pending: n,
662
698
  will_dispense: !1
@@ -668,28 +704,28 @@ C = function({ dispensed: n = null, limit: e = 80 } = {}) {
668
704
  will_dispense: !1
669
705
  };
670
706
  if (!this.hasCoinPurse || n <= 0 || this.totalInTubes === 0) return e;
671
- const t = (s, r, c = null) => {
707
+ const t = (i, r, o = null) => {
672
708
  if (this.coins.tubes[r] > 0) {
673
- c === null && (c = "$_" + s);
674
- const o = Math.floor(e.pending / s), u = Math.min(o, this.coins.tubes[r]);
675
- e.coins[c] = u, e.pending = parseFloat((e.pending - u * s).toFixed(2));
709
+ o === null && (o = "$_" + i);
710
+ const l = Math.floor(e.pending / i), u = Math.min(l, this.coins.tubes[r]);
711
+ e.coins[o] = u, e.pending = parseFloat((e.pending - u * i).toFixed(2));
676
712
  }
677
713
  };
678
- return t(10, "p10"), t(5, "p5"), t(2, "p2"), t(1, "p1"), t(0.5, "g50", "$_50c"), e.will_dispense = Object.values(e.coins).some((s) => s > 0), e;
714
+ return t(10, "p10"), t(5, "p5"), t(2, "p2"), t(1, "p1"), t(0.5, "g50", "$_50c"), e.will_dispense = Object.values(e.coins).some((i) => i > 0), e;
679
715
  }, B = async function(n = null) {
680
- if (!a(this, i, S).call(this)) throw new Error("Change not available");
716
+ if (!a(this, s, S).call(this)) throw new Error("Change not available");
681
717
  let e = this.change, t = this.change;
682
718
  if (n !== null && (e = n, t = n), t <= 0) return !1;
683
- const s = a(this, i, P).call(this, t);
684
- t = s.pending;
685
- const r = a(this, i, $).call(this, t);
719
+ const i = a(this, s, P).call(this, t);
720
+ t = i.pending;
721
+ const r = a(this, s, $).call(this, t);
686
722
  return t = r.pending, t > 0 && this.dispatch("change:pending", { pending: t }), this.dispatch("change:dispense", {
687
- recycler: s.banknotes,
723
+ recycler: i.banknotes,
688
724
  coins: r.coins,
689
725
  pending: t,
690
726
  delivery: e - t
691
- }), t === e ? !1 : (s.will_dispense && await this.banknotePurseDispense(s.banknotes), r.will_dispense && await this.coinPurseDispense(r.coins), !0);
727
+ }), t === e ? !1 : (i.will_dispense && await this.banknotePurseDispense(i.banknotes), r.will_dispense && await this.coinPurseDispense(r.coins), !0);
692
728
  };
693
729
  export {
694
- he as Boardroid
730
+ _e as Boardroid
695
731
  };
package/dist/kernel.cjs CHANGED
@@ -6,4 +6,4 @@
6
6
  *
7
7
  * This source code is licensed under the MIT license found in the
8
8
  * LICENSE file in the root directory of this source tree.
9
- */const r="4.1.8";exports.Devices=e._;exports.Kernel=e.Kernel;exports.version=r;
9
+ */const r="4.1.9";exports.Devices=e._;exports.Kernel=e.Kernel;exports.version=r;
package/dist/kernel.js CHANGED
@@ -8,7 +8,7 @@ import { _ as s, K as n } from "./kernel-Bquzoyqh.js";
8
8
  * This source code is licensed under the MIT license found in the
9
9
  * LICENSE file in the root directory of this source tree.
10
10
  */
11
- const e = "4.1.8";
11
+ const e = "4.1.9";
12
12
  export {
13
13
  s as Devices,
14
14
  n as Kernel,
@@ -6,4 +6,4 @@
6
6
  *
7
7
  * This source code is licensed under the MIT license found in the
8
8
  * LICENSE file in the root directory of this source tree.
9
- */const u={wait:e.wait,getSeconds:e.getSeconds,supportWebSerial:e.supportWebSerial},c="4.1.8";exports.Devices=e._;exports.Emulator=e.Emulator;exports.Kernel=e.Kernel;exports.Relay=r.Relay;exports.Locker=o.Locker;exports.PinPad=i.PinPad;exports.PinPax=n.PinPax;exports.Jofemar=t.Jofemar;exports.Boardroid=a.Boardroid;exports.Arduino=s.Arduino;exports.utils=u;exports.version=c;
9
+ */const u={wait:e.wait,getSeconds:e.getSeconds,supportWebSerial:e.supportWebSerial},c="4.1.9";exports.Devices=e._;exports.Emulator=e.Emulator;exports.Kernel=e.Kernel;exports.Relay=r.Relay;exports.Locker=o.Locker;exports.PinPad=i.PinPad;exports.PinPax=n.PinPax;exports.Jofemar=t.Jofemar;exports.Boardroid=a.Boardroid;exports.Arduino=s.Arduino;exports.utils=u;exports.version=c;
package/dist/webserial.js CHANGED
@@ -20,7 +20,7 @@ const a = {
20
20
  wait: e,
21
21
  getSeconds: r,
22
22
  supportWebSerial: o
23
- }, s = "4.1.8";
23
+ }, s = "4.1.9";
24
24
  export {
25
25
  k as Arduino,
26
26
  S as Boardroid,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@danidoble/webserial",
3
- "version": "4.2.5",
3
+ "version": "4.2.7",
4
4
  "author": "danidoble",
5
5
  "repository": {
6
6
  "type": "git",
@@ -9,19 +9,19 @@
9
9
  "main": "./dist/webserial.cjs",
10
10
  "module": "./dist/webserial.js",
11
11
  "devDependencies": {
12
- "@danidoble/webserial-vending-commands": "file:../parser",
12
+ "@danidoble/webserial-vending-commands": "^1.0.1",
13
13
  "@eslint/eslintrc": "^3.3.1",
14
- "@eslint/js": "^9.26.0",
14
+ "@eslint/js": "^9.27.0",
15
15
  "autoprefixer": "^10.4.21",
16
16
  "axios": "^1.9.0",
17
- "eslint": "^9.26.0",
17
+ "eslint": "^9.27.0",
18
18
  "globals": "^15.15.0",
19
19
  "jsencrypt": "^3.3.2",
20
20
  "postcss": "^8.5.3",
21
21
  "prettier": "^3.5.3",
22
22
  "uuid": "^11.1.0",
23
23
  "vite": "^6.3.5",
24
- "webserial-core": "file:../webserial-core"
24
+ "webserial-core": "^1.0.7"
25
25
  },
26
26
  "exports": {
27
27
  ".": {