@codexhost/cli-linux-arm64 0.18.0-beta.4 → 0.18.0-beta.5

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 (46) hide show
  1. package/README.md +1 -1
  2. package/app/codexhost-distribution.json +1 -1
  3. package/app/console-server.mjs +93 -53
  4. package/app/console-web.js +159 -119
  5. package/app/desktop-controller.mjs +283 -113
  6. package/app/host-runtime.mjs +2129 -1529
  7. package/app/plugins/antigravity/plugin.mjs +787 -303
  8. package/app/plugins/claude-code/plugin.mjs +85 -45
  9. package/app/plugins/codebuddy/plugin.mjs +99 -59
  10. package/app/plugins/codex-usage/plugin.mjs +85 -45
  11. package/app/plugins/copilot/plugin.mjs +90 -50
  12. package/app/plugins/cursor-cli/plugin.mjs +113 -73
  13. package/app/plugins/deepseek-harness/plugin.mjs +116 -76
  14. package/app/plugins/devin/plugin.mjs +90 -50
  15. package/app/plugins/grok/plugin.mjs +96 -56
  16. package/app/plugins/hermes/plugin.mjs +77 -37
  17. package/app/plugins/kimi-code/plugin.mjs +94 -54
  18. package/app/plugins/kiro-cli/plugin.mjs +90 -50
  19. package/app/plugins/omp/plugin.mjs +81 -41
  20. package/app/plugins/opencode/plugin.mjs +78 -38
  21. package/app/plugins/pi/plugin.mjs +94 -54
  22. package/app/plugins/qoder/plugin.mjs +106 -66
  23. package/app/plugins/qoder-cn/plugin.mjs +106 -66
  24. package/app/plugins/qwen-code/plugin.mjs +101 -61
  25. package/app/plugins/workbuddy/plugin.mjs +99 -59
  26. package/app/plugins/zcode/plugin.mjs +82 -42
  27. package/app/renderer-extension.js +353 -295
  28. package/app/web/assets/{index-D1dOzBMI.js → index-C0aXz2jD.js} +63 -63
  29. package/app/web/codex-agent.png +0 -0
  30. package/app/web/codexhost-settings.js +154 -114
  31. package/app/web/index.html +1 -1
  32. package/app/web/plugins/deepseek-ai__dsh-api-remotes/client.js +1 -1
  33. package/app/web/plugins/deepseek-ai__dsh-api-session-controller/client.js +61 -61
  34. package/app/web/plugins/deepseek-ai__dsh-client-ui-chat/client.js +8 -8
  35. package/app/web/plugins/deepseek-ai__dsh-client-ui-codexhost/client.js +2 -2
  36. package/app/web/plugins/deepseek-ai__dsh-client-ui-conversation/client.js +12 -12
  37. package/app/web/plugins/deepseek-ai__dsh-client-ui-permission-presets/client.js +1 -1
  38. package/app/web/plugins/deepseek-ai__dsh-client-ui-settings/client.js +1 -1
  39. package/app/web/plugins/deepseek-ai__dsh-client-ui-tool/client.js +18 -18
  40. package/app/web/plugins/deepseek-ai__dsh-client-ui-workspace/client.js +8 -8
  41. package/app/web/sw.js +1 -6
  42. package/app/web-modules/server.mjs +2079 -1201
  43. package/bin/codexhost +0 -0
  44. package/libexec/codexhost-shim +0 -0
  45. package/libexec/codexhost-updater +0 -0
  46. package/package.json +1 -1
@@ -1 +1 @@
1
- window.__ModuleLoader__.load({id:`@deepseek-ai/dsh-client-ui-permission-presets`,factory:e=>{var t={exports:{}},n=t.exports;Object.defineProperty(n,Symbol.toStringTag,{value:`Module`});let r=e("react"),i=e("@deepseek-ai/dsh-client-ui-primitives"),a=e("react/jsx-runtime");function o(e){var t,n,r=``;if(typeof e==`string`||typeof e==`number`)r+=e;else if(typeof e==`object`){if(Array.isArray(e)){var i=e.length;for(t=0;t<i;t++)e[t]&&(n=o(e[t]))&&(r&&(r+=` `),r+=n)}else for(n in e)e[n]&&(r&&(r+=` `),r+=n)}return r}function s(){for(var e,t,n=0,r=``,i=arguments.length;n<i;n++)(e=arguments[n])&&(t=o(e))&&(r&&(r+=` `),r+=t);return r}let c=`permission.access`,l={mode:`访问模式,当前:{name}`,"codex.:read-only":`只读`,"codex.:workspace":`工作区写入`,"codex.:danger-full-access":`完全访问`,"native.configuration":`原生配置`,"native.configuration.description":`使用 Harness 原生权限配置,尚未匹配到已确认的权限模式。`,"native.atCreate":`此 Harness 仅允许在创建原生会话前选择权限模式。`,"native.confirm.title":`启用 {name}?`,"native.confirm.description":`此原生模式可能跳过权限确认,请确认你信任当前任务。`,"native.confirm.enable":`启用此模式`,"native.error":`权限切换失败:{message}`,close:`关闭`,"preset.readOnly":`仅可查看`,"preset.workspaceWrite":`工作区内修改`,"preset.fullAccess":`完全权限`,"confirm.title":`确认启用完全权限?`,"confirm.description":`启用完全权限后,智能体将减少确认步骤,并且可以直接执行更多操作,包括敏感操作、文件修改或外部命令。仅建议在你信任当前任务时使用。`,"confirm.acknowledge":`我已了解风险,并愿意继续`,"confirm.cancel":`取消`,"confirm.enable":`启用完全权限`,"auto.label":`Auto review`,"auto.badge":`EXP`,"auto.description":`无沙箱运行;每次原生工具调用和 PTC 内层调用前由同一模型进行实验性审查。`,"auto.confirm.title":`确认启用 Auto review(实验)?`,"auto.confirm.description":`Auto review 不使用沙箱。每次原生工具调用和 PTC 内层调用前,都会由与当前 agent 相同的模型进行审查;审查拒绝的调用由你批准或拒绝。此功能仍属实验性,可能误放行或误拒绝,并会消耗额外 token。`,"auto.confirm.acknowledge":`我已了解这些风险,并愿意继续`,"auto.confirm.enable":`启用 Auto review`},u={mode:`Access mode, current: {name}`,"codex.:read-only":`Read only`,"codex.:workspace":`Workspace write`,"codex.:danger-full-access":`Full access`,"native.configuration":`Native configuration`,"native.configuration.description":`Using the Harness's native permissions; no confirmed permission mode matches the catalog.`,"native.atCreate":`This Harness only allows permission selection before creating its native session.`,"native.confirm.title":`Enable {name}?`,"native.confirm.description":`This native mode may skip permission checks. Only enable it for a trusted task.`,"native.confirm.enable":`Enable mode`,"native.error":`Permission switch failed: {message}`,close:`Close`,"preset.readOnly":`Read Only`,"preset.workspaceWrite":`Workspace Write`,"preset.fullAccess":`Full access`,"confirm.title":`Enable Full access?`,"confirm.description":`Full access reduces confirmation steps and lets the agent perform more actions directly, including sensitive operations, file changes, or external commands. Only use it when you trust the current task.`,"confirm.acknowledge":`I understand the risks and want to continue`,"confirm.cancel":`Cancel`,"confirm.enable":`Enable Full access`,"auto.label":`Auto review`,"auto.badge":`EXP`,"auto.description":`Run without a sandbox after an experimental same-model review of every native tool call and PTC inner call.`,"auto.confirm.title":`Enable Auto review (experimental)?`,"auto.confirm.description":`Auto review runs without a sandbox. Before every native tool call and PTC inner call, the same model as the current agent reviews whether to allow it; you approve or reject each call it denies. This feature is experimental, can falsely allow or deny actions, and uses additional tokens.`,"auto.confirm.acknowledge":`I understand these risks and want to continue`,"auto.confirm.enable":`Enable Auto review`},d=`@deepseek-ai/dsh-client-ui-permission-presets/PermissionSelect.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(d)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-permission-presets`,e.dataset.pluginCss=d,e.textContent=`.DWdtSq_trigger{border-radius:var(--dsw-radius-sm);min-width:0;max-width:220px;height:28px;color:var(--dsw-alias-label-secondary);cursor:pointer;background:0 0;border:none;outline:none;align-items:center;gap:4px;padding:0 4px 0 8px;font-size:13px;font-weight:500;line-height:20px;display:inline-flex}.DWdtSq_trigger:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-hover)}.DWdtSq_trigger.DWdtSq_triggerDangerous:not(:disabled){color:#f28048}.DWdtSq_trigger.DWdtSq_triggerDangerous .DWdtSq_chevron{color:inherit;opacity:.7}.DWdtSq_trigger:focus-visible{box-shadow:0 0 0 2px var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary))}.DWdtSq_trigger:disabled{color:var(--dsw-alias-label-dimmed);cursor:default}.DWdtSq_triggerIcon{flex:none;display:inline-flex}.DWdtSq_triggerIcon svg{width:14px;height:14px}.DWdtSq_triggerLabel{text-overflow:ellipsis;white-space:nowrap;min-width:0;overflow:hidden}.DWdtSq_optionLabel{align-items:baseline;gap:4px;min-width:0;max-width:100%;display:inline-flex}.DWdtSq_optionLabelText{text-overflow:ellipsis;white-space:nowrap;min-width:0;overflow:hidden}.DWdtSq_badge{color:var(--dsw-alias-label-tertiary);letter-spacing:.2px;flex:none;align-self:flex-start;margin-top:-1px;font-size:8px;font-weight:600;line-height:10px}.DWdtSq_chevron{color:var(--dsw-alias-label-caption);flex:none;transition:transform .12s;display:inline-flex}@container (width<=460px){.DWdtSq_trigger:has(.DWdtSq_triggerIcon) .DWdtSq_triggerLabel{display:none}}.DWdtSq_chevronOpen{transform:rotate(180deg)}.DWdtSq_optionCopy{white-space:normal;text-align:left;flex-direction:column;gap:3px;min-width:0;max-width:270px;display:flex}.DWdtSq_description{color:var(--dsw-alias-label-tertiary);font-size:11px;line-height:16px}.DWdtSq_dangerous{color:var(--dsw-alias-state-danger-primary,#c2413b)}`,document.head.appendChild(e)}var f={badge:`DWdtSq_badge`,chevron:`DWdtSq_chevron`,chevronOpen:`DWdtSq_chevronOpen`,dangerous:`DWdtSq_dangerous`,description:`DWdtSq_description`,optionCopy:`DWdtSq_optionCopy`,optionLabel:`DWdtSq_optionLabel`,optionLabelText:`DWdtSq_optionLabelText`,trigger:`DWdtSq_trigger`,triggerDangerous:`DWdtSq_triggerDangerous`,triggerIcon:`DWdtSq_triggerIcon`,triggerLabel:`DWdtSq_triggerLabel`};let p=()=>/* @__PURE__ */ (0,a.jsxs)(`svg`,{width:16,height:16,viewBox:`0 0 16 16`,fill:`none`,"aria-hidden":`true`,children:[/* @__PURE__ */ (0,a.jsx)(`path`,{d:`M8 1.75 2.75 3.6v3.9c0 3.1 2.1 5.4 5.25 6.75 3.15-1.35 5.25-3.65 5.25-6.75V3.6L8 1.75Z`,stroke:`currentColor`,strokeWidth:`1.2`,strokeLinejoin:`round`}),/* @__PURE__ */ (0,a.jsx)(`path`,{d:`M8 5.6v3`,stroke:`currentColor`,strokeWidth:`1.2`,strokeLinecap:`round`}),/* @__PURE__ */ (0,a.jsx)(`circle`,{cx:`8`,cy:`10.6`,r:`0.75`,fill:`currentColor`})]});function m({locked:e,select:t,useProjection:n,t:o}){let c=n(`permissions`),l=n(`nativePermissions`),[d,m]=(0,r.useState)(null),[h,g]=(0,r.useState)(!1),[_,v]=(0,r.useState)(null),[y,b]=(0,r.useState)(!1),[x,S]=(0,r.useState)(null),C=e||l?.locked===!0;if((0,r.useEffect)(()=>{(C||!l?.selectable||!l.catalog||_!==null&&!l.catalog.modes.some(e=>e.id===_.id))&&(g(!1),v(null),b(!1))},[l,C,_]),c===void 0||!l?.selectable||l.catalog===null)return null;let w=l.catalog.modes.map(e=>{let t=`codex.${e.id}`;return l.harnessId===`codex`&&Object.hasOwn(u,t)?{...e,label:o(t)}:e}),T=w.find(e=>e.id===c.currentValue),E=T?.label??o(`native.configuration`),D=d!==null||_!==null,O=()=>{b(!1),v(null)},k=e=>{m(e),t(e).catch(e=>{let t=e instanceof Error?e.message:String(e);S(e=>({text:t,seq:(e?.seq??0)+1}))}).finally(()=>m(null))};return/* @__PURE__ */ (0,a.jsxs)(a.Fragment,{children:[/* @__PURE__ */ (0,a.jsx)(i.Menu,{open:h,portal:!0,side:`top`,selectedId:c.currentValue,items:w.map(e=>({id:e.id,label:/* @__PURE__ */ (0,a.jsxs)(`span`,{className:s(f.optionCopy,e.dangerous&&f.dangerous),children:[/* @__PURE__ */ (0,a.jsx)(`span`,{children:e.label}),e.description?/* @__PURE__ */ (0,a.jsx)(`span`,{className:f.description,children:e.description}):null]}),...e.dangerous?{icon:/* @__PURE__ */ (0,a.jsx)(i.IconWarningOutlineRegular,{size:16})}:{}})),onSelect:e=>{if(g(!1),C||D||e===c.currentValue)return;let t=w.find(t=>t.id===e);t&&(t.dangerous?(b(!1),v(t)):k(e))},onClose:()=>g(!1),footer:l.scope===`atCreate`?[{type:`label`,id:`scope`,text:o(`native.atCreate`)}]:[],anchor:/* @__PURE__ */ (0,a.jsxs)(`button`,{type:`button`,className:s(f.trigger,T?.dangerous&&f.triggerDangerous),"aria-label":o(`mode`,{name:E}),title:l.locked?o(`native.atCreate`):T?T.description:o(`native.configuration.description`),disabled:C||D,onClick:()=>g(!h),children:[/* @__PURE__ */ (0,a.jsx)(`span`,{className:f.triggerIcon,children:T?.dangerous?/* @__PURE__ */ (0,a.jsx)(p,{}):/* @__PURE__ */ (0,a.jsx)(i.IconShieldOutlineRegular,{})}),/* @__PURE__ */ (0,a.jsx)(`span`,{className:f.triggerLabel,children:E}),/* @__PURE__ */ (0,a.jsx)(`span`,{className:s(f.chevron,h&&f.chevronOpen),children:/* @__PURE__ */ (0,a.jsx)(i.IconChevronDownOutlineRegular,{})})]})}),_?/* @__PURE__ */ (0,a.jsx)(i.RiskConfirmation,{open:!0,title:o(`native.confirm.title`,{name:_.label}),description:_.description??o(`native.confirm.description`),acknowledgeLabel:o(`confirm.acknowledge`),cancelLabel:o(`confirm.cancel`),closeLabel:o(`close`),confirmLabel:o(`native.confirm.enable`),acknowledged:y,disabled:C,onAcknowledgedChange:b,onCancel:O,onConfirm:()=>{let e=_.id;O(),k(e)}}):null,x?/* @__PURE__ */ (0,a.jsx)(i.Toast,{text:o(`native.error`,{message:x.text}),icon:/* @__PURE__ */ (0,a.jsx)(i.IconWarningOutlineRegular,{}),onDone:()=>S(null)},x.seq):null]})}let h=[`commandUi`,`sessions`,`slots`,`locale`,`remote`,`remote.commands`];function g(e){return e?.projections.faceOf(`nativePermissions`).getSnapshot()}function _(e){let t=e.get(`commandUi`),n=e.sessions;e.effect(()=>e.locale.register(c,{zh:l,en:u}),`ui-permission: native dictionaries`);let r=e.locale.bind(c),i=async(t,r)=>{if(n.binding(t)===void 0)throw Error(`This session is not materialized yet.`);let i=g(n.binding(t)?.session);if(!i?.selectable||i.locked||!i.catalog?.modes.some(e=>e.id===r))throw Error(`Native permission mode selection is unavailable for this session.`);let a=await e.remote.commands.execute(t,`/permission ${r}`,[]);if(!a.ok)throw Error(a.error.message);if(a.value===void 0)throw Error(`The Host offers no /permission command.`);if(a.value.result?.kind===`error`)throw Error(a.value.result.text??`Native permission switch failed.`);return!0};e.slots.inject(`conversation.input.permission`,()=>e.slots.register({name:`conversation.input.permission`,locale:c,inject:e=>({select:t=>i(e,t)})},m)),e.effect(()=>t.decorate({name:`permission`,available:e=>{let t=g(n.binding(e.sessionId)?.session);return t?.selectable===!0&&!t.locked},ui:{kind:`popupSelect`,options:async e=>{let t=n.binding(e.sessionId)?.session,i=g(t);if(!i?.selectable||i.locked||!i.catalog)throw Error(`Native permissions unavailable.`);let a=t?.projections.faceOf(`permissions`).getSnapshot();return i.catalog.modes.map(e=>({id:e.id,label:e.label,...e.description?{detail:e.description}:{},...e.id===a?.currentValue?{active:!0}:{},...e.dangerous?{confirmation:{title:r(`native.confirm.title`,{name:e.label}),description:e.description??r(`native.confirm.description`),acknowledgeLabel:r(`confirm.acknowledge`),cancelLabel:r(`confirm.cancel`),confirmLabel:r(`native.confirm.enable`)}}:{}}))},onSelect:(e,t)=>i(t.sessionId,e.id).then(()=>void 0)}}),`ui-permission: native /permission picker`)}return n.apply=_,n.inject=h,t.exports}});
1
+ window.__ModuleLoader__.load({id:`@deepseek-ai/dsh-client-ui-permission-presets`,factory:e=>{var t={exports:{}},n=t.exports;Object.defineProperty(n,Symbol.toStringTag,{value:`Module`});let r=e("react"),i=e("@deepseek-ai/dsh-client-ui-primitives"),a=e("react/jsx-runtime");function o(e){var t,n,r=``;if(typeof e==`string`||typeof e==`number`)r+=e;else if(typeof e==`object`){if(Array.isArray(e)){var i=e.length;for(t=0;t<i;t++)e[t]&&(n=o(e[t]))&&(r&&(r+=` `),r+=n)}else for(n in e)e[n]&&(r&&(r+=` `),r+=n)}return r}function s(){for(var e,t,n=0,r=``,i=arguments.length;n<i;n++)(e=arguments[n])&&(t=o(e))&&(r&&(r+=` `),r+=t);return r}let c=`permission.access`,l={mode:`访问模式,当前:{name}`,"codex.:read-only":`只读`,"codex.:workspace":`工作区写入`,"codex.:danger-full-access":`完全访问`,"codex.configuration":`跟随 Codex 设置`,"codex.configuration.description":`未选择权限档案,由 Codex 当前配置决定。`,"native.configuration":`原生配置`,"native.configuration.description":`使用 Harness 原生权限配置,尚未匹配到已确认的权限模式。`,"native.atCreate":`此 Harness 仅允许在创建原生会话前选择权限模式。`,"native.confirm.title":`启用 {name}?`,"native.confirm.description":`此原生模式可能跳过权限确认,请确认你信任当前任务。`,"native.confirm.enable":`启用此模式`,"native.error":`权限切换失败:{message}`,close:`关闭`,"preset.readOnly":`仅可查看`,"preset.workspaceWrite":`工作区内修改`,"preset.fullAccess":`完全权限`,"confirm.title":`确认启用完全权限?`,"confirm.description":`启用完全权限后,智能体将减少确认步骤,并且可以直接执行更多操作,包括敏感操作、文件修改或外部命令。仅建议在你信任当前任务时使用。`,"confirm.acknowledge":`我已了解风险,并愿意继续`,"confirm.cancel":`取消`,"confirm.enable":`启用完全权限`,"auto.label":`Auto review`,"auto.badge":`EXP`,"auto.description":`无沙箱运行;每次原生工具调用和 PTC 内层调用前由同一模型进行实验性审查。`,"auto.confirm.title":`确认启用 Auto review(实验)?`,"auto.confirm.description":`Auto review 不使用沙箱。每次原生工具调用和 PTC 内层调用前,都会由与当前 agent 相同的模型进行审查;审查拒绝的调用由你批准或拒绝。此功能仍属实验性,可能误放行或误拒绝,并会消耗额外 token。`,"auto.confirm.acknowledge":`我已了解这些风险,并愿意继续`,"auto.confirm.enable":`启用 Auto review`},u={mode:`Access mode, current: {name}`,"codex.:read-only":`Read only`,"codex.:workspace":`Workspace write`,"codex.:danger-full-access":`Full access`,"codex.configuration":`Follow Codex settings`,"codex.configuration.description":`No permission profile is selected; Codex applies its current configuration.`,"native.configuration":`Native configuration`,"native.configuration.description":`Using the Harness's native permissions; no confirmed permission mode matches the catalog.`,"native.atCreate":`This Harness only allows permission selection before creating its native session.`,"native.confirm.title":`Enable {name}?`,"native.confirm.description":`This native mode may skip permission checks. Only enable it for a trusted task.`,"native.confirm.enable":`Enable mode`,"native.error":`Permission switch failed: {message}`,close:`Close`,"preset.readOnly":`Read Only`,"preset.workspaceWrite":`Workspace Write`,"preset.fullAccess":`Full access`,"confirm.title":`Enable Full access?`,"confirm.description":`Full access reduces confirmation steps and lets the agent perform more actions directly, including sensitive operations, file changes, or external commands. Only use it when you trust the current task.`,"confirm.acknowledge":`I understand the risks and want to continue`,"confirm.cancel":`Cancel`,"confirm.enable":`Enable Full access`,"auto.label":`Auto review`,"auto.badge":`EXP`,"auto.description":`Run without a sandbox after an experimental same-model review of every native tool call and PTC inner call.`,"auto.confirm.title":`Enable Auto review (experimental)?`,"auto.confirm.description":`Auto review runs without a sandbox. Before every native tool call and PTC inner call, the same model as the current agent reviews whether to allow it; you approve or reject each call it denies. This feature is experimental, can falsely allow or deny actions, and uses additional tokens.`,"auto.confirm.acknowledge":`I understand these risks and want to continue`,"auto.confirm.enable":`Enable Auto review`},d=`@deepseek-ai/dsh-client-ui-permission-presets/PermissionSelect.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(d)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-permission-presets`,e.dataset.pluginCss=d,e.textContent=`.DWdtSq_trigger{border-radius:var(--dsw-radius-sm);min-width:0;max-width:220px;height:28px;color:var(--dsw-alias-label-secondary);cursor:pointer;background:0 0;border:none;outline:none;align-items:center;gap:4px;padding:0 4px 0 8px;font-size:13px;font-weight:500;line-height:20px;display:inline-flex}.DWdtSq_trigger:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-hover)}.DWdtSq_trigger.DWdtSq_triggerDangerous:not(:disabled){color:#f28048}.DWdtSq_trigger.DWdtSq_triggerDangerous .DWdtSq_chevron{color:inherit;opacity:.7}.DWdtSq_trigger:focus-visible{box-shadow:0 0 0 2px var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary))}.DWdtSq_trigger:disabled{color:var(--dsw-alias-label-dimmed);cursor:default}.DWdtSq_triggerIcon{flex:none;display:inline-flex}.DWdtSq_triggerIcon svg{width:14px;height:14px}.DWdtSq_triggerLabel{text-overflow:ellipsis;white-space:nowrap;min-width:0;overflow:hidden}.DWdtSq_optionLabel{align-items:baseline;gap:4px;min-width:0;max-width:100%;display:inline-flex}.DWdtSq_optionLabelText{text-overflow:ellipsis;white-space:nowrap;min-width:0;overflow:hidden}.DWdtSq_badge{color:var(--dsw-alias-label-tertiary);letter-spacing:.2px;flex:none;align-self:flex-start;margin-top:-1px;font-size:8px;font-weight:600;line-height:10px}.DWdtSq_chevron{color:var(--dsw-alias-label-caption);flex:none;transition:transform .12s;display:inline-flex}@container (width<=460px){.DWdtSq_trigger:has(.DWdtSq_triggerIcon) .DWdtSq_triggerLabel{display:none}}.DWdtSq_chevronOpen{transform:rotate(180deg)}.DWdtSq_optionCopy{white-space:normal;text-align:left;flex-direction:column;gap:3px;min-width:0;max-width:270px;display:flex}.DWdtSq_description{color:var(--dsw-alias-label-tertiary);font-size:11px;line-height:16px}.DWdtSq_dangerous{color:var(--dsw-alias-state-danger-primary,#c2413b)}`,document.head.appendChild(e)}var f={badge:`DWdtSq_badge`,chevron:`DWdtSq_chevron`,chevronOpen:`DWdtSq_chevronOpen`,dangerous:`DWdtSq_dangerous`,description:`DWdtSq_description`,optionCopy:`DWdtSq_optionCopy`,optionLabel:`DWdtSq_optionLabel`,optionLabelText:`DWdtSq_optionLabelText`,trigger:`DWdtSq_trigger`,triggerDangerous:`DWdtSq_triggerDangerous`,triggerIcon:`DWdtSq_triggerIcon`,triggerLabel:`DWdtSq_triggerLabel`};let p=()=>/* @__PURE__ */ (0,a.jsxs)(`svg`,{width:16,height:16,viewBox:`0 0 16 16`,fill:`none`,"aria-hidden":`true`,children:[/* @__PURE__ */ (0,a.jsx)(`path`,{d:`M8 1.75 2.75 3.6v3.9c0 3.1 2.1 5.4 5.25 6.75 3.15-1.35 5.25-3.65 5.25-6.75V3.6L8 1.75Z`,stroke:`currentColor`,strokeWidth:`1.2`,strokeLinejoin:`round`}),/* @__PURE__ */ (0,a.jsx)(`path`,{d:`M8 5.6v3`,stroke:`currentColor`,strokeWidth:`1.2`,strokeLinecap:`round`}),/* @__PURE__ */ (0,a.jsx)(`circle`,{cx:`8`,cy:`10.6`,r:`0.75`,fill:`currentColor`})]});function m({locked:e,select:t,useProjection:n,t:o}){let c=n(`permissions`),l=n(`nativePermissions`),[d,m]=(0,r.useState)(null),[h,g]=(0,r.useState)(!1),[_,v]=(0,r.useState)(null),[y,b]=(0,r.useState)(!1),[x,S]=(0,r.useState)(null),C=e||l?.locked===!0;if((0,r.useEffect)(()=>{(C||!l?.selectable||!l.catalog||_!==null&&!l.catalog.modes.some(e=>e.id===_.id))&&(g(!1),v(null),b(!1))},[l,C,_]),c===void 0||!l?.selectable||l.catalog===null)return null;let w=l.catalog.modes.map(e=>{let t=`codex.${e.id}`;return l.harnessId===`codex`&&Object.hasOwn(u,t)?{...e,label:o(t)}:e}),T=w.find(e=>e.id===c.currentValue),E=l.harnessId===`codex`&&c.currentValue===``,D=T?.label??o(E?`codex.configuration`:`native.configuration`),O=o(E?`codex.configuration.description`:`native.configuration.description`),k=d!==null||_!==null,A=()=>{b(!1),v(null)},j=e=>{m(e),t(e).catch(e=>{let t=e instanceof Error?e.message:String(e);S(e=>({text:t,seq:(e?.seq??0)+1}))}).finally(()=>m(null))};return/* @__PURE__ */ (0,a.jsxs)(a.Fragment,{children:[/* @__PURE__ */ (0,a.jsx)(i.Menu,{open:h,portal:!0,side:`top`,selectedId:c.currentValue,items:w.map(e=>({id:e.id,label:/* @__PURE__ */ (0,a.jsxs)(`span`,{className:s(f.optionCopy,e.dangerous&&f.dangerous),children:[/* @__PURE__ */ (0,a.jsx)(`span`,{children:e.label}),e.description?/* @__PURE__ */ (0,a.jsx)(`span`,{className:f.description,children:e.description}):null]}),...e.dangerous?{icon:/* @__PURE__ */ (0,a.jsx)(i.IconWarningOutlineRegular,{size:16})}:{}})),onSelect:e=>{if(g(!1),C||k||e===c.currentValue)return;let t=w.find(t=>t.id===e);t&&(t.dangerous?(b(!1),v(t)):j(e))},onClose:()=>g(!1),footer:l.scope===`atCreate`?[{type:`label`,id:`scope`,text:o(`native.atCreate`)}]:[],anchor:/* @__PURE__ */ (0,a.jsxs)(`button`,{type:`button`,className:s(f.trigger,T?.dangerous&&f.triggerDangerous),"aria-label":o(`mode`,{name:D}),title:l.locked?o(`native.atCreate`):T?T.description:O,disabled:C||k,onClick:()=>g(!h),children:[/* @__PURE__ */ (0,a.jsx)(`span`,{className:f.triggerIcon,children:T?.dangerous?/* @__PURE__ */ (0,a.jsx)(p,{}):/* @__PURE__ */ (0,a.jsx)(i.IconShieldOutlineRegular,{})}),/* @__PURE__ */ (0,a.jsx)(`span`,{className:f.triggerLabel,children:D}),/* @__PURE__ */ (0,a.jsx)(`span`,{className:s(f.chevron,h&&f.chevronOpen),children:/* @__PURE__ */ (0,a.jsx)(i.IconChevronDownOutlineRegular,{})})]})}),_?/* @__PURE__ */ (0,a.jsx)(i.RiskConfirmation,{open:!0,title:o(`native.confirm.title`,{name:_.label}),description:_.description??o(`native.confirm.description`),acknowledgeLabel:o(`confirm.acknowledge`),cancelLabel:o(`confirm.cancel`),closeLabel:o(`close`),confirmLabel:o(`native.confirm.enable`),acknowledged:y,disabled:C,onAcknowledgedChange:b,onCancel:A,onConfirm:()=>{let e=_.id;A(),j(e)}}):null,x?/* @__PURE__ */ (0,a.jsx)(i.Toast,{text:o(`native.error`,{message:x.text}),icon:/* @__PURE__ */ (0,a.jsx)(i.IconWarningOutlineRegular,{}),onDone:()=>S(null)},x.seq):null]})}let h=[`commandUi`,`sessions`,`slots`,`locale`,`remote`,`remote.commands`];function g(e){return e?.projections.faceOf(`nativePermissions`).getSnapshot()}function _(e){let t=e.get(`commandUi`),n=e.sessions;e.effect(()=>e.locale.register(c,{zh:l,en:u}),`ui-permission: native dictionaries`);let r=e.locale.bind(c),i=async(t,r)=>{if(n.binding(t)===void 0)throw Error(`This session is not materialized yet.`);let i=g(n.binding(t)?.session);if(!i?.selectable||i.locked||!i.catalog?.modes.some(e=>e.id===r))throw Error(`Native permission mode selection is unavailable for this session.`);let a=await e.remote.commands.execute(t,`/permission ${r}`,[]);if(!a.ok)throw Error(a.error.message);if(a.value===void 0)throw Error(`The Host offers no /permission command.`);if(a.value.result?.kind===`error`)throw Error(a.value.result.text??`Native permission switch failed.`);return!0};e.slots.inject(`conversation.input.permission`,()=>e.slots.register({name:`conversation.input.permission`,locale:c,inject:e=>({select:t=>i(e,t)})},m)),e.effect(()=>t.decorate({name:`permission`,available:e=>{let t=g(n.binding(e.sessionId)?.session);return t?.selectable===!0&&!t.locked},ui:{kind:`popupSelect`,options:async e=>{let t=n.binding(e.sessionId)?.session,i=g(t);if(!i?.selectable||i.locked||!i.catalog)throw Error(`Native permissions unavailable.`);let a=t?.projections.faceOf(`permissions`).getSnapshot();return i.catalog.modes.map(e=>({id:e.id,label:e.label,...e.description?{detail:e.description}:{},...e.id===a?.currentValue?{active:!0}:{},...e.dangerous?{confirmation:{title:r(`native.confirm.title`,{name:e.label}),description:e.description??r(`native.confirm.description`),acknowledgeLabel:r(`confirm.acknowledge`),cancelLabel:r(`confirm.cancel`),confirmLabel:r(`native.confirm.enable`)}}:{}}))},onSelect:(e,t)=>i(t.sessionId,e.id).then(()=>void 0)}}),`ui-permission: native /permission picker`)}return n.apply=_,n.inject=h,t.exports}});
@@ -1 +1 @@
1
- window.__ModuleLoader__.load({id:`@deepseek-ai/dsh-client-ui-settings`,factory:e=>{var t={exports:{}},n=t.exports;Object.defineProperty(n,Symbol.toStringTag,{value:`Module`});let r=e("@deepseek-ai/cordis"),i=e("@deepseek-ai/dsh-client-store");function a(e){return e==null}function o(e){return e&&typeof e==`object`&&!Array.isArray(e)}function s(e,t){return Object.fromEntries(Object.entries(e).filter(([e,n])=>t(e,n)))}function c(e,t){return Object.fromEntries(Object.entries(e).map(([e,n])=>[e,t(n,e)]))}function l(e,t,n){if(!t)return{...e};let r={};for(let i of t)(n||e[i]!==void 0)&&(r[i]=e[i]);return r}let u=Symbol.for(`cosmokit.volatile.write`);function d(e,t=/* @__PURE__ */ new Set){if(typeof e==`function`)throw TypeError(`volatile config cannot contain functions`);if(typeof e!=`object`||!e)return e;if(t.has(e))throw TypeError(`volatile config cannot contain cycles`);t.add(e);try{if(Array.isArray(e))return Object.freeze(e.map(e=>d(e,t)));if(Object.getPrototypeOf(e)!==Object.prototype&&Object.getPrototypeOf(e)!==null)throw TypeError(`volatile config objects must be plain objects or arrays`);return Object.freeze(Object.fromEntries(Object.entries(e).map(([e,n])=>[e,d(n,t)])))}finally{t.delete(e)}}function f(e){let t=d(e);return Object.freeze({get:()=>t,[u]:e=>{t=e}})}function p(e){return typeof e==`object`&&!!e&&u in e}function m(e,t){return arguments.length===1?t=>m(e,t):e in globalThis&&t instanceof globalThis[e]||Object.prototype.toString.call(t).slice(8,-1)===e}function h(e){return m(`ArrayBuffer`,e)||m(`SharedArrayBuffer`,e)}function g(e){return h(e)||ArrayBuffer.isView(e)}let _;(function(e){e.is=h,e.isSource=g;function t(e){return ArrayBuffer.isView(e)?e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength):e}e.fromSource=t;function n(e){if(e=t(e),typeof Buffer<`u`)return Buffer.from(e).toString(`base64`);let n=``,r=new Uint8Array(e);for(let e=0;e<r.byteLength;e++)n+=String.fromCharCode(r[e]);return btoa(n)}e.toBase64=n;function r(e){return typeof Buffer<`u`?t(Buffer.from(e,`base64`)):Uint8Array.from(atob(e),e=>e.charCodeAt(0))}e.fromBase64=r;function i(e){return e=t(e),typeof Buffer<`u`?Buffer.from(e).toString(`hex`):Array.from(new Uint8Array(e),e=>e.toString(16).padStart(2,`0`)).join(``)}e.toHex=i;function a(e){if(typeof Buffer<`u`)return t(Buffer.from(e,`hex`));let n=e.length%2==0?e:e.slice(0,e.length-1),r=[];for(let e=0;e<n.length;e+=2)r.push(parseInt(`${n[e]}${n[e+1]}`,16));return Uint8Array.from(r).buffer}e.fromHex=a})(_||={}),_.fromBase64,_.toBase64,_.fromHex,_.toHex;function v(e,t=/* @__PURE__ */ new Map){if(!e||typeof e!=`object`)return e;if(m(`Date`,e))return new Date(e.valueOf());if(m(`RegExp`,e))return new RegExp(e.source,e.flags);if(h(e))return e.slice(0);if(ArrayBuffer.isView(e))return e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength);let n=t.get(e);if(n)return n;if(Array.isArray(e)){let n=[];return t.set(e,n),e.forEach((e,r)=>{n[r]=Reflect.apply(v,null,[e,t])}),n}let r=Object.create(Object.getPrototypeOf(e));t.set(e,r);for(let n of Reflect.ownKeys(e)){let i={...Reflect.getOwnPropertyDescriptor(e,n)};`value`in i&&(i.value=Reflect.apply(v,null,[i.value,t])),Reflect.defineProperty(r,n,i)}return r}function y(e,t,n){let r=/* @__PURE__ */ new Set;function i(e,t){if(e===t)return!0;if(p(e)||p(t))return p(e)&&p(t);if(!n&&a(e)&&a(t))return!0;if(typeof e!=typeof t||typeof e!=`object`||!e||!t||r.has(e))return!1;function o(n,r){return n(e)?n(t)?r(e,t):!1:!n(t)&&void 0}r.add(e);try{return o(Array.isArray,(e,t)=>{if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!i(e[n],t[n]))return!1;return!0})??o(m(`Date`),(e,t)=>e.valueOf()===t.valueOf())??o(m(`URL`),(e,t)=>e.href===t.href)??o(m(`RegExp`),(e,t)=>e.source===t.source&&e.flags===t.flags)??o(h,(e,t)=>{if(e.byteLength!==t.byteLength)return!1;let n=new Uint8Array(e),r=new Uint8Array(t);for(let e=0;e<n.length;e++)if(n[e]!==r[e])return!1;return!0})??((!n||[e,t].every(e=>Object.getPrototypeOf(e)===Object.prototype||Object.getPrototypeOf(e)===null))&&Object.keys({...e,...t}).every(n=>i(e[n],t[n])))}finally{r.delete(e)}}return i(e,t)}let b;(function(e){e.millisecond=1;let t=e.second=1e3,n=e.minute=t*60,r=e.hour=n*60,i=e.day=r*24,a=e.week=i*7,o=(/* @__PURE__ */ new Date()).getTimezoneOffset();function s(e){o=e}e.setTimezoneOffset=s;function c(){return o}e.getTimezoneOffset=c;function l(e=/* @__PURE__ */ new Date,t){return typeof e==`number`&&(e=new Date(e)),t===void 0&&(t=o),Math.floor((e.valueOf()/n-t)/1440)}e.getDateNumber=l;function u(e,t){let r=new Date(e*i);return t===void 0&&(t=o),new Date(+r+t*n)}e.fromDateNumber=u;let d=RegExp(`^${[`w(?:eek(?:s)?)?`,`d(?:ay(?:s)?)?`,`h(?:our(?:s)?)?`,`m(?:in(?:ute)?(?:s)?)?`,`s(?:ec(?:ond)?(?:s)?)?`].map(e=>`(\\d+(?:\\.\\d+)?${e})?`).join(``)}$`);function f(e){let o=d.exec(e);return o?(parseFloat(o[1])*a||0)+(parseFloat(o[2])*i||0)+(parseFloat(o[3])*r||0)+(parseFloat(o[4])*n||0)+(parseFloat(o[5])*t||0):0}e.parseTime=f;function p(e){let t=f(e);return t?e=Date.now()+t:/^\d{1,2}(:\d{1,2}){1,2}$/.test(e)?e=`${(/* @__PURE__ */ new Date()).toLocaleDateString()}-${e}`:/^\d{1,2}-\d{1,2}-\d{1,2}(:\d{1,2}){1,2}$/.test(e)&&(e=`${(/* @__PURE__ */ new Date()).getFullYear()}-${e}`),e?new Date(e):/* @__PURE__ */ new Date}e.parseDate=p;function m(e){let a=Math.abs(e);return a>=i-r/2?Math.round(e/i)+`d`:a>=r-n/2?Math.round(e/r)+`h`:a>=n-t/2?Math.round(e/n)+`m`:a>=t?Math.round(e/t)+`s`:e+`ms`}e.format=m;function h(e,t=2){return e.toString().padStart(t,`0`)}e.toDigits=h;function g(e,t=/* @__PURE__ */ new Date){return e.replace(`yyyy`,t.getFullYear().toString()).replace(`yy`,t.getFullYear().toString().slice(2)).replace(`MM`,h(t.getMonth()+1)).replace(`dd`,h(t.getDate())).replace(`hh`,h(t.getHours())).replace(`mm`,h(t.getMinutes())).replace(`ss`,h(t.getSeconds())).replace(`SSS`,h(t.getMilliseconds(),3))}e.template=g})(b||={});let x=Symbol.for(`schemastery`),S=Symbol.for(`ValidationError`);globalThis.__schemastery_index__??=0,globalThis.__schemastery_refs__=void 0;var C=class extends TypeError{options;name=`ValidationError`;constructor(e,t){let n=`$`;for(let e of t.path||[])typeof e==`string`?n+=`.`+e:typeof e==`number`?n+=`[`+e+`]`:typeof e==`symbol`&&(n+=`[Symbol(${e.toString()})]`);n.startsWith(`.`)&&(n=n.slice(1)),super((n===`$`?``:`${n} `)+e),this.options=t}static is(e){return!!e?.[S]}};Object.defineProperty(C.prototype,S,{value:!0});let w=function(e){let t=function(e,n={}){return w.resolve(e,t,n)[0]};if(e.refs){let t=c(e.refs,e=>new w(e)),n=e=>t[e];for(let e in t){let r=t[e];r.sKey=n(r.sKey),r.inner=n(r.inner),r.list=r.list&&r.list.map(n),r.dict=r.dict&&c(r.dict,n)}return t[e.uid]}if(Object.assign(t,e),typeof t.callback==`string`)try{t.callback=Function(`return `+t.callback)()}catch{}return Object.defineProperty(t,"uid",{value:globalThis.__schemastery_index__++}),Object.setPrototypeOf(t,w.prototype),t.meta||={},t.toString=t.toString.bind(t),t};w.prototype=Object.create(Function.prototype),w.prototype[x]=!0,Object.defineProperty(w.prototype,"~standard",{get(){return{version:1,vendor:`schemastery`,validate:e=>{try{return{value:w.resolve(e,this,{})[0]}}catch(e){if(C.is(e))return{issues:[{message:e.message,path:e.options.path}]};throw e}}}}}),w.ValidationError=C,w.prototype.toJSON=function(){if(globalThis.__schemastery_refs__)return globalThis.__schemastery_refs__[this.uid]??=JSON.parse(JSON.stringify({...this})),this.uid;globalThis.__schemastery_refs__={[this.uid]:{...this}},globalThis.__schemastery_refs__[this.uid]=JSON.parse(JSON.stringify({...this}));let e={uid:this.uid,refs:globalThis.__schemastery_refs__};return globalThis.__schemastery_refs__=void 0,e},w.prototype.set=function(e,t){return this.dict[e]=t,this},w.prototype.push=function(e){return this.list.push(e),this};function T(e,t){let n=typeof e==`string`?{"":e}:{...e};for(let e in t){let r=t[e];r?.$description||r?.$desc?n[e]=r.$description||r.$desc:typeof r==`string`&&(n[e]=r)}return n}function E(e){return e?.$value??e?.$inner}function D(e){return s(e??{},e=>!e.startsWith(`$`))}w.prototype.i18n=function(e){let t=w(this),n=T(t.meta.description,e);return Object.keys(n).length&&(t.meta.description=n),t.dict&&=c(t.dict,(t,n)=>t.i18n(c(e,e=>E(e)?.[n]??e?.[n]))),t.list&&=t.list.map((t,n)=>t.i18n(c(e,(e={})=>Array.isArray(E(e))?E(e)[n]:Array.isArray(e)?e[n]:D(e)))),t.inner&&=t.inner.i18n(c(e,e=>E(e)?E(e):D(e))),t.sKey&&=t.sKey.i18n(c(e,e=>e?.$key)),t},w.prototype.extra=function(e,t){let n=w(this);return n.meta={...n.meta,[e]:t},n};for(let e of[`required`,`disabled`,`collapse`,`hidden`,`loose`])Object.assign(w.prototype,{[e](t=!0){let n=w(this);return n.meta={...n.meta,[e]:t},n}});w.prototype.deprecated=function(){let e=w(this);return e.meta.badges||=[],e.meta.badges.push({text:`deprecated`,type:`danger`}),e},w.prototype.experimental=function(){let e=w(this);return e.meta.badges||=[],e.meta.badges.push({text:`experimental`,type:`warning`}),e},w.prototype.pattern=function(e){let t=w(this),n=l(e,[`source`,`flags`]);return t.meta={...t.meta,pattern:n},t},w.prototype.simplify=function(e){if(p(e)&&(e=e.get()),y(e,this.meta.default,this.type===`dict`))return null;if(a(e))return e;if(this.type===`object`||this.type===`dict`){let t={};for(let n in e){let r=(this.type===`object`?this.dict[n]:this.inner)?.simplify(e[n]);(this.type===`dict`||!a(r))&&(t[n]=r)}return y(t,this.meta.default,this.type===`dict`)?null:t}if(this.type===`array`||this.type===`tuple`){let t=[];return e.forEach((e,n)=>{let r=this.type===`array`?this.inner:this.list[n],i=r?r.simplify(e):e;t.push(i)}),t}if(this.type===`intersect`){let t={};for(let n of this.list)Object.assign(t,n.simplify(e));return t}if(this.type===`union`)for(let t of this.list)try{return w.resolve(e,t,{}),t.simplify(e)}catch{}return e},w.prototype.toString=function(e){return I[this.type]?.(this,e)??`Schema<${this.type}>`},w.prototype.role=function(e,t){let n=w(this);return n.meta={...n.meta,role:e,extra:t},n};for(let e of[`default`,`link`,`comment`,`description`,`max`,`min`,`step`])Object.assign(w.prototype,{[e](t){let n=w(this);return n.meta={...n.meta,[e]:t},n}});w.prototype.volatile=function(){if(this.meta.volatile)throw TypeError(`volatile schema is already wrapped`);return this.extra(`volatile`,!0)};let O={},k=Symbol(`checked-volatile-schema`);function A(e,t=[],n=!1,r=/* @__PURE__ */ new Map){let i=r.get(e)??/* @__PURE__ */ new Set;if(i.has(n))return;if(i.add(n),r.set(e,i),e.meta?.volatile&&n)throw new C(`volatile fields require a fixed object path without an enclosing volatile field`,{path:t});let a=n||!!e.meta?.volatile;if(e.dict)for(let[n,i]of Object.entries(e.dict))A(i,[...t,n],a,r);if(e.sKey&&A(e.sKey,[...t,`<key>`],!0,r),e.inner&&(e.type!==`lazy`||e.inner[x])&&A(e.inner,[...t,`*`],!0,r),e.list)for(let n=0;n<e.list.length;n++)A(e.list[n],[...t,String(n)],!0,r)}w.extend=function(e,t){O[e]=t},w.resolve=function(e,t,n={},r=!1){if(!t)return[e];if(n[k]||(A(t,n.path),n={...n,[k]:!0}),t.meta?.volatile){let i=w(t);i.meta={...t.meta,volatile:!1};let[a,o]=w.resolve(e,i,n,r);try{return[f(a),o]}catch(e){throw new C(e instanceof Error?e.message:String(e),n)}}if(n.ignore?.(e,t))return[e];if(a(e)&&t.type!==`lazy`){if(t.meta.required)throw new C(`missing required value`,n);let r=t,i=t.meta.default;for(;r?.type===`intersect`&&a(i);)r=r.list[0],i=r?.meta.default;if(a(i))return[e];e=v(i)}let i=O[t.type];if(!i)throw new C(`unsupported type "${t.type}"`,n);try{return i(e,t,n,r)}catch(e){if(!t.meta.loose)throw e;return[t.meta.default]}},w.from=function(e){if(a(e))return w.any();if([`string`,`number`,`boolean`].includes(typeof e))return w.const(e).required();if(e[x])return e;if(typeof e==`function`)switch(e){case String:return w.string().required();case Number:return w.number().required();case Boolean:return w.boolean().required();case Function:return w.function().required();default:return w.is(e).required()}else throw TypeError(`cannot infer schema from ${e}`)},w.lazy=function(e){let t=new w({type:`lazy`,builder:e,inner:{toJSON:()=>(t.inner[x]||(t.inner=t.builder(),t.inner.meta={...t.meta,...t.inner.meta}),t.inner.toJSON())}});return t},w.natural=function(){return w.number().step(1).min(0)},w.percent=function(){return w.number().step(.01).min(0).max(1).role(`slider`)},w.date=function(){return w.union([w.is(Date),w.transform(w.string().role(`datetime`),(e,t)=>{let n=new Date(e);if(isNaN(+n))throw new C(`invalid date "${e}"`,t);return n},!0)])},w.regExp=function(e=``){return w.union([w.is(RegExp),w.transform(w.string().role(`regexp`,{flag:e}),(t,n)=>{try{return new RegExp(t,e)}catch(e){throw new C(e.message,n)}},!0)])},w.arrayBuffer=function(e){return w.union([w.is(ArrayBuffer),w.is(SharedArrayBuffer),w.transform(w.any(),(e,t)=>{if(_.isSource(e))return _.fromSource(e);throw new C(`expected ArrayBufferSource but got ${e}`,t)},!0),...e?[w.transform(w.string(),(t,n)=>{try{return e===`base64`?_.fromBase64(t):_.fromHex(t)}catch(e){throw new C(e.message,n)}},!0)]:[]])},w.extend(`lazy`,(e,t,n,r)=>(t.inner[x]||(t.inner=t.builder(),t.inner.meta={...t.meta,...t.inner.meta},A(t.inner,n.path,!0)),w.resolve(e,t.inner,n,r))),w.extend(`any`,e=>[e]),w.extend(`never`,(e,t,n)=>{throw new C(`expected nullable but got ${e}`,n)}),w.extend(`const`,(e,{value:t},n)=>{if(y(e,t))return[t];throw new C(`expected ${t} but got ${e}`,n)});function j(e,t,n,r,i=!1){let{max:a=1/0,min:o=-1/0}=t;if(e>a)throw new C(`expected ${n} <= ${a} but got ${e}`,r);if(e<o&&!i)throw new C(`expected ${n} >= ${o} but got ${e}`,r)}w.extend(`string`,(e,{meta:t},n)=>{if(typeof e!=`string`)throw new C(`expected string but got ${e}`,n);if(t.pattern){let r=new RegExp(t.pattern.source,t.pattern.flags);if(!r.test(e))throw new C(`expect string to match regexp ${r}`,n)}return j(e.length,t,`string length`,n),[e]});function M(e,t){let n=e.toString();if(n.includes(`e`))return e*10**t;let r=n.indexOf(`.`);if(r===-1)return e*10**t;let i=n.slice(r+1),a=n.slice(0,r);return i.length<=t?+(a+i.padEnd(t,`0`)):+(a+i.slice(0,t)+`.`+i.slice(t))}function N(e,t,n){if(n=Math.abs(n),!/^\d+\.\d+$/.test(n.toString()))return(e-t)%n===0;let r=n.toString().indexOf(`.`),i=n.toString().slice(r+1).length;return Math.abs(M(e,i)-M(t,i))%M(n,i)===0}w.extend(`number`,(e,{meta:t},n)=>{if(typeof e!=`number`)throw new C(`expected number but got ${e}`,n);j(e,t,`number`,n);let{step:r}=t;if(r&&!N(e,t.min??0,r))throw new C(`expected number multiple of ${r} but got ${e}`,n);return[e]}),w.extend(`boolean`,(e,t,n)=>{if(typeof e==`boolean`)return[e];throw new C(`expected boolean but got ${e}`,n)}),w.extend(`bitset`,(e,{bits:t,meta:n},r)=>{let i=0,a=[];if(typeof e==`number`){i=e;for(let n in t)e&t[n]&&a.push(n)}else if(Array.isArray(e)){a=e;for(let e of a){if(typeof e!=`string`)throw new C(`expected string but got ${e}`,r);e in t&&(i|=t[e])}}else throw new C(`expected number or array but got ${e}`,r);return i===n.default?[i]:[i,a]}),w.extend(`function`,(e,t,n)=>{if(typeof e==`function`)return[e];throw new C(`expected function but got ${e}`,n)}),w.extend(`is`,(e,{constructor:t},n)=>{if(typeof t==`function`){if(e instanceof t)return[e];throw new C(`expected ${t.name} but got ${e}`,n)}{if(a(e))throw new C(`expected ${t} but got ${e}`,n);let r=Object.getPrototypeOf(e);for(;r;){if(r.constructor?.name===t)return[e];r=Object.getPrototypeOf(r)}throw new C(`expected ${t} but got ${e}`,n)}});function P(e,t,n,r){try{let[i,a]=w.resolve(e[t],n,{...r,path:[...r.path||[],t]});return a!==void 0&&(e[t]=a),i}catch(i){if(!r?.autofix)throw i;return delete e[t],n.meta.volatile?f(n.meta.default):n.meta.default}}w.extend(`array`,(e,{inner:t,meta:n},r)=>{if(!Array.isArray(e))throw new C(`expected array but got ${e}`,r);return j(e.length,n,`array length`,r,!a(t.meta.default)),[e.map((n,i)=>P(e,i,t,r))]}),w.extend(`dict`,(e,{inner:t,sKey:n},r,i)=>{if(!o(e))throw new C(`expected object but got ${e}`,r);let a={};for(let o in e){let s;try{s=w.resolve(o,n,r)[0]}catch(e){if(i)continue;throw e}a[s]=P(e,o,t,r),e[s]=e[o],o!==s&&delete e[o]}return[a]}),w.extend(`tuple`,(e,{list:t},n,r)=>{if(!Array.isArray(e))throw new C(`expected array but got ${e}`,n);let i=t.map((t,r)=>P(e,r,t,n));return r||i.push(...e.slice(t.length)),[i]});function F(e,t){for(let n in t)n in e||(e[n]=t[n])}w.extend(`object`,(e,{dict:t},n,r)=>{if(!o(e))throw new C(`expected object but got ${e}`,n);let i={};for(let r in t){let o=P(e,r,t[r],n);(!a(o)||r in e)&&(i[r]=o)}return r||F(i,e),[i]}),w.extend(`union`,(e,{list:t,toString:n},r,i)=>{let a=[];for(let n of t)try{return w.resolve(e,n,r,i)}catch(e){a.push(e)}throw new C(`expected ${n()} but got ${JSON.stringify(e)}`,r)}),w.extend(`intersect`,(e,{list:t,toString:n},r,i)=>{if(!t.length)return[e];let s;for(let i of t){let t=w.resolve(e,i,r,!0)[0];if(!a(t)){if(a(s))s=t;else if(typeof s!=typeof t)throw new C(`expected ${n()} but got ${JSON.stringify(e)}`,r);else if(typeof t==`object`)F(s??={},t);else if(s!==t)throw new C(`expected ${n()} but got ${JSON.stringify(e)}`,r)}}return!i&&o(e)&&F(s,e),[s]}),w.extend(`transform`,(e,{inner:t,callback:n,preserve:r},i)=>{let[a,o=e]=w.resolve(e,t,i,!0);return r?[n(a)]:[n(a),n(o)]});let I={};function L(e,t,n){I[e]=n,Object.assign(w,{[e](...n){let r=new w({type:e});return t.forEach((e,t)=>{switch(e){case`sKey`:r.sKey=n[t]??w.string();break;case`inner`:r.inner=w.from(n[t]);break;case`list`:r.list=n[t].map(w.from);break;case`dict`:r.dict=c(n[t],w.from);break;case`bits`:r.bits={};for(let e in n[t])typeof n[t][e]==`number`&&(r.bits[e]=n[t][e]);break;case`callback`:{let e=r.callback=n[t];e.toJSON||=()=>e.toString();break}case`constructor`:{let e=r.constructor=n[t];typeof e==`function`&&(e.toJSON||=()=>e.name);break}default:r[e]=n[t]}}),e===`object`||e===`dict`?r.meta.default={}:e===`array`||e===`tuple`?r.meta.default=[]:e===`bitset`&&(r.meta.default=0),r}})}L(`is`,[`constructor`],({constructor:e})=>typeof e==`function`?e.name:e),L(`any`,[],()=>`any`),L(`never`,[],()=>`never`),L(`const`,[`value`],({value:e})=>typeof e==`string`?JSON.stringify(e):e),L(`string`,[],()=>`string`),L(`number`,[],()=>`number`),L(`boolean`,[],()=>`boolean`),L(`bitset`,[`bits`],()=>`bitset`),L(`function`,[],()=>`function`),L(`array`,[`inner`],({inner:e})=>`${e.toString(!0)}[]`),L(`dict`,[`inner`,`sKey`],({inner:e,sKey:t})=>`{ [key: ${t.toString()}]: ${e.toString()} }`),L(`tuple`,[`list`],({list:e})=>`[${e.map(e=>e.toString()).join(`, `)}]`),L(`object`,[`dict`],({dict:e})=>Object.keys(e).length===0?`{}`:`{ ${Object.entries(e).map(([e,t])=>`${e}${t.meta.required?``:`?`}: ${t.toString()}`).join(`, `)} }`),L(`union`,[`list`],({list:e},t)=>{let n=e.map(({toString:e})=>e()).join(` | `);return t?`(${n})`:n}),L(`intersect`,[`list`],({list:e})=>`${e.map(e=>e.toString(!0)).join(` & `)}`),L(`transform`,[`inner`,`callback`,`preserve`],({inner:e},t)=>e.toString(t));function R(e,t){return Array.isArray(e)?[...e]:typeof e==`object`&&e?{...e}:/^\d+$/.test(t)?[]:{}}function z(e,t){let n={...e},r=n;for(let e=0;e<t.length-1;e++){let n=t[e],i=R(Array.isArray(r)?r[Number(n)]:r[n],t[e+1]);Array.isArray(r)?r[Number(n)]=i:r[n]=i,r=i}return{result:n,parent:r,leaf:t[t.length-1]}}var B=class extends r.Service{constructor(e){super(e,`settingsSchema`)}rehydrate(e){return new w(e)}validate(e,t){try{e(t);return}catch(e){return e instanceof Error?e.message:String(e)}}nodeAtPath(e,t){let n=e;for(let e of t){if(n===void 0)return;if(n.type===`object`)n=n.dict?.[e];else if(n.type===`dict`||n.type===`array`)n=n.inner;else return}return n}getPath(e,t){let n=e;for(let e of t)if(Array.isArray(n))n=n[Number(e)];else{if(typeof n!=`object`||!n)return;n=n[e]}return n}hasPath(e,t){if(t.length===0)return e!==void 0;let n=this.getPath(e,t.slice(0,-1)),r=t[t.length-1];return Array.isArray(n)?Number(r)<n.length:typeof n!=`object`||!n?!1:r in n}setPath(e,t,n){if(t.length===0)throw Error(`ui-settings: setPath needs a non-empty path`);let{result:r,parent:i,leaf:a}=z(e,t);return Array.isArray(i)?i[Number(a)]=n:i[a]=n,r}deletePath(e,t){if(t.length===0)throw Error(`ui-settings: deletePath needs a non-empty path`);if(!this.hasPath(e,t))return e;let{result:n,parent:r,leaf:i}=z(e,t);return Array.isArray(r)?r.splice(Number(i),1):Reflect.deleteProperty(r,i),n}},V=class{scope;enabled;local=(0,i.createSnapshotStore)(!0);constructor(e){this.scope=e,this.enabled=e.getSnapshot().mode===`memory`?this.local:{getSnapshot:()=>e.getSnapshot().value?.enabled??!1,subscribe:t=>{let n=this.enabled.getSnapshot();return e.subscribe(()=>{let e=this.enabled.getSnapshot();e!==n&&(n=e,t())})}}}async setEnabled(e){if(this.scope.getSnapshot().mode===`memory`)this.local.set(e);else if(!await this.scope.set(`enabled`,e))throw Error(`Developer tools preference was not saved`)}};let H={enabled:w.boolean().default(!0)};w.object(H);let U=/* @__PURE__ */ new Set([`ui-theme`,`locale`,`ui-chat`,`ui-conversation`,`ui-settings`,`ui-workspace`]);function W(e){return U.has(e)}function G(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var K=class{schema;key;constructor(e,t){this.schema=t,this.key=`codexhost.web.preferences.v1:${e}`}read(e){let t;try{let n=JSON.parse(localStorage.getItem(this.key)??`null`);G(n)&&G(n.user)&&Number.isSafeInteger(n.revision)&&n.revision>=0&&this.valid(e,n.user)&&(t=n)}catch{}return t===void 0&&(t={user:G(e.user)?e.user:{},revision:0},this.valid(e,t.user)||(t.user={}),this.save(t)),{...e,...t,value:{...G(e.base)?e.base:{},...t.user}}}write(e,t,n){let r=this.read(e);if(n!==void 0&&n!==r.revision)return!1;let i={...G(r.user)?r.user:{}};for(let e of t){if(e.path.length!==1)return!1;let t=e.path[0];e.op===`set`?i={...i,[t]:e.value}:delete i[t]}return this.valid(e,i)?this.save({user:i,revision:r.revision+1}):!1}valid(e,t){try{return this.schema.validate(this.schema.rehydrate(e.schema),{...G(e.base)?e.base:{},...t})===void 0}catch{return!1}}save(e){try{return localStorage.setItem(this.key,JSON.stringify(e)),!0}catch{return!1}}},q=class{ctx;spec;mirror;persistence;schema;store;tail=Promise.resolve();writeGeneration=0;disposed=!1;unsubscribe;browser;pendingRevision;constructor(e,t,n,r,a){if(this.ctx=e,this.spec=t,this.mirror=n,this.persistence=r,this.schema=a,this.browser=r===`browser`?new K(t.namespace,a):void 0,this.store=(0,i.createSnapshotStore)({status:r===`memory`?`unavailable`:`loading`,value:void 0,base:void 0,user:void 0,revision:void 0,writable:!1,mode:r}),r!==`memory`){let e=t.browserView===void 0?n.subscribe(()=>{this.derive()}):void 0,r=e=>{(e.key===null||e.key===this.browser?.key)&&this.derive()};this.browser!==void 0&&window.addEventListener(`storage`,r),this.unsubscribe=()=>{e?.(),this.browser!==void 0&&window.removeEventListener(`storage`,r)},this.derive()}}getSnapshot(){return this.store.getSnapshot()}subscribe(e){return this.store.subscribe(e)}set(e,t){return this.mutate([{op:`set`,path:[e],value:t}])}unset(e){return this.mutate([{op:`unset`,path:[e]}])}mutate(e,t){let n=structuredClone(e),r=this.browser;if(r!==void 0)return this.enqueue(()=>{let e=this.spec.browserView??this.mirror.namespace(this.spec.namespace),i=e!==void 0&&r.write(e,n,t);return this.derive(),Promise.resolve(i)});let i=++this.writeGeneration;return this.enqueue(async()=>{let e=t??this.pendingRevision??this.getSnapshot().revision,r=await this.ctx.remote.settings.mutate(this.spec.namespace,n,e);return r.ok?(this.disposed||(i===this.writeGeneration?(this.pendingRevision=void 0,this.mirror.acceptView(r.value)):this.pendingRevision=r.value.revision),!0):(await this.recover(i),!1)})}async recover(e){this.disposed||e!==this.writeGeneration||(this.pendingRevision=void 0,await this.mirror.load())}async dispose(){this.disposed=!0,this.writeGeneration+=1,this.unsubscribe?.(),await this.tail}enqueue(e){if(this.persistence===`memory`||this.disposed)return Promise.resolve(!1);let t=this.tail.then(async()=>!this.disposed&&await e());return this.tail=t.then(()=>{},()=>{}),t}derive(){if(this.disposed)return;let e=this.mirror.getSnapshot();if(this.spec.browserView===void 0&&e.view===void 0)return;let t=e.view?.writable??!1,n=this.spec.browserView??this.mirror.namespace(this.spec.namespace);if(n===void 0){this.store.update(e=>{e.status=`unavailable`,e.writable=t});return}let r=this.browser?.read(n)??n,i=this.decode(r);this.store.update(e=>{e.revision=r.revision,e.base=r.base,e.user=r.user,e.writable=this.browser!==void 0||t,i!==void 0&&(e.status=`ready`,e.value=i)})}decode(e){if(this.spec.decode!==void 0)return this.spec.decode(e.value);if(typeof e.value!=`object`||e.value===null||Array.isArray(e.value))return;let t;try{t=this.schema.validate(this.schema.rehydrate(e.schema),e.value)}catch{return}return t===void 0?e.value:void 0}},J=class extends r.Service{forms=/* @__PURE__ */ new Map;developerTools;mirror;schema;persistence;owner;constructor(e,t){super(e,`configForms`),this.mirror=t.mirror,this.schema=t.schema,this.persistence=t.persistence,this.owner=e,this.developerTools=new V(this.get(`ui-settings`)),e.effect(()=>async()=>{await Promise.all([...this.forms.values()].map(e=>e.dispose())),this.forms.clear()},`ui-settings: configuration forms`)}describe(){return this.mirror}get(e){let t=this.forms.get(e);if(t!==void 0)return t;let n=new q(this.owner,{namespace:e},this.mirror,W(e)?`browser`:this.persistence,this.schema);return this.forms.set(e,n),this.mirror.ensure(),n}registerBrowser(e,t,n){if(!W(e))throw Error(`ui-settings: ${e} is not a browser preference namespace`);let r=this.forms.get(e);if(r!==void 0)return r;let i={ns:e,autoGenerate:!1,applies:`live`,secrets:[],schema:t,base:n,user:{},value:n,revision:0},a=new q(this.owner,{namespace:e,browserView:i},this.mirror,`browser`,this.schema);return this.forms.set(e,a),a}whileServed(e,t){let n,r=()=>{let r=new Set(this.mirror.getSnapshot().view?.namespaces.map(e=>e.ns)??[]),i=e.some(e=>r.has(e));i&&n===void 0?n=t(r):!i&&n!==void 0&&(n(),n=void 0)},i=this.mirror.subscribe(r);return this.mirror.ensure(),r(),()=>{i(),n?.(),n=void 0}}},Y=class{ctx;persistence;store;inFlight;rerun=!1;generation=0;constructor(e,t=`host`){this.ctx=e,this.persistence=t,this.store=(0,i.createSnapshotStore)({status:t===`host`?`idle`:`unavailable`,view:void 0,error:null})}getSnapshot(){return this.store.getSnapshot()}subscribe(e){return this.store.subscribe(e)}load(){if(this.persistence===`memory`)return Promise.resolve();if(this.inFlight!==void 0)return this.rerun=!0,this.inFlight;let e=Promise.resolve().then(()=>this.run());return this.inFlight=e,e}ensure(){return this.persistence===`memory`?Promise.resolve():this.inFlight===void 0?this.getSnapshot().status===`idle`?this.load():Promise.resolve():this.inFlight}acceptView(e){let t=this.store.getSnapshot();if(this.generation+=1,this.inFlight!==void 0&&(this.rerun=!0),t.view===void 0)return;let n=t.view.namespaces.some(t=>t.ns===e.ns)?t.view.namespaces.map(t=>t.ns===e.ns?e:t):[...t.view.namespaces,e];this.store.set({...t,view:{...t.view,namespaces:n}})}namespace(e){return this.store.getSnapshot().view?.namespaces.find(t=>t.ns===e)}async run(){try{do{let e=this.store.getSnapshot();e.status===`idle`&&this.store.set({...e,status:`loading`}),this.rerun=!1;let t=++this.generation,n;try{let e=await this.ctx.remote.settings.describe();n=e.ok?{view:e.value}:{failure:e.error.message}}catch(e){n={failure:e instanceof Error?e.message:String(e)}}if(t===this.generation){if(`view`in n)this.store.set({status:`ready`,view:n.view,error:null});else{let e=this.store.getSnapshot();this.store.set({status:e.view===void 0?`idle`:`ready`,view:e.view,error:n.failure})}}}while(this.shouldRerun())}finally{this.inFlight=void 0}}shouldRerun(){return this.rerun}};let X=[`remote`,`remote.settings`];function Z(e){let t=new B(e),n=`host`,r=new Y(e,n);e.effect(()=>{let t=[e.remote.$on(`settings/document-updated`,()=>{r.load()}),e.on(`connection/reset`,()=>{r.load()})];return r.ensure(),()=>{for(let e of t)e()}},`ui-settings: describe mirror invalidations`),new J(e,{mirror:r,schema:t,persistence:n})}return n.apply=Z,n.inject=X,t.exports}});
1
+ window.__ModuleLoader__.load({id:`@deepseek-ai/dsh-client-ui-settings`,factory:e=>{var t={exports:{}},n=t.exports;Object.defineProperty(n,Symbol.toStringTag,{value:`Module`});let r=e("@deepseek-ai/cordis"),i=e("@deepseek-ai/dsh-client-store");function a(e){return e==null}function o(e){return e&&typeof e==`object`&&!Array.isArray(e)}function s(e,t){return Object.fromEntries(Object.entries(e).filter(([e,n])=>t(e,n)))}function c(e,t){return Object.fromEntries(Object.entries(e).map(([e,n])=>[e,t(n,e)]))}function l(e,t,n){if(!t)return{...e};let r={};for(let i of t)(n||e[i]!==void 0)&&(r[i]=e[i]);return r}let u=Symbol.for(`cosmokit.volatile.write`);function d(e,t=/* @__PURE__ */ new Set){if(typeof e==`function`)throw TypeError(`volatile config cannot contain functions`);if(typeof e!=`object`||!e)return e;if(t.has(e))throw TypeError(`volatile config cannot contain cycles`);t.add(e);try{if(Array.isArray(e))return Object.freeze(e.map(e=>d(e,t)));if(Object.getPrototypeOf(e)!==Object.prototype&&Object.getPrototypeOf(e)!==null)throw TypeError(`volatile config objects must be plain objects or arrays`);return Object.freeze(Object.fromEntries(Object.entries(e).map(([e,n])=>[e,d(n,t)])))}finally{t.delete(e)}}function f(e){let t=d(e);return Object.freeze({get:()=>t,[u]:e=>{t=e}})}function p(e){return typeof e==`object`&&!!e&&u in e}function m(e,t){return arguments.length===1?t=>m(e,t):e in globalThis&&t instanceof globalThis[e]||Object.prototype.toString.call(t).slice(8,-1)===e}function h(e){return m(`ArrayBuffer`,e)||m(`SharedArrayBuffer`,e)}function g(e){return h(e)||ArrayBuffer.isView(e)}let _;(function(e){e.is=h,e.isSource=g;function t(e){return ArrayBuffer.isView(e)?e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength):e}e.fromSource=t;function n(e){if(e=t(e),typeof Buffer<`u`)return Buffer.from(e).toString(`base64`);let n=``,r=new Uint8Array(e);for(let e=0;e<r.byteLength;e++)n+=String.fromCharCode(r[e]);return btoa(n)}e.toBase64=n;function r(e){return typeof Buffer<`u`?t(Buffer.from(e,`base64`)):Uint8Array.from(atob(e),e=>e.charCodeAt(0))}e.fromBase64=r;function i(e){return e=t(e),typeof Buffer<`u`?Buffer.from(e).toString(`hex`):Array.from(new Uint8Array(e),e=>e.toString(16).padStart(2,`0`)).join(``)}e.toHex=i;function a(e){if(typeof Buffer<`u`)return t(Buffer.from(e,`hex`));let n=e.length%2==0?e:e.slice(0,e.length-1),r=[];for(let e=0;e<n.length;e+=2)r.push(parseInt(`${n[e]}${n[e+1]}`,16));return Uint8Array.from(r).buffer}e.fromHex=a})(_||={}),_.fromBase64,_.toBase64,_.fromHex,_.toHex;function v(e,t=/* @__PURE__ */ new Map){if(!e||typeof e!=`object`)return e;if(m(`Date`,e))return new Date(e.valueOf());if(m(`RegExp`,e))return new RegExp(e.source,e.flags);if(h(e))return e.slice(0);if(ArrayBuffer.isView(e))return e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength);let n=t.get(e);if(n)return n;if(Array.isArray(e)){let n=[];return t.set(e,n),e.forEach((e,r)=>{n[r]=Reflect.apply(v,null,[e,t])}),n}let r=Object.create(Object.getPrototypeOf(e));t.set(e,r);for(let n of Reflect.ownKeys(e)){let i={...Reflect.getOwnPropertyDescriptor(e,n)};`value`in i&&(i.value=Reflect.apply(v,null,[i.value,t])),Reflect.defineProperty(r,n,i)}return r}function y(e,t,n){let r=/* @__PURE__ */ new Set;function i(e,t){if(e===t)return!0;if(p(e)||p(t))return p(e)&&p(t);if(!n&&a(e)&&a(t))return!0;if(typeof e!=typeof t||typeof e!=`object`||!e||!t||r.has(e))return!1;function o(n,r){return n(e)?n(t)?r(e,t):!1:!n(t)&&void 0}r.add(e);try{return o(Array.isArray,(e,t)=>{if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!i(e[n],t[n]))return!1;return!0})??o(m(`Date`),(e,t)=>e.valueOf()===t.valueOf())??o(m(`URL`),(e,t)=>e.href===t.href)??o(m(`RegExp`),(e,t)=>e.source===t.source&&e.flags===t.flags)??o(h,(e,t)=>{if(e.byteLength!==t.byteLength)return!1;let n=new Uint8Array(e),r=new Uint8Array(t);for(let e=0;e<n.length;e++)if(n[e]!==r[e])return!1;return!0})??((!n||[e,t].every(e=>Object.getPrototypeOf(e)===Object.prototype||Object.getPrototypeOf(e)===null))&&Object.keys({...e,...t}).every(n=>i(e[n],t[n])))}finally{r.delete(e)}}return i(e,t)}let b;(function(e){e.millisecond=1;let t=e.second=1e3,n=e.minute=t*60,r=e.hour=n*60,i=e.day=r*24,a=e.week=i*7,o=(/* @__PURE__ */ new Date()).getTimezoneOffset();function s(e){o=e}e.setTimezoneOffset=s;function c(){return o}e.getTimezoneOffset=c;function l(e=/* @__PURE__ */ new Date,t){return typeof e==`number`&&(e=new Date(e)),t===void 0&&(t=o),Math.floor((e.valueOf()/n-t)/1440)}e.getDateNumber=l;function u(e,t){let r=new Date(e*i);return t===void 0&&(t=o),new Date(+r+t*n)}e.fromDateNumber=u;let d=RegExp(`^${[`w(?:eek(?:s)?)?`,`d(?:ay(?:s)?)?`,`h(?:our(?:s)?)?`,`m(?:in(?:ute)?(?:s)?)?`,`s(?:ec(?:ond)?(?:s)?)?`].map(e=>`(\\d+(?:\\.\\d+)?${e})?`).join(``)}$`);function f(e){let o=d.exec(e);return o?(parseFloat(o[1])*a||0)+(parseFloat(o[2])*i||0)+(parseFloat(o[3])*r||0)+(parseFloat(o[4])*n||0)+(parseFloat(o[5])*t||0):0}e.parseTime=f;function p(e){let t=f(e);return t?e=Date.now()+t:/^\d{1,2}(:\d{1,2}){1,2}$/.test(e)?e=`${(/* @__PURE__ */ new Date()).toLocaleDateString()}-${e}`:/^\d{1,2}-\d{1,2}-\d{1,2}(:\d{1,2}){1,2}$/.test(e)&&(e=`${(/* @__PURE__ */ new Date()).getFullYear()}-${e}`),e?new Date(e):/* @__PURE__ */ new Date}e.parseDate=p;function m(e){let a=Math.abs(e);return a>=i-r/2?Math.round(e/i)+`d`:a>=r-n/2?Math.round(e/r)+`h`:a>=n-t/2?Math.round(e/n)+`m`:a>=t?Math.round(e/t)+`s`:e+`ms`}e.format=m;function h(e,t=2){return e.toString().padStart(t,`0`)}e.toDigits=h;function g(e,t=/* @__PURE__ */ new Date){return e.replace(`yyyy`,t.getFullYear().toString()).replace(`yy`,t.getFullYear().toString().slice(2)).replace(`MM`,h(t.getMonth()+1)).replace(`dd`,h(t.getDate())).replace(`hh`,h(t.getHours())).replace(`mm`,h(t.getMinutes())).replace(`ss`,h(t.getSeconds())).replace(`SSS`,h(t.getMilliseconds(),3))}e.template=g})(b||={});let x=Symbol.for(`schemastery`),S=Symbol.for(`ValidationError`);globalThis.__schemastery_index__??=0,globalThis.__schemastery_refs__=void 0;var C=class extends TypeError{options;name=`ValidationError`;constructor(e,t){let n=`$`;for(let e of t.path||[])typeof e==`string`?n+=`.`+e:typeof e==`number`?n+=`[`+e+`]`:typeof e==`symbol`&&(n+=`[Symbol(${e.toString()})]`);n.startsWith(`.`)&&(n=n.slice(1)),super((n===`$`?``:`${n} `)+e),this.options=t}static is(e){return!!e?.[S]}};Object.defineProperty(C.prototype,S,{value:!0});let w=function(e){let t=function(e,n={}){return w.resolve(e,t,n)[0]};if(e.refs){let t=c(e.refs,e=>new w(e)),n=e=>t[e];for(let e in t){let r=t[e];r.sKey=n(r.sKey),r.inner=n(r.inner),r.list=r.list&&r.list.map(n),r.dict=r.dict&&c(r.dict,n)}return t[e.uid]}if(Object.assign(t,e),typeof t.callback==`string`)try{t.callback=Function(`return `+t.callback)()}catch{}return Object.defineProperty(t,"uid",{value:globalThis.__schemastery_index__++}),Object.setPrototypeOf(t,w.prototype),t.meta||={},t.toString=t.toString.bind(t),t};w.prototype=Object.create(Function.prototype),w.prototype[x]=!0,Object.defineProperty(w.prototype,"~standard",{get(){return{version:1,vendor:`schemastery`,validate:e=>{try{return{value:w.resolve(e,this,{})[0]}}catch(e){if(C.is(e))return{issues:[{message:e.message,path:e.options.path}]};throw e}}}}}),w.ValidationError=C,w.prototype.toJSON=function(){if(globalThis.__schemastery_refs__)return globalThis.__schemastery_refs__[this.uid]??=JSON.parse(JSON.stringify({...this})),this.uid;globalThis.__schemastery_refs__={[this.uid]:{...this}},globalThis.__schemastery_refs__[this.uid]=JSON.parse(JSON.stringify({...this}));let e={uid:this.uid,refs:globalThis.__schemastery_refs__};return globalThis.__schemastery_refs__=void 0,e},w.prototype.set=function(e,t){return this.dict[e]=t,this},w.prototype.push=function(e){return this.list.push(e),this};function T(e,t){let n=typeof e==`string`?{"":e}:{...e};for(let e in t){let r=t[e];r?.$description||r?.$desc?n[e]=r.$description||r.$desc:typeof r==`string`&&(n[e]=r)}return n}function E(e){return e?.$value??e?.$inner}function D(e){return s(e??{},e=>!e.startsWith(`$`))}w.prototype.i18n=function(e){let t=w(this),n=T(t.meta.description,e);return Object.keys(n).length&&(t.meta.description=n),t.dict&&=c(t.dict,(t,n)=>t.i18n(c(e,e=>E(e)?.[n]??e?.[n]))),t.list&&=t.list.map((t,n)=>t.i18n(c(e,(e={})=>Array.isArray(E(e))?E(e)[n]:Array.isArray(e)?e[n]:D(e)))),t.inner&&=t.inner.i18n(c(e,e=>E(e)?E(e):D(e))),t.sKey&&=t.sKey.i18n(c(e,e=>e?.$key)),t},w.prototype.extra=function(e,t){let n=w(this);return n.meta={...n.meta,[e]:t},n};for(let e of[`required`,`disabled`,`collapse`,`hidden`,`loose`])Object.assign(w.prototype,{[e](t=!0){let n=w(this);return n.meta={...n.meta,[e]:t},n}});w.prototype.deprecated=function(){let e=w(this);return e.meta.badges||=[],e.meta.badges.push({text:`deprecated`,type:`danger`}),e},w.prototype.experimental=function(){let e=w(this);return e.meta.badges||=[],e.meta.badges.push({text:`experimental`,type:`warning`}),e},w.prototype.pattern=function(e){let t=w(this),n=l(e,[`source`,`flags`]);return t.meta={...t.meta,pattern:n},t},w.prototype.simplify=function(e){if(p(e)&&(e=e.get()),y(e,this.meta.default,this.type===`dict`))return null;if(a(e))return e;if(this.type===`object`||this.type===`dict`){let t={};for(let n in e){let r=(this.type===`object`?this.dict[n]:this.inner)?.simplify(e[n]);(this.type===`dict`||!a(r))&&(t[n]=r)}return y(t,this.meta.default,this.type===`dict`)?null:t}if(this.type===`array`||this.type===`tuple`){let t=[];return e.forEach((e,n)=>{let r=this.type===`array`?this.inner:this.list[n],i=r?r.simplify(e):e;t.push(i)}),t}if(this.type===`intersect`){let t={};for(let n of this.list)Object.assign(t,n.simplify(e));return t}if(this.type===`union`)for(let t of this.list)try{return w.resolve(e,t,{}),t.simplify(e)}catch{}return e},w.prototype.toString=function(e){return I[this.type]?.(this,e)??`Schema<${this.type}>`},w.prototype.role=function(e,t){let n=w(this);return n.meta={...n.meta,role:e,extra:t},n};for(let e of[`default`,`link`,`comment`,`description`,`max`,`min`,`step`])Object.assign(w.prototype,{[e](t){let n=w(this);return n.meta={...n.meta,[e]:t},n}});w.prototype.volatile=function(){if(this.meta.volatile)throw TypeError(`volatile schema is already wrapped`);return this.extra(`volatile`,!0)};let O={},k=Symbol(`checked-volatile-schema`);function A(e,t=[],n=!1,r=/* @__PURE__ */ new Map){let i=r.get(e)??/* @__PURE__ */ new Set;if(i.has(n))return;if(i.add(n),r.set(e,i),e.meta?.volatile&&n)throw new C(`volatile fields require a fixed object path without an enclosing volatile field`,{path:t});let a=n||!!e.meta?.volatile;if(e.dict)for(let[n,i]of Object.entries(e.dict))A(i,[...t,n],a,r);if(e.sKey&&A(e.sKey,[...t,`<key>`],!0,r),e.inner&&(e.type!==`lazy`||e.inner[x])&&A(e.inner,[...t,`*`],!0,r),e.list)for(let n=0;n<e.list.length;n++)A(e.list[n],[...t,String(n)],!0,r)}w.extend=function(e,t){O[e]=t},w.resolve=function(e,t,n={},r=!1){if(!t)return[e];if(n[k]||(A(t,n.path),n={...n,[k]:!0}),t.meta?.volatile){let i=w(t);i.meta={...t.meta,volatile:!1};let[a,o]=w.resolve(e,i,n,r);try{return[f(a),o]}catch(e){throw new C(e instanceof Error?e.message:String(e),n)}}if(n.ignore?.(e,t))return[e];if(a(e)&&t.type!==`lazy`){if(t.meta.required)throw new C(`missing required value`,n);let r=t,i=t.meta.default;for(;r?.type===`intersect`&&a(i);)r=r.list[0],i=r?.meta.default;if(a(i))return[e];e=v(i)}let i=O[t.type];if(!i)throw new C(`unsupported type "${t.type}"`,n);try{return i(e,t,n,r)}catch(e){if(!t.meta.loose)throw e;return[t.meta.default]}},w.from=function(e){if(a(e))return w.any();if([`string`,`number`,`boolean`].includes(typeof e))return w.const(e).required();if(e[x])return e;if(typeof e==`function`)switch(e){case String:return w.string().required();case Number:return w.number().required();case Boolean:return w.boolean().required();case Function:return w.function().required();default:return w.is(e).required()}else throw TypeError(`cannot infer schema from ${e}`)},w.lazy=function(e){let t=new w({type:`lazy`,builder:e,inner:{toJSON:()=>(t.inner[x]||(t.inner=t.builder(),t.inner.meta={...t.meta,...t.inner.meta}),t.inner.toJSON())}});return t},w.natural=function(){return w.number().step(1).min(0)},w.percent=function(){return w.number().step(.01).min(0).max(1).role(`slider`)},w.date=function(){return w.union([w.is(Date),w.transform(w.string().role(`datetime`),(e,t)=>{let n=new Date(e);if(isNaN(+n))throw new C(`invalid date "${e}"`,t);return n},!0)])},w.regExp=function(e=``){return w.union([w.is(RegExp),w.transform(w.string().role(`regexp`,{flag:e}),(t,n)=>{try{return new RegExp(t,e)}catch(e){throw new C(e.message,n)}},!0)])},w.arrayBuffer=function(e){return w.union([w.is(ArrayBuffer),w.is(SharedArrayBuffer),w.transform(w.any(),(e,t)=>{if(_.isSource(e))return _.fromSource(e);throw new C(`expected ArrayBufferSource but got ${e}`,t)},!0),...e?[w.transform(w.string(),(t,n)=>{try{return e===`base64`?_.fromBase64(t):_.fromHex(t)}catch(e){throw new C(e.message,n)}},!0)]:[]])},w.extend(`lazy`,(e,t,n,r)=>(t.inner[x]||(t.inner=t.builder(),t.inner.meta={...t.meta,...t.inner.meta},A(t.inner,n.path,!0)),w.resolve(e,t.inner,n,r))),w.extend(`any`,e=>[e]),w.extend(`never`,(e,t,n)=>{throw new C(`expected nullable but got ${e}`,n)}),w.extend(`const`,(e,{value:t},n)=>{if(y(e,t))return[t];throw new C(`expected ${t} but got ${e}`,n)});function j(e,t,n,r,i=!1){let{max:a=1/0,min:o=-1/0}=t;if(e>a)throw new C(`expected ${n} <= ${a} but got ${e}`,r);if(e<o&&!i)throw new C(`expected ${n} >= ${o} but got ${e}`,r)}w.extend(`string`,(e,{meta:t},n)=>{if(typeof e!=`string`)throw new C(`expected string but got ${e}`,n);if(t.pattern){let r=new RegExp(t.pattern.source,t.pattern.flags);if(!r.test(e))throw new C(`expect string to match regexp ${r}`,n)}return j(e.length,t,`string length`,n),[e]});function M(e,t){let n=e.toString();if(n.includes(`e`))return e*10**t;let r=n.indexOf(`.`);if(r===-1)return e*10**t;let i=n.slice(r+1),a=n.slice(0,r);return i.length<=t?+(a+i.padEnd(t,`0`)):+(a+i.slice(0,t)+`.`+i.slice(t))}function N(e,t,n){if(n=Math.abs(n),!/^\d+\.\d+$/.test(n.toString()))return(e-t)%n===0;let r=n.toString().indexOf(`.`),i=n.toString().slice(r+1).length;return Math.abs(M(e,i)-M(t,i))%M(n,i)===0}w.extend(`number`,(e,{meta:t},n)=>{if(typeof e!=`number`)throw new C(`expected number but got ${e}`,n);j(e,t,`number`,n);let{step:r}=t;if(r&&!N(e,t.min??0,r))throw new C(`expected number multiple of ${r} but got ${e}`,n);return[e]}),w.extend(`boolean`,(e,t,n)=>{if(typeof e==`boolean`)return[e];throw new C(`expected boolean but got ${e}`,n)}),w.extend(`bitset`,(e,{bits:t,meta:n},r)=>{let i=0,a=[];if(typeof e==`number`){i=e;for(let n in t)e&t[n]&&a.push(n)}else if(Array.isArray(e)){a=e;for(let e of a){if(typeof e!=`string`)throw new C(`expected string but got ${e}`,r);e in t&&(i|=t[e])}}else throw new C(`expected number or array but got ${e}`,r);return i===n.default?[i]:[i,a]}),w.extend(`function`,(e,t,n)=>{if(typeof e==`function`)return[e];throw new C(`expected function but got ${e}`,n)}),w.extend(`is`,(e,{constructor:t},n)=>{if(typeof t==`function`){if(e instanceof t)return[e];throw new C(`expected ${t.name} but got ${e}`,n)}{if(a(e))throw new C(`expected ${t} but got ${e}`,n);let r=Object.getPrototypeOf(e);for(;r;){if(r.constructor?.name===t)return[e];r=Object.getPrototypeOf(r)}throw new C(`expected ${t} but got ${e}`,n)}});function P(e,t,n,r){try{let[i,a]=w.resolve(e[t],n,{...r,path:[...r.path||[],t]});return a!==void 0&&(e[t]=a),i}catch(i){if(!r?.autofix)throw i;return delete e[t],n.meta.volatile?f(n.meta.default):n.meta.default}}w.extend(`array`,(e,{inner:t,meta:n},r)=>{if(!Array.isArray(e))throw new C(`expected array but got ${e}`,r);return j(e.length,n,`array length`,r,!a(t.meta.default)),[e.map((n,i)=>P(e,i,t,r))]}),w.extend(`dict`,(e,{inner:t,sKey:n},r,i)=>{if(!o(e))throw new C(`expected object but got ${e}`,r);let a={};for(let o in e){let s;try{s=w.resolve(o,n,r)[0]}catch(e){if(i)continue;throw e}a[s]=P(e,o,t,r),e[s]=e[o],o!==s&&delete e[o]}return[a]}),w.extend(`tuple`,(e,{list:t},n,r)=>{if(!Array.isArray(e))throw new C(`expected array but got ${e}`,n);let i=t.map((t,r)=>P(e,r,t,n));return r||i.push(...e.slice(t.length)),[i]});function F(e,t){for(let n in t)n in e||(e[n]=t[n])}w.extend(`object`,(e,{dict:t},n,r)=>{if(!o(e))throw new C(`expected object but got ${e}`,n);let i={};for(let r in t){let o=P(e,r,t[r],n);(!a(o)||r in e)&&(i[r]=o)}return r||F(i,e),[i]}),w.extend(`union`,(e,{list:t,toString:n},r,i)=>{let a=[];for(let n of t)try{return w.resolve(e,n,r,i)}catch(e){a.push(e)}throw new C(`expected ${n()} but got ${JSON.stringify(e)}`,r)}),w.extend(`intersect`,(e,{list:t,toString:n},r,i)=>{if(!t.length)return[e];let s;for(let i of t){let t=w.resolve(e,i,r,!0)[0];if(!a(t)){if(a(s))s=t;else if(typeof s!=typeof t)throw new C(`expected ${n()} but got ${JSON.stringify(e)}`,r);else if(typeof t==`object`)F(s??={},t);else if(s!==t)throw new C(`expected ${n()} but got ${JSON.stringify(e)}`,r)}}return!i&&o(e)&&F(s,e),[s]}),w.extend(`transform`,(e,{inner:t,callback:n,preserve:r},i)=>{let[a,o=e]=w.resolve(e,t,i,!0);return r?[n(a)]:[n(a),n(o)]});let I={};function L(e,t,n){I[e]=n,Object.assign(w,{[e](...n){let r=new w({type:e});return t.forEach((e,t)=>{switch(e){case`sKey`:r.sKey=n[t]??w.string();break;case`inner`:r.inner=w.from(n[t]);break;case`list`:r.list=n[t].map(w.from);break;case`dict`:r.dict=c(n[t],w.from);break;case`bits`:r.bits={};for(let e in n[t])typeof n[t][e]==`number`&&(r.bits[e]=n[t][e]);break;case`callback`:{let e=r.callback=n[t];e.toJSON||=()=>e.toString();break}case`constructor`:{let e=r.constructor=n[t];typeof e==`function`&&(e.toJSON||=()=>e.name);break}default:r[e]=n[t]}}),e===`object`||e===`dict`?r.meta.default={}:e===`array`||e===`tuple`?r.meta.default=[]:e===`bitset`&&(r.meta.default=0),r}})}L(`is`,[`constructor`],({constructor:e})=>typeof e==`function`?e.name:e),L(`any`,[],()=>`any`),L(`never`,[],()=>`never`),L(`const`,[`value`],({value:e})=>typeof e==`string`?JSON.stringify(e):e),L(`string`,[],()=>`string`),L(`number`,[],()=>`number`),L(`boolean`,[],()=>`boolean`),L(`bitset`,[`bits`],()=>`bitset`),L(`function`,[],()=>`function`),L(`array`,[`inner`],({inner:e})=>`${e.toString(!0)}[]`),L(`dict`,[`inner`,`sKey`],({inner:e,sKey:t})=>`{ [key: ${t.toString()}]: ${e.toString()} }`),L(`tuple`,[`list`],({list:e})=>`[${e.map(e=>e.toString()).join(`, `)}]`),L(`object`,[`dict`],({dict:e})=>Object.keys(e).length===0?`{}`:`{ ${Object.entries(e).map(([e,t])=>`${e}${t.meta.required?``:`?`}: ${t.toString()}`).join(`, `)} }`),L(`union`,[`list`],({list:e},t)=>{let n=e.map(({toString:e})=>e()).join(` | `);return t?`(${n})`:n}),L(`intersect`,[`list`],({list:e})=>`${e.map(e=>e.toString(!0)).join(` & `)}`),L(`transform`,[`inner`,`callback`,`preserve`],({inner:e},t)=>e.toString(t));function R(e,t){return Array.isArray(e)?[...e]:typeof e==`object`&&e?{...e}:/^\d+$/.test(t)?[]:{}}function z(e,t){let n={...e},r=n;for(let e=0;e<t.length-1;e++){let n=t[e],i=R(Array.isArray(r)?r[Number(n)]:r[n],t[e+1]);Array.isArray(r)?r[Number(n)]=i:r[n]=i,r=i}return{result:n,parent:r,leaf:t[t.length-1]}}var B=class extends r.Service{constructor(e){super(e,`settingsSchema`)}rehydrate(e){return new w(e)}validate(e,t){try{e(t);return}catch(e){return e instanceof Error?e.message:String(e)}}nodeAtPath(e,t){let n=e;for(let e of t){if(n===void 0)return;if(n.type===`object`)n=n.dict?.[e];else if(n.type===`dict`||n.type===`array`)n=n.inner;else return}return n}getPath(e,t){let n=e;for(let e of t)if(Array.isArray(n))n=n[Number(e)];else{if(typeof n!=`object`||!n)return;n=n[e]}return n}hasPath(e,t){if(t.length===0)return e!==void 0;let n=this.getPath(e,t.slice(0,-1)),r=t[t.length-1];return Array.isArray(n)?Number(r)<n.length:typeof n!=`object`||!n?!1:r in n}setPath(e,t,n){if(t.length===0)throw Error(`ui-settings: setPath needs a non-empty path`);let{result:r,parent:i,leaf:a}=z(e,t);return Array.isArray(i)?i[Number(a)]=n:i[a]=n,r}deletePath(e,t){if(t.length===0)throw Error(`ui-settings: deletePath needs a non-empty path`);if(!this.hasPath(e,t))return e;let{result:n,parent:r,leaf:i}=z(e,t);return Array.isArray(r)?r.splice(Number(i),1):Reflect.deleteProperty(r,i),n}},V=class{scope;enabled;local=(0,i.createSnapshotStore)(!0);constructor(e){this.scope=e,this.enabled=e.getSnapshot().mode===`memory`?this.local:{getSnapshot:()=>e.getSnapshot().value?.enabled??!1,subscribe:t=>{let n=this.enabled.getSnapshot();return e.subscribe(()=>{let e=this.enabled.getSnapshot();e!==n&&(n=e,t())})}}}async setEnabled(e){if(this.scope.getSnapshot().mode===`memory`)this.local.set(e);else if(!await this.scope.set(`enabled`,e))throw Error(`Developer tools preference was not saved`)}};let H={enabled:w.boolean().default(!0)};w.object(H);let U=/* @__PURE__ */ new Set([`ui-theme`,`locale`,`ui-chat`,`ui-conversation`,`ui-settings`,`ui-workspace`]);function W(e){return U.has(e)}function G(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var K=class{schema;key;constructor(e,t){this.schema=t,this.key=`codexhost.web.preferences.v1:${e}`}read(e){let t;try{let n=JSON.parse(localStorage.getItem(this.key)??`null`);G(n)&&G(n.user)&&Number.isSafeInteger(n.revision)&&n.revision>=0&&this.valid(e,n.user)&&(t=n)}catch{}return t===void 0&&(t={user:G(e.user)?e.user:{},revision:0},this.valid(e,t.user)||(t.user={}),this.save(t)),{...e,...t,value:{...G(e.base)?e.base:{},...t.user}}}write(e,t,n){let r=this.read(e);if(n!==void 0&&n!==r.revision)return!1;let i={...G(r.user)?r.user:{}};for(let e of t){if(e.path.length!==1)return!1;let t=e.path[0];e.op===`set`?i={...i,[t]:e.value}:delete i[t]}return this.valid(e,i)?this.save({user:i,revision:r.revision+1}):!1}valid(e,t){try{return this.schema.validate(this.schema.rehydrate(e.schema),{...G(e.base)?e.base:{},...t})===void 0}catch{return!1}}save(e){try{return localStorage.setItem(this.key,JSON.stringify(e)),!0}catch{return!1}}},q=class{ctx;spec;mirror;persistence;schema;store;tail=Promise.resolve();writeGeneration=0;disposed=!1;unsubscribe;browser;pendingRevision;constructor(e,t,n,r,a){if(this.ctx=e,this.spec=t,this.mirror=n,this.persistence=r,this.schema=a,this.browser=r===`browser`?new K(t.namespace,a):void 0,this.store=(0,i.createSnapshotStore)({status:r===`memory`?`unavailable`:`loading`,value:void 0,base:void 0,user:void 0,revision:void 0,writable:!1,mode:r}),r!==`memory`){let e=t.browserView===void 0?n.subscribe(()=>{this.derive()}):void 0,r=e=>{(e.key===null||e.key===this.browser?.key)&&this.derive()};this.browser!==void 0&&window.addEventListener(`storage`,r),this.unsubscribe=()=>{e?.(),this.browser!==void 0&&window.removeEventListener(`storage`,r)},this.derive()}}getSnapshot(){return this.store.getSnapshot()}subscribe(e){return this.store.subscribe(e)}updateBrowserView(e){if(this.browser===void 0||e.ns!==this.spec.namespace)throw Error(`ui-settings: browser view does not belong to this form`);this.spec.browserView=e,this.derive()}set(e,t){return this.mutate([{op:`set`,path:[e],value:t}])}unset(e){return this.mutate([{op:`unset`,path:[e]}])}mutate(e,t){let n=structuredClone(e),r=this.browser;if(r!==void 0)return this.enqueue(()=>{let e=this.spec.browserView??this.mirror.namespace(this.spec.namespace),i=e!==void 0&&r.write(e,n,t);return this.derive(),Promise.resolve(i)});let i=++this.writeGeneration;return this.enqueue(async()=>{let e=t??this.pendingRevision??this.getSnapshot().revision,r=await this.ctx.remote.settings.mutate(this.spec.namespace,n,e);return r.ok?(this.disposed||(i===this.writeGeneration?(this.pendingRevision=void 0,this.mirror.acceptView(r.value)):this.pendingRevision=r.value.revision),!0):(await this.recover(i),!1)})}async recover(e){this.disposed||e!==this.writeGeneration||(this.pendingRevision=void 0,await this.mirror.load())}async dispose(){this.disposed=!0,this.writeGeneration+=1,this.unsubscribe?.(),await this.tail}enqueue(e){if(this.persistence===`memory`||this.disposed)return Promise.resolve(!1);let t=this.tail.then(async()=>!this.disposed&&await e());return this.tail=t.then(()=>{},()=>{}),t}derive(){if(this.disposed)return;let e=this.mirror.getSnapshot();if(this.spec.browserView===void 0&&e.view===void 0)return;let t=e.view?.writable??!1,n=this.spec.browserView??this.mirror.namespace(this.spec.namespace);if(n===void 0){this.store.update(e=>{e.status=`unavailable`,e.writable=t});return}let r=this.browser?.read(n)??n,i=this.decode(r);this.store.update(e=>{e.revision=r.revision,e.base=r.base,e.user=r.user,e.writable=this.browser!==void 0||t,i!==void 0&&(e.status=`ready`,e.value=i)})}decode(e){if(this.spec.decode!==void 0)return this.spec.decode(e.value);if(typeof e.value!=`object`||e.value===null||Array.isArray(e.value))return;let t;try{t=this.schema.validate(this.schema.rehydrate(e.schema),e.value)}catch{return}return t===void 0?e.value:void 0}},J=class extends r.Service{forms=/* @__PURE__ */ new Map;developerTools;mirror;schema;persistence;owner;constructor(e,t){super(e,`configForms`),this.mirror=t.mirror,this.schema=t.schema,this.persistence=t.persistence,this.owner=e,this.developerTools=new V(this.get(`ui-settings`)),e.effect(()=>async()=>{await Promise.all([...this.forms.values()].map(e=>e.dispose())),this.forms.clear()},`ui-settings: configuration forms`)}describe(){return this.mirror}get(e){let t=this.forms.get(e);if(t!==void 0)return t;let n=new q(this.owner,{namespace:e},this.mirror,W(e)?`browser`:this.persistence,this.schema);return this.forms.set(e,n),this.mirror.ensure(),n}registerBrowser(e,t,n){if(!W(e))throw Error(`ui-settings: ${e} is not a browser preference namespace`);let r={ns:e,autoGenerate:!1,applies:`live`,secrets:[],schema:t,base:n,user:{},value:n,revision:0},i=this.forms.get(e);if(i!==void 0)return i.updateBrowserView(r),i;let a=new q(this.owner,{namespace:e,browserView:r},this.mirror,`browser`,this.schema);return this.forms.set(e,a),a}whileServed(e,t){let n,r=()=>{let r=new Set(this.mirror.getSnapshot().view?.namespaces.map(e=>e.ns)??[]),i=e.some(e=>r.has(e));i&&n===void 0?n=t(r):!i&&n!==void 0&&(n(),n=void 0)},i=this.mirror.subscribe(r);return this.mirror.ensure(),r(),()=>{i(),n?.(),n=void 0}}},Y=class{ctx;persistence;store;inFlight;rerun=!1;generation=0;constructor(e,t=`host`){this.ctx=e,this.persistence=t,this.store=(0,i.createSnapshotStore)({status:t===`host`?`idle`:`unavailable`,view:void 0,error:null})}getSnapshot(){return this.store.getSnapshot()}subscribe(e){return this.store.subscribe(e)}load(){if(this.persistence===`memory`)return Promise.resolve();if(this.inFlight!==void 0)return this.rerun=!0,this.inFlight;let e=Promise.resolve().then(()=>this.run());return this.inFlight=e,e}ensure(){return this.persistence===`memory`?Promise.resolve():this.inFlight===void 0?this.getSnapshot().status===`idle`?this.load():Promise.resolve():this.inFlight}acceptView(e){let t=this.store.getSnapshot();if(this.generation+=1,this.inFlight!==void 0&&(this.rerun=!0),t.view===void 0)return;let n=t.view.namespaces.some(t=>t.ns===e.ns)?t.view.namespaces.map(t=>t.ns===e.ns?e:t):[...t.view.namespaces,e];this.store.set({...t,view:{...t.view,namespaces:n}})}namespace(e){return this.store.getSnapshot().view?.namespaces.find(t=>t.ns===e)}async run(){try{do{let e=this.store.getSnapshot();e.status===`idle`&&this.store.set({...e,status:`loading`}),this.rerun=!1;let t=++this.generation,n;try{let e=await this.ctx.remote.settings.describe();n=e.ok?{view:e.value}:{failure:e.error.message}}catch(e){n={failure:e instanceof Error?e.message:String(e)}}if(t===this.generation){if(`view`in n)this.store.set({status:`ready`,view:n.view,error:null});else{let e=this.store.getSnapshot();this.store.set({status:e.view===void 0?`idle`:`ready`,view:e.view,error:n.failure})}}}while(this.shouldRerun())}finally{this.inFlight=void 0}}shouldRerun(){return this.rerun}};let X=[`remote`,`remote.settings`];function Z(e){let t=new B(e),n=`host`,r=new Y(e,n);e.effect(()=>{let t=[e.remote.$on(`settings/document-updated`,()=>{r.load()}),e.on(`connection/reset`,()=>{r.load()})];return r.ensure(),()=>{for(let e of t)e()}},`ui-settings: describe mirror invalidations`),new J(e,{mirror:r,schema:t,persistence:n})}return n.apply=Z,n.inject=X,t.exports}});