function R(){return window.crypto.getRandomValues(new Uint32Array(1))[0]}function u(t,e=!1){let a=R(),i=`_${a}`;return Object.defineProperty(window,i,{value:r=>(e&&Reflect.deleteProperty(window,i),t?.(r)),writable:!1,configurable:!0}),a}async function _(t,e={}){return new Promise((a,i)=>{let r=u(l=>{a(l),Reflect.deleteProperty(window,`_${o}`)},!0),o=u(l=>{i(l),Reflect.deleteProperty(window,`_${r}`)},!0);window.__TAURI_IPC__({cmd:t,callback:r,error:o,...e})})}async function n(t){return _("tauri",t)}async function W(t,e){return n({__tauriModule:"Event",message:{cmd:"unlisten",event:t,eventId:e}})}async function g(t,e,a){await n({__tauriModule:"Event",message:{cmd:"emit",event:t,windowLabel:e,payload:a}})}async function c(t,e,a){return n({__tauriModule:"Event",message:{cmd:"listen",event:t,windowLabel:e,handler:u(a)}}).then(i=>async()=>W(t,i))}async function w(t,e,a){return c(t,e,i=>{a(i),W(t,i.id).catch(()=>{})})}var s;(function(t){t.WINDOW_RESIZED="tauri://resize",t.WINDOW_MOVED="tauri://move",t.WINDOW_CLOSE_REQUESTED="tauri://close-requested",t.WINDOW_CREATED="tauri://window-created",t.WINDOW_DESTROYED="tauri://destroyed",t.WINDOW_FOCUS="tauri://focus",t.WINDOW_BLUR="tauri://blur",t.WINDOW_SCALE_FACTOR_CHANGED="tauri://scale-change",t.WINDOW_THEME_CHANGED="tauri://theme-changed",t.WINDOW_FILE_DROP="tauri://file-drop",t.WINDOW_FILE_DROP_HOVER="tauri://file-drop-hover",t.WINDOW_FILE_DROP_CANCELLED="tauri://file-drop-cancelled",t.MENU="tauri://menu",t.CHECK_UPDATE="tauri://update",t.UPDATE_AVAILABLE="tauri://update-available",t.INSTALL_UPDATE="tauri://update-install",t.STATUS_UPDATE="tauri://update-status",t.DOWNLOAD_PROGRESS="tauri://update-download-progress"})(s||(s={}));async function f(t,e){return c(t,null,e)}var y;(function(t){t[t.Audio=1]="Audio",t[t.Cache=2]="Cache",t[t.Config=3]="Config",t[t.Data=4]="Data",t[t.LocalData=5]="LocalData",t[t.Desktop=6]="Desktop",t[t.Document=7]="Document",t[t.Download=8]="Download",t[t.Executable=9]="Executable",t[t.Font=10]="Font",t[t.Home=11]="Home",t[t.Picture=12]="Picture",t[t.Public=13]="Public",t[t.Runtime=14]="Runtime",t[t.Template=15]="Template",t[t.Video=16]="Video",t[t.Resource=17]="Resource",t[t.App=18]="App",t[t.Log=19]="Log",t[t.Temp=20]="Temp",t[t.AppConfig=21]="AppConfig",t[t.AppData=22]="AppData",t[t.AppLocalData=23]="AppLocalData",t[t.AppCache=24]="AppCache",t[t.AppLog=25]="AppLog"})(y||(y={}));var D;(function(t){t[t.JSON=1]="JSON",t[t.Text=2]="Text",t[t.Binary=3]="Binary"})(D||(D={}));function d(){return navigator.appVersion.includes("Win")}async function L(t){return n({__tauriModule:"Path",message:{cmd:"resolvePath",path:t,directory:y.Resource}})}var Pe=d()?"\\":"/",Ae=d()?";":":";var b=class{constructor(e,a){this.type="Logical",this.width=e,this.height=a}},m=class{constructor(e,a){this.type="Physical",this.width=e,this.height=a}toLogical(e){return new b(this.width/e,this.height/e)}},M=class{constructor(e,a){this.type="Logical",this.x=e,this.y=a}},p=class{constructor(e,a){this.type="Physical",this.x=e,this.y=a}toLogical(e){return new M(this.x/e,this.y/e)}},v;(function(t){t[t.Critical=1]="Critical",t[t.Informational=2]="Informational"})(v||(v={}));function T(){return window.__TAURI_METADATA__.__windows.map(t=>new h(t.label,{skip:!0}))}var O=["tauri://created","tauri://error"],P=class{constructor(e){this.label=e,this.listeners=Object.create(null)}async listen(e,a){return this._handleTauriEvent(e,a)?Promise.resolve(()=>{let i=this.listeners[e];i.splice(i.indexOf(a),1)}):c(e,this.label,a)}async once(e,a){return this._handleTauriEvent(e,a)?Promise.resolve(()=>{let i=this.listeners[e];i.splice(i.indexOf(a),1)}):w(e,this.label,a)}async emit(e,a){if(O.includes(e)){for(let i of this.listeners[e]||[])i({event:e,id:-1,windowLabel:this.label,payload:a});return Promise.resolve()}return g(e,this.label,a)}_handleTauriEvent(e,a){return O.includes(e)?(e in this.listeners?this.listeners[e].push(a):this.listeners[e]=[a],!0):!1}},A=class extends P{async scaleFactor(){return n({__tauriModule:"Window",message:{cmd:"manage",data:{label:this.label,cmd:{type:"scaleFactor"}}}})}async innerPosition(){return n({__tauriModule:"Window",message:{cmd:"manage",data:{label:this.label,cmd:{type:"innerPosition"}}}}).then(({x:e,y:a})=>new p(e,a))}async outerPosition(){return n({__tauriModule:"Window",message:{cmd:"manage",data:{label:this.label,cmd:{type:"outerPosition"}}}}).then(({x:e,y:a})=>new p(e,a))}async innerSize(){return n({__tauriModule:"Window",message:{cmd:"manage",data:{label:this.label,cmd:{type:"innerSize"}}}}).then(({width:e,height:a})=>new m(e,a))}async outerSize(){return n({__tauriModule:"Window",message:{cmd:"manage",data:{label:this.label,cmd:{type:"outerSize"}}}}).then(({width:e,height:a})=>new m(e,a))}async isFullscreen(){return n({__tauriModule:"Window",message:{cmd:"manage",data:{label:this.label,cmd:{type:"isFullscreen"}}}})}async isMinimized(){return n({__tauriModule:"Window",message:{cmd:"manage",data:{label:this.label,cmd:{type:"isMinimized"}}}})}async isMaximized(){return n({__tauriModule:"Window",message:{cmd:"manage",data:{label:this.label,cmd:{type:"isMaximized"}}}})}async isFocused(){return n({__tauriModule:"Window",message:{cmd:"manage",data:{label:this.label,cmd:{type:"isFocused"}}}})}async isDecorated(){return n({__tauriModule:"Window",message:{cmd:"manage",data:{label:this.label,cmd:{type:"isDecorated"}}}})}async isResizable(){return n({__tauriModule:"Window",message:{cmd:"manage",data:{label:this.label,cmd:{type:"isResizable"}}}})}async isMaximizable(){return n({__tauriModule:"Window",message:{cmd:"manage",data:{label:this.label,cmd:{type:"isMaximizable"}}}})}async isMinimizable(){return n({__tauriModule:"Window",message:{cmd:"manage",data:{label:this.label,cmd:{type:"isMinimizable"}}}})}async isClosable(){return n({__tauriModule:"Window",message:{cmd:"manage",data:{label:this.label,cmd:{type:"isClosable"}}}})}async isVisible(){return n({__tauriModule:"Window",message:{cmd:"manage",data:{label:this.label,cmd:{type:"isVisible"}}}})}async title(){return n({__tauriModule:"Window",message:{cmd:"manage",data:{label:this.label,cmd:{type:"title"}}}})}async theme(){return n({__tauriModule:"Window",message:{cmd:"manage",data:{label:this.label,cmd:{type:"theme"}}}})}async center(){return n({__tauriModule:"Window",message:{cmd:"manage",data:{label:this.label,cmd:{type:"center"}}}})}async requestUserAttention(e){let a=null;return e&&(e===v.Critical?a={type:"Critical"}:a={type:"Informational"}),n({__tauriModule:"Window",message:{cmd:"manage",data:{label:this.label,cmd:{type:"requestUserAttention",payload:a}}}})}async setResizable(e){return n({__tauriModule:"Window",message:{cmd:"manage",data:{label:this.label,cmd:{type:"setResizable",payload:e}}}})}async setMaximizable(e){return n({__tauriModule:"Window",message:{cmd:"manage",data:{label:this.label,cmd:{type:"setMaximizable",payload:e}}}})}async setMinimizable(e){return n({__tauriModule:"Window",message:{cmd:"manage",data:{label:this.label,cmd:{type:"setMinimizable",payload:e}}}})}async setClosable(e){return n({__tauriModule:"Window",message:{cmd:"manage",data:{label:this.label,cmd:{type:"setClosable",payload:e}}}})}async setTitle(e){return n({__tauriModule:"Window",message:{cmd:"manage",data:{label:this.label,cmd:{type:"setTitle",payload:e}}}})}async maximize(){return n({__tauriModule:"Window",message:{cmd:"manage",data:{label:this.label,cmd:{type:"maximize"}}}})}async unmaximize(){return n({__tauriModule:"Window",message:{cmd:"manage",data:{label:this.label,cmd:{type:"unmaximize"}}}})}async toggleMaximize(){return n({__tauriModule:"Window",message:{cmd:"manage",data:{label:this.label,cmd:{type:"toggleMaximize"}}}})}async minimize(){return n({__tauriModule:"Window",message:{cmd:"manage",data:{label:this.label,cmd:{type:"minimize"}}}})}async unminimize(){return n({__tauriModule:"Window",message:{cmd:"manage",data:{label:this.label,cmd:{type:"unminimize"}}}})}async show(){return n({__tauriModule:"Window",message:{cmd:"manage",data:{label:this.label,cmd:{type:"show"}}}})}async hide(){return n({__tauriModule:"Window",message:{cmd:"manage",data:{label:this.label,cmd:{type:"hide"}}}})}async close(){return n({__tauriModule:"Window",message:{cmd:"manage",data:{label:this.label,cmd:{type:"close"}}}})}async setDecorations(e){return n({__tauriModule:"Window",message:{cmd:"manage",data:{label:this.label,cmd:{type:"setDecorations",payload:e}}}})}async setAlwaysOnTop(e){return n({__tauriModule:"Window",message:{cmd:"manage",data:{label:this.label,cmd:{type:"setAlwaysOnTop",payload:e}}}})}async setContentProtected(e){return n({__tauriModule:"Window",message:{cmd:"manage",data:{label:this.label,cmd:{type:"setContentProtected",payload:e}}}})}async setSize(e){if(!e||e.type!=="Logical"&&e.type!=="Physical")throw new Error("the `size` argument must be either a LogicalSize or a PhysicalSize instance");return n({__tauriModule:"Window",message:{cmd:"manage",data:{label:this.label,cmd:{type:"setSize",payload:{type:e.type,data:{width:e.width,height:e.height}}}}}})}async setMinSize(e){if(e&&e.type!=="Logical"&&e.type!=="Physical")throw new Error("the `size` argument must be either a LogicalSize or a PhysicalSize instance");return n({__tauriModule:"Window",message:{cmd:"manage",data:{label:this.label,cmd:{type:"setMinSize",payload:e?{type:e.type,data:{width:e.width,height:e.height}}:null}}}})}async setMaxSize(e){if(e&&e.type!=="Logical"&&e.type!=="Physical")throw new Error("the `size` argument must be either a LogicalSize or a PhysicalSize instance");return n({__tauriModule:"Window",message:{cmd:"manage",data:{label:this.label,cmd:{type:"setMaxSize",payload:e?{type:e.type,data:{width:e.width,height:e.height}}:null}}}})}async setPosition(e){if(!e||e.type!=="Logical"&&e.type!=="Physical")throw new Error("the `position` argument must be either a LogicalPosition or a PhysicalPosition instance");return n({__tauriModule:"Window",message:{cmd:"manage",data:{label:this.label,cmd:{type:"setPosition",payload:{type:e.type,data:{x:e.x,y:e.y}}}}}})}async setFullscreen(e){return n({__tauriModule:"Window",message:{cmd:"manage",data:{label:this.label,cmd:{type:"setFullscreen",payload:e}}}})}async setFocus(){return n({__tauriModule:"Window",message:{cmd:"manage",data:{label:this.label,cmd:{type:"setFocus"}}}})}async setIcon(e){return n({__tauriModule:"Window",message:{cmd:"manage",data:{label:this.label,cmd:{type:"setIcon",payload:{icon:typeof e=="string"?e:Array.from(e)}}}}})}async setSkipTaskbar(e){return n({__tauriModule:"Window",message:{cmd:"manage",data:{label:this.label,cmd:{type:"setSkipTaskbar",payload:e}}}})}async setCursorGrab(e){return n({__tauriModule:"Window",message:{cmd:"manage",data:{label:this.label,cmd:{type:"setCursorGrab",payload:e}}}})}async setCursorVisible(e){return n({__tauriModule:"Window",message:{cmd:"manage",data:{label:this.label,cmd:{type:"setCursorVisible",payload:e}}}})}async setCursorIcon(e){return n({__tauriModule:"Window",message:{cmd:"manage",data:{label:this.label,cmd:{type:"setCursorIcon",payload:e}}}})}async setCursorPosition(e){if(!e||e.type!=="Logical"&&e.type!=="Physical")throw new Error("the `position` argument must be either a LogicalPosition or a PhysicalPosition instance");return n({__tauriModule:"Window",message:{cmd:"manage",data:{label:this.label,cmd:{type:"setCursorPosition",payload:{type:e.type,data:{x:e.x,y:e.y}}}}}})}async setIgnoreCursorEvents(e){return n({__tauriModule:"Window",message:{cmd:"manage",data:{label:this.label,cmd:{type:"setIgnoreCursorEvents",payload:e}}}})}async startDragging(){return n({__tauriModule:"Window",message:{cmd:"manage",data:{label:this.label,cmd:{type:"startDragging"}}}})}async onResized(e){return this.listen(s.WINDOW_RESIZED,a=>{a.payload=X(a.payload),e(a)})}async onMoved(e){return this.listen(s.WINDOW_MOVED,a=>{a.payload=Z(a.payload),e(a)})}async onCloseRequested(e){return this.listen(s.WINDOW_CLOSE_REQUESTED,a=>{let i=new x(a);Promise.resolve(e(i)).then(()=>{if(!i.isPreventDefault())return this.close()})})}async onFocusChanged(e){let a=await this.listen(s.WINDOW_FOCUS,r=>{e({...r,payload:!0})}),i=await this.listen(s.WINDOW_BLUR,r=>{e({...r,payload:!1})});return()=>{a(),i()}}async onScaleChanged(e){return this.listen(s.WINDOW_SCALE_FACTOR_CHANGED,e)}async onMenuClicked(e){return this.listen(s.MENU,e)}async onFileDropEvent(e){let a=await this.listen(s.WINDOW_FILE_DROP,o=>{e({...o,payload:{type:"drop",paths:o.payload}})}),i=await this.listen(s.WINDOW_FILE_DROP_HOVER,o=>{e({...o,payload:{type:"hover",paths:o.payload}})}),r=await this.listen(s.WINDOW_FILE_DROP_CANCELLED,o=>{e({...o,payload:{type:"cancel"}})});return()=>{a(),i(),r()}}async onThemeChanged(e){return this.listen(s.WINDOW_THEME_CHANGED,e)}},x=class{constructor(e){this._preventDefault=!1,this.event=e.event,this.windowLabel=e.windowLabel,this.id=e.id}preventDefault(){this._preventDefault=!0}isPreventDefault(){return this._preventDefault}},h=class t extends A{constructor(e,a={}){super(e),a?.skip||n({__tauriModule:"Window",message:{cmd:"createWebview",data:{options:{label:e,...a}}}}).then(async()=>this.emit("tauri://created")).catch(async i=>this.emit("tauri://error",i))}static getByLabel(e){return T().some(a=>a.label===e)?new t(e,{skip:!0}):null}static async getFocusedWindow(){for(let e of T())if(await e.isFocused())return e;return null}},S;"__TAURI_METADATA__"in window?S=new h(window.__TAURI_METADATA__.__currentWindow.label,{skip:!0}):(console.warn(`Could not find "window.__TAURI_METADATA__". The "appWindow" value will reference the "main" window label. Note that this is not an issue if running this frontend on a browser instead of a Tauri window.`),S=new h("main",{skip:!0}));function Z(t){return new p(t.x,t.y)}function X(t){return new m(t.width,t.height)}var Ie=d()?`\r `:` `;var F=_;var ae="plugin:context_menu|show_context_menu";async function Re(t){return await L(t)}async function k(t,e){let a=[],i=[...t.map(r=>({...r}))];for(let r=0;r{let N={...I,payload:t[r].payload};o(N)})),i[r].event=l,i[r].payload=void 0}if(t[r].subitems){let l=await k(t[r].subitems,`${e}_${r}`);a.push(...l.unlisteners),i[r].subitems=l.processed}}return{unlisteners:a,processed:i}}async function ne(t){let{unlisteners:e,processed:a}=await k(t.items,"root"),i=await f("menu-did-close",()=>{e.forEach(r=>r()),e.length=0,i()});F(ae,{...t,items:a})}function ze(t,e){window.addEventListener(t,async a=>{a.preventDefault(),typeof e=="function"&&(e=await e(a)),await ne(e)})}export{Re as assetToPath,ze as onEventShowMenu,ne as showMenu}; //# sourceMappingURL=index.js.map