vite-devtools-svelte 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # vite-devtools-svelte
2
2
 
3
- Svelte DevTools plugin for [Vite DevTools](https://github.com/nicepkg/vite-devtools). Provides 15 specialized panels for debugging, profiling, and inspecting Svelte/SvelteKit applications — all integrated directly into the Vite DevTools UI.
3
+ Svelte DevTools plugin for [Vite DevTools](https://github.com/vitejs/devtools). Provides 15 specialized panels for debugging, profiling, and inspecting Svelte/SvelteKit applications — all integrated directly into the Vite DevTools UI.
4
4
 
5
5
  > **Status:** Early development. APIs may change.
6
6
 
@@ -135,25 +135,33 @@ Svelte DevTools plugin for [Vite DevTools](https://github.com/nicepkg/vite-devto
135
135
  - **Vite** >= 8.0.0
136
136
  - **Svelte** 5 (runes mode)
137
137
  - **SvelteKit** (recommended, but not required for basic features)
138
+ - **[@vitejs/devtools](https://devtools.vite.dev/)** — the host UI this plugin's panels render inside
138
139
 
139
140
  ## Installation
140
141
 
142
+ `vite-devtools-svelte` is a panel provider — it needs the [`@vitejs/devtools`](https://devtools.vite.dev/) host plugin to render its UI. Install both:
143
+
141
144
  ```bash
142
- npm install -D vite-devtools-svelte
145
+ npm install -D vite-devtools-svelte @vitejs/devtools
143
146
  ```
144
147
 
145
148
  ## Setup
146
149
 
147
- Add the plugin to your `vite.config.ts`. **It must come before `sveltekit()`** so that the transforms run before the Svelte compiler.
150
+ Register **both** plugins in your `vite.config.ts`. `svelteDevtools()` **must come before `sveltekit()`** so that its transforms run before the Svelte compiler.
148
151
 
149
152
  ```ts
150
153
  // vite.config.ts
151
- import { svelteDevtools } from 'vite-devtools-svelte'
152
154
  import { sveltekit } from '@sveltejs/kit/vite'
155
+ import { DevTools } from '@vitejs/devtools'
156
+ import { svelteDevtools } from 'vite-devtools-svelte'
153
157
  import { defineConfig } from 'vite'
154
158
 
155
159
  export default defineConfig({
156
- plugins: [svelteDevtools(), sveltekit()],
160
+ plugins: [
161
+ svelteDevtools(), // must come before sveltekit()
162
+ DevTools(), // the @vitejs/devtools host — without it the panels have nowhere to render
163
+ sveltekit(),
164
+ ],
157
165
  })
158
166
  ```
159
167
 
@@ -163,7 +171,10 @@ Then start your dev server as usual:
163
171
  npm run dev
164
172
  ```
165
173
 
166
- The Svelte DevTools panels will appear inside the Vite DevTools UI.
174
+ Open your app in the browser. The Vite DevTools drawer appears at the bottom edge of the page — click the floating handle to open it, then switch to the **Svelte** tab to see the panels provided by this plugin.
175
+
176
+ > [!NOTE]
177
+ > If you only register `svelteDevtools()` without `DevTools()` from `@vitejs/devtools`, the dev server starts fine but **no DevTools UI appears** — there is no host for the panels to mount into.
167
178
 
168
179
  ## Options
169
180
 
@@ -0,0 +1,2 @@
1
+ function e(e){return typeof e==`string`?`'${e}'`:new t().serialize(e)}var t=function(){class e{#e=new Map;compare(e,t){let n=typeof e,r=typeof t;return n===`string`&&r===`string`?e.localeCompare(t):n===`number`&&r===`number`?e-t:String.prototype.localeCompare.call(this.serialize(e,!0),this.serialize(t,!0))}serialize(e,t){if(e===null)return`null`;switch(typeof e){case`string`:return t?e:`'${e}'`;case`bigint`:return`${e}n`;case`object`:return this.$object(e);case`function`:return this.$function(e)}return String(e)}serializeObject(e){let t=Object.prototype.toString.call(e);if(t!==`[object Object]`)return this.serializeBuiltInType(t.length<10?`unknown:${t}`:t.slice(8,-1),e);let n=e.constructor,r=n===Object||n===void 0?``:n.name;if(r!==``&&globalThis[r]===n)return this.serializeBuiltInType(r,e);if(typeof e.toJSON==`function`){let t=e.toJSON();return r+(typeof t==`object`&&t?this.$object(t):`(${this.serialize(t)})`)}return this.serializeObjectEntries(r,Object.entries(e))}serializeBuiltInType(e,t){let n=this[`$`+e];if(n)return n.call(this,t);if(typeof t?.entries==`function`)return this.serializeObjectEntries(e,t.entries());throw Error(`Cannot serialize ${e}`)}serializeObjectEntries(e,t){let n=Array.from(t).sort((e,t)=>this.compare(e[0],t[0])),r=`${e}{`;for(let e=0;e<n.length;e++){let[t,i]=n[e];r+=`${this.serialize(t,!0)}:${this.serialize(i)}`,e<n.length-1&&(r+=`,`)}return r+`}`}$object(e){let t=this.#e.get(e);return t===void 0&&(this.#e.set(e,`#${this.#e.size}`),t=this.serializeObject(e),this.#e.set(e,t)),t}$function(e){let t=Function.prototype.toString.call(e);return t.slice(-15)===`[native code] }`?`${e.name||``}()[native]`:`${e.name}(${e.length})${t.replace(/\s*\n\s*/g,``)}`}$Array(e){let t=`[`;for(let n=0;n<e.length;n++)t+=this.serialize(e[n]),n<e.length-1&&(t+=`,`);return t+`]`}$Date(e){try{return`Date(${e.toISOString()})`}catch{return`Date(null)`}}$ArrayBuffer(e){return`ArrayBuffer[${new Uint8Array(e).join(`,`)}]`}$Set(e){return`Set${this.$Array(Array.from(e).sort((e,t)=>this.compare(e,t)))}`}$Map(e){return this.serializeObjectEntries(`Map`,e.entries())}}for(let t of[`Error`,`RegExp`,`URL`])e.prototype[`$`+t]=function(e){return`${t}(${e})`};for(let t of[`Int8Array`,`Uint8Array`,`Uint8ClampedArray`,`Int16Array`,`Uint16Array`,`Int32Array`,`Uint32Array`,`Float32Array`,`Float64Array`])e.prototype[`$`+t]=function(e){return`${t}[${e.join(`,`)}]`};for(let t of[`BigInt64Array`,`BigUint64Array`])e.prototype[`$`+t]=function(e){return`${t}[${e.join(`n,`)}${e.length>0?`n`:``}]`};return e}(),n=[1779033703,-1150833019,1013904242,-1521486534,1359893119,-1694144372,528734635,1541459225],r=[1116352408,1899447441,-1245643825,-373957723,961987163,1508970993,-1841331548,-1424204075,-670586216,310598401,607225278,1426881987,1925078388,-2132889090,-1680079193,-1046744716,-459576895,-272742522,264347078,604807628,770255983,1249150122,1555081692,1996064986,-1740746414,-1473132947,-1341970488,-1084653625,-958395405,-710438585,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,-2117940946,-1838011259,-1564481375,-1474664885,-1035236496,-949202525,-778901479,-694614492,-200395387,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,-2067236844,-1933114872,-1866530822,-1538233109,-1090935817,-965641998],i=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_`,a=[],o=class{_data=new s;_hash=new s([...n]);_nDataBytes=0;_minBufferSize=0;finalize(e){e&&this._append(e);let t=this._nDataBytes*8,n=this._data.sigBytes*8;return this._data.words[n>>>5]|=128<<24-n%32,this._data.words[(n+64>>>9<<4)+14]=Math.floor(t/4294967296),this._data.words[(n+64>>>9<<4)+15]=t,this._data.sigBytes=this._data.words.length*4,this._process(),this._hash}_doProcessBlock(e,t){let n=this._hash.words,i=n[0],o=n[1],s=n[2],c=n[3],l=n[4],u=n[5],d=n[6],f=n[7];for(let n=0;n<64;n++){if(n<16)a[n]=e[t+n]|0;else{let e=a[n-15],t=(e<<25|e>>>7)^(e<<14|e>>>18)^e>>>3,r=a[n-2],i=(r<<15|r>>>17)^(r<<13|r>>>19)^r>>>10;a[n]=t+a[n-7]+i+a[n-16]}let p=l&u^~l&d,m=i&o^i&s^o&s,h=(i<<30|i>>>2)^(i<<19|i>>>13)^(i<<10|i>>>22),g=(l<<26|l>>>6)^(l<<21|l>>>11)^(l<<7|l>>>25),_=f+g+p+r[n]+a[n],v=h+m;f=d,d=u,u=l,l=c+_|0,c=s,s=o,o=i,i=_+v|0}n[0]=n[0]+i|0,n[1]=n[1]+o|0,n[2]=n[2]+s|0,n[3]=n[3]+c|0,n[4]=n[4]+l|0,n[5]=n[5]+u|0,n[6]=n[6]+d|0,n[7]=n[7]+f|0}_append(e){typeof e==`string`&&(e=s.fromUtf8(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes}_process(e){let t,n=this._data.sigBytes/64;n=e?Math.ceil(n):Math.max((n|0)-this._minBufferSize,0);let r=n*16,i=Math.min(r*4,this._data.sigBytes);if(r){for(let e=0;e<r;e+=16)this._doProcessBlock(this._data.words,e);t=this._data.words.splice(0,r),this._data.sigBytes-=i}return new s(t,i)}},s=class e{words;sigBytes;constructor(e,t){e=this.words=e||[],this.sigBytes=t===void 0?e.length*4:t}static fromUtf8(t){let n=unescape(encodeURIComponent(t)),r=n.length,i=[];for(let e=0;e<r;e++)i[e>>>2]|=(n.charCodeAt(e)&255)<<24-e%4*8;return new e(i,r)}toBase64(){let e=[];for(let t=0;t<this.sigBytes;t+=3){let n=this.words[t>>>2]>>>24-t%4*8&255,r=this.words[t+1>>>2]>>>24-(t+1)%4*8&255,a=this.words[t+2>>>2]>>>24-(t+2)%4*8&255,o=n<<16|r<<8|a;for(let n=0;n<4&&t*8+n*6<this.sigBytes*8;n++)e.push(i.charAt(o>>>6*(3-n)&63))}return e.join(``)}concat(e){if(this.words[this.sigBytes>>>2]&=4294967295<<32-this.sigBytes%4*8,this.words.length=Math.ceil(this.sigBytes/4),this.sigBytes%4)for(let t=0;t<e.sigBytes;t++){let n=e.words[t>>>2]>>>24-t%4*8&255;this.words[this.sigBytes+t>>>2]|=n<<24-(this.sigBytes+t)%4*8}else for(let t=0;t<e.sigBytes;t+=4)this.words[this.sigBytes+t>>>2]=e.words[t>>>2];this.sigBytes+=e.sigBytes}};function c(e){return new o().finalize(e).toBase64()}function l(t){return c(e(t))}function u(e){return l(e)}function d(e,t){let n=`\x1B[${e}m`,r=`\x1B[${t}m`;return((e,...t)=>{if(Array.isArray(e)&&`raw`in e){let i=e,a=``;for(let e=0;e<i.length;e++)a+=i[e],e<t.length&&(a+=String(t[e]));return`${n}${a}${r}`}return`${n}${String(e)}${r}`})}var f={blue:d(34,39),cyan:d(36,39),gray:d(90,39),green:d(32,39),red:d(31,39),yellow:d(33,39),bold:d(1,22),dim:d(2,22),reset:d(0,0),underline:d(4,24)};function p(){let e={};function t(t,...n){let r=e[t]||[];for(let e=0,t=r.length;e<t;e++){let t=r[e];t&&t(...n)}}function n(n,...r){t(n,...r),delete e[n]}function r(t,n){return(e[t]||=[]).push(n),()=>{e[t]=e[t]?.filter(e=>n!==e)}}function i(e,t){let n=r(e,((...e)=>(n(),t(...e))));return n}return{_listeners:e,emit:t,emitOnce:n,on:r,once:i}}var m=`useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict`;function h(e=21){let t=``,n=e;for(;n--;)t+=m[Math.random()*64|0];return t}var g=Symbol.for(`immer-nothing`),_=Symbol.for(`immer-draftable`),v=Symbol.for(`immer-state`),y=[function(e){return`The plugin for '${e}' has not been loaded into Immer. To enable the plugin, import and call \`enable${e}()\` when initializing your application.`},function(e){return`produce can only be called on things that are draftable: plain objects, arrays, Map, Set or classes that are marked with '[immerable]: true'. Got '${e}'`},`This object has been frozen and should not be mutated`,function(e){return`Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? `+e},`An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.`,`Immer forbids circular references`,"The first or second argument to `produce` must be a function","The third argument to `produce` must be a function or undefined","First argument to `createDraft` must be a plain object, an array, or an immerable object","First argument to `finishDraft` must be a draft returned by `createDraft`",function(e){return`'current' expects a draft, got: ${e}`},`Object.defineProperty() cannot be used on an Immer draft`,`Object.setPrototypeOf() cannot be used on an Immer draft`,`Immer only supports deleting array indices`,`Immer only supports setting array indices and the 'length' property`,function(e){return`'original' expects a draft, got: ${e}`}];function b(e,...t){{let n=y[e],r=j(n)?n.apply(null,t):n;throw Error(`[Immer] ${r}`)}}var x=Object,S=x.getPrototypeOf,C=`constructor`,w=`prototype`,ee=`configurable`,te=`enumerable`,ne=`writable`,re=`value`,T=e=>!!e&&!!e[v];function E(e){return e?oe(e)||ue(e)||!!e[_]||!!e[C]?.[_]||de(e)||fe(e):!1}var ie=x[w][C].toString(),ae=new WeakMap;function oe(e){if(!e||!A(e))return!1;let t=S(e);if(t===null||t===x[w])return!0;let n=x.hasOwnProperty.call(t,C)&&t[C];if(n===Object)return!0;if(!j(n))return!1;let r=ae.get(n);return r===void 0&&(r=Function.toString.call(n),ae.set(n,r)),r===ie}function se(e,t,n=!0){D(e)===0?(n?Reflect.ownKeys(e):x.keys(e)).forEach(n=>{t(n,e[n],e)}):e.forEach((n,r)=>t(r,n,e))}function D(e){let t=e[v];return t?t.type_:ue(e)?1:de(e)?2:fe(e)?3:0}var O=(e,t,n=D(e))=>n===2?e.has(t):x[w].hasOwnProperty.call(e,t),k=(e,t,n=D(e))=>n===2?e.get(t):e[t],ce=(e,t,n,r=D(e))=>{r===2?e.set(t,n):r===3?e.add(n):e[t]=n};function le(e,t){return e===t?e!==0||1/e==1/t:e!==e&&t!==t}var ue=Array.isArray,de=e=>e instanceof Map,fe=e=>e instanceof Set,A=e=>typeof e==`object`,j=e=>typeof e==`function`,pe=e=>typeof e==`boolean`;function me(e){let t=+e;return Number.isInteger(t)&&String(t)===e}var he=e=>A(e)?e?.[v]:null,M=e=>e.copy_||e.base_,ge=e=>e.modified_?e.copy_:e.base_;function _e(e,t){if(de(e))return new Map(e);if(fe(e))return new Set(e);if(ue(e))return Array[w].slice.call(e);let n=oe(e);if(t===!0||t===`class_only`&&!n){let t=x.getOwnPropertyDescriptors(e);delete t[v];let n=Reflect.ownKeys(t);for(let r=0;r<n.length;r++){let i=n[r],a=t[i];a[ne]===!1&&(a[ne]=!0,a[ee]=!0),(a.get||a.set)&&(t[i]={[ee]:!0,[ne]:!0,[te]:a[te],[re]:e[i]})}return x.create(S(e),t)}else{let t=S(e);if(t!==null&&n)return{...e};let r=x.create(t);return x.assign(r,e)}}function ve(e,t=!1){return xe(e)||T(e)||!E(e)?e:(D(e)>1&&x.defineProperties(e,{set:be,add:be,clear:be,delete:be}),x.freeze(e),t&&se(e,(e,t)=>{ve(t,!0)},!1),e)}function ye(){b(2)}var be={[re]:ye};function xe(e){return e===null||!A(e)||x.isFrozen(e)}var Se=`MapSet`,Ce=`Patches`,we=`ArrayMethods`,Te={};function N(e){let t=Te[e];return t||b(0,e),t}var Ee=e=>!!Te[e];function De(e,t){Te[e]||(Te[e]=t)}var P,Oe=()=>P,ke=(e,t)=>({drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0,handledSet_:new Set,processedForPatches_:new Set,mapSetPlugin_:Ee(Se)?N(Se):void 0,arrayMethodsPlugin_:Ee(we)?N(we):void 0});function Ae(e,t){t&&(e.patchPlugin_=N(Ce),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function je(e){Me(e),e.drafts_.forEach(Pe),e.drafts_=null}function Me(e){e===P&&(P=e.parent_)}var Ne=e=>P=ke(P,e);function Pe(e){let t=e[v];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function Fe(e,t){t.unfinalizedDrafts_=t.drafts_.length;let n=t.drafts_[0];if(e!==void 0&&e!==n){n[v].modified_&&(je(t),b(4)),E(e)&&(e=Ie(t,e));let{patchPlugin_:r}=t;r&&r.generateReplacementPatches_(n[v].base_,e,t)}else e=Ie(t,n);return Le(t,e,!0),je(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e===g?void 0:e}function Ie(e,t){if(xe(t))return t;let n=t[v];if(!n)return Ge(t,e.handledSet_,e);if(!ze(n,e))return t;if(!n.modified_)return n.base_;if(!n.finalized_){let{callbacks_:t}=n;if(t)for(;t.length>0;)t.pop()(e);Ue(n,e)}return n.copy_}function Le(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&ve(t,n)}function Re(e){e.finalized_=!0,e.scope_.unfinalizedDrafts_--}var ze=(e,t)=>e.scope_===t,Be=[];function Ve(e,t,n,r){let i=M(e),a=e.type_;if(r!==void 0&&k(i,r,a)===t){ce(i,r,n,a);return}if(!e.draftLocations_){let t=e.draftLocations_=new Map;se(i,(e,n)=>{if(T(n)){let r=t.get(n)||[];r.push(e),t.set(n,r)}})}let o=e.draftLocations_.get(t)??Be;for(let e of o)ce(i,e,n,a)}function He(e,t,n){e.callbacks_.push(function(r){let i=t;if(!i||!ze(i,r))return;r.mapSetPlugin_?.fixSetContents(i);let a=ge(i);Ve(e,i.draft_??i,a,n),Ue(i,r)})}function Ue(e,t){if(e.modified_&&!e.finalized_&&(e.type_===3||e.type_===1&&e.allIndicesReassigned_||(e.assigned_?.size??0)>0)){let{patchPlugin_:n}=t;if(n){let r=n.getPath(e);r&&n.generatePatches_(e,r,t)}Re(e)}}function We(e,t,n){let{scope_:r}=e;if(T(n)){let i=n[v];ze(i,r)&&i.callbacks_.push(function(){$e(e),Ve(e,n,ge(i),t)})}else E(n)&&e.callbacks_.push(function(){let i=M(e);e.type_===3?i.has(n)&&Ge(n,r.handledSet_,r):k(i,t,e.type_)===n&&r.drafts_.length>1&&(e.assigned_.get(t)??!1)===!0&&e.copy_&&Ge(k(e.copy_,t,e.type_),r.handledSet_,r)})}function Ge(e,t,n){return!n.immer_.autoFreeze_&&n.unfinalizedDrafts_<1||T(e)||t.has(e)||!E(e)||xe(e)?e:(t.add(e),se(e,(r,i)=>{if(T(i)){let t=i[v];ze(t,n)&&(ce(e,r,ge(t),e.type_),Re(t))}else E(i)&&Ge(i,t,n)}),e)}function Ke(e,t){let n=ue(e),r={type_:+!!n,scope_:t?t.scope_:Oe(),modified_:!1,finalized_:!1,assigned_:void 0,parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1,callbacks_:void 0},i=r,a=qe;n&&(i=[r],a=F);let{revoke:o,proxy:s}=Proxy.revocable(i,a);return r.draft_=s,r.revoke_=o,[s,r]}var qe={get(e,t){if(t===v)return e;let n=e.scope_.arrayMethodsPlugin_,r=e.type_===1&&typeof t==`string`;if(r&&n?.isArrayOperationMethod(t))return n.createMethodInterceptor(e,t);let i=M(e);if(!O(i,t,e.type_))return Xe(e,i,t);let a=i[t];if(e.finalized_||!E(a)||r&&e.operationMethod&&n?.isMutatingArrayMethod(e.operationMethod)&&me(t))return a;if(a===Je(e.base_,t)||Ye(e,t,a)){$e(e);let n=e.type_===1?+t:t,r=tt(e.scope_,a,e,n);return e.copy_[n]=r}return a},has(e,t){return t in M(e)},ownKeys(e){return Reflect.ownKeys(M(e))},set(e,t,n){let r=Ze(M(e),t);if(r?.set)return r.set.call(e.draft_,n),!0;if(!e.modified_){let r=Je(M(e),t),i=r?.[v];if(i&&i.base_===n)return e.copy_[t]=n,e.assigned_.set(t,!1),!0;if(le(n,r)&&(n!==void 0||O(e.base_,t,e.type_)))return!0;$e(e),Qe(e)}return e.copy_[t]===n&&(n!==void 0||O(e.copy_,t,e.type_))||Number.isNaN(n)&&Number.isNaN(e.copy_[t])?!0:(e.copy_[t]=n,e.assigned_.set(t,!0),We(e,t,n),!0)},deleteProperty(e,t){return $e(e),Je(e.base_,t)!==void 0||t in e.base_?(e.assigned_.set(t,!1),Qe(e)):e.assigned_.delete(t),e.copy_&&delete e.copy_[t],!0},getOwnPropertyDescriptor(e,t){let n=M(e),r=Reflect.getOwnPropertyDescriptor(n,t);return r&&{[ne]:!0,[ee]:e.type_!==1||t!==`length`,[te]:r[te],[re]:n[t]}},defineProperty(){b(11)},getPrototypeOf(e){return S(e.base_)},setPrototypeOf(){b(12)}},F={};for(let e in qe){let t=qe[e];F[e]=function(){let e=arguments;return e[0]=e[0][0],t.apply(this,e)}}F.deleteProperty=function(e,t){return isNaN(parseInt(t))&&b(13),F.set.call(this,e,t,void 0)},F.set=function(e,t,n){return t!==`length`&&isNaN(parseInt(t))&&b(14),qe.set.call(this,e[0],t,n,e[0])};function Je(e,t){let n=e[v];return(n?M(n):e)[t]}function Ye(e,t,n){return e.type_!==1||!e.allIndicesReassigned_||e.assigned_?.get(t)||!E(n)||n[v]?!1:e.baseRefs_.has(n)}function Xe(e,t,n){let r=Ze(t,n);return r?re in r?r[re]:r.get?.call(e.draft_):void 0}function Ze(e,t){if(!(t in e))return;let n=S(e);for(;n;){let e=Object.getOwnPropertyDescriptor(n,t);if(e)return e;n=S(n)}}function Qe(e){e.modified_||(e.modified_=!0,e.parent_&&Qe(e.parent_))}function $e(e){e.copy_||=(e.assigned_=new Map,_e(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var et=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!1,this.produce=(e,t,n)=>{if(j(e)&&!j(t)){let n=t;t=e;let r=this;return function(e=n,...i){return r.produce(e,e=>t.call(this,e,...i))}}j(t)||b(6),n!==void 0&&!j(n)&&b(7);let r;if(E(e)){let i=Ne(this),a=tt(i,e,void 0),o=!0;try{r=t(a),o=!1}finally{o?je(i):Me(i)}return Ae(i,n),Fe(r,i)}else if(!e||!A(e)){if(r=t(e),r===void 0&&(r=e),r===g&&(r=void 0),this.autoFreeze_&&ve(r,!0),n){let t=[],i=[];N(Ce).generateReplacementPatches_(e,r,{patches_:t,inversePatches_:i}),n(t,i)}return r}else b(1,e)},this.produceWithPatches=(e,t)=>{if(j(e))return(t,...n)=>this.produceWithPatches(t,t=>e(t,...n));let n,r;return[this.produce(e,t,(e,t)=>{n=e,r=t}),n,r]},pe(e?.autoFreeze)&&this.setAutoFreeze(e.autoFreeze),pe(e?.useStrictShallowCopy)&&this.setUseStrictShallowCopy(e.useStrictShallowCopy),pe(e?.useStrictIteration)&&this.setUseStrictIteration(e.useStrictIteration)}createDraft(e){E(e)||b(8),T(e)&&(e=nt(e));let t=Ne(this),n=tt(t,e,void 0);return n[v].isManual_=!0,Me(t),n}finishDraft(e,t){let n=e&&e[v];(!n||!n.isManual_)&&b(9);let{scope_:r}=n;return Ae(r,t),Fe(void 0,r)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}setUseStrictIteration(e){this.useStrictIteration_=e}shouldUseStrictIteration(){return this.useStrictIteration_}applyPatches(e,t){let n;for(n=t.length-1;n>=0;n--){let r=t[n];if(r.path.length===0&&r.op===`replace`){e=r.value;break}}n>-1&&(t=t.slice(n+1));let r=N(Ce).applyPatches_;return T(e)?r(e,t):this.produce(e,e=>r(e,t))}};function tt(e,t,n,r){let[i,a]=de(t)?N(Se).proxyMap_(t,n):fe(t)?N(Se).proxySet_(t,n):Ke(t,n);return(n?.scope_??Oe()).drafts_.push(i),a.callbacks_=n?.callbacks_??[],a.key_=r,n&&r!==void 0?He(n,a,r):a.callbacks_.push(function(e){e.mapSetPlugin_?.fixSetContents(a);let{patchPlugin_:t}=e;a.modified_&&t&&t.generatePatches_(a,[],e)}),i}function nt(e){return T(e)||b(10,e),rt(e)}function rt(e){if(!E(e)||xe(e))return e;let t=e[v],n,r=!0;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=_e(e,t.scope_.immer_.useStrictShallowCopy_),r=t.scope_.immer_.shouldUseStrictIteration()}else n=_e(e,!0);return se(n,(e,t)=>{ce(n,e,rt(t))},r),t&&(t.finalized_=!1),n}function it(){y.push(`Sets cannot have "replace" patches.`,function(e){return`Unsupported patch operation: `+e},function(e){return`Cannot apply patch, path doesn't resolve: `+e},`Patching reserved attributes like __proto__, prototype and constructor is not allowed`);function e(n,r=[]){if(n.key_!==void 0){let e=n.parent_.copy_??n.parent_.base_,t=he(k(e,n.key_)),i=k(e,n.key_);if(i===void 0||i!==n.draft_&&i!==n.base_&&i!==n.copy_||t!=null&&t.base_!==n.base_)return null;let a=n.parent_.type_===3,o;if(a){let e=n.parent_;o=Array.from(e.drafts_.keys()).indexOf(n.key_)}else o=n.key_;if(!(a&&e.size>o||O(e,o)))return null;r.push(o)}if(n.parent_)return e(n.parent_,r);r.reverse();try{t(n.copy_,r)}catch{return null}return r}function t(e,t){let n=e;for(let e=0;e<t.length-1;e++){let r=t[e];if(n=k(n,r),!A(n)||n===null)throw Error(`Cannot resolve path at '${t.join(`/`)}'`)}return n}let n=`replace`,r=`remove`;function i(e,t,n){if(e.scope_.processedForPatches_.has(e))return;e.scope_.processedForPatches_.add(e);let{patches_:r,inversePatches_:i}=n;switch(e.type_){case 0:case 2:return o(e,t,r,i);case 1:return a(e,t,r,i);case 3:return s(e,t,r,i)}}function a(e,t,i,a){let{base_:o,assigned_:s}=e,c=e.copy_;c.length<o.length&&([o,c]=[c,o],[i,a]=[a,i]);let l=e.allIndicesReassigned_===!0;for(let e=0;e<o.length;e++){let r=c[e],u=o[e];if((l||s?.get(e.toString()))&&r!==u){let o=r?.[v];if(o&&o.modified_)continue;let s=t.concat([e]);i.push({op:n,path:s,value:d(r)}),a.push({op:n,path:s,value:d(u)})}}for(let e=o.length;e<c.length;e++){let n=t.concat([e]);i.push({op:`add`,path:n,value:d(c[e])})}for(let e=c.length-1;o.length<=e;--e){let n=t.concat([e]);a.push({op:r,path:n})}}function o(e,t,i,a){let{base_:o,copy_:s,type_:c}=e;se(e.assigned_,(e,l)=>{let u=k(o,e,c),f=k(s,e,c),p=l?O(o,e)?n:`add`:r;if(u===f&&p===n)return;let m=t.concat(e);i.push(p===r?{op:p,path:m}:{op:p,path:m,value:d(f)}),a.push(p===`add`?{op:r,path:m}:p===r?{op:`add`,path:m,value:d(u)}:{op:n,path:m,value:d(u)})})}function s(e,t,n,i){let{base_:a,copy_:o}=e,s=0;a.forEach(e=>{if(!o.has(e)){let a=t.concat([s]);n.push({op:r,path:a,value:e}),i.unshift({op:`add`,path:a,value:e})}s++}),s=0,o.forEach(e=>{if(!a.has(e)){let a=t.concat([s]);n.push({op:`add`,path:a,value:e}),i.unshift({op:r,path:a,value:e})}s++})}function c(e,t,r){let{patches_:i,inversePatches_:a}=r;i.push({op:n,path:[],value:t===g?void 0:t}),a.push({op:n,path:[],value:e})}function l(e,t){return t.forEach(t=>{let{path:i,op:a}=t,o=e;for(let e=0;e<i.length-1;e++){let t=D(o),n=i[e];typeof n!=`string`&&typeof n!=`number`&&(n=``+n),(t===0||t===1)&&(n===`__proto__`||n===C)&&b(19),j(o)&&n===w&&b(19),o=k(o,n),(o===null||!A(o))&&b(18,i.join(`/`))}let s=D(o),c=u(t.value),l=i[i.length-1];switch(a){case n:switch(s){case 2:return o.set(l,c);case 3:b(16);default:return o[l]=c}case`add`:switch(s){case 1:return l===`-`?o.push(c):o.splice(l,0,c);case 2:return o.set(l,c);case 3:return o.add(c);default:return o[l]=c}case r:switch(s){case 1:return o.splice(l,1);case 2:return o.delete(l);case 3:return o.delete(t.value);default:return delete o[l]}default:b(17,a)}}),e}function u(e){if(!E(e))return e;if(ue(e))return e.map(u);if(de(e))return new Map(Array.from(e.entries()).map(([e,t])=>[e,u(t)]));if(fe(e))return new Set(Array.from(e).map(u));let t=Object.create(S(e));for(let n in e)t[n]=u(e[n]);return O(e,_)&&(t[_]=e[_]),t}function d(e){return T(e)?u(e):e}De(Ce,{applyPatches_:l,generatePatches_:i,generateReplacementPatches_:c,getPath:e})}var at=new et,ot=at.produce,st=at.produceWithPatches.bind(at),ct=at.applyPatches.bind(at),lt=1e3;function ut(e,t){if(e.add(t),e.size>lt){let t=e.values().next().value;t!==void 0&&e.delete(t)}}function dt(e){let{enablePatches:t=!1}=e;t&&it();let n=p(),r=e.initialValue,i=new Set;return{on:n.on,value:()=>r,patch:(e,t=h())=>{i.has(t)||(it(),r=ct(r,e),ut(i,t),n.emit(`updated`,r,void 0,t))},mutate:(e,a=h())=>{if(!i.has(a))if(ut(i,a),t){let[t,i]=st(r,e);r=t,n.emit(`updated`,r,i,a)}else r=ot(r,e),n.emit(`updated`,r,void 0,a)},syncIds:i}}var ft=typeof self==`object`?self:globalThis;function pt(e,t){let n=(t,n)=>(e.set(n,t),t),r=i=>{if(e.has(i))return e.get(i);let[a,o]=t[i];switch(a){case 0:case-1:return n(o,i);case 1:{let e=n([],i);for(let t of o)e.push(r(t));return e}case 2:{let e=n({},i);for(let[t,n]of o)e[r(t)]=r(n);return e}case 3:return n(new Date(o),i);case 4:{let{source:e,flags:t}=o;return n(new RegExp(e,t),i)}case 5:{let e=n(new Map,i);for(let[t,n]of o)e.set(r(t),r(n));return e}case 6:{let e=n(new Set,i);for(let t of o)e.add(r(t));return e}case 7:{let{name:e,message:t}=o;return n(new ft[e](t),i)}case 8:return n(BigInt(o),i);case`BigInt`:return n(Object(BigInt(o)),i);case`ArrayBuffer`:return n(new Uint8Array(o).buffer,o);case`DataView`:{let{buffer:e}=new Uint8Array(o);return n(new DataView(e),o)}}return n(new ft[a](o),i)};return r}function mt(e){return pt(new Map,e)(0)}var I=``,{toString:ht}={},{keys:gt}=Object;function _t(e){let t=typeof e;if(t!==`object`||!e)return[0,t];let n=ht.call(e).slice(8,-1);switch(n){case`Array`:return[1,I];case`Object`:return[2,I];case`Date`:return[3,I];case`RegExp`:return[4,I];case`Map`:return[5,I];case`Set`:return[6,I];case`DataView`:return[1,n]}return n.includes(`Array`)?[1,n]:n.includes(`Error`)?[7,n]:[2,n]}function vt([e,t]){return e===0&&(t===`function`||t===`symbol`)}function yt(e,t,n,r){let i=(e,t)=>{let i=r.push(e)-1;return n.set(t,i),i},a=r=>{if(n.has(r))return n.get(r);let[o,s]=_t(r);switch(o){case 0:{let t=r;switch(s){case`bigint`:o=8,t=r.toString();break;case`function`:case`symbol`:if(e)throw TypeError(`unable to serialize ${s}`);t=null;break;case`undefined`:return i([-1],r)}return i([o,t],r)}case 1:{if(s){let e=r;return s===`DataView`?e=new Uint8Array(r.buffer):s===`ArrayBuffer`&&(e=new Uint8Array(r)),i([s,[...e]],r)}let e=[],t=i([o,e],r);for(let t of r)e.push(a(t));return t}case 2:{if(s)switch(s){case`BigInt`:return i([s,r.toString()],r);case`Boolean`:case`Number`:case`String`:return i([s,r.valueOf()],r)}if(t&&`toJSON`in r)return a(r.toJSON());let n=[],c=i([o,n],r);for(let t of gt(r))(e||!vt(_t(r[t])))&&n.push([a(t),a(r[t])]);return c}case 3:return i([o,r.toISOString()],r);case 4:{let{source:e,flags:t}=r;return i([o,{source:e,flags:t}],r)}case 5:{let t=[],n=i([o,t],r);for(let[n,i]of r)(e||!(vt(_t(n))||vt(_t(i))))&&t.push([a(n),a(i)]);return n}case 6:{let t=[],n=i([o,t],r);for(let n of r)(e||!vt(_t(n)))&&t.push(a(n));return n}}let{message:c}=r;return i([o,{name:s,message:c}],r)};return a}function bt(e,t={}){let n=[];return yt(!(t.json||t.lossy),!!t.json,new Map,n)(e),n}var{parse:xt,stringify:St}=JSON,Ct={json:!0,lossy:!0};function wt(e){return mt(xt(e))}function Tt(e){return St(bt(e,Ct))}function Et(e){return mt(e)}function Dt(e){return Tt(e)}function Ot(e){return wt(e)}var kt=256,At=class extends Error{name=`StreamClosedError`};function jt(e={}){let t=e.id??h(),n=Math.max(0,e.replayWindow??0),r=p(),i=new AbortController,a=[],o=!1,s=0;function c(e){if(o)throw new At(`Cannot write to a closed stream "${t}"`);s+=1,n>0&&(a.push({seq:s,chunk:e}),a.length>n&&a.splice(0,a.length-n)),r.emit(`chunk`,s,e)}function l(e){if(o)return;o=!0;let t=Nt(e);i.abort(e),r.emit(`end`,t)}function u(){o||(o=!0,i.signal.aborted||i.abort(`stream closed`),r.emit(`end`,void 0))}function d(e){o||i.signal.aborted||i.abort(e??`aborted`)}let f=new WritableStream({write(e){c(e)},close(){u()},abort(e){l(e)}});return{id:t,signal:i.signal,get closed(){return o},get lastSeq(){return s},write:c,error:l,close:u,abort:d,writable:f,events:r,buffer:a}}function Mt(e={}){let t=e.id??h(),n=Math.max(1,e.highWaterMark??kt),r=[],i=0,a=!1,o=!1,s,c,l,u;function d(){if(c){if(r.length>0){let e=r.shift(),t=c;c=void 0,t.resolve({value:e,done:!1});return}if(a){let e=c;if(c=void 0,s){let t=Error(s.message);t.name=s.name,e.reject(t)}else e.resolve({value:void 0,done:!0})}}}function f(){if(l){for(;r.length>0;){let e=r.shift();try{l.enqueue(e)}catch{break}}if(a&&l){try{if(s){let e=Error(s.message);e.name=s.name,l.error(e)}else l.close()}catch{}l=void 0}}}function p(t,s){if(!(a||o)&&!(t<=i)){if(i=t,r.push(s),r.length>n){let t=r.length-n;r.splice(0,t),e.onOverflow?.(t)}d(),u&&f()}}function m(e){a||(a=!0,s=e,d(),u&&f())}function g(){o||a||(o=!0,e.onCancel?.(),m(void 0))}function _(){return u||(u=new ReadableStream({start(e){l=e,f()},cancel(){g()}}),u)}return{id:t,get cancelled(){return o},get done(){return a},get lastSeenSeq(){return i},get readable(){return _()},cancel:g,_push:p,_end:m,[Symbol.asyncIterator](){return{next(){if(r.length>0)return Promise.resolve({value:r.shift(),done:!1});if(a){if(s){let e=Error(s.message);return e.name=s.name,Promise.reject(e)}return Promise.resolve({value:void 0,done:!0})}return new Promise((e,t)=>{c={resolve:e,reject:t}})},return(){return g(),Promise.resolve({value:void 0,done:!0})}}}}}function Nt(e){if(e instanceof Error)return{name:e.name||`Error`,message:e.message};if(typeof e==`string`)return{name:`Error`,message:e};try{return{name:`Error`,message:JSON.stringify(e)}}catch{return{name:`Error`,message:String(e)}}}function Pt(){let e,t;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}}function Ft(e){return e.includes(`:`)}function L(e,t){return Ft(t)?t:`${e}:${t}`}function It(e,...t){return typeof e==`function`?e(...t):e}var Lt=Error.captureStackTrace,Rt=class e extends Error{name;code;docs;fix;sources;get why(){return this.message}constructor(t,n=e){super(t.why,{cause:t.cause}),this.code=this.name=t.code,this.fix=t.fix,this.docs=t.docs,this.sources=t.sources,Lt?.(this,n)}toJSON(){return{name:this.name,why:this.why,fix:this.fix,docs:this.docs,sources:this.sources,cause:this.cause,stack:this.stack}}};function zt(e,t){return typeof e==`string`?`${e}/${t.toLowerCase()}`:e?.(t)}function Bt(e){let t=e.reporters??[],n={},{docsBase:r}=e;for(let i of Object.keys(e.codes)){let a=e.codes[i],o=a.docs===!1?void 0:a.docs||zt(r,i),s=(e={},n={})=>{let r=new Rt({code:i,why:It(a.why,e),fix:It(a.fix,e),docs:o,cause:e.cause,sources:e.sources},s);for(let e of t)e(r,n);return r};n[i]=s}return n}function Vt(e){return t=>{let n=`${e.bold(e.red(`[${t.name}]`))} ${t.message}`,r=[];return t.fix&&r.push(`${e.dim(`fix:`)} ${t.fix}`),t.sources?.length&&r.push(`${e.dim(`sources:`)} ${t.sources.join(`, `)}`),t.docs&&r.push(`${e.dim(`see:`)} ${e.cyan(t.docs)}`),r.length===0?n:[n,...r.map((t,n)=>`${e.dim(n<r.length-1?`├▶`:`╰▶`)} ${t}`)].join(`
2
+ `)}}String.fromCharCode;var Ht=/^[\s\w\0+.-]{2,}:([/\\]{1,2})/,Ut=/^[\s\w\0+.-]{2,}:([/\\]{2})?/,Wt=/^([/\\]\s*){2,}[^/\\]/,Gt=/\/$|\/\?|\/#/,Kt=/^\.?\//;function qt(e,t={}){return typeof t==`boolean`&&(t={acceptRelative:t}),t.strict?Ht.test(e):Ut.test(e)||(t.acceptRelative?Wt.test(e):!1)}function Jt(e=``,t){return t?Gt.test(e):e.endsWith(`/`)}function Yt(e=``,t){if(!t)return(Jt(e)?e.slice(0,-1):e)||`/`;if(!Jt(e,!0))return e||`/`;let n=e,r=``,i=e.indexOf(`#`);i!==-1&&(n=e.slice(0,i),r=e.slice(i));let[a,...o]=n.split(`?`);return((a.endsWith(`/`)?a.slice(0,-1):a)||`/`)+(o.length>0?`?${o.join(`?`)}`:``)+r}function Xt(e=``,t){if(!t)return e.endsWith(`/`)?e:e+`/`;if(Jt(e,!0))return e||`/`;let n=e,r=``,i=e.indexOf(`#`);if(i!==-1&&(n=e.slice(0,i),r=e.slice(i),!n))return r;let[a,...o]=n.split(`?`);return a+`/`+(o.length>0?`?${o.join(`?`)}`:``)+r}function Zt(e,t){if(Qt(t)||qt(e))return e;let n=Yt(t);if(e.startsWith(n)){let t=e[n.length];if(!t||t===`/`||t===`?`)return e}return en(n,e)}function Qt(e){return!e||e===`/`}function $t(e){return e&&e!==`/`}function en(e,...t){let n=e||``;for(let e of t.filter(e=>$t(e)))if(n){let t=e.replace(Kt,``);n=Xt(n)+t}else n=e;return n}function tn(e,t){let n=e.match(Ut);return n||=e.match(/^\/{2,}/),n?t+e.slice(n[0].length):t+e}var nn=`q`,rn=`s`;function an(){let e,t;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}}var on=Math.random.bind(Math),sn=`useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict`;function cn(e=21){let t=``,n=e;for(;n--;)t+=sn[on()*64|0];return t}var ln=6e4,un=e=>e,dn=un,{clearTimeout:fn,setTimeout:pn}=globalThis;function mn(e,t){let{post:n,on:r,off:i=()=>{},eventNames:a=[],serialize:o=un,deserialize:s=dn,resolver:c,bind:l=`rpc`,timeout:u=ln,proxify:d=!0}=t,f=!1,p=new Map,m,h;async function g(e,r,i,a){if(f)throw Error(`[birpc] rpc is closed, cannot call "${e}"`);let s={m:e,a:r,t:nn};a&&(s.o=!0);let c=async e=>n(o(e));if(i){await c(s);return}if(m)try{await m}finally{m=void 0}let{promise:l,resolve:d,reject:g}=an(),_=cn();s.i=_;let v;async function y(n=s){return u>=0&&(v=pn(()=>{try{if(t.onTimeoutError?.call(h,e,r)!==!0)throw Error(`[birpc] timeout on calling "${e}"`)}catch(e){g(e)}p.delete(_)},u),typeof v==`object`&&(v=v.unref?.())),p.set(_,{resolve:d,reject:g,timeoutId:v,method:e}),await c(n),l}try{t.onRequest?await t.onRequest.call(h,s,y,d):await y()}catch(e){if(t.onGeneralError?.call(h,e)!==!0)throw e;return}finally{fn(v),p.delete(_)}return l}let _={$call:(e,...t)=>g(e,t,!1),$callOptional:(e,...t)=>g(e,t,!1,!0),$callEvent:(e,...t)=>g(e,t,!0),$callRaw:e=>g(e.method,e.args,e.event,e.optional),$rejectPendingCalls:y,get $closed(){return f},get $meta(){return t.meta},$close:v,$functions:e};h=d?new Proxy({},{get(t,n){if(Object.prototype.hasOwnProperty.call(_,n))return _[n];if(n===`then`&&!a.includes(`then`)&&!(`then`in e))return;let r=(...e)=>g(n,e,!0);if(a.includes(n))return r.asEvent=r,r;let i=(...e)=>g(n,e,!1);return i.asEvent=r,i}}):_;function v(e){f=!0,p.forEach(({reject:t,method:n})=>{let r=Error(`[birpc] rpc is closed, cannot call "${n}"`);if(e)return e.cause??=r,t(e);t(r)}),p.clear(),i(b)}function y(e){let t=Array.from(p.values()).map(({method:t,reject:n})=>e?e({method:t,reject:n}):n(Error(`[birpc]: rejected pending call "${t}".`)));return p.clear(),t}async function b(r,...i){let a;try{a=s(r)}catch(e){if(t.onGeneralError?.call(h,e)!==!0)throw e;return}if(a.t===nn){let{m:r,a:s,o:u}=a,d,f,p=await(c?c.call(h,r,e[r]):e[r]);if(u&&(p||=()=>void 0),!p)f=Error(`[birpc] function "${r}" not found`);else try{d=await p.apply(l===`rpc`?h:e,s)}catch(e){f=e}if(a.i){if(f&&t.onFunctionError&&t.onFunctionError.call(h,f,r,s)===!0)return;if(!f)try{await n(o({t:rn,i:a.i,r:d}),...i);return}catch(e){if(f=e,t.onGeneralError?.call(h,e,r,s)!==!0)throw e}try{await n(o({t:rn,i:a.i,e:f}),...i)}catch(e){if(t.onGeneralError?.call(h,e,r,s)!==!0)throw e}}}else{let{i:e,r:t,e:n}=a,r=p.get(e);r&&(fn(r.timeoutId),n?r.reject(n):r.resolve(t)),p.delete(e)}}return m=r(b),h}var hn=`__connection.json`,gn=`__rpc-dump/index.json`,_n=`devframe_otp`,vn=`devframe_auth_token`,yn=Vt(f);function bn(e,{method:t=`warn`}={}){console[t](yn(e))}var R=Bt({docsBase:`https://devfra.me/errors`,reporters:[bn],codes:{DF0019:{why:e=>`RPC function "${e.name}" has \`agent\` set but \`jsonSerializable\` is not \`true\` — MCP requires JSON-serializable data.`,fix:"Set `jsonSerializable: true` if the payload is JSON-safe, or remove `agent` to keep it RPC-only."},DF0020:{why:e=>`RPC function "${e.name}" declares \`jsonSerializable: true\` but the value at "${e.path}" is a ${e.type}.`,fix:"Either drop `jsonSerializable: true` (falls back to structured-clone) or change the value to a JSON-safe shape."},DF0021:{why:e=>`RPC function "${e.name}" is already registered`,fix:"Use the `force` parameter to overwrite an existing registration."},DF0022:{why:e=>`RPC function "${e.name}" is not registered. Use register() to add new functions.`},DF0023:{why:e=>`RPC function "${e.name}" is not registered`},DF0024:{why:e=>`Either handler or setup function must be provided for RPC function "${e.name}"`},DF0025:{why:e=>`Function "${e.name}" not found in dump store`},DF0026:{why:e=>`No dump match for "${e.name}" with args: ${e.args}`},DF0027:{why:e=>`Function "${e.name}" with type "${e.type}" cannot have dump configuration. Only "static" and "query" types support dumps.`},DF0028:{why:e=>`Function "${e.name}" with type "${e.type}" cannot use \`snapshot: true\`. Only "query" functions support this sugar; "static" functions have equivalent default behavior already.`,fix:"Remove `snapshot: true`, or change the function type to `query`."}}});function xn(e){let t=e.cause instanceof Error?e.cause:Sn(e.cause)?xn(e.cause):e.cause,n=t===void 0?Error(e.message):Error(e.message,{cause:t});n.name=e.name;for(let t of Object.keys(e))t===`name`||t===`message`||t===`cause`||(n[t]=e[t]);return n}function Sn(e){return typeof e==`object`&&!!e&&typeof e.message==`string`&&typeof e.name==`string`}async function Cn(e,t){if(!e.setup)return{};if(typeof t==`object`&&t){e.__cache??=new WeakMap;let n=e.__cache,r=n.get(t);return r||(r=Promise.resolve(e.setup(t)),r.catch(()=>{n.get(t)===r&&n.delete(t)}),n.set(t,r)),await r}if(!e.__promise){let n=Promise.resolve(e.setup(t));n.catch(()=>{e.__promise===n&&(e.__promise=void 0)}),e.__promise=n}return await e.__promise}async function wn(e,t){if(e.handler)return e.handler;let n=await Cn(e,t);if(!n.handler)throw R.DF0024({name:e.name});return n.handler}var Tn=class{cacheMap=new Map;options;keySerializer;constructor(e){this.options=e,this.keySerializer=e.keySerializer||(e=>u(e))}updateOptions(e){this.options={...this.options,...e}}cached(e,t){let n=this.cacheMap.get(e);if(n)return n.get(this.keySerializer(t))}has(e,t){return this.cacheMap.get(e)?.has(this.keySerializer(t))??!1}apply(e,t){let n=this.cacheMap.get(e.m)||new Map;n.set(this.keySerializer(e.a),t),this.cacheMap.set(e.m,n)}validate(e){return this.options.functions.includes(e)}clear(e){e?this.cacheMap.delete(e):this.cacheMap.clear()}},En=class{context;definitions=new Map;functions;_onChanged=[];constructor(e){this.context=e;let t=this.definitions,n=this;this.functions=new Proxy({},{get(e,r){let i=t.get(r);if(i)return wn(i,n.context)},has(e,n){return t.has(n)},getOwnPropertyDescriptor(e,n){return{value:t.get(n)?.handler,configurable:!0,enumerable:!0}},ownKeys(){return Array.from(t.keys())}})}register(e,t=!1){if(this.definitions.has(e.name)&&!t)throw R.DF0021({name:e.name});Dn(e),this.definitions.set(e.name,e),this._onChanged.forEach(t=>t(e.name))}update(e,t=!1){if(!this.definitions.has(e.name)&&!t)throw R.DF0022({name:e.name});Dn(e),this.definitions.set(e.name,e),this._onChanged.forEach(t=>t(e.name))}onChanged(e){return this._onChanged.push(e),()=>{let t=this._onChanged.indexOf(e);t!==-1&&this._onChanged.splice(t,1)}}async getHandler(e){return await wn(this.definitions.get(e),this.context)}getSchema(e){let t=this.definitions.get(e);if(!t)throw R.DF0023({name:String(e)});return{args:t.args,returns:t.returns}}has(e){return this.definitions.has(e)}get(e){return this.definitions.get(e)}list(){return Array.from(this.definitions.keys())}};function Dn(e){if(e.agent&&e.jsonSerializable!==!0)throw R.DF0019({name:e.name})}function On(e,t=``){return JSON.stringify(e,function(e,n){let r=this,i=r==null?n:r[e];if(i===void 0){if(Array.isArray(r))throw z(t,`undefined`,r,e);return n}if(i===null)return n;if(typeof i==`bigint`)throw z(t,`BigInt`,r,e);if(typeof i==`object`){if(i instanceof Map)throw z(t,`Map`,r,e);if(i instanceof Set)throw z(t,`Set`,r,e);if(i instanceof Date)throw z(t,`Date`,r,e);if(Array.isArray(i))return n;let a=Object.getPrototypeOf(i);if(a!==null&&a!==Object.prototype)throw z(t,i.constructor?.name??`class instance`,r,e)}return n})}function z(e,t,n,r){let i=kn(n,r);return R.DF0020({name:e||`<anonymous>`,type:t,path:i})}function kn(e,t){return Array.isArray(e)?`[${t}]`:t===``?`<root>`:t}function An(e=_n){try{return new URLSearchParams(globalThis.location?.search).get(e)||void 0}catch{return}}function jn(e){try{let t=new URL(globalThis.location.href);if(!t.searchParams.has(e))return;t.searchParams.delete(e),globalThis.history?.replaceState(globalThis.history.state,``,t.href)}catch{}}function Mn(e=_n){let t=An(e);return t&&jn(e),t}async function Nn(e,t={}){let n=Mn(t.param??`devframe_otp`);return n?e.isTrusted?!0:e.requestTrustWithCode(n):!1}function Pn(e){let t=new Map,n=new Map,r=new Map,i=new Set,a=e.connectionMeta.backend===`static`;function o(e,t){let n=r.get(e);return n&&typeof n==`object`&&!Array.isArray(n)&&typeof t==`object`&&!Array.isArray(t)?{...n,...t}:t}e.client.register({name:`devframe:rpc:client-state:updated`,type:`event`,handler:(e,n,r)=>{let i=t.get(e);!i||i.syncIds.has(r)||i.mutate(()=>o(e,n),r)}}),e.client.register({name:`devframe:rpc:client-state:patch`,type:`event`,handler:(e,n,r)=>{let i=t.get(e);!i||i.syncIds.has(r)||i.patch(n,r)}});function s(t,n){let r=[];return r.push(n.on(`updated`,(n,r,i)=>{a||(r?e.callEvent(`devframe:rpc:server-state:patch`,t,r,i):e.callEvent(`devframe:rpc:server-state:set`,t,n,i))})),()=>{for(let e of r)e()}}return{keys:()=>Array.from(t.keys()),onKeyAdded(e){return i.add(e),()=>{i.delete(e)}},delete(e){let i=n.get(e);n.delete(e);let a=t.delete(e);return r.delete(e),i?.(),a},get:async(c,l)=>{if(l?.initialValue!==void 0&&r.set(c,l.initialValue),t.has(c))return t.get(c);let u=dt({initialValue:l?.initialValue,enablePatches:!1});async function d(){if(a||e.callEvent(`devframe:rpc:server-state:subscribe`,c),l?.initialValue!==void 0){t.set(c,u);for(let e of i)e(c);return e.call(`devframe:rpc:server-state:get`,c).then(e=>{e!==void 0&&u.mutate(()=>o(c,e))}).catch(e=>{console.error(`Error getting server state`,e)}),n.set(c,s(c,u)),u}else{let r=await e.call(`devframe:rpc:server-state:get`,c);u.mutate(()=>o(c,r)),t.set(c,u);for(let e of i)e(c);return n.set(c,s(c,u)),u}}return new Promise(t=>{if(e.isTrusted)d().then(t);else{t(u);let n=!1;e.events.on(`rpc:is-trusted:updated`,e=>{e&&!n&&(n=!0,d())})}})}}}function Fn(e){return typeof e==`object`&&!!e&&e.type===`static`&&typeof e.path==`string`}function In(e){return typeof e==`object`&&!!e&&e.type===`query`&&typeof e.records==`object`&&e.records!==null}function Ln(e){return typeof e==`object`&&!!e&&(`output`in e||`error`in e)}function Rn(e){if(e.error)throw xn(e.error);return e.output}function zn(e){return e.some(e=>e!=null)}function Bn(e){return typeof e==`object`&&e&&`serialization`in e&&`data`in e?e.data:e}function Vn(e,t){let n=new Map,r=new Map;function i(e,t){return t===`structured-clone`&&Array.isArray(e)?Et(e):e}function a(e,t){return i(Bn(e),t)}async function o(e){n.has(e.path)||n.set(e.path,t(e.path).then(t=>a(t,e.serialization)));let r=await n.get(e.path);return Ln(r)?Rn(r):r}async function s(e,n){return r.has(e)||r.set(e,t(e).then(e=>a(e,n))),await r.get(e)}async function c(t,n){if(!(t in e))throw Error(`[devframe-rpc] Function "${t}" not found in dump store`);let r=e[t];if(Fn(r)){if(zn(n))throw Error(`[devframe-rpc] No dump match for "${t}" with args: ${JSON.stringify(n)}`);return await o(r)}if(In(r)){let e=u(n),i=r.records[e];if(i)return Rn(await s(i,r.serialization));if(r.fallback)return Rn(await s(r.fallback,r.serialization));throw Error(`[devframe-rpc] No dump match for "${t}" with args: ${JSON.stringify(n)}`)}if(!zn(n))return r;throw Error(`[devframe-rpc] No dump match for "${t}" with args: ${JSON.stringify(n)}`)}return{call:async(e,t)=>await c(e,t),callOptional:async(t,n)=>{if(t in e)return await c(t,n)},callEvent:async(e,t)=>{}}}async function Hn(e){let t=Vn(await e.fetchJsonFromBases(gn),e.fetchJsonFromBases);return{isTrusted:!0,status:`connected`,connectionError:null,requestTrust:async()=>!0,requestTrustWithToken:async()=>!0,requestTrustWithCode:async()=>null,ensureTrusted:async()=>!0,call:(...e)=>t.call(e[0],e.slice(1)),callEvent:(...e)=>t.callEvent(e[0],e.slice(1)),callOptional:(...e)=>t.callOptional(e[0],e.slice(1))}}var Un=``;function Wn(e,t){return`${e}${Un}${t}`}function Gn(e){let t=new Map,n=new Map;e.client.register({name:`devframe:streaming:chunk`,type:`event`,handler(e,n,r,i){t.get(Wn(e,n))?._push(r,i)}}),e.client.register({name:`devframe:streaming:end`,type:`event`,handler(e,n,r){let i=Wn(e,n),a=t.get(i);a&&(a._end(r),t.delete(i))}}),e.client.register({name:`devframe:streaming:upload-cancel`,type:`event`,handler(e,t){let r=Wn(e,t),i=n.get(r);i&&(i.abort(`server cancelled upload`),n.delete(r))}}),e.events.on(`rpc:is-trusted:updated`,n=>{if(n)for(let[n,r]of t){if(r.cancelled||r.done)continue;let t=n.indexOf(Un);if(t<0)continue;let i=n.slice(0,t),a=n.slice(t+1);e.callEvent(`devframe:streaming:subscribe`,i,a,{afterSeq:r.lastSeenSeq})}});function r(n,r,i={}){let a=Wn(n,r),o=t.get(a);if(o)return o;let s=Mt({id:r,highWaterMark:i.highWaterMark,onOverflow(e){console.warn(`[devframe] DF0029: Stream "${n}#${r}" dropped ${e} chunk(s) after exceeding the client high-water mark.`)},onCancel(){e.callEvent(`devframe:streaming:cancel`,n,r),t.delete(a)}});if(t.set(a,s),e.isTrusted)e.callEvent(`devframe:streaming:subscribe`,n,r,{afterSeq:0});else{let i=e.events.on(`rpc:is-trusted:updated`,o=>{o&&(i(),t.has(a)&&!s.cancelled&&!s.done&&e.callEvent(`devframe:streaming:subscribe`,n,r,{afterSeq:s.lastSeenSeq}))})}return s}function i(t,r){let i=Wn(t,r),a=n.get(i);if(a)return a;let o=jt({id:r});return o.events.on(`chunk`,(n,i)=>{e.callEvent(`devframe:streaming:upload-chunk`,t,r,n,i)}),o.events.on(`end`,a=>{e.callEvent(`devframe:streaming:upload-end`,t,r,a),n.delete(i)}),n.set(i,o),o}return{subscribe:r,upload:i}}function Kn(e,t){let{channel:n,rpcOptions:r={}}=t;return mn(e,{...n,timeout:-1,...r,proxify:!1})}function qn(){}var Jn=new Map;function Yn(e){let t=e.url;e.authToken&&(t=`${t}?${vn}=${encodeURIComponent(e.authToken)}`);let n=new WebSocket(t),{onConnected:r=qn,onError:i=qn,onDisconnected:a=qn,definitions:o=Jn}=e;n.addEventListener(`open`,e=>{r(e)}),n.addEventListener(`error`,e=>{let t=e instanceof Error?e:Error(e.type);i(t)}),n.addEventListener(`close`,e=>{a(e)});let s=new Map;return{on:e=>{n.addEventListener(`message`,t=>{e(t.data)})},post:e=>{if(n.readyState===WebSocket.OPEN){n.send(e);return}if(n.readyState===WebSocket.CONNECTING){let t=()=>{i(),n.readyState===WebSocket.OPEN&&n.send(e)},r=()=>i();function i(){n.removeEventListener(`open`,t),n.removeEventListener(`close`,r)}n.addEventListener(`open`,t),n.addEventListener(`close`,r);return}i(Error(`Devframe WebSocket is not open; message dropped`))},serialize:e=>{let t;return e.t===`q`?t=e.m:(t=s.get(e.i),s.delete(e.i)),!(e.t===`s`&&`e`in e)&&t&&o.get(t)?.jsonSerializable===!0?On(e,t??``):`s:${Dt(e)}`},deserialize:e=>{let t=e.startsWith(`s:`)?Ot(e.slice(2)):JSON.parse(e);return t.t===`q`&&t.i&&t.m&&s.set(t.i,t.m),t}}}var Xn=``,Zn=`?`,Qn=`major`,B=`model`,V=`name`,H=`type`,U=`vendor`,W=`version`,G=`architecture`,$n=`console`,K=`mobile`,q=`tablet`,J=`smarttv`,Y=`wearable`,er=`embedded`,tr=500,nr=`Amazon`,rr=`Apple`,ir=`ASUS`,ar=`BlackBerry`,X=`Browser`,or=`Chrome`,sr=`Edge`,cr=`Firefox`,lr=`Google`,ur=`Huawei`,dr=`LG`,fr=`Microsoft`,pr=`Motorola`,Z=`Opera`,mr=`Samsung`,hr=`Sharp`,gr=`Sony`,_r=`Xiaomi`,vr=`Zebra`,yr=`Facebook`,br=`Chromium OS`,xr=`Mac OS`;function Sr(e,t={}){let n={};for(let r of Object.keys(e)){let i=t[r];i&&i.length%2==0?n[r]=[...i,...e[r]]:n[r]=e[r]}return n}function Cr(e){let t={};for(let n=0;n<e.length;n++)t[e[n].toUpperCase()]=e[n];return t}function wr(e){return e.toLowerCase()}function Tr(e,t){return typeof e==`string`&&wr(t).includes(wr(e))}function Er(e){return typeof e==`string`?e.replace(/[^\d.]/g,Xn).split(`.`)[0]:void 0}function Dr(e,t){let n=e.replace(/^\s+/,Xn);return t===void 0?n:n.substring(0,t)}function Or(e,t,n){let r=n??{};for(let n=0;n<t.length;n+=2){let i=t[n],a=t[n+1];for(let t=0;t<i.length;t++){let n=i[t];if(!n)break;let o=n.exec(e);if(o){for(let e=0;e<a.length;e++){let t=o[e+1],n=a[e];if(Array.isArray(n)){let e=n[0],i=n.length;if(i===2){let i=n[1];typeof i==`function`?r[e]=i(t,void 0,r):r[e]=i}else if(i===3){let i=n[1],a=n[2];typeof i==`function`&&!(`exec`in i)&&!(`test`in i)?r[e]=t?i(t,a,r):void 0:r[e]=t?t.replace(i,a):void 0}else i===4&&(r[e]=t?n[3](t.replace(n[1],n[2]),void 0,r):void 0)}else r[n]=t||void 0}return r}}}return r}function kr(e,t){for(let n in t){let r=t[n];if(Array.isArray(r)&&r.length>0){for(let t=0;t<r.length;t++)if(Tr(r[t],e))return n===Zn?void 0:n}else if(Tr(r,e))return n===Zn?void 0:n}return e}var Ar={"1.0":`/8`,"1.2":`/1`,"1.3":`/3`,"2.0":`/412`,"2.0.2":`/416`,"2.0.3":`/417`,"2.0.4":`/419`,"?":`/`},jr={ME:`4.90`,"NT 3.11":`NT3.51`,"NT 4.0":`NT4.0`,2e3:`NT 5.0`,XP:[`NT 5.1`,`NT 5.2`],Vista:`NT 6.0`,7:`NT 6.1`,8:`NT 6.2`,"8.1":`NT 6.3`,10:[`NT 6.4`,`NT 10.0`],RT:`ARM`},Mr={browser:[[/\b(?:crmo|crios)\/([\w.]+)/i],[W,[V,`Chrome`]],[/edg(?:e|ios|a)?\/([\w.]+)/i],[W,[V,`Edge`]],[/(opera mini)\/([-\w.]+)/i,/(opera [mobileta]{3,6})\b.+version\/([-\w.]+)/i,/(opera)(?:.+version\/|[/ ]+)([\w.]+)/i],[V,W],[/opios[/ ]+([\w.]+)/i],[W,[V,`${Z} Mini`]],[/\bop(?:rg)?x\/([\w.]+)/i],[W,[V,`${Z} GX`]],[/\bopr\/([\w.]+)/i],[W,[V,Z]],[/\bb[ai]*d(?:uhd|[ub]*[aekoprswx]{5,6})[/ ]?([\w.]+)/i],[W,[V,`Baidu`]],[/(kindle)\/([\w.]+)/i,/(lunascape|maxthon|netfront|jasmine|blazer)[/ ]?([\w.]*)/i,/(avant|iemobile|slim)\s?(?:browser)?[/ ]?([\w.]*)/i,/(?:ms|\()(ie) ([\w.]+)/i,/(flock|rockmelt|midori|epiphany|silk|skyfire|bolt|iron|vivaldi|iridium|phantomjs|bowser|quark|qupzilla|falkon|rekonq|puffin|brave|whale(?!.+naver)|qqbrowserlite|qq|duckduckgo)\/([-\w.]+)/i,/(heytap|ovi)browser\/([\d.]+)/i,/(weibo)__([\d.]+)/i],[V,W],[/\bddg\/([\w.]+)/i],[W,[V,`DuckDuckGo`]],[/(?:\buc? ?browser|juc.+ucweb)[/ ]?([\w.]+)/i],[W,[V,`UC${X}`]],[/microm.+\bqbcore\/([\w.]+)/i,/\bqbcore\/([\w.]+).+microm/i,/micromessenger\/([\w.]+)/i],[W,[V,`WeChat`]],[/konqueror\/([\w.]+)/i],[W,[V,`Konqueror`]],[/trident.+rv[: ]([\w.]{1,9})\b.+like gecko/i],[W,[V,`IE`]],[/ya(?:search)?browser\/([\w.]+)/i],[W,[V,`Yandex`]],[/slbrowser\/([\w.]+)/i],[W,[V,`Smart Lenovo ${X}`]],[/(avast|avg)\/([\w.]+)/i],[[V,/(.+)/,`$1 Secure ${X}`],W],[/\bfocus\/([\w.]+)/i],[W,[V,`${cr} Focus`]],[/\bopt\/([\w.]+)/i],[W,[V,`${Z} Touch`]],[/coc_coc\w+\/([\w.]+)/i],[W,[V,`Coc Coc`]],[/dolfin\/([\w.]+)/i],[W,[V,`Dolphin`]],[/coast\/([\w.]+)/i],[W,[V,`${Z} Coast`]],[/miuibrowser\/([\w.]+)/i],[W,[V,`MIUI ${X}`]],[/fxios\/([-\w.]+)/i],[W,[V,cr]],[/\bqihu|(qi?ho{0,2}|360)browser/i],[[V,`360 ${X}`]],[/(oculus|sailfish|huawei|vivo)browser\/([\w.]+)/i],[[V,/(.+)/,`$1 ${X}`],W],[/samsungbrowser\/([\w.]+)/i],[W,[V,`${mr} Internet`]],[/(comodo_dragon)\/([\w.]+)/i],[[V,/_/g,` `],W],[/metasr[/ ]?([\d.]+)/i],[W,[V,`Sogou Explorer`]],[/(sogou)mo\w+\/([\d.]+)/i],[[V,`Sogou Mobile`],W],[/(electron)\/([\w.]+) safari/i,/(tesla)(?: qtcarbrowser|\/(20\d\d\.[-\w.]+))/i,/m?(qqbrowser|2345Explorer)[/ ]?([\w.]+)/i],[V,W],[/(lbbrowser)/i,/\[(linkedin)app\]/i],[V],[/((?:fban\/fbios|fb_iab\/fb4a)(?!.+fbav)|;fbav\/([\w.]+);)/i],[[V,yr],W],[/(Klarna)\/([\w.]+)/i,/(kakao(?:talk|story))[/ ]([\w.]+)/i,/(naver)\(.*?(\d+\.[\w.]+).*\)/i,/safari (line)\/([\w.]+)/i,/\b(line)\/([\w.]+)\/iab/i,/(alipay)client\/([\w.]+)/i,/(twitter)(?:and| f.+e\/([\w.]+))/i,/(chromium|instagram|snapchat)[/ ]([-\w.]+)/i],[V,W],[/\bgsa\/([\w.]+) .*safari\//i],[W,[V,`GSA`]],[/musical_ly(?:.+app_?version\/|_)([\w.]+)/i],[W,[V,`TikTok`]],[/headlesschrome(?:\/([\w.]+)| )/i],[W,[V,`${or} Headless`]],[/ wv\).+(chrome)\/([\w.]+)/i],[[V,`${or} WebView`],W],[/droid.+ version\/([\w.]+)\b.+(?:mobile safari|safari)/i],[W,[V,`Android ${X}`]],[/(chrome|omniweb|arora|[tizenoka]{5} ?browser)\/v?([\w.]+)/i],[V,W],[/version\/([\w.,]+) .*mobile\/\w+ (safari)/i],[W,[V,`Mobile Safari`]],[/version\/([\w(.|,)]+) .*(mobile ?safari|safari)/i],[W,V],[/webkit.+?(mobile ?safari|safari)(\/[\w.]+)/i],[V,[W,kr,Ar]],[/(webkit|khtml)\/([\w.]+)/i],[V,W],[/(navigator|netscape\d?)\/([-\w.]+)/i],[[V,`Netscape`],W],[/mobile vr; rv:([\w.]+)\).+firefox/i],[W,[V,`${cr} Reality`]],[/ekiohf.+(flow)\/([\w.]+)/i,/(swiftfox)/i,/(icedragon|iceweasel|camino|chimera|fennec|maemo browser|minimo|conkeror|klar)[/ ]?([\w.+]+)/i,/(seamonkey|k-meleon|icecat|iceape|firebird|phoenix|palemoon|basilisk|waterfox)\/([-\w.]+)$/i,/(firefox)\/([\w.]+)/i,/(mozilla)\/([\w.]+) .+rv:.+gecko\/\d+/i,/(polaris|lynx|dillo|icab|doris|amaya|w3m|netsurf|sleipnir|obigo|mosaic|(?:go|ice|up)[. ]?browser)[-/ ]?v?([\w.]+)/i,/(links) \(([\w.]+)/i,/panasonic;(viera)/i],[V,W],[/(cobalt)\/([\w.]+)/i],[V,[W,/master.|lts./,``]]],cpu:[[/(amd|x(?:(?:86|64)[-_])?|wow|win)64[;)]/i],[[G,`amd64`]],[/(ia32(?=;))/i],[[G,wr]],[/((?:i[346]|x)86)[;)]/i],[[G,`ia32`]],[/\b(aarch64|arm(v?8e?l?|_?64))\b/i],[[G,`arm64`]],[/\b(arm(?:v[67])?ht?n?[fl]p?)\b/i],[[G,`armhf`]],[/windows (ce|mobile); ppc;/i],[[G,`arm`]],[/((?:ppc|powerpc)(?:64)?)(?: mac|;|\))/i],[[G,/ower/,Xn,wr]],[/(sun4\w)[;)]/i],[[G,`sparc`]],[/(avr32|ia64(?=;)|68k(?=\))|\barm(?=v(?:[1-7]|[5-7]1)l?|;|eabi)|(?=atmel )avr|(?:irix|mips|sparc)(?:64)?\b|pa-risc)/i],[[G,wr]]],device:[[/\b(sch-i[89]0\d|shw-m380s|sm-[ptx]\w{2,4}|gt-[pn]\d{2,4}|sgh-t8[56]9|nexus 10)/i],[B,[U,mr],[H,q]],[/\b((?:s[cgp]h|gt|sm)-\w+|sc[g-]?\d+a?|galaxy nexus)/i,/samsung[- ]([-\w]+)/i,/sec-(sgh\w+)/i],[B,[U,mr],[H,K]],[/(?:\/|\()(ip(?:hone|od)[\w, ]*)(?:\/|;)/i],[B,[U,rr],[H,K]],[/\((ipad);[-\w),; ]+apple/i,/applecoremedia\/[\w.]+ \((ipad)/i,/\b(ipad)\d\d?,\d\d?[;\]].+ios/i],[B,[U,rr],[H,q]],[/(macintosh);/i],[B,[U,rr]],[/\b(sh-?[altvz]?\d\d[a-ekm]?)/i],[B,[U,hr],[H,K]],[/\b((?:ag[rs][23]?|bah2?|sht?|btv)-a?[lw]\d{2})\b(?!.+d\/s)/i],[B,[U,ur],[H,q]],[/(?:huawei|honor)([-\w ]+)[;)]/i,/\b(nexus 6p|\w{2,4}e?-[atu]?[ln][\dx][0-359c][adn]?)\b(?!.+d\/s)/i],[B,[U,ur],[H,K]],[/\b(poco[\w ]+|m2\d{3}j\d\d[a-z]{2})(?: bui|\))/i,/\b; (\w+) build\/hm\1/i,/\b(hm[-_ ]?note?[_ ]?(?:\d\w)?) bui/i,/\b(redmi[\-_ ]?[\w ]+)(?: bui|\))/i,/oid[^)]+; (m?[12][0-389][01]\w{3,6}[c-y])( bui|; wv|\))/i,/\b(mi[-_ ]?(?:a\d|one|one[_ ]plus|note lte|max|cc)?[_ ]?\d?\w?[_ ]?(?:plus|se|lite)?)(?: bui|\))/i],[[B,/_/g,` `],[U,_r],[H,K]],[/oid[^)]+; (2\d{4}(283|rpbf)[cgl])( bui|\))/i,/\b(mi[-_ ]?pad[\w ]+)(?: bui|\))/i],[[B,/_/g,` `],[U,_r],[H,q]],[/; (\w+) bui.+ oppo/i,/\b(cph[12]\d{3}|p(?:af|c[al]|d\w|e[ar])[mt]\d0|x9007|a101op)\b/i],[B,[U,`OPPO`],[H,K]],[/\b(opd2\d{3}a?) bui/i],[B,[U,`OPPO`],[H,q]],[/vivo (\w+)(?: bui|\))/i,/\b(v[12]\d{3}\w?[at])(?: bui|;)/i],[B,[U,`Vivo`],[H,K]],[/\b(rmx[1-3]\d{3})(?: bui|;|\))/i],[B,[U,`Realme`],[H,K]],[/\b(milestone|droid(?:[2-4x]| (?:bionic|x2|pro|razr))?:?( 4g)?)\b[\w ]+build\//i,/\bmot(?:orola)?[- ](\w*)/i,/((?:moto[\w() ]+|xt\d{3,4}|nexus 6)(?= bui|\)))/i],[B,[U,pr],[H,K]],[/\b(mz60\d|xoom[2 ]{0,2}) build\//i],[B,[U,pr],[H,q]],[/((?=lg)?[vl]k-?\d{3}) bui| 3\.[-\w; ]{10}lg?-([06cv9]{3,4})/i],[B,[U,dr],[H,q]],[/(lm(?:-?f100[nv]?|-[\w.]+)(?= bui|\))|nexus [45])/i,/\blg[-e;/ ]+((?!browser|netcast|android tv)\w+)/i,/\blg-?(\w+) bui/i],[B,[U,dr],[H,K]],[/(ideatab[-\w ]+)/i,/lenovo ?(s[56]000[-\w]+|tab[\w ]+|yt[-\w]{6}|tb[-\w]{6})/i],[B,[U,`Lenovo`],[H,q]],[/(?:maemo|nokia).*(n900|lumia \d+)/i,/nokia[-_ ]?([-\w.]*)/i],[[B,/_/g,` `],[U,`Nokia`],[H,K]],[/(pixel c)\b/i],[B,[U,lr],[H,q]],[/droid.+; (pixel[\daxl ]{0,6})(?: bui|\))/i],[B,[U,lr],[H,K]],[/droid.+ (a?\d[0-2]{2}so|[c-g]\d{4}|so[-gl]\w+|xq-a\w[4-7][12])(?= bui|\).+chrome\/(?![1-6]?\d\.))/i],[B,[U,gr],[H,K]],[/sony tablet [ps]/i,/\b(?:sony)?sgp\w+(?: bui|\))/i],[[B,`Xperia Tablet`],[U,gr],[H,q]],[/ (kb2005|in20[12]5|be20[12][59])\b/i,/(?:one)?(?:plus)? (a\d0\d\d)(?: b|\))/i],[B,[U,`OnePlus`],[H,K]],[/(alexa)webm/i,/(kf[a-z]{2}wi|aeo[c-r]{2})( bui|\))/i,/(kf[a-z]+)( bui|\)).+silk\//i],[B,[U,nr],[H,q]],[/((?:sd|kf)[0349hijor-uw]+)( bui|\)).+silk\//i],[[B,/(.+)/g,`Fire Phone $1`],[U,nr],[H,K]],[/(playbook);[-\w),; ]+(rim)/i],[B,U,[H,q]],[/\b((?:bb[a-f]|st[hv])100-\d)/i,/\(bb10; (\w+)/i],[B,[U,ar],[H,K]],[/(?:\b|asus_)(transfo[prime ]{4,10} \w+|eeepc|slider \w+|nexus 7|padfone|p00[cj])/i],[B,[U,ir],[H,q]],[/ (z[bes]6[027][012][km][ls]|zenfone \d\w?)\b/i],[B,[U,ir],[H,K]],[/(nexus 9)/i],[B,[U,`HTC`],[H,q]],[/(htc)[-;_ ]{1,2}([\w ]+(?=\)| bui)|\w+)/i,/(zte)[- ]([\w ]+?)(?: bui|\/|\))/i,/(alcatel|geeksphone|nexian|panasonic(?!;|\.)|sony(?!-bra))[-_ ]?([-\w]*)/i],[U,[B,/_/g,` `],[H,K]],[/droid.+; ([ab][1-7]-?[0178a]\d\d?)/i],[B,[U,`Acer`],[H,q]],[/droid.+; (m[1-5] note) bui/i,/\bmz-([-\w]{2,})/i],[B,[U,`Meizu`],[H,K]],[/; ((?:power )?armor[\w ]{0,8})(?: bui|\))/i],[B,[U,`Ulefone`],[H,K]],[/(blackberry|benq|palm(?=-)|sonyericsson|acer|asus|dell|meizu|motorola|polytron|infinix|tecno)[-_ ]?([-\w]*)/i,/(hp) ([\w ]+\w)/i,/(asus)-?(\w+)/i,/(microsoft); (lumia[\w ]+)/i,/(lenovo)[-_ ]?([-\w]+)/i,/(jolla)/i,/(oppo) ?([\w ]+) bui/i],[U,B,[H,K]],[/(kobo)\s(ereader|touch)/i,/(archos) (gamepad2?)/i,/(hp).+(touchpad(?!.+tablet)|tablet)/i,/(kindle)\/([\w.]+)/i,/(nook)[\w ]+build\/(\w+)/i,/(dell) (strea[kpr\d ]*[\dko])/i,/(le[- ]+pan)[- ]+(\w{1,9}) bui/i,/(trinity)[- ]*(t\d{3}) bui/i,/(gigaset)[- ]+(q\w{1,9}) bui/i,/(vodafone) ([\w ]+)(?:\)| bui)/i],[U,B,[H,q]],[/(surface duo)/i],[B,[U,fr],[H,q]],[/droid [\d.]+; (fp\du?)(?: b|\))/i],[B,[U,`Fairphone`],[H,K]],[/(u304aa)/i],[B,[U,`AT&T`],[H,K]],[/\bsie-(\w*)/i],[B,[U,`Siemens`],[H,K]],[/\b(rct\w+) b/i],[B,[U,`RCA`],[H,q]],[/\b(venue[\d ]{2,7}) b/i],[B,[U,`Dell`],[H,q]],[/\b(q(?:mv|ta)\w+) b/i],[B,[U,`Verizon`],[H,q]],[/\b(?:barnes[& ]+noble |bn[rt])([\w+ ]*) b/i],[B,[U,`Barnes & Noble`],[H,q]],[/\b(tm\d{3}\w+) b/i],[B,[U,`NuVision`],[H,q]],[/\b(k88) b/i],[B,[U,`ZTE`],[H,q]],[/\b(nx\d{3}j) b/i],[B,[U,`ZTE`],[H,K]],[/\b(gen\d{3}) b.+49h/i],[B,[U,`Swiss`],[H,K]],[/\b(zur\d{3}) b/i],[B,[U,`Swiss`],[H,q]],[/\b((zeki)?tb.*\b) b/i],[B,[U,`Zeki`],[H,q]],[/\b([yr]\d{2}) b/i,/\b(dragon[- ]+touch |dt)(\w{5}) b/i],[[U,`Dragon Touch`],B,[H,q]],[/\b(ns-?\w{0,9}) b/i],[B,[U,`Insignia`],[H,q]],[/\b((nxa|next)-?\w{0,9}) b/i],[B,[U,`NextBook`],[H,q]],[/\b(xtreme_)?(v(1[045]|2[015]|[3469]0|7[05])) b/i],[[U,`Voice`],B,[H,K]],[/\b(lvtel-)?(v1[12]) b/i],[[U,`LvTel`],B,[H,K]],[/\b(ph-1) /i],[B,[U,`Essential`],[H,K]],[/\b(v(100md|700na|7011|917g).*\b) b/i],[B,[U,`Envizen`],[H,q]],[/\b(trio[-\w. ]+) b/i],[B,[U,`MachSpeed`],[H,q]],[/\btu_(1491) b/i],[B,[U,`Rotor`],[H,q]],[/(shield[\w ]+) b/i],[B,[U,`Nvidia`],[H,q]],[/(sprint) (\w+)/i],[U,B,[H,K]],[/(kin\.[onetw]{3})/i],[[B,/\./g,` `],[U,fr],[H,K]],[/droid.+; (cc6666?|et5[16]|mc[239][23]x?|vc8[03]x?)\)/i],[B,[U,vr],[H,q]],[/droid.+; (ec30|ps20|tc[2-8]\d[kx])\)/i],[B,[U,vr],[H,K]],[/smart-tv.+(samsung)/i],[U,[H,J]],[/hbbtv.+maple;(\d+)/i],[[B,/^/,`SmartTV`],[U,mr],[H,J]],[/(nux; netcast.+smarttv|lg (netcast\.tv-201\d|android tv))/i],[[U,dr],[H,J]],[/(apple) ?tv/i],[U,[B,`${rr} TV`],[H,J]],[/crkey/i],[[B,`${or}cast`],[U,lr],[H,J]],[/droid.+aft(\w+)( bui|\))/i],[B,[U,nr],[H,J]],[/\(dtv[);].+(aquos)/i,/(aquos-tv[\w ]+)\)/i],[B,[U,hr],[H,J]],[/(bravia[\w ]+)( bui|\))/i],[B,[U,gr],[H,J]],[/(mitv-\w{5}) bui/i],[B,[U,_r],[H,J]],[/Hbbtv.*(technisat) (.*);/i],[U,B,[H,J]],[/\b(roku)[\dx]*[)/]((?:dvp-)?[\d.]*)/i,/hbbtv\/\d+\.\d+\.\d+ +\([\w+ ]*; *(\w[^;]*);([^;]*)/i],[[U,Dr],[B,Dr],[H,J]],[/\b(android tv|smart[- ]?tv|opera tv|tv; rv:)\b/i],[[H,J]],[/(ouya)/i,/(nintendo) ([wids3utch]+)/i],[U,B,[H,$n]],[/droid.+; (shield) bui/i],[B,[U,`Nvidia`],[H,$n]],[/(playstation [345portablevi]+)/i],[B,[U,gr],[H,$n]],[/\b(xbox(?: one)?(?!; xbox))[); ]/i],[B,[U,fr],[H,$n]],[/((pebble))app/i],[U,B,[H,Y]],[/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i],[B,[U,rr],[H,Y]],[/droid.+; (glass) \d/i],[B,[U,lr],[H,Y]],[/droid.+; (wt63?0{2,3})\)/i],[B,[U,vr],[H,Y]],[/(quest( \d| pro)?)/i],[B,[U,yr],[H,Y]],[/(tesla)(?: qtcarbrowser|\/[-\w.]+)/i],[U,[H,er]],[/(aeobc)\b/i],[B,[U,nr],[H,er]],[/droid .+?; ([^;]+?)(?: bui|; wv\)|\) applew).+? mobile safari/i],[B,[H,K]],[/droid .+?; ([^;]+?)(?: bui|\) applew).+?(?! mobile) safari/i],[B,[H,q]],[/\b((tablet|tab)[;/]|focus\/\d(?!.+mobile))/i],[[H,q]],[/(phone|mobile(?:[;/]| [ \w/.]*safari)|pda(?=.+windows ce))/i],[[H,K]],[/(android[-\w. ]{0,9});.+buil/i],[B,[U,`Generic`]]],engine:[[/windows.+ edge\/([\w.]+)/i],[W,[V,`${sr}HTML`]],[/webkit\/537\.36.+chrome\/(?!27)([\w.]+)/i],[W,[V,`Blink`]],[/(presto)\/([\w.]+)/i,/(webkit|trident|netfront|netsurf|amaya|lynx|w3m|goanna)\/([\w.]+)/i,/ekioh(flow)\/([\w.]+)/i,/(khtml|tasman|links)[/ ]\(?([\w.]+)/i,/(icab)[/ ]([23]\.[\d.]+)/i,/\b(libweb)/i],[V,W],[/rv:([\w.]{1,9})\b.+(gecko)/i],[W,V]],os:[[/microsoft (windows) (vista|xp)/i],[V,W],[/(windows (?:phone(?: os)?|mobile))[/ ]?([.\w ]*)/i],[V,[W,kr,jr]],[/windows nt 6\.2; (arm)/i,/windows[/ ]?([ntce\d. ]+\w)(?!.+xbox)/i,/(?:win(?=[39n])|win 9x )([nt\d.]+)/i],[[W,kr,jr],[V,`Windows`]],[/ip[honead]{2,4}\b(?:.*os (\w+) like mac|; opera)/i,/(?:ios;fbsv\/|iphone.+ios[/ ])([\d.]+)/i,/cfnetwork\/.+darwin/i],[[W,/_/g,`.`],[V,`iOS`]],[/(mac os x) ?([\w. ]*)/i,/(macintosh|mac_powerpc\b)(?!.+haiku)/i],[[V,xr],[W,/_/g,`.`]],[/droid ([\w.]+)\b.+(android[- ]x86|harmonyos)/i],[W,V],[/(android|webos|qnx|bada|rim tablet os|maemo|meego|sailfish)[-/ ]?([\w.]*)/i,/(blackberry)\w*\/([\w.]*)/i,/(tizen|kaios)[/ ]([\w.]+)/i,/\((series40);/i],[V,W],[/\(bb(10);/i],[W,[V,ar]],[/(?:symbian ?os|symbos|s60(?=;)|series60)[-/ ]?([\w.]*)/i],[W,[V,`Symbian`]],[/mozilla\/[\d.]+ \((?:mobile|tablet|tv|mobile; [\w ]+); rv:.+ gecko\/([\w.]+)/i],[W,[V,`${cr} OS`]],[/web0s;.+rt(tv)/i,/\b(?:hp)?wos(?:browser)?\/([\w.]+)/i],[W,[V,`webOS`]],[/watch(?: ?os[,/]|\d,\d\/)([\d.]+)/i],[W,[V,`watchOS`]],[/crkey\/([\d.]+)/i],[W,[V,`${or}cast`]],[/(cros) \w+(?:\)| ([\w.]+)\b)/i],[[V,br],W],[/panasonic;(viera)/i,/(netrange)mmh/i,/(nettv)\/(\d+\.[\w.]+)/i,/(nintendo|playstation) ([wids345portablevuch]+)/i,/(xbox); +xbox ([^);]+)/i,/\b(joli|palm)\b ?(?:os)?\/?([\w.]*)/i,/(mint)[/() ]?(\w*)/i,/(mageia|vectorlinux)[; ]/i,/([kxln]?ubuntu|debian|suse|opensuse|gentoo|arch(?= linux)|slackware|fedora|mandriva|centos|pclinuxos|red ?hat|zenwalk|linpus|raspbian|plan 9|minix|risc os|contiki|deepin|manjaro|elementary os|sabayon|linspire)(?: gnu\/linux)?(?: enterprise)?(?:[- ]linux)?(?:-gnu)?[-/ ]?(?!chrom|package)([-\w.]*)/i,/(hurd|linux) ?([\w.]*)/i,/(gnu) ?([\w.]*)/i,/\b([-e-hrntopcs]{0,5}bsd|dragonfly)[/ ]?(?!amd|[ix346]{1,2}86)([\w.]*)/i,/(haiku) (\w+)/i],[V,W],[/(sunos) ?([\w.]*)/i],[[V,`Solaris`],W],[/((?:open)?solaris)[-/ ]?([\w.]*)/i,/(aix) ((\d)(?=[.) ])[\w.])*/i,/\b(beos|os\/2|amigaos|morphos|openvms|fuchsia|hp-ux|serenityos)/i,/(unix) ?([\w.]*)/i],[V,W]]};function Nr(e){return typeof e==`object`&&!!e}Object.freeze(Cr([V,W,Qn])),Object.freeze(Cr([G])),Object.freeze(Cr([B,U,H,$n,K,J,q,Y,er])),Object.freeze(Cr([V,W])),Object.freeze(Cr([V,W]));function Pr(){if(!(typeof window>`u`||!window.navigator))return window.navigator}function Fr(e){return e.length>tr?Dr(e,tr):e}function Ir(e){if(typeof e==`string`)return{ua:Fr(e),isSelfNavigator:!1,navigator:void 0,userAgentData:void 0,regexMap:Mr};let t=Pr(),n=Fr(t&&t.userAgent?t.userAgent:Xn);return{ua:n,isSelfNavigator:!!(t&&t.userAgent===n),navigator:t,userAgentData:t?.userAgentData,regexMap:Mr}}function Lr(e,t){if(!t&&!Nr(e))return Ir(e);let n=Pr(),r=Nr(e)?void 0:e,i=Nr(e)?e:t,a=Fr(r||(n&&n.userAgent?n.userAgent:Xn)),o=n?.userAgentData;return{ua:a,isSelfNavigator:!!(n&&n.userAgent===a),navigator:n,userAgentData:o,regexMap:i?Sr(Mr,i):Mr}}function Rr(e){let t={name:void 0,version:void 0,major:void 0};return Or(e.ua,e.regexMap.browser,t),t.major=Er(t.version),e.isSelfNavigator&&e.navigator?.brave&&typeof e.navigator.brave.isBrave==`function`&&(t.name=`Brave`),t}function zr(e){let t={architecture:void 0};return Or(e.ua,e.regexMap.cpu,t),t}function Br(e){let t={vendor:void 0,model:void 0,type:void 0};return Or(e.ua,e.regexMap.device,t),e.isSelfNavigator&&!t.type&&e.userAgentData?.mobile&&(t.type=K),e.isSelfNavigator&&t.model===`Macintosh`&&e.navigator&&e.navigator.standalone!==void 0&&e.navigator.maxTouchPoints&&e.navigator.maxTouchPoints>2&&(t.model=`iPad`,t.type=q),t}function Vr(e){let t={name:void 0,version:void 0};return Or(e.ua,e.regexMap.engine,t),t}function Hr(e){let t={name:void 0,version:void 0};return Or(e.ua,e.regexMap.os,t),e.isSelfNavigator&&!t.name&&e.userAgentData?.platform&&e.userAgentData.platform!==`Unknown`&&(t.name=e.userAgentData.platform.replace(/chrome os/i,br).replace(/macos/i,xr)),t}function Ur(e,t){let n,r,i,a,o,s,c=()=>n||=Lr(e,t);return{get ua(){return c().ua},get browser(){return r||=Rr(c()),r},get engine(){return i||=Vr(c()),i},get os(){return a||=Hr(c()),a},get device(){return o||=Br(c()),o},get cpu(){return s||=zr(c()),s}}}var Q=class extends Error{name=`DevframeConnectionError`;kind;constructor(e,t,n){super(t,n),this.kind=e}};function Wr(e,t,n){let r=n.protocol===`https:`?`wss:`:`ws:`,i=(()=>{try{return new URL(t,n.href)}catch{return new URL(n.href)}})();if(e&&typeof e==`object`){if(e.host!=null||e.port!=null){let t=e.host??`${n.hostname}:${e.port}`,i=new URL(e.path??`/`,`${r}//${t}`);return i.protocol=r,i.href}let t=new URL(e.path??``,i);return t.protocol=r,t.href}if(typeof e==`number`)return`${r}//${n.hostname}:${e}`;let a=e??``;if(/^wss?:\/\//i.test(a))return a;if(/^https?:\/\//i.test(a))return tn(a,/^https/i.test(a)?`wss://`:`ws://`);let o=new URL(a,i);return o.protocol=r,o.href}function Gr(e){let{authToken:t,connectionMeta:n,metaBaseUrl:r,events:i,clientRpc:a,rpcOptions:o={},wsOptions:s={},callTimeout:c=0}=e,l=!1,u=`connecting`,d=null,f=Pt(),p=Wr(n.websocket,r??`./`,location);function m(e,t=null){if(t?d=t:e===`connected`&&(d=null),e===u)return;let n=u;u=e,i.emit(`connection:status`,e,n)}let h=new Set;function g(e){for(let t of[...h])t.reject(e)}function _(){return u===`disconnected`||u===`error`?new Q(`connection`,`[devframe] Not connected to the devframe server`,{cause:d??void 0}):u===`unauthorized`?new Q(`auth`,`[devframe] Not authorized by the devframe server`,{cause:d??void 0}):null}function v(e,t){return new Promise((n,r)=>{let a=!1,o,s={reject(e){a||(l(),i.emit(`rpc:error`,e,t),r(e))}};function l(){a=!0,h.delete(s),o&&clearTimeout(o)}h.add(s),c>0&&(o=setTimeout(()=>{s.reject(new Q(`timeout`,`[devframe] RPC call "${t}" timed out after ${c}ms`))},c)),e.then(e=>{a||(l(),n(e))},e=>{if(a)return;l();let n=e instanceof Error?e:Error(String(e));i.emit(`rpc:error`,n,t),r(n)})})}let y=new Map;for(let e of n.jsonSerializableMethods??[])y.set(e,{jsonSerializable:!0});let b=Kn(a.functions,{channel:Yn({url:p,authToken:t,definitions:y,...s,onConnected(e){s.onConnected?.(e)},onError(e){m(`error`,e),i.emit(`connection:error`,e),g(new Q(`connection`,`[devframe] Connection to the devframe server failed`,{cause:e})),s.onError?.(e)},onDisconnected(e){u!==`error`&&m(`disconnected`),g(new Q(`connection`,`[devframe] Disconnected from the devframe server`,{cause:d??void 0})),s.onDisconnected?.(e)}}),rpcOptions:o});a.register({name:`devframe:auth:revoked`,type:`event`,handler:()=>{l=!1;let e=new Q(`auth`,`[devframe] The devframe server revoked this client's trust`);m(`unauthorized`,e),i.emit(`connection:error`,e),g(e),i.emit(`rpc:is-trusted:updated`,!1)}});let x=t;function S(){let e=Ur(navigator.userAgent);return[e.browser.name,e.browser.version,`|`,e.os.name,e.os.version,e.device.type].filter(e=>e).join(` `)}async function C(e){x=e;let t=await b.$call(`anonymous:devframe:auth`,{authToken:e,ua:S(),origin:location.origin});if(l=t.isTrusted,l)f.resolve(!0),m(`connected`);else{let e=new Q(`auth`,`[devframe] The devframe server refused this client's credentials`);m(`unauthorized`,e),i.emit(`connection:error`,e)}return i.emit(`rpc:is-trusted:updated`,l),t.isTrusted}async function w(e){let t=(await b.$call(`anonymous:devframe:auth:exchange`,{code:e,ua:S(),origin:location.origin}))?.authToken??null;return t&&(x=t,l=!0,f.resolve(!0),m(`connected`),i.emit(`rpc:is-trusted:updated`,!0)),t}async function ee(){return l?!0:C(x??``)}async function te(e=6e4){if(l&&f.resolve(!0),e<=0)return f.promise;let t=()=>{};return await Promise.race([f.promise.then(t),new Promise((n,r)=>{let i=setTimeout(()=>{r(Error(`[devframe] Timeout waiting for rpc to be trusted`))},e);t=()=>clearTimeout(i)})]),l}return{get isTrusted(){return l},get status(){return u},get connectionError(){return d},requestTrust:ee,requestTrustWithToken:C,requestTrustWithCode:w,ensureTrusted:te,call:(...e)=>{let t=String(e[0]),n=_();return n?(i.emit(`rpc:error`,n,t),Promise.reject(n)):v(b.$call(...e),t)},callEvent:(...e)=>{let t=_();if(t){i.emit(`rpc:error`,t,String(e[0]));return}return b.$callEvent(...e)},callOptional:(...e)=>{let t=String(e[0]),n=_();return n?(i.emit(`rpc:error`,n,t),Promise.reject(n)):v(b.$callOptional(...e),t)}}}function Kr(e,t,n){let r=`devframe:settings:${n}:${t}`,i;function a(){return i||=e.sharedState.get(r,{initialValue:{}}),i}return{async get(e){return(await a()).value()[e]},async set(e,t){(await a()).mutate(n=>{n[e]=t})},async delete(e){(await a()).mutate(t=>{delete t[e]})},async all(){return(await a()).value()},async onChange(e){return(await a()).on(`updated`,t=>e(t))}}}function qr(e,t){return{global:Kr(e,t,`global`),project:Kr(e,t,`project`)}}function Jr(e,t){return{namespace:t,base:e,rpc:{namespace:t,register(n){if(Ft(n.name))throw Error(`[devframe] Scoped client RPC registration for namespace "${t}" received an already-namespaced function name "${n.name}". Pass a bare name without a ":" separator.`);e.client.register({...n,name:`${t}:${n.name}`})},call:((n,...r)=>e.call(L(t,n),...r)),callEvent:((n,...r)=>e.callEvent(L(t,n),...r)),callOptional:((n,...r)=>e.callOptional(L(t,n),...r)),sharedState:((n,r)=>e.sharedState.get(L(t,n),r)),streaming:{subscribe:(n,r,i)=>e.streaming.subscribe(L(t,n),r,i),upload:(n,r)=>e.streaming.upload(L(t,n),r)}},settings:qr(e,t),scope:e.scope}}var Yr=`__DEVFRAME_CONNECTION_META__`,$=`__DEVFRAME_CONNECTION_AUTH_TOKEN__`;function Xr(e){let t=[()=>e,()=>localStorage.getItem($)??void 0,()=>window?.[$],()=>globalThis?.[$],()=>parent.window?.[$]];for(let e of t)try{let t=e();if(t)return t}catch{}}function Zr(e){try{localStorage.setItem($,e)}catch{}globalThis[$]=e}function Qr(){let e=[()=>window?.[Yr],()=>globalThis?.[Yr],()=>parent.window?.[Yr]];for(let t of e)try{let e=t();if(e)return e}catch{}}async function $r(e={}){let{baseURL:t=`./`,rpcOptions:n={},cacheOptions:r=!1}=e,i=p(),a=Array.isArray(t)?t:[t],o=e.connectionMeta||Qr(),s=a[0]??`./`,c=e.connectionMeta?void 0:o?.baseUrl;function l(){if(c)return c;let e=Zt(hn,s);try{return new URL(e,globalThis.location?.href).href}catch{return e}}if(!o){let e=[];for(let t of a)try{o=await fetch(Zt(hn,t)).then(e=>e.json()),s=t,globalThis[Yr]={...o,baseUrl:l()};break}catch(t){e.push(t)}if(!o)throw Error(`Failed to get connection meta from ${a.join(`, `)}`,{cause:e})}let u=new Tn({functions:[],...typeof e.cacheOptions==`object`?e.cacheOptions:{}}),d={rpc:void 0},f=Xr(e.authToken||o.authToken);f&&Zr(f);let m=new En(d);async function h(e){let t=[s,...a.filter(e=>e!==s)].filter(e=>e!=null),n=[];for(let r of t)try{return await fetch(Zt(e,r)).then(t=>{if(!t.ok)throw Error(`Failed to fetch ${e} from ${r}: ${t.status}`);return t.json()})}catch(e){n.push(e)}throw Error(`Failed to load ${e} from ${t.join(`, `)}`,{cause:n})}let g=o.backend===`static`?await Hn({fetchJsonFromBases:h}):Gr({authToken:f,connectionMeta:o,metaBaseUrl:l(),events:i,clientRpc:m,callTimeout:e.callTimeout,rpcOptions:{...n,async onRequest(e,t,i){if(await n.onRequest?.call(this,e,t,i),r&&u?.validate(e.m)){if(u.has(e.m,e.a))return i(u.cached(e.m,e.a));let n=await t(e);u.apply(e,n)}else await t(e)}},wsOptions:e.wsOptions}),_;try{_=new BroadcastChannel(`devframe-auth`)}catch{}let v,y=!1;function b(e){return((...t)=>y||!v?e(...t):v.then(()=>e(...t)))}let x={events:i,get isTrusted(){return g.isTrusted},get status(){return g.status},get connectionError(){return g.connectionError},connectionMeta:o,ensureTrusted:g.ensureTrusted,requestTrust:g.requestTrust,requestTrustWithToken:async e=>(Zr(e),g.requestTrustWithToken(e)),requestTrustWithCode:async e=>{let t=await g.requestTrustWithCode(e);if(!t)return!1;Zr(t);try{_?.postMessage({type:`auth-update`,authToken:t})}catch{}return!0},call:b(g.call),callEvent:b(g.callEvent),callOptional:b(g.callOptional),client:m,sharedState:void 0,streaming:void 0,cacheManager:u,scope:void 0};x.sharedState=Pn(x),x.streaming=Gn(x);let S=new Map;x.scope=(e=>{if(!e)return x;let t=S.get(e);return t||(t=Jr(x,e),S.set(e,t)),t}),d.rpc=x;function C(){try{return typeof window<`u`&&window.self===window.top}catch{return!1}}async function w(){if(!(e.simpleAuth===!1||!C())&&typeof globalThis.prompt==`function`)for(;!x.isTrusted;){let e=globalThis.prompt(`devframe: enter the authentication code shown in your terminal`);if(e==null)return;let t=e.trim();if(t&&await x.requestTrustWithCode(t))return}}async function ee(){let t=await g.requestTrust(),n=e.otpParam??`devframe_otp`,r=n?await Nn(x,{param:n}):!1;t||r||x.isTrusted||await w()}return v=ee().then(()=>{y=!0},()=>{y=!0}),_&&(_.onmessage=e=>{e.data?.type===`auth-update`&&e.data.authToken&&x.requestTrustWithToken(e.data.authToken)}),x}function ei(e={}){return $r({...e,simpleAuth:!1})}export{ei as getDevToolsRpcClient};