openrtc 1.0.13 → 1.0.14
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/auth/index.d.ts +2 -0
- package/dist/auth/index.js +1 -1
- package/dist/auth/internal.js +1 -1
- package/dist/{chunk-NP3JZ2LD.js → chunk-6J3QKQRS.js} +1 -1
- package/dist/chunk-HFWOWDEH.js +2 -0
- package/dist/{chunk-HXTGHALT.js → chunk-JGBEYISL.js} +1 -1
- package/dist/{chunk-WFUW3BHK.js → chunk-R5P73PEG.js} +1 -1
- package/dist/chunk-SVBFZRGV.js +2 -0
- package/dist/{chunk-LVJSU53Y.js → chunk-TOO3FUPK.js} +1 -1
- package/dist/chunk-TW4HQLK6.js +1 -0
- package/dist/{chunk-KP5H3SYJ.js → chunk-W5YFLH2U.js} +1 -1
- package/dist/index.js +1 -1
- package/dist/native.js +1 -1
- package/dist/runtime/WasmRuntimeAdapter.js +1 -1
- package/dist/runtime/index.js +1 -1
- package/dist/runtime/tauri.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-3SND2COC.js +0 -1
- package/dist/chunk-YFNRKQEA.js +0 -2
- package/dist/chunk-ZZIIBIEC.js +0 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
import {g,h}from'./chunk-
|
|
1
|
+
import {g,h}from'./chunk-W5YFLH2U.js';function c(){return g()}var i=class extends h{constructor(r){super({...r,bridge:g(),allowWasmFallback:r.allowWasmFallback??false});}};export{c as a,i as b};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import {c as c$1}from'./chunk-C7YN5MSV.js';import {getApps,initializeApp}from'firebase/app';import {getToken,initializeAppCheck,ReCaptchaEnterpriseProvider}from'firebase/app-check';import {getFunctions,connectFunctionsEmulator,httpsCallable}from'firebase/functions';import {browserLocalPersistence,inMemoryPersistence,browserPopupRedirectResolver,initializeAuth,getAuth,connectAuthEmulator,setPersistence,onIdTokenChanged,getIdToken,signInWithCustomToken,onAuthStateChanged,signInAnonymously,signInWithEmailAndPassword,createUserWithEmailAndPassword,signOut,deleteUser,updateProfile,GoogleAuthProvider,OAuthProvider,signInWithCredential,signInWithPopup,signInWithRedirect,getRedirectResult}from'firebase/auth';function D(){return typeof window>"u"?false:!!(window.__TAURI_IPC__||window.__TAURI_INTERNALS__||window.__TAURI__||window.location.protocol==="tauri:"||window.location.hostname==="tauri.localhost")}var L=new Set;function I(t,e){L.has(t)||(L.add(t),console.warn(e));}function oe(t){return /^pk_(live|test)_[0-9a-f]{40}$/.test(t)}async function je(t,e){let n=`${t}:${e}`,o=new TextEncoder().encode(n),i=await crypto.subtle.digest("SHA-256",o);return Array.from(new Uint8Array(i)).map(d=>d.toString(16).padStart(2,"0")).join("")}function S(t){let e=typeof t.apiKey=="string"?t.apiKey.trim():"";if(e)return oe(e)||I(`invalid-api-key:${e.slice(0,10)}`,"[pluto-rtc] The provided `apiKey` does not match the expected format (pk_live_... or pk_test_...). Create an app at https://api.openrtc.app/developer."),`app_${e.slice(-16)}`;throw new Error("[openrtc] `apiKey` is required. Create an app at https://api.openrtc.app/developer.")}function P(t){return t.authMode?t.authMode:("apiKey"in t&&typeof t.apiKey=="string"&&t.apiKey.trim().length>0&&typeof(t.spaceKey??t.space)=="string"&&(t.spaceKey??t.space).trim().length>0||I("default-auth-mode","[pluto-rtc] `authMode` is not set; defaulting to `anonymous` for compatibility."),"anonymous")}function Ge(t){let e=typeof t.projectId=="string"?t.projectId.trim():"";return e||(I("default-project-id","[pluto-rtc] `projectId` is not set; defaulting to the built-in PlutoRTC Firebase project."),f)}function H(t){return t.trim().replace(/[^a-zA-Z0-9._-]+/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"")}function ze(t){let e="storagePrefix"in t&&typeof t.storagePrefix=="string"?H(t.storagePrefix):"";return e||H(S(t))||"default"}var ie={devicesPerUser:100,maxRooms:1e4,maxMembersPerRoom:250,maxPersonalDevices:25e3},$e=ie;var ae=[{urls:"stun:stun.l.google.com:19302"},{urls:"stun:stun.cloudflare.com:3478"}],B={iceServers:ae},Ye={};var F=["iroh-relay","iroh","moq"];function se(t){return (Array.isArray(t.urls)?t.urls:[t.urls]).some(n=>typeof n=="string"&&(n.startsWith("turn:")||n.startsWith("turns:")))}function ce(t){let n=(Array.isArray(t.urls)?t.urls:[t.urls]).filter(r=>typeof r=="string"&&!r.startsWith("stun:"));return n.length===0?null:{...t,urls:Array.isArray(t.urls)?n:n[0]}}function R(t){if(t)return t.map(e=>ce(e)).filter(e=>e!==null)}function K(t,e){let n=new Set(["iroh-relay","iroh","moq"]);e&&n.add("webrtc");let r=(t??F).filter(o=>n.has(o));return r.length>0?r:[...F]}function Je(t){return !!t?.transports?.webrtc}function Xe(t,e){let n=t?.transports?.webrtc||void 0;if(n)return t?.strictMode||n.privacyMode?{...n,iceServers:R(n.iceServers),iceTransportPolicy:"relay"}:n.iceTransportPolicy==="relay"&&!(Array.isArray(n.iceServers)&&n.iceServers.some(o=>se(o)))?(e?.("[Client] Overriding relay-only ICE policy to all because no TURN servers are configured"),{...n,iceTransportPolicy:"all"}):n}var le=/^[A-Za-z0-9._-]+$/,de="[redacted]";function q(t){let e;try{e=new URL(t);}catch{throw new Error("[OpenRTC] transports.moq.relayUrl must be a valid HTTPS URL.")}if(e.protocol!=="https:")throw new Error("[OpenRTC] transports.moq.relayUrl must use HTTPS/WebTransport.");if(e.hash)throw new Error("[OpenRTC] transports.moq.relayUrl must not contain a fragment.");if(e.searchParams.has("jwt"))throw new Error("[OpenRTC] transports.moq.relayUrl must not contain a jwt query parameter; use transports.moq.accessToken.");return e}function C(t){return q(t.trim()).toString()}function et(t,e){let n=q(t.trim());if(e!==void 0){let r=e.trim();if(!r)throw new Error("[OpenRTC] transports.moq.accessToken must not be empty when provided.");if(new TextEncoder().encode(r).byteLength>16384)throw new Error("[OpenRTC] transports.moq.accessToken exceeds the maximum supported size.");if(!le.test(r))throw new Error("[OpenRTC] transports.moq.accessToken must be a URL-safe JWT.");n.searchParams.append("jwt",r);}return n.toString()}function tt(t){try{let e=new URL(t);return e.search="",e.hash="",e.toString()}catch{return "invalid-moq-relay-url"}}function nt(t,e){let n=t instanceof Error?`${t.name}: ${t.message}`:String(t),r=e?.trim();return r?n.split(r).join(de):n}var ue=[...c$1];function A(t){let e=t.spaceKey??t.space;return {...t,...e!==void 0?{spaceKey:e}:{}}}function W(t){return {...t,iceServers:t.iceServers?t.iceServers.map(e=>({...e})):t.iceServers}}function pe(t){return {...t}}function me(t){return {...t}}function ge(t){if(t)return {iroh:typeof t.iroh=="object"?me(t.iroh):t.iroh,webrtc:typeof t.webrtc=="object"?W(t.webrtc):t.webrtc,ble:typeof t.ble=="object"?{...t.ble}:t.ble,moq:typeof t.moq=="object"?pe(t.moq):t.moq}}function ye(t){if(t.strictMode&&!t.transports&&(t.transports={iroh:{relayOnly:true}}),!!t.transports){if(t.transports.webrtc===true?t.transports.webrtc=W(B):t.transports.webrtc===false&&(t.transports.webrtc=void 0),t.transports.moq===true)throw new Error("[OpenRTC] transports.moq=true is ambiguous because no anonymous MoQ relay is available; provide transports.moq.relayUrl explicitly.");if(t.transports.moq===false)t.transports.moq=void 0;else if(t.transports.moq&&typeof t.transports.moq=="object"){let e=t.transports.moq,n=e.relayUrl?.trim(),r=e.accessToken;if(r!==void 0&&!r.trim())throw new Error("[OpenRTC] transports.moq.accessToken must not be empty when provided.");t.transports.moq={...e,...n?{relayUrl:C(n)}:{},...r!==void 0?{accessToken:r.trim()}:{}};}t.transports.iroh===true?t.transports.iroh={}:t.transports.iroh===false&&(t.transports.iroh=void 0);}}function fe(t){if(!t.strictMode||!t.transports)return;let e=t.transports.iroh&&typeof t.transports.iroh=="object"?t.transports.iroh:{};t.transports.iroh={...e,relayOnly:true,relayTransportPolicy:e.relayTransportPolicy??"websocketRequired",localDiscovery:false,localDiscoveryMode:void 0},t.transports.ble=void 0;let n=t.transports.webrtc;n&&typeof n=="object"&&(t.transports.webrtc={...n,privacyMode:true,lanMode:false,iceServers:R(n.iceServers)??[],iceTransportPolicy:"relay"});let r=t.transports.moq;if(r&&typeof r=="object"){let o=r.relayUrl?.trim();if(!o)throw new Error("[OpenRTC] strictMode requires an explicit transports.moq.relayUrl.");t.transports.moq={...r,relayUrl:C(o)};}}function lt(t){let e=A(t),n=S(e),r=P(e),o={strictMode:false,disableIrohFallback:false,transportPriority:[...ue],...e,authMode:r,transports:ge(e.transports)};ye(o),fe(o),o.strictMode&&(o.transportPriority=K(e.transportPriority,!!o.transports?.webrtc));let i=j(o),a=(o.discoveryMode??"space")==="space"?"client-open":"client-auth";return {appTag:n,authMode:r,configuredPersistenceMode:i,options:o,roomCreationMode:a}}function j(t){let e=t.transports?.iroh;return t.endpointIdPersistence??t.nodeIdPersistence??(typeof e=="object"?e.persistenceMode:void 0)??"ephemeral"}function dt(t){return "options"in t&&"configuredPersistenceMode"in t?{apiKey:t.options.apiKey,authMode:P(t.options),projectId:t.options.projectId,storagePrefix:t.options.storagePrefix,nodeIdPersistence:t.configuredPersistenceMode}:{apiKey:t.apiKey,authMode:P(t),projectId:t.projectId,storagePrefix:t.storagePrefix,nodeIdPersistence:j(t)}}function ut(t,e){e&&(t.transports={...t.transports||{},...e});}var f="pluto-rtc-prod",he="https://openrtc-coordination-gateway.hargreaves-bryant.workers.dev",k={apiKey:"AIzaSyA62Krj-7ZYFT5xjrTUq7mXana41Ahj_mM",authDomain:"api.openrtc.app",projectId:f,storageBucket:"pluto-rtc-prod.firebasestorage.app",messagingSenderId:"607066575224",appId:"1:607066575224:web:ed3f51825ba228db92b88d",recaptchaSiteKey:"6LfGv2gtAAAAALFAuE_kpLYpNBpk2IsKiLIGdOGl"};function gt(t){let e=A(t),n=typeof e.projectId=="string"&&e.projectId.trim()?e.projectId.trim():void 0,r=n??f;return {...e,projectId:r,coordinationGateway:e.coordinationGateway??(!n&&r===f?{endpoint:he,environment:"production"}:void 0)}}function G(t){return new Promise(e=>setTimeout(e,t))}function ft(t){let e=new Uint8Array(t.byteLength);return e.set(t),e}function ht(t){let e=t.reduce((o,i)=>o+i.byteLength,0),n=new Uint8Array(e),r=0;for(let o of t)n.set(o,r),r+=o.byteLength;return n}function bt(t,e,n){let r=e*Math.pow(2,Math.max(0,t-1));return Math.min(n,r)}function Tt(t){try{let e=t;return !!e&&!!e.send&&typeof e.send.getWriter=="function"&&!!e.recv&&typeof e.recv.getReader=="function"}catch{return false}}function Pt(t,e,n){let r=t;if(!r)return null;try{let o=r.send,i=r.recv;if(!o||typeof o.getWriter!="function"||!i||typeof i.getReader!="function")return null;let a=typeof r.endpoint_id=="string"&&r.endpoint_id.trim().length>0?r.endpoint_id:e,l=Number.isSafeInteger(r.transport_stable_id)&&Number(r.transport_stable_id)>0?Number(r.transport_stable_id):void 0,d=Number.isSafeInteger(n)&&Number(n)>0?Number(n):void 0;if(l!==void 0&&d!==void 0&&l!==d)return null;let s=l??d;return {send:o,recv:i,endpoint_id:a,...s?{transport_stable_id:s}:{}}}catch{return null}}function vt(t,e){let n={send:t.send,recv:e,endpoint_id:typeof t.endpoint_id=="string"?t.endpoint_id:"",...Number.isSafeInteger(t.transport_stable_id)&&Number(t.transport_stable_id)>0?{transport_stable_id:Number(t.transport_stable_id)}:{}};return t?.applicationCryptoWrapped===true&&(n.applicationCryptoWrapped=true),n}async function It(t,e){if(!t)return false;try{let n=t.send?.getWriter?.();if(n)try{await n.close();}catch{}finally{try{n.releaseLock();}catch{}}}catch{}try{let n=t.recv?.getReader?.();if(n)try{await n.cancel(e);}catch{}finally{try{n.releaseLock();}catch{}}}catch{}return true}function St(t,e,n={}){let r=n.context??"prependBytesToReader",o=n.traceId,i=e.byteLength===0,a=n.pendingRead??null,l=s=>n.release?.(s),d=(s,p)=>n.log?.(s,p);return new ReadableStream({async pull(s){if(!i){i=true,s.enqueue(e);return}if(a){let u=a;a=null;let m;try{m=await u;}catch(y){s.error(y),l("pending-read-error"),d("prepend-bytes:pending-read-error",{context:r,traceId:o||null,error:y?.message||String(y)});return}if(m.done){s.close(),l("pending-done");return}m.value&&s.enqueue(m.value);return}let p;try{p=await t.read();}catch(u){s.error(u),l("read-error"),d("prepend-bytes:read-error",{context:r,traceId:o||null,error:u?.message||String(u)});return}let{done:v,value:T}=p;if(v){s.close(),l("done");return}T&&s.enqueue(T);},async cancel(s){l("cancel");}})}async function Rt(t,e){let n=t.read(),r=e-Date.now();if(r<=0)return {status:"timeout",pendingRead:n};let o=Symbol("probe-timeout"),i,a=new Promise(l=>{i=setTimeout(()=>l(o),r);});try{let l=await Promise.race([n,a]);if(l===o)return {status:"timeout",pendingRead:n};let{done:d,value:s}=l;return d?{status:"done"}:{status:"data",value:s&&s.byteLength>0?new Uint8Array(s):new Uint8Array(0)}}finally{i&&clearTimeout(i);}}function z(t,e,n){let r;return new Promise((o,i)=>{r=setTimeout(()=>{if(r=void 0,typeof n=="function"){i(n());return}let a=n?`${n} timed out`:"timeout";i(new Error(`${a} after ${e}ms`));},e),t.then(a=>{r!==void 0&&clearTimeout(r),o(a);},a=>{r!==void 0&&clearTimeout(r),i(a);});})}var X="pluto-rtc-auth";function He(t){let e=typeof import.meta<"u"?import.meta.env:null,n=String(e?.VITE_OPENRTC_APP_CHECK_SITE_KEY??globalThis.__OPENRTC_APP_CHECK_SITE_KEY__??k.recaptchaSiteKey??"").trim(),r=String(e?.VITE_OPENRTC_APP_CHECK_MODE??globalThis.__OPENRTC_APP_CHECK_MODE__??"monitor").trim().toLowerCase();if(!n)return r==="enforce"&&console.error("[PLUTO-RTC][APP-CHECK] Enforcement requested without VITE_OPENRTC_APP_CHECK_SITE_KEY"),null;let o=String(e?.VITE_OPENRTC_APP_CHECK_DEBUG_TOKEN??"").trim();o&&e?.DEV!==true?console.error("[PLUTO-RTC][APP-CHECK] Debug tokens are allowed only in development builds"):o&&typeof self<"u"&&(self.FIREBASE_APPCHECK_DEBUG_TOKEN=o==="true"?true:o);try{return initializeAppCheck(t,{provider:new ReCaptchaEnterpriseProvider(n),isTokenAutoRefreshEnabled:!0})}catch(i){let a=i instanceof Error?i.message:String(i);return a.toLowerCase().includes("already exists")||console.warn("[PLUTO-RTC][APP-CHECK] Initialization failed",{message:a}),null}}var _=null;function Be(){if(typeof globalThis<"u"&&globalThis.__OPENRTC_DEBUG__===true)return true;if(typeof localStorage<"u")try{return localStorage.getItem("openrtc:debug")==="1"}catch{return false}return false}function c(t,e){if(Be()){if(typeof e>"u"){console.log(t);return}console.log(t,e);}}function Kt(t){_=t;}function Fe(){return D()}function ne(){return typeof navigator>"u"?false:/iPhone|iPad|iPod|Android/i.test(navigator.userAgent||"")}function Z(){return Fe()&&ne()}function g(t,e,n){return z(t,e,()=>new Error(`${n} timeout after ${e}ms`))}function ee(t){let e="0123456789ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvwxyz-._",n=new Uint8Array(t);window.crypto.getRandomValues(n);let r="";for(let o=0;o<t;o+=1)r+=e[n[o]%e.length];return r}async function te(t){let n=new TextEncoder().encode(t),r=await crypto.subtle.digest("SHA-256",n);return Array.from(new Uint8Array(r)).map(i=>i.toString(16).padStart(2,"0")).join("")}var E=class{constructor(){this.redirectResultPromise=null;this.redirectResultConsumed=false;this.lastRelayedToken=null;this.lastRelayedRefreshToken=null;this.desktopTokenRefreshIntervalId=null;let e=getApps().find(o=>o.name===X);this.app=e||initializeApp(k,X),this.appCheck=He(this.app);let n=ne(),r=Z();if(n)try{let o=r?{persistence:[browserLocalPersistence,inMemoryPersistence]}:{persistence:[browserLocalPersistence,inMemoryPersistence],popupRedirectResolver:browserPopupRedirectResolver};this.auth=initializeAuth(this.app,o),c("[PLUTO-RTC][AUTH-HOST] Using mobile-safe Firebase auth initialization",{appName:this.app.name,persistence:"browserLocalPersistence->inMemoryPersistence",redirectResolver:r?"disabled-for-tauri-mobile":"browserPopupRedirectResolver",tauriMobile:r});}catch{this.auth=getAuth(this.app),console.warn("[PLUTO-RTC][AUTH-HOST] Mobile-safe auth initialization unavailable; falling back to default getAuth");}else this.auth=getAuth(this.app);this.functions=getFunctions(this.app);try{let o=typeof globalThis<"u"?String(globalThis.__OPENRTC_AUTH_EMULATOR_HOST__??"").trim():"",i=typeof globalThis<"u"?String(globalThis.__OPENRTC_FUNCTIONS_EMULATOR_HOST__??"").trim():"",a=typeof import.meta<"u"?import.meta.env:null;if(!!o||!!i||!!a&&String(a.VITE_USE_EMULATORS)==="true"&&(a.DEV||String(a.VITE_E2E)==="true")){let d=String(a?.VITE_OPENRTC_EMULATOR_HOST??"127.0.0.1").trim()||"127.0.0.1",[s,p]=o.split(":"),[v,T]=i.split(":"),u=(s??"").trim()||d,m=(v??"").trim()||d,y=Number(p??a?.VITE_OPENRTC_AUTH_EMULATOR_PORT??9100),re=Number(T??a?.VITE_OPENRTC_FUNCTIONS_EMULATOR_PORT??5002);try{connectAuthEmulator(this.auth,`http://${u}:${y}`,{disableWarnings:!0});}catch{}try{connectFunctionsEmulator(this.functions,m,re);}catch{}}}catch{}n?this.persistenceReady=Promise.resolve():this.persistenceReady=setPersistence(this.auth,browserLocalPersistence).catch(o=>{console.warn("[PLUTO-RTC][AUTH-HOST] Failed to set auth persistence",{message:o?.message});}),c("[PLUTO-RTC][AUTH-HOST] Initialized auth host",{appName:this.app.name,mobileSafeAuth:n}),onIdTokenChanged(this.auth,o=>{c("[PLUTO-RTC][AUTH-HOST] Firebase ID token changed",{hasUser:!!o,uid:o?.uid,providerDataCount:o?.providerData?.length||0}),this.syncDesktopAuthToken(o);}),this.desktopTokenRefreshIntervalId||(this.desktopTokenRefreshIntervalId=setInterval(()=>{this.syncDesktopAuthToken(this.auth.currentUser,true);},600*1e3));}async syncDesktopAuthToken(e,n=false){if(!_)return;let r=e?await getIdToken(e,n).catch(()=>null):null,o=e?e.refreshToken??null:null;if(r===this.lastRelayedToken&&o===this.lastRelayedRefreshToken)return;this.lastRelayedToken=r,this.lastRelayedRefreshToken=o;let i=await Promise.allSettled([Promise.resolve(_({authToken:r,refreshToken:o}))]);i[0]?.status==="rejected"&&console.warn("[PLUTO-RTC][AUTH-HOST] Failed to relay auth token to desktop backend",{message:i[0].reason?.message});}getApp(){return this.app}async getAppCheckToken(e=false){if(!this.appCheck)return null;try{return (await getToken(this.appCheck,e)).token?.trim()||null}catch(n){let r=n instanceof Error?n.message:String(n);return console.warn("[PLUTO-RTC][APP-CHECK] Token acquisition failed",{message:r}),null}}getCurrentUser(){return this.auth.currentUser}getAuth(){return this.auth}onAuthStateChanged(e){return c("[PLUTO-RTC][AUTH-HOST] onAuthStateChanged listener registered (via onIdTokenChanged)"),onIdTokenChanged(this.auth,e)}onIdTokenChanged(e){return c("[PLUTO-RTC][AUTH-HOST] onIdTokenChanged listener registered"),onIdTokenChanged(this.auth,e)}async getIdToken(e){return this.auth.currentUser?getIdToken(this.auth.currentUser,e?.forceRefresh??true):null}async checkForSSOToken(){if(typeof window>"u")return;let e=new URLSearchParams(window.location.search),n=new URLSearchParams(window.location.hash.startsWith("#")?window.location.hash.slice(1):window.location.hash),r=e.get("token")||n.get("token")||(e.get("custom_token")==="true"||n.get("custom_token")==="true"?e.get("id_token")||n.get("id_token"):null);if(r)try{await this.persistenceReady,await signInWithCustomToken(this.auth,r),window.history.replaceState({},document.title,window.location.pathname);}catch(o){console.error("[PLUTO-RTC][AUTH-HOST] SSO sign-in failed:",o);}}async signInWithCustomTokenValue(e){return await this.persistenceReady,(await signInWithCustomToken(this.auth,e)).user}async signInWithPluto(e){if(typeof window>"u")throw new Error("Pluto SSO requires a browser environment.");let n=e?.redirectUri||window.location.href,r=e?.authorizeBaseUrl||"https://pluto.openrtc.app/sso/authorize",o=new URL(r);o.searchParams.set("redirect_uri",n),window.location.assign(o.toString());}async waitForAuth(){if(await this.persistenceReady,!this.auth.currentUser)return new Promise(e=>{let n=onAuthStateChanged(this.auth,r=>{r&&(n(),e());});})}async signInAnonymously(){await signInAnonymously(this.auth);}async signIn(e,n){return (await signInWithEmailAndPassword(this.auth,e,n)).user}async signUp(e,n){return (await createUserWithEmailAndPassword(this.auth,e,n)).user}async signOut(){await signOut(this.auth);}async deleteAccount(){if(!this.auth.currentUser)throw new Error("No user signed in");await deleteUser(this.auth.currentUser);}async signInWithCredential(e){let n=Date.now();if(c("[PLUTO-RTC][AUTH-HOST] signInWithCredential start",{callbackId:e.callbackId,provider:e.provider,hasIdToken:!!e.idToken,hasAccessToken:!!e.accessToken,hasNonce:!!e.nonce}),e.isCustomToken){c("[PLUTO-RTC][AUTH-HOST] signInWithCredential: custom token detected, using signInWithCustomToken");try{if(Z())c("[PLUTO-RTC][AUTH-HOST] Skipping authStateReady before custom token sign-in on Tauri mobile",{callbackId:e.callbackId});else {c("[PLUTO-RTC][AUTH-HOST] Awaiting authStateReady...");try{await g(this.auth.authStateReady(),5e3,"authStateReady"),c("[PLUTO-RTC][AUTH-HOST] Auth state ready, signing in with custom token...");}catch(a){console.warn("[PLUTO-RTC][AUTH-HOST] authStateReady did not resolve in time; continuing custom token sign-in",{callbackId:e.callbackId,message:a?.message});}}let i;try{i=await g(signInWithCustomToken(this.auth,e.idToken),25e3,"signInWithCustomToken (custom token path)");}catch(a){console.warn("[PLUTO-RTC][AUTH-HOST] First custom token sign-in attempt failed; retrying once",{callbackId:e.callbackId,message:a?.message,code:a?.code}),await G(250),i=await g(signInWithCustomToken(this.auth,e.idToken),25e3,"signInWithCustomToken (custom token path retry)");}if(c("[PLUTO-RTC][AUTH-HOST] signInWithCustomToken success",{callbackId:e.callbackId,provider:e.provider,uid:i.user?.uid,elapsedMs:Date.now()-n}),i.user&&(e.displayName||e.photoURL))try{await updateProfile(i.user,{displayName:e.displayName||i.user.displayName||void 0,photoURL:e.photoURL||i.user.photoURL||void 0});}catch(a){console.warn("[PLUTO-RTC][AUTH-HOST] Failed to update custom-token user profile",{callbackId:e.callbackId,message:a?.message});}return i.user}catch(o){throw console.error("[PLUTO-RTC][AUTH-HOST] signInWithCustomToken failed",{callbackId:e.callbackId,error:o?.message,code:o?.code,stack:o?.stack,elapsedMs:Date.now()-n}),o}}let r;e.provider==="google"?r=GoogleAuthProvider.credential(e.idToken,e.accessToken):r=new OAuthProvider("apple.com").credential({idToken:e.idToken,rawNonce:e.nonce,accessToken:e.accessToken});try{let o=await g(signInWithCredential(this.auth,r),1e4,"firebase signInWithCredential");return c("[PLUTO-RTC][AUTH-HOST] signInWithCredential success",{callbackId:e.callbackId,provider:e.provider,uid:o.user?.uid,elapsedMs:Date.now()-n}),o.user}catch(o){console.warn("[PLUTO-RTC][AUTH-HOST] signInWithCredential primary path failed; trying custom token fallback",{callbackId:e.callbackId,provider:e.provider,elapsedMs:Date.now()-n,code:o?.code,message:o?.message});let i=await g(this.mintSessionTokenFromProviderToken(e),15e3,"mintSessionTokenFromProviderToken"),a=await g(signInWithCustomToken(this.auth,i),15e3,"signInWithCustomToken");return c("[PLUTO-RTC][AUTH-HOST] signInWithCustomToken fallback success",{callbackId:e.callbackId,provider:e.provider,uid:a.user?.uid,elapsedMs:Date.now()-n}),a.user}}async mintSessionTokenFromProviderToken(e){let n=httpsCallable(this.functions,"mintSessionToken");c("[PLUTO-RTC][AUTH-HOST] mintSessionToken fallback request start",{provider:e.provider,hasIdToken:!!e.idToken,hasNonce:!!e.nonce});let o=(await n({provider:e.provider,idToken:e.idToken,nonce:e.nonce})).data?.token;if(!o)throw new Error("mintSessionToken did not return a token for provider exchange");return c("[PLUTO-RTC][AUTH-HOST] mintSessionToken fallback request success",{provider:e.provider}),o}async signInWithPopup(e){if(e==="google"){let i=new GoogleAuthProvider;i.addScope("email"),i.addScope("profile"),i.setCustomParameters({prompt:"select_account"});let a=await signInWithPopup(this.auth,i);return {idToken:await getIdToken(a.user,true),refreshToken:a.user.refreshToken}}let n=new OAuthProvider("apple.com");n.addScope("email"),n.addScope("name");let r=ee(32);typeof sessionStorage<"u"&&sessionStorage.setItem("apple_auth_nonce",r),n.setCustomParameters({nonce:await te(r)});let o=await signInWithPopup(this.auth,n);return {idToken:await getIdToken(o.user,true),refreshToken:o.user.refreshToken}}async signInWithRedirect(e,n){if(e==="google"){let i=new GoogleAuthProvider;i.addScope("email"),i.addScope("profile"),i.setCustomParameters({prompt:"select_account"}),await signInWithRedirect(this.auth,i);return}let r=new OAuthProvider("apple.com");r.addScope("email"),r.addScope("name");let o=n?.nonce||ee(32);typeof sessionStorage<"u"&&sessionStorage.setItem("apple_auth_nonce",o),r.setCustomParameters({nonce:await te(o)}),await signInWithRedirect(this.auth,r);}async consumeRedirectResult(){return this.redirectResultConsumed?(c("[PLUTO-RTC][AUTH-HOST] consumeRedirectResult skipped (already consumed)"),null):this.redirectResultPromise?this.redirectResultPromise:(this.redirectResultPromise=(async()=>{try{c("[PLUTO-RTC][AUTH-HOST] consumeRedirectResult start");let e=await getRedirectResult(this.auth);if(!e)return c("[PLUTO-RTC][AUTH-HOST] consumeRedirectResult: no redirect result"),{fromRedirect:!1,user:null};this.redirectResultConsumed=!0;let n=await getIdToken(e.user,!0).catch(()=>null),r=e.providerId||e.user.providerData?.[0]?.providerId||null;return c("[PLUTO-RTC][AUTH-HOST] consumeRedirectResult success",{uid:e.user.uid,providerId:r,hasIdToken:!!n}),{fromRedirect:!0,user:e.user,providerId:r,idToken:n}}finally{this.redirectResultPromise=null;}})(),this.redirectResultPromise)}async startGoogleSignIn(){await this.signInWithRedirect("google");}async startAppleSignIn(){await this.signInWithRedirect("apple");}async mintSessionToken(){let r=(await httpsCallable(this.functions,"mintSessionToken")()).data;if(!r?.token)throw new Error("mintSessionToken did not return a token");return r.token}},M=null;function Ke(){return M||(M=new E),M}var qt=new Proxy({},{get(t,e,n){let r=Ke(),o=r[e];return typeof o=="function"?o.bind(r):o}});
|
|
2
|
+
export{vt as A,It as B,St as C,Rt as D,z as E,Kt as F,Ke as G,qt as H,je as a,S as b,P as c,Ge as d,ze as e,$e as f,ae as g,B as h,Ye as i,Je as j,Xe as k,et as l,tt as m,nt as n,A as o,lt as p,dt as q,ut as r,gt as s,D as t,G as u,ft as v,ht as w,bt as x,Tt as y,Pt as z};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {a as a$1,A as A$1}from'./chunk-NP3JZ2LD.js';import {a as a$2}from'./chunk-3SND2COC.js';import {h}from'./chunk-KP5H3SYJ.js';import {s as s$1}from'./chunk-YFNRKQEA.js';var z=class c{static __wrap(t){let e=Object.create(c.prototype);return e.__wbg_ptr=t,tt.register(e,e.__wbg_ptr,e),e}__destroy_into_raw(){let t=this.__wbg_ptr;return this.__wbg_ptr=0,tt.unregister(this),t}free(){let t=this.__destroy_into_raw();n.__wbg_bistream_free(t,0);}get applicationCryptoWrapped(){return n.bistream_applicationCryptoWrapped(this.__wbg_ptr)!==0}get endpoint_id(){let t,e;try{let i=n.__wbindgen_add_to_stack_pointer(-16);n.bistream_endpoint_id(i,this.__wbg_ptr);var _=d().getInt32(i+0,!0),r=d().getInt32(i+4,!0);return t=_,e=r,v(_,r)}finally{n.__wbindgen_add_to_stack_pointer(16),n.__wbindgen_export4(t,e,1);}}finishSend(){let t=n.bistream_finishSend(this.__wbg_ptr);return u(t)}get recv(){let t=n.bistream_recv(this.__wbg_ptr);return u(t)}get send(){let t=n.bistream_send(this.__wbg_ptr);return u(t)}};Symbol.dispose&&(z.prototype[Symbol.dispose]=z.prototype.free);var B=class c{static __wrap(t){let e=Object.create(c.prototype);return e.__wbg_ptr=t,et.register(e,e.__wbg_ptr,e),e}__destroy_into_raw(){let t=this.__wbg_ptr;return this.__wbg_ptr=0,et.unregister(this),t}free(){let t=this.__destroy_into_raw();n.__wbg_intounderlyingsink_free(t,0);}abort(t){let e=this.__destroy_into_raw(),_=n.intounderlyingsink_abort(e,p(t));return u(_)}close(){let t=this.__destroy_into_raw(),e=n.intounderlyingsink_close(t);return u(e)}write(t){let e=n.intounderlyingsink_write(this.__wbg_ptr,p(t));return u(e)}};Symbol.dispose&&(B.prototype[Symbol.dispose]=B.prototype.free);var N=class c{static __wrap(t){let e=Object.create(c.prototype);return e.__wbg_ptr=t,nt.register(e,e.__wbg_ptr,e),e}__destroy_into_raw(){let t=this.__wbg_ptr;return this.__wbg_ptr=0,nt.unregister(this),t}free(){let t=this.__destroy_into_raw();n.__wbg_intounderlyingsource_free(t,0);}cancel(){let t=this.__destroy_into_raw();n.intounderlyingsource_cancel(t);}pull(t){let e=n.intounderlyingsource_pull(this.__wbg_ptr,p(t));return u(e)}};Symbol.dispose&&(N.prototype[Symbol.dispose]=N.prototype.free);var q=class c{static __wrap(t){let e=Object.create(c.prototype);return e.__wbg_ptr=t,_t.register(e,e.__wbg_ptr,e),e}__destroy_into_raw(){let t=this.__wbg_ptr;return this.__wbg_ptr=0,_t.unregister(this),t}free(){let t=this.__destroy_into_raw();n.__wbg_peerunistream_free(t,0);}get applicationCryptoWrapped(){return n.peerunistream_applicationCryptoWrapped(this.__wbg_ptr)!==0}finishSend(){let t=n.peerunistream_finishSend(this.__wbg_ptr);return u(t)}get writable(){let t=n.peerunistream_writable(this.__wbg_ptr);return u(t)}};Symbol.dispose&&(q.prototype[Symbol.dispose]=q.prototype.free);var O=class c{static __wrap(t){let e=Object.create(c.prototype);return e.__wbg_ptr=t,H.register(e,e.__wbg_ptr,e),e}__destroy_into_raw(){let t=this.__wbg_ptr;return this.__wbg_ptr=0,H.unregister(this),t}free(){let t=this.__destroy_into_raw();n.__wbg_wasmclient_free(t,0);}add_peer_scope(t,e){let _=a(t,n.__wbindgen_export,n.__wbindgen_export2),r=s,i=a(e,n.__wbindgen_export,n.__wbindgen_export2),b=s,w=n.wasmclient_add_peer_scope(this.__wbg_ptr,_,r,i,b);return u(w)}bind_connection_device_id(t,e){let _=a(t,n.__wbindgen_export,n.__wbindgen_export2),r=s,i=a(e,n.__wbindgen_export,n.__wbindgen_export2),b=s,w=n.wasmclient_bind_connection_device_id(this.__wbg_ptr,_,r,i,b);return u(w)}bind_node_device_id(t,e){let _=a(t,n.__wbindgen_export,n.__wbindgen_export2),r=s,i=a(e,n.__wbindgen_export,n.__wbindgen_export2),b=s,w=n.wasmclient_bind_node_device_id(this.__wbg_ptr,_,r,i,b);return u(w)}clearConnectionApplicationCryptoKey(t){let e=a(t,n.__wbindgen_export,n.__wbindgen_export2),_=s;n.wasmclient_clearConnectionApplicationCryptoKey(this.__wbg_ptr,e,_);}clear_session_tokens(){n.wasmclient_clear_session_tokens(this.__wbg_ptr);}confirm_inline_reciprocal_session_admission(t,e,_,r,i,b){let w=a(t,n.__wbindgen_export,n.__wbindgen_export2),g=s,m=a(_,n.__wbindgen_export,n.__wbindgen_export2),l=s,y=a(r,n.__wbindgen_export,n.__wbindgen_export2),h=s;var k=f(b)?0:a(b,n.__wbindgen_export,n.__wbindgen_export2),I=s;let S=n.wasmclient_confirm_inline_reciprocal_session_admission(this.__wbg_ptr,w,g,e,m,l,y,h,i,k,I);return u(S)}connect(t){let e=a(t,n.__wbindgen_export,n.__wbindgen_export2),_=s,r=n.wasmclient_connect(this.__wbg_ptr,e,_);return u(r)}connect_device(t,e){var _=f(t)?0:a(t,n.__wbindgen_export,n.__wbindgen_export2),r=s;let i=a(e,n.__wbindgen_export,n.__wbindgen_export2),b=s,w=n.wasmclient_connect_device(this.__wbg_ptr,_,r,i,b);return u(w)}connection_state(t){let e=a(t,n.__wbindgen_export,n.__wbindgen_export2),_=s,r=n.wasmclient_connection_state(this.__wbg_ptr,e,_);return u(r)}connection_states(){let t=n.wasmclient_connection_states(this.__wbg_ptr);return u(t)}create_room(t,e,_,r,i,b){let w=a(t,n.__wbindgen_export,n.__wbindgen_export2),g=s,m=a(e,n.__wbindgen_export,n.__wbindgen_export2),l=s,y=a(_,n.__wbindgen_export,n.__wbindgen_export2),h=s,k=a(r,n.__wbindgen_export,n.__wbindgen_export2),I=s,S=a(i,n.__wbindgen_export,n.__wbindgen_export2),C=s,V=n.wasmclient_create_room(this.__wbg_ptr,w,g,m,l,y,h,k,I,S,C,f(b)?Number.MAX_SAFE_INTEGER:b>>>0);return u(V)}create_session(t){let e=a(t,n.__wbindgen_export,n.__wbindgen_export2),_=s,r=n.wasmclient_create_session(this.__wbg_ptr,e,_);return u(r)}delete_device(t,e){let _=a(t,n.__wbindgen_export,n.__wbindgen_export2),r=s,i=a(e,n.__wbindgen_export,n.__wbindgen_export2),b=s,w=n.wasmclient_delete_device(this.__wbg_ptr,_,r,i,b);return u(w)}devices_with_status(t){let e=a(t,n.__wbindgen_export,n.__wbindgen_export2),_=s,r=n.wasmclient_devices_with_status(this.__wbg_ptr,e,_);return u(r)}disconnect(t){let e=a(t,n.__wbindgen_export,n.__wbindgen_export2),_=s,r=n.wasmclient_disconnect(this.__wbg_ptr,e,_);return u(r)}disconnect_device(t,e){let _=a(t,n.__wbindgen_export,n.__wbindgen_export2),r=s;var i=f(e)?0:a(e,n.__wbindgen_export,n.__wbindgen_export2),b=s;let w=n.wasmclient_disconnect_device(this.__wbg_ptr,_,r,i,b);return u(w)}disconnect_transient(t){let e=a(t,n.__wbindgen_export,n.__wbindgen_export2),_=s,r=n.wasmclient_disconnect_transient(this.__wbg_ptr,e,_);return u(r)}endpoint_id_from_ticket(t){let e,_;try{let l=n.__wbindgen_add_to_stack_pointer(-16),y=a(t,n.__wbindgen_export,n.__wbindgen_export2),h=s;n.wasmclient_endpoint_id_from_ticket(l,this.__wbg_ptr,y,h);var r=d().getInt32(l+0,!0),i=d().getInt32(l+4,!0),b=d().getInt32(l+8,!0),w=d().getInt32(l+12,!0),g=r,m=i;if(w)throw g=0,m=0,u(b);return e=g,_=m,v(g,m)}finally{n.__wbindgen_add_to_stack_pointer(16),n.__wbindgen_export4(e,_,1);}}endpoint_ticket(){let t=n.wasmclient_endpoint_ticket(this.__wbg_ptr);return u(t)}endpoint_ticket_with_token(t,e){let _=a(t,n.__wbindgen_export,n.__wbindgen_export2),r=s,i=n.wasmclient_endpoint_ticket_with_token(this.__wbg_ptr,_,r,e);return u(i)}force_reconnect_snapshot(){n.wasmclient_force_reconnect_snapshot(this.__wbg_ptr);}get_members(t,e,_){let r=a(t,n.__wbindgen_export,n.__wbindgen_export2),i=s,b=a(e,n.__wbindgen_export,n.__wbindgen_export2),w=s,g=a(_,n.__wbindgen_export,n.__wbindgen_export2),m=s,l=n.wasmclient_get_members(this.__wbg_ptr,r,i,b,w,g,m);return u(l)}heartbeat_tick(t,e,_){let r=a(t,n.__wbindgen_export,n.__wbindgen_export2),i=s,b=a(e,n.__wbindgen_export,n.__wbindgen_export2),w=s,g=a(_,n.__wbindgen_export,n.__wbindgen_export2),m=s,l=n.wasmclient_heartbeat_tick(this.__wbg_ptr,r,i,b,w,g,m);return u(l)}incoming_streams(){let t=n.wasmclient_incoming_streams(this.__wbg_ptr);return u(t)}init_iroh(t){var e=f(t)?0:L(t,n.__wbindgen_export),_=s;let r=n.wasmclient_init_iroh(this.__wbg_ptr,e,_);return u(r)}iroh_path_kind(t){let e=a(t,n.__wbindgen_export,n.__wbindgen_export2),_=s,r=n.wasmclient_iroh_path_kind(this.__wbg_ptr,e,_);return u(r)}iroh_secret_key(){let t=n.wasmclient_iroh_secret_key(this.__wbg_ptr);return u(t)}iroh_transport_rtt_ms(t){let e=a(t,n.__wbindgen_export,n.__wbindgen_export2),_=s,r=n.wasmclient_iroh_transport_rtt_ms(this.__wbg_ptr,e,_);return u(r)}is_auto_connect_excluded(t){let e=a(t,n.__wbindgen_export,n.__wbindgen_export2),_=s;return n.wasmclient_is_auto_connect_excluded(this.__wbg_ptr,e,_)!==0}is_connected(t){let e=a(t,n.__wbindgen_export,n.__wbindgen_export2),_=s,r=n.wasmclient_is_connected(this.__wbg_ptr,e,_);return u(r)}is_current_transport_stable_id(t,e){let _=a(t,n.__wbindgen_export,n.__wbindgen_export2),r=s,i=n.wasmclient_is_current_transport_stable_id(this.__wbg_ptr,_,r,e);return u(i)}join_room(t,e,_,r,i){let b=a(t,n.__wbindgen_export,n.__wbindgen_export2),w=s,g=a(e,n.__wbindgen_export,n.__wbindgen_export2),m=s,l=a(_,n.__wbindgen_export,n.__wbindgen_export2),y=s,h=a(r,n.__wbindgen_export,n.__wbindgen_export2),k=s,I=a(i,n.__wbindgen_export,n.__wbindgen_export2),S=s,C=n.wasmclient_join_room(this.__wbg_ptr,b,w,g,m,l,y,h,k,I,S);return u(C)}leave_room(t,e,_){let r=a(t,n.__wbindgen_export,n.__wbindgen_export2),i=s,b=a(e,n.__wbindgen_export,n.__wbindgen_export2),w=s,g=a(_,n.__wbindgen_export,n.__wbindgen_export2),m=s,l=n.wasmclient_leave_room(this.__wbg_ptr,r,i,b,w,g,m);return u(l)}list_managed_connections(){let t=n.wasmclient_list_managed_connections(this.__wbg_ptr);return u(t)}constructor(t,e){try{let b=n.__wbindgen_add_to_stack_pointer(-16),w=a(t,n.__wbindgen_export,n.__wbindgen_export2),g=s,m=a(e,n.__wbindgen_export,n.__wbindgen_export2),l=s;n.wasmclient_new(b,w,g,m,l);var _=d().getInt32(b+0,!0),r=d().getInt32(b+4,!0),i=d().getInt32(b+8,!0);if(i)throw u(r);return this.__wbg_ptr=_,H.register(this,this.__wbg_ptr,this),this}finally{n.__wbindgen_add_to_stack_pointer(16);}}static newWithAppTag(t,e){try{let b=n.__wbindgen_add_to_stack_pointer(-16),w=a(t,n.__wbindgen_export,n.__wbindgen_export2),g=s,m=a(e,n.__wbindgen_export,n.__wbindgen_export2),l=s;n.wasmclient_newWithAppTag(b,w,g,m,l);var _=d().getInt32(b+0,!0),r=d().getInt32(b+4,!0),i=d().getInt32(b+8,!0);if(i)throw u(r);return c.__wrap(_)}finally{n.__wbindgen_add_to_stack_pointer(16);}}node_addr(){let t=n.wasmclient_node_addr(this.__wbg_ptr);return u(t)}open_bi(t){let e=a(t,n.__wbindgen_export,n.__wbindgen_export2),_=s,r=n.wasmclient_open_bi(this.__wbg_ptr,e,_);return u(r)}open_native_main_control_bi(t){let e=a(t,n.__wbindgen_export,n.__wbindgen_export2),_=s,r=n.wasmclient_open_native_main_control_bi(this.__wbg_ptr,e,_);return u(r)}open_peer_bi(t,e){let _=a(t,n.__wbindgen_export,n.__wbindgen_export2),r=s,i=n.wasmclient_open_peer_bi(this.__wbg_ptr,_,r,f(e)?Number.MAX_SAFE_INTEGER:e>>>0);return u(i)}open_peer_bi_explicit_file_sender(t,e){let _=a(t,n.__wbindgen_export,n.__wbindgen_export2),r=s,i=n.wasmclient_open_peer_bi_explicit_file_sender(this.__wbg_ptr,_,r,f(e)?Number.MAX_SAFE_INTEGER:e>>>0);return u(i)}open_peer_bi_transport_only(t,e){let _=a(t,n.__wbindgen_export,n.__wbindgen_export2),r=s,i=n.wasmclient_open_peer_bi_transport_only(this.__wbg_ptr,_,r,f(e)?Number.MAX_SAFE_INTEGER:e>>>0);return u(i)}open_peer_native_bi(t,e,_){let r=a(t,n.__wbindgen_export,n.__wbindgen_export2),i=s,b=a(e,n.__wbindgen_export,n.__wbindgen_export2),w=s,g=n.wasmclient_open_peer_native_bi(this.__wbg_ptr,r,i,b,w,f(_)?Number.MAX_SAFE_INTEGER:_>>>0);return u(g)}open_peer_uni(t,e){let _=a(t,n.__wbindgen_export,n.__wbindgen_export2),r=s,i=n.wasmclient_open_peer_uni(this.__wbg_ptr,_,r,f(e)?Number.MAX_SAFE_INTEGER:e>>>0);return u(i)}open_uni(t){let e=a(t,n.__wbindgen_export,n.__wbindgen_export2),_=s,r=n.wasmclient_open_uni(this.__wbg_ptr,e,_);return u(r)}peer_scopes(t){let e=a(t,n.__wbindgen_export,n.__wbindgen_export2),_=s,r=n.wasmclient_peer_scopes(this.__wbg_ptr,e,_);return u(r)}peer_session(t){let e=a(t,n.__wbindgen_export,n.__wbindgen_export2),_=s,r=n.wasmclient_peer_session(this.__wbg_ptr,e,_);return u(r)}peer_sessions(){let t=n.wasmclient_peer_sessions(this.__wbg_ptr);return u(t)}peer_snapshot(t){let e=a(t,n.__wbindgen_export,n.__wbindgen_export2),_=s,r=n.wasmclient_peer_snapshot(this.__wbg_ptr,e,_);return u(r)}prepare_inline_reciprocal_session_admission(t,e,_,r,i,b,w,g){let m=a(t,n.__wbindgen_export,n.__wbindgen_export2),l=s,y=a(_,n.__wbindgen_export,n.__wbindgen_export2),h=s,k=a(r,n.__wbindgen_export,n.__wbindgen_export2),I=s,S=a(i,n.__wbindgen_export,n.__wbindgen_export2),C=s,V=a(b,n.__wbindgen_export,n.__wbindgen_export2),ct=s,at=a(w,n.__wbindgen_export,n.__wbindgen_export2),bt=s,pt=a(g,n.__wbindgen_export,n.__wbindgen_export2),ut=s,wt=n.wasmclient_prepare_inline_reciprocal_session_admission(this.__wbg_ptr,m,l,e,y,h,k,I,S,C,V,ct,at,bt,pt,ut);return u(wt)}present_session_token_to_host(t,e){let _=a(t,n.__wbindgen_export,n.__wbindgen_export2),r=s,i=a(e,n.__wbindgen_export,n.__wbindgen_export2),b=s,w=n.wasmclient_present_session_token_to_host(this.__wbg_ptr,_,r,i,b);return u(w)}present_session_token_to_host_with_payload(t,e,_){let r=a(t,n.__wbindgen_export,n.__wbindgen_export2),i=s,b=a(e,n.__wbindgen_export,n.__wbindgen_export2),w=s;var g=f(_)?0:a(_,n.__wbindgen_export,n.__wbindgen_export2),m=s;let l=n.wasmclient_present_session_token_to_host_with_payload(this.__wbg_ptr,r,i,b,w,g,m);return u(l)}present_session_token_to_host_with_payload_and_device_id(t,e,_,r){let i=a(t,n.__wbindgen_export,n.__wbindgen_export2),b=s,w=a(e,n.__wbindgen_export,n.__wbindgen_export2),g=s;var m=f(_)?0:a(_,n.__wbindgen_export,n.__wbindgen_export2),l=s,y=f(r)?0:a(r,n.__wbindgen_export,n.__wbindgen_export2),h=s;let k=n.wasmclient_present_session_token_to_host_with_payload_and_device_id(this.__wbg_ptr,i,b,w,g,m,l,y,h);return u(k)}rankRoutes(t,e){try{let b=n.__wbindgen_add_to_stack_pointer(-16),w=ot(t,n.__wbindgen_export),g=s,m=ot(e,n.__wbindgen_export),l=s;n.wasmclient_rankRoutes(b,this.__wbg_ptr,w,g,m,l);var _=d().getInt32(b+0,!0),r=d().getInt32(b+4,!0),i=Ct(_,r).slice();return n.__wbindgen_export4(_,r*4,4),i}finally{n.__wbindgen_add_to_stack_pointer(16);}}register_session_token(t,e,_){let r=a(t,n.__wbindgen_export,n.__wbindgen_export2),i=s,b=a(e,n.__wbindgen_export,n.__wbindgen_export2),w=s;n.wasmclient_register_session_token(this.__wbg_ptr,r,i,b,w,_);}register_session_token_with_expiry_ms(t,e,_,r){let i=a(t,n.__wbindgen_export,n.__wbindgen_export2),b=s,w=a(e,n.__wbindgen_export,n.__wbindgen_export2),g=s;n.wasmclient_register_session_token_with_expiry_ms(this.__wbg_ptr,i,b,w,g,_,r);}reject_connection_admission(t,e){let _=a(t,n.__wbindgen_export,n.__wbindgen_export2),r=s,i=a(e,n.__wbindgen_export,n.__wbindgen_export2),b=s,w=n.wasmclient_reject_connection_admission(this.__wbg_ptr,_,r,i,b);return u(w)}release_peer_scope(t,e){let _=a(t,n.__wbindgen_export,n.__wbindgen_export2),r=s;var i=f(e)?0:a(e,n.__wbindgen_export,n.__wbindgen_export2),b=s;let w=n.wasmclient_release_peer_scope(this.__wbg_ptr,_,r,i,b);return u(w)}remote_session_admission_ready_for_ticket(t){let e=a(t,n.__wbindgen_export,n.__wbindgen_export2),_=s,r=n.wasmclient_remote_session_admission_ready_for_ticket(this.__wbg_ptr,e,_);return u(r)}report_managed_connection_settled(t,e,_,r,i,b){let w=a(t,n.__wbindgen_export,n.__wbindgen_export2),g=s;var m=f(_)?0:a(_,n.__wbindgen_export,n.__wbindgen_export2),l=s;let y=n.wasmclient_report_managed_connection_settled(this.__wbg_ptr,w,g,e,m,l,!f(r),f(r)?BigInt(0):r,!f(i),f(i)?BigInt(0):i,!f(b),f(b)?BigInt(0):b);return u(y)}report_transport_status(t,e,_,r,i,b){let w=a(t,n.__wbindgen_export,n.__wbindgen_export2),g=s,m=a(e,n.__wbindgen_export,n.__wbindgen_export2),l=s;var y=f(_)?0:a(_,n.__wbindgen_export,n.__wbindgen_export2),h=s;let k=n.wasmclient_report_transport_status(this.__wbg_ptr,w,g,m,l,y,h,!f(r),f(r)?BigInt(0):r,!f(i),f(i)?BigInt(0):i,!f(b),f(b)?BigInt(0):b);return u(k)}resolve_peer_connection_records(t){let e=a(t,n.__wbindgen_export,n.__wbindgen_export2),_=s,r=n.wasmclient_resolve_peer_connection_records(this.__wbg_ptr,e,_);return u(r)}revoke_session_token(t){try{let i=n.__wbindgen_add_to_stack_pointer(-16),b=a(t,n.__wbindgen_export,n.__wbindgen_export2),w=s;n.wasmclient_revoke_session_token(i,this.__wbg_ptr,b,w);var e=d().getInt32(i+0,!0),_=d().getInt32(i+4,!0),r=d().getInt32(i+8,!0);if(r)throw u(_);return u(e)}finally{n.__wbindgen_add_to_stack_pointer(16);}}revoke_tokens_by_scope(t){let e=a(t,n.__wbindgen_export,n.__wbindgen_export2),_=s,r=n.wasmclient_revoke_tokens_by_scope(this.__wbg_ptr,e,_);return u(r)}runtime_policy(){try{let r=n.__wbindgen_add_to_stack_pointer(-16);n.wasmclient_runtime_policy(r,this.__wbg_ptr);var t=d().getInt32(r+0,!0),e=d().getInt32(r+4,!0),_=d().getInt32(r+8,!0);if(_)throw u(e);return u(t)}finally{n.__wbindgen_add_to_stack_pointer(16);}}same_peer(t,e){let _=a(t,n.__wbindgen_export,n.__wbindgen_export2),r=s,i=a(e,n.__wbindgen_export,n.__wbindgen_export2),b=s,w=n.wasmclient_same_peer(this.__wbg_ptr,_,r,i,b);return u(w)}search_devices(t){let e=a(t,n.__wbindgen_export,n.__wbindgen_export2),_=s,r=n.wasmclient_search_devices(this.__wbg_ptr,e,_);return u(r)}send_message(t,e,_,r){let i=a(t,n.__wbindgen_export,n.__wbindgen_export2),b=s,w=a(e,n.__wbindgen_export,n.__wbindgen_export2),g=s;var m=f(_)?0:a(_,n.__wbindgen_export,n.__wbindgen_export2),l=s,y=f(r)?0:a(r,n.__wbindgen_export,n.__wbindgen_export2),h=s;let k=n.wasmclient_send_message(this.__wbg_ptr,i,b,w,g,m,l,y,h);return u(k)}send_peer(t,e){let _=a(t,n.__wbindgen_export,n.__wbindgen_export2),r=s,i=L(e,n.__wbindgen_export),b=s,w=n.wasmclient_send_peer(this.__wbg_ptr,_,r,i,b);return u(w)}send_peer_application_frame(t,e,_){let r=a(t,n.__wbindgen_export,n.__wbindgen_export2),i=s,b=L(e,n.__wbindgen_export),w=s,g=n.wasmclient_send_peer_application_frame(this.__wbg_ptr,r,i,b,w,f(_)?Number.MAX_SAFE_INTEGER:_>>>0);return u(g)}setConnectionApplicationCryptoKey(t,e){let _=a(t,n.__wbindgen_export,n.__wbindgen_export2),r=s,i=L(e,n.__wbindgen_export),b=s,w=n.wasmclient_setConnectionApplicationCryptoKey(this.__wbg_ptr,_,r,i,b);return u(w)}setConnectionApplicationCryptoRequired(t){try{let r=n.__wbindgen_add_to_stack_pointer(-16),i=a(t,n.__wbindgen_export,n.__wbindgen_export2),b=s;n.wasmclient_setConnectionApplicationCryptoRequired(r,this.__wbg_ptr,i,b);var e=d().getInt32(r+0,!0),_=d().getInt32(r+4,!0);if(_)throw u(e)}finally{n.__wbindgen_add_to_stack_pointer(16);}}set_auth_token(t){var e=f(t)?0:a(t,n.__wbindgen_export,n.__wbindgen_export2),_=s;n.wasmclient_set_auth_token(this.__wbg_ptr,e,_);}set_auto_connect_excluded(t,e){let _=a(t,n.__wbindgen_export,n.__wbindgen_export2),r=s,i=n.wasmclient_set_auto_connect_excluded(this.__wbg_ptr,_,r,e);return u(i)}set_offline(t){let e=a(t,n.__wbindgen_export,n.__wbindgen_export2),_=s,r=n.wasmclient_set_offline(this.__wbg_ptr,e,_);return u(r)}start_auto_connect(t,e){try{let i=n.__wbindgen_add_to_stack_pointer(-16),b=a(t,n.__wbindgen_export,n.__wbindgen_export2),w=s,g=a(e,n.__wbindgen_export,n.__wbindgen_export2),m=s;n.wasmclient_start_auto_connect(i,this.__wbg_ptr,b,w,g,m);var _=d().getInt32(i+0,!0),r=d().getInt32(i+4,!0);if(r)throw u(_)}finally{n.__wbindgen_add_to_stack_pointer(16);}}start_presence_loop(t,e,_,r){let i=a(t,n.__wbindgen_export,n.__wbindgen_export2),b=s,w=a(e,n.__wbindgen_export,n.__wbindgen_export2),g=s,m=a(_,n.__wbindgen_export,n.__wbindgen_export2),l=s;var y=f(r)?0:a(r,n.__wbindgen_export,n.__wbindgen_export2),h=s;n.wasmclient_start_presence_loop(this.__wbg_ptr,i,b,w,g,m,l,y,h);}stop_auth_scoped_activity(){n.wasmclient_stop_auth_scoped_activity(this.__wbg_ptr);}stop_auto_connect(){n.wasmclient_stop_auto_connect(this.__wbg_ptr);}stop_presence_loop(){n.wasmclient_stop_presence_loop(this.__wbg_ptr);}submit_browser_desired_peers(t,e){try{let b=n.__wbindgen_add_to_stack_pointer(-16),w=a(e,n.__wbindgen_export,n.__wbindgen_export2),g=s;n.wasmclient_submit_browser_desired_peers(b,this.__wbg_ptr,t,w,g);var _=d().getInt32(b+0,!0),r=d().getInt32(b+4,!0),i=d().getInt32(b+8,!0);if(i)throw u(r);return _!==0}finally{n.__wbindgen_add_to_stack_pointer(16);}}update_device(t,e,_,r,i){let b=a(t,n.__wbindgen_export,n.__wbindgen_export2),w=s,g=a(e,n.__wbindgen_export,n.__wbindgen_export2),m=s;var l=f(_)?0:a(_,n.__wbindgen_export,n.__wbindgen_export2),y=s,h=f(i)?0:a(i,n.__wbindgen_export,n.__wbindgen_export2),k=s;let I=n.wasmclient_update_device(this.__wbg_ptr,b,w,g,m,l,y,f(r)?0:p(r),h,k);return u(I)}update_presence(t,e,_,r,i){let b=a(t,n.__wbindgen_export,n.__wbindgen_export2),w=s,g=a(e,n.__wbindgen_export,n.__wbindgen_export2),m=s,l=a(_,n.__wbindgen_export,n.__wbindgen_export2),y=s;var h=f(r)?0:a(r,n.__wbindgen_export,n.__wbindgen_export2),k=s;let I=n.wasmclient_update_presence(this.__wbg_ptr,b,w,g,m,l,y,h,k,!f(i),f(i)?BigInt(0):i);return u(I)}update_session(t,e){let _=a(t,n.__wbindgen_export,n.__wbindgen_export2),r=s,i=a(e,n.__wbindgen_export,n.__wbindgen_export2),b=s,w=n.wasmclient_update_session(this.__wbg_ptr,_,r,i,b);return u(w)}validate_session_token(t){let e,_;try{let l=n.__wbindgen_add_to_stack_pointer(-16),y=a(t,n.__wbindgen_export,n.__wbindgen_export2),h=s;n.wasmclient_validate_session_token(l,this.__wbg_ptr,y,h);var r=d().getInt32(l+0,!0),i=d().getInt32(l+4,!0),b=d().getInt32(l+8,!0),w=d().getInt32(l+12,!0),g=r,m=i;if(w)throw g=0,m=0,u(b);return e=g,_=m,v(g,m)}finally{n.__wbindgen_add_to_stack_pointer(16),n.__wbindgen_export4(e,_,1);}}validate_session_token_for_connection(t,e){let _=a(t,n.__wbindgen_export,n.__wbindgen_export2),r=s,i=a(e,n.__wbindgen_export,n.__wbindgen_export2),b=s,w=n.wasmclient_validate_session_token_for_connection(this.__wbg_ptr,_,r,i,b);return u(w)}validate_session_token_for_connection_with_payload(t,e,_){let r=a(t,n.__wbindgen_export,n.__wbindgen_export2),i=s,b=a(e,n.__wbindgen_export,n.__wbindgen_export2),w=s;var g=f(_)?0:a(_,n.__wbindgen_export,n.__wbindgen_export2),m=s;let l=n.wasmclient_validate_session_token_for_connection_with_payload(this.__wbg_ptr,r,i,b,w,g,m);return u(l)}wait_for_settled_peer(t,e){let _=a(t,n.__wbindgen_export,n.__wbindgen_export2),r=s,i=n.wasmclient_wait_for_settled_peer(this.__wbg_ptr,_,r,f(e)?Number.MAX_SAFE_INTEGER:e>>>0);return u(i)}wake_browser_auto_connect(){return n.wasmclient_wake_browser_auto_connect(this.__wbg_ptr)!==0}};Symbol.dispose&&(O.prototype[Symbol.dispose]=O.prototype.free);function it(){n.start();}function gt(){return {__proto__:null,"./openrtc_bg.js":{__proto__:null,__wbg_Error_9dc85fe1bc224456:function(t,e){let _=Error(v(t,e));return p(_)},__wbg_String_8564e559799eccda:function(t,e){let _=String(o(e)),r=a(_,n.__wbindgen_export,n.__wbindgen_export2),i=s;d().setInt32(t+4,i,true),d().setInt32(t+0,r,true);},__wbg___wbindgen_boolean_get_b131b2f36d6b2f55:function(t){let e=o(t),_=typeof e=="boolean"?e:void 0;return f(_)?16777215:_?1:0},__wbg___wbindgen_debug_string_56c147eb1a51f0c4:function(t,e){let _=K(o(e)),r=a(_,n.__wbindgen_export,n.__wbindgen_export2),i=s;d().setInt32(t+4,i,true),d().setInt32(t+0,r,true);},__wbg___wbindgen_in_ce8569b2fc6f5088:function(t,e){return o(t)in o(e)},__wbg___wbindgen_is_function_147961669f068cd4:function(t){return typeof o(t)=="function"},__wbg___wbindgen_is_null_ced4761460071341:function(t){return o(t)===null},__wbg___wbindgen_is_object_3a2c414391dbf751:function(t){let e=o(t);return typeof e=="object"&&e!==null},__wbg___wbindgen_is_string_6541b0f6ecd4e8e5:function(t){return typeof o(t)=="string"},__wbg___wbindgen_is_undefined_4410e3c20a99fa97:function(t){return o(t)===void 0},__wbg___wbindgen_jsval_eq_174c93ec61bab0c5:function(t,e){return o(t)===o(e)},__wbg___wbindgen_jsval_loose_eq_e07e3b1f5db6da6c:function(t,e){return o(t)==o(e)},__wbg___wbindgen_number_get_588ed6b97f0d7e14:function(t,e){let _=o(e),r=typeof _=="number"?_:void 0;d().setFloat64(t+8,f(r)?0:r,true),d().setInt32(t+0,!f(r),true);},__wbg___wbindgen_string_get_fa2687d531ed17a5:function(t,e){let _=o(e),r=typeof _=="string"?_:void 0;var i=f(r)?0:a(r,n.__wbindgen_export,n.__wbindgen_export2),b=s;d().setInt32(t+4,b,true),d().setInt32(t+0,i,true);},__wbg___wbindgen_throw_bbadd78c1bac3a77:function(t,e){throw new Error(v(t,e))},__wbg__wbg_cb_unref_c2301a3c9b78104b:function(t){o(t)._wbg_cb_unref();},__wbg_abort_56c00f462c9261d9:function(t,e){o(t).abort(o(e));},__wbg_abort_f2416f4a9852003e:function(t){o(t).abort();},__wbg_addEventListener_b635263c509aa7de:function(){return x(function(t,e,_,r){o(t).addEventListener(v(e,_),o(r));},arguments)},__wbg_append_c5a0c94a6a73b22e:function(){return x(function(t,e,_,r,i){o(t).append(v(e,_),v(r,i));},arguments)},__wbg_arrayBuffer_cc7704fa158b907a:function(){return x(function(t){let e=o(t).arrayBuffer();return p(e)},arguments)},__wbg_bistream_new:function(t){let e=z.__wrap(t);return p(e)},__wbg_body_442a47f02322d7b0:function(t){let e=o(t).body;return f(e)?0:p(e)},__wbg_buffer_8524b3453cde4918:function(t){let e=o(t).buffer;return p(e)},__wbg_byobRequest_cc72d210de793e64:function(t){let e=o(t).byobRequest;return f(e)?0:p(e)},__wbg_byteLength_96807b1d9ab24a4c:function(t){return o(t).byteLength},__wbg_byteOffset_a9c7002428843c41:function(t){return o(t).byteOffset},__wbg_call_91f00ddc43e01490:function(){return x(function(t,e){let _=o(t).call(o(e));return p(_)},arguments)},__wbg_call_ec09a4cf93377d3a:function(){return x(function(t,e,_){let r=o(t).call(o(e),o(_));return p(r)},arguments)},__wbg_cancel_f3a197b26dc88b39:function(t){let e=o(t).cancel();return p(e)},__wbg_catch_66060324c27be6f7:function(t,e){let _=o(t).catch(o(e));return p(_)},__wbg_clearTimeout_113b1cde814ec762:function(t){let e=clearTimeout(u(t));return p(e)},__wbg_clearTimeout_333bba87532ab9d3:function(t){let e=clearTimeout(u(t));return p(e)},__wbg_clearTimeout_47a40e3be01ed7a3:function(){return x(function(t,e){o(t).clearTimeout(u(e));},arguments)},__wbg_clearTimeout_6b8d9a38b9263d65:function(t){let e=clearTimeout(u(t));return p(e)},__wbg_close_296263cfe1bb2999:function(){return x(function(t){o(t).close();},arguments)},__wbg_close_388d99468213b286:function(){return x(function(t){o(t).close();},arguments)},__wbg_close_4857e22d08b71356:function(){return x(function(t){o(t).close();},arguments)},__wbg_code_1cda2855fcd9b009:function(t){return o(t).code},__wbg_code_70beb7b22374d55e:function(t){return o(t).code},__wbg_createDataChannel_122bd3d8aacee49b:function(t,e,_){let r=o(t).createDataChannel(v(e,_));return p(r)},__wbg_crypto_38df2bab126b63dc:function(t){let e=o(t).crypto;return p(e)},__wbg_data_8a04443c1e5a8cd3:function(t){let e=o(t).data;return p(e)},__wbg_dispatchEvent_cc62a6a43d28b01c:function(){return x(function(t,e){return o(t).dispatchEvent(o(e))},arguments)},__wbg_done_6a8439e544ec6206:function(t){return o(t).done},__wbg_enqueue_bbeb09ba0b140f76:function(){return x(function(t,e){o(t).enqueue(o(e));},arguments)},__wbg_entries_4e00eefd3fd54cf1:function(t){let e=o(t).entries();return p(e)},__wbg_error_6651fee1c71e5da9:function(t){console.error(o(t));},__wbg_error_a6fa202b58aa1cd3:function(t,e){let _,r;try{_=t,r=e,console.error(v(t,e));}finally{n.__wbindgen_export4(_,r,1);}},__wbg_fetch_074561c3e313c86f:function(t){let e=fetch(o(t));return p(e)},__wbg_fetch_22858a12fcf93152:function(t,e){let _=o(t).fetch(o(e));return p(_)},__wbg_fetch_9dad4fe911207b37:function(t){let e=fetch(o(t));return p(e)},__wbg_fetch_c374c6d9532750f2:function(t,e){let _=o(t).fetch(o(e));return p(_)},__wbg_getRandomValues_76dfc69825c9c552:function(){return x(function(t,e){globalThis.crypto.getRandomValues(F(t,e));},arguments)},__wbg_getRandomValues_c44a50d8cfdaebeb:function(){return x(function(t,e){o(t).getRandomValues(o(e));},arguments)},__wbg_getReader_0cd37e95fbf00f7f:function(t){let e=o(t).getReader();return p(e)},__wbg_getReader_9facd4f899beac89:function(){return x(function(t){let e=o(t).getReader();return p(e)},arguments)},__wbg_get_44e98e27bda25b5b:function(){return x(function(t,e){let _=Reflect.get(o(t),o(e));return p(_)},arguments)},__wbg_get_4b90d6d8c5deb5d5:function(t,e){let _=o(t)[e>>>0];return p(_)},__wbg_get_52a8a619f7b88df6:function(){return x(function(t,e){let _=Reflect.get(o(t),o(e));return p(_)},arguments)},__wbg_get_a82defe8d6b5b2e5:function(){return x(function(t,e,_,r){let i=o(e).get(v(_,r));var b=f(i)?0:a(i,n.__wbindgen_export,n.__wbindgen_export2),w=s;d().setInt32(t+4,w,true),d().setInt32(t+0,b,true);},arguments)},__wbg_get_done_c21b9933fc9a9e9c:function(t){let e=o(t).done;return f(e)?16777215:e?1:0},__wbg_get_value_ad568c7d3db9073f:function(t){let e=o(t).value;return p(e)},__wbg_get_with_ref_key_6412cf3094599694:function(t,e){let _=o(t)[o(e)];return p(_)},__wbg_has_14676d88c1340d2c:function(){return x(function(t,e){return Reflect.has(o(t),o(e))},arguments)},__wbg_headers_5b19cf40627ae54d:function(t){let e=o(t).headers;return p(e)},__wbg_info_a2b5f8a5dae8b26c:function(t){console.info(o(t));},__wbg_instanceof_ArrayBuffer_a581da923203f29f:function(t){let e;try{e=o(t)instanceof ArrayBuffer;}catch{e=false;}return e},__wbg_instanceof_Blob_5c4e145be35f9b1e:function(t){let e;try{e=o(t)instanceof Blob;}catch{e=false;}return e},__wbg_instanceof_ReadableStreamDefaultReader_2ab4b6bb85f96463:function(t){let e;try{e=o(t)instanceof ReadableStreamDefaultReader;}catch{e=false;}return e},__wbg_instanceof_Response_36a65a969abaa7c6:function(t){let e;try{e=o(t)instanceof Response;}catch{e=false;}return e},__wbg_instanceof_Uint8Array_b6fe1ac89eba107e:function(t){let e;try{e=o(t)instanceof Uint8Array;}catch{e=false;}return e},__wbg_instanceof_Window_9e0fe7d3d1ff4342:function(t){let e;try{e=o(t)instanceof Window;}catch{e=false;}return e},__wbg_isArray_139f48e3c057ede8:function(t){return Array.isArray(o(t))},__wbg_iterator_9b36cebf3be7b7cd:function(){return p(Symbol.iterator)},__wbg_length_68a9d5278d084f4f:function(t){return o(t).length},__wbg_log_6614a4effdb4e983:function(t){console.log(o(t));},__wbg_message_12958526424a887b:function(t,e){let _=o(e).message,r=a(_,n.__wbindgen_export,n.__wbindgen_export2),i=s;d().setInt32(t+4,i,true),d().setInt32(t+0,r,true);},__wbg_msCrypto_bd5a034af96bcba6:function(t){let e=o(t).msCrypto;return p(e)},__wbg_new_0_878c6ec3a1c600f3:function(){return p(new Date)},__wbg_new_0b303268aa395a38:function(){let t=new Array;return p(t)},__wbg_new_189262ff31890c23:function(){return x(function(){let t=new Headers;return p(t)},arguments)},__wbg_new_20b778a4c5c691c3:function(){let t=new Object;return p(t)},__wbg_new_227d7c05414eb861:function(){let t=new Error;return p(t)},__wbg_new_24739629d416f982:function(){return x(function(){let t=new AbortController;return p(t)},arguments)},__wbg_new_5fae30e6b23db8df:function(t,e){let _=new Error(v(t,e));return p(_)},__wbg_new_883c0db065f06efd:function(){return p(new Map)},__wbg_new_a21cf41c5c809e4c:function(t){let e=new Date(o(t));return p(e)},__wbg_new_a3e5112401a82338:function(){return x(function(t,e){let _=new WebSocket(v(t,e));return p(_)},arguments)},__wbg_new_b06772b280cc6e52:function(t){let e=new Uint8Array(o(t));return p(e)},__wbg_new_from_slice_bb2d1778c0b87eb1:function(t,e){let _=new Uint8Array(F(t,e));return p(_)},__wbg_new_typed_90c3f6c29ba36d19:function(t,e){try{var _={a:t,b:e},r=(b,w)=>{let g=_.a;_.a=0;try{return It(g,_.b,b,w)}finally{_.a=g;}};let i=new Promise(r);return p(i)}finally{_.a=0;}},__wbg_new_with_byte_offset_and_length_9e1e664fe1a5d385:function(t,e,_){let r=new Uint8Array(o(t),e>>>0,_>>>0);return p(r)},__wbg_new_with_configuration_3a96aa953ca17197:function(){return x(function(t){let e=new RTCPeerConnection(o(t));return p(e)},arguments)},__wbg_new_with_event_init_dict_bd850674488710b1:function(){return x(function(t,e,_){let r=new CustomEvent(v(t,e),o(_));return p(r)},arguments)},__wbg_new_with_into_underlying_sink_2596343f9b6c8e58:function(t){let e=new WritableStream(B.__wrap(t));return p(e)},__wbg_new_with_into_underlying_source_fd904252f385f59c:function(t,e){let _=new ReadableStream(N.__wrap(t),u(e));return p(_)},__wbg_new_with_length_4b57a7a5dc67221c:function(t){let e=new Uint8Array(t>>>0);return p(e)},__wbg_new_with_str_and_init_df876572184fe639:function(){return x(function(t,e,_){let r=new Request(v(t,e),o(_));return p(r)},arguments)},__wbg_new_with_str_sequence_505a4829cc247e79:function(){return x(function(t,e,_){let r=new WebSocket(v(t,e),o(_));return p(r)},arguments)},__wbg_next_8cb028b6ba50743f:function(){return x(function(t){let e=o(t).next();return p(e)},arguments)},__wbg_next_cfd0b146c9538df8:function(t){let e=o(t).next;return p(e)},__wbg_node_84ea875411254db1:function(t){let e=o(t).node;return p(e)},__wbg_now_bce4dc999095ea77:function(){return Date.now()},__wbg_now_e7c6795a7f81e10f:function(t){return o(t).now()},__wbg_ok_2279b99c57bfdfba:function(t){return o(t).ok},__wbg_parse_a5c06e19bc1187fd:function(t,e){return Date.parse(v(t,e))},__wbg_peerunistream_new:function(t){let e=q.__wrap(t);return p(e)},__wbg_performance_3fcf6e32a7e1ed0a:function(t){let e=o(t).performance;return p(e)},__wbg_process_44c7a14e11e9f69e:function(t){let e=o(t).process;return p(e)},__wbg_protocol_28aaef5ea42981d6:function(t,e){let _=o(e).protocol,r=a(_,n.__wbindgen_export,n.__wbindgen_export2),i=s;d().setInt32(t+4,i,true),d().setInt32(t+0,r,true);},__wbg_prototypesetcall_956c7493c68e29b4:function(t,e,_){Uint8Array.prototype.set.call(F(t,e),o(_));},__wbg_push_ceb8ef046afb2041:function(t,e){return o(t).push(o(e))},__wbg_queueMicrotask_4698f900840e3286:function(t){queueMicrotask(o(t));},__wbg_queueMicrotask_477a5533c7100338:function(t){let e=o(t).queueMicrotask;return p(e)},__wbg_randomFillSync_6c25eac9869eb53c:function(){return x(function(t,e){o(t).randomFillSync(u(e));},arguments)},__wbg_read_8426c146431f2905:function(t){let e=o(t).read();return p(e)},__wbg_readyState_25243ad6ce649774:function(t){return o(t).readyState},__wbg_reason_4ec455bac79b33ce:function(t,e){let _=o(e).reason,r=a(_,n.__wbindgen_export,n.__wbindgen_export2),i=s;d().setInt32(t+4,i,true),d().setInt32(t+0,r,true);},__wbg_releaseLock_188846ef719acb10:function(t){o(t).releaseLock();},__wbg_removeEventListener_016c1d24523b4730:function(){return x(function(t,e,_,r){o(t).removeEventListener(v(e,_),o(r));},arguments)},__wbg_require_b4edbdcf3e2a1ef0:function(){return x(function(){let t=module.require;return p(t)},arguments)},__wbg_resolve_0183de2e8c6b1d54:function(t){let e=Promise.resolve(o(t));return p(e)},__wbg_respond_3cdb4cf32683fd79:function(){return x(function(t,e){o(t).respond(e>>>0);},arguments)},__wbg_send_99d049cae69c53cc:function(){return x(function(t,e,_){o(t).send(F(e,_));},arguments)},__wbg_send_bac9d3dc4f21ef28:function(){return x(function(t,e,_){o(t).send(v(e,_));},arguments)},__wbg_setTimeout_3a808dd861dd3c12:function(t,e){let _=setTimeout(o(t),e);return p(_)},__wbg_setTimeout_6613a51400c1bf9f:function(){return x(function(t,e,_){let r=o(t).setTimeout(u(e),_);return p(r)},arguments)},__wbg_setTimeout_ef24d2fc3ad97385:function(){return x(function(t,e){let _=setTimeout(o(t),e);return p(_)},arguments)},__wbg_setTimeout_f757f00851f76c42:function(t,e){let _=setTimeout(o(t),e);return p(_)},__wbg_set_3ab3dfede3bae139:function(){return x(function(t,e,_,r,i){o(t).set(v(e,_),v(r,i));},arguments)},__wbg_set_5f806304fb633ab3:function(t,e,_){let r=o(t).set(o(e),o(_));return p(r)},__wbg_set_6be42768c690e380:function(t,e,_){o(t)[u(e)]=u(_);},__wbg_set_86698c227e5b9dad:function(t,e,_){o(t).set(F(e,_));},__wbg_set_a6ba3ac0e634b822:function(){return x(function(t,e,_){return Reflect.set(o(t),o(e),o(_))},arguments)},__wbg_set_binaryType_8c2dd2cf1cfc2e28:function(t,e){o(t).binaryType=Rt[e];},__wbg_set_body_d1153b16a2b95ca1:function(t,e){o(t).body=o(e);},__wbg_set_cache_5a01a8b5e6ca6cf2:function(t,e){o(t).cache=St[e];},__wbg_set_credentials_e9120ed88b1fc0b8:function(t,e){o(t).credentials=Ft[e];},__wbg_set_da33c120a6584674:function(t,e,_){o(t)[e>>>0]=u(_);},__wbg_set_detail_c7af5edea934390b:function(t,e){o(t).detail=o(e);},__wbg_set_handle_event_6147c38b782c7b42:function(t,e){o(t).handleEvent=o(e);},__wbg_set_headers_877ed41890d28af2:function(t,e){o(t).headers=o(e);},__wbg_set_high_water_mark_77da20c49668427d:function(t,e){o(t).highWaterMark=e;},__wbg_set_method_b4ede299b2064f37:function(t,e,_){o(t).method=v(e,_);},__wbg_set_mode_d6c2e1991aa963c6:function(t,e){o(t).mode=Et[e];},__wbg_set_onclose_9cb5c3372e16c192:function(t,e){o(t).onclose=o(e);},__wbg_set_onerror_190fe67e911ebf28:function(t,e){o(t).onerror=o(e);},__wbg_set_onmessage_96337495f0bfb796:function(t,e){o(t).onmessage=o(e);},__wbg_set_onopen_3e2bf6b11d434c2d:function(t,e){o(t).onopen=o(e);},__wbg_set_signal_9022b5aa06a6ce5b:function(t,e){o(t).signal=o(e);},__wbg_signal_41dd1a8913cd0b7d:function(t){let e=o(t).signal;return p(e)},__wbg_stack_3b0d974bbf31e44f:function(t,e){let _=o(e).stack,r=a(_,n.__wbindgen_export,n.__wbindgen_export2),i=s;d().setInt32(t+4,i,true),d().setInt32(t+0,r,true);},__wbg_static_accessor_GLOBAL_60a4124bab7dcc9a:function(){let t=typeof global>"u"?null:global;return f(t)?0:p(t)},__wbg_static_accessor_GLOBAL_THIS_95ca6460658b5d13:function(){let t=typeof globalThis>"u"?null:globalThis;return f(t)?0:p(t)},__wbg_static_accessor_SELF_4c95f759a91e9aae:function(){let t=typeof self>"u"?null:self;return f(t)?0:p(t)},__wbg_static_accessor_WINDOW_44b435597f9e9ee7:function(){let t=typeof window>"u"?null:window;return f(t)?0:p(t)},__wbg_status_9e6505cfa3e73a7c:function(t){return o(t).status},__wbg_stringify_a42c95ea9a7591c9:function(){return x(function(t){let e=JSON.stringify(o(t));return p(e)},arguments)},__wbg_subarray_42216645a367cd7a:function(t,e,_){let r=o(t).subarray(e>>>0,_>>>0);return p(r)},__wbg_text_d0039cf442b19ec4:function(){return x(function(t){let e=o(t).text();return p(e)},arguments)},__wbg_then_254bab9b266a77a5:function(t,e,_){let r=o(t).then(o(e),o(_));return p(r)},__wbg_then_3ea18602c6a5123b:function(t,e){let _=o(t).then(o(e));return p(_)},__wbg_toISOString_1c29c14154d57c76:function(t){let e=o(t).toISOString();return p(e)},__wbg_url_72c67c175685a054:function(t,e){let _=o(e).url,r=a(_,n.__wbindgen_export,n.__wbindgen_export2),i=s;d().setInt32(t+4,i,true),d().setInt32(t+0,r,true);},__wbg_url_d0b8042af0d1bbba:function(t,e){let _=o(e).url,r=a(_,n.__wbindgen_export,n.__wbindgen_export2),i=s;d().setInt32(t+4,i,true),d().setInt32(t+0,r,true);},__wbg_value_3d3defe09fb1ffca:function(t){let e=o(t).value;return p(e)},__wbg_versions_276b2795b1c6a219:function(t){let e=o(t).versions;return p(e)},__wbg_view_15fa5865c6b336e3:function(t){let e=o(t).view;return f(e)?0:p(e)},__wbg_warn_633bacc13ba7e6c3:function(t){console.warn(o(t));},__wbg_wasClean_f17429d064911939:function(t){return o(t).wasClean},__wbindgen_cast_0000000000000001:function(t,e){let _=A(t,e,yt);return p(_)},__wbindgen_cast_0000000000000002:function(t,e){let _=A(t,e,kt);return p(_)},__wbindgen_cast_0000000000000003:function(t,e){let _=A(t,e,ht);return p(_)},__wbindgen_cast_0000000000000004:function(t,e){let _=A(t,e,vt);return p(_)},__wbindgen_cast_0000000000000005:function(t,e){let _=A(t,e,dt);return p(_)},__wbindgen_cast_0000000000000006:function(t,e){let _=A(t,e,ft);return p(_)},__wbindgen_cast_0000000000000007:function(t,e){let _=A(t,e,lt);return p(_)},__wbindgen_cast_0000000000000008:function(t,e){let _=jt(t,e,mt);return p(_)},__wbindgen_cast_0000000000000009:function(t,e){let _=A(t,e,xt);return p(_)},__wbindgen_cast_000000000000000a:function(t){return p(t)},__wbindgen_cast_000000000000000b:function(t){return p(t)},__wbindgen_cast_000000000000000c:function(t,e){let _=F(t,e);return p(_)},__wbindgen_cast_000000000000000d:function(t,e){let _=v(t,e);return p(_)},__wbindgen_cast_000000000000000e:function(t){let e=BigInt.asUintN(64,t);return p(e)},__wbindgen_cast_000000000000000f:function(t,e){var _=F(t,e).slice();return n.__wbindgen_export4(t,e*1,1),p(_)},__wbindgen_object_clone_ref:function(t){let e=o(t);return p(e)},__wbindgen_object_drop_ref:function(t){u(t);}}}}function dt(c,t){n.__wasm_bindgen_func_elem_5312(c,t);}function ft(c,t){n.__wasm_bindgen_func_elem_9736(c,t);}function lt(c,t){n.__wasm_bindgen_func_elem_10866(c,t);}function mt(c,t){n.__wasm_bindgen_func_elem_10941(c,t);}function xt(c,t){n.__wasm_bindgen_func_elem_18514(c,t);}function yt(c,t,e){n.__wasm_bindgen_func_elem_9938(c,t,p(e));}function ht(c,t,e){n.__wasm_bindgen_func_elem_7414(c,t,p(e));}function vt(c,t,e){n.__wasm_bindgen_func_elem_11580(c,t,p(e));}function kt(c,t,e){try{let i=n.__wbindgen_add_to_stack_pointer(-16);n.__wasm_bindgen_func_elem_18660(i,c,t,p(e));var _=d().getInt32(i+0,!0),r=d().getInt32(i+4,!0);if(r)throw u(_)}finally{n.__wbindgen_add_to_stack_pointer(16);}}function It(c,t,e,_){n.__wasm_bindgen_func_elem_18662(c,t,p(e),p(_));}var Rt=["blob","arraybuffer"],St=["default","no-store","reload","no-cache","force-cache","only-if-cached"],Ft=["omit","same-origin","include"],Et=["same-origin","no-cors","cors","navigate"],tt=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(c=>n.__wbg_bistream_free(c,1));typeof FinalizationRegistry>"u"?{}:new FinalizationRegistry(c=>n.__wbg_intounderlyingbytesource_free(c,1));var et=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(c=>n.__wbg_intounderlyingsink_free(c,1)),nt=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(c=>n.__wbg_intounderlyingsource_free(c,1)),_t=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(c=>n.__wbg_peerunistream_free(c,1)),H=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(c=>n.__wbg_wasmclient_free(c,1));typeof FinalizationRegistry>"u"?{}:new FinalizationRegistry(c=>n.__wbg_wasmconnection_free(c,1));function p(c){W===R.length&&R.push(R.length+1);let t=W;return W=R[t],R[t]=c,t}var G=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(c=>n.__wbindgen_export5(c.a,c.b));function K(c){let t=typeof c;if(t=="number"||t=="boolean"||c==null)return `${c}`;if(t=="string")return `"${c}"`;if(t=="symbol"){let r=c.description;return r==null?"Symbol":`Symbol(${r})`}if(t=="function"){let r=c.name;return typeof r=="string"&&r.length>0?`Function(${r})`:"Function"}if(Array.isArray(c)){let r=c.length,i="[";r>0&&(i+=K(c[0]));for(let b=1;b<r;b++)i+=", "+K(c[b]);return i+="]",i}let e=/\[object ([^\]]+)\]/.exec(toString.call(c)),_;if(e&&e.length>1)_=e[1];else return toString.call(c);if(_=="Object")try{return "Object("+JSON.stringify(c)+")"}catch{return "Object"}return c instanceof Error?`${c.name}: ${c.message}
|
|
1
|
+
import {a as a$1,A as A$1}from'./chunk-6J3QKQRS.js';import {a as a$2}from'./chunk-TW4HQLK6.js';import {h}from'./chunk-W5YFLH2U.js';import {s as s$1}from'./chunk-SVBFZRGV.js';var z=class c{static __wrap(t){let e=Object.create(c.prototype);return e.__wbg_ptr=t,tt.register(e,e.__wbg_ptr,e),e}__destroy_into_raw(){let t=this.__wbg_ptr;return this.__wbg_ptr=0,tt.unregister(this),t}free(){let t=this.__destroy_into_raw();n.__wbg_bistream_free(t,0);}get applicationCryptoWrapped(){return n.bistream_applicationCryptoWrapped(this.__wbg_ptr)!==0}get endpoint_id(){let t,e;try{let i=n.__wbindgen_add_to_stack_pointer(-16);n.bistream_endpoint_id(i,this.__wbg_ptr);var _=d().getInt32(i+0,!0),r=d().getInt32(i+4,!0);return t=_,e=r,v(_,r)}finally{n.__wbindgen_add_to_stack_pointer(16),n.__wbindgen_export4(t,e,1);}}finishSend(){let t=n.bistream_finishSend(this.__wbg_ptr);return u(t)}get recv(){let t=n.bistream_recv(this.__wbg_ptr);return u(t)}get send(){let t=n.bistream_send(this.__wbg_ptr);return u(t)}};Symbol.dispose&&(z.prototype[Symbol.dispose]=z.prototype.free);var B=class c{static __wrap(t){let e=Object.create(c.prototype);return e.__wbg_ptr=t,et.register(e,e.__wbg_ptr,e),e}__destroy_into_raw(){let t=this.__wbg_ptr;return this.__wbg_ptr=0,et.unregister(this),t}free(){let t=this.__destroy_into_raw();n.__wbg_intounderlyingsink_free(t,0);}abort(t){let e=this.__destroy_into_raw(),_=n.intounderlyingsink_abort(e,p(t));return u(_)}close(){let t=this.__destroy_into_raw(),e=n.intounderlyingsink_close(t);return u(e)}write(t){let e=n.intounderlyingsink_write(this.__wbg_ptr,p(t));return u(e)}};Symbol.dispose&&(B.prototype[Symbol.dispose]=B.prototype.free);var N=class c{static __wrap(t){let e=Object.create(c.prototype);return e.__wbg_ptr=t,nt.register(e,e.__wbg_ptr,e),e}__destroy_into_raw(){let t=this.__wbg_ptr;return this.__wbg_ptr=0,nt.unregister(this),t}free(){let t=this.__destroy_into_raw();n.__wbg_intounderlyingsource_free(t,0);}cancel(){let t=this.__destroy_into_raw();n.intounderlyingsource_cancel(t);}pull(t){let e=n.intounderlyingsource_pull(this.__wbg_ptr,p(t));return u(e)}};Symbol.dispose&&(N.prototype[Symbol.dispose]=N.prototype.free);var q=class c{static __wrap(t){let e=Object.create(c.prototype);return e.__wbg_ptr=t,_t.register(e,e.__wbg_ptr,e),e}__destroy_into_raw(){let t=this.__wbg_ptr;return this.__wbg_ptr=0,_t.unregister(this),t}free(){let t=this.__destroy_into_raw();n.__wbg_peerunistream_free(t,0);}get applicationCryptoWrapped(){return n.peerunistream_applicationCryptoWrapped(this.__wbg_ptr)!==0}finishSend(){let t=n.peerunistream_finishSend(this.__wbg_ptr);return u(t)}get writable(){let t=n.peerunistream_writable(this.__wbg_ptr);return u(t)}};Symbol.dispose&&(q.prototype[Symbol.dispose]=q.prototype.free);var O=class c{static __wrap(t){let e=Object.create(c.prototype);return e.__wbg_ptr=t,H.register(e,e.__wbg_ptr,e),e}__destroy_into_raw(){let t=this.__wbg_ptr;return this.__wbg_ptr=0,H.unregister(this),t}free(){let t=this.__destroy_into_raw();n.__wbg_wasmclient_free(t,0);}add_peer_scope(t,e){let _=a(t,n.__wbindgen_export,n.__wbindgen_export2),r=s,i=a(e,n.__wbindgen_export,n.__wbindgen_export2),b=s,w=n.wasmclient_add_peer_scope(this.__wbg_ptr,_,r,i,b);return u(w)}bind_connection_device_id(t,e){let _=a(t,n.__wbindgen_export,n.__wbindgen_export2),r=s,i=a(e,n.__wbindgen_export,n.__wbindgen_export2),b=s,w=n.wasmclient_bind_connection_device_id(this.__wbg_ptr,_,r,i,b);return u(w)}bind_node_device_id(t,e){let _=a(t,n.__wbindgen_export,n.__wbindgen_export2),r=s,i=a(e,n.__wbindgen_export,n.__wbindgen_export2),b=s,w=n.wasmclient_bind_node_device_id(this.__wbg_ptr,_,r,i,b);return u(w)}clearConnectionApplicationCryptoKey(t){let e=a(t,n.__wbindgen_export,n.__wbindgen_export2),_=s;n.wasmclient_clearConnectionApplicationCryptoKey(this.__wbg_ptr,e,_);}clear_session_tokens(){n.wasmclient_clear_session_tokens(this.__wbg_ptr);}confirm_inline_reciprocal_session_admission(t,e,_,r,i,b){let w=a(t,n.__wbindgen_export,n.__wbindgen_export2),g=s,m=a(_,n.__wbindgen_export,n.__wbindgen_export2),l=s,y=a(r,n.__wbindgen_export,n.__wbindgen_export2),h=s;var k=f(b)?0:a(b,n.__wbindgen_export,n.__wbindgen_export2),I=s;let S=n.wasmclient_confirm_inline_reciprocal_session_admission(this.__wbg_ptr,w,g,e,m,l,y,h,i,k,I);return u(S)}connect(t){let e=a(t,n.__wbindgen_export,n.__wbindgen_export2),_=s,r=n.wasmclient_connect(this.__wbg_ptr,e,_);return u(r)}connect_device(t,e){var _=f(t)?0:a(t,n.__wbindgen_export,n.__wbindgen_export2),r=s;let i=a(e,n.__wbindgen_export,n.__wbindgen_export2),b=s,w=n.wasmclient_connect_device(this.__wbg_ptr,_,r,i,b);return u(w)}connection_state(t){let e=a(t,n.__wbindgen_export,n.__wbindgen_export2),_=s,r=n.wasmclient_connection_state(this.__wbg_ptr,e,_);return u(r)}connection_states(){let t=n.wasmclient_connection_states(this.__wbg_ptr);return u(t)}create_room(t,e,_,r,i,b){let w=a(t,n.__wbindgen_export,n.__wbindgen_export2),g=s,m=a(e,n.__wbindgen_export,n.__wbindgen_export2),l=s,y=a(_,n.__wbindgen_export,n.__wbindgen_export2),h=s,k=a(r,n.__wbindgen_export,n.__wbindgen_export2),I=s,S=a(i,n.__wbindgen_export,n.__wbindgen_export2),C=s,V=n.wasmclient_create_room(this.__wbg_ptr,w,g,m,l,y,h,k,I,S,C,f(b)?Number.MAX_SAFE_INTEGER:b>>>0);return u(V)}create_session(t){let e=a(t,n.__wbindgen_export,n.__wbindgen_export2),_=s,r=n.wasmclient_create_session(this.__wbg_ptr,e,_);return u(r)}delete_device(t,e){let _=a(t,n.__wbindgen_export,n.__wbindgen_export2),r=s,i=a(e,n.__wbindgen_export,n.__wbindgen_export2),b=s,w=n.wasmclient_delete_device(this.__wbg_ptr,_,r,i,b);return u(w)}devices_with_status(t){let e=a(t,n.__wbindgen_export,n.__wbindgen_export2),_=s,r=n.wasmclient_devices_with_status(this.__wbg_ptr,e,_);return u(r)}disconnect(t){let e=a(t,n.__wbindgen_export,n.__wbindgen_export2),_=s,r=n.wasmclient_disconnect(this.__wbg_ptr,e,_);return u(r)}disconnect_device(t,e){let _=a(t,n.__wbindgen_export,n.__wbindgen_export2),r=s;var i=f(e)?0:a(e,n.__wbindgen_export,n.__wbindgen_export2),b=s;let w=n.wasmclient_disconnect_device(this.__wbg_ptr,_,r,i,b);return u(w)}disconnect_transient(t){let e=a(t,n.__wbindgen_export,n.__wbindgen_export2),_=s,r=n.wasmclient_disconnect_transient(this.__wbg_ptr,e,_);return u(r)}endpoint_id_from_ticket(t){let e,_;try{let l=n.__wbindgen_add_to_stack_pointer(-16),y=a(t,n.__wbindgen_export,n.__wbindgen_export2),h=s;n.wasmclient_endpoint_id_from_ticket(l,this.__wbg_ptr,y,h);var r=d().getInt32(l+0,!0),i=d().getInt32(l+4,!0),b=d().getInt32(l+8,!0),w=d().getInt32(l+12,!0),g=r,m=i;if(w)throw g=0,m=0,u(b);return e=g,_=m,v(g,m)}finally{n.__wbindgen_add_to_stack_pointer(16),n.__wbindgen_export4(e,_,1);}}endpoint_ticket(){let t=n.wasmclient_endpoint_ticket(this.__wbg_ptr);return u(t)}endpoint_ticket_with_token(t,e){let _=a(t,n.__wbindgen_export,n.__wbindgen_export2),r=s,i=n.wasmclient_endpoint_ticket_with_token(this.__wbg_ptr,_,r,e);return u(i)}force_reconnect_snapshot(){n.wasmclient_force_reconnect_snapshot(this.__wbg_ptr);}get_members(t,e,_){let r=a(t,n.__wbindgen_export,n.__wbindgen_export2),i=s,b=a(e,n.__wbindgen_export,n.__wbindgen_export2),w=s,g=a(_,n.__wbindgen_export,n.__wbindgen_export2),m=s,l=n.wasmclient_get_members(this.__wbg_ptr,r,i,b,w,g,m);return u(l)}heartbeat_tick(t,e,_){let r=a(t,n.__wbindgen_export,n.__wbindgen_export2),i=s,b=a(e,n.__wbindgen_export,n.__wbindgen_export2),w=s,g=a(_,n.__wbindgen_export,n.__wbindgen_export2),m=s,l=n.wasmclient_heartbeat_tick(this.__wbg_ptr,r,i,b,w,g,m);return u(l)}incoming_streams(){let t=n.wasmclient_incoming_streams(this.__wbg_ptr);return u(t)}init_iroh(t){var e=f(t)?0:L(t,n.__wbindgen_export),_=s;let r=n.wasmclient_init_iroh(this.__wbg_ptr,e,_);return u(r)}iroh_path_kind(t){let e=a(t,n.__wbindgen_export,n.__wbindgen_export2),_=s,r=n.wasmclient_iroh_path_kind(this.__wbg_ptr,e,_);return u(r)}iroh_secret_key(){let t=n.wasmclient_iroh_secret_key(this.__wbg_ptr);return u(t)}iroh_transport_rtt_ms(t){let e=a(t,n.__wbindgen_export,n.__wbindgen_export2),_=s,r=n.wasmclient_iroh_transport_rtt_ms(this.__wbg_ptr,e,_);return u(r)}is_auto_connect_excluded(t){let e=a(t,n.__wbindgen_export,n.__wbindgen_export2),_=s;return n.wasmclient_is_auto_connect_excluded(this.__wbg_ptr,e,_)!==0}is_connected(t){let e=a(t,n.__wbindgen_export,n.__wbindgen_export2),_=s,r=n.wasmclient_is_connected(this.__wbg_ptr,e,_);return u(r)}is_current_transport_stable_id(t,e){let _=a(t,n.__wbindgen_export,n.__wbindgen_export2),r=s,i=n.wasmclient_is_current_transport_stable_id(this.__wbg_ptr,_,r,e);return u(i)}join_room(t,e,_,r,i){let b=a(t,n.__wbindgen_export,n.__wbindgen_export2),w=s,g=a(e,n.__wbindgen_export,n.__wbindgen_export2),m=s,l=a(_,n.__wbindgen_export,n.__wbindgen_export2),y=s,h=a(r,n.__wbindgen_export,n.__wbindgen_export2),k=s,I=a(i,n.__wbindgen_export,n.__wbindgen_export2),S=s,C=n.wasmclient_join_room(this.__wbg_ptr,b,w,g,m,l,y,h,k,I,S);return u(C)}leave_room(t,e,_){let r=a(t,n.__wbindgen_export,n.__wbindgen_export2),i=s,b=a(e,n.__wbindgen_export,n.__wbindgen_export2),w=s,g=a(_,n.__wbindgen_export,n.__wbindgen_export2),m=s,l=n.wasmclient_leave_room(this.__wbg_ptr,r,i,b,w,g,m);return u(l)}list_managed_connections(){let t=n.wasmclient_list_managed_connections(this.__wbg_ptr);return u(t)}constructor(t,e){try{let b=n.__wbindgen_add_to_stack_pointer(-16),w=a(t,n.__wbindgen_export,n.__wbindgen_export2),g=s,m=a(e,n.__wbindgen_export,n.__wbindgen_export2),l=s;n.wasmclient_new(b,w,g,m,l);var _=d().getInt32(b+0,!0),r=d().getInt32(b+4,!0),i=d().getInt32(b+8,!0);if(i)throw u(r);return this.__wbg_ptr=_,H.register(this,this.__wbg_ptr,this),this}finally{n.__wbindgen_add_to_stack_pointer(16);}}static newWithAppTag(t,e){try{let b=n.__wbindgen_add_to_stack_pointer(-16),w=a(t,n.__wbindgen_export,n.__wbindgen_export2),g=s,m=a(e,n.__wbindgen_export,n.__wbindgen_export2),l=s;n.wasmclient_newWithAppTag(b,w,g,m,l);var _=d().getInt32(b+0,!0),r=d().getInt32(b+4,!0),i=d().getInt32(b+8,!0);if(i)throw u(r);return c.__wrap(_)}finally{n.__wbindgen_add_to_stack_pointer(16);}}node_addr(){let t=n.wasmclient_node_addr(this.__wbg_ptr);return u(t)}open_bi(t){let e=a(t,n.__wbindgen_export,n.__wbindgen_export2),_=s,r=n.wasmclient_open_bi(this.__wbg_ptr,e,_);return u(r)}open_native_main_control_bi(t){let e=a(t,n.__wbindgen_export,n.__wbindgen_export2),_=s,r=n.wasmclient_open_native_main_control_bi(this.__wbg_ptr,e,_);return u(r)}open_peer_bi(t,e){let _=a(t,n.__wbindgen_export,n.__wbindgen_export2),r=s,i=n.wasmclient_open_peer_bi(this.__wbg_ptr,_,r,f(e)?Number.MAX_SAFE_INTEGER:e>>>0);return u(i)}open_peer_bi_explicit_file_sender(t,e){let _=a(t,n.__wbindgen_export,n.__wbindgen_export2),r=s,i=n.wasmclient_open_peer_bi_explicit_file_sender(this.__wbg_ptr,_,r,f(e)?Number.MAX_SAFE_INTEGER:e>>>0);return u(i)}open_peer_bi_transport_only(t,e){let _=a(t,n.__wbindgen_export,n.__wbindgen_export2),r=s,i=n.wasmclient_open_peer_bi_transport_only(this.__wbg_ptr,_,r,f(e)?Number.MAX_SAFE_INTEGER:e>>>0);return u(i)}open_peer_native_bi(t,e,_){let r=a(t,n.__wbindgen_export,n.__wbindgen_export2),i=s,b=a(e,n.__wbindgen_export,n.__wbindgen_export2),w=s,g=n.wasmclient_open_peer_native_bi(this.__wbg_ptr,r,i,b,w,f(_)?Number.MAX_SAFE_INTEGER:_>>>0);return u(g)}open_peer_uni(t,e){let _=a(t,n.__wbindgen_export,n.__wbindgen_export2),r=s,i=n.wasmclient_open_peer_uni(this.__wbg_ptr,_,r,f(e)?Number.MAX_SAFE_INTEGER:e>>>0);return u(i)}open_uni(t){let e=a(t,n.__wbindgen_export,n.__wbindgen_export2),_=s,r=n.wasmclient_open_uni(this.__wbg_ptr,e,_);return u(r)}peer_scopes(t){let e=a(t,n.__wbindgen_export,n.__wbindgen_export2),_=s,r=n.wasmclient_peer_scopes(this.__wbg_ptr,e,_);return u(r)}peer_session(t){let e=a(t,n.__wbindgen_export,n.__wbindgen_export2),_=s,r=n.wasmclient_peer_session(this.__wbg_ptr,e,_);return u(r)}peer_sessions(){let t=n.wasmclient_peer_sessions(this.__wbg_ptr);return u(t)}peer_snapshot(t){let e=a(t,n.__wbindgen_export,n.__wbindgen_export2),_=s,r=n.wasmclient_peer_snapshot(this.__wbg_ptr,e,_);return u(r)}prepare_inline_reciprocal_session_admission(t,e,_,r,i,b,w,g){let m=a(t,n.__wbindgen_export,n.__wbindgen_export2),l=s,y=a(_,n.__wbindgen_export,n.__wbindgen_export2),h=s,k=a(r,n.__wbindgen_export,n.__wbindgen_export2),I=s,S=a(i,n.__wbindgen_export,n.__wbindgen_export2),C=s,V=a(b,n.__wbindgen_export,n.__wbindgen_export2),ct=s,at=a(w,n.__wbindgen_export,n.__wbindgen_export2),bt=s,pt=a(g,n.__wbindgen_export,n.__wbindgen_export2),ut=s,wt=n.wasmclient_prepare_inline_reciprocal_session_admission(this.__wbg_ptr,m,l,e,y,h,k,I,S,C,V,ct,at,bt,pt,ut);return u(wt)}present_session_token_to_host(t,e){let _=a(t,n.__wbindgen_export,n.__wbindgen_export2),r=s,i=a(e,n.__wbindgen_export,n.__wbindgen_export2),b=s,w=n.wasmclient_present_session_token_to_host(this.__wbg_ptr,_,r,i,b);return u(w)}present_session_token_to_host_with_payload(t,e,_){let r=a(t,n.__wbindgen_export,n.__wbindgen_export2),i=s,b=a(e,n.__wbindgen_export,n.__wbindgen_export2),w=s;var g=f(_)?0:a(_,n.__wbindgen_export,n.__wbindgen_export2),m=s;let l=n.wasmclient_present_session_token_to_host_with_payload(this.__wbg_ptr,r,i,b,w,g,m);return u(l)}present_session_token_to_host_with_payload_and_device_id(t,e,_,r){let i=a(t,n.__wbindgen_export,n.__wbindgen_export2),b=s,w=a(e,n.__wbindgen_export,n.__wbindgen_export2),g=s;var m=f(_)?0:a(_,n.__wbindgen_export,n.__wbindgen_export2),l=s,y=f(r)?0:a(r,n.__wbindgen_export,n.__wbindgen_export2),h=s;let k=n.wasmclient_present_session_token_to_host_with_payload_and_device_id(this.__wbg_ptr,i,b,w,g,m,l,y,h);return u(k)}rankRoutes(t,e){try{let b=n.__wbindgen_add_to_stack_pointer(-16),w=ot(t,n.__wbindgen_export),g=s,m=ot(e,n.__wbindgen_export),l=s;n.wasmclient_rankRoutes(b,this.__wbg_ptr,w,g,m,l);var _=d().getInt32(b+0,!0),r=d().getInt32(b+4,!0),i=Ct(_,r).slice();return n.__wbindgen_export4(_,r*4,4),i}finally{n.__wbindgen_add_to_stack_pointer(16);}}register_session_token(t,e,_){let r=a(t,n.__wbindgen_export,n.__wbindgen_export2),i=s,b=a(e,n.__wbindgen_export,n.__wbindgen_export2),w=s;n.wasmclient_register_session_token(this.__wbg_ptr,r,i,b,w,_);}register_session_token_with_expiry_ms(t,e,_,r){let i=a(t,n.__wbindgen_export,n.__wbindgen_export2),b=s,w=a(e,n.__wbindgen_export,n.__wbindgen_export2),g=s;n.wasmclient_register_session_token_with_expiry_ms(this.__wbg_ptr,i,b,w,g,_,r);}reject_connection_admission(t,e){let _=a(t,n.__wbindgen_export,n.__wbindgen_export2),r=s,i=a(e,n.__wbindgen_export,n.__wbindgen_export2),b=s,w=n.wasmclient_reject_connection_admission(this.__wbg_ptr,_,r,i,b);return u(w)}release_peer_scope(t,e){let _=a(t,n.__wbindgen_export,n.__wbindgen_export2),r=s;var i=f(e)?0:a(e,n.__wbindgen_export,n.__wbindgen_export2),b=s;let w=n.wasmclient_release_peer_scope(this.__wbg_ptr,_,r,i,b);return u(w)}remote_session_admission_ready_for_ticket(t){let e=a(t,n.__wbindgen_export,n.__wbindgen_export2),_=s,r=n.wasmclient_remote_session_admission_ready_for_ticket(this.__wbg_ptr,e,_);return u(r)}report_managed_connection_settled(t,e,_,r,i,b){let w=a(t,n.__wbindgen_export,n.__wbindgen_export2),g=s;var m=f(_)?0:a(_,n.__wbindgen_export,n.__wbindgen_export2),l=s;let y=n.wasmclient_report_managed_connection_settled(this.__wbg_ptr,w,g,e,m,l,!f(r),f(r)?BigInt(0):r,!f(i),f(i)?BigInt(0):i,!f(b),f(b)?BigInt(0):b);return u(y)}report_transport_status(t,e,_,r,i,b){let w=a(t,n.__wbindgen_export,n.__wbindgen_export2),g=s,m=a(e,n.__wbindgen_export,n.__wbindgen_export2),l=s;var y=f(_)?0:a(_,n.__wbindgen_export,n.__wbindgen_export2),h=s;let k=n.wasmclient_report_transport_status(this.__wbg_ptr,w,g,m,l,y,h,!f(r),f(r)?BigInt(0):r,!f(i),f(i)?BigInt(0):i,!f(b),f(b)?BigInt(0):b);return u(k)}resolve_peer_connection_records(t){let e=a(t,n.__wbindgen_export,n.__wbindgen_export2),_=s,r=n.wasmclient_resolve_peer_connection_records(this.__wbg_ptr,e,_);return u(r)}revoke_session_token(t){try{let i=n.__wbindgen_add_to_stack_pointer(-16),b=a(t,n.__wbindgen_export,n.__wbindgen_export2),w=s;n.wasmclient_revoke_session_token(i,this.__wbg_ptr,b,w);var e=d().getInt32(i+0,!0),_=d().getInt32(i+4,!0),r=d().getInt32(i+8,!0);if(r)throw u(_);return u(e)}finally{n.__wbindgen_add_to_stack_pointer(16);}}revoke_tokens_by_scope(t){let e=a(t,n.__wbindgen_export,n.__wbindgen_export2),_=s,r=n.wasmclient_revoke_tokens_by_scope(this.__wbg_ptr,e,_);return u(r)}runtime_policy(){try{let r=n.__wbindgen_add_to_stack_pointer(-16);n.wasmclient_runtime_policy(r,this.__wbg_ptr);var t=d().getInt32(r+0,!0),e=d().getInt32(r+4,!0),_=d().getInt32(r+8,!0);if(_)throw u(e);return u(t)}finally{n.__wbindgen_add_to_stack_pointer(16);}}same_peer(t,e){let _=a(t,n.__wbindgen_export,n.__wbindgen_export2),r=s,i=a(e,n.__wbindgen_export,n.__wbindgen_export2),b=s,w=n.wasmclient_same_peer(this.__wbg_ptr,_,r,i,b);return u(w)}search_devices(t){let e=a(t,n.__wbindgen_export,n.__wbindgen_export2),_=s,r=n.wasmclient_search_devices(this.__wbg_ptr,e,_);return u(r)}send_message(t,e,_,r){let i=a(t,n.__wbindgen_export,n.__wbindgen_export2),b=s,w=a(e,n.__wbindgen_export,n.__wbindgen_export2),g=s;var m=f(_)?0:a(_,n.__wbindgen_export,n.__wbindgen_export2),l=s,y=f(r)?0:a(r,n.__wbindgen_export,n.__wbindgen_export2),h=s;let k=n.wasmclient_send_message(this.__wbg_ptr,i,b,w,g,m,l,y,h);return u(k)}send_peer(t,e){let _=a(t,n.__wbindgen_export,n.__wbindgen_export2),r=s,i=L(e,n.__wbindgen_export),b=s,w=n.wasmclient_send_peer(this.__wbg_ptr,_,r,i,b);return u(w)}send_peer_application_frame(t,e,_){let r=a(t,n.__wbindgen_export,n.__wbindgen_export2),i=s,b=L(e,n.__wbindgen_export),w=s,g=n.wasmclient_send_peer_application_frame(this.__wbg_ptr,r,i,b,w,f(_)?Number.MAX_SAFE_INTEGER:_>>>0);return u(g)}setConnectionApplicationCryptoKey(t,e){let _=a(t,n.__wbindgen_export,n.__wbindgen_export2),r=s,i=L(e,n.__wbindgen_export),b=s,w=n.wasmclient_setConnectionApplicationCryptoKey(this.__wbg_ptr,_,r,i,b);return u(w)}setConnectionApplicationCryptoRequired(t){try{let r=n.__wbindgen_add_to_stack_pointer(-16),i=a(t,n.__wbindgen_export,n.__wbindgen_export2),b=s;n.wasmclient_setConnectionApplicationCryptoRequired(r,this.__wbg_ptr,i,b);var e=d().getInt32(r+0,!0),_=d().getInt32(r+4,!0);if(_)throw u(e)}finally{n.__wbindgen_add_to_stack_pointer(16);}}set_auth_token(t){var e=f(t)?0:a(t,n.__wbindgen_export,n.__wbindgen_export2),_=s;n.wasmclient_set_auth_token(this.__wbg_ptr,e,_);}set_auto_connect_excluded(t,e){let _=a(t,n.__wbindgen_export,n.__wbindgen_export2),r=s,i=n.wasmclient_set_auto_connect_excluded(this.__wbg_ptr,_,r,e);return u(i)}set_offline(t){let e=a(t,n.__wbindgen_export,n.__wbindgen_export2),_=s,r=n.wasmclient_set_offline(this.__wbg_ptr,e,_);return u(r)}start_auto_connect(t,e){try{let i=n.__wbindgen_add_to_stack_pointer(-16),b=a(t,n.__wbindgen_export,n.__wbindgen_export2),w=s,g=a(e,n.__wbindgen_export,n.__wbindgen_export2),m=s;n.wasmclient_start_auto_connect(i,this.__wbg_ptr,b,w,g,m);var _=d().getInt32(i+0,!0),r=d().getInt32(i+4,!0);if(r)throw u(_)}finally{n.__wbindgen_add_to_stack_pointer(16);}}start_presence_loop(t,e,_,r){let i=a(t,n.__wbindgen_export,n.__wbindgen_export2),b=s,w=a(e,n.__wbindgen_export,n.__wbindgen_export2),g=s,m=a(_,n.__wbindgen_export,n.__wbindgen_export2),l=s;var y=f(r)?0:a(r,n.__wbindgen_export,n.__wbindgen_export2),h=s;n.wasmclient_start_presence_loop(this.__wbg_ptr,i,b,w,g,m,l,y,h);}stop_auth_scoped_activity(){n.wasmclient_stop_auth_scoped_activity(this.__wbg_ptr);}stop_auto_connect(){n.wasmclient_stop_auto_connect(this.__wbg_ptr);}stop_presence_loop(){n.wasmclient_stop_presence_loop(this.__wbg_ptr);}submit_browser_desired_peers(t,e){try{let b=n.__wbindgen_add_to_stack_pointer(-16),w=a(e,n.__wbindgen_export,n.__wbindgen_export2),g=s;n.wasmclient_submit_browser_desired_peers(b,this.__wbg_ptr,t,w,g);var _=d().getInt32(b+0,!0),r=d().getInt32(b+4,!0),i=d().getInt32(b+8,!0);if(i)throw u(r);return _!==0}finally{n.__wbindgen_add_to_stack_pointer(16);}}update_device(t,e,_,r,i){let b=a(t,n.__wbindgen_export,n.__wbindgen_export2),w=s,g=a(e,n.__wbindgen_export,n.__wbindgen_export2),m=s;var l=f(_)?0:a(_,n.__wbindgen_export,n.__wbindgen_export2),y=s,h=f(i)?0:a(i,n.__wbindgen_export,n.__wbindgen_export2),k=s;let I=n.wasmclient_update_device(this.__wbg_ptr,b,w,g,m,l,y,f(r)?0:p(r),h,k);return u(I)}update_presence(t,e,_,r,i){let b=a(t,n.__wbindgen_export,n.__wbindgen_export2),w=s,g=a(e,n.__wbindgen_export,n.__wbindgen_export2),m=s,l=a(_,n.__wbindgen_export,n.__wbindgen_export2),y=s;var h=f(r)?0:a(r,n.__wbindgen_export,n.__wbindgen_export2),k=s;let I=n.wasmclient_update_presence(this.__wbg_ptr,b,w,g,m,l,y,h,k,!f(i),f(i)?BigInt(0):i);return u(I)}update_session(t,e){let _=a(t,n.__wbindgen_export,n.__wbindgen_export2),r=s,i=a(e,n.__wbindgen_export,n.__wbindgen_export2),b=s,w=n.wasmclient_update_session(this.__wbg_ptr,_,r,i,b);return u(w)}validate_session_token(t){let e,_;try{let l=n.__wbindgen_add_to_stack_pointer(-16),y=a(t,n.__wbindgen_export,n.__wbindgen_export2),h=s;n.wasmclient_validate_session_token(l,this.__wbg_ptr,y,h);var r=d().getInt32(l+0,!0),i=d().getInt32(l+4,!0),b=d().getInt32(l+8,!0),w=d().getInt32(l+12,!0),g=r,m=i;if(w)throw g=0,m=0,u(b);return e=g,_=m,v(g,m)}finally{n.__wbindgen_add_to_stack_pointer(16),n.__wbindgen_export4(e,_,1);}}validate_session_token_for_connection(t,e){let _=a(t,n.__wbindgen_export,n.__wbindgen_export2),r=s,i=a(e,n.__wbindgen_export,n.__wbindgen_export2),b=s,w=n.wasmclient_validate_session_token_for_connection(this.__wbg_ptr,_,r,i,b);return u(w)}validate_session_token_for_connection_with_payload(t,e,_){let r=a(t,n.__wbindgen_export,n.__wbindgen_export2),i=s,b=a(e,n.__wbindgen_export,n.__wbindgen_export2),w=s;var g=f(_)?0:a(_,n.__wbindgen_export,n.__wbindgen_export2),m=s;let l=n.wasmclient_validate_session_token_for_connection_with_payload(this.__wbg_ptr,r,i,b,w,g,m);return u(l)}wait_for_settled_peer(t,e){let _=a(t,n.__wbindgen_export,n.__wbindgen_export2),r=s,i=n.wasmclient_wait_for_settled_peer(this.__wbg_ptr,_,r,f(e)?Number.MAX_SAFE_INTEGER:e>>>0);return u(i)}wake_browser_auto_connect(){return n.wasmclient_wake_browser_auto_connect(this.__wbg_ptr)!==0}};Symbol.dispose&&(O.prototype[Symbol.dispose]=O.prototype.free);function it(){n.start();}function gt(){return {__proto__:null,"./openrtc_bg.js":{__proto__:null,__wbg_Error_9dc85fe1bc224456:function(t,e){let _=Error(v(t,e));return p(_)},__wbg_String_8564e559799eccda:function(t,e){let _=String(o(e)),r=a(_,n.__wbindgen_export,n.__wbindgen_export2),i=s;d().setInt32(t+4,i,true),d().setInt32(t+0,r,true);},__wbg___wbindgen_boolean_get_b131b2f36d6b2f55:function(t){let e=o(t),_=typeof e=="boolean"?e:void 0;return f(_)?16777215:_?1:0},__wbg___wbindgen_debug_string_56c147eb1a51f0c4:function(t,e){let _=K(o(e)),r=a(_,n.__wbindgen_export,n.__wbindgen_export2),i=s;d().setInt32(t+4,i,true),d().setInt32(t+0,r,true);},__wbg___wbindgen_in_ce8569b2fc6f5088:function(t,e){return o(t)in o(e)},__wbg___wbindgen_is_function_147961669f068cd4:function(t){return typeof o(t)=="function"},__wbg___wbindgen_is_null_ced4761460071341:function(t){return o(t)===null},__wbg___wbindgen_is_object_3a2c414391dbf751:function(t){let e=o(t);return typeof e=="object"&&e!==null},__wbg___wbindgen_is_string_6541b0f6ecd4e8e5:function(t){return typeof o(t)=="string"},__wbg___wbindgen_is_undefined_4410e3c20a99fa97:function(t){return o(t)===void 0},__wbg___wbindgen_jsval_eq_174c93ec61bab0c5:function(t,e){return o(t)===o(e)},__wbg___wbindgen_jsval_loose_eq_e07e3b1f5db6da6c:function(t,e){return o(t)==o(e)},__wbg___wbindgen_number_get_588ed6b97f0d7e14:function(t,e){let _=o(e),r=typeof _=="number"?_:void 0;d().setFloat64(t+8,f(r)?0:r,true),d().setInt32(t+0,!f(r),true);},__wbg___wbindgen_string_get_fa2687d531ed17a5:function(t,e){let _=o(e),r=typeof _=="string"?_:void 0;var i=f(r)?0:a(r,n.__wbindgen_export,n.__wbindgen_export2),b=s;d().setInt32(t+4,b,true),d().setInt32(t+0,i,true);},__wbg___wbindgen_throw_bbadd78c1bac3a77:function(t,e){throw new Error(v(t,e))},__wbg__wbg_cb_unref_c2301a3c9b78104b:function(t){o(t)._wbg_cb_unref();},__wbg_abort_56c00f462c9261d9:function(t,e){o(t).abort(o(e));},__wbg_abort_f2416f4a9852003e:function(t){o(t).abort();},__wbg_addEventListener_b635263c509aa7de:function(){return x(function(t,e,_,r){o(t).addEventListener(v(e,_),o(r));},arguments)},__wbg_append_c5a0c94a6a73b22e:function(){return x(function(t,e,_,r,i){o(t).append(v(e,_),v(r,i));},arguments)},__wbg_arrayBuffer_cc7704fa158b907a:function(){return x(function(t){let e=o(t).arrayBuffer();return p(e)},arguments)},__wbg_bistream_new:function(t){let e=z.__wrap(t);return p(e)},__wbg_body_442a47f02322d7b0:function(t){let e=o(t).body;return f(e)?0:p(e)},__wbg_buffer_8524b3453cde4918:function(t){let e=o(t).buffer;return p(e)},__wbg_byobRequest_cc72d210de793e64:function(t){let e=o(t).byobRequest;return f(e)?0:p(e)},__wbg_byteLength_96807b1d9ab24a4c:function(t){return o(t).byteLength},__wbg_byteOffset_a9c7002428843c41:function(t){return o(t).byteOffset},__wbg_call_91f00ddc43e01490:function(){return x(function(t,e){let _=o(t).call(o(e));return p(_)},arguments)},__wbg_call_ec09a4cf93377d3a:function(){return x(function(t,e,_){let r=o(t).call(o(e),o(_));return p(r)},arguments)},__wbg_cancel_f3a197b26dc88b39:function(t){let e=o(t).cancel();return p(e)},__wbg_catch_66060324c27be6f7:function(t,e){let _=o(t).catch(o(e));return p(_)},__wbg_clearTimeout_113b1cde814ec762:function(t){let e=clearTimeout(u(t));return p(e)},__wbg_clearTimeout_333bba87532ab9d3:function(t){let e=clearTimeout(u(t));return p(e)},__wbg_clearTimeout_47a40e3be01ed7a3:function(){return x(function(t,e){o(t).clearTimeout(u(e));},arguments)},__wbg_clearTimeout_6b8d9a38b9263d65:function(t){let e=clearTimeout(u(t));return p(e)},__wbg_close_296263cfe1bb2999:function(){return x(function(t){o(t).close();},arguments)},__wbg_close_388d99468213b286:function(){return x(function(t){o(t).close();},arguments)},__wbg_close_4857e22d08b71356:function(){return x(function(t){o(t).close();},arguments)},__wbg_code_1cda2855fcd9b009:function(t){return o(t).code},__wbg_code_70beb7b22374d55e:function(t){return o(t).code},__wbg_createDataChannel_122bd3d8aacee49b:function(t,e,_){let r=o(t).createDataChannel(v(e,_));return p(r)},__wbg_crypto_38df2bab126b63dc:function(t){let e=o(t).crypto;return p(e)},__wbg_data_8a04443c1e5a8cd3:function(t){let e=o(t).data;return p(e)},__wbg_dispatchEvent_cc62a6a43d28b01c:function(){return x(function(t,e){return o(t).dispatchEvent(o(e))},arguments)},__wbg_done_6a8439e544ec6206:function(t){return o(t).done},__wbg_enqueue_bbeb09ba0b140f76:function(){return x(function(t,e){o(t).enqueue(o(e));},arguments)},__wbg_entries_4e00eefd3fd54cf1:function(t){let e=o(t).entries();return p(e)},__wbg_error_6651fee1c71e5da9:function(t){console.error(o(t));},__wbg_error_a6fa202b58aa1cd3:function(t,e){let _,r;try{_=t,r=e,console.error(v(t,e));}finally{n.__wbindgen_export4(_,r,1);}},__wbg_fetch_074561c3e313c86f:function(t){let e=fetch(o(t));return p(e)},__wbg_fetch_22858a12fcf93152:function(t,e){let _=o(t).fetch(o(e));return p(_)},__wbg_fetch_9dad4fe911207b37:function(t){let e=fetch(o(t));return p(e)},__wbg_fetch_c374c6d9532750f2:function(t,e){let _=o(t).fetch(o(e));return p(_)},__wbg_getRandomValues_76dfc69825c9c552:function(){return x(function(t,e){globalThis.crypto.getRandomValues(F(t,e));},arguments)},__wbg_getRandomValues_c44a50d8cfdaebeb:function(){return x(function(t,e){o(t).getRandomValues(o(e));},arguments)},__wbg_getReader_0cd37e95fbf00f7f:function(t){let e=o(t).getReader();return p(e)},__wbg_getReader_9facd4f899beac89:function(){return x(function(t){let e=o(t).getReader();return p(e)},arguments)},__wbg_get_44e98e27bda25b5b:function(){return x(function(t,e){let _=Reflect.get(o(t),o(e));return p(_)},arguments)},__wbg_get_4b90d6d8c5deb5d5:function(t,e){let _=o(t)[e>>>0];return p(_)},__wbg_get_52a8a619f7b88df6:function(){return x(function(t,e){let _=Reflect.get(o(t),o(e));return p(_)},arguments)},__wbg_get_a82defe8d6b5b2e5:function(){return x(function(t,e,_,r){let i=o(e).get(v(_,r));var b=f(i)?0:a(i,n.__wbindgen_export,n.__wbindgen_export2),w=s;d().setInt32(t+4,w,true),d().setInt32(t+0,b,true);},arguments)},__wbg_get_done_c21b9933fc9a9e9c:function(t){let e=o(t).done;return f(e)?16777215:e?1:0},__wbg_get_value_ad568c7d3db9073f:function(t){let e=o(t).value;return p(e)},__wbg_get_with_ref_key_6412cf3094599694:function(t,e){let _=o(t)[o(e)];return p(_)},__wbg_has_14676d88c1340d2c:function(){return x(function(t,e){return Reflect.has(o(t),o(e))},arguments)},__wbg_headers_5b19cf40627ae54d:function(t){let e=o(t).headers;return p(e)},__wbg_info_a2b5f8a5dae8b26c:function(t){console.info(o(t));},__wbg_instanceof_ArrayBuffer_a581da923203f29f:function(t){let e;try{e=o(t)instanceof ArrayBuffer;}catch{e=false;}return e},__wbg_instanceof_Blob_5c4e145be35f9b1e:function(t){let e;try{e=o(t)instanceof Blob;}catch{e=false;}return e},__wbg_instanceof_ReadableStreamDefaultReader_2ab4b6bb85f96463:function(t){let e;try{e=o(t)instanceof ReadableStreamDefaultReader;}catch{e=false;}return e},__wbg_instanceof_Response_36a65a969abaa7c6:function(t){let e;try{e=o(t)instanceof Response;}catch{e=false;}return e},__wbg_instanceof_Uint8Array_b6fe1ac89eba107e:function(t){let e;try{e=o(t)instanceof Uint8Array;}catch{e=false;}return e},__wbg_instanceof_Window_9e0fe7d3d1ff4342:function(t){let e;try{e=o(t)instanceof Window;}catch{e=false;}return e},__wbg_isArray_139f48e3c057ede8:function(t){return Array.isArray(o(t))},__wbg_iterator_9b36cebf3be7b7cd:function(){return p(Symbol.iterator)},__wbg_length_68a9d5278d084f4f:function(t){return o(t).length},__wbg_log_6614a4effdb4e983:function(t){console.log(o(t));},__wbg_message_12958526424a887b:function(t,e){let _=o(e).message,r=a(_,n.__wbindgen_export,n.__wbindgen_export2),i=s;d().setInt32(t+4,i,true),d().setInt32(t+0,r,true);},__wbg_msCrypto_bd5a034af96bcba6:function(t){let e=o(t).msCrypto;return p(e)},__wbg_new_0_878c6ec3a1c600f3:function(){return p(new Date)},__wbg_new_0b303268aa395a38:function(){let t=new Array;return p(t)},__wbg_new_189262ff31890c23:function(){return x(function(){let t=new Headers;return p(t)},arguments)},__wbg_new_20b778a4c5c691c3:function(){let t=new Object;return p(t)},__wbg_new_227d7c05414eb861:function(){let t=new Error;return p(t)},__wbg_new_24739629d416f982:function(){return x(function(){let t=new AbortController;return p(t)},arguments)},__wbg_new_5fae30e6b23db8df:function(t,e){let _=new Error(v(t,e));return p(_)},__wbg_new_883c0db065f06efd:function(){return p(new Map)},__wbg_new_a21cf41c5c809e4c:function(t){let e=new Date(o(t));return p(e)},__wbg_new_a3e5112401a82338:function(){return x(function(t,e){let _=new WebSocket(v(t,e));return p(_)},arguments)},__wbg_new_b06772b280cc6e52:function(t){let e=new Uint8Array(o(t));return p(e)},__wbg_new_from_slice_bb2d1778c0b87eb1:function(t,e){let _=new Uint8Array(F(t,e));return p(_)},__wbg_new_typed_90c3f6c29ba36d19:function(t,e){try{var _={a:t,b:e},r=(b,w)=>{let g=_.a;_.a=0;try{return It(g,_.b,b,w)}finally{_.a=g;}};let i=new Promise(r);return p(i)}finally{_.a=0;}},__wbg_new_with_byte_offset_and_length_9e1e664fe1a5d385:function(t,e,_){let r=new Uint8Array(o(t),e>>>0,_>>>0);return p(r)},__wbg_new_with_configuration_3a96aa953ca17197:function(){return x(function(t){let e=new RTCPeerConnection(o(t));return p(e)},arguments)},__wbg_new_with_event_init_dict_bd850674488710b1:function(){return x(function(t,e,_){let r=new CustomEvent(v(t,e),o(_));return p(r)},arguments)},__wbg_new_with_into_underlying_sink_2596343f9b6c8e58:function(t){let e=new WritableStream(B.__wrap(t));return p(e)},__wbg_new_with_into_underlying_source_fd904252f385f59c:function(t,e){let _=new ReadableStream(N.__wrap(t),u(e));return p(_)},__wbg_new_with_length_4b57a7a5dc67221c:function(t){let e=new Uint8Array(t>>>0);return p(e)},__wbg_new_with_str_and_init_df876572184fe639:function(){return x(function(t,e,_){let r=new Request(v(t,e),o(_));return p(r)},arguments)},__wbg_new_with_str_sequence_505a4829cc247e79:function(){return x(function(t,e,_){let r=new WebSocket(v(t,e),o(_));return p(r)},arguments)},__wbg_next_8cb028b6ba50743f:function(){return x(function(t){let e=o(t).next();return p(e)},arguments)},__wbg_next_cfd0b146c9538df8:function(t){let e=o(t).next;return p(e)},__wbg_node_84ea875411254db1:function(t){let e=o(t).node;return p(e)},__wbg_now_bce4dc999095ea77:function(){return Date.now()},__wbg_now_e7c6795a7f81e10f:function(t){return o(t).now()},__wbg_ok_2279b99c57bfdfba:function(t){return o(t).ok},__wbg_parse_a5c06e19bc1187fd:function(t,e){return Date.parse(v(t,e))},__wbg_peerunistream_new:function(t){let e=q.__wrap(t);return p(e)},__wbg_performance_3fcf6e32a7e1ed0a:function(t){let e=o(t).performance;return p(e)},__wbg_process_44c7a14e11e9f69e:function(t){let e=o(t).process;return p(e)},__wbg_protocol_28aaef5ea42981d6:function(t,e){let _=o(e).protocol,r=a(_,n.__wbindgen_export,n.__wbindgen_export2),i=s;d().setInt32(t+4,i,true),d().setInt32(t+0,r,true);},__wbg_prototypesetcall_956c7493c68e29b4:function(t,e,_){Uint8Array.prototype.set.call(F(t,e),o(_));},__wbg_push_ceb8ef046afb2041:function(t,e){return o(t).push(o(e))},__wbg_queueMicrotask_4698f900840e3286:function(t){queueMicrotask(o(t));},__wbg_queueMicrotask_477a5533c7100338:function(t){let e=o(t).queueMicrotask;return p(e)},__wbg_randomFillSync_6c25eac9869eb53c:function(){return x(function(t,e){o(t).randomFillSync(u(e));},arguments)},__wbg_read_8426c146431f2905:function(t){let e=o(t).read();return p(e)},__wbg_readyState_25243ad6ce649774:function(t){return o(t).readyState},__wbg_reason_4ec455bac79b33ce:function(t,e){let _=o(e).reason,r=a(_,n.__wbindgen_export,n.__wbindgen_export2),i=s;d().setInt32(t+4,i,true),d().setInt32(t+0,r,true);},__wbg_releaseLock_188846ef719acb10:function(t){o(t).releaseLock();},__wbg_removeEventListener_016c1d24523b4730:function(){return x(function(t,e,_,r){o(t).removeEventListener(v(e,_),o(r));},arguments)},__wbg_require_b4edbdcf3e2a1ef0:function(){return x(function(){let t=module.require;return p(t)},arguments)},__wbg_resolve_0183de2e8c6b1d54:function(t){let e=Promise.resolve(o(t));return p(e)},__wbg_respond_3cdb4cf32683fd79:function(){return x(function(t,e){o(t).respond(e>>>0);},arguments)},__wbg_send_99d049cae69c53cc:function(){return x(function(t,e,_){o(t).send(F(e,_));},arguments)},__wbg_send_bac9d3dc4f21ef28:function(){return x(function(t,e,_){o(t).send(v(e,_));},arguments)},__wbg_setTimeout_3a808dd861dd3c12:function(t,e){let _=setTimeout(o(t),e);return p(_)},__wbg_setTimeout_6613a51400c1bf9f:function(){return x(function(t,e,_){let r=o(t).setTimeout(u(e),_);return p(r)},arguments)},__wbg_setTimeout_ef24d2fc3ad97385:function(){return x(function(t,e){let _=setTimeout(o(t),e);return p(_)},arguments)},__wbg_setTimeout_f757f00851f76c42:function(t,e){let _=setTimeout(o(t),e);return p(_)},__wbg_set_3ab3dfede3bae139:function(){return x(function(t,e,_,r,i){o(t).set(v(e,_),v(r,i));},arguments)},__wbg_set_5f806304fb633ab3:function(t,e,_){let r=o(t).set(o(e),o(_));return p(r)},__wbg_set_6be42768c690e380:function(t,e,_){o(t)[u(e)]=u(_);},__wbg_set_86698c227e5b9dad:function(t,e,_){o(t).set(F(e,_));},__wbg_set_a6ba3ac0e634b822:function(){return x(function(t,e,_){return Reflect.set(o(t),o(e),o(_))},arguments)},__wbg_set_binaryType_8c2dd2cf1cfc2e28:function(t,e){o(t).binaryType=Rt[e];},__wbg_set_body_d1153b16a2b95ca1:function(t,e){o(t).body=o(e);},__wbg_set_cache_5a01a8b5e6ca6cf2:function(t,e){o(t).cache=St[e];},__wbg_set_credentials_e9120ed88b1fc0b8:function(t,e){o(t).credentials=Ft[e];},__wbg_set_da33c120a6584674:function(t,e,_){o(t)[e>>>0]=u(_);},__wbg_set_detail_c7af5edea934390b:function(t,e){o(t).detail=o(e);},__wbg_set_handle_event_6147c38b782c7b42:function(t,e){o(t).handleEvent=o(e);},__wbg_set_headers_877ed41890d28af2:function(t,e){o(t).headers=o(e);},__wbg_set_high_water_mark_77da20c49668427d:function(t,e){o(t).highWaterMark=e;},__wbg_set_method_b4ede299b2064f37:function(t,e,_){o(t).method=v(e,_);},__wbg_set_mode_d6c2e1991aa963c6:function(t,e){o(t).mode=Et[e];},__wbg_set_onclose_9cb5c3372e16c192:function(t,e){o(t).onclose=o(e);},__wbg_set_onerror_190fe67e911ebf28:function(t,e){o(t).onerror=o(e);},__wbg_set_onmessage_96337495f0bfb796:function(t,e){o(t).onmessage=o(e);},__wbg_set_onopen_3e2bf6b11d434c2d:function(t,e){o(t).onopen=o(e);},__wbg_set_signal_9022b5aa06a6ce5b:function(t,e){o(t).signal=o(e);},__wbg_signal_41dd1a8913cd0b7d:function(t){let e=o(t).signal;return p(e)},__wbg_stack_3b0d974bbf31e44f:function(t,e){let _=o(e).stack,r=a(_,n.__wbindgen_export,n.__wbindgen_export2),i=s;d().setInt32(t+4,i,true),d().setInt32(t+0,r,true);},__wbg_static_accessor_GLOBAL_60a4124bab7dcc9a:function(){let t=typeof global>"u"?null:global;return f(t)?0:p(t)},__wbg_static_accessor_GLOBAL_THIS_95ca6460658b5d13:function(){let t=typeof globalThis>"u"?null:globalThis;return f(t)?0:p(t)},__wbg_static_accessor_SELF_4c95f759a91e9aae:function(){let t=typeof self>"u"?null:self;return f(t)?0:p(t)},__wbg_static_accessor_WINDOW_44b435597f9e9ee7:function(){let t=typeof window>"u"?null:window;return f(t)?0:p(t)},__wbg_status_9e6505cfa3e73a7c:function(t){return o(t).status},__wbg_stringify_a42c95ea9a7591c9:function(){return x(function(t){let e=JSON.stringify(o(t));return p(e)},arguments)},__wbg_subarray_42216645a367cd7a:function(t,e,_){let r=o(t).subarray(e>>>0,_>>>0);return p(r)},__wbg_text_d0039cf442b19ec4:function(){return x(function(t){let e=o(t).text();return p(e)},arguments)},__wbg_then_254bab9b266a77a5:function(t,e,_){let r=o(t).then(o(e),o(_));return p(r)},__wbg_then_3ea18602c6a5123b:function(t,e){let _=o(t).then(o(e));return p(_)},__wbg_toISOString_1c29c14154d57c76:function(t){let e=o(t).toISOString();return p(e)},__wbg_url_72c67c175685a054:function(t,e){let _=o(e).url,r=a(_,n.__wbindgen_export,n.__wbindgen_export2),i=s;d().setInt32(t+4,i,true),d().setInt32(t+0,r,true);},__wbg_url_d0b8042af0d1bbba:function(t,e){let _=o(e).url,r=a(_,n.__wbindgen_export,n.__wbindgen_export2),i=s;d().setInt32(t+4,i,true),d().setInt32(t+0,r,true);},__wbg_value_3d3defe09fb1ffca:function(t){let e=o(t).value;return p(e)},__wbg_versions_276b2795b1c6a219:function(t){let e=o(t).versions;return p(e)},__wbg_view_15fa5865c6b336e3:function(t){let e=o(t).view;return f(e)?0:p(e)},__wbg_warn_633bacc13ba7e6c3:function(t){console.warn(o(t));},__wbg_wasClean_f17429d064911939:function(t){return o(t).wasClean},__wbindgen_cast_0000000000000001:function(t,e){let _=A(t,e,yt);return p(_)},__wbindgen_cast_0000000000000002:function(t,e){let _=A(t,e,kt);return p(_)},__wbindgen_cast_0000000000000003:function(t,e){let _=A(t,e,ht);return p(_)},__wbindgen_cast_0000000000000004:function(t,e){let _=A(t,e,vt);return p(_)},__wbindgen_cast_0000000000000005:function(t,e){let _=A(t,e,dt);return p(_)},__wbindgen_cast_0000000000000006:function(t,e){let _=A(t,e,ft);return p(_)},__wbindgen_cast_0000000000000007:function(t,e){let _=A(t,e,lt);return p(_)},__wbindgen_cast_0000000000000008:function(t,e){let _=jt(t,e,mt);return p(_)},__wbindgen_cast_0000000000000009:function(t,e){let _=A(t,e,xt);return p(_)},__wbindgen_cast_000000000000000a:function(t){return p(t)},__wbindgen_cast_000000000000000b:function(t){return p(t)},__wbindgen_cast_000000000000000c:function(t,e){let _=F(t,e);return p(_)},__wbindgen_cast_000000000000000d:function(t,e){let _=v(t,e);return p(_)},__wbindgen_cast_000000000000000e:function(t){let e=BigInt.asUintN(64,t);return p(e)},__wbindgen_cast_000000000000000f:function(t,e){var _=F(t,e).slice();return n.__wbindgen_export4(t,e*1,1),p(_)},__wbindgen_object_clone_ref:function(t){let e=o(t);return p(e)},__wbindgen_object_drop_ref:function(t){u(t);}}}}function dt(c,t){n.__wasm_bindgen_func_elem_5312(c,t);}function ft(c,t){n.__wasm_bindgen_func_elem_9736(c,t);}function lt(c,t){n.__wasm_bindgen_func_elem_10866(c,t);}function mt(c,t){n.__wasm_bindgen_func_elem_10941(c,t);}function xt(c,t){n.__wasm_bindgen_func_elem_18514(c,t);}function yt(c,t,e){n.__wasm_bindgen_func_elem_9938(c,t,p(e));}function ht(c,t,e){n.__wasm_bindgen_func_elem_7414(c,t,p(e));}function vt(c,t,e){n.__wasm_bindgen_func_elem_11580(c,t,p(e));}function kt(c,t,e){try{let i=n.__wbindgen_add_to_stack_pointer(-16);n.__wasm_bindgen_func_elem_18660(i,c,t,p(e));var _=d().getInt32(i+0,!0),r=d().getInt32(i+4,!0);if(r)throw u(_)}finally{n.__wbindgen_add_to_stack_pointer(16);}}function It(c,t,e,_){n.__wasm_bindgen_func_elem_18662(c,t,p(e),p(_));}var Rt=["blob","arraybuffer"],St=["default","no-store","reload","no-cache","force-cache","only-if-cached"],Ft=["omit","same-origin","include"],Et=["same-origin","no-cors","cors","navigate"],tt=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(c=>n.__wbg_bistream_free(c,1));typeof FinalizationRegistry>"u"?{}:new FinalizationRegistry(c=>n.__wbg_intounderlyingbytesource_free(c,1));var et=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(c=>n.__wbg_intounderlyingsink_free(c,1)),nt=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(c=>n.__wbg_intounderlyingsource_free(c,1)),_t=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(c=>n.__wbg_peerunistream_free(c,1)),H=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(c=>n.__wbg_wasmclient_free(c,1));typeof FinalizationRegistry>"u"?{}:new FinalizationRegistry(c=>n.__wbg_wasmconnection_free(c,1));function p(c){W===R.length&&R.push(R.length+1);let t=W;return W=R[t],R[t]=c,t}var G=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(c=>n.__wbindgen_export5(c.a,c.b));function K(c){let t=typeof c;if(t=="number"||t=="boolean"||c==null)return `${c}`;if(t=="string")return `"${c}"`;if(t=="symbol"){let r=c.description;return r==null?"Symbol":`Symbol(${r})`}if(t=="function"){let r=c.name;return typeof r=="string"&&r.length>0?`Function(${r})`:"Function"}if(Array.isArray(c)){let r=c.length,i="[";r>0&&(i+=K(c[0]));for(let b=1;b<r;b++)i+=", "+K(c[b]);return i+="]",i}let e=/\[object ([^\]]+)\]/.exec(toString.call(c)),_;if(e&&e.length>1)_=e[1];else return toString.call(c);if(_=="Object")try{return "Object("+JSON.stringify(c)+")"}catch{return "Object"}return c instanceof Error?`${c.name}: ${c.message}
|
|
2
2
|
${c.stack}`:_}function Ot(c){c<1028||(R[c]=W,W=c);}function Ct(c,t){c=c>>>0;let e=d(),_=[];for(let r=c;r<c+4*t;r+=4)_.push(u(e.getUint32(r,true)));return _}function F(c,t){return c=c>>>0,T().subarray(c/1,c/1+t)}var E=null;function d(){return (E===null||E.buffer.detached===true||E.buffer.detached===void 0&&E.buffer!==n.memory.buffer)&&(E=new DataView(n.memory.buffer)),E}function v(c,t){return Mt(c>>>0,t)}var j=null;function T(){return (j===null||j.byteLength===0)&&(j=new Uint8Array(n.memory.buffer)),j}function o(c){return R[c]}function x(c,t){try{return c.apply(this,t)}catch(e){n.__wbindgen_export3(p(e));}}var R=new Array(1024).fill(void 0);R.push(void 0,null,true,false);var W=R.length;function f(c){return c==null}function jt(c,t,e){let _={a:c,b:t,cnt:1},r=(...i)=>{_.cnt++;try{return e(_.a,_.b,...i)}finally{r._wbg_cb_unref();}};return r._wbg_cb_unref=()=>{--_.cnt===0&&(n.__wbindgen_export5(_.a,_.b),_.a=0,G.unregister(_));},G.register(r,_,_),r}function A(c,t,e){let _={a:c,b:t,cnt:1},r=(...i)=>{_.cnt++;let b=_.a;_.a=0;try{return e(b,_.b,...i)}finally{_.a=b,r._wbg_cb_unref();}};return r._wbg_cb_unref=()=>{--_.cnt===0&&(n.__wbindgen_export5(_.a,_.b),_.a=0,G.unregister(_));},G.register(r,_,_),r}function L(c,t){let e=t(c.length*1,1)>>>0;return T().set(c,e/1),s=c.length,e}function ot(c,t){let e=t(c.length*4,4)>>>0,_=d();for(let r=0;r<c.length;r++)_.setUint32(e+4*r,p(c[r]),true);return s=c.length,e}function a(c,t,e){if(e===void 0){let w=M.encode(c),g=t(w.length,1)>>>0;return T().subarray(g,g+w.length).set(w),s=w.length,g}let _=c.length,r=t(_,1)>>>0,i=T(),b=0;for(;b<_;b++){let w=c.charCodeAt(b);if(w>127)break;i[r+b]=w;}if(b!==_){b!==0&&(c=c.slice(b)),r=e(r,_,_=b+c.length*3,1)>>>0;let w=T().subarray(r+b,r+_),g=M.encodeInto(c,w);b+=g.written,r=e(r,_,b,1)>>>0;}return s=b,r}function u(c){let t=o(c);return Ot(c),t}var D=new TextDecoder("utf-8",{ignoreBOM:true,fatal:true});D.decode();var Wt=2146435072,J=0;function Mt(c,t){return J+=t,J>=Wt&&(D=new TextDecoder("utf-8",{ignoreBOM:true,fatal:true}),D.decode(),J=t),D.decode(T().subarray(c,c+t))}var M=new TextEncoder;"encodeInto"in M||(M.encodeInto=function(c,t){let e=M.encode(c);return t.set(e),{read:c.length,written:e.length}});var s=0,n;function Nt(c,t){return n=c.exports,E=null,j=null,n.__wbindgen_start(),n}async function qt(c,t){if(typeof Response=="function"&&c instanceof Response){if(typeof WebAssembly.instantiateStreaming=="function")try{return await WebAssembly.instantiateStreaming(c,t)}catch(r){if(c.ok&&e(c.type)&&c.headers.get("Content-Type")!=="application/wasm")console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n",r);else throw r}let _=await c.arrayBuffer();return await WebAssembly.instantiate(_,t)}else {let _=await WebAssembly.instantiate(c,t);return _ instanceof WebAssembly.Instance?{instance:_,module:c}:_}function e(_){switch(_){case "basic":case "cors":case "default":return true}return false}}async function st(c){if(n!==void 0)return n;c!==void 0&&(Object.getPrototypeOf(c)===Object.prototype?{module_or_path:c}=c:console.warn("using deprecated parameters for the initialization function; pass a single object instead")),c===void 0&&(c=new URL("openrtc_bg.wasm",import.meta.url));let t=gt();(typeof c=="string"||typeof Request=="function"&&c instanceof Request||typeof URL=="function"&&c instanceof URL)&&(c=fetch(c));let{instance:e,module:_}=await qt(await c,t);return Nt(e)}a$1(async()=>({initWasm:st,WasmClient:O,start:it}));function $t(c){let t=s$1(c);return A$1(t,new a$2(t))}function Ht(c,t){let e=s$1(c);return A$1(e,new h({...e,bridge:t}))}export{$t as a,Ht as b};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import {G,F}from'./chunk-JGBEYISL.js';var n=class extends G{constructor(e){super(new F(e));}setWasmClient(e){this.unwrap().setWasmClient(e);}};export{n as a};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {x,G,D as D$1,F,B,d,q as q$1,c,p,s,t as t$1,u as u$1,v,w}from'./chunk-HXTGHALT.js';import {x as x$1,u,a,g as g$1,t,E,G as G$1}from'./chunk-YFNRKQEA.js';function ie(p){let e=String(p?.message??p??"").toLowerCase();return e?e.includes("__tauri_internals__")||e.includes("window is not defined")||e.includes("cannot read properties of undefined")?"runtime-unavailable":e.includes("timeout after")?"timeout":e.includes("not found")||e.includes("not allowed")||e.includes("unknown command")||e.includes("plugin not found")||e.includes("plugin:openrtc-tauri-plugin")||e.includes("plugin:openrtc")?"command-unavailable":"unknown":"unknown"}function L(p){return ie(p)==="command-unavailable"}function T(p,e="native runtime"){if(!p||typeof p!="object")throw new Error(`[openrtc] ${e} requires a valid IPC bridge object.`);if(typeof p.invoke!="function")throw new Error(`[openrtc] ${e} IPC bridge is missing invoke(command, args).`);if(typeof p.listen!="function")throw new Error(`[openrtc] ${e} IPC bridge is missing listen(event, handler).`);return p}var q=null;async function ne(){return q||(q=(async()=>{let p="openrtc-tauri",e="../../../tauri/src/runtime/ipc";try{return await import(p)}catch(t){try{return await import(e)}catch(i){let n=new Error("[openrtc] Native support now lives in the first-party `openrtc-tauri` package. Install `openrtc-tauri` (and `@tauri-apps/api`) or pass an explicit IPC bridge to OpenRTC.native(...).");throw n.cause={packageError:t,workspaceError:i},n}}})()),q}function Q(){let p=null,e=async()=>(p||(p=ne().then(t=>T(t.createTauriIpcBridge(),"openrtc-tauri"))),p);return {async invoke(t,i){return (await e()).invoke(t,i)},async listen(t,i){return (await e()).listen(t,i)},async isAvailable(){try{let t=await e();return typeof t.isAvailable=="function"?!!await t.isAvailable():!0}catch{return false}}}}var ae="relay-only endpoint ticket unavailable",re=12e3,se=250,oe=1500;function ce(p){return String(p?.message??p??"").toLowerCase().includes(ae)}async function O(p,e={}){let t=e.windowMs??re,i=e.minDelayMs??se,n=e.maxDelayMs??oe,a=Date.now(),o=0,r=null;for(;e.isActive?.()??true;){o+=1;try{return await p()}catch(c){if(r=c,!ce(c))throw c;let l=Date.now()-a;if(l>=t)throw c;let s=Math.min(x$1(o,i,n),Math.max(0,t-l));s>0&&await u(s);}}throw r||new Error("endpoint ticket minting stopped before a ticket was available")}function Z(p){let e=p?.split(".")[1];if(!e)return null;try{let t=e.replace(/-/g,"+").replace(/_/g,"/"),i=(4-t.length%4)%4,n=atob(t+"=".repeat(i)),a=JSON.parse(n);return a&&typeof a=="object"&&!Array.isArray(a)?a:null}catch{return null}}function X(p,e){let t=p?.[e];return typeof t=="string"&&t.trim()?t.trim():null}function ee(p,e){return X(p,"namespaceId")===e||X(p,"appTag")===`space::${e}`}var g=class g{constructor(e){this.subscriptionNonce=0;this.lastSyncedAuthToken=null;this.cachedLocalDeviceId=null;this.cachedLocalDeviceName=null;this.tauriCoreAvailability=null;this.tauriCoreAvailabilityValue=null;this.tauriCoreAvailabilityCheckedAtMs=0;this.authSyncInFlight=null;this.nativeRuntimeCapabilitiesSyncInFlight=null;this.gatewayDesiredPeersCleanup=null;this.gatewayDesiredPeerRevision=0;this.gatewayDesiredPeerSubmission=Promise.resolve();this.lastNativeAuthSyncAtMs=0;this.hasLoggedMissingAuthForDevices=false;this.runtimeCapabilities=D$1(null,false);this.fallback=new F({...e,coordinationPlatformType:"desktop"}),this.app=this.fallback.app,this.auth=this.fallback.auth,this.appTag=this.fallback.tag,this.options=this.fallback.getResolvedOptions(),this.transportOptions=e.transports,this.strictMode=e.strictMode===true,this.turnCredentialsProvider=e.turnCredentialsProvider,this.allowWasmFallback=e.allowWasmFallback??false,this.ipcBridge=T(e.ipcBridge??Q(),"NativeIpcBridge"),this.runtimeCapabilities=D$1(null,this.allowWasmFallback),this.syncNativeRuntimeCapabilities("constructor");}get currentUser(){return this.fallback.currentUser}get tag(){return this.fallback.tag}getRuntimeCapabilities(){let e=B(this.runtimeCapabilities);return e.fallback.wasm=this.allowWasmFallback,e}usesCoordinationGateway(){return this.fallback.usesCoordinationGateway()}async joinCoordinationRoom(e,t,i){await this.syncCoordinationDeviceIdentity(),await this.fallback.joinCoordinationRoom(e,t,i);}leaveCoordinationRoom(e){return this.fallback.leaveCoordinationRoom(e)}getCoordinationRoomMembers(e){return this.fallback.getCoordinationRoomMembers(e)}watchCoordinationRoomMembers(e,t){return this.fallback.watchCoordinationRoomMembers(e,t)}async syncCoordinationDeviceIdentity(){if(!this.usesCoordinationGateway())return;let e=await this.resolveLocalDeviceId();this.fallback.setCoordinationLocalDeviceId(e);}setWasmClient(e){if(!this.allowWasmFallback){let t="[NativeIpcBridge][NATIVE-GUARD] Refusing WasmClient attachment because native IPC is authoritative and WASM fallback is disabled.";throw console.error(t,{capabilities:this.getRuntimeCapabilities()}),new Error(t)}this.fallback.setWasmClient(e);}onAuthChange(e){return this.fallback.onAuthChange(e)}checkForSSOToken(){return this.fallback.checkForSSOToken()}waitForAuth(){return this.fallback.waitForAuth()}signInAnonymously(){return this.fallback.signInAnonymously()}getTurnCredentials(){return this.fallback.getTurnCredentials()}cleanupStaleDevices(){return this.fallback.cleanupStaleDevices()}sendMessage(e,t,i,n){return this.fallback.sendMessage(e,t,i,n)}pollMessages(e){return this.fallback.pollMessages(e)}createSession(e){return this.fallback.createSession(e)}updateSession(e,t){return this.fallback.updateSession(e,t)}async openPeerBi(e,t){return await this.canUseTauriIpc()?this.openPeerBiViaIpc("open_peer_bi_stream",{peerId:e,timeoutMs:t??null}):this.fallback.openPeerBi(e,t)}async openPeerBiTransportOnly(e,t){return await this.canUseTauriIpc()?this.openPeerBiViaIpc("open_peer_bi_transport_only_stream",{peerId:e,timeoutMs:t??null},{fallbackCommand:"open_peer_bi_stream"}):this.fallback.openPeerBiTransportOnly(e,t)}async openPeerNativeBi(e,t,i){return await this.canUseTauriIpc()?this.openPeerBiViaIpc("open_peer_native_bi_stream",{peerId:e,label:t,timeoutMs:i??null},{fallbackCommand:"open_peer_bi_stream",fallbackArgs:{peerId:e,timeoutMs:i??null}}):this.fallback.openPeerNativeBi(e,t,i)}async incoming_streams(){if(!await this.canUseTauriIpc()){let a=this.fallback;if(typeof a.incoming_streams=="function")return a.incoming_streams();throw new Error("Native incoming stream bridge is unavailable")}let e=`native-incoming-${Date.now()}-${++this.subscriptionNonce}`,t=null,i=false,n=async()=>{i=true;let a=t;t=null,await Promise.allSettled([a?Promise.resolve(a()):Promise.resolve(),this.invokeIpc("stop_rtc_subscription",{requestId:e},{timeoutMs:null}).catch(()=>{})]);};return new ReadableStream({start:async a=>{try{t=await this.listenIpc("openrtc://peer-bi-stream/incoming",o=>{if(i)return;let r=o.payload,c=typeof r?.requestId=="string"?r.requestId:typeof r?.request_id=="string"?r.request_id:"";if(c!==e){d("[NativeIpcBridge][incoming-application-stream] ignored request id",{expectedRequestId:e,eventRequestId:c});return}let l=typeof r?.streamId=="string"?r.streamId.trim():typeof r?.stream_id=="string"?r.stream_id.trim():"";if(!l)return;let s=typeof r?.remoteNodeId=="string"?r.remoteNodeId.trim():typeof r?.remote_node_id=="string"?r.remote_node_id.trim():"",u=Number.isSafeInteger(r?.transportStableId)?Number(r.transportStableId):Number.isSafeInteger(r?.transport_stable_id)?Number(r.transport_stable_id):0;if(!s||u<=0){d("[NativeIpcBridge][incoming-application-stream] ignored invalid generation",{requestId:e,remoteNodeId:s,transportStableId:u});return}d("[NativeIpcBridge][incoming-application-stream] accepted event",{requestId:e,remoteNodeId:s,transportStableId:u});let d$1=this.peerBiStreamFromId(l,{startReadAfterListeners:!0});a.enqueue({type:"bi",stream:{send:d$1.writable,recv:d$1.readable,endpoint_id:s},endpointId:s,transportStableId:u,protocolHint:"unknown",channel:null});}),await this.invokeIpc("start_incoming_peer_bi_streams",{requestId:e},{timeoutMs:null});}catch(o){i=true,a.error(o),await n();}},cancel:async()=>{await n();}})}async is_current_transport_stable_id(e,t){if(!await this.canUseTauriIpc()){let i=this.fallback;return typeof i.is_current_transport_stable_id=="function"?i.is_current_transport_stable_id(e,t):false}return !e.trim()||t<=0n||t>BigInt(Number.MAX_SAFE_INTEGER)?false:this.invokeIpc("is_current_transport_stable_id",{endpointId:e.trim(),transportStableId:Number(t)})}openPeerUni(e,t){return this.fallback.openPeerUni(e,t)}isConnected(e){return this.fallback.isConnected(e)}getAuthContext(){return this.fallback.getAuthContext()}resolveNativeAuthScopedUserId(e){return this.currentUser?.id??this.getAuthContext()?.userId??e??null}resolveConfiguredSpaceKey(){let e=this.options.spaceKey??this.options.space;return typeof e=="string"?e.trim():""}usesAnonymousSpaceMode(){return this.options.authMode==="anonymous"&&this.resolveConfiguredSpaceKey().length>0}requiresNativeAuthToken(){return !this.usesAnonymousSpaceMode()||typeof this.options.spaceTokenProvider=="function"}async nativeAuthTokenMatchesExpectedScope(e){if(!this.usesAnonymousSpaceMode())return true;let t=typeof this.options.apiKey=="string"?this.options.apiKey.trim():"",i=this.resolveConfiguredSpaceKey();if(!t||!i)return true;let n=await a(t,i).catch(()=>null);return n?ee(Z(e),n):true}resolveNativeSignalingUserId(e){return this.usesAnonymousSpaceMode()?(typeof e=="string"?e.trim():"")||this.resolveConfiguredSpaceKey()||null:this.resolveNativeAuthScopedUserId(e)}getCurrentUserId(){return this.resolveNativeSignalingUserId(this.fallback.getCurrentUserIdForScope())}nativeAuthWaitMs(){return this.requiresNativeAuthToken()?g.AUTH_REQUIRED_WAIT_MS:0}resolveWebLogicalDeviceId(){return this.fallback.getResolvedWebLogicalDeviceId()}normalizeDevice(e,t){return this.fallback.normalizeDeviceRecord(e,t)}matchesTag(e){return this.fallback.matchesLegacyOrCurrentTag(e)}nativeRosterTagDisposition(e){let t=q$1(e);if(this.matchesTag(t))return {keep:true,classification:"match"};let i=typeof t.appTag=="string"&&t.appTag.trim().length>0?t.appTag.trim():typeof t.tag=="string"&&t.tag.trim().length>0?t.tag.trim():void 0;return i===void 0?{keep:true,classification:"untagged"}:{keep:false,classification:"foreign",foreignTag:i}}filterNativeRosterByTag(e,t){let i=new Set,n=e.filter(a=>{let o=this.nativeRosterTagDisposition(a);return !o.keep&&o.foreignTag&&i.add(o.foreignTag),o.keep});return e.length>0&&n.length===0&&i.size>0?console.warn(`[NativeIpcBridge] ${t}: dropped ALL ${e.length} native device(s) as foreign-app \u2014 this is the app-tag drift signature (empty native device list). The native Rust OpenRTC app tag does not match the SDK app tag; check that the desktop binary and the web bundle use the same VITE_PLUTO_OPENRTC_API_KEY / VITE_PLUTO_OPENRTC_APP_TAG for this environment lane.`,{sdkAppTag:this.appTag,foreignTags:Array.from(i),droppedCount:e.length}):i.size>0&&d(`[NativeIpcBridge] ${t}: filtered ${e.length-n.length} foreign-app device(s) from the native roster`,{sdkAppTag:this.appTag,foreignTags:Array.from(i)}),n}normalizeNativeIceServer(e){let t=e.urls,i=Array.isArray(t)?t.filter(n=>typeof n=="string"&&n.trim().length>0):typeof t=="string"&&t.trim().length>0?[t]:[];return i.length===0?null:{urls:i,username:typeof e.username=="string"&&e.username.trim().length>0?e.username:void 0,credential:typeof e.credential=="string"&&e.credential.trim().length>0?e.credential:void 0}}filterNativeStunServers(e){return e.map(t=>({...t,urls:t.urls.filter(i=>!i.startsWith("stun:"))})).filter(t=>t.urls.length>0)}nativeIceServerHasTurnUrl(e){return e.urls.some(t=>t.startsWith("turn:")||t.startsWith("turns:"))}async loadNativeTurnIceServers(){if(typeof this.turnCredentialsProvider!="function")return [];let e=await this.turnCredentialsProvider().catch(t=>(console.warn("[NativeIpcBridge] TURN credential provider failed:",t),null));return !e||!Array.isArray(e.iceServers)?[]:e.iceServers.map(t=>this.normalizeNativeIceServer(t)).filter(t=>!!t)}async buildNativeTransportConfigPayload(){let e=this.transportOptions;if(!e&&!this.strictMode)return null;let t=null;if(!this.strictMode&&e?.iroh&&typeof e.iroh=="object"){let l=e.iroh;l.localDiscovery===true&&(t={enabled:true,advertise:l.localDiscoveryMode!=="passive"});}let i=null;if(e?.webrtc===true||e?.webrtc&&typeof e.webrtc=="object"){let l=e.webrtc===true?null:e.webrtc,s=l?.useDefaultIceServers!==false,u=Array.isArray(l?.iceServers)&&l.iceServers.length>0?l.iceServers.map(m=>this.normalizeNativeIceServer(m)).filter(m=>!!m):s?g$1.map(m=>this.normalizeNativeIceServer(m)).filter(m=>!!m):[],d=this.strictMode||l?.privacyMode===true;(this.strictMode||l?.privacyMode===true||l?.useTurn===true)&&(u=[...u,...await this.loadNativeTurnIceServers()]),d&&(u=this.filterNativeStunServers(u));let v=u.some(m=>this.nativeIceServerHasTurnUrl(m)),f=d&&v;d&&!v&&console.warn("[NativeIpcBridge] Relay-only WebRTC requested, but no TURN servers are configured; native WebRTC override disabled");let _=l?.lanMode===true;(u.length>0||f||_||!s)&&(i={iceServers:u.length>0||!s?u:void 0,privacyMode:f,lanMode:_||void 0});}let n=null;if(e?.moq&&typeof e.moq=="object"){let l=typeof e.moq.relayUrl=="string"&&e.moq.relayUrl.trim().length>0?e.moq.relayUrl:void 0;if(l){let s=typeof e.moq.accessToken=="string"&&e.moq.accessToken.trim().length>0?e.moq.accessToken.trim():void 0;n={relayUrl:l,accessToken:s};}}let a=null;if(!this.strictMode&&(e?.ble===true||e?.ble&&typeof e.ble=="object")){let l=e.ble===true?null:e.ble,s=Number(l?.connectTimeoutMs);a={enabled:l?.enabled!==false,connectTimeoutMs:Number.isFinite(s)&&s>0?Math.round(s):void 0};}let o=this.strictMode||e?.iroh&&typeof e.iroh=="object"&&e.iroh.relayOnly===true,r=e?.iroh&&typeof e.iroh=="object"?e.iroh.relayTransportPolicy:void 0,c=this.strictMode?r??"auto":r;return !o&&!c&&!i&&!n&&!t&&!a?null:{irohRelayOnly:o||void 0,irohRelayTransportPolicy:c,irohLan:t,webrtc:i,moq:n,ble:a}}isTauriEnv(){return t()}nextConnectionEventRetryDelayMs(e){return x$1(e,g.CONNECTION_EVENT_RETRY_MIN_DELAY_MS,g.CONNECTION_EVENT_RETRY_MAX_DELAY_MS)}async clearNativeAuthRelay(e){if(await this.canUseTauriIpc())try{await this.invokeIpc("desktop_set_pluto_auth_token",{authToken:null,refreshToken:null}),this.lastSyncedAuthToken=null,this.lastNativeAuthSyncAtMs=0,d(`[NativeIpcBridge] cleared native auth relay (${e})`);}catch(t){console.warn(`[NativeIpcBridge] failed clearing native auth relay (${e}):`,t);}}async relayNativeAuthToken(e,t,i,n){if(!await this.canUseTauriIpc())return true;if(!await this.nativeAuthTokenMatchesExpectedScope(e))return d(`[NativeIpcBridge] auth sync deferred (${i}): token claims do not match configured space`),false;if(e===this.lastSyncedAuthToken)return true;try{await this.invokeIpc("desktop_set_pluto_auth_token",{authToken:e,refreshToken:t??null});}catch(a){return L(a)?console.warn(`[NativeIpcBridge] desktop auth relay unavailable (${i}); install/register openrtc-tauri-plugin and include its default permission set.`,a):console.warn(`[NativeIpcBridge] desktop auth relay failed (${i}):`,a),false}return this.lastSyncedAuthToken=e,this.lastNativeAuthSyncAtMs=Date.now(),d(`[NativeIpcBridge] auth token relayed to native runtime (${i}) user_id=${n??this.currentUser?.id??"unknown"}`),true}async relayExplicitNativeAuthContext(e){let t=this.authSyncInFlight,i=(async()=>(await t?.catch(()=>{}),this.relayNativeAuthToken(e.token,e.refreshToken,"setAuthContext",e.userId)))();this.authSyncInFlight=i;try{return await i}finally{this.authSyncInFlight===i&&(this.authSyncInFlight=null);}}applyNativeRuntimeStatus(e){this.runtimeCapabilities=D$1(e,this.allowWasmFallback);}syncNativeRuntimeCapabilities(e){return this.ipcBridge?this.nativeRuntimeCapabilitiesSyncInFlight?this.nativeRuntimeCapabilitiesSyncInFlight:(this.nativeRuntimeCapabilitiesSyncInFlight=(async()=>{try{let t=await this.invokeIpc("rtc_native_status",void 0,{timeoutMs:g.NATIVE_STATUS_IPC_TIMEOUT_MS});this.applyNativeRuntimeStatus(t),d(`[NativeIpcBridge] refreshed native runtime capabilities (${e})`);}catch(t){c("[NativeIpcBridge] native runtime capability refresh skipped",t);}})().finally(()=>{this.nativeRuntimeCapabilitiesSyncInFlight=null;}),this.nativeRuntimeCapabilitiesSyncInFlight):Promise.resolve()}async canUseTauriIpc(){if(this.ipcBridge){let e=typeof this.ipcBridge.isAvailable=="function"?!!await this.ipcBridge.isAvailable():true;return e&&this.syncNativeRuntimeCapabilities("ipc-available"),e}return typeof window>"u"?false:this.tauriCoreAvailabilityValue===true?true:this.tauriCoreAvailabilityValue===false&&Date.now()-this.tauriCoreAvailabilityCheckedAtMs<g.TAURI_IPC_NEGATIVE_CACHE_MS?false:(this.tauriCoreAvailability||(this.tauriCoreAvailability=(async()=>{try{if(this.isTauriEnv())return this.tauriCoreAvailabilityValue=!0,this.tauriCoreAvailabilityCheckedAtMs=Date.now(),this.syncNativeRuntimeCapabilities("tauri-env"),!0;try{let e=await this.invokeIpc("rtc_native_status");return this.applyNativeRuntimeStatus(e),d("[NativeIpcBridge] Resolved Tauri IPC via rtc_native_status probe"),this.tauriCoreAvailabilityValue=!0,this.tauriCoreAvailabilityCheckedAtMs=Date.now(),!0}catch(e){let t=String(e?.message??e??"");return t.includes("__TAURI_INTERNALS__")||t.includes("Cannot read properties of undefined")||t.includes("window is not defined")?(this.tauriCoreAvailabilityValue=!1,this.tauriCoreAvailabilityCheckedAtMs=Date.now(),!1):(d("[NativeIpcBridge] Tauri IPC probe reached native layer (command-level error acceptable)"),this.tauriCoreAvailabilityValue=!0,this.tauriCoreAvailabilityCheckedAtMs=Date.now(),!0)}}catch{return this.tauriCoreAvailabilityValue=false,this.tauriCoreAvailabilityCheckedAtMs=Date.now(),false}})().finally(()=>{this.tauriCoreAvailability=null;})),this.tauriCoreAvailability)}async invokeIpc(e,t,i){let n=this.ipcBridge.invoke(e,t),a=i&&Object.prototype.hasOwnProperty.call(i,"timeoutMs")?i.timeoutMs:g.DEFAULT_BOUNDED_IPC_TIMEOUT_MS;return a==null||a<=0?n:E(n,a,()=>new Error(`${e} timeout after ${a}ms`))}async listenIpc(e,t){return this.ipcBridge.listen(e,i=>{t({payload:i});})}async openPeerBiViaIpc(e,t,i){let n=await this.invokePeerBiOpen(e,t,i),a=typeof n?.streamId=="string"?n.streamId.trim():typeof n?.stream_id=="string"?n.stream_id.trim():"";if(!a)throw new Error(`${e} returned no streamId`);return this.peerBiStreamFromId(a)}peerBiStreamFromId(e,t={}){let i=this,n=null,a=null,o=false,r=null,c=null,l=async()=>{let v=[n,a];n=null,a=null,await Promise.allSettled(v.filter(f=>typeof f=="function").map(f=>Promise.resolve(f())));},s=(async()=>{n=await this.listenIpc("openrtc://peer-bi-stream/chunk",v=>{let f=v.payload;if((typeof f?.streamId=="string"?f.streamId:typeof f?.stream_id=="string"?f.stream_id:"")!==e||o||!r)return;let w=f?.bytes;w instanceof Uint8Array?r.enqueue(w):Array.isArray(w)&&r.enqueue(new Uint8Array(w));}),a=await this.listenIpc("openrtc://peer-bi-stream/closed",v=>{let f=v.payload;if((typeof f?.streamId=="string"?f.streamId:typeof f?.stream_id=="string"?f.stream_id:"")!==e||o||!r)return;o=true;let w=typeof f?.error=="string"?f.error.trim():"";w?r.error(new Error(w)):r.close(),l();}),t.startReadAfterListeners&&await this.invokeIpc("start_peer_bi_stream_read",{streamId:e},{timeoutMs:null});})().catch(v=>{c=v,r&&!o&&(o=true,r.error(v));}),u=async()=>{await this.invokeIpc("close_peer_bi_stream",{streamId:e},{timeoutMs:null}).catch(()=>{}),await l();},d=new ReadableStream({async start(v){r=v,await s,c&&!o&&(o=true,v.error(c));},async cancel(){o=true,await u();}}),y=new WritableStream({write:async v=>{await i.invokeIpc("write_peer_bi_stream",{streamId:e,bytes:Array.from(v)},{timeoutMs:null});},close:u,abort:u});return {readable:d,writable:y}}async invokePeerBiOpen(e,t,i){try{return await this.invokeIpc(e,t)}catch(n){if(!i?.fallbackCommand||!this.isMissingNativeCommandError(n))throw n;return this.invokeIpc(i.fallbackCommand,i.fallbackArgs??t)}}isMissingNativeCommandError(e){let t=e instanceof Error?e.message:String(e??"");return t.includes("Command")&&t.includes("not found")}async shouldUseTauriSignaling(){if(await this.canUseTauriIpc())return true;if(this.allowWasmFallback)return false;throw new Error("[pluto-rtc] Tauri runtime adapter requires native IPC, but it is unavailable.")}async signInWithPluto(){if(!await this.canUseTauriIpc()){await this.fallback.signInWithPluto();return}let e=await this.invokeIpc("rtc_sign_in_with_pluto"),t=typeof e?.customToken=="string"?e.customToken.trim():"";if(!t)throw new Error("[pluto-rtc] Native Pluto SSO did not return a custom token.");await G$1().signInWithCustomTokenValue(t),await this.ensureNativeAuth("pluto-sso",{requireToken:true,maxWaitMs:1e4});}async setAuthContext(e){let t=this.getAuthContext()?.userId??null,i=typeof e?.userId=="string"&&e.userId.trim()||null,n=this.fallback.setAuthContext(e);if(t&&i&&t!==i&&await this.stopNativeAuthScopedActivity(t),await n,!e?.token)await this.clearNativeAuthRelay("setAuthContext");else if(!await this.relayExplicitNativeAuthContext(e))throw new Error("Native auth token unavailable for setAuthContext")}async signOut(){await this.fallback.signOut(),await this.clearNativeAuthRelay("signOut");}async stopAuthScopedActivity(e){let t=this.resolveNativeSignalingUserId(e?.userId??null);await this.stopNativeAuthScopedActivity(t);}async stopNativeAuthScopedActivity(e){this.stopGatewayDesiredPeerRelay();let t=await this.shouldUseTauriSignaling();if(p("NativeIpcBridge.stopAuthScopedActivity",{userId:e,useTauri:t}),t)try{await Promise.allSettled([this.revokeSessionTokensByScope("user-device"),this.invokeIpc("stop_rtc_presence_loop"),this.invokeIpc("stop_rtc_auto_connect"),e&&!this.usesCoordinationGateway()?this.invokeIpc("set_rtc_offline",{userId:e}):Promise.resolve()]);}catch(i){console.warn("[NativeIpcBridge] Failed to stop native auth-scoped RTC activity:",i);}await this.fallback.stopAuthScopedActivity({userId:e});}async ensureNativeAuthOnce(e,t){if(!await this.canUseTauriIpc())return true;if(this.authSyncInFlight)return this.authSyncInFlight;let i=(async()=>{try{if(!this.currentUser)return d(`[NativeIpcBridge] auth sync deferred (${e}): no current user`),!t;let n=Date.now()-this.lastNativeAuthSyncAtMs>=480*1e3,a=this.currentUser?.getToken?await this.currentUser.getToken(n):null,r=this.getAuthContext()?.refreshToken??this.auth?.currentUser?.refreshToken??null;return a?this.relayNativeAuthToken(a,r,e,this.currentUser?.id):(d(`[NativeIpcBridge] auth sync deferred (${e}): missing token for user ${this.currentUser?.id}`),!t)}catch(n){return console.error("[NativeIpcBridge] auth sync failed:",n),false}})();this.authSyncInFlight=i;try{return await i}finally{this.authSyncInFlight===i&&(this.authSyncInFlight=null);}}async ensureNativeAuth(e="runtime",t){if(!await this.canUseTauriIpc())return true;let i=t?.requireToken??false,n=t?.maxWaitMs??(i?g.AUTH_REQUIRED_WAIT_MS:0),a=t?.pollMs??250,o=Date.now()+Math.max(0,n);for(;;){if(await this.ensureNativeAuthOnce(e,i))return true;if(!i||Date.now()>=o)return false;await u(a);}}decodeNativeDeviceIdentity(e){let t=e?.systemInfo??e?.system_info??null,i=typeof e?.deviceId=="string"?e.deviceId.trim():typeof e?.device_id=="string"?e.device_id.trim():"",n=typeof e?.deviceName=="string"?e.deviceName.trim():typeof e?.device_name=="string"?e.device_name.trim():"",a=typeof e?.platformType=="string"?e.platformType.trim():typeof e?.platform_type=="string"?e.platform_type.trim():typeof t?.platformType=="string"?t.platformType.trim():typeof t?.platform_type=="string"?t.platform_type.trim():"";return {deviceId:i,deviceName:n,platformType:a}}async resolveLocalDeviceId(){if(this.cachedLocalDeviceId)return this.cachedLocalDeviceId;if(await this.canUseTauriIpc())try{let t=await this.invokeIpc("get_rtc_local_device_info"),{deviceId:i,deviceName:n}=this.decodeNativeDeviceIdentity(t);if(i)return this.cachedLocalDeviceId=i,n&&(this.cachedLocalDeviceName=n),i}catch(t){console.warn("[NativeIpcBridge] get_rtc_local_device_info failed:",t);}let e=this.resolveWebLogicalDeviceId();return this.cachedLocalDeviceId=e,e}async resolveLocalDeviceName(){if(this.cachedLocalDeviceName)return this.cachedLocalDeviceName;if(await this.canUseTauriIpc())try{let e=await this.invokeIpc("get_rtc_local_device_info"),{deviceName:t}=this.decodeNativeDeviceIdentity(e);if(t){let i=this.normalizeNativeDeviceName(t);return this.cachedLocalDeviceName=i,i}}catch(e){console.warn("[NativeIpcBridge] get_rtc_local_device_info failed:",e);}return this.defaultDeviceNameFallback()}normalizeNativeDeviceName(e){let t=e.trim();if(!t)return this.defaultDeviceNameFallback();if(t==="Desktop Device"){let i=this.defaultDeviceNameFallback();if(i!=="Desktop Device")return i}return t}defaultDeviceNameFallback(){if(typeof window>"u"||typeof navigator>"u")return "Desktop Device";let e=navigator.userAgent||"";return /iPhone|iPad|iPod/i.test(e)?"iPhone":/Android/i.test(e)?"Android":"Desktop Device"}inferNativePlatformTypeFallback(){if(typeof window>"u"||typeof navigator>"u")return "desktop";if(!this.isTauriEnv())return "web";let e=navigator.userAgent||"";return /iPhone|iPad|iPod|Android|Mobile/i.test(e)?"mobile":"desktop"}withPresenceMetadata(e,t){try{let i=e?JSON.parse(e):{};return JSON.stringify({...i,deviceId:t,plutoVersion:"0.1.0-desktop"})}catch{return JSON.stringify({deviceId:t,plutoVersion:"0.1.0-desktop",rawMetadata:e})}}async searchDevices(e){if(this.usesCoordinationGateway())return this.fallback.searchDevices(e);if(await this.shouldUseTauriSignaling()){if(!await this.ensureNativeAuth("searchDevices",{requireToken:this.requiresNativeAuthToken(),maxWaitMs:this.nativeAuthWaitMs()}))throw new Error("Native auth token unavailable for searchDevices");let i=await this.invokeIpc("search_rtc_devices",{userId:this.getCurrentUserId()});if(Array.isArray(i?.devices)){let n=i.devices.map(a=>this.normalizeDevice(a));return e&&(n=n.filter(a=>a.ticket!==e&&a.deviceId!==e&&a.nodeId!==e)),n}throw typeof i?.message=="string"?new Error(String(i.message)):new Error("Unexpected response for search_rtc_devices")}return this.fallback.searchDevices(e)}async listDevicesWithStatus(){if(this.usesCoordinationGateway())return (await this.fallback.searchDevices()).map(e=>s(e));if(await this.shouldUseTauriSignaling()){if(!await this.ensureNativeAuth("listDevicesWithStatus",{requireToken:this.requiresNativeAuthToken(),maxWaitMs:this.nativeAuthWaitMs()}))throw new Error("Native auth token unavailable for listDevicesWithStatus");let t=await this.invokeIpc("search_rtc_devices_with_status",{userId:this.getCurrentUserId()});if(Array.isArray(t?.devices)){let i=t.devices,n=this.filterNativeRosterByTag(i,"listDevicesWithStatus").map(r=>s(r)),a=await this.resolveLocalDeviceId().catch(()=>null),o=!!a&&n.some(r=>r.deviceId===a);return c("[NativeIpcBridge] listDevicesWithStatus result",{rawCount:i.length,count:n.length,localDeviceId:a,selfIncluded:o,devices:n.map(r=>({deviceId:r.deviceId,deviceName:r.deviceName,online:!!r.online,presenceStatus:r.presenceStatus,connectable:r.connectable,connectionStatus:r.connectionStatus,settledReady:!!r.settledReady,peerHealth:r.peerHealth,scopes:r.scopes,connectionId:r.connectionId??null,deviceIdHint:r.deviceIdHint??null,nodeId:r.nodeId??null,activeTransport:r.activeTransport??null,parallelTransport:r.parallelTransport??null}))}),a&&!o&&c("[NativeIpcBridge] native status snapshot excludes local device by design",{localDeviceId:a,count:n.length}),n}throw typeof t?.message=="string"?new Error(String(t.message)):new Error("Unexpected response for search_rtc_devices_with_status")}return this.fallback.listDevicesWithStatus()}async getPeerSession(e){if(await this.shouldUseTauriSignaling()){let t=await this.invokeIpc("get_rtc_peer_session",{id:e});return !t||typeof t!="object"?null:t$1(t)}return this.fallback.getPeerSession(e)}async listPeerSessions(){if(await this.shouldUseTauriSignaling()){let e=await this.invokeIpc("list_rtc_peer_sessions");return (Array.isArray(e)?e:[]).map(t=>t$1(t))}return this.fallback.listPeerSessions()}async waitForSettledPeer(e,t){if(await this.shouldUseTauriSignaling()){let i=typeof t=="number"?Math.max(g.DEFAULT_BOUNDED_IPC_TIMEOUT_MS,t+1e3):g.DEFAULT_BOUNDED_IPC_TIMEOUT_MS,n=await this.invokeIpc("wait_for_rtc_settled_peer",{id:e,timeoutMs:t},{timeoutMs:i});return !n||typeof n!="object"?null:t$1(n)}return this.fallback.waitForSettledPeer(e,t)}async resolvePeerConnectionRecords(e){if(await this.shouldUseTauriSignaling()){let t=await this.invokeIpc("resolve_rtc_peer_connection_records",{id:e});return (Array.isArray(t)?t:[]).map(i=>u$1(i))}return this.fallback.resolvePeerConnectionRecords(e)}async resolvePeerIdentity(e){if(await this.shouldUseTauriSignaling()){let t=await this.invokeIpc("resolve_rtc_peer_identity",{id:e});return v(t)}return this.fallback.resolvePeerIdentity(e)}async setOffline(e){if(this.usesCoordinationGateway())return this.fallback.setOffline(e);if(await this.shouldUseTauriSignaling())try{if(!await this.ensureNativeAuth("setOffline",{requireToken:this.requiresNativeAuthToken(),maxWaitMs:this.nativeAuthWaitMs()}))throw new Error("Native auth token unavailable for setOffline");let i=this.getCurrentUserId();await this.invokeIpc("set_rtc_offline",{userId:i});return}catch(t){console.warn("[NativeIpcBridge] set_rtc_offline failed:",t);}return this.fallback.setOffline(e)}async updateDevice(e,t){if(this.usesCoordinationGateway())return await this.syncCoordinationDeviceIdentity(),this.fallback.updateDevice(e,t);if(await this.shouldUseTauriSignaling()){if(!await this.ensureNativeAuth("updateDevice",{requireToken:this.requiresNativeAuthToken(),maxWaitMs:this.nativeAuthWaitMs()}))throw new Error("Native auth token unavailable for updateDevice");let a=this.getCurrentUserId();if(!a)throw new Error("updateDevice requires authenticated user scope");try{await this.invokeIpc("update_rtc_device",{userId:a,deviceId:e,deviceName:t.deviceName??null,capabilities:t.capabilities??null,metadata:t.metadata??null});return}catch(o){throw console.warn("[NativeIpcBridge] update_rtc_device failed:",o),o instanceof Error?o:new Error(String(o))}}return this.fallback.updateDevice(e,t)}async deleteDevice(e){if(this.usesCoordinationGateway())return await this.syncCoordinationDeviceIdentity(),this.fallback.deleteDevice(e);if(await this.shouldUseTauriSignaling()){if(!await this.ensureNativeAuth("deleteDevice",{requireToken:this.requiresNativeAuthToken(),maxWaitMs:this.nativeAuthWaitMs()}))throw new Error("Native auth token unavailable for deleteDevice");let n=this.getCurrentUserId();if(!n)throw new Error("deleteDevice requires authenticated user scope");try{await this.invokeIpc("delete_rtc_device",{userId:n,deviceId:e});return}catch(a){throw console.warn("[NativeIpcBridge] delete_rtc_device failed:",a),a instanceof Error?a:new Error(String(a))}}return this.fallback.deleteDevice(e)}async getLocalDeviceInfo(){if(!await this.canUseTauriIpc()){let e=await this.getLocalDeviceId?.();return e?{deviceId:e,deviceName:this.defaultDeviceNameFallback(),platformType:this.inferNativePlatformTypeFallback()}:null}try{let e=await this.invokeIpc("get_rtc_local_device_info"),t=this.decodeNativeDeviceIdentity(e),{deviceId:i}=t;return i?{deviceId:i,deviceName:this.normalizeNativeDeviceName(t.deviceName),platformType:t.platformType||this.inferNativePlatformTypeFallback(),capabilities:e?.capabilities??void 0,lastSeenAt:typeof e?.last_seen_at=="string"?e.last_seen_at:void 0}:null}catch(e){return console.warn("[NativeIpcBridge] getLocalDeviceInfo failed:",e),null}}async updateLocalDeviceName(e){if(!await this.canUseTauriIpc())return null;try{let t=await this.invokeIpc("update_rtc_local_device_name",{deviceName:e}),i=this.decodeNativeDeviceIdentity(t),{deviceId:n}=i;return n?(this.cachedLocalDeviceName=this.normalizeNativeDeviceName(e),{deviceId:n,deviceName:this.cachedLocalDeviceName,platformType:i.platformType||this.inferNativePlatformTypeFallback(),capabilities:t?.capabilities??void 0,lastSeenAt:typeof t?.last_seen_at=="string"?t.last_seen_at:void 0}):null}catch(t){return console.warn("[NativeIpcBridge] updateLocalDeviceName failed:",t),null}}async startManagedSessionNative(e){if(!await this.shouldUseTauriSignaling())throw new Error("[pluto-rtc] Native IPC unavailable for startManagedSessionNative().");if(!await this.ensureNativeAuth("startManagedSessionNative",{requireToken:this.requiresNativeAuthToken(),maxWaitMs:this.nativeAuthWaitMs()}))throw new Error("Native auth token unavailable for startManagedSessionNative");let i=this.resolveNativeSignalingUserId(e.userId);if(!i)throw new Error("Native managed session startup requires a runtime auth-scoped user id.");i!==e.userId&&console.info("[NativeIpcBridge][managed-session][user-id-remap]",{requestedUserId:e.userId,runtimeUserId:this.currentUser?.id??this.getAuthContext()?.userId??null,effectiveUserId:i});let n=this.resolveConfiguredSpaceKey();console.info("[NativeIpcBridge][managed-session][start-request]",{requestedUserId:e.userId,runtimeUserId:this.currentUser?.id??this.getAuthContext()?.userId??null,effectiveUserId:i,spaceKey:n?"[configured]":null,deviceName:e.deviceName??null,localDeviceId:e.localDeviceId??null,presence:e.presence!==false,autoConnect:e.autoConnect!==false,hasMetadata:typeof e.metadata=="string"&&e.metadata.trim().length>0});let a=await this.buildNativeTransportConfigPayload(),o=this.usesCoordinationGateway(),r={userId:i,deviceName:e.deviceName??null,localDeviceId:e.localDeviceId??null,metadata:e.metadata??null,...a?{transports:a}:{},autoConnect:o?false:e.autoConnect!==false,presence:o?false:e.presence!==false,apiKey:this.options.apiKey??null,spaceKey:n||null},c=await this.invokeIpc("start_rtc_managed_session",r,{timeoutMs:null});this.syncNativeRuntimeCapabilities("managed-session-started");let l=typeof c?.ticket=="string"&&c.ticket.trim().length>0?c.ticket.trim():null,s=c?.localDevice&&typeof c.localDevice=="object"?c.localDevice:c?.local_device&&typeof c.local_device=="object"?c.local_device:null,u=s?{deviceId:typeof s.deviceId=="string"?s.deviceId:typeof s.device_id=="string"?s.device_id:"",deviceName:this.normalizeNativeDeviceName(typeof s.deviceName=="string"?s.deviceName:typeof s.device_name=="string"?s.device_name:""),platformType:typeof s.platformType=="string"?s.platformType:typeof s.platform_type=="string"?s.platform_type:"desktop",capabilities:s.capabilities??void 0,lastSeenAt:typeof s.lastSeenAt=="string"?s.lastSeenAt:typeof s.last_seen_at=="string"?s.last_seen_at:void 0}:null,d={localNodeId:typeof c?.localNodeId=="string"?c.localNodeId:typeof c?.local_node_id=="string"?c.local_node_id:null,ticket:l,ticketScope:typeof c?.ticketScope=="string"?c.ticketScope:typeof c?.ticket_scope=="string"?c.ticket_scope:null,presenceStarted:typeof c?.presenceStarted=="boolean"?c.presenceStarted:!!c?.presence_started,autoConnectStarted:typeof c?.autoConnectStarted=="boolean"?c.autoConnectStarted:!!c?.auto_connect_started,localDevice:u?.deviceId?u:null};if(o){e.presence!==false&&!d.ticket&&(d.ticket=await this.getEndpointTicketWithToken("user-device",0),d.ticketScope=d.ticket?"user-device":null);let y=d.localDevice?.deviceId||e.localDeviceId?.trim()||await this.resolveLocalDeviceId();if(y&&this.fallback.setCoordinationLocalDeviceId(y),e.presence!==false){if(!d.localNodeId||!d.ticket)throw new Error("Native managed session did not return the node identity required for gateway presence.");await this.fallback.updatePresence(d.localNodeId,d.ticket,true,3e5,e.metadata,d.localDevice?.deviceName||e.deviceName),d.presenceStarted=true;}else d.presenceStarted=false;e.autoConnect!==false&&y?(await this.startGatewayAutoConnect(i,y),d.autoConnectStarted=true):d.autoConnectStarted=false;}return console.info("[NativeIpcBridge][managed-session][ipc-started]",{requestedUserId:e.userId,runtimeUserId:this.currentUser?.id??this.getAuthContext()?.userId??null,effectiveUserId:i,localNodeId:d.localNodeId,ticketScope:d.ticketScope,presenceStarted:d.presenceStarted,autoConnectStarted:d.autoConnectStarted,localDeviceId:d.localDevice?.deviceId??null}),d}async reconcileNativeManagedSession(e){if(this.usesCoordinationGateway())return console.info("[NativeIpcBridge] native Firebase managed-session reconciliation is disabled in the staging gateway lane.",{reason:e?.reason??"frontend"}),null;if(!await this.shouldUseTauriSignaling())return null;if(!await this.ensureNativeAuth("reconcileNativeManagedSession",{requireToken:this.requiresNativeAuthToken(),maxWaitMs:this.nativeAuthWaitMs()}))throw new Error("Native auth token unavailable for reconcileNativeManagedSession");return this.invokeIpc("reconcile_mobile_rtc_after_resume",{reason:e?.reason??"frontend"})}async notifyNetworkChange(e){return await this.canUseTauriIpc()?(d("[NativeIpcBridge] forwarding host network-change hint",{reason:e?.reason??"host"}),this.invokeIpc("notify_rtc_network_change")):null}async getManagedNodeId(e){let t=e?.initializeIfMissing??true;console.info("[NativeIpcBridge][getManagedNodeId] enter",{initializeIfMissing:t});let i=await this.canUseTauriIpc();if(console.info("[NativeIpcBridge][getManagedNodeId] canUseTauriIpc",{canUse:i}),!i)return null;try{console.info("[NativeIpcBridge][getManagedNodeId] invoking get_iroh_node_id");let n=await this.invokeIpc("get_iroh_node_id");if(console.info("[NativeIpcBridge][getManagedNodeId] get_iroh_node_id returned",{existing:n}),n||!t)return n;console.info("[NativeIpcBridge][getManagedNodeId] invoking start_iroh_node");let a=await this.invokeIpc("start_iroh_node");return console.info("[NativeIpcBridge][getManagedNodeId] start_iroh_node returned",{started:a}),a}catch(n){if(console.warn("[NativeIpcBridge] getManagedNodeId failed:",n),!t)return null;throw n}}async getEndpointTicket(){if(!await this.canUseTauriIpc())throw new Error("[pluto-rtc] getEndpointTicket requires native IPC in Tauri runtime.");return O(()=>this.invokeIpc("get_iroh_endpoint_ticket"))}async connectToDevice(e){if(!await this.canUseTauriIpc())throw new Error("[pluto-rtc] connectToDevice requires native IPC in Tauri runtime.");this.options.authMode!=="anonymous"?await this.ensureNativeAuth("connectToDevice",{requireToken:true,maxWaitMs:g.AUTH_REQUIRED_WAIT_MS}):d("[NativeIpcBridge] connectToDevice using anonymous native ticket path");let t=Math.max(1,Math.floor(e.timeoutMs??g.DEFAULT_BOUNDED_IPC_TIMEOUT_MS));return this.invokeIpc("connect_to_device",{deviceId:e.deviceId??null,endpointTicket:e.endpointTicket,timeoutMs:t},{timeoutMs:t+1e3})}async registerSessionToken(e,t,i){await this.canUseTauriIpc()&&await this.invokeIpc("register_session_token",{token:e,scope:t,maxConnections:i});}async getEndpointTicketWithToken(e,t){if(!await this.canUseTauriIpc())return null;try{return await O(()=>this.invokeIpc("get_endpoint_ticket_with_token",{scope:e,maxConnections:t}))}catch{return null}}async validateSessionToken(e,t){if(!await this.canUseTauriIpc())return null;try{return await this.invokeIpc("validate_session_token",{token:e,connectionId:t??null})}catch{return null}}async revokeSessionTokensByScope(e){if(p("NativeIpcBridge.revokeSessionTokensByScope",{grantScope:e}),!await this.canUseTauriIpc())return [];try{return await this.invokeIpc("revoke_session_tokens_by_scope",{scope:e})}catch{return []}}async disconnectDevice(e){if(!await this.canUseTauriIpc())throw new Error("[pluto-rtc] disconnectDevice requires native IPC in Tauri runtime.");await this.invokeIpc("disconnect_device",{deviceId:e});}async setAutoConnectExcluded(e,t){await this.canUseTauriIpc()&&await this.invokeIpc(this.usesCoordinationGateway()?"set_rtc_external_auto_connect_excluded":"set_auto_connect_excluded",{deviceId:e,excluded:t});}onDevicesChange(e,t){if(this.usesCoordinationGateway())return this.fallback.onDevicesChange(e,t);let i=false,n=new Map,a=null,o=false,r=false,c=()=>{if(r=false,i)return;let d=Array.from(n.values());t&&(d=d.filter(y=>y.ticket!==t&&y.deviceId!==t&&y.nodeId!==t)),e(d);},l=()=>{if(!r){if(r=true,typeof queueMicrotask=="function"){queueMicrotask(c);return}Promise.resolve().then(c);}},s=async()=>{if(!await this.shouldUseTauriSignaling()){console.warn("[NativeIpcBridge] onDevicesChange falling back to wasm signaling (Tauri IPC unavailable)"),u$1=this.fallback.onDevicesChange(e,t);return}for(;!i;)try{let d$1=this.requiresNativeAuthToken()?15e3:0,y=Date.now()+d$1,v=this.getCurrentUserId();for(;!i&&!v&&Date.now()<y&&(this.hasLoggedMissingAuthForDevices||(this.hasLoggedMissingAuthForDevices=!0,d("[NativeIpcBridge] onDevicesChange waiting for authenticated user before subscription")),v=this.getCurrentUserId(),!v);)await u(250);if(!v){!i&&!o&&(console.warn("[NativeIpcBridge] onDevicesChange could not resolve authenticated user; keeping subscription in retry mode"),e([]),o=!0),await u(1e3);continue}if(!await this.ensureNativeAuth("onDevicesChange",{requireToken:this.requiresNativeAuthToken(),maxWaitMs:Math.max(0,y-Date.now())})){!i&&!o&&(console.warn("[NativeIpcBridge] onDevicesChange timed out waiting for auth token; keeping subscription in retry mode"),e([]),o=!0),await u(1e3);continue}this.hasLoggedMissingAuthForDevices=!1,o=!1,d(`[NativeIpcBridge] onDevicesChange starting subscription user_id=${v}`);let _=await this.listDevicesWithStatus().catch(async m=>(d(`[NativeIpcBridge] onDevicesChange full-roster seed failed; falling back to online-only search: ${m}`),this.searchDevices(t)));n.clear();for(let m of _)m?.deviceId&&n.set(m.deviceId,m);for(l(),a=(await this.subscribeDevices(v)).getReader();!i;){let{done:m,value:x}=await a.read();if(m||!x)break;for(let N of x){if(N.type==="removed"){n.delete(N.deviceId);continue}let M=N.device?.deviceId,R=this.nativeRosterTagDisposition(N.device??{});if(!R.keep){R.foreignTag&&d("[NativeIpcBridge] onDevicesChange dropped foreign-app device event",{sdkAppTag:this.appTag,foreignTag:R.foreignTag,deviceId:M??null}),M&&n.delete(M);continue}let E=this.normalizeDevice(N.device);E.deviceId&&n.set(E.deviceId,E);}l();}}catch(d){i||(console.error("[NativeIpcBridge] onDevicesChange stream failed; retrying subscription:",d),await u(1e3));}finally{if(a){try{await a.cancel();}catch{}a=null;}}},u$1=()=>{i=true,a&&(a.cancel(),a=null);};return s(),()=>u$1()}async subscribeDevices(e){if(this.usesCoordinationGateway())return this.fallback.subscribeDevices(e);if(await this.shouldUseTauriSignaling()){if(!await this.ensureNativeAuth("subscribeDevices",{requireToken:this.requiresNativeAuthToken(),maxWaitMs:this.nativeAuthWaitMs()}))throw new Error("Native auth token unavailable for subscribeDevices");let i=`sub-${Math.random().toString(36).substring(2,11)}`,n=null,a=null,o=false,r=async()=>{if(!o&&(o=true,n&&(await Promise.resolve(n()),n=null),a)){try{await a();}catch{}a=null;}};return new ReadableStream({start:async c$1=>{d(`[NativeIpcBridge] subscribeDevices request start user_id=${e} request_id=${i}`),n=await this.listenIpc("rtc-device-events",l=>{if(o)return;let s=l.payload;if(s.requestId===i){if(s.type==="deviceEvents"){let u=Array.isArray(s.events)?s.events.length:0;c(`[NativeIpcBridge] subscribeDevices event batch request_id=${i} count=${u}`);try{c$1.enqueue(s.events);}catch{r();}}else if(s.type==="error"&&(console.warn(`[NativeIpcBridge] subscribeDevices stream error request_id=${i}: ${s.message}`),!o)){try{c$1.error(s.message);}catch{}r();}}}),a=async()=>{await this.invokeIpc("stop_rtc_subscription",{requestId:i});};try{await this.invokeIpc("start_rtc_device_subscription",{requestId:i,userId:e});}catch(l){try{c$1.error(l);}catch{}await r();}},cancel:async()=>{d(`[NativeIpcBridge] subscribeDevices request stop request_id=${i}`),await r();}})}return this.fallback.subscribeDevices(e)}async subscribeSessions(e){if(this.usesCoordinationGateway())return this.fallback.subscribeSessions(e);if(await this.shouldUseTauriSignaling()){if(!await this.ensureNativeAuth("subscribeSessions",{requireToken:this.requiresNativeAuthToken(),maxWaitMs:this.nativeAuthWaitMs()}))throw new Error("Native auth token unavailable for subscribeSessions");let i=`sub-${Math.random().toString(36).substring(2,11)}`,n=await this.resolveLocalDeviceId()||e,a=null,o=null,r=false,c=async()=>{if(!r&&(r=true,a&&(await Promise.resolve(a()),a=null),o)){try{await o();}catch{}o=null;}};return new ReadableStream({start:async l=>{a=await this.listenIpc("rtc-session-events",s=>{if(r)return;let u=s.payload;if(u.requestId===i){if(u.type==="sessionEvents")try{l.enqueue(u.events);}catch{c();}else if(u.type==="error"&&!r){try{l.error(u.message);}catch{}c();}}}),o=async()=>{await this.invokeIpc("stop_rtc_subscription",{requestId:i});};try{await this.invokeIpc("start_rtc_session_subscription",{requestId:i,localDeviceId:n});}catch(s){try{l.error(s);}catch{}await c();}},cancel:async()=>{await c();}})}return this.fallback.subscribeSessions(e)}async getLocalDeviceId(){return this.resolveLocalDeviceId()}async updatePresence(e,t,i=true,n=3e5,a){if(this.usesCoordinationGateway())return await this.syncCoordinationDeviceIdentity(),this.fallback.updatePresence(e,t,i,n,a);if(await this.shouldUseTauriSignaling())try{if(!await this.ensureNativeAuth("updatePresence",{requireToken:this.requiresNativeAuthToken(),maxWaitMs:this.nativeAuthWaitMs()}))throw new Error("Native auth token unavailable for updatePresence");let r=this.resolveNativeSignalingUserId(),c=await this.resolveLocalDeviceId(),l=await this.resolveLocalDeviceName();await this.invokeIpc("update_rtc_presence",{userId:r,deviceName:l,ticket:t,metadata:this.withPresenceMetadata(a,c)});return}catch(o){console.warn("[NativeIpcBridge] update_rtc_presence failed:",o);}return this.fallback.updatePresence(e,t,i,n,a)}startAutoConnect(e,t){if(this.usesCoordinationGateway()){this.startGatewayAutoConnect(e,t).catch(i=>{console.warn("[NativeIpcBridge] staging gateway auto-connect failed:",i);});return}(async()=>{try{if(!await this.shouldUseTauriSignaling()){console.error("[NativeIpcBridge] startAutoConnect requires native Rust signaling; IPC unavailable");return}let i=await this.resolveLocalDeviceId()||t;await this.startAutoConnectOnce(e,i);}catch(i){console.warn("[NativeIpcBridge] startAutoConnect failed:",i);}})();}forceReconnectSnapshot(){if(this.usesCoordinationGateway()){console.info("[NativeIpcBridge] native Firebase reconnect snapshots are disabled in the staging gateway lane.");return}(async()=>{if(!await this.shouldUseTauriSignaling()){console.error("[NativeIpcBridge] forceReconnectSnapshot requires native Rust signaling; IPC unavailable");return}try{await this.invokeIpc("force_rtc_reconnect_snapshot");}catch(e){console.warn("[NativeIpcBridge] force_rtc_reconnect_snapshot failed:",e);}})();}startPresenceLoop(e,t,i,n,a){if(this.usesCoordinationGateway()){this.syncCoordinationDeviceIdentity().then(()=>this.fallback.startPresenceLoop(e,t,i,n,a));return}(async()=>{try{if(!await this.shouldUseTauriSignaling()){console.warn("[NativeIpcBridge] startPresenceLoop falling back to wasm signaling (Tauri IPC unavailable)"),this.fallback.startPresenceLoop(e,t,i,n,a);return}let o=await this.resolveLocalDeviceId(),r=this.shouldUseResolvedDeviceName(i)?await this.resolveLocalDeviceName():i.trim(),c=this.withPresenceMetadata(a,o);await this.startPresenceLoopOnce(e,t,r,n,c);}catch(o){console.warn("[NativeIpcBridge] startPresenceLoop failed:",o);}})();}async startAutoConnectOnce(e,t){if(this.usesCoordinationGateway()){await this.startGatewayAutoConnect(e,t);return}if(!await this.shouldUseTauriSignaling())throw new Error("[pluto-rtc] Native IPC unavailable for startAutoConnectOnce().");if(!await this.ensureNativeAuth("startAutoConnect",{requireToken:this.requiresNativeAuthToken(),maxWaitMs:this.nativeAuthWaitMs()}))throw new Error("Native auth token unavailable for startAutoConnect");let n=this.resolveNativeSignalingUserId(e);if(!n)throw new Error("Native auto-connect requires a runtime auth-scoped user id.");await this.invokeIpc("start_rtc_auto_connect",{userId:n,localDeviceId:t});}stopGatewayDesiredPeerRelay(){this.gatewayDesiredPeersCleanup?.(),this.gatewayDesiredPeersCleanup=null,this.gatewayDesiredPeerRevision=0,this.gatewayDesiredPeerSubmission=Promise.resolve();}async startGatewayAutoConnect(e,t){if(!await this.shouldUseTauriSignaling())throw new Error("[openrtc] Native IPC unavailable for staging gateway auto-connect.");if(!await this.ensureNativeAuth("startGatewayAutoConnect",{requireToken:this.requiresNativeAuthToken(),maxWaitMs:this.nativeAuthWaitMs()}))throw new Error("Native auth token unavailable for staging gateway auto-connect");let n=this.resolveNativeSignalingUserId(e);if(!n)throw new Error("Staging gateway auto-connect requires an authenticated user id.");let a=await this.resolveLocalDeviceId()||t.trim();if(!a)throw new Error("Staging gateway auto-connect requires a local device id.");this.fallback.setCoordinationLocalDeviceId(a),this.stopGatewayDesiredPeerRelay(),await this.invokeIpc("start_rtc_external_auto_connect",{userId:n,localDeviceId:a}),this.gatewayDesiredPeersCleanup=this.fallback.onDevicesChange(o=>{let r=o.map(l=>({deviceId:String(l.deviceId??"").trim(),nodeId:typeof l.nodeId=="string"&&l.nodeId.trim()||null,ticket:typeof l.ticket=="string"&&l.ticket.trim()||null,online:l.online===true,sessionId:typeof l.sessionId=="string"&&l.sessionId.trim()||null,excludedPeers:Array.isArray(l.excludedPeers)?[...new Set(l.excludedPeers.map(s=>String(s??"").trim().toLowerCase()).filter(Boolean))].sort():[]})).filter(l=>l.deviceId.length>0).sort((l,s)=>l.deviceId.localeCompare(s.deviceId)),c=++this.gatewayDesiredPeerRevision;this.gatewayDesiredPeerSubmission=this.gatewayDesiredPeerSubmission.then(async()=>{await this.invokeIpc("submit_rtc_desired_peers",{revision:c,peersJson:JSON.stringify(r)});}).catch(l=>{console.warn("[NativeIpcBridge] failed to relay gateway desired peers to Rust:",{revision:c,error:l});});},a);}async startPresenceLoopOnce(e,t,i,n,a){if(this.usesCoordinationGateway()){await this.syncCoordinationDeviceIdentity(),await this.fallback.startPresenceLoop(e,t,i,n,a);return}if(!await this.shouldUseTauriSignaling())throw new Error("[pluto-rtc] Native IPC unavailable for startPresenceLoopOnce().");if(console.info("[NativeIpcBridge][presence][start-request]",{userId:e,localNodeId:t,deviceName:i,hasMetadata:typeof a=="string"&&a.trim().length>0,hasCompoundTicket:typeof n=="string"&&n.includes(".")}),!await this.ensureNativeAuth("startPresenceLoop",{requireToken:this.requiresNativeAuthToken(),maxWaitMs:this.nativeAuthWaitMs()}))throw new Error("Native auth token unavailable for startPresenceLoop");let r=this.resolveNativeSignalingUserId(e);if(!r)throw new Error("Native presence loop requires a runtime auth-scoped user id.");console.info("[NativeIpcBridge][presence][auth-ready]",{requestedUserId:e,runtimeUserId:this.currentUser?.id??this.getAuthContext()?.userId??null,effectiveUserId:r,localNodeId:t}),await this.invokeIpc("start_rtc_presence_loop",{userId:r,localNodeId:t,deviceName:i,ticket:n,metadata:a,apiKey:this.options.apiKey??null,spaceKey:this.resolveConfiguredSpaceKey()||null}),console.info("[NativeIpcBridge][presence][ipc-started]",{requestedUserId:e,effectiveUserId:r,localNodeId:t,deviceName:i});}shouldUseResolvedDeviceName(e){let t=e.trim();return t.length===0||t==="Unknown Device"||t==="Desktop Device"}async sendExplicitFilePath(e,t,i=""){if(d("[NativeIpcBridge] sendExplicitFilePath start",{connectionId:e,filePath:t,transferId:i||null,authMode:this.options.authMode}),await this.canUseTauriIpc()){this.options.authMode!=="anonymous"?await this.ensureNativeAuth("sendExplicitFilePath"):d("[NativeIpcBridge] sendExplicitFilePath using anonymous native path");let n=await this.invokeIpc("send_file",{connectionId:e,filePath:t,transferId:i});return d("[NativeIpcBridge] sendExplicitFilePath completed",{connectionId:e,transferId:i||null,result:n}),n}return this.fallback.sendExplicitFilePath(e,t,i)}async sendExplicitFileData(e){d("[NativeIpcBridge] sendExplicitFileData start",{connectionId:e.connectionId??null,connectionRemoteNodeId:e.connection?.remoteNodeId??null,remoteNodeId:e.remoteNodeId??null,transferId:e.transferId??null,fileName:e.file.name,fileSize:e.file.size,authMode:this.options.authMode});let t=e.applicationCrypto??this.options.applicationCrypto;if(await this.canUseTauriIpc()){this.options.authMode!=="anonymous"?await this.ensureNativeAuth("sendExplicitFileData"):d("[NativeIpcBridge] sendExplicitFileData using anonymous native path");let i=e.connectionId||e.connection?.deviceId||e.connection?.remoteNodeId||e.remoteNodeId||"";if(!i)throw new Error("sendExplicitFileData requires a settled peer identifier in native runtime");let n=new Uint8Array(await e.file.arrayBuffer());await this.invokeIpc("send_file_data",{connectionId:i,filename:e.file.name,data:Array.from(n),transferId:e.transferId}),d("[NativeIpcBridge] sendExplicitFileData completed",{connectionId:i,transferId:e.transferId??null,fileName:e.file.name,fileSize:e.file.size});return}return this.fallback.sendExplicitFileData({...e,applicationCrypto:t})}async getConnectionStates(){if(await this.canUseTauriIpc())try{this.options.authMode!=="anonymous"&&await this.ensureNativeAuth("getConnectionStates");let e=await this.invokeIpc("list_rtc_connection_states");return (Array.isArray(e)?e:[]).map(t=>w(t)).filter(t=>!!t)}catch(e){return L(e)?d("[NativeIpcBridge] native connection-state replay unavailable; continuing without replay. Install/register openrtc-tauri-plugin default permissions to enable it."):console.warn("[NativeIpcBridge] Failed to fetch native connection states:",e),[]}return []}async getConnectionState(e){let t=e.trim();if(!t||!await this.canUseTauriIpc())return null;try{return this.options.authMode!=="anonymous"&&await this.ensureNativeAuth("getConnectionState"),w(await this.invokeIpc("get_rtc_connection_state",{connectionId:t}))}catch(i){return console.warn("[NativeIpcBridge] Failed to fetch native connection state:",{connectionId:t,error:i}),null}}async onConnectionStateChange(e){let t=false,i=null,n=new Map,a=Date.now(),o=0,r=()=>{let s=i;s&&Promise.resolve(s());},c$1=async()=>{try{let s=await this.getConnectionStates();s.length>0&&(c("[NativeIpcBridge] replaying current native connection states",s.map(u=>({connectionId:u.connectionId,deviceId:u.deviceId??null,deviceIdHint:u.deviceIdHint??null,remoteNodeId:u.remoteNodeId??null,state:u.state,transportState:u.transportState??null,protocolState:u.protocolState??null,routable:u.routable??null}))),s.forEach(u=>e(u)));}catch(s){console.warn("[NativeIpcBridge] Failed to replay native connection states after event subscription:",s);}},l=async s=>{let u$1=(n.get(s)??0)+1;n.set(s,u$1);let d=await this.getConnectionState(s);if(!d||t||n.get(s)!==u$1)return;if(["closed","failed","disconnected"].includes(String(d.state??"").trim().toLowerCase())){if(await u(g.CONNECTION_TERMINAL_CONFIRMATION_MS),t||n.get(s)!==u$1)return;d=await this.getConnectionState(s)??d;}!t&&n.get(s)===u$1&&e(d);};for(;!t&&Date.now()-a<=g.CONNECTION_EVENT_SUBSCRIBE_WINDOW_MS;){if(o+=1,!await this.canUseTauriIpc()){await u(this.nextConnectionEventRetryDelayMs(o));continue}return i=await this.listenIpc("connection-state-changed",s=>{let u=w(s?.payload);u&&(c("[NativeIpcBridge] connection-state-changed trigger",{connectionId:u.connectionId}),l(u.connectionId));}),await c$1(),()=>{t=true,r();}}return ()=>{t=true,r();}}async onIncomingNativeMessage(e){if(!await this.canUseTauriIpc())return ()=>{};let t=await this.listenIpc("iroh://message",i=>{if(i?.payload?.data&&i.payload.streamId==="main")try{let n=new Uint8Array(i.payload.data);if(n.length<2||n[0]!==0)return;let o=n.slice(1),r=new TextDecoder().decode(o),c=JSON.parse(r);e(i.payload.connectionId,i.payload.remoteNodeId??null,c);}catch{}});return typeof t=="function"?t:()=>{}}async getTransferHistory(e=50){return await this.canUseTauriIpc()?this.invokeIpc("get_transfer_history",{limit:e}):[]}async deleteTransferJob(e){await this.canUseTauriIpc()&&await this.invokeIpc("delete_transfer_job",{jobId:e});}};g.AUTH_REQUIRED_WAIT_MS=x.nativeIpc.authRequiredWaitMs,g.DEFAULT_BOUNDED_IPC_TIMEOUT_MS=x.nativeIpc.defaultBoundedCommandTimeoutMs,g.CONNECTION_EVENT_SUBSCRIBE_WINDOW_MS=x.nativeIpc.connectionEventSubscribeWindowMs,g.CONNECTION_EVENT_RETRY_MIN_DELAY_MS=x.nativeIpc.connectionEventRetryMinDelayMs,g.CONNECTION_EVENT_RETRY_MAX_DELAY_MS=x.nativeIpc.connectionEventRetryMaxDelayMs,g.CONNECTION_TERMINAL_CONFIRMATION_MS=1500,g.TAURI_IPC_NEGATIVE_CACHE_MS=x.nativeIpc.tauriIpcNegativeCacheMs,g.NATIVE_STATUS_IPC_TIMEOUT_MS=2500;var D=g;var te=class extends G{constructor(e){let t=T(e.bridge,"IpcRuntimeAdapter");super(new D({...e,ipcBridge:t,allowWasmFallback:e.allowWasmFallback??false}));}};
|
|
1
|
+
import {x,G,D as D$1,F,B,d,q as q$1,c,p,s,t as t$1,u as u$1,v,w}from'./chunk-JGBEYISL.js';import {x as x$1,u,a,g as g$1,t,E,G as G$1}from'./chunk-SVBFZRGV.js';function ie(p){let e=String(p?.message??p??"").toLowerCase();return e?e.includes("__tauri_internals__")||e.includes("window is not defined")||e.includes("cannot read properties of undefined")?"runtime-unavailable":e.includes("timeout after")?"timeout":e.includes("not found")||e.includes("not allowed")||e.includes("unknown command")||e.includes("plugin not found")||e.includes("plugin:openrtc-tauri-plugin")||e.includes("plugin:openrtc")?"command-unavailable":"unknown":"unknown"}function L(p){return ie(p)==="command-unavailable"}function T(p,e="native runtime"){if(!p||typeof p!="object")throw new Error(`[openrtc] ${e} requires a valid IPC bridge object.`);if(typeof p.invoke!="function")throw new Error(`[openrtc] ${e} IPC bridge is missing invoke(command, args).`);if(typeof p.listen!="function")throw new Error(`[openrtc] ${e} IPC bridge is missing listen(event, handler).`);return p}var q=null;async function ne(){return q||(q=(async()=>{let p="openrtc-tauri",e="../../../tauri/src/runtime/ipc";try{return await import(p)}catch(t){try{return await import(e)}catch(i){let n=new Error("[openrtc] Native support now lives in the first-party `openrtc-tauri` package. Install `openrtc-tauri` (and `@tauri-apps/api`) or pass an explicit IPC bridge to OpenRTC.native(...).");throw n.cause={packageError:t,workspaceError:i},n}}})()),q}function Q(){let p=null,e=async()=>(p||(p=ne().then(t=>T(t.createTauriIpcBridge(),"openrtc-tauri"))),p);return {async invoke(t,i){return (await e()).invoke(t,i)},async listen(t,i){return (await e()).listen(t,i)},async isAvailable(){try{let t=await e();return typeof t.isAvailable=="function"?!!await t.isAvailable():!0}catch{return false}}}}var ae="relay-only endpoint ticket unavailable",re=12e3,se=250,oe=1500;function ce(p){return String(p?.message??p??"").toLowerCase().includes(ae)}async function O(p,e={}){let t=e.windowMs??re,i=e.minDelayMs??se,n=e.maxDelayMs??oe,a=Date.now(),o=0,r=null;for(;e.isActive?.()??true;){o+=1;try{return await p()}catch(c){if(r=c,!ce(c))throw c;let l=Date.now()-a;if(l>=t)throw c;let s=Math.min(x$1(o,i,n),Math.max(0,t-l));s>0&&await u(s);}}throw r||new Error("endpoint ticket minting stopped before a ticket was available")}function Z(p){let e=p?.split(".")[1];if(!e)return null;try{let t=e.replace(/-/g,"+").replace(/_/g,"/"),i=(4-t.length%4)%4,n=atob(t+"=".repeat(i)),a=JSON.parse(n);return a&&typeof a=="object"&&!Array.isArray(a)?a:null}catch{return null}}function X(p,e){let t=p?.[e];return typeof t=="string"&&t.trim()?t.trim():null}function ee(p,e){return X(p,"namespaceId")===e||X(p,"appTag")===`space::${e}`}var g=class g{constructor(e){this.subscriptionNonce=0;this.lastSyncedAuthToken=null;this.cachedLocalDeviceId=null;this.cachedLocalDeviceName=null;this.tauriCoreAvailability=null;this.tauriCoreAvailabilityValue=null;this.tauriCoreAvailabilityCheckedAtMs=0;this.authSyncInFlight=null;this.nativeRuntimeCapabilitiesSyncInFlight=null;this.gatewayDesiredPeersCleanup=null;this.gatewayDesiredPeerRevision=0;this.gatewayDesiredPeerSubmission=Promise.resolve();this.lastNativeAuthSyncAtMs=0;this.hasLoggedMissingAuthForDevices=false;this.runtimeCapabilities=D$1(null,false);this.fallback=new F({...e,coordinationPlatformType:"desktop"}),this.app=this.fallback.app,this.auth=this.fallback.auth,this.appTag=this.fallback.tag,this.options=this.fallback.getResolvedOptions(),this.transportOptions=e.transports,this.strictMode=e.strictMode===true,this.turnCredentialsProvider=e.turnCredentialsProvider,this.allowWasmFallback=e.allowWasmFallback??false,this.ipcBridge=T(e.ipcBridge??Q(),"NativeIpcBridge"),this.runtimeCapabilities=D$1(null,this.allowWasmFallback),this.syncNativeRuntimeCapabilities("constructor");}get currentUser(){return this.fallback.currentUser}get tag(){return this.fallback.tag}getRuntimeCapabilities(){let e=B(this.runtimeCapabilities);return e.fallback.wasm=this.allowWasmFallback,e}usesCoordinationGateway(){return this.fallback.usesCoordinationGateway()}async joinCoordinationRoom(e,t,i){await this.syncCoordinationDeviceIdentity(),await this.fallback.joinCoordinationRoom(e,t,i);}leaveCoordinationRoom(e){return this.fallback.leaveCoordinationRoom(e)}getCoordinationRoomMembers(e){return this.fallback.getCoordinationRoomMembers(e)}watchCoordinationRoomMembers(e,t){return this.fallback.watchCoordinationRoomMembers(e,t)}async syncCoordinationDeviceIdentity(){if(!this.usesCoordinationGateway())return;let e=await this.resolveLocalDeviceId();this.fallback.setCoordinationLocalDeviceId(e);}setWasmClient(e){if(!this.allowWasmFallback){let t="[NativeIpcBridge][NATIVE-GUARD] Refusing WasmClient attachment because native IPC is authoritative and WASM fallback is disabled.";throw console.error(t,{capabilities:this.getRuntimeCapabilities()}),new Error(t)}this.fallback.setWasmClient(e);}onAuthChange(e){return this.fallback.onAuthChange(e)}checkForSSOToken(){return this.fallback.checkForSSOToken()}waitForAuth(){return this.fallback.waitForAuth()}signInAnonymously(){return this.fallback.signInAnonymously()}getTurnCredentials(){return this.fallback.getTurnCredentials()}cleanupStaleDevices(){return this.fallback.cleanupStaleDevices()}sendMessage(e,t,i,n){return this.fallback.sendMessage(e,t,i,n)}pollMessages(e){return this.fallback.pollMessages(e)}createSession(e){return this.fallback.createSession(e)}updateSession(e,t){return this.fallback.updateSession(e,t)}async openPeerBi(e,t){return await this.canUseTauriIpc()?this.openPeerBiViaIpc("open_peer_bi_stream",{peerId:e,timeoutMs:t??null}):this.fallback.openPeerBi(e,t)}async openPeerBiTransportOnly(e,t){return await this.canUseTauriIpc()?this.openPeerBiViaIpc("open_peer_bi_transport_only_stream",{peerId:e,timeoutMs:t??null},{fallbackCommand:"open_peer_bi_stream"}):this.fallback.openPeerBiTransportOnly(e,t)}async openPeerNativeBi(e,t,i){return await this.canUseTauriIpc()?this.openPeerBiViaIpc("open_peer_native_bi_stream",{peerId:e,label:t,timeoutMs:i??null},{fallbackCommand:"open_peer_bi_stream",fallbackArgs:{peerId:e,timeoutMs:i??null}}):this.fallback.openPeerNativeBi(e,t,i)}async incoming_streams(){if(!await this.canUseTauriIpc()){let a=this.fallback;if(typeof a.incoming_streams=="function")return a.incoming_streams();throw new Error("Native incoming stream bridge is unavailable")}let e=`native-incoming-${Date.now()}-${++this.subscriptionNonce}`,t=null,i=false,n=async()=>{i=true;let a=t;t=null,await Promise.allSettled([a?Promise.resolve(a()):Promise.resolve(),this.invokeIpc("stop_rtc_subscription",{requestId:e},{timeoutMs:null}).catch(()=>{})]);};return new ReadableStream({start:async a=>{try{t=await this.listenIpc("openrtc://peer-bi-stream/incoming",o=>{if(i)return;let r=o.payload,c=typeof r?.requestId=="string"?r.requestId:typeof r?.request_id=="string"?r.request_id:"";if(c!==e){d("[NativeIpcBridge][incoming-application-stream] ignored request id",{expectedRequestId:e,eventRequestId:c});return}let l=typeof r?.streamId=="string"?r.streamId.trim():typeof r?.stream_id=="string"?r.stream_id.trim():"";if(!l)return;let s=typeof r?.remoteNodeId=="string"?r.remoteNodeId.trim():typeof r?.remote_node_id=="string"?r.remote_node_id.trim():"",u=Number.isSafeInteger(r?.transportStableId)?Number(r.transportStableId):Number.isSafeInteger(r?.transport_stable_id)?Number(r.transport_stable_id):0;if(!s||u<=0){d("[NativeIpcBridge][incoming-application-stream] ignored invalid generation",{requestId:e,remoteNodeId:s,transportStableId:u});return}d("[NativeIpcBridge][incoming-application-stream] accepted event",{requestId:e,remoteNodeId:s,transportStableId:u});let d$1=this.peerBiStreamFromId(l,{startReadAfterListeners:!0});a.enqueue({type:"bi",stream:{send:d$1.writable,recv:d$1.readable,endpoint_id:s},endpointId:s,transportStableId:u,protocolHint:"unknown",channel:null});}),await this.invokeIpc("start_incoming_peer_bi_streams",{requestId:e},{timeoutMs:null});}catch(o){i=true,a.error(o),await n();}},cancel:async()=>{await n();}})}async is_current_transport_stable_id(e,t){if(!await this.canUseTauriIpc()){let i=this.fallback;return typeof i.is_current_transport_stable_id=="function"?i.is_current_transport_stable_id(e,t):false}return !e.trim()||t<=0n||t>BigInt(Number.MAX_SAFE_INTEGER)?false:this.invokeIpc("is_current_transport_stable_id",{endpointId:e.trim(),transportStableId:Number(t)})}openPeerUni(e,t){return this.fallback.openPeerUni(e,t)}isConnected(e){return this.fallback.isConnected(e)}getAuthContext(){return this.fallback.getAuthContext()}resolveNativeAuthScopedUserId(e){return this.currentUser?.id??this.getAuthContext()?.userId??e??null}resolveConfiguredSpaceKey(){let e=this.options.spaceKey??this.options.space;return typeof e=="string"?e.trim():""}usesAnonymousSpaceMode(){return this.options.authMode==="anonymous"&&this.resolveConfiguredSpaceKey().length>0}requiresNativeAuthToken(){return !this.usesAnonymousSpaceMode()||typeof this.options.spaceTokenProvider=="function"}async nativeAuthTokenMatchesExpectedScope(e){if(!this.usesAnonymousSpaceMode())return true;let t=typeof this.options.apiKey=="string"?this.options.apiKey.trim():"",i=this.resolveConfiguredSpaceKey();if(!t||!i)return true;let n=await a(t,i).catch(()=>null);return n?ee(Z(e),n):true}resolveNativeSignalingUserId(e){return this.usesAnonymousSpaceMode()?(typeof e=="string"?e.trim():"")||this.resolveConfiguredSpaceKey()||null:this.resolveNativeAuthScopedUserId(e)}getCurrentUserId(){return this.resolveNativeSignalingUserId(this.fallback.getCurrentUserIdForScope())}nativeAuthWaitMs(){return this.requiresNativeAuthToken()?g.AUTH_REQUIRED_WAIT_MS:0}resolveWebLogicalDeviceId(){return this.fallback.getResolvedWebLogicalDeviceId()}normalizeDevice(e,t){return this.fallback.normalizeDeviceRecord(e,t)}matchesTag(e){return this.fallback.matchesLegacyOrCurrentTag(e)}nativeRosterTagDisposition(e){let t=q$1(e);if(this.matchesTag(t))return {keep:true,classification:"match"};let i=typeof t.appTag=="string"&&t.appTag.trim().length>0?t.appTag.trim():typeof t.tag=="string"&&t.tag.trim().length>0?t.tag.trim():void 0;return i===void 0?{keep:true,classification:"untagged"}:{keep:false,classification:"foreign",foreignTag:i}}filterNativeRosterByTag(e,t){let i=new Set,n=e.filter(a=>{let o=this.nativeRosterTagDisposition(a);return !o.keep&&o.foreignTag&&i.add(o.foreignTag),o.keep});return e.length>0&&n.length===0&&i.size>0?console.warn(`[NativeIpcBridge] ${t}: dropped ALL ${e.length} native device(s) as foreign-app \u2014 this is the app-tag drift signature (empty native device list). The native Rust OpenRTC app tag does not match the SDK app tag; check that the desktop binary and the web bundle use the same VITE_PLUTO_OPENRTC_API_KEY / VITE_PLUTO_OPENRTC_APP_TAG for this environment lane.`,{sdkAppTag:this.appTag,foreignTags:Array.from(i),droppedCount:e.length}):i.size>0&&d(`[NativeIpcBridge] ${t}: filtered ${e.length-n.length} foreign-app device(s) from the native roster`,{sdkAppTag:this.appTag,foreignTags:Array.from(i)}),n}normalizeNativeIceServer(e){let t=e.urls,i=Array.isArray(t)?t.filter(n=>typeof n=="string"&&n.trim().length>0):typeof t=="string"&&t.trim().length>0?[t]:[];return i.length===0?null:{urls:i,username:typeof e.username=="string"&&e.username.trim().length>0?e.username:void 0,credential:typeof e.credential=="string"&&e.credential.trim().length>0?e.credential:void 0}}filterNativeStunServers(e){return e.map(t=>({...t,urls:t.urls.filter(i=>!i.startsWith("stun:"))})).filter(t=>t.urls.length>0)}nativeIceServerHasTurnUrl(e){return e.urls.some(t=>t.startsWith("turn:")||t.startsWith("turns:"))}async loadNativeTurnIceServers(){if(typeof this.turnCredentialsProvider!="function")return [];let e=await this.turnCredentialsProvider().catch(t=>(console.warn("[NativeIpcBridge] TURN credential provider failed:",t),null));return !e||!Array.isArray(e.iceServers)?[]:e.iceServers.map(t=>this.normalizeNativeIceServer(t)).filter(t=>!!t)}async buildNativeTransportConfigPayload(){let e=this.transportOptions;if(!e&&!this.strictMode)return null;let t=null;if(!this.strictMode&&e?.iroh&&typeof e.iroh=="object"){let l=e.iroh;l.localDiscovery===true&&(t={enabled:true,advertise:l.localDiscoveryMode!=="passive"});}let i=null;if(e?.webrtc===true||e?.webrtc&&typeof e.webrtc=="object"){let l=e.webrtc===true?null:e.webrtc,s=l?.useDefaultIceServers!==false,u=Array.isArray(l?.iceServers)&&l.iceServers.length>0?l.iceServers.map(m=>this.normalizeNativeIceServer(m)).filter(m=>!!m):s?g$1.map(m=>this.normalizeNativeIceServer(m)).filter(m=>!!m):[],d=this.strictMode||l?.privacyMode===true;(this.strictMode||l?.privacyMode===true||l?.useTurn===true)&&(u=[...u,...await this.loadNativeTurnIceServers()]),d&&(u=this.filterNativeStunServers(u));let v=u.some(m=>this.nativeIceServerHasTurnUrl(m)),f=d&&v;d&&!v&&console.warn("[NativeIpcBridge] Relay-only WebRTC requested, but no TURN servers are configured; native WebRTC override disabled");let _=l?.lanMode===true;(u.length>0||f||_||!s)&&(i={iceServers:u.length>0||!s?u:void 0,privacyMode:f,lanMode:_||void 0});}let n=null;if(e?.moq&&typeof e.moq=="object"){let l=typeof e.moq.relayUrl=="string"&&e.moq.relayUrl.trim().length>0?e.moq.relayUrl:void 0;if(l){let s=typeof e.moq.accessToken=="string"&&e.moq.accessToken.trim().length>0?e.moq.accessToken.trim():void 0;n={relayUrl:l,accessToken:s};}}let a=null;if(!this.strictMode&&(e?.ble===true||e?.ble&&typeof e.ble=="object")){let l=e.ble===true?null:e.ble,s=Number(l?.connectTimeoutMs);a={enabled:l?.enabled!==false,connectTimeoutMs:Number.isFinite(s)&&s>0?Math.round(s):void 0};}let o=this.strictMode||e?.iroh&&typeof e.iroh=="object"&&e.iroh.relayOnly===true,r=e?.iroh&&typeof e.iroh=="object"?e.iroh.relayTransportPolicy:void 0,c=this.strictMode?r??"auto":r;return !o&&!c&&!i&&!n&&!t&&!a?null:{irohRelayOnly:o||void 0,irohRelayTransportPolicy:c,irohLan:t,webrtc:i,moq:n,ble:a}}isTauriEnv(){return t()}nextConnectionEventRetryDelayMs(e){return x$1(e,g.CONNECTION_EVENT_RETRY_MIN_DELAY_MS,g.CONNECTION_EVENT_RETRY_MAX_DELAY_MS)}async clearNativeAuthRelay(e){if(await this.canUseTauriIpc())try{await this.invokeIpc("desktop_set_pluto_auth_token",{authToken:null,refreshToken:null}),this.lastSyncedAuthToken=null,this.lastNativeAuthSyncAtMs=0,d(`[NativeIpcBridge] cleared native auth relay (${e})`);}catch(t){console.warn(`[NativeIpcBridge] failed clearing native auth relay (${e}):`,t);}}async relayNativeAuthToken(e,t,i,n){if(!await this.canUseTauriIpc())return true;if(!await this.nativeAuthTokenMatchesExpectedScope(e))return d(`[NativeIpcBridge] auth sync deferred (${i}): token claims do not match configured space`),false;if(e===this.lastSyncedAuthToken)return true;try{await this.invokeIpc("desktop_set_pluto_auth_token",{authToken:e,refreshToken:t??null});}catch(a){return L(a)?console.warn(`[NativeIpcBridge] desktop auth relay unavailable (${i}); install/register openrtc-tauri-plugin and include its default permission set.`,a):console.warn(`[NativeIpcBridge] desktop auth relay failed (${i}):`,a),false}return this.lastSyncedAuthToken=e,this.lastNativeAuthSyncAtMs=Date.now(),d(`[NativeIpcBridge] auth token relayed to native runtime (${i}) user_id=${n??this.currentUser?.id??"unknown"}`),true}async relayExplicitNativeAuthContext(e){let t=this.authSyncInFlight,i=(async()=>(await t?.catch(()=>{}),this.relayNativeAuthToken(e.token,e.refreshToken,"setAuthContext",e.userId)))();this.authSyncInFlight=i;try{return await i}finally{this.authSyncInFlight===i&&(this.authSyncInFlight=null);}}applyNativeRuntimeStatus(e){this.runtimeCapabilities=D$1(e,this.allowWasmFallback);}syncNativeRuntimeCapabilities(e){return this.ipcBridge?this.nativeRuntimeCapabilitiesSyncInFlight?this.nativeRuntimeCapabilitiesSyncInFlight:(this.nativeRuntimeCapabilitiesSyncInFlight=(async()=>{try{let t=await this.invokeIpc("rtc_native_status",void 0,{timeoutMs:g.NATIVE_STATUS_IPC_TIMEOUT_MS});this.applyNativeRuntimeStatus(t),d(`[NativeIpcBridge] refreshed native runtime capabilities (${e})`);}catch(t){c("[NativeIpcBridge] native runtime capability refresh skipped",t);}})().finally(()=>{this.nativeRuntimeCapabilitiesSyncInFlight=null;}),this.nativeRuntimeCapabilitiesSyncInFlight):Promise.resolve()}async canUseTauriIpc(){if(this.ipcBridge){let e=typeof this.ipcBridge.isAvailable=="function"?!!await this.ipcBridge.isAvailable():true;return e&&this.syncNativeRuntimeCapabilities("ipc-available"),e}return typeof window>"u"?false:this.tauriCoreAvailabilityValue===true?true:this.tauriCoreAvailabilityValue===false&&Date.now()-this.tauriCoreAvailabilityCheckedAtMs<g.TAURI_IPC_NEGATIVE_CACHE_MS?false:(this.tauriCoreAvailability||(this.tauriCoreAvailability=(async()=>{try{if(this.isTauriEnv())return this.tauriCoreAvailabilityValue=!0,this.tauriCoreAvailabilityCheckedAtMs=Date.now(),this.syncNativeRuntimeCapabilities("tauri-env"),!0;try{let e=await this.invokeIpc("rtc_native_status");return this.applyNativeRuntimeStatus(e),d("[NativeIpcBridge] Resolved Tauri IPC via rtc_native_status probe"),this.tauriCoreAvailabilityValue=!0,this.tauriCoreAvailabilityCheckedAtMs=Date.now(),!0}catch(e){let t=String(e?.message??e??"");return t.includes("__TAURI_INTERNALS__")||t.includes("Cannot read properties of undefined")||t.includes("window is not defined")?(this.tauriCoreAvailabilityValue=!1,this.tauriCoreAvailabilityCheckedAtMs=Date.now(),!1):(d("[NativeIpcBridge] Tauri IPC probe reached native layer (command-level error acceptable)"),this.tauriCoreAvailabilityValue=!0,this.tauriCoreAvailabilityCheckedAtMs=Date.now(),!0)}}catch{return this.tauriCoreAvailabilityValue=false,this.tauriCoreAvailabilityCheckedAtMs=Date.now(),false}})().finally(()=>{this.tauriCoreAvailability=null;})),this.tauriCoreAvailability)}async invokeIpc(e,t,i){let n=this.ipcBridge.invoke(e,t),a=i&&Object.prototype.hasOwnProperty.call(i,"timeoutMs")?i.timeoutMs:g.DEFAULT_BOUNDED_IPC_TIMEOUT_MS;return a==null||a<=0?n:E(n,a,()=>new Error(`${e} timeout after ${a}ms`))}async listenIpc(e,t){return this.ipcBridge.listen(e,i=>{t({payload:i});})}async openPeerBiViaIpc(e,t,i){let n=await this.invokePeerBiOpen(e,t,i),a=typeof n?.streamId=="string"?n.streamId.trim():typeof n?.stream_id=="string"?n.stream_id.trim():"";if(!a)throw new Error(`${e} returned no streamId`);return this.peerBiStreamFromId(a)}peerBiStreamFromId(e,t={}){let i=this,n=null,a=null,o=false,r=null,c=null,l=async()=>{let v=[n,a];n=null,a=null,await Promise.allSettled(v.filter(f=>typeof f=="function").map(f=>Promise.resolve(f())));},s=(async()=>{n=await this.listenIpc("openrtc://peer-bi-stream/chunk",v=>{let f=v.payload;if((typeof f?.streamId=="string"?f.streamId:typeof f?.stream_id=="string"?f.stream_id:"")!==e||o||!r)return;let w=f?.bytes;w instanceof Uint8Array?r.enqueue(w):Array.isArray(w)&&r.enqueue(new Uint8Array(w));}),a=await this.listenIpc("openrtc://peer-bi-stream/closed",v=>{let f=v.payload;if((typeof f?.streamId=="string"?f.streamId:typeof f?.stream_id=="string"?f.stream_id:"")!==e||o||!r)return;o=true;let w=typeof f?.error=="string"?f.error.trim():"";w?r.error(new Error(w)):r.close(),l();}),t.startReadAfterListeners&&await this.invokeIpc("start_peer_bi_stream_read",{streamId:e},{timeoutMs:null});})().catch(v=>{c=v,r&&!o&&(o=true,r.error(v));}),u=async()=>{await this.invokeIpc("close_peer_bi_stream",{streamId:e},{timeoutMs:null}).catch(()=>{}),await l();},d=new ReadableStream({async start(v){r=v,await s,c&&!o&&(o=true,v.error(c));},async cancel(){o=true,await u();}}),y=new WritableStream({write:async v=>{await i.invokeIpc("write_peer_bi_stream",{streamId:e,bytes:Array.from(v)},{timeoutMs:null});},close:u,abort:u});return {readable:d,writable:y}}async invokePeerBiOpen(e,t,i){try{return await this.invokeIpc(e,t)}catch(n){if(!i?.fallbackCommand||!this.isMissingNativeCommandError(n))throw n;return this.invokeIpc(i.fallbackCommand,i.fallbackArgs??t)}}isMissingNativeCommandError(e){let t=e instanceof Error?e.message:String(e??"");return t.includes("Command")&&t.includes("not found")}async shouldUseTauriSignaling(){if(await this.canUseTauriIpc())return true;if(this.allowWasmFallback)return false;throw new Error("[pluto-rtc] Tauri runtime adapter requires native IPC, but it is unavailable.")}async signInWithPluto(){if(!await this.canUseTauriIpc()){await this.fallback.signInWithPluto();return}let e=await this.invokeIpc("rtc_sign_in_with_pluto"),t=typeof e?.customToken=="string"?e.customToken.trim():"";if(!t)throw new Error("[pluto-rtc] Native Pluto SSO did not return a custom token.");await G$1().signInWithCustomTokenValue(t),await this.ensureNativeAuth("pluto-sso",{requireToken:true,maxWaitMs:1e4});}async setAuthContext(e){let t=this.getAuthContext()?.userId??null,i=typeof e?.userId=="string"&&e.userId.trim()||null,n=this.fallback.setAuthContext(e);if(t&&i&&t!==i&&await this.stopNativeAuthScopedActivity(t),await n,!e?.token)await this.clearNativeAuthRelay("setAuthContext");else if(!await this.relayExplicitNativeAuthContext(e))throw new Error("Native auth token unavailable for setAuthContext")}async signOut(){await this.fallback.signOut(),await this.clearNativeAuthRelay("signOut");}async stopAuthScopedActivity(e){let t=this.resolveNativeSignalingUserId(e?.userId??null);await this.stopNativeAuthScopedActivity(t);}async stopNativeAuthScopedActivity(e){this.stopGatewayDesiredPeerRelay();let t=await this.shouldUseTauriSignaling();if(p("NativeIpcBridge.stopAuthScopedActivity",{userId:e,useTauri:t}),t)try{await Promise.allSettled([this.revokeSessionTokensByScope("user-device"),this.invokeIpc("stop_rtc_presence_loop"),this.invokeIpc("stop_rtc_auto_connect"),e&&!this.usesCoordinationGateway()?this.invokeIpc("set_rtc_offline",{userId:e}):Promise.resolve()]);}catch(i){console.warn("[NativeIpcBridge] Failed to stop native auth-scoped RTC activity:",i);}await this.fallback.stopAuthScopedActivity({userId:e});}async ensureNativeAuthOnce(e,t){if(!await this.canUseTauriIpc())return true;if(this.authSyncInFlight)return this.authSyncInFlight;let i=(async()=>{try{if(!this.currentUser)return d(`[NativeIpcBridge] auth sync deferred (${e}): no current user`),!t;let n=Date.now()-this.lastNativeAuthSyncAtMs>=480*1e3,a=this.currentUser?.getToken?await this.currentUser.getToken(n):null,r=this.getAuthContext()?.refreshToken??this.auth?.currentUser?.refreshToken??null;return a?this.relayNativeAuthToken(a,r,e,this.currentUser?.id):(d(`[NativeIpcBridge] auth sync deferred (${e}): missing token for user ${this.currentUser?.id}`),!t)}catch(n){return console.error("[NativeIpcBridge] auth sync failed:",n),false}})();this.authSyncInFlight=i;try{return await i}finally{this.authSyncInFlight===i&&(this.authSyncInFlight=null);}}async ensureNativeAuth(e="runtime",t){if(!await this.canUseTauriIpc())return true;let i=t?.requireToken??false,n=t?.maxWaitMs??(i?g.AUTH_REQUIRED_WAIT_MS:0),a=t?.pollMs??250,o=Date.now()+Math.max(0,n);for(;;){if(await this.ensureNativeAuthOnce(e,i))return true;if(!i||Date.now()>=o)return false;await u(a);}}decodeNativeDeviceIdentity(e){let t=e?.systemInfo??e?.system_info??null,i=typeof e?.deviceId=="string"?e.deviceId.trim():typeof e?.device_id=="string"?e.device_id.trim():"",n=typeof e?.deviceName=="string"?e.deviceName.trim():typeof e?.device_name=="string"?e.device_name.trim():"",a=typeof e?.platformType=="string"?e.platformType.trim():typeof e?.platform_type=="string"?e.platform_type.trim():typeof t?.platformType=="string"?t.platformType.trim():typeof t?.platform_type=="string"?t.platform_type.trim():"";return {deviceId:i,deviceName:n,platformType:a}}async resolveLocalDeviceId(){if(this.cachedLocalDeviceId)return this.cachedLocalDeviceId;if(await this.canUseTauriIpc())try{let t=await this.invokeIpc("get_rtc_local_device_info"),{deviceId:i,deviceName:n}=this.decodeNativeDeviceIdentity(t);if(i)return this.cachedLocalDeviceId=i,n&&(this.cachedLocalDeviceName=n),i}catch(t){console.warn("[NativeIpcBridge] get_rtc_local_device_info failed:",t);}let e=this.resolveWebLogicalDeviceId();return this.cachedLocalDeviceId=e,e}async resolveLocalDeviceName(){if(this.cachedLocalDeviceName)return this.cachedLocalDeviceName;if(await this.canUseTauriIpc())try{let e=await this.invokeIpc("get_rtc_local_device_info"),{deviceName:t}=this.decodeNativeDeviceIdentity(e);if(t){let i=this.normalizeNativeDeviceName(t);return this.cachedLocalDeviceName=i,i}}catch(e){console.warn("[NativeIpcBridge] get_rtc_local_device_info failed:",e);}return this.defaultDeviceNameFallback()}normalizeNativeDeviceName(e){let t=e.trim();if(!t)return this.defaultDeviceNameFallback();if(t==="Desktop Device"){let i=this.defaultDeviceNameFallback();if(i!=="Desktop Device")return i}return t}defaultDeviceNameFallback(){if(typeof window>"u"||typeof navigator>"u")return "Desktop Device";let e=navigator.userAgent||"";return /iPhone|iPad|iPod/i.test(e)?"iPhone":/Android/i.test(e)?"Android":"Desktop Device"}inferNativePlatformTypeFallback(){if(typeof window>"u"||typeof navigator>"u")return "desktop";if(!this.isTauriEnv())return "web";let e=navigator.userAgent||"";return /iPhone|iPad|iPod|Android|Mobile/i.test(e)?"mobile":"desktop"}withPresenceMetadata(e,t){try{let i=e?JSON.parse(e):{};return JSON.stringify({...i,deviceId:t,plutoVersion:"0.1.0-desktop"})}catch{return JSON.stringify({deviceId:t,plutoVersion:"0.1.0-desktop",rawMetadata:e})}}async searchDevices(e){if(this.usesCoordinationGateway())return this.fallback.searchDevices(e);if(await this.shouldUseTauriSignaling()){if(!await this.ensureNativeAuth("searchDevices",{requireToken:this.requiresNativeAuthToken(),maxWaitMs:this.nativeAuthWaitMs()}))throw new Error("Native auth token unavailable for searchDevices");let i=await this.invokeIpc("search_rtc_devices",{userId:this.getCurrentUserId()});if(Array.isArray(i?.devices)){let n=i.devices.map(a=>this.normalizeDevice(a));return e&&(n=n.filter(a=>a.ticket!==e&&a.deviceId!==e&&a.nodeId!==e)),n}throw typeof i?.message=="string"?new Error(String(i.message)):new Error("Unexpected response for search_rtc_devices")}return this.fallback.searchDevices(e)}async listDevicesWithStatus(){if(this.usesCoordinationGateway())return (await this.fallback.searchDevices()).map(e=>s(e));if(await this.shouldUseTauriSignaling()){if(!await this.ensureNativeAuth("listDevicesWithStatus",{requireToken:this.requiresNativeAuthToken(),maxWaitMs:this.nativeAuthWaitMs()}))throw new Error("Native auth token unavailable for listDevicesWithStatus");let t=await this.invokeIpc("search_rtc_devices_with_status",{userId:this.getCurrentUserId()});if(Array.isArray(t?.devices)){let i=t.devices,n=this.filterNativeRosterByTag(i,"listDevicesWithStatus").map(r=>s(r)),a=await this.resolveLocalDeviceId().catch(()=>null),o=!!a&&n.some(r=>r.deviceId===a);return c("[NativeIpcBridge] listDevicesWithStatus result",{rawCount:i.length,count:n.length,localDeviceId:a,selfIncluded:o,devices:n.map(r=>({deviceId:r.deviceId,deviceName:r.deviceName,online:!!r.online,presenceStatus:r.presenceStatus,connectable:r.connectable,connectionStatus:r.connectionStatus,settledReady:!!r.settledReady,peerHealth:r.peerHealth,scopes:r.scopes,connectionId:r.connectionId??null,deviceIdHint:r.deviceIdHint??null,nodeId:r.nodeId??null,activeTransport:r.activeTransport??null,parallelTransport:r.parallelTransport??null}))}),a&&!o&&c("[NativeIpcBridge] native status snapshot excludes local device by design",{localDeviceId:a,count:n.length}),n}throw typeof t?.message=="string"?new Error(String(t.message)):new Error("Unexpected response for search_rtc_devices_with_status")}return this.fallback.listDevicesWithStatus()}async getPeerSession(e){if(await this.shouldUseTauriSignaling()){let t=await this.invokeIpc("get_rtc_peer_session",{id:e});return !t||typeof t!="object"?null:t$1(t)}return this.fallback.getPeerSession(e)}async listPeerSessions(){if(await this.shouldUseTauriSignaling()){let e=await this.invokeIpc("list_rtc_peer_sessions");return (Array.isArray(e)?e:[]).map(t=>t$1(t))}return this.fallback.listPeerSessions()}async waitForSettledPeer(e,t){if(await this.shouldUseTauriSignaling()){let i=typeof t=="number"?Math.max(g.DEFAULT_BOUNDED_IPC_TIMEOUT_MS,t+1e3):g.DEFAULT_BOUNDED_IPC_TIMEOUT_MS,n=await this.invokeIpc("wait_for_rtc_settled_peer",{id:e,timeoutMs:t},{timeoutMs:i});return !n||typeof n!="object"?null:t$1(n)}return this.fallback.waitForSettledPeer(e,t)}async resolvePeerConnectionRecords(e){if(await this.shouldUseTauriSignaling()){let t=await this.invokeIpc("resolve_rtc_peer_connection_records",{id:e});return (Array.isArray(t)?t:[]).map(i=>u$1(i))}return this.fallback.resolvePeerConnectionRecords(e)}async resolvePeerIdentity(e){if(await this.shouldUseTauriSignaling()){let t=await this.invokeIpc("resolve_rtc_peer_identity",{id:e});return v(t)}return this.fallback.resolvePeerIdentity(e)}async setOffline(e){if(this.usesCoordinationGateway())return this.fallback.setOffline(e);if(await this.shouldUseTauriSignaling())try{if(!await this.ensureNativeAuth("setOffline",{requireToken:this.requiresNativeAuthToken(),maxWaitMs:this.nativeAuthWaitMs()}))throw new Error("Native auth token unavailable for setOffline");let i=this.getCurrentUserId();await this.invokeIpc("set_rtc_offline",{userId:i});return}catch(t){console.warn("[NativeIpcBridge] set_rtc_offline failed:",t);}return this.fallback.setOffline(e)}async updateDevice(e,t){if(this.usesCoordinationGateway())return await this.syncCoordinationDeviceIdentity(),this.fallback.updateDevice(e,t);if(await this.shouldUseTauriSignaling()){if(!await this.ensureNativeAuth("updateDevice",{requireToken:this.requiresNativeAuthToken(),maxWaitMs:this.nativeAuthWaitMs()}))throw new Error("Native auth token unavailable for updateDevice");let a=this.getCurrentUserId();if(!a)throw new Error("updateDevice requires authenticated user scope");try{await this.invokeIpc("update_rtc_device",{userId:a,deviceId:e,deviceName:t.deviceName??null,capabilities:t.capabilities??null,metadata:t.metadata??null});return}catch(o){throw console.warn("[NativeIpcBridge] update_rtc_device failed:",o),o instanceof Error?o:new Error(String(o))}}return this.fallback.updateDevice(e,t)}async deleteDevice(e){if(this.usesCoordinationGateway())return await this.syncCoordinationDeviceIdentity(),this.fallback.deleteDevice(e);if(await this.shouldUseTauriSignaling()){if(!await this.ensureNativeAuth("deleteDevice",{requireToken:this.requiresNativeAuthToken(),maxWaitMs:this.nativeAuthWaitMs()}))throw new Error("Native auth token unavailable for deleteDevice");let n=this.getCurrentUserId();if(!n)throw new Error("deleteDevice requires authenticated user scope");try{await this.invokeIpc("delete_rtc_device",{userId:n,deviceId:e});return}catch(a){throw console.warn("[NativeIpcBridge] delete_rtc_device failed:",a),a instanceof Error?a:new Error(String(a))}}return this.fallback.deleteDevice(e)}async getLocalDeviceInfo(){if(!await this.canUseTauriIpc()){let e=await this.getLocalDeviceId?.();return e?{deviceId:e,deviceName:this.defaultDeviceNameFallback(),platformType:this.inferNativePlatformTypeFallback()}:null}try{let e=await this.invokeIpc("get_rtc_local_device_info"),t=this.decodeNativeDeviceIdentity(e),{deviceId:i}=t;return i?{deviceId:i,deviceName:this.normalizeNativeDeviceName(t.deviceName),platformType:t.platformType||this.inferNativePlatformTypeFallback(),capabilities:e?.capabilities??void 0,lastSeenAt:typeof e?.last_seen_at=="string"?e.last_seen_at:void 0}:null}catch(e){return console.warn("[NativeIpcBridge] getLocalDeviceInfo failed:",e),null}}async updateLocalDeviceName(e){if(!await this.canUseTauriIpc())return null;try{let t=await this.invokeIpc("update_rtc_local_device_name",{deviceName:e}),i=this.decodeNativeDeviceIdentity(t),{deviceId:n}=i;return n?(this.cachedLocalDeviceName=this.normalizeNativeDeviceName(e),{deviceId:n,deviceName:this.cachedLocalDeviceName,platformType:i.platformType||this.inferNativePlatformTypeFallback(),capabilities:t?.capabilities??void 0,lastSeenAt:typeof t?.last_seen_at=="string"?t.last_seen_at:void 0}):null}catch(t){return console.warn("[NativeIpcBridge] updateLocalDeviceName failed:",t),null}}async startManagedSessionNative(e){if(!await this.shouldUseTauriSignaling())throw new Error("[pluto-rtc] Native IPC unavailable for startManagedSessionNative().");if(!await this.ensureNativeAuth("startManagedSessionNative",{requireToken:this.requiresNativeAuthToken(),maxWaitMs:this.nativeAuthWaitMs()}))throw new Error("Native auth token unavailable for startManagedSessionNative");let i=this.resolveNativeSignalingUserId(e.userId);if(!i)throw new Error("Native managed session startup requires a runtime auth-scoped user id.");i!==e.userId&&console.info("[NativeIpcBridge][managed-session][user-id-remap]",{requestedUserId:e.userId,runtimeUserId:this.currentUser?.id??this.getAuthContext()?.userId??null,effectiveUserId:i});let n=this.resolveConfiguredSpaceKey();console.info("[NativeIpcBridge][managed-session][start-request]",{requestedUserId:e.userId,runtimeUserId:this.currentUser?.id??this.getAuthContext()?.userId??null,effectiveUserId:i,spaceKey:n?"[configured]":null,deviceName:e.deviceName??null,localDeviceId:e.localDeviceId??null,presence:e.presence!==false,autoConnect:e.autoConnect!==false,hasMetadata:typeof e.metadata=="string"&&e.metadata.trim().length>0});let a=await this.buildNativeTransportConfigPayload(),o=this.usesCoordinationGateway(),r={userId:i,deviceName:e.deviceName??null,localDeviceId:e.localDeviceId??null,metadata:e.metadata??null,...a?{transports:a}:{},autoConnect:o?false:e.autoConnect!==false,presence:o?false:e.presence!==false,apiKey:this.options.apiKey??null,spaceKey:n||null},c=await this.invokeIpc("start_rtc_managed_session",r,{timeoutMs:null});this.syncNativeRuntimeCapabilities("managed-session-started");let l=typeof c?.ticket=="string"&&c.ticket.trim().length>0?c.ticket.trim():null,s=c?.localDevice&&typeof c.localDevice=="object"?c.localDevice:c?.local_device&&typeof c.local_device=="object"?c.local_device:null,u=s?{deviceId:typeof s.deviceId=="string"?s.deviceId:typeof s.device_id=="string"?s.device_id:"",deviceName:this.normalizeNativeDeviceName(typeof s.deviceName=="string"?s.deviceName:typeof s.device_name=="string"?s.device_name:""),platformType:typeof s.platformType=="string"?s.platformType:typeof s.platform_type=="string"?s.platform_type:"desktop",capabilities:s.capabilities??void 0,lastSeenAt:typeof s.lastSeenAt=="string"?s.lastSeenAt:typeof s.last_seen_at=="string"?s.last_seen_at:void 0}:null,d={localNodeId:typeof c?.localNodeId=="string"?c.localNodeId:typeof c?.local_node_id=="string"?c.local_node_id:null,ticket:l,ticketScope:typeof c?.ticketScope=="string"?c.ticketScope:typeof c?.ticket_scope=="string"?c.ticket_scope:null,presenceStarted:typeof c?.presenceStarted=="boolean"?c.presenceStarted:!!c?.presence_started,autoConnectStarted:typeof c?.autoConnectStarted=="boolean"?c.autoConnectStarted:!!c?.auto_connect_started,localDevice:u?.deviceId?u:null};if(o){e.presence!==false&&!d.ticket&&(d.ticket=await this.getEndpointTicketWithToken("user-device",0),d.ticketScope=d.ticket?"user-device":null);let y=d.localDevice?.deviceId||e.localDeviceId?.trim()||await this.resolveLocalDeviceId();if(y&&this.fallback.setCoordinationLocalDeviceId(y),e.presence!==false){if(!d.localNodeId||!d.ticket)throw new Error("Native managed session did not return the node identity required for gateway presence.");await this.fallback.updatePresence(d.localNodeId,d.ticket,true,3e5,e.metadata,d.localDevice?.deviceName||e.deviceName),d.presenceStarted=true;}else d.presenceStarted=false;e.autoConnect!==false&&y?(await this.startGatewayAutoConnect(i,y),d.autoConnectStarted=true):d.autoConnectStarted=false;}return console.info("[NativeIpcBridge][managed-session][ipc-started]",{requestedUserId:e.userId,runtimeUserId:this.currentUser?.id??this.getAuthContext()?.userId??null,effectiveUserId:i,localNodeId:d.localNodeId,ticketScope:d.ticketScope,presenceStarted:d.presenceStarted,autoConnectStarted:d.autoConnectStarted,localDeviceId:d.localDevice?.deviceId??null}),d}async reconcileNativeManagedSession(e){if(this.usesCoordinationGateway())return console.info("[NativeIpcBridge] native Firebase managed-session reconciliation is disabled in the staging gateway lane.",{reason:e?.reason??"frontend"}),null;if(!await this.shouldUseTauriSignaling())return null;if(!await this.ensureNativeAuth("reconcileNativeManagedSession",{requireToken:this.requiresNativeAuthToken(),maxWaitMs:this.nativeAuthWaitMs()}))throw new Error("Native auth token unavailable for reconcileNativeManagedSession");return this.invokeIpc("reconcile_mobile_rtc_after_resume",{reason:e?.reason??"frontend"})}async notifyNetworkChange(e){return await this.canUseTauriIpc()?(d("[NativeIpcBridge] forwarding host network-change hint",{reason:e?.reason??"host"}),this.invokeIpc("notify_rtc_network_change")):null}async getManagedNodeId(e){let t=e?.initializeIfMissing??true;console.info("[NativeIpcBridge][getManagedNodeId] enter",{initializeIfMissing:t});let i=await this.canUseTauriIpc();if(console.info("[NativeIpcBridge][getManagedNodeId] canUseTauriIpc",{canUse:i}),!i)return null;try{console.info("[NativeIpcBridge][getManagedNodeId] invoking get_iroh_node_id");let n=await this.invokeIpc("get_iroh_node_id");if(console.info("[NativeIpcBridge][getManagedNodeId] get_iroh_node_id returned",{existing:n}),n||!t)return n;console.info("[NativeIpcBridge][getManagedNodeId] invoking start_iroh_node");let a=await this.invokeIpc("start_iroh_node");return console.info("[NativeIpcBridge][getManagedNodeId] start_iroh_node returned",{started:a}),a}catch(n){if(console.warn("[NativeIpcBridge] getManagedNodeId failed:",n),!t)return null;throw n}}async getEndpointTicket(){if(!await this.canUseTauriIpc())throw new Error("[pluto-rtc] getEndpointTicket requires native IPC in Tauri runtime.");return O(()=>this.invokeIpc("get_iroh_endpoint_ticket"))}async connectToDevice(e){if(!await this.canUseTauriIpc())throw new Error("[pluto-rtc] connectToDevice requires native IPC in Tauri runtime.");this.options.authMode!=="anonymous"?await this.ensureNativeAuth("connectToDevice",{requireToken:true,maxWaitMs:g.AUTH_REQUIRED_WAIT_MS}):d("[NativeIpcBridge] connectToDevice using anonymous native ticket path");let t=Math.max(1,Math.floor(e.timeoutMs??g.DEFAULT_BOUNDED_IPC_TIMEOUT_MS));return this.invokeIpc("connect_to_device",{deviceId:e.deviceId??null,endpointTicket:e.endpointTicket,timeoutMs:t},{timeoutMs:t+1e3})}async registerSessionToken(e,t,i){await this.canUseTauriIpc()&&await this.invokeIpc("register_session_token",{token:e,scope:t,maxConnections:i});}async getEndpointTicketWithToken(e,t){if(!await this.canUseTauriIpc())return null;try{return await O(()=>this.invokeIpc("get_endpoint_ticket_with_token",{scope:e,maxConnections:t}))}catch{return null}}async validateSessionToken(e,t){if(!await this.canUseTauriIpc())return null;try{return await this.invokeIpc("validate_session_token",{token:e,connectionId:t??null})}catch{return null}}async revokeSessionTokensByScope(e){if(p("NativeIpcBridge.revokeSessionTokensByScope",{grantScope:e}),!await this.canUseTauriIpc())return [];try{return await this.invokeIpc("revoke_session_tokens_by_scope",{scope:e})}catch{return []}}async disconnectDevice(e){if(!await this.canUseTauriIpc())throw new Error("[pluto-rtc] disconnectDevice requires native IPC in Tauri runtime.");await this.invokeIpc("disconnect_device",{deviceId:e});}async setAutoConnectExcluded(e,t){await this.canUseTauriIpc()&&await this.invokeIpc(this.usesCoordinationGateway()?"set_rtc_external_auto_connect_excluded":"set_auto_connect_excluded",{deviceId:e,excluded:t});}onDevicesChange(e,t){if(this.usesCoordinationGateway())return this.fallback.onDevicesChange(e,t);let i=false,n=new Map,a=null,o=false,r=false,c=()=>{if(r=false,i)return;let d=Array.from(n.values());t&&(d=d.filter(y=>y.ticket!==t&&y.deviceId!==t&&y.nodeId!==t)),e(d);},l=()=>{if(!r){if(r=true,typeof queueMicrotask=="function"){queueMicrotask(c);return}Promise.resolve().then(c);}},s=async()=>{if(!await this.shouldUseTauriSignaling()){console.warn("[NativeIpcBridge] onDevicesChange falling back to wasm signaling (Tauri IPC unavailable)"),u$1=this.fallback.onDevicesChange(e,t);return}for(;!i;)try{let d$1=this.requiresNativeAuthToken()?15e3:0,y=Date.now()+d$1,v=this.getCurrentUserId();for(;!i&&!v&&Date.now()<y&&(this.hasLoggedMissingAuthForDevices||(this.hasLoggedMissingAuthForDevices=!0,d("[NativeIpcBridge] onDevicesChange waiting for authenticated user before subscription")),v=this.getCurrentUserId(),!v);)await u(250);if(!v){!i&&!o&&(console.warn("[NativeIpcBridge] onDevicesChange could not resolve authenticated user; keeping subscription in retry mode"),e([]),o=!0),await u(1e3);continue}if(!await this.ensureNativeAuth("onDevicesChange",{requireToken:this.requiresNativeAuthToken(),maxWaitMs:Math.max(0,y-Date.now())})){!i&&!o&&(console.warn("[NativeIpcBridge] onDevicesChange timed out waiting for auth token; keeping subscription in retry mode"),e([]),o=!0),await u(1e3);continue}this.hasLoggedMissingAuthForDevices=!1,o=!1,d(`[NativeIpcBridge] onDevicesChange starting subscription user_id=${v}`);let _=await this.listDevicesWithStatus().catch(async m=>(d(`[NativeIpcBridge] onDevicesChange full-roster seed failed; falling back to online-only search: ${m}`),this.searchDevices(t)));n.clear();for(let m of _)m?.deviceId&&n.set(m.deviceId,m);for(l(),a=(await this.subscribeDevices(v)).getReader();!i;){let{done:m,value:x}=await a.read();if(m||!x)break;for(let N of x){if(N.type==="removed"){n.delete(N.deviceId);continue}let M=N.device?.deviceId,R=this.nativeRosterTagDisposition(N.device??{});if(!R.keep){R.foreignTag&&d("[NativeIpcBridge] onDevicesChange dropped foreign-app device event",{sdkAppTag:this.appTag,foreignTag:R.foreignTag,deviceId:M??null}),M&&n.delete(M);continue}let E=this.normalizeDevice(N.device);E.deviceId&&n.set(E.deviceId,E);}l();}}catch(d){i||(console.error("[NativeIpcBridge] onDevicesChange stream failed; retrying subscription:",d),await u(1e3));}finally{if(a){try{await a.cancel();}catch{}a=null;}}},u$1=()=>{i=true,a&&(a.cancel(),a=null);};return s(),()=>u$1()}async subscribeDevices(e){if(this.usesCoordinationGateway())return this.fallback.subscribeDevices(e);if(await this.shouldUseTauriSignaling()){if(!await this.ensureNativeAuth("subscribeDevices",{requireToken:this.requiresNativeAuthToken(),maxWaitMs:this.nativeAuthWaitMs()}))throw new Error("Native auth token unavailable for subscribeDevices");let i=`sub-${Math.random().toString(36).substring(2,11)}`,n=null,a=null,o=false,r=async()=>{if(!o&&(o=true,n&&(await Promise.resolve(n()),n=null),a)){try{await a();}catch{}a=null;}};return new ReadableStream({start:async c$1=>{d(`[NativeIpcBridge] subscribeDevices request start user_id=${e} request_id=${i}`),n=await this.listenIpc("rtc-device-events",l=>{if(o)return;let s=l.payload;if(s.requestId===i){if(s.type==="deviceEvents"){let u=Array.isArray(s.events)?s.events.length:0;c(`[NativeIpcBridge] subscribeDevices event batch request_id=${i} count=${u}`);try{c$1.enqueue(s.events);}catch{r();}}else if(s.type==="error"&&(console.warn(`[NativeIpcBridge] subscribeDevices stream error request_id=${i}: ${s.message}`),!o)){try{c$1.error(s.message);}catch{}r();}}}),a=async()=>{await this.invokeIpc("stop_rtc_subscription",{requestId:i});};try{await this.invokeIpc("start_rtc_device_subscription",{requestId:i,userId:e});}catch(l){try{c$1.error(l);}catch{}await r();}},cancel:async()=>{d(`[NativeIpcBridge] subscribeDevices request stop request_id=${i}`),await r();}})}return this.fallback.subscribeDevices(e)}async subscribeSessions(e){if(this.usesCoordinationGateway())return this.fallback.subscribeSessions(e);if(await this.shouldUseTauriSignaling()){if(!await this.ensureNativeAuth("subscribeSessions",{requireToken:this.requiresNativeAuthToken(),maxWaitMs:this.nativeAuthWaitMs()}))throw new Error("Native auth token unavailable for subscribeSessions");let i=`sub-${Math.random().toString(36).substring(2,11)}`,n=await this.resolveLocalDeviceId()||e,a=null,o=null,r=false,c=async()=>{if(!r&&(r=true,a&&(await Promise.resolve(a()),a=null),o)){try{await o();}catch{}o=null;}};return new ReadableStream({start:async l=>{a=await this.listenIpc("rtc-session-events",s=>{if(r)return;let u=s.payload;if(u.requestId===i){if(u.type==="sessionEvents")try{l.enqueue(u.events);}catch{c();}else if(u.type==="error"&&!r){try{l.error(u.message);}catch{}c();}}}),o=async()=>{await this.invokeIpc("stop_rtc_subscription",{requestId:i});};try{await this.invokeIpc("start_rtc_session_subscription",{requestId:i,localDeviceId:n});}catch(s){try{l.error(s);}catch{}await c();}},cancel:async()=>{await c();}})}return this.fallback.subscribeSessions(e)}async getLocalDeviceId(){return this.resolveLocalDeviceId()}async updatePresence(e,t,i=true,n=3e5,a){if(this.usesCoordinationGateway())return await this.syncCoordinationDeviceIdentity(),this.fallback.updatePresence(e,t,i,n,a);if(await this.shouldUseTauriSignaling())try{if(!await this.ensureNativeAuth("updatePresence",{requireToken:this.requiresNativeAuthToken(),maxWaitMs:this.nativeAuthWaitMs()}))throw new Error("Native auth token unavailable for updatePresence");let r=this.resolveNativeSignalingUserId(),c=await this.resolveLocalDeviceId(),l=await this.resolveLocalDeviceName();await this.invokeIpc("update_rtc_presence",{userId:r,deviceName:l,ticket:t,metadata:this.withPresenceMetadata(a,c)});return}catch(o){console.warn("[NativeIpcBridge] update_rtc_presence failed:",o);}return this.fallback.updatePresence(e,t,i,n,a)}startAutoConnect(e,t){if(this.usesCoordinationGateway()){this.startGatewayAutoConnect(e,t).catch(i=>{console.warn("[NativeIpcBridge] staging gateway auto-connect failed:",i);});return}(async()=>{try{if(!await this.shouldUseTauriSignaling()){console.error("[NativeIpcBridge] startAutoConnect requires native Rust signaling; IPC unavailable");return}let i=await this.resolveLocalDeviceId()||t;await this.startAutoConnectOnce(e,i);}catch(i){console.warn("[NativeIpcBridge] startAutoConnect failed:",i);}})();}forceReconnectSnapshot(){if(this.usesCoordinationGateway()){console.info("[NativeIpcBridge] native Firebase reconnect snapshots are disabled in the staging gateway lane.");return}(async()=>{if(!await this.shouldUseTauriSignaling()){console.error("[NativeIpcBridge] forceReconnectSnapshot requires native Rust signaling; IPC unavailable");return}try{await this.invokeIpc("force_rtc_reconnect_snapshot");}catch(e){console.warn("[NativeIpcBridge] force_rtc_reconnect_snapshot failed:",e);}})();}startPresenceLoop(e,t,i,n,a){if(this.usesCoordinationGateway()){this.syncCoordinationDeviceIdentity().then(()=>this.fallback.startPresenceLoop(e,t,i,n,a));return}(async()=>{try{if(!await this.shouldUseTauriSignaling()){console.warn("[NativeIpcBridge] startPresenceLoop falling back to wasm signaling (Tauri IPC unavailable)"),this.fallback.startPresenceLoop(e,t,i,n,a);return}let o=await this.resolveLocalDeviceId(),r=this.shouldUseResolvedDeviceName(i)?await this.resolveLocalDeviceName():i.trim(),c=this.withPresenceMetadata(a,o);await this.startPresenceLoopOnce(e,t,r,n,c);}catch(o){console.warn("[NativeIpcBridge] startPresenceLoop failed:",o);}})();}async startAutoConnectOnce(e,t){if(this.usesCoordinationGateway()){await this.startGatewayAutoConnect(e,t);return}if(!await this.shouldUseTauriSignaling())throw new Error("[pluto-rtc] Native IPC unavailable for startAutoConnectOnce().");if(!await this.ensureNativeAuth("startAutoConnect",{requireToken:this.requiresNativeAuthToken(),maxWaitMs:this.nativeAuthWaitMs()}))throw new Error("Native auth token unavailable for startAutoConnect");let n=this.resolveNativeSignalingUserId(e);if(!n)throw new Error("Native auto-connect requires a runtime auth-scoped user id.");await this.invokeIpc("start_rtc_auto_connect",{userId:n,localDeviceId:t});}stopGatewayDesiredPeerRelay(){this.gatewayDesiredPeersCleanup?.(),this.gatewayDesiredPeersCleanup=null,this.gatewayDesiredPeerRevision=0,this.gatewayDesiredPeerSubmission=Promise.resolve();}async startGatewayAutoConnect(e,t){if(!await this.shouldUseTauriSignaling())throw new Error("[openrtc] Native IPC unavailable for staging gateway auto-connect.");if(!await this.ensureNativeAuth("startGatewayAutoConnect",{requireToken:this.requiresNativeAuthToken(),maxWaitMs:this.nativeAuthWaitMs()}))throw new Error("Native auth token unavailable for staging gateway auto-connect");let n=this.resolveNativeSignalingUserId(e);if(!n)throw new Error("Staging gateway auto-connect requires an authenticated user id.");let a=await this.resolveLocalDeviceId()||t.trim();if(!a)throw new Error("Staging gateway auto-connect requires a local device id.");this.fallback.setCoordinationLocalDeviceId(a),this.stopGatewayDesiredPeerRelay(),await this.invokeIpc("start_rtc_external_auto_connect",{userId:n,localDeviceId:a}),this.gatewayDesiredPeersCleanup=this.fallback.onDevicesChange(o=>{let r=o.map(l=>({deviceId:String(l.deviceId??"").trim(),nodeId:typeof l.nodeId=="string"&&l.nodeId.trim()||null,ticket:typeof l.ticket=="string"&&l.ticket.trim()||null,online:l.online===true,sessionId:typeof l.sessionId=="string"&&l.sessionId.trim()||null,excludedPeers:Array.isArray(l.excludedPeers)?[...new Set(l.excludedPeers.map(s=>String(s??"").trim().toLowerCase()).filter(Boolean))].sort():[]})).filter(l=>l.deviceId.length>0).sort((l,s)=>l.deviceId.localeCompare(s.deviceId)),c=++this.gatewayDesiredPeerRevision;this.gatewayDesiredPeerSubmission=this.gatewayDesiredPeerSubmission.then(async()=>{await this.invokeIpc("submit_rtc_desired_peers",{revision:c,peersJson:JSON.stringify(r)});}).catch(l=>{console.warn("[NativeIpcBridge] failed to relay gateway desired peers to Rust:",{revision:c,error:l});});},a);}async startPresenceLoopOnce(e,t,i,n,a){if(this.usesCoordinationGateway()){await this.syncCoordinationDeviceIdentity(),await this.fallback.startPresenceLoop(e,t,i,n,a);return}if(!await this.shouldUseTauriSignaling())throw new Error("[pluto-rtc] Native IPC unavailable for startPresenceLoopOnce().");if(console.info("[NativeIpcBridge][presence][start-request]",{userId:e,localNodeId:t,deviceName:i,hasMetadata:typeof a=="string"&&a.trim().length>0,hasCompoundTicket:typeof n=="string"&&n.includes(".")}),!await this.ensureNativeAuth("startPresenceLoop",{requireToken:this.requiresNativeAuthToken(),maxWaitMs:this.nativeAuthWaitMs()}))throw new Error("Native auth token unavailable for startPresenceLoop");let r=this.resolveNativeSignalingUserId(e);if(!r)throw new Error("Native presence loop requires a runtime auth-scoped user id.");console.info("[NativeIpcBridge][presence][auth-ready]",{requestedUserId:e,runtimeUserId:this.currentUser?.id??this.getAuthContext()?.userId??null,effectiveUserId:r,localNodeId:t}),await this.invokeIpc("start_rtc_presence_loop",{userId:r,localNodeId:t,deviceName:i,ticket:n,metadata:a,apiKey:this.options.apiKey??null,spaceKey:this.resolveConfiguredSpaceKey()||null}),console.info("[NativeIpcBridge][presence][ipc-started]",{requestedUserId:e,effectiveUserId:r,localNodeId:t,deviceName:i});}shouldUseResolvedDeviceName(e){let t=e.trim();return t.length===0||t==="Unknown Device"||t==="Desktop Device"}async sendExplicitFilePath(e,t,i=""){if(d("[NativeIpcBridge] sendExplicitFilePath start",{connectionId:e,filePath:t,transferId:i||null,authMode:this.options.authMode}),await this.canUseTauriIpc()){this.options.authMode!=="anonymous"?await this.ensureNativeAuth("sendExplicitFilePath"):d("[NativeIpcBridge] sendExplicitFilePath using anonymous native path");let n=await this.invokeIpc("send_file",{connectionId:e,filePath:t,transferId:i});return d("[NativeIpcBridge] sendExplicitFilePath completed",{connectionId:e,transferId:i||null,result:n}),n}return this.fallback.sendExplicitFilePath(e,t,i)}async sendExplicitFileData(e){d("[NativeIpcBridge] sendExplicitFileData start",{connectionId:e.connectionId??null,connectionRemoteNodeId:e.connection?.remoteNodeId??null,remoteNodeId:e.remoteNodeId??null,transferId:e.transferId??null,fileName:e.file.name,fileSize:e.file.size,authMode:this.options.authMode});let t=e.applicationCrypto??this.options.applicationCrypto;if(await this.canUseTauriIpc()){this.options.authMode!=="anonymous"?await this.ensureNativeAuth("sendExplicitFileData"):d("[NativeIpcBridge] sendExplicitFileData using anonymous native path");let i=e.connectionId||e.connection?.deviceId||e.connection?.remoteNodeId||e.remoteNodeId||"";if(!i)throw new Error("sendExplicitFileData requires a settled peer identifier in native runtime");let n=new Uint8Array(await e.file.arrayBuffer());await this.invokeIpc("send_file_data",{connectionId:i,filename:e.file.name,data:Array.from(n),transferId:e.transferId}),d("[NativeIpcBridge] sendExplicitFileData completed",{connectionId:i,transferId:e.transferId??null,fileName:e.file.name,fileSize:e.file.size});return}return this.fallback.sendExplicitFileData({...e,applicationCrypto:t})}async getConnectionStates(){if(await this.canUseTauriIpc())try{this.options.authMode!=="anonymous"&&await this.ensureNativeAuth("getConnectionStates");let e=await this.invokeIpc("list_rtc_connection_states");return (Array.isArray(e)?e:[]).map(t=>w(t)).filter(t=>!!t)}catch(e){return L(e)?d("[NativeIpcBridge] native connection-state replay unavailable; continuing without replay. Install/register openrtc-tauri-plugin default permissions to enable it."):console.warn("[NativeIpcBridge] Failed to fetch native connection states:",e),[]}return []}async getConnectionState(e){let t=e.trim();if(!t||!await this.canUseTauriIpc())return null;try{return this.options.authMode!=="anonymous"&&await this.ensureNativeAuth("getConnectionState"),w(await this.invokeIpc("get_rtc_connection_state",{connectionId:t}))}catch(i){return console.warn("[NativeIpcBridge] Failed to fetch native connection state:",{connectionId:t,error:i}),null}}async onConnectionStateChange(e){let t=false,i=null,n=new Map,a=Date.now(),o=0,r=()=>{let s=i;s&&Promise.resolve(s());},c$1=async()=>{try{let s=await this.getConnectionStates();s.length>0&&(c("[NativeIpcBridge] replaying current native connection states",s.map(u=>({connectionId:u.connectionId,deviceId:u.deviceId??null,deviceIdHint:u.deviceIdHint??null,remoteNodeId:u.remoteNodeId??null,state:u.state,transportState:u.transportState??null,protocolState:u.protocolState??null,routable:u.routable??null}))),s.forEach(u=>e(u)));}catch(s){console.warn("[NativeIpcBridge] Failed to replay native connection states after event subscription:",s);}},l=async s=>{let u$1=(n.get(s)??0)+1;n.set(s,u$1);let d=await this.getConnectionState(s);if(!d||t||n.get(s)!==u$1)return;if(["closed","failed","disconnected"].includes(String(d.state??"").trim().toLowerCase())){if(await u(g.CONNECTION_TERMINAL_CONFIRMATION_MS),t||n.get(s)!==u$1)return;d=await this.getConnectionState(s)??d;}!t&&n.get(s)===u$1&&e(d);};for(;!t&&Date.now()-a<=g.CONNECTION_EVENT_SUBSCRIBE_WINDOW_MS;){if(o+=1,!await this.canUseTauriIpc()){await u(this.nextConnectionEventRetryDelayMs(o));continue}return i=await this.listenIpc("connection-state-changed",s=>{let u=w(s?.payload);u&&(c("[NativeIpcBridge] connection-state-changed trigger",{connectionId:u.connectionId}),l(u.connectionId));}),await c$1(),()=>{t=true,r();}}return ()=>{t=true,r();}}async onIncomingNativeMessage(e){if(!await this.canUseTauriIpc())return ()=>{};let t=await this.listenIpc("iroh://message",i=>{if(i?.payload?.data&&i.payload.streamId==="main")try{let n=new Uint8Array(i.payload.data);if(n.length<2||n[0]!==0)return;let o=n.slice(1),r=new TextDecoder().decode(o),c=JSON.parse(r);e(i.payload.connectionId,i.payload.remoteNodeId??null,c);}catch{}});return typeof t=="function"?t:()=>{}}async getTransferHistory(e=50){return await this.canUseTauriIpc()?this.invokeIpc("get_transfer_history",{limit:e}):[]}async deleteTransferJob(e){await this.canUseTauriIpc()&&await this.invokeIpc("delete_transfer_job",{jobId:e});}};g.AUTH_REQUIRED_WAIT_MS=x.nativeIpc.authRequiredWaitMs,g.DEFAULT_BOUNDED_IPC_TIMEOUT_MS=x.nativeIpc.defaultBoundedCommandTimeoutMs,g.CONNECTION_EVENT_SUBSCRIBE_WINDOW_MS=x.nativeIpc.connectionEventSubscribeWindowMs,g.CONNECTION_EVENT_RETRY_MIN_DELAY_MS=x.nativeIpc.connectionEventRetryMinDelayMs,g.CONNECTION_EVENT_RETRY_MAX_DELAY_MS=x.nativeIpc.connectionEventRetryMaxDelayMs,g.CONNECTION_TERMINAL_CONFIRMATION_MS=1500,g.TAURI_IPC_NEGATIVE_CACHE_MS=x.nativeIpc.tauriIpcNegativeCacheMs,g.NATIVE_STATUS_IPC_TIMEOUT_MS=2500;var D=g;var te=class extends G{constructor(e){let t=T(e.bridge,"IpcRuntimeAdapter");super(new D({...e,ipcBridge:t,allowWasmFallback:e.allowWasmFallback??false}));}};
|
|
2
2
|
export{Z as a,X as b,ee as c,O as d,ie as e,L as f,Q as g,te as h};
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import {a,b}from'./chunk-
|
|
1
|
+
import {a,b}from'./chunk-HFWOWDEH.js';export{e as createPublicSpaceTokenProvider,h as createSpaceTokenProvider,c as enableSpaceAuth,d as mintSpaceToken,f as sandboxSpaceKey,g as spaceToken}from'./chunk-HFWOWDEH.js';import {a as a$1,b as b$1}from'./chunk-TOO3FUPK.js';export{d as KEY_AGREEMENT_ALGORITHM,c as KEY_AGREEMENT_PUBLIC_KEY_BYTES,h as ScopedSession,w as createRuntimeJsonFrameDecoder,s as createRuntimeU32BEFrameDecoder,u as decodeRuntimeJsonPayload,f as deriveApplicationCryptoKey,g as encodeApplicationKeyAgreementPayload,v as encodeRuntimeJsonFrame,t as encodeRuntimeJsonPayload,r as encodeRuntimeU32BEFrame,e as generateEphemeralKeyAgreement,b as getPreferredProtocolOrder}from'./chunk-6J3QKQRS.js';export{a as isRuntimeDeviceActive,c as isRuntimeDeviceConnectable,b as isRuntimeDeviceRoutable}from'./chunk-CK6WQV7J.js';import'./chunk-TW4HQLK6.js';import {g}from'./chunk-W5YFLH2U.js';export{x as OPENRTC_RUNTIME_POLICY,o as createApplicationCryptoStreamTools,n as createSharedSecretApplicationCrypto,y as getRuntimePolicy,m as isApplicationEncryptedPayload}from'./chunk-JGBEYISL.js';export{a as TRANSPORT_LABELS,d as isDirectIrohTransportLabel,h as isIndependentTransportLabel,c as isIrohBaseTransportLabel,e as isOptionalTransportLabel,f as isWebRtcTransportLabel,b as normalizeTransportLabel}from'./chunk-QT2ASNI3.js';import'./chunk-SVBFZRGV.js';export{a as ROUTE_DESCRIPTORS,e as getRouteDescriptor,f as listRouteDescriptors}from'./chunk-C7YN5MSV.js';function s(e){let t=a(e),o=a$1(t);return b(o,"web")}s.native=function(e,t){let o=a(e),c=t??g(),m=b$1(o,c);return b(m,"native")};export{s as OpenRTC};
|
package/dist/native.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import {a,b}from'./chunk-
|
|
1
|
+
import {a,b}from'./chunk-HFWOWDEH.js';export{e as createPublicSpaceTokenProvider,h as createSpaceTokenProvider,c as enableSpaceAuth,d as mintSpaceToken,f as sandboxSpaceKey,g as spaceToken}from'./chunk-HFWOWDEH.js';import {A as A$1}from'./chunk-6J3QKQRS.js';import {h}from'./chunk-W5YFLH2U.js';export{e as classifyNativeIpcFailure,f as isNativeIpcCommandUnavailable}from'./chunk-W5YFLH2U.js';import'./chunk-JGBEYISL.js';import'./chunk-QT2ASNI3.js';import {s}from'./chunk-SVBFZRGV.js';import'./chunk-C7YN5MSV.js';function c(t,p){let e=s(t);return A$1(e,new h({...e,bridge:p}))}function A(t,p){let e=c(a(t),p);return b(e,"native")}export{A as createNativeOpenRTC};
|