import{c as v}from"./chunk-J36J6JDY.js";import{a as A,e as T,f as p}from"./chunk-JBSVAA72.js";import{B as h,H as O,Kb as u,Lb as I,sc as _,x as D}from"./chunk-IA4I4FFG.js";import{k as E}from"./chunk-24IZEI4V.js";var l=v("AppUpdate",{web:()=>import("./chunk-5I5A3CV7.js").then(n=>new n.AppUpdateWeb)});var o=[];for(let n=0;n<256;++n)o.push((n+256).toString(16).slice(1));function x(n,e=0){return(o[n[e+0]]+o[n[e+1]]+o[n[e+2]]+o[n[e+3]]+"-"+o[n[e+4]]+o[n[e+5]]+"-"+o[n[e+6]]+o[n[e+7]]+"-"+o[n[e+8]]+o[n[e+9]]+"-"+o[n[e+10]]+o[n[e+11]]+o[n[e+12]]+o[n[e+13]]+o[n[e+14]]+o[n[e+15]]).toLowerCase()}var L,w=new Uint8Array(16);function m(){if(!L){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");L=crypto.getRandomValues.bind(crypto)}return L(w)}var g={};function y(n,e,i){let s,c=n?._v6??!1;if(n){let t=Object.keys(n);t.length===1&&t[0]==="_v6"&&(n=void 0)}if(n)s=P(n.random??n.rng?.()??m(),n.msecs,n.nsecs,n.clockseq,n.node,e,i);else{let t=Date.now(),r=m();R(g,t,r),s=P(r,g.msecs,g.nsecs,c?void 0:g.clockseq,c?void 0:g.node,e,i)}return e??x(s)}function R(n,e,i){return n.msecs??=-1/0,n.nsecs??=0,e===n.msecs?(n.nsecs++,n.nsecs>=1e4&&(n.node=void 0,n.nsecs=0)):e>n.msecs?n.nsecs=0:e<n.msecs&&(n.node=void 0),n.node||(n.node=i.slice(10,16),n.node[0]|=1,n.clockseq=(i[8]<<8|i[9])&16383),n.msecs=e,n}function P(n,e,i,s,c,t,r=0){if(n.length<16)throw new Error("Random bytes length must be >= 16");if(!t)t=new Uint8Array(16),r=0;else if(r<0||r+16>t.length)throw new RangeError(`UUID byte range ${r}:${r+15} is out of buffer bounds`);e??=Date.now(),i??=0,s??=(n[8]<<8|n[9])&16383,c??=n.slice(10,16),e+=122192928e5;let f=((e&268435455)*1e4+i)%4294967296;t[r++]=f>>>24&255,t[r++]=f>>>16&255,t[r++]=f>>>8&255,t[r++]=f&255;let d=e/4294967296*1e4&268435455;t[r++]=d>>>8&255,t[r++]=d&255,t[r++]=d>>>24&15|16,t[r++]=d>>>16&255,t[r++]=s>>>8|128,t[r++]=s&255;for(let N=0;N<6;++N)t[r++]=c[N];return t}var a=y;var S=class n{constructor(){this.loading=h(_);this.injector=h(O);this.platform=h(u);this.electron=h(T);this.version=""}initapp(){return E(this,null,function*(){let e=yield this.loading.create({message:"Iniciando aplicaci\xF3n..."});if(e.present(),this.settings=this.injector.get(p),this.settings.clientId=a(),A.clientId=this.settings.clientId,yield this.settings.load()){this.electron.isElectron&&(console.log("is Electron app"),this.initElectronApp()),(yield this.platform.ready())==="capacitor"&&this.platform.is("android")&&(console.log("is Capacitor over Android platform"),yield this.checkForUpdatesAndroid());let i=this.injector.get(I);this.settings.currentSettings[this.settings.MANDATORY_SELECTING_CHEF]&&this.settings.currentSettings[this.settings.COD_TIPO_PANTALLA]!==this.settings.TIPO_PANTALLA_SECOND_MONITOR&&this.settings.currentSettings[this.settings.COD_TIPO_PANTALLA]!==this.settings.TIPO_PANTALLA_SEATING?i.navigateRoot("chef-selection"):i.navigateRoot("home")}else yield this.settings.setValue(this.settings.PASSWORD,"2001");A.clientId=this.settings.clientId,e.dismiss()})}initElectronApp(){if(!(!this.electron.isElectron||!this.electron.ipcRenderer)&&(this.settings.currentSettings[this.settings.DEBUG_MODE]&&this.electron.ipcRenderer.send(this.electron.channels.showDevTools),this.settings.currentSettings[this.settings.COD_TIPO_PANTALLA]===this.settings.TIPO_PANTALLA_SECOND_MONITOR&&this.electron.ipcRenderer.send(this.electron.channels.openInSecondMonitor),this.settings.currentSettings[this.settings.API_SERVER_URL]!=="")){let e=this.settings.currentSettings[this.settings.API_SERVER_URL];e.substr(e.length-1)!=="/"&&(e=e+"/"),this.electron.ipcRenderer.send(this.electron.channels.checkForKitchenControlUpdates,`${e}api/updates/KitchenControl/`),this.electron.ipcRenderer.on(this.electron.channels.updater,(i,s)=>{s==="update-downloaded"&&this.electron.ipcRenderer.send(this.electron.channels.quitAndInstallKitchenControlUpdate)})}}checkForUpdatesAndroid(){return E(this,null,function*(){let{currentVersionCode:e}=yield l.getAppUpdateInfo(),i=this.settings.currentSettings[this.settings.API_SERVER_URL]+"/api/updates/KitchenControl/android/android.xml?localVersion="+e+"&arch=android";console.log(i)})}static{this.\u0275fac=function(i){return new(i||n)}}static{this.\u0275prov=D({token:n,factory:n.\u0275fac,providedIn:"root"})}};export{S as a};
