openrtc 2.0.0-rc.7 → 2.0.0-rc.8

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.
@@ -1 +1 @@
1
- import {f}from'./chunk-NRO64VRR.js';import {d}from'./chunk-K37WVIZL.js';function c(){return d()}var i=class extends f{constructor(r){super({...r,bridge:d(),allowWasmFallback:r.allowWasmFallback??false});}};export{c as a,i as b};
1
+ import {f}from'./chunk-A7AMB23L.js';import {d}from'./chunk-K37WVIZL.js';function c(){return d()}var i=class extends f{constructor(r){super({...r,bridge:d(),allowWasmFallback:r.allowWasmFallback??false});}};export{c as a,i as b};
@@ -0,0 +1 @@
1
+ export{b as createIpcClient,a as createWasmClient}from'./chunk-D45U2NXV.js';import'./chunk-IAIGT5G3.js';import'./chunk-NCL672QJ.js';import'./chunk-A7AMB23L.js';import'./chunk-C6PAXO3N.js';import'./chunk-7Z6N46RB.js';import'./chunk-JIVVHBCB.js';import'./chunk-VK6KX433.js';import'./chunk-NT5YHZQH.js';import'./chunk-K37WVIZL.js';import'./chunk-BXFXPIXO.js';import'./chunk-N26S7V4N.js';import'./chunk-NB4H5TP3.js';import'./chunk-RD3JEGGF.js';import'./chunk-C7YN5MSV.js';
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import {a}from'./chunk-BY3EPIAB.js';import {c}from'./chunk-IAEGDK4P.js';export{a as OPENRTC_ERROR_CODES,b as OpenRtcError,e as classifyOpenRtcFailure,d as openRtcError,c as projectOpenRtcErrorFields}from'./chunk-NT5YHZQH.js';import {d}from'./chunk-K37WVIZL.js';function i(p){return c(p,{platform:"web",runtimeFactory:async e=>{let{createWasmClient:t}=await import('./factories-JWIRMXCV.js');return t(e)}})}i.native=function(p,e=d()){return c(p,{platform:"native",deviceKeyProvider:a(e),deviceIdProvider:async()=>{let t=await e.invoke("get_rtc_local_device_info");return String(t?.deviceId??"")},runtimeFactory:async t=>{let{createIpcClient:a}=await import('./ipcFactory-UAVK2YED.js');return a(t,e)}})};export{i as OpenRTC};
1
+ import {a}from'./chunk-BY3EPIAB.js';import {c}from'./chunk-IAEGDK4P.js';export{a as OPENRTC_ERROR_CODES,b as OpenRtcError,e as classifyOpenRtcFailure,d as openRtcError,c as projectOpenRtcErrorFields}from'./chunk-NT5YHZQH.js';import {d}from'./chunk-K37WVIZL.js';function i(p){return c(p,{platform:"web",runtimeFactory:async e=>{let{createWasmClient:t}=await import('./factories-TLUZAXUG.js');return t(e)}})}i.native=function(p,e=d()){return c(p,{platform:"native",deviceKeyProvider:a(e),deviceIdProvider:async()=>{let t=await e.invoke("get_rtc_local_device_info");return String(t?.deviceId??"")},runtimeFactory:async t=>{let{createIpcClient:a}=await import('./ipcFactory-QOAZVE56.js');return a(t,e)}})};export{i as OpenRTC};
@@ -0,0 +1 @@
1
+ export{a as createIpcClient}from'./chunk-EUNCYGJD.js';import'./chunk-IAIGT5G3.js';import'./chunk-NCL672QJ.js';import'./chunk-A7AMB23L.js';import'./chunk-C6PAXO3N.js';import'./chunk-7Z6N46RB.js';import'./chunk-JIVVHBCB.js';import'./chunk-VK6KX433.js';import'./chunk-NT5YHZQH.js';import'./chunk-K37WVIZL.js';import'./chunk-BXFXPIXO.js';import'./chunk-N26S7V4N.js';import'./chunk-NB4H5TP3.js';import'./chunk-RD3JEGGF.js';import'./chunk-C7YN5MSV.js';
package/dist/native.js CHANGED
@@ -1 +1 @@
1
- import {a}from'./chunk-BY3EPIAB.js';import {c}from'./chunk-IAEGDK4P.js';export{a as classifyNativeIpcFailure,b as isNativeIpcCommandUnavailable}from'./chunk-K37WVIZL.js';function m(n,e){return c(n,{platform:"native",deviceKeyProvider:a(e),deviceIdProvider:async()=>{let t=await e.invoke("get_rtc_local_device_info");return String(t?.deviceId??"")},runtimeFactory:async t=>{let{createIpcClient:o}=await import('./ipcFactory-UAVK2YED.js');return o(t,e)}})}export{m as createNativeOpenRTC};
1
+ import {a}from'./chunk-BY3EPIAB.js';import {c}from'./chunk-IAEGDK4P.js';export{a as classifyNativeIpcFailure,b as isNativeIpcCommandUnavailable}from'./chunk-K37WVIZL.js';function m(n,e){return c(n,{platform:"native",deviceKeyProvider:a(e),deviceIdProvider:async()=>{let t=await e.invoke("get_rtc_local_device_info");return String(t?.deviceId??"")},runtimeFactory:async t=>{let{createIpcClient:o}=await import('./ipcFactory-QOAZVE56.js');return o(t,e)}})}export{m as createNativeOpenRTC};
@@ -1,2 +1,2 @@
1
- var z=class s{static __wrap(t){let e=Object.create(s.prototype);return e.__wbg_ptr=t,K.register(e,e.__wbg_ptr,e),e}__destroy_into_raw(){let t=this.__wbg_ptr;return this.__wbg_ptr=0,K.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 _=f().getInt32(i+0,!0),r=f().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 p(t)}get recv(){let t=n.bistream_recv(this.__wbg_ptr);return p(t)}get send(){let t=n.bistream_send(this.__wbg_ptr);return p(t)}};Symbol.dispose&&(z.prototype[Symbol.dispose]=z.prototype.free);var U=class{__destroy_into_raw(){let t=this.__wbg_ptr;return this.__wbg_ptr=0,kt.unregister(this),t}free(){let t=this.__destroy_into_raw();n.__wbg_intounderlyingbytesource_free(t,0);}get autoAllocateChunkSize(){return n.intounderlyingbytesource_autoAllocateChunkSize(this.__wbg_ptr)>>>0}cancel(){let t=this.__destroy_into_raw();n.intounderlyingbytesource_cancel(t);}pull(t){let e=n.intounderlyingbytesource_pull(this.__wbg_ptr,w(t));return p(e)}start(t){n.intounderlyingbytesource_start(this.__wbg_ptr,w(t));}get type(){let t=n.intounderlyingbytesource_type(this.__wbg_ptr);return mt[t]}};Symbol.dispose&&(U.prototype[Symbol.dispose]=U.prototype.free);var B=class s{static __wrap(t){let e=Object.create(s.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_intounderlyingsink_free(t,0);}abort(t){let e=this.__destroy_into_raw(),_=n.intounderlyingsink_abort(e,w(t));return p(_)}close(){let t=this.__destroy_into_raw(),e=n.intounderlyingsink_close(t);return p(e)}write(t){let e=n.intounderlyingsink_write(this.__wbg_ptr,w(t));return p(e)}};Symbol.dispose&&(B.prototype[Symbol.dispose]=B.prototype.free);var N=class s{static __wrap(t){let e=Object.create(s.prototype);return e.__wbg_ptr=t,J.register(e,e.__wbg_ptr,e),e}__destroy_into_raw(){let t=this.__wbg_ptr;return this.__wbg_ptr=0,J.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,w(t));return p(e)}};Symbol.dispose&&(N.prototype[Symbol.dispose]=N.prototype.free);var q=class s{static __wrap(t){let e=Object.create(s.prototype);return e.__wbg_ptr=t,Y.register(e,e.__wbg_ptr,e),e}__destroy_into_raw(){let t=this.__wbg_ptr;return this.__wbg_ptr=0,Y.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 p(t)}get writable(){let t=n.peerunistream_writable(this.__wbg_ptr);return p(t)}};Symbol.dispose&&(q.prototype[Symbol.dispose]=q.prototype.free);var D=class s{static __wrap(t){let e=Object.create(s.prototype);return e.__wbg_ptr=t,Q.register(e,e.__wbg_ptr,e),e}__destroy_into_raw(){let t=this.__wbg_ptr;return this.__wbg_ptr=0,Q.unregister(this),t}free(){let t=this.__destroy_into_raw();n.__wbg_wasmclient_free(t,0);}add_peer_scope(t,e){let _=b(t,n.__wbindgen_export,n.__wbindgen_export2),r=c,i=b(e,n.__wbindgen_export,n.__wbindgen_export2),a=c,g=n.wasmclient_add_peer_scope(this.__wbg_ptr,_,r,i,a);return p(g)}bind_connection_device_id(t,e){let _=b(t,n.__wbindgen_export,n.__wbindgen_export2),r=c,i=b(e,n.__wbindgen_export,n.__wbindgen_export2),a=c,g=n.wasmclient_bind_connection_device_id(this.__wbg_ptr,_,r,i,a);return p(g)}bind_node_device_id(t,e){let _=b(t,n.__wbindgen_export,n.__wbindgen_export2),r=c,i=b(e,n.__wbindgen_export,n.__wbindgen_export2),a=c,g=n.wasmclient_bind_node_device_id(this.__wbg_ptr,_,r,i,a);return p(g)}clearConnectionApplicationCryptoKey(t){let e=b(t,n.__wbindgen_export,n.__wbindgen_export2),_=c;n.wasmclient_clearConnectionApplicationCryptoKey(this.__wbg_ptr,e,_);}clearIdentityCredential(){n.wasmclient_clearIdentityCredential(this.__wbg_ptr);}clear_session_tokens(){n.wasmclient_clear_session_tokens(this.__wbg_ptr);}confirm_inline_reciprocal_session_admission(t,e,_,r,i,a){let g=b(t,n.__wbindgen_export,n.__wbindgen_export2),d=c,x=b(_,n.__wbindgen_export,n.__wbindgen_export2),l=c,h=b(r,n.__wbindgen_export,n.__wbindgen_export2),y=c;var k=u(a)?0:b(a,n.__wbindgen_export,n.__wbindgen_export2),I=c;let R=n.wasmclient_confirm_inline_reciprocal_session_admission(this.__wbg_ptr,g,d,e,x,l,h,y,i,k,I);return p(R)}connect(t){let e=b(t,n.__wbindgen_export,n.__wbindgen_export2),_=c,r=n.wasmclient_connect(this.__wbg_ptr,e,_);return p(r)}connect_device(t,e){var _=u(t)?0:b(t,n.__wbindgen_export,n.__wbindgen_export2),r=c;let i=b(e,n.__wbindgen_export,n.__wbindgen_export2),a=c,g=n.wasmclient_connect_device(this.__wbg_ptr,_,r,i,a);return p(g)}connection_state(t){let e=b(t,n.__wbindgen_export,n.__wbindgen_export2),_=c,r=n.wasmclient_connection_state(this.__wbg_ptr,e,_);return p(r)}connection_states(){let t=n.wasmclient_connection_states(this.__wbg_ptr);return p(t)}create_room(t,e,_,r,i,a){let g=b(t,n.__wbindgen_export,n.__wbindgen_export2),d=c,x=b(e,n.__wbindgen_export,n.__wbindgen_export2),l=c,h=b(_,n.__wbindgen_export,n.__wbindgen_export2),y=c,k=b(r,n.__wbindgen_export,n.__wbindgen_export2),I=c,R=b(i,n.__wbindgen_export,n.__wbindgen_export2),C=c,X=n.wasmclient_create_room(this.__wbg_ptr,g,d,x,l,h,y,k,I,R,C,u(a)?Number.MAX_SAFE_INTEGER:a>>>0);return p(X)}create_session(t){let e=b(t,n.__wbindgen_export,n.__wbindgen_export2),_=c,r=n.wasmclient_create_session(this.__wbg_ptr,e,_);return p(r)}delete_device(t,e){let _=b(t,n.__wbindgen_export,n.__wbindgen_export2),r=c,i=b(e,n.__wbindgen_export,n.__wbindgen_export2),a=c,g=n.wasmclient_delete_device(this.__wbg_ptr,_,r,i,a);return p(g)}devices_with_status(t){let e=b(t,n.__wbindgen_export,n.__wbindgen_export2),_=c,r=n.wasmclient_devices_with_status(this.__wbg_ptr,e,_);return p(r)}disconnect(t){let e=b(t,n.__wbindgen_export,n.__wbindgen_export2),_=c,r=n.wasmclient_disconnect(this.__wbg_ptr,e,_);return p(r)}disconnect_device(t,e){let _=b(t,n.__wbindgen_export,n.__wbindgen_export2),r=c;var i=u(e)?0:b(e,n.__wbindgen_export,n.__wbindgen_export2),a=c;let g=n.wasmclient_disconnect_device(this.__wbg_ptr,_,r,i,a);return p(g)}disconnect_transient(t){let e=b(t,n.__wbindgen_export,n.__wbindgen_export2),_=c,r=n.wasmclient_disconnect_transient(this.__wbg_ptr,e,_);return p(r)}endpoint_id_from_ticket(t){let e,_;try{let l=n.__wbindgen_add_to_stack_pointer(-16),h=b(t,n.__wbindgen_export,n.__wbindgen_export2),y=c;n.wasmclient_endpoint_id_from_ticket(l,this.__wbg_ptr,h,y);var r=f().getInt32(l+0,!0),i=f().getInt32(l+4,!0),a=f().getInt32(l+8,!0),g=f().getInt32(l+12,!0),d=r,x=i;if(g)throw d=0,x=0,p(a);return e=d,_=x,v(d,x)}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 p(t)}endpoint_ticket_with_token(t,e){let _=b(t,n.__wbindgen_export,n.__wbindgen_export2),r=c,i=n.wasmclient_endpoint_ticket_with_token(this.__wbg_ptr,_,r,e);return p(i)}force_reconnect_snapshot(){n.wasmclient_force_reconnect_snapshot(this.__wbg_ptr);}get_members(t,e,_){let r=b(t,n.__wbindgen_export,n.__wbindgen_export2),i=c,a=b(e,n.__wbindgen_export,n.__wbindgen_export2),g=c,d=b(_,n.__wbindgen_export,n.__wbindgen_export2),x=c,l=n.wasmclient_get_members(this.__wbg_ptr,r,i,a,g,d,x);return p(l)}heartbeat_tick(t,e,_){let r=b(t,n.__wbindgen_export,n.__wbindgen_export2),i=c,a=b(e,n.__wbindgen_export,n.__wbindgen_export2),g=c,d=b(_,n.__wbindgen_export,n.__wbindgen_export2),x=c,l=n.wasmclient_heartbeat_tick(this.__wbg_ptr,r,i,a,g,d,x);return p(l)}incoming_streams(){let t=n.wasmclient_incoming_streams(this.__wbg_ptr);return p(t)}initIrohWithTestRelay(t,e){var _=u(t)?0:j(t,n.__wbindgen_export),r=c,i=u(e)?0:b(e,n.__wbindgen_export,n.__wbindgen_export2),a=c;let g=n.wasmclient_initIrohWithTestRelay(this.__wbg_ptr,_,r,i,a);return p(g)}init_iroh(t){var e=u(t)?0:j(t,n.__wbindgen_export),_=c;let r=n.wasmclient_init_iroh(this.__wbg_ptr,e,_);return p(r)}iroh_path_kind(t){let e=b(t,n.__wbindgen_export,n.__wbindgen_export2),_=c,r=n.wasmclient_iroh_path_kind(this.__wbg_ptr,e,_);return p(r)}iroh_secret_key(){let t=n.wasmclient_iroh_secret_key(this.__wbg_ptr);return p(t)}iroh_transport_rtt_ms(t){let e=b(t,n.__wbindgen_export,n.__wbindgen_export2),_=c,r=n.wasmclient_iroh_transport_rtt_ms(this.__wbg_ptr,e,_);return p(r)}is_auto_connect_excluded(t){let e=b(t,n.__wbindgen_export,n.__wbindgen_export2),_=c;return n.wasmclient_is_auto_connect_excluded(this.__wbg_ptr,e,_)!==0}is_connected(t){let e=b(t,n.__wbindgen_export,n.__wbindgen_export2),_=c,r=n.wasmclient_is_connected(this.__wbg_ptr,e,_);return p(r)}is_current_transport_stable_id(t,e){let _=b(t,n.__wbindgen_export,n.__wbindgen_export2),r=c,i=n.wasmclient_is_current_transport_stable_id(this.__wbg_ptr,_,r,e);return p(i)}join_room(t,e,_,r,i){let a=b(t,n.__wbindgen_export,n.__wbindgen_export2),g=c,d=b(e,n.__wbindgen_export,n.__wbindgen_export2),x=c,l=b(_,n.__wbindgen_export,n.__wbindgen_export2),h=c,y=b(r,n.__wbindgen_export,n.__wbindgen_export2),k=c,I=b(i,n.__wbindgen_export,n.__wbindgen_export2),R=c,C=n.wasmclient_join_room(this.__wbg_ptr,a,g,d,x,l,h,y,k,I,R);return p(C)}leave_room(t,e,_){let r=b(t,n.__wbindgen_export,n.__wbindgen_export2),i=c,a=b(e,n.__wbindgen_export,n.__wbindgen_export2),g=c,d=b(_,n.__wbindgen_export,n.__wbindgen_export2),x=c,l=n.wasmclient_leave_room(this.__wbg_ptr,r,i,a,g,d,x);return p(l)}list_managed_connections(){let t=n.wasmclient_list_managed_connections(this.__wbg_ptr);return p(t)}static newV2(t){try{let i=n.__wbindgen_add_to_stack_pointer(-16),a=b(t,n.__wbindgen_export,n.__wbindgen_export2),g=c;n.wasmclient_newV2(i,a,g);var e=f().getInt32(i+0,!0),_=f().getInt32(i+4,!0),r=f().getInt32(i+8,!0);if(r)throw p(_);return s.__wrap(e)}finally{n.__wbindgen_add_to_stack_pointer(16);}}node_addr(){let t=n.wasmclient_node_addr(this.__wbg_ptr);return p(t)}open_bi(t){let e=b(t,n.__wbindgen_export,n.__wbindgen_export2),_=c,r=n.wasmclient_open_bi(this.__wbg_ptr,e,_);return p(r)}open_native_main_control_bi(t){let e=b(t,n.__wbindgen_export,n.__wbindgen_export2),_=c,r=n.wasmclient_open_native_main_control_bi(this.__wbg_ptr,e,_);return p(r)}open_peer_bi(t,e){let _=b(t,n.__wbindgen_export,n.__wbindgen_export2),r=c,i=n.wasmclient_open_peer_bi(this.__wbg_ptr,_,r,u(e)?Number.MAX_SAFE_INTEGER:e>>>0);return p(i)}open_peer_bi_explicit_file_sender(t,e){let _=b(t,n.__wbindgen_export,n.__wbindgen_export2),r=c,i=n.wasmclient_open_peer_bi_explicit_file_sender(this.__wbg_ptr,_,r,u(e)?Number.MAX_SAFE_INTEGER:e>>>0);return p(i)}open_peer_bi_transport_only(t,e){let _=b(t,n.__wbindgen_export,n.__wbindgen_export2),r=c,i=n.wasmclient_open_peer_bi_transport_only(this.__wbg_ptr,_,r,u(e)?Number.MAX_SAFE_INTEGER:e>>>0);return p(i)}open_peer_native_bi(t,e,_){let r=b(t,n.__wbindgen_export,n.__wbindgen_export2),i=c,a=b(e,n.__wbindgen_export,n.__wbindgen_export2),g=c,d=n.wasmclient_open_peer_native_bi(this.__wbg_ptr,r,i,a,g,u(_)?Number.MAX_SAFE_INTEGER:_>>>0);return p(d)}open_peer_uni(t,e){let _=b(t,n.__wbindgen_export,n.__wbindgen_export2),r=c,i=n.wasmclient_open_peer_uni(this.__wbg_ptr,_,r,u(e)?Number.MAX_SAFE_INTEGER:e>>>0);return p(i)}open_uni(t){let e=b(t,n.__wbindgen_export,n.__wbindgen_export2),_=c,r=n.wasmclient_open_uni(this.__wbg_ptr,e,_);return p(r)}peer_scopes(t){let e=b(t,n.__wbindgen_export,n.__wbindgen_export2),_=c,r=n.wasmclient_peer_scopes(this.__wbg_ptr,e,_);return p(r)}peer_session(t){let e=b(t,n.__wbindgen_export,n.__wbindgen_export2),_=c,r=n.wasmclient_peer_session(this.__wbg_ptr,e,_);return p(r)}peer_sessions(){let t=n.wasmclient_peer_sessions(this.__wbg_ptr);return p(t)}peer_snapshot(t){let e=b(t,n.__wbindgen_export,n.__wbindgen_export2),_=c,r=n.wasmclient_peer_snapshot(this.__wbg_ptr,e,_);return p(r)}prepare_inline_reciprocal_session_admission(t,e,_,r,i,a,g,d){let x=b(t,n.__wbindgen_export,n.__wbindgen_export2),l=c,h=b(_,n.__wbindgen_export,n.__wbindgen_export2),y=c,k=b(r,n.__wbindgen_export,n.__wbindgen_export2),I=c,R=b(i,n.__wbindgen_export,n.__wbindgen_export2),C=c,X=b(a,n.__wbindgen_export,n.__wbindgen_export2),_t=c,rt=b(g,n.__wbindgen_export,n.__wbindgen_export2),ot=c,it=b(d,n.__wbindgen_export,n.__wbindgen_export2),st=c,ct=n.wasmclient_prepare_inline_reciprocal_session_admission(this.__wbg_ptr,x,l,e,h,y,k,I,R,C,X,_t,rt,ot,it,st);return p(ct)}present_session_token_to_host(t,e){let _=b(t,n.__wbindgen_export,n.__wbindgen_export2),r=c,i=b(e,n.__wbindgen_export,n.__wbindgen_export2),a=c,g=n.wasmclient_present_session_token_to_host(this.__wbg_ptr,_,r,i,a);return p(g)}present_session_token_to_host_with_payload(t,e,_){let r=b(t,n.__wbindgen_export,n.__wbindgen_export2),i=c,a=b(e,n.__wbindgen_export,n.__wbindgen_export2),g=c;var d=u(_)?0:b(_,n.__wbindgen_export,n.__wbindgen_export2),x=c;let l=n.wasmclient_present_session_token_to_host_with_payload(this.__wbg_ptr,r,i,a,g,d,x);return p(l)}present_session_token_to_host_with_payload_and_device_id(t,e,_,r){let i=b(t,n.__wbindgen_export,n.__wbindgen_export2),a=c,g=b(e,n.__wbindgen_export,n.__wbindgen_export2),d=c;var x=u(_)?0:b(_,n.__wbindgen_export,n.__wbindgen_export2),l=c,h=u(r)?0:b(r,n.__wbindgen_export,n.__wbindgen_export2),y=c;let k=n.wasmclient_present_session_token_to_host_with_payload_and_device_id(this.__wbg_ptr,i,a,g,d,x,l,h,y);return p(k)}rankRoutes(t,e){try{let a=n.__wbindgen_add_to_stack_pointer(-16),g=tt(t,n.__wbindgen_export),d=c,x=tt(e,n.__wbindgen_export),l=c;n.wasmclient_rankRoutes(a,this.__wbg_ptr,g,d,x,l);var _=f().getInt32(a+0,!0),r=f().getInt32(a+4,!0),i=At(_,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=b(t,n.__wbindgen_export,n.__wbindgen_export2),i=c,a=b(e,n.__wbindgen_export,n.__wbindgen_export2),g=c;n.wasmclient_register_session_token(this.__wbg_ptr,r,i,a,g,_);}register_session_token_with_expiry_ms(t,e,_,r){let i=b(t,n.__wbindgen_export,n.__wbindgen_export2),a=c,g=b(e,n.__wbindgen_export,n.__wbindgen_export2),d=c;n.wasmclient_register_session_token_with_expiry_ms(this.__wbg_ptr,i,a,g,d,_,r);}reject_connection_admission(t,e){let _=b(t,n.__wbindgen_export,n.__wbindgen_export2),r=c,i=b(e,n.__wbindgen_export,n.__wbindgen_export2),a=c,g=n.wasmclient_reject_connection_admission(this.__wbg_ptr,_,r,i,a);return p(g)}release_peer_scope(t,e){let _=b(t,n.__wbindgen_export,n.__wbindgen_export2),r=c;var i=u(e)?0:b(e,n.__wbindgen_export,n.__wbindgen_export2),a=c;let g=n.wasmclient_release_peer_scope(this.__wbg_ptr,_,r,i,a);return p(g)}remote_session_admission_ready_for_ticket(t){let e=b(t,n.__wbindgen_export,n.__wbindgen_export2),_=c,r=n.wasmclient_remote_session_admission_ready_for_ticket(this.__wbg_ptr,e,_);return p(r)}report_managed_connection_settled(t,e,_,r,i,a){let g=b(t,n.__wbindgen_export,n.__wbindgen_export2),d=c;var x=u(_)?0:b(_,n.__wbindgen_export,n.__wbindgen_export2),l=c;let h=n.wasmclient_report_managed_connection_settled(this.__wbg_ptr,g,d,e,x,l,!u(r),u(r)?BigInt(0):r,!u(i),u(i)?BigInt(0):i,!u(a),u(a)?BigInt(0):a);return p(h)}report_transport_status(t,e,_,r,i,a){let g=b(t,n.__wbindgen_export,n.__wbindgen_export2),d=c,x=b(e,n.__wbindgen_export,n.__wbindgen_export2),l=c;var h=u(_)?0:b(_,n.__wbindgen_export,n.__wbindgen_export2),y=c;let k=n.wasmclient_report_transport_status(this.__wbg_ptr,g,d,x,l,h,y,!u(r),u(r)?BigInt(0):r,!u(i),u(i)?BigInt(0):i,!u(a),u(a)?BigInt(0):a);return p(k)}resolve_peer_connection_records(t){let e=b(t,n.__wbindgen_export,n.__wbindgen_export2),_=c,r=n.wasmclient_resolve_peer_connection_records(this.__wbg_ptr,e,_);return p(r)}revoke_session_token(t){try{let i=n.__wbindgen_add_to_stack_pointer(-16),a=b(t,n.__wbindgen_export,n.__wbindgen_export2),g=c;n.wasmclient_revoke_session_token(i,this.__wbg_ptr,a,g);var e=f().getInt32(i+0,!0),_=f().getInt32(i+4,!0),r=f().getInt32(i+8,!0);if(r)throw p(_);return p(e)}finally{n.__wbindgen_add_to_stack_pointer(16);}}revoke_tokens_by_scope(t){let e=b(t,n.__wbindgen_export,n.__wbindgen_export2),_=c,r=n.wasmclient_revoke_tokens_by_scope(this.__wbg_ptr,e,_);return p(r)}runtime_policy(){try{let r=n.__wbindgen_add_to_stack_pointer(-16);n.wasmclient_runtime_policy(r,this.__wbg_ptr);var t=f().getInt32(r+0,!0),e=f().getInt32(r+4,!0),_=f().getInt32(r+8,!0);if(_)throw p(e);return p(t)}finally{n.__wbindgen_add_to_stack_pointer(16);}}same_peer(t,e){let _=b(t,n.__wbindgen_export,n.__wbindgen_export2),r=c,i=b(e,n.__wbindgen_export,n.__wbindgen_export2),a=c,g=n.wasmclient_same_peer(this.__wbg_ptr,_,r,i,a);return p(g)}search_devices(t){let e=b(t,n.__wbindgen_export,n.__wbindgen_export2),_=c,r=n.wasmclient_search_devices(this.__wbg_ptr,e,_);return p(r)}send_message(t,e,_,r){let i=b(t,n.__wbindgen_export,n.__wbindgen_export2),a=c,g=b(e,n.__wbindgen_export,n.__wbindgen_export2),d=c;var x=u(_)?0:b(_,n.__wbindgen_export,n.__wbindgen_export2),l=c,h=u(r)?0:b(r,n.__wbindgen_export,n.__wbindgen_export2),y=c;let k=n.wasmclient_send_message(this.__wbg_ptr,i,a,g,d,x,l,h,y);return p(k)}send_peer(t,e){let _=b(t,n.__wbindgen_export,n.__wbindgen_export2),r=c,i=j(e,n.__wbindgen_export),a=c,g=n.wasmclient_send_peer(this.__wbg_ptr,_,r,i,a);return p(g)}send_peer_application_frame(t,e,_){let r=b(t,n.__wbindgen_export,n.__wbindgen_export2),i=c,a=j(e,n.__wbindgen_export),g=c,d=n.wasmclient_send_peer_application_frame(this.__wbg_ptr,r,i,a,g,u(_)?Number.MAX_SAFE_INTEGER:_>>>0);return p(d)}setConnectionApplicationCryptoKey(t,e){let _=b(t,n.__wbindgen_export,n.__wbindgen_export2),r=c,i=j(e,n.__wbindgen_export),a=c,g=n.wasmclient_setConnectionApplicationCryptoKey(this.__wbg_ptr,_,r,i,a);return p(g)}setConnectionApplicationCryptoRequired(t){try{let r=n.__wbindgen_add_to_stack_pointer(-16),i=b(t,n.__wbindgen_export,n.__wbindgen_export2),a=c;n.wasmclient_setConnectionApplicationCryptoRequired(r,this.__wbg_ptr,i,a);var e=f().getInt32(r+0,!0),_=f().getInt32(r+4,!0);if(_)throw p(e)}finally{n.__wbindgen_add_to_stack_pointer(16);}}setIdentityCredential(t){var e=u(t)?0:b(t,n.__wbindgen_export,n.__wbindgen_export2),_=c;n.wasmclient_setIdentityCredential(this.__wbg_ptr,e,_);}set_auto_connect_excluded(t,e){let _=b(t,n.__wbindgen_export,n.__wbindgen_export2),r=c,i=n.wasmclient_set_auto_connect_excluded(this.__wbg_ptr,_,r,e);return p(i)}set_offline(t){let e=b(t,n.__wbindgen_export,n.__wbindgen_export2),_=c,r=n.wasmclient_set_offline(this.__wbg_ptr,e,_);return p(r)}start_auto_connect(t,e){try{let i=n.__wbindgen_add_to_stack_pointer(-16),a=b(t,n.__wbindgen_export,n.__wbindgen_export2),g=c,d=b(e,n.__wbindgen_export,n.__wbindgen_export2),x=c;n.wasmclient_start_auto_connect(i,this.__wbg_ptr,a,g,d,x);var _=f().getInt32(i+0,!0),r=f().getInt32(i+4,!0);if(r)throw p(_)}finally{n.__wbindgen_add_to_stack_pointer(16);}}start_presence_loop(t,e,_,r){let i=b(t,n.__wbindgen_export,n.__wbindgen_export2),a=c,g=b(e,n.__wbindgen_export,n.__wbindgen_export2),d=c,x=b(_,n.__wbindgen_export,n.__wbindgen_export2),l=c;var h=u(r)?0:b(r,n.__wbindgen_export,n.__wbindgen_export2),y=c;n.wasmclient_start_presence_loop(this.__wbg_ptr,i,a,g,d,x,l,h,y);}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 a=n.__wbindgen_add_to_stack_pointer(-16),g=b(e,n.__wbindgen_export,n.__wbindgen_export2),d=c;n.wasmclient_submit_browser_desired_peers(a,this.__wbg_ptr,t,g,d);var _=f().getInt32(a+0,!0),r=f().getInt32(a+4,!0),i=f().getInt32(a+8,!0);if(i)throw p(r);return _!==0}finally{n.__wbindgen_add_to_stack_pointer(16);}}update_device(t,e,_,r,i){let a=b(t,n.__wbindgen_export,n.__wbindgen_export2),g=c,d=b(e,n.__wbindgen_export,n.__wbindgen_export2),x=c;var l=u(_)?0:b(_,n.__wbindgen_export,n.__wbindgen_export2),h=c,y=u(i)?0:b(i,n.__wbindgen_export,n.__wbindgen_export2),k=c;let I=n.wasmclient_update_device(this.__wbg_ptr,a,g,d,x,l,h,u(r)?0:w(r),y,k);return p(I)}update_presence(t,e,_,r,i){let a=b(t,n.__wbindgen_export,n.__wbindgen_export2),g=c,d=b(e,n.__wbindgen_export,n.__wbindgen_export2),x=c,l=b(_,n.__wbindgen_export,n.__wbindgen_export2),h=c;var y=u(r)?0:b(r,n.__wbindgen_export,n.__wbindgen_export2),k=c;let I=n.wasmclient_update_presence(this.__wbg_ptr,a,g,d,x,l,h,y,k,!u(i),u(i)?BigInt(0):i);return p(I)}update_session(t,e){let _=b(t,n.__wbindgen_export,n.__wbindgen_export2),r=c,i=b(e,n.__wbindgen_export,n.__wbindgen_export2),a=c,g=n.wasmclient_update_session(this.__wbg_ptr,_,r,i,a);return p(g)}validate_session_token(t){let e,_;try{let l=n.__wbindgen_add_to_stack_pointer(-16),h=b(t,n.__wbindgen_export,n.__wbindgen_export2),y=c;n.wasmclient_validate_session_token(l,this.__wbg_ptr,h,y);var r=f().getInt32(l+0,!0),i=f().getInt32(l+4,!0),a=f().getInt32(l+8,!0),g=f().getInt32(l+12,!0),d=r,x=i;if(g)throw d=0,x=0,p(a);return e=d,_=x,v(d,x)}finally{n.__wbindgen_add_to_stack_pointer(16),n.__wbindgen_export4(e,_,1);}}validate_session_token_for_connection(t,e){let _=b(t,n.__wbindgen_export,n.__wbindgen_export2),r=c,i=b(e,n.__wbindgen_export,n.__wbindgen_export2),a=c,g=n.wasmclient_validate_session_token_for_connection(this.__wbg_ptr,_,r,i,a);return p(g)}validate_session_token_for_connection_with_payload(t,e,_){let r=b(t,n.__wbindgen_export,n.__wbindgen_export2),i=c,a=b(e,n.__wbindgen_export,n.__wbindgen_export2),g=c;var d=u(_)?0:b(_,n.__wbindgen_export,n.__wbindgen_export2),x=c;let l=n.wasmclient_validate_session_token_for_connection_with_payload(this.__wbg_ptr,r,i,a,g,d,x);return p(l)}wait_for_settled_peer(t,e){let _=b(t,n.__wbindgen_export,n.__wbindgen_export2),r=c,i=n.wasmclient_wait_for_settled_peer(this.__wbg_ptr,_,r,u(e)?Number.MAX_SAFE_INTEGER:e>>>0);return p(i)}wake_browser_auto_connect(){return n.wasmclient_wake_browser_auto_connect(this.__wbg_ptr)!==0}};Symbol.dispose&&(D.prototype[Symbol.dispose]=D.prototype.free);var V=class{__destroy_into_raw(){let t=this.__wbg_ptr;return this.__wbg_ptr=0,Z.unregister(this),t}free(){let t=this.__destroy_into_raw();n.__wbg_wasmconnection_free(t,0);}create_data_channel(t){let e=b(t,n.__wbindgen_export,n.__wbindgen_export2),_=c,r=n.wasmconnection_create_data_channel(this.__wbg_ptr,e,_);return p(r)}constructor(){try{let r=n.__wbindgen_add_to_stack_pointer(-16);n.wasmconnection_new(r);var t=f().getInt32(r+0,!0),e=f().getInt32(r+4,!0),_=f().getInt32(r+8,!0);if(_)throw p(e);return this.__wbg_ptr=t,Z.register(this,this.__wbg_ptr,this),this}finally{n.__wbindgen_add_to_stack_pointer(16);}}};Symbol.dispose&&(V.prototype[Symbol.dispose]=V.prototype.free);function jt(){n.start();}function et(){return {__proto__:null,"./openrtc_bg.js":{__proto__:null,__wbg_Error_9dc85fe1bc224456:function(t,e){let _=Error(v(t,e));return w(_)},__wbg_String_8564e559799eccda:function(t,e){let _=String(o(e)),r=b(_,n.__wbindgen_export,n.__wbindgen_export2),i=c;f().setInt32(t+4,i,true),f().setInt32(t+0,r,true);},__wbg___wbindgen_boolean_get_b131b2f36d6b2f55:function(t){let e=o(t),_=typeof e=="boolean"?e:void 0;return u(_)?16777215:_?1:0},__wbg___wbindgen_debug_string_56c147eb1a51f0c4:function(t,e){let _=P(o(e)),r=b(_,n.__wbindgen_export,n.__wbindgen_export2),i=c;f().setInt32(t+4,i,true),f().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;f().setFloat64(t+8,u(r)?0:r,true),f().setInt32(t+0,!u(r),true);},__wbg___wbindgen_string_get_fa2687d531ed17a5:function(t,e){let _=o(e),r=typeof _=="string"?_:void 0;var i=u(r)?0:b(r,n.__wbindgen_export,n.__wbindgen_export2),a=c;f().setInt32(t+4,a,true),f().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 m(function(t,e,_,r){o(t).addEventListener(v(e,_),o(r));},arguments)},__wbg_append_c5a0c94a6a73b22e:function(){return m(function(t,e,_,r,i){o(t).append(v(e,_),v(r,i));},arguments)},__wbg_arrayBuffer_cc7704fa158b907a:function(){return m(function(t){let e=o(t).arrayBuffer();return w(e)},arguments)},__wbg_bistream_new:function(t){let e=z.__wrap(t);return w(e)},__wbg_body_442a47f02322d7b0:function(t){let e=o(t).body;return u(e)?0:w(e)},__wbg_buffer_8524b3453cde4918:function(t){let e=o(t).buffer;return w(e)},__wbg_byobRequest_cc72d210de793e64:function(t){let e=o(t).byobRequest;return u(e)?0:w(e)},__wbg_byteLength_96807b1d9ab24a4c:function(t){return o(t).byteLength},__wbg_byteOffset_a9c7002428843c41:function(t){return o(t).byteOffset},__wbg_call_ec09a4cf93377d3a:function(){return m(function(t,e,_){let r=o(t).call(o(e),o(_));return w(r)},arguments)},__wbg_cancel_f3a197b26dc88b39:function(t){let e=o(t).cancel();return w(e)},__wbg_catch_66060324c27be6f7:function(t,e){let _=o(t).catch(o(e));return w(_)},__wbg_clearTimeout_113b1cde814ec762:function(t){let e=clearTimeout(p(t));return w(e)},__wbg_clearTimeout_333bba87532ab9d3:function(t){let e=clearTimeout(p(t));return w(e)},__wbg_clearTimeout_47a40e3be01ed7a3:function(){return m(function(t,e){o(t).clearTimeout(p(e));},arguments)},__wbg_close_296263cfe1bb2999:function(){return m(function(t){o(t).close();},arguments)},__wbg_close_388d99468213b286:function(){return m(function(t){o(t).close();},arguments)},__wbg_close_4857e22d08b71356:function(){return m(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 w(r)},__wbg_crypto_38df2bab126b63dc:function(t){let e=o(t).crypto;return w(e)},__wbg_data_8a04443c1e5a8cd3:function(t){let e=o(t).data;return w(e)},__wbg_dispatchEvent_cc62a6a43d28b01c:function(){return m(function(t,e){return o(t).dispatchEvent(o(e))},arguments)},__wbg_done_6a8439e544ec6206:function(t){return o(t).done},__wbg_enqueue_bbeb09ba0b140f76:function(){return m(function(t,e){o(t).enqueue(o(e));},arguments)},__wbg_entries_4e00eefd3fd54cf1:function(t){let e=o(t).entries();return w(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 w(e)},__wbg_fetch_22858a12fcf93152:function(t,e){let _=o(t).fetch(o(e));return w(_)},__wbg_getRandomValues_76dfc69825c9c552:function(){return m(function(t,e){globalThis.crypto.getRandomValues(S(t,e));},arguments)},__wbg_getRandomValues_c44a50d8cfdaebeb:function(){return m(function(t,e){o(t).getRandomValues(o(e));},arguments)},__wbg_getReader_9facd4f899beac89:function(){return m(function(t){let e=o(t).getReader();return w(e)},arguments)},__wbg_get_4b90d6d8c5deb5d5:function(t,e){let _=o(t)[e>>>0];return w(_)},__wbg_get_52a8a619f7b88df6:function(){return m(function(t,e){let _=Reflect.get(o(t),o(e));return w(_)},arguments)},__wbg_get_done_c21b9933fc9a9e9c:function(t){let e=o(t).done;return u(e)?16777215:e?1:0},__wbg_get_value_ad568c7d3db9073f:function(t){let e=o(t).value;return w(e)},__wbg_get_with_ref_key_6412cf3094599694:function(t,e){let _=o(t)[o(e)];return w(_)},__wbg_has_14676d88c1340d2c:function(){return m(function(t,e){return Reflect.has(o(t),o(e))},arguments)},__wbg_headers_5b19cf40627ae54d:function(t){let e=o(t).headers;return w(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_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_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=b(_,n.__wbindgen_export,n.__wbindgen_export2),i=c;f().setInt32(t+4,i,true),f().setInt32(t+0,r,true);},__wbg_msCrypto_bd5a034af96bcba6:function(t){let e=o(t).msCrypto;return w(e)},__wbg_new_0b303268aa395a38:function(){let t=new Array;return w(t)},__wbg_new_189262ff31890c23:function(){return m(function(){let t=new Headers;return w(t)},arguments)},__wbg_new_20b778a4c5c691c3:function(){let t=new Object;return w(t)},__wbg_new_227d7c05414eb861:function(){let t=new Error;return w(t)},__wbg_new_24739629d416f982:function(){return m(function(){let t=new AbortController;return w(t)},arguments)},__wbg_new_5fae30e6b23db8df:function(t,e){let _=new Error(v(t,e));return w(_)},__wbg_new_883c0db065f06efd:function(){return w(new Map)},__wbg_new_a3e5112401a82338:function(){return m(function(t,e){let _=new WebSocket(v(t,e));return w(_)},arguments)},__wbg_new_b06772b280cc6e52:function(t){let e=new Uint8Array(o(t));return w(e)},__wbg_new_from_slice_bb2d1778c0b87eb1:function(t,e){let _=new Uint8Array(S(t,e));return w(_)},__wbg_new_typed_90c3f6c29ba36d19:function(t,e){try{var _={a:t,b:e},r=(a,g)=>{let d=_.a;_.a=0;try{return lt(d,_.b,a,g)}finally{_.a=d;}};let i=new Promise(r);return w(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 w(r)},__wbg_new_with_configuration_3a96aa953ca17197:function(){return m(function(t){let e=new RTCPeerConnection(o(t));return w(e)},arguments)},__wbg_new_with_event_init_dict_bd850674488710b1:function(){return m(function(t,e,_){let r=new CustomEvent(v(t,e),o(_));return w(r)},arguments)},__wbg_new_with_into_underlying_sink_2596343f9b6c8e58:function(t){let e=new WritableStream(B.__wrap(t));return w(e)},__wbg_new_with_into_underlying_source_fd904252f385f59c:function(t,e){let _=new ReadableStream(N.__wrap(t),p(e));return w(_)},__wbg_new_with_length_4b57a7a5dc67221c:function(t){let e=new Uint8Array(t>>>0);return w(e)},__wbg_new_with_str_and_init_df876572184fe639:function(){return m(function(t,e,_){let r=new Request(v(t,e),o(_));return w(r)},arguments)},__wbg_new_with_str_sequence_505a4829cc247e79:function(){return m(function(t,e,_){let r=new WebSocket(v(t,e),o(_));return w(r)},arguments)},__wbg_next_8cb028b6ba50743f:function(){return m(function(t){let e=o(t).next();return w(e)},arguments)},__wbg_node_84ea875411254db1:function(t){let e=o(t).node;return w(e)},__wbg_now_bce4dc999095ea77:function(){return Date.now()},__wbg_now_e7c6795a7f81e10f:function(t){return o(t).now()},__wbg_parse_a5c06e19bc1187fd:function(t,e){return Date.parse(v(t,e))},__wbg_peerunistream_new:function(t){let e=q.__wrap(t);return w(e)},__wbg_performance_3fcf6e32a7e1ed0a:function(t){let e=o(t).performance;return w(e)},__wbg_process_44c7a14e11e9f69e:function(t){let e=o(t).process;return w(e)},__wbg_protocol_28aaef5ea42981d6:function(t,e){let _=o(e).protocol,r=b(_,n.__wbindgen_export,n.__wbindgen_export2),i=c;f().setInt32(t+4,i,true),f().setInt32(t+0,r,true);},__wbg_prototypesetcall_956c7493c68e29b4:function(t,e,_){Uint8Array.prototype.set.call(S(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 w(e)},__wbg_randomFillSync_6c25eac9869eb53c:function(){return m(function(t,e){o(t).randomFillSync(p(e));},arguments)},__wbg_read_8426c146431f2905:function(t){let e=o(t).read();return w(e)},__wbg_readyState_25243ad6ce649774:function(t){return o(t).readyState},__wbg_reason_4ec455bac79b33ce:function(t,e){let _=o(e).reason,r=b(_,n.__wbindgen_export,n.__wbindgen_export2),i=c;f().setInt32(t+4,i,true),f().setInt32(t+0,r,true);},__wbg_releaseLock_188846ef719acb10:function(t){o(t).releaseLock();},__wbg_removeEventListener_016c1d24523b4730:function(){return m(function(t,e,_,r){o(t).removeEventListener(v(e,_),o(r));},arguments)},__wbg_require_b4edbdcf3e2a1ef0:function(){return m(function(){let t=module.require;return w(t)},arguments)},__wbg_resolve_0183de2e8c6b1d54:function(t){let e=Promise.resolve(o(t));return w(e)},__wbg_respond_3cdb4cf32683fd79:function(){return m(function(t,e){o(t).respond(e>>>0);},arguments)},__wbg_send_99d049cae69c53cc:function(){return m(function(t,e,_){o(t).send(S(e,_));},arguments)},__wbg_send_bac9d3dc4f21ef28:function(){return m(function(t,e,_){o(t).send(v(e,_));},arguments)},__wbg_setTimeout_3a808dd861dd3c12:function(t,e){let _=setTimeout(o(t),e);return w(_)},__wbg_setTimeout_6613a51400c1bf9f:function(){return m(function(t,e,_){let r=o(t).setTimeout(p(e),_);return w(r)},arguments)},__wbg_setTimeout_ef24d2fc3ad97385:function(){return m(function(t,e){let _=setTimeout(o(t),e);return w(_)},arguments)},__wbg_set_5f806304fb633ab3:function(t,e,_){let r=o(t).set(o(e),o(_));return w(r)},__wbg_set_6be42768c690e380:function(t,e,_){o(t)[p(e)]=p(_);},__wbg_set_86698c227e5b9dad:function(t,e,_){o(t).set(S(e,_));},__wbg_set_a6ba3ac0e634b822:function(){return m(function(t,e,_){return Reflect.set(o(t),o(e),o(_))},arguments)},__wbg_set_binaryType_8c2dd2cf1cfc2e28:function(t,e){o(t).binaryType=xt[e];},__wbg_set_body_d1153b16a2b95ca1:function(t,e){o(t).body=o(e);},__wbg_set_cache_5a01a8b5e6ca6cf2:function(t,e){o(t).cache=ht[e];},__wbg_set_credentials_e9120ed88b1fc0b8:function(t,e){o(t).credentials=yt[e];},__wbg_set_da33c120a6584674:function(t,e,_){o(t)[e>>>0]=p(_);},__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=vt[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 w(e)},__wbg_stack_3b0d974bbf31e44f:function(t,e){let _=o(e).stack,r=b(_,n.__wbindgen_export,n.__wbindgen_export2),i=c;f().setInt32(t+4,i,true),f().setInt32(t+0,r,true);},__wbg_static_accessor_GLOBAL_60a4124bab7dcc9a:function(){let t=typeof global>"u"?null:global;return u(t)?0:w(t)},__wbg_static_accessor_GLOBAL_THIS_95ca6460658b5d13:function(){let t=typeof globalThis>"u"?null:globalThis;return u(t)?0:w(t)},__wbg_static_accessor_SELF_4c95f759a91e9aae:function(){let t=typeof self>"u"?null:self;return u(t)?0:w(t)},__wbg_static_accessor_WINDOW_44b435597f9e9ee7:function(){let t=typeof window>"u"?null:window;return u(t)?0:w(t)},__wbg_status_9e6505cfa3e73a7c:function(t){return o(t).status},__wbg_subarray_42216645a367cd7a:function(t,e,_){let r=o(t).subarray(e>>>0,_>>>0);return w(r)},__wbg_then_254bab9b266a77a5:function(t,e,_){let r=o(t).then(o(e),o(_));return w(r)},__wbg_then_3ea18602c6a5123b:function(t,e){let _=o(t).then(o(e));return w(_)},__wbg_url_72c67c175685a054:function(t,e){let _=o(e).url,r=b(_,n.__wbindgen_export,n.__wbindgen_export2),i=c;f().setInt32(t+4,i,true),f().setInt32(t+0,r,true);},__wbg_url_d0b8042af0d1bbba:function(t,e){let _=o(e).url,r=b(_,n.__wbindgen_export,n.__wbindgen_export2),i=c;f().setInt32(t+4,i,true),f().setInt32(t+0,r,true);},__wbg_value_3d3defe09fb1ffca:function(t){let e=o(t).value;return w(e)},__wbg_versions_276b2795b1c6a219:function(t){let e=o(t).versions;return w(e)},__wbg_view_15fa5865c6b336e3:function(t){let e=o(t).view;return u(e)?0:w(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 _=F(t,e,gt);return w(_)},__wbindgen_cast_0000000000000002:function(t,e){let _=F(t,e,ft);return w(_)},__wbindgen_cast_0000000000000003:function(t,e){let _=F(t,e,dt);return w(_)},__wbindgen_cast_0000000000000004:function(t,e){let _=F(t,e,ut);return w(_)},__wbindgen_cast_0000000000000005:function(t,e){let _=F(t,e,bt);return w(_)},__wbindgen_cast_0000000000000006:function(t,e){let _=F(t,e,at);return w(_)},__wbindgen_cast_0000000000000007:function(t,e){let _=Rt(t,e,pt);return w(_)},__wbindgen_cast_0000000000000008:function(t,e){let _=F(t,e,wt);return w(_)},__wbindgen_cast_0000000000000009:function(t){return w(t)},__wbindgen_cast_000000000000000a:function(t){return w(t)},__wbindgen_cast_000000000000000b:function(t,e){let _=S(t,e);return w(_)},__wbindgen_cast_000000000000000c:function(t,e){let _=v(t,e);return w(_)},__wbindgen_cast_000000000000000d:function(t){let e=BigInt.asUintN(64,t);return w(e)},__wbindgen_cast_000000000000000e:function(t,e){var _=S(t,e).slice();return n.__wbindgen_export4(t,e*1,1),w(_)},__wbindgen_object_clone_ref:function(t){let e=o(t);return w(e)},__wbindgen_object_drop_ref:function(t){p(t);}}}}function bt(s,t){n.__wasm_bindgen_func_elem_8835(s,t);}function at(s,t){n.__wasm_bindgen_func_elem_9957(s,t);}function pt(s,t){n.__wasm_bindgen_func_elem_10010(s,t);}function wt(s,t){n.__wasm_bindgen_func_elem_17816(s,t);}function gt(s,t,e){n.__wasm_bindgen_func_elem_9037(s,t,w(e));}function dt(s,t,e){n.__wasm_bindgen_func_elem_6495(s,t,w(e));}function ut(s,t,e){n.__wasm_bindgen_func_elem_10645(s,t,w(e));}function ft(s,t,e){try{let i=n.__wbindgen_add_to_stack_pointer(-16);n.__wasm_bindgen_func_elem_17961(i,s,t,w(e));var _=f().getInt32(i+0,!0),r=f().getInt32(i+4,!0);if(r)throw p(_)}finally{n.__wbindgen_add_to_stack_pointer(16);}}function lt(s,t,e,_){n.__wasm_bindgen_func_elem_17963(s,t,w(e),w(_));}var xt=["blob","arraybuffer"],mt=["bytes"],ht=["default","no-store","reload","no-cache","force-cache","only-if-cached"],yt=["omit","same-origin","include"],vt=["same-origin","no-cors","cors","navigate"],K=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(s=>n.__wbg_bistream_free(s,1)),kt=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(s=>n.__wbg_intounderlyingbytesource_free(s,1)),H=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(s=>n.__wbg_intounderlyingsink_free(s,1)),J=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(s=>n.__wbg_intounderlyingsource_free(s,1)),Y=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(s=>n.__wbg_peerunistream_free(s,1)),Q=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(s=>n.__wbg_wasmclient_free(s,1)),Z=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(s=>n.__wbg_wasmconnection_free(s,1));function w(s){W===A.length&&A.push(A.length+1);let t=W;return W=A[t],A[t]=s,t}var G=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(s=>n.__wbindgen_export5(s.a,s.b));function P(s){let t=typeof s;if(t=="number"||t=="boolean"||s==null)return `${s}`;if(t=="string")return `"${s}"`;if(t=="symbol"){let r=s.description;return r==null?"Symbol":`Symbol(${r})`}if(t=="function"){let r=s.name;return typeof r=="string"&&r.length>0?`Function(${r})`:"Function"}if(Array.isArray(s)){let r=s.length,i="[";r>0&&(i+=P(s[0]));for(let a=1;a<r;a++)i+=", "+P(s[a]);return i+="]",i}let e=/\[object ([^\]]+)\]/.exec(toString.call(s)),_;if(e&&e.length>1)_=e[1];else return toString.call(s);if(_=="Object")try{return "Object("+JSON.stringify(s)+")"}catch{return "Object"}return s instanceof Error?`${s.name}: ${s.message}
1
+ var z=class s{static __wrap(t){let e=Object.create(s.prototype);return e.__wbg_ptr=t,K.register(e,e.__wbg_ptr,e),e}__destroy_into_raw(){let t=this.__wbg_ptr;return this.__wbg_ptr=0,K.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 _=f().getInt32(i+0,!0),r=f().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 p(t)}get recv(){let t=n.bistream_recv(this.__wbg_ptr);return p(t)}get send(){let t=n.bistream_send(this.__wbg_ptr);return p(t)}};Symbol.dispose&&(z.prototype[Symbol.dispose]=z.prototype.free);var U=class{__destroy_into_raw(){let t=this.__wbg_ptr;return this.__wbg_ptr=0,kt.unregister(this),t}free(){let t=this.__destroy_into_raw();n.__wbg_intounderlyingbytesource_free(t,0);}get autoAllocateChunkSize(){return n.intounderlyingbytesource_autoAllocateChunkSize(this.__wbg_ptr)>>>0}cancel(){let t=this.__destroy_into_raw();n.intounderlyingbytesource_cancel(t);}pull(t){let e=n.intounderlyingbytesource_pull(this.__wbg_ptr,w(t));return p(e)}start(t){n.intounderlyingbytesource_start(this.__wbg_ptr,w(t));}get type(){let t=n.intounderlyingbytesource_type(this.__wbg_ptr);return mt[t]}};Symbol.dispose&&(U.prototype[Symbol.dispose]=U.prototype.free);var B=class s{static __wrap(t){let e=Object.create(s.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_intounderlyingsink_free(t,0);}abort(t){let e=this.__destroy_into_raw(),_=n.intounderlyingsink_abort(e,w(t));return p(_)}close(){let t=this.__destroy_into_raw(),e=n.intounderlyingsink_close(t);return p(e)}write(t){let e=n.intounderlyingsink_write(this.__wbg_ptr,w(t));return p(e)}};Symbol.dispose&&(B.prototype[Symbol.dispose]=B.prototype.free);var N=class s{static __wrap(t){let e=Object.create(s.prototype);return e.__wbg_ptr=t,J.register(e,e.__wbg_ptr,e),e}__destroy_into_raw(){let t=this.__wbg_ptr;return this.__wbg_ptr=0,J.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,w(t));return p(e)}};Symbol.dispose&&(N.prototype[Symbol.dispose]=N.prototype.free);var q=class s{static __wrap(t){let e=Object.create(s.prototype);return e.__wbg_ptr=t,Y.register(e,e.__wbg_ptr,e),e}__destroy_into_raw(){let t=this.__wbg_ptr;return this.__wbg_ptr=0,Y.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 p(t)}get writable(){let t=n.peerunistream_writable(this.__wbg_ptr);return p(t)}};Symbol.dispose&&(q.prototype[Symbol.dispose]=q.prototype.free);var D=class s{static __wrap(t){let e=Object.create(s.prototype);return e.__wbg_ptr=t,Q.register(e,e.__wbg_ptr,e),e}__destroy_into_raw(){let t=this.__wbg_ptr;return this.__wbg_ptr=0,Q.unregister(this),t}free(){let t=this.__destroy_into_raw();n.__wbg_wasmclient_free(t,0);}add_peer_scope(t,e){let _=b(t,n.__wbindgen_export,n.__wbindgen_export2),r=c,i=b(e,n.__wbindgen_export,n.__wbindgen_export2),a=c,g=n.wasmclient_add_peer_scope(this.__wbg_ptr,_,r,i,a);return p(g)}bind_connection_device_id(t,e){let _=b(t,n.__wbindgen_export,n.__wbindgen_export2),r=c,i=b(e,n.__wbindgen_export,n.__wbindgen_export2),a=c,g=n.wasmclient_bind_connection_device_id(this.__wbg_ptr,_,r,i,a);return p(g)}bind_node_device_id(t,e){let _=b(t,n.__wbindgen_export,n.__wbindgen_export2),r=c,i=b(e,n.__wbindgen_export,n.__wbindgen_export2),a=c,g=n.wasmclient_bind_node_device_id(this.__wbg_ptr,_,r,i,a);return p(g)}clearConnectionApplicationCryptoKey(t){let e=b(t,n.__wbindgen_export,n.__wbindgen_export2),_=c;n.wasmclient_clearConnectionApplicationCryptoKey(this.__wbg_ptr,e,_);}clearIdentityCredential(){n.wasmclient_clearIdentityCredential(this.__wbg_ptr);}clear_session_tokens(){n.wasmclient_clear_session_tokens(this.__wbg_ptr);}confirm_inline_reciprocal_session_admission(t,e,_,r,i,a){let g=b(t,n.__wbindgen_export,n.__wbindgen_export2),d=c,x=b(_,n.__wbindgen_export,n.__wbindgen_export2),l=c,h=b(r,n.__wbindgen_export,n.__wbindgen_export2),y=c;var k=u(a)?0:b(a,n.__wbindgen_export,n.__wbindgen_export2),I=c;let R=n.wasmclient_confirm_inline_reciprocal_session_admission(this.__wbg_ptr,g,d,e,x,l,h,y,i,k,I);return p(R)}connect(t){let e=b(t,n.__wbindgen_export,n.__wbindgen_export2),_=c,r=n.wasmclient_connect(this.__wbg_ptr,e,_);return p(r)}connect_device(t,e){var _=u(t)?0:b(t,n.__wbindgen_export,n.__wbindgen_export2),r=c;let i=b(e,n.__wbindgen_export,n.__wbindgen_export2),a=c,g=n.wasmclient_connect_device(this.__wbg_ptr,_,r,i,a);return p(g)}connection_state(t){let e=b(t,n.__wbindgen_export,n.__wbindgen_export2),_=c,r=n.wasmclient_connection_state(this.__wbg_ptr,e,_);return p(r)}connection_states(){let t=n.wasmclient_connection_states(this.__wbg_ptr);return p(t)}create_room(t,e,_,r,i,a){let g=b(t,n.__wbindgen_export,n.__wbindgen_export2),d=c,x=b(e,n.__wbindgen_export,n.__wbindgen_export2),l=c,h=b(_,n.__wbindgen_export,n.__wbindgen_export2),y=c,k=b(r,n.__wbindgen_export,n.__wbindgen_export2),I=c,R=b(i,n.__wbindgen_export,n.__wbindgen_export2),C=c,X=n.wasmclient_create_room(this.__wbg_ptr,g,d,x,l,h,y,k,I,R,C,u(a)?Number.MAX_SAFE_INTEGER:a>>>0);return p(X)}create_session(t){let e=b(t,n.__wbindgen_export,n.__wbindgen_export2),_=c,r=n.wasmclient_create_session(this.__wbg_ptr,e,_);return p(r)}delete_device(t,e){let _=b(t,n.__wbindgen_export,n.__wbindgen_export2),r=c,i=b(e,n.__wbindgen_export,n.__wbindgen_export2),a=c,g=n.wasmclient_delete_device(this.__wbg_ptr,_,r,i,a);return p(g)}devices_with_status(t){let e=b(t,n.__wbindgen_export,n.__wbindgen_export2),_=c,r=n.wasmclient_devices_with_status(this.__wbg_ptr,e,_);return p(r)}disconnect(t){let e=b(t,n.__wbindgen_export,n.__wbindgen_export2),_=c,r=n.wasmclient_disconnect(this.__wbg_ptr,e,_);return p(r)}disconnect_device(t,e){let _=b(t,n.__wbindgen_export,n.__wbindgen_export2),r=c;var i=u(e)?0:b(e,n.__wbindgen_export,n.__wbindgen_export2),a=c;let g=n.wasmclient_disconnect_device(this.__wbg_ptr,_,r,i,a);return p(g)}disconnect_transient(t){let e=b(t,n.__wbindgen_export,n.__wbindgen_export2),_=c,r=n.wasmclient_disconnect_transient(this.__wbg_ptr,e,_);return p(r)}endpoint_id_from_ticket(t){let e,_;try{let l=n.__wbindgen_add_to_stack_pointer(-16),h=b(t,n.__wbindgen_export,n.__wbindgen_export2),y=c;n.wasmclient_endpoint_id_from_ticket(l,this.__wbg_ptr,h,y);var r=f().getInt32(l+0,!0),i=f().getInt32(l+4,!0),a=f().getInt32(l+8,!0),g=f().getInt32(l+12,!0),d=r,x=i;if(g)throw d=0,x=0,p(a);return e=d,_=x,v(d,x)}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 p(t)}endpoint_ticket_with_token(t,e){let _=b(t,n.__wbindgen_export,n.__wbindgen_export2),r=c,i=n.wasmclient_endpoint_ticket_with_token(this.__wbg_ptr,_,r,e);return p(i)}force_reconnect_snapshot(){n.wasmclient_force_reconnect_snapshot(this.__wbg_ptr);}get_members(t,e,_){let r=b(t,n.__wbindgen_export,n.__wbindgen_export2),i=c,a=b(e,n.__wbindgen_export,n.__wbindgen_export2),g=c,d=b(_,n.__wbindgen_export,n.__wbindgen_export2),x=c,l=n.wasmclient_get_members(this.__wbg_ptr,r,i,a,g,d,x);return p(l)}heartbeat_tick(t,e,_){let r=b(t,n.__wbindgen_export,n.__wbindgen_export2),i=c,a=b(e,n.__wbindgen_export,n.__wbindgen_export2),g=c,d=b(_,n.__wbindgen_export,n.__wbindgen_export2),x=c,l=n.wasmclient_heartbeat_tick(this.__wbg_ptr,r,i,a,g,d,x);return p(l)}incoming_streams(){let t=n.wasmclient_incoming_streams(this.__wbg_ptr);return p(t)}initIrohWithTestRelay(t,e){var _=u(t)?0:j(t,n.__wbindgen_export),r=c,i=u(e)?0:b(e,n.__wbindgen_export,n.__wbindgen_export2),a=c;let g=n.wasmclient_initIrohWithTestRelay(this.__wbg_ptr,_,r,i,a);return p(g)}init_iroh(t){var e=u(t)?0:j(t,n.__wbindgen_export),_=c;let r=n.wasmclient_init_iroh(this.__wbg_ptr,e,_);return p(r)}iroh_path_kind(t){let e=b(t,n.__wbindgen_export,n.__wbindgen_export2),_=c,r=n.wasmclient_iroh_path_kind(this.__wbg_ptr,e,_);return p(r)}iroh_secret_key(){let t=n.wasmclient_iroh_secret_key(this.__wbg_ptr);return p(t)}iroh_transport_rtt_ms(t){let e=b(t,n.__wbindgen_export,n.__wbindgen_export2),_=c,r=n.wasmclient_iroh_transport_rtt_ms(this.__wbg_ptr,e,_);return p(r)}is_auto_connect_excluded(t){let e=b(t,n.__wbindgen_export,n.__wbindgen_export2),_=c;return n.wasmclient_is_auto_connect_excluded(this.__wbg_ptr,e,_)!==0}is_connected(t){let e=b(t,n.__wbindgen_export,n.__wbindgen_export2),_=c,r=n.wasmclient_is_connected(this.__wbg_ptr,e,_);return p(r)}is_current_transport_stable_id(t,e){let _=b(t,n.__wbindgen_export,n.__wbindgen_export2),r=c,i=n.wasmclient_is_current_transport_stable_id(this.__wbg_ptr,_,r,e);return p(i)}join_room(t,e,_,r,i){let a=b(t,n.__wbindgen_export,n.__wbindgen_export2),g=c,d=b(e,n.__wbindgen_export,n.__wbindgen_export2),x=c,l=b(_,n.__wbindgen_export,n.__wbindgen_export2),h=c,y=b(r,n.__wbindgen_export,n.__wbindgen_export2),k=c,I=b(i,n.__wbindgen_export,n.__wbindgen_export2),R=c,C=n.wasmclient_join_room(this.__wbg_ptr,a,g,d,x,l,h,y,k,I,R);return p(C)}leave_room(t,e,_){let r=b(t,n.__wbindgen_export,n.__wbindgen_export2),i=c,a=b(e,n.__wbindgen_export,n.__wbindgen_export2),g=c,d=b(_,n.__wbindgen_export,n.__wbindgen_export2),x=c,l=n.wasmclient_leave_room(this.__wbg_ptr,r,i,a,g,d,x);return p(l)}list_managed_connections(){let t=n.wasmclient_list_managed_connections(this.__wbg_ptr);return p(t)}static newV2(t){try{let i=n.__wbindgen_add_to_stack_pointer(-16),a=b(t,n.__wbindgen_export,n.__wbindgen_export2),g=c;n.wasmclient_newV2(i,a,g);var e=f().getInt32(i+0,!0),_=f().getInt32(i+4,!0),r=f().getInt32(i+8,!0);if(r)throw p(_);return s.__wrap(e)}finally{n.__wbindgen_add_to_stack_pointer(16);}}node_addr(){let t=n.wasmclient_node_addr(this.__wbg_ptr);return p(t)}open_bi(t){let e=b(t,n.__wbindgen_export,n.__wbindgen_export2),_=c,r=n.wasmclient_open_bi(this.__wbg_ptr,e,_);return p(r)}open_native_main_control_bi(t){let e=b(t,n.__wbindgen_export,n.__wbindgen_export2),_=c,r=n.wasmclient_open_native_main_control_bi(this.__wbg_ptr,e,_);return p(r)}open_peer_bi(t,e){let _=b(t,n.__wbindgen_export,n.__wbindgen_export2),r=c,i=n.wasmclient_open_peer_bi(this.__wbg_ptr,_,r,u(e)?Number.MAX_SAFE_INTEGER:e>>>0);return p(i)}open_peer_bi_explicit_file_sender(t,e){let _=b(t,n.__wbindgen_export,n.__wbindgen_export2),r=c,i=n.wasmclient_open_peer_bi_explicit_file_sender(this.__wbg_ptr,_,r,u(e)?Number.MAX_SAFE_INTEGER:e>>>0);return p(i)}open_peer_bi_transport_only(t,e){let _=b(t,n.__wbindgen_export,n.__wbindgen_export2),r=c,i=n.wasmclient_open_peer_bi_transport_only(this.__wbg_ptr,_,r,u(e)?Number.MAX_SAFE_INTEGER:e>>>0);return p(i)}open_peer_native_bi(t,e,_){let r=b(t,n.__wbindgen_export,n.__wbindgen_export2),i=c,a=b(e,n.__wbindgen_export,n.__wbindgen_export2),g=c,d=n.wasmclient_open_peer_native_bi(this.__wbg_ptr,r,i,a,g,u(_)?Number.MAX_SAFE_INTEGER:_>>>0);return p(d)}open_peer_uni(t,e){let _=b(t,n.__wbindgen_export,n.__wbindgen_export2),r=c,i=n.wasmclient_open_peer_uni(this.__wbg_ptr,_,r,u(e)?Number.MAX_SAFE_INTEGER:e>>>0);return p(i)}open_uni(t){let e=b(t,n.__wbindgen_export,n.__wbindgen_export2),_=c,r=n.wasmclient_open_uni(this.__wbg_ptr,e,_);return p(r)}peer_scopes(t){let e=b(t,n.__wbindgen_export,n.__wbindgen_export2),_=c,r=n.wasmclient_peer_scopes(this.__wbg_ptr,e,_);return p(r)}peer_session(t){let e=b(t,n.__wbindgen_export,n.__wbindgen_export2),_=c,r=n.wasmclient_peer_session(this.__wbg_ptr,e,_);return p(r)}peer_sessions(){let t=n.wasmclient_peer_sessions(this.__wbg_ptr);return p(t)}peer_snapshot(t){let e=b(t,n.__wbindgen_export,n.__wbindgen_export2),_=c,r=n.wasmclient_peer_snapshot(this.__wbg_ptr,e,_);return p(r)}prepare_inline_reciprocal_session_admission(t,e,_,r,i,a,g,d){let x=b(t,n.__wbindgen_export,n.__wbindgen_export2),l=c,h=b(_,n.__wbindgen_export,n.__wbindgen_export2),y=c,k=b(r,n.__wbindgen_export,n.__wbindgen_export2),I=c,R=b(i,n.__wbindgen_export,n.__wbindgen_export2),C=c,X=b(a,n.__wbindgen_export,n.__wbindgen_export2),_t=c,rt=b(g,n.__wbindgen_export,n.__wbindgen_export2),ot=c,it=b(d,n.__wbindgen_export,n.__wbindgen_export2),st=c,ct=n.wasmclient_prepare_inline_reciprocal_session_admission(this.__wbg_ptr,x,l,e,h,y,k,I,R,C,X,_t,rt,ot,it,st);return p(ct)}present_session_token_to_host(t,e){let _=b(t,n.__wbindgen_export,n.__wbindgen_export2),r=c,i=b(e,n.__wbindgen_export,n.__wbindgen_export2),a=c,g=n.wasmclient_present_session_token_to_host(this.__wbg_ptr,_,r,i,a);return p(g)}present_session_token_to_host_with_payload(t,e,_){let r=b(t,n.__wbindgen_export,n.__wbindgen_export2),i=c,a=b(e,n.__wbindgen_export,n.__wbindgen_export2),g=c;var d=u(_)?0:b(_,n.__wbindgen_export,n.__wbindgen_export2),x=c;let l=n.wasmclient_present_session_token_to_host_with_payload(this.__wbg_ptr,r,i,a,g,d,x);return p(l)}present_session_token_to_host_with_payload_and_device_id(t,e,_,r){let i=b(t,n.__wbindgen_export,n.__wbindgen_export2),a=c,g=b(e,n.__wbindgen_export,n.__wbindgen_export2),d=c;var x=u(_)?0:b(_,n.__wbindgen_export,n.__wbindgen_export2),l=c,h=u(r)?0:b(r,n.__wbindgen_export,n.__wbindgen_export2),y=c;let k=n.wasmclient_present_session_token_to_host_with_payload_and_device_id(this.__wbg_ptr,i,a,g,d,x,l,h,y);return p(k)}rankRoutes(t,e){try{let a=n.__wbindgen_add_to_stack_pointer(-16),g=tt(t,n.__wbindgen_export),d=c,x=tt(e,n.__wbindgen_export),l=c;n.wasmclient_rankRoutes(a,this.__wbg_ptr,g,d,x,l);var _=f().getInt32(a+0,!0),r=f().getInt32(a+4,!0),i=At(_,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=b(t,n.__wbindgen_export,n.__wbindgen_export2),i=c,a=b(e,n.__wbindgen_export,n.__wbindgen_export2),g=c;n.wasmclient_register_session_token(this.__wbg_ptr,r,i,a,g,_);}register_session_token_with_expiry_ms(t,e,_,r){let i=b(t,n.__wbindgen_export,n.__wbindgen_export2),a=c,g=b(e,n.__wbindgen_export,n.__wbindgen_export2),d=c;n.wasmclient_register_session_token_with_expiry_ms(this.__wbg_ptr,i,a,g,d,_,r);}reject_connection_admission(t,e){let _=b(t,n.__wbindgen_export,n.__wbindgen_export2),r=c,i=b(e,n.__wbindgen_export,n.__wbindgen_export2),a=c,g=n.wasmclient_reject_connection_admission(this.__wbg_ptr,_,r,i,a);return p(g)}release_peer_scope(t,e){let _=b(t,n.__wbindgen_export,n.__wbindgen_export2),r=c;var i=u(e)?0:b(e,n.__wbindgen_export,n.__wbindgen_export2),a=c;let g=n.wasmclient_release_peer_scope(this.__wbg_ptr,_,r,i,a);return p(g)}remote_session_admission_ready_for_ticket(t){let e=b(t,n.__wbindgen_export,n.__wbindgen_export2),_=c,r=n.wasmclient_remote_session_admission_ready_for_ticket(this.__wbg_ptr,e,_);return p(r)}report_managed_connection_settled(t,e,_,r,i,a){let g=b(t,n.__wbindgen_export,n.__wbindgen_export2),d=c;var x=u(_)?0:b(_,n.__wbindgen_export,n.__wbindgen_export2),l=c;let h=n.wasmclient_report_managed_connection_settled(this.__wbg_ptr,g,d,e,x,l,!u(r),u(r)?BigInt(0):r,!u(i),u(i)?BigInt(0):i,!u(a),u(a)?BigInt(0):a);return p(h)}report_transport_status(t,e,_,r,i,a){let g=b(t,n.__wbindgen_export,n.__wbindgen_export2),d=c,x=b(e,n.__wbindgen_export,n.__wbindgen_export2),l=c;var h=u(_)?0:b(_,n.__wbindgen_export,n.__wbindgen_export2),y=c;let k=n.wasmclient_report_transport_status(this.__wbg_ptr,g,d,x,l,h,y,!u(r),u(r)?BigInt(0):r,!u(i),u(i)?BigInt(0):i,!u(a),u(a)?BigInt(0):a);return p(k)}resolve_peer_connection_records(t){let e=b(t,n.__wbindgen_export,n.__wbindgen_export2),_=c,r=n.wasmclient_resolve_peer_connection_records(this.__wbg_ptr,e,_);return p(r)}revoke_session_token(t){try{let i=n.__wbindgen_add_to_stack_pointer(-16),a=b(t,n.__wbindgen_export,n.__wbindgen_export2),g=c;n.wasmclient_revoke_session_token(i,this.__wbg_ptr,a,g);var e=f().getInt32(i+0,!0),_=f().getInt32(i+4,!0),r=f().getInt32(i+8,!0);if(r)throw p(_);return p(e)}finally{n.__wbindgen_add_to_stack_pointer(16);}}revoke_tokens_by_scope(t){let e=b(t,n.__wbindgen_export,n.__wbindgen_export2),_=c,r=n.wasmclient_revoke_tokens_by_scope(this.__wbg_ptr,e,_);return p(r)}runtime_policy(){try{let r=n.__wbindgen_add_to_stack_pointer(-16);n.wasmclient_runtime_policy(r,this.__wbg_ptr);var t=f().getInt32(r+0,!0),e=f().getInt32(r+4,!0),_=f().getInt32(r+8,!0);if(_)throw p(e);return p(t)}finally{n.__wbindgen_add_to_stack_pointer(16);}}same_peer(t,e){let _=b(t,n.__wbindgen_export,n.__wbindgen_export2),r=c,i=b(e,n.__wbindgen_export,n.__wbindgen_export2),a=c,g=n.wasmclient_same_peer(this.__wbg_ptr,_,r,i,a);return p(g)}search_devices(t){let e=b(t,n.__wbindgen_export,n.__wbindgen_export2),_=c,r=n.wasmclient_search_devices(this.__wbg_ptr,e,_);return p(r)}send_message(t,e,_,r){let i=b(t,n.__wbindgen_export,n.__wbindgen_export2),a=c,g=b(e,n.__wbindgen_export,n.__wbindgen_export2),d=c;var x=u(_)?0:b(_,n.__wbindgen_export,n.__wbindgen_export2),l=c,h=u(r)?0:b(r,n.__wbindgen_export,n.__wbindgen_export2),y=c;let k=n.wasmclient_send_message(this.__wbg_ptr,i,a,g,d,x,l,h,y);return p(k)}send_peer(t,e){let _=b(t,n.__wbindgen_export,n.__wbindgen_export2),r=c,i=j(e,n.__wbindgen_export),a=c,g=n.wasmclient_send_peer(this.__wbg_ptr,_,r,i,a);return p(g)}send_peer_application_frame(t,e,_){let r=b(t,n.__wbindgen_export,n.__wbindgen_export2),i=c,a=j(e,n.__wbindgen_export),g=c,d=n.wasmclient_send_peer_application_frame(this.__wbg_ptr,r,i,a,g,u(_)?Number.MAX_SAFE_INTEGER:_>>>0);return p(d)}setConnectionApplicationCryptoKey(t,e){let _=b(t,n.__wbindgen_export,n.__wbindgen_export2),r=c,i=j(e,n.__wbindgen_export),a=c,g=n.wasmclient_setConnectionApplicationCryptoKey(this.__wbg_ptr,_,r,i,a);return p(g)}setConnectionApplicationCryptoRequired(t){try{let r=n.__wbindgen_add_to_stack_pointer(-16),i=b(t,n.__wbindgen_export,n.__wbindgen_export2),a=c;n.wasmclient_setConnectionApplicationCryptoRequired(r,this.__wbg_ptr,i,a);var e=f().getInt32(r+0,!0),_=f().getInt32(r+4,!0);if(_)throw p(e)}finally{n.__wbindgen_add_to_stack_pointer(16);}}setIdentityCredential(t){var e=u(t)?0:b(t,n.__wbindgen_export,n.__wbindgen_export2),_=c;n.wasmclient_setIdentityCredential(this.__wbg_ptr,e,_);}set_auto_connect_excluded(t,e){let _=b(t,n.__wbindgen_export,n.__wbindgen_export2),r=c,i=n.wasmclient_set_auto_connect_excluded(this.__wbg_ptr,_,r,e);return p(i)}set_offline(t){let e=b(t,n.__wbindgen_export,n.__wbindgen_export2),_=c,r=n.wasmclient_set_offline(this.__wbg_ptr,e,_);return p(r)}start_auto_connect(t,e){try{let i=n.__wbindgen_add_to_stack_pointer(-16),a=b(t,n.__wbindgen_export,n.__wbindgen_export2),g=c,d=b(e,n.__wbindgen_export,n.__wbindgen_export2),x=c;n.wasmclient_start_auto_connect(i,this.__wbg_ptr,a,g,d,x);var _=f().getInt32(i+0,!0),r=f().getInt32(i+4,!0);if(r)throw p(_)}finally{n.__wbindgen_add_to_stack_pointer(16);}}start_presence_loop(t,e,_,r){let i=b(t,n.__wbindgen_export,n.__wbindgen_export2),a=c,g=b(e,n.__wbindgen_export,n.__wbindgen_export2),d=c,x=b(_,n.__wbindgen_export,n.__wbindgen_export2),l=c;var h=u(r)?0:b(r,n.__wbindgen_export,n.__wbindgen_export2),y=c;n.wasmclient_start_presence_loop(this.__wbg_ptr,i,a,g,d,x,l,h,y);}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 a=n.__wbindgen_add_to_stack_pointer(-16),g=b(e,n.__wbindgen_export,n.__wbindgen_export2),d=c;n.wasmclient_submit_browser_desired_peers(a,this.__wbg_ptr,t,g,d);var _=f().getInt32(a+0,!0),r=f().getInt32(a+4,!0),i=f().getInt32(a+8,!0);if(i)throw p(r);return _!==0}finally{n.__wbindgen_add_to_stack_pointer(16);}}update_device(t,e,_,r,i){let a=b(t,n.__wbindgen_export,n.__wbindgen_export2),g=c,d=b(e,n.__wbindgen_export,n.__wbindgen_export2),x=c;var l=u(_)?0:b(_,n.__wbindgen_export,n.__wbindgen_export2),h=c,y=u(i)?0:b(i,n.__wbindgen_export,n.__wbindgen_export2),k=c;let I=n.wasmclient_update_device(this.__wbg_ptr,a,g,d,x,l,h,u(r)?0:w(r),y,k);return p(I)}update_presence(t,e,_,r,i){let a=b(t,n.__wbindgen_export,n.__wbindgen_export2),g=c,d=b(e,n.__wbindgen_export,n.__wbindgen_export2),x=c,l=b(_,n.__wbindgen_export,n.__wbindgen_export2),h=c;var y=u(r)?0:b(r,n.__wbindgen_export,n.__wbindgen_export2),k=c;let I=n.wasmclient_update_presence(this.__wbg_ptr,a,g,d,x,l,h,y,k,!u(i),u(i)?BigInt(0):i);return p(I)}update_session(t,e){let _=b(t,n.__wbindgen_export,n.__wbindgen_export2),r=c,i=b(e,n.__wbindgen_export,n.__wbindgen_export2),a=c,g=n.wasmclient_update_session(this.__wbg_ptr,_,r,i,a);return p(g)}validate_session_token(t){let e,_;try{let l=n.__wbindgen_add_to_stack_pointer(-16),h=b(t,n.__wbindgen_export,n.__wbindgen_export2),y=c;n.wasmclient_validate_session_token(l,this.__wbg_ptr,h,y);var r=f().getInt32(l+0,!0),i=f().getInt32(l+4,!0),a=f().getInt32(l+8,!0),g=f().getInt32(l+12,!0),d=r,x=i;if(g)throw d=0,x=0,p(a);return e=d,_=x,v(d,x)}finally{n.__wbindgen_add_to_stack_pointer(16),n.__wbindgen_export4(e,_,1);}}validate_session_token_for_connection(t,e){let _=b(t,n.__wbindgen_export,n.__wbindgen_export2),r=c,i=b(e,n.__wbindgen_export,n.__wbindgen_export2),a=c,g=n.wasmclient_validate_session_token_for_connection(this.__wbg_ptr,_,r,i,a);return p(g)}validate_session_token_for_connection_with_payload(t,e,_){let r=b(t,n.__wbindgen_export,n.__wbindgen_export2),i=c,a=b(e,n.__wbindgen_export,n.__wbindgen_export2),g=c;var d=u(_)?0:b(_,n.__wbindgen_export,n.__wbindgen_export2),x=c;let l=n.wasmclient_validate_session_token_for_connection_with_payload(this.__wbg_ptr,r,i,a,g,d,x);return p(l)}wait_for_settled_peer(t,e){let _=b(t,n.__wbindgen_export,n.__wbindgen_export2),r=c,i=n.wasmclient_wait_for_settled_peer(this.__wbg_ptr,_,r,u(e)?Number.MAX_SAFE_INTEGER:e>>>0);return p(i)}wake_browser_auto_connect(){return n.wasmclient_wake_browser_auto_connect(this.__wbg_ptr)!==0}};Symbol.dispose&&(D.prototype[Symbol.dispose]=D.prototype.free);var V=class{__destroy_into_raw(){let t=this.__wbg_ptr;return this.__wbg_ptr=0,Z.unregister(this),t}free(){let t=this.__destroy_into_raw();n.__wbg_wasmconnection_free(t,0);}create_data_channel(t){let e=b(t,n.__wbindgen_export,n.__wbindgen_export2),_=c,r=n.wasmconnection_create_data_channel(this.__wbg_ptr,e,_);return p(r)}constructor(){try{let r=n.__wbindgen_add_to_stack_pointer(-16);n.wasmconnection_new(r);var t=f().getInt32(r+0,!0),e=f().getInt32(r+4,!0),_=f().getInt32(r+8,!0);if(_)throw p(e);return this.__wbg_ptr=t,Z.register(this,this.__wbg_ptr,this),this}finally{n.__wbindgen_add_to_stack_pointer(16);}}};Symbol.dispose&&(V.prototype[Symbol.dispose]=V.prototype.free);function jt(){n.start();}function et(){return {__proto__:null,"./openrtc_bg.js":{__proto__:null,__wbg_Error_9dc85fe1bc224456:function(t,e){let _=Error(v(t,e));return w(_)},__wbg_String_8564e559799eccda:function(t,e){let _=String(o(e)),r=b(_,n.__wbindgen_export,n.__wbindgen_export2),i=c;f().setInt32(t+4,i,true),f().setInt32(t+0,r,true);},__wbg___wbindgen_boolean_get_b131b2f36d6b2f55:function(t){let e=o(t),_=typeof e=="boolean"?e:void 0;return u(_)?16777215:_?1:0},__wbg___wbindgen_debug_string_56c147eb1a51f0c4:function(t,e){let _=P(o(e)),r=b(_,n.__wbindgen_export,n.__wbindgen_export2),i=c;f().setInt32(t+4,i,true),f().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;f().setFloat64(t+8,u(r)?0:r,true),f().setInt32(t+0,!u(r),true);},__wbg___wbindgen_string_get_fa2687d531ed17a5:function(t,e){let _=o(e),r=typeof _=="string"?_:void 0;var i=u(r)?0:b(r,n.__wbindgen_export,n.__wbindgen_export2),a=c;f().setInt32(t+4,a,true),f().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 m(function(t,e,_,r){o(t).addEventListener(v(e,_),o(r));},arguments)},__wbg_append_c5a0c94a6a73b22e:function(){return m(function(t,e,_,r,i){o(t).append(v(e,_),v(r,i));},arguments)},__wbg_arrayBuffer_cc7704fa158b907a:function(){return m(function(t){let e=o(t).arrayBuffer();return w(e)},arguments)},__wbg_bistream_new:function(t){let e=z.__wrap(t);return w(e)},__wbg_body_442a47f02322d7b0:function(t){let e=o(t).body;return u(e)?0:w(e)},__wbg_buffer_8524b3453cde4918:function(t){let e=o(t).buffer;return w(e)},__wbg_byobRequest_cc72d210de793e64:function(t){let e=o(t).byobRequest;return u(e)?0:w(e)},__wbg_byteLength_96807b1d9ab24a4c:function(t){return o(t).byteLength},__wbg_byteOffset_a9c7002428843c41:function(t){return o(t).byteOffset},__wbg_call_ec09a4cf93377d3a:function(){return m(function(t,e,_){let r=o(t).call(o(e),o(_));return w(r)},arguments)},__wbg_cancel_f3a197b26dc88b39:function(t){let e=o(t).cancel();return w(e)},__wbg_catch_66060324c27be6f7:function(t,e){let _=o(t).catch(o(e));return w(_)},__wbg_clearTimeout_113b1cde814ec762:function(t){let e=clearTimeout(p(t));return w(e)},__wbg_clearTimeout_333bba87532ab9d3:function(t){let e=clearTimeout(p(t));return w(e)},__wbg_clearTimeout_47a40e3be01ed7a3:function(){return m(function(t,e){o(t).clearTimeout(p(e));},arguments)},__wbg_close_296263cfe1bb2999:function(){return m(function(t){o(t).close();},arguments)},__wbg_close_388d99468213b286:function(){return m(function(t){o(t).close();},arguments)},__wbg_close_4857e22d08b71356:function(){return m(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 w(r)},__wbg_crypto_38df2bab126b63dc:function(t){let e=o(t).crypto;return w(e)},__wbg_data_8a04443c1e5a8cd3:function(t){let e=o(t).data;return w(e)},__wbg_dispatchEvent_cc62a6a43d28b01c:function(){return m(function(t,e){return o(t).dispatchEvent(o(e))},arguments)},__wbg_done_6a8439e544ec6206:function(t){return o(t).done},__wbg_enqueue_bbeb09ba0b140f76:function(){return m(function(t,e){o(t).enqueue(o(e));},arguments)},__wbg_entries_4e00eefd3fd54cf1:function(t){let e=o(t).entries();return w(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 w(e)},__wbg_fetch_22858a12fcf93152:function(t,e){let _=o(t).fetch(o(e));return w(_)},__wbg_getRandomValues_76dfc69825c9c552:function(){return m(function(t,e){globalThis.crypto.getRandomValues(S(t,e));},arguments)},__wbg_getRandomValues_c44a50d8cfdaebeb:function(){return m(function(t,e){o(t).getRandomValues(o(e));},arguments)},__wbg_getReader_9facd4f899beac89:function(){return m(function(t){let e=o(t).getReader();return w(e)},arguments)},__wbg_get_4b90d6d8c5deb5d5:function(t,e){let _=o(t)[e>>>0];return w(_)},__wbg_get_52a8a619f7b88df6:function(){return m(function(t,e){let _=Reflect.get(o(t),o(e));return w(_)},arguments)},__wbg_get_done_c21b9933fc9a9e9c:function(t){let e=o(t).done;return u(e)?16777215:e?1:0},__wbg_get_value_ad568c7d3db9073f:function(t){let e=o(t).value;return w(e)},__wbg_get_with_ref_key_6412cf3094599694:function(t,e){let _=o(t)[o(e)];return w(_)},__wbg_has_14676d88c1340d2c:function(){return m(function(t,e){return Reflect.has(o(t),o(e))},arguments)},__wbg_headers_5b19cf40627ae54d:function(t){let e=o(t).headers;return w(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_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_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=b(_,n.__wbindgen_export,n.__wbindgen_export2),i=c;f().setInt32(t+4,i,true),f().setInt32(t+0,r,true);},__wbg_msCrypto_bd5a034af96bcba6:function(t){let e=o(t).msCrypto;return w(e)},__wbg_new_0b303268aa395a38:function(){let t=new Array;return w(t)},__wbg_new_189262ff31890c23:function(){return m(function(){let t=new Headers;return w(t)},arguments)},__wbg_new_20b778a4c5c691c3:function(){let t=new Object;return w(t)},__wbg_new_227d7c05414eb861:function(){let t=new Error;return w(t)},__wbg_new_24739629d416f982:function(){return m(function(){let t=new AbortController;return w(t)},arguments)},__wbg_new_5fae30e6b23db8df:function(t,e){let _=new Error(v(t,e));return w(_)},__wbg_new_883c0db065f06efd:function(){return w(new Map)},__wbg_new_a3e5112401a82338:function(){return m(function(t,e){let _=new WebSocket(v(t,e));return w(_)},arguments)},__wbg_new_b06772b280cc6e52:function(t){let e=new Uint8Array(o(t));return w(e)},__wbg_new_from_slice_bb2d1778c0b87eb1:function(t,e){let _=new Uint8Array(S(t,e));return w(_)},__wbg_new_typed_90c3f6c29ba36d19:function(t,e){try{var _={a:t,b:e},r=(a,g)=>{let d=_.a;_.a=0;try{return lt(d,_.b,a,g)}finally{_.a=d;}};let i=new Promise(r);return w(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 w(r)},__wbg_new_with_configuration_3a96aa953ca17197:function(){return m(function(t){let e=new RTCPeerConnection(o(t));return w(e)},arguments)},__wbg_new_with_event_init_dict_bd850674488710b1:function(){return m(function(t,e,_){let r=new CustomEvent(v(t,e),o(_));return w(r)},arguments)},__wbg_new_with_into_underlying_sink_2596343f9b6c8e58:function(t){let e=new WritableStream(B.__wrap(t));return w(e)},__wbg_new_with_into_underlying_source_fd904252f385f59c:function(t,e){let _=new ReadableStream(N.__wrap(t),p(e));return w(_)},__wbg_new_with_length_4b57a7a5dc67221c:function(t){let e=new Uint8Array(t>>>0);return w(e)},__wbg_new_with_str_and_init_df876572184fe639:function(){return m(function(t,e,_){let r=new Request(v(t,e),o(_));return w(r)},arguments)},__wbg_new_with_str_sequence_505a4829cc247e79:function(){return m(function(t,e,_){let r=new WebSocket(v(t,e),o(_));return w(r)},arguments)},__wbg_next_8cb028b6ba50743f:function(){return m(function(t){let e=o(t).next();return w(e)},arguments)},__wbg_node_84ea875411254db1:function(t){let e=o(t).node;return w(e)},__wbg_now_bce4dc999095ea77:function(){return Date.now()},__wbg_now_e7c6795a7f81e10f:function(t){return o(t).now()},__wbg_parse_a5c06e19bc1187fd:function(t,e){return Date.parse(v(t,e))},__wbg_peerunistream_new:function(t){let e=q.__wrap(t);return w(e)},__wbg_performance_3fcf6e32a7e1ed0a:function(t){let e=o(t).performance;return w(e)},__wbg_process_44c7a14e11e9f69e:function(t){let e=o(t).process;return w(e)},__wbg_protocol_28aaef5ea42981d6:function(t,e){let _=o(e).protocol,r=b(_,n.__wbindgen_export,n.__wbindgen_export2),i=c;f().setInt32(t+4,i,true),f().setInt32(t+0,r,true);},__wbg_prototypesetcall_956c7493c68e29b4:function(t,e,_){Uint8Array.prototype.set.call(S(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 w(e)},__wbg_randomFillSync_6c25eac9869eb53c:function(){return m(function(t,e){o(t).randomFillSync(p(e));},arguments)},__wbg_read_8426c146431f2905:function(t){let e=o(t).read();return w(e)},__wbg_readyState_25243ad6ce649774:function(t){return o(t).readyState},__wbg_reason_4ec455bac79b33ce:function(t,e){let _=o(e).reason,r=b(_,n.__wbindgen_export,n.__wbindgen_export2),i=c;f().setInt32(t+4,i,true),f().setInt32(t+0,r,true);},__wbg_releaseLock_188846ef719acb10:function(t){o(t).releaseLock();},__wbg_removeEventListener_016c1d24523b4730:function(){return m(function(t,e,_,r){o(t).removeEventListener(v(e,_),o(r));},arguments)},__wbg_require_b4edbdcf3e2a1ef0:function(){return m(function(){let t=module.require;return w(t)},arguments)},__wbg_resolve_0183de2e8c6b1d54:function(t){let e=Promise.resolve(o(t));return w(e)},__wbg_respond_3cdb4cf32683fd79:function(){return m(function(t,e){o(t).respond(e>>>0);},arguments)},__wbg_send_99d049cae69c53cc:function(){return m(function(t,e,_){o(t).send(S(e,_));},arguments)},__wbg_send_bac9d3dc4f21ef28:function(){return m(function(t,e,_){o(t).send(v(e,_));},arguments)},__wbg_setTimeout_3a808dd861dd3c12:function(t,e){let _=setTimeout(o(t),e);return w(_)},__wbg_setTimeout_6613a51400c1bf9f:function(){return m(function(t,e,_){let r=o(t).setTimeout(p(e),_);return w(r)},arguments)},__wbg_setTimeout_ef24d2fc3ad97385:function(){return m(function(t,e){let _=setTimeout(o(t),e);return w(_)},arguments)},__wbg_set_5f806304fb633ab3:function(t,e,_){let r=o(t).set(o(e),o(_));return w(r)},__wbg_set_6be42768c690e380:function(t,e,_){o(t)[p(e)]=p(_);},__wbg_set_86698c227e5b9dad:function(t,e,_){o(t).set(S(e,_));},__wbg_set_a6ba3ac0e634b822:function(){return m(function(t,e,_){return Reflect.set(o(t),o(e),o(_))},arguments)},__wbg_set_binaryType_8c2dd2cf1cfc2e28:function(t,e){o(t).binaryType=xt[e];},__wbg_set_body_d1153b16a2b95ca1:function(t,e){o(t).body=o(e);},__wbg_set_cache_5a01a8b5e6ca6cf2:function(t,e){o(t).cache=ht[e];},__wbg_set_credentials_e9120ed88b1fc0b8:function(t,e){o(t).credentials=yt[e];},__wbg_set_da33c120a6584674:function(t,e,_){o(t)[e>>>0]=p(_);},__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=vt[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 w(e)},__wbg_stack_3b0d974bbf31e44f:function(t,e){let _=o(e).stack,r=b(_,n.__wbindgen_export,n.__wbindgen_export2),i=c;f().setInt32(t+4,i,true),f().setInt32(t+0,r,true);},__wbg_static_accessor_GLOBAL_60a4124bab7dcc9a:function(){let t=typeof global>"u"?null:global;return u(t)?0:w(t)},__wbg_static_accessor_GLOBAL_THIS_95ca6460658b5d13:function(){let t=typeof globalThis>"u"?null:globalThis;return u(t)?0:w(t)},__wbg_static_accessor_SELF_4c95f759a91e9aae:function(){let t=typeof self>"u"?null:self;return u(t)?0:w(t)},__wbg_static_accessor_WINDOW_44b435597f9e9ee7:function(){let t=typeof window>"u"?null:window;return u(t)?0:w(t)},__wbg_status_9e6505cfa3e73a7c:function(t){return o(t).status},__wbg_subarray_42216645a367cd7a:function(t,e,_){let r=o(t).subarray(e>>>0,_>>>0);return w(r)},__wbg_then_254bab9b266a77a5:function(t,e,_){let r=o(t).then(o(e),o(_));return w(r)},__wbg_then_3ea18602c6a5123b:function(t,e){let _=o(t).then(o(e));return w(_)},__wbg_url_72c67c175685a054:function(t,e){let _=o(e).url,r=b(_,n.__wbindgen_export,n.__wbindgen_export2),i=c;f().setInt32(t+4,i,true),f().setInt32(t+0,r,true);},__wbg_url_d0b8042af0d1bbba:function(t,e){let _=o(e).url,r=b(_,n.__wbindgen_export,n.__wbindgen_export2),i=c;f().setInt32(t+4,i,true),f().setInt32(t+0,r,true);},__wbg_value_3d3defe09fb1ffca:function(t){let e=o(t).value;return w(e)},__wbg_versions_276b2795b1c6a219:function(t){let e=o(t).versions;return w(e)},__wbg_view_15fa5865c6b336e3:function(t){let e=o(t).view;return u(e)?0:w(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 _=F(t,e,gt);return w(_)},__wbindgen_cast_0000000000000002:function(t,e){let _=F(t,e,ft);return w(_)},__wbindgen_cast_0000000000000003:function(t,e){let _=F(t,e,dt);return w(_)},__wbindgen_cast_0000000000000004:function(t,e){let _=F(t,e,ut);return w(_)},__wbindgen_cast_0000000000000005:function(t,e){let _=F(t,e,bt);return w(_)},__wbindgen_cast_0000000000000006:function(t,e){let _=F(t,e,at);return w(_)},__wbindgen_cast_0000000000000007:function(t,e){let _=Rt(t,e,pt);return w(_)},__wbindgen_cast_0000000000000008:function(t,e){let _=F(t,e,wt);return w(_)},__wbindgen_cast_0000000000000009:function(t){return w(t)},__wbindgen_cast_000000000000000a:function(t){return w(t)},__wbindgen_cast_000000000000000b:function(t,e){let _=S(t,e);return w(_)},__wbindgen_cast_000000000000000c:function(t,e){let _=v(t,e);return w(_)},__wbindgen_cast_000000000000000d:function(t){let e=BigInt.asUintN(64,t);return w(e)},__wbindgen_cast_000000000000000e:function(t,e){var _=S(t,e).slice();return n.__wbindgen_export4(t,e*1,1),w(_)},__wbindgen_object_clone_ref:function(t){let e=o(t);return w(e)},__wbindgen_object_drop_ref:function(t){p(t);}}}}function bt(s,t){n.__wasm_bindgen_func_elem_8801(s,t);}function at(s,t){n.__wasm_bindgen_func_elem_9944(s,t);}function pt(s,t){n.__wasm_bindgen_func_elem_9998(s,t);}function wt(s,t){n.__wasm_bindgen_func_elem_17767(s,t);}function gt(s,t,e){n.__wasm_bindgen_func_elem_9005(s,t,w(e));}function dt(s,t,e){n.__wasm_bindgen_func_elem_6464(s,t,w(e));}function ut(s,t,e){n.__wasm_bindgen_func_elem_10631(s,t,w(e));}function ft(s,t,e){try{let i=n.__wbindgen_add_to_stack_pointer(-16);n.__wasm_bindgen_func_elem_17912(i,s,t,w(e));var _=f().getInt32(i+0,!0),r=f().getInt32(i+4,!0);if(r)throw p(_)}finally{n.__wbindgen_add_to_stack_pointer(16);}}function lt(s,t,e,_){n.__wasm_bindgen_func_elem_17914(s,t,w(e),w(_));}var xt=["blob","arraybuffer"],mt=["bytes"],ht=["default","no-store","reload","no-cache","force-cache","only-if-cached"],yt=["omit","same-origin","include"],vt=["same-origin","no-cors","cors","navigate"],K=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(s=>n.__wbg_bistream_free(s,1)),kt=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(s=>n.__wbg_intounderlyingbytesource_free(s,1)),H=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(s=>n.__wbg_intounderlyingsink_free(s,1)),J=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(s=>n.__wbg_intounderlyingsource_free(s,1)),Y=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(s=>n.__wbg_peerunistream_free(s,1)),Q=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(s=>n.__wbg_wasmclient_free(s,1)),Z=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(s=>n.__wbg_wasmconnection_free(s,1));function w(s){W===A.length&&A.push(A.length+1);let t=W;return W=A[t],A[t]=s,t}var G=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(s=>n.__wbindgen_export5(s.a,s.b));function P(s){let t=typeof s;if(t=="number"||t=="boolean"||s==null)return `${s}`;if(t=="string")return `"${s}"`;if(t=="symbol"){let r=s.description;return r==null?"Symbol":`Symbol(${r})`}if(t=="function"){let r=s.name;return typeof r=="string"&&r.length>0?`Function(${r})`:"Function"}if(Array.isArray(s)){let r=s.length,i="[";r>0&&(i+=P(s[0]));for(let a=1;a<r;a++)i+=", "+P(s[a]);return i+="]",i}let e=/\[object ([^\]]+)\]/.exec(toString.call(s)),_;if(e&&e.length>1)_=e[1];else return toString.call(s);if(_=="Object")try{return "Object("+JSON.stringify(s)+")"}catch{return "Object"}return s instanceof Error?`${s.name}: ${s.message}
2
2
  ${s.stack}`:_}function It(s){s<1028||(A[s]=W,W=s);}function At(s,t){s=s>>>0;let e=f(),_=[];for(let r=s;r<s+4*t;r+=4)_.push(p(e.getUint32(r,true)));return _}function S(s,t){return s=s>>>0,T().subarray(s/1,s/1+t)}var E=null;function f(){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(s,t){return Ft(s>>>0,t)}var O=null;function T(){return (O===null||O.byteLength===0)&&(O=new Uint8Array(n.memory.buffer)),O}function o(s){return A[s]}function m(s,t){try{return s.apply(this,t)}catch(e){n.__wbindgen_export3(w(e));}}var A=new Array(1024).fill(void 0);A.push(void 0,null,true,false);var W=A.length;function u(s){return s==null}function Rt(s,t,e){let _={a:s,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 F(s,t,e){let _={a:s,b:t,cnt:1},r=(...i)=>{_.cnt++;let a=_.a;_.a=0;try{return e(a,_.b,...i)}finally{_.a=a,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 j(s,t){let e=t(s.length*1,1)>>>0;return T().set(s,e/1),c=s.length,e}function tt(s,t){let e=t(s.length*4,4)>>>0,_=f();for(let r=0;r<s.length;r++)_.setUint32(e+4*r,w(s[r]),true);return c=s.length,e}function b(s,t,e){if(e===void 0){let g=M.encode(s),d=t(g.length,1)>>>0;return T().subarray(d,d+g.length).set(g),c=g.length,d}let _=s.length,r=t(_,1)>>>0,i=T(),a=0;for(;a<_;a++){let g=s.charCodeAt(a);if(g>127)break;i[r+a]=g;}if(a!==_){a!==0&&(s=s.slice(a)),r=e(r,_,_=a+s.length*3,1)>>>0;let g=T().subarray(r+a,r+_),d=M.encodeInto(s,g);a+=d.written,r=e(r,_,a,1)>>>0;}return c=a,r}function p(s){let t=o(s);return It(s),t}var L=new TextDecoder("utf-8",{ignoreBOM:true,fatal:true});L.decode();var St=2146435072,$=0;function Ft(s,t){return $+=t,$>=St&&(L=new TextDecoder("utf-8",{ignoreBOM:true,fatal:true}),L.decode(),$=t),L.decode(T().subarray(s,s+t))}var M=new TextEncoder;"encodeInto"in M||(M.encodeInto=function(s,t){let e=M.encode(s);return t.set(e),{read:s.length,written:e.length}});var c=0,n;function nt(s,t){return n=s.exports,E=null,O=null,n.__wbindgen_start(),n}async function Ct(s,t){if(typeof Response=="function"&&s instanceof Response){if(typeof WebAssembly.instantiateStreaming=="function")try{return await WebAssembly.instantiateStreaming(s,t)}catch(r){if(s.ok&&e(s.type)&&s.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 s.arrayBuffer();return await WebAssembly.instantiate(_,t)}else {let _=await WebAssembly.instantiate(s,t);return _ instanceof WebAssembly.Instance?{instance:_,module:s}:_}function e(_){switch(_){case "basic":case "cors":case "default":return true}return false}}function Ot(s){if(n!==void 0)return n;s!==void 0&&(Object.getPrototypeOf(s)===Object.prototype?{module:s}=s:console.warn("using deprecated parameters for `initSync()`; pass a single object instead"));let t=et();s instanceof WebAssembly.Module||(s=new WebAssembly.Module(s));let e=new WebAssembly.Instance(s,t);return nt(e)}async function Wt(s){if(n!==void 0)return n;s!==void 0&&(Object.getPrototypeOf(s)===Object.prototype?{module_or_path:s}=s:console.warn("using deprecated parameters for the initialization function; pass a single object instead")),s===void 0&&(s=new URL("openrtc_bg.wasm",import.meta.url));let t=et();(typeof s=="string"||typeof Request=="function"&&s instanceof Request||typeof URL=="function"&&s instanceof URL)&&(s=fetch(s));let{instance:e,module:_}=await Ct(await s,t);return nt(e)}export{z as BiStream,U as IntoUnderlyingByteSource,B as IntoUnderlyingSink,N as IntoUnderlyingSource,q as PeerUniStream,D as WasmClient,V as WasmConnection,Wt as default,Ot as initSync,jt as start};
Binary file
@@ -1 +1 @@
1
- import {a}from'../chunk-6KCPRIB5.js';import {w}from'../chunk-JUHDH6K4.js';import'../chunk-VK6KX433.js';import'../chunk-NT5YHZQH.js';import'../chunk-N26S7V4N.js';import'../chunk-NB4H5TP3.js';import'../chunk-RD3JEGGF.js';import'../chunk-C7YN5MSV.js';var n=class extends a{constructor(e){super(new w(e));}setWasmClient(e){this.unwrap().setWasmClient(e);}};export{n as WasmRuntimeAdapter};
1
+ import {a}from'../chunk-C6PAXO3N.js';import {w}from'../chunk-JIVVHBCB.js';import'../chunk-VK6KX433.js';import'../chunk-NT5YHZQH.js';import'../chunk-N26S7V4N.js';import'../chunk-NB4H5TP3.js';import'../chunk-RD3JEGGF.js';import'../chunk-C7YN5MSV.js';var n=class extends a{constructor(e){super(new w(e));}setWasmClient(e){this.unwrap().setWasmClient(e);}};export{n as WasmRuntimeAdapter};
@@ -1,2 +1,2 @@
1
- export{b as TauriRuntimeAdapter,a as createTauriIpcBridge}from'../chunk-CA6HLY7T.js';export{b as runtimeFromCapability}from'../chunk-IAEGDK4P.js';export{b as Connection,t as RuntimeClient,c as RuntimeConnectionController,g as ScopedConnectionActorError,j as ScopedConnectionActorHandle,k as ScopedConnectionActorRegistry,f as clog,r as concatRuntimeBytes,e as correlationForDriveGrantScope,q as createRuntimeJsonFrameDecoder,m as createRuntimeU32BEFrameDecoder,o as decodeRuntimeJsonPayload,p as encodeRuntimeJsonFrame,n as encodeRuntimeJsonPayload,l as encodeRuntimeU32BEFrame,s as readRuntimeU32BE,d as renderCorrelationFields,h as scopedConnectionKey,i as scopedConnectionKeyToString}from'../chunk-QHWMILLL.js';export{f as IpcRuntimeAdapter}from'../chunk-NRO64VRR.js';import'../chunk-6KCPRIB5.js';import'../chunk-7Z6N46RB.js';export{q as BROWSER_WASM_RUNTIME_CAPABILITIES,r as NATIVE_IPC_RUNTIME_CAPABILITIES,o as OPENRTC_RUNTIME_POLICY,s as cloneRuntimeCapabilities,p as getRuntimePolicy,g as logOpenRtcTeardownTrace,t as runtimeCapabilitiesForBrowserHost,u as runtimeCapabilitiesFromNativeStatus,v as runtimeCapabilityProfile}from'../chunk-JUHDH6K4.js';export{b as openRtcDebug,a as openRtcDebugEnabled,c as openRtcDebugInfo,d as openRtcDebugLog}from'../chunk-VK6KX433.js';import'../chunk-NT5YHZQH.js';export{a as classifyNativeIpcFailure,b as isNativeIpcCommandUnavailable}from'../chunk-K37WVIZL.js';import'../chunk-BXFXPIXO.js';import {b}from'../chunk-N26S7V4N.js';import'../chunk-NB4H5TP3.js';import'../chunk-RD3JEGGF.js';import'../chunk-C7YN5MSV.js';export{a as isRuntimeDeviceActive,c as isRuntimeDeviceConnectable,b as isRuntimeDeviceRoutable}from'../chunk-CK6WQV7J.js';var j="https://api.openrtc.app";function c(e){if(typeof globalThis.crypto?.randomUUID!="function")throw new Error(`Secure request identity is unavailable for ${e}.`);return `${e}:${globalThis.crypto.randomUUID()}`}async function z(e,t,n){let o=e.replace(/\/$/,""),r=await fetch(`${o}/v1/spaces/${encodeURIComponent(n)}/scoped-auth`,{method:"POST",headers:{Authorization:`Bearer ${t}`,"Content-Type":"application/json","X-OpenRTC-Idempotency-Key":c("enable-space-auth")},body:"{}"}),a=await r.json().catch(()=>({}));if(!r.ok){let s=typeof a?.error=="string"?a.error:`enableSpaceAuth failed (${r.status})`;throw new Error(s)}return a}async function q(e,t,n){let o=await fetch(e,{method:"POST",headers:{Authorization:`Bearer ${t}`,"Content-Type":"application/json","X-OpenRTC-Idempotency-Key":c("mint-space-token")},body:JSON.stringify(n)}),r=await o.json().catch(()=>({}));if(!o.ok){let a=typeof r?.error=="string"?r.error:`mintSpaceToken failed (${o.status})`;throw new Error(a)}if(typeof r?.token!="string"||!r.token.trim())throw new Error("mintSpaceToken response missing token");return r}function d(e){let t=e.apiKey.trim(),n=(e.spaceKey??e.space??"").trim(),o=g(e.sandboxAppId),r=(e.endpointUrl??j).replace(/\/$/,""),a=e.memberIdStorageKey??`openrtc:space-member:${n}${o?`:sandbox:${o}`:""}`;return async()=>{if(!t||!n)throw new Error("spaceToken requires apiKey and space");let s=null;typeof sessionStorage<"u"?(s=sessionStorage.getItem(a),s||(s=globalThis.crypto?.randomUUID?.()??`member-${Date.now()}`,sessionStorage.setItem(a,s))):s=`member-${Date.now()}`;let m=await b().getAppCheckToken(),i=await fetch(`${r}/v1SpacePublicTokens`,{method:"POST",headers:{"Content-Type":"application/json","X-OpenRTC-Idempotency-Key":c("mint-public-space-token"),...m?{"X-Firebase-AppCheck":m}:{}},body:JSON.stringify({apiKey:t,spaceKey:n,memberId:s,...o?{sandboxAppId:o}:{}})}),{text:u,payload:p}=await B(i);if(!i.ok){let f=typeof p?.error=="string"?p.error:u.trim()?u.trim().slice(0,240):`public space token mint failed (${i.status})`;throw new Error(f)}let l=typeof p?.token=="string"?p.token.trim():"";if(!l)throw new Error("public space token response missing token");return {customToken:l}}}function M(e){if(!e.trim())return {};try{let t=JSON.parse(e);return t&&typeof t=="object"?t:{}}catch{return {}}}async function B(e){let t=e.text;if(typeof t=="function"){let o=await t.call(e).catch(()=>"");return {text:o,payload:M(o)}}let n=await e.json().catch(()=>({}));return {text:JSON.stringify(n),payload:n&&typeof n=="object"?n:{}}}function g(e){let t=e?.trim().toLowerCase()??"";if(!t)return "";if(!/^[a-z0-9][a-z0-9-]{0,47}$/.test(t))throw new Error("sandboxAppId must be 1-48 lowercase letters, numbers, or dashes.");return t}function J(e,t){let n=e.trim(),o=g(t);return o?`${n}::sandbox::${o}`:n}var L=d,H=d;
1
+ export{b as TauriRuntimeAdapter,a as createTauriIpcBridge}from'../chunk-O3D7S5MD.js';export{b as runtimeFromCapability}from'../chunk-IAEGDK4P.js';export{b as Connection,t as RuntimeClient,c as RuntimeConnectionController,g as ScopedConnectionActorError,j as ScopedConnectionActorHandle,k as ScopedConnectionActorRegistry,f as clog,r as concatRuntimeBytes,e as correlationForDriveGrantScope,q as createRuntimeJsonFrameDecoder,m as createRuntimeU32BEFrameDecoder,o as decodeRuntimeJsonPayload,p as encodeRuntimeJsonFrame,n as encodeRuntimeJsonPayload,l as encodeRuntimeU32BEFrame,s as readRuntimeU32BE,d as renderCorrelationFields,h as scopedConnectionKey,i as scopedConnectionKeyToString}from'../chunk-NCL672QJ.js';export{f as IpcRuntimeAdapter}from'../chunk-A7AMB23L.js';import'../chunk-C6PAXO3N.js';import'../chunk-7Z6N46RB.js';export{q as BROWSER_WASM_RUNTIME_CAPABILITIES,r as NATIVE_IPC_RUNTIME_CAPABILITIES,o as OPENRTC_RUNTIME_POLICY,s as cloneRuntimeCapabilities,p as getRuntimePolicy,g as logOpenRtcTeardownTrace,t as runtimeCapabilitiesForBrowserHost,u as runtimeCapabilitiesFromNativeStatus,v as runtimeCapabilityProfile}from'../chunk-JIVVHBCB.js';export{b as openRtcDebug,a as openRtcDebugEnabled,c as openRtcDebugInfo,d as openRtcDebugLog}from'../chunk-VK6KX433.js';import'../chunk-NT5YHZQH.js';export{a as classifyNativeIpcFailure,b as isNativeIpcCommandUnavailable}from'../chunk-K37WVIZL.js';import'../chunk-BXFXPIXO.js';import {b}from'../chunk-N26S7V4N.js';import'../chunk-NB4H5TP3.js';import'../chunk-RD3JEGGF.js';import'../chunk-C7YN5MSV.js';export{a as isRuntimeDeviceActive,c as isRuntimeDeviceConnectable,b as isRuntimeDeviceRoutable}from'../chunk-CK6WQV7J.js';var j="https://api.openrtc.app";function c(e){if(typeof globalThis.crypto?.randomUUID!="function")throw new Error(`Secure request identity is unavailable for ${e}.`);return `${e}:${globalThis.crypto.randomUUID()}`}async function z(e,t,n){let o=e.replace(/\/$/,""),r=await fetch(`${o}/v1/spaces/${encodeURIComponent(n)}/scoped-auth`,{method:"POST",headers:{Authorization:`Bearer ${t}`,"Content-Type":"application/json","X-OpenRTC-Idempotency-Key":c("enable-space-auth")},body:"{}"}),a=await r.json().catch(()=>({}));if(!r.ok){let s=typeof a?.error=="string"?a.error:`enableSpaceAuth failed (${r.status})`;throw new Error(s)}return a}async function q(e,t,n){let o=await fetch(e,{method:"POST",headers:{Authorization:`Bearer ${t}`,"Content-Type":"application/json","X-OpenRTC-Idempotency-Key":c("mint-space-token")},body:JSON.stringify(n)}),r=await o.json().catch(()=>({}));if(!o.ok){let a=typeof r?.error=="string"?r.error:`mintSpaceToken failed (${o.status})`;throw new Error(a)}if(typeof r?.token!="string"||!r.token.trim())throw new Error("mintSpaceToken response missing token");return r}function d(e){let t=e.apiKey.trim(),n=(e.spaceKey??e.space??"").trim(),o=g(e.sandboxAppId),r=(e.endpointUrl??j).replace(/\/$/,""),a=e.memberIdStorageKey??`openrtc:space-member:${n}${o?`:sandbox:${o}`:""}`;return async()=>{if(!t||!n)throw new Error("spaceToken requires apiKey and space");let s=null;typeof sessionStorage<"u"?(s=sessionStorage.getItem(a),s||(s=globalThis.crypto?.randomUUID?.()??`member-${Date.now()}`,sessionStorage.setItem(a,s))):s=`member-${Date.now()}`;let m=await b().getAppCheckToken(),i=await fetch(`${r}/v1SpacePublicTokens`,{method:"POST",headers:{"Content-Type":"application/json","X-OpenRTC-Idempotency-Key":c("mint-public-space-token"),...m?{"X-Firebase-AppCheck":m}:{}},body:JSON.stringify({apiKey:t,spaceKey:n,memberId:s,...o?{sandboxAppId:o}:{}})}),{text:u,payload:p}=await B(i);if(!i.ok){let f=typeof p?.error=="string"?p.error:u.trim()?u.trim().slice(0,240):`public space token mint failed (${i.status})`;throw new Error(f)}let l=typeof p?.token=="string"?p.token.trim():"";if(!l)throw new Error("public space token response missing token");return {customToken:l}}}function M(e){if(!e.trim())return {};try{let t=JSON.parse(e);return t&&typeof t=="object"?t:{}}catch{return {}}}async function B(e){let t=e.text;if(typeof t=="function"){let o=await t.call(e).catch(()=>"");return {text:o,payload:M(o)}}let n=await e.json().catch(()=>({}));return {text:JSON.stringify(n),payload:n&&typeof n=="object"?n:{}}}function g(e){let t=e?.trim().toLowerCase()??"";if(!t)return "";if(!/^[a-z0-9][a-z0-9-]{0,47}$/.test(t))throw new Error("sandboxAppId must be 1-48 lowercase letters, numbers, or dashes.");return t}function J(e,t){let n=e.trim(),o=g(t);return o?`${n}::sandbox::${o}`:n}var L=d,H=d;
2
2
  export{d as createPublicSpaceTokenProvider,H as createSpaceTokenProvider,z as enableSpaceAuth,q as mintSpaceToken,J as sandboxSpaceKey,L as spaceToken};
@@ -1 +1 @@
1
- export{a as createLegacyOpenRTC}from'../chunk-LBRXS637.js';import'../chunk-2QHDEGVX.js';import'../chunk-VGMSLZH5.js';import'../chunk-XDYCWI5Z.js';import'../chunk-PEBFQ4CL.js';import'../chunk-N4SX7C3W.js';import'../chunk-QHWMILLL.js';import'../chunk-NRO64VRR.js';import'../chunk-6KCPRIB5.js';import'../chunk-7Z6N46RB.js';import'../chunk-JUHDH6K4.js';import'../chunk-VK6KX433.js';import'../chunk-NT5YHZQH.js';import'../chunk-K37WVIZL.js';import'../chunk-BXFXPIXO.js';import'../chunk-N26S7V4N.js';import'../chunk-NB4H5TP3.js';import'../chunk-RD3JEGGF.js';import'../chunk-C7YN5MSV.js';
1
+ export{a as createLegacyOpenRTC}from'../chunk-DZCZLRM5.js';import'../chunk-2QHDEGVX.js';import'../chunk-D45U2NXV.js';import'../chunk-EUNCYGJD.js';import'../chunk-IAIGT5G3.js';import'../chunk-N4SX7C3W.js';import'../chunk-NCL672QJ.js';import'../chunk-A7AMB23L.js';import'../chunk-C6PAXO3N.js';import'../chunk-7Z6N46RB.js';import'../chunk-JIVVHBCB.js';import'../chunk-VK6KX433.js';import'../chunk-NT5YHZQH.js';import'../chunk-K37WVIZL.js';import'../chunk-BXFXPIXO.js';import'../chunk-N26S7V4N.js';import'../chunk-NB4H5TP3.js';import'../chunk-RD3JEGGF.js';import'../chunk-C7YN5MSV.js';
@@ -1 +1 @@
1
- export{b as TauriRuntimeAdapter,a as createTauriIpcBridge}from'../chunk-CA6HLY7T.js';import'../chunk-NRO64VRR.js';import'../chunk-6KCPRIB5.js';import'../chunk-JUHDH6K4.js';import'../chunk-VK6KX433.js';import'../chunk-NT5YHZQH.js';import'../chunk-K37WVIZL.js';import'../chunk-BXFXPIXO.js';import'../chunk-N26S7V4N.js';import'../chunk-NB4H5TP3.js';import'../chunk-RD3JEGGF.js';import'../chunk-C7YN5MSV.js';
1
+ export{b as TauriRuntimeAdapter,a as createTauriIpcBridge}from'../chunk-O3D7S5MD.js';import'../chunk-A7AMB23L.js';import'../chunk-C6PAXO3N.js';import'../chunk-JIVVHBCB.js';import'../chunk-VK6KX433.js';import'../chunk-NT5YHZQH.js';import'../chunk-K37WVIZL.js';import'../chunk-BXFXPIXO.js';import'../chunk-N26S7V4N.js';import'../chunk-NB4H5TP3.js';import'../chunk-RD3JEGGF.js';import'../chunk-C7YN5MSV.js';
package/dist/testing.js CHANGED
@@ -1 +1 @@
1
- import {a as a$1}from'./chunk-BY3EPIAB.js';import {c}from'./chunk-IAEGDK4P.js';import {a}from'./chunk-LBRXS637.js';import'./chunk-2QHDEGVX.js';import'./chunk-VGMSLZH5.js';import'./chunk-XDYCWI5Z.js';import'./chunk-PEBFQ4CL.js';import'./chunk-N4SX7C3W.js';import'./chunk-QHWMILLL.js';import'./chunk-NRO64VRR.js';import'./chunk-6KCPRIB5.js';import'./chunk-7Z6N46RB.js';import'./chunk-JUHDH6K4.js';import'./chunk-VK6KX433.js';import'./chunk-NT5YHZQH.js';import'./chunk-K37WVIZL.js';import'./chunk-BXFXPIXO.js';import'./chunk-N26S7V4N.js';import'./chunk-NB4H5TP3.js';import'./chunk-RD3JEGGF.js';import'./chunk-C7YN5MSV.js';function m(e,t,n={}){return c(e,{endpoints:t,testingAllowInsecureLoopback:true,platform:"web",...n.deviceId?{deviceIdProvider:async()=>n.deviceId}:{},...n.irohTestRelayUrl?{irohTestRelayUrl:n.irohTestRelayUrl}:{},runtimeFactory:async i=>{let{createWasmClient:o}=await import('./factories-JWIRMXCV.js');return o(i)}})}function d(e,t,n){return c(e,{endpoints:t,testingAllowInsecureLoopback:true,platform:"native",deviceKeyProvider:a$1(n),deviceIdProvider:async()=>{let i=await n.invoke("get_rtc_local_device_info");return String(i?.deviceId??"")},runtimeFactory:async i=>{let{createIpcClient:o}=await import('./ipcFactory-UAVK2YED.js');return o(i,n)}})}function p(e){let t=e.coordinationGateway;return {...e,...t?{coordinationGateway:{...t,testingAllowInsecureLoopback:true}}:{}}}var C=Object.assign(e=>a(p(e)),{native:(e,t)=>a.native(p(e),t)});export{C as createTestingLegacyOpenRTC,d as createTestingNativeOpenRTC,m as createTestingOpenRTC};
1
+ import {a as a$1}from'./chunk-BY3EPIAB.js';import {c}from'./chunk-IAEGDK4P.js';import {a}from'./chunk-DZCZLRM5.js';import'./chunk-2QHDEGVX.js';import'./chunk-D45U2NXV.js';import'./chunk-EUNCYGJD.js';import'./chunk-IAIGT5G3.js';import'./chunk-N4SX7C3W.js';import'./chunk-NCL672QJ.js';import'./chunk-A7AMB23L.js';import'./chunk-C6PAXO3N.js';import'./chunk-7Z6N46RB.js';import'./chunk-JIVVHBCB.js';import'./chunk-VK6KX433.js';import'./chunk-NT5YHZQH.js';import'./chunk-K37WVIZL.js';import'./chunk-BXFXPIXO.js';import'./chunk-N26S7V4N.js';import'./chunk-NB4H5TP3.js';import'./chunk-RD3JEGGF.js';import'./chunk-C7YN5MSV.js';function m(e,t,n={}){return c(e,{endpoints:t,testingAllowInsecureLoopback:true,platform:"web",...n.deviceId?{deviceIdProvider:async()=>n.deviceId}:{},...n.irohTestRelayUrl?{irohTestRelayUrl:n.irohTestRelayUrl}:{},runtimeFactory:async i=>{let{createWasmClient:o}=await import('./factories-TLUZAXUG.js');return o(i)}})}function d(e,t,n){return c(e,{endpoints:t,testingAllowInsecureLoopback:true,platform:"native",deviceKeyProvider:a$1(n),deviceIdProvider:async()=>{let i=await n.invoke("get_rtc_local_device_info");return String(i?.deviceId??"")},runtimeFactory:async i=>{let{createIpcClient:o}=await import('./ipcFactory-QOAZVE56.js');return o(i,n)}})}function p(e){let t=e.coordinationGateway;return {...e,...t?{coordinationGateway:{...t,testingAllowInsecureLoopback:true}}:{}}}var C=Object.assign(e=>a(p(e)),{native:(e,t)=>a.native(p(e),t)});export{C as createTestingLegacyOpenRTC,d as createTestingNativeOpenRTC,m as createTestingOpenRTC};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openrtc",
3
- "version": "2.0.0-rc.7",
3
+ "version": "2.0.0-rc.8",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -1,2 +0,0 @@
1
- import {b as b$2,c as c$1,l,o,f as f$2}from'./chunk-VK6KX433.js';import {c as c$2,a as a$1,e as e$1}from'./chunk-NT5YHZQH.js';import {b as b$1,c}from'./chunk-N26S7V4N.js';import {b,a,d as d$1}from'./chunk-NB4H5TP3.js';import {e,g as g$1,f as f$1,h,d}from'./chunk-RD3JEGGF.js';import*as U from'tweetnacl';var et=3e4,tt=5*6e4,nt=3e4,it=12,V=15e3,rt=15e3,ot=1e3,Pe=250,st="openrtc.v1",at="openrtc.auth.",f=class extends Error{constructor(t,i){super(t);this.retryable=i;this.name="CoordinationConnectError";this.code=a$1.COORDINATION_DISCONNECTED;this.plane="coordination";}},J=class extends Error{constructor(t,i,r){let o=e$1({code:t,message:i,retryable:r});super(`Coordination gateway ${t}: ${i}`);this.name="CoordinationGatewayProtocolError";this.code=o.code||t||a$1.COORDINATION_PROTOCOL,this.retryable=r,this.plane=o.plane;}};function Ae(n){return n instanceof f&&/\bstale-budget\b/i.test(n.message)}function Ee(n){let e=typeof n=="object"&&n!==null&&"code"in n?String(n.code??""):"";return ["functions/unauthenticated","functions/permission-denied","functions/invalid-argument","functions/failed-precondition","functions/resource-exhausted","unauthenticated","permission-denied","invalid-argument","failed-precondition","resource-exhausted"].includes(e)}function ct(n){let e=new Uint32Array(1);return crypto.getRandomValues(e),Math.max(1,Math.round(n*(.75+e[0]/4294967295*.5)))}function T(n){if(typeof crypto.randomUUID=="function")return `${n}:${crypto.randomUUID()}`;let e=new Uint8Array(16);crypto.getRandomValues(e);let t=Array.from(e,i=>i.toString(16).padStart(2,"0")).join("");return `${n}:${t}`}async function dt(n){let e=await crypto.subtle.digest("SHA-256",new TextEncoder().encode(n)),t="";for(let i of new Uint8Array(e))t+=String.fromCharCode(i);return btoa(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"")}function lt(n,e,t){let i=new URL(n);if(i.search||i.hash||i.username||i.password)throw new Error("[OpenRTC] Coordination gateway endpoint must not contain credentials, query, or fragment.");if(i.protocol==="https:")i.protocol="wss:";else if(i.protocol==="http:")i.protocol="ws:";else if(i.protocol!=="wss:"&&i.protocol!=="ws:")throw new Error("[OpenRTC] Coordination gateway endpoint must use HTTPS/WSS.");return i.pathname=`${i.pathname.replace(/\/+$/,"")}/v${t}/connect/${e}`,i.toString()}function _e(n){let e=new URL(n);return e.protocol==="wss:"&&(e.protocol="https:"),e.protocol==="ws:"&&(e.protocol="http:"),e.origin}function ut(n,e){let t=n.trim();if(!t)throw new Error("[OpenRTC] Firebase project ID is required for the native gateway credential.");let i=typeof globalThis>"u"?"":String(globalThis.__OPENRTC_FUNCTIONS_EMULATOR_HOST__??"").trim();if(i)return `http://${i}/${encodeURIComponent(t)}/us-central1`;let r=e.controlPlaneEndpoint?.trim()||(e.environment==="production"?"https://api.openrtc.app":"");if(!r)throw new Error("[OpenRTC] Internal staging coordination requires coordinationGateway.controlPlaneEndpoint.");let o=typeof globalThis.location?.origin=="string"?globalThis.location.origin:void 0,s=new URL(r,o);if(s.protocol!=="https:"&&s.protocol!=="http:"||s.username||s.password||s.search||s.hash)throw new Error("[OpenRTC] Coordination control-plane endpoint is invalid.");return s.toString().replace(/\/+$/,"")}function ke(n,e,t){return `${ut(n,e)}/${encodeURIComponent(t)}`}async function Me(n){let e=`request failed with status ${n.status}`;try{let t=await n.json(),i=typeof t.error?.message=="string"?t.error.message.trim():"";return i?i.slice(0,256):e}catch{return e}}var Q=class n{constructor(e){this.options=e;this.runtimeInstanceId=T("runtime");this.socket=null;this.socketReady=false;this.activeGrantToken=null;this.activeGrantProtocolVersion=1;this.leaseRefreshMode="off";this.pendingLeaseRefreshKey=null;this.connectPromise=null;this.desiredPresence=null;this.desiredExcludedPeers=[];this.devices=new Map;this.deviceListeners=new Set;this.deviceStreams=new Set;this.sessionStreams=new Set;this.pendingAcks=new Map;this.pendingMessages=[];this.roomConnections=new Map;this.friendConnections=new Map;this.reconnectTimer=null;this.authRefreshTimer=null;this.pendingAuthRefresh=null;this.budgetRenewalPromise=null;this.budgetRenewalEpoch=0;this.reconnectAttempt=0;this.reconnectCircuitOpen=false;this.connectionReadyWaiters=new Set;this.hostResumeReconnectPromise=null;this.lastHostResumeReconnectAtMs=0;this.desiredPresenceRevision=0;this.appliedPresenceRevision=0;this.stopped=false;if(e.gateway.environment!=="staging"&&e.gateway.environment!=="production")throw new Error("[OpenRTC] Coordination gateway environment is invalid.");let t=new URL(e.gateway.endpoint),i=t.hostname==="127.0.0.1"||t.hostname==="localhost"||t.hostname==="[::1]",r=t.protocol==="https:"||t.protocol==="wss:",o=e.gateway.testingAllowInsecureLoopback===true&&i&&(t.protocol==="http:"||t.protocol==="ws:");if(!r&&!o)throw new Error("[OpenRTC] Coordination gateway requires HTTPS/WSS.");if(t.username||t.password||t.search||t.hash)throw new Error("[OpenRTC] Coordination gateway credentials and parameters cannot be supplied in its URL.")}async updatePresence(e,t,i,r,o,s){let a=this.desiredPresence;this.desiredPresence={localNodeId:e,ticket:t,online:i,ttlMs:r,metadata:o,deviceName:s?.trim()||this.options.getDefaultDeviceName()},(!a||a.localNodeId!==e||a.ticket!==t||a.online!==i||a.ttlMs!==r||a.metadata!==o||a.deviceName!==this.desiredPresence.deviceName)&&(this.desiredPresenceRevision+=1,this.reconnectCircuitOpen=false,this.reconnectAttempt=0);let d=this.desiredPresenceRevision;await this.ensureConnected(),!(this.appliedPresenceRevision>=d)&&(a&&a.ticket!==t&&await this.refreshAuthentication(),await this.sendOperation({v:1,type:"presence.upsert",idempotencyKey:T("presence"),ttlMs:r,device:this.gatewayDevice(this.desiredPresence)}),this.appliedPresenceRevision=Math.max(this.appliedPresenceRevision,d));}async setOffline(e){this.desiredPresence&&(this.desiredPresence.online=false,this.socket?.readyState===WebSocket.OPEN&&await this.sendOperation({v:1,type:"presence.offline",idempotencyKey:T("offline")}));}async reconnectAfterHostResume(){if(this.desiredPresence){if(this.hostResumeReconnectPromise)return this.hostResumeReconnectPromise;if(!(Date.now()-this.lastHostResumeReconnectAtMs<rt)){this.lastHostResumeReconnectAtMs=Date.now(),this.hostResumeReconnectPromise=(async()=>{(this.socket?.readyState===WebSocket.OPEN||this.socketReady)&&this.stopSocket(),await this.ensureConnected();})();try{await this.hostResumeReconnectPromise;}finally{this.hostResumeReconnectPromise=null;}}}}async updateDevice(e,t){if(e!==this.options.getLocalDeviceId())throw new Error("A coordination socket can update only its local device.");let i=t;if(t.excludedPeers!==void 0){let r=[...new Set(t.excludedPeers.map(o=>String(o??"").trim().toLowerCase()).filter(Boolean))].sort();if(r.length>Pe)throw new Error(`Coordination excluded-peer set exceeds ${Pe} devices.`);this.desiredExcludedPeers=r,i={...t,excludedPeers:r};}await this.ensureConnected(),await this.sendOperation({v:1,type:"device.patch",idempotencyKey:T("device-patch"),patch:i});}async deleteDevice(e){if(this.options.credentialPurpose!=="device-control"&&(!this.socketReady||this.socket?.readyState!==WebSocket.OPEN)){let t=new n({...this.options,credentialPurpose:"device-control"});try{await t.deleteDevice(e);}finally{t.stopAuthScopedActivity();}return}await this.ensureConnected();try{await this.sendOperation({v:1,type:"device.delete",idempotencyKey:T("device-delete"),targetDeviceId:e});}finally{this.options.credentialPurpose==="device-control"&&this.stopSocket();}}async cleanupStaleDevices(){}async searchDevices(e){return this.snapshot(e)}async listDevices(e){return this.snapshot(e)}onDevicesChange(e,t){let i=r=>e(t?r.filter(o=>o.nodeId!==t):r);return this.deviceListeners.add(i),i(this.snapshot()),this.desiredPresence&&this.ensureConnected(),()=>this.deviceListeners.delete(i)}async subscribeDevices(){let e=null;return new ReadableStream({start:t=>{e=t,this.deviceStreams.add(t);let i=this.snapshot().map(r=>({type:"added",device:r}));i.length>0&&t.enqueue(i);},cancel:()=>{e&&this.deviceStreams.delete(e),e=null;}})}async createSession(e){await this.ensureConnected(),await this.sendOperation({v:1,type:"session.put",idempotencyKey:T("session-put"),sessionId:e.connectionId,session:e,expiresAtMs:e.expiresAt??Date.now()+15*6e4});}async updateSession(e,t){await this.ensureConnected(),await this.sendOperation({v:1,type:"session.put",idempotencyKey:T("session-update"),sessionId:this.unscopedId(e),session:t,expiresAtMs:typeof t.expiresAt=="number"?t.expiresAt:Date.now()+15*6e4});}async subscribeSessions(e){let t=null;return new ReadableStream({start:i=>{t=i,this.sessionStreams.add(i);},cancel:()=>{t&&this.sessionStreams.delete(t),t=null;}})}async sendMessage(e,t,i,r){await this.ensureConnected();let o=T("signal");return await this.sendOperation({v:1,type:"signal.send",idempotencyKey:o,targetDeviceId:this.unscopedId(e),payload:t,state:i,replyPayload:r}),o}async pollMessages(e){return this.pendingMessages.splice(0,this.pendingMessages.length)}watchFriendDevices(e,t){let i=[...new Set(e.map(a=>a.trim()).filter(Boolean))];if(i.length>25)throw new RangeError(`watchFriendDevices accepts at most ${25} unique friend IDs per runtime.`);for(let a of i)if(a.length>128||a.includes("/"))throw new TypeError('Friend user IDs must be 1-128 characters and cannot contain "/".');let r={value:false},o=new Map,s=[];t(new Map);for(let a of i)!a||a===this.options.getCurrentUserId()||this.openFriendConnection(a).then(c=>{if(r.value){c.stopAuthScopedActivity();return}s.push(c.onDevicesChange(d=>{o.set(a,d.filter(l=>l.online)),t(new Map(o));}));}).catch(()=>{r.value||(o.set(a,[]),t(new Map(o)));});return ()=>{r.value=true;for(let a of s)a();for(let a of i)this.friendConnections.get(a)?.stopAuthScopedActivity(),this.friendConnections.delete(a);}}async updateFriendTicket(e){await this.ensureConnected(),await this.sendOperation({v:1,type:"device.patch",idempotencyKey:T("friend-ticket"),patch:{friendTicket:e??""}});}async handleScopeChange(){this.stopSocket(),this.reconnectCircuitOpen=false,this.reconnectAttempt=0,this.appliedPresenceRevision=0,this.devices.clear(),this.emitDevices();}stopAuthScopedActivity(){this.stopped=true,this.stopSocket(),this.rejectConnectionReadyWaiters(new f("Coordination activity stopped before room admission completed.",false)),this.desiredExcludedPeers=[];for(let e of this.pendingAcks.values())clearTimeout(e.timer),e.resolve();this.pendingAcks.clear(),this.devices.clear(),this.pendingMessages.splice(0,this.pendingMessages.length),this.emitDevices();for(let e of this.roomConnections.values())e.stopAuthScopedActivity();this.roomConnections.clear();for(let e of this.friendConnections.values())e.stopAuthScopedActivity();this.friendConnections.clear();}usesCoordinationGateway(){return true}async joinCoordinationRoom(e,t,i){let r=e.trim().toUpperCase(),o=this.roomConnections.get(r);o||(o=new n({...this.options,avenueOverride:{kind:"room",id:r}}),this.roomConnections.set(r,o));try{await o.updatePresence(t,i,!0,5*6e4,void 0,this.options.getDefaultDeviceName());}catch(s){if(!(s instanceof f)||!s.retryable)throw s;await o.waitForConnectionReady();}}async leaveCoordinationRoom(e){let t=e.trim().toUpperCase(),i=this.roomConnections.get(t);i&&(await i.setOffline(this.options.getLocalDeviceId()).catch(()=>{}),i.stopAuthScopedActivity(),this.roomConnections.delete(t));}async getCoordinationRoomMembers(e){return this.requireRoomConnection(e).snapshot().map(i=>this.roomMember(i))}watchCoordinationRoomMembers(e,t){return this.requireRoomConnection(e).onDevicesChange(r=>t(r.map(o=>this.roomMember(o))))}async ensureConnected(){if(this.connectPromise)return this.connectPromise;if(!(this.socket?.readyState===WebSocket.OPEN&&this.socketReady)){if(!this.desiredPresence&&this.options.credentialPurpose!=="device-control")throw new Error("Coordination presence must be initialized before the gateway can connect.");if(this.reconnectCircuitOpen)throw new f("Coordination reconnect circuit is open until presence or scope changes.",false);if(this.reconnectTimer)throw new f("Coordination reconnect is already scheduled.",true);this.stopped=false,this.connectPromise=this.connect();try{await this.connectPromise;}catch(e){throw this.scheduleReconnect(e),e}finally{this.connectPromise=null;}}}async connect(){let e=this.desiredPresence??this.controlPresence(),t=this.desiredPresenceRevision,i=async()=>{let r=await this.mintGatewayCredential(e,false);await new Promise((o,s)=>{let a=new WebSocket(lt(r.gatewayUrl,r.routeKey,r.protocolVersion),[st,`${at}${r.token}`]);this.socket=a;let c=false,d=null,l=setTimeout(()=>{a.close(4408,"authentication timeout"),d=new f("Coordination gateway authentication timed out.",true),s(d);},V);a.onopen=()=>{a.send(JSON.stringify({v:1,type:"auth",token:r.token,device:this.gatewayDevice(e)}));},a.onmessage=m=>{let h;try{h=JSON.parse(String(m.data));}catch{a.close(4400,"invalid gateway frame"),c||(clearTimeout(l),s(new Error("Coordination gateway returned an invalid frame.")));return}if(h.type==="ready"&&!c&&(this.activeGrantToken=r.token,this.activeGrantProtocolVersion=r.protocolVersion,this.leaseRefreshMode=h.leaseRefreshMode??"off",c=true,this.socketReady=true,this.appliedPresenceRevision=Math.max(this.appliedPresenceRevision,this.desiredPresence?t:0),clearTimeout(l),this.reconnectAttempt=0,this.scheduleAuthRefresh(r.expiresAtMs,r.protocolVersion),this.resolveConnectionReadyWaiters(),o()),h.type==="error"&&!c){d=new f(`Coordination gateway ${h.code}: ${h.message}`,h.retryable),clearTimeout(l),s(d),a.close(4403,h.code);return}this.handleFrame(h);},a.onerror=()=>{c||(clearTimeout(l),d??(d=new f("Coordination gateway connection failed.",true)),s(d));},a.onclose=m=>{clearTimeout(l),this.socket===a&&(this.socket=null,this.socketReady=false),this.rejectPendingAcks("Coordination gateway connection closed."),this.rejectPendingAuthRefresh(new f("Coordination gateway closed during credential refresh.",m.code!==4401&&m.code!==4403)),!this.stopped&&this.desiredPresence&&m.code!==1e3&&!Ae(d)&&this.scheduleReconnect(d??new f(`Coordination gateway closed (${m.code}).`,m.code!==4401));};});};try{await i();}catch(r){if(!Ae(r))throw r;await i();}}async mintGatewayCredential(e,t){let r={avenue:await this.resolveAvenue(),deviceId:this.options.getLocalDeviceId(),runtimeInstanceId:this.runtimeInstanceId,ticketFingerprint:await dt(e.ticket),purpose:this.options.credentialPurpose??"presence",idempotencyKey:T("credential")},o;try{o=this.options.gateway.grantProvider?await this.options.gateway.grantProvider({...r,...t&&this.activeGrantToken?{refreshGrant:this.activeGrantToken}:{}}):this.options.getPlatformType()==="web"?await this.mintBrowserCredential(r):await this.mintNativeCredential(r);}catch(a){throw a instanceof f?a:new f(a instanceof Error?a.message:"Coordination credential mint failed.",!Ee(a))}if(o.protocolVersion!==1&&o.protocolVersion!==2)throw new f("Unsupported coordination gateway protocol.",false);let s=_e(this.options.gateway.endpoint);if(_e(o.gatewayUrl)!==s)throw new f("Coordination credential returned an unexpected gateway origin.",false);return o}async mintBrowserCredential(e){let t=async s=>{let a=await this.options.getAuthToken(s);if(!a)throw new f("[OpenRTC] Browser coordination requires an authenticated runtime.",false);let c=await this.options.getAppCheckToken(s);if(!c)throw new f("[OpenRTC] Browser coordination requires platform attestation.",false);return fetch(ke(this.options.projectId,this.options.gateway,"mintCoordinationCredential"),{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${a}`,"X-Firebase-AppCheck":c},body:JSON.stringify({data:e}),signal:AbortSignal.timeout(15e3)})},i=await t(false);if((i.status===401||i.status===403)&&(i=await t(true)),!i.ok)throw new f(`[OpenRTC] Browser coordination credential denied: ${await Me(i)}`,i.status===408||i.status===425||i.status===429||i.status>=500);let r=await i.json(),o=r.result??r.data;if(!o)throw new f("[OpenRTC] Browser coordination credential returned an invalid callable response.",false);return o}async getNativeTrustToken(e=false){return (await this.options.nativeTrustTokens.get(e)).token}async mintNativeCredential(e){let t=await this.options.getAuthToken(false);if(!t)throw new Error("[OpenRTC] Native coordination requires an authenticated runtime.");let i=async a=>{let[c,d]=await Promise.all([a?this.options.getAuthToken(true):Promise.resolve(t),this.getNativeTrustToken(a)]);if(!c)throw new Error("[OpenRTC] Native coordination requires an authenticated runtime.");return fetch(ke(this.options.projectId,this.options.gateway,"mintNativeCoordinationCredential"),{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${c}`,"X-Firebase-AppCheck":d},body:JSON.stringify({data:e}),signal:AbortSignal.timeout(15e3)})},r=await i(false);if((r.status===401||r.status===403)&&(this.options.nativeTrustTokens.invalidate(),r=await i(true)),!r.ok)throw new f(`[OpenRTC] Native coordination credential denied: ${await Me(r)}`,r.status===408||r.status===425||r.status===429||r.status>=500);let o=await r.json(),s=o.result??o.data;if(!s)throw new Error("[OpenRTC] Native coordination credential returned an invalid callable response.");return s}handleFrame(e){if(e.type==="auth.refreshed"){let t=this.pendingAuthRefresh;t&&(clearTimeout(t.timer),this.pendingAuthRefresh=null,this.pendingLeaseRefreshKey=null,this.scheduleAuthRefresh(e.expiresAtMs,this.activeGrantProtocolVersion),t.resolve());}else if(e.type==="lease.refreshed"){let t=this.pendingAuthRefresh;t&&e.idempotencyKey===this.pendingLeaseRefreshKey&&(clearTimeout(t.timer),this.pendingAuthRefresh=null,this.pendingLeaseRefreshKey=null,this.scheduleAuthRefresh(e.expiresAtMs,this.activeGrantProtocolVersion),t.resolve());}else if(e.type==="roster.snapshot"){this.devices.clear();for(let t of e.devices)this.devices.set(t.deviceId,this.toDevice(t));this.emitDevices();}else if(e.type==="presence.changed"){if(e.operation==="delete")this.devices.delete(e.device.deviceId),this.emitDeviceEvents([{type:"removed",deviceId:e.device.deviceId}]);else {let t=this.devices.has(e.device.deviceId),i=this.toDevice(e.device);this.devices.set(i.deviceId,i),this.emitDeviceEvents([{type:t?"modified":"added",device:i}]);}this.emitDevices();}else if(e.type==="signal.received")this.pendingMessages.length>=ot&&this.pendingMessages.shift(),this.pendingMessages.push({senderId:e.senderDeviceId,targetId:this.options.getLocalDeviceId(),payload:e.payload,state:e.state,replyPayload:e.replyPayload,timestamp:e.createdAtMs,appTag:this.options.appTag});else if(e.type==="session.changed"){let t=e.operation==="delete"?[{type:"removed",sessionId:e.sessionId}]:[{type:"modified",session:{...e.session??{},connectionId:e.sessionId}}];for(let i of this.sessionStreams)i.enqueue(t);}else if(e.type==="ack"){let t=this.pendingAcks.get(e.idempotencyKey);t&&(clearTimeout(t.timer),this.pendingAcks.delete(e.idempotencyKey),t.resolve());}else if(e.type==="error"){if(this.pendingAuthRefresh&&(!e.idempotencyKey||e.idempotencyKey===this.pendingLeaseRefreshKey)){let i=this.pendingAuthRefresh;clearTimeout(i.timer),this.pendingAuthRefresh=null,this.pendingLeaseRefreshKey=null,i.reject(new f(`Coordination gateway ${e.code}: ${e.message}`,e.retryable));return}let t=e.idempotencyKey?this.pendingAcks.get(e.idempotencyKey):null;t&&(clearTimeout(t.timer),this.pendingAcks.delete(e.idempotencyKey),t.reject(new J(e.code,e.message,e.retryable)));}}async sendOperation(e){this.budgetRenewalPromise&&await this.budgetRenewalPromise;let t=this.budgetRenewalEpoch;try{await this.sendOperationOnce(e);}catch(i){if(!(i instanceof J)||i.code!=="budget-renewal-required"&&i.code!==a$1.BUDGET_RENEWAL_REQUIRED||!i.retryable)throw i;this.budgetRenewalEpoch===t&&await this.renewBudget(),await this.sendOperationOnce(e);}}async sendOperationOnce(e){let t=this.socket;if(!t||t.readyState!==WebSocket.OPEN||!this.socketReady)throw new Error("Coordination gateway is not connected.");await new Promise((i,r)=>{let o=setTimeout(()=>{this.pendingAcks.delete(e.idempotencyKey),r(new Error("Coordination gateway acknowledgement timed out."));},V);this.pendingAcks.set(e.idempotencyKey,{resolve:i,reject:r,timer:o}),t.send(JSON.stringify(e));});}async renewBudget(){if(this.budgetRenewalPromise)return this.budgetRenewalPromise;let e=this.refreshAuthentication().then(()=>{this.budgetRenewalEpoch+=1;});this.budgetRenewalPromise=e;try{await e;}finally{this.budgetRenewalPromise===e&&(this.budgetRenewalPromise=null);}}async resolveAvenue(){if(this.options.avenueOverride)return this.options.avenueOverride;if((this.options.discoveryMode??"space")==="space"){let t=await this.options.resolveSpaceNamespaceId();if(!t)throw new Error("Space namespace is not available for coordination.");return {kind:"space",id:t}}let e=this.options.getCurrentUserId();if(!e)throw new Error("Authenticated user is required for coordination.");return {kind:"user",id:e}}gatewayDevice(e){return {deviceId:this.options.getLocalDeviceId(),runtimeInstanceId:this.runtimeInstanceId,nodeId:e.localNodeId,deviceName:e.deviceName,platformType:this.options.getPlatformType(),ticket:e.ticket,metadata:e.metadata,excludedPeers:this.desiredExcludedPeers,online:e.online}}controlPresence(){if(this.options.credentialPurpose!=="device-control")throw new Error("Coordination presence must be initialized before the gateway can connect.");return {localNodeId:this.options.getLocalDeviceId(),ticket:`openrtc-device-control:${this.runtimeInstanceId}`,online:false,ttlMs:0,deviceName:this.options.getDefaultDeviceName()}}toDevice(e){return this.options.normalizeDevice({...e,appTag:this.options.appTag,lastSeenAt:e.updatedAtMs,expiresAt:e.expiresAtMs},e.deviceId)}snapshot(e){return [...this.devices.values()].filter(t=>!e||t.nodeId!==e).sort((t,i)=>t.deviceId.localeCompare(i.deviceId))}emitDevices(){let e=this.snapshot();for(let t of this.deviceListeners)t(e);}emitDeviceEvents(e){for(let t of this.deviceStreams)t.enqueue(e);}scheduleAuthRefresh(e,t){this.authRefreshTimer&&clearTimeout(this.authRefreshTimer);let i=e-Date.now(),r=t===2?tt:et,o=i>r+1e3;this.authRefreshTimer=setTimeout(()=>{if(this.authRefreshTimer=null,this.stopped)return;if(!o){this.stopSocket(false),this.scheduleReconnect(new f("Coordination credential crossed a billing boundary.",true));return}(t===2&&this.leaseRefreshMode==="active"?this.refreshLease():this.refreshAuthentication()).catch(a=>{this.stopSocket(false),this.scheduleReconnect(a);});},o?i-r:Math.max(1e3,i+1e3));}async refreshAuthentication(e=false){let t=this.socket,i=this.desiredPresence;if(!t||t.readyState!==WebSocket.OPEN||!this.socketReady||!i)throw new f("Coordination socket is unavailable for credential refresh.",true);if(this.pendingAuthRefresh)return this.pendingAuthRefresh.promise;let r=await this.mintGatewayCredential(i,!e),o,s,a=new Promise((d,l)=>{o=d,s=l;}),c=setTimeout(()=>{this.pendingAuthRefresh?.timer===c&&(this.pendingAuthRefresh=null),s(new f("Coordination credential refresh timed out.",true));},V);this.pendingAuthRefresh={promise:a,resolve:o,reject:s,timer:c},t.send(JSON.stringify({v:1,type:"auth.refresh",token:r.token})),await a,this.activeGrantToken=r.token,this.activeGrantProtocolVersion=r.protocolVersion;}async refreshLease(){let e=this.socket;if(!e||e.readyState!==WebSocket.OPEN||!this.socketReady)throw new f("Coordination socket is unavailable for lease refresh.",true);if(this.pendingAuthRefresh)return this.pendingAuthRefresh.promise;let t=T("lease"),i,r,o=new Promise((a,c)=>{i=a,r=c;}),s=setTimeout(()=>{this.pendingAuthRefresh?.timer===s&&(this.pendingAuthRefresh=null,this.pendingLeaseRefreshKey=null),r(new f("Coordination lease refresh timed out.",true));},V);this.pendingLeaseRefreshKey=t,this.pendingAuthRefresh={promise:o,resolve:i,reject:r,timer:s},e.send(JSON.stringify({v:1,type:"lease.refresh",idempotencyKey:t}));try{await o;}catch{await this.refreshAuthentication(true);}}scheduleReconnect(e){if(this.reconnectTimer||this.reconnectCircuitOpen||this.stopped)return;if(!(e instanceof f?e.retryable:!Ee(e))||this.reconnectAttempt>=it){this.reconnectCircuitOpen=true,this.rejectConnectionReadyWaiters(e instanceof Error?e:new f("Coordination reconnect circuit is open.",false));return}let i=ct(d$1(this.reconnectAttempt++,250,nt));this.reconnectTimer=setTimeout(()=>{this.reconnectTimer=null,this.ensureConnected().catch(r=>this.scheduleReconnect(r));},i);}stopSocket(e=true){e&&this.reconnectTimer&&clearTimeout(this.reconnectTimer),this.authRefreshTimer&&clearTimeout(this.authRefreshTimer),this.reconnectTimer=null,this.authRefreshTimer=null,this.leaseRefreshMode="off",this.pendingLeaseRefreshKey=null,this.rejectPendingAuthRefresh(new f("Coordination credential refresh was canceled.",true));let t=this.socket;this.socket=null,this.socketReady=false,t?.close(1e3,"coordination session stopped");}waitForConnectionReady(){return this.socket?.readyState===WebSocket.OPEN&&this.socketReady?Promise.resolve():this.stopped||this.reconnectCircuitOpen?Promise.reject(new f("Coordination reconnect circuit is unavailable.",false)):new Promise((e,t)=>{this.connectionReadyWaiters.add({resolve:e,reject:t});})}resolveConnectionReadyWaiters(){for(let e of this.connectionReadyWaiters)e.resolve();this.connectionReadyWaiters.clear();}rejectConnectionReadyWaiters(e){for(let t of this.connectionReadyWaiters)t.reject(e);this.connectionReadyWaiters.clear();}rejectPendingAuthRefresh(e){let t=this.pendingAuthRefresh;t&&(clearTimeout(t.timer),this.pendingAuthRefresh=null,this.pendingLeaseRefreshKey=null,t.reject(e));}rejectPendingAcks(e){for(let t of this.pendingAcks.values())clearTimeout(t.timer),t.reject(new Error(e));this.pendingAcks.clear();}unscopedId(e){let t=e.split("::");return t.length===2?t[1]:e}requireRoomConnection(e){let t=e.trim().toUpperCase(),i=this.roomConnections.get(t);if(!i)throw new Error(`Room ${t} is not joined through the coordination gateway.`);return i}async openFriendConnection(e){let t=this.friendConnections.get(e);if(t||(t=new n({...this.options,avenueOverride:{kind:"user",id:e}}),this.friendConnections.set(e,t)),!t.desiredPresence){if(!this.desiredPresence)throw new Error("Local coordination presence must start before friend discovery.");t.desiredPresence={...this.desiredPresence};}return await t.ensureConnected(),t}roomMember(e){return {nodeId:e.nodeId??e.deviceId,userId:e.userId??"",ticket:e.ticket,joinedAt:Number(e.createdAt??e.lastSeenAt??Date.now()),lastSeenAt:Number(e.lastSeenAt??Date.now()),expiresAt:typeof e.expiresAt=="number"?e.expiresAt:void 0}}};var Z=class{constructor(e){this.provider=e;this.cached=null;this.inFlight=null;this.refreshTimer=null;this.refreshRetryUsed=false;this.listeners=new Set;}async get(e=false){if(!this.provider)throw new Error("[OpenRTC] Native coordination requires coordinationGateway.nativeTrustTokenProvider; obtain tokens through a trusted backend without shipping the developer secret.");let t=Date.now();if(!e&&this.cached&&this.cached.expiresAtMs>t+3e4)return this.cached;if(this.inFlight)return this.inFlight;let i=(async()=>{let r=await this.provider(e),o=r?.token?.trim()??"",s=Number(r?.expiresAtMs),a=Date.now();if(!o||!Number.isFinite(s)||s<=a+3e4)throw new Error("[OpenRTC] Native trust token provider returned no usable short-lived token.");let c={token:o,expiresAtMs:s};return this.cached=c,this.refreshRetryUsed=false,this.notify(c),this.scheduleRefresh(c),c})();this.inFlight=i;try{return await i}finally{this.inFlight===i&&(this.inFlight=null);}}invalidate(){this.cached=null,this.clearRefreshTimer(),this.notify(null);}clear(){this.invalidate(),this.listeners.clear();}subscribe(e,t){return this.listeners.add(e),this.cached&&this.cached.expiresAtMs>Date.now()&&(t?.emitCurrent!==false&&e(this.cached),this.scheduleRefresh(this.cached)),()=>{this.listeners.delete(e),this.listeners.size===0&&this.clearRefreshTimer();}}notify(e){for(let t of this.listeners)t(e);}scheduleRefresh(e){if(this.clearRefreshTimer(),this.listeners.size===0)return;let t=Math.max(0,e.expiresAtMs-Date.now()-3e4);this.refreshTimer=setTimeout(()=>{this.refreshTimer=null,this.get(true).catch(()=>{if(this.listeners.size===0||this.refreshRetryUsed){this.invalidate();return}this.refreshRetryUsed=true,this.refreshTimer=setTimeout(()=>{this.refreshTimer=null,this.get(true).catch(()=>this.invalidate());},15e3);});},t);}clearRefreshTimer(){this.refreshTimer&&(clearTimeout(this.refreshTimer),this.refreshTimer=null);}};function ee(n){if(!n)return null;let e=2166136261;for(let t=0;t<n.length;t+=1)e^=n.charCodeAt(t),e=Math.imul(e,16777619);return `fp-${(e>>>0).toString(16).padStart(8,"0")}`}var w=class w{constructor(e){this.deps=e;this.startedAutoConnectKey=null;this.browserAutoConnectUnsubscribe=null;this.desiredPeerRevision=0;this.desiredPeerSignature=null;this.desiredPeerSubmission=null;this.desiredPeerSubmissionQueue=Promise.resolve();this.queuedDesiredPeers=null;this.desiredPeersByDeviceId=new Map;this.wakeSubmission=null;this.presenceState=null;this.presenceStartGeneration=0;this.durablePresenceRetryTimer=null;this.durablePresenceRetryAttempt=0;this.localExcludedPeers=new Set;}stop(){this.stopAutoConnect(),this.stopPresenceLoop();}get autoConnectKey(){return this.startedAutoConnectKey}set autoConnectKey(e){this.startedAutoConnectKey=e;}get presenceLoopState(){return this.presenceState}set presenceLoopState(e){this.presenceState=e;}stopPresence(){this.stopPresenceLoop();}updatePresenceLoopState(e){this.presenceState=e;}startAutoConnect(e,t){if(this.deps.isTicketOnlyMode())return;let i=t.trim()||this.deps.resolveWebLogicalDeviceId(),r=`${e}::${i}`;this.startedAutoConnectKey===r&&this.browserAutoConnectUnsubscribe||(this.stopAutoConnect(),this.startedAutoConnectKey=r,this.browserAutoConnectUnsubscribe=this.deps.getCoordinationSignaling().onDevicesChange(o=>this.submitDesiredPeers(o),this.currentLocalNodeId()??void 0));}wakeRustAutoConnectOwner(){return this.deps.isTicketOnlyMode()||!this.startedAutoConnectKey||this.wakeSubmission?false:(this.wakeSubmission=this.deps.waitForWasmClient(500).then(async e=>{e&&typeof e.wake_browser_auto_connect=="function"&&await e.wake_browser_auto_connect();}).finally(()=>{this.wakeSubmission=null;}),true)}submitDesiredPeers(e){if(!this.startedAutoConnectKey)return;let t=this.normalizeDesiredPeers(e);this.desiredPeersByDeviceId=new Map(t.map(r=>[r.deviceId,r]));let i=JSON.stringify(t);i!==this.desiredPeerSignature&&(this.desiredPeerSignature=i,this.deps.onDesiredPeersChanged?.(),this.queuedDesiredPeers=t,this.flushDesiredPeerSubmission());}async submitDesiredPeerProjection(e,t){if(!Number.isSafeInteger(e)||e<=0)throw new Error("Desired-peer projection revision must be a positive safe integer.");let i=this.startedAutoConnectKey;if(!i)throw new Error("Cannot submit a desired-peer projection before managed auto-connect starts.");let r=this.normalizeDesiredPeers(t),o=JSON.stringify(r),s=o!==this.desiredPeerSignature;this.desiredPeerSignature=o,this.desiredPeersByDeviceId=new Map(r.map(a=>[a.deviceId,a])),this.queuedDesiredPeers=null,this.desiredPeerRevision=Math.max(this.desiredPeerRevision,e),s&&this.deps.onDesiredPeersChanged?.(),await this.enqueueDesiredPeerSubmission(i,e,r);}resolveDesiredPeer(e,t){let i=typeof e=="string"?e.trim():"",r=typeof t=="string"?t.trim():"";if(i){let o=this.desiredPeersByDeviceId.get(i);if(o&&(!r||!o.nodeId||o.nodeId===r))return o}return r?Array.from(this.desiredPeersByDeviceId.values()).find(o=>o.nodeId===r)??null:null}flushDesiredPeerSubmission(){if(this.desiredPeerSubmission||!this.queuedDesiredPeers||!this.startedAutoConnectKey)return;let e=this.startedAutoConnectKey,t=this.queuedDesiredPeers,i=++this.desiredPeerRevision;this.queuedDesiredPeers=null,this.desiredPeerSubmission=this.enqueueDesiredPeerSubmission(e,i,t).catch(()=>{}).finally(()=>{this.desiredPeerSubmission=null,this.flushDesiredPeerSubmission();});}normalizeDesiredPeers(e){return (Array.isArray(e)?e:[]).map(t=>({deviceId:String(t?.deviceId??"").trim(),nodeId:typeof t?.nodeId=="string"&&t.nodeId.trim()||null,ticket:typeof t?.ticket=="string"&&t.ticket.trim()||null,online:t?.online===true,sessionId:typeof t?.sessionId=="string"&&t.sessionId.trim()||null,excludedPeers:Array.isArray(t?.excludedPeers)?[...new Set(t.excludedPeers.map(i=>String(i??"").trim().toLowerCase()).filter(Boolean))].sort():[]})).filter(t=>t.deviceId.length>0).sort((t,i)=>t.deviceId.localeCompare(i.deviceId))}enqueueDesiredPeerSubmission(e,t,i){let r=this.desiredPeerSubmissionQueue.then(async()=>{if(this.startedAutoConnectKey!==e)return;let o=await this.deps.waitForWasmClient();if(this.startedAutoConnectKey===e){if(!o||typeof o.submit_browser_desired_peers!="function"){this.deps.warnMissingWasmOnce("submitBrowserDesiredPeers");return}await Promise.all(i.map(async s=>{if(s.ticket)try{await this.deps.rememberRouteRepairTokenFromTicket(s.ticket);}catch(a){console.warn("[WasmSignaling] failed to retain desired-peer admission token",{deviceId:s.deviceId,nodeId:s.nodeId,error:a});}})),await o.submit_browser_desired_peers(t,JSON.stringify(i));}});return this.desiredPeerSubmissionQueue=r.catch(o=>{console.warn("[WasmSignaling] failed to submit browser desired peers to Rust",{revision:t,error:o});}),r}async setAutoConnectExcluded(e,t){let i=await this.deps.waitForWasmClient();i&&typeof i.set_auto_connect_excluded=="function"&&await i.set_auto_connect_excluded(e,t),await this.recordAutoConnectExcludedForPresence(e,t);}async recordAutoConnectExcludedForPresence(e,t){let i=e.trim().toLowerCase();if(!i)return;t?this.localExcludedPeers.add(i):this.localExcludedPeers.delete(i);let r=this.deps.resolveWebLogicalDeviceId();r&&await this.deps.updateExcludedPeers(r,this.currentExcludedPeersSnapshot());}startPresenceLoop(e,t,i,r,o){if(this.deps.isTicketOnlyMode())return;this.stopPresenceLoop();let s=++this.presenceStartGeneration;this.presenceState={userId:e,localNodeId:t,ticket:r,metadata:o,deviceName:i};let a=this.deps.resolveWebLogicalDeviceId();(async()=>{let d=await this.deps.withWebPresenceMetadata(o,a);if(!(s===this.presenceStartGeneration&&this.presenceState!==null))return;let m=false,h=null,y=(v,D)=>{this.scheduleDurableRosterRetry(a,s,w.PRESENCE_LEASE_MS,v,D);};h=setTimeout(()=>{m||y("initial coordination presence write timed out");},w.INITIAL_PRESENCE_WRITE_TIMEOUT_MS),this.deps.updatePresence(t,r,true,w.PRESENCE_LEASE_MS,d,i).then(()=>{m=true,h&&(clearTimeout(h),h=null),this.clearDurablePresenceRetryTimer(),this.durablePresenceRetryAttempt=0;}).catch(v=>{h&&(clearTimeout(h),h=null),y("initial coordination presence write failed",v);});})();}clearDurablePresenceRetryTimer(){this.durablePresenceRetryTimer&&(clearTimeout(this.durablePresenceRetryTimer),this.durablePresenceRetryTimer=null);}scheduleDurableRosterRetry(e,t,i,r,o){if(t!==this.presenceStartGeneration||this.presenceState===null||this.durablePresenceRetryTimer||this.isPermanentProviderError(o))return;let s=this.durablePresenceRetryAttempt+1;if(s>w.PRESENCE_RETRY_LIMIT){console.warn(`[WasmBridge] ${r}; durable roster retry circuit opened after ${w.PRESENCE_RETRY_LIMIT} attempts`,o);return}this.durablePresenceRetryAttempt=s;let a=Math.min(w.PRESENCE_RETRY_MIN_DELAY_MS*2**Math.min(8,s-1),w.PRESENCE_RETRY_MAX_DELAY_MS),c=(s*17%21-10)/100,d=Math.max(w.PRESENCE_RETRY_MIN_DELAY_MS,Math.trunc(a+a*c));console.warn(`[WasmBridge] ${r}; retrying coordination presence in ${d}ms`,o),this.durablePresenceRetryTimer=setTimeout(()=>{this.durablePresenceRetryTimer=null,!(t!==this.presenceStartGeneration||this.presenceState===null)&&(async()=>{if(this.presenceState===null)return;let l=await this.deps.withWebPresenceMetadata(this.presenceState.metadata,e);t!==this.presenceStartGeneration||this.presenceState===null||await this.deps.updatePresence(this.presenceState.localNodeId,this.presenceState.ticket,true,i,l,this.presenceState.deviceName);})().then(()=>{this.durablePresenceRetryAttempt=0,this.clearDurablePresenceRetryTimer();}).catch(l=>{this.scheduleDurableRosterRetry(e,t,i,"durable roster registration retry failed",l);});},d);}isPermanentProviderError(e){let i=(e&&typeof e=="object"&&"code"in e?String(e.code??""):"").toLowerCase().replace(/^functions\//,"");return ["auth/invalid-user-token","auth/user-token-expired","auth/user-disabled","permission-denied","unauthenticated","invalid-argument","failed-precondition"].some(r=>i===r||i.endsWith(`/${r}`))}stopAutoConnect(){this.browserAutoConnectUnsubscribe?.(),this.browserAutoConnectUnsubscribe=null,this.startedAutoConnectKey=null,this.desiredPeerSignature=null,this.queuedDesiredPeers=null,this.desiredPeersByDeviceId.clear(),this.wakeSubmission=null;}currentExcludedPeersSnapshot(){return Array.from(this.localExcludedPeers).sort()}currentLocalNodeId(){let e=this.presenceState?.localNodeId;return typeof e=="string"&&e.trim()||null}stopPresenceLoop(){this.presenceStartGeneration+=1,this.clearDurablePresenceRetryTimer(),this.durablePresenceRetryAttempt=0,this.presenceState=null;}};w.INITIAL_PRESENCE_WRITE_TIMEOUT_MS=5e3,w.PRESENCE_RETRY_MIN_DELAY_MS=2e3,w.PRESENCE_RETRY_MAX_DELAY_MS=6e4,w.PRESENCE_RETRY_LIMIT=8,w.PRESENCE_LEASE_MS=15*6e4;var te=w;var pt="[OpenRTC][teardown-trace]";function ht(){try{let n=globalThis;if(n.OPENRTC_TEARDOWN_TRACE===!0||n.localStorage?.getItem("OPENRTC_TEARDOWN_TRACE")==="1")return !0}catch{}return false}function De(n,e={}){console.info(pt,{kind:n,ts:new Date().toISOString(),...e}),ht()&&console.info("[OpenRTC][teardown-trace:stack]",{kind:n,stack:new Error(`teardown: ${n}`).stack});}var ie="trustedDevice",ft="plutonium:e2ee:identity:v1",mt="plutonium:e2ee:identity:session:v1",gt="openrtc-trust",W="identity",Ne="transport-trust:v1",yt=1,I=null,G=null;function P(n){let e=atob(n),t=new Uint8Array(e.length);for(let i=0;i<e.length;i+=1)t[i]=e.charCodeAt(i);return t}function H(n){let e="";for(let t=0;t<n.length;t+=1)e+=String.fromCharCode(n[t]);return btoa(e)}async function oe(n){let e=await crypto.subtle.digest("SHA-256",n),t=new Uint8Array(e);return Array.from(t).map(i=>i.toString(16).padStart(2,"0")).join("")}function vt(){return typeof sessionStorage>"u"?null:sessionStorage}function wt(){if(!(typeof localStorage>"u"))try{localStorage.removeItem(ft);}catch{}}var ne=null;async function Oe(){return ne||(ne=(async()=>{let n=globalThis.crypto?.subtle;if(!n||typeof n.generateKey!="function")return false;try{let e=await n.generateKey({name:"Ed25519"},!1,["sign","verify"]);return !!(e&&e.privateKey&&e.publicKey)}catch{return false}})(),ne)}async function St(n){let e=await crypto.subtle.exportKey("raw",n);return new Uint8Array(e)}function bt(){try{return typeof indexedDB<"u"?indexedDB:null}catch{return null}}function xe(){let n=bt();return n?new Promise(e=>{let t;try{t=n.open(gt,1);}catch{e(null);return}t.onupgradeneeded=()=>{let i=t.result;i.objectStoreNames.contains(W)||i.createObjectStore(W);},t.onsuccess=()=>e(t.result),t.onerror=()=>e(null),t.onblocked=()=>e(null);}):Promise.resolve(null)}async function It(){let n=await xe();if(!n)return null;try{return await new Promise(e=>{let r=n.transaction(W,"readonly").objectStore(W).get(Ne);r.onsuccess=()=>{let o=r.result;e(o&&o.privateKey&&o.publicKey?o:null);},r.onerror=()=>e(null);})}catch{return null}finally{n.close();}}async function Rt(n){let e=await xe();if(!e)return false;try{return await new Promise(t=>{let i=e.transaction(W,"readwrite");i.objectStore(W).put(n,Ne),i.oncomplete=()=>t(!0),i.onerror=()=>t(!1),i.onabort=()=>t(!1);})}catch{return false}finally{e.close();}}async function Le(n,e){let t=await St(n.publicKey),i=await oe(t),r=n.privateKey;return {publicKey:t,fingerprint:i,backend:"webcrypto-nonextractable",durable:e,privateKey:r,async signChallenge(o){let s=await crypto.subtle.sign({name:"Ed25519"},r,P(o));return H(new Uint8Array(s))}}}function Tt(n,e,t){let i=n.secretKey;return {publicKey:n.publicKey,secretKey:i,fingerprint:e,backend:"tweetnacl",durable:t,async signChallenge(r){return Ct(r,i)}}}function Zt(n=32){let e=crypto.getRandomValues(new Uint8Array(n));return H(e)}function Ct(n,e){let t=U.sign.detached(P(n),e);return H(t)}function Pt(n,e,t){try{return U.sign.detached.verify(P(n),P(e),P(t))}catch{return false}}async function en(n,e,t){let i=globalThis.crypto?.subtle;if(i&&typeof i.importKey=="function"&&typeof i.verify=="function")try{let r=await i.importKey("raw",P(t),{name:"Ed25519"},!1,["verify"]);return await i.verify({name:"Ed25519"},r,P(e),P(n))}catch{}return Pt(n,e,t)}function tn(n){return H(n)}function nn(n){if(!n||!n.trim())return null;try{let e=JSON.parse(n),t=e&&typeof e=="object"&&!Array.isArray(e)?e[ie]:null;if(!t||typeof t!="object"||Array.isArray(t))return null;let i=t,r=typeof i.version=="number"?i.version:null,o=typeof i.identityPublicKey=="string"?i.identityPublicKey:null,s=typeof i.identityFingerprint=="string"?i.identityFingerprint:null;return !r||!o||!s?null:{version:r,identityPublicKey:o,identityFingerprint:s}}catch{return null}}async function At(){let n=await Dt().catch(()=>null);return n?{version:yt,identityPublicKey:H(n.publicKey),identityFingerprint:n.fingerprint}:null}async function se(n){let e=await At();if(!e)return n??void 0;let t=typeof n=="string"?n.trim():"";if(!t)return JSON.stringify({[ie]:e});try{let i=JSON.parse(t);if(i&&typeof i=="object"&&!Array.isArray(i))return JSON.stringify({...i,[ie]:e})}catch{}return JSON.stringify({metadata:n,[ie]:e})}function Et(){if(typeof window>"u")return null;let n=window.__TAURI_INTERNALS__;return !n||typeof n.invoke!="function"?null:n.invoke.bind(n)}async function _t(){if(typeof window>"u")return null;let n=Et();if(!c()&&!n)return null;if(!n)throw new Error("[OpenRTC] Tauri transport trust requires the native signing provider, but Tauri invoke is unavailable.");try{let e=await n("openrtc_get_transport_trust_identity"),t=P(e.publicKeyBase64);if(t.byteLength!==U.sign.publicKeyLength)throw new Error("native transport trust public key has an invalid length");let i=await oe(t);if(e.fingerprint!==i)throw new Error("native transport trust fingerprint does not match its public key");return {publicKey:t,fingerprint:i,backend:"native-provider",durable:!0,async signChallenge(r){return n("openrtc_sign_transport_trust_challenge",{challenge:r})}}}catch(e){let t=new Error("[OpenRTC] native transport trust provider failed; refusing WebCrypto fallback in Tauri.");throw t.cause=e,t}}function kt(){let n=vt();n&&n.removeItem(mt);}async function Mt(){if(wt(),kt(),I)return I;let n=await _t();if(n)return I=n,I;if(await Oe()){let e=await It();if(e)return I=await Le(e,true),I}return null}async function Dt(n={}){let e=await Mt();if(e)return e;if(G)return G;let t=Nt(n);G=t;try{return await t}finally{G===t&&(G=null);}}async function Nt(n){if(I)return I;let e=n.ephemeral===true;if(await Oe())try{let t=await crypto.subtle.generateKey({name:"Ed25519"},!1,["sign","verify"]),i=!1;return e||(i=await Rt(t)),I=await Le(t,i),I}catch{}if(!e)return console.warn("[OpenRTC][TRUST] Managed transport trust requires WebCrypto Ed25519 or native keychain; refusing extractable fallback storage"),null;try{let t=U.sign.keyPair(),i=await oe(b(t.publicKey));return I=Tt(t,i,!1),I}catch{return null}}var ae={managedSession:{nativeStartRetryWindowMs:12e4,nativeStartRetryMinDelayMs:400,nativeStartRetryMaxDelayMs:5e3,reconciliationIntervalMs:5e3,deviceStatusRefreshDebounceMs:50},browserAutoConnect:{scanDebounceMs:150,retryCooldownMs:2e3,settleGuardMs:1e4,retryMaxMs:8e3,nonInitiatorBaseGraceMs:2e3,nonInitiatorMaxGraceMs:16e3},nativeIpc:{authRequiredWaitMs:15e3,defaultBoundedCommandTimeoutMs:15e3,connectionEventSubscribeWindowMs:15e3,connectionEventRetryMinDelayMs:250,connectionEventRetryMaxDelayMs:1e3,tauriIpcNegativeCacheMs:2e3},browserIdentity:{ephemeralDeviceIdTtlMs:6e4}};function on(){return ae}var Ot={adapter:"browser-wasm",signaling:{coordinationGateway:true,nativeIpc:false,managedPresence:true},transport:{irohQuic:true,irohLan:false,webRtcUpgrade:true,webRtcLan:true,nativeWebRtc:false,moq:true,ble:false,wasm:true},nativeProtocols:{productAlpn:false,irohDocs:false,irohBlobs:false,irohGossip:false},lifecycle:{managedSession:true,autoConnect:true,manualDisconnect:true,connectionStateEvents:true,peerSessions:true},transfers:{explicitFilePath:false,explicitFileData:true,history:false},fallback:{wasm:false}},xt={adapter:"native-ipc",signaling:{coordinationGateway:true,nativeIpc:true,managedPresence:true},transport:{irohQuic:true,irohLan:false,webRtcUpgrade:false,webRtcLan:false,nativeWebRtc:false,moq:false,ble:false,wasm:false},nativeProtocols:{productAlpn:true,irohDocs:true,irohBlobs:true,irohGossip:true},lifecycle:{managedSession:true,autoConnect:true,manualDisconnect:true,connectionStateEvents:true,peerSessions:true},transfers:{explicitFilePath:true,explicitFileData:true,history:true},fallback:{wasm:false}};function We(n){return {adapter:n.adapter,signaling:{...n.signaling},transport:{...n.transport},nativeProtocols:{...n.nativeProtocols},lifecycle:{...n.lifecycle},transfers:{...n.transfers},fallback:{...n.fallback}}}function Fe(n=globalThis){let e=We(Ot),t=typeof n?.RTCPeerConnection=="function";return e.transport.webRtcUpgrade=t,e.transport.webRtcLan=t,e}function L(n){return n?.compiled===true&&n.enabled===true}function an(n,e=false){let t=We(xt),i=n?.transport;return i&&(t.transport.irohQuic=L(i.irohQuic),t.transport.irohLan=L(i.irohLan),t.transport.webRtcUpgrade=L(i.webRtc),t.transport.nativeWebRtc=L(i.webRtc),t.transport.webRtcLan=L(i.webRtcLan),t.transport.moq=L(i.moq),t.transport.ble=L(i.ble)),t.transport.wasm=false,t.fallback.wasm=e,t}function cn(n){return {environment:n.adapter==="native-ipc"||n.adapter==="tauri-ipc"?"native":n.adapter==="browser-wasm"?"web":"unknown",transports:{quic:n.transport.irohQuic,irohRelay:n.transport.irohQuic,irohLan:n.transport.irohLan,webRtc:n.transport.webRtcUpgrade||n.transport.nativeWebRtc,webRtcLan:n.transport.webRtcLan,moq:n.transport.moq,ble:n.transport.ble},lifecycle:{...n.lifecycle},storage:{localFileSystem:n.transfers.explicitFilePath,transferHistory:n.transfers.history},nativeProtocols:{...n.nativeProtocols}}}function Be(n){if(n.errorCode)return n;let e=n.error||n.readinessReason;if(!e)return n;let t=c$2(e);return {...n,errorCode:t.errorCode,retryable:t.retryable,errorPlane:t.errorPlane}}function F(n){return !n||typeof n!="object"?{}:n instanceof Map?Object.fromEntries(n):n}function ce(n){let e=F(n),t=F(e.device);if(!Object.keys(t).length)return e;let i={...t,...e};return delete i.device,i}function u(n,...e){for(let t of e){let i=n[t];if(typeof i=="string"&&i.trim().length>0)return i}}function k(n,...e){for(let t of e){let i=n[t];if(typeof i=="boolean")return i}}function p(n,...e){for(let t of e){let i=n[t];if(typeof i=="number"&&Number.isFinite(i))return i}}function M(n){if(typeof n=="number"&&Number.isFinite(n))return n;if(n instanceof Date){let e=n.getTime();return Number.isFinite(e)?e:void 0}if(typeof n=="string"){let e=Date.parse(n);return Number.isFinite(e)?e:void 0}if(n&&typeof n=="object"){let e=n;if(typeof e.toMillis=="function"){let i=e.toMillis();return Number.isFinite(i)?i:void 0}let t=typeof e.seconds=="number"?e.seconds:typeof e._seconds=="number"?e._seconds:void 0;if(t!==void 0&&Number.isFinite(t)){let i=typeof e.nanoseconds=="number"?e.nanoseconds:typeof e._nanoseconds=="number"?e._nanoseconds:0;return t*1e3+Math.floor((Number.isFinite(i)?i:0)/1e6)}}}function de(...n){let e=n.map(M).filter(t=>typeof t=="number"&&Number.isFinite(t));return e.length?Math.max(...e):void 0}function le(n){if(typeof n!="string")return;let e=n.trim().toLowerCase();return e==="online"||e==="idle"||e==="offline"?e:void 0}function Ge(n){let e=le("presenceStatus"in n?n.presenceStatus:void 0),t="presenceUpdatedAt"in n?M(n.presenceUpdatedAt):void 0,i="presenceExpiresAt"in n?M(n.presenceExpiresAt):void 0,r=t??de(n.lastSeenAt,n.updatedAt,n.createdAt),o=i??M(n.expiresAt),s=e;s||(n.online?r!==void 0&&r+3e5<=Date.now()?s="idle":s="online":s="offline");let a=typeof n.ticket=="string"?n.ticket.trim():"",c="connectable"in n&&typeof n.connectable=="boolean"?n.connectable:s==="online"&&a.length>0;return {presenceStatus:s,presenceUpdatedAt:r,presenceExpiresAt:o,connectable:c}}function Ue(n){return f$2(n)}function B(n,...e){return Ue(u(n,...e))}function z(n){if(!Array.isArray(n))return;let e=Array.from(new Set(n.map(Ue).filter(t=>!!t)));return e.length?e:void 0}function He(n){let e=F(n),t={webrtc:p(e,"webrtc"),webrtcLan:p(e,"webrtcLan","webrtc_lan"),webrtcTurn:p(e,"webrtcTurn","webrtc_turn"),iroh:p(e,"iroh"),irohLan:p(e,"irohLan","iroh_lan"),irohRelay:p(e,"irohRelay","iroh_relay"),ble:p(e,"ble"),moq:p(e,"moq")};return Object.values(t).some(i=>i!==void 0)?t:void 0}function Ke(n){return (n.discoveryMode??"space")==="space"&&typeof n.apiKey=="string"&&n.apiKey.trim().length>0&&typeof n.spaceKey=="string"&&n.spaceKey.trim().length>0}function ze(n,e,t){return t?true:(typeof n.appTag=="string"?n.appTag:typeof n.tag=="string"?n.tag:void 0)===e}function ue(n,e){let t=ce(n),i=u(t,"deviceId","device_id")||e||"",r=u(t,"nodeId","node_id")||"",o=u(t,"ticket")||"";return {deviceId:i,deviceName:u(t,"deviceName","device_name")||"Unknown Device",online:!!t.online,ticket:o,friendTicket:u(t,"friendTicket","friend_ticket"),presenceStatus:le(u(t,"presenceStatus","presence_status","livenessStatus","liveness_status")),presenceUpdatedAt:p(t,"presenceUpdatedAt","presence_updated_at")??de(t.presenceUpdatedAt,t.presence_updated_at,t.lastSeenAt,t.last_seen_at,t.updatedAt,t.updated_at,t.createdAt,t.created_at),presenceExpiresAt:p(t,"presenceExpiresAt","presence_expires_at")??M(t.presenceExpiresAt??t.presence_expires_at)??M(t.expiresAt??t.expires_at),connectable:k(t,"connectable"),kind:u(t,"kind"),nodeId:r||void 0,platformType:u(t,"platformType","platform_type"),capabilities:t.capabilities||void 0,sessionId:u(t,"sessionId","session_id"),userId:u(t,"userId","user_id"),lastSeenAt:t.lastSeenAt??t.last_seen_at,expiresAt:t.expiresAt??t.expires_at,createdAt:t.createdAt??t.created_at,updatedAt:t.updatedAt??t.updated_at,metadata:u(t,"metadata"),excludedPeers:pe(t.excludedPeers??t.excluded_peers),availableTransports:z(t.availableTransports??t.available_transports),transports:z(t.transports)}}function pe(n){return Array.isArray(n)?n.filter(e=>typeof e=="string"):[]}function Lt(n){let e=Ge(n);return {...n,...e,connectionStatus:"connectionStatus"in n&&typeof n.connectionStatus=="string"?n.connectionStatus:n.online?"online":"disconnected",settledReady:"settledReady"in n&&typeof n.settledReady=="boolean"?n.settledReady:false,readinessState:"readinessState"in n&&typeof n.readinessState=="string"?n.readinessState:void 0,readinessReason:"readinessReason"in n&&typeof n.readinessReason=="string"?n.readinessReason:void 0,peerHealth:"peerHealth"in n&&typeof n.peerHealth=="string"?n.peerHealth:"unknown",peerId:"peerId"in n&&typeof n.peerId=="string"?n.peerId:void 0,promotionEligible:"promotionEligible"in n&&typeof n.promotionEligible=="boolean"?n.promotionEligible:true,scopes:"scopes"in n?pe(n.scopes):[],connectionId:"connectionId"in n&&typeof n.connectionId=="string"?n.connectionId:void 0,deviceIdHint:"deviceIdHint"in n&&typeof n.deviceIdHint=="string"?n.deviceIdHint:void 0,activeTransportStableId:"activeTransportStableId"in n&&typeof n.activeTransportStableId=="number"?n.activeTransportStableId:"activeTransportStableId"in n?n.activeTransportStableId??null:void 0,transportGeneration:"transportGeneration"in n&&typeof n.transportGeneration=="number"?n.transportGeneration:void 0,routeGeneration:"routeGeneration"in n&&typeof n.routeGeneration=="number"?n.routeGeneration:void 0,activeTransport:"activeTransport"in n?n.activeTransport:void 0,parallelTransport:"parallelTransport"in n?n.parallelTransport:void 0,availableTransports:"availableTransports"in n?z(n.availableTransports):"transports"in n?z(n.transports):void 0,latencyMs:"latencyMs"in n&&typeof n.latencyMs=="number"?n.latencyMs:void 0,latencyByTransport:"latencyByTransport"in n?He(n.latencyByTransport):void 0}}function K(n,e){return e===void 0?true:e===null?n==null:n==null||n===e}function je(n,e){let t=K(n.connectionId,e.connectionId)&&K(n.nodeId,e.nodeId)&&K(n.activeTransportStableId,e.activeTransportStableId)&&K(n.transportGeneration,e.transportGeneration)&&K(n.routeGeneration,e.routeGeneration),i=(r,o)=>r!==void 0?r:t?o:void 0;return {inheritsSnapshot:t,fields:{connectionId:i(e.connectionId??void 0,n.connectionId),activeTransportStableId:i(e.activeTransportStableId,n.activeTransportStableId),transportGeneration:i(e.transportGeneration,n.transportGeneration),routeGeneration:i(e.routeGeneration,n.routeGeneration),activeTransport:i(e.activeTransport,n.activeTransport),parallelTransport:i(e.parallelTransport,n.parallelTransport),latencyMs:t?n.latencyMs:void 0,latencyByTransport:t?n.latencyByTransport:void 0}}}var Wt={connectionId:void 0,activeTransportStableId:null,transportGeneration:void 0,routeGeneration:void 0,activeTransport:void 0,parallelTransport:void 0,latencyMs:void 0,latencyByTransport:void 0};function Ft(n,e,t){let i=je(n,{connectionId:e.activeConnectionId,nodeId:e.nodeId,activeTransportStableId:e.activeTransportStableId,transportGeneration:e.transportGeneration,routeGeneration:e.routeGeneration,activeTransport:e.activeTransport,parallelTransport:e.parallelTransport}),r=t?t({connectionId:e.activeConnectionId??void 0,deviceId:e.deviceId??void 0,deviceIdHint:e.deviceIdHint??void 0,nodeId:e.nodeId??void 0}):n.promotionEligible??true;if(!r)return {...n,peerHealth:e.health??n.peerHealth,peerId:e.peerId??n.peerId,promotionEligible:r,scopes:e.scopes?.length?[...e.scopes]:n.scopes,nodeId:e.nodeId===void 0?n.nodeId:e.nodeId??void 0,deviceIdHint:e.deviceIdHint??n.deviceIdHint,...i.fields,readinessReason:e.readinessReason??n.readinessReason};let o=e.status??n.connectionStatus,s=typeof o=="string"?o.trim().toLowerCase():"",a=s==="failed"||s==="closed"||s==="disconnected",d=typeof e.readinessState=="string"&&e.readinessState.trim().length>0?e.readinessState==="routable":e.settledReady===true,l=n.settledReady===true||n.readinessState==="routable";if(i.inheritsSnapshot&&l&&!a&&!d)return {...n,peerHealth:e.health??n.peerHealth,peerId:e.peerId??n.peerId,promotionEligible:r,scopes:e.scopes?.length?[...e.scopes]:n.scopes,nodeId:e.nodeId===void 0?n.nodeId:e.nodeId??void 0,deviceIdHint:e.deviceIdHint??n.deviceIdHint,...i.fields,readinessReason:e.readinessReason??n.readinessReason};let m=a?false:d,h=d&&!a&&(s==="connecting"||s==="connected")?"connected":o,y=d?"routable":e.readinessState??(i.inheritsSnapshot?n.readinessState:void 0),v=m?e.readinessReason??"peer-session-settled":e.readinessReason??(i.inheritsSnapshot?n.readinessReason:void 0);return {...n,connectionStatus:h,settledReady:m,readinessState:y,readinessReason:v,peerHealth:e.health??n.peerHealth,peerId:e.peerId??n.peerId,promotionEligible:r,scopes:e.scopes?.length?[...e.scopes]:n.scopes,nodeId:e.nodeId===void 0?n.nodeId:e.nodeId??void 0,deviceIdHint:e.deviceIdHint??n.deviceIdHint,...i.fields}}function Bt(n,e){let t=je(n,{connectionId:e.connectionId,nodeId:e.nodeId,activeTransportStableId:e.activeTransportStableId,transportGeneration:e.transportGeneration,routeGeneration:e.routeGeneration,activeTransport:e.activeTransport,parallelTransport:e.parallelTransport});if(e.promotionEligible===false)return {...n,peerHealth:e.health??n.peerHealth,peerId:e.peerId??n.peerId,promotionEligible:false,nodeId:e.nodeId??n.nodeId,deviceIdHint:e.deviceIdHint??n.deviceIdHint,...t.fields,scopes:e.scopes?.length?[...e.scopes]:n.scopes};let i=e.status??n.connectionStatus,r=typeof i=="string"?i.trim().toLowerCase():"",o=r==="failed"||r==="closed"||r==="disconnected",s=n.settledReady===true||n.readinessState==="routable",a=e.routable===false;if(t.inheritsSnapshot&&s&&o&&!a)return {...n,peerHealth:n.peerHealth??e.health,peerId:n.peerId??e.peerId,promotionEligible:e.promotionEligible??n.promotionEligible??true,connectionId:n.connectionId??e.connectionId,deviceIdHint:n.deviceIdHint??e.deviceIdHint,scopes:n.scopes?.length?n.scopes:e.scopes??n.scopes};if(s&&o)return {...n,connectionStatus:i,settledReady:false,readinessState:void 0,readinessReason:e.error??n.readinessReason,peerHealth:e.health??n.peerHealth,peerId:e.peerId??n.peerId,promotionEligible:e.promotionEligible??n.promotionEligible??true,deviceIdHint:e.deviceIdHint??n.deviceIdHint,...Wt,scopes:e.scopes?.length?[...e.scopes]:n.scopes};let c=e.routable===true||e.protocolState==="routable";if(t.inheritsSnapshot&&s&&!o&&!c)return {...n,peerHealth:n.peerHealth??e.health,peerId:n.peerId??e.peerId,promotionEligible:e.promotionEligible??n.promotionEligible??true,connectionId:n.connectionId??e.connectionId,deviceIdHint:n.deviceIdHint??e.deviceIdHint,activeTransportStableId:n.activeTransportStableId??e.activeTransportStableId,transportGeneration:n.transportGeneration??e.transportGeneration,routeGeneration:n.routeGeneration??e.routeGeneration,activeTransport:n.activeTransport??e.activeTransport,parallelTransport:n.parallelTransport===void 0?e.parallelTransport:n.parallelTransport,scopes:n.scopes?.length?n.scopes:e.scopes??n.scopes};let d=e.transportState==="connected"&&e.health==="healthy",l=o?false:c,m=!o&&(c||d)&&(r==="connecting"||r==="connected"||e.transportState==="connected")?"connected":i,h=l?"routable":(e.routable===false&&e.protocolState?e.protocolState:void 0)??(t.inheritsSnapshot?n.readinessState:void 0)??(e.status==="connecting"?e.transportState==="connected"?"transport-only":"connecting":void 0),y=l?(t.inheritsSnapshot?n.readinessReason:void 0)??(e.routable===true?"peer-projection-routable":void 0):(e.routable===false&&e.error?e.error:void 0)??(t.inheritsSnapshot?n.readinessReason:void 0)??(e.status==="connecting"?e.transportState==="connected"?"peer-projection-transport-ready":"peer-projection-connecting":void 0);return {...n,connectionStatus:m,settledReady:l,readinessState:h,readinessReason:y,peerHealth:e.health??n.peerHealth,peerId:e.peerId??n.peerId,promotionEligible:e.promotionEligible??n.promotionEligible??true,nodeId:e.nodeId??n.nodeId,deviceIdHint:e.deviceIdHint??n.deviceIdHint,...t.fields,scopes:e.scopes?.length?[...e.scopes]:n.scopes}}function Gt(n){let{device:e,session:t=null,peer:i=null,isPromotionEligible:r}=n,o=Lt(e);return t&&(o=Ft(o,t,r)),i&&(o=Bt(o,i)),Be(o)}function qe(n){let e=ce(n),t=ue(e),i=le(u(e,"presenceStatus","presence_status","livenessStatus","liveness_status")),r=Ge({...t,...i?{presenceStatus:i}:{},presenceUpdatedAt:p(e,"presenceUpdatedAt","presence_updated_at")??de(e.presenceUpdatedAt,e.presence_updated_at,e.lastSeenAt,e.last_seen_at,e.updatedAt,e.updated_at,e.createdAt,e.created_at),presenceExpiresAt:p(e,"presenceExpiresAt","presence_expires_at")??M(e.presenceExpiresAt??e.presence_expires_at)??M(e.expiresAt??e.expires_at),connectable:k(e,"connectable")}),o={...t,...r,connectionStatus:u(e,"connectionStatus","connection_status")||"disconnected",settledReady:k(e,"settledReady","settled_ready")??false,readinessState:u(e,"readinessState","readiness_state")??void 0,readinessReason:u(e,"readinessReason","readiness_reason")??void 0,peerHealth:u(e,"peerHealth","peer_health")||"unknown",peerId:u(e,"peerId","peer_id"),scopes:pe(e.scopes),connectionId:u(e,"connectionId","connection_id"),deviceIdHint:u(e,"deviceIdHint","device_id_hint"),activeTransportStableId:p(e,"activeTransportStableId","active_transport_stable_id")??void 0,transportGeneration:p(e,"transportGeneration","transport_generation")??void 0,routeGeneration:p(e,"routeGeneration","route_generation")??void 0,activeTransport:B(e,"activeTransport","active_transport"),parallelTransport:B(e,"parallelTransport","parallel_transport")??null,availableTransports:z(e.availableTransports??e.available_transports),latencyMs:p(e,"latencyMs","latency_ms"),latencyByTransport:He(e.latencyByTransport??e.latency_by_transport)};return Gt({device:o})}function $e(n){let e=ce(n);return Be({peerId:u(e,"peerId","peer_id")||"",deviceId:u(e,"deviceId","device_id"),deviceIdHint:u(e,"deviceIdHint","device_id_hint"),nodeId:u(e,"nodeId","node_id"),activeConnectionId:u(e,"activeConnectionId","active_connection_id"),candidateConnectionIds:Array.isArray(e.candidateConnectionIds)?e.candidateConnectionIds.filter(t=>typeof t=="string"):Array.isArray(e.candidate_connection_ids)?e.candidate_connection_ids.filter(t=>typeof t=="string"):[],status:u(e,"status")||"disconnected",health:u(e,"health")||"unknown",settledReady:k(e,"settledReady","settled_ready")??false,readinessState:u(e,"readinessState","readiness_state")??void 0,activeTransportStableId:p(e,"activeTransportStableId","active_transport_stable_id")??void 0,transportGeneration:p(e,"transportGeneration","transport_generation")??void 0,routeGeneration:p(e,"routeGeneration","route_generation")??void 0,activeTransport:B(e,"activeTransport","active_transport"),parallelTransport:B(e,"parallelTransport","parallel_transport")??null,replacementPending:k(e,"replacementPending","replacement_pending")??void 0,lastLifecycleTransitionAtMs:p(e,"lastLifecycleTransitionAtMs","last_lifecycle_transition_at_ms")??void 0,readinessReason:u(e,"readinessReason","readiness_reason")??void 0,transitionCount:p(e,"transitionCount","transition_count")??void 0,connectingTransitionCount:p(e,"connectingTransitionCount","connecting_transition_count")??void 0,replacementCount:p(e,"replacementCount","replacement_count")??void 0,retireCount:p(e,"retireCount","retire_count")??void 0,lastDisconnectReason:u(e,"lastDisconnectReason","last_disconnect_reason")??void 0,lastReconnectReason:u(e,"lastReconnectReason","last_reconnect_reason")??void 0,scopes:Array.isArray(e.scopes)?e.scopes.filter(t=>typeof t=="string"):[],lastSeenAtMs:typeof e.lastSeenAtMs=="number"?e.lastSeenAtMs:typeof e.last_seen_at_ms=="number"?e.last_seen_at_ms:0,error:u(e,"error"),errorCode:u(e,"errorCode","error_code")??void 0,retryable:k(e,"retryable")??void 0,errorPlane:u(e,"errorPlane","error_plane")??void 0})}function hn(n){let e=F(n);return {connectionId:typeof e.connectionId=="string"?e.connectionId:"",nodeId:typeof e.nodeId=="string"?e.nodeId:null,deviceId:typeof e.deviceId=="string"?e.deviceId:null,deviceIdHint:typeof e.deviceIdHint=="string"?e.deviceIdHint:null,endpointId:typeof e.endpointId=="string"?e.endpointId:null,transportGeneration:typeof e.transportGeneration=="number"?e.transportGeneration:0,routeGeneration:typeof e.routeGeneration=="number"?e.routeGeneration:void 0,transportStableId:typeof e.transportStableId=="number"?e.transportStableId:null,transportSource:typeof e.transportSource=="string"?e.transportSource:null,lastTransportChangeAtMs:typeof e.lastTransportChangeAtMs=="number"?e.lastTransportChangeAtMs:0,lastRouteChangeAtMs:typeof e.lastRouteChangeAtMs=="number"?e.lastRouteChangeAtMs:void 0,state:typeof e.state=="string"?e.state:"pending",statusReason:typeof e.statusReason=="string"?e.statusReason:null,transitionCount:typeof e.transitionCount=="number"?e.transitionCount:void 0,connectingTransitionCount:typeof e.connectingTransitionCount=="number"?e.connectingTransitionCount:void 0,replacementCount:typeof e.replacementCount=="number"?e.replacementCount:void 0,retireCount:typeof e.retireCount=="number"?e.retireCount:void 0,lastDisconnectReason:typeof e.lastDisconnectReason=="string"?e.lastDisconnectReason:void 0,lastReconnectReason:typeof e.lastReconnectReason=="string"?e.lastReconnectReason:void 0,createdAtMs:typeof e.createdAtMs=="number"?e.createdAtMs:0,updatedAtMs:typeof e.updatedAtMs=="number"?e.updatedAtMs:0}}function fn(n){let e=F(n);return {peerId:typeof e.peerId=="string"?e.peerId:null,deviceId:typeof e.deviceId=="string"?e.deviceId:null,deviceIdHint:typeof e.deviceIdHint=="string"?e.deviceIdHint:null,nodeId:typeof e.nodeId=="string"?e.nodeId:null}}function Ut(n){switch(n){case "connected":return "connected";case "connecting":return "connecting";case "failed":return "failed";default:return "closed"}}function Ye(n){let e=n.activeConnectionId||n.candidateConnectionIds[0]||null;if(!e)return null;let t=Ut(n.status),i=t==="connected"?"connected":t==="connecting"?"connecting":"closed",r=t==="connected"?n.settledReady?"routable":"transport-only":t==="connecting"?"connecting":"closed";return {connectionId:e,deviceId:n.deviceId??null,deviceIdHint:n.deviceIdHint??null,remoteNodeId:n.nodeId??null,state:t,transportState:i,protocolState:r,routable:!!n.settledReady,readinessState:n.readinessState,readinessReason:n.readinessReason,transportGeneration:n.transportGeneration,routeGeneration:n.routeGeneration,activeTransportStableId:n.activeTransportStableId,activeTransport:n.activeTransport,parallelTransport:n.parallelTransport??null,replacementInProgress:n.replacementPending,lastLifecycleTransitionAtMs:n.lastLifecycleTransitionAtMs,transitionCount:n.transitionCount,connectingTransitionCount:n.connectingTransitionCount,replacementCount:n.replacementCount,retireCount:n.retireCount,lastDisconnectReason:n.lastDisconnectReason??void 0,lastReconnectReason:n.lastReconnectReason??void 0,updatedAt:n.lastSeenAtMs,error:n.error??void 0}}function Xe(n){let e=F(n),t=u(e,"connectionId","connection_id");if(!t)return null;let i=u(e,"state")||"connecting",r=p(e,"createdAt","created_at")??p(e,"updatedAt","updated_at")??Date.now(),o=p(e,"updatedAt","updated_at")??r;return {connectionId:t,deviceId:u(e,"deviceId","device_id"),deviceIdHint:u(e,"deviceIdHint","device_id_hint"),remoteNodeId:u(e,"remoteNodeId","remote_node_id"),state:i,transportState:u(e,"transportState","transport_state")??(i==="connected"?"connected":i==="connecting"?"connecting":"closed"),protocolState:u(e,"protocolState","protocol_state")??(i==="connected"?"routable":i==="connecting"?"connecting":"closed"),routable:k(e,"routable")??false,readinessState:u(e,"readinessState","readiness_state")??void 0,readinessReason:u(e,"readinessReason","readiness_reason")??void 0,transportGeneration:p(e,"transportGeneration","transport_generation")??void 0,routeGeneration:p(e,"routeGeneration","route_generation")??void 0,activeTransportStableId:p(e,"activeTransportStableId","active_transport_stable_id")??void 0,activeTransport:B(e,"activeTransport","active_transport"),parallelTransport:B(e,"parallelTransport","parallel_transport")??null,replacementInProgress:k(e,"replacementInProgress","replacement_in_progress")??void 0,lastLifecycleTransitionAtMs:p(e,"lastLifecycleTransitionAtMs","last_lifecycle_transition_at_ms")??void 0,transitionCount:p(e,"transitionCount","transition_count")??void 0,connectingTransitionCount:p(e,"connectingTransitionCount","connecting_transition_count")??void 0,replacementCount:p(e,"replacementCount","replacement_count")??void 0,retireCount:p(e,"retireCount","retire_count")??void 0,lastDisconnectReason:u(e,"lastDisconnectReason","last_disconnect_reason")??void 0,lastReconnectReason:u(e,"lastReconnectReason","last_reconnect_reason")??void 0,error:u(e,"error")??void 0,createdAt:r,updatedAt:o}}function Ve(n,e){return n?n.connectionId===e.connectionId&&(n.deviceId??null)===(e.deviceId??null)&&(n.deviceIdHint??null)===(e.deviceIdHint??null)&&(n.remoteNodeId??null)===(e.remoteNodeId??null)&&n.state===e.state&&(n.transportState??null)===(e.transportState??null)&&(n.protocolState??null)===(e.protocolState??null)&&!!n.routable==!!e.routable&&(n.activeTransport??null)===(e.activeTransport??null)&&(n.parallelTransport??null)===(e.parallelTransport??null)&&(n.activeTransportStableId??null)===(e.activeTransportStableId??null)&&(n.transportGeneration??null)===(e.transportGeneration??null)&&(n.routeGeneration??null)===(e.routeGeneration??null)&&!!n.replacementInProgress==!!e.replacementInProgress&&(n.transitionCount??null)===(e.transitionCount??null)&&(n.connectingTransitionCount??null)===(e.connectingTransitionCount??null)&&(n.replacementCount??null)===(e.replacementCount??null)&&(n.retireCount??null)===(e.retireCount??null)&&(n.lastDisconnectReason??null)===(e.lastDisconnectReason??null)&&(n.lastReconnectReason??null)===(e.lastReconnectReason??null)&&(n.error??null)===(e.error??null):false}function Ht(n){try{let e=n.replace(/-/g,"+").replace(/_/g,"/"),t=(4-e.length%4)%4,i=e+"=".repeat(t);if(typeof atob=="function")return JSON.parse(atob(i));let r=globalThis.Buffer;if(r)return JSON.parse(r.from(i,"base64").toString("utf8"))}catch{return null}return null}function Kt(n){let e=typeof n=="string"?n.trim():"";if(!e)return {present:false};let t=e.lastIndexOf("."),i=t>=0?e.slice(0,t):e,r=t>=0?e.slice(t+1):null,o=r?Ht(r):null,s=o&&typeof o.t=="string"&&o.t.trim().length>0?o.t.trim():null,a=o&&typeof o.s=="string"&&o.s.trim().length>0?o.s.trim():null,c=o&&typeof o.m=="number"&&Number.isFinite(o.m)?o.m:null;return {present:true,irohFingerprint:ee(i),tokenFingerprint:ee(s),tokenSuffixFingerprint:ee(r),scope:a,maxConnections:c}}function j(n,e,t={}){let i=typeof n.finishSend=="function"?n.finishSend.bind(n):typeof n.finish_send=="function"?n.finish_send.bind(n):null;if(!i){if(t.requireFinish===true)throw new Error("WASM peer stream is missing finishSend(); rebuild the current OpenRTC WASM before sending application data");return e}let r=e.getWriter();return new WritableStream({write:o=>r.write(o),async close(){await r.close(),await i();},abort:o=>r.abort(o)})}var g=class g{constructor(e$1){this.spaceNamespaceIdPromise=null;this.cachedSpaceNamespaceId=null;this.authListeners=[];this.wasmClient=null;this.createdAtMs=Date.now();this.missingWasmWarnings=new Set;this.wasmReadyWarningDelayMs=15e3;this.browserCoordinationSignaling=null;this.lastObservedFirebaseUserId=null;this.sessionReaders=new Set;this.authContext=null;this.injectedBrowserAuthSessionActive=false;this.hasSyncedAuthToWasmClient=false;this.lastWasmAuthUserId=null;this.lastWasmAuthToken=null;this.lastDeliveredConnectionStates=new Map;this.authScopedRuntimeGeneration=0;this.coreClient=null;this.applicationRouteEscalations=new Map;this.applicationRouteEscalationUnsubscribe=null;this.applicationRouteEscalationSubscriptionGeneration=-1;this.applicationRouteEscalationSubscriptionEpoch=0;if(this.appTag=e(e$1),this.options={...e$1,appTag:this.appTag,authMode:f$1(e$1),projectId:g$1(e$1)},this.nativeTrustTokens=this.options.coordinationGateway?new Z(this.options.coordinationGateway.nativeTrustTokenProvider):null,this.presenceManager=new te({isTicketOnlyMode:()=>this.isTicketOnlyMode(),waitForWasmClient:(i,r)=>this.waitForWasmClient(i,r),warnMissingWasmOnce:i=>this.warnMissingWasmOnce(i),resolveWebLogicalDeviceId:()=>this.resolveWebLogicalDeviceId(),withWebPresenceMetadata:(i,r)=>this.withWebPresenceMetadata(i,r),updatePresence:(i,r,o,s,a,c)=>this.updatePresence(i,r,o,s,a,c),updateExcludedPeers:(i,r)=>this.getCoordinationSignaling().updateDevice(i,{excludedPeers:r}),getCoordinationSignaling:()=>this.getCoordinationSignaling(),rememberRouteRepairTokenFromTicket:i=>this.coreClient?.rememberRouteRepairTokenFromTicket?.(i)??Promise.resolve(false),onDesiredPeersChanged:()=>this.retryManagedApplicationRouteEscalations()}),this.persistenceReady=Promise.resolve(),this.isTicketOnlyMode()||this.usesProviderNeutralGrant()){this.app=null,this.auth=null;return}let t=b$1();this.app=t.getApp(),this.auth=t.getAuth(),t.onAuthStateChanged(i=>{if(this.authContext)return;if(this.isSpaceMode()){this.authListeners.forEach(s=>s(this.toRuntimeIdentity(i)));return}let r=i?.uid??null,o=this.lastObservedFirebaseUserId;this.lastObservedFirebaseUserId=r,o&&o!==r&&this.stopAuthScopedActivity({userId:o}),this.browserCoordinationSignaling?.handleScopeChange(),this.authListeners.forEach(s=>s(this.toRuntimeIdentity(i)));});}get tag(){return this.appTag}getRuntimeCapabilities(){return Fe()}getDeviceIdentityStorageKey(){let e=h(this.options);return `${g.WEB_DEVICE_ID_STORAGE_PREFIX}_${e}`}getDeviceIdPersistenceMode(){return this.options.deviceIdPersistence??this.options.nodeIdPersistence??"persistent"}isTicketOnlyMode(){return this.options.signalingMode==="ticket-only"}usesProviderNeutralGrant(){return typeof this.options.coordinationGateway?.grantProvider=="function"}createRandomDeviceId(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`web-${Date.now()}-${Math.random().toString(36).slice(2,10)}`}resolveWebLogicalDeviceId(){let e=this.options.localDeviceId?.trim();if(e)return e;let t=this.getDeviceIdPersistenceMode();if(typeof localStorage>"u")return this.createRandomDeviceId();let i=this.getDeviceIdentityStorageKey(),r=Date.now(),o=null;try{let l=localStorage.getItem(i);o=l?JSON.parse(l):null;}catch{o=null;}let s=typeof o?.deviceId=="string"?o.deviceId.trim():"",a=typeof o?.expiresAt=="number"?o.expiresAt:void 0;if(t==="persistent"){let l=s||this.createRandomDeviceId();return localStorage.setItem(i,JSON.stringify({deviceId:l})),l}if(s&&typeof a=="number"&&a>r){let l=r+g.EPHEMERAL_DEVICE_ID_TTL_MS;return localStorage.setItem(i,JSON.stringify({deviceId:s,expiresAt:l})),s}let c=this.createRandomDeviceId(),d=r+g.EPHEMERAL_DEVICE_ID_TTL_MS;return localStorage.setItem(i,JSON.stringify({deviceId:c,expiresAt:d})),c}getDefaultBrowserDeviceName(){return this.options.deviceName?.trim()||(this.options.storagePrefix?`Web (${this.options.storagePrefix.replace(/_$/,"")})`:"Web Browser")}getCoordinationSignaling(){if(this.isTicketOnlyMode())throw new Error('[openrtc] Browser signaling is disabled when signalingMode="ticket-only".');if(!this.options.coordinationGateway)throw new Error("[OpenRTC] Managed coordination requires coordinationGateway; the legacy direct Firebase data plane has been removed.");return this.browserCoordinationSignaling||(this.browserCoordinationSignaling=new Q({projectId:this.options.projectId,gateway:this.options.coordinationGateway,appTag:this.appTag,discoveryMode:this.options.discoveryMode,resolveSpaceNamespaceId:()=>this.ensureSpaceNamespaceIdPromise(),getCurrentUserId:()=>this.getCurrentUserId(),getAuthToken:async(e=false)=>{let t=this.currentUser;return t?.getToken?t.getToken(e):null},getAppCheckToken:async(e=false)=>{let t=this.authContext?.appCheckTokenProvider??this.options.platformAttestationTokenProvider;return t?t(e):b$1().getAppCheckToken(e)},getLocalDeviceId:()=>this.resolveWebLogicalDeviceId(),getDefaultDeviceName:()=>this.getDefaultBrowserDeviceName(),getPlatformType:()=>this.options.coordinationPlatformType??"web",normalizeDevice:(e,t)=>this.normalizeDevice(e,t),avenueOverride:this.options.coordinationAvenueOverride,nativeTrustTokens:this.nativeTrustTokens})),this.browserCoordinationSignaling}usesCoordinationGateway(){return !!this.options.coordinationGateway}async reconnectCoordinationAfterHostResume(){await this.browserCoordinationSignaling?.reconnectAfterHostResume?.();}async getCoordinationNativeTrustToken(e=false){if(!this.nativeTrustTokens)throw new Error("[OpenRTC] Native trust tokens require a coordination gateway.");return this.nativeTrustTokens.get(e)}invalidateCoordinationNativeTrustToken(){this.nativeTrustTokens?.invalidate();}subscribeCoordinationNativeTrustToken(e,t){return this.nativeTrustTokens?this.nativeTrustTokens.subscribe(e,t):()=>{}}setCoordinationLocalDeviceId(e){if(!this.options.coordinationGateway)return;let t=e.trim();t&&(this.options.localDeviceId=t);}setCoordinationPlatformType(e){this.options.coordinationGateway&&(this.options.coordinationPlatformType=e);}async setCoordinationExcludedPeers(e){let t=this.resolveWebLogicalDeviceId();if(!t)throw new Error("The local device must be known before publishing peer exclusions.");await this.getCoordinationSignaling().updateDevice(t,{excludedPeers:e});}async joinCoordinationRoom(e,t,i){let r=this.getCoordinationSignaling();if(!r.joinCoordinationRoom)throw new Error("The active coordination provider does not support rooms.");await r.joinCoordinationRoom(e,t,i);}async leaveCoordinationRoom(e){await this.getCoordinationSignaling().leaveCoordinationRoom?.(e);}async getCoordinationRoomMembers(e){let t=this.getCoordinationSignaling();if(!t.getCoordinationRoomMembers)throw new Error("The active coordination provider does not support rooms.");return t.getCoordinationRoomMembers(e)}watchCoordinationRoomMembers(e,t){let i=this.getCoordinationSignaling();if(!i.watchCoordinationRoomMembers)throw new Error("The active coordination provider does not support rooms.");return i.watchCoordinationRoomMembers(e,t)}async withWebPresenceMetadata(e,t){let i;if(!e||!e.trim())i=JSON.stringify({deviceId:t});else {try{let r=JSON.parse(e);if(r&&typeof r=="object"&&!Array.isArray(r))return i=JSON.stringify({...r,deviceId:t}),await se(i)??i}catch{}i=JSON.stringify({deviceId:t,metadata:e});}return await se(i)??i}async setAuthContext(e){let t=this.injectedBrowserAuthSessionActive,i=this.authContext?.userId??null,r=e?.userId??null;if(this.authContext=e,!this.isTicketOnlyMode()&&!this.usesProviderNeutralGrant()&&e?.customToken?.trim()&&!(c()&&this.options.authMode==="external"&&typeof e.tokenProvider=="function"))try{await this.ensureBrowserPlatformAuth(e.userId,e.customToken.trim());}catch(o){console.warn("[WasmBridge] ensureBrowserPlatformAuth failed (non-fatal):",o);}else if(!this.isTicketOnlyMode()&&!this.usesProviderNeutralGrant()&&!e&&t)try{await this.auth?.signOut();}catch(o){console.warn("[WasmBridge] Failed to clear injected browser auth session:",o);}finally{this.injectedBrowserAuthSessionActive=false;}this.syncWasmAuthToken(),!this.isTicketOnlyMode()&&i!==r&&await this.browserCoordinationSignaling?.handleScopeChange(),this.authListeners.forEach(o=>o(this.currentUser));}async ensureBrowserPlatformAuth(e,t){if((this.auth?.currentUser?.uid??null)===e){this.injectedBrowserAuthSessionActive=true;return}await b$1().signInWithCustomTokenValue(t),this.injectedBrowserAuthSessionActive=true;}syncWasmAuthToken(){let e=this.wasmClient?.setIdentityCredential??this.wasmClient?.set_auth_token;if(!this.wasmClient||typeof e!="function"||!this.authContext&&this.isSpaceMode())return;let t=this.authContext?.userId??null,i=this.authContext?.token,r=typeof i=="string"&&i.trim().length>0?i:null;if(!(this.hasSyncedAuthToWasmClient&&this.lastWasmAuthUserId===t&&this.lastWasmAuthToken===r)){if(this.lastWasmAuthUserId=t,this.lastWasmAuthToken=r,this.hasSyncedAuthToWasmClient=true,r===null&&typeof this.wasmClient.clearIdentityCredential=="function"){this.wasmClient.clearIdentityCredential();return}e.call(this.wasmClient,r);}}toRuntimeIdentity(e){return e?{id:e.uid,email:e.email,displayName:e.displayName,isAnonymous:e.isAnonymous,getToken:async(t=false)=>{try{return await e.getIdToken(t)}catch{return null}}}:null}getCurrentUserId(){return this.authContext?.userId?this.authContext.userId:this.isTicketOnlyMode()?null:this.auth?.currentUser?.uid??null}getCurrentUserIdForScope(){return this.getCurrentUserId()}getAuthContext(){return this.authContext}isSpaceMode(){return Ke(this.options)}getResolvedOptions(){return this.options}getDiscoveryScopeId(){if(this.isTicketOnlyMode())return null;let e=this.getCurrentUserId();return e||(this.isSpaceMode()?this.resolveWebLogicalDeviceId():null)}matchesTag(e){return ze(e,this.appTag,this.isSpaceMode())}matchesLegacyOrCurrentTag(e){return this.matchesTag(e)}async stopSessionSubscriptions(){let e=Array.from(this.sessionReaders);this.sessionReaders.clear(),await Promise.allSettled(e.map(async t=>{try{await t.cancel();}catch{}}));}async stopRuntimeAuthScopedLoops(){let e=await this.waitForWasmClient(250);if(e)try{typeof e.stop_auth_scoped_activity=="function"?await e.stop_auth_scoped_activity():(typeof e.stop_presence_loop=="function"&&await e.stop_presence_loop(),typeof e.stop_auto_connect=="function"&&await e.stop_auto_connect());}catch(t){console.warn("[WasmSignaling] Failed to stop auth-scoped runtime loops:",t);}}async stopAuthScopedActivity(e){De("WasmBridge.stopAuthScopedActivity",{userId:e?.userId??null}),this.authScopedRuntimeGeneration+=1,this.stopApplicationRouteEscalationSubscription();let t=await this.waitForWasmClient(500);if(t&&typeof t.revoke_tokens_by_scope=="function")try{await t.revoke_tokens_by_scope("user-device");}catch(i){console.warn("[WasmBridge] user-device revoke during auth-scoped shutdown failed:",i);}this.presenceManager.stop(),this.browserCoordinationSignaling?.stopAuthScopedActivity(),await this.stopSessionSubscriptions(),this.lastDeliveredConnectionStates.clear(),this.applicationRouteEscalations?.clear(),await this.stopRuntimeAuthScopedLoops();}setWasmClient(e){this.wasmClient=e,this.lastWasmAuthUserId=null,this.lastWasmAuthToken=null,this.hasSyncedAuthToWasmClient=this.authContext===null,this.lastDeliveredConnectionStates.clear(),this.applicationRouteEscalations?.clear(),this.syncWasmAuthToken();}warnMissingWasmOnce(e){!this.wasmClient&&Date.now()-this.createdAtMs<this.wasmReadyWarningDelayMs||this.missingWasmWarnings.has(e)||(this.missingWasmWarnings.add(e),console.warn(`[WasmSignaling] ${e} skipped: wasm client is not ready.`));}async waitForWasmClient(e=4e3,t=50){if(this.wasmClient)return this.wasmClient;let i=Date.now();for(;!this.wasmClient&&Date.now()-i<e;)await a(t);return this.wasmClient??null}normalizeDevice(e,t){return ue(e,t)}normalizeDeviceRecord(e,t){return this.normalizeDevice(e,t)}getResolvedWebLogicalDeviceId(){return this.resolveWebLogicalDeviceId()}normalizeDeviceStatusSnapshot(e){return qe(e)}normalizePeerSessionSnapshot(e){return $e(e)}toBackendConnectionStateFromPeerSession(e){return Ye(e)}normalizeConnectionStateSnapshot(e){return Xe(e)}stabilizeConnectionState(e){let t=this.lastDeliveredConnectionStates.get(e.connectionId);return {...e,deviceId:e.deviceId??t?.deviceId??null,deviceIdHint:e.deviceIdHint??t?.deviceIdHint??null,remoteNodeId:e.remoteNodeId??t?.remoteNodeId??null,createdAt:e.createdAt??t?.createdAt,updatedAt:e.updatedAt??t?.updatedAt}}sameConnectionState(e,t){return Ve(e,t)}deliverConnectionState(e,t,i,r){let o=this.stabilizeConnectionState(e);this.escalateManagedApplicationRoute(o),this.lastDeliveredConnectionStates.set(o.connectionId,o);let a=(r??this.lastDeliveredConnectionStates).get(o.connectionId);this.sameConnectionState(a,o)||(r&&r.set(o.connectionId,o),t(o));}get browserPresenceLoopState(){return this.presenceManager.presenceLoopState}set browserPresenceLoopState(e){this.presenceManager.presenceLoopState=e;}get currentUser(){if(this.authContext?.userId){let e=this.authContext.token??null,t=this.authContext.tokenProvider;return {id:this.authContext.userId,getToken:async(i=false)=>{if(e&&(!i||!t))return e;if(t)try{let o=await t(i);if(o)return o}catch{}let r=this.isTicketOnlyMode()?null:this.auth?.currentUser??null;if(r&&r.uid===this.authContext?.userId)try{return await r.getIdToken(i)}catch{return null}return null}}}return this.isTicketOnlyMode()?null:this.toRuntimeIdentity(this.auth?.currentUser??null)}onAuthChange(e){return this.authListeners.push(e),e(this.currentUser),()=>{this.authListeners=this.authListeners.filter(t=>t!==e);}}async checkForSSOToken(){this.isTicketOnlyMode()||this.usesProviderNeutralGrant()||await b$1().checkForSSOToken();}async waitForAuth(){this.isTicketOnlyMode()||this.usesProviderNeutralGrant()||this.isSpaceMode()||this.authContext?.userId||this.auth?.currentUser||await b$1().waitForAuth();}async signInAnonymously(){if(!this.isTicketOnlyMode()){if(this.options.authMode!=="anonymous")throw new Error(`[pluto-rtc] Anonymous sign-in is disabled when authMode=${this.options.authMode}.`);await b$1().signInAnonymously();}}async signInWithPluto(){if(this.isTicketOnlyMode())throw new Error('[openrtc] Pluto sign-in is unavailable when signalingMode="ticket-only".');await b$1().signInWithPluto();}async signOut(){let e=this.getCurrentUserId();await this.stopAuthScopedActivity({userId:e}),this.authContext=null,this.syncWasmAuthToken(),this.isTicketOnlyMode()||await this.auth?.signOut(),this.authListeners.forEach(t=>t(this.currentUser));}async getTurnCredentials(){return this.isTicketOnlyMode()||!this.auth?.currentUser?null:typeof this.options.turnCredentialsProvider=="function"?await this.options.turnCredentialsProvider()??null:null}async updatePresence(e,t,i=true,r=3e5,o,s){if(this.isTicketOnlyMode())return;let a=this.resolveWebLogicalDeviceId(),c=this.getDeviceIdPersistenceMode()==="ephemeral"?g.EPHEMERAL_DEVICE_ID_TTL_MS:r,d=await this.withWebPresenceMetadata(o,a);this.presenceManager.updatePresenceLoopState({userId:this.getCurrentUserId()??"",localNodeId:e,ticket:t,metadata:d,deviceName:s?.trim()||this.getDefaultBrowserDeviceName()}),await this.getCoordinationSignaling().updatePresence(e,t,i,c,d,s);}async refreshLivePresence(e,t,i,r){if(this.isTicketOnlyMode())return;let o=this.resolveWebLogicalDeviceId(),s=await this.withWebPresenceMetadata(i,o);this.presenceManager.updatePresenceLoopState({userId:this.getCurrentUserId()??"",localNodeId:e,ticket:t,metadata:s,deviceName:r?.trim()||this.getDefaultBrowserDeviceName()}),await this.getCoordinationSignaling().updatePresence(e,t,true,15*6e4,s,r);}async setOffline(e){this.presenceManager.stopPresence(),!this.isTicketOnlyMode()&&await this.getCoordinationSignaling().setOffline(e);}async updateDevice(e,t){if(!e?.trim())throw new Error("updateDevice requires a deviceId");this.isTicketOnlyMode()||await this.getCoordinationSignaling().updateDevice(e,t);}async deleteDevice(e){if(!e?.trim())throw new Error("deleteDevice requires a deviceId");this.isTicketOnlyMode()||await this.getCoordinationSignaling().deleteDevice(e);}async cleanupStaleDevices(){this.isTicketOnlyMode()||await this.getCoordinationSignaling().cleanupStaleDevices();}async sendMessage(e,t,i,r){if(this.isTicketOnlyMode())throw new Error('[openrtc] sendMessage() is unavailable when signalingMode="ticket-only".');return this.getCoordinationSignaling().sendMessage(e,t,i,r)}async pollMessages(e){return this.isTicketOnlyMode()?[]:this.getCoordinationSignaling().pollMessages(e)}async searchDevices(e){return this.isTicketOnlyMode()?[]:this.getCoordinationSignaling().searchDevices(e)}async listDevicesWithStatus(){if(this.isTicketOnlyMode())return [];if(!this.getDiscoveryScopeId())return [];let t=await this.getCoordinationSignaling().listDevices(),i=this.wasmClient;return Promise.all(t.map(async r=>{let o=this.normalizeDeviceStatusSnapshot({...r,connectionStatus:r.online?"online":"disconnected"}),s=typeof r.nodeId=="string"?r.nodeId.trim():"";if(!s||typeof i?.iroh_path_kind!="function"||typeof i?.iroh_transport_rtt_ms!="function")return o;try{let[a,c]=await Promise.all([i.iroh_path_kind(s),i.iroh_transport_rtt_ms(s)]);if(typeof c!="number"||!Number.isFinite(c))return o;let d=Math.max(0,Math.round(c)),l={};if(a==="direct-lan")l.irohLan=d;else if(a==="direct-quic")l.iroh=d;else if(a==="ble")l.ble=d;else if(a==="relay")l.irohRelay=d;else return o;return {...o,latencyMs:d,latencyByTransport:l}}catch(a){return b$2("[WasmBridge] iroh transport latency unavailable",{deviceId:r.deviceId,error:a instanceof Error?a.message:String(a)}),o}}))}async getPeerSession(e){let t=await this.waitForWasmClient(500);if(t&&typeof t.peer_session=="function"){let i=await t.peer_session(e);return !i||typeof i!="object"?null:this.normalizePeerSessionSnapshot(i)}return this.warnMissingWasmOnce("getPeerSession"),null}async listPeerSessions(){let e=await this.waitForWasmClient(500);if(e&&typeof e.peer_sessions=="function"){let t=await e.peer_sessions();return (Array.isArray(t)?t:[]).map(r=>this.normalizePeerSessionSnapshot(r)).filter(r=>!!(r.peerId||r.deviceId||r.deviceIdHint||r.nodeId||r.activeConnectionId))}return this.warnMissingWasmOnce("listPeerSessions"),[]}async waitForSettledPeer(e,t){let i=await this.waitForWasmClient(500);if(i&&typeof i.wait_for_settled_peer=="function"){let r=await i.wait_for_settled_peer(e,t);return !r||typeof r!="object"?null:this.normalizePeerSessionSnapshot(r)}return this.warnMissingWasmOnce("waitForSettledPeer"),null}async openPeerBi(e,t){let i=await this.waitForWasmClient(500);if(i&&typeof i.open_peer_bi=="function"){let r=await i.open_peer_bi(e,t);if(!r?.recv||!r?.send)throw new Error("WASM open_peer_bi returned an invalid bidirectional stream");return {readable:r.recv,writable:j(r,r.send)}}throw this.warnMissingWasmOnce("openPeerBi"),new Error("WASM runtime does not support open_peer_bi()")}async openPeerNativeBi(e,t,i){let r=await this.waitForWasmClient(500),o=r&&r.open_peer_native_bi;if(typeof o=="function"){let s=await o.call(r,e,t,i);if(!s?.recv||!s?.send)throw new Error("WASM open_peer_native_bi returned an invalid bidirectional stream");return {readable:s.recv,writable:j(s,s.send)}}throw this.warnMissingWasmOnce("openPeerNativeBi"),new Error("WASM runtime does not support open_peer_native_bi()")}async openPeerBiTransportOnly(e,t){if(this.options.applicationCrypto?.requireEncrypted)throw new Error("[WasmBridge] openPeerBiTransportOnly is debug-only and cannot be used when application crypto is required");let i=await this.waitForWasmClient(500),r=i&&typeof i.open_peer_bi_transport_only=="function";if(console.debug("[WasmBridge] openPeerBiTransportOnly",{peerId:e,hasWasmClient:!!i,hasTransportOnly:r,timeoutMs:t}),r){let o=await i.open_peer_bi_transport_only(e,t);if(!o?.recv||!o?.send)throw new Error("WASM open_peer_bi_transport_only returned an invalid bidirectional stream");return {readable:o.recv,writable:j(o,o.send)}}return console.debug("[WasmBridge] openPeerBiTransportOnly falling back to openPeerBi",{peerId:e}),this.openPeerBi(e,t)}async openPeerUni(e,t){let i=await this.waitForWasmClient(500);if(i&&typeof i.open_peer_uni=="function"){let r=await i.open_peer_uni(e,t),o=r?.writable??r;if(!o)throw new Error("WASM open_peer_uni returned an invalid writable stream");return {writable:j(r,o)}}throw this.warnMissingWasmOnce("openPeerUni"),new Error("WASM runtime does not support open_peer_uni()")}async resolvePeerConnectionRecords(e){let t=await this.waitForWasmClient(500);if(t&&typeof t.resolve_peer_connection_records=="function"){let i=await t.resolve_peer_connection_records(e);return (Array.isArray(i)?i:[]).map(r=>({connectionId:typeof r.connectionId=="string"?r.connectionId:"",nodeId:typeof r.nodeId=="string"?r.nodeId:null,deviceId:typeof r.deviceId=="string"?r.deviceId:null,deviceIdHint:typeof r.deviceIdHint=="string"?r.deviceIdHint:null,endpointId:typeof r.endpointId=="string"?r.endpointId:null,transportGeneration:typeof r.transportGeneration=="number"?r.transportGeneration:0,routeGeneration:typeof r.routeGeneration=="number"?r.routeGeneration:void 0,transportStableId:typeof r.transportStableId=="number"?r.transportStableId:null,transportSource:typeof r.transportSource=="string"?r.transportSource:null,lastTransportChangeAtMs:typeof r.lastTransportChangeAtMs=="number"?r.lastTransportChangeAtMs:0,lastRouteChangeAtMs:typeof r.lastRouteChangeAtMs=="number"?r.lastRouteChangeAtMs:void 0,state:typeof r.state=="string"?r.state:"pending",statusReason:typeof r.statusReason=="string"?r.statusReason:null,createdAtMs:typeof r.createdAtMs=="number"?r.createdAtMs:0,updatedAtMs:typeof r.updatedAtMs=="number"?r.updatedAtMs:0}))}return this.warnMissingWasmOnce("resolvePeerConnectionRecords"),[]}async resolvePeerIdentity(e){let t=await this.waitForWasmClient(500);if(t){let i=r=>{if(!r||typeof r!="object")return {peerId:null,deviceId:null,deviceIdHint:null,nodeId:null};let o=r;return {peerId:typeof o.peerId=="string"?o.peerId:null,deviceId:typeof o.deviceId=="string"?o.deviceId:null,deviceIdHint:typeof o.deviceIdHint=="string"?o.deviceIdHint:null,nodeId:typeof o.nodeId=="string"?o.nodeId:null}};if(typeof t.peer_session=="function")try{let r=await t.peer_session(e),o=i(r);if(o.peerId||o.deviceId||o.deviceIdHint||o.nodeId)return o}catch{}if(typeof t.peer_snapshot=="function")try{return i(await t.peer_snapshot(e))}catch{}}return this.warnMissingWasmOnce("resolvePeerIdentity"),{peerId:null,deviceId:null,deviceIdHint:null,nodeId:null}}onDevicesChange(e,t){return this.isTicketOnlyMode()?(e([]),()=>{}):this.getCoordinationSignaling().onDevicesChange(e,t)}async subscribeDevices(e){return this.isTicketOnlyMode()?new ReadableStream({start(t){t.close();}}):this.getCoordinationSignaling().subscribeDevices()}async startAutoConnect(e,t){if(this.isTicketOnlyMode())return;this.startApplicationRouteEscalationSubscription();let i=this.authScopedRuntimeGeneration;try{let r=await this.waitForWasmClient();if(i!==this.authScopedRuntimeGeneration||!r||typeof r.start_auto_connect!="function")return;await r.start_auto_connect(e,t),i===this.authScopedRuntimeGeneration&&this.presenceManager.startAutoConnect(e,t);}catch(r){console.warn("[WasmBridge] failed to initialize WASM auto-connect context",{userId:e,localDeviceId:t,error:r});}}async startAutoConnectOnce(e,t){await this.startAutoConnect(e,t),this.forceReconnectSnapshot();}notifyDisconnectRequested(e){this.presenceManager.wakeRustAutoConnectOwner();}async setAutoConnectExcluded(e,t){await this.presenceManager.setAutoConnectExcluded(e,t);}async disconnectDevice(e){let t=await this.waitForWasmClient();if(!t||typeof t.disconnect_device!="function"){this.warnMissingWasmOnce("disconnectDevice"),await this.presenceManager.setAutoConnectExcluded(e,true).catch(()=>{});return}try{await t.disconnect_device(e,null),await this.presenceManager.recordAutoConnectExcludedForPresence(e,!0).catch(()=>{});}catch(i){throw console.warn("[WasmBridge] disconnect_device failed",{deviceId:e,error:i?.message??String(i)}),i}}async submitDesiredPeerProjection(e,t){return this.presenceManager.submitDesiredPeerProjection(e,t)}setCoreClient(e){e&&typeof e.connect=="function"?(this.coreClient=e,this.startApplicationRouteEscalationSubscription(),this.retryManagedApplicationRouteEscalations()):(this.coreClient=null,this.stopApplicationRouteEscalationSubscription());}startApplicationRouteEscalationSubscription(){if(this.applicationRouteEscalationUnsubscribe&&this.applicationRouteEscalationSubscriptionGeneration===this.authScopedRuntimeGeneration)return;this.stopApplicationRouteEscalationSubscription();let e=this.authScopedRuntimeGeneration,t=this.applicationRouteEscalationSubscriptionEpoch,i=this.onConnectionStateChange(()=>{});this.applicationRouteEscalationUnsubscribe=()=>{},this.applicationRouteEscalationSubscriptionGeneration=e,Promise.resolve(i).then(r=>{if(!this.coreClient||e!==this.authScopedRuntimeGeneration||t!==this.applicationRouteEscalationSubscriptionEpoch){r();return}this.applicationRouteEscalationUnsubscribe=r,this.applicationRouteEscalationSubscriptionGeneration=e;});}stopApplicationRouteEscalationSubscription(){this.applicationRouteEscalationSubscriptionEpoch+=1,this.applicationRouteEscalationUnsubscribe?.(),this.applicationRouteEscalationUnsubscribe=null,this.applicationRouteEscalationSubscriptionGeneration=-1;}retryManagedApplicationRouteEscalations(){for(let e of this.lastDeliveredConnectionStates.values())this.escalateManagedApplicationRoute(e);}escalateManagedApplicationRoute(e){if(!this.coreClient||!["connected","connecting"].includes(e.state)||this.applicationRouteEscalations.has(e.connectionId)||e.remoteNodeId&&this.coreClient.hasApplicationRouteForPeer?.(e.connectionId,e.remoteNodeId)===true)return;let t=this.presenceManager.resolveDesiredPeer(e.deviceId??e.deviceIdHint,e.remoteNodeId);if(!t?.ticket)return;let i=this.authScopedRuntimeGeneration,r=this.coreClient,o;o=(async()=>{let s=typeof r.ensureManagedApplicationRoute=="function"?await r.ensureManagedApplicationRoute({ticket:t.ticket,connectionId:e.connectionId,remoteNodeId:e.remoteNodeId??t.nodeId,expectedDeviceId:t.deviceId,timeoutMs:2e4}):await r.connect(t.ticket,2e4,t.deviceId,void 0,{admissionAlreadyPresented:true});if(i!==this.authScopedRuntimeGeneration)return;let a=s,c=a.id?.trim()||e.connectionId,d=a.remoteNodeId?.trim()||e.remoteNodeId?.trim()||a.deviceId?.trim()||t.deviceId;if(r.hasApplicationRouteForPeer?.(c,d)!==true&&r.hasApplicationRouteForPeer?.(c,d)!==true)throw new Error(`application crypto was not ready for ${d}`)})().catch(s=>{i===this.authScopedRuntimeGeneration&&console.warn("[WasmBridge][ROUTE-ESCALATION] Rust-managed route remains pending",{connectionId:e.connectionId,deviceId:t.deviceId,remoteNodeId:e.remoteNodeId??t.nodeId,error:s?.message??String(s)});}).finally(()=>{this.applicationRouteEscalations.get(e.connectionId)===o&&this.applicationRouteEscalations.delete(e.connectionId);}),this.applicationRouteEscalations.set(e.connectionId,o);}async connectToDevice(e){let t=await this.waitForWasmClient();if(!t||typeof t.connect_device!="function")throw this.warnMissingWasmOnce("connectToDevice"),new Error("WASM runtime does not support connect_device()");let i=Date.now();c$1("[WasmBridge][ROUTE-ESCALATION] starting managed transport dial",{deviceId:e.deviceId??null,ticket:Kt(e.endpointTicket),hasCoreClient:!!this.coreClient});let r=await t.connect_device(e.deviceId??null,e.endpointTicket);c$1("[WasmBridge][ROUTE-ESCALATION] managed transport dial completed",{deviceId:e.deviceId??null,remoteNodeId:r?.remoteNodeId??null,connectionId:r?.connectionId??null,elapsedMs:Date.now()-i});let o=e.endpointTicket;if(o&&this.coreClient){let s=this.coreClient;try{c$1("[WasmBridge][ROUTE-ESCALATION] starting typed application connection",{deviceId:e.deviceId??null,remoteNodeId:r?.remoteNodeId??null,connectionId:r?.connectionId??null});let a=typeof s.ensureManagedApplicationRoute=="function"?await s.ensureManagedApplicationRoute({ticket:o,connectionId:r?.connectionId??null,remoteNodeId:r?.remoteNodeId??null,expectedDeviceId:e.deviceId??null,approvedScope:r?.approvedScope??null,timeoutMs:2e4}):await s.connect(o,2e4,e.deviceId??null,void 0,{admissionAlreadyPresented:!0,approvedScope:r?.approvedScope??null}),c=typeof a?.remoteNodeId=="string"?a.remoteNodeId.trim():"",d=typeof a?.deviceId=="string"?a.deviceId.trim():"",l=c||r?.remoteNodeId?.trim?.()||d||e.deviceId?.trim?.()||"",m=typeof s.hasApplicationRouteForPeer=="function"?s.hasApplicationRouteForPeer.bind(s):null;if(!(!!l&&m?.(a?.id??void 0,l)===!0)&&l&&typeof s.waitForApplicationCryptoForPeer=="function"&&!(!!await s.waitForApplicationCryptoForPeer(l,2e4)&&(!m||m(a?.id??void 0,l)===!0)))throw console.warn("[WasmBridge][ROUTE-ESCALATION] application route still pending after managed dial",{deviceId:e.deviceId??null,remoteNodeId:c||(r?.remoteNodeId??null),connectionId:r?.connectionId??null,peerForCrypto:l,elapsedMs:Date.now()-i}),Object.assign(new Error(`application crypto was not ready for ${l}`),{applicationCryptoNotReady:!0});c$1("[WasmBridge][ROUTE-ESCALATION] application route ready",{deviceId:e.deviceId??null,remoteNodeId:c||(r?.remoteNodeId??null),connectionId:r?.connectionId??null,elapsedMs:Date.now()-i});}catch(a){if(a?.applicationCryptoNotReady)throw a;return console.warn("[WasmBridge] Managed transport connected; TS application route escalation is still pending",{deviceId:e.deviceId??null,remoteNodeId:r?.remoteNodeId??null,connectionId:r?.connectionId??null,error:a?.message??String(a)}),r}}return r}forceReconnectSnapshot(){this.isTicketOnlyMode()||!this.app||!this.auth||this.presenceManager.wakeRustAutoConnectOwner();}startPresenceLoop(e,t,i,r,o){this.presenceManager.startPresenceLoop(e,t,i,r,o);}ensureSpaceNamespaceIdPromise(){if(this.cachedSpaceNamespaceId)return Promise.resolve(this.cachedSpaceNamespaceId);if(!this.spaceNamespaceIdPromise){let e=this.options.apiKey?.trim()??"",t=this.options.spaceKey?.trim()??"";if(!e||!t)return Promise.resolve(null);this.spaceNamespaceIdPromise=d(e,t).then(i=>(this.cachedSpaceNamespaceId=i,i)).catch(()=>null);}return this.spaceNamespaceIdPromise}async createSession(e){if(this.isTicketOnlyMode())throw new Error('[openrtc] createSession() is unavailable when signalingMode="ticket-only".');let t=this.getCurrentUserId();if(!t&&!e.initiator&&!e.target&&!this.isSpaceMode())throw new Error("createSession requires user scope");let i={...e,appTag:e.appTag??this.appTag,initiator:e.initiator??t??void 0,target:e.target??t??void 0};await this.getCoordinationSignaling().createSession(i);}async updateSession(e,t){if(this.isTicketOnlyMode())throw new Error('[openrtc] updateSession() is unavailable when signalingMode="ticket-only".');await this.getCoordinationSignaling().updateSession(e,t);}async subscribeSessions(e){return this.isTicketOnlyMode()?new ReadableStream({start(t){t.close();}}):this.getCoordinationSignaling().subscribeSessions(e)}async getLocalDeviceId(){return this.resolveWebLogicalDeviceId()}async isConnected(e){let t=await this.waitForWasmClient();return t&&typeof t.is_connected=="function"&&await t.is_connected(e)?true:this.hasConnectedIndependentPeerRoute(t,e)}async hasConnectedIndependentPeerRoute(e,t){if(!e||typeof t!="string"||t.trim().length===0)return false;let i=t.trim(),r=[];if(typeof e.peer_session=="function")try{let o=await e.peer_session(i);o&&typeof o=="object"&&r.push(this.normalizePeerSessionSnapshot(o));}catch{}if(typeof e.peer_sessions=="function")try{let o=await e.peer_sessions();Array.isArray(o)&&r.push(...o.filter(s=>!!s&&typeof s=="object").map(s=>this.normalizePeerSessionSnapshot(s)));}catch{}return r.some(o=>{let s=typeof o.peerId=="string"?o.peerId.trim():"",a=typeof o.deviceId=="string"?o.deviceId.trim():"",c=typeof o.deviceIdHint=="string"?o.deviceIdHint.trim():"",d=typeof o.nodeId=="string"?o.nodeId.trim():"";return (i===s||i===a||i===c||i===d)&&o.status==="connected"&&o.settledReady===true&&o.replacementPending!==true&&l(o.activeTransport)})}async getConnectionStates(){let e=await this.waitForWasmClient(500);if(e&&typeof e.connection_states=="function"){let r=await e.connection_states(),o=(Array.isArray(r)?r:[]).map(s=>this.normalizeConnectionStateSnapshot(s)).filter(s=>!!s);return o.length>0&&b$2("[WasmBridge] replaying current wasm connection states",o.map(s=>({connectionId:s.connectionId,deviceId:s.deviceId??null,deviceIdHint:s.deviceIdHint??null,remoteNodeId:s.remoteNodeId??null,state:s.state,transportState:s.transportState??null,protocolState:s.protocolState??null,routable:s.routable??null}))),o}let i=(await this.listPeerSessions().catch(()=>[])).map(r=>this.toBackendConnectionStateFromPeerSession(r)).filter(r=>!!r);return i.length>0&&b$2("[WasmBridge] replaying current wasm connection states",i.map(r=>({connectionId:r.connectionId,deviceId:r.deviceId??null,deviceIdHint:r.deviceIdHint??null,remoteNodeId:r.remoteNodeId??null,state:r.state,transportState:r.transportState??null,protocolState:r.protocolState??null,routable:r.routable??null}))),i}onConnectionStateChange(e){let t=new Map,i=new Map,r=this.authScopedRuntimeGeneration,o=false,s=d=>{let l=d.detail,m=typeof l?.connectionId=="string"?l.connectionId.trim():"";if(!m||o)return;let h=(i.get(m)??0)+1;i.set(m,h);let y=this.authScopedRuntimeGeneration;(async()=>{let v=this.normalizeConnectionStateSnapshot(l),D=await this.waitForWasmClient(500);if(!(o||y!==this.authScopedRuntimeGeneration||i.get(m)!==h)){if(D&&typeof D.connection_state=="function"){let re=await D.connection_state(m),S=this.normalizeConnectionStateSnapshot(re);if(!o&&y===this.authScopedRuntimeGeneration&&i.get(m)===h&&S){this.deliverConnectionState(S,e,"rust-event",t);return}}!o&&y===this.authScopedRuntimeGeneration&&i.get(m)===h&&v&&this.deliverConnectionState(v,e,"rust-event-detail",t);}})().catch(v=>{o||console.warn("[WasmBridge] Failed to read Rust connection state after lifecycle event",{connectionId:m,error:v});});},a=typeof window<"u"?window:null,c=typeof a?.addEventListener=="function"&&typeof a?.removeEventListener=="function";return c&&a.addEventListener("connection-state-changed",s),this.getConnectionStates().then(d=>{!o&&r===this.authScopedRuntimeGeneration&&d.forEach(l=>{i.has(l.connectionId)||this.deliverConnectionState(l,e,"replay",t);});}).catch(d=>{console.warn("[WasmBridge] Failed to replay wasm connection states after subscription:",d);}),()=>{o=true,i.clear(),c&&a.removeEventListener("connection-state-changed",s);}}async sendExplicitFilePath(e,t,i=""){throw new Error("sendExplicitFilePath is native-only. Use sendExplicitFileData in web/wasm runtime.")}sanitizeExplicitFileName(e){let i=(typeof e=="string"?e.replace(/\\/g,"/"):"").split("/").reverse().find(s=>s.trim().length>0)?.trim()??"";if(!i||i==="."||i==="..")return g.FALLBACK_EXPLICIT_FILE_NAME;let r="";for(let s of i){if([...r].length>=g.MAX_EXPLICIT_FILE_NAME_CHARS)break;let a=s.charCodeAt(0);s==="/"||s==="\\"||s==="\0"||a<32||a===127?r+="_":r+=s;}let o=r.trim();return !o||o==="."||o===".."?g.FALLBACK_EXPLICIT_FILE_NAME:o}sanitizeExplicitMimeType(e){let t=typeof e=="string"?e.trim():"";if(!t)return g.FALLBACK_EXPLICIT_MIME_TYPE;let i="";for(let r of t){if(i.length>=g.MAX_EXPLICIT_MIME_TYPE_CHARS)break;let o=r.charCodeAt(0);o<33||o>126||r==='"'||r==="\\"?i+="_":i+=r;}return i.length>0?i:g.FALLBACK_EXPLICIT_MIME_TYPE}assertExplicitTransferHeaderSize(e){if(e.byteLength===0||e.byteLength>g.MAX_EXPLICIT_TRANSFER_HEADER_BYTES)throw new Error(`Explicit transfer header is too large: ${e.byteLength} bytes`)}createWebRTCExplicitTransferId(){let e=new Uint8Array(16),t=globalThis.crypto;if(t&&typeof t.getRandomValues=="function")return t.getRandomValues(e),e;for(let i=0;i<e.byteLength;i+=1)e[i]=Math.floor(Math.random()*256);return e}createWebRTCExplicitTransferFrame(e,t,i,r,o){let s=o?.headerFrame===true?4:0,a=new Uint8Array(25+s+r.byteLength);a[0]=g.EXPLICIT_FILE_PROTOCOL_TYPE,a.set(e,1);let c=new DataView(a.buffer);c.setUint32(17,t,false),c.setUint32(21,i,false);let d=o?.headerFrame===true?29:25;return o?.headerFrame===true&&c.setUint32(25,r.byteLength,false),a.set(r,d),a}async sendExplicitFileData(e){let t=e.connection,i=e.file,r=e.applicationCrypto??this.options.applicationCrypto;if((e.requireApplicationCrypto===true||t?.requireApplicationCrypto===true)&&!r)throw new Error("[WasmBridge] Explicit transfer requires application crypto but none is available for this connection");let s=e.transferId&&e.transferId.trim().length>0?e.transferId:`transfer-${Date.now()}`,a=typeof e.receiverPlatformType=="string"?e.receiverPlatformType.trim().toLowerCase():null,c=e.remoteNodeId?.trim()||t?.remoteNodeId?.trim()||t?.deviceId?.trim();if(c$1("[WasmBridge] sendExplicitFileData start",{connectionId:e.connectionId??null,connectionRemoteNodeId:t?.remoteNodeId??null,remoteNodeId:c??null,fileName:i.name,fileSize:i.size,transferId:s}),!c)throw new Error("Web explicit transfer requires an active connection with a resolved remote node ID");let d=await this.waitForWasmClient();if(!d)throw new Error("WASM explicit transfer requires an initialized WASM client");let l=new TextEncoder,m={transfer_id:s,filename:this.sanitizeExplicitFileName(i.name),size:i.size,mime_type:this.sanitizeExplicitMimeType(i.type)},h=l.encode(JSON.stringify(m));this.assertExplicitTransferHeaderSize(h);let y=new Uint8Array(4);new DataView(y.buffer).setUint32(0,h.byteLength,false);let v=new Uint8Array(y.byteLength+h.byteLength);v.set(y,0),v.set(h,y.byteLength);let D=async()=>{if(a!=="web"||!t||typeof t.sendOnWebRTC!="function"||typeof t.isWebRtcApplicationRouteReady!="function"||t.isWebRtcApplicationRouteReady()!==true)return a&&a!=="web"&&typeof t?.isWebRtcApplicationRouteReady=="function"&&t.isWebRtcApplicationRouteReady()===true&&c$1("[WasmBridge] sendExplicitFileData kept on Iroh for non-browser receiver",{remoteNodeId:c,transferId:s,receiverPlatformType:a}),false;let S=r?o(r):null,A=x=>S?S.protectFrame(x):x,C=new Uint8Array(await i.arrayBuffer()),E=this.createWebRTCExplicitTransferId(),N=Math.max(1,Math.ceil(C.byteLength/g.EXPLICIT_FILE_CHUNK_SIZE_BYTES)),b=typeof t.getWebRTCTransport=="function"?t.getWebRTCTransport():null,O=async()=>{b&&typeof b.getBufferedAmount=="function"&&typeof b.waitForDrain=="function"&&b.getBufferedAmount()>g.EXPLICIT_FILE_CHUNK_SIZE_BYTES*4&&await b.waitForDrain(g.EXPLICIT_FILE_CHUNK_SIZE_BYTES*2);};if(await t.sendOnWebRTC(this.createWebRTCExplicitTransferFrame(E,4294967295,N,A(h),{headerFrame:true})),await O(),C.byteLength===0)return await t.sendOnWebRTC(this.createWebRTCExplicitTransferFrame(E,0,N,A(new Uint8Array(0)))),true;let q=0;for(let x=0;x<C.byteLength;x+=g.EXPLICIT_FILE_CHUNK_SIZE_BYTES){let Qe=C.slice(x,Math.min(x+g.EXPLICIT_FILE_CHUNK_SIZE_BYTES,C.byteLength));await t.sendOnWebRTC(this.createWebRTCExplicitTransferFrame(E,q,N,A(Qe))),q+=1,await O();}return c$1("[WasmBridge] sendExplicitFileData sent over WebRTC explicit route",{connectionId:e.connectionId??null,remoteNodeId:c,transferId:s,chunks:N,encrypted:!!S}),true},re=async()=>{let S=d.open_peer_bi_explicit_file_sender;if(typeof S!="function")return false;let A=await S.call(d,c,5e3),C=A?.writable??A?.send;if(!C||typeof C.getWriter!="function")throw new Error("WASM explicit peer stream returned an invalid writable stream");c$1("[WasmBridge] sendExplicitFileData open_peer_bi_explicit_file_sender resolved",{remoteNodeId:c,transferId:e.transferId??null,applicationCryptoWrapped:A.applicationCryptoWrapped===true});let E=j(A,C,{requireFinish:true}).getWriter(),N=false;try{await E.write(v);let b=new Uint8Array(await i.arrayBuffer());for(let O=0;O<b.byteLength;O+=g.EXPLICIT_FILE_CHUNK_SIZE_BYTES){let q=b.slice(O,Math.min(O+g.EXPLICIT_FILE_CHUNK_SIZE_BYTES,b.byteLength));await E.write(q);}}catch(b){throw N=true,b}finally{try{await E.close();}catch(b){if(!N)throw b}finally{E.releaseLock();}}return true};try{try{if(await D())return}catch(S){c$1("[WasmBridge] sendExplicitFileData WebRTC explicit route failed; falling back",{remoteNodeId:c,transferId:s,error:S instanceof Error?S.message:String(S)});}if(await re())return;throw new Error("[WasmBridge] Explicit transfer requires the generation-fenced open_peer_bi_explicit_file_sender path, but it is unavailable on this WASM build. Rebuild the current OpenRTC WASM; raw open_bi fallback is intentionally unsupported for application data.")}finally{c$1("[WasmBridge] sendExplicitFileData completed",{remoteNodeId:c,transferId:s,fileName:i.name,fileSize:i.size});}}async getTransferHistory(e=50){return []}async deleteTransferJob(e){}watchFriendDevices(e,t){return this.isTicketOnlyMode()?()=>{}:this.getCoordinationSignaling().watchFriendDevices(e,t)}async updateFriendTicket(e){this.isTicketOnlyMode()||await this.getCoordinationSignaling().updateFriendTicket(e);}};g.EXPLICIT_FILE_PROTOCOL_TYPE=2,g.EXPLICIT_FILE_CHUNK_SIZE_BYTES=64*1024,g.MAX_EXPLICIT_TRANSFER_HEADER_BYTES=64*1024,g.FALLBACK_EXPLICIT_FILE_NAME="openrtc-transfer.bin",g.MAX_EXPLICIT_FILE_NAME_CHARS=180,g.FALLBACK_EXPLICIT_MIME_TYPE="application/octet-stream",g.MAX_EXPLICIT_MIME_TYPE_CHARS=255,g.WEB_DEVICE_ID_STORAGE_PREFIX="pluto_rtc_web_device_identity",g.EPHEMERAL_DEVICE_ID_TTL_MS=ae.browserIdentity.ephemeralDeviceIdTtlMs;var Je=g;
2
- export{Zt as a,en as b,tn as c,nn as d,se as e,Dt as f,De as g,ce as h,Gt as i,qe as j,$e as k,hn as l,fn as m,Xe as n,ae as o,on as p,Ot as q,xt as r,We as s,Fe as t,an as u,cn as v,Je as w};