import{B as k,j as g}from"./chunk-OKJYL2E7.js";import{G as E,U as f,b,j as y}from"./chunk-OXQYUXXW.js";import{a as m}from"./chunk-KAT7YFEL.js";var e={closeApp:"close-app",checkForUpdates:"check-for-updates",showDevTools:"show-dev-tools",disableTouchEmulation:"disable-touch-emulation",enableTouchEmulation:"enable-touch-emulation",quitAndInstallUpdate:"quit-and-install-update",printNetwork:"print-network",printNetworkResponse:"print-network-response",printUsb:"print-usb",printUsbResponse:"print-usb-response",printError:"print-error",cashDraw:"cash-draw",cashDrawResponse:"cash-draw-response",cashDrawError:"cash-draw-error",usbDevices:"get-devices",usbDevicesResponse:"get-devices-response",usbDevicesError:"get-devices-error",getUnsafe:"get-unsafe",getUnsafeResponse:"get-unsafe-response",getUnsafeError:"get-unsafe-error",socketWrite:"socket-write",socketWriteResponse:"socket-write-response",socketWriteError:"socket-write-error",socketRead:"socket-read",socketReadResponse:"socket-read-response",socketReadError:"socket-read-error",socketClose:"socket-close",socketCloseResponse:"socket-close-response",socketCloseError:"socket-close-error",socketConnect:"socket-connect",socketConnectResponse:"socket-connect-response",socketConnectError:"socket-connect-error"},w;function R(){return w||(w=window.require("electron").ipcRenderer),w}function h(s,t,r,n){let c=R();return new Promise((o,i)=>{c.once(t,(a,p)=>o(p)),c.once(r,(a,p)=>i(p)),c.send(s,n)})}function u(s,t,r,n,c={}){let o=R();return new Promise((i,a)=>{let p=(D,d)=>{d.id===s&&(o.off(r,p),o.off(n,l),i(d.response))},l=(D,d)=>{d.id===s&&(o.off(r,p),o.off(n,l),a(d.response))};o.on(n,l),o.on(r,p),o.send(t,m({id:s},c))})}function U(s){return"address"in s?h(e.printNetwork,e.printNetworkResponse,e.printError,s):h(e.printUsb,e.printUsbResponse,e.printError,s)}function T(s){return u(k(),e.getUnsafe,e.getUnsafeResponse,e.getUnsafeError,s)}function F(s){return h(e.cashDraw,e.cashDrawResponse,e.cashDrawError,s)}function v(s){return new b(t=>{let r=R(),n=(o,i)=>{i.id===s&&t.next(i.response)},c=(o,i)=>{i.id===s&&t.error(i.response)};return r.on(e.socketReadResponse,n),r.on(e.socketReadError,c),r.send(e.socketRead,{id:s}),()=>{r.off(e.socketReadResponse,n),r.off(e.socketReadError,c)}})}async function q(s,t){let r=k();return await u(r,e.socketConnect,e.socketConnectResponse,e.socketConnectError,{address:s,port:t}),{close:()=>u(r,e.socketClose,e.socketCloseResponse,e.socketCloseError),write:n=>u(r,e.socketWrite,e.socketWriteResponse,e.socketWriteError,{data:n}),read:()=>v(r),readFirst:()=>y(v(r))}}function P(){return!!window?.process?.type}var V={print:U,cashDraw:F,httpUnsafe:T,openSocket:q,isElectron:P};var C=class s{ipcRenderer;webFrame;childProcess;fs;app;channels;constructor(){this.isElectron&&(this.ipcRenderer=window.require("electron").ipcRenderer,this.webFrame=window.require("electron").webFrame,this.app=window.require("electron").app,this.fs=window.require("fs"),this.childProcess=window.require("child_process"),this.channels=e)}resource(t){let r=f("idle"),n=f(void 0),c=async()=>{if(!this.isElectron)return!1;try{let o=await this.get(t.send,t.on,t.error),i=t.transform?.(o)??o;return n.set(i),r.set("resolved"),!0}catch(o){return g.error(o),r.set("error"),!1}};return c(),Object.assign(n.asReadonly(),{reload:c,status:r.asReadonly()})}async get(t,r,n){return new Promise((c,o)=>{this.ipcRenderer.send(t),this.ipcRenderer.once(r,(i,a)=>c(a)),this.ipcRenderer.once(n,(i,a)=>o(a))})}get isElectron(){return!!window?.process?.type}static \u0275fac=function(r){return new(r||s)};static \u0275prov=E({token:s,factory:s.\u0275fac,providedIn:"root"})};export{V as a,C as b};
