@danidoble/webserial 4.3.1 → 4.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/arduino.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var c=t=>{throw TypeError(t)};var _=(t,s,n)=>s.has(t)||c("Cannot "+n);var d=(t,s,n)=>s.has(t)?c("Cannot add the same private member more than once"):s instanceof WeakSet?s.add(t):s.set(t,n);var l=(t,s,n)=>(_(t,s,"access private method"),n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=require("./kernel-BTqvt4pt.cjs"),a=require("./relay-BsUsBpOv.cjs"),u=require("./webserial-core-DlH0cFSH.cjs");var r,h;class y extends p.Kernel{constructor({filters:n=null,config_port:o=null,no_device:i=1}={}){super({filters:n,config_port:o,no_device:i});d(this,r);if(this.__internal__.device.type="arduino",u.h.getCustom(this.typeDevice,i))throw new Error(`Device ${this.typeDevice} ${i} already exists`);this.__internal__.time.response_connection=2e3,this.__internal__.time.response_general=2e3,this.__internal__.serial.delay_first_connection=1e3,l(this,r,h).call(this),u.h.add(this),this.getResponseAsString()}serialMessage(n){const o=this.stringToArrayHex(n),i=this.stringToArrayBuffer(n),e={original_code:o,arrayBuffer:i,code:null,name:null,description:null,request:null,no_code:0};switch(e.code=n,n){case"connected":e.name="connected",e.description="Connection established",e.request="connect",e.no_code=100;break;case"created by danidoble":e.name="thanks",e.description="thanks for using this software",e.request="credits",e.no_code=101;break;case"hello there":e.name="hello there",e.description="hi human",e.request="hi",e.no_code=102;break;case"ara ara":e.name="ara ara",e.description="troll",e.request="ara ara",e.no_code=404;break;default:e.name="unknown",e.description="Unknown command",e.request="unknown",e.no_code=400;break}this.dispatch("serial:message",e)}serialSetConnectionConstant(n=1){return a.i.connection(n)}async sayCredits(){await this.appendToQueue(a.i.credits(),"credits")}async sayHi(){await this.appendToQueue(a.i.hi(),"hi")}async sayAra(){await this.appendToQueue(a.i.ara(),"ara")}async sendCustomCode({code:n=""}={}){if(typeof n!="string")throw new Error("Invalid string");await this.appendToQueue(this.parseStringToTextEncoder(n),"custom")}async doSomething(){await this.sayCredits(),await this.sayAra(),await this.sayHi()}}r=new WeakSet,h=function(){};exports.Arduino=y;
1
+ "use strict";var c=t=>{throw TypeError(t)};var _=(t,s,n)=>s.has(t)||c("Cannot "+n);var d=(t,s,n)=>s.has(t)?c("Cannot add the same private member more than once"):s instanceof WeakSet?s.add(t):s.set(t,n);var l=(t,s,n)=>(_(t,s,"access private method"),n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=require("./kernel-DlsHh4AG.cjs"),a=require("./relay-BsUsBpOv.cjs"),u=require("./webserial-core-DlH0cFSH.cjs");var r,h;class y extends p.Kernel{constructor({filters:n=null,config_port:o=null,no_device:i=1}={}){super({filters:n,config_port:o,no_device:i});d(this,r);if(this.__internal__.device.type="arduino",u.h.getCustom(this.typeDevice,i))throw new Error(`Device ${this.typeDevice} ${i} already exists`);this.__internal__.time.response_connection=2e3,this.__internal__.time.response_general=2e3,this.__internal__.serial.delay_first_connection=1e3,l(this,r,h).call(this),u.h.add(this),this.getResponseAsString()}serialMessage(n){const o=this.stringToArrayHex(n),i=this.stringToArrayBuffer(n),e={original_code:o,arrayBuffer:i,code:null,name:null,description:null,request:null,no_code:0};switch(e.code=n,n){case"connected":e.name="connected",e.description="Connection established",e.request="connect",e.no_code=100;break;case"created by danidoble":e.name="thanks",e.description="thanks for using this software",e.request="credits",e.no_code=101;break;case"hello there":e.name="hello there",e.description="hi human",e.request="hi",e.no_code=102;break;case"ara ara":e.name="ara ara",e.description="troll",e.request="ara ara",e.no_code=404;break;default:e.name="unknown",e.description="Unknown command",e.request="unknown",e.no_code=400;break}this.dispatch("serial:message",e)}serialSetConnectionConstant(n=1){return a.i.connection(n)}async sayCredits(){await this.appendToQueue(a.i.credits(),"credits")}async sayHi(){await this.appendToQueue(a.i.hi(),"hi")}async sayAra(){await this.appendToQueue(a.i.ara(),"ara")}async sendCustomCode({code:n=""}={}){if(typeof n!="string")throw new Error("Invalid string");await this.appendToQueue(this.parseStringToTextEncoder(n),"custom")}async doSomething(){await this.sayCredits(),await this.sayAra(),await this.sayHi()}}r=new WeakSet,h=function(){};exports.Arduino=y;
package/dist/arduino.js CHANGED
@@ -4,7 +4,7 @@ var c = (n) => {
4
4
  var p = (n, s, t) => s.has(n) || c("Cannot " + t);
5
5
  var d = (n, s, t) => s.has(n) ? c("Cannot add the same private member more than once") : s instanceof WeakSet ? s.add(n) : s.set(n, t);
6
6
  var h = (n, s, t) => (p(n, s, "access private method"), t);
7
- import { K as _ } from "./kernel-lcvN8cY0.js";
7
+ import { K as _ } from "./kernel-IUeiZp8d.js";
8
8
  import { i } from "./relay-Dop4mFk-.js";
9
9
  import { h as l } from "./webserial-core-DGKQCs5a.js";
10
10
  var r, u;
@@ -1 +1 @@
1
- "use strict";var ce=Object.defineProperty;var D=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)||D("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)?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);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const ue=require("./kernel-BTqvt4pt.cjs"),d=require("./relay-BsUsBpOv.cjs"),x=require("./webserial-core-DlH0cFSH.cjs");var f,_,k,s,E,M,v,S,Q,N,m,j,F,O,U,A,L,T,V,z,W,Y,G,H,J,K,X,Z,g,ee,ne,te,se,ie,re,ae,R,C,oe,le,P,$,q;class de extends ue.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",x.h.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.status&&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,R).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,R).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,P).call(this,e).pending,e=a(this,s,$).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(){x.h.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]},T=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,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},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,T).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)],B=t*20+i*50+r*100+o*200+l*500+u*1e3;return e.name="Banknotes dispensed",e.description=B>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:B},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})},R=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},P=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}},$=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,P).call(this,t);t=i.pending;const r=a(this,s,$).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=de;
1
+ "use strict";var ce=Object.defineProperty;var D=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)||D("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)?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);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const ue=require("./kernel-DlsHh4AG.cjs"),d=require("./relay-BsUsBpOv.cjs"),x=require("./webserial-core-DlH0cFSH.cjs");var f,_,k,s,E,M,v,S,Q,N,m,j,F,O,U,A,L,T,V,z,W,Y,G,H,J,K,X,Z,g,ee,ne,te,se,ie,re,ae,R,C,oe,le,P,$,q;class de extends ue.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",x.h.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.status&&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,R).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,R).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,P).call(this,e).pending,e=a(this,s,$).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(){x.h.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]},T=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,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},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,T).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)],B=t*20+i*50+r*100+o*200+l*500+u*1e3;return e.name="Banknotes dispensed",e.description=B>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:B},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})},R=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},P=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}},$=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,P).call(this,t);t=i.pending;const r=a(this,s,$).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=de;
package/dist/boardroid.js CHANGED
@@ -5,7 +5,7 @@ var D = (c) => {
5
5
  var pe = (c, p, n) => p in c ? ce(c, p, { enumerable: !0, configurable: !0, writable: !0, value: n }) : c[p] = n;
6
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
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 } from "./kernel-lcvN8cY0.js";
8
+ import { K as ue } from "./kernel-IUeiZp8d.js";
9
9
  import { l as d } from "./relay-Dop4mFk-.js";
10
10
  import { h as x } from "./webserial-core-DGKQCs5a.js";
11
11
  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;
package/dist/hopper.cjs CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";var N=Object.defineProperty;var w=p=>{throw TypeError(p)};var R=(p,a,e)=>a in p?N(p,a,{enumerable:!0,configurable:!0,writable:!0,value:e}):p[a]=e;var x=(p,a,e)=>R(p,typeof a!="symbol"?a+"":a,e),P=(p,a,e)=>a.has(p)||w("Cannot "+e);var E=(p,a,e)=>a.has(p)?w("Cannot add the same private member more than once"):a instanceof WeakSet?a.add(p):a.set(p,e);var n=(p,a,e)=>(P(p,a,"access private method"),e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("./webserial-core-DlH0cFSH.cjs");var t,H,u,f,c,_,b,A,v,s;class I extends l.K{constructor({filters:e=null,config_port:r={baudRate:115200,dataBits:8,stopBits:1,parity:"none",bufferSize:32768,flowControl:"none"},no_device:i=1}={filters:null,config_port:{baudRate:115200,dataBits:8,stopBits:1,parity:"none",bufferSize:32768,flowControl:"none"},no_device:1}){super({filters:e,config_port:r,no_device:i});E(this,t);x(this,"__hoppers__",{levels:[{id:1,currency:10,key:"Hopper 1",name:"10 Pesos",amount:0,capacity:1e3},{id:2,currency:5,key:"Hopper 2",name:"5 Pesos",amount:0,capacity:1e3},{id:3,currency:2,key:"Hopper 3",name:"2 Pesos",amount:0,capacity:1e3},{id:4,currency:1,key:"Hopper 4",name:"1 Peso",amount:0,capacity:1e3}],balance:0,current:null});if(this.__internal__.device.type="hopper",l.h.registerType(this.__internal__.device.type),l.h.getByNumber(this.typeDevice,i))throw new Error(`Device ${this.typeDevice} ${i} already exists`);this.__internal__.time.response_connection=7e3,this.__internal__.time.response_general=7e3,this.__internal__.serial.delay_first_connection=500,this.__internal__.serial.response.replacer="",this.__internal__.serial.response.limiter=`\r
2
- `,l.h.add(this),n(this,t,H).call(this)}get balance(){return this.__hoppers__.balance}get currentHopper(){return this.__hoppers__.current}get levels(){return this.__hoppers__.levels}setMaxCapacity({hopper:e=null,capacity:r=1e3}={hopper:null,capacity:1e3}){return n(this,t,_).call(this,e),this.__hoppers__.levels[e-1].capacity=r,this}setHopperName({hopper:e=null,name:r=""}={hopper:null,name:""}){if(n(this,t,_).call(this,e),typeof r!="string"||r.length===0)throw new TypeError("Name must be a non-empty string");return this.__hoppers__.levels[e-1].name=r,this}setHopperKey({hopper:e=null,key:r=""}={hopper:null,key:""}){if(n(this,t,_).call(this,e),typeof r!="string"||r.length===0)throw new TypeError("Key must be a non-empty string");return this.__hoppers__.levels[e-1].key=r,this}setHopperCurrency({hopper:e=null,currency:r=1}={hopper:null,currency:1}){if(n(this,t,_).call(this,e),typeof r!="number"||r<=0)throw new RangeError("Currency must be a positive number");return this.__hoppers__.levels[e-1].currency=r,this}serialMessage(e){const r=this.parseUint8ArrayToString(e),o={ascii:this.asciiToHex(r),code:e,name:"",description:"",request:this.lastAction,no_code:0,error:!1,data:null};if(e.length===3){n(this,t,u).call(this,o);return}if(e.length!==13){const h=n(this,t,v).call(this,{array:e,chunkSize:13});for(const d of h){const y=this.parseUint8ArrayToString(new Uint8Array(d)),T=this.asciiToHex(y),C=this.stringToArrayHex(y);o.code=d,o.hex=C,o.ascii=T,d.length!==13?n(this,t,u).call(this,o):n(this,t,f).call(this,o)}return}n(this,t,f).call(this,o)}serialSetConnectionConstant(){return[10,0,0,0,0,0,0,0,0,0,0,0,15]}async sendConnect(){const e=n(this,t,s).call(this,[10]);return await this.appendToQueue(e,"connect")}async requestStatus(){const e=n(this,t,s).call(this,[10,10,11,12]);return await this.appendToQueue(e,"status")}async readBalance(){const e=n(this,t,s).call(this,[10,192,1]);return await this.appendToQueue(e,"readBalance")}async clearBalance(){const e=n(this,t,s).call(this,[10,192,2]);return await this.appendToQueue(e,"clearBalance")}async forceInvalid(){const e="0A000F00".match(/.{1,2}/g);return await this.appendToQueue(e,"ForceInvalid")}async readHopper({hopper:e=null}={hopper:null}){n(this,t,_).call(this,e),this.__hoppers__.current=e;const r=n(this,t,s).call(this,[10,e,e]);return await this.appendToQueue(r,"readHopper")}async writeHopper({hopper:e=null,quantity:r=0}={hopper:null,quantity:0}){n(this,t,_).call(this,e),n(this,t,b).call(this,r),this.__hoppers__.current=e;const[i,o]=n(this,t,A).call(this,r),h=n(this,t,s).call(this,[10,240,e,0,0,0,0,0,0,i,o]);return await this.appendToQueue(h,"writeHopper")}async dispenseHopper({hopper:e=null}={hopper:null}){n(this,t,_).call(this,e),this.__hoppers__.current=e;const r=n(this,t,s).call(this,[10,2,e]);return await this.appendToQueue(r,"dispenseHopper")}async dispenseChange({change:e=0}={change:0}){if(typeof e!="number"||e<0||e>32767)throw new RangeError("Change must be a number between 0 and 32767");if(typeof e!="number"||!Number.isInteger(e))throw new TypeError("Change must be an integer");const r=e&255,i=e>>8&255,o=n(this,t,s).call(this,[10,204,170,0,0,0,0,0,0,i,r]);return await this.appendToQueue(o,"dispenseChange")}async configValidator({enable:e=!1}={enable:!1}){if(typeof e!="boolean")throw new TypeError("Enable must be a boolean");const r=n(this,t,s).call(this,[10,176,e?1:0]);return await this.appendToQueue(r,"configValidator")}async disableValidator(){return await this.configValidator({enable:!1})}async enableValidator(){return await this.configValidator({enable:!0})}async change1x1({hopper:e=null}={hopper:null}){n(this,t,_).call(this,e),this.__hoppers__.current=e;const r=n(this,t,s).call(this,[10,224,e]);return await this.appendToQueue(r,"change1x1Hopper-"+e)}async sendCustomCode({code:e=[]}={code:[]}){if(!Array.isArray(e)||!e.every(i=>typeof i=="number"&&i>=0&&i<=255))throw new TypeError("Code must be an array of numbers between 0 and 255");const r=n(this,t,s).call(this,e);await this.appendToQueue(r,"custom")}}t=new WeakSet,H=function(){const e=["levels","hopper:updated","dispense-change","balance:updated","validator:status","change:1x1"];for(const r of e)this.serialRegisterAvailableListener(r)},u=function(e){e.error=!0,e.ascii.includes("ffffff")?(e.name="SINTAX",e.description="Error de Sintaxis",e.no_code=400):e.ascii.includes("ffaaaa")?(e.name="LOWLEVEL",e.description="Bajo nivel de monedas en Hopper (99)",e.no_code=401):e.ascii.includes("ffbbbb")?(e.name="TIMEOUT_DISPENSE",e.description="Error de dispensado, timeout",e.no_code=402):(e.name="UNKNOWN_ERROR",e.description="Unknown error occurred",e.no_code=999),this.dispatch("serial:message",e)},f=function(e){if(this.lastAction==="status")e.name="STATUS",e.description="Hoppers status",e.no_code=1,this.__hoppers__.levels[0].amount=n(this,t,c).call(this,e.code[9],e.code[10]),this.__hoppers__.levels[1].amount=n(this,t,c).call(this,e.code[7],e.code[8]),this.__hoppers__.levels[2].amount=n(this,t,c).call(this,e.code[5],e.code[6]),this.__hoppers__.levels[3].amount=n(this,t,c).call(this,e.code[3],e.code[4]),e.data=this.__hoppers__.levels,this.dispatch("levels",e.data);else if(this.lastAction==="readHopper"){e.name="READ_HOPPER",e.description=`Hopper ${this.__hoppers__.current} level`,e.no_code=2;const r=this.__hoppers__.current-1;this.__hoppers__.levels[r].amount=n(this,t,c).call(this,e.code[9],e.code[10]),e.data=this.__hoppers__.levels,e.hopperId=this.__hoppers__.current,this.dispatch("hopper:updated",this.__hoppers__.levels[r])}else this.lastAction==="writeHopper"?(e.name="WRITE_HOPPER",e.description="Hopper "+this.__hoppers__.current+" write",e.no_code=3,this.__hoppers__.levels[this.__hoppers__.current-1].amount=n(this,t,c).call(this,e.code[9],e.code[10]),e.data=this.__hoppers__.levels,e.hopperId=this.__hoppers__.current,this.dispatch("hopper:updated",this.__hoppers__.levels[this.__hoppers__.current=-1])):this.lastAction==="dispenseHopper"?(e.name="DISPENSEHOPPER",e.description="Hopper "+this.__hoppers__.current+" dispense",e.no_code=4,this.__hoppers__.levels[this.__hoppers__.current-1].amount=n(this,t,c).call(this,e.code[9],e.code[10]),e.data=this.__hoppers__.levels,e.hopperId=this.__hoppers__.current,this.dispatch("hopper:updated",this.__hoppers__.levels[this.__hoppers__.current=-1])):this.lastAction==="dispenseChange"?(e.name="DISPENSE_CHANGE",e.description="Change dispensed",e.no_code=5,e.data=n(this,t,c).call(this,e.code[9],e.code[10]),this.dispatch("dispense-change",{amount:e.data})):this.lastAction==="readBalance"?(e.name="READ_BALANCE",e.description="Read Balance",e.no_code=6,this.__hoppers__.balance=n(this,t,c).call(this,e.code[9],e.code[10]),e.data=this.__hoppers__.balance,this.dispatch("balance:updated",{balance:e.data})):this.lastAction==="clearBalance"?(e.name="CLEAR_BALANCE",e.description="Clared hoppers balance",e.no_code=7,this.__hoppers__.balance=n(this,t,c).call(this,e.code[9],e.code[10]),e.data=this.__hoppers__.balance,this.dispatch("balance:updated",{balance:e.data})):this.lastAction==="configValidator"?(e.code[2]===1?(e.name="ENABLE_VALIDATOR",e.description="Validator enabled",e.no_code=8,this.dispatch("validator:status",{enabled:!0})):(e.name="DISABLE_VALIDATOR",e.description="Validator disabled",e.no_code=9,this.dispatch("validator:status",{enabled:!1})),e.no_code=400,e.data=e.code[2]===1?"enabled":"disabled"):this.lastAction.includes("change1x1Hopper")&&(e.code[2]===1?(e.name="CHANGE_1X1_HOPPER_1",e.description="Change 1x1 Hopper 1",e.no_code=10):e.code[2]===2?(e.name="CHANGE_1X1_HOPPER_2",e.description="Change 1x1 Hopper 2",e.no_code=11):e.code[2]===3?(e.name="CHANGE_1X1_HOPPER_3",e.description="Change 1x1 Hopper 3",e.no_code=12):e.code[2]===4?(e.name="CHANGE_1X1_HOPPER_4",e.description="Change 1x1 Hopper 4",e.no_code=13):(e.name="CHANGE_1X1_HOPPER_UNKNOWN",e.description="Change 1x1 Hopper Unknown",e.no_code=14),this.dispatch("change:1x1",{hopperId:e.code[2]}));this.dispatch("serial:message",e)},c=function(e,r){return(e<<8|r)<<16>>16},_=function(e){if(typeof e!="number"||e<1||e>4)throw new RangeError("Hopper ID must be a number between 1 and 4");if(typeof e!="number"||!Number.isInteger(e))throw new TypeError("Hopper ID must be an integer")},b=function(e){if(typeof e!="number"||e<-32768||e>32767)throw new RangeError("Quantity must be a number between -32768 and 32767");if(typeof e!="number"||!Number.isInteger(e))throw new TypeError("Quantity must be an integer")},A=function(e){n(this,t,b).call(this,e);const r=e&65535,i=r>>8&255,o=r&255;return[i,o]},v=function({array:e,chunkSize:r=13}={}){if(!Array.isArray(e))throw new TypeError("Expected an array");if(typeof r!="number"||r<=0)throw new RangeError("Chunk size must be a positive number");const i=[];for(let o=0;o<e.length;o+=r)i.push(e.slice(o,o+r));return i},s=function(e){e.length<11&&(e=[...e,...Array(11-e.length).fill(0)]);const i=e.slice(1,11).reduce((o,h)=>{if(typeof h!="number")throw new TypeError("Array must contain only numbers");return o+h},0)&255;return e[11]=i,e[12]=15,e};exports.Hopper=I;
1
+ "use strict";var R=Object.defineProperty;var w=p=>{throw TypeError(p)};var N=(p,a,e)=>a in p?R(p,a,{enumerable:!0,configurable:!0,writable:!0,value:e}):p[a]=e;var x=(p,a,e)=>N(p,typeof a!="symbol"?a+"":a,e),P=(p,a,e)=>a.has(p)||w("Cannot "+e);var E=(p,a,e)=>a.has(p)?w("Cannot add the same private member more than once"):a instanceof WeakSet?a.add(p):a.set(p,e);var n=(p,a,e)=>(P(p,a,"access private method"),e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("./webserial-core-DlH0cFSH.cjs");var t,H,u,f,c,h,b,A,v,s;class I extends d.K{constructor({filters:e=null,config_port:r={baudRate:115200,dataBits:8,stopBits:1,parity:"none",bufferSize:32768,flowControl:"none"},no_device:i=1}={filters:null,config_port:{baudRate:115200,dataBits:8,stopBits:1,parity:"none",bufferSize:32768,flowControl:"none"},no_device:1}){super({filters:e,config_port:r,no_device:i});E(this,t);x(this,"__hoppers__",{levels:[{id:1,currency:10,key:"Hopper 1",name:"10 Pesos",amount:0,capacity:1e3},{id:2,currency:5,key:"Hopper 2",name:"5 Pesos",amount:0,capacity:1e3},{id:3,currency:2,key:"Hopper 3",name:"2 Pesos",amount:0,capacity:1e3},{id:4,currency:1,key:"Hopper 4",name:"1 Peso",amount:0,capacity:1e3}],balance:0,current:null});if(this.__internal__.device.type="hopper",d.h.getCustom(this.typeDevice,i))throw new Error(`Device ${this.typeDevice} ${i} already exists`);this.__internal__.time.response_connection=7e3,this.__internal__.time.response_general=7e3,this.__internal__.serial.delay_first_connection=500,this.__internal__.serial.response.replacer="",this.__internal__.serial.response.limiter=`\r
2
+ `,d.h.add(this),n(this,t,H).call(this)}get balance(){return this.__hoppers__.balance}get currentHopper(){return this.__hoppers__.current}get levels(){return this.__hoppers__.levels}setMaxCapacity({hopper:e=null,capacity:r=1e3}={hopper:null,capacity:1e3}){return n(this,t,h).call(this,e),this.__hoppers__.levels[e-1].capacity=r,this}setHopperName({hopper:e=null,name:r=""}={hopper:null,name:""}){if(n(this,t,h).call(this,e),typeof r!="string"||r.length===0)throw new TypeError("Name must be a non-empty string");return this.__hoppers__.levels[e-1].name=r,this}setHopperKey({hopper:e=null,key:r=""}={hopper:null,key:""}){if(n(this,t,h).call(this,e),typeof r!="string"||r.length===0)throw new TypeError("Key must be a non-empty string");return this.__hoppers__.levels[e-1].key=r,this}setHopperCurrency({hopper:e=null,currency:r=1}={hopper:null,currency:1}){if(n(this,t,h).call(this,e),typeof r!="number"||r<=0)throw new RangeError("Currency must be a positive number");return this.__hoppers__.levels[e-1].currency=r,this}serialMessage(e){const r=this.parseUint8ArrayToString(e),o={ascii:this.asciiToHex(r),code:e,name:"",description:"",request:this.lastAction,no_code:0,error:!1,data:null};if(e.length===3){n(this,t,u).call(this,o);return}if(e.length!==13){const _=n(this,t,v).call(this,{array:e,chunkSize:13});for(const l of _){const y=this.parseUint8ArrayToString(new Uint8Array(l)),T=this.asciiToHex(y),C=this.stringToArrayHex(y);o.code=l,o.hex=C,o.ascii=T,l.length!==13?n(this,t,u).call(this,o):n(this,t,f).call(this,o)}return}n(this,t,f).call(this,o)}serialSetConnectionConstant(){return[10,0,0,0,0,0,0,0,0,0,0,0,15]}async sendConnect(){const e=n(this,t,s).call(this,[10]);return await this.appendToQueue(e,"connect")}async requestStatus(){const e=n(this,t,s).call(this,[10,10,11,12]);return await this.appendToQueue(e,"status")}async readBalance(){const e=n(this,t,s).call(this,[10,192,1]);return await this.appendToQueue(e,"readBalance")}async clearBalance(){const e=n(this,t,s).call(this,[10,192,2]);return await this.appendToQueue(e,"clearBalance")}async forceInvalid(){const e="0A000F00".match(/.{1,2}/g);return await this.appendToQueue(e,"ForceInvalid")}async readHopper({hopper:e=null}={hopper:null}){n(this,t,h).call(this,e),this.__hoppers__.current=e;const r=n(this,t,s).call(this,[10,e,e]);return await this.appendToQueue(r,"readHopper")}async writeHopper({hopper:e=null,quantity:r=0}={hopper:null,quantity:0}){n(this,t,h).call(this,e),n(this,t,b).call(this,r),this.__hoppers__.current=e;const[i,o]=n(this,t,A).call(this,r),_=n(this,t,s).call(this,[10,240,e,0,0,0,0,0,0,i,o]);return await this.appendToQueue(_,"writeHopper")}async dispenseHopper({hopper:e=null}={hopper:null}){n(this,t,h).call(this,e),this.__hoppers__.current=e;const r=n(this,t,s).call(this,[10,2,e]);return await this.appendToQueue(r,"dispenseHopper")}async dispenseChange({change:e=0}={change:0}){if(typeof e!="number"||e<0||e>32767)throw new RangeError("Change must be a number between 0 and 32767");if(typeof e!="number"||!Number.isInteger(e))throw new TypeError("Change must be an integer");const r=e&255,i=e>>8&255,o=n(this,t,s).call(this,[10,204,170,0,0,0,0,0,0,i,r]);return await this.appendToQueue(o,"dispenseChange")}async configValidator({enable:e=!1}={enable:!1}){if(typeof e!="boolean")throw new TypeError("Enable must be a boolean");const r=n(this,t,s).call(this,[10,176,e?1:0]);return await this.appendToQueue(r,"configValidator")}async disableValidator(){return await this.configValidator({enable:!1})}async enableValidator(){return await this.configValidator({enable:!0})}async change1x1({hopper:e=null}={hopper:null}){n(this,t,h).call(this,e),this.__hoppers__.current=e;const r=n(this,t,s).call(this,[10,224,e]);return await this.appendToQueue(r,"change1x1Hopper-"+e)}async sendCustomCode({code:e=[]}={code:[]}){if(!Array.isArray(e)||!e.every(i=>typeof i=="number"&&i>=0&&i<=255))throw new TypeError("Code must be an array of numbers between 0 and 255");const r=n(this,t,s).call(this,e);await this.appendToQueue(r,"custom")}}t=new WeakSet,H=function(){const e=["levels","hopper:updated","dispense-change","balance:updated","validator:status","change:1x1"];for(const r of e)this.serialRegisterAvailableListener(r)},u=function(e){e.error=!0,e.ascii.includes("ffffff")?(e.name="SINTAX",e.description="Error de Sintaxis",e.no_code=400):e.ascii.includes("ffaaaa")?(e.name="LOWLEVEL",e.description="Bajo nivel de monedas en Hopper (99)",e.no_code=401):e.ascii.includes("ffbbbb")?(e.name="TIMEOUT_DISPENSE",e.description="Error de dispensado, timeout",e.no_code=402):(e.name="UNKNOWN_ERROR",e.description="Unknown error occurred",e.no_code=999),this.dispatch("serial:message",e)},f=function(e){if(this.lastAction==="status")e.name="STATUS",e.description="Hoppers status",e.no_code=1,this.__hoppers__.levels[0].amount=n(this,t,c).call(this,e.code[9],e.code[10]),this.__hoppers__.levels[1].amount=n(this,t,c).call(this,e.code[7],e.code[8]),this.__hoppers__.levels[2].amount=n(this,t,c).call(this,e.code[5],e.code[6]),this.__hoppers__.levels[3].amount=n(this,t,c).call(this,e.code[3],e.code[4]),e.data=this.__hoppers__.levels,this.dispatch("levels",e.data);else if(this.lastAction==="readHopper"){e.name="READ_HOPPER",e.description=`Hopper ${this.__hoppers__.current} level`,e.no_code=2;const r=this.__hoppers__.current-1;this.__hoppers__.levels[r].amount=n(this,t,c).call(this,e.code[9],e.code[10]),e.data=this.__hoppers__.levels,e.hopperId=this.__hoppers__.current,this.dispatch("hopper:updated",this.__hoppers__.levels[r])}else this.lastAction==="writeHopper"?(e.name="WRITE_HOPPER",e.description="Hopper "+this.__hoppers__.current+" write",e.no_code=3,this.__hoppers__.levels[this.__hoppers__.current-1].amount=n(this,t,c).call(this,e.code[9],e.code[10]),e.data=this.__hoppers__.levels,e.hopperId=this.__hoppers__.current,this.dispatch("hopper:updated",this.__hoppers__.levels[this.__hoppers__.current=-1])):this.lastAction==="dispenseHopper"?(e.name="DISPENSEHOPPER",e.description="Hopper "+this.__hoppers__.current+" dispense",e.no_code=4,this.__hoppers__.levels[this.__hoppers__.current-1].amount=n(this,t,c).call(this,e.code[9],e.code[10]),e.data=this.__hoppers__.levels,e.hopperId=this.__hoppers__.current,this.dispatch("hopper:updated",this.__hoppers__.levels[this.__hoppers__.current=-1])):this.lastAction==="dispenseChange"?(e.name="DISPENSE_CHANGE",e.description="Change dispensed",e.no_code=5,e.data=n(this,t,c).call(this,e.code[9],e.code[10]),this.dispatch("dispense-change",{amount:e.data})):this.lastAction==="readBalance"?(e.name="READ_BALANCE",e.description="Read Balance",e.no_code=6,this.__hoppers__.balance=n(this,t,c).call(this,e.code[9],e.code[10]),e.data=this.__hoppers__.balance,this.dispatch("balance:updated",{balance:e.data})):this.lastAction==="clearBalance"?(e.name="CLEAR_BALANCE",e.description="Clared hoppers balance",e.no_code=7,this.__hoppers__.balance=n(this,t,c).call(this,e.code[9],e.code[10]),e.data=this.__hoppers__.balance,this.dispatch("balance:updated",{balance:e.data})):this.lastAction==="configValidator"?(e.code[2]===1?(e.name="ENABLE_VALIDATOR",e.description="Validator enabled",e.no_code=8,this.dispatch("validator:status",{enabled:!0})):(e.name="DISABLE_VALIDATOR",e.description="Validator disabled",e.no_code=9,this.dispatch("validator:status",{enabled:!1})),e.no_code=400,e.data=e.code[2]===1?"enabled":"disabled"):this.lastAction.includes("change1x1Hopper")&&(e.code[2]===1?(e.name="CHANGE_1X1_HOPPER_1",e.description="Change 1x1 Hopper 1",e.no_code=10):e.code[2]===2?(e.name="CHANGE_1X1_HOPPER_2",e.description="Change 1x1 Hopper 2",e.no_code=11):e.code[2]===3?(e.name="CHANGE_1X1_HOPPER_3",e.description="Change 1x1 Hopper 3",e.no_code=12):e.code[2]===4?(e.name="CHANGE_1X1_HOPPER_4",e.description="Change 1x1 Hopper 4",e.no_code=13):(e.name="CHANGE_1X1_HOPPER_UNKNOWN",e.description="Change 1x1 Hopper Unknown",e.no_code=14),this.dispatch("change:1x1",{hopperId:e.code[2]}));this.dispatch("serial:message",e)},c=function(e,r){return(e<<8|r)<<16>>16},h=function(e){if(typeof e!="number"||e<1||e>4)throw new RangeError("Hopper ID must be a number between 1 and 4");if(typeof e!="number"||!Number.isInteger(e))throw new TypeError("Hopper ID must be an integer")},b=function(e){if(typeof e!="number"||e<-32768||e>32767)throw new RangeError("Quantity must be a number between -32768 and 32767");if(typeof e!="number"||!Number.isInteger(e))throw new TypeError("Quantity must be an integer")},A=function(e){n(this,t,b).call(this,e);const r=e&65535,i=r>>8&255,o=r&255;return[i,o]},v=function({array:e,chunkSize:r=13}={}){if(!Array.isArray(e))throw new TypeError("Expected an array");if(typeof r!="number"||r<=0)throw new RangeError("Chunk size must be a positive number");const i=[];for(let o=0;o<e.length;o+=r)i.push(e.slice(o,o+r));return i},s=function(e){e.length<11&&(e=[...e,...Array(11-e.length).fill(0)]);const i=e.slice(1,11).reduce((o,_)=>{if(typeof _!="number")throw new TypeError("Array must contain only numbers");return o+_},0)&255;return e[11]=i,e[12]=15,e};exports.Hopper=I;
package/dist/hopper.js CHANGED
@@ -1,13 +1,13 @@
1
- var N = Object.defineProperty;
2
- var w = (p) => {
1
+ var R = Object.defineProperty;
2
+ var y = (p) => {
3
3
  throw TypeError(p);
4
4
  };
5
- var R = (p, a, e) => a in p ? N(p, a, { enumerable: !0, configurable: !0, writable: !0, value: e }) : p[a] = e;
6
- var x = (p, a, e) => R(p, typeof a != "symbol" ? a + "" : a, e), P = (p, a, e) => a.has(p) || w("Cannot " + e);
7
- var E = (p, a, e) => a.has(p) ? w("Cannot add the same private member more than once") : a instanceof WeakSet ? a.add(p) : a.set(p, e);
5
+ var N = (p, a, e) => a in p ? R(p, a, { enumerable: !0, configurable: !0, writable: !0, value: e }) : p[a] = e;
6
+ var w = (p, a, e) => N(p, typeof a != "symbol" ? a + "" : a, e), P = (p, a, e) => a.has(p) || y("Cannot " + e);
7
+ var x = (p, a, e) => a.has(p) ? y("Cannot add the same private member more than once") : a instanceof WeakSet ? a.add(p) : a.set(p, e);
8
8
  var n = (p, a, e) => (P(p, a, "access private method"), e);
9
- import { K as I, h as d } from "./webserial-core-DGKQCs5a.js";
10
- var t, H, u, f, c, _, b, A, v, s;
9
+ import { K as I, h as E } from "./webserial-core-DGKQCs5a.js";
10
+ var t, H, d, u, c, h, f, A, v, s;
11
11
  class O extends I {
12
12
  constructor({
13
13
  filters: e = null,
@@ -33,8 +33,8 @@ class O extends I {
33
33
  no_device: 1
34
34
  }) {
35
35
  super({ filters: e, config_port: r, no_device: i });
36
- E(this, t);
37
- x(this, "__hoppers__", {
36
+ x(this, t);
37
+ w(this, "__hoppers__", {
38
38
  levels: [
39
39
  { id: 1, currency: 10, key: "Hopper 1", name: "10 Pesos", amount: 0, capacity: 1e3 },
40
40
  { id: 2, currency: 5, key: "Hopper 2", name: "5 Pesos", amount: 0, capacity: 1e3 },
@@ -44,10 +44,10 @@ class O extends I {
44
44
  balance: 0,
45
45
  current: null
46
46
  });
47
- if (this.__internal__.device.type = "hopper", d.registerType(this.__internal__.device.type), d.getByNumber(this.typeDevice, i))
47
+ if (this.__internal__.device.type = "hopper", E.getCustom(this.typeDevice, i))
48
48
  throw new Error(`Device ${this.typeDevice} ${i} already exists`);
49
49
  this.__internal__.time.response_connection = 7e3, this.__internal__.time.response_general = 7e3, this.__internal__.serial.delay_first_connection = 500, this.__internal__.serial.response.replacer = "", this.__internal__.serial.response.limiter = `\r
50
- `, d.add(this), n(this, t, H).call(this);
50
+ `, E.add(this), n(this, t, H).call(this);
51
51
  }
52
52
  get balance() {
53
53
  return this.__hoppers__.balance;
@@ -59,20 +59,20 @@ class O extends I {
59
59
  return this.__hoppers__.levels;
60
60
  }
61
61
  setMaxCapacity({ hopper: e = null, capacity: r = 1e3 } = { hopper: null, capacity: 1e3 }) {
62
- return n(this, t, _).call(this, e), this.__hoppers__.levels[e - 1].capacity = r, this;
62
+ return n(this, t, h).call(this, e), this.__hoppers__.levels[e - 1].capacity = r, this;
63
63
  }
64
64
  setHopperName({ hopper: e = null, name: r = "" } = { hopper: null, name: "" }) {
65
- if (n(this, t, _).call(this, e), typeof r != "string" || r.length === 0)
65
+ if (n(this, t, h).call(this, e), typeof r != "string" || r.length === 0)
66
66
  throw new TypeError("Name must be a non-empty string");
67
67
  return this.__hoppers__.levels[e - 1].name = r, this;
68
68
  }
69
69
  setHopperKey({ hopper: e = null, key: r = "" } = { hopper: null, key: "" }) {
70
- if (n(this, t, _).call(this, e), typeof r != "string" || r.length === 0)
70
+ if (n(this, t, h).call(this, e), typeof r != "string" || r.length === 0)
71
71
  throw new TypeError("Key must be a non-empty string");
72
72
  return this.__hoppers__.levels[e - 1].key = r, this;
73
73
  }
74
74
  setHopperCurrency({ hopper: e = null, currency: r = 1 } = { hopper: null, currency: 1 }) {
75
- if (n(this, t, _).call(this, e), typeof r != "number" || r <= 0)
75
+ if (n(this, t, h).call(this, e), typeof r != "number" || r <= 0)
76
76
  throw new RangeError("Currency must be a positive number");
77
77
  return this.__hoppers__.levels[e - 1].currency = r, this;
78
78
  }
@@ -89,18 +89,18 @@ class O extends I {
89
89
  data: null
90
90
  };
91
91
  if (e.length === 3) {
92
- n(this, t, u).call(this, o);
92
+ n(this, t, d).call(this, o);
93
93
  return;
94
94
  }
95
95
  if (e.length !== 13) {
96
- const h = n(this, t, v).call(this, { array: e, chunkSize: 13 });
97
- for (const l of h) {
98
- const y = this.parseUint8ArrayToString(new Uint8Array(l)), T = this.asciiToHex(y), C = this.stringToArrayHex(y);
99
- o.code = l, o.hex = C, o.ascii = T, l.length !== 13 ? n(this, t, u).call(this, o) : n(this, t, f).call(this, o);
96
+ const _ = n(this, t, v).call(this, { array: e, chunkSize: 13 });
97
+ for (const l of _) {
98
+ const b = this.parseUint8ArrayToString(new Uint8Array(l)), T = this.asciiToHex(b), C = this.stringToArrayHex(b);
99
+ o.code = l, o.hex = C, o.ascii = T, l.length !== 13 ? n(this, t, d).call(this, o) : n(this, t, u).call(this, o);
100
100
  }
101
101
  return;
102
102
  }
103
- n(this, t, f).call(this, o);
103
+ n(this, t, u).call(this, o);
104
104
  }
105
105
  serialSetConnectionConstant() {
106
106
  return [10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 15];
@@ -126,17 +126,17 @@ class O extends I {
126
126
  return await this.appendToQueue(e, "ForceInvalid");
127
127
  }
128
128
  async readHopper({ hopper: e = null } = { hopper: null }) {
129
- n(this, t, _).call(this, e), this.__hoppers__.current = e;
129
+ n(this, t, h).call(this, e), this.__hoppers__.current = e;
130
130
  const r = n(this, t, s).call(this, [10, e, e]);
131
131
  return await this.appendToQueue(r, "readHopper");
132
132
  }
133
133
  async writeHopper({ hopper: e = null, quantity: r = 0 } = { hopper: null, quantity: 0 }) {
134
- n(this, t, _).call(this, e), n(this, t, b).call(this, r), this.__hoppers__.current = e;
135
- const [i, o] = n(this, t, A).call(this, r), h = n(this, t, s).call(this, [10, 240, e, 0, 0, 0, 0, 0, 0, i, o]);
136
- return await this.appendToQueue(h, "writeHopper");
134
+ n(this, t, h).call(this, e), n(this, t, f).call(this, r), this.__hoppers__.current = e;
135
+ const [i, o] = n(this, t, A).call(this, r), _ = n(this, t, s).call(this, [10, 240, e, 0, 0, 0, 0, 0, 0, i, o]);
136
+ return await this.appendToQueue(_, "writeHopper");
137
137
  }
138
138
  async dispenseHopper({ hopper: e = null } = { hopper: null }) {
139
- n(this, t, _).call(this, e), this.__hoppers__.current = e;
139
+ n(this, t, h).call(this, e), this.__hoppers__.current = e;
140
140
  const r = n(this, t, s).call(this, [10, 2, e]);
141
141
  return await this.appendToQueue(r, "dispenseHopper");
142
142
  }
@@ -161,7 +161,7 @@ class O extends I {
161
161
  return await this.configValidator({ enable: !0 });
162
162
  }
163
163
  async change1x1({ hopper: e = null } = { hopper: null }) {
164
- n(this, t, _).call(this, e), this.__hoppers__.current = e;
164
+ n(this, t, h).call(this, e), this.__hoppers__.current = e;
165
165
  const r = n(this, t, s).call(this, [10, 224, e]);
166
166
  return await this.appendToQueue(r, "change1x1Hopper-" + e);
167
167
  }
@@ -176,9 +176,9 @@ t = new WeakSet(), H = function() {
176
176
  const e = ["levels", "hopper:updated", "dispense-change", "balance:updated", "validator:status", "change:1x1"];
177
177
  for (const r of e)
178
178
  this.serialRegisterAvailableListener(r);
179
- }, u = function(e) {
179
+ }, d = function(e) {
180
180
  e.error = !0, e.ascii.includes("ffffff") ? (e.name = "SINTAX", e.description = "Error de Sintaxis", e.no_code = 400) : e.ascii.includes("ffaaaa") ? (e.name = "LOWLEVEL", e.description = "Bajo nivel de monedas en Hopper (99)", e.no_code = 401) : e.ascii.includes("ffbbbb") ? (e.name = "TIMEOUT_DISPENSE", e.description = "Error de dispensado, timeout", e.no_code = 402) : (e.name = "UNKNOWN_ERROR", e.description = "Unknown error occurred", e.no_code = 999), this.dispatch("serial:message", e);
181
- }, f = function(e) {
181
+ }, u = function(e) {
182
182
  if (this.lastAction === "status")
183
183
  e.name = "STATUS", e.description = "Hoppers status", e.no_code = 1, this.__hoppers__.levels[0].amount = n(this, t, c).call(this, e.code[9], e.code[10]), this.__hoppers__.levels[1].amount = n(this, t, c).call(this, e.code[7], e.code[8]), this.__hoppers__.levels[2].amount = n(this, t, c).call(this, e.code[5], e.code[6]), this.__hoppers__.levels[3].amount = n(this, t, c).call(this, e.code[3], e.code[4]), e.data = this.__hoppers__.levels, this.dispatch("levels", e.data);
184
184
  else if (this.lastAction === "readHopper") {
@@ -189,18 +189,18 @@ t = new WeakSet(), H = function() {
189
189
  this.dispatch("serial:message", e);
190
190
  }, c = function(e, r) {
191
191
  return (e << 8 | r) << 16 >> 16;
192
- }, _ = function(e) {
192
+ }, h = function(e) {
193
193
  if (typeof e != "number" || e < 1 || e > 4)
194
194
  throw new RangeError("Hopper ID must be a number between 1 and 4");
195
195
  if (typeof e != "number" || !Number.isInteger(e))
196
196
  throw new TypeError("Hopper ID must be an integer");
197
- }, b = function(e) {
197
+ }, f = function(e) {
198
198
  if (typeof e != "number" || e < -32768 || e > 32767)
199
199
  throw new RangeError("Quantity must be a number between -32768 and 32767");
200
200
  if (typeof e != "number" || !Number.isInteger(e))
201
201
  throw new TypeError("Quantity must be an integer");
202
202
  }, A = function(e) {
203
- n(this, t, b).call(this, e);
203
+ n(this, t, f).call(this, e);
204
204
  const r = e & 65535, i = r >> 8 & 255, o = r & 255;
205
205
  return [i, o];
206
206
  }, v = function({ array: e, chunkSize: r = 13 } = {}) {
@@ -214,10 +214,10 @@ t = new WeakSet(), H = function() {
214
214
  return i;
215
215
  }, s = function(e) {
216
216
  e.length < 11 && (e = [...e, ...Array(11 - e.length).fill(0)]);
217
- const i = e.slice(1, 11).reduce((o, h) => {
218
- if (typeof h != "number")
217
+ const i = e.slice(1, 11).reduce((o, _) => {
218
+ if (typeof _ != "number")
219
219
  throw new TypeError("Array must contain only numbers");
220
- return o + h;
220
+ return o + _;
221
221
  }, 0) & 255;
222
222
  return e[11] = i, e[12] = 15, e;
223
223
  };
package/dist/jofemar.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var le=Object.defineProperty;var O=p=>{throw TypeError(p)};var se=(p,h,t)=>h in p?le(p,h,{enumerable:!0,configurable:!0,writable:!0,value:t}):p[h]=t;var M=(p,h,t)=>se(p,typeof h!="symbol"?h+"":h,t),de=(p,h,t)=>h.has(p)||O("Cannot "+t);var I=(p,h,t)=>h.has(p)?O("Cannot add the same private member more than once"):h instanceof WeakSet?h.add(p):h.set(p,t);var i=(p,h,t)=>(de(p,h,"access private method"),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const v=require("./kernel-BTqvt4pt.cjs"),a=require("./relay-BsUsBpOv.cjs"),S=require("./webserial-core-DlH0cFSH.cjs");var n,P,Q,g,A,B,W,F,q,R,$,j,N,L,V,J,U,K,H,z,G,Y,Z,X,ee,te,ne,ie,re,u,s,b,d,_,ae,oe,ce,T,E,D;class pe extends v.Kernel{constructor({filters:t=null,config_port:e=null,no_device:r=1,device_listen_on_port:o=1,type:c="esplus",support_cart:l=!0}={}){super({filters:t,config_port:e,no_device:r,device_listen_on_port:o});I(this,n);M(this,"__device",{type:"esplus",support_cart:!1,withdraw:{in_process:!1,seconds:60,interval:0},cart:{in_process:!1},channels:{verification:{clear(){this.running=!1,this.current=1,this.channels=[]},running:!1,start:1,end:80,current:1,channels:[]}}});if(this.__internal__.device.type="jofemar",S.h.getCustom(this.typeDevice,r))throw new Error(`Device ${this.typeDevice} ${r} already exists`);this.__internal__.dispense.must_response=!0,this.__internal__.time.response_general=800,this.__internal__.time.response_engines=800,this.__internal__.dispense.limit_counter=40,this.__internal__.dispense.timeout=0,this.__internal__.dispense.timeout_time=4e3,this.__internal__.dispense.interval=0,this.__internal__.dispense.interval_time=1e3,this.__internal__.device.hex_number=(128+this.listenOnChannel).toString(16),this.__internal__.device.door_open=!1,this.__internal__.dispense.elevator={locking_time:60,locking_interval:0,need_reset:!1},this.deviceType=c,this.supportCart=l,i(this,n,P).call(this),S.h.add(this),i(this,n,Q).call(this)}set startChannelVerification(t){const e=parseInt(t);if(isNaN(e))throw new Error("Invalid start channel verification, must be a number");if(e<1||e>126)throw new Error("Invalid start channel verification, valid range is 1 to 126");this.__device.channels.verification.start=e}set endChannelVerification(t){const e=parseInt(t);if(isNaN(e))throw new Error("Invalid end channel verification, must be a number");if(e<1||e>126)throw new Error("Invalid end channel verification, valid range is 1 to 126");this.__device.channels.verification.end=e}set listenOnChannel(t){if(t=parseInt(t),isNaN(t)||t<1||t>31)throw new Error("Invalid port number, valid range is 1 to 31");this.__internal__.device.listen_on_port=t,this.__internal__.serial.bytes_connection=this.serialSetConnectionConstant(t),this.__internal__.device.hex_number=(128+t).toString(16)}set listenOnPort(t){this.listenOnChannel=t}set deviceType(t){if(typeof t!="string")throw new Error("Invalid device type, must be a string");this.__device.type=t}set supportCart(t){if(typeof t!="boolean")throw new Error("Invalid support cart, must be a boolean");this.__device.support_cart=t}serialSetConnectionConstant(t=1){return a.o.connection({channel:t})}serialMessage(t){let r={code:t,name:null,description:null,request:"unknown",no_code:0,additional:{machine:{hex:null,dec:null}}};switch(t[0]){case"02":r=i(this,n,re).call(this,t,r,128);break;case"06":r=i(this,n,ae).call(this,t,r);break;case"15":r.name="Checksum error",r.description="The calculated checksum does not match the received checksum",r.no_code=38,i(this,n,s).call(this);break;default:r.name="unknown",r.description="The message received is unknown",r.no_code=404;break}this.dispatch("serial:message",r)}productRemovedContinueDispensing(){this.__internal__.dispense.elevator.locking_interval&&(this.__internal__.dispense.elevator.locking_time=0)}async dispense({selection:t=1,cart:e=!1}={}){const r=a.o.dispense({selection:t,cart:e,machineChannel:this.listenOnChannel}),o=r[5],c=r[6];this.__internal__.dispense.backup_dispense={selection:t,cart:e,channel:c,tray:o};let l;do l=await this.internalDispense(r),i(this,n,oe).call(this),l.error==="elevator-locked"?await i(this,n,g).call(this):l.error==="no-response"&&await v.wait(1e3);while(["elevator-locked","no-response"].includes(l.error));return this.__internal__.dispense.backup_dispense={},l}internalClearSensing(){super.internalClearSensing(),this.__internal__.dispense.timeout&&clearTimeout(this.__internal__.dispense.timeout),this.__internal__.dispense.interval&&clearInterval(this.__internal__.dispense.interval),this.__internal__.serial.queue.length>0&&(this.__internal__.serial.queue=this.__internal__.serial.queue.filter(t=>t.type!=="status"))}async endDispense(){const t=a.o.endCartDispense({machineChannel:this.listenOnChannel});return await this.internalDispense(t)}async collect(){return await this.appendToQueue(a.o.collect({machineChannel:this.listenOnChannel}),"collect")}async resetSoldOutErrors(){return await i(this,n,T).call(this,"soldOut")}async resetWaitingProductRemovedError(){return await i(this,n,T).call(this,"waiting")}async resetMachineErrors(){return this.__internal__.serial.queue.length===0?(i(this,n,E).call(this),await i(this,n,T).call(this,"machine")):new Promise(t=>{const e=setInterval(async()=>{this.__internal__.serial.queue.length>0||(clearInterval(e),await i(this,n,T).call(this,"machine"),i(this,n,E).call(this),t(!0))},100)})}async resetAllErrors(){return await this.resetSoldOutErrors(),await v.wait(100),await this.resetWaitingProductRemovedError(),await v.wait(100),await this.resetMachineErrors()}async status(){return await this.appendToQueue(a.o.status({machineChannel:this.listenOnChannel}),"status")}async lightsOn(){return await i(this,n,D).call(this,"on")}async lightsOff(){return await i(this,n,D).call(this,"off")}async program(t,e){return await this.appendToQueue(a.o.program({machineChannel:this.listenOnChannel,param1:t,param2:e}),"program")}async programDisplayLanguage({language:t="spanish"}={}){return await this.appendToQueue(a.o.programDisplayLanguage({machineChannel:this.listenOnChannel,language:t}),"program")}async programBeeper({enable:t=!0}={}){return await this.appendToQueue(a.o.programBeeper({machineChannel:this.listenOnChannel,enable:t}),"program")}async programDisableWorkingTemperature(){if(this.__device.type==="iceplus")throw new Error("IcePlus does not support disable working temperature");return await this.appendToQueue(a.o.programDisableWorkingTemperature({machineChannel:this.listenOnChannel}),"program")}async programDisableThermometer(){return await this.appendToQueue(a.o.programDisableThermometer({machineChannel:this.listenOnChannel}),"program")}async programWorkingTemperature({degrees:t=.5}={}){return await this.appendToQueue(a.o.programWorkingTemperature({machineChannel:this.listenOnChannel,degrees:t,machineType:this.__device.type}),"program")}async programIsolationTray({tray:t=0}={}){return await this.appendToQueue(a.o.programIsolationTray({machineChannel:this.listenOnChannel,tray:t}),"program")}async programTimeToStandbyAfterCollect({seconds:t=15}={}){return await this.appendToQueue(a.o.programTimeToStandbyAfterCollect({machineChannel:this.listenOnChannel,seconds:t}),"program")}async programTimeToStandbyWithoutCollect({minutes:t=1}={}){return await this.appendToQueue(a.o.programTimeToStandbyWithoutCollect({machineChannel:this.listenOnChannel,minutes:t}),"program")}async programElevatorSpeed({speed:t="high"}={}){return await this.appendToQueue(a.o.programElevatorSpeed({machineChannel:this.listenOnChannel,speed:t}),"program")}async programTemperatureExpiration({enable:t=!1}={}){return await this.appendToQueue(a.o.programTemperatureExpiration({machineChannel:this.listenOnChannel,enable:t}),"program")}async programEnableTemperatureExpiration(){return await this.programTemperatureExpiration({enable:!0})}async programDisableTemperatureExpiration(){return await this.programTemperatureExpiration({enable:!1})}async programMachineAddress({address:t=1}={}){return await this.appendToQueue(a.o.programMachineAddress({machineChannel:this.listenOnChannel,address:t}),"program")}async programTemperatureBeforeExpiration({degrees:t=.5}={}){return await this.appendToQueue(a.o.programTemperatureBeforeExpiration({machineChannel:this.listenOnChannel,degrees:t}),"program")}async programTimeBeforeExpirationByTemperature({minutes:t=1}={}){return await this.appendToQueue(a.o.programTimeBeforeExpirationByTemperature({machineChannel:this.listenOnChannel,minutes:t}),"program")}async programTemperatureScale({scale:t="celsius"}={}){return await this.appendToQueue(a.o.programTemperatureScale({machineChannel:this.listenOnChannel,scale:t}),"program")}async programVoltageEngine({selection:t=1,voltage:e=5}={}){return await this.appendToQueue(a.o.programVoltageEngine({machineChannel:this.listenOnChannel,selection:t,voltage:e}),"voltage-engine")}async programPushOverProducts({selection:t=1,enable:e=!0}={}){return await this.appendToQueue(a.o.programPushOverProducts({machineChannel:this.listenOnChannel,selection:t,enable:e}),"push-over-products")}async programChannelRunningAfterDispense({selection:t=1,seconds:e=0}={}){return await this.appendToQueue(a.o.programChannelRunningAfterDispense({machineChannel:this.listenOnChannel,selection:t,seconds:e}),"channel-running-after-dispense")}async checkData(t,e="FF"){return await this.appendToQueue(a.o.checkData({machineChannel:this.listenOnChannel,type:t,aux:e}),"check-data")}async getDisplayLanguage(){return await this.appendToQueue(a.o.getDisplayLanguage({machineChannel:this.listenOnChannel}),"check-data")}async getBeeper(){return await this.appendToQueue(a.o.getBeeper({machineChannel:this.listenOnChannel}),"check-data")}async getWorkingTemperature(){return await this.appendToQueue(a.o.getWorkingTemperature({machineChannel:this.listenOnChannel}),"check-data")}async getIsolationTray(){return await this.appendToQueue(a.o.getIsolationTray({machineChannel:this.listenOnChannel}),"check-data")}async getProgramVersion(){return await this.appendToQueue(a.o.getProgramVersion({machineChannel:this.listenOnChannel}),"check-data")}async getFaults(){return await this.appendToQueue(a.o.getFaults({machineChannel:this.listenOnChannel}),"check-data")}async getMachineId(){return await this.appendToQueue(a.o.getMachineId({machineChannel:this.listenOnChannel}),"check-data")}async getCurrentTemperature(){return await this.appendToQueue(a.o.getCurrentTemperature({machineChannel:this.listenOnChannel}),"check-data")}async getTimeToStandbyAfterCollect(){return await this.appendToQueue(a.o.getTimeToStandbyAfterCollect({machineChannel:this.listenOnChannel}),"check-data")}async getTimeToStandbyWithoutCollect(){return await this.appendToQueue(a.o.getTimeToStandbyWithoutCollect({machineChannel:this.listenOnChannel}),"check-data")}async getElevatorSpeed(){return await this.appendToQueue(a.o.getElevatorSpeed({machineChannel:this.listenOnChannel}),"check-data")}async getTemperatureExpiration(){return await this.appendToQueue(a.o.getTemperatureExpiration({machineChannel:this.listenOnChannel}),"check-data")}async getTemperatureBeforeExpiration(){return await this.appendToQueue(a.o.getTemperatureBeforeExpiration({machineChannel:this.listenOnChannel}),"check-data")}async getTimeBeforeExpirationByTemperature(){return await this.appendToQueue(a.o.getTimeBeforeExpirationByTemperature({machineChannel:this.listenOnChannel}),"check-data")}async getTemperatureScale(){return await this.appendToQueue(a.o.getTemperatureScale({machineChannel:this.listenOnChannel}),"check-data")}async getClockRegisters(){return await this.appendToQueue(a.o.getClockRegisters({machineChannel:this.listenOnChannel}),"check-data")}async getMachineActivity(){return await this.appendToQueue(a.o.getMachineActivity({machineChannel:this.listenOnChannel}),"check-data")}async getVoltageEngine({selection:t=1}={}){return await this.appendToQueue(a.o.getVoltageEngine({machineChannel:this.listenOnChannel,selection:t}),"check-data")}async getChannelPresence({selection:t=1}={}){return await this.appendToQueue(a.o.getChannelPresence({machineChannel:this.listenOnChannel,selection:t}),"check-data")}async getPushOverProducts({selection:t=1}={}){return await this.appendToQueue(a.o.getPushOverProducts({machineChannel:this.listenOnChannel,selection:t}),"check-data")}async getChannelRunningAfterDispense({selection:t=1}={}){return await this.appendToQueue(a.o.getChannelRunningAfterDispense({machineChannel:this.listenOnChannel,selection:t}),"check-data")}async setDisplayStandbyMessage({message:t=""}={}){return await this.appendToQueue(a.o.setDisplayStandbyMessage({machineChannel:this.listenOnChannel,message:t}),"display")}async setDisplayMessageTemporarily({message:t="",seconds:e=1}){return this.appendToQueue(a.o.setDisplayMessageTemporarily({machineChannel:this.listenOnChannel,message:t,seconds:e}),"display")}async setDisplayMessageUnlimited({message:t=""}){return await this.appendToQueue(a.o.setDisplayMessageUnlimited({machineChannel:this.listenOnChannel,message:t}),"display")}async programClock({date:t=new Date}={}){return await this.appendToQueue(a.o.programClock({machineChannel:this.listenOnChannel,date:t}),"clock")}async eventsConfig({event:t=null,enable:e=!0}={}){return await this.appendToQueue(a.o.eventsConfig({machineChannel:this.listenOnChannel,event:t,enable:e}),"events-config")}async eventEnable({event:t=null}={}){return await this.appendToQueue(a.o.eventEnable({machineChannel:this.listenOnChannel,event:t}),"events-config")}async eventDisable({event:t=null}={}){return await this.appendToQueue(a.o.eventEnable({machineChannel:this.listenOnChannel,event:t}),"events-config")}async sendCustomCode({code:t=[]}={}){return await this.appendToQueue(a.o.sendCustomCode({machineChannel:this.listenOnChannel,code:t}),"custom")}async assignChannels(){const t=this.__device.channels.verification.start,e=this.__device.channels.verification.end;if(t>e)throw new Error("Invalid range, start must be less than end");this.__device.channels.verification.clear(),this.__device.channels.verification.running=!0;for(let r=t;r<=e;r++)this.__device.channels.verification.current=r,await this.getChannelPresence({selection:r});return new Promise(r=>{let o=setInterval(()=>{this.__device.channels.verification.channels.length===e-t+1&&(clearInterval(o),this.dispatch("channels",{channels:this.__device.channels.verification.channels}),this.__device.channels.verification.clear(),r(!0))},500)})}}n=new WeakSet,P=function(){const t=["dispensing:withdrawal","command-executed","keyboard:pressed","door:event","program:version","machine:faults","clock:registers","machine:activity","check:language","check:beeper","check:isolation-tray","check:engine-voltage","check:push-over","check:extractor-after-dispense","check:standby-after-collect","check:standby-without-collect","check:elevator-speed","check:expiration-by-temperature","check:temperature-before-expiration","check:expiration-after","check:temperature-scale","check:machine-id","temperature:working","temperature:current","jofemar:warning","jofemar:error","serial:message","reset:errors","channels","channel:status","machine:status"];for(const e of t)this.serialRegisterAvailableListener(e)},Q=function(){this.on("internal:dispense:running",i(this,n,ce).bind(this))},g=async function(){if(this.__internal__.dispense.elevator.locking_interval)return;this.__internal__.dispense.elevator.need_reset&&(this.__internal__.dispense.elevator.need_reset=!1,await this.resetWaitingProductRemovedError(),await v.wait(500));const t=this;return this.__internal__.dispense.status="elevator-locked",this.__internal__.dispense.elevator.locking_time=60,new Promise(e=>{t.__internal__.dispense.elevator.locking_interval=setInterval(()=>{t.dispatch("dispensing:withdrawal",{elevator:!0,seconds:t.__internal__.dispense.elevator.locking_time,description:"Please recall products from the elevator"}),t.__internal__.dispense.elevator.locking_time-=1,t.__internal__.dispense.elevator.locking_time<=0&&(clearInterval(t.__internal__.dispense.elevator.locking_interval),t.__internal__.dispense.elevator.locking_interval=0,e(!0))},1e3)})},A=function(t,e){return e.name="ok",e.description="The last command was executed successfully",e.no_code=1,this.dispatch("command-executed",e),e},B=function(t,e){e.additional={hex:t,dec:this.hexToDec(t),ascii:null};const r={30:"0",31:"1",32:"2",33:"3",34:"4",35:"5",36:"6",37:"7",38:"8",39:"9","2a":"*",23:"#",41:"A",42:"B",43:"C",44:"D"};return e.additional.ascii=r[t]??null,e.name="Key pressed",e.description=`The key ${e.additional.ascii} was pressed`,e.no_code=2,this.dispatch("keyboard:pressed",e.additional),e},W=function(t,e){return e.additional={open:!1},e.no_code=3,t==="4f"?(e.name="door open",e.description="The door was opened",e.additional.open=!0,this.__internal__.device.door_open=!0,this.dispatch("door:event",e.additional)):t==="43"?(e.name="door close",e.description="The door was closed",e.additional.open=!1,this.__internal__.device.door_open=!1,this.dispatch("door:event",e.additional)):(e.name="door event",e.description="The door event received is unknown",this.dispatch("door:event",{open:e.additional.open,message:e})),e},F=function(t,e){e.no_code=404;let r=t[5]??null;return r&&this.listenOnChannel>1&&(r=this.hexToDec(r)-this.listenOnChannel+1,r=this.decToHex(r)),r&&(r==="FD"?(e.no_code=4,e.name="channel disconnected",e.description="The channel is disconnected",e.additional={active:!1}):r==="FC"?(e.no_code=5,e.name="channel connected",e.description="The channel is connected",e.additional={active:!0}):(e.no_code=6,e.name="channel sold out",e.description="The channel is empty",e.additional={active:!0}),this.__device.channels.verification.running&&(this.__device.channels.verification.channels.push({selection:this.__device.channels.verification.current,active:e.additional.active}),e.additional.selection=this.__device.channels.verification.current),this.dispatch("channel:status",e.additional)),e},q=function(t,e){e.no_code=39,e.name="Program version";const r=t.slice(4,12),o=r.map(c=>String.fromCharCode(this.hexToDec(c))).join("");return e.additional={version:o,hex:r},e.description=`The program version is ${o}`,this.dispatch("program:version",e.additional),e},R=function(t,e){e.no_code=39,e.name="Machine faults",e.description="No faults detected",e.additional={no_faults:0,faults:[]};const r=t.slice(4,-3);if(r.length>1&&r[0]!=="30"){e.description="Machine has faults";const o={31:"Busy",32:"Invalid tray",33:"Invalid channel",34:"Empty channel",35:"Jam in elevator engine",36:"Malfunction in the elevator belt or product detector",37:"Failure in one of the photo transistors in the cabinet",38:"No channels detected",39:"Product detector fault",41:"Machine display is disconnected",42:"Product alarm under elevator",43:"Error when elevator approaching to a position",44:"Fault in keyboard",45:"Eeprom writing error",46:"Fault communicating with temperature control",47:"The thermometer is disconnected",48:"Thermometer programming lost",49:"Thermometer faulty","4a":"Channels power consumption detector faulty","4b":"Elevator does not find channel or tray","4c":"Elevator does not find delivery product position","4d":"Interior of elevator blocked","4e":"Error in tester of product detector","4f":"Waiting for product to be removed",50:"Product expired by temperature reasons",51:"Automatic door faulty",59:"Product is expired","5a":"Product is expired",61:"Product is expired",62:"Product is expired",63:"Product is expired",64:"Product detector didn't change during its verification test"};for(const c of r)o[c]&&(e.additional.faults.push(o[c]),e.additional.no_faults++)}return this.dispatch("machine:faults",e.additional),e},$=function(t,e){e.no_code=40,e.name="Clock registers",e.description="Clock registers";const r=t.slice(4,-3),o=r.map(x=>String.fromCharCode(this.hexToDec(x))).join(""),[c,l]=o.split(" "),[f,y]=c.split(":"),[C,k,m]=l.split("-"),w=new Date(2e3+parseInt(m),parseInt(k)-1,parseInt(C),parseInt(f),parseInt(y));return e.additional={day:C,month:k,year:m,hours:f,minutes:y,formatted:o,date:w,hex:r},this.dispatch("clock:registers",e.additional),e},j=function(t,e){e.no_code=41,e.name="Machine activity",e.description="Events from read machine activity";const r=String.fromCharCode(this.hexToDec(t[4]));if(r!=="0"){const o=t.slice(5,-3);if(r==="T"&&o.length===4){const c=String.fromCharCode(this.hexToDec(o[0])),l=String.fromCharCode(this.hexToDec(o[1])),f=String.fromCharCode(this.hexToDec(o[3]));e.additional={ascii:r,type:"DU.d",dozens:c,units:l,decimals:f,time:parseFloat(`${c}${l}.${f}`),meaning:"Extraction time (in seconds)"}}else if(["B","D","E","F","G"].includes(r)&&o.length===3){const c=String.fromCharCode(this.hexToDec(o[0])),l=String.fromCharCode(this.hexToDec(o[1])),f=String.fromCharCode(this.hexToDec(o[2])),y=parseInt(`${c}${l}${f}`),C={B:"Error on going to tray channel",D:"Error on product detector",E:"Extraction of channel ok",F:"Error on engine intensity detection",G:"Error on product exit door"};e.additional={type:"HDU",hundreds:c,dozens:l,decimals:f,channel:y,selection:y-109,ascii:r,meaning:C[r]??"Unknown"}}else if(o.length===13){const c=o.map(he=>String.fromCharCode(this.hexToDec(he))).join(""),l=parseInt(c.slice(0,2)),f=parseInt(c.slice(2,4)),y=parseInt(c.slice(4,6)),C=parseInt(c.slice(7,9)),k=parseInt(c.slice(9,11))-1,m=2e3+parseInt(c.slice(11,13)),w=new Date(m,k,C,l,f,y),x={A:"Attempt to close product exit door",C:"Closing of exterior door",H:"Error on opening of product exit door",I:"New attempt to arrive at product exit position after an error on first attempt",J:"Power on cooling unit",K:"Power off cooling unit",L:"Start of defrosting",M:"End of defrosting",O:"Opening of exterior door",R:"Memory reset",S:"Error on going to product exit position",Y:"Power on machine",Z:"Power off machine",c:"Closing of inner door",e:"New attempt to extract from channel due no product detection when elevator arrived to product exit position",o:"Opening of inner door"};e.additional={type:"hhmmssWddMMAA",date:w,hex:o,formatted:w.toLocaleString(),ascii:r,meaning:x[r]??"Unknown"}}}return this.dispatch("machine:activity",e.additional),e},N=function(t,e){const r={30:"Spanish",31:"English",32:"French"};return e.no_code=42,e.name="Language",e.description=`The language is ${r[t]??"unknown"}`,e.additional={hex:t,language:r[t]??"unknown"},this.dispatch("check:language",e.additional),e},L=function(t,e){return e.no_code=43,e.name="Beeper",e.description=`The beeper is ${t==="30"?"on":"off"}`,e.additional={hex:t,beeper:t==="30"},this.dispatch("check:beeper",e.additional),e},V=function(t,e){e.no_code=44,e.name="Isolation tray",e.description="Isolation tray";const r=this.hexToDec(t)-139;return e.additional={hex:t,tray:r},this.dispatch("check:isolation-tray",e.additional),e},J=function(t,e){e.no_code=45,e.name="Engine voltage",e.description="Engine voltage";const r=(this.hexToDec(t)-128)/2+5;return e.additional={hex:t,voltage:r},this.dispatch("check:engine-voltage",e.additional),e},U=function(t,e){e.no_code=46,e.name="Push over",e.description="Push over";const r=t==="30";return e.additional={hex:t,push:r},this.dispatch("check:push-over",e.additional),e},K=function(t,e){e.no_code=47,e.name="Extractor after dispense",e.description="Extractor after dispense";const r=(this.hexToDec(t)-128)/10;return e.additional={hex:t,seconds:r},this.dispatch("check:extractor-after-dispense",e.additional),e},H=function(t,e){e.no_code=48,e.name="Standby after collect",e.description="Time to standby after collect product";const r=this.hexToDec(t)-128;return e.additional={hex:t,seconds:r},this.dispatch("check:standby-after-collect",e.additional),e},z=function(t,e){e.no_code=49,e.name="Standby without collect",e.description="Time to standby when product delivery is not collected";const r=this.hexToDec(t)-128;return e.additional={hex:t,minutes:r},this.dispatch("check:standby-without-collect",e.additional),e},G=function(t,e){e.no_code=50,e.name="Elevator speed",e.description="Elevator speed";const r=t==="30"?"low":"high";return e.additional={hex:t,speed:r},this.dispatch("check:elevator-speed",e.additional),e},Y=function(t,e){e.no_code=51,e.name="Temperature expiration",e.description="Temperature expiration";const r=t==="31";return e.additional={hex:t,enabled:r},this.dispatch("check:expiration-by-temperature",e.additional),e},Z=function(t,e){e.no_code=52,e.name="Temperature before expiration",e.description="Temperature before expiration";const r=(this.hexToDec(t)-128)/2;return e.additional={hex:t,temperature:r},this.dispatch("check:temperature-before-expiration",e.additional),e},X=function(t,e){e.no_code=53,e.name="Time before expiration",e.description="Time before expiration";const r=this.hexToDec(t)-128;return e.additional={hex:t,minutes:r},this.dispatch("check:expiration-after",e.additional),e},ee=function(t,e){e.no_code=54,e.name="Temperature scale",e.description="Temperature scale";const r=t==="43"?"Celsius":"Fahrenheit";return e.additional={hex:t,scale:r},this.dispatch("check:temperature-scale",e.additional),e},te=function(t,e){return e.no_code=54,e.name="Machine ID",e.description="Machine ID",e.additional={hex:t[4],full_hex:t},this.dispatch("check:machine-id",e.additional),e},ne=function(t,e){return e.no_code=7,e.name="working temperature",e.description=`The working temperature is ${t}`,e.additional={hex:t,temperature:{traditional:(this.hexToDec(t)-this.hexToDec("80"))/2,ice_plus:(this.hexToDec(t)-this.hexToDec("80"))/2-25.5}},this.dispatch("temperature:working",e.additional),e},ie=function(t,e){return e.no_code=8,e.name="current temperature",e.additional={sign:null,tens:null,units:null,decimals:null,type_degrees:null,formatted:null,decimal_point:t[7]==="2e"?".":null,degrees:t[9]==="7f"?"°":null,error:null},t[4]==="2b"?e.additional.sign=t[4]="+":["2e","2d"].includes(t[4])?e.additional.sign=t[4]="-":t[4]==="20"&&(e.additional.error="Error in thermometer"),this.hexToDec(t[5])>=48&&this.hexToDec(t[5])<=57?e.additional.tens=this.hexToDec(t[5])-48:t[5]==="2a"&&(e.additional.error="Error in thermometer"),this.hexToDec(t[6])>=48&&this.hexToDec(t[6])<=57?e.additional.units=this.hexToDec(t[6])-48:t[6]==="2a"&&(e.additional.error="Error in thermometer"),this.hexToDec(t[8])>=48&&this.hexToDec(t[8])<=57?e.additional.decimals=this.hexToDec(t[8])-48:t[8]==="2a"&&(e.additional.error="Error in thermometer"),t[10]==="43"?e.additional.type_degrees="C":t[10]==="46"&&(e.additional.type_degrees="F"),e.additional.error==="Error in thermometer"?(e.additional.formatted="Error in thermometer",e.description="The current temperature cannot be read because there is an error in the thermometer"):(e.additional.formatted=(e.additional.sign??"")+(e.additional.tens??"")+(e.additional.units??"")+(e.additional.decimal_point??"")+(e.additional.decimals??"")+(e.additional.degrees??"")+(e.additional.type_degrees??""),e.description=`The current temperature is ${e.additional.formatted}`),this.dispatch("temperature:current",e.additional),e},re=function(t,e,r=128){if(t[1]&&(e.additional.machine.hex=t[1],e.additional.machine.dec=this.hexToDec(t[1])-r),!(t[1]&&t[2]))e=i(this,n,A).call(this,t,e);else switch(t[2]){case"54":e.request="--automatic",e=i(this,n,B).call(this,t[3],e);break;case"50":e.request="--automatic",e=i(this,n,W).call(this,t[3],e);break;case"43":switch(e.request="check-data",t[3]){case"41":e=i(this,n,j).call(this,t,e);break;case"43":e.request="channel-status",e=i(this,n,F).call(this,t,e);break;case"50":e=i(this,n,q).call(this,t,e);break;case"53":e=i(this,n,R).call(this,t,e);break;case"54":e.request="working-temperature",e=i(this,n,ne).call(this,t[4],e);break;case"72":e=i(this,n,$).call(this,t,e);break;case"74":e.request="current-temperature",e=i(this,n,ie).call(this,t,e);break;case"49":e=i(this,n,N).call(this,t[4],e);break;case"5a":e=i(this,n,L).call(this,t[4],e);break;case"42":e=i(this,n,V).call(this,t[4],e);break;case"47":e=i(this,n,J).call(this,t[4],e);break;case"4e":e=i(this,n,te).call(this,t,e);break;case"4f":e=i(this,n,U).call(this,t[4],e);break;case"45":e=i(this,n,K).call(this,t[4],e);break;case"46":e=i(this,n,H).call(this,t[4],e);break;case"48":e=i(this,n,z).call(this,t[4],e);break;case"76":e=i(this,n,G).call(this,t[4],e);break;case"63":e=i(this,n,Y).call(this,t[4],e);break;case"65":e=i(this,n,Z).call(this,t[4],e);break;case"66":e=i(this,n,X).call(this,t[4],e);break;case"67":e=i(this,n,ee).call(this,t[4],e);break}break}return e},u=function(){this.__internal__.dispense.dispensing&&(this.__internal__.dispense.status=!0)},s=function(){this.__internal__.dispense.dispensing&&(this.__internal__.dispense.status=!1)},b=function(){this.__internal__.dispense.dispensing&&(this.__internal__.dispense.status="elevator-locked")},d=function({type:t=null,severity:e="low"}={}){this.dispatch("jofemar:warning",{type:t,severity:e})},_=function({type:t=null,severity:e="high"}={}){this.dispatch("jofemar:error",{type:t,severity:e})},ae=function(t,e){if(e.request="status",t[1]&&!t[2]){switch(t[1]){case"30":e.name="Machine ready",e.description="The machine is ready for instructions",e.no_code=9,i(this,n,u).call(this);break;case"31":e.name="Machine busy",e.description="The machine is busy right now",e.no_code=10;break;case"32":e.name="Invalid tray",e.description="The tray requested is invalid",e.no_code=11,i(this,n,s).call(this),i(this,n,d).call(this,{type:"invalid-tray"});break;case"33":e.name="Invalid channel",e.description="The channel requested is invalid",e.no_code=12,i(this,n,s).call(this),i(this,n,d).call(this,{type:"invalid-channel"});break;case"34":e.name="Empty channel",e.description="The channel requested is empty",e.no_code=13,i(this,n,s).call(this),i(this,n,d).call(this,{type:"empty-channel"});break;case"35":e.name="Jam",e.description="Jam in elevator engine",e.no_code=14,i(this,n,s).call(this),i(this,n,_).call(this,{type:"jam"});break;case"36":e.name="Malfunction",e.description="Malfunction in the elevator belt or product detector",e.no_code=15,i(this,n,s).call(this),i(this,n,_).call(this,{type:"malfunction"});break;case"37":e.name="Photo transistors",e.description="Failure in one of the photo transistors in the cabinet",e.no_code=16,i(this,n,s).call(this),i(this,n,_).call(this,{type:"photo-transistors"});break;case"38":e.name="Without channels",e.description="No channels detected",e.no_code=17,i(this,n,s).call(this),i(this,n,_).call(this,{type:"without-channels"});break;case"39":e.name="Product detector fault",e.description="Product detector fault",e.no_code=18,i(this,n,b).call(this),i(this,n,d).call(this,{type:"fault-product-detector"});break;case"41":e.name="Fault in 485 BUS",e.description="Machine display is disconnected",e.no_code=19,i(this,n,u).call(this),i(this,n,d).call(this,{type:"display-disconnected"});break;case"42":e.name="Product under elevator",e.description="Product alarm under elevator",e.no_code=20,i(this,n,s).call(this),i(this,n,d).call(this,{type:"product-under-elevator"});break;case"43":e.name="Error when elevator approaching to a position",e.description="Error when elevator approaching to a position",e.no_code=21,i(this,n,u).call(this),i(this,n,d).call(this,{type:"error-approaching-position",severity:"high"});break;case"44":e.name="Fault in keyboard",e.description="Fault in keyboard",e.no_code=22,i(this,n,s).call(this),i(this,n,_).call(this,{type:"fault-keyboard"});break;case"45":e.name="Eeprom writing error",e.description="Eeprom writing error",e.no_code=23,i(this,n,s).call(this),i(this,n,_).call(this,{type:"eeprom-writing-error",severity:"critical"});break;case"46":e.name="Fault communicating with temperature control",e.description="Fault communicating with temperature control",e.no_code=24,i(this,n,u).call(this),i(this,n,d).call(this,{type:"fault-temperature-control"});break;case"47":e.name="Thermometer disconnected",e.description="The thermometer is disconnected",e.no_code=25,i(this,n,u).call(this),i(this,n,d).call(this,{type:"thermometer-disconnected"});break;case"48":e.name="Thermometer programming lost",e.description="Thermometer programming lost",e.no_code=26,i(this,n,u).call(this),i(this,n,d).call(this,{type:"thermometer-programming-lost"});break;case"49":e.name="Thermometer faulty",e.description="Thermometer faulty",e.no_code=27,i(this,n,u).call(this),i(this,n,d).call(this,{type:"thermometer-faulty"});break;case"4a":e.name="Channels power consumption detector faulty",e.description="Channels power consumption detector faulty",e.no_code=28,i(this,n,s).call(this),i(this,n,_).call(this,{type:"channels-power-consumption-detector-faulty",severity:"critical"});break;case"4b":e.name="Elevator does not find channel or tray",e.description="Elevator does not find channel or tray",e.no_code=29,i(this,n,s).call(this),i(this,n,d).call(this,{type:"elevator-not-find-channel-tray"});break;case"4c":e.name="Elevator does not find delivery product position",e.description="Elevator does not find delivery product position",e.no_code=30,i(this,n,s).call(this),i(this,n,_).call(this,{type:"elevator-not-find-delivery-position"});break;case"4d":e.name="Interior of elevator blocked",e.description="Interior of elevator blocked",e.no_code=31,i(this,n,b).call(this),this.__internal__.dispense.elevator.need_reset||(this.__internal__.dispense.elevator.need_reset=!0),i(this,n,_).call(this,{type:"interior-elevator-blocked",severity:"low"});break;case"4e":e.name="Error in tester of product detector",e.description="Error in tester of product detector",e.no_code=32,i(this,n,s).call(this),i(this,n,_).call(this,{type:"error-tester-product-detector"});break;case"4f":e.name="Waiting for product to be removed",e.description="Waiting for product to be removed",e.no_code=33,i(this,n,b).call(this);break;case"50":e.name="Product expired by temperature reasons",e.description="Product expired by temperature reasons",e.no_code=34,i(this,n,u).call(this),i(this,n,d).call(this,{type:"product-expired-temperature"});break;case"51":e.name="Automatic door faulty",e.description="Automatic door faulty",e.no_code=35,i(this,n,u).call(this),i(this,n,d).call(this,{type:"automatic-door-faulty"});break;case"59":case"5a":case"61":case"62":case"63":switch(e.name="Product is expired",e.description="Product is expired",e.additional={nsf_alarm:1},t[1]){case"5a":e.additional.nsf_alarm=2;break;case"61":e.additional.nsf_alarm=3;break;case"62":e.additional.nsf_alarm=4;break;case"63":e.additional.nsf_alarm=5;break}e.no_code=36,i(this,n,u).call(this),i(this,n,d).call(this,{type:"product-expired"});break;case"64":e.name="Product detector didn't change during its verification test",e.description="Product detector didn't change during its verification test",e.no_code=37,i(this,n,u).call(this),i(this,n,d).call(this,{type:"automatic-door-faulty"});break}this.dispatch("machine:status",e)}else e.name="executed",e.description="The last command was executed successfully",e.no_code=8,!t[1]&&this.__internal__.dispense.dispensing&&i(this,n,s).call(this);return e},oe=function(){this.__internal__.dispense.timeout&&clearTimeout(this.__internal__.dispense.timeout),this.__internal__.dispense.interval&&clearInterval(this.__internal__.dispense.interval),this.__internal__.dispense.timeout=0,this.__internal__.dispense.interval=0},ce=function(){this.__internal__.dispense.timeout&&clearTimeout(this.__internal__.dispense.timeout),this.__internal__.dispense.interval&&clearInterval(this.__internal__.dispense.interval);const t=this;t.__internal__.dispense.timeout=setTimeout(()=>{t.__internal__.dispense.interval=setInterval(()=>{t.status().then(()=>{})},t.__internal__.dispense.interval_time)},t.__internal__.dispense.timeout_time)},T=async function(t){return await this.appendToQueue(a.o.reset({machineChannel:this.listenOnChannel,type:t}),"reset")},E=function(){const t=this.__device.type==="iceplus"?v.getSeconds(40):v.getSeconds(25),e=new Date,r=1e3*t+e.getTime(),o=new Date(r);this.dispatch("reset:errors",{description:"Resetting machine errors",duration:t,started_at:e,finished_at:o})},D=async function(t){return await this.appendToQueue(a.o.lights({machineChannel:this.listenOnChannel,type:t}),"lights")};exports.Jofemar=pe;
1
+ "use strict";var le=Object.defineProperty;var O=p=>{throw TypeError(p)};var se=(p,h,t)=>h in p?le(p,h,{enumerable:!0,configurable:!0,writable:!0,value:t}):p[h]=t;var M=(p,h,t)=>se(p,typeof h!="symbol"?h+"":h,t),de=(p,h,t)=>h.has(p)||O("Cannot "+t);var I=(p,h,t)=>h.has(p)?O("Cannot add the same private member more than once"):h instanceof WeakSet?h.add(p):h.set(p,t);var i=(p,h,t)=>(de(p,h,"access private method"),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const v=require("./kernel-DlsHh4AG.cjs"),a=require("./relay-BsUsBpOv.cjs"),S=require("./webserial-core-DlH0cFSH.cjs");var n,P,Q,g,A,B,W,F,q,R,$,j,N,L,V,J,U,K,H,z,G,Y,Z,X,ee,te,ne,ie,re,u,s,b,d,_,ae,oe,ce,T,E,D;class pe extends v.Kernel{constructor({filters:t=null,config_port:e=null,no_device:r=1,device_listen_on_port:o=1,type:c="esplus",support_cart:l=!0}={}){super({filters:t,config_port:e,no_device:r,device_listen_on_port:o});I(this,n);M(this,"__device",{type:"esplus",support_cart:!1,withdraw:{in_process:!1,seconds:60,interval:0},cart:{in_process:!1},channels:{verification:{clear(){this.running=!1,this.current=1,this.channels=[]},running:!1,start:1,end:80,current:1,channels:[]}}});if(this.__internal__.device.type="jofemar",S.h.getCustom(this.typeDevice,r))throw new Error(`Device ${this.typeDevice} ${r} already exists`);this.__internal__.dispense.must_response=!0,this.__internal__.time.response_general=800,this.__internal__.time.response_engines=800,this.__internal__.dispense.limit_counter=40,this.__internal__.dispense.timeout=0,this.__internal__.dispense.timeout_time=4e3,this.__internal__.dispense.interval=0,this.__internal__.dispense.interval_time=1e3,this.__internal__.device.hex_number=(128+this.listenOnChannel).toString(16),this.__internal__.device.door_open=!1,this.__internal__.dispense.elevator={locking_time:60,locking_interval:0,need_reset:!1},this.deviceType=c,this.supportCart=l,i(this,n,P).call(this),S.h.add(this),i(this,n,Q).call(this)}set startChannelVerification(t){const e=parseInt(t);if(isNaN(e))throw new Error("Invalid start channel verification, must be a number");if(e<1||e>126)throw new Error("Invalid start channel verification, valid range is 1 to 126");this.__device.channels.verification.start=e}set endChannelVerification(t){const e=parseInt(t);if(isNaN(e))throw new Error("Invalid end channel verification, must be a number");if(e<1||e>126)throw new Error("Invalid end channel verification, valid range is 1 to 126");this.__device.channels.verification.end=e}set listenOnChannel(t){if(t=parseInt(t),isNaN(t)||t<1||t>31)throw new Error("Invalid port number, valid range is 1 to 31");this.__internal__.device.listen_on_port=t,this.__internal__.serial.bytes_connection=this.serialSetConnectionConstant(t),this.__internal__.device.hex_number=(128+t).toString(16)}set listenOnPort(t){this.listenOnChannel=t}set deviceType(t){if(typeof t!="string")throw new Error("Invalid device type, must be a string");this.__device.type=t}set supportCart(t){if(typeof t!="boolean")throw new Error("Invalid support cart, must be a boolean");this.__device.support_cart=t}serialSetConnectionConstant(t=1){return a.o.connection({channel:t})}serialMessage(t){let r={code:t,name:null,description:null,request:"unknown",no_code:0,additional:{machine:{hex:null,dec:null}}};switch(t[0]){case"02":r=i(this,n,re).call(this,t,r,128);break;case"06":r=i(this,n,ae).call(this,t,r);break;case"15":r.name="Checksum error",r.description="The calculated checksum does not match the received checksum",r.no_code=38,i(this,n,s).call(this);break;default:r.name="unknown",r.description="The message received is unknown",r.no_code=404;break}this.dispatch("serial:message",r)}productRemovedContinueDispensing(){this.__internal__.dispense.elevator.locking_interval&&(this.__internal__.dispense.elevator.locking_time=0)}async dispense({selection:t=1,cart:e=!1}={}){const r=a.o.dispense({selection:t,cart:e,machineChannel:this.listenOnChannel}),o=r[5],c=r[6];this.__internal__.dispense.backup_dispense={selection:t,cart:e,channel:c,tray:o};let l;do l=await this.internalDispense(r),i(this,n,oe).call(this),l.error==="elevator-locked"?await i(this,n,g).call(this):l.error==="no-response"&&await v.wait(1e3);while(["elevator-locked","no-response"].includes(l.error));return this.__internal__.dispense.backup_dispense={},l}internalClearSensing(){super.internalClearSensing(),this.__internal__.dispense.timeout&&clearTimeout(this.__internal__.dispense.timeout),this.__internal__.dispense.interval&&clearInterval(this.__internal__.dispense.interval),this.__internal__.serial.queue.length>0&&(this.__internal__.serial.queue=this.__internal__.serial.queue.filter(t=>t.type!=="status"))}async endDispense(){const t=a.o.endCartDispense({machineChannel:this.listenOnChannel});return await this.internalDispense(t)}async collect(){return await this.appendToQueue(a.o.collect({machineChannel:this.listenOnChannel}),"collect")}async resetSoldOutErrors(){return await i(this,n,T).call(this,"soldOut")}async resetWaitingProductRemovedError(){return await i(this,n,T).call(this,"waiting")}async resetMachineErrors(){return this.__internal__.serial.queue.length===0?(i(this,n,E).call(this),await i(this,n,T).call(this,"machine")):new Promise(t=>{const e=setInterval(async()=>{this.__internal__.serial.queue.length>0||(clearInterval(e),await i(this,n,T).call(this,"machine"),i(this,n,E).call(this),t(!0))},100)})}async resetAllErrors(){return await this.resetSoldOutErrors(),await v.wait(100),await this.resetWaitingProductRemovedError(),await v.wait(100),await this.resetMachineErrors()}async status(){return await this.appendToQueue(a.o.status({machineChannel:this.listenOnChannel}),"status")}async lightsOn(){return await i(this,n,D).call(this,"on")}async lightsOff(){return await i(this,n,D).call(this,"off")}async program(t,e){return await this.appendToQueue(a.o.program({machineChannel:this.listenOnChannel,param1:t,param2:e}),"program")}async programDisplayLanguage({language:t="spanish"}={}){return await this.appendToQueue(a.o.programDisplayLanguage({machineChannel:this.listenOnChannel,language:t}),"program")}async programBeeper({enable:t=!0}={}){return await this.appendToQueue(a.o.programBeeper({machineChannel:this.listenOnChannel,enable:t}),"program")}async programDisableWorkingTemperature(){if(this.__device.type==="iceplus")throw new Error("IcePlus does not support disable working temperature");return await this.appendToQueue(a.o.programDisableWorkingTemperature({machineChannel:this.listenOnChannel}),"program")}async programDisableThermometer(){return await this.appendToQueue(a.o.programDisableThermometer({machineChannel:this.listenOnChannel}),"program")}async programWorkingTemperature({degrees:t=.5}={}){return await this.appendToQueue(a.o.programWorkingTemperature({machineChannel:this.listenOnChannel,degrees:t,machineType:this.__device.type}),"program")}async programIsolationTray({tray:t=0}={}){return await this.appendToQueue(a.o.programIsolationTray({machineChannel:this.listenOnChannel,tray:t}),"program")}async programTimeToStandbyAfterCollect({seconds:t=15}={}){return await this.appendToQueue(a.o.programTimeToStandbyAfterCollect({machineChannel:this.listenOnChannel,seconds:t}),"program")}async programTimeToStandbyWithoutCollect({minutes:t=1}={}){return await this.appendToQueue(a.o.programTimeToStandbyWithoutCollect({machineChannel:this.listenOnChannel,minutes:t}),"program")}async programElevatorSpeed({speed:t="high"}={}){return await this.appendToQueue(a.o.programElevatorSpeed({machineChannel:this.listenOnChannel,speed:t}),"program")}async programTemperatureExpiration({enable:t=!1}={}){return await this.appendToQueue(a.o.programTemperatureExpiration({machineChannel:this.listenOnChannel,enable:t}),"program")}async programEnableTemperatureExpiration(){return await this.programTemperatureExpiration({enable:!0})}async programDisableTemperatureExpiration(){return await this.programTemperatureExpiration({enable:!1})}async programMachineAddress({address:t=1}={}){return await this.appendToQueue(a.o.programMachineAddress({machineChannel:this.listenOnChannel,address:t}),"program")}async programTemperatureBeforeExpiration({degrees:t=.5}={}){return await this.appendToQueue(a.o.programTemperatureBeforeExpiration({machineChannel:this.listenOnChannel,degrees:t}),"program")}async programTimeBeforeExpirationByTemperature({minutes:t=1}={}){return await this.appendToQueue(a.o.programTimeBeforeExpirationByTemperature({machineChannel:this.listenOnChannel,minutes:t}),"program")}async programTemperatureScale({scale:t="celsius"}={}){return await this.appendToQueue(a.o.programTemperatureScale({machineChannel:this.listenOnChannel,scale:t}),"program")}async programVoltageEngine({selection:t=1,voltage:e=5}={}){return await this.appendToQueue(a.o.programVoltageEngine({machineChannel:this.listenOnChannel,selection:t,voltage:e}),"voltage-engine")}async programPushOverProducts({selection:t=1,enable:e=!0}={}){return await this.appendToQueue(a.o.programPushOverProducts({machineChannel:this.listenOnChannel,selection:t,enable:e}),"push-over-products")}async programChannelRunningAfterDispense({selection:t=1,seconds:e=0}={}){return await this.appendToQueue(a.o.programChannelRunningAfterDispense({machineChannel:this.listenOnChannel,selection:t,seconds:e}),"channel-running-after-dispense")}async checkData(t,e="FF"){return await this.appendToQueue(a.o.checkData({machineChannel:this.listenOnChannel,type:t,aux:e}),"check-data")}async getDisplayLanguage(){return await this.appendToQueue(a.o.getDisplayLanguage({machineChannel:this.listenOnChannel}),"check-data")}async getBeeper(){return await this.appendToQueue(a.o.getBeeper({machineChannel:this.listenOnChannel}),"check-data")}async getWorkingTemperature(){return await this.appendToQueue(a.o.getWorkingTemperature({machineChannel:this.listenOnChannel}),"check-data")}async getIsolationTray(){return await this.appendToQueue(a.o.getIsolationTray({machineChannel:this.listenOnChannel}),"check-data")}async getProgramVersion(){return await this.appendToQueue(a.o.getProgramVersion({machineChannel:this.listenOnChannel}),"check-data")}async getFaults(){return await this.appendToQueue(a.o.getFaults({machineChannel:this.listenOnChannel}),"check-data")}async getMachineId(){return await this.appendToQueue(a.o.getMachineId({machineChannel:this.listenOnChannel}),"check-data")}async getCurrentTemperature(){return await this.appendToQueue(a.o.getCurrentTemperature({machineChannel:this.listenOnChannel}),"check-data")}async getTimeToStandbyAfterCollect(){return await this.appendToQueue(a.o.getTimeToStandbyAfterCollect({machineChannel:this.listenOnChannel}),"check-data")}async getTimeToStandbyWithoutCollect(){return await this.appendToQueue(a.o.getTimeToStandbyWithoutCollect({machineChannel:this.listenOnChannel}),"check-data")}async getElevatorSpeed(){return await this.appendToQueue(a.o.getElevatorSpeed({machineChannel:this.listenOnChannel}),"check-data")}async getTemperatureExpiration(){return await this.appendToQueue(a.o.getTemperatureExpiration({machineChannel:this.listenOnChannel}),"check-data")}async getTemperatureBeforeExpiration(){return await this.appendToQueue(a.o.getTemperatureBeforeExpiration({machineChannel:this.listenOnChannel}),"check-data")}async getTimeBeforeExpirationByTemperature(){return await this.appendToQueue(a.o.getTimeBeforeExpirationByTemperature({machineChannel:this.listenOnChannel}),"check-data")}async getTemperatureScale(){return await this.appendToQueue(a.o.getTemperatureScale({machineChannel:this.listenOnChannel}),"check-data")}async getClockRegisters(){return await this.appendToQueue(a.o.getClockRegisters({machineChannel:this.listenOnChannel}),"check-data")}async getMachineActivity(){return await this.appendToQueue(a.o.getMachineActivity({machineChannel:this.listenOnChannel}),"check-data")}async getVoltageEngine({selection:t=1}={}){return await this.appendToQueue(a.o.getVoltageEngine({machineChannel:this.listenOnChannel,selection:t}),"check-data")}async getChannelPresence({selection:t=1}={}){return await this.appendToQueue(a.o.getChannelPresence({machineChannel:this.listenOnChannel,selection:t}),"check-data")}async getPushOverProducts({selection:t=1}={}){return await this.appendToQueue(a.o.getPushOverProducts({machineChannel:this.listenOnChannel,selection:t}),"check-data")}async getChannelRunningAfterDispense({selection:t=1}={}){return await this.appendToQueue(a.o.getChannelRunningAfterDispense({machineChannel:this.listenOnChannel,selection:t}),"check-data")}async setDisplayStandbyMessage({message:t=""}={}){return await this.appendToQueue(a.o.setDisplayStandbyMessage({machineChannel:this.listenOnChannel,message:t}),"display")}async setDisplayMessageTemporarily({message:t="",seconds:e=1}){return this.appendToQueue(a.o.setDisplayMessageTemporarily({machineChannel:this.listenOnChannel,message:t,seconds:e}),"display")}async setDisplayMessageUnlimited({message:t=""}){return await this.appendToQueue(a.o.setDisplayMessageUnlimited({machineChannel:this.listenOnChannel,message:t}),"display")}async programClock({date:t=new Date}={}){return await this.appendToQueue(a.o.programClock({machineChannel:this.listenOnChannel,date:t}),"clock")}async eventsConfig({event:t=null,enable:e=!0}={}){return await this.appendToQueue(a.o.eventsConfig({machineChannel:this.listenOnChannel,event:t,enable:e}),"events-config")}async eventEnable({event:t=null}={}){return await this.appendToQueue(a.o.eventEnable({machineChannel:this.listenOnChannel,event:t}),"events-config")}async eventDisable({event:t=null}={}){return await this.appendToQueue(a.o.eventEnable({machineChannel:this.listenOnChannel,event:t}),"events-config")}async sendCustomCode({code:t=[]}={}){return await this.appendToQueue(a.o.sendCustomCode({machineChannel:this.listenOnChannel,code:t}),"custom")}async assignChannels(){const t=this.__device.channels.verification.start,e=this.__device.channels.verification.end;if(t>e)throw new Error("Invalid range, start must be less than end");this.__device.channels.verification.clear(),this.__device.channels.verification.running=!0;for(let r=t;r<=e;r++)this.__device.channels.verification.current=r,await this.getChannelPresence({selection:r});return new Promise(r=>{let o=setInterval(()=>{this.__device.channels.verification.channels.length===e-t+1&&(clearInterval(o),this.dispatch("channels",{channels:this.__device.channels.verification.channels}),this.__device.channels.verification.clear(),r(!0))},500)})}}n=new WeakSet,P=function(){const t=["dispensing:withdrawal","command-executed","keyboard:pressed","door:event","program:version","machine:faults","clock:registers","machine:activity","check:language","check:beeper","check:isolation-tray","check:engine-voltage","check:push-over","check:extractor-after-dispense","check:standby-after-collect","check:standby-without-collect","check:elevator-speed","check:expiration-by-temperature","check:temperature-before-expiration","check:expiration-after","check:temperature-scale","check:machine-id","temperature:working","temperature:current","jofemar:warning","jofemar:error","serial:message","reset:errors","channels","channel:status","machine:status"];for(const e of t)this.serialRegisterAvailableListener(e)},Q=function(){this.on("internal:dispense:running",i(this,n,ce).bind(this))},g=async function(){if(this.__internal__.dispense.elevator.locking_interval)return;this.__internal__.dispense.elevator.need_reset&&(this.__internal__.dispense.elevator.need_reset=!1,await this.resetWaitingProductRemovedError(),await v.wait(500));const t=this;return this.__internal__.dispense.status="elevator-locked",this.__internal__.dispense.elevator.locking_time=60,new Promise(e=>{t.__internal__.dispense.elevator.locking_interval=setInterval(()=>{t.dispatch("dispensing:withdrawal",{elevator:!0,seconds:t.__internal__.dispense.elevator.locking_time,description:"Please recall products from the elevator"}),t.__internal__.dispense.elevator.locking_time-=1,t.__internal__.dispense.elevator.locking_time<=0&&(clearInterval(t.__internal__.dispense.elevator.locking_interval),t.__internal__.dispense.elevator.locking_interval=0,e(!0))},1e3)})},A=function(t,e){return e.name="ok",e.description="The last command was executed successfully",e.no_code=1,this.dispatch("command-executed",e),e},B=function(t,e){e.additional={hex:t,dec:this.hexToDec(t),ascii:null};const r={30:"0",31:"1",32:"2",33:"3",34:"4",35:"5",36:"6",37:"7",38:"8",39:"9","2a":"*",23:"#",41:"A",42:"B",43:"C",44:"D"};return e.additional.ascii=r[t]??null,e.name="Key pressed",e.description=`The key ${e.additional.ascii} was pressed`,e.no_code=2,this.dispatch("keyboard:pressed",e.additional),e},W=function(t,e){return e.additional={open:!1},e.no_code=3,t==="4f"?(e.name="door open",e.description="The door was opened",e.additional.open=!0,this.__internal__.device.door_open=!0,this.dispatch("door:event",e.additional)):t==="43"?(e.name="door close",e.description="The door was closed",e.additional.open=!1,this.__internal__.device.door_open=!1,this.dispatch("door:event",e.additional)):(e.name="door event",e.description="The door event received is unknown",this.dispatch("door:event",{open:e.additional.open,message:e})),e},F=function(t,e){e.no_code=404;let r=t[5]??null;return r&&this.listenOnChannel>1&&(r=this.hexToDec(r)-this.listenOnChannel+1,r=this.decToHex(r)),r&&(r==="FD"?(e.no_code=4,e.name="channel disconnected",e.description="The channel is disconnected",e.additional={active:!1}):r==="FC"?(e.no_code=5,e.name="channel connected",e.description="The channel is connected",e.additional={active:!0}):(e.no_code=6,e.name="channel sold out",e.description="The channel is empty",e.additional={active:!0}),this.__device.channels.verification.running&&(this.__device.channels.verification.channels.push({selection:this.__device.channels.verification.current,active:e.additional.active}),e.additional.selection=this.__device.channels.verification.current),this.dispatch("channel:status",e.additional)),e},q=function(t,e){e.no_code=39,e.name="Program version";const r=t.slice(4,12),o=r.map(c=>String.fromCharCode(this.hexToDec(c))).join("");return e.additional={version:o,hex:r},e.description=`The program version is ${o}`,this.dispatch("program:version",e.additional),e},R=function(t,e){e.no_code=39,e.name="Machine faults",e.description="No faults detected",e.additional={no_faults:0,faults:[]};const r=t.slice(4,-3);if(r.length>1&&r[0]!=="30"){e.description="Machine has faults";const o={31:"Busy",32:"Invalid tray",33:"Invalid channel",34:"Empty channel",35:"Jam in elevator engine",36:"Malfunction in the elevator belt or product detector",37:"Failure in one of the photo transistors in the cabinet",38:"No channels detected",39:"Product detector fault",41:"Machine display is disconnected",42:"Product alarm under elevator",43:"Error when elevator approaching to a position",44:"Fault in keyboard",45:"Eeprom writing error",46:"Fault communicating with temperature control",47:"The thermometer is disconnected",48:"Thermometer programming lost",49:"Thermometer faulty","4a":"Channels power consumption detector faulty","4b":"Elevator does not find channel or tray","4c":"Elevator does not find delivery product position","4d":"Interior of elevator blocked","4e":"Error in tester of product detector","4f":"Waiting for product to be removed",50:"Product expired by temperature reasons",51:"Automatic door faulty",59:"Product is expired","5a":"Product is expired",61:"Product is expired",62:"Product is expired",63:"Product is expired",64:"Product detector didn't change during its verification test"};for(const c of r)o[c]&&(e.additional.faults.push(o[c]),e.additional.no_faults++)}return this.dispatch("machine:faults",e.additional),e},$=function(t,e){e.no_code=40,e.name="Clock registers",e.description="Clock registers";const r=t.slice(4,-3),o=r.map(x=>String.fromCharCode(this.hexToDec(x))).join(""),[c,l]=o.split(" "),[f,y]=c.split(":"),[C,k,m]=l.split("-"),w=new Date(2e3+parseInt(m),parseInt(k)-1,parseInt(C),parseInt(f),parseInt(y));return e.additional={day:C,month:k,year:m,hours:f,minutes:y,formatted:o,date:w,hex:r},this.dispatch("clock:registers",e.additional),e},j=function(t,e){e.no_code=41,e.name="Machine activity",e.description="Events from read machine activity";const r=String.fromCharCode(this.hexToDec(t[4]));if(r!=="0"){const o=t.slice(5,-3);if(r==="T"&&o.length===4){const c=String.fromCharCode(this.hexToDec(o[0])),l=String.fromCharCode(this.hexToDec(o[1])),f=String.fromCharCode(this.hexToDec(o[3]));e.additional={ascii:r,type:"DU.d",dozens:c,units:l,decimals:f,time:parseFloat(`${c}${l}.${f}`),meaning:"Extraction time (in seconds)"}}else if(["B","D","E","F","G"].includes(r)&&o.length===3){const c=String.fromCharCode(this.hexToDec(o[0])),l=String.fromCharCode(this.hexToDec(o[1])),f=String.fromCharCode(this.hexToDec(o[2])),y=parseInt(`${c}${l}${f}`),C={B:"Error on going to tray channel",D:"Error on product detector",E:"Extraction of channel ok",F:"Error on engine intensity detection",G:"Error on product exit door"};e.additional={type:"HDU",hundreds:c,dozens:l,decimals:f,channel:y,selection:y-109,ascii:r,meaning:C[r]??"Unknown"}}else if(o.length===13){const c=o.map(he=>String.fromCharCode(this.hexToDec(he))).join(""),l=parseInt(c.slice(0,2)),f=parseInt(c.slice(2,4)),y=parseInt(c.slice(4,6)),C=parseInt(c.slice(7,9)),k=parseInt(c.slice(9,11))-1,m=2e3+parseInt(c.slice(11,13)),w=new Date(m,k,C,l,f,y),x={A:"Attempt to close product exit door",C:"Closing of exterior door",H:"Error on opening of product exit door",I:"New attempt to arrive at product exit position after an error on first attempt",J:"Power on cooling unit",K:"Power off cooling unit",L:"Start of defrosting",M:"End of defrosting",O:"Opening of exterior door",R:"Memory reset",S:"Error on going to product exit position",Y:"Power on machine",Z:"Power off machine",c:"Closing of inner door",e:"New attempt to extract from channel due no product detection when elevator arrived to product exit position",o:"Opening of inner door"};e.additional={type:"hhmmssWddMMAA",date:w,hex:o,formatted:w.toLocaleString(),ascii:r,meaning:x[r]??"Unknown"}}}return this.dispatch("machine:activity",e.additional),e},N=function(t,e){const r={30:"Spanish",31:"English",32:"French"};return e.no_code=42,e.name="Language",e.description=`The language is ${r[t]??"unknown"}`,e.additional={hex:t,language:r[t]??"unknown"},this.dispatch("check:language",e.additional),e},L=function(t,e){return e.no_code=43,e.name="Beeper",e.description=`The beeper is ${t==="30"?"on":"off"}`,e.additional={hex:t,beeper:t==="30"},this.dispatch("check:beeper",e.additional),e},V=function(t,e){e.no_code=44,e.name="Isolation tray",e.description="Isolation tray";const r=this.hexToDec(t)-139;return e.additional={hex:t,tray:r},this.dispatch("check:isolation-tray",e.additional),e},J=function(t,e){e.no_code=45,e.name="Engine voltage",e.description="Engine voltage";const r=(this.hexToDec(t)-128)/2+5;return e.additional={hex:t,voltage:r},this.dispatch("check:engine-voltage",e.additional),e},U=function(t,e){e.no_code=46,e.name="Push over",e.description="Push over";const r=t==="30";return e.additional={hex:t,push:r},this.dispatch("check:push-over",e.additional),e},K=function(t,e){e.no_code=47,e.name="Extractor after dispense",e.description="Extractor after dispense";const r=(this.hexToDec(t)-128)/10;return e.additional={hex:t,seconds:r},this.dispatch("check:extractor-after-dispense",e.additional),e},H=function(t,e){e.no_code=48,e.name="Standby after collect",e.description="Time to standby after collect product";const r=this.hexToDec(t)-128;return e.additional={hex:t,seconds:r},this.dispatch("check:standby-after-collect",e.additional),e},z=function(t,e){e.no_code=49,e.name="Standby without collect",e.description="Time to standby when product delivery is not collected";const r=this.hexToDec(t)-128;return e.additional={hex:t,minutes:r},this.dispatch("check:standby-without-collect",e.additional),e},G=function(t,e){e.no_code=50,e.name="Elevator speed",e.description="Elevator speed";const r=t==="30"?"low":"high";return e.additional={hex:t,speed:r},this.dispatch("check:elevator-speed",e.additional),e},Y=function(t,e){e.no_code=51,e.name="Temperature expiration",e.description="Temperature expiration";const r=t==="31";return e.additional={hex:t,enabled:r},this.dispatch("check:expiration-by-temperature",e.additional),e},Z=function(t,e){e.no_code=52,e.name="Temperature before expiration",e.description="Temperature before expiration";const r=(this.hexToDec(t)-128)/2;return e.additional={hex:t,temperature:r},this.dispatch("check:temperature-before-expiration",e.additional),e},X=function(t,e){e.no_code=53,e.name="Time before expiration",e.description="Time before expiration";const r=this.hexToDec(t)-128;return e.additional={hex:t,minutes:r},this.dispatch("check:expiration-after",e.additional),e},ee=function(t,e){e.no_code=54,e.name="Temperature scale",e.description="Temperature scale";const r=t==="43"?"Celsius":"Fahrenheit";return e.additional={hex:t,scale:r},this.dispatch("check:temperature-scale",e.additional),e},te=function(t,e){return e.no_code=54,e.name="Machine ID",e.description="Machine ID",e.additional={hex:t[4],full_hex:t},this.dispatch("check:machine-id",e.additional),e},ne=function(t,e){return e.no_code=7,e.name="working temperature",e.description=`The working temperature is ${t}`,e.additional={hex:t,temperature:{traditional:(this.hexToDec(t)-this.hexToDec("80"))/2,ice_plus:(this.hexToDec(t)-this.hexToDec("80"))/2-25.5}},this.dispatch("temperature:working",e.additional),e},ie=function(t,e){return e.no_code=8,e.name="current temperature",e.additional={sign:null,tens:null,units:null,decimals:null,type_degrees:null,formatted:null,decimal_point:t[7]==="2e"?".":null,degrees:t[9]==="7f"?"°":null,error:null},t[4]==="2b"?e.additional.sign=t[4]="+":["2e","2d"].includes(t[4])?e.additional.sign=t[4]="-":t[4]==="20"&&(e.additional.error="Error in thermometer"),this.hexToDec(t[5])>=48&&this.hexToDec(t[5])<=57?e.additional.tens=this.hexToDec(t[5])-48:t[5]==="2a"&&(e.additional.error="Error in thermometer"),this.hexToDec(t[6])>=48&&this.hexToDec(t[6])<=57?e.additional.units=this.hexToDec(t[6])-48:t[6]==="2a"&&(e.additional.error="Error in thermometer"),this.hexToDec(t[8])>=48&&this.hexToDec(t[8])<=57?e.additional.decimals=this.hexToDec(t[8])-48:t[8]==="2a"&&(e.additional.error="Error in thermometer"),t[10]==="43"?e.additional.type_degrees="C":t[10]==="46"&&(e.additional.type_degrees="F"),e.additional.error==="Error in thermometer"?(e.additional.formatted="Error in thermometer",e.description="The current temperature cannot be read because there is an error in the thermometer"):(e.additional.formatted=(e.additional.sign??"")+(e.additional.tens??"")+(e.additional.units??"")+(e.additional.decimal_point??"")+(e.additional.decimals??"")+(e.additional.degrees??"")+(e.additional.type_degrees??""),e.description=`The current temperature is ${e.additional.formatted}`),this.dispatch("temperature:current",e.additional),e},re=function(t,e,r=128){if(t[1]&&(e.additional.machine.hex=t[1],e.additional.machine.dec=this.hexToDec(t[1])-r),!(t[1]&&t[2]))e=i(this,n,A).call(this,t,e);else switch(t[2]){case"54":e.request="--automatic",e=i(this,n,B).call(this,t[3],e);break;case"50":e.request="--automatic",e=i(this,n,W).call(this,t[3],e);break;case"43":switch(e.request="check-data",t[3]){case"41":e=i(this,n,j).call(this,t,e);break;case"43":e.request="channel-status",e=i(this,n,F).call(this,t,e);break;case"50":e=i(this,n,q).call(this,t,e);break;case"53":e=i(this,n,R).call(this,t,e);break;case"54":e.request="working-temperature",e=i(this,n,ne).call(this,t[4],e);break;case"72":e=i(this,n,$).call(this,t,e);break;case"74":e.request="current-temperature",e=i(this,n,ie).call(this,t,e);break;case"49":e=i(this,n,N).call(this,t[4],e);break;case"5a":e=i(this,n,L).call(this,t[4],e);break;case"42":e=i(this,n,V).call(this,t[4],e);break;case"47":e=i(this,n,J).call(this,t[4],e);break;case"4e":e=i(this,n,te).call(this,t,e);break;case"4f":e=i(this,n,U).call(this,t[4],e);break;case"45":e=i(this,n,K).call(this,t[4],e);break;case"46":e=i(this,n,H).call(this,t[4],e);break;case"48":e=i(this,n,z).call(this,t[4],e);break;case"76":e=i(this,n,G).call(this,t[4],e);break;case"63":e=i(this,n,Y).call(this,t[4],e);break;case"65":e=i(this,n,Z).call(this,t[4],e);break;case"66":e=i(this,n,X).call(this,t[4],e);break;case"67":e=i(this,n,ee).call(this,t[4],e);break}break}return e},u=function(){this.__internal__.dispense.dispensing&&(this.__internal__.dispense.status=!0)},s=function(){this.__internal__.dispense.dispensing&&(this.__internal__.dispense.status=!1)},b=function(){this.__internal__.dispense.dispensing&&(this.__internal__.dispense.status="elevator-locked")},d=function({type:t=null,severity:e="low"}={}){this.dispatch("jofemar:warning",{type:t,severity:e})},_=function({type:t=null,severity:e="high"}={}){this.dispatch("jofemar:error",{type:t,severity:e})},ae=function(t,e){if(e.request="status",t[1]&&!t[2]){switch(t[1]){case"30":e.name="Machine ready",e.description="The machine is ready for instructions",e.no_code=9,i(this,n,u).call(this);break;case"31":e.name="Machine busy",e.description="The machine is busy right now",e.no_code=10;break;case"32":e.name="Invalid tray",e.description="The tray requested is invalid",e.no_code=11,i(this,n,s).call(this),i(this,n,d).call(this,{type:"invalid-tray"});break;case"33":e.name="Invalid channel",e.description="The channel requested is invalid",e.no_code=12,i(this,n,s).call(this),i(this,n,d).call(this,{type:"invalid-channel"});break;case"34":e.name="Empty channel",e.description="The channel requested is empty",e.no_code=13,i(this,n,s).call(this),i(this,n,d).call(this,{type:"empty-channel"});break;case"35":e.name="Jam",e.description="Jam in elevator engine",e.no_code=14,i(this,n,s).call(this),i(this,n,_).call(this,{type:"jam"});break;case"36":e.name="Malfunction",e.description="Malfunction in the elevator belt or product detector",e.no_code=15,i(this,n,s).call(this),i(this,n,_).call(this,{type:"malfunction"});break;case"37":e.name="Photo transistors",e.description="Failure in one of the photo transistors in the cabinet",e.no_code=16,i(this,n,s).call(this),i(this,n,_).call(this,{type:"photo-transistors"});break;case"38":e.name="Without channels",e.description="No channels detected",e.no_code=17,i(this,n,s).call(this),i(this,n,_).call(this,{type:"without-channels"});break;case"39":e.name="Product detector fault",e.description="Product detector fault",e.no_code=18,i(this,n,b).call(this),i(this,n,d).call(this,{type:"fault-product-detector"});break;case"41":e.name="Fault in 485 BUS",e.description="Machine display is disconnected",e.no_code=19,i(this,n,u).call(this),i(this,n,d).call(this,{type:"display-disconnected"});break;case"42":e.name="Product under elevator",e.description="Product alarm under elevator",e.no_code=20,i(this,n,s).call(this),i(this,n,d).call(this,{type:"product-under-elevator"});break;case"43":e.name="Error when elevator approaching to a position",e.description="Error when elevator approaching to a position",e.no_code=21,i(this,n,u).call(this),i(this,n,d).call(this,{type:"error-approaching-position",severity:"high"});break;case"44":e.name="Fault in keyboard",e.description="Fault in keyboard",e.no_code=22,i(this,n,s).call(this),i(this,n,_).call(this,{type:"fault-keyboard"});break;case"45":e.name="Eeprom writing error",e.description="Eeprom writing error",e.no_code=23,i(this,n,s).call(this),i(this,n,_).call(this,{type:"eeprom-writing-error",severity:"critical"});break;case"46":e.name="Fault communicating with temperature control",e.description="Fault communicating with temperature control",e.no_code=24,i(this,n,u).call(this),i(this,n,d).call(this,{type:"fault-temperature-control"});break;case"47":e.name="Thermometer disconnected",e.description="The thermometer is disconnected",e.no_code=25,i(this,n,u).call(this),i(this,n,d).call(this,{type:"thermometer-disconnected"});break;case"48":e.name="Thermometer programming lost",e.description="Thermometer programming lost",e.no_code=26,i(this,n,u).call(this),i(this,n,d).call(this,{type:"thermometer-programming-lost"});break;case"49":e.name="Thermometer faulty",e.description="Thermometer faulty",e.no_code=27,i(this,n,u).call(this),i(this,n,d).call(this,{type:"thermometer-faulty"});break;case"4a":e.name="Channels power consumption detector faulty",e.description="Channels power consumption detector faulty",e.no_code=28,i(this,n,s).call(this),i(this,n,_).call(this,{type:"channels-power-consumption-detector-faulty",severity:"critical"});break;case"4b":e.name="Elevator does not find channel or tray",e.description="Elevator does not find channel or tray",e.no_code=29,i(this,n,s).call(this),i(this,n,d).call(this,{type:"elevator-not-find-channel-tray"});break;case"4c":e.name="Elevator does not find delivery product position",e.description="Elevator does not find delivery product position",e.no_code=30,i(this,n,s).call(this),i(this,n,_).call(this,{type:"elevator-not-find-delivery-position"});break;case"4d":e.name="Interior of elevator blocked",e.description="Interior of elevator blocked",e.no_code=31,i(this,n,b).call(this),this.__internal__.dispense.elevator.need_reset||(this.__internal__.dispense.elevator.need_reset=!0),i(this,n,_).call(this,{type:"interior-elevator-blocked",severity:"low"});break;case"4e":e.name="Error in tester of product detector",e.description="Error in tester of product detector",e.no_code=32,i(this,n,s).call(this),i(this,n,_).call(this,{type:"error-tester-product-detector"});break;case"4f":e.name="Waiting for product to be removed",e.description="Waiting for product to be removed",e.no_code=33,i(this,n,b).call(this);break;case"50":e.name="Product expired by temperature reasons",e.description="Product expired by temperature reasons",e.no_code=34,i(this,n,u).call(this),i(this,n,d).call(this,{type:"product-expired-temperature"});break;case"51":e.name="Automatic door faulty",e.description="Automatic door faulty",e.no_code=35,i(this,n,u).call(this),i(this,n,d).call(this,{type:"automatic-door-faulty"});break;case"59":case"5a":case"61":case"62":case"63":switch(e.name="Product is expired",e.description="Product is expired",e.additional={nsf_alarm:1},t[1]){case"5a":e.additional.nsf_alarm=2;break;case"61":e.additional.nsf_alarm=3;break;case"62":e.additional.nsf_alarm=4;break;case"63":e.additional.nsf_alarm=5;break}e.no_code=36,i(this,n,u).call(this),i(this,n,d).call(this,{type:"product-expired"});break;case"64":e.name="Product detector didn't change during its verification test",e.description="Product detector didn't change during its verification test",e.no_code=37,i(this,n,u).call(this),i(this,n,d).call(this,{type:"automatic-door-faulty"});break}this.dispatch("machine:status",e)}else e.name="executed",e.description="The last command was executed successfully",e.no_code=8,!t[1]&&this.__internal__.dispense.dispensing&&i(this,n,s).call(this);return e},oe=function(){this.__internal__.dispense.timeout&&clearTimeout(this.__internal__.dispense.timeout),this.__internal__.dispense.interval&&clearInterval(this.__internal__.dispense.interval),this.__internal__.dispense.timeout=0,this.__internal__.dispense.interval=0},ce=function(){this.__internal__.dispense.timeout&&clearTimeout(this.__internal__.dispense.timeout),this.__internal__.dispense.interval&&clearInterval(this.__internal__.dispense.interval);const t=this;t.__internal__.dispense.timeout=setTimeout(()=>{t.__internal__.dispense.interval=setInterval(()=>{t.status().then(()=>{})},t.__internal__.dispense.interval_time)},t.__internal__.dispense.timeout_time)},T=async function(t){return await this.appendToQueue(a.o.reset({machineChannel:this.listenOnChannel,type:t}),"reset")},E=function(){const t=this.__device.type==="iceplus"?v.getSeconds(40):v.getSeconds(25),e=new Date,r=1e3*t+e.getTime(),o=new Date(r);this.dispatch("reset:errors",{description:"Resetting machine errors",duration:t,started_at:e,finished_at:o})},D=async function(t){return await this.appendToQueue(a.o.lights({machineChannel:this.listenOnChannel,type:t}),"lights")};exports.Jofemar=pe;
package/dist/jofemar.js CHANGED
@@ -6,7 +6,7 @@ var de = (p, h, t) => h in p ? se(p, h, { enumerable: !0, configurable: !0, writ
6
6
  var M = (p, h, t) => de(p, typeof h != "symbol" ? h + "" : h, t), pe = (p, h, t) => h.has(p) || O("Cannot " + t);
7
7
  var I = (p, h, t) => h.has(p) ? O("Cannot add the same private member more than once") : h instanceof WeakSet ? h.add(p) : h.set(p, t);
8
8
  var i = (p, h, t) => (pe(p, h, "access private method"), t);
9
- import { K as ue, w, g as P } from "./kernel-lcvN8cY0.js";
9
+ import { K as ue, w, g as P } from "./kernel-IUeiZp8d.js";
10
10
  import { o as a } from "./relay-Dop4mFk-.js";
11
11
  import { h as Q } from "./webserial-core-DGKQCs5a.js";
12
12
  var n, S, g, A, B, W, F, q, R, $, N, j, L, V, J, U, K, H, z, G, Y, Z, X, ee, te, ne, ie, re, ae, u, s, b, d, _, oe, ce, he, C, E, D;
@@ -1 +1 @@
1
- "use strict";var L=Object.defineProperty;var I=u=>{throw TypeError(u)};var R=(u,n,e)=>n in u?L(u,n,{enumerable:!0,configurable:!0,writable:!0,value:e}):u[n]=e;var P=(u,n,e)=>R(u,typeof n!="symbol"?n+"":n,e),x=(u,n,e)=>n.has(u)||I("Cannot "+e);var g=(u,n,e)=>(x(u,n,"read from private field"),e?e.call(u):n.get(u)),B=(u,n,e)=>n.has(u)?I("Cannot add the same private member more than once"):n instanceof WeakSet?n.add(u):n.set(u,e),E=(u,n,e,s)=>(x(u,n,"write to private field"),s?s.call(u,e):n.set(u,e),e),a=(u,n,e)=>(x(u,n,"access private method"),e);const f=require("./webserial-core-DlH0cFSH.cjs");function j(u=100){return new Promise(n=>setTimeout(()=>n(),u))}function q(){return"serial"in navigator}function J(){return"geolocation"in navigator}function H(){return"crypto"in window}function K(u=1){return u*1e3}function W(u){return u==null||u===""}var k,M,r,N,U,o,F,m,h,C,l,T,S;const t=class t{static status(n=null){var s,i;if(!a(s=t,r,o).call(s,n))return!1;let e=[];switch(g(t,k)){case"locker":e=["0","8"];break;case"boardroid":e=["2",(5+g(t,M)).toString(16).toUpperCase()];break;case"jofemar":e=["6"];break;default:return!1}a(i=t,r,l).call(i,e)}static dispensed(n=null){var s,i;if(!a(s=t,r,o).call(s,n))return!1;let e=[];switch(g(t,k)){case"locker":e=["0","7","4","4","4"];break;case"boardroid":e=["2","D7","A","0","0","0","0","0","0","0","0","0","F2"];break;case"jofemar":e=["6","30"];break;default:return!1}a(i=t,r,l).call(i,e)}static notDispensed(n=null){var s,i;if(!a(s=t,r,o).call(s,n))return!1;let e=[];switch(g(t,k)){case"locker":e=["0","7","5","5","5"];break;case"boardroid":e=["2","D7","A","0","0","1","0","0","0","0","0","0","F2"];break;case"jofemar":e=["6","34"];break;default:return!1}a(i=t,r,l).call(i,e)}static gateInactive(n=null){var e;if(!a(e=t,r,o).call(e,n)||!a(this,r,F).call(this))return!1;a(this,r,l).call(this,["0","7","5","5","5"])}static gateConfigured(n=null){var e;if(!a(e=t,r,o).call(e,n)||!a(this,r,F).call(this))return!1;a(this,r,l).call(this,["0","6"])}static keyPressed(n=null){var c,b,p;if(!a(c=t,r,o).call(c,n)||!a(b=t,r,h).call(b))return!1;const e=["30","31","32","33","34","35","36","37","38","39","2A","23","41","42","43","44"],s=(128+g(t,M)).toString(16),i=Math.floor(Math.random()*15);a(p=t,r,l).call(p,["2",s,"54",e[i]])}static doorOpened(n=null){var i,c;if(!a(i=t,r,o).call(i,n)||!a(this,r,C).call(this))return!1;let e=[];const s=(128+g(t,M)).toString(16);switch(g(t,k)){case"boardroid":e=["2","D8","dc"];break;case"jofemar":e=["2",s,"50","4F"];break}a(c=t,r,l).call(c,e)}static doorClosed(n=null){var i,c;if(!a(i=t,r,o).call(i,n)||!a(this,r,C).call(this))return!1;let e=[];const s=(128+g(t,M)).toString(16);switch(g(t,k)){case"boardroid":e=["2","D8","db"];break;case"jofemar":e=["2",s,"50","43"];break}a(c=t,r,l).call(c,e)}static channelDisconnected(n=null){var s,i,c;if(!a(s=t,r,o).call(s,n)||!a(i=t,r,h).call(i))return!1;const e=(128+g(t,M)).toString(16);a(c=t,r,l).call(c,["2",e,"43","43","43","FD"])}static channelConnected(n=null){var s,i,c;if(!a(s=t,r,o).call(s,n)||!a(i=t,r,h).call(i))return!1;const e=(128+g(t,M)).toString(16);a(c=t,r,l).call(c,["2",e,"43","43","43","FC"])}static channelEmpty(n=null){var s,i,c;if(!a(s=t,r,o).call(s,n)||!a(i=t,r,h).call(i))return!1;const e=(128+g(t,M)).toString(16);a(c=t,r,l).call(c,["2",e,"43","43","43","FF"])}static workingTemperature(n=null){var s,i,c;if(!a(s=t,r,o).call(s,n)||!a(i=t,r,h).call(i))return!1;const e=(128+g(t,M)).toString(16);a(c=t,r,l).call(c,["2",e,"43","54","16"])}static currentTemperature(n=null){var i,c,b;if(!a(i=t,r,o).call(i,n)||!a(c=t,r,C).call(c))return!1;let e=[];const s=(128+g(t,M)).toString(16);switch(g(t,k)){case"boardroid":e=["2","D9","44","30"];break;case"jofemar":e=["2",s,"43","74","2B","30","39","2E","31","7F","43"];break}a(b=t,r,l).call(b,e)}static ready(n=null){var e,s,i;if(!a(e=t,r,o).call(e,n)||!a(s=t,r,h).call(s))return!1;a(i=t,r,l).call(i,["6","30"])}static busy(n=null){var e,s,i;if(!a(e=t,r,o).call(e,n)||!a(s=t,r,h).call(s))return!1;a(i=t,r,l).call(i,["6","31"])}static invalidTray(n=null){var e,s,i;if(!a(e=t,r,o).call(e,n)||!a(s=t,r,h).call(s))return!1;a(i=t,r,l).call(i,["6","32"])}static invalidChannel(n=null){var e,s,i;if(!a(e=t,r,o).call(e,n)||!a(s=t,r,h).call(s))return!1;a(i=t,r,l).call(i,["6","33"])}static emptyChannel(n=null){var e,s,i;if(!a(e=t,r,o).call(e,n)||!a(s=t,r,h).call(s))return!1;a(i=t,r,l).call(i,["6","34"])}static elevatorJam(n=null){var e,s,i;if(!a(e=t,r,o).call(e,n)||!a(s=t,r,h).call(s))return!1;a(i=t,r,l).call(i,["6","35"])}static elevatorMalfunction(n=null){var e,s,i;if(!a(e=t,r,o).call(e,n)||!a(s=t,r,h).call(s))return!1;a(i=t,r,l).call(i,["6","36"])}static phototransistorFailure(n=null){var e,s,i;if(!a(e=t,r,o).call(e,n)||!a(s=t,r,h).call(s))return!1;a(i=t,r,l).call(i,["6","37"])}static allChannelsEmpty(n=null){var e,s,i;if(!a(e=t,r,o).call(e,n)||!a(s=t,r,h).call(s))return!1;a(i=t,r,l).call(i,["6","38"])}static productDetectorFailure(n=null){var e,s,i;if(!a(e=t,r,o).call(e,n)||!a(s=t,r,h).call(s))return!1;a(i=t,r,l).call(i,["6","39"])}static displayDisconnected(n=null){var e,s,i;if(!a(e=t,r,o).call(e,n)||!a(s=t,r,h).call(s))return!1;a(i=t,r,l).call(i,["6","41"])}static productUnderElevator(n=null){var e,s,i;if(!a(e=t,r,o).call(e,n)||!a(s=t,r,h).call(s))return!1;a(i=t,r,l).call(i,["6","42"])}static elevatorSettingAlarm(n=null){var e,s,i;if(!a(e=t,r,o).call(e,n)||!a(s=t,r,h).call(s))return!1;a(i=t,r,l).call(i,["6","43"])}static buttonPanelFailure(n=null){var e,s,i;if(!a(e=t,r,o).call(e,n)||!a(s=t,r,h).call(s))return!1;a(i=t,r,l).call(i,["6","44"])}static errorWritingEeprom(n=null){var e,s,i;if(!a(e=t,r,o).call(e,n)||!a(s=t,r,h).call(s))return!1;a(i=t,r,l).call(i,["6","45"])}static errorControlTemperature(n=null){var e,s,i;if(!a(e=t,r,o).call(e,n)||!a(s=t,r,h).call(s))return!1;a(i=t,r,l).call(i,["6","46"])}static thermometerDisconnected(n=null){var e,s,i;if(!a(e=t,r,o).call(e,n)||!a(s=t,r,h).call(s))return!1;a(i=t,r,l).call(i,["6","47"])}static thermometerMisconfigured(n=null){var e,s,i;if(!a(e=t,r,o).call(e,n)||!a(s=t,r,h).call(s))return!1;a(i=t,r,l).call(i,["6","48"])}static thermometerFailure(n=null){var e,s,i;if(!a(e=t,r,o).call(e,n)||!a(s=t,r,h).call(s))return!1;a(i=t,r,l).call(i,["6","49"])}static errorExtractorConsumption(n=null){var e,s,i;if(!a(e=t,r,o).call(e,n)||!a(s=t,r,h).call(s))return!1;a(i=t,r,l).call(i,["6","4A"])}static channelSearchError(n=null){var e,s,i;if(!a(e=t,r,o).call(e,n)||!a(s=t,r,h).call(s))return!1;a(i=t,r,l).call(i,["6","4B"])}static productExitMouthSearchError(n=null){var e,s,i;if(!a(e=t,r,o).call(e,n)||!a(s=t,r,h).call(s))return!1;a(i=t,r,l).call(i,["6","4C"])}static elevatorInteriorLocked(n=null){var e,s,i;if(!a(e=t,r,o).call(e,n)||!a(s=t,r,h).call(s))return!1;a(i=t,r,l).call(i,["6","4D"])}static productDetectorVerifierError(n=null){var e,s,i;if(!a(e=t,r,o).call(e,n)||!a(s=t,r,h).call(s))return!1;a(i=t,r,l).call(i,["6","4E"])}static waitingForProductRecall(n=null){var e,s,i;if(!a(e=t,r,o).call(e,n)||!a(s=t,r,h).call(s))return!1;a(i=t,r,l).call(i,["6","4F"])}static productExpiredByTemperature(n=null){var e,s,i;if(!a(e=t,r,o).call(e,n)||!a(s=t,r,h).call(s))return!1;a(i=t,r,l).call(i,["6","50"])}static faultyAutomaticDoor(n=null){var e,s,i;if(!a(e=t,r,o).call(e,n)||!a(s=t,r,h).call(s))return!1;a(i=t,r,l).call(i,["6","51"])}static rejectLever(n=null){var e,s,i;if(!a(e=t,r,o).call(e,n)||!a(s=t,r,m).call(s))return!1;a(i=t,r,l).call(i,["2","A0","1"])}static resetCoinPurse(n=null){var e,s,i;if(!a(e=t,r,o).call(e,n)||!a(s=t,r,m).call(s))return!1;a(i=t,r,l).call(i,["2","A0","2"])}static coinInsertedBox(n=null,e=null){var c,b,p,d;if(!a(c=t,r,o).call(c,n)||!a(b=t,r,m).call(b))return!1;const s=["40","41","42","43","44","45"],i=a(p=t,r,T).call(p,s,e);a(d=t,r,l).call(d,["2","A0",i])}static coinInsertedTube(n=null,e=null){var c,b,p,d;if(!a(c=t,r,o).call(c,n)||!a(b=t,r,m).call(b))return!1;const s=["50","51","52","53","54","55"],i=a(p=t,r,T).call(p,s,e);a(d=t,r,l).call(d,["2","A0",i])}static banknoteInsertedStacker(n=null,e=null){var c,b,p,d;if(!a(c=t,r,o).call(c,n)||!a(b=t,r,m).call(b))return!1;const s=["80","81","82","83","84"],i=a(p=t,r,S).call(p,s,e);a(d=t,r,l).call(d,["2","B0",i])}static banknoteInsertedEscrow(n=null,e=null){var c,b,p,d;if(!a(c=t,r,o).call(c,n)||!a(b=t,r,m).call(b))return!1;const s=["90","91","92","93","94"],i=a(p=t,r,S).call(p,s,e);a(d=t,r,l).call(d,["2","B0",i])}static banknoteEjected(n=null,e=null){var c,b,p,d;if(!a(c=t,r,o).call(c,n)||!a(b=t,r,m).call(b))return!1;const s=["A0","A1","A2","A3","A4"],i=a(p=t,r,S).call(p,s,e);a(d=t,r,l).call(d,["2","B0",i])}static banknoteInsertedRecycler(n=null,e=null){var c,b,p,d;if(!a(c=t,r,o).call(c,n)||!a(b=t,r,m).call(b))return!1;const s=["B0","B1","B2","B3","B4"],i=a(p=t,r,S).call(p,s,e);a(d=t,r,l).call(d,["2","B0",i])}static banknoteTaken(n=null){var e,s,i;if(!a(e=t,r,o).call(e,n)||!a(s=t,r,m).call(s))return!1;a(i=t,r,l).call(i,["2","B0","2a"])}static coinPurseEnabled(n=null){var e,s,i;if(!a(e=t,r,o).call(e,n)||!a(s=t,r,m).call(s))return!1;a(i=t,r,l).call(i,["2","D0","1"])}static coinPurseDisabled(n=null){var e,s,i;if(!a(e=t,r,o).call(e,n)||!a(s=t,r,m).call(s))return!1;a(i=t,r,l).call(i,["2","D0","0"])}static billPurseDisabled(n=null){var e,s,i;if(!a(e=t,r,o).call(e,n)||!a(s=t,r,m).call(s))return!1;a(i=t,r,l).call(i,["2","D1","0","0"])}static billPurseEnabled(n=null){var e,s,i;if(!a(e=t,r,o).call(e,n)||!a(s=t,r,m).call(s))return!1;a(i=t,r,l).call(i,["2","D1","1","1"])}static readTubes(n=null){var y,D,w;if(!a(y=t,r,o).call(y,n)||!a(D=t,r,m).call(D))return!1;const e=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f"],[s,i,c,b,p,d]=[e[Math.floor(Math.random()*30)],e[Math.floor(Math.random()*30)],e[Math.floor(Math.random()*30)],e[Math.floor(Math.random()*30)],e[Math.floor(Math.random()*30)],e[Math.floor(Math.random()*30)]];a(w=t,r,l).call(w,["2","D2",s,i,c,b,p,d])}static readBillPurse(n=null,e=null){var i,c,b,p;if(!a(i=t,r,o).call(i,n)||!a(c=t,r,m).call(c))return!1;let s=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c"];if(n._recycler.ict){const d=s[Math.floor(Math.random()*31)];let y="0",D="0",w="0",v="0",_="0";if(e!==null&&!isNaN(parseInt(e)))switch(e.toString()){case"20":y=d;break;case"50":D=d;break;case"100":w=d;break;case"200":v=d;break;case"500":_=d;break}else switch(n._recycler.bill){case 0:y=d;break;case 1:D=d;break;case 2:w=d;break;case 3:v=d;break;case 4:_=d;break}a(b=t,r,l).call(b,["2","D3",y,D,w,v,_,"0"])}else{const[d,y,D,w,v,_]=[s[Math.floor(Math.random()*30)],s[Math.floor(Math.random()*30)],s[Math.floor(Math.random()*30)],s[Math.floor(Math.random()*2)],s[Math.floor(Math.random())],s[Math.floor(Math.random())]];a(p=t,r,l).call(p,["2","D3",d,y,D,w,v,_])}}static banknoteAccepted(n=null){var e,s,i;if(!a(e=t,r,o).call(e,n)||!a(s=t,r,m).call(s))return!1;a(i=t,r,l).call(i,["2","D4","1"])}static banknoteRejected(n=null){var e,s,i;if(!a(e=t,r,o).call(e,n)||!a(s=t,r,m).call(s))return!1;a(i=t,r,l).call(i,["2","D4","0"])}static banknotesDispensed(n=null){var s,i,c,b;if(!a(s=t,r,o).call(s,n)||!a(i=t,r,m).call(i))return!1;let e=["1","2","3","4","5","6","7","8","9","a","b","c","d","e","f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c"];if(n._recycler.ict){const p=e[Math.floor(Math.random()*30)];let d="0",y="0",D="0",w="0",v="0";switch(n._recycler.bill){case 0:d=p;break;case 1:y=p;break;case 2:D=p;break;case 3:w=p;break;case 4:v=p;break}a(c=t,r,l).call(c,["2","D5",d,y,D,w,v,"0"])}else{const[p,d,y,D,w,v]=[e[Math.floor(Math.random()*30)],e[Math.floor(Math.random()*30)],e[Math.floor(Math.random()*30)],e[Math.floor(Math.random()*2)],e[Math.floor(Math.random())],e[Math.floor(Math.random())]];a(b=t,r,l).call(b,["2","D5",p,d,y,D,w,v])}}static coinsDispensed(n=null){var e,s,i;if(!a(e=t,r,o).call(e,n)||!a(s=t,r,m).call(s))return!1;a(i=t,r,l).call(i,["2","D6"])}static relayOn(n=null){var e,s,i;if(!a(e=t,r,o).call(e,n)||!a(s=t,r,m).call(s))return!1;a(i=t,r,l).call(i,["2","DA","1"])}static relayOff(n=null){var e,s,i;if(!a(e=t,r,o).call(e,n)||!a(s=t,r,m).call(s))return!1;a(i=t,r,l).call(i,["2","DA","0"])}static nayaxEnabled(n=null){var e,s,i;if(!a(e=t,r,o).call(e,n)||!a(s=t,r,m).call(s))return!1;a(i=t,r,l).call(i,["2","DD","1"])}static nayaxDisabled(n=null){var e,s,i;if(!a(e=t,r,o).call(e,n)||!a(s=t,r,m).call(s))return!1;a(i=t,r,l).call(i,["2","DD","0"])}static nayaxPreCreditAuthorized(n=null){var e,s,i;if(!a(e=t,r,o).call(e,n)||!a(s=t,r,m).call(s))return!1;a(i=t,r,l).call(i,["2","DD","3"])}static nayaxCancelRequest(n=null){var e,s,i;if(!a(e=t,r,o).call(e,n)||!a(s=t,r,m).call(s))return!1;a(i=t,r,l).call(i,["2","DD","4"])}static nayaxSellApproved(n=null){var e,s,i;if(!a(e=t,r,o).call(e,n)||!a(s=t,r,m).call(s))return!1;a(i=t,r,l).call(i,["2","DD","5"])}static nayaxSellDenied(n=null){var e,s,i;if(!a(e=t,r,o).call(e,n)||!a(s=t,r,m).call(s))return!1;a(i=t,r,l).call(i,["2","DD","6"])}static nayaxEndSession(n=null){var e,s,i;if(!a(e=t,r,o).call(e,n)||!a(s=t,r,m).call(s))return!1;a(i=t,r,l).call(i,["2","DD","7"])}static nayaxCancelled(n=null){var e,s,i;if(!a(e=t,r,o).call(e,n)||!a(s=t,r,m).call(s))return!1;a(i=t,r,l).call(i,["2","DD","8"])}static nayaxDispensed(n=null){var e,s,i;if(!a(e=t,r,o).call(e,n)||!a(s=t,r,m).call(s))return!1;a(i=t,r,l).call(i,["2","DD","A","0"])}static nayaxNotDispensed(n=null){var e,s,i;if(!a(e=t,r,o).call(e,n)||!a(s=t,r,m).call(s))return!1;a(i=t,r,l).call(i,["2","DD","A","1"])}static fullTray(n=null){var e,s,i;if(!a(e=t,r,o).call(e,n)||!a(s=t,r,h).call(s))return!1;a(i=t,r,l).call(i,["6","4F"])}static setConnection(n=null){var e;if(!a(e=t,r,o).call(e,n))return!1;n.__internal__.serial.connected=!0}};k=new WeakMap,M=new WeakMap,r=new WeakSet,N=function(){if(t.enable===!1)throw new Error("Emulator is disabled");return t.enable},U=function(n){if(typeof n!="object"||!(n instanceof O))throw new Error(`Type ${n.typeDevice} is not supported`);return t.instance=n,E(t,k,n.typeDevice),E(t,M,n.deviceNumber),!0},o=function(n=null){var e,s;return!a(e=t,r,N).call(e)||n===null&&t.instance===null?!1:(t.instance===null&&a(s=t,r,U).call(s,n),!0)},F=function(){if(g(t,k)!=="locker")throw new Error("This function is only available for Locker devices");return!0},m=function(){if(g(t,k)!=="boardroid")throw new Error("This function is only available for Boardroid devices");return!0},h=function(){if(g(t,k)!=="jofemar")throw new Error("This function is only available for Jofemar devices");return!0},C=function(){if(g(t,k)==="locker")throw new Error("This function is not available for Locker devices");return!0},l=function(n){t.instance.__emulate({code:n})},T=function(n,e=null){let s=n[Math.floor(Math.random()*5)];if(e!==null&&!isNaN(parseFloat(e)))switch(e.toString()){case"0.5":s=n[1];break;case"1":s=n[2];break;case"2":s=n[3];break;case"5":s=n[4];break;case"10":s=n[5];break}return s},S=function(n,e=null){let s=n[Math.floor(Math.random()*4)];if(e!==null&&!isNaN(parseFloat(e)))switch(e.toString()){case"20":s=n[0];break;case"50":s=n[1];break;case"100":s=n[2];break;case"200":s=n[3];break;case"500":s=n[4];break}return s},B(t,r),P(t,"enable",!1),P(t,"instance",null),B(t,k,null),B(t,M,1);let A=t;f.h.instance||(f.h.instance=new f.h);const G={relay:[],locker:[],jofemar:[],boardroid:[],arduino:[],pinpad:[],pinpax:[]};f.h.devices={...f.h.devices,...G};f.h.addCustom=(u,n)=>{f.h.registerType(u),f.h.add(n)};f.h.getCustomByUuid=(u,n)=>f.h.get(u,n);f.h.getJofemarByUuid=u=>f.h.get("jofemar",u);f.h.getLockerByUuid=u=>f.h.get("locker",u);f.h.getRelayByUuid=u=>f.h.get("relay",u);f.h.getBoardroidByUuid=u=>f.h.get("boardroid",u);f.h.getArduinoByUuid=u=>f.h.get("arduino",u);f.h.getPinPadByUuid=u=>f.h.get("pinpad",u);f.h.getPinPaxByUuid=u=>f.h.get("pinpax",u);f.h.getHopperByUuid=u=>f.h.get("hopper",u);f.h.getJofemar=(u=1)=>f.h.getByNumber("jofemar",u);f.h.getBoardroid=(u=1)=>f.h.getByNumber("boardroid",u);f.h.getLocker=(u=1)=>f.h.getByNumber("locker",u);f.h.getRelay=(u=1)=>f.h.getByNumber("relay",u);f.h.getArduino=(u=1)=>f.h.getByNumber("arduino",u);f.h.getPinPad=(u=1)=>f.h.getByNumber("pinpad",u);f.h.getPinPax=(u=1)=>f.h.getByNumber("pinpax",u);f.h.getHopper=(u=1)=>f.h.getByNumber("hopper",u);class O extends f.K{constructor(n){super(n),this.__internal__=structuredClone(this.__internal__),this.getResponseAsArrayHex(),this.__internal__.device.door_open=!1,this.__internal__.time.response_engines=2e3,this.__internal__.time.sense=100,this.__internal__.interval.waiting_sense=0,this.__internal__.dispense={must_response:!1,dispensing:!1,status:null,counter:0,limit_counter:20,custom_limit_counter:null,backup_dispense:{}}}get isDoorOpen(){return this.__internal__.device.door_open}get isDispensing(){return this.__internal__.interval.waiting_sense||this.__internal__.dispense.dispensing}async timeout(n,e){await super.timeout(n,e),e==="dispense"&&(this.__internal__.dispense.status="no-response")}async serialPortsSaved(n){const e=this.serialFilters;if(this.__internal__.aux_port_connector<n.length){const s=this.__internal__.aux_port_connector;this.__internal__.serial.port=n[s]}else this.__internal__.aux_port_connector=0,this.__internal__.serial.port=await navigator.serial.requestPort({filters:e});if(!this.__internal__.serial.port)throw new Error("Select another port please")}internalClearSensing(){this.__internal__.interval.waiting_sense&&clearInterval(this.__internal__.interval.waiting_sense),this.__internal__.interval.waiting_sense=0,this.__internal__.dispense.status=null,this.__internal__.dispense.counter=0,this.__internal__.dispense.dispensing=!1}internalDispensingProcess(){let n=this.__internal__.dispense.limit_counter;return this.__internal__.dispense.custom_limit_counter&&(n=this.__internal__.dispense.custom_limit_counter),n+=Math.ceil(n*.6),this.__internal__.dispense.counter>=n?(this.internalClearSensing(),this.__internal__.dispense.status=!1,this.__internal__.dispense.dispensing=!1,!1):(this.__internal__.dispense.counter=parseFloat((.1+this.__internal__.dispense.counter).toFixed(1)),this.__internal__.dispense.counter%1===0&&this.dispatch("dispensing",{status:this.__internal__.dispense.status,counter:this.__internal__.dispense.counter,limit:n}),null)}async internalDispenseStatus(){if(this.__internal__.dispense.must_response&&(await j(this.__internal__.time.response_engines+10),this.__internal__.dispense.status==="no-response"))return this.internalClearSensing(),this.__internal__.dispense.status=!1,this.dispatch("not-dispensed",{reason:"no-response"}),{status:!1,error:"no-response"};this.__internal__.dispense.status=null,this.__internal__.dispense.dispensing=!0,this.dispatch("internal:dispense:running",{});const n=this;return new Promise(e=>{this.__internal__.interval.waiting_sense=setInterval(()=>{switch(n.__internal__.dispense.status){case null:n.internalDispensingProcess()===!1&&(n.internalClearSensing(),n.dispatch("not-dispensed",{reason:"timeout"}),e({status:!1,error:"timeout"}));break;case!0:n.internalClearSensing(),n.__internal__.dispense.status=!0,n.dispatch("dispensed",{}),e({status:!0,error:null});break;case!1:n.internalClearSensing(),n.__internal__.dispense.status=!1,n.dispatch("not-dispensed",{reason:"no-stock"}),e({status:!1,error:null});break;case"elevator-locked":n.internalClearSensing(),n.__internal__.dispense.status=!1,n.dispatch("not-dispensed",{reason:"elevator-locked"}),e({status:!1,error:"elevator-locked"});break;case"no-response":n.internalClearSensing(),n.__internal__.dispense.status=!1,n.dispatch("not-dispensed",{reason:"no-response"}),e({status:!1,error:"no-response"});break}},this.__internal__.time.sense)})}async internalDispense(n){if(this.isDispensing)throw new Error("Another dispensing process is running");if(!A.enable&&!this.__internal__.serial.connected&&(await this.serialConnect(),!this.__internal__.serial.connected))throw new Error("Serial device not connected");return this.__internal__.serial.queue.length===0?(await this.appendToQueue(n,"dispense"),await this.internalDispenseStatus()):new Promise(e=>{const s=setInterval(async()=>{if(this.__internal__.serial.queue.length>0)return;clearInterval(s),await this.appendToQueue(n,"dispense");const i=await this.internalDispenseStatus();e(i)},100)})}__emulate(n){if(typeof n.code!="object"){console.error("Invalid data to make an emulation");return}this.__internal__.serial.connected||(this.__internal__.serial.connected=!0,this.dispatch("serial:connected"),f.h.instance.dispatch("change"),this.__internal__.interval.reconnection&&(clearInterval(this.__internal__.interval.reconnection),this.__internal__.interval.reconnection=0)),this.__internal__.timeout.until_response&&(clearTimeout(this.__internal__.timeout.until_response),this.__internal__.timeout.until_response=0);const e=[];for(const s in n.code)e.push(n.code[s].toString().padStart(2,"0").toLowerCase());this.serialMessage(e)}set listenOnPort(n){this.listenOnChannel=n}get listenOnPort(){return this.__internal__.device.listen_on_port??1}}exports.Emulator=A;exports.Kernel=O;exports.getSeconds=K;exports.isEmpty=W;exports.supportCrypto=H;exports.supportGeolocation=J;exports.supportWebSerial=q;exports.wait=j;
1
+ "use strict";var L=Object.defineProperty;var I=u=>{throw TypeError(u)};var R=(u,n,e)=>n in u?L(u,n,{enumerable:!0,configurable:!0,writable:!0,value:e}):u[n]=e;var P=(u,n,e)=>R(u,typeof n!="symbol"?n+"":n,e),x=(u,n,e)=>n.has(u)||I("Cannot "+e);var g=(u,n,e)=>(x(u,n,"read from private field"),e?e.call(u):n.get(u)),B=(u,n,e)=>n.has(u)?I("Cannot add the same private member more than once"):n instanceof WeakSet?n.add(u):n.set(u,e),E=(u,n,e,s)=>(x(u,n,"write to private field"),s?s.call(u,e):n.set(u,e),e),a=(u,n,e)=>(x(u,n,"access private method"),e);const f=require("./webserial-core-DlH0cFSH.cjs");function j(u=100){return new Promise(n=>setTimeout(()=>n(),u))}function q(){return"serial"in navigator}function J(){return"geolocation"in navigator}function H(){return"crypto"in window}function K(u=1){return u*1e3}function W(u){return u==null||u===""}var k,M,r,N,U,o,F,m,h,C,l,T,S;const t=class t{static status(n=null){var s,i;if(!a(s=t,r,o).call(s,n))return!1;let e=[];switch(g(t,k)){case"locker":e=["0","8"];break;case"boardroid":e=["2",(5+g(t,M)).toString(16).toUpperCase()];break;case"jofemar":e=["6"];break;default:return!1}a(i=t,r,l).call(i,e)}static dispensed(n=null){var s,i;if(!a(s=t,r,o).call(s,n))return!1;let e=[];switch(g(t,k)){case"locker":e=["0","7","4","4","4"];break;case"boardroid":e=["2","D7","A","0","0","0","0","0","0","0","0","0","F2"];break;case"jofemar":e=["6","30"];break;default:return!1}a(i=t,r,l).call(i,e)}static notDispensed(n=null){var s,i;if(!a(s=t,r,o).call(s,n))return!1;let e=[];switch(g(t,k)){case"locker":e=["0","7","5","5","5"];break;case"boardroid":e=["2","D7","A","0","0","1","0","0","0","0","0","0","F2"];break;case"jofemar":e=["6","34"];break;default:return!1}a(i=t,r,l).call(i,e)}static gateInactive(n=null){var e;if(!a(e=t,r,o).call(e,n)||!a(this,r,F).call(this))return!1;a(this,r,l).call(this,["0","7","5","5","5"])}static gateConfigured(n=null){var e;if(!a(e=t,r,o).call(e,n)||!a(this,r,F).call(this))return!1;a(this,r,l).call(this,["0","6"])}static keyPressed(n=null){var c,b,p;if(!a(c=t,r,o).call(c,n)||!a(b=t,r,h).call(b))return!1;const e=["30","31","32","33","34","35","36","37","38","39","2A","23","41","42","43","44"],s=(128+g(t,M)).toString(16),i=Math.floor(Math.random()*15);a(p=t,r,l).call(p,["2",s,"54",e[i]])}static doorOpened(n=null){var i,c;if(!a(i=t,r,o).call(i,n)||!a(this,r,C).call(this))return!1;let e=[];const s=(128+g(t,M)).toString(16);switch(g(t,k)){case"boardroid":e=["2","D8","dc"];break;case"jofemar":e=["2",s,"50","4F"];break}a(c=t,r,l).call(c,e)}static doorClosed(n=null){var i,c;if(!a(i=t,r,o).call(i,n)||!a(this,r,C).call(this))return!1;let e=[];const s=(128+g(t,M)).toString(16);switch(g(t,k)){case"boardroid":e=["2","D8","db"];break;case"jofemar":e=["2",s,"50","43"];break}a(c=t,r,l).call(c,e)}static channelDisconnected(n=null){var s,i,c;if(!a(s=t,r,o).call(s,n)||!a(i=t,r,h).call(i))return!1;const e=(128+g(t,M)).toString(16);a(c=t,r,l).call(c,["2",e,"43","43","43","FD"])}static channelConnected(n=null){var s,i,c;if(!a(s=t,r,o).call(s,n)||!a(i=t,r,h).call(i))return!1;const e=(128+g(t,M)).toString(16);a(c=t,r,l).call(c,["2",e,"43","43","43","FC"])}static channelEmpty(n=null){var s,i,c;if(!a(s=t,r,o).call(s,n)||!a(i=t,r,h).call(i))return!1;const e=(128+g(t,M)).toString(16);a(c=t,r,l).call(c,["2",e,"43","43","43","FF"])}static workingTemperature(n=null){var s,i,c;if(!a(s=t,r,o).call(s,n)||!a(i=t,r,h).call(i))return!1;const e=(128+g(t,M)).toString(16);a(c=t,r,l).call(c,["2",e,"43","54","16"])}static currentTemperature(n=null){var i,c,b;if(!a(i=t,r,o).call(i,n)||!a(c=t,r,C).call(c))return!1;let e=[];const s=(128+g(t,M)).toString(16);switch(g(t,k)){case"boardroid":e=["2","D9","44","30"];break;case"jofemar":e=["2",s,"43","74","2B","30","39","2E","31","7F","43"];break}a(b=t,r,l).call(b,e)}static ready(n=null){var e,s,i;if(!a(e=t,r,o).call(e,n)||!a(s=t,r,h).call(s))return!1;a(i=t,r,l).call(i,["6","30"])}static busy(n=null){var e,s,i;if(!a(e=t,r,o).call(e,n)||!a(s=t,r,h).call(s))return!1;a(i=t,r,l).call(i,["6","31"])}static invalidTray(n=null){var e,s,i;if(!a(e=t,r,o).call(e,n)||!a(s=t,r,h).call(s))return!1;a(i=t,r,l).call(i,["6","32"])}static invalidChannel(n=null){var e,s,i;if(!a(e=t,r,o).call(e,n)||!a(s=t,r,h).call(s))return!1;a(i=t,r,l).call(i,["6","33"])}static emptyChannel(n=null){var e,s,i;if(!a(e=t,r,o).call(e,n)||!a(s=t,r,h).call(s))return!1;a(i=t,r,l).call(i,["6","34"])}static elevatorJam(n=null){var e,s,i;if(!a(e=t,r,o).call(e,n)||!a(s=t,r,h).call(s))return!1;a(i=t,r,l).call(i,["6","35"])}static elevatorMalfunction(n=null){var e,s,i;if(!a(e=t,r,o).call(e,n)||!a(s=t,r,h).call(s))return!1;a(i=t,r,l).call(i,["6","36"])}static phototransistorFailure(n=null){var e,s,i;if(!a(e=t,r,o).call(e,n)||!a(s=t,r,h).call(s))return!1;a(i=t,r,l).call(i,["6","37"])}static allChannelsEmpty(n=null){var e,s,i;if(!a(e=t,r,o).call(e,n)||!a(s=t,r,h).call(s))return!1;a(i=t,r,l).call(i,["6","38"])}static productDetectorFailure(n=null){var e,s,i;if(!a(e=t,r,o).call(e,n)||!a(s=t,r,h).call(s))return!1;a(i=t,r,l).call(i,["6","39"])}static displayDisconnected(n=null){var e,s,i;if(!a(e=t,r,o).call(e,n)||!a(s=t,r,h).call(s))return!1;a(i=t,r,l).call(i,["6","41"])}static productUnderElevator(n=null){var e,s,i;if(!a(e=t,r,o).call(e,n)||!a(s=t,r,h).call(s))return!1;a(i=t,r,l).call(i,["6","42"])}static elevatorSettingAlarm(n=null){var e,s,i;if(!a(e=t,r,o).call(e,n)||!a(s=t,r,h).call(s))return!1;a(i=t,r,l).call(i,["6","43"])}static buttonPanelFailure(n=null){var e,s,i;if(!a(e=t,r,o).call(e,n)||!a(s=t,r,h).call(s))return!1;a(i=t,r,l).call(i,["6","44"])}static errorWritingEeprom(n=null){var e,s,i;if(!a(e=t,r,o).call(e,n)||!a(s=t,r,h).call(s))return!1;a(i=t,r,l).call(i,["6","45"])}static errorControlTemperature(n=null){var e,s,i;if(!a(e=t,r,o).call(e,n)||!a(s=t,r,h).call(s))return!1;a(i=t,r,l).call(i,["6","46"])}static thermometerDisconnected(n=null){var e,s,i;if(!a(e=t,r,o).call(e,n)||!a(s=t,r,h).call(s))return!1;a(i=t,r,l).call(i,["6","47"])}static thermometerMisconfigured(n=null){var e,s,i;if(!a(e=t,r,o).call(e,n)||!a(s=t,r,h).call(s))return!1;a(i=t,r,l).call(i,["6","48"])}static thermometerFailure(n=null){var e,s,i;if(!a(e=t,r,o).call(e,n)||!a(s=t,r,h).call(s))return!1;a(i=t,r,l).call(i,["6","49"])}static errorExtractorConsumption(n=null){var e,s,i;if(!a(e=t,r,o).call(e,n)||!a(s=t,r,h).call(s))return!1;a(i=t,r,l).call(i,["6","4A"])}static channelSearchError(n=null){var e,s,i;if(!a(e=t,r,o).call(e,n)||!a(s=t,r,h).call(s))return!1;a(i=t,r,l).call(i,["6","4B"])}static productExitMouthSearchError(n=null){var e,s,i;if(!a(e=t,r,o).call(e,n)||!a(s=t,r,h).call(s))return!1;a(i=t,r,l).call(i,["6","4C"])}static elevatorInteriorLocked(n=null){var e,s,i;if(!a(e=t,r,o).call(e,n)||!a(s=t,r,h).call(s))return!1;a(i=t,r,l).call(i,["6","4D"])}static productDetectorVerifierError(n=null){var e,s,i;if(!a(e=t,r,o).call(e,n)||!a(s=t,r,h).call(s))return!1;a(i=t,r,l).call(i,["6","4E"])}static waitingForProductRecall(n=null){var e,s,i;if(!a(e=t,r,o).call(e,n)||!a(s=t,r,h).call(s))return!1;a(i=t,r,l).call(i,["6","4F"])}static productExpiredByTemperature(n=null){var e,s,i;if(!a(e=t,r,o).call(e,n)||!a(s=t,r,h).call(s))return!1;a(i=t,r,l).call(i,["6","50"])}static faultyAutomaticDoor(n=null){var e,s,i;if(!a(e=t,r,o).call(e,n)||!a(s=t,r,h).call(s))return!1;a(i=t,r,l).call(i,["6","51"])}static rejectLever(n=null){var e,s,i;if(!a(e=t,r,o).call(e,n)||!a(s=t,r,m).call(s))return!1;a(i=t,r,l).call(i,["2","A0","1"])}static resetCoinPurse(n=null){var e,s,i;if(!a(e=t,r,o).call(e,n)||!a(s=t,r,m).call(s))return!1;a(i=t,r,l).call(i,["2","A0","2"])}static coinInsertedBox(n=null,e=null){var c,b,p,d;if(!a(c=t,r,o).call(c,n)||!a(b=t,r,m).call(b))return!1;const s=["40","41","42","43","44","45"],i=a(p=t,r,T).call(p,s,e);a(d=t,r,l).call(d,["2","A0",i])}static coinInsertedTube(n=null,e=null){var c,b,p,d;if(!a(c=t,r,o).call(c,n)||!a(b=t,r,m).call(b))return!1;const s=["50","51","52","53","54","55"],i=a(p=t,r,T).call(p,s,e);a(d=t,r,l).call(d,["2","A0",i])}static banknoteInsertedStacker(n=null,e=null){var c,b,p,d;if(!a(c=t,r,o).call(c,n)||!a(b=t,r,m).call(b))return!1;const s=["80","81","82","83","84"],i=a(p=t,r,S).call(p,s,e);a(d=t,r,l).call(d,["2","B0",i])}static banknoteInsertedEscrow(n=null,e=null){var c,b,p,d;if(!a(c=t,r,o).call(c,n)||!a(b=t,r,m).call(b))return!1;const s=["90","91","92","93","94"],i=a(p=t,r,S).call(p,s,e);a(d=t,r,l).call(d,["2","B0",i])}static banknoteEjected(n=null,e=null){var c,b,p,d;if(!a(c=t,r,o).call(c,n)||!a(b=t,r,m).call(b))return!1;const s=["A0","A1","A2","A3","A4"],i=a(p=t,r,S).call(p,s,e);a(d=t,r,l).call(d,["2","B0",i])}static banknoteInsertedRecycler(n=null,e=null){var c,b,p,d;if(!a(c=t,r,o).call(c,n)||!a(b=t,r,m).call(b))return!1;const s=["B0","B1","B2","B3","B4"],i=a(p=t,r,S).call(p,s,e);a(d=t,r,l).call(d,["2","B0",i])}static banknoteTaken(n=null){var e,s,i;if(!a(e=t,r,o).call(e,n)||!a(s=t,r,m).call(s))return!1;a(i=t,r,l).call(i,["2","B0","2a"])}static coinPurseEnabled(n=null){var e,s,i;if(!a(e=t,r,o).call(e,n)||!a(s=t,r,m).call(s))return!1;a(i=t,r,l).call(i,["2","D0","1"])}static coinPurseDisabled(n=null){var e,s,i;if(!a(e=t,r,o).call(e,n)||!a(s=t,r,m).call(s))return!1;a(i=t,r,l).call(i,["2","D0","0"])}static billPurseDisabled(n=null){var e,s,i;if(!a(e=t,r,o).call(e,n)||!a(s=t,r,m).call(s))return!1;a(i=t,r,l).call(i,["2","D1","0","0"])}static billPurseEnabled(n=null){var e,s,i;if(!a(e=t,r,o).call(e,n)||!a(s=t,r,m).call(s))return!1;a(i=t,r,l).call(i,["2","D1","1","1"])}static readTubes(n=null){var y,D,w;if(!a(y=t,r,o).call(y,n)||!a(D=t,r,m).call(D))return!1;const e=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f"],[s,i,c,b,p,d]=[e[Math.floor(Math.random()*30)],e[Math.floor(Math.random()*30)],e[Math.floor(Math.random()*30)],e[Math.floor(Math.random()*30)],e[Math.floor(Math.random()*30)],e[Math.floor(Math.random()*30)]];a(w=t,r,l).call(w,["2","D2",s,i,c,b,p,d])}static readBillPurse(n=null,e=null){var i,c,b,p;if(!a(i=t,r,o).call(i,n)||!a(c=t,r,m).call(c))return!1;let s=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c"];if(n._recycler.ict){const d=s[Math.floor(Math.random()*31)];let y="0",D="0",w="0",v="0",_="0";if(e!==null&&!isNaN(parseInt(e)))switch(e.toString()){case"20":y=d;break;case"50":D=d;break;case"100":w=d;break;case"200":v=d;break;case"500":_=d;break}else switch(n._recycler.bill){case 0:y=d;break;case 1:D=d;break;case 2:w=d;break;case 3:v=d;break;case 4:_=d;break}a(b=t,r,l).call(b,["2","D3",y,D,w,v,_,"0"])}else{const[d,y,D,w,v,_]=[s[Math.floor(Math.random()*30)],s[Math.floor(Math.random()*30)],s[Math.floor(Math.random()*30)],s[Math.floor(Math.random()*2)],s[Math.floor(Math.random())],s[Math.floor(Math.random())]];a(p=t,r,l).call(p,["2","D3",d,y,D,w,v,_])}}static banknoteAccepted(n=null){var e,s,i;if(!a(e=t,r,o).call(e,n)||!a(s=t,r,m).call(s))return!1;a(i=t,r,l).call(i,["2","D4","1"])}static banknoteRejected(n=null){var e,s,i;if(!a(e=t,r,o).call(e,n)||!a(s=t,r,m).call(s))return!1;a(i=t,r,l).call(i,["2","D4","0"])}static banknotesDispensed(n=null){var s,i,c,b;if(!a(s=t,r,o).call(s,n)||!a(i=t,r,m).call(i))return!1;let e=["1","2","3","4","5","6","7","8","9","a","b","c","d","e","f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c"];if(n._recycler.ict){const p=e[Math.floor(Math.random()*30)];let d="0",y="0",D="0",w="0",v="0";switch(n._recycler.bill){case 0:d=p;break;case 1:y=p;break;case 2:D=p;break;case 3:w=p;break;case 4:v=p;break}a(c=t,r,l).call(c,["2","D5",d,y,D,w,v,"0"])}else{const[p,d,y,D,w,v]=[e[Math.floor(Math.random()*30)],e[Math.floor(Math.random()*30)],e[Math.floor(Math.random()*30)],e[Math.floor(Math.random()*2)],e[Math.floor(Math.random())],e[Math.floor(Math.random())]];a(b=t,r,l).call(b,["2","D5",p,d,y,D,w,v])}}static coinsDispensed(n=null){var e,s,i;if(!a(e=t,r,o).call(e,n)||!a(s=t,r,m).call(s))return!1;a(i=t,r,l).call(i,["2","D6"])}static relayOn(n=null){var e,s,i;if(!a(e=t,r,o).call(e,n)||!a(s=t,r,m).call(s))return!1;a(i=t,r,l).call(i,["2","DA","1"])}static relayOff(n=null){var e,s,i;if(!a(e=t,r,o).call(e,n)||!a(s=t,r,m).call(s))return!1;a(i=t,r,l).call(i,["2","DA","0"])}static nayaxEnabled(n=null){var e,s,i;if(!a(e=t,r,o).call(e,n)||!a(s=t,r,m).call(s))return!1;a(i=t,r,l).call(i,["2","DD","1"])}static nayaxDisabled(n=null){var e,s,i;if(!a(e=t,r,o).call(e,n)||!a(s=t,r,m).call(s))return!1;a(i=t,r,l).call(i,["2","DD","0"])}static nayaxPreCreditAuthorized(n=null){var e,s,i;if(!a(e=t,r,o).call(e,n)||!a(s=t,r,m).call(s))return!1;a(i=t,r,l).call(i,["2","DD","3"])}static nayaxCancelRequest(n=null){var e,s,i;if(!a(e=t,r,o).call(e,n)||!a(s=t,r,m).call(s))return!1;a(i=t,r,l).call(i,["2","DD","4"])}static nayaxSellApproved(n=null){var e,s,i;if(!a(e=t,r,o).call(e,n)||!a(s=t,r,m).call(s))return!1;a(i=t,r,l).call(i,["2","DD","5"])}static nayaxSellDenied(n=null){var e,s,i;if(!a(e=t,r,o).call(e,n)||!a(s=t,r,m).call(s))return!1;a(i=t,r,l).call(i,["2","DD","6"])}static nayaxEndSession(n=null){var e,s,i;if(!a(e=t,r,o).call(e,n)||!a(s=t,r,m).call(s))return!1;a(i=t,r,l).call(i,["2","DD","7"])}static nayaxCancelled(n=null){var e,s,i;if(!a(e=t,r,o).call(e,n)||!a(s=t,r,m).call(s))return!1;a(i=t,r,l).call(i,["2","DD","8"])}static nayaxDispensed(n=null){var e,s,i;if(!a(e=t,r,o).call(e,n)||!a(s=t,r,m).call(s))return!1;a(i=t,r,l).call(i,["2","DD","A","0"])}static nayaxNotDispensed(n=null){var e,s,i;if(!a(e=t,r,o).call(e,n)||!a(s=t,r,m).call(s))return!1;a(i=t,r,l).call(i,["2","DD","A","1"])}static fullTray(n=null){var e,s,i;if(!a(e=t,r,o).call(e,n)||!a(s=t,r,h).call(s))return!1;a(i=t,r,l).call(i,["6","4F"])}static setConnection(n=null){var e;if(!a(e=t,r,o).call(e,n))return!1;n.__internal__.serial.connected=!0}};k=new WeakMap,M=new WeakMap,r=new WeakSet,N=function(){if(t.enable===!1)throw new Error("Emulator is disabled");return t.enable},U=function(n){if(typeof n!="object"||!(n instanceof O))throw new Error(`Type ${n.typeDevice} is not supported`);return t.instance=n,E(t,k,n.typeDevice),E(t,M,n.deviceNumber),!0},o=function(n=null){var e,s;return!a(e=t,r,N).call(e)||n===null&&t.instance===null?!1:(t.instance===null&&a(s=t,r,U).call(s,n),!0)},F=function(){if(g(t,k)!=="locker")throw new Error("This function is only available for Locker devices");return!0},m=function(){if(g(t,k)!=="boardroid")throw new Error("This function is only available for Boardroid devices");return!0},h=function(){if(g(t,k)!=="jofemar")throw new Error("This function is only available for Jofemar devices");return!0},C=function(){if(g(t,k)==="locker")throw new Error("This function is not available for Locker devices");return!0},l=function(n){t.instance.__emulate({code:n})},T=function(n,e=null){let s=n[Math.floor(Math.random()*5)];if(e!==null&&!isNaN(parseFloat(e)))switch(e.toString()){case"0.5":s=n[1];break;case"1":s=n[2];break;case"2":s=n[3];break;case"5":s=n[4];break;case"10":s=n[5];break}return s},S=function(n,e=null){let s=n[Math.floor(Math.random()*4)];if(e!==null&&!isNaN(parseFloat(e)))switch(e.toString()){case"20":s=n[0];break;case"50":s=n[1];break;case"100":s=n[2];break;case"200":s=n[3];break;case"500":s=n[4];break}return s},B(t,r),P(t,"enable",!1),P(t,"instance",null),B(t,k,null),B(t,M,1);let A=t;f.h.instance||(f.h.instance=new f.h);const G={relay:[],locker:[],jofemar:[],boardroid:[],arduino:[],pinpad:[],pinpax:[],hopper:[]};f.h.devices={...f.h.devices,...G};f.h.addCustom=(u,n)=>{f.h.registerType(u),f.h.add(n)};f.h.getCustomByUuid=(u,n)=>f.h.get(u,n);f.h.getJofemarByUuid=u=>f.h.get("jofemar",u);f.h.getLockerByUuid=u=>f.h.get("locker",u);f.h.getRelayByUuid=u=>f.h.get("relay",u);f.h.getBoardroidByUuid=u=>f.h.get("boardroid",u);f.h.getArduinoByUuid=u=>f.h.get("arduino",u);f.h.getPinPadByUuid=u=>f.h.get("pinpad",u);f.h.getPinPaxByUuid=u=>f.h.get("pinpax",u);f.h.getHopperByUuid=u=>f.h.get("hopper",u);f.h.getJofemar=(u=1)=>f.h.getByNumber("jofemar",u);f.h.getBoardroid=(u=1)=>f.h.getByNumber("boardroid",u);f.h.getLocker=(u=1)=>f.h.getByNumber("locker",u);f.h.getRelay=(u=1)=>f.h.getByNumber("relay",u);f.h.getArduino=(u=1)=>f.h.getByNumber("arduino",u);f.h.getPinPad=(u=1)=>f.h.getByNumber("pinpad",u);f.h.getPinPax=(u=1)=>f.h.getByNumber("pinpax",u);f.h.getHopper=(u=1)=>f.h.getByNumber("hopper",u);class O extends f.K{constructor(n){super(n),this.__internal__=structuredClone(this.__internal__),this.getResponseAsArrayHex(),this.__internal__.device.door_open=!1,this.__internal__.time.response_engines=2e3,this.__internal__.time.sense=100,this.__internal__.interval.waiting_sense=0,this.__internal__.dispense={must_response:!1,dispensing:!1,status:null,counter:0,limit_counter:20,custom_limit_counter:null,backup_dispense:{}}}get isDoorOpen(){return this.__internal__.device.door_open}get isDispensing(){return this.__internal__.interval.waiting_sense||this.__internal__.dispense.dispensing}async timeout(n,e){await super.timeout(n,e),e==="dispense"&&(this.__internal__.dispense.status="no-response")}async serialPortsSaved(n){const e=this.serialFilters;if(this.__internal__.aux_port_connector<n.length){const s=this.__internal__.aux_port_connector;this.__internal__.serial.port=n[s]}else this.__internal__.aux_port_connector=0,this.__internal__.serial.port=await navigator.serial.requestPort({filters:e});if(!this.__internal__.serial.port)throw new Error("Select another port please")}internalClearSensing(){this.__internal__.interval.waiting_sense&&clearInterval(this.__internal__.interval.waiting_sense),this.__internal__.interval.waiting_sense=0,this.__internal__.dispense.status=null,this.__internal__.dispense.counter=0,this.__internal__.dispense.dispensing=!1}internalDispensingProcess(){let n=this.__internal__.dispense.limit_counter;return this.__internal__.dispense.custom_limit_counter&&(n=this.__internal__.dispense.custom_limit_counter),n+=Math.ceil(n*.6),this.__internal__.dispense.counter>=n?(this.internalClearSensing(),this.__internal__.dispense.status=!1,this.__internal__.dispense.dispensing=!1,!1):(this.__internal__.dispense.counter=parseFloat((.1+this.__internal__.dispense.counter).toFixed(1)),this.__internal__.dispense.counter%1===0&&this.dispatch("dispensing",{status:this.__internal__.dispense.status,counter:this.__internal__.dispense.counter,limit:n}),null)}async internalDispenseStatus(){if(this.__internal__.dispense.must_response&&(await j(this.__internal__.time.response_engines+10),this.__internal__.dispense.status==="no-response"))return this.internalClearSensing(),this.__internal__.dispense.status=!1,this.dispatch("not-dispensed",{reason:"no-response"}),{status:!1,error:"no-response"};this.__internal__.dispense.status=null,this.__internal__.dispense.dispensing=!0,this.dispatch("internal:dispense:running",{});const n=this;return new Promise(e=>{this.__internal__.interval.waiting_sense=setInterval(()=>{switch(n.__internal__.dispense.status){case null:n.internalDispensingProcess()===!1&&(n.internalClearSensing(),n.dispatch("not-dispensed",{reason:"timeout"}),e({status:!1,error:"timeout"}));break;case!0:n.internalClearSensing(),n.__internal__.dispense.status=!0,n.dispatch("dispensed",{}),e({status:!0,error:null});break;case!1:n.internalClearSensing(),n.__internal__.dispense.status=!1,n.dispatch("not-dispensed",{reason:"no-stock"}),e({status:!1,error:null});break;case"elevator-locked":n.internalClearSensing(),n.__internal__.dispense.status=!1,n.dispatch("not-dispensed",{reason:"elevator-locked"}),e({status:!1,error:"elevator-locked"});break;case"no-response":n.internalClearSensing(),n.__internal__.dispense.status=!1,n.dispatch("not-dispensed",{reason:"no-response"}),e({status:!1,error:"no-response"});break}},this.__internal__.time.sense)})}async internalDispense(n){if(this.isDispensing)throw new Error("Another dispensing process is running");if(!A.enable&&!this.__internal__.serial.connected&&(await this.serialConnect(),!this.__internal__.serial.connected))throw new Error("Serial device not connected");return this.__internal__.serial.queue.length===0?(await this.appendToQueue(n,"dispense"),await this.internalDispenseStatus()):new Promise(e=>{const s=setInterval(async()=>{if(this.__internal__.serial.queue.length>0)return;clearInterval(s),await this.appendToQueue(n,"dispense");const i=await this.internalDispenseStatus();e(i)},100)})}__emulate(n){if(typeof n.code!="object"){console.error("Invalid data to make an emulation");return}this.__internal__.serial.connected||(this.__internal__.serial.connected=!0,this.dispatch("serial:connected"),f.h.instance.dispatch("change"),this.__internal__.interval.reconnection&&(clearInterval(this.__internal__.interval.reconnection),this.__internal__.interval.reconnection=0)),this.__internal__.timeout.until_response&&(clearTimeout(this.__internal__.timeout.until_response),this.__internal__.timeout.until_response=0);const e=[];for(const s in n.code)e.push(n.code[s].toString().padStart(2,"0").toLowerCase());this.serialMessage(e)}set listenOnPort(n){this.listenOnChannel=n}get listenOnPort(){return this.__internal__.device.listen_on_port??1}}exports.Emulator=A;exports.Kernel=O;exports.getSeconds=K;exports.isEmpty=W;exports.supportCrypto=H;exports.supportGeolocation=J;exports.supportWebSerial=q;exports.wait=j;
@@ -735,7 +735,8 @@ const q = {
735
735
  boardroid: [],
736
736
  arduino: [],
737
737
  pinpad: [],
738
- pinpax: []
738
+ pinpax: [],
739
+ hopper: []
739
740
  };
740
741
  f.devices = { ...f.devices, ...q };
741
742
  f.addCustom = (u, n) => {
package/dist/kernel.cjs CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./kernel-BTqvt4pt.cjs"),r=require("./webserial-core-DlH0cFSH.cjs");/**
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./kernel-DlsHh4AG.cjs"),r=require("./webserial-core-DlH0cFSH.cjs");/**
2
2
  * @license Webserial
3
3
  * webserial
4
4
  *
package/dist/kernel.js CHANGED
@@ -1,4 +1,4 @@
1
- import { K as s } from "./kernel-lcvN8cY0.js";
1
+ import { K as s } from "./kernel-IUeiZp8d.js";
2
2
  import { h as n } from "./webserial-core-DGKQCs5a.js";
3
3
  /**
4
4
  * @license Webserial
package/dist/locker.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var y=l=>{throw TypeError(l)};var w=(l,c,e)=>c.has(l)||y("Cannot "+e);var r=(l,c,e)=>(w(l,c,"read from private field"),e?e.call(l):c.get(l)),u=(l,c,e)=>c.has(l)?y("Cannot add the same private member more than once"):c instanceof WeakSet?c.add(l):c.set(l,e),i=(l,c,e,s)=>(w(l,c,"write to private field"),s?s.call(l,e):c.set(l,e),e),n=(l,c,e)=>(w(l,c,"access private method"),e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("./kernel-BTqvt4pt.cjs"),d=require("./relay-BsUsBpOv.cjs"),v=require("./webserial-core-DlH0cFSH.cjs");var h,a,o,t,C,_,f,g,b,k,T;class A extends m.Kernel{constructor({filters:e=null,config_port:s=null,no_device:p=1,device_listen_on_port:q=3}={}){super({filters:e,config_port:s,no_device:p,device_listen_on_port:q});u(this,t);u(this,h,!1);u(this,a,0);u(this,o,0);if(this.__internal__.device.type="locker",v.h.getCustom(this.typeDevice,p))throw new Error(`Device ${this.typeDevice} ${p} already exists`);this.__internal__.time.response_engines=1e3,this.__internal__.device.milliseconds=666,this.__internal__.dispense.limit_counter=1,v.h.add(this),n(this,t,C).call(this)}serialMessage(e){const s={code:e,name:null,description:null,request:null,no_code:0};switch(e[1]){case"08":s.name="Connection with the serial device completed.",s.description="Your connection with the serial device was successfully completed.",s.request="connect",s.no_code=100;break;case"07":switch(e[4]){case"00":s.name="Cell closed.",s.description="The selected cell is closed.",s.request="dispense",s.no_code=1102,this.__internal__.dispense.status=!1,this.dispatch("dispensed",{}),r(this,h)&&r(this,a)>=89?(s.finished_test=!0,i(this,h,!1),i(this,a,0)):r(this,h)&&(s.finished_test=!1);break;case"01":case"04":s.name="Cell open.",s.description="The selected cell was open successfully.",s.request="dispense",s.no_code=102,this.__internal__.dispense.status=!0,this.dispatch("dispensed",{}),r(this,h)&&r(this,a)>=89?(s.finished_test=!0,i(this,h,!1),i(this,a,0)):r(this,h)&&(s.finished_test=!1);break;case"05":s.name="Cell inactive.",s.description="The selected cell is inactive or doesn't exist.",s.request="dispense",s.no_code=101,this.__internal__.dispense.status=!1,this.dispatch("not-dispensed",{}),r(this,h)&&r(this,a)>=89?(s.finished_test=!0,i(this,h,!1),i(this,a,0)):r(this,h)&&(s.finished_test=!1);break}break;case"06":s.name="Configuration applied.",s.description="The configuration was successfully applied.",s.request="configure cell",s.no_code=103;break;default:s.request="undefined",s.name="Response unrecognized",s.description="The response of application was received, but dont identify with any of current parameters",s.no_code=400;break}this.dispatch("serial:message",s)}serialSetConnectionConstant(e=3){return d.u.connection({channel:e})}async dispense({cell:e=1,status:s=!0}={}){return setTimeout(()=>{s===!0?n(this,t,k).call(this):n(this,t,T).call(this)},this.__internal__.time.response_engines/2),await this.internalDispense(d.u.openCell({cell:e,channel:this.__internal__.device.listen_on_port}))}async status({cell:e=1}={}){return await this.appendToQueue(d.u.statusCell({cell:e,channel:this.__internal__.device.listen_on_port}),"status")}async lightScan({since:e=0,until:s=10}={}){return await this.appendToQueue(d.u.lightScan({channel:this.__internal__.device.listen_on_port,since:e,until:s}),"light-scan")}async enable({cell:e=1}={}){return await this.appendToQueue(d.u.enableCell({cell:e,channel:this.__internal__.device.listen_on_port}),"activate")}async disable({cell:e=1}={}){await this.appendToQueue(d.u.disableCell({cell:e,channel:this.__internal__.device.listen_on_port}),"disable")}async openAll(){if(this.isDispensing)throw new Error("Another dispensing process is running");n(this,t,_).call(this),i(this,h,!0),n(this,t,f).call(this);const e=[];for(let s=1;s<=80;s++){const p=await this.dispense({cell:s,status:!0});e.push(p),i(this,a,s),n(this,t,f).call(this)}i(this,a,80),n(this,t,f).call(this,e),n(this,t,_).call(this)}async enableAll(){n(this,t,_).call(this),i(this,h,!0),n(this,t,g).call(this);for(let e=1;e<=80;e++)await this.enable({cell:e}),await m.wait(100),i(this,a,e),n(this,t,g).call(this);i(this,a,80),n(this,t,g).call(this),n(this,t,_).call(this)}async disableAll(){n(this,t,_).call(this),i(this,h,!0),n(this,t,b).call(this);for(let e=1;e<=80;e++)await this.disable({cell:e}),await m.wait(100),i(this,a,e),n(this,t,b).call(this);i(this,a,80),n(this,t,b).call(this),n(this,t,_).call(this)}}h=new WeakMap,a=new WeakMap,o=new WeakMap,t=new WeakSet,C=function(){const e=["percentage:disable","percentage:enable","percentage:open"];for(const s of e)this.serialRegisterAvailableListener(s)},_=function(){i(this,h,!1),i(this,a,0),i(this,o,0)},f=function(e=null){i(this,o,Math.round(r(this,a)*100/80)),this.dispatch("percentage:open",{percentage:r(this,o),dispensed:e})},g=function(){i(this,o,Math.round(r(this,a)*100/80)),this.dispatch("percentage:enable",{percentage:r(this,o)})},b=function(){i(this,o,Math.round(r(this,a)*100/80)),this.dispatch("percentage:disable",{percentage:r(this,o)})},k=function(){this.__internal__.dispense.dispensing&&(this.__internal__.dispense.status=!0)},T=function(){this.__internal__.dispense.dispensing&&(this.__internal__.dispense.status=!1)};exports.Locker=A;
1
+ "use strict";var y=l=>{throw TypeError(l)};var w=(l,c,e)=>c.has(l)||y("Cannot "+e);var r=(l,c,e)=>(w(l,c,"read from private field"),e?e.call(l):c.get(l)),u=(l,c,e)=>c.has(l)?y("Cannot add the same private member more than once"):c instanceof WeakSet?c.add(l):c.set(l,e),i=(l,c,e,s)=>(w(l,c,"write to private field"),s?s.call(l,e):c.set(l,e),e),n=(l,c,e)=>(w(l,c,"access private method"),e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("./kernel-DlsHh4AG.cjs"),d=require("./relay-BsUsBpOv.cjs"),v=require("./webserial-core-DlH0cFSH.cjs");var h,a,o,t,C,_,f,g,b,k,T;class A extends m.Kernel{constructor({filters:e=null,config_port:s=null,no_device:p=1,device_listen_on_port:q=3}={}){super({filters:e,config_port:s,no_device:p,device_listen_on_port:q});u(this,t);u(this,h,!1);u(this,a,0);u(this,o,0);if(this.__internal__.device.type="locker",v.h.getCustom(this.typeDevice,p))throw new Error(`Device ${this.typeDevice} ${p} already exists`);this.__internal__.time.response_engines=1e3,this.__internal__.device.milliseconds=666,this.__internal__.dispense.limit_counter=1,v.h.add(this),n(this,t,C).call(this)}serialMessage(e){const s={code:e,name:null,description:null,request:null,no_code:0};switch(e[1]){case"08":s.name="Connection with the serial device completed.",s.description="Your connection with the serial device was successfully completed.",s.request="connect",s.no_code=100;break;case"07":switch(e[4]){case"00":s.name="Cell closed.",s.description="The selected cell is closed.",s.request="dispense",s.no_code=1102,this.__internal__.dispense.status=!1,this.dispatch("dispensed",{}),r(this,h)&&r(this,a)>=89?(s.finished_test=!0,i(this,h,!1),i(this,a,0)):r(this,h)&&(s.finished_test=!1);break;case"01":case"04":s.name="Cell open.",s.description="The selected cell was open successfully.",s.request="dispense",s.no_code=102,this.__internal__.dispense.status=!0,this.dispatch("dispensed",{}),r(this,h)&&r(this,a)>=89?(s.finished_test=!0,i(this,h,!1),i(this,a,0)):r(this,h)&&(s.finished_test=!1);break;case"05":s.name="Cell inactive.",s.description="The selected cell is inactive or doesn't exist.",s.request="dispense",s.no_code=101,this.__internal__.dispense.status=!1,this.dispatch("not-dispensed",{}),r(this,h)&&r(this,a)>=89?(s.finished_test=!0,i(this,h,!1),i(this,a,0)):r(this,h)&&(s.finished_test=!1);break}break;case"06":s.name="Configuration applied.",s.description="The configuration was successfully applied.",s.request="configure cell",s.no_code=103;break;default:s.request="undefined",s.name="Response unrecognized",s.description="The response of application was received, but dont identify with any of current parameters",s.no_code=400;break}this.dispatch("serial:message",s)}serialSetConnectionConstant(e=3){return d.u.connection({channel:e})}async dispense({cell:e=1,status:s=!0}={}){return setTimeout(()=>{s===!0?n(this,t,k).call(this):n(this,t,T).call(this)},this.__internal__.time.response_engines/2),await this.internalDispense(d.u.openCell({cell:e,channel:this.__internal__.device.listen_on_port}))}async status({cell:e=1}={}){return await this.appendToQueue(d.u.statusCell({cell:e,channel:this.__internal__.device.listen_on_port}),"status")}async lightScan({since:e=0,until:s=10}={}){return await this.appendToQueue(d.u.lightScan({channel:this.__internal__.device.listen_on_port,since:e,until:s}),"light-scan")}async enable({cell:e=1}={}){return await this.appendToQueue(d.u.enableCell({cell:e,channel:this.__internal__.device.listen_on_port}),"activate")}async disable({cell:e=1}={}){await this.appendToQueue(d.u.disableCell({cell:e,channel:this.__internal__.device.listen_on_port}),"disable")}async openAll(){if(this.isDispensing)throw new Error("Another dispensing process is running");n(this,t,_).call(this),i(this,h,!0),n(this,t,f).call(this);const e=[];for(let s=1;s<=80;s++){const p=await this.dispense({cell:s,status:!0});e.push(p),i(this,a,s),n(this,t,f).call(this)}i(this,a,80),n(this,t,f).call(this,e),n(this,t,_).call(this)}async enableAll(){n(this,t,_).call(this),i(this,h,!0),n(this,t,g).call(this);for(let e=1;e<=80;e++)await this.enable({cell:e}),await m.wait(100),i(this,a,e),n(this,t,g).call(this);i(this,a,80),n(this,t,g).call(this),n(this,t,_).call(this)}async disableAll(){n(this,t,_).call(this),i(this,h,!0),n(this,t,b).call(this);for(let e=1;e<=80;e++)await this.disable({cell:e}),await m.wait(100),i(this,a,e),n(this,t,b).call(this);i(this,a,80),n(this,t,b).call(this),n(this,t,_).call(this)}}h=new WeakMap,a=new WeakMap,o=new WeakMap,t=new WeakSet,C=function(){const e=["percentage:disable","percentage:enable","percentage:open"];for(const s of e)this.serialRegisterAvailableListener(s)},_=function(){i(this,h,!1),i(this,a,0),i(this,o,0)},f=function(e=null){i(this,o,Math.round(r(this,a)*100/80)),this.dispatch("percentage:open",{percentage:r(this,o),dispensed:e})},g=function(){i(this,o,Math.round(r(this,a)*100/80)),this.dispatch("percentage:enable",{percentage:r(this,o)})},b=function(){i(this,o,Math.round(r(this,a)*100/80)),this.dispatch("percentage:disable",{percentage:r(this,o)})},k=function(){this.__internal__.dispense.dispensing&&(this.__internal__.dispense.status=!0)},T=function(){this.__internal__.dispense.dispensing&&(this.__internal__.dispense.status=!1)};exports.Locker=A;
package/dist/locker.js CHANGED
@@ -3,7 +3,7 @@ var w = (l) => {
3
3
  };
4
4
  var b = (l, c, e) => c.has(l) || w("Cannot " + e);
5
5
  var r = (l, c, e) => (b(l, c, "read from private field"), e ? e.call(l) : c.get(l)), u = (l, c, e) => c.has(l) ? w("Cannot add the same private member more than once") : c instanceof WeakSet ? c.add(l) : c.set(l, e), i = (l, c, e, s) => (b(l, c, "write to private field"), s ? s.call(l, e) : c.set(l, e), e), n = (l, c, e) => (b(l, c, "access private method"), e);
6
- import { K as D, w as v } from "./kernel-lcvN8cY0.js";
6
+ import { K as D, w as v } from "./kernel-IUeiZp8d.js";
7
7
  import { u as p } from "./relay-Dop4mFk-.js";
8
8
  import { h as y } from "./webserial-core-DGKQCs5a.js";
9
9
  var h, a, o, t, C, _, f, g, m, T, k;
package/dist/pinpad.cjs CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";var gn=Object.defineProperty;var Te=n=>{throw TypeError(n)};var mn=(n,i,t)=>i in n?gn(n,i,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[i]=t;var Ce=(n,i,t)=>mn(n,typeof i!="symbol"?i+"":i,t),yn=(n,i,t)=>i.has(n)||Te("Cannot "+t);var Ae=(n,i,t)=>i.has(n)?Te("Cannot add the same private member more than once"):i instanceof WeakSet?i.add(n):i.set(n,t);var f=(n,i,t)=>(yn(n,i,"access private method"),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const N=require("./kernel-BTqvt4pt.cjs"),Re=require("./webserial-core-DlH0cFSH.cjs");var bn="0123456789abcdefghijklmnopqrstuvwxyz";function $(n){return bn.charAt(n)}function Pn(n,i){return n&i}function Et(n,i){return n|i}function Oe(n,i){return n^i}function xe(n,i){return n&~i}function vn(n){if(n==0)return-1;var i=0;return(n&65535)==0&&(n>>=16,i+=16),(n&255)==0&&(n>>=8,i+=8),(n&15)==0&&(n>>=4,i+=4),(n&3)==0&&(n>>=2,i+=2),(n&1)==0&&++i,i}function wn(n){for(var i=0;n!=0;)n&=n-1,++i;return i}var at="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Ze="=";function Vt(n){var i,t,e="";for(i=0;i+3<=n.length;i+=3)t=parseInt(n.substring(i,i+3),16),e+=at.charAt(t>>6)+at.charAt(t&63);for(i+1==n.length?(t=parseInt(n.substring(i,i+1),16),e+=at.charAt(t<<2)):i+2==n.length&&(t=parseInt(n.substring(i,i+2),16),e+=at.charAt(t>>2)+at.charAt((t&3)<<4));(e.length&3)>0;)e+=Ze;return e}function De(n){var i="",t,e=0,r=0;for(t=0;t<n.length&&n.charAt(t)!=Ze;++t){var s=at.indexOf(n.charAt(t));s<0||(e==0?(i+=$(s>>2),r=s&3,e=1):e==1?(i+=$(r<<2|s>>4),r=s&15,e=2):e==2?(i+=$(r),i+=$(s>>2),r=s&3,e=3):(i+=$(r<<2|s>>4),i+=$(s&15),e=0))}return e==1&&(i+=$(r<<2)),i}var rt,En={decode:function(n){var i;if(rt===void 0){var t="0123456789ABCDEF",e=` \f
1
+ "use strict";var gn=Object.defineProperty;var Te=n=>{throw TypeError(n)};var mn=(n,i,t)=>i in n?gn(n,i,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[i]=t;var Ce=(n,i,t)=>mn(n,typeof i!="symbol"?i+"":i,t),yn=(n,i,t)=>i.has(n)||Te("Cannot "+t);var Ae=(n,i,t)=>i.has(n)?Te("Cannot add the same private member more than once"):i instanceof WeakSet?i.add(n):i.set(n,t);var f=(n,i,t)=>(yn(n,i,"access private method"),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const N=require("./kernel-DlsHh4AG.cjs"),Re=require("./webserial-core-DlH0cFSH.cjs");var bn="0123456789abcdefghijklmnopqrstuvwxyz";function $(n){return bn.charAt(n)}function Pn(n,i){return n&i}function Et(n,i){return n|i}function Oe(n,i){return n^i}function xe(n,i){return n&~i}function vn(n){if(n==0)return-1;var i=0;return(n&65535)==0&&(n>>=16,i+=16),(n&255)==0&&(n>>=8,i+=8),(n&15)==0&&(n>>=4,i+=4),(n&3)==0&&(n>>=2,i+=2),(n&1)==0&&++i,i}function wn(n){for(var i=0;n!=0;)n&=n-1,++i;return i}var at="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Ze="=";function Vt(n){var i,t,e="";for(i=0;i+3<=n.length;i+=3)t=parseInt(n.substring(i,i+3),16),e+=at.charAt(t>>6)+at.charAt(t&63);for(i+1==n.length?(t=parseInt(n.substring(i,i+1),16),e+=at.charAt(t<<2)):i+2==n.length&&(t=parseInt(n.substring(i,i+2),16),e+=at.charAt(t>>2)+at.charAt((t&3)<<4));(e.length&3)>0;)e+=Ze;return e}function De(n){var i="",t,e=0,r=0;for(t=0;t<n.length&&n.charAt(t)!=Ze;++t){var s=at.indexOf(n.charAt(t));s<0||(e==0?(i+=$(s>>2),r=s&3,e=1):e==1?(i+=$(r<<2|s>>4),r=s&15,e=2):e==2?(i+=$(r),i+=$(s>>2),r=s&3,e=3):(i+=$(r<<2|s>>4),i+=$(s&15),e=0))}return e==1&&(i+=$(r<<2)),i}var rt,En={decode:function(n){var i;if(rt===void 0){var t="0123456789ABCDEF",e=` \f
2
2
  \r  \u2028\u2029`;for(rt={},i=0;i<16;++i)rt[t.charAt(i)]=i;for(t=t.toLowerCase(),i=10;i<16;++i)rt[t.charAt(i)]=i;for(i=0;i<e.length;++i)rt[e.charAt(i)]=-1}var r=[],s=0,a=0;for(i=0;i<n.length;++i){var o=n.charAt(i);if(o=="=")break;if(o=rt[o],o!=-1){if(o===void 0)throw new Error("Illegal character at offset "+i);s|=o,++a>=2?(r[r.length]=s,s=0,a=0):s<<=4}}if(a)throw new Error("Hex encoding incomplete: 4 bits missing");return r}},Y,Yt={decode:function(n){var i;if(Y===void 0){var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",e=`= \f
3
3
  \r  \u2028\u2029`;for(Y=Object.create(null),i=0;i<64;++i)Y[t.charAt(i)]=i;for(Y["-"]=62,Y._=63,i=0;i<e.length;++i)Y[e.charAt(i)]=-1}var r=[],s=0,a=0;for(i=0;i<n.length;++i){var o=n.charAt(i);if(o=="=")break;if(o=Y[o],o!=-1){if(o===void 0)throw new Error("Illegal character at offset "+i);s|=o,++a>=4?(r[r.length]=s>>16,r[r.length]=s>>8&255,r[r.length]=s&255,s=0,a=0):s<<=6}}switch(a){case 1:throw new Error("Base64 encoding incomplete: at least 2 bits missing");case 2:r[r.length]=s>>10;break;case 3:r[r.length]=s>>16,r[r.length]=s>>8&255;break}return r},re:/-----BEGIN [^-]+-----([A-Za-z0-9+\/=\s]+)-----END [^-]+-----|begin-base64[^\n]+\n([A-Za-z0-9+\/=\s]+)====/,unarmor:function(n){var i=Yt.re.exec(n);if(i)if(i[1])n=i[1];else if(i[2])n=i[2];else throw new Error("RegExp out of sync");return Yt.decode(n)}},st=1e13,ft=function(){function n(i){this.buf=[+i||0]}return n.prototype.mulAdd=function(i,t){var e=this.buf,r=e.length,s,a;for(s=0;s<r;++s)a=e[s]*i+t,a<st?t=0:(t=0|a/st,a-=t*st),e[s]=a;t>0&&(e[s]=t)},n.prototype.sub=function(i){var t=this.buf,e=t.length,r,s;for(r=0;r<e;++r)s=t[r]-i,s<0?(s+=st,i=1):i=0,t[r]=s;for(;t[t.length-1]===0;)t.pop()},n.prototype.toString=function(i){if((i||10)!=10)throw new Error("only base 10 is supported");for(var t=this.buf,e=t[t.length-1].toString(),r=t.length-2;r>=0;--r)e+=(st+t[r]).toString().substring(1);return e},n.prototype.valueOf=function(){for(var i=this.buf,t=0,e=i.length-1;e>=0;--e)t=t*st+i[e];return t},n.prototype.simplify=function(){var i=this.buf;return i.length==1?i[0]:this},n}(),Ye="…",Sn=/^(\d\d)(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])([01]\d|2[0-3])(?:([0-5]\d)(?:([0-5]\d)(?:[.,](\d{1,3}))?)?)?(Z|[-+](?:[0]\d|1[0-2])([0-5]\d)?)?$/,Tn=/^(\d\d\d\d)(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])([01]\d|2[0-3])(?:([0-5]\d)(?:([0-5]\d)(?:[.,](\d{1,3}))?)?)?(Z|[-+](?:[0]\d|1[0-2])([0-5]\d)?)?$/;function ct(n,i){return n.length>i&&(n=n.substring(0,i)+Ye),n}var zt=function(){function n(i,t){this.hexDigits="0123456789ABCDEF",i instanceof n?(this.enc=i.enc,this.pos=i.pos):(this.enc=i,this.pos=t)}return n.prototype.get=function(i){if(i===void 0&&(i=this.pos++),i>=this.enc.length)throw new Error("Requesting byte offset ".concat(i," on a stream of length ").concat(this.enc.length));return typeof this.enc=="string"?this.enc.charCodeAt(i):this.enc[i]},n.prototype.hexByte=function(i){return this.hexDigits.charAt(i>>4&15)+this.hexDigits.charAt(i&15)},n.prototype.hexDump=function(i,t,e){for(var r="",s=i;s<t;++s)if(r+=this.hexByte(this.get(s)),e!==!0)switch(s&15){case 7:r+=" ";break;case 15:r+=`
4
4
  `;break;default:r+=" "}return r},n.prototype.isASCII=function(i,t){for(var e=i;e<t;++e){var r=this.get(e);if(r<32||r>176)return!1}return!0},n.prototype.parseStringISO=function(i,t){for(var e="",r=i;r<t;++r)e+=String.fromCharCode(this.get(r));return e},n.prototype.parseStringUTF=function(i,t){for(var e="",r=i;r<t;){var s=this.get(r++);s<128?e+=String.fromCharCode(s):s>191&&s<224?e+=String.fromCharCode((s&31)<<6|this.get(r++)&63):e+=String.fromCharCode((s&15)<<12|(this.get(r++)&63)<<6|this.get(r++)&63)}return e},n.prototype.parseStringBMP=function(i,t){for(var e="",r,s,a=i;a<t;)r=this.get(a++),s=this.get(a++),e+=String.fromCharCode(r<<8|s);return e},n.prototype.parseTime=function(i,t,e){var r=this.parseStringISO(i,t),s=(e?Sn:Tn).exec(r);return s?(e&&(s[1]=+s[1],s[1]+=+s[1]<70?2e3:1900),r=s[1]+"-"+s[2]+"-"+s[3]+" "+s[4],s[5]&&(r+=":"+s[5],s[6]&&(r+=":"+s[6],s[7]&&(r+="."+s[7]))),s[8]&&(r+=" UTC",s[8]!="Z"&&(r+=s[8],s[9]&&(r+=":"+s[9]))),r):"Unrecognized time: "+r},n.prototype.parseInteger=function(i,t){for(var e=this.get(i),r=e>127,s=r?255:0,a,o="";e==s&&++i<t;)e=this.get(i);if(a=t-i,a===0)return r?-1:0;if(a>4){for(o=e,a<<=3;((+o^s)&128)==0;)o=+o<<1,--a;o="("+a+` bit)
package/dist/pinpad.js CHANGED
@@ -6,7 +6,7 @@ var bn = (n, i, t) => i in n ? yn(n, i, { enumerable: !0, configurable: !0, writ
6
6
  var Ce = (n, i, t) => bn(n, typeof i != "symbol" ? i + "" : i, t), Pn = (n, i, t) => i.has(n) || Te("Cannot " + t);
7
7
  var Ae = (n, i, t) => i.has(n) ? Te("Cannot add the same private member more than once") : i instanceof WeakSet ? i.add(n) : i.set(n, t);
8
8
  var p = (n, i, t) => (Pn(n, i, "access private method"), t);
9
- import { K as vn, a as wn, i as G, b as Re, w as Oe } from "./kernel-lcvN8cY0.js";
9
+ import { K as vn, a as wn, i as G, b as Re, w as Oe } from "./kernel-IUeiZp8d.js";
10
10
  import { h as xe } from "./webserial-core-DGKQCs5a.js";
11
11
  var En = "0123456789abcdefghijklmnopqrstuvwxyz";
12
12
  function $(n) {
package/dist/pinpax.cjs CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";var R=Object.defineProperty;var d=r=>{throw TypeError(r)};var E=(r,i,s)=>i in r?R(r,i,{enumerable:!0,configurable:!0,writable:!0,value:s}):r[i]=s;var y=(r,i,s)=>E(r,typeof i!="symbol"?i+"":i,s),I=(r,i,s)=>i.has(r)||d("Cannot "+s);var f=(r,i,s)=>i.has(r)?d("Cannot add the same private member more than once"):i instanceof WeakSet?i.add(r):i.set(r,s);var o=(r,i,s)=>(I(r,i,"access private method"),s);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const C=require("./kernel-BTqvt4pt.cjs"),n=require("./relay-BsUsBpOv.cjs"),w=require("./webserial-core-DlH0cFSH.cjs");var t,m,_,l,g,v,b,x,T;class A extends C.Kernel{constructor({filters:s=null,config_port:e={baudRate:115200,dataBits:8,stopBits:1,parity:"none",bufferSize:32768,flowControl:"none"},no_device:a=1,device_listen_on_channel:c=1}={filters:null,config_port:{baudRate:115200,dataBits:8,stopBits:1,parity:"none",bufferSize:32768,flowControl:"none"},no_device:1,device_listen_on_channel:1}){super({filters:s,config_port:e,no_device:a,device_listen_on_channel:c});f(this,t);y(this,"__pinpax__",{server:"DEV",bussinessId:null,encriptionKey:null,apiKey:null,asyncResponses:{voucher:null,sale:null},waiting:{voucher:!1,sale:!1}});if(this.__internal__.device.type="pinpax",w.h.getCustom(this.typeDevice,a))throw new Error(`Device ${this.typeDevice} ${a} already exists`);this.__internal__.time.response_connection=4e3,this.__internal__.time.response_general=3e3,this.__internal__.serial.delay_first_connection=1e3,this.__internal__.serial.response.replacer="",this.__internal__.serial.response.limiter=`\r
1
+ "use strict";var R=Object.defineProperty;var d=r=>{throw TypeError(r)};var E=(r,i,s)=>i in r?R(r,i,{enumerable:!0,configurable:!0,writable:!0,value:s}):r[i]=s;var y=(r,i,s)=>E(r,typeof i!="symbol"?i+"":i,s),I=(r,i,s)=>i.has(r)||d("Cannot "+s);var f=(r,i,s)=>i.has(r)?d("Cannot add the same private member more than once"):i instanceof WeakSet?i.add(r):i.set(r,s);var o=(r,i,s)=>(I(r,i,"access private method"),s);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const C=require("./kernel-DlsHh4AG.cjs"),n=require("./relay-BsUsBpOv.cjs"),w=require("./webserial-core-DlH0cFSH.cjs");var t,m,_,l,g,v,b,x,T;class A extends C.Kernel{constructor({filters:s=null,config_port:e={baudRate:115200,dataBits:8,stopBits:1,parity:"none",bufferSize:32768,flowControl:"none"},no_device:a=1,device_listen_on_channel:c=1}={filters:null,config_port:{baudRate:115200,dataBits:8,stopBits:1,parity:"none",bufferSize:32768,flowControl:"none"},no_device:1,device_listen_on_channel:1}){super({filters:s,config_port:e,no_device:a,device_listen_on_channel:c});f(this,t);y(this,"__pinpax__",{server:"DEV",bussinessId:null,encriptionKey:null,apiKey:null,asyncResponses:{voucher:null,sale:null},waiting:{voucher:!1,sale:!1}});if(this.__internal__.device.type="pinpax",w.h.getCustom(this.typeDevice,a))throw new Error(`Device ${this.typeDevice} ${a} already exists`);this.__internal__.time.response_connection=4e3,this.__internal__.time.response_general=3e3,this.__internal__.serial.delay_first_connection=1e3,this.__internal__.serial.response.replacer="",this.__internal__.serial.response.limiter=`\r
2
2
  `,o(this,t,m).call(this),w.h.add(this),this.getResponseAsString()}set bussinessId(s){this.__pinpax__.bussinessId=s}get bussinessId(){return this.__pinpax__.bussinessId}set encriptionKey(s){this.__pinpax__.encriptionKey=s}get encriptionKey(){return this.__pinpax__.encriptionKey}set apiKey(s){this.__pinpax__.apiKey=s}get apiKey(){return this.__pinpax__.apiKey}set server(s){this.__pinpax__.server=s}get server(){return this.__pinpax__.server}serialMessage(s){let e=null;try{e=JSON.parse(s)}catch(a){console.error("Error parsing response",a,s),this.dispatch("serial:message",s);return}switch(e.response){case"INITAPP":this.dispatch("init-app",{status:"started"}),o(this,t,b).call(this).then(()=>{});break;case"CONNECT":this.dispatch("connectMessage",{status:"connected"}),o(this,t,x).call(this).then(()=>{});break;case"LOGIN":this.dispatch("login",e);break;case"LASTVOUCHER":this.dispatch("voucher",e),this.__pinpax__.waiting.voucher&&(this.__pinpax__.asyncResponses.voucher=e,this.__pinpax__.waiting.voucher=!1);break;case"DEVICEINFO":this.dispatch("info",e);break;case"KEEPALIVE":this.dispatch("keep-alive",{status:"alive"});break;case"RESETAPP":this.dispatch("reset-app",{status:"accepted"});break;case"GETCONFIG":this.dispatch("get-config",e);break;case"HIDEBUTTONS":this.dispatch("buttons-status",{hidden:!0});break;case"SHOWBUTTONS":this.dispatch("buttons-status",{hidden:!1});break;case"PAYMENT_PROCESS":this.dispatch("payment",{status:"starting",amount:e.amount,reference:e.referecence});break;case"INSERT_CARD":this.dispatch("payment",{status:"insert card"});break;case"CARD_DATA":this.dispatch("payment",{status:"card data",amount:e.amount,cardHolderName:e.cardHolderName,ccMark:e.ccMark,ccType:e.ccType,currency:e.currency,maskedPan:e.maskedPan,readingType:e.readingType});break;case"MERCHANT":this.dispatch("payment",{status:"merchant",afiliation:e.afiliation,alias:e.alias,amountCashBackCommission:e.amountCashBackCommission,currency:e.currency,description:e.description,hasCashBack:e.hasCashBack,limitCashBackAmount:e.limitCashBackAmount,merchant:e.merchant,months:e.months,name:e.name});break;case"TRANSACTION_RESULT":o(this,t,T).call(this,{status:"result",approved:e.approved,acquirer:e.acquirer,address:e.address,amount:e.amount,amountCashback:e.amountCashback,appIDLabel:e.appIDLabel,appId:e.appId,arqc:e.arqc,auth:e.auth,ccBin:e.ccBin,ccExpirationDate:e.ccExpirationDate,ccName:e.ccName,ccNumber:e.ccNumber,ccType:e.ccType,comissionCashback:e.comissionCashback,currency:e.currency,date:e.date,errorCode:e.errorCode,errorDescription:e.errorDescription,folio:e.folio,id:e.id,merchantName:e.merchantName,msiLabel:e.msiLabel,operation:e.operation,pin:e.pin,qps:e.qps,reference:e.reference,response:e.response,source:e.source,sourceLabel:e.sourceLabel,time:e.time});break;case"ERROR":this.__pinpax__.waiting.sale&&(this.__pinpax__.asyncResponses.sale={status:"error",approved:!1,response:e}),this.dispatch("error",{status:"error",response:e}),this.dispatch("payment",{status:"error",response:e});break;case"REFUND":this.dispatch("refund",{status:"refund",response:e});break}this.dispatch("serial:message",e)}serialSetConnectionConstant(s=1){return n.s.connection(s)}softReload(){super.softReload(),this.__pinpax__.waiting.sale=!1,this.__pinpax__.waiting.voucher=!1,this.__pinpax__.asyncResponses.sale=null,this.__pinpax__.asyncResponses.voucher=null}async sendCustomCode(s={}){if(typeof s!="object")throw new Error("Invalid object");if(s.constructor!==Object)throw new Error("Invalid object");if(Object.keys(s).length===0)throw new Error("Empty object");if(s.action===void 0||s.action===null)throw new Error("Invalid object add action");const e=JSON.stringify(s),a=this.parseStringToBytes(e,`\r
3
3
  `);await this.appendToQueue(this.stringArrayToUint8Array(a),"custom")}async connectMessage(){await this.appendToQueue(n.s.connect(),"connect:message")}async makeSale({amount:s=0,reference:e=null}={}){if(this.isDisconnected)throw new Error("Device is disconnected");if(this.__pinpax__.waiting.sale)throw new Error("Already waiting for sale response");const a=n.s.makeSale({amount:s,reference:e});this.__pinpax__.waiting.sale=!0,this.__pinpax__.asyncResponses.sale=null,this.queue.length>0&&await o(this,t,_).call(this);const c=this;return await this.appendToQueue(a,"make-sale"),new Promise(p=>{const h=setInterval(()=>{if(c.__pinpax__.asyncResponses.sale){const u=c.__pinpax__.asyncResponses.sale;c.__pinpax__.asyncResponses.sale=null,c.__pinpax__.waiting.sale=!1,clearInterval(h),p(u.approved)}},100)})}async getVoucher({folio:s=null}={}){if(this.isDisconnected)throw new Error("Device is disconnected");if(this.__pinpax__.waiting.voucher)throw new Error("Already waiting for voucher");if(!s)throw new Error("Folio is required");this.__pinpax__.waiting.voucher=!0,this.__pinpax__.asyncResponses.voucher=null;const e=n.s.getVoucher({folio:s});this.queue.length>0&&await o(this,t,_).call(this),await this.appendToQueue(e,"get-voucher");const a=this;return new Promise((c,p)=>{const h=setTimeout(()=>{a.__pinpax__.waiting.voucher=!1,p("Timeout")},1e4),u=setInterval(()=>{if(a.__pinpax__.asyncResponses.voucher){const k=a.__pinpax__.asyncResponses.voucher;a.__pinpax__.asyncResponses.voucher=null,a.__pinpax__.waiting.voucher=!1,clearInterval(u),clearTimeout(h),c(k.voucher)}},100)})}async info(){await this.appendToQueue(n.s.info(),"info")}async keepAlive(){await this.appendToQueue(n.s.keepAlive(),"keep-alive")}async restartApp(){await this.appendToQueue(n.s.restartApp(),"reset-app")}async getConfig(){return await this.appendToQueue(n.s.getConfig(),"get-config")}async hideButtons(){return await this.appendToQueue(n.s.hideButtons(),"hide-buttons"),await o(this,t,g).call(this)}async showButtons(){return await this.appendToQueue(n.s.showButtons(),"show-buttons"),await o(this,t,v).call(this)}async demo(){return console.warn("RUNNING DEMO APP, BE CAREFUL"),await this.appendToQueue(n.s.demo(),"demo")}async refund({amount:s=0,folio:e=null,auth:a=null}={}){return await this.appendToQueue(n.s.refund({amount:s,folio:e,auth:a}),"refund")}async readProductionQR(){return await o(this,t,l).call(this,{type:"production"})}async readQualityAssuranceQR(){return o(this,t,l).call(this,{type:"QA"})}async exit(){return await this.appendToQueue(n.s.exit(),"exit-app")}async init(){await this.appendToQueue(n.s.init(),"init-app")}async login(){if(!this.apiKey||!this.bussinessId||!this.encriptionKey||!this.server)throw new Error("Invalid data to login check apiKey, bussinessId, encriptionKey, server");const s=JSON.stringify({action:"LOGIN_MIT",server:this.__pinpax__.server,bussiness_id:this.__pinpax__.bussinessId,encription_key:this.__pinpax__.encriptionKey,api_key:this.__pinpax__.apiKey}),e=this.parseStringToBytes(s,`\r
4
4
  `);await this.appendToQueue(e,"login")}}t=new WeakSet,m=function(){const s=["buttons-status","init-app","connectMessage","voucher","info","keep-alive","reset-app","get-config","payment","error","refund","login"];for(const e of s)this.serialRegisterAvailableListener(e)},_=async function(){if(this.isDisconnected)throw new Error("Device is disconnected");if(this.queue.length===0)return!0;const s=this;return new Promise(e=>{let a=setInterval(()=>{s.queue.length===0&&(clearInterval(a),e(!0))},500)})},l=async function({type:s="production"}={}){const e=n.s.readQR({type:s});return await this.appendToQueue(e,"read-qr")},g=async function(){await this.appendToQueue(n.s.forceHide(),"force-hide")},v=async function(){await this.appendToQueue(n.s.forceShow(),"force-show")},b=async function(){await this.connectMessage()},x=async function(){await this.hideButtons()},T=function(s){this.dispatch("payment",s),this.__pinpax__.waiting.sale&&(this.__pinpax__.asyncResponses.sale=s)};exports.PinPax=A;
package/dist/pinpax.js CHANGED
@@ -6,7 +6,7 @@ var E = (r, i, s) => i in r ? R(r, i, { enumerable: !0, configurable: !0, writab
6
6
  var y = (r, i, s) => E(r, typeof i != "symbol" ? i + "" : i, s), I = (r, i, s) => i.has(r) || d("Cannot " + s);
7
7
  var f = (r, i, s) => i.has(r) ? d("Cannot add the same private member more than once") : i instanceof WeakSet ? i.add(r) : i.set(r, s);
8
8
  var o = (r, i, s) => (I(r, i, "access private method"), s);
9
- import { K as C } from "./kernel-lcvN8cY0.js";
9
+ import { K as C } from "./kernel-IUeiZp8d.js";
10
10
  import { s as n } from "./relay-Dop4mFk-.js";
11
11
  import { h as m } from "./webserial-core-DGKQCs5a.js";
12
12
  var t, w, _, l, g, v, b, x, T;
package/dist/relay.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("./kernel-BTqvt4pt.cjs"),i=require("./relay-BsUsBpOv.cjs"),r=require("./webserial-core-DlH0cFSH.cjs");class o extends a.Kernel{constructor({filters:t=null,config_port:e=null,no_device:n=1}={}){if(super({filters:t,config_port:e,no_device:n}),this.__internal__.device.type="relay",this.__internal__.auto_response=!0,r.h.getCustom(this.typeDevice,n))throw new Error(`Device ${this.typeDevice} ${n} already exists`);r.h.add(this)}serialMessage(t){const e={code:t,name:null,description:null,request:null,no_code:0};switch(t[1].toString()){case"dd":e.name="Connection with the serial device completed.",e.description="Your connection with the serial device was successfully completed.",e.request="connect",e.no_code=100;break;case"de":break;default:e.name="Unrecognized response",e.description="The response of application was received, but dont identify with any of current parameters",e.request="undefined",e.no_code=400;break}this.dispatch("serial:message",e)}serialRelaySumHex(t){let e=0;return t.forEach((n,s)=>{s!==3&&(e+=n)}),e}serialSetConnectionConstant(t=1){return i.e.connection(t)}async turnOn(){const t=i.e.activate();await this.appendToQueue(t,"relay:turn-on")}async turnOff(){const t=i.e.deactivate();await this.appendToQueue(t,"relay:turn-off")}async toggle({inverse:t=!1,ms:e=300}={}){if(!t){await this.turnOn(),await a.wait(e),await this.turnOff();return}await this.turnOff(),await a.wait(e),await this.turnOn()}}exports.Relay=o;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("./kernel-DlsHh4AG.cjs"),i=require("./relay-BsUsBpOv.cjs"),r=require("./webserial-core-DlH0cFSH.cjs");class o extends a.Kernel{constructor({filters:t=null,config_port:e=null,no_device:n=1}={}){if(super({filters:t,config_port:e,no_device:n}),this.__internal__.device.type="relay",this.__internal__.auto_response=!0,r.h.getCustom(this.typeDevice,n))throw new Error(`Device ${this.typeDevice} ${n} already exists`);r.h.add(this)}serialMessage(t){const e={code:t,name:null,description:null,request:null,no_code:0};switch(t[1].toString()){case"dd":e.name="Connection with the serial device completed.",e.description="Your connection with the serial device was successfully completed.",e.request="connect",e.no_code=100;break;case"de":break;default:e.name="Unrecognized response",e.description="The response of application was received, but dont identify with any of current parameters",e.request="undefined",e.no_code=400;break}this.dispatch("serial:message",e)}serialRelaySumHex(t){let e=0;return t.forEach((n,s)=>{s!==3&&(e+=n)}),e}serialSetConnectionConstant(t=1){return i.e.connection(t)}async turnOn(){const t=i.e.activate();await this.appendToQueue(t,"relay:turn-on")}async turnOff(){const t=i.e.deactivate();await this.appendToQueue(t,"relay:turn-off")}async toggle({inverse:t=!1,ms:e=300}={}){if(!t){await this.turnOn(),await a.wait(e),await this.turnOff();return}await this.turnOff(),await a.wait(e),await this.turnOn()}}exports.Relay=o;
package/dist/relay.js CHANGED
@@ -1,4 +1,4 @@
1
- import { K as o, w as i } from "./kernel-lcvN8cY0.js";
1
+ import { K as o, w as i } from "./kernel-IUeiZp8d.js";
2
2
  import { e as a } from "./relay-Dop4mFk-.js";
3
3
  import { h as s } from "./webserial-core-DGKQCs5a.js";
4
4
  class p extends o {
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./kernel-BTqvt4pt.cjs"),r=require("./relay.cjs"),o=require("./locker.cjs"),i=require("./pinpad.cjs"),n=require("./pinpax.cjs"),t=require("./jofemar.cjs"),a=require("./boardroid.cjs"),s=require("./arduino.cjs"),u=require("./hopper.cjs"),c=require("./webserial-core-DlH0cFSH.cjs");/**
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./kernel-DlsHh4AG.cjs"),r=require("./relay.cjs"),o=require("./locker.cjs"),i=require("./pinpad.cjs"),n=require("./pinpax.cjs"),t=require("./jofemar.cjs"),a=require("./boardroid.cjs"),s=require("./arduino.cjs"),u=require("./hopper.cjs"),c=require("./webserial-core-DlH0cFSH.cjs");/**
2
2
  * @license Webserial
3
3
  * webserial
4
4
  *
package/dist/webserial.js CHANGED
@@ -1,5 +1,5 @@
1
- import { s as o, g as r, w as e } from "./kernel-lcvN8cY0.js";
2
- import { E as f, K as x } from "./kernel-lcvN8cY0.js";
1
+ import { s as o, g as r, w as e } from "./kernel-IUeiZp8d.js";
2
+ import { E as f, K as x } from "./kernel-IUeiZp8d.js";
3
3
  import { Relay as n } from "./relay.js";
4
4
  import { Locker as d } from "./locker.js";
5
5
  import { PinPad as u } from "./pinpad.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@danidoble/webserial",
3
- "version": "4.3.1",
3
+ "version": "4.3.2",
4
4
  "author": "danidoble",
5
5
  "repository": {
6
6
  "type": "git",