@chainingintention/pi-web-cn 2.202611.4 → 2.202611.6

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.
Files changed (40) hide show
  1. package/dist/client/assets/{PiWebApp-rG0WhMEa.js → PiWebApp-NXSXyci_.js} +879 -866
  2. package/dist/client/assets/SettingsDialog-lAadl-rm.js +1274 -0
  3. package/dist/client/assets/{external-DZQ-GM9O.js → external-Bxk-hFko.js} +1 -1
  4. package/dist/client/assets/{index-C8SnDkf4.js → index-AJX2U-nF.js} +2 -2
  5. package/dist/client/assets/{main-T8PgowZ_.js → main-BrnfeRme.js} +2 -2
  6. package/dist/client/assets/requiredTerminalPlugin-M436A3oj.js +3 -0
  7. package/dist/client/index.html +1 -1
  8. package/dist/config.js +22 -0
  9. package/dist/config.js.map +1 -1
  10. package/dist/pi-web-plugins/zh-cn/catalogs.json +38 -0
  11. package/dist/pi-web-plugins/zh-cn/config-errors.json +9 -1
  12. package/dist/server/configRoutes.js +1 -0
  13. package/dist/server/configRoutes.js.map +1 -1
  14. package/dist/server/normalAuth.js +1 -1
  15. package/dist/server/normalAuth.js.map +1 -1
  16. package/dist/server/sessiond/sessionProxyRoutes.js +9 -2
  17. package/dist/server/sessiond/sessionProxyRoutes.js.map +1 -1
  18. package/dist/server/sessiond.js +10 -1
  19. package/dist/server/sessiond.js.map +1 -1
  20. package/dist/server/speech/speechRoutes.js +25 -0
  21. package/dist/server/speech/speechRoutes.js.map +1 -0
  22. package/dist/server/speech/transcriptionService.js +198 -0
  23. package/dist/server/speech/transcriptionService.js.map +1 -0
  24. package/dist/shared/apiTypes.js +1 -0
  25. package/dist/shared/apiTypes.js.map +1 -1
  26. package/dist/shared/capabilities.js +3 -0
  27. package/dist/shared/capabilities.js.map +1 -1
  28. package/dist/shared/configResolution.js +2 -0
  29. package/dist/shared/configResolution.js.map +1 -1
  30. package/dist/shared/federatedRoutes.js +2 -0
  31. package/dist/shared/federatedRoutes.js.map +1 -1
  32. package/dist/shared/piWebConfigParsing.js +76 -0
  33. package/dist/shared/piWebConfigParsing.js.map +1 -1
  34. package/dist/shared/speechTranscription.js +81 -0
  35. package/dist/shared/speechTranscription.js.map +1 -0
  36. package/docs/config.md +30 -3
  37. package/docs/plugins.md +1 -1
  38. package/package.json +1 -1
  39. package/dist/client/assets/SettingsDialog-D6czghzo.js +0 -1129
  40. package/dist/client/assets/requiredTerminalPlugin-DrXvpLs1.js +0 -3
@@ -1 +1 @@
1
- import{_ as e,g as t,p as n}from"./themePreference-BBiJxLjs.js";import{a as r,at as i,bt as a,it as o,mt as s,ot as c,t as l}from"./requiredTerminalPlugin-DrXvpLs1.js";function u(e,t){for(let n of[`title`,`name`,`description`,`group`,`label`,`disabledReason`]){let r=Object.getOwnPropertyDescriptor(e,n);r?.get!==void 0&&Object.defineProperty(t,n,{enumerable:!0,configurable:!0,get:r.get.bind(e)})}return t}function d(e){return{id:e.id,cwd:e.cwd,...e.name===void 0?{}:{name:e.name},...e.metadata===void 0?{}:{metadata:structuredClone(e.metadata)},archived:e.archived===!0,pending:`clientPendingStart`in e&&e.clientPendingStart===!0}}function f(e){let t=e.selectedSession,n=e.selectedMachine,r=e.selectedProject,i=e.selectedWorkspace;return{...n===void 0?{}:{selectedMachine:{id:n.id,name:n.name,kind:n.kind}},...r===void 0?{}:{selectedProject:{id:r.id,name:r.name,path:r.path}},...i===void 0?{}:{selectedWorkspace:{id:i.id,projectId:i.projectId,path:i.path,label:i.label,isMain:i.isMain,...i.branch===void 0?{}:{branch:i.branch},...i.isGitRepo===void 0?{}:{isGitRepo:i.isGitRepo},...i.isGitWorktree===void 0?{}:{isGitWorktree:i.isGitWorktree},...i.provider===void 0?{}:{provider:structuredClone(i.provider)},...i.removal===void 0?{}:{removal:{actionLabel:i.removal.actionLabel,confirmation:i.removal.confirmation}}}},...t===void 0?{}:{selectedSession:d(t)}}}function p(e){return{...f(e),...e.workspaceTool===void 0?{}:{workspaceTool:e.workspaceTool},mainView:e.mainView===`navigation`||e.mainView===`chat`?e.mainView:`workspace`,...e.piWebStatus===void 0?{}:{piWebStatus:e.piWebStatus}}}function m(e){return{...e,state:p(e.state)}}function h(e){return{...e,async activate(t){let n=await e.activate(t),{actions:r,applicationPanels:i,workspacePanels:a,workspaceLabels:o,sessionLabels:s}=n.contributions;return{...n,...n.start===void 0?{}:{start:n.start.bind(n)},...n.dispose===void 0?{}:{dispose:n.dispose.bind(n)},contributions:{...n.contributions,...r===void 0?{}:{actions:r.map(e=>{let{enabled:t,disabledReason:n,run:r}=e;return u(e,{...e,...t===void 0?{}:{enabled:e=>t(m(e))},...n===void 0?{}:{disabledReason:e=>n(m(e))},run:e=>r(m(e))})})},...i===void 0?{}:{applicationPanels:i.map(e=>{let{visible:t,badge:n,onInvalidate:r,render:i}=e;return u(e,{...e,...t===void 0?{}:{visible:e=>t(m(e))},...n===void 0?{}:{badge:e=>n(m(e))},...r===void 0?{}:{onInvalidate:e=>r(m(e))},render:e=>i(m(e))})})},...a===void 0?{}:{workspacePanels:a.map(e=>{let{visible:t,fileOpenQuery:n,badge:r,onInvalidate:i,render:a}=e;return u(e,{...e,...t===void 0?{}:{visible:e=>t(m(e))},...n===void 0?{}:{fileOpenQuery:(e,t)=>n(m(e),t)},...r===void 0?{}:{badge:e=>r(m(e))},...i===void 0?{}:{onInvalidate:(e,t)=>i(m(e),t)},render:e=>a(m(e))})})},...o===void 0?{}:{workspaceLabels:o.map(({visible:e,items:t,...n})=>({...n,...e===void 0?{}:{visible:t=>e(m(t))},items:e=>t(m(e))}))},...s===void 0?{}:{sessionLabels:s.map(({visible:e,items:t,...n})=>({...n,...e===void 0?{}:{visible:t=>e(m(t))},items:e=>t(m(e))}))}}}}}}function g(e,t,n,r){let i=new Set,o=new Set,c=()=>{r.throwIfAborted()},l=e=>{let t=()=>{i.delete(t)&&e()};return i.add(t),t};r.addEventListener(`abort`,()=>{for(let e of i)e()},{once:!0});let u={message:a,get preferences(){return e.preferences},get language(){return e.language},get direction(){return e.direction},get ready(){return e.ready},registerMessages(n,r){if(c(),!/^[a-z][a-z0-9.-]*$/u.test(n)||o.has(n))throw Error(`Duplicate or invalid plugin message namespace: ${n}`);let i=e.acquireMessages(`plugin:${t}:${n}`,r);return o.add(n),l(()=>{i.release()}),i.messages},registerCatalog(t){if(c(),!t.id)throw Error(`A plugin catalog ID is required`);return l(e.registerCatalog({...t,id:JSON.stringify([n,t.id])}))},subscribe(t){if(r.aborted)return()=>void 0;let i=e=>{console.warn(`PI WEB plugin ${n} localization subscriber failed`,e)};return l(e.subscribe(()=>{if(!r.aborted)try{let e=t();e!==void 0&&Promise.resolve(e).catch(i)}catch(e){i(e)}}))},controller:e=>new s(e,u),number:(t,n)=>e.number(t,n),date:(t,n)=>e.date(t,n),time:(t,n)=>e.time(t,n),relativeTime:(t,n,r)=>e.relativeTime(t,n,r),list:(t,n)=>e.list(t,n)};return Object.freeze(u)}var _=`machine.`;function v(e,t){if(x(e,t),c(t))throw Error(`Reserved PI WEB plugin id: ${t}`);return S(e,t)}function y(e,t){if(x(e,t),!o(t))throw Error(`PI WEB bundled plugin id is required: ${t}`);return S(e,t)}function b(e,t){return o(t)?y(e,t):v(e,t)}function x(e,t){if(e===``)throw Error(`Machine id is required`);if(!i(t))throw Error(`Invalid PI WEB plugin id: ${t}`)}function S(e,t){return`${_}${C(e)}.${t}`}function C(e){return[...new TextEncoder().encode(e)].map(e=>e.toString(16).padStart(2,`0`)).join(``)}async function w(t=`pi-web-plugins/manifest.json`,r={}){let i=n(e(t)),a=await O(i,r.manifest),o=[],s=[],c=[],l=a.plugins.filter(e=>r.shouldLoadPlugin?.(e)!==!1).sort((e,t)=>Number(t.scope===`bundled`)-Number(e.scope===`bundled`)),u=r.moduleLoader??E,d=new Map,f=e=>{let t=d.get(e);if(t!==void 0)return t;let n=(async()=>{let t=T(e.module,i);return L(await D(t,u),t)})();return n.catch(()=>void 0),d.set(e,n),n},p=a.terminalMode===`required`&&l[0]?.id===`pi-web.terminal`;p||l.forEach(e=>{f(e)});for(let[e,t]of l.entries()){let n=I(t,r.machineId);o.push(n);try{let r=await f(t);p&&e===0&&l.slice(1).forEach(e=>{f(e)}),s.push({...n,plugin:r,...t.backendRevision===void 0?{}:{backendRevision:t.backendRevision},...t.pairedRequestVersion===void 0?{}:{pairedRequestVersion:t.pairedRequestVersion},...t.pairedChannelVersion===void 0?{}:{pairedChannelVersion:t.pairedChannelVersion},...t.pairedResourceVersion===void 0?{}:{pairedResourceVersion:t.pairedResourceVersion}})}catch(e){if(c.push({entry:t,error:e}),a.terminalMode===`required`&&t.id===`pi-web.terminal`)return{terminalMode:a.terminalMode,declarations:o,registrations:[],failures:c}}}return{terminalMode:a.terminalMode,declarations:o,registrations:s,failures:c}}function T(e,t,r){return e.startsWith(`/`)?r===void 0?n(e):n(e,r):new URL(e,t).toString()}async function E(e){return import(e)}async function D(e,t){let n,r=new Promise((t,r)=>{n=setTimeout(()=>{r(Error(`Browser plugin import timed out after 10000ms: ${e}`))},1e4)});try{return await Promise.race([Promise.resolve().then(()=>t(e)),r])}finally{clearTimeout(n)}}async function O(e,t){if(t!==void 0)return k(t);let n=await fetch(e,{cache:`no-store`});if(!n.ok)throw Error(await M(n));return k(await n.json())}function k(e){if(!z(e)||!Array.isArray(e.plugins))throw Error(`Invalid plugin manifest`);if(e.lifecycleVersion!==2)throw Error(`Unsupported plugin manifest lifecycle version`);let n=j(e.terminalMode),r=e.plugins.map(e=>{if(!z(e)||typeof e.id!=`string`||typeof e.module!=`string`||e.module===``)throw Error(`Invalid plugin manifest entry`);let t=e.id;if(!i(t))throw Error(`Invalid plugin manifest id: ${t}`);let n=A(e.source),r=A(e.scope);if(c(t)&&!(o(t)&&n===`bundled`&&r===`bundled`))throw Error(`Reserved plugin manifest id: ${t}`);let a=N(e.backendRevision),s=P(e.pairedRequestVersion),l=P(e.pairedChannelVersion),u=P(e.pairedResourceVersion);if((s!==void 0||l!==void 0||u!==void 0)&&a===void 0)throw Error(`Invalid plugin manifest entry`);return{id:t,module:e.module,...a===void 0?{}:{backendRevision:a},...s===void 0?{}:{pairedRequestVersion:s},...l===void 0?{}:{pairedChannelVersion:l},...u===void 0?{}:{pairedResourceVersion:u},...n===void 0?{}:{source:n},...r===void 0?{}:{scope:r},machineSpecific:F(e.machineSpecific)}}),a=new Set;for(let e of r){if(a.has(e.id))throw Error(`Duplicate plugin manifest id: ${e.id}`);a.add(e.id)}let s=r.find(({id:e})=>e===l);if(n===`required`&&!t()){if(s===void 0||r[0]!==s||!s.machineSpecific)throw Error(`Required Terminal plugin manifest entry is unavailable or out of order`);if(s.backendRevision===void 0||s.pairedRequestVersion!==1||s.pairedChannelVersion!==1)throw Error(`Required Terminal plugin manifest entry is incompatible`)}else if(n===`recovery-disabled`&&s!==void 0)throw Error(`Recovery-disabled plugin manifest must not publish Terminal`);return{terminalMode:n,plugins:r}}function A(e){return typeof e==`string`?e:void 0}function j(e){if(e===`required`||e===`recovery-disabled`)return e;throw Error(`Invalid plugin manifest Terminal mode`)}async function M(e){let t;try{let n=await e.json();if(z(n)){let e=n.error,r=n.detail,i=n.message;t=typeof r==`string`?`${typeof e==`string`?`${e}: `:``}${r}`:typeof i==`string`?i:typeof e==`string`?e:void 0}}catch{}return`Failed to load plugin manifest (${`${String(e.status)}${e.statusText===``?``:` ${e.statusText}`}`})${t===void 0?``:`: ${t}`}`}function N(e){if(e!==void 0)try{return r(e)}catch{throw Error(`Invalid plugin manifest entry`)}}function P(e){if(e!==void 0){if(e!==1)throw Error(`Invalid plugin manifest entry`);return e}}function F(e){if(e===void 0)return!1;if(typeof e!=`boolean`)throw Error(`Invalid plugin manifest entry`);return e}function I(e,t){return Object.freeze({id:t===void 0?e.id:b(t,e.id),machineSpecific:e.machineSpecific,...e.source===void 0?{}:{manifestSource:e.source},...e.scope===void 0?{}:{manifestScope:e.scope},...t===void 0?{}:{machineId:t,sourcePluginId:e.id}})}function L(e,t){if(!z(e))throw Error(`Plugin module ${t} did not export an object`);let n=e.default;if(z(n)&&n.apiVersion!==4&&n.apiVersion!==5)throw Error(`Unsupported browser plugin API version for ${t}: ${String(n.apiVersion)} (expected 4 or 5)`);if(!R(n))throw Error(`Plugin module ${t} default export is not a PiWebPlugin`);return h(n)}function R(e){return z(e)&&(e.apiVersion===4||e.apiVersion===5)&&typeof e.name==`string`&&typeof e.activate==`function`}function z(e){return typeof e==`object`&&!!e}export{d as a,f as i,y as n,u as o,g as r,w as t};
1
+ import{_ as e,g as t,p as n}from"./themePreference-BBiJxLjs.js";import{a as r,at as i,ht as a,ot as o,st as s,t as c,xt as l}from"./requiredTerminalPlugin-M436A3oj.js";function u(e,t){for(let n of[`title`,`name`,`description`,`group`,`label`,`disabledReason`]){let r=Object.getOwnPropertyDescriptor(e,n);r?.get!==void 0&&Object.defineProperty(t,n,{enumerable:!0,configurable:!0,get:r.get.bind(e)})}return t}function d(e){return{id:e.id,cwd:e.cwd,...e.name===void 0?{}:{name:e.name},...e.metadata===void 0?{}:{metadata:structuredClone(e.metadata)},archived:e.archived===!0,pending:`clientPendingStart`in e&&e.clientPendingStart===!0}}function f(e){let t=e.selectedSession,n=e.selectedMachine,r=e.selectedProject,i=e.selectedWorkspace;return{...n===void 0?{}:{selectedMachine:{id:n.id,name:n.name,kind:n.kind}},...r===void 0?{}:{selectedProject:{id:r.id,name:r.name,path:r.path}},...i===void 0?{}:{selectedWorkspace:{id:i.id,projectId:i.projectId,path:i.path,label:i.label,isMain:i.isMain,...i.branch===void 0?{}:{branch:i.branch},...i.isGitRepo===void 0?{}:{isGitRepo:i.isGitRepo},...i.isGitWorktree===void 0?{}:{isGitWorktree:i.isGitWorktree},...i.provider===void 0?{}:{provider:structuredClone(i.provider)},...i.removal===void 0?{}:{removal:{actionLabel:i.removal.actionLabel,confirmation:i.removal.confirmation}}}},...t===void 0?{}:{selectedSession:d(t)}}}function p(e){return{...f(e),...e.workspaceTool===void 0?{}:{workspaceTool:e.workspaceTool},mainView:e.mainView===`navigation`||e.mainView===`chat`?e.mainView:`workspace`,...e.piWebStatus===void 0?{}:{piWebStatus:e.piWebStatus}}}function m(e){return{...e,state:p(e.state)}}function h(e){return{...e,async activate(t){let n=await e.activate(t),{actions:r,applicationPanels:i,workspacePanels:a,workspaceLabels:o,sessionLabels:s}=n.contributions;return{...n,...n.start===void 0?{}:{start:n.start.bind(n)},...n.dispose===void 0?{}:{dispose:n.dispose.bind(n)},contributions:{...n.contributions,...r===void 0?{}:{actions:r.map(e=>{let{enabled:t,disabledReason:n,run:r}=e;return u(e,{...e,...t===void 0?{}:{enabled:e=>t(m(e))},...n===void 0?{}:{disabledReason:e=>n(m(e))},run:e=>r(m(e))})})},...i===void 0?{}:{applicationPanels:i.map(e=>{let{visible:t,badge:n,onInvalidate:r,render:i}=e;return u(e,{...e,...t===void 0?{}:{visible:e=>t(m(e))},...n===void 0?{}:{badge:e=>n(m(e))},...r===void 0?{}:{onInvalidate:e=>r(m(e))},render:e=>i(m(e))})})},...a===void 0?{}:{workspacePanels:a.map(e=>{let{visible:t,fileOpenQuery:n,badge:r,onInvalidate:i,render:a}=e;return u(e,{...e,...t===void 0?{}:{visible:e=>t(m(e))},...n===void 0?{}:{fileOpenQuery:(e,t)=>n(m(e),t)},...r===void 0?{}:{badge:e=>r(m(e))},...i===void 0?{}:{onInvalidate:(e,t)=>i(m(e),t)},render:e=>a(m(e))})})},...o===void 0?{}:{workspaceLabels:o.map(({visible:e,items:t,...n})=>({...n,...e===void 0?{}:{visible:t=>e(m(t))},items:e=>t(m(e))}))},...s===void 0?{}:{sessionLabels:s.map(({visible:e,items:t,...n})=>({...n,...e===void 0?{}:{visible:t=>e(m(t))},items:e=>t(m(e))}))}}}}}}function g(e,t,n,r){let i=new Set,o=new Set,s=()=>{r.throwIfAborted()},c=e=>{let t=()=>{i.delete(t)&&e()};return i.add(t),t};r.addEventListener(`abort`,()=>{for(let e of i)e()},{once:!0});let u={message:l,get preferences(){return e.preferences},get language(){return e.language},get direction(){return e.direction},get ready(){return e.ready},registerMessages(n,r){if(s(),!/^[a-z][a-z0-9.-]*$/u.test(n)||o.has(n))throw Error(`Duplicate or invalid plugin message namespace: ${n}`);let i=e.acquireMessages(`plugin:${t}:${n}`,r);return o.add(n),c(()=>{i.release()}),i.messages},registerCatalog(t){if(s(),!t.id)throw Error(`A plugin catalog ID is required`);return c(e.registerCatalog({...t,id:JSON.stringify([n,t.id])}))},subscribe(t){if(r.aborted)return()=>void 0;let i=e=>{console.warn(`PI WEB plugin ${n} localization subscriber failed`,e)};return c(e.subscribe(()=>{if(!r.aborted)try{let e=t();e!==void 0&&Promise.resolve(e).catch(i)}catch(e){i(e)}}))},controller:e=>new a(e,u),number:(t,n)=>e.number(t,n),date:(t,n)=>e.date(t,n),time:(t,n)=>e.time(t,n),relativeTime:(t,n,r)=>e.relativeTime(t,n,r),list:(t,n)=>e.list(t,n)};return Object.freeze(u)}var _=`machine.`;function v(e,t){if(x(e,t),s(t))throw Error(`Reserved PI WEB plugin id: ${t}`);return S(e,t)}function y(e,t){if(x(e,t),!i(t))throw Error(`PI WEB bundled plugin id is required: ${t}`);return S(e,t)}function b(e,t){return i(t)?y(e,t):v(e,t)}function x(e,t){if(e===``)throw Error(`Machine id is required`);if(!o(t))throw Error(`Invalid PI WEB plugin id: ${t}`)}function S(e,t){return`${_}${C(e)}.${t}`}function C(e){return[...new TextEncoder().encode(e)].map(e=>e.toString(16).padStart(2,`0`)).join(``)}async function w(t=`pi-web-plugins/manifest.json`,r={}){let i=n(e(t)),a=await O(i,r.manifest),o=[],s=[],c=[],l=a.plugins.filter(e=>r.shouldLoadPlugin?.(e)!==!1).sort((e,t)=>Number(t.scope===`bundled`)-Number(e.scope===`bundled`)),u=r.moduleLoader??E,d=new Map,f=e=>{let t=d.get(e);if(t!==void 0)return t;let n=(async()=>{let t=T(e.module,i);return L(await D(t,u),t)})();return n.catch(()=>void 0),d.set(e,n),n},p=a.terminalMode===`required`&&l[0]?.id===`pi-web.terminal`;p||l.forEach(e=>{f(e)});for(let[e,t]of l.entries()){let n=I(t,r.machineId);o.push(n);try{let r=await f(t);p&&e===0&&l.slice(1).forEach(e=>{f(e)}),s.push({...n,plugin:r,...t.backendRevision===void 0?{}:{backendRevision:t.backendRevision},...t.pairedRequestVersion===void 0?{}:{pairedRequestVersion:t.pairedRequestVersion},...t.pairedChannelVersion===void 0?{}:{pairedChannelVersion:t.pairedChannelVersion},...t.pairedResourceVersion===void 0?{}:{pairedResourceVersion:t.pairedResourceVersion}})}catch(e){if(c.push({entry:t,error:e}),a.terminalMode===`required`&&t.id===`pi-web.terminal`)return{terminalMode:a.terminalMode,declarations:o,registrations:[],failures:c}}}return{terminalMode:a.terminalMode,declarations:o,registrations:s,failures:c}}function T(e,t,r){return e.startsWith(`/`)?r===void 0?n(e):n(e,r):new URL(e,t).toString()}async function E(e){return import(e)}async function D(e,t){let n,r=new Promise((t,r)=>{n=setTimeout(()=>{r(Error(`Browser plugin import timed out after 10000ms: ${e}`))},1e4)});try{return await Promise.race([Promise.resolve().then(()=>t(e)),r])}finally{clearTimeout(n)}}async function O(e,t){if(t!==void 0)return k(t);let n=await fetch(e,{cache:`no-store`});if(!n.ok)throw Error(await M(n));return k(await n.json())}function k(e){if(!z(e)||!Array.isArray(e.plugins))throw Error(`Invalid plugin manifest`);if(e.lifecycleVersion!==2)throw Error(`Unsupported plugin manifest lifecycle version`);let n=j(e.terminalMode),r=e.plugins.map(e=>{if(!z(e)||typeof e.id!=`string`||typeof e.module!=`string`||e.module===``)throw Error(`Invalid plugin manifest entry`);let t=e.id;if(!o(t))throw Error(`Invalid plugin manifest id: ${t}`);let n=A(e.source),r=A(e.scope);if(s(t)&&!(i(t)&&n===`bundled`&&r===`bundled`))throw Error(`Reserved plugin manifest id: ${t}`);let a=N(e.backendRevision),c=P(e.pairedRequestVersion),l=P(e.pairedChannelVersion),u=P(e.pairedResourceVersion);if((c!==void 0||l!==void 0||u!==void 0)&&a===void 0)throw Error(`Invalid plugin manifest entry`);return{id:t,module:e.module,...a===void 0?{}:{backendRevision:a},...c===void 0?{}:{pairedRequestVersion:c},...l===void 0?{}:{pairedChannelVersion:l},...u===void 0?{}:{pairedResourceVersion:u},...n===void 0?{}:{source:n},...r===void 0?{}:{scope:r},machineSpecific:F(e.machineSpecific)}}),a=new Set;for(let e of r){if(a.has(e.id))throw Error(`Duplicate plugin manifest id: ${e.id}`);a.add(e.id)}let l=r.find(({id:e})=>e===c);if(n===`required`&&!t()){if(l===void 0||r[0]!==l||!l.machineSpecific)throw Error(`Required Terminal plugin manifest entry is unavailable or out of order`);if(l.backendRevision===void 0||l.pairedRequestVersion!==1||l.pairedChannelVersion!==1)throw Error(`Required Terminal plugin manifest entry is incompatible`)}else if(n===`recovery-disabled`&&l!==void 0)throw Error(`Recovery-disabled plugin manifest must not publish Terminal`);return{terminalMode:n,plugins:r}}function A(e){return typeof e==`string`?e:void 0}function j(e){if(e===`required`||e===`recovery-disabled`)return e;throw Error(`Invalid plugin manifest Terminal mode`)}async function M(e){let t;try{let n=await e.json();if(z(n)){let e=n.error,r=n.detail,i=n.message;t=typeof r==`string`?`${typeof e==`string`?`${e}: `:``}${r}`:typeof i==`string`?i:typeof e==`string`?e:void 0}}catch{}return`Failed to load plugin manifest (${`${String(e.status)}${e.statusText===``?``:` ${e.statusText}`}`})${t===void 0?``:`: ${t}`}`}function N(e){if(e!==void 0)try{return r(e)}catch{throw Error(`Invalid plugin manifest entry`)}}function P(e){if(e!==void 0){if(e!==1)throw Error(`Invalid plugin manifest entry`);return e}}function F(e){if(e===void 0)return!1;if(typeof e!=`boolean`)throw Error(`Invalid plugin manifest entry`);return e}function I(e,t){return Object.freeze({id:t===void 0?e.id:b(t,e.id),machineSpecific:e.machineSpecific,...e.source===void 0?{}:{manifestSource:e.source},...e.scope===void 0?{}:{manifestScope:e.scope},...t===void 0?{}:{machineId:t,sourcePluginId:e.id}})}function L(e,t){if(!z(e))throw Error(`Plugin module ${t} did not export an object`);let n=e.default;if(z(n)&&n.apiVersion!==4&&n.apiVersion!==5)throw Error(`Unsupported browser plugin API version for ${t}: ${String(n.apiVersion)} (expected 4 or 5)`);if(!R(n))throw Error(`Plugin module ${t} default export is not a PiWebPlugin`);return h(n)}function R(e){return z(e)&&(e.apiVersion===4||e.apiVersion===5)&&typeof e.name==`string`&&typeof e.activate==`function`}function z(e){return typeof e==`object`&&!!e}export{d as a,f as i,y as n,u as o,g as r,w as t};
@@ -1,2 +1,2 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./main-T8PgowZ_.js","./themePreference-BBiJxLjs.js","./preload-helper-CRzLMJPS.js","./requiredTerminalPlugin-DrXvpLs1.js","./lit-CJ6w1GHF.js","./external-DZQ-GM9O.js"])))=>i.map(i=>d[i]);
2
- import{t as e}from"./preload-helper-CRzLMJPS.js";import{a as t,t as n}from"./themeStartup-0b02tNrh.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})(),n(),e(()=>import(`./main-T8PgowZ_.js`),__vite__mapDeps([0,1,2,3,4,5]),import.meta.url).catch(e=>{console.error(`PI WEB startup failed`,e),t()});
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./main-BrnfeRme.js","./themePreference-BBiJxLjs.js","./preload-helper-CRzLMJPS.js","./requiredTerminalPlugin-M436A3oj.js","./lit-CJ6w1GHF.js","./external-Bxk-hFko.js"])))=>i.map(i=>d[i]);
2
+ import{t as e}from"./preload-helper-CRzLMJPS.js";import{a as t,t as n}from"./themeStartup-0b02tNrh.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})(),n(),e(()=>import(`./main-BrnfeRme.js`),__vite__mapDeps([0,1,2,3,4,5]),import.meta.url).catch(e=>{console.error(`PI WEB startup failed`,e),t()});
@@ -1,2 +1,2 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./PiWebApp-rG0WhMEa.js","./styles-BwN5rgmt.js","./styleSources-CdF2T_pj.js","./lit-CJ6w1GHF.js","./themePreference-BBiJxLjs.js","./themeCatalog-B3yda95n.js","./preload-helper-CRzLMJPS.js","./themeStartup-0b02tNrh.js","./composerShortcuts-BggqvE9J.js","./requiredTerminalPlugin-DrXvpLs1.js","./external-DZQ-GM9O.js","./vendor-editor-core-BfnHL1Dg.js","./vendor-editor-languages-bNquDJP0.js"])))=>i.map(i=>d[i]);
2
- import{p as e}from"./themePreference-BBiJxLjs.js";import{t}from"./preload-helper-CRzLMJPS.js";import{_t as n,dt as r,ft as i,m as a,pt as o,vt as s,yt as c}from"./requiredTerminalPlugin-DrXvpLs1.js";import{c as l,o as u}from"./lit-CJ6w1GHF.js";import{r as d,t as f}from"./external-DZQ-GM9O.js";var p,m;async function h(e=async()=>(await f(`pi-web-plugins/localization.json`,{shouldLoadPlugin:e=>e.id===`zh-cn`})).registrations){p?.abort(),m?.(),m=void 0,i(`en`,{});try{let t=(await e()).find(e=>e.id===`zh-cn`&&e.machineId===void 0);if(t!==void 0){let e=new AbortController;p=e;let n=(await t.plugin.activate({apiVersion:5,pluginId:t.id,runtimePluginId:t.id,html:u,svg:l,translate:o,localization:d(s,t.id,t.id,e.signal),signal:e.signal,lifetimeSignal:e.signal})).contributions.localizations?.find(e=>e.locale===`zh-CN`);n!==void 0&&(i(n.locale,n.messages),m=s.subscribe(()=>{let e=s.language.toLowerCase().startsWith(`zh`)?n.locale:`en`;r()!==e&&(i(e,e===n.locale?n.messages:{}),typeof document<`u`&&(g(document),document.documentElement.lang=s.language))}))}}catch(e){console.warn(`Could not initialize UI localization; using English`,e)}}function g(t){t.documentElement.lang=r();let n=t.querySelector(`meta[name="description"]`);n!==null&&(n.content=o(`app.description`,`Remote web UI and browser control plane for persistent Pi Coding Agent sessions.`));let i=t.querySelector(`link[rel="manifest"]`);i!==null&&(i.href=e(r()===`zh-CN`?`pi-web-plugins/zh-cn/manifest.webmanifest`:`manifest.webmanifest`))}await h();var _=r();g(document),await t(()=>import(`./PiWebApp-rG0WhMEa.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12]),import.meta.url);var v=a.config().catch(e=>{console.warn(`[i18n] Could not load gateway localization defaults; using browser preferences`,e)});n(void 0,window,void 0,v.then(e=>({language:_,...e?.effectiveConfig.defaultLocalization})),v.then(e=>e===void 0?{}:c(e))).catch(e=>{console.error(`[i18n] Localization startup failed`,e)});
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./PiWebApp-NXSXyci_.js","./styles-BwN5rgmt.js","./styleSources-CdF2T_pj.js","./lit-CJ6w1GHF.js","./themePreference-BBiJxLjs.js","./themeCatalog-B3yda95n.js","./preload-helper-CRzLMJPS.js","./themeStartup-0b02tNrh.js","./composerShortcuts-BggqvE9J.js","./requiredTerminalPlugin-M436A3oj.js","./external-Bxk-hFko.js","./vendor-editor-core-BfnHL1Dg.js","./vendor-editor-languages-bNquDJP0.js"])))=>i.map(i=>d[i]);
2
+ import{p as e}from"./themePreference-BBiJxLjs.js";import{t}from"./preload-helper-CRzLMJPS.js";import{bt as n,ft as r,h as i,mt as a,pt as o,vt as s,yt as c}from"./requiredTerminalPlugin-M436A3oj.js";import{c as l,o as u}from"./lit-CJ6w1GHF.js";import{r as d,t as f}from"./external-Bxk-hFko.js";var p,m;async function h(e=async()=>(await f(`pi-web-plugins/localization.json`,{shouldLoadPlugin:e=>e.id===`zh-cn`})).registrations){p?.abort(),m?.(),m=void 0,o(`en`,{});try{let t=(await e()).find(e=>e.id===`zh-cn`&&e.machineId===void 0);if(t!==void 0){let e=new AbortController;p=e;let n=(await t.plugin.activate({apiVersion:5,pluginId:t.id,runtimePluginId:t.id,html:u,svg:l,translate:a,localization:d(c,t.id,t.id,e.signal),signal:e.signal,lifetimeSignal:e.signal})).contributions.localizations?.find(e=>e.locale===`zh-CN`);n!==void 0&&(o(n.locale,n.messages),m=c.subscribe(()=>{let e=c.language.toLowerCase().startsWith(`zh`)?n.locale:`en`;r()!==e&&(o(e,e===n.locale?n.messages:{}),typeof document<`u`&&(g(document),document.documentElement.lang=c.language))}))}}catch(e){console.warn(`Could not initialize UI localization; using English`,e)}}function g(t){t.documentElement.lang=r();let n=t.querySelector(`meta[name="description"]`);n!==null&&(n.content=a(`app.description`,`Remote web UI and browser control plane for persistent Pi Coding Agent sessions.`));let i=t.querySelector(`link[rel="manifest"]`);i!==null&&(i.href=e(r()===`zh-CN`?`pi-web-plugins/zh-cn/manifest.webmanifest`:`manifest.webmanifest`))}await h();var _=r();g(document),await t(()=>import(`./PiWebApp-NXSXyci_.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12]),import.meta.url);var v=i.config().catch(e=>{console.warn(`[i18n] Could not load gateway localization defaults; using browser preferences`,e)});s(void 0,window,void 0,v.then(e=>({language:_,...e?.effectiveConfig.defaultLocalization})),v.then(e=>e===void 0?{}:n(e))).catch(e=>{console.error(`[i18n] Localization startup failed`,e)});
@@ -0,0 +1,3 @@
1
+ import{_ as e,a as t,d as n,h as r,i,l as a,m as o,o as s,p as c,r as l,u,v as d}from"./themePreference-BBiJxLjs.js";var f=/(?:[Eec]{1,6}|G{1,5}|[Qq]{1,5}|(?:[yYur]+|U{1,5})|[ML]{1,5}|d{1,2}|D{1,3}|F{1}|[abB]{1,5}|[hkHK]{1,2}|w{1,2}|W{1}|m{1,2}|s{1,2}|[zZOvVxX]{1,4})(?=([^']*'[^']*')*[^']*$)/g;function ee(e){let t={};return e.replace(f,e=>{let n=e.length;switch(e[0]){case`G`:t.era=n===4?`long`:n===5?`narrow`:`short`;break;case`y`:t.year=n===2?`2-digit`:`numeric`;break;case`Y`:case`u`:case`U`:case`r`:throw RangeError("`Y/u/U/r` (year) patterns are not supported, use `y` instead");case`q`:case`Q`:throw RangeError("`q/Q` (quarter) patterns are not supported");case`M`:case`L`:t.month=[`numeric`,`2-digit`,`short`,`long`,`narrow`][n-1];break;case`w`:case`W`:throw RangeError("`w/W` (week) patterns are not supported");case`d`:t.day=[`numeric`,`2-digit`][n-1];break;case`D`:case`F`:case`g`:throw RangeError("`D/F/g` (day) patterns are not supported, use `d` instead");case`E`:t.weekday=n===4?`long`:n===5?`narrow`:`short`;break;case`e`:if(n<4)throw RangeError("`e..eee` (weekday) patterns are not supported");t.weekday=[`short`,`long`,`narrow`,`short`][n-3];break;case`c`:if(n<4)throw RangeError("`c..ccc` (weekday) patterns are not supported");t.weekday=[`short`,`long`,`narrow`,`short`][n-3];break;case`a`:t.hour12=!0;break;case`b`:case`B`:throw RangeError("`b/B` (period) patterns are not supported, use `a` instead");case`h`:t.hourCycle=`h12`,t.hour=[`numeric`,`2-digit`][n-1];break;case`H`:t.hourCycle=`h23`,t.hour=[`numeric`,`2-digit`][n-1];break;case`K`:t.hourCycle=`h11`,t.hour=[`numeric`,`2-digit`][n-1];break;case`k`:t.hourCycle=`h24`,t.hour=[`numeric`,`2-digit`][n-1];break;case`j`:case`J`:case`C`:throw RangeError("`j/J/C` (hour) patterns are not supported, use `h/H/K/k` instead");case`m`:t.minute=[`numeric`,`2-digit`][n-1];break;case`s`:t.second=[`numeric`,`2-digit`][n-1];break;case`S`:case`A`:throw RangeError("`S/A` (second) patterns are not supported, use `s` instead");case`z`:t.timeZoneName=n<4?`short`:`long`;break;case`Z`:case`O`:case`v`:case`V`:case`X`:case`x`:throw RangeError("`Z/O/v/V/X/x` (timeZone) patterns are not supported, use `z` instead")}return``}),t}var te=/[\t-\r \x85\u200E\u200F\u2028\u2029]/i;function ne(e){if(e.length===0)throw Error(`Number skeleton cannot be empty`);let t=e.split(te).filter(e=>e.length>0),n=[];for(let e of t){let t=e.split(`/`);if(t.length===0)throw Error(`Invalid number skeleton`);let[r,...i]=t;for(let e of i)if(e.length===0)throw Error(`Invalid number skeleton`);n.push({stem:r,options:i})}return n}function re(e){return e.replace(/^(.*?)-/,``)}var ie=/^\.(?:(0+)(\*)?|(#+)|(0+)(#+))$/g,ae=/^(@+)?(\+|#+)?[rs]?$/g,oe=/(\*)(0+)|(#+)(0+)|(0+)/g,se=/^(0+)$/;function ce(e){let t={};return e[e.length-1]===`r`?t.roundingPriority=`morePrecision`:e[e.length-1]===`s`&&(t.roundingPriority=`lessPrecision`),e.replace(ae,function(e,n,r){return typeof r==`string`?r===`+`?t.minimumSignificantDigits=n.length:n[0]===`#`?t.maximumSignificantDigits=n.length:(t.minimumSignificantDigits=n.length,t.maximumSignificantDigits=n.length+(typeof r==`string`?r.length:0)):(t.minimumSignificantDigits=n.length,t.maximumSignificantDigits=n.length),``}),t}function le(e){switch(e){case`sign-auto`:return{signDisplay:`auto`};case`sign-accounting`:case`()`:return{currencySign:`accounting`};case`sign-always`:case`+!`:return{signDisplay:`always`};case`sign-accounting-always`:case`()!`:return{signDisplay:`always`,currencySign:`accounting`};case`sign-except-zero`:case`+?`:return{signDisplay:`exceptZero`};case`sign-accounting-except-zero`:case`()?`:return{signDisplay:`exceptZero`,currencySign:`accounting`};case`sign-never`:case`+_`:return{signDisplay:`never`}}}function ue(e){let t;if(e[0]===`E`&&e[1]===`E`?(t={notation:`engineering`},e=e.slice(2)):e[0]===`E`&&(t={notation:`scientific`},e=e.slice(1)),t){let n=e.slice(0,2);if(n===`+!`?(t.signDisplay=`always`,e=e.slice(2)):n===`+?`&&(t.signDisplay=`exceptZero`,e=e.slice(2)),!se.test(e))throw Error(`Malformed concise eng/scientific notation`);t.minimumIntegerDigits=e.length}return t}function de(e){return le(e)||{}}function fe(e){let t={};for(let n of e){switch(n.stem){case`percent`:case`%`:t.style=`percent`;continue;case`%x100`:t.style=`percent`,t.scale=100;continue;case`currency`:t.style=`currency`,t.currency=n.options[0];continue;case`group-off`:case`,_`:t.useGrouping=!1;continue;case`precision-integer`:case`.`:t.maximumFractionDigits=0;continue;case`measure-unit`:case`unit`:t.style=`unit`,t.unit=re(n.options[0]);continue;case`compact-short`:case`K`:t.notation=`compact`,t.compactDisplay=`short`;continue;case`compact-long`:case`KK`:t.notation=`compact`,t.compactDisplay=`long`;continue;case`scientific`:t={...t,notation:`scientific`,...n.options.reduce((e,t)=>({...e,...de(t)}),{})};continue;case`engineering`:t={...t,notation:`engineering`,...n.options.reduce((e,t)=>({...e,...de(t)}),{})};continue;case`notation-simple`:t.notation=`standard`;continue;case`unit-width-narrow`:t.currencyDisplay=`narrowSymbol`,t.unitDisplay=`narrow`;continue;case`unit-width-short`:t.currencyDisplay=`code`,t.unitDisplay=`short`;continue;case`unit-width-full-name`:t.currencyDisplay=`name`,t.unitDisplay=`long`;continue;case`unit-width-iso-code`:t.currencyDisplay=`symbol`;continue;case`scale`:t.scale=parseFloat(n.options[0]);continue;case`rounding-mode-floor`:t.roundingMode=`floor`;continue;case`rounding-mode-ceiling`:t.roundingMode=`ceil`;continue;case`rounding-mode-down`:t.roundingMode=`trunc`;continue;case`rounding-mode-up`:t.roundingMode=`expand`;continue;case`rounding-mode-half-even`:t.roundingMode=`halfEven`;continue;case`rounding-mode-half-down`:t.roundingMode=`halfTrunc`;continue;case`rounding-mode-half-up`:t.roundingMode=`halfExpand`;continue;case`integer-width`:if(n.options.length>1)throw RangeError(`integer-width stems only accept a single optional option`);n.options[0].replace(oe,function(e,n,r,i,a,o){if(n)t.minimumIntegerDigits=r.length;else if(i&&a)throw Error(`We currently do not support maximum integer digits`);else if(o)throw Error(`We currently do not support exact integer digits`);return``});continue}if(se.test(n.stem)){t.minimumIntegerDigits=n.stem.length;continue}if(ie.test(n.stem)){if(n.options.length>1)throw RangeError(`Fraction-precision stems only accept a single optional option`);n.stem.replace(ie,function(e,n,r,i,a,o){return r===`*`?t.minimumFractionDigits=n.length:i&&i[0]===`#`?t.maximumFractionDigits=i.length:a&&o?(t.minimumFractionDigits=a.length,t.maximumFractionDigits=a.length+o.length):(t.minimumFractionDigits=n.length,t.maximumFractionDigits=n.length),``});let e=n.options[0];e===`w`?t={...t,trailingZeroDisplay:`stripIfInteger`}:e&&(t={...t,...ce(e)});continue}if(ae.test(n.stem)){t={...t,...ce(n.stem)};continue}let e=le(n.stem);e&&(t={...t,...e});let r=ue(n.stem);r&&(t={...t,...r})}return t}var pe=function(e){return e[e.EXPECT_ARGUMENT_CLOSING_BRACE=1]=`EXPECT_ARGUMENT_CLOSING_BRACE`,e[e.EMPTY_ARGUMENT=2]=`EMPTY_ARGUMENT`,e[e.MALFORMED_ARGUMENT=3]=`MALFORMED_ARGUMENT`,e[e.EXPECT_ARGUMENT_TYPE=4]=`EXPECT_ARGUMENT_TYPE`,e[e.INVALID_ARGUMENT_TYPE=5]=`INVALID_ARGUMENT_TYPE`,e[e.EXPECT_ARGUMENT_STYLE=6]=`EXPECT_ARGUMENT_STYLE`,e[e.INVALID_NUMBER_SKELETON=7]=`INVALID_NUMBER_SKELETON`,e[e.INVALID_DATE_TIME_SKELETON=8]=`INVALID_DATE_TIME_SKELETON`,e[e.EXPECT_NUMBER_SKELETON=9]=`EXPECT_NUMBER_SKELETON`,e[e.EXPECT_DATE_TIME_SKELETON=10]=`EXPECT_DATE_TIME_SKELETON`,e[e.UNCLOSED_QUOTE_IN_ARGUMENT_STYLE=11]=`UNCLOSED_QUOTE_IN_ARGUMENT_STYLE`,e[e.EXPECT_SELECT_ARGUMENT_OPTIONS=12]=`EXPECT_SELECT_ARGUMENT_OPTIONS`,e[e.EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE=13]=`EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE`,e[e.INVALID_PLURAL_ARGUMENT_OFFSET_VALUE=14]=`INVALID_PLURAL_ARGUMENT_OFFSET_VALUE`,e[e.EXPECT_SELECT_ARGUMENT_SELECTOR=15]=`EXPECT_SELECT_ARGUMENT_SELECTOR`,e[e.EXPECT_PLURAL_ARGUMENT_SELECTOR=16]=`EXPECT_PLURAL_ARGUMENT_SELECTOR`,e[e.EXPECT_SELECT_ARGUMENT_SELECTOR_FRAGMENT=17]=`EXPECT_SELECT_ARGUMENT_SELECTOR_FRAGMENT`,e[e.EXPECT_PLURAL_ARGUMENT_SELECTOR_FRAGMENT=18]=`EXPECT_PLURAL_ARGUMENT_SELECTOR_FRAGMENT`,e[e.INVALID_PLURAL_ARGUMENT_SELECTOR=19]=`INVALID_PLURAL_ARGUMENT_SELECTOR`,e[e.DUPLICATE_PLURAL_ARGUMENT_SELECTOR=20]=`DUPLICATE_PLURAL_ARGUMENT_SELECTOR`,e[e.DUPLICATE_SELECT_ARGUMENT_SELECTOR=21]=`DUPLICATE_SELECT_ARGUMENT_SELECTOR`,e[e.MISSING_OTHER_CLAUSE=22]=`MISSING_OTHER_CLAUSE`,e[e.INVALID_TAG=23]=`INVALID_TAG`,e[e.INVALID_TAG_NAME=25]=`INVALID_TAG_NAME`,e[e.UNMATCHED_CLOSING_TAG=26]=`UNMATCHED_CLOSING_TAG`,e[e.UNCLOSED_TAG=27]=`UNCLOSED_TAG`,e}({}),p=function(e){return e[e.literal=0]=`literal`,e[e.argument=1]=`argument`,e[e.number=2]=`number`,e[e.date=3]=`date`,e[e.time=4]=`time`,e[e.select=5]=`select`,e[e.plural=6]=`plural`,e[e.pound=7]=`pound`,e[e.tag=8]=`tag`,e}({});function me(e){return e.type===0}function he(e){return e.type===1}function ge(e){return e.type===2}function _e(e){return e.type===3}function ve(e){return e.type===4}function ye(e){return e.type===5}function be(e){return e.type===6}function xe(e){return e.type===7}function Se(e){return e.type===8}function Ce(e){return!!(e&&typeof e==`object`&&e.type===0)}function we(e){return!!(e&&typeof e==`object`&&e.type===1)}var Te=/[ \xA0\u1680\u2000-\u200A\u202F\u205F\u3000]/,Ee=/([^\t-\r -\/:-@\[-\^`\{-~\x85\xA0-\xA7\xA9\xAB\xAC\xAE\xB0\xB1\xB6\xBB\xBF\xD7\xF7\u1680\u2000-\u200A\u2010-\u2029\u202F-\u203E\u2041-\u2053\u2055-\u205F\u2190-\u245F\u2500-\u2775\u2794-\u2BFF\u2E00-\u2E7F\u3000-\u3003\u3008-\u3020\u3030\uFD3E\uFD3F\uFE45\uFE46]*)/g,m={"001":[`H`,`h`],419:[`h`,`H`,`hB`,`hb`],AC:[`H`,`h`,`hb`,`hB`],AD:[`H`,`hB`],AE:[`h`,`hB`,`hb`,`H`],AF:[`H`,`hb`,`hB`,`h`],AG:[`h`,`hb`,`H`,`hB`],AI:[`H`,`h`,`hb`,`hB`],AL:[`h`,`H`,`hB`],AM:[`H`,`hB`],AO:[`H`,`hB`],AR:[`h`,`H`,`hB`,`hb`],AS:[`h`,`H`],AT:[`H`,`hB`],AU:[`h`,`hb`,`H`,`hB`],AW:[`H`,`hB`],AX:[`H`],AZ:[`H`,`hB`,`h`],BA:[`H`,`hB`,`h`],BB:[`h`,`hb`,`H`,`hB`],BD:[`h`,`hB`,`H`],BE:[`H`,`hB`],BF:[`H`,`hB`],BG:[`H`,`hB`,`h`],BH:[`h`,`hB`,`hb`,`H`],BI:[`H`,`h`],BJ:[`H`,`hB`],BL:[`H`,`hB`],BM:[`h`,`hb`,`H`,`hB`],BN:[`hb`,`hB`,`h`,`H`],BO:[`h`,`H`,`hB`,`hb`],BQ:[`H`],BR:[`H`,`hB`],BS:[`h`,`hb`,`H`,`hB`],BT:[`h`,`H`],BW:[`H`,`h`,`hb`,`hB`],BY:[`H`,`h`],BZ:[`H`,`h`,`hb`,`hB`],CA:[`h`,`hb`,`H`,`hB`],CC:[`H`,`h`,`hb`,`hB`],CD:[`hB`,`H`],CF:[`H`,`h`,`hB`],CG:[`H`,`hB`],CH:[`H`,`hB`,`h`],CI:[`H`,`hB`],CK:[`H`,`h`,`hb`,`hB`],CL:[`h`,`H`,`hB`,`hb`],CM:[`H`,`h`,`hB`],CN:[`H`,`hB`,`hb`,`h`],CO:[`h`,`H`,`hB`,`hb`],CP:[`H`],CR:[`h`,`H`,`hB`,`hb`],CU:[`h`,`H`,`hB`,`hb`],CV:[`H`,`hB`],CW:[`H`,`hB`],CX:[`H`,`h`,`hb`,`hB`],CY:[`h`,`H`,`hb`,`hB`],CZ:[`H`],DE:[`H`,`hB`],DG:[`H`,`h`,`hb`,`hB`],DJ:[`h`,`H`],DK:[`H`],DM:[`h`,`hb`,`H`,`hB`],DO:[`h`,`H`,`hB`,`hb`],DZ:[`h`,`hB`,`hb`,`H`],EA:[`H`,`h`,`hB`,`hb`],EC:[`h`,`H`,`hB`,`hb`],EE:[`H`,`hB`],EG:[`h`,`hB`,`hb`,`H`],EH:[`h`,`hB`,`hb`,`H`],ER:[`h`,`H`],ES:[`H`,`hB`,`h`,`hb`],ET:[`hB`,`hb`,`h`,`H`],FI:[`H`],FJ:[`h`,`hb`,`H`,`hB`],FK:[`H`,`h`,`hb`,`hB`],FM:[`h`,`hb`,`H`,`hB`],FO:[`H`,`h`],FR:[`H`,`hB`],GA:[`H`,`hB`],GB:[`H`,`h`,`hb`,`hB`],GD:[`h`,`hb`,`H`,`hB`],GE:[`H`,`hB`,`h`],GF:[`H`,`hB`],GG:[`H`,`h`,`hb`,`hB`],GH:[`h`,`H`],GI:[`H`,`h`,`hb`,`hB`],GL:[`H`,`h`],GM:[`h`,`hb`,`H`,`hB`],GN:[`H`,`hB`],GP:[`H`,`hB`],GQ:[`H`,`hB`,`h`,`hb`],GR:[`h`,`H`,`hb`,`hB`],GS:[`H`,`h`,`hb`,`hB`],GT:[`h`,`H`,`hB`,`hb`],GU:[`h`,`hb`,`H`,`hB`],GW:[`H`,`hB`],GY:[`h`,`hb`,`H`,`hB`],HK:[`h`,`hB`,`hb`,`H`],HN:[`h`,`H`,`hB`,`hb`],HR:[`H`,`hB`],HU:[`H`,`h`],IC:[`H`,`h`,`hB`,`hb`],ID:[`H`],IE:[`H`,`h`,`hb`,`hB`],IL:[`H`,`hB`],IM:[`H`,`h`,`hb`,`hB`],IN:[`h`,`H`],IO:[`H`,`h`,`hb`,`hB`],IQ:[`h`,`hB`,`hb`,`H`],IR:[`hB`,`H`],IS:[`H`],IT:[`H`,`hB`],JE:[`H`,`h`,`hb`,`hB`],JM:[`h`,`hb`,`H`,`hB`],JO:[`h`,`hB`,`hb`,`H`],JP:[`H`,`K`,`h`],KE:[`hB`,`hb`,`H`,`h`],KG:[`H`,`h`,`hB`,`hb`],KH:[`hB`,`h`,`H`,`hb`],KI:[`h`,`hb`,`H`,`hB`],KM:[`H`,`h`,`hB`,`hb`],KN:[`h`,`hb`,`H`,`hB`],KP:[`h`,`H`,`hB`,`hb`],KR:[`h`,`H`,`hB`,`hb`],KW:[`h`,`hB`,`hb`,`H`],KY:[`h`,`hb`,`H`,`hB`],KZ:[`H`,`hB`],LA:[`H`,`hb`,`hB`,`h`],LB:[`h`,`hB`,`hb`,`H`],LC:[`h`,`hb`,`H`,`hB`],LI:[`H`,`hB`,`h`],LK:[`H`,`h`,`hB`,`hb`],LR:[`h`,`hb`,`H`,`hB`],LS:[`h`,`H`],LT:[`H`,`h`,`hb`,`hB`],LU:[`H`,`h`,`hB`],LV:[`H`,`hB`,`hb`,`h`],LY:[`h`,`hB`,`hb`,`H`],MA:[`H`,`h`,`hB`,`hb`],MC:[`H`,`hB`],MD:[`H`,`hB`],ME:[`H`,`hB`,`h`],MF:[`H`,`hB`],MG:[`H`,`h`],MH:[`h`,`hb`,`H`,`hB`],MK:[`H`,`h`,`hb`,`hB`],ML:[`H`],MM:[`hB`,`hb`,`H`,`h`],MN:[`H`,`h`,`hb`,`hB`],MO:[`h`,`hB`,`hb`,`H`],MP:[`h`,`hb`,`H`,`hB`],MQ:[`H`,`hB`],MR:[`h`,`hB`,`hb`,`H`],MS:[`H`,`h`,`hb`,`hB`],MT:[`H`,`h`],MU:[`H`,`h`],MV:[`H`,`h`],MW:[`h`,`hb`,`H`,`hB`],MX:[`h`,`H`,`hB`,`hb`],MY:[`hb`,`hB`,`h`,`H`],MZ:[`H`,`hB`],NA:[`h`,`H`,`hB`,`hb`],NC:[`H`,`hB`],NE:[`H`],NF:[`H`,`h`,`hb`,`hB`],NG:[`H`,`h`,`hb`,`hB`],NI:[`h`,`H`,`hB`,`hb`],NL:[`H`,`hB`],NO:[`H`,`h`],NP:[`H`,`h`,`hB`],NR:[`H`,`h`,`hb`,`hB`],NU:[`H`,`h`,`hb`,`hB`],NZ:[`h`,`hb`,`H`,`hB`],OM:[`h`,`hB`,`hb`,`H`],PA:[`h`,`H`,`hB`,`hb`],PE:[`h`,`H`,`hB`,`hb`],PF:[`H`,`h`,`hB`],PG:[`h`,`H`],PH:[`h`,`hB`,`hb`,`H`],PK:[`h`,`hB`,`H`],PL:[`H`,`h`],PM:[`H`,`hB`],PN:[`H`,`h`,`hb`,`hB`],PR:[`h`,`H`,`hB`,`hb`],PS:[`h`,`hB`,`hb`,`H`],PT:[`H`,`hB`],PW:[`h`,`H`],PY:[`h`,`H`,`hB`,`hb`],QA:[`h`,`hB`,`hb`,`H`],RE:[`H`,`hB`],RO:[`H`,`hB`],RS:[`H`,`hB`,`h`],RU:[`H`],RW:[`H`,`h`],SA:[`h`,`hB`,`hb`,`H`],SB:[`h`,`hb`,`H`,`hB`],SC:[`H`,`h`,`hB`],SD:[`h`,`hB`,`hb`,`H`],SE:[`H`],SG:[`h`,`hb`,`H`,`hB`],SH:[`H`,`h`,`hb`,`hB`],SI:[`H`,`hB`],SJ:[`H`],SK:[`H`],SL:[`h`,`hb`,`H`,`hB`],SM:[`H`,`h`,`hB`],SN:[`H`,`h`,`hB`],SO:[`h`,`H`],SR:[`H`,`hB`],SS:[`h`,`hb`,`H`,`hB`],ST:[`H`,`hB`],SV:[`h`,`H`,`hB`,`hb`],SX:[`H`,`h`,`hb`,`hB`],SY:[`h`,`hB`,`hb`,`H`],SZ:[`h`,`hb`,`H`,`hB`],TA:[`H`,`h`,`hb`,`hB`],TC:[`h`,`hb`,`H`,`hB`],TD:[`h`,`H`,`hB`],TF:[`H`,`h`,`hB`],TG:[`H`,`hB`],TH:[`H`,`h`],TJ:[`H`,`h`],TL:[`H`,`hB`,`hb`,`h`],TM:[`H`,`h`],TN:[`h`,`hB`,`hb`,`H`],TO:[`h`,`H`],TR:[`H`,`hB`],TT:[`h`,`hb`,`H`,`hB`],TW:[`hB`,`hb`,`h`,`H`],TZ:[`hB`,`hb`,`H`,`h`],UA:[`H`,`hB`,`h`],UG:[`hB`,`hb`,`H`,`h`],UM:[`h`,`hb`,`H`,`hB`],US:[`h`,`hb`,`H`,`hB`],UY:[`h`,`H`,`hB`,`hb`],UZ:[`H`,`hB`,`h`],VA:[`H`,`h`,`hB`],VC:[`h`,`hb`,`H`,`hB`],VE:[`h`,`H`,`hB`,`hb`],VG:[`h`,`hb`,`H`,`hB`],VI:[`h`,`hb`,`H`,`hB`],VN:[`H`,`h`],VU:[`h`,`H`],WF:[`H`,`hB`],WS:[`h`,`H`],XK:[`H`,`hB`,`h`],YE:[`h`,`hB`,`hb`,`H`],YT:[`H`,`hB`],ZA:[`H`,`h`,`hb`,`hB`],ZM:[`h`,`hb`,`H`,`hB`],ZW:[`H`,`h`],"af-ZA":[`H`,`h`,`hB`,`hb`],"ar-001":[`h`,`hB`,`hb`,`H`],"ca-ES":[`H`,`h`,`hB`],"en-001":[`h`,`hb`,`H`,`hB`],"en-HK":[`h`,`hb`,`H`,`hB`],"en-IL":[`H`,`h`,`hb`,`hB`],"en-MY":[`h`,`hb`,`H`,`hB`],"es-BR":[`H`,`h`,`hB`,`hb`],"es-ES":[`H`,`h`,`hB`,`hb`],"es-GQ":[`H`,`h`,`hB`,`hb`],"fr-CA":[`H`,`h`,`hB`],"gl-ES":[`H`,`h`,`hB`],"gu-IN":[`hB`,`hb`,`h`,`H`],"hi-IN":[`hB`,`h`,`H`],"it-CH":[`H`,`h`,`hB`],"it-IT":[`H`,`h`,`hB`],"kn-IN":[`hB`,`h`,`H`],"ku-SY":[`H`,`hB`],"ml-IN":[`hB`,`h`,`H`],"mr-IN":[`hB`,`hb`,`h`,`H`],"pa-IN":[`hB`,`hb`,`h`,`H`],"ta-IN":[`hB`,`h`,`hb`,`H`],"te-IN":[`hB`,`h`,`H`],"zu-ZA":[`H`,`hB`,`hb`,`h`]};function De(e,t){let n=``;for(let r=0;r<e.length;r++){let i=e.charAt(r);if(i===`j`){let a=0;for(;r+1<e.length&&e.charAt(r+1)===i;)a++,r++;let o=1+(a&1),s=a<2?1:3+(a>>1),c=Oe(t);for((c==`H`||c==`k`)&&(s=0);s-->0;)n+=`a`;for(;o-->0;)n=c+n}else n+=i===`J`?`H`:i}return n}function Oe(e){let t=e.hourCycle;if(t===void 0){let n=e;t=n.getHourCycles?.()[0]??n.hourCycles?.[0]}if(t)switch(t){case`h24`:return`k`;case`h23`:return`H`;case`h12`:return`h`;case`h11`:return`K`;default:throw Error(`Invalid hourCycle`)}let n=e.language,r;return n!==`root`&&(r=e.maximize().region),(m[`${n}-${r}`]||m[r||``]||m[n||``]||m[`${n}-001`]||m[`001`])[0].charAt(0)}var ke=RegExp(`^${Te.source}*`),Ae=RegExp(`${Te.source}*$`);function h(e,t){return{start:e,end:t}}var je=!!Object.fromEntries,Me=!!String.prototype.trimStart,Ne=!!String.prototype.trimEnd,Pe=je?Object.fromEntries:function(e){let t={};for(let[n,r]of e)t[n]=r;return t},Fe=Me?function(e){return e.trimStart()}:function(e){return e.replace(ke,``)},Ie=Ne?function(e){return e.trimEnd()}:function(e){return e.replace(Ae,``)},Le=Re();function Re(){try{let e=RegExp(`([^\\p{White_Space}\\p{Pattern_Syntax}]*)`,`yu`);if(e.exec(`a `)?.[1]===`a`)return e}catch{}return Ee}function ze(e,t){return Le.lastIndex=t,Le.exec(e)[1]??``}function Be(e){if(e.length===0)return null;let t=1,n=1;for(let r=0;r<e.length;){let i=e.charCodeAt(r);switch(i){case 35:case 39:case 60:case 123:case 125:return null}if(i===10)t++,n=1,r++;else if(n++,i>=55296&&i<=56319&&r+1<e.length){let t=e.charCodeAt(r+1);r+=t>=56320&&t<=57343?2:1}else r++}return{offset:e.length,line:t,column:n}}var Ve=class{constructor(e,t={}){this.message=e,this.position={offset:0,line:1,column:1},this.ignoreTag=!!t.ignoreTag,this.locale=t.locale,this.requiresOtherClause=!!t.requiresOtherClause,this.shouldParseSkeletons=!!t.shouldParseSkeletons}parse(){if(this.offset()!==0)throw Error(`parser can only be used once`);if(this.message.length>0){let e=this.message.charCodeAt(0);if(e!==35&&e!==39&&e!==60&&e!==123&&e!==125){let e=Be(this.message);if(e){let t=this.clonePosition();return this.position=e,{val:[{type:0,value:this.message,location:h(t,this.clonePosition())}],err:null}}}}return this.parseMessage(0,``,!1)}parseMessage(e,t,n){let r=[];for(;!this.isEOF();){let i=this.char();if(i===123){let t=this.parseArgument(e,n);if(t.err)return t;r.push(t.val)}else if(i===125&&e>0)break;else if(i===35&&(t===`plural`||t===`selectordinal`)){let e=this.clonePosition();this.bump(),r.push({type:7,location:h(e,this.clonePosition())})}else if(i===60&&!this.ignoreTag&&this.peek()===47){if(n)break;return this.error(26,h(this.clonePosition(),this.clonePosition()))}else if(i===60&&!this.ignoreTag&&He(this.peek()||0)){let n=this.parseTag(e,t);if(n.err)return n;r.push(n.val)}else{let n=this.parseLiteral(e,t);if(n.err)return n;r.push(n.val)}}return{val:r,err:null}}parseTag(e,t){let n=this.clonePosition();this.bump();let r=this.parseTagName();if(this.bumpSpace(),this.bumpIf(`/>`))return{val:{type:0,value:`<${r}/>`,location:h(n,this.clonePosition())},err:null};if(this.bumpIf(`>`)){let i=this.parseMessage(e+1,t,!0);if(i.err)return i;let a=i.val,o=this.clonePosition();if(this.bumpIf(`</`)){if(this.isEOF()||!He(this.char()))return this.error(23,h(o,this.clonePosition()));let e=this.clonePosition();return r===this.parseTagName()?(this.bumpSpace(),this.bumpIf(`>`)?{val:{type:8,value:r,children:a,location:h(n,this.clonePosition())},err:null}:this.error(23,h(o,this.clonePosition()))):this.error(26,h(e,this.clonePosition()))}return this.error(27,h(n,this.clonePosition()))}return this.error(23,h(n,this.clonePosition()))}parseTagName(){let e=this.offset();for(this.bump();!this.isEOF()&&We(this.char());)this.bump();return this.message.slice(e,this.offset())}parseLiteral(e,t){let n=this.clonePosition(),r=``;for(;;){let n=this.tryParseQuote(t);if(n){r+=n;continue}let i=this.tryParseUnquoted(e,t);if(i){r+=i;continue}let a=this.tryParseLeftAngleBracket();if(a)r+=a;else break}let i=h(n,this.clonePosition());return{val:{type:0,value:r,location:i},err:null}}tryParseLeftAngleBracket(){return!this.isEOF()&&this.char()===60&&(this.ignoreTag||!Ue(this.peek()||0))?(this.bump(),`<`):null}tryParseQuote(e){if(this.isEOF()||this.char()!==39)return null;switch(this.peek()){case 39:return this.bump(),this.bump(),`'`;case 123:case 60:case 62:case 125:break;case 35:if(e===`plural`||e===`selectordinal`)break;return null;default:return null}this.bump();let t=[this.char()];for(this.bump();!this.isEOF();){let e=this.char();if(e===39){if(this.peek()===39)t.push(39),this.bump();else{this.bump();break}}else t.push(e);this.bump()}return String.fromCodePoint(...t)}tryParseUnquoted(e,t){if(this.isEOF())return null;let n=this.char();return n===60||n===123||n===35&&(t===`plural`||t===`selectordinal`)||n===125&&e>0?null:(this.bump(),String.fromCodePoint(n))}parseArgument(e,t){let n=this.clonePosition();if(this.bump(),this.bumpSpace(),this.isEOF())return this.error(1,h(n,this.clonePosition()));if(this.char()===125)return this.bump(),this.error(2,h(n,this.clonePosition()));let r=this.parseIdentifierIfPossible().value;if(!r)return this.error(3,h(n,this.clonePosition()));if(this.bumpSpace(),this.isEOF())return this.error(1,h(n,this.clonePosition()));switch(this.char()){case 125:return this.bump(),{val:{type:1,value:r,location:h(n,this.clonePosition())},err:null};case 44:return this.bump(),this.bumpSpace(),this.isEOF()?this.error(1,h(n,this.clonePosition())):this.parseArgumentOptions(e,t,r,n);default:return this.error(3,h(n,this.clonePosition()))}}parseIdentifierIfPossible(){let e=this.clonePosition(),t=this.offset(),n=ze(this.message,t),r=t+n.length;return this.bumpTo(r),{value:n,location:h(e,this.clonePosition())}}parseArgumentOptions(e,t,n,r){let i=this.clonePosition(),a=this.parseIdentifierIfPossible().value,o=this.clonePosition();switch(a){case``:return this.error(4,h(i,o));case`number`:case`date`:case`time`:{this.bumpSpace();let e=null;if(this.bumpIf(`,`)){this.bumpSpace();let t=this.clonePosition(),n=this.parseSimpleArgStyleIfPossible();if(n.err)return n;let r=Ie(n.val);if(r.length===0)return this.error(6,h(this.clonePosition(),this.clonePosition()));e={style:r,styleLocation:h(t,this.clonePosition())}}let t=this.tryParseArgumentClose(r);if(t.err)return t;let i=h(r,this.clonePosition());if(e&&e.style.startsWith(`::`)){let t=Fe(e.style.slice(2));if(a===`number`){let r=this.parseNumberSkeletonFromString(t,e.styleLocation);return r.err?r:{val:{type:2,value:n,location:i,style:r.val},err:null}}{if(t.length===0)return this.error(10,i);let r=t;this.locale&&(r=De(t,this.locale));let o={type:1,pattern:r,location:e.styleLocation,parsedOptions:this.shouldParseSkeletons?ee(r):{}};return{val:{type:a===`date`?3:4,value:n,location:i,style:o},err:null}}}return{val:{type:a===`number`?2:a===`date`?3:4,value:n,location:i,style:e?.style??null},err:null}}case`plural`:case`selectordinal`:case`select`:{let i=this.clonePosition();if(this.bumpSpace(),!this.bumpIf(`,`))return this.error(12,h(i,{...i}));this.bumpSpace();let o=this.parseIdentifierIfPossible(),s=0;if(a!==`select`&&o.value===`offset`){if(!this.bumpIf(`:`))return this.error(13,h(this.clonePosition(),this.clonePosition()));this.bumpSpace();let e=this.tryParseDecimalInteger(13,14);if(e.err)return e;this.bumpSpace(),o=this.parseIdentifierIfPossible(),s=e.val}let c=this.tryParsePluralOrSelectOptions(e,a,t,o);if(c.err)return c;let l=this.tryParseArgumentClose(r);if(l.err)return l;let u=h(r,this.clonePosition());return a===`select`?{val:{type:5,value:n,options:Pe(c.val),location:u},err:null}:{val:{type:6,value:n,options:Pe(c.val),offset:s,pluralType:a===`plural`?`cardinal`:`ordinal`,location:u},err:null}}default:return this.error(5,h(i,o))}}tryParseArgumentClose(e){return this.isEOF()||this.char()!==125?this.error(1,h(e,this.clonePosition())):(this.bump(),{val:!0,err:null})}parseSimpleArgStyleIfPossible(){let e=0,t=this.clonePosition();for(;!this.isEOF();)switch(this.char()){case 39:{this.bump();let e=this.clonePosition();if(!this.bumpUntil(`'`))return this.error(11,h(e,this.clonePosition()));this.bump();break}case 123:e+=1,this.bump();break;case 125:if(e>0)--e;else return{val:this.message.slice(t.offset,this.offset()),err:null};break;default:this.bump()}return{val:this.message.slice(t.offset,this.offset()),err:null}}parseNumberSkeletonFromString(e,t){let n=[];try{n=ne(e)}catch{return this.error(7,t)}return{val:{type:0,tokens:n,location:t,parsedOptions:this.shouldParseSkeletons?fe(n):{}},err:null}}tryParsePluralOrSelectOptions(e,t,n,r){let i=!1,a=[],o=new Set,{value:s,location:c}=r;for(;;){if(s.length===0){let e=this.clonePosition();if(t!==`select`&&this.bumpIf(`=`)){let t=this.tryParseDecimalInteger(16,19);if(t.err)return t;c=h(e,this.clonePosition()),s=this.message.slice(e.offset,this.offset())}else break}if(o.has(s))return this.error(t===`select`?21:20,c);s===`other`&&(i=!0),this.bumpSpace();let r=this.clonePosition();if(!this.bumpIf(`{`))return this.error(t===`select`?17:18,h(this.clonePosition(),this.clonePosition()));let l=this.parseMessage(e+1,t,n);if(l.err)return l;let u=this.tryParseArgumentClose(r);if(u.err)return u;a.push([s,{value:l.val,location:h(r,this.clonePosition())}]),o.add(s),this.bumpSpace(),{value:s,location:c}=this.parseIdentifierIfPossible()}return a.length===0?this.error(t===`select`?15:16,h(this.clonePosition(),this.clonePosition())):this.requiresOtherClause&&!i?this.error(22,h(this.clonePosition(),this.clonePosition())):{val:a,err:null}}tryParseDecimalInteger(e,t){let n=1,r=this.clonePosition();this.bumpIf(`+`)||this.bumpIf(`-`)&&(n=-1);let i=!1,a=0;for(;!this.isEOF();){let e=this.char();if(e>=48&&e<=57)i=!0,a=a*10+(e-48),this.bump();else break}let o=h(r,this.clonePosition());return i?(a*=n,Number.isSafeInteger(a)?{val:a,err:null}:this.error(t,o)):this.error(e,o)}offset(){return this.position.offset}isEOF(){return this.offset()===this.message.length}clonePosition(){return{offset:this.position.offset,line:this.position.line,column:this.position.column}}char(){let e=this.position.offset;if(e>=this.message.length)throw Error(`out of bound`);let t=this.message.codePointAt(e);if(t===void 0)throw Error(`Offset ${e} is at invalid UTF-16 code unit boundary`);return t}error(e,t){return{val:null,err:{kind:e,message:this.message,location:t}}}bump(){if(this.isEOF())return;let e=this.char();e===10?(this.position.line+=1,this.position.column=1,this.position.offset+=1):(this.position.column+=1,this.position.offset+=e<65536?1:2)}bumpIf(e){let t=this.offset();if(this.message.slice(t,t+e.length)===e){for(let t=0;t<e.length;t++)this.bump();return!0}return!1}bumpUntil(e){let t=this.offset(),n=this.message.indexOf(e,t);return n>=0?(this.bumpTo(n),!0):(this.bumpTo(this.message.length),!1)}bumpTo(e){if(this.offset()>e)throw Error(`targetOffset ${e} must be greater than or equal to the current offset ${this.offset()}`);for(e=Math.min(e,this.message.length);;){let t=this.offset();if(t===e)break;if(t>e)throw Error(`targetOffset ${e} is at invalid UTF-16 code unit boundary`);if(this.bump(),this.isEOF())break}}bumpSpace(){for(;!this.isEOF()&&Ge(this.char());)this.bump()}peek(){if(this.isEOF())return null;let e=this.char(),t=this.offset();return this.message.charCodeAt(t+(e>=65536?2:1))??null}};function He(e){return e>=97&&e<=122||e>=65&&e<=90}function Ue(e){return He(e)||e===47}function We(e){return e===45||e===46||e>=48&&e<=57||e===95||e>=97&&e<=122||e>=65&&e<=90||e==183||e>=192&&e<=214||e>=216&&e<=246||e>=248&&e<=893||e>=895&&e<=8191||e>=8204&&e<=8205||e>=8255&&e<=8256||e>=8304&&e<=8591||e>=11264&&e<=12271||e>=12289&&e<=55295||e>=63744&&e<=64975||e>=65008&&e<=65533||e>=65536&&e<=983039}function Ge(e){return e>=9&&e<=13||e===32||e===133||e>=8206&&e<=8207||e===8232||e===8233}function Ke(e){e.forEach(e=>{if(delete e.location,ye(e)||be(e))for(let t in e.options)delete e.options[t].location,Ke(e.options[t].value);else ge(e)&&Ce(e.style)||(_e(e)||ve(e))&&we(e.style)?delete e.style.location:Se(e)&&Ke(e.children)})}function g(e,t={}){t={shouldParseSkeletons:!0,requiresOtherClause:!0,...t};let n=new Ve(e,t).parse();if(n.err){let e=SyntaxError(pe[n.err.kind]);throw e.location=n.err.location,e.originalMessage=n.err.message,e}return t?.captureLocation||Ke(n.val),n.val}function qe(e,t){let n=t&&t.cache?t.cache:rt,r=t&&t.serializer?t.serializer:tt;return(t&&t.strategy?t.strategy:Qe)(e,{cache:n,serializer:r})}function Je(e){return e==null||typeof e==`number`||typeof e==`boolean`}function Ye(e,t,n,r){let i=Je(r)?r:n(r),a=t.get(i);return a===void 0&&(a=e.call(this,r),t.set(i,a)),a}function Xe(e,t,n){let r=Array.prototype.slice.call(arguments,3),i=n(r),a=t.get(i);return a===void 0&&(a=e.apply(this,r),t.set(i,a)),a}function Ze(e,t,n,r,i){return n.bind(t,e,r,i)}function Qe(e,t){let n=e.length===1?Ye:Xe;return Ze(e,this,n,t.cache.create(),t.serializer)}function $e(e,t){return Ze(e,this,Xe,t.cache.create(),t.serializer)}function et(e,t){return Ze(e,this,Ye,t.cache.create(),t.serializer)}var tt=function(){return JSON.stringify(arguments)},nt=class{constructor(){this.cache=Object.create(null)}get(e){return this.cache[e]}set(e,t){this.cache[e]=t}},rt={create:function(){return new nt}},it={variadic:$e,monadic:et},at=class extends Error{constructor(e,t,n){super(e),this.code=t,this.originalMessage=n}toString(){return`[formatjs Error: ${this.code}] ${this.message}`}},ot=class extends at{constructor(e,t,n,r){super(`Invalid values for "${e}": "${t}". Options are "${Object.keys(n).join(`", "`)}"`,`INVALID_VALUE`,r)}},st=class extends at{constructor(e,t,n){super(`Value for "${e}" must be of type ${t}`,`INVALID_VALUE`,n)}},ct=class extends at{constructor(e,t){super(`The intl string context variable "${e}" was not provided to the string "${t}"`,`MISSING_VALUE`,t)}};function lt(e){return e.length<2?e:e.reduce((e,t)=>{let n=e[e.length-1];return!n||n.type!==0||t.type!==0?e.push(t):n.value+=t.value,e},[])}function ut(e){return typeof e==`function`}function dt(e,t,n,r,i,a,o){if(e.length===1&&me(e[0]))return[{type:0,value:e[0].value}];let s=[];for(let c of e){if(me(c)){s.push({type:0,value:c.value});continue}if(xe(c)){typeof a==`number`&&s.push({type:0,value:n.getNumberFormat(t).format(a)});continue}let{value:e}=c;if(!(i&&e in i))throw new ct(e,o);let l=i[e];if(he(c))l&&typeof l!=`string`&&typeof l!=`number`&&typeof l!=`bigint`||(l=typeof l==`string`||typeof l==`number`||typeof l==`bigint`?String(l):``),s.push({type:typeof l==`string`?0:1,value:l});else if(_e(c)){let e=typeof c.style==`string`?r.date[c.style]:we(c.style)?c.style.parsedOptions:void 0;s.push({type:0,value:n.getDateTimeFormat(t,e).format(l)})}else if(ve(c)){let e=typeof c.style==`string`?r.time[c.style]:we(c.style)?c.style.parsedOptions:r.time.medium;s.push({type:0,value:n.getDateTimeFormat(t,e).format(l)})}else if(ge(c)){let e=typeof c.style==`string`?r.number[c.style]:Ce(c.style)?c.style.parsedOptions:void 0;if(e&&e.scale){let t=e.scale||1;if(typeof l==`bigint`){if(!Number.isInteger(t))throw TypeError(`Cannot apply fractional scale ${t} to bigint value. Scale must be an integer when formatting bigint.`);l*=BigInt(t)}else l*=t}s.push({type:0,value:n.getNumberFormat(t,e).format(l)})}else{if(Se(c)){let{children:e,value:l}=c,u=i[l];if(!ut(u))throw new st(l,`function`,o);let d=u(dt(e,t,n,r,i,a).map(e=>e.value));Array.isArray(d)||(d=[d]),s.push(...d.map(e=>({type:typeof e==`string`?0:1,value:e})))}if(ye(c)){let e=l,a=(Object.prototype.hasOwnProperty.call(c.options,e)?c.options[e]:void 0)||c.options.other;if(!a)throw new ot(c.value,l,Object.keys(c.options),o);s.push(...dt(a.value,t,n,r,i))}else if(be(c)){let e=`=${l}`,a=Object.prototype.hasOwnProperty.call(c.options,e)?c.options[e]:void 0;if(!a){if(!Intl.PluralRules)throw new at(`Intl.PluralRules is not available in this environment.
2
+ Try polyfilling it using "@formatjs/intl-pluralrules"
3
+ `,`MISSING_INTL_API`,o);let e=typeof l==`bigint`?Number(l):l,r=n.getPluralRules(t,{type:c.pluralType}).select(e-(c.offset||0));a=(Object.prototype.hasOwnProperty.call(c.options,r)?c.options[r]:void 0)||c.options.other}if(!a)throw new ot(c.value,l,Object.keys(c.options),o);let u=typeof l==`bigint`?Number(l):l;s.push(...dt(a.value,t,n,r,i,u-(c.offset||0)))}}}return lt(s)}function ft(e,t){return t?{...e,...t,...Object.keys(e).reduce((n,r)=>(n[r]={...e[r],...t[r]},n),{})}:e}function pt(e,t){return t?Object.keys(e).reduce((n,r)=>(n[r]=ft(e[r],t[r]),n),{...e}):e}function mt(e){return{create(){return{get(t){return e[t]},set(t,n){e[t]=n}}}}}function ht(e={number:{},dateTime:{},pluralRules:{}}){return{getNumberFormat:qe((...e)=>new Intl.NumberFormat(...e),{cache:mt(e.number),strategy:it.variadic}),getDateTimeFormat:qe((...e)=>new Intl.DateTimeFormat(...e),{cache:mt(e.dateTime),strategy:it.variadic}),getPluralRules:qe((...e)=>new Intl.PluralRules(...e),{cache:mt(e.pluralRules),strategy:it.variadic})}}var gt=class e{constructor(t,n=e.defaultLocale,r,i){if(this.formatterCache={number:{},dateTime:{},pluralRules:{}},this.format=(e=>{let t=this.formatToParts(e);if(t.length===1)return t[0].value;let n=t.reduce((e,t)=>(!e.length||t.type!==0||typeof e[e.length-1]!=`string`?e.push(t.value):e[e.length-1]+=t.value,e),[]);return n.length<=1?n[0]||``:n}),this.formatToParts=(e=>dt(this.ast,this.locales,this.formatters,this.formats,e,void 0,this.message)),this.resolvedOptions=()=>({locale:this.resolvedLocale?.toString()||Intl.NumberFormat.supportedLocalesOf(this.locales)[0]}),this.getAst=()=>this.ast,this.locales=n,this.resolvedLocale=e.resolveLocale(n),typeof t==`string`){if(this.message=t,!e.__parse)throw TypeError("IntlMessageFormat.__parse must be set to process `message` of type `string`");let{...n}=i||{};this.ast=e.__parse(t,{...n,locale:this.resolvedLocale})}else this.ast=t;if(!Array.isArray(this.ast))throw TypeError(`A message must be provided as a String or AST.`);this.formats=pt(e.formats,r),this.formatters=i&&i.formatters||ht(this.formatterCache)}static{this.memoizedDefaultLocale=null}static get defaultLocale(){return e.memoizedDefaultLocale||=new Intl.NumberFormat().resolvedOptions().locale,e.memoizedDefaultLocale}static{this.resolveLocale=e=>{if(Intl.Locale===void 0)return;let t=Intl.NumberFormat.supportedLocalesOf(e);return t.length>0?new Intl.Locale(t[0]):new Intl.Locale(typeof e==`string`?e:e[0])}}static{this.__parse=g}static{this.formats={number:{integer:{maximumFractionDigits:0},currency:{style:`currency`},percent:{style:`percent`}},date:{short:{month:`numeric`,day:`numeric`,year:`2-digit`},medium:{month:`short`,day:`numeric`,year:`numeric`},long:{month:`long`,day:`numeric`,year:`numeric`},full:{weekday:`long`,month:`long`,day:`numeric`,year:`numeric`}},time:{short:{hour:`numeric`,minute:`numeric`},medium:{hour:`numeric`,minute:`numeric`,second:`numeric`},long:{hour:`numeric`,minute:`numeric`,second:`numeric`,timeZoneName:`short`},full:{hour:`numeric`,minute:`numeric`,second:`numeric`,timeZoneName:`short`}}}}};function _t(e,t=new Set){for(let n of e){if(n.type===p.literal||n.type===p.pound)continue;let e=n.type===p.plural||n.type===p.number?`number`:n.type===p.date||n.type===p.time?`date`:String(n.type);if(t.add(`${n.value}:${e}`),n.type===p.tag&&_t(n.children,t),n.type===p.select||n.type===p.plural)for(let e of Object.values(n.options))_t(e.value,t)}return[...t].sort()}function vt(e,t){let n=[];for(let[r,i]of Object.entries(t)){let t=e[r];if(!t)n.push(`${r}: unknown message`);else try{if(typeof i!=`string`)throw Error(`Expected an ICU string`);let e=_t(g(t.message)),a=_t(g(i));JSON.stringify(e)!==JSON.stringify(a)&&n.push(`${r}: arguments/tags differ (expected ${e.join(`, `)}; got ${a.join(`, `)})`)}catch(e){n.push(`${r}: ${String(e)}`)}}return n}function yt(e){let t=[];for(let[n,r]of Object.entries(e)){r.description.trim()||t.push(`${n}: missing translator description`);try{g(r.message)}catch(e){t.push(`${n}: ${String(e)}`)}}return t}var bt={a:`á`,e:`ë`,i:`ï`,o:`ö`,u:`ü`,A:`Á`,E:`Ë`,I:`Ï`,O:`Ö`,U:`Ü`};function xt(e,t){return e.map(e=>{if(e.type===p.literal){if(!e.value.trim())return e;let n=e.value.replace(/[aeiouAEIOU]/g,e=>bt[e]??e);return{...e,value:t?`\u202e${n}\u202c`:`[${n}${`~`.repeat(Math.ceil(n.length*.3))}]`}}return e.type===p.tag?{...e,children:xt(e.children,t)}:e.type===p.plural||e.type===p.select?{...e,options:Object.fromEntries(Object.entries(e.options).map(([e,n])=>[e,{...n,value:xt(n.value,t)}]))}:e})}var St=5e3;function Ct(e,t){let n,r=()=>void 0,i=new Promise(e=>{r=e}),a=!0,o=(i,o)=>{a&&(a=!1,clearTimeout(s),n=i,o!==void 0&&t({code:`load`,message:`Could not load ${e.id} (${e.locale}/${e.namespace})`,cause:o}),r())},s=setTimeout(()=>{o({},Error(`Catalog loading exceeded 5 seconds; using fallback messages`))},St);return Promise.resolve().then(()=>a?e.load():void 0).then(n=>{if(!a)return;if(typeof n!=`object`||!n||Array.isArray(n))throw TypeError(`Expected a translation catalog object`);let r=[];for(let[i,a]of Object.entries(n))typeof a==`string`?r.push([i,a]):t({code:`invalid`,message:`${e.id}: ${i}: expected an ICU string`});o(Object.fromEntries(r))}).catch(e=>{o({},e)}),{ready:i,get catalog(){return n},dispose(){a&&(a=!1,clearTimeout(s),r())}}}function wt(e,t){return{message:e,description:t}}function Tt(e,t,n,r){if(n!==void 0&&Object.getPrototypeOf(n)!==Object.prototype&&Object.getPrototypeOf(n)!==null)return r();let i=[];for(let[e,t]of Object.entries(Object.getOwnPropertyDescriptors(n??{}))){if(!(`value`in t))return r();let n=t.value;if(n!==void 0){if(typeof n!=`string`&&typeof n!=`boolean`&&(typeof n!=`number`||!Number.isFinite(n)))return r();i.push([e,n])}}i.sort(([e],[t])=>e.localeCompare(t));let a=JSON.stringify([t,i]),o=e.get(a);if(o!==void 0)return o;let s=r();if(e.size>=64){let t=e.keys().next().value;t!==void 0&&e.delete(t)}return e.set(a,s),s}var Et=[`language`,`formatLocale`,`timeZone`,`hourCycle`];function Dt(e){let t=Intl.getCanonicalLocales(e)[0];if(t===void 0)throw RangeError(`A locale is required`);return t}function Ot(e){let t=new Intl.Locale(e).baseName.split(`-`),n=[];for(;t.length;)n.unshift(t.join(`-`)),t.pop();return n}function _(e){if(typeof e!=`object`||!e||!(`language`in e)||typeof e.language!=`string`||!(`formatLocale`in e)||typeof e.formatLocale!=`string`)throw TypeError(`Expected language and formatLocale`);let t=Dt(e.language),n=Dt(e.formatLocale),r=`hourCycle`in e?e.hourCycle:void 0,i=`timeZone`in e?e.timeZone:void 0;if(r!==void 0&&r!==`h11`&&r!==`h12`&&r!==`h23`&&r!==`h24`)throw RangeError(`Invalid hour cycle`);if(i!==void 0&&typeof i!=`string`)throw TypeError(`Expected a time-zone name`);let a=i===void 0?void 0:new Intl.DateTimeFormat(n,{timeZone:i}).resolvedOptions().timeZone;return{language:t,formatLocale:n,...a===void 0?{}:{timeZone:a},...r===void 0?{}:{hourCycle:r}}}function kt(e){if(typeof e!=`object`||!e||Array.isArray(e))throw TypeError(`Expected localization overrides`);let t=_({language:`en`,formatLocale:`en`,...e});return{...`language`in e?{language:t.language}:{},...`formatLocale`in e?{formatLocale:t.formatLocale}:{},...t.timeZone===void 0?{}:{timeZone:t.timeZone},...t.hourCycle===void 0?{}:{hourCycle:t.hourCycle}}}function At(e){return`getTextInfo`in e&&typeof e.getTextInfo==`function`}function jt(e){if(e===`ar-XB`)return`rtl`;let t=new Intl.Locale(e),n=At(t)?t.getTextInfo():`textInfo`in t?t.textInfo:void 0;return typeof n==`object`&&n&&`direction`in n&&n.direction===`rtl`?`rtl`:`ltr`}var Mt=class{constructor(e={}){this.defaults={language:`en`,formatLocale:`en`},this.policy={},this.sources=new Map,this.contributions=new Map,this.listeners=new Set,this.formats=new Map,this.dateFormats=new Map,this.listFormats=new Map,this.reported=new Set,this.preferencesRevision=0,this.pending=Promise.resolve(),this.resolvedLanguage=`en`,this.current=_(e.preferences??this.defaults),this.overrides=e.preferences===void 0?{}:{...this.current},this.development=e.development??!1,this.diagnostic=e.diagnostic??(e=>{console.warn(`[i18n:${e.code}] ${e.message}`,e.cause??``)}),this.assertLanguage(this.current.language)}get preferences(){return{...this.current}}get preferenceOverrides(){return{...this.overrides}}get preferenceDefaults(){return{...this.defaults}}get preferencePolicy(){return{enforcedFields:{...this.policy.enforcedFields},sources:{...this.policy.sources}}}preferenceSettingPolicy(e){let t=this.policy.enforcedFields?.[e];return{locked:t!==void 0,enforcedBy:t,source:this.policy.sources?.[e]}}resolvePreferences(e,t,n){let r={...e,...t};for(let t of Et)n.enforcedFields?.[t]!==void 0&&(Reflect.deleteProperty(r,t),Object.assign(r,{[t]:e[t]}));return _(r)}get preferenceRevision(){return this.preferencesRevision}get language(){return this.isPseudo?this.current.language:this.resolvedLanguage}get direction(){return jt(this.language)}get ready(){return this.pending}get availableLanguages(){return[...new Set([`en`,...[...this.contributions.values()].map(e=>e.locale)])].filter(e=>e!==`en-XA`&&e!==`ar-XB`).sort()}get isPseudo(){return this.current.language===`en-XA`||this.current.language===`ar-XB`}subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}notify(){this.formats.clear(),this.dateFormats.clear(),this.listFormats.clear();for(let e of this.listeners)e()}report(e,t,n){let r=`${e}:${t}`;this.reported.has(r)||(this.reported.add(r),this.diagnostic({code:e,message:t,...n===void 0?{}:{cause:n}}))}assertLanguage(e){if(!this.development&&(e===`en-XA`||e===`ar-XB`))throw RangeError(`Pseudo-localization is available only in development`)}setPreferences(e){let t=_(e);return this.assertLanguage(t.language),this.setPreferenceOverrides(t)}setPreferenceDefaults(e,t=this.policy){let n=_(e),r=this.resolvePreferences(n,this.overrides,t);return this.assertLanguage(n.language),this.assertLanguage(r.language),this.defaults=n,this.policy={enforcedFields:{...t.enforcedFields},sources:{...t.sources}},this.current=r,this.refresh(),this.pending}setPreferenceOverrides(e){let t=kt(e);for(let e of Et)this.policy.enforcedFields?.[e]!==void 0&&(Reflect.deleteProperty(t,e),this.overrides[e]!==void 0&&Object.assign(t,{[e]:this.overrides[e]}));let n=this.resolvePreferences(this.defaults,t,this.policy);return this.assertLanguage(n.language),this.overrides=t,this.current=n,this.preferencesRevision++,this.refresh(),this.pending}registerMessages(e,t){if(!e||this.sources.has(e))throw Error(`Duplicate or empty message namespace: ${e}`);return this.messageHandle(e,this.addSource(e,t))}acquireMessages(e,t){let n=this.addSource(e,t);return{messages:this.messageHandle(e,n),release:()=>{if(!n.active)return;n.active=!1,n.selected.clear();let t=this.sources.get(e);t?.delete(n),t?.size===0&&this.sources.delete(e),this.refresh()}}}addSource(e,t){if(!e)throw Error(`Empty message namespace`);let n=yt(t);if(n.length)throw Error(`Invalid source ${e}: ${n.join(`; `)}`);let r={definitions:t,selected:new Map,active:!0},i=this.sources.get(e);return i||(i=new Set,this.sources.set(e,i)),i.add(r),this.refresh(),r}messageHandle(e,t){return{t:(n,...r)=>{let i=this.format(e,t,n,r[0]);if(typeof i!=`string`)throw Error(`Use rich() for ${e}.${n}`);return i},rich:(n,...r)=>this.format(e,t,n,r[0])}}registerCatalog(e){if(!e.id||this.contributions.has(e.id))throw Error(`Duplicate or empty catalog ID: ${e.id}`);let t={...e,locale:Dt(e.locale)};return this.contributions.set(t.id,t),this.refresh(),()=>{this.contributions.get(t.id)===t&&(this.contributions.delete(t.id),t.loaded?.dispose(),this.refresh())}}matchingCatalogs(){let e=this.isPseudo?[]:Ot(this.current.language).filter(e=>e!==`en`);return[...this.contributions.values()].filter(t=>e.includes(t.locale)).sort((t,n)=>e.indexOf(t.locale)-e.indexOf(n.locale)||(t.id<n.id?-1:+(t.id>n.id)))}refresh(){let e=[];for(let t of this.matchingCatalogs())t.loaded===void 0&&(t.loaded=Ct(t,({code:e,message:t,cause:n})=>{this.report(e,t,n)}),t.loaded.ready.then(()=>{this.publish()})),e.push(t.loaded.ready);this.pending=Promise.all(e).then(()=>void 0),this.publish()}publish(){for(let e of this.sources.values())for(let t of e)t.selected.clear();let e=new Map,t=`en`;for(let n of this.matchingCatalogs()){let r=this.sources.get(n.namespace);if(r)for(let[i,a]of Object.entries(n.loaded?.catalog??{})){let o=!1,s=new Set;for(let e of r){let t=vt(e.definitions,{[i]:a});t.length?t.forEach(e=>s.add(e)):(e.selected.set(i,{message:a,locale:n.locale}),o=!0)}if(!o){this.report(`invalid`,`${n.id}: ${[...s].join(`; `)}`);continue}let c=JSON.stringify([n.locale,n.namespace,i]),l=e.get(c);l!==void 0&&this.report(`duplicate`,`${n.locale}/${n.namespace}.${i}: ${n.id} overrides ${l}`),e.set(c,n.id),t=n.locale}}this.resolvedLanguage=t,this.notify()}dateOptions(e){return{...e,...this.current.timeZone===void 0?{}:{timeZone:this.current.timeZone},...this.current.hourCycle===void 0?{}:{hourCycle:this.current.hourCycle,hour12:void 0}}}dateFormatter(e){let t=this.dateOptions(e);return Tt(this.dateFormats,this.current.formatLocale,t,()=>new Intl.DateTimeFormat(this.current.formatLocale,t))}format(e,t,n,r){let i=t.definitions[n];if(!i)throw Error(`Unknown message: ${e}.${n}`);let a=t.selected.get(n);!a&&t.active&&!this.isPseudo&&!this.current.language.startsWith(`en`)&&this.development&&this.report(`missing`,`${this.current.language}/${e}.${n}: using English`);let o=this.isPseudo?{message:i.message,locale:`en`}:a??{message:i.message,locale:`en`},s=(t,i)=>{let a=JSON.stringify([e,n,t,i,this.isPseudo]),o=this.formats.get(a);if(!o){let e={getNumberFormat:(e,t)=>new Intl.NumberFormat(this.current.formatLocale,t),getDateTimeFormat:(e,t)=>this.dateFormatter(t??{}),getPluralRules:(e,t)=>new Intl.PluralRules(e,t)},n=g(t);this.isPseudo&&(n=xt(n,this.current.language===`ar-XB`)),o=new gt(n,i,void 0,{formatters:e}),this.formats.set(a,o)}return o.format(r)};try{return s(o.message,o.locale)}catch(t){if(this.report(`format`,`${e}.${n}: formatting failed`,t),o.message!==i.message)return s(i.message,`en`);throw t}}number(e,t){return new Intl.NumberFormat(this.current.formatLocale,t).format(e)}date(e,t={dateStyle:`medium`}){return this.dateFormatter(t).format(e)}time(e,t={timeStyle:`short`}){return this.dateFormatter(t).format(e)}relativeTime(e,t,n={numeric:`auto`}){return new Intl.RelativeTimeFormat(this.current.formatLocale,n).format(e,t)}list(e,t){return Tt(this.listFormats,this.current.formatLocale,t,()=>new Intl.ListFormat(this.current.formatLocale,t)).format(e)}},Nt=`pi-web-localization`,v=new Mt({development:!1}),Pt=new WeakMap,Ft=new WeakMap;function It(e){let t={},n={};for(let r of Et){let i=`/defaultLocalization/${r}`,a=e.enforcedSettings?.[i],o=e.configSources?.[i];a!==void 0&&(t[r]=a),o!==void 0&&(n[r]=o)}return{enforcedFields:t,sources:n}}function Lt(e,t=v){return Rt(e.effectiveConfig.defaultLocalization??{},It(e),t)}function Rt(e,t,n){let r=kt(e),i=Ft.get(n)??zt(),a=n.setPreferenceDefaults(_({...i,...r}),t);return Pt.set(n,r),a}function zt(e=typeof window>`u`?void 0:window.navigator){let t=e?.languages[0]??e?.language??`en`;return{language:t,formatLocale:t}}function Bt(e,t=v){let n=Pt.get(t),r=t.preferenceDefaults[e]??new Intl.DateTimeFormat().resolvedOptions().timeZone;return{source:n?.[e]===void 0?`browser`:`server`,value:r}}async function Vt(e=v,t=window,n=!1,r={},i={}){let a=zt(t.navigator),o=a,s={};try{let e=t.localStorage.getItem(Nt);e!==null&&(s=kt(JSON.parse(e)))}catch(e){console.warn(`[i18n] Could not restore localization preferences; using browser defaults`,e)}let c=n?new URLSearchParams(t.location.search).get(`pseudoLocale`):null,l=c===`en-XA`||c===`ar-XB`?c:void 0,u=s.language;(s.language===`en-XA`||s.language===`ar-XB`)&&(delete s.language,u=void 0),l!==void 0&&(s={...s,language:l}),Pt.set(e,{}),Ft.set(e,a),e.setPreferenceDefaults(a,{}),e.setPreferenceOverrides({}),e.setPreferenceOverrides(s),await Promise.resolve();let d=e.preferenceRevision,f=()=>{t.document.documentElement.lang=e.language,t.document.documentElement.dir=e.direction;let n=e.preferenceRevision;if(n===d)return;d=n;let r=e.preferenceOverrides,i=r.language===`en-XA`||r.language===`ar-XB`?u??o.language:r.language,a={...r,...i===void 0?{}:{language:i}};try{t.localStorage.setItem(Nt,JSON.stringify(a))}catch(e){console.warn(`[i18n] Could not save localization preferences`,e)}};f();let ee=e.subscribe(f);try{let[t,n]=await Promise.all([r,i]);Rt(t??{},n,e),o=e.preferenceDefaults}catch(e){throw ee(),e}return ee}var Ht=class{constructor(e,t=v,n){this.host=e,this.service=t,this.invalidate=n,e.addController(this)}hostConnected(){this.unsubscribe??=this.service.subscribe(()=>{this.invalidate?.(),this.host.requestUpdate()}),this.invalidate?.(),this.host.requestUpdate()}hostDisconnected(){this.unsubscribe?.(),this.unsubscribe=void 0}},Ut=t(`en`,{}),Wt=`en`,y=(e,t,n)=>Ut(e,t,n);function Gt(e,n){let r=s(n);Ut=t(e,r),Wt=e}function Kt(){return Wt}var qt=(e,t)=>t,Jt=[`off`,`minimal`,`low`,`medium`,`high`,`xhigh`,`max`];function Yt(e){return Jt.some(t=>t===e)}function Xt(e){return e===void 0||e===``?`off`:e}function Zt(e,t=qt){let n=Xt(e),r={off:t(`thinking.label.off`,`Off`),minimal:t(`thinking.label.minimal`,`Minimal`),low:t(`thinking.label.low`,`Low`),medium:t(`thinking.label.medium`,`Medium`),high:t(`thinking.label.high`,`High`),xhigh:t(`thinking.label.xhigh`,`Extra high`),max:t(`thinking.label.max`,`Maximum`)};return Yt(n)?r[n]??n:n}function Qt(e,t=qt){switch(e){case`off`:return t(`thinking.description.off`,`No reasoning`);case`minimal`:return t(`thinking.description.minimal`,`Minimal reasoning (about 1k tokens)`);case`low`:return t(`thinking.description.low`,`Light reasoning (about 2k tokens)`);case`medium`:return t(`thinking.description.medium`,`Moderate reasoning (about 8k tokens)`);case`high`:return t(`thinking.description.high`,`Deep reasoning (about 16k tokens)`);case`xhigh`:return t(`thinking.description.xhigh`,`Extra high reasoning (about 32k tokens)`);case`max`:return t(`thinking.description.max`,`Maximum reasoning (about 64k tokens)`);default:return}}function $t(e,t){let n=t.length>=2?t:Jt,r=n.length-1,i=Xt(e),a=n.indexOf(i);return{total:r,filled:a<=0?0:Math.min(a,r)}}function en(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function tn(e){if(!en(e))throw new i(`server.main.b5b69396302e`,`Invalid session defaults`);let t=e,n={};for(let e of[`defaultProvider`,`defaultModel`]){let r=t[e];if(r!==void 0){if(typeof r!=`string`)throw new i(`server.main.d20dbeed752b`,`Invalid {arg0}`,{arg0:e});n[e]=r}}let r=t.defaultThinkingLevel;if(r!==void 0){if(typeof r!=`string`||!Yt(r))throw new i(`server.main.e937d7ab07c7`,`Invalid defaultThinkingLevel`);n.defaultThinkingLevel=r}return n}function nn(e,t){if(e!==`steer`&&e!==`followUp`)throw new i(`configError.defaultStreamingBehavior.invalid`,`PI WEB config defaultStreamingBehavior must be steer or followUp: {source}`,{source:t});return e}var rn=new Set([`language`,`formatLocale`,`timeZone`,`hourCycle`]);function an(e,t=`request`){let n=e=>{throw Error(`PI WEB config defaultLocalization ${e}: ${t}`)};if(!on(e))return n(`must be an object`);let r=e;for(let e of Object.keys(r))rn.has(e)||n(`contains unknown key ${e}`);let i={};for(let e of[`language`,`formatLocale`]){let t=r[e];if(t===void 0)continue;if(typeof t!=`string`||t===``)return n(`${e} must be a valid locale`);let a;try{let r=Intl.getCanonicalLocales(t)[0];if(r===void 0)return n(`${e} must be a valid locale`);a=r}catch{return n(`${e} must be a valid locale`)}let{language:o,region:s}=new Intl.Locale(a);if(o===`en`&&s===`XA`||o===`ar`&&s===`XB`)return n(`${e} pseudo locales are development-only`);i[e]=a}let a=r.timeZone;if(a!==void 0){if(typeof a!=`string`||a===``)return n(`timeZone must be a valid date/time zone`);try{i.timeZone=new Intl.DateTimeFormat(`en`,{timeZone:a}).resolvedOptions().timeZone}catch{return n(`timeZone must be a valid date/time zone`)}}let o=r.hourCycle;if(o!==void 0){if(o!==`h11`&&o!==`h12`&&o!==`h23`&&o!==`h24`)return n(`hourCycle must be h11, h12, h23, or h24`);i.hourCycle=o}return i}function on(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function sn(e,t=`PI WEB config installationName`){if(typeof e!=`string`||e.length>120||cn(e))throw Error(`${t} must be a string of at most 120 characters without control characters`);return e.trim()}function cn(e){for(let t=0;t<e.length;t++){let n=e.charCodeAt(t);if(n<32||n===127)return!0}return!1}var ln=/^[a-z][a-z0-9.-]*$/u,un=new Set([`core`,`themes`]),dn=`machine.`,fn=`pi-web`,pn=`${fn}.`;function mn(e){return ln.test(e)}function hn(e){return e===fn||e.startsWith(pn)}function gn(e){return un.has(e)||e.startsWith(dn)||hn(e)}function _n(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function vn(e,t){if(!_n(e))throw new i(`configError.sessionArchive.object`,`PI WEB config sessionArchive must be an object: {source}`,{source:t});let n=Object.keys(e).find(e=>e!==`directory`);if(n!==void 0)throw new i(`configError.sessionArchive.unknownKey`,`PI WEB config sessionArchive has unknown key {key}: {source}`,{key:JSON.stringify(n),source:t});let r=e.directory;if(r===void 0)return{};if(typeof r!=`string`||r.trim()===``||r.includes(`\0`))throw new i(`configError.sessionArchive.directory`,`PI WEB config sessionArchive.directory must be a non-empty path: {source}`,{source:t});return{directory:r}}var b={sessionsDeleteArchived:`sessions.deleteArchived`,sessionsBulkMutations:`sessions.bulkMutations`,sessionsCleanup:`sessions.cleanup`,sessionsReload:`sessions.reload`,sessionsClearQueue:`sessions.clearQueue`,sessionsQueueMessageActions:`sessions.queueMessageActions`,sessionsPersistedState:`sessions.persistedState`,sessionsNotifications:`sessions.notifications`,sessionsUnread:`sessions.unread`,sessionsAskUser:`sessions.askUser`,promptAttachments:`prompt.attachments`,promptSpeechRecognition:`prompt.speechRecognition`,workspaceFileSuggestions:`workspace.fileSuggestions`,piPackagesManage:`piPackages.manage`,selectedMachineSettings:`settings.selectedMachine`,agentProfileConfig:`settings.agentProfile`,pluginLifecycle:`plugins.lifecycle`,sessionCleanupPinnedExclusions:`sessions.cleanup.pinnedExclusions`,sessionPinsDaemonOwned:`sessions.pins.daemonOwned`,sessionPinsManagementScoped:`sessions.pins.managementScoped`},yn=1e3,bn=32768,xn=8192,Sn=`pi-web.ask.answers`,Cn=1e3,wn=4e3,Tn=4e3,En=1e3,Dn=4e3,On=1e4,kn=new Set([`schemaVersion`,`dir`]);function An(e){if(!Nn(e)||Object.keys(e).some(e=>!kn.has(e)))return;let t=e.schemaVersion,n=e.dir;if(t===2&&typeof n==`string`&&jn(n))return Object.freeze({schemaVersion:2,dir:n})}function jn(e){if(e===``||e!==e.trim()||Mn(e))return!1;let t=e.replace(/\\/g,`/`);return t.startsWith(`/`)||/^[A-Za-z]:\//u.test(t)}function Mn(e){for(let t of e){let e=t.charCodeAt(0);if(e<32||e===127)return!0}return!1}function Nn(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Pn(e){if(typeof e!=`object`||!e||Array.isArray(e))return;let t=Reflect.get(e,`kind`);if(t===`workspaceRemovalCommandFailed`)return{kind:t};let n=Reflect.get(e,`detail`);if(t===`workspaceRemovalFailed`&&typeof n==`string`&&n.length<=4096)return{kind:t,detail:n}}function Fn(e){if(typeof e!=`object`||!e||Array.isArray(e))return;let t=Reflect.get(e,`kind`),n=Reflect.get(e,`label`),r=Reflect.get(e,`path`);return t===`gitWorktree`&&typeof n==`string`&&typeof r==`string`?Object.freeze({kind:t,label:n,path:r}):void 0}var In=[`forkCancelled`,`forked`,`nameUsage`,`requestExpired`,`reloadActive`,`reloadUnavailable`,`reloaded`,`cloneEmpty`,`cloneCancelled`,`cloned`,`forkEmpty`,`forkSelect`,`treeActive`,`treeEmpty`,`treeUnavailable`,`navigationActive`];function Ln(e){if(!Rn(e)||e.kind!==`commandResult`||!Rn(e.feedback))return;let t=e.feedback,n=t.code;if(typeof n!=`string`)return;let r=In.find(e=>e===n);if(r!==void 0)return{kind:`commandResult`,feedback:{code:r}};switch(n){case`unknown`:case`notImplemented`:if(typeof t.command==`string`)return{kind:`commandResult`,feedback:{code:n,command:t.command}};break;case`named`:if(typeof t.name==`string`)return{kind:`commandResult`,feedback:{code:n,name:t.name}};break;case`reloadFailed`:case`treeFailed`:if(typeof t.detail==`string`)return{kind:`commandResult`,feedback:{code:n,detail:t.detail}};break;case`replacementActive`:if(t.command===`fork`||t.command===`clone`)return{kind:`commandResult`,feedback:{code:n,command:t.command}};break;case`stats`:{let e=t.stats;if(!Rn(e)||typeof e.sessionId!=`string`||!Rn(e.tokens))break;let{totalMessages:r,userMessages:i,assistantMessages:a,toolCalls:o,cost:s}=e,{input:c,output:l,total:u}=e.tokens;if(!x(r)||!x(i)||!x(a)||!x(o)||!x(s)||!x(c)||!x(l)||!x(u))break;return{kind:`commandResult`,feedback:{code:n,stats:{sessionId:e.sessionId,totalMessages:r,userMessages:i,assistantMessages:a,toolCalls:o,cost:s,tokens:{input:c,output:l,total:u}}}}}}}function x(e){return typeof e==`number`&&Number.isFinite(e)}function Rn(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function zn(e){if(typeof e!=`object`||!e||Array.isArray(e))return;let t=Reflect.get(e,`kind`);if(t===`modelAuthRemoved`){let n=Reflect.get(e,`provider`),r=Reflect.get(e,`model`);return typeof n==`string`&&typeof r==`string`?{kind:t,provider:n,model:r}:void 0}if(t===`sessionNamingFailed`){let n=Reflect.get(e,`detail`);return typeof n==`string`?{kind:t,detail:n}:void 0}}var Bn={compactionCancelled:`Compaction cancelled.`,automaticCompactionCancelled:`Automatic compaction cancelled.`,compactionFailed:`Couldn’t compact history. Try again.`};function Vn(e){if(typeof e!=`object`||!e||Array.isArray(e))return;let t=Reflect.get(e,`kind`);if(t===`compactionCancelled`||t===`automaticCompactionCancelled`||t===`compactionFailed`)return{kind:t}}function Hn(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Un(e){return e===`message`||e===`user-message`||e===`assistant-response`||e===`assistant-error`||e===`assistant-aborted`||e===`hidden-custom-message`||e===`compaction-summary`||e===`branch-summary`}function Wn(e){return e===`shell`||e===`model`||e===`thinking-level`||e===`session-name`||e===`label`||e===`custom-entry`||e===`entry`}function Gn(e,t){return typeof e==`string`&&e.length<=t}function Kn(e){if(!Array.isArray(e)||e.length>720)return;let t=[],n=720;for(let r of e){if(!Hn(r))return;if(r.type===`text`&&Gn(r.text,n))t.push({type:`text`,text:r.text}),n-=r.text.length;else if(r.type===`image`&&n>0)t.push({type:`image`}),n-=7;else return}return t}function qn(e){if(!Hn(e))return;let t=e.type;switch(t){case`status`:return Un(e.status)?{type:t,status:e.status}:void 0;case`content`:{let n=Kn(e.parts);return n!==void 0&&Un(e.fallback)?{type:t,parts:n,fallback:e.fallback}:void 0}case`named`:{let n=e.field,r=e.value;return!Wn(n)||r!==void 0&&!Gn(r,n===`model`?161:80)?void 0:{type:t,field:n,...r===void 0?{}:{value:r}}}case`assistant-tools`:{let n=e.names;if(!Array.isArray(n)||n.length>3)return;let r=[];for(let e of n){if(!Gn(e,80))return;r.push(e)}return{type:t,names:r}}case`tool-result`:{let n=Kn(e.parts),r=e.isError,i=e.toolName;return n===void 0||typeof r!=`boolean`||i!==void 0&&!Gn(i,80)?void 0:{type:t,parts:n,isError:r,...i===void 0?{}:{toolName:i}}}case`custom-message`:{let n=Kn(e.parts),r=e.customType;return n===void 0||r!==void 0&&!Gn(r,80)?void 0:{type:t,parts:n,...r===void 0?{}:{customType:r}}}default:return}}var Jn=Object.values(b),Yn=new Set(Jn);b.sessionsDeleteArchived,b.sessionsBulkMutations,b.sessionsCleanup,b.sessionsReload,b.sessionsClearQueue,b.sessionsQueueMessageActions,b.sessionsPersistedState,b.sessionsNotifications,b.sessionsUnread,b.sessionsAskUser,b.promptAttachments,b.promptSpeechRecognition,b.workspaceFileSuggestions,b.piPackagesManage,b.selectedMachineSettings,b.agentProfileConfig,b.pluginLifecycle,b.sessionCleanupPinnedExclusions,b.sessionPinsDaemonOwned,b.sessionPinsManagementScoped,b.sessionsDeleteArchived,b.sessionsBulkMutations,b.sessionsCleanup,b.sessionsReload,b.sessionsClearQueue,b.sessionsQueueMessageActions,b.sessionsPersistedState,b.sessionsNotifications,b.sessionsUnread,b.sessionsAskUser,b.promptAttachments,b.promptSpeechRecognition,b.sessionCleanupPinnedExclusions,b.sessionPinsDaemonOwned,b.sessionPinsManagementScoped,b.sessionsDeleteArchived,b.sessionsBulkMutations,b.sessionsCleanup,b.sessionsReload,b.sessionsClearQueue,b.sessionsQueueMessageActions,b.sessionsPersistedState,b.sessionsNotifications,b.sessionsUnread,b.sessionsAskUser,b.promptAttachments,b.promptSpeechRecognition,b.workspaceFileSuggestions,b.piPackagesManage,b.selectedMachineSettings,b.agentProfileConfig,b.pluginLifecycle,b.sessionCleanupPinnedExclusions,b.sessionPinsDaemonOwned,b.sessionPinsManagementScoped;function Xn(e){return typeof e==`string`&&Yn.has(e)}function Zn(e,t){return e?.capabilities?.includes(t)===!0}function Qn(e){if(Array.isArray(e)&&e.every(e=>typeof e==`string`))return e.filter(Xn)}function $n(e){if(!Array.isArray(e))return;let t=[];for(let n of e){if(!er(n))continue;let e=n.source,r=n.name,i=n.replacement;(e===`environment`||e===`config`)&&typeof r==`string`&&r!==``&&(i===void 0||typeof i==`string`&&i!==``)&&t.push({source:e,name:r,...i===void 0?{}:{replacement:i}})}return t}function er(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var tr=[`projectId`,`workspaceId`,`sessionId`];function nr(e,t){if(!ir(e))throw Error(`${t} must be an object`);let n=!1;for(let r in e)if(Object.hasOwn(e,r)&&(n=!0,!rr(r)))throw Error(`Unsupported ${t} field: ${r}`);if(!n)throw Error(`${t} must contain at least one of projectId, workspaceId, or sessionId`);let r={};for(let n of tr){if(!Object.hasOwn(e,n))continue;let i=e[n];if(typeof i!=`string`||i.length>512||i.trim()===``)throw Error(`${t} ${n} must be a non-empty string of at most 512 characters`);r[n]=i}if(r.projectId!==void 0)return Object.freeze({...r,projectId:r.projectId});if(r.workspaceId!==void 0)return Object.freeze({...r,workspaceId:r.workspaceId});if(r.sessionId!==void 0)return Object.freeze({...r,sessionId:r.sessionId});throw Error(`${t} must contain at least one visibility selector`)}function rr(e){return tr.some(t=>t===e)}function ir(e){if(typeof e!=`object`||!e||Array.isArray(e))return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}var ar={working:`core:working`,terminal:`core:terminal`,unread:`core:unread`,interventionRequired:`core:intervention-required`};function or(e){if(!lr(e))return;let t=e.epochId,n=e.revision,r=e.generatedAt,i=sr(e.machine),a=sr(e.unattributed),o=cr(e.projects),s=cr(e.workspaces);if(typeof t!=`string`||t===``||typeof n!=`number`||!Number.isFinite(n)||typeof r!=`string`||r===``||i===void 0||a===void 0||o===void 0||s===void 0)return;let c={epochId:t,revision:n,machine:i,projects:o,workspaces:s,unattributed:a,generatedAt:r};if(Object.hasOwn(e,`sessions`)){let t=cr(e.sessions,!0);if(t===void 0)return;c.sessions=t}return c}function sr(e){if(!lr(e))return;let t=new Map;for(let[n,r]of Object.entries(e))typeof r==`boolean`&&t.set(n,r);return Object.fromEntries(t)}function cr(e,t=!1){if(!lr(e))return;let n=new Map;for(let[r,i]of Object.entries(e)){let e=sr(i);if(e===void 0&&t)return;e!==void 0&&n.set(r,e)}return Object.fromEntries(n)}function lr(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var ur={compacting:`compacting`,duplicateQueuedMessage:`duplicate queued message ignored`,steeringQueued:`steering queued`,messageQueued:`message queued`,promptAccepted:`prompt accepted`,error:`error`,queuedDuringCompaction:`message queued during compaction`,runningBash:`running bash`,bashComplete:`bash complete`,bashFailed:`bash failed`,summarizingBranch:`summarizing branch`,navigatingTree:`navigating session tree`,branchSummaryAborted:`branch summary aborted`,treeNavigationCancelled:`tree navigation cancelled`,treeNavigated:`session tree navigated`,treeNavigationFailed:`tree navigation failed`,forking:`forking session from entry`,forkCancelled:`fork cancelled`,forked:`session forked`,forkFailed:`fork failed`,reloading:`reloading resources`,reloaded:`resources reloaded`,reloadFailed:`reload failed`,stopped:`stopped`,stopFailed:`stop failed`,extensionError:`extension error`,extensionCallbackFailed:`extension callback failed`,compactionCancelled:`compaction cancelled`,compactionComplete:`compaction complete`,compactionFailed:`compaction failed`,updatingSession:`updating session`,agentRunning:`agent running`,queued:`queued`,active:`active`,idle:`idle`,turnComplete:`turn complete`,messageStarted:`message started`,messageComplete:`message complete`,receivingResponse:`receiving response`,runningTool:`running tool`,toolFailed:`tool failed`,toolComplete:`tool complete`};function dr(e){return Object.hasOwn(ur,e)}function fr(e){if(typeof e!=`object`||!e||!(`kind`in e))return;let{kind:t}=e;if(t===`model`||t===`thinking`||t===`event`)return`value`in e&&typeof e.value==`string`?{kind:t,value:e.value}:void 0;if(typeof t!=`string`||!dr(t))return;let n=`detailKind`in e?e.detailKind:void 0;if(n===void 0||n===`compactionCancelled`||n===`automaticCompactionCancelled`||n===`compactionFailed`)return{kind:t,...n===void 0?{}:{detailKind:n}}}var S=Object.freeze({showSafeStart:`pi-web plugins safe-start show`,bundledOnly:`pi-web plugins safe-start set bundled-only --restart`,noServerPlugins:`pi-web plugins safe-start set none --restart`,clearSafeStart:`pi-web plugins safe-start clear --restart`});function pr(e){if(!mn(e))throw Error(`Invalid PI WEB plugin id: ${e}`);return`pi-web plugins disable ${e} --restart`}function C(e){return typeof e==`object`&&!!e}function w(e){if(!C(e))throw Error(`Expected object response`);return e}function T(e,t){let n=e[t];if(typeof n!=`string`)throw Error(`Expected string field: ${t}`);return n}function E(e,t){let n=e[t];if(n!==void 0){if(typeof n!=`string`)throw Error(`Expected optional string field: ${t}`);return n}}function D(e,t){let n=e[t];if(typeof n!=`number`)throw Error(`Expected number field: ${t}`);return n}function O(e,t){let n=e[t];if(typeof n!=`boolean`)throw Error(`Expected boolean field: ${t}`);return n}function k(e){return t=>{if(!Array.isArray(t))throw Error(`Expected array response`);return t.map(e)}}function mr(e){if(!Array.isArray(e))throw Error(`Expected array response`);return e.map(e=>{if(typeof e==`object`&&e&&`entryId`in e&&e.entryId!==void 0&&typeof e.entryId!=`string`)throw Error(`Expected string field: entryId`);return e})}function A(e,t){if(!Array.isArray(e)||!e.every(e=>typeof e==`string`))throw Error(`Expected string array field: ${t}`);return e}function hr(e){let t=w(e),n=t.leafId;if(n!=null&&typeof n!=`string`)throw Error(`Expected optional string|null field: leafId`);return{messages:mr(t.messages),start:D(t,`start`),total:D(t,`total`),...W(`leafId`,n)}}function gr(e){let t=w(e);return k(_r)(t.machines)}function _r(e){let t=w(e),n=xr(t,`kind`),r=E(t,`baseUrl`),i=Sr(t,`status`),a=E(t,`statusMessage`);return{id:T(t,`id`),name:T(t,`name`),...W(`nameOverride`,E(t,`nameOverride`)),...W(`reportedName`,E(t,`reportedName`)),kind:n,...r===void 0?{}:{baseUrl:r},createdAt:T(t,`createdAt`),updatedAt:T(t,`updatedAt`),...i===void 0?{}:{status:i},...a===void 0?{}:{statusMessage:a}}}function vr(e){let t=w(e),n=Sr(t,`status`),r=E(t,`error`);return{machineId:T(t,`machineId`),ok:O(t,`ok`),checkedAt:T(t,`checkedAt`),...n===void 0?{}:{status:n},...t.web===void 0?{}:{web:Do(t.web)},...t.sessiond===void 0?{}:{sessiond:Do(t.sessiond)},...r===void 0?{}:{error:r}}}function yr(e){let t=w(e),n=E(t,`error`);return{machineId:T(t,`machineId`),ok:O(t,`ok`),checkedAt:T(t,`checkedAt`),...W(`packageName`,E(t,`packageName`)),...W(`generatedAt`,E(t,`generatedAt`)),...t.components===void 0?{}:{components:To(t.components)},...t.capabilities===void 0?{}:{capabilities:No(t.capabilities)},...t.deprecatedAgentInputs===void 0?{}:{deprecatedAgentInputs:br(t.deprecatedAgentInputs)},...n===void 0?{}:{error:n}}}function br(e){let t=$n(e);if(t===void 0)throw Error(`Invalid PI WEB deprecated agent inputs`);return t}function xr(e,t){let n=T(e,t);if(n!==`local`&&n!==`remote`)throw Error(`Expected machine kind field: ${t}`);return n}function Sr(e,t){let n=E(e,t);if(n!==void 0){if(n!==`unknown`&&n!==`online`&&n!==`offline`&&n!==`error`)throw Error(`Expected machine status field: ${t}`);return n}}function Cr(e){let t=w(e);return{id:T(t,`id`),name:T(t,`name`),path:T(t,`path`),createdAt:T(t,`createdAt`)}}function wr(e){let t=w(e);return Object.freeze({id:T(t,`id`),projectId:T(t,`projectId`),path:T(t,`path`),label:T(t,`label`),isMain:O(t,`isMain`),...W(`branch`,E(t,`branch`)),...W(`isGitRepo`,H(t,`isGitRepo`)),...W(`isGitWorktree`,H(t,`isGitWorktree`)),...W(`provider`,Ar(t.provider)),...W(`removal`,jr(t.removal)),effectiveConfig:Pr(t.effectiveConfig)})}function Tr(e){let t=w(e),n=Er(t.status),r=T(t,`projectId`),i=E(t,`ownerPluginId`);if(n===`provider`&&i===void 0)throw Error(`Provider workspace resolution is missing ownerPluginId`);if(n===`folder`&&i!==void 0)throw Error(`Folder workspace resolution must not include ownerPluginId`);let a=k(wr)(t.workspaces);if(a.length===0||a.some(e=>e.projectId!==r))throw Error(`Workspace resolution contains invalid project workspaces`);let o=k(Dr)(t.diagnostics);return Object.freeze({status:n,projectId:r,...i===void 0?{}:{ownerPluginId:i},workspaces:Object.freeze(a),diagnostics:Object.freeze(o)})}function Er(e){if(e===`provider`||e===`folder`||e===`degraded`)return e;throw Error(`Invalid workspace provider resolution status`)}function Dr(e){let t=w(e),n=E(t,`pluginId`),r=t.pluginIds===void 0?void 0:A(t.pluginIds,`pluginIds`);return Object.freeze({code:Or(t.code),message:T(t,`message`),tier:kr(t.tier),...n===void 0?{}:{pluginId:n},...r===void 0?{}:{pluginIds:Object.freeze(r)}})}function Or(e){if(e===`probe-failed`||e===`claim-conflict`||e===`list-failed`)return e;throw Error(`Invalid workspace provider diagnostic code`)}function kr(e){if(e===`primary`||e===`fallback`)return e;throw Error(`Invalid workspace provider diagnostic tier`)}function Ar(e){if(e===void 0)return;if(!C(e)||Array.isArray(e))throw Error(`Invalid workspace provider field`);let t=e.capabilities;if(!C(t)||Array.isArray(t))throw Error(`Invalid workspace provider capabilities field`);let n=e.metadata;return Object.freeze({pluginId:T(e,`pluginId`),capabilities:Object.freeze({remove:O(t,`remove`),...W(`request`,H(t,`request`))}),...W(`metadata`,n===void 0?void 0:Mr(n,`workspace provider metadata`))})}function jr(e){if(e!==void 0){if(!C(e)||Array.isArray(e))throw Error(`Invalid workspace removal field`);return Object.freeze({actionLabel:I(e,`actionLabel`),confirmation:I(e,`confirmation`),precondition:I(e,`precondition`),...W(`localization`,Fn(e.localization))})}}function Mr(e,t){if(!C(e)||Array.isArray(e))throw Error(`Invalid ${t} field`);return Object.freeze(Object.fromEntries(Object.entries(e).map(([e,n])=>[e,Nr(n,t)])))}function Nr(e,t){if(e===null||typeof e==`string`||typeof e==`boolean`||typeof e==`number`&&Number.isFinite(e))return e;if(Array.isArray(e))return Object.freeze(e.map(e=>Nr(e,t)));if(C(e))return Mr(e,t);throw Error(`Invalid ${t} field`)}function Pr(e){if(!C(e)||Array.isArray(e))throw Error(`Expected workspace effectiveConfig field`);let t=Xa(e.uploads),n=Za(e.attachments);return Object.freeze({...W(`uploads`,t===void 0?void 0:Object.freeze({...t})),...W(`attachments`,n===void 0?void 0:Object.freeze({...n}))})}function Fr(e){if(!C(e)||Array.isArray(e))throw Error(`Invalid session metadata field`);return Object.freeze(Object.fromEntries(Object.entries(e).map(([e,t])=>[e,Mr(t,`session metadata namespace`)])))}function j(e){let t=w(e),n=E(t,`name`),r=t.metadata===void 0?void 0:Fr(t.metadata),i=B(t.persisted,`persisted`),a=E(t,`parentSessionPath`),o=E(t,`archivedAt`);return{id:T(t,`id`),path:T(t,`path`),cwd:T(t,`cwd`),...i===void 0?{}:{persisted:i},...W(`interventionRequired`,B(t.interventionRequired,`interventionRequired`)),...W(`agentSubsession`,B(t.agentSubsession,`agentSubsession`)),...n===void 0?{}:{name:n},...r===void 0?{}:{metadata:r},created:T(t,`created`),modified:T(t,`modified`),messageCount:D(t,`messageCount`),firstMessage:T(t,`firstMessage`),...a===void 0?{}:{parentSessionPath:a},...W(`agentSubsession`,H(t,`agentSubsession`)),...t.archived===!0?{archived:!0}:{},...o===void 0?{}:{archivedAt:o}}}function Ir(e){let t=w(e);return{configured:O(t,`configured`),authenticated:O(t,`authenticated`)}}function Lr(e){return{path:T(w(e),`path`)}}function Rr(e){let t=w(e);if(t.deleted!==!0)throw Error(`Expected deleted response`);return{deleted:!0,path:T(t,`path`)}}function zr(e){let t=w(e);return{results:k(Br)(t.results),matchCount:D(t,`matchCount`),truncated:O(t,`truncated`)}}function Br(e){let t=w(e);return{session:j(t.session),matches:k(Vr)(t.matches)}}function Vr(e){let t=w(e),n=T(t,`role`);if(n!==`user`&&n!==`assistant`)throw Error(`Invalid session content search role`);return{messageIndex:D(t,`messageIndex`),role:n,excerpts:k(Hr)(t.excerpts),occurrenceCount:D(t,`occurrenceCount`)}}function Hr(e){let t=w(e);return{text:T(t,`text`),matchRanges:k(e=>{let t=w(e);return{start:D(t,`start`),length:D(t,`length`)}})(t.matchRanges)}}function Ur(e){if(e!==`info`&&e!==`warning`&&e!==`error`)throw Error(`Invalid session warning severity`);return e}function Wr(e){if(e!==void 0)return{id:T(w(e),`id`)}}function Gr(e){let t=w(e),n=Wr(t.dismiss);return{severity:Ur(t.severity),message:T(t,`message`),...C(t.presentation)&&t.presentation.kind===`anthropicSubscriptionAuth`?{presentation:{kind:`anthropicSubscriptionAuth`}}:{},...W(`source`,E(t,`source`)),...W(`path`,E(t,`path`)),...n===void 0?{}:{dismiss:n}}}function Kr(e){let t=`Recently active in another PI-WEB instance. Avoid working on this session in both instances at once.`;return e.severity===`info`&&e.source===`PI-WEB`&&(e.message===t||e.message===y(`ui.sessionActivity.message`,t))}function qr(e){let t=w(e);return{value:N(t,`value`,128),label:N(t,`label`,Cn),...W(`detail`,P(t,`detail`,Cn))}}function Jr(e){let t=w(e),n=F(t.options,qr,12,`options`);ei(n.map(e=>e.value),`ask option value`),B(t.allowOther,`allowOther`);let r=B(t.multiple,`multiple`);return{id:N(t,`id`,128),question:N(t,`question`,Cn),...W(`detail`,P(t,`detail`,Cn)),options:n,allowOther:!0,...r===void 0?{}:{multiple:r}}}function Yr(e){let t=w(e),n=F(t.questions,Jr,20,`questions`);if(n.length===0)throw Error(`Ask has no questions`);return ei(n.map(e=>e.id),`ask question id`),{askId:N(t,`askId`,128),askedAt:I(t,`askedAt`),questions:n}}function Xr(e){if(e!==`submitted`&&e!==`superseded`&&e!==`cancelled`)throw Error(`Invalid ask close reason`);return e}function Zr(e){let t=w(e),n=Jr(t.question),r=F(t.values,Ui,12,`values`),i=new Set(n.options.map(e=>e.value));if(r.some(e=>!i.has(e)))throw Error(`Ask answer selected an option the question never offered`);let a=P(t,`otherText`,wn),o=P(t,`comment`,Tn),s=O(t,`answered`);if(s!==(r.length>0||a!==void 0))throw Error(`Ask answer contradicts its answered flag`);return{question:n,answered:s,values:r,...a===void 0?{}:{otherText:a},...o===void 0?{}:{comment:o}}}function Qr(e){let t=w(e),n=F(t.questions,Zr,20,`questions`),r=L(t,`answeredCount`),i=A(t.unansweredIds,`unansweredIds`),a=n.filter(e=>!e.answered).map(e=>e.question.id);if(r!==n.length-a.length)throw Error(`Ask outcome answered count mismatch`);if(i.length!==a.length||i.some((e,t)=>e!==a[t]))throw Error(`Ask outcome unanswered ids mismatch`);return{askId:N(t,`askId`,128),reason:Xr(t.reason),askedAt:I(t,`askedAt`),closedAt:I(t,`closedAt`),questions:n,answeredCount:r,unansweredIds:i,summary:I(t,`summary`)}}function $r(e){let t=w(e),n=t.result;if(n!==`closed`&&n!==`stale`)throw Error(`Invalid dialog close result`);let r=t.outcome===void 0?void 0:li(t.outcome);if(n===`closed`!=(r!==void 0))throw Error(`Dialog close response outcome mismatch`);return{result:n,...r===void 0?{}:{outcome:r},sessionStatus:M(t.sessionStatus)}}function ei(e,t){if(new Set(e).size!==e.length)throw Error(`Duplicate ${t}`)}function ti(e){if(e!==`confirm`&&e!==`select`&&e!==`input`)throw Error(`Invalid extension dialog kind`);return e}function ni(e){if(e!==`answered`&&e!==`cancelled`&&e!==`timeout`&&e!==`aborted`&&e!==`session-ended`)throw Error(`Invalid extension dialog close reason`);return e}function ri(e){if(typeof e==`boolean`||typeof e==`string`&&e.length<=4e3)return e;throw Error(`Invalid extension dialog answer`)}function ii(e){let t=Ui(e);if(t.length>1e3)throw Error(`String field exceeds limit: option`);return t}function ai(e){let t=w(e),n=ti(t.kind),r=t.options===void 0?void 0:F(t.options,ii,24,`options`);if(r!==void 0&&ei(r,`dialog option`),n===`select`&&(r===void 0||r.length===0))throw Error(`Select dialog has no options`);return{dialogId:N(t,`dialogId`,128),kind:n,title:N(t,`title`,En),...W(`message`,P(t,`message`,En)),...r===void 0?{}:{options:r},...W(`placeholder`,P(t,`placeholder`,En)),askedAt:I(t,`askedAt`),...W(`timeoutAt`,ui(t,`timeoutAt`)),runScoped:O(t,`runScoped`)}}function oi(e){if(e===void 0)return{};let t=k(ai)(e);return ei(t.map(e=>e.dialogId),`dialog id`),{pendingDialogs:t}}function si(e){let t=w(e);if(t.type!==`dialog.opened`)throw Error(`Invalid dialog opened event type`);return{type:`dialog.opened`,dialog:ai(t.dialog)}}function ci(e){let t=w(e);if(t.type!==`dialog.closed`)throw Error(`Invalid dialog closed event type`);let n=ni(t.reason),r=t.answer===void 0?void 0:ri(t.answer);if(n===`answered`!=(r!==void 0))throw Error(`Dialog closed event answer mismatch`);return{type:`dialog.closed`,dialogId:N(t,`dialogId`,128),reason:n,...r===void 0?{}:{answer:r}}}function li(e){let t=w(e),n=ni(t.reason),r=t.answer===void 0?void 0:ri(t.answer);if(n===`answered`!=(r!==void 0))throw Error(`Dialog outcome answer mismatch`);return{dialogId:N(t,`dialogId`,128),reason:n,...r===void 0?{}:{answer:r},askedAt:I(t,`askedAt`),closedAt:I(t,`closedAt`)}}function ui(e,t){let n=E(e,t);if(n!==void 0){if(n===``)throw Error(`Expected non-empty string field: ${t}`);return n}}function M(e){let t=w(e),n=t.warnings===void 0?void 0:k(Gr)(t.warnings),r=B(t.recentlyActiveElsewhere,`recentlyActiveElsewhere`);return{sessionId:T(t,`sessionId`),...W(`persisted`,B(t.persisted,`persisted`)),recentlyActiveElsewhere:r??n?.some(Kr)??!1,...W(`interventionRequired`,B(t.interventionRequired,`interventionRequired`)),isStreaming:O(t,`isStreaming`),isCompacting:O(t,`isCompacting`),isBashRunning:O(t,`isBashRunning`),pendingMessageCount:D(t,`pendingMessageCount`),queuedMessages:t.queuedMessages===void 0?[]:k(na)(t.queuedMessages),...W(`queueMessageActionsUnavailable`,E(t,`queueMessageActionsUnavailable`)),...W(`messageCount`,U(t,`messageCount`)),tokens:ra(t.tokens),cost:D(t,`cost`),...aa(t.model),...Ta(t.contextUsage),...W(`thinkingLevel`,E(t,`thinkingLevel`)),...W(`warnings`,n?.filter(e=>!Kr(e))),...oi(t.pendingDialogs),...W(`suggestedInput`,E(t,`suggestedInput`))}}function di(e){let t=w(e);return{seq:D(t,`seq`),partial:t.partial??null}}function fi(e){let t=w(e);if(t.partial===void 0)throw Error(`Expected field: partial`);return{page:hr(t.page),status:M(t.status),seq:L(t,`seq`),partial:t.partial}}function pi(e){let t=w(e),n=L(t,`catalogRevision`),r=F(t.sessions,Ei,yn,`sessions`);if(Di(r),Oi(r),r.some(e=>e.completionOrder>n))throw Error(`Session unread completion order exceeds catalog revision`);return{catalogId:N(t,`catalogId`,512),catalogRevision:n,sessions:r}}function mi(e){let t=w(e);if(t.type!==`sessions.unread`)throw Error(`Invalid session unread event type`);let n=N(t,`sessionId`,512),r=N(t,`cwd`,bn),i=ki(t,`catalogRevision`),a=t.unread===null?null:Ei(t.unread);if(a!==null&&(a.sessionId!==n||a.cwd!==r))throw Error(`Session unread event identity mismatch`);if(a!==null&&a.completionOrder>i)throw Error(`Session unread completion order exceeds catalog revision`);return{type:`sessions.unread`,catalogId:N(t,`catalogId`,512),catalogRevision:i,sessionId:n,cwd:r,unread:a}}function hi(e){let t=w(e);if(t.type!==`session.startup`)throw Error(`Invalid session startup event type`);let n=E(t,`startupToken`);if(n===``)throw Error(`Expected non-empty string field: startupToken`);return{type:`session.startup`,...W(`startupToken`,n),activity:gi(t.activity)}}function gi(e){let t=w(e);return{sessionId:I(t,`sessionId`),phase:yi(t,`phase`),label:I(t,`label`),...W(`detail`,E(t,`detail`)),at:I(t,`at`),...W(`startup`,vi(t)),...W(`startupPresentation`,_i(t.startupPresentation)),...W(`runtimePresentation`,fr(t.runtimePresentation))}}function _i(e){if(!C(e))return;let{intent:t,stage:n,catalogRefreshing:r}=e;if(!(t!==`create`&&t!==`open`||n!==`runtime`&&n!==`extensions`||typeof r!=`boolean`))return{intent:t,stage:n,catalogRefreshing:r}}function vi(e){let t=e.startup;if(t!==void 0){if(typeof t!=`boolean`)throw Error(`Expected optional boolean field: startup`);return t}}function yi(e,t){let n=T(e,t);if(n!==`active`&&n!==`idle`&&n!==`error`)throw Error(`Expected session activity phase field: ${t}`);return n}function bi(e){let t=w(e);switch(t.type){case`message.append`:return{type:`message.append`,message:Si(t,`message`)};case`assistant.start`:return{type:`assistant.start`,message:Si(t,`message`)};case`assistant.delta`:return{type:`assistant.delta`,text:T(t,`text`),...W(`streamId`,E(t,`streamId`))};case`assistant.thinking.delta`:return{type:`assistant.thinking.delta`,text:T(t,`text`),...W(`streamId`,E(t,`streamId`))};case`tool.start`:return{type:`tool.start`,toolName:T(t,`toolName`),toolCallId:T(t,`toolCallId`),summary:T(t,`summary`),...W(`args`,t.args)};case`tool.update`:return{type:`tool.update`,toolName:T(t,`toolName`),toolCallId:T(t,`toolCallId`),text:T(t,`text`),...W(`content`,t.content),...W(`details`,t.details)};case`tool.end`:return{type:`tool.end`,toolName:T(t,`toolName`),toolCallId:T(t,`toolCallId`),text:T(t,`text`),isError:O(t,`isError`),...W(`content`,t.content),...W(`details`,t.details)};case`shell.start`:return{type:`shell.start`,command:T(t,`command`),...W(`excludeFromContext`,B(t.excludeFromContext,`excludeFromContext`))};case`shell.chunk`:return{type:`shell.chunk`,chunk:T(t,`chunk`)};case`shell.end`:return{type:`shell.end`,...W(`output`,E(t,`output`)),...W(`exitCode`,Ci(t,`exitCode`)),...W(`cancelled`,B(t.cancelled,`cancelled`)),...W(`truncated`,B(t.truncated,`truncated`)),...W(`fullOutputPath`,E(t,`fullOutputPath`)),...W(`isError`,B(t.isError,`isError`))};case`agent.start`:return{type:`agent.start`};case`agent.end`:return{type:`agent.end`};case`message.end`:return{type:`message.end`,...W(`message`,t.message)};case`status.update`:return{type:`status.update`,status:M(t.status)};case`activity.update`:return{type:`activity.update`,activity:gi(t.activity)};case`command.output`:return wi(t);case`session.error`:return{type:`session.error`,message:T(t,`message`)};case`session.diagnostic`:return{type:`session.diagnostic`,message:T(t,`message`)};case`session.name`:return Ti(t);case`session.created`:return{type:`session.created`,session:j(t.session)};case`session.tree.changed`:return{type:`session.tree.changed`};case`pi.event`:return{type:`pi.event`,eventType:T(t,`eventType`)};default:throw Error(`Unsupported session stream event type`)}}function xi(e){let t=w(e);switch(t.type){case`status.update`:return{type:`status.update`,status:M(t.status)};case`activity.update`:return{type:`activity.update`,activity:gi(t.activity)};case`session.name`:return Ti(t);case`session.created`:return{type:`session.created`,session:j(t.session)};case`models.changed`:return{type:`models.changed`,revision:L(t,`revision`)};case`workspaces.changed`:return{type:`workspaces.changed`,projectId:I(t,`projectId`)};case`session-pins.changed`:return{type:`session-pins.changed`,projectId:I(t,`projectId`),workspaceId:I(t,`workspaceId`),revision:L(t,`revision`)};case`notices.updated`:return Ni(t);case`machine.status`:return{type:`machine.status`,status:Ha(t.status)};default:throw Error(`Unsupported realtime stream event type`)}}function Si(e,t){let n=e[t];if(n===void 0)throw Error(`Expected field: ${t}`);return n}function Ci(e,t){let n=e[t];if(n!==void 0){if(n===null)return null;if(typeof n!=`number`)throw Error(`Expected optional number|null field: ${t}`);return n}}function wi(e){let t=T(e,`level`);if(t!==`info`&&t!==`success`&&t!==`error`)throw Error(`Invalid command output level`);return{type:`command.output`,level:t,message:T(e,`message`),...W(`presentation`,zn(e.presentation))}}function Ti(e){return{type:`session.name`,sessionId:I(e,`sessionId`),...W(`name`,E(e,`name`))}}function Ei(e){let t=w(e),n=N(t,`completedAt`,64),r=new Date(n);if(!Number.isFinite(r.getTime())||r.toISOString()!==n)throw Error(`Invalid canonical session unread completion time`);let i=t.messageRange===void 0?void 0:w(t.messageRange),a;if(i!==void 0){let e=L(i,`start`),t=L(i,`end`),n=i.leafId;if(t<e||n!==null&&typeof n!=`string`)throw Error(`Invalid unread message range`);a={start:e,end:t,leafId:n}}return{sessionId:N(t,`sessionId`,512),cwd:N(t,`cwd`,bn),completionOrder:ki(t,`completionOrder`),completedAt:n,...a===void 0?{}:{messageRange:a}}}function Di(e){let t=e.map(e=>JSON.stringify([e.sessionId,e.cwd]));if(new Set(t).size!==t.length)throw Error(`Duplicate session unread identity`);let n=e.map(e=>e.completionOrder);if(new Set(n).size!==n.length)throw Error(`Duplicate session unread completion order`)}function Oi(e){for(let t=1;t<e.length;t+=1){let n=e[t-1],r=e[t];if(n===void 0||r===void 0||n.completionOrder<=r.completionOrder)throw Error(`Session unread summaries are not newest-first`)}}function N(e,t,n){let r=I(e,t);if(r.length>n)throw Error(`String field exceeds limit: ${t}`);return r}function P(e,t,n){let r=E(e,t);if(r!==void 0){if(r===``)throw Error(`Expected non-empty string field: ${t}`);if(r.length>n)throw Error(`String field exceeds limit: ${t}`);return r}}function ki(e,t){let n=L(e,t);if(n===0)throw Error(`Expected positive safe integer field: ${t}`);return n}function Ai(e){let t=w(e),n=Ii(t.summary),r=F(t.notifications,Li,100,`notifications`);if(Wi(r),Gi(r),n.retainedCount!==r.length)throw Error(`Notification snapshot retained count mismatch`);if(n.highestSeverity!==qi(r))throw Error(`Notification snapshot severity mismatch`);let i=Ri(t.dismissThrough),a=r[0]?.order??0;if(i.order!==a)throw Error(`Notification snapshot dismiss cutoff mismatch`);if(i.overflowWatermark<n.discardedCount)throw Error(`Notification snapshot overflow cutoff mismatch`);return{daemonInstanceId:I(t,`daemonInstanceId`),catalogRevision:L(t,`catalogRevision`),summary:n,notifications:r,dismissThrough:i}}function ji(e){let t=w(e);if(t.type!==`notifications.inbox`)throw Error(`Invalid notification inbox event type`);let n=Ii(t.summary),r=Ri(t.dismissThrough);if(r.overflowWatermark<n.discardedCount)throw Error(`Notification event overflow cutoff mismatch`);let i=zi(t.delta);if(i.kind===`cleared`&&!Ki(n))throw Error(`Notification clear event summary mismatch`);if(i.kind===`added`&&n.retainedCount===0)throw Error(`Notification add event summary mismatch`);return{type:`notifications.inbox`,daemonInstanceId:I(t,`daemonInstanceId`),catalogRevision:L(t,`catalogRevision`),summary:n,dismissThrough:r,delta:i}}function Mi(e){let t=w(e),n=k(Pi)(t.notices),r=n.map(e=>e.id);if(new Set(r).size!==r.length)throw Error(`Duplicate server notice id`);return{daemonInstanceId:I(t,`daemonInstanceId`),revision:L(t,`revision`),notices:n}}function Ni(e){let t=w(e);if(t.type!==`notices.updated`)throw Error(`Invalid server notice event type`);return{type:`notices.updated`,snapshot:Mi(t.snapshot)}}function Pi(e){let t=w(e),n=Pn(t.presentation),r=I(t,`createdAt`);if(!Number.isFinite(Date.parse(r)))throw Error(`Invalid server notice creation time`);let i=E(t,`source`),a=t.context===void 0?void 0:Mr(t.context,`server notice context`),o=t.scope===void 0?void 0:nr(t.scope,`server notice scope`);return{id:I(t,`id`),severity:Fi(t.severity),...W(`presentation`,n),message:T(t,`message`),createdAt:r,...W(`source`,i),...W(`scope`,o),...W(`context`,a)}}function Fi(e){if(e!==`info`&&e!==`warning`&&e!==`error`)throw Error(`Invalid server notice severity`);return e}function Ii(e){let t=w(e),n=L(t,`retainedCount`);if(n>100)throw Error(`Notification retained count exceeds limit`);let r=L(t,`discardedCount`),i=Vi(t.highestSeverity);if(n===0!=(i===void 0))throw Error(`Notification summary severity mismatch`);return{sessionId:I(t,`sessionId`),cwd:I(t,`cwd`),inboxRevision:L(t,`inboxRevision`),retainedCount:n,discardedCount:r,...i===void 0?{}:{highestSeverity:i}}}function Li(e){let t=w(e),n=T(t,`message`);if(new TextEncoder().encode(n).byteLength>8192)throw Error(`Notification message exceeds byte limit`);let r=T(t,`receivedAt`);if(!Number.isFinite(Date.parse(r)))throw Error(`Invalid notification receive time`);let i=L(t,`order`);if(i===0)throw Error(`Invalid notification order`);return{id:I(t,`id`),message:n,...W(`presentation`,Vn(t.presentation)),truncated:O(t,`truncated`),severity:Bi(t.severity),receivedAt:r,order:i}}function Ri(e){let t=w(e);return{order:L(t,`order`),overflowWatermark:L(t,`overflowWatermark`)}}function zi(e){let t=w(e);switch(t.kind){case`added`:{let e=E(t,`evictedNotificationId`);return{kind:`added`,notification:Li(t.notification),...e===void 0?{}:{evictedNotificationId:e}}}case`dismissed`:{let e=F(t.notificationIds,Ui,100,`notificationIds`);if(new Set(e).size!==e.length)throw Error(`Duplicate dismissed notification id`);return{kind:`dismissed`,notificationIds:e}}case`cleared`:return{kind:`cleared`,reason:Hi(t.reason)};case`resync`:return{kind:`resync`};default:throw Error(`Invalid notification inbox delta`)}}function Bi(e){if(e!==`info`&&e!==`warning`&&e!==`error`)throw Error(`Invalid notification severity`);return e}function Vi(e){return e===void 0?void 0:Bi(e)}function Hi(e){switch(e){case`runtime-close`:case`archive`:case`delete`:case`restore`:case`archive-reconcile`:case`replacement`:case`initialization-failed`:case`service-dispose`:return e;default:throw Error(`Invalid notification clear reason`)}}function F(e,t,n,r){if(!Array.isArray(e))throw Error(`Expected array field: ${r}`);if(e.length>n)throw Error(`Array field exceeds limit: ${r}`);return e.map(t)}function Ui(e){if(typeof e!=`string`||e===``)throw Error(`Expected non-empty string`);return e}function I(e,t){let n=T(e,t);if(n===``)throw Error(`Expected non-empty string field: ${t}`);return n}function L(e,t){let n=e[t];if(typeof n!=`number`||!Number.isSafeInteger(n)||n<0)throw Error(`Expected non-negative safe integer field: ${t}`);return n}function Wi(e){if(new Set(e.map(e=>e.id)).size!==e.length)throw Error(`Duplicate notification id`);if(new Set(e.map(e=>e.order)).size!==e.length)throw Error(`Duplicate notification order`)}function Gi(e){for(let t=1;t<e.length;t+=1){let n=e[t-1],r=e[t];if(n===void 0||r===void 0||n.order<=r.order)throw Error(`Notifications are not newest-first`)}}function Ki(e){return e.retainedCount===0&&e.discardedCount===0}function qi(e){let t;for(let n of e){if(n.severity===`error`)return`error`;n.severity===`warning`?t=`warning`:t??=`info`}return t}function Ji(e){let t=w(e),n=t.skippedBusySessionIds===void 0?void 0:A(t.skippedBusySessionIds,`skippedBusySessionIds`),r=t.skippedPinnedSessionIds===void 0?void 0:A(t.skippedPinnedSessionIds,`skippedPinnedSessionIds`);return{generatedAt:T(t,`generatedAt`),thresholds:$i(t.thresholds),projects:k(ea)(t.projects),totals:ta(t.totals),...n===void 0?{}:{skippedBusySessionIds:n},...r===void 0?{}:{skippedPinnedSessionIds:r}}}function Yi(e){let t=w(e);return{...Ji(t),archivedSessionIds:A(t.archivedSessionIds,`archivedSessionIds`),deletedSessionIds:A(t.deletedSessionIds,`deletedSessionIds`)}}function Xi(e){let t=w(e);if(t.archived!==!0)throw Error(`Expected bulk archived response`);return{archived:!0,archivedSessionIds:A(t.archivedSessionIds,`archivedSessionIds`),failures:k(Qi)(t.failures),generatedAt:T(t,`generatedAt`)}}function Zi(e){let t=w(e);if(t.deleted!==!0)throw Error(`Expected bulk deleted response`);return{deleted:!0,deletedSessionIds:A(t.deletedSessionIds,`deletedSessionIds`),failures:k(Qi)(t.failures),generatedAt:T(t,`generatedAt`)}}function Qi(e){let t=w(e);return{sessionId:T(t,`sessionId`),error:T(t,`error`)}}function $i(e){let t=w(e);return{...W(`archiveIdleDays`,U(t,`archiveIdleDays`)),...W(`deleteArchivedDays`,U(t,`deleteArchivedDays`))}}function ea(e){let t=w(e);return{cwd:T(t,`cwd`),archiveCount:D(t,`archiveCount`),deleteCount:D(t,`deleteCount`)}}function ta(e){let t=w(e);return{archiveCount:D(t,`archiveCount`),deleteCount:D(t,`deleteCount`)}}function na(e){let t=w(e),n=T(t,`kind`);if(n!==`steer`&&n!==`followUp`)throw Error(`Invalid queued message kind`);return{kind:n,text:T(t,`text`),...W(`hasAttachments`,H(t,`hasAttachments`)),...W(`attachmentCount`,t.attachmentCount===void 0?void 0:L(t,`attachmentCount`))}}function ra(e){let t=w(e);return{input:D(t,`input`),output:D(t,`output`),cacheRead:D(t,`cacheRead`),cacheWrite:D(t,`cacheWrite`),total:D(t,`total`)}}function ia(e){let t=w(e);return{...W(`provider`,E(t,`provider`)),...W(`id`,E(t,`id`)),...W(`name`,E(t,`name`)),...W(`contextWindow`,U(t,`contextWindow`)),...W(`reasoning`,t.reasoning)}}function aa(e){return e===void 0?{}:{model:ia(e)}}function oa(e){let t=w(e);return{models:k(ia)(t.models)}}function sa(e){let t=w(e);return{provider:T(t,`provider`),id:T(t,`id`),...W(`name`,E(t,`name`)),...W(`contextWindow`,U(t,`contextWindow`)),...W(`reasoning`,t.reasoning),enabled:O(t,`enabled`),...W(`editable`,H(t,`editable`)),...W(`catalogIndex`,t.catalogIndex===void 0?void 0:L(t,`catalogIndex`))}}function ca(e){let t=w(e);return{models:k(sa)(t.models)}}function la(e){if(typeof e!=`string`)throw Error(`Invalid thinking level`);return e}function ua(e){let t=w(e);return{levels:k(la)(t.levels)}}function da(e){if(e!==`oauth`&&e!==`api_key`)throw Error(`Invalid auth type`);return e}function fa(e){if(e!==`stored`&&e!==`runtime`&&e!==`environment`&&e!==`fallback`&&e!==`models_json_key`&&e!==`models_json_command`)throw Error(`Invalid auth status source`);return e}function pa(e){let t=w(e),n=t.source===void 0?void 0:fa(t.source);return{configured:O(t,`configured`),...W(`source`,n),...W(`label`,E(t,`label`))}}function ma(e){let t=w(e),n=t.loginFlow;if(n!==void 0&&n!==`interactive`)throw Error(`Invalid auth provider login flow`);return{id:T(t,`id`),name:T(t,`name`),authType:da(t.authType),status:pa(t.status),...n===void 0?{}:{loginFlow:n}}}function ha(e){let t=w(e);return{providers:k(ma)(t.providers)}}function ga(e){let t=w(e);return{servers:k(e=>{let t=w(e);return{name:T(t,`name`),...W(`description`,E(t,`description`))}})(t.servers)}}function R(e){let t=w(e),n=t.target;if(n!==void 0&&n!==`mcp`)throw Error(`Invalid login flow target`);let r=t.mcpMode;if(r!==void 0&&r!==`login`&&r!==`logout`)throw Error(`Invalid MCP authentication mode`);let i={flowId:T(t,`flowId`),providerId:T(t,`providerId`),providerName:T(t,`providerName`),...n===void 0?{}:{target:n},...r===void 0?{}:{mcpMode:r},...W(`cancelRequested`,H(t,`cancelRequested`)),status:_a(t.status),progress:k(e=>{if(typeof e!=`string`)throw Error(`Expected progress item string`);return e})(t.progress),...W(`error`,E(t,`error`)),...W(`auth`,va(t.auth)),...W(`prompt`,ba(t.prompt)),...W(`select`,Sa(t.select)),...W(`info`,Ca(t.info))};if(i.target===`mcp`&&i.auth!==void 0){let e=new URL(i.auth.url);if(e.protocol!==`https:`&&e.protocol!==`http:`)throw Error(`Invalid MCP authorization URL`)}return i}function _a(e){if(e!==`running`&&e!==`complete`&&e!==`error`&&e!==`cancelled`)throw Error(`Invalid OAuth flow status`);return e}function va(e){if(e===void 0)return;let t=w(e);return{url:T(t,`url`),...W(`instructions`,E(t,`instructions`)),...W(`deviceCode`,ya(t.deviceCode))}}function ya(e){if(e===void 0)return;let t=w(e);return{userCode:T(t,`userCode`),...W(`intervalSeconds`,U(t,`intervalSeconds`)),...W(`expiresInSeconds`,U(t,`expiresInSeconds`))}}function ba(e){if(e===void 0)return;let t=w(e),n=E(t,`kind`);if(n!==void 0&&n!==`prompt`&&n!==`manual`)throw Error(`Invalid OAuth prompt kind`);let r=t.promptType===void 0&&n!==void 0?n===`manual`?`manual_code`:`text`:xa(t.promptType);return{requestId:T(t,`requestId`),message:T(t,`message`),...W(`kind`,n),promptType:r,...W(`placeholder`,E(t,`placeholder`)),...W(`allowEmpty`,H(t,`allowEmpty`))}}function xa(e){if(e!==`text`&&e!==`secret`&&e!==`manual_code`)throw Error(`Invalid OAuth prompt type`);return e}function Sa(e){if(e===void 0)return;let t=w(e);return{requestId:T(t,`requestId`),message:T(t,`message`),options:k(Go)(t.options)}}function Ca(e){if(e!==void 0)return k(e=>{let t=w(e);return{message:T(t,`message`),...W(`links`,t.links===void 0?void 0:k(wa)(t.links))}})(e)}function wa(e){let t=w(e);return{url:T(t,`url`),...W(`label`,E(t,`label`))}}function Ta(e){if(e===void 0)return{};let t=w(e);return{contextUsage:{tokens:rs(t,`tokens`),contextWindow:D(t,`contextWindow`),percent:rs(t,`percent`)}}}function Ea(e){let t=w(e),n=T(t,`source`);if(n!==`extension`&&n!==`prompt`&&n!==`skill`&&n!==`builtin`)throw Error(`Invalid command source`);return{name:T(t,`name`),source:n,...W(`description`,E(t,`description`)),...W(`argumentHint`,E(t,`argumentHint`))}}function Da(e){let t=w(e),n=T(t,`kind`);if(n!==`tracked`&&n!==`untracked`&&n!==`other`)throw Error(`Invalid file kind`);return{path:T(t,`path`),kind:n}}function Oa(e){let t=w(e);return{path:T(t,`path`),entries:k(ja)(t.entries),scannedAt:T(t,`scannedAt`),truncated:O(t,`truncated`)}}function ka(e){let t=w(e);return{results:k(Aa)(t.results)}}function Aa(e){let t=w(e),n=T(t,`path`),r=t.tree,i=t.error;if(r===void 0==(i===void 0))throw Error(`File tree batch result must contain exactly one of tree or error`);return r===void 0?{path:n,error:T(t,`error`)}:{path:n,tree:Oa(r)}}function ja(e){let t=w(e),n=T(t,`type`);if(n!==`file`&&n!==`directory`&&n!==`symlink`)throw Error(`Invalid file tree entry type`);return{name:T(t,`name`),path:T(t,`path`),type:n,...W(`size`,U(t,`size`)),...W(`modifiedAt`,E(t,`modifiedAt`))}}function Ma(e){let t=w(e),n=T(t,`encoding`);if(n!==`utf8`)throw Error(`Invalid file encoding`);return{path:T(t,`path`),...W(`language`,E(t,`language`)),...W(`mediaType`,Ia(t.mediaType)),...W(`mimeType`,E(t,`mimeType`)),encoding:n,size:D(t,`size`),modifiedAt:T(t,`modifiedAt`),content:T(t,`content`),truncated:O(t,`truncated`),binary:O(t,`binary`)}}function Na(e){let t=w(e);return{path:T(t,`path`),size:D(t,`size`),modifiedAt:T(t,`modifiedAt`),created:O(t,`created`)}}function Pa(e){let t=w(e);return{path:T(t,`path`),existed:O(t,`existed`)}}function Fa(e){let t=w(e);return{fromPath:T(t,`fromPath`),toPath:T(t,`toPath`),size:D(t,`size`),modifiedAt:T(t,`modifiedAt`)}}function Ia(e){if(e!==void 0){if(e!==`image`&&e!==`html`&&e!==`pdf`&&e!==`markdown`)throw Error(`Invalid file media type`);return e}}function La(e){let t=w(e);return{id:T(t,`id`),cwd:T(t,`cwd`),name:T(t,`name`),createdAt:T(t,`createdAt`),exited:O(t,`exited`),...W(`exitCode`,U(t,`exitCode`)),...W(`commandRunId`,E(t,`commandRunId`))}}function z(e){let t=w(e);return{id:T(t,`id`),origin:T(t,`origin`),projectId:T(t,`projectId`),workspaceId:T(t,`workspaceId`),terminalId:T(t,`terminalId`),title:T(t,`title`),command:T(t,`command`),status:Ra(t.status),...W(`exitCode`,U(t,`exitCode`)),createdAt:T(t,`createdAt`),...W(`startedAt`,E(t,`startedAt`)),...W(`completedAt`,E(t,`completedAt`)),metadata:za(t.metadata,`metadata`)}}function Ra(e){if(e!==`queued`&&e!==`running`&&e!==`succeeded`&&e!==`failed`)throw Error(`Invalid terminal command run status`);return e}function za(e,t){let n=w(e);return Object.fromEntries(Object.entries(n).map(([e,n])=>{if(typeof n!=`string`)throw Error(`Expected string record field: ${t}.${e}`);return[e,n]}))}function Ba(e){let t=w(e);return{cwd:T(t,`cwd`),hasSessionActivity:O(t,`hasSessionActivity`),hasTerminalActivity:O(t,`hasTerminalActivity`),updatedAt:T(t,`updatedAt`)}}function Va(e){let t=w(e);return{workspaces:k(Ba)(t.workspaces),generatedAt:T(t,`generatedAt`)}}function Ha(e){let t=or(e);if(t===void 0)throw Error(`Expected machine status snapshot`);return t}function Ua(e){let t=w(e);return{path:T(t,`path`),exists:O(t,`exists`),config:Ga(t.config),effectiveConfig:Ga(t.effectiveConfig),envOverrides:no(t.envOverrides),...W(`enforcedSettings`,Wa(t.enforcedSettings)),...W(`configSources`,Wa(t.configSources)),...W(`defaultsConfig`,t.defaultsConfig===void 0?void 0:Ga(t.defaultsConfig)),...W(`defaultsPath`,E(t,`defaultsPath`))}}function Wa(e){if(e===void 0)return;let t=w(e);return Object.fromEntries(Object.entries(t).map(([e,t])=>{if(typeof t!=`string`)throw Error(`Invalid configuration source for ${e}`);return[e,t]}))}function Ga(e){let t=w(e);if(Object.hasOwn(t,`sessionNaming`))throw Error(`Retired PI WEB sessionNaming config field`);return{...W(`host`,E(t,`host`)),...W(`port`,U(t,`port`)),...W(`installationName`,t.installationName===void 0?void 0:sn(t.installationName)),...W(`allowedHosts`,qa(t.allowedHosts)),...W(`shortcuts`,eo(t.shortcuts)),...W(`defaultTheme`,t.defaultTheme===void 0?void 0:l(t.defaultTheme,`response`)),...W(`defaultStreamingBehavior`,t.defaultStreamingBehavior===void 0?void 0:nn(t.defaultStreamingBehavior,`response`)),...W(`defaultLocalization`,t.defaultLocalization===void 0?void 0:an(t.defaultLocalization,`response`)),...W(`quietMode`,H(t,`quietMode`)),...W(`plugins`,to(t.plugins)),...W(`basePaths`,Ya(t.basePaths,`basePaths`)),...W(`pathAccess`,Ja(t.pathAccess)),...W(`uploads`,Xa(t.uploads)),...W(`attachments`,Za(t.attachments)),...W(`maxUploadBytes`,U(t,`maxUploadBytes`)),...W(`agent`,Ka(t.agent)),...W(`spawnSessions`,H(t,`spawnSessions`)),...W(`subsessions`,H(t,`subsessions`)),...W(`sessionMessages`,H(t,`sessionMessages`)),...W(`askUser`,H(t,`askUser`)),...W(`environmentFacts`,H(t,`environmentFacts`)),...W(`extensionDialogsTimeoutMs`,U(t,`extensionDialogsTimeoutMs`)),...W(`sessionArchive`,t.sessionArchive===void 0?void 0:vn(t.sessionArchive,`response`))}}function Ka(e){if(e!==void 0){if(!C(e)||Array.isArray(e))throw Error(`Invalid PI WEB agent field`);return{...W(`command`,E(e,`command`)),...W(`dir`,E(e,`dir`))}}}function qa(e){if(e!==void 0){if(e===!0)return!0;if(Qa(e))return e;throw Error(`Invalid PI WEB allowedHosts field`)}}function Ja(e){if(e===void 0)return;if(!C(e))throw Error(`Invalid PI WEB pathAccess field`);let t=e.allowedPaths;return{...W(`allowedPaths`,Ya(t,`pathAccess.allowedPaths`))}}function Ya(e,t){if(e!==void 0){if($a(e))return e;throw Error(`Invalid PI WEB ${t} field`)}}function Xa(e){if(e!==void 0){if(!C(e)||Array.isArray(e))throw Error(`Invalid PI WEB uploads field`);return{...W(`defaultFolder`,E(e,`defaultFolder`))}}}function Za(e){if(e!==void 0){if(!C(e)||Array.isArray(e))throw Error(`Invalid PI WEB attachments field`);return{...W(`defaultFolder`,E(e,`defaultFolder`))}}}function Qa(e){return Array.isArray(e)&&e.every(e=>typeof e==`string`)}function $a(e){return Array.isArray(e)&&e.every(e=>typeof e==`string`&&e!==``)}function eo(e){if(e!==void 0){if(!C(e)||Array.isArray(e))throw Error(`Invalid PI WEB shortcuts field`);return Object.fromEntries(Object.entries(e).map(([e,t])=>{if(t!==null&&(typeof t!=`string`||t===``))throw Error(`Invalid PI WEB shortcut field`);return[e,t]}))}}function to(e){if(e!==void 0){if(!C(e)||Array.isArray(e))throw Error(`Invalid PI WEB plugins field`);return Object.fromEntries(Object.entries(e).map(([e,t])=>{if(!C(t)||Array.isArray(t))throw Error(`Invalid PI WEB plugin config field`);let n=t.enabled;if(n!==void 0&&typeof n!=`boolean`)throw Error(`Invalid PI WEB plugin enabled field`);let r=t.settings;if(r!==void 0&&(!C(r)||Array.isArray(r)))throw Error(`Invalid PI WEB plugin settings field`);return[e,t]}))}}function no(e){let t=w(e);return{host:O(t,`host`),port:O(t,`port`),allowedHosts:O(t,`allowedHosts`),spawnSessions:O(t,`spawnSessions`),subsessions:O(t,`subsessions`),sessionMessages:H(t,`sessionMessages`)??!1,askUser:O(t,`askUser`),agentCommand:H(t,`agentCommand`)??!1,agentDir:H(t,`agentDir`)??!1,...ro(t),agentSessionDir:H(t,`agentSessionDir`)??!1}}function ro(e){let t=e.agentDirSource;if(t===void 0)return{};if(t!==`pi-web`&&t!==`pi-compatibility`)throw Error(`Invalid PI WEB agentDirSource field`);return{agentDirSource:t}}function io(e){let t=w(e);return{packages:k(oo)(t.packages),...W(`installableKnownPackages`,so(t.installableKnownPackages))}}function ao(e){let t=w(e),n=E(t,`source`),r=t.scope===void 0?void 0:lo(t.scope),i=B(t.removed,`removed`);return{action:uo(t.action),...W(`source`,n),...W(`scope`,r),...W(`removed`,i),packages:k(oo)(t.packages),...W(`installableKnownPackages`,so(t.installableKnownPackages))}}function oo(e){let t=w(e);return{source:T(t,`source`),scope:lo(t.scope),filtered:O(t,`filtered`),...W(`installedPath`,E(t,`installedPath`))}}function so(e){return e===void 0?void 0:k(co)(e)}function co(e){let t=w(e);return{id:T(t,`id`),label:T(t,`label`),description:T(t,`description`),source:T(t,`source`)}}function lo(e){if(e!==`user`&&e!==`project`)throw Error(`Invalid Pi package scope`);return e}function uo(e){if(e!==`install`&&e!==`remove`&&e!==`update`)throw Error(`Invalid Pi package mutation action`);return e}function fo(e){let t=w(e),n=k(po)(t.plugins);if(t.lifecycleVersion===void 0)return{lifecycleVersion:2,plugins:n,diagnostics:[],serverRuntime:{status:`incompatible`,terminalMode:`required`,restartRequired:!1,message:y(`ui.main.fe09b19a1f40`,`PI WEB does not support plugin lifecycle diagnostics. Update and restart PI WEB, then try again.`),recovery:yo()}};if(t.lifecycleVersion!==2)throw Error(`Unsupported PI WEB plugin lifecycle version`);return{lifecycleVersion:2,plugins:n,diagnostics:k(go)(t.diagnostics),serverRuntime:_o(t.serverRuntime)}}function po(e){let t=w(e),n=T(t,`id`),r=t.server===void 0?void 0:mo(t.server,n),i=E(t,`backendRevision`),a=bo(t.pairedRequestVersion),o=bo(t.pairedChannelVersion);if((a!==void 0||o!==void 0)&&i===void 0)throw Error(`Invalid PI WEB plugin paired capability`);let s=B(t.required,`required`);if(s===!1)throw Error(`Invalid PI WEB required plugin marker`);return{id:n,...s===!0?{required:!0}:{},...W(`module`,E(t,`module`)),...i===void 0?{}:{backendRevision:i},...a===void 0?{}:{pairedRequestVersion:a},...o===void 0?{}:{pairedChannelVersion:o},source:T(t,`source`),scope:xo(t.scope),machineSpecific:B(t.machineSpecific,`machineSpecific`)??!1,enabled:O(t,`enabled`),discovered:B(t.discovered,`discovered`)??!0,conflict:B(t.conflict,`conflict`)??!1,...r===void 0?{}:{server:r}}}function mo(e,t){let n=w(e),r=n.state,i=n.phase;if(r!==`active`&&r!==`failed`&&r!==`incompatible`&&r!==`disabled`&&r!==`missing`&&r!==`unknown`)throw Error(`Invalid PI WEB server plugin state`);if(i!==void 0&&i!==`import`&&i!==`activate`&&i!==`validate`&&i!==`start`&&i!==`health`&&i!==`dispose`)throw Error(`Invalid PI WEB server plugin phase`);let a=n.health===void 0?void 0:ho(n.health),o=T(n,`disableCommand`);if(o!==pr(t))throw Error(`Invalid PI WEB server plugin recovery command`);return{state:r,...W(`desiredRevision`,E(n,`desiredRevision`)),...W(`activeRevision`,E(n,`activeRevision`)),...i===void 0?{}:{phase:i},...W(`message`,E(n,`message`)),...a===void 0?{}:{health:a},staleRevision:O(n,`staleRevision`),restartRequired:O(n,`restartRequired`),disableCommand:o}}function ho(e){let t=w(e),n=t.status;if(n!==`healthy`&&n!==`degraded`&&n!==`unhealthy`)throw Error(`Invalid PI WEB server plugin health status`);return{status:n,...W(`message`,E(t,`message`))}}function go(e){let t=w(e),n=t.kind,r=t.snapshot;if(n!==`conflict`&&n!==`discovery`)throw Error(`Invalid PI WEB plugin diagnostic kind`);if(r!==`desired`&&r!==`active`)throw Error(`Invalid PI WEB plugin diagnostic snapshot`);return{kind:n,snapshot:r,source:T(t,`source`),message:T(t,`message`),...W(`pluginId`,E(t,`pluginId`))}}function _o(e){let t=w(e),n=t.status,r=t.terminalMode,i=t.safeStart,a=t.desiredSafeStart;if(n!==`available`&&n!==`unavailable`&&n!==`incompatible`)throw Error(`Invalid PI WEB server-plugin runtime status`);if(r!==`required`&&r!==`recovery-disabled`)throw Error(`Invalid PI WEB Terminal plugin mode`);if(i!==void 0&&i!==`bundled-only`&&i!==`none`)throw Error(`Invalid PI WEB server-plugin safe-start state`);if(a!==void 0&&a!==`off`&&a!==`bundled-only`&&a!==`none`)throw Error(`Invalid desired PI WEB server-plugin safe-start state`);if(n!==`available`&&r===`recovery-disabled`)throw Error(`Unavailable PI WEB runtime cannot declare Terminal recovery mode`);if(i===`none`!=(r===`recovery-disabled`)&&n===`available`)throw Error(`PI WEB Terminal plugin mode does not match safe start`);return{status:n,terminalMode:r,...i===void 0?{}:{safeStart:i},...a===void 0?{}:{desiredSafeStart:a},restartRequired:O(t,`restartRequired`),...W(`message`,E(t,`message`)),recovery:vo(t.recovery)}}function vo(e){let t=w(e),n={showSafeStart:T(t,`showSafeStart`),bundledOnly:T(t,`bundledOnly`),noServerPlugins:T(t,`noServerPlugins`),clearSafeStart:T(t,`clearSafeStart`)};if(n.showSafeStart!==S.showSafeStart||n.bundledOnly!==S.bundledOnly||n.noServerPlugins!==S.noServerPlugins||n.clearSafeStart!==S.clearSafeStart)throw Error(`Invalid PI WEB server plugin recovery commands`);return n}function yo(){return{...S}}function bo(e){if(e!==void 0){if(e!==1)throw Error(`Invalid PI WEB plugin paired capability version`);return 1}}function xo(e){if(e!==`bundled`&&e!==`local`&&e!==`user`&&e!==`project`)throw Error(`Invalid PI WEB plugin scope`);return e}function B(e,t){if(e!==void 0){if(typeof e!=`boolean`)throw Error(`Expected optional boolean field: ${t}`);return e}}function So(e){let t=w(e);return{packageName:T(t,`packageName`),generatedAt:T(t,`generatedAt`),components:wo(t.components),release:ko(t.release),commands:Ao(t.commands),messages:k(jo)(t.messages)}}function Co(e){let t=w(e);return{packageName:T(t,`packageName`),generatedAt:T(t,`generatedAt`),components:To(t.components),capabilities:No(t.capabilities)}}function wo(e){let t=w(e);return{web:Do(t.web),sessiond:Do(t.sessiond)}}function To(e){let t=w(e);return{web:Eo(t.web),sessiond:Eo(t.sessiond)}}function Eo(e){let t=w(e),n=Mo(t.component),r=t.activeAgentProfile,i=r===void 0?void 0:An(r);if(r!==void 0&&(n!==`sessiond`||i===void 0))throw Error(`Invalid active agent profile descriptor`);return{component:n,label:T(t,`label`),...W(`runtimeVersion`,E(t,`runtimeVersion`)),...W(`piVersion`,E(t,`piVersion`)),available:O(t,`available`),capabilities:No(t.capabilities),...W(`activeAgentProfile`,i),...W(`deprecatedAgentInputs`,$n(t.deprecatedAgentInputs)),...W(`error`,E(t,`error`))}}function Do(e){let t=w(e);return{component:Mo(t.component),label:T(t,`label`),...W(`runtimeVersion`,E(t,`runtimeVersion`)),...W(`installedVersion`,E(t,`installedVersion`)),...W(`piVersion`,E(t,`piVersion`)),stale:O(t,`stale`),available:O(t,`available`),...W(`installation`,Oo(t.installation)),...W(`error`,E(t,`error`))}}function Oo(e){if(e===void 0)return;let t=w(e),n=T(t,`kind`);if(n!==`pi-package`&&n!==`npm-global`&&n!==`local`&&n!==`docker`&&n!==`unknown`)throw Error(`Invalid PI WEB installation kind`);let r=t.scope;if(r!==void 0&&r!==`user`&&r!==`project`)throw Error(`Invalid PI WEB installation scope`);let i=t.dockerMode;if(i!==void 0&&i!==`runtime`&&i!==`dev`)throw Error(`Invalid PI WEB Docker mode`);return{kind:n,...W(`path`,E(t,`path`)),...W(`source`,E(t,`source`)),...r===void 0?{}:{scope:r},...W(`npmRoot`,E(t,`npmRoot`)),...i===void 0?{}:{dockerMode:i}}}function ko(e){let t=w(e);return{packageName:T(t,`packageName`),...W(`latestVersion`,E(t,`latestVersion`)),updateAvailable:O(t,`updateAvailable`),...W(`checkedAt`,E(t,`checkedAt`)),...t.skipped===!0?{skipped:!0}:{},...W(`error`,E(t,`error`))}}function Ao(e){let t=w(e);return{...W(`update`,E(t,`update`)),...W(`restart`,E(t,`restart`)),...W(`restartWeb`,E(t,`restartWeb`)),...W(`restartSessiond`,E(t,`restartSessiond`)),...W(`status`,E(t,`status`))}}function jo(e){let t=w(e);return{id:T(t,`id`),severity:Po(t.severity),title:T(t,`title`),body:T(t,`body`),...W(`command`,E(t,`command`))}}function Mo(e){if(e!==`web`&&e!==`sessiond`)throw Error(`Invalid PI WEB service component`);return e}function No(e){let t=Qn(e);if(t===void 0)throw Error(`Invalid PI WEB capabilities`);return t}function Po(e){if(e!==`info`&&e!==`warning`&&e!==`error`)throw Error(`Invalid PI WEB status severity`);return e}function Fo(e){let t=w(e),n=T(t,`type`);if(n===`unsupported`)return{type:n,...W(`presentation`,Ln(t.presentation)),message:T(t,`message`)};if(n===`select`)return{type:n,...W(`presentation`,Ln(t.presentation)),requestId:T(t,`requestId`),title:T(t,`title`),options:k(Go)(t.options)};if(n===`tree`)return{type:n,tree:Io(t.tree)};if(n===`done`)return{type:n,...W(`presentation`,Ln(t.presentation)),...W(`message`,E(t,`message`)),...Ko(t.session),...W(`promptDraft`,E(t,`promptDraft`))};throw Error(`Invalid command result type`)}function Io(e){let t=w(e),n=k(Lo)(t.nodes),r=new Set(n.map(e=>e.id));if(r.size!==n.length)throw Error(`Duplicate session tree node id`);let i=Ho(t,`activeLeafId`);if(i!==null&&!r.has(i))throw Error(`Invalid session tree activeLeafId`);return{nodes:n,activeLeafId:i,activePathIds:Wo(t.activePathIds,`activePathIds`)}}function Lo(e){let t=w(e);return{id:Uo(t,`id`),parentId:Ho(t,`parentId`),kind:Ro(t.kind),summary:T(t,`summary`),...W(`summaryPresentation`,qn(t.summaryPresentation)),...W(`timestamp`,E(t,`timestamp`)),...W(`label`,E(t,`label`))}}function Ro(e){switch(e){case`user`:case`assistant`:case`tool-result`:case`bash`:case`custom-message`:case`compaction`:case`branch-summary`:case`model-change`:case`thinking-level-change`:case`session-info`:case`label`:case`custom`:case`other`:return e;default:throw Error(`Invalid session tree node kind`)}}function zo(e){let t=w(e),n=O(t,`cancelled`);if(Object.hasOwn(t,`summaryEntry`))throw Error(`Invalid session tree navigation result field: summaryEntry`);if(n){Vo(t,`editorText`,`session tree cancellation result`);let e=t.aborted;if(e!==void 0&&typeof e!=`boolean`)throw Error(`Expected optional boolean field: aborted`);return{cancelled:n,...e===void 0?{}:{aborted:e}}}return Vo(t,`aborted`,`session tree navigation result`),{cancelled:n,...W(`editorText`,E(t,`editorText`))}}function Bo(e){let t=w(e),n=O(t,`cancelled`);return n?(Vo(t,`session`,`session tree fork cancellation result`),Vo(t,`promptDraft`,`session tree fork cancellation result`),{cancelled:n}):{cancelled:n,session:j(t.session),...W(`promptDraft`,E(t,`promptDraft`))}}function Vo(e,t,n){if(Object.hasOwn(e,t))throw Error(`Invalid ${n} field: ${t}`)}function Ho(e,t){let n=e[t];if(n!==null&&typeof n!=`string`)throw Error(`Expected string or null field: ${t}`);if(typeof n==`string`&&n.trim()===``)throw Error(`Expected non-blank string or null field: ${t}`);return n}function Uo(e,t){let n=T(e,t);if(n.trim()===``)throw Error(`Expected non-blank string field: ${t}`);return n}function Wo(e,t){let n=A(e,t);if(n.some(e=>e.trim()===``))throw Error(`Expected non-blank string array field: ${t}`);return n}function Go(e){let t=w(e);return{value:T(t,`value`),label:T(t,`label`),...W(`description`,E(t,`description`))}}function Ko(e){return e===void 0?{}:{session:j(e)}}function V(e){if(w(e).accepted!==!0)throw Error(`Expected accepted response`);return{accepted:!0}}function qo(e){let t=w(e);return k(Jo)(t.attachments)}function Jo(e){let t=w(e);return{path:T(t,`path`),mimeType:T(t,`mimeType`),size:D(t,`size`)}}function Yo(e){if(w(e).closed!==!0)throw Error(`Expected closed response`);return{closed:!0}}function Xo(e){if(w(e).aborted!==!0)throw Error(`Expected aborted response`);return{aborted:!0}}function Zo(e){if(w(e).stopped!==!0)throw Error(`Expected stopped response`);return{stopped:!0}}function Qo(e){let t=w(e);if(t.archived!==!0)throw Error(`Expected archived response`);let n=t.sessionIds===void 0?void 0:A(t.sessionIds,`sessionIds`),r=U(t,`archivedCount`),i=U(t,`skippedAlreadyArchivedCount`);return{archived:!0,...n===void 0?{}:{sessionIds:n},...r===void 0?{}:{archivedCount:r},...i===void 0?{}:{skippedAlreadyArchivedCount:i}}}function $o(e){if(w(e).restored!==!0)throw Error(`Expected restored response`);return{restored:!0}}function es(e){if(w(e).deleted!==!0)throw Error(`Expected deleted response`);return{deleted:!0}}function ts(e){if(w(e).detached!==!0)throw Error(`Expected detached response`);return{detached:!0}}function ns(e){if(w(e).reloaded!==!0)throw Error(`Expected reloaded response`);return{reloaded:!0}}function H(e,t){let n=e[t];if(n!==void 0){if(typeof n!=`boolean`)throw Error(`Invalid PI WEB ${t} field`);return n}}function U(e,t){let n=e[t];if(n!==void 0){if(typeof n!=`number`)throw Error(`Expected optional number field: ${t}`);return n}}function rs(e,t){let n=e[t];if(n===null)return null;if(typeof n!=`number`)throw Error(`Expected number|null field: ${t}`);return n}function W(e,t){return t===void 0?{}:{[e]:t}}function is(e){let t=w(e),n=t.decision;if(n!==!0&&n!==!1&&n!==null)throw Error(`Invalid workspace trust decision`);return{path:T(t,`path`),decision:n,trusted:O(t,`trusted`)}}function as(e,t){return typeof e==`number`&&Number.isSafeInteger(e)&&e>0&&typeof t==`number`&&Number.isSafeInteger(t)&&t>0?{width:e,height:t}:void 0}var os=`reference`;function ss(e){return typeof e==`string`&&/^[0-9a-f]{64}$/u.test(e)}function cs(e,t,n,r){let i=new URLSearchParams({cwd:e.cwd});return n?.limit!==void 0&&i.set(`limit`,String(n.limit)),n?.before!==void 0&&i.set(`before`,String(n.before)),i.set(`media`,os),`api/machines/${encodeURIComponent(r)}/sessions/${encodeURIComponent(e.id)}/${t}?${i.toString()}`}function ls(e,t,n=`local`){return cs(e,`messages`,t,n)}function us(e,t,n=`local`){return cs(e,`transcript-snapshot`,t,n)}function ds(e,t=`local`){return cs(e,`stream-snapshot`,void 0,t)}function fs(e,t=`local`){return cs(e,`events`,void 0,t)}function ps(t,n,r=`local`){let i=new URLSearchParams({cwd:t.cwd}),a=`api/machines/${encodeURIComponent(r)}/sessions/${encodeURIComponent(t.id)}/media/${encodeURIComponent(n)}?${i.toString()}`,o=c(a);return new URL(e(o),o).href}function ms(t,n,r,i){let a=new URLSearchParams({path:r});i?.createDirs===!1&&a.set(`createDirs`,`false`),i?.overwrite===!1&&a.set(`overwrite`,`false`);let o=`api/machines/${encodeURIComponent(i?.machineId??`local`)}`;return c(e(`${o}/projects/${encodeURIComponent(t)}/workspaces/${encodeURIComponent(n)}/file?${a.toString()}`))}function hs(t,n,r,i){let a=new URLSearchParams;a.set(`path`,r),i?.modifiedAt!==void 0&&a.set(`v`,i.modifiedAt),i?.download===!0&&a.set(`download`,`1`);let o=`api/machines/${encodeURIComponent(i?.machineId??`local`)}`;return e(`${o}/projects/${encodeURIComponent(t)}/workspaces/${encodeURIComponent(n)}/file/preview?${a.toString()}`)}function gs(e,t,n,r){return c(hs(e,t,n,r))}function _s(e,t,n,r){return gs(e,t,n,{...r,download:!0})}var G=(e=`local`)=>`api/machines/${encodeURIComponent(e)}`,vs={projectTrust:(e,t=`local`)=>a(`${G(t)}/projects/trust?${new URLSearchParams({path:e})}`,is),workspaceTrust:(e,t,n=`local`)=>a(`${G(n)}/projects/${encodeURIComponent(e)}/workspaces/${encodeURIComponent(t)}/trust`,is),setWorkspaceTrust:(e,t,n,r=`local`)=>a(`${G(r)}/projects/${encodeURIComponent(e)}/workspaces/${encodeURIComponent(t)}/trust`,is,{method:`PUT`,body:JSON.stringify({trusted:n})})};function ys(e,t=`local`){return`${G(t)}/sessions/${encodeURIComponent(e.id)}`}function K(e,t,n=`local`){return`${ys(e,n)}/${t}`}function q(e,t,n=`local`){return`${K(e,t,n)}${xs(e)}`}function bs(e,t=`local`,n){return`${ys(e,t)}${xs(e,n===void 0?{}:{scopeProjectId:n})}`}function xs(e,t={}){return`?${new URLSearchParams({cwd:e.cwd,...t}).toString()}`}function J(e,t={}){return JSON.stringify({cwd:e.cwd,...t})}function Ss(e,t){let n={sessions:e.map(({id:e,cwd:t})=>({id:e,cwd:t})),...t===void 0?{}:{scopeProjectId:t}};return JSON.stringify(n)}function Y(e,t){let n=new URLSearchParams;t.projectId!==void 0&&n.set(`projectId`,t.projectId);let r=n.toString();return`${G(t.machineId)}/auth/${e}${r===``?``:`?${r}`}`}function Cs(e){return e===`local`?`api/pi-web/status`:`${G(e)}/pi-web/status`}var ws={piWebStatus:(e=`local`)=>a(Cs(e),So),checkForUpdates:(e=`local`)=>a(`${Cs(e)}?refresh=1`,So,{cache:`no-store`}),piWebRuntime:()=>a(`api/pi-web/runtime`,Co)},Ts={machines:()=>a(`api/machines`,gr),machine:e=>a(`api/machines/${encodeURIComponent(e)}`,_r),addMachine:e=>a(`api/machines`,_r,{method:`POST`,body:JSON.stringify(e)}),updateMachine:(e,t)=>a(`api/machines/${encodeURIComponent(e)}`,_r,{method:`PATCH`,body:JSON.stringify(t)}),deleteMachine:e=>a(`api/machines/${encodeURIComponent(e)}`,e=>e,{method:`DELETE`}),health:e=>a(`api/machines/${encodeURIComponent(e)}/health`,vr),runtime:(e,t=!1)=>a(`api/machines/${encodeURIComponent(e)}/runtime${t?`?refresh=1`:``}`,yr,t?{cache:`no-store`}:{})};function Es(e){return e===void 0?`api/config`:`${G(e)}/config`}function Ds(e){return e===void 0?`api/plugins`:`${G(e)}/plugins`}var Os={namingModels:e=>{let t=new URLSearchParams;e.projectId!==void 0&&t.set(`projectId`,e.projectId);let n=t.toString();return a(`${G(e.machineId)}/models${n===``?``:`?${n}`}`,oa)},config:e=>a(Es(e),Ua),updateConfig:(e,t)=>a(Es(t),Ua,{method:`PATCH`,body:JSON.stringify(e)}),saveConfig:(e,t)=>a(Es(t),Ua,{method:`PUT`,body:JSON.stringify({config:e})})},ks={status:()=>a(`api/normal-auth/status`,Ir),setup:e=>a(`api/normal-auth/setup`,V,{method:`POST`,body:JSON.stringify({password:e})}),login:e=>a(`api/normal-auth/login`,V,{method:`POST`,body:JSON.stringify({password:e})}),changePassword:(e,t)=>a(`api/normal-auth/change-password`,V,{method:`POST`,body:JSON.stringify({currentPassword:e,newPassword:t})})},As={plugins:e=>a(Ds(e),fo)};function js(e=``,t){let n=t===void 0?`api/pi-packages`:`${G(t)}/pi-packages`;return e===``?n:`${n}/${e}`}var Ms={packages:e=>a(js(``,e),io),install:(e,t)=>{let n={source:e};return a(js(`install`,t),ao,{method:`POST`,body:JSON.stringify(n)})},remove:(e,t,n)=>{let r=t===void 0?{source:e}:{source:e,scope:t};return a(js(`remove`,n),ao,{method:`POST`,body:JSON.stringify(r)})},update:(e,t)=>{let n=e===void 0?void 0:{source:e};return a(js(`update`,t),ao,{method:`POST`,...n===void 0?{}:{body:JSON.stringify(n)}})}},Ns={workspaceActivity:(e=`local`)=>a(`${G(e)}/activity`,Va)},Ps={machineStatus:(e=`local`)=>a(`${G(e)}/status`,Ha)},Fs={snapshot:(e=`local`)=>a(`${G(e)}/notices`,Mi,{cache:`no-store`}),dismiss:(e,t,n)=>{let r={daemonInstanceId:t,noticeId:n};return a(`${G(e)}/notices/dismiss`,Mi,{method:`POST`,body:JSON.stringify(r)})}},Is={projects:(e=`local`)=>a(`${G(e)}/projects`,k(Cr)),addProject:(e,t,n,r=`local`)=>a(`${G(r)}/projects`,Cr,{method:`POST`,body:JSON.stringify({path:e,name:t,create:n})}),closeProject:(e,t=`local`)=>a(`${G(t)}/projects/${encodeURIComponent(e)}`,Yo,{method:`DELETE`}),projectDirectories:(e,t=`local`)=>a(`${G(t)}/project-directories?q=${encodeURIComponent(e)}`,k(Da))};function Ls(e,t,n,r,i,o=`local`){let s=new URLSearchParams({path:n});i?.createDirs===!1&&s.set(`createDirs`,`false`),i?.overwrite===!1&&s.set(`overwrite`,`false`);let c=r instanceof Uint8Array,l=c?new Uint8Array(r):new TextEncoder().encode(r);return a(`${G(o)}/projects/${encodeURIComponent(e)}/workspaces/${encodeURIComponent(t)}/file?${s.toString()}`,Na,{method:`PUT`,body:l,headers:{"Content-Type":c?`application/octet-stream`:`text/plain`}})}function Rs(e,t=`local`,n){return a(`${G(t)}/projects/${encodeURIComponent(e)}/workspaces`,t=>{let n=Tr(t);if(n.projectId!==e)throw Error(`Workspace resolution project does not match request`);return n},n?.signal===void 0?void 0:{signal:n.signal})}var zs={workspaceResolution:Rs,workspaces:async(e,t=`local`,n)=>r()===`management`?a(`${G(t)}/projects/${encodeURIComponent(e)}/workspaces`,k(wr),n?.signal===void 0?void 0:{signal:n.signal}):[...(await Rs(e,t,n)).workspaces],deleteWorkspace:(e,t,n,r=`local`)=>{let i={precondition:n};return a(`${G(r)}/projects/${encodeURIComponent(e)}/workspaces/${encodeURIComponent(t)}`,e=>e,{method:`DELETE`,body:JSON.stringify(i)})},workspaceTree:(e,t,n=``,r=`local`,i)=>a(`${G(r)}/projects/${encodeURIComponent(e)}/workspaces/${encodeURIComponent(t)}/tree?path=${encodeURIComponent(n)}`,Oa,i),workspaceTreeBatch:(e,t,n,r=`local`)=>{let i={paths:[...n]};return a(`${G(r)}/projects/${encodeURIComponent(e)}/workspaces/${encodeURIComponent(t)}/tree/batch`,ka,{method:`POST`,body:JSON.stringify(i)})},workspaceFile:(e,t,n,r=`local`,i)=>a(`${G(r)}/projects/${encodeURIComponent(e)}/workspaces/${encodeURIComponent(t)}/file?path=${encodeURIComponent(n)}`,Ma,i),optionalWorkspaceFile:(e,t,n,r=`local`,i)=>u(`${G(r)}/projects/${encodeURIComponent(e)}/workspaces/${encodeURIComponent(t)}/file?path=${encodeURIComponent(n)}&optional=true`,Ma,i),createWorkspaceFile:(e,t,n,r=`local`)=>Ls(e,t,n,new Uint8Array,void 0,r),writeWorkspaceFile:Ls,deleteWorkspaceFile:(e,t,n,r=`local`)=>{let i=new URLSearchParams({path:n});return a(`${G(r)}/projects/${encodeURIComponent(e)}/workspaces/${encodeURIComponent(t)}/file?${i.toString()}`,Pa,{method:`DELETE`})},moveWorkspaceFile:(e,t,n,r,i,o=`local`)=>{let s=new URLSearchParams({fromPath:n,toPath:r});return i?.createDirs===!1&&s.set(`createDirs`,`false`),i?.overwrite===!0&&s.set(`overwrite`,`true`),a(`${G(o)}/projects/${encodeURIComponent(e)}/workspaces/${encodeURIComponent(t)}/file/move?${s.toString()}`,Fa,{method:`POST`})},createWorkspaceDirectory:(e,t,n,r=`local`)=>a(`${G(r)}/projects/${encodeURIComponent(e)}/workspaces/${encodeURIComponent(t)}/directory`,Lr,{method:`POST`,body:JSON.stringify({path:n})}),moveWorkspaceDirectory:(e,t,n,r,i=`local`)=>a(`${G(i)}/projects/${encodeURIComponent(e)}/workspaces/${encodeURIComponent(t)}/directory`,Lr,{method:`PATCH`,body:JSON.stringify({fromPath:n,toPath:r})}),deleteWorkspaceDirectory:(e,t,n,r=`local`)=>a(`${G(r)}/projects/${encodeURIComponent(e)}/workspaces/${encodeURIComponent(t)}/directory?path=${encodeURIComponent(n)}`,Rr,{method:`DELETE`}),downloadWorkspaceFile:(e,t,n,r=`local`)=>Js(e,t,n,r)},Bs={sessions:(e,t=`local`,n)=>a(`${G(t)}/sessions?cwd=${encodeURIComponent(e)}`,k(j),n?.signal===void 0?void 0:{signal:n.signal}),search:(e,t,n=`local`)=>a(`${G(n)}/sessions/search?${new URLSearchParams({cwd:e,q:t}).toString()}`,k(j)),searchContent:(e,t,n=`local`,r)=>a(`${G(n)}/sessions/search-content?${new URLSearchParams({cwd:e,q:t}).toString()}`,zr,r?.signal===void 0?void 0:{signal:r.signal}),unreadCatalog:(e=`local`)=>a(`${G(e)}/sessions/unread`,pi,{cache:`no-store`}),markUnread:(e,t=`local`)=>a(K(e,`unread`,t),pi,{method:`POST`,body:JSON.stringify({cwd:e.cwd})}),acknowledgeUnread:(e,t,n,r=`local`)=>{let i={cwd:e.cwd,catalogId:t,throughCompletionOrder:n};return a(K(e,`unread/acknowledge`,r),pi,{method:`POST`,body:JSON.stringify(i)})},notificationInbox:(e,t=`local`)=>a(q(e,`notifications`,t),Ai),dismissNotification:(e,t,n,r=`local`)=>a(K(e,`notifications/dismiss`,r),Ai,{method:`POST`,body:J(e,{daemonInstanceId:t,notificationId:n})}),dismissAllNotifications:(e,t,n,r=`local`)=>a(K(e,`notifications/dismiss-all`,r),Ai,{method:`POST`,body:J(e,{daemonInstanceId:t,throughOrder:n.order,throughOverflowWatermark:n.overflowWatermark})}),startSession:(e,t=`local`,n)=>a(`${G(t)}/sessions`,j,{method:`POST`,body:JSON.stringify(n===void 0?{cwd:e}:{cwd:e,startupToken:n})}),cleanupPreview:(e,t=`local`)=>a(`${G(t)}/sessions/cleanup/preview`,Ji,{method:`POST`,body:JSON.stringify(e)}),cleanup:(e,t=`local`)=>a(`${G(t)}/sessions/cleanup`,Yi,{method:`POST`,body:JSON.stringify(e)}),archiveMany:(e,t=`local`,n)=>a(`${G(t)}/sessions/bulk/archive`,Xi,{method:`POST`,body:Ss(e,n)}),deleteArchivedMany:(e,t=`local`,n)=>a(`${G(t)}/sessions/bulk/delete-archived`,Zi,{method:`POST`,body:Ss(e,n)}),messages:(e,t,n=`local`)=>a(ls(e,t,n),hr),status:(e,t=`local`)=>a(q(e,`status`,t),M),streamSnapshot:(e,t=`local`)=>a(ds(e,t),di),transcriptSnapshot:(e,t,n=`local`)=>a(us(e,t,n),fi,{...t?.signal===void 0?{}:{signal:t.signal},...t?.timeoutMs===void 0?{}:{timeoutMs:t.timeoutMs}}),models:(e,t=`local`)=>a(q(e,`models`,t),oa),modelCatalog:(e,t=`local`)=>a(q(e,`models/catalog`,t),ca),setModelEnabled:(e,t,n,r,i=`local`)=>a(K(e,`models/enabled`,i),ca,{method:`POST`,body:J(e,{provider:t,modelId:n,enabled:r})}),setModelScope:(e,t,n=`local`)=>a(K(e,`models/scope`,n),ca,{method:`POST`,body:J(e,{mode:t})}),setModel:(e,t,n,r=`local`)=>a(K(e,`model`,r),M,{method:`POST`,body:J(e,{provider:t,modelId:n})}),cycleModel:(e,t,n=`local`)=>a(K(e,`model/cycle`,n),M,{method:`POST`,body:J(e,{direction:t})}),getSessionDefaults:(e,t=`local`)=>a(q(e,`defaults`,t),tn),setSessionDefaults:(e,t,n=`local`)=>a(K(e,`defaults`,n),tn,{method:`POST`,body:J(e,{...t})}),thinkingLevels:(e,t=`local`)=>a(q(e,`thinking-levels`,t),ua),setThinkingLevel:(e,t,n=`local`)=>a(K(e,`thinking-level`,n),M,{method:`POST`,body:J(e,{level:t})}),cycleThinkingLevel:(e,t=`local`)=>a(K(e,`thinking-level/cycle`,t),M,{method:`POST`,body:J(e)}),commands:(e,t=`local`)=>a(q(e,`commands`,t),k(Ea)),prompt:(e,t,n,r=`local`,i)=>a(K(e,`prompt`,r),V,{method:`POST`,body:J(e,{text:t,...n===void 0?{}:{streamingBehavior:n},...i!==void 0&&i.length>0?{attachments:i}:{}})}),saveAttachments:(e,t,n=`local`,r)=>a(K(e,`attachments`,n),qo,{method:`POST`,body:J(e,{attachments:t,...r===void 0?{}:{folder:r}})}),shell:(e,t,n=`local`)=>a(K(e,`shell`,n),V,{method:`POST`,body:J(e,{text:t})}),runCommand:(e,t,n=`local`)=>a(K(e,`commands/run`,n),Fo,{method:`POST`,body:J(e,{text:t})}),respondToCommand:(e,t,n,r=`local`)=>a(K(e,`commands/respond`,r),Fo,{method:`POST`,body:J(e,{requestId:t,value:n})}),navigateTree:(e,t,n=`local`)=>a(K(e,`tree/navigate`,n),zo,{method:`POST`,body:J(e,{targetId:t.targetId,expectedLeafId:t.expectedLeafId,summary:t.summary,...t.retainCheckpoint===void 0?{}:{retainCheckpoint:t.retainCheckpoint}})}),forkTree:(e,t,n=`local`)=>Ws(e,t,n),abort:(e,t=`local`)=>a(K(e,`abort`,t),Xo,{method:`POST`,body:J(e)}),stop:(e,t=`local`)=>a(K(e,`stop`,t),Zo,{method:`POST`,body:J(e)}),archive:(e,t=`local`,n)=>a(K(e,`archive`,t),Qo,{method:`POST`,body:J(e,n===void 0?{}:{scopeProjectId:n})}),archiveWithDescendants:(e,t=`local`,n)=>a(K(e,`archive-tree`,t),Qo,{method:`POST`,body:J(e,n===void 0?{}:{scopeProjectId:n})}),restore:(e,t=`local`,n)=>a(K(e,`restore`,t),$o,{method:`POST`,body:J(e,n===void 0?{}:{scopeProjectId:n})}),deleteArchived:(e,t=`local`,n)=>a(bs(e,t,n),es,{method:`DELETE`}),detachParent:(e,t=`local`)=>a(K(e,`detach-parent`,t),ts,{method:`POST`,body:J(e)}),reloadSession:(e,t=`local`)=>a(K(e,`reload`,t),ns,{method:`POST`,body:J(e)}),clearQueue:(e,t=`local`)=>a(K(e,`queue/clear`,t),M,{method:`POST`,body:J(e)}),mutateQueuedMessage:(e,t,n=`local`)=>a(K(e,`queue/message`,n),M,{method:`POST`,body:J(e,{...t})}),dismissWarning:(e,t,n=`local`)=>a(K(e,`warnings/dismiss`,n),M,{method:`POST`,body:J(e,{dismissId:t})}),submitAsk:(e,t,n,r=`local`)=>a(K(e,`ask/submit`,r),M,{method:`POST`,body:J(e,{askId:t,answers:n.answers})}),cancelAsk:(e,t,n=`local`)=>a(K(e,`ask/cancel`,n),M,{method:`POST`,body:J(e,{askId:t})}),answerDialog:(e,t,n,r=`local`)=>a(K(e,`dialogs/answer`,r),$r,{method:`POST`,body:J(e,{dialogId:t,value:n})}),cancelDialog:(e,t,n=`local`)=>a(K(e,`dialogs/cancel`,n),$r,{method:`POST`,body:J(e,{dialogId:t})}),authProviders:e=>{let t=new URLSearchParams;e.mode!==void 0&&t.set(`mode`,e.mode),e.authType!==void 0&&t.set(`authType`,e.authType),e.projectId!==void 0&&t.set(`projectId`,e.projectId);let n=t.toString();return a(`${G(e.machineId)}/auth/providers${n===``?``:`?${n}`}`,ha)},saveApiKey:(e,t,n)=>a(Y(`api-key`,n),V,{method:`POST`,body:JSON.stringify({providerId:e,key:t})}),startInteractiveApiKeyLogin:(e,t)=>a(Y(`api-key/interactive`,t),R,{method:`POST`,body:JSON.stringify({providerId:e})}),logoutProvider:(e,t)=>a(Y(`logout`,t),V,{method:`POST`,body:JSON.stringify({providerId:e})}),mcpAuthServers:(e,t=`local`)=>a(q(e,`mcp/auth/servers`,t),ga),startMcpAuth:(e,t,n=`local`,r)=>a(K(e,`mcp/auth`,n),R,{method:`POST`,body:J(e,{mode:t,...r===void 0?{}:{serverName:r}})}),mcpAuthFlow:(e,t=`local`)=>a(`${G(t)}/auth/mcp/${encodeURIComponent(e)}`,R),respondMcpAuthFlow:(e,t,n,r=`local`)=>a(`${G(r)}/auth/mcp/${encodeURIComponent(e)}/respond`,R,{method:`POST`,body:JSON.stringify({requestId:t,value:n})}),cancelMcpAuthFlow:(e,t=`local`)=>a(`${G(t)}/auth/mcp/${encodeURIComponent(e)}/cancel`,R,{method:`POST`}),startOAuthLogin:(e,t)=>a(Y(`oauth`,t),R,{method:`POST`,body:JSON.stringify({providerId:e})}),oauthFlow:(e,t)=>a(Y(`oauth/${encodeURIComponent(e)}`,t),R),respondOAuthFlow:(e,t,n,r)=>a(Y(`oauth/${encodeURIComponent(e)}/respond`,r),R,{method:`POST`,body:JSON.stringify({requestId:t,value:n})}),cancelOAuthFlow:(e,t)=>a(Y(`oauth/${encodeURIComponent(e)}/cancel`,t),R,{method:`POST`})},Vs={runTerminalCommand:(e,t,n=`local`)=>a(`${G(n)}/projects/${encodeURIComponent(t.workspace.projectId)}/workspaces/${encodeURIComponent(t.workspace.id)}/terminal-command-runs`,z,{method:`POST`,body:JSON.stringify({origin:e,title:t.title,command:t.command,metadata:t.metadata??{}})}),listCommandRuns:(e,t=`local`,n)=>a(`${G(t)}/terminal-command-runs${Ks(e)}`,k(z),n?.signal===void 0?void 0:{signal:n.signal}),getCommandRun:(e,t=`local`)=>Hs(e,t),cancelCommandRun:(e,t=`local`)=>a(`${G(t)}/terminal-command-runs/${encodeURIComponent(e)}/cancel`,z,{method:`POST`})};async function Hs(e,t){return u(`${G(t)}/terminal-command-runs/${encodeURIComponent(e)}`,z)}var Us=class extends Error{constructor(){super(y(`ui.main.8501d1e756a4`,`Fork from the session tree is unavailable. Restart the session daemon to enable it.`)),this.name=`SessionTreeForkUnavailableError`}};async function Ws(e,t,r){let i=await fetch(n(K(e,`tree/fork`,r)),{method:`POST`,headers:{"content-type":`application/json`},body:J(e,{entryId:t.entryId,expectedLeafId:t.expectedLeafId,...t.retainCheckpoint===void 0?{}:{retainCheckpoint:t.retainCheckpoint}})});if(!i.ok){let e=await i.json().catch(()=>({}));throw Gs(i.status,e)?new Us:Error(qs(e)??i.statusText)}return Bo(await i.json())}function Gs(e,t){if(e!==404||!Ys(t)||t.statusCode!==404||t.error!==`Not Found`)return!1;let n=t.message;return typeof n==`string`&&/^Route POST:.*\/tree\/fork not found$/i.test(n)}function Ks(e){if(e===void 0)return``;let t=new URLSearchParams;e.projectId!==void 0&&t.set(`projectId`,e.projectId),e.workspaceId!==void 0&&t.set(`workspaceId`,e.workspaceId),e.terminalId!==void 0&&t.set(`terminalId`,e.terminalId),e.statuses!==void 0&&e.statuses.length>0&&t.set(`statuses`,e.statuses.join(`,`)),e.metadata!==void 0&&Object.keys(e.metadata).length>0&&t.set(`metadata`,JSON.stringify(e.metadata));let n=t.toString();return n===``?``:`?${n}`}function qs(e){if(!Ys(e))return;let t=e.error;return typeof t==`string`?t:void 0}async function Js(e,t,n,r){let i=await fetch(_s(e,t,n,{machineId:r}));if(!i.ok){let e=await i.json().catch(()=>({}));throw Error(qs(e)??i.statusText)}let a=await i.blob(),o=URL.createObjectURL(a),s=document.createElement(`a`);s.href=o;let c=n.split(`/`).pop();s.download=c===void 0||c===``?`download`:c,document.body.append(s),s.click(),s.remove(),URL.revokeObjectURL(o)}function Ys(e){return typeof e==`object`&&!!e}var Xs={files:(e,t,n={})=>{let r=typeof t==`string`,i=r?e:``,o=r?t:e,s=r?n:t,c=new URLSearchParams({q:o});if(s.kind!==void 0&&c.set(`kind`,s.kind),s.mode!==void 0&&c.set(`mode`,s.mode),s.scope!==void 0&&c.set(`scope`,s.scope),(!r||s.workspaceScoped===!0)&&s.projectId!==void 0&&s.workspaceId!==void 0)return a(`${G(s.machineId)}/projects/${encodeURIComponent(s.projectId)}/workspaces/${encodeURIComponent(s.workspaceId)}/files?${c.toString()}`,k(Da),{signal:s.signal??null});if(!r)throw Error(`File suggestions require a project and workspace`);return c.set(`cwd`,i),a(`${G(s.machineId)}/files?${c.toString()}`,k(Da),{signal:s.signal??null})}},Zs={...ws,...Ts,...Fs,...Os,...ks,...As,...Ms,...Ns,...Ps,...Is,...vs,...zs,...Bs,...Xs,...Vs},Qs=12e4;function $s(e){if(!ec(e))throw Error(`Invalid speech transcription response`);let t=e.text;if(typeof t!=`string`)throw Error(`Invalid speech transcription response`);return{text:t}}function ec(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function tc(e){return`api/machines/${encodeURIComponent(e)}/speech/transcriptions`}var nc={transcribe:(e,t=`local`,n)=>a(tc(t),$s,{method:`POST`,body:JSON.stringify(e),timeoutMs:Qs,...n?.signal===void 0?{}:{signal:n.signal}})},rc=`.pi-web/uploads`,ic=class extends Error{constructor(e=y(`client.workspaceUploads.workspace.upload.cancelled.ac6723`,`Workspace upload cancelled`)){super(e),this.name=`WorkspaceUploadCancelledError`}};function ac(e){return e?.uploads?.defaultFolder??`.pi-web/uploads`}function oc(e,t){return e?.uploads?.defaultFolder??t}function sc(e,t){let n=fc(e,y(`client.workspaceUploads.upload.destination.874cbb`,`Upload destination`),{allowEmpty:!0}),r=fc(t,y(`client.workspaceUploads.upload.filename.9252dd`,`Upload filename`),{allowEmpty:!1});return n===``?r:`${n}/${r}`}function cc(e,t,n,r={}){let i=r.xhrFactory?.()??new XMLHttpRequest,a=!1,o=!1;return{promise:new Promise((s,c)=>{let l=e=>{a||(a=!0,c(e))},u=e=>{a||(a=!0,s(e))};i.open(`PUT`,ms(e,t,n.path,lc(r)),!0),i.responseType=`json`,i.setRequestHeader(`Content-Type`,(n.contentType??n.file.type)||`application/octet-stream`),i.upload.onprogress=e=>{r.onProgress?.(uc(e,n.file.size))},i.onload=()=>{if(i.status>=200&&i.status<300)try{r.onProgress?.({loaded:n.file.size,total:n.file.size,percent:1,lengthComputable:!0}),u(Na(mc(i)))}catch(e){l(e instanceof Error?e:Error(String(e)))}else l(Error(hc(i)))},i.onerror=()=>{l(Error(y(`client.workspaceUploads.workspace.upload.failed.a87e6b`,`Workspace upload failed`)))},i.onabort=()=>{l(new ic(o?void 0:y(`client.workspaceUploads.workspace.upload.aborted.58a455`,`Workspace upload aborted`)))},i.send(n.file)}),cancel:()=>{a||(o=!0,i.abort())}}}function lc(e){return{...e.createDirs===void 0?{}:{createDirs:e.createDirs},...e.overwrite===void 0?{}:{overwrite:e.overwrite},...e.machineId===void 0?{}:{machineId:e.machineId}}}function uc(e,t){let n=e.lengthComputable?e.total:t;return{loaded:e.loaded,total:n,percent:dc(e.loaded,n),lengthComputable:e.lengthComputable}}function dc(e,t){return t<=0?e<=0?0:1:Math.max(0,Math.min(1,e/t))}function fc(e,t,n){let r=e.trim();if(r===``){if(n.allowEmpty)return``;throw Error(y(`client.workspaceUploads.must.not.be.empty.b22cd8`,`{value1} must not be empty`,{value1:t}))}if(pc(r))throw Error(y(`client.workspaceUploads.must.be.a.workspace.relative.path.79fcd6`,`{value1} must be a workspace-relative path`,{value1:t}));let i=r.split(/[\\/]+/u).filter(e=>e!==``&&e!==`.`);if(i.length===0){if(n.allowEmpty)return``;throw Error(y(`client.workspaceUploads.must.not.be.empty.b22cd8`,`{value1} must not be empty`,{value1:t}))}if(i.some(e=>e===`..`))throw Error(y(`client.workspaceUploads.must.not.contain.path.traversal.dac533`,`{value1} must not contain path traversal`,{value1:t}));return i.join(`/`)}function pc(e){let t=e.replace(/\\/g,`/`);return t.startsWith(`/`)||/^[A-Za-z]:\//u.test(t)}function mc(e){return e.response!==void 0&&e.response!==null&&e.response!==``?e.response:e.responseText===``?{}:JSON.parse(e.responseText)}function hc(e){let t=gc(e);return _c(t)&&typeof t.error==`string`?t.error:e.statusText||`HTTP ${String(e.status)}`}function gc(e){try{return mc(e)}catch{return}}function _c(e){return typeof e==`object`&&!!e}var vc=262144,yc=8388608,bc=266240,xc=8392704,Sc=266240,Cc=65536,wc=69632,Tc=1e4,Ec=2048;Object.freeze([`/paired-plugin-backends/:pluginId/:operation`,`/paired-plugin-backends/:pluginId/projects/:projectId/:operation`,`/paired-plugin-backends/:pluginId/projects/:projectId/workspaces/:workspaceId/:operation`]),Object.freeze([`/paired-plugin-backends/:pluginId/channels/:operation`,`/paired-plugin-backends/:pluginId/projects/:projectId/channels/:operation`,`/paired-plugin-backends/:pluginId/projects/:projectId/workspaces/:workspaceId/channels/:operation`]);var Dc=4096;Object.freeze([`/paired-plugin-backends/:pluginId/resources/:operation`,`/paired-plugin-backends/:pluginId/projects/:projectId/resources/:operation`,`/paired-plugin-backends/:pluginId/projects/:projectId/workspaces/:workspaceId/resources/:operation`]);function Oc(e){let t=e.scope,n=e.projectId,r=e.workspaceId;if(t===void 0&&n===void 0&&r===void 0)return{};if(t!==`machine`&&t!==`project`&&t!==`workspace`)throw Error(`Plugin backend scope must be machine, project, or workspace`);for(let e of[n,r])if(e!==void 0&&(typeof e!=`string`||e===``||e.length>512))throw Error(`Plugin backend scope ids must be non-empty strings of at most 512 characters`);if(t===`machine`&&(n!==void 0||r!==void 0))throw Error(`Machine scope cannot contain project or workspace ids`);if(t===`project`&&r!==void 0)throw Error(`Project scope cannot contain a workspace id`);return{scope:t,...typeof n==`string`?{projectId:n}:{},...typeof r==`string`?{workspaceId:r}:{}}}function kc(e,t){let n=e.workspaceId===void 0?e.projectId===void 0?`machine`:`project`:`workspace`;if(t===void 0)return n;if(n!==`workspace`&&t.scope===void 0)throw Error(`Scoped plugin backend calls require an explicit scope`);if(t.scope!==void 0&&t.scope!==n||t.projectId!==void 0&&t.projectId!==e.projectId||t.workspaceId!==void 0&&t.workspaceId!==e.workspaceId)throw Error(`Plugin backend wire scope does not match route authority`);return n}function Ac(e,t=!1){let n=[``,`paired-plugin-backends`,encodeURIComponent(e.pluginId)];return e.projectId!==void 0&&n.push(`projects`,encodeURIComponent(e.projectId)),e.workspaceId!==void 0&&n.push(`workspaces`,encodeURIComponent(e.workspaceId)),t&&n.push(`channels`),n.push(encodeURIComponent(e.operation)),n.join(`/`)}function jc(e){let t=Ac(e),n=t.lastIndexOf(`/`);return`${t.slice(0,n)}/resources${t.slice(n)}`}var Mc=/^[a-z][a-z0-9.-]*$/u,Nc=/^[a-z][a-z0-9.-]*$/u,Pc=64;function Fc(e){return e.length<=128&&Mc.test(e)}function Ic(e){if(!Fc(e))throw Error(`Plugin backend operation must match ${String(Mc)} and be at most 128 characters`);return e}function Lc(e){if(typeof e!=`string`||e===``||e.length>512)throw Error(`Plugin backend revision must be a non-empty string of at most 512 characters`);return e}function X(e,t,n=vc){let r=Yc(e,new Set,t,0);if(Z(JSON.stringify(r))>n)throw Error(`${t} exceeds the ${String(n)} byte limit`);return r}function Rc(e,t,n=vc){if(Z(e)>n)throw Error(`${t} exceeds the ${String(n)} byte limit`);let r;try{r=JSON.parse(e)}catch(e){throw Error(`${t} must be valid JSON`,{cause:e})}return X(r,t,n)}function zc(e,t,n={}){return Uc({version:1,kind:`open`,...Oc({...n}),revision:Lc(e),input:X(t,`Plugin backend channel open input`,vc)},`Plugin backend channel open envelope`,Sc)}function Bc(e){return Uc({version:1,kind:`data`,data:X(e,`Plugin backend channel data`,Cc)},`Plugin backend channel data envelope`,wc)}function Vc(e){let t=Wc(e,`Plugin backend channel server frame`);if(Kc(t),t.kind===`ready`)return Q(e,wc,`Plugin backend channel ready frame`),Object.freeze({version:1,kind:`ready`});if(t.kind===`data`)return Gc(t,e);if(t.kind===`error`)return Q(e,wc,`Plugin backend channel error frame`),Object.freeze({version:1,kind:`error`,code:qc(t.code),message:Jc(t.message)});throw Error(`Plugin backend channel server frame kind is invalid`)}function Hc(e){if(typeof e!=`string`)throw Error(`Plugin backend channel close reason must be a string`);if(Z(e)>120)throw Error(`Plugin backend channel close reason exceeds the 120 byte limit`);return e}function Z(e){return new TextEncoder().encode(e).byteLength}function Uc(e,t,n){let r=JSON.stringify(e);return Q(r,n,t),r}function Wc(e,t){Q(e,Sc,t);let n;try{n=JSON.parse(e)}catch(e){throw Error(`${t} must be valid JSON`,{cause:e})}if(!Zc(n))throw Error(`${t} must be an object`);return n}function Gc(e,t){return Q(t,wc,`Plugin backend channel data frame`),Object.freeze({version:1,kind:`data`,data:X(e.data,`Plugin backend channel data`,Cc)})}function Kc(e){if(e.version!==1)throw Error(`Plugin backend channel frame version is unsupported`)}function qc(e){if(typeof e!=`string`||e.length>64||!Nc.test(e))throw Error(`Plugin backend channel error code is invalid`);return e}function Jc(e){if(typeof e!=`string`||e===``)throw Error(`Plugin backend channel error message must be a non-empty string`);if(Z(e)>2048)throw Error(`Plugin backend channel error message exceeds the ${String(Ec)} byte limit`);return e}function Q(e,t,n){if(Z(e)>t)throw Error(`${n} exceeds the ${String(t)} byte limit`)}function Yc(e,t,n,r){if(r>Pc)throw Error(`${n} exceeds the maximum JSON depth of ${String(Pc)}`);if(e===null||typeof e==`string`||typeof e==`boolean`)return e;if(typeof e==`number`){if(!Number.isFinite(e))throw Error(`${n} must contain only finite JSON numbers`);return e}if(Array.isArray(e)){if(t.has(e))throw Error(`${n} must not contain cycles`);t.add(e);let i=e.map(e=>Yc(e,t,n,r+1));return t.delete(e),Object.freeze(i),i}if(!Zc(e))throw Error(`${n} must contain only JSON values`);if(t.has(e))throw Error(`${n} must not contain cycles`);t.add(e);let i={};for(let[a,o]of Object.entries(e))Xc(i,a,Yc(o,t,n,r+1));return t.delete(e),Object.freeze(i)}function Xc(e,t,n){Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0})}function Zc(e){if(typeof e!=`object`||!e||Array.isArray(e))return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function Qc(e,t){return ol(e,t)}function $c(t,r,i){let a=Qc(t,r);return i===void 0?n(a):c(e(a),i)}function el(e,t){let n=Qc(e,t),r=n.lastIndexOf(`/`);return`${n.slice(0,r)}/channels${n.slice(r)}`}function tl(e,t,n){let i=d(el(e,t),void 0,r());return n===void 0?o(i):o(i,n)}function nl(e,t,n){if(!mn(e.pluginId))throw Error(`Invalid PI WEB plugin id: ${e.pluginId}`);if(e.machineId===``)throw Error(`Machine id is required`);if(e.projectId===``||e.workspaceId===``)throw Error(`Scope ids must not be empty`);if(e.workspaceId!==void 0&&e.projectId===void 0)throw Error(`Workspace scope requires a project id`);kc(e,sl(e));let r=Ic(t),i=Lc(e.backendRevision),a=X(n,`Plugin backend resource input`,Dc),o=new URLSearchParams({revision:i,input:JSON.stringify(a)});return`api/machines/${encodeURIComponent(e.machineId)}${jc({...e,operation:r})}?${o.toString()}`}function rl(t,r,i,a){let o=nl(t,r,i);return a===void 0?n(o):c(e(o),a)}function il(e,t,n,r={}){return cl(e,t,n,r,$c)}function al(e,t,n,r,i=e=>new WebSocket(e)){if(r.signal?.aborted===!0)return Promise.reject(fl(r.signal));let a=zc(e.backendRevision,n,sl(e)),o=tl(e,t),s;try{s=i(o)}catch(e){return Promise.reject(Error(`Plugin backend channel unavailable: ${pl(e)}`,{cause:e}))}let c=!1,l=!1,u=0,d,f=()=>void 0,ee=new Promise(e=>{f=e}),te=Object.freeze({closed:ee,send(e){if(!c||l||s.readyState!==1)throw Error(`Plugin backend channel is not open`);let t=Bc(e),n=Z(t);if(s.bufferedAmount===0&&(u=0),u>=128||s.bufferedAmount+n>1048576){let e=Error(`Plugin backend channel browser queue limit was exceeded`);throw d=Object.freeze({code:`queue-overflow`,message:e.message}),$(s,`Channel queue overflow`),e}try{s.send(t),u+=1}catch(e){throw d=Object.freeze({code:`send-failed`,message:pl(e)}),$(s,`Channel send failed`),e}},close(e=`Channel closed`){$(s,Hc(e))}});return new Promise((e,t)=>{let n=setTimeout(()=>{let e=Error(`Plugin backend channel open timed out after ${String(Tc)}ms`);d=Object.freeze({code:`open-timeout`,message:e.message}),t(e),$(s,`Channel open timed out`)},Tc),i=()=>{let e=r.signal;if(e===void 0)return;let n=fl(e);c||t(n),d=Object.freeze({code:`cancelled`,message:n.message}),$(s,`Channel cancelled`)};r.signal?.addEventListener(`abort`,i,{once:!0}),s.addEventListener(`open`,()=>{try{s.send(a)}catch(e){t(Error(`Plugin backend channel unavailable: ${pl(e)}`,{cause:e})),$(s,`Channel open failed`)}}),s.addEventListener(`message`,i=>{try{if(typeof i.data!=`string`)throw Error(`Plugin backend channels accept text JSON frames only`);let a=Vc(i.data);if(a.kind===`ready`){if(c)throw Error(`Plugin backend channel sent more than one ready envelope`);c=!0,clearTimeout(n),e(te);return}if(a.kind===`error`){d=Object.freeze({code:a.code,message:a.message}),c||t(Error(a.message)),$(s,`Channel failed`);return}if(!c)throw Error(`Plugin backend channel sent data before ready`);r.onData(a.data)}catch(e){d=Object.freeze({code:`protocol-error`,message:pl(e)}),c||t(e instanceof Error?e:Error(String(e))),$(s,`Channel protocol error`)}}),s.addEventListener(`error`,()=>{d??=Object.freeze({code:`transport-error`,message:`Plugin backend channel transport failed`}),c||t(Error(`Plugin backend channel unavailable`)),$(s,`Channel transport error`)}),s.addEventListener(`close`,e=>{if(l)return;l=!0,clearTimeout(n),r.signal?.removeEventListener(`abort`,i),c||t(Error(d?.message??`Plugin backend channel closed before ready (${String(e.code)})`));let a=d??(e.code===1e3?void 0:Object.freeze({code:`channel-closed`,message:e.reason||`Plugin backend channel closed with code ${String(e.code)}`}));f(Object.freeze({code:e.code,reason:e.reason,wasClean:e.wasClean,...a===void 0?{}:{error:a}}))})})}function ol(e,t){if(!mn(e.pluginId))throw Error(`Invalid PI WEB plugin id: ${e.pluginId}`);if(e.machineId===``)throw Error(`Machine id is required`);if(e.projectId===``)throw Error(`Project id is required`);if(e.workspaceId===``)throw Error(`Workspace id is required`);if(e.workspaceId!==void 0&&e.projectId===void 0)throw Error(`Workspace scope requires a project id`);kc(e,sl(e));let n=Ic(t);return`${e.machineId===`local`?`api`:`api/machines/${encodeURIComponent(e.machineId)}`}${Ac({...e,operation:n})}`}function sl(e){return e.scope===void 0?{}:{scope:e.scope,...e.projectId===void 0?{}:{projectId:e.projectId},...e.workspaceId===void 0?{}:{workspaceId:e.workspaceId}}}async function cl(e,t,n,r,i){let a=Lc(e.backendRevision),o=X(n,`Plugin backend request input`),s=JSON.stringify({revision:a,input:o,...sl(e)});if(Z(s)>266240)throw Error(`Plugin backend request exceeds the ${String(bc)} byte wire limit`);let c;try{c=await fetch(i(e,t),{method:`POST`,headers:{"content-type":`application/json`},body:s,...r.signal===void 0?{}:{signal:r.signal}})}catch(e){throw r.signal?.aborted===!0?fl(r.signal):Error(`Plugin backend request unavailable: ${pl(e)}`,{cause:e})}let l=await ll(c);if(!c.ok)throw Error(dl(l)??`Plugin backend request returned HTTP ${String(c.status)}`);return Rc(l,`Plugin backend response`,yc)}async function ll(e){let t=e.headers.get(`content-length`);if(t!==null&&/^\d+$/u.test(t)&&Number(t)>8392704)throw await e.body?.cancel(),Error(`Plugin backend response exceeds the ${String(xc)} byte wire limit`);if(e.body===null){let t=await e.text();if(Z(t)>8392704)throw ul();return t}let n=e.body.getReader(),r=new TextDecoder,i=0,a=``;try{let e=await n.read();for(;!e.done;){if(i+=e.value.byteLength,i>8392704)throw await n.cancel(),ul();a+=r.decode(e.value,{stream:!0}),e=await n.read()}return a+r.decode()}finally{n.releaseLock()}}function $(e,t){if(e.readyState===0||e.readyState===1)try{e.close(1e3,Hc(t))}catch{e.close()}}function ul(){return Error(`Plugin backend response exceeds the ${String(xc)} byte wire limit`)}function dl(e){try{let t=JSON.parse(e);return ml(t)&&typeof t.error==`string`?t.error:void 0}catch{return}}function fl(e){let t=e.reason;return t instanceof Error?t:new DOMException(`Plugin backend request cancelled`,`AbortError`)}function pl(e){return e instanceof Error?e.message:String(e)}function ml(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var hl=`pi-web.terminal`;export{wn as $,ss as A,bi as B,Bs as C,fs as D,zs as E,Ni as F,S as G,z as H,ci as I,ar as J,fr as K,si as L,Qr as M,Yr as N,ps as O,xi as P,Tn as Q,ji as R,Is as S,vs as T,La as U,mi as V,Ba as W,Bn as X,Zn as Y,Sn as Z,ks as _,Bt as _t,Lc as a,hn as at,ws as b,It as bt,ac as c,Yt as ct,sc as d,Zt as dt,Dn as et,nc as f,Kt as ft,Ps as g,Lt as gt,Os as h,Ht as ht,il as i,yn as it,as as j,gs as k,cc as l,$t as lt,Zs as m,y as mt,al as n,xn as nt,rc as o,mn as ot,Ns as p,Gt as pt,ur as q,rl as r,On as rt,ic as s,gn as st,hl as t,b as tt,oc as u,Qt as ut,Fs as v,Vt as vt,Vs as w,As as x,wt as xt,Ms as y,v as yt,hi as z};
@@ -10,7 +10,7 @@
10
10
  <link rel="apple-touch-icon" href="./apple-touch-icon.png" />
11
11
  <link rel="manifest" crossorigin="use-credentials" href="./manifest.webmanifest" />
12
12
  <style>:root{--lightningcss-light:initial;--lightningcss-dark: ;color-scheme:light dark;--pi-control-font-size:16px;--pi-control-font-family:var(--pi-font,system-ui, sans-serif);--pi-control-monospace-font-family:var(--pi-mono,ui-monospace, SFMono-Regular, Menlo, Consolas, monospace);--pi-bg:var(--pi-initial-bg);--pi-initial-bg:Canvas;--pi-initial-text:CanvasText;--pi-surface:color-mix(in srgb, var(--pi-bg) 95%, var(--pi-text));--pi-surface-hover:color-mix(in srgb, var(--pi-bg) 90%, var(--pi-text));--pi-terminal-bg:#05070a;--pi-terminal-text:#e6edf3;--pi-border:color-mix(in srgb, var(--pi-bg) 75%, var(--pi-text));--pi-border-muted:color-mix(in srgb, var(--pi-bg) 88%, var(--pi-text));--pi-text:var(--pi-initial-text);--pi-text-secondary:var(--pi-text);--pi-text-bright:var(--pi-text);--pi-muted:color-mix(in srgb, var(--pi-text) 65%, var(--pi-bg));--pi-dim:color-mix(in srgb, var(--pi-text) 50%, var(--pi-bg));--pi-accent:#58a6ff;--pi-accent-border:#2f81f7;--pi-selection-bg:#0d2847;--pi-success:#3fb950;--pi-success-border:#238636;--pi-success-bg:#0f1b12;--pi-success-surface:#0f2a16;--pi-success-ring:#3fb95055;--pi-warning:#d29922;--pi-warning-border:#6e5200;--pi-warning-surface:#1f1a10;--pi-danger:#ff7b72;--pi-purple:#d2a8ff;--pi-purple-border:#a371f7;--pi-purple-surface:#21132f;--pi-overlay:#0008;--pi-shadow-soft:#0006;--pi-shadow:#0008;--pi-shadow-strong:#000b;--pi-bg-overlay-soft:color-mix(in srgb, var(--pi-bg) 87%, transparent);--pi-bg-overlay:color-mix(in srgb, var(--pi-bg) 90%, transparent);--pi-success-bg-overlay:#0f1b12ee;--pi-terminal-selection:#264f78}@media (prefers-color-scheme:dark){:root{--lightningcss-light: ;--lightningcss-dark:initial}}html,body{background:var(--pi-bg);height:100%;color:var(--pi-text);margin:0;overflow:hidden}body{min-height:100dvh}html[data-pi-web-loading] pi-web-app{visibility:hidden}#pi-web-startup{--lightningcss-light:initial;--lightningcss-dark: ;color-scheme:light dark;color:canvastext;background:canvas;place-content:center;justify-items:center;font:16px system-ui,sans-serif;display:grid;position:fixed;inset:0}@media (prefers-color-scheme:dark){#pi-web-startup{--lightningcss-light: ;--lightningcss-dark:initial}}#pi-web-startup svg{color:#00f0d8;fill:currentColor;width:96px;height:16px;filter:drop-shadow(0 0 4px color-mix(in srgb, currentColor 25%, transparent));animation:2.4s ease-in-out infinite alternate pi-web-startup-glow;overflow:visible}@media (prefers-color-scheme:light){#pi-web-startup svg{color:#008c82}}html[data-pi-web-deployment=dev] #pi-web-startup svg{color:#a371f7}@keyframes pi-web-startup-glow{to{filter:drop-shadow(0 0 8px color-mix(in srgb, currentColor 45%, transparent))}}@media (prefers-reduced-motion:reduce){#pi-web-startup svg{animation:none}}html:not([data-pi-web-loading]) #pi-web-startup{display:none}</style>
13
- <script type="module" crossorigin src="./assets/index-C8SnDkf4.js"></script>
13
+ <script type="module" crossorigin src="./assets/index-AJX2U-nF.js"></script>
14
14
  <link rel="modulepreload" crossorigin href="./assets/preload-helper-CRzLMJPS.js">
15
15
  <link rel="modulepreload" crossorigin href="./assets/themePreference-BBiJxLjs.js">
16
16
  <link rel="modulepreload" crossorigin href="./assets/themeCatalog-B3yda95n.js">
package/dist/config.js CHANGED
@@ -24,6 +24,13 @@ export function defaultPiWebDataDir() {
24
24
  export const DEFAULT_MAX_UPLOAD_BYTES = 64 * 1024 * 1024;
25
25
  export const DEFAULT_UPLOADS_FOLDER = ".pi-web/uploads";
26
26
  export const DEFAULT_ATTACHMENT_FOLDER = ".pi-web/attachments";
27
+ /**
28
+ * Composer dictation defaults. Timeout covers one utterance round trip through
29
+ * the speech service; the byte cap applies after base64 decoding and stays far
30
+ * below the service-side per-file limit.
31
+ */
32
+ export const DEFAULT_SPEECH_TIMEOUT_MS = 60_000;
33
+ export const DEFAULT_SPEECH_MAX_AUDIO_BYTES = 8 * 1024 * 1024;
27
34
  /**
28
35
  * Default auto-cancel delay for extension dialogs whose extension set no
29
36
  * `timeout` of its own: five minutes. `extensionDialogsTimeoutMs: 0` waits
@@ -113,6 +120,17 @@ export function effectiveUploadsConfig(config = {}) {
113
120
  export function effectiveAttachmentsConfig(config = {}) {
114
121
  return { defaultFolder: config.attachments?.defaultFolder ?? DEFAULT_ATTACHMENT_FOLDER };
115
122
  }
123
+ /** Fill dictation defaults without resolving the bearer token, which stays in the environment. */
124
+ export function effectiveSpeechConfig(configured) {
125
+ if (configured === undefined)
126
+ return undefined;
127
+ return {
128
+ ...configured,
129
+ api: configured.api ?? "transcriptions",
130
+ timeoutMs: configured.timeoutMs ?? DEFAULT_SPEECH_TIMEOUT_MS,
131
+ maxAudioBytes: configured.maxAudioBytes ?? DEFAULT_SPEECH_MAX_AUDIO_BYTES,
132
+ };
133
+ }
116
134
  export function maxUploadBytes(env = process.env, config = {}) {
117
135
  const fromEnv = env["PI_WEB_MAX_UPLOAD_BYTES"];
118
136
  if (fromEnv !== undefined && fromEnv !== "")
@@ -186,6 +204,7 @@ export function resolveEffectivePiWebConfig(loaded, options = {}) {
186
204
  const agent = effectiveAgentConfig(env, config);
187
205
  const workbenchIntegration = effectiveWorkbenchIntegrationConfig(env, config.workbenchIntegration);
188
206
  const auditLog = effectiveAuditLogConfig(config.auditLog, env);
207
+ const speech = effectiveSpeechConfig(config.speech);
189
208
  return {
190
209
  ...loaded,
191
210
  config: {
@@ -194,6 +213,9 @@ export function resolveEffectivePiWebConfig(loaded, options = {}) {
194
213
  auditLog,
195
214
  uploads: effectiveUploadsConfig(config),
196
215
  attachments: effectiveAttachmentsConfig(config),
216
+ // Absent speech config keeps dictation off; the daemon advertises its
217
+ // capability only when an endpoint is configured.
218
+ ...(speech === undefined ? {} : { speech }),
197
219
  // Always resolved (on by default) so the effective config is the single
198
220
  // source of truth for the runtime state and the settings UI toggle.
199
221
  spawnSessions: spawnSessionsEnabled({}, config),