@bigduu/lotus-next 2026.9.13 → 2026.9.16
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 +36 -7
- package/dist/asset-manifest.json +39 -39
- package/dist/assets/{CodeBlock-dYUQ9iue.js → CodeBlock-BD0dxoK1.js} +1 -1
- package/dist/assets/{Markdown-DBG0vWxL.js → Markdown-DBgPZQmh.js} +2 -2
- package/dist/assets/{MermaidChart-U1Z5JCRh.js → MermaidChart-DQmhZUGR.js} +1 -1
- package/dist/assets/Root-BEo2vkPq.js +7 -0
- package/dist/assets/{Settings-BcsRaEDP.js → Settings-B5mbtM74.js} +1 -1
- package/dist/assets/{StreamdownMarkdown-CiLy0KJD.js → StreamdownMarkdown-CNZkpiH5.js} +2 -2
- package/dist/assets/{StreamdownMermaid-J7jSRtO6.js → StreamdownMermaid-I-FMxv6d.js} +1 -1
- package/dist/assets/html2canvas-0VX6Q4F2.js +1 -0
- package/dist/assets/{index-CjY6eMv8.js → index-CetaXSQl.js} +2 -2
- package/dist/assets/{renderPdf-DbvJnEQL.js → renderPdf-BHOiVXVS.js} +3 -3
- package/dist/assets/{select-DYBAIyVx.js → select-BQoctDKH.js} +21 -21
- package/dist/assets/{strictConfig-Bf8nyKvx.js → strictConfig-DWxLgSCr.js} +1 -1
- package/dist/assets/{vendor-highlighter-ClvlgmIK.js → vendor-highlighter-BcgzBkPn.js} +1 -1
- package/dist/assets/{vendor-mermaid-Da_wWrs4.js → vendor-mermaid-CLYBA7Ke.js} +1 -1
- package/dist/assets/{vendor-streamdown-BIRX7zKm.js → vendor-streamdown-BLuMYZXO.js} +1 -1
- package/dist/assets/{vendor-streamdown-code-B6SuuZwa.js → vendor-streamdown-code-DslGaU_r.js} +1 -1
- package/dist/bundle-ownership.json +16 -16
- package/dist/index.html +1 -1
- package/dist/lotus-next-manifest.json +40 -40
- package/package.json +2 -1
- package/dist/assets/Root-dWsRRTlH.js +0 -7
- package/dist/assets/html2canvas-ChX2ETZ3.js +0 -1
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import{r as e,t}from"./rolldown-runtime-QTnfLwEv.js";import{i as n,r,t as i}from"./vendor-react-CCIEwYL0.js";import{n as a,t as o}from"./index-
|
|
1
|
+
import{r as e,t}from"./rolldown-runtime-QTnfLwEv.js";import{i as n,r,t as i}from"./vendor-react-CCIEwYL0.js";import{n as a,t as o}from"./index-CetaXSQl.js";import{a as s,f as c,i as l,l as u,o as d,s as f}from"./ErrorBoundary-DLCRl4Er.js";var p=c(`circle-alert`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`line`,{x1:`12`,x2:`12`,y1:`8`,y2:`12`,key:`1pkeuh`}],[`line`,{x1:`12`,x2:`12.01`,y1:`16`,y2:`16`,key:`4dfq90`}]]),m=c(`loader-circle`,[[`path`,{d:`M21 12a9 9 0 1 1-6.219-8.56`,key:`13zald`}]]),h=c(`check`,[[`path`,{d:`M20 6 9 17l-5-5`,key:`1gmf2c`}]]),g=c(`chevron-down`,[[`path`,{d:`m6 9 6 6 6-6`,key:`qrunsl`}]]),_=c(`chevron-right`,[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]),v=c(`chevron-up`,[[`path`,{d:`m18 15-6-6-6 6`,key:`153udz`}]]),y=c(`copy`,[[`rect`,{width:`14`,height:`14`,x:`8`,y:`8`,rx:`2`,ry:`2`,key:`17jyea`}],[`path`,{d:`M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2`,key:`zix9uf`}]]),b=c(`monitor`,[[`rect`,{width:`20`,height:`14`,x:`2`,y:`3`,rx:`2`,key:`48i651`}],[`line`,{x1:`8`,x2:`16`,y1:`21`,y2:`21`,key:`1svkeh`}],[`line`,{x1:`12`,x2:`12`,y1:`17`,y2:`21`,key:`vw1qmm`}]]),x=c(`pencil`,[[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}],[`path`,{d:`m15 5 4 4`,key:`1mk7zo`}]]),S=c(`plus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]]),C=c(`search`,[[`path`,{d:`m21 21-4.34-4.34`,key:`14j7rj`}],[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}]]),w=c(`server`,[[`rect`,{width:`20`,height:`8`,x:`2`,y:`2`,rx:`2`,ry:`2`,key:`ngkwjq`}],[`rect`,{width:`20`,height:`8`,x:`2`,y:`14`,rx:`2`,ry:`2`,key:`iecqi9`}],[`line`,{x1:`6`,x2:`6.01`,y1:`6`,y2:`6`,key:`16zg32`}],[`line`,{x1:`6`,x2:`6.01`,y1:`18`,y2:`18`,key:`nzw8ys`}]]),T=c(`trash-2`,[[`path`,{d:`M10 11v6`,key:`nco0om`}],[`path`,{d:`M14 11v6`,key:`outv1u`}],[`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6`,key:`miytrc`}],[`path`,{d:`M3 6h18`,key:`d0wm0j`}],[`path`,{d:`M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`,key:`e791ji`}]]),E=c(`x`,[[`path`,{d:`M18 6 6 18`,key:`1bl5f8`}],[`path`,{d:`m6 6 12 12`,key:`d8bk6v`}]]),D=e(n(),1),O=e=>Symbol.iterator in e,ee=e=>`entries`in e,k=(e,t)=>{let n=e instanceof Map?e:new Map(e.entries()),r=t instanceof Map?t:new Map(t.entries());if(n.size!==r.size)return!1;for(let[e,t]of n)if(!r.has(e)||!Object.is(t,r.get(e)))return!1;return!0},te=(e,t)=>{let n=e[Symbol.iterator](),r=t[Symbol.iterator](),i=n.next(),a=r.next();for(;!i.done&&!a.done;){if(!Object.is(i.value,a.value))return!1;i=n.next(),a=r.next()}return!!i.done&&!!a.done};function ne(e,t){return Object.is(e,t)?!0:typeof e!=`object`||!e||typeof t!=`object`||!t||Object.getPrototypeOf(e)!==Object.getPrototypeOf(t)?!1:O(e)&&O(t)?ee(e)&&ee(t)?k(e,t):te(e,t):k({entries:()=>Object.entries(e)},{entries:()=>Object.entries(t)})}function A(e){let t=D.useRef(void 0);return n=>{let r=e(n);return ne(t.current,r)?t.current:t.current=r}}var re=e=>{let t,n=new Set,r=(e,r)=>{let i=typeof e==`function`?e(t):e;if(!Object.is(i,t)){let e=t;t=r??(typeof i!=`object`||!i)?i:Object.assign({},t,i),n.forEach(n=>n(t,e))}},i=()=>t,a={setState:r,getState:i,getInitialState:()=>o,subscribe:e=>(n.add(e),()=>n.delete(e))},o=t=e(r,i,a);return a},ie=(e=>e?re(e):re),ae=e=>e;function j(e,t=ae){let n=D.useSyncExternalStore(e.subscribe,D.useCallback(()=>t(e.getState()),[e,t]),D.useCallback(()=>t(e.getInitialState()),[e,t]));return D.useDebugValue(n),n}var oe=e=>{let t=ie(e),n=e=>j(t,e);return Object.assign(n,t),n},se=(e=>e?oe(e):oe),ce=e=>!!e.dispatchFromDevtools&&typeof e.dispatch==`function`,le=new Map,ue=e=>{let t=le.get(e);return t?Object.fromEntries(Object.entries(t.stores).map(([e,t])=>[e,t.getState()])):{}},de=(e,t,n)=>{if(e===void 0)return{type:`untracked`,connection:t.connect(n)};let r=le.get(n.name);if(r)return{type:`tracked`,store:e,...r};let i={connection:t.connect(n),stores:{}};return le.set(n.name,i),{type:`tracked`,store:e,...i}},fe=(e,t)=>{if(t===void 0)return;let n=le.get(e);n&&(delete n.stores[t],Object.keys(n.stores).length===0&&le.delete(e))},M=/.+ (.+) .+/,pe=/^([^@]+)@/;function N(e){if(!e)return;let t=e.split(`
|
|
2
2
|
`),n=t.findIndex(e=>e.includes(`api.setState`));if(n<0)return;let r=t[n+1]?.trim()||``;return M.exec(r)?.[1]||pe.exec(r)?.[1]}var me=(e,t={})=>(n,r,i)=>{let{enabled:a,anonymousActionType:o,store:s,...c}=t,l;try{l=(a??!1)&&window.__REDUX_DEVTOOLS_EXTENSION__}catch{}if(!l)return e(n,r,i);let{connection:u,...d}=de(s,l,c),f=!0;i.setState=((e,t,a)=>{let l=n(e,t);if(!f)return l;let d=a===void 0?{type:o||N(Error().stack)||`anonymous`}:typeof a==`string`?{type:a}:a;return s===void 0?(u?.send(d,r()),l):(u?.send({...d,type:`${s}/${d.type}`},{...ue(c.name),[s]:i.getState()}),l)}),i.devtools={cleanup:()=>{u&&typeof u.unsubscribe==`function`&&u.unsubscribe(),fe(c.name,s)}};let p=(...e)=>{let t=f;f=!1,n(...e),f=t},m=e(i.setState,r,i);if(d.type===`untracked`?u?.init(m):(d.stores[d.store]=i,u?.init(Object.fromEntries(Object.entries(d.stores).map(([e,t])=>[e,e===d.store?m:t.getState()])))),ce(i)){let e=i.dispatch;i.dispatch=(...t)=>{e(...t)}}return u.subscribe(e=>{switch(e.type){case`ACTION`:if(typeof e.payload!=`string`){console.error(`[zustand devtools middleware] Unsupported action format`);return}return he(e.payload,e=>{if(e.type===`__setState`){if(s===void 0){p(e.state);return}Object.keys(e.state).length!==1&&console.error(`
|
|
3
3
|
[zustand devtools middleware] Unsupported __setState action format.
|
|
4
4
|
When using 'store' option in devtools(), the 'state' should have only one key, which is a value of 'store' that was passed in devtools(),
|
|
5
5
|
and value of this only key should be a state object. Example: { "type": "__setState", "state": { "abc123Store": { "foo": "bar" } } }
|
|
6
|
-
`);let t=e.state[s];if(t==null)return;JSON.stringify(i.getState())!==JSON.stringify(t)&&p(t);return}ce(i)&&i.dispatch(e)});case`DISPATCH`:switch(e.payload.type){case`RESET`:return p(m),s===void 0?u?.init(i.getState()):u?.init(ue(c.name));case`COMMIT`:if(s===void 0){u?.init(i.getState());return}return u?.init(ue(c.name));case`ROLLBACK`:return he(e.state,e=>{if(s===void 0){p(e),u?.init(i.getState());return}p(e[s]),u?.init(ue(c.name))});case`JUMP_TO_STATE`:case`JUMP_TO_ACTION`:return he(e.state,e=>{if(s===void 0){p(e);return}JSON.stringify(i.getState())!==JSON.stringify(e[s])&&p(e[s])});case`IMPORT_STATE`:{let{nextLiftedState:t}=e.payload,n=t.computedStates.slice(-1)[0]?.state;if(!n)return;p(s===void 0?n:n[s]),u?.send(null,t);return}case`PAUSE_RECORDING`:return f=!f}return}}),m},he=(e,t)=>{let n;try{n=JSON.parse(e)}catch(e){console.error(`[zustand devtools middleware] Could not parse the received json`,e)}n!==void 0&&t(n)},ge=e=>(t,n,r)=>{let i=r.subscribe;return r.subscribe=((e,t,n)=>{let a=e;if(t){let i=n?.equalityFn||Object.is,o=e(r.getState());a=n=>{let r=e(n);if(!i(o,r)){let e=o;t(o=r,e)}},n?.fireImmediately&&t(o,o)}return i(a)}),e(t,n,r)},_e=()=>!1,ve=e=>{if(!_e())return!1;try{return localStorage.getItem(e)===`1`}catch{return!1}},P=(e,t,...n)=>{_e()&&ve(`bodhi_debug_verbose`)&&console.log(`${e} ${t}`,...n)},ye=`bodhi_api_v2_msgpack`,be=()=>{try{return localStorage.getItem(ye)===`1`}catch{return!1}},xe=e(r(),1),F=i(),Se=class extends Error{status;statusText;body;kind=`http`;constructor(e,t,n,r){super(e),this.status=t,this.statusText=n,this.body=r,this.name=`ApiError`}},Ce=class extends Error{kind=`network`;constructor(e){super(`A network error prevented the request. Check your connection and try again.`,{cause:e}),this.name=`NetworkRequestError`}},we=class extends Error{kind=`timeout`;constructor(e){super(`The request timed out. Please try again.`,{cause:e}),this.name=`RequestTimeoutError`}},Te=class extends Error{kind=`cancelled`;constructor(e){super(`The request was cancelled.`,{cause:e}),this.name=`RequestCancelledError`}};function Ee(e){return e instanceof Se}function De(e){return e instanceof we?`The request timed out. Please try again.`:e instanceof Te?`The request was cancelled.`:e instanceof Ce?`A network error prevented the request. Check your connection and try again.`:Ee(e)?e.status===401?`Authentication failed. Please check your credentials.`:e.status===403?`You don't have permission to perform this action.`:e.status===404?`The requested resource was not found.`:e.status>=500?e.message?.trim()?e.message:`Server error. Please try again later.`:e.message:e instanceof Error?e.message:`An unexpected error occurred`}var Oe=[/\/api\/v1\/respond\/[^/]+\/pending/,/\/api\/v1\/sessions\/?$/,/\/api\/v1\/events\/[^/]+/],ke=!1;function Ae(){return ke&&typeof localStorage<`u`&&localStorage.getItem(`lotus_debug_api_requests`)===`1`}function je(e){try{let t=new URL(e,typeof window<`u`?window.location.origin:`http://localhost`).pathname;return Oe.some(e=>e.test(t))}catch{return!1}}var Me={};function Ne(e,t){if(!Ae()||!je(t))return;let n=`${e} ${new URL(t,typeof window<`u`?window.location.origin:`http://localhost`).pathname}`;Me[n]=(Me[n]||0)+1,console.debug(`[ApiClient] ${e} ${n} (total: ${Me[n]})`)}var Pe=e=>{ke=e,!(!e||typeof window>`u`)&&(window.__lotusApiCounters=()=>(console.table(Me),{...Me}),window.__lotusResetApiCounters=()=>{Me={}})},I=class{baseUrl;defaultHeaders;requestCredentials;transport;constructor(e){this.baseUrl=e.baseUrl.trim().replace(/\/+$/,``),this.defaultHeaders=e.defaultHeaders??{"Content-Type":`application/json`},this.requestCredentials=e.requestCredentials,this.transport=e.transport}resolveUrl(e){let t=e.replace(/^\/+/,``);return`${this.baseUrl}/${t}`}mergeHeaders(e){let t=new Headers(this.defaultHeaders);return e&&new Headers(e).forEach((e,n)=>t.set(n,e)),t}createRequestInit(e,t,n){return{...t,method:e,headers:this.mergeHeaders(t?.headers),credentials:this.requestCredentials,...n?{body:n.value?JSON.stringify(n.value):void 0}:{}}}async handleResponse(e){if(!e.ok){let t=await e.text(),n=e.statusText;if(t)try{let r=JSON.parse(t),i=typeof r.error==`object`?r.error?.message:void 0,a=typeof r.error==`string`?r.error:void 0,o=typeof r.message==`string`?r.message:void 0,s=typeof r.detail==`string`?r.detail:void 0;n=a||(typeof i==`string`?i:void 0)||o||s||e.statusText}catch{n=t}throw new Se(n,e.status,e.statusText,t)}if(e.status!==204)return(e.headers?.get?.(`content-type`)||``).includes(`application/json`)?e.json():typeof e.text==`function`?await e.text():e.json()}async send(e,t,n,r){let i=this.resolveUrl(t);Ne(e.toUpperCase(),i);let a=await this.transport.request(i,this.createRequestInit(e,n,r));return this.handleResponse(a)}async get(e,t){return this.send(`GET`,e,t)}async post(e,t,n){return this.send(`POST`,e,n,{value:t})}async put(e,t,n){return this.send(`PUT`,e,n,{value:t})}async putOnce(e,t,n){let r=this.resolveUrl(e);Ne(`PUT`,r);let i=await this.transport.requestOnce(r,this.createRequestInit(`PUT`,n,{value:t}));return this.handleResponse(i)}async patch(e,t,n){return this.send(`PATCH`,e,n,{value:t})}async delete(e,t){return this.send(`DELETE`,e,t)}async request(e,t,n){return this.send(e,t,n)}async fetchRaw(e,t){let n=this.resolveUrl(e);Ne(t?.method?.toUpperCase()??`GET`,n);let r=await this.transport.requestOnce(n,{...t,headers:this.mergeHeaders(t?.headers),credentials:this.requestCredentials});if(!r.ok){let e=r.body?.cancel();throw e&&e.catch(()=>void 0),new Se(`API request failed: ${r.statusText}`,r.status,r.statusText)}return r}},Fe=new Set([`GET`,`HEAD`,`OPTIONS`,`PUT`,`DELETE`]),Ie=new Set([408,429,500,502,503,504]),Le=new Set([101,103,204,205,304]),L=3e4,Re=3,ze=2e3,Be=typeof ReadableStream>`u`?void 0:Object.getOwnPropertyDescriptor(ReadableStream.prototype,`locked`)?.get;function Ve(e){return 250*2**Math.max(0,e-1)}function He(e,t){if(!Number.isFinite(e)||e<=0)throw TypeError(`${t} must be a positive finite number.`)}function Ue(e,t){if(typeof DOMException<`u`)return new DOMException(t,e);let n=Error(t);return n.name=e,n}function We(e){return typeof e==`object`&&!!e&&`name`in e&&e.name===`TimeoutError`}function Ge(e,t){let n=new AbortController,r,i,a,o=(e,t)=>{r===void 0&&(r=e,i=t,n.abort(t))},s=()=>{let t=e?.reason;o(We(t)?`caller-timeout`:`caller-cancelled`,t)};return e?.aborted?s():(e?.addEventListener(`abort`,s,{once:!0}),a=setTimeout(()=>{o(`logical-timeout`,Ue(`TimeoutError`,`The logical request deadline elapsed.`))},t)),{signal:n.signal,get source(){return r},get cause(){return i},cleanup(){a!==void 0&&clearTimeout(a),e?.removeEventListener(`abort`,s)}}}function Ke(e,t){let n=e.cause??t;return e.source===`caller-timeout`||e.source===`logical-timeout`?new we(n):new Te(n)}function qe(e,t){return t.aborted?Promise.reject(t.reason):new Promise((n,r)=>{let i=()=>{t.removeEventListener(`abort`,i),r(t.reason)};t.addEventListener(`abort`,i,{once:!0}),e.then(e=>{t.removeEventListener(`abort`,i),n(e)},e=>{t.removeEventListener(`abort`,i),r(e)})})}function Je(e,t){return t.aborted?Promise.reject(t.reason):new Promise((n,r)=>{let i=setTimeout(()=>{t.removeEventListener(`abort`,a),n()},e),a=()=>{clearTimeout(i),t.removeEventListener(`abort`,a),r(t.reason)};t.addEventListener(`abort`,a,{once:!0})})}function R(e){if(typeof e!=`string`){if(typeof URL<`u`)try{URL.prototype.toString.call(e);return}catch{}throw TypeError(`HttpTransport input must be a string or URL; Request is unsupported.`)}}function Ye(e){if(e===null||typeof e!=`object`&&typeof e!=`function`)throw TypeError(`RequestInit must be an object.`);let t=e,n=Object.create(null),r,i,a,o=!1,s=!1,c=!1;for(let[t,l]of Object.entries(e)){if(t===`method`){r=l,o=!0;continue}if(t===`body`){i=l,s=!0;continue}if(t===`signal`){a=l,c=!0;continue}Object.defineProperty(n,t,{configurable:!0,enumerable:!0,value:l,writable:!0})}o||(r=t.method),s||(i=t.body),c||(a=t.signal);for(let[e,t]of[[`method`,r],[`body`,i]])Object.defineProperty(n,e,{configurable:!0,enumerable:!0,value:t,writable:!0});return{method:r,body:i,callerSignal:a,requestInit:n}}function Xe(e){if(e===void 0)return`GET`;if(typeof e==`string`)return e.replace(/[a-z]/g,e=>String.fromCharCode(e.charCodeAt(0)-32))}function Ze(e){if(typeof e!=`object`||!e)return!1;if(Be)try{return Be.call(e),!0}catch{}try{let t=new Set,n=e;for(;n!==null;){if(t.has(n)||(t.add(n),Object.getOwnPropertyDescriptor(n,`getReader`)!==void 0))return!0;n=Object.getPrototypeOf(n)}return!1}catch{return!0}}async function Qe(e,t){try{let n=e.body?.cancel();n&&await qe(n,t)}catch(e){if(t.aborted)throw e}}function $e(e,t){if(Le.has(e.status)||!e.body)return t.cleanup(),e;let n;try{n=e.body.getReader()}catch(n){let r=new Ce(n);throw e.body.cancel(n).catch(()=>void 0),t.cleanup(),r}let r=!1,i,a=()=>r?!1:(r=!0,t.signal.removeEventListener(`abort`,o),t.cleanup(),!0),o=()=>{let e=Ke(t,t.signal.reason);if(a()){n.cancel(t.signal.reason).catch(()=>void 0);try{i?.error(e)}catch{}}},s;try{s=new ReadableStream({start(e){i=e,t.signal.addEventListener(`abort`,o,{once:!0}),t.signal.aborted&&o()},async pull(e){try{let t=await n.read();if(r)return;if(t.done){a();try{e.close()}catch{}}else e.enqueue(t.value)}catch(n){if(!a())return;try{e.error(t.signal.aborted?Ke(t,n):new Ce(n))}catch{}}},async cancel(e){a(),await n.cancel(e)}})}catch(t){let r=new Ce(t);throw a(),n.releaseLock(),e.body.cancel(t).catch(()=>void 0),r}let c;try{c=new Response(s,{headers:e.headers,status:e.status,statusText:e.statusText})}catch(e){let t=new Ce(e);if(a()){n.cancel(e).catch(()=>void 0);try{i?.error(t)}catch{}}throw t}for(let[t,n]of[[`redirected`,e.redirected],[`type`,e.type],[`url`,e.url]])try{Object.defineProperty(c,t,{configurable:!0,enumerable:!0,value:n})}catch{}return c}var et=class{fetchImplementation;logicalTimeoutMs;totalAttempts;retryDelayMs;maxRetryDelayMs;constructor(e){let t=e.logicalTimeoutMs??L,n=e.totalAttempts??Re,r=e.maxRetryDelayMs??ze;if(He(t,`logicalTimeoutMs`),He(n,`totalAttempts`),He(r,`maxRetryDelayMs`),!Number.isInteger(n))throw TypeError(`totalAttempts must be an integer.`);this.fetchImplementation=e.fetchImplementation,this.logicalTimeoutMs=t,this.totalAttempts=n,this.retryDelayMs=e.retryDelayMs??Ve,this.maxRetryDelayMs=r}request(e,t={}){return this.execute(e,t,this.totalAttempts)}requestOnce(e,t={}){return this.execute(e,t,1)}async execute(e,t,n){R(e);let r;try{r=Ye(t)}catch(e){throw new Ce(e)}let i=Xe(r.method),a=i!==void 0&&Fe.has(i)&&!Ze(r.body)?n:1,o=Ge(r.callerSignal,this.logicalTimeoutMs),s=Object.freeze({...r.requestInit,signal:o.signal}),c=!1;try{if(o.signal.aborted)throw Ke(o);for(let t=1;t<=a;t+=1)try{if(o.signal.aborted)throw Ke(o);let n=await qe(Promise.resolve(this.fetchImplementation(e,s)),o.signal);if(!(t<a&&Ie.has(n.status))){let e=$e(n,o);return c=!0,e}await Qe(n,o.signal),await this.waitBeforeRetry(t,o.signal)}catch(e){if(o.signal.aborted)throw Ke(o,e);if(e instanceof Ce||e instanceof we||e instanceof Te)throw e;if(t>=a)throw new Ce(e);try{await this.waitBeforeRetry(t,o.signal)}catch(e){throw o.signal.aborted?Ke(o,e):e}}throw new Ce}finally{c||o.cleanup()}}waitBeforeRetry(e,t){let n=this.retryDelayMs(e);return Je(Number.isFinite(n)?Math.min(this.maxRetryDelayMs,Math.max(0,n)):this.maxRetryDelayMs,t)}};function tt(){return new et({fetchImplementation:(e,t)=>globalThis.fetch(e,t)})}var nt=a();Pe(nt.publicMetadata.development);var rt=tt(),z=new I({baseUrl:nt.endpoints.nativeApi,requestCredentials:nt.auth.requestCredentials,transport:rt});function it(e){let t=e.length,n=0,r=0;for(;r<t;){let i=e.charCodeAt(r++);if(!(i&4294967168)){n++;continue}else if(!(i&4294965248))n+=2;else{if(i>=55296&&i<=56319&&r<t){let t=e.charCodeAt(r);(t&64512)==56320&&(++r,i=((i&1023)<<10)+(t&1023)+65536)}i&4294901760?n+=4:n+=3}}return n}function at(e,t,n){let r=e.length,i=n,a=0;for(;a<r;){let n=e.charCodeAt(a++);if(!(n&4294967168)){t[i++]=n;continue}else if(!(n&4294965248))t[i++]=n>>6&31|192;else{if(n>=55296&&n<=56319&&a<r){let t=e.charCodeAt(a);(t&64512)==56320&&(++a,n=((n&1023)<<10)+(t&1023)+65536)}n&4294901760?(t[i++]=n>>18&7|240,t[i++]=n>>12&63|128,t[i++]=n>>6&63|128):(t[i++]=n>>12&15|224,t[i++]=n>>6&63|128)}t[i++]=n&63|128}}var ot=new TextEncoder,st=50;function ct(e,t,n){ot.encodeInto(e,t.subarray(n))}function lt(e,t,n){e.length>st?ct(e,t,n):at(e,t,n)}var B=4096;function ut(e,t,n){let r=t,i=r+n,a=[],o=``;for(;r<i;){let t=e[r++];if(!(t&128))a.push(t);else if((t&224)==192){let n=e[r++]&63;a.push((t&31)<<6|n)}else if((t&240)==224){let n=e[r++]&63,i=e[r++]&63;a.push((t&31)<<12|n<<6|i)}else if((t&248)==240){let n=e[r++]&63,i=e[r++]&63,o=e[r++]&63,s=(t&7)<<18|n<<12|i<<6|o;s>65535&&(s-=65536,a.push(s>>>10&1023|55296),s=56320|s&1023),a.push(s)}else a.push(t);a.length>=B&&(o+=String.fromCharCode(...a),a.length=0)}return a.length>0&&(o+=String.fromCharCode(...a)),o}var dt=new TextDecoder,ft=200;function pt(e,t,n){let r=e.subarray(t,t+n);return dt.decode(r)}function mt(e,t,n){return n>ft?pt(e,t,n):ut(e,t,n)}var ht=class{type;data;constructor(e,t){this.type=e,this.data=t}},gt=class e extends Error{constructor(t){super(t);let n=Object.create(e.prototype);Object.setPrototypeOf(this,n),Object.defineProperty(this,"name",{configurable:!0,enumerable:!1,value:e.name})}};function _t(e,t,n){let r=n/4294967296,i=n;e.setUint32(t,r),e.setUint32(t+4,i)}function vt(e,t,n){let r=Math.floor(n/4294967296),i=n;e.setUint32(t,r),e.setUint32(t+4,i)}function yt(e,t){let n=e.getInt32(t),r=e.getUint32(t+4);return n*4294967296+r}function V(e,t){let n=e.getUint32(t),r=e.getUint32(t+4);return n*4294967296+r}var bt=4294967295,xt=17179869183;function St({sec:e,nsec:t}){if(e>=0&&t>=0&&e<=xt)if(t===0&&e<=bt){let t=new Uint8Array(4);return new DataView(t.buffer).setUint32(0,e),t}else{let n=e/4294967296,r=e&4294967295,i=new Uint8Array(8),a=new DataView(i.buffer);return a.setUint32(0,t<<2|n&3),a.setUint32(4,r),i}else{let n=new Uint8Array(12),r=new DataView(n.buffer);return r.setUint32(0,t),vt(r,4,e),n}}function Ct(e){let t=e.getTime(),n=Math.floor(t/1e3),r=(t-n*1e3)*1e6,i=Math.floor(r/1e9);return{sec:n+i,nsec:r-i*1e9}}function wt(e){return e instanceof Date?St(Ct(e)):null}function Tt(e){let t=new DataView(e.buffer,e.byteOffset,e.byteLength);switch(e.byteLength){case 4:return{sec:t.getUint32(0),nsec:0};case 8:{let e=t.getUint32(0),n=t.getUint32(4);return{sec:(e&3)*4294967296+n,nsec:e>>>2}}case 12:return{sec:yt(t,4),nsec:t.getUint32(0)};default:throw new gt(`Unrecognized data size for timestamp (expected 4, 8, or 12): ${e.length}`)}}function Et(e){let t=Tt(e);return new Date(t.sec*1e3+t.nsec/1e6)}var H={type:-1,encode:wt,decode:Et},Dt=class e{static defaultCodec=new e;__brand;builtInEncoders=[];builtInDecoders=[];encoders=[];decoders=[];constructor(){this.register(H)}register({type:e,encode:t,decode:n}){if(e>=0)this.encoders[e]=t,this.decoders[e]=n;else{let r=-1-e;this.builtInEncoders[r]=t,this.builtInDecoders[r]=n}}tryToEncode(e,t){for(let n=0;n<this.builtInEncoders.length;n++){let r=this.builtInEncoders[n];if(r!=null){let i=r(e,t);if(i!=null)return new ht(-1-n,i)}}for(let n=0;n<this.encoders.length;n++){let r=this.encoders[n];if(r!=null){let i=r(e,t);if(i!=null)return new ht(n,i)}}return e instanceof ht?e:null}decode(e,t,n){let r=t<0?this.builtInDecoders[-1-t]:this.decoders[t];return r?r(e,t,n):new ht(t,e)}};function Ot(e){return e instanceof ArrayBuffer||typeof SharedArrayBuffer<`u`&&e instanceof SharedArrayBuffer}function kt(e){return e instanceof Uint8Array?e:ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):Ot(e)?new Uint8Array(e):Uint8Array.from(e)}var At=class e{extensionCodec;context;useBigInt64;maxDepth;initialBufferSize;sortKeys;forceFloat32;ignoreUndefined;forceIntegerToFloat;pos;view;bytes;entered=!1;constructor(e){this.extensionCodec=e?.extensionCodec??Dt.defaultCodec,this.context=e?.context,this.useBigInt64=e?.useBigInt64??!1,this.maxDepth=e?.maxDepth??100,this.initialBufferSize=e?.initialBufferSize??2048,this.sortKeys=e?.sortKeys??!1,this.forceFloat32=e?.forceFloat32??!1,this.ignoreUndefined=e?.ignoreUndefined??!1,this.forceIntegerToFloat=e?.forceIntegerToFloat??!1,this.pos=0,this.view=new DataView(new ArrayBuffer(this.initialBufferSize)),this.bytes=new Uint8Array(this.view.buffer)}clone(){return new e({extensionCodec:this.extensionCodec,context:this.context,useBigInt64:this.useBigInt64,maxDepth:this.maxDepth,initialBufferSize:this.initialBufferSize,sortKeys:this.sortKeys,forceFloat32:this.forceFloat32,ignoreUndefined:this.ignoreUndefined,forceIntegerToFloat:this.forceIntegerToFloat})}reinitializeState(){this.pos=0}encodeSharedRef(e){if(this.entered)return this.clone().encodeSharedRef(e);try{return this.entered=!0,this.reinitializeState(),this.doEncode(e,1),this.bytes.subarray(0,this.pos)}finally{this.entered=!1}}encode(e){if(this.entered)return this.clone().encode(e);try{return this.entered=!0,this.reinitializeState(),this.doEncode(e,1),this.bytes.slice(0,this.pos)}finally{this.entered=!1}}doEncode(e,t){if(t>this.maxDepth)throw Error(`Too deep objects in depth ${t}`);e==null?this.encodeNil():typeof e==`boolean`?this.encodeBoolean(e):typeof e==`number`?this.forceIntegerToFloat?this.encodeNumberAsFloat(e):this.encodeNumber(e):typeof e==`string`?this.encodeString(e):this.useBigInt64&&typeof e==`bigint`?this.encodeBigInt64(e):this.encodeObject(e,t)}ensureBufferSizeToWrite(e){let t=this.pos+e;this.view.byteLength<t&&this.resizeBuffer(t*2)}resizeBuffer(e){let t=new ArrayBuffer(e),n=new Uint8Array(t),r=new DataView(t);n.set(this.bytes),this.view=r,this.bytes=n}encodeNil(){this.writeU8(192)}encodeBoolean(e){e===!1?this.writeU8(194):this.writeU8(195)}encodeNumber(e){!this.forceIntegerToFloat&&Number.isSafeInteger(e)?e>=0?e<128?this.writeU8(e):e<256?(this.writeU8(204),this.writeU8(e)):e<65536?(this.writeU8(205),this.writeU16(e)):e<4294967296?(this.writeU8(206),this.writeU32(e)):this.useBigInt64?this.encodeNumberAsFloat(e):(this.writeU8(207),this.writeU64(e)):e>=-32?this.writeU8(224|e+32):e>=-128?(this.writeU8(208),this.writeI8(e)):e>=-32768?(this.writeU8(209),this.writeI16(e)):e>=-2147483648?(this.writeU8(210),this.writeI32(e)):this.useBigInt64?this.encodeNumberAsFloat(e):(this.writeU8(211),this.writeI64(e)):this.encodeNumberAsFloat(e)}encodeNumberAsFloat(e){this.forceFloat32?(this.writeU8(202),this.writeF32(e)):(this.writeU8(203),this.writeF64(e))}encodeBigInt64(e){e>=BigInt(0)?(this.writeU8(207),this.writeBigUint64(e)):(this.writeU8(211),this.writeBigInt64(e))}writeStringHeader(e){if(e<32)this.writeU8(160+e);else if(e<256)this.writeU8(217),this.writeU8(e);else if(e<65536)this.writeU8(218),this.writeU16(e);else if(e<4294967296)this.writeU8(219),this.writeU32(e);else throw Error(`Too long string: ${e} bytes in UTF-8`)}encodeString(e){let t=it(e);this.ensureBufferSizeToWrite(5+t),this.writeStringHeader(t),lt(e,this.bytes,this.pos),this.pos+=t}encodeObject(e,t){let n=this.extensionCodec.tryToEncode(e,this.context);if(n!=null)this.encodeExtension(n);else if(Array.isArray(e))this.encodeArray(e,t);else if(ArrayBuffer.isView(e))this.encodeBinary(e);else if(typeof e==`object`)this.encodeMap(e,t);else throw Error(`Unrecognized object: ${Object.prototype.toString.apply(e)}`)}encodeBinary(e){let t=e.byteLength;if(t<256)this.writeU8(196),this.writeU8(t);else if(t<65536)this.writeU8(197),this.writeU16(t);else if(t<4294967296)this.writeU8(198),this.writeU32(t);else throw Error(`Too large binary: ${t}`);let n=kt(e);this.writeU8a(n)}encodeArray(e,t){let n=e.length;if(n<16)this.writeU8(144+n);else if(n<65536)this.writeU8(220),this.writeU16(n);else if(n<4294967296)this.writeU8(221),this.writeU32(n);else throw Error(`Too large array: ${n}`);for(let n of e)this.doEncode(n,t+1)}countWithoutUndefined(e,t){let n=0;for(let r of t)e[r]!==void 0&&n++;return n}encodeMap(e,t){let n=Object.keys(e);this.sortKeys&&n.sort();let r=this.ignoreUndefined?this.countWithoutUndefined(e,n):n.length;if(r<16)this.writeU8(128+r);else if(r<65536)this.writeU8(222),this.writeU16(r);else if(r<4294967296)this.writeU8(223),this.writeU32(r);else throw Error(`Too large map object: ${r}`);for(let r of n){let n=e[r];this.ignoreUndefined&&n===void 0||(this.encodeString(r),this.doEncode(n,t+1))}}encodeExtension(e){if(typeof e.data==`function`){let t=e.data(this.pos+6),n=t.length;if(n>=4294967296)throw Error(`Too large extension object: ${n}`);this.writeU8(201),this.writeU32(n),this.writeI8(e.type),this.writeU8a(t);return}let t=e.data.length;if(t===1)this.writeU8(212);else if(t===2)this.writeU8(213);else if(t===4)this.writeU8(214);else if(t===8)this.writeU8(215);else if(t===16)this.writeU8(216);else if(t<256)this.writeU8(199),this.writeU8(t);else if(t<65536)this.writeU8(200),this.writeU16(t);else if(t<4294967296)this.writeU8(201),this.writeU32(t);else throw Error(`Too large extension object: ${t}`);this.writeI8(e.type),this.writeU8a(e.data)}writeU8(e){this.ensureBufferSizeToWrite(1),this.view.setUint8(this.pos,e),this.pos++}writeU8a(e){let t=e.length;this.ensureBufferSizeToWrite(t),this.bytes.set(e,this.pos),this.pos+=t}writeI8(e){this.ensureBufferSizeToWrite(1),this.view.setInt8(this.pos,e),this.pos++}writeU16(e){this.ensureBufferSizeToWrite(2),this.view.setUint16(this.pos,e),this.pos+=2}writeI16(e){this.ensureBufferSizeToWrite(2),this.view.setInt16(this.pos,e),this.pos+=2}writeU32(e){this.ensureBufferSizeToWrite(4),this.view.setUint32(this.pos,e),this.pos+=4}writeI32(e){this.ensureBufferSizeToWrite(4),this.view.setInt32(this.pos,e),this.pos+=4}writeF32(e){this.ensureBufferSizeToWrite(4),this.view.setFloat32(this.pos,e),this.pos+=4}writeF64(e){this.ensureBufferSizeToWrite(8),this.view.setFloat64(this.pos,e),this.pos+=8}writeU64(e){this.ensureBufferSizeToWrite(8),_t(this.view,this.pos,e),this.pos+=8}writeI64(e){this.ensureBufferSizeToWrite(8),vt(this.view,this.pos,e),this.pos+=8}writeBigUint64(e){this.ensureBufferSizeToWrite(8),this.view.setBigUint64(this.pos,e),this.pos+=8}writeBigInt64(e){this.ensureBufferSizeToWrite(8),this.view.setBigInt64(this.pos,e),this.pos+=8}};function jt(e,t){return new At(t).encodeSharedRef(e)}function Mt(e){return`${e<0?`-`:``}0x${Math.abs(e).toString(16).padStart(2,`0`)}`}var Nt=16,Pt=16,Ft=class{hit=0;miss=0;caches;maxKeyLength;maxLengthPerKey;constructor(e=Nt,t=Pt){this.maxKeyLength=e,this.maxLengthPerKey=t,this.caches=[];for(let e=0;e<this.maxKeyLength;e++)this.caches.push([])}canBeCached(e){return e>0&&e<=this.maxKeyLength}find(e,t,n){let r=this.caches[n-1];FIND_CHUNK:for(let i of r){let r=i.bytes;for(let i=0;i<n;i++)if(r[i]!==e[t+i])continue FIND_CHUNK;return i.str}return null}store(e,t){let n=this.caches[e.length-1],r={bytes:e,str:t};n.length>=this.maxLengthPerKey?n[Math.random()*n.length|0]=r:n.push(r)}decode(e,t,n){let r=this.find(e,t,n);if(r!=null)return this.hit++,r;this.miss++;let i=ut(e,t,n),a=Uint8Array.prototype.slice.call(e,t,t+n);return this.store(a,i),i}},It=`array`,U=`map_key`,Lt=`map_value`,Rt=e=>{if(typeof e==`string`||typeof e==`number`)return e;throw new gt(`The type of key must be string or number but `+typeof e)},zt=class{stack=[];stackHeadPosition=-1;get length(){return this.stackHeadPosition+1}top(){return this.stack[this.stackHeadPosition]}pushArrayState(e){let t=this.getUninitializedStateFromPool();t.type=It,t.position=0,t.size=e,t.array=Array(e)}pushMapState(e){let t=this.getUninitializedStateFromPool();t.type=U,t.readCount=0,t.size=e,t.map={}}getUninitializedStateFromPool(){return this.stackHeadPosition++,this.stackHeadPosition===this.stack.length&&this.stack.push({type:void 0,size:0,array:void 0,position:0,readCount:0,map:void 0,key:null}),this.stack[this.stackHeadPosition]}release(e){if(this.stack[this.stackHeadPosition]!==e)throw Error(`Invalid stack state. Released state is not on top of the stack.`);if(e.type===It){let t=e;t.size=0,t.array=void 0,t.position=0,t.type=void 0}if(e.type===U||e.type===Lt){let t=e;t.size=0,t.map=void 0,t.readCount=0,t.type=void 0}this.stackHeadPosition--}reset(){this.stack.length=0,this.stackHeadPosition=-1}},Bt=-1,Vt=new DataView(new ArrayBuffer(0)),Ht=new Uint8Array(Vt.buffer);try{Vt.getInt8(0)}catch(e){if(!(e instanceof RangeError))throw Error(`This module is not supported in the current JavaScript engine because DataView does not throw RangeError on out-of-bounds access`)}var Ut=RangeError(`Insufficient data`),Wt=new Ft,Gt=class e{extensionCodec;context;useBigInt64;rawStrings;maxStrLength;maxBinLength;maxArrayLength;maxMapLength;maxExtLength;keyDecoder;mapKeyConverter;totalPos=0;pos=0;view=Vt;bytes=Ht;headByte=Bt;stack=new zt;entered=!1;constructor(e){this.extensionCodec=e?.extensionCodec??Dt.defaultCodec,this.context=e?.context,this.useBigInt64=e?.useBigInt64??!1,this.rawStrings=e?.rawStrings??!1,this.maxStrLength=e?.maxStrLength??4294967295,this.maxBinLength=e?.maxBinLength??4294967295,this.maxArrayLength=e?.maxArrayLength??4294967295,this.maxMapLength=e?.maxMapLength??4294967295,this.maxExtLength=e?.maxExtLength??4294967295,this.keyDecoder=e?.keyDecoder===void 0?Wt:e.keyDecoder,this.mapKeyConverter=e?.mapKeyConverter??Rt}clone(){return new e({extensionCodec:this.extensionCodec,context:this.context,useBigInt64:this.useBigInt64,rawStrings:this.rawStrings,maxStrLength:this.maxStrLength,maxBinLength:this.maxBinLength,maxArrayLength:this.maxArrayLength,maxMapLength:this.maxMapLength,maxExtLength:this.maxExtLength,keyDecoder:this.keyDecoder})}reinitializeState(){this.totalPos=0,this.headByte=Bt,this.stack.reset()}setBuffer(e){let t=kt(e);this.bytes=t,this.view=new DataView(t.buffer,t.byteOffset,t.byteLength),this.pos=0}appendBuffer(e){if(this.headByte===Bt&&!this.hasRemaining(1))this.setBuffer(e);else{let t=this.bytes.subarray(this.pos),n=kt(e),r=new Uint8Array(t.length+n.length);r.set(t),r.set(n,t.length),this.setBuffer(r)}}hasRemaining(e){return this.view.byteLength-this.pos>=e}createExtraByteError(e){let{view:t,pos:n}=this;return RangeError(`Extra ${t.byteLength-n} of ${t.byteLength} byte(s) found at buffer[${e}]`)}decode(e){if(this.entered)return this.clone().decode(e);try{this.entered=!0,this.reinitializeState(),this.setBuffer(e);let t=this.doDecodeSync();if(this.hasRemaining(1))throw this.createExtraByteError(this.pos);return t}finally{this.entered=!1}}*decodeMulti(e){if(this.entered){yield*this.clone().decodeMulti(e);return}try{for(this.entered=!0,this.reinitializeState(),this.setBuffer(e);this.hasRemaining(1);)yield this.doDecodeSync()}finally{this.entered=!1}}async decodeAsync(e){if(this.entered)return this.clone().decodeAsync(e);try{this.entered=!0;let t=!1,n;for await(let r of e){if(t)throw this.entered=!1,this.createExtraByteError(this.totalPos);this.appendBuffer(r);try{n=this.doDecodeSync(),t=!0}catch(e){if(!(e instanceof RangeError))throw e}this.totalPos+=this.pos}if(t){if(this.hasRemaining(1))throw this.createExtraByteError(this.totalPos);return n}let{headByte:r,pos:i,totalPos:a}=this;throw RangeError(`Insufficient data in parsing ${Mt(r)} at ${a} (${i} in the current buffer)`)}finally{this.entered=!1}}decodeArrayStream(e){return this.decodeMultiAsync(e,!0)}decodeStream(e){return this.decodeMultiAsync(e,!1)}async*decodeMultiAsync(e,t){if(this.entered){yield*this.clone().decodeMultiAsync(e,t);return}try{this.entered=!0;let n=t,r=-1;for await(let i of e){if(t&&r===0)throw this.createExtraByteError(this.totalPos);this.appendBuffer(i),n&&(r=this.readArraySize(),n=!1,this.complete());try{for(;yield this.doDecodeSync(),--r!==0;);}catch(e){if(!(e instanceof RangeError))throw e}this.totalPos+=this.pos}}finally{this.entered=!1}}doDecodeSync(){DECODE:for(;;){let e=this.readHeadByte(),t;if(e>=224)t=e-256;else if(e<192)if(e<128)t=e;else if(e<144){let n=e-128;if(n!==0){this.pushMapState(n),this.complete();continue DECODE}else t={}}else if(e<160){let n=e-144;if(n!==0){this.pushArrayState(n),this.complete();continue DECODE}else t=[]}else{let n=e-160;t=this.decodeString(n,0)}else if(e===192)t=null;else if(e===194)t=!1;else if(e===195)t=!0;else if(e===202)t=this.readF32();else if(e===203)t=this.readF64();else if(e===204)t=this.readU8();else if(e===205)t=this.readU16();else if(e===206)t=this.readU32();else if(e===207)t=this.useBigInt64?this.readU64AsBigInt():this.readU64();else if(e===208)t=this.readI8();else if(e===209)t=this.readI16();else if(e===210)t=this.readI32();else if(e===211)t=this.useBigInt64?this.readI64AsBigInt():this.readI64();else if(e===217){let e=this.lookU8();t=this.decodeString(e,1)}else if(e===218){let e=this.lookU16();t=this.decodeString(e,2)}else if(e===219){let e=this.lookU32();t=this.decodeString(e,4)}else if(e===220){let e=this.readU16();if(e!==0){this.pushArrayState(e),this.complete();continue DECODE}else t=[]}else if(e===221){let e=this.readU32();if(e!==0){this.pushArrayState(e),this.complete();continue DECODE}else t=[]}else if(e===222){let e=this.readU16();if(e!==0){this.pushMapState(e),this.complete();continue DECODE}else t={}}else if(e===223){let e=this.readU32();if(e!==0){this.pushMapState(e),this.complete();continue DECODE}else t={}}else if(e===196){let e=this.lookU8();t=this.decodeBinary(e,1)}else if(e===197){let e=this.lookU16();t=this.decodeBinary(e,2)}else if(e===198){let e=this.lookU32();t=this.decodeBinary(e,4)}else if(e===212)t=this.decodeExtension(1,0);else if(e===213)t=this.decodeExtension(2,0);else if(e===214)t=this.decodeExtension(4,0);else if(e===215)t=this.decodeExtension(8,0);else if(e===216)t=this.decodeExtension(16,0);else if(e===199){let e=this.lookU8();t=this.decodeExtension(e,1)}else if(e===200){let e=this.lookU16();t=this.decodeExtension(e,2)}else if(e===201){let e=this.lookU32();t=this.decodeExtension(e,4)}else throw new gt(`Unrecognized type byte: ${Mt(e)}`);this.complete();let n=this.stack;for(;n.length>0;){let e=n.top();if(e.type===It)if(e.array[e.position]=t,e.position++,e.position===e.size)t=e.array,n.release(e);else continue DECODE;else if(e.type===U){if(t===`__proto__`)throw new gt(`The key __proto__ is not allowed`);e.key=this.mapKeyConverter(t),e.type=Lt;continue DECODE}else if(e.map[e.key]=t,e.readCount++,e.readCount===e.size)t=e.map,n.release(e);else{e.key=null,e.type=U;continue DECODE}}return t}}readHeadByte(){return this.headByte===Bt&&(this.headByte=this.readU8()),this.headByte}complete(){this.headByte=Bt}readArraySize(){let e=this.readHeadByte();switch(e){case 220:return this.readU16();case 221:return this.readU32();default:if(e<160)return e-144;throw new gt(`Unrecognized array type byte: ${Mt(e)}`)}}pushMapState(e){if(e>this.maxMapLength)throw new gt(`Max length exceeded: map length (${e}) > maxMapLengthLength (${this.maxMapLength})`);this.stack.pushMapState(e)}pushArrayState(e){if(e>this.maxArrayLength)throw new gt(`Max length exceeded: array length (${e}) > maxArrayLength (${this.maxArrayLength})`);this.stack.pushArrayState(e)}decodeString(e,t){return!this.rawStrings||this.stateIsMapKey()?this.decodeUtf8String(e,t):this.decodeBinary(e,t)}decodeUtf8String(e,t){if(e>this.maxStrLength)throw new gt(`Max length exceeded: UTF-8 byte length (${e}) > maxStrLength (${this.maxStrLength})`);if(this.bytes.byteLength<this.pos+t+e)throw Ut;let n=this.pos+t,r;return r=this.stateIsMapKey()&&this.keyDecoder?.canBeCached(e)?this.keyDecoder.decode(this.bytes,n,e):mt(this.bytes,n,e),this.pos+=t+e,r}stateIsMapKey(){return this.stack.length>0?this.stack.top().type===U:!1}decodeBinary(e,t){if(e>this.maxBinLength)throw new gt(`Max length exceeded: bin length (${e}) > maxBinLength (${this.maxBinLength})`);if(!this.hasRemaining(e+t))throw Ut;let n=this.pos+t,r=this.bytes.subarray(n,n+e);return this.pos+=t+e,r}decodeExtension(e,t){if(e>this.maxExtLength)throw new gt(`Max length exceeded: ext length (${e}) > maxExtLength (${this.maxExtLength})`);let n=this.view.getInt8(this.pos+t),r=this.decodeBinary(e,t+1);return this.extensionCodec.decode(r,n,this.context)}lookU8(){return this.view.getUint8(this.pos)}lookU16(){return this.view.getUint16(this.pos)}lookU32(){return this.view.getUint32(this.pos)}readU8(){let e=this.view.getUint8(this.pos);return this.pos++,e}readI8(){let e=this.view.getInt8(this.pos);return this.pos++,e}readU16(){let e=this.view.getUint16(this.pos);return this.pos+=2,e}readI16(){let e=this.view.getInt16(this.pos);return this.pos+=2,e}readU32(){let e=this.view.getUint32(this.pos);return this.pos+=4,e}readI32(){let e=this.view.getInt32(this.pos);return this.pos+=4,e}readU64(){let e=V(this.view,this.pos);return this.pos+=8,e}readI64(){let e=yt(this.view,this.pos);return this.pos+=8,e}readU64AsBigInt(){let e=this.view.getBigUint64(this.pos);return this.pos+=8,e}readI64AsBigInt(){let e=this.view.getBigInt64(this.pos);return this.pos+=8,e}readF32(){let e=this.view.getFloat32(this.pos);return this.pos+=4,e}readF64(){let e=this.view.getFloat64(this.pos);return this.pos+=8,e}};function Kt(e,t){return new Gt(t).decode(e)}var qt=15e3,Jt=500,Yt=15e3,Xt=4e4,Zt=1e3,Qt=5e3,$t=`bamboo.v2.msgpack`,en=e=>typeof e==`object`&&!!e&&!Array.isArray(e),tn=e=>typeof e==`number`&&Number.isSafeInteger(e)&&e>0,nn=e=>{if(!tn(e.seq)||e.control!==void 0||!en(e.event))return null;let t=e.event;return!tn(t.seq)||t.seq!==e.seq||typeof t.ts!=`string`||t.session_id!==void 0&&typeof t.session_id!=`string`||!en(t.event)||typeof t.event.type!=`string`?null:t},rn=e=>e.seq!==0||e.event!==void 0||!en(e.control)||e.control.type!==`feed_reset`||!tn(e.control.from_seq)?null:e.control.from_seq,W=null,an=!1,on=0,sn=null,cn=!1,ln=!1,un=null,dn=new Set,fn=e=>(dn.add(e),()=>dn.delete(e)),pn=(e=W)=>{let t=un;return e!==null&&W===e&&e.readyState===WebSocket.OPEN&&t!==null&&t.socket===e&&t.phase===`ready`},G=null,mn=()=>pn()&&G!==null&&!G.deliveryFailed&&G.subscribedSince!==null,hn=new Map,gn=e=>`agent.${e}`,_n=()=>G!==null&&!G.deliveryFailed||hn.size>0,vn=e=>e.protocol===$t,yn=(e,t)=>{if(W===e&&e.readyState===WebSocket.OPEN)try{return e.send(vn(e)?jt(t):JSON.stringify(t)),!0}catch(e){P(`[v2Stream]`,`send.error`,{payload:t,error:e})}return!1},bn=e=>W!==null&&yn(W,e),xn=(e,t)=>{let n=e.since;return e.subscribedSince=null,e.acceptedInSubscription=!1,e.resetHandledInSubscription=!1,yn(t,{type:`subscribe`,ch:`feed`,since:n})?(e.subscribedSince=n,!0):!1},Sn=(e,t,n)=>{if(console.warn(`Failed to ${t} v2 feed:`,n),!(G!==e||e.deliveryFailed)){e.deliveryFailed=!0,e.subscribedSince=null,pn()&&bn({type:`unsubscribe`,ch:`feed`});try{e.handlers.onError?.()}catch(e){console.warn(`Failed to report v2 feed handler error:`,e)}Fn()}},Cn=e=>{if(G&&!G.deliveryFailed&&!xn(G,e))return!1;for(let t of hn.keys())if(!yn(e,{type:`subscribe`,ch:t}))return!1;return!0},wn=()=>{sn&&=(clearTimeout(sn),null)},Tn=()=>{if(!_n()||cn||sn)return;let e=Math.min(Jt*2**on,qt);on+=1,P(`[v2Stream]`,`reconnect.schedule`,{attempt:on,delay:e}),sn=setTimeout(()=>{sn=null,Vn()},e)},En=e=>{let t=un;!t||e&&t.socket!==e||(t.welcomeTimer!==null&&(clearTimeout(t.welcomeTimer),t.welcomeTimer=null),t.heartbeatTimer!==null&&(clearInterval(t.heartbeatTimer),t.heartbeatTimer=null),t.watchdogTimer!==null&&(clearInterval(t.watchdogTimer),t.watchdogTimer=null),t.visibilityListener&&typeof document<`u`&&(document.removeEventListener(`visibilitychange`,t.visibilityListener),t.visibilityListener=null),un===t&&(un=null))},Dn=e=>{let t=W;if(!t||e&&t!==e)return!1;En(t),t.onopen=null,t.onmessage=null,t.onerror=null,t.onclose=null;try{t.close()}catch{}return W===t&&(W=null),!0},On=()=>{try{G?.handlers.onError?.()}catch(e){P(`[v2Stream]`,`unavailable.listener_error`,{error:e})}},K=(e,t)=>{un!==e||W!==e.socket||e.recoveryStarted||(e.recoveryStarted=!0,G&&(G.subscribedSince=null,G.acceptedInSubscription=!1,G.resetHandledInSubscription=!1),ln=!0,P(`[v2Stream]`,`epoch.unavailable`,{reason:t}),On(),Dn(e.socket),an=!1,Tn())},kn=e=>{un!==e||W!==e.socket||e.recoveryStarted||(P(`[v2Stream]`,`watchdog.stale_socket`,{silentForMs:Date.now()-e.lastFrameAt}),K(e,`heartbeat-stale`))},An=e=>{un!==e||W!==e.socket||e.socket.readyState!==WebSocket.OPEN||e.phase!==`ready`||!e.heartbeatAckSeen||Date.now()-e.lastFrameAt>=Xt&&kn(e)},jn=e=>{En();let t={socket:e,phase:`awaiting-welcome`,lastFrameAt:Date.now(),pingSent:!1,heartbeatAckSeen:!1,recoveryStarted:!1,welcomeTimer:null,heartbeatTimer:null,watchdogTimer:null,visibilityListener:null};return un=t,t.welcomeTimer=setTimeout(()=>{un!==t||W!==e||t.phase!==`awaiting-welcome`||K(t,`welcome-timeout`)},Qt),t},Mn=e=>{let t=e.socket;e.welcomeTimer!==null&&(clearTimeout(e.welcomeTimer),e.welcomeTimer=null),e.lastFrameAt=Date.now(),e.heartbeatTimer=setInterval(()=>{un!==e||W!==t||t.readyState!==WebSocket.OPEN||e.phase!==`ready`||yn(t,{type:`ping`})&&(e.pingSent=!0)},Yt),e.watchdogTimer=setInterval(()=>An(e),Zt),typeof document<`u`&&(e.visibilityListener=()=>{document.visibilityState===`visible`&&An(e)},document.addEventListener(`visibilitychange`,e.visibilityListener))},Nn=e=>{let t=un;return!t||t.socket!==e||W!==e||t.phase!==`ready`?null:(t.lastFrameAt=Date.now(),t)},Pn=e=>{!e||!e.pingSent||e.heartbeatAckSeen||(e.heartbeatAckSeen=!0,P(`[v2Stream]`,`heartbeat.acknowledged`,{}))},Fn=()=>{_n()||(cn=!0,wn(),Dn(),En(),an=!1,on=0,ln=!1)},In=e=>{try{if(typeof e==`string`)return JSON.parse(e);if(e instanceof ArrayBuffer)return Kt(new Uint8Array(e));if(ArrayBuffer.isView(e)){let t=e;return Kt(new Uint8Array(t.buffer,t.byteOffset,t.byteLength))}P(`[v2Stream]`,`frame.unknown_data_type`,{});return}catch(t){console.warn(`Failed to parse v2 stream frame:`,e,t);return}},Ln=e=>en(e)&&Object.keys(e).length===1&&Object.prototype.hasOwnProperty.call(e,`type`)&&e.type===`welcome`,Rn=e=>en(e)&&e.type===`welcome`,zn=e=>{let t=e.socket;if(un!==e||W!==t||t.readyState!==WebSocket.OPEN||e.phase!==`awaiting-welcome`)return;if(e.welcomeTimer!==null&&(clearTimeout(e.welcomeTimer),e.welcomeTimer=null),e.phase=`subscribing`,!_n()){Fn();return}if(!Cn(t)){K(e,`subscribe-send-failed`);return}if(un!==e||W!==t||!_n()){Fn();return}e.phase=`ready`,on=0;let n=ln;if(ln=!1,Mn(e),P(`[v2Stream]`,`ready`,{afterDrop:n}),G&&!G.deliveryFailed&&G.subscribedSince!==null)try{G.handlers.onOpen?.()}catch(e){P(`[v2Stream]`,`feed.open_listener_error`,{error:e})}if(!(un!==e||W!==t||e.phase!==`ready`||!_n())&&n)for(let e of[...dn])try{e()}catch(e){P(`[v2Stream]`,`reconnected.listener_error`,{error:e})}},Bn=(e,t)=>{if(e?.type===`pong`&&e.ch===void 0){Pn(t);return}if(!e||typeof e.ch!=`string`){P(`[v2Stream]`,`frame.unknown`,{});return}let{ch:n,control:r,event:i}=e;if(n!==`sys`){if(n===`feed`){let t=G;if(!t||t.deliveryFailed||t.subscribedSince===null)return;if(r){let n=rn(e);if(n!==null&&n===t.subscribedSince&&!t.acceptedInSubscription&&!t.resetHandledInSubscription){P(`[v2Stream]`,`feed.reset`,{});let e=t.handlers.onReset;if(!e){Sn(t,`apply reset`,Error(`feed_reset requires an application reset handler`));return}let r=t.since;t.since=0;try{e()}catch(e){t.since=r,Sn(t,`apply reset`,e);return}G===t&&!t.deliveryFailed&&(t.resetHandledInSubscription=!0,t.postResetFloor=n)}else P(`[v2Stream]`,`feed.control.invalid`,{});return}let n=nn(e);if(!n){P(`[v2Stream]`,`feed.frame.invalid_event`,{});return}let i=Math.max(t.since,t.postResetFloor??0);if(n.seq<=i){P(`[v2Stream]`,`feed.frame.stale`,{seq:n.seq,since:i});return}try{t.handlers.onChange(n)}catch(e){Sn(t,`apply event`,e);return}G===t&&(t.since=n.seq,t.acceptedInSubscription=!0,t.postResetFloor=null);return}if(n.startsWith(`agent.`)){let e=hn.get(n);if(!e||e.size===0)return;if(r){if(r.type===`terminal`){P(`[v2Stream]`,`agent.terminal`,{ch:n,subscribers:e.size});for(let t of[...e])t.resolve()}return}if(i===void 0){P(`[v2Stream]`,`agent.frame.no_event`,{});return}for(let t of[...e])try{t.dispatch(i,t.handlers)}catch(e){console.warn(`Failed to dispatch v2 agent event:`,i,e)}return}P(`[v2Stream]`,`frame.unknown_channel`,{ch:n})}},Vn=()=>{if(!_n()||W&&(W.readyState===WebSocket.OPEN||W.readyState===WebSocket.CONNECTING)||an)return;if(typeof WebSocket>`u`){P(`[v2Stream]`,`connect.no_websocket`,{});return}an=!0,cn=!1;let e=a().endpoints.v2Stream;P(`[v2Stream]`,`connect`,{url:e});let t=be(),n;try{n=t?new WebSocket(e,[$t]):new WebSocket(e),t&&(n.binaryType=`arraybuffer`)}catch(e){an=!1,P(`[v2Stream]`,`connect.error`,{error:e}),G?.handlers.onError?.(),Tn();return}W=n,n.onopen=()=>{if(W!==n)return;an=!1;let e=jn(n);P(`[v2Stream]`,`open.awaiting_welcome`,{}),yn(n,{type:`hello`})||K(e,`hello-send-failed`)},n.onmessage=e=>{if(W!==n)return;let t=In(e.data),r=un;if(!(!r||r.socket!==n)){if(r.phase===`awaiting-welcome`){Ln(t)?zn(r):P(`[v2Stream]`,`frame.before_welcome`,{});return}r.phase!==`subscribing`&&(Rn(t)||Bn(t,Nn(n)))}},n.onerror=()=>{W===n&&(P(`[v2Stream]`,`error`,{}),On())},n.onclose=()=>{W===n&&(an=!1,En(n),P(`[v2Stream]`,`close`,{intentional:cn}),W=null,!cn&&(ln=!0,G&&(G.subscribedSince=null),On(),Tn()))}},Hn=(e,t)=>{G={handlers:e,since:tn(t)?t:0,deliveryFailed:!1,subscribedSince:null,acceptedInSubscription:!1,resetHandledInSubscription:!1,postResetFloor:null};let n=G;if(W&&pn(W)){if(!xn(n,W)){let e=un;e&&K(e,`feed-subscribe-send-failed`)}}else Vn();let r=!1;return{close(){r||(r=!0,G===n&&(G=null,pn()&&bn({type:`unsubscribe`,ch:`feed`}),Fn()))}}},Un=(e,t,n)=>{let r=gn(e),i=!1,a=()=>{},o={sessionId:e,handlers:t,dispatch:n,resolve:()=>a()},s=new Promise(e=>{a=()=>{if(i)return;i=!0;let t=hn.get(r);t?.delete(o),(!t||t.size===0)&&(hn.delete(r),pn()&&bn({type:`unsubscribe`,ch:r}),Fn()),e()}}),c=hn.get(r),l=!c||c.size===0;if(c?c.add(o):hn.set(r,new Set([o])),W&&pn(W)){if(l&&!yn(W,{type:`subscribe`,ch:r})){let e=un;e&&K(e,`agent-subscribe-send-failed`)}}else Vn();return{promise:s,close:()=>a()}},Wn=e=>e==="default"||e===`bypass`||e===`auto`?e:null,Gn=e=>{if(typeof e!=`string`||!/^"\d{1,20}"$/.test(e))return null;let t=BigInt(e.slice(1,-1));return t<=18446744073709551615n?t:null},Kn=class extends Error{constructor(){super(`The backend did not confirm a supported, revisioned session permission mode.`),this.name=`SessionPermissionContractError`}},qn=async(e,t)=>{let n=await t.json(),r=n&&typeof n==`object`&&`session`in n?n.session:null,i=r&&typeof r==`object`&&`permission_mode`in r?Wn(r.permission_mode):null,a=t.headers.get(`ETag`);if(!r||typeof r!=`object`||!(`id`in r)||r.id!==e||!i||!a||Gn(a)===null)throw new Kn;return{sessionId:e,mode:i,etag:a}},Jn=class extends Error{constructor(){super(`无法确认当前请求,请刷新后重试。`),this.name=`PendingInteractionContractError`}},Yn=e=>typeof e==`object`&&e&&!Array.isArray(e)?e:null,Xn=e=>typeof e==`string`&&e.trim().length>0,Zn=e=>typeof e==`number`&&Number.isSafeInteger(e)&&e>=0;function Qn(e,t){let n=Yn(t);if(!n)throw new Jn;if(n.has_pending_question===!1&&n.interaction_kind==null&&n.permission_request==null)return{has_pending_question:!1};if(n.has_pending_question!==!0||typeof n.question!=`string`||!Array.isArray(n.options)||!n.options.every(e=>typeof e==`string`)||typeof n.allow_custom!=`boolean`||!Xn(n.tool_call_id))throw new Jn;if(n.interaction_kind===`clarification`&&n.permission_request==null)return n;let r=Yn(n.permission_request);if(n.interaction_kind!==`permission`||!r||r.session_id!==e||r.request_id!==n.tool_call_id||!Xn(r.request_generation)||!Zn(r.policy_revision)||![`tool_name`,`permission_type`,`resource`,`operation_summary`].every(e=>typeof r[e]==`string`)||!Array.isArray(r.allowed_decisions)||!r.allowed_decisions.every(e=>typeof e==`string`))throw new Jn;return n}var $n=e=>e?{client_message_count:e.client_message_count,client_last_message_id:e.client_last_message_id??null,client_has_pending_question:e.client_has_pending_question,client_pending_question_tool_call_id:e.client_pending_question_tool_call_id??null}:null,er=e=>e?{need_sync:e.need_sync,reason:e.reason??null,server_message_count:e.server_message_count,server_last_message_id:e.server_last_message_id??null,has_pending_question:e.has_pending_question,pending_question_tool_call_id:e.pending_question_tool_call_id??null,has_pending_user_message:e.has_pending_user_message}:null,tr=e=>{let t=e.messages[e.messages.length-1];return{session_id:e.session_id,messageCount:e.messages.length,lastMessageId:t?.id??null,lastRole:t?.role??null,compressionEvents:e.compression_events?.length??0}},nr=e=>({count:e.length,runningCount:e.filter(e=>e.is_running).length,sessions:e.slice(0,10).map(e=>({id:e.id,is_running:e.is_running,last_run_status:e.last_run_status??null,message_count:e.message_count,has_pending_question:e.has_pending_question??!1,running_child_count:e.running_child_count??0,updated_at:e.updated_at}))}),rr=e=>({count:e.sessions.length,sessions:e.sessions.map(e=>({session_id:e.session_id,run_id:e.run_id,round_count:e.round_count,last_event_at:e.last_event_at??null,last_tool_name:e.last_tool_name??null,last_tool_phase:e.last_tool_phase??null,criticalEventCount:e.last_critical_events.length,runningChildCount:e.running_child_session_ids.length}))}),ir=e=>({type:e.type,session_id:e.session_id??null,run_id:e.run_id??null,round_count:e.round_count??null,message:e.message??null,error:e.error??null,tool_call_id:e.tool_call_id??null}),ar=class e{static instance;static getInstance(){return e.instance||=new e,e.instance}async sendMessage(e){P(`[AgentClient]`,`chat.request`,{sessionId:e.session_id??null,model:e.model,modelRef:e.model_ref??null,provider:e.provider??null,messageLength:e.message.length,hasImages:(e.images?.length??0)>0,imageCount:e.images?.length??0,selectedSkillCount:e.selected_skill_ids?.length??0,workspacePath:e.workspace_path??null});let t=await z.post(`chat`,e);return P(`[AgentClient]`,`chat.response`,{requestedSessionId:e.session_id??null,sessionId:t.session_id,status:t.status}),t}async execute(e,t,n,r,i){let a={};t&&(a.model=t),n&&(a.reasoning_effort=n),r&&(a.client_sync=r),i&&(a.model_ref=i,a.provider=i.provider),P(`[AgentClient]`,`execute.request`,{sessionId:e,model:a.model??null,reasoningEffort:a.reasoning_effort??null,modelRef:a.model_ref??null,provider:a.provider??null,clientSync:$n(a.client_sync)});let o=await z.post(`execute/${e}`,a);return P(`[AgentClient]`,`execute.response`,{sessionId:e,status:o.status,runId:o.run_id??null,eventsUrl:o.events_url,sync:er(o.sync)}),o}async listSessions(){P(`[AgentClient]`,`sessions.list.request`,{});let e=await z.get(`sessions`);return P(`[AgentClient]`,`sessions.list.response`,nr(e.sessions)),e}async getTaskList(e){let t=encodeURIComponent(e),n=await z.get(`task/${t}`);if(!(typeof n.title==`string`||n.items.length>0))return null;let r=new Date().toISOString();return{session_id:n.session_id,title:n.title??`Task List`,items:n.items,created_at:r,updated_at:r}}async getPendingQuestion(e){let t=encodeURIComponent(e);return Qn(e,await z.get(`respond/${t}/pending`,{cache:`no-store`}))}async submitPermissionDecision(e,t){if(!Xn(t.request_id)||!Xn(t.request_generation)||!Zn(t.expected_policy_revision)||t.decision!==`allow_once`&&t.decision!==`deny_once`)throw new Jn;let n=Yn(await z.post(`sessions/${encodeURIComponent(e)}/permission-decisions`,t)),r=Yn(n?.receipt),i=Yn(r?.decision);if(n?.success!==!0||typeof n.replayed!=`boolean`||r?.session_id!==e||i?.request_id!==t.request_id||i?.request_generation!==t.request_generation||i?.decision!==t.decision||i?.matcher_id!=null||i?.expected_policy_revision!=null&&!Zn(i.expected_policy_revision)||i?.confirm_global!=null&&i.confirm_global!==!1)throw new Jn;let a=Yn(n.resume),o=a?.auto_resume_status,s=n.replayed&&n.resume==null&&n.auto_resume_status==null||a?.success===!0&&typeof o==`string`&&[`started`,`already_running`,`completed`].includes(o)&&n.auto_resume_status===o;return{replayed:n.replayed,autoResumeStatus:typeof o==`string`?o:void 0,continuationConfirmed:s}}async createSession(e){return z.post(`sessions`,e)}async patchSession(e,t){let n=encodeURIComponent(e);await z.patch(`sessions/${n}`,t)}async getSessionPermissionMode(e){return qn(e,await z.fetchRaw(`sessions/${encodeURIComponent(e)}`,{cache:`no-store`}))}async patchSessionPermissionMode(e,t,n){if(!Wn(t)||Gn(n)===null)throw new Kn;let r={permission_mode:t};return qn(e,await z.fetchRaw(`sessions/${encodeURIComponent(e)}`,{method:`PATCH`,headers:{"If-Match":n},body:JSON.stringify(r),cache:`no-store`}))}async regenerateSessionTitle(e){let t=encodeURIComponent(e);await z.post(`sessions/${t}/regenerate-title`)}async getSessionSystemPrompt(e){let t=encodeURIComponent(e);return z.get(`sessions/${t}/system-prompt`)}async clearSession(e){let t=encodeURIComponent(e);await z.post(`sessions/${t}/clear`)}async runProjectDream(e){let t=encodeURIComponent(e);return z.post(`sessions/${t}/project-dream/run`)}async truncateSessionMessages(e,t){let n=encodeURIComponent(e);return z.post(`sessions/${n}/messages/truncate`,t)}async restoreSessionState(e,t){let n=encodeURIComponent(e);return z.post(`sessions/${n}/restore`,t)}async patchSessionMessage(e,t,n){let r=encodeURIComponent(e),i=encodeURIComponent(t);await z.patch(`sessions/${r}/messages/${i}`,n)}async deleteSessionMessage(e,t){let n=encodeURIComponent(e),r=encodeURIComponent(t);await z.delete(`sessions/${n}/messages/${r}`)}async cleanupSessions(e,t){await z.post(`sessions/cleanup`,{mode:e,keep_pinned:t})}async respondToChildApproval(e,t,n){return z.post(`child-approval/${encodeURIComponent(e)}`,{request_id:t,approved:n})}async devResetSessions(){await z.post(`dev/reset`)}async getRunningSessions(){P(`[AgentClient]`,`runs.active.request`,{});let e=await z.get(`runs/active`);return P(`[AgentClient]`,`runs.active.response`,rr(e)),e}async listSchedules(){return z.get(`schedules`)}async createSchedule(e){return z.post(`schedules`,e)}async patchSchedule(e,t){let n=encodeURIComponent(e);return z.patch(`schedules/${n}`,t)}async deleteSchedule(e){let t=encodeURIComponent(e);await z.delete(`schedules/${t}`)}async runScheduleNow(e){let t=encodeURIComponent(e);await z.post(`schedules/${t}/run`)}async listScheduleSessions(e){let t=encodeURIComponent(e);return z.get(`schedules/${t}/sessions`)}async listScheduleRuns(e){let t=encodeURIComponent(e);return z.get(`schedules/${t}/runs`)}async subscribeToEvents(e,t,n){let r=n?.signal;if(P(`[AgentClient]`,`events.subscribe.request`,{sessionId:e}),r?.aborted){P(`[AgentClient]`,`events.subscribe.ws.aborted_before_connect`,{sessionId:e});return}let{promise:i,close:a}=Un(e,t,(e,t)=>this.handleEvent(e,t)),o=()=>{P(`[AgentClient]`,`events.subscribe.ws.abort`,{sessionId:e}),a()};r?.addEventListener(`abort`,o,{once:!0});try{await i}finally{r?.removeEventListener(`abort`,o)}}subscribeToAccountStream(e,t){return Hn(e,t?.since??0)}handleEvent(e,t){switch(e.type){case`token`:t.onToken?.(e.content||``);break;case`reasoning_token`:t.onReasoningToken?.(e.content||``);break;case`tool_token`:t.onToolToken?.(e.tool_call_id||``,e.content||``);break;case`tool_start`:t.onToolStart?.(e.tool_call_id||``,e.tool_name||``,e.arguments||{});break;case`tool_complete`:e.result&&t.onToolComplete?.(e.tool_call_id||``,e.result);break;case`bash_completed`:t.onBashCompleted?.(e.bash_id??``,e.command??``,e.exit_code??null,typeof e.status==`string`?e.status:`completed`);break;case`tool_error`:t.onToolError?.(e.tool_call_id||``,e.error||``);break;case`task_list_updated`:e.task_list&&t.onTaskListUpdated?.(e.task_list);break;case`task_list_item_progress`:if(e.session_id&&e.item_id&&e.status&&e.tool_calls_count!==void 0&&e.version!==void 0){let n=e.status;if(!(n===`pending`||n===`in_progress`||n===`completed`||n===`blocked`))break;t.onTaskListItemProgress?.({session_id:e.session_id,item_id:e.item_id,status:n,tool_calls_count:e.tool_calls_count,version:e.version})}break;case`task_list_completed`:e.session_id&&e.total_rounds!==void 0&&e.total_tool_calls!==void 0&&t.onTaskListCompleted?.(e.session_id,e.total_rounds,e.total_tool_calls,e.completed_at);break;case`task_evaluation_started`:e.session_id&&e.items_count!==void 0&&t.onTaskEvaluationStarted?.(e.session_id,e.items_count);break;case`task_evaluation_completed`:e.session_id&&e.updates_count!==void 0&&e.reasoning&&t.onTaskEvaluationCompleted?.(e.session_id,e.updates_count,e.reasoning);break;case`token_budget_updated`:e.usage&&`system_tokens`in e.usage&&t.onTokenBudgetUpdated?.(e.usage);break;case`context_compression_status`:typeof e.phase==`string`&&typeof e.status==`string`&&t.onContextCompressionStatus?.(e.phase,e.status);break;case`tool_lifecycle`:t.onToolLifecycle?.(e.tool_call_id||``,e.tool_name||``,e.phase||``,e.elapsed_ms,e.is_mutating,e.auto_approved,e.summary,e.error);break;case`context_summarized`:e.summary_info&&t.onContextSummarized?.(e.summary_info);break;case`context_pressure_notification`:typeof e.percent==`number`&&typeof e.level==`string`&&t.onContextPressureNotification?.(e.percent,e.level,e.message||``);break;case`sub_agent_started`:e.parent_session_id&&e.child_session_id&&t.onSubAgentStarted?.(e.parent_session_id,e.child_session_id,e.title);break;case`sub_agent_event`:e.parent_session_id&&e.child_session_id&&e.event&&t.onSubAgentEvent?.(e.parent_session_id,e.child_session_id,e.event);break;case`sub_agent_heartbeat`:e.parent_session_id&&e.child_session_id&&e.timestamp&&t.onSubAgentHeartbeat?.(e.parent_session_id,e.child_session_id,e.timestamp);break;case`sub_agent_completed`:e.parent_session_id&&e.child_session_id&&t.onSubAgentCompleted?.(e.parent_session_id,e.child_session_id,typeof e.status==`string`?e.status:`completed`,e.error);break;case`child_approval_requested`:e.child_session_id&&e.request_id&&t.onChildApprovalRequested?.(e.child_session_id,e.request_id,{toolName:e.tool_name,permission:e.permission,resource:e.resource});break;case`execution_started`:t.onExecutionStarted?.(e.run_id||``,e.started_at);break;case`runner_progress`:e.session_id&&typeof e.round_count==`number`&&t.onRunnerProgress?.(e.session_id,e.round_count);break;case`need_clarification`:t.onNeedClarification?.(e);break;case`notification`:t.onNotification?.(e);break;case`session_title_updated`:e.session_id&&typeof e.title==`string`&&typeof e.title_version==`number`&&(e.source===`auto`||e.source===`manual`||e.source===`fallback`)&&typeof e.updated_at==`string`&&t.onSessionTitleUpdated?.({type:`session_title_updated`,session_id:e.session_id,title:e.title,title_version:e.title_version,source:e.source,updated_at:e.updated_at});break;case`session_pinned_updated`:e.session_id&&typeof e.pinned==`boolean`&&typeof e.updated_at==`string`&&t.onSessionPinnedUpdated?.({type:`session_pinned_updated`,session_id:e.session_id,pinned:e.pinned,updated_at:e.updated_at});break;case`plan_mode_entered`:t.onPlanModeEntered?.(e);break;case`plan_mode_exited`:t.onPlanModeExited?.(e);break;case`plan_file_updated`:t.onPlanFileUpdated?.(e);break;case`goal_status_changed`:t.onGoalStatusChanged?.(e);break;case`complete`:P(`[AgentClient]`,`events.dispatch.complete`,ir(e)),t.onComplete?.(e.usage);break;case`cancelled`:P(`[AgentClient]`,`events.dispatch.cancelled`,ir(e)),t.onCancelled?.(e.message);break;case`error`:P(`[AgentClient]`,`events.dispatch.error`,ir(e)),t.onError?.(e.message||e.error||`Unknown error`);break;default:console.warn(`Unknown event type:`,e)}}async stopGeneration(e){await z.post(`stop/${e}`)}async deleteSession(e){let t=encodeURIComponent(e);await z.delete(`sessions/${t}`)}async getHistory(e,t){P(`[AgentClient]`,`history.request`,{sessionId:e,sinceMessageId:t});let n=t?`history/${e}?since_message_id=${encodeURIComponent(t)}`:`history/${e}`,r=await z.get(n);return P(`[AgentClient]`,`history.response`,tr(r)),r}async healthCheck(){try{return await z.get(`health`),!0}catch{return!1}}},or=ar.getInstance(),sr=new class{async reloadConfig(){return z.post(`/bamboo/settings/reload`)}async getPermissionAskRules(){return(await z.get(`/bamboo/permission/ask-rules`)).rules}async updatePermissionAskRules(e){return(await z.put(`/bamboo/permission/ask-rules`,{rules:e})).rules}async getCopilotAuthStatus(){return z.post(`/bamboo/copilot/auth/status`)}async startCopilotAuth(){return z.post(`/bamboo/copilot/auth/start`)}async completeCopilotAuth(e){return z.post(`/bamboo/copilot/auth/complete`,e)}async authenticateCopilot(){return z.post(`/bamboo/copilot/authenticate`)}async logoutCopilot(){return z.post(`/bamboo/copilot/logout`)}async getProviderCatalog(){return z.get(`/bamboo/provider-catalog`)}async fetchCatalogModels(e){let t=e?{provider:e}:{};return z.post(`/bamboo/provider-catalog/fetch-models`,t)}async getProviderInstances(){return z.get(`/bamboo/settings/provider-instances`)}async createProviderInstance(e){return z.post(`/bamboo/settings/provider-instances`,e)}async updateProviderInstance(e,t){return z.put(`/bamboo/settings/provider-instances/${encodeURIComponent(e)}`,t)}async deleteProviderInstance(e){return z.delete(`/bamboo/settings/provider-instances/${encodeURIComponent(e)}`)}async getEnvVars(){return z.get(`/bamboo/env-vars`)}async upsertEnvVar(e){return z.post(`/bamboo/env-vars`,e)}async deleteEnvVar(e){return z.delete(`/bamboo/env-vars/${encodeURIComponent(e)}`)}async replaceEnvVars(e){return z.post(`/bamboo/env-vars/replace`,{entries:e})}async listNodes(){return z.get(`/bamboo/settings/nodes`)}async createNode(e){return z.post(`/bamboo/settings/nodes`,e)}async updateNode(e,t){return z.put(`/bamboo/settings/nodes/${encodeURIComponent(e)}`,t)}async deleteNode(e){await z.delete(`/bamboo/settings/nodes/${encodeURIComponent(e)}`)}async createCluster(e){return z.post(`/bamboo/settings/clusters`,e)}async updateCluster(e,t){return z.put(`/bamboo/settings/clusters/${encodeURIComponent(e)}`,t)}async deleteCluster(e){return z.delete(`/bamboo/settings/clusters/${encodeURIComponent(e)}`)}async nodeAction(e,t){return z.post(`/bamboo/settings/nodes/${encodeURIComponent(e)}/${t}`,{})}async nodeStatus(e){return z.get(`/bamboo/settings/nodes/${encodeURIComponent(e)}/status`)}async nodeLogs(e,t=200){return z.get(`/bamboo/settings/nodes/${encodeURIComponent(e)}/logs?lines=${t}`)}},cr=[`chat`,`fast`,`task_summary`,`vision`,`memory_background`,`planning`,`search`,`code_review`,`sub_agent`],lr=[`copilot`,`openai`,`anthropic`,`gemini`,`bodhi`],q={copilot:`GitHub Copilot`,openai:`OpenAI`,anthropic:`Anthropic`,gemini:`Google Gemini`,bodhi:`Bodhi`},ur=class extends Error{constructor(e){super(e),this.name=`ProviderSnapshotValidationError`}},dr=e=>typeof e==`object`&&!!e&&!Array.isArray(e),fr=e=>dr(e)&&typeof e.provider==`string`&&e.provider.trim().length>0&&typeof e.model==`string`&&e.model.trim().length>0,pr=(e,t=`Provider instance`)=>{if(!dr(e)||typeof e.id!=`string`||e.id.trim().length===0||!lr.includes(e.type)||typeof e.label!=`string`||typeof e.enabled!=`boolean`||!dr(e.config))throw new ur(`${t} is invalid`);return e},mr=e=>{if(e===void 0)return;if(!dr(e)||!fr(e.chat))throw new ur(`Provider defaults must contain a valid chat model reference`);for(let t of cr){let n=e[t];if(n!==void 0&&!fr(n))throw new ur(`Provider defaults.${t} is invalid`)}let t=e.subagent_models;if(t!==void 0){if(!dr(t))throw new ur(`Provider defaults.subagent_models is invalid`);for(let e of Object.values(t))if(!fr(e))throw new ur(`Provider defaults.subagent_models contains an invalid reference`)}return e},hr=e=>{if(!dr(e)||!Array.isArray(e.instances))throw new ur(`Provider instances payload is invalid`);let t=e.instances.map((e,t)=>pr(e,`Provider instance at index ${t}`));if(new Set(t.map(e=>e.id)).size!==t.length)throw new ur(`Provider instance ids must be unique`);let n=e.default_provider_instance_id;if(n!=null&&typeof n!=`string`||typeof n==`string`&&n.trim().length===0)throw new ur(`Provider compatibility route id is invalid`);let r=typeof n==`string`?n:null,i;if(e.features!==void 0){if(!dr(e.features)||e.features.provider_model_ref!==void 0&&typeof e.features.provider_model_ref!=`boolean`)throw new ur(`Provider features payload is invalid`);i=e.features}return{default_provider_instance_id:r,instances:t,defaults:mr(e.defaults),features:i}},gr=e=>{let t=new Set(e.instances.map(e=>e.id)),n=[],r=e.default_provider_instance_id;r&&!t.has(r)&&n.push({kind:`default_provider_instance`,path:`default_provider_instance_id`,provider:r});for(let r of cr){let i=e.defaults?.[r];i&&!t.has(i.provider)&&n.push({kind:`default_model_ref`,path:`defaults.${r}`,provider:i.provider,role:r})}for(let[r,i]of Object.entries(e.defaults?.subagent_models??{}))t.has(i.provider)||n.push({kind:`subagent_model_ref`,path:`defaults.subagent_models.${r}`,provider:i.provider,subagent:r});return n},_r=e=>typeof e==`object`&&!!e&&!Array.isArray(e),vr=e=>!_r(e)||!_r(e.reference)||!_r(e.capabilities)?!1:typeof e.reference.provider==`string`&&e.reference.provider.trim().length>0&&typeof e.reference.model==`string`&&e.reference.model.trim().length>0&&typeof e.display_name==`string`&&typeof e.provider_display_name==`string`&&typeof e.capabilities.supports_tools==`boolean`&&typeof e.capabilities.supports_vision==`boolean`&&typeof e.capabilities.supports_reasoning==`boolean`,yr=e=>{if(e===void 0)return[];if(!Array.isArray(e)||!e.every(vr))throw Error(`Provider model refresh returned invalid models`);return e},br=()=>Error(`Provider model discovery failed`),xr=(e,t)=>!e?.models||!t.trim()?[]:e.models.filter(e=>e.reference.provider===t),Sr=0,Cr=0,wr=null,Tr=e=>Error(`Failed to ${e} provider instance`),Er=se((e,t)=>{let n=async(e,n)=>{try{await n()}catch{throw Tr(e)}return t().loadProviderInstances()};return{providerSnapshot:null,providerRepairSnapshot:null,providerRepairIssues:[],providerStatus:`idle`,providerError:null,catalog:null,isCatalogFetching:!1,loadProviderInstances:async()=>{let t=++Sr;e({providerSnapshot:null,providerRepairSnapshot:null,providerRepairIssues:[],providerStatus:`loading`,providerError:null});try{let n=hr(await sr.getProviderInstances()),r=gr(n);if(t===Sr){let t=r.length>0;e({providerSnapshot:t?null:n,providerRepairSnapshot:t?n:null,providerRepairIssues:r,providerStatus:t?`degraded`:`ready`,providerError:t?`Provider routing or model preferences contain ${r.length} unknown instance reference${r.length===1?``:`s`}`:null})}return n}catch(n){let r=n instanceof ur,i=r?n.message:`Provider settings are unavailable`;throw t===Sr&&e({providerSnapshot:null,providerRepairSnapshot:null,providerRepairIssues:[],providerStatus:r?`incompatible`:`unavailable`,providerError:i}),r?n:Error(i)}},createProviderInstance:async e=>{let n;try{n=await sr.createProviderInstance(e)}catch{throw Tr(`create`)}let r=null;try{r=pr(n,`Created provider instance`)}catch{}try{let e=await t().loadProviderInstances(),n=r!==null&&e.instances.some(e=>e.id===r.id);return{instance:r,responseValid:r!==null,authorityRefreshed:!0,instanceConfirmed:n}}catch{return{instance:r,responseValid:r!==null,authorityRefreshed:!1,instanceConfirmed:!1}}},updateProviderInstance:(e,t)=>n(`update`,()=>sr.updateProviderInstance(e,t)),deleteProviderInstance:e=>n(`delete`,()=>sr.deleteProviderInstance(e)),loadCatalog:()=>{if(wr)return wr;let t=++Cr,n;return n=Promise.resolve().then(()=>sr.getProviderCatalog()).then(n=>{t===Cr&&e({catalog:n})}).catch(()=>{}).finally(()=>{wr===n&&(wr=null)}),wr=n,n},fetchCatalogModels:async t=>{e({isCatalogFetching:!0});try{let n=await sr.fetchCatalogModels(t);if(!Array.isArray(n.fetched))throw Error(`Provider model refresh returned an invalid response`);if(t){let r=n.fetched.find(e=>_r(e)&&e.provider===t);if(!r||r.error!==void 0&&typeof r.error!=`string`||r.error?.trim())throw br();let i=yr(r.models).filter(e=>e.reference.provider===t);return++Cr,e(e=>({catalog:{providers:e.catalog?.providers??[],models:[...(e.catalog?.models??[]).filter(e=>e.reference.provider!==t),...i],updated_at:e.catalog?.updated_at}})),n}let r=n.fetched.filter(e=>_r(e)&&typeof e.provider==`string`&&(e.error===void 0||typeof e.error==`string`)&&!e.error?.trim()),i=new Set(r.map(e=>e.provider)),a=r.flatMap(e=>yr(e.models).filter(t=>t.reference.provider===e.provider));return++Cr,e(e=>({catalog:{providers:e.catalog?.providers??[],models:[...(e.catalog?.models??[]).filter(e=>!i.has(e.reference.provider)),...a],updated_at:e.catalog?.updated_at}})),n}catch{throw br()}finally{e({isCatalogFetching:!1})}},getActiveModel:()=>{if(t().providerStatus===`ready`)return t().providerSnapshot?.defaults?.chat.model.trim()||void 0},getFastModel:()=>{if(t().providerStatus===`ready`)return t().providerSnapshot?.defaults?.fast?.model.trim()||t().getActiveModel()},getVisionModel:()=>{if(t().providerStatus===`ready`)return t().providerSnapshot?.defaults?.vision?.model.trim()||t().getActiveModel()},isProviderModelRefEnabled:()=>t().providerStatus===`ready`&&t().providerSnapshot?.features?.provider_model_ref===!0,getFastModelRef:()=>{if(t().providerStatus!==`ready`)return null;let e=t().providerSnapshot?.defaults;return e?.fast?.model.trim()?e.fast:e?.chat.model.trim()?e.chat:null},getVisionModelRef:()=>{if(t().providerStatus!==`ready`)return null;let e=t().providerSnapshot?.defaults;return e?.vision?.model.trim()?e.vision:e?.chat.model.trim()?e.chat:null},getModelsForProvider:e=>xr(t().catalog,e),getProviderInstance:e=>t().providerSnapshot?.instances.find(t=>t.id===e),getProviderDisplayLabel:e=>{let n=(t().providerSnapshot??t().providerRepairSnapshot)?.instances.find(t=>t.id===e);return n?.label||n?.type||e},getProviderType:e=>t().providerSnapshot?.instances.find(t=>t.id===e)?.type}});function Dr(e){return e.type===`session_title_updated`||e.type===`session_pinned_updated`}function Or(e,t){switch(e.type){case`session_title_updated`:typeof e.session_id==`string`&&typeof e.title==`string`&&typeof e.title_version==`number`&&t.applyServerTitle(e.session_id,e.title,e.title_version);break;case`session_pinned_updated`:typeof e.session_id==`string`&&typeof e.pinned==`boolean`&&typeof e.updated_at==`string`&&t.applyServerPinned(e.session_id,e.pinned,e.updated_at);break}}function kr(e,t){let n=t.findIndex(t=>t.id===e.session_id);if(!(n<0))switch(e.type){case`session_title_updated`:{if(typeof e.title!=`string`||typeof e.title_version!=`number`)return;let r=e.title_version;if(r<=(t[n].titleVersion??0))return;t[n]={...t[n],title:e.title,titleVersion:r};return}case`session_pinned_updated`:if(typeof e.pinned!=`boolean`||typeof e.updated_at!=`string`||new Date(e.updated_at).getTime()<new Date(t[n].updatedAt??0).getTime()||t[n].pinned===e.pinned)return;t[n]={...t[n],pinned:e.pinned,updatedAt:e.updated_at};return}}var Ar=e=>e!==void 0&&e!==`idle`&&e!==`completed`&&e!==`error`&&e!==`cancelled`,jr=e=>({sessionId:e,phase:`idle`,confidence:`optimistic`,activeReasons:[],generation:0,backendRunId:null,stream:{hasTokens:!1,tokenCount:0,activeToolCalls:[],lastStatusHint:null},backend:{isRunning:!1,lastRunStatus:null,lastRunError:null,syncedAt:null,hasPendingQuestion:null,runningChildCount:null},interaction:{pendingQuestion:null,respondMode:null,pendingChildApproval:null},children:{byId:{},runningCount:0},timestamps:{optimisticAt:null,confirmedAt:null,firstTokenAt:null,terminalAt:null,settlingStartedAt:null,settledAt:null},error:null}),Mr=(e,t)=>e[t]??jr(t),J=(e,t)=>[...e.length>=16?e.slice(-15):e,t],Nr=e=>e.length<=80?e:e.slice(e.length-80),Pr=(e,t)=>e.length===t.length&&e.every((e,n)=>e===t[n]),Fr=(e,t)=>e?e.question===t.question&&e.allowCustom===t.allowCustom&&e.toolCallId===t.toolCallId&&Pr(e.options,t.options):!1,Ir=(e,t,n)=>{let r=Fr(e.interaction.pendingQuestion,t)?e.interaction.pendingQuestion:{...t,receivedAt:n};return e.phase===`waiting_user_answer`&&e.confidence===`live`&&r===e.interaction.pendingQuestion?e:{...e,phase:`waiting_user_answer`,confidence:`live`,interaction:{...e.interaction,pendingQuestion:r,respondMode:null},activeReasons:J(e.activeReasons,`sse:need_clarification`)}},Lr=(e,t)=>e?e.childSessionId===t.childSessionId&&e.requestId===t.requestId&&e.toolName===t.toolName&&e.permission===t.permission&&e.resource===t.resource:!1,Rr=(e,t,n)=>Lr(e.interaction.pendingChildApproval,t)?e:{...e,interaction:{...e.interaction,pendingChildApproval:{...t,receivedAt:n}}},zr=new Set([`idle`,`completed`,`error`,`cancelled`,`settling`,`waiting_user_answer`]),Br=e=>zr.has(e.phase)?e:e.children.runningCount>0?e.phase===`running_children`?e:{...e,phase:`running_children`}:e.stream.activeToolCalls.length>0?e.phase===`running_tools`?e:{...e,phase:`running_tools`}:e.stream.hasTokens?e.phase===`streaming`?e:{...e,phase:`streaming`}:e.phase===`running`?e:{...e,phase:`running`},Y=(e,t,n)=>({...e,[t]:n}),Vr=(e,t)=>{if(!(t in e))return e;let n={...e};return delete n[t],n},Hr=(e,t,n)=>{let r=e.timestamps.firstTokenAt??n();return Br({...e,confidence:`live`,stream:{...e.stream,hasTokens:!0,tokenCount:e.stream.tokenCount+1},timestamps:{...e.timestamps,firstTokenAt:r},activeReasons:J(e.activeReasons,t)})},Ur=(e,t)=>{if(e.stream.hasTokens&&e.timestamps.firstTokenAt!==null)return e;let n=e.timestamps.firstTokenAt??t();return Br({...e,confidence:`live`,stream:{...e.stream,hasTokens:!0,tokenCount:Math.max(1,e.stream.tokenCount)},timestamps:{...e.timestamps,firstTokenAt:n},activeReasons:J(e.activeReasons,`sse:token`)})},Wr=(e,t,n,r)=>{let i=e.stream.activeToolCalls.findIndex(e=>e.toolCallId===t)>=0?e.stream.activeToolCalls:[...e.stream.activeToolCalls,{toolCallId:t,toolName:n,startedAt:r}];return Br({...e,confidence:`live`,stream:{...e.stream,activeToolCalls:i},activeReasons:J(e.activeReasons,`sse:tool_start`)})},Gr=(e,t,n)=>{let r=e.stream.activeToolCalls.findIndex(e=>e.toolCallId===t);if(r<0)return e;let i=e.stream.activeToolCalls[r],a=Nr((i.preview??``)+n),o={...i,preview:a},s=[...e.stream.activeToolCalls];return s[r]=o,{...e,stream:{...e.stream,activeToolCalls:s}}},Kr=(e,t,n)=>{let r=e.stream.activeToolCalls.filter(e=>e.toolCallId!==t);if(r.length===e.stream.activeToolCalls.length)return e;let i={...e,stream:{...e.stream,activeToolCalls:r},activeReasons:J(e.activeReasons,n)};return i.timestamps.terminalAt&&i.children.runningCount===0&&i.stream.activeToolCalls.length===0&&!zr.has(i.phase)?{...i,phase:`settling`,timestamps:{...i.timestamps,settlingStartedAt:i.timestamps.settlingStartedAt??i.timestamps.terminalAt}}:Br(i)},qr=(e,t,n)=>{let r=e.children.byId[t],i=r!==void 0&&(r.status===void 0||r.status===`running`),a={...r,...n,status:n.status??r?.status??`running`},o=(a.status===void 0||a.status===`running`)-+!!i;return Br({...e,confidence:`live`,children:{byId:{...e.children.byId,[t]:a},runningCount:Math.max(0,e.children.runningCount+o)},activeReasons:J(e.activeReasons,`sse:sub_agent_started`)})},Jr=(e,t,n)=>{let r=e.children.byId[t],i=r===void 0||r.status===void 0||r.status===`running`,a={...r,...n};if(r!==void 0&&r.title===a.title&&r.status===a.status&&r.error===a.error&&r.lastHeartbeatAt===a.lastHeartbeatAt&&r.lastEventAt===a.lastEventAt&&r.outputPreview===a.outputPreview&&r.roundCount===a.roundCount)return e;let o=a.status===void 0||a.status===`running`,s=0;r!==void 0&&(s=!!o-+!!i);let c=Math.max(0,e.children.runningCount+s),l={...e,children:{byId:{...e.children.byId,[t]:a},runningCount:c}};return l.timestamps.terminalAt&&l.children.runningCount===0&&l.stream.activeToolCalls.length===0&&!zr.has(l.phase)?{...l,phase:`settling`,timestamps:{...l.timestamps,settlingStartedAt:l.timestamps.settlingStartedAt??l.timestamps.terminalAt},activeReasons:J(l.activeReasons,`sse:sub_agent_completed`)}:Br(l)},Yr=(e,t)=>{if(!(t in e.children.byId))return e;let n=e.children.byId[t],r=n.status===void 0||n.status===`running`,i={...e.children.byId};delete i[t];let a={...e,children:{byId:i,runningCount:Math.max(0,e.children.runningCount-+!!r)}};return a.timestamps.terminalAt&&a.children.runningCount===0&&a.stream.activeToolCalls.length===0&&!zr.has(a.phase)?{...a,phase:`settling`,timestamps:{...a.timestamps,settlingStartedAt:a.timestamps.settlingStartedAt??a.timestamps.terminalAt}}:Br(a)},Xr=(e,t,n)=>{switch(t.type){case`token`:return Hr(e,`sse:token`,n);case`reasoning_token`:return Hr(e,`sse:token`,n);case`tool_start`:{let r=t.tool_call_id??``,i=t.tool_name??``;return r?Wr(e,r,i,n()):e}case`tool_token`:{let n=t.tool_call_id??``;return n?Gr(e,n,t.content??``):e}case`tool_complete`:case`tool_error`:{let n=t.tool_call_id??``;return n?Kr(e,n,`sse:tool_complete`):e}case`tool_lifecycle`:return e;case`sub_agent_started`:{let n=t.child_session_id??``;return n?qr(e,n,{title:t.title,status:`running`}):e}case`sub_agent_event`:case`sub_agent_heartbeat`:{let r=t.child_session_id??``;if(!r)return e;let i={lastEventAt:t.timestamp??n()};return t.type===`sub_agent_heartbeat`&&(i.lastHeartbeatAt=t.timestamp??n()),Jr(e,r,i)}case`sub_agent_completed`:{let n=t.child_session_id??``;return n?Jr(e,n,{status:typeof t.status==`string`?t.status:`completed`,error:t.error}):e}case`need_clarification`:return Ir(e,{question:t.question??``,options:t.options??[],allowCustom:t.allow_custom??!1,toolCallId:t.tool_call_id??null},n());case`execution_started`:{let r=t.run_id;return r?e.phase!==`starting`&&e.phase!==`settling`?{...e,backendRunId:r,confidence:`live`,activeReasons:J(e.activeReasons,`sse:execution_started`)}:{...e,phase:`running`,confidence:`live`,backendRunId:r,timestamps:{...e.timestamps,confirmedAt:n()},activeReasons:J(e.activeReasons,`sse:execution_started`)}:e}case`complete`:{if(zr.has(e.phase))return e;let t=n();return{...e,phase:`settling`,timestamps:{...e.timestamps,terminalAt:t,settlingStartedAt:e.timestamps.settlingStartedAt??t},activeReasons:J(e.activeReasons,`sse:complete`)}}case`cancelled`:{let r=n();return{...e,phase:`cancelled`,confidence:`terminal`,timestamps:{...e.timestamps,terminalAt:r,settledAt:r},error:t.message?{message:t.message,source:`user_cancel`,occurredAt:r}:null,activeReasons:J(e.activeReasons,`sse:error`)}}case`error`:{let r=n();return{...e,phase:`error`,confidence:`terminal`,timestamps:{...e.timestamps,terminalAt:r},error:{message:t.message??t.error??`Unknown error`,source:`sse`,occurredAt:r},activeReasons:J(e.activeReasons,`sse:error`)}}case`task_list_updated`:case`task_list_item_progress`:case`task_list_completed`:case`task_evaluation_started`:case`task_evaluation_completed`:case`token_budget_updated`:case`context_compression_status`:case`context_summarized`:case`context_pressure_notification`:return e;default:return e}},Zr=e=>e===`completed`||e===`error`||e===`cancelled`,Qr=(e,t,n)=>{let r=t.last_run_status,i=Zr(r)?r:null,a=n(),o=t.has_pending_question===void 0?null:t.has_pending_question,s=t.running_child_count===void 0?null:t.running_child_count,c={...e,backend:{...e.backend,isRunning:t.is_running,lastRunStatus:i,lastRunError:t.last_run_error??null,syncedAt:a,hasPendingQuestion:o,runningChildCount:s},backendRunId:e.backendRunId};if(t.is_running)return e.phase===`idle`||e.phase===`completed`||e.phase===`error`||e.phase===`cancelled`?{...c,phase:`running`,confidence:`summary`,activeReasons:J(c.activeReasons,`summary:is_running`)}:e.phase===`starting`?{...c,phase:`running`,confidence:`summary`,timestamps:{...c.timestamps,confirmedAt:a},activeReasons:J(c.activeReasons,`summary:is_running`)}:c;if(t.id,e.phase,e.generation,e.backendRunId,t.is_running,e.timestamps.optimisticAt,new Set([`starting`,`running`,`streaming`,`running_tools`,`running_children`,`settling`]).has(e.phase)){if(i===`completed`)return t.id,e.phase,e.generation,e.backendRunId,{...c,phase:`completed`,confidence:`terminal`,timestamps:{...c.timestamps,settledAt:a},activeReasons:J(c.activeReasons,`summary:terminal`)};if(i===`error`)return t.id,e.phase,e.generation,e.backendRunId,{...c,phase:`error`,confidence:`terminal`,timestamps:{...c.timestamps,settledAt:a},error:{message:t.last_run_error??`Backend reported error`,source:`summary`,occurredAt:a},activeReasons:J(c.activeReasons,`summary:terminal`)};if(i===`cancelled`)return t.id,e.phase,e.generation,e.backendRunId,{...c,phase:`cancelled`,confidence:`terminal`,timestamps:{...c.timestamps,settledAt:a},activeReasons:J(c.activeReasons,`summary:terminal`)};if(e.timestamps.optimisticAt){let n=Date.parse(a)-Date.parse(e.timestamps.optimisticAt);if(Number.isFinite(n)&&n<5e3)return t.id,e.phase,e.generation,e.backendRunId,c}return t.id,e.phase,e.generation,e.backendRunId,{...c,phase:`idle`,confidence:`summary`,activeReasons:J(c.activeReasons,`summary:terminal`)}}return c},$r=()=>new Date().toISOString(),ei=(e,t,n=$r)=>{switch(t.type){case`ensureSession`:return t.sessionId in e?e:Y(e,t.sessionId,jr(t.sessionId));case`markOptimisticStart`:{let r=Mr(e,t.sessionId),i=n(),a={...r,phase:`starting`,confidence:`optimistic`,generation:r.generation+1,stream:{hasTokens:!1,tokenCount:0,activeToolCalls:[],lastStatusHint:null},interaction:{...r.interaction,respondMode:null},error:null,timestamps:{optimisticAt:i,confirmedAt:null,firstTokenAt:null,terminalAt:null,settlingStartedAt:null,settledAt:null},activeReasons:J(r.activeReasons,`optimistic:send`)};return Y(e,t.sessionId,a)}case`markRespondStart`:{let r=Mr(e,t.sessionId),i=n(),a={...r,phase:`starting`,confidence:`optimistic`,generation:r.generation+1,stream:{hasTokens:!1,tokenCount:0,activeToolCalls:[],lastStatusHint:null},interaction:{...r.interaction,pendingQuestion:null,respondMode:null},error:null,timestamps:{...r.timestamps,optimisticAt:i,confirmedAt:null,firstTokenAt:null,terminalAt:null,settlingStartedAt:null,settledAt:null},activeReasons:J(r.activeReasons,`optimistic:respond`)};return Y(e,t.sessionId,a)}case`markRetryStart`:{let r=Mr(e,t.sessionId),i=n(),a={...r,phase:`starting`,confidence:`optimistic`,generation:r.generation+1,stream:{hasTokens:!1,tokenCount:0,activeToolCalls:[],lastStatusHint:null},error:null,timestamps:{...r.timestamps,optimisticAt:i,confirmedAt:null,firstTokenAt:null,terminalAt:null,settlingStartedAt:null,settledAt:null},activeReasons:J(r.activeReasons,`optimistic:retry`)};return Y(e,t.sessionId,a)}case`markForceSubscribe`:{let n=Mr(e,t.sessionId);if(Ar(n.phase))return e;let r={...n,phase:`running`,confidence:`optimistic`,generation:n.generation+1,error:null,activeReasons:J(n.activeReasons,`optimistic:openSession.forceSubscribe`)};return Y(e,t.sessionId,r)}case`markCancel`:{let r=Mr(e,t.sessionId),i=n(),a={...r,phase:`cancelled`,confidence:`terminal`,timestamps:{...r.timestamps,settledAt:i},activeReasons:J(r.activeReasons,`user:cancel`)};return Y(e,t.sessionId,a)}case`markSettleTimeout`:{let r=Mr(e,t.sessionId);if(r.phase!==`starting`&&r.phase!==`settling`)return e;let i={...r,phase:`idle`,confidence:`optimistic`,timestamps:{...r.timestamps,settledAt:n()},activeReasons:J(r.activeReasons,`settle:timeout`)};return Y(e,t.sessionId,i)}case`markStreamStarted`:{let r=Mr(e,t.sessionId);if(t.generation!==r.generation)return e;let i=Ur(r,n);return i===r?e:Y(e,t.sessionId,i)}case`applyAgentEvent`:{let r=Mr(e,t.sessionId);if(t.generation!==r.generation)return t.sessionId,t.generation,r.generation,t.event.type,r.phase,r.backendRunId,e;let i=Xr(r,t.event,n);return i===r?e:Y(e,t.sessionId,i)}case`applyExecutionStarted`:{let r=Mr(e,t.sessionId);if(t.generation!==r.generation)return t.sessionId,t.generation,r.generation,t.runId,r.phase,r.backendRunId,e;if(r.phase!==`starting`&&r.phase!==`settling`)return Y(e,t.sessionId,{...r,backendRunId:t.runId,confidence:`live`,activeReasons:J(r.activeReasons,`sse:execution_started`)});let i={...r,phase:`running`,confidence:`live`,backendRunId:t.runId,timestamps:{...r.timestamps,confirmedAt:n()},activeReasons:J(r.activeReasons,`sse:execution_started`)};return Y(e,t.sessionId,i)}case`applySessionSummary`:{let r=Mr(e,t.sessionId),i=Qr(r,t.summary,n);return i===r?e:Y(e,t.sessionId,i)}case`applyOneShotTerminal`:{let r=Mr(e,t.sessionId);if(t.generation!==r.generation||r.phase!==`idle`&&r.phase!==`starting`)return e;let i=n();return t.payload.status===`completed`?Y(e,t.sessionId,{...r,phase:`completed`,confidence:`terminal`,timestamps:{...r.timestamps,terminalAt:i,settledAt:i},activeReasons:J(r.activeReasons,`sse:terminal_one_shot`)}):t.payload.status===`cancelled`?Y(e,t.sessionId,{...r,phase:`cancelled`,confidence:`terminal`,timestamps:{...r.timestamps,terminalAt:i,settledAt:i},error:t.payload.message?{message:t.payload.message,source:`user_cancel`,occurredAt:i}:null,activeReasons:J(r.activeReasons,`sse:terminal_one_shot`)}):Y(e,t.sessionId,{...r,phase:`error`,confidence:`terminal`,timestamps:{...r.timestamps,terminalAt:i,settledAt:i},error:{message:t.payload.message??`Unknown error`,source:`sse`,occurredAt:i},activeReasons:J(r.activeReasons,`sse:terminal_one_shot`)})}case`beginSettle`:{let r=Mr(e,t.sessionId);if(t.generation!==r.generation||r.phase!==`running`&&r.phase!==`streaming`&&r.phase!==`running_tools`&&r.phase!==`running_children`)return e;let i=n();return Y(e,t.sessionId,{...r,phase:`settling`,timestamps:{...r.timestamps,settlingStartedAt:i,terminalAt:r.timestamps.terminalAt??i}})}case`applyChildProgress`:{let n=Mr(e,t.sessionId),r=t.childId in n.children.byId?Jr(n,t.childId,t.patch):qr(n,t.childId,t.patch);return r===n?e:Y(e,t.sessionId,r)}case`clearChildProgress`:{let n=Mr(e,t.sessionId),r=Yr(n,t.childId);return r===n?e:Y(e,t.sessionId,r)}case`setPendingQuestion`:{let r=Mr(e,t.sessionId),i=Ir(r,t.payload,n());return i===r?e:Y(e,t.sessionId,i)}case`clearPendingQuestion`:{let n=Mr(e,t.sessionId);if(n.interaction.pendingQuestion===null&&n.interaction.respondMode===null)return e;let r={...n,interaction:{...n.interaction,pendingQuestion:null,respondMode:null}};return Y(e,t.sessionId,r)}case`setPendingChildApproval`:{let r=Mr(e,t.sessionId),i=Rr(r,t.payload,n());return i===r?e:Y(e,t.sessionId,i)}case`clearPendingChildApproval`:{let n=Mr(e,t.sessionId);if(n.interaction.pendingChildApproval===null)return e;let r={...n,interaction:{...n.interaction,pendingChildApproval:null}};return Y(e,t.sessionId,r)}case`resetSession`:return Vr(e,t.sessionId);case`applyRunningSnapshot`:{let r=e;for(let e of t.sessions){let t=Mr(r,e.sessionId),i=t.generation+1,a={...t,generation:i,backendRunId:e.runId,phase:`running`,confidence:`live`,timestamps:{...t.timestamps,confirmedAt:n()},activeReasons:J(t.activeReasons,`sse:execution_started`)};for(let t of e.criticalEvents)t.type!==`execution_started`&&(a=Xr(a,t,n));r=Y(r,e.sessionId,a)}return r}default:return e}},ti=()=>new Date().toISOString(),ni=(e,t)=>{e(e=>{let n=ei(e.executionBySession,t,ti);return n===e.executionBySession?e:{executionBySession:n}})},ri=(e,t)=>({executionBySession:{},ensureSession:t=>ni(e,{type:`ensureSession`,sessionId:t}),markOptimisticStart:n=>{let r=t().executionBySession[n],i=r?r.generation+1:1;return ni(e,{type:`markOptimisticStart`,sessionId:n}),i},markRespondStart:(n,r)=>{let i=t().executionBySession[n],a=i?i.generation+1:1;return ni(e,{type:`markRespondStart`,sessionId:n,toolCallId:r}),a},markRetryStart:n=>{let r=t().executionBySession[n],i=r?r.generation+1:1;return ni(e,{type:`markRetryStart`,sessionId:n}),i},markForceSubscribe:t=>ni(e,{type:`markForceSubscribe`,sessionId:t}),markCancel:t=>ni(e,{type:`markCancel`,sessionId:t}),markSettleTimeout:t=>ni(e,{type:`markSettleTimeout`,sessionId:t}),markStreamStarted:(t,n)=>ni(e,{type:`markStreamStarted`,sessionId:t,generation:n}),applyAgentEvent:(t,n,r)=>ni(e,{type:`applyAgentEvent`,sessionId:t,event:n,generation:r}),applyExecutionStarted:(t,n,r)=>ni(e,{type:`applyExecutionStarted`,sessionId:t,runId:n,generation:r}),applySessionSummary:(t,n)=>ni(e,{type:`applySessionSummary`,sessionId:t,summary:n}),applyOneShotTerminal:(t,n,r)=>ni(e,{type:`applyOneShotTerminal`,sessionId:t,generation:n,payload:r}),beginSettle:(t,n)=>ni(e,{type:`beginSettle`,sessionId:t,generation:n}),applyChildProgress:(t,n,r)=>ni(e,{type:`applyChildProgress`,sessionId:t,childId:n,patch:r}),clearChildProgress:(t,n)=>ni(e,{type:`clearChildProgress`,sessionId:t,childId:n}),setPendingQuestion:(t,n)=>ni(e,{type:`setPendingQuestion`,sessionId:t,payload:n}),clearPendingQuestion:t=>ni(e,{type:`clearPendingQuestion`,sessionId:t}),setPendingChildApproval:(t,n)=>ni(e,{type:`setPendingChildApproval`,sessionId:t,payload:n}),clearPendingChildApproval:t=>ni(e,{type:`clearPendingChildApproval`,sessionId:t}),resetSession:t=>ni(e,{type:`resetSession`,sessionId:t}),applyRunningSnapshot:n=>{let r=t();ni(e,{type:`applyRunningSnapshot`,sessions:n.map(e=>{let t=[];for(let n of e.criticalEvents){if(Dr(n)){Or(n,r);continue}t.push(n)}return{...e,criticalEvents:t}})})}}),X=e=>typeof e==`string`,ii=()=>{let e,t,n=new Promise((n,r)=>{e=n,t=r});return n.resolve=e,n.reject=t,n},ai=e=>e==null?``:String(e),oi=(e,t,n)=>{e.forEach(e=>{t[e]&&(n[e]=t[e])})},si=/###/g,ci=e=>e&&e.includes(`###`)?e.replace(si,`.`):e,li=e=>!e||X(e),ui=(e,t,n)=>{let r=X(t)?t.split(`.`):t,i=0;for(;i<r.length-1;){if(li(e))return{};let t=ci(r[i]);!e[t]&&n&&(e[t]=new n),e=Object.prototype.hasOwnProperty.call(e,t)?e[t]:{},++i}return li(e)?{}:{obj:e,k:ci(r[i])}},di=(e,t,n)=>{let{obj:r,k:i}=ui(e,t,Object);if(r!==void 0||t.length===1){r[i]=n;return}let a=t[t.length-1],o=t.slice(0,t.length-1),s=ui(e,o,Object);for(;s.obj===void 0&&o.length;)a=`${o[o.length-1]}.${a}`,o=o.slice(0,o.length-1),s=ui(e,o,Object),s?.obj&&s.obj[`${s.k}.${a}`]!==void 0&&(s.obj=void 0);s.obj[`${s.k}.${a}`]=n},fi=(e,t,n,r)=>{let{obj:i,k:a}=ui(e,t,Object);i[a]=i[a]||[],i[a].push(n)},pi=(e,t)=>{let{obj:n,k:r}=ui(e,t);if(n&&Object.prototype.hasOwnProperty.call(n,r))return n[r]},mi=(e,t,n)=>{let r=pi(e,n);return r===void 0?pi(t,n):r},hi=(e,t,n)=>{for(let r in t)r!==`__proto__`&&r!==`constructor`&&(r in e?X(e[r])||e[r]instanceof String||X(t[r])||t[r]instanceof String?n&&(e[r]=t[r]):hi(e[r],t[r],n):e[r]=t[r]);return e},gi=e=>e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,`\\$&`),_i={"&":`&`,"<":`<`,">":`>`,'"':`"`,"'":`'`,"/":`/`},vi=e=>X(e)?e.replace(/[&<>"'\/]/g,e=>_i[e]):e,yi=class{constructor(e){this.capacity=e,this.regExpMap=new Map,this.regExpQueue=[]}getRegExp(e){let t=this.regExpMap.get(e);if(t!==void 0)return t;let n=new RegExp(e);return this.regExpQueue.length===this.capacity&&this.regExpMap.delete(this.regExpQueue.shift()),this.regExpMap.set(e,n),this.regExpQueue.push(e),n}},bi=[` `,`,`,`?`,`!`,`;`],xi=new yi(20),Si=(e,t,n)=>{t||=``,n||=``;let r=bi.filter(e=>!t.includes(e)&&!n.includes(e));if(r.length===0)return!0;let i=xi.getRegExp(`(${r.map(e=>e===`?`?`\\?`:e).join(`|`)})`),a=!i.test(e);if(!a){let t=e.indexOf(n);t>0&&!i.test(e.substring(0,t))&&(a=!0)}return a},Ci=(e,t,n=`.`)=>{if(!e)return;if(e[t])return Object.prototype.hasOwnProperty.call(e,t)?e[t]:void 0;let r=t.split(n),i=e;for(let e=0;e<r.length;){if(!i||typeof i!=`object`)return;let t,a=``;for(let o=e;o<r.length;++o)if(o!==e&&(a+=n),a+=r[o],t=i[a],t!==void 0){if([`string`,`number`,`boolean`].includes(typeof t)&&o<r.length-1)continue;e+=o-e+1;break}i=t}return i},wi=e=>e?.replace(/_/g,`-`),Ti={type:`logger`,log(e){this.output(`log`,e)},warn(e){this.output(`warn`,e)},error(e){this.output(`error`,e)},output(e,t){console?.[e]?.apply?.(console,t)}},Ei=new class e{constructor(e,t={}){this.init(e,t)}init(e,t={}){this.prefix=t.prefix||`i18next:`,this.logger=e||Ti,this.options=t,this.debug=t.debug}log(...e){return this.forward(e,`log`,``,!0)}warn(...e){return this.forward(e,`warn`,``,!0)}error(...e){return this.forward(e,`error`,``)}deprecate(...e){return this.forward(e,`warn`,`WARNING DEPRECATED: `,!0)}forward(e,t,n,r){return r&&!this.debug?null:(e=e.map(e=>X(e)?e.replace(/[\r\n\x00-\x1F\x7F]/g,` `):e),X(e[0])&&(e[0]=`${n}${this.prefix} ${e[0]}`),this.logger[t](e))}create(t){return new e(this.logger,{prefix:`${this.prefix}:${t}:`,...this.options})}clone(t){return t||=this.options,t.prefix=t.prefix||this.prefix,new e(this.logger,t)}},Di=class{constructor(){this.observers={}}on(e,t){return e.split(` `).forEach(e=>{this.observers[e]||(this.observers[e]=new Map);let n=this.observers[e].get(t)||0;this.observers[e].set(t,n+1)}),this}off(e,t){if(this.observers[e]){if(!t){delete this.observers[e];return}this.observers[e].delete(t)}}once(e,t){let n=(...r)=>{t(...r),this.off(e,n)};return this.on(e,n),this}emit(e,...t){this.observers[e]&&Array.from(this.observers[e].entries()).forEach(([e,n])=>{for(let r=0;r<n;r++)e(...t)}),this.observers[`*`]&&Array.from(this.observers[`*`].entries()).forEach(([n,r])=>{for(let i=0;i<r;i++)n(e,...t)})}},Oi=class extends Di{constructor(e,t={ns:[`translation`],defaultNS:`translation`}){super(),this.data=e||{},this.options=t,this.options.keySeparator===void 0&&(this.options.keySeparator=`.`),this.options.ignoreJSONStructure===void 0&&(this.options.ignoreJSONStructure=!0)}addNamespaces(e){this.options.ns.includes(e)||this.options.ns.push(e)}removeNamespaces(e){let t=this.options.ns.indexOf(e);t>-1&&this.options.ns.splice(t,1)}getResource(e,t,n,r={}){let i=r.keySeparator===void 0?this.options.keySeparator:r.keySeparator,a=r.ignoreJSONStructure===void 0?this.options.ignoreJSONStructure:r.ignoreJSONStructure,o;e.includes(`.`)?o=e.split(`.`):(o=[e,t],n&&(Array.isArray(n)?o.push(...n):X(n)&&i?o.push(...n.split(i)):o.push(n)));let s=pi(this.data,o);return!s&&!t&&!n&&e.includes(`.`)&&(e=o[0],t=o[1],n=o.slice(2).join(`.`)),s||!a||!X(n)?s:Ci(this.data?.[e]?.[t],n,i)}addResource(e,t,n,r,i={silent:!1}){let a=i.keySeparator===void 0?this.options.keySeparator:i.keySeparator,o=[e,t];n&&(o=o.concat(a?n.split(a):n)),e.includes(`.`)&&(o=e.split(`.`),r=t,t=o[1]),this.addNamespaces(t),di(this.data,o,r),i.silent||this.emit(`added`,e,t,n,r)}addResources(e,t,n,r={silent:!1}){for(let r in n)(X(n[r])||Array.isArray(n[r]))&&this.addResource(e,t,r,n[r],{silent:!0});r.silent||this.emit(`added`,e,t,n)}addResourceBundle(e,t,n,r,i,a={silent:!1,skipCopy:!1}){let o=[e,t];e.includes(`.`)&&(o=e.split(`.`),r=n,n=t,t=o[1]),this.addNamespaces(t);let s=pi(this.data,o)||{};a.skipCopy||(n=JSON.parse(JSON.stringify(n))),r?hi(s,n,i):s={...s,...n},di(this.data,o,s),a.silent||this.emit(`added`,e,t,n)}removeResourceBundle(e,t){this.hasResourceBundle(e,t)&&delete this.data[e][t],this.removeNamespaces(t),this.emit(`removed`,e,t)}hasResourceBundle(e,t){return this.getResource(e,t)!==void 0}getResourceBundle(e,t){return t||=this.options.defaultNS,this.getResource(e,t)}getDataByLanguage(e){return this.data[e]}hasLanguageSomeTranslations(e){let t=this.getDataByLanguage(e);return!!(t&&Object.keys(t)||[]).find(e=>t[e]&&Object.keys(t[e]).length>0)}toJSON(){return this.data}},ki={processors:{},addPostProcessor(e){this.processors[e.name]=e},handle(e,t,n,r,i){return e.forEach(e=>{t=this.processors[e]?.process(t,n,r,i)??t}),t}},Ai=Symbol(`i18next/PATH_KEY`);function ji(){let e=[],t=Object.create(null),n;return t.get=(r,i)=>(n?.revoke?.(),i===Ai?e:(e.push(i),n=Proxy.revocable(r,t),n.proxy)),Proxy.revocable(Object.create(null),t).proxy}function Mi(e,t){let{[Ai]:n}=e(ji()),r=t?.keySeparator??`.`,i=t?.nsSeparator??`:`,a=t?.enableSelector===`strict`;if(n.length>1&&i){let e=t?.ns,o=a?Array.isArray(e)?e:e?[e]:null:Array.isArray(e)?e:null;if(o&&(a?o:o.length>1?o.slice(1):[]).includes(n[0]))return`${n[0]}${i}${n.slice(1).join(r)}`}return n.join(r)}var Ni=e=>!X(e)&&typeof e!=`boolean`&&typeof e!=`number`,Pi=class e extends Di{constructor(e,t={}){super(),oi([`resourceStore`,`languageUtils`,`pluralResolver`,`interpolator`,`backendConnector`,`i18nFormat`,`utils`],e,this),this.options=t,this.options.keySeparator===void 0&&(this.options.keySeparator=`.`),this.logger=Ei.create(`translator`),this.checkedLoadedFor={}}changeLanguage(e){e&&(this.language=e)}exists(e,t={interpolation:{}}){let n={...t};if(e==null)return!1;let r=this.resolve(e,n);if(r?.res===void 0)return!1;let i=Ni(r.res);return!(n.returnObjects===!1&&i)}extractFromKey(e,t){let n=t.nsSeparator===void 0?this.options.nsSeparator:t.nsSeparator;n===void 0&&(n=`:`);let r=t.keySeparator===void 0?this.options.keySeparator:t.keySeparator,i=t.ns||this.options.defaultNS||[],a=n&&e.includes(n),o=!this.options.userDefinedKeySeparator&&!t.keySeparator&&!this.options.userDefinedNsSeparator&&!t.nsSeparator&&!Si(e,n,r);if(a&&!o){let t=e.match(this.interpolator.nestingRegexp);if(t&&t.length>0)return{key:e,namespaces:X(i)?[i]:i};let a=e.split(n);(n!==r||n===r&&this.options.ns.includes(a[0]))&&(i=a.shift()),e=a.join(r)}return{key:e,namespaces:X(i)?[i]:i}}translate(t,n,r){let i=typeof n==`object`?{...n}:n;if(typeof i!=`object`&&this.options.overloadTranslationOptionHandler&&(i=this.options.overloadTranslationOptionHandler(arguments)),typeof i==`object`&&(i={...i}),i||={},t==null)return``;typeof t==`function`&&(t=Mi(t,{...this.options,...i})),Array.isArray(t)||(t=[String(t)]),t=t.map(e=>typeof e==`function`?Mi(e,{...this.options,...i}):String(e));let a=i.returnDetails===void 0?this.options.returnDetails:i.returnDetails,o=i.keySeparator===void 0?this.options.keySeparator:i.keySeparator,{key:s,namespaces:c}=this.extractFromKey(t[t.length-1],i),l=c[c.length-1],u=i.nsSeparator===void 0?this.options.nsSeparator:i.nsSeparator;u===void 0&&(u=`:`);let d=i.lng||this.language,f=i.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(d?.toLowerCase()===`cimode`)return f?a?{res:`${l}${u}${s}`,usedKey:s,exactUsedKey:s,usedLng:d,usedNS:l,usedParams:this.getUsedParamsDetails(i)}:`${l}${u}${s}`:a?{res:s,usedKey:s,exactUsedKey:s,usedLng:d,usedNS:l,usedParams:this.getUsedParamsDetails(i)}:s;let p=this.resolve(t,i),m=p?.res,h=p?.usedKey||s,g=p?.exactUsedKey||s,_=[`[object Number]`,`[object Function]`,`[object RegExp]`],v=i.joinArrays===void 0?this.options.joinArrays:i.joinArrays,y=!this.i18nFormat||this.i18nFormat.handleAsObject,b=i.count!==void 0&&!X(i.count),x=e.hasDefaultValue(i),S=b?this.pluralResolver.getSuffix(d,i.count,i):``,C=i.ordinal&&b?this.pluralResolver.getSuffix(d,i.count,{ordinal:!1}):``,w=b&&!i.ordinal&&i.count===0,T=w&&i[`defaultValue${this.options.pluralSeparator}zero`]||i[`defaultValue${S}`]||i[`defaultValue${C}`]||i.defaultValue,E=m;y&&!m&&x&&(E=T);let D=Ni(E),O=Object.prototype.toString.apply(E);if(y&&E&&D&&!_.includes(O)&&!(X(v)&&Array.isArray(E))){if(!i.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn(`accessing an object - but returnObjects options is not enabled!`);let e=this.options.returnedObjectHandler?this.options.returnedObjectHandler(h,E,{...i,ns:c}):`key '${s} (${this.language})' returned an object instead of string.`;return a?(p.res=e,p.usedParams=this.getUsedParamsDetails(i),p):e}if(o){let e=Array.isArray(E),t=e?[]:{},n=e?g:h;for(let e in E)if(Object.prototype.hasOwnProperty.call(E,e)){let r=`${n}${o}${e}`;x&&!m?t[e]=this.translate(r,{...i,defaultValue:Ni(T)?T[e]:void 0,joinArrays:!1,ns:c}):t[e]=this.translate(r,{...i,joinArrays:!1,ns:c}),t[e]===r&&(t[e]=E[e])}m=t}}else if(y&&X(v)&&Array.isArray(m))m=m.join(v),m&&=this.extendTranslation(m,t,i,r);else{let e=!1,n=!1;!this.isValidLookup(m)&&x&&(e=!0,m=T),this.isValidLookup(m)||(n=!0,m=s);let a=(i.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&n?void 0:m,c=x&&T!==m&&this.options.updateMissing;if(n||e||c){if(this.logger.log(c?`updateKey`:`missingKey`,d,l,b&&!c?`${s}${this.pluralResolver.getSuffix(d,i.count,i)}`:s,c?T:m),o){let e=this.resolve(s,{...i,keySeparator:!1});e&&e.res&&this.logger.warn(`Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.`)}let e=[],t=this.languageUtils.getFallbackCodes(this.options.fallbackLng,i.lng||this.language);if(this.options.saveMissingTo===`fallback`&&t&&t[0])for(let n=0;n<t.length;n++)e.push(t[n]);else this.options.saveMissingTo===`all`?e=this.languageUtils.toResolveHierarchy(i.lng||this.language):e.push(i.lng||this.language);let n=(e,t,n)=>{let r=x&&n!==m?n:a;this.options.missingKeyHandler?this.options.missingKeyHandler(e,l,t,r,c,i):this.backendConnector?.saveMissing&&this.backendConnector.saveMissing(e,l,t,r,c,i),this.emit(`missingKey`,e,l,t,m)};this.options.saveMissing&&(this.options.saveMissingPlurals&&b?e.forEach(e=>{let t=this.pluralResolver.getSuffixes(e,i);w&&i[`defaultValue${this.options.pluralSeparator}zero`]&&!t.includes(`${this.options.pluralSeparator}zero`)&&t.push(`${this.options.pluralSeparator}zero`),t.forEach(t=>{n([e],s+t,i[`defaultValue${t}`]||T)})}):n(e,s,T))}m=this.extendTranslation(m,t,i,p,r),n&&m===s&&this.options.appendNamespaceToMissingKey&&(m=`${l}${u}${s}`),(n||e)&&this.options.parseMissingKeyHandler&&(m=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${l}${u}${s}`:s,e?m:void 0,i))}return a?(p.res=m,p.usedParams=this.getUsedParamsDetails(i),p):m}extendTranslation(e,t,n,r,i){if(this.i18nFormat?.parse)e=this.i18nFormat.parse(e,{...this.options.interpolation.defaultVariables,...n},n.lng||this.language||r.usedLng,r.usedNS,r.usedKey,{resolved:r});else if(!n.skipInterpolation){n.interpolation&&this.interpolator.init({...n,interpolation:{...this.options.interpolation,...n.interpolation}});let a=X(e)&&(n?.interpolation?.skipOnVariables===void 0?this.options.interpolation.skipOnVariables:n.interpolation.skipOnVariables),o;if(a){let t=e.match(this.interpolator.nestingRegexp);o=t&&t.length}let s=n.replace&&!X(n.replace)?n.replace:n;if(this.options.interpolation.defaultVariables&&(s={...this.options.interpolation.defaultVariables,...s}),e=this.interpolator.interpolate(e,s,n.lng||this.language||r.usedLng,n),a){let t=e.match(this.interpolator.nestingRegexp),r=t&&t.length;o<r&&(n.nest=!1)}!n.lng&&r&&r.res&&(n.lng=this.language||r.usedLng),n.nest!==!1&&(e=this.interpolator.nest(e,(...e)=>i?.[0]===e[0]&&!n.context?(this.logger.warn(`It seems you are nesting recursively key: ${e[0]} in key: ${t[0]}`),null):this.translate(...e,t),n)),n.interpolation&&this.interpolator.reset()}let a=n.postProcess||this.options.postProcess,o=X(a)?[a]:a;return e!=null&&o?.length&&n.applyPostProcessor!==!1&&(e=ki.handle(o,e,t,this.options&&this.options.postProcessPassResolved?{i18nResolved:{...r,usedParams:this.getUsedParamsDetails(n)},...n}:n,this)),e}resolve(e,t={}){let n,r,i,a,o;return X(e)&&(e=[e]),Array.isArray(e)&&(e=e.map(e=>typeof e==`function`?Mi(e,{...this.options,...t}):e)),e.forEach(e=>{if(this.isValidLookup(n))return;let s=this.extractFromKey(e,t),c=s.key;r=c;let l=s.namespaces;this.options.fallbackNS&&(l=l.concat(this.options.fallbackNS));let u=t.count!==void 0&&!X(t.count),d=u&&!t.ordinal&&t.count===0,f=t.context!==void 0&&(X(t.context)||typeof t.context==`number`)&&t.context!==``,p=t.lngs?t.lngs:this.languageUtils.toResolveHierarchy(t.lng||this.language,t.fallbackLng);l.forEach(e=>{this.isValidLookup(n)||(o=e,!this.checkedLoadedFor[`${p[0]}-${e}`]&&this.utils?.hasLoadedNamespace&&!this.utils?.hasLoadedNamespace(o)&&(this.checkedLoadedFor[`${p[0]}-${e}`]=!0,this.logger.warn(`key "${r}" for languages "${p.join(`, `)}" won't get resolved as namespace "${o}" was not yet loaded`,`This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!`)),p.forEach(r=>{if(this.isValidLookup(n))return;a=r;let o=[c];if(this.i18nFormat?.addLookupKeys)this.i18nFormat.addLookupKeys(o,c,r,e,t);else{let e;u&&(e=this.pluralResolver.getSuffix(r,t.count,t));let n=`${this.options.pluralSeparator}zero`,i=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(u&&(t.ordinal&&e.startsWith(i)&&o.push(c+e.replace(i,this.options.pluralSeparator)),o.push(c+e),d&&o.push(c+n)),f){let r=`${c}${this.options.contextSeparator||`_`}${t.context}`;o.push(r),u&&(t.ordinal&&e.startsWith(i)&&o.push(r+e.replace(i,this.options.pluralSeparator)),o.push(r+e),d&&o.push(r+n))}}let s;for(;s=o.pop();)this.isValidLookup(n)||(i=s,n=this.getResource(r,e,s,t))}))})}),{res:n,usedKey:r,exactUsedKey:i,usedLng:a,usedNS:o}}isValidLookup(e){return e!==void 0&&!(!this.options.returnNull&&e===null)&&!(!this.options.returnEmptyString&&e===``)}getResource(e,t,n,r={}){return this.i18nFormat?.getResource?this.i18nFormat.getResource(e,t,n,r):this.resourceStore.getResource(e,t,n,r)}getUsedParamsDetails(e={}){let t=[`defaultValue`,`ordinal`,`context`,`replace`,`lng`,`lngs`,`fallbackLng`,`ns`,`keySeparator`,`nsSeparator`,`returnObjects`,`returnDetails`,`joinArrays`,`postProcess`,`interpolation`],n=e.replace&&!X(e.replace),r=n?e.replace:e;if(n&&e.count!==void 0&&(r.count=e.count),this.options.interpolation.defaultVariables&&(r={...this.options.interpolation.defaultVariables,...r}),!n){r={...r};for(let e of t)delete r[e]}return r}static hasDefaultValue(e){for(let t in e)if(Object.prototype.hasOwnProperty.call(e,t)&&t.startsWith(`defaultValue`)&&e[t]!==void 0)return!0;return!1}},Fi=class{constructor(e){this.options=e,this.supportedLngs=this.options.supportedLngs||!1,this.logger=Ei.create(`languageUtils`)}getScriptPartFromCode(e){if(e=wi(e),!e||!e.includes(`-`))return null;let t=e.split(`-`);return t.length===2||(t.pop(),t[t.length-1].toLowerCase()===`x`)?null:this.formatLanguageCode(t.join(`-`))}getLanguagePartFromCode(e){if(e=wi(e),!e||!e.includes(`-`))return e;let t=e.split(`-`);return this.formatLanguageCode(t[0])}formatLanguageCode(e){if(X(e)&&e.includes(`-`)){let t;try{t=Intl.getCanonicalLocales(e)[0]}catch{}return t&&this.options.lowerCaseLng&&(t=t.toLowerCase()),t||(this.options.lowerCaseLng?e.toLowerCase():e)}return this.options.cleanCode||this.options.lowerCaseLng?e.toLowerCase():e}isSupportedCode(e){return(this.options.load===`languageOnly`||this.options.nonExplicitSupportedLngs)&&(e=this.getLanguagePartFromCode(e)),!this.supportedLngs||!this.supportedLngs.length||this.supportedLngs.includes(e)}getBestMatchFromCodes(e){if(!e)return null;let t;return e.forEach(e=>{if(t)return;let n=this.formatLanguageCode(e);(!this.options.supportedLngs||this.isSupportedCode(n))&&(t=n)}),!t&&this.options.supportedLngs&&e.forEach(e=>{if(t)return;let n=this.getScriptPartFromCode(e);if(this.isSupportedCode(n))return t=n;let r=this.getLanguagePartFromCode(e);if(this.isSupportedCode(r))return t=r;t=this.options.supportedLngs.find(e=>e===r?!0:!e.includes(`-`)&&!r.includes(`-`)?!1:!!(e.includes(`-`)&&!r.includes(`-`)&&e.slice(0,e.indexOf(`-`))===r||e.startsWith(r)&&r.length>1))}),t||=this.getFallbackCodes(this.options.fallbackLng)[0],t}getFallbackCodes(e,t){if(!e)return[];if(typeof e==`function`&&(e=e(t)),X(e)&&(e=[e]),Array.isArray(e))return e;if(!t)return e.default||[];let n=e[t];return n||=e[this.getScriptPartFromCode(t)],n||=e[this.formatLanguageCode(t)],n||=e[this.getLanguagePartFromCode(t)],n||=e.default,n||[]}toResolveHierarchy(e,t){let n=this.getFallbackCodes((t===!1?[]:t)||this.options.fallbackLng||[],e),r=[],i=e=>{e&&(this.isSupportedCode(e)?r.push(e):this.logger.warn(`rejecting language code not found in supportedLngs: ${e}`))};return X(e)&&(e.includes(`-`)||e.includes(`_`))?(this.options.load!==`languageOnly`&&i(this.formatLanguageCode(e)),this.options.load!==`languageOnly`&&this.options.load!==`currentOnly`&&i(this.getScriptPartFromCode(e)),this.options.load!==`currentOnly`&&i(this.getLanguagePartFromCode(e))):X(e)&&i(this.formatLanguageCode(e)),n.forEach(e=>{r.includes(e)||i(this.formatLanguageCode(e))}),r}},Ii={zero:0,one:1,two:2,few:3,many:4,other:5},Li={select:e=>e===1?`one`:`other`,resolvedOptions:()=>({pluralCategories:[`one`,`other`]})},Ri=class{constructor(e,t={}){this.languageUtils=e,this.options=t,this.logger=Ei.create(`pluralResolver`),this.pluralRulesCache={}}clearCache(){this.pluralRulesCache={}}getRule(e,t={}){let n=wi(e===`dev`?`en`:e),r=t.ordinal?`ordinal`:`cardinal`,i=JSON.stringify({cleanedCode:n,type:r});if(i in this.pluralRulesCache)return this.pluralRulesCache[i];let a;try{a=new Intl.PluralRules(n,{type:r})}catch{if(typeof Intl>`u`)return this.logger.error(`No Intl support, please use an Intl polyfill!`),Li;if(!e.match(/-|_/))return Li;let n=this.languageUtils.getLanguagePartFromCode(e);a=this.getRule(n,t)}return this.pluralRulesCache[i]=a,a}needsPlural(e,t={}){let n=this.getRule(e,t);return n||=this.getRule(`dev`,t),n?.resolvedOptions().pluralCategories.length>1}getPluralFormsOfKey(e,t,n={}){return this.getSuffixes(e,n).map(e=>`${t}${e}`)}getSuffixes(e,t={}){let n=this.getRule(e,t);return n||=this.getRule(`dev`,t),n?n.resolvedOptions().pluralCategories.sort((e,t)=>Ii[e]-Ii[t]).map(e=>`${this.options.prepend}${t.ordinal?`ordinal${this.options.prepend}`:``}${e}`):[]}getSuffix(e,t,n={}){let r=this.getRule(e,n);return r?`${this.options.prepend}${n.ordinal?`ordinal${this.options.prepend}`:``}${r.select(t)}`:(this.logger.warn(`no plural rule found for: ${e}`),this.getSuffix(`dev`,t,n))}},zi=(e,t,n,r=`.`,i=!0)=>{let a=mi(e,t,n);return!a&&i&&X(n)&&(a=Ci(e,n,r),a===void 0&&(a=Ci(t,n,r))),a},Bi=e=>e.replace(/\$/g,`$$$$`),Vi=class{constructor(e={}){this.logger=Ei.create(`interpolator`),this.options=e,this.format=e?.interpolation?.format||(e=>e),this.init(e)}init(e={}){e.interpolation||={escapeValue:!0};let{escape:t,escapeValue:n,useRawValueToEscape:r,prefix:i,prefixEscaped:a,suffix:o,suffixEscaped:s,formatSeparator:c,unescapeSuffix:l,unescapePrefix:u,nestingPrefix:d,nestingPrefixEscaped:f,nestingSuffix:p,nestingSuffixEscaped:m,nestingOptionsSeparator:h,maxReplaces:g,alwaysFormat:_}=e.interpolation;this.escape=t===void 0?vi:t,this.escapeValue=n===void 0?!0:n,this.useRawValueToEscape=r===void 0?!1:r,this.prefix=i?gi(i):a||`{{`,this.suffix=o?gi(o):s||`}}`,this.formatSeparator=c||`,`,this.unescapePrefix=l?``:u?gi(u):`-`,this.unescapeSuffix=this.unescapePrefix?``:l?gi(l):``,this.nestingPrefix=d?gi(d):f||gi(`$t(`),this.nestingSuffix=p?gi(p):m||gi(`)`),this.nestingOptionsSeparator=h||`,`,this.maxReplaces=g||1e3,this.alwaysFormat=_===void 0?!1:_,this.resetRegExp()}reset(){this.options&&this.init(this.options)}resetRegExp(){let e=(e,t)=>e?.source===t?(e.lastIndex=0,e):new RegExp(t,`g`);this.regexp=e(this.regexp,`${this.prefix}(.+?)${this.suffix}`),this.regexpUnescape=e(this.regexpUnescape,`${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`),this.nestingRegexp=e(this.nestingRegexp,`${this.nestingPrefix}((?:[^()"']+|"[^"]*"|'[^']*'|\\((?:[^()]|"[^"]*"|'[^']*')*\\))*?)${this.nestingSuffix}`)}interpolate(e,t,n,r){let i,a,o,s=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{},c=e=>{if(!e.includes(this.formatSeparator)){let i=zi(t,s,e,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(i,void 0,n,{...r,...t,interpolationkey:e}):i}let i=e.split(this.formatSeparator),a=i.shift().trim(),o=i.join(this.formatSeparator).trim();return this.format(zi(t,s,a,this.options.keySeparator,this.options.ignoreJSONStructure),o,n,{...r,...t,interpolationkey:a})};this.resetRegExp(),!this.escapeValue&&typeof e==`string`&&/\$t\([^)]*\{[^}]*\{\{/.test(e)&&this.logger.warn(`nesting options string contains interpolated variables with escapeValue: false — if any of those values are attacker-controlled they can inject additional nesting options (e.g. redirect lng/ns). Sanitise untrusted input before passing it to t(), or keep escapeValue: true.`);let l=r?.missingInterpolationHandler||this.options.missingInterpolationHandler,u=r?.interpolation?.skipOnVariables===void 0?this.options.interpolation.skipOnVariables:r.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:e=>Bi(e)},{regex:this.regexp,safeValue:e=>this.escapeValue?Bi(this.escape(e)):Bi(e)}].forEach(t=>{for(o=0;i=t.regex.exec(e);){let n=i[1].trim();if(a=c(n),a===void 0)if(typeof l==`function`){let t=l(e,i,r);a=X(t)?t:``}else if(r&&Object.prototype.hasOwnProperty.call(r,n))a=``;else if(u){a=i[0];continue}else this.logger.warn(`missed to pass in variable ${n} for interpolating ${e}`),a=``;else!X(a)&&!this.useRawValueToEscape&&(a=ai(a));let s=t.safeValue(a);if(e=e.replace(i[0],s),u?(t.regex.lastIndex+=a.length,t.regex.lastIndex-=i[0].length):t.regex.lastIndex=0,o++,o>=this.maxReplaces)break}}),e}nest(e,t,n={}){let r,i,a,o=(e,t)=>{let n=this.nestingOptionsSeparator;if(!e.includes(n))return e;let r=e.split(RegExp(`${gi(n)}[ ]*{`)),i=`{${r[1]}`;e=r[0],i=this.interpolate(i,a);let o=i.match(/'/g),s=i.match(/"/g);((o?.length??0)%2==0&&!s||(s?.length??0)%2!=0)&&(i=i.replace(/'/g,`"`));try{a=JSON.parse(i),t&&(a={...t,...a})}catch(t){return this.logger.warn(`failed parsing options string in nesting for key ${e}`,t),`${e}${n}${i}`}return a.defaultValue&&a.defaultValue.includes(this.prefix)&&delete a.defaultValue,e};for(;r=this.nestingRegexp.exec(e);){let s=[];a={...n},a=a.replace&&!X(a.replace)?a.replace:a,a.applyPostProcessor=!1,delete a.defaultValue;let c=/{.*}/.test(r[1])?r[1].lastIndexOf(`}`)+1:r[1].indexOf(this.formatSeparator);if(c!==-1&&(s=r[1].slice(c).split(this.formatSeparator).map(e=>e.trim()).filter(Boolean),r[1]=r[1].slice(0,c)),i=t(o.call(this,r[1].trim(),a),a),i&&r[0]===e&&!X(i))return i;X(i)||(i=ai(i)),i||=(this.logger.warn(`missed to resolve ${r[1]} for nesting ${e}`),``),s.length&&(i=s.reduce((e,t)=>this.format(e,t,n.lng,{...n,interpolationkey:r[1].trim()}),i.trim())),e=e.replace(r[0],i),this.regexp.lastIndex=0}return e}},Hi=e=>{let t=e.toLowerCase().trim(),n={};if(e.includes(`(`)){let r=e.split(`(`);t=r[0].toLowerCase().trim();let i=r[1].slice(0,-1);t===`currency`&&!i.includes(`:`)?n.currency||=i.trim():t===`relativetime`&&!i.includes(`:`)?n.range||=i.trim():i.split(`;`).forEach(e=>{if(e){let[t,...r]=e.split(`:`),i=r.join(`:`).trim().replace(/^'+|'+$/g,``),a=t.trim();n[a]||(n[a]=i),i===`false`&&(n[a]=!1),i===`true`&&(n[a]=!0),isNaN(i)||(n[a]=parseInt(i,10))}})}return{formatName:t,formatOptions:n}},Ui=e=>{let t={};return(n,r,i)=>{let a=i;i&&i.interpolationkey&&i.formatParams&&i.formatParams[i.interpolationkey]&&i[i.interpolationkey]&&(a={...a,[i.interpolationkey]:void 0});let o=r+JSON.stringify(a),s=t[o];return s||(s=e(wi(r),i),t[o]=s),s(n)}},Wi=e=>(t,n,r)=>e(wi(n),r)(t),Gi=class{constructor(e={}){this.logger=Ei.create(`formatter`),this.options=e,this.init(e)}init(e,t={interpolation:{}}){this.formatSeparator=t.interpolation.formatSeparator||`,`;let n=t.cacheInBuiltFormats?Ui:Wi;this.formats={number:n((e,t)=>{let n=new Intl.NumberFormat(e,{...t});return e=>n.format(e)}),currency:n((e,t)=>{let n=new Intl.NumberFormat(e,{...t,style:`currency`});return e=>n.format(e)}),datetime:n((e,t)=>{let n=new Intl.DateTimeFormat(e,{...t});return e=>n.format(e)}),relativetime:n((e,t)=>{let n=new Intl.RelativeTimeFormat(e,{...t});return e=>n.format(e,t.range||`day`)}),list:n((e,t)=>{let n=new Intl.ListFormat(e,{...t});return e=>n.format(e)})}}add(e,t){this.formats[e.toLowerCase().trim()]=t}addCached(e,t){this.formats[e.toLowerCase().trim()]=Ui(t)}format(e,t,n,r={}){if(!t||e==null)return e;let i=t.split(this.formatSeparator),a=[];for(let e=0;e<i.length;e++){let t=i[e];for(;t.indexOf(`(`)>-1&&!t.includes(`)`)&&e+1<i.length;)t=`${t}${this.formatSeparator}${i[++e]}`;a.push(t)}return a.reduce((e,t)=>{let{formatName:i,formatOptions:a}=Hi(t);if(this.formats[i]){let t=e;try{let o=r?.formatParams?.[r.interpolationkey]||{},s=o.locale||o.lng||r.locale||r.lng||n;t=this.formats[i](e,s,{...a,...r,...o})}catch(e){this.logger.warn(e)}return t}else this.logger.warn(`there was no format function for ${i}`);return e},e)}},Ki=(e,t)=>{e.pending[t]!==void 0&&(delete e.pending[t],e.pendingCount--)},qi=class extends Di{constructor(e,t,n,r={}){super(),this.backend=e,this.store=t,this.services=n,this.languageUtils=n.languageUtils,this.options=r,this.logger=Ei.create(`backendConnector`),this.waitingReads=[],this.maxParallelReads=r.maxParallelReads||10,this.readingCalls=0,this.maxRetries=r.maxRetries>=0?r.maxRetries:5,this.retryTimeout=r.retryTimeout>=1?r.retryTimeout:350,this.state={},this.queue=[],this.backend?.init?.(n,r.backend,r)}queueLoad(e,t,n,r){let i={},a={},o={},s={};return e.forEach(e=>{let r=!0;t.forEach(t=>{let o=`${e}|${t}`;!n.reload&&this.store.hasResourceBundle(e,t)?this.state[o]=2:this.state[o]<0||(this.state[o]===1?a[o]===void 0&&(a[o]=!0):(this.state[o]=1,r=!1,a[o]===void 0&&(a[o]=!0),i[o]===void 0&&(i[o]=!0),s[t]===void 0&&(s[t]=!0)))}),r||(o[e]=!0)}),(Object.keys(i).length||Object.keys(a).length)&&this.queue.push({pending:a,pendingCount:Object.keys(a).length,loaded:{},errors:[],callback:r}),{toLoad:Object.keys(i),pending:Object.keys(a),toLoadLanguages:Object.keys(o),toLoadNamespaces:Object.keys(s)}}loaded(e,t,n){let r=e.split(`|`),i=r[0],a=r[1];t&&this.emit(`failedLoading`,i,a,t),!t&&n&&this.store.addResourceBundle(i,a,n,void 0,void 0,{skipCopy:!0}),this.state[e]=t?-1:2,t&&n&&(this.state[e]=0);let o={};this.queue.forEach(n=>{fi(n.loaded,[i],a),Ki(n,e),t&&n.errors.push(t),n.pendingCount===0&&!n.done&&(Object.keys(n.loaded).forEach(e=>{o[e]||(o[e]={});let t=n.loaded[e];t.length&&t.forEach(t=>{o[e][t]===void 0&&(o[e][t]=!0)})}),n.done=!0,n.errors.length?n.callback(n.errors):n.callback())}),this.emit(`loaded`,o),this.queue=this.queue.filter(e=>!e.done)}read(e,t,n,r=0,i=this.retryTimeout,a){if(!e.length)return a(null,{});if(this.readingCalls>=this.maxParallelReads){this.waitingReads.push({lng:e,ns:t,fcName:n,tried:r,wait:i,callback:a});return}this.readingCalls++;let o=(o,s)=>{if(this.readingCalls--,this.waitingReads.length>0){let e=this.waitingReads.shift();this.read(e.lng,e.ns,e.fcName,e.tried,e.wait,e.callback)}if(o&&s&&r<this.maxRetries){setTimeout(()=>{this.read(e,t,n,r+1,i*2,a)},i);return}a(o,s)},s=this.backend[n].bind(this.backend);if(s.length===2){try{let n=s(e,t);n&&typeof n.then==`function`?n.then(e=>o(null,e)).catch(o):o(null,n)}catch(e){o(e)}return}return s(e,t,o)}prepareLoading(e,t,n={},r){if(!this.backend)return this.logger.warn(`No backend was added via i18next.use. Will not load resources.`),r&&r();X(e)&&(e=this.languageUtils.toResolveHierarchy(e)),X(t)&&(t=[t]);let i=this.queueLoad(e,t,n,r);if(!i.toLoad.length)return i.pending.length||r(),null;i.toLoad.forEach(e=>{this.loadOne(e)})}load(e,t,n){this.prepareLoading(e,t,{},n)}reload(e,t,n){this.prepareLoading(e,t,{reload:!0},n)}loadOne(e,t=``){let n=e.split(`|`),r=n[0],i=n[1];this.read(r,i,`read`,void 0,void 0,(n,a)=>{n&&this.logger.warn(`${t}loading namespace ${i} for language ${r} failed`,n),!n&&a&&this.logger.log(`${t}loaded namespace ${i} for language ${r}`,a),this.loaded(e,n,a)})}saveMissing(e,t,n,r,i,a={},o=()=>{}){if(this.services?.utils?.hasLoadedNamespace&&!this.services?.utils?.hasLoadedNamespace(t)){this.logger.warn(`did not save key "${n}" as the namespace "${t}" was not yet loaded`,`This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!`);return}if(!(n==null||n===``)){if(this.backend?.create){let s={...a,isUpdate:i},c=this.backend.create.bind(this.backend);if(c.length<6)try{let i;i=c.length===5?c(e,t,n,r,s):c(e,t,n,r),i&&typeof i.then==`function`?i.then(e=>o(null,e)).catch(o):o(null,i)}catch(e){o(e)}else c(e,t,n,r,o,s)}!e||!e[0]||this.store.addResource(e[0],t,n,r)}}},Ji=()=>({debug:!1,initAsync:!0,ns:[`translation`],defaultNS:[`translation`],fallbackLng:[`dev`],fallbackNS:!1,supportedLngs:!1,nonExplicitSupportedLngs:!1,load:`all`,preload:!1,keySeparator:`.`,nsSeparator:`:`,pluralSeparator:`_`,contextSeparator:`_`,enableSelector:!1,partialBundledLanguages:!1,saveMissing:!1,updateMissing:!1,saveMissingTo:`fallback`,saveMissingPlurals:!0,missingKeyHandler:!1,missingInterpolationHandler:!1,postProcess:!1,postProcessPassResolved:!1,returnNull:!1,returnEmptyString:!0,returnObjects:!1,joinArrays:!1,returnedObjectHandler:!1,parseMissingKeyHandler:!1,appendNamespaceToMissingKey:!1,appendNamespaceToCIMode:!1,overloadTranslationOptionHandler:e=>{let t={};if(typeof e[1]==`object`&&(t=e[1]),X(e[1])&&(t.defaultValue=e[1]),X(e[2])&&(t.tDescription=e[2]),typeof e[2]==`object`||typeof e[3]==`object`){let n=e[3]||e[2];Object.keys(n).forEach(e=>{t[e]=n[e]})}return t},interpolation:{escapeValue:!0,prefix:`{{`,suffix:`}}`,formatSeparator:`,`,unescapePrefix:`-`,nestingPrefix:`$t(`,nestingSuffix:`)`,nestingOptionsSeparator:`,`,maxReplaces:1e3,skipOnVariables:!0},cacheInBuiltFormats:!0}),Yi=e=>(X(e.ns)&&(e.ns=[e.ns]),X(e.fallbackLng)&&(e.fallbackLng=[e.fallbackLng]),X(e.fallbackNS)&&(e.fallbackNS=[e.fallbackNS]),e.supportedLngs&&!e.supportedLngs.includes(`cimode`)&&(e.supportedLngs=e.supportedLngs.concat([`cimode`])),e),Xi=()=>{},Zi=e=>{Object.getOwnPropertyNames(Object.getPrototypeOf(e)).forEach(t=>{typeof e[t]==`function`&&(e[t]=e[t].bind(e))})},Qi=class e extends Di{constructor(e={},t){if(super(),this.options=Yi(e),this.services={},this.logger=Ei,this.modules={external:[]},Zi(this),t&&!this.isInitialized&&!e.isClone){if(!this.options.initAsync)return this.init(e,t),this;setTimeout(()=>{this.init(e,t)},0)}}init(e={},t){this.isInitializing=!0,typeof e==`function`&&(t=e,e={}),e.defaultNS==null&&e.ns&&(X(e.ns)?e.defaultNS=e.ns:e.ns.includes(`translation`)||(e.defaultNS=e.ns[0]));let n=Ji();this.options={...n,...this.options,...Yi(e)},this.options.interpolation={...n.interpolation,...this.options.interpolation},e.keySeparator!==void 0&&(this.options.userDefinedKeySeparator=e.keySeparator),e.nsSeparator!==void 0&&(this.options.userDefinedNsSeparator=e.nsSeparator),typeof this.options.overloadTranslationOptionHandler!=`function`&&(this.options.overloadTranslationOptionHandler=n.overloadTranslationOptionHandler);let r=e=>e?typeof e==`function`?new e:e:null;if(!this.options.isClone){this.modules.logger?Ei.init(r(this.modules.logger),this.options):Ei.init(null,this.options);let e;e=this.modules.formatter?this.modules.formatter:Gi;let t=new Fi(this.options);this.store=new Oi(this.options.resources,this.options);let n=this.services;n.logger=Ei,n.resourceStore=this.store,n.languageUtils=t,n.pluralResolver=new Ri(t,{prepend:this.options.pluralSeparator}),e&&(n.formatter=r(e),n.formatter.init&&n.formatter.init(n,this.options),this.options.interpolation.format=n.formatter.format.bind(n.formatter)),n.interpolator=new Vi(this.options),n.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},n.backendConnector=new qi(r(this.modules.backend),n.resourceStore,n,this.options),n.backendConnector.on(`*`,(e,...t)=>{this.emit(e,...t)}),this.modules.languageDetector&&(n.languageDetector=r(this.modules.languageDetector),n.languageDetector.init&&n.languageDetector.init(n,this.options.detection,this.options)),this.modules.i18nFormat&&(n.i18nFormat=r(this.modules.i18nFormat),n.i18nFormat.init&&n.i18nFormat.init(this)),this.translator=new Pi(this.services,this.options),this.translator.on(`*`,(e,...t)=>{this.emit(e,...t)}),this.modules.external.forEach(e=>{e.init&&e.init(this)})}if(this.format=this.options.interpolation.format,t||=Xi,this.options.fallbackLng&&!this.services.languageDetector&&!this.options.lng){let e=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);e.length>0&&e[0]!==`dev`&&(this.options.lng=e[0])}!this.services.languageDetector&&!this.options.lng&&this.logger.warn(`init: no languageDetector is used and no lng is defined`),[`getResource`,`hasResourceBundle`,`getResourceBundle`,`getDataByLanguage`].forEach(e=>{this[e]=(...t)=>this.store[e](...t)}),[`addResource`,`addResources`,`addResourceBundle`,`removeResourceBundle`].forEach(e=>{this[e]=(...t)=>(this.store[e](...t),this)});let i=ii(),a=()=>{let e=(e,n)=>{this.isInitializing=!1,this.isInitialized&&!this.initializedStoreOnce&&this.logger.warn(`init: i18next is already initialized. You should call init just once!`),this.isInitialized=!0,this.options.isClone||this.logger.log(`initialized`,this.options),this.emit(`initialized`,this.options),i.resolve(n),t(e,n)};if((this.languages||this.isLanguageChangingTo)&&!this.isInitialized)return e(null,this.t.bind(this));this.changeLanguage(this.options.lng,e)};return this.options.resources||!this.options.initAsync?a():setTimeout(a,0),i}loadResources(e,t=Xi){let n=t,r=X(e)?e:this.language;if(typeof e==`function`&&(n=e),!this.options.resources||this.options.partialBundledLanguages){if(r?.toLowerCase()===`cimode`&&(!this.options.preload||this.options.preload.length===0))return n();let e=[],t=t=>{t&&t!==`cimode`&&this.services.languageUtils.toResolveHierarchy(t).forEach(t=>{t!==`cimode`&&(e.includes(t)||e.push(t))})};r?t(r):this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach(e=>t(e)),this.options.preload?.forEach?.(e=>t(e)),this.services.backendConnector.load(e,this.options.ns,e=>{!e&&!this.resolvedLanguage&&this.language&&this.setResolvedLanguage(this.language),n(e)})}else n(null)}reloadResources(e,t,n){let r=ii();return typeof e==`function`&&(n=e,e=void 0),typeof t==`function`&&(n=t,t=void 0),e||=this.languages,t||=this.options.ns,n||=Xi,this.services.backendConnector.reload(e,t,e=>{r.resolve(),n(e)}),r}use(e){if(!e)throw Error(`You are passing an undefined module! Please check the object you are passing to i18next.use()`);if(!e.type)throw Error(`You are passing a wrong module! Please check the object you are passing to i18next.use()`);return e.type===`backend`&&(this.modules.backend=e),(e.type===`logger`||e.log&&e.warn&&e.error)&&(this.modules.logger=e),e.type===`languageDetector`&&(this.modules.languageDetector=e),e.type===`i18nFormat`&&(this.modules.i18nFormat=e),e.type===`postProcessor`&&ki.addPostProcessor(e),e.type===`formatter`&&(this.modules.formatter=e),e.type===`3rdParty`&&this.modules.external.push(e),this}setResolvedLanguage(e){if(!(!e||!this.languages)&&![`cimode`,`dev`].includes(e)){for(let e=0;e<this.languages.length;e++){let t=this.languages[e];if(![`cimode`,`dev`].includes(t)&&this.store.hasLanguageSomeTranslations(t)){this.resolvedLanguage=t;break}}!this.resolvedLanguage&&!this.languages.includes(e)&&this.store.hasLanguageSomeTranslations(e)&&(this.resolvedLanguage=e,this.languages.unshift(e))}}changeLanguage(e,t){this.isLanguageChangingTo=e;let n=ii();this.emit(`languageChanging`,e);let r=e=>{this.language=e,this.languages=this.services.languageUtils.toResolveHierarchy(e),this.resolvedLanguage=void 0,this.setResolvedLanguage(e)},i=(i,a)=>{a?this.isLanguageChangingTo===e&&(r(a),this.translator.changeLanguage(a),this.isLanguageChangingTo=void 0,this.emit(`languageChanged`,a),this.logger.log(`languageChanged`,a)):this.isLanguageChangingTo=void 0,n.resolve((...e)=>this.t(...e)),t&&t(i,(...e)=>this.t(...e))},a=t=>{!e&&!t&&this.services.languageDetector&&(t=[]);let n=X(t)?t:t&&t[0],a=this.store.hasLanguageSomeTranslations(n)?n:this.services.languageUtils.getBestMatchFromCodes(X(t)?[t]:t);a&&(this.language||r(a),this.translator.language||this.translator.changeLanguage(a),this.services.languageDetector?.cacheUserLanguage?.(a)),this.loadResources(a,e=>{i(e,a)})};return!e&&this.services.languageDetector&&!this.services.languageDetector.async?a(this.services.languageDetector.detect()):!e&&this.services.languageDetector&&this.services.languageDetector.async?this.services.languageDetector.detect.length===0?this.services.languageDetector.detect().then(a):this.services.languageDetector.detect(a):a(e),n}getFixedT(e,t,n,r){let i=r?.scopeNs,a=(e,t,...r)=>{let o;o=typeof t==`object`?{...t}:this.options.overloadTranslationOptionHandler([e,t].concat(r)),o.lng=o.lng||a.lng,o.lngs=o.lngs||a.lngs;let s=o.ns!==void 0&&o.ns!==null;o.ns=o.ns||a.ns,o.keyPrefix!==``&&(o.keyPrefix=o.keyPrefix||n||a.keyPrefix);let c={...this.options,...o};Array.isArray(i)&&!s&&(c.ns=i),typeof o.keyPrefix==`function`&&(o.keyPrefix=Mi(o.keyPrefix,c));let l=this.options.keySeparator||`.`,u;return o.keyPrefix&&Array.isArray(e)?u=e.map(e=>(typeof e==`function`&&(e=Mi(e,c)),`${o.keyPrefix}${l}${e}`)):(typeof e==`function`&&(e=Mi(e,c)),u=o.keyPrefix?`${o.keyPrefix}${l}${e}`:e),this.t(u,o)};return X(e)?a.lng=e:a.lngs=e,a.ns=t,a.keyPrefix=n,a}t(...e){return this.translator?.translate(...e)}exists(...e){return this.translator?.exists(...e)}setDefaultNamespace(e){this.options.defaultNS=e}hasLoadedNamespace(e,t={}){if(!this.isInitialized)return this.logger.warn(`hasLoadedNamespace: i18next was not initialized`,this.languages),!1;if(!this.languages||!this.languages.length)return this.logger.warn(`hasLoadedNamespace: i18n.languages were undefined or empty`,this.languages),!1;let n=t.lng||this.resolvedLanguage||this.languages[0],r=this.options?this.options.fallbackLng:!1,i=this.languages[this.languages.length-1];if(n.toLowerCase()===`cimode`)return!0;let a=(e,t)=>{let n=this.services.backendConnector.state[`${e}|${t}`];return n===-1||n===0||n===2};if(t.precheck){let e=t.precheck(this,a);if(e!==void 0)return e}return!!(this.hasResourceBundle(n,e)||!this.services.backendConnector.backend||this.options.resources&&!this.options.partialBundledLanguages||a(n,e)&&(!r||a(i,e)))}loadNamespaces(e,t){let n=ii();return this.options.ns?(X(e)&&(e=[e]),e.forEach(e=>{this.options.ns.includes(e)||this.options.ns.push(e)}),this.loadResources(e=>{n.resolve(),t&&t(e)}),n):(t&&t(),Promise.resolve())}loadLanguages(e,t){let n=ii();X(e)&&(e=[e]);let r=this.options.preload||[],i=e.filter(e=>!r.includes(e)&&this.services.languageUtils.isSupportedCode(e));return i.length?(this.options.preload=r.concat(i),this.loadResources(e=>{n.resolve(),t&&t(e)}),n):(t&&t(),Promise.resolve())}dir(e){if(e||=this.resolvedLanguage||(this.languages?.length>0?this.languages[0]:this.language),!e)return`rtl`;try{let t=new Intl.Locale(e);if(t&&t.getTextInfo){let e=t.getTextInfo();if(e&&e.direction)return e.direction}}catch{}let t=`ar.shu.sqr.ssh.xaa.yhd.yud.aao.abh.abv.acm.acq.acw.acx.acy.adf.ads.aeb.aec.afb.ajp.apc.apd.arb.arq.ars.ary.arz.auz.avl.ayh.ayl.ayn.ayp.bbz.pga.he.iw.ps.pbt.pbu.pst.prp.prd.ug.ur.ydd.yds.yih.ji.yi.hbo.men.xmn.fa.jpr.peo.pes.prs.dv.sam.ckb`.split(`.`),n=this.services?.languageUtils||new Fi(Ji());return e.toLowerCase().indexOf(`-latn`)>1?`ltr`:t.includes(n.getLanguagePartFromCode(e))||e.toLowerCase().indexOf(`-arab`)>1?`rtl`:`ltr`}static createInstance(t={},n){let r=new e(t,n);return r.createInstance=e.createInstance,r}cloneInstance(t={},n=Xi){let r=t.forkResourceStore;r&&delete t.forkResourceStore;let i={...this.options,...t,isClone:!0},a=new e(i);if((t.debug!==void 0||t.prefix!==void 0)&&(a.logger=a.logger.clone(t)),[`store`,`services`,`language`].forEach(e=>{a[e]=this[e]}),a.services={...this.services},a.services.utils={hasLoadedNamespace:a.hasLoadedNamespace.bind(a)},r&&(a.store=new Oi(Object.keys(this.store.data).reduce((e,t)=>(e[t]={...this.store.data[t]},e[t]=Object.keys(e[t]).reduce((n,r)=>(n[r]={...e[t][r]},n),e[t]),e),{}),i),a.services.resourceStore=a.store),t.interpolation){let e={...Ji().interpolation,...this.options.interpolation,...t.interpolation},n={...i,interpolation:e};a.services.interpolator=new Vi(n)}return a.translator=new Pi(a.services,i),a.translator.on(`*`,(e,...t)=>{a.emit(e,...t)}),a.init(i,n),a.translator.options=i,a.translator.backendConnector.services.utils={hasLoadedNamespace:a.hasLoadedNamespace.bind(a)},a}toJSON(){return{options:this.options,store:this.store,language:this.language,languages:this.languages,resolvedLanguage:this.resolvedLanguage}}}.createInstance();Qi.createInstance,Qi.dir,Qi.init,Qi.loadResources,Qi.reloadResources,Qi.use,Qi.changeLanguage,Qi.getFixedT,Qi.t,Qi.exists,Qi.setDefaultNamespace,Qi.hasLoadedNamespace,Qi.loadNamespaces,Qi.loadLanguages;var $i=t((e=>{var t=n();function r(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var i=typeof Object.is==`function`?Object.is:r,a=t.useState,o=t.useEffect,s=t.useLayoutEffect,c=t.useDebugValue;function l(e,t){var n=t(),r=a({inst:{value:n,getSnapshot:t}}),i=r[0].inst,l=r[1];return s(function(){i.value=n,i.getSnapshot=t,u(i)&&l({inst:i})},[e,n,t]),o(function(){return u(i)&&l({inst:i}),e(function(){u(i)&&l({inst:i})})},[e]),c(n),n}function u(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!i(e,n)}catch{return!0}}function d(e,t){return t()}var f=typeof window>`u`||window.document===void 0||window.document.createElement===void 0?d:l;e.useSyncExternalStore=t.useSyncExternalStore===void 0?f:t.useSyncExternalStore})),ea=t(((e,t)=>{t.exports=$i()}))(),ta=/&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g,na={"&":`&`,"&":`&`,"<":`<`,"<":`<`,">":`>`,">":`>`,"'":`'`,"'":`'`,""":`"`,""":`"`," ":` `," ":` `,"©":`©`,"©":`©`,"®":`®`,"®":`®`,"…":`…`,"…":`…`,"/":`/`,"/":`/`},ra=e=>na[e],ia={bindI18n:`languageChanged`,bindI18nStore:``,transEmptyNodeValue:``,transSupportBasicHtmlNodes:!0,transWrapTextNodes:``,transKeepBasicHtmlNodesFor:[`br`,`strong`,`i`,`p`],useSuspense:!0,unescape:e=>e.replace(ta,ra),transDefaultProps:void 0},aa=(e={})=>{ia={...ia,...e}},oa=()=>ia,sa,ca=e=>{sa=e},la=()=>sa,ua={type:`3rdParty`,init(e){aa(e.options.react),ca(e)}},da=(0,D.createContext)(),fa=class{constructor(){this.usedNamespaces={}}addUsedNamespaces(e){e.forEach(e=>{this.usedNamespaces[e]||(this.usedNamespaces[e]=!0)})}getUsedNamespaces(){return Object.keys(this.usedNamespaces)}},pa=(e,t,n,r)=>{let i=[n,{code:t,...r||{}}];if(e?.services?.logger?.forward)return e.services.logger.forward(i,`warn`,`react-i18next::`,!0);ba(i[0])&&(i[0]=`react-i18next:: ${i[0]}`),e?.services?.logger?.warn?e.services.logger.warn(...i):console?.warn&&console.warn(...i)},ma={},ha=(e,t,n,r)=>{ba(n)&&ma[n]||(ba(n)&&(ma[n]=new Date),pa(e,t,n,r))},ga=(e,t)=>()=>{if(e.isInitialized)t();else{let n=()=>{setTimeout(()=>{e.off(`initialized`,n)},0),t()};e.on(`initialized`,n)}},_a=(e,t,n)=>{e.loadNamespaces(t,ga(e,n))},va=(e,t,n,r)=>{if(ba(n)&&(n=[n]),e.options.preload&&e.options.preload.indexOf(t)>-1)return _a(e,n,r);n.forEach(t=>{e.options.ns.indexOf(t)<0&&e.options.ns.push(t)}),e.loadLanguages(t,ga(e,r))},ya=(e,t,n={})=>!t.languages||!t.languages.length?(ha(t,`NO_LANGUAGES`,`i18n.languages were undefined or empty`,{languages:t.languages}),!0):t.hasLoadedNamespace(e,{lng:n.lng,precheck:(t,r)=>{if(n.bindI18n&&n.bindI18n.indexOf(`languageChanging`)>-1&&t.services.backendConnector.backend&&t.isLanguageChangingTo&&!r(t.isLanguageChangingTo,e))return!1}}),ba=e=>typeof e==`string`,xa=e=>typeof e==`object`&&!!e,Sa={t:(e,t)=>{if(ba(t))return t;if(xa(t)&&ba(t.defaultValue))return t.defaultValue;if(typeof e==`function`)return``;if(Array.isArray(e)){let t=e[e.length-1];return typeof t==`function`?``:t}return e},ready:!1},Ca=()=>()=>{},wa=(e,t={})=>{let{i18n:n}=t,{i18n:r,defaultNS:i}=(0,D.useContext)(da)||{},a=n||r||la();a&&!a.reportNamespaces&&(a.reportNamespaces=new fa),a||ha(a,`NO_I18NEXT_INSTANCE`,`useTranslation: You will need to pass in an i18next instance by using initReactI18next`);let o=(0,D.useMemo)(()=>({...oa(),...a?.options?.react,...t}),[a,t]),{useSuspense:s,keyPrefix:c}=o,l=e||i||a?.options?.defaultNS,u=ba(l)?[l]:l||[`translation`],d=(0,D.useMemo)(()=>u,u);a?.reportNamespaces?.addUsedNamespaces?.(d);let f=(0,D.useRef)(0),p=(0,D.useCallback)(e=>{if(!a)return Ca;let{bindI18n:t,bindI18nStore:n}=o,r=()=>{f.current+=1,e()};return t&&a.on(t,r),n&&a.store.on(n,r),()=>{t&&t.split(` `).forEach(e=>a.off(e,r)),n&&n.split(` `).forEach(e=>a.store.off(e,r))}},[a,o]),m=(0,D.useRef)(),h=(0,D.useCallback)(()=>{if(!a)return Sa;let e=!!(a.isInitialized||a.initializedStoreOnce)&&d.every(e=>ya(e,a,o)),n=t.lng||a.language,r=f.current,i=m.current;if(i&&i.ready===e&&i.lng===n&&i.keyPrefix===c&&i.revision===r)return i;let s={t:a.getFixedT(n,o.nsMode===`fallback`?d:d[0],c,{scopeNs:d}),ready:e,lng:n,keyPrefix:c,revision:r};return m.current=s,s},[a,d,c,o,t.lng]),[g,_]=(0,D.useState)(0),{t:v,ready:y}=(0,ea.useSyncExternalStore)(p,h,h);(0,D.useEffect)(()=>{if(a&&!y&&!s){let e=()=>_(e=>e+1);t.lng?va(a,t.lng,d,e):_a(a,d,e)}},[a,t.lng,d,y,s,g]);let b=a||{},x=(0,D.useRef)(null),S=(0,D.useRef)(),C=e=>{let t=Object.getOwnPropertyDescriptors(e);t.__original&&delete t.__original;let n=Object.create(Object.getPrototypeOf(e),t);if(!Object.prototype.hasOwnProperty.call(n,`__original`))try{Object.defineProperty(n,"__original",{value:e,writable:!1,enumerable:!1,configurable:!1})}catch{}return n},w=(0,D.useMemo)(()=>{let e=b,t=e?.language,n=e;e&&(x.current&&x.current.__original===e&&S.current===t?n=x.current:(n=C(e),x.current=n,S.current=t));let r=!y&&!s?(...e)=>(ha(a,`USE_T_BEFORE_READY`,`useTranslation: t was called before ready. When using useSuspense: false, make sure to check the ready flag before using t.`),v(...e)):v,i=[r,n,y];return i.t=r,i.i18n=n,i.ready=y,i},[v,b,y,b.resolvedLanguage,b.language,b.languages]);if(a&&s&&!y)throw new Promise(e=>{let n=()=>e();t.lng?va(a,t.lng,d,n):_a(a,d,n)});return w},Ta={"en-US":()=>o(async()=>{let{enUsTranslation:e}=await import(`./en-US-DOXBXLLy.js`);return{enUsTranslation:e}},[],import.meta.url).then(({enUsTranslation:e})=>e),"zh-CN":()=>o(async()=>{let{zhCnTranslation:e}=await import(`./zh-CN-C4xbZjjC.js`);return{zhCnTranslation:e}},[],import.meta.url).then(({zhCnTranslation:e})=>e)},Ea=new Map,Da=e=>{let t=Ea.get(e);return t||(t=Ta[e](),Ea.set(e,t)),t},Oa={app:{errorBoundary:{title:`Un problème est survenu`,description:`Une erreur inattendue s'est produite dans cette section. Vous pouvez réessayer ou recharger la page si le problème persiste.`,tryAgain:`Réessayer`,showDetails:`Afficher les détails`,hideDetails:`Masquer les détails`},passwordGate:{title:`Entrez le mot de passe d'accès`,description:`Une vérification du mot de passe est requise avant d'accéder à l'application.`,passwordLabel:`Mot de passe d'accès`,passwordPlaceholder:`Entrez le mot de passe d'accès`,submit:`Vérifier et continuer`,validation:{required:`Veuillez entrer le mot de passe d'accès`,verifyFailed:`Échec de la vérification du mot de passe`}},notifications:{toolApproval:{title:`Approbation requise : {{tool}}`,body:`L'outil {{tool}} nécessite votre approbation avant exécution`,unknownTool:`Outil inconnu`},contextPressure:{title:`Fenêtre de contexte presque épuisée`},backgroundTask:{completedTitle:`Tâche en arrière-plan terminée`,completedBody:`« {{title}} » est terminé`,completedFallback:`Une tâche en arrière-plan est terminée`},clarification:{title:`Bodhi AI attend votre réponse`,fallbackBody:`L'agent attend une réponse à une question`},conversationSummarized:`Conversation résumée : {{messages}} messages compressés, {{tokens}} jetons économisés`,allTasksCompleted:`Toutes les tâches sont terminées ! Tours totaux : {{rounds}}, Appels d'outils : {{toolCalls}}`,evaluatingTasks:`Évaluation de {{count}} tâche(s)...`,evaluationCompleteUpdated:`Évaluation terminée : {{count}} tâche(s) mise(s) à jour.`,evaluationCompleteNoUpdates:`Évaluation terminée : aucune mise à jour nécessaire`}},commandPalette:{searchPlaceholder:`Rechercher sessions, paramètres et actions`,navigationHint:`Utilisez ↑↓ pour naviguer, Entrée pour ouvrir, Échap pour fermer.`,empty:`Aucune commande correspondante`,groups:{quickActions:`Actions rapides`,settings:`Paramètres système`},badges:{quickAction:`Action`,pinned:`Épinglé`,running:`En cours`,child:`Enfant`,childSession:`Session enfant`,rootSession:`Session`},actions:{newSession:`Créer une nouvelle session`,openProviderSettings:`Ouvrir les paramètres fournisseur`,openMcpSettings:`Ouvrir les paramètres MCP`,openWorkflowSettings:`Ouvrir les paramètres de flux de travail`,openSessionsSettings:`Ouvrir le moniteur de sessions`,openSchedulesSettings:`Ouvrir les planifications`},errors:{actionFailed:`Échec de la commande`}},setup:{welcome:{heading:`Bienvenue dans Bodhi`,description:`Bodhi est votre assistant de développement alimenté par l'IA. Configurez un fournisseur IA pour commencer, ou lancez-vous directement.`,providerHint:`Pour commencer à discuter, vous devez configurer un fournisseur IA (ex. OpenAI, Anthropic) avec une clé API.`,proxyHint:`Derrière un proxy d'entreprise ? Vous pouvez configurer les paramètres proxy plus tard dans Paramètres système > Réseau.`},button:{getStarted:`Commencer`,configureProvider:`Configurer le fournisseur`},complete:{title:`Tout est prêt !`,restartMessage:`Rechargement de l'application...`},error:{completeFailed:`Échec de la configuration. Veuillez réessayer.`}},onboarding:{welcome:{title:`Bienvenue dans Bodhi !`,description:`Bodhi est votre assistant de développement alimenté par l'IA. Faisons un rapide tour d'horizon.`},newSession:{title:`Nouvelle session`,description:`Cliquez ici pour démarrer une nouvelle session de chat avec l'assistant IA.`},taskTemplates:{title:`Modèles de tâches`,description:`Choisissez parmi des modèles prédéfinis : revue de code, investigation de bug, refactoring, etc.`},modelPicker:{title:`Sélection du modèle`,description:`Changez de modèle IA et de fournisseur à tout moment depuis ici.`},sidebar:{title:`Barre latérale des sessions`,description:`Recherchez, filtrez, épinglez et naviguez entre vos conversations.`},settings:{title:`Paramètres`,description:`Configurez les fournisseurs IA, proxy, mappages de modèles, serveurs MCP et plus encore.`}},common:{saveAnyway:`Enregistrer quand même`,parentDirectory:`Répertoire parent`,currentPath:`Chemin actuel\xA0:`,cancel:`Annuler`,ok:`OK`,apply:`Appliquer`,save:`Enregistrer`,delete:`Supprimer`,yes:`Oui`,no:`Non`,home:`Accueil`,download:`Télécharger`,directory:`Répertoire`,file:`Fichier`},chat:{workspace:{modalTitle:`Définir le chemin de l'espace de travail`,invalidTitle:`Chemin d'accès à l'espace de travail non valide`,issuesDetected:`Problèmes potentiels détectés avec le chemin de l'espace de travail\xA0:`,confirmSaveInvalid:`Voulez-vous toujours enregistrer ce chemin\xA0?`,errorEnterPath:`Veuillez saisir un chemin d'accès à l'espace de travail`,errorSaveFailed:`Échec de l'enregistrement du chemin de l'espace de travail`,placeholder:`par ex. /Utilisateurs/alice/Espace de travail/MonProjet`,browseFolder:`Parcourir le dossier`,descriptionTitle:`Description du chemin de l'espace de travail`,descriptionP1:`Définissez un chemin d'accès à l'espace de travail afin que les références de fichiers et les outils de l'espace de travail puissent résoudre les fichiers de manière fiable.`,descriptionP2:`Choisissez un dossier de projet existant. Vous pouvez toujours continuer avec un chemin non valide, mais les fonctionnalités associées risquent de ne pas fonctionner correctement.`,checkTitle:`Vérification du chemin de l'espace de travail`,checkDescription:`La validation du chemin de l'espace de travail a échoué.`,label:`Espace de travail`,folderSelected:`Dossier sélectionné avec succès`},folderBrowser:{title:`Sélectionnez le dossier de l'espace de travail`,selectCurrent:`Sélectionnez le dossier actuel`,emptyFolder:`Ce dossier est vide`,tip:`Astuce\xA0:\xA0cliquez sur un dossier pour y accéder, cliquez sur "Sélectionner le dossier actuel" pour confirmer`,readFolderError:`Impossible de lire le dossier`},input:{placeholder:`Envoyer un message...`,placeholderWithReference:`Envoyer un message (inclut la référence)`,placeholderWithWorkflows:`Envoyer un message... (saisissez '/' pour les workflows)`,toolCallsOnly:`Appels d'outils uniquement (outils autorisés\xA0: {{tools}})`,autoPrefixMode:`Mode de préfixe automatique\xA0: {{prefix}} (saisissez «\xA0/\xA0» pour sélectionner les outils)`,toolSpecificMode:`Mode spécifique à l'outil (outils autorisés\xA0: {{tools}})`,processingFiles:`Traitement des fichiers…`,imageCountSingular:`Image {{count}}`,imageCountPlural:`Images {{count}}`,reasoning:{max:`Max`}},actions:{regenerate:`Régénérer la réponse`,retryFailed:`Réessayer la demande ayant échoué`,retryOptions:`Options de nouvelle tentative`,cancelRequest:`Annuler la demande`,sendMessage:`Envoyer un message`,copyMessage:`Copier le message`,referenceMessage:`Message de référence`,generateTitle:`Générer un titre IA`,unpin:`Détacher`,pin:`Épingler`},fileReference:{title:`@ Référence du fichier`,setWorkspace:`Définir l'espace de travail`,noMatches:`Aucun fichier correspondant trouvé`,emptyDirectory:`Le répertoire est vide`},commandSelector:{types:{mcp:`MCP`}},streaming:{assistant:`Assistant`}},settings:{configTab:{toolsLoadFailed:`Échec du chargement des outils disponibles`,toolsReloadSuccess:`Liste d'outils rechargée`,toolsSaveSuccess:`Paramètres de l'outil enregistrés avec succès`,toolsSaveFailed:`Échec de l'enregistrement des paramètres de l'outil`,languageHindi:`Hindi`,backendUrlEmpty:`L'URL du back-end ne peut pas être vide`,backendUrlInvalidProtocol:`L'URL du back-end doit commencer par http:// ou https://`,backendUrlInvalidUrl:`L'URL du back-end n'est pas une URL valide`,backendUrlMustEndWithV1:`L'URL du back-end doit se terminer par "/v1"`,accessPassword:{validation:{currentPasswordRequired:`Veuillez entrer le mot de passe actuel`,newPasswordRequired:`Veuillez entrer un nouveau mot de passe`,confirmPasswordRequired:`Veuillez entrer le nouveau mot de passe à nouveau`,minLength:`Le mot de passe doit contenir au moins 4 caractères`,passwordMismatch:`Les mots de passe ne correspondent pas`}}},modelLimits:{placeholders:{vendor:`OpenAI / Google / Moonshot`},columns:{notes:`Notes`,actions:`Actions`}},systemPromptManager:{title:`Gestion des prompts système`,addButton:`Ajouter un prompt`,defaultPromptLocked:`Les prompts système par défaut sont verrouillés et ne peuvent pas être modifiés.`,updateSuccess:`Prompt mis à jour avec succès`,addSuccess:`Prompt ajouté avec succès`,saveError:`Échec de l'enregistrement du prompt. Veuillez réessayer.`,deleteSuccess:`Prompt supprimé avec succès`,deleteError:`Échec de la suppression du prompt. Veuillez réessayer.`,deleteConfirm:`Êtes-vous sûr de supprimer ce prompt ?`,defaultTag:`Par défaut (verrouillé)`,editTitle:`Modifier le prompt système`,addTitle:`Ajouter un nouveau prompt système`,nameLabel:`Nom du prompt`,nameRequired:`Veuillez saisir le nom du prompt !`,descriptionLabel:`Description du prompt`,descriptionRequired:`Veuillez saisir la description du prompt !`,contentLabel:`Contenu du prompt`,contentRequired:`Veuillez saisir le contenu du prompt !`},envVars:{title:`Variables d'environnement`,description:`Les variables sont injectées dans les processus de l'outil Bash. Les variables secrètes sont chiffrées au repos.`,fetchError:`Échec du chargement des variables d'environnement`,created:`Variable créée`,updated:`Variable mise à jour`,saveError:`Échec de l'enregistrement de la variable`,deleted:`Variable supprimée`,deleteError:`Échec de la suppression de la variable`,addButton:`Ajouter une variable`,noVars:`Aucune variable d'environnement configurée`,addTitle:`Ajouter une variable d'environnement`,editTitle:`Modifier une variable`,nameRequired:`Le nom de la variable est obligatoire`,nameInvalid:`Doit commencer par une lettre ou un trait de soulignement, suivi de lettres, de chiffres ou de traits de soulignement`,valueRequired:`La valeur est requise pour les nouvelles variables`,valueEditHint:`Laisser vide pour conserver la valeur existante`,valuePlaceholder:`Entrez la valeur`,valuePlaceholderEdit:`Entrez une nouvelle valeur ou laissez vide`,secretHint:`Les variables secrètes sont chiffrées sur le disque et masquées dans l'interface utilisateur`,descriptionPlaceholder:`Description facultative`,deleteConfirm:`Supprimer cette variable\xA0?`,notSet:`(non réglé)`,empty:`(vide)`,save:`Enregistrer`,cancel:`Annuler`,name:`Nom`,value:`Valeur`,secret:`Secrète`,descriptionField:`Description`,type:`Type`,plain:`Texte brut`,descriptionCol:`Description`,actions:`Actions`,yes:`Oui`,no:`Non`},hooksTab:{mode:{ocr:`OCR (Windows)`,vision:`Vision (LLM)`,placeholder:`Placeholder`},modeLabel:`Mode`},providerTab:{fastModel:`Modèle rapide (facultatif)`,fastModelHelp:`Modèle moins cher/plus rapide pour les tâches légères telles que la génération de titres, la correction Mermaid et la synthèse. Utilise le modèle par défaut lorsqu'il n'est pas défini.`,visionModel:`Modèle de vision (facultatif)`,visionModelHelp:`Modèle capable de vision pour la compréhension des images. Lorsque hooks.image_fallback.mode est défini sur «\xA0vision\xA0», ce modèle décrit les images sous forme de texte afin que les modèles contenant uniquement du texte puissent les comprendre. Utilise le modèle par défaut lorsqu'il n'est pas défini.`,sameAsDefault:`Identique au modèle par défaut`,providerNames:{openai:`OpenAI`,anthropic:`Anthropic`,gemini:`Gemini`,copilot:`Copilot`}},mcpTab:{statusHelp:{connecting:`Le serveur démarre ou se reconnecte`,ready:`Le serveur est connecté et sert les outils normalement`,degraded:`Le serveur est partiellement disponible\xA0; certains outils peuvent échouer`,stopped:`Le serveur ne fonctionne pas`,error:`Le serveur n'a pas pu démarrer ou a rencontré des erreurs d'exécution`}},metricsDashboard:{sessionsCount:`{{count}} sessions`,tokensAmount:`{{value}} jetons`,sessionsTabLabel:`Sessions ({{count}})`,roundColumns:{tokens:`Jetons`},multiplierSuffix:`x`,sessionDetail:{messages:`Messages`}},page:{tabs:{prompts:`Prompts`,mermaid:`Mermaid`,mcp:`MCP`,sessions:`Sessions`,hooks:`Hooks`}},appTab:{languageHindi:`Hindi`},modelMappingCard:{modelTypeOpus:`Opus`,modelTypeSonnet:`Sonnet`,modelTypeHaiku:`Haïku`},mermaidTab:{switchAuto:`Auto`,flowchartCurveOptions:{cardinal:`Cardinal`}},schedulesTab:{columns:{actions:`Actions`},actions:{sessions:`Sessions`},triggerTypes:{interval:`Intervalle`,daily:`Quotidien`,weekly:`Hebdomadaire`,monthly:`Mensuel`,cron:`Cron`},weekdays:{mon:`Lun`,tue:`Mar`,wed:`Mer`,thu:`Jeu`,fri:`Ven`,sat:`Sam`,sun:`Dim`},statusLabels:{running:`En cours`,queued:`En file d'attente`,failing:`En échec`,disabled:`Désactivé`,healthy:`Sain`,idle:`Inactif`},statusDetails:{active:`{{count}} actif(s)`,pending:`{{count}} en attente`,consecutiveFailures:`{{count}} échecs consécutifs`,lastRunSucceeded:`Dernière exécution réussie`},activityLabels:{queued:`En file : {{count}}`,running:`En cours : {{count}}`,ok:`OK : {{count}}`,fail:`Échec : {{count}}`}},sessionsTab:{id:`Identifiant`},mcpServerTable:{columns:{actions:`Actions`},transportOptions:{sse:`SSE`,stdio:`Stdio`}},mcpServerForm:{modeJson:`JSON`,transportOptions:{stdio:`Stdio`,sse:`SSE`},arguments:`Arguments`},metricsTable:{session:{columns:{session:`Session`,tokens:`Jetons`,messages:`Messages`,action:`Action`}},forward:{columns:{id:`Identifiant`,type:`Type`,tokens:`Jetons`}}},charts:{total:`Total`,prompt:`Prompt`,chat:`Chat`}},components:{markdown:{codeCopiedSuccess:`Code copié dans le presse-papier`,copyFailed:`Échec de la copie`},jsonSchema:{noProperties:`Aucune propriété dans le schéma`,field:`Champ`,type:`Type`,required:`Requis`,yes:`Oui`,no:`Non`,default:`Défaut`,description:`Description`},imageGrid:{ocr:`OCR`},tokenUsage:{messages:`Messages`,tokens:`jetons`},approval:{workflow:`Flux de travail`}}},ka={app:{errorBoundary:{title:`कुछ गलत हो गया`,description:`इस अनुभाग में एक अप्रत्याशित त्रुटि हुई। आप पुनः प्रयास कर सकते हैं या समस्या बनी रहने पर पृष्ठ पुनः लोड कर सकते हैं।`,tryAgain:`पुनः प्रयास करें`,showDetails:`विवरण दिखाएँ`,hideDetails:`विवरण छिपाएँ`},passwordGate:{title:`एक्सेस पासवर्ड दर्ज करें`,description:`एप्लिकेशन में प्रवेश करने से पहले पासवर्ड सत्यापन आवश्यक है।`,passwordLabel:`एक्सेस पासवर्ड`,passwordPlaceholder:`एक्सेस पासवर्ड दर्ज करें`,submit:`सत्यापित करें और जारी रखें`,validation:{required:`कृपया एक्सेस पासवर्ड दर्ज करें`,verifyFailed:`पासवर्ड सत्यापन विफल`}},notifications:{toolApproval:{title:`अनुमोदन आवश्यक: {{tool}}`,body:`टूल {{tool}} को निष्पादित करने के लिए आपकी मंजूरी चाहिए`,unknownTool:`अज्ञात टूल`},contextPressure:{title:`कॉन्टेक्स्ट विंडो लगभग भर गई है`},backgroundTask:{completedTitle:`बैकग्राउंड टास्क पूरा हुआ`,completedBody:`「{{title}}」 पूरा हुआ`,completedFallback:`बैकग्राउंड टास्क पूरा हुआ`},clarification:{title:`Bodhi AI आपका जवाब दे रहा है`,fallbackBody:`एजेंट एक सवाल का जवाब दे रहा है`},conversationSummarized:`वार्तालाप सारांशित: {{messages}} संदेश संपीड़ित, {{tokens}} टोकन बचाए गए`,allTasksCompleted:`सभी कार्य पूरे हुए! कुल राउंड: {{rounds}}, टूल कॉल: {{toolCalls}}`,evaluatingTasks:`{{count}} कार्यों का मूल्यांकन हो रहा है...`,evaluationCompleteUpdated:`मूल्यांकन पूर्ण: {{count}} कार्य अद्यतन किए गए।`,evaluationCompleteNoUpdates:`मूल्यांकन पूर्ण: कोई अद्यतन आवश्यक नहीं`}},common:{saveAnyway:`फिर भी सहेजें`,parentDirectory:`मूल निर्देशिका`,currentPath:`वर्तमान पथ:`,cancel:`रद्द करें`,ok:`ठीक है`,apply:`लागू करें`,save:`सहेजें`,delete:`हटाएँ`,yes:`हाँ`,no:`नहीं`,home:`होम`,download:`डाउनलोड करें`,directory:`निर्देशिका`,file:`फ़ाइल`},chat:{workspace:{placeholder:`जैसे /उपयोगकर्ता/ऐलिस/वर्कस्पेस/मायप्रोजेक्ट`,descriptionP1:`एक वर्कस्पेस पथ सेट करें ताकि फ़ाइल संदर्भ और वर्कस्पेस उपकरण फ़ाइलों को विश्वसनीय रूप से हल कर सकें।`,descriptionP2:`कोई मौजूदा प्रोजेक्ट फ़ोल्डर चुनें. आप अभी भी अमान्य पथ के साथ जारी रख सकते हैं, लेकिन हो सकता है कि संबंधित सुविधाएं ठीक से काम न करें।`},folderBrowser:{title:`वर्कस्पेस फ़ोल्डर चुनें`,selectCurrent:`वर्तमान फ़ोल्डर का चयन करें`,emptyFolder:`यह फ़ोल्डर खाली है`,tip:`युक्ति: दर्ज करने के लिए किसी फ़ोल्डर पर क्लिक करें, पुष्टि करने के लिए "वर्तमान फ़ोल्डर का चयन करें" पर क्लिक करें`},actions:{regenerate:`प्रतिक्रिया पुनः उत्पन्न करें`,retryFailed:`विफल अनुरोध पुनः प्रयास करें`,retryOptions:`पुनः प्रयास विकल्प`,cancelRequest:`अनुरोध को रद्द करें`,sendMessage:`संदेश भेजें`,copyMessage:`संदेश कॉपी करें`,referenceMessage:`संदर्भ संदेश`,generateTitle:`AI शीर्षक उत्पन्न करें`,unpin:`अनपिन`,pin:`नत्थी करें`},fileReference:{title:`@फ़ाइल संदर्भ`,setWorkspace:`वर्कस्पेस सेट करें`,noMatches:`कोई मेल खाती फ़ाइलें नहीं मिलीं`,emptyDirectory:`निर्देशिका खाली है`},commandSelector:{types:{mcp:`MCP`}}},settings:{notifications:{deleteAllSuccess:`सभी सत्र हटा दिए गए (पिन किए गए को छोड़कर)`,deleteEmptySuccess:`खाली सत्र हटा दिए गए (पिन किए गए को छोड़कर)`,localStorageCleared:`स्थानीय भंडारण साफ़ कर दिया गया है`,resetSuccessReloading:`एप्लिकेशन रीसेट सफल. पुनः लोड हो रहा है...`,resetFailed:`एप्लिकेशन रीसेट करने में विफल`,autoTitleEnabled:`स्वतः शीर्षक निर्माण सक्षम`,autoTitleDisabled:`स्वतः शीर्षक निर्माण अक्षम`,autoTitleUpdateFailed:`स्वतः शीर्षक प्राथमिकता अद्यतन करने में विफल`,promptEnhancementSaved:`सिस्टम प्रॉम्प्ट एन्हांसमेंट सहेजा गया`},appTab:{deleteAllTitle:`सभी सत्र हटाएँ`,deleteAllDescription:`क्या आपको यकीन है? इससे पिन किए गए को छोड़कर सभी सत्र हटा दिए जाएंगे.`,deleteAllButton:`सभी सत्र हटाएँ`,deleteEmptyTitle:`खाली सत्र हटाएँ`,deleteEmptyDescription:`क्या आपको यकीन है? इससे बिना किसी संदेश वाले (पिन किए गए को छोड़कर) सभी सत्र हटा दिए जाएंगे।`,deleteEmptyButton:`खाली सत्र हटाएँ`,clearLocalStorageTitle:`स्थानीय संग्रहण साफ़ करें`,clearLocalStorageDescription:`क्या आपको यकीन है? यह सभी स्थानीय संग्रहण डेटा को हटा देगा और एप्लिकेशन को रीसेट कर देगा।`,clearLocalStorageButton:`स्थानीय संग्रहण साफ़ करें`,confirmDeleteAll:`हाँ, सभी हटा दें`,confirmDeleteEmpty:`हां, खाली हटाएं`,confirmClear:`हाँ, इसे साफ़ करें`,dangerDescription:`इन कार्रवाइयों को पूर्ववत नहीं किया जा सकता. सारा डेटा स्थायी रूप से हटा दिया जाएगा.`,resetApplicationTitle:`एप्लिकेशन रीसेट करें`,resetApplicationIntro:`क्या आपको यकीन है? यह करेगा:`,resetStepDeleteAllSessions:`सभी सत्र हटाएं (पिन किए गए सहित)`,resetStepClearStorage:`सभी स्थानीय संग्रहण डेटा साफ़ करें`,resetStepResetConfig:`config.json को डिफ़ॉल्ट पर रीसेट करें`,resetStepSetupFlow:`अगले लॉन्च पर प्रारंभिक सेटअप प्रवाह ट्रिगर करें`,resetStepReload:`एप्लिकेशन पुनः लोड करें`,resetConfirm:`हाँ, सब कुछ रीसेट करें`,resetButton:`एप्लिकेशन रीसेट करें (सभी डेटा)`},configTab:{loadConfigFailed:`कॉन्फ़िगरेशन लोड करने में विफल`,invalidConfig:`अमान्य कॉन्फ़िगरेशन`,saveConfigSuccess:`कॉन्फ़िगरेशन सफलतापूर्वक सहेजा गया`,saveConfigFailed:`कॉन्फ़िगरेशन सहेजने में विफल`,toolsLoadFailed:`उपलब्ध उपकरण लोड करने में विफल`,toolsReloadSuccess:`टूल सूची पुनः लोड की गई`,toolsSaveSuccess:`टूल सेटिंग सफलतापूर्वक सहेजी गईं`,toolsSaveFailed:`टूल सेटिंग सहेजने में विफल`,backendSaved:`बैकएंड URL सहेजा गया`,backendResetDefault:`बैकएंड URL डिफ़ॉल्ट पर रीसेट हो गया`,backendUrlEmpty:`बैकएंड URL खाली नहीं हो सकता`,backendUrlInvalidProtocol:`बैकएंड URL http:// या https:// से शुरू होना चाहिए`,backendUrlInvalidUrl:`बैकएंड URL एक मान्य URL नहीं है`,backendUrlMustEndWithV1:`बैकएंड URL को "/v1" पर समाप्त होना चाहिए`,accessPassword:{validation:{currentPasswordRequired:`कृपया वर्तमान पासवर्ड दर्ज करें`,newPasswordRequired:`कृपया नया पासवर्ड दर्ज करें`,confirmPasswordRequired:`कृपया नया पासवर्ड दोबारा दर्ज करें`,minLength:`पासवर्ड कम से कम 4 अक्षरों का होना चाहिए`,passwordMismatch:`पासवर्ड मेल नहीं खाते`}}},modelMappingCard:{loadProviderFailed:`प्रदाता कॉन्फ़िगरेशन लोड करने में विफल`,loadMappingsFailed:`मौजूदा मैपिंग लोड करने में विफल`,loadModelsFailed:`मॉडल लोड करने में विफल`,loadModelsHint:`मॉडल लोड करने में विफल. कृपया अपने प्रदाता कॉन्फ़िगरेशन की जाँच करें।`,mappingSaved:`मॉडल मैपिंग सहेजी गई`,mappingSaveFailed:`मॉडल मैपिंग सहेजने में विफल`,enterModelName:`कृपया एक मॉडल नाम दर्ज करें`,customMappingSaved:`कस्टम मॉडल मैपिंग सहेजी गई`,customMappingSaveFailed:`कस्टम मॉडल मैपिंग सहेजने में विफल`,mappedModelNotFound:`मैप किया गया मॉडल "{{model}}" वर्तमान प्रदाता के उपलब्ध मॉडल में नहीं मिला`,cached:`(कैश्ड)`,modelTypeOpus:`Opus`,modelTypeSonnet:`Sonnet`,modelTypeHaiku:`Haiku`},modelTab:{selectModelTitle:`मॉडल का चयन करें`,loadingModels:`मॉडल लोड हो रहे हैं...`,selectModelPlaceholder:`एक मॉडल चुनें`,backendApiBaseUrlTitle:`बैकएंड API बेस URL`,resetToDefault:`डिफ़ॉल्ट पर रीसेट करें`,backendApiHint:`/v1 (उदा. {{example}}) सहित पूर्ण आधार URL होना चाहिए।`,save:`सहेजें`},mermaidTab:{title:`Mermaid आरेख सेटिंग्स`,description:`अनुकूलित करें कि आपकी चैट में Mermaid आरेख कैसे प्रस्तुत किए जाते हैं`,themeLabel:`Mermaid थीम`,themeTooltip:`एक अंतर्निर्मित Mermaid थीम चुनें। ऐप थीम के आधार पर प्रकाश और अंधेरे के बीच डिफ़ॉल्ट और न्यूट्रल ऑटो-स्विच।`,themeOptions:{default:`डिफ़ॉल्ट (स्वतः लाइट/डार्क)`,neutral:`तटस्थ (स्वतः लाइट/डार्क)`,forest:`वन (हरा थीम)`,base:`आधार (न्यूनतम)`,dark:`अँधेरा`},themeDescriptionsTitle:`थीम डिस्क्रिप्शन:`,themeDescriptions:{default:`डिफ़ॉल्ट: क्लासिक Mermaid लुक, प्रकाश/अंधेरे में स्वतः अनुकूलित`,neutral:`तटस्थ: ग्रे टोन, प्रकाश/अंधेरे के लिए स्वतः अनुकूलित`,dark:`डार्क: हमेशा डार्क थीम`,forest:`वन: हरा रंग योजना, तकनीकी आरेखों के लिए उपयुक्त`,base:`आधार: अनुकूलित थीम के लिए न्यूनतम शैली`},globalCardTitle:`वैश्विक सेटिंग्स`,fontSizeLabel:`फ़ॉन्ट आकार`,fontSizeTooltip:`सभी आरेख पाठ के लिए आधार फ़ॉन्ट आकार (पिक्सेल में)`,defaultZoomLabel:`डिफ़ॉल्ट ज़ूम`,defaultZoomTooltip:`आरेखों के लिए प्रारंभिक ज़ूम स्तर (1.0 = 100%)`,responsiveWidthLabel:`प्रतिक्रियाशील चौड़ाई`,responsiveWidthTooltip:`आरेखों को कंटेनर की चौड़ाई के अनुकूल बनाने में सक्षम करें। निश्चित-चौड़ाई वाले आरेखों के लिए अक्षम करें.`,flowchartCardTitle:`Flowchart सेटिंग्स`,flowchartNodeSpacingLabel:`नोड रिक्ति`,flowchartNodeSpacingTooltip:`नोड्स के बीच क्षैतिज दूरी`,flowchartRankSpacingLabel:`रैंक रिक्ति`,flowchartRankSpacingTooltip:`परतों के बीच लंबवत दूरी`,flowchartCurveTypeLabel:`वक्र प्रकार`,flowchartCurveTypeTooltip:`कनेक्शन के लिए वक्र का प्रकार`,flowchartCurveOptions:{basis:`Basis (स्मूथ)`,linear:`रेखीय`,cardinal:`Cardinal`},sequenceCardTitle:`Sequence Diagram सेटिंग्स`,sequenceActorMarginLabel:`एक्टर मार्जिन`,sequenceActorMarginTooltip:`एक्टरों के बीच अंतर`,sequenceMessageMarginLabel:`संदेश मार्जिन`,sequenceMessageMarginTooltip:`संदेश के बीच अंतर`,sequenceActorWidthLabel:`एक्टर चौड़ाई`,sequenceActorWidthTooltip:`प्रत्येक एक्टर बॉक्स की चौड़ाई`,sequenceActorHeightLabel:`एक्टर की ऊंचाई`,sequenceActorHeightTooltip:`प्रत्येक एक्टर बॉक्स की ऊंचाई`,ganttCardTitle:`Gantt चार्ट सेटिंग्स`,ganttBarHeightLabel:`बार की ऊंचाई`,ganttBarHeightTooltip:`प्रत्येक कार्य पट्टी की ऊंचाई`,ganttTopPaddingLabel:`शीर्ष गद्दी`,ganttTopPaddingTooltip:`चार्ट के शीर्ष पर स्थान`,resetToDefaults:`डिफ़ॉल्ट पर पुनः सेट करें`,previewDescription:`परिवर्तन तुरंत लागू होते हैं. अपनी सेटिंग्स को क्रियान्वित होते देखने के लिए एक आरेख बनाने या देखने का प्रयास करें।`,themeCardTitle:`विषय`,switchAuto:`ऑटो`,switchFixed:`तय`,previewTitle:`पूर्व दर्शन`},modelLimits:{title:`टोकन बजट मॉडल सीमाएँ`,descriptionPrefix:`संदर्भ बजटिंग के लिए प्रति-मॉडल टोकन सीमाएं कॉन्फ़िगर करें। ये सेटिंग्स Bamboo में विश्व स्तर पर कायम हैं`,descriptionSuffix:`और बैकएंड रिज़ॉल्वर द्वारा उपयोग किया जाता है।`,defaultsTitle:`मॉडल डिफ़ॉल्ट`,defaultsDescription:`GPT-5 / GPT-4 / Gemini / Kimi / GLM डिफ़ॉल्ट के साथ प्रीलोडेड। आप आवश्यकतानुसार संपादन जारी रख सकते हैं।`,migratedFromLocalStorage:`स्थानीय भंडारण से वैश्विक कॉन्फिगरेशन में स्थानांतरित मॉडल सीमाएँ।`,loadFailed:`मॉडल सीमा सेटिंग लोड करने में विफल`,saveSuccess:`मॉडल सीमाएँ वैश्विक कॉन्फ़िगरेशन में सहेजी गईं`,saveFailed:`मॉडल सीमा सेटिंग सहेजने में विफल`,resetSuccess:`मॉडल सीमाएँ उत्पाद डिफ़ॉल्ट पर रीसेट हो गईं`,resetFailed:`मॉडल सीमा सेटिंग रीसेट करने में विफल`,defaults:{gpt54:`तर्क की गहराई के साथ शीर्ष स्तरीय क्षमता।`,gpt53Codex:`कोड रीफैक्टरिंग वर्कफ़्लोज़ के लिए अनुकूलित।`,gpt52Pro:`जटिल कार्यों के लिए मजबूत तार्किक स्थिरता।`,gpt5Mini:`तेज़ और लागत प्रभावी सामान्य प्रयोजन विकल्प।`,gpt41:`1M विंडो वाला क्लासिक बड़े-संदर्भ वाला मॉडल।`,gpt4o:`कम विलंबता, रोजमर्रा की चैट के लिए उपयुक्त।`,gemini25Pro:`मजबूत मल्टीमॉडल विश्लेषण क्षमताएं।`,kimiK25:`दीर्घ-रूप वाली चीनी सामग्री के लिए पसंदीदा।`,kimiCoding:`कोडिंग-केंद्रित परिदृश्यों के लिए ट्यून किया गया।`,glm5:`एक-शॉट बड़े-दस्तावेज़ निर्माण के लिए अच्छा है।`},columns:{contextWindow:`Context Window`,maxOutput:`अधिकतम आउटपुट`,model:`मॉडल`,notes:`टिप्पणियाँ`,actions:`कार्रवाई`},placeholders:{vendor:`OpenAI/Google/Moonshot`,model:`जैसे gpt-5.4-think`,optional:`वैकल्पिक`},actions:{addRow:`लाइन जोड़ें`,resetToDefaults:`डिफ़ॉल्ट पर पुनः सेट करें`,remove:`निकालें`,save:`सहेजें`,reload:`पुनः लोड करें`},validation:{atLeastOneRow:`कृपया कम से कम एक मॉडल सीमा पंक्ति रखें।`,modelPatternEmpty:`मॉडल पैटर्न खाली नहीं हो सकता.`,duplicateModelPattern:`डुप्लिकेट मॉडल पैटर्न: {{pattern}}`,contextWindowMin:`{{pattern}} के लिए संदर्भ विंडो कम से कम 1000 होनी चाहिए।`,maxOutputMin:`{{pattern}} के लिए अधिकतम आउटपुट कम से कम 1 होना चाहिए।`,maxOutputExceedsContext:`{{pattern}} के लिए अधिकतम आउटपुट संदर्भ विंडो से कम या उसके बराबर होना चाहिए।`,safetyMarginNegative:`{{pattern}} के लिए सुरक्षा मार्जिन नकारात्मक नहीं हो सकता।`,safetyMarginTooLarge:`{{pattern}} के लिए सुरक्षा मार्जिन संदर्भ विंडो से छोटा होना चाहिए।`}},systemPromptManager:{title:`सिस्टम प्रॉम्प्ट प्रबंधन`,addButton:`प्रॉम्प्ट जोड़ें`,defaultPromptLocked:`डिफ़ॉल्ट सिस्टम प्रॉम्प्ट लॉक हैं और संपादित नहीं किए जा सकते।`,updateSuccess:`प्रॉम्प्ट सफलतापूर्वक अद्यतन किया गया`,addSuccess:`प्रॉम्प्ट सफलतापूर्वक जोड़ा गया`,saveError:`प्रॉम्प्ट सहेजने में विफल. कृपया पुन: प्रयास करें।`,deleteSuccess:`प्रॉम्प्ट सफलतापूर्वक हटा दिया गया`,deleteError:`प्रॉम्प्ट हटाने में विफल. कृपया पुन: प्रयास करें।`,deleteConfirm:`क्या आप निश्चित रूप से इस प्रॉम्प्ट को हटाना चाहते हैं?`,defaultTag:`डिफ़ॉल्ट (लॉक)`,editTitle:`सिस्टम प्रॉम्प्ट संपादित करें`,addTitle:`नया सिस्टम प्रॉम्प्ट जोड़ें`,nameLabel:`प्रॉम्प्ट नाम`,nameRequired:`कृपया प्रॉम्प्ट का नाम इनपुट करें!`,descriptionLabel:`प्रॉम्प्ट डिस्क्रिप्शन`,descriptionRequired:`कृपया प्रॉम्प्ट का डिस्क्रिप्शन दर्ज करें!`,contentLabel:`प्रॉम्प्ट सामग्री`,contentRequired:`कृपया प्रॉम्प्ट की सामग्री इनपुट करें!`},envVars:{title:`एनवायरमेंट वेरिएबल्स`,description:`वैरिएबल को Bash टूल प्रक्रियाओं में इंजेक्ट किया जाता है। गुप्त चर आराम से एन्क्रिप्ट किए गए हैं।`,fetchError:`एनवायरमेंट वेरिएबल्स लोड करने में विफल`,created:`वेरिएबल बनाया गया`,updated:`वेरिएबल अद्यतन किया गया`,saveError:`वेरिएबल सहेजने में विफल`,deleted:`वेरिएबल हटा दिया गया`,deleteError:`वेरिएबल हटाने में विफल`,addButton:`वेरिएबल जोड़ें`,noVars:`कोई एनवायरमेंट वेरिएबल कॉन्फ़िगर नहीं किया गया`,addTitle:`एनवायरमेंट वेरिएबल जोड़ें`,editTitle:`वेरिएबल संपादित करें`,nameRequired:`वेरिएबल नाम आवश्यक है`,nameInvalid:`एक अक्षर या अंडरस्कोर से शुरू होना चाहिए, उसके बाद अक्षर, अंक या अंडरस्कोर होना चाहिए`,valueRequired:`नए वेरिएबल के लिए मान आवश्यक है`,valueEditHint:`मौजूदा मान बनाए रखने के लिए खाली छोड़ें`,valuePlaceholder:`मान दर्ज करें`,valuePlaceholderEdit:`नया मान दर्ज करें या खाली छोड़ दें`,secretHint:`गुप्त चर डिस्क पर एन्क्रिप्ट किए गए हैं और यूआई में छिपाए गए हैं`,descriptionPlaceholder:`वैकल्पिक डिस्क्रिप्शन`,deleteConfirm:`यह वेरिएबल हटाएं?`,notSet:`(सेट नहीं)`,empty:`(खाली)`,save:`सहेजें`,cancel:`रद्द करें`,name:`नाम`,value:`वैल्यू`,secret:`गुप्त`,descriptionField:`डिस्क्रिप्शन`,type:`प्रकार`,plain:`सादा`,descriptionCol:`डिस्क्रिप्शन`,actions:`कार्रवाई`,yes:`हाँ`,no:`नहीं`},promptsTab:{title:`सिस्टम प्रॉम्प्ट एन्हांसमेंट`,mermaidEnhancement:`Mermaid एन्हांसमेंट`,taskListRules:`साझा कार्य नियम`,copilotConclusionWithOptionsBeforeFinish:`समाप्त होने से पहले Copilot ने उपयोगकर्ता से पूछा`,enhancementPlaceholder:`प्रत्येक सिस्टम प्रॉम्प्ट में जोड़ने के लिए वैश्विक एन्हांसमेंट टेक्स्ट जोड़ें।`,saveEnhancement:`एन्हांसमेंट सहेजें`,description:`प्रत्येक अनुरोध भेजे जाने से पहले इस पाठ को पहले जोड़ा जाता है, उसके बाद सक्षम सिस्टम एन्हांसमेंट जोड़ा जाता है।`,switchOn:`पर`,switchOff:`बंद`},hooksTab:{title:`छवि हुक`,enableImagePreflight:`छवि प्रीफ़्लाइट हुक सक्षम करें`,description:`प्लेसहोल्डर मोड छवियों को पाठ सारांश में फिर से लिखता है (यह उन टूल को तोड़ सकता है जो वास्तविक छवि डेटा की अपेक्षा करते हैं)। OCR वर्तमान में केवल विंडोज़ है।`,loadFailed:`हुक सेटिंग्स लोड करने में विफल`,updateFailed:`हुक अद्यतन करने में विफल`,modeUpdateFailed:`हुक मोड अपडेट करने में विफल`,enabled:`छवि हुक सक्षम`,disabled:`छवि हुक अक्षम किए गए`,modeUpdated:`इमेज हुक मोड इस पर सेट है: {{mode}}`,mode:{ocr:`OCR (Windows)`,vision:`Vision (LLM)`,placeholder:`प्लेसहोल्डर`,error:`त्रुटि`},modeLabel:`मोड`},schedulesTab:{triggerTypes:{interval:`अंतराल`,daily:`दैनिक`,weekly:`साप्ताहिक`,monthly:`मासिक`,cron:`Cron`},loadFailed:`शेड्यूल लोड करने में विफल`,loadSessionsFailed:`शेड्यूल सत्र लोड करने में विफल`,createFailed:`शेड्यूल बनाने में विफल`,updateFailed:`शेड्यूल अपडेट करने में विफल`,deleteFailed:`शेड्यूल हटाने में विफल`,runNowFailed:`शेड्यूल चलाने में विफल`,taskMessageRequired:`ऑटो एक्ज़ीक्यूट सक्षम होने पर कार्य संदेश आवश्यक है`,created:`शेड्यूल बनाया गया`,updated:`शेड्यूल अपडेट किया गया`,deleted:`हटाया गया शेड्यूल`,enqueuedRun:`कतार में जोड़ा गया`,optional:`(वैकल्पिक)`,defaultName:`मेरी अनुसूची`,createTitle:`शेड्यूल बनाएं`,scheduleSessionsTitle:`सत्र अनुसूची`,noSessionsYet:`अभी तक कोई सत्र नहीं.`,editTitle:`शेड्यूल संपादित करें`,columns:{autoExecute:`स्वतः निष्पादित`,intervalSeconds:`अंतराल`,nextRun:`अगला रन`,lastRun:`आखरी बार`,name:`नाम`,model:`मॉडल`,enabled:`सक्रिय`,actions:`कार्रवाई`},form:{intervalSeconds:`अंतराल सेकंड`,taskMessage:`कार्य संदेश`,taskMessagePlaceholder:`(वैकल्पिक) चलाने के लिए एक कार्य`,modelPlaceholder:`(वैकल्पिक) उदा. gpt-4o-mini`,modelRequiredIfAuto:`यदि स्वतः निष्पादित हो तो आवश्यक है`,autoExecute:`स्वतः निष्पादित`,systemPrompt:`सिस्टम प्रॉम्प्ट`,workspacePath:`वर्कस्पेस पथ`,enhancePrompt:`प्रॉम्प्ट बढ़ाएँ`,name:`नाम`,enabled:`सक्रिय`,model:`मॉडल`},validation:{nameRequired:`नाम आवश्यक है`,intervalRequired:`अंतराल आवश्यक है`},actions:{runNow:`अब चलाएँ`,create:`बनाएं`,refresh:`ताज़ा करें`,edit:`संपादन करें`,sessions:`सत्र`,delete:`हटाएँ`,open:`खोलें`,save:`सहेजें`},yes:`हाँ`,no:`नहीं`,listTitle:`अनुसूचियों`,weekdays:{mon:`सोम`,tue:`मंगल`,wed:`बुध`,thu:`गुरु`,fri:`शुक्र`,sat:`शनि`,sun:`रवि`},statusLabels:{running:`चल रहा है`,queued:`कतार में`,failing:`विफल हो रहा है`,disabled:`अक्षम`,healthy:`स्वस्थ`,idle:`निष्क्रिय`},statusDetails:{active:`{{count}} सक्रिय`,pending:`{{count}} लंबित`,consecutiveFailures:`{{count}} लगातार विफलताएँ`,lastRunSucceeded:`अंतिम रन सफल रहा`},activityLabels:{queued:`कतार: {{count}}`,running:`चल रहे: {{count}}`,ok:`सफल: {{count}}`,fail:`विफल: {{count}}`}},sessionsTab:{currentSessionTitle:`वर्तमान सत्र`,clearMessages:`संदेश साफ़ करें`,clearMessagesTitle:`सत्र संदेश साफ़ करें`,clearMessagesContent:`यह वर्तमान सत्र के लिए संदेश/अनुलग्नक साफ़ करता है लेकिन सत्र प्रविष्टि रखता है।`,sessionCleared:`सत्र साफ़ हो गया`,noActiveSession:`कोई सक्रिय सत्र नहीं.`,bulkCleanupTitle:`थोक सफ़ाई`,keepPinned:`पिन किए रखें`,deleteAll:`सभी हटा दो`,deleteAllTitle:`सभी सत्र हटाएँ`,deleteAllKeepPinned:`पिन किए गए को छोड़कर सभी सत्र हटा देता है।`,deleteAllIncludePinned:`पिन किए गए सहित सभी सत्र हटा देता है।`,deleteEmpty:`रिक्त हटाएँ`,deleteEmptyTitle:`खाली सत्र हटाएँ`,deleteEmptyKeepPinned:`पिन किए गए को छोड़कर खाली सत्र हटा देता है।`,deleteEmptyIncludePinned:`पिन किए गए सहित खाली सत्र हटा देता है।`,deleteChildren:`बच्चों को हटाएँ`,deleteChildrenTitle:`बाल सत्र हटाएँ`,deleteChildrenKeepPinned:`पिन किए गए को छोड़कर सभी चाइल्ड सत्र हटा देता है।`,deleteChildrenIncludePinned:`पिन किए गए सहित सभी चाइल्ड सत्र हटा देता है।`,cleanupComplete:`सफ़ाई पूर्ण`,devResetTitle:`विकास रीसेट`,devResetDescription:`सत्र संग्रहण के लिए ग्रीनफ़ील्ड रीसेट (सत्र हटाता है/ और session.json रीसेट करता है)।`,devResetAction:`देव रीसेट सत्र`,devResetConfirmTitle:`सत्र संग्रहण रीसेट करें (डेव)`,devResetConfirmContent:`यह सभी सत्रों (पिन किए गए/चाइल्ड सहित) को हटा देता है और सत्र सूचकांक को रीसेट कर देता है। रीफ्रेश के बाद एक नया खाली सत्र बनाया जाएगा।`,devResetDone:`सत्र संग्रहण रीसेट`,id:`ID`,kind:`प्रकार`,clear:`साफ़ करें`,cancel:`रद्द करें`,delete:`हटाएँ`,reset:`रीसेट करें`},workflowsTab:{description:"वर्कफ़्लो को `~/.bamboo/workflows` में मार्कडाउन फ़ाइलों के रूप में संग्रहीत किया जाता है। चैट में वर्कफ़्लो सम्मिलित करने के लिए `/name` का उपयोग करें।",loadFailed:`वर्कफ़्लो लोड करने में विफल`,loadContentFailed:`वर्कफ़्लो सामग्री लोड करने में विफल`,invalidName:`अमान्य वर्कफ़्लो नाम`,nameAlreadyExists:`इस नाम का एक वर्कफ़्लो पहले से मौजूद है`,saved:`वर्कफ़्लो सहेजा गया`,saveFailed:`वर्कफ़्लो सहेजने में विफल`,deleted:`वर्कफ़्लो हटा दिया गया`,deleteFailed:`वर्कफ़्लो हटाने में विफल`,newWorkflow:`नया वर्कफ़्लो`,empty:`कोई वर्कफ़्लो नहीं मिला`,namePlaceholder:`वर्कफ़्लो नाम`,contentPlaceholder:`# वर्कफ़्लो शीर्षक
|
|
6
|
+
`);let t=e.state[s];if(t==null)return;JSON.stringify(i.getState())!==JSON.stringify(t)&&p(t);return}ce(i)&&i.dispatch(e)});case`DISPATCH`:switch(e.payload.type){case`RESET`:return p(m),s===void 0?u?.init(i.getState()):u?.init(ue(c.name));case`COMMIT`:if(s===void 0){u?.init(i.getState());return}return u?.init(ue(c.name));case`ROLLBACK`:return he(e.state,e=>{if(s===void 0){p(e),u?.init(i.getState());return}p(e[s]),u?.init(ue(c.name))});case`JUMP_TO_STATE`:case`JUMP_TO_ACTION`:return he(e.state,e=>{if(s===void 0){p(e);return}JSON.stringify(i.getState())!==JSON.stringify(e[s])&&p(e[s])});case`IMPORT_STATE`:{let{nextLiftedState:t}=e.payload,n=t.computedStates.slice(-1)[0]?.state;if(!n)return;p(s===void 0?n:n[s]),u?.send(null,t);return}case`PAUSE_RECORDING`:return f=!f}return}}),m},he=(e,t)=>{let n;try{n=JSON.parse(e)}catch(e){console.error(`[zustand devtools middleware] Could not parse the received json`,e)}n!==void 0&&t(n)},ge=e=>(t,n,r)=>{let i=r.subscribe;return r.subscribe=((e,t,n)=>{let a=e;if(t){let i=n?.equalityFn||Object.is,o=e(r.getState());a=n=>{let r=e(n);if(!i(o,r)){let e=o;t(o=r,e)}},n?.fireImmediately&&t(o,o)}return i(a)}),e(t,n,r)},_e=()=>!1,ve=e=>{if(!_e())return!1;try{return localStorage.getItem(e)===`1`}catch{return!1}},P=(e,t,...n)=>{_e()&&ve(`bodhi_debug_verbose`)&&console.log(`${e} ${t}`,...n)},ye=`bodhi_api_v2_msgpack`,be=()=>{try{return localStorage.getItem(ye)===`1`}catch{return!1}},xe=e(r(),1),F=i(),Se=class extends Error{status;statusText;body;kind=`http`;constructor(e,t,n,r){super(e),this.status=t,this.statusText=n,this.body=r,this.name=`ApiError`}},Ce=class extends Error{kind=`network`;constructor(e){super(`A network error prevented the request. Check your connection and try again.`,{cause:e}),this.name=`NetworkRequestError`}},we=class extends Error{kind=`timeout`;constructor(e){super(`The request timed out. Please try again.`,{cause:e}),this.name=`RequestTimeoutError`}},Te=class extends Error{kind=`cancelled`;constructor(e){super(`The request was cancelled.`,{cause:e}),this.name=`RequestCancelledError`}};function Ee(e){return e instanceof Se}function De(e){return e instanceof we?`The request timed out. Please try again.`:e instanceof Te?`The request was cancelled.`:e instanceof Ce?`A network error prevented the request. Check your connection and try again.`:Ee(e)?e.status===401?`Authentication failed. Please check your credentials.`:e.status===403?`You don't have permission to perform this action.`:e.status===404?`The requested resource was not found.`:e.status>=500?e.message?.trim()?e.message:`Server error. Please try again later.`:e.message:e instanceof Error?e.message:`An unexpected error occurred`}var Oe=[/\/api\/v1\/respond\/[^/]+\/pending/,/\/api\/v1\/sessions\/?$/,/\/api\/v1\/events\/[^/]+/],ke=!1;function Ae(){return ke&&typeof localStorage<`u`&&localStorage.getItem(`lotus_debug_api_requests`)===`1`}function je(e){try{let t=new URL(e,typeof window<`u`?window.location.origin:`http://localhost`).pathname;return Oe.some(e=>e.test(t))}catch{return!1}}var Me={};function Ne(e,t){if(!Ae()||!je(t))return;let n=`${e} ${new URL(t,typeof window<`u`?window.location.origin:`http://localhost`).pathname}`;Me[n]=(Me[n]||0)+1,console.debug(`[ApiClient] ${e} ${n} (total: ${Me[n]})`)}var Pe=e=>{ke=e,!(!e||typeof window>`u`)&&(window.__lotusApiCounters=()=>(console.table(Me),{...Me}),window.__lotusResetApiCounters=()=>{Me={}})},I=class{baseUrl;defaultHeaders;requestCredentials;transport;constructor(e){this.baseUrl=e.baseUrl.trim().replace(/\/+$/,``),this.defaultHeaders=e.defaultHeaders??{"Content-Type":`application/json`},this.requestCredentials=e.requestCredentials,this.transport=e.transport}resolveUrl(e){let t=e.replace(/^\/+/,``);return`${this.baseUrl}/${t}`}mergeHeaders(e){let t=new Headers(this.defaultHeaders);return e&&new Headers(e).forEach((e,n)=>t.set(n,e)),t}createRequestInit(e,t,n){return{...t,method:e,headers:this.mergeHeaders(t?.headers),credentials:this.requestCredentials,...n?{body:n.value?JSON.stringify(n.value):void 0}:{}}}async handleResponse(e){if(!e.ok){let t=await e.text(),n=e.statusText;if(t)try{let r=JSON.parse(t),i=typeof r.error==`object`?r.error?.message:void 0,a=typeof r.error==`string`?r.error:void 0,o=typeof r.message==`string`?r.message:void 0,s=typeof r.detail==`string`?r.detail:void 0;n=a||(typeof i==`string`?i:void 0)||o||s||e.statusText}catch{n=t}throw new Se(n,e.status,e.statusText,t)}if(e.status!==204)return(e.headers?.get?.(`content-type`)||``).includes(`application/json`)?e.json():typeof e.text==`function`?await e.text():e.json()}async send(e,t,n,r){let i=this.resolveUrl(t);Ne(e.toUpperCase(),i);let a=await this.transport.request(i,this.createRequestInit(e,n,r));return this.handleResponse(a)}async get(e,t){return this.send(`GET`,e,t)}async post(e,t,n){return this.send(`POST`,e,n,{value:t})}async put(e,t,n){return this.send(`PUT`,e,n,{value:t})}async putOnce(e,t,n){let r=this.resolveUrl(e);Ne(`PUT`,r);let i=await this.transport.requestOnce(r,this.createRequestInit(`PUT`,n,{value:t}));return this.handleResponse(i)}async patch(e,t,n){return this.send(`PATCH`,e,n,{value:t})}async delete(e,t){return this.send(`DELETE`,e,t)}async request(e,t,n){return this.send(e,t,n)}async fetchRaw(e,t){let n=this.resolveUrl(e);Ne(t?.method?.toUpperCase()??`GET`,n);let r=await this.transport.requestOnce(n,{...t,headers:this.mergeHeaders(t?.headers),credentials:this.requestCredentials});if(!r.ok){let e=r.body?.cancel();throw e&&e.catch(()=>void 0),new Se(`API request failed: ${r.statusText}`,r.status,r.statusText)}return r}},Fe=new Set([`GET`,`HEAD`,`OPTIONS`,`PUT`,`DELETE`]),Ie=new Set([408,429,500,502,503,504]),Le=new Set([101,103,204,205,304]),L=3e4,Re=3,ze=2e3,Be=typeof ReadableStream>`u`?void 0:Object.getOwnPropertyDescriptor(ReadableStream.prototype,`locked`)?.get;function Ve(e){return 250*2**Math.max(0,e-1)}function He(e,t){if(!Number.isFinite(e)||e<=0)throw TypeError(`${t} must be a positive finite number.`)}function Ue(e,t){if(typeof DOMException<`u`)return new DOMException(t,e);let n=Error(t);return n.name=e,n}function We(e){return typeof e==`object`&&!!e&&`name`in e&&e.name===`TimeoutError`}function Ge(e,t){let n=new AbortController,r,i,a,o=(e,t)=>{r===void 0&&(r=e,i=t,n.abort(t))},s=()=>{let t=e?.reason;o(We(t)?`caller-timeout`:`caller-cancelled`,t)};return e?.aborted?s():(e?.addEventListener(`abort`,s,{once:!0}),a=setTimeout(()=>{o(`logical-timeout`,Ue(`TimeoutError`,`The logical request deadline elapsed.`))},t)),{signal:n.signal,get source(){return r},get cause(){return i},cleanup(){a!==void 0&&clearTimeout(a),e?.removeEventListener(`abort`,s)}}}function Ke(e,t){let n=e.cause??t;return e.source===`caller-timeout`||e.source===`logical-timeout`?new we(n):new Te(n)}function qe(e,t){return t.aborted?Promise.reject(t.reason):new Promise((n,r)=>{let i=()=>{t.removeEventListener(`abort`,i),r(t.reason)};t.addEventListener(`abort`,i,{once:!0}),e.then(e=>{t.removeEventListener(`abort`,i),n(e)},e=>{t.removeEventListener(`abort`,i),r(e)})})}function Je(e,t){return t.aborted?Promise.reject(t.reason):new Promise((n,r)=>{let i=setTimeout(()=>{t.removeEventListener(`abort`,a),n()},e),a=()=>{clearTimeout(i),t.removeEventListener(`abort`,a),r(t.reason)};t.addEventListener(`abort`,a,{once:!0})})}function R(e){if(typeof e!=`string`){if(typeof URL<`u`)try{URL.prototype.toString.call(e);return}catch{}throw TypeError(`HttpTransport input must be a string or URL; Request is unsupported.`)}}function Ye(e){if(e===null||typeof e!=`object`&&typeof e!=`function`)throw TypeError(`RequestInit must be an object.`);let t=e,n=Object.create(null),r,i,a,o=!1,s=!1,c=!1;for(let[t,l]of Object.entries(e)){if(t===`method`){r=l,o=!0;continue}if(t===`body`){i=l,s=!0;continue}if(t===`signal`){a=l,c=!0;continue}Object.defineProperty(n,t,{configurable:!0,enumerable:!0,value:l,writable:!0})}o||(r=t.method),s||(i=t.body),c||(a=t.signal);for(let[e,t]of[[`method`,r],[`body`,i]])Object.defineProperty(n,e,{configurable:!0,enumerable:!0,value:t,writable:!0});return{method:r,body:i,callerSignal:a,requestInit:n}}function Xe(e){if(e===void 0)return`GET`;if(typeof e==`string`)return e.replace(/[a-z]/g,e=>String.fromCharCode(e.charCodeAt(0)-32))}function Ze(e){if(typeof e!=`object`||!e)return!1;if(Be)try{return Be.call(e),!0}catch{}try{let t=new Set,n=e;for(;n!==null;){if(t.has(n)||(t.add(n),Object.getOwnPropertyDescriptor(n,`getReader`)!==void 0))return!0;n=Object.getPrototypeOf(n)}return!1}catch{return!0}}async function Qe(e,t){try{let n=e.body?.cancel();n&&await qe(n,t)}catch(e){if(t.aborted)throw e}}function $e(e,t){if(Le.has(e.status)||!e.body)return t.cleanup(),e;let n;try{n=e.body.getReader()}catch(n){let r=new Ce(n);throw e.body.cancel(n).catch(()=>void 0),t.cleanup(),r}let r=!1,i,a=()=>r?!1:(r=!0,t.signal.removeEventListener(`abort`,o),t.cleanup(),!0),o=()=>{let e=Ke(t,t.signal.reason);if(a()){n.cancel(t.signal.reason).catch(()=>void 0);try{i?.error(e)}catch{}}},s;try{s=new ReadableStream({start(e){i=e,t.signal.addEventListener(`abort`,o,{once:!0}),t.signal.aborted&&o()},async pull(e){try{let t=await n.read();if(r)return;if(t.done){a();try{e.close()}catch{}}else e.enqueue(t.value)}catch(n){if(!a())return;try{e.error(t.signal.aborted?Ke(t,n):new Ce(n))}catch{}}},async cancel(e){a(),await n.cancel(e)}})}catch(t){let r=new Ce(t);throw a(),n.releaseLock(),e.body.cancel(t).catch(()=>void 0),r}let c;try{c=new Response(s,{headers:e.headers,status:e.status,statusText:e.statusText})}catch(e){let t=new Ce(e);if(a()){n.cancel(e).catch(()=>void 0);try{i?.error(t)}catch{}}throw t}for(let[t,n]of[[`redirected`,e.redirected],[`type`,e.type],[`url`,e.url]])try{Object.defineProperty(c,t,{configurable:!0,enumerable:!0,value:n})}catch{}return c}var et=class{fetchImplementation;logicalTimeoutMs;totalAttempts;retryDelayMs;maxRetryDelayMs;constructor(e){let t=e.logicalTimeoutMs??L,n=e.totalAttempts??Re,r=e.maxRetryDelayMs??ze;if(He(t,`logicalTimeoutMs`),He(n,`totalAttempts`),He(r,`maxRetryDelayMs`),!Number.isInteger(n))throw TypeError(`totalAttempts must be an integer.`);this.fetchImplementation=e.fetchImplementation,this.logicalTimeoutMs=t,this.totalAttempts=n,this.retryDelayMs=e.retryDelayMs??Ve,this.maxRetryDelayMs=r}request(e,t={}){return this.execute(e,t,this.totalAttempts)}requestOnce(e,t={}){return this.execute(e,t,1)}async execute(e,t,n){R(e);let r;try{r=Ye(t)}catch(e){throw new Ce(e)}let i=Xe(r.method),a=i!==void 0&&Fe.has(i)&&!Ze(r.body)?n:1,o=Ge(r.callerSignal,this.logicalTimeoutMs),s=Object.freeze({...r.requestInit,signal:o.signal}),c=!1;try{if(o.signal.aborted)throw Ke(o);for(let t=1;t<=a;t+=1)try{if(o.signal.aborted)throw Ke(o);let n=await qe(Promise.resolve(this.fetchImplementation(e,s)),o.signal);if(!(t<a&&Ie.has(n.status))){let e=$e(n,o);return c=!0,e}await Qe(n,o.signal),await this.waitBeforeRetry(t,o.signal)}catch(e){if(o.signal.aborted)throw Ke(o,e);if(e instanceof Ce||e instanceof we||e instanceof Te)throw e;if(t>=a)throw new Ce(e);try{await this.waitBeforeRetry(t,o.signal)}catch(e){throw o.signal.aborted?Ke(o,e):e}}throw new Ce}finally{c||o.cleanup()}}waitBeforeRetry(e,t){let n=this.retryDelayMs(e);return Je(Number.isFinite(n)?Math.min(this.maxRetryDelayMs,Math.max(0,n)):this.maxRetryDelayMs,t)}};function tt(){return new et({fetchImplementation:(e,t)=>globalThis.fetch(e,t)})}var nt=a();Pe(nt.publicMetadata.development);var rt=tt(),z=new I({baseUrl:nt.endpoints.nativeApi,requestCredentials:nt.auth.requestCredentials,transport:rt});function it(e){let t=e.length,n=0,r=0;for(;r<t;){let i=e.charCodeAt(r++);if(!(i&4294967168)){n++;continue}else if(!(i&4294965248))n+=2;else{if(i>=55296&&i<=56319&&r<t){let t=e.charCodeAt(r);(t&64512)==56320&&(++r,i=((i&1023)<<10)+(t&1023)+65536)}i&4294901760?n+=4:n+=3}}return n}function at(e,t,n){let r=e.length,i=n,a=0;for(;a<r;){let n=e.charCodeAt(a++);if(!(n&4294967168)){t[i++]=n;continue}else if(!(n&4294965248))t[i++]=n>>6&31|192;else{if(n>=55296&&n<=56319&&a<r){let t=e.charCodeAt(a);(t&64512)==56320&&(++a,n=((n&1023)<<10)+(t&1023)+65536)}n&4294901760?(t[i++]=n>>18&7|240,t[i++]=n>>12&63|128,t[i++]=n>>6&63|128):(t[i++]=n>>12&15|224,t[i++]=n>>6&63|128)}t[i++]=n&63|128}}var ot=new TextEncoder,st=50;function ct(e,t,n){ot.encodeInto(e,t.subarray(n))}function lt(e,t,n){e.length>st?ct(e,t,n):at(e,t,n)}var B=4096;function ut(e,t,n){let r=t,i=r+n,a=[],o=``;for(;r<i;){let t=e[r++];if(!(t&128))a.push(t);else if((t&224)==192){let n=e[r++]&63;a.push((t&31)<<6|n)}else if((t&240)==224){let n=e[r++]&63,i=e[r++]&63;a.push((t&31)<<12|n<<6|i)}else if((t&248)==240){let n=e[r++]&63,i=e[r++]&63,o=e[r++]&63,s=(t&7)<<18|n<<12|i<<6|o;s>65535&&(s-=65536,a.push(s>>>10&1023|55296),s=56320|s&1023),a.push(s)}else a.push(t);a.length>=B&&(o+=String.fromCharCode(...a),a.length=0)}return a.length>0&&(o+=String.fromCharCode(...a)),o}var dt=new TextDecoder,ft=200;function pt(e,t,n){let r=e.subarray(t,t+n);return dt.decode(r)}function mt(e,t,n){return n>ft?pt(e,t,n):ut(e,t,n)}var ht=class{type;data;constructor(e,t){this.type=e,this.data=t}},gt=class e extends Error{constructor(t){super(t);let n=Object.create(e.prototype);Object.setPrototypeOf(this,n),Object.defineProperty(this,"name",{configurable:!0,enumerable:!1,value:e.name})}};function _t(e,t,n){let r=n/4294967296,i=n;e.setUint32(t,r),e.setUint32(t+4,i)}function vt(e,t,n){let r=Math.floor(n/4294967296),i=n;e.setUint32(t,r),e.setUint32(t+4,i)}function yt(e,t){let n=e.getInt32(t),r=e.getUint32(t+4);return n*4294967296+r}function V(e,t){let n=e.getUint32(t),r=e.getUint32(t+4);return n*4294967296+r}var bt=4294967295,xt=17179869183;function St({sec:e,nsec:t}){if(e>=0&&t>=0&&e<=xt)if(t===0&&e<=bt){let t=new Uint8Array(4);return new DataView(t.buffer).setUint32(0,e),t}else{let n=e/4294967296,r=e&4294967295,i=new Uint8Array(8),a=new DataView(i.buffer);return a.setUint32(0,t<<2|n&3),a.setUint32(4,r),i}else{let n=new Uint8Array(12),r=new DataView(n.buffer);return r.setUint32(0,t),vt(r,4,e),n}}function Ct(e){let t=e.getTime(),n=Math.floor(t/1e3),r=(t-n*1e3)*1e6,i=Math.floor(r/1e9);return{sec:n+i,nsec:r-i*1e9}}function wt(e){return e instanceof Date?St(Ct(e)):null}function Tt(e){let t=new DataView(e.buffer,e.byteOffset,e.byteLength);switch(e.byteLength){case 4:return{sec:t.getUint32(0),nsec:0};case 8:{let e=t.getUint32(0),n=t.getUint32(4);return{sec:(e&3)*4294967296+n,nsec:e>>>2}}case 12:return{sec:yt(t,4),nsec:t.getUint32(0)};default:throw new gt(`Unrecognized data size for timestamp (expected 4, 8, or 12): ${e.length}`)}}function Et(e){let t=Tt(e);return new Date(t.sec*1e3+t.nsec/1e6)}var H={type:-1,encode:wt,decode:Et},Dt=class e{static defaultCodec=new e;__brand;builtInEncoders=[];builtInDecoders=[];encoders=[];decoders=[];constructor(){this.register(H)}register({type:e,encode:t,decode:n}){if(e>=0)this.encoders[e]=t,this.decoders[e]=n;else{let r=-1-e;this.builtInEncoders[r]=t,this.builtInDecoders[r]=n}}tryToEncode(e,t){for(let n=0;n<this.builtInEncoders.length;n++){let r=this.builtInEncoders[n];if(r!=null){let i=r(e,t);if(i!=null)return new ht(-1-n,i)}}for(let n=0;n<this.encoders.length;n++){let r=this.encoders[n];if(r!=null){let i=r(e,t);if(i!=null)return new ht(n,i)}}return e instanceof ht?e:null}decode(e,t,n){let r=t<0?this.builtInDecoders[-1-t]:this.decoders[t];return r?r(e,t,n):new ht(t,e)}};function Ot(e){return e instanceof ArrayBuffer||typeof SharedArrayBuffer<`u`&&e instanceof SharedArrayBuffer}function kt(e){return e instanceof Uint8Array?e:ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):Ot(e)?new Uint8Array(e):Uint8Array.from(e)}var At=class e{extensionCodec;context;useBigInt64;maxDepth;initialBufferSize;sortKeys;forceFloat32;ignoreUndefined;forceIntegerToFloat;pos;view;bytes;entered=!1;constructor(e){this.extensionCodec=e?.extensionCodec??Dt.defaultCodec,this.context=e?.context,this.useBigInt64=e?.useBigInt64??!1,this.maxDepth=e?.maxDepth??100,this.initialBufferSize=e?.initialBufferSize??2048,this.sortKeys=e?.sortKeys??!1,this.forceFloat32=e?.forceFloat32??!1,this.ignoreUndefined=e?.ignoreUndefined??!1,this.forceIntegerToFloat=e?.forceIntegerToFloat??!1,this.pos=0,this.view=new DataView(new ArrayBuffer(this.initialBufferSize)),this.bytes=new Uint8Array(this.view.buffer)}clone(){return new e({extensionCodec:this.extensionCodec,context:this.context,useBigInt64:this.useBigInt64,maxDepth:this.maxDepth,initialBufferSize:this.initialBufferSize,sortKeys:this.sortKeys,forceFloat32:this.forceFloat32,ignoreUndefined:this.ignoreUndefined,forceIntegerToFloat:this.forceIntegerToFloat})}reinitializeState(){this.pos=0}encodeSharedRef(e){if(this.entered)return this.clone().encodeSharedRef(e);try{return this.entered=!0,this.reinitializeState(),this.doEncode(e,1),this.bytes.subarray(0,this.pos)}finally{this.entered=!1}}encode(e){if(this.entered)return this.clone().encode(e);try{return this.entered=!0,this.reinitializeState(),this.doEncode(e,1),this.bytes.slice(0,this.pos)}finally{this.entered=!1}}doEncode(e,t){if(t>this.maxDepth)throw Error(`Too deep objects in depth ${t}`);e==null?this.encodeNil():typeof e==`boolean`?this.encodeBoolean(e):typeof e==`number`?this.forceIntegerToFloat?this.encodeNumberAsFloat(e):this.encodeNumber(e):typeof e==`string`?this.encodeString(e):this.useBigInt64&&typeof e==`bigint`?this.encodeBigInt64(e):this.encodeObject(e,t)}ensureBufferSizeToWrite(e){let t=this.pos+e;this.view.byteLength<t&&this.resizeBuffer(t*2)}resizeBuffer(e){let t=new ArrayBuffer(e),n=new Uint8Array(t),r=new DataView(t);n.set(this.bytes),this.view=r,this.bytes=n}encodeNil(){this.writeU8(192)}encodeBoolean(e){e===!1?this.writeU8(194):this.writeU8(195)}encodeNumber(e){!this.forceIntegerToFloat&&Number.isSafeInteger(e)?e>=0?e<128?this.writeU8(e):e<256?(this.writeU8(204),this.writeU8(e)):e<65536?(this.writeU8(205),this.writeU16(e)):e<4294967296?(this.writeU8(206),this.writeU32(e)):this.useBigInt64?this.encodeNumberAsFloat(e):(this.writeU8(207),this.writeU64(e)):e>=-32?this.writeU8(224|e+32):e>=-128?(this.writeU8(208),this.writeI8(e)):e>=-32768?(this.writeU8(209),this.writeI16(e)):e>=-2147483648?(this.writeU8(210),this.writeI32(e)):this.useBigInt64?this.encodeNumberAsFloat(e):(this.writeU8(211),this.writeI64(e)):this.encodeNumberAsFloat(e)}encodeNumberAsFloat(e){this.forceFloat32?(this.writeU8(202),this.writeF32(e)):(this.writeU8(203),this.writeF64(e))}encodeBigInt64(e){e>=BigInt(0)?(this.writeU8(207),this.writeBigUint64(e)):(this.writeU8(211),this.writeBigInt64(e))}writeStringHeader(e){if(e<32)this.writeU8(160+e);else if(e<256)this.writeU8(217),this.writeU8(e);else if(e<65536)this.writeU8(218),this.writeU16(e);else if(e<4294967296)this.writeU8(219),this.writeU32(e);else throw Error(`Too long string: ${e} bytes in UTF-8`)}encodeString(e){let t=it(e);this.ensureBufferSizeToWrite(5+t),this.writeStringHeader(t),lt(e,this.bytes,this.pos),this.pos+=t}encodeObject(e,t){let n=this.extensionCodec.tryToEncode(e,this.context);if(n!=null)this.encodeExtension(n);else if(Array.isArray(e))this.encodeArray(e,t);else if(ArrayBuffer.isView(e))this.encodeBinary(e);else if(typeof e==`object`)this.encodeMap(e,t);else throw Error(`Unrecognized object: ${Object.prototype.toString.apply(e)}`)}encodeBinary(e){let t=e.byteLength;if(t<256)this.writeU8(196),this.writeU8(t);else if(t<65536)this.writeU8(197),this.writeU16(t);else if(t<4294967296)this.writeU8(198),this.writeU32(t);else throw Error(`Too large binary: ${t}`);let n=kt(e);this.writeU8a(n)}encodeArray(e,t){let n=e.length;if(n<16)this.writeU8(144+n);else if(n<65536)this.writeU8(220),this.writeU16(n);else if(n<4294967296)this.writeU8(221),this.writeU32(n);else throw Error(`Too large array: ${n}`);for(let n of e)this.doEncode(n,t+1)}countWithoutUndefined(e,t){let n=0;for(let r of t)e[r]!==void 0&&n++;return n}encodeMap(e,t){let n=Object.keys(e);this.sortKeys&&n.sort();let r=this.ignoreUndefined?this.countWithoutUndefined(e,n):n.length;if(r<16)this.writeU8(128+r);else if(r<65536)this.writeU8(222),this.writeU16(r);else if(r<4294967296)this.writeU8(223),this.writeU32(r);else throw Error(`Too large map object: ${r}`);for(let r of n){let n=e[r];this.ignoreUndefined&&n===void 0||(this.encodeString(r),this.doEncode(n,t+1))}}encodeExtension(e){if(typeof e.data==`function`){let t=e.data(this.pos+6),n=t.length;if(n>=4294967296)throw Error(`Too large extension object: ${n}`);this.writeU8(201),this.writeU32(n),this.writeI8(e.type),this.writeU8a(t);return}let t=e.data.length;if(t===1)this.writeU8(212);else if(t===2)this.writeU8(213);else if(t===4)this.writeU8(214);else if(t===8)this.writeU8(215);else if(t===16)this.writeU8(216);else if(t<256)this.writeU8(199),this.writeU8(t);else if(t<65536)this.writeU8(200),this.writeU16(t);else if(t<4294967296)this.writeU8(201),this.writeU32(t);else throw Error(`Too large extension object: ${t}`);this.writeI8(e.type),this.writeU8a(e.data)}writeU8(e){this.ensureBufferSizeToWrite(1),this.view.setUint8(this.pos,e),this.pos++}writeU8a(e){let t=e.length;this.ensureBufferSizeToWrite(t),this.bytes.set(e,this.pos),this.pos+=t}writeI8(e){this.ensureBufferSizeToWrite(1),this.view.setInt8(this.pos,e),this.pos++}writeU16(e){this.ensureBufferSizeToWrite(2),this.view.setUint16(this.pos,e),this.pos+=2}writeI16(e){this.ensureBufferSizeToWrite(2),this.view.setInt16(this.pos,e),this.pos+=2}writeU32(e){this.ensureBufferSizeToWrite(4),this.view.setUint32(this.pos,e),this.pos+=4}writeI32(e){this.ensureBufferSizeToWrite(4),this.view.setInt32(this.pos,e),this.pos+=4}writeF32(e){this.ensureBufferSizeToWrite(4),this.view.setFloat32(this.pos,e),this.pos+=4}writeF64(e){this.ensureBufferSizeToWrite(8),this.view.setFloat64(this.pos,e),this.pos+=8}writeU64(e){this.ensureBufferSizeToWrite(8),_t(this.view,this.pos,e),this.pos+=8}writeI64(e){this.ensureBufferSizeToWrite(8),vt(this.view,this.pos,e),this.pos+=8}writeBigUint64(e){this.ensureBufferSizeToWrite(8),this.view.setBigUint64(this.pos,e),this.pos+=8}writeBigInt64(e){this.ensureBufferSizeToWrite(8),this.view.setBigInt64(this.pos,e),this.pos+=8}};function jt(e,t){return new At(t).encodeSharedRef(e)}function Mt(e){return`${e<0?`-`:``}0x${Math.abs(e).toString(16).padStart(2,`0`)}`}var Nt=16,Pt=16,Ft=class{hit=0;miss=0;caches;maxKeyLength;maxLengthPerKey;constructor(e=Nt,t=Pt){this.maxKeyLength=e,this.maxLengthPerKey=t,this.caches=[];for(let e=0;e<this.maxKeyLength;e++)this.caches.push([])}canBeCached(e){return e>0&&e<=this.maxKeyLength}find(e,t,n){let r=this.caches[n-1];FIND_CHUNK:for(let i of r){let r=i.bytes;for(let i=0;i<n;i++)if(r[i]!==e[t+i])continue FIND_CHUNK;return i.str}return null}store(e,t){let n=this.caches[e.length-1],r={bytes:e,str:t};n.length>=this.maxLengthPerKey?n[Math.random()*n.length|0]=r:n.push(r)}decode(e,t,n){let r=this.find(e,t,n);if(r!=null)return this.hit++,r;this.miss++;let i=ut(e,t,n),a=Uint8Array.prototype.slice.call(e,t,t+n);return this.store(a,i),i}},It=`array`,U=`map_key`,Lt=`map_value`,Rt=e=>{if(typeof e==`string`||typeof e==`number`)return e;throw new gt(`The type of key must be string or number but `+typeof e)},zt=class{stack=[];stackHeadPosition=-1;get length(){return this.stackHeadPosition+1}top(){return this.stack[this.stackHeadPosition]}pushArrayState(e){let t=this.getUninitializedStateFromPool();t.type=It,t.position=0,t.size=e,t.array=Array(e)}pushMapState(e){let t=this.getUninitializedStateFromPool();t.type=U,t.readCount=0,t.size=e,t.map={}}getUninitializedStateFromPool(){return this.stackHeadPosition++,this.stackHeadPosition===this.stack.length&&this.stack.push({type:void 0,size:0,array:void 0,position:0,readCount:0,map:void 0,key:null}),this.stack[this.stackHeadPosition]}release(e){if(this.stack[this.stackHeadPosition]!==e)throw Error(`Invalid stack state. Released state is not on top of the stack.`);if(e.type===It){let t=e;t.size=0,t.array=void 0,t.position=0,t.type=void 0}if(e.type===U||e.type===Lt){let t=e;t.size=0,t.map=void 0,t.readCount=0,t.type=void 0}this.stackHeadPosition--}reset(){this.stack.length=0,this.stackHeadPosition=-1}},Bt=-1,Vt=new DataView(new ArrayBuffer(0)),Ht=new Uint8Array(Vt.buffer);try{Vt.getInt8(0)}catch(e){if(!(e instanceof RangeError))throw Error(`This module is not supported in the current JavaScript engine because DataView does not throw RangeError on out-of-bounds access`)}var Ut=RangeError(`Insufficient data`),Wt=new Ft,Gt=class e{extensionCodec;context;useBigInt64;rawStrings;maxStrLength;maxBinLength;maxArrayLength;maxMapLength;maxExtLength;keyDecoder;mapKeyConverter;totalPos=0;pos=0;view=Vt;bytes=Ht;headByte=Bt;stack=new zt;entered=!1;constructor(e){this.extensionCodec=e?.extensionCodec??Dt.defaultCodec,this.context=e?.context,this.useBigInt64=e?.useBigInt64??!1,this.rawStrings=e?.rawStrings??!1,this.maxStrLength=e?.maxStrLength??4294967295,this.maxBinLength=e?.maxBinLength??4294967295,this.maxArrayLength=e?.maxArrayLength??4294967295,this.maxMapLength=e?.maxMapLength??4294967295,this.maxExtLength=e?.maxExtLength??4294967295,this.keyDecoder=e?.keyDecoder===void 0?Wt:e.keyDecoder,this.mapKeyConverter=e?.mapKeyConverter??Rt}clone(){return new e({extensionCodec:this.extensionCodec,context:this.context,useBigInt64:this.useBigInt64,rawStrings:this.rawStrings,maxStrLength:this.maxStrLength,maxBinLength:this.maxBinLength,maxArrayLength:this.maxArrayLength,maxMapLength:this.maxMapLength,maxExtLength:this.maxExtLength,keyDecoder:this.keyDecoder})}reinitializeState(){this.totalPos=0,this.headByte=Bt,this.stack.reset()}setBuffer(e){let t=kt(e);this.bytes=t,this.view=new DataView(t.buffer,t.byteOffset,t.byteLength),this.pos=0}appendBuffer(e){if(this.headByte===Bt&&!this.hasRemaining(1))this.setBuffer(e);else{let t=this.bytes.subarray(this.pos),n=kt(e),r=new Uint8Array(t.length+n.length);r.set(t),r.set(n,t.length),this.setBuffer(r)}}hasRemaining(e){return this.view.byteLength-this.pos>=e}createExtraByteError(e){let{view:t,pos:n}=this;return RangeError(`Extra ${t.byteLength-n} of ${t.byteLength} byte(s) found at buffer[${e}]`)}decode(e){if(this.entered)return this.clone().decode(e);try{this.entered=!0,this.reinitializeState(),this.setBuffer(e);let t=this.doDecodeSync();if(this.hasRemaining(1))throw this.createExtraByteError(this.pos);return t}finally{this.entered=!1}}*decodeMulti(e){if(this.entered){yield*this.clone().decodeMulti(e);return}try{for(this.entered=!0,this.reinitializeState(),this.setBuffer(e);this.hasRemaining(1);)yield this.doDecodeSync()}finally{this.entered=!1}}async decodeAsync(e){if(this.entered)return this.clone().decodeAsync(e);try{this.entered=!0;let t=!1,n;for await(let r of e){if(t)throw this.entered=!1,this.createExtraByteError(this.totalPos);this.appendBuffer(r);try{n=this.doDecodeSync(),t=!0}catch(e){if(!(e instanceof RangeError))throw e}this.totalPos+=this.pos}if(t){if(this.hasRemaining(1))throw this.createExtraByteError(this.totalPos);return n}let{headByte:r,pos:i,totalPos:a}=this;throw RangeError(`Insufficient data in parsing ${Mt(r)} at ${a} (${i} in the current buffer)`)}finally{this.entered=!1}}decodeArrayStream(e){return this.decodeMultiAsync(e,!0)}decodeStream(e){return this.decodeMultiAsync(e,!1)}async*decodeMultiAsync(e,t){if(this.entered){yield*this.clone().decodeMultiAsync(e,t);return}try{this.entered=!0;let n=t,r=-1;for await(let i of e){if(t&&r===0)throw this.createExtraByteError(this.totalPos);this.appendBuffer(i),n&&(r=this.readArraySize(),n=!1,this.complete());try{for(;yield this.doDecodeSync(),--r!==0;);}catch(e){if(!(e instanceof RangeError))throw e}this.totalPos+=this.pos}}finally{this.entered=!1}}doDecodeSync(){DECODE:for(;;){let e=this.readHeadByte(),t;if(e>=224)t=e-256;else if(e<192)if(e<128)t=e;else if(e<144){let n=e-128;if(n!==0){this.pushMapState(n),this.complete();continue DECODE}else t={}}else if(e<160){let n=e-144;if(n!==0){this.pushArrayState(n),this.complete();continue DECODE}else t=[]}else{let n=e-160;t=this.decodeString(n,0)}else if(e===192)t=null;else if(e===194)t=!1;else if(e===195)t=!0;else if(e===202)t=this.readF32();else if(e===203)t=this.readF64();else if(e===204)t=this.readU8();else if(e===205)t=this.readU16();else if(e===206)t=this.readU32();else if(e===207)t=this.useBigInt64?this.readU64AsBigInt():this.readU64();else if(e===208)t=this.readI8();else if(e===209)t=this.readI16();else if(e===210)t=this.readI32();else if(e===211)t=this.useBigInt64?this.readI64AsBigInt():this.readI64();else if(e===217){let e=this.lookU8();t=this.decodeString(e,1)}else if(e===218){let e=this.lookU16();t=this.decodeString(e,2)}else if(e===219){let e=this.lookU32();t=this.decodeString(e,4)}else if(e===220){let e=this.readU16();if(e!==0){this.pushArrayState(e),this.complete();continue DECODE}else t=[]}else if(e===221){let e=this.readU32();if(e!==0){this.pushArrayState(e),this.complete();continue DECODE}else t=[]}else if(e===222){let e=this.readU16();if(e!==0){this.pushMapState(e),this.complete();continue DECODE}else t={}}else if(e===223){let e=this.readU32();if(e!==0){this.pushMapState(e),this.complete();continue DECODE}else t={}}else if(e===196){let e=this.lookU8();t=this.decodeBinary(e,1)}else if(e===197){let e=this.lookU16();t=this.decodeBinary(e,2)}else if(e===198){let e=this.lookU32();t=this.decodeBinary(e,4)}else if(e===212)t=this.decodeExtension(1,0);else if(e===213)t=this.decodeExtension(2,0);else if(e===214)t=this.decodeExtension(4,0);else if(e===215)t=this.decodeExtension(8,0);else if(e===216)t=this.decodeExtension(16,0);else if(e===199){let e=this.lookU8();t=this.decodeExtension(e,1)}else if(e===200){let e=this.lookU16();t=this.decodeExtension(e,2)}else if(e===201){let e=this.lookU32();t=this.decodeExtension(e,4)}else throw new gt(`Unrecognized type byte: ${Mt(e)}`);this.complete();let n=this.stack;for(;n.length>0;){let e=n.top();if(e.type===It)if(e.array[e.position]=t,e.position++,e.position===e.size)t=e.array,n.release(e);else continue DECODE;else if(e.type===U){if(t===`__proto__`)throw new gt(`The key __proto__ is not allowed`);e.key=this.mapKeyConverter(t),e.type=Lt;continue DECODE}else if(e.map[e.key]=t,e.readCount++,e.readCount===e.size)t=e.map,n.release(e);else{e.key=null,e.type=U;continue DECODE}}return t}}readHeadByte(){return this.headByte===Bt&&(this.headByte=this.readU8()),this.headByte}complete(){this.headByte=Bt}readArraySize(){let e=this.readHeadByte();switch(e){case 220:return this.readU16();case 221:return this.readU32();default:if(e<160)return e-144;throw new gt(`Unrecognized array type byte: ${Mt(e)}`)}}pushMapState(e){if(e>this.maxMapLength)throw new gt(`Max length exceeded: map length (${e}) > maxMapLengthLength (${this.maxMapLength})`);this.stack.pushMapState(e)}pushArrayState(e){if(e>this.maxArrayLength)throw new gt(`Max length exceeded: array length (${e}) > maxArrayLength (${this.maxArrayLength})`);this.stack.pushArrayState(e)}decodeString(e,t){return!this.rawStrings||this.stateIsMapKey()?this.decodeUtf8String(e,t):this.decodeBinary(e,t)}decodeUtf8String(e,t){if(e>this.maxStrLength)throw new gt(`Max length exceeded: UTF-8 byte length (${e}) > maxStrLength (${this.maxStrLength})`);if(this.bytes.byteLength<this.pos+t+e)throw Ut;let n=this.pos+t,r;return r=this.stateIsMapKey()&&this.keyDecoder?.canBeCached(e)?this.keyDecoder.decode(this.bytes,n,e):mt(this.bytes,n,e),this.pos+=t+e,r}stateIsMapKey(){return this.stack.length>0?this.stack.top().type===U:!1}decodeBinary(e,t){if(e>this.maxBinLength)throw new gt(`Max length exceeded: bin length (${e}) > maxBinLength (${this.maxBinLength})`);if(!this.hasRemaining(e+t))throw Ut;let n=this.pos+t,r=this.bytes.subarray(n,n+e);return this.pos+=t+e,r}decodeExtension(e,t){if(e>this.maxExtLength)throw new gt(`Max length exceeded: ext length (${e}) > maxExtLength (${this.maxExtLength})`);let n=this.view.getInt8(this.pos+t),r=this.decodeBinary(e,t+1);return this.extensionCodec.decode(r,n,this.context)}lookU8(){return this.view.getUint8(this.pos)}lookU16(){return this.view.getUint16(this.pos)}lookU32(){return this.view.getUint32(this.pos)}readU8(){let e=this.view.getUint8(this.pos);return this.pos++,e}readI8(){let e=this.view.getInt8(this.pos);return this.pos++,e}readU16(){let e=this.view.getUint16(this.pos);return this.pos+=2,e}readI16(){let e=this.view.getInt16(this.pos);return this.pos+=2,e}readU32(){let e=this.view.getUint32(this.pos);return this.pos+=4,e}readI32(){let e=this.view.getInt32(this.pos);return this.pos+=4,e}readU64(){let e=V(this.view,this.pos);return this.pos+=8,e}readI64(){let e=yt(this.view,this.pos);return this.pos+=8,e}readU64AsBigInt(){let e=this.view.getBigUint64(this.pos);return this.pos+=8,e}readI64AsBigInt(){let e=this.view.getBigInt64(this.pos);return this.pos+=8,e}readF32(){let e=this.view.getFloat32(this.pos);return this.pos+=4,e}readF64(){let e=this.view.getFloat64(this.pos);return this.pos+=8,e}};function Kt(e,t){return new Gt(t).decode(e)}var qt=15e3,Jt=500,Yt=15e3,Xt=4e4,Zt=1e3,Qt=5e3,$t=`bamboo.v2.msgpack`,en=e=>typeof e==`object`&&!!e&&!Array.isArray(e),tn=e=>typeof e==`number`&&Number.isSafeInteger(e)&&e>0,nn=e=>{if(!tn(e.seq)||e.control!==void 0||!en(e.event))return null;let t=e.event;return!tn(t.seq)||t.seq!==e.seq||typeof t.ts!=`string`||t.session_id!==void 0&&typeof t.session_id!=`string`||!en(t.event)||typeof t.event.type!=`string`?null:t},rn=e=>e.seq!==0||e.event!==void 0||!en(e.control)||e.control.type!==`feed_reset`||!tn(e.control.from_seq)?null:e.control.from_seq,W=null,an=!1,on=0,sn=null,cn=!1,ln=!1,un=null,dn=new Set,fn=e=>(dn.add(e),()=>dn.delete(e)),pn=(e=W)=>{let t=un;return e!==null&&W===e&&e.readyState===WebSocket.OPEN&&t!==null&&t.socket===e&&t.phase===`ready`},G=null,mn=()=>pn()&&G!==null&&!G.deliveryFailed&&G.subscribedSince!==null,hn=new Map,gn=e=>`agent.${e}`,_n=()=>G!==null&&!G.deliveryFailed||hn.size>0,vn=e=>e.protocol===$t,yn=(e,t)=>{if(W===e&&e.readyState===WebSocket.OPEN)try{return e.send(vn(e)?jt(t):JSON.stringify(t)),!0}catch(e){P(`[v2Stream]`,`send.error`,{payload:t,error:e})}return!1},bn=e=>W!==null&&yn(W,e),xn=(e,t)=>{let n=e.since;return e.subscribedSince=null,e.acceptedInSubscription=!1,e.resetHandledInSubscription=!1,yn(t,{type:`subscribe`,ch:`feed`,since:n})?(e.subscribedSince=n,!0):!1},Sn=(e,t,n)=>{if(console.warn(`Failed to ${t} v2 feed:`,n),!(G!==e||e.deliveryFailed)){e.deliveryFailed=!0,e.subscribedSince=null,pn()&&bn({type:`unsubscribe`,ch:`feed`});try{e.handlers.onError?.()}catch(e){console.warn(`Failed to report v2 feed handler error:`,e)}Fn()}},Cn=e=>{if(G&&!G.deliveryFailed&&!xn(G,e))return!1;for(let t of hn.keys())if(!yn(e,{type:`subscribe`,ch:t}))return!1;return!0},wn=()=>{sn&&=(clearTimeout(sn),null)},Tn=()=>{if(!_n()||cn||sn)return;let e=Math.min(Jt*2**on,qt);on+=1,P(`[v2Stream]`,`reconnect.schedule`,{attempt:on,delay:e}),sn=setTimeout(()=>{sn=null,Vn()},e)},En=e=>{let t=un;!t||e&&t.socket!==e||(t.welcomeTimer!==null&&(clearTimeout(t.welcomeTimer),t.welcomeTimer=null),t.heartbeatTimer!==null&&(clearInterval(t.heartbeatTimer),t.heartbeatTimer=null),t.watchdogTimer!==null&&(clearInterval(t.watchdogTimer),t.watchdogTimer=null),t.visibilityListener&&typeof document<`u`&&(document.removeEventListener(`visibilitychange`,t.visibilityListener),t.visibilityListener=null),un===t&&(un=null))},Dn=e=>{let t=W;if(!t||e&&t!==e)return!1;En(t),t.onopen=null,t.onmessage=null,t.onerror=null,t.onclose=null;try{t.close()}catch{}return W===t&&(W=null),!0},On=()=>{try{G?.handlers.onError?.()}catch(e){P(`[v2Stream]`,`unavailable.listener_error`,{error:e})}},K=(e,t)=>{un!==e||W!==e.socket||e.recoveryStarted||(e.recoveryStarted=!0,G&&(G.subscribedSince=null,G.acceptedInSubscription=!1,G.resetHandledInSubscription=!1),ln=!0,P(`[v2Stream]`,`epoch.unavailable`,{reason:t}),On(),Dn(e.socket),an=!1,Tn())},kn=e=>{un!==e||W!==e.socket||e.recoveryStarted||(P(`[v2Stream]`,`watchdog.stale_socket`,{silentForMs:Date.now()-e.lastFrameAt}),K(e,`heartbeat-stale`))},An=e=>{un!==e||W!==e.socket||e.socket.readyState!==WebSocket.OPEN||e.phase!==`ready`||!e.heartbeatAckSeen||Date.now()-e.lastFrameAt>=Xt&&kn(e)},jn=e=>{En();let t={socket:e,phase:`awaiting-welcome`,lastFrameAt:Date.now(),pingSent:!1,heartbeatAckSeen:!1,recoveryStarted:!1,welcomeTimer:null,heartbeatTimer:null,watchdogTimer:null,visibilityListener:null};return un=t,t.welcomeTimer=setTimeout(()=>{un!==t||W!==e||t.phase!==`awaiting-welcome`||K(t,`welcome-timeout`)},Qt),t},Mn=e=>{let t=e.socket;e.welcomeTimer!==null&&(clearTimeout(e.welcomeTimer),e.welcomeTimer=null),e.lastFrameAt=Date.now(),e.heartbeatTimer=setInterval(()=>{un!==e||W!==t||t.readyState!==WebSocket.OPEN||e.phase!==`ready`||yn(t,{type:`ping`})&&(e.pingSent=!0)},Yt),e.watchdogTimer=setInterval(()=>An(e),Zt),typeof document<`u`&&(e.visibilityListener=()=>{document.visibilityState===`visible`&&An(e)},document.addEventListener(`visibilitychange`,e.visibilityListener))},Nn=e=>{let t=un;return!t||t.socket!==e||W!==e||t.phase!==`ready`?null:(t.lastFrameAt=Date.now(),t)},Pn=e=>{!e||!e.pingSent||e.heartbeatAckSeen||(e.heartbeatAckSeen=!0,P(`[v2Stream]`,`heartbeat.acknowledged`,{}))},Fn=()=>{_n()||(cn=!0,wn(),Dn(),En(),an=!1,on=0,ln=!1)},In=e=>{try{if(typeof e==`string`)return JSON.parse(e);if(e instanceof ArrayBuffer)return Kt(new Uint8Array(e));if(ArrayBuffer.isView(e)){let t=e;return Kt(new Uint8Array(t.buffer,t.byteOffset,t.byteLength))}P(`[v2Stream]`,`frame.unknown_data_type`,{});return}catch(t){console.warn(`Failed to parse v2 stream frame:`,e,t);return}},Ln=e=>en(e)&&Object.keys(e).length===1&&Object.prototype.hasOwnProperty.call(e,`type`)&&e.type===`welcome`,Rn=e=>en(e)&&e.type===`welcome`,zn=e=>{let t=e.socket;if(un!==e||W!==t||t.readyState!==WebSocket.OPEN||e.phase!==`awaiting-welcome`)return;if(e.welcomeTimer!==null&&(clearTimeout(e.welcomeTimer),e.welcomeTimer=null),e.phase=`subscribing`,!_n()){Fn();return}if(!Cn(t)){K(e,`subscribe-send-failed`);return}if(un!==e||W!==t||!_n()){Fn();return}e.phase=`ready`,on=0;let n=ln;if(ln=!1,Mn(e),P(`[v2Stream]`,`ready`,{afterDrop:n}),G&&!G.deliveryFailed&&G.subscribedSince!==null)try{G.handlers.onOpen?.()}catch(e){P(`[v2Stream]`,`feed.open_listener_error`,{error:e})}if(!(un!==e||W!==t||e.phase!==`ready`||!_n())&&n)for(let e of[...dn])try{e()}catch(e){P(`[v2Stream]`,`reconnected.listener_error`,{error:e})}},Bn=(e,t)=>{if(e?.type===`pong`&&e.ch===void 0){Pn(t);return}if(!e||typeof e.ch!=`string`){P(`[v2Stream]`,`frame.unknown`,{});return}let{ch:n,control:r,event:i}=e;if(n!==`sys`){if(n===`feed`){let t=G;if(!t||t.deliveryFailed||t.subscribedSince===null)return;if(r){let n=rn(e);if(n!==null&&n===t.subscribedSince&&!t.acceptedInSubscription&&!t.resetHandledInSubscription){P(`[v2Stream]`,`feed.reset`,{});let e=t.handlers.onReset;if(!e){Sn(t,`apply reset`,Error(`feed_reset requires an application reset handler`));return}let r=t.since;t.since=0;try{e()}catch(e){t.since=r,Sn(t,`apply reset`,e);return}G===t&&!t.deliveryFailed&&(t.resetHandledInSubscription=!0,t.postResetFloor=n)}else P(`[v2Stream]`,`feed.control.invalid`,{});return}let n=nn(e);if(!n){P(`[v2Stream]`,`feed.frame.invalid_event`,{});return}let i=Math.max(t.since,t.postResetFloor??0);if(n.seq<=i){P(`[v2Stream]`,`feed.frame.stale`,{seq:n.seq,since:i});return}try{t.handlers.onChange(n)}catch(e){Sn(t,`apply event`,e);return}G===t&&(t.since=n.seq,t.acceptedInSubscription=!0,t.postResetFloor=null);return}if(n.startsWith(`agent.`)){let e=hn.get(n);if(!e||e.size===0)return;if(r){if(r.type===`terminal`){P(`[v2Stream]`,`agent.terminal`,{ch:n,subscribers:e.size});for(let t of[...e])t.resolve()}return}if(i===void 0){P(`[v2Stream]`,`agent.frame.no_event`,{});return}for(let t of[...e])try{t.dispatch(i,t.handlers)}catch(e){console.warn(`Failed to dispatch v2 agent event:`,i,e)}return}P(`[v2Stream]`,`frame.unknown_channel`,{ch:n})}},Vn=()=>{if(!_n()||W&&(W.readyState===WebSocket.OPEN||W.readyState===WebSocket.CONNECTING)||an)return;if(typeof WebSocket>`u`){P(`[v2Stream]`,`connect.no_websocket`,{});return}an=!0,cn=!1;let e=a().endpoints.v2Stream;P(`[v2Stream]`,`connect`,{url:e});let t=be(),n;try{n=t?new WebSocket(e,[$t]):new WebSocket(e),t&&(n.binaryType=`arraybuffer`)}catch(e){an=!1,P(`[v2Stream]`,`connect.error`,{error:e}),G?.handlers.onError?.(),Tn();return}W=n,n.onopen=()=>{if(W!==n)return;an=!1;let e=jn(n);P(`[v2Stream]`,`open.awaiting_welcome`,{}),yn(n,{type:`hello`})||K(e,`hello-send-failed`)},n.onmessage=e=>{if(W!==n)return;let t=In(e.data),r=un;if(!(!r||r.socket!==n)){if(r.phase===`awaiting-welcome`){Ln(t)?zn(r):P(`[v2Stream]`,`frame.before_welcome`,{});return}r.phase!==`subscribing`&&(Rn(t)||Bn(t,Nn(n)))}},n.onerror=()=>{W===n&&(P(`[v2Stream]`,`error`,{}),On())},n.onclose=()=>{W===n&&(an=!1,En(n),P(`[v2Stream]`,`close`,{intentional:cn}),W=null,!cn&&(ln=!0,G&&(G.subscribedSince=null),On(),Tn()))}},Hn=(e,t)=>{G={handlers:e,since:tn(t)?t:0,deliveryFailed:!1,subscribedSince:null,acceptedInSubscription:!1,resetHandledInSubscription:!1,postResetFloor:null};let n=G;if(W&&pn(W)){if(!xn(n,W)){let e=un;e&&K(e,`feed-subscribe-send-failed`)}}else Vn();let r=!1;return{close(){r||(r=!0,G===n&&(G=null,pn()&&bn({type:`unsubscribe`,ch:`feed`}),Fn()))}}},Un=(e,t,n)=>{let r=gn(e),i=!1,a=()=>{},o={sessionId:e,handlers:t,dispatch:n,resolve:()=>a()},s=new Promise(e=>{a=()=>{if(i)return;i=!0;let t=hn.get(r);t?.delete(o),(!t||t.size===0)&&(hn.delete(r),pn()&&bn({type:`unsubscribe`,ch:r}),Fn()),e()}}),c=hn.get(r),l=!c||c.size===0;if(c?c.add(o):hn.set(r,new Set([o])),W&&pn(W)){if(l&&!yn(W,{type:`subscribe`,ch:r})){let e=un;e&&K(e,`agent-subscribe-send-failed`)}}else Vn();return{promise:s,close:()=>a()}},Wn=e=>e==="default"||e===`bypass`||e===`auto`?e:null,Gn=e=>{if(typeof e!=`string`||!/^"\d{1,20}"$/.test(e))return null;let t=BigInt(e.slice(1,-1));return t<=18446744073709551615n?t:null},Kn=class extends Error{constructor(){super(`The backend did not confirm a supported, revisioned session permission mode.`),this.name=`SessionPermissionContractError`}},qn=async(e,t)=>{let n=await t.json(),r=n&&typeof n==`object`&&`session`in n?n.session:null,i=r&&typeof r==`object`&&`permission_mode`in r?Wn(r.permission_mode):null,a=t.headers.get(`ETag`);if(!r||typeof r!=`object`||!(`id`in r)||r.id!==e||!i||!a||Gn(a)===null)throw new Kn;return{sessionId:e,mode:i,etag:a}},Jn=class extends Error{constructor(){super(`无法确认当前请求,请刷新后重试。`),this.name=`PendingInteractionContractError`}},Yn=e=>typeof e==`object`&&e&&!Array.isArray(e)?e:null,Xn=e=>typeof e==`string`&&e.trim().length>0,Zn=e=>typeof e==`number`&&Number.isSafeInteger(e)&&e>=0;function Qn(e,t){let n=Yn(t);if(!n)throw new Jn;if(n.has_pending_question===!1&&n.interaction_kind==null&&n.permission_request==null)return{has_pending_question:!1};if(n.has_pending_question!==!0||typeof n.question!=`string`||!Array.isArray(n.options)||!n.options.every(e=>typeof e==`string`)||typeof n.allow_custom!=`boolean`||!Xn(n.tool_call_id))throw new Jn;if(n.interaction_kind===`clarification`&&n.permission_request==null)return n;let r=Yn(n.permission_request);if(n.interaction_kind!==`permission`||!r||r.session_id!==e||r.request_id!==n.tool_call_id||!Xn(r.request_generation)||!Zn(r.policy_revision)||![`tool_name`,`permission_type`,`resource`,`operation_summary`].every(e=>typeof r[e]==`string`)||!Array.isArray(r.allowed_decisions)||!r.allowed_decisions.every(e=>typeof e==`string`))throw new Jn;return n}var $n=e=>e?{client_message_count:e.client_message_count,client_last_message_id:e.client_last_message_id??null,client_has_pending_question:e.client_has_pending_question,client_pending_question_tool_call_id:e.client_pending_question_tool_call_id??null}:null,er=e=>e?{need_sync:e.need_sync,reason:e.reason??null,server_message_count:e.server_message_count,server_last_message_id:e.server_last_message_id??null,has_pending_question:e.has_pending_question,pending_question_tool_call_id:e.pending_question_tool_call_id??null,has_pending_user_message:e.has_pending_user_message}:null,tr=e=>{let t=e.messages[e.messages.length-1];return{session_id:e.session_id,messageCount:e.messages.length,lastMessageId:t?.id??null,lastRole:t?.role??null,compressionEvents:e.compression_events?.length??0}},nr=e=>({count:e.length,runningCount:e.filter(e=>e.is_running).length,sessions:e.slice(0,10).map(e=>({id:e.id,is_running:e.is_running,last_run_status:e.last_run_status??null,message_count:e.message_count,has_pending_question:e.has_pending_question??!1,running_child_count:e.running_child_count??0,updated_at:e.updated_at}))}),rr=e=>({count:e.sessions.length,sessions:e.sessions.map(e=>({session_id:e.session_id,run_id:e.run_id,round_count:e.round_count,last_event_at:e.last_event_at??null,last_tool_name:e.last_tool_name??null,last_tool_phase:e.last_tool_phase??null,criticalEventCount:e.last_critical_events.length,runningChildCount:e.running_child_session_ids.length}))}),ir=e=>({type:e.type,session_id:e.session_id??null,run_id:e.run_id??null,round_count:e.round_count??null,message:e.message??null,error:e.error??null,tool_call_id:e.tool_call_id??null}),ar=class e{static instance;static getInstance(){return e.instance||=new e,e.instance}async sendMessage(e){P(`[AgentClient]`,`chat.request`,{sessionId:e.session_id??null,model:e.model,modelRef:e.model_ref??null,provider:e.provider??null,messageLength:e.message.length,hasImages:(e.images?.length??0)>0,imageCount:e.images?.length??0,selectedSkillCount:e.selected_skill_ids?.length??0,workspacePath:e.workspace_path??null});let t=await z.post(`chat`,e);return P(`[AgentClient]`,`chat.response`,{requestedSessionId:e.session_id??null,sessionId:t.session_id,status:t.status}),t}async execute(e,t,n,r,i){let a={};t&&(a.model=t),n&&(a.reasoning_effort=n),r&&(a.client_sync=r),i&&(a.model_ref=i,a.provider=i.provider),P(`[AgentClient]`,`execute.request`,{sessionId:e,model:a.model??null,reasoningEffort:a.reasoning_effort??null,modelRef:a.model_ref??null,provider:a.provider??null,clientSync:$n(a.client_sync)});let o=await z.post(`execute/${e}`,a);return P(`[AgentClient]`,`execute.response`,{sessionId:e,status:o.status,runId:o.run_id??null,eventsUrl:o.events_url,sync:er(o.sync)}),o}async listSessions(e={}){let t=new URLSearchParams;e.limit!==void 0&&t.set(`limit`,String(e.limit)),e.offset!==void 0&&t.set(`offset`,String(e.offset)),e.kind!==void 0&&t.set(`kind`,e.kind),e.root_session_id!==void 0&&t.set(`root_session_id`,e.root_session_id);let n=t.size>0?`?${t.toString()}`:``;P(`[AgentClient]`,`sessions.list.request`,e);let r=await z.get(`sessions${n}`);return P(`[AgentClient]`,`sessions.list.response`,nr(r.sessions)),r}async getSession(e){return z.get(`sessions/${encodeURIComponent(e)}`)}async getTaskList(e){let t=encodeURIComponent(e),n=await z.get(`task/${t}`);if(!(typeof n.title==`string`||n.items.length>0))return null;let r=new Date().toISOString();return{session_id:n.session_id,title:n.title??`Task List`,items:n.items,created_at:r,updated_at:r}}async getPendingQuestion(e){let t=encodeURIComponent(e);return Qn(e,await z.get(`respond/${t}/pending`,{cache:`no-store`}))}async submitPermissionDecision(e,t){if(!Xn(t.request_id)||!Xn(t.request_generation)||!Zn(t.expected_policy_revision)||t.decision!==`allow_once`&&t.decision!==`deny_once`)throw new Jn;let n=Yn(await z.post(`sessions/${encodeURIComponent(e)}/permission-decisions`,t)),r=Yn(n?.receipt),i=Yn(r?.decision);if(n?.success!==!0||typeof n.replayed!=`boolean`||r?.session_id!==e||i?.request_id!==t.request_id||i?.request_generation!==t.request_generation||i?.decision!==t.decision||i?.matcher_id!=null||i?.expected_policy_revision!=null&&!Zn(i.expected_policy_revision)||i?.confirm_global!=null&&i.confirm_global!==!1)throw new Jn;let a=Yn(n.resume),o=a?.auto_resume_status,s=n.replayed&&n.resume==null&&n.auto_resume_status==null||a?.success===!0&&typeof o==`string`&&[`started`,`already_running`,`completed`].includes(o)&&n.auto_resume_status===o;return{replayed:n.replayed,autoResumeStatus:typeof o==`string`?o:void 0,continuationConfirmed:s}}async createSession(e){return z.post(`sessions`,e)}async patchSession(e,t){let n=encodeURIComponent(e);await z.patch(`sessions/${n}`,t)}async getSessionPermissionMode(e){return qn(e,await z.fetchRaw(`sessions/${encodeURIComponent(e)}`,{cache:`no-store`}))}async patchSessionPermissionMode(e,t,n){if(!Wn(t)||Gn(n)===null)throw new Kn;let r={permission_mode:t};return qn(e,await z.fetchRaw(`sessions/${encodeURIComponent(e)}`,{method:`PATCH`,headers:{"If-Match":n},body:JSON.stringify(r),cache:`no-store`}))}async regenerateSessionTitle(e){let t=encodeURIComponent(e);await z.post(`sessions/${t}/regenerate-title`)}async getSessionSystemPrompt(e){let t=encodeURIComponent(e);return z.get(`sessions/${t}/system-prompt`)}async clearSession(e){let t=encodeURIComponent(e);await z.post(`sessions/${t}/clear`)}async runProjectDream(e){let t=encodeURIComponent(e);return z.post(`sessions/${t}/project-dream/run`)}async truncateSessionMessages(e,t){let n=encodeURIComponent(e);return z.post(`sessions/${n}/messages/truncate`,t)}async restoreSessionState(e,t){let n=encodeURIComponent(e);return z.post(`sessions/${n}/restore`,t)}async patchSessionMessage(e,t,n){let r=encodeURIComponent(e),i=encodeURIComponent(t);await z.patch(`sessions/${r}/messages/${i}`,n)}async deleteSessionMessage(e,t){let n=encodeURIComponent(e),r=encodeURIComponent(t);await z.delete(`sessions/${n}/messages/${r}`)}async cleanupSessions(e,t){await z.post(`sessions/cleanup`,{mode:e,keep_pinned:t})}async respondToChildApproval(e,t,n){return z.post(`child-approval/${encodeURIComponent(e)}`,{request_id:t,approved:n})}async devResetSessions(){await z.post(`dev/reset`)}async getRunningSessions(){P(`[AgentClient]`,`runs.active.request`,{});let e=await z.get(`runs/active`);return P(`[AgentClient]`,`runs.active.response`,rr(e)),e}async listSchedules(){return z.get(`schedules`)}async createSchedule(e){return z.post(`schedules`,e)}async patchSchedule(e,t){let n=encodeURIComponent(e);return z.patch(`schedules/${n}`,t)}async deleteSchedule(e){let t=encodeURIComponent(e);await z.delete(`schedules/${t}`)}async runScheduleNow(e){let t=encodeURIComponent(e);await z.post(`schedules/${t}/run`)}async listScheduleSessions(e){let t=encodeURIComponent(e);return z.get(`schedules/${t}/sessions`)}async listScheduleRuns(e){let t=encodeURIComponent(e);return z.get(`schedules/${t}/runs`)}async subscribeToEvents(e,t,n){let r=n?.signal;if(P(`[AgentClient]`,`events.subscribe.request`,{sessionId:e}),r?.aborted){P(`[AgentClient]`,`events.subscribe.ws.aborted_before_connect`,{sessionId:e});return}let{promise:i,close:a}=Un(e,t,(e,t)=>this.handleEvent(e,t)),o=()=>{P(`[AgentClient]`,`events.subscribe.ws.abort`,{sessionId:e}),a()};r?.addEventListener(`abort`,o,{once:!0});try{await i}finally{r?.removeEventListener(`abort`,o)}}subscribeToAccountStream(e,t){return Hn(e,t?.since??0)}handleEvent(e,t){switch(e.type){case`token`:t.onToken?.(e.content||``);break;case`reasoning_token`:t.onReasoningToken?.(e.content||``);break;case`tool_token`:t.onToolToken?.(e.tool_call_id||``,e.content||``);break;case`tool_start`:t.onToolStart?.(e.tool_call_id||``,e.tool_name||``,e.arguments||{});break;case`tool_complete`:e.result&&t.onToolComplete?.(e.tool_call_id||``,e.result);break;case`bash_completed`:t.onBashCompleted?.(e.bash_id??``,e.command??``,e.exit_code??null,typeof e.status==`string`?e.status:`completed`);break;case`tool_error`:t.onToolError?.(e.tool_call_id||``,e.error||``);break;case`task_list_updated`:e.task_list&&t.onTaskListUpdated?.(e.task_list);break;case`task_list_item_progress`:if(e.session_id&&e.item_id&&e.status&&e.tool_calls_count!==void 0&&e.version!==void 0){let n=e.status;if(!(n===`pending`||n===`in_progress`||n===`completed`||n===`blocked`))break;t.onTaskListItemProgress?.({session_id:e.session_id,item_id:e.item_id,status:n,tool_calls_count:e.tool_calls_count,version:e.version})}break;case`task_list_completed`:e.session_id&&e.total_rounds!==void 0&&e.total_tool_calls!==void 0&&t.onTaskListCompleted?.(e.session_id,e.total_rounds,e.total_tool_calls,e.completed_at);break;case`task_evaluation_started`:e.session_id&&e.items_count!==void 0&&t.onTaskEvaluationStarted?.(e.session_id,e.items_count);break;case`task_evaluation_completed`:e.session_id&&e.updates_count!==void 0&&e.reasoning&&t.onTaskEvaluationCompleted?.(e.session_id,e.updates_count,e.reasoning);break;case`token_budget_updated`:e.usage&&`system_tokens`in e.usage&&t.onTokenBudgetUpdated?.(e.usage);break;case`context_compression_status`:typeof e.phase==`string`&&typeof e.status==`string`&&t.onContextCompressionStatus?.(e.phase,e.status);break;case`tool_lifecycle`:t.onToolLifecycle?.(e.tool_call_id||``,e.tool_name||``,e.phase||``,e.elapsed_ms,e.is_mutating,e.auto_approved,e.summary,e.error);break;case`context_summarized`:e.summary_info&&t.onContextSummarized?.(e.summary_info);break;case`context_pressure_notification`:typeof e.percent==`number`&&typeof e.level==`string`&&t.onContextPressureNotification?.(e.percent,e.level,e.message||``);break;case`sub_agent_started`:e.parent_session_id&&e.child_session_id&&t.onSubAgentStarted?.(e.parent_session_id,e.child_session_id,e.title);break;case`sub_agent_event`:e.parent_session_id&&e.child_session_id&&e.event&&t.onSubAgentEvent?.(e.parent_session_id,e.child_session_id,e.event);break;case`sub_agent_heartbeat`:e.parent_session_id&&e.child_session_id&&e.timestamp&&t.onSubAgentHeartbeat?.(e.parent_session_id,e.child_session_id,e.timestamp);break;case`sub_agent_completed`:e.parent_session_id&&e.child_session_id&&t.onSubAgentCompleted?.(e.parent_session_id,e.child_session_id,typeof e.status==`string`?e.status:`completed`,e.error);break;case`child_approval_requested`:e.child_session_id&&e.request_id&&t.onChildApprovalRequested?.(e.child_session_id,e.request_id,{toolName:e.tool_name,permission:e.permission,resource:e.resource});break;case`execution_started`:t.onExecutionStarted?.(e.run_id||``,e.started_at);break;case`runner_progress`:e.session_id&&typeof e.round_count==`number`&&t.onRunnerProgress?.(e.session_id,e.round_count);break;case`need_clarification`:t.onNeedClarification?.(e);break;case`notification`:t.onNotification?.(e);break;case`session_title_updated`:e.session_id&&typeof e.title==`string`&&typeof e.title_version==`number`&&(e.source===`auto`||e.source===`manual`||e.source===`fallback`)&&typeof e.updated_at==`string`&&t.onSessionTitleUpdated?.({type:`session_title_updated`,session_id:e.session_id,title:e.title,title_version:e.title_version,source:e.source,updated_at:e.updated_at});break;case`session_pinned_updated`:e.session_id&&typeof e.pinned==`boolean`&&typeof e.updated_at==`string`&&t.onSessionPinnedUpdated?.({type:`session_pinned_updated`,session_id:e.session_id,pinned:e.pinned,updated_at:e.updated_at});break;case`plan_mode_entered`:t.onPlanModeEntered?.(e);break;case`plan_mode_exited`:t.onPlanModeExited?.(e);break;case`plan_file_updated`:t.onPlanFileUpdated?.(e);break;case`goal_status_changed`:t.onGoalStatusChanged?.(e);break;case`complete`:P(`[AgentClient]`,`events.dispatch.complete`,ir(e)),t.onComplete?.(e.usage);break;case`cancelled`:P(`[AgentClient]`,`events.dispatch.cancelled`,ir(e)),t.onCancelled?.(e.message);break;case`error`:P(`[AgentClient]`,`events.dispatch.error`,ir(e)),t.onError?.(e.message||e.error||`Unknown error`);break;default:console.warn(`Unknown event type:`,e)}}async stopGeneration(e){await z.post(`stop/${e}`)}async deleteSession(e){let t=encodeURIComponent(e);await z.delete(`sessions/${t}`)}async getHistory(e,t){P(`[AgentClient]`,`history.request`,{sessionId:e,sinceMessageId:t});let n=t?`history/${e}?since_message_id=${encodeURIComponent(t)}`:`history/${e}`,r=await z.get(n);return P(`[AgentClient]`,`history.response`,tr(r)),r}async healthCheck(){try{return await z.get(`health`),!0}catch{return!1}}},or=ar.getInstance(),sr=new class{async reloadConfig(){return z.post(`/bamboo/settings/reload`)}async getPermissionAskRules(){return(await z.get(`/bamboo/permission/ask-rules`)).rules}async updatePermissionAskRules(e){return(await z.put(`/bamboo/permission/ask-rules`,{rules:e})).rules}async getCopilotAuthStatus(){return z.post(`/bamboo/copilot/auth/status`)}async startCopilotAuth(){return z.post(`/bamboo/copilot/auth/start`)}async completeCopilotAuth(e){return z.post(`/bamboo/copilot/auth/complete`,e)}async authenticateCopilot(){return z.post(`/bamboo/copilot/authenticate`)}async logoutCopilot(){return z.post(`/bamboo/copilot/logout`)}async getProviderCatalog(){return z.get(`/bamboo/provider-catalog`)}async fetchCatalogModels(e){let t=e?{provider:e}:{};return z.post(`/bamboo/provider-catalog/fetch-models`,t)}async getProviderInstances(){return z.get(`/bamboo/settings/provider-instances`)}async createProviderInstance(e){return z.post(`/bamboo/settings/provider-instances`,e)}async updateProviderInstance(e,t){return z.put(`/bamboo/settings/provider-instances/${encodeURIComponent(e)}`,t)}async deleteProviderInstance(e){return z.delete(`/bamboo/settings/provider-instances/${encodeURIComponent(e)}`)}async getEnvVars(){return z.get(`/bamboo/env-vars`)}async upsertEnvVar(e){return z.post(`/bamboo/env-vars`,e)}async deleteEnvVar(e){return z.delete(`/bamboo/env-vars/${encodeURIComponent(e)}`)}async replaceEnvVars(e){return z.post(`/bamboo/env-vars/replace`,{entries:e})}async listNodes(){return z.get(`/bamboo/settings/nodes`)}async createNode(e){return z.post(`/bamboo/settings/nodes`,e)}async updateNode(e,t){return z.put(`/bamboo/settings/nodes/${encodeURIComponent(e)}`,t)}async deleteNode(e){await z.delete(`/bamboo/settings/nodes/${encodeURIComponent(e)}`)}async createCluster(e){return z.post(`/bamboo/settings/clusters`,e)}async updateCluster(e,t){return z.put(`/bamboo/settings/clusters/${encodeURIComponent(e)}`,t)}async deleteCluster(e){return z.delete(`/bamboo/settings/clusters/${encodeURIComponent(e)}`)}async nodeAction(e,t){return z.post(`/bamboo/settings/nodes/${encodeURIComponent(e)}/${t}`,{})}async nodeStatus(e){return z.get(`/bamboo/settings/nodes/${encodeURIComponent(e)}/status`)}async nodeLogs(e,t=200){return z.get(`/bamboo/settings/nodes/${encodeURIComponent(e)}/logs?lines=${t}`)}},cr=[`chat`,`fast`,`task_summary`,`vision`,`memory_background`,`planning`,`search`,`code_review`,`sub_agent`],lr=[`copilot`,`openai`,`anthropic`,`gemini`,`bodhi`],q={copilot:`GitHub Copilot`,openai:`OpenAI`,anthropic:`Anthropic`,gemini:`Google Gemini`,bodhi:`Bodhi`},ur=class extends Error{constructor(e){super(e),this.name=`ProviderSnapshotValidationError`}},dr=e=>typeof e==`object`&&!!e&&!Array.isArray(e),fr=e=>dr(e)&&typeof e.provider==`string`&&e.provider.trim().length>0&&typeof e.model==`string`&&e.model.trim().length>0,pr=(e,t=`Provider instance`)=>{if(!dr(e)||typeof e.id!=`string`||e.id.trim().length===0||!lr.includes(e.type)||typeof e.label!=`string`||typeof e.enabled!=`boolean`||!dr(e.config))throw new ur(`${t} is invalid`);return e},mr=e=>{if(e===void 0)return;if(!dr(e)||!fr(e.chat))throw new ur(`Provider defaults must contain a valid chat model reference`);for(let t of cr){let n=e[t];if(n!==void 0&&!fr(n))throw new ur(`Provider defaults.${t} is invalid`)}let t=e.subagent_models;if(t!==void 0){if(!dr(t))throw new ur(`Provider defaults.subagent_models is invalid`);for(let e of Object.values(t))if(!fr(e))throw new ur(`Provider defaults.subagent_models contains an invalid reference`)}return e},hr=e=>{if(!dr(e)||!Array.isArray(e.instances))throw new ur(`Provider instances payload is invalid`);let t=e.instances.map((e,t)=>pr(e,`Provider instance at index ${t}`));if(new Set(t.map(e=>e.id)).size!==t.length)throw new ur(`Provider instance ids must be unique`);let n=e.default_provider_instance_id;if(n!=null&&typeof n!=`string`||typeof n==`string`&&n.trim().length===0)throw new ur(`Provider compatibility route id is invalid`);let r=typeof n==`string`?n:null,i;if(e.features!==void 0){if(!dr(e.features)||e.features.provider_model_ref!==void 0&&typeof e.features.provider_model_ref!=`boolean`)throw new ur(`Provider features payload is invalid`);i=e.features}return{default_provider_instance_id:r,instances:t,defaults:mr(e.defaults),features:i}},gr=e=>{let t=new Set(e.instances.map(e=>e.id)),n=[],r=e.default_provider_instance_id;r&&!t.has(r)&&n.push({kind:`default_provider_instance`,path:`default_provider_instance_id`,provider:r});for(let r of cr){let i=e.defaults?.[r];i&&!t.has(i.provider)&&n.push({kind:`default_model_ref`,path:`defaults.${r}`,provider:i.provider,role:r})}for(let[r,i]of Object.entries(e.defaults?.subagent_models??{}))t.has(i.provider)||n.push({kind:`subagent_model_ref`,path:`defaults.subagent_models.${r}`,provider:i.provider,subagent:r});return n},_r=e=>typeof e==`object`&&!!e&&!Array.isArray(e),vr=e=>!_r(e)||!_r(e.reference)||!_r(e.capabilities)?!1:typeof e.reference.provider==`string`&&e.reference.provider.trim().length>0&&typeof e.reference.model==`string`&&e.reference.model.trim().length>0&&typeof e.display_name==`string`&&typeof e.provider_display_name==`string`&&typeof e.capabilities.supports_tools==`boolean`&&typeof e.capabilities.supports_vision==`boolean`&&typeof e.capabilities.supports_reasoning==`boolean`,yr=e=>{if(e===void 0)return[];if(!Array.isArray(e)||!e.every(vr))throw Error(`Provider model refresh returned invalid models`);return e},br=()=>Error(`Provider model discovery failed`),xr=(e,t)=>!e?.models||!t.trim()?[]:e.models.filter(e=>e.reference.provider===t),Sr=0,Cr=0,wr=null,Tr=e=>Error(`Failed to ${e} provider instance`),Er=se((e,t)=>{let n=async(e,n)=>{try{await n()}catch{throw Tr(e)}return t().loadProviderInstances()};return{providerSnapshot:null,providerRepairSnapshot:null,providerRepairIssues:[],providerStatus:`idle`,providerError:null,catalog:null,isCatalogFetching:!1,loadProviderInstances:async()=>{let t=++Sr;e({providerSnapshot:null,providerRepairSnapshot:null,providerRepairIssues:[],providerStatus:`loading`,providerError:null});try{let n=hr(await sr.getProviderInstances()),r=gr(n);if(t===Sr){let t=r.length>0;e({providerSnapshot:t?null:n,providerRepairSnapshot:t?n:null,providerRepairIssues:r,providerStatus:t?`degraded`:`ready`,providerError:t?`Provider routing or model preferences contain ${r.length} unknown instance reference${r.length===1?``:`s`}`:null})}return n}catch(n){let r=n instanceof ur,i=r?n.message:`Provider settings are unavailable`;throw t===Sr&&e({providerSnapshot:null,providerRepairSnapshot:null,providerRepairIssues:[],providerStatus:r?`incompatible`:`unavailable`,providerError:i}),r?n:Error(i)}},createProviderInstance:async e=>{let n;try{n=await sr.createProviderInstance(e)}catch{throw Tr(`create`)}let r=null;try{r=pr(n,`Created provider instance`)}catch{}try{let e=await t().loadProviderInstances(),n=r!==null&&e.instances.some(e=>e.id===r.id);return{instance:r,responseValid:r!==null,authorityRefreshed:!0,instanceConfirmed:n}}catch{return{instance:r,responseValid:r!==null,authorityRefreshed:!1,instanceConfirmed:!1}}},updateProviderInstance:(e,t)=>n(`update`,()=>sr.updateProviderInstance(e,t)),deleteProviderInstance:e=>n(`delete`,()=>sr.deleteProviderInstance(e)),loadCatalog:()=>{if(wr)return wr;let t=++Cr,n;return n=Promise.resolve().then(()=>sr.getProviderCatalog()).then(n=>{t===Cr&&e({catalog:n})}).catch(()=>{}).finally(()=>{wr===n&&(wr=null)}),wr=n,n},fetchCatalogModels:async t=>{e({isCatalogFetching:!0});try{let n=await sr.fetchCatalogModels(t);if(!Array.isArray(n.fetched))throw Error(`Provider model refresh returned an invalid response`);if(t){let r=n.fetched.find(e=>_r(e)&&e.provider===t);if(!r||r.error!==void 0&&typeof r.error!=`string`||r.error?.trim())throw br();let i=yr(r.models).filter(e=>e.reference.provider===t);return++Cr,e(e=>({catalog:{providers:e.catalog?.providers??[],models:[...(e.catalog?.models??[]).filter(e=>e.reference.provider!==t),...i],updated_at:e.catalog?.updated_at}})),n}let r=n.fetched.filter(e=>_r(e)&&typeof e.provider==`string`&&(e.error===void 0||typeof e.error==`string`)&&!e.error?.trim()),i=new Set(r.map(e=>e.provider)),a=r.flatMap(e=>yr(e.models).filter(t=>t.reference.provider===e.provider));return++Cr,e(e=>({catalog:{providers:e.catalog?.providers??[],models:[...(e.catalog?.models??[]).filter(e=>!i.has(e.reference.provider)),...a],updated_at:e.catalog?.updated_at}})),n}catch{throw br()}finally{e({isCatalogFetching:!1})}},getActiveModel:()=>{if(t().providerStatus===`ready`)return t().providerSnapshot?.defaults?.chat.model.trim()||void 0},getFastModel:()=>{if(t().providerStatus===`ready`)return t().providerSnapshot?.defaults?.fast?.model.trim()||t().getActiveModel()},getVisionModel:()=>{if(t().providerStatus===`ready`)return t().providerSnapshot?.defaults?.vision?.model.trim()||t().getActiveModel()},isProviderModelRefEnabled:()=>t().providerStatus===`ready`&&t().providerSnapshot?.features?.provider_model_ref===!0,getFastModelRef:()=>{if(t().providerStatus!==`ready`)return null;let e=t().providerSnapshot?.defaults;return e?.fast?.model.trim()?e.fast:e?.chat.model.trim()?e.chat:null},getVisionModelRef:()=>{if(t().providerStatus!==`ready`)return null;let e=t().providerSnapshot?.defaults;return e?.vision?.model.trim()?e.vision:e?.chat.model.trim()?e.chat:null},getModelsForProvider:e=>xr(t().catalog,e),getProviderInstance:e=>t().providerSnapshot?.instances.find(t=>t.id===e),getProviderDisplayLabel:e=>{let n=(t().providerSnapshot??t().providerRepairSnapshot)?.instances.find(t=>t.id===e);return n?.label||n?.type||e},getProviderType:e=>t().providerSnapshot?.instances.find(t=>t.id===e)?.type}});function Dr(e){return e.type===`session_title_updated`||e.type===`session_pinned_updated`}function Or(e,t){switch(e.type){case`session_title_updated`:typeof e.session_id==`string`&&typeof e.title==`string`&&typeof e.title_version==`number`&&t.applyServerTitle(e.session_id,e.title,e.title_version);break;case`session_pinned_updated`:typeof e.session_id==`string`&&typeof e.pinned==`boolean`&&typeof e.updated_at==`string`&&t.applyServerPinned(e.session_id,e.pinned,e.updated_at);break}}function kr(e,t){let n=t.findIndex(t=>t.id===e.session_id);if(!(n<0))switch(e.type){case`session_title_updated`:{if(typeof e.title!=`string`||typeof e.title_version!=`number`)return;let r=e.title_version;if(r<=(t[n].titleVersion??0))return;t[n]={...t[n],title:e.title,titleVersion:r};return}case`session_pinned_updated`:if(typeof e.pinned!=`boolean`||typeof e.updated_at!=`string`||new Date(e.updated_at).getTime()<new Date(t[n].updatedAt??0).getTime()||t[n].pinned===e.pinned)return;t[n]={...t[n],pinned:e.pinned,updatedAt:e.updated_at};return}}var Ar=e=>e!==void 0&&e!==`idle`&&e!==`completed`&&e!==`error`&&e!==`cancelled`,jr=e=>({sessionId:e,phase:`idle`,confidence:`optimistic`,activeReasons:[],generation:0,backendRunId:null,stream:{hasTokens:!1,tokenCount:0,activeToolCalls:[],lastStatusHint:null},backend:{isRunning:!1,lastRunStatus:null,lastRunError:null,syncedAt:null,hasPendingQuestion:null,runningChildCount:null},interaction:{pendingQuestion:null,respondMode:null,pendingChildApproval:null},children:{byId:{},runningCount:0},timestamps:{optimisticAt:null,confirmedAt:null,firstTokenAt:null,terminalAt:null,settlingStartedAt:null,settledAt:null},error:null}),Mr=(e,t)=>e[t]??jr(t),J=(e,t)=>[...e.length>=16?e.slice(-15):e,t],Nr=e=>e.length<=80?e:e.slice(e.length-80),Pr=(e,t)=>e.length===t.length&&e.every((e,n)=>e===t[n]),Fr=(e,t)=>e?e.question===t.question&&e.allowCustom===t.allowCustom&&e.toolCallId===t.toolCallId&&Pr(e.options,t.options):!1,Ir=(e,t,n)=>{let r=Fr(e.interaction.pendingQuestion,t)?e.interaction.pendingQuestion:{...t,receivedAt:n};return e.phase===`waiting_user_answer`&&e.confidence===`live`&&r===e.interaction.pendingQuestion?e:{...e,phase:`waiting_user_answer`,confidence:`live`,interaction:{...e.interaction,pendingQuestion:r,respondMode:null},activeReasons:J(e.activeReasons,`sse:need_clarification`)}},Lr=(e,t)=>e?e.childSessionId===t.childSessionId&&e.requestId===t.requestId&&e.toolName===t.toolName&&e.permission===t.permission&&e.resource===t.resource:!1,Rr=(e,t,n)=>Lr(e.interaction.pendingChildApproval,t)?e:{...e,interaction:{...e.interaction,pendingChildApproval:{...t,receivedAt:n}}},zr=new Set([`idle`,`completed`,`error`,`cancelled`,`settling`,`waiting_user_answer`]),Br=e=>zr.has(e.phase)?e:e.children.runningCount>0?e.phase===`running_children`?e:{...e,phase:`running_children`}:e.stream.activeToolCalls.length>0?e.phase===`running_tools`?e:{...e,phase:`running_tools`}:e.stream.hasTokens?e.phase===`streaming`?e:{...e,phase:`streaming`}:e.phase===`running`?e:{...e,phase:`running`},Y=(e,t,n)=>({...e,[t]:n}),Vr=(e,t)=>{if(!(t in e))return e;let n={...e};return delete n[t],n},Hr=(e,t,n)=>{let r=e.timestamps.firstTokenAt??n();return Br({...e,confidence:`live`,stream:{...e.stream,hasTokens:!0,tokenCount:e.stream.tokenCount+1},timestamps:{...e.timestamps,firstTokenAt:r},activeReasons:J(e.activeReasons,t)})},Ur=(e,t)=>{if(e.stream.hasTokens&&e.timestamps.firstTokenAt!==null)return e;let n=e.timestamps.firstTokenAt??t();return Br({...e,confidence:`live`,stream:{...e.stream,hasTokens:!0,tokenCount:Math.max(1,e.stream.tokenCount)},timestamps:{...e.timestamps,firstTokenAt:n},activeReasons:J(e.activeReasons,`sse:token`)})},Wr=(e,t,n,r)=>{let i=e.stream.activeToolCalls.findIndex(e=>e.toolCallId===t)>=0?e.stream.activeToolCalls:[...e.stream.activeToolCalls,{toolCallId:t,toolName:n,startedAt:r}];return Br({...e,confidence:`live`,stream:{...e.stream,activeToolCalls:i},activeReasons:J(e.activeReasons,`sse:tool_start`)})},Gr=(e,t,n)=>{let r=e.stream.activeToolCalls.findIndex(e=>e.toolCallId===t);if(r<0)return e;let i=e.stream.activeToolCalls[r],a=Nr((i.preview??``)+n),o={...i,preview:a},s=[...e.stream.activeToolCalls];return s[r]=o,{...e,stream:{...e.stream,activeToolCalls:s}}},Kr=(e,t,n)=>{let r=e.stream.activeToolCalls.filter(e=>e.toolCallId!==t);if(r.length===e.stream.activeToolCalls.length)return e;let i={...e,stream:{...e.stream,activeToolCalls:r},activeReasons:J(e.activeReasons,n)};return i.timestamps.terminalAt&&i.children.runningCount===0&&i.stream.activeToolCalls.length===0&&!zr.has(i.phase)?{...i,phase:`settling`,timestamps:{...i.timestamps,settlingStartedAt:i.timestamps.settlingStartedAt??i.timestamps.terminalAt}}:Br(i)},qr=(e,t,n)=>{let r=e.children.byId[t],i=r!==void 0&&(r.status===void 0||r.status===`running`),a={...r,...n,status:n.status??r?.status??`running`},o=(a.status===void 0||a.status===`running`)-+!!i;return Br({...e,confidence:`live`,children:{byId:{...e.children.byId,[t]:a},runningCount:Math.max(0,e.children.runningCount+o)},activeReasons:J(e.activeReasons,`sse:sub_agent_started`)})},Jr=(e,t,n)=>{let r=e.children.byId[t],i=r===void 0||r.status===void 0||r.status===`running`,a={...r,...n};if(r!==void 0&&r.title===a.title&&r.status===a.status&&r.error===a.error&&r.lastHeartbeatAt===a.lastHeartbeatAt&&r.lastEventAt===a.lastEventAt&&r.outputPreview===a.outputPreview&&r.roundCount===a.roundCount)return e;let o=a.status===void 0||a.status===`running`,s=0;r!==void 0&&(s=!!o-+!!i);let c=Math.max(0,e.children.runningCount+s),l={...e,children:{byId:{...e.children.byId,[t]:a},runningCount:c}};return l.timestamps.terminalAt&&l.children.runningCount===0&&l.stream.activeToolCalls.length===0&&!zr.has(l.phase)?{...l,phase:`settling`,timestamps:{...l.timestamps,settlingStartedAt:l.timestamps.settlingStartedAt??l.timestamps.terminalAt},activeReasons:J(l.activeReasons,`sse:sub_agent_completed`)}:Br(l)},Yr=(e,t)=>{if(!(t in e.children.byId))return e;let n=e.children.byId[t],r=n.status===void 0||n.status===`running`,i={...e.children.byId};delete i[t];let a={...e,children:{byId:i,runningCount:Math.max(0,e.children.runningCount-+!!r)}};return a.timestamps.terminalAt&&a.children.runningCount===0&&a.stream.activeToolCalls.length===0&&!zr.has(a.phase)?{...a,phase:`settling`,timestamps:{...a.timestamps,settlingStartedAt:a.timestamps.settlingStartedAt??a.timestamps.terminalAt}}:Br(a)},Xr=(e,t,n)=>{switch(t.type){case`token`:return Hr(e,`sse:token`,n);case`reasoning_token`:return Hr(e,`sse:token`,n);case`tool_start`:{let r=t.tool_call_id??``,i=t.tool_name??``;return r?Wr(e,r,i,n()):e}case`tool_token`:{let n=t.tool_call_id??``;return n?Gr(e,n,t.content??``):e}case`tool_complete`:case`tool_error`:{let n=t.tool_call_id??``;return n?Kr(e,n,`sse:tool_complete`):e}case`tool_lifecycle`:return e;case`sub_agent_started`:{let n=t.child_session_id??``;return n?qr(e,n,{title:t.title,status:`running`}):e}case`sub_agent_event`:case`sub_agent_heartbeat`:{let r=t.child_session_id??``;if(!r)return e;let i={lastEventAt:t.timestamp??n()};return t.type===`sub_agent_heartbeat`&&(i.lastHeartbeatAt=t.timestamp??n()),Jr(e,r,i)}case`sub_agent_completed`:{let n=t.child_session_id??``;return n?Jr(e,n,{status:typeof t.status==`string`?t.status:`completed`,error:t.error}):e}case`need_clarification`:return Ir(e,{question:t.question??``,options:t.options??[],allowCustom:t.allow_custom??!1,toolCallId:t.tool_call_id??null},n());case`execution_started`:{let r=t.run_id;return r?e.phase!==`starting`&&e.phase!==`settling`?{...e,backendRunId:r,confidence:`live`,activeReasons:J(e.activeReasons,`sse:execution_started`)}:{...e,phase:`running`,confidence:`live`,backendRunId:r,timestamps:{...e.timestamps,confirmedAt:n()},activeReasons:J(e.activeReasons,`sse:execution_started`)}:e}case`complete`:{if(zr.has(e.phase))return e;let t=n();return{...e,phase:`settling`,timestamps:{...e.timestamps,terminalAt:t,settlingStartedAt:e.timestamps.settlingStartedAt??t},activeReasons:J(e.activeReasons,`sse:complete`)}}case`cancelled`:{let r=n();return{...e,phase:`cancelled`,confidence:`terminal`,timestamps:{...e.timestamps,terminalAt:r,settledAt:r},error:t.message?{message:t.message,source:`user_cancel`,occurredAt:r}:null,activeReasons:J(e.activeReasons,`sse:error`)}}case`error`:{let r=n();return{...e,phase:`error`,confidence:`terminal`,timestamps:{...e.timestamps,terminalAt:r},error:{message:t.message??t.error??`Unknown error`,source:`sse`,occurredAt:r},activeReasons:J(e.activeReasons,`sse:error`)}}case`task_list_updated`:case`task_list_item_progress`:case`task_list_completed`:case`task_evaluation_started`:case`task_evaluation_completed`:case`token_budget_updated`:case`context_compression_status`:case`context_summarized`:case`context_pressure_notification`:return e;default:return e}},Zr=e=>e===`completed`||e===`error`||e===`cancelled`,Qr=(e,t,n)=>{let r=t.last_run_status,i=Zr(r)?r:null,a=n(),o=t.has_pending_question===void 0?null:t.has_pending_question,s=t.running_child_count===void 0?null:t.running_child_count,c={...e,backend:{...e.backend,isRunning:t.is_running,lastRunStatus:i,lastRunError:t.last_run_error??null,syncedAt:a,hasPendingQuestion:o,runningChildCount:s},backendRunId:e.backendRunId};if(t.is_running)return e.phase===`idle`||e.phase===`completed`||e.phase===`error`||e.phase===`cancelled`?{...c,phase:`running`,confidence:`summary`,activeReasons:J(c.activeReasons,`summary:is_running`)}:e.phase===`starting`?{...c,phase:`running`,confidence:`summary`,timestamps:{...c.timestamps,confirmedAt:a},activeReasons:J(c.activeReasons,`summary:is_running`)}:c;if(t.id,e.phase,e.generation,e.backendRunId,t.is_running,e.timestamps.optimisticAt,new Set([`starting`,`running`,`streaming`,`running_tools`,`running_children`,`settling`]).has(e.phase)){if(i===`completed`)return t.id,e.phase,e.generation,e.backendRunId,{...c,phase:`completed`,confidence:`terminal`,timestamps:{...c.timestamps,settledAt:a},activeReasons:J(c.activeReasons,`summary:terminal`)};if(i===`error`)return t.id,e.phase,e.generation,e.backendRunId,{...c,phase:`error`,confidence:`terminal`,timestamps:{...c.timestamps,settledAt:a},error:{message:t.last_run_error??`Backend reported error`,source:`summary`,occurredAt:a},activeReasons:J(c.activeReasons,`summary:terminal`)};if(i===`cancelled`)return t.id,e.phase,e.generation,e.backendRunId,{...c,phase:`cancelled`,confidence:`terminal`,timestamps:{...c.timestamps,settledAt:a},activeReasons:J(c.activeReasons,`summary:terminal`)};if(e.timestamps.optimisticAt){let n=Date.parse(a)-Date.parse(e.timestamps.optimisticAt);if(Number.isFinite(n)&&n<5e3)return t.id,e.phase,e.generation,e.backendRunId,c}return t.id,e.phase,e.generation,e.backendRunId,{...c,phase:`idle`,confidence:`summary`,activeReasons:J(c.activeReasons,`summary:terminal`)}}return c},$r=()=>new Date().toISOString(),ei=(e,t,n=$r)=>{switch(t.type){case`ensureSession`:return t.sessionId in e?e:Y(e,t.sessionId,jr(t.sessionId));case`markOptimisticStart`:{let r=Mr(e,t.sessionId),i=n(),a={...r,phase:`starting`,confidence:`optimistic`,generation:r.generation+1,stream:{hasTokens:!1,tokenCount:0,activeToolCalls:[],lastStatusHint:null},interaction:{...r.interaction,respondMode:null},error:null,timestamps:{optimisticAt:i,confirmedAt:null,firstTokenAt:null,terminalAt:null,settlingStartedAt:null,settledAt:null},activeReasons:J(r.activeReasons,`optimistic:send`)};return Y(e,t.sessionId,a)}case`markRespondStart`:{let r=Mr(e,t.sessionId),i=n(),a={...r,phase:`starting`,confidence:`optimistic`,generation:r.generation+1,stream:{hasTokens:!1,tokenCount:0,activeToolCalls:[],lastStatusHint:null},interaction:{...r.interaction,pendingQuestion:null,respondMode:null},error:null,timestamps:{...r.timestamps,optimisticAt:i,confirmedAt:null,firstTokenAt:null,terminalAt:null,settlingStartedAt:null,settledAt:null},activeReasons:J(r.activeReasons,`optimistic:respond`)};return Y(e,t.sessionId,a)}case`markRetryStart`:{let r=Mr(e,t.sessionId),i=n(),a={...r,phase:`starting`,confidence:`optimistic`,generation:r.generation+1,stream:{hasTokens:!1,tokenCount:0,activeToolCalls:[],lastStatusHint:null},error:null,timestamps:{...r.timestamps,optimisticAt:i,confirmedAt:null,firstTokenAt:null,terminalAt:null,settlingStartedAt:null,settledAt:null},activeReasons:J(r.activeReasons,`optimistic:retry`)};return Y(e,t.sessionId,a)}case`markForceSubscribe`:{let n=Mr(e,t.sessionId);if(Ar(n.phase))return e;let r={...n,phase:`running`,confidence:`optimistic`,generation:n.generation+1,error:null,activeReasons:J(n.activeReasons,`optimistic:openSession.forceSubscribe`)};return Y(e,t.sessionId,r)}case`markCancel`:{let r=Mr(e,t.sessionId),i=n(),a={...r,phase:`cancelled`,confidence:`terminal`,timestamps:{...r.timestamps,settledAt:i},activeReasons:J(r.activeReasons,`user:cancel`)};return Y(e,t.sessionId,a)}case`markSettleTimeout`:{let r=Mr(e,t.sessionId);if(r.phase!==`starting`&&r.phase!==`settling`)return e;let i={...r,phase:`idle`,confidence:`optimistic`,timestamps:{...r.timestamps,settledAt:n()},activeReasons:J(r.activeReasons,`settle:timeout`)};return Y(e,t.sessionId,i)}case`markStreamStarted`:{let r=Mr(e,t.sessionId);if(t.generation!==r.generation)return e;let i=Ur(r,n);return i===r?e:Y(e,t.sessionId,i)}case`applyAgentEvent`:{let r=Mr(e,t.sessionId);if(t.generation!==r.generation)return t.sessionId,t.generation,r.generation,t.event.type,r.phase,r.backendRunId,e;let i=Xr(r,t.event,n);return i===r?e:Y(e,t.sessionId,i)}case`applyExecutionStarted`:{let r=Mr(e,t.sessionId);if(t.generation!==r.generation)return t.sessionId,t.generation,r.generation,t.runId,r.phase,r.backendRunId,e;if(r.phase!==`starting`&&r.phase!==`settling`)return Y(e,t.sessionId,{...r,backendRunId:t.runId,confidence:`live`,activeReasons:J(r.activeReasons,`sse:execution_started`)});let i={...r,phase:`running`,confidence:`live`,backendRunId:t.runId,timestamps:{...r.timestamps,confirmedAt:n()},activeReasons:J(r.activeReasons,`sse:execution_started`)};return Y(e,t.sessionId,i)}case`applySessionSummary`:{let r=Mr(e,t.sessionId),i=Qr(r,t.summary,n);return i===r?e:Y(e,t.sessionId,i)}case`applyOneShotTerminal`:{let r=Mr(e,t.sessionId);if(t.generation!==r.generation||r.phase!==`idle`&&r.phase!==`starting`)return e;let i=n();return t.payload.status===`completed`?Y(e,t.sessionId,{...r,phase:`completed`,confidence:`terminal`,timestamps:{...r.timestamps,terminalAt:i,settledAt:i},activeReasons:J(r.activeReasons,`sse:terminal_one_shot`)}):t.payload.status===`cancelled`?Y(e,t.sessionId,{...r,phase:`cancelled`,confidence:`terminal`,timestamps:{...r.timestamps,terminalAt:i,settledAt:i},error:t.payload.message?{message:t.payload.message,source:`user_cancel`,occurredAt:i}:null,activeReasons:J(r.activeReasons,`sse:terminal_one_shot`)}):Y(e,t.sessionId,{...r,phase:`error`,confidence:`terminal`,timestamps:{...r.timestamps,terminalAt:i,settledAt:i},error:{message:t.payload.message??`Unknown error`,source:`sse`,occurredAt:i},activeReasons:J(r.activeReasons,`sse:terminal_one_shot`)})}case`beginSettle`:{let r=Mr(e,t.sessionId);if(t.generation!==r.generation||r.phase!==`running`&&r.phase!==`streaming`&&r.phase!==`running_tools`&&r.phase!==`running_children`)return e;let i=n();return Y(e,t.sessionId,{...r,phase:`settling`,timestamps:{...r.timestamps,settlingStartedAt:i,terminalAt:r.timestamps.terminalAt??i}})}case`applyChildProgress`:{let n=Mr(e,t.sessionId),r=t.childId in n.children.byId?Jr(n,t.childId,t.patch):qr(n,t.childId,t.patch);return r===n?e:Y(e,t.sessionId,r)}case`clearChildProgress`:{let n=Mr(e,t.sessionId),r=Yr(n,t.childId);return r===n?e:Y(e,t.sessionId,r)}case`setPendingQuestion`:{let r=Mr(e,t.sessionId),i=Ir(r,t.payload,n());return i===r?e:Y(e,t.sessionId,i)}case`clearPendingQuestion`:{let n=Mr(e,t.sessionId);if(n.interaction.pendingQuestion===null&&n.interaction.respondMode===null)return e;let r={...n,interaction:{...n.interaction,pendingQuestion:null,respondMode:null}};return Y(e,t.sessionId,r)}case`setPendingChildApproval`:{let r=Mr(e,t.sessionId),i=Rr(r,t.payload,n());return i===r?e:Y(e,t.sessionId,i)}case`clearPendingChildApproval`:{let n=Mr(e,t.sessionId);if(n.interaction.pendingChildApproval===null)return e;let r={...n,interaction:{...n.interaction,pendingChildApproval:null}};return Y(e,t.sessionId,r)}case`resetSession`:return Vr(e,t.sessionId);case`applyRunningSnapshot`:{let r=e;for(let e of t.sessions){let t=Mr(r,e.sessionId),i=t.generation+1,a={...t,generation:i,backendRunId:e.runId,phase:`running`,confidence:`live`,timestamps:{...t.timestamps,confirmedAt:n()},activeReasons:J(t.activeReasons,`sse:execution_started`)};for(let t of e.criticalEvents)t.type!==`execution_started`&&(a=Xr(a,t,n));r=Y(r,e.sessionId,a)}return r}default:return e}},ti=()=>new Date().toISOString(),ni=(e,t)=>{e(e=>{let n=ei(e.executionBySession,t,ti);return n===e.executionBySession?e:{executionBySession:n}})},ri=(e,t)=>({executionBySession:{},ensureSession:t=>ni(e,{type:`ensureSession`,sessionId:t}),markOptimisticStart:n=>{let r=t().executionBySession[n],i=r?r.generation+1:1;return ni(e,{type:`markOptimisticStart`,sessionId:n}),i},markRespondStart:(n,r)=>{let i=t().executionBySession[n],a=i?i.generation+1:1;return ni(e,{type:`markRespondStart`,sessionId:n,toolCallId:r}),a},markRetryStart:n=>{let r=t().executionBySession[n],i=r?r.generation+1:1;return ni(e,{type:`markRetryStart`,sessionId:n}),i},markForceSubscribe:t=>ni(e,{type:`markForceSubscribe`,sessionId:t}),markCancel:t=>ni(e,{type:`markCancel`,sessionId:t}),markSettleTimeout:t=>ni(e,{type:`markSettleTimeout`,sessionId:t}),markStreamStarted:(t,n)=>ni(e,{type:`markStreamStarted`,sessionId:t,generation:n}),applyAgentEvent:(t,n,r)=>ni(e,{type:`applyAgentEvent`,sessionId:t,event:n,generation:r}),applyExecutionStarted:(t,n,r)=>ni(e,{type:`applyExecutionStarted`,sessionId:t,runId:n,generation:r}),applySessionSummary:(t,n)=>ni(e,{type:`applySessionSummary`,sessionId:t,summary:n}),applyOneShotTerminal:(t,n,r)=>ni(e,{type:`applyOneShotTerminal`,sessionId:t,generation:n,payload:r}),beginSettle:(t,n)=>ni(e,{type:`beginSettle`,sessionId:t,generation:n}),applyChildProgress:(t,n,r)=>ni(e,{type:`applyChildProgress`,sessionId:t,childId:n,patch:r}),clearChildProgress:(t,n)=>ni(e,{type:`clearChildProgress`,sessionId:t,childId:n}),setPendingQuestion:(t,n)=>ni(e,{type:`setPendingQuestion`,sessionId:t,payload:n}),clearPendingQuestion:t=>ni(e,{type:`clearPendingQuestion`,sessionId:t}),setPendingChildApproval:(t,n)=>ni(e,{type:`setPendingChildApproval`,sessionId:t,payload:n}),clearPendingChildApproval:t=>ni(e,{type:`clearPendingChildApproval`,sessionId:t}),resetSession:t=>ni(e,{type:`resetSession`,sessionId:t}),applyRunningSnapshot:n=>{let r=t();ni(e,{type:`applyRunningSnapshot`,sessions:n.map(e=>{let t=[];for(let n of e.criticalEvents){if(Dr(n)){Or(n,r);continue}t.push(n)}return{...e,criticalEvents:t}})})}}),X=e=>typeof e==`string`,ii=()=>{let e,t,n=new Promise((n,r)=>{e=n,t=r});return n.resolve=e,n.reject=t,n},ai=e=>e==null?``:String(e),oi=(e,t,n)=>{e.forEach(e=>{t[e]&&(n[e]=t[e])})},si=/###/g,ci=e=>e&&e.includes(`###`)?e.replace(si,`.`):e,li=e=>!e||X(e),ui=(e,t,n)=>{let r=X(t)?t.split(`.`):t,i=0;for(;i<r.length-1;){if(li(e))return{};let t=ci(r[i]);!e[t]&&n&&(e[t]=new n),e=Object.prototype.hasOwnProperty.call(e,t)?e[t]:{},++i}return li(e)?{}:{obj:e,k:ci(r[i])}},di=(e,t,n)=>{let{obj:r,k:i}=ui(e,t,Object);if(r!==void 0||t.length===1){r[i]=n;return}let a=t[t.length-1],o=t.slice(0,t.length-1),s=ui(e,o,Object);for(;s.obj===void 0&&o.length;)a=`${o[o.length-1]}.${a}`,o=o.slice(0,o.length-1),s=ui(e,o,Object),s?.obj&&s.obj[`${s.k}.${a}`]!==void 0&&(s.obj=void 0);s.obj[`${s.k}.${a}`]=n},fi=(e,t,n,r)=>{let{obj:i,k:a}=ui(e,t,Object);i[a]=i[a]||[],i[a].push(n)},pi=(e,t)=>{let{obj:n,k:r}=ui(e,t);if(n&&Object.prototype.hasOwnProperty.call(n,r))return n[r]},mi=(e,t,n)=>{let r=pi(e,n);return r===void 0?pi(t,n):r},hi=(e,t,n)=>{for(let r in t)r!==`__proto__`&&r!==`constructor`&&(r in e?X(e[r])||e[r]instanceof String||X(t[r])||t[r]instanceof String?n&&(e[r]=t[r]):hi(e[r],t[r],n):e[r]=t[r]);return e},gi=e=>e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,`\\$&`),_i={"&":`&`,"<":`<`,">":`>`,'"':`"`,"'":`'`,"/":`/`},vi=e=>X(e)?e.replace(/[&<>"'\/]/g,e=>_i[e]):e,yi=class{constructor(e){this.capacity=e,this.regExpMap=new Map,this.regExpQueue=[]}getRegExp(e){let t=this.regExpMap.get(e);if(t!==void 0)return t;let n=new RegExp(e);return this.regExpQueue.length===this.capacity&&this.regExpMap.delete(this.regExpQueue.shift()),this.regExpMap.set(e,n),this.regExpQueue.push(e),n}},bi=[` `,`,`,`?`,`!`,`;`],xi=new yi(20),Si=(e,t,n)=>{t||=``,n||=``;let r=bi.filter(e=>!t.includes(e)&&!n.includes(e));if(r.length===0)return!0;let i=xi.getRegExp(`(${r.map(e=>e===`?`?`\\?`:e).join(`|`)})`),a=!i.test(e);if(!a){let t=e.indexOf(n);t>0&&!i.test(e.substring(0,t))&&(a=!0)}return a},Ci=(e,t,n=`.`)=>{if(!e)return;if(e[t])return Object.prototype.hasOwnProperty.call(e,t)?e[t]:void 0;let r=t.split(n),i=e;for(let e=0;e<r.length;){if(!i||typeof i!=`object`)return;let t,a=``;for(let o=e;o<r.length;++o)if(o!==e&&(a+=n),a+=r[o],t=i[a],t!==void 0){if([`string`,`number`,`boolean`].includes(typeof t)&&o<r.length-1)continue;e+=o-e+1;break}i=t}return i},wi=e=>e?.replace(/_/g,`-`),Ti={type:`logger`,log(e){this.output(`log`,e)},warn(e){this.output(`warn`,e)},error(e){this.output(`error`,e)},output(e,t){console?.[e]?.apply?.(console,t)}},Ei=new class e{constructor(e,t={}){this.init(e,t)}init(e,t={}){this.prefix=t.prefix||`i18next:`,this.logger=e||Ti,this.options=t,this.debug=t.debug}log(...e){return this.forward(e,`log`,``,!0)}warn(...e){return this.forward(e,`warn`,``,!0)}error(...e){return this.forward(e,`error`,``)}deprecate(...e){return this.forward(e,`warn`,`WARNING DEPRECATED: `,!0)}forward(e,t,n,r){return r&&!this.debug?null:(e=e.map(e=>X(e)?e.replace(/[\r\n\x00-\x1F\x7F]/g,` `):e),X(e[0])&&(e[0]=`${n}${this.prefix} ${e[0]}`),this.logger[t](e))}create(t){return new e(this.logger,{prefix:`${this.prefix}:${t}:`,...this.options})}clone(t){return t||=this.options,t.prefix=t.prefix||this.prefix,new e(this.logger,t)}},Di=class{constructor(){this.observers={}}on(e,t){return e.split(` `).forEach(e=>{this.observers[e]||(this.observers[e]=new Map);let n=this.observers[e].get(t)||0;this.observers[e].set(t,n+1)}),this}off(e,t){if(this.observers[e]){if(!t){delete this.observers[e];return}this.observers[e].delete(t)}}once(e,t){let n=(...r)=>{t(...r),this.off(e,n)};return this.on(e,n),this}emit(e,...t){this.observers[e]&&Array.from(this.observers[e].entries()).forEach(([e,n])=>{for(let r=0;r<n;r++)e(...t)}),this.observers[`*`]&&Array.from(this.observers[`*`].entries()).forEach(([n,r])=>{for(let i=0;i<r;i++)n(e,...t)})}},Oi=class extends Di{constructor(e,t={ns:[`translation`],defaultNS:`translation`}){super(),this.data=e||{},this.options=t,this.options.keySeparator===void 0&&(this.options.keySeparator=`.`),this.options.ignoreJSONStructure===void 0&&(this.options.ignoreJSONStructure=!0)}addNamespaces(e){this.options.ns.includes(e)||this.options.ns.push(e)}removeNamespaces(e){let t=this.options.ns.indexOf(e);t>-1&&this.options.ns.splice(t,1)}getResource(e,t,n,r={}){let i=r.keySeparator===void 0?this.options.keySeparator:r.keySeparator,a=r.ignoreJSONStructure===void 0?this.options.ignoreJSONStructure:r.ignoreJSONStructure,o;e.includes(`.`)?o=e.split(`.`):(o=[e,t],n&&(Array.isArray(n)?o.push(...n):X(n)&&i?o.push(...n.split(i)):o.push(n)));let s=pi(this.data,o);return!s&&!t&&!n&&e.includes(`.`)&&(e=o[0],t=o[1],n=o.slice(2).join(`.`)),s||!a||!X(n)?s:Ci(this.data?.[e]?.[t],n,i)}addResource(e,t,n,r,i={silent:!1}){let a=i.keySeparator===void 0?this.options.keySeparator:i.keySeparator,o=[e,t];n&&(o=o.concat(a?n.split(a):n)),e.includes(`.`)&&(o=e.split(`.`),r=t,t=o[1]),this.addNamespaces(t),di(this.data,o,r),i.silent||this.emit(`added`,e,t,n,r)}addResources(e,t,n,r={silent:!1}){for(let r in n)(X(n[r])||Array.isArray(n[r]))&&this.addResource(e,t,r,n[r],{silent:!0});r.silent||this.emit(`added`,e,t,n)}addResourceBundle(e,t,n,r,i,a={silent:!1,skipCopy:!1}){let o=[e,t];e.includes(`.`)&&(o=e.split(`.`),r=n,n=t,t=o[1]),this.addNamespaces(t);let s=pi(this.data,o)||{};a.skipCopy||(n=JSON.parse(JSON.stringify(n))),r?hi(s,n,i):s={...s,...n},di(this.data,o,s),a.silent||this.emit(`added`,e,t,n)}removeResourceBundle(e,t){this.hasResourceBundle(e,t)&&delete this.data[e][t],this.removeNamespaces(t),this.emit(`removed`,e,t)}hasResourceBundle(e,t){return this.getResource(e,t)!==void 0}getResourceBundle(e,t){return t||=this.options.defaultNS,this.getResource(e,t)}getDataByLanguage(e){return this.data[e]}hasLanguageSomeTranslations(e){let t=this.getDataByLanguage(e);return!!(t&&Object.keys(t)||[]).find(e=>t[e]&&Object.keys(t[e]).length>0)}toJSON(){return this.data}},ki={processors:{},addPostProcessor(e){this.processors[e.name]=e},handle(e,t,n,r,i){return e.forEach(e=>{t=this.processors[e]?.process(t,n,r,i)??t}),t}},Ai=Symbol(`i18next/PATH_KEY`);function ji(){let e=[],t=Object.create(null),n;return t.get=(r,i)=>(n?.revoke?.(),i===Ai?e:(e.push(i),n=Proxy.revocable(r,t),n.proxy)),Proxy.revocable(Object.create(null),t).proxy}function Mi(e,t){let{[Ai]:n}=e(ji()),r=t?.keySeparator??`.`,i=t?.nsSeparator??`:`,a=t?.enableSelector===`strict`;if(n.length>1&&i){let e=t?.ns,o=a?Array.isArray(e)?e:e?[e]:null:Array.isArray(e)?e:null;if(o&&(a?o:o.length>1?o.slice(1):[]).includes(n[0]))return`${n[0]}${i}${n.slice(1).join(r)}`}return n.join(r)}var Ni=e=>!X(e)&&typeof e!=`boolean`&&typeof e!=`number`,Pi=class e extends Di{constructor(e,t={}){super(),oi([`resourceStore`,`languageUtils`,`pluralResolver`,`interpolator`,`backendConnector`,`i18nFormat`,`utils`],e,this),this.options=t,this.options.keySeparator===void 0&&(this.options.keySeparator=`.`),this.logger=Ei.create(`translator`),this.checkedLoadedFor={}}changeLanguage(e){e&&(this.language=e)}exists(e,t={interpolation:{}}){let n={...t};if(e==null)return!1;let r=this.resolve(e,n);if(r?.res===void 0)return!1;let i=Ni(r.res);return!(n.returnObjects===!1&&i)}extractFromKey(e,t){let n=t.nsSeparator===void 0?this.options.nsSeparator:t.nsSeparator;n===void 0&&(n=`:`);let r=t.keySeparator===void 0?this.options.keySeparator:t.keySeparator,i=t.ns||this.options.defaultNS||[],a=n&&e.includes(n),o=!this.options.userDefinedKeySeparator&&!t.keySeparator&&!this.options.userDefinedNsSeparator&&!t.nsSeparator&&!Si(e,n,r);if(a&&!o){let t=e.match(this.interpolator.nestingRegexp);if(t&&t.length>0)return{key:e,namespaces:X(i)?[i]:i};let a=e.split(n);(n!==r||n===r&&this.options.ns.includes(a[0]))&&(i=a.shift()),e=a.join(r)}return{key:e,namespaces:X(i)?[i]:i}}translate(t,n,r){let i=typeof n==`object`?{...n}:n;if(typeof i!=`object`&&this.options.overloadTranslationOptionHandler&&(i=this.options.overloadTranslationOptionHandler(arguments)),typeof i==`object`&&(i={...i}),i||={},t==null)return``;typeof t==`function`&&(t=Mi(t,{...this.options,...i})),Array.isArray(t)||(t=[String(t)]),t=t.map(e=>typeof e==`function`?Mi(e,{...this.options,...i}):String(e));let a=i.returnDetails===void 0?this.options.returnDetails:i.returnDetails,o=i.keySeparator===void 0?this.options.keySeparator:i.keySeparator,{key:s,namespaces:c}=this.extractFromKey(t[t.length-1],i),l=c[c.length-1],u=i.nsSeparator===void 0?this.options.nsSeparator:i.nsSeparator;u===void 0&&(u=`:`);let d=i.lng||this.language,f=i.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(d?.toLowerCase()===`cimode`)return f?a?{res:`${l}${u}${s}`,usedKey:s,exactUsedKey:s,usedLng:d,usedNS:l,usedParams:this.getUsedParamsDetails(i)}:`${l}${u}${s}`:a?{res:s,usedKey:s,exactUsedKey:s,usedLng:d,usedNS:l,usedParams:this.getUsedParamsDetails(i)}:s;let p=this.resolve(t,i),m=p?.res,h=p?.usedKey||s,g=p?.exactUsedKey||s,_=[`[object Number]`,`[object Function]`,`[object RegExp]`],v=i.joinArrays===void 0?this.options.joinArrays:i.joinArrays,y=!this.i18nFormat||this.i18nFormat.handleAsObject,b=i.count!==void 0&&!X(i.count),x=e.hasDefaultValue(i),S=b?this.pluralResolver.getSuffix(d,i.count,i):``,C=i.ordinal&&b?this.pluralResolver.getSuffix(d,i.count,{ordinal:!1}):``,w=b&&!i.ordinal&&i.count===0,T=w&&i[`defaultValue${this.options.pluralSeparator}zero`]||i[`defaultValue${S}`]||i[`defaultValue${C}`]||i.defaultValue,E=m;y&&!m&&x&&(E=T);let D=Ni(E),O=Object.prototype.toString.apply(E);if(y&&E&&D&&!_.includes(O)&&!(X(v)&&Array.isArray(E))){if(!i.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn(`accessing an object - but returnObjects options is not enabled!`);let e=this.options.returnedObjectHandler?this.options.returnedObjectHandler(h,E,{...i,ns:c}):`key '${s} (${this.language})' returned an object instead of string.`;return a?(p.res=e,p.usedParams=this.getUsedParamsDetails(i),p):e}if(o){let e=Array.isArray(E),t=e?[]:{},n=e?g:h;for(let e in E)if(Object.prototype.hasOwnProperty.call(E,e)){let r=`${n}${o}${e}`;x&&!m?t[e]=this.translate(r,{...i,defaultValue:Ni(T)?T[e]:void 0,joinArrays:!1,ns:c}):t[e]=this.translate(r,{...i,joinArrays:!1,ns:c}),t[e]===r&&(t[e]=E[e])}m=t}}else if(y&&X(v)&&Array.isArray(m))m=m.join(v),m&&=this.extendTranslation(m,t,i,r);else{let e=!1,n=!1;!this.isValidLookup(m)&&x&&(e=!0,m=T),this.isValidLookup(m)||(n=!0,m=s);let a=(i.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&n?void 0:m,c=x&&T!==m&&this.options.updateMissing;if(n||e||c){if(this.logger.log(c?`updateKey`:`missingKey`,d,l,b&&!c?`${s}${this.pluralResolver.getSuffix(d,i.count,i)}`:s,c?T:m),o){let e=this.resolve(s,{...i,keySeparator:!1});e&&e.res&&this.logger.warn(`Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.`)}let e=[],t=this.languageUtils.getFallbackCodes(this.options.fallbackLng,i.lng||this.language);if(this.options.saveMissingTo===`fallback`&&t&&t[0])for(let n=0;n<t.length;n++)e.push(t[n]);else this.options.saveMissingTo===`all`?e=this.languageUtils.toResolveHierarchy(i.lng||this.language):e.push(i.lng||this.language);let n=(e,t,n)=>{let r=x&&n!==m?n:a;this.options.missingKeyHandler?this.options.missingKeyHandler(e,l,t,r,c,i):this.backendConnector?.saveMissing&&this.backendConnector.saveMissing(e,l,t,r,c,i),this.emit(`missingKey`,e,l,t,m)};this.options.saveMissing&&(this.options.saveMissingPlurals&&b?e.forEach(e=>{let t=this.pluralResolver.getSuffixes(e,i);w&&i[`defaultValue${this.options.pluralSeparator}zero`]&&!t.includes(`${this.options.pluralSeparator}zero`)&&t.push(`${this.options.pluralSeparator}zero`),t.forEach(t=>{n([e],s+t,i[`defaultValue${t}`]||T)})}):n(e,s,T))}m=this.extendTranslation(m,t,i,p,r),n&&m===s&&this.options.appendNamespaceToMissingKey&&(m=`${l}${u}${s}`),(n||e)&&this.options.parseMissingKeyHandler&&(m=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${l}${u}${s}`:s,e?m:void 0,i))}return a?(p.res=m,p.usedParams=this.getUsedParamsDetails(i),p):m}extendTranslation(e,t,n,r,i){if(this.i18nFormat?.parse)e=this.i18nFormat.parse(e,{...this.options.interpolation.defaultVariables,...n},n.lng||this.language||r.usedLng,r.usedNS,r.usedKey,{resolved:r});else if(!n.skipInterpolation){n.interpolation&&this.interpolator.init({...n,interpolation:{...this.options.interpolation,...n.interpolation}});let a=X(e)&&(n?.interpolation?.skipOnVariables===void 0?this.options.interpolation.skipOnVariables:n.interpolation.skipOnVariables),o;if(a){let t=e.match(this.interpolator.nestingRegexp);o=t&&t.length}let s=n.replace&&!X(n.replace)?n.replace:n;if(this.options.interpolation.defaultVariables&&(s={...this.options.interpolation.defaultVariables,...s}),e=this.interpolator.interpolate(e,s,n.lng||this.language||r.usedLng,n),a){let t=e.match(this.interpolator.nestingRegexp),r=t&&t.length;o<r&&(n.nest=!1)}!n.lng&&r&&r.res&&(n.lng=this.language||r.usedLng),n.nest!==!1&&(e=this.interpolator.nest(e,(...e)=>i?.[0]===e[0]&&!n.context?(this.logger.warn(`It seems you are nesting recursively key: ${e[0]} in key: ${t[0]}`),null):this.translate(...e,t),n)),n.interpolation&&this.interpolator.reset()}let a=n.postProcess||this.options.postProcess,o=X(a)?[a]:a;return e!=null&&o?.length&&n.applyPostProcessor!==!1&&(e=ki.handle(o,e,t,this.options&&this.options.postProcessPassResolved?{i18nResolved:{...r,usedParams:this.getUsedParamsDetails(n)},...n}:n,this)),e}resolve(e,t={}){let n,r,i,a,o;return X(e)&&(e=[e]),Array.isArray(e)&&(e=e.map(e=>typeof e==`function`?Mi(e,{...this.options,...t}):e)),e.forEach(e=>{if(this.isValidLookup(n))return;let s=this.extractFromKey(e,t),c=s.key;r=c;let l=s.namespaces;this.options.fallbackNS&&(l=l.concat(this.options.fallbackNS));let u=t.count!==void 0&&!X(t.count),d=u&&!t.ordinal&&t.count===0,f=t.context!==void 0&&(X(t.context)||typeof t.context==`number`)&&t.context!==``,p=t.lngs?t.lngs:this.languageUtils.toResolveHierarchy(t.lng||this.language,t.fallbackLng);l.forEach(e=>{this.isValidLookup(n)||(o=e,!this.checkedLoadedFor[`${p[0]}-${e}`]&&this.utils?.hasLoadedNamespace&&!this.utils?.hasLoadedNamespace(o)&&(this.checkedLoadedFor[`${p[0]}-${e}`]=!0,this.logger.warn(`key "${r}" for languages "${p.join(`, `)}" won't get resolved as namespace "${o}" was not yet loaded`,`This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!`)),p.forEach(r=>{if(this.isValidLookup(n))return;a=r;let o=[c];if(this.i18nFormat?.addLookupKeys)this.i18nFormat.addLookupKeys(o,c,r,e,t);else{let e;u&&(e=this.pluralResolver.getSuffix(r,t.count,t));let n=`${this.options.pluralSeparator}zero`,i=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(u&&(t.ordinal&&e.startsWith(i)&&o.push(c+e.replace(i,this.options.pluralSeparator)),o.push(c+e),d&&o.push(c+n)),f){let r=`${c}${this.options.contextSeparator||`_`}${t.context}`;o.push(r),u&&(t.ordinal&&e.startsWith(i)&&o.push(r+e.replace(i,this.options.pluralSeparator)),o.push(r+e),d&&o.push(r+n))}}let s;for(;s=o.pop();)this.isValidLookup(n)||(i=s,n=this.getResource(r,e,s,t))}))})}),{res:n,usedKey:r,exactUsedKey:i,usedLng:a,usedNS:o}}isValidLookup(e){return e!==void 0&&!(!this.options.returnNull&&e===null)&&!(!this.options.returnEmptyString&&e===``)}getResource(e,t,n,r={}){return this.i18nFormat?.getResource?this.i18nFormat.getResource(e,t,n,r):this.resourceStore.getResource(e,t,n,r)}getUsedParamsDetails(e={}){let t=[`defaultValue`,`ordinal`,`context`,`replace`,`lng`,`lngs`,`fallbackLng`,`ns`,`keySeparator`,`nsSeparator`,`returnObjects`,`returnDetails`,`joinArrays`,`postProcess`,`interpolation`],n=e.replace&&!X(e.replace),r=n?e.replace:e;if(n&&e.count!==void 0&&(r.count=e.count),this.options.interpolation.defaultVariables&&(r={...this.options.interpolation.defaultVariables,...r}),!n){r={...r};for(let e of t)delete r[e]}return r}static hasDefaultValue(e){for(let t in e)if(Object.prototype.hasOwnProperty.call(e,t)&&t.startsWith(`defaultValue`)&&e[t]!==void 0)return!0;return!1}},Fi=class{constructor(e){this.options=e,this.supportedLngs=this.options.supportedLngs||!1,this.logger=Ei.create(`languageUtils`)}getScriptPartFromCode(e){if(e=wi(e),!e||!e.includes(`-`))return null;let t=e.split(`-`);return t.length===2||(t.pop(),t[t.length-1].toLowerCase()===`x`)?null:this.formatLanguageCode(t.join(`-`))}getLanguagePartFromCode(e){if(e=wi(e),!e||!e.includes(`-`))return e;let t=e.split(`-`);return this.formatLanguageCode(t[0])}formatLanguageCode(e){if(X(e)&&e.includes(`-`)){let t;try{t=Intl.getCanonicalLocales(e)[0]}catch{}return t&&this.options.lowerCaseLng&&(t=t.toLowerCase()),t||(this.options.lowerCaseLng?e.toLowerCase():e)}return this.options.cleanCode||this.options.lowerCaseLng?e.toLowerCase():e}isSupportedCode(e){return(this.options.load===`languageOnly`||this.options.nonExplicitSupportedLngs)&&(e=this.getLanguagePartFromCode(e)),!this.supportedLngs||!this.supportedLngs.length||this.supportedLngs.includes(e)}getBestMatchFromCodes(e){if(!e)return null;let t;return e.forEach(e=>{if(t)return;let n=this.formatLanguageCode(e);(!this.options.supportedLngs||this.isSupportedCode(n))&&(t=n)}),!t&&this.options.supportedLngs&&e.forEach(e=>{if(t)return;let n=this.getScriptPartFromCode(e);if(this.isSupportedCode(n))return t=n;let r=this.getLanguagePartFromCode(e);if(this.isSupportedCode(r))return t=r;t=this.options.supportedLngs.find(e=>e===r?!0:!e.includes(`-`)&&!r.includes(`-`)?!1:!!(e.includes(`-`)&&!r.includes(`-`)&&e.slice(0,e.indexOf(`-`))===r||e.startsWith(r)&&r.length>1))}),t||=this.getFallbackCodes(this.options.fallbackLng)[0],t}getFallbackCodes(e,t){if(!e)return[];if(typeof e==`function`&&(e=e(t)),X(e)&&(e=[e]),Array.isArray(e))return e;if(!t)return e.default||[];let n=e[t];return n||=e[this.getScriptPartFromCode(t)],n||=e[this.formatLanguageCode(t)],n||=e[this.getLanguagePartFromCode(t)],n||=e.default,n||[]}toResolveHierarchy(e,t){let n=this.getFallbackCodes((t===!1?[]:t)||this.options.fallbackLng||[],e),r=[],i=e=>{e&&(this.isSupportedCode(e)?r.push(e):this.logger.warn(`rejecting language code not found in supportedLngs: ${e}`))};return X(e)&&(e.includes(`-`)||e.includes(`_`))?(this.options.load!==`languageOnly`&&i(this.formatLanguageCode(e)),this.options.load!==`languageOnly`&&this.options.load!==`currentOnly`&&i(this.getScriptPartFromCode(e)),this.options.load!==`currentOnly`&&i(this.getLanguagePartFromCode(e))):X(e)&&i(this.formatLanguageCode(e)),n.forEach(e=>{r.includes(e)||i(this.formatLanguageCode(e))}),r}},Ii={zero:0,one:1,two:2,few:3,many:4,other:5},Li={select:e=>e===1?`one`:`other`,resolvedOptions:()=>({pluralCategories:[`one`,`other`]})},Ri=class{constructor(e,t={}){this.languageUtils=e,this.options=t,this.logger=Ei.create(`pluralResolver`),this.pluralRulesCache={}}clearCache(){this.pluralRulesCache={}}getRule(e,t={}){let n=wi(e===`dev`?`en`:e),r=t.ordinal?`ordinal`:`cardinal`,i=JSON.stringify({cleanedCode:n,type:r});if(i in this.pluralRulesCache)return this.pluralRulesCache[i];let a;try{a=new Intl.PluralRules(n,{type:r})}catch{if(typeof Intl>`u`)return this.logger.error(`No Intl support, please use an Intl polyfill!`),Li;if(!e.match(/-|_/))return Li;let n=this.languageUtils.getLanguagePartFromCode(e);a=this.getRule(n,t)}return this.pluralRulesCache[i]=a,a}needsPlural(e,t={}){let n=this.getRule(e,t);return n||=this.getRule(`dev`,t),n?.resolvedOptions().pluralCategories.length>1}getPluralFormsOfKey(e,t,n={}){return this.getSuffixes(e,n).map(e=>`${t}${e}`)}getSuffixes(e,t={}){let n=this.getRule(e,t);return n||=this.getRule(`dev`,t),n?n.resolvedOptions().pluralCategories.sort((e,t)=>Ii[e]-Ii[t]).map(e=>`${this.options.prepend}${t.ordinal?`ordinal${this.options.prepend}`:``}${e}`):[]}getSuffix(e,t,n={}){let r=this.getRule(e,n);return r?`${this.options.prepend}${n.ordinal?`ordinal${this.options.prepend}`:``}${r.select(t)}`:(this.logger.warn(`no plural rule found for: ${e}`),this.getSuffix(`dev`,t,n))}},zi=(e,t,n,r=`.`,i=!0)=>{let a=mi(e,t,n);return!a&&i&&X(n)&&(a=Ci(e,n,r),a===void 0&&(a=Ci(t,n,r))),a},Bi=e=>e.replace(/\$/g,`$$$$`),Vi=class{constructor(e={}){this.logger=Ei.create(`interpolator`),this.options=e,this.format=e?.interpolation?.format||(e=>e),this.init(e)}init(e={}){e.interpolation||={escapeValue:!0};let{escape:t,escapeValue:n,useRawValueToEscape:r,prefix:i,prefixEscaped:a,suffix:o,suffixEscaped:s,formatSeparator:c,unescapeSuffix:l,unescapePrefix:u,nestingPrefix:d,nestingPrefixEscaped:f,nestingSuffix:p,nestingSuffixEscaped:m,nestingOptionsSeparator:h,maxReplaces:g,alwaysFormat:_}=e.interpolation;this.escape=t===void 0?vi:t,this.escapeValue=n===void 0?!0:n,this.useRawValueToEscape=r===void 0?!1:r,this.prefix=i?gi(i):a||`{{`,this.suffix=o?gi(o):s||`}}`,this.formatSeparator=c||`,`,this.unescapePrefix=l?``:u?gi(u):`-`,this.unescapeSuffix=this.unescapePrefix?``:l?gi(l):``,this.nestingPrefix=d?gi(d):f||gi(`$t(`),this.nestingSuffix=p?gi(p):m||gi(`)`),this.nestingOptionsSeparator=h||`,`,this.maxReplaces=g||1e3,this.alwaysFormat=_===void 0?!1:_,this.resetRegExp()}reset(){this.options&&this.init(this.options)}resetRegExp(){let e=(e,t)=>e?.source===t?(e.lastIndex=0,e):new RegExp(t,`g`);this.regexp=e(this.regexp,`${this.prefix}(.+?)${this.suffix}`),this.regexpUnescape=e(this.regexpUnescape,`${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`),this.nestingRegexp=e(this.nestingRegexp,`${this.nestingPrefix}((?:[^()"']+|"[^"]*"|'[^']*'|\\((?:[^()]|"[^"]*"|'[^']*')*\\))*?)${this.nestingSuffix}`)}interpolate(e,t,n,r){let i,a,o,s=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{},c=e=>{if(!e.includes(this.formatSeparator)){let i=zi(t,s,e,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(i,void 0,n,{...r,...t,interpolationkey:e}):i}let i=e.split(this.formatSeparator),a=i.shift().trim(),o=i.join(this.formatSeparator).trim();return this.format(zi(t,s,a,this.options.keySeparator,this.options.ignoreJSONStructure),o,n,{...r,...t,interpolationkey:a})};this.resetRegExp(),!this.escapeValue&&typeof e==`string`&&/\$t\([^)]*\{[^}]*\{\{/.test(e)&&this.logger.warn(`nesting options string contains interpolated variables with escapeValue: false — if any of those values are attacker-controlled they can inject additional nesting options (e.g. redirect lng/ns). Sanitise untrusted input before passing it to t(), or keep escapeValue: true.`);let l=r?.missingInterpolationHandler||this.options.missingInterpolationHandler,u=r?.interpolation?.skipOnVariables===void 0?this.options.interpolation.skipOnVariables:r.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:e=>Bi(e)},{regex:this.regexp,safeValue:e=>this.escapeValue?Bi(this.escape(e)):Bi(e)}].forEach(t=>{for(o=0;i=t.regex.exec(e);){let n=i[1].trim();if(a=c(n),a===void 0)if(typeof l==`function`){let t=l(e,i,r);a=X(t)?t:``}else if(r&&Object.prototype.hasOwnProperty.call(r,n))a=``;else if(u){a=i[0];continue}else this.logger.warn(`missed to pass in variable ${n} for interpolating ${e}`),a=``;else!X(a)&&!this.useRawValueToEscape&&(a=ai(a));let s=t.safeValue(a);if(e=e.replace(i[0],s),u?(t.regex.lastIndex+=a.length,t.regex.lastIndex-=i[0].length):t.regex.lastIndex=0,o++,o>=this.maxReplaces)break}}),e}nest(e,t,n={}){let r,i,a,o=(e,t)=>{let n=this.nestingOptionsSeparator;if(!e.includes(n))return e;let r=e.split(RegExp(`${gi(n)}[ ]*{`)),i=`{${r[1]}`;e=r[0],i=this.interpolate(i,a);let o=i.match(/'/g),s=i.match(/"/g);((o?.length??0)%2==0&&!s||(s?.length??0)%2!=0)&&(i=i.replace(/'/g,`"`));try{a=JSON.parse(i),t&&(a={...t,...a})}catch(t){return this.logger.warn(`failed parsing options string in nesting for key ${e}`,t),`${e}${n}${i}`}return a.defaultValue&&a.defaultValue.includes(this.prefix)&&delete a.defaultValue,e};for(;r=this.nestingRegexp.exec(e);){let s=[];a={...n},a=a.replace&&!X(a.replace)?a.replace:a,a.applyPostProcessor=!1,delete a.defaultValue;let c=/{.*}/.test(r[1])?r[1].lastIndexOf(`}`)+1:r[1].indexOf(this.formatSeparator);if(c!==-1&&(s=r[1].slice(c).split(this.formatSeparator).map(e=>e.trim()).filter(Boolean),r[1]=r[1].slice(0,c)),i=t(o.call(this,r[1].trim(),a),a),i&&r[0]===e&&!X(i))return i;X(i)||(i=ai(i)),i||=(this.logger.warn(`missed to resolve ${r[1]} for nesting ${e}`),``),s.length&&(i=s.reduce((e,t)=>this.format(e,t,n.lng,{...n,interpolationkey:r[1].trim()}),i.trim())),e=e.replace(r[0],i),this.regexp.lastIndex=0}return e}},Hi=e=>{let t=e.toLowerCase().trim(),n={};if(e.includes(`(`)){let r=e.split(`(`);t=r[0].toLowerCase().trim();let i=r[1].slice(0,-1);t===`currency`&&!i.includes(`:`)?n.currency||=i.trim():t===`relativetime`&&!i.includes(`:`)?n.range||=i.trim():i.split(`;`).forEach(e=>{if(e){let[t,...r]=e.split(`:`),i=r.join(`:`).trim().replace(/^'+|'+$/g,``),a=t.trim();n[a]||(n[a]=i),i===`false`&&(n[a]=!1),i===`true`&&(n[a]=!0),isNaN(i)||(n[a]=parseInt(i,10))}})}return{formatName:t,formatOptions:n}},Ui=e=>{let t={};return(n,r,i)=>{let a=i;i&&i.interpolationkey&&i.formatParams&&i.formatParams[i.interpolationkey]&&i[i.interpolationkey]&&(a={...a,[i.interpolationkey]:void 0});let o=r+JSON.stringify(a),s=t[o];return s||(s=e(wi(r),i),t[o]=s),s(n)}},Wi=e=>(t,n,r)=>e(wi(n),r)(t),Gi=class{constructor(e={}){this.logger=Ei.create(`formatter`),this.options=e,this.init(e)}init(e,t={interpolation:{}}){this.formatSeparator=t.interpolation.formatSeparator||`,`;let n=t.cacheInBuiltFormats?Ui:Wi;this.formats={number:n((e,t)=>{let n=new Intl.NumberFormat(e,{...t});return e=>n.format(e)}),currency:n((e,t)=>{let n=new Intl.NumberFormat(e,{...t,style:`currency`});return e=>n.format(e)}),datetime:n((e,t)=>{let n=new Intl.DateTimeFormat(e,{...t});return e=>n.format(e)}),relativetime:n((e,t)=>{let n=new Intl.RelativeTimeFormat(e,{...t});return e=>n.format(e,t.range||`day`)}),list:n((e,t)=>{let n=new Intl.ListFormat(e,{...t});return e=>n.format(e)})}}add(e,t){this.formats[e.toLowerCase().trim()]=t}addCached(e,t){this.formats[e.toLowerCase().trim()]=Ui(t)}format(e,t,n,r={}){if(!t||e==null)return e;let i=t.split(this.formatSeparator),a=[];for(let e=0;e<i.length;e++){let t=i[e];for(;t.indexOf(`(`)>-1&&!t.includes(`)`)&&e+1<i.length;)t=`${t}${this.formatSeparator}${i[++e]}`;a.push(t)}return a.reduce((e,t)=>{let{formatName:i,formatOptions:a}=Hi(t);if(this.formats[i]){let t=e;try{let o=r?.formatParams?.[r.interpolationkey]||{},s=o.locale||o.lng||r.locale||r.lng||n;t=this.formats[i](e,s,{...a,...r,...o})}catch(e){this.logger.warn(e)}return t}else this.logger.warn(`there was no format function for ${i}`);return e},e)}},Ki=(e,t)=>{e.pending[t]!==void 0&&(delete e.pending[t],e.pendingCount--)},qi=class extends Di{constructor(e,t,n,r={}){super(),this.backend=e,this.store=t,this.services=n,this.languageUtils=n.languageUtils,this.options=r,this.logger=Ei.create(`backendConnector`),this.waitingReads=[],this.maxParallelReads=r.maxParallelReads||10,this.readingCalls=0,this.maxRetries=r.maxRetries>=0?r.maxRetries:5,this.retryTimeout=r.retryTimeout>=1?r.retryTimeout:350,this.state={},this.queue=[],this.backend?.init?.(n,r.backend,r)}queueLoad(e,t,n,r){let i={},a={},o={},s={};return e.forEach(e=>{let r=!0;t.forEach(t=>{let o=`${e}|${t}`;!n.reload&&this.store.hasResourceBundle(e,t)?this.state[o]=2:this.state[o]<0||(this.state[o]===1?a[o]===void 0&&(a[o]=!0):(this.state[o]=1,r=!1,a[o]===void 0&&(a[o]=!0),i[o]===void 0&&(i[o]=!0),s[t]===void 0&&(s[t]=!0)))}),r||(o[e]=!0)}),(Object.keys(i).length||Object.keys(a).length)&&this.queue.push({pending:a,pendingCount:Object.keys(a).length,loaded:{},errors:[],callback:r}),{toLoad:Object.keys(i),pending:Object.keys(a),toLoadLanguages:Object.keys(o),toLoadNamespaces:Object.keys(s)}}loaded(e,t,n){let r=e.split(`|`),i=r[0],a=r[1];t&&this.emit(`failedLoading`,i,a,t),!t&&n&&this.store.addResourceBundle(i,a,n,void 0,void 0,{skipCopy:!0}),this.state[e]=t?-1:2,t&&n&&(this.state[e]=0);let o={};this.queue.forEach(n=>{fi(n.loaded,[i],a),Ki(n,e),t&&n.errors.push(t),n.pendingCount===0&&!n.done&&(Object.keys(n.loaded).forEach(e=>{o[e]||(o[e]={});let t=n.loaded[e];t.length&&t.forEach(t=>{o[e][t]===void 0&&(o[e][t]=!0)})}),n.done=!0,n.errors.length?n.callback(n.errors):n.callback())}),this.emit(`loaded`,o),this.queue=this.queue.filter(e=>!e.done)}read(e,t,n,r=0,i=this.retryTimeout,a){if(!e.length)return a(null,{});if(this.readingCalls>=this.maxParallelReads){this.waitingReads.push({lng:e,ns:t,fcName:n,tried:r,wait:i,callback:a});return}this.readingCalls++;let o=(o,s)=>{if(this.readingCalls--,this.waitingReads.length>0){let e=this.waitingReads.shift();this.read(e.lng,e.ns,e.fcName,e.tried,e.wait,e.callback)}if(o&&s&&r<this.maxRetries){setTimeout(()=>{this.read(e,t,n,r+1,i*2,a)},i);return}a(o,s)},s=this.backend[n].bind(this.backend);if(s.length===2){try{let n=s(e,t);n&&typeof n.then==`function`?n.then(e=>o(null,e)).catch(o):o(null,n)}catch(e){o(e)}return}return s(e,t,o)}prepareLoading(e,t,n={},r){if(!this.backend)return this.logger.warn(`No backend was added via i18next.use. Will not load resources.`),r&&r();X(e)&&(e=this.languageUtils.toResolveHierarchy(e)),X(t)&&(t=[t]);let i=this.queueLoad(e,t,n,r);if(!i.toLoad.length)return i.pending.length||r(),null;i.toLoad.forEach(e=>{this.loadOne(e)})}load(e,t,n){this.prepareLoading(e,t,{},n)}reload(e,t,n){this.prepareLoading(e,t,{reload:!0},n)}loadOne(e,t=``){let n=e.split(`|`),r=n[0],i=n[1];this.read(r,i,`read`,void 0,void 0,(n,a)=>{n&&this.logger.warn(`${t}loading namespace ${i} for language ${r} failed`,n),!n&&a&&this.logger.log(`${t}loaded namespace ${i} for language ${r}`,a),this.loaded(e,n,a)})}saveMissing(e,t,n,r,i,a={},o=()=>{}){if(this.services?.utils?.hasLoadedNamespace&&!this.services?.utils?.hasLoadedNamespace(t)){this.logger.warn(`did not save key "${n}" as the namespace "${t}" was not yet loaded`,`This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!`);return}if(!(n==null||n===``)){if(this.backend?.create){let s={...a,isUpdate:i},c=this.backend.create.bind(this.backend);if(c.length<6)try{let i;i=c.length===5?c(e,t,n,r,s):c(e,t,n,r),i&&typeof i.then==`function`?i.then(e=>o(null,e)).catch(o):o(null,i)}catch(e){o(e)}else c(e,t,n,r,o,s)}!e||!e[0]||this.store.addResource(e[0],t,n,r)}}},Ji=()=>({debug:!1,initAsync:!0,ns:[`translation`],defaultNS:[`translation`],fallbackLng:[`dev`],fallbackNS:!1,supportedLngs:!1,nonExplicitSupportedLngs:!1,load:`all`,preload:!1,keySeparator:`.`,nsSeparator:`:`,pluralSeparator:`_`,contextSeparator:`_`,enableSelector:!1,partialBundledLanguages:!1,saveMissing:!1,updateMissing:!1,saveMissingTo:`fallback`,saveMissingPlurals:!0,missingKeyHandler:!1,missingInterpolationHandler:!1,postProcess:!1,postProcessPassResolved:!1,returnNull:!1,returnEmptyString:!0,returnObjects:!1,joinArrays:!1,returnedObjectHandler:!1,parseMissingKeyHandler:!1,appendNamespaceToMissingKey:!1,appendNamespaceToCIMode:!1,overloadTranslationOptionHandler:e=>{let t={};if(typeof e[1]==`object`&&(t=e[1]),X(e[1])&&(t.defaultValue=e[1]),X(e[2])&&(t.tDescription=e[2]),typeof e[2]==`object`||typeof e[3]==`object`){let n=e[3]||e[2];Object.keys(n).forEach(e=>{t[e]=n[e]})}return t},interpolation:{escapeValue:!0,prefix:`{{`,suffix:`}}`,formatSeparator:`,`,unescapePrefix:`-`,nestingPrefix:`$t(`,nestingSuffix:`)`,nestingOptionsSeparator:`,`,maxReplaces:1e3,skipOnVariables:!0},cacheInBuiltFormats:!0}),Yi=e=>(X(e.ns)&&(e.ns=[e.ns]),X(e.fallbackLng)&&(e.fallbackLng=[e.fallbackLng]),X(e.fallbackNS)&&(e.fallbackNS=[e.fallbackNS]),e.supportedLngs&&!e.supportedLngs.includes(`cimode`)&&(e.supportedLngs=e.supportedLngs.concat([`cimode`])),e),Xi=()=>{},Zi=e=>{Object.getOwnPropertyNames(Object.getPrototypeOf(e)).forEach(t=>{typeof e[t]==`function`&&(e[t]=e[t].bind(e))})},Qi=class e extends Di{constructor(e={},t){if(super(),this.options=Yi(e),this.services={},this.logger=Ei,this.modules={external:[]},Zi(this),t&&!this.isInitialized&&!e.isClone){if(!this.options.initAsync)return this.init(e,t),this;setTimeout(()=>{this.init(e,t)},0)}}init(e={},t){this.isInitializing=!0,typeof e==`function`&&(t=e,e={}),e.defaultNS==null&&e.ns&&(X(e.ns)?e.defaultNS=e.ns:e.ns.includes(`translation`)||(e.defaultNS=e.ns[0]));let n=Ji();this.options={...n,...this.options,...Yi(e)},this.options.interpolation={...n.interpolation,...this.options.interpolation},e.keySeparator!==void 0&&(this.options.userDefinedKeySeparator=e.keySeparator),e.nsSeparator!==void 0&&(this.options.userDefinedNsSeparator=e.nsSeparator),typeof this.options.overloadTranslationOptionHandler!=`function`&&(this.options.overloadTranslationOptionHandler=n.overloadTranslationOptionHandler);let r=e=>e?typeof e==`function`?new e:e:null;if(!this.options.isClone){this.modules.logger?Ei.init(r(this.modules.logger),this.options):Ei.init(null,this.options);let e;e=this.modules.formatter?this.modules.formatter:Gi;let t=new Fi(this.options);this.store=new Oi(this.options.resources,this.options);let n=this.services;n.logger=Ei,n.resourceStore=this.store,n.languageUtils=t,n.pluralResolver=new Ri(t,{prepend:this.options.pluralSeparator}),e&&(n.formatter=r(e),n.formatter.init&&n.formatter.init(n,this.options),this.options.interpolation.format=n.formatter.format.bind(n.formatter)),n.interpolator=new Vi(this.options),n.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},n.backendConnector=new qi(r(this.modules.backend),n.resourceStore,n,this.options),n.backendConnector.on(`*`,(e,...t)=>{this.emit(e,...t)}),this.modules.languageDetector&&(n.languageDetector=r(this.modules.languageDetector),n.languageDetector.init&&n.languageDetector.init(n,this.options.detection,this.options)),this.modules.i18nFormat&&(n.i18nFormat=r(this.modules.i18nFormat),n.i18nFormat.init&&n.i18nFormat.init(this)),this.translator=new Pi(this.services,this.options),this.translator.on(`*`,(e,...t)=>{this.emit(e,...t)}),this.modules.external.forEach(e=>{e.init&&e.init(this)})}if(this.format=this.options.interpolation.format,t||=Xi,this.options.fallbackLng&&!this.services.languageDetector&&!this.options.lng){let e=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);e.length>0&&e[0]!==`dev`&&(this.options.lng=e[0])}!this.services.languageDetector&&!this.options.lng&&this.logger.warn(`init: no languageDetector is used and no lng is defined`),[`getResource`,`hasResourceBundle`,`getResourceBundle`,`getDataByLanguage`].forEach(e=>{this[e]=(...t)=>this.store[e](...t)}),[`addResource`,`addResources`,`addResourceBundle`,`removeResourceBundle`].forEach(e=>{this[e]=(...t)=>(this.store[e](...t),this)});let i=ii(),a=()=>{let e=(e,n)=>{this.isInitializing=!1,this.isInitialized&&!this.initializedStoreOnce&&this.logger.warn(`init: i18next is already initialized. You should call init just once!`),this.isInitialized=!0,this.options.isClone||this.logger.log(`initialized`,this.options),this.emit(`initialized`,this.options),i.resolve(n),t(e,n)};if((this.languages||this.isLanguageChangingTo)&&!this.isInitialized)return e(null,this.t.bind(this));this.changeLanguage(this.options.lng,e)};return this.options.resources||!this.options.initAsync?a():setTimeout(a,0),i}loadResources(e,t=Xi){let n=t,r=X(e)?e:this.language;if(typeof e==`function`&&(n=e),!this.options.resources||this.options.partialBundledLanguages){if(r?.toLowerCase()===`cimode`&&(!this.options.preload||this.options.preload.length===0))return n();let e=[],t=t=>{t&&t!==`cimode`&&this.services.languageUtils.toResolveHierarchy(t).forEach(t=>{t!==`cimode`&&(e.includes(t)||e.push(t))})};r?t(r):this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach(e=>t(e)),this.options.preload?.forEach?.(e=>t(e)),this.services.backendConnector.load(e,this.options.ns,e=>{!e&&!this.resolvedLanguage&&this.language&&this.setResolvedLanguage(this.language),n(e)})}else n(null)}reloadResources(e,t,n){let r=ii();return typeof e==`function`&&(n=e,e=void 0),typeof t==`function`&&(n=t,t=void 0),e||=this.languages,t||=this.options.ns,n||=Xi,this.services.backendConnector.reload(e,t,e=>{r.resolve(),n(e)}),r}use(e){if(!e)throw Error(`You are passing an undefined module! Please check the object you are passing to i18next.use()`);if(!e.type)throw Error(`You are passing a wrong module! Please check the object you are passing to i18next.use()`);return e.type===`backend`&&(this.modules.backend=e),(e.type===`logger`||e.log&&e.warn&&e.error)&&(this.modules.logger=e),e.type===`languageDetector`&&(this.modules.languageDetector=e),e.type===`i18nFormat`&&(this.modules.i18nFormat=e),e.type===`postProcessor`&&ki.addPostProcessor(e),e.type===`formatter`&&(this.modules.formatter=e),e.type===`3rdParty`&&this.modules.external.push(e),this}setResolvedLanguage(e){if(!(!e||!this.languages)&&![`cimode`,`dev`].includes(e)){for(let e=0;e<this.languages.length;e++){let t=this.languages[e];if(![`cimode`,`dev`].includes(t)&&this.store.hasLanguageSomeTranslations(t)){this.resolvedLanguage=t;break}}!this.resolvedLanguage&&!this.languages.includes(e)&&this.store.hasLanguageSomeTranslations(e)&&(this.resolvedLanguage=e,this.languages.unshift(e))}}changeLanguage(e,t){this.isLanguageChangingTo=e;let n=ii();this.emit(`languageChanging`,e);let r=e=>{this.language=e,this.languages=this.services.languageUtils.toResolveHierarchy(e),this.resolvedLanguage=void 0,this.setResolvedLanguage(e)},i=(i,a)=>{a?this.isLanguageChangingTo===e&&(r(a),this.translator.changeLanguage(a),this.isLanguageChangingTo=void 0,this.emit(`languageChanged`,a),this.logger.log(`languageChanged`,a)):this.isLanguageChangingTo=void 0,n.resolve((...e)=>this.t(...e)),t&&t(i,(...e)=>this.t(...e))},a=t=>{!e&&!t&&this.services.languageDetector&&(t=[]);let n=X(t)?t:t&&t[0],a=this.store.hasLanguageSomeTranslations(n)?n:this.services.languageUtils.getBestMatchFromCodes(X(t)?[t]:t);a&&(this.language||r(a),this.translator.language||this.translator.changeLanguage(a),this.services.languageDetector?.cacheUserLanguage?.(a)),this.loadResources(a,e=>{i(e,a)})};return!e&&this.services.languageDetector&&!this.services.languageDetector.async?a(this.services.languageDetector.detect()):!e&&this.services.languageDetector&&this.services.languageDetector.async?this.services.languageDetector.detect.length===0?this.services.languageDetector.detect().then(a):this.services.languageDetector.detect(a):a(e),n}getFixedT(e,t,n,r){let i=r?.scopeNs,a=(e,t,...r)=>{let o;o=typeof t==`object`?{...t}:this.options.overloadTranslationOptionHandler([e,t].concat(r)),o.lng=o.lng||a.lng,o.lngs=o.lngs||a.lngs;let s=o.ns!==void 0&&o.ns!==null;o.ns=o.ns||a.ns,o.keyPrefix!==``&&(o.keyPrefix=o.keyPrefix||n||a.keyPrefix);let c={...this.options,...o};Array.isArray(i)&&!s&&(c.ns=i),typeof o.keyPrefix==`function`&&(o.keyPrefix=Mi(o.keyPrefix,c));let l=this.options.keySeparator||`.`,u;return o.keyPrefix&&Array.isArray(e)?u=e.map(e=>(typeof e==`function`&&(e=Mi(e,c)),`${o.keyPrefix}${l}${e}`)):(typeof e==`function`&&(e=Mi(e,c)),u=o.keyPrefix?`${o.keyPrefix}${l}${e}`:e),this.t(u,o)};return X(e)?a.lng=e:a.lngs=e,a.ns=t,a.keyPrefix=n,a}t(...e){return this.translator?.translate(...e)}exists(...e){return this.translator?.exists(...e)}setDefaultNamespace(e){this.options.defaultNS=e}hasLoadedNamespace(e,t={}){if(!this.isInitialized)return this.logger.warn(`hasLoadedNamespace: i18next was not initialized`,this.languages),!1;if(!this.languages||!this.languages.length)return this.logger.warn(`hasLoadedNamespace: i18n.languages were undefined or empty`,this.languages),!1;let n=t.lng||this.resolvedLanguage||this.languages[0],r=this.options?this.options.fallbackLng:!1,i=this.languages[this.languages.length-1];if(n.toLowerCase()===`cimode`)return!0;let a=(e,t)=>{let n=this.services.backendConnector.state[`${e}|${t}`];return n===-1||n===0||n===2};if(t.precheck){let e=t.precheck(this,a);if(e!==void 0)return e}return!!(this.hasResourceBundle(n,e)||!this.services.backendConnector.backend||this.options.resources&&!this.options.partialBundledLanguages||a(n,e)&&(!r||a(i,e)))}loadNamespaces(e,t){let n=ii();return this.options.ns?(X(e)&&(e=[e]),e.forEach(e=>{this.options.ns.includes(e)||this.options.ns.push(e)}),this.loadResources(e=>{n.resolve(),t&&t(e)}),n):(t&&t(),Promise.resolve())}loadLanguages(e,t){let n=ii();X(e)&&(e=[e]);let r=this.options.preload||[],i=e.filter(e=>!r.includes(e)&&this.services.languageUtils.isSupportedCode(e));return i.length?(this.options.preload=r.concat(i),this.loadResources(e=>{n.resolve(),t&&t(e)}),n):(t&&t(),Promise.resolve())}dir(e){if(e||=this.resolvedLanguage||(this.languages?.length>0?this.languages[0]:this.language),!e)return`rtl`;try{let t=new Intl.Locale(e);if(t&&t.getTextInfo){let e=t.getTextInfo();if(e&&e.direction)return e.direction}}catch{}let t=`ar.shu.sqr.ssh.xaa.yhd.yud.aao.abh.abv.acm.acq.acw.acx.acy.adf.ads.aeb.aec.afb.ajp.apc.apd.arb.arq.ars.ary.arz.auz.avl.ayh.ayl.ayn.ayp.bbz.pga.he.iw.ps.pbt.pbu.pst.prp.prd.ug.ur.ydd.yds.yih.ji.yi.hbo.men.xmn.fa.jpr.peo.pes.prs.dv.sam.ckb`.split(`.`),n=this.services?.languageUtils||new Fi(Ji());return e.toLowerCase().indexOf(`-latn`)>1?`ltr`:t.includes(n.getLanguagePartFromCode(e))||e.toLowerCase().indexOf(`-arab`)>1?`rtl`:`ltr`}static createInstance(t={},n){let r=new e(t,n);return r.createInstance=e.createInstance,r}cloneInstance(t={},n=Xi){let r=t.forkResourceStore;r&&delete t.forkResourceStore;let i={...this.options,...t,isClone:!0},a=new e(i);if((t.debug!==void 0||t.prefix!==void 0)&&(a.logger=a.logger.clone(t)),[`store`,`services`,`language`].forEach(e=>{a[e]=this[e]}),a.services={...this.services},a.services.utils={hasLoadedNamespace:a.hasLoadedNamespace.bind(a)},r&&(a.store=new Oi(Object.keys(this.store.data).reduce((e,t)=>(e[t]={...this.store.data[t]},e[t]=Object.keys(e[t]).reduce((n,r)=>(n[r]={...e[t][r]},n),e[t]),e),{}),i),a.services.resourceStore=a.store),t.interpolation){let e={...Ji().interpolation,...this.options.interpolation,...t.interpolation},n={...i,interpolation:e};a.services.interpolator=new Vi(n)}return a.translator=new Pi(a.services,i),a.translator.on(`*`,(e,...t)=>{a.emit(e,...t)}),a.init(i,n),a.translator.options=i,a.translator.backendConnector.services.utils={hasLoadedNamespace:a.hasLoadedNamespace.bind(a)},a}toJSON(){return{options:this.options,store:this.store,language:this.language,languages:this.languages,resolvedLanguage:this.resolvedLanguage}}}.createInstance();Qi.createInstance,Qi.dir,Qi.init,Qi.loadResources,Qi.reloadResources,Qi.use,Qi.changeLanguage,Qi.getFixedT,Qi.t,Qi.exists,Qi.setDefaultNamespace,Qi.hasLoadedNamespace,Qi.loadNamespaces,Qi.loadLanguages;var $i=t((e=>{var t=n();function r(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var i=typeof Object.is==`function`?Object.is:r,a=t.useState,o=t.useEffect,s=t.useLayoutEffect,c=t.useDebugValue;function l(e,t){var n=t(),r=a({inst:{value:n,getSnapshot:t}}),i=r[0].inst,l=r[1];return s(function(){i.value=n,i.getSnapshot=t,u(i)&&l({inst:i})},[e,n,t]),o(function(){return u(i)&&l({inst:i}),e(function(){u(i)&&l({inst:i})})},[e]),c(n),n}function u(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!i(e,n)}catch{return!0}}function d(e,t){return t()}var f=typeof window>`u`||window.document===void 0||window.document.createElement===void 0?d:l;e.useSyncExternalStore=t.useSyncExternalStore===void 0?f:t.useSyncExternalStore})),ea=t(((e,t)=>{t.exports=$i()}))(),ta=/&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g,na={"&":`&`,"&":`&`,"<":`<`,"<":`<`,">":`>`,">":`>`,"'":`'`,"'":`'`,""":`"`,""":`"`," ":` `," ":` `,"©":`©`,"©":`©`,"®":`®`,"®":`®`,"…":`…`,"…":`…`,"/":`/`,"/":`/`},ra=e=>na[e],ia={bindI18n:`languageChanged`,bindI18nStore:``,transEmptyNodeValue:``,transSupportBasicHtmlNodes:!0,transWrapTextNodes:``,transKeepBasicHtmlNodesFor:[`br`,`strong`,`i`,`p`],useSuspense:!0,unescape:e=>e.replace(ta,ra),transDefaultProps:void 0},aa=(e={})=>{ia={...ia,...e}},oa=()=>ia,sa,ca=e=>{sa=e},la=()=>sa,ua={type:`3rdParty`,init(e){aa(e.options.react),ca(e)}},da=(0,D.createContext)(),fa=class{constructor(){this.usedNamespaces={}}addUsedNamespaces(e){e.forEach(e=>{this.usedNamespaces[e]||(this.usedNamespaces[e]=!0)})}getUsedNamespaces(){return Object.keys(this.usedNamespaces)}},pa=(e,t,n,r)=>{let i=[n,{code:t,...r||{}}];if(e?.services?.logger?.forward)return e.services.logger.forward(i,`warn`,`react-i18next::`,!0);ba(i[0])&&(i[0]=`react-i18next:: ${i[0]}`),e?.services?.logger?.warn?e.services.logger.warn(...i):console?.warn&&console.warn(...i)},ma={},ha=(e,t,n,r)=>{ba(n)&&ma[n]||(ba(n)&&(ma[n]=new Date),pa(e,t,n,r))},ga=(e,t)=>()=>{if(e.isInitialized)t();else{let n=()=>{setTimeout(()=>{e.off(`initialized`,n)},0),t()};e.on(`initialized`,n)}},_a=(e,t,n)=>{e.loadNamespaces(t,ga(e,n))},va=(e,t,n,r)=>{if(ba(n)&&(n=[n]),e.options.preload&&e.options.preload.indexOf(t)>-1)return _a(e,n,r);n.forEach(t=>{e.options.ns.indexOf(t)<0&&e.options.ns.push(t)}),e.loadLanguages(t,ga(e,r))},ya=(e,t,n={})=>!t.languages||!t.languages.length?(ha(t,`NO_LANGUAGES`,`i18n.languages were undefined or empty`,{languages:t.languages}),!0):t.hasLoadedNamespace(e,{lng:n.lng,precheck:(t,r)=>{if(n.bindI18n&&n.bindI18n.indexOf(`languageChanging`)>-1&&t.services.backendConnector.backend&&t.isLanguageChangingTo&&!r(t.isLanguageChangingTo,e))return!1}}),ba=e=>typeof e==`string`,xa=e=>typeof e==`object`&&!!e,Sa={t:(e,t)=>{if(ba(t))return t;if(xa(t)&&ba(t.defaultValue))return t.defaultValue;if(typeof e==`function`)return``;if(Array.isArray(e)){let t=e[e.length-1];return typeof t==`function`?``:t}return e},ready:!1},Ca=()=>()=>{},wa=(e,t={})=>{let{i18n:n}=t,{i18n:r,defaultNS:i}=(0,D.useContext)(da)||{},a=n||r||la();a&&!a.reportNamespaces&&(a.reportNamespaces=new fa),a||ha(a,`NO_I18NEXT_INSTANCE`,`useTranslation: You will need to pass in an i18next instance by using initReactI18next`);let o=(0,D.useMemo)(()=>({...oa(),...a?.options?.react,...t}),[a,t]),{useSuspense:s,keyPrefix:c}=o,l=e||i||a?.options?.defaultNS,u=ba(l)?[l]:l||[`translation`],d=(0,D.useMemo)(()=>u,u);a?.reportNamespaces?.addUsedNamespaces?.(d);let f=(0,D.useRef)(0),p=(0,D.useCallback)(e=>{if(!a)return Ca;let{bindI18n:t,bindI18nStore:n}=o,r=()=>{f.current+=1,e()};return t&&a.on(t,r),n&&a.store.on(n,r),()=>{t&&t.split(` `).forEach(e=>a.off(e,r)),n&&n.split(` `).forEach(e=>a.store.off(e,r))}},[a,o]),m=(0,D.useRef)(),h=(0,D.useCallback)(()=>{if(!a)return Sa;let e=!!(a.isInitialized||a.initializedStoreOnce)&&d.every(e=>ya(e,a,o)),n=t.lng||a.language,r=f.current,i=m.current;if(i&&i.ready===e&&i.lng===n&&i.keyPrefix===c&&i.revision===r)return i;let s={t:a.getFixedT(n,o.nsMode===`fallback`?d:d[0],c,{scopeNs:d}),ready:e,lng:n,keyPrefix:c,revision:r};return m.current=s,s},[a,d,c,o,t.lng]),[g,_]=(0,D.useState)(0),{t:v,ready:y}=(0,ea.useSyncExternalStore)(p,h,h);(0,D.useEffect)(()=>{if(a&&!y&&!s){let e=()=>_(e=>e+1);t.lng?va(a,t.lng,d,e):_a(a,d,e)}},[a,t.lng,d,y,s,g]);let b=a||{},x=(0,D.useRef)(null),S=(0,D.useRef)(),C=e=>{let t=Object.getOwnPropertyDescriptors(e);t.__original&&delete t.__original;let n=Object.create(Object.getPrototypeOf(e),t);if(!Object.prototype.hasOwnProperty.call(n,`__original`))try{Object.defineProperty(n,"__original",{value:e,writable:!1,enumerable:!1,configurable:!1})}catch{}return n},w=(0,D.useMemo)(()=>{let e=b,t=e?.language,n=e;e&&(x.current&&x.current.__original===e&&S.current===t?n=x.current:(n=C(e),x.current=n,S.current=t));let r=!y&&!s?(...e)=>(ha(a,`USE_T_BEFORE_READY`,`useTranslation: t was called before ready. When using useSuspense: false, make sure to check the ready flag before using t.`),v(...e)):v,i=[r,n,y];return i.t=r,i.i18n=n,i.ready=y,i},[v,b,y,b.resolvedLanguage,b.language,b.languages]);if(a&&s&&!y)throw new Promise(e=>{let n=()=>e();t.lng?va(a,t.lng,d,n):_a(a,d,n)});return w},Ta={"en-US":()=>o(async()=>{let{enUsTranslation:e}=await import(`./en-US-DOXBXLLy.js`);return{enUsTranslation:e}},[],import.meta.url).then(({enUsTranslation:e})=>e),"zh-CN":()=>o(async()=>{let{zhCnTranslation:e}=await import(`./zh-CN-C4xbZjjC.js`);return{zhCnTranslation:e}},[],import.meta.url).then(({zhCnTranslation:e})=>e)},Ea=new Map,Da=e=>{let t=Ea.get(e);return t||(t=Ta[e](),Ea.set(e,t)),t},Oa={app:{errorBoundary:{title:`Un problème est survenu`,description:`Une erreur inattendue s'est produite dans cette section. Vous pouvez réessayer ou recharger la page si le problème persiste.`,tryAgain:`Réessayer`,showDetails:`Afficher les détails`,hideDetails:`Masquer les détails`},passwordGate:{title:`Entrez le mot de passe d'accès`,description:`Une vérification du mot de passe est requise avant d'accéder à l'application.`,passwordLabel:`Mot de passe d'accès`,passwordPlaceholder:`Entrez le mot de passe d'accès`,submit:`Vérifier et continuer`,validation:{required:`Veuillez entrer le mot de passe d'accès`,verifyFailed:`Échec de la vérification du mot de passe`}},notifications:{toolApproval:{title:`Approbation requise : {{tool}}`,body:`L'outil {{tool}} nécessite votre approbation avant exécution`,unknownTool:`Outil inconnu`},contextPressure:{title:`Fenêtre de contexte presque épuisée`},backgroundTask:{completedTitle:`Tâche en arrière-plan terminée`,completedBody:`« {{title}} » est terminé`,completedFallback:`Une tâche en arrière-plan est terminée`},clarification:{title:`Bodhi AI attend votre réponse`,fallbackBody:`L'agent attend une réponse à une question`},conversationSummarized:`Conversation résumée : {{messages}} messages compressés, {{tokens}} jetons économisés`,allTasksCompleted:`Toutes les tâches sont terminées ! Tours totaux : {{rounds}}, Appels d'outils : {{toolCalls}}`,evaluatingTasks:`Évaluation de {{count}} tâche(s)...`,evaluationCompleteUpdated:`Évaluation terminée : {{count}} tâche(s) mise(s) à jour.`,evaluationCompleteNoUpdates:`Évaluation terminée : aucune mise à jour nécessaire`}},commandPalette:{searchPlaceholder:`Rechercher sessions, paramètres et actions`,navigationHint:`Utilisez ↑↓ pour naviguer, Entrée pour ouvrir, Échap pour fermer.`,empty:`Aucune commande correspondante`,groups:{quickActions:`Actions rapides`,settings:`Paramètres système`},badges:{quickAction:`Action`,pinned:`Épinglé`,running:`En cours`,child:`Enfant`,childSession:`Session enfant`,rootSession:`Session`},actions:{newSession:`Créer une nouvelle session`,openProviderSettings:`Ouvrir les paramètres fournisseur`,openMcpSettings:`Ouvrir les paramètres MCP`,openWorkflowSettings:`Ouvrir les paramètres de flux de travail`,openSessionsSettings:`Ouvrir le moniteur de sessions`,openSchedulesSettings:`Ouvrir les planifications`},errors:{actionFailed:`Échec de la commande`}},setup:{welcome:{heading:`Bienvenue dans Bodhi`,description:`Bodhi est votre assistant de développement alimenté par l'IA. Configurez un fournisseur IA pour commencer, ou lancez-vous directement.`,providerHint:`Pour commencer à discuter, vous devez configurer un fournisseur IA (ex. OpenAI, Anthropic) avec une clé API.`,proxyHint:`Derrière un proxy d'entreprise ? Vous pouvez configurer les paramètres proxy plus tard dans Paramètres système > Réseau.`},button:{getStarted:`Commencer`,configureProvider:`Configurer le fournisseur`},complete:{title:`Tout est prêt !`,restartMessage:`Rechargement de l'application...`},error:{completeFailed:`Échec de la configuration. Veuillez réessayer.`}},onboarding:{welcome:{title:`Bienvenue dans Bodhi !`,description:`Bodhi est votre assistant de développement alimenté par l'IA. Faisons un rapide tour d'horizon.`},newSession:{title:`Nouvelle session`,description:`Cliquez ici pour démarrer une nouvelle session de chat avec l'assistant IA.`},taskTemplates:{title:`Modèles de tâches`,description:`Choisissez parmi des modèles prédéfinis : revue de code, investigation de bug, refactoring, etc.`},modelPicker:{title:`Sélection du modèle`,description:`Changez de modèle IA et de fournisseur à tout moment depuis ici.`},sidebar:{title:`Barre latérale des sessions`,description:`Recherchez, filtrez, épinglez et naviguez entre vos conversations.`},settings:{title:`Paramètres`,description:`Configurez les fournisseurs IA, proxy, mappages de modèles, serveurs MCP et plus encore.`}},common:{saveAnyway:`Enregistrer quand même`,parentDirectory:`Répertoire parent`,currentPath:`Chemin actuel\xA0:`,cancel:`Annuler`,ok:`OK`,apply:`Appliquer`,save:`Enregistrer`,delete:`Supprimer`,yes:`Oui`,no:`Non`,home:`Accueil`,download:`Télécharger`,directory:`Répertoire`,file:`Fichier`},chat:{workspace:{modalTitle:`Définir le chemin de l'espace de travail`,invalidTitle:`Chemin d'accès à l'espace de travail non valide`,issuesDetected:`Problèmes potentiels détectés avec le chemin de l'espace de travail\xA0:`,confirmSaveInvalid:`Voulez-vous toujours enregistrer ce chemin\xA0?`,errorEnterPath:`Veuillez saisir un chemin d'accès à l'espace de travail`,errorSaveFailed:`Échec de l'enregistrement du chemin de l'espace de travail`,placeholder:`par ex. /Utilisateurs/alice/Espace de travail/MonProjet`,browseFolder:`Parcourir le dossier`,descriptionTitle:`Description du chemin de l'espace de travail`,descriptionP1:`Définissez un chemin d'accès à l'espace de travail afin que les références de fichiers et les outils de l'espace de travail puissent résoudre les fichiers de manière fiable.`,descriptionP2:`Choisissez un dossier de projet existant. Vous pouvez toujours continuer avec un chemin non valide, mais les fonctionnalités associées risquent de ne pas fonctionner correctement.`,checkTitle:`Vérification du chemin de l'espace de travail`,checkDescription:`La validation du chemin de l'espace de travail a échoué.`,label:`Espace de travail`,folderSelected:`Dossier sélectionné avec succès`},folderBrowser:{title:`Sélectionnez le dossier de l'espace de travail`,selectCurrent:`Sélectionnez le dossier actuel`,emptyFolder:`Ce dossier est vide`,tip:`Astuce\xA0:\xA0cliquez sur un dossier pour y accéder, cliquez sur "Sélectionner le dossier actuel" pour confirmer`,readFolderError:`Impossible de lire le dossier`},input:{placeholder:`Envoyer un message...`,placeholderWithReference:`Envoyer un message (inclut la référence)`,placeholderWithWorkflows:`Envoyer un message... (saisissez '/' pour les workflows)`,toolCallsOnly:`Appels d'outils uniquement (outils autorisés\xA0: {{tools}})`,autoPrefixMode:`Mode de préfixe automatique\xA0: {{prefix}} (saisissez «\xA0/\xA0» pour sélectionner les outils)`,toolSpecificMode:`Mode spécifique à l'outil (outils autorisés\xA0: {{tools}})`,processingFiles:`Traitement des fichiers…`,imageCountSingular:`Image {{count}}`,imageCountPlural:`Images {{count}}`,reasoning:{max:`Max`}},actions:{regenerate:`Régénérer la réponse`,retryFailed:`Réessayer la demande ayant échoué`,retryOptions:`Options de nouvelle tentative`,cancelRequest:`Annuler la demande`,sendMessage:`Envoyer un message`,copyMessage:`Copier le message`,referenceMessage:`Message de référence`,generateTitle:`Générer un titre IA`,unpin:`Détacher`,pin:`Épingler`},fileReference:{title:`@ Référence du fichier`,setWorkspace:`Définir l'espace de travail`,noMatches:`Aucun fichier correspondant trouvé`,emptyDirectory:`Le répertoire est vide`},commandSelector:{types:{mcp:`MCP`}},streaming:{assistant:`Assistant`}},settings:{configTab:{toolsLoadFailed:`Échec du chargement des outils disponibles`,toolsReloadSuccess:`Liste d'outils rechargée`,toolsSaveSuccess:`Paramètres de l'outil enregistrés avec succès`,toolsSaveFailed:`Échec de l'enregistrement des paramètres de l'outil`,languageHindi:`Hindi`,backendUrlEmpty:`L'URL du back-end ne peut pas être vide`,backendUrlInvalidProtocol:`L'URL du back-end doit commencer par http:// ou https://`,backendUrlInvalidUrl:`L'URL du back-end n'est pas une URL valide`,backendUrlMustEndWithV1:`L'URL du back-end doit se terminer par "/v1"`,accessPassword:{validation:{currentPasswordRequired:`Veuillez entrer le mot de passe actuel`,newPasswordRequired:`Veuillez entrer un nouveau mot de passe`,confirmPasswordRequired:`Veuillez entrer le nouveau mot de passe à nouveau`,minLength:`Le mot de passe doit contenir au moins 4 caractères`,passwordMismatch:`Les mots de passe ne correspondent pas`}}},modelLimits:{placeholders:{vendor:`OpenAI / Google / Moonshot`},columns:{notes:`Notes`,actions:`Actions`}},systemPromptManager:{title:`Gestion des prompts système`,addButton:`Ajouter un prompt`,defaultPromptLocked:`Les prompts système par défaut sont verrouillés et ne peuvent pas être modifiés.`,updateSuccess:`Prompt mis à jour avec succès`,addSuccess:`Prompt ajouté avec succès`,saveError:`Échec de l'enregistrement du prompt. Veuillez réessayer.`,deleteSuccess:`Prompt supprimé avec succès`,deleteError:`Échec de la suppression du prompt. Veuillez réessayer.`,deleteConfirm:`Êtes-vous sûr de supprimer ce prompt ?`,defaultTag:`Par défaut (verrouillé)`,editTitle:`Modifier le prompt système`,addTitle:`Ajouter un nouveau prompt système`,nameLabel:`Nom du prompt`,nameRequired:`Veuillez saisir le nom du prompt !`,descriptionLabel:`Description du prompt`,descriptionRequired:`Veuillez saisir la description du prompt !`,contentLabel:`Contenu du prompt`,contentRequired:`Veuillez saisir le contenu du prompt !`},envVars:{title:`Variables d'environnement`,description:`Les variables sont injectées dans les processus de l'outil Bash. Les variables secrètes sont chiffrées au repos.`,fetchError:`Échec du chargement des variables d'environnement`,created:`Variable créée`,updated:`Variable mise à jour`,saveError:`Échec de l'enregistrement de la variable`,deleted:`Variable supprimée`,deleteError:`Échec de la suppression de la variable`,addButton:`Ajouter une variable`,noVars:`Aucune variable d'environnement configurée`,addTitle:`Ajouter une variable d'environnement`,editTitle:`Modifier une variable`,nameRequired:`Le nom de la variable est obligatoire`,nameInvalid:`Doit commencer par une lettre ou un trait de soulignement, suivi de lettres, de chiffres ou de traits de soulignement`,valueRequired:`La valeur est requise pour les nouvelles variables`,valueEditHint:`Laisser vide pour conserver la valeur existante`,valuePlaceholder:`Entrez la valeur`,valuePlaceholderEdit:`Entrez une nouvelle valeur ou laissez vide`,secretHint:`Les variables secrètes sont chiffrées sur le disque et masquées dans l'interface utilisateur`,descriptionPlaceholder:`Description facultative`,deleteConfirm:`Supprimer cette variable\xA0?`,notSet:`(non réglé)`,empty:`(vide)`,save:`Enregistrer`,cancel:`Annuler`,name:`Nom`,value:`Valeur`,secret:`Secrète`,descriptionField:`Description`,type:`Type`,plain:`Texte brut`,descriptionCol:`Description`,actions:`Actions`,yes:`Oui`,no:`Non`},hooksTab:{mode:{ocr:`OCR (Windows)`,vision:`Vision (LLM)`,placeholder:`Placeholder`},modeLabel:`Mode`},providerTab:{fastModel:`Modèle rapide (facultatif)`,fastModelHelp:`Modèle moins cher/plus rapide pour les tâches légères telles que la génération de titres, la correction Mermaid et la synthèse. Utilise le modèle par défaut lorsqu'il n'est pas défini.`,visionModel:`Modèle de vision (facultatif)`,visionModelHelp:`Modèle capable de vision pour la compréhension des images. Lorsque hooks.image_fallback.mode est défini sur «\xA0vision\xA0», ce modèle décrit les images sous forme de texte afin que les modèles contenant uniquement du texte puissent les comprendre. Utilise le modèle par défaut lorsqu'il n'est pas défini.`,sameAsDefault:`Identique au modèle par défaut`,providerNames:{openai:`OpenAI`,anthropic:`Anthropic`,gemini:`Gemini`,copilot:`Copilot`}},mcpTab:{statusHelp:{connecting:`Le serveur démarre ou se reconnecte`,ready:`Le serveur est connecté et sert les outils normalement`,degraded:`Le serveur est partiellement disponible\xA0; certains outils peuvent échouer`,stopped:`Le serveur ne fonctionne pas`,error:`Le serveur n'a pas pu démarrer ou a rencontré des erreurs d'exécution`}},metricsDashboard:{sessionsCount:`{{count}} sessions`,tokensAmount:`{{value}} jetons`,sessionsTabLabel:`Sessions ({{count}})`,roundColumns:{tokens:`Jetons`},multiplierSuffix:`x`,sessionDetail:{messages:`Messages`}},page:{tabs:{prompts:`Prompts`,mermaid:`Mermaid`,mcp:`MCP`,sessions:`Sessions`,hooks:`Hooks`}},appTab:{languageHindi:`Hindi`},modelMappingCard:{modelTypeOpus:`Opus`,modelTypeSonnet:`Sonnet`,modelTypeHaiku:`Haïku`},mermaidTab:{switchAuto:`Auto`,flowchartCurveOptions:{cardinal:`Cardinal`}},schedulesTab:{columns:{actions:`Actions`},actions:{sessions:`Sessions`},triggerTypes:{interval:`Intervalle`,daily:`Quotidien`,weekly:`Hebdomadaire`,monthly:`Mensuel`,cron:`Cron`},weekdays:{mon:`Lun`,tue:`Mar`,wed:`Mer`,thu:`Jeu`,fri:`Ven`,sat:`Sam`,sun:`Dim`},statusLabels:{running:`En cours`,queued:`En file d'attente`,failing:`En échec`,disabled:`Désactivé`,healthy:`Sain`,idle:`Inactif`},statusDetails:{active:`{{count}} actif(s)`,pending:`{{count}} en attente`,consecutiveFailures:`{{count}} échecs consécutifs`,lastRunSucceeded:`Dernière exécution réussie`},activityLabels:{queued:`En file : {{count}}`,running:`En cours : {{count}}`,ok:`OK : {{count}}`,fail:`Échec : {{count}}`}},sessionsTab:{id:`Identifiant`},mcpServerTable:{columns:{actions:`Actions`},transportOptions:{sse:`SSE`,stdio:`Stdio`}},mcpServerForm:{modeJson:`JSON`,transportOptions:{stdio:`Stdio`,sse:`SSE`},arguments:`Arguments`},metricsTable:{session:{columns:{session:`Session`,tokens:`Jetons`,messages:`Messages`,action:`Action`}},forward:{columns:{id:`Identifiant`,type:`Type`,tokens:`Jetons`}}},charts:{total:`Total`,prompt:`Prompt`,chat:`Chat`}},components:{markdown:{codeCopiedSuccess:`Code copié dans le presse-papier`,copyFailed:`Échec de la copie`},jsonSchema:{noProperties:`Aucune propriété dans le schéma`,field:`Champ`,type:`Type`,required:`Requis`,yes:`Oui`,no:`Non`,default:`Défaut`,description:`Description`},imageGrid:{ocr:`OCR`},tokenUsage:{messages:`Messages`,tokens:`jetons`},approval:{workflow:`Flux de travail`}}},ka={app:{errorBoundary:{title:`कुछ गलत हो गया`,description:`इस अनुभाग में एक अप्रत्याशित त्रुटि हुई। आप पुनः प्रयास कर सकते हैं या समस्या बनी रहने पर पृष्ठ पुनः लोड कर सकते हैं।`,tryAgain:`पुनः प्रयास करें`,showDetails:`विवरण दिखाएँ`,hideDetails:`विवरण छिपाएँ`},passwordGate:{title:`एक्सेस पासवर्ड दर्ज करें`,description:`एप्लिकेशन में प्रवेश करने से पहले पासवर्ड सत्यापन आवश्यक है।`,passwordLabel:`एक्सेस पासवर्ड`,passwordPlaceholder:`एक्सेस पासवर्ड दर्ज करें`,submit:`सत्यापित करें और जारी रखें`,validation:{required:`कृपया एक्सेस पासवर्ड दर्ज करें`,verifyFailed:`पासवर्ड सत्यापन विफल`}},notifications:{toolApproval:{title:`अनुमोदन आवश्यक: {{tool}}`,body:`टूल {{tool}} को निष्पादित करने के लिए आपकी मंजूरी चाहिए`,unknownTool:`अज्ञात टूल`},contextPressure:{title:`कॉन्टेक्स्ट विंडो लगभग भर गई है`},backgroundTask:{completedTitle:`बैकग्राउंड टास्क पूरा हुआ`,completedBody:`「{{title}}」 पूरा हुआ`,completedFallback:`बैकग्राउंड टास्क पूरा हुआ`},clarification:{title:`Bodhi AI आपका जवाब दे रहा है`,fallbackBody:`एजेंट एक सवाल का जवाब दे रहा है`},conversationSummarized:`वार्तालाप सारांशित: {{messages}} संदेश संपीड़ित, {{tokens}} टोकन बचाए गए`,allTasksCompleted:`सभी कार्य पूरे हुए! कुल राउंड: {{rounds}}, टूल कॉल: {{toolCalls}}`,evaluatingTasks:`{{count}} कार्यों का मूल्यांकन हो रहा है...`,evaluationCompleteUpdated:`मूल्यांकन पूर्ण: {{count}} कार्य अद्यतन किए गए।`,evaluationCompleteNoUpdates:`मूल्यांकन पूर्ण: कोई अद्यतन आवश्यक नहीं`}},common:{saveAnyway:`फिर भी सहेजें`,parentDirectory:`मूल निर्देशिका`,currentPath:`वर्तमान पथ:`,cancel:`रद्द करें`,ok:`ठीक है`,apply:`लागू करें`,save:`सहेजें`,delete:`हटाएँ`,yes:`हाँ`,no:`नहीं`,home:`होम`,download:`डाउनलोड करें`,directory:`निर्देशिका`,file:`फ़ाइल`},chat:{workspace:{placeholder:`जैसे /उपयोगकर्ता/ऐलिस/वर्कस्पेस/मायप्रोजेक्ट`,descriptionP1:`एक वर्कस्पेस पथ सेट करें ताकि फ़ाइल संदर्भ और वर्कस्पेस उपकरण फ़ाइलों को विश्वसनीय रूप से हल कर सकें।`,descriptionP2:`कोई मौजूदा प्रोजेक्ट फ़ोल्डर चुनें. आप अभी भी अमान्य पथ के साथ जारी रख सकते हैं, लेकिन हो सकता है कि संबंधित सुविधाएं ठीक से काम न करें।`},folderBrowser:{title:`वर्कस्पेस फ़ोल्डर चुनें`,selectCurrent:`वर्तमान फ़ोल्डर का चयन करें`,emptyFolder:`यह फ़ोल्डर खाली है`,tip:`युक्ति: दर्ज करने के लिए किसी फ़ोल्डर पर क्लिक करें, पुष्टि करने के लिए "वर्तमान फ़ोल्डर का चयन करें" पर क्लिक करें`},actions:{regenerate:`प्रतिक्रिया पुनः उत्पन्न करें`,retryFailed:`विफल अनुरोध पुनः प्रयास करें`,retryOptions:`पुनः प्रयास विकल्प`,cancelRequest:`अनुरोध को रद्द करें`,sendMessage:`संदेश भेजें`,copyMessage:`संदेश कॉपी करें`,referenceMessage:`संदर्भ संदेश`,generateTitle:`AI शीर्षक उत्पन्न करें`,unpin:`अनपिन`,pin:`नत्थी करें`},fileReference:{title:`@फ़ाइल संदर्भ`,setWorkspace:`वर्कस्पेस सेट करें`,noMatches:`कोई मेल खाती फ़ाइलें नहीं मिलीं`,emptyDirectory:`निर्देशिका खाली है`},commandSelector:{types:{mcp:`MCP`}}},settings:{notifications:{deleteAllSuccess:`सभी सत्र हटा दिए गए (पिन किए गए को छोड़कर)`,deleteEmptySuccess:`खाली सत्र हटा दिए गए (पिन किए गए को छोड़कर)`,localStorageCleared:`स्थानीय भंडारण साफ़ कर दिया गया है`,resetSuccessReloading:`एप्लिकेशन रीसेट सफल. पुनः लोड हो रहा है...`,resetFailed:`एप्लिकेशन रीसेट करने में विफल`,autoTitleEnabled:`स्वतः शीर्षक निर्माण सक्षम`,autoTitleDisabled:`स्वतः शीर्षक निर्माण अक्षम`,autoTitleUpdateFailed:`स्वतः शीर्षक प्राथमिकता अद्यतन करने में विफल`,promptEnhancementSaved:`सिस्टम प्रॉम्प्ट एन्हांसमेंट सहेजा गया`},appTab:{deleteAllTitle:`सभी सत्र हटाएँ`,deleteAllDescription:`क्या आपको यकीन है? इससे पिन किए गए को छोड़कर सभी सत्र हटा दिए जाएंगे.`,deleteAllButton:`सभी सत्र हटाएँ`,deleteEmptyTitle:`खाली सत्र हटाएँ`,deleteEmptyDescription:`क्या आपको यकीन है? इससे बिना किसी संदेश वाले (पिन किए गए को छोड़कर) सभी सत्र हटा दिए जाएंगे।`,deleteEmptyButton:`खाली सत्र हटाएँ`,clearLocalStorageTitle:`स्थानीय संग्रहण साफ़ करें`,clearLocalStorageDescription:`क्या आपको यकीन है? यह सभी स्थानीय संग्रहण डेटा को हटा देगा और एप्लिकेशन को रीसेट कर देगा।`,clearLocalStorageButton:`स्थानीय संग्रहण साफ़ करें`,confirmDeleteAll:`हाँ, सभी हटा दें`,confirmDeleteEmpty:`हां, खाली हटाएं`,confirmClear:`हाँ, इसे साफ़ करें`,dangerDescription:`इन कार्रवाइयों को पूर्ववत नहीं किया जा सकता. सारा डेटा स्थायी रूप से हटा दिया जाएगा.`,resetApplicationTitle:`एप्लिकेशन रीसेट करें`,resetApplicationIntro:`क्या आपको यकीन है? यह करेगा:`,resetStepDeleteAllSessions:`सभी सत्र हटाएं (पिन किए गए सहित)`,resetStepClearStorage:`सभी स्थानीय संग्रहण डेटा साफ़ करें`,resetStepResetConfig:`config.json को डिफ़ॉल्ट पर रीसेट करें`,resetStepSetupFlow:`अगले लॉन्च पर प्रारंभिक सेटअप प्रवाह ट्रिगर करें`,resetStepReload:`एप्लिकेशन पुनः लोड करें`,resetConfirm:`हाँ, सब कुछ रीसेट करें`,resetButton:`एप्लिकेशन रीसेट करें (सभी डेटा)`},configTab:{loadConfigFailed:`कॉन्फ़िगरेशन लोड करने में विफल`,invalidConfig:`अमान्य कॉन्फ़िगरेशन`,saveConfigSuccess:`कॉन्फ़िगरेशन सफलतापूर्वक सहेजा गया`,saveConfigFailed:`कॉन्फ़िगरेशन सहेजने में विफल`,toolsLoadFailed:`उपलब्ध उपकरण लोड करने में विफल`,toolsReloadSuccess:`टूल सूची पुनः लोड की गई`,toolsSaveSuccess:`टूल सेटिंग सफलतापूर्वक सहेजी गईं`,toolsSaveFailed:`टूल सेटिंग सहेजने में विफल`,backendSaved:`बैकएंड URL सहेजा गया`,backendResetDefault:`बैकएंड URL डिफ़ॉल्ट पर रीसेट हो गया`,backendUrlEmpty:`बैकएंड URL खाली नहीं हो सकता`,backendUrlInvalidProtocol:`बैकएंड URL http:// या https:// से शुरू होना चाहिए`,backendUrlInvalidUrl:`बैकएंड URL एक मान्य URL नहीं है`,backendUrlMustEndWithV1:`बैकएंड URL को "/v1" पर समाप्त होना चाहिए`,accessPassword:{validation:{currentPasswordRequired:`कृपया वर्तमान पासवर्ड दर्ज करें`,newPasswordRequired:`कृपया नया पासवर्ड दर्ज करें`,confirmPasswordRequired:`कृपया नया पासवर्ड दोबारा दर्ज करें`,minLength:`पासवर्ड कम से कम 4 अक्षरों का होना चाहिए`,passwordMismatch:`पासवर्ड मेल नहीं खाते`}}},modelMappingCard:{loadProviderFailed:`प्रदाता कॉन्फ़िगरेशन लोड करने में विफल`,loadMappingsFailed:`मौजूदा मैपिंग लोड करने में विफल`,loadModelsFailed:`मॉडल लोड करने में विफल`,loadModelsHint:`मॉडल लोड करने में विफल. कृपया अपने प्रदाता कॉन्फ़िगरेशन की जाँच करें।`,mappingSaved:`मॉडल मैपिंग सहेजी गई`,mappingSaveFailed:`मॉडल मैपिंग सहेजने में विफल`,enterModelName:`कृपया एक मॉडल नाम दर्ज करें`,customMappingSaved:`कस्टम मॉडल मैपिंग सहेजी गई`,customMappingSaveFailed:`कस्टम मॉडल मैपिंग सहेजने में विफल`,mappedModelNotFound:`मैप किया गया मॉडल "{{model}}" वर्तमान प्रदाता के उपलब्ध मॉडल में नहीं मिला`,cached:`(कैश्ड)`,modelTypeOpus:`Opus`,modelTypeSonnet:`Sonnet`,modelTypeHaiku:`Haiku`},modelTab:{selectModelTitle:`मॉडल का चयन करें`,loadingModels:`मॉडल लोड हो रहे हैं...`,selectModelPlaceholder:`एक मॉडल चुनें`,backendApiBaseUrlTitle:`बैकएंड API बेस URL`,resetToDefault:`डिफ़ॉल्ट पर रीसेट करें`,backendApiHint:`/v1 (उदा. {{example}}) सहित पूर्ण आधार URL होना चाहिए।`,save:`सहेजें`},mermaidTab:{title:`Mermaid आरेख सेटिंग्स`,description:`अनुकूलित करें कि आपकी चैट में Mermaid आरेख कैसे प्रस्तुत किए जाते हैं`,themeLabel:`Mermaid थीम`,themeTooltip:`एक अंतर्निर्मित Mermaid थीम चुनें। ऐप थीम के आधार पर प्रकाश और अंधेरे के बीच डिफ़ॉल्ट और न्यूट्रल ऑटो-स्विच।`,themeOptions:{default:`डिफ़ॉल्ट (स्वतः लाइट/डार्क)`,neutral:`तटस्थ (स्वतः लाइट/डार्क)`,forest:`वन (हरा थीम)`,base:`आधार (न्यूनतम)`,dark:`अँधेरा`},themeDescriptionsTitle:`थीम डिस्क्रिप्शन:`,themeDescriptions:{default:`डिफ़ॉल्ट: क्लासिक Mermaid लुक, प्रकाश/अंधेरे में स्वतः अनुकूलित`,neutral:`तटस्थ: ग्रे टोन, प्रकाश/अंधेरे के लिए स्वतः अनुकूलित`,dark:`डार्क: हमेशा डार्क थीम`,forest:`वन: हरा रंग योजना, तकनीकी आरेखों के लिए उपयुक्त`,base:`आधार: अनुकूलित थीम के लिए न्यूनतम शैली`},globalCardTitle:`वैश्विक सेटिंग्स`,fontSizeLabel:`फ़ॉन्ट आकार`,fontSizeTooltip:`सभी आरेख पाठ के लिए आधार फ़ॉन्ट आकार (पिक्सेल में)`,defaultZoomLabel:`डिफ़ॉल्ट ज़ूम`,defaultZoomTooltip:`आरेखों के लिए प्रारंभिक ज़ूम स्तर (1.0 = 100%)`,responsiveWidthLabel:`प्रतिक्रियाशील चौड़ाई`,responsiveWidthTooltip:`आरेखों को कंटेनर की चौड़ाई के अनुकूल बनाने में सक्षम करें। निश्चित-चौड़ाई वाले आरेखों के लिए अक्षम करें.`,flowchartCardTitle:`Flowchart सेटिंग्स`,flowchartNodeSpacingLabel:`नोड रिक्ति`,flowchartNodeSpacingTooltip:`नोड्स के बीच क्षैतिज दूरी`,flowchartRankSpacingLabel:`रैंक रिक्ति`,flowchartRankSpacingTooltip:`परतों के बीच लंबवत दूरी`,flowchartCurveTypeLabel:`वक्र प्रकार`,flowchartCurveTypeTooltip:`कनेक्शन के लिए वक्र का प्रकार`,flowchartCurveOptions:{basis:`Basis (स्मूथ)`,linear:`रेखीय`,cardinal:`Cardinal`},sequenceCardTitle:`Sequence Diagram सेटिंग्स`,sequenceActorMarginLabel:`एक्टर मार्जिन`,sequenceActorMarginTooltip:`एक्टरों के बीच अंतर`,sequenceMessageMarginLabel:`संदेश मार्जिन`,sequenceMessageMarginTooltip:`संदेश के बीच अंतर`,sequenceActorWidthLabel:`एक्टर चौड़ाई`,sequenceActorWidthTooltip:`प्रत्येक एक्टर बॉक्स की चौड़ाई`,sequenceActorHeightLabel:`एक्टर की ऊंचाई`,sequenceActorHeightTooltip:`प्रत्येक एक्टर बॉक्स की ऊंचाई`,ganttCardTitle:`Gantt चार्ट सेटिंग्स`,ganttBarHeightLabel:`बार की ऊंचाई`,ganttBarHeightTooltip:`प्रत्येक कार्य पट्टी की ऊंचाई`,ganttTopPaddingLabel:`शीर्ष गद्दी`,ganttTopPaddingTooltip:`चार्ट के शीर्ष पर स्थान`,resetToDefaults:`डिफ़ॉल्ट पर पुनः सेट करें`,previewDescription:`परिवर्तन तुरंत लागू होते हैं. अपनी सेटिंग्स को क्रियान्वित होते देखने के लिए एक आरेख बनाने या देखने का प्रयास करें।`,themeCardTitle:`विषय`,switchAuto:`ऑटो`,switchFixed:`तय`,previewTitle:`पूर्व दर्शन`},modelLimits:{title:`टोकन बजट मॉडल सीमाएँ`,descriptionPrefix:`संदर्भ बजटिंग के लिए प्रति-मॉडल टोकन सीमाएं कॉन्फ़िगर करें। ये सेटिंग्स Bamboo में विश्व स्तर पर कायम हैं`,descriptionSuffix:`और बैकएंड रिज़ॉल्वर द्वारा उपयोग किया जाता है।`,defaultsTitle:`मॉडल डिफ़ॉल्ट`,defaultsDescription:`GPT-5 / GPT-4 / Gemini / Kimi / GLM डिफ़ॉल्ट के साथ प्रीलोडेड। आप आवश्यकतानुसार संपादन जारी रख सकते हैं।`,migratedFromLocalStorage:`स्थानीय भंडारण से वैश्विक कॉन्फिगरेशन में स्थानांतरित मॉडल सीमाएँ।`,loadFailed:`मॉडल सीमा सेटिंग लोड करने में विफल`,saveSuccess:`मॉडल सीमाएँ वैश्विक कॉन्फ़िगरेशन में सहेजी गईं`,saveFailed:`मॉडल सीमा सेटिंग सहेजने में विफल`,resetSuccess:`मॉडल सीमाएँ उत्पाद डिफ़ॉल्ट पर रीसेट हो गईं`,resetFailed:`मॉडल सीमा सेटिंग रीसेट करने में विफल`,defaults:{gpt54:`तर्क की गहराई के साथ शीर्ष स्तरीय क्षमता।`,gpt53Codex:`कोड रीफैक्टरिंग वर्कफ़्लोज़ के लिए अनुकूलित।`,gpt52Pro:`जटिल कार्यों के लिए मजबूत तार्किक स्थिरता।`,gpt5Mini:`तेज़ और लागत प्रभावी सामान्य प्रयोजन विकल्प।`,gpt41:`1M विंडो वाला क्लासिक बड़े-संदर्भ वाला मॉडल।`,gpt4o:`कम विलंबता, रोजमर्रा की चैट के लिए उपयुक्त।`,gemini25Pro:`मजबूत मल्टीमॉडल विश्लेषण क्षमताएं।`,kimiK25:`दीर्घ-रूप वाली चीनी सामग्री के लिए पसंदीदा।`,kimiCoding:`कोडिंग-केंद्रित परिदृश्यों के लिए ट्यून किया गया।`,glm5:`एक-शॉट बड़े-दस्तावेज़ निर्माण के लिए अच्छा है।`},columns:{contextWindow:`Context Window`,maxOutput:`अधिकतम आउटपुट`,model:`मॉडल`,notes:`टिप्पणियाँ`,actions:`कार्रवाई`},placeholders:{vendor:`OpenAI/Google/Moonshot`,model:`जैसे gpt-5.4-think`,optional:`वैकल्पिक`},actions:{addRow:`लाइन जोड़ें`,resetToDefaults:`डिफ़ॉल्ट पर पुनः सेट करें`,remove:`निकालें`,save:`सहेजें`,reload:`पुनः लोड करें`},validation:{atLeastOneRow:`कृपया कम से कम एक मॉडल सीमा पंक्ति रखें।`,modelPatternEmpty:`मॉडल पैटर्न खाली नहीं हो सकता.`,duplicateModelPattern:`डुप्लिकेट मॉडल पैटर्न: {{pattern}}`,contextWindowMin:`{{pattern}} के लिए संदर्भ विंडो कम से कम 1000 होनी चाहिए।`,maxOutputMin:`{{pattern}} के लिए अधिकतम आउटपुट कम से कम 1 होना चाहिए।`,maxOutputExceedsContext:`{{pattern}} के लिए अधिकतम आउटपुट संदर्भ विंडो से कम या उसके बराबर होना चाहिए।`,safetyMarginNegative:`{{pattern}} के लिए सुरक्षा मार्जिन नकारात्मक नहीं हो सकता।`,safetyMarginTooLarge:`{{pattern}} के लिए सुरक्षा मार्जिन संदर्भ विंडो से छोटा होना चाहिए।`}},systemPromptManager:{title:`सिस्टम प्रॉम्प्ट प्रबंधन`,addButton:`प्रॉम्प्ट जोड़ें`,defaultPromptLocked:`डिफ़ॉल्ट सिस्टम प्रॉम्प्ट लॉक हैं और संपादित नहीं किए जा सकते।`,updateSuccess:`प्रॉम्प्ट सफलतापूर्वक अद्यतन किया गया`,addSuccess:`प्रॉम्प्ट सफलतापूर्वक जोड़ा गया`,saveError:`प्रॉम्प्ट सहेजने में विफल. कृपया पुन: प्रयास करें।`,deleteSuccess:`प्रॉम्प्ट सफलतापूर्वक हटा दिया गया`,deleteError:`प्रॉम्प्ट हटाने में विफल. कृपया पुन: प्रयास करें।`,deleteConfirm:`क्या आप निश्चित रूप से इस प्रॉम्प्ट को हटाना चाहते हैं?`,defaultTag:`डिफ़ॉल्ट (लॉक)`,editTitle:`सिस्टम प्रॉम्प्ट संपादित करें`,addTitle:`नया सिस्टम प्रॉम्प्ट जोड़ें`,nameLabel:`प्रॉम्प्ट नाम`,nameRequired:`कृपया प्रॉम्प्ट का नाम इनपुट करें!`,descriptionLabel:`प्रॉम्प्ट डिस्क्रिप्शन`,descriptionRequired:`कृपया प्रॉम्प्ट का डिस्क्रिप्शन दर्ज करें!`,contentLabel:`प्रॉम्प्ट सामग्री`,contentRequired:`कृपया प्रॉम्प्ट की सामग्री इनपुट करें!`},envVars:{title:`एनवायरमेंट वेरिएबल्स`,description:`वैरिएबल को Bash टूल प्रक्रियाओं में इंजेक्ट किया जाता है। गुप्त चर आराम से एन्क्रिप्ट किए गए हैं।`,fetchError:`एनवायरमेंट वेरिएबल्स लोड करने में विफल`,created:`वेरिएबल बनाया गया`,updated:`वेरिएबल अद्यतन किया गया`,saveError:`वेरिएबल सहेजने में विफल`,deleted:`वेरिएबल हटा दिया गया`,deleteError:`वेरिएबल हटाने में विफल`,addButton:`वेरिएबल जोड़ें`,noVars:`कोई एनवायरमेंट वेरिएबल कॉन्फ़िगर नहीं किया गया`,addTitle:`एनवायरमेंट वेरिएबल जोड़ें`,editTitle:`वेरिएबल संपादित करें`,nameRequired:`वेरिएबल नाम आवश्यक है`,nameInvalid:`एक अक्षर या अंडरस्कोर से शुरू होना चाहिए, उसके बाद अक्षर, अंक या अंडरस्कोर होना चाहिए`,valueRequired:`नए वेरिएबल के लिए मान आवश्यक है`,valueEditHint:`मौजूदा मान बनाए रखने के लिए खाली छोड़ें`,valuePlaceholder:`मान दर्ज करें`,valuePlaceholderEdit:`नया मान दर्ज करें या खाली छोड़ दें`,secretHint:`गुप्त चर डिस्क पर एन्क्रिप्ट किए गए हैं और यूआई में छिपाए गए हैं`,descriptionPlaceholder:`वैकल्पिक डिस्क्रिप्शन`,deleteConfirm:`यह वेरिएबल हटाएं?`,notSet:`(सेट नहीं)`,empty:`(खाली)`,save:`सहेजें`,cancel:`रद्द करें`,name:`नाम`,value:`वैल्यू`,secret:`गुप्त`,descriptionField:`डिस्क्रिप्शन`,type:`प्रकार`,plain:`सादा`,descriptionCol:`डिस्क्रिप्शन`,actions:`कार्रवाई`,yes:`हाँ`,no:`नहीं`},promptsTab:{title:`सिस्टम प्रॉम्प्ट एन्हांसमेंट`,mermaidEnhancement:`Mermaid एन्हांसमेंट`,taskListRules:`साझा कार्य नियम`,copilotConclusionWithOptionsBeforeFinish:`समाप्त होने से पहले Copilot ने उपयोगकर्ता से पूछा`,enhancementPlaceholder:`प्रत्येक सिस्टम प्रॉम्प्ट में जोड़ने के लिए वैश्विक एन्हांसमेंट टेक्स्ट जोड़ें।`,saveEnhancement:`एन्हांसमेंट सहेजें`,description:`प्रत्येक अनुरोध भेजे जाने से पहले इस पाठ को पहले जोड़ा जाता है, उसके बाद सक्षम सिस्टम एन्हांसमेंट जोड़ा जाता है।`,switchOn:`पर`,switchOff:`बंद`},hooksTab:{title:`छवि हुक`,enableImagePreflight:`छवि प्रीफ़्लाइट हुक सक्षम करें`,description:`प्लेसहोल्डर मोड छवियों को पाठ सारांश में फिर से लिखता है (यह उन टूल को तोड़ सकता है जो वास्तविक छवि डेटा की अपेक्षा करते हैं)। OCR वर्तमान में केवल विंडोज़ है।`,loadFailed:`हुक सेटिंग्स लोड करने में विफल`,updateFailed:`हुक अद्यतन करने में विफल`,modeUpdateFailed:`हुक मोड अपडेट करने में विफल`,enabled:`छवि हुक सक्षम`,disabled:`छवि हुक अक्षम किए गए`,modeUpdated:`इमेज हुक मोड इस पर सेट है: {{mode}}`,mode:{ocr:`OCR (Windows)`,vision:`Vision (LLM)`,placeholder:`प्लेसहोल्डर`,error:`त्रुटि`},modeLabel:`मोड`},schedulesTab:{triggerTypes:{interval:`अंतराल`,daily:`दैनिक`,weekly:`साप्ताहिक`,monthly:`मासिक`,cron:`Cron`},loadFailed:`शेड्यूल लोड करने में विफल`,loadSessionsFailed:`शेड्यूल सत्र लोड करने में विफल`,createFailed:`शेड्यूल बनाने में विफल`,updateFailed:`शेड्यूल अपडेट करने में विफल`,deleteFailed:`शेड्यूल हटाने में विफल`,runNowFailed:`शेड्यूल चलाने में विफल`,taskMessageRequired:`ऑटो एक्ज़ीक्यूट सक्षम होने पर कार्य संदेश आवश्यक है`,created:`शेड्यूल बनाया गया`,updated:`शेड्यूल अपडेट किया गया`,deleted:`हटाया गया शेड्यूल`,enqueuedRun:`कतार में जोड़ा गया`,optional:`(वैकल्पिक)`,defaultName:`मेरी अनुसूची`,createTitle:`शेड्यूल बनाएं`,scheduleSessionsTitle:`सत्र अनुसूची`,noSessionsYet:`अभी तक कोई सत्र नहीं.`,editTitle:`शेड्यूल संपादित करें`,columns:{autoExecute:`स्वतः निष्पादित`,intervalSeconds:`अंतराल`,nextRun:`अगला रन`,lastRun:`आखरी बार`,name:`नाम`,model:`मॉडल`,enabled:`सक्रिय`,actions:`कार्रवाई`},form:{intervalSeconds:`अंतराल सेकंड`,taskMessage:`कार्य संदेश`,taskMessagePlaceholder:`(वैकल्पिक) चलाने के लिए एक कार्य`,modelPlaceholder:`(वैकल्पिक) उदा. gpt-4o-mini`,modelRequiredIfAuto:`यदि स्वतः निष्पादित हो तो आवश्यक है`,autoExecute:`स्वतः निष्पादित`,systemPrompt:`सिस्टम प्रॉम्प्ट`,workspacePath:`वर्कस्पेस पथ`,enhancePrompt:`प्रॉम्प्ट बढ़ाएँ`,name:`नाम`,enabled:`सक्रिय`,model:`मॉडल`},validation:{nameRequired:`नाम आवश्यक है`,intervalRequired:`अंतराल आवश्यक है`},actions:{runNow:`अब चलाएँ`,create:`बनाएं`,refresh:`ताज़ा करें`,edit:`संपादन करें`,sessions:`सत्र`,delete:`हटाएँ`,open:`खोलें`,save:`सहेजें`},yes:`हाँ`,no:`नहीं`,listTitle:`अनुसूचियों`,weekdays:{mon:`सोम`,tue:`मंगल`,wed:`बुध`,thu:`गुरु`,fri:`शुक्र`,sat:`शनि`,sun:`रवि`},statusLabels:{running:`चल रहा है`,queued:`कतार में`,failing:`विफल हो रहा है`,disabled:`अक्षम`,healthy:`स्वस्थ`,idle:`निष्क्रिय`},statusDetails:{active:`{{count}} सक्रिय`,pending:`{{count}} लंबित`,consecutiveFailures:`{{count}} लगातार विफलताएँ`,lastRunSucceeded:`अंतिम रन सफल रहा`},activityLabels:{queued:`कतार: {{count}}`,running:`चल रहे: {{count}}`,ok:`सफल: {{count}}`,fail:`विफल: {{count}}`}},sessionsTab:{currentSessionTitle:`वर्तमान सत्र`,clearMessages:`संदेश साफ़ करें`,clearMessagesTitle:`सत्र संदेश साफ़ करें`,clearMessagesContent:`यह वर्तमान सत्र के लिए संदेश/अनुलग्नक साफ़ करता है लेकिन सत्र प्रविष्टि रखता है।`,sessionCleared:`सत्र साफ़ हो गया`,noActiveSession:`कोई सक्रिय सत्र नहीं.`,bulkCleanupTitle:`थोक सफ़ाई`,keepPinned:`पिन किए रखें`,deleteAll:`सभी हटा दो`,deleteAllTitle:`सभी सत्र हटाएँ`,deleteAllKeepPinned:`पिन किए गए को छोड़कर सभी सत्र हटा देता है।`,deleteAllIncludePinned:`पिन किए गए सहित सभी सत्र हटा देता है।`,deleteEmpty:`रिक्त हटाएँ`,deleteEmptyTitle:`खाली सत्र हटाएँ`,deleteEmptyKeepPinned:`पिन किए गए को छोड़कर खाली सत्र हटा देता है।`,deleteEmptyIncludePinned:`पिन किए गए सहित खाली सत्र हटा देता है।`,deleteChildren:`बच्चों को हटाएँ`,deleteChildrenTitle:`बाल सत्र हटाएँ`,deleteChildrenKeepPinned:`पिन किए गए को छोड़कर सभी चाइल्ड सत्र हटा देता है।`,deleteChildrenIncludePinned:`पिन किए गए सहित सभी चाइल्ड सत्र हटा देता है।`,cleanupComplete:`सफ़ाई पूर्ण`,devResetTitle:`विकास रीसेट`,devResetDescription:`सत्र संग्रहण के लिए ग्रीनफ़ील्ड रीसेट (सत्र हटाता है/ और session.json रीसेट करता है)।`,devResetAction:`देव रीसेट सत्र`,devResetConfirmTitle:`सत्र संग्रहण रीसेट करें (डेव)`,devResetConfirmContent:`यह सभी सत्रों (पिन किए गए/चाइल्ड सहित) को हटा देता है और सत्र सूचकांक को रीसेट कर देता है। रीफ्रेश के बाद एक नया खाली सत्र बनाया जाएगा।`,devResetDone:`सत्र संग्रहण रीसेट`,id:`ID`,kind:`प्रकार`,clear:`साफ़ करें`,cancel:`रद्द करें`,delete:`हटाएँ`,reset:`रीसेट करें`},workflowsTab:{description:"वर्कफ़्लो को `~/.bamboo/workflows` में मार्कडाउन फ़ाइलों के रूप में संग्रहीत किया जाता है। चैट में वर्कफ़्लो सम्मिलित करने के लिए `/name` का उपयोग करें।",loadFailed:`वर्कफ़्लो लोड करने में विफल`,loadContentFailed:`वर्कफ़्लो सामग्री लोड करने में विफल`,invalidName:`अमान्य वर्कफ़्लो नाम`,nameAlreadyExists:`इस नाम का एक वर्कफ़्लो पहले से मौजूद है`,saved:`वर्कफ़्लो सहेजा गया`,saveFailed:`वर्कफ़्लो सहेजने में विफल`,deleted:`वर्कफ़्लो हटा दिया गया`,deleteFailed:`वर्कफ़्लो हटाने में विफल`,newWorkflow:`नया वर्कफ़्लो`,empty:`कोई वर्कफ़्लो नहीं मिला`,namePlaceholder:`वर्कफ़्लो नाम`,contentPlaceholder:`# वर्कफ़्लो शीर्षक
|
|
7
7
|
|
|
8
8
|
यहां वर्कफ़्लो चरणों का वर्णन करें.`,title:`वर्कफ़्लो`,refresh:`ताज़ा करें`,save:`सहेजें`},providerTab:{title:`LLM प्रदाता कॉन्फ़िगरेशन`,description:`अपने पसंदीदा LLM प्रदाता को कॉन्फ़िगर करें। "कॉन्फ़िगरेशन सहेजें और लागू करें" पर क्लिक करने पर कॉन्फ़िगरेशन सहेजा और लागू हो जाएगा।`,currentProvider:`वर्तमान प्रदाता`,activeProvider:`सक्रिय LLM प्रदाता`,selectProviderRequired:`कृपया एक प्रदाता चुनें`,saveAndApply:`कॉन्फ़िगरेशन सहेजें और लागू करें`,loadConfigFailed:`प्रदाता कॉन्फ़िगरेशन लोड करने में विफल`,checkStatusFailed:`स्थिति जाँचने में विफल`,startCopilotAuthFailed:`Copilot प्रमाणीकरण प्रारंभ करने में विफल`,copilotAuthSuccess:`Copilot प्रमाणीकरण सफल!`,providerReloaded:`प्रदाता ने नए प्रमाणीकरण के साथ पुनः लोड किया।`,completeAuthFailed:`प्रमाणीकरण पूर्ण होने में विफल रहा. कृपया पुन: प्रयास करें।`,userCodeCopied:`उपयोगकर्ता कोड क्लिपबोर्ड पर कॉपी किया गया!`,copyCodeFailedPrefix:`कोड कॉपी करने में विफल. कृपया मैन्युअल रूप से कॉपी करें:`,logoutSuccess:`Copilot से लॉग आउट किया गया`,logoutFailed:`Copilot से लॉगआउट करने में विफल`,unknownError:`अज्ञात त्रुटि`,invalidConfig:`अमान्य कॉन्फ़िगरेशन`,invalidConfigPrefix:`अमान्य कॉन्फ़िगरेशन`,invalidRequestOverridesJson:`{{provider}} के लिए अमान्य request_overrides JSON: {{error}}`,fetchModelsCopilotFailed:`मॉडल लाने में विफल. कृपया Copilot को प्रमाणित करें और पुनः प्रयास करें।`,fetchModelsFailed:`मॉडल लाने में विफल. कृपया अपनी API कुंजी और आधार URL जांचें।`,noModelsReturned:`कोई मॉडल वापस नहीं आया. पहले Copilot को प्रमाणित करें, फिर मॉडल लाएँ।`,foundModels:`{{count}} उपलब्ध मॉडल मिले`,fetchModelsErrorPrefix:`मॉडल लाने में विफल`,saveConfigSuccess:`कॉन्फ़िगरेशन सफलतापूर्वक सहेजा गया`,saveConfigFailed:`कॉन्फ़िगरेशन सहेजने में विफल`,saveConfigErrorPrefix:`कॉन्फ़िगरेशन सहेजने में विफल`,applyConfigSuccess:`कॉन्फ़िगरेशन सफलतापूर्वक लागू किया गया। परिवर्तन नए सत्रों में प्रभावी होंगे।`,applyConfigFailed:`कॉन्फ़िगरेशन लागू करने में विफल`,applyConfigErrorPrefix:`कॉन्फ़िगरेशन लागू करने में विफल`,modelUpdated:`मॉडल सफलतापूर्वक अपडेट किया गया`,updateModelFailed:`मॉडल अद्यतन करने में विफल`,updateModelErrorPrefix:`मॉडल अद्यतन करने में विफल`,fetchingModels:`मॉडल लाये जा रहे हैं...`,refreshModelsFrom:`{{source}} से उपलब्ध मॉडल ताज़ा करें`,fetchModelsFrom:`{{source}} से उपलब्ध मॉडल प्राप्त करें`,saveModelChangeFailed:`मॉडल परिवर्तन सहेजने में विफल`,fetchModelsFailedShort:`मॉडल लाने में विफल`,openaiConfigTitle:`OpenAI कॉन्फ़िगरेशन`,openaiConfigDescription:`GPT मॉडल का उपयोग करने के लिए अपनी OpenAI API कुंजी दर्ज करें। आप वैकल्पिक रूप से प्रॉक्सी सर्वर के लिए एक कस्टम बेस URL निर्दिष्ट कर सकते हैं।`,openaiApiKey:`OpenAI API कुंजी`,openaiApiKeyRequired:`कृपया अपनी OpenAI API कुंजी दर्ज करें`,baseUrlOptional:`आधार URL (वैकल्पिक)`,openaiBaseUrlHelp:`डिफ़ॉल्ट OpenAI API एंडपॉइंट का उपयोग करने के लिए खाली छोड़ दें। यदि आवश्यक हो तो पूर्ण पथ शामिल करें (उदाहरण के लिए, /v1)।`,defaultModel:`डिफ़ॉल्ट मॉडल`,fastModel:`तेज़ मॉडल (वैकल्पिक)`,fastModelHelp:`शीर्षक निर्माण, Mermaid रेंडरिंग और सारांशीकरण जैसे हल्के कार्यों के लिए सस्ता/तेज़ मॉडल। सेट न होने पर डिफ़ॉल्ट मॉडल का उपयोग करता है।`,visionModel:`विज़न मॉडल (वैकल्पिक)`,visionModelHelp:`छवि समझ के लिए दृष्टि-सक्षम मॉडल। जब hooks.image_fallback.mode को 'vision' पर सेट किया जाता है, तो यह मॉडल छवियों को टेक्स्ट के रूप में वर्णित करता है ताकि केवल टेक्स्ट वाले मॉडल उन्हें समझ सकें। सेट न होने पर डिफ़ॉल्ट मॉडल का उपयोग करता है।`,sameAsDefault:`डिफ़ॉल्ट मॉडल के समान`,selectModelRequired:`कृपया एक मॉडल चुनें`,selectModel:`एक मॉडल चुनें`,responsesOnlyModelsOptional:`केवल प्रतिक्रियाएँ मॉडल (वैकल्पिक)`,responsesOnlyHelp1:`कुछ मॉडल केवल OpenAI रिस्पॉन्स API (चैट/पूर्णता नहीं) का समर्थन करते हैं। Bamboo को अपस्ट्रीम का उपयोग करने के लिए मजबूर करने के लिए यहां मॉडल आईडी जोड़ें`,responsesOnlyHelp2:`सटीक मिलान (उदा. gpt-5.3-codex) और अनुगामी * (उदा. gpt-5*) के साथ उपसर्ग मिलान का समर्थन करता है।`,anthropicConfigTitle:`Anthropic कॉन्फ़िगरेशन`,anthropicConfigDescription:`Claude मॉडल का उपयोग करने के लिए अपनी Anthropic API कुंजी दर्ज करें।`,anthropicApiKey:`Anthropic API कुंजी`,anthropicApiKeyRequired:`कृपया अपनी एंथ्रोपिक API कुंजी दर्ज करें`,anthropicBaseUrlHelp:`डिफ़ॉल्ट एंथ्रोपिक API एंडपॉइंट का उपयोग करने के लिए खाली छोड़ दें। यदि आवश्यक हो तो पूर्ण पथ शामिल करें (उदाहरण के लिए, /v1)।`,maxTokensOptional:`अधिकतम टोकन (वैकल्पिक)`,maxTokensHelp:`उत्पन्न करने के लिए टोकन की अधिकतम संख्या`,geminiConfigTitle:`Google Gemini कॉन्फ़िगरेशन`,geminiConfigDescription:`Gemini मॉडल का उपयोग करने के लिए अपनी Google AI API कुंजी दर्ज करें।`,geminiApiKey:`Gemini API कुंजी`,geminiApiKeyRequired:`कृपया अपनी Gemini API कुंजी दर्ज करें`,geminiBaseUrlHelp:`डिफ़ॉल्ट Google AI API एंडपॉइंट का उपयोग करने के लिए खाली छोड़ दें। यदि आवश्यक हो तो पूर्ण पथ शामिल करें।`,copilotConfigTitle:`GitHub Copilot कॉन्फ़िगरेशन`,copilotConfigDescription:`GitHub Copilot OAuth प्रमाणीकरण का उपयोग करता है। किसी API कुंजी की आवश्यकता नहीं है. सुनिश्चित करें कि आपके पास सक्रिय GitHub Copilot सदस्यता है।`,authStatusTitle:`प्रमाणीकरण स्थिति`,notAuthenticated:`प्रमाणित नहीं`,logoutCopilot:`Copilot से लॉगआउट करें`,authenticateCopilot:`Copilot को प्रमाणित करें`,refreshStatus:`ताज़ा स्थिति`,headlessAuth:`हेडलेस प्रमाणीकरण`,headlessAuthHelp:`ब्राउज़र को स्वतः खोलने के बजाय कंसोल में लॉगिन URL प्रिंट करें`,noModelsLoaded:`अभी तक कोई मॉडल लोड नहीं हुआ। "बैकएंड से मॉडल लाएँ" पर क्लिक करें।`,authFirstThenFetch:`पहले Copilot को प्रमाणित करें, फिर मॉडल लाएँ।`,copilotUsageTitle:`GitHub Copilot का उपयोग करने के लिए:`,copilotUsageStep1:`सुनिश्चित करें कि आपके पास सक्रिय GitHub Copilot सदस्यता है`,copilotUsageStep2:`डिवाइस कोड प्रवाह प्रारंभ करने के लिए "प्रमाणीकृत Copilot" पर क्लिक करें`,copilotUsageStep3:`प्रमाणीकरण पूरा करने के लिए अपने टर्मिनल में दिए गए निर्देशों का पालन करें`,copilotAuthModalTitle:`Copilot प्रमाणीकरण`,completedAuthorization:`मैंने प्राधिकरण पूरा कर लिया है`,browserOpened:`ब्राउज़र अपने आप खुल गया`,authStep1:`आपके ब्राउज़र में एक GitHub पेज खुल जाना चाहिए`,authStep2:`नीचे दिए गए कोड को कॉपी करें और GitHub पेज पर पेस्ट करें`,authStep3:`अधिकृत करने के लिए GitHub पर "जारी रखें" पर क्लिक करें`,visitUrl:`1. इस URL पर जाएँ:`,enterCode:`2. यह कोड दर्ज करें:`,copied:`कॉपी किया गया!`,copyCode:`कोड कॉपी करें`,afterContinueHint:`GitHub पर "जारी रखें" पर क्लिक करने के बाद, नीचे "मैंने प्राधिकरण पूरा कर लिया है" बटन पर क्लिक करें।`,retry:`पुनः प्रयास करें`,authenticated:`प्रमाणीकृत`,cancel:`रद्द करें`,providerNames:{openai:`OpenAI`,anthropic:`Anthropic`,gemini:`Gemini`,copilot:`Copilot`}},mcpTab:{statusGuideTitle:`स्थिति मार्गदर्शिका:`,statusHelp:{connecting:`सर्वर प्रारंभ हो रहा है या पुनः कनेक्ट हो रहा है`,ready:`सर्वर जुड़ा हुआ है और टूल सामान्य रूप से परोस रहा है`,degraded:`सर्वर आंशिक रूप से उपलब्ध है; कुछ टूल विफल हो सकते हैं`,stopped:`सर्वर नहीं चल रहा है`,error:`सर्वर प्रारंभ करने में विफल रहा या रनटाइम त्रुटियों का सामना करना पड़ा`},statusLastError:`अंतिम त्रुटि: {{error}}`,serverDeleted:`MCP सर्वर हटा दिया गया`,deleteServerFailed:`MCP सर्वर को हटाने में विफल`,connectedTo:`{{name}} से कनेक्टेड`,connectServerFailed:`MCP सर्वर कनेक्ट करने में विफल`,disconnected:`{{name}} डिस्कनेक्ट किया गया`,disconnectServerFailed:`MCP सर्वर को डिस्कनेक्ट करने में विफल`,toolsRefreshedFor:`{{name}} के लिए टूल ताज़ा किए गए`,refreshToolsFailed:`टूल ताज़ा करने में विफल`,statusRefreshed:`MCP स्थिति ताज़ा की गई`,refreshStatusFailed:`MCP स्थिति ताज़ा करने में विफल`,noServerForEditing:`संपादन के लिए कोई सर्वर चयनित नहीं`,savedServer:`{{name}} सहेजा गया`,addedServer:`{{name}} जोड़ा गया`,saveServerFailed:`MCP सर्वर सहेजने में विफल`,copiedConfig:`MCP कॉन्फिगरेशन को क्लिपबोर्ड पर कॉपी किया गया`,clipboardUnavailable:`क्लिपबोर्ड उपलब्ध नहीं है. निर्यात को मोडल में दिखाया गया है।`,invalidJsonPrefix:`अमान्य JSON`,unknownError:`अज्ञात त्रुटि`,jsonMustBeObject:`JSON एक ऑब्जेक्ट होना चाहिए`,missingMcpServers:`'mcpServers' गुम है। पूर्ण क्लाउड डेस्कटॉप-शैली कॉन्फिग भाग चिपकाएँ: { "mcpServers": {... } }`,importSummary:`आयातित {{count}} सर्वर ({{added}} जोड़ा गया, {{updated}} अद्यतन किया गया, {{removed}} हटाया गया)। {{failed}} सर्वर प्रारंभ करने में विफल रहे।`,importStartFailures:`कुछ सर्वर प्रारंभ नहीं हुए. कॉन्फ़िगरेशन सहेजा गया है; त्रुटियाँ देखने के लिए सर्वर सूची खोलें।`,importFailed:`MCP सर्वर आयात करने में विफल`,overviewTitle:`MCP अवलोकन`,overviewDescription:`बाहरी MCP सर्वर कॉन्फ़िगर करें और पंजीकृत टूल उपनामों का निरीक्षण करें।`,totalServers:`कुल सर्वर: {{count}}`,totalTools:`कुल टूल: {{count}}`,serversTitle:`MCP सर्वर`,addServer:`सर्वर जोड़ें`,refreshAll:`सभी को ताज़ा करें`,importModalTitle:`MCP सर्वर आयात करें`,importHint:`क्लाउड डेस्कटॉप-शैली कॉन्फिग भाग चिपकाएँ। उदाहरण:`,importModeMerge:`मर्ज (अप्सर्ट)`,importModeReplace:`बदलें (अन्य हटाएं)`,replaceWarning:`रिप्लेसमेंट मोड मौजूदा MCP सर्वर को हटा देगा जो आयातित MCP सर्वर में मौजूद नहीं हैं।`,status:{connecting:`कनेक्ट हो रहा है`,ready:`तैयार`,degraded:`डिग्रेडेड`,stopped:`रुक गया`,error:`एरर`},export:`निर्यात करें`,import:`आयात करें`},mcpServerTable:{columns:{transportType:`ट्रांसपोर्ट प्रकार`,toolCount:`टूल संख्या`,name:`नाम`,status:`स्थिति`,actions:`कार्रवाई`},deleteTitle:`MCP सर्वर हटाएँ`,deleteDescription:`सर्वर "{{name}}" हटाएं?`,empty:`कोई MCP सर्वर कॉन्फ़िगर नहीं किया गया`,actions:{refreshTools:`टूल ताज़ा करें`,edit:`संपादित करें`,delete:`हटाएँ`,disconnect:`डिस्कनेक्ट करें`,connect:`जोड़ें`},transportOptions:{sse:`SSE`,stdio:`Stdio`}},mcpToolList:{title:`MCP टूल्स`,selectServerHint:`इसके MCP टूल्स का निरीक्षण करने के लिए एक सर्वर का चयन करें`,empty:`इस सर्वर के लिए कोई टूल्स नहीं मिले`,noDescription:`कोई डिस्क्रिप्शन उपलब्ध नहीं`,aliasMapping:`उपनाम मैपिंग`,parametersSchema:`पैरामीटर स्कीमा`},mcpServerForm:{jsonMustBeObject:`JSON एक ऑब्जेक्ट होना चाहिए`,detectedBulkConfig:`MCPसर्वर (बल्क कॉन्फ़िगरेशन) का पता लगाया गया। थोक आयात के लिए MCP टैब आयात बटन का उपयोग करें, या यहां एकल सर्वर कॉन्फ़िगरेशन पेस्ट करें।`,missingIdField:`गुम या अमान्य आईडी फ़ील्ड`,missingTransportField:`गुम या अमान्य परिवहन फ़ील्ड`,missingTransportInfo:`परिवहन संबंधी जानकारी अनुपलब्ध. या तो ट्रांसपोर्ट (बोधि प्रारूप) या कमांड/URL (मुख्यधारा MCP प्रारूप) अपेक्षित है।`,invalidJson:`अमान्य JSON: {{message}}`,unknownError:`अज्ञात त्रुटि`,editTitle:`MCP सर्वर संपादित करें`,addTitle:`MCP सर्वर जोड़ें`,jsonError:`JSON त्रुटि`,serverId:`सर्वर ID`,serverIdRequired:`सर्वर ID आवश्यक है`,serverIdPatternError:`केवल अक्षरों, संख्याओं, अंडरस्कोर और हाइफ़न का उपयोग करें`,displayName:`प्रदर्शित होने वाला नाम`,enabledHelp:`अक्षम सर्वर कॉन्फ़िगरेशन में बने रहेंगे लेकिन प्रारंभ नहीं होंगे।`,transportType:`ट्रांसपोर्ट प्रकार`,transportTypeRequired:`ट्रांसपोर्ट प्रकार आवश्यक है`,commandRequired:`कमांड आवश्यक है`,argumentsPlaceholder:`एक तर्क जोड़ें और Enter दबाएँ`,envVars:`एनवायरमेंट वेरिएबल`,addEnv:`एनवायरमेंट वेरिएबल जोड़ें`,keyRequired:`कुंजी आवश्यक है`,sseUrl:`SSE URL`,sseUrlRequired:`SSE URL आवश्यक है`,validUrlRequired:`कृपया मान्य URL दर्ज करें`,addHeader:`हेडर जोड़ें`,headerNameRequired:`हेडर नाम आवश्यक है`,save:`सहेजें`,modeForm:`फॉर्म`,modeJson:`JSON`,enabled:`सक्रिय`,transportOptions:{stdio:`Stdio`,sse:`SSE`},command:`कमांड`,arguments:`आर्ग्युमेंट्स`,headers:`हेडर`},metricsCards:{totalSessions:`कुल सत्र`,chatTokens:`चैट टोकन`,totalToolCalls:`कुल टूल कॉल`,avgSessionDuration:`औसत सत्र अवधि`},forwardMetricsCards:{totalForwardRequests:`कुल फॉरवर्ड अनुरोध`,successRate:`सफलता दर`,forwardTokens:`फॉरवर्ड टोकन`,avgResponseTime:`औसत प्रतिक्रिया समय`},unifiedMetricsCards:{totalRequests:`कुल अनुरोध`,totalTokens:`कुल टोकन`,successRate:`सफलता दर`,avgResponseTime:`औसत प्रतिक्रिया समय`,chatSessions:`चैट सत्र`,chatTokens:`चैट टोकन`,toolCalls:`टूल कॉल`,avgSessionDuration:`औसत सत्र अवधि`,forwardRequests:`अग्रेषित अनुरोध`,forwardTokens:`फॉरवर्ड टोकन`,successful:`सफल`,failed:`असफल`},metricsTable:{session:{columns:{toolCalls:`टूल कॉल`,session:`सत्र`,model:`मॉडल`,status:`स्थिति`,started:`शुरू कर दिया`,duration:`अवधि`,tokens:`टोकन`,messages:`संदेश`,action:`कार्रवाई`},view:`देखें`},forward:{totalRequests:`{{total}} अनुरोध`,empty:`इस श्रेणी के लिए कोई फॉरवर्ड अनुरोध दर्ज नहीं किया गया`,columns:{id:`ID`,endpoint:`एंडपॉइंट`,model:`मॉडल`,type:`प्रकार`,status:`स्थिति`,tokens:`टोकन`,duration:`अवधि`,started:`शुरू कर दिया`,error:`एरर`},typeStream:`स्ट्रीम`,typeSync:`सिंक`}},metricsDashboard:{roundColumns:{toolCalls:`टूल कॉल`,round:`राउंड`,status:`स्थिति`,duration:`अवधि`,tokens:`टोकन`},compactStats:{combinedTokens:`संयुक्त टोकन`,chatTokens:`चैट टोकन`,forwardTokens:`फॉरवर्ड टोकन`,avgTokensPerSession:`औसत टोकन/सत्र`,estimatedTimeSaved:`Est. समय बचत`,estimatedEfficiencyLift:`Est. दक्षता वृद्धि`,estimatedSpeedMultiplier:`Est. गति गुणक`,estimatedSavedWorkdays:`Est. बचत कार्यदिवस`,avgRoundsPerSession:`औसत राउंड/सत्र`,toolCallsPerSession:`टूल कॉल/सत्र`,activeSessionRate:`सक्रिय सत्र दर`,avgTokensPerForward:`औसत टोकन/फॉरवर्ड`,forwardErrorRate:`फॉरवर्ड एरर रेट`,streamingRatio:`स्ट्रीमिंग अनुपात`,p95ForwardLatency:`P95 फॉरवर्ड विलंबता`,modelCoverage:`मॉडल कवरेज`,endpointCoverage:`एंडपॉइंट कवरेज`},startDate:`आरंभ करने की तिथि`,endDate:`अंतिम तिथि`,daysOption:`{{value}} दिन`,derivedMetricsTitle:`व्युत्पन्न मेट्रिक्स (संक्षिप्त)`,derivedMetricsSubtitle:`अतिरिक्त पृष्ठ लंबाई के बिना अधिक आयाम`,efficiencyHint:`दक्षता अनुमान रूढ़िवादी मान्यताओं का उपयोग करते हैं: {{manualTpm}} मैनुअल टोकन/मिनट + {{manualToolMinutes}} मिनट/टूल बनाम {{assistedTpm}} सहायता प्राप्त टोकन/मिनट + {{assistedToolMinutes}} मिनट/टूल, फिर {{realization}}% प्राप्ति और कैप्स ({{maxLift}}% / {{maxMultiplier}}x) लागू करें।`,toolUsageTitle:`उपकरण उपयोग आवृत्ति`,noToolUsage:`इस श्रेणी के लिए कोई टूल कॉल रिकॉर्ड नहीं की गई।`,activityHeatmapTitle:`दैनिक गतिविधि हीटमैप`,noActivity:`इस श्रेणी के लिए कोई गतिविधि उपलब्ध नहीं है.`,sessionsCount:`{{count}} सत्र`,tokensAmount:`{{value}} टोकन`,sessionsTabLabel:`सत्र ({{count}})`,chatSessionsLabel:`चैट सत्र ({{count}})`,sessionsHint:`पूरे दौर के डिस्क्रिप्शन के लिए एक सत्र पर क्लिक करें`,forwardTabLabel:`फॉरवर्ड अनुरोध ({{count}})`,detailedMetricsTitle:`विस्तृत मेट्रिक्स`,sessionMetricsTitle:`सत्र मेट्रिक्स`,loadingSessionDetails:`सत्र डिस्क्रिप्शन लोड हो रहा है...`,sessionDetail:{sessionId:`सत्र आईडी`,totalTokens:`कुल टोकन`,toolCalls:`टूल कॉल`,model:`मॉडल`,status:`स्थिति`,duration:`अवधि`,messages:`संदेश`},noDetail:`कोई डिटेल उपलब्ध नहीं है`,multiplierSuffix:`एक्स`,filtersTitle:`फिल्टर`,refresh:`ताज़ा करें`,model:`मॉडल`,granularity:{daily:`दैनिक`,weekly:`साप्ताहिक`,monthly:`मासिक`},dashboardTitle:`डैशबोर्ड`,tabs:{overview:`अवलोकन`,analysis:`विश्लेषण`,records:`रिकॉर्ड्स`},calls:`कॉल`},charts:{tokenUsageOverTime:`समय के साथ टोकन का उपयोग`,unifiedTokenUsageOverTime:`समय के साथ टोकन का उपयोग (चैट + फॉरवर्ड)`,noTokenUsage:`कोई टोकन उपयोग उपलब्ध नहीं है`,tokenUsageDescription:`दिन/अवधि के अनुसार प्रॉम्प्ट, कम्प्लीशन और कुल टोकन।`,unifiedTokenUsageDescription:`समय के साथ संयुक्त चैट और फॉरवर्ड टोकन उपयोग।`,modelDistribution:`मॉडल वितरण`,noModelMetrics:`कोई मॉडल मेट्रिक्स उपलब्ध नहीं है`,modelDistributionDescription:`मॉडल द्वारा उपभोग किए गए कुल टोकन का हिस्सा।`,endpointDistribution:`एंडपॉइंट डिस्ट्रीब्यूशन`,noForwardMetrics:`इस श्रेणी के लिए कोई फ़ॉरवर्ड मेट्रिक्स उपलब्ध नहीं है।`,total:`कुल`,prompt:`प्रॉम्प्ट`,completion:`Completion`,chat:`चैट`,forward:`फॉरवर्ड`},page:{tabs:{mermaid:`Mermaid`,mcp:`MCP`},groups:{ai:`AI`}}},components:{markdown:{codeCopiedSuccess:`कोड क्लिपबोर्ड पर कॉपी किया गया`,copyFailed:`कॉपी विफल`},jsonSchema:{noProperties:`स्कीमा में कोई प्रॉपर्टी नहीं`,field:`फ़ील्ड`,type:`प्रकार`,required:`आवश्यक`,yes:`हाँ`,no:`नहीं`,default:`डिफ़ॉल्ट`,description:`डिस्क्रिप्शन`},imageGrid:{ocr:`OCR`}}},Aa=`lotus_ui_locale_v1`,ja=`en-US`,Ma=[`en-US`,`zh-CN`,`zh-TW`,`fr-FR`,`ja-JP`,`hi-IN`],Na=e=>e?Ma.includes(e):!1,Pa=()=>{if(typeof window>`u`)return ja;try{let e=window.localStorage,t=e&&typeof e.getItem==`function`?e.getItem(Aa):null;if(Na(t))return t}catch{}let e=window.navigator.language?.toLowerCase()??``;return e.startsWith(`zh`)?e.includes(`tw`)||e.includes(`hk`)||e.includes(`mo`)||e.includes(`hant`)?`zh-TW`:`zh-CN`:e.startsWith(`fr`)?`fr-FR`:e.startsWith(`ja`)?`ja-JP`:e.startsWith(`hi`)?`hi-IN`:ja},Fa=e=>!!e&&typeof e==`object`&&!Array.isArray(e),Ia=(e,t)=>{let n={...e};for(let[e,r]of Object.entries(t)){let t=n[e];if(Fa(t)&&Fa(r)){n[e]=Ia(t,r);continue}n[e]=r}return n},La=e=>({...e,app:{...e.app,loading:`Chargement...`,retry:`Réessayer`,backendNotReachable:`Le back-end est inaccessible à {{baseUrl}} (dernière erreur : {{message}})`},chat:{...e.chat,sidebar:{...e.chat.sidebar,newSession:`Nouvelle session`,empty:{noSessions:`Pas encore de sessions`,hint:`Cliquez sur "Nouvelle session" pour commencer`},dateGroups:{today:`Aujourd'hui`,yesterday:`Hier`,thisWeek:`Cette semaine`,thisMonth:`Ce mois-ci`,pinned:`Épinglé`,scheduled:`Planifié`},actions:{collapseChildren:`Réduire les sessions enfants`,expandChildren:`Développer les sessions enfants`}}},settings:{...e.settings,page:{...e.settings.page,back:`Retour`,title:`Paramètres système`,tabs:{...e.settings.page.tabs,config:`Configuration`,prompts:`Prompts`,mermaid:`Mermaid`,skills:`Compétences`,workflows:`Flux de travail`,mcp:`MCP`,modelLimits:`Limites des modèles`,metrics:`Métriques`,schedules:`Planifications`,sessions:`Sessions`,app:`Application`,provider:`Fournisseur`,hooks:`Hooks`,masking:`Masquage`},groups:{...e.settings.page.groups,ai:`IA`,toolsAndExtensions:`Outils & Extensions`,securityAndPrivacy:`Sécurité`,monitoring:`Surveillance`,system:`Système`}},notifications:{...e.settings.notifications,deleteAllSuccess:`Toutes les sessions ont été supprimées (hors épinglées)`,deleteEmptySuccess:`Les sessions vides ont été supprimées (hors épinglées)`,localStorageCleared:`Le stockage local a été effacé`,resetSuccessReloading:`Réinitialisation de l'application réussie. Rechargement...`,resetFailed:`Échec de la réinitialisation de l'application`,promptEnhancementSaved:`Amélioration du prompt système enregistrée`},configTab:{...e.settings.configTab,loadConfigFailed:`Échec du chargement de la configuration`,invalidConfig:`Configuration invalide`,saveConfigSuccess:`Configuration enregistrée avec succès`,saveConfigFailed:`Échec de l'enregistrement de la configuration`,backendSaved:`URL du back-end enregistrée`,backendResetDefault:`URL du back-end rétablie par défaut`,providerMovedTitle:`Configuration du fournisseur déplacée`,providerMovedDescription:`Les paramètres GitHub Copilot et d'autres fournisseurs ont été déplacés vers l'onglet Paramètres fournisseur. Configurez-les là-bas.`,backendApiBaseUrlTitle:`URL de base de l'API du back-end`,backendApiHint:`Doit inclure le chemin /v1`,resetToDefault:`Rétablir les valeurs par défaut`,save:`Enregistrer`,language:`Langue`,languageEnglish:`Anglais`,languageChinese:`Chinois simplifié`,languageTraditionalChinese:`Chinois traditionnel`,languageFrench:`Français`,languageJapanese:`Japonais`,languageHindi:`Hindi`},appTab:{...e.settings.appTab,switchOn:`ACTIVÉ`,switchOff:`DÉSACTIVÉ`,darkMode:`Mode sombre`,darkModeDark:`Sombre`,darkModeLight:`Clair`,language:`Langue`,languageEnglish:`Anglais`,languageChinese:`Chinois simplifié`,languageTraditionalChinese:`Chinois traditionnel`,languageFrench:`Français`,languageJapanese:`Japonais`,languageHindi:`Hindi`,deleteAllTitle:`Supprimer toutes les sessions`,deleteAllDescription:`Voulez-vous continuer ? Cette action supprimera toutes les sessions, sauf celles épinglées.`,deleteAllButton:`Supprimer toutes les sessions`,deleteEmptyTitle:`Supprimer les sessions vides`,deleteEmptyDescription:`Voulez-vous continuer ? Cette action supprimera toutes les sessions sans message (hors sessions épinglées).`,deleteEmptyButton:`Supprimer les sessions vides`,clearLocalStorageTitle:`Effacer le stockage local`,clearLocalStorageDescription:`Voulez-vous continuer ? Cette action supprimera toutes les données locales et réinitialisera l'application.`,clearLocalStorageButton:`Effacer le stockage local`,confirmDeleteAll:`Oui, tout supprimer`,confirmDeleteEmpty:`Oui, supprimer les vides`,confirmClear:`Oui, effacer`,cancel:`Annuler`,dangerZone:`Zone dangereuse`,dangerDescription:`Ces actions sont irréversibles. Toutes les données seront supprimées définitivement.`,resetApplicationTitle:`Réinitialiser l'application`,resetApplicationIntro:`Voulez-vous continuer ? Cette action va :`,resetStepDeleteAllSessions:`Supprimer TOUTES les sessions (y compris les épinglées)`,resetStepClearStorage:`Effacer toutes les données du stockage local`,resetStepResetConfig:`Réinitialiser config.json aux valeurs par défaut`,resetStepSetupFlow:`Relancer l'assistant de configuration au prochain démarrage`,resetStepReload:`Recharger l'application`,resetConfirm:`Oui, tout réinitialiser`,resetButton:`Réinitialiser l'application (toutes les données)`,runningVersion:`Version en cours`,runningVersionDesc:`Il s'agit de la version frontend Lotus actuellement en cours d'exécution.`},networkCard:{...e.settings.networkCard,title:`Paramètres réseau`,httpProxy:`Proxy HTTP`,httpsProxy:`Proxy HTTPS`,proxyAuthTitle:`Authentification du proxy`,proxyConfiguredForUser:`Configuré pour l'utilisateur : {{username}}`,clearCredentials:`Effacer les identifiants`,username:`Nom d'utilisateur`,password:`Mot de passe`,apply:`Appliquer`,credentialsStorageNote:`Les identifiants du proxy sont stockés de façon chiffrée dans ~/.bamboo/config.json`,reload:`Recharger`,save:`Enregistrer`},modelMappingCard:{...e.settings.modelMappingCard,loadProviderFailed:`Échec du chargement de la configuration du fournisseur`,loadMappingsFailed:`Échec du chargement des mappages existants`,loadModelsFailed:`Échec du chargement des modèles`,loadModelsHint:`Impossible de charger les modèles. Vérifiez la configuration du fournisseur.`,mappingSaved:`Mappage de modèle enregistré`,mappingSaveFailed:`Échec de l'enregistrement du mappage de modèle`,enterModelName:`Veuillez saisir un nom de modèle`,customMappingSaved:`Mappage de modèle personnalisé enregistré`,customMappingSaveFailed:`Échec de l'enregistrement du mappage de modèle personnalisé`,collapseTitle:`Mappage de modèles Anthropic`,description:`Configurez les modèles {{provider}} à utiliser lorsque Claude CLI demande des modèles spécifiques.`,loadModelsErrorTitle:`Échec du chargement des modèles`,retry:`Réessayer`,loadingModels:`Chargement des modèles...`,modelTypeOpusDescription:`correspond aux modèles contenant "opus"`,modelTypeSonnetDescription:`correspond aux modèles contenant "sonnet"`,modelTypeHaikuDescription:`correspond aux modèles contenant "haiku"`,selectModelPlaceholder:`Sélectionner le modèle {{label}}`,customModelOption:`Modèle personnalisé...`,mappedModelNotFound:`Le modèle mappé "{{model}}" est introuvable dans les modèles disponibles du fournisseur actuel`,refreshModels:`Actualiser les modèles`,currentProvider:`Fournisseur actuel`,loadingProvider:`Chargement...`,availableModels:`Modèles disponibles`,cached:`(en cache)`,storedIn:`Enregistré dans`,customModalTitle:`Saisir un nom de modèle personnalisé`,customModalDescription:`Saisissez un nom de modèle personnalisé pour {{modelType}}`,customModalPlaceholder:`ex. : gpt-4-turbo-preview`,customModalNote:`Note : assurez-vous que ce nom de modèle est valide pour le fournisseur actuel.`,save:`Enregistrer`,cancel:`Annuler`},modelTab:{...e.settings.modelTab,selectModelTitle:`Sélectionner un modèle`,loadingModels:`Chargement des modèles...`,selectModelPlaceholder:`Sélectionner un modèle`,backendApiBaseUrlTitle:`URL de base de l'API du back-end`,resetToDefault:`Rétablir les valeurs par défaut`,save:`Enregistrer`,backendApiHint:`Doit être une URL de base complète incluant /v1 (ex. {{example}}).`},common:{...e.settings.common,loading:`Chargement...`,successful:`Réussi`,failed:`Échec`},promptsTab:{...e.settings.promptsTab,title:`Amélioration du prompt système`,mermaidEnhancement:`Amélioration Mermaid`,taskListRules:`Règles de tâches partagées`,copilotConclusionWithOptionsBeforeFinish:`Copilot conclusion_with_options avant de terminer`,switchOn:`ACTIVÉ`,switchOff:`DÉSACTIVÉ`,enhancementPlaceholder:`Ajoutez un texte d'amélioration global à ajouter à chaque prompt système.`,saveEnhancement:`Enregistrer l'amélioration`,description:`Ce texte est ajouté en premier, suivi des améliorations système activées, avant l'envoi de chaque requête.`},hooksTab:{...e.settings.hooksTab,title:`Hooks d'images`,enableImagePreflight:`Activer le hook de pré-vérification d'image`,modeLabel:`Mode`,description:`Le mode Placeholder réécrit les images en résumés textuels (cela peut perturber les outils qui attendent de vraies données d'image). L'OCR est actuellement disponible uniquement sous Windows.`,loadFailed:`Échec du chargement des paramètres de hooks`,updateFailed:`Échec de la mise à jour des hooks`,modeUpdateFailed:`Échec de la mise à jour du mode de hook`,enabled:`Hooks d'image activés`,disabled:`Hooks d'image désactivés`,modeUpdated:`Mode du hook d'image défini sur : {{mode}}`,mode:{...e.settings.hooksTab.mode,error:`Erreur`}},keywordMaskingTab:{...e.settings.keywordMaskingTab,title:`Masquage de mots-clés`,addKeyword:`Ajouter un mot-clé`,description:`Configurez les mots-clés à masquer avant l'envoi vers l'API Copilot. Utilisez une correspondance exacte pour les chaînes littérales ou des regex pour les motifs. Toutes les correspondances seront remplacées par [MASKED].`,empty:`Aucune règle de masquage de mots-clés configurée`,cancel:`Annuler`,patternPlaceholder:`Saisissez un motif à rechercher`,examples:`Exemples`,exactMatch:`Correspondance exacte`,regexPattern:`Motif regex`,enabled:`Activé`,disabled:`Désactivé`,sampleText:`Texte d'exemple`,sampleTextPlaceholder:`Saisissez un texte d'exemple`,maskedPreview:`Aperçu du masquage`,emptyPattern:`(vide)`,loadFailed:`Échec du chargement de la configuration de masquage de mots-clés`,saveFailed:`Échec de l'enregistrement de la configuration`,saveSuccess:`Configuration de masquage de mots-clés enregistrée`,validationFailedPrefix:`Échec de validation`,patternRequired:`Le motif ne peut pas être vide`,example:{...e.settings.keywordMaskingTab.example,literalToken:`Masquer un jeton littéral`,githubTokens:`Masquer les jetons GitHub`,awsKeys:`Masquer les clés AWS`,emails:`Masquer les adresses e-mail`}},workflowsTab:{...e.settings.workflowsTab,title:`Flux de travail`,description:"Les workflows sont stockés dans `~/.bamboo/workflows` sous forme de fichiers Markdown. Utilisez `/nom` pour insérer un workflow dans le chat.",loadFailed:`Échec du chargement des flux de travail`,loadContentFailed:`Échec du chargement du contenu du flux`,invalidName:`Nom de flux invalide`,nameAlreadyExists:`Un flux avec ce nom existe déjà`,saved:`Flux de travail enregistré`,saveFailed:`Échec de l'enregistrement du flux de travail`,deleted:`Flux de travail supprimé`,deleteFailed:`Échec de la suppression du flux de travail`,refresh:`Actualiser`,newWorkflow:`Nouveau flux`,save:`Enregistrer`,empty:`Aucun flux de travail trouvé`,namePlaceholder:`Nom du flux`,contentPlaceholder:`# Titre du flux
|
|
9
9
|
|
|
@@ -12,15 +12,15 @@ Décrivez ici les étapes du flux de travail.`},mermaidTab:{...e.settings.mermai
|
|
|
12
12
|
在這裡描述工作流程步驟。`},metricsCards:{...e.settings.metricsCards,totalSessions:`會話總數`,chatTokens:`聊天 Token`,totalToolCalls:`工具呼叫總數`,avgSessionDuration:`平均會話時長`},forwardMetricsCards:{...e.settings.forwardMetricsCards,totalForwardRequests:`Forward 請求總數`,successRate:`成功率`,forwardTokens:`Forward Token`,avgResponseTime:`平均回應時間`},unifiedMetricsCards:{...e.settings.unifiedMetricsCards,totalRequests:`請求總數`,totalTokens:`Token 總數`,successRate:`成功率`,avgResponseTime:`平均回應時間`,chatSessions:`聊天會話`,chatTokens:`聊天 Token`,toolCalls:`工具呼叫`,avgSessionDuration:`平均會話時長`,totalMemories:`記憶總數`,staleCandidates:`陳舊候選項`,memoryProjects:`記憶專案數`,lastReindex:`上次重建索引`,forwardRequests:`Forward 請求`,forwardTokens:`Forward Token`,successful:`成功`,failed:`失敗`},metricsTable:{...e.settings.metricsTable,session:{...e.settings.metricsTable?.session,columns:{...e.settings.metricsTable?.session?.columns,session:`會話`,model:`模型`,status:`狀態`,started:`開始時間`,duration:`耗時`,tokens:`Token`,toolCalls:`工具呼叫`,messages:`訊息數`,action:`操作`},view:`查看`},forward:{...e.settings.metricsTable?.forward,columns:{...e.settings.metricsTable?.forward?.columns,id:`ID`,endpoint:`端點`,model:`模型`,type:`類型`,status:`狀態`,tokens:`Token`,duration:`耗時`,started:`開始時間`,error:`錯誤`},typeStream:`流式`,typeSync:`同步`,totalRequests:`{{total}} 條請求`,empty:`目前範圍內暫無 forward 請求記錄`}},keywordMaskingTab:{...e.settings.keywordMaskingTab,title:`關鍵詞脫敏`,addKeyword:`新增關鍵詞`,description:`配置發送到 Copilot API 前需要脫敏的關鍵詞。可使用精確匹配或正規匹配,匹配內容會被替換為 [MASKED]。`,empty:`暫無關鍵詞脫敏規則`,cancel:`取消`,patternPlaceholder:`輸入要匹配的模式`,examples:`範例`,exactMatch:`精確匹配`,regexPattern:`正規模式`,enabled:`啟用`,disabled:`停用`,sampleText:`範例文本`,sampleTextPlaceholder:`輸入範例文本`,maskedPreview:`脫敏預覽`,emptyPattern:`(空)`,loadFailed:`載入關鍵詞脫敏配置失敗`,saveFailed:`儲存配置失敗`,saveSuccess:`關鍵詞脫敏配置已儲存`,validationFailedPrefix:`校驗失敗`,patternRequired:`匹配模式不能為空`,invalidRegexPattern:`無效的正規表示式模式`,example:{...e.settings.keywordMaskingTab?.example,literalToken:`脫敏字面量 token`,githubTokens:`脫敏 GitHub token`,awsKeys:`脫敏 AWS Key`,emails:`脫敏郵件位址`}}},components:{...e.components,markdown:{codeCopiedSuccess:`程式碼已複製到剪貼簿`,copyFailed:`複製失敗`},jsonSchema:{...e.components.jsonSchema,field:`欄位`,type:`類型`,required:`必填`,default:`預設`,description:`描述`},tokenUsage:{...e.components.tokenUsage,messages:`訊息`,tokens:`Token`},workflowResult:{...e.components?.workflowResult,waitingForResult:`等待工作流程結果...`,executionFailed:`工作流程執行失敗`,retryWorkflow:`重試工作流程`,copyParameters:`複製參數`,copyResult:`複製結果`},toolResult:{...e.components?.toolResult,waitingForResult:`等待結果...`,executionFailed:`工具執行失敗`,copyResult:`複製結果`},mermaid:{...e.components?.mermaid,loadingDiagram:`正在載入圖表...`,diagramError:`Mermaid 圖表錯誤`,fixMermaid:`修復 Mermaid`,exportSvg:`匯出 SVG`,exportFailed:`匯出圖表失敗`},approval:{...e.components?.approval,workflow:`工作流程`},todoList:{...e.components.todoList,llmEvaluation:`LLM 評估`,tools:`個工具`,dependsOn:`依賴:{{deps}}`,dependencies:`項依賴`},toolSession:{...e.components?.toolSession,title:`工具會話`,running:`執行中`,done:`完成`,error:`錯誤`,completedOnly:`{{completed}} 已完成`,completedWithErrors:`{{completed}} 已完成(有錯誤)`,completedProgress:`{{completed}} / {{total}} 已完成`,noPersistedMessage:`無持久化輸出`,deleteMessage:`刪除工具會話`}}}),Ua={"fr-FR":async()=>{let e=(await Da(`en-US`)).translation;return{translation:Ia(Ba(e),Oa)}},"hi-IN":async()=>{let e=(await Da(`en-US`)).translation;return{translation:Ia(Va(e),ka)}},"ja-JP":async()=>{let e=(await Da(`en-US`)).translation;return{translation:Ra(e)}},"zh-TW":async()=>{let e=(await Da(`zh-CN`)).translation;return{translation:Ha(e)}}},Wa=new Set([`en-US`,`zh-CN`]),Ga=new Map,Ka=e=>{let t=Ga.get(e);if(t)return t;let n=(async()=>{if(Wa.has(e))return await Da(e);let t=Ua[e];if(!t)throw Error(`No i18n resource loader registered for locale: ${e}`);return t()})();return Ga.set(e,n),n},qa=async e=>{if(Qi.hasResourceBundle(e,`translation`))return;let t=await Ka(e);Qi.addResourceBundle(e,`translation`,t.translation,!0,!1)},Ja=Pa();(async()=>{let e={};if(e[ja]=await Ka(ja),Ja!==`en-US`&&(e[Ja]=await Ka(Ja)),!Qi.isInitialized){Qi.use(ua),await Qi.init({resources:e,lng:Ja,fallbackLng:ja,supportedLngs:Ma,interpolation:{escapeValue:!1},react:{useSuspense:!1},returnNull:!1});return}await qa(Ja),Qi.language!==Ja&&await Qi.changeLanguage(Ja)})();var Ya=Qi,Xa=new Set([`low`,`medium`,`high`,`xhigh`,`max`]),Za=e=>{let t=e?.reasoning_effort;return typeof t==`string`&&Xa.has(t)?t:void 0},Qa=(e,t)=>{let n=t?.trim();if(!n)return;let r=e?.instances.find(e=>e.id===n);return Za(r?.config)},$a=(e,t)=>Qa(e,t),eo=(e,t,n)=>Qa(e,t?.provider?.trim()||e?.defaults?.chat.provider.trim()||n?.trim()),to=()=>({id:`general_assistant`,name:`Bodhi`,description:Ya.t(`chat.prompt.defaultDescription`),content:`You are Bodhi, a highly capable AI assistant.
|
|
13
13
|
|
|
14
14
|
You help users solve problems quickly and correctly. Be concise, practical, and proactive.
|
|
15
|
-
If requirements are unclear, ask focused clarifying questions before proceeding.`,isDefault:!0}),no=()=>[to()];function ro(e){if(!e)return;let t={systemTokens:e.system_tokens,summaryTokens:e.summary_tokens,windowTokens:e.window_tokens,totalTokens:e.total_tokens,budgetLimit:e.budget_limit};return typeof e.max_context_tokens==`number`&&e.max_context_tokens>0&&(t.maxContextTokens=e.max_context_tokens),typeof e.prompt_cached_tool_outputs==`number`&&(t.promptCachedToolOutputs=e.prompt_cached_tool_outputs),typeof e.prompt_cached_tool_tokens_saved==`number`&&(t.promptCachedToolTokensSaved=e.prompt_cached_tool_tokens_saved),typeof e.thinking_tokens==`number`&&(t.thinkingTokens=e.thinking_tokens),typeof e.cache_read_input_tokens==`number`&&(t.cacheReadInputTokens=e.cache_read_input_tokens),t}var io=no()[0],ao=io?.id||`general_assistant`,oo=io?.content?.trim()||``,so=`tool`,co=()=>{try{let e=globalThis.crypto;if(e?.randomUUID)return e.randomUUID()}catch{}return`id_${Date.now()}_${Math.random().toString(16).slice(2)}`},lo=e=>{let t=e.trim();if(!t.startsWith(`bamboo-attachment://`))return null;let[n,r]=t.slice(20).split(`/`,2);return!n||!r?null:{sessionId:n,attachmentId:r}},uo=e=>{let t=lo(e);return t?z.resolveUrl(`sessions/${encodeURIComponent(t.sessionId)}/attachments/${encodeURIComponent(t.attachmentId)}`):e},fo=e=>{if(typeof e!=`string`)return;let t=e.trim();if(t&&t.toLowerCase()!==`unknown`)return t},po=e=>{let t=(e||``).trim();if(!t)return;let n=t.match(/tool policy blocked ['"`]([^'"`]+)['"`]/i);if(n?.[1])return fo(n[1]);try{let e=JSON.parse(t);if(typeof e?.tool_name==`string`)return fo(e.tool_name)}catch{}},mo=e=>{let t=Number.isFinite(Date.parse(e.created_at))?Date.parse(e.created_at):Date.now(),n=ro(e.token_usage);return{id:e.id,kind:e.kind,parentSessionId:e.parent_session_id??null,rootSessionId:e.root_session_id,spawnDepth:e.spawn_depth,createdByScheduleId:e.created_by_schedule_id??null,isRunning:e.is_running,updatedAt:e.updated_at,lastActivityAt:e.last_activity_at,messageCount:e.message_count,hasAttachments:e.has_attachments,lastRunStatus:e.last_run_status,lastRunError:e.last_run_error,planMode:e.plan_mode??null,subagentType:e.subagent_type??null,lifecycle:e.lifecycle??null,residentName:e.resident_name??null,placement:e.placement??null,title:e.title||Ya.t(`chat.session.defaultTitle`),titleVersion:e.title_version??0,createdAt:t,pinned:e.pinned,messages:[],config:{systemPromptId:ao,baseSystemPrompt:oo,lastUsedEnhancedPrompt:null,model:e.model,model_ref:e.model_ref??null,reasoningEffort:e.reasoning_effort??null,bypassPermissions:e.bypass_permissions??!1,permissionMode:Wn(e.permission_mode),goldConfig:e.gold_config??null,tokenUsage:n,truncationOccurred:e.token_usage?.truncation_occurred,segmentsRemoved:e.token_usage?.segments_removed,compressionEvents:[]}}},ho=(e,t)=>{let n=new Map,r=new Map;for(let e of t)e.role===`tool`&&e.tool_call_id&&e.metadata&&r.set(e.tool_call_id,e.metadata);let i=[];for(let e of t){let t=e.created_at||new Date().toISOString();if(e.role===`system`){let n={role:`system`,id:e.id,createdAt:t,content:e.content||``,isCompressed:!!e.compressed,compressedEventId:e.compressed_by_event_id};i.push(n);continue}if(e.role===`user`){let n=new Map;for(let t of e.image_ocr||[]){let e=t.image_url?.trim();if(!e)continue;let r=(t.lines||[]).map(e=>(e?.text||``).trim()).filter(Boolean);n.set(e,{ocrText:r.length?r.join(`
|
|
16
|
-
`):void 0,ocrError:t.error?String(t.error):void 0})}let r=[];for(let t of e.content_parts||[]){if(t.type!==`image_url`)continue;let e=t.image_url?.url||``;if(!e)continue;let i=uo(e),a=lo(e),o=n.get(e.trim());r.push({id:co(),url:i,ocrText:o?.ocrText,ocrError:o?.ocrError,name:a?`attachment-${a.attachmentId}`:`image`,size:0,type:`image/*`})}let a={role:`user`,id:e.id,createdAt:t,content:e.content||``,images:r.length?r:void 0,isCompressed:!!e.compressed,compressedEventId:e.compressed_by_event_id};i.push(a);continue}if(e.role===`assistant`){let a=e.tool_calls||[];if(a.length>0){let o=(e.content||``).trim(),s=typeof e.reasoning==`string`&&e.reasoning.trim().length>0;if(o||s){let n=s?{reasoning:e.reasoning,backendMessageId:e.id}:{backendMessageId:e.id},r={role:`assistant`,type:`text`,id:`${e.id}_text`,createdAt:t,content:e.content||``,metadata:n,isCompressed:!!e.compressed,compressedEventId:e.compressed_by_event_id};i.push(r)}for(let e of a)e.id&&n.set(e.id,fo(e.function?.name)||so);let c=a[0]?.id,l=c?r.get(c):void 0,u={role:`assistant`,type:`tool_call`,id:e.id,createdAt:t,toolCalls:a.map(e=>({toolCallId:e.id,toolName:fo(e.function?.name)||so,parameters:(()=>{try{return JSON.parse(e.function?.arguments||`{}`)}catch{return{raw:e.function?.arguments||``}}})(),streamingOutput:``})),...l?{metadata:l}:{},isCompressed:!!e.compressed,compressedEventId:e.compressed_by_event_id};i.push(u);continue}let o=typeof e.reasoning==`string`&&e.reasoning.trim().length>0?{reasoning:e.reasoning}:{},s={role:`assistant`,type:`text`,id:e.id,createdAt:t,content:e.content||``,metadata:o,isCompressed:!!e.compressed,compressedEventId:e.compressed_by_event_id};i.push(s);continue}if(e.role===`tool`){let r=e.tool_call_id?.trim()||`orphan-tool-call:${e.id}`,a=fo(n.get(r))||fo(e.tool_name)||fo(e.name)||po(e.content)||so,o=e.tool_success===!1||e.tool_success==null&&typeof e.content==`string`&&e.content.trimStart().startsWith(`Error:`),s=[];for(let t of e.content_parts||[]){if(t.type!==`image_url`)continue;let e=t.image_url?.url||``;e&&s.push({id:co(),url:uo(e),name:`screenshot`,size:0,type:`image/*`})}let c={role:`assistant`,type:`tool_result`,id:e.id,createdAt:t,toolName:a,toolCallId:r,result:{tool_name:a,result:e.content||``,display_preference:`Default`},isError:o,images:s.length?s:void 0,isCompressed:!!e.compressed,compressedEventId:e.compressed_by_event_id};i.push(c);continue}}return i},go=e=>{if(typeof e!=`string`||!e.trim())return null;let t=Date.parse(e);return Number.isFinite(t)?t:null},_o=(e,t)=>e===t?!0:!e||!t?e==null&&t==null:e.provider===t.provider&&e.model===t.model,vo=(e,t)=>e===t?!0:!e||!t?e==null&&t==null:e.systemTokens===t.systemTokens&&e.summaryTokens===t.summaryTokens&&e.windowTokens===t.windowTokens&&e.totalTokens===t.totalTokens&&(e.maxContextTokens??0)===(t.maxContextTokens??0)&&e.budgetLimit===t.budgetLimit&&(e.promptCachedToolOutputs??0)===(t.promptCachedToolOutputs??0)&&(e.promptCachedToolTokensSaved??0)===(t.promptCachedToolTokensSaved??0)&&(e.thinkingTokens??0)===(t.thinkingTokens??0)&&(e.cacheReadInputTokens??0)===(t.cacheReadInputTokens??0),yo=(e,t)=>{if(e===t)return!0;let n=e??[],r=t??[];return n.length===r.length?n.every((e,t)=>{let n=r[t];return!!n&&e.id===n.id&&e.createdAt===n.createdAt&&e.messagesCompressed===n.messagesCompressed&&e.segmentsRemoved===n.segmentsRemoved}):!1},bo=(e,t)=>e===t?!0:!e||!t?e==null&&t==null:e.messageCount===t.messageCount&&e.lastMessageId===t.lastMessageId&&e.hasPendingQuestion===t.hasPendingQuestion&&e.pendingQuestionToolCallId===t.pendingQuestionToolCallId,xo=(e,t)=>e===t?!0:e.systemPromptId===t.systemPromptId&&e.baseSystemPrompt===t.baseSystemPrompt&&e.lastUsedEnhancedPrompt===t.lastUsedEnhancedPrompt&&e.agentRole===t.agentRole&&e.workspacePath===t.workspacePath&&e.model===t.model&&_o(e.model_ref,t.model_ref)&&e.reasoningEffort===t.reasoningEffort&&e.bypassPermissions===t.bypassPermissions&&e.permissionMode===t.permissionMode&&e.permissionModeEtag===t.permissionModeEtag&&JSON.stringify(e.goldConfig??null)===JSON.stringify(t.goldConfig??null)&&JSON.stringify(e.goalState??null)===JSON.stringify(t.goalState??null)&&vo(e.tokenUsage,t.tokenUsage)&&e.truncationOccurred===t.truncationOccurred&&e.segmentsRemoved===t.segmentsRemoved&&yo(e.compressionEvents,t.compressionEvents)&&bo(e.syncCursor,t.syncCursor),So=(e,t)=>e.id===t.id&&e.kind===t.kind&&e.parentSessionId===t.parentSessionId&&e.rootSessionId===t.rootSessionId&&e.spawnDepth===t.spawnDepth&&e.createdByScheduleId===t.createdByScheduleId&&e.isRunning===t.isRunning&&e.updatedAt===t.updatedAt&&e.lastActivityAt===t.lastActivityAt&&e.messageCount===t.messageCount&&e.hasAttachments===t.hasAttachments&&e.lastRunStatus===t.lastRunStatus&&e.lastRunError===t.lastRunError&&e.planMode===t.planMode&&e.subagentType===t.subagentType&&e.placement?.kind===t.placement?.kind&&e.placement?.host===t.placement?.host&&e.title===t.title&&e.titleVersion===t.titleVersion&&e.createdAt===t.createdAt&&e.pinned===t.pinned&&e.messages===t.messages&&xo(e.config,t.config),Co=ar.getInstance(),Z={inFlight:null,forcedPromise:null,timer:null,trailingPromise:null,trailingResolve:null,trailingReject:null};function wo(){let e={resolve:Z.trailingResolve,reject:Z.trailingReject};return Z.trailingPromise=null,Z.trailingResolve=null,Z.trailingReject=null,e}function To(e,t){!t.resolve&&!t.reject||e.then(()=>t.resolve?.(),e=>t.reject?.(e))}function Eo(){return Z.timer&&=(clearTimeout(Z.timer),null),wo()}function Do(e,t){let n=e.map(mo);t(t=>{let r=t.executionBySession;for(let t of e)r=ei(r,{type:`applySessionSummary`,sessionId:t.id,summary:t});let i=new Map(t.chats.map(e=>[e.id,e])),a=t.chats.length!==n.length,o=n.map((e,n)=>{let r=i.get(e.id);if(!r)return a=!0,e;let o=go(r.updatedAt),s=go(e.updatedAt),c=o!==null&&s!==null&&o>s,l=r.config||{},u=e.config||{},d=Object.prototype.hasOwnProperty.call(l,`model`),f=Object.prototype.hasOwnProperty.call(l,`model_ref`),p=Object.prototype.hasOwnProperty.call(l,`reasoningEffort`),m=Object.prototype.hasOwnProperty.call(l,`goldConfig`),h=Math.max(r.messageCount??0,e.messageCount??0),g=e.titleVersion??0,_=r.titleVersion??0,v=g>_?{title:e.title,titleVersion:g}:{title:r.title,titleVersion:_},y={...l,...u,model:c&&d?l.model:u.model,model_ref:c&&f?l.model_ref:u.model_ref,reasoningEffort:c&&p?l.reasoningEffort:u.reasoningEffort,goldConfig:c&&m?l.goldConfig:u.goldConfig,permissionMode:l.permissionModeEtag?l.permissionMode:u.permissionMode,permissionModeEtag:l.permissionModeEtag,bypassPermissions:l.permissionModeEtag?l.bypassPermissions:u.bypassPermissions,compressionEvents:r.config?.compressionEvents??e.config?.compressionEvents,syncCursor:r.config?.syncCursor??e.config?.syncCursor},b={...e,pinned:c?r.pinned:e.pinned,updatedAt:c?r.updatedAt:e.updatedAt,messages:r.messages,messageCount:h,planMode:e.planMode,config:y,...v};return So(r,b)?(t.chats[n]!==r&&(a=!0),r):(a=!0,b)});return!a&&r===t.executionBySession?t:{...t,chats:a?o:t.chats,executionBySession:r}})}async function Oo(e,t){return Z.inFlight?(P(`[ChatSlice]`,`refreshChats.inFlight.reuse`,{}),Z.inFlight):(P(`[ChatSlice]`,`refreshChats.start`,{}),Z.inFlight=(async()=>{try{let n=await Co.listSessions();P(`[ChatSlice]`,`refreshChats.response`,{count:n.sessions.length,runningCount:n.sessions.filter(e=>e.is_running).length}),Do(n.sessions,e),t().reconcileSessionPermissionModes(n.sessions)}catch(e){throw console.error(`[ChatSlice] Failed to refresh sessions:`,e),P(`[ChatSlice]`,`refreshChats.error`,{error:e}),e}})().finally(()=>{P(`[ChatSlice]`,`refreshChats.finally`,{}),Z.inFlight=null}),Z.inFlight)}function ko(e,t){return Z.forcedPromise?(P(`[ChatSlice]`,`refreshChatsNow.forced.reuse`,{}),Z.forcedPromise):(P(`[ChatSlice]`,`refreshChatsNow.forced.start`,{hasInflight:!!Z.inFlight}),Z.forcedPromise=(async()=>{Z.inFlight&&await Z.inFlight,await Oo(e,t)})().finally(()=>{P(`[ChatSlice]`,`refreshChatsNow.forced.finally`,{}),Z.forcedPromise=null}),Z.forcedPromise)}var Ao=ar.getInstance(),jo=new Map,Mo=300,No=(e,t)=>({chats:[],currentSessionId:null,latestActiveSessionId:null,addChat:async t=>{let n=(t.title||Ya.t(`chat.sidebar.newSession`)).trim(),r=t.config?.baseSystemPrompt?.trim()||``,i=Er.getState().providerSnapshot,a=i?.defaults?.chat,o=t.config?.model?.trim()||a?.model?.trim()||void 0,s,c;if(Er.getState().isProviderModelRefEnabled()){let e=t.config?.model_ref;e?.provider?.trim()&&e?.model?.trim()?(s=e,c=e.provider):a?.provider?.trim()&&a?.model?.trim()&&(s=a,c=a.provider)}let l=t.config?.reasoningEffort??eo(i,s??null,c??null),u=await Ao.createSession({title:n,system_prompt:r||void 0,model:o,model_ref:s,provider:c,reasoning_effort:l||void 0,gold_config:t.config?.goldConfig??void 0}),d={...mo(u.session),title:n,config:{...t.config,permissionMode:Wn(u.session.permission_mode),permissionModeEtag:void 0,bypassPermissions:u.session.bypass_permissions??!1,model:u.session.model,model_ref:u.session.model_ref??null,reasoningEffort:u.session.reasoning_effort??null,goldConfig:u.session.gold_config??t.config?.goldConfig??null,baseSystemPrompt:r||oo},messages:[]};return e(e=>{let t=[d,...e.chats.filter(e=>e.id!==d.id)];return{...e,chats:t,currentSessionId:d.id,latestActiveSessionId:d.id}}),d.id},selectSession:n=>{let r=t();r.currentSessionId===n&&r.latestActiveSessionId===n||e({currentSessionId:n,latestActiveSessionId:n})},deleteSession:async n=>{try{await Ao.deleteSession(n)}catch(e){console.error(`[ChatSlice] Failed to delete backend session ${n}:`,e)}let r=t().chats.filter(e=>e.id===n||e.rootSessionId===n).map(e=>e.id);t().resetSessionPermissionModes(r),e(e=>{let t=new Set;for(let r of e.chats)r.id===n&&t.add(r.id),r.rootSessionId===n&&t.add(r.id);let r=e.chats.filter(e=>!t.has(e.id)),i=e.currentSessionId&&t.has(e.currentSessionId)?null:e.currentSessionId,a=e.latestActiveSessionId&&t.has(e.latestActiveSessionId)?r[0]?.id??null:e.latestActiveSessionId;return{...e,chats:r,currentSessionId:i,latestActiveSessionId:a}})},deleteSessions:async e=>{for(let n of e)await t().deleteSession(n)},updateSession:(t,n,r)=>{let i=!!n.config&&(Object.prototype.hasOwnProperty.call(n.config,`model`)||Object.prototype.hasOwnProperty.call(n.config,`reasoningEffort`)||Object.prototype.hasOwnProperty.call(n.config,`goldConfig`)),a=typeof n.title==`string`||typeof n.pinned==`boolean`,o=i||a?new Date().toISOString():void 0;e(e=>{let r=e.chats.map(e=>e.id===t?{...e,...n,...o?{updatedAt:o}:{}}:e);return{...e,chats:r}});let s={};if(typeof n.title==`string`&&(s.title=n.title),typeof n.pinned==`boolean`&&(s.pinned=n.pinned),n.config&&Object.prototype.hasOwnProperty.call(n.config,`model`)&&(s.model=n.config.model??null),n.config&&Object.prototype.hasOwnProperty.call(n.config,`model_ref`)&&Er.getState().isProviderModelRefEnabled()&&(s.model_ref=n.config.model_ref??null,n.config.model_ref&&(s.provider=n.config.model_ref.provider)),n.config&&Object.prototype.hasOwnProperty.call(n.config,`reasoningEffort`)){let e=n.config.reasoningEffort;e?s.reasoning_effort=e:s.clear_reasoning_effort=!0}n.config&&Object.prototype.hasOwnProperty.call(n.config,`goldConfig`)&&(s.gold_config=n.config.goldConfig??{enabled:!1,auto_answer_enabled:!1,auto_continue_enabled:!1}),!r?.skipBackendPatch&&Object.keys(s).length>0&&Ao.patchSession(t,s).catch(e=>{console.warn(`[ChatSlice] Failed to patch session ${t}:`,e)})},persistSessionTitle:async(n,r)=>{let i=t().chats.find(e=>e.id===n)?.title;e(e=>({...e,chats:e.chats.map(e=>e.id===n?{...e,title:r,updatedAt:new Date().toISOString()}:e)}));try{await Ao.patchSession(n,{title:r})}catch(t){throw typeof i==`string`&&e(e=>({...e,chats:e.chats.map(e=>e.id===n?{...e,title:i}:e)})),console.warn(`[ChatSlice] persistSessionTitle failed for ${n}:`,t),t}},applyServerTitle:(t,n,r)=>e(e=>{let i=e.chats.find(e=>e.id===t);return!i||r<=(i.titleVersion??0)?e:{...e,chats:e.chats.map(e=>e.id===t?{...e,title:n,titleVersion:r,updatedAt:new Date().toISOString()}:e)}}),applyServerPinned:(t,n,r)=>e(e=>{let i=e.chats.find(e=>e.id===t);if(!i)return e;let a=Date.parse(r),o=i.updatedAt?Date.parse(i.updatedAt):NaN;return Number.isFinite(a)&&Number.isFinite(o)&&a<o||i.pinned===n?e:{...e,chats:e.chats.map(e=>e.id===t?{...e,pinned:n,updatedAt:r}:e)}}),pinSession:e=>{t().updateSession(e,{pinned:!0})},unpinSession:e=>{t().updateSession(e,{pinned:!1})},setMessages:(e,n)=>{t().chats.find(t=>t.id===e)&&t().updateSession(e,{messages:n})},addMessage:async(e,n)=>{let r=t().chats.find(t=>t.id===e);if(!r)return;let i=[...r.messages,n];t().updateSession(e,{messages:i})},updateMessage:(e,n,r)=>{let i=t().chats.find(t=>t.id===e);if(!i)return;let a=i.messages.map(e=>{if(e.id!==n)return e;let t={...e};return Object.keys(r).forEach(e=>{Object.prototype.hasOwnProperty.call(t,e)&&(t[e]=r[e])}),t});t().updateSession(e,{messages:a})},deleteMessage:async(n,r)=>{let i=t().chats.find(e=>e.id===n);if(!i)return{success:!1,sessionId:n,messageId:r,reason:`session_not_found`};if(!i.messages.some(e=>e.id===r))return{success:!1,sessionId:n,messageId:r,reason:`message_not_found`};try{await Ao.deleteSessionMessage(n,r)}catch(e){return console.warn(`[ChatSlice] Failed to delete message ${r} from session ${n}:`,e),e instanceof Se?e.status===404?{success:!1,sessionId:n,messageId:r,reason:`backend_not_found`,statusCode:e.status,errorMessage:e.message}:e.status===409?{success:!1,sessionId:n,messageId:r,reason:`session_running`,statusCode:e.status,errorMessage:e.message}:{success:!1,sessionId:n,messageId:r,reason:`backend_error`,statusCode:e.status,errorMessage:e.message}:{success:!1,sessionId:n,messageId:r,reason:`backend_error`,errorMessage:e instanceof Error?e.message:void 0}}return e(e=>({...e,chats:e.chats.map(e=>e.id===n?{...e,messages:e.messages.filter(e=>e.id!==r)}:e)})),{success:!0,sessionId:n,messageId:r}},refreshChats:async()=>Z.inFlight?Z.inFlight:Z.timer?(Z.trailingPromise||=new Promise((e,t)=>{Z.trailingResolve=e,Z.trailingReject=t}),Z.trailingPromise):(Z.timer=setTimeout(()=>{if(Z.timer=null,Z.trailingPromise){let n=wo();To(Oo(e,t),n)}},750),Oo(e,t)),refreshChatsNow:async()=>{let n=Eo();P(`[ChatSlice]`,`refreshChatsNow.start`,{hadTrailingCallbacks:!!n,hasInflight:!!Z.inFlight});let r=Z.inFlight?ko(e,t):Oo(e,t);return To(r,n),r},loadChats:async()=>{P(`[ChatSlice]`,`loadChats.start`,{});let n=await Ao.listSessions();if(!n.sessions||n.sessions.length===0){let e=Er.getState().providerSnapshot?.defaults?.chat,t=e?.model?.trim();P(`[ChatSlice]`,`loadChats.createInitialSession`,{defaultModel:t??null,defaultModelRef:e??null}),n={sessions:[(await Ao.createSession({title:Ya.t(`chat.sidebar.newSession`),model:t,model_ref:e,provider:e?.provider})).session]}}let r=n.sessions.map(mo),i=r[0]?.id??null;P(`[ChatSlice]`,`loadChats.listResolved`,{count:n.sessions.length,currentSessionId:i});let a=t().executionBySession;for(let e of n.sessions)a=ei(a,{type:`applySessionSummary`,sessionId:e.id,summary:e});try{let e=await Ao.getRunningSessions();if(P(`[ChatSlice]`,`loadChats.runningSnapshot`,{count:e.sessions.length}),e.sessions.length>0){let t=e.sessions.map(e=>{let t=[];for(let n of e.last_critical_events){if(Dr(n)){kr(n,r);continue}t.push(n)}return{sessionId:e.session_id,runId:e.run_id,criticalEvents:t}});a=ei(a,{type:`applyRunningSnapshot`,sessions:t},()=>new Date().toISOString())}}catch(e){P(`[ChatSlice]`,`loadChats.runningSnapshot.error`,{error:e})}t().resetSessionPermissionModes(),e({chats:r,latestActiveSessionId:i,currentSessionId:i,executionBySession:a}),P(`[ChatSlice]`,`loadChats.applied`,{currentSessionId:i,chatCount:r.length,executionSessionCount:Object.keys(a||{}).length}),i&&(P(`[ChatSlice]`,`loadChats.loadInitialHistory`,{currentSessionId:i}),await t().loadChatHistory(i))},loadChatHistory:async(e,n)=>{let r=n?.mode??`replace`,i=Math.max(0,n?.retries??0),a=Math.max(0,n?.retryDelayMs??0);P(`[ChatSlice]`,`loadChatHistory.start`,{sessionId:e,mode:r,retries:i,retryDelayMs:a,waitForAssistant:n?.waitForAssistant??!1});for(let o=0;o<=i;o+=1)try{let s=t().chats.find(t=>t.id===e);if(!s){P(`[ChatSlice]`,`loadChatHistory.skipMissingChat`,{sessionId:e,attempt:o});return}let c=await Ao.getHistory(e);P(`[ChatSlice]`,`loadChatHistory.response`,{sessionId:e,attempt:o,historyMessageCount:c.messages.length,localMessageCount:s.messages.length,localStoredMessageCount:s.messageCount??null,lastMessageId:c.messages[c.messages.length-1]?.id??null,lastRole:c.messages[c.messages.length-1]?.role??null});let l=c.messages[c.messages.length-1]?.role;if(n?.waitForAssistant&&l===`user`&&o<i){let t=a>0?a*(o+1):200*(o+1);P(`[ChatSlice]`,`loadChatHistory.waitForAssistant.retry`,{sessionId:e,attempt:o,delay:t}),await new Promise(e=>setTimeout(e,t));continue}let u=ho(e,c.messages);if(r===`monotonic`){let n=s.messages||[],r=n.length,i=u.length,a=u[u.length-1]?.role,l=n[n.length-1]?.role,d=n[n.length-1],f=u[u.length-1],p=d?.id,m=f?.id,h=!1;if(i>r?h=!0:i===r&&(h=l===`user`&&a!==`user`||typeof p==`string`&&typeof m==`string`&&p!==m),P(`[ChatSlice]`,`loadChatHistory.monotonicDecision`,{sessionId:e,attempt:o,prevLen:r,nextLen:i,prevLastRole:l??null,nextLastRole:a??null,prevLastId:p??null,nextLastId:m??null,shouldReplace:h}),!h){t().updateSession(e,{messageCount:Math.max(s.messageCount??0,c.messages.length)}),P(`[ChatSlice]`,`loadChatHistory.monotonicSkip`,{sessionId:e,attempt:o,localMessageCount:s.messages.length,serverMessageCount:c.messages.length});return}}let d=t().chats.find(t=>t.id===e);if(!d)return;t().updateSession(e,{messages:u,messageCount:c.messages.length,config:{...d.config,...c.gold_config==null?{}:{goldConfig:c.gold_config},...c.goal_state==null?{}:{goalState:c.goal_state},compressionEvents:(c.compression_events||[]).map(e=>({id:e.id,createdAt:e.created_at,messagesCompressed:e.messages_compressed,segmentsRemoved:e.segments_removed})),syncCursor:{messageCount:c.messages.length,lastMessageId:c.messages[c.messages.length-1]?.id??null,hasPendingQuestion:!!t().executionBySession?.[e]?.interaction.pendingQuestion,pendingQuestionToolCallId:t().executionBySession?.[e]?.interaction.pendingQuestion?.toolCallId??null}}},{skipBackendPatch:!0}),P(`[ChatSlice]`,`loadChatHistory.applied`,{sessionId:e,attempt:o,mode:r,messageCount:c.messages.length,lastMessageId:c.messages[c.messages.length-1]?.id??null});return}catch(t){if(o>=i){console.warn(`[ChatSlice] Failed to load history for ${e}:`,t),P(`[ChatSlice]`,`loadChatHistory.error.final`,{sessionId:e,attempt:o,retries:i,error:t});return}let n=a>0?a*(o+1):200*(o+1);P(`[ChatSlice]`,`loadChatHistory.error.retry`,{sessionId:e,attempt:o,delay:n,error:t}),await new Promise(e=>setTimeout(e,n))}},reconcileOpenSession:(e,n)=>{if(!e||t().currentSessionId!==e)return;let r=jo.get(e);r&&clearTimeout(r),jo.set(e,setTimeout(()=>{jo.delete(e),t().currentSessionId===e&&(async()=>{P(`[ChatSlice]`,`reconcileOpenSession.start`,{sessionId:e,reason:n??null}),await t().loadChatHistory(e,{mode:`monotonic`,waitForAssistant:!0,retries:3,retryDelayMs:250});try{let n=await Ao.getPendingQuestion(e);if(t().currentSessionId!==e)return;n.has_pending_question?t().setPendingQuestion(e,{question:n.question??``,options:n.options??[],allowCustom:n.allow_custom??!0,toolCallId:n.tool_call_id??null}):t().clearPendingQuestion(e)}catch(t){P(`[ChatSlice]`,`reconcileOpenSession.pendingError`,{sessionId:e,error:t})}})()},Mo))}}),Po=class extends Error{code=`proxy_auth_required`;constructor(e=`Proxy authentication required`){super(e),this.name=`ProxyAuthRequiredError`}},Fo=class e{static instance;constructor(){}static getInstance(){return e.instance||=new e,e.instance}async getModels(e){try{let t=await sr.fetchCatalogModels(e),n=[];for(let e of t.fetched)if(e.models&&e.models.length>0)for(let t of e.models)t.reference&&t.reference.model&&n.push(t.reference.model);return[...new Set(n)].sort()}catch(e){if(console.error(`Failed to fetch models from Provider Catalog:`,e),e instanceof Se){if(e.status===428)throw new Po(e.message);let t;if(e.body)try{t=JSON.parse(e.body)}catch{}if(t&&typeof t==`object`&&`error`in t&&t.error?.code===`proxy_auth_required`)throw new Po(t.error?.message||e.message)}throw e}}}.getInstance(),Io=async e=>{if(typeof navigator>`u`||!navigator.clipboard?.writeText)throw Error(`navigator.clipboard.writeText is unavailable`);await navigator.clipboard.writeText(e)},Lo=e=>{if(typeof document>`u`)throw Error(`document is unavailable`);let t=document.createElement(`textarea`);t.value=e,t.setAttribute(`readonly`,`true`),t.style.position=`fixed`,t.style.top=`-9999px`,t.style.left=`-9999px`,t.style.opacity=`0`,document.body.appendChild(t),t.focus(),t.select();let n=document.execCommand(`copy`);if(document.body.removeChild(t),!n)throw Error(`document.execCommand('copy') returned false`)},Ro=async e=>{try{await Io(e);return}catch(t){try{Lo(e);return}catch(e){let n=t instanceof Error?t.message:String(t),r=e instanceof Error?e.message:String(e);throw Error(`Clipboard copy failed: navigator(${n}); fallback(${r})`)}}},zo=class{async copyToClipboard(e){await Ro(e)}async getBambooConfig(){try{return await z.get(`bamboo/config`)}catch(e){return console.error(`Failed to fetch Bamboo config:`,e),{}}}async getBambooTools(){try{return await z.get(`bamboo/tools`)}catch(e){return console.error(`Failed to fetch Bamboo tools:`,e),{tools:[]}}}async getModelLimitDefaults(){try{return await z.get(`bamboo/model-limits/defaults`)}catch(e){return console.error(`Failed to fetch model limit defaults:`,e),{model_limits:[]}}}async setBambooConfig(e){return z.post(`bamboo/config`,e)}async validateBambooConfigPatch(e){return z.post(`bamboo/config/validate`,e)}async setProxyAuth(e){return z.post(`bamboo/proxy-auth`,e)}async getProxyAuthStatus(){try{return await z.get(`bamboo/proxy-auth/status`)}catch(e){return console.error(`Failed to fetch proxy auth status:`,e),{configured:!1,username:null}}}async clearProxyAuth(){return z.post(`bamboo/proxy-auth`,{username:``,password:``})}async resetBambooConfig(){return z.post(`bamboo/config/reset`,{})}async saveWorkflow(e,t){return z.post(`bamboo/workflows`,{name:e,content:t})}async deleteWorkflow(e){return z.delete(`bamboo/workflows/${encodeURIComponent(e)}`)}async getKeywordMaskingConfig(){try{return await z.get(`bamboo/keyword-masking`)}catch(e){return console.error(`Failed to fetch keyword masking config:`,e),{entries:[]}}}async updateKeywordMaskingConfig(e){return z.post(`bamboo/keyword-masking`,e)}async validateKeywordEntries(e){return z.post(`bamboo/keyword-masking/validate`,e)}async getSetupStatus(){return await z.get(`bamboo/setup/status`)}async markSetupComplete(){return z.post(`bamboo/setup/complete`,{})}async resetSetupStatus(){await z.post(`bamboo/setup/incomplete`,{})}async getAccessStatus(){return z.get(`bamboo/access/status`)}async updateAccessPassword(e){return z.post(`bamboo/access/password`,e)}},Bo=class e extends zo{static instance;constructor(){super()}static getInstance(){return e.instance||=new e,e.instance}getUtilityService(){return this}},Vo=Bo.getInstance(),Ho=null,Uo=null,Wo=(e,t)=>e instanceof Error&&e.message.trim()?e.message:t,Go=se((e,t)=>({config:null,proxyAuthStatus:null,isLoadingConfig:!1,isLoadingProxyAuthStatus:!1,lastLoadedAt:null,error:null,loadConfig:async({force:n=!1}={})=>{let r=t().config;if(!n&&r)return r;if(Ho)return Ho;Ho=(async()=>{e({isLoadingConfig:!0,error:null});try{let t=await Vo.getBambooConfig()??{};return e({config:t,lastLoadedAt:Date.now(),error:null}),t}catch(t){throw e({error:Wo(t,`Failed to load Bamboo config`)}),t}finally{e({isLoadingConfig:!1})}})();try{return await Ho}finally{Ho=null}},saveConfig:async t=>{e({isLoadingConfig:!0,error:null,config:t});try{let n=await Vo.setBambooConfig(t);return e({config:n,lastLoadedAt:Date.now(),error:null}),n}catch(t){throw e({error:Wo(t,`Failed to save Bamboo config`)}),t}finally{e({isLoadingConfig:!1})}},patchConfig:async e=>{let n={...await t().loadConfig()??{},...e??{}};return t().saveConfig(n)},loadProxyAuthStatus:async({force:n=!1}={})=>{let r=t().proxyAuthStatus;if(!n&&r)return r;if(Uo)return Uo;Uo=(async()=>{e({isLoadingProxyAuthStatus:!0,error:null});try{let t=await Vo.getProxyAuthStatus();return e({proxyAuthStatus:t,error:null}),t}catch(t){throw e({error:Wo(t,`Failed to load proxy auth status`)}),t}finally{e({isLoadingProxyAuthStatus:!1})}})();try{return await Uo}finally{Uo=null}},applyProxyAuth:async e=>{await Vo.setProxyAuth(e),await t().loadProxyAuthStatus({force:!0})},clearProxyAuth:async()=>{await Vo.clearProxyAuth(),await t().loadProxyAuthStatus({force:!0})}})),Ko=null,qo=(e,t)=>({models:[],selectedModel:void 0,isLoadingModels:!1,modelsError:null,configModel:void 0,setSelectedModel:t=>{e({selectedModel:t})},loadConfigModel:async()=>{try{let t=await Go.getState().loadConfig(),n=typeof t?.model==`string`?t.model:void 0;n&&e({configModel:n})}catch(e){console.error(`Failed to load model from config:`,e)}},fetchModels:async()=>{if(Ko)return Ko;Ko=(async()=>{e({isLoadingModels:!0,modelsError:null});try{try{if(!(await Vo.getSetupStatus()).is_complete){P(`[ModelSlice]`,`Setup not complete, skipping model fetch`),e({models:[],selectedModel:void 0,isLoadingModels:!1,modelsError:`Complete setup to access all models`});return}}catch(e){console.error(`Failed to check setup status:`,e)}let n=await Fo.getModels();e(e=>{let t=e.selectedModel,r=e.selectedModel;return t&&n.includes(t)||(r=void 0),{...e,models:n,selectedModel:r,modelsError:n.length>0?null:`No available model options`}}),t().models.length===0&&console.warn(`No models available from service`)}catch(t){let n=t instanceof Error?t.message:String(t);if(console.error(`Failed to fetch models:`,t),t instanceof Po){e(e=>({...e,models:e.models,selectedModel:e.selectedModel,modelsError:n||`Proxy authentication required. Please configure proxy auth.`}));return}e(e=>({...e,models:[],selectedModel:e.selectedModel,modelsError:n}))}finally{e({isLoadingModels:!1})}})();try{await Ko}finally{Ko=null}}}),Jo=[`system_prompt`,`system_prompt_selected_id`],Yo=e=>({id:e.id,name:e.name||e.id,content:e.content||``,description:e.description,isDefault:!!e.is_default}),Xo=class e{static instance;deprecatedKeysCleanupDone=!1;constructor(){}static getInstance(){return e.instance||=new e,e.instance.cleanupDeprecatedPromptStorageKeys(),e.instance}cleanupDeprecatedPromptStorageKeys(){if(!this.deprecatedKeysCleanupDone){this.deprecatedKeysCleanupDone=!0;try{for(let e of Jo)localStorage.removeItem(e)}catch(e){console.warn(`[SystemPromptService] Failed to cleanup deprecated prompt storage keys:`,e)}}}async getSystemPromptPresets(){try{let e=await z.get(`prompt-presets`),t=(Array.isArray(e?.prompts)?e.prompts:[]).filter(e=>e.id&&e.id.trim().length>0).map(Yo);if(t.length>0)return t}catch(e){console.error(`Failed to load prompt presets from backend:`,e)}return no()}async createSystemPromptPreset(e){let t={name:e.name,content:e.content};e.id?.trim()&&(t.id=e.id.trim()),e.description!==void 0&&(t.description=e.description);let n=await z.post(`prompt-presets`,t);if(!n?.prompt)throw Error(`Backend did not return created prompt preset`);return Yo(n.prompt)}async updateSystemPromptPreset(e){let t=encodeURIComponent(e.id),n={name:e.name,content:e.content,description:e.description},r=await z.patch(`prompt-presets/${t}`,n);if(!r?.prompt)throw Error(`Backend did not return updated prompt preset`);return Yo(r.prompt)}async deleteSystemPromptPreset(e){let t=encodeURIComponent(e);await z.delete(`prompt-presets/${t}`)}async findPresetById(e){return(await this.getSystemPromptPresets()).find(t=>t.id===e)}async getCurrentSystemPromptContent(e){let t=await this.findPresetById(e);if(t)return t.content;let n=await this.getSystemPromptPresets();return(n.find(e=>e.isDefault)||n[0])?.content||``}},Zo=`copilot_last_selected_prompt_id`,Qo=`copilot_custom_system_prompts_v2`,$o=`copilot_custom_system_prompts_v2_migrated_to_backend`,es=`general_assistant`,ts=80,ns=Xo.getInstance(),rs=null;function is(e){let t=e.toLowerCase().trim().replace(/[^a-z0-9]+/g,`_`).replace(/^_+|_+$/g,``);return t.length===0?`prompt_${Date.now()}_${Math.random().toString(36).substring(2,9)}`:t.slice(0,ts)}function as(e){if(typeof e!=`string`)return null;let t=e.toLowerCase().trim().replace(/[^a-z0-9_]+/g,`_`).replace(/^_+|_+$/g,``);return t?t.slice(0,ts):null}function os(e,t){if(!t.has(e))return e;let n=2;for(;;){let r=`_${n}`,i=`${e.slice(0,Math.max(0,ts-r.length))}${r}`;if(!t.has(i))return i;n+=1}}function ss(){try{let e=localStorage.getItem(Qo);if(!e)return[];let t=JSON.parse(e);if(!Array.isArray(t))return[];let n=new Set,r=[];for(let e of t){let t=typeof e?.name==`string`?e.name.trim():``,i=typeof e?.content==`string`?e.content.trim():``;if(!t||!i)continue;let a=os(as(e?.id)||is(t),n);a!==es&&(n.add(a),r.push({id:a,name:t,content:i,description:typeof e?.description==`string`&&e.description.trim()||void 0,isDefault:!!e?.isDefault}))}return r}catch(e){return console.error(`[promptSlice] Failed to read legacy custom prompts:`,e),[]}}function cs(){try{return localStorage.getItem($o)===`1`}catch(e){return console.error(`[promptSlice] Failed to read migration marker:`,e),!1}}function ls(){try{localStorage.setItem($o,`1`)}catch(e){console.error(`[promptSlice] Failed to write migration marker:`,e)}}function us(){try{localStorage.removeItem(Qo)}catch(e){console.error(`[promptSlice] Failed to clear legacy custom prompts:`,e)}}async function ds(){if(cs())return;let e=ss();if(e.length===0){us(),ls();return}let t=await ns.getSystemPromptPresets(),n=new Set(t.map(e=>e.id)),r=!1;for(let t of e){let e=t.name?.trim(),i=t.content?.trim();if(!e||!i||t.id===es||t.isDefault)continue;let a=os(as(t.id)||is(e),n);try{let r=await ns.createSystemPromptPreset({id:a,name:e,content:i,description:t.description});n.add(r.id)}catch(t){r=!0,console.error(`[promptSlice] Failed to migrate legacy prompt '${e}' to backend:`,t)}}r||(us(),ls())}async function fs(){rs||=ds().finally(()=>{rs=null}),await rs}var ps=(e,t)=>({systemPrompts:[],lastSelectedPromptId:localStorage.getItem(Zo)||null,loadSystemPrompts:async()=>{try{await fs()}catch(e){console.warn(`[promptSlice] Legacy prompt migration skipped:`,e)}let t=[];try{t=await ns.getSystemPromptPresets()}catch(e){console.error(`Failed to load system prompts from backend:`,e)}let n=t.length?t:no();if(!cs()){let e=ss();n=ms(n,e)}n.length===0&&(n=no()),e({systemPrompts:n})},addSystemPrompt:async e=>{try{await ns.createSystemPromptPreset({id:is(e.name),name:e.name,content:e.content,description:e.description}),await t().loadSystemPrompts()}catch(e){throw console.error(`Failed to add system prompt:`,e),e}},updateSystemPrompt:async e=>{try{await ns.updateSystemPromptPreset(e),await t().loadSystemPrompts()}catch(e){throw console.error(`Failed to update system prompt:`,e),e}},deleteSystemPrompt:async e=>{try{await ns.deleteSystemPromptPreset(e),await t().loadSystemPrompts()}catch(e){throw console.error(`Failed to delete system prompt:`,e),e}},setLastSelectedPromptId:t=>{e({lastSelectedPromptId:t});try{localStorage.setItem(Zo,t)}catch(e){console.error(`Failed to save last selected prompt ID to localStorage:`,e)}}}),ms=(e,t)=>{let n=new Map;return e.forEach(e=>{n.set(e.id,e)}),t.forEach(e=>{n.set(e.id,e)}),Array.from(n.values())},hs=()=>({}),gs=new class{async listSkills(e,t){let n=new URLSearchParams;e?.search&&n.append(`search`,e.search),e?.includeDisabled&&n.append(`include_disabled`,`true`),t&&n.append(`refresh`,`true`);let r=n.toString(),i=r?`skills?${r}`:`skills`;return z.get(i)}async getSkill(e){return z.get(`skills/${e}`)}async getFilteredTools(e){let t=e?`?session_id=${encodeURIComponent(e)}`:``;return(await z.get(`skills/filtered-tools${t}`)).tools??[]}},_s=(e,t)=>({skills:[],isLoadingSkills:!1,skillsError:null,loadSkills:async(t,n)=>{e({isLoadingSkills:!0,skillsError:null});try{e({skills:(await gs.listSkills(t,n)).skills,isLoadingSkills:!1})}catch(t){e({skillsError:t instanceof Error?t.message:Ya.t(`components.skillManager.loadFailed`),isLoadingSkills:!1})}},getSkill:async n=>{e({isLoadingSkills:!0,skillsError:null});try{let r=await gs.getSkill(n),i=t().skills;e({skills:i.findIndex(e=>e.id===r.id)>=0?i.map(e=>e.id===r.id?r:e):[...i,r],isLoadingSkills:!1})}catch(t){e({skillsError:t instanceof Error?t.message:Ya.t(`components.skillManager.getFailed`),isLoadingSkills:!1})}},clearSkillsError:()=>{e({skillsError:null})}}),vs=e=>({tokenUsages:{},truncationOccurred:{},segmentsRemoved:{},updateTokenUsage:(t,n)=>e(e=>({tokenUsages:{...e.tokenUsages,[t]:n}})),setTruncationInfo:(t,n,r)=>e(e=>({truncationOccurred:{...e.truncationOccurred,[t]:n},segmentsRemoved:{...e.segmentsRemoved,[t]:r}})),clearTokenUsage:t=>e(e=>{let{[t]:n,...r}=e.tokenUsages,{[t]:i,...a}=e.truncationOccurred,{[t]:o,...s}=e.segmentsRemoved;return{tokenUsages:r,truncationOccurred:a,segmentsRemoved:s}})}),ys=ar.getInstance(),bs=(e,t)=>({taskLists:{},taskListVersions:{},activeItems:{},evaluationStates:{},setTaskList:(t,n)=>e(e=>({taskLists:{...e.taskLists,[t]:n},taskListVersions:{...e.taskListVersions,[t]:n.version||0}})),loadTaskList:async e=>{let n=await ys.getTaskList(e);return n?(t().setTaskList(n.session_id||e,n),n):null},updateTaskListDelta:(t,n)=>e(e=>{let r=e.taskListVersions[t]||0;if(n.version<=r)return e;let i=e.taskLists[t];if(!i)return e;let a=i.items.map(e=>e.id===n.item_id?{...e,status:n.status,tool_calls_count:n.tool_calls_count}:e);return{taskLists:{...e.taskLists,[t]:{...i,items:a,updated_at:new Date().toISOString()}},taskListVersions:{...e.taskListVersions,[t]:n.version},activeItems:{...e.activeItems,[t]:n.status===`in_progress`?n.item_id:null}}}),clearTaskList:t=>e(e=>{let{[t]:n,...r}=e.taskLists,{[t]:i,...a}=e.taskListVersions,{[t]:o,...s}=e.activeItems,{[t]:c,...l}=e.evaluationStates;return{taskLists:r,taskListVersions:a,activeItems:s,evaluationStates:l}}),getTaskListVersion:e=>t().taskListVersions[e]||0,setEvaluationState:(t,n)=>e(e=>({evaluationStates:{...e.evaluationStates,[t]:n}})),clearEvaluationState:t=>e(e=>{let{[t]:n,...r}=e.evaluationStates;return{evaluationStates:r}})}),xs=e(t(((e,t)=>{((n,r)=>{typeof e==`object`&&t!==void 0?t.exports=r():typeof define==`function`&&define.amd?define(r):(n=typeof globalThis<`u`?globalThis:n||self).Dexie=r()})(e,function(){var e=function(t,n){return(e=Object.setPrototypeOf||({__proto__:[]}instanceof Array?function(e,t){e.__proto__=t}:function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])}))(t,n)},t=function(){return(t=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e}).apply(this,arguments)};function n(e,t,n){if(n||arguments.length===2)for(var r,i=0,a=t.length;i<a;i++)!r&&i in t||((r||=Array.prototype.slice.call(t,0,i))[i]=t[i]);return e.concat(r||Array.prototype.slice.call(t))}var r=typeof globalThis<`u`?globalThis:typeof self<`u`?self:typeof window<`u`?window:global,i=Object.keys,a=Array.isArray;function o(e,t){return typeof t==`object`&&i(t).forEach(function(n){e[n]=t[n]}),e}typeof Promise>`u`||r.Promise||(r.Promise=Promise);var s=Object.getPrototypeOf,c={}.hasOwnProperty;function l(e,t){return c.call(e,t)}function u(e,t){typeof t==`function`&&(t=t(s(e))),(typeof Reflect>`u`?i:Reflect.ownKeys)(t).forEach(function(n){f(e,n,t[n])})}var d=Object.defineProperty;function f(e,t,n,r){d(e,t,o(n&&l(n,`get`)&&typeof n.get==`function`?{get:n.get,set:n.set,configurable:!0}:{value:n,configurable:!0,writable:!0},r))}function p(e){return{from:function(t){return e.prototype=Object.create(t.prototype),f(e.prototype,`constructor`,e),{extend:u.bind(null,e.prototype)}}}}var m=Object.getOwnPropertyDescriptor,h=[].slice;function g(e,t,n){return h.call(e,t,n)}function _(e,t){return t(e)}function v(e){if(!e)throw Error(`Assertion Failed`)}function y(e){r.setImmediate?setImmediate(e):setTimeout(e,0)}function b(e,t){if(typeof t==`string`&&l(e,t))return e[t];if(!t)return e;if(typeof t!=`string`){for(var n=[],r=0,i=t.length;r<i;++r){var a=b(e,t[r]);n.push(a)}return n}var o,s=t.indexOf(`.`);return s===-1||(o=e[t.substr(0,s)])==null?void 0:b(o,t.substr(s+1))}function x(e,t,n){if(e&&t!==void 0&&!(`isFrozen`in Object&&Object.isFrozen(e)))if(typeof t!=`string`&&`length`in t){v(typeof n!=`string`&&`length`in n);for(var r=0,i=t.length;r<i;++r)x(e,t[r],n[r])}else{var o=t.indexOf(`.`);if(o!==-1){var s=t.substr(0,o),o=t.substr(o+1);if(o===``)n===void 0?a(e)&&!isNaN(parseInt(s))?e.splice(s,1):delete e[s]:e[s]=n;else{var c=e[s];if(!c||!l(e,s)){if(n===void 0)return;c=e[s]={}}x(c,o,n)}}else n===void 0?a(e)&&!isNaN(parseInt(t))?e.splice(t,1):delete e[t]:e[t]=n}}function S(e){var t,n={};for(t in e)l(e,t)&&(n[t]=e[t]);return n}var C=[].concat;function w(e){return C.apply([],e)}var T=`BigUint64Array,BigInt64Array,Array,Boolean,String,Date,RegExp,Blob,File,FileList,FileSystemFileHandle,FileSystemDirectoryHandle,ArrayBuffer,DataView,Uint8ClampedArray,ImageBitmap,ImageData,Map,Set,CryptoKey`.split(`,`).concat(w([8,16,32,64].map(function(e){return[`Int`,`Uint`,`Float`].map(function(t){return t+e+`Array`})}))).filter(function(e){return r[e]}),E=new Set(T.map(function(e){return r[e]})),D=null;function O(e){return D=new WeakMap,e=function e(t){if(!t||typeof t!=`object`)return t;var n=D.get(t);if(n)return n;if(a(t)){n=[],D.set(t,n);for(var r=0,i=t.length;r<i;++r)n.push(e(t[r]))}else if(E.has(t.constructor))n=t;else{var o,c=s(t);for(o in n=c===Object.prototype?{}:Object.create(c),D.set(t,n),t)l(t,o)&&(n[o]=e(t[o]))}return n}(e),D=null,e}var ee={}.toString;function k(e){return ee.call(e).slice(8,-1)}var te=typeof Symbol<`u`?Symbol.iterator:`@@iterator`,ne=typeof te==`symbol`?function(e){var t;return e!=null&&(t=e[te])&&t.apply(e)}:function(){return null};function A(e,t){t=e.indexOf(t),0<=t&&e.splice(t,1)}var re={};function ie(e){var t,n,r,i;if(arguments.length===1){if(a(e))return e.slice();if(this===re&&typeof e==`string`)return[e];if(i=ne(e))for(n=[];!(r=i.next()).done;)n.push(r.value);else{if(e==null||typeof(t=e.length)!=`number`)return[e];for(n=Array(t);t--;)n[t]=e[t]}}else for(t=arguments.length,n=Array(t);t--;)n[t]=arguments[t];return n}var ae=typeof Symbol<`u`?function(e){return e[Symbol.toStringTag]===`AsyncFunction`}:function(){return!1},T=[`Unknown`,`Constraint`,`Data`,`TransactionInactive`,`ReadOnly`,`Version`,`NotFound`,`InvalidState`,`InvalidAccess`,`Abort`,`Timeout`,`QuotaExceeded`,`Syntax`,`DataClone`],j=[`Modify`,`Bulk`,`OpenFailed`,`VersionChange`,`Schema`,`Upgrade`,`InvalidTable`,`MissingAPI`,`NoSuchDatabase`,`InvalidArgument`,`SubTransaction`,`Unsupported`,`Internal`,`DatabaseClosed`,`PrematureCommit`,`ForeignAwait`].concat(T),oe={VersionChanged:`Database version changed by other database connection`,DatabaseClosed:`Database has been closed`,Abort:`Transaction aborted`,TransactionInactive:`Transaction has already completed or failed`,MissingAPI:`IndexedDB API missing. Please visit https://tinyurl.com/y2uuvskb`};function se(e,t){this.name=e,this.message=t}function ce(e,t){return e+`. Errors: `+Object.keys(t).map(function(e){return t[e].toString()}).filter(function(e,t,n){return n.indexOf(e)===t}).join(`
|
|
15
|
+
If requirements are unclear, ask focused clarifying questions before proceeding.`,isDefault:!0}),no=()=>[to()];function ro(e){if(!e)return;let t={systemTokens:e.system_tokens,summaryTokens:e.summary_tokens,windowTokens:e.window_tokens,totalTokens:e.total_tokens,budgetLimit:e.budget_limit};return typeof e.max_context_tokens==`number`&&e.max_context_tokens>0&&(t.maxContextTokens=e.max_context_tokens),typeof e.prompt_cached_tool_outputs==`number`&&(t.promptCachedToolOutputs=e.prompt_cached_tool_outputs),typeof e.prompt_cached_tool_tokens_saved==`number`&&(t.promptCachedToolTokensSaved=e.prompt_cached_tool_tokens_saved),typeof e.thinking_tokens==`number`&&(t.thinkingTokens=e.thinking_tokens),typeof e.cache_read_input_tokens==`number`&&(t.cacheReadInputTokens=e.cache_read_input_tokens),t}var io=no()[0],ao=io?.id||`general_assistant`,oo=io?.content?.trim()||``,so=`tool`,co=()=>{try{let e=globalThis.crypto;if(e?.randomUUID)return e.randomUUID()}catch{}return`id_${Date.now()}_${Math.random().toString(16).slice(2)}`},lo=e=>{let t=e.trim();if(!t.startsWith(`bamboo-attachment://`))return null;let[n,r]=t.slice(20).split(`/`,2);return!n||!r?null:{sessionId:n,attachmentId:r}},uo=e=>{let t=lo(e);return t?z.resolveUrl(`sessions/${encodeURIComponent(t.sessionId)}/attachments/${encodeURIComponent(t.attachmentId)}`):e},fo=e=>{if(typeof e!=`string`)return;let t=e.trim();if(t&&t.toLowerCase()!==`unknown`)return t},po=e=>{let t=(e||``).trim();if(!t)return;let n=t.match(/tool policy blocked ['"`]([^'"`]+)['"`]/i);if(n?.[1])return fo(n[1]);try{let e=JSON.parse(t);if(typeof e?.tool_name==`string`)return fo(e.tool_name)}catch{}},mo=e=>{let t=Number.isFinite(Date.parse(e.created_at))?Date.parse(e.created_at):Date.now(),n=ro(e.token_usage);return{id:e.id,kind:e.kind,parentSessionId:e.parent_session_id??null,rootSessionId:e.root_session_id,spawnDepth:e.spawn_depth,createdByScheduleId:e.created_by_schedule_id??null,isRunning:e.is_running,updatedAt:e.updated_at,lastActivityAt:e.last_activity_at,messageCount:e.message_count,hasAttachments:e.has_attachments,lastRunStatus:e.last_run_status,lastRunError:e.last_run_error,planMode:e.plan_mode??null,subagentType:e.subagent_type??null,lifecycle:e.lifecycle??null,residentName:e.resident_name??null,subagentCount:e.subagent_count??0,placement:e.placement??null,title:e.title||Ya.t(`chat.session.defaultTitle`),titleVersion:e.title_version??0,createdAt:t,pinned:e.pinned,messages:[],config:{systemPromptId:ao,baseSystemPrompt:oo,lastUsedEnhancedPrompt:null,model:e.model,model_ref:e.model_ref??null,reasoningEffort:e.reasoning_effort??null,bypassPermissions:e.bypass_permissions??!1,permissionMode:Wn(e.permission_mode),goldConfig:e.gold_config??null,tokenUsage:n,truncationOccurred:e.token_usage?.truncation_occurred,segmentsRemoved:e.token_usage?.segments_removed,compressionEvents:[]}}},ho=(e,t)=>{let n=new Map,r=new Map;for(let e of t)e.role===`tool`&&e.tool_call_id&&e.metadata&&r.set(e.tool_call_id,e.metadata);let i=[];for(let e of t){let t=e.created_at||new Date().toISOString();if(e.role===`system`){let n={role:`system`,id:e.id,createdAt:t,content:e.content||``,isCompressed:!!e.compressed,compressedEventId:e.compressed_by_event_id};i.push(n);continue}if(e.role===`user`){let n=new Map;for(let t of e.image_ocr||[]){let e=t.image_url?.trim();if(!e)continue;let r=(t.lines||[]).map(e=>(e?.text||``).trim()).filter(Boolean);n.set(e,{ocrText:r.length?r.join(`
|
|
16
|
+
`):void 0,ocrError:t.error?String(t.error):void 0})}let r=[];for(let t of e.content_parts||[]){if(t.type!==`image_url`)continue;let e=t.image_url?.url||``;if(!e)continue;let i=uo(e),a=lo(e),o=n.get(e.trim());r.push({id:co(),url:i,ocrText:o?.ocrText,ocrError:o?.ocrError,name:a?`attachment-${a.attachmentId}`:`image`,size:0,type:`image/*`})}let a={role:`user`,id:e.id,createdAt:t,content:e.content||``,images:r.length?r:void 0,isCompressed:!!e.compressed,compressedEventId:e.compressed_by_event_id};i.push(a);continue}if(e.role===`assistant`){let a=e.tool_calls||[];if(a.length>0){let o=(e.content||``).trim(),s=typeof e.reasoning==`string`&&e.reasoning.trim().length>0;if(o||s){let n=s?{reasoning:e.reasoning,backendMessageId:e.id}:{backendMessageId:e.id},r={role:`assistant`,type:`text`,id:`${e.id}_text`,createdAt:t,content:e.content||``,metadata:n,isCompressed:!!e.compressed,compressedEventId:e.compressed_by_event_id};i.push(r)}for(let e of a)e.id&&n.set(e.id,fo(e.function?.name)||so);let c=a[0]?.id,l=c?r.get(c):void 0,u={role:`assistant`,type:`tool_call`,id:e.id,createdAt:t,toolCalls:a.map(e=>({toolCallId:e.id,toolName:fo(e.function?.name)||so,parameters:(()=>{try{return JSON.parse(e.function?.arguments||`{}`)}catch{return{raw:e.function?.arguments||``}}})(),streamingOutput:``})),...l?{metadata:l}:{},isCompressed:!!e.compressed,compressedEventId:e.compressed_by_event_id};i.push(u);continue}let o=typeof e.reasoning==`string`&&e.reasoning.trim().length>0?{reasoning:e.reasoning}:{},s={role:`assistant`,type:`text`,id:e.id,createdAt:t,content:e.content||``,metadata:o,isCompressed:!!e.compressed,compressedEventId:e.compressed_by_event_id};i.push(s);continue}if(e.role===`tool`){let r=e.tool_call_id?.trim()||`orphan-tool-call:${e.id}`,a=fo(n.get(r))||fo(e.tool_name)||fo(e.name)||po(e.content)||so,o=e.tool_success===!1||e.tool_success==null&&typeof e.content==`string`&&e.content.trimStart().startsWith(`Error:`),s=[];for(let t of e.content_parts||[]){if(t.type!==`image_url`)continue;let e=t.image_url?.url||``;e&&s.push({id:co(),url:uo(e),name:`screenshot`,size:0,type:`image/*`})}let c={role:`assistant`,type:`tool_result`,id:e.id,createdAt:t,toolName:a,toolCallId:r,result:{tool_name:a,result:e.content||``,display_preference:`Default`},isError:o,images:s.length?s:void 0,isCompressed:!!e.compressed,compressedEventId:e.compressed_by_event_id};i.push(c);continue}}return i},go=e=>{if(typeof e!=`string`||!e.trim())return null;let t=Date.parse(e);return Number.isFinite(t)?t:null},_o=(e,t)=>e===t?!0:!e||!t?e==null&&t==null:e.provider===t.provider&&e.model===t.model,vo=(e,t)=>e===t?!0:!e||!t?e==null&&t==null:e.systemTokens===t.systemTokens&&e.summaryTokens===t.summaryTokens&&e.windowTokens===t.windowTokens&&e.totalTokens===t.totalTokens&&(e.maxContextTokens??0)===(t.maxContextTokens??0)&&e.budgetLimit===t.budgetLimit&&(e.promptCachedToolOutputs??0)===(t.promptCachedToolOutputs??0)&&(e.promptCachedToolTokensSaved??0)===(t.promptCachedToolTokensSaved??0)&&(e.thinkingTokens??0)===(t.thinkingTokens??0)&&(e.cacheReadInputTokens??0)===(t.cacheReadInputTokens??0),yo=(e,t)=>{if(e===t)return!0;let n=e??[],r=t??[];return n.length===r.length?n.every((e,t)=>{let n=r[t];return!!n&&e.id===n.id&&e.createdAt===n.createdAt&&e.messagesCompressed===n.messagesCompressed&&e.segmentsRemoved===n.segmentsRemoved}):!1},bo=(e,t)=>e===t?!0:!e||!t?e==null&&t==null:e.messageCount===t.messageCount&&e.lastMessageId===t.lastMessageId&&e.hasPendingQuestion===t.hasPendingQuestion&&e.pendingQuestionToolCallId===t.pendingQuestionToolCallId,xo=(e,t)=>e===t?!0:e.systemPromptId===t.systemPromptId&&e.baseSystemPrompt===t.baseSystemPrompt&&e.lastUsedEnhancedPrompt===t.lastUsedEnhancedPrompt&&e.agentRole===t.agentRole&&e.workspacePath===t.workspacePath&&e.model===t.model&&_o(e.model_ref,t.model_ref)&&e.reasoningEffort===t.reasoningEffort&&e.bypassPermissions===t.bypassPermissions&&e.permissionMode===t.permissionMode&&e.permissionModeEtag===t.permissionModeEtag&&JSON.stringify(e.goldConfig??null)===JSON.stringify(t.goldConfig??null)&&JSON.stringify(e.goalState??null)===JSON.stringify(t.goalState??null)&&vo(e.tokenUsage,t.tokenUsage)&&e.truncationOccurred===t.truncationOccurred&&e.segmentsRemoved===t.segmentsRemoved&&yo(e.compressionEvents,t.compressionEvents)&&bo(e.syncCursor,t.syncCursor),So=(e,t)=>e.id===t.id&&e.kind===t.kind&&e.parentSessionId===t.parentSessionId&&e.rootSessionId===t.rootSessionId&&e.spawnDepth===t.spawnDepth&&e.createdByScheduleId===t.createdByScheduleId&&e.isRunning===t.isRunning&&e.updatedAt===t.updatedAt&&e.lastActivityAt===t.lastActivityAt&&e.messageCount===t.messageCount&&e.hasAttachments===t.hasAttachments&&e.lastRunStatus===t.lastRunStatus&&e.lastRunError===t.lastRunError&&e.planMode===t.planMode&&e.subagentType===t.subagentType&&e.subagentCount===t.subagentCount&&e.placement?.kind===t.placement?.kind&&e.placement?.host===t.placement?.host&&e.title===t.title&&e.titleVersion===t.titleVersion&&e.createdAt===t.createdAt&&e.pinned===t.pinned&&e.messages===t.messages&&xo(e.config,t.config),Co=ar.getInstance(),wo=200,To=2,Eo=new Map;async function Do(e,t=Co){let n=null,r=0;for(;;){let i=new Map,a=new Set,o=null,s=!1,c=0;for(;;){if(a.has(c))throw Error(`Session pagination repeated offset ${c}`);a.add(c);let l=await t.listSessions({...e,limit:e.limit??wo,offset:c});if(!Number.isSafeInteger(l.total)||l.total<0)throw Error(`Session pagination returned invalid total ${l.total}`);o===null?o=l.total:l.total!==o&&(s=!0);for(let t of l.sessions){if(e.kind&&t.kind!==e.kind)throw Error(`Session list returned ${t.kind} for ${e.kind} query`);if(e.root_session_id&&t.root_session_id!==e.root_session_id)throw Error(`Session list returned a row from another root tree`);i.has(t.id)?s=!0:i.set(t.id,t)}let u=l.next_offset;if(typeof u==`number`){if(!Number.isSafeInteger(u)||u<=c)throw Error(`Session pagination did not advance from offset ${c}`);c=u;continue}if(!s&&i.size===l.total){let e=[...i.values()];if(a.size===1)return e;let t=e.map(e=>e.id);if(n?.length===t.length&&n.every((e,n)=>e===t[n]))return e;n&&(r+=1),n=t}else r+=1,n=null;if(r>To)throw Error(`Session pagination changed while reading; retry the refresh`);break}}}var Z={inFlight:null,forcedPromise:null,timer:null,trailingPromise:null,trailingResolve:null,trailingReject:null};function Oo(){let e={resolve:Z.trailingResolve,reject:Z.trailingReject};return Z.trailingPromise=null,Z.trailingResolve=null,Z.trailingReject=null,e}function ko(e,t){!t.resolve&&!t.reject||e.then(()=>t.resolve?.(),e=>t.reject?.(e))}function Ao(){return Z.timer&&=(clearTimeout(Z.timer),null),Oo()}function jo(e,t,n={kind:`all`}){let r=e.map(mo);t(t=>{let i=t.executionBySession;for(let t of e)i=ei(i,{type:`applySessionSummary`,sessionId:t.id,summary:t});let a=new Map(t.chats.map(e=>[e.id,e])),o=r.map(e=>{let t=a.get(e.id);if(!t)return e;let n=go(t.updatedAt),r=go(e.updatedAt),i=n!==null&&r!==null&&n>r,o=t.config||{},s=e.config||{},c=Object.prototype.hasOwnProperty.call(o,`model`),l=Object.prototype.hasOwnProperty.call(o,`model_ref`),u=Object.prototype.hasOwnProperty.call(o,`reasoningEffort`),d=Object.prototype.hasOwnProperty.call(o,`goldConfig`),f=Math.max(t.messageCount??0,e.messageCount??0),p=e.titleVersion??0,m=t.titleVersion??0,h=p>m?{title:e.title,titleVersion:p}:{title:t.title,titleVersion:m},g={...o,...s,model:i&&c?o.model:s.model,model_ref:i&&l?o.model_ref:s.model_ref,reasoningEffort:i&&u?o.reasoningEffort:s.reasoningEffort,goldConfig:i&&d?o.goldConfig:s.goldConfig,permissionMode:o.permissionModeEtag?o.permissionMode:s.permissionMode,permissionModeEtag:o.permissionModeEtag,bypassPermissions:o.permissionModeEtag?o.bypassPermissions:s.bypassPermissions,compressionEvents:t.config?.compressionEvents??e.config?.compressionEvents,syncCursor:t.config?.syncCursor??e.config?.syncCursor},_={...e,pinned:i?t.pinned:e.pinned,updatedAt:i?t.updatedAt:e.updatedAt,messages:t.messages,messageCount:f,planMode:e.planMode,config:g,...h};return So(t,_)?t:_}),s;switch(n.kind){case`all`:s=o;break;case`roots`:{let e=new Set(o.map(e=>e.id));s=[...o,...t.chats.filter(t=>{let n=t.rootSessionId;return t.kind===`child`&&typeof n==`string`&&e.has(n)})];break}case`children`:s=[...t.chats.filter(e=>!(e.kind===`child`&&e.rootSessionId===n.rootSessionId)),...o];break;case`upsert`:{let e=new Map(o.map(e=>[e.id,e]));s=t.chats.map(t=>e.get(t.id)??t),s.push(...o.filter(e=>!a.has(e.id)));break}}let c=new Set;s=s.filter(e=>c.has(e.id)?!1:(c.add(e.id),!0));let l=t.currentSessionId?a.get(t.currentSessionId):void 0,u=n.kind===`children`&&s.some(e=>e.id===n.rootSessionId&&e.kind!==`child`)?n.rootSessionId:null,d=n.kind===`children`&&l?.kind===`child`&&l.rootSessionId===n.rootSessionId&&!c.has(l.id)?u:t.currentSessionId,f=t.latestActiveSessionId?a.get(t.latestActiveSessionId):void 0,p=n.kind===`children`&&f?.kind===`child`&&f.rootSessionId===n.rootSessionId&&!c.has(f.id)?u:t.latestActiveSessionId,m=s.length!==t.chats.length||s.some((e,n)=>e!==t.chats[n]),h=n.kind===`roots`?t.sessionIndexRevision+1:t.sessionIndexRevision;return!m&&i===t.executionBySession&&d===t.currentSessionId&&p===t.latestActiveSessionId&&h===t.sessionIndexRevision?t:{...t,chats:m?s:t.chats,executionBySession:i,currentSessionId:d,latestActiveSessionId:p,sessionIndexRevision:h}})}function Mo(e,t,n,r={}){let i=n().chats.find(t=>t.id===e);if(!i)return Promise.resolve();let a=i.kind===`child`?i.rootSessionId:i.id;if(!a)return Promise.resolve();let o=n().chats.find(e=>e.id===a);if(!o||o.kind===`child`)return Promise.resolve();let s=Eo.get(a);if(s)return r.force&&(s.requestedRevision=Math.max(s.requestedRevision,n().sessionIndexRevision)),s.promise;let c=n().chats.filter(e=>e.kind===`child`&&e.rootSessionId===a),l=o.subagentCount??0;if(!r.force&&c.length===l)return Promise.resolve();let u={requestedRevision:n().sessionIndexRevision,promise:Promise.resolve()};return u.promise=(async()=>{let e=-1;for(;e<u.requestedRevision;){let r=u.requestedRevision,i=n().chats.find(e=>e.id===a),o=i?.kind===`root`?i.subagentCount??0:0;P(`[ChatSlice]`,`subagents.load.start`,{rootSessionId:a,expectedChildren:o,sessionIndexRevision:r});let s=o===0?[]:await Do({kind:`child`,root_session_id:a,limit:wo}),c=n().chats.find(e=>e.id===a);if(!c||c.kind!==`root`){P(`[ChatSlice]`,`subagents.load.discarded`,{rootSessionId:a,reason:`root_removed`,sessionIndexRevision:r});return}jo(s,t,{kind:`children`,rootSessionId:a}),n().reconcileSessionPermissionModes(s),e=r,P(`[ChatSlice]`,`subagents.load.applied`,{rootSessionId:a,count:s.length,sessionIndexRevision:r})}})().finally(()=>{Eo.get(a)===u&&Eo.delete(a)}),Eo.set(a,u),u.promise}async function No(e,t){return Z.inFlight?(P(`[ChatSlice]`,`refreshChats.inFlight.reuse`,{}),Z.inFlight):(P(`[ChatSlice]`,`refreshChats.start`,{}),Z.inFlight=(async()=>{try{let n=await Do({kind:`root`,limit:wo});P(`[ChatSlice]`,`refreshChats.response`,{count:n.length,runningCount:n.filter(e=>e.is_running).length}),jo(n,e,{kind:`roots`}),t().reconcileSessionPermissionModes(n)}catch(e){throw console.error(`[ChatSlice] Failed to refresh sessions:`,e),P(`[ChatSlice]`,`refreshChats.error`,{error:e}),e}})().finally(()=>{P(`[ChatSlice]`,`refreshChats.finally`,{}),Z.inFlight=null}),Z.inFlight)}function Po(e,t){return Z.forcedPromise?(P(`[ChatSlice]`,`refreshChatsNow.forced.reuse`,{}),Z.forcedPromise):(P(`[ChatSlice]`,`refreshChatsNow.forced.start`,{hasInflight:!!Z.inFlight}),Z.forcedPromise=(async()=>{Z.inFlight&&await Z.inFlight,await No(e,t)})().finally(()=>{P(`[ChatSlice]`,`refreshChatsNow.forced.finally`,{}),Z.forcedPromise=null}),Z.forcedPromise)}var Fo=ar.getInstance(),Io=new Map,Lo=300,Ro=(e,t)=>({chats:[],currentSessionId:null,latestActiveSessionId:null,sessionIndexRevision:0,addChat:async t=>{let n=(t.title||Ya.t(`chat.sidebar.newSession`)).trim(),r=t.config?.baseSystemPrompt?.trim()||``,i=Er.getState().providerSnapshot,a=i?.defaults?.chat,o=t.config?.model?.trim()||a?.model?.trim()||void 0,s,c;if(Er.getState().isProviderModelRefEnabled()){let e=t.config?.model_ref;e?.provider?.trim()&&e?.model?.trim()?(s=e,c=e.provider):a?.provider?.trim()&&a?.model?.trim()&&(s=a,c=a.provider)}let l=t.config?.reasoningEffort??eo(i,s??null,c??null),u=await Fo.createSession({title:n,system_prompt:r||void 0,model:o,model_ref:s,provider:c,reasoning_effort:l||void 0,gold_config:t.config?.goldConfig??void 0}),d={...mo(u.session),title:n,config:{...t.config,permissionMode:Wn(u.session.permission_mode),permissionModeEtag:void 0,bypassPermissions:u.session.bypass_permissions??!1,model:u.session.model,model_ref:u.session.model_ref??null,reasoningEffort:u.session.reasoning_effort??null,goldConfig:u.session.gold_config??t.config?.goldConfig??null,baseSystemPrompt:r||oo},messages:[]};return e(e=>{let t=[d,...e.chats.filter(e=>e.id!==d.id)];return{...e,chats:t,currentSessionId:d.id,latestActiveSessionId:d.id}}),d.id},selectSession:n=>{let r=t();r.currentSessionId===n&&r.latestActiveSessionId===n||e({currentSessionId:n,latestActiveSessionId:n})},deleteSession:async n=>{try{await Fo.deleteSession(n)}catch(e){console.error(`[ChatSlice] Failed to delete backend session ${n}:`,e)}let r=t().chats.filter(e=>e.id===n||e.rootSessionId===n).map(e=>e.id);t().resetSessionPermissionModes(r),e(e=>{let t=new Set;for(let r of e.chats)r.id===n&&t.add(r.id),r.rootSessionId===n&&t.add(r.id);let r=e.chats.filter(e=>!t.has(e.id)),i=e.currentSessionId&&t.has(e.currentSessionId)?null:e.currentSessionId,a=e.latestActiveSessionId&&t.has(e.latestActiveSessionId)?r[0]?.id??null:e.latestActiveSessionId;return{...e,chats:r,currentSessionId:i,latestActiveSessionId:a}})},deleteSessions:async e=>{for(let n of e)await t().deleteSession(n)},updateSession:(t,n,r)=>{let i=!!n.config&&(Object.prototype.hasOwnProperty.call(n.config,`model`)||Object.prototype.hasOwnProperty.call(n.config,`reasoningEffort`)||Object.prototype.hasOwnProperty.call(n.config,`goldConfig`)),a=typeof n.title==`string`||typeof n.pinned==`boolean`,o=i||a?new Date().toISOString():void 0;e(e=>{let r=e.chats.map(e=>e.id===t?{...e,...n,...o?{updatedAt:o}:{}}:e);return{...e,chats:r}});let s={};if(typeof n.title==`string`&&(s.title=n.title),typeof n.pinned==`boolean`&&(s.pinned=n.pinned),n.config&&Object.prototype.hasOwnProperty.call(n.config,`model`)&&(s.model=n.config.model??null),n.config&&Object.prototype.hasOwnProperty.call(n.config,`model_ref`)&&Er.getState().isProviderModelRefEnabled()&&(s.model_ref=n.config.model_ref??null,n.config.model_ref&&(s.provider=n.config.model_ref.provider)),n.config&&Object.prototype.hasOwnProperty.call(n.config,`reasoningEffort`)){let e=n.config.reasoningEffort;e?s.reasoning_effort=e:s.clear_reasoning_effort=!0}n.config&&Object.prototype.hasOwnProperty.call(n.config,`goldConfig`)&&(s.gold_config=n.config.goldConfig??{enabled:!1,auto_answer_enabled:!1,auto_continue_enabled:!1}),!r?.skipBackendPatch&&Object.keys(s).length>0&&Fo.patchSession(t,s).catch(e=>{console.warn(`[ChatSlice] Failed to patch session ${t}:`,e)})},persistSessionTitle:async(n,r)=>{let i=t().chats.find(e=>e.id===n)?.title;e(e=>({...e,chats:e.chats.map(e=>e.id===n?{...e,title:r,updatedAt:new Date().toISOString()}:e)}));try{await Fo.patchSession(n,{title:r})}catch(t){throw typeof i==`string`&&e(e=>({...e,chats:e.chats.map(e=>e.id===n?{...e,title:i}:e)})),console.warn(`[ChatSlice] persistSessionTitle failed for ${n}:`,t),t}},applyServerTitle:(t,n,r)=>e(e=>{let i=e.chats.find(e=>e.id===t);return!i||r<=(i.titleVersion??0)?e:{...e,chats:e.chats.map(e=>e.id===t?{...e,title:n,titleVersion:r,updatedAt:new Date().toISOString()}:e)}}),applyServerPinned:(t,n,r)=>e(e=>{let i=e.chats.find(e=>e.id===t);if(!i)return e;let a=Date.parse(r),o=i.updatedAt?Date.parse(i.updatedAt):NaN;return Number.isFinite(a)&&Number.isFinite(o)&&a<o||i.pinned===n?e:{...e,chats:e.chats.map(e=>e.id===t?{...e,pinned:n,updatedAt:r}:e)}}),pinSession:e=>{t().updateSession(e,{pinned:!0})},unpinSession:e=>{t().updateSession(e,{pinned:!1})},setMessages:(e,n)=>{t().chats.find(t=>t.id===e)&&t().updateSession(e,{messages:n})},addMessage:async(e,n)=>{let r=t().chats.find(t=>t.id===e);if(!r)return;let i=[...r.messages,n];t().updateSession(e,{messages:i})},updateMessage:(e,n,r)=>{let i=t().chats.find(t=>t.id===e);if(!i)return;let a=i.messages.map(e=>{if(e.id!==n)return e;let t={...e};return Object.keys(r).forEach(e=>{Object.prototype.hasOwnProperty.call(t,e)&&(t[e]=r[e])}),t});t().updateSession(e,{messages:a})},deleteMessage:async(n,r)=>{let i=t().chats.find(e=>e.id===n);if(!i)return{success:!1,sessionId:n,messageId:r,reason:`session_not_found`};if(!i.messages.some(e=>e.id===r))return{success:!1,sessionId:n,messageId:r,reason:`message_not_found`};try{await Fo.deleteSessionMessage(n,r)}catch(e){return console.warn(`[ChatSlice] Failed to delete message ${r} from session ${n}:`,e),e instanceof Se?e.status===404?{success:!1,sessionId:n,messageId:r,reason:`backend_not_found`,statusCode:e.status,errorMessage:e.message}:e.status===409?{success:!1,sessionId:n,messageId:r,reason:`session_running`,statusCode:e.status,errorMessage:e.message}:{success:!1,sessionId:n,messageId:r,reason:`backend_error`,statusCode:e.status,errorMessage:e.message}:{success:!1,sessionId:n,messageId:r,reason:`backend_error`,errorMessage:e instanceof Error?e.message:void 0}}return e(e=>({...e,chats:e.chats.map(e=>e.id===n?{...e,messages:e.messages.filter(e=>e.id!==r)}:e)})),{success:!0,sessionId:n,messageId:r}},refreshChats:async()=>Z.inFlight?Z.inFlight:Z.timer?(Z.trailingPromise||=new Promise((e,t)=>{Z.trailingResolve=e,Z.trailingReject=t}),Z.trailingPromise):(Z.timer=setTimeout(()=>{if(Z.timer=null,Z.trailingPromise){let n=Oo();ko(No(e,t),n)}},750),No(e,t)),refreshChatsNow:async()=>{let n=Ao();P(`[ChatSlice]`,`refreshChatsNow.start`,{hadTrailingCallbacks:!!n,hasInflight:!!Z.inFlight});let r=Z.inFlight?Po(e,t):No(e,t);return ko(r,n),r},loadChats:async()=>{P(`[ChatSlice]`,`loadChats.start`,{});let n=await Do({kind:`root`});if(n.length===0){let e=Er.getState().providerSnapshot?.defaults?.chat,t=e?.model?.trim();P(`[ChatSlice]`,`loadChats.createInitialSession`,{defaultModel:t??null,defaultModelRef:e??null}),n=[(await Fo.createSession({title:Ya.t(`chat.sidebar.newSession`),model:t,model_ref:e,provider:e?.provider})).session]}let r=n.map(mo),i=r[0]?.id??null;P(`[ChatSlice]`,`loadChats.listResolved`,{count:n.length,currentSessionId:i});let a=t().executionBySession;for(let e of n)a=ei(a,{type:`applySessionSummary`,sessionId:e.id,summary:e});try{let e=await Fo.getRunningSessions();if(P(`[ChatSlice]`,`loadChats.runningSnapshot`,{count:e.sessions.length}),e.sessions.length>0){let t=e.sessions.map(e=>{let t=[];for(let n of e.last_critical_events){if(Dr(n)){kr(n,r);continue}t.push(n)}return{sessionId:e.session_id,runId:e.run_id,criticalEvents:t}});a=ei(a,{type:`applyRunningSnapshot`,sessions:t},()=>new Date().toISOString())}}catch(e){P(`[ChatSlice]`,`loadChats.runningSnapshot.error`,{error:e})}t().resetSessionPermissionModes(),e({chats:r,latestActiveSessionId:i,currentSessionId:i,executionBySession:a}),P(`[ChatSlice]`,`loadChats.applied`,{currentSessionId:i,chatCount:r.length,executionSessionCount:Object.keys(a||{}).length}),i&&(P(`[ChatSlice]`,`loadChats.loadInitialHistory`,{currentSessionId:i}),await t().loadChatHistory(i))},loadSubagentSessions:(n,r)=>Mo(n,e,t,r),restoreSession:async n=>{if(t().chats.find(e=>e.id===n))return await t().loadSubagentSessions(n),!0;try{let r=await Fo.getSession(n);if(r.session.kind===`root`)jo([r.session],e,{kind:`upsert`}),await t().loadSubagentSessions(r.session.id,{force:!0});else{let n=await Fo.getSession(r.session.root_session_id);if(n.session.kind!==`root`)return!1;jo([n.session],e,{kind:`upsert`}),await t().loadSubagentSessions(n.session.id,{force:!0})}return t().chats.some(e=>e.id===n)}catch(e){return P(`[ChatSlice]`,`restoreSession.error`,{sessionId:n,error:e}),!1}},loadChatHistory:async(e,n)=>{let r=n?.mode??`replace`,i=Math.max(0,n?.retries??0),a=Math.max(0,n?.retryDelayMs??0);P(`[ChatSlice]`,`loadChatHistory.start`,{sessionId:e,mode:r,retries:i,retryDelayMs:a,waitForAssistant:n?.waitForAssistant??!1});for(let o=0;o<=i;o+=1)try{let s=t().chats.find(t=>t.id===e);if(!s){P(`[ChatSlice]`,`loadChatHistory.skipMissingChat`,{sessionId:e,attempt:o});return}let c=await Fo.getHistory(e);P(`[ChatSlice]`,`loadChatHistory.response`,{sessionId:e,attempt:o,historyMessageCount:c.messages.length,localMessageCount:s.messages.length,localStoredMessageCount:s.messageCount??null,lastMessageId:c.messages[c.messages.length-1]?.id??null,lastRole:c.messages[c.messages.length-1]?.role??null});let l=c.messages[c.messages.length-1]?.role;if(n?.waitForAssistant&&l===`user`&&o<i){let t=a>0?a*(o+1):200*(o+1);P(`[ChatSlice]`,`loadChatHistory.waitForAssistant.retry`,{sessionId:e,attempt:o,delay:t}),await new Promise(e=>setTimeout(e,t));continue}let u=ho(e,c.messages);if(r===`monotonic`){let n=s.messages||[],r=n.length,i=u.length,a=u[u.length-1]?.role,l=n[n.length-1]?.role,d=n[n.length-1],f=u[u.length-1],p=d?.id,m=f?.id,h=!1;if(i>r?h=!0:i===r&&(h=l===`user`&&a!==`user`||typeof p==`string`&&typeof m==`string`&&p!==m),P(`[ChatSlice]`,`loadChatHistory.monotonicDecision`,{sessionId:e,attempt:o,prevLen:r,nextLen:i,prevLastRole:l??null,nextLastRole:a??null,prevLastId:p??null,nextLastId:m??null,shouldReplace:h}),!h){t().updateSession(e,{messageCount:Math.max(s.messageCount??0,c.messages.length)}),P(`[ChatSlice]`,`loadChatHistory.monotonicSkip`,{sessionId:e,attempt:o,localMessageCount:s.messages.length,serverMessageCount:c.messages.length});return}}let d=t().chats.find(t=>t.id===e);if(!d)return;t().updateSession(e,{messages:u,messageCount:c.messages.length,config:{...d.config,...c.gold_config==null?{}:{goldConfig:c.gold_config},...c.goal_state==null?{}:{goalState:c.goal_state},compressionEvents:(c.compression_events||[]).map(e=>({id:e.id,createdAt:e.created_at,messagesCompressed:e.messages_compressed,segmentsRemoved:e.segments_removed})),syncCursor:{messageCount:c.messages.length,lastMessageId:c.messages[c.messages.length-1]?.id??null,hasPendingQuestion:!!t().executionBySession?.[e]?.interaction.pendingQuestion,pendingQuestionToolCallId:t().executionBySession?.[e]?.interaction.pendingQuestion?.toolCallId??null}}},{skipBackendPatch:!0}),P(`[ChatSlice]`,`loadChatHistory.applied`,{sessionId:e,attempt:o,mode:r,messageCount:c.messages.length,lastMessageId:c.messages[c.messages.length-1]?.id??null});return}catch(t){if(o>=i){console.warn(`[ChatSlice] Failed to load history for ${e}:`,t),P(`[ChatSlice]`,`loadChatHistory.error.final`,{sessionId:e,attempt:o,retries:i,error:t});return}let n=a>0?a*(o+1):200*(o+1);P(`[ChatSlice]`,`loadChatHistory.error.retry`,{sessionId:e,attempt:o,delay:n,error:t}),await new Promise(e=>setTimeout(e,n))}},reconcileOpenSession:(e,n)=>{if(!e||t().currentSessionId!==e)return;let r=Io.get(e);r&&clearTimeout(r),Io.set(e,setTimeout(()=>{Io.delete(e),t().currentSessionId===e&&(async()=>{P(`[ChatSlice]`,`reconcileOpenSession.start`,{sessionId:e,reason:n??null}),await t().loadChatHistory(e,{mode:`monotonic`,waitForAssistant:!0,retries:3,retryDelayMs:250});try{let n=await Fo.getPendingQuestion(e);if(t().currentSessionId!==e)return;n.has_pending_question?t().setPendingQuestion(e,{question:n.question??``,options:n.options??[],allowCustom:n.allow_custom??!0,toolCallId:n.tool_call_id??null}):t().clearPendingQuestion(e)}catch(t){P(`[ChatSlice]`,`reconcileOpenSession.pendingError`,{sessionId:e,error:t})}})()},Lo))}}),zo=class extends Error{code=`proxy_auth_required`;constructor(e=`Proxy authentication required`){super(e),this.name=`ProxyAuthRequiredError`}},Bo=class e{static instance;constructor(){}static getInstance(){return e.instance||=new e,e.instance}async getModels(e){try{let t=await sr.fetchCatalogModels(e),n=[];for(let e of t.fetched)if(e.models&&e.models.length>0)for(let t of e.models)t.reference&&t.reference.model&&n.push(t.reference.model);return[...new Set(n)].sort()}catch(e){if(console.error(`Failed to fetch models from Provider Catalog:`,e),e instanceof Se){if(e.status===428)throw new zo(e.message);let t;if(e.body)try{t=JSON.parse(e.body)}catch{}if(t&&typeof t==`object`&&`error`in t&&t.error?.code===`proxy_auth_required`)throw new zo(t.error?.message||e.message)}throw e}}}.getInstance(),Vo=async e=>{if(typeof navigator>`u`||!navigator.clipboard?.writeText)throw Error(`navigator.clipboard.writeText is unavailable`);await navigator.clipboard.writeText(e)},Ho=e=>{if(typeof document>`u`)throw Error(`document is unavailable`);let t=document.createElement(`textarea`);t.value=e,t.setAttribute(`readonly`,`true`),t.style.position=`fixed`,t.style.top=`-9999px`,t.style.left=`-9999px`,t.style.opacity=`0`,document.body.appendChild(t),t.focus(),t.select();let n=document.execCommand(`copy`);if(document.body.removeChild(t),!n)throw Error(`document.execCommand('copy') returned false`)},Uo=async e=>{try{await Vo(e);return}catch(t){try{Ho(e);return}catch(e){let n=t instanceof Error?t.message:String(t),r=e instanceof Error?e.message:String(e);throw Error(`Clipboard copy failed: navigator(${n}); fallback(${r})`)}}},Wo=class{async copyToClipboard(e){await Uo(e)}async getBambooConfig(){try{return await z.get(`bamboo/config`)}catch(e){return console.error(`Failed to fetch Bamboo config:`,e),{}}}async getBambooTools(){try{return await z.get(`bamboo/tools`)}catch(e){return console.error(`Failed to fetch Bamboo tools:`,e),{tools:[]}}}async getModelLimitDefaults(){try{return await z.get(`bamboo/model-limits/defaults`)}catch(e){return console.error(`Failed to fetch model limit defaults:`,e),{model_limits:[]}}}async setBambooConfig(e){return z.post(`bamboo/config`,e)}async validateBambooConfigPatch(e){return z.post(`bamboo/config/validate`,e)}async setProxyAuth(e){return z.post(`bamboo/proxy-auth`,e)}async getProxyAuthStatus(){try{return await z.get(`bamboo/proxy-auth/status`)}catch(e){return console.error(`Failed to fetch proxy auth status:`,e),{configured:!1,username:null}}}async clearProxyAuth(){return z.post(`bamboo/proxy-auth`,{username:``,password:``})}async resetBambooConfig(){return z.post(`bamboo/config/reset`,{})}async saveWorkflow(e,t){return z.post(`bamboo/workflows`,{name:e,content:t})}async deleteWorkflow(e){return z.delete(`bamboo/workflows/${encodeURIComponent(e)}`)}async getKeywordMaskingConfig(){try{return await z.get(`bamboo/keyword-masking`)}catch(e){return console.error(`Failed to fetch keyword masking config:`,e),{entries:[]}}}async updateKeywordMaskingConfig(e){return z.post(`bamboo/keyword-masking`,e)}async validateKeywordEntries(e){return z.post(`bamboo/keyword-masking/validate`,e)}async getSetupStatus(){return await z.get(`bamboo/setup/status`)}async markSetupComplete(){return z.post(`bamboo/setup/complete`,{})}async resetSetupStatus(){await z.post(`bamboo/setup/incomplete`,{})}async getAccessStatus(){return z.get(`bamboo/access/status`)}async updateAccessPassword(e){return z.post(`bamboo/access/password`,e)}},Go=class e extends Wo{static instance;constructor(){super()}static getInstance(){return e.instance||=new e,e.instance}getUtilityService(){return this}},Ko=Go.getInstance(),qo=null,Jo=null,Yo=(e,t)=>e instanceof Error&&e.message.trim()?e.message:t,Xo=se((e,t)=>({config:null,proxyAuthStatus:null,isLoadingConfig:!1,isLoadingProxyAuthStatus:!1,lastLoadedAt:null,error:null,loadConfig:async({force:n=!1}={})=>{let r=t().config;if(!n&&r)return r;if(qo)return qo;qo=(async()=>{e({isLoadingConfig:!0,error:null});try{let t=await Ko.getBambooConfig()??{};return e({config:t,lastLoadedAt:Date.now(),error:null}),t}catch(t){throw e({error:Yo(t,`Failed to load Bamboo config`)}),t}finally{e({isLoadingConfig:!1})}})();try{return await qo}finally{qo=null}},saveConfig:async t=>{e({isLoadingConfig:!0,error:null,config:t});try{let n=await Ko.setBambooConfig(t);return e({config:n,lastLoadedAt:Date.now(),error:null}),n}catch(t){throw e({error:Yo(t,`Failed to save Bamboo config`)}),t}finally{e({isLoadingConfig:!1})}},patchConfig:async e=>{let n={...await t().loadConfig()??{},...e??{}};return t().saveConfig(n)},loadProxyAuthStatus:async({force:n=!1}={})=>{let r=t().proxyAuthStatus;if(!n&&r)return r;if(Jo)return Jo;Jo=(async()=>{e({isLoadingProxyAuthStatus:!0,error:null});try{let t=await Ko.getProxyAuthStatus();return e({proxyAuthStatus:t,error:null}),t}catch(t){throw e({error:Yo(t,`Failed to load proxy auth status`)}),t}finally{e({isLoadingProxyAuthStatus:!1})}})();try{return await Jo}finally{Jo=null}},applyProxyAuth:async e=>{await Ko.setProxyAuth(e),await t().loadProxyAuthStatus({force:!0})},clearProxyAuth:async()=>{await Ko.clearProxyAuth(),await t().loadProxyAuthStatus({force:!0})}})),Zo=null,Qo=(e,t)=>({models:[],selectedModel:void 0,isLoadingModels:!1,modelsError:null,configModel:void 0,setSelectedModel:t=>{e({selectedModel:t})},loadConfigModel:async()=>{try{let t=await Xo.getState().loadConfig(),n=typeof t?.model==`string`?t.model:void 0;n&&e({configModel:n})}catch(e){console.error(`Failed to load model from config:`,e)}},fetchModels:async()=>{if(Zo)return Zo;Zo=(async()=>{e({isLoadingModels:!0,modelsError:null});try{try{if(!(await Ko.getSetupStatus()).is_complete){P(`[ModelSlice]`,`Setup not complete, skipping model fetch`),e({models:[],selectedModel:void 0,isLoadingModels:!1,modelsError:`Complete setup to access all models`});return}}catch(e){console.error(`Failed to check setup status:`,e)}let n=await Bo.getModels();e(e=>{let t=e.selectedModel,r=e.selectedModel;return t&&n.includes(t)||(r=void 0),{...e,models:n,selectedModel:r,modelsError:n.length>0?null:`No available model options`}}),t().models.length===0&&console.warn(`No models available from service`)}catch(t){let n=t instanceof Error?t.message:String(t);if(console.error(`Failed to fetch models:`,t),t instanceof zo){e(e=>({...e,models:e.models,selectedModel:e.selectedModel,modelsError:n||`Proxy authentication required. Please configure proxy auth.`}));return}e(e=>({...e,models:[],selectedModel:e.selectedModel,modelsError:n}))}finally{e({isLoadingModels:!1})}})();try{await Zo}finally{Zo=null}}}),$o=[`system_prompt`,`system_prompt_selected_id`],es=e=>({id:e.id,name:e.name||e.id,content:e.content||``,description:e.description,isDefault:!!e.is_default}),ts=class e{static instance;deprecatedKeysCleanupDone=!1;constructor(){}static getInstance(){return e.instance||=new e,e.instance.cleanupDeprecatedPromptStorageKeys(),e.instance}cleanupDeprecatedPromptStorageKeys(){if(!this.deprecatedKeysCleanupDone){this.deprecatedKeysCleanupDone=!0;try{for(let e of $o)localStorage.removeItem(e)}catch(e){console.warn(`[SystemPromptService] Failed to cleanup deprecated prompt storage keys:`,e)}}}async getSystemPromptPresets(){try{let e=await z.get(`prompt-presets`),t=(Array.isArray(e?.prompts)?e.prompts:[]).filter(e=>e.id&&e.id.trim().length>0).map(es);if(t.length>0)return t}catch(e){console.error(`Failed to load prompt presets from backend:`,e)}return no()}async createSystemPromptPreset(e){let t={name:e.name,content:e.content};e.id?.trim()&&(t.id=e.id.trim()),e.description!==void 0&&(t.description=e.description);let n=await z.post(`prompt-presets`,t);if(!n?.prompt)throw Error(`Backend did not return created prompt preset`);return es(n.prompt)}async updateSystemPromptPreset(e){let t=encodeURIComponent(e.id),n={name:e.name,content:e.content,description:e.description},r=await z.patch(`prompt-presets/${t}`,n);if(!r?.prompt)throw Error(`Backend did not return updated prompt preset`);return es(r.prompt)}async deleteSystemPromptPreset(e){let t=encodeURIComponent(e);await z.delete(`prompt-presets/${t}`)}async findPresetById(e){return(await this.getSystemPromptPresets()).find(t=>t.id===e)}async getCurrentSystemPromptContent(e){let t=await this.findPresetById(e);if(t)return t.content;let n=await this.getSystemPromptPresets();return(n.find(e=>e.isDefault)||n[0])?.content||``}},ns=`copilot_last_selected_prompt_id`,rs=`copilot_custom_system_prompts_v2`,is=`copilot_custom_system_prompts_v2_migrated_to_backend`,as=`general_assistant`,os=80,ss=ts.getInstance(),cs=null;function ls(e){let t=e.toLowerCase().trim().replace(/[^a-z0-9]+/g,`_`).replace(/^_+|_+$/g,``);return t.length===0?`prompt_${Date.now()}_${Math.random().toString(36).substring(2,9)}`:t.slice(0,os)}function us(e){if(typeof e!=`string`)return null;let t=e.toLowerCase().trim().replace(/[^a-z0-9_]+/g,`_`).replace(/^_+|_+$/g,``);return t?t.slice(0,os):null}function ds(e,t){if(!t.has(e))return e;let n=2;for(;;){let r=`_${n}`,i=`${e.slice(0,Math.max(0,os-r.length))}${r}`;if(!t.has(i))return i;n+=1}}function fs(){try{let e=localStorage.getItem(rs);if(!e)return[];let t=JSON.parse(e);if(!Array.isArray(t))return[];let n=new Set,r=[];for(let e of t){let t=typeof e?.name==`string`?e.name.trim():``,i=typeof e?.content==`string`?e.content.trim():``;if(!t||!i)continue;let a=ds(us(e?.id)||ls(t),n);a!==as&&(n.add(a),r.push({id:a,name:t,content:i,description:typeof e?.description==`string`&&e.description.trim()||void 0,isDefault:!!e?.isDefault}))}return r}catch(e){return console.error(`[promptSlice] Failed to read legacy custom prompts:`,e),[]}}function ps(){try{return localStorage.getItem(is)===`1`}catch(e){return console.error(`[promptSlice] Failed to read migration marker:`,e),!1}}function ms(){try{localStorage.setItem(is,`1`)}catch(e){console.error(`[promptSlice] Failed to write migration marker:`,e)}}function hs(){try{localStorage.removeItem(rs)}catch(e){console.error(`[promptSlice] Failed to clear legacy custom prompts:`,e)}}async function gs(){if(ps())return;let e=fs();if(e.length===0){hs(),ms();return}let t=await ss.getSystemPromptPresets(),n=new Set(t.map(e=>e.id)),r=!1;for(let t of e){let e=t.name?.trim(),i=t.content?.trim();if(!e||!i||t.id===as||t.isDefault)continue;let a=ds(us(t.id)||ls(e),n);try{let r=await ss.createSystemPromptPreset({id:a,name:e,content:i,description:t.description});n.add(r.id)}catch(t){r=!0,console.error(`[promptSlice] Failed to migrate legacy prompt '${e}' to backend:`,t)}}r||(hs(),ms())}async function _s(){cs||=gs().finally(()=>{cs=null}),await cs}var vs=(e,t)=>({systemPrompts:[],lastSelectedPromptId:localStorage.getItem(ns)||null,loadSystemPrompts:async()=>{try{await _s()}catch(e){console.warn(`[promptSlice] Legacy prompt migration skipped:`,e)}let t=[];try{t=await ss.getSystemPromptPresets()}catch(e){console.error(`Failed to load system prompts from backend:`,e)}let n=t.length?t:no();if(!ps()){let e=fs();n=ys(n,e)}n.length===0&&(n=no()),e({systemPrompts:n})},addSystemPrompt:async e=>{try{await ss.createSystemPromptPreset({id:ls(e.name),name:e.name,content:e.content,description:e.description}),await t().loadSystemPrompts()}catch(e){throw console.error(`Failed to add system prompt:`,e),e}},updateSystemPrompt:async e=>{try{await ss.updateSystemPromptPreset(e),await t().loadSystemPrompts()}catch(e){throw console.error(`Failed to update system prompt:`,e),e}},deleteSystemPrompt:async e=>{try{await ss.deleteSystemPromptPreset(e),await t().loadSystemPrompts()}catch(e){throw console.error(`Failed to delete system prompt:`,e),e}},setLastSelectedPromptId:t=>{e({lastSelectedPromptId:t});try{localStorage.setItem(ns,t)}catch(e){console.error(`Failed to save last selected prompt ID to localStorage:`,e)}}}),ys=(e,t)=>{let n=new Map;return e.forEach(e=>{n.set(e.id,e)}),t.forEach(e=>{n.set(e.id,e)}),Array.from(n.values())},bs=()=>({}),xs=new class{async listSkills(e,t){let n=new URLSearchParams;e?.search&&n.append(`search`,e.search),e?.includeDisabled&&n.append(`include_disabled`,`true`),t&&n.append(`refresh`,`true`);let r=n.toString(),i=r?`skills?${r}`:`skills`;return z.get(i)}async getSkill(e){return z.get(`skills/${e}`)}async getFilteredTools(e){let t=e?`?session_id=${encodeURIComponent(e)}`:``;return(await z.get(`skills/filtered-tools${t}`)).tools??[]}},Ss=(e,t)=>({skills:[],isLoadingSkills:!1,skillsError:null,loadSkills:async(t,n)=>{e({isLoadingSkills:!0,skillsError:null});try{e({skills:(await xs.listSkills(t,n)).skills,isLoadingSkills:!1})}catch(t){e({skillsError:t instanceof Error?t.message:Ya.t(`components.skillManager.loadFailed`),isLoadingSkills:!1})}},getSkill:async n=>{e({isLoadingSkills:!0,skillsError:null});try{let r=await xs.getSkill(n),i=t().skills;e({skills:i.findIndex(e=>e.id===r.id)>=0?i.map(e=>e.id===r.id?r:e):[...i,r],isLoadingSkills:!1})}catch(t){e({skillsError:t instanceof Error?t.message:Ya.t(`components.skillManager.getFailed`),isLoadingSkills:!1})}},clearSkillsError:()=>{e({skillsError:null})}}),Cs=e=>({tokenUsages:{},truncationOccurred:{},segmentsRemoved:{},updateTokenUsage:(t,n)=>e(e=>({tokenUsages:{...e.tokenUsages,[t]:n}})),setTruncationInfo:(t,n,r)=>e(e=>({truncationOccurred:{...e.truncationOccurred,[t]:n},segmentsRemoved:{...e.segmentsRemoved,[t]:r}})),clearTokenUsage:t=>e(e=>{let{[t]:n,...r}=e.tokenUsages,{[t]:i,...a}=e.truncationOccurred,{[t]:o,...s}=e.segmentsRemoved;return{tokenUsages:r,truncationOccurred:a,segmentsRemoved:s}})}),ws=ar.getInstance(),Ts=(e,t)=>({taskLists:{},taskListVersions:{},activeItems:{},evaluationStates:{},setTaskList:(t,n)=>e(e=>({taskLists:{...e.taskLists,[t]:n},taskListVersions:{...e.taskListVersions,[t]:n.version||0}})),loadTaskList:async e=>{let n=await ws.getTaskList(e);return n?(t().setTaskList(n.session_id||e,n),n):null},updateTaskListDelta:(t,n)=>e(e=>{let r=e.taskListVersions[t]||0;if(n.version<=r)return e;let i=e.taskLists[t];if(!i)return e;let a=i.items.map(e=>e.id===n.item_id?{...e,status:n.status,tool_calls_count:n.tool_calls_count}:e);return{taskLists:{...e.taskLists,[t]:{...i,items:a,updated_at:new Date().toISOString()}},taskListVersions:{...e.taskListVersions,[t]:n.version},activeItems:{...e.activeItems,[t]:n.status===`in_progress`?n.item_id:null}}}),clearTaskList:t=>e(e=>{let{[t]:n,...r}=e.taskLists,{[t]:i,...a}=e.taskListVersions,{[t]:o,...s}=e.activeItems,{[t]:c,...l}=e.evaluationStates;return{taskLists:r,taskListVersions:a,activeItems:s,evaluationStates:l}}),getTaskListVersion:e=>t().taskListVersions[e]||0,setEvaluationState:(t,n)=>e(e=>({evaluationStates:{...e.evaluationStates,[t]:n}})),clearEvaluationState:t=>e(e=>{let{[t]:n,...r}=e.evaluationStates;return{evaluationStates:r}})}),Es=e(t(((e,t)=>{((n,r)=>{typeof e==`object`&&t!==void 0?t.exports=r():typeof define==`function`&&define.amd?define(r):(n=typeof globalThis<`u`?globalThis:n||self).Dexie=r()})(e,function(){var e=function(t,n){return(e=Object.setPrototypeOf||({__proto__:[]}instanceof Array?function(e,t){e.__proto__=t}:function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])}))(t,n)},t=function(){return(t=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e}).apply(this,arguments)};function n(e,t,n){if(n||arguments.length===2)for(var r,i=0,a=t.length;i<a;i++)!r&&i in t||((r||=Array.prototype.slice.call(t,0,i))[i]=t[i]);return e.concat(r||Array.prototype.slice.call(t))}var r=typeof globalThis<`u`?globalThis:typeof self<`u`?self:typeof window<`u`?window:global,i=Object.keys,a=Array.isArray;function o(e,t){return typeof t==`object`&&i(t).forEach(function(n){e[n]=t[n]}),e}typeof Promise>`u`||r.Promise||(r.Promise=Promise);var s=Object.getPrototypeOf,c={}.hasOwnProperty;function l(e,t){return c.call(e,t)}function u(e,t){typeof t==`function`&&(t=t(s(e))),(typeof Reflect>`u`?i:Reflect.ownKeys)(t).forEach(function(n){f(e,n,t[n])})}var d=Object.defineProperty;function f(e,t,n,r){d(e,t,o(n&&l(n,`get`)&&typeof n.get==`function`?{get:n.get,set:n.set,configurable:!0}:{value:n,configurable:!0,writable:!0},r))}function p(e){return{from:function(t){return e.prototype=Object.create(t.prototype),f(e.prototype,`constructor`,e),{extend:u.bind(null,e.prototype)}}}}var m=Object.getOwnPropertyDescriptor,h=[].slice;function g(e,t,n){return h.call(e,t,n)}function _(e,t){return t(e)}function v(e){if(!e)throw Error(`Assertion Failed`)}function y(e){r.setImmediate?setImmediate(e):setTimeout(e,0)}function b(e,t){if(typeof t==`string`&&l(e,t))return e[t];if(!t)return e;if(typeof t!=`string`){for(var n=[],r=0,i=t.length;r<i;++r){var a=b(e,t[r]);n.push(a)}return n}var o,s=t.indexOf(`.`);return s===-1||(o=e[t.substr(0,s)])==null?void 0:b(o,t.substr(s+1))}function x(e,t,n){if(e&&t!==void 0&&!(`isFrozen`in Object&&Object.isFrozen(e)))if(typeof t!=`string`&&`length`in t){v(typeof n!=`string`&&`length`in n);for(var r=0,i=t.length;r<i;++r)x(e,t[r],n[r])}else{var o=t.indexOf(`.`);if(o!==-1){var s=t.substr(0,o),o=t.substr(o+1);if(o===``)n===void 0?a(e)&&!isNaN(parseInt(s))?e.splice(s,1):delete e[s]:e[s]=n;else{var c=e[s];if(!c||!l(e,s)){if(n===void 0)return;c=e[s]={}}x(c,o,n)}}else n===void 0?a(e)&&!isNaN(parseInt(t))?e.splice(t,1):delete e[t]:e[t]=n}}function S(e){var t,n={};for(t in e)l(e,t)&&(n[t]=e[t]);return n}var C=[].concat;function w(e){return C.apply([],e)}var T=`BigUint64Array,BigInt64Array,Array,Boolean,String,Date,RegExp,Blob,File,FileList,FileSystemFileHandle,FileSystemDirectoryHandle,ArrayBuffer,DataView,Uint8ClampedArray,ImageBitmap,ImageData,Map,Set,CryptoKey`.split(`,`).concat(w([8,16,32,64].map(function(e){return[`Int`,`Uint`,`Float`].map(function(t){return t+e+`Array`})}))).filter(function(e){return r[e]}),E=new Set(T.map(function(e){return r[e]})),D=null;function O(e){return D=new WeakMap,e=function e(t){if(!t||typeof t!=`object`)return t;var n=D.get(t);if(n)return n;if(a(t)){n=[],D.set(t,n);for(var r=0,i=t.length;r<i;++r)n.push(e(t[r]))}else if(E.has(t.constructor))n=t;else{var o,c=s(t);for(o in n=c===Object.prototype?{}:Object.create(c),D.set(t,n),t)l(t,o)&&(n[o]=e(t[o]))}return n}(e),D=null,e}var ee={}.toString;function k(e){return ee.call(e).slice(8,-1)}var te=typeof Symbol<`u`?Symbol.iterator:`@@iterator`,ne=typeof te==`symbol`?function(e){var t;return e!=null&&(t=e[te])&&t.apply(e)}:function(){return null};function A(e,t){t=e.indexOf(t),0<=t&&e.splice(t,1)}var re={};function ie(e){var t,n,r,i;if(arguments.length===1){if(a(e))return e.slice();if(this===re&&typeof e==`string`)return[e];if(i=ne(e))for(n=[];!(r=i.next()).done;)n.push(r.value);else{if(e==null||typeof(t=e.length)!=`number`)return[e];for(n=Array(t);t--;)n[t]=e[t]}}else for(t=arguments.length,n=Array(t);t--;)n[t]=arguments[t];return n}var ae=typeof Symbol<`u`?function(e){return e[Symbol.toStringTag]===`AsyncFunction`}:function(){return!1},T=[`Unknown`,`Constraint`,`Data`,`TransactionInactive`,`ReadOnly`,`Version`,`NotFound`,`InvalidState`,`InvalidAccess`,`Abort`,`Timeout`,`QuotaExceeded`,`Syntax`,`DataClone`],j=[`Modify`,`Bulk`,`OpenFailed`,`VersionChange`,`Schema`,`Upgrade`,`InvalidTable`,`MissingAPI`,`NoSuchDatabase`,`InvalidArgument`,`SubTransaction`,`Unsupported`,`Internal`,`DatabaseClosed`,`PrematureCommit`,`ForeignAwait`].concat(T),oe={VersionChanged:`Database version changed by other database connection`,DatabaseClosed:`Database has been closed`,Abort:`Transaction aborted`,TransactionInactive:`Transaction has already completed or failed`,MissingAPI:`IndexedDB API missing. Please visit https://tinyurl.com/y2uuvskb`};function se(e,t){this.name=e,this.message=t}function ce(e,t){return e+`. Errors: `+Object.keys(t).map(function(e){return t[e].toString()}).filter(function(e,t,n){return n.indexOf(e)===t}).join(`
|
|
17
17
|
`)}function le(e,t,n,r){this.failures=t,this.failedKeys=r,this.successCount=n,this.message=ce(e,t)}function ue(e,t){this.name=`BulkError`,this.failures=Object.keys(t).map(function(e){return t[e]}),this.failuresByPos=t,this.message=ce(e,this.failures)}p(se).from(Error).extend({toString:function(){return this.name+`: `+this.message}}),p(le).from(se),p(ue).from(se);var de=j.reduce(function(e,t){return e[t]=t+`Error`,e},{}),fe=se,M=j.reduce(function(e,t){var n=t+`Error`;function r(e,r){this.name=n,e?typeof e==`string`?(this.message=`${e}${r?`
|
|
18
|
-
`+r:``}`,this.inner=r||null):typeof e==`object`&&(this.message=`${e.name} ${e.message}`,this.inner=e):(this.message=oe[t]||n,this.inner=null)}return p(r).from(fe),e[t]=r,e},{}),pe=(M.Syntax=SyntaxError,M.Type=TypeError,M.Range=RangeError,T.reduce(function(e,t){return e[t+`Error`]=M[t],e},{}));T=j.reduce(function(e,t){return[`Syntax`,`Type`,`Range`].indexOf(t)===-1&&(e[t+`Error`]=M[t]),e},{});function N(){}function me(e){return e}function he(e,t){return e==null||e===me?t:function(n){return t(e(n))}}function ge(e,t){return function(){e.apply(this,arguments),t.apply(this,arguments)}}function _e(e,t){return e===N?t:function(){var n=e.apply(this,arguments),r=(n!==void 0&&(arguments[0]=n),this.onsuccess),i=this.onerror,a=(this.onsuccess=null,this.onerror=null,t.apply(this,arguments));return r&&(this.onsuccess=this.onsuccess?ge(r,this.onsuccess):r),i&&(this.onerror=this.onerror?ge(i,this.onerror):i),a===void 0?n:a}}function ve(e,t){return e===N?t:function(){e.apply(this,arguments);var n=this.onsuccess,r=this.onerror;this.onsuccess=this.onerror=null,t.apply(this,arguments),n&&(this.onsuccess=this.onsuccess?ge(n,this.onsuccess):n),r&&(this.onerror=this.onerror?ge(r,this.onerror):r)}}function P(e,t){return e===N?t:function(n){var r=e.apply(this,arguments),n=(o(n,r),this.onsuccess),i=this.onerror,a=(this.onsuccess=null,this.onerror=null,t.apply(this,arguments));return n&&(this.onsuccess=this.onsuccess?ge(n,this.onsuccess):n),i&&(this.onerror=this.onerror?ge(i,this.onerror):i),r===void 0?a===void 0?void 0:a:o(r,a)}}function ye(e,t){return e===N?t:function(){return!1!==t.apply(this,arguments)&&e.apply(this,arguments)}}function be(e,t){return e===N?t:function(){var n=e.apply(this,arguments);if(n&&typeof n.then==`function`){for(var r=this,i=arguments.length,a=Array(i);i--;)a[i]=arguments[i];return n.then(function(){return t.apply(r,a)})}return t.apply(this,arguments)}}T.ModifyError=le,T.DexieError=se,T.BulkError=ue;var xe=typeof location<`u`&&/^(http|https):\/\/(localhost|127\.0\.0\.1)/.test(location.href);function F(e){xe=e}var Se={},Ce=100,we=typeof Promise>`u`?[]:(j=Promise.resolve(),typeof crypto<`u`&&crypto.subtle?[we=crypto.subtle.digest(`SHA-512`,new Uint8Array([0])),s(we),j]:[j,s(j),j]),j=we[0],Te=we[1],Te=Te&&Te.then,Ee=j&&j.constructor,De=!!we[2],Oe=function(e,t){Fe.push([e,t]),Ae&&=(queueMicrotask(We),!1)},ke=!0,Ae=!0,je=[],Me=[],Ne=me,Pe={id:`global`,global:!0,ref:0,unhandleds:[],onunhandled:N,pgp:!1,env:{},finalize:N},I=Pe,Fe=[],Ie=0,Le=[];function L(e){if(typeof this!=`object`)throw TypeError(`Promises must be constructed via new`);this._listeners=[],this._lib=!1;var t=this._PSD=I;if(typeof e!=`function`){if(e!==Se)throw TypeError(`Not a function`);this._state=arguments[1],this._value=arguments[2],!1===this._state&&Be(this,this._value)}else this._state=null,this._value=null,++t.ref,function e(t,n){try{n(function(n){if(t._state===null){if(n===t)throw TypeError(`A promise cannot be resolved with itself.`);var r=t._lib&&Ge();n&&typeof n.then==`function`?e(t,function(e,t){n instanceof L?n._then(e,t):n.then(e,t)}):(t._state=!0,t._value=n,Ve(t)),r&&Ke()}},Be.bind(null,t))}catch(e){Be(t,e)}}(this,e)}var Re={get:function(){var e=I,t=$e;function n(n,r){var i=this,a=!e.global&&(e!==I||t!==$e),o=a&&!rt(),s=new L(function(t,s){He(i,new ze(ct(n,e,a,o),ct(r,e,a,o),t,s,e))});return this._consoleTask&&(s._consoleTask=this._consoleTask),s}return n.prototype=Se,n},set:function(e){f(this,`then`,e&&e.prototype===Se?Re:{get:function(){return e},set:Re.set})}};function ze(e,t,n,r,i){this.onFulfilled=typeof e==`function`?e:null,this.onRejected=typeof t==`function`?t:null,this.resolve=n,this.reject=r,this.psd=i}function Be(e,t){var n,r;Me.push(t),e._state===null&&(n=e._lib&&Ge(),t=Ne(t),e._state=!1,e._value=t,r=e,je.some(function(e){return e._value===r._value})||je.push(r),Ve(e),n)&&Ke()}function Ve(e){var t=e._listeners;e._listeners=[];for(var n=0,r=t.length;n<r;++n)He(e,t[n]);var i=e._PSD;--i.ref||i.finalize(),Ie===0&&(++Ie,Oe(function(){--Ie==0&&qe()},[]))}function He(e,t){if(e._state===null)e._listeners.push(t);else{var n=e._state?t.onFulfilled:t.onRejected;if(n===null)return(e._state?t.resolve:t.reject)(e._value);++t.psd.ref,++Ie,Oe(Ue,[n,e,t])}}function Ue(e,t,n){try{var r,i=t._value;!t._state&&Me.length&&(Me=[]),r=xe&&t._consoleTask?t._consoleTask.run(function(){return e(i)}):e(i),t._state||Me.indexOf(i)!==-1||(e=>{for(var t=je.length;t;)if(je[--t]._value===e._value)return je.splice(t,1)})(t),n.resolve(r)}catch(e){n.reject(e)}finally{--Ie==0&&qe(),--n.psd.ref||n.psd.finalize()}}function We(){st(Pe,function(){Ge()&&Ke()})}function Ge(){var e=ke;return Ae=ke=!1,e}function Ke(){var e,t,n;do for(;0<Fe.length;)for(e=Fe,Fe=[],n=e.length,t=0;t<n;++t){var r=e[t];r[0].apply(null,r[1])}while(0<Fe.length);Ae=ke=!0}function qe(){for(var e=je,t=(je=[],e.forEach(function(e){e._PSD.onunhandled.call(null,e._value,e)}),Le.slice(0)),n=t.length;n;)t[--n]()}function Je(e){return new L(Se,!1,e)}function R(e,t){var n=I;return function(){var r=Ge(),i=I;try{return at(n,!0),e.apply(this,arguments)}catch(e){t&&t(e)}finally{at(i,!1),r&&Ke()}}}u(L.prototype,{then:Re,_then:function(e,t){He(this,new ze(null,null,e,t,I))},catch:function(e){var t,n;return arguments.length===1?this.then(null,e):(t=e,n=arguments[1],typeof t==`function`?this.then(null,function(e){return(e instanceof t?n:Je)(e)}):this.then(null,function(e){return(e&&e.name===t?n:Je)(e)}))},finally:function(e){return this.then(function(t){return L.resolve(e()).then(function(){return t})},function(t){return L.resolve(e()).then(function(){return Je(t)})})},timeout:function(e,t){var n=this;return e<1/0?new L(function(r,i){var a=setTimeout(function(){return i(new M.Timeout(t))},e);n.then(r,i).finally(clearTimeout.bind(null,a))}):this}}),typeof Symbol<`u`&&Symbol.toStringTag&&f(L.prototype,Symbol.toStringTag,`Dexie.Promise`),Pe.env=ot(),u(L,{all:function(){var e=ie.apply(null,arguments).map(z);return new L(function(t,n){e.length===0&&t([]);var r=e.length;e.forEach(function(i,a){return L.resolve(i).then(function(n){e[a]=n,--r||t(e)},n)})})},resolve:function(e){return e instanceof L?e:e&&typeof e.then==`function`?new L(function(t,n){e.then(t,n)}):new L(Se,!0,e)},reject:Je,race:function(){var e=ie.apply(null,arguments).map(z);return new L(function(t,n){e.map(function(e){return L.resolve(e).then(t,n)})})},PSD:{get:function(){return I},set:function(e){return I=e}},totalEchoes:{get:function(){return $e}},newPSD:tt,usePSD:st,scheduler:{get:function(){return Oe},set:function(e){Oe=e}},rejectionMapper:{get:function(){return Ne},set:function(e){Ne=e}},follow:function(e,t){return new L(function(n,r){return tt(function(t,n){var r=I;r.unhandleds=[],r.onunhandled=n,r.finalize=ge(function(){var e,r=this;e=function(){r.unhandleds.length===0?t():n(r.unhandleds[0])},Le.push(function t(){e(),Le.splice(Le.indexOf(t),1)}),++Ie,Oe(function(){--Ie==0&&qe()},[])},r.finalize),e()},t,n,r)})}}),Ee&&(Ee.allSettled&&f(L,`allSettled`,function(){var e=ie.apply(null,arguments).map(z);return new L(function(t){e.length===0&&t([]);var n=e.length,r=Array(n);e.forEach(function(e,i){return L.resolve(e).then(function(e){return r[i]={status:`fulfilled`,value:e}},function(e){return r[i]={status:`rejected`,reason:e}}).then(function(){return--n||t(r)})})})}),Ee.any&&typeof AggregateError<`u`&&f(L,`any`,function(){var e=ie.apply(null,arguments).map(z);return new L(function(t,n){e.length===0&&n(AggregateError([]));var r=e.length,i=Array(r);e.forEach(function(e,a){return L.resolve(e).then(function(e){return t(e)},function(e){i[a]=e,--r||n(AggregateError(i))})})})}),Ee.withResolvers)&&(L.withResolvers=Ee.withResolvers);var Ye={awaits:0,echoes:0,id:0},Xe=0,Ze=[],Qe=0,$e=0,et=0;function tt(e,t,n,r){var i=I,a=Object.create(i),t=(a.parent=i,a.ref=0,a.global=!1,a.id=++et,Pe.env,a.env=De?{Promise:L,PromiseProp:{value:L,configurable:!0,writable:!0},all:L.all,race:L.race,allSettled:L.allSettled,any:L.any,resolve:L.resolve,reject:L.reject}:{},t&&o(a,t),++i.ref,a.finalize=function(){--this.parent.ref||this.parent.finalize()},st(a,e,n,r));return a.ref===0&&a.finalize(),t}function nt(){return Ye.id||=++Xe,++Ye.awaits,Ye.echoes+=Ce,Ye.id}function rt(){return!!Ye.awaits&&(--Ye.awaits==0&&(Ye.id=0),Ye.echoes=Ye.awaits*Ce,!0)}function z(e){return Ye.echoes&&e&&e.constructor===Ee?(nt(),e.then(function(e){return rt(),e},function(e){return rt(),B(e)})):e}function it(){var e=Ze[Ze.length-1];Ze.pop(),at(e,!1)}function at(e,t){var n,i,a=I;(t?!Ye.echoes||Qe++&&e===I:!Qe||--Qe&&e===I)||queueMicrotask(t?function(e){++$e,Ye.echoes&&--Ye.echoes!=0||(Ye.echoes=Ye.awaits=Ye.id=0),Ze.push(I),at(e,!0)}.bind(null,e):it),e!==I&&(I=e,a===Pe&&(Pe.env=ot()),De)&&(n=Pe.env.Promise,i=e.env,a.global||e.global)&&(Object.defineProperty(r,"Promise",i.PromiseProp),n.all=i.all,n.race=i.race,n.resolve=i.resolve,n.reject=i.reject,i.allSettled&&(n.allSettled=i.allSettled),i.any)&&(n.any=i.any)}function ot(){var e=r.Promise;return De?{Promise:e,PromiseProp:Object.getOwnPropertyDescriptor(r,`Promise`),all:e.all,race:e.race,allSettled:e.allSettled,any:e.any,resolve:e.resolve,reject:e.reject}:{}}function st(e,t,n,r,i){var a=I;try{return at(e,!0),t(n,r,i)}finally{at(a,!1)}}function ct(e,t,n,r){return typeof e==`function`?function(){var i=I;n&&nt(),at(t,!0);try{return e.apply(this,arguments)}finally{at(i,!1),r&&queueMicrotask(rt)}}:e}function lt(e){Promise===Ee&&Ye.echoes===0?Qe===0?e():enqueueNativeMicroTask(e):setTimeout(e,0)}(``+Te).indexOf(`[native code]`)===-1&&(nt=rt=N);var B=L.reject,ut=``,dt=`Invalid key provided. Keys must be of type string, number, Date or Array<string | number | Date>.`,ft=`String expected.`,pt=`__dbnames`,mt=`readonly`,ht=`readwrite`;function gt(e,t){return e?t?function(){return e.apply(this,arguments)&&t.apply(this,arguments)}:e:t}var _t={type:3,lower:-1/0,lowerOpen:!1,upper:[[]],upperOpen:!1};function vt(e){return typeof e!=`string`||/\./.test(e)?function(e){return e}:function(t){return t[e]===void 0&&e in t&&delete(t=O(t))[e],t}}function yt(){throw M.Type(`Entity instances must never be new:ed. Instances are generated by the framework bypassing the constructor.`)}function V(e,t){try{var n=bt(e),r=bt(t);if(n!==r)return n===`Array`?1:r===`Array`?-1:n===`binary`?1:r===`binary`?-1:n===`string`?1:r===`string`?-1:n===`Date`?1:r===`Date`?-1:NaN;switch(n){case`number`:case`Date`:case`string`:return t<e?1:e<t?-1:0;case`binary`:for(var i=xt(e),a=xt(t),o=i.length,s=a.length,c=o<s?o:s,l=0;l<c;++l)if(i[l]!==a[l])return i[l]<a[l]?-1:1;return o===s?0:o<s?-1:1;case`Array`:for(var u=e,d=t,f=u.length,p=d.length,m=f<p?f:p,h=0;h<m;++h){var g=V(u[h],d[h]);if(g!==0)return g}return f===p?0:f<p?-1:1}}catch{}return NaN}function bt(e){var t=typeof e;return t==`object`&&(ArrayBuffer.isView(e)||(t=k(e))===`ArrayBuffer`)?`binary`:t}function xt(e){return e instanceof Uint8Array?e:ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):new Uint8Array(e)}function St(e,t,n){var r=e.schema.yProps;return r?(t&&0<n.numFailures&&(t=t.filter(function(e,t){return!n.failures[t]})),Promise.all(r.map(function(n){return n=n.updatesTable,t?e.db.table(n).where(`k`).anyOf(t).delete():e.db.table(n).clear()})).then(function(){return n})):n}wt.prototype.execute=function(e){var t=this[`@@propmod`];if(t.add!==void 0){var r=t.add;if(a(r))return n(n([],a(e)?e:[],!0),r,!0).sort();if(typeof r==`number`)return(Number(e)||0)+r;if(typeof r==`bigint`)try{return BigInt(e)+r}catch{return BigInt(0)+r}throw TypeError(`Invalid term ${r}`)}if(t.remove!==void 0){var i=t.remove;if(a(i))return a(e)?e.filter(function(e){return!i.includes(e)}).sort():[];if(typeof i==`number`)return Number(e)-i;if(typeof i==`bigint`)try{return BigInt(e)-i}catch{return BigInt(0)-i}throw TypeError(`Invalid subtrahend ${i}`)}return r=(r=t.replacePrefix)?.[0],r&&typeof e==`string`&&e.startsWith(r)?t.replacePrefix[1]+e.substring(r.length):e};var Ct=wt;function wt(e){this[`@@propmod`]=e}function Tt(e,t){for(var n=i(t),r=n.length,a=!1,o=0;o<r;++o){var s=n[o],c=t[s],l=b(e,s);c instanceof Ct?(x(e,s,c.execute(l)),a=!0):l!==c&&(x(e,s,c),a=!0)}return a}H.prototype._trans=function(e,t,n){var r=this._tx||I.trans,i=this.name,a=xe&&typeof console<`u`&&console.createTask&&console.createTask(`Dexie: ${e===`readonly`?`read`:`write`} ${this.name}`);function o(e,n,r){if(r.schema[i])return t(r.idbtrans,r);throw new M.NotFound(`Table `+i+` not part of transaction`)}var s=Ge();try{var c=r&&r.db._novip===this.db._novip?r===I.trans?r._promise(e,o,n):tt(function(){return r._promise(e,o,n)},{trans:r,transless:I.transless||I}):function e(t,n,r,i){if(t.idbdb&&(t._state.openComplete||I.letThrough||t._vip)){var a=t._createTransaction(n,r,t._dbSchema);try{a.create(),t._state.PR1398_maxLoop=3}catch(a){return a.name===de.InvalidState&&t.isOpen()&&0<--t._state.PR1398_maxLoop?(console.warn(`Dexie: Need to reopen db`),t.close({disableAutoOpen:!1}),t.open().then(function(){return e(t,n,r,i)})):B(a)}return a._promise(n,function(e,t){return tt(function(){return I.trans=a,i(e,t,a)})}).then(function(e){if(n===`readwrite`)try{a.idbtrans.commit()}catch{}return n===`readonly`?e:a._completion.then(function(){return e})})}if(t._state.openComplete)return B(new M.DatabaseClosed(t._state.dbOpenError));if(!t._state.isBeingOpened){if(!t._state.autoOpen)return B(new M.DatabaseClosed);t.open().catch(N)}return t._state.dbReadyPromise.then(function(){return e(t,n,r,i)})}(this.db,e,[this.name],o);return a&&(c._consoleTask=a,c=c.catch(function(e){return console.trace(e),B(e)})),c}finally{s&&Ke()}},H.prototype.get=function(e,t){var n=this;return e&&e.constructor===Object?this.where(e).first(t):e==null?B(new M.Type(`Invalid argument to Table.get()`)):this._trans(`readonly`,function(t){return n.core.get({trans:t,key:e}).then(function(e){return n.hook.reading.fire(e)})}).then(t)},H.prototype.where=function(e){if(typeof e==`string`)return new this.db.WhereClause(this,e);if(a(e))return new this.db.WhereClause(this,`[${e.join(`+`)}]`);var t=i(e);if(t.length===1)return this.where(t[0]).equals(e[t[0]]);var n=this.schema.indexes.concat(this.schema.primKey).filter(function(e){if(e.compound&&t.every(function(t){return 0<=e.keyPath.indexOf(t)})){for(var n=0;n<t.length;++n)if(t.indexOf(e.keyPath[n])===-1)return!1;return!0}return!1}).sort(function(e,t){return e.keyPath.length-t.keyPath.length})[0];if(n&&this.db._maxKey!==ut)return s=n.keyPath.slice(0,t.length),this.where(s).equals(s.map(function(t){return e[t]}));!n&&xe&&console.warn(`The query ${JSON.stringify(e)} on ${this.name} would benefit from a compound index [${t.join(`+`)}]`);var r=this.schema.idxByName;function o(e,t){return V(e,t)===0}var s=t.reduce(function(t,n){var i=t[0],t=t[1],s=r[n],c=e[n];return[i||s,i||!s?gt(t,s&&s.multi?function(e){return e=b(e,n),a(e)&&e.some(function(e){return o(c,e)})}:function(e){return o(c,b(e,n))}):t]},[null,null]),c=s[0],s=s[1];return c?this.where(c.name).equals(e[c.keyPath]).filter(s):n?this.filter(s):this.where(t).equals(``)},H.prototype.filter=function(e){return this.toCollection().and(e)},H.prototype.count=function(e){return this.toCollection().count(e)},H.prototype.offset=function(e){return this.toCollection().offset(e)},H.prototype.limit=function(e){return this.toCollection().limit(e)},H.prototype.each=function(e){return this.toCollection().each(e)},H.prototype.toArray=function(e){return this.toCollection().toArray(e)},H.prototype.toCollection=function(){return new this.db.Collection(new this.db.WhereClause(this))},H.prototype.orderBy=function(e){return new this.db.Collection(new this.db.WhereClause(this,a(e)?`[${e.join(`+`)}]`:e))},H.prototype.reverse=function(){return this.toCollection().reverse()},H.prototype.mapToClass=function(t){for(var n=this.db,r=this.name,i=((this.schema.mappedClass=t).prototype instanceof yt&&(t=(t=>{var i=s,a=t;if(typeof a!=`function`&&a!==null)throw TypeError(`Class extends value `+String(a)+` is not a constructor or null`);function o(){this.constructor=i}function s(){return t!==null&&t.apply(this,arguments)||this}return e(i,a),i.prototype=a===null?Object.create(a):(o.prototype=a.prototype,new o),Object.defineProperty(s.prototype,"db",{get:function(){return n},enumerable:!1,configurable:!0}),s.prototype.table=function(){return r},s})(t)),new Set),a=t.prototype;a;a=s(a))Object.getOwnPropertyNames(a).forEach(function(e){return i.add(e)});function o(e){if(!e)return e;var n,r=Object.create(t.prototype);for(n in e)if(!i.has(n))try{r[n]=e[n]}catch{}return r}return this.schema.readHook&&this.hook.reading.unsubscribe(this.schema.readHook),this.schema.readHook=o,this.hook(`reading`,o),t},H.prototype.defineClass=function(){return this.mapToClass(function(e){o(this,e)})},H.prototype.add=function(e,t){var n=this,r=this.schema.primKey,i=r.auto,a=r.keyPath,o=e;return a&&i&&(o=vt(a)(e)),this._trans(`readwrite`,function(e){return n.core.mutate({trans:e,type:`add`,keys:t==null?null:[t],values:[o]})}).then(function(e){return e.numFailures?L.reject(e.failures[0]):e.lastResult}).then(function(t){if(a)try{x(e,a,t)}catch{}return t})},H.prototype.upsert=function(e,t){var n=this,r=this.schema.primKey.keyPath;return this._trans(`readwrite`,function(i){return n.core.get({trans:i,key:e}).then(function(a){var o=a??{};return Tt(o,t),r&&x(o,r,e),n.core.mutate({trans:i,type:`put`,values:[o],keys:[e],upsert:!0,updates:{keys:[e],changeSpecs:[t]}}).then(function(e){return e.numFailures?L.reject(e.failures[0]):!!a})})})},H.prototype.update=function(e,t){return typeof e!=`object`||a(e)?this.where(`:id`).equals(e).modify(t):(e=b(e,this.schema.primKey.keyPath))===void 0?B(new M.InvalidArgument(`Given object does not contain its primary key`)):this.where(`:id`).equals(e).modify(t)},H.prototype.put=function(e,t){var n=this,r=this.schema.primKey,i=r.auto,a=r.keyPath,o=e;return a&&i&&(o=vt(a)(e)),this._trans(`readwrite`,function(e){return n.core.mutate({trans:e,type:`put`,values:[o],keys:t==null?null:[t]})}).then(function(e){return e.numFailures?L.reject(e.failures[0]):e.lastResult}).then(function(t){if(a)try{x(e,a,t)}catch{}return t})},H.prototype.delete=function(e){var t=this;return this._trans(`readwrite`,function(n){return t.core.mutate({trans:n,type:`delete`,keys:[e]}).then(function(n){return St(t,[e],n)}).then(function(e){return e.numFailures?L.reject(e.failures[0]):void 0})})},H.prototype.clear=function(){var e=this;return this._trans(`readwrite`,function(t){return e.core.mutate({trans:t,type:`deleteRange`,range:_t}).then(function(t){return St(e,null,t)})}).then(function(e){return e.numFailures?L.reject(e.failures[0]):void 0})},H.prototype.bulkGet=function(e){var t=this;return this._trans(`readonly`,function(n){return t.core.getMany({keys:e,trans:n}).then(function(e){return e.map(function(e){return t.hook.reading.fire(e)})})})},H.prototype.bulkAdd=function(e,t,n){var r=this,i=Array.isArray(t)?t:void 0,a=(n||=i?void 0:t)?n.allKeys:void 0;return this._trans(`readwrite`,function(t){var n=r.schema.primKey,o=n.auto,n=n.keyPath;if(n&&i)throw new M.InvalidArgument(`bulkAdd(): keys argument invalid on tables with inbound keys`);if(i&&i.length!==e.length)throw new M.InvalidArgument(`Arguments objects and keys must have the same length`);var s=e.length,o=n&&o?e.map(vt(n)):e;return r.core.mutate({trans:t,type:`add`,keys:i,values:o,wantResults:a}).then(function(e){var t=e.numFailures,n=e.failures;if(t===0)return a?e.results:e.lastResult;throw new ue(`${r.name}.bulkAdd(): ${t} of ${s} operations failed`,n)})})},H.prototype.bulkPut=function(e,t,n){var r=this,i=Array.isArray(t)?t:void 0,a=(n||=i?void 0:t)?n.allKeys:void 0;return this._trans(`readwrite`,function(t){var n=r.schema.primKey,o=n.auto,n=n.keyPath;if(n&&i)throw new M.InvalidArgument(`bulkPut(): keys argument invalid on tables with inbound keys`);if(i&&i.length!==e.length)throw new M.InvalidArgument(`Arguments objects and keys must have the same length`);var s=e.length,o=n&&o?e.map(vt(n)):e;return r.core.mutate({trans:t,type:`put`,keys:i,values:o,wantResults:a}).then(function(e){var t=e.numFailures,n=e.failures;if(t===0)return a?e.results:e.lastResult;throw new ue(`${r.name}.bulkPut(): ${t} of ${s} operations failed`,n)})})},H.prototype.bulkUpdate=function(e){var t=this,n=this.core,r=e.map(function(e){return e.key}),i=e.map(function(e){return e.changes}),a=[];return this._trans(`readwrite`,function(o){return n.getMany({trans:o,keys:r,cache:`clone`}).then(function(s){var c=[],l=[],u=(e.forEach(function(e,n){var r=e.key,i=e.changes,o=s[n];if(o){for(var u=0,d=Object.keys(i);u<d.length;u++){var f=d[u],p=i[f];if(f===t.schema.primKey.keyPath){if(V(p,r)!==0)throw new M.Constraint(`Cannot update primary key in bulkUpdate()`)}else x(o,f,p)}a.push(n),c.push(r),l.push(o)}}),c.length);return n.mutate({trans:o,type:`put`,keys:c,values:l,updates:{keys:r,changeSpecs:i}}).then(function(e){var n=e.numFailures,r=e.failures;if(n===0)return u;for(var i=0,o=Object.keys(r);i<o.length;i++){var s,c=o[i],l=a[Number(c)];l!=null&&(s=r[c],delete r[c],r[l]=s)}throw new ue(`${t.name}.bulkUpdate(): ${n} of ${u} operations failed`,r)})})})},H.prototype.bulkDelete=function(e){var t=this,n=e.length;return this._trans(`readwrite`,function(n){return t.core.mutate({trans:n,type:`delete`,keys:e}).then(function(n){return St(t,e,n)})}).then(function(e){var r=e.numFailures,i=e.failures;if(r===0)return e.lastResult;throw new ue(`${t.name}.bulkDelete(): ${r} of ${n} operations failed`,i)})};var Et=H;function H(){}function Dt(e){function t(t,r){if(r){for(var i=arguments.length,a=Array(i-1);--i;)a[i-1]=arguments[i];return n[t].subscribe.apply(null,a),e}if(typeof t==`string`)return n[t]}var n={};t.addEventType=s;for(var r=1,o=arguments.length;r<o;++r)s(arguments[r]);return t;function s(e,r,o){var c,l;if(typeof e!=`object`)return r||=ye,l={subscribers:[],fire:o||=N,subscribe:function(e){l.subscribers.indexOf(e)===-1&&(l.subscribers.push(e),l.fire=r(l.fire,e))},unsubscribe:function(e){l.subscribers=l.subscribers.filter(function(t){return t!==e}),l.fire=l.subscribers.reduce(r,o)}},n[e]=t[e]=l;i(c=e).forEach(function(e){var t=c[e];if(a(t))s(e,c[e][0],c[e][1]);else{if(t!==`asap`)throw new M.InvalidArgument(`Invalid event config`);var n=s(e,me,function(){for(var e=arguments.length,t=Array(e);e--;)t[e]=arguments[e];n.subscribers.forEach(function(e){y(function(){e.apply(null,t)})})})}})}}function Ot(e,t){return p(t).from({prototype:e}),t}function kt(e,t){return!(e.filter||e.algorithm||e.or)&&(t?e.justLimit:!e.replayFilter)}function At(e,t){e.filter=gt(e.filter,t)}function jt(e,t,n){var r=e.replayFilter;e.replayFilter=r?function(){return gt(r(),t())}:t,e.justLimit=n&&!r}function Mt(e,t){if(e.isPrimKey)return t.primaryKey;var n=t.getIndexByKeyPath(e.index);if(n)return n;throw new M.Schema(`KeyPath `+e.index+` on object store `+t.name+` is not indexed`)}function Nt(e,t,n){var r=Mt(e,t.schema);return t.openCursor({trans:n,values:!e.keysOnly,reverse:e.dir===`prev`,unique:!!e.unique,query:{index:r,range:e.range}})}function Pt(e,t,n,r){var i,a,o=e.replayFilter?gt(e.filter,e.replayFilter()):e.filter;return e.or?(i={},a=function(e,n,r){var a,s;o&&!o(n,r,function(e){return n.stop(e)},function(e){return n.fail(e)})||((s=``+(a=n.primaryKey))==`[object ArrayBuffer]`&&(s=``+new Uint8Array(a)),l(i,s))||(i[s]=!0,t(e,n,r))},Promise.all([e.or._iterate(a,n),Ft(Nt(e,r,n),e.algorithm,a,!e.keysOnly&&e.valueMapper)])):Ft(Nt(e,r,n),gt(e.algorithm,o),t,!e.keysOnly&&e.valueMapper)}function Ft(e,t,n,r){var i=R(r?function(e,t,i){return n(r(e),t,i)}:n);return e.then(function(e){if(e)return e.start(function(){var n=function(){return e.continue()};t&&!t(e,function(e){return n=e},function(t){e.stop(t),n=N},function(t){e.fail(t),n=N})||i(e.value,e,function(e){return n=e}),n()})})}U.prototype._read=function(e,t){var n=this._ctx;return n.error?n.table._trans(null,B.bind(null,n.error)):n.table._trans(`readonly`,e).then(t)},U.prototype._write=function(e){var t=this._ctx;return t.error?t.table._trans(null,B.bind(null,t.error)):t.table._trans(`readwrite`,e,`locked`)},U.prototype._addAlgorithm=function(e){var t=this._ctx;t.algorithm=gt(t.algorithm,e)},U.prototype._iterate=function(e,t){return Pt(this._ctx,e,t,this._ctx.table.core)},U.prototype.clone=function(e){var t=Object.create(this.constructor.prototype),n=Object.create(this._ctx);return e&&o(n,e),t._ctx=n,t},U.prototype.raw=function(){return this._ctx.valueMapper=null,this},U.prototype.each=function(e){var t=this._ctx;return this._read(function(n){return Pt(t,e,n,t.table.core)})},U.prototype.count=function(e){var t=this;return this._read(function(e){var n,r=t._ctx,i=r.table.core;return kt(r,!0)?i.count({trans:e,query:{index:Mt(r,i.schema),range:r.range}}).then(function(e){return Math.min(e,r.limit)}):(n=0,Pt(r,function(){return++n,!1},e,i).then(function(){return n}))}).then(e)},U.prototype.sortBy=function(e,t){var n=e.split(`.`).reverse(),r=n[0],i=n.length-1;function a(e,t){return t?a(e[n[t]],t-1):e[r]}var o=this._ctx.dir===`next`?1:-1;function s(e,t){return V(a(e,i),a(t,i))*o}return this.toArray(function(e){return e.slice().sort(s)}).then(t)},U.prototype.toArray=function(e){var t=this;return this._read(function(e){var n,r,i,a=t._ctx;return kt(a,!0)&&0<a.limit?(n=a.valueMapper,r=Mt(a,a.table.core.schema),a.table.core.query({trans:e,limit:a.limit,values:!0,direction:a.dir===`prev`?`prev`:void 0,query:{index:r,range:a.range}}).then(function(e){return e=e.result,n?e.map(n):e})):(i=[],Pt(a,function(e){return i.push(e)},e,a.table.core).then(function(){return i}))},e)},U.prototype.offset=function(e){var t=this._ctx;return e<=0||(t.offset+=e,kt(t)?jt(t,function(){var t=e;return function(e,n){return t===0||(t===1?--t:n(function(){e.advance(t),t=0}),!1)}}):jt(t,function(){var t=e;return function(){return--t<0}})),this},U.prototype.limit=function(e){return this._ctx.limit=Math.min(this._ctx.limit,e),jt(this._ctx,function(){var t=e;return function(e,n,r){return--t<=0&&n(r),0<=t}},!0),this},U.prototype.until=function(e,t){return At(this._ctx,function(n,r,i){return!e(n.value)||(r(i),t)}),this},U.prototype.first=function(e){return this.limit(1).toArray(function(e){return e[0]}).then(e)},U.prototype.last=function(e){return this.reverse().first(e)},U.prototype.filter=function(e){var t;return At(this._ctx,function(t){return e(t.value)}),(t=this._ctx).isMatch=gt(t.isMatch,e),this},U.prototype.and=function(e){return this.filter(e)},U.prototype.or=function(e){return new this.db.WhereClause(this._ctx.table,e,this)},U.prototype.reverse=function(){return this._ctx.dir=this._ctx.dir===`prev`?`next`:`prev`,this._ondirectionchange&&this._ondirectionchange(this._ctx.dir),this},U.prototype.desc=function(){return this.reverse()},U.prototype.eachKey=function(e){var t=this._ctx;return t.keysOnly=!t.isMatch,this.each(function(t,n){e(n.key,n)})},U.prototype.eachUniqueKey=function(e){return this._ctx.unique=`unique`,this.eachKey(e)},U.prototype.eachPrimaryKey=function(e){var t=this._ctx;return t.keysOnly=!t.isMatch,this.each(function(t,n){e(n.primaryKey,n)})},U.prototype.keys=function(e){var t=this._ctx,n=(t.keysOnly=!t.isMatch,[]);return this.each(function(e,t){n.push(t.key)}).then(function(){return n}).then(e)},U.prototype.primaryKeys=function(e){var t=this._ctx;if(kt(t,!0)&&0<t.limit)return this._read(function(e){var n=Mt(t,t.table.core.schema);return t.table.core.query({trans:e,values:!1,limit:t.limit,direction:t.dir===`prev`?`prev`:void 0,query:{index:n,range:t.range}})}).then(function(e){return e.result}).then(e);t.keysOnly=!t.isMatch;var n=[];return this.each(function(e,t){n.push(t.primaryKey)}).then(function(){return n}).then(e)},U.prototype.uniqueKeys=function(e){return this._ctx.unique=`unique`,this.keys(e)},U.prototype.firstKey=function(e){return this.limit(1).keys(function(e){return e[0]}).then(e)},U.prototype.lastKey=function(e){return this.reverse().firstKey(e)},U.prototype.distinct=function(){var e,t=this._ctx,t=t.index&&t.table.schema.idxByName[t.index];return t&&t.multi&&(e={},At(this._ctx,function(t){var t=t.primaryKey.toString(),n=l(e,t);return e[t]=!0,!n})),this},U.prototype.modify=function(e){var t=this,n=this._ctx;return this._write(function(r){function a(e,t){var n=t.failures;p+=e-t.numFailures;for(var r=0,a=i(n);r<a.length;r++){var o=a[r];f.push(n[o])}}var o=typeof e==`function`?e:function(t){return Tt(t,e)},s=n.table.core,c=s.schema.primaryKey,l=c.outbound,u=c.extractKey,d=200,c=t.db._options.modifyChunkSize,f=(c&&(d=typeof c==`object`?c[s.name]||c[`*`]||200:c),[]),p=0,m=[],h=e===Lt;return t.clone().primaryKeys().then(function(t){function i(f){var p=Math.min(d,t.length-f),m=t.slice(f,f+p);return(h?Promise.resolve([]):s.getMany({trans:r,keys:m,cache:`immutable`})).then(function(g){var _=[],v=[],y=l?[]:null,b=h?m:[];if(!h)for(var x=0;x<p;++x){var S=g[x],C={value:O(S),primKey:t[f+x]};!1!==o.call(C,C.value,C)&&(C.value==null?b.push(t[f+x]):l||V(u(S),u(C.value))===0?(v.push(C.value),l&&y.push(t[f+x])):(b.push(t[f+x]),_.push(C.value)))}return Promise.resolve(0<_.length&&s.mutate({trans:r,type:`add`,values:_}).then(function(e){for(var t in e.failures)b.splice(parseInt(t),1);a(_.length,e)})).then(function(){return(0<v.length||c&&typeof e==`object`)&&s.mutate({trans:r,type:`put`,keys:y,values:v,criteria:c,changeSpec:typeof e!=`function`&&e,isAdditionalChunk:0<f}).then(function(e){return a(v.length,e)})}).then(function(){return(0<b.length||c&&h)&&s.mutate({trans:r,type:`delete`,keys:b,criteria:c,isAdditionalChunk:0<f}).then(function(e){return St(n.table,b,e)}).then(function(e){return a(b.length,e)})}).then(function(){return t.length>f+p&&i(f+d)})})}var c=kt(n)&&n.limit===1/0&&(typeof e!=`function`||h)&&{index:n.index,range:n.range};return i(0).then(function(){if(0<f.length)throw new le(`Error modifying one or more objects`,f,p,m);return t.length})})})},U.prototype.delete=function(){var e=this._ctx,t=e.range;return!kt(e)||e.table.schema.yProps||!e.isPrimKey&&t.type!==3?this.modify(Lt):this._write(function(n){var r=e.table.core.schema.primaryKey,i=t;return e.table.core.count({trans:n,query:{index:r,range:i}}).then(function(t){return e.table.core.mutate({trans:n,type:`deleteRange`,range:i}).then(function(e){var n=e.failures,e=e.numFailures;if(e)throw new le(`Could not delete some values`,Object.keys(n).map(function(e){return n[e]}),t-e);return t-e})})})};var It=U;function U(){}var Lt=function(e,t){return t.value=null};function Rt(e,t){return e<t?-1:e===t?0:1}function zt(e,t){return t<e?-1:e===t?0:1}function Bt(e,t,n){return e=e instanceof Gt?new e.Collection(e):e,e._ctx.error=new(n||TypeError)(t),e}function Vt(e){return new e.Collection(e,function(){return Wt(``)}).limit(0)}function Ht(e,t,n,r){var i,a,o,s,c,l,u,d=n.length;if(!n.every(function(e){return typeof e==`string`}))return Bt(e,ft);function f(e){i=e===`next`?function(e){return e.toUpperCase()}:function(e){return e.toLowerCase()},a=e===`next`?function(e){return e.toLowerCase()}:function(e){return e.toUpperCase()},o=e===`next`?Rt:zt;var t=n.map(function(e){return{lower:a(e),upper:i(e)}}).sort(function(e,t){return o(e.lower,t.lower)});s=t.map(function(e){return e.upper}),c=t.map(function(e){return e.lower}),u=(l=e)===`next`?``:r}f(`next`);var e=new e.Collection(e,function(){return Ut(s[0],c[d-1]+r)}),p=(e._ondirectionchange=function(e){f(e)},0);return e._addAlgorithm(function(e,n,r){var i=e.key;if(typeof i==`string`){var f=a(i);if(t(f,c,p))return!0;for(var m=null,h=p;h<d;++h){var g=((e,t,n,r,i,a)=>{for(var o=Math.min(e.length,r.length),s=-1,c=0;c<o;++c){var l=t[c];if(l!==r[c])return i(e[c],n[c])<0?e.substr(0,c)+n[c]+n.substr(c+1):i(e[c],r[c])<0?e.substr(0,c)+r[c]+n.substr(c+1):0<=s?e.substr(0,s)+t[s]+n.substr(s+1):null;i(e[c],l)<0&&(s=c)}return o<r.length&&a===`next`?e+n.substr(e.length):o<e.length&&a===`prev`?e.substr(0,n.length):s<0?null:e.substr(0,s)+r[s]+n.substr(s+1)})(i,f,s[h],c[h],o,l);g===null&&m===null?p=h+1:(m===null||0<o(m,g))&&(m=g)}n(m===null?r:function(){e.continue(m+u)})}return!1}),e}function Ut(e,t,n,r){return{type:2,lower:e,upper:t,lowerOpen:n,upperOpen:r}}function Wt(e){return{type:1,lower:e,upper:e}}Object.defineProperty(Kt.prototype,"Collection",{get:function(){return this._ctx.table.db.Collection},enumerable:!1,configurable:!0}),Kt.prototype.between=function(e,t,n,r){n=!1!==n,r=!0===r;try{return 0<this._cmp(e,t)||this._cmp(e,t)===0&&(n||r)&&(!n||!r)?Vt(this):new this.Collection(this,function(){return Ut(e,t,!n,!r)})}catch{return Bt(this,dt)}},Kt.prototype.equals=function(e){return e==null?Bt(this,dt):new this.Collection(this,function(){return Wt(e)})},Kt.prototype.above=function(e){return e==null?Bt(this,dt):new this.Collection(this,function(){return Ut(e,void 0,!0)})},Kt.prototype.aboveOrEqual=function(e){return e==null?Bt(this,dt):new this.Collection(this,function(){return Ut(e,void 0,!1)})},Kt.prototype.below=function(e){return e==null?Bt(this,dt):new this.Collection(this,function(){return Ut(void 0,e,!1,!0)})},Kt.prototype.belowOrEqual=function(e){return e==null?Bt(this,dt):new this.Collection(this,function(){return Ut(void 0,e)})},Kt.prototype.startsWith=function(e){return typeof e==`string`?this.between(e,e+ut,!0,!0):Bt(this,ft)},Kt.prototype.startsWithIgnoreCase=function(e){return e===``?this.startsWith(e):Ht(this,function(e,t){return e.indexOf(t[0])===0},[e],ut)},Kt.prototype.equalsIgnoreCase=function(e){return Ht(this,function(e,t){return e===t[0]},[e],``)},Kt.prototype.anyOfIgnoreCase=function(){var e=ie.apply(re,arguments);return e.length===0?Vt(this):Ht(this,function(e,t){return t.indexOf(e)!==-1},e,``)},Kt.prototype.startsWithAnyOfIgnoreCase=function(){var e=ie.apply(re,arguments);return e.length===0?Vt(this):Ht(this,function(e,t){return t.some(function(t){return e.indexOf(t)===0})},e,ut)},Kt.prototype.anyOf=function(){var e,t,n=this,r=ie.apply(re,arguments),i=this._cmp;try{r.sort(i)}catch{return Bt(this,dt)}return r.length===0?Vt(this):((e=new this.Collection(this,function(){return Ut(r[0],r[r.length-1])}))._ondirectionchange=function(e){i=e===`next`?n._ascending:n._descending,r.sort(i)},t=0,e._addAlgorithm(function(e,n,a){for(var o=e.key;0<i(o,r[t]);)if(++t===r.length)return n(a),!1;return i(o,r[t])===0||(n(function(){e.continue(r[t])}),!1)}),e)},Kt.prototype.notEqual=function(e){return this.inAnyRange([[-1/0,e],[e,this.db._maxKey]],{includeLowers:!1,includeUppers:!1})},Kt.prototype.noneOf=function(){var e=ie.apply(re,arguments);if(e.length===0)return new this.Collection(this);try{e.sort(this._ascending)}catch{return Bt(this,dt)}var t=e.reduce(function(e,t){return e?e.concat([[e[e.length-1][1],t]]):[[-1/0,t]]},null);return t.push([e[e.length-1],this.db._maxKey]),this.inAnyRange(t,{includeLowers:!1,includeUppers:!1})},Kt.prototype.inAnyRange=function(e,t){var n=this,r=this._cmp,i=this._ascending,a=this._descending,o=this._min,s=this._max;if(e.length===0)return Vt(this);if(!e.every(function(e){return e[0]!==void 0&&e[1]!==void 0&&i(e[0],e[1])<=0}))return Bt(this,`First argument to inAnyRange() must be an Array of two-value Arrays [lower,upper] where upper must not be lower than lower`,M.InvalidArgument);var c=!t||!1!==t.includeLowers,l=t&&!0===t.includeUppers,u,d=i;function f(e,t){return d(e[0],t[0])}try{(u=e.reduce(function(e,t){for(var n=0,i=e.length;n<i;++n){var a=e[n];if(r(t[0],a[1])<0&&0<r(t[1],a[0])){a[0]=o(a[0],t[0]),a[1]=s(a[1],t[1]);break}}return n===i&&e.push(t),e},[])).sort(f)}catch{return Bt(this,dt)}var p=0,m=l?function(e){return 0<i(e,u[p][1])}:function(e){return 0<=i(e,u[p][1])},h=c?function(e){return 0<a(e,u[p][0])}:function(e){return 0<=a(e,u[p][0])},g=m,t=new this.Collection(this,function(){return Ut(u[0][0],u[u.length-1][1],!c,!l)});return t._ondirectionchange=function(e){d=e===`next`?(g=m,i):(g=h,a),u.sort(f)},t._addAlgorithm(function(e,t,r){for(var a,o=e.key;g(o);)if(++p===u.length)return t(r),!1;return!m(a=o)&&!h(a)||(n._cmp(o,u[p][1])===0||n._cmp(o,u[p][0])===0||t(function(){d===i?e.continue(u[p][0]):e.continue(u[p][1])}),!1)}),t},Kt.prototype.startsWithAnyOf=function(){var e=ie.apply(re,arguments);return e.every(function(e){return typeof e==`string`})?e.length===0?Vt(this):this.inAnyRange(e.map(function(e){return[e,e+ut]})):Bt(this,`startsWithAnyOf() only works with strings`)};var Gt=Kt;function Kt(){}function qt(e){return R(function(t){return Jt(t),e(t.target.error),!1})}function Jt(e){e.stopPropagation&&e.stopPropagation(),e.preventDefault&&e.preventDefault()}var Yt=`storagemutated`,Xt=`x-storagemutated-1`,Zt=Dt(null,Yt),Qt=($t.prototype._lock=function(){return v(!I.global),++this._reculock,this._reculock!==1||I.global||(I.lockOwnerFor=this),this},$t.prototype._unlock=function(){if(v(!I.global),--this._reculock==0)for(I.global||(I.lockOwnerFor=null);0<this._blockedFuncs.length&&!this._locked();){var e=this._blockedFuncs.shift();try{st(e[1],e[0])}catch{}}return this},$t.prototype._locked=function(){return this._reculock&&I.lockOwnerFor!==this},$t.prototype.create=function(e){var t=this;if(this.mode){var n=this.db.idbdb,r=this.db._state.dbOpenError;if(v(!this.idbtrans),!e&&!n)switch(r&&r.name){case`DatabaseClosedError`:throw new M.DatabaseClosed(r);case`MissingAPIError`:throw new M.MissingAPI(r.message,r);default:throw new M.OpenFailed(r)}if(!this.active)throw new M.TransactionInactive;v(this._completion._state===null),(e=this.idbtrans=e||(this.db.core||n).transaction(this.storeNames,this.mode,{durability:this.chromeTransactionDurability})).onerror=R(function(n){Jt(n),t._reject(e.error)}),e.onabort=R(function(n){Jt(n),t.active&&t._reject(new M.Abort(e.error)),t.active=!1,t.on(`abort`).fire(n)}),e.oncomplete=R(function(){t.active=!1,t._resolve(),`mutatedParts`in e&&Zt.storagemutated.fire(e.mutatedParts)})}return this},$t.prototype._promise=function(e,t,n){var r,i=this;return e===`readwrite`&&this.mode!==`readwrite`?B(new M.ReadOnly(`Transaction is readonly`)):this.active?this._locked()?new L(function(r,a){i._blockedFuncs.push([function(){i._promise(e,t,n).then(r,a)},I])}):n?tt(function(){var e=new L(function(e,n){i._lock();var r=t(e,n,i);r&&r.then&&r.then(e,n)});return e.finally(function(){return i._unlock()}),e._lib=!0,e}):((r=new L(function(e,n){var r=t(e,n,i);r&&r.then&&r.then(e,n)}))._lib=!0,r):B(new M.TransactionInactive)},$t.prototype._root=function(){return this.parent?this.parent._root():this},$t.prototype.waitFor=function(e){var t,n=this._root(),r=L.resolve(e),i=(n._waitingFor?n._waitingFor=n._waitingFor.then(function(){return r}):(n._waitingFor=r,n._waitingQueue=[],t=n.idbtrans.objectStore(n.storeNames[0]),function e(){for(++n._spinCount;n._waitingQueue.length;)n._waitingQueue.shift()();n._waitingFor&&(t.get(-1/0).onsuccess=e)}()),n._waitingFor);return new L(function(e,t){r.then(function(t){return n._waitingQueue.push(R(e.bind(null,t)))},function(e){return n._waitingQueue.push(R(t.bind(null,e)))}).finally(function(){n._waitingFor===i&&(n._waitingFor=null)})})},$t.prototype.abort=function(){this.active&&(this.active=!1,this.idbtrans&&this.idbtrans.abort(),this._reject(new M.Abort))},$t.prototype.table=function(e){var t=this._memoizedTables||={};if(l(t,e))return t[e];var n=this.schema[e];if(n)return(n=new this.db.Table(e,n,this)).core=this.db.core.table(e),t[e]=n;throw new M.NotFound(`Table `+e+` not part of transaction`)},$t);function $t(){}function en(e,t,n,r,i,a,o,s){return{name:e,keyPath:t,unique:n,multi:r,auto:i,compound:a,src:(n&&!o?`&`:``)+(r?`*`:``)+(i?`++`:``)+tn(t),type:s}}function tn(e){return typeof e==`string`?e:e?`[`+[].join.call(e,`+`)+`]`:``}function nn(e,t,n){return{name:e,primKey:t,indexes:n,mappedClass:null,idxByName:(r=function(e){return[e.name,e]},n.reduce(function(e,t,n){return t=r(t,n),t&&(e[t[0]]=t[1]),e},{}))};var r}var rn=function(e){try{return e.only([[]]),rn=function(){return[[]]},[[]]}catch{return rn=function(){return ut},ut}};function W(e){return e==null?function(){}:typeof e==`string`?(t=e).split(`.`).length===1?function(e){return e[t]}:function(e){return b(e,t)}:function(t){return b(t,e)};var t}function an(e){return[].slice.call(e)}var on=0;function sn(e){return e==null?`:id`:typeof e==`string`?e:`[${e.join(`+`)}]`}function cn(e,t,n){function r(e){if(e.type===3)return null;if(e.type===4)throw Error(`Cannot convert never type to IDBKeyRange`);var n=e.lower,r=e.upper,i=e.lowerOpen,e=e.upperOpen;return n===void 0?r===void 0?null:t.upperBound(r,!!e):r===void 0?t.lowerBound(n,!!i):t.bound(n,r,!!i,!!e)}function i(e){var t,n,i=e.name;return{name:i,schema:e,mutate:function(e){var t=e.trans,n=e.type,a=e.keys,o=e.values,s=e.range;return new Promise(function(e,c){e=R(e);var l=t.objectStore(i),u=l.keyPath==null,d=n===`put`||n===`add`;if(!d&&n!==`delete`&&n!==`deleteRange`)throw Error(`Invalid operation type: `+n);var f,p=(a||o||{length:1}).length;if(a&&o&&a.length!==o.length)throw Error(`Given keys array must have same length as given values array.`);if(p===0)return e({numFailures:0,failures:{},results:[],lastResult:void 0});function m(e){++_,Jt(e)}var h=[],g=[],_=0;if(n===`deleteRange`){if(s.type===4)return e({numFailures:_,failures:g,results:[],lastResult:void 0});s.type===3?h.push(f=l.clear()):h.push(f=l.delete(r(s)))}else{var u=d?u?[o,a]:[o,null]:[a,null],v=u[0],y=u[1];if(d)for(var b=0;b<p;++b)h.push(f=y&&y[b]!==void 0?l[n](v[b],y[b]):l[n](v[b])),f.onerror=m;else for(b=0;b<p;++b)h.push(f=l[n](v[b])),f.onerror=m}function x(t){t=t.target.result,h.forEach(function(e,t){return e.error!=null&&(g[t]=e.error)}),e({numFailures:_,failures:g,results:n===`delete`?a:h.map(function(e){return e.result}),lastResult:t})}f.onerror=function(e){m(e),x(e)},f.onsuccess=x})},getMany:function(e){var t=e.trans,n=e.keys;return new Promise(function(e,r){e=R(e);for(var a,o=t.objectStore(i),s=n.length,c=Array(s),l=0,u=0,d=function(t){t=t.target,c[t._pos]=t.result,++u===l&&e(c)},f=qt(r),p=0;p<s;++p)n[p]!=null&&((a=o.get(n[p]))._pos=p,a.onsuccess=d,a.onerror=f,++l);l===0&&e(c)})},get:function(e){var t=e.trans,n=e.key;return new Promise(function(e,r){e=R(e);var a=t.objectStore(i).get(n);a.onsuccess=function(t){return e(t.target.result)},a.onerror=qt(r)})},query:(t=c,n=l,function(e){return new Promise(function(a,o){a=R(a);var s,c,l,u,d=e.trans,f=e.values,p=e.limit,m=e.query,h=(h=e.direction)??`next`,g=p===1/0?void 0:p,_=m.index,m=m.range,d=d.objectStore(i),d=_.isPrimaryKey?d:d.index(_.name),_=r(m);if(p===0)return a({result:[]});n?(m={query:_,count:g,direction:h},(s=f?d.getAll(m):d.getAllKeys(m)).onsuccess=function(e){return a({result:e.target.result})},s.onerror=qt(o)):t&&h===`next`?((s=f?d.getAll(_,g):d.getAllKeys(_,g)).onsuccess=function(e){return a({result:e.target.result})},s.onerror=qt(o)):(c=0,l=!f&&`openKeyCursor`in d?d.openKeyCursor(_,h):d.openCursor(_,h),u=[],l.onsuccess=function(){var e=l.result;return!e||(u.push(f?e.value:e.primaryKey),++c===p)?a({result:u}):void e.continue()},l.onerror=qt(o))})}),openCursor:function(e){var t=e.trans,n=e.values,a=e.query,o=e.reverse,s=e.unique;return new Promise(function(e,c){e=R(e);var l=a.index,u=a.range,d=t.objectStore(i),d=l.isPrimaryKey?d:d.index(l.name),l=o?s?`prevunique`:`prev`:s?`nextunique`:`next`,f=!n&&`openKeyCursor`in d?d.openKeyCursor(r(u),l):d.openCursor(r(u),l);f.onerror=qt(c),f.onsuccess=R(function(n){var r,i,a,o,s=f.result;s?(s.___id=++on,s.done=!1,r=s.continue.bind(s),i=(i=s.continuePrimaryKey)&&i.bind(s),a=s.advance.bind(s),o=function(){throw Error(`Cursor not stopped`)},s.trans=t,s.stop=s.continue=s.continuePrimaryKey=s.advance=function(){throw Error(`Cursor not started`)},s.fail=R(c),s.next=function(){var e=this,t=1;return this.start(function(){return t--?e.continue():e.stop()}).then(function(){return e})},s.start=function(e){function t(){if(f.result)try{e()}catch(e){s.fail(e)}else s.done=!0,s.start=function(){throw Error(`Cursor behind last entry`)},s.stop()}var n=new Promise(function(e,t){e=R(e),f.onerror=qt(t),s.fail=t,s.stop=function(t){s.stop=s.continue=s.continuePrimaryKey=s.advance=o,e(t)}});return f.onsuccess=R(function(e){f.onsuccess=t,t()}),s.continue=r,s.continuePrimaryKey=i,s.advance=a,t(),n},e(s)):e(null)},c)})},count:function(e){var t=e.query,n=e.trans,a=t.index,o=t.range;return new Promise(function(e,t){var s=n.objectStore(i),s=a.isPrimaryKey?s:s.index(a.name),c=r(o),c=c?s.count(c):s.count();c.onsuccess=R(function(t){return e(t.target.result)}),c.onerror=qt(t)})}}}o=n,s=an((n=e).objectStoreNames),u=0<s.length?o.objectStore(s[0]):{};var o,n={schema:{name:n.name,tables:s.map(function(e){return o.objectStore(e)}).map(function(e){var t=e.keyPath,n=e.autoIncrement,r=a(t),i={},r={name:e.name,primaryKey:{name:null,isPrimaryKey:!0,outbound:t==null,compound:r,keyPath:t,autoIncrement:n,unique:!0,extractKey:W(t)},indexes:an(e.indexNames).map(function(t){return e.index(t)}).map(function(e){var t=e.name,n=e.unique,r=e.multiEntry,e=e.keyPath,t={name:t,compound:a(e),keyPath:e,unique:n,multiEntry:r,extractKey:W(e)};return i[sn(e)]=t}),getIndexByKeyPath:function(e){return i[sn(e)]}};return i[`:id`]=r.primaryKey,t!=null&&(i[sn(t)]=r.primaryKey),r})},hasGetAll:0<s.length&&`getAll`in u&&!(typeof navigator<`u`&&/Safari/.test(navigator.userAgent)&&!/(Chrome\/|Edge\/)/.test(navigator.userAgent)&&[].concat(navigator.userAgent.match(/Safari\/(\d*)/))[1]<604),hasIdb3Features:`getAllRecords`in u},s=n.schema,c=n.hasGetAll,l=n.hasIdb3Features,u=s.tables.map(i),d={};return u.forEach(function(e){return d[e.name]=e}),{stack:`dbcore`,transaction:e.transaction.bind(e),table:function(e){if(d[e])return d[e];throw Error(`Table '${e}' not found`)},MIN_KEY:-1/0,MAX_KEY:rn(t),schema:s}}function ln(e,n,r,i){return r=r.IDBKeyRange,n=cn(n,r,i),{dbcore:e.dbcore.reduce(function(e,n){return n=n.create,t(t({},e),n(e))},n)}}function un(e,t){var n=t.db,n=ln(e._middlewares,n,e._deps,t);e.core=n.dbcore,e.tables.forEach(function(t){var n=t.name;e.core.schema.tables.some(function(e){return e.name===n})&&(t.core=e.core.table(n),e[n]instanceof e.Table)&&(e[n].core=t.core)})}function dn(e,t,n,r){n.forEach(function(n){var i=r[n];t.forEach(function(t){var r=function e(t,n){return m(t,n)||(t=s(t))&&e(t,n)}(t,n);(!r||`value`in r&&r.value===void 0)&&(t===e.Transaction.prototype||t instanceof e.Transaction?f(t,n,{get:function(){return this.table(n)},set:function(e){d(this,n,{value:e,writable:!0,configurable:!0,enumerable:!0})}}):t[n]=new e.Table(n,i))})})}function fn(e,t){t.forEach(function(t){for(var n in t)t[n]instanceof e.Table&&delete t[n]})}function pn(e,t){return e._cfg.version-t._cfg.version}function G(e,t,n,r){var a=e._dbSchema,o=(n.objectStoreNames.contains(`$meta`)&&!a.$meta&&(a.$meta=nn(`$meta`,xn(``)[0],[]),e._storeNames.push(`$meta`)),e._createTransaction(`readwrite`,e._storeNames,a)),s=(o.create(n),o._completion.catch(r),o._reject.bind(o)),c=I.transless||I;tt(function(){if(I.trans=o,I.transless=c,t!==0)return un(e,n),l=t,((r=o).storeNames.includes(`$meta`)?r.table(`$meta`).get(`version`).then(function(e){return e??l}):L.resolve(l)).then(function(t){var r=e,a=t,s=o,c=n,l=[],t=r._versions,u=r._dbSchema=yn(0,r.idbdb,c);return(t=t.filter(function(e){return e._cfg.version>=a})).length===0?L.resolve():(t.forEach(function(e){l.push(function(){var t,n,o,l=u,d=e._cfg.dbschema,f=(bn(r,l,c),bn(r,d,c),u=r._dbSchema=d,hn(l,d)),p=(f.add.forEach(function(e){gn(c,e[0],e[1].primKey,e[1].indexes)}),f.change.forEach(function(e){if(e.recreate)throw new M.Upgrade(`Not yet support for changing primary key`);var t=c.objectStore(e.name);e.add.forEach(function(e){return vn(t,e)}),e.change.forEach(function(e){t.deleteIndex(e.name),vn(t,e)}),e.del.forEach(function(e){return t.deleteIndex(e)})}),e._cfg.contentUpgrade);if(p&&e._cfg.version>a)return un(r,c),s._memoizedTables={},t=S(d),f.del.forEach(function(e){t[e]=l[e]}),fn(r,[r.Transaction.prototype]),dn(r,[r.Transaction.prototype],i(t),t),s.schema=t,(n=ae(p))&&nt(),d=L.follow(function(){var e;(o=p(s))&&n&&(e=rt.bind(null,null),o.then(e,e))}),o&&typeof o.then==`function`?L.resolve(o):d.then(function(){return o})}),l.push(function(t){var n=e._cfg.dbschema,i=t;[].slice.call(i.db.objectStoreNames).forEach(function(e){return n[e]==null&&i.db.deleteObjectStore(e)}),fn(r,[r.Transaction.prototype]),dn(r,[r.Transaction.prototype],r._storeNames,r._dbSchema),s.schema=r._dbSchema}),l.push(function(t){r.idbdb.objectStoreNames.contains(`$meta`)&&(Math.ceil(r.idbdb.version/10)===e._cfg.version?(r.idbdb.deleteObjectStore(`$meta`),delete r._dbSchema.$meta,r._storeNames=r._storeNames.filter(function(e){return e!==`$meta`})):t.objectStore(`$meta`).put(e._cfg.version,`version`))})}),function e(){return l.length?L.resolve(l.shift()(s.idbtrans)).then(e):L.resolve()}().then(function(){_n(u,c)}))}).catch(s);var r,l;i(a).forEach(function(e){gn(n,e,a[e].primKey,a[e].indexes)}),un(e,n),L.follow(function(){return e.on.populate.fire(o)}).catch(s)})}function mn(e,t){_n(e._dbSchema,t),t.db.version%10!=0||t.objectStoreNames.contains(`$meta`)||t.db.createObjectStore(`$meta`).add(Math.ceil(t.db.version/10-1),`version`);var n=yn(0,e.idbdb,t);bn(e,e._dbSchema,t);for(var r=0,i=hn(n,e._dbSchema).change;r<i.length;r++){var a=(e=>{if(e.change.length||e.recreate)return console.warn(`Unable to patch indexes of table ${e.name} because it has changes on the type of index or primary key.`),{value:void 0};var n=t.objectStore(e.name);e.add.forEach(function(t){xe&&console.debug(`Dexie upgrade patch: Creating missing index ${e.name}.${t.src}`),vn(n,t)})})(i[r]);if(typeof a==`object`)return a.value}}function hn(e,t){var n,r={del:[],add:[],change:[]};for(n in e)t[n]||r.del.push(n);for(n in t){var i=e[n],a=t[n];if(i){var o={name:n,def:a,recreate:!1,del:[],add:[],change:[]};if(``+(i.primKey.keyPath||``)!=``+(a.primKey.keyPath||``)||i.primKey.auto!==a.primKey.auto)o.recreate=!0,r.change.push(o);else{var s=i.idxByName,c=a.idxByName,l=void 0;for(l in s)c[l]||o.del.push(l);for(l in c){var u=s[l],d=c[l];u?u.src!==d.src&&o.change.push(d):o.add.push(d)}(0<o.del.length||0<o.add.length||0<o.change.length)&&r.change.push(o)}}else r.add.push([n,a])}return r}function gn(e,t,n,r){var i=e.db.createObjectStore(t,n.keyPath?{keyPath:n.keyPath,autoIncrement:n.auto}:{autoIncrement:n.auto});r.forEach(function(e){return vn(i,e)})}function _n(e,t){i(e).forEach(function(n){t.db.objectStoreNames.contains(n)||(xe&&console.debug(`Dexie: Creating missing table`,n),gn(t,n,e[n].primKey,e[n].indexes))})}function vn(e,t){e.createIndex(t.name,t.keyPath,{unique:t.unique,multiEntry:t.multi})}function yn(e,t,n){var r={};return g(t.objectStoreNames,0).forEach(function(e){for(var t=n.objectStore(e),i=en(tn(c=t.keyPath),c||``,!0,!1,!!t.autoIncrement,c&&typeof c!=`string`,!0),a=[],o=0;o<t.indexNames.length;++o){var s=t.index(t.indexNames[o]),c=s.keyPath,s=en(s.name,c,!!s.unique,!!s.multiEntry,!1,c&&typeof c!=`string`,!1);a.push(s)}r[e]=nn(e,i,a)}),r}function bn(e,t,n){for(var i=n.db.objectStoreNames,a=0;a<i.length;++a){var o=i[a],s=n.objectStore(o);e._hasGetAll=`getAll`in s;for(var c=0;c<s.indexNames.length;++c){var l,u=s.indexNames[c],d=s.index(u).keyPath,d=typeof d==`string`?d:`[`+g(d).join(`+`)+`]`;t[o]&&(l=t[o].idxByName[d])&&(l.name=u,delete t[o].idxByName[d],t[o].idxByName[u]=l)}}typeof navigator<`u`&&/Safari/.test(navigator.userAgent)&&!/(Chrome\/|Edge\/)/.test(navigator.userAgent)&&r.WorkerGlobalScope&&r instanceof r.WorkerGlobalScope&&[].concat(navigator.userAgent.match(/Safari\/(\d*)/))[1]<604&&(e._hasGetAll=!1)}function xn(e){return e.split(`,`).map(function(e,t){var n=e.split(`:`),r=(r=n[1])?.trim(),n=(e=n[0].trim()).replace(/([&*]|\+\+)/g,``),i=/^\[/.test(n)?n.match(/^\[(.*)\]$/)[1].split(`+`):n;return en(n,i||null,/\&/.test(e),/\*/.test(e),/\+\+/.test(e),a(i),t===0,r)})}Cn.prototype._createTableSchema=nn,Cn.prototype._parseIndexSyntax=xn,Cn.prototype._parseStoresSpec=function(e,t){var n=this;i(e).forEach(function(r){if(e[r]!==null){var i=n._parseIndexSyntax(e[r]),a=i.shift();if(!a)throw new M.Schema(`Invalid schema for table `+r+`: `+e[r]);if(a.unique=!0,a.multi)throw new M.Schema(`Primary key cannot be multiEntry*`);i.forEach(function(e){if(e.auto)throw new M.Schema(`Only primary key can be marked as autoIncrement (++)`);if(!e.keyPath)throw new M.Schema(`Index must have a name and cannot be an empty string`)}),a=n._createTableSchema(r,a,i),t[r]=a}})},Cn.prototype.stores=function(e){var t=this.db,e=(this._cfg.storesSource=this._cfg.storesSource?o(this._cfg.storesSource,e):e,t._versions),n={},r={};return e.forEach(function(e){o(n,e._cfg.storesSource),r=e._cfg.dbschema={},e._parseStoresSpec(n,r)}),t._dbSchema=r,fn(t,[t._allTables,t,t.Transaction.prototype]),dn(t,[t._allTables,t,t.Transaction.prototype,this._cfg.tables],i(r),r),t._storeNames=i(r),this},Cn.prototype.upgrade=function(e){return this._cfg.contentUpgrade=be(this._cfg.contentUpgrade||N,e),this};var Sn=Cn;function Cn(){}var wn=(()=>{var e,t,n;return typeof FinalizationRegistry<`u`&&typeof WeakRef<`u`?(e=new Set,t=new FinalizationRegistry(function(t){e.delete(t)}),{toArray:function(){return Array.from(e).map(function(e){return e.deref()}).filter(function(e){return e!==void 0})},add:function(n){var r=new WeakRef(n._novip);e.add(r),t.register(n._novip,r,r),e.size>n._options.maxConnections&&(r=e.values().next().value,e.delete(r),t.unregister(r))},remove:function(n){if(n)for(var r=e.values(),i=r.next();!i.done;){var a=i.value;if(a.deref()===n._novip)return e.delete(a),void t.unregister(a);i=r.next()}}}):(n=[],{toArray:function(){return n},add:function(e){n.push(e._novip)},remove:function(e){e&&(e=n.indexOf(e._novip))!==-1&&n.splice(e,1)}})})();function Tn(e,t){var n=e._dbNamesDB;return n||(n=e._dbNamesDB=new lr(pt,{addons:[],indexedDB:e,IDBKeyRange:t})).version(1).stores({dbnames:`name`}),n.table(`dbnames`)}function En(e){return e&&typeof e.databases==`function`}function Dn(e){return tt(function(){return I.letThrough=!0,e()})}function On(e){return!(`from`in e)}var K=function(e,t){var n;if(!this)return n=new K,e&&`d`in e&&o(n,e),n;o(this,arguments.length?{d:1,from:e,to:1<arguments.length?t:e}:{d:0})};function kn(e,t,n){var r=V(t,n);if(!isNaN(r)){if(0<r)throw RangeError();if(On(e))return o(e,{from:t,to:n,d:1});var r=e.l,i=e.r;if(V(n,e.from)<0)return r?kn(r,t,n):e.l={from:t,to:n,d:1,l:null,r:null},Nn(e);if(0<V(t,e.to))return i?kn(i,t,n):e.r={from:t,to:n,d:1,l:null,r:null},Nn(e);V(t,e.from)<0&&(e.from=t,e.l=null,e.d=i?i.d+1:1),0<V(n,e.to)&&(e.to=n,e.r=null,e.d=e.l?e.l.d+1:1),t=!e.r,r&&!e.l&&An(e,r),i&&t&&An(e,i)}}function An(e,t){On(t)||function e(t,n){var r=n.from,i=n.l,a=n.r;kn(t,r,n.to),i&&e(t,i),a&&e(t,a)}(e,t)}function jn(e,t){var n=Mn(t),r=n.next();if(!r.done)for(var i=r.value,a=Mn(e),o=a.next(i.from),s=o.value;!r.done&&!o.done;){if(V(s.from,i.to)<=0&&0<=V(s.to,i.from))return!0;V(i.from,s.from)<0?i=(r=n.next(s.from)).value:s=(o=a.next(i.from)).value}return!1}function Mn(e){var t=On(e)?null:{s:0,n:e};return{next:function(e){for(var n=0<arguments.length;t;)switch(t.s){case 0:if(t.s=1,n)for(;t.n.l&&V(e,t.n.from)<0;)t={up:t,n:t.n.l,s:1};else for(;t.n.l;)t={up:t,n:t.n.l,s:1};case 1:if(t.s=2,!n||V(e,t.n.to)<=0)return{value:t.n,done:!1};case 2:if(t.n.r){t.s=3,t={up:t,n:t.n.r,s:0};continue}case 3:t=t.up}return{done:!0}}}}function Nn(e){var n,r,i,a=((a=e.r)?.d||0)-((a=e.l)?.d||0),a=1<a?`r`:a<-1?`l`:``;a&&(n=a==`r`?`l`:`r`,r=t({},e),i=e[a],e.from=i.from,e.to=i.to,e[a]=i[a],r[a]=i[n],(e[n]=r).d=Pn(r)),e.d=Pn(e)}function Pn(e){var t=e.r,e=e.l;return(t?e?Math.max(t.d,e.d):t.d:e?e.d:0)+1}function Fn(e,t){return i(t).forEach(function(n){e[n]?An(e[n],t[n]):e[n]=function e(t){var n,r,i={};for(n in t)l(t,n)&&(r=t[n],i[n]=!r||typeof r!=`object`||E.has(r.constructor)?r:e(r));return i}(t[n])}),e}function In(e,t){return e.all||t.all||Object.keys(e).some(function(n){return t[n]&&jn(t[n],e[n])})}u(K.prototype,((j={add:function(e){return An(this,e),this},addKey:function(e){return kn(this,e,e),this},addKeys:function(e){var t=this;return e.forEach(function(e){return kn(t,e,e)}),this},hasKey:function(e){var t=Mn(this).next(e).value;return t&&V(t.from,e)<=0&&0<=V(t.to,e)}})[te]=function(){return Mn(this)},j));var Ln={},Rn={},zn=!1;function Bn(e){Fn(Rn,e),zn||(zn=!0,setTimeout(function(){zn=!1,Vn(Rn,!(Rn={}))},0))}function Vn(e,t){t===void 0&&(t=!1);var n=new Set;if(e.all)for(var r=0,i=Object.values(Ln);r<i.length;r++)Hn(s=i[r],e,n,t);else for(var a in e){var o,s,a=/^idb\:\/\/(.*)\/(.*)\//.exec(a);a&&(o=a[1],a=a[2],s=Ln[`idb://${o}/${a}`])&&Hn(s,e,n,t)}n.forEach(function(e){return e()})}function Hn(e,t,n,r){for(var i=[],a=0,o=Object.entries(e.queries.query);a<o.length;a++){for(var s=o[a],c=s[0],l=[],u=0,d=s[1];u<d.length;u++){var f=d[u];In(t,f.obsSet)?f.subscribers.forEach(function(e){return n.add(e)}):r&&l.push(f)}r&&i.push([c,l])}if(r)for(var p=0,m=i;p<m.length;p++){var h=m[p],c=h[0],l=h[1];e.queries.query[c]=l}}function Un(e){var t=e._state,n=e._deps.indexedDB;if(t.isBeingOpened||e.idbdb)return t.dbReadyPromise.then(function(){return t.dbOpenError?B(t.dbOpenError):e});t.isBeingOpened=!0,t.dbOpenError=null,t.openComplete=!1;var r=t.openCanceller,a=Math.round(10*e.verno),o=!1;function s(){if(t.openCanceller!==r)throw new M.DatabaseClosed(`db.open() was cancelled`)}function c(){return new L(function(r,l){if(s(),!n)throw new M.MissingAPI;var u=e.name,p=t.autoSchema||!a?n.open(u):n.open(u,a);if(!p)throw new M.MissingAPI;p.onerror=qt(l),p.onblocked=R(e._fireOnBlocked),p.onupgradeneeded=R(function(r){var i;d=p.transaction,t.autoSchema&&!e._options.allowEmptyDB?(p.onerror=Jt,d.abort(),p.result.close(),(i=n.deleteDatabase(u)).onsuccess=i.onerror=R(function(){l(new M.NoSuchDatabase(`Database ${u} doesnt exist`))})):(d.onerror=qt(l),i=r.oldVersion>2**62?0:r.oldVersion,f=i<1,e.idbdb=p.result,o&&mn(e,d),G(e,i/10,d,l))},l),p.onsuccess=R(function(){d=null;var n,s,l,m,h,_,v=e.idbdb=p.result,y=g(v.objectStoreNames);if(0<y.length)try{var b=v.transaction((h=y).length===1?h[0]:h,`readonly`);if(t.autoSchema)_=v,m=b,(l=e).verno=_.version/10,m=l._dbSchema=yn(0,_,m),l._storeNames=g(_.objectStoreNames,0),dn(l,[l._allTables],i(m),m);else if(bn(e,e._dbSchema,b),s=b,((s=hn(yn(0,(n=e).idbdb,s),n._dbSchema)).add.length||s.change.some(function(e){return e.add.length||e.change.length}))&&!o)return console.warn(`Dexie SchemaDiff: Schema was extended without increasing the number passed to db.version(). Dexie will add missing parts and increment native version number to workaround this.`),v.close(),a=v.version+1,o=!0,r(c());un(e,b)}catch{}wn.add(e),v.onversionchange=R(function(n){t.vcFired=!0,e.on(`versionchange`).fire(n)}),v.onclose=R(function(){e.close({disableAutoOpen:!1})}),f&&(y=e._deps,h=u,En(_=y.indexedDB)||h===pt||Tn(_,y.IDBKeyRange).put({name:h}).catch(N)),r()},l)}).catch(function(e){switch(e?.name){case`UnknownError`:if(0<t.PR1398_maxLoop)return t.PR1398_maxLoop--,console.warn(`Dexie: Workaround for Chrome UnknownError on open()`),c();break;case`VersionError`:if(0<a)return a=0,c()}return L.reject(e)})}var l,u=t.dbReadyResolve,d=null,f=!1;return L.race([r,(typeof navigator>`u`?L.resolve():!navigator.userAgentData&&/Safari\//.test(navigator.userAgent)&&!/Chrom(e|ium)\//.test(navigator.userAgent)&&indexedDB.databases?new Promise(function(e){function t(){return indexedDB.databases().finally(e)}l=setInterval(t,100),t()}).finally(function(){return clearInterval(l)}):Promise.resolve()).then(c)]).then(function(){return s(),t.onReadyBeingFired=[],L.resolve(Dn(function(){return e.on.ready.fire(e.vip)})).then(function n(){var r;if(0<t.onReadyBeingFired.length)return r=t.onReadyBeingFired.reduce(be,N),t.onReadyBeingFired=[],L.resolve(Dn(function(){return r(e.vip)})).then(n)})}).finally(function(){t.openCanceller===r&&(t.onReadyBeingFired=null,t.isBeingOpened=!1)}).catch(function(n){t.dbOpenError=n;try{d&&d.abort()}catch{}return r===t.openCanceller&&e._close(),B(n)}).finally(function(){t.openComplete=!0,u()}).then(function(){var t;return f&&(t={},e.tables.forEach(function(n){n.schema.indexes.forEach(function(r){r.name&&(t[`idb://${e.name}/${n.name}/${r.name}`]=new K(-1/0,[[[]]]))}),t[`idb://${e.name}/${n.name}/`]=t[`idb://${e.name}/${n.name}/:dels`]=new K(-1/0,[[[]]])}),Zt(Yt).fire(t),Vn(t,!0)),e})}function Wn(e){function t(t){return e.next(t)}var n=i(t),r=i(function(t){return e.throw(t)});function i(e){return function(t){var t=e(t),i=t.value;return t.done?i:i&&typeof i.then==`function`?i.then(n,r):a(i)?Promise.all(i).then(n,r):n(i)}}return i(t)()}function Gn(e,t,n){for(var r=a(e)?e.slice():[e],i=0;i<n;++i)r.push(t);return r}var Kn={stack:`dbcore`,name:`VirtualIndexMiddleware`,level:1,create:function(e){return t(t({},e),{table:function(n){var r=e.table(n),n=r.schema,i={},a=[];function o(e,n,r){var s=sn(e),c=i[s]=i[s]||[],l=e==null?0:typeof e==`string`?1:e.length,u=0<n,s=t(t({},r),{name:u?`${s}(virtual-from:${r.name})`:r.name,lowLevelIndex:r,isVirtual:u,keyTail:n,keyLength:l,extractKey:W(e),unique:!u&&r.unique});return c.push(s),s.isPrimaryKey||a.push(s),1<l&&o(l===2?e[0]:e.slice(0,l-1),n+1,r),c.sort(function(e,t){return e.keyTail-t.keyTail}),s}var s=o(n.primaryKey.keyPath,0,n.primaryKey);i[`:id`]=[s];for(var c=0,l=n.indexes;c<l.length;c++){var u=l[c];o(u.keyPath,0,u)}function d(n){var r,i=n.query.index;return i.isVirtual?t(t({},n),{query:{index:i.lowLevelIndex,range:(r=n.query.range,i=i.keyTail,{type:r.type===1?2:r.type,lower:Gn(r.lower,r.lowerOpen?e.MAX_KEY:e.MIN_KEY,i),lowerOpen:!0,upper:Gn(r.upper,r.upperOpen?e.MIN_KEY:e.MAX_KEY,i),upperOpen:!0})}}):n}return t(t({},r),{schema:t(t({},n),{primaryKey:s,indexes:a,getIndexByKeyPath:function(e){return(e=i[sn(e)])&&e[0]}}),count:function(e){return r.count(d(e))},query:function(e){return r.query(d(e))},openCursor:function(t){var n=t.query.index,i=n.keyTail,a=n.keyLength;return n.isVirtual?r.openCursor(d(t)).then(function(e){return e&&o(e)}):r.openCursor(t);function o(n){return Object.create(n,{continue:{value:function(r){r==null?t.unique?n.continue(n.key.slice(0,a).concat(t.reverse?e.MIN_KEY:e.MAX_KEY,i)):n.continue():n.continue(Gn(r,t.reverse?e.MAX_KEY:e.MIN_KEY,i))}},continuePrimaryKey:{value:function(t,r){n.continuePrimaryKey(Gn(t,e.MAX_KEY,i),r)}},primaryKey:{get:function(){return n.primaryKey}},key:{get:function(){var e=n.key;return a===1?e[0]:e.slice(0,a)}},value:{get:function(){return n.value}}})}}})}})}};function qn(e,t,n,r){return n||={},r||=``,i(e).forEach(function(i){var a,o,s;l(t,i)?(a=e[i],o=t[i],typeof a==`object`&&typeof o==`object`&&a&&o?(s=k(a))===k(o)?s===`Object`?qn(a,o,n,r+i+`.`):a!==o&&(n[r+i]=t[i]):n[r+i]=t[i]:a!==o&&(n[r+i]=t[i])):n[r+i]=void 0}),i(t).forEach(function(i){l(e,i)||(n[r+i]=t[i])}),n}function Jn(e,t){return t.type===`delete`?t.keys:t.keys||t.values.map(e.extractKey)}var Yn={stack:`dbcore`,name:`HooksMiddleware`,level:2,create:function(e){return t(t({},e),{table:function(r){var i=e.table(r),a=i.schema.primaryKey;return t(t({},i),{mutate:function(e){var o=I.trans,s=o.table(r).hook,c=s.deleting,u=s.creating,d=s.updating;switch(e.type){case`add`:if(u.fire===N)break;return o._promise(`readwrite`,function(){return f(e)},!0);case`put`:if(u.fire===N&&d.fire===N)break;return o._promise(`readwrite`,function(){return f(e)},!0);case`delete`:if(c.fire===N)break;return o._promise(`readwrite`,function(){return f(e)},!0);case`deleteRange`:if(c.fire===N)break;return o._promise(`readwrite`,function(){return function e(n,r,o){return i.query({trans:n,values:!1,query:{index:a,range:r},limit:o}).then(function(i){var a=i.result;return f({type:`delete`,keys:a,trans:n}).then(function(i){return 0<i.numFailures?Promise.reject(i.failures[0]):a.length<o?{failures:[],numFailures:0,lastResult:void 0}:e(n,t(t({},r),{lower:a[a.length-1],lowerOpen:!0}),o)})})}(e.trans,e.range,1e4)},!0)}return i.mutate(e);function f(e){var r,o,s,f=I.trans,p=e.keys||Jn(a,e);if(p)return(e=e.type===`add`||e.type===`put`?t(t({},e),{keys:p}):t({},e)).type!==`delete`&&(e.values=n([],e.values,!0)),e.keys&&=n([],e.keys,!0),r=i,s=p,((o=e).type===`add`?Promise.resolve([]):r.getMany({trans:o.trans,keys:s,cache:`immutable`})).then(function(t){var n=p.map(function(n,r){var i,o,s,p=t[r],m={onerror:null,onsuccess:null};return e.type===`delete`?c.fire.call(m,n,p,f):e.type===`add`||p===void 0?(i=u.fire.call(m,n,e.values[r],f),n==null&&i!=null&&(e.keys[r]=n=i,a.outbound||x(e.values[r],a.keyPath,n))):(i=qn(p,e.values[r]),(o=d.fire.call(m,i,n,p,f))&&(s=e.values[r],Object.keys(o).forEach(function(e){l(s,e)?s[e]=o[e]:x(s,e,o[e])}))),m});return i.mutate(e).then(function(r){for(var i=r.failures,a=r.results,o=r.numFailures,r=r.lastResult,s=0;s<p.length;++s){var c=(a||p)[s],l=n[s];c==null?l.onerror&&l.onerror(i[s]):l.onsuccess&&l.onsuccess(e.type===`put`&&t[s]?e.values[s]:c)}return{failures:i,results:a,numFailures:o,lastResult:r}}).catch(function(e){return n.forEach(function(t){return t.onerror&&t.onerror(e)}),Promise.reject(e)})});throw Error(`Keys missing`)}}})}})}};function Xn(e,t,n){try{if(!t||t.keys.length<e.length)return null;for(var r=[],i=0,a=0;i<t.keys.length&&a<e.length;++i)V(t.keys[i],e[a])===0&&(r.push(n?O(t.values[i]):t.values[i]),++a);return r.length===e.length?r:null}catch{return null}}var Zn={stack:`dbcore`,level:-1,create:function(e){return{table:function(n){var r=e.table(n);return t(t({},r),{getMany:function(e){var t;return e.cache?(t=Xn(e.keys,e.trans._cache,e.cache===`clone`))?L.resolve(t):r.getMany(e).then(function(t){return e.trans._cache={keys:e.keys,values:e.cache===`clone`?O(t):t},t}):r.getMany(e)},mutate:function(e){return e.type!==`add`&&(e.trans._cache=null),r.mutate(e)}})}}}};function Qn(e,t){return e.trans.mode===`readonly`&&!!e.subscr&&!e.trans.explicit&&e.trans.db._options.cache!==`disabled`&&!t.schema.primaryKey.outbound}function $n(e,t){switch(e){case`query`:return t.values&&!t.unique;case`get`:case`getMany`:case`count`:case`openCursor`:return!1}}var er={stack:`dbcore`,level:0,name:`Observability`,create:function(e){var n=e.schema.name,r=new K(e.MIN_KEY,e.MAX_KEY);return t(t({},e),{transaction:function(t,n,r){if(I.subscr&&n!==`readonly`)throw new M.ReadOnly(`Readwrite transaction in liveQuery context. Querier source: ${I.querier}`);return e.transaction(t,n,r)},table:function(o){function s(t){var t=t.query;return[t.index,new K((t=t.range).lower??e.MIN_KEY,t.upper??e.MAX_KEY)]}var c=e.table(o),l=c.schema,u=l.primaryKey,d=l.indexes,f=u.extractKey,p=u.outbound,m=u.autoIncrement&&d.filter(function(e){return e.compound&&e.keyPath.includes(u.keyPath)}),h=t(t({},c),{mutate:function(t){function i(e){return e=`idb://${n}/${o}/${e}`,h[e]||(h[e]=new K)}var s,d,f,p=t.trans,h=t.mutatedParts||={},g=i(``),_=i(`:dels`),v=t.type,y=t.type===`deleteRange`?[t.range]:t.type===`delete`?[t.keys]:t.values.length<50?[Jn(u,t).filter(function(e){return e}),t.values]:[],b=y[0],y=y[1],x=t.trans._cache;return a(b)?(g.addKeys(b),(v=v===`delete`||b.length===y.length?Xn(b,x):null)||_.addKeys(b),(v||y)&&(s=i,d=v,f=y,l.indexes.forEach(function(e){var t=s(e.name||``);function n(t){return t==null?null:e.extractKey(t)}function r(n){e.multiEntry&&a(n)?n.forEach(function(e){return t.addKey(e)}):t.addKey(n)}(d||f).forEach(function(e,t){var i=d&&n(d[t]),t=f&&n(f[t]);V(i,t)!==0&&(i!=null&&r(i),t!=null)&&r(t)})}))):b?(y={from:(x=b.lower)??e.MIN_KEY,to:(v=b.upper)??e.MAX_KEY},_.add(y),g.add(y)):(g.add(r),_.add(r),l.indexes.forEach(function(e){return i(e.name).add(r)})),c.mutate(t).then(function(e){return!b||t.type!==`add`&&t.type!==`put`||(g.addKeys(e.results),m&&m.forEach(function(n){for(var r=t.values.map(function(e){return n.extractKey(e)}),a=n.keyPath.findIndex(function(e){return e===u.keyPath}),o=0,s=e.results.length;o<s;++o)r[o][a]=e.results[o];i(n.name).addKeys(r)})),p.mutatedParts=Fn(p.mutatedParts||{},h),e})}}),g={get:function(e){return[u,new K(e.key)]},getMany:function(e){return[u,new K().addKeys(e.keys)]},count:s,query:s,openCursor:s};return i(g).forEach(function(e){h[e]=function(i){var a=I.subscr,s=!!a,l=Qn(I,c)&&$n(e,i)?i.obsSet={}:a;if(s){var u,a=function(e){return e=`idb://${n}/${o}/${e}`,l[e]||(l[e]=new K)},d=a(``),m=a(`:dels`),s=g[e](i),h=s[0],s=s[1];if((e===`query`&&h.isPrimaryKey&&!i.values?m:a(h.name||``)).add(s),!h.isPrimaryKey){if(e!==`count`)return u=e===`query`&&p&&i.values&&c.query(t(t({},i),{values:!1})),c[e].apply(this,arguments).then(function(t){if(e===`query`){if(p&&i.values)return u.then(function(e){return e=e.result,d.addKeys(e),t});var n=i.values?t.result.map(f):t.result;(i.values?d:m).addKeys(n)}else{var r,a;if(e===`openCursor`)return a=i.values,(r=t)&&Object.create(r,{key:{get:function(){return m.addKey(r.primaryKey),r.key}},primaryKey:{get:function(){var e=r.primaryKey;return m.addKey(e),e}},value:{get:function(){return a&&d.addKey(r.primaryKey),r.value}}})}return t});m.add(r)}}return c[e].apply(this,arguments)}}),h}})}};function tr(e,n,r){var i;return r.numFailures===0?n:n.type===`deleteRange`||(i=n.keys?n.keys.length:`values`in n&&n.values?n.values.length:1,r.numFailures===i)?null:(i=t({},n),a(i.keys)&&(i.keys=i.keys.filter(function(e,t){return!(t in r.failures)})),`values`in i&&a(i.values)&&(i.values=i.values.filter(function(e,t){return!(t in r.failures)})),i)}function nr(e,t){return n=e,((r=t).lower===void 0||(r.lowerOpen?0<V(n,r.lower):0<=V(n,r.lower)))&&(n=e,(r=t).upper===void 0||(r.upperOpen?V(n,r.upper)<0:V(n,r.upper)<=0));var n,r}function rr(e,t,n,r,i,o){var s,c,l,u,d,f,p;return!n||n.length===0||(s=t.query.index,c=s.multiEntry,l=t.query.range,u=r.schema.primaryKey.extractKey,d=s.extractKey,f=(s.lowLevelIndex||s).extractKey,(r=n.reduce(function(e,n){var r=e,i=[];if(n.type===`add`||n.type===`put`)for(var o=new K,s=n.values.length-1;0<=s;--s){var f,p=n.values[s],m=u(p);!o.hasKey(m)&&(f=d(p),c&&a(f)?f.some(function(e){return nr(e,l)}):nr(f,l))&&(o.addKey(m),i.push(p))}switch(n.type){case`add`:var h=new K().addKeys(t.values?e.map(function(e){return u(e)}):e),r=e.concat(t.values?i.filter(function(e){return e=u(e),!h.hasKey(e)&&(h.addKey(e),!0)}):i.map(function(e){return u(e)}).filter(function(e){return!h.hasKey(e)&&(h.addKey(e),!0)}));break;case`put`:var g=new K().addKeys(n.values.map(function(e){return u(e)}));r=e.filter(function(e){return!g.hasKey(t.values?u(e):e)}).concat(t.values?i:i.map(function(e){return u(e)}));break;case`delete`:var _=new K().addKeys(n.keys);r=e.filter(function(e){return!_.hasKey(t.values?u(e):e)});break;case`deleteRange`:var v=n.range;r=e.filter(function(e){return!nr(u(e),v)})}return r},e))===e)?e:(p=function(e,t){return V(f(e),f(t))||V(u(e),u(t))},r.sort(t.direction===`prev`||t.direction===`prevunique`?function(e,t){return p(t,e)}:p),t.limit&&t.limit<1/0&&(r.length>t.limit?r.length=t.limit:e.length===t.limit&&r.length<t.limit&&(i.dirty=!0)),o?Object.freeze(r):r)}function ir(e,t){return V(e.lower,t.lower)===0&&V(e.upper,t.upper)===0&&!!e.lowerOpen==!!t.lowerOpen&&!!e.upperOpen==!!t.upperOpen}function ar(e,t){return((e,t,n,r)=>{if(e===void 0)return t===void 0?0:-1;if(t===void 0)return 1;if((e=V(e,t))===0){if(n&&r)return 0;if(n)return 1;if(r)return-1}return e})(e.lower,t.lower,e.lowerOpen,t.lowerOpen)<=0&&0<=((e,t,n,r)=>{if(e===void 0)return t===void 0?0:1;if(t===void 0)return-1;if((e=V(e,t))===0){if(n&&r)return 0;if(n)return-1;if(r)return 1}return e})(e.upper,t.upper,e.upperOpen,t.upperOpen)}function or(e,t,n,r){e.subscribers.add(n),r.addEventListener(`abort`,function(){var r,i;e.subscribers.delete(n),e.subscribers.size===0&&(r=e,i=t,setTimeout(function(){r.subscribers.size===0&&A(i,r)},3e3))})}var sr={stack:`dbcore`,level:0,name:`Cache`,create:function(e){var n=e.schema.name;return t(t({},e),{transaction:function(t,r,i){var a,o,s=e.transaction(t,r,i);return r===`readwrite`&&(i=(a=new AbortController).signal,s.addEventListener(`abort`,(o=function(i){return function(){if(a.abort(),r===`readwrite`){for(var o=new Set,c=0,l=t;c<l.length;c++){var u=l[c],d=Ln[`idb://${n}/${u}`];if(d){var f=e.table(u),p=d.optimisticOps.filter(function(e){return e.trans===s});if(s._explicit&&i&&s.mutatedParts)for(var m=0,h=Object.values(d.queries.query);m<h.length;m++)for(var g=0,_=(b=h[m]).slice();g<_.length;g++)In((x=_[g]).obsSet,s.mutatedParts)&&(A(b,x),x.subscribers.forEach(function(e){return o.add(e)}));else if(0<p.length){d.optimisticOps=d.optimisticOps.filter(function(e){return e.trans!==s});for(var v=0,y=Object.values(d.queries.query);v<y.length;v++)for(var b,x,S,C=0,w=(b=y[v]).slice();C<w.length;C++)(x=w[C]).res!=null&&s.mutatedParts&&(i&&!x.dirty?(S=Object.isFrozen(x.res),S=rr(x.res,x.req,p,f,x,S),x.dirty?(A(b,x),x.subscribers.forEach(function(e){return o.add(e)})):S!==x.res&&(x.res=S,x.promise=L.resolve({result:S}))):(x.dirty&&A(b,x),x.subscribers.forEach(function(e){return o.add(e)})))}}}o.forEach(function(e){return e()})}}})(!1),{signal:i}),s.addEventListener(`error`,o(!1),{signal:i}),s.addEventListener(`complete`,o(!0),{signal:i})),s},table:function(r){var i=e.table(r),a=i.schema.primaryKey;return t(t({},i),{mutate:function(e){var o,s=I.trans;return!a.outbound&&s.db._options.cache!==`disabled`&&!s.explicit&&s.idbtrans.mode===`readwrite`&&(o=Ln[`idb://${n}/${r}`])?(s=i.mutate(e),e.type!==`add`&&e.type!==`put`||!(50<=e.values.length||Jn(a,e).some(function(e){return e==null}))?(o.optimisticOps.push(e),e.mutatedParts&&Bn(e.mutatedParts),s.then(function(t){0<t.numFailures&&(A(o.optimisticOps,e),(t=tr(0,e,t))&&o.optimisticOps.push(t),e.mutatedParts)&&Bn(e.mutatedParts)}),s.catch(function(){A(o.optimisticOps,e),e.mutatedParts&&Bn(e.mutatedParts)})):s.then(function(n){var r=tr(0,t(t({},e),{values:e.values.map(function(e,r){var i;return n.failures[r]?e:(x(i=(i=a.keyPath)!=null&&i.includes(`.`)?O(e):t({},e),a.keyPath,n.results[r]),i)})}),n);o.optimisticOps.push(r),queueMicrotask(function(){return e.mutatedParts&&Bn(e.mutatedParts)})}),s):i.mutate(e)},query:function(e){var t,a,o,s,c,l,u;return Qn(I,i)&&$n(`query`,e)?(t=(o=I.trans)?.db._options.cache===`immutable`,a=(o=I).requery,o=o.signal,l=((e,t,n,r)=>{var i=Ln[`idb://${e}/${t}`];if(!i)return[];if(!(e=i.queries[n]))return[null,!1,i,null];var a=e[(r.query?r.query.index.name:null)||``];if(!a)return[null,!1,i,null];switch(n){case`query`:var o=(s=r.direction)??`next`,s=a.find(function(e){return e.req.limit===r.limit&&e.req.values===r.values&&(e.req.direction??`next`)===o&&ir(e.req.query.range,r.query.range)});return s?[s,!0,i,a]:[a.find(function(e){return(`limit`in e.req?e.req.limit:1/0)>=r.limit&&(e.req.direction??`next`)===o&&(!r.values||e.req.values)&&ar(e.req.query.range,r.query.range)}),!1,i,a];case`count`:return s=a.find(function(e){return ir(e.req.query.range,r.query.range)}),[s,!!s,i,a]}})(n,r,`query`,e),u=l[0],s=l[2],c=l[3],u&&l[1]?u.obsSet=e.obsSet:(l=i.query(e).then(function(e){var n=e.result;if(u&&(u.res=n),t){for(var r=0,i=n.length;r<i;++r)Object.freeze(n[r]);Object.freeze(n)}return e}).catch(function(e){return c&&u&&A(c,u),Promise.reject(e)}),u={obsSet:e.obsSet,promise:l,subscribers:new Set,type:`query`,req:e,dirty:!1},c?c.push(u):(c=[u],(s||=Ln[`idb://${n}/${r}`]={queries:{query:{},count:{}},objs:new Map,optimisticOps:[],unsignaledParts:{}}).queries.query[e.query.index.name||``]=c)),or(u,c,a,o),u.promise.then(function(n){return n=rr(n.result,e,s?.optimisticOps,i,u,t),{result:t?n:O(n)}})):i.query(e)}})}})}};function cr(e,t){return new Proxy(e,{get:function(e,n,r){return n===`db`?t:Reflect.get(e,n,r)}})}q.prototype.version=function(e){if(isNaN(e)||e<.1)throw new M.Type(`Given version is not a positive number`);if(e=Math.round(10*e)/10,this.idbdb||this._state.isBeingOpened)throw new M.Schema(`Cannot add version when database is open`);this.verno=Math.max(this.verno,e);var t=this._versions,n=t.filter(function(t){return t._cfg.version===e})[0];return n||(n=new this.Version(e),t.push(n),t.sort(pn),n.stores({}),this._state.autoSchema=!1),n},q.prototype._whenReady=function(e){var t=this;return this.idbdb&&(this._state.openComplete||I.letThrough||this._vip)?e():new L(function(e,n){if(t._state.openComplete)return n(new M.DatabaseClosed(t._state.dbOpenError));if(!t._state.isBeingOpened){if(!t._state.autoOpen)return void n(new M.DatabaseClosed);t.open().catch(N)}t._state.dbReadyPromise.then(e,n)}).then(e)},q.prototype.use=function(e){var t=e.stack,n=e.create,r=e.level,e=e.name,i=(e&&this.unuse({stack:t,name:e}),this._middlewares[t]||(this._middlewares[t]=[]));return i.push({stack:t,create:n,level:r??10,name:e}),i.sort(function(e,t){return e.level-t.level}),this},q.prototype.unuse=function(e){var t=e.stack,n=e.name,r=e.create;return t&&this._middlewares[t]&&(this._middlewares[t]=this._middlewares[t].filter(function(e){return r?e.create!==r:!!n&&e.name!==n})),this},q.prototype.open=function(){var e=this;return st(Pe,function(){return Un(e)})},q.prototype._close=function(){this.on.close.fire(new CustomEvent(`close`));var e=this._state;if(wn.remove(this),this.idbdb){try{this.idbdb.close()}catch{}this.idbdb=null}e.isBeingOpened||(e.dbReadyPromise=new L(function(t){e.dbReadyResolve=t}),e.openCanceller=new L(function(t,n){e.cancelOpen=n}))},q.prototype.close=function(e){var e=(e===void 0?{disableAutoOpen:!0}:e).disableAutoOpen,t=this._state;e?(t.isBeingOpened&&t.cancelOpen(new M.DatabaseClosed),this._close(),t.autoOpen=!1,t.dbOpenError=new M.DatabaseClosed):(this._close(),t.autoOpen=this._options.autoOpen||t.isBeingOpened,t.openComplete=!1,t.dbOpenError=null)},q.prototype.delete=function(e){var t=this,n=(e===void 0&&(e={disableAutoOpen:!0}),0<arguments.length&&typeof arguments[0]!=`object`),r=this._state;return new L(function(i,a){function o(){t.close(e);var n=t._deps.indexedDB.deleteDatabase(t.name);n.onsuccess=R(function(){var e=t._deps,n=t.name,r;En(r=e.indexedDB)||n===pt||Tn(r,e.IDBKeyRange).delete(n).catch(N),i()}),n.onerror=qt(a),n.onblocked=t._fireOnBlocked}if(n)throw new M.InvalidArgument(`Invalid closeOptions argument to db.delete()`);r.isBeingOpened?r.dbReadyPromise.then(o):o()})},q.prototype.backendDB=function(){return this.idbdb},q.prototype.isOpen=function(){return this.idbdb!==null},q.prototype.hasBeenClosed=function(){var e=this._state.dbOpenError;return e&&e.name===`DatabaseClosed`},q.prototype.hasFailed=function(){return this._state.dbOpenError!==null},q.prototype.dynamicallyOpened=function(){return this._state.autoSchema},Object.defineProperty(q.prototype,"tables",{get:function(){var e=this;return i(this._allTables).map(function(t){return e._allTables[t]})},enumerable:!1,configurable:!0}),q.prototype.transaction=function(){var e=function(e,t,n){var r=arguments.length;if(r<2)throw new M.InvalidArgument(`Too few arguments`);for(var i=Array(r-1);--r;)i[r-1]=arguments[r];return n=i.pop(),[e,w(i),n]}.apply(this,arguments);return this._transaction.apply(this,e)},q.prototype._transaction=function(e,t,n){var r,i,a=this,o=I.trans,s=(o&&o.db===this&&e.indexOf(`!`)===-1||(o=null),e.indexOf(`?`)!==-1);e=e.replace(`!`,``).replace(`?`,``);try{if(i=t.map(function(e){if(e=e instanceof a.Table?e.name:e,typeof e!=`string`)throw TypeError(`Invalid table argument to Dexie.transaction(). Only Table or String are allowed`);return e}),e==`r`||e===mt)r=mt;else{if(e!=`rw`&&e!=ht)throw new M.InvalidArgument(`Invalid transaction mode: `+e);r=ht}if(o){if(o.mode===mt&&r===ht){if(!s)throw new M.SubTransaction(`Cannot enter a sub-transaction with READWRITE mode when parent transaction is READONLY`);o=null}o&&i.forEach(function(e){if(o&&o.storeNames.indexOf(e)===-1){if(!s)throw new M.SubTransaction(`Table `+e+` not included in parent transaction.`);o=null}}),s&&o&&!o.active&&(o=null)}}catch(e){return o?o._promise(null,function(t,n){n(e)}):B(e)}var c=function e(t,n,r,i,a){return L.resolve().then(function(){var o=I.transless||I,s=t._createTransaction(n,r,t._dbSchema,i),o=(s.explicit=!0,{trans:s,transless:o});if(i)s.idbtrans=i.idbtrans;else try{s.create(),s.idbtrans._explicit=!0,t._state.PR1398_maxLoop=3}catch(i){return i.name===de.InvalidState&&t.isOpen()&&0<--t._state.PR1398_maxLoop?(console.warn(`Dexie: Need to reopen db`),t.close({disableAutoOpen:!1}),t.open().then(function(){return e(t,n,r,null,a)})):B(i)}var c,l=ae(a),o=(l&&nt(),L.follow(function(){var e;(c=a.call(s,s))&&(l?(e=rt.bind(null,null),c.then(e,e)):typeof c.next==`function`&&typeof c.throw==`function`&&(c=Wn(c)))},o));return(c&&typeof c.then==`function`?L.resolve(c).then(function(e){return s.active?e:B(new M.PrematureCommit(`Transaction committed too early. See http://bit.ly/2kdckMn`))}):o.then(function(){return c})).then(function(e){return i&&s._resolve(),s._completion.then(function(){return e})}).catch(function(e){return s._reject(e),B(e)})})}.bind(null,this,r,i,o,n);return o?o._promise(r,c,`lock`):I.trans?st(I.transless,function(){return a._whenReady(c)}):this._whenReady(c)},q.prototype.table=function(e){if(l(this._allTables,e))return this._allTables[e];throw new M.InvalidTable(`Table ${e} does not exist`)};var lr=q;function q(e,n){var r,i,a,o,s,c=this,l=(this._middlewares={},this.verno=0,q.dependencies),l=(this._options=n=t({addons:q.addons,autoOpen:!0,indexedDB:l.indexedDB,IDBKeyRange:l.IDBKeyRange,cache:`cloned`,maxConnections:1e3},n),this._deps={indexedDB:n.indexedDB,IDBKeyRange:n.IDBKeyRange},n.addons),u=(this._dbSchema={},this._versions=[],this._storeNames=[],this._allTables={},this.idbdb=null,this._novip=this,{dbOpenError:null,isBeingOpened:!1,onReadyBeingFired:null,openComplete:!1,dbReadyResolve:N,dbReadyPromise:null,cancelOpen:N,openCanceller:null,autoSchema:!0,PR1398_maxLoop:3,autoOpen:n.autoOpen}),d=(u.dbReadyPromise=new L(function(e){u.dbReadyResolve=e}),u.openCanceller=new L(function(e,t){u.cancelOpen=t}),this._state=u,this.name=e,this.on=Dt(this,`populate`,`blocked`,`versionchange`,`close`,{ready:[be,N]}),this.once=function(e,t){var n=function(){var r=[...arguments];c.on(e).unsubscribe(n),t.apply(c,r)};return c.on(e,n)},this.on.ready.subscribe=_(this.on.ready.subscribe,function(e){return function(t,n){q.vip(function(){var r,i=c._state;i.openComplete?(i.dbOpenError||L.resolve().then(t),n&&e(t)):i.onReadyBeingFired?(i.onReadyBeingFired.push(t),n&&e(t)):(e(t),r=c,n||e(function e(){r.on.ready.unsubscribe(t),r.on.ready.unsubscribe(e)}))})}}),this.Collection=(r=this,Ot(It.prototype,function(e,t){this.db=r;var n=_t,i=null;if(t)try{n=t()}catch(e){i=e}var t=e._ctx,e=t.table,a=e.hook.reading.fire;this._ctx={table:e,index:t.index,isPrimKey:!t.index||e.schema.primKey.keyPath&&t.index===e.schema.primKey.name,range:n,keysOnly:!1,dir:`next`,unique:``,algorithm:null,filter:null,replayFilter:null,justLimit:!0,isMatch:null,offset:0,limit:1/0,error:i,or:t.or,valueMapper:a===me?null:a}})),this.Table=(i=this,Ot(Et.prototype,function(e,t,n){this.db=i,this._tx=n,this.name=e,this.schema=t,this.hook=i._allTables[e]?i._allTables[e].hook:Dt(null,{creating:[_e,N],reading:[he,me],updating:[P,N],deleting:[ve,N]})})),this.Transaction=(a=this,Ot(Qt.prototype,function(e,t,n,r,i){var o=this;e!==`readonly`&&t.forEach(function(e){e=(e=n[e])?.yProps,e&&(t=t.concat(e.map(function(e){return e.updatesTable})))}),this.db=a,this.mode=e,this.storeNames=t,this.schema=n,this.chromeTransactionDurability=r,this.idbtrans=null,this.on=Dt(this,`complete`,`error`,`abort`),this.parent=i||null,this.active=!0,this._reculock=0,this._blockedFuncs=[],this._resolve=null,this._reject=null,this._waitingFor=null,this._waitingQueue=null,this._spinCount=0,this._completion=new L(function(e,t){o._resolve=e,o._reject=t}),this._completion.then(function(){o.active=!1,o.on.complete.fire()},function(e){var t=o.active;return o.active=!1,o.on.error.fire(e),o.parent?o.parent._reject(e):t&&o.idbtrans&&o.idbtrans.abort(),B(e)})})),this.Version=(o=this,Ot(Sn.prototype,function(e){this.db=o,this._cfg={version:e,storesSource:null,dbschema:{},tables:{},contentUpgrade:null}})),this.WhereClause=(s=this,Ot(Gt.prototype,function(e,t,n){if(this.db=s,this._ctx={table:e,index:t===`:id`?null:t,or:n},this._cmp=this._ascending=V,this._descending=function(e,t){return V(t,e)},this._max=function(e,t){return 0<V(e,t)?e:t},this._min=function(e,t){return V(e,t)<0?e:t},this._IDBKeyRange=s._deps.IDBKeyRange,!this._IDBKeyRange)throw new M.MissingAPI})),this.on(`versionchange`,function(e){0<e.newVersion?console.warn(`Another connection wants to upgrade database '${c.name}'. Closing db now to resume the upgrade.`):console.warn(`Another connection wants to delete database '${c.name}'. Closing db now to resume the delete request.`),c.close({disableAutoOpen:!1})}),this.on(`blocked`,function(e){!e.newVersion||e.newVersion<e.oldVersion?console.warn(`Dexie.delete('${c.name}') was blocked`):console.warn(`Upgrade '${c.name}' blocked by other connection holding version ${e.oldVersion/10}`)}),this._maxKey=rn(n.IDBKeyRange),this._createTransaction=function(e,t,n,r){return new c.Transaction(e,t,n,c._options.chromeTransactionDurability,r)},this._fireOnBlocked=function(e){c.on(`blocked`).fire(e),wn.toArray().filter(function(e){return e.name===c.name&&e!==c&&!e._state.vcFired}).map(function(t){return t.on(`versionchange`).fire(e)})},this.use(Zn),this.use(sr),this.use(er),this.use(Kn),this.use(Yn),new Proxy(this,{get:function(e,t,n){var r;return t===`_vip`||(t===`table`?function(e){return cr(c.table(e),d)}:(r=Reflect.get(e,t,n))instanceof Et?cr(r,d):t===`tables`?r.map(function(e){return cr(e,d)}):t===`_createTransaction`?function(){return cr(r.apply(this,arguments),d)}:r)}}));this.vip=d,l.forEach(function(e){return e(c)})}var ur,Te=typeof Symbol<`u`&&`observable`in Symbol?Symbol.observable:`@@observable`,dr=(fr.prototype.subscribe=function(e,t,n){return this._subscribe(e&&typeof e!=`function`?e:{next:e,error:t,complete:n})},fr.prototype[Te]=function(){return this},fr);function fr(e){this._subscribe=e}try{ur={indexedDB:r.indexedDB||r.mozIndexedDB||r.webkitIndexedDB||r.msIndexedDB,IDBKeyRange:r.IDBKeyRange||r.webkitIDBKeyRange}}catch{ur={indexedDB:null,IDBKeyRange:null}}function pr(e){var t,n=!1,r=new dr(function(r){var i=ae(e),a,o=!1,s={},c={},l={get closed(){return o},unsubscribe:function(){o||(o=!0,a&&a.abort(),u&&Zt.storagemutated.unsubscribe(p))}},u=(r.start&&r.start(l),!1),d=function(){return lt(m)};function f(){return In(c,s)}var p=function(e){Fn(s,e),f()&&d()},m=function(){var l,m,h;!o&&ur.indexedDB&&(s={},l={},a&&a.abort(),a=new AbortController,h=(t=>{var n=Ge();try{i&&nt();var r=tt(e,t);return r=i?r.finally(rt):r}finally{n&&Ke()}})(m={subscr:l,signal:a.signal,requery:d,querier:e,trans:null}),u||=(Zt.storagemutated.subscribe(p),!0),Promise.resolve(h).then(function(e){n=!0,t=e,o||m.signal.aborted||(f()||(c=l,f())?d():(s={},lt(function(){return!o&&r.next&&r.next(e)})))},function(e){n=!1,[`DatabaseClosedError`,`AbortError`].includes(e?.name)||o||lt(function(){o||r.error&&r.error(e)})}))};return setTimeout(d,0),l});return r.hasValue=function(){return n},r.getValue=function(){return t},r}var mr=lr;function hr(e){var t=_r;try{_r=!0,Zt.storagemutated.fire(e),Vn(e,!0)}finally{_r=t}}u(mr,t(t({},T),{delete:function(e){return new mr(e,{addons:[]}).delete()},exists:function(e){return new mr(e,{addons:[]}).open().then(function(e){return e.close(),!0}).catch(`NoSuchDatabaseError`,function(){return!1})},getDatabaseNames:function(e){try{return t=mr.dependencies,n=t.indexedDB,t=t.IDBKeyRange,(En(n)?Promise.resolve(n.databases()).then(function(e){return e.map(function(e){return e.name}).filter(function(e){return e!==pt})}):Tn(n,t).toCollection().primaryKeys()).then(e)}catch{return B(new M.MissingAPI)}var t,n},defineClass:function(){return function(e){o(this,e)}},ignoreTransaction:function(e){return I.trans?st(I.transless||Pe,e):e()},vip:Dn,async:function(e){return function(){try{var t=Wn(e.apply(this,arguments));return t&&typeof t.then==`function`?t:L.resolve(t)}catch(e){return B(e)}}},spawn:function(e,t,n){try{var r=Wn(e.apply(n,t||[]));return r&&typeof r.then==`function`?r:L.resolve(r)}catch(e){return B(e)}},currentTransaction:{get:function(){return I.trans||null}},waitFor:function(e,t){return e=L.resolve(typeof e==`function`?mr.ignoreTransaction(e):e).timeout(t||6e4),I.trans?I.trans.waitFor(e):e},Promise:L,debug:{get:function(){return xe},set:function(e){F(e)}},derive:p,extend:o,props:u,override:_,Events:Dt,on:Zt,liveQuery:pr,extendObservabilitySet:Fn,getByKeyPath:b,setByKeyPath:x,delByKeyPath:function(e,t){typeof t==`string`?x(e,t,void 0):`length`in t&&[].map.call(t,function(t){x(e,t,void 0)})},shallowClone:S,deepClone:O,getObjectDiff:qn,cmp:V,asap:y,minKey:-1/0,addons:[],connections:{get:wn.toArray},errnames:de,dependencies:ur,cache:Ln,semVer:`4.4.4`,version:`4.4.4`.split(`.`).map(function(e){return parseInt(e)}).reduce(function(e,t,n){return e+t/10**(2*n)})})),mr.maxKey=rn(mr.dependencies.IDBKeyRange),typeof dispatchEvent<`u`&&typeof addEventListener<`u`&&(Zt(Yt,function(e){_r||=(e=new CustomEvent(Xt,{detail:e}),_r=!0,dispatchEvent(e),!1)}),addEventListener(Xt,function(e){e=e.detail,_r||hr(e)}));var gr,_r=!1,vr=function(){};return typeof BroadcastChannel<`u`&&((vr=function(){(gr=new BroadcastChannel(Xt)).onmessage=function(e){return e.data&&hr(e.data)}})(),typeof gr.unref==`function`&&gr.unref(),Zt(Yt,function(e){_r||gr.postMessage(e)})),typeof addEventListener<`u`&&(addEventListener(`pagehide`,function(e){if(!lr.disableBfCache&&e.persisted){xe&&console.debug(`Dexie: handling persisted pagehide`),gr?.close();for(var t=0,n=wn.toArray();t<n.length;t++)n[t].close({disableAutoOpen:!1})}}),addEventListener(`pageshow`,function(e){!lr.disableBfCache&&e.persisted&&(xe&&console.debug(`Dexie: handling persisted pageshow`),vr(),hr({all:new K(-1/0,[[]])}))})),L.rejectionMapper=function(e,t){return!e||e instanceof se||e instanceof TypeError||e instanceof SyntaxError||!e.name||!pe[e.name]?e:(t=new pe[e.name](t||e.message,e),`stack`in e&&f(t,`stack`,{get:function(){return this.inner.stack}}),t)},F(xe),t(lr,Object.freeze({__proto__:null,DEFAULT_MAX_CONNECTIONS:1e3,Dexie:lr,Entity:yt,PropModification:Ct,RangeSet:K,add:function(e){return new Ct({add:e})},cmp:V,default:lr,liveQuery:pr,mergeRanges:An,rangesOverlap:jn,remove:function(e){return new Ct({remove:e})},replacePrefix:function(e,t){return new Ct({replacePrefix:[e,t]})}}),{default:lr}),lr})}))(),1),Ss=Symbol.for(`Dexie`),Cs=globalThis[Ss]||(globalThis[Ss]=xs.default);if(xs.default.semVer!==Cs.semVer)throw Error(`Two different versions of Dexie loaded in the same app: ${xs.default.semVer} and ${Cs.semVer}`);var{liveQuery:ws,mergeRanges:Ts,rangesOverlap:Es,RangeSet:Ds,cmp:Os,Entity:ks,PropModification:As,replacePrefix:js,add:Ms,remove:Ns,DexieYProvider:Ps}=Cs,Fs=new class extends Cs{scrollAnchors;toolSessionCollapses;diffCollapses;inputStates;modelOptionsCaches;constructor(){super(`LotusStorage`),this.version(1).stores({scrollAnchors:`sessionId, ts`,toolSessionCollapses:`id, sessionId, updatedAt`,diffCollapses:`sessionId, updatedAt`,inputStates:`sessionId, updatedAt`,modelOptionsCaches:`provider, timestamp`})}},Is=class e{static instance;db=Fs;static getInstance(){return e.instance||=new e,e.instance}async saveScrollAnchor(e,t){try{await this.db.scrollAnchors.put({sessionId:e,anchorId:t.anchorId,offsetPx:t.offsetPx,ts:t.ts,indexHint:t.indexHint,createdAt:t.createdAt})}catch(n){console.warn(`[StorageManager] IndexedDB save failed, falling back to localStorage`,n);try{localStorage.setItem(`chat_scroll_anchor_v2:${e}`,JSON.stringify(t))}catch{}}}async loadScrollAnchor(e){try{let t=await this.db.scrollAnchors.get(e);return t?{v:1,anchorId:t.anchorId,offsetPx:t.offsetPx,ts:t.ts,indexHint:t.indexHint,createdAt:t.createdAt}:null}catch{try{let t=localStorage.getItem(`chat_scroll_anchor_v2:${e}`);if(!t)return null;let n=JSON.parse(t);if(n&&n.v===1&&typeof n.anchorId==`string`)return n}catch{}return null}}async clearScrollAnchor(e){try{await this.db.scrollAnchors.delete(e)}catch{}try{localStorage.removeItem(`chat_scroll_anchor_v2:${e}`)}catch{}}async saveToolSessionCollapse(e,t,n){try{await this.db.toolSessionCollapses.put({id:`${e}:${t}`,sessionId:e,toolSessionId:t,isExpanded:n.isExpanded,expandedTools:n.expandedTools,updatedAt:Date.now()})}catch(r){console.warn(`[StorageManager] saveToolSessionCollapse failed`,r);try{localStorage.setItem(`chat-session-tool-collapse:${e}:${t}`,JSON.stringify(n))}catch{}}}async loadToolSessionCollapse(e,t){try{let n=await this.db.toolSessionCollapses.get(`${e}:${t}`);return n?{isExpanded:n.isExpanded,expandedTools:n.expandedTools}:null}catch{try{let n=localStorage.getItem(`chat-session-tool-collapse:${e}:${t}`);if(!n)return null;let r=JSON.parse(n);if(r&&typeof r.isExpanded==`boolean`)return r}catch{}return null}}async saveDiffCollapse(e,t){try{await this.db.diffCollapses.put({sessionId:e,isExpanded:t.isExpanded,expandedFiles:t.expandedFiles,updatedAt:Date.now()})}catch(n){console.warn(`[StorageManager] saveDiffCollapse failed`,n);try{localStorage.setItem(`chat-session-diff-collapse:${e}`,JSON.stringify(t))}catch{}}}async loadDiffCollapse(e){try{let t=await this.db.diffCollapses.get(e);return t?{isExpanded:t.isExpanded,expandedFiles:t.expandedFiles}:null}catch{try{let t=localStorage.getItem(`chat-session-diff-collapse:${e}`);if(!t)return null;let n=JSON.parse(t);if(n&&typeof n.isExpanded==`boolean`)return n}catch{}return null}}async saveInputReasoning(e,t){try{let n=await this.db.inputStates.get(e);await this.db.inputStates.put({sessionId:e,reasoningEffort:t,content:n?.content,referenceText:n?.referenceText,updatedAt:Date.now()})}catch(n){console.warn(`[StorageManager] saveInputReasoning failed`,n);try{let n=localStorage.getItem(`chat_input_reasoning_by_session_v1`),r=n?JSON.parse(n):{};r[e]=t,localStorage.setItem(`chat_input_reasoning_by_session_v1`,JSON.stringify(r))}catch{}}}async loadInputReasoning(e){try{return(await this.db.inputStates.get(e))?.reasoningEffort??null}catch{try{let t=localStorage.getItem(`chat_input_reasoning_by_session_v1`);return t?JSON.parse(t)[e]??null:null}catch{return null}}}async saveLastUsedReasoningEffort(e){try{await this.db.inputStates.put({sessionId:`__last_used__`,reasoningEffort:e,updatedAt:Date.now()})}catch{try{localStorage.setItem(`chat_input_reasoning_last_used_v1`,e)}catch{}}}async loadLastUsedReasoningEffort(){try{return(await this.db.inputStates.get(`__last_used__`))?.reasoningEffort??null}catch{try{return localStorage.getItem(`chat_input_reasoning_last_used_v1`)}catch{return null}}}async saveModelOptionsCache(e,t,n){try{await this.db.modelOptionsCaches.put({provider:e,options:t,timestamp:n})}catch(r){console.warn(`[StorageManager] saveModelOptionsCache failed`,r);try{localStorage.setItem(`chat-model-options-cache-v1:${e}`,JSON.stringify({timestamp:n,options:t}))}catch{}}}async loadModelOptionsCache(e){try{let t=await this.db.modelOptionsCaches.get(e);return t?{options:t.options,timestamp:t.timestamp}:null}catch{try{let t=localStorage.getItem(`chat-model-options-cache-v1:${e}`);if(!t)return null;let n=JSON.parse(t);if(n&&Array.isArray(n.options))return{options:n.options,timestamp:n.timestamp}}catch{}return null}}async clearSessionData(e){try{await Promise.all([this.db.scrollAnchors.delete(e),this.db.diffCollapses.delete(e),this.db.toolSessionCollapses.where(`sessionId`).equals(e).delete(),this.db.inputStates.delete(e)])}catch{}}async cleanupStaleData(e=30){let t=Date.now()-e*24*60*60*1e3;try{await Promise.all([this.db.scrollAnchors.where(`ts`).below(t).delete(),this.db.toolSessionCollapses.where(`updatedAt`).below(t).delete(),this.db.diffCollapses.where(`updatedAt`).below(t).delete(),this.db.inputStates.where(`updatedAt`).below(t).delete(),this.db.modelOptionsCaches.where(`timestamp`).below(t).delete()])}catch{}}async getStats(){try{let[e,t,n,r,i]=await Promise.all([this.db.scrollAnchors.count(),this.db.toolSessionCollapses.count(),this.db.diffCollapses.count(),this.db.inputStates.count(),this.db.modelOptionsCaches.count()]);return{scrollAnchors:e,toolSessionCollapses:t,diffCollapses:n,inputStates:r,modelOptionsCaches:i}}catch{return{scrollAnchors:0,toolSessionCollapses:0,diffCollapses:0,inputStates:0,modelOptionsCaches:0}}}},Ls=`chat_input_reasoning_by_session_v1`,Rs=`chat_input_reasoning_last_used_v1`,zs={content:``,contentRevision:0,referenceText:null,attachments:[],reasoningEffort:`medium`},Bs=0,Vs=()=>(Bs+=1,Bs),Hs=e=>e===`low`||e===`medium`||e===`high`||e===`xhigh`||e===`max`,Us=()=>{if(typeof window>`u`)return{};try{let e=localStorage.getItem(Ls);if(!e)return{};let t=JSON.parse(e),n={};for(let[e,r]of Object.entries(t||{}))Hs(r)&&(n[e]=r);return n}catch{return{}}},Ws=e=>{if(!(typeof window>`u`))try{localStorage.setItem(Ls,JSON.stringify(e))}catch{}},Gs=()=>{if(!(typeof window>`u`))try{let e=localStorage.getItem(Rs);return Hs(e)?e:void 0}catch{return}},Ks=e=>{if(!(typeof window>`u`))try{localStorage.setItem(Rs,e)}catch{}},qs=e=>{let t=Us();return Hs(t[e])?t[e]:Gs()},Js=e=>({...zs,reasoningEffort:qs(e)??zs.reasoningEffort}),Ys=(e,t)=>({inputStates:{},setInputContent:(t,n)=>e(e=>({inputStates:{...e.inputStates,[t]:{...e.inputStates[t]||Js(t),content:n,contentRevision:Vs()}}})),setInputContentIfRevision:(t,n,r)=>{let i=!1;return e(e=>{let a=e.inputStates[t]||Js(t);return a.contentRevision===n?(i=!0,{inputStates:{...e.inputStates,[t]:{...a,content:r,contentRevision:Vs()}}}):e}),i},moveInputContentIfRevision:(t,n,r)=>{let i=!1;return e(e=>{let a=e.inputStates[t]||Js(t),o=e.inputStates[r]||Js(r);return a.contentRevision!==n||o.content?e:(i=!0,{inputStates:{...e.inputStates,[t]:{...a,content:``,contentRevision:Vs()},[r]:{...o,content:a.content,contentRevision:Vs()}}})}),i},setReferenceText:(t,n)=>e(e=>({inputStates:{...e.inputStates,[t]:{...e.inputStates[t]||Js(t),referenceText:n}}})),setAttachments:(t,n)=>e(e=>({inputStates:{...e.inputStates,[t]:{...e.inputStates[t]||Js(t),attachments:n}}})),setInputReasoningEffort:(t,n)=>{e(e=>({inputStates:{...e.inputStates,[t]:{...e.inputStates[t]||Js(t),reasoningEffort:n}}}));let r=Us();r[t]=n,Ws(r),Ks(n);let i=Is.getInstance();i.saveInputReasoning(t,n).catch(()=>{}),i.saveLastUsedReasoningEffort(n).catch(()=>{})},clearInputState:t=>e(e=>{let{[t]:n,...r}=e.inputStates;return{inputStates:r}}),getInputState:e=>t().inputStates[e]||Js(e)}),Xs=e=>e===`killed`?`killed`:e===`error`?`error`:`completed`,Zs=e=>({backgroundBash:{},setBashCompleted:(t,n,r)=>{if(!t)return;let i=Xs(n);e(e=>{let n=e.backgroundBash[t];return n&&n.status===i&&n.exitCode===r?e:{backgroundBash:{...e.backgroundBash,[t]:{status:i,exitCode:r}}}})}}),Qs=(e,t)=>{let n=new Map,r=0,i=e=>t().chats.find(t=>t.id===e),a=(e,r)=>n.get(e)===r&&t().permissionModeRequests[e]?.operationId===r.id&&!!i(e),o=(t,n,r,i)=>{a(t,n)&&e(e=>({permissionModeRequests:{...e.permissionModeRequests,[t]:{status:r,operationId:n.id,error:i}}}))},s=(t,i)=>{let a={id:++r};return n.set(t,a),e(e=>({permissionModeRequests:{...e.permissionModeRequests,[t]:{status:i,operationId:a.id}}})),a},c=(t,n,r,s,c=`ready`)=>{if(!a(t,n))return!1;let l=i(t),u=Gn(l.config.permissionModeEtag),d=Gn(r.etag);return r.sessionId!==t||!Wn(r.mode)||d===null||u!==null&&(d<u||d===u&&l.config.permissionMode!==r.mode)?(o(t,n,`unconfirmed`,`stale`),!1):(e(e=>({chats:e.chats.map(e=>e.id===t?{...e,config:{...e.config,permissionMode:r.mode,permissionModeEtag:r.etag,bypassPermissions:r.mode!=="default"}}:e),permissionModeRequests:{...e.permissionModeRequests,[t]:{status:c===`ready`&&n.reconcileRequested?`loading`:c,operationId:n.id,error:s}}})),!0)},l=async(e,r)=>{for(;a(e,r)&&r.reconcileRequested;){r.reconcileRequested=!1;let n=t().permissionModeRequests[e]?.error;o(e,r,`loading`,n);try{c(e,r,await or.getSessionPermissionMode(e),n)}catch(t){let n=t instanceof Kn;o(e,r,n?`unsupported`:`unconfirmed`,n?`unsupported`:`unconfirmed`)}}n.get(e)===r&&n.delete(e)};return{permissionModeRequests:{},refreshSessionPermissionMode:e=>{let t=n.get(e);if(t)return t.promise??Promise.resolve();if(!i(e))return Promise.resolve();let r=s(e,`loading`);return r.promise=(async()=>{try{c(e,r,await or.getSessionPermissionMode(e))}catch(t){let n=t instanceof Kn;o(e,r,n?`unsupported`:`unconfirmed`,n?`unsupported`:`unconfirmed`)}})().finally(()=>l(e,r)),r.promise},changeSessionPermissionMode:(r,u,d)=>{let f=i(r),p=t().permissionModeRequests[r];if(n.has(r)||!f||p?.status!==`ready`||!Wn(u)||Gn(d)===null)return Promise.resolve();if(f.config.permissionModeEtag!==d)return e(e=>({permissionModeRequests:{...e.permissionModeRequests,[r]:{...p,error:`changed`}}})),Promise.resolve();if(f.config.permissionMode===u)return Promise.resolve();let m=f.config.permissionMode,h=s(r,`saving`);return h.promise=(async()=>{let e;try{e=await or.getSessionPermissionMode(r)}catch(e){let t=e instanceof Kn;o(r,h,t?`unsupported`:`unconfirmed`,t?`unsupported`:`unconfirmed`);return}let t=e.mode!==m;if(!(!c(r,h,e,t?`changed`:void 0,t?`ready`:`saving`)||t))try{let t=await or.patchSessionPermissionMode(r,u,e.etag);c(r,h,t,t.mode===u?void 0:`changed`)}catch(e){if(!a(r,h))return;let t=Ee(e)&&e.status===412?`conflict`:Ee(e)&&e.status<500?`rejected`:`ambiguous`;try{h.reconcileRequested=!1,c(r,h,await or.getSessionPermissionMode(r),t)}catch{o(r,h,`unconfirmed`,`unconfirmed`)}}})().finally(()=>l(r,h)),h.promise},reconcileSessionPermissionModes:e=>{let r=new Set(t().chats.map(e=>e.id));t().resetSessionPermissionModes(Object.keys(t().permissionModeRequests).filter(e=>!r.has(e)));for(let r of e){let e=t().permissionModeRequests[r.id],a=i(r.id);if(!e||!a)continue;let o=Wn(r.permission_mode)!==a.config.permissionMode,s=n.get(r.id);if(s){(o||!a.config.permissionModeEtag)&&(s.reconcileRequested=!0);continue}(e.status!==`ready`||!a.config.permissionModeEtag||o)&&t().refreshSessionPermissionMode(r.id)}},resetSessionPermissionModes:r=>{let i=r??[...new Set([...n.keys(),...Object.keys(t().permissionModeRequests)])];if(i.length!==0){for(let e of i)n.delete(e);e(e=>{let t={...e.permissionModeRequests};for(let e of i)delete t[e];return{permissionModeRequests:t}})}}}},$s=`lotus_notify_enabled_v1`;function ec(){try{return localStorage.getItem($s)===`1`}catch{return!1}}function tc(e){try{localStorage.setItem($s,e?`1`:`0`)}catch{}}function nc(){return typeof Notification>`u`?`unsupported`:Notification.permission}async function rc(){if(typeof Notification>`u`)return!1;if(Notification.permission===`granted`)return!0;try{return await Notification.requestPermission()===`granted`}catch{return!1}}function ic(e,t){if(ec()&&!(typeof Notification>`u`||Notification.permission!==`granted`))try{new Notification(e,{body:t,icon:`/vite.svg`})}catch{}}var ac=`lotus_account_feed_cursor_v1`,oc=400,sc=/^[1-9][0-9]*$/,cc=null,lc=null,uc=()=>cc!==null&&!mn(),dc=e=>{if(!e||!sc.test(e))return 0;let t=Number(e);return Number.isSafeInteger(t)&&t>0&&String(t)===e?t:0},fc=()=>{try{return dc(localStorage.getItem(ac))}catch{return 0}},pc=e=>{if(!(!Number.isSafeInteger(e)||e<=0))try{if(e<=dc(localStorage.getItem(ac)))return;localStorage.setItem(ac,String(e))}catch{}},mc=()=>{try{localStorage.removeItem(ac)}catch{}},hc=()=>{lc&&=(clearTimeout(lc),null)},gc=()=>{try{Lc.getState().refreshChatsNow().catch(e=>console.warn(`[AccountFeed] Failed to resync sessions after reset:`,e))}catch(e){console.warn(`[AccountFeed] Failed to resync sessions after reset:`,e)}},_c=()=>{lc||=setTimeout(()=>{lc=null,Lc.getState().refreshSessionsIndex()},oc)},vc=new Set([`message_appended`,`task_list_updated`,`task_list_item_progress`,`task_list_completed`,`complete`,`cancelled`,`error`,`execution_started`,`need_clarification`]),yc=e=>{let{event:t}=e,n=Lc.getState(),r=e.session_id??t.session_id;if(t.type===`notification`){let e=t;(typeof document>`u`||document.hidden||r!==n.currentSessionId)&&ic(e.title||`Bodhi`,e.body);return}switch(r&&r===n.currentSessionId&&vc.has(t.type)&&n.reconcileOpenSession(r,t.type),r&&r===n.currentSessionId&&t.type===`execution_started`&&!Tc(r)(n)&&n.refreshChatsNow(),t.type){case`session_title_updated`:r&&typeof t.title==`string`&&n.applyServerTitle(r,t.title,t.title_version??0),_c();break;case`session_pinned_updated`:r&&typeof t.pinned==`boolean`&&n.applyServerPinned(r,t.pinned,t.updated_at??e.ts),_c();break;default:_c();break}},bc=()=>{if(cc||typeof WebSocket>`u`)return;let e=ar.getInstance();fn(()=>{let e=Lc.getState();e.refreshChatsNow();let t=e.currentSessionId;t&&e.reconcileOpenSession(t,`ws_reconnected`)}),cc=e.subscribeToAccountStream({onOpen:()=>{Lc.getState().setAgentAvailability(!0)},onError:()=>{Lc.getState().setAgentAvailability(!1)},onReset:()=>{mc(),hc(),gc()},onChange:e=>{Lc.getState().setAgentAvailability(!0),yc(e),pc(e.seq)}},{since:fc()})},xc=`bamboo_proxy_auth`,Sc=()=>{try{let e=localStorage.getItem(xc);if(!e)return null;let t=JSON.parse(e);if(!t||typeof t!=`object`)return null;let n=typeof t.username==`string`?t.username.trim():``,r=typeof t.password==`string`?t.password:``;return n?{username:n,password:r}:null}catch{return null}},Cc={byId:{},runningCount:0},wc=(e,t)=>t?e.executionBySession[t]??null:null,Tc=e=>t=>{let n=wc(t,e);return Ar(n?.phase)?n?.phase!==`waiting_user_answer`:!1},Ec=e=>t=>wc(t,e)?.children.byId??Cc.byId;Object.freeze({state:`idle`,activeToolCalls:[],runningChildCount:0,hasQuestion:!1,hasError:!1,errorMessage:null,generation:0});var Dc=`auto`,Oc=`required`,kc=1e4,Ac=15e3,jc=ar.getInstance(),Mc=null,Nc=null,Pc=null,Fc=null,Ic=new WeakMap,Lc=se()(me(ge((e,t,n)=>({...No(e,t,n),...qo(e,t,n),...ps(e,t,n),...hs(e,t,n),..._s(e,t,n),...vs(e,t,n),...bs(e,t,n),...Ys(e,t,n),...ri(e,t,n),...Zs(e,t,n),...Qs(e,t,n),agentAvailability:null,setAgentAvailability:t=>{e({agentAvailability:t})},checkAgentAvailability:async()=>{if(Nc)return Nc;Nc=(async()=>{let n=await jc.healthCheck();return!(n&&uc()&&t().agentAvailability!==null)&&t().agentAvailability!==n&&e({agentAvailability:n}),n})();try{return await Nc}finally{Nc=null}},startAgentHealthCheck:()=>{Mc||=(t().checkAgentAvailability(),setInterval(()=>{t().checkAgentAvailability()},kc))},refreshSessionsIndex:async()=>{if(Fc)return Fc;Fc=(async()=>{try{await t().refreshChats()}catch(e){console.warn(`[AppStore] refreshChats failed:`,e)}})();try{return await Fc}finally{Fc=null}},startSessionsIndexSync:()=>{Pc||=(t().refreshSessionsIndex(),setInterval(()=>{t().refreshSessionsIndex()},Ac))}})),{name:`AppStore`})),Rc=e=>{let t=Ic.get(e);if(t)return t;let n=new Map(e.map(e=>[e.id,e]));return Ic.set(e,n),n},zc=e=>t=>e?Rc(t.chats).get(e)??null:null,Bc=e=>e.currentSessionId?Rc(e.chats).get(e.currentSessionId)??null:null,Vc=e=>Lc(t=>t.backgroundBash[e]),Hc=async()=>{let e=Sc();if(!e)return!1;try{return await Vo.setProxyAuth(e),!0}catch(e){return console.error(`Failed to apply stored proxy auth during startup:`,e),!1}},Uc=async()=>{try{let e=await Go.getState().loadConfig();return(typeof e?.proxy_auth_mode==`string`?e.proxy_auth_mode:Dc)===Oc?(await Go.getState().loadProxyAuthStatus({force:!0}))?.configured||await Hc()?!1:(Lc.setState(e=>({...e,models:[],selectedModel:void 0,modelsError:`Proxy auth mode is set to required. Please configure proxy username/password and apply it.`,isLoadingModels:!1})),!0):(await Hc(),!1)}catch(e){return console.error(`Failed to evaluate startup proxy auth mode:`,e),!1}},Wc=!1,Gc=!1,Kc=null,qc=async(e=!1)=>{if(!(Wc&&!e)){if(Wc=!0,bc(),Lc.getState().startAgentHealthCheck(),Lc.getState().startSessionsIndexSync(),!(typeof globalThis<`u`&&`__vitest_worker__`in globalThis))try{await Er.getState().loadProviderInstances()}catch{}await Lc.getState().loadChats(),Gc=!0}},Jc=async()=>{if(Gc)return Kc||(Kc=(async()=>{try{await Uc()||await Lc.getState().fetchModels(),await Lc.getState().loadSystemPrompts()}catch(e){console.error(`[AppStore] Deferred bootstrap failed:`,e)}})(),Kc)},Yc=async(e=!1)=>{await qc(e),Jc().catch(e=>{console.error(`[AppStore] Deferred bootstrap error:`,e)})};typeof window<`u`&&window.document&&window.document.createElement;function Q(e,t,{checkForDefaultPrevented:n=!0}={}){return function(r){if(e?.(r),n===!1||!r.defaultPrevented)return t?.(r)}}function Xc(e,t=[]){let n=[];function r(t,r){let i=D.createContext(r);i.displayName=t+`Context`;let a=n.length;n=[...n,r];let o=t=>{let{scope:n,children:r,...o}=t,s=n?.[e]?.[a]||i,c=D.useMemo(()=>o,Object.values(o));return(0,F.jsx)(s.Provider,{value:c,children:r})};o.displayName=t+`Provider`;function s(n,o){let s=o?.[e]?.[a]||i,c=D.useContext(s);if(c)return c;if(r!==void 0)return r;throw Error(`\`${n}\` must be used within \`${t}\``)}return[o,s]}let i=()=>{let t=n.map(e=>D.createContext(e));return function(n){let r=n?.[e]||t;return D.useMemo(()=>({[`__scope${e}`]:{...n,[e]:r}}),[n,r])}};return i.scopeName=e,[r,Zc(i,...t)]}function Zc(...e){let t=e[0];if(e.length===1)return t;let n=()=>{let n=e.map(e=>({useScope:e(),scopeName:e.scopeName}));return function(e){let r=n.reduce((t,{useScope:n,scopeName:r})=>{let i=n(e)[`__scope${r}`];return{...t,...i}},{});return D.useMemo(()=>({[`__scope${t.scopeName}`]:r}),[r])}};return n.scopeName=t.scopeName,n}var Qc=globalThis?.document?D.useLayoutEffect:()=>{},$c=D.useId||(()=>void 0),el=0;function tl(e){let[t,n]=D.useState($c());return Qc(()=>{e||n(e=>e??String(el++))},[e]),e||(t?`radix-${t}`:``)}var nl=D.useInsertionEffect||Qc;function rl({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){let[i,a,o]=il({defaultProp:t,onChange:n}),s=e!==void 0,c=s?e:i;{let t=D.useRef(e!==void 0);D.useEffect(()=>{let e=t.current;e!==s&&console.warn(`${r} is changing from ${e?`controlled`:`uncontrolled`} to ${s?`controlled`:`uncontrolled`}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),t.current=s},[s,r])}return[c,D.useCallback(t=>{if(s){let n=al(t)?t(e):t;n!==e&&o.current?.(n)}else a(t)},[s,e,a,o])]}function il({defaultProp:e,onChange:t}){let[n,r]=D.useState(e),i=D.useRef(n),a=D.useRef(t);return nl(()=>{a.current=t},[t]),D.useEffect(()=>{i.current!==n&&(a.current?.(n),i.current=n)},[n,i]),[n,r,a]}function al(e){return typeof e==`function`}var $=[`a`,`button`,`div`,`form`,`h2`,`h3`,`img`,`input`,`label`,`li`,`nav`,`ol`,`p`,`select`,`span`,`svg`,`ul`].reduce((e,t)=>{let n=f(`Primitive.${t}`),r=D.forwardRef((e,r)=>{let{asChild:i,...a}=e,o=i?n:t;return typeof window<`u`&&(window[Symbol.for(`radix-ui`)]=!0),(0,F.jsx)(o,{...a,ref:r})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function ol(e,t){e&&xe.flushSync(()=>e.dispatchEvent(t))}function sl(e){let t=D.useRef(e);return D.useEffect(()=>{t.current=e}),D.useMemo(()=>((...e)=>t.current?.(...e)),[])}function cl(e,t=globalThis?.document){let n=sl(e);D.useEffect(()=>{let e=e=>{e.key===`Escape`&&n(e)};return t.addEventListener(`keydown`,e,{capture:!0}),()=>t.removeEventListener(`keydown`,e,{capture:!0})},[n,t])}var ll=`DismissableLayer`,ul=`dismissableLayer.update`,dl=`dismissableLayer.pointerDownOutside`,fl=`dismissableLayer.focusOutside`,pl,ml=D.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set,dismissableSurfaces:new Set}),hl=D.forwardRef((e,t)=>{let{disableOutsidePointerEvents:n=!1,deferPointerDownOutside:r=!1,onEscapeKeyDown:i,onPointerDownOutside:a,onFocusOutside:o,onInteractOutside:s,onDismiss:c,...l}=e,d=D.useContext(ml),[f,p]=D.useState(null),m=f?.ownerDocument??globalThis?.document,[,h]=D.useState({}),g=u(t,e=>p(e)),_=Array.from(d.layers),[v]=[...d.layersWithOutsidePointerEventsDisabled].slice(-1),y=_.indexOf(v),b=f?_.indexOf(f):-1,x=d.layersWithOutsidePointerEventsDisabled.size>0,S=b>=y,C=D.useRef(!1),w=yl(e=>{let t=e.target;if(!(t instanceof Node))return;let n=[...d.branches].some(e=>e.contains(t));!S||n||(a?.(e),s?.(e),e.defaultPrevented||c?.())},{ownerDocument:m,deferPointerDownOutside:r,isDeferredPointerDownOutsideRef:C,dismissableSurfaces:d.dismissableSurfaces}),T=bl(e=>{if(r&&C.current)return;let t=e.target;[...d.branches].some(e=>e.contains(t))||(o?.(e),s?.(e),e.defaultPrevented||c?.())},m);return cl(e=>{b===d.layers.size-1&&(i?.(e),!e.defaultPrevented&&c&&(e.preventDefault(),c()))},m),D.useEffect(()=>{if(f)return n&&(d.layersWithOutsidePointerEventsDisabled.size===0&&(pl=m.body.style.pointerEvents,m.body.style.pointerEvents=`none`),d.layersWithOutsidePointerEventsDisabled.add(f)),d.layers.add(f),xl(),()=>{n&&(d.layersWithOutsidePointerEventsDisabled.delete(f),d.layersWithOutsidePointerEventsDisabled.size===0&&(m.body.style.pointerEvents=pl))}},[f,m,n,d]),D.useEffect(()=>()=>{f&&(d.layers.delete(f),d.layersWithOutsidePointerEventsDisabled.delete(f),xl())},[f,d]),D.useEffect(()=>{let e=()=>h({});return document.addEventListener(ul,e),()=>document.removeEventListener(ul,e)},[]),(0,F.jsx)($.div,{...l,ref:g,style:{pointerEvents:x?S?`auto`:`none`:void 0,...e.style},onFocusCapture:Q(e.onFocusCapture,T.onFocusCapture),onBlurCapture:Q(e.onBlurCapture,T.onBlurCapture),onPointerDownCapture:Q(e.onPointerDownCapture,w.onPointerDownCapture)})});hl.displayName=ll;var gl=`DismissableLayerBranch`,_l=D.forwardRef((e,t)=>{let n=D.useContext(ml),r=D.useRef(null),i=u(t,r);return D.useEffect(()=>{let e=r.current;if(e)return n.branches.add(e),()=>{n.branches.delete(e)}},[n.branches]),(0,F.jsx)($.div,{...e,ref:i})});_l.displayName=gl;function vl(){let e=D.useContext(ml),[t,n]=D.useState(null);return D.useEffect(()=>{if(t)return e.dismissableSurfaces.add(t),()=>{e.dismissableSurfaces.delete(t)}},[t,e.dismissableSurfaces]),n}function yl(e,t){let{ownerDocument:n=globalThis?.document,deferPointerDownOutside:r=!1,isDeferredPointerDownOutsideRef:i,dismissableSurfaces:a}=t,o=sl(e),s=D.useRef(!1),c=D.useRef(!1),l=D.useRef(new Map),u=D.useRef(()=>{});return D.useEffect(()=>{function e(){c.current=!1,i.current=!1,l.current.clear()}function t(){return Array.from(l.current.values()).some(Boolean)}function d(e){if(!c.current)return;let t=e.target;t instanceof Node&&[...a].some(e=>e.contains(t))||l.current.set(e.type,!0),e.type===`click`&&window.setTimeout(()=>{c.current&&u.current()},0)}function f(e){c.current&&l.current.set(e.type,!1)}let p=a=>{if(a.target&&!s.current){let s=function(){n.removeEventListener(`click`,u.current);let r=t();e(),r||Sl(dl,o,d,{discrete:!0})},d={originalEvent:a};c.current=!0,i.current=r&&a.button===0,l.current.clear(),!r||a.button!==0?s():(n.removeEventListener(`click`,u.current),u.current=s,n.addEventListener(`click`,u.current,{once:!0}))}else n.removeEventListener(`click`,u.current),e();s.current=!1},m=[`pointerup`,`mousedown`,`mouseup`,`touchstart`,`touchend`,`click`];for(let e of m)n.addEventListener(e,d,!0),n.addEventListener(e,f);let h=window.setTimeout(()=>{n.addEventListener(`pointerdown`,p)},0);return()=>{window.clearTimeout(h),n.removeEventListener(`pointerdown`,p),n.removeEventListener(`click`,u.current);for(let e of m)n.removeEventListener(e,d,!0),n.removeEventListener(e,f)}},[n,o,r,i,a]),{onPointerDownCapture:()=>s.current=!0}}function bl(e,t=globalThis?.document){let n=sl(e),r=D.useRef(!1);return D.useEffect(()=>{let e=e=>{e.target&&!r.current&&Sl(fl,n,{originalEvent:e},{discrete:!1})};return t.addEventListener(`focusin`,e),()=>t.removeEventListener(`focusin`,e)},[t,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function xl(){let e=new CustomEvent(ul);document.dispatchEvent(e)}function Sl(e,t,n,{discrete:r}){let i=n.originalEvent.target,a=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&i.addEventListener(e,t,{once:!0}),r?ol(i,a):i.dispatchEvent(a)}var Cl=`focusScope.autoFocusOnMount`,wl=`focusScope.autoFocusOnUnmount`,Tl={bubbles:!1,cancelable:!0},El=`FocusScope`,Dl=D.forwardRef((e,t)=>{let{loop:n=!1,trapped:r=!1,onMountAutoFocus:i,onUnmountAutoFocus:a,...o}=e,[s,c]=D.useState(null),l=sl(i),d=sl(a),f=D.useRef(null),p=u(t,e=>c(e)),m=D.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;D.useEffect(()=>{if(r){let e=function(e){if(m.paused||!s)return;let t=e.target;s.contains(t)?f.current=t:Pl(f.current,{select:!0})},t=function(e){if(m.paused||!s)return;let t=e.relatedTarget;t!==null&&(s.contains(t)||Pl(f.current,{select:!0}))},n=function(e){if(document.activeElement===document.body)for(let t of e)t.removedNodes.length>0&&Pl(s)};document.addEventListener(`focusin`,e),document.addEventListener(`focusout`,t);let r=new MutationObserver(n);return s&&r.observe(s,{childList:!0,subtree:!0}),()=>{document.removeEventListener(`focusin`,e),document.removeEventListener(`focusout`,t),r.disconnect()}}},[r,s,m.paused]),D.useEffect(()=>{if(s){Fl.add(m);let e=document.activeElement;if(!s.contains(e)){let t=new CustomEvent(Cl,Tl);s.addEventListener(Cl,l),s.dispatchEvent(t),t.defaultPrevented||(Ol(Rl(Al(s)),{select:!0}),document.activeElement===e&&Pl(s))}return()=>{s.removeEventListener(Cl,l),setTimeout(()=>{let t=new CustomEvent(wl,Tl);s.addEventListener(wl,d),s.dispatchEvent(t),t.defaultPrevented||Pl(e??document.body,{select:!0}),s.removeEventListener(wl,d),Fl.remove(m)},0)}}},[s,l,d,m]);let h=D.useCallback(e=>{if(!n&&!r||m.paused)return;let t=e.key===`Tab`&&!e.altKey&&!e.ctrlKey&&!e.metaKey,i=document.activeElement;if(t&&i){let t=e.currentTarget,[r,a]=kl(t);r&&a?!e.shiftKey&&i===a?(e.preventDefault(),n&&Pl(r,{select:!0})):e.shiftKey&&i===r&&(e.preventDefault(),n&&Pl(a,{select:!0})):i===t&&e.preventDefault()}},[n,r,m.paused]);return(0,F.jsx)($.div,{tabIndex:-1,...o,ref:p,onKeyDown:h})});Dl.displayName=El;function Ol(e,{select:t=!1}={}){let n=document.activeElement;for(let r of e)if(Pl(r,{select:t}),document.activeElement!==n)return}function kl(e){let t=Al(e);return[jl(t,e),jl(t.reverse(),e)]}function Al(e){let t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:e=>{let t=e.tagName===`INPUT`&&e.type===`hidden`;return e.disabled||e.hidden||t?NodeFilter.FILTER_SKIP:e.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function jl(e,t){for(let n of e)if(!Ml(n,{upTo:t}))return n}function Ml(e,{upTo:t}){if(getComputedStyle(e).visibility===`hidden`)return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display===`none`)return!0;e=e.parentElement}return!1}function Nl(e){return e instanceof HTMLInputElement&&`select`in e}function Pl(e,{select:t=!1}={}){if(e&&e.focus){let n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&Nl(e)&&t&&e.select()}}var Fl=Il();function Il(){let e=[];return{add(t){let n=e[0];t!==n&&n?.pause(),e=Ll(e,t),e.unshift(t)},remove(t){e=Ll(e,t),e[0]?.resume()}}}function Ll(e,t){let n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function Rl(e){return e.filter(e=>e.tagName!==`A`)}var zl=`Portal`,Bl=D.forwardRef((e,t)=>{let{container:n,...r}=e,[i,a]=D.useState(!1);Qc(()=>a(!0),[]);let o=n||i&&globalThis?.document?.body;return o?xe.createPortal((0,F.jsx)($.div,{...r,ref:t}),o):null});Bl.displayName=zl;function Vl(e,t){return D.useReducer((e,n)=>t[e][n]??e,e)}var Hl=e=>{let{present:t,children:n}=e,r=Ul(t),i=typeof n==`function`?n({present:r.isPresent}):D.Children.only(n),a=Gl(r.ref,ql(i));return typeof n==`function`||r.isPresent?D.cloneElement(i,{ref:a}):null};Hl.displayName=`Presence`;function Ul(e){let[t,n]=D.useState(),r=D.useRef(null),i=D.useRef(e),a=D.useRef(`none`),[o,s]=Vl(e?`mounted`:`unmounted`,{mounted:{UNMOUNT:`unmounted`,ANIMATION_OUT:`unmountSuspended`},unmountSuspended:{MOUNT:`mounted`,ANIMATION_END:`unmounted`},unmounted:{MOUNT:`mounted`}});return D.useEffect(()=>{let e=Kl(r.current);a.current=o===`mounted`?e:`none`},[o]),Qc(()=>{let t=r.current,n=i.current;if(n!==e){let r=a.current,o=Kl(t);e?s(`MOUNT`):o===`none`||t?.display===`none`?s(`UNMOUNT`):s(n&&r!==o?`ANIMATION_OUT`:`UNMOUNT`),i.current=e}},[e,s]),Qc(()=>{if(t){let e,n=t.ownerDocument.defaultView??window,o=a=>{let o=Kl(r.current).includes(CSS.escape(a.animationName));if(a.target===t&&o&&(s(`ANIMATION_END`),!i.current)){let r=t.style.animationFillMode;t.style.animationFillMode=`forwards`,e=n.setTimeout(()=>{t.style.animationFillMode===`forwards`&&(t.style.animationFillMode=r)})}},c=e=>{e.target===t&&(a.current=Kl(r.current))};return t.addEventListener(`animationstart`,c),t.addEventListener(`animationcancel`,o),t.addEventListener(`animationend`,o),()=>{n.clearTimeout(e),t.removeEventListener(`animationstart`,c),t.removeEventListener(`animationcancel`,o),t.removeEventListener(`animationend`,o)}}else s(`ANIMATION_END`)},[t,s]),{isPresent:[`mounted`,`unmountSuspended`].includes(o),ref:D.useCallback(e=>{r.current=e?getComputedStyle(e):null,n(e)},[])}}function Wl(e,t){if(typeof e==`function`)return e(t);e!=null&&(e.current=t)}function Gl(...e){let t=D.useRef(e);return t.current=e,D.useCallback(e=>{let n=t.current,r=!1,i=n.map(t=>{let n=Wl(t,e);return!r&&typeof n==`function`&&(r=!0),n});if(r)return()=>{for(let e=0;e<i.length;e++){let t=i[e];typeof t==`function`?t():Wl(n[e],null)}}},[])}function Kl(e){return e?.animationName||`none`}function ql(e){let t=Object.getOwnPropertyDescriptor(e.props,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var Jl=0,Yl=null;function Xl(){D.useEffect(()=>{Yl||={start:Zl(),end:Zl()};let{start:e,end:t}=Yl;return document.body.firstElementChild!==e&&document.body.insertAdjacentElement(`afterbegin`,e),document.body.lastElementChild!==t&&document.body.insertAdjacentElement(`beforeend`,t),Jl++,()=>{Jl===1&&(Yl?.start.remove(),Yl?.end.remove(),Yl=null),Jl=Math.max(0,Jl-1)}},[])}function Zl(){let e=document.createElement(`span`);return e.setAttribute(`data-radix-focus-guard`,``),e.tabIndex=0,e.style.outline=`none`,e.style.opacity=`0`,e.style.position=`fixed`,e.style.pointerEvents=`none`,e}var Ql=function(){return Ql=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n],t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},Ql.apply(this,arguments)};function $l(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols==`function`)for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n}function eu(e,t,n){if(n||arguments.length===2)for(var r=0,i=t.length,a;r<i;r++)(a||!(r in t))&&(a||=Array.prototype.slice.call(t,0,r),a[r]=t[r]);return e.concat(a||Array.prototype.slice.call(t))}var tu=`right-scroll-bar-position`,nu=`width-before-scroll-bar`,ru=`with-scroll-bars-hidden`,iu=`--removed-body-scroll-bar-size`;function au(e,t){return typeof e==`function`?e(t):e&&(e.current=t),e}function ou(e,t){var n=(0,D.useState)(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(e){var t=n.value;t!==e&&(n.value=e,n.callback(e,t))}}}})[0];return n.callback=t,n.facade}var su=typeof window<`u`?D.useLayoutEffect:D.useEffect,cu=new WeakMap;function lu(e,t){var n=ou(t||null,function(t){return e.forEach(function(e){return au(e,t)})});return su(function(){var t=cu.get(n);if(t){var r=new Set(t),i=new Set(e),a=n.current;r.forEach(function(e){i.has(e)||au(e,null)}),i.forEach(function(e){r.has(e)||au(e,a)})}cu.set(n,e)},[e]),n}function uu(e){return e}function du(e,t){t===void 0&&(t=uu);var n=[],r=!1;return{read:function(){if(r)throw Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(e){var i=t(e,r);return n.push(i),function(){n=n.filter(function(e){return e!==i})}},assignSyncMedium:function(e){for(r=!0;n.length;){var t=n;n=[],t.forEach(e)}n={push:function(t){return e(t)},filter:function(){return n}}},assignMedium:function(e){r=!0;var t=[];if(n.length){var i=n;n=[],i.forEach(e),t=n}var a=function(){var n=t;t=[],n.forEach(e)},o=function(){return Promise.resolve().then(a)};o(),n={push:function(e){t.push(e),o()},filter:function(e){return t=t.filter(e),n}}}}}function fu(e){e===void 0&&(e={});var t=du(null);return t.options=Ql({async:!0,ssr:!1},e),t}var pu=function(e){var t=e.sideCar,n=$l(e,[`sideCar`]);if(!t)throw Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw Error(`Sidecar medium not found`);return D.createElement(r,Ql({},n))};pu.isSideCarExport=!0;function mu(e,t){return e.useMedium(t),pu}var hu=fu(),gu=function(){},_u=D.forwardRef(function(e,t){var n=D.useRef(null),r=D.useState({onScrollCapture:gu,onWheelCapture:gu,onTouchMoveCapture:gu}),i=r[0],a=r[1],o=e.forwardProps,s=e.children,c=e.className,l=e.removeScrollBar,u=e.enabled,d=e.shards,f=e.sideCar,p=e.noRelative,m=e.noIsolation,h=e.inert,g=e.allowPinchZoom,_=e.as,v=_===void 0?`div`:_,y=e.gapMode,b=$l(e,[`forwardProps`,`children`,`className`,`removeScrollBar`,`enabled`,`shards`,`sideCar`,`noRelative`,`noIsolation`,`inert`,`allowPinchZoom`,`as`,`gapMode`]),x=f,S=lu([n,t]),C=Ql(Ql({},b),i);return D.createElement(D.Fragment,null,u&&D.createElement(x,{sideCar:hu,removeScrollBar:l,shards:d,noRelative:p,noIsolation:m,inert:h,setCallbacks:a,allowPinchZoom:!!g,lockRef:n,gapMode:y}),o?D.cloneElement(D.Children.only(s),Ql(Ql({},C),{ref:S})):D.createElement(v,Ql({},C,{className:c,ref:S}),s))});_u.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},_u.classNames={fullWidth:nu,zeroRight:tu};var vu,yu=function(){if(vu)return vu;if(typeof __webpack_nonce__<`u`)return __webpack_nonce__};function bu(){if(!document)return null;var e=document.createElement(`style`);e.type=`text/css`;var t=yu();return t&&e.setAttribute(`nonce`,t),e}function xu(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function Su(e){(document.head||document.getElementsByTagName(`head`)[0]).appendChild(e)}var Cu=function(){var e=0,t=null;return{add:function(n){e==0&&(t=bu())&&(xu(t,n),Su(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},wu=function(){var e=Cu();return function(t,n){D.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},Tu=function(){var e=wu();return function(t){var n=t.styles,r=t.dynamic;return e(n,r),null}},Eu={left:0,top:0,right:0,gap:0},Du=function(e){return parseInt(e||``,10)||0},Ou=function(e){var t=window.getComputedStyle(document.body),n=t[e===`padding`?`paddingLeft`:`marginLeft`],r=t[e===`padding`?`paddingTop`:`marginTop`],i=t[e===`padding`?`paddingRight`:`marginRight`];return[Du(n),Du(r),Du(i)]},ku=function(e){if(e===void 0&&(e=`margin`),typeof window>`u`)return Eu;var t=Ou(e),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-n+t[2]-t[0])}},Au=Tu(),ju=`data-scroll-locked`,Mu=function(e,t,n,r){var i=e.left,a=e.top,o=e.right,s=e.gap;return n===void 0&&(n=`margin`),`
|
|
19
|
-
.${
|
|
18
|
+
`+r:``}`,this.inner=r||null):typeof e==`object`&&(this.message=`${e.name} ${e.message}`,this.inner=e):(this.message=oe[t]||n,this.inner=null)}return p(r).from(fe),e[t]=r,e},{}),pe=(M.Syntax=SyntaxError,M.Type=TypeError,M.Range=RangeError,T.reduce(function(e,t){return e[t+`Error`]=M[t],e},{}));T=j.reduce(function(e,t){return[`Syntax`,`Type`,`Range`].indexOf(t)===-1&&(e[t+`Error`]=M[t]),e},{});function N(){}function me(e){return e}function he(e,t){return e==null||e===me?t:function(n){return t(e(n))}}function ge(e,t){return function(){e.apply(this,arguments),t.apply(this,arguments)}}function _e(e,t){return e===N?t:function(){var n=e.apply(this,arguments),r=(n!==void 0&&(arguments[0]=n),this.onsuccess),i=this.onerror,a=(this.onsuccess=null,this.onerror=null,t.apply(this,arguments));return r&&(this.onsuccess=this.onsuccess?ge(r,this.onsuccess):r),i&&(this.onerror=this.onerror?ge(i,this.onerror):i),a===void 0?n:a}}function ve(e,t){return e===N?t:function(){e.apply(this,arguments);var n=this.onsuccess,r=this.onerror;this.onsuccess=this.onerror=null,t.apply(this,arguments),n&&(this.onsuccess=this.onsuccess?ge(n,this.onsuccess):n),r&&(this.onerror=this.onerror?ge(r,this.onerror):r)}}function P(e,t){return e===N?t:function(n){var r=e.apply(this,arguments),n=(o(n,r),this.onsuccess),i=this.onerror,a=(this.onsuccess=null,this.onerror=null,t.apply(this,arguments));return n&&(this.onsuccess=this.onsuccess?ge(n,this.onsuccess):n),i&&(this.onerror=this.onerror?ge(i,this.onerror):i),r===void 0?a===void 0?void 0:a:o(r,a)}}function ye(e,t){return e===N?t:function(){return!1!==t.apply(this,arguments)&&e.apply(this,arguments)}}function be(e,t){return e===N?t:function(){var n=e.apply(this,arguments);if(n&&typeof n.then==`function`){for(var r=this,i=arguments.length,a=Array(i);i--;)a[i]=arguments[i];return n.then(function(){return t.apply(r,a)})}return t.apply(this,arguments)}}T.ModifyError=le,T.DexieError=se,T.BulkError=ue;var xe=typeof location<`u`&&/^(http|https):\/\/(localhost|127\.0\.0\.1)/.test(location.href);function F(e){xe=e}var Se={},Ce=100,we=typeof Promise>`u`?[]:(j=Promise.resolve(),typeof crypto<`u`&&crypto.subtle?[we=crypto.subtle.digest(`SHA-512`,new Uint8Array([0])),s(we),j]:[j,s(j),j]),j=we[0],Te=we[1],Te=Te&&Te.then,Ee=j&&j.constructor,De=!!we[2],Oe=function(e,t){Fe.push([e,t]),Ae&&=(queueMicrotask(We),!1)},ke=!0,Ae=!0,je=[],Me=[],Ne=me,Pe={id:`global`,global:!0,ref:0,unhandleds:[],onunhandled:N,pgp:!1,env:{},finalize:N},I=Pe,Fe=[],Ie=0,Le=[];function L(e){if(typeof this!=`object`)throw TypeError(`Promises must be constructed via new`);this._listeners=[],this._lib=!1;var t=this._PSD=I;if(typeof e!=`function`){if(e!==Se)throw TypeError(`Not a function`);this._state=arguments[1],this._value=arguments[2],!1===this._state&&Be(this,this._value)}else this._state=null,this._value=null,++t.ref,function e(t,n){try{n(function(n){if(t._state===null){if(n===t)throw TypeError(`A promise cannot be resolved with itself.`);var r=t._lib&&Ge();n&&typeof n.then==`function`?e(t,function(e,t){n instanceof L?n._then(e,t):n.then(e,t)}):(t._state=!0,t._value=n,Ve(t)),r&&Ke()}},Be.bind(null,t))}catch(e){Be(t,e)}}(this,e)}var Re={get:function(){var e=I,t=$e;function n(n,r){var i=this,a=!e.global&&(e!==I||t!==$e),o=a&&!rt(),s=new L(function(t,s){He(i,new ze(ct(n,e,a,o),ct(r,e,a,o),t,s,e))});return this._consoleTask&&(s._consoleTask=this._consoleTask),s}return n.prototype=Se,n},set:function(e){f(this,`then`,e&&e.prototype===Se?Re:{get:function(){return e},set:Re.set})}};function ze(e,t,n,r,i){this.onFulfilled=typeof e==`function`?e:null,this.onRejected=typeof t==`function`?t:null,this.resolve=n,this.reject=r,this.psd=i}function Be(e,t){var n,r;Me.push(t),e._state===null&&(n=e._lib&&Ge(),t=Ne(t),e._state=!1,e._value=t,r=e,je.some(function(e){return e._value===r._value})||je.push(r),Ve(e),n)&&Ke()}function Ve(e){var t=e._listeners;e._listeners=[];for(var n=0,r=t.length;n<r;++n)He(e,t[n]);var i=e._PSD;--i.ref||i.finalize(),Ie===0&&(++Ie,Oe(function(){--Ie==0&&qe()},[]))}function He(e,t){if(e._state===null)e._listeners.push(t);else{var n=e._state?t.onFulfilled:t.onRejected;if(n===null)return(e._state?t.resolve:t.reject)(e._value);++t.psd.ref,++Ie,Oe(Ue,[n,e,t])}}function Ue(e,t,n){try{var r,i=t._value;!t._state&&Me.length&&(Me=[]),r=xe&&t._consoleTask?t._consoleTask.run(function(){return e(i)}):e(i),t._state||Me.indexOf(i)!==-1||(e=>{for(var t=je.length;t;)if(je[--t]._value===e._value)return je.splice(t,1)})(t),n.resolve(r)}catch(e){n.reject(e)}finally{--Ie==0&&qe(),--n.psd.ref||n.psd.finalize()}}function We(){st(Pe,function(){Ge()&&Ke()})}function Ge(){var e=ke;return Ae=ke=!1,e}function Ke(){var e,t,n;do for(;0<Fe.length;)for(e=Fe,Fe=[],n=e.length,t=0;t<n;++t){var r=e[t];r[0].apply(null,r[1])}while(0<Fe.length);Ae=ke=!0}function qe(){for(var e=je,t=(je=[],e.forEach(function(e){e._PSD.onunhandled.call(null,e._value,e)}),Le.slice(0)),n=t.length;n;)t[--n]()}function Je(e){return new L(Se,!1,e)}function R(e,t){var n=I;return function(){var r=Ge(),i=I;try{return at(n,!0),e.apply(this,arguments)}catch(e){t&&t(e)}finally{at(i,!1),r&&Ke()}}}u(L.prototype,{then:Re,_then:function(e,t){He(this,new ze(null,null,e,t,I))},catch:function(e){var t,n;return arguments.length===1?this.then(null,e):(t=e,n=arguments[1],typeof t==`function`?this.then(null,function(e){return(e instanceof t?n:Je)(e)}):this.then(null,function(e){return(e&&e.name===t?n:Je)(e)}))},finally:function(e){return this.then(function(t){return L.resolve(e()).then(function(){return t})},function(t){return L.resolve(e()).then(function(){return Je(t)})})},timeout:function(e,t){var n=this;return e<1/0?new L(function(r,i){var a=setTimeout(function(){return i(new M.Timeout(t))},e);n.then(r,i).finally(clearTimeout.bind(null,a))}):this}}),typeof Symbol<`u`&&Symbol.toStringTag&&f(L.prototype,Symbol.toStringTag,`Dexie.Promise`),Pe.env=ot(),u(L,{all:function(){var e=ie.apply(null,arguments).map(z);return new L(function(t,n){e.length===0&&t([]);var r=e.length;e.forEach(function(i,a){return L.resolve(i).then(function(n){e[a]=n,--r||t(e)},n)})})},resolve:function(e){return e instanceof L?e:e&&typeof e.then==`function`?new L(function(t,n){e.then(t,n)}):new L(Se,!0,e)},reject:Je,race:function(){var e=ie.apply(null,arguments).map(z);return new L(function(t,n){e.map(function(e){return L.resolve(e).then(t,n)})})},PSD:{get:function(){return I},set:function(e){return I=e}},totalEchoes:{get:function(){return $e}},newPSD:tt,usePSD:st,scheduler:{get:function(){return Oe},set:function(e){Oe=e}},rejectionMapper:{get:function(){return Ne},set:function(e){Ne=e}},follow:function(e,t){return new L(function(n,r){return tt(function(t,n){var r=I;r.unhandleds=[],r.onunhandled=n,r.finalize=ge(function(){var e,r=this;e=function(){r.unhandleds.length===0?t():n(r.unhandleds[0])},Le.push(function t(){e(),Le.splice(Le.indexOf(t),1)}),++Ie,Oe(function(){--Ie==0&&qe()},[])},r.finalize),e()},t,n,r)})}}),Ee&&(Ee.allSettled&&f(L,`allSettled`,function(){var e=ie.apply(null,arguments).map(z);return new L(function(t){e.length===0&&t([]);var n=e.length,r=Array(n);e.forEach(function(e,i){return L.resolve(e).then(function(e){return r[i]={status:`fulfilled`,value:e}},function(e){return r[i]={status:`rejected`,reason:e}}).then(function(){return--n||t(r)})})})}),Ee.any&&typeof AggregateError<`u`&&f(L,`any`,function(){var e=ie.apply(null,arguments).map(z);return new L(function(t,n){e.length===0&&n(AggregateError([]));var r=e.length,i=Array(r);e.forEach(function(e,a){return L.resolve(e).then(function(e){return t(e)},function(e){i[a]=e,--r||n(AggregateError(i))})})})}),Ee.withResolvers)&&(L.withResolvers=Ee.withResolvers);var Ye={awaits:0,echoes:0,id:0},Xe=0,Ze=[],Qe=0,$e=0,et=0;function tt(e,t,n,r){var i=I,a=Object.create(i),t=(a.parent=i,a.ref=0,a.global=!1,a.id=++et,Pe.env,a.env=De?{Promise:L,PromiseProp:{value:L,configurable:!0,writable:!0},all:L.all,race:L.race,allSettled:L.allSettled,any:L.any,resolve:L.resolve,reject:L.reject}:{},t&&o(a,t),++i.ref,a.finalize=function(){--this.parent.ref||this.parent.finalize()},st(a,e,n,r));return a.ref===0&&a.finalize(),t}function nt(){return Ye.id||=++Xe,++Ye.awaits,Ye.echoes+=Ce,Ye.id}function rt(){return!!Ye.awaits&&(--Ye.awaits==0&&(Ye.id=0),Ye.echoes=Ye.awaits*Ce,!0)}function z(e){return Ye.echoes&&e&&e.constructor===Ee?(nt(),e.then(function(e){return rt(),e},function(e){return rt(),B(e)})):e}function it(){var e=Ze[Ze.length-1];Ze.pop(),at(e,!1)}function at(e,t){var n,i,a=I;(t?!Ye.echoes||Qe++&&e===I:!Qe||--Qe&&e===I)||queueMicrotask(t?function(e){++$e,Ye.echoes&&--Ye.echoes!=0||(Ye.echoes=Ye.awaits=Ye.id=0),Ze.push(I),at(e,!0)}.bind(null,e):it),e!==I&&(I=e,a===Pe&&(Pe.env=ot()),De)&&(n=Pe.env.Promise,i=e.env,a.global||e.global)&&(Object.defineProperty(r,"Promise",i.PromiseProp),n.all=i.all,n.race=i.race,n.resolve=i.resolve,n.reject=i.reject,i.allSettled&&(n.allSettled=i.allSettled),i.any)&&(n.any=i.any)}function ot(){var e=r.Promise;return De?{Promise:e,PromiseProp:Object.getOwnPropertyDescriptor(r,`Promise`),all:e.all,race:e.race,allSettled:e.allSettled,any:e.any,resolve:e.resolve,reject:e.reject}:{}}function st(e,t,n,r,i){var a=I;try{return at(e,!0),t(n,r,i)}finally{at(a,!1)}}function ct(e,t,n,r){return typeof e==`function`?function(){var i=I;n&&nt(),at(t,!0);try{return e.apply(this,arguments)}finally{at(i,!1),r&&queueMicrotask(rt)}}:e}function lt(e){Promise===Ee&&Ye.echoes===0?Qe===0?e():enqueueNativeMicroTask(e):setTimeout(e,0)}(``+Te).indexOf(`[native code]`)===-1&&(nt=rt=N);var B=L.reject,ut=``,dt=`Invalid key provided. Keys must be of type string, number, Date or Array<string | number | Date>.`,ft=`String expected.`,pt=`__dbnames`,mt=`readonly`,ht=`readwrite`;function gt(e,t){return e?t?function(){return e.apply(this,arguments)&&t.apply(this,arguments)}:e:t}var _t={type:3,lower:-1/0,lowerOpen:!1,upper:[[]],upperOpen:!1};function vt(e){return typeof e!=`string`||/\./.test(e)?function(e){return e}:function(t){return t[e]===void 0&&e in t&&delete(t=O(t))[e],t}}function yt(){throw M.Type(`Entity instances must never be new:ed. Instances are generated by the framework bypassing the constructor.`)}function V(e,t){try{var n=bt(e),r=bt(t);if(n!==r)return n===`Array`?1:r===`Array`?-1:n===`binary`?1:r===`binary`?-1:n===`string`?1:r===`string`?-1:n===`Date`?1:r===`Date`?-1:NaN;switch(n){case`number`:case`Date`:case`string`:return t<e?1:e<t?-1:0;case`binary`:for(var i=xt(e),a=xt(t),o=i.length,s=a.length,c=o<s?o:s,l=0;l<c;++l)if(i[l]!==a[l])return i[l]<a[l]?-1:1;return o===s?0:o<s?-1:1;case`Array`:for(var u=e,d=t,f=u.length,p=d.length,m=f<p?f:p,h=0;h<m;++h){var g=V(u[h],d[h]);if(g!==0)return g}return f===p?0:f<p?-1:1}}catch{}return NaN}function bt(e){var t=typeof e;return t==`object`&&(ArrayBuffer.isView(e)||(t=k(e))===`ArrayBuffer`)?`binary`:t}function xt(e){return e instanceof Uint8Array?e:ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):new Uint8Array(e)}function St(e,t,n){var r=e.schema.yProps;return r?(t&&0<n.numFailures&&(t=t.filter(function(e,t){return!n.failures[t]})),Promise.all(r.map(function(n){return n=n.updatesTable,t?e.db.table(n).where(`k`).anyOf(t).delete():e.db.table(n).clear()})).then(function(){return n})):n}wt.prototype.execute=function(e){var t=this[`@@propmod`];if(t.add!==void 0){var r=t.add;if(a(r))return n(n([],a(e)?e:[],!0),r,!0).sort();if(typeof r==`number`)return(Number(e)||0)+r;if(typeof r==`bigint`)try{return BigInt(e)+r}catch{return BigInt(0)+r}throw TypeError(`Invalid term ${r}`)}if(t.remove!==void 0){var i=t.remove;if(a(i))return a(e)?e.filter(function(e){return!i.includes(e)}).sort():[];if(typeof i==`number`)return Number(e)-i;if(typeof i==`bigint`)try{return BigInt(e)-i}catch{return BigInt(0)-i}throw TypeError(`Invalid subtrahend ${i}`)}return r=(r=t.replacePrefix)?.[0],r&&typeof e==`string`&&e.startsWith(r)?t.replacePrefix[1]+e.substring(r.length):e};var Ct=wt;function wt(e){this[`@@propmod`]=e}function Tt(e,t){for(var n=i(t),r=n.length,a=!1,o=0;o<r;++o){var s=n[o],c=t[s],l=b(e,s);c instanceof Ct?(x(e,s,c.execute(l)),a=!0):l!==c&&(x(e,s,c),a=!0)}return a}H.prototype._trans=function(e,t,n){var r=this._tx||I.trans,i=this.name,a=xe&&typeof console<`u`&&console.createTask&&console.createTask(`Dexie: ${e===`readonly`?`read`:`write`} ${this.name}`);function o(e,n,r){if(r.schema[i])return t(r.idbtrans,r);throw new M.NotFound(`Table `+i+` not part of transaction`)}var s=Ge();try{var c=r&&r.db._novip===this.db._novip?r===I.trans?r._promise(e,o,n):tt(function(){return r._promise(e,o,n)},{trans:r,transless:I.transless||I}):function e(t,n,r,i){if(t.idbdb&&(t._state.openComplete||I.letThrough||t._vip)){var a=t._createTransaction(n,r,t._dbSchema);try{a.create(),t._state.PR1398_maxLoop=3}catch(a){return a.name===de.InvalidState&&t.isOpen()&&0<--t._state.PR1398_maxLoop?(console.warn(`Dexie: Need to reopen db`),t.close({disableAutoOpen:!1}),t.open().then(function(){return e(t,n,r,i)})):B(a)}return a._promise(n,function(e,t){return tt(function(){return I.trans=a,i(e,t,a)})}).then(function(e){if(n===`readwrite`)try{a.idbtrans.commit()}catch{}return n===`readonly`?e:a._completion.then(function(){return e})})}if(t._state.openComplete)return B(new M.DatabaseClosed(t._state.dbOpenError));if(!t._state.isBeingOpened){if(!t._state.autoOpen)return B(new M.DatabaseClosed);t.open().catch(N)}return t._state.dbReadyPromise.then(function(){return e(t,n,r,i)})}(this.db,e,[this.name],o);return a&&(c._consoleTask=a,c=c.catch(function(e){return console.trace(e),B(e)})),c}finally{s&&Ke()}},H.prototype.get=function(e,t){var n=this;return e&&e.constructor===Object?this.where(e).first(t):e==null?B(new M.Type(`Invalid argument to Table.get()`)):this._trans(`readonly`,function(t){return n.core.get({trans:t,key:e}).then(function(e){return n.hook.reading.fire(e)})}).then(t)},H.prototype.where=function(e){if(typeof e==`string`)return new this.db.WhereClause(this,e);if(a(e))return new this.db.WhereClause(this,`[${e.join(`+`)}]`);var t=i(e);if(t.length===1)return this.where(t[0]).equals(e[t[0]]);var n=this.schema.indexes.concat(this.schema.primKey).filter(function(e){if(e.compound&&t.every(function(t){return 0<=e.keyPath.indexOf(t)})){for(var n=0;n<t.length;++n)if(t.indexOf(e.keyPath[n])===-1)return!1;return!0}return!1}).sort(function(e,t){return e.keyPath.length-t.keyPath.length})[0];if(n&&this.db._maxKey!==ut)return s=n.keyPath.slice(0,t.length),this.where(s).equals(s.map(function(t){return e[t]}));!n&&xe&&console.warn(`The query ${JSON.stringify(e)} on ${this.name} would benefit from a compound index [${t.join(`+`)}]`);var r=this.schema.idxByName;function o(e,t){return V(e,t)===0}var s=t.reduce(function(t,n){var i=t[0],t=t[1],s=r[n],c=e[n];return[i||s,i||!s?gt(t,s&&s.multi?function(e){return e=b(e,n),a(e)&&e.some(function(e){return o(c,e)})}:function(e){return o(c,b(e,n))}):t]},[null,null]),c=s[0],s=s[1];return c?this.where(c.name).equals(e[c.keyPath]).filter(s):n?this.filter(s):this.where(t).equals(``)},H.prototype.filter=function(e){return this.toCollection().and(e)},H.prototype.count=function(e){return this.toCollection().count(e)},H.prototype.offset=function(e){return this.toCollection().offset(e)},H.prototype.limit=function(e){return this.toCollection().limit(e)},H.prototype.each=function(e){return this.toCollection().each(e)},H.prototype.toArray=function(e){return this.toCollection().toArray(e)},H.prototype.toCollection=function(){return new this.db.Collection(new this.db.WhereClause(this))},H.prototype.orderBy=function(e){return new this.db.Collection(new this.db.WhereClause(this,a(e)?`[${e.join(`+`)}]`:e))},H.prototype.reverse=function(){return this.toCollection().reverse()},H.prototype.mapToClass=function(t){for(var n=this.db,r=this.name,i=((this.schema.mappedClass=t).prototype instanceof yt&&(t=(t=>{var i=s,a=t;if(typeof a!=`function`&&a!==null)throw TypeError(`Class extends value `+String(a)+` is not a constructor or null`);function o(){this.constructor=i}function s(){return t!==null&&t.apply(this,arguments)||this}return e(i,a),i.prototype=a===null?Object.create(a):(o.prototype=a.prototype,new o),Object.defineProperty(s.prototype,"db",{get:function(){return n},enumerable:!1,configurable:!0}),s.prototype.table=function(){return r},s})(t)),new Set),a=t.prototype;a;a=s(a))Object.getOwnPropertyNames(a).forEach(function(e){return i.add(e)});function o(e){if(!e)return e;var n,r=Object.create(t.prototype);for(n in e)if(!i.has(n))try{r[n]=e[n]}catch{}return r}return this.schema.readHook&&this.hook.reading.unsubscribe(this.schema.readHook),this.schema.readHook=o,this.hook(`reading`,o),t},H.prototype.defineClass=function(){return this.mapToClass(function(e){o(this,e)})},H.prototype.add=function(e,t){var n=this,r=this.schema.primKey,i=r.auto,a=r.keyPath,o=e;return a&&i&&(o=vt(a)(e)),this._trans(`readwrite`,function(e){return n.core.mutate({trans:e,type:`add`,keys:t==null?null:[t],values:[o]})}).then(function(e){return e.numFailures?L.reject(e.failures[0]):e.lastResult}).then(function(t){if(a)try{x(e,a,t)}catch{}return t})},H.prototype.upsert=function(e,t){var n=this,r=this.schema.primKey.keyPath;return this._trans(`readwrite`,function(i){return n.core.get({trans:i,key:e}).then(function(a){var o=a??{};return Tt(o,t),r&&x(o,r,e),n.core.mutate({trans:i,type:`put`,values:[o],keys:[e],upsert:!0,updates:{keys:[e],changeSpecs:[t]}}).then(function(e){return e.numFailures?L.reject(e.failures[0]):!!a})})})},H.prototype.update=function(e,t){return typeof e!=`object`||a(e)?this.where(`:id`).equals(e).modify(t):(e=b(e,this.schema.primKey.keyPath))===void 0?B(new M.InvalidArgument(`Given object does not contain its primary key`)):this.where(`:id`).equals(e).modify(t)},H.prototype.put=function(e,t){var n=this,r=this.schema.primKey,i=r.auto,a=r.keyPath,o=e;return a&&i&&(o=vt(a)(e)),this._trans(`readwrite`,function(e){return n.core.mutate({trans:e,type:`put`,values:[o],keys:t==null?null:[t]})}).then(function(e){return e.numFailures?L.reject(e.failures[0]):e.lastResult}).then(function(t){if(a)try{x(e,a,t)}catch{}return t})},H.prototype.delete=function(e){var t=this;return this._trans(`readwrite`,function(n){return t.core.mutate({trans:n,type:`delete`,keys:[e]}).then(function(n){return St(t,[e],n)}).then(function(e){return e.numFailures?L.reject(e.failures[0]):void 0})})},H.prototype.clear=function(){var e=this;return this._trans(`readwrite`,function(t){return e.core.mutate({trans:t,type:`deleteRange`,range:_t}).then(function(t){return St(e,null,t)})}).then(function(e){return e.numFailures?L.reject(e.failures[0]):void 0})},H.prototype.bulkGet=function(e){var t=this;return this._trans(`readonly`,function(n){return t.core.getMany({keys:e,trans:n}).then(function(e){return e.map(function(e){return t.hook.reading.fire(e)})})})},H.prototype.bulkAdd=function(e,t,n){var r=this,i=Array.isArray(t)?t:void 0,a=(n||=i?void 0:t)?n.allKeys:void 0;return this._trans(`readwrite`,function(t){var n=r.schema.primKey,o=n.auto,n=n.keyPath;if(n&&i)throw new M.InvalidArgument(`bulkAdd(): keys argument invalid on tables with inbound keys`);if(i&&i.length!==e.length)throw new M.InvalidArgument(`Arguments objects and keys must have the same length`);var s=e.length,o=n&&o?e.map(vt(n)):e;return r.core.mutate({trans:t,type:`add`,keys:i,values:o,wantResults:a}).then(function(e){var t=e.numFailures,n=e.failures;if(t===0)return a?e.results:e.lastResult;throw new ue(`${r.name}.bulkAdd(): ${t} of ${s} operations failed`,n)})})},H.prototype.bulkPut=function(e,t,n){var r=this,i=Array.isArray(t)?t:void 0,a=(n||=i?void 0:t)?n.allKeys:void 0;return this._trans(`readwrite`,function(t){var n=r.schema.primKey,o=n.auto,n=n.keyPath;if(n&&i)throw new M.InvalidArgument(`bulkPut(): keys argument invalid on tables with inbound keys`);if(i&&i.length!==e.length)throw new M.InvalidArgument(`Arguments objects and keys must have the same length`);var s=e.length,o=n&&o?e.map(vt(n)):e;return r.core.mutate({trans:t,type:`put`,keys:i,values:o,wantResults:a}).then(function(e){var t=e.numFailures,n=e.failures;if(t===0)return a?e.results:e.lastResult;throw new ue(`${r.name}.bulkPut(): ${t} of ${s} operations failed`,n)})})},H.prototype.bulkUpdate=function(e){var t=this,n=this.core,r=e.map(function(e){return e.key}),i=e.map(function(e){return e.changes}),a=[];return this._trans(`readwrite`,function(o){return n.getMany({trans:o,keys:r,cache:`clone`}).then(function(s){var c=[],l=[],u=(e.forEach(function(e,n){var r=e.key,i=e.changes,o=s[n];if(o){for(var u=0,d=Object.keys(i);u<d.length;u++){var f=d[u],p=i[f];if(f===t.schema.primKey.keyPath){if(V(p,r)!==0)throw new M.Constraint(`Cannot update primary key in bulkUpdate()`)}else x(o,f,p)}a.push(n),c.push(r),l.push(o)}}),c.length);return n.mutate({trans:o,type:`put`,keys:c,values:l,updates:{keys:r,changeSpecs:i}}).then(function(e){var n=e.numFailures,r=e.failures;if(n===0)return u;for(var i=0,o=Object.keys(r);i<o.length;i++){var s,c=o[i],l=a[Number(c)];l!=null&&(s=r[c],delete r[c],r[l]=s)}throw new ue(`${t.name}.bulkUpdate(): ${n} of ${u} operations failed`,r)})})})},H.prototype.bulkDelete=function(e){var t=this,n=e.length;return this._trans(`readwrite`,function(n){return t.core.mutate({trans:n,type:`delete`,keys:e}).then(function(n){return St(t,e,n)})}).then(function(e){var r=e.numFailures,i=e.failures;if(r===0)return e.lastResult;throw new ue(`${t.name}.bulkDelete(): ${r} of ${n} operations failed`,i)})};var Et=H;function H(){}function Dt(e){function t(t,r){if(r){for(var i=arguments.length,a=Array(i-1);--i;)a[i-1]=arguments[i];return n[t].subscribe.apply(null,a),e}if(typeof t==`string`)return n[t]}var n={};t.addEventType=s;for(var r=1,o=arguments.length;r<o;++r)s(arguments[r]);return t;function s(e,r,o){var c,l;if(typeof e!=`object`)return r||=ye,l={subscribers:[],fire:o||=N,subscribe:function(e){l.subscribers.indexOf(e)===-1&&(l.subscribers.push(e),l.fire=r(l.fire,e))},unsubscribe:function(e){l.subscribers=l.subscribers.filter(function(t){return t!==e}),l.fire=l.subscribers.reduce(r,o)}},n[e]=t[e]=l;i(c=e).forEach(function(e){var t=c[e];if(a(t))s(e,c[e][0],c[e][1]);else{if(t!==`asap`)throw new M.InvalidArgument(`Invalid event config`);var n=s(e,me,function(){for(var e=arguments.length,t=Array(e);e--;)t[e]=arguments[e];n.subscribers.forEach(function(e){y(function(){e.apply(null,t)})})})}})}}function Ot(e,t){return p(t).from({prototype:e}),t}function kt(e,t){return!(e.filter||e.algorithm||e.or)&&(t?e.justLimit:!e.replayFilter)}function At(e,t){e.filter=gt(e.filter,t)}function jt(e,t,n){var r=e.replayFilter;e.replayFilter=r?function(){return gt(r(),t())}:t,e.justLimit=n&&!r}function Mt(e,t){if(e.isPrimKey)return t.primaryKey;var n=t.getIndexByKeyPath(e.index);if(n)return n;throw new M.Schema(`KeyPath `+e.index+` on object store `+t.name+` is not indexed`)}function Nt(e,t,n){var r=Mt(e,t.schema);return t.openCursor({trans:n,values:!e.keysOnly,reverse:e.dir===`prev`,unique:!!e.unique,query:{index:r,range:e.range}})}function Pt(e,t,n,r){var i,a,o=e.replayFilter?gt(e.filter,e.replayFilter()):e.filter;return e.or?(i={},a=function(e,n,r){var a,s;o&&!o(n,r,function(e){return n.stop(e)},function(e){return n.fail(e)})||((s=``+(a=n.primaryKey))==`[object ArrayBuffer]`&&(s=``+new Uint8Array(a)),l(i,s))||(i[s]=!0,t(e,n,r))},Promise.all([e.or._iterate(a,n),Ft(Nt(e,r,n),e.algorithm,a,!e.keysOnly&&e.valueMapper)])):Ft(Nt(e,r,n),gt(e.algorithm,o),t,!e.keysOnly&&e.valueMapper)}function Ft(e,t,n,r){var i=R(r?function(e,t,i){return n(r(e),t,i)}:n);return e.then(function(e){if(e)return e.start(function(){var n=function(){return e.continue()};t&&!t(e,function(e){return n=e},function(t){e.stop(t),n=N},function(t){e.fail(t),n=N})||i(e.value,e,function(e){return n=e}),n()})})}U.prototype._read=function(e,t){var n=this._ctx;return n.error?n.table._trans(null,B.bind(null,n.error)):n.table._trans(`readonly`,e).then(t)},U.prototype._write=function(e){var t=this._ctx;return t.error?t.table._trans(null,B.bind(null,t.error)):t.table._trans(`readwrite`,e,`locked`)},U.prototype._addAlgorithm=function(e){var t=this._ctx;t.algorithm=gt(t.algorithm,e)},U.prototype._iterate=function(e,t){return Pt(this._ctx,e,t,this._ctx.table.core)},U.prototype.clone=function(e){var t=Object.create(this.constructor.prototype),n=Object.create(this._ctx);return e&&o(n,e),t._ctx=n,t},U.prototype.raw=function(){return this._ctx.valueMapper=null,this},U.prototype.each=function(e){var t=this._ctx;return this._read(function(n){return Pt(t,e,n,t.table.core)})},U.prototype.count=function(e){var t=this;return this._read(function(e){var n,r=t._ctx,i=r.table.core;return kt(r,!0)?i.count({trans:e,query:{index:Mt(r,i.schema),range:r.range}}).then(function(e){return Math.min(e,r.limit)}):(n=0,Pt(r,function(){return++n,!1},e,i).then(function(){return n}))}).then(e)},U.prototype.sortBy=function(e,t){var n=e.split(`.`).reverse(),r=n[0],i=n.length-1;function a(e,t){return t?a(e[n[t]],t-1):e[r]}var o=this._ctx.dir===`next`?1:-1;function s(e,t){return V(a(e,i),a(t,i))*o}return this.toArray(function(e){return e.slice().sort(s)}).then(t)},U.prototype.toArray=function(e){var t=this;return this._read(function(e){var n,r,i,a=t._ctx;return kt(a,!0)&&0<a.limit?(n=a.valueMapper,r=Mt(a,a.table.core.schema),a.table.core.query({trans:e,limit:a.limit,values:!0,direction:a.dir===`prev`?`prev`:void 0,query:{index:r,range:a.range}}).then(function(e){return e=e.result,n?e.map(n):e})):(i=[],Pt(a,function(e){return i.push(e)},e,a.table.core).then(function(){return i}))},e)},U.prototype.offset=function(e){var t=this._ctx;return e<=0||(t.offset+=e,kt(t)?jt(t,function(){var t=e;return function(e,n){return t===0||(t===1?--t:n(function(){e.advance(t),t=0}),!1)}}):jt(t,function(){var t=e;return function(){return--t<0}})),this},U.prototype.limit=function(e){return this._ctx.limit=Math.min(this._ctx.limit,e),jt(this._ctx,function(){var t=e;return function(e,n,r){return--t<=0&&n(r),0<=t}},!0),this},U.prototype.until=function(e,t){return At(this._ctx,function(n,r,i){return!e(n.value)||(r(i),t)}),this},U.prototype.first=function(e){return this.limit(1).toArray(function(e){return e[0]}).then(e)},U.prototype.last=function(e){return this.reverse().first(e)},U.prototype.filter=function(e){var t;return At(this._ctx,function(t){return e(t.value)}),(t=this._ctx).isMatch=gt(t.isMatch,e),this},U.prototype.and=function(e){return this.filter(e)},U.prototype.or=function(e){return new this.db.WhereClause(this._ctx.table,e,this)},U.prototype.reverse=function(){return this._ctx.dir=this._ctx.dir===`prev`?`next`:`prev`,this._ondirectionchange&&this._ondirectionchange(this._ctx.dir),this},U.prototype.desc=function(){return this.reverse()},U.prototype.eachKey=function(e){var t=this._ctx;return t.keysOnly=!t.isMatch,this.each(function(t,n){e(n.key,n)})},U.prototype.eachUniqueKey=function(e){return this._ctx.unique=`unique`,this.eachKey(e)},U.prototype.eachPrimaryKey=function(e){var t=this._ctx;return t.keysOnly=!t.isMatch,this.each(function(t,n){e(n.primaryKey,n)})},U.prototype.keys=function(e){var t=this._ctx,n=(t.keysOnly=!t.isMatch,[]);return this.each(function(e,t){n.push(t.key)}).then(function(){return n}).then(e)},U.prototype.primaryKeys=function(e){var t=this._ctx;if(kt(t,!0)&&0<t.limit)return this._read(function(e){var n=Mt(t,t.table.core.schema);return t.table.core.query({trans:e,values:!1,limit:t.limit,direction:t.dir===`prev`?`prev`:void 0,query:{index:n,range:t.range}})}).then(function(e){return e.result}).then(e);t.keysOnly=!t.isMatch;var n=[];return this.each(function(e,t){n.push(t.primaryKey)}).then(function(){return n}).then(e)},U.prototype.uniqueKeys=function(e){return this._ctx.unique=`unique`,this.keys(e)},U.prototype.firstKey=function(e){return this.limit(1).keys(function(e){return e[0]}).then(e)},U.prototype.lastKey=function(e){return this.reverse().firstKey(e)},U.prototype.distinct=function(){var e,t=this._ctx,t=t.index&&t.table.schema.idxByName[t.index];return t&&t.multi&&(e={},At(this._ctx,function(t){var t=t.primaryKey.toString(),n=l(e,t);return e[t]=!0,!n})),this},U.prototype.modify=function(e){var t=this,n=this._ctx;return this._write(function(r){function a(e,t){var n=t.failures;p+=e-t.numFailures;for(var r=0,a=i(n);r<a.length;r++){var o=a[r];f.push(n[o])}}var o=typeof e==`function`?e:function(t){return Tt(t,e)},s=n.table.core,c=s.schema.primaryKey,l=c.outbound,u=c.extractKey,d=200,c=t.db._options.modifyChunkSize,f=(c&&(d=typeof c==`object`?c[s.name]||c[`*`]||200:c),[]),p=0,m=[],h=e===Lt;return t.clone().primaryKeys().then(function(t){function i(f){var p=Math.min(d,t.length-f),m=t.slice(f,f+p);return(h?Promise.resolve([]):s.getMany({trans:r,keys:m,cache:`immutable`})).then(function(g){var _=[],v=[],y=l?[]:null,b=h?m:[];if(!h)for(var x=0;x<p;++x){var S=g[x],C={value:O(S),primKey:t[f+x]};!1!==o.call(C,C.value,C)&&(C.value==null?b.push(t[f+x]):l||V(u(S),u(C.value))===0?(v.push(C.value),l&&y.push(t[f+x])):(b.push(t[f+x]),_.push(C.value)))}return Promise.resolve(0<_.length&&s.mutate({trans:r,type:`add`,values:_}).then(function(e){for(var t in e.failures)b.splice(parseInt(t),1);a(_.length,e)})).then(function(){return(0<v.length||c&&typeof e==`object`)&&s.mutate({trans:r,type:`put`,keys:y,values:v,criteria:c,changeSpec:typeof e!=`function`&&e,isAdditionalChunk:0<f}).then(function(e){return a(v.length,e)})}).then(function(){return(0<b.length||c&&h)&&s.mutate({trans:r,type:`delete`,keys:b,criteria:c,isAdditionalChunk:0<f}).then(function(e){return St(n.table,b,e)}).then(function(e){return a(b.length,e)})}).then(function(){return t.length>f+p&&i(f+d)})})}var c=kt(n)&&n.limit===1/0&&(typeof e!=`function`||h)&&{index:n.index,range:n.range};return i(0).then(function(){if(0<f.length)throw new le(`Error modifying one or more objects`,f,p,m);return t.length})})})},U.prototype.delete=function(){var e=this._ctx,t=e.range;return!kt(e)||e.table.schema.yProps||!e.isPrimKey&&t.type!==3?this.modify(Lt):this._write(function(n){var r=e.table.core.schema.primaryKey,i=t;return e.table.core.count({trans:n,query:{index:r,range:i}}).then(function(t){return e.table.core.mutate({trans:n,type:`deleteRange`,range:i}).then(function(e){var n=e.failures,e=e.numFailures;if(e)throw new le(`Could not delete some values`,Object.keys(n).map(function(e){return n[e]}),t-e);return t-e})})})};var It=U;function U(){}var Lt=function(e,t){return t.value=null};function Rt(e,t){return e<t?-1:e===t?0:1}function zt(e,t){return t<e?-1:e===t?0:1}function Bt(e,t,n){return e=e instanceof Gt?new e.Collection(e):e,e._ctx.error=new(n||TypeError)(t),e}function Vt(e){return new e.Collection(e,function(){return Wt(``)}).limit(0)}function Ht(e,t,n,r){var i,a,o,s,c,l,u,d=n.length;if(!n.every(function(e){return typeof e==`string`}))return Bt(e,ft);function f(e){i=e===`next`?function(e){return e.toUpperCase()}:function(e){return e.toLowerCase()},a=e===`next`?function(e){return e.toLowerCase()}:function(e){return e.toUpperCase()},o=e===`next`?Rt:zt;var t=n.map(function(e){return{lower:a(e),upper:i(e)}}).sort(function(e,t){return o(e.lower,t.lower)});s=t.map(function(e){return e.upper}),c=t.map(function(e){return e.lower}),u=(l=e)===`next`?``:r}f(`next`);var e=new e.Collection(e,function(){return Ut(s[0],c[d-1]+r)}),p=(e._ondirectionchange=function(e){f(e)},0);return e._addAlgorithm(function(e,n,r){var i=e.key;if(typeof i==`string`){var f=a(i);if(t(f,c,p))return!0;for(var m=null,h=p;h<d;++h){var g=((e,t,n,r,i,a)=>{for(var o=Math.min(e.length,r.length),s=-1,c=0;c<o;++c){var l=t[c];if(l!==r[c])return i(e[c],n[c])<0?e.substr(0,c)+n[c]+n.substr(c+1):i(e[c],r[c])<0?e.substr(0,c)+r[c]+n.substr(c+1):0<=s?e.substr(0,s)+t[s]+n.substr(s+1):null;i(e[c],l)<0&&(s=c)}return o<r.length&&a===`next`?e+n.substr(e.length):o<e.length&&a===`prev`?e.substr(0,n.length):s<0?null:e.substr(0,s)+r[s]+n.substr(s+1)})(i,f,s[h],c[h],o,l);g===null&&m===null?p=h+1:(m===null||0<o(m,g))&&(m=g)}n(m===null?r:function(){e.continue(m+u)})}return!1}),e}function Ut(e,t,n,r){return{type:2,lower:e,upper:t,lowerOpen:n,upperOpen:r}}function Wt(e){return{type:1,lower:e,upper:e}}Object.defineProperty(Kt.prototype,"Collection",{get:function(){return this._ctx.table.db.Collection},enumerable:!1,configurable:!0}),Kt.prototype.between=function(e,t,n,r){n=!1!==n,r=!0===r;try{return 0<this._cmp(e,t)||this._cmp(e,t)===0&&(n||r)&&(!n||!r)?Vt(this):new this.Collection(this,function(){return Ut(e,t,!n,!r)})}catch{return Bt(this,dt)}},Kt.prototype.equals=function(e){return e==null?Bt(this,dt):new this.Collection(this,function(){return Wt(e)})},Kt.prototype.above=function(e){return e==null?Bt(this,dt):new this.Collection(this,function(){return Ut(e,void 0,!0)})},Kt.prototype.aboveOrEqual=function(e){return e==null?Bt(this,dt):new this.Collection(this,function(){return Ut(e,void 0,!1)})},Kt.prototype.below=function(e){return e==null?Bt(this,dt):new this.Collection(this,function(){return Ut(void 0,e,!1,!0)})},Kt.prototype.belowOrEqual=function(e){return e==null?Bt(this,dt):new this.Collection(this,function(){return Ut(void 0,e)})},Kt.prototype.startsWith=function(e){return typeof e==`string`?this.between(e,e+ut,!0,!0):Bt(this,ft)},Kt.prototype.startsWithIgnoreCase=function(e){return e===``?this.startsWith(e):Ht(this,function(e,t){return e.indexOf(t[0])===0},[e],ut)},Kt.prototype.equalsIgnoreCase=function(e){return Ht(this,function(e,t){return e===t[0]},[e],``)},Kt.prototype.anyOfIgnoreCase=function(){var e=ie.apply(re,arguments);return e.length===0?Vt(this):Ht(this,function(e,t){return t.indexOf(e)!==-1},e,``)},Kt.prototype.startsWithAnyOfIgnoreCase=function(){var e=ie.apply(re,arguments);return e.length===0?Vt(this):Ht(this,function(e,t){return t.some(function(t){return e.indexOf(t)===0})},e,ut)},Kt.prototype.anyOf=function(){var e,t,n=this,r=ie.apply(re,arguments),i=this._cmp;try{r.sort(i)}catch{return Bt(this,dt)}return r.length===0?Vt(this):((e=new this.Collection(this,function(){return Ut(r[0],r[r.length-1])}))._ondirectionchange=function(e){i=e===`next`?n._ascending:n._descending,r.sort(i)},t=0,e._addAlgorithm(function(e,n,a){for(var o=e.key;0<i(o,r[t]);)if(++t===r.length)return n(a),!1;return i(o,r[t])===0||(n(function(){e.continue(r[t])}),!1)}),e)},Kt.prototype.notEqual=function(e){return this.inAnyRange([[-1/0,e],[e,this.db._maxKey]],{includeLowers:!1,includeUppers:!1})},Kt.prototype.noneOf=function(){var e=ie.apply(re,arguments);if(e.length===0)return new this.Collection(this);try{e.sort(this._ascending)}catch{return Bt(this,dt)}var t=e.reduce(function(e,t){return e?e.concat([[e[e.length-1][1],t]]):[[-1/0,t]]},null);return t.push([e[e.length-1],this.db._maxKey]),this.inAnyRange(t,{includeLowers:!1,includeUppers:!1})},Kt.prototype.inAnyRange=function(e,t){var n=this,r=this._cmp,i=this._ascending,a=this._descending,o=this._min,s=this._max;if(e.length===0)return Vt(this);if(!e.every(function(e){return e[0]!==void 0&&e[1]!==void 0&&i(e[0],e[1])<=0}))return Bt(this,`First argument to inAnyRange() must be an Array of two-value Arrays [lower,upper] where upper must not be lower than lower`,M.InvalidArgument);var c=!t||!1!==t.includeLowers,l=t&&!0===t.includeUppers,u,d=i;function f(e,t){return d(e[0],t[0])}try{(u=e.reduce(function(e,t){for(var n=0,i=e.length;n<i;++n){var a=e[n];if(r(t[0],a[1])<0&&0<r(t[1],a[0])){a[0]=o(a[0],t[0]),a[1]=s(a[1],t[1]);break}}return n===i&&e.push(t),e},[])).sort(f)}catch{return Bt(this,dt)}var p=0,m=l?function(e){return 0<i(e,u[p][1])}:function(e){return 0<=i(e,u[p][1])},h=c?function(e){return 0<a(e,u[p][0])}:function(e){return 0<=a(e,u[p][0])},g=m,t=new this.Collection(this,function(){return Ut(u[0][0],u[u.length-1][1],!c,!l)});return t._ondirectionchange=function(e){d=e===`next`?(g=m,i):(g=h,a),u.sort(f)},t._addAlgorithm(function(e,t,r){for(var a,o=e.key;g(o);)if(++p===u.length)return t(r),!1;return!m(a=o)&&!h(a)||(n._cmp(o,u[p][1])===0||n._cmp(o,u[p][0])===0||t(function(){d===i?e.continue(u[p][0]):e.continue(u[p][1])}),!1)}),t},Kt.prototype.startsWithAnyOf=function(){var e=ie.apply(re,arguments);return e.every(function(e){return typeof e==`string`})?e.length===0?Vt(this):this.inAnyRange(e.map(function(e){return[e,e+ut]})):Bt(this,`startsWithAnyOf() only works with strings`)};var Gt=Kt;function Kt(){}function qt(e){return R(function(t){return Jt(t),e(t.target.error),!1})}function Jt(e){e.stopPropagation&&e.stopPropagation(),e.preventDefault&&e.preventDefault()}var Yt=`storagemutated`,Xt=`x-storagemutated-1`,Zt=Dt(null,Yt),Qt=($t.prototype._lock=function(){return v(!I.global),++this._reculock,this._reculock!==1||I.global||(I.lockOwnerFor=this),this},$t.prototype._unlock=function(){if(v(!I.global),--this._reculock==0)for(I.global||(I.lockOwnerFor=null);0<this._blockedFuncs.length&&!this._locked();){var e=this._blockedFuncs.shift();try{st(e[1],e[0])}catch{}}return this},$t.prototype._locked=function(){return this._reculock&&I.lockOwnerFor!==this},$t.prototype.create=function(e){var t=this;if(this.mode){var n=this.db.idbdb,r=this.db._state.dbOpenError;if(v(!this.idbtrans),!e&&!n)switch(r&&r.name){case`DatabaseClosedError`:throw new M.DatabaseClosed(r);case`MissingAPIError`:throw new M.MissingAPI(r.message,r);default:throw new M.OpenFailed(r)}if(!this.active)throw new M.TransactionInactive;v(this._completion._state===null),(e=this.idbtrans=e||(this.db.core||n).transaction(this.storeNames,this.mode,{durability:this.chromeTransactionDurability})).onerror=R(function(n){Jt(n),t._reject(e.error)}),e.onabort=R(function(n){Jt(n),t.active&&t._reject(new M.Abort(e.error)),t.active=!1,t.on(`abort`).fire(n)}),e.oncomplete=R(function(){t.active=!1,t._resolve(),`mutatedParts`in e&&Zt.storagemutated.fire(e.mutatedParts)})}return this},$t.prototype._promise=function(e,t,n){var r,i=this;return e===`readwrite`&&this.mode!==`readwrite`?B(new M.ReadOnly(`Transaction is readonly`)):this.active?this._locked()?new L(function(r,a){i._blockedFuncs.push([function(){i._promise(e,t,n).then(r,a)},I])}):n?tt(function(){var e=new L(function(e,n){i._lock();var r=t(e,n,i);r&&r.then&&r.then(e,n)});return e.finally(function(){return i._unlock()}),e._lib=!0,e}):((r=new L(function(e,n){var r=t(e,n,i);r&&r.then&&r.then(e,n)}))._lib=!0,r):B(new M.TransactionInactive)},$t.prototype._root=function(){return this.parent?this.parent._root():this},$t.prototype.waitFor=function(e){var t,n=this._root(),r=L.resolve(e),i=(n._waitingFor?n._waitingFor=n._waitingFor.then(function(){return r}):(n._waitingFor=r,n._waitingQueue=[],t=n.idbtrans.objectStore(n.storeNames[0]),function e(){for(++n._spinCount;n._waitingQueue.length;)n._waitingQueue.shift()();n._waitingFor&&(t.get(-1/0).onsuccess=e)}()),n._waitingFor);return new L(function(e,t){r.then(function(t){return n._waitingQueue.push(R(e.bind(null,t)))},function(e){return n._waitingQueue.push(R(t.bind(null,e)))}).finally(function(){n._waitingFor===i&&(n._waitingFor=null)})})},$t.prototype.abort=function(){this.active&&(this.active=!1,this.idbtrans&&this.idbtrans.abort(),this._reject(new M.Abort))},$t.prototype.table=function(e){var t=this._memoizedTables||={};if(l(t,e))return t[e];var n=this.schema[e];if(n)return(n=new this.db.Table(e,n,this)).core=this.db.core.table(e),t[e]=n;throw new M.NotFound(`Table `+e+` not part of transaction`)},$t);function $t(){}function en(e,t,n,r,i,a,o,s){return{name:e,keyPath:t,unique:n,multi:r,auto:i,compound:a,src:(n&&!o?`&`:``)+(r?`*`:``)+(i?`++`:``)+tn(t),type:s}}function tn(e){return typeof e==`string`?e:e?`[`+[].join.call(e,`+`)+`]`:``}function nn(e,t,n){return{name:e,primKey:t,indexes:n,mappedClass:null,idxByName:(r=function(e){return[e.name,e]},n.reduce(function(e,t,n){return t=r(t,n),t&&(e[t[0]]=t[1]),e},{}))};var r}var rn=function(e){try{return e.only([[]]),rn=function(){return[[]]},[[]]}catch{return rn=function(){return ut},ut}};function W(e){return e==null?function(){}:typeof e==`string`?(t=e).split(`.`).length===1?function(e){return e[t]}:function(e){return b(e,t)}:function(t){return b(t,e)};var t}function an(e){return[].slice.call(e)}var on=0;function sn(e){return e==null?`:id`:typeof e==`string`?e:`[${e.join(`+`)}]`}function cn(e,t,n){function r(e){if(e.type===3)return null;if(e.type===4)throw Error(`Cannot convert never type to IDBKeyRange`);var n=e.lower,r=e.upper,i=e.lowerOpen,e=e.upperOpen;return n===void 0?r===void 0?null:t.upperBound(r,!!e):r===void 0?t.lowerBound(n,!!i):t.bound(n,r,!!i,!!e)}function i(e){var t,n,i=e.name;return{name:i,schema:e,mutate:function(e){var t=e.trans,n=e.type,a=e.keys,o=e.values,s=e.range;return new Promise(function(e,c){e=R(e);var l=t.objectStore(i),u=l.keyPath==null,d=n===`put`||n===`add`;if(!d&&n!==`delete`&&n!==`deleteRange`)throw Error(`Invalid operation type: `+n);var f,p=(a||o||{length:1}).length;if(a&&o&&a.length!==o.length)throw Error(`Given keys array must have same length as given values array.`);if(p===0)return e({numFailures:0,failures:{},results:[],lastResult:void 0});function m(e){++_,Jt(e)}var h=[],g=[],_=0;if(n===`deleteRange`){if(s.type===4)return e({numFailures:_,failures:g,results:[],lastResult:void 0});s.type===3?h.push(f=l.clear()):h.push(f=l.delete(r(s)))}else{var u=d?u?[o,a]:[o,null]:[a,null],v=u[0],y=u[1];if(d)for(var b=0;b<p;++b)h.push(f=y&&y[b]!==void 0?l[n](v[b],y[b]):l[n](v[b])),f.onerror=m;else for(b=0;b<p;++b)h.push(f=l[n](v[b])),f.onerror=m}function x(t){t=t.target.result,h.forEach(function(e,t){return e.error!=null&&(g[t]=e.error)}),e({numFailures:_,failures:g,results:n===`delete`?a:h.map(function(e){return e.result}),lastResult:t})}f.onerror=function(e){m(e),x(e)},f.onsuccess=x})},getMany:function(e){var t=e.trans,n=e.keys;return new Promise(function(e,r){e=R(e);for(var a,o=t.objectStore(i),s=n.length,c=Array(s),l=0,u=0,d=function(t){t=t.target,c[t._pos]=t.result,++u===l&&e(c)},f=qt(r),p=0;p<s;++p)n[p]!=null&&((a=o.get(n[p]))._pos=p,a.onsuccess=d,a.onerror=f,++l);l===0&&e(c)})},get:function(e){var t=e.trans,n=e.key;return new Promise(function(e,r){e=R(e);var a=t.objectStore(i).get(n);a.onsuccess=function(t){return e(t.target.result)},a.onerror=qt(r)})},query:(t=c,n=l,function(e){return new Promise(function(a,o){a=R(a);var s,c,l,u,d=e.trans,f=e.values,p=e.limit,m=e.query,h=(h=e.direction)??`next`,g=p===1/0?void 0:p,_=m.index,m=m.range,d=d.objectStore(i),d=_.isPrimaryKey?d:d.index(_.name),_=r(m);if(p===0)return a({result:[]});n?(m={query:_,count:g,direction:h},(s=f?d.getAll(m):d.getAllKeys(m)).onsuccess=function(e){return a({result:e.target.result})},s.onerror=qt(o)):t&&h===`next`?((s=f?d.getAll(_,g):d.getAllKeys(_,g)).onsuccess=function(e){return a({result:e.target.result})},s.onerror=qt(o)):(c=0,l=!f&&`openKeyCursor`in d?d.openKeyCursor(_,h):d.openCursor(_,h),u=[],l.onsuccess=function(){var e=l.result;return!e||(u.push(f?e.value:e.primaryKey),++c===p)?a({result:u}):void e.continue()},l.onerror=qt(o))})}),openCursor:function(e){var t=e.trans,n=e.values,a=e.query,o=e.reverse,s=e.unique;return new Promise(function(e,c){e=R(e);var l=a.index,u=a.range,d=t.objectStore(i),d=l.isPrimaryKey?d:d.index(l.name),l=o?s?`prevunique`:`prev`:s?`nextunique`:`next`,f=!n&&`openKeyCursor`in d?d.openKeyCursor(r(u),l):d.openCursor(r(u),l);f.onerror=qt(c),f.onsuccess=R(function(n){var r,i,a,o,s=f.result;s?(s.___id=++on,s.done=!1,r=s.continue.bind(s),i=(i=s.continuePrimaryKey)&&i.bind(s),a=s.advance.bind(s),o=function(){throw Error(`Cursor not stopped`)},s.trans=t,s.stop=s.continue=s.continuePrimaryKey=s.advance=function(){throw Error(`Cursor not started`)},s.fail=R(c),s.next=function(){var e=this,t=1;return this.start(function(){return t--?e.continue():e.stop()}).then(function(){return e})},s.start=function(e){function t(){if(f.result)try{e()}catch(e){s.fail(e)}else s.done=!0,s.start=function(){throw Error(`Cursor behind last entry`)},s.stop()}var n=new Promise(function(e,t){e=R(e),f.onerror=qt(t),s.fail=t,s.stop=function(t){s.stop=s.continue=s.continuePrimaryKey=s.advance=o,e(t)}});return f.onsuccess=R(function(e){f.onsuccess=t,t()}),s.continue=r,s.continuePrimaryKey=i,s.advance=a,t(),n},e(s)):e(null)},c)})},count:function(e){var t=e.query,n=e.trans,a=t.index,o=t.range;return new Promise(function(e,t){var s=n.objectStore(i),s=a.isPrimaryKey?s:s.index(a.name),c=r(o),c=c?s.count(c):s.count();c.onsuccess=R(function(t){return e(t.target.result)}),c.onerror=qt(t)})}}}o=n,s=an((n=e).objectStoreNames),u=0<s.length?o.objectStore(s[0]):{};var o,n={schema:{name:n.name,tables:s.map(function(e){return o.objectStore(e)}).map(function(e){var t=e.keyPath,n=e.autoIncrement,r=a(t),i={},r={name:e.name,primaryKey:{name:null,isPrimaryKey:!0,outbound:t==null,compound:r,keyPath:t,autoIncrement:n,unique:!0,extractKey:W(t)},indexes:an(e.indexNames).map(function(t){return e.index(t)}).map(function(e){var t=e.name,n=e.unique,r=e.multiEntry,e=e.keyPath,t={name:t,compound:a(e),keyPath:e,unique:n,multiEntry:r,extractKey:W(e)};return i[sn(e)]=t}),getIndexByKeyPath:function(e){return i[sn(e)]}};return i[`:id`]=r.primaryKey,t!=null&&(i[sn(t)]=r.primaryKey),r})},hasGetAll:0<s.length&&`getAll`in u&&!(typeof navigator<`u`&&/Safari/.test(navigator.userAgent)&&!/(Chrome\/|Edge\/)/.test(navigator.userAgent)&&[].concat(navigator.userAgent.match(/Safari\/(\d*)/))[1]<604),hasIdb3Features:`getAllRecords`in u},s=n.schema,c=n.hasGetAll,l=n.hasIdb3Features,u=s.tables.map(i),d={};return u.forEach(function(e){return d[e.name]=e}),{stack:`dbcore`,transaction:e.transaction.bind(e),table:function(e){if(d[e])return d[e];throw Error(`Table '${e}' not found`)},MIN_KEY:-1/0,MAX_KEY:rn(t),schema:s}}function ln(e,n,r,i){return r=r.IDBKeyRange,n=cn(n,r,i),{dbcore:e.dbcore.reduce(function(e,n){return n=n.create,t(t({},e),n(e))},n)}}function un(e,t){var n=t.db,n=ln(e._middlewares,n,e._deps,t);e.core=n.dbcore,e.tables.forEach(function(t){var n=t.name;e.core.schema.tables.some(function(e){return e.name===n})&&(t.core=e.core.table(n),e[n]instanceof e.Table)&&(e[n].core=t.core)})}function dn(e,t,n,r){n.forEach(function(n){var i=r[n];t.forEach(function(t){var r=function e(t,n){return m(t,n)||(t=s(t))&&e(t,n)}(t,n);(!r||`value`in r&&r.value===void 0)&&(t===e.Transaction.prototype||t instanceof e.Transaction?f(t,n,{get:function(){return this.table(n)},set:function(e){d(this,n,{value:e,writable:!0,configurable:!0,enumerable:!0})}}):t[n]=new e.Table(n,i))})})}function fn(e,t){t.forEach(function(t){for(var n in t)t[n]instanceof e.Table&&delete t[n]})}function pn(e,t){return e._cfg.version-t._cfg.version}function G(e,t,n,r){var a=e._dbSchema,o=(n.objectStoreNames.contains(`$meta`)&&!a.$meta&&(a.$meta=nn(`$meta`,xn(``)[0],[]),e._storeNames.push(`$meta`)),e._createTransaction(`readwrite`,e._storeNames,a)),s=(o.create(n),o._completion.catch(r),o._reject.bind(o)),c=I.transless||I;tt(function(){if(I.trans=o,I.transless=c,t!==0)return un(e,n),l=t,((r=o).storeNames.includes(`$meta`)?r.table(`$meta`).get(`version`).then(function(e){return e??l}):L.resolve(l)).then(function(t){var r=e,a=t,s=o,c=n,l=[],t=r._versions,u=r._dbSchema=yn(0,r.idbdb,c);return(t=t.filter(function(e){return e._cfg.version>=a})).length===0?L.resolve():(t.forEach(function(e){l.push(function(){var t,n,o,l=u,d=e._cfg.dbschema,f=(bn(r,l,c),bn(r,d,c),u=r._dbSchema=d,hn(l,d)),p=(f.add.forEach(function(e){gn(c,e[0],e[1].primKey,e[1].indexes)}),f.change.forEach(function(e){if(e.recreate)throw new M.Upgrade(`Not yet support for changing primary key`);var t=c.objectStore(e.name);e.add.forEach(function(e){return vn(t,e)}),e.change.forEach(function(e){t.deleteIndex(e.name),vn(t,e)}),e.del.forEach(function(e){return t.deleteIndex(e)})}),e._cfg.contentUpgrade);if(p&&e._cfg.version>a)return un(r,c),s._memoizedTables={},t=S(d),f.del.forEach(function(e){t[e]=l[e]}),fn(r,[r.Transaction.prototype]),dn(r,[r.Transaction.prototype],i(t),t),s.schema=t,(n=ae(p))&&nt(),d=L.follow(function(){var e;(o=p(s))&&n&&(e=rt.bind(null,null),o.then(e,e))}),o&&typeof o.then==`function`?L.resolve(o):d.then(function(){return o})}),l.push(function(t){var n=e._cfg.dbschema,i=t;[].slice.call(i.db.objectStoreNames).forEach(function(e){return n[e]==null&&i.db.deleteObjectStore(e)}),fn(r,[r.Transaction.prototype]),dn(r,[r.Transaction.prototype],r._storeNames,r._dbSchema),s.schema=r._dbSchema}),l.push(function(t){r.idbdb.objectStoreNames.contains(`$meta`)&&(Math.ceil(r.idbdb.version/10)===e._cfg.version?(r.idbdb.deleteObjectStore(`$meta`),delete r._dbSchema.$meta,r._storeNames=r._storeNames.filter(function(e){return e!==`$meta`})):t.objectStore(`$meta`).put(e._cfg.version,`version`))})}),function e(){return l.length?L.resolve(l.shift()(s.idbtrans)).then(e):L.resolve()}().then(function(){_n(u,c)}))}).catch(s);var r,l;i(a).forEach(function(e){gn(n,e,a[e].primKey,a[e].indexes)}),un(e,n),L.follow(function(){return e.on.populate.fire(o)}).catch(s)})}function mn(e,t){_n(e._dbSchema,t),t.db.version%10!=0||t.objectStoreNames.contains(`$meta`)||t.db.createObjectStore(`$meta`).add(Math.ceil(t.db.version/10-1),`version`);var n=yn(0,e.idbdb,t);bn(e,e._dbSchema,t);for(var r=0,i=hn(n,e._dbSchema).change;r<i.length;r++){var a=(e=>{if(e.change.length||e.recreate)return console.warn(`Unable to patch indexes of table ${e.name} because it has changes on the type of index or primary key.`),{value:void 0};var n=t.objectStore(e.name);e.add.forEach(function(t){xe&&console.debug(`Dexie upgrade patch: Creating missing index ${e.name}.${t.src}`),vn(n,t)})})(i[r]);if(typeof a==`object`)return a.value}}function hn(e,t){var n,r={del:[],add:[],change:[]};for(n in e)t[n]||r.del.push(n);for(n in t){var i=e[n],a=t[n];if(i){var o={name:n,def:a,recreate:!1,del:[],add:[],change:[]};if(``+(i.primKey.keyPath||``)!=``+(a.primKey.keyPath||``)||i.primKey.auto!==a.primKey.auto)o.recreate=!0,r.change.push(o);else{var s=i.idxByName,c=a.idxByName,l=void 0;for(l in s)c[l]||o.del.push(l);for(l in c){var u=s[l],d=c[l];u?u.src!==d.src&&o.change.push(d):o.add.push(d)}(0<o.del.length||0<o.add.length||0<o.change.length)&&r.change.push(o)}}else r.add.push([n,a])}return r}function gn(e,t,n,r){var i=e.db.createObjectStore(t,n.keyPath?{keyPath:n.keyPath,autoIncrement:n.auto}:{autoIncrement:n.auto});r.forEach(function(e){return vn(i,e)})}function _n(e,t){i(e).forEach(function(n){t.db.objectStoreNames.contains(n)||(xe&&console.debug(`Dexie: Creating missing table`,n),gn(t,n,e[n].primKey,e[n].indexes))})}function vn(e,t){e.createIndex(t.name,t.keyPath,{unique:t.unique,multiEntry:t.multi})}function yn(e,t,n){var r={};return g(t.objectStoreNames,0).forEach(function(e){for(var t=n.objectStore(e),i=en(tn(c=t.keyPath),c||``,!0,!1,!!t.autoIncrement,c&&typeof c!=`string`,!0),a=[],o=0;o<t.indexNames.length;++o){var s=t.index(t.indexNames[o]),c=s.keyPath,s=en(s.name,c,!!s.unique,!!s.multiEntry,!1,c&&typeof c!=`string`,!1);a.push(s)}r[e]=nn(e,i,a)}),r}function bn(e,t,n){for(var i=n.db.objectStoreNames,a=0;a<i.length;++a){var o=i[a],s=n.objectStore(o);e._hasGetAll=`getAll`in s;for(var c=0;c<s.indexNames.length;++c){var l,u=s.indexNames[c],d=s.index(u).keyPath,d=typeof d==`string`?d:`[`+g(d).join(`+`)+`]`;t[o]&&(l=t[o].idxByName[d])&&(l.name=u,delete t[o].idxByName[d],t[o].idxByName[u]=l)}}typeof navigator<`u`&&/Safari/.test(navigator.userAgent)&&!/(Chrome\/|Edge\/)/.test(navigator.userAgent)&&r.WorkerGlobalScope&&r instanceof r.WorkerGlobalScope&&[].concat(navigator.userAgent.match(/Safari\/(\d*)/))[1]<604&&(e._hasGetAll=!1)}function xn(e){return e.split(`,`).map(function(e,t){var n=e.split(`:`),r=(r=n[1])?.trim(),n=(e=n[0].trim()).replace(/([&*]|\+\+)/g,``),i=/^\[/.test(n)?n.match(/^\[(.*)\]$/)[1].split(`+`):n;return en(n,i||null,/\&/.test(e),/\*/.test(e),/\+\+/.test(e),a(i),t===0,r)})}Cn.prototype._createTableSchema=nn,Cn.prototype._parseIndexSyntax=xn,Cn.prototype._parseStoresSpec=function(e,t){var n=this;i(e).forEach(function(r){if(e[r]!==null){var i=n._parseIndexSyntax(e[r]),a=i.shift();if(!a)throw new M.Schema(`Invalid schema for table `+r+`: `+e[r]);if(a.unique=!0,a.multi)throw new M.Schema(`Primary key cannot be multiEntry*`);i.forEach(function(e){if(e.auto)throw new M.Schema(`Only primary key can be marked as autoIncrement (++)`);if(!e.keyPath)throw new M.Schema(`Index must have a name and cannot be an empty string`)}),a=n._createTableSchema(r,a,i),t[r]=a}})},Cn.prototype.stores=function(e){var t=this.db,e=(this._cfg.storesSource=this._cfg.storesSource?o(this._cfg.storesSource,e):e,t._versions),n={},r={};return e.forEach(function(e){o(n,e._cfg.storesSource),r=e._cfg.dbschema={},e._parseStoresSpec(n,r)}),t._dbSchema=r,fn(t,[t._allTables,t,t.Transaction.prototype]),dn(t,[t._allTables,t,t.Transaction.prototype,this._cfg.tables],i(r),r),t._storeNames=i(r),this},Cn.prototype.upgrade=function(e){return this._cfg.contentUpgrade=be(this._cfg.contentUpgrade||N,e),this};var Sn=Cn;function Cn(){}var wn=(()=>{var e,t,n;return typeof FinalizationRegistry<`u`&&typeof WeakRef<`u`?(e=new Set,t=new FinalizationRegistry(function(t){e.delete(t)}),{toArray:function(){return Array.from(e).map(function(e){return e.deref()}).filter(function(e){return e!==void 0})},add:function(n){var r=new WeakRef(n._novip);e.add(r),t.register(n._novip,r,r),e.size>n._options.maxConnections&&(r=e.values().next().value,e.delete(r),t.unregister(r))},remove:function(n){if(n)for(var r=e.values(),i=r.next();!i.done;){var a=i.value;if(a.deref()===n._novip)return e.delete(a),void t.unregister(a);i=r.next()}}}):(n=[],{toArray:function(){return n},add:function(e){n.push(e._novip)},remove:function(e){e&&(e=n.indexOf(e._novip))!==-1&&n.splice(e,1)}})})();function Tn(e,t){var n=e._dbNamesDB;return n||(n=e._dbNamesDB=new lr(pt,{addons:[],indexedDB:e,IDBKeyRange:t})).version(1).stores({dbnames:`name`}),n.table(`dbnames`)}function En(e){return e&&typeof e.databases==`function`}function Dn(e){return tt(function(){return I.letThrough=!0,e()})}function On(e){return!(`from`in e)}var K=function(e,t){var n;if(!this)return n=new K,e&&`d`in e&&o(n,e),n;o(this,arguments.length?{d:1,from:e,to:1<arguments.length?t:e}:{d:0})};function kn(e,t,n){var r=V(t,n);if(!isNaN(r)){if(0<r)throw RangeError();if(On(e))return o(e,{from:t,to:n,d:1});var r=e.l,i=e.r;if(V(n,e.from)<0)return r?kn(r,t,n):e.l={from:t,to:n,d:1,l:null,r:null},Nn(e);if(0<V(t,e.to))return i?kn(i,t,n):e.r={from:t,to:n,d:1,l:null,r:null},Nn(e);V(t,e.from)<0&&(e.from=t,e.l=null,e.d=i?i.d+1:1),0<V(n,e.to)&&(e.to=n,e.r=null,e.d=e.l?e.l.d+1:1),t=!e.r,r&&!e.l&&An(e,r),i&&t&&An(e,i)}}function An(e,t){On(t)||function e(t,n){var r=n.from,i=n.l,a=n.r;kn(t,r,n.to),i&&e(t,i),a&&e(t,a)}(e,t)}function jn(e,t){var n=Mn(t),r=n.next();if(!r.done)for(var i=r.value,a=Mn(e),o=a.next(i.from),s=o.value;!r.done&&!o.done;){if(V(s.from,i.to)<=0&&0<=V(s.to,i.from))return!0;V(i.from,s.from)<0?i=(r=n.next(s.from)).value:s=(o=a.next(i.from)).value}return!1}function Mn(e){var t=On(e)?null:{s:0,n:e};return{next:function(e){for(var n=0<arguments.length;t;)switch(t.s){case 0:if(t.s=1,n)for(;t.n.l&&V(e,t.n.from)<0;)t={up:t,n:t.n.l,s:1};else for(;t.n.l;)t={up:t,n:t.n.l,s:1};case 1:if(t.s=2,!n||V(e,t.n.to)<=0)return{value:t.n,done:!1};case 2:if(t.n.r){t.s=3,t={up:t,n:t.n.r,s:0};continue}case 3:t=t.up}return{done:!0}}}}function Nn(e){var n,r,i,a=((a=e.r)?.d||0)-((a=e.l)?.d||0),a=1<a?`r`:a<-1?`l`:``;a&&(n=a==`r`?`l`:`r`,r=t({},e),i=e[a],e.from=i.from,e.to=i.to,e[a]=i[a],r[a]=i[n],(e[n]=r).d=Pn(r)),e.d=Pn(e)}function Pn(e){var t=e.r,e=e.l;return(t?e?Math.max(t.d,e.d):t.d:e?e.d:0)+1}function Fn(e,t){return i(t).forEach(function(n){e[n]?An(e[n],t[n]):e[n]=function e(t){var n,r,i={};for(n in t)l(t,n)&&(r=t[n],i[n]=!r||typeof r!=`object`||E.has(r.constructor)?r:e(r));return i}(t[n])}),e}function In(e,t){return e.all||t.all||Object.keys(e).some(function(n){return t[n]&&jn(t[n],e[n])})}u(K.prototype,((j={add:function(e){return An(this,e),this},addKey:function(e){return kn(this,e,e),this},addKeys:function(e){var t=this;return e.forEach(function(e){return kn(t,e,e)}),this},hasKey:function(e){var t=Mn(this).next(e).value;return t&&V(t.from,e)<=0&&0<=V(t.to,e)}})[te]=function(){return Mn(this)},j));var Ln={},Rn={},zn=!1;function Bn(e){Fn(Rn,e),zn||(zn=!0,setTimeout(function(){zn=!1,Vn(Rn,!(Rn={}))},0))}function Vn(e,t){t===void 0&&(t=!1);var n=new Set;if(e.all)for(var r=0,i=Object.values(Ln);r<i.length;r++)Hn(s=i[r],e,n,t);else for(var a in e){var o,s,a=/^idb\:\/\/(.*)\/(.*)\//.exec(a);a&&(o=a[1],a=a[2],s=Ln[`idb://${o}/${a}`])&&Hn(s,e,n,t)}n.forEach(function(e){return e()})}function Hn(e,t,n,r){for(var i=[],a=0,o=Object.entries(e.queries.query);a<o.length;a++){for(var s=o[a],c=s[0],l=[],u=0,d=s[1];u<d.length;u++){var f=d[u];In(t,f.obsSet)?f.subscribers.forEach(function(e){return n.add(e)}):r&&l.push(f)}r&&i.push([c,l])}if(r)for(var p=0,m=i;p<m.length;p++){var h=m[p],c=h[0],l=h[1];e.queries.query[c]=l}}function Un(e){var t=e._state,n=e._deps.indexedDB;if(t.isBeingOpened||e.idbdb)return t.dbReadyPromise.then(function(){return t.dbOpenError?B(t.dbOpenError):e});t.isBeingOpened=!0,t.dbOpenError=null,t.openComplete=!1;var r=t.openCanceller,a=Math.round(10*e.verno),o=!1;function s(){if(t.openCanceller!==r)throw new M.DatabaseClosed(`db.open() was cancelled`)}function c(){return new L(function(r,l){if(s(),!n)throw new M.MissingAPI;var u=e.name,p=t.autoSchema||!a?n.open(u):n.open(u,a);if(!p)throw new M.MissingAPI;p.onerror=qt(l),p.onblocked=R(e._fireOnBlocked),p.onupgradeneeded=R(function(r){var i;d=p.transaction,t.autoSchema&&!e._options.allowEmptyDB?(p.onerror=Jt,d.abort(),p.result.close(),(i=n.deleteDatabase(u)).onsuccess=i.onerror=R(function(){l(new M.NoSuchDatabase(`Database ${u} doesnt exist`))})):(d.onerror=qt(l),i=r.oldVersion>2**62?0:r.oldVersion,f=i<1,e.idbdb=p.result,o&&mn(e,d),G(e,i/10,d,l))},l),p.onsuccess=R(function(){d=null;var n,s,l,m,h,_,v=e.idbdb=p.result,y=g(v.objectStoreNames);if(0<y.length)try{var b=v.transaction((h=y).length===1?h[0]:h,`readonly`);if(t.autoSchema)_=v,m=b,(l=e).verno=_.version/10,m=l._dbSchema=yn(0,_,m),l._storeNames=g(_.objectStoreNames,0),dn(l,[l._allTables],i(m),m);else if(bn(e,e._dbSchema,b),s=b,((s=hn(yn(0,(n=e).idbdb,s),n._dbSchema)).add.length||s.change.some(function(e){return e.add.length||e.change.length}))&&!o)return console.warn(`Dexie SchemaDiff: Schema was extended without increasing the number passed to db.version(). Dexie will add missing parts and increment native version number to workaround this.`),v.close(),a=v.version+1,o=!0,r(c());un(e,b)}catch{}wn.add(e),v.onversionchange=R(function(n){t.vcFired=!0,e.on(`versionchange`).fire(n)}),v.onclose=R(function(){e.close({disableAutoOpen:!1})}),f&&(y=e._deps,h=u,En(_=y.indexedDB)||h===pt||Tn(_,y.IDBKeyRange).put({name:h}).catch(N)),r()},l)}).catch(function(e){switch(e?.name){case`UnknownError`:if(0<t.PR1398_maxLoop)return t.PR1398_maxLoop--,console.warn(`Dexie: Workaround for Chrome UnknownError on open()`),c();break;case`VersionError`:if(0<a)return a=0,c()}return L.reject(e)})}var l,u=t.dbReadyResolve,d=null,f=!1;return L.race([r,(typeof navigator>`u`?L.resolve():!navigator.userAgentData&&/Safari\//.test(navigator.userAgent)&&!/Chrom(e|ium)\//.test(navigator.userAgent)&&indexedDB.databases?new Promise(function(e){function t(){return indexedDB.databases().finally(e)}l=setInterval(t,100),t()}).finally(function(){return clearInterval(l)}):Promise.resolve()).then(c)]).then(function(){return s(),t.onReadyBeingFired=[],L.resolve(Dn(function(){return e.on.ready.fire(e.vip)})).then(function n(){var r;if(0<t.onReadyBeingFired.length)return r=t.onReadyBeingFired.reduce(be,N),t.onReadyBeingFired=[],L.resolve(Dn(function(){return r(e.vip)})).then(n)})}).finally(function(){t.openCanceller===r&&(t.onReadyBeingFired=null,t.isBeingOpened=!1)}).catch(function(n){t.dbOpenError=n;try{d&&d.abort()}catch{}return r===t.openCanceller&&e._close(),B(n)}).finally(function(){t.openComplete=!0,u()}).then(function(){var t;return f&&(t={},e.tables.forEach(function(n){n.schema.indexes.forEach(function(r){r.name&&(t[`idb://${e.name}/${n.name}/${r.name}`]=new K(-1/0,[[[]]]))}),t[`idb://${e.name}/${n.name}/`]=t[`idb://${e.name}/${n.name}/:dels`]=new K(-1/0,[[[]]])}),Zt(Yt).fire(t),Vn(t,!0)),e})}function Wn(e){function t(t){return e.next(t)}var n=i(t),r=i(function(t){return e.throw(t)});function i(e){return function(t){var t=e(t),i=t.value;return t.done?i:i&&typeof i.then==`function`?i.then(n,r):a(i)?Promise.all(i).then(n,r):n(i)}}return i(t)()}function Gn(e,t,n){for(var r=a(e)?e.slice():[e],i=0;i<n;++i)r.push(t);return r}var Kn={stack:`dbcore`,name:`VirtualIndexMiddleware`,level:1,create:function(e){return t(t({},e),{table:function(n){var r=e.table(n),n=r.schema,i={},a=[];function o(e,n,r){var s=sn(e),c=i[s]=i[s]||[],l=e==null?0:typeof e==`string`?1:e.length,u=0<n,s=t(t({},r),{name:u?`${s}(virtual-from:${r.name})`:r.name,lowLevelIndex:r,isVirtual:u,keyTail:n,keyLength:l,extractKey:W(e),unique:!u&&r.unique});return c.push(s),s.isPrimaryKey||a.push(s),1<l&&o(l===2?e[0]:e.slice(0,l-1),n+1,r),c.sort(function(e,t){return e.keyTail-t.keyTail}),s}var s=o(n.primaryKey.keyPath,0,n.primaryKey);i[`:id`]=[s];for(var c=0,l=n.indexes;c<l.length;c++){var u=l[c];o(u.keyPath,0,u)}function d(n){var r,i=n.query.index;return i.isVirtual?t(t({},n),{query:{index:i.lowLevelIndex,range:(r=n.query.range,i=i.keyTail,{type:r.type===1?2:r.type,lower:Gn(r.lower,r.lowerOpen?e.MAX_KEY:e.MIN_KEY,i),lowerOpen:!0,upper:Gn(r.upper,r.upperOpen?e.MIN_KEY:e.MAX_KEY,i),upperOpen:!0})}}):n}return t(t({},r),{schema:t(t({},n),{primaryKey:s,indexes:a,getIndexByKeyPath:function(e){return(e=i[sn(e)])&&e[0]}}),count:function(e){return r.count(d(e))},query:function(e){return r.query(d(e))},openCursor:function(t){var n=t.query.index,i=n.keyTail,a=n.keyLength;return n.isVirtual?r.openCursor(d(t)).then(function(e){return e&&o(e)}):r.openCursor(t);function o(n){return Object.create(n,{continue:{value:function(r){r==null?t.unique?n.continue(n.key.slice(0,a).concat(t.reverse?e.MIN_KEY:e.MAX_KEY,i)):n.continue():n.continue(Gn(r,t.reverse?e.MAX_KEY:e.MIN_KEY,i))}},continuePrimaryKey:{value:function(t,r){n.continuePrimaryKey(Gn(t,e.MAX_KEY,i),r)}},primaryKey:{get:function(){return n.primaryKey}},key:{get:function(){var e=n.key;return a===1?e[0]:e.slice(0,a)}},value:{get:function(){return n.value}}})}}})}})}};function qn(e,t,n,r){return n||={},r||=``,i(e).forEach(function(i){var a,o,s;l(t,i)?(a=e[i],o=t[i],typeof a==`object`&&typeof o==`object`&&a&&o?(s=k(a))===k(o)?s===`Object`?qn(a,o,n,r+i+`.`):a!==o&&(n[r+i]=t[i]):n[r+i]=t[i]:a!==o&&(n[r+i]=t[i])):n[r+i]=void 0}),i(t).forEach(function(i){l(e,i)||(n[r+i]=t[i])}),n}function Jn(e,t){return t.type===`delete`?t.keys:t.keys||t.values.map(e.extractKey)}var Yn={stack:`dbcore`,name:`HooksMiddleware`,level:2,create:function(e){return t(t({},e),{table:function(r){var i=e.table(r),a=i.schema.primaryKey;return t(t({},i),{mutate:function(e){var o=I.trans,s=o.table(r).hook,c=s.deleting,u=s.creating,d=s.updating;switch(e.type){case`add`:if(u.fire===N)break;return o._promise(`readwrite`,function(){return f(e)},!0);case`put`:if(u.fire===N&&d.fire===N)break;return o._promise(`readwrite`,function(){return f(e)},!0);case`delete`:if(c.fire===N)break;return o._promise(`readwrite`,function(){return f(e)},!0);case`deleteRange`:if(c.fire===N)break;return o._promise(`readwrite`,function(){return function e(n,r,o){return i.query({trans:n,values:!1,query:{index:a,range:r},limit:o}).then(function(i){var a=i.result;return f({type:`delete`,keys:a,trans:n}).then(function(i){return 0<i.numFailures?Promise.reject(i.failures[0]):a.length<o?{failures:[],numFailures:0,lastResult:void 0}:e(n,t(t({},r),{lower:a[a.length-1],lowerOpen:!0}),o)})})}(e.trans,e.range,1e4)},!0)}return i.mutate(e);function f(e){var r,o,s,f=I.trans,p=e.keys||Jn(a,e);if(p)return(e=e.type===`add`||e.type===`put`?t(t({},e),{keys:p}):t({},e)).type!==`delete`&&(e.values=n([],e.values,!0)),e.keys&&=n([],e.keys,!0),r=i,s=p,((o=e).type===`add`?Promise.resolve([]):r.getMany({trans:o.trans,keys:s,cache:`immutable`})).then(function(t){var n=p.map(function(n,r){var i,o,s,p=t[r],m={onerror:null,onsuccess:null};return e.type===`delete`?c.fire.call(m,n,p,f):e.type===`add`||p===void 0?(i=u.fire.call(m,n,e.values[r],f),n==null&&i!=null&&(e.keys[r]=n=i,a.outbound||x(e.values[r],a.keyPath,n))):(i=qn(p,e.values[r]),(o=d.fire.call(m,i,n,p,f))&&(s=e.values[r],Object.keys(o).forEach(function(e){l(s,e)?s[e]=o[e]:x(s,e,o[e])}))),m});return i.mutate(e).then(function(r){for(var i=r.failures,a=r.results,o=r.numFailures,r=r.lastResult,s=0;s<p.length;++s){var c=(a||p)[s],l=n[s];c==null?l.onerror&&l.onerror(i[s]):l.onsuccess&&l.onsuccess(e.type===`put`&&t[s]?e.values[s]:c)}return{failures:i,results:a,numFailures:o,lastResult:r}}).catch(function(e){return n.forEach(function(t){return t.onerror&&t.onerror(e)}),Promise.reject(e)})});throw Error(`Keys missing`)}}})}})}};function Xn(e,t,n){try{if(!t||t.keys.length<e.length)return null;for(var r=[],i=0,a=0;i<t.keys.length&&a<e.length;++i)V(t.keys[i],e[a])===0&&(r.push(n?O(t.values[i]):t.values[i]),++a);return r.length===e.length?r:null}catch{return null}}var Zn={stack:`dbcore`,level:-1,create:function(e){return{table:function(n){var r=e.table(n);return t(t({},r),{getMany:function(e){var t;return e.cache?(t=Xn(e.keys,e.trans._cache,e.cache===`clone`))?L.resolve(t):r.getMany(e).then(function(t){return e.trans._cache={keys:e.keys,values:e.cache===`clone`?O(t):t},t}):r.getMany(e)},mutate:function(e){return e.type!==`add`&&(e.trans._cache=null),r.mutate(e)}})}}}};function Qn(e,t){return e.trans.mode===`readonly`&&!!e.subscr&&!e.trans.explicit&&e.trans.db._options.cache!==`disabled`&&!t.schema.primaryKey.outbound}function $n(e,t){switch(e){case`query`:return t.values&&!t.unique;case`get`:case`getMany`:case`count`:case`openCursor`:return!1}}var er={stack:`dbcore`,level:0,name:`Observability`,create:function(e){var n=e.schema.name,r=new K(e.MIN_KEY,e.MAX_KEY);return t(t({},e),{transaction:function(t,n,r){if(I.subscr&&n!==`readonly`)throw new M.ReadOnly(`Readwrite transaction in liveQuery context. Querier source: ${I.querier}`);return e.transaction(t,n,r)},table:function(o){function s(t){var t=t.query;return[t.index,new K((t=t.range).lower??e.MIN_KEY,t.upper??e.MAX_KEY)]}var c=e.table(o),l=c.schema,u=l.primaryKey,d=l.indexes,f=u.extractKey,p=u.outbound,m=u.autoIncrement&&d.filter(function(e){return e.compound&&e.keyPath.includes(u.keyPath)}),h=t(t({},c),{mutate:function(t){function i(e){return e=`idb://${n}/${o}/${e}`,h[e]||(h[e]=new K)}var s,d,f,p=t.trans,h=t.mutatedParts||={},g=i(``),_=i(`:dels`),v=t.type,y=t.type===`deleteRange`?[t.range]:t.type===`delete`?[t.keys]:t.values.length<50?[Jn(u,t).filter(function(e){return e}),t.values]:[],b=y[0],y=y[1],x=t.trans._cache;return a(b)?(g.addKeys(b),(v=v===`delete`||b.length===y.length?Xn(b,x):null)||_.addKeys(b),(v||y)&&(s=i,d=v,f=y,l.indexes.forEach(function(e){var t=s(e.name||``);function n(t){return t==null?null:e.extractKey(t)}function r(n){e.multiEntry&&a(n)?n.forEach(function(e){return t.addKey(e)}):t.addKey(n)}(d||f).forEach(function(e,t){var i=d&&n(d[t]),t=f&&n(f[t]);V(i,t)!==0&&(i!=null&&r(i),t!=null)&&r(t)})}))):b?(y={from:(x=b.lower)??e.MIN_KEY,to:(v=b.upper)??e.MAX_KEY},_.add(y),g.add(y)):(g.add(r),_.add(r),l.indexes.forEach(function(e){return i(e.name).add(r)})),c.mutate(t).then(function(e){return!b||t.type!==`add`&&t.type!==`put`||(g.addKeys(e.results),m&&m.forEach(function(n){for(var r=t.values.map(function(e){return n.extractKey(e)}),a=n.keyPath.findIndex(function(e){return e===u.keyPath}),o=0,s=e.results.length;o<s;++o)r[o][a]=e.results[o];i(n.name).addKeys(r)})),p.mutatedParts=Fn(p.mutatedParts||{},h),e})}}),g={get:function(e){return[u,new K(e.key)]},getMany:function(e){return[u,new K().addKeys(e.keys)]},count:s,query:s,openCursor:s};return i(g).forEach(function(e){h[e]=function(i){var a=I.subscr,s=!!a,l=Qn(I,c)&&$n(e,i)?i.obsSet={}:a;if(s){var u,a=function(e){return e=`idb://${n}/${o}/${e}`,l[e]||(l[e]=new K)},d=a(``),m=a(`:dels`),s=g[e](i),h=s[0],s=s[1];if((e===`query`&&h.isPrimaryKey&&!i.values?m:a(h.name||``)).add(s),!h.isPrimaryKey){if(e!==`count`)return u=e===`query`&&p&&i.values&&c.query(t(t({},i),{values:!1})),c[e].apply(this,arguments).then(function(t){if(e===`query`){if(p&&i.values)return u.then(function(e){return e=e.result,d.addKeys(e),t});var n=i.values?t.result.map(f):t.result;(i.values?d:m).addKeys(n)}else{var r,a;if(e===`openCursor`)return a=i.values,(r=t)&&Object.create(r,{key:{get:function(){return m.addKey(r.primaryKey),r.key}},primaryKey:{get:function(){var e=r.primaryKey;return m.addKey(e),e}},value:{get:function(){return a&&d.addKey(r.primaryKey),r.value}}})}return t});m.add(r)}}return c[e].apply(this,arguments)}}),h}})}};function tr(e,n,r){var i;return r.numFailures===0?n:n.type===`deleteRange`||(i=n.keys?n.keys.length:`values`in n&&n.values?n.values.length:1,r.numFailures===i)?null:(i=t({},n),a(i.keys)&&(i.keys=i.keys.filter(function(e,t){return!(t in r.failures)})),`values`in i&&a(i.values)&&(i.values=i.values.filter(function(e,t){return!(t in r.failures)})),i)}function nr(e,t){return n=e,((r=t).lower===void 0||(r.lowerOpen?0<V(n,r.lower):0<=V(n,r.lower)))&&(n=e,(r=t).upper===void 0||(r.upperOpen?V(n,r.upper)<0:V(n,r.upper)<=0));var n,r}function rr(e,t,n,r,i,o){var s,c,l,u,d,f,p;return!n||n.length===0||(s=t.query.index,c=s.multiEntry,l=t.query.range,u=r.schema.primaryKey.extractKey,d=s.extractKey,f=(s.lowLevelIndex||s).extractKey,(r=n.reduce(function(e,n){var r=e,i=[];if(n.type===`add`||n.type===`put`)for(var o=new K,s=n.values.length-1;0<=s;--s){var f,p=n.values[s],m=u(p);!o.hasKey(m)&&(f=d(p),c&&a(f)?f.some(function(e){return nr(e,l)}):nr(f,l))&&(o.addKey(m),i.push(p))}switch(n.type){case`add`:var h=new K().addKeys(t.values?e.map(function(e){return u(e)}):e),r=e.concat(t.values?i.filter(function(e){return e=u(e),!h.hasKey(e)&&(h.addKey(e),!0)}):i.map(function(e){return u(e)}).filter(function(e){return!h.hasKey(e)&&(h.addKey(e),!0)}));break;case`put`:var g=new K().addKeys(n.values.map(function(e){return u(e)}));r=e.filter(function(e){return!g.hasKey(t.values?u(e):e)}).concat(t.values?i:i.map(function(e){return u(e)}));break;case`delete`:var _=new K().addKeys(n.keys);r=e.filter(function(e){return!_.hasKey(t.values?u(e):e)});break;case`deleteRange`:var v=n.range;r=e.filter(function(e){return!nr(u(e),v)})}return r},e))===e)?e:(p=function(e,t){return V(f(e),f(t))||V(u(e),u(t))},r.sort(t.direction===`prev`||t.direction===`prevunique`?function(e,t){return p(t,e)}:p),t.limit&&t.limit<1/0&&(r.length>t.limit?r.length=t.limit:e.length===t.limit&&r.length<t.limit&&(i.dirty=!0)),o?Object.freeze(r):r)}function ir(e,t){return V(e.lower,t.lower)===0&&V(e.upper,t.upper)===0&&!!e.lowerOpen==!!t.lowerOpen&&!!e.upperOpen==!!t.upperOpen}function ar(e,t){return((e,t,n,r)=>{if(e===void 0)return t===void 0?0:-1;if(t===void 0)return 1;if((e=V(e,t))===0){if(n&&r)return 0;if(n)return 1;if(r)return-1}return e})(e.lower,t.lower,e.lowerOpen,t.lowerOpen)<=0&&0<=((e,t,n,r)=>{if(e===void 0)return t===void 0?0:1;if(t===void 0)return-1;if((e=V(e,t))===0){if(n&&r)return 0;if(n)return-1;if(r)return 1}return e})(e.upper,t.upper,e.upperOpen,t.upperOpen)}function or(e,t,n,r){e.subscribers.add(n),r.addEventListener(`abort`,function(){var r,i;e.subscribers.delete(n),e.subscribers.size===0&&(r=e,i=t,setTimeout(function(){r.subscribers.size===0&&A(i,r)},3e3))})}var sr={stack:`dbcore`,level:0,name:`Cache`,create:function(e){var n=e.schema.name;return t(t({},e),{transaction:function(t,r,i){var a,o,s=e.transaction(t,r,i);return r===`readwrite`&&(i=(a=new AbortController).signal,s.addEventListener(`abort`,(o=function(i){return function(){if(a.abort(),r===`readwrite`){for(var o=new Set,c=0,l=t;c<l.length;c++){var u=l[c],d=Ln[`idb://${n}/${u}`];if(d){var f=e.table(u),p=d.optimisticOps.filter(function(e){return e.trans===s});if(s._explicit&&i&&s.mutatedParts)for(var m=0,h=Object.values(d.queries.query);m<h.length;m++)for(var g=0,_=(b=h[m]).slice();g<_.length;g++)In((x=_[g]).obsSet,s.mutatedParts)&&(A(b,x),x.subscribers.forEach(function(e){return o.add(e)}));else if(0<p.length){d.optimisticOps=d.optimisticOps.filter(function(e){return e.trans!==s});for(var v=0,y=Object.values(d.queries.query);v<y.length;v++)for(var b,x,S,C=0,w=(b=y[v]).slice();C<w.length;C++)(x=w[C]).res!=null&&s.mutatedParts&&(i&&!x.dirty?(S=Object.isFrozen(x.res),S=rr(x.res,x.req,p,f,x,S),x.dirty?(A(b,x),x.subscribers.forEach(function(e){return o.add(e)})):S!==x.res&&(x.res=S,x.promise=L.resolve({result:S}))):(x.dirty&&A(b,x),x.subscribers.forEach(function(e){return o.add(e)})))}}}o.forEach(function(e){return e()})}}})(!1),{signal:i}),s.addEventListener(`error`,o(!1),{signal:i}),s.addEventListener(`complete`,o(!0),{signal:i})),s},table:function(r){var i=e.table(r),a=i.schema.primaryKey;return t(t({},i),{mutate:function(e){var o,s=I.trans;return!a.outbound&&s.db._options.cache!==`disabled`&&!s.explicit&&s.idbtrans.mode===`readwrite`&&(o=Ln[`idb://${n}/${r}`])?(s=i.mutate(e),e.type!==`add`&&e.type!==`put`||!(50<=e.values.length||Jn(a,e).some(function(e){return e==null}))?(o.optimisticOps.push(e),e.mutatedParts&&Bn(e.mutatedParts),s.then(function(t){0<t.numFailures&&(A(o.optimisticOps,e),(t=tr(0,e,t))&&o.optimisticOps.push(t),e.mutatedParts)&&Bn(e.mutatedParts)}),s.catch(function(){A(o.optimisticOps,e),e.mutatedParts&&Bn(e.mutatedParts)})):s.then(function(n){var r=tr(0,t(t({},e),{values:e.values.map(function(e,r){var i;return n.failures[r]?e:(x(i=(i=a.keyPath)!=null&&i.includes(`.`)?O(e):t({},e),a.keyPath,n.results[r]),i)})}),n);o.optimisticOps.push(r),queueMicrotask(function(){return e.mutatedParts&&Bn(e.mutatedParts)})}),s):i.mutate(e)},query:function(e){var t,a,o,s,c,l,u;return Qn(I,i)&&$n(`query`,e)?(t=(o=I.trans)?.db._options.cache===`immutable`,a=(o=I).requery,o=o.signal,l=((e,t,n,r)=>{var i=Ln[`idb://${e}/${t}`];if(!i)return[];if(!(e=i.queries[n]))return[null,!1,i,null];var a=e[(r.query?r.query.index.name:null)||``];if(!a)return[null,!1,i,null];switch(n){case`query`:var o=(s=r.direction)??`next`,s=a.find(function(e){return e.req.limit===r.limit&&e.req.values===r.values&&(e.req.direction??`next`)===o&&ir(e.req.query.range,r.query.range)});return s?[s,!0,i,a]:[a.find(function(e){return(`limit`in e.req?e.req.limit:1/0)>=r.limit&&(e.req.direction??`next`)===o&&(!r.values||e.req.values)&&ar(e.req.query.range,r.query.range)}),!1,i,a];case`count`:return s=a.find(function(e){return ir(e.req.query.range,r.query.range)}),[s,!!s,i,a]}})(n,r,`query`,e),u=l[0],s=l[2],c=l[3],u&&l[1]?u.obsSet=e.obsSet:(l=i.query(e).then(function(e){var n=e.result;if(u&&(u.res=n),t){for(var r=0,i=n.length;r<i;++r)Object.freeze(n[r]);Object.freeze(n)}return e}).catch(function(e){return c&&u&&A(c,u),Promise.reject(e)}),u={obsSet:e.obsSet,promise:l,subscribers:new Set,type:`query`,req:e,dirty:!1},c?c.push(u):(c=[u],(s||=Ln[`idb://${n}/${r}`]={queries:{query:{},count:{}},objs:new Map,optimisticOps:[],unsignaledParts:{}}).queries.query[e.query.index.name||``]=c)),or(u,c,a,o),u.promise.then(function(n){return n=rr(n.result,e,s?.optimisticOps,i,u,t),{result:t?n:O(n)}})):i.query(e)}})}})}};function cr(e,t){return new Proxy(e,{get:function(e,n,r){return n===`db`?t:Reflect.get(e,n,r)}})}q.prototype.version=function(e){if(isNaN(e)||e<.1)throw new M.Type(`Given version is not a positive number`);if(e=Math.round(10*e)/10,this.idbdb||this._state.isBeingOpened)throw new M.Schema(`Cannot add version when database is open`);this.verno=Math.max(this.verno,e);var t=this._versions,n=t.filter(function(t){return t._cfg.version===e})[0];return n||(n=new this.Version(e),t.push(n),t.sort(pn),n.stores({}),this._state.autoSchema=!1),n},q.prototype._whenReady=function(e){var t=this;return this.idbdb&&(this._state.openComplete||I.letThrough||this._vip)?e():new L(function(e,n){if(t._state.openComplete)return n(new M.DatabaseClosed(t._state.dbOpenError));if(!t._state.isBeingOpened){if(!t._state.autoOpen)return void n(new M.DatabaseClosed);t.open().catch(N)}t._state.dbReadyPromise.then(e,n)}).then(e)},q.prototype.use=function(e){var t=e.stack,n=e.create,r=e.level,e=e.name,i=(e&&this.unuse({stack:t,name:e}),this._middlewares[t]||(this._middlewares[t]=[]));return i.push({stack:t,create:n,level:r??10,name:e}),i.sort(function(e,t){return e.level-t.level}),this},q.prototype.unuse=function(e){var t=e.stack,n=e.name,r=e.create;return t&&this._middlewares[t]&&(this._middlewares[t]=this._middlewares[t].filter(function(e){return r?e.create!==r:!!n&&e.name!==n})),this},q.prototype.open=function(){var e=this;return st(Pe,function(){return Un(e)})},q.prototype._close=function(){this.on.close.fire(new CustomEvent(`close`));var e=this._state;if(wn.remove(this),this.idbdb){try{this.idbdb.close()}catch{}this.idbdb=null}e.isBeingOpened||(e.dbReadyPromise=new L(function(t){e.dbReadyResolve=t}),e.openCanceller=new L(function(t,n){e.cancelOpen=n}))},q.prototype.close=function(e){var e=(e===void 0?{disableAutoOpen:!0}:e).disableAutoOpen,t=this._state;e?(t.isBeingOpened&&t.cancelOpen(new M.DatabaseClosed),this._close(),t.autoOpen=!1,t.dbOpenError=new M.DatabaseClosed):(this._close(),t.autoOpen=this._options.autoOpen||t.isBeingOpened,t.openComplete=!1,t.dbOpenError=null)},q.prototype.delete=function(e){var t=this,n=(e===void 0&&(e={disableAutoOpen:!0}),0<arguments.length&&typeof arguments[0]!=`object`),r=this._state;return new L(function(i,a){function o(){t.close(e);var n=t._deps.indexedDB.deleteDatabase(t.name);n.onsuccess=R(function(){var e=t._deps,n=t.name,r;En(r=e.indexedDB)||n===pt||Tn(r,e.IDBKeyRange).delete(n).catch(N),i()}),n.onerror=qt(a),n.onblocked=t._fireOnBlocked}if(n)throw new M.InvalidArgument(`Invalid closeOptions argument to db.delete()`);r.isBeingOpened?r.dbReadyPromise.then(o):o()})},q.prototype.backendDB=function(){return this.idbdb},q.prototype.isOpen=function(){return this.idbdb!==null},q.prototype.hasBeenClosed=function(){var e=this._state.dbOpenError;return e&&e.name===`DatabaseClosed`},q.prototype.hasFailed=function(){return this._state.dbOpenError!==null},q.prototype.dynamicallyOpened=function(){return this._state.autoSchema},Object.defineProperty(q.prototype,"tables",{get:function(){var e=this;return i(this._allTables).map(function(t){return e._allTables[t]})},enumerable:!1,configurable:!0}),q.prototype.transaction=function(){var e=function(e,t,n){var r=arguments.length;if(r<2)throw new M.InvalidArgument(`Too few arguments`);for(var i=Array(r-1);--r;)i[r-1]=arguments[r];return n=i.pop(),[e,w(i),n]}.apply(this,arguments);return this._transaction.apply(this,e)},q.prototype._transaction=function(e,t,n){var r,i,a=this,o=I.trans,s=(o&&o.db===this&&e.indexOf(`!`)===-1||(o=null),e.indexOf(`?`)!==-1);e=e.replace(`!`,``).replace(`?`,``);try{if(i=t.map(function(e){if(e=e instanceof a.Table?e.name:e,typeof e!=`string`)throw TypeError(`Invalid table argument to Dexie.transaction(). Only Table or String are allowed`);return e}),e==`r`||e===mt)r=mt;else{if(e!=`rw`&&e!=ht)throw new M.InvalidArgument(`Invalid transaction mode: `+e);r=ht}if(o){if(o.mode===mt&&r===ht){if(!s)throw new M.SubTransaction(`Cannot enter a sub-transaction with READWRITE mode when parent transaction is READONLY`);o=null}o&&i.forEach(function(e){if(o&&o.storeNames.indexOf(e)===-1){if(!s)throw new M.SubTransaction(`Table `+e+` not included in parent transaction.`);o=null}}),s&&o&&!o.active&&(o=null)}}catch(e){return o?o._promise(null,function(t,n){n(e)}):B(e)}var c=function e(t,n,r,i,a){return L.resolve().then(function(){var o=I.transless||I,s=t._createTransaction(n,r,t._dbSchema,i),o=(s.explicit=!0,{trans:s,transless:o});if(i)s.idbtrans=i.idbtrans;else try{s.create(),s.idbtrans._explicit=!0,t._state.PR1398_maxLoop=3}catch(i){return i.name===de.InvalidState&&t.isOpen()&&0<--t._state.PR1398_maxLoop?(console.warn(`Dexie: Need to reopen db`),t.close({disableAutoOpen:!1}),t.open().then(function(){return e(t,n,r,null,a)})):B(i)}var c,l=ae(a),o=(l&&nt(),L.follow(function(){var e;(c=a.call(s,s))&&(l?(e=rt.bind(null,null),c.then(e,e)):typeof c.next==`function`&&typeof c.throw==`function`&&(c=Wn(c)))},o));return(c&&typeof c.then==`function`?L.resolve(c).then(function(e){return s.active?e:B(new M.PrematureCommit(`Transaction committed too early. See http://bit.ly/2kdckMn`))}):o.then(function(){return c})).then(function(e){return i&&s._resolve(),s._completion.then(function(){return e})}).catch(function(e){return s._reject(e),B(e)})})}.bind(null,this,r,i,o,n);return o?o._promise(r,c,`lock`):I.trans?st(I.transless,function(){return a._whenReady(c)}):this._whenReady(c)},q.prototype.table=function(e){if(l(this._allTables,e))return this._allTables[e];throw new M.InvalidTable(`Table ${e} does not exist`)};var lr=q;function q(e,n){var r,i,a,o,s,c=this,l=(this._middlewares={},this.verno=0,q.dependencies),l=(this._options=n=t({addons:q.addons,autoOpen:!0,indexedDB:l.indexedDB,IDBKeyRange:l.IDBKeyRange,cache:`cloned`,maxConnections:1e3},n),this._deps={indexedDB:n.indexedDB,IDBKeyRange:n.IDBKeyRange},n.addons),u=(this._dbSchema={},this._versions=[],this._storeNames=[],this._allTables={},this.idbdb=null,this._novip=this,{dbOpenError:null,isBeingOpened:!1,onReadyBeingFired:null,openComplete:!1,dbReadyResolve:N,dbReadyPromise:null,cancelOpen:N,openCanceller:null,autoSchema:!0,PR1398_maxLoop:3,autoOpen:n.autoOpen}),d=(u.dbReadyPromise=new L(function(e){u.dbReadyResolve=e}),u.openCanceller=new L(function(e,t){u.cancelOpen=t}),this._state=u,this.name=e,this.on=Dt(this,`populate`,`blocked`,`versionchange`,`close`,{ready:[be,N]}),this.once=function(e,t){var n=function(){var r=[...arguments];c.on(e).unsubscribe(n),t.apply(c,r)};return c.on(e,n)},this.on.ready.subscribe=_(this.on.ready.subscribe,function(e){return function(t,n){q.vip(function(){var r,i=c._state;i.openComplete?(i.dbOpenError||L.resolve().then(t),n&&e(t)):i.onReadyBeingFired?(i.onReadyBeingFired.push(t),n&&e(t)):(e(t),r=c,n||e(function e(){r.on.ready.unsubscribe(t),r.on.ready.unsubscribe(e)}))})}}),this.Collection=(r=this,Ot(It.prototype,function(e,t){this.db=r;var n=_t,i=null;if(t)try{n=t()}catch(e){i=e}var t=e._ctx,e=t.table,a=e.hook.reading.fire;this._ctx={table:e,index:t.index,isPrimKey:!t.index||e.schema.primKey.keyPath&&t.index===e.schema.primKey.name,range:n,keysOnly:!1,dir:`next`,unique:``,algorithm:null,filter:null,replayFilter:null,justLimit:!0,isMatch:null,offset:0,limit:1/0,error:i,or:t.or,valueMapper:a===me?null:a}})),this.Table=(i=this,Ot(Et.prototype,function(e,t,n){this.db=i,this._tx=n,this.name=e,this.schema=t,this.hook=i._allTables[e]?i._allTables[e].hook:Dt(null,{creating:[_e,N],reading:[he,me],updating:[P,N],deleting:[ve,N]})})),this.Transaction=(a=this,Ot(Qt.prototype,function(e,t,n,r,i){var o=this;e!==`readonly`&&t.forEach(function(e){e=(e=n[e])?.yProps,e&&(t=t.concat(e.map(function(e){return e.updatesTable})))}),this.db=a,this.mode=e,this.storeNames=t,this.schema=n,this.chromeTransactionDurability=r,this.idbtrans=null,this.on=Dt(this,`complete`,`error`,`abort`),this.parent=i||null,this.active=!0,this._reculock=0,this._blockedFuncs=[],this._resolve=null,this._reject=null,this._waitingFor=null,this._waitingQueue=null,this._spinCount=0,this._completion=new L(function(e,t){o._resolve=e,o._reject=t}),this._completion.then(function(){o.active=!1,o.on.complete.fire()},function(e){var t=o.active;return o.active=!1,o.on.error.fire(e),o.parent?o.parent._reject(e):t&&o.idbtrans&&o.idbtrans.abort(),B(e)})})),this.Version=(o=this,Ot(Sn.prototype,function(e){this.db=o,this._cfg={version:e,storesSource:null,dbschema:{},tables:{},contentUpgrade:null}})),this.WhereClause=(s=this,Ot(Gt.prototype,function(e,t,n){if(this.db=s,this._ctx={table:e,index:t===`:id`?null:t,or:n},this._cmp=this._ascending=V,this._descending=function(e,t){return V(t,e)},this._max=function(e,t){return 0<V(e,t)?e:t},this._min=function(e,t){return V(e,t)<0?e:t},this._IDBKeyRange=s._deps.IDBKeyRange,!this._IDBKeyRange)throw new M.MissingAPI})),this.on(`versionchange`,function(e){0<e.newVersion?console.warn(`Another connection wants to upgrade database '${c.name}'. Closing db now to resume the upgrade.`):console.warn(`Another connection wants to delete database '${c.name}'. Closing db now to resume the delete request.`),c.close({disableAutoOpen:!1})}),this.on(`blocked`,function(e){!e.newVersion||e.newVersion<e.oldVersion?console.warn(`Dexie.delete('${c.name}') was blocked`):console.warn(`Upgrade '${c.name}' blocked by other connection holding version ${e.oldVersion/10}`)}),this._maxKey=rn(n.IDBKeyRange),this._createTransaction=function(e,t,n,r){return new c.Transaction(e,t,n,c._options.chromeTransactionDurability,r)},this._fireOnBlocked=function(e){c.on(`blocked`).fire(e),wn.toArray().filter(function(e){return e.name===c.name&&e!==c&&!e._state.vcFired}).map(function(t){return t.on(`versionchange`).fire(e)})},this.use(Zn),this.use(sr),this.use(er),this.use(Kn),this.use(Yn),new Proxy(this,{get:function(e,t,n){var r;return t===`_vip`||(t===`table`?function(e){return cr(c.table(e),d)}:(r=Reflect.get(e,t,n))instanceof Et?cr(r,d):t===`tables`?r.map(function(e){return cr(e,d)}):t===`_createTransaction`?function(){return cr(r.apply(this,arguments),d)}:r)}}));this.vip=d,l.forEach(function(e){return e(c)})}var ur,Te=typeof Symbol<`u`&&`observable`in Symbol?Symbol.observable:`@@observable`,dr=(fr.prototype.subscribe=function(e,t,n){return this._subscribe(e&&typeof e!=`function`?e:{next:e,error:t,complete:n})},fr.prototype[Te]=function(){return this},fr);function fr(e){this._subscribe=e}try{ur={indexedDB:r.indexedDB||r.mozIndexedDB||r.webkitIndexedDB||r.msIndexedDB,IDBKeyRange:r.IDBKeyRange||r.webkitIDBKeyRange}}catch{ur={indexedDB:null,IDBKeyRange:null}}function pr(e){var t,n=!1,r=new dr(function(r){var i=ae(e),a,o=!1,s={},c={},l={get closed(){return o},unsubscribe:function(){o||(o=!0,a&&a.abort(),u&&Zt.storagemutated.unsubscribe(p))}},u=(r.start&&r.start(l),!1),d=function(){return lt(m)};function f(){return In(c,s)}var p=function(e){Fn(s,e),f()&&d()},m=function(){var l,m,h;!o&&ur.indexedDB&&(s={},l={},a&&a.abort(),a=new AbortController,h=(t=>{var n=Ge();try{i&&nt();var r=tt(e,t);return r=i?r.finally(rt):r}finally{n&&Ke()}})(m={subscr:l,signal:a.signal,requery:d,querier:e,trans:null}),u||=(Zt.storagemutated.subscribe(p),!0),Promise.resolve(h).then(function(e){n=!0,t=e,o||m.signal.aborted||(f()||(c=l,f())?d():(s={},lt(function(){return!o&&r.next&&r.next(e)})))},function(e){n=!1,[`DatabaseClosedError`,`AbortError`].includes(e?.name)||o||lt(function(){o||r.error&&r.error(e)})}))};return setTimeout(d,0),l});return r.hasValue=function(){return n},r.getValue=function(){return t},r}var mr=lr;function hr(e){var t=_r;try{_r=!0,Zt.storagemutated.fire(e),Vn(e,!0)}finally{_r=t}}u(mr,t(t({},T),{delete:function(e){return new mr(e,{addons:[]}).delete()},exists:function(e){return new mr(e,{addons:[]}).open().then(function(e){return e.close(),!0}).catch(`NoSuchDatabaseError`,function(){return!1})},getDatabaseNames:function(e){try{return t=mr.dependencies,n=t.indexedDB,t=t.IDBKeyRange,(En(n)?Promise.resolve(n.databases()).then(function(e){return e.map(function(e){return e.name}).filter(function(e){return e!==pt})}):Tn(n,t).toCollection().primaryKeys()).then(e)}catch{return B(new M.MissingAPI)}var t,n},defineClass:function(){return function(e){o(this,e)}},ignoreTransaction:function(e){return I.trans?st(I.transless||Pe,e):e()},vip:Dn,async:function(e){return function(){try{var t=Wn(e.apply(this,arguments));return t&&typeof t.then==`function`?t:L.resolve(t)}catch(e){return B(e)}}},spawn:function(e,t,n){try{var r=Wn(e.apply(n,t||[]));return r&&typeof r.then==`function`?r:L.resolve(r)}catch(e){return B(e)}},currentTransaction:{get:function(){return I.trans||null}},waitFor:function(e,t){return e=L.resolve(typeof e==`function`?mr.ignoreTransaction(e):e).timeout(t||6e4),I.trans?I.trans.waitFor(e):e},Promise:L,debug:{get:function(){return xe},set:function(e){F(e)}},derive:p,extend:o,props:u,override:_,Events:Dt,on:Zt,liveQuery:pr,extendObservabilitySet:Fn,getByKeyPath:b,setByKeyPath:x,delByKeyPath:function(e,t){typeof t==`string`?x(e,t,void 0):`length`in t&&[].map.call(t,function(t){x(e,t,void 0)})},shallowClone:S,deepClone:O,getObjectDiff:qn,cmp:V,asap:y,minKey:-1/0,addons:[],connections:{get:wn.toArray},errnames:de,dependencies:ur,cache:Ln,semVer:`4.4.4`,version:`4.4.4`.split(`.`).map(function(e){return parseInt(e)}).reduce(function(e,t,n){return e+t/10**(2*n)})})),mr.maxKey=rn(mr.dependencies.IDBKeyRange),typeof dispatchEvent<`u`&&typeof addEventListener<`u`&&(Zt(Yt,function(e){_r||=(e=new CustomEvent(Xt,{detail:e}),_r=!0,dispatchEvent(e),!1)}),addEventListener(Xt,function(e){e=e.detail,_r||hr(e)}));var gr,_r=!1,vr=function(){};return typeof BroadcastChannel<`u`&&((vr=function(){(gr=new BroadcastChannel(Xt)).onmessage=function(e){return e.data&&hr(e.data)}})(),typeof gr.unref==`function`&&gr.unref(),Zt(Yt,function(e){_r||gr.postMessage(e)})),typeof addEventListener<`u`&&(addEventListener(`pagehide`,function(e){if(!lr.disableBfCache&&e.persisted){xe&&console.debug(`Dexie: handling persisted pagehide`),gr?.close();for(var t=0,n=wn.toArray();t<n.length;t++)n[t].close({disableAutoOpen:!1})}}),addEventListener(`pageshow`,function(e){!lr.disableBfCache&&e.persisted&&(xe&&console.debug(`Dexie: handling persisted pageshow`),vr(),hr({all:new K(-1/0,[[]])}))})),L.rejectionMapper=function(e,t){return!e||e instanceof se||e instanceof TypeError||e instanceof SyntaxError||!e.name||!pe[e.name]?e:(t=new pe[e.name](t||e.message,e),`stack`in e&&f(t,`stack`,{get:function(){return this.inner.stack}}),t)},F(xe),t(lr,Object.freeze({__proto__:null,DEFAULT_MAX_CONNECTIONS:1e3,Dexie:lr,Entity:yt,PropModification:Ct,RangeSet:K,add:function(e){return new Ct({add:e})},cmp:V,default:lr,liveQuery:pr,mergeRanges:An,rangesOverlap:jn,remove:function(e){return new Ct({remove:e})},replacePrefix:function(e,t){return new Ct({replacePrefix:[e,t]})}}),{default:lr}),lr})}))(),1),Ds=Symbol.for(`Dexie`),Os=globalThis[Ds]||(globalThis[Ds]=Es.default);if(Es.default.semVer!==Os.semVer)throw Error(`Two different versions of Dexie loaded in the same app: ${Es.default.semVer} and ${Os.semVer}`);var{liveQuery:ks,mergeRanges:As,rangesOverlap:js,RangeSet:Ms,cmp:Ns,Entity:Ps,PropModification:Fs,replacePrefix:Is,add:Ls,remove:Rs,DexieYProvider:zs}=Os,Bs=new class extends Os{scrollAnchors;toolSessionCollapses;diffCollapses;inputStates;modelOptionsCaches;constructor(){super(`LotusStorage`),this.version(1).stores({scrollAnchors:`sessionId, ts`,toolSessionCollapses:`id, sessionId, updatedAt`,diffCollapses:`sessionId, updatedAt`,inputStates:`sessionId, updatedAt`,modelOptionsCaches:`provider, timestamp`})}},Vs=class e{static instance;db=Bs;static getInstance(){return e.instance||=new e,e.instance}async saveScrollAnchor(e,t){try{await this.db.scrollAnchors.put({sessionId:e,anchorId:t.anchorId,offsetPx:t.offsetPx,ts:t.ts,indexHint:t.indexHint,createdAt:t.createdAt})}catch(n){console.warn(`[StorageManager] IndexedDB save failed, falling back to localStorage`,n);try{localStorage.setItem(`chat_scroll_anchor_v2:${e}`,JSON.stringify(t))}catch{}}}async loadScrollAnchor(e){try{let t=await this.db.scrollAnchors.get(e);return t?{v:1,anchorId:t.anchorId,offsetPx:t.offsetPx,ts:t.ts,indexHint:t.indexHint,createdAt:t.createdAt}:null}catch{try{let t=localStorage.getItem(`chat_scroll_anchor_v2:${e}`);if(!t)return null;let n=JSON.parse(t);if(n&&n.v===1&&typeof n.anchorId==`string`)return n}catch{}return null}}async clearScrollAnchor(e){try{await this.db.scrollAnchors.delete(e)}catch{}try{localStorage.removeItem(`chat_scroll_anchor_v2:${e}`)}catch{}}async saveToolSessionCollapse(e,t,n){try{await this.db.toolSessionCollapses.put({id:`${e}:${t}`,sessionId:e,toolSessionId:t,isExpanded:n.isExpanded,expandedTools:n.expandedTools,updatedAt:Date.now()})}catch(r){console.warn(`[StorageManager] saveToolSessionCollapse failed`,r);try{localStorage.setItem(`chat-session-tool-collapse:${e}:${t}`,JSON.stringify(n))}catch{}}}async loadToolSessionCollapse(e,t){try{let n=await this.db.toolSessionCollapses.get(`${e}:${t}`);return n?{isExpanded:n.isExpanded,expandedTools:n.expandedTools}:null}catch{try{let n=localStorage.getItem(`chat-session-tool-collapse:${e}:${t}`);if(!n)return null;let r=JSON.parse(n);if(r&&typeof r.isExpanded==`boolean`)return r}catch{}return null}}async saveDiffCollapse(e,t){try{await this.db.diffCollapses.put({sessionId:e,isExpanded:t.isExpanded,expandedFiles:t.expandedFiles,updatedAt:Date.now()})}catch(n){console.warn(`[StorageManager] saveDiffCollapse failed`,n);try{localStorage.setItem(`chat-session-diff-collapse:${e}`,JSON.stringify(t))}catch{}}}async loadDiffCollapse(e){try{let t=await this.db.diffCollapses.get(e);return t?{isExpanded:t.isExpanded,expandedFiles:t.expandedFiles}:null}catch{try{let t=localStorage.getItem(`chat-session-diff-collapse:${e}`);if(!t)return null;let n=JSON.parse(t);if(n&&typeof n.isExpanded==`boolean`)return n}catch{}return null}}async saveInputReasoning(e,t){try{let n=await this.db.inputStates.get(e);await this.db.inputStates.put({sessionId:e,reasoningEffort:t,content:n?.content,referenceText:n?.referenceText,updatedAt:Date.now()})}catch(n){console.warn(`[StorageManager] saveInputReasoning failed`,n);try{let n=localStorage.getItem(`chat_input_reasoning_by_session_v1`),r=n?JSON.parse(n):{};r[e]=t,localStorage.setItem(`chat_input_reasoning_by_session_v1`,JSON.stringify(r))}catch{}}}async loadInputReasoning(e){try{return(await this.db.inputStates.get(e))?.reasoningEffort??null}catch{try{let t=localStorage.getItem(`chat_input_reasoning_by_session_v1`);return t?JSON.parse(t)[e]??null:null}catch{return null}}}async saveLastUsedReasoningEffort(e){try{await this.db.inputStates.put({sessionId:`__last_used__`,reasoningEffort:e,updatedAt:Date.now()})}catch{try{localStorage.setItem(`chat_input_reasoning_last_used_v1`,e)}catch{}}}async loadLastUsedReasoningEffort(){try{return(await this.db.inputStates.get(`__last_used__`))?.reasoningEffort??null}catch{try{return localStorage.getItem(`chat_input_reasoning_last_used_v1`)}catch{return null}}}async saveModelOptionsCache(e,t,n){try{await this.db.modelOptionsCaches.put({provider:e,options:t,timestamp:n})}catch(r){console.warn(`[StorageManager] saveModelOptionsCache failed`,r);try{localStorage.setItem(`chat-model-options-cache-v1:${e}`,JSON.stringify({timestamp:n,options:t}))}catch{}}}async loadModelOptionsCache(e){try{let t=await this.db.modelOptionsCaches.get(e);return t?{options:t.options,timestamp:t.timestamp}:null}catch{try{let t=localStorage.getItem(`chat-model-options-cache-v1:${e}`);if(!t)return null;let n=JSON.parse(t);if(n&&Array.isArray(n.options))return{options:n.options,timestamp:n.timestamp}}catch{}return null}}async clearSessionData(e){try{await Promise.all([this.db.scrollAnchors.delete(e),this.db.diffCollapses.delete(e),this.db.toolSessionCollapses.where(`sessionId`).equals(e).delete(),this.db.inputStates.delete(e)])}catch{}}async cleanupStaleData(e=30){let t=Date.now()-e*24*60*60*1e3;try{await Promise.all([this.db.scrollAnchors.where(`ts`).below(t).delete(),this.db.toolSessionCollapses.where(`updatedAt`).below(t).delete(),this.db.diffCollapses.where(`updatedAt`).below(t).delete(),this.db.inputStates.where(`updatedAt`).below(t).delete(),this.db.modelOptionsCaches.where(`timestamp`).below(t).delete()])}catch{}}async getStats(){try{let[e,t,n,r,i]=await Promise.all([this.db.scrollAnchors.count(),this.db.toolSessionCollapses.count(),this.db.diffCollapses.count(),this.db.inputStates.count(),this.db.modelOptionsCaches.count()]);return{scrollAnchors:e,toolSessionCollapses:t,diffCollapses:n,inputStates:r,modelOptionsCaches:i}}catch{return{scrollAnchors:0,toolSessionCollapses:0,diffCollapses:0,inputStates:0,modelOptionsCaches:0}}}},Hs=`chat_input_reasoning_by_session_v1`,Us=`chat_input_reasoning_last_used_v1`,Ws={content:``,contentRevision:0,referenceText:null,attachments:[],reasoningEffort:`medium`},Gs=0,Ks=()=>(Gs+=1,Gs),qs=e=>e===`low`||e===`medium`||e===`high`||e===`xhigh`||e===`max`,Js=()=>{if(typeof window>`u`)return{};try{let e=localStorage.getItem(Hs);if(!e)return{};let t=JSON.parse(e),n={};for(let[e,r]of Object.entries(t||{}))qs(r)&&(n[e]=r);return n}catch{return{}}},Ys=e=>{if(!(typeof window>`u`))try{localStorage.setItem(Hs,JSON.stringify(e))}catch{}},Xs=()=>{if(!(typeof window>`u`))try{let e=localStorage.getItem(Us);return qs(e)?e:void 0}catch{return}},Zs=e=>{if(!(typeof window>`u`))try{localStorage.setItem(Us,e)}catch{}},Qs=e=>{let t=Js();return qs(t[e])?t[e]:Xs()},$s=e=>({...Ws,reasoningEffort:Qs(e)??Ws.reasoningEffort}),ec=(e,t)=>({inputStates:{},setInputContent:(t,n)=>e(e=>({inputStates:{...e.inputStates,[t]:{...e.inputStates[t]||$s(t),content:n,contentRevision:Ks()}}})),setInputContentIfRevision:(t,n,r)=>{let i=!1;return e(e=>{let a=e.inputStates[t]||$s(t);return a.contentRevision===n?(i=!0,{inputStates:{...e.inputStates,[t]:{...a,content:r,contentRevision:Ks()}}}):e}),i},moveInputContentIfRevision:(t,n,r)=>{let i=!1;return e(e=>{let a=e.inputStates[t]||$s(t),o=e.inputStates[r]||$s(r);return a.contentRevision!==n||o.content?e:(i=!0,{inputStates:{...e.inputStates,[t]:{...a,content:``,contentRevision:Ks()},[r]:{...o,content:a.content,contentRevision:Ks()}}})}),i},setReferenceText:(t,n)=>e(e=>({inputStates:{...e.inputStates,[t]:{...e.inputStates[t]||$s(t),referenceText:n}}})),setAttachments:(t,n)=>e(e=>({inputStates:{...e.inputStates,[t]:{...e.inputStates[t]||$s(t),attachments:n}}})),setInputReasoningEffort:(t,n)=>{e(e=>({inputStates:{...e.inputStates,[t]:{...e.inputStates[t]||$s(t),reasoningEffort:n}}}));let r=Js();r[t]=n,Ys(r),Zs(n);let i=Vs.getInstance();i.saveInputReasoning(t,n).catch(()=>{}),i.saveLastUsedReasoningEffort(n).catch(()=>{})},clearInputState:t=>e(e=>{let{[t]:n,...r}=e.inputStates;return{inputStates:r}}),getInputState:e=>t().inputStates[e]||$s(e)}),tc=e=>e===`killed`?`killed`:e===`error`?`error`:`completed`,nc=e=>({backgroundBash:{},setBashCompleted:(t,n,r)=>{if(!t)return;let i=tc(n);e(e=>{let n=e.backgroundBash[t];return n&&n.status===i&&n.exitCode===r?e:{backgroundBash:{...e.backgroundBash,[t]:{status:i,exitCode:r}}}})}}),rc=(e,t)=>{let n=new Map,r=0,i=e=>t().chats.find(t=>t.id===e),a=(e,r)=>n.get(e)===r&&t().permissionModeRequests[e]?.operationId===r.id&&!!i(e),o=(t,n,r,i)=>{a(t,n)&&e(e=>({permissionModeRequests:{...e.permissionModeRequests,[t]:{status:r,operationId:n.id,error:i}}}))},s=(t,i)=>{let a={id:++r};return n.set(t,a),e(e=>({permissionModeRequests:{...e.permissionModeRequests,[t]:{status:i,operationId:a.id}}})),a},c=(t,n,r,s,c=`ready`)=>{if(!a(t,n))return!1;let l=i(t),u=Gn(l.config.permissionModeEtag),d=Gn(r.etag);return r.sessionId!==t||!Wn(r.mode)||d===null||u!==null&&(d<u||d===u&&l.config.permissionMode!==r.mode)?(o(t,n,`unconfirmed`,`stale`),!1):(e(e=>({chats:e.chats.map(e=>e.id===t?{...e,config:{...e.config,permissionMode:r.mode,permissionModeEtag:r.etag,bypassPermissions:r.mode!=="default"}}:e),permissionModeRequests:{...e.permissionModeRequests,[t]:{status:c===`ready`&&n.reconcileRequested?`loading`:c,operationId:n.id,error:s}}})),!0)},l=async(e,r)=>{for(;a(e,r)&&r.reconcileRequested;){r.reconcileRequested=!1;let n=t().permissionModeRequests[e]?.error;o(e,r,`loading`,n);try{c(e,r,await or.getSessionPermissionMode(e),n)}catch(t){let n=t instanceof Kn;o(e,r,n?`unsupported`:`unconfirmed`,n?`unsupported`:`unconfirmed`)}}n.get(e)===r&&n.delete(e)};return{permissionModeRequests:{},refreshSessionPermissionMode:e=>{let t=n.get(e);if(t)return t.promise??Promise.resolve();if(!i(e))return Promise.resolve();let r=s(e,`loading`);return r.promise=(async()=>{try{c(e,r,await or.getSessionPermissionMode(e))}catch(t){let n=t instanceof Kn;o(e,r,n?`unsupported`:`unconfirmed`,n?`unsupported`:`unconfirmed`)}})().finally(()=>l(e,r)),r.promise},changeSessionPermissionMode:(r,u,d)=>{let f=i(r),p=t().permissionModeRequests[r];if(n.has(r)||!f||p?.status!==`ready`||!Wn(u)||Gn(d)===null)return Promise.resolve();if(f.config.permissionModeEtag!==d)return e(e=>({permissionModeRequests:{...e.permissionModeRequests,[r]:{...p,error:`changed`}}})),Promise.resolve();if(f.config.permissionMode===u)return Promise.resolve();let m=f.config.permissionMode,h=s(r,`saving`);return h.promise=(async()=>{let e;try{e=await or.getSessionPermissionMode(r)}catch(e){let t=e instanceof Kn;o(r,h,t?`unsupported`:`unconfirmed`,t?`unsupported`:`unconfirmed`);return}let t=e.mode!==m;if(!(!c(r,h,e,t?`changed`:void 0,t?`ready`:`saving`)||t))try{let t=await or.patchSessionPermissionMode(r,u,e.etag);c(r,h,t,t.mode===u?void 0:`changed`)}catch(e){if(!a(r,h))return;let t=Ee(e)&&e.status===412?`conflict`:Ee(e)&&e.status<500?`rejected`:`ambiguous`;try{h.reconcileRequested=!1,c(r,h,await or.getSessionPermissionMode(r),t)}catch{o(r,h,`unconfirmed`,`unconfirmed`)}}})().finally(()=>l(r,h)),h.promise},reconcileSessionPermissionModes:e=>{let r=new Set(t().chats.map(e=>e.id));t().resetSessionPermissionModes(Object.keys(t().permissionModeRequests).filter(e=>!r.has(e)));for(let r of e){let e=t().permissionModeRequests[r.id],a=i(r.id);if(!e||!a)continue;let o=Wn(r.permission_mode)!==a.config.permissionMode,s=n.get(r.id);if(s){(o||!a.config.permissionModeEtag)&&(s.reconcileRequested=!0);continue}(e.status!==`ready`||!a.config.permissionModeEtag||o)&&t().refreshSessionPermissionMode(r.id)}},resetSessionPermissionModes:r=>{let i=r??[...new Set([...n.keys(),...Object.keys(t().permissionModeRequests)])];if(i.length!==0){for(let e of i)n.delete(e);e(e=>{let t={...e.permissionModeRequests};for(let e of i)delete t[e];return{permissionModeRequests:t}})}}}},ic=`lotus_notify_enabled_v1`;function ac(){try{return localStorage.getItem(ic)===`1`}catch{return!1}}function oc(e){try{localStorage.setItem(ic,e?`1`:`0`)}catch{}}function sc(){return typeof Notification>`u`?`unsupported`:Notification.permission}async function cc(){if(typeof Notification>`u`)return!1;if(Notification.permission===`granted`)return!0;try{return await Notification.requestPermission()===`granted`}catch{return!1}}function lc(e,t){if(ac()&&!(typeof Notification>`u`||Notification.permission!==`granted`))try{new Notification(e,{body:t,icon:`/vite.svg`})}catch{}}var uc=`lotus_account_feed_cursor_v1`,dc=400,fc=/^[1-9][0-9]*$/,pc=null,mc=null,hc=()=>pc!==null&&!mn(),gc=e=>{if(!e||!fc.test(e))return 0;let t=Number(e);return Number.isSafeInteger(t)&&t>0&&String(t)===e?t:0},_c=()=>{try{return gc(localStorage.getItem(uc))}catch{return 0}},vc=e=>{if(!(!Number.isSafeInteger(e)||e<=0))try{if(e<=gc(localStorage.getItem(uc)))return;localStorage.setItem(uc,String(e))}catch{}},yc=()=>{try{localStorage.removeItem(uc)}catch{}},bc=()=>{mc&&=(clearTimeout(mc),null)},xc=()=>{try{Hc.getState().refreshChatsNow().catch(e=>console.warn(`[AccountFeed] Failed to resync sessions after reset:`,e))}catch(e){console.warn(`[AccountFeed] Failed to resync sessions after reset:`,e)}},Sc=()=>{mc||=setTimeout(()=>{mc=null,Hc.getState().refreshSessionsIndex()},dc)},Cc=new Set([`message_appended`,`task_list_updated`,`task_list_item_progress`,`task_list_completed`,`complete`,`cancelled`,`error`,`execution_started`,`need_clarification`]),wc=e=>{let{event:t}=e,n=Hc.getState(),r=e.session_id??t.session_id;if(t.type===`notification`){let e=t;(typeof document>`u`||document.hidden||r!==n.currentSessionId)&&lc(e.title||`Bodhi`,e.body);return}switch(r&&r===n.currentSessionId&&Cc.has(t.type)&&n.reconcileOpenSession(r,t.type),r&&r===n.currentSessionId&&t.type===`execution_started`&&!Ac(r)(n)&&n.refreshChatsNow(),t.type){case`session_title_updated`:r&&typeof t.title==`string`&&n.applyServerTitle(r,t.title,t.title_version??0),Sc();break;case`session_pinned_updated`:r&&typeof t.pinned==`boolean`&&n.applyServerPinned(r,t.pinned,t.updated_at??e.ts),Sc();break;default:Sc();break}},Tc=()=>{if(pc||typeof WebSocket>`u`)return;let e=ar.getInstance();fn(()=>{let e=Hc.getState();e.refreshChatsNow();let t=e.currentSessionId;t&&e.reconcileOpenSession(t,`ws_reconnected`)}),pc=e.subscribeToAccountStream({onOpen:()=>{Hc.getState().setAgentAvailability(!0)},onError:()=>{Hc.getState().setAgentAvailability(!1)},onReset:()=>{yc(),bc(),xc()},onChange:e=>{Hc.getState().setAgentAvailability(!0),wc(e),vc(e.seq)}},{since:_c()})},Ec=`bamboo_proxy_auth`,Dc=()=>{try{let e=localStorage.getItem(Ec);if(!e)return null;let t=JSON.parse(e);if(!t||typeof t!=`object`)return null;let n=typeof t.username==`string`?t.username.trim():``,r=typeof t.password==`string`?t.password:``;return n?{username:n,password:r}:null}catch{return null}},Oc={byId:{},runningCount:0},kc=(e,t)=>t?e.executionBySession[t]??null:null,Ac=e=>t=>{let n=kc(t,e);return Ar(n?.phase)?n?.phase!==`waiting_user_answer`:!1},jc=e=>t=>kc(t,e)?.children.byId??Oc.byId;Object.freeze({state:`idle`,activeToolCalls:[],runningChildCount:0,hasQuestion:!1,hasError:!1,errorMessage:null,generation:0});var Mc=`auto`,Nc=`required`,Pc=1e4,Fc=15e3,Ic=ar.getInstance(),Lc=null,Rc=null,zc=null,Bc=null,Vc=new WeakMap,Hc=se()(me(ge((e,t,n)=>({...Ro(e,t,n),...Qo(e,t,n),...vs(e,t,n),...bs(e,t,n),...Ss(e,t,n),...Cs(e,t,n),...Ts(e,t,n),...ec(e,t,n),...ri(e,t,n),...nc(e,t,n),...rc(e,t,n),agentAvailability:null,setAgentAvailability:t=>{e({agentAvailability:t})},checkAgentAvailability:async()=>{if(Rc)return Rc;Rc=(async()=>{let n=await Ic.healthCheck();return!(n&&hc()&&t().agentAvailability!==null)&&t().agentAvailability!==n&&e({agentAvailability:n}),n})();try{return await Rc}finally{Rc=null}},startAgentHealthCheck:()=>{Lc||=(t().checkAgentAvailability(),setInterval(()=>{t().checkAgentAvailability()},Pc))},refreshSessionsIndex:async()=>{if(Bc)return Bc;Bc=(async()=>{try{await t().refreshChats()}catch(e){console.warn(`[AppStore] refreshChats failed:`,e)}})();try{return await Bc}finally{Bc=null}},startSessionsIndexSync:()=>{zc||=(t().refreshSessionsIndex(),setInterval(()=>{t().refreshSessionsIndex()},Fc))}})),{name:`AppStore`})),Uc=e=>{let t=Vc.get(e);if(t)return t;let n=new Map(e.map(e=>[e.id,e]));return Vc.set(e,n),n},Wc=e=>t=>e?Uc(t.chats).get(e)??null:null,Gc=e=>e.currentSessionId?Uc(e.chats).get(e.currentSessionId)??null:null,Kc=e=>Hc(t=>t.backgroundBash[e]),qc=async()=>{let e=Dc();if(!e)return!1;try{return await Ko.setProxyAuth(e),!0}catch(e){return console.error(`Failed to apply stored proxy auth during startup:`,e),!1}},Jc=async()=>{try{let e=await Xo.getState().loadConfig();return(typeof e?.proxy_auth_mode==`string`?e.proxy_auth_mode:Mc)===Nc?(await Xo.getState().loadProxyAuthStatus({force:!0}))?.configured||await qc()?!1:(Hc.setState(e=>({...e,models:[],selectedModel:void 0,modelsError:`Proxy auth mode is set to required. Please configure proxy username/password and apply it.`,isLoadingModels:!1})),!0):(await qc(),!1)}catch(e){return console.error(`Failed to evaluate startup proxy auth mode:`,e),!1}},Yc=!1,Xc=!1,Zc=null,Qc=async(e=!1)=>{if(!(Yc&&!e)){if(Yc=!0,Tc(),Hc.getState().startAgentHealthCheck(),Hc.getState().startSessionsIndexSync(),!(typeof globalThis<`u`&&`__vitest_worker__`in globalThis))try{await Er.getState().loadProviderInstances()}catch{}await Hc.getState().loadChats(),Xc=!0}},$c=async()=>{if(Xc)return Zc||(Zc=(async()=>{try{await Jc()||await Hc.getState().fetchModels(),await Hc.getState().loadSystemPrompts()}catch(e){console.error(`[AppStore] Deferred bootstrap failed:`,e)}})(),Zc)},el=async(e=!1)=>{await Qc(e),$c().catch(e=>{console.error(`[AppStore] Deferred bootstrap error:`,e)})};typeof window<`u`&&window.document&&window.document.createElement;function Q(e,t,{checkForDefaultPrevented:n=!0}={}){return function(r){if(e?.(r),n===!1||!r.defaultPrevented)return t?.(r)}}function tl(e,t=[]){let n=[];function r(t,r){let i=D.createContext(r);i.displayName=t+`Context`;let a=n.length;n=[...n,r];let o=t=>{let{scope:n,children:r,...o}=t,s=n?.[e]?.[a]||i,c=D.useMemo(()=>o,Object.values(o));return(0,F.jsx)(s.Provider,{value:c,children:r})};o.displayName=t+`Provider`;function s(n,o){let s=o?.[e]?.[a]||i,c=D.useContext(s);if(c)return c;if(r!==void 0)return r;throw Error(`\`${n}\` must be used within \`${t}\``)}return[o,s]}let i=()=>{let t=n.map(e=>D.createContext(e));return function(n){let r=n?.[e]||t;return D.useMemo(()=>({[`__scope${e}`]:{...n,[e]:r}}),[n,r])}};return i.scopeName=e,[r,nl(i,...t)]}function nl(...e){let t=e[0];if(e.length===1)return t;let n=()=>{let n=e.map(e=>({useScope:e(),scopeName:e.scopeName}));return function(e){let r=n.reduce((t,{useScope:n,scopeName:r})=>{let i=n(e)[`__scope${r}`];return{...t,...i}},{});return D.useMemo(()=>({[`__scope${t.scopeName}`]:r}),[r])}};return n.scopeName=t.scopeName,n}var rl=globalThis?.document?D.useLayoutEffect:()=>{},il=D.useId||(()=>void 0),al=0;function ol(e){let[t,n]=D.useState(il());return rl(()=>{e||n(e=>e??String(al++))},[e]),e||(t?`radix-${t}`:``)}var sl=D.useInsertionEffect||rl;function cl({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){let[i,a,o]=ll({defaultProp:t,onChange:n}),s=e!==void 0,c=s?e:i;{let t=D.useRef(e!==void 0);D.useEffect(()=>{let e=t.current;e!==s&&console.warn(`${r} is changing from ${e?`controlled`:`uncontrolled`} to ${s?`controlled`:`uncontrolled`}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),t.current=s},[s,r])}return[c,D.useCallback(t=>{if(s){let n=ul(t)?t(e):t;n!==e&&o.current?.(n)}else a(t)},[s,e,a,o])]}function ll({defaultProp:e,onChange:t}){let[n,r]=D.useState(e),i=D.useRef(n),a=D.useRef(t);return sl(()=>{a.current=t},[t]),D.useEffect(()=>{i.current!==n&&(a.current?.(n),i.current=n)},[n,i]),[n,r,a]}function ul(e){return typeof e==`function`}var $=[`a`,`button`,`div`,`form`,`h2`,`h3`,`img`,`input`,`label`,`li`,`nav`,`ol`,`p`,`select`,`span`,`svg`,`ul`].reduce((e,t)=>{let n=f(`Primitive.${t}`),r=D.forwardRef((e,r)=>{let{asChild:i,...a}=e,o=i?n:t;return typeof window<`u`&&(window[Symbol.for(`radix-ui`)]=!0),(0,F.jsx)(o,{...a,ref:r})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function dl(e,t){e&&xe.flushSync(()=>e.dispatchEvent(t))}function fl(e){let t=D.useRef(e);return D.useEffect(()=>{t.current=e}),D.useMemo(()=>((...e)=>t.current?.(...e)),[])}function pl(e,t=globalThis?.document){let n=fl(e);D.useEffect(()=>{let e=e=>{e.key===`Escape`&&n(e)};return t.addEventListener(`keydown`,e,{capture:!0}),()=>t.removeEventListener(`keydown`,e,{capture:!0})},[n,t])}var ml=`DismissableLayer`,hl=`dismissableLayer.update`,gl=`dismissableLayer.pointerDownOutside`,_l=`dismissableLayer.focusOutside`,vl,yl=D.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set,dismissableSurfaces:new Set}),bl=D.forwardRef((e,t)=>{let{disableOutsidePointerEvents:n=!1,deferPointerDownOutside:r=!1,onEscapeKeyDown:i,onPointerDownOutside:a,onFocusOutside:o,onInteractOutside:s,onDismiss:c,...l}=e,d=D.useContext(yl),[f,p]=D.useState(null),m=f?.ownerDocument??globalThis?.document,[,h]=D.useState({}),g=u(t,e=>p(e)),_=Array.from(d.layers),[v]=[...d.layersWithOutsidePointerEventsDisabled].slice(-1),y=_.indexOf(v),b=f?_.indexOf(f):-1,x=d.layersWithOutsidePointerEventsDisabled.size>0,S=b>=y,C=D.useRef(!1),w=wl(e=>{let t=e.target;if(!(t instanceof Node))return;let n=[...d.branches].some(e=>e.contains(t));!S||n||(a?.(e),s?.(e),e.defaultPrevented||c?.())},{ownerDocument:m,deferPointerDownOutside:r,isDeferredPointerDownOutsideRef:C,dismissableSurfaces:d.dismissableSurfaces}),T=Tl(e=>{if(r&&C.current)return;let t=e.target;[...d.branches].some(e=>e.contains(t))||(o?.(e),s?.(e),e.defaultPrevented||c?.())},m);return pl(e=>{b===d.layers.size-1&&(i?.(e),!e.defaultPrevented&&c&&(e.preventDefault(),c()))},m),D.useEffect(()=>{if(f)return n&&(d.layersWithOutsidePointerEventsDisabled.size===0&&(vl=m.body.style.pointerEvents,m.body.style.pointerEvents=`none`),d.layersWithOutsidePointerEventsDisabled.add(f)),d.layers.add(f),El(),()=>{n&&(d.layersWithOutsidePointerEventsDisabled.delete(f),d.layersWithOutsidePointerEventsDisabled.size===0&&(m.body.style.pointerEvents=vl))}},[f,m,n,d]),D.useEffect(()=>()=>{f&&(d.layers.delete(f),d.layersWithOutsidePointerEventsDisabled.delete(f),El())},[f,d]),D.useEffect(()=>{let e=()=>h({});return document.addEventListener(hl,e),()=>document.removeEventListener(hl,e)},[]),(0,F.jsx)($.div,{...l,ref:g,style:{pointerEvents:x?S?`auto`:`none`:void 0,...e.style},onFocusCapture:Q(e.onFocusCapture,T.onFocusCapture),onBlurCapture:Q(e.onBlurCapture,T.onBlurCapture),onPointerDownCapture:Q(e.onPointerDownCapture,w.onPointerDownCapture)})});bl.displayName=ml;var xl=`DismissableLayerBranch`,Sl=D.forwardRef((e,t)=>{let n=D.useContext(yl),r=D.useRef(null),i=u(t,r);return D.useEffect(()=>{let e=r.current;if(e)return n.branches.add(e),()=>{n.branches.delete(e)}},[n.branches]),(0,F.jsx)($.div,{...e,ref:i})});Sl.displayName=xl;function Cl(){let e=D.useContext(yl),[t,n]=D.useState(null);return D.useEffect(()=>{if(t)return e.dismissableSurfaces.add(t),()=>{e.dismissableSurfaces.delete(t)}},[t,e.dismissableSurfaces]),n}function wl(e,t){let{ownerDocument:n=globalThis?.document,deferPointerDownOutside:r=!1,isDeferredPointerDownOutsideRef:i,dismissableSurfaces:a}=t,o=fl(e),s=D.useRef(!1),c=D.useRef(!1),l=D.useRef(new Map),u=D.useRef(()=>{});return D.useEffect(()=>{function e(){c.current=!1,i.current=!1,l.current.clear()}function t(){return Array.from(l.current.values()).some(Boolean)}function d(e){if(!c.current)return;let t=e.target;t instanceof Node&&[...a].some(e=>e.contains(t))||l.current.set(e.type,!0),e.type===`click`&&window.setTimeout(()=>{c.current&&u.current()},0)}function f(e){c.current&&l.current.set(e.type,!1)}let p=a=>{if(a.target&&!s.current){let s=function(){n.removeEventListener(`click`,u.current);let r=t();e(),r||Dl(gl,o,d,{discrete:!0})},d={originalEvent:a};c.current=!0,i.current=r&&a.button===0,l.current.clear(),!r||a.button!==0?s():(n.removeEventListener(`click`,u.current),u.current=s,n.addEventListener(`click`,u.current,{once:!0}))}else n.removeEventListener(`click`,u.current),e();s.current=!1},m=[`pointerup`,`mousedown`,`mouseup`,`touchstart`,`touchend`,`click`];for(let e of m)n.addEventListener(e,d,!0),n.addEventListener(e,f);let h=window.setTimeout(()=>{n.addEventListener(`pointerdown`,p)},0);return()=>{window.clearTimeout(h),n.removeEventListener(`pointerdown`,p),n.removeEventListener(`click`,u.current);for(let e of m)n.removeEventListener(e,d,!0),n.removeEventListener(e,f)}},[n,o,r,i,a]),{onPointerDownCapture:()=>s.current=!0}}function Tl(e,t=globalThis?.document){let n=fl(e),r=D.useRef(!1);return D.useEffect(()=>{let e=e=>{e.target&&!r.current&&Dl(_l,n,{originalEvent:e},{discrete:!1})};return t.addEventListener(`focusin`,e),()=>t.removeEventListener(`focusin`,e)},[t,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function El(){let e=new CustomEvent(hl);document.dispatchEvent(e)}function Dl(e,t,n,{discrete:r}){let i=n.originalEvent.target,a=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&i.addEventListener(e,t,{once:!0}),r?dl(i,a):i.dispatchEvent(a)}var Ol=`focusScope.autoFocusOnMount`,kl=`focusScope.autoFocusOnUnmount`,Al={bubbles:!1,cancelable:!0},jl=`FocusScope`,Ml=D.forwardRef((e,t)=>{let{loop:n=!1,trapped:r=!1,onMountAutoFocus:i,onUnmountAutoFocus:a,...o}=e,[s,c]=D.useState(null),l=fl(i),d=fl(a),f=D.useRef(null),p=u(t,e=>c(e)),m=D.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;D.useEffect(()=>{if(r){let e=function(e){if(m.paused||!s)return;let t=e.target;s.contains(t)?f.current=t:zl(f.current,{select:!0})},t=function(e){if(m.paused||!s)return;let t=e.relatedTarget;t!==null&&(s.contains(t)||zl(f.current,{select:!0}))},n=function(e){if(document.activeElement===document.body)for(let t of e)t.removedNodes.length>0&&zl(s)};document.addEventListener(`focusin`,e),document.addEventListener(`focusout`,t);let r=new MutationObserver(n);return s&&r.observe(s,{childList:!0,subtree:!0}),()=>{document.removeEventListener(`focusin`,e),document.removeEventListener(`focusout`,t),r.disconnect()}}},[r,s,m.paused]),D.useEffect(()=>{if(s){Bl.add(m);let e=document.activeElement;if(!s.contains(e)){let t=new CustomEvent(Ol,Al);s.addEventListener(Ol,l),s.dispatchEvent(t),t.defaultPrevented||(Nl(Ul(Fl(s)),{select:!0}),document.activeElement===e&&zl(s))}return()=>{s.removeEventListener(Ol,l),setTimeout(()=>{let t=new CustomEvent(kl,Al);s.addEventListener(kl,d),s.dispatchEvent(t),t.defaultPrevented||zl(e??document.body,{select:!0}),s.removeEventListener(kl,d),Bl.remove(m)},0)}}},[s,l,d,m]);let h=D.useCallback(e=>{if(!n&&!r||m.paused)return;let t=e.key===`Tab`&&!e.altKey&&!e.ctrlKey&&!e.metaKey,i=document.activeElement;if(t&&i){let t=e.currentTarget,[r,a]=Pl(t);r&&a?!e.shiftKey&&i===a?(e.preventDefault(),n&&zl(r,{select:!0})):e.shiftKey&&i===r&&(e.preventDefault(),n&&zl(a,{select:!0})):i===t&&e.preventDefault()}},[n,r,m.paused]);return(0,F.jsx)($.div,{tabIndex:-1,...o,ref:p,onKeyDown:h})});Ml.displayName=jl;function Nl(e,{select:t=!1}={}){let n=document.activeElement;for(let r of e)if(zl(r,{select:t}),document.activeElement!==n)return}function Pl(e){let t=Fl(e);return[Il(t,e),Il(t.reverse(),e)]}function Fl(e){let t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:e=>{let t=e.tagName===`INPUT`&&e.type===`hidden`;return e.disabled||e.hidden||t?NodeFilter.FILTER_SKIP:e.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function Il(e,t){for(let n of e)if(!Ll(n,{upTo:t}))return n}function Ll(e,{upTo:t}){if(getComputedStyle(e).visibility===`hidden`)return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display===`none`)return!0;e=e.parentElement}return!1}function Rl(e){return e instanceof HTMLInputElement&&`select`in e}function zl(e,{select:t=!1}={}){if(e&&e.focus){let n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&Rl(e)&&t&&e.select()}}var Bl=Vl();function Vl(){let e=[];return{add(t){let n=e[0];t!==n&&n?.pause(),e=Hl(e,t),e.unshift(t)},remove(t){e=Hl(e,t),e[0]?.resume()}}}function Hl(e,t){let n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function Ul(e){return e.filter(e=>e.tagName!==`A`)}var Wl=`Portal`,Gl=D.forwardRef((e,t)=>{let{container:n,...r}=e,[i,a]=D.useState(!1);rl(()=>a(!0),[]);let o=n||i&&globalThis?.document?.body;return o?xe.createPortal((0,F.jsx)($.div,{...r,ref:t}),o):null});Gl.displayName=Wl;function Kl(e,t){return D.useReducer((e,n)=>t[e][n]??e,e)}var ql=e=>{let{present:t,children:n}=e,r=Jl(t),i=typeof n==`function`?n({present:r.isPresent}):D.Children.only(n),a=Xl(r.ref,Ql(i));return typeof n==`function`||r.isPresent?D.cloneElement(i,{ref:a}):null};ql.displayName=`Presence`;function Jl(e){let[t,n]=D.useState(),r=D.useRef(null),i=D.useRef(e),a=D.useRef(`none`),[o,s]=Kl(e?`mounted`:`unmounted`,{mounted:{UNMOUNT:`unmounted`,ANIMATION_OUT:`unmountSuspended`},unmountSuspended:{MOUNT:`mounted`,ANIMATION_END:`unmounted`},unmounted:{MOUNT:`mounted`}});return D.useEffect(()=>{let e=Zl(r.current);a.current=o===`mounted`?e:`none`},[o]),rl(()=>{let t=r.current,n=i.current;if(n!==e){let r=a.current,o=Zl(t);e?s(`MOUNT`):o===`none`||t?.display===`none`?s(`UNMOUNT`):s(n&&r!==o?`ANIMATION_OUT`:`UNMOUNT`),i.current=e}},[e,s]),rl(()=>{if(t){let e,n=t.ownerDocument.defaultView??window,o=a=>{let o=Zl(r.current).includes(CSS.escape(a.animationName));if(a.target===t&&o&&(s(`ANIMATION_END`),!i.current)){let r=t.style.animationFillMode;t.style.animationFillMode=`forwards`,e=n.setTimeout(()=>{t.style.animationFillMode===`forwards`&&(t.style.animationFillMode=r)})}},c=e=>{e.target===t&&(a.current=Zl(r.current))};return t.addEventListener(`animationstart`,c),t.addEventListener(`animationcancel`,o),t.addEventListener(`animationend`,o),()=>{n.clearTimeout(e),t.removeEventListener(`animationstart`,c),t.removeEventListener(`animationcancel`,o),t.removeEventListener(`animationend`,o)}}else s(`ANIMATION_END`)},[t,s]),{isPresent:[`mounted`,`unmountSuspended`].includes(o),ref:D.useCallback(e=>{r.current=e?getComputedStyle(e):null,n(e)},[])}}function Yl(e,t){if(typeof e==`function`)return e(t);e!=null&&(e.current=t)}function Xl(...e){let t=D.useRef(e);return t.current=e,D.useCallback(e=>{let n=t.current,r=!1,i=n.map(t=>{let n=Yl(t,e);return!r&&typeof n==`function`&&(r=!0),n});if(r)return()=>{for(let e=0;e<i.length;e++){let t=i[e];typeof t==`function`?t():Yl(n[e],null)}}},[])}function Zl(e){return e?.animationName||`none`}function Ql(e){let t=Object.getOwnPropertyDescriptor(e.props,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var $l=0,eu=null;function tu(){D.useEffect(()=>{eu||={start:nu(),end:nu()};let{start:e,end:t}=eu;return document.body.firstElementChild!==e&&document.body.insertAdjacentElement(`afterbegin`,e),document.body.lastElementChild!==t&&document.body.insertAdjacentElement(`beforeend`,t),$l++,()=>{$l===1&&(eu?.start.remove(),eu?.end.remove(),eu=null),$l=Math.max(0,$l-1)}},[])}function nu(){let e=document.createElement(`span`);return e.setAttribute(`data-radix-focus-guard`,``),e.tabIndex=0,e.style.outline=`none`,e.style.opacity=`0`,e.style.position=`fixed`,e.style.pointerEvents=`none`,e}var ru=function(){return ru=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n],t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},ru.apply(this,arguments)};function iu(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols==`function`)for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n}function au(e,t,n){if(n||arguments.length===2)for(var r=0,i=t.length,a;r<i;r++)(a||!(r in t))&&(a||=Array.prototype.slice.call(t,0,r),a[r]=t[r]);return e.concat(a||Array.prototype.slice.call(t))}var ou=`right-scroll-bar-position`,su=`width-before-scroll-bar`,cu=`with-scroll-bars-hidden`,lu=`--removed-body-scroll-bar-size`;function uu(e,t){return typeof e==`function`?e(t):e&&(e.current=t),e}function du(e,t){var n=(0,D.useState)(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(e){var t=n.value;t!==e&&(n.value=e,n.callback(e,t))}}}})[0];return n.callback=t,n.facade}var fu=typeof window<`u`?D.useLayoutEffect:D.useEffect,pu=new WeakMap;function mu(e,t){var n=du(t||null,function(t){return e.forEach(function(e){return uu(e,t)})});return fu(function(){var t=pu.get(n);if(t){var r=new Set(t),i=new Set(e),a=n.current;r.forEach(function(e){i.has(e)||uu(e,null)}),i.forEach(function(e){r.has(e)||uu(e,a)})}pu.set(n,e)},[e]),n}function hu(e){return e}function gu(e,t){t===void 0&&(t=hu);var n=[],r=!1;return{read:function(){if(r)throw Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(e){var i=t(e,r);return n.push(i),function(){n=n.filter(function(e){return e!==i})}},assignSyncMedium:function(e){for(r=!0;n.length;){var t=n;n=[],t.forEach(e)}n={push:function(t){return e(t)},filter:function(){return n}}},assignMedium:function(e){r=!0;var t=[];if(n.length){var i=n;n=[],i.forEach(e),t=n}var a=function(){var n=t;t=[],n.forEach(e)},o=function(){return Promise.resolve().then(a)};o(),n={push:function(e){t.push(e),o()},filter:function(e){return t=t.filter(e),n}}}}}function _u(e){e===void 0&&(e={});var t=gu(null);return t.options=ru({async:!0,ssr:!1},e),t}var vu=function(e){var t=e.sideCar,n=iu(e,[`sideCar`]);if(!t)throw Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw Error(`Sidecar medium not found`);return D.createElement(r,ru({},n))};vu.isSideCarExport=!0;function yu(e,t){return e.useMedium(t),vu}var bu=_u(),xu=function(){},Su=D.forwardRef(function(e,t){var n=D.useRef(null),r=D.useState({onScrollCapture:xu,onWheelCapture:xu,onTouchMoveCapture:xu}),i=r[0],a=r[1],o=e.forwardProps,s=e.children,c=e.className,l=e.removeScrollBar,u=e.enabled,d=e.shards,f=e.sideCar,p=e.noRelative,m=e.noIsolation,h=e.inert,g=e.allowPinchZoom,_=e.as,v=_===void 0?`div`:_,y=e.gapMode,b=iu(e,[`forwardProps`,`children`,`className`,`removeScrollBar`,`enabled`,`shards`,`sideCar`,`noRelative`,`noIsolation`,`inert`,`allowPinchZoom`,`as`,`gapMode`]),x=f,S=mu([n,t]),C=ru(ru({},b),i);return D.createElement(D.Fragment,null,u&&D.createElement(x,{sideCar:bu,removeScrollBar:l,shards:d,noRelative:p,noIsolation:m,inert:h,setCallbacks:a,allowPinchZoom:!!g,lockRef:n,gapMode:y}),o?D.cloneElement(D.Children.only(s),ru(ru({},C),{ref:S})):D.createElement(v,ru({},C,{className:c,ref:S}),s))});Su.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},Su.classNames={fullWidth:su,zeroRight:ou};var Cu,wu=function(){if(Cu)return Cu;if(typeof __webpack_nonce__<`u`)return __webpack_nonce__};function Tu(){if(!document)return null;var e=document.createElement(`style`);e.type=`text/css`;var t=wu();return t&&e.setAttribute(`nonce`,t),e}function Eu(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function Du(e){(document.head||document.getElementsByTagName(`head`)[0]).appendChild(e)}var Ou=function(){var e=0,t=null;return{add:function(n){e==0&&(t=Tu())&&(Eu(t,n),Du(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},ku=function(){var e=Ou();return function(t,n){D.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},Au=function(){var e=ku();return function(t){var n=t.styles,r=t.dynamic;return e(n,r),null}},ju={left:0,top:0,right:0,gap:0},Mu=function(e){return parseInt(e||``,10)||0},Nu=function(e){var t=window.getComputedStyle(document.body),n=t[e===`padding`?`paddingLeft`:`marginLeft`],r=t[e===`padding`?`paddingTop`:`marginTop`],i=t[e===`padding`?`paddingRight`:`marginRight`];return[Mu(n),Mu(r),Mu(i)]},Pu=function(e){if(e===void 0&&(e=`margin`),typeof window>`u`)return ju;var t=Nu(e),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-n+t[2]-t[0])}},Fu=Au(),Iu=`data-scroll-locked`,Lu=function(e,t,n,r){var i=e.left,a=e.top,o=e.right,s=e.gap;return n===void 0&&(n=`margin`),`
|
|
19
|
+
.${cu} {
|
|
20
20
|
overflow: hidden ${r};
|
|
21
21
|
padding-right: ${s}px ${r};
|
|
22
22
|
}
|
|
23
|
-
body[${
|
|
23
|
+
body[${Iu}] {
|
|
24
24
|
overflow: hidden ${r};
|
|
25
25
|
overscroll-behavior: contain;
|
|
26
26
|
${[t&&`position: relative ${r};`,n===`margin`&&`
|
|
@@ -33,29 +33,29 @@ If requirements are unclear, ask focused clarifying questions before proceeding.
|
|
|
33
33
|
`,n===`padding`&&`padding-right: ${s}px ${r};`].filter(Boolean).join(``)}
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
.${
|
|
36
|
+
.${ou} {
|
|
37
37
|
right: ${s}px ${r};
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
.${
|
|
40
|
+
.${su} {
|
|
41
41
|
margin-right: ${s}px ${r};
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
.${
|
|
44
|
+
.${ou} .${ou} {
|
|
45
45
|
right: 0 ${r};
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
.${
|
|
48
|
+
.${su} .${su} {
|
|
49
49
|
margin-right: 0 ${r};
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
-
body[${
|
|
53
|
-
${
|
|
52
|
+
body[${Iu}] {
|
|
53
|
+
${lu}: ${s}px;
|
|
54
54
|
}
|
|
55
|
-
`},
|
|
55
|
+
`},Ru=function(){var e=parseInt(document.body.getAttribute(`data-scroll-locked`)||`0`,10);return isFinite(e)?e:0},zu=function(){D.useEffect(function(){return document.body.setAttribute(Iu,(Ru()+1).toString()),function(){var e=Ru()-1;e<=0?document.body.removeAttribute(Iu):document.body.setAttribute(Iu,e.toString())}},[])},Bu=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,i=r===void 0?`margin`:r;zu();var a=D.useMemo(function(){return Pu(i)},[i]);return D.createElement(Fu,{styles:Lu(a,!t,i,n?``:`!important`)})},Vu=!1;if(typeof window<`u`)try{var Hu=Object.defineProperty({},"passive",{get:function(){return Vu=!0,!0}});window.addEventListener(`test`,Hu,Hu),window.removeEventListener(`test`,Hu,Hu)}catch{Vu=!1}var Uu=Vu?{passive:!1}:!1,Wu=function(e){return e.tagName===`TEXTAREA`},Gu=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!==`hidden`&&!(n.overflowY===n.overflowX&&!Wu(e)&&n[t]===`visible`)},Ku=function(e){return Gu(e,`overflowY`)},qu=function(e){return Gu(e,`overflowX`)},Ju=function(e,t){var n=t.ownerDocument,r=t;do{if(typeof ShadowRoot<`u`&&r instanceof ShadowRoot&&(r=r.host),Zu(e,r)){var i=Qu(e,r);if(i[1]>i[2])return!0}r=r.parentNode}while(r&&r!==n.body);return!1},Yu=function(e){return[e.scrollTop,e.scrollHeight,e.clientHeight]},Xu=function(e){return[e.scrollLeft,e.scrollWidth,e.clientWidth]},Zu=function(e,t){return e===`v`?Ku(t):qu(t)},Qu=function(e,t){return e===`v`?Yu(t):Xu(t)},$u=function(e,t){return e===`h`&&t===`rtl`?-1:1},ed=function(e,t,n,r,i){var a=$u(e,window.getComputedStyle(t).direction),o=a*r,s=n.target,c=t.contains(s),l=!1,u=o>0,d=0,f=0;do{if(!s)break;var p=Qu(e,s),m=p[0],h=p[1]-p[2]-a*m;(m||h)&&Zu(e,s)&&(d+=h,f+=m);var g=s.parentNode;s=g&&g.nodeType===Node.DOCUMENT_FRAGMENT_NODE?g.host:g}while(!c&&s!==document.body||c&&(t.contains(s)||t===s));return(u&&(i&&Math.abs(d)<1||!i&&o>d)||!u&&(i&&Math.abs(f)<1||!i&&-o>f))&&(l=!0),l},td=function(e){return`changedTouches`in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},nd=function(e){return[e.deltaX,e.deltaY]},rd=function(e){return e&&`current`in e?e.current:e},id=function(e,t){return e[0]===t[0]&&e[1]===t[1]},ad=function(e){return`
|
|
56
56
|
.block-interactivity-${e} {pointer-events: none;}
|
|
57
57
|
.allow-interactivity-${e} {pointer-events: all;}
|
|
58
|
-
`},td=0,nd=[];function rd(e){var t=D.useRef([]),n=D.useRef([0,0]),r=D.useRef(),i=D.useState(td++)[0],a=D.useState(Tu)[0],o=D.useRef(e);D.useEffect(function(){o.current=e},[e]),D.useEffect(function(){if(e.inert){document.body.classList.add(`block-interactivity-${i}`);var t=eu([e.lockRef.current],(e.shards||[]).map(Qu),!0).filter(Boolean);return t.forEach(function(e){return e.classList.add(`allow-interactivity-${i}`)}),function(){document.body.classList.remove(`block-interactivity-${i}`),t.forEach(function(e){return e.classList.remove(`allow-interactivity-${i}`)})}}},[e.inert,e.lockRef.current,e.shards]);var s=D.useCallback(function(e,t){if(`touches`in e&&e.touches.length===2||e.type===`wheel`&&e.ctrlKey)return!o.current.allowPinchZoom;var i=Xu(e),a=n.current,s=`deltaX`in e?e.deltaX:a[0]-i[0],c=`deltaY`in e?e.deltaY:a[1]-i[1],l,u=e.target,d=Math.abs(s)>Math.abs(c)?`h`:`v`;if(`touches`in e&&d===`h`&&u.type===`range`)return!1;var f=window.getSelection(),p=f&&f.anchorNode;if(p&&(p===u||p.contains(u)))return!1;var m=Uu(d,u);if(!m)return!0;if(m?l=d:(l=d===`v`?`h`:`v`,m=Uu(d,u)),!m)return!1;if(!r.current&&`changedTouches`in e&&(s||c)&&(r.current=l),!l)return!0;var h=r.current||l;return Yu(h,t,e,h===`h`?s:c,!0)},[]),c=D.useCallback(function(e){var n=e;if(!(!nd.length||nd[nd.length-1]!==a)){var r=`deltaY`in n?Zu(n):Xu(n),i=t.current.filter(function(e){return e.name===n.type&&(e.target===n.target||n.target===e.shadowParent)&&$u(e.delta,r)})[0];if(i&&i.should){n.cancelable&&n.preventDefault();return}if(!i){var c=(o.current.shards||[]).map(Qu).filter(Boolean).filter(function(e){return e.contains(n.target)});(c.length>0?s(n,c[0]):!o.current.noIsolation)&&n.cancelable&&n.preventDefault()}}},[]),l=D.useCallback(function(e,n,r,i){var a={name:e,delta:n,target:r,should:i,shadowParent:id(r)};t.current.push(a),setTimeout(function(){t.current=t.current.filter(function(e){return e!==a})},1)},[]),u=D.useCallback(function(e){n.current=Xu(e),r.current=void 0},[]),d=D.useCallback(function(t){l(t.type,Zu(t),t.target,s(t,e.lockRef.current))},[]),f=D.useCallback(function(t){l(t.type,Xu(t),t.target,s(t,e.lockRef.current))},[]);D.useEffect(function(){return nd.push(a),e.setCallbacks({onScrollCapture:d,onWheelCapture:d,onTouchMoveCapture:f}),document.addEventListener(`wheel`,c,Ru),document.addEventListener(`touchmove`,c,Ru),document.addEventListener(`touchstart`,u,Ru),function(){nd=nd.filter(function(e){return e!==a}),document.removeEventListener(`wheel`,c,Ru),document.removeEventListener(`touchmove`,c,Ru),document.removeEventListener(`touchstart`,u,Ru)}},[]);var p=e.removeScrollBar,m=e.inert;return D.createElement(D.Fragment,null,m?D.createElement(a,{styles:ed(i)}):null,p?D.createElement(Fu,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function id(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}var ad=mu(hu,rd),od=D.forwardRef(function(e,t){return D.createElement(_u,Ql({},e,{ref:t,sideCar:ad}))});od.classNames=_u.classNames;var sd=function(e){return typeof document>`u`?null:(Array.isArray(e)?e[0]:e).ownerDocument.body},cd=new WeakMap,ld=new WeakMap,ud={},dd=0,fd=function(e){return e&&(e.host||fd(e.parentNode))},pd=function(e,t){return t.map(function(t){if(e.contains(t))return t;var n=fd(t);return n&&e.contains(n)?n:(console.error(`aria-hidden`,t,`in not contained inside`,e,`. Doing nothing`),null)}).filter(function(e){return!!e})},md=function(e,t,n,r){var i=pd(t,Array.isArray(e)?e:[e]);ud[n]||(ud[n]=new WeakMap);var a=ud[n],o=[],s=new Set,c=new Set(i),l=function(e){!e||s.has(e)||(s.add(e),l(e.parentNode))};i.forEach(l);var u=function(e){!e||c.has(e)||Array.prototype.forEach.call(e.children,function(e){if(s.has(e))u(e);else try{var t=e.getAttribute(r),i=t!==null&&t!==`false`,c=(cd.get(e)||0)+1,l=(a.get(e)||0)+1;cd.set(e,c),a.set(e,l),o.push(e),c===1&&i&&ld.set(e,!0),l===1&&e.setAttribute(n,`true`),i||e.setAttribute(r,`true`)}catch(t){console.error(`aria-hidden: cannot operate on `,e,t)}})};return u(t),s.clear(),dd++,function(){o.forEach(function(e){var t=cd.get(e)-1,i=a.get(e)-1;cd.set(e,t),a.set(e,i),t||(ld.has(e)||e.removeAttribute(r),ld.delete(e)),i||e.removeAttribute(n)}),dd--,dd||(cd=new WeakMap,cd=new WeakMap,ld=new WeakMap,ud={})}},hd=function(e,t,n){n===void 0&&(n=`data-aria-hidden`);var r=Array.from(Array.isArray(e)?e:[e]),i=t||sd(e);return i?(r.push.apply(r,Array.from(i.querySelectorAll(`[aria-live], script`))),md(r,i,n,`aria-hidden`)):function(){return null}},gd=`Dialog`,[_d,vd]=Xc(gd),[yd,bd]=_d(gd),xd=e=>{let{__scopeDialog:t,children:n,open:r,defaultOpen:i,onOpenChange:a,modal:o=!0}=e,s=D.useRef(null),c=D.useRef(null),[l,u]=rl({prop:r,defaultProp:i??!1,onChange:a,caller:gd});return(0,F.jsx)(yd,{scope:t,triggerRef:s,contentRef:c,contentId:tl(),titleId:tl(),descriptionId:tl(),open:l,onOpenChange:u,onOpenToggle:D.useCallback(()=>u(e=>!e),[u]),modal:o,children:n})};xd.displayName=gd;var Sd=`DialogTrigger`,Cd=D.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=bd(Sd,n),a=u(t,i.triggerRef);return(0,F.jsx)($.button,{type:`button`,"aria-haspopup":`dialog`,"aria-expanded":i.open,"aria-controls":i.open?i.contentId:void 0,"data-state":Ud(i.open),...r,ref:a,onClick:Q(e.onClick,i.onOpenToggle)})});Cd.displayName=Sd;var wd=`DialogPortal`,[Td,Ed]=_d(wd,{forceMount:void 0}),Dd=e=>{let{__scopeDialog:t,forceMount:n,children:r,container:i}=e,a=bd(wd,t);return(0,F.jsx)(Td,{scope:t,forceMount:n,children:D.Children.map(r,e=>(0,F.jsx)(Hl,{present:n||a.open,children:(0,F.jsx)(Bl,{asChild:!0,container:i,children:e})}))})};Dd.displayName=wd;var Od=`DialogOverlay`,kd=D.forwardRef((e,t)=>{let n=Ed(Od,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=bd(Od,e.__scopeDialog);return a.modal?(0,F.jsx)(Hl,{present:r||a.open,children:(0,F.jsx)(jd,{...i,ref:t})}):null});kd.displayName=Od;var Ad=f(`DialogOverlay.RemoveScroll`),jd=D.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=bd(Od,n),a=u(t,vl());return(0,F.jsx)(od,{as:Ad,allowPinchZoom:!0,shards:[i.contentRef],children:(0,F.jsx)($.div,{"data-state":Ud(i.open),...r,ref:a,style:{pointerEvents:`auto`,...r.style}})})}),Md=`DialogContent`,Nd=D.forwardRef((e,t)=>{let n=Ed(Md,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=bd(Md,e.__scopeDialog);return(0,F.jsx)(Hl,{present:r||a.open,children:a.modal?(0,F.jsx)(Pd,{...i,ref:t}):(0,F.jsx)(Fd,{...i,ref:t})})});Nd.displayName=Md;var Pd=D.forwardRef((e,t)=>{let n=bd(Md,e.__scopeDialog),r=D.useRef(null),i=u(t,n.contentRef,r);return D.useEffect(()=>{let e=r.current;if(e)return hd(e)},[]),(0,F.jsx)(Id,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,onCloseAutoFocus:Q(e.onCloseAutoFocus,e=>{e.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:Q(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0;(t.button===2||n)&&e.preventDefault()}),onFocusOutside:Q(e.onFocusOutside,e=>e.preventDefault())})}),Fd=D.forwardRef((e,t)=>{let n=bd(Md,e.__scopeDialog),r=D.useRef(!1),i=D.useRef(!1);return(0,F.jsx)(Id,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),t.defaultPrevented||(r.current||n.triggerRef.current?.focus(),t.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),t.defaultPrevented||(r.current=!0,t.detail.originalEvent.type===`pointerdown`&&(i.current=!0));let a=t.target;n.triggerRef.current?.contains(a)&&t.preventDefault(),t.detail.originalEvent.type===`focusin`&&i.current&&t.preventDefault()}})}),Id=D.forwardRef((e,t)=>{let{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:a,...o}=e,s=bd(Md,n);return Xl(),(0,F.jsx)(F.Fragment,{children:(0,F.jsx)(Dl,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:a,children:(0,F.jsx)(hl,{role:`dialog`,id:s.contentId,"aria-describedby":s.descriptionId,"aria-labelledby":s.titleId,"data-state":Ud(s.open),...o,ref:t,deferPointerDownOutside:!0,onDismiss:()=>s.onOpenChange(!1)})})})}),Ld=`DialogTitle`,Rd=D.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=bd(Ld,n);return(0,F.jsx)($.h2,{id:i.titleId,...r,ref:t})});Rd.displayName=Ld;var zd=`DialogDescription`,Bd=D.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=bd(zd,n);return(0,F.jsx)($.p,{id:i.descriptionId,...r,ref:t})});Bd.displayName=zd;var Vd=`DialogClose`,Hd=D.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=bd(Vd,n);return(0,F.jsx)($.button,{type:`button`,...r,ref:t,onClick:Q(e.onClick,()=>i.onOpenChange(!1))})});Hd.displayName=Vd;function Ud(e){return e?`open`:`closed`}function Wd(e){return(0,F.jsx)(xd,{"data-slot":`responsive-dialog`,...e})}function Gd({className:e,children:t,showCloseButton:n=!0,dismissable:r=!0,onEscapeKeyDown:i,...a}){return(0,F.jsxs)(Dd,{children:[(0,F.jsx)(kd,{className:`data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-[120] bg-black/50`}),(0,F.jsxs)(Nd,{"data-slot":`responsive-dialog-content`,onInteractOutside:r?void 0:e=>e.preventDefault(),onEscapeKeyDown:e=>{let t=e.target,n=t?.ownerDocument??document,a=!!(typeof t?.closest==`function`?t:n.activeElement)?.closest(`[role="combobox"][aria-expanded="true"]`);(!r||a)&&e.preventDefault(),i?.(e)},className:l(`bg-card text-card-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed z-[130] flex flex-col border shadow-xl outline-none duration-200`,`inset-x-0 bottom-0 max-h-[90dvh] rounded-t-2xl pb-[env(safe-area-inset-bottom)] data-[state=open]:slide-in-from-bottom-4 data-[state=closed]:slide-out-to-bottom-4`,`sm:inset-x-auto sm:bottom-auto sm:top-1/2 sm:left-1/2 sm:max-h-[85vh] sm:w-full sm:max-w-md sm:-translate-x-1/2 sm:-translate-y-1/2 sm:rounded-2xl sm:pb-0 sm:data-[state=open]:slide-in-from-bottom-0 sm:data-[state=open]:zoom-in-95 sm:data-[state=closed]:zoom-out-95`,e),...a,children:[t,n&&r&&(0,F.jsxs)(Hd,{className:`ring-offset-background focus:ring-ring absolute top-3.5 right-3.5 rounded-md p-1 text-muted-foreground opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:outline-hidden disabled:pointer-events-none [&_svg]:size-4`,children:[(0,F.jsx)(E,{}),(0,F.jsx)(`span`,{className:`sr-only`,children:`关闭`})]})]})]})}function Kd({className:e,...t}){return(0,F.jsx)(Rd,{"data-slot":`responsive-dialog-title`,className:l(`text-base leading-none font-semibold`,e),...t})}function qd({className:e,...t}){return(0,F.jsx)(Bd,{"data-slot":`responsive-dialog-description`,className:l(`text-muted-foreground text-sm`,e),...t})}function Jd({className:e,type:t,...n}){return(0,F.jsx)(`input`,{type:t,"data-slot":`input`,className:l(`file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground border-input flex h-9 w-full min-w-0 rounded-md border bg-background px-3 py-1 text-base shadow-xs transition-[color,box-shadow] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm`,`focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]`,`aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive`,e),...n})}var Yd=`copilot_ui_theme_v1`,Xd=()=>typeof window<`u`?window.matchMedia?.(`(prefers-color-scheme: dark)`):void 0,Zd=()=>Xd()?.matches?`dark`:`light`,Qd=e=>e===`system`?Zd():e;function $d(){try{let e=localStorage.getItem(Yd);if(e===`light`||e===`dark`||e===`system`)return e}catch{}return`system`}var ef=se((e,t)=>({themePreference:$d(),themeMode:Qd($d()),setThemePreference:t=>{try{localStorage.setItem(Yd,t)}catch{}e({themePreference:t,themeMode:Qd(t)})},toggleTheme:()=>{let e=t().themeMode===`dark`?`light`:`dark`;t().setThemePreference(e)}}));Xd()?.addEventListener?.(`change`,()=>{ef.getState().themePreference===`system`&&ef.setState({themeMode:Zd()})});var tf=`mermaid_enhancement_enabled`,nf=()=>localStorage.getItem(tf)!==`false`,rf=e=>{localStorage.setItem(tf,e.toString())},af=()=>`
|
|
58
|
+
`},od=0,sd=[];function cd(e){var t=D.useRef([]),n=D.useRef([0,0]),r=D.useRef(),i=D.useState(od++)[0],a=D.useState(Au)[0],o=D.useRef(e);D.useEffect(function(){o.current=e},[e]),D.useEffect(function(){if(e.inert){document.body.classList.add(`block-interactivity-${i}`);var t=au([e.lockRef.current],(e.shards||[]).map(rd),!0).filter(Boolean);return t.forEach(function(e){return e.classList.add(`allow-interactivity-${i}`)}),function(){document.body.classList.remove(`block-interactivity-${i}`),t.forEach(function(e){return e.classList.remove(`allow-interactivity-${i}`)})}}},[e.inert,e.lockRef.current,e.shards]);var s=D.useCallback(function(e,t){if(`touches`in e&&e.touches.length===2||e.type===`wheel`&&e.ctrlKey)return!o.current.allowPinchZoom;var i=td(e),a=n.current,s=`deltaX`in e?e.deltaX:a[0]-i[0],c=`deltaY`in e?e.deltaY:a[1]-i[1],l,u=e.target,d=Math.abs(s)>Math.abs(c)?`h`:`v`;if(`touches`in e&&d===`h`&&u.type===`range`)return!1;var f=window.getSelection(),p=f&&f.anchorNode;if(p&&(p===u||p.contains(u)))return!1;var m=Ju(d,u);if(!m)return!0;if(m?l=d:(l=d===`v`?`h`:`v`,m=Ju(d,u)),!m)return!1;if(!r.current&&`changedTouches`in e&&(s||c)&&(r.current=l),!l)return!0;var h=r.current||l;return ed(h,t,e,h===`h`?s:c,!0)},[]),c=D.useCallback(function(e){var n=e;if(!(!sd.length||sd[sd.length-1]!==a)){var r=`deltaY`in n?nd(n):td(n),i=t.current.filter(function(e){return e.name===n.type&&(e.target===n.target||n.target===e.shadowParent)&&id(e.delta,r)})[0];if(i&&i.should){n.cancelable&&n.preventDefault();return}if(!i){var c=(o.current.shards||[]).map(rd).filter(Boolean).filter(function(e){return e.contains(n.target)});(c.length>0?s(n,c[0]):!o.current.noIsolation)&&n.cancelable&&n.preventDefault()}}},[]),l=D.useCallback(function(e,n,r,i){var a={name:e,delta:n,target:r,should:i,shadowParent:ld(r)};t.current.push(a),setTimeout(function(){t.current=t.current.filter(function(e){return e!==a})},1)},[]),u=D.useCallback(function(e){n.current=td(e),r.current=void 0},[]),d=D.useCallback(function(t){l(t.type,nd(t),t.target,s(t,e.lockRef.current))},[]),f=D.useCallback(function(t){l(t.type,td(t),t.target,s(t,e.lockRef.current))},[]);D.useEffect(function(){return sd.push(a),e.setCallbacks({onScrollCapture:d,onWheelCapture:d,onTouchMoveCapture:f}),document.addEventListener(`wheel`,c,Uu),document.addEventListener(`touchmove`,c,Uu),document.addEventListener(`touchstart`,u,Uu),function(){sd=sd.filter(function(e){return e!==a}),document.removeEventListener(`wheel`,c,Uu),document.removeEventListener(`touchmove`,c,Uu),document.removeEventListener(`touchstart`,u,Uu)}},[]);var p=e.removeScrollBar,m=e.inert;return D.createElement(D.Fragment,null,m?D.createElement(a,{styles:ad(i)}):null,p?D.createElement(Bu,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function ld(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}var ud=yu(bu,cd),dd=D.forwardRef(function(e,t){return D.createElement(Su,ru({},e,{ref:t,sideCar:ud}))});dd.classNames=Su.classNames;var fd=function(e){return typeof document>`u`?null:(Array.isArray(e)?e[0]:e).ownerDocument.body},pd=new WeakMap,md=new WeakMap,hd={},gd=0,_d=function(e){return e&&(e.host||_d(e.parentNode))},vd=function(e,t){return t.map(function(t){if(e.contains(t))return t;var n=_d(t);return n&&e.contains(n)?n:(console.error(`aria-hidden`,t,`in not contained inside`,e,`. Doing nothing`),null)}).filter(function(e){return!!e})},yd=function(e,t,n,r){var i=vd(t,Array.isArray(e)?e:[e]);hd[n]||(hd[n]=new WeakMap);var a=hd[n],o=[],s=new Set,c=new Set(i),l=function(e){!e||s.has(e)||(s.add(e),l(e.parentNode))};i.forEach(l);var u=function(e){!e||c.has(e)||Array.prototype.forEach.call(e.children,function(e){if(s.has(e))u(e);else try{var t=e.getAttribute(r),i=t!==null&&t!==`false`,c=(pd.get(e)||0)+1,l=(a.get(e)||0)+1;pd.set(e,c),a.set(e,l),o.push(e),c===1&&i&&md.set(e,!0),l===1&&e.setAttribute(n,`true`),i||e.setAttribute(r,`true`)}catch(t){console.error(`aria-hidden: cannot operate on `,e,t)}})};return u(t),s.clear(),gd++,function(){o.forEach(function(e){var t=pd.get(e)-1,i=a.get(e)-1;pd.set(e,t),a.set(e,i),t||(md.has(e)||e.removeAttribute(r),md.delete(e)),i||e.removeAttribute(n)}),gd--,gd||(pd=new WeakMap,pd=new WeakMap,md=new WeakMap,hd={})}},bd=function(e,t,n){n===void 0&&(n=`data-aria-hidden`);var r=Array.from(Array.isArray(e)?e:[e]),i=t||fd(e);return i?(r.push.apply(r,Array.from(i.querySelectorAll(`[aria-live], script`))),yd(r,i,n,`aria-hidden`)):function(){return null}},xd=`Dialog`,[Sd,Cd]=tl(xd),[wd,Td]=Sd(xd),Ed=e=>{let{__scopeDialog:t,children:n,open:r,defaultOpen:i,onOpenChange:a,modal:o=!0}=e,s=D.useRef(null),c=D.useRef(null),[l,u]=cl({prop:r,defaultProp:i??!1,onChange:a,caller:xd});return(0,F.jsx)(wd,{scope:t,triggerRef:s,contentRef:c,contentId:ol(),titleId:ol(),descriptionId:ol(),open:l,onOpenChange:u,onOpenToggle:D.useCallback(()=>u(e=>!e),[u]),modal:o,children:n})};Ed.displayName=xd;var Dd=`DialogTrigger`,Od=D.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=Td(Dd,n),a=u(t,i.triggerRef);return(0,F.jsx)($.button,{type:`button`,"aria-haspopup":`dialog`,"aria-expanded":i.open,"aria-controls":i.open?i.contentId:void 0,"data-state":Jd(i.open),...r,ref:a,onClick:Q(e.onClick,i.onOpenToggle)})});Od.displayName=Dd;var kd=`DialogPortal`,[Ad,jd]=Sd(kd,{forceMount:void 0}),Md=e=>{let{__scopeDialog:t,forceMount:n,children:r,container:i}=e,a=Td(kd,t);return(0,F.jsx)(Ad,{scope:t,forceMount:n,children:D.Children.map(r,e=>(0,F.jsx)(ql,{present:n||a.open,children:(0,F.jsx)(Gl,{asChild:!0,container:i,children:e})}))})};Md.displayName=kd;var Nd=`DialogOverlay`,Pd=D.forwardRef((e,t)=>{let n=jd(Nd,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=Td(Nd,e.__scopeDialog);return a.modal?(0,F.jsx)(ql,{present:r||a.open,children:(0,F.jsx)(Id,{...i,ref:t})}):null});Pd.displayName=Nd;var Fd=f(`DialogOverlay.RemoveScroll`),Id=D.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=Td(Nd,n),a=u(t,Cl());return(0,F.jsx)(dd,{as:Fd,allowPinchZoom:!0,shards:[i.contentRef],children:(0,F.jsx)($.div,{"data-state":Jd(i.open),...r,ref:a,style:{pointerEvents:`auto`,...r.style}})})}),Ld=`DialogContent`,Rd=D.forwardRef((e,t)=>{let n=jd(Ld,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=Td(Ld,e.__scopeDialog);return(0,F.jsx)(ql,{present:r||a.open,children:a.modal?(0,F.jsx)(zd,{...i,ref:t}):(0,F.jsx)(Bd,{...i,ref:t})})});Rd.displayName=Ld;var zd=D.forwardRef((e,t)=>{let n=Td(Ld,e.__scopeDialog),r=D.useRef(null),i=u(t,n.contentRef,r);return D.useEffect(()=>{let e=r.current;if(e)return bd(e)},[]),(0,F.jsx)(Vd,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,onCloseAutoFocus:Q(e.onCloseAutoFocus,e=>{e.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:Q(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0;(t.button===2||n)&&e.preventDefault()}),onFocusOutside:Q(e.onFocusOutside,e=>e.preventDefault())})}),Bd=D.forwardRef((e,t)=>{let n=Td(Ld,e.__scopeDialog),r=D.useRef(!1),i=D.useRef(!1);return(0,F.jsx)(Vd,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),t.defaultPrevented||(r.current||n.triggerRef.current?.focus(),t.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),t.defaultPrevented||(r.current=!0,t.detail.originalEvent.type===`pointerdown`&&(i.current=!0));let a=t.target;n.triggerRef.current?.contains(a)&&t.preventDefault(),t.detail.originalEvent.type===`focusin`&&i.current&&t.preventDefault()}})}),Vd=D.forwardRef((e,t)=>{let{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:a,...o}=e,s=Td(Ld,n);return tu(),(0,F.jsx)(F.Fragment,{children:(0,F.jsx)(Ml,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:a,children:(0,F.jsx)(bl,{role:`dialog`,id:s.contentId,"aria-describedby":s.descriptionId,"aria-labelledby":s.titleId,"data-state":Jd(s.open),...o,ref:t,deferPointerDownOutside:!0,onDismiss:()=>s.onOpenChange(!1)})})})}),Hd=`DialogTitle`,Ud=D.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=Td(Hd,n);return(0,F.jsx)($.h2,{id:i.titleId,...r,ref:t})});Ud.displayName=Hd;var Wd=`DialogDescription`,Gd=D.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=Td(Wd,n);return(0,F.jsx)($.p,{id:i.descriptionId,...r,ref:t})});Gd.displayName=Wd;var Kd=`DialogClose`,qd=D.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=Td(Kd,n);return(0,F.jsx)($.button,{type:`button`,...r,ref:t,onClick:Q(e.onClick,()=>i.onOpenChange(!1))})});qd.displayName=Kd;function Jd(e){return e?`open`:`closed`}function Yd(e){return(0,F.jsx)(Ed,{"data-slot":`responsive-dialog`,...e})}function Xd({className:e,children:t,showCloseButton:n=!0,dismissable:r=!0,onEscapeKeyDown:i,...a}){return(0,F.jsxs)(Md,{children:[(0,F.jsx)(Pd,{className:`data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-[120] bg-black/50`}),(0,F.jsxs)(Rd,{"data-slot":`responsive-dialog-content`,onInteractOutside:r?void 0:e=>e.preventDefault(),onEscapeKeyDown:e=>{let t=e.target,n=t?.ownerDocument??document,a=!!(typeof t?.closest==`function`?t:n.activeElement)?.closest(`[role="combobox"][aria-expanded="true"]`);(!r||a)&&e.preventDefault(),i?.(e)},className:l(`bg-card text-card-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed z-[130] flex flex-col border shadow-xl outline-none duration-200`,`inset-x-0 bottom-0 max-h-[90dvh] rounded-t-2xl pb-[env(safe-area-inset-bottom)] data-[state=open]:slide-in-from-bottom-4 data-[state=closed]:slide-out-to-bottom-4`,`sm:inset-x-auto sm:bottom-auto sm:top-1/2 sm:left-1/2 sm:max-h-[85vh] sm:w-full sm:max-w-md sm:-translate-x-1/2 sm:-translate-y-1/2 sm:rounded-2xl sm:pb-0 sm:data-[state=open]:slide-in-from-bottom-0 sm:data-[state=open]:zoom-in-95 sm:data-[state=closed]:zoom-out-95`,e),...a,children:[t,n&&r&&(0,F.jsxs)(qd,{className:`ring-offset-background focus:ring-ring absolute top-3.5 right-3.5 rounded-md p-1 text-muted-foreground opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:outline-hidden disabled:pointer-events-none [&_svg]:size-4`,children:[(0,F.jsx)(E,{}),(0,F.jsx)(`span`,{className:`sr-only`,children:`关闭`})]})]})]})}function Zd({className:e,...t}){return(0,F.jsx)(Ud,{"data-slot":`responsive-dialog-title`,className:l(`text-base leading-none font-semibold`,e),...t})}function Qd({className:e,...t}){return(0,F.jsx)(Gd,{"data-slot":`responsive-dialog-description`,className:l(`text-muted-foreground text-sm`,e),...t})}function $d({className:e,type:t,...n}){return(0,F.jsx)(`input`,{type:t,"data-slot":`input`,className:l(`file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground border-input flex h-9 w-full min-w-0 rounded-md border bg-background px-3 py-1 text-base shadow-xs transition-[color,box-shadow] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm`,`focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]`,`aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive`,e),...n})}var ef=`copilot_ui_theme_v1`,tf=()=>typeof window<`u`?window.matchMedia?.(`(prefers-color-scheme: dark)`):void 0,nf=()=>tf()?.matches?`dark`:`light`,rf=e=>e===`system`?nf():e;function af(){try{let e=localStorage.getItem(ef);if(e===`light`||e===`dark`||e===`system`)return e}catch{}return`system`}var of=se((e,t)=>({themePreference:af(),themeMode:rf(af()),setThemePreference:t=>{try{localStorage.setItem(ef,t)}catch{}e({themePreference:t,themeMode:rf(t)})},toggleTheme:()=>{let e=t().themeMode===`dark`?`light`:`dark`;t().setThemePreference(e)}}));tf()?.addEventListener?.(`change`,()=>{of.getState().themePreference===`system`&&of.setState({themeMode:nf()})});var sf=`mermaid_enhancement_enabled`,cf=()=>localStorage.getItem(sf)!==`false`,lf=e=>{localStorage.setItem(sf,e.toString())},uf=()=>`
|
|
59
59
|
|
|
60
60
|
## 📊 Visual Representation Guidelines
|
|
61
61
|
|
|
@@ -80,7 +80,7 @@ When explaining concepts, processes, relationships, or data structures, use Merm
|
|
|
80
80
|
- Keep participant names simple (no spaces): \`participant UserService\`
|
|
81
81
|
- Arrow syntax: \`-->\` (solid), \`-.->\` (dotted), \`==>\` (thick), \`-->|label|\` (labeled)
|
|
82
82
|
|
|
83
|
-
Include relevant diagrams when discussing architecture, workflows, data flow, or relationships.`,
|
|
83
|
+
Include relevant diagrams when discussing architecture, workflows, data flow, or relationships.`,df=`task_enhancement_enabled`,ff=`todo_enhancement_enabled`,pf=e=>e===`false`,mf=()=>{let e=localStorage.getItem(df);if(e===null){let t=localStorage.getItem(ff);t!==null&&(e=t,localStorage.setItem(df,t),localStorage.removeItem(ff))}return!pf(e)},hf=e=>{localStorage.setItem(df,e.toString())},gf=()=>`
|
|
84
84
|
|
|
85
85
|
## Task Management Rules
|
|
86
86
|
|
|
@@ -92,9 +92,9 @@ When marking a task as completed, always fill in the \`summary\` field with a co
|
|
|
92
92
|
Do not use Markdown checkbox lists as a substitute for Task.
|
|
93
93
|
Skip Task only for simple one-step requests.
|
|
94
94
|
Use SubAgent only when the user explicitly requests delegated/parallel sub-agent work.
|
|
95
|
-
`,
|
|
95
|
+
`,_f=()=>{if(typeof window<`u`&&`__TAURI__`in window){let e=(navigator.platform??``).toLowerCase();if(e.startsWith(`win`))return`windows`;if(e.startsWith(`mac`))return`macos`;if(e.startsWith(`linux`))return`linux`}if(typeof navigator<`u`){let e=(navigator.userAgent??``).toLowerCase();if(e.includes(`windows`))return`windows`;if(e.includes(`mac`))return`macos`;if(e.includes(`linux`))return`linux`}return`unknown`},vf=e=>{switch(e){case`windows`:return`Windows`;case`macos`:return`macOS`;case`linux`:return`Linux`;default:return`Unknown OS`}},yf=()=>{let e=_f(),t=`## 🖥️ Operating System Information
|
|
96
96
|
|
|
97
|
-
You are running on **${
|
|
97
|
+
You are running on **${vf(e)}**.`;return e===`windows`?t+`
|
|
98
98
|
|
|
99
99
|
### Windows-Specific Notes:
|
|
100
100
|
|
|
@@ -125,7 +125,7 @@ You are running on **${pf(e)}**.`;return e===`windows`?t+`
|
|
|
125
125
|
|
|
126
126
|
- **File Paths**: Linux uses Unix-style paths with forward slashes (/)
|
|
127
127
|
- **Home Directory**: The tilde (~) expands to /home/[username]
|
|
128
|
-
- **Case Sensitivity**: Linux file systems are case-sensitive (File.txt and file.txt are different files)`:t},
|
|
129
|
-
`),
|
|
128
|
+
- **Case Sensitivity**: Linux file systems are case-sensitive (File.txt and file.txt are different files)`:t},bf=`copilot_conclusion_with_options_enhancement_enabled`,xf=()=>localStorage.getItem(bf)===`true`,Sf=e=>{try{localStorage.setItem(bf,e.toString())}catch(e){console.error(`[copilotConclusionWithOptionsEnhancement] Failed to persist setting:`,e)}},Cf=()=>"\n## Copilot Completion Confirmation Rule\n\nBefore ending the task, always call the `conclusion_with_options` tool to confirm whether the user still has additional requests.\n\nRequirements:\n- This rule applies at the end of every task turn.\n- Do not ask final confirmation in plain assistant text; use `conclusion_with_options` for the final confirmation step.\n- The `conclusion_with_options` call must include a `conclusion` object in its arguments.\n- `conclusion.summary` is required and should summarize progress/conclusions.\n- `conclusion.mermaid.graph` is required and must contain a Mermaid graph.\n- Ask a clear confirmation question and include `OK` as one of the selectable options.\n- Only treat the task as finished when the user explicitly selects or replies `OK`.\n- If the user gives any other response, continue assisting and do not end the task.\n- A response that ends the task without `conclusion_with_options` is invalid and must be corrected before finishing.\n",wf=`bamboo_system_prompt_enhancement`,Tf=()=>[`## Bamboo Operational Guidance`,``,"- For recurring or delayed tasks, use the `schedule_tasks` tool to create and manage schedule jobs instead of only describing manual steps.","- The `schedule_tasks` tool supports: `list`, `create`, `patch`, `delete`, `run_now`, and `list_sessions`.","- Bamboo configuration is stored in `${BAMBOO_DATA_DIR}/config.json`.","- Default config path: `~/.bamboo/config.json` (macOS/Linux) or `%USERPROFILE%\\\\.bamboo\\\\config.json` (Windows)."].join(`
|
|
129
|
+
`),Ef=e=>e.map(e=>e.trim()).filter(e=>e.length>0).join(`
|
|
130
130
|
|
|
131
|
-
`),Sf=()=>{try{return localStorage.getItem(yf)??``}catch(e){return console.error(`Failed to load system prompt enhancement:`,e),``}},Cf=e=>{try{let t=e.trim()?e:``;localStorage.setItem(yf,t)}catch(e){console.error(`Failed to save system prompt enhancement:`,e)}},wf=e=>{let t=[];t.push(mf().trim()),t.push(bf().trim());let n=Sf().trim();return n&&t.push(n),nf()&&t.push(af().trim()),lf()&&t.push(df().trim()),(e??``).trim().toLowerCase()===`copilot`&&gf()&&t.push(vf().trim()),t},Tf=e=>xf(wf(e)),Ef=`lotus_vdi_safe_mode`,Df=`lotus-vdi-safe-mode-change`,Of=()=>{try{return localStorage.getItem(Ef)===`true`}catch{return!1}},kf=e=>{try{localStorage.setItem(Ef,e.toString())}catch(e){console.error(`[vdiSafeMode] Failed to persist setting:`,e)}},Af=e=>{let t=t=>{t.key!==null&&t.key!==Ef||e()};return window.addEventListener(`storage`,t),window.addEventListener(Df,e),()=>{window.removeEventListener(`storage`,t),window.removeEventListener(Df,e)}};function jf(e){let t=e+`CollectionProvider`,[n,r]=Xc(t),[i,a]=n(t,{collectionRef:{current:null},itemMap:new Map}),o=e=>{let{scope:t,children:n}=e,r=D.useRef(null),a=D.useRef(new Map).current;return(0,F.jsx)(i,{scope:t,itemMap:a,collectionRef:r,children:n})};o.displayName=t;let s=e+`CollectionSlot`,c=f(s),l=D.forwardRef((e,t)=>{let{scope:n,children:r}=e;return(0,F.jsx)(c,{ref:u(t,a(s,n).collectionRef),children:r})});l.displayName=s;let d=e+`CollectionItemSlot`,p=`data-radix-collection-item`,m=f(d),h=D.forwardRef((e,t)=>{let{scope:n,children:r,...i}=e,o=D.useRef(null),s=u(t,o),c=a(d,n);return D.useEffect(()=>(c.itemMap.set(o,{ref:o,...i}),()=>void c.itemMap.delete(o))),(0,F.jsx)(m,{[p]:``,ref:s,children:r})});h.displayName=d;function g(t){let n=a(e+`CollectionConsumer`,t);return D.useCallback(()=>{let e=n.collectionRef.current;if(!e)return[];let t=Array.from(e.querySelectorAll(`[${p}]`));return Array.from(n.itemMap.values()).sort((e,n)=>t.indexOf(e.ref.current)-t.indexOf(n.ref.current))},[n.collectionRef,n.itemMap])}return[{Provider:o,Slot:l,ItemSlot:h},g,r]}var Mf=D.createContext(void 0);function Nf(e){let t=D.useContext(Mf);return e||t||`ltr`}var Pf=[`top`,`right`,`bottom`,`left`],Ff=Math.min,If=Math.max,Lf=Math.round,Rf=Math.floor,zf=e=>({x:e,y:e}),Bf={left:`right`,right:`left`,bottom:`top`,top:`bottom`};function Vf(e,t,n){return If(e,Ff(t,n))}function Hf(e,t){return typeof e==`function`?e(t):e}function Uf(e){return e.split(`-`)[0]}function Wf(e){return e.split(`-`)[1]}function Gf(e){return e===`x`?`y`:`x`}function Kf(e){return e===`y`?`height`:`width`}function qf(e){let t=e[0];return t===`t`||t===`b`?`y`:`x`}function Jf(e){return Gf(qf(e))}function Yf(e,t,n){n===void 0&&(n=!1);let r=Wf(e),i=Jf(e),a=Kf(i),o=i===`x`?r===(n?`end`:`start`)?`right`:`left`:r===`start`?`bottom`:`top`;return t.reference[a]>t.floating[a]&&(o=ip(o)),[o,ip(o)]}function Xf(e){let t=ip(e);return[Zf(e),t,Zf(t)]}function Zf(e){return e.includes(`start`)?e.replace(`start`,`end`):e.replace(`end`,`start`)}var Qf=[`left`,`right`],$f=[`right`,`left`],ep=[`top`,`bottom`],tp=[`bottom`,`top`];function np(e,t,n){switch(e){case`top`:case`bottom`:return n?t?$f:Qf:t?Qf:$f;case`left`:case`right`:return t?ep:tp;default:return[]}}function rp(e,t,n,r){let i=Wf(e),a=np(Uf(e),n===`start`,r);return i&&(a=a.map(e=>e+`-`+i),t&&(a=a.concat(a.map(Zf)))),a}function ip(e){let t=Uf(e);return Bf[t]+e.slice(t.length)}function ap(e){return{top:0,right:0,bottom:0,left:0,...e}}function op(e){return typeof e==`number`?{top:e,right:e,bottom:e,left:e}:ap(e)}function sp(e){let{x:t,y:n,width:r,height:i}=e;return{width:r,height:i,top:n,left:t,right:t+r,bottom:n+i,x:t,y:n}}function cp(e,t,n){let{reference:r,floating:i}=e,a=qf(t),o=Jf(t),s=Kf(o),c=Uf(t),l=a===`y`,u=r.x+r.width/2-i.width/2,d=r.y+r.height/2-i.height/2,f=r[s]/2-i[s]/2,p;switch(c){case`top`:p={x:u,y:r.y-i.height};break;case`bottom`:p={x:u,y:r.y+r.height};break;case`right`:p={x:r.x+r.width,y:d};break;case`left`:p={x:r.x-i.width,y:d};break;default:p={x:r.x,y:r.y}}switch(Wf(t)){case`start`:p[o]-=f*(n&&l?-1:1);break;case`end`:p[o]+=f*(n&&l?-1:1);break}return p}async function lp(e,t){t===void 0&&(t={});let{x:n,y:r,platform:i,rects:a,elements:o,strategy:s}=e,{boundary:c=`clippingAncestors`,rootBoundary:l=`viewport`,elementContext:u=`floating`,altBoundary:d=!1,padding:f=0}=Hf(t,e),p=op(f),m=o[d?u===`floating`?`reference`:`floating`:u],h=sp(await i.getClippingRect({element:await(i.isElement==null?void 0:i.isElement(m))??!0?m:m.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(o.floating)),boundary:c,rootBoundary:l,strategy:s})),g=u===`floating`?{x:n,y:r,width:a.floating.width,height:a.floating.height}:a.reference,_=await(i.getOffsetParent==null?void 0:i.getOffsetParent(o.floating)),v=await(i.isElement==null?void 0:i.isElement(_))&&await(i.getScale==null?void 0:i.getScale(_))||{x:1,y:1},y=sp(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:o,rect:g,offsetParent:_,strategy:s}):g);return{top:(h.top-y.top+p.top)/v.y,bottom:(y.bottom-h.bottom+p.bottom)/v.y,left:(h.left-y.left+p.left)/v.x,right:(y.right-h.right+p.right)/v.x}}var up=50,dp=async(e,t,n)=>{let{placement:r=`bottom`,strategy:i=`absolute`,middleware:a=[],platform:o}=n,s=o.detectOverflow?o:{...o,detectOverflow:lp},c=await(o.isRTL==null?void 0:o.isRTL(t)),l=await o.getElementRects({reference:e,floating:t,strategy:i}),{x:u,y:d}=cp(l,r,c),f=r,p=0,m={};for(let n=0;n<a.length;n++){let h=a[n];if(!h)continue;let{name:g,fn:_}=h,{x:v,y,data:b,reset:x}=await _({x:u,y:d,initialPlacement:r,placement:f,strategy:i,middlewareData:m,rects:l,platform:s,elements:{reference:e,floating:t}});u=v??u,d=y??d,m[g]={...m[g],...b},x&&p<up&&(p++,typeof x==`object`&&(x.placement&&(f=x.placement),x.rects&&(l=x.rects===!0?await o.getElementRects({reference:e,floating:t,strategy:i}):x.rects),{x:u,y:d}=cp(l,f,c)),n=-1)}return{x:u,y:d,placement:f,strategy:i,middlewareData:m}},fp=e=>({name:`arrow`,options:e,async fn(t){let{x:n,y:r,placement:i,rects:a,platform:o,elements:s,middlewareData:c}=t,{element:l,padding:u=0}=Hf(e,t)||{};if(l==null)return{};let d=op(u),f={x:n,y:r},p=Jf(i),m=Kf(p),h=await o.getDimensions(l),g=p===`y`,_=g?`top`:`left`,v=g?`bottom`:`right`,y=g?`clientHeight`:`clientWidth`,b=a.reference[m]+a.reference[p]-f[p]-a.floating[m],x=f[p]-a.reference[p],S=await(o.getOffsetParent==null?void 0:o.getOffsetParent(l)),C=S?S[y]:0;(!C||!await(o.isElement==null?void 0:o.isElement(S)))&&(C=s.floating[y]||a.floating[m]);let w=b/2-x/2,T=C/2-h[m]/2-1,E=Ff(d[_],T),D=Ff(d[v],T),O=E,ee=C-h[m]-D,k=C/2-h[m]/2+w,te=Vf(O,k,ee),ne=!c.arrow&&Wf(i)!=null&&k!==te&&a.reference[m]/2-(k<O?E:D)-h[m]/2<0,A=ne?k<O?k-O:k-ee:0;return{[p]:f[p]+A,data:{[p]:te,centerOffset:k-te-A,...ne&&{alignmentOffset:A}},reset:ne}}}),pp=function(e){return e===void 0&&(e={}),{name:`flip`,options:e,async fn(t){var n;let{placement:r,middlewareData:i,rects:a,initialPlacement:o,platform:s,elements:c}=t,{mainAxis:l=!0,crossAxis:u=!0,fallbackPlacements:d,fallbackStrategy:f=`bestFit`,fallbackAxisSideDirection:p=`none`,flipAlignment:m=!0,...h}=Hf(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};let g=Uf(r),_=qf(o),v=Uf(o)===o,y=await(s.isRTL==null?void 0:s.isRTL(c.floating)),b=d||(v||!m?[ip(o)]:Xf(o)),x=p!==`none`;!d&&x&&b.push(...rp(o,m,p,y));let S=[o,...b],C=await s.detectOverflow(t,h),w=[],T=i.flip?.overflows||[];if(l&&w.push(C[g]),u){let e=Yf(r,a,y);w.push(C[e[0]],C[e[1]])}if(T=[...T,{placement:r,overflows:w}],!w.every(e=>e<=0)){let e=(i.flip?.index||0)+1,t=S[e];if(t&&(!(u===`alignment`&&_!==qf(t))||T.every(e=>qf(e.placement)===_?e.overflows[0]>0:!0)))return{data:{index:e,overflows:T},reset:{placement:t}};let n=T.filter(e=>e.overflows[0]<=0).sort((e,t)=>e.overflows[1]-t.overflows[1])[0]?.placement;if(!n)switch(f){case`bestFit`:{let e=T.filter(e=>{if(x){let t=qf(e.placement);return t===_||t===`y`}return!0}).map(e=>[e.placement,e.overflows.filter(e=>e>0).reduce((e,t)=>e+t,0)]).sort((e,t)=>e[1]-t[1])[0]?.[0];e&&(n=e);break}case`initialPlacement`:n=o;break}if(r!==n)return{reset:{placement:n}}}return{}}}};function mp(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function hp(e){return Pf.some(t=>e[t]>=0)}var gp=function(e){return e===void 0&&(e={}),{name:`hide`,options:e,async fn(t){let{rects:n,platform:r}=t,{strategy:i=`referenceHidden`,...a}=Hf(e,t);switch(i){case`referenceHidden`:{let e=mp(await r.detectOverflow(t,{...a,elementContext:`reference`}),n.reference);return{data:{referenceHiddenOffsets:e,referenceHidden:hp(e)}}}case`escaped`:{let e=mp(await r.detectOverflow(t,{...a,altBoundary:!0}),n.floating);return{data:{escapedOffsets:e,escaped:hp(e)}}}default:return{}}}}},_p=new Set([`left`,`top`]);async function vp(e,t){let{placement:n,platform:r,elements:i}=e,a=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=Uf(n),s=Wf(n),c=qf(n)===`y`,l=_p.has(o)?-1:1,u=a&&c?-1:1,d=Hf(t,e),{mainAxis:f,crossAxis:p,alignmentAxis:m}=typeof d==`number`?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return s&&typeof m==`number`&&(p=s===`end`?m*-1:m),c?{x:p*u,y:f*l}:{x:f*l,y:p*u}}var yp=function(e){return e===void 0&&(e=0),{name:`offset`,options:e,async fn(t){var n;let{x:r,y:i,placement:a,middlewareData:o}=t,s=await vp(t,e);return a===o.offset?.placement&&(n=o.arrow)!=null&&n.alignmentOffset?{}:{x:r+s.x,y:i+s.y,data:{...s,placement:a}}}}},bp=function(e){return e===void 0&&(e={}),{name:`shift`,options:e,async fn(t){let{x:n,y:r,placement:i,platform:a}=t,{mainAxis:o=!0,crossAxis:s=!1,limiter:c={fn:e=>{let{x:t,y:n}=e;return{x:t,y:n}}},...l}=Hf(e,t),u={x:n,y:r},d=await a.detectOverflow(t,l),f=qf(Uf(i)),p=Gf(f),m=u[p],h=u[f];if(o){let e=p===`y`?`top`:`left`,t=p===`y`?`bottom`:`right`,n=m+d[e],r=m-d[t];m=Vf(n,m,r)}if(s){let e=f===`y`?`top`:`left`,t=f===`y`?`bottom`:`right`,n=h+d[e],r=h-d[t];h=Vf(n,h,r)}let g=c.fn({...t,[p]:m,[f]:h});return{...g,data:{x:g.x-n,y:g.y-r,enabled:{[p]:o,[f]:s}}}}}},xp=function(e){return e===void 0&&(e={}),{options:e,fn(t){let{x:n,y:r,placement:i,rects:a,middlewareData:o}=t,{offset:s=0,mainAxis:c=!0,crossAxis:l=!0}=Hf(e,t),u={x:n,y:r},d=qf(i),f=Gf(d),p=u[f],m=u[d],h=Hf(s,t),g=typeof h==`number`?{mainAxis:h,crossAxis:0}:{mainAxis:0,crossAxis:0,...h};if(c){let e=f===`y`?`height`:`width`,t=a.reference[f]-a.floating[e]+g.mainAxis,n=a.reference[f]+a.reference[e]-g.mainAxis;p<t?p=t:p>n&&(p=n)}if(l){let e=f===`y`?`width`:`height`,t=_p.has(Uf(i)),n=a.reference[d]-a.floating[e]+(t&&o.offset?.[d]||0)+(t?0:g.crossAxis),r=a.reference[d]+a.reference[e]+(t?0:o.offset?.[d]||0)-(t?g.crossAxis:0);m<n?m=n:m>r&&(m=r)}return{[f]:p,[d]:m}}}},Sp=function(e){return e===void 0&&(e={}),{name:`size`,options:e,async fn(t){var n,r;let{placement:i,rects:a,platform:o,elements:s}=t,{apply:c=()=>{},...l}=Hf(e,t),u=await o.detectOverflow(t,l),d=Uf(i),f=Wf(i),p=qf(i)===`y`,{width:m,height:h}=a.floating,g,_;d===`top`||d===`bottom`?(g=d,_=f===(await(o.isRTL==null?void 0:o.isRTL(s.floating))?`start`:`end`)?`left`:`right`):(_=d,g=f===`end`?`top`:`bottom`);let v=h-u.top-u.bottom,y=m-u.left-u.right,b=Ff(h-u[g],v),x=Ff(m-u[_],y),S=!t.middlewareData.shift,C=b,w=x;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(w=y),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(C=v),S&&!f){let e=If(u.left,0),t=If(u.right,0),n=If(u.top,0),r=If(u.bottom,0);p?w=m-2*(e!==0||t!==0?e+t:If(u.left,u.right)):C=h-2*(n!==0||r!==0?n+r:If(u.top,u.bottom))}await c({...t,availableWidth:w,availableHeight:C});let T=await o.getDimensions(s.floating);return m!==T.width||h!==T.height?{reset:{rects:!0}}:{}}}};function Cp(){return typeof window<`u`}function wp(e){return Dp(e)?(e.nodeName||``).toLowerCase():`#document`}function Tp(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Ep(e){return((Dp(e)?e.ownerDocument:e.document)||window.document)?.documentElement}function Dp(e){return Cp()?e instanceof Node||e instanceof Tp(e).Node:!1}function Op(e){return Cp()?e instanceof Element||e instanceof Tp(e).Element:!1}function kp(e){return Cp()?e instanceof HTMLElement||e instanceof Tp(e).HTMLElement:!1}function Ap(e){return!Cp()||typeof ShadowRoot>`u`?!1:e instanceof ShadowRoot||e instanceof Tp(e).ShadowRoot}function jp(e){let{overflow:t,overflowX:n,overflowY:r,display:i}=Hp(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&i!==`inline`&&i!==`contents`}function Mp(e){return/^(table|td|th)$/.test(wp(e))}function Np(e){try{if(e.matches(`:popover-open`))return!0}catch{}try{return e.matches(`:modal`)}catch{return!1}}var Pp=/transform|translate|scale|rotate|perspective|filter/,Fp=/paint|layout|strict|content/,Ip=e=>!!e&&e!==`none`,Lp;function Rp(e){let t=Op(e)?Hp(e):e;return Ip(t.transform)||Ip(t.translate)||Ip(t.scale)||Ip(t.rotate)||Ip(t.perspective)||!Bp()&&(Ip(t.backdropFilter)||Ip(t.filter))||Pp.test(t.willChange||``)||Fp.test(t.contain||``)}function zp(e){let t=Wp(e);for(;kp(t)&&!Vp(t);){if(Rp(t))return t;if(Np(t))return null;t=Wp(t)}return null}function Bp(){return Lp??=typeof CSS<`u`&&CSS.supports&&CSS.supports(`-webkit-backdrop-filter`,`none`),Lp}function Vp(e){return/^(html|body|#document)$/.test(wp(e))}function Hp(e){return Tp(e).getComputedStyle(e)}function Up(e){return Op(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Wp(e){if(wp(e)===`html`)return e;let t=e.assignedSlot||e.parentNode||Ap(e)&&e.host||Ep(e);return Ap(t)?t.host:t}function Gp(e){let t=Wp(e);return Vp(t)?e.ownerDocument?e.ownerDocument.body:e.body:kp(t)&&jp(t)?t:Gp(t)}function Kp(e,t,n){t===void 0&&(t=[]),n===void 0&&(n=!0);let r=Gp(e),i=r===e.ownerDocument?.body,a=Tp(r);if(i){let e=qp(a);return t.concat(a,a.visualViewport||[],jp(r)?r:[],e&&n?Kp(e):[])}else return t.concat(r,Kp(r,[],n))}function qp(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function Jp(e){let t=Hp(e),n=parseFloat(t.width)||0,r=parseFloat(t.height)||0,i=kp(e),a=i?e.offsetWidth:n,o=i?e.offsetHeight:r,s=Lf(n)!==a||Lf(r)!==o;return s&&(n=a,r=o),{width:n,height:r,$:s}}function Yp(e){return Op(e)?e:e.contextElement}function Xp(e){let t=Yp(e);if(!kp(t))return zf(1);let n=t.getBoundingClientRect(),{width:r,height:i,$:a}=Jp(t),o=(a?Lf(n.width):n.width)/r,s=(a?Lf(n.height):n.height)/i;return(!o||!Number.isFinite(o))&&(o=1),(!s||!Number.isFinite(s))&&(s=1),{x:o,y:s}}var Zp=zf(0);function Qp(e){let t=Tp(e);return!Bp()||!t.visualViewport?Zp:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function $p(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==Tp(e)?!1:t}function em(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);let i=e.getBoundingClientRect(),a=Yp(e),o=zf(1);t&&(r?Op(r)&&(o=Xp(r)):o=Xp(e));let s=$p(a,n,r)?Qp(a):zf(0),c=(i.left+s.x)/o.x,l=(i.top+s.y)/o.y,u=i.width/o.x,d=i.height/o.y;if(a){let e=Tp(a),t=r&&Op(r)?Tp(r):r,n=e,i=qp(n);for(;i&&r&&t!==n;){let e=Xp(i),t=i.getBoundingClientRect(),r=Hp(i),a=t.left+(i.clientLeft+parseFloat(r.paddingLeft))*e.x,o=t.top+(i.clientTop+parseFloat(r.paddingTop))*e.y;c*=e.x,l*=e.y,u*=e.x,d*=e.y,c+=a,l+=o,n=Tp(i),i=qp(n)}}return sp({width:u,height:d,x:c,y:l})}function tm(e,t){let n=Up(e).scrollLeft;return t?t.left+n:em(Ep(e)).left+n}function nm(e,t){let n=e.getBoundingClientRect();return{x:n.left+t.scrollLeft-tm(e,n),y:n.top+t.scrollTop}}function rm(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e,a=i===`fixed`,o=Ep(r),s=t?Np(t.floating):!1;if(r===o||s&&a)return n;let c={scrollLeft:0,scrollTop:0},l=zf(1),u=zf(0),d=kp(r);if((d||!d&&!a)&&((wp(r)!==`body`||jp(o))&&(c=Up(r)),d)){let e=em(r);l=Xp(r),u.x=e.x+r.clientLeft,u.y=e.y+r.clientTop}let f=o&&!d&&!a?nm(o,c):zf(0);return{width:n.width*l.x,height:n.height*l.y,x:n.x*l.x-c.scrollLeft*l.x+u.x+f.x,y:n.y*l.y-c.scrollTop*l.y+u.y+f.y}}function im(e){return Array.from(e.getClientRects())}function am(e){let t=Ep(e),n=Up(e),r=e.ownerDocument.body,i=If(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),a=If(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight),o=-n.scrollLeft+tm(e),s=-n.scrollTop;return Hp(r).direction===`rtl`&&(o+=If(t.clientWidth,r.clientWidth)-i),{width:i,height:a,x:o,y:s}}var om=25;function sm(e,t){let n=Tp(e),r=Ep(e),i=n.visualViewport,a=r.clientWidth,o=r.clientHeight,s=0,c=0;if(i){a=i.width,o=i.height;let e=Bp();(!e||e&&t===`fixed`)&&(s=i.offsetLeft,c=i.offsetTop)}let l=tm(r);if(l<=0){let e=r.ownerDocument,t=e.body,n=getComputedStyle(t),i=e.compatMode===`CSS1Compat`&&parseFloat(n.marginLeft)+parseFloat(n.marginRight)||0,o=Math.abs(r.clientWidth-t.clientWidth-i);o<=om&&(a-=o)}else l<=om&&(a+=l);return{width:a,height:o,x:s,y:c}}function cm(e,t){let n=em(e,!0,t===`fixed`),r=n.top+e.clientTop,i=n.left+e.clientLeft,a=kp(e)?Xp(e):zf(1);return{width:e.clientWidth*a.x,height:e.clientHeight*a.y,x:i*a.x,y:r*a.y}}function lm(e,t,n){let r;if(t===`viewport`)r=sm(e,n);else if(t===`document`)r=am(Ep(e));else if(Op(t))r=cm(t,n);else{let n=Qp(e);r={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return sp(r)}function um(e,t){let n=Wp(e);return n===t||!Op(n)||Vp(n)?!1:Hp(n).position===`fixed`||um(n,t)}function dm(e,t){let n=t.get(e);if(n)return n;let r=Kp(e,[],!1).filter(e=>Op(e)&&wp(e)!==`body`),i=null,a=Hp(e).position===`fixed`,o=a?Wp(e):e;for(;Op(o)&&!Vp(o);){let t=Hp(o),n=Rp(o);!n&&t.position===`fixed`&&(i=null),(a?!n&&!i:!n&&t.position===`static`&&i&&(i.position===`absolute`||i.position===`fixed`)||jp(o)&&!n&&um(e,o))?r=r.filter(e=>e!==o):i=t,o=Wp(o)}return t.set(e,r),r}function fm(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e,a=[...n===`clippingAncestors`?Np(t)?[]:dm(t,this._c):[].concat(n),r],o=lm(t,a[0],i),s=o.top,c=o.right,l=o.bottom,u=o.left;for(let e=1;e<a.length;e++){let n=lm(t,a[e],i);s=If(n.top,s),c=Ff(n.right,c),l=Ff(n.bottom,l),u=If(n.left,u)}return{width:c-u,height:l-s,x:u,y:s}}function pm(e){let{width:t,height:n}=Jp(e);return{width:t,height:n}}function mm(e,t,n){let r=kp(t),i=Ep(t),a=n===`fixed`,o=em(e,!0,a,t),s={scrollLeft:0,scrollTop:0},c=zf(0);function l(){c.x=tm(i)}if(r||!r&&!a)if((wp(t)!==`body`||jp(i))&&(s=Up(t)),r){let e=em(t,!0,a,t);c.x=e.x+t.clientLeft,c.y=e.y+t.clientTop}else i&&l();a&&!r&&i&&l();let u=i&&!r&&!a?nm(i,s):zf(0);return{x:o.left+s.scrollLeft-c.x-u.x,y:o.top+s.scrollTop-c.y-u.y,width:o.width,height:o.height}}function hm(e){return Hp(e).position===`static`}function gm(e,t){if(!kp(e)||Hp(e).position===`fixed`)return null;if(t)return t(e);let n=e.offsetParent;return Ep(e)===n&&(n=n.ownerDocument.body),n}function _m(e,t){let n=Tp(e);if(Np(e))return n;if(!kp(e)){let t=Wp(e);for(;t&&!Vp(t);){if(Op(t)&&!hm(t))return t;t=Wp(t)}return n}let r=gm(e,t);for(;r&&Mp(r)&&hm(r);)r=gm(r,t);return r&&Vp(r)&&hm(r)&&!Rp(r)?n:r||zp(e)||n}var vm=async function(e){let t=this.getOffsetParent||_m,n=this.getDimensions,r=await n(e.floating);return{reference:mm(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function ym(e){return Hp(e).direction===`rtl`}var bm={convertOffsetParentRelativeRectToViewportRelativeRect:rm,getDocumentElement:Ep,getClippingRect:fm,getOffsetParent:_m,getElementRects:vm,getClientRects:im,getDimensions:pm,getScale:Xp,isElement:Op,isRTL:ym};function xm(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Sm(e,t){let n=null,r,i=Ep(e);function a(){var e;clearTimeout(r),(e=n)==null||e.disconnect(),n=null}function o(s,c){s===void 0&&(s=!1),c===void 0&&(c=1),a();let l=e.getBoundingClientRect(),{left:u,top:d,width:f,height:p}=l;if(s||t(),!f||!p)return;let m=Rf(d),h=Rf(i.clientWidth-(u+f)),g=Rf(i.clientHeight-(d+p)),_=Rf(u),v={rootMargin:-m+`px `+-h+`px `+-g+`px `+-_+`px`,threshold:If(0,Ff(1,c))||1},y=!0;function b(t){let n=t[0].intersectionRatio;if(n!==c){if(!y)return o();n?o(!1,n):r=setTimeout(()=>{o(!1,1e-7)},1e3)}n===1&&!xm(l,e.getBoundingClientRect())&&o(),y=!1}try{n=new IntersectionObserver(b,{...v,root:i.ownerDocument})}catch{n=new IntersectionObserver(b,v)}n.observe(e)}return o(!0),a}function Cm(e,t,n,r){r===void 0&&(r={});let{ancestorScroll:i=!0,ancestorResize:a=!0,elementResize:o=typeof ResizeObserver==`function`,layoutShift:s=typeof IntersectionObserver==`function`,animationFrame:c=!1}=r,l=Yp(e),u=i||a?[...l?Kp(l):[],...t?Kp(t):[]]:[];u.forEach(e=>{i&&e.addEventListener(`scroll`,n,{passive:!0}),a&&e.addEventListener(`resize`,n)});let d=l&&s?Sm(l,n):null,f=-1,p=null;o&&(p=new ResizeObserver(e=>{let[r]=e;r&&r.target===l&&p&&t&&(p.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var e;(e=p)==null||e.observe(t)})),n()}),l&&!c&&p.observe(l),t&&p.observe(t));let m,h=c?em(e):null;c&&g();function g(){let t=em(e);h&&!xm(h,t)&&n(),h=t,m=requestAnimationFrame(g)}return n(),()=>{var e;u.forEach(e=>{i&&e.removeEventListener(`scroll`,n),a&&e.removeEventListener(`resize`,n)}),d?.(),(e=p)==null||e.disconnect(),p=null,c&&cancelAnimationFrame(m)}}var wm=yp,Tm=bp,Em=pp,Dm=Sp,Om=gp,km=fp,Am=xp,jm=(e,t,n)=>{let r=new Map,i={platform:bm,...n},a={...i.platform,_c:r};return dp(e,t,{...i,platform:a})},Mm=typeof document<`u`?D.useLayoutEffect:function(){};function Nm(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e==`function`&&e.toString()===t.toString())return!0;let n,r,i;if(e&&t&&typeof e==`object`){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!Nm(e[r],t[r]))return!1;return!0}if(i=Object.keys(e),n=i.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,i[r]))return!1;for(r=n;r--!==0;){let n=i[r];if(!(n===`_owner`&&e.$$typeof)&&!Nm(e[n],t[n]))return!1}return!0}return e!==e&&t!==t}function Pm(e){return typeof window>`u`?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Fm(e,t){let n=Pm(e);return Math.round(t*n)/n}function Im(e){let t=D.useRef(e);return Mm(()=>{t.current=e}),t}function Lm(e){e===void 0&&(e={});let{placement:t=`bottom`,strategy:n=`absolute`,middleware:r=[],platform:i,elements:{reference:a,floating:o}={},transform:s=!0,whileElementsMounted:c,open:l}=e,[u,d]=D.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[f,p]=D.useState(r);Nm(f,r)||p(r);let[m,h]=D.useState(null),[g,_]=D.useState(null),v=D.useCallback(e=>{e!==S.current&&(S.current=e,h(e))},[]),y=D.useCallback(e=>{e!==C.current&&(C.current=e,_(e))},[]),b=a||m,x=o||g,S=D.useRef(null),C=D.useRef(null),w=D.useRef(u),T=c!=null,E=Im(c),O=Im(i),ee=Im(l),k=D.useCallback(()=>{if(!S.current||!C.current)return;let e={placement:t,strategy:n,middleware:f};O.current&&(e.platform=O.current),jm(S.current,C.current,e).then(e=>{let t={...e,isPositioned:ee.current!==!1};te.current&&!Nm(w.current,t)&&(w.current=t,xe.flushSync(()=>{d(t)}))})},[f,t,n,O,ee]);Mm(()=>{l===!1&&w.current.isPositioned&&(w.current.isPositioned=!1,d(e=>({...e,isPositioned:!1})))},[l]);let te=D.useRef(!1);Mm(()=>(te.current=!0,()=>{te.current=!1}),[]),Mm(()=>{if(b&&(S.current=b),x&&(C.current=x),b&&x){if(E.current)return E.current(b,x,k);k()}},[b,x,k,E,T]);let ne=D.useMemo(()=>({reference:S,floating:C,setReference:v,setFloating:y}),[v,y]),A=D.useMemo(()=>({reference:b,floating:x}),[b,x]),re=D.useMemo(()=>{let e={position:n,left:0,top:0};if(!A.floating)return e;let t=Fm(A.floating,u.x),r=Fm(A.floating,u.y);return s?{...e,transform:`translate(`+t+`px, `+r+`px)`,...Pm(A.floating)>=1.5&&{willChange:`transform`}}:{position:n,left:t,top:r}},[n,s,A.floating,u.x,u.y]);return D.useMemo(()=>({...u,update:k,refs:ne,elements:A,floatingStyles:re}),[u,k,ne,A,re])}var Rm=e=>{function t(e){return{}.hasOwnProperty.call(e,`current`)}return{name:`arrow`,options:e,fn(n){let{element:r,padding:i}=typeof e==`function`?e(n):e;return r&&t(r)?r.current==null?{}:km({element:r.current,padding:i}).fn(n):r?km({element:r,padding:i}).fn(n):{}}}},zm=(e,t)=>{let n=wm(e);return{name:n.name,fn:n.fn,options:[e,t]}},Bm=(e,t)=>{let n=Tm(e);return{name:n.name,fn:n.fn,options:[e,t]}},Vm=(e,t)=>({fn:Am(e).fn,options:[e,t]}),Hm=(e,t)=>{let n=Em(e);return{name:n.name,fn:n.fn,options:[e,t]}},Um=(e,t)=>{let n=Dm(e);return{name:n.name,fn:n.fn,options:[e,t]}},Wm=(e,t)=>{let n=Om(e);return{name:n.name,fn:n.fn,options:[e,t]}},Gm=(e,t)=>{let n=Rm(e);return{name:n.name,fn:n.fn,options:[e,t]}},Km=`Arrow`,qm=D.forwardRef((e,t)=>{let{children:n,width:r=10,height:i=5,...a}=e;return(0,F.jsx)($.svg,{...a,ref:t,width:r,height:i,viewBox:`0 0 30 10`,preserveAspectRatio:`none`,children:e.asChild?n:(0,F.jsx)(`polygon`,{points:`0,0 30,0 15,10`})})});qm.displayName=Km;var Jm=qm;function Ym(e){let[t,n]=D.useState(void 0);return Qc(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});let t=new ResizeObserver(t=>{if(!Array.isArray(t)||!t.length)return;let r=t[0],i,a;if(`borderBoxSize`in r){let e=r.borderBoxSize,t=Array.isArray(e)?e[0]:e;i=t.inlineSize,a=t.blockSize}else i=e.offsetWidth,a=e.offsetHeight;n({width:i,height:a})});return t.observe(e,{box:`border-box`}),()=>t.unobserve(e)}else n(void 0)},[e]),t}var Xm=`Popper`,[Zm,Qm]=Xc(Xm),[$m,eh]=Zm(Xm),th=e=>{let{__scopePopper:t,children:n}=e,[r,i]=D.useState(null),[a,o]=D.useState(void 0);return(0,F.jsx)($m,{scope:t,anchor:r,onAnchorChange:i,placementState:a,setPlacementState:o,children:n})};th.displayName=Xm;var nh=`PopperAnchor`,rh=D.forwardRef((e,t)=>{let{__scopePopper:n,virtualRef:r,...i}=e,a=eh(nh,n),o=D.useRef(null),s=a.onAnchorChange,c=u(t,D.useCallback(e=>{o.current=e,e&&s(e)},[s])),l=D.useRef(null);D.useEffect(()=>{if(!r)return;let e=l.current;l.current=r.current,e!==l.current&&s(l.current)});let d=a.placementState&&ph(a.placementState),f=d?.[0],p=d?.[1];return r?null:(0,F.jsx)($.div,{"data-radix-popper-side":f,"data-radix-popper-align":p,...i,ref:c})});rh.displayName=nh;var ih=`PopperContent`,[ah,oh]=Zm(ih),sh=D.forwardRef((e,t)=>{let{__scopePopper:n,side:r=`bottom`,sideOffset:i=0,align:a=`center`,alignOffset:o=0,arrowPadding:s=0,avoidCollisions:c=!0,collisionBoundary:l=[],collisionPadding:d=0,sticky:f=`partial`,hideWhenDetached:p=!1,updatePositionStrategy:m=`optimized`,onPlaced:h,...g}=e,_=eh(ih,n),[v,y]=D.useState(null),b=u(t,e=>y(e)),[x,S]=D.useState(null),C=Ym(x),w=C?.width??0,T=C?.height??0,E=r+(a===`center`?``:`-`+a),O=typeof d==`number`?d:{top:0,right:0,bottom:0,left:0,...d},ee=Array.isArray(l)?l:[l],k=ee.length>0,te={padding:O,boundary:ee.filter(dh),altBoundary:k},{refs:ne,floatingStyles:A,placement:re,isPositioned:ie,middlewareData:ae}=Lm({strategy:`fixed`,placement:E,whileElementsMounted:(...e)=>Cm(...e,{animationFrame:m===`always`}),elements:{reference:_.anchor},middleware:[zm({mainAxis:i+T,alignmentAxis:o}),c&&Bm({mainAxis:!0,crossAxis:!1,limiter:f===`partial`?Vm():void 0,...te}),c&&Hm({...te}),Um({...te,apply:({elements:e,rects:t,availableWidth:n,availableHeight:r})=>{let{width:i,height:a}=t.reference,o=e.floating.style;o.setProperty(`--radix-popper-available-width`,`${n}px`),o.setProperty(`--radix-popper-available-height`,`${r}px`),o.setProperty(`--radix-popper-anchor-width`,`${i}px`),o.setProperty(`--radix-popper-anchor-height`,`${a}px`)}}),x&&Gm({element:x,padding:s}),fh({arrowWidth:w,arrowHeight:T}),p&&Wm({strategy:`referenceHidden`,...te,boundary:k?te.boundary:void 0})]}),j=_.setPlacementState;Qc(()=>(j(re),()=>{j(void 0)}),[re,j]);let[oe,se]=ph(re),ce=sl(h);Qc(()=>{ie&&ce?.()},[ie,ce]);let le=ae.arrow?.x,ue=ae.arrow?.y,de=ae.arrow?.centerOffset!==0,[fe,M]=D.useState();return Qc(()=>{v&&M(window.getComputedStyle(v).zIndex)},[v]),(0,F.jsx)(`div`,{ref:ne.setFloating,"data-radix-popper-content-wrapper":``,style:{...A,transform:ie?A.transform:`translate(0, -200%)`,minWidth:`max-content`,zIndex:fe,"--radix-popper-transform-origin":[ae.transformOrigin?.x,ae.transformOrigin?.y].join(` `),...ae.hide?.referenceHidden&&{visibility:`hidden`,pointerEvents:`none`}},dir:e.dir,children:(0,F.jsx)(ah,{scope:n,placedSide:oe,placedAlign:se,onArrowChange:S,arrowX:le,arrowY:ue,shouldHideArrow:de,children:(0,F.jsx)($.div,{"data-side":oe,"data-align":se,...g,ref:b,style:{...g.style,animation:ie?void 0:`none`}})})})});sh.displayName=ih;var ch=`PopperArrow`,lh={top:`bottom`,right:`left`,bottom:`top`,left:`right`},uh=D.forwardRef(function(e,t){let{__scopePopper:n,...r}=e,i=oh(ch,n),a=lh[i.placedSide];return(0,F.jsx)(`span`,{ref:i.onArrowChange,style:{position:`absolute`,left:i.arrowX,top:i.arrowY,[a]:0,transformOrigin:{top:``,right:`0 0`,bottom:`center 0`,left:`100% 0`}[i.placedSide],transform:{top:`translateY(100%)`,right:`translateY(50%) rotate(90deg) translateX(-50%)`,bottom:`rotate(180deg)`,left:`translateY(50%) rotate(-90deg) translateX(50%)`}[i.placedSide],visibility:i.shouldHideArrow?`hidden`:void 0},children:(0,F.jsx)(Jm,{...r,ref:t,style:{...r.style,display:`block`}})})});uh.displayName=ch;function dh(e){return e!==null}var fh=e=>({name:`transformOrigin`,options:e,fn(t){let{placement:n,rects:r,middlewareData:i}=t,a=i.arrow?.centerOffset!==0,o=a?0:e.arrowWidth,s=a?0:e.arrowHeight,[c,l]=ph(n),u={start:`0%`,center:`50%`,end:`100%`}[l],d=(i.arrow?.x??0)+o/2,f=(i.arrow?.y??0)+s/2,p=``,m=``;return c===`bottom`?(p=a?u:`${d}px`,m=`${-s}px`):c===`top`?(p=a?u:`${d}px`,m=`${r.floating.height+s}px`):c===`right`?(p=`${-s}px`,m=a?u:`${f}px`):c===`left`&&(p=`${r.floating.width+s}px`,m=a?u:`${f}px`),{data:{x:p,y:m}}}});function ph(e){let[t,n=`center`]=e.split(`-`);return[t,n]}var mh=th,hh=rh,gh=sh,_h=uh;function vh({className:e,...t}){return(0,F.jsx)(`textarea`,{"data-slot":`textarea`,className:l(`field-sizing-content min-h-10 w-full min-w-0 resize-none overflow-x-hidden rounded-md bg-transparent px-3 py-2 text-base outline-none [overflow-wrap:anywhere] placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50`,e),...t})}var yh=new class{async listCommands(){return z.get(`/commands`)}async getCommand(e,t){return z.get(`/commands/${encodeURIComponent(e)}/${encodeURIComponent(t)}`)}async getWorkflowCommand(e){return this.getCommand(`workflow`,e)}},bh=s(`inline-flex items-center justify-center rounded-md border px-2 py-0.5 text-xs font-medium w-fit whitespace-nowrap shrink-0 [&>svg]:size-3 gap-1 [&>svg]:pointer-events-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] transition-[color,box-shadow] overflow-hidden`,{variants:{variant:{default:`border-transparent bg-primary text-primary-foreground [a&]:hover:bg-primary/90`,secondary:`border-transparent bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/90`,destructive:`border-transparent bg-destructive text-white [a&]:hover:bg-destructive/90`,outline:`text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground`,warning:`border-transparent bg-amber-500/15 text-amber-600 dark:text-amber-400`,success:`border-transparent bg-primary/15 text-primary`}},defaultVariants:{variant:`default`}});function xh({className:e,variant:t,asChild:n=!1,...r}){return(0,F.jsx)(n?d:`span`,{"data-slot":`badge`,className:l(bh({variant:t}),e),...r})}function Sh(e,[t,n]){return Math.min(n,Math.max(t,e))}function Ch(e){let t=D.useRef({value:e,previous:e});return D.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var wh=Object.freeze({position:`absolute`,border:0,width:1,height:1,padding:0,margin:-1,overflow:`hidden`,clip:`rect(0, 0, 0, 0)`,whiteSpace:`nowrap`,wordWrap:`normal`}),Th=`VisuallyHidden`,Eh=D.forwardRef((e,t)=>(0,F.jsx)($.span,{...e,ref:t,style:{...wh,...e.style}}));Eh.displayName=Th;var Dh=[` `,`Enter`,`ArrowUp`,`ArrowDown`],Oh=[` `,`Enter`],kh=`Select`,[Ah,jh,Mh]=jf(kh),[Nh,Ph]=Xc(kh,[Mh,Qm]),Fh=Qm(),[Ih,Lh]=Nh(kh),[Rh,zh]=Nh(kh),Bh=`SelectProvider`;function Vh(e){let{__scopeSelect:t,children:n,open:r,defaultOpen:i,onOpenChange:a,value:o,defaultValue:s,onValueChange:c,dir:l,name:u,autoComplete:d,disabled:f,required:p,form:m,internal_do_not_use_render:h}=e,g=Fh(t),[_,v]=D.useState(null),[y,b]=D.useState(null),[x,S]=D.useState(!1),C=Nf(l),[w,T]=rl({prop:r,defaultProp:i??!1,onChange:a,caller:kh}),[E,O]=rl({prop:o,defaultProp:s,onChange:c,caller:kh}),ee=D.useRef(null),k=_?!!m||!!_.closest(`form`):!0,[te,ne]=D.useState(new Set),A=tl(),re=Array.from(te).map(e=>e.props.value).join(`;`),ie=D.useCallback(e=>{ne(t=>new Set(t).add(e))},[]),ae=D.useCallback(e=>{ne(t=>{let n=new Set(t);return n.delete(e),n})},[]),j={required:p,trigger:_,onTriggerChange:v,valueNode:y,onValueNodeChange:b,valueNodeHasChildren:x,onValueNodeHasChildrenChange:S,contentId:A,value:E,onValueChange:O,open:w,onOpenChange:T,dir:C,triggerPointerDownPosRef:ee,disabled:f,name:u,autoComplete:d,form:m,nativeOptions:te,nativeSelectKey:re,isFormControl:k};return(0,F.jsx)(mh,{...g,children:(0,F.jsx)(Ih,{scope:t,...j,children:(0,F.jsx)(Ah.Provider,{scope:t,children:(0,F.jsx)(Rh,{scope:t,onNativeOptionAdd:ie,onNativeOptionRemove:ae,children:Vg(h)?h(j):n})})})})}Vh.displayName=Bh;var Hh=e=>{let{__scopeSelect:t,children:n,...r}=e;return(0,F.jsx)(Vh,{__scopeSelect:t,...r,internal_do_not_use_render:({isFormControl:e})=>(0,F.jsxs)(F.Fragment,{children:[n,e?(0,F.jsx)(Bg,{__scopeSelect:t}):null]})})};Hh.displayName=kh;var Uh=`SelectTrigger`,Wh=D.forwardRef((e,t)=>{let{__scopeSelect:n,disabled:r=!1,...i}=e,a=Fh(n),o=Lh(Uh,n),s=o.disabled||r,c=u(t,o.onTriggerChange),l=jh(n),d=D.useRef(`touch`),[f,p,m]=Ug(e=>{let t=l().filter(e=>!e.disabled),n=Wg(t,e,t.find(e=>e.value===o.value));n!==void 0&&o.onValueChange(n.value)}),h=e=>{s||(o.onOpenChange(!0),m()),e&&(o.triggerPointerDownPosRef.current={x:Math.round(e.pageX),y:Math.round(e.pageY)})};return(0,F.jsx)(hh,{asChild:!0,...a,children:(0,F.jsx)($.button,{type:`button`,role:`combobox`,"aria-controls":o.open?o.contentId:void 0,"aria-expanded":o.open,"aria-required":o.required,"aria-autocomplete":`none`,dir:o.dir,"data-state":o.open?`open`:`closed`,disabled:s,"data-disabled":s?``:void 0,"data-placeholder":Hg(o.value)?``:void 0,...i,ref:c,onClick:Q(i.onClick,e=>{e.currentTarget.focus(),d.current!==`mouse`&&h(e)}),onPointerDown:Q(i.onPointerDown,e=>{d.current=e.pointerType;let t=e.target;t.hasPointerCapture(e.pointerId)&&t.releasePointerCapture(e.pointerId),e.button===0&&e.ctrlKey===!1&&e.pointerType===`mouse`&&(h(e),e.preventDefault())}),onKeyDown:Q(i.onKeyDown,e=>{let t=f.current!==``;!(e.ctrlKey||e.altKey||e.metaKey)&&e.key.length===1&&p(e.key),!(t&&e.key===` `)&&Dh.includes(e.key)&&(h(),e.preventDefault())})})})});Wh.displayName=Uh;var Gh=`SelectValue`,Kh=D.forwardRef((e,t)=>{let{__scopeSelect:n,className:r,style:i,children:a,placeholder:o=``,...s}=e,c=Lh(Gh,n),{onValueNodeHasChildrenChange:l}=c,d=a!==void 0,f=u(t,c.onValueNodeChange);Qc(()=>{l(d)},[l,d]);let p=Hg(c.value);return(0,F.jsx)($.span,{...s,asChild:p?!1:s.asChild,ref:f,style:{pointerEvents:`none`},children:(0,F.jsx)(D.Fragment,{children:p?o:a},p?`placeholder`:`value`)})});Kh.displayName=Gh;var qh=`SelectIcon`,Jh=D.forwardRef((e,t)=>{let{__scopeSelect:n,children:r,...i}=e;return(0,F.jsx)($.span,{"aria-hidden":!0,...i,ref:t,children:r||`▼`})});Jh.displayName=qh;var Yh=`SelectPortal`,[Xh,Zh]=Nh(Yh,{forceMount:void 0}),Qh=e=>{let{__scopeSelect:t,forceMount:n,...r}=e;return(0,F.jsx)(Xh,{scope:e.__scopeSelect,forceMount:n,children:(0,F.jsx)(Bl,{asChild:!0,...r})})};Qh.displayName=Yh;var $h=`SelectContent`,eg=D.forwardRef((e,t)=>{let n=Zh($h,e.__scopeSelect),{forceMount:r=n.forceMount,...i}=e,a=Lh($h,e.__scopeSelect),[o,s]=D.useState();return Qc(()=>{s(new DocumentFragment)},[]),(0,F.jsx)(Hl,{present:r||a.open,children:({present:e})=>e?(0,F.jsx)(sg,{...i,ref:t}):(0,F.jsx)(tg,{...i,fragment:o})})});eg.displayName=$h;var tg=D.forwardRef((e,t)=>{let{__scopeSelect:n,children:r,fragment:i}=e;return i?xe.createPortal((0,F.jsx)(rg,{scope:n,children:(0,F.jsx)(Ah.Slot,{scope:n,children:(0,F.jsx)(`div`,{ref:t,children:r})})}),i):null});tg.displayName=`SelectContentFragment`;var ng=10,[rg,ig]=Nh($h),ag=`SelectContentImpl`,og=f(`SelectContent.RemoveScroll`),sg=D.forwardRef((e,t)=>{let{__scopeSelect:n}=e,{position:r=`item-aligned`,onCloseAutoFocus:i,onEscapeKeyDown:a,onPointerDownOutside:o,side:s,sideOffset:c,align:l,alignOffset:d,arrowPadding:f,collisionBoundary:p,collisionPadding:m,sticky:h,hideWhenDetached:g,avoidCollisions:_,...v}=e,y=Lh($h,n),[b,x]=D.useState(null),[S,C]=D.useState(null),w=u(t,e=>x(e)),[T,E]=D.useState(null),[O,ee]=D.useState(null),k=jh(n),[te,ne]=D.useState(!1),A=D.useRef(!1);D.useEffect(()=>{if(b)return hd(b)},[b]),Xl();let re=D.useCallback(e=>{let[t,...n]=k().map(e=>e.ref.current),[r]=n.slice(-1),i=document.activeElement;for(let n of e)if(n===i||(n?.scrollIntoView({block:`nearest`}),n===t&&S&&(S.scrollTop=0),n===r&&S&&(S.scrollTop=S.scrollHeight),n?.focus(),document.activeElement!==i))return},[k,S]),ie=D.useCallback(()=>re([T,b]),[re,T,b]);D.useEffect(()=>{te&&ie()},[te,ie]);let{onOpenChange:ae,triggerPointerDownPosRef:j}=y;D.useEffect(()=>{if(b){let e={x:0,y:0},t=t=>{e={x:Math.abs(Math.round(t.pageX)-(j.current?.x??0)),y:Math.abs(Math.round(t.pageY)-(j.current?.y??0))}},n=n=>{e.x<=10&&e.y<=10?n.preventDefault():n.composedPath().includes(b)||ae(!1),document.removeEventListener(`pointermove`,t),j.current=null};return j.current!==null&&(document.addEventListener(`pointermove`,t),document.addEventListener(`pointerup`,n,{capture:!0,once:!0})),()=>{document.removeEventListener(`pointermove`,t),document.removeEventListener(`pointerup`,n,{capture:!0})}}},[b,ae,j]),D.useEffect(()=>{let e=()=>ae(!1);return window.addEventListener(`blur`,e),window.addEventListener(`resize`,e),()=>{window.removeEventListener(`blur`,e),window.removeEventListener(`resize`,e)}},[ae]);let[oe,se]=Ug(e=>{let t=k().filter(e=>!e.disabled),n=Wg(t,e,t.find(e=>e.ref.current===document.activeElement));n&&setTimeout(()=>n.ref.current?.focus())}),ce=D.useCallback((e,t,n)=>{let r=!A.current&&!n;(y.value!==void 0&&y.value===t||r)&&(E(e),r&&(A.current=!0))},[y.value]),le=D.useCallback(()=>b?.focus(),[b]),ue=D.useCallback((e,t,n)=>{let r=!A.current&&!n;(y.value!==void 0&&y.value===t||r)&&ee(e)},[y.value]),de=r===`popper`?dg:lg,fe=de===dg?{side:s,sideOffset:c,align:l,alignOffset:d,arrowPadding:f,collisionBoundary:p,collisionPadding:m,sticky:h,hideWhenDetached:g,avoidCollisions:_}:{};return(0,F.jsx)(rg,{scope:n,content:b,viewport:S,onViewportChange:C,itemRefCallback:ce,selectedItem:T,onItemLeave:le,itemTextRefCallback:ue,focusSelectedItem:ie,selectedItemText:O,position:r,isPositioned:te,searchRef:oe,children:(0,F.jsx)(od,{as:og,allowPinchZoom:!0,children:(0,F.jsx)(Dl,{asChild:!0,trapped:y.open,onMountAutoFocus:e=>{e.preventDefault()},onUnmountAutoFocus:Q(i,e=>{y.trigger?.focus({preventScroll:!0}),e.preventDefault()}),children:(0,F.jsx)(hl,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:a,onPointerDownOutside:o,onFocusOutside:e=>e.preventDefault(),onDismiss:()=>y.onOpenChange(!1),children:(0,F.jsx)(de,{role:`listbox`,id:y.contentId,"data-state":y.open?`open`:`closed`,dir:y.dir,onContextMenu:e=>e.preventDefault(),...v,...fe,onPlaced:()=>ne(!0),ref:w,style:{display:`flex`,flexDirection:`column`,outline:`none`,...v.style},onKeyDown:Q(v.onKeyDown,e=>{let t=e.ctrlKey||e.altKey||e.metaKey;if(e.key===`Tab`&&e.preventDefault(),!t&&e.key.length===1&&se(e.key),[`ArrowUp`,`ArrowDown`,`Home`,`End`].includes(e.key)){let t=k().filter(e=>!e.disabled).map(e=>e.ref.current);if([`ArrowUp`,`End`].includes(e.key)&&(t=t.slice().reverse()),[`ArrowUp`,`ArrowDown`].includes(e.key)){let n=e.target,r=t.indexOf(n);t=t.slice(r+1)}setTimeout(()=>re(t)),e.preventDefault()}})})})})})})});sg.displayName=ag;var cg=`SelectItemAlignedPosition`,lg=D.forwardRef((e,t)=>{let{__scopeSelect:n,onPlaced:r,...i}=e,a=Lh($h,n),o=ig($h,n),[s,c]=D.useState(null),[l,d]=D.useState(null),f=u(t,e=>d(e)),p=jh(n),m=D.useRef(!1),h=D.useRef(!0),{viewport:g,selectedItem:_,selectedItemText:v,focusSelectedItem:y}=o,b=D.useCallback(()=>{if(a.trigger&&a.valueNode&&s&&l&&g&&_&&v){let e=a.trigger.getBoundingClientRect(),t=l.getBoundingClientRect(),n=a.valueNode.getBoundingClientRect(),i=v.getBoundingClientRect();if(a.dir!==`rtl`){let r=i.left-t.left,a=n.left-r,o=e.left-a,c=e.width+o,l=Math.max(c,t.width),u=window.innerWidth-ng,d=Sh(a,[ng,Math.max(ng,u-l)]);s.style.minWidth=c+`px`,s.style.left=d+`px`}else{let r=t.right-i.right,a=window.innerWidth-n.right-r,o=window.innerWidth-e.right-a,c=e.width+o,l=Math.max(c,t.width),u=window.innerWidth-ng,d=Sh(a,[ng,Math.max(ng,u-l)]);s.style.minWidth=c+`px`,s.style.right=d+`px`}let o=p(),c=window.innerHeight-ng*2,u=g.scrollHeight,d=window.getComputedStyle(l),f=parseInt(d.borderTopWidth,10),h=parseInt(d.paddingTop,10),y=parseInt(d.borderBottomWidth,10),b=parseInt(d.paddingBottom,10),x=f+h+u+b+y,S=Math.min(_.offsetHeight*5,x),C=window.getComputedStyle(g),w=parseInt(C.paddingTop,10),T=parseInt(C.paddingBottom,10),E=e.top+e.height/2-ng,D=c-E,O=_.offsetHeight/2,ee=_.offsetTop+O,k=f+h+ee,te=x-k;if(k<=E){let e=o.length>0&&_===o[o.length-1].ref.current;s.style.bottom=`0px`;let t=l.clientHeight-g.offsetTop-g.offsetHeight,n=k+Math.max(D,O+(e?T:0)+t+y);s.style.height=n+`px`}else{let e=o.length>0&&_===o[0].ref.current;s.style.top=`0px`;let t=Math.max(E,f+g.offsetTop+(e?w:0)+O)+te;s.style.height=t+`px`,g.scrollTop=k-E+g.offsetTop}s.style.margin=`${ng}px 0`,s.style.minHeight=S+`px`,s.style.maxHeight=c+`px`,r?.(),requestAnimationFrame(()=>m.current=!0)}},[p,a.trigger,a.valueNode,s,l,g,_,v,a.dir,r]);Qc(()=>b(),[b]);let[x,S]=D.useState();return Qc(()=>{l&&S(window.getComputedStyle(l).zIndex)},[l]),(0,F.jsx)(fg,{scope:n,contentWrapper:s,shouldExpandOnScrollRef:m,onScrollButtonChange:D.useCallback(e=>{e&&h.current===!0&&(b(),y?.(),h.current=!1)},[b,y]),children:(0,F.jsx)(`div`,{ref:c,style:{display:`flex`,flexDirection:`column`,position:`fixed`,zIndex:x},children:(0,F.jsx)($.div,{...i,ref:f,style:{boxSizing:`border-box`,maxHeight:`100%`,...i.style}})})})});lg.displayName=cg;var ug=`SelectPopperPosition`,dg=D.forwardRef((e,t)=>{let{__scopeSelect:n,align:r=`start`,collisionPadding:i=ng,...a}=e,o=Fh(n);return(0,F.jsx)(gh,{...o,...a,ref:t,align:r,collisionPadding:i,style:{boxSizing:`border-box`,...a.style,"--radix-select-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-select-content-available-width":`var(--radix-popper-available-width)`,"--radix-select-content-available-height":`var(--radix-popper-available-height)`,"--radix-select-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-select-trigger-height":`var(--radix-popper-anchor-height)`}})});dg.displayName=ug;var[fg,pg]=Nh($h,{}),mg=`SelectViewport`,hg=D.forwardRef((e,t)=>{let{__scopeSelect:n,nonce:r,...i}=e,a=ig(mg,n),o=pg(mg,n),s=u(t,a.onViewportChange),c=D.useRef(0);return(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`style`,{dangerouslySetInnerHTML:{__html:`[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}`},nonce:r}),(0,F.jsx)(Ah.Slot,{scope:n,children:(0,F.jsx)($.div,{"data-radix-select-viewport":``,role:`presentation`,...i,ref:s,style:{position:`relative`,flex:1,overflow:`hidden auto`,...i.style},onScroll:Q(i.onScroll,e=>{let t=e.currentTarget,{contentWrapper:n,shouldExpandOnScrollRef:r}=o;if(r?.current&&n){let e=Math.abs(c.current-t.scrollTop);if(e>0){let r=window.innerHeight-ng*2,i=parseFloat(n.style.minHeight),a=parseFloat(n.style.height),o=Math.max(i,a);if(o<r){let i=o+e,a=Math.min(r,i),s=i-a;n.style.height=a+`px`,n.style.bottom===`0px`&&(t.scrollTop=s>0?s:0,n.style.justifyContent=`flex-end`)}}}c.current=t.scrollTop})})})]})});hg.displayName=mg;var gg=`SelectGroup`,[_g,vg]=Nh(gg),yg=D.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e,i=tl();return(0,F.jsx)(_g,{scope:n,id:i,children:(0,F.jsx)($.div,{role:`group`,"aria-labelledby":i,...r,ref:t})})});yg.displayName=gg;var bg=`SelectLabel`,xg=D.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e,i=vg(bg,n);return(0,F.jsx)($.div,{id:i.id,...r,ref:t})});xg.displayName=bg;var Sg=`SelectItem`,[Cg,wg]=Nh(Sg),Tg=D.forwardRef((e,t)=>{let{__scopeSelect:n,value:r,disabled:i=!1,textValue:a,...o}=e,s=Lh(Sg,n),c=ig(Sg,n),l=s.value===r,[d,f]=D.useState(a??``),[p,m]=D.useState(!1),h=u(t,e=>c.itemRefCallback?.(e,r,i)),g=tl(),_=D.useRef(`touch`),v=()=>{i||(s.onValueChange(r),s.onOpenChange(!1))};return(0,F.jsx)(Cg,{scope:n,value:r,disabled:i,textId:g,isSelected:l,onItemTextChange:D.useCallback(e=>{f(t=>t||(e?.textContent??``).trim())},[]),children:(0,F.jsx)(Ah.ItemSlot,{scope:n,value:r,disabled:i,textValue:d,children:(0,F.jsx)($.div,{role:`option`,"aria-labelledby":g,"data-highlighted":p?``:void 0,"aria-selected":l&&p,"data-state":l?`checked`:`unchecked`,"aria-disabled":i||void 0,"data-disabled":i?``:void 0,tabIndex:i?void 0:-1,...o,ref:h,onFocus:Q(o.onFocus,()=>m(!0)),onBlur:Q(o.onBlur,()=>m(!1)),onClick:Q(o.onClick,()=>{_.current!==`mouse`&&v()}),onPointerUp:Q(o.onPointerUp,()=>{_.current===`mouse`&&v()}),onPointerDown:Q(o.onPointerDown,e=>{_.current=e.pointerType}),onPointerMove:Q(o.onPointerMove,e=>{_.current=e.pointerType,i?c.onItemLeave?.():_.current===`mouse`&&e.currentTarget.focus({preventScroll:!0})}),onPointerLeave:Q(o.onPointerLeave,e=>{e.currentTarget===document.activeElement&&c.onItemLeave?.()}),onKeyDown:Q(o.onKeyDown,e=>{c.searchRef?.current!==``&&e.key===` `||(Oh.includes(e.key)&&v(),e.key===` `&&e.preventDefault())})})})})});Tg.displayName=Sg;var Eg=`SelectItemText`,Dg=D.forwardRef((e,t)=>{let{__scopeSelect:n,className:r,style:i,...a}=e,o=Lh(Eg,n),s=ig(Eg,n),c=wg(Eg,n),l=zh(Eg,n),[d,f]=D.useState(null),p=u(t,e=>f(e),c.onItemTextChange,e=>s.itemTextRefCallback?.(e,c.value,c.disabled)),m=d?.textContent,h=D.useMemo(()=>(0,F.jsx)(`option`,{value:c.value,disabled:c.disabled,children:m},c.value),[c.disabled,c.value,m]),{onNativeOptionAdd:g,onNativeOptionRemove:_}=l;return Qc(()=>(g(h),()=>_(h)),[g,_,h]),(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)($.span,{id:c.textId,...a,ref:p}),c.isSelected&&o.valueNode&&!o.valueNodeHasChildren&&!Hg(o.value)?xe.createPortal(a.children,o.valueNode):null]})});Dg.displayName=Eg;var Og=`SelectItemIndicator`,kg=D.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e;return wg(Og,n).isSelected?(0,F.jsx)($.span,{"aria-hidden":!0,...r,ref:t}):null});kg.displayName=Og;var Ag=`SelectScrollUpButton`,jg=D.forwardRef((e,t)=>{let n=ig(Ag,e.__scopeSelect),r=pg(Ag,e.__scopeSelect),[i,a]=D.useState(!1),o=u(t,r.onScrollButtonChange);return Qc(()=>{if(n.viewport&&n.isPositioned){let e=function(){a(t.scrollTop>0)},t=n.viewport;return e(),t.addEventListener(`scroll`,e),()=>t.removeEventListener(`scroll`,e)}},[n.viewport,n.isPositioned]),i?(0,F.jsx)(Pg,{...e,ref:o,onAutoScroll:()=>{let{viewport:e,selectedItem:t}=n;e&&t&&(e.scrollTop-=t.offsetHeight)}}):null});jg.displayName=Ag;var Mg=`SelectScrollDownButton`,Ng=D.forwardRef((e,t)=>{let n=ig(Mg,e.__scopeSelect),r=pg(Mg,e.__scopeSelect),[i,a]=D.useState(!1),o=u(t,r.onScrollButtonChange);return Qc(()=>{if(n.viewport&&n.isPositioned){let e=function(){let e=t.scrollHeight-t.clientHeight;a(Math.ceil(t.scrollTop)<e)},t=n.viewport;return e(),t.addEventListener(`scroll`,e),()=>t.removeEventListener(`scroll`,e)}},[n.viewport,n.isPositioned]),i?(0,F.jsx)(Pg,{...e,ref:o,onAutoScroll:()=>{let{viewport:e,selectedItem:t}=n;e&&t&&(e.scrollTop+=t.offsetHeight)}}):null});Ng.displayName=Mg;var Pg=D.forwardRef((e,t)=>{let{__scopeSelect:n,onAutoScroll:r,...i}=e,a=ig(`SelectScrollButton`,n),o=D.useRef(null),s=jh(n),c=D.useCallback(()=>{o.current!==null&&(window.clearInterval(o.current),o.current=null)},[]);return D.useEffect(()=>()=>c(),[c]),Qc(()=>{s().find(e=>e.ref.current===document.activeElement)?.ref.current?.scrollIntoView({block:`nearest`})},[s]),(0,F.jsx)($.div,{"aria-hidden":!0,...i,ref:t,style:{flexShrink:0,...i.style},onPointerDown:Q(i.onPointerDown,()=>{o.current===null&&(o.current=window.setInterval(r,50))}),onPointerMove:Q(i.onPointerMove,()=>{a.onItemLeave?.(),o.current===null&&(o.current=window.setInterval(r,50))}),onPointerLeave:Q(i.onPointerLeave,()=>{c()})})}),Fg=`SelectSeparator`,Ig=D.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e;return(0,F.jsx)($.div,{"aria-hidden":!0,...r,ref:t})});Ig.displayName=Fg;var Lg=`SelectArrow`,Rg=D.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e,i=Fh(n);return ig(Lg,n).position===`popper`?(0,F.jsx)(_h,{...i,...r,ref:t}):null});Rg.displayName=Lg;var zg=`SelectBubbleInput`,Bg=D.forwardRef(({__scopeSelect:e,...t},n)=>{let r=Lh(zg,e),{value:i,onValueChange:a,required:o,disabled:s,name:c,autoComplete:l,form:d}=r,{nativeOptions:f,nativeSelectKey:p}=r,m=D.useRef(null),h=u(n,m),g=i??``,_=Ch(g),v=Array.from(f).some(e=>(e.props.value??``)===``);return D.useEffect(()=>{let e=m.current;if(!e)return;let t=window.HTMLSelectElement.prototype,n=Object.getOwnPropertyDescriptor(t,`value`).set;if(_!==g&&n){let t=new Event(`change`,{bubbles:!0});n.call(e,g),e.dispatchEvent(t)}},[_,g]),(0,F.jsxs)($.select,{"aria-hidden":!0,required:o,tabIndex:-1,name:c,autoComplete:l,disabled:s,form:d,onChange:e=>a(e.target.value),...t,style:{...wh,...t.style},ref:h,defaultValue:g,children:[Hg(i)&&!v?(0,F.jsx)(`option`,{value:``}):null,Array.from(f)]},p)});Bg.displayName=zg;function Vg(e){return typeof e==`function`}function Hg(e){return e===``||e===void 0}function Ug(e){let t=sl(e),n=D.useRef(``),r=D.useRef(0),i=D.useCallback(e=>{let i=n.current+e;t(i),(function e(t){n.current=t,window.clearTimeout(r.current),t!==``&&(r.current=window.setTimeout(()=>e(``),1e3))})(i)},[t]),a=D.useCallback(()=>{n.current=``,window.clearTimeout(r.current)},[]);return D.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,i,a]}function Wg(e,t,n){let r=t.length>1&&Array.from(t).every(e=>e===t[0])?t[0]:t,i=n?e.indexOf(n):-1,a=Gg(e,Math.max(i,0));r.length===1&&(a=a.filter(e=>e!==n));let o=a.find(e=>e.textValue.toLowerCase().startsWith(r.toLowerCase()));return o===n?void 0:o}function Gg(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function Kg(e){return(0,F.jsx)(Hh,{"data-slot":`select`,...e})}function qg(e){return(0,F.jsx)(Kh,{"data-slot":`select-value`,...e})}function Jg({className:e,size:t=`default`,children:n,...r}){return(0,F.jsxs)(Wh,{"data-slot":`select-trigger`,"data-size":t,className:l(`border-input data-[placeholder]:text-muted-foreground [&_svg:not([class*='text-'])]:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 dark:hover:bg-input/50 flex w-fit items-center justify-between gap-2 rounded-md border bg-transparent px-3 py-2 text-sm whitespace-nowrap shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 data-[size=default]:h-9 data-[size=sm]:h-8 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,e),...r,children:[n,(0,F.jsx)(Jh,{asChild:!0,children:(0,F.jsx)(g,{className:`size-4 opacity-50`})})]})}function Yg({className:e,children:t,position:n=`popper`,...r}){return(0,F.jsx)(Qh,{children:(0,F.jsxs)(eg,{"data-slot":`select-content`,className:l(`bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 relative z-[140] max-h-(--radix-select-content-available-height) min-w-[8rem] origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border shadow-md`,n===`popper`&&`data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1`,e),position:n,...r,children:[(0,F.jsx)(Zg,{}),(0,F.jsx)(hg,{className:l(`p-1`,n===`popper`&&`h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1`),children:t}),(0,F.jsx)(Qg,{})]})})}function Xg({className:e,children:t,...n}){return(0,F.jsxs)(Tg,{"data-slot":`select-item`,className:l(`focus:bg-accent focus:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex w-full cursor-default items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2`,e),...n,children:[(0,F.jsx)(`span`,{className:`absolute right-2 flex size-3.5 items-center justify-center`,children:(0,F.jsx)(kg,{children:(0,F.jsx)(h,{className:`size-4`})})}),(0,F.jsx)(Dg,{children:t})]})}function Zg({className:e,...t}){return(0,F.jsx)(jg,{"data-slot":`select-scroll-up-button`,className:l(`flex cursor-default items-center justify-center py-1`,e),...t,children:(0,F.jsx)(v,{className:`size-4`})})}function Qg({className:e,...t}){return(0,F.jsx)(Ng,{"data-slot":`select-scroll-down-button`,className:l(`flex cursor-default items-center justify-center py-1`,e),...t,children:(0,F.jsx)(g,{className:`size-4`})})}export{ol as $,p as $t,rf as A,Wn as At,Bd as B,A as Bt,Tf as C,wa as Ct,lf as D,gr as Dt,_f as E,q as Et,qd as F,Te as Ft,od as G,S as Gt,Dd as H,T as Ht,Kd as I,we as It,Bl as J,y as Jt,Xl as K,x as Kt,xd as L,De as Lt,Jd as M,z as Mt,Wd as N,Se as Nt,uf as O,sr as Ot,Gd as P,Ce as Pt,$ as Q,m as Qt,Hd as R,Ee as Rt,Sf as S,Ya as St,gf as T,cr as Tt,Rd as U,w as Ut,kd as V,E as Vt,hd as W,C as Wt,hl as X,g as Xt,Dl as Y,_ as Yt,sl as Z,h as Zt,jf as _,Go as _t,qg as a,Bc as at,Af as b,ro as bt,yh as c,Vc as ct,_h as d,ec as dt,rl as et,gh as f,ic as ft,Nf as g,gs as gt,Ym as h,tc as ht,Jg as i,Yc as it,ef as j,Gn as jt,nf as k,or as kt,vh as l,Ec as lt,Qm as m,rc as mt,Yg as n,Xc as nt,Ch as o,zc as ot,mh as p,nc as pt,Hl as q,b as qt,Xg as r,Q as rt,xh as s,Lc as st,Kg as t,tl as tt,hh as u,Tc as ut,Df as v,Bo as vt,Cf as w,Er as wt,kf as x,$a as xt,Of as y,Vo as yt,Nd as z,se as zt};
|
|
131
|
+
`),Df=()=>{try{return localStorage.getItem(wf)??``}catch(e){return console.error(`Failed to load system prompt enhancement:`,e),``}},Of=e=>{try{let t=e.trim()?e:``;localStorage.setItem(wf,t)}catch(e){console.error(`Failed to save system prompt enhancement:`,e)}},kf=e=>{let t=[];t.push(yf().trim()),t.push(Tf().trim());let n=Df().trim();return n&&t.push(n),cf()&&t.push(uf().trim()),mf()&&t.push(gf().trim()),(e??``).trim().toLowerCase()===`copilot`&&xf()&&t.push(Cf().trim()),t},Af=e=>Ef(kf(e)),jf=`lotus_vdi_safe_mode`,Mf=`lotus-vdi-safe-mode-change`,Nf=()=>{try{return localStorage.getItem(jf)===`true`}catch{return!1}},Pf=e=>{try{localStorage.setItem(jf,e.toString())}catch(e){console.error(`[vdiSafeMode] Failed to persist setting:`,e)}},Ff=e=>{let t=t=>{t.key!==null&&t.key!==jf||e()};return window.addEventListener(`storage`,t),window.addEventListener(Mf,e),()=>{window.removeEventListener(`storage`,t),window.removeEventListener(Mf,e)}};function If(e){let t=e+`CollectionProvider`,[n,r]=tl(t),[i,a]=n(t,{collectionRef:{current:null},itemMap:new Map}),o=e=>{let{scope:t,children:n}=e,r=D.useRef(null),a=D.useRef(new Map).current;return(0,F.jsx)(i,{scope:t,itemMap:a,collectionRef:r,children:n})};o.displayName=t;let s=e+`CollectionSlot`,c=f(s),l=D.forwardRef((e,t)=>{let{scope:n,children:r}=e;return(0,F.jsx)(c,{ref:u(t,a(s,n).collectionRef),children:r})});l.displayName=s;let d=e+`CollectionItemSlot`,p=`data-radix-collection-item`,m=f(d),h=D.forwardRef((e,t)=>{let{scope:n,children:r,...i}=e,o=D.useRef(null),s=u(t,o),c=a(d,n);return D.useEffect(()=>(c.itemMap.set(o,{ref:o,...i}),()=>void c.itemMap.delete(o))),(0,F.jsx)(m,{[p]:``,ref:s,children:r})});h.displayName=d;function g(t){let n=a(e+`CollectionConsumer`,t);return D.useCallback(()=>{let e=n.collectionRef.current;if(!e)return[];let t=Array.from(e.querySelectorAll(`[${p}]`));return Array.from(n.itemMap.values()).sort((e,n)=>t.indexOf(e.ref.current)-t.indexOf(n.ref.current))},[n.collectionRef,n.itemMap])}return[{Provider:o,Slot:l,ItemSlot:h},g,r]}var Lf=D.createContext(void 0);function Rf(e){let t=D.useContext(Lf);return e||t||`ltr`}var zf=[`top`,`right`,`bottom`,`left`],Bf=Math.min,Vf=Math.max,Hf=Math.round,Uf=Math.floor,Wf=e=>({x:e,y:e}),Gf={left:`right`,right:`left`,bottom:`top`,top:`bottom`};function Kf(e,t,n){return Vf(e,Bf(t,n))}function qf(e,t){return typeof e==`function`?e(t):e}function Jf(e){return e.split(`-`)[0]}function Yf(e){return e.split(`-`)[1]}function Xf(e){return e===`x`?`y`:`x`}function Zf(e){return e===`y`?`height`:`width`}function Qf(e){let t=e[0];return t===`t`||t===`b`?`y`:`x`}function $f(e){return Xf(Qf(e))}function ep(e,t,n){n===void 0&&(n=!1);let r=Yf(e),i=$f(e),a=Zf(i),o=i===`x`?r===(n?`end`:`start`)?`right`:`left`:r===`start`?`bottom`:`top`;return t.reference[a]>t.floating[a]&&(o=lp(o)),[o,lp(o)]}function tp(e){let t=lp(e);return[np(e),t,np(t)]}function np(e){return e.includes(`start`)?e.replace(`start`,`end`):e.replace(`end`,`start`)}var rp=[`left`,`right`],ip=[`right`,`left`],ap=[`top`,`bottom`],op=[`bottom`,`top`];function sp(e,t,n){switch(e){case`top`:case`bottom`:return n?t?ip:rp:t?rp:ip;case`left`:case`right`:return t?ap:op;default:return[]}}function cp(e,t,n,r){let i=Yf(e),a=sp(Jf(e),n===`start`,r);return i&&(a=a.map(e=>e+`-`+i),t&&(a=a.concat(a.map(np)))),a}function lp(e){let t=Jf(e);return Gf[t]+e.slice(t.length)}function up(e){return{top:0,right:0,bottom:0,left:0,...e}}function dp(e){return typeof e==`number`?{top:e,right:e,bottom:e,left:e}:up(e)}function fp(e){let{x:t,y:n,width:r,height:i}=e;return{width:r,height:i,top:n,left:t,right:t+r,bottom:n+i,x:t,y:n}}function pp(e,t,n){let{reference:r,floating:i}=e,a=Qf(t),o=$f(t),s=Zf(o),c=Jf(t),l=a===`y`,u=r.x+r.width/2-i.width/2,d=r.y+r.height/2-i.height/2,f=r[s]/2-i[s]/2,p;switch(c){case`top`:p={x:u,y:r.y-i.height};break;case`bottom`:p={x:u,y:r.y+r.height};break;case`right`:p={x:r.x+r.width,y:d};break;case`left`:p={x:r.x-i.width,y:d};break;default:p={x:r.x,y:r.y}}switch(Yf(t)){case`start`:p[o]-=f*(n&&l?-1:1);break;case`end`:p[o]+=f*(n&&l?-1:1);break}return p}async function mp(e,t){t===void 0&&(t={});let{x:n,y:r,platform:i,rects:a,elements:o,strategy:s}=e,{boundary:c=`clippingAncestors`,rootBoundary:l=`viewport`,elementContext:u=`floating`,altBoundary:d=!1,padding:f=0}=qf(t,e),p=dp(f),m=o[d?u===`floating`?`reference`:`floating`:u],h=fp(await i.getClippingRect({element:await(i.isElement==null?void 0:i.isElement(m))??!0?m:m.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(o.floating)),boundary:c,rootBoundary:l,strategy:s})),g=u===`floating`?{x:n,y:r,width:a.floating.width,height:a.floating.height}:a.reference,_=await(i.getOffsetParent==null?void 0:i.getOffsetParent(o.floating)),v=await(i.isElement==null?void 0:i.isElement(_))&&await(i.getScale==null?void 0:i.getScale(_))||{x:1,y:1},y=fp(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:o,rect:g,offsetParent:_,strategy:s}):g);return{top:(h.top-y.top+p.top)/v.y,bottom:(y.bottom-h.bottom+p.bottom)/v.y,left:(h.left-y.left+p.left)/v.x,right:(y.right-h.right+p.right)/v.x}}var hp=50,gp=async(e,t,n)=>{let{placement:r=`bottom`,strategy:i=`absolute`,middleware:a=[],platform:o}=n,s=o.detectOverflow?o:{...o,detectOverflow:mp},c=await(o.isRTL==null?void 0:o.isRTL(t)),l=await o.getElementRects({reference:e,floating:t,strategy:i}),{x:u,y:d}=pp(l,r,c),f=r,p=0,m={};for(let n=0;n<a.length;n++){let h=a[n];if(!h)continue;let{name:g,fn:_}=h,{x:v,y,data:b,reset:x}=await _({x:u,y:d,initialPlacement:r,placement:f,strategy:i,middlewareData:m,rects:l,platform:s,elements:{reference:e,floating:t}});u=v??u,d=y??d,m[g]={...m[g],...b},x&&p<hp&&(p++,typeof x==`object`&&(x.placement&&(f=x.placement),x.rects&&(l=x.rects===!0?await o.getElementRects({reference:e,floating:t,strategy:i}):x.rects),{x:u,y:d}=pp(l,f,c)),n=-1)}return{x:u,y:d,placement:f,strategy:i,middlewareData:m}},_p=e=>({name:`arrow`,options:e,async fn(t){let{x:n,y:r,placement:i,rects:a,platform:o,elements:s,middlewareData:c}=t,{element:l,padding:u=0}=qf(e,t)||{};if(l==null)return{};let d=dp(u),f={x:n,y:r},p=$f(i),m=Zf(p),h=await o.getDimensions(l),g=p===`y`,_=g?`top`:`left`,v=g?`bottom`:`right`,y=g?`clientHeight`:`clientWidth`,b=a.reference[m]+a.reference[p]-f[p]-a.floating[m],x=f[p]-a.reference[p],S=await(o.getOffsetParent==null?void 0:o.getOffsetParent(l)),C=S?S[y]:0;(!C||!await(o.isElement==null?void 0:o.isElement(S)))&&(C=s.floating[y]||a.floating[m]);let w=b/2-x/2,T=C/2-h[m]/2-1,E=Bf(d[_],T),D=Bf(d[v],T),O=E,ee=C-h[m]-D,k=C/2-h[m]/2+w,te=Kf(O,k,ee),ne=!c.arrow&&Yf(i)!=null&&k!==te&&a.reference[m]/2-(k<O?E:D)-h[m]/2<0,A=ne?k<O?k-O:k-ee:0;return{[p]:f[p]+A,data:{[p]:te,centerOffset:k-te-A,...ne&&{alignmentOffset:A}},reset:ne}}}),vp=function(e){return e===void 0&&(e={}),{name:`flip`,options:e,async fn(t){var n;let{placement:r,middlewareData:i,rects:a,initialPlacement:o,platform:s,elements:c}=t,{mainAxis:l=!0,crossAxis:u=!0,fallbackPlacements:d,fallbackStrategy:f=`bestFit`,fallbackAxisSideDirection:p=`none`,flipAlignment:m=!0,...h}=qf(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};let g=Jf(r),_=Qf(o),v=Jf(o)===o,y=await(s.isRTL==null?void 0:s.isRTL(c.floating)),b=d||(v||!m?[lp(o)]:tp(o)),x=p!==`none`;!d&&x&&b.push(...cp(o,m,p,y));let S=[o,...b],C=await s.detectOverflow(t,h),w=[],T=i.flip?.overflows||[];if(l&&w.push(C[g]),u){let e=ep(r,a,y);w.push(C[e[0]],C[e[1]])}if(T=[...T,{placement:r,overflows:w}],!w.every(e=>e<=0)){let e=(i.flip?.index||0)+1,t=S[e];if(t&&(!(u===`alignment`&&_!==Qf(t))||T.every(e=>Qf(e.placement)===_?e.overflows[0]>0:!0)))return{data:{index:e,overflows:T},reset:{placement:t}};let n=T.filter(e=>e.overflows[0]<=0).sort((e,t)=>e.overflows[1]-t.overflows[1])[0]?.placement;if(!n)switch(f){case`bestFit`:{let e=T.filter(e=>{if(x){let t=Qf(e.placement);return t===_||t===`y`}return!0}).map(e=>[e.placement,e.overflows.filter(e=>e>0).reduce((e,t)=>e+t,0)]).sort((e,t)=>e[1]-t[1])[0]?.[0];e&&(n=e);break}case`initialPlacement`:n=o;break}if(r!==n)return{reset:{placement:n}}}return{}}}};function yp(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function bp(e){return zf.some(t=>e[t]>=0)}var xp=function(e){return e===void 0&&(e={}),{name:`hide`,options:e,async fn(t){let{rects:n,platform:r}=t,{strategy:i=`referenceHidden`,...a}=qf(e,t);switch(i){case`referenceHidden`:{let e=yp(await r.detectOverflow(t,{...a,elementContext:`reference`}),n.reference);return{data:{referenceHiddenOffsets:e,referenceHidden:bp(e)}}}case`escaped`:{let e=yp(await r.detectOverflow(t,{...a,altBoundary:!0}),n.floating);return{data:{escapedOffsets:e,escaped:bp(e)}}}default:return{}}}}},Sp=new Set([`left`,`top`]);async function Cp(e,t){let{placement:n,platform:r,elements:i}=e,a=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=Jf(n),s=Yf(n),c=Qf(n)===`y`,l=Sp.has(o)?-1:1,u=a&&c?-1:1,d=qf(t,e),{mainAxis:f,crossAxis:p,alignmentAxis:m}=typeof d==`number`?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return s&&typeof m==`number`&&(p=s===`end`?m*-1:m),c?{x:p*u,y:f*l}:{x:f*l,y:p*u}}var wp=function(e){return e===void 0&&(e=0),{name:`offset`,options:e,async fn(t){var n;let{x:r,y:i,placement:a,middlewareData:o}=t,s=await Cp(t,e);return a===o.offset?.placement&&(n=o.arrow)!=null&&n.alignmentOffset?{}:{x:r+s.x,y:i+s.y,data:{...s,placement:a}}}}},Tp=function(e){return e===void 0&&(e={}),{name:`shift`,options:e,async fn(t){let{x:n,y:r,placement:i,platform:a}=t,{mainAxis:o=!0,crossAxis:s=!1,limiter:c={fn:e=>{let{x:t,y:n}=e;return{x:t,y:n}}},...l}=qf(e,t),u={x:n,y:r},d=await a.detectOverflow(t,l),f=Qf(Jf(i)),p=Xf(f),m=u[p],h=u[f];if(o){let e=p===`y`?`top`:`left`,t=p===`y`?`bottom`:`right`,n=m+d[e],r=m-d[t];m=Kf(n,m,r)}if(s){let e=f===`y`?`top`:`left`,t=f===`y`?`bottom`:`right`,n=h+d[e],r=h-d[t];h=Kf(n,h,r)}let g=c.fn({...t,[p]:m,[f]:h});return{...g,data:{x:g.x-n,y:g.y-r,enabled:{[p]:o,[f]:s}}}}}},Ep=function(e){return e===void 0&&(e={}),{options:e,fn(t){let{x:n,y:r,placement:i,rects:a,middlewareData:o}=t,{offset:s=0,mainAxis:c=!0,crossAxis:l=!0}=qf(e,t),u={x:n,y:r},d=Qf(i),f=Xf(d),p=u[f],m=u[d],h=qf(s,t),g=typeof h==`number`?{mainAxis:h,crossAxis:0}:{mainAxis:0,crossAxis:0,...h};if(c){let e=f===`y`?`height`:`width`,t=a.reference[f]-a.floating[e]+g.mainAxis,n=a.reference[f]+a.reference[e]-g.mainAxis;p<t?p=t:p>n&&(p=n)}if(l){let e=f===`y`?`width`:`height`,t=Sp.has(Jf(i)),n=a.reference[d]-a.floating[e]+(t&&o.offset?.[d]||0)+(t?0:g.crossAxis),r=a.reference[d]+a.reference[e]+(t?0:o.offset?.[d]||0)-(t?g.crossAxis:0);m<n?m=n:m>r&&(m=r)}return{[f]:p,[d]:m}}}},Dp=function(e){return e===void 0&&(e={}),{name:`size`,options:e,async fn(t){var n,r;let{placement:i,rects:a,platform:o,elements:s}=t,{apply:c=()=>{},...l}=qf(e,t),u=await o.detectOverflow(t,l),d=Jf(i),f=Yf(i),p=Qf(i)===`y`,{width:m,height:h}=a.floating,g,_;d===`top`||d===`bottom`?(g=d,_=f===(await(o.isRTL==null?void 0:o.isRTL(s.floating))?`start`:`end`)?`left`:`right`):(_=d,g=f===`end`?`top`:`bottom`);let v=h-u.top-u.bottom,y=m-u.left-u.right,b=Bf(h-u[g],v),x=Bf(m-u[_],y),S=!t.middlewareData.shift,C=b,w=x;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(w=y),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(C=v),S&&!f){let e=Vf(u.left,0),t=Vf(u.right,0),n=Vf(u.top,0),r=Vf(u.bottom,0);p?w=m-2*(e!==0||t!==0?e+t:Vf(u.left,u.right)):C=h-2*(n!==0||r!==0?n+r:Vf(u.top,u.bottom))}await c({...t,availableWidth:w,availableHeight:C});let T=await o.getDimensions(s.floating);return m!==T.width||h!==T.height?{reset:{rects:!0}}:{}}}};function Op(){return typeof window<`u`}function kp(e){return Mp(e)?(e.nodeName||``).toLowerCase():`#document`}function Ap(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function jp(e){return((Mp(e)?e.ownerDocument:e.document)||window.document)?.documentElement}function Mp(e){return Op()?e instanceof Node||e instanceof Ap(e).Node:!1}function Np(e){return Op()?e instanceof Element||e instanceof Ap(e).Element:!1}function Pp(e){return Op()?e instanceof HTMLElement||e instanceof Ap(e).HTMLElement:!1}function Fp(e){return!Op()||typeof ShadowRoot>`u`?!1:e instanceof ShadowRoot||e instanceof Ap(e).ShadowRoot}function Ip(e){let{overflow:t,overflowX:n,overflowY:r,display:i}=qp(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&i!==`inline`&&i!==`contents`}function Lp(e){return/^(table|td|th)$/.test(kp(e))}function Rp(e){try{if(e.matches(`:popover-open`))return!0}catch{}try{return e.matches(`:modal`)}catch{return!1}}var zp=/transform|translate|scale|rotate|perspective|filter/,Bp=/paint|layout|strict|content/,Vp=e=>!!e&&e!==`none`,Hp;function Up(e){let t=Np(e)?qp(e):e;return Vp(t.transform)||Vp(t.translate)||Vp(t.scale)||Vp(t.rotate)||Vp(t.perspective)||!Gp()&&(Vp(t.backdropFilter)||Vp(t.filter))||zp.test(t.willChange||``)||Bp.test(t.contain||``)}function Wp(e){let t=Yp(e);for(;Pp(t)&&!Kp(t);){if(Up(t))return t;if(Rp(t))return null;t=Yp(t)}return null}function Gp(){return Hp??=typeof CSS<`u`&&CSS.supports&&CSS.supports(`-webkit-backdrop-filter`,`none`),Hp}function Kp(e){return/^(html|body|#document)$/.test(kp(e))}function qp(e){return Ap(e).getComputedStyle(e)}function Jp(e){return Np(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Yp(e){if(kp(e)===`html`)return e;let t=e.assignedSlot||e.parentNode||Fp(e)&&e.host||jp(e);return Fp(t)?t.host:t}function Xp(e){let t=Yp(e);return Kp(t)?e.ownerDocument?e.ownerDocument.body:e.body:Pp(t)&&Ip(t)?t:Xp(t)}function Zp(e,t,n){t===void 0&&(t=[]),n===void 0&&(n=!0);let r=Xp(e),i=r===e.ownerDocument?.body,a=Ap(r);if(i){let e=Qp(a);return t.concat(a,a.visualViewport||[],Ip(r)?r:[],e&&n?Zp(e):[])}else return t.concat(r,Zp(r,[],n))}function Qp(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function $p(e){let t=qp(e),n=parseFloat(t.width)||0,r=parseFloat(t.height)||0,i=Pp(e),a=i?e.offsetWidth:n,o=i?e.offsetHeight:r,s=Hf(n)!==a||Hf(r)!==o;return s&&(n=a,r=o),{width:n,height:r,$:s}}function em(e){return Np(e)?e:e.contextElement}function tm(e){let t=em(e);if(!Pp(t))return Wf(1);let n=t.getBoundingClientRect(),{width:r,height:i,$:a}=$p(t),o=(a?Hf(n.width):n.width)/r,s=(a?Hf(n.height):n.height)/i;return(!o||!Number.isFinite(o))&&(o=1),(!s||!Number.isFinite(s))&&(s=1),{x:o,y:s}}var nm=Wf(0);function rm(e){let t=Ap(e);return!Gp()||!t.visualViewport?nm:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function im(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==Ap(e)?!1:t}function am(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);let i=e.getBoundingClientRect(),a=em(e),o=Wf(1);t&&(r?Np(r)&&(o=tm(r)):o=tm(e));let s=im(a,n,r)?rm(a):Wf(0),c=(i.left+s.x)/o.x,l=(i.top+s.y)/o.y,u=i.width/o.x,d=i.height/o.y;if(a){let e=Ap(a),t=r&&Np(r)?Ap(r):r,n=e,i=Qp(n);for(;i&&r&&t!==n;){let e=tm(i),t=i.getBoundingClientRect(),r=qp(i),a=t.left+(i.clientLeft+parseFloat(r.paddingLeft))*e.x,o=t.top+(i.clientTop+parseFloat(r.paddingTop))*e.y;c*=e.x,l*=e.y,u*=e.x,d*=e.y,c+=a,l+=o,n=Ap(i),i=Qp(n)}}return fp({width:u,height:d,x:c,y:l})}function om(e,t){let n=Jp(e).scrollLeft;return t?t.left+n:am(jp(e)).left+n}function sm(e,t){let n=e.getBoundingClientRect();return{x:n.left+t.scrollLeft-om(e,n),y:n.top+t.scrollTop}}function cm(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e,a=i===`fixed`,o=jp(r),s=t?Rp(t.floating):!1;if(r===o||s&&a)return n;let c={scrollLeft:0,scrollTop:0},l=Wf(1),u=Wf(0),d=Pp(r);if((d||!d&&!a)&&((kp(r)!==`body`||Ip(o))&&(c=Jp(r)),d)){let e=am(r);l=tm(r),u.x=e.x+r.clientLeft,u.y=e.y+r.clientTop}let f=o&&!d&&!a?sm(o,c):Wf(0);return{width:n.width*l.x,height:n.height*l.y,x:n.x*l.x-c.scrollLeft*l.x+u.x+f.x,y:n.y*l.y-c.scrollTop*l.y+u.y+f.y}}function lm(e){return Array.from(e.getClientRects())}function um(e){let t=jp(e),n=Jp(e),r=e.ownerDocument.body,i=Vf(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),a=Vf(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight),o=-n.scrollLeft+om(e),s=-n.scrollTop;return qp(r).direction===`rtl`&&(o+=Vf(t.clientWidth,r.clientWidth)-i),{width:i,height:a,x:o,y:s}}var dm=25;function fm(e,t){let n=Ap(e),r=jp(e),i=n.visualViewport,a=r.clientWidth,o=r.clientHeight,s=0,c=0;if(i){a=i.width,o=i.height;let e=Gp();(!e||e&&t===`fixed`)&&(s=i.offsetLeft,c=i.offsetTop)}let l=om(r);if(l<=0){let e=r.ownerDocument,t=e.body,n=getComputedStyle(t),i=e.compatMode===`CSS1Compat`&&parseFloat(n.marginLeft)+parseFloat(n.marginRight)||0,o=Math.abs(r.clientWidth-t.clientWidth-i);o<=dm&&(a-=o)}else l<=dm&&(a+=l);return{width:a,height:o,x:s,y:c}}function pm(e,t){let n=am(e,!0,t===`fixed`),r=n.top+e.clientTop,i=n.left+e.clientLeft,a=Pp(e)?tm(e):Wf(1);return{width:e.clientWidth*a.x,height:e.clientHeight*a.y,x:i*a.x,y:r*a.y}}function mm(e,t,n){let r;if(t===`viewport`)r=fm(e,n);else if(t===`document`)r=um(jp(e));else if(Np(t))r=pm(t,n);else{let n=rm(e);r={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return fp(r)}function hm(e,t){let n=Yp(e);return n===t||!Np(n)||Kp(n)?!1:qp(n).position===`fixed`||hm(n,t)}function gm(e,t){let n=t.get(e);if(n)return n;let r=Zp(e,[],!1).filter(e=>Np(e)&&kp(e)!==`body`),i=null,a=qp(e).position===`fixed`,o=a?Yp(e):e;for(;Np(o)&&!Kp(o);){let t=qp(o),n=Up(o);!n&&t.position===`fixed`&&(i=null),(a?!n&&!i:!n&&t.position===`static`&&i&&(i.position===`absolute`||i.position===`fixed`)||Ip(o)&&!n&&hm(e,o))?r=r.filter(e=>e!==o):i=t,o=Yp(o)}return t.set(e,r),r}function _m(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e,a=[...n===`clippingAncestors`?Rp(t)?[]:gm(t,this._c):[].concat(n),r],o=mm(t,a[0],i),s=o.top,c=o.right,l=o.bottom,u=o.left;for(let e=1;e<a.length;e++){let n=mm(t,a[e],i);s=Vf(n.top,s),c=Bf(n.right,c),l=Bf(n.bottom,l),u=Vf(n.left,u)}return{width:c-u,height:l-s,x:u,y:s}}function vm(e){let{width:t,height:n}=$p(e);return{width:t,height:n}}function ym(e,t,n){let r=Pp(t),i=jp(t),a=n===`fixed`,o=am(e,!0,a,t),s={scrollLeft:0,scrollTop:0},c=Wf(0);function l(){c.x=om(i)}if(r||!r&&!a)if((kp(t)!==`body`||Ip(i))&&(s=Jp(t)),r){let e=am(t,!0,a,t);c.x=e.x+t.clientLeft,c.y=e.y+t.clientTop}else i&&l();a&&!r&&i&&l();let u=i&&!r&&!a?sm(i,s):Wf(0);return{x:o.left+s.scrollLeft-c.x-u.x,y:o.top+s.scrollTop-c.y-u.y,width:o.width,height:o.height}}function bm(e){return qp(e).position===`static`}function xm(e,t){if(!Pp(e)||qp(e).position===`fixed`)return null;if(t)return t(e);let n=e.offsetParent;return jp(e)===n&&(n=n.ownerDocument.body),n}function Sm(e,t){let n=Ap(e);if(Rp(e))return n;if(!Pp(e)){let t=Yp(e);for(;t&&!Kp(t);){if(Np(t)&&!bm(t))return t;t=Yp(t)}return n}let r=xm(e,t);for(;r&&Lp(r)&&bm(r);)r=xm(r,t);return r&&Kp(r)&&bm(r)&&!Up(r)?n:r||Wp(e)||n}var Cm=async function(e){let t=this.getOffsetParent||Sm,n=this.getDimensions,r=await n(e.floating);return{reference:ym(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function wm(e){return qp(e).direction===`rtl`}var Tm={convertOffsetParentRelativeRectToViewportRelativeRect:cm,getDocumentElement:jp,getClippingRect:_m,getOffsetParent:Sm,getElementRects:Cm,getClientRects:lm,getDimensions:vm,getScale:tm,isElement:Np,isRTL:wm};function Em(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Dm(e,t){let n=null,r,i=jp(e);function a(){var e;clearTimeout(r),(e=n)==null||e.disconnect(),n=null}function o(s,c){s===void 0&&(s=!1),c===void 0&&(c=1),a();let l=e.getBoundingClientRect(),{left:u,top:d,width:f,height:p}=l;if(s||t(),!f||!p)return;let m=Uf(d),h=Uf(i.clientWidth-(u+f)),g=Uf(i.clientHeight-(d+p)),_=Uf(u),v={rootMargin:-m+`px `+-h+`px `+-g+`px `+-_+`px`,threshold:Vf(0,Bf(1,c))||1},y=!0;function b(t){let n=t[0].intersectionRatio;if(n!==c){if(!y)return o();n?o(!1,n):r=setTimeout(()=>{o(!1,1e-7)},1e3)}n===1&&!Em(l,e.getBoundingClientRect())&&o(),y=!1}try{n=new IntersectionObserver(b,{...v,root:i.ownerDocument})}catch{n=new IntersectionObserver(b,v)}n.observe(e)}return o(!0),a}function Om(e,t,n,r){r===void 0&&(r={});let{ancestorScroll:i=!0,ancestorResize:a=!0,elementResize:o=typeof ResizeObserver==`function`,layoutShift:s=typeof IntersectionObserver==`function`,animationFrame:c=!1}=r,l=em(e),u=i||a?[...l?Zp(l):[],...t?Zp(t):[]]:[];u.forEach(e=>{i&&e.addEventListener(`scroll`,n,{passive:!0}),a&&e.addEventListener(`resize`,n)});let d=l&&s?Dm(l,n):null,f=-1,p=null;o&&(p=new ResizeObserver(e=>{let[r]=e;r&&r.target===l&&p&&t&&(p.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var e;(e=p)==null||e.observe(t)})),n()}),l&&!c&&p.observe(l),t&&p.observe(t));let m,h=c?am(e):null;c&&g();function g(){let t=am(e);h&&!Em(h,t)&&n(),h=t,m=requestAnimationFrame(g)}return n(),()=>{var e;u.forEach(e=>{i&&e.removeEventListener(`scroll`,n),a&&e.removeEventListener(`resize`,n)}),d?.(),(e=p)==null||e.disconnect(),p=null,c&&cancelAnimationFrame(m)}}var km=wp,Am=Tp,jm=vp,Mm=Dp,Nm=xp,Pm=_p,Fm=Ep,Im=(e,t,n)=>{let r=new Map,i={platform:Tm,...n},a={...i.platform,_c:r};return gp(e,t,{...i,platform:a})},Lm=typeof document<`u`?D.useLayoutEffect:function(){};function Rm(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e==`function`&&e.toString()===t.toString())return!0;let n,r,i;if(e&&t&&typeof e==`object`){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!Rm(e[r],t[r]))return!1;return!0}if(i=Object.keys(e),n=i.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,i[r]))return!1;for(r=n;r--!==0;){let n=i[r];if(!(n===`_owner`&&e.$$typeof)&&!Rm(e[n],t[n]))return!1}return!0}return e!==e&&t!==t}function zm(e){return typeof window>`u`?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Bm(e,t){let n=zm(e);return Math.round(t*n)/n}function Vm(e){let t=D.useRef(e);return Lm(()=>{t.current=e}),t}function Hm(e){e===void 0&&(e={});let{placement:t=`bottom`,strategy:n=`absolute`,middleware:r=[],platform:i,elements:{reference:a,floating:o}={},transform:s=!0,whileElementsMounted:c,open:l}=e,[u,d]=D.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[f,p]=D.useState(r);Rm(f,r)||p(r);let[m,h]=D.useState(null),[g,_]=D.useState(null),v=D.useCallback(e=>{e!==S.current&&(S.current=e,h(e))},[]),y=D.useCallback(e=>{e!==C.current&&(C.current=e,_(e))},[]),b=a||m,x=o||g,S=D.useRef(null),C=D.useRef(null),w=D.useRef(u),T=c!=null,E=Vm(c),O=Vm(i),ee=Vm(l),k=D.useCallback(()=>{if(!S.current||!C.current)return;let e={placement:t,strategy:n,middleware:f};O.current&&(e.platform=O.current),Im(S.current,C.current,e).then(e=>{let t={...e,isPositioned:ee.current!==!1};te.current&&!Rm(w.current,t)&&(w.current=t,xe.flushSync(()=>{d(t)}))})},[f,t,n,O,ee]);Lm(()=>{l===!1&&w.current.isPositioned&&(w.current.isPositioned=!1,d(e=>({...e,isPositioned:!1})))},[l]);let te=D.useRef(!1);Lm(()=>(te.current=!0,()=>{te.current=!1}),[]),Lm(()=>{if(b&&(S.current=b),x&&(C.current=x),b&&x){if(E.current)return E.current(b,x,k);k()}},[b,x,k,E,T]);let ne=D.useMemo(()=>({reference:S,floating:C,setReference:v,setFloating:y}),[v,y]),A=D.useMemo(()=>({reference:b,floating:x}),[b,x]),re=D.useMemo(()=>{let e={position:n,left:0,top:0};if(!A.floating)return e;let t=Bm(A.floating,u.x),r=Bm(A.floating,u.y);return s?{...e,transform:`translate(`+t+`px, `+r+`px)`,...zm(A.floating)>=1.5&&{willChange:`transform`}}:{position:n,left:t,top:r}},[n,s,A.floating,u.x,u.y]);return D.useMemo(()=>({...u,update:k,refs:ne,elements:A,floatingStyles:re}),[u,k,ne,A,re])}var Um=e=>{function t(e){return{}.hasOwnProperty.call(e,`current`)}return{name:`arrow`,options:e,fn(n){let{element:r,padding:i}=typeof e==`function`?e(n):e;return r&&t(r)?r.current==null?{}:Pm({element:r.current,padding:i}).fn(n):r?Pm({element:r,padding:i}).fn(n):{}}}},Wm=(e,t)=>{let n=km(e);return{name:n.name,fn:n.fn,options:[e,t]}},Gm=(e,t)=>{let n=Am(e);return{name:n.name,fn:n.fn,options:[e,t]}},Km=(e,t)=>({fn:Fm(e).fn,options:[e,t]}),qm=(e,t)=>{let n=jm(e);return{name:n.name,fn:n.fn,options:[e,t]}},Jm=(e,t)=>{let n=Mm(e);return{name:n.name,fn:n.fn,options:[e,t]}},Ym=(e,t)=>{let n=Nm(e);return{name:n.name,fn:n.fn,options:[e,t]}},Xm=(e,t)=>{let n=Um(e);return{name:n.name,fn:n.fn,options:[e,t]}},Zm=`Arrow`,Qm=D.forwardRef((e,t)=>{let{children:n,width:r=10,height:i=5,...a}=e;return(0,F.jsx)($.svg,{...a,ref:t,width:r,height:i,viewBox:`0 0 30 10`,preserveAspectRatio:`none`,children:e.asChild?n:(0,F.jsx)(`polygon`,{points:`0,0 30,0 15,10`})})});Qm.displayName=Zm;var $m=Qm;function eh(e){let[t,n]=D.useState(void 0);return rl(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});let t=new ResizeObserver(t=>{if(!Array.isArray(t)||!t.length)return;let r=t[0],i,a;if(`borderBoxSize`in r){let e=r.borderBoxSize,t=Array.isArray(e)?e[0]:e;i=t.inlineSize,a=t.blockSize}else i=e.offsetWidth,a=e.offsetHeight;n({width:i,height:a})});return t.observe(e,{box:`border-box`}),()=>t.unobserve(e)}else n(void 0)},[e]),t}var th=`Popper`,[nh,rh]=tl(th),[ih,ah]=nh(th),oh=e=>{let{__scopePopper:t,children:n}=e,[r,i]=D.useState(null),[a,o]=D.useState(void 0);return(0,F.jsx)(ih,{scope:t,anchor:r,onAnchorChange:i,placementState:a,setPlacementState:o,children:n})};oh.displayName=th;var sh=`PopperAnchor`,ch=D.forwardRef((e,t)=>{let{__scopePopper:n,virtualRef:r,...i}=e,a=ah(sh,n),o=D.useRef(null),s=a.onAnchorChange,c=u(t,D.useCallback(e=>{o.current=e,e&&s(e)},[s])),l=D.useRef(null);D.useEffect(()=>{if(!r)return;let e=l.current;l.current=r.current,e!==l.current&&s(l.current)});let d=a.placementState&&vh(a.placementState),f=d?.[0],p=d?.[1];return r?null:(0,F.jsx)($.div,{"data-radix-popper-side":f,"data-radix-popper-align":p,...i,ref:c})});ch.displayName=sh;var lh=`PopperContent`,[uh,dh]=nh(lh),fh=D.forwardRef((e,t)=>{let{__scopePopper:n,side:r=`bottom`,sideOffset:i=0,align:a=`center`,alignOffset:o=0,arrowPadding:s=0,avoidCollisions:c=!0,collisionBoundary:l=[],collisionPadding:d=0,sticky:f=`partial`,hideWhenDetached:p=!1,updatePositionStrategy:m=`optimized`,onPlaced:h,...g}=e,_=ah(lh,n),[v,y]=D.useState(null),b=u(t,e=>y(e)),[x,S]=D.useState(null),C=eh(x),w=C?.width??0,T=C?.height??0,E=r+(a===`center`?``:`-`+a),O=typeof d==`number`?d:{top:0,right:0,bottom:0,left:0,...d},ee=Array.isArray(l)?l:[l],k=ee.length>0,te={padding:O,boundary:ee.filter(gh),altBoundary:k},{refs:ne,floatingStyles:A,placement:re,isPositioned:ie,middlewareData:ae}=Hm({strategy:`fixed`,placement:E,whileElementsMounted:(...e)=>Om(...e,{animationFrame:m===`always`}),elements:{reference:_.anchor},middleware:[Wm({mainAxis:i+T,alignmentAxis:o}),c&&Gm({mainAxis:!0,crossAxis:!1,limiter:f===`partial`?Km():void 0,...te}),c&&qm({...te}),Jm({...te,apply:({elements:e,rects:t,availableWidth:n,availableHeight:r})=>{let{width:i,height:a}=t.reference,o=e.floating.style;o.setProperty(`--radix-popper-available-width`,`${n}px`),o.setProperty(`--radix-popper-available-height`,`${r}px`),o.setProperty(`--radix-popper-anchor-width`,`${i}px`),o.setProperty(`--radix-popper-anchor-height`,`${a}px`)}}),x&&Xm({element:x,padding:s}),_h({arrowWidth:w,arrowHeight:T}),p&&Ym({strategy:`referenceHidden`,...te,boundary:k?te.boundary:void 0})]}),j=_.setPlacementState;rl(()=>(j(re),()=>{j(void 0)}),[re,j]);let[oe,se]=vh(re),ce=fl(h);rl(()=>{ie&&ce?.()},[ie,ce]);let le=ae.arrow?.x,ue=ae.arrow?.y,de=ae.arrow?.centerOffset!==0,[fe,M]=D.useState();return rl(()=>{v&&M(window.getComputedStyle(v).zIndex)},[v]),(0,F.jsx)(`div`,{ref:ne.setFloating,"data-radix-popper-content-wrapper":``,style:{...A,transform:ie?A.transform:`translate(0, -200%)`,minWidth:`max-content`,zIndex:fe,"--radix-popper-transform-origin":[ae.transformOrigin?.x,ae.transformOrigin?.y].join(` `),...ae.hide?.referenceHidden&&{visibility:`hidden`,pointerEvents:`none`}},dir:e.dir,children:(0,F.jsx)(uh,{scope:n,placedSide:oe,placedAlign:se,onArrowChange:S,arrowX:le,arrowY:ue,shouldHideArrow:de,children:(0,F.jsx)($.div,{"data-side":oe,"data-align":se,...g,ref:b,style:{...g.style,animation:ie?void 0:`none`}})})})});fh.displayName=lh;var ph=`PopperArrow`,mh={top:`bottom`,right:`left`,bottom:`top`,left:`right`},hh=D.forwardRef(function(e,t){let{__scopePopper:n,...r}=e,i=dh(ph,n),a=mh[i.placedSide];return(0,F.jsx)(`span`,{ref:i.onArrowChange,style:{position:`absolute`,left:i.arrowX,top:i.arrowY,[a]:0,transformOrigin:{top:``,right:`0 0`,bottom:`center 0`,left:`100% 0`}[i.placedSide],transform:{top:`translateY(100%)`,right:`translateY(50%) rotate(90deg) translateX(-50%)`,bottom:`rotate(180deg)`,left:`translateY(50%) rotate(-90deg) translateX(50%)`}[i.placedSide],visibility:i.shouldHideArrow?`hidden`:void 0},children:(0,F.jsx)($m,{...r,ref:t,style:{...r.style,display:`block`}})})});hh.displayName=ph;function gh(e){return e!==null}var _h=e=>({name:`transformOrigin`,options:e,fn(t){let{placement:n,rects:r,middlewareData:i}=t,a=i.arrow?.centerOffset!==0,o=a?0:e.arrowWidth,s=a?0:e.arrowHeight,[c,l]=vh(n),u={start:`0%`,center:`50%`,end:`100%`}[l],d=(i.arrow?.x??0)+o/2,f=(i.arrow?.y??0)+s/2,p=``,m=``;return c===`bottom`?(p=a?u:`${d}px`,m=`${-s}px`):c===`top`?(p=a?u:`${d}px`,m=`${r.floating.height+s}px`):c===`right`?(p=`${-s}px`,m=a?u:`${f}px`):c===`left`&&(p=`${r.floating.width+s}px`,m=a?u:`${f}px`),{data:{x:p,y:m}}}});function vh(e){let[t,n=`center`]=e.split(`-`);return[t,n]}var yh=oh,bh=ch,xh=fh,Sh=hh;function Ch({className:e,...t}){return(0,F.jsx)(`textarea`,{"data-slot":`textarea`,className:l(`field-sizing-content min-h-10 w-full min-w-0 resize-none overflow-x-hidden rounded-md bg-transparent px-3 py-2 text-base outline-none [overflow-wrap:anywhere] placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50`,e),...t})}var wh=new class{async listCommands(){return z.get(`/commands`)}async getCommand(e,t){return z.get(`/commands/${encodeURIComponent(e)}/${encodeURIComponent(t)}`)}async getWorkflowCommand(e){return this.getCommand(`workflow`,e)}},Th=s(`inline-flex items-center justify-center rounded-md border px-2 py-0.5 text-xs font-medium w-fit whitespace-nowrap shrink-0 [&>svg]:size-3 gap-1 [&>svg]:pointer-events-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] transition-[color,box-shadow] overflow-hidden`,{variants:{variant:{default:`border-transparent bg-primary text-primary-foreground [a&]:hover:bg-primary/90`,secondary:`border-transparent bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/90`,destructive:`border-transparent bg-destructive text-white [a&]:hover:bg-destructive/90`,outline:`text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground`,warning:`border-transparent bg-amber-500/15 text-amber-600 dark:text-amber-400`,success:`border-transparent bg-primary/15 text-primary`}},defaultVariants:{variant:`default`}});function Eh({className:e,variant:t,asChild:n=!1,...r}){return(0,F.jsx)(n?d:`span`,{"data-slot":`badge`,className:l(Th({variant:t}),e),...r})}function Dh(e,[t,n]){return Math.min(n,Math.max(t,e))}function Oh(e){let t=D.useRef({value:e,previous:e});return D.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var kh=Object.freeze({position:`absolute`,border:0,width:1,height:1,padding:0,margin:-1,overflow:`hidden`,clip:`rect(0, 0, 0, 0)`,whiteSpace:`nowrap`,wordWrap:`normal`}),Ah=`VisuallyHidden`,jh=D.forwardRef((e,t)=>(0,F.jsx)($.span,{...e,ref:t,style:{...kh,...e.style}}));jh.displayName=Ah;var Mh=[` `,`Enter`,`ArrowUp`,`ArrowDown`],Nh=[` `,`Enter`],Ph=`Select`,[Fh,Ih,Lh]=If(Ph),[Rh,zh]=tl(Ph,[Lh,rh]),Bh=rh(),[Vh,Hh]=Rh(Ph),[Uh,Wh]=Rh(Ph),Gh=`SelectProvider`;function Kh(e){let{__scopeSelect:t,children:n,open:r,defaultOpen:i,onOpenChange:a,value:o,defaultValue:s,onValueChange:c,dir:l,name:u,autoComplete:d,disabled:f,required:p,form:m,internal_do_not_use_render:h}=e,g=Bh(t),[_,v]=D.useState(null),[y,b]=D.useState(null),[x,S]=D.useState(!1),C=Rf(l),[w,T]=cl({prop:r,defaultProp:i??!1,onChange:a,caller:Ph}),[E,O]=cl({prop:o,defaultProp:s,onChange:c,caller:Ph}),ee=D.useRef(null),k=_?!!m||!!_.closest(`form`):!0,[te,ne]=D.useState(new Set),A=ol(),re=Array.from(te).map(e=>e.props.value).join(`;`),ie=D.useCallback(e=>{ne(t=>new Set(t).add(e))},[]),ae=D.useCallback(e=>{ne(t=>{let n=new Set(t);return n.delete(e),n})},[]),j={required:p,trigger:_,onTriggerChange:v,valueNode:y,onValueNodeChange:b,valueNodeHasChildren:x,onValueNodeHasChildrenChange:S,contentId:A,value:E,onValueChange:O,open:w,onOpenChange:T,dir:C,triggerPointerDownPosRef:ee,disabled:f,name:u,autoComplete:d,form:m,nativeOptions:te,nativeSelectKey:re,isFormControl:k};return(0,F.jsx)(yh,{...g,children:(0,F.jsx)(Vh,{scope:t,...j,children:(0,F.jsx)(Fh.Provider,{scope:t,children:(0,F.jsx)(Uh,{scope:t,onNativeOptionAdd:ie,onNativeOptionRemove:ae,children:Kg(h)?h(j):n})})})})}Kh.displayName=Gh;var qh=e=>{let{__scopeSelect:t,children:n,...r}=e;return(0,F.jsx)(Kh,{__scopeSelect:t,...r,internal_do_not_use_render:({isFormControl:e})=>(0,F.jsxs)(F.Fragment,{children:[n,e?(0,F.jsx)(Gg,{__scopeSelect:t}):null]})})};qh.displayName=Ph;var Jh=`SelectTrigger`,Yh=D.forwardRef((e,t)=>{let{__scopeSelect:n,disabled:r=!1,...i}=e,a=Bh(n),o=Hh(Jh,n),s=o.disabled||r,c=u(t,o.onTriggerChange),l=Ih(n),d=D.useRef(`touch`),[f,p,m]=Jg(e=>{let t=l().filter(e=>!e.disabled),n=Yg(t,e,t.find(e=>e.value===o.value));n!==void 0&&o.onValueChange(n.value)}),h=e=>{s||(o.onOpenChange(!0),m()),e&&(o.triggerPointerDownPosRef.current={x:Math.round(e.pageX),y:Math.round(e.pageY)})};return(0,F.jsx)(bh,{asChild:!0,...a,children:(0,F.jsx)($.button,{type:`button`,role:`combobox`,"aria-controls":o.open?o.contentId:void 0,"aria-expanded":o.open,"aria-required":o.required,"aria-autocomplete":`none`,dir:o.dir,"data-state":o.open?`open`:`closed`,disabled:s,"data-disabled":s?``:void 0,"data-placeholder":qg(o.value)?``:void 0,...i,ref:c,onClick:Q(i.onClick,e=>{e.currentTarget.focus(),d.current!==`mouse`&&h(e)}),onPointerDown:Q(i.onPointerDown,e=>{d.current=e.pointerType;let t=e.target;t.hasPointerCapture(e.pointerId)&&t.releasePointerCapture(e.pointerId),e.button===0&&e.ctrlKey===!1&&e.pointerType===`mouse`&&(h(e),e.preventDefault())}),onKeyDown:Q(i.onKeyDown,e=>{let t=f.current!==``;!(e.ctrlKey||e.altKey||e.metaKey)&&e.key.length===1&&p(e.key),!(t&&e.key===` `)&&Mh.includes(e.key)&&(h(),e.preventDefault())})})})});Yh.displayName=Jh;var Xh=`SelectValue`,Zh=D.forwardRef((e,t)=>{let{__scopeSelect:n,className:r,style:i,children:a,placeholder:o=``,...s}=e,c=Hh(Xh,n),{onValueNodeHasChildrenChange:l}=c,d=a!==void 0,f=u(t,c.onValueNodeChange);rl(()=>{l(d)},[l,d]);let p=qg(c.value);return(0,F.jsx)($.span,{...s,asChild:p?!1:s.asChild,ref:f,style:{pointerEvents:`none`},children:(0,F.jsx)(D.Fragment,{children:p?o:a},p?`placeholder`:`value`)})});Zh.displayName=Xh;var Qh=`SelectIcon`,$h=D.forwardRef((e,t)=>{let{__scopeSelect:n,children:r,...i}=e;return(0,F.jsx)($.span,{"aria-hidden":!0,...i,ref:t,children:r||`▼`})});$h.displayName=Qh;var eg=`SelectPortal`,[tg,ng]=Rh(eg,{forceMount:void 0}),rg=e=>{let{__scopeSelect:t,forceMount:n,...r}=e;return(0,F.jsx)(tg,{scope:e.__scopeSelect,forceMount:n,children:(0,F.jsx)(Gl,{asChild:!0,...r})})};rg.displayName=eg;var ig=`SelectContent`,ag=D.forwardRef((e,t)=>{let n=ng(ig,e.__scopeSelect),{forceMount:r=n.forceMount,...i}=e,a=Hh(ig,e.__scopeSelect),[o,s]=D.useState();return rl(()=>{s(new DocumentFragment)},[]),(0,F.jsx)(ql,{present:r||a.open,children:({present:e})=>e?(0,F.jsx)(fg,{...i,ref:t}):(0,F.jsx)(og,{...i,fragment:o})})});ag.displayName=ig;var og=D.forwardRef((e,t)=>{let{__scopeSelect:n,children:r,fragment:i}=e;return i?xe.createPortal((0,F.jsx)(cg,{scope:n,children:(0,F.jsx)(Fh.Slot,{scope:n,children:(0,F.jsx)(`div`,{ref:t,children:r})})}),i):null});og.displayName=`SelectContentFragment`;var sg=10,[cg,lg]=Rh(ig),ug=`SelectContentImpl`,dg=f(`SelectContent.RemoveScroll`),fg=D.forwardRef((e,t)=>{let{__scopeSelect:n}=e,{position:r=`item-aligned`,onCloseAutoFocus:i,onEscapeKeyDown:a,onPointerDownOutside:o,side:s,sideOffset:c,align:l,alignOffset:d,arrowPadding:f,collisionBoundary:p,collisionPadding:m,sticky:h,hideWhenDetached:g,avoidCollisions:_,...v}=e,y=Hh(ig,n),[b,x]=D.useState(null),[S,C]=D.useState(null),w=u(t,e=>x(e)),[T,E]=D.useState(null),[O,ee]=D.useState(null),k=Ih(n),[te,ne]=D.useState(!1),A=D.useRef(!1);D.useEffect(()=>{if(b)return bd(b)},[b]),tu();let re=D.useCallback(e=>{let[t,...n]=k().map(e=>e.ref.current),[r]=n.slice(-1),i=document.activeElement;for(let n of e)if(n===i||(n?.scrollIntoView({block:`nearest`}),n===t&&S&&(S.scrollTop=0),n===r&&S&&(S.scrollTop=S.scrollHeight),n?.focus(),document.activeElement!==i))return},[k,S]),ie=D.useCallback(()=>re([T,b]),[re,T,b]);D.useEffect(()=>{te&&ie()},[te,ie]);let{onOpenChange:ae,triggerPointerDownPosRef:j}=y;D.useEffect(()=>{if(b){let e={x:0,y:0},t=t=>{e={x:Math.abs(Math.round(t.pageX)-(j.current?.x??0)),y:Math.abs(Math.round(t.pageY)-(j.current?.y??0))}},n=n=>{e.x<=10&&e.y<=10?n.preventDefault():n.composedPath().includes(b)||ae(!1),document.removeEventListener(`pointermove`,t),j.current=null};return j.current!==null&&(document.addEventListener(`pointermove`,t),document.addEventListener(`pointerup`,n,{capture:!0,once:!0})),()=>{document.removeEventListener(`pointermove`,t),document.removeEventListener(`pointerup`,n,{capture:!0})}}},[b,ae,j]),D.useEffect(()=>{let e=()=>ae(!1);return window.addEventListener(`blur`,e),window.addEventListener(`resize`,e),()=>{window.removeEventListener(`blur`,e),window.removeEventListener(`resize`,e)}},[ae]);let[oe,se]=Jg(e=>{let t=k().filter(e=>!e.disabled),n=Yg(t,e,t.find(e=>e.ref.current===document.activeElement));n&&setTimeout(()=>n.ref.current?.focus())}),ce=D.useCallback((e,t,n)=>{let r=!A.current&&!n;(y.value!==void 0&&y.value===t||r)&&(E(e),r&&(A.current=!0))},[y.value]),le=D.useCallback(()=>b?.focus(),[b]),ue=D.useCallback((e,t,n)=>{let r=!A.current&&!n;(y.value!==void 0&&y.value===t||r)&&ee(e)},[y.value]),de=r===`popper`?gg:mg,fe=de===gg?{side:s,sideOffset:c,align:l,alignOffset:d,arrowPadding:f,collisionBoundary:p,collisionPadding:m,sticky:h,hideWhenDetached:g,avoidCollisions:_}:{};return(0,F.jsx)(cg,{scope:n,content:b,viewport:S,onViewportChange:C,itemRefCallback:ce,selectedItem:T,onItemLeave:le,itemTextRefCallback:ue,focusSelectedItem:ie,selectedItemText:O,position:r,isPositioned:te,searchRef:oe,children:(0,F.jsx)(dd,{as:dg,allowPinchZoom:!0,children:(0,F.jsx)(Ml,{asChild:!0,trapped:y.open,onMountAutoFocus:e=>{e.preventDefault()},onUnmountAutoFocus:Q(i,e=>{y.trigger?.focus({preventScroll:!0}),e.preventDefault()}),children:(0,F.jsx)(bl,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:a,onPointerDownOutside:o,onFocusOutside:e=>e.preventDefault(),onDismiss:()=>y.onOpenChange(!1),children:(0,F.jsx)(de,{role:`listbox`,id:y.contentId,"data-state":y.open?`open`:`closed`,dir:y.dir,onContextMenu:e=>e.preventDefault(),...v,...fe,onPlaced:()=>ne(!0),ref:w,style:{display:`flex`,flexDirection:`column`,outline:`none`,...v.style},onKeyDown:Q(v.onKeyDown,e=>{let t=e.ctrlKey||e.altKey||e.metaKey;if(e.key===`Tab`&&e.preventDefault(),!t&&e.key.length===1&&se(e.key),[`ArrowUp`,`ArrowDown`,`Home`,`End`].includes(e.key)){let t=k().filter(e=>!e.disabled).map(e=>e.ref.current);if([`ArrowUp`,`End`].includes(e.key)&&(t=t.slice().reverse()),[`ArrowUp`,`ArrowDown`].includes(e.key)){let n=e.target,r=t.indexOf(n);t=t.slice(r+1)}setTimeout(()=>re(t)),e.preventDefault()}})})})})})})});fg.displayName=ug;var pg=`SelectItemAlignedPosition`,mg=D.forwardRef((e,t)=>{let{__scopeSelect:n,onPlaced:r,...i}=e,a=Hh(ig,n),o=lg(ig,n),[s,c]=D.useState(null),[l,d]=D.useState(null),f=u(t,e=>d(e)),p=Ih(n),m=D.useRef(!1),h=D.useRef(!0),{viewport:g,selectedItem:_,selectedItemText:v,focusSelectedItem:y}=o,b=D.useCallback(()=>{if(a.trigger&&a.valueNode&&s&&l&&g&&_&&v){let e=a.trigger.getBoundingClientRect(),t=l.getBoundingClientRect(),n=a.valueNode.getBoundingClientRect(),i=v.getBoundingClientRect();if(a.dir!==`rtl`){let r=i.left-t.left,a=n.left-r,o=e.left-a,c=e.width+o,l=Math.max(c,t.width),u=window.innerWidth-sg,d=Dh(a,[sg,Math.max(sg,u-l)]);s.style.minWidth=c+`px`,s.style.left=d+`px`}else{let r=t.right-i.right,a=window.innerWidth-n.right-r,o=window.innerWidth-e.right-a,c=e.width+o,l=Math.max(c,t.width),u=window.innerWidth-sg,d=Dh(a,[sg,Math.max(sg,u-l)]);s.style.minWidth=c+`px`,s.style.right=d+`px`}let o=p(),c=window.innerHeight-sg*2,u=g.scrollHeight,d=window.getComputedStyle(l),f=parseInt(d.borderTopWidth,10),h=parseInt(d.paddingTop,10),y=parseInt(d.borderBottomWidth,10),b=parseInt(d.paddingBottom,10),x=f+h+u+b+y,S=Math.min(_.offsetHeight*5,x),C=window.getComputedStyle(g),w=parseInt(C.paddingTop,10),T=parseInt(C.paddingBottom,10),E=e.top+e.height/2-sg,D=c-E,O=_.offsetHeight/2,ee=_.offsetTop+O,k=f+h+ee,te=x-k;if(k<=E){let e=o.length>0&&_===o[o.length-1].ref.current;s.style.bottom=`0px`;let t=l.clientHeight-g.offsetTop-g.offsetHeight,n=k+Math.max(D,O+(e?T:0)+t+y);s.style.height=n+`px`}else{let e=o.length>0&&_===o[0].ref.current;s.style.top=`0px`;let t=Math.max(E,f+g.offsetTop+(e?w:0)+O)+te;s.style.height=t+`px`,g.scrollTop=k-E+g.offsetTop}s.style.margin=`${sg}px 0`,s.style.minHeight=S+`px`,s.style.maxHeight=c+`px`,r?.(),requestAnimationFrame(()=>m.current=!0)}},[p,a.trigger,a.valueNode,s,l,g,_,v,a.dir,r]);rl(()=>b(),[b]);let[x,S]=D.useState();return rl(()=>{l&&S(window.getComputedStyle(l).zIndex)},[l]),(0,F.jsx)(_g,{scope:n,contentWrapper:s,shouldExpandOnScrollRef:m,onScrollButtonChange:D.useCallback(e=>{e&&h.current===!0&&(b(),y?.(),h.current=!1)},[b,y]),children:(0,F.jsx)(`div`,{ref:c,style:{display:`flex`,flexDirection:`column`,position:`fixed`,zIndex:x},children:(0,F.jsx)($.div,{...i,ref:f,style:{boxSizing:`border-box`,maxHeight:`100%`,...i.style}})})})});mg.displayName=pg;var hg=`SelectPopperPosition`,gg=D.forwardRef((e,t)=>{let{__scopeSelect:n,align:r=`start`,collisionPadding:i=sg,...a}=e,o=Bh(n);return(0,F.jsx)(xh,{...o,...a,ref:t,align:r,collisionPadding:i,style:{boxSizing:`border-box`,...a.style,"--radix-select-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-select-content-available-width":`var(--radix-popper-available-width)`,"--radix-select-content-available-height":`var(--radix-popper-available-height)`,"--radix-select-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-select-trigger-height":`var(--radix-popper-anchor-height)`}})});gg.displayName=hg;var[_g,vg]=Rh(ig,{}),yg=`SelectViewport`,bg=D.forwardRef((e,t)=>{let{__scopeSelect:n,nonce:r,...i}=e,a=lg(yg,n),o=vg(yg,n),s=u(t,a.onViewportChange),c=D.useRef(0);return(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`style`,{dangerouslySetInnerHTML:{__html:`[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}`},nonce:r}),(0,F.jsx)(Fh.Slot,{scope:n,children:(0,F.jsx)($.div,{"data-radix-select-viewport":``,role:`presentation`,...i,ref:s,style:{position:`relative`,flex:1,overflow:`hidden auto`,...i.style},onScroll:Q(i.onScroll,e=>{let t=e.currentTarget,{contentWrapper:n,shouldExpandOnScrollRef:r}=o;if(r?.current&&n){let e=Math.abs(c.current-t.scrollTop);if(e>0){let r=window.innerHeight-sg*2,i=parseFloat(n.style.minHeight),a=parseFloat(n.style.height),o=Math.max(i,a);if(o<r){let i=o+e,a=Math.min(r,i),s=i-a;n.style.height=a+`px`,n.style.bottom===`0px`&&(t.scrollTop=s>0?s:0,n.style.justifyContent=`flex-end`)}}}c.current=t.scrollTop})})})]})});bg.displayName=yg;var xg=`SelectGroup`,[Sg,Cg]=Rh(xg),wg=D.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e,i=ol();return(0,F.jsx)(Sg,{scope:n,id:i,children:(0,F.jsx)($.div,{role:`group`,"aria-labelledby":i,...r,ref:t})})});wg.displayName=xg;var Tg=`SelectLabel`,Eg=D.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e,i=Cg(Tg,n);return(0,F.jsx)($.div,{id:i.id,...r,ref:t})});Eg.displayName=Tg;var Dg=`SelectItem`,[Og,kg]=Rh(Dg),Ag=D.forwardRef((e,t)=>{let{__scopeSelect:n,value:r,disabled:i=!1,textValue:a,...o}=e,s=Hh(Dg,n),c=lg(Dg,n),l=s.value===r,[d,f]=D.useState(a??``),[p,m]=D.useState(!1),h=u(t,e=>c.itemRefCallback?.(e,r,i)),g=ol(),_=D.useRef(`touch`),v=()=>{i||(s.onValueChange(r),s.onOpenChange(!1))};return(0,F.jsx)(Og,{scope:n,value:r,disabled:i,textId:g,isSelected:l,onItemTextChange:D.useCallback(e=>{f(t=>t||(e?.textContent??``).trim())},[]),children:(0,F.jsx)(Fh.ItemSlot,{scope:n,value:r,disabled:i,textValue:d,children:(0,F.jsx)($.div,{role:`option`,"aria-labelledby":g,"data-highlighted":p?``:void 0,"aria-selected":l&&p,"data-state":l?`checked`:`unchecked`,"aria-disabled":i||void 0,"data-disabled":i?``:void 0,tabIndex:i?void 0:-1,...o,ref:h,onFocus:Q(o.onFocus,()=>m(!0)),onBlur:Q(o.onBlur,()=>m(!1)),onClick:Q(o.onClick,()=>{_.current!==`mouse`&&v()}),onPointerUp:Q(o.onPointerUp,()=>{_.current===`mouse`&&v()}),onPointerDown:Q(o.onPointerDown,e=>{_.current=e.pointerType}),onPointerMove:Q(o.onPointerMove,e=>{_.current=e.pointerType,i?c.onItemLeave?.():_.current===`mouse`&&e.currentTarget.focus({preventScroll:!0})}),onPointerLeave:Q(o.onPointerLeave,e=>{e.currentTarget===document.activeElement&&c.onItemLeave?.()}),onKeyDown:Q(o.onKeyDown,e=>{c.searchRef?.current!==``&&e.key===` `||(Nh.includes(e.key)&&v(),e.key===` `&&e.preventDefault())})})})})});Ag.displayName=Dg;var jg=`SelectItemText`,Mg=D.forwardRef((e,t)=>{let{__scopeSelect:n,className:r,style:i,...a}=e,o=Hh(jg,n),s=lg(jg,n),c=kg(jg,n),l=Wh(jg,n),[d,f]=D.useState(null),p=u(t,e=>f(e),c.onItemTextChange,e=>s.itemTextRefCallback?.(e,c.value,c.disabled)),m=d?.textContent,h=D.useMemo(()=>(0,F.jsx)(`option`,{value:c.value,disabled:c.disabled,children:m},c.value),[c.disabled,c.value,m]),{onNativeOptionAdd:g,onNativeOptionRemove:_}=l;return rl(()=>(g(h),()=>_(h)),[g,_,h]),(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)($.span,{id:c.textId,...a,ref:p}),c.isSelected&&o.valueNode&&!o.valueNodeHasChildren&&!qg(o.value)?xe.createPortal(a.children,o.valueNode):null]})});Mg.displayName=jg;var Ng=`SelectItemIndicator`,Pg=D.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e;return kg(Ng,n).isSelected?(0,F.jsx)($.span,{"aria-hidden":!0,...r,ref:t}):null});Pg.displayName=Ng;var Fg=`SelectScrollUpButton`,Ig=D.forwardRef((e,t)=>{let n=lg(Fg,e.__scopeSelect),r=vg(Fg,e.__scopeSelect),[i,a]=D.useState(!1),o=u(t,r.onScrollButtonChange);return rl(()=>{if(n.viewport&&n.isPositioned){let e=function(){a(t.scrollTop>0)},t=n.viewport;return e(),t.addEventListener(`scroll`,e),()=>t.removeEventListener(`scroll`,e)}},[n.viewport,n.isPositioned]),i?(0,F.jsx)(zg,{...e,ref:o,onAutoScroll:()=>{let{viewport:e,selectedItem:t}=n;e&&t&&(e.scrollTop-=t.offsetHeight)}}):null});Ig.displayName=Fg;var Lg=`SelectScrollDownButton`,Rg=D.forwardRef((e,t)=>{let n=lg(Lg,e.__scopeSelect),r=vg(Lg,e.__scopeSelect),[i,a]=D.useState(!1),o=u(t,r.onScrollButtonChange);return rl(()=>{if(n.viewport&&n.isPositioned){let e=function(){let e=t.scrollHeight-t.clientHeight;a(Math.ceil(t.scrollTop)<e)},t=n.viewport;return e(),t.addEventListener(`scroll`,e),()=>t.removeEventListener(`scroll`,e)}},[n.viewport,n.isPositioned]),i?(0,F.jsx)(zg,{...e,ref:o,onAutoScroll:()=>{let{viewport:e,selectedItem:t}=n;e&&t&&(e.scrollTop+=t.offsetHeight)}}):null});Rg.displayName=Lg;var zg=D.forwardRef((e,t)=>{let{__scopeSelect:n,onAutoScroll:r,...i}=e,a=lg(`SelectScrollButton`,n),o=D.useRef(null),s=Ih(n),c=D.useCallback(()=>{o.current!==null&&(window.clearInterval(o.current),o.current=null)},[]);return D.useEffect(()=>()=>c(),[c]),rl(()=>{s().find(e=>e.ref.current===document.activeElement)?.ref.current?.scrollIntoView({block:`nearest`})},[s]),(0,F.jsx)($.div,{"aria-hidden":!0,...i,ref:t,style:{flexShrink:0,...i.style},onPointerDown:Q(i.onPointerDown,()=>{o.current===null&&(o.current=window.setInterval(r,50))}),onPointerMove:Q(i.onPointerMove,()=>{a.onItemLeave?.(),o.current===null&&(o.current=window.setInterval(r,50))}),onPointerLeave:Q(i.onPointerLeave,()=>{c()})})}),Bg=`SelectSeparator`,Vg=D.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e;return(0,F.jsx)($.div,{"aria-hidden":!0,...r,ref:t})});Vg.displayName=Bg;var Hg=`SelectArrow`,Ug=D.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e,i=Bh(n);return lg(Hg,n).position===`popper`?(0,F.jsx)(Sh,{...i,...r,ref:t}):null});Ug.displayName=Hg;var Wg=`SelectBubbleInput`,Gg=D.forwardRef(({__scopeSelect:e,...t},n)=>{let r=Hh(Wg,e),{value:i,onValueChange:a,required:o,disabled:s,name:c,autoComplete:l,form:d}=r,{nativeOptions:f,nativeSelectKey:p}=r,m=D.useRef(null),h=u(n,m),g=i??``,_=Oh(g),v=Array.from(f).some(e=>(e.props.value??``)===``);return D.useEffect(()=>{let e=m.current;if(!e)return;let t=window.HTMLSelectElement.prototype,n=Object.getOwnPropertyDescriptor(t,`value`).set;if(_!==g&&n){let t=new Event(`change`,{bubbles:!0});n.call(e,g),e.dispatchEvent(t)}},[_,g]),(0,F.jsxs)($.select,{"aria-hidden":!0,required:o,tabIndex:-1,name:c,autoComplete:l,disabled:s,form:d,onChange:e=>a(e.target.value),...t,style:{...kh,...t.style},ref:h,defaultValue:g,children:[qg(i)&&!v?(0,F.jsx)(`option`,{value:``}):null,Array.from(f)]},p)});Gg.displayName=Wg;function Kg(e){return typeof e==`function`}function qg(e){return e===``||e===void 0}function Jg(e){let t=fl(e),n=D.useRef(``),r=D.useRef(0),i=D.useCallback(e=>{let i=n.current+e;t(i),(function e(t){n.current=t,window.clearTimeout(r.current),t!==``&&(r.current=window.setTimeout(()=>e(``),1e3))})(i)},[t]),a=D.useCallback(()=>{n.current=``,window.clearTimeout(r.current)},[]);return D.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,i,a]}function Yg(e,t,n){let r=t.length>1&&Array.from(t).every(e=>e===t[0])?t[0]:t,i=n?e.indexOf(n):-1,a=Xg(e,Math.max(i,0));r.length===1&&(a=a.filter(e=>e!==n));let o=a.find(e=>e.textValue.toLowerCase().startsWith(r.toLowerCase()));return o===n?void 0:o}function Xg(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function Zg(e){return(0,F.jsx)(qh,{"data-slot":`select`,...e})}function Qg(e){return(0,F.jsx)(Zh,{"data-slot":`select-value`,...e})}function $g({className:e,size:t=`default`,children:n,...r}){return(0,F.jsxs)(Yh,{"data-slot":`select-trigger`,"data-size":t,className:l(`border-input data-[placeholder]:text-muted-foreground [&_svg:not([class*='text-'])]:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 dark:hover:bg-input/50 flex w-fit items-center justify-between gap-2 rounded-md border bg-transparent px-3 py-2 text-sm whitespace-nowrap shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 data-[size=default]:h-9 data-[size=sm]:h-8 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,e),...r,children:[n,(0,F.jsx)($h,{asChild:!0,children:(0,F.jsx)(g,{className:`size-4 opacity-50`})})]})}function e_({className:e,children:t,position:n=`popper`,...r}){return(0,F.jsx)(rg,{children:(0,F.jsxs)(ag,{"data-slot":`select-content`,className:l(`bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 relative z-[140] max-h-(--radix-select-content-available-height) min-w-[8rem] origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border shadow-md`,n===`popper`&&`data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1`,e),position:n,...r,children:[(0,F.jsx)(n_,{}),(0,F.jsx)(bg,{className:l(`p-1`,n===`popper`&&`h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1`),children:t}),(0,F.jsx)(r_,{})]})})}function t_({className:e,children:t,...n}){return(0,F.jsxs)(Ag,{"data-slot":`select-item`,className:l(`focus:bg-accent focus:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex w-full cursor-default items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2`,e),...n,children:[(0,F.jsx)(`span`,{className:`absolute right-2 flex size-3.5 items-center justify-center`,children:(0,F.jsx)(Pg,{children:(0,F.jsx)(h,{className:`size-4`})})}),(0,F.jsx)(Mg,{children:t})]})}function n_({className:e,...t}){return(0,F.jsx)(Ig,{"data-slot":`select-scroll-up-button`,className:l(`flex cursor-default items-center justify-center py-1`,e),...t,children:(0,F.jsx)(v,{className:`size-4`})})}function r_({className:e,...t}){return(0,F.jsx)(Rg,{"data-slot":`select-scroll-down-button`,className:l(`flex cursor-default items-center justify-center py-1`,e),...t,children:(0,F.jsx)(g,{className:`size-4`})})}export{dl as $,p as $t,lf as A,Wn as At,Gd as B,A as Bt,Af as C,wa as Ct,mf as D,gr as Dt,Sf as E,q as Et,Qd as F,Te as Ft,dd as G,S as Gt,Md as H,T as Ht,Zd as I,we as It,Gl as J,y as Jt,tu as K,x as Kt,Ed as L,De as Lt,$d as M,z as Mt,Yd as N,Se as Nt,hf as O,sr as Ot,Xd as P,Ce as Pt,$ as Q,m as Qt,qd as R,Ee as Rt,Df as S,Ya as St,xf as T,cr as Tt,Ud as U,w as Ut,Pd as V,E as Vt,bd as W,C as Wt,bl as X,g as Xt,Ml as Y,_ as Yt,fl as Z,h as Zt,If as _,Xo as _t,Qg as a,Gc as at,Ff as b,ro as bt,wh as c,Kc as ct,Sh as d,ac as dt,cl as et,xh as f,lc as ft,Rf as g,xs as gt,eh as h,oc as ht,$g as i,el as it,of as j,Gn as jt,cf as k,or as kt,Ch as l,jc as lt,rh as m,cc as mt,e_ as n,tl as nt,Oh as o,Wc as ot,yh as p,sc as pt,ql as q,b as qt,t_ as r,Q as rt,Eh as s,Hc as st,Zg as t,ol as tt,bh as u,Ac as ut,Mf as v,Go as vt,Of as w,Er as wt,Pf as x,$a as xt,Nf as y,Ko as yt,Rd as z,se as zt};
|