function r(n,e,s,t){if(typeof e=="function"?n!==e||!t:!e.has(n))throw new TypeError("Cannot read private member from an object whose class did not declare it");return s==="m"?t:s==="a"?t.call(n):t?t.value:e.get(n)}function l(n,e,s,t,u){if(typeof e=="function"?n!==e||!0:!e.has(n))throw new TypeError("Cannot write private member to an object whose class did not declare it");return e.set(n,s),s}var i,a,o,h;function f(n,e=!1){return window.__TAURI_INTERNALS__.transformCallback(n,e)}class p{constructor(){this.__TAURI_CHANNEL_MARKER__=!0,i.set(this,()=>{}),a.set(this,0),o.set(this,{}),this.id=f(({message:e,id:s})=>{if(s===r(this,a,"f")){l(this,a,s+1),r(this,i,"f").call(this,e);const t=Object.keys(r(this,o,"f"));if(t.length>0){let u=s+1;for(const _ of t.sort())if(parseInt(_)===u){const d=r(this,o,"f")[_];delete r(this,o,"f")[_],r(this,i,"f").call(this,d),u+=1}else break;l(this,a,u)}}else r(this,o,"f")[s.toString()]=e})}set onmessage(e){l(this,i,e)}get onmessage(){return r(this,i,"f")}toJSON(){return`__CHANNEL__:${this.id}`}}i=new WeakMap,a=new WeakMap,o=new WeakMap;class g{constructor(e,s,t){this.plugin=e,this.event=s,this.channelId=t}async unregister(){return c(`plugin:${this.plugin}|remove_listener`,{event:this.event,channelId:this.channelId})}}async function w(n,e,s){const t=new p;return t.onmessage=s,c(`plugin:${n}|register_listener`,{event:e,handler:t}).then(()=>new g(n,e,t.id))}async function m(n){return c(`plugin:${n}|check_permissions`)}async function I(n){return c(`plugin:${n}|request_permissions`)}async function c(n,e={},s){return window.__TAURI_INTERNALS__.invoke(n,e,s)}function k(n,e="asset"){return window.__TAURI_INTERNALS__.convertFileSrc(n,e)}class y{get rid(){return r(this,h,"f")}constructor(e){h.set(this,void 0),l(this,h,e)}async close(){return c("plugin:resources|close",{rid:this.rid})}}h=new WeakMap;function E(){return"isTauri"in window&&!!window.isTauri}export{p as Channel,g as PluginListener,y as Resource,w as addPluginListener,m as checkPermissions,k as convertFileSrc,c as invoke,E as isTauri,I as requestPermissions,f as transformCallback};
