@liberseek/boft-cli-win32-arm64 0.8.8 → 0.8.9

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 (68) hide show
  1. package/README.md +1 -1
  2. package/app/codexhost-distribution.json +1 -1
  3. package/app/console-server.mjs +59 -6
  4. package/app/console-web.js +1376 -1053
  5. package/app/desktop-controller.mjs +239 -57
  6. package/app/host-runtime.mjs +35964 -28304
  7. package/app/plugins/antigravity/assets/icon.svg +1 -1
  8. package/app/plugins/antigravity/plugin.mjs +9491 -4266
  9. package/app/plugins/claude-code/plugin.mjs +580 -116
  10. package/app/plugins/codebuddy/plugin.mjs +85 -8
  11. package/app/plugins/codex-usage/plugin.mjs +70 -6
  12. package/app/plugins/copilot/plugin.mjs +62 -6
  13. package/app/plugins/cursor-cli/plugin.mjs +62 -6
  14. package/app/plugins/deepseek-harness/plugin.mjs +87 -11
  15. package/app/plugins/devin/plugin.mjs +61 -6
  16. package/app/plugins/grok/plugin.mjs +320 -223
  17. package/app/plugins/hermes/plugin.mjs +61 -6
  18. package/app/plugins/kimi-code/plugin.mjs +87 -16
  19. package/app/plugins/kiro-cli/plugin.mjs +62 -6
  20. package/app/plugins/muse/plugin.mjs +61 -6
  21. package/app/plugins/omp/plugin.mjs +195 -31
  22. package/app/plugins/opencode/plugin.mjs +88 -15
  23. package/app/plugins/pi/plugin.mjs +207 -32
  24. package/app/plugins/qoder/plugin.mjs +99 -7
  25. package/app/plugins/qoder-cn/plugin.mjs +99 -7
  26. package/app/plugins/qwen-code/plugin.mjs +62 -6
  27. package/app/plugins/workbuddy/plugin.mjs +89 -11
  28. package/app/plugins/zcode/plugin.mjs +70 -6
  29. package/app/renderer-extension.js +1767 -1187
  30. package/app/web/assets/index-C2OA-eHT.js +201 -0
  31. package/app/web/assets/index-DJW4bmyx.css +1 -0
  32. package/app/web/assets/langs/{graphql-B8vkg11W.js → graphql-ChAeyPkT.js} +1 -1
  33. package/app/web/assets/langs/{http-DmoDEjMt.js → http-BvreBIbD.js} +1 -1
  34. package/app/web/assets/langs/{php-DJ5ovfAM.js → php-D8omCIuJ.js} +1 -1
  35. package/app/web/assets/langs/{rst-U5-R5x3p.js → rst-Do7RLLCS.js} +1 -1
  36. package/app/web/assets/langs/{ruby-VKVsnS0H.js → ruby-rH_O_vse.js} +1 -1
  37. package/app/web/assets/langs/{svelte-C20lOv9V.js → svelte-xZy73wAj.js} +1 -1
  38. package/app/web/assets/langs/{vue-z6Y-lzP-.js → vue-C4DW8agZ.js} +1 -1
  39. package/app/web/assets/{vendor-dSL872WO.js → vendor-C9g2bw8s.js} +3 -3
  40. package/app/web/codexhost-settings.js +1383 -1056
  41. package/app/web/index.html +4 -3
  42. package/app/web/plugins/deepseek-ai__dsh-api-gateway/client.js +2 -2
  43. package/app/web/plugins/deepseek-ai__dsh-api-remotes/client.js +1 -1
  44. package/app/web/plugins/deepseek-ai__dsh-api-session-controller/client.js +11 -11
  45. package/app/web/plugins/deepseek-ai__dsh-client-connection/client.js +1 -1
  46. package/app/web/plugins/deepseek-ai__dsh-client-locale/client.js +3 -3
  47. package/app/web/plugins/deepseek-ai__dsh-client-ui-attachment/client.js +1 -1
  48. package/app/web/plugins/deepseek-ai__dsh-client-ui-chat/client.js +74 -69
  49. package/app/web/plugins/deepseek-ai__dsh-client-ui-codexhost/client.js +3 -3
  50. package/app/web/plugins/deepseek-ai__dsh-client-ui-conversation/client.js +28 -28
  51. package/app/web/plugins/deepseek-ai__dsh-client-ui-input-trigger/client.js +1 -1
  52. package/app/web/plugins/deepseek-ai__dsh-client-ui-layout/client.js +2 -2
  53. package/app/web/plugins/deepseek-ai__dsh-client-ui-model-selection/client.js +1 -1
  54. package/app/web/plugins/deepseek-ai__dsh-client-ui-session/client.js +1 -1
  55. package/app/web/plugins/deepseek-ai__dsh-client-ui-settings-general/client.js +1 -1
  56. package/app/web/plugins/deepseek-ai__dsh-client-ui-sidebar/client.js +1 -1
  57. package/app/web/plugins/deepseek-ai__dsh-client-ui-sidebar-documentpreview/client.js +9 -9
  58. package/app/web/plugins/deepseek-ai__dsh-client-ui-sidebar-files/client.js +1 -1
  59. package/app/web/plugins/deepseek-ai__dsh-client-ui-tool/client.js +18 -18
  60. package/app/web/plugins/deepseek-ai__dsh-client-ui-workspace/client.js +11 -11
  61. package/app/web-modules/server.mjs +2458 -1615
  62. package/bin/boft.exe +0 -0
  63. package/libexec/boft-node-repl.exe +0 -0
  64. package/libexec/boft-shim.exe +0 -0
  65. package/libexec/boft-updater.exe +0 -0
  66. package/package.json +1 -1
  67. package/app/web/assets/index-CP6wY-1D.css +0 -1
  68. package/app/web/assets/index-Da35Phrd.js +0 -199
@@ -1,6 +1,6 @@
1
- window.__ModuleLoader__.load({id:`@deepseek-ai/dsh-client-ui-chat`,factory:e=>{var t={exports:{}},n=t.exports;Object.defineProperty(n,Symbol.toStringTag,{value:`Module`});var r=Object.create,i=Object.defineProperty,a=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyNames,s=Object.getPrototypeOf,c=Object.prototype.hasOwnProperty,l=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var s=o(t),l=0,u=s.length,d;l<u;l++)d=s[l],!c.call(e,d)&&d!==n&&i(e,d,{get:(e=>t[e]).bind(null,d),enumerable:!(r=a(t,d))||r.enumerable});return e},u=(e,t,n)=>(n=e==null?{}:r(s(e)),l(t||!e||!e.__esModule||!c.call(e,`default`)?i(n,`default`,{value:e,enumerable:!0}):n,e));let d=e("react");d=u(d,1);let f=e("react/jsx-runtime"),p=e("@deepseek-ai/dsh-client-ui-primitives"),m=e("@deepseek-ai/dsh-client-store"),h=e("react-dom"),g=`@deepseek-ai/dsh-client-ui-chat/ChangeStat.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(g)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=g,e.textContent=`.zmMCYq_stat{font-size:var(--dsh-change-stat-font-size,inherit);font-variant-numeric:tabular-nums;white-space:nowrap;gap:6px;display:inline-flex}.zmMCYq_added{color:var(--dsw-alias-state-success-primary)}.zmMCYq_removed{color:var(--dsw-alias-state-error-primary)}`,document.head.appendChild(e)}var _={added:`zmMCYq_added`,removed:`zmMCYq_removed`,stat:`zmMCYq_stat`};function v({added:e,removed:t}){return/* @__PURE__ */ (0,f.jsxs)(`span`,{className:_.stat,children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:_.added,children:`+${e}`}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:_.removed,children:`-${t}`})]})}let y=[],b={getSnapshot:()=>void 0,subscribe:()=>()=>{}};function x(e){let t=/* @__PURE__ */ new Map;for(let n of e){let{parentCallId:e,isError:r,meta:i}=n;if(e!==void 0||r===!0||!Array.isArray(i?.diffs))continue;let a=/* @__PURE__ */ new Map;for(let e of i.diffs)typeof e?.path==`string`&&a.set(e.path,[...a.get(e.path)??[],e]);for(let[e,n]of a)t.set(e,n)}return[...t].map(([e,t])=>({path:e,...(0,p.diffTotals)(t),hunks:t}))}function ee(e,t,n){let r=n(`codexhostTurnChanges`,e=>t===void 0?void 0:e?.[t]),i=t===void 0||r!==void 0?b:e.turnDataSource(t,`tool-call`),a=(0,d.useSyncExternalStore)(i.subscribe,i.getSnapshot);return r===void 0?a===void 0?y:x(a.map(e=>e.root)):r}function S(e){return{added:e.reduce((e,t)=>e+t.added,0),removed:e.reduce((e,t)=>e+t.removed,0)}}function C(e){return e.split(/[\\/]/).at(-1)??e}let te=`@deepseek-ai/dsh-client-ui-chat/ChangesDock.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(te)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=te,e.textContent=`.c0dK-q_root{justify-content:center;margin-bottom:6px;display:flex}.c0dK-q_anchor{corner-shape:round;border-radius:16px;position:relative}.c0dK-q_anchor:focus-visible{outline:2px solid var(--dsw-alias-label-tertiary);outline-offset:2px}.c0dK-q_pill{border:1px solid var(--dsw-alias-border-l1);border-radius:inherit;corner-shape:round;color:var(--dsw-alias-label-tertiary);font-size:calc(var(--dsh-content-font-size-secondary,13px) + 2px);white-space:nowrap;--dsh-change-stat-font-size:calc(var(--dsh-content-font-size-secondary,13px) + 1px);--dsw-alias-state-success-primary:var(--dsw-alias-file-diff-added-marker);--dsw-alias-state-error-primary:var(--dsw-alias-file-diff-deleted-marker);background:0 0;align-items:center;gap:4px;padding:8px 12px;line-height:20px;display:inline-flex}.c0dK-q_list{corner-shape:round;background:var(--dsw-alias-button-floating-fill);box-shadow:var(--dsw-elevation-panel);color:var(--dsw-alias-label-primary);font-size:calc(var(--dsh-content-font-size-secondary,13px) - 1px);white-space:nowrap;border-radius:12px;margin:0;padding:4px 12px;list-style:none;display:none;position:absolute;bottom:calc(100% + 6px);left:50%;transform:translate(-50%)}.c0dK-q_anchor:is(:hover,:focus-visible) .c0dK-q_list{display:block}.c0dK-q_file{justify-content:space-between;gap:16px;max-width:360px;padding:3px 0;display:flex}.c0dK-q_path{text-overflow:ellipsis;overflow:hidden}`,document.head.appendChild(e)}var w={anchor:`c0dK-q_anchor`,file:`c0dK-q_file`,list:`c0dK-q_list`,path:`c0dK-q_path`,pill:`c0dK-q_pill`,root:`c0dK-q_root`};let T=(0,d.memo)(function({useChat:e,useSession:t,useProjection:n,t:r}){let i=t(e=>e.running),a=e(e=>e.nodes),o=e(e=>e.navigation.items().at(-1)?.turn),s=ee(a,i?o:void 0,n);if(!i||s.length===0)return null;let{added:c,removed:l}=S(s);return/* @__PURE__ */ (0,f.jsx)(`div`,{className:w.root,children:/* @__PURE__ */ (0,f.jsxs)(`div`,{className:w.anchor,tabIndex:0,children:[/* @__PURE__ */ (0,f.jsx)(`ul`,{className:w.list,children:s.map(e=>/* @__PURE__ */ (0,f.jsxs)(`li`,{className:w.file,children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:w.path,children:C(e.path)}),/* @__PURE__ */ (0,f.jsx)(v,{added:e.added,removed:e.removed})]},e.path))}),/* @__PURE__ */ (0,f.jsxs)(`div`,{className:w.pill,role:`status`,children:[/* @__PURE__ */ (0,f.jsx)(`span`,{children:r(`chat.filesChanged`,{count:s.length})}),/* @__PURE__ */ (0,f.jsx)(v,{added:c,removed:l})]})]})})});function ne(e){return encodeURIComponent(e).replace(/%3A/gi,`:`)}function re(e){return e.split(`/`).map(ne).join(`/`)}function E(e,t){let n=t.replace(/\\/g,`/`).replace(/^(?:\.\/)+/,``);return`dsh-resource://file/session/${ne(e)}/${re(n)}`}function ie(e){return/^[A-Za-z]:[/\\]/.test(e)||e.startsWith(`\\\\`)}function D(e){return e.startsWith(`/`)||ie(e)}function ae(e,t){if(D(t)||e===void 0||e===``)return t;let n=ie(e)&&e.includes(`\\`)?`\\`:`/`;return`${e.replace(/[/\\]+$/,``)}${n}${t.replace(/^[/\\]+/,``)}`}function oe(e,t,n){let r=n.replace(/\\/g,`/`);if(!D(r))return E(e,r);let i=t===void 0?``:t.replace(/\\/g,`/`).replace(/\/+$/,``);return i!==``&&r===i?E(e,``):i!==``&&r.startsWith(`${i}/`)?E(e,r.slice(i.length+1)):E(e,r)}function se(e,t){if(!(!/^https?:/u.test(e)&&!e.startsWith(`dsh-app://app/`)||!D(t)||/^[/\\]{2}/u.test(t)||/[\u0000-\u001f\u007f]/u.test(t)))return new URL(`api/file?path=${encodeURIComponent(t)}`,e).href}let O=[],ce={turnOrder:O,turns:/* @__PURE__ */ new Map},le={getSnapshot:()=>void 0,subscribe:()=>()=>{}},ue={getSnapshot:()=>void 0,subscribe:()=>()=>{}},de={getSnapshot:()=>O,subscribe:()=>()=>{}},fe={order:O,nodes:{get:()=>void 0,source:()=>le,turnDataSource:()=>de,processSource:()=>ue,values:()=>O},locations:{getTurn:()=>O,getStep:()=>O},navigation:{items:()=>O},timeline:ce,legacy:{nodes:O,turnTimings:/* @__PURE__ */ new Map,turnEnds:/* @__PURE__ */ new Map,partial:null,runningCalls:O}};function pe(e){if(e!==void 0)try{let t=JSON.parse(e.argsRaw);return typeof t.command==`string`?t.command:void 0}catch{return}}function me({callId:e,useChat:t}){return t(t=>{for(let n of t.nodes.values()){let t=n.kind===`tool-call`?n.data.root:void 0;if(t!==void 0&&t.callId===e&&!(`kind`in t)&&t.phase===`start`)return pe(t)}})??null}var he;let ge=/*@__PURE__*/ Object.freeze({status:`aborted`});function k(e,t,n){function r(n,r){if(n._zod||Object.defineProperty(n,"_zod",{value:{def:r,constr:o,traits:/* @__PURE__ */ new Set},enumerable:!1}),n._zod.traits.has(e))return;n._zod.traits.add(e),t(n,r);let i=o.prototype,a=Object.keys(i);for(let e=0;e<a.length;e++){let t=a[e];t in n||(n[t]=i[t].bind(n))}}let i=n?.Parent??Object;class a extends i{}Object.defineProperty(a,"name",{value:e});function o(e){var t;let i=n?.Parent?new a:this;r(i,e),(t=i._zod).deferred??(t.deferred=[]);for(let e of i._zod.deferred)e();return i}return Object.defineProperty(o,"init",{value:r}),Object.defineProperty(o,Symbol.hasInstance,{value:t=>n?.Parent&&t instanceof n.Parent?!0:t?._zod?.traits?.has(e)}),Object.defineProperty(o,"name",{value:e}),o}var _e=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}},ve=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name=`ZodEncodeError`}};(he=globalThis).__zod_globalConfig??(he.__zod_globalConfig={});let ye=globalThis.__zod_globalConfig;function be(e){return e&&Object.assign(ye,e),ye}function xe(e){let t=Object.values(e).filter(e=>typeof e==`number`);return Object.entries(e).filter(([e,n])=>t.indexOf(+e)===-1).map(([e,t])=>t)}function Se(e,t){return typeof t==`bigint`?t.toString():t}function Ce(e){return{get value(){{let t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function we(e){return e==null}function Te(e){let t=+!!e.startsWith(`^`),n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function Ee(e,t){let n=e/t,r=Math.round(n),i=2**-52*Math.max(Math.abs(n),1);return Math.abs(n-r)<i?0:n-r}let De=/* @__PURE__*/ Symbol(`evaluating`);function A(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==De)return r===void 0&&(r=De,r=n()),r},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function Oe(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function ke(...e){let t={};for(let n of e){let e=Object.getOwnPropertyDescriptors(n);Object.assign(t,e)}return Object.defineProperties({},t)}function Ae(e){return JSON.stringify(e)}function je(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,``).replace(/[\s_-]+/g,`-`).replace(/^-+|-+$/g,``)}let Me=`captureStackTrace`in Error?Error.captureStackTrace:(...e)=>{};function Ne(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}let Pe=/* @__PURE__*/ Ce(()=>{if(ye.jitless||typeof navigator<`u`&&navigator?.userAgent?.includes(`Cloudflare`))return!1;try{return Function(``),!0}catch{return!1}});function Fe(e){if(Ne(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!=`function`)return!0;let n=t.prototype;return Ne(n)!==!1&&Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)!==!1}function Ie(e){return Fe(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}let Le=/* @__PURE__*/ new Set([`string`,`number`,`symbol`]);function Re(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function ze(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function j(e){let t=e;if(!t)return{};if(typeof t==`string`)return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error==`string`?{...t,error:()=>t.error}:t}function Be(e){return Object.keys(e).filter(t=>e[t]._zod.optin===`optional`&&e[t]._zod.optout===`optional`)}let Ve={safeint:[-(2**53-1),2**53-1],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function He(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.pick() cannot be used on object schemas containing refinements`);return ze(e,ke(e._zod.def,{get shape(){let e={};for(let r in t){if(!(r in n.shape))throw Error(`Unrecognized key: "${r}"`);t[r]&&(e[r]=n.shape[r])}return Oe(this,`shape`,e),e},checks:[]}))}function Ue(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.omit() cannot be used on object schemas containing refinements`);return ze(e,ke(e._zod.def,{get shape(){let r={...e._zod.def.shape};for(let e in t){if(!(e in n.shape))throw Error(`Unrecognized key: "${e}"`);t[e]&&delete r[e]}return Oe(this,`shape`,r),r},checks:[]}))}function We(e,t){if(!Fe(t))throw Error(`Invalid input to extend: expected a plain object`);let n=e._zod.def.checks;if(n&&n.length>0){let n=e._zod.def.shape;for(let e in t)if(Object.getOwnPropertyDescriptor(n,e)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return ze(e,ke(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return Oe(this,`shape`,n),n}}))}function Ge(e,t){if(!Fe(t))throw Error(`Invalid input to safeExtend: expected a plain object`);return ze(e,ke(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return Oe(this,`shape`,n),n}}))}function Ke(e,t){if(e._zod.def.checks?.length)throw Error(`.merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.`);return ze(e,ke(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t._zod.def.shape};return Oe(this,`shape`,n),n},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]}))}function qe(e,t,n){let r=t._zod.def.checks;if(r&&r.length>0)throw Error(`.partial() cannot be used on object schemas containing refinements`);return ze(t,ke(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in r))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t])}else for(let t in r)i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t];return Oe(this,`shape`,i),i},checks:[]}))}function Je(e,t,n){return ze(t,ke(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in i))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=new e({type:`nonoptional`,innerType:r[t]}))}else for(let t in r)i[t]=new e({type:`nonoptional`,innerType:r[t]});return Oe(this,`shape`,i),i}}))}function Ye(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function Xe(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue===!1)return!0;return!1}function Ze(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function Qe(e){return typeof e==`string`?e:e?.message}function $e(e,t,n){let r=e.message?e.message:Qe(e.inst?._zod.def?.error?.(e))??Qe(t?.error?.(e))??Qe(n.customError?.(e))??Qe(n.localeError?.(e))??`Invalid input`,{inst:i,continue:a,input:o,...s}=e;return s.path??=[],s.message=r,t?.reportInput&&(s.input=o),s}function et(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function tt(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}let nt=(e,t)=>{e.name=`$ZodError`,Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,Se,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},rt=k(`$ZodError`,nt),it=k(`$ZodError`,nt,{Parent:Error});function at(e,t=e=>e.message){let n={},r=[];for(let i of e.issues)i.path.length>0?(n[i.path[0]]=n[i.path[0]]||[],n[i.path[0]].push(t(i))):r.push(t(i));return{formErrors:r,fieldErrors:n}}function ot(e,t=e=>e.message){let n={_errors:[]},r=(e,i=[])=>{for(let a of e.issues)if(a.code===`invalid_union`&&a.errors.length)a.errors.map(e=>r({issues:e},[...i,...a.path]));else if(a.code===`invalid_key`)r({issues:a.issues},[...i,...a.path]);else if(a.code===`invalid_element`)r({issues:a.issues},[...i,...a.path]);else{let e=[...i,...a.path];if(e.length===0)n._errors.push(t(a));else{let r=n,i=0;for(;i<e.length;){let n=e[i];i===e.length-1?(r[n]=r[n]||{_errors:[]},r[n]._errors.push(t(a))):r[n]=r[n]||{_errors:[]},r=r[n],i++}}}};return r(e),n}let st=e=>(t,n,r,i)=>{let a=r?{...r,async:!1}:{async:!1},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise)throw new _e;if(o.issues.length){let t=new((i?.Err)??e)(o.issues.map(e=>$e(e,a,be())));throw Me(t,i?.callee),t}return o.value},ct=e=>async(t,n,r,i)=>{let a=r?{...r,async:!0}:{async:!0},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise&&(o=await o),o.issues.length){let t=new((i?.Err)??e)(o.issues.map(e=>$e(e,a,be())));throw Me(t,i?.callee),t}return o.value},lt=e=>(t,n,r)=>{let i=r?{...r,async:!1}:{async:!1},a=t._zod.run({value:n,issues:[]},i);if(a instanceof Promise)throw new _e;return a.issues.length?{success:!1,error:new(e??rt)(a.issues.map(e=>$e(e,i,be())))}:{success:!0,data:a.value}},ut=/* @__PURE__*/ lt(it),dt=e=>async(t,n,r)=>{let i=r?{...r,async:!0}:{async:!0},a=t._zod.run({value:n,issues:[]},i);return a instanceof Promise&&(a=await a),a.issues.length?{success:!1,error:new e(a.issues.map(e=>$e(e,i,be())))}:{success:!0,data:a.value}},ft=/* @__PURE__*/ dt(it),pt=e=>(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return st(e)(t,n,i)},mt=e=>(t,n,r)=>st(e)(t,n,r),ht=e=>async(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return ct(e)(t,n,i)},gt=e=>async(t,n,r)=>ct(e)(t,n,r),_t=e=>(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return lt(e)(t,n,i)},vt=e=>(t,n,r)=>lt(e)(t,n,r),yt=e=>async(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return dt(e)(t,n,i)},bt=e=>async(t,n,r)=>dt(e)(t,n,r),xt=/^[cC][0-9a-z]{6,}$/,St=/^[0-9a-z]+$/,Ct=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,wt=/^[0-9a-vA-V]{20}$/,Tt=/^[A-Za-z0-9]{27}$/,Et=/^[a-zA-Z0-9_-]{21}$/,Dt=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Ot=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,kt=e=>e?RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,At=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;function jt(){return RegExp(`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`,`u`)}let Mt=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Nt=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,Pt=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,Ft=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,It=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Lt=/^[A-Za-z0-9_-]*$/,Rt=/^https?$/,zt=/^\+[1-9]\d{6,14}$/,Bt=`(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))`,Vt=/*@__PURE__*/ RegExp(`^${Bt}$`);function Ht(e){let t=`(?:[01]\\d|2[0-3]):[0-5]\\d`;return typeof e.precision==`number`?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function Ut(e){return RegExp(`^${Ht(e)}$`)}function Wt(e){let t=Ht({precision:e.precision}),n=[`Z`];e.local&&n.push(``),e.offset&&n.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);let r=`${t}(?:${n.join(`|`)})`;return RegExp(`^${Bt}T(?:${r})$`)}let Gt=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??``}}`:`[\\s\\S]*`;return RegExp(`^${t}$`)},Kt=/^-?\d+$/,qt=/^-?\d+(?:\.\d+)?$/,Jt=/^(?:true|false)$/i,Yt=/^null$/i,Xt=/^[^A-Z]*$/,Zt=/^[^a-z]*$/,Qt=/*@__PURE__*/ k(`$ZodCheck`,(e,t)=>{var n;e._zod??={},e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),$t={number:`number`,bigint:`bigint`,object:`date`},en=/*@__PURE__*/ k(`$ZodCheckLessThan`,(e,t)=>{Qt.init(e,t);let n=$t[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.maximum:n.exclusiveMaximum)??1/0;t.value<r&&(t.inclusive?n.maximum=t.value:n.exclusiveMaximum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:n,code:`too_big`,maximum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),tn=/*@__PURE__*/ k(`$ZodCheckGreaterThan`,(e,t)=>{Qt.init(e,t);let n=$t[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.minimum:n.exclusiveMinimum)??-1/0;t.value>r&&(t.inclusive?n.minimum=t.value:n.exclusiveMinimum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:n,code:`too_small`,minimum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),nn=/*@__PURE__*/ k(`$ZodCheckMultipleOf`,(e,t)=>{Qt.init(e,t),e._zod.onattach.push(e=>{var n;(n=e._zod.bag).multipleOf??(n.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw Error(`Cannot mix number and bigint in multiple_of check.`);(typeof n.value==`bigint`?n.value%t.value===BigInt(0):Ee(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:`not_multiple_of`,divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),rn=/*@__PURE__*/ k(`$ZodCheckNumberFormat`,(e,t)=>{Qt.init(e,t),t.format=t.format||`float64`;let n=t.format?.includes(`int`),r=n?`int`:`number`,[i,a]=Ve[t.format];e._zod.onattach.push(e=>{let r=e._zod.bag;r.format=t.format,r.minimum=i,r.maximum=a,n&&(r.pattern=Kt)}),e._zod.check=o=>{let s=o.value;if(n){if(!Number.isInteger(s)){o.issues.push({expected:r,format:t.format,code:`invalid_type`,continue:!1,input:s,inst:e});return}if(!Number.isSafeInteger(s)){s>0?o.issues.push({input:s,code:`too_big`,maximum:2**53-1,note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort}):o.issues.push({input:s,code:`too_small`,minimum:-(2**53-1),note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort});return}}s<i&&o.issues.push({origin:`number`,input:s,code:`too_small`,minimum:i,inclusive:!0,inst:e,continue:!t.abort}),s>a&&o.issues.push({origin:`number`,input:s,code:`too_big`,maximum:a,inclusive:!0,inst:e,continue:!t.abort})}}),an=/*@__PURE__*/ k(`$ZodCheckMaxLength`,(e,t)=>{var n;Qt.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!we(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.maximum??1/0;t.maximum<n&&(e._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{let r=n.value;if(r.length<=t.maximum)return;let i=et(r);n.issues.push({origin:i,code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),on=/*@__PURE__*/ k(`$ZodCheckMinLength`,(e,t)=>{var n;Qt.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!we(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.minimum??-1/0;t.minimum>n&&(e._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{let r=n.value;if(r.length>=t.minimum)return;let i=et(r);n.issues.push({origin:i,code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),sn=/*@__PURE__*/ k(`$ZodCheckLengthEquals`,(e,t)=>{var n;Qt.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!we(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag;n.minimum=t.length,n.maximum=t.length,n.length=t.length}),e._zod.check=n=>{let r=n.value,i=r.length;if(i===t.length)return;let a=et(r),o=i>t.length;n.issues.push({origin:a,...o?{code:`too_big`,maximum:t.length}:{code:`too_small`,minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),cn=/*@__PURE__*/ k(`$ZodCheckStringFormat`,(e,t)=>{var n,r;Qt.init(e,t),e._zod.onattach.push(e=>{let n=e._zod.bag;n.format=t.format,t.pattern&&(n.patterns??=/* @__PURE__ */ new Set,n.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),ln=/*@__PURE__*/ k(`$ZodCheckRegex`,(e,t)=>{cn.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:`regex`,input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),un=/*@__PURE__*/ k(`$ZodCheckLowerCase`,(e,t)=>{t.pattern??=Xt,cn.init(e,t)}),dn=/*@__PURE__*/ k(`$ZodCheckUpperCase`,(e,t)=>{t.pattern??=Zt,cn.init(e,t)}),fn=/*@__PURE__*/ k(`$ZodCheckIncludes`,(e,t)=>{Qt.init(e,t);let n=Re(t.includes),r=new RegExp(typeof t.position==`number`?`^.{${t.position}}${n}`:n);t.pattern=r,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=/* @__PURE__ */ new Set,t.patterns.add(r)}),e._zod.check=n=>{n.value.includes(t.includes,t.position)||n.issues.push({origin:`string`,code:`invalid_format`,format:`includes`,includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),pn=/*@__PURE__*/ k(`$ZodCheckStartsWith`,(e,t)=>{Qt.init(e,t);let n=RegExp(`^${Re(t.prefix)}.*`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=/* @__PURE__ */ new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`starts_with`,prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),mn=/*@__PURE__*/ k(`$ZodCheckEndsWith`,(e,t)=>{Qt.init(e,t);let n=RegExp(`.*${Re(t.suffix)}$`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=/* @__PURE__ */ new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`ends_with`,suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}),hn=/*@__PURE__*/ k(`$ZodCheckOverwrite`,(e,t)=>{Qt.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}});var gn=class{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),--this.indent}write(e){if(typeof e==`function`){e(this,{execution:`sync`}),e(this,{execution:`async`});return}let t=e.split(`
1
+ window.__ModuleLoader__.load({id:`@deepseek-ai/dsh-client-ui-chat`,factory:e=>{var t={exports:{}},n=t.exports;Object.defineProperty(n,Symbol.toStringTag,{value:`Module`});var r=Object.create,i=Object.defineProperty,a=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyNames,s=Object.getPrototypeOf,c=Object.prototype.hasOwnProperty,l=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var s=o(t),l=0,u=s.length,d;l<u;l++)d=s[l],!c.call(e,d)&&d!==n&&i(e,d,{get:(e=>t[e]).bind(null,d),enumerable:!(r=a(t,d))||r.enumerable});return e},u=(e,t,n)=>(n=e==null?{}:r(s(e)),l(t||!e||!e.__esModule||!c.call(e,`default`)?i(n,`default`,{value:e,enumerable:!0}):n,e));let d=e("react");d=u(d,1);let f=e("react/jsx-runtime"),p=e("@deepseek-ai/dsh-client-ui-primitives"),m=e("@deepseek-ai/dsh-client-store"),h=e("react-dom"),g=`@deepseek-ai/dsh-client-ui-chat/ChangeStat.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(g)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=g,e.textContent=`.zmMCYq_stat{font-size:var(--dsh-change-stat-font-size,inherit);font-variant-numeric:tabular-nums;white-space:nowrap;gap:6px;display:inline-flex}.zmMCYq_added{color:var(--dsw-alias-state-success-primary)}.zmMCYq_removed{color:var(--dsw-alias-state-error-primary)}`,document.head.appendChild(e)}var _={added:`zmMCYq_added`,removed:`zmMCYq_removed`,stat:`zmMCYq_stat`};function v({added:e,removed:t}){return/* @__PURE__ */ (0,f.jsxs)(`span`,{className:_.stat,children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:_.added,children:`+${e}`}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:_.removed,children:`-${t}`})]})}let y=[],ee={getSnapshot:()=>void 0,subscribe:()=>()=>{}};function b(e){let t=/* @__PURE__ */ new Map;for(let n of e){let{parentCallId:e,isError:r,meta:i}=n;if(e!==void 0||r===!0||!Array.isArray(i?.diffs))continue;let a=/* @__PURE__ */ new Map;for(let e of i.diffs)typeof e?.path==`string`&&a.set(e.path,[...a.get(e.path)??[],e]);for(let[e,n]of a)t.set(e,n)}return[...t].map(([e,t])=>({path:e,...(0,p.diffTotals)(t),hunks:t}))}function te(e,t,n){let r=n(`codexhostTurnChanges`,e=>t===void 0?void 0:e?.[t]),i=t===void 0||r!==void 0?ee:e.turnDataSource(t,`tool-call`),a=(0,d.useSyncExternalStore)(i.subscribe,i.getSnapshot);return r===void 0?a===void 0?y:b(a.map(e=>e.root)):r}function x(e){return{added:e.reduce((e,t)=>e+t.added,0),removed:e.reduce((e,t)=>e+t.removed,0)}}function S(e){return e.split(/[\\/]/).at(-1)??e}let C=`@deepseek-ai/dsh-client-ui-chat/ChangesDock.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(C)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=C,e.textContent=`.c0dK-q_root{justify-content:center;margin-bottom:6px;display:flex}.c0dK-q_anchor{corner-shape:round;border-radius:16px;position:relative}.c0dK-q_anchor:focus-visible{outline:2px solid var(--dsw-alias-label-tertiary);outline-offset:2px}.c0dK-q_pill{border:1px solid var(--dsw-alias-border-l1);border-radius:inherit;corner-shape:round;color:var(--dsw-alias-label-tertiary);font-size:calc(var(--dsh-content-font-size-secondary,13px) + 2px);white-space:nowrap;--dsh-change-stat-font-size:calc(var(--dsh-content-font-size-secondary,13px) + 1px);--dsw-alias-state-success-primary:var(--dsw-alias-file-diff-added-marker);--dsw-alias-state-error-primary:var(--dsw-alias-file-diff-deleted-marker);background:0 0;align-items:center;gap:4px;padding:8px 12px;line-height:20px;display:inline-flex}.c0dK-q_list{corner-shape:round;background:var(--dsw-alias-button-floating-fill);box-shadow:var(--dsw-elevation-panel);color:var(--dsw-alias-label-primary);font-size:calc(var(--dsh-content-font-size-secondary,13px) - 1px);white-space:nowrap;border-radius:12px;margin:0;padding:4px 12px;list-style:none;display:none;position:absolute;bottom:calc(100% + 6px);left:50%;transform:translate(-50%)}.c0dK-q_anchor:is(:hover,:focus-visible) .c0dK-q_list{display:block}.c0dK-q_file{justify-content:space-between;gap:16px;max-width:360px;padding:3px 0;display:flex}.c0dK-q_path{text-overflow:ellipsis;overflow:hidden}`,document.head.appendChild(e)}var w={anchor:`c0dK-q_anchor`,file:`c0dK-q_file`,list:`c0dK-q_list`,path:`c0dK-q_path`,pill:`c0dK-q_pill`,root:`c0dK-q_root`};let T=(0,d.memo)(function({useChat:e,useSession:t,useProjection:n,t:r}){let i=t(e=>e.running),a=e(e=>e.nodes),o=e(e=>e.navigation.items().at(-1)?.turn),s=te(a,i?o:void 0,n);if(!i||s.length===0)return null;let{added:c,removed:l}=x(s);return/* @__PURE__ */ (0,f.jsx)(`div`,{className:w.root,children:/* @__PURE__ */ (0,f.jsxs)(`div`,{className:w.anchor,tabIndex:0,children:[/* @__PURE__ */ (0,f.jsx)(`ul`,{className:w.list,children:s.map(e=>/* @__PURE__ */ (0,f.jsxs)(`li`,{className:w.file,children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:w.path,children:S(e.path)}),/* @__PURE__ */ (0,f.jsx)(v,{added:e.added,removed:e.removed})]},e.path))}),/* @__PURE__ */ (0,f.jsxs)(`div`,{className:w.pill,role:`status`,children:[/* @__PURE__ */ (0,f.jsx)(`span`,{children:r(`chat.filesChanged`,{count:s.length})}),/* @__PURE__ */ (0,f.jsx)(v,{added:c,removed:l})]})]})})});function E(e){return encodeURIComponent(e).replace(/%3A/gi,`:`)}function ne(e){return e.split(`/`).map(E).join(`/`)}function re(e,t){let n=t.replace(/\\/g,`/`).replace(/^(?:\.\/)+/,``);return`dsh-resource://file/session/${E(e)}/${ne(n)}`}function ie(e){return/^[A-Za-z]:[/\\]/.test(e)||e.startsWith(`\\\\`)}function D(e){return e.startsWith(`/`)||ie(e)}function ae(e,t){if(D(t)||e===void 0||e===``)return t;let n=ie(e)&&e.includes(`\\`)?`\\`:`/`;return`${e.replace(/[/\\]+$/,``)}${n}${t.replace(/^[/\\]+/,``)}`}function O(e,t,n){let r=n.replace(/\\/g,`/`);if(!D(r))return re(e,r);let i=t===void 0?``:t.replace(/\\/g,`/`).replace(/\/+$/,``);return i!==``&&r===i?re(e,``):i!==``&&r.startsWith(`${i}/`)?re(e,r.slice(i.length+1)):re(e,r)}function oe(e,t){if(!(!/^https?:/u.test(e)&&!e.startsWith(`dsh-app://app/`)||!D(t)||/^[/\\]{2}/u.test(t)||/[\u0000-\u001f\u007f]/u.test(t)))return new URL(`api/file?path=${encodeURIComponent(t)}`,e).href}let k=[],se={turnOrder:k,turns:/* @__PURE__ */ new Map},ce={getSnapshot:()=>void 0,subscribe:()=>()=>{}},le={getSnapshot:()=>void 0,subscribe:()=>()=>{}},ue={getSnapshot:()=>k,subscribe:()=>()=>{}},de={order:k,nodes:{get:()=>void 0,source:()=>ce,turnDataSource:()=>ue,processSource:()=>le,values:()=>k},locations:{getTurn:()=>k,getStep:()=>k},navigation:{items:()=>k},timeline:se,legacy:{nodes:k,turnTimings:/* @__PURE__ */ new Map,turnEnds:/* @__PURE__ */ new Map,partial:null,runningCalls:k}};function fe(e){if(e!==void 0)try{let t=JSON.parse(e.argsRaw);return typeof t.command==`string`?t.command:void 0}catch{return}}function pe({callId:e,useChat:t}){return t(t=>{for(let n of t.nodes.values()){let t=n.kind===`tool-call`?n.data.root:void 0;if(t!==void 0&&t.callId===e&&!(`kind`in t)&&t.phase===`start`)return fe(t)}})??null}var me;let he=/*@__PURE__*/ Object.freeze({status:`aborted`});function A(e,t,n){function r(n,r){if(n._zod||Object.defineProperty(n,"_zod",{value:{def:r,constr:o,traits:/* @__PURE__ */ new Set},enumerable:!1}),n._zod.traits.has(e))return;n._zod.traits.add(e),t(n,r);let i=o.prototype,a=Object.keys(i);for(let e=0;e<a.length;e++){let t=a[e];t in n||(n[t]=i[t].bind(n))}}let i=n?.Parent??Object;class a extends i{}Object.defineProperty(a,"name",{value:e});function o(e){var t;let i=n?.Parent?new a:this;r(i,e),(t=i._zod).deferred??(t.deferred=[]);for(let e of i._zod.deferred)e();return i}return Object.defineProperty(o,"init",{value:r}),Object.defineProperty(o,Symbol.hasInstance,{value:t=>n?.Parent&&t instanceof n.Parent?!0:t?._zod?.traits?.has(e)}),Object.defineProperty(o,"name",{value:e}),o}var ge=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}},_e=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name=`ZodEncodeError`}};(me=globalThis).__zod_globalConfig??(me.__zod_globalConfig={});let ve=globalThis.__zod_globalConfig;function ye(e){return e&&Object.assign(ve,e),ve}function be(e){let t=Object.values(e).filter(e=>typeof e==`number`);return Object.entries(e).filter(([e,n])=>t.indexOf(+e)===-1).map(([e,t])=>t)}function xe(e,t){return typeof t==`bigint`?t.toString():t}function Se(e){return{get value(){{let t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function Ce(e){return e==null}function we(e){let t=+!!e.startsWith(`^`),n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function Te(e,t){let n=e/t,r=Math.round(n),i=2**-52*Math.max(Math.abs(n),1);return Math.abs(n-r)<i?0:n-r}let Ee=/* @__PURE__*/ Symbol(`evaluating`);function j(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==Ee)return r===void 0&&(r=Ee,r=n()),r},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function De(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function Oe(...e){let t={};for(let n of e){let e=Object.getOwnPropertyDescriptors(n);Object.assign(t,e)}return Object.defineProperties({},t)}function ke(e){return JSON.stringify(e)}function Ae(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,``).replace(/[\s_-]+/g,`-`).replace(/^-+|-+$/g,``)}let je=`captureStackTrace`in Error?Error.captureStackTrace:(...e)=>{};function Me(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}let Ne=/* @__PURE__*/ Se(()=>{if(ve.jitless||typeof navigator<`u`&&navigator?.userAgent?.includes(`Cloudflare`))return!1;try{return Function(``),!0}catch{return!1}});function Pe(e){if(Me(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!=`function`)return!0;let n=t.prototype;return Me(n)!==!1&&Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)!==!1}function Fe(e){return Pe(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}let Ie=/* @__PURE__*/ new Set([`string`,`number`,`symbol`]);function Le(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function Re(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function M(e){let t=e;if(!t)return{};if(typeof t==`string`)return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error==`string`?{...t,error:()=>t.error}:t}function ze(e){return Object.keys(e).filter(t=>e[t]._zod.optin===`optional`&&e[t]._zod.optout===`optional`)}let Be={safeint:[-(2**53-1),2**53-1],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function Ve(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.pick() cannot be used on object schemas containing refinements`);return Re(e,Oe(e._zod.def,{get shape(){let e={};for(let r in t){if(!(r in n.shape))throw Error(`Unrecognized key: "${r}"`);t[r]&&(e[r]=n.shape[r])}return De(this,`shape`,e),e},checks:[]}))}function He(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.omit() cannot be used on object schemas containing refinements`);return Re(e,Oe(e._zod.def,{get shape(){let r={...e._zod.def.shape};for(let e in t){if(!(e in n.shape))throw Error(`Unrecognized key: "${e}"`);t[e]&&delete r[e]}return De(this,`shape`,r),r},checks:[]}))}function Ue(e,t){if(!Pe(t))throw Error(`Invalid input to extend: expected a plain object`);let n=e._zod.def.checks;if(n&&n.length>0){let n=e._zod.def.shape;for(let e in t)if(Object.getOwnPropertyDescriptor(n,e)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return Re(e,Oe(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return De(this,`shape`,n),n}}))}function We(e,t){if(!Pe(t))throw Error(`Invalid input to safeExtend: expected a plain object`);return Re(e,Oe(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return De(this,`shape`,n),n}}))}function Ge(e,t){if(e._zod.def.checks?.length)throw Error(`.merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.`);return Re(e,Oe(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t._zod.def.shape};return De(this,`shape`,n),n},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]}))}function Ke(e,t,n){let r=t._zod.def.checks;if(r&&r.length>0)throw Error(`.partial() cannot be used on object schemas containing refinements`);return Re(t,Oe(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in r))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t])}else for(let t in r)i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t];return De(this,`shape`,i),i},checks:[]}))}function qe(e,t,n){return Re(t,Oe(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in i))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=new e({type:`nonoptional`,innerType:r[t]}))}else for(let t in r)i[t]=new e({type:`nonoptional`,innerType:r[t]});return De(this,`shape`,i),i}}))}function Je(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function Ye(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue===!1)return!0;return!1}function Xe(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function Ze(e){return typeof e==`string`?e:e?.message}function Qe(e,t,n){let r=e.message?e.message:Ze(e.inst?._zod.def?.error?.(e))??Ze(t?.error?.(e))??Ze(n.customError?.(e))??Ze(n.localeError?.(e))??`Invalid input`,{inst:i,continue:a,input:o,...s}=e;return s.path??=[],s.message=r,t?.reportInput&&(s.input=o),s}function $e(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function et(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}let tt=(e,t)=>{e.name=`$ZodError`,Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,xe,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},nt=A(`$ZodError`,tt),rt=A(`$ZodError`,tt,{Parent:Error});function it(e,t=e=>e.message){let n={},r=[];for(let i of e.issues)i.path.length>0?(n[i.path[0]]=n[i.path[0]]||[],n[i.path[0]].push(t(i))):r.push(t(i));return{formErrors:r,fieldErrors:n}}function at(e,t=e=>e.message){let n={_errors:[]},r=(e,i=[])=>{for(let a of e.issues)if(a.code===`invalid_union`&&a.errors.length)a.errors.map(e=>r({issues:e},[...i,...a.path]));else if(a.code===`invalid_key`)r({issues:a.issues},[...i,...a.path]);else if(a.code===`invalid_element`)r({issues:a.issues},[...i,...a.path]);else{let e=[...i,...a.path];if(e.length===0)n._errors.push(t(a));else{let r=n,i=0;for(;i<e.length;){let n=e[i];i===e.length-1?(r[n]=r[n]||{_errors:[]},r[n]._errors.push(t(a))):r[n]=r[n]||{_errors:[]},r=r[n],i++}}}};return r(e),n}let ot=e=>(t,n,r,i)=>{let a=r?{...r,async:!1}:{async:!1},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise)throw new ge;if(o.issues.length){let t=new((i?.Err)??e)(o.issues.map(e=>Qe(e,a,ye())));throw je(t,i?.callee),t}return o.value},st=e=>async(t,n,r,i)=>{let a=r?{...r,async:!0}:{async:!0},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise&&(o=await o),o.issues.length){let t=new((i?.Err)??e)(o.issues.map(e=>Qe(e,a,ye())));throw je(t,i?.callee),t}return o.value},ct=e=>(t,n,r)=>{let i=r?{...r,async:!1}:{async:!1},a=t._zod.run({value:n,issues:[]},i);if(a instanceof Promise)throw new ge;return a.issues.length?{success:!1,error:new(e??nt)(a.issues.map(e=>Qe(e,i,ye())))}:{success:!0,data:a.value}},lt=/* @__PURE__*/ ct(rt),ut=e=>async(t,n,r)=>{let i=r?{...r,async:!0}:{async:!0},a=t._zod.run({value:n,issues:[]},i);return a instanceof Promise&&(a=await a),a.issues.length?{success:!1,error:new e(a.issues.map(e=>Qe(e,i,ye())))}:{success:!0,data:a.value}},dt=/* @__PURE__*/ ut(rt),ft=e=>(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return ot(e)(t,n,i)},pt=e=>(t,n,r)=>ot(e)(t,n,r),mt=e=>async(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return st(e)(t,n,i)},ht=e=>async(t,n,r)=>st(e)(t,n,r),gt=e=>(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return ct(e)(t,n,i)},_t=e=>(t,n,r)=>ct(e)(t,n,r),vt=e=>async(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return ut(e)(t,n,i)},yt=e=>async(t,n,r)=>ut(e)(t,n,r),bt=/^[cC][0-9a-z]{6,}$/,xt=/^[0-9a-z]+$/,St=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Ct=/^[0-9a-vA-V]{20}$/,wt=/^[A-Za-z0-9]{27}$/,Tt=/^[a-zA-Z0-9_-]{21}$/,Et=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Dt=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,Ot=e=>e?RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,kt=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;function At(){return RegExp(`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`,`u`)}let jt=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Mt=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,Nt=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,Pt=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Ft=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,It=/^[A-Za-z0-9_-]*$/,Lt=/^https?$/,Rt=/^\+[1-9]\d{6,14}$/,zt=`(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))`,Bt=/*@__PURE__*/ RegExp(`^${zt}$`);function Vt(e){let t=`(?:[01]\\d|2[0-3]):[0-5]\\d`;return typeof e.precision==`number`?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function Ht(e){return RegExp(`^${Vt(e)}$`)}function Ut(e){let t=Vt({precision:e.precision}),n=[`Z`];e.local&&n.push(``),e.offset&&n.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);let r=`${t}(?:${n.join(`|`)})`;return RegExp(`^${zt}T(?:${r})$`)}let Wt=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??``}}`:`[\\s\\S]*`;return RegExp(`^${t}$`)},Gt=/^-?\d+$/,Kt=/^-?\d+(?:\.\d+)?$/,qt=/^(?:true|false)$/i,Jt=/^null$/i,Yt=/^[^A-Z]*$/,Xt=/^[^a-z]*$/,Zt=/*@__PURE__*/ A(`$ZodCheck`,(e,t)=>{var n;e._zod??={},e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),Qt={number:`number`,bigint:`bigint`,object:`date`},$t=/*@__PURE__*/ A(`$ZodCheckLessThan`,(e,t)=>{Zt.init(e,t);let n=Qt[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.maximum:n.exclusiveMaximum)??1/0;t.value<r&&(t.inclusive?n.maximum=t.value:n.exclusiveMaximum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:n,code:`too_big`,maximum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),en=/*@__PURE__*/ A(`$ZodCheckGreaterThan`,(e,t)=>{Zt.init(e,t);let n=Qt[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.minimum:n.exclusiveMinimum)??-1/0;t.value>r&&(t.inclusive?n.minimum=t.value:n.exclusiveMinimum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:n,code:`too_small`,minimum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),tn=/*@__PURE__*/ A(`$ZodCheckMultipleOf`,(e,t)=>{Zt.init(e,t),e._zod.onattach.push(e=>{var n;(n=e._zod.bag).multipleOf??(n.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw Error(`Cannot mix number and bigint in multiple_of check.`);(typeof n.value==`bigint`?n.value%t.value===BigInt(0):Te(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:`not_multiple_of`,divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),nn=/*@__PURE__*/ A(`$ZodCheckNumberFormat`,(e,t)=>{Zt.init(e,t),t.format=t.format||`float64`;let n=t.format?.includes(`int`),r=n?`int`:`number`,[i,a]=Be[t.format];e._zod.onattach.push(e=>{let r=e._zod.bag;r.format=t.format,r.minimum=i,r.maximum=a,n&&(r.pattern=Gt)}),e._zod.check=o=>{let s=o.value;if(n){if(!Number.isInteger(s)){o.issues.push({expected:r,format:t.format,code:`invalid_type`,continue:!1,input:s,inst:e});return}if(!Number.isSafeInteger(s)){s>0?o.issues.push({input:s,code:`too_big`,maximum:2**53-1,note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort}):o.issues.push({input:s,code:`too_small`,minimum:-(2**53-1),note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort});return}}s<i&&o.issues.push({origin:`number`,input:s,code:`too_small`,minimum:i,inclusive:!0,inst:e,continue:!t.abort}),s>a&&o.issues.push({origin:`number`,input:s,code:`too_big`,maximum:a,inclusive:!0,inst:e,continue:!t.abort})}}),rn=/*@__PURE__*/ A(`$ZodCheckMaxLength`,(e,t)=>{var n;Zt.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!Ce(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.maximum??1/0;t.maximum<n&&(e._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{let r=n.value;if(r.length<=t.maximum)return;let i=$e(r);n.issues.push({origin:i,code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),an=/*@__PURE__*/ A(`$ZodCheckMinLength`,(e,t)=>{var n;Zt.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!Ce(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.minimum??-1/0;t.minimum>n&&(e._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{let r=n.value;if(r.length>=t.minimum)return;let i=$e(r);n.issues.push({origin:i,code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),on=/*@__PURE__*/ A(`$ZodCheckLengthEquals`,(e,t)=>{var n;Zt.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!Ce(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag;n.minimum=t.length,n.maximum=t.length,n.length=t.length}),e._zod.check=n=>{let r=n.value,i=r.length;if(i===t.length)return;let a=$e(r),o=i>t.length;n.issues.push({origin:a,...o?{code:`too_big`,maximum:t.length}:{code:`too_small`,minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),sn=/*@__PURE__*/ A(`$ZodCheckStringFormat`,(e,t)=>{var n,r;Zt.init(e,t),e._zod.onattach.push(e=>{let n=e._zod.bag;n.format=t.format,t.pattern&&(n.patterns??=/* @__PURE__ */ new Set,n.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),cn=/*@__PURE__*/ A(`$ZodCheckRegex`,(e,t)=>{sn.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:`regex`,input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),ln=/*@__PURE__*/ A(`$ZodCheckLowerCase`,(e,t)=>{t.pattern??=Yt,sn.init(e,t)}),un=/*@__PURE__*/ A(`$ZodCheckUpperCase`,(e,t)=>{t.pattern??=Xt,sn.init(e,t)}),dn=/*@__PURE__*/ A(`$ZodCheckIncludes`,(e,t)=>{Zt.init(e,t);let n=Le(t.includes),r=new RegExp(typeof t.position==`number`?`^.{${t.position}}${n}`:n);t.pattern=r,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=/* @__PURE__ */ new Set,t.patterns.add(r)}),e._zod.check=n=>{n.value.includes(t.includes,t.position)||n.issues.push({origin:`string`,code:`invalid_format`,format:`includes`,includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),fn=/*@__PURE__*/ A(`$ZodCheckStartsWith`,(e,t)=>{Zt.init(e,t);let n=RegExp(`^${Le(t.prefix)}.*`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=/* @__PURE__ */ new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`starts_with`,prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),pn=/*@__PURE__*/ A(`$ZodCheckEndsWith`,(e,t)=>{Zt.init(e,t);let n=RegExp(`.*${Le(t.suffix)}$`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=/* @__PURE__ */ new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`ends_with`,suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}),mn=/*@__PURE__*/ A(`$ZodCheckOverwrite`,(e,t)=>{Zt.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}});var hn=class{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),--this.indent}write(e){if(typeof e==`function`){e(this,{execution:`sync`}),e(this,{execution:`async`});return}let t=e.split(`
2
2
  `).filter(e=>e),n=Math.min(...t.map(e=>e.length-e.trimStart().length)),r=t.map(e=>e.slice(n)).map(e=>` `.repeat(this.indent*2)+e);for(let e of r)this.content.push(e)}compile(){let e=Function,t=this?.args,n=[...(this?.content??[``]).map(e=>` ${e}`)];return new e(...t,n.join(`
3
- `))}};let _n={major:4,minor:4,patch:3},M=/*@__PURE__*/ k(`$ZodType`,(e,t)=>{var n;e??={},e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=_n;let r=[...e._zod.def.checks??[]];e._zod.traits.has(`$ZodCheck`)&&r.unshift(e);for(let t of r)for(let n of t._zod.onattach)n(e);if(r.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let t=(e,t,n)=>{let r=Ye(e),i;for(let a of t){if(a._zod.def.when){if(Xe(e)||!a._zod.def.when(e))continue}else if(r)continue;let t=e.issues.length,o=a._zod.check(e);if(o instanceof Promise&&n?.async===!1)throw new _e;if(i||o instanceof Promise)i=(i??Promise.resolve()).then(async()=>{await o,e.issues.length!==t&&(r||=Ye(e,t))});else{if(e.issues.length===t)continue;r||=Ye(e,t)}}return i?i.then(()=>e):e},n=(n,i,a)=>{if(Ye(n))return n.aborted=!0,n;let o=t(i,r,a);if(o instanceof Promise){if(a.async===!1)throw new _e;return o.then(t=>e._zod.parse(t,a))}return e._zod.parse(o,a)};e._zod.run=(i,a)=>{if(a.skipChecks)return e._zod.parse(i,a);if(a.direction===`backward`){let t=e._zod.parse({value:i.value,issues:[]},{...a,skipChecks:!0});return t instanceof Promise?t.then(e=>n(e,i,a)):n(t,i,a)}let o=e._zod.parse(i,a);if(o instanceof Promise){if(a.async===!1)throw new _e;return o.then(e=>t(e,r,a))}return t(o,r,a)}}A(e,`~standard`,()=>({validate:t=>{try{let n=ut(e,t);return n.success?{value:n.data}:{issues:n.error?.issues}}catch{return ft(e,t).then(e=>e.success?{value:e.data}:{issues:e.error?.issues})}},vendor:`zod`,version:1}))}),vn=/*@__PURE__*/ k(`$ZodString`,(e,t)=>{M.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??Gt(e._zod.bag),e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value==`string`||n.issues.push({expected:`string`,code:`invalid_type`,input:n.value,inst:e}),n}}),N=/*@__PURE__*/ k(`$ZodStringFormat`,(e,t)=>{cn.init(e,t),vn.init(e,t)}),yn=/*@__PURE__*/ k(`$ZodGUID`,(e,t)=>{t.pattern??=Ot,N.init(e,t)}),bn=/*@__PURE__*/ k(`$ZodUUID`,(e,t)=>{if(t.version){let e={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(e===void 0)throw Error(`Invalid UUID version: "${t.version}"`);t.pattern??=kt(e)}else t.pattern??=kt();N.init(e,t)}),xn=/*@__PURE__*/ k(`$ZodEmail`,(e,t)=>{t.pattern??=At,N.init(e,t)}),Sn=/*@__PURE__*/ k(`$ZodURL`,(e,t)=>{N.init(e,t),e._zod.check=n=>{try{let r=n.value.trim();if(!t.normalize&&t.protocol?.source===Rt.source&&!/^https?:\/\//i.test(r)){n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid URL format`,input:n.value,inst:e,continue:!t.abort});return}let i=new URL(r);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(i.hostname)||n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid hostname`,pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(i.protocol.endsWith(`:`)?i.protocol.slice(0,-1):i.protocol)||n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid protocol`,pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),n.value=t.normalize?i.href:r;return}catch{n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort})}}}),Cn=/*@__PURE__*/ k(`$ZodEmoji`,(e,t)=>{t.pattern??=jt(),N.init(e,t)}),wn=/*@__PURE__*/ k(`$ZodNanoID`,(e,t)=>{t.pattern??=Et,N.init(e,t)}),Tn=/*@__PURE__*/ k(`$ZodCUID`,(e,t)=>{t.pattern??=xt,N.init(e,t)}),En=/*@__PURE__*/ k(`$ZodCUID2`,(e,t)=>{t.pattern??=St,N.init(e,t)}),Dn=/*@__PURE__*/ k(`$ZodULID`,(e,t)=>{t.pattern??=Ct,N.init(e,t)}),On=/*@__PURE__*/ k(`$ZodXID`,(e,t)=>{t.pattern??=wt,N.init(e,t)}),kn=/*@__PURE__*/ k(`$ZodKSUID`,(e,t)=>{t.pattern??=Tt,N.init(e,t)}),An=/*@__PURE__*/ k(`$ZodISODateTime`,(e,t)=>{t.pattern??=Wt(t),N.init(e,t)}),jn=/*@__PURE__*/ k(`$ZodISODate`,(e,t)=>{t.pattern??=Vt,N.init(e,t)}),Mn=/*@__PURE__*/ k(`$ZodISOTime`,(e,t)=>{t.pattern??=Ut(t),N.init(e,t)}),Nn=/*@__PURE__*/ k(`$ZodISODuration`,(e,t)=>{t.pattern??=Dt,N.init(e,t)}),Pn=/*@__PURE__*/ k(`$ZodIPv4`,(e,t)=>{t.pattern??=Mt,N.init(e,t),e._zod.bag.format=`ipv4`}),Fn=/*@__PURE__*/ k(`$ZodIPv6`,(e,t)=>{t.pattern??=Nt,N.init(e,t),e._zod.bag.format=`ipv6`,e._zod.check=n=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:`invalid_format`,format:`ipv6`,input:n.value,inst:e,continue:!t.abort})}}}),In=/*@__PURE__*/ k(`$ZodCIDRv4`,(e,t)=>{t.pattern??=Pt,N.init(e,t)}),Ln=/*@__PURE__*/ k(`$ZodCIDRv6`,(e,t)=>{t.pattern??=Ft,N.init(e,t),e._zod.check=n=>{let r=n.value.split(`/`);try{if(r.length!==2)throw Error();let[e,t]=r;if(!t)throw Error();let n=Number(t);if(`${n}`!==t||n<0||n>128)throw Error();new URL(`http://[${e}]`)}catch{n.issues.push({code:`invalid_format`,format:`cidrv6`,input:n.value,inst:e,continue:!t.abort})}}});function Rn(e){if(e===``)return!0;if(/\s/.test(e)||e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}let zn=/*@__PURE__*/ k(`$ZodBase64`,(e,t)=>{t.pattern??=It,N.init(e,t),e._zod.bag.contentEncoding=`base64`,e._zod.check=n=>{Rn(n.value)||n.issues.push({code:`invalid_format`,format:`base64`,input:n.value,inst:e,continue:!t.abort})}});function Bn(e){if(!Lt.test(e))return!1;let t=e.replace(/[-_]/g,e=>e===`-`?`+`:`/`);return Rn(t.padEnd(Math.ceil(t.length/4)*4,`=`))}let Vn=/*@__PURE__*/ k(`$ZodBase64URL`,(e,t)=>{t.pattern??=Lt,N.init(e,t),e._zod.bag.contentEncoding=`base64url`,e._zod.check=n=>{Bn(n.value)||n.issues.push({code:`invalid_format`,format:`base64url`,input:n.value,inst:e,continue:!t.abort})}}),Hn=/*@__PURE__*/ k(`$ZodE164`,(e,t)=>{t.pattern??=zt,N.init(e,t)});function Un(e,t=null){try{let n=e.split(`.`);if(n.length!==3)return!1;let[r]=n;if(!r)return!1;let i=JSON.parse(atob(r));return!(`typ`in i&&i?.typ!==`JWT`||!i.alg||t&&(!(`alg`in i)||i.alg!==t))}catch{return!1}}let Wn=/*@__PURE__*/ k(`$ZodJWT`,(e,t)=>{N.init(e,t),e._zod.check=n=>{Un(n.value,t.alg)||n.issues.push({code:`invalid_format`,format:`jwt`,input:n.value,inst:e,continue:!t.abort})}}),Gn=/*@__PURE__*/ k(`$ZodNumber`,(e,t)=>{M.init(e,t),e._zod.pattern=e._zod.bag.pattern??qt,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}let i=n.value;if(typeof i==`number`&&!Number.isNaN(i)&&Number.isFinite(i))return n;let a=typeof i==`number`?Number.isNaN(i)?`NaN`:Number.isFinite(i)?void 0:`Infinity`:void 0;return n.issues.push({expected:`number`,code:`invalid_type`,input:i,inst:e,...a?{received:a}:{}}),n}}),Kn=/*@__PURE__*/ k(`$ZodNumberFormat`,(e,t)=>{rn.init(e,t),Gn.init(e,t)}),qn=/*@__PURE__*/ k(`$ZodBoolean`,(e,t)=>{M.init(e,t),e._zod.pattern=Jt,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=!!n.value}catch{}let i=n.value;return typeof i==`boolean`||n.issues.push({expected:`boolean`,code:`invalid_type`,input:i,inst:e}),n}}),Jn=/*@__PURE__*/ k(`$ZodNull`,(e,t)=>{M.init(e,t),e._zod.pattern=Yt,e._zod.values=/* @__PURE__ */ new Set([null]),e._zod.parse=(t,n)=>{let r=t.value;return r===null||t.issues.push({expected:`null`,code:`invalid_type`,input:r,inst:e}),t}}),Yn=/*@__PURE__*/ k(`$ZodUnknown`,(e,t)=>{M.init(e,t),e._zod.parse=e=>e}),Xn=/*@__PURE__*/ k(`$ZodNever`,(e,t)=>{M.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:`never`,code:`invalid_type`,input:t.value,inst:e}),t)});function Zn(e,t,n){e.issues.length&&t.issues.push(...Ze(n,e.issues)),t.value[n]=e.value}let Qn=/*@__PURE__*/ k(`$ZodArray`,(e,t)=>{M.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!Array.isArray(i))return n.issues.push({expected:`array`,code:`invalid_type`,input:i,inst:e}),n;n.value=Array(i.length);let a=[];for(let e=0;e<i.length;e++){let o=i[e],s=t.element._zod.run({value:o,issues:[]},r);s instanceof Promise?a.push(s.then(t=>Zn(t,n,e))):Zn(s,n,e)}return a.length?Promise.all(a).then(()=>n):n}});function $n(e,t,n,r,i,a){let o=n in r;if(e.issues.length){if(i&&a&&!o)return;t.issues.push(...Ze(n,e.issues))}!o&&!i?e.issues.length||t.issues.push({code:`invalid_type`,expected:`nonoptional`,input:void 0,path:[n]}):e.value===void 0?o&&(t.value[n]=void 0):t.value[n]=e.value}function er(e){let t=Object.keys(e.shape);for(let n of t)if(!e.shape?.[n]?._zod?.traits?.has(`$ZodType`))throw Error(`Invalid element at key "${n}": expected a Zod schema`);let n=Be(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function tr(e,t,n,r,i,a){let o=[],s=i.keySet,c=i.catchall._zod,l=c.def.type,u=c.optin===`optional`,d=c.optout===`optional`;for(let i in t){if(i===`__proto__`||s.has(i))continue;if(l===`never`){o.push(i);continue}let a=c.run({value:t[i],issues:[]},r);a instanceof Promise?e.push(a.then(e=>$n(e,n,i,t,u,d))):$n(a,n,i,t,u,d)}return o.length&&n.issues.push({code:`unrecognized_keys`,keys:o,input:t,inst:a}),e.length?Promise.all(e).then(()=>n):n}let nr=/*@__PURE__*/ k(`$ZodObject`,(e,t)=>{if(M.init(e,t),!Object.getOwnPropertyDescriptor(t,`shape`)?.get){let e=t.shape;Object.defineProperty(t,"shape",{get:()=>{let n={...e};return Object.defineProperty(t,"shape",{value:n}),n}})}let n=Ce(()=>er(t));A(e._zod,`propValues`,()=>{let e=t.shape,n={};for(let t in e){let r=e[t]._zod;if(r.values){n[t]??(n[t]=/* @__PURE__ */ new Set);for(let e of r.values)n[t].add(e)}}return n});let r=Ne,i=t.catchall,a;e._zod.parse=(t,o)=>{a??=n.value;let s=t.value;if(!r(s))return t.issues.push({expected:`object`,code:`invalid_type`,input:s,inst:e}),t;t.value={};let c=[],l=a.shape;for(let e of a.keys){let n=l[e],r=n._zod.optin===`optional`,i=n._zod.optout===`optional`,a=n._zod.run({value:s[e],issues:[]},o);a instanceof Promise?c.push(a.then(n=>$n(n,t,e,s,r,i))):$n(a,t,e,s,r,i)}return i?tr(c,s,t,o,n.value,e):c.length?Promise.all(c).then(()=>t):t}}),rr=/*@__PURE__*/ k(`$ZodObjectJIT`,(e,t)=>{nr.init(e,t);let n=e._zod.parse,r=Ce(()=>er(t)),i=e=>{let t=new gn([`shape`,`payload`,`ctx`]),n=r.value,i=e=>{let t=Ae(e);return`shape[${t}]._zod.run({ value: input[${t}], issues: [] }, ctx)`};t.write(`const input = payload.value;`);let a=Object.create(null),o=0;for(let e of n.keys)a[e]=`key_${o++}`;t.write(`const newResult = {};`);for(let r of n.keys){let n=a[r],o=Ae(r),s=e[r],c=s?._zod?.optin===`optional`,l=s?._zod?.optout===`optional`;t.write(`const ${n} = ${i(r)};`),c&&l?t.write(`
3
+ `))}};let gn={major:4,minor:4,patch:3},N=/*@__PURE__*/ A(`$ZodType`,(e,t)=>{var n;e??={},e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=gn;let r=[...e._zod.def.checks??[]];e._zod.traits.has(`$ZodCheck`)&&r.unshift(e);for(let t of r)for(let n of t._zod.onattach)n(e);if(r.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let t=(e,t,n)=>{let r=Je(e),i;for(let a of t){if(a._zod.def.when){if(Ye(e)||!a._zod.def.when(e))continue}else if(r)continue;let t=e.issues.length,o=a._zod.check(e);if(o instanceof Promise&&n?.async===!1)throw new ge;if(i||o instanceof Promise)i=(i??Promise.resolve()).then(async()=>{await o,e.issues.length!==t&&(r||=Je(e,t))});else{if(e.issues.length===t)continue;r||=Je(e,t)}}return i?i.then(()=>e):e},n=(n,i,a)=>{if(Je(n))return n.aborted=!0,n;let o=t(i,r,a);if(o instanceof Promise){if(a.async===!1)throw new ge;return o.then(t=>e._zod.parse(t,a))}return e._zod.parse(o,a)};e._zod.run=(i,a)=>{if(a.skipChecks)return e._zod.parse(i,a);if(a.direction===`backward`){let t=e._zod.parse({value:i.value,issues:[]},{...a,skipChecks:!0});return t instanceof Promise?t.then(e=>n(e,i,a)):n(t,i,a)}let o=e._zod.parse(i,a);if(o instanceof Promise){if(a.async===!1)throw new ge;return o.then(e=>t(e,r,a))}return t(o,r,a)}}j(e,`~standard`,()=>({validate:t=>{try{let n=lt(e,t);return n.success?{value:n.data}:{issues:n.error?.issues}}catch{return dt(e,t).then(e=>e.success?{value:e.data}:{issues:e.error?.issues})}},vendor:`zod`,version:1}))}),_n=/*@__PURE__*/ A(`$ZodString`,(e,t)=>{N.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??Wt(e._zod.bag),e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value==`string`||n.issues.push({expected:`string`,code:`invalid_type`,input:n.value,inst:e}),n}}),P=/*@__PURE__*/ A(`$ZodStringFormat`,(e,t)=>{sn.init(e,t),_n.init(e,t)}),vn=/*@__PURE__*/ A(`$ZodGUID`,(e,t)=>{t.pattern??=Dt,P.init(e,t)}),yn=/*@__PURE__*/ A(`$ZodUUID`,(e,t)=>{if(t.version){let e={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(e===void 0)throw Error(`Invalid UUID version: "${t.version}"`);t.pattern??=Ot(e)}else t.pattern??=Ot();P.init(e,t)}),bn=/*@__PURE__*/ A(`$ZodEmail`,(e,t)=>{t.pattern??=kt,P.init(e,t)}),xn=/*@__PURE__*/ A(`$ZodURL`,(e,t)=>{P.init(e,t),e._zod.check=n=>{try{let r=n.value.trim();if(!t.normalize&&t.protocol?.source===Lt.source&&!/^https?:\/\//i.test(r)){n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid URL format`,input:n.value,inst:e,continue:!t.abort});return}let i=new URL(r);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(i.hostname)||n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid hostname`,pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(i.protocol.endsWith(`:`)?i.protocol.slice(0,-1):i.protocol)||n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid protocol`,pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),n.value=t.normalize?i.href:r;return}catch{n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort})}}}),Sn=/*@__PURE__*/ A(`$ZodEmoji`,(e,t)=>{t.pattern??=At(),P.init(e,t)}),Cn=/*@__PURE__*/ A(`$ZodNanoID`,(e,t)=>{t.pattern??=Tt,P.init(e,t)}),wn=/*@__PURE__*/ A(`$ZodCUID`,(e,t)=>{t.pattern??=bt,P.init(e,t)}),Tn=/*@__PURE__*/ A(`$ZodCUID2`,(e,t)=>{t.pattern??=xt,P.init(e,t)}),En=/*@__PURE__*/ A(`$ZodULID`,(e,t)=>{t.pattern??=St,P.init(e,t)}),Dn=/*@__PURE__*/ A(`$ZodXID`,(e,t)=>{t.pattern??=Ct,P.init(e,t)}),On=/*@__PURE__*/ A(`$ZodKSUID`,(e,t)=>{t.pattern??=wt,P.init(e,t)}),kn=/*@__PURE__*/ A(`$ZodISODateTime`,(e,t)=>{t.pattern??=Ut(t),P.init(e,t)}),An=/*@__PURE__*/ A(`$ZodISODate`,(e,t)=>{t.pattern??=Bt,P.init(e,t)}),jn=/*@__PURE__*/ A(`$ZodISOTime`,(e,t)=>{t.pattern??=Ht(t),P.init(e,t)}),Mn=/*@__PURE__*/ A(`$ZodISODuration`,(e,t)=>{t.pattern??=Et,P.init(e,t)}),Nn=/*@__PURE__*/ A(`$ZodIPv4`,(e,t)=>{t.pattern??=jt,P.init(e,t),e._zod.bag.format=`ipv4`}),Pn=/*@__PURE__*/ A(`$ZodIPv6`,(e,t)=>{t.pattern??=Mt,P.init(e,t),e._zod.bag.format=`ipv6`,e._zod.check=n=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:`invalid_format`,format:`ipv6`,input:n.value,inst:e,continue:!t.abort})}}}),Fn=/*@__PURE__*/ A(`$ZodCIDRv4`,(e,t)=>{t.pattern??=Nt,P.init(e,t)}),In=/*@__PURE__*/ A(`$ZodCIDRv6`,(e,t)=>{t.pattern??=Pt,P.init(e,t),e._zod.check=n=>{let r=n.value.split(`/`);try{if(r.length!==2)throw Error();let[e,t]=r;if(!t)throw Error();let n=Number(t);if(`${n}`!==t||n<0||n>128)throw Error();new URL(`http://[${e}]`)}catch{n.issues.push({code:`invalid_format`,format:`cidrv6`,input:n.value,inst:e,continue:!t.abort})}}});function Ln(e){if(e===``)return!0;if(/\s/.test(e)||e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}let Rn=/*@__PURE__*/ A(`$ZodBase64`,(e,t)=>{t.pattern??=Ft,P.init(e,t),e._zod.bag.contentEncoding=`base64`,e._zod.check=n=>{Ln(n.value)||n.issues.push({code:`invalid_format`,format:`base64`,input:n.value,inst:e,continue:!t.abort})}});function zn(e){if(!It.test(e))return!1;let t=e.replace(/[-_]/g,e=>e===`-`?`+`:`/`);return Ln(t.padEnd(Math.ceil(t.length/4)*4,`=`))}let Bn=/*@__PURE__*/ A(`$ZodBase64URL`,(e,t)=>{t.pattern??=It,P.init(e,t),e._zod.bag.contentEncoding=`base64url`,e._zod.check=n=>{zn(n.value)||n.issues.push({code:`invalid_format`,format:`base64url`,input:n.value,inst:e,continue:!t.abort})}}),Vn=/*@__PURE__*/ A(`$ZodE164`,(e,t)=>{t.pattern??=Rt,P.init(e,t)});function Hn(e,t=null){try{let n=e.split(`.`);if(n.length!==3)return!1;let[r]=n;if(!r)return!1;let i=JSON.parse(atob(r));return!(`typ`in i&&i?.typ!==`JWT`||!i.alg||t&&(!(`alg`in i)||i.alg!==t))}catch{return!1}}let Un=/*@__PURE__*/ A(`$ZodJWT`,(e,t)=>{P.init(e,t),e._zod.check=n=>{Hn(n.value,t.alg)||n.issues.push({code:`invalid_format`,format:`jwt`,input:n.value,inst:e,continue:!t.abort})}}),Wn=/*@__PURE__*/ A(`$ZodNumber`,(e,t)=>{N.init(e,t),e._zod.pattern=e._zod.bag.pattern??Kt,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}let i=n.value;if(typeof i==`number`&&!Number.isNaN(i)&&Number.isFinite(i))return n;let a=typeof i==`number`?Number.isNaN(i)?`NaN`:Number.isFinite(i)?void 0:`Infinity`:void 0;return n.issues.push({expected:`number`,code:`invalid_type`,input:i,inst:e,...a?{received:a}:{}}),n}}),Gn=/*@__PURE__*/ A(`$ZodNumberFormat`,(e,t)=>{nn.init(e,t),Wn.init(e,t)}),Kn=/*@__PURE__*/ A(`$ZodBoolean`,(e,t)=>{N.init(e,t),e._zod.pattern=qt,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=!!n.value}catch{}let i=n.value;return typeof i==`boolean`||n.issues.push({expected:`boolean`,code:`invalid_type`,input:i,inst:e}),n}}),qn=/*@__PURE__*/ A(`$ZodNull`,(e,t)=>{N.init(e,t),e._zod.pattern=Jt,e._zod.values=/* @__PURE__ */ new Set([null]),e._zod.parse=(t,n)=>{let r=t.value;return r===null||t.issues.push({expected:`null`,code:`invalid_type`,input:r,inst:e}),t}}),Jn=/*@__PURE__*/ A(`$ZodUnknown`,(e,t)=>{N.init(e,t),e._zod.parse=e=>e}),Yn=/*@__PURE__*/ A(`$ZodNever`,(e,t)=>{N.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:`never`,code:`invalid_type`,input:t.value,inst:e}),t)});function Xn(e,t,n){e.issues.length&&t.issues.push(...Xe(n,e.issues)),t.value[n]=e.value}let Zn=/*@__PURE__*/ A(`$ZodArray`,(e,t)=>{N.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!Array.isArray(i))return n.issues.push({expected:`array`,code:`invalid_type`,input:i,inst:e}),n;n.value=Array(i.length);let a=[];for(let e=0;e<i.length;e++){let o=i[e],s=t.element._zod.run({value:o,issues:[]},r);s instanceof Promise?a.push(s.then(t=>Xn(t,n,e))):Xn(s,n,e)}return a.length?Promise.all(a).then(()=>n):n}});function Qn(e,t,n,r,i,a){let o=n in r;if(e.issues.length){if(i&&a&&!o)return;t.issues.push(...Xe(n,e.issues))}!o&&!i?e.issues.length||t.issues.push({code:`invalid_type`,expected:`nonoptional`,input:void 0,path:[n]}):e.value===void 0?o&&(t.value[n]=void 0):t.value[n]=e.value}function $n(e){let t=Object.keys(e.shape);for(let n of t)if(!e.shape?.[n]?._zod?.traits?.has(`$ZodType`))throw Error(`Invalid element at key "${n}": expected a Zod schema`);let n=ze(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function er(e,t,n,r,i,a){let o=[],s=i.keySet,c=i.catchall._zod,l=c.def.type,u=c.optin===`optional`,d=c.optout===`optional`;for(let i in t){if(i===`__proto__`||s.has(i))continue;if(l===`never`){o.push(i);continue}let a=c.run({value:t[i],issues:[]},r);a instanceof Promise?e.push(a.then(e=>Qn(e,n,i,t,u,d))):Qn(a,n,i,t,u,d)}return o.length&&n.issues.push({code:`unrecognized_keys`,keys:o,input:t,inst:a}),e.length?Promise.all(e).then(()=>n):n}let tr=/*@__PURE__*/ A(`$ZodObject`,(e,t)=>{if(N.init(e,t),!Object.getOwnPropertyDescriptor(t,`shape`)?.get){let e=t.shape;Object.defineProperty(t,"shape",{get:()=>{let n={...e};return Object.defineProperty(t,"shape",{value:n}),n}})}let n=Se(()=>$n(t));j(e._zod,`propValues`,()=>{let e=t.shape,n={};for(let t in e){let r=e[t]._zod;if(r.values){n[t]??(n[t]=/* @__PURE__ */ new Set);for(let e of r.values)n[t].add(e)}}return n});let r=Me,i=t.catchall,a;e._zod.parse=(t,o)=>{a??=n.value;let s=t.value;if(!r(s))return t.issues.push({expected:`object`,code:`invalid_type`,input:s,inst:e}),t;t.value={};let c=[],l=a.shape;for(let e of a.keys){let n=l[e],r=n._zod.optin===`optional`,i=n._zod.optout===`optional`,a=n._zod.run({value:s[e],issues:[]},o);a instanceof Promise?c.push(a.then(n=>Qn(n,t,e,s,r,i))):Qn(a,t,e,s,r,i)}return i?er(c,s,t,o,n.value,e):c.length?Promise.all(c).then(()=>t):t}}),nr=/*@__PURE__*/ A(`$ZodObjectJIT`,(e,t)=>{tr.init(e,t);let n=e._zod.parse,r=Se(()=>$n(t)),i=e=>{let t=new hn([`shape`,`payload`,`ctx`]),n=r.value,i=e=>{let t=ke(e);return`shape[${t}]._zod.run({ value: input[${t}], issues: [] }, ctx)`};t.write(`const input = payload.value;`);let a=Object.create(null),o=0;for(let e of n.keys)a[e]=`key_${o++}`;t.write(`const newResult = {};`);for(let r of n.keys){let n=a[r],o=ke(r),s=e[r],c=s?._zod?.optin===`optional`,l=s?._zod?.optout===`optional`;t.write(`const ${n} = ${i(r)};`),c&&l?t.write(`
4
4
  if (${n}.issues.length) {
5
5
  if (${o} in input) {
6
6
  payload.issues = payload.issues.concat(${n}.issues.map(iss => ({
@@ -59,77 +59,82 @@ window.__ModuleLoader__.load({id:`@deepseek-ai/dsh-client-ui-chat`,factory:e=>{v
59
59
  }
60
60
  }
61
61
 
62
- `)}t.write(`payload.value = newResult;`),t.write(`return payload;`);let s=t.compile();return(t,n)=>s(e,t,n)},a,o=Ne,s=!ye.jitless,c=s&&Pe.value,l=t.catchall,u;e._zod.parse=(d,f)=>{u??=r.value;let p=d.value;return o(p)?s&&c&&f?.async===!1&&f.jitless!==!0?(a||=i(t.shape),d=a(d,f),l?tr([],p,d,f,u,e):d):n(d,f):(d.issues.push({expected:`object`,code:`invalid_type`,input:p,inst:e}),d)}});function ir(e,t,n,r){for(let n of e)if(n.issues.length===0)return t.value=n.value,t;let i=e.filter(e=>!Ye(e));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:`invalid_union`,input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>$e(e,r,be())))}),t)}let ar=/*@__PURE__*/ k(`$ZodUnion`,(e,t)=>{M.init(e,t),A(e._zod,`optin`,()=>t.options.some(e=>e._zod.optin===`optional`)?`optional`:void 0),A(e._zod,`optout`,()=>t.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),A(e._zod,`values`,()=>{if(t.options.every(e=>e._zod.values))return new Set(t.options.flatMap(e=>Array.from(e._zod.values)))}),A(e._zod,`pattern`,()=>{if(t.options.every(e=>e._zod.pattern)){let e=t.options.map(e=>e._zod.pattern);return RegExp(`^(${e.map(e=>Te(e.source)).join(`|`)})$`)}});let n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,i)=>{if(n)return n(r,i);let a=!1,o=[];for(let e of t.options){let t=e._zod.run({value:r.value,issues:[]},i);if(t instanceof Promise)o.push(t),a=!0;else{if(t.issues.length===0)return t;o.push(t)}}return a?Promise.all(o).then(t=>ir(t,r,e,i)):ir(o,r,e,i)}}),or=/*@__PURE__*/ k(`$ZodDiscriminatedUnion`,(e,t)=>{t.inclusive=!1,ar.init(e,t);let n=e._zod.parse;A(e._zod,`propValues`,()=>{let e={};for(let n of t.options){let r=n._zod.propValues;if(!r||Object.keys(r).length===0)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(n)}"`);for(let[t,n]of Object.entries(r)){e[t]||(e[t]=/* @__PURE__ */ new Set);for(let r of n)e[t].add(r)}}return e});let r=Ce(()=>{let e=t.options,n=/* @__PURE__ */ new Map;for(let r of e){let e=r._zod.propValues?.[t.discriminator];if(!e||e.size===0)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(r)}"`);for(let t of e){if(n.has(t))throw Error(`Duplicate discriminator value "${String(t)}"`);n.set(t,r)}}return n});e._zod.parse=(i,a)=>{let o=i.value;if(!Ne(o))return i.issues.push({code:`invalid_type`,expected:`object`,input:o,inst:e}),i;let s=r.value.get(o?.[t.discriminator]);return s?s._zod.run(i,a):t.unionFallback||a.direction===`backward`?n(i,a):(i.issues.push({code:`invalid_union`,errors:[],note:`No matching discriminator`,discriminator:t.discriminator,options:Array.from(r.value.keys()),input:o,path:[t.discriminator],inst:e}),i)}}),sr=/*@__PURE__*/ k(`$ZodIntersection`,(e,t)=>{M.init(e,t),e._zod.parse=(e,n)=>{let r=e.value,i=t.left._zod.run({value:r,issues:[]},n),a=t.right._zod.run({value:r,issues:[]},n);return i instanceof Promise||a instanceof Promise?Promise.all([i,a]).then(([t,n])=>lr(e,t,n)):lr(e,i,a)}});function cr(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(Fe(e)&&Fe(t)){let n=Object.keys(t),r=Object.keys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};for(let n of r){let r=cr(e[n],t[n]);if(!r.valid)return{valid:!1,mergeErrorPath:[n,...r.mergeErrorPath]};i[n]=r.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[r],o=cr(i,a);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function lr(e,t,n){let r=/* @__PURE__ */ new Map,i;for(let n of t.issues)if(n.code===`unrecognized_keys`){i??=n;for(let e of n.keys)r.has(e)||r.set(e,{}),r.get(e).l=!0}else e.issues.push(n);for(let t of n.issues)if(t.code===`unrecognized_keys`)for(let e of t.keys)r.has(e)||r.set(e,{}),r.get(e).r=!0;else e.issues.push(t);let a=[...r].filter(([,e])=>e.l&&e.r).map(([e])=>e);if(a.length&&i&&e.issues.push({...i,keys:a}),Ye(e))return e;let o=cr(t.value,n.value);if(!o.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(o.mergeErrorPath)}`);return e.value=o.data,e}let ur=/*@__PURE__*/ k(`$ZodTuple`,(e,t)=>{M.init(e,t);let n=t.items;e._zod.parse=(r,i)=>{let a=r.value;if(!Array.isArray(a))return r.issues.push({input:a,inst:e,expected:`tuple`,code:`invalid_type`}),r;r.value=[];let o=[],s=dr(n,`optin`),c=dr(n,`optout`);if(!t.rest){if(a.length<s)return r.issues.push({code:`too_small`,minimum:s,inclusive:!0,input:a,inst:e,origin:`array`}),r;a.length>n.length&&r.issues.push({code:`too_big`,maximum:n.length,inclusive:!0,input:a,inst:e,origin:`array`})}let l=Array(n.length);for(let e=0;e<n.length;e++){let t=n[e]._zod.run({value:a[e],issues:[]},i);t instanceof Promise?o.push(t.then(t=>{l[e]=t})):l[e]=t}if(t.rest){let e=n.length-1,s=a.slice(n.length);for(let n of s){e++;let a=t.rest._zod.run({value:n,issues:[]},i);a instanceof Promise?o.push(a.then(t=>fr(t,r,e))):fr(a,r,e)}}return o.length?Promise.all(o).then(()=>pr(l,r,n,a,c)):pr(l,r,n,a,c)}});function dr(e,t){for(let n=e.length-1;n>=0;n--)if(e[n]._zod[t]!==`optional`)return n+1;return 0}function fr(e,t,n){e.issues.length&&t.issues.push(...Ze(n,e.issues)),t.value[n]=e.value}function pr(e,t,n,r,i){for(let a=0;a<n.length;a++){let n=e[a],o=a<r.length;if(n.issues.length){if(!o&&a>=i){t.value.length=a;break}t.issues.push(...Ze(a,n.issues))}t.value[a]=n.value}for(let e=t.value.length-1;e>=r.length&&n[e]._zod.optout===`optional`&&t.value[e]===void 0;e--)t.value.length=e;return t}let mr=/*@__PURE__*/ k(`$ZodRecord`,(e,t)=>{M.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!Fe(i))return n.issues.push({expected:`record`,code:`invalid_type`,input:i,inst:e}),n;let a=[],o=t.keyType._zod.values;if(o){n.value={};let s=/* @__PURE__ */ new Set;for(let c of o)if(typeof c==`string`||typeof c==`number`||typeof c==`symbol`){s.add(typeof c==`number`?c.toString():c);let o=t.keyType._zod.run({value:c,issues:[]},r);if(o instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(o.issues.length){n.issues.push({code:`invalid_key`,origin:`record`,issues:o.issues.map(e=>$e(e,r,be())),input:c,path:[c],inst:e});continue}let l=o.value,u=t.valueType._zod.run({value:i[c],issues:[]},r);u instanceof Promise?a.push(u.then(e=>{e.issues.length&&n.issues.push(...Ze(c,e.issues)),n.value[l]=e.value})):(u.issues.length&&n.issues.push(...Ze(c,u.issues)),n.value[l]=u.value)}let c;for(let e in i)s.has(e)||(c??=[],c.push(e));c&&c.length>0&&n.issues.push({code:`unrecognized_keys`,input:i,inst:e,keys:c})}else{n.value={};for(let o of Reflect.ownKeys(i)){if(o===`__proto__`||!Object.prototype.propertyIsEnumerable.call(i,o))continue;let s=t.keyType._zod.run({value:o,issues:[]},r);if(s instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(typeof o==`string`&&qt.test(o)&&s.issues.length){let e=t.keyType._zod.run({value:Number(o),issues:[]},r);if(e instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);e.issues.length===0&&(s=e)}if(s.issues.length){t.mode===`loose`?n.value[o]=i[o]:n.issues.push({code:`invalid_key`,origin:`record`,issues:s.issues.map(e=>$e(e,r,be())),input:o,path:[o],inst:e});continue}let c=t.valueType._zod.run({value:i[o],issues:[]},r);c instanceof Promise?a.push(c.then(e=>{e.issues.length&&n.issues.push(...Ze(o,e.issues)),n.value[s.value]=e.value})):(c.issues.length&&n.issues.push(...Ze(o,c.issues)),n.value[s.value]=c.value)}}return a.length?Promise.all(a).then(()=>n):n}}),hr=/*@__PURE__*/ k(`$ZodEnum`,(e,t)=>{M.init(e,t);let n=xe(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=RegExp(`^(${n.filter(e=>Le.has(typeof e)).map(e=>typeof e==`string`?Re(e):e.toString()).join(`|`)})$`),e._zod.parse=(t,i)=>{let a=t.value;return r.has(a)||t.issues.push({code:`invalid_value`,values:n,input:a,inst:e}),t}}),gr=/*@__PURE__*/ k(`$ZodLiteral`,(e,t)=>{if(M.init(e,t),t.values.length===0)throw Error(`Cannot create literal schema with no valid values`);let n=new Set(t.values);e._zod.values=n,e._zod.pattern=RegExp(`^(${t.values.map(e=>typeof e==`string`?Re(e):e?Re(e.toString()):String(e)).join(`|`)})$`),e._zod.parse=(r,i)=>{let a=r.value;return n.has(a)||r.issues.push({code:`invalid_value`,values:t.values,input:a,inst:e}),r}}),_r=/*@__PURE__*/ k(`$ZodTransform`,(e,t)=>{M.init(e,t),e._zod.optin=`optional`,e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new ve(e.constructor.name);let i=t.transform(n.value,n);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(e=>(n.value=e,n.fallback=!0,n));if(i instanceof Promise)throw new _e;return n.value=i,n.fallback=!0,n}});function vr(e,t){return t===void 0&&(e.issues.length||e.fallback)?{issues:[],value:void 0}:e}let yr=/*@__PURE__*/ k(`$ZodOptional`,(e,t)=>{M.init(e,t),e._zod.optin=`optional`,e._zod.optout=`optional`,A(e._zod,`values`,()=>t.innerType._zod.values?/* @__PURE__ */ new Set([...t.innerType._zod.values,void 0]):void 0),A(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${Te(e.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if(t.innerType._zod.optin===`optional`){let r=e.value,i=t.innerType._zod.run(e,n);return i instanceof Promise?i.then(e=>vr(e,r)):vr(i,r)}return e.value===void 0?e:t.innerType._zod.run(e,n)}}),br=/*@__PURE__*/ k(`$ZodExactOptional`,(e,t)=>{yr.init(e,t),A(e._zod,`values`,()=>t.innerType._zod.values),A(e._zod,`pattern`,()=>t.innerType._zod.pattern),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),xr=/*@__PURE__*/ k(`$ZodNullable`,(e,t)=>{M.init(e,t),A(e._zod,`optin`,()=>t.innerType._zod.optin),A(e._zod,`optout`,()=>t.innerType._zod.optout),A(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${Te(e.source)}|null)$`):void 0}),A(e._zod,`values`,()=>t.innerType._zod.values?/* @__PURE__ */ new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>e.value===null?e:t.innerType._zod.run(e,n)}),Sr=/*@__PURE__*/ k(`$ZodDefault`,(e,t)=>{M.init(e,t),e._zod.optin=`optional`,A(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);if(e.value===void 0)return e.value=t.defaultValue,e;let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(e=>Cr(e,t)):Cr(r,t)}});function Cr(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}let wr=/*@__PURE__*/ k(`$ZodPrefault`,(e,t)=>{M.init(e,t),e._zod.optin=`optional`,A(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>(n.direction===`backward`||e.value===void 0&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))}),Tr=/*@__PURE__*/ k(`$ZodNonOptional`,(e,t)=>{M.init(e,t),A(e._zod,`values`,()=>{let e=t.innerType._zod.values;return e?new Set([...e].filter(e=>e!==void 0)):void 0}),e._zod.parse=(n,r)=>{let i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(t=>Er(t,e)):Er(i,e)}});function Er(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:`invalid_type`,expected:`nonoptional`,input:e.value,inst:t}),e}let Dr=/*@__PURE__*/ k(`$ZodCatch`,(e,t)=>{M.init(e,t),e._zod.optin=`optional`,A(e._zod,`optout`,()=>t.innerType._zod.optout),A(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(r=>(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>$e(e,n,be()))},input:e.value}),e.issues=[],e.fallback=!0),e)):(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>$e(e,n,be()))},input:e.value}),e.issues=[],e.fallback=!0),e)}}),Or=/*@__PURE__*/ k(`$ZodPipe`,(e,t)=>{M.init(e,t),A(e._zod,`values`,()=>t.in._zod.values),A(e._zod,`optin`,()=>t.in._zod.optin),A(e._zod,`optout`,()=>t.out._zod.optout),A(e._zod,`propValues`,()=>t.in._zod.propValues),e._zod.parse=(e,n)=>{if(n.direction===`backward`){let r=t.out._zod.run(e,n);return r instanceof Promise?r.then(e=>kr(e,t.in,n)):kr(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>kr(e,t.out,n)):kr(r,t.out,n)}});function kr(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues,fallback:e.fallback},n)}let Ar=/*@__PURE__*/ k(`$ZodReadonly`,(e,t)=>{M.init(e,t),A(e._zod,`propValues`,()=>t.innerType._zod.propValues),A(e._zod,`values`,()=>t.innerType._zod.values),A(e._zod,`optin`,()=>t.innerType?._zod?.optin),A(e._zod,`optout`,()=>t.innerType?._zod?.optout),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(jr):jr(r)}});function jr(e){return e.value=Object.freeze(e.value),e}let Mr=/*@__PURE__*/ k(`$ZodLazy`,(e,t)=>{M.init(e,t),A(e._zod,`innerType`,()=>{let e=t;return e._cachedInner||=t.getter(),e._cachedInner}),A(e._zod,`pattern`,()=>e._zod.innerType?._zod?.pattern),A(e._zod,`propValues`,()=>e._zod.innerType?._zod?.propValues),A(e._zod,`optin`,()=>e._zod.innerType?._zod?.optin??void 0),A(e._zod,`optout`,()=>e._zod.innerType?._zod?.optout??void 0),e._zod.parse=(t,n)=>e._zod.innerType._zod.run(t,n)}),Nr=/*@__PURE__*/ k(`$ZodCustom`,(e,t)=>{Qt.init(e,t),M.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{let r=n.value,i=t.fn(r);if(i instanceof Promise)return i.then(t=>Pr(t,n,r,e));Pr(i,n,r,e)}});function Pr(e,t,n,r){if(!e){let e={code:`custom`,input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(e.params=r._zod.def.params),t.issues.push(tt(e))}}var Fr,Ir=class{constructor(){this._map=/* @__PURE__ */ new WeakMap,this._idmap=/* @__PURE__ */ new Map}add(e,...t){let n=t[0];return this._map.set(e,n),n&&typeof n==`object`&&`id`in n&&this._idmap.set(n.id,e),this}clear(){return this._map=/* @__PURE__ */ new WeakMap,this._idmap=/* @__PURE__ */ new Map,this}remove(e){let t=this._map.get(e);return t&&typeof t==`object`&&`id`in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let n={...this.get(t)??{}};delete n.id;let r={...n,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}};function Lr(){return new Ir}(Fr=globalThis).__zod_globalRegistry??(Fr.__zod_globalRegistry=Lr());let Rr=globalThis.__zod_globalRegistry;// @__NO_SIDE_EFFECTS__
63
- function zr(e,t){return new e({type:`string`,...j(t)})}// @__NO_SIDE_EFFECTS__
64
- function Br(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...j(t)})}// @__NO_SIDE_EFFECTS__
65
- function Vr(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...j(t)})}// @__NO_SIDE_EFFECTS__
66
- function Hr(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...j(t)})}// @__NO_SIDE_EFFECTS__
67
- function Ur(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...j(t)})}// @__NO_SIDE_EFFECTS__
68
- function Wr(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...j(t)})}// @__NO_SIDE_EFFECTS__
69
- function Gr(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...j(t)})}// @__NO_SIDE_EFFECTS__
70
- function Kr(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...j(t)})}// @__NO_SIDE_EFFECTS__
71
- function qr(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...j(t)})}// @__NO_SIDE_EFFECTS__
72
- function Jr(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...j(t)})}// @__NO_SIDE_EFFECTS__
73
- function Yr(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...j(t)})}// @__NO_SIDE_EFFECTS__
74
- function Xr(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...j(t)})}// @__NO_SIDE_EFFECTS__
75
- function Zr(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...j(t)})}// @__NO_SIDE_EFFECTS__
76
- function Qr(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...j(t)})}// @__NO_SIDE_EFFECTS__
77
- function $r(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...j(t)})}// @__NO_SIDE_EFFECTS__
78
- function ei(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...j(t)})}// @__NO_SIDE_EFFECTS__
79
- function ti(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...j(t)})}// @__NO_SIDE_EFFECTS__
80
- function ni(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...j(t)})}// @__NO_SIDE_EFFECTS__
81
- function ri(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...j(t)})}// @__NO_SIDE_EFFECTS__
82
- function ii(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...j(t)})}// @__NO_SIDE_EFFECTS__
83
- function ai(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...j(t)})}// @__NO_SIDE_EFFECTS__
84
- function oi(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...j(t)})}// @__NO_SIDE_EFFECTS__
85
- function si(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...j(t)})}// @__NO_SIDE_EFFECTS__
86
- function ci(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...j(t)})}// @__NO_SIDE_EFFECTS__
87
- function li(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...j(t)})}// @__NO_SIDE_EFFECTS__
88
- function ui(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...j(t)})}// @__NO_SIDE_EFFECTS__
89
- function di(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...j(t)})}// @__NO_SIDE_EFFECTS__
90
- function fi(e,t){return new e({type:`number`,checks:[],...j(t)})}// @__NO_SIDE_EFFECTS__
91
- function pi(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...j(t)})}// @__NO_SIDE_EFFECTS__
92
- function mi(e,t){return new e({type:`boolean`,...j(t)})}// @__NO_SIDE_EFFECTS__
93
- function hi(e,t){return new e({type:`null`,...j(t)})}// @__NO_SIDE_EFFECTS__
94
- function gi(e){return new e({type:`unknown`})}// @__NO_SIDE_EFFECTS__
95
- function _i(e,t){return new e({type:`never`,...j(t)})}// @__NO_SIDE_EFFECTS__
96
- function vi(e,t){return new en({check:`less_than`,...j(t),value:e,inclusive:!1})}// @__NO_SIDE_EFFECTS__
97
- function yi(e,t){return new en({check:`less_than`,...j(t),value:e,inclusive:!0})}// @__NO_SIDE_EFFECTS__
98
- function bi(e,t){return new tn({check:`greater_than`,...j(t),value:e,inclusive:!1})}// @__NO_SIDE_EFFECTS__
99
- function xi(e,t){return new tn({check:`greater_than`,...j(t),value:e,inclusive:!0})}// @__NO_SIDE_EFFECTS__
100
- function Si(e,t){return new nn({check:`multiple_of`,...j(t),value:e})}// @__NO_SIDE_EFFECTS__
101
- function Ci(e,t){return new an({check:`max_length`,...j(t),maximum:e})}// @__NO_SIDE_EFFECTS__
102
- function wi(e,t){return new on({check:`min_length`,...j(t),minimum:e})}// @__NO_SIDE_EFFECTS__
103
- function Ti(e,t){return new sn({check:`length_equals`,...j(t),length:e})}// @__NO_SIDE_EFFECTS__
104
- function Ei(e,t){return new ln({check:`string_format`,format:`regex`,...j(t),pattern:e})}// @__NO_SIDE_EFFECTS__
105
- function Di(e){return new un({check:`string_format`,format:`lowercase`,...j(e)})}// @__NO_SIDE_EFFECTS__
106
- function Oi(e){return new dn({check:`string_format`,format:`uppercase`,...j(e)})}// @__NO_SIDE_EFFECTS__
107
- function ki(e,t){return new fn({check:`string_format`,format:`includes`,...j(t),includes:e})}// @__NO_SIDE_EFFECTS__
108
- function Ai(e,t){return new pn({check:`string_format`,format:`starts_with`,...j(t),prefix:e})}// @__NO_SIDE_EFFECTS__
109
- function ji(e,t){return new mn({check:`string_format`,format:`ends_with`,...j(t),suffix:e})}// @__NO_SIDE_EFFECTS__
110
- function Mi(e){return new hn({check:`overwrite`,tx:e})}// @__NO_SIDE_EFFECTS__
111
- function Ni(e){return/* @__PURE__ */ Mi(t=>t.normalize(e))}// @__NO_SIDE_EFFECTS__
112
- function Pi(){return/* @__PURE__ */ Mi(e=>e.trim())}// @__NO_SIDE_EFFECTS__
113
- function Fi(){return/* @__PURE__ */ Mi(e=>e.toLowerCase())}// @__NO_SIDE_EFFECTS__
114
- function Ii(){return/* @__PURE__ */ Mi(e=>e.toUpperCase())}// @__NO_SIDE_EFFECTS__
115
- function Li(){return/* @__PURE__ */ Mi(e=>je(e))}// @__NO_SIDE_EFFECTS__
116
- function Ri(e,t,n){return new e({type:`array`,element:t,...j(n)})}// @__NO_SIDE_EFFECTS__
117
- function zi(e,t,n){let r=j(n);return r.abort??=!0,new e({type:`custom`,check:`custom`,fn:t,...r})}// @__NO_SIDE_EFFECTS__
118
- function Bi(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...j(n)})}// @__NO_SIDE_EFFECTS__
119
- function Vi(e,t){let n=/* @__PURE__ */ Hi(t=>(t.addIssue=e=>{if(typeof e==`string`)t.issues.push(tt(e,t.value,n._zod.def));else{let r=e;r.fatal&&(r.continue=!1),r.code??=`custom`,r.input??=t.value,r.inst??=n,r.continue??=!n._zod.def.abort,t.issues.push(tt(r))}},e(t.value,t)),t);return n}// @__NO_SIDE_EFFECTS__
120
- function Hi(e,t){let n=new Qt({check:`custom`,...j(t)});return n._zod.check=e,n}function Ui(e){let t=e?.target??`draft-2020-12`;return t===`draft-4`&&(t=`draft-04`),t===`draft-7`&&(t=`draft-07`),{processors:e.processors??{},metadataRegistry:e?.metadata??Rr,target:t,unrepresentable:e?.unrepresentable??`throw`,override:e?.override??(()=>{}),io:e?.io??`output`,counter:0,seen:/* @__PURE__ */ new Map,cycles:e?.cycles??`ref`,reused:e?.reused??`inline`,external:e?.external??void 0}}function P(e,t,n={path:[],schemaPath:[]}){var r;let i=e._zod.def,a=t.seen.get(e);if(a)return a.count++,n.schemaPath.includes(e)&&(a.cycle=n.path),a.schema;let o={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,o);let s=e._zod.toJSONSchema?.();if(s)o.schema=s;else{let r={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,r);else{let n=o.schema,a=t.processors[i.type];if(!a)throw Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);a(e,t,n,r)}let a=e._zod.parent;a&&(o.ref||=a,P(a,t,r),t.seen.get(a).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&Object.assign(o.schema,c),t.io===`input`&&Ki(e)&&(delete o.schema.examples,delete o.schema.default),t.io===`input`&&`_prefault`in o.schema&&((r=o.schema).default??(r.default=o.schema._prefault)),delete o.schema._prefault,t.seen.get(e).schema}function Wi(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=/* @__PURE__ */ new Map;for(let t of e.seen.entries()){let n=e.metadataRegistry.get(t[0])?.id;if(n){let e=r.get(n);if(e&&e!==t[0])throw Error(`Duplicate schema id "${n}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(n,t[0])}}let i=t=>{let r=e.target===`draft-2020-12`?`$defs`:`definitions`;if(e.external){let n=e.external.registry.get(t[0])?.id,i=e.external.uri??(e=>e);if(n)return{ref:i(n)};let a=t[1].defId??t[1].schema.id??`schema${e.counter++}`;return t[1].defId=a,{defId:a,ref:`${i(`__shared`)}#/${r}/${a}`}}if(t[1]===n)return{ref:`#`};let i=`#/${r}/`,a=t[1].schema.id??`__schema${e.counter++}`;return{defId:a,ref:i+a}},a=e=>{if(e[1].schema.$ref)return;let t=e[1],{ref:n,defId:r}=i(e);t.def={...t.schema},r&&(t.defId=r);let a=t.schema;for(let e in a)delete a[e];a.$ref=n};if(e.cycles===`throw`)for(let t of e.seen.entries()){let e=t[1];if(e.cycle)throw Error(`Cycle detected: #/${e.cycle?.join(`/`)}/<root>
62
+ `)}t.write(`payload.value = newResult;`),t.write(`return payload;`);let s=t.compile();return(t,n)=>s(e,t,n)},a,o=Me,s=!ve.jitless,c=s&&Ne.value,l=t.catchall,u;e._zod.parse=(d,f)=>{u??=r.value;let p=d.value;return o(p)?s&&c&&f?.async===!1&&f.jitless!==!0?(a||=i(t.shape),d=a(d,f),l?er([],p,d,f,u,e):d):n(d,f):(d.issues.push({expected:`object`,code:`invalid_type`,input:p,inst:e}),d)}});function rr(e,t,n,r){for(let n of e)if(n.issues.length===0)return t.value=n.value,t;let i=e.filter(e=>!Je(e));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:`invalid_union`,input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>Qe(e,r,ye())))}),t)}let ir=/*@__PURE__*/ A(`$ZodUnion`,(e,t)=>{N.init(e,t),j(e._zod,`optin`,()=>t.options.some(e=>e._zod.optin===`optional`)?`optional`:void 0),j(e._zod,`optout`,()=>t.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),j(e._zod,`values`,()=>{if(t.options.every(e=>e._zod.values))return new Set(t.options.flatMap(e=>Array.from(e._zod.values)))}),j(e._zod,`pattern`,()=>{if(t.options.every(e=>e._zod.pattern)){let e=t.options.map(e=>e._zod.pattern);return RegExp(`^(${e.map(e=>we(e.source)).join(`|`)})$`)}});let n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,i)=>{if(n)return n(r,i);let a=!1,o=[];for(let e of t.options){let t=e._zod.run({value:r.value,issues:[]},i);if(t instanceof Promise)o.push(t),a=!0;else{if(t.issues.length===0)return t;o.push(t)}}return a?Promise.all(o).then(t=>rr(t,r,e,i)):rr(o,r,e,i)}}),ar=/*@__PURE__*/ A(`$ZodDiscriminatedUnion`,(e,t)=>{t.inclusive=!1,ir.init(e,t);let n=e._zod.parse;j(e._zod,`propValues`,()=>{let e={};for(let n of t.options){let r=n._zod.propValues;if(!r||Object.keys(r).length===0)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(n)}"`);for(let[t,n]of Object.entries(r)){e[t]||(e[t]=/* @__PURE__ */ new Set);for(let r of n)e[t].add(r)}}return e});let r=Se(()=>{let e=t.options,n=/* @__PURE__ */ new Map;for(let r of e){let e=r._zod.propValues?.[t.discriminator];if(!e||e.size===0)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(r)}"`);for(let t of e){if(n.has(t))throw Error(`Duplicate discriminator value "${String(t)}"`);n.set(t,r)}}return n});e._zod.parse=(i,a)=>{let o=i.value;if(!Me(o))return i.issues.push({code:`invalid_type`,expected:`object`,input:o,inst:e}),i;let s=r.value.get(o?.[t.discriminator]);return s?s._zod.run(i,a):t.unionFallback||a.direction===`backward`?n(i,a):(i.issues.push({code:`invalid_union`,errors:[],note:`No matching discriminator`,discriminator:t.discriminator,options:Array.from(r.value.keys()),input:o,path:[t.discriminator],inst:e}),i)}}),or=/*@__PURE__*/ A(`$ZodIntersection`,(e,t)=>{N.init(e,t),e._zod.parse=(e,n)=>{let r=e.value,i=t.left._zod.run({value:r,issues:[]},n),a=t.right._zod.run({value:r,issues:[]},n);return i instanceof Promise||a instanceof Promise?Promise.all([i,a]).then(([t,n])=>cr(e,t,n)):cr(e,i,a)}});function sr(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(Pe(e)&&Pe(t)){let n=Object.keys(t),r=Object.keys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};for(let n of r){let r=sr(e[n],t[n]);if(!r.valid)return{valid:!1,mergeErrorPath:[n,...r.mergeErrorPath]};i[n]=r.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[r],o=sr(i,a);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function cr(e,t,n){let r=/* @__PURE__ */ new Map,i;for(let n of t.issues)if(n.code===`unrecognized_keys`){i??=n;for(let e of n.keys)r.has(e)||r.set(e,{}),r.get(e).l=!0}else e.issues.push(n);for(let t of n.issues)if(t.code===`unrecognized_keys`)for(let e of t.keys)r.has(e)||r.set(e,{}),r.get(e).r=!0;else e.issues.push(t);let a=[...r].filter(([,e])=>e.l&&e.r).map(([e])=>e);if(a.length&&i&&e.issues.push({...i,keys:a}),Je(e))return e;let o=sr(t.value,n.value);if(!o.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(o.mergeErrorPath)}`);return e.value=o.data,e}let lr=/*@__PURE__*/ A(`$ZodTuple`,(e,t)=>{N.init(e,t);let n=t.items;e._zod.parse=(r,i)=>{let a=r.value;if(!Array.isArray(a))return r.issues.push({input:a,inst:e,expected:`tuple`,code:`invalid_type`}),r;r.value=[];let o=[],s=ur(n,`optin`),c=ur(n,`optout`);if(!t.rest){if(a.length<s)return r.issues.push({code:`too_small`,minimum:s,inclusive:!0,input:a,inst:e,origin:`array`}),r;a.length>n.length&&r.issues.push({code:`too_big`,maximum:n.length,inclusive:!0,input:a,inst:e,origin:`array`})}let l=Array(n.length);for(let e=0;e<n.length;e++){let t=n[e]._zod.run({value:a[e],issues:[]},i);t instanceof Promise?o.push(t.then(t=>{l[e]=t})):l[e]=t}if(t.rest){let e=n.length-1,s=a.slice(n.length);for(let n of s){e++;let a=t.rest._zod.run({value:n,issues:[]},i);a instanceof Promise?o.push(a.then(t=>dr(t,r,e))):dr(a,r,e)}}return o.length?Promise.all(o).then(()=>fr(l,r,n,a,c)):fr(l,r,n,a,c)}});function ur(e,t){for(let n=e.length-1;n>=0;n--)if(e[n]._zod[t]!==`optional`)return n+1;return 0}function dr(e,t,n){e.issues.length&&t.issues.push(...Xe(n,e.issues)),t.value[n]=e.value}function fr(e,t,n,r,i){for(let a=0;a<n.length;a++){let n=e[a],o=a<r.length;if(n.issues.length){if(!o&&a>=i){t.value.length=a;break}t.issues.push(...Xe(a,n.issues))}t.value[a]=n.value}for(let e=t.value.length-1;e>=r.length&&n[e]._zod.optout===`optional`&&t.value[e]===void 0;e--)t.value.length=e;return t}let pr=/*@__PURE__*/ A(`$ZodRecord`,(e,t)=>{N.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!Pe(i))return n.issues.push({expected:`record`,code:`invalid_type`,input:i,inst:e}),n;let a=[],o=t.keyType._zod.values;if(o){n.value={};let s=/* @__PURE__ */ new Set;for(let c of o)if(typeof c==`string`||typeof c==`number`||typeof c==`symbol`){s.add(typeof c==`number`?c.toString():c);let o=t.keyType._zod.run({value:c,issues:[]},r);if(o instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(o.issues.length){n.issues.push({code:`invalid_key`,origin:`record`,issues:o.issues.map(e=>Qe(e,r,ye())),input:c,path:[c],inst:e});continue}let l=o.value,u=t.valueType._zod.run({value:i[c],issues:[]},r);u instanceof Promise?a.push(u.then(e=>{e.issues.length&&n.issues.push(...Xe(c,e.issues)),n.value[l]=e.value})):(u.issues.length&&n.issues.push(...Xe(c,u.issues)),n.value[l]=u.value)}let c;for(let e in i)s.has(e)||(c??=[],c.push(e));c&&c.length>0&&n.issues.push({code:`unrecognized_keys`,input:i,inst:e,keys:c})}else{n.value={};for(let o of Reflect.ownKeys(i)){if(o===`__proto__`||!Object.prototype.propertyIsEnumerable.call(i,o))continue;let s=t.keyType._zod.run({value:o,issues:[]},r);if(s instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(typeof o==`string`&&Kt.test(o)&&s.issues.length){let e=t.keyType._zod.run({value:Number(o),issues:[]},r);if(e instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);e.issues.length===0&&(s=e)}if(s.issues.length){t.mode===`loose`?n.value[o]=i[o]:n.issues.push({code:`invalid_key`,origin:`record`,issues:s.issues.map(e=>Qe(e,r,ye())),input:o,path:[o],inst:e});continue}let c=t.valueType._zod.run({value:i[o],issues:[]},r);c instanceof Promise?a.push(c.then(e=>{e.issues.length&&n.issues.push(...Xe(o,e.issues)),n.value[s.value]=e.value})):(c.issues.length&&n.issues.push(...Xe(o,c.issues)),n.value[s.value]=c.value)}}return a.length?Promise.all(a).then(()=>n):n}}),mr=/*@__PURE__*/ A(`$ZodEnum`,(e,t)=>{N.init(e,t);let n=be(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=RegExp(`^(${n.filter(e=>Ie.has(typeof e)).map(e=>typeof e==`string`?Le(e):e.toString()).join(`|`)})$`),e._zod.parse=(t,i)=>{let a=t.value;return r.has(a)||t.issues.push({code:`invalid_value`,values:n,input:a,inst:e}),t}}),hr=/*@__PURE__*/ A(`$ZodLiteral`,(e,t)=>{if(N.init(e,t),t.values.length===0)throw Error(`Cannot create literal schema with no valid values`);let n=new Set(t.values);e._zod.values=n,e._zod.pattern=RegExp(`^(${t.values.map(e=>typeof e==`string`?Le(e):e?Le(e.toString()):String(e)).join(`|`)})$`),e._zod.parse=(r,i)=>{let a=r.value;return n.has(a)||r.issues.push({code:`invalid_value`,values:t.values,input:a,inst:e}),r}}),gr=/*@__PURE__*/ A(`$ZodTransform`,(e,t)=>{N.init(e,t),e._zod.optin=`optional`,e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new _e(e.constructor.name);let i=t.transform(n.value,n);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(e=>(n.value=e,n.fallback=!0,n));if(i instanceof Promise)throw new ge;return n.value=i,n.fallback=!0,n}});function _r(e,t){return t===void 0&&(e.issues.length||e.fallback)?{issues:[],value:void 0}:e}let vr=/*@__PURE__*/ A(`$ZodOptional`,(e,t)=>{N.init(e,t),e._zod.optin=`optional`,e._zod.optout=`optional`,j(e._zod,`values`,()=>t.innerType._zod.values?/* @__PURE__ */ new Set([...t.innerType._zod.values,void 0]):void 0),j(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${we(e.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if(t.innerType._zod.optin===`optional`){let r=e.value,i=t.innerType._zod.run(e,n);return i instanceof Promise?i.then(e=>_r(e,r)):_r(i,r)}return e.value===void 0?e:t.innerType._zod.run(e,n)}}),yr=/*@__PURE__*/ A(`$ZodExactOptional`,(e,t)=>{vr.init(e,t),j(e._zod,`values`,()=>t.innerType._zod.values),j(e._zod,`pattern`,()=>t.innerType._zod.pattern),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),br=/*@__PURE__*/ A(`$ZodNullable`,(e,t)=>{N.init(e,t),j(e._zod,`optin`,()=>t.innerType._zod.optin),j(e._zod,`optout`,()=>t.innerType._zod.optout),j(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${we(e.source)}|null)$`):void 0}),j(e._zod,`values`,()=>t.innerType._zod.values?/* @__PURE__ */ new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>e.value===null?e:t.innerType._zod.run(e,n)}),xr=/*@__PURE__*/ A(`$ZodDefault`,(e,t)=>{N.init(e,t),e._zod.optin=`optional`,j(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);if(e.value===void 0)return e.value=t.defaultValue,e;let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(e=>Sr(e,t)):Sr(r,t)}});function Sr(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}let Cr=/*@__PURE__*/ A(`$ZodPrefault`,(e,t)=>{N.init(e,t),e._zod.optin=`optional`,j(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>(n.direction===`backward`||e.value===void 0&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))}),wr=/*@__PURE__*/ A(`$ZodNonOptional`,(e,t)=>{N.init(e,t),j(e._zod,`values`,()=>{let e=t.innerType._zod.values;return e?new Set([...e].filter(e=>e!==void 0)):void 0}),e._zod.parse=(n,r)=>{let i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(t=>Tr(t,e)):Tr(i,e)}});function Tr(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:`invalid_type`,expected:`nonoptional`,input:e.value,inst:t}),e}let Er=/*@__PURE__*/ A(`$ZodCatch`,(e,t)=>{N.init(e,t),e._zod.optin=`optional`,j(e._zod,`optout`,()=>t.innerType._zod.optout),j(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(r=>(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>Qe(e,n,ye()))},input:e.value}),e.issues=[],e.fallback=!0),e)):(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>Qe(e,n,ye()))},input:e.value}),e.issues=[],e.fallback=!0),e)}}),Dr=/*@__PURE__*/ A(`$ZodPipe`,(e,t)=>{N.init(e,t),j(e._zod,`values`,()=>t.in._zod.values),j(e._zod,`optin`,()=>t.in._zod.optin),j(e._zod,`optout`,()=>t.out._zod.optout),j(e._zod,`propValues`,()=>t.in._zod.propValues),e._zod.parse=(e,n)=>{if(n.direction===`backward`){let r=t.out._zod.run(e,n);return r instanceof Promise?r.then(e=>Or(e,t.in,n)):Or(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>Or(e,t.out,n)):Or(r,t.out,n)}});function Or(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues,fallback:e.fallback},n)}let kr=/*@__PURE__*/ A(`$ZodReadonly`,(e,t)=>{N.init(e,t),j(e._zod,`propValues`,()=>t.innerType._zod.propValues),j(e._zod,`values`,()=>t.innerType._zod.values),j(e._zod,`optin`,()=>t.innerType?._zod?.optin),j(e._zod,`optout`,()=>t.innerType?._zod?.optout),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(Ar):Ar(r)}});function Ar(e){return e.value=Object.freeze(e.value),e}let jr=/*@__PURE__*/ A(`$ZodLazy`,(e,t)=>{N.init(e,t),j(e._zod,`innerType`,()=>{let e=t;return e._cachedInner||=t.getter(),e._cachedInner}),j(e._zod,`pattern`,()=>e._zod.innerType?._zod?.pattern),j(e._zod,`propValues`,()=>e._zod.innerType?._zod?.propValues),j(e._zod,`optin`,()=>e._zod.innerType?._zod?.optin??void 0),j(e._zod,`optout`,()=>e._zod.innerType?._zod?.optout??void 0),e._zod.parse=(t,n)=>e._zod.innerType._zod.run(t,n)}),Mr=/*@__PURE__*/ A(`$ZodCustom`,(e,t)=>{Zt.init(e,t),N.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{let r=n.value,i=t.fn(r);if(i instanceof Promise)return i.then(t=>Nr(t,n,r,e));Nr(i,n,r,e)}});function Nr(e,t,n,r){if(!e){let e={code:`custom`,input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(e.params=r._zod.def.params),t.issues.push(et(e))}}var Pr,Fr=class{constructor(){this._map=/* @__PURE__ */ new WeakMap,this._idmap=/* @__PURE__ */ new Map}add(e,...t){let n=t[0];return this._map.set(e,n),n&&typeof n==`object`&&`id`in n&&this._idmap.set(n.id,e),this}clear(){return this._map=/* @__PURE__ */ new WeakMap,this._idmap=/* @__PURE__ */ new Map,this}remove(e){let t=this._map.get(e);return t&&typeof t==`object`&&`id`in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let n={...this.get(t)??{}};delete n.id;let r={...n,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}};function Ir(){return new Fr}(Pr=globalThis).__zod_globalRegistry??(Pr.__zod_globalRegistry=Ir());let Lr=globalThis.__zod_globalRegistry;// @__NO_SIDE_EFFECTS__
63
+ function Rr(e,t){return new e({type:`string`,...M(t)})}// @__NO_SIDE_EFFECTS__
64
+ function zr(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...M(t)})}// @__NO_SIDE_EFFECTS__
65
+ function Br(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...M(t)})}// @__NO_SIDE_EFFECTS__
66
+ function Vr(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...M(t)})}// @__NO_SIDE_EFFECTS__
67
+ function Hr(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...M(t)})}// @__NO_SIDE_EFFECTS__
68
+ function Ur(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...M(t)})}// @__NO_SIDE_EFFECTS__
69
+ function Wr(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...M(t)})}// @__NO_SIDE_EFFECTS__
70
+ function Gr(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...M(t)})}// @__NO_SIDE_EFFECTS__
71
+ function Kr(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...M(t)})}// @__NO_SIDE_EFFECTS__
72
+ function qr(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...M(t)})}// @__NO_SIDE_EFFECTS__
73
+ function Jr(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...M(t)})}// @__NO_SIDE_EFFECTS__
74
+ function Yr(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...M(t)})}// @__NO_SIDE_EFFECTS__
75
+ function Xr(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...M(t)})}// @__NO_SIDE_EFFECTS__
76
+ function Zr(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...M(t)})}// @__NO_SIDE_EFFECTS__
77
+ function Qr(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...M(t)})}// @__NO_SIDE_EFFECTS__
78
+ function $r(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...M(t)})}// @__NO_SIDE_EFFECTS__
79
+ function ei(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...M(t)})}// @__NO_SIDE_EFFECTS__
80
+ function ti(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...M(t)})}// @__NO_SIDE_EFFECTS__
81
+ function ni(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...M(t)})}// @__NO_SIDE_EFFECTS__
82
+ function ri(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...M(t)})}// @__NO_SIDE_EFFECTS__
83
+ function ii(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...M(t)})}// @__NO_SIDE_EFFECTS__
84
+ function ai(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...M(t)})}// @__NO_SIDE_EFFECTS__
85
+ function oi(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...M(t)})}// @__NO_SIDE_EFFECTS__
86
+ function si(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...M(t)})}// @__NO_SIDE_EFFECTS__
87
+ function ci(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...M(t)})}// @__NO_SIDE_EFFECTS__
88
+ function li(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...M(t)})}// @__NO_SIDE_EFFECTS__
89
+ function ui(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...M(t)})}// @__NO_SIDE_EFFECTS__
90
+ function di(e,t){return new e({type:`number`,checks:[],...M(t)})}// @__NO_SIDE_EFFECTS__
91
+ function fi(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...M(t)})}// @__NO_SIDE_EFFECTS__
92
+ function pi(e,t){return new e({type:`boolean`,...M(t)})}// @__NO_SIDE_EFFECTS__
93
+ function mi(e,t){return new e({type:`null`,...M(t)})}// @__NO_SIDE_EFFECTS__
94
+ function hi(e){return new e({type:`unknown`})}// @__NO_SIDE_EFFECTS__
95
+ function gi(e,t){return new e({type:`never`,...M(t)})}// @__NO_SIDE_EFFECTS__
96
+ function _i(e,t){return new $t({check:`less_than`,...M(t),value:e,inclusive:!1})}// @__NO_SIDE_EFFECTS__
97
+ function vi(e,t){return new $t({check:`less_than`,...M(t),value:e,inclusive:!0})}// @__NO_SIDE_EFFECTS__
98
+ function yi(e,t){return new en({check:`greater_than`,...M(t),value:e,inclusive:!1})}// @__NO_SIDE_EFFECTS__
99
+ function bi(e,t){return new en({check:`greater_than`,...M(t),value:e,inclusive:!0})}// @__NO_SIDE_EFFECTS__
100
+ function xi(e,t){return new tn({check:`multiple_of`,...M(t),value:e})}// @__NO_SIDE_EFFECTS__
101
+ function Si(e,t){return new rn({check:`max_length`,...M(t),maximum:e})}// @__NO_SIDE_EFFECTS__
102
+ function Ci(e,t){return new an({check:`min_length`,...M(t),minimum:e})}// @__NO_SIDE_EFFECTS__
103
+ function wi(e,t){return new on({check:`length_equals`,...M(t),length:e})}// @__NO_SIDE_EFFECTS__
104
+ function Ti(e,t){return new cn({check:`string_format`,format:`regex`,...M(t),pattern:e})}// @__NO_SIDE_EFFECTS__
105
+ function Ei(e){return new ln({check:`string_format`,format:`lowercase`,...M(e)})}// @__NO_SIDE_EFFECTS__
106
+ function Di(e){return new un({check:`string_format`,format:`uppercase`,...M(e)})}// @__NO_SIDE_EFFECTS__
107
+ function Oi(e,t){return new dn({check:`string_format`,format:`includes`,...M(t),includes:e})}// @__NO_SIDE_EFFECTS__
108
+ function ki(e,t){return new fn({check:`string_format`,format:`starts_with`,...M(t),prefix:e})}// @__NO_SIDE_EFFECTS__
109
+ function Ai(e,t){return new pn({check:`string_format`,format:`ends_with`,...M(t),suffix:e})}// @__NO_SIDE_EFFECTS__
110
+ function ji(e){return new mn({check:`overwrite`,tx:e})}// @__NO_SIDE_EFFECTS__
111
+ function Mi(e){return/* @__PURE__ */ ji(t=>t.normalize(e))}// @__NO_SIDE_EFFECTS__
112
+ function Ni(){return/* @__PURE__ */ ji(e=>e.trim())}// @__NO_SIDE_EFFECTS__
113
+ function Pi(){return/* @__PURE__ */ ji(e=>e.toLowerCase())}// @__NO_SIDE_EFFECTS__
114
+ function Fi(){return/* @__PURE__ */ ji(e=>e.toUpperCase())}// @__NO_SIDE_EFFECTS__
115
+ function Ii(){return/* @__PURE__ */ ji(e=>Ae(e))}// @__NO_SIDE_EFFECTS__
116
+ function Li(e,t,n){return new e({type:`array`,element:t,...M(n)})}// @__NO_SIDE_EFFECTS__
117
+ function Ri(e,t,n){let r=M(n);return r.abort??=!0,new e({type:`custom`,check:`custom`,fn:t,...r})}// @__NO_SIDE_EFFECTS__
118
+ function zi(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...M(n)})}// @__NO_SIDE_EFFECTS__
119
+ function Bi(e,t){let n=/* @__PURE__ */ Vi(t=>(t.addIssue=e=>{if(typeof e==`string`)t.issues.push(et(e,t.value,n._zod.def));else{let r=e;r.fatal&&(r.continue=!1),r.code??=`custom`,r.input??=t.value,r.inst??=n,r.continue??=!n._zod.def.abort,t.issues.push(et(r))}},e(t.value,t)),t);return n}// @__NO_SIDE_EFFECTS__
120
+ function Vi(e,t){let n=new Zt({check:`custom`,...M(t)});return n._zod.check=e,n}function Hi(e){let t=e?.target??`draft-2020-12`;return t===`draft-4`&&(t=`draft-04`),t===`draft-7`&&(t=`draft-07`),{processors:e.processors??{},metadataRegistry:e?.metadata??Lr,target:t,unrepresentable:e?.unrepresentable??`throw`,override:e?.override??(()=>{}),io:e?.io??`output`,counter:0,seen:/* @__PURE__ */ new Map,cycles:e?.cycles??`ref`,reused:e?.reused??`inline`,external:e?.external??void 0}}function F(e,t,n={path:[],schemaPath:[]}){var r;let i=e._zod.def,a=t.seen.get(e);if(a)return a.count++,n.schemaPath.includes(e)&&(a.cycle=n.path),a.schema;let o={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,o);let s=e._zod.toJSONSchema?.();if(s)o.schema=s;else{let r={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,r);else{let n=o.schema,a=t.processors[i.type];if(!a)throw Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);a(e,t,n,r)}let a=e._zod.parent;a&&(o.ref||=a,F(a,t,r),t.seen.get(a).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&Object.assign(o.schema,c),t.io===`input`&&Gi(e)&&(delete o.schema.examples,delete o.schema.default),t.io===`input`&&`_prefault`in o.schema&&((r=o.schema).default??(r.default=o.schema._prefault)),delete o.schema._prefault,t.seen.get(e).schema}function Ui(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=/* @__PURE__ */ new Map;for(let t of e.seen.entries()){let n=e.metadataRegistry.get(t[0])?.id;if(n){let e=r.get(n);if(e&&e!==t[0])throw Error(`Duplicate schema id "${n}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(n,t[0])}}let i=t=>{let r=e.target===`draft-2020-12`?`$defs`:`definitions`;if(e.external){let n=e.external.registry.get(t[0])?.id,i=e.external.uri??(e=>e);if(n)return{ref:i(n)};let a=t[1].defId??t[1].schema.id??`schema${e.counter++}`;return t[1].defId=a,{defId:a,ref:`${i(`__shared`)}#/${r}/${a}`}}if(t[1]===n)return{ref:`#`};let i=`#/${r}/`,a=t[1].schema.id??`__schema${e.counter++}`;return{defId:a,ref:i+a}},a=e=>{if(e[1].schema.$ref)return;let t=e[1],{ref:n,defId:r}=i(e);t.def={...t.schema},r&&(t.defId=r);let a=t.schema;for(let e in a)delete a[e];a.$ref=n};if(e.cycles===`throw`)for(let t of e.seen.entries()){let e=t[1];if(e.cycle)throw Error(`Cycle detected: #/${e.cycle?.join(`/`)}/<root>
121
121
 
122
- Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let n of e.seen.entries()){let r=n[1];if(t===n[0])a(n);else{if(e.external){let r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){a(n);continue}}(e.metadataRegistry.get(n[0])?.id||r.cycle||r.count>1&&e.reused===`ref`)&&a(n)}}}function Gi(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=t=>{let n=e.seen.get(t);if(n.ref===null)return;let i=n.def??n.schema,a={...i},o=n.ref;if(n.ref=null,o){r(o);let n=e.seen.get(o),s=n.schema;if(s.$ref&&(e.target===`draft-07`||e.target===`draft-04`||e.target===`openapi-3.0`)?(i.allOf=i.allOf??[],i.allOf.push(s)):Object.assign(i,s),Object.assign(i,a),t._zod.parent===o)for(let e in i)e!==`$ref`&&e!==`allOf`&&(e in a||delete i[e]);if(s.$ref&&n.def)for(let e in i)e!==`$ref`&&e!==`allOf`&&e in n.def&&JSON.stringify(i[e])===JSON.stringify(n.def[e])&&delete i[e]}let s=t._zod.parent;if(s&&s!==o){r(s);let t=e.seen.get(s);if(t?.schema.$ref&&(i.$ref=t.schema.$ref,t.def))for(let e in i)e!==`$ref`&&e!==`allOf`&&e in t.def&&JSON.stringify(i[e])===JSON.stringify(t.def[e])&&delete i[e]}e.override({zodSchema:t,jsonSchema:i,path:n.path??[]})};for(let t of[...e.seen.entries()].reverse())r(t[0]);let i={};if(e.target===`draft-2020-12`?i.$schema=`https://json-schema.org/draft/2020-12/schema`:e.target===`draft-07`?i.$schema=`http://json-schema.org/draft-07/schema#`:e.target===`draft-04`?i.$schema=`http://json-schema.org/draft-04/schema#`:e.target,e.external?.uri){let n=e.external.registry.get(t)?.id;if(!n)throw Error("Schema is missing an `id` property");i.$id=e.external.uri(n)}Object.assign(i,n.def??n.schema);let a=e.metadataRegistry.get(t)?.id;a!==void 0&&i.id===a&&delete i.id;let o=e.external?.defs??{};for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(e.def.id===e.defId&&delete e.def.id,o[e.defId]=e.def)}e.external||Object.keys(o).length>0&&(e.target===`draft-2020-12`?i.$defs=o:i.definitions=o);try{let n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,"~standard",{value:{...t[`~standard`],jsonSchema:{input:Ji(t,`input`,e.processors),output:Ji(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function Ki(e,t){let n=t??{seen:/* @__PURE__ */ new Set};if(n.seen.has(e))return!1;n.seen.add(e);let r=e._zod.def;if(r.type===`transform`)return!0;if(r.type===`array`)return Ki(r.element,n);if(r.type===`set`)return Ki(r.valueType,n);if(r.type===`lazy`)return Ki(r.getter(),n);if(r.type===`promise`||r.type===`optional`||r.type===`nonoptional`||r.type===`nullable`||r.type===`readonly`||r.type==="default"||r.type===`prefault`)return Ki(r.innerType,n);if(r.type===`intersection`)return Ki(r.left,n)||Ki(r.right,n);if(r.type===`record`||r.type===`map`)return Ki(r.keyType,n)||Ki(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:Ki(r.in,n)||Ki(r.out,n);if(r.type===`object`){for(let e in r.shape)if(Ki(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(Ki(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(Ki(e,n))return!0;return!!(r.rest&&Ki(r.rest,n))}return!1}let qi=(e,t={})=>n=>{let r=Ui({...n,processors:t});return P(e,r),Wi(r,e),Gi(r,e)},Ji=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=Ui({...i??{},target:a,io:t,processors:n});return P(e,o),Wi(o,e),Gi(o,e)},Yi={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},Xi=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l}=e._zod.bag;if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=Yi[s]??s,i.format===``&&delete i.format,s===`time`&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let e=[...c];e.length===1?i.pattern=e[0].source:e.length>1&&(i.allOf=[...e.map(e=>({...t.target===`draft-07`||t.target===`draft-04`||t.target===`openapi-3.0`?{type:`string`}:{},pattern:e.source}))])}},Zi=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,format:s,multipleOf:c,exclusiveMaximum:l,exclusiveMinimum:u}=e._zod.bag;i.type=typeof s==`string`&&s.includes(`int`)?`integer`:`number`;let d=typeof u==`number`&&u>=(a??-1/0),f=typeof l==`number`&&l<=(o??1/0),p=t.target===`draft-04`||t.target===`openapi-3.0`;d?p?(i.minimum=u,i.exclusiveMinimum=!0):i.exclusiveMinimum=u:typeof a==`number`&&(i.minimum=a),f?p?(i.maximum=l,i.exclusiveMaximum=!0):i.exclusiveMaximum=l:typeof o==`number`&&(i.maximum=o),typeof c==`number`&&(i.multipleOf=c)},Qi=(e,t,n,r)=>{n.type=`boolean`},$i=(e,t,n,r)=>{t.target===`openapi-3.0`?(n.type=`string`,n.nullable=!0,n.enum=[null]):n.type=`null`},ea=(e,t,n,r)=>{n.not={}},ta=(e,t,n,r)=>{let i=e._zod.def,a=xe(i.entries);a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a},na=(e,t,n,r)=>{let i=e._zod.def,a=[];for(let e of i.values)if(e===void 0){if(t.unrepresentable===`throw`)throw Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof e==`bigint`){if(t.unrepresentable===`throw`)throw Error(`BigInt literals cannot be represented in JSON Schema`);a.push(Number(e))}else a.push(e);if(a.length!==0){if(a.length===1){let e=a[0];n.type=e===null?`null`:typeof e,t.target===`draft-04`||t.target===`openapi-3.0`?n.enum=[e]:n.const=e}else a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),a.every(e=>typeof e==`boolean`)&&(n.type=`boolean`),a.every(e=>e===null)&&(n.type=`null`),n.enum=a}},ra=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Custom types cannot be represented in JSON Schema`)},ia=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Transforms cannot be represented in JSON Schema`)},aa=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=e._zod.bag;typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=P(a.element,t,{...r,path:[...r.path,`items`]})},oa=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`,i.properties={};let o=a.shape;for(let e in o)i.properties[e]=P(o[e],t,{...r,path:[...r.path,`properties`,e]});let s=new Set(Object.keys(o)),c=new Set([...s].filter(e=>{let n=a.shape[e]._zod;return t.io===`input`?n.optin===void 0:n.optout===void 0}));c.size>0&&(i.required=Array.from(c)),a.catchall?._zod.def.type===`never`?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=P(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},sa=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>P(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},ca=(e,t,n,r)=>{let i=e._zod.def,a=P(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=P(i.right,t,{...r,path:[...r.path,`allOf`,1]}),s=e=>`allOf`in e&&Object.keys(e).length===1;n.allOf=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]]},la=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`array`;let o=t.target===`draft-2020-12`?`prefixItems`:`items`,s=t.target===`draft-2020-12`||t.target===`openapi-3.0`?`items`:`additionalItems`,c=a.items.map((e,n)=>P(e,t,{...r,path:[...r.path,o,n]})),l=a.rest?P(a.rest,t,{...r,path:[...r.path,s,...t.target===`openapi-3.0`?[a.items.length]:[]]}):null;t.target===`draft-2020-12`?(i.prefixItems=c,l&&(i.items=l)):t.target===`openapi-3.0`?(i.items={anyOf:c},l&&i.items.anyOf.push(l),i.minItems=c.length,l||(i.maxItems=c.length)):(i.items=c,l&&(i.additionalItems=l));let{minimum:u,maximum:d}=e._zod.bag;typeof u==`number`&&(i.minItems=u),typeof d==`number`&&(i.maxItems=d)},ua=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`;let o=a.keyType,s=o._zod.bag?.patterns;if(a.mode===`loose`&&s&&s.size>0){let e=P(a.valueType,t,{...r,path:[...r.path,`patternProperties`,`*`]});i.patternProperties={};for(let t of s)i.patternProperties[t.source]=e}else(t.target===`draft-07`||t.target===`draft-2020-12`)&&(i.propertyNames=P(a.keyType,t,{...r,path:[...r.path,`propertyNames`]})),i.additionalProperties=P(a.valueType,t,{...r,path:[...r.path,`additionalProperties`]});let c=o._zod.values;if(c){let e=[...c].filter(e=>typeof e==`string`||typeof e==`number`);e.length>0&&(i.required=e)}},da=(e,t,n,r)=>{let i=e._zod.def,a=P(i.innerType,t,r),o=t.seen.get(e);t.target===`openapi-3.0`?(o.ref=i.innerType,n.nullable=!0):n.anyOf=[a,{type:`null`}]},fa=(e,t,n,r)=>{let i=e._zod.def;P(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},pa=(e,t,n,r)=>{let i=e._zod.def;P(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.default=JSON.parse(JSON.stringify(i.defaultValue))},ma=(e,t,n,r)=>{let i=e._zod.def;P(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,t.io===`input`&&(n._prefault=JSON.parse(JSON.stringify(i.defaultValue)))},ha=(e,t,n,r)=>{let i=e._zod.def;P(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{throw Error(`Dynamic catch values are not supported in JSON Schema`)}n.default=o},ga=(e,t,n,r)=>{let i=e._zod.def,a=i.in._zod.traits.has(`$ZodTransform`),o=t.io===`input`?a?i.out:i.in:i.out;P(o,t,r);let s=t.seen.get(e);s.ref=o},_a=(e,t,n,r)=>{let i=e._zod.def;P(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},va=(e,t,n,r)=>{let i=e._zod.def;P(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},ya=(e,t,n,r)=>{let i=e._zod.innerType;P(i,t,r);let a=t.seen.get(e);a.ref=i},ba=/*@__PURE__*/ k(`ZodISODateTime`,(e,t)=>{An.init(e,t),L.init(e,t)});function xa(e){return/* @__PURE__ */ ci(ba,e)}let Sa=/*@__PURE__*/ k(`ZodISODate`,(e,t)=>{jn.init(e,t),L.init(e,t)});function Ca(e){return/* @__PURE__ */ li(Sa,e)}let wa=/*@__PURE__*/ k(`ZodISOTime`,(e,t)=>{Mn.init(e,t),L.init(e,t)});function Ta(e){return/* @__PURE__ */ ui(wa,e)}let Ea=/*@__PURE__*/ k(`ZodISODuration`,(e,t)=>{Nn.init(e,t),L.init(e,t)});function Da(e){return/* @__PURE__ */ di(Ea,e)}let Oa=/*@__PURE__*/ k(`ZodError`,(e,t)=>{rt.init(e,t),e.name=`ZodError`,Object.defineProperties(e,{format:{value:t=>ot(e,t)},flatten:{value:t=>at(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,Se,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,Se,2)}},isEmpty:{get(){return e.issues.length===0}}})},{Parent:Error}),ka=/* @__PURE__ */ st(Oa),Aa=/* @__PURE__ */ ct(Oa),ja=/* @__PURE__ */ lt(Oa),Ma=/* @__PURE__ */ dt(Oa),Na=/* @__PURE__ */ pt(Oa),Pa=/* @__PURE__ */ mt(Oa),Fa=/* @__PURE__ */ ht(Oa),Ia=/* @__PURE__ */ gt(Oa),La=/* @__PURE__ */ _t(Oa),Ra=/* @__PURE__ */ vt(Oa),za=/* @__PURE__ */ yt(Oa),Ba=/* @__PURE__ */ bt(Oa),Va=/* @__PURE__ */ new WeakMap;function Ha(e,t,n){let r=Object.getPrototypeOf(e),i=Va.get(r);if(i||(i=/* @__PURE__ */ new Set,Va.set(r,i)),!i.has(t)){i.add(t);for(let e in n){let t=n[e];Object.defineProperty(r,e,{configurable:!0,enumerable:!1,get(){let n=t.bind(this);return Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:n}),n},set(t){Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:t})}})}}}let F=/*@__PURE__*/ k(`ZodType`,(e,t)=>(M.init(e,t),Object.assign(e[`~standard`],{jsonSchema:{input:Ji(e,`input`),output:Ji(e,`output`)}}),e.toJSONSchema=qi(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(t,n)=>ka(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>ja(e,t,n),e.parseAsync=async(t,n)=>Aa(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>Ma(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>Na(e,t,n),e.decode=(t,n)=>Pa(e,t,n),e.encodeAsync=async(t,n)=>Fa(e,t,n),e.decodeAsync=async(t,n)=>Ia(e,t,n),e.safeEncode=(t,n)=>La(e,t,n),e.safeDecode=(t,n)=>Ra(e,t,n),e.safeEncodeAsync=async(t,n)=>za(e,t,n),e.safeDecodeAsync=async(t,n)=>Ba(e,t,n),Ha(e,`ZodType`,{check(...e){let t=this.def;return this.clone(ke(t,{checks:[...t.checks??[],...e.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return ze(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(os(e,t))},superRefine(e,t){return this.check(ss(e,t))},overwrite(e){return this.check(/* @__PURE__ */ Mi(e))},optional(){return zo(this)},exactOptional(){return Vo(this)},nullable(){return Uo(this)},nullish(){return zo(Uo(this))},nonoptional(e){return Yo(this,e)},array(){return B(this)},or(e){return To([this,e])},and(e){return ko(this,e)},transform(e){return $o(this,Lo(e))},default(e){return Go(this,e)},prefault(e){return qo(this,e)},catch(e){return Zo(this,e)},pipe(e){return $o(this,e)},readonly(){return ts(this)},describe(e){let t=this.clone();return Rr.add(t,{description:e}),t},meta(...e){if(e.length===0)return Rr.get(this);let t=this.clone();return Rr.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e){return e(this)}}),Object.defineProperty(e,"description",{get(){return Rr.get(e)?.description},configurable:!0}),e)),Ua=/*@__PURE__*/ k(`_ZodString`,(e,t)=>{vn.init(e,t),F.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Xi(e,t,n,r);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,Ha(e,`_ZodString`,{regex(...e){return this.check(/* @__PURE__ */ Ei(...e))},includes(...e){return this.check(/* @__PURE__ */ ki(...e))},startsWith(...e){return this.check(/* @__PURE__ */ Ai(...e))},endsWith(...e){return this.check(/* @__PURE__ */ ji(...e))},min(...e){return this.check(/* @__PURE__ */ wi(...e))},max(...e){return this.check(/* @__PURE__ */ Ci(...e))},length(...e){return this.check(/* @__PURE__ */ Ti(...e))},nonempty(...e){return this.check(/* @__PURE__ */ wi(1,...e))},lowercase(e){return this.check(/* @__PURE__ */ Di(e))},uppercase(e){return this.check(/* @__PURE__ */ Oi(e))},trim(){return this.check(/* @__PURE__ */ Pi())},normalize(...e){return this.check(/* @__PURE__ */ Ni(...e))},toLowerCase(){return this.check(/* @__PURE__ */ Fi())},toUpperCase(){return this.check(/* @__PURE__ */ Ii())},slugify(){return this.check(/* @__PURE__ */ Li())}})}),Wa=/*@__PURE__*/ k(`ZodString`,(e,t)=>{vn.init(e,t),Ua.init(e,t),e.email=t=>e.check(/* @__PURE__ */ Br(Ga,t)),e.url=t=>e.check(/* @__PURE__ */ Kr(Ja,t)),e.jwt=t=>e.check(/* @__PURE__ */ si(uo,t)),e.emoji=t=>e.check(/* @__PURE__ */ qr(Xa,t)),e.guid=t=>e.check(/* @__PURE__ */ Vr(Ka,t)),e.uuid=t=>e.check(/* @__PURE__ */ Hr(qa,t)),e.uuidv4=t=>e.check(/* @__PURE__ */ Ur(qa,t)),e.uuidv6=t=>e.check(/* @__PURE__ */ Wr(qa,t)),e.uuidv7=t=>e.check(/* @__PURE__ */ Gr(qa,t)),e.nanoid=t=>e.check(/* @__PURE__ */ Jr(Za,t)),e.guid=t=>e.check(/* @__PURE__ */ Vr(Ka,t)),e.cuid=t=>e.check(/* @__PURE__ */ Yr(Qa,t)),e.cuid2=t=>e.check(/* @__PURE__ */ Xr($a,t)),e.ulid=t=>e.check(/* @__PURE__ */ Zr(eo,t)),e.base64=t=>e.check(/* @__PURE__ */ ii(so,t)),e.base64url=t=>e.check(/* @__PURE__ */ ai(co,t)),e.xid=t=>e.check(/* @__PURE__ */ Qr(to,t)),e.ksuid=t=>e.check(/* @__PURE__ */ $r(no,t)),e.ipv4=t=>e.check(/* @__PURE__ */ ei(ro,t)),e.ipv6=t=>e.check(/* @__PURE__ */ ti(io,t)),e.cidrv4=t=>e.check(/* @__PURE__ */ ni(ao,t)),e.cidrv6=t=>e.check(/* @__PURE__ */ ri(oo,t)),e.e164=t=>e.check(/* @__PURE__ */ oi(lo,t)),e.datetime=t=>e.check(xa(t)),e.date=t=>e.check(Ca(t)),e.time=t=>e.check(Ta(t)),e.duration=t=>e.check(Da(t))});function I(e){return/* @__PURE__ */ zr(Wa,e)}let L=/*@__PURE__*/ k(`ZodStringFormat`,(e,t)=>{N.init(e,t),Ua.init(e,t)}),Ga=/*@__PURE__*/ k(`ZodEmail`,(e,t)=>{xn.init(e,t),L.init(e,t)}),Ka=/*@__PURE__*/ k(`ZodGUID`,(e,t)=>{yn.init(e,t),L.init(e,t)}),qa=/*@__PURE__*/ k(`ZodUUID`,(e,t)=>{bn.init(e,t),L.init(e,t)}),Ja=/*@__PURE__*/ k(`ZodURL`,(e,t)=>{Sn.init(e,t),L.init(e,t)});function Ya(e){return/* @__PURE__ */ Kr(Ja,e)}let Xa=/*@__PURE__*/ k(`ZodEmoji`,(e,t)=>{Cn.init(e,t),L.init(e,t)}),Za=/*@__PURE__*/ k(`ZodNanoID`,(e,t)=>{wn.init(e,t),L.init(e,t)}),Qa=/*@__PURE__*/ k(`ZodCUID`,(e,t)=>{Tn.init(e,t),L.init(e,t)}),$a=/*@__PURE__*/ k(`ZodCUID2`,(e,t)=>{En.init(e,t),L.init(e,t)}),eo=/*@__PURE__*/ k(`ZodULID`,(e,t)=>{Dn.init(e,t),L.init(e,t)}),to=/*@__PURE__*/ k(`ZodXID`,(e,t)=>{On.init(e,t),L.init(e,t)}),no=/*@__PURE__*/ k(`ZodKSUID`,(e,t)=>{kn.init(e,t),L.init(e,t)}),ro=/*@__PURE__*/ k(`ZodIPv4`,(e,t)=>{Pn.init(e,t),L.init(e,t)}),io=/*@__PURE__*/ k(`ZodIPv6`,(e,t)=>{Fn.init(e,t),L.init(e,t)}),ao=/*@__PURE__*/ k(`ZodCIDRv4`,(e,t)=>{In.init(e,t),L.init(e,t)}),oo=/*@__PURE__*/ k(`ZodCIDRv6`,(e,t)=>{Ln.init(e,t),L.init(e,t)}),so=/*@__PURE__*/ k(`ZodBase64`,(e,t)=>{zn.init(e,t),L.init(e,t)}),co=/*@__PURE__*/ k(`ZodBase64URL`,(e,t)=>{Vn.init(e,t),L.init(e,t)}),lo=/*@__PURE__*/ k(`ZodE164`,(e,t)=>{Hn.init(e,t),L.init(e,t)}),uo=/*@__PURE__*/ k(`ZodJWT`,(e,t)=>{Wn.init(e,t),L.init(e,t)}),fo=/*@__PURE__*/ k(`ZodNumber`,(e,t)=>{Gn.init(e,t),F.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Zi(e,t,n,r),Ha(e,`ZodNumber`,{gt(e,t){return this.check(/* @__PURE__ */ bi(e,t))},gte(e,t){return this.check(/* @__PURE__ */ xi(e,t))},min(e,t){return this.check(/* @__PURE__ */ xi(e,t))},lt(e,t){return this.check(/* @__PURE__ */ vi(e,t))},lte(e,t){return this.check(/* @__PURE__ */ yi(e,t))},max(e,t){return this.check(/* @__PURE__ */ yi(e,t))},int(e){return this.check(mo(e))},safe(e){return this.check(mo(e))},positive(e){return this.check(/* @__PURE__ */ bi(0,e))},nonnegative(e){return this.check(/* @__PURE__ */ xi(0,e))},negative(e){return this.check(/* @__PURE__ */ vi(0,e))},nonpositive(e){return this.check(/* @__PURE__ */ yi(0,e))},multipleOf(e,t){return this.check(/* @__PURE__ */ Si(e,t))},step(e,t){return this.check(/* @__PURE__ */ Si(e,t))},finite(){return this}});let n=e._zod.bag;e.minValue=Math.max(n.minimum??-1/0,n.exclusiveMinimum??-1/0)??null,e.maxValue=Math.min(n.maximum??1/0,n.exclusiveMaximum??1/0)??null,e.isInt=(n.format??``).includes(`int`)||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function R(e){return/* @__PURE__ */ fi(fo,e)}let po=/*@__PURE__*/ k(`ZodNumberFormat`,(e,t)=>{Kn.init(e,t),fo.init(e,t)});function mo(e){return/* @__PURE__ */ pi(po,e)}let ho=/*@__PURE__*/ k(`ZodBoolean`,(e,t)=>{qn.init(e,t),F.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Qi(e,t,n,r)});function z(e){return/* @__PURE__ */ mi(ho,e)}let go=/*@__PURE__*/ k(`ZodNull`,(e,t)=>{Jn.init(e,t),F.init(e,t),e._zod.processJSONSchema=(t,n,r)=>$i(e,t,n,r)});function _o(e){return/* @__PURE__ */ hi(go,e)}let vo=/*@__PURE__*/ k(`ZodUnknown`,(e,t)=>{Yn.init(e,t),F.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function yo(){return/* @__PURE__ */ gi(vo)}let bo=/*@__PURE__*/ k(`ZodNever`,(e,t)=>{Xn.init(e,t),F.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ea(e,t,n,r)});function xo(e){return/* @__PURE__ */ _i(bo,e)}let So=/*@__PURE__*/ k(`ZodArray`,(e,t)=>{Qn.init(e,t),F.init(e,t),e._zod.processJSONSchema=(t,n,r)=>aa(e,t,n,r),e.element=t.element,Ha(e,`ZodArray`,{min(e,t){return this.check(/* @__PURE__ */ wi(e,t))},nonempty(e){return this.check(/* @__PURE__ */ wi(1,e))},max(e,t){return this.check(/* @__PURE__ */ Ci(e,t))},length(e,t){return this.check(/* @__PURE__ */ Ti(e,t))},unwrap(){return this.element}})});function B(e,t){return/* @__PURE__ */ Ri(So,e,t)}let Co=/*@__PURE__*/ k(`ZodObject`,(e,t)=>{rr.init(e,t),F.init(e,t),e._zod.processJSONSchema=(t,n,r)=>oa(e,t,n,r),A(e,`shape`,()=>t.shape),Ha(e,`ZodObject`,{keyof(){return U(Object.keys(this._zod.def.shape))},catchall(e){return this.clone({...this._zod.def,catchall:e})},passthrough(){return this.clone({...this._zod.def,catchall:yo()})},loose(){return this.clone({...this._zod.def,catchall:yo()})},strict(){return this.clone({...this._zod.def,catchall:xo()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(e){return We(this,e)},safeExtend(e){return Ge(this,e)},merge(e){return Ke(this,e)},pick(e){return He(this,e)},omit(e){return Ue(this,e)},partial(...e){return qe(Ro,this,e[0])},required(...e){return Je(Jo,this,e[0])}})});function V(e,t){let n={type:`object`,shape:e??{},...j(t)};return new Co(n)}function H(e,t){return new Co({type:`object`,shape:e,catchall:xo(),...j(t)})}let wo=/*@__PURE__*/ k(`ZodUnion`,(e,t)=>{ar.init(e,t),F.init(e,t),e._zod.processJSONSchema=(t,n,r)=>sa(e,t,n,r),e.options=t.options});function To(e,t){return new wo({type:`union`,options:e,...j(t)})}let Eo=/*@__PURE__*/ k(`ZodDiscriminatedUnion`,(e,t)=>{wo.init(e,t),or.init(e,t)});function Do(e,t,n){return new Eo({type:`union`,options:t,discriminator:e,...j(n)})}let Oo=/*@__PURE__*/ k(`ZodIntersection`,(e,t)=>{sr.init(e,t),F.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ca(e,t,n,r)});function ko(e,t){return new Oo({type:`intersection`,left:e,right:t})}let Ao=/*@__PURE__*/ k(`ZodTuple`,(e,t)=>{ur.init(e,t),F.init(e,t),e._zod.processJSONSchema=(t,n,r)=>la(e,t,n,r),e.rest=t=>e.clone({...e._zod.def,rest:t})});function jo(e,t,n){let r=t instanceof M;return new Ao({type:`tuple`,items:e,rest:r?t:null,...j(r?n:t)})}let Mo=/*@__PURE__*/ k(`ZodRecord`,(e,t)=>{mr.init(e,t),F.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ua(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType});function No(e,t,n){return!t||!t._zod?new Mo({type:`record`,keyType:I(),valueType:e,...j(t)}):new Mo({type:`record`,keyType:e,valueType:t,...j(n)})}let Po=/*@__PURE__*/ k(`ZodEnum`,(e,t)=>{hr.init(e,t),F.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ta(e,t,n,r),e.enum=t.entries,e.options=Object.values(t.entries);let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new Po({...t,checks:[],...j(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new Po({...t,checks:[],...j(r),entries:i})}});function U(e,t){let n=Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e;return new Po({type:`enum`,entries:n,...j(t)})}let Fo=/*@__PURE__*/ k(`ZodLiteral`,(e,t)=>{gr.init(e,t),F.init(e,t),e._zod.processJSONSchema=(t,n,r)=>na(e,t,n,r),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function W(e,t){return new Fo({type:`literal`,values:Array.isArray(e)?e:[e],...j(t)})}let Io=/*@__PURE__*/ k(`ZodTransform`,(e,t)=>{_r.init(e,t),F.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ia(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new ve(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(tt(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,t.input??=n.value,t.inst??=e,n.issues.push(tt(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n.fallback=!0,n)):(n.value=i,n.fallback=!0,n)}});function Lo(e){return new Io({type:`transform`,transform:e})}let Ro=/*@__PURE__*/ k(`ZodOptional`,(e,t)=>{yr.init(e,t),F.init(e,t),e._zod.processJSONSchema=(t,n,r)=>va(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function zo(e){return new Ro({type:`optional`,innerType:e})}let Bo=/*@__PURE__*/ k(`ZodExactOptional`,(e,t)=>{br.init(e,t),F.init(e,t),e._zod.processJSONSchema=(t,n,r)=>va(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Vo(e){return new Bo({type:`optional`,innerType:e})}let Ho=/*@__PURE__*/ k(`ZodNullable`,(e,t)=>{xr.init(e,t),F.init(e,t),e._zod.processJSONSchema=(t,n,r)=>da(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Uo(e){return new Ho({type:`nullable`,innerType:e})}let Wo=/*@__PURE__*/ k(`ZodDefault`,(e,t)=>{Sr.init(e,t),F.init(e,t),e._zod.processJSONSchema=(t,n,r)=>pa(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Go(e,t){return new Wo({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():Ie(t)}})}let Ko=/*@__PURE__*/ k(`ZodPrefault`,(e,t)=>{wr.init(e,t),F.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ma(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function qo(e,t){return new Ko({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():Ie(t)}})}let Jo=/*@__PURE__*/ k(`ZodNonOptional`,(e,t)=>{Tr.init(e,t),F.init(e,t),e._zod.processJSONSchema=(t,n,r)=>fa(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Yo(e,t){return new Jo({type:`nonoptional`,innerType:e,...j(t)})}let Xo=/*@__PURE__*/ k(`ZodCatch`,(e,t)=>{Dr.init(e,t),F.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ha(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Zo(e,t){return new Xo({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:()=>t})}let Qo=/*@__PURE__*/ k(`ZodPipe`,(e,t)=>{Or.init(e,t),F.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ga(e,t,n,r),e.in=t.in,e.out=t.out});function $o(e,t){return new Qo({type:`pipe`,in:e,out:t})}let es=/*@__PURE__*/ k(`ZodReadonly`,(e,t)=>{Ar.init(e,t),F.init(e,t),e._zod.processJSONSchema=(t,n,r)=>_a(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function ts(e){return new es({type:`readonly`,innerType:e})}let ns=/*@__PURE__*/ k(`ZodLazy`,(e,t)=>{Mr.init(e,t),F.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ya(e,t,n,r),e.unwrap=()=>e._zod.def.getter()});function rs(e){return new ns({type:`lazy`,getter:e})}let is=/*@__PURE__*/ k(`ZodCustom`,(e,t)=>{Nr.init(e,t),F.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ra(e,t,n,r)});function as(e,t){return/* @__PURE__ */ zi(is,e??(()=>!0),t)}function os(e,t={}){return/* @__PURE__ */ Bi(is,e,t)}function ss(e,t){return/* @__PURE__ */ Vi(e,t)}function cs(e){return(t,n)=>{for(let r of e)Object.hasOwn(t,r)&&t[r]===void 0&&n.addIssue({code:`custom`,path:[r],message:`Explicit undefined is not valid JSON`})}}let ls=To([I(),R(),z(),_o()]);function us(e){let t=/* @__PURE__ */ new WeakSet,n=[{value:e,leaving:!1}];try{for(;n.length>0;){let e=n.pop();if(!e)break;if(e.leaving)t.delete(e.value);else if(typeof e.value==`object`&&e.value!==null){if(t.has(e.value))return!1;t.add(e.value),n.push({value:e.value,leaving:!0});for(let t of Object.values(e.value))n.push({value:t,leaving:!1})}}}catch{return!1}return!0}let ds=as(us,{message:`JSON value must not contain circular references`}),fs=rs(()=>To([ls,B(fs),No(I(),fs)])),ps=ds.pipe(fs);ds.pipe(B(fs));let ms=ds.pipe(No(I(),fs)),hs=H({code:I().min(1),message:I().min(1),retryable:z(),diagnostic:I().min(1).optional(),stage:I().min(1).optional(),durationMs:R().int().nonnegative().optional(),stderrTail:I().min(1).optional()}).superRefine(cs([`diagnostic`,`stage`,`durationMs`,`stderrTail`])),gs=I().max(64).regex(/^[a-z]{2,3}(?:-[A-Za-z0-9]{2,8})*$/u),_s=e=>I().min(1).max(e).refine(e=>e.trim().length>0),vs=No(gs,V({label:_s(256).optional(),description:_s(1024).optional()}).strict()).refine(e=>Object.keys(e).length<=16,`Too many locales`),ys=No(gs,_s(4096)).refine(e=>typeof e.en==`string`,`English fallback is required`).refine(e=>Object.keys(e).length<=16,`Too many locales`),bs=I().refine(e=>e.trim().length>0,{message:`Identifier must not be empty or whitespace`}),xs=bs.brand(),G=bs.brand(),Ss=bs.brand();bs.brand(),bs.brand();let Cs=I().refine(e=>e.trim().length>0,{message:`Value must not be empty or whitespace`}),ws=Cs.max(128).regex(/^[A-Za-z0-9._~:-]+$/u,`Permission Mode ID must use transport-safe characters`).brand(),Ts=V({modes:B(V({id:ws,label:Cs.max(256),description:Cs.max(1024).optional(),dangerous:z().optional(),localizations:vs.optional()}).strict()).min(1).max(32),defaultModeId:ws}).strict().superRefine((e,t)=>{let n=/* @__PURE__ */ new Set;for(let[r,i]of e.modes.entries())n.has(i.id)&&t.addIssue({code:`custom`,message:`Permission Mode IDs must be unique`,path:[`modes`,r,`id`]}),n.add(i.id);n.has(e.defaultModeId)||t.addIssue({code:`custom`,message:`Default Permission Mode must exist in the catalog`,path:[`defaultModeId`]})});V({threadId:G,permissionModeId:ws}).strict();let Es=R().int().safe().nonnegative(),Ds=R().finite().nonnegative(),Os=R().finite().min(0).max(100),ks=V({value:Ds,turnId:I().min(1).max(1024),at:Es}).strict();V({outputTokensPerSecond:ks.optional(),timeToFirstOutputMs:ks.extend({value:Es}).optional()}).strict();let As=e=>ys.refine(t=>Object.values(t).every(t=>t.length<=e)),js=V({composerIndicators:B(V({kind:W(`countdown`),id:I().min(1).max(64),expiresAtUnix:Es,label:As(256).optional(),tooltip:As(1024).optional()}).strict()).max(2).refine(e=>new Set(e.map(({id:e})=>e)).size===e.length,{message:`Composer indicator IDs must be unique`}).optional(),inputTokens:Es.optional(),cachedInputTokens:Es.optional(),cacheWriteInputTokens:Es.optional(),outputTokens:Es.optional(),outputTokensPerSecond:Ds.optional(),apiOutputTokensPerSecond:Ds.optional(),reasoningOutputTokens:Es.optional(),totalTokens:Es.optional(),totalCostUsd:Ds.optional(),totalCredits:Ds.optional(),contextUsagePercent:Ds.optional(),cacheHitRatePercent:Os.optional(),contextWindowTokens:Es.optional(),contextUsedTokens:Es.optional(),planFiveHourUsedPercent:Os.optional(),planFiveHourResetsAtUnix:Es.optional(),planSevenDayUsedPercent:Os.optional(),planSevenDayResetsAtUnix:Es.optional(),sessionCacheHitRatePercent:Os.optional(),timeToFirstOutputMs:Es.optional(),costSource:U([`publicPrice`,`native`]).optional(),unpricedModels:B(I().min(1)).min(1).optional()}).strict().superRefine((e,t)=>{Object.keys(e).length===0&&t.addIssue({code:`custom`,message:`Thread Usage must contain a reliable field`});let n=e.contextUsedTokens!==void 0;n!==(e.contextWindowTokens!==void 0)&&t.addIssue({code:`custom`,message:`Thread Usage context fields must be provided together`,path:[n?`contextWindowTokens`:`contextUsedTokens`]}),e.contextWindowTokens===0&&t.addIssue({code:`custom`,message:`Thread Usage contextWindowTokens must be greater than zero`,path:[`contextWindowTokens`]}),e.costSource!==void 0&&e.totalCostUsd===void 0&&t.addIssue({code:`custom`,message:`Thread Usage costSource must be provided with totalCostUsd`,path:[`costSource`]}),e.unpricedModels!==void 0&&e.costSource!==`publicPrice`&&t.addIssue({code:`custom`,message:`Thread Usage unpricedModels must be provided with a publicPrice cost`,path:[`unpricedModels`]}),e.planFiveHourResetsAtUnix!==void 0&&e.planFiveHourUsedPercent===void 0&&t.addIssue({code:`custom`,message:`Thread Usage planFiveHourResetsAtUnix must be provided with planFiveHourUsedPercent`,path:[`planFiveHourResetsAtUnix`]}),e.planSevenDayResetsAtUnix!==void 0&&e.planSevenDayUsedPercent===void 0&&t.addIssue({code:`custom`,message:`Thread Usage planSevenDayResetsAtUnix must be provided with planSevenDayUsedPercent`,path:[`planSevenDayResetsAtUnix`]})}),Ms=R().finite().min(0).max(100),Ns=U([`weekly`,`monthly`,`five_hour`,`seven_day`,`unknown`]),Ps=V({id:I().min(1).max(256),label:I().min(1).max(256),localizations:vs.optional()}).strict(),Fs=V({product:I().min(1),periodType:Ns.optional(),scope:Ps.optional(),localizations:vs.optional(),used:R().finite().nonnegative().optional(),limit:R().finite().nonnegative().optional(),unit:I().min(1).max(32).optional(),usagePercent:Ms,resetsAt:I().min(1).optional()}).strict(),Is=V({availableCount:R().int().safe().positive(),nextExpiresAt:I().min(1).optional(),expiresAt:B(I().min(1)).min(1).max(32).optional()}).strict(),Ls=V({used:R().finite().nonnegative().optional(),limit:R().finite().nonnegative().optional(),unit:I().trim().min(1).max(32).optional(),label:I().min(1).optional(),usedPercent:Ms.optional(),remaining:R().finite().optional(),scope:Ps.optional(),localizations:vs.optional(),resetsAt:I().min(1).optional(),periodType:Ns,productUsage:B(Fs).min(1).optional(),resetCredits:Is.optional()}).strict().superRefine((e,t)=>{e.usedPercent===void 0&&e.remaining===void 0&&t.addIssue({code:`custom`,message:`Account credits must include usedPercent or remaining`}),e.remaining!==void 0&&!e.unit&&t.addIssue({code:`custom`,message:`Account remaining credits require a unit`,path:[`unit`]})});V({threadId:G,refresh:W(`exact`).optional()}).strict(),V({threadId:G,usage:js.nullable(),accountCredits:Ls.optional(),accountCreditsSupported:z().optional()}).strict();let Rs=I().refine(e=>e.trim().length>0,{message:`Value must not be empty or whitespace`}),zs=V({id:Rs.max(512).regex(/^[A-Za-z0-9._~-]+$/u,`Model Ref must use transport-safe opaque characters`).brand()}).strict(),Bs=Rs.max(128).regex(/^[A-Za-z0-9._~-]+$/u,`Thinking option ID must use transport-safe characters`).brand(),Vs=Rs.max(256),Hs=V({id:Bs,label:Rs.max(256)}).strict(),Us=V({ref:zs,label:Rs.max(256),resolvedModelLabel:Vs.optional(),fastModel:zs.optional(),supportedThinkingOptionIds:B(Bs).optional()}).strict(),Ws=B(Hs).superRefine((e,t)=>{let n=/* @__PURE__ */ new Set;for(let[r,i]of e.entries())n.has(i.id)&&t.addIssue({code:`custom`,message:`Thinking option IDs must be unique`,path:[r,`id`]}),n.add(i.id)}),Gs=V({models:B(Us),defaultModel:zs.optional(),thinkingOptions:Ws,defaultThinkingOptionId:Bs.optional()}).strict().superRefine((e,t)=>{let n=/* @__PURE__ */ new Set,r=new Set(e.thinkingOptions.map(({id:e})=>e));for(let[i,a]of e.models.entries()){n.has(a.ref.id)&&t.addIssue({code:`custom`,message:`Model Catalog refs must be unique`,path:[`models`,i,`ref`,`id`]}),n.add(a.ref.id),a.fastModel&&((n.has(a.fastModel.id)||e.models.some(e=>e.ref.id===a.fastModel?.id))&&t.addIssue({code:`custom`,message:`Fast Model refs must be distinct and unique`,path:[`models`,i,`fastModel`]}),n.add(a.fastModel.id));let o=/* @__PURE__ */ new Set;for(let[e,n]of(a.supportedThinkingOptionIds??[]).entries())o.has(n)&&t.addIssue({code:`custom`,message:`Supported Thinking option IDs must be unique per Model`,path:[`models`,i,`supportedThinkingOptionIds`,e]}),o.add(n),r.has(n)||t.addIssue({code:`custom`,message:`Supported Thinking option must exist in the catalog`,path:[`models`,i,`supportedThinkingOptionIds`,e]})}e.defaultModel&&!n.has(e.defaultModel.id)&&t.addIssue({code:`custom`,message:`Default Model must exist in the Model Catalog`,path:[`defaultModel`,`id`]}),e.defaultThinkingOptionId&&!r.has(e.defaultThinkingOptionId)&&t.addIssue({code:`custom`,message:`Default Thinking option must exist in the catalog`,path:[`defaultThinkingOptionId`]})}),Ks=V({fork:z(),forkAcrossCwd:z(),rollbackLastTurn:z()}).strict().refine(e=>e.fork||!e.forkAcrossCwd,{path:[`forkAcrossCwd`],message:`Cross-cwd Fork requires exact history Fork support`}),qs=U([`live`,`atCreate`]),Js=V({configuration:V({selectModel:z(),selectThinkingOption:z(),selectPermissionMode:z(),permissionModeScope:qs.default(`live`)}).strict(),history:Ks,subagents:V({observe:z(),readTranscript:z()}).strict().optional(),autonomousTurns:V({observe:z()}).strict().optional(),input:V({image:z()}).strict().optional(),steer:z().optional()}).strict();V({effectiveModel:zs.optional(),resolvedModelLabel:Vs.optional(),effectiveThinkingOptionId:Bs.optional(),availableThinkingOptions:Ws.optional(),effectivePermissionModeId:ws.optional()}).strict().superRefine((e,t)=>{e.effectiveThinkingOptionId&&e.availableThinkingOptions&&!e.availableThinkingOptions.some(({id:t})=>t===e.effectiveThinkingOptionId)&&t.addIssue({code:`custom`,message:`Effective Thinking option must be currently available`,path:[`effectiveThinkingOptionId`]})});let Ys=V({open:W(!0)}).strict();To([V({status:W(`ready`),catalog:Gs,permissionModes:Ts.optional(),capabilities:Js,webUi:Ys.optional()}).strict().superRefine((e,t)=>{let n=e.capabilities.configuration.selectPermissionMode;n!==!!e.permissionModes&&t.addIssue({code:`custom`,message:`Permission Mode catalog and capability must agree`,path:n?[`permissionModes`]:[`capabilities`,`configuration`,`selectPermissionMode`]})}),V({status:U([`notInstalled`,`unavailable`,`error`]),error:hs}).strict()]),V({harnessId:xs,cwd:Rs.max(16384).optional(),refresh:z().optional(),purpose:W(`availability`).optional()}).strict(),V({harnessId:xs}).strict(),V({}).strict(),V({threadId:G,model:zs}).strict(),V({threadId:G,thinkingOptionId:Bs}).strict(),V({threadId:G,includeReferenceCapability:z().optional()}).strict(),Do(`owner`,[V({owner:W(`codex`),locked:z(),effectiveModel:zs.optional(),resolvedModelLabel:Vs.optional(),effectiveThinkingOptionId:Bs.optional(),effectivePermissionModeId:ws.optional(),history:Ks.optional(),supportsThreadReferences:W(!0).optional()}).strict(),V({owner:W(`external`),harnessId:Rs.max(256),transportModelId:Rs.max(1024),effectiveModel:zs.optional(),resolvedModelLabel:Vs.optional(),effectiveThinkingOptionId:Bs.optional(),availableThinkingOptions:Ws.optional(),effectivePermissionModeId:ws.optional(),history:Ks,usage:js.optional(),subagent:z().optional(),locked:W(!0)}).strict()]),V({threadIds:B(G).min(1).max(100)}).strict().superRefine(({threadIds:e},t)=>{let n=/* @__PURE__ */ new Set;for(let[r,i]of e.entries())n.has(i)&&t.addIssue({code:`custom`,message:`Thread ownership-list IDs must be unique`,path:[`threadIds`,r]}),n.add(i)});let Xs=Do(`owner`,[V({threadId:G,owner:W(`codex`)}).strict(),V({threadId:G,owner:W(`external`),harnessId:I().max(256).pipe(xs)}).strict()]);V({threads:B(Xs).min(1).max(100)}).strict().superRefine(({threads:e},t)=>{let n=/* @__PURE__ */ new Set;for(let[r,i]of e.entries())n.has(i.threadId)&&t.addIssue({code:`custom`,message:`Thread ownership-list results must be unique`,path:[`threads`,r,`threadId`]}),n.add(i.threadId)}),V({threadId:G,text:I().optional()}).strict(),V({kind:W(`application`),value:I().transform((e,t)=>{try{return JSON.parse(e)}catch{return t.addIssue({code:`custom`,message:`Invalid steering context JSON`}),ge}}).pipe(V({expectedTurnId:Ss,clientUserMessageId:I().min(1),delivery:U([`newTurn`,`activeTurn`])}).strict())}).strict().transform(e=>e.value),U([`activeTurn`,`newTurn`]),V({delivery:U([`official`,`activeTurn`,`newTurn`])}).strict(),V({threadIds:B(I().min(1))}).strict(),V({threadId:I().min(1).max(1024),pinned:z()}).strict(),V({prompt:I().max(16384).optional()}).strict(),V({projects:B(V({id:I(),name:I(),rootPaths:B(I())})),assignments:No(I(),I()),projectless:B(I()),pinned:B(I())});let Zs=No(I(),yo()),Qs=V({epoch:I().uuid(),sequence:R().int().nonnegative()});Do(`type`,[V({type:W(`skills-changed`),cursor:Qs,cwd:I().optional()}),V({type:W(`display-settings-changed`),cursor:Qs}),V({type:W(`preferences-changed`),cursor:Qs,revision:R().int().nonnegative()}),V({type:W(`hello`),version:W(1),cursor:Qs,reset:z()}),V({type:W(`changed`),cursor:Qs,threadId:I().min(1),method:I().min(1)})]);let $s=Do(`type`,[V({type:W(`text`),id:I(),prompt:I(),secret:z().optional(),optional:z().optional()}),V({type:W(`choice`),id:I(),prompt:I(),multiple:z(),allowOther:z(),optional:z().optional(),options:B(V({value:I(),label:I(),description:I().optional()}))})]),ec=Do(`type`,[V({type:W(`approval`),title:I(),description:I().optional(),subject:yo().optional(),actions:B(V({id:I(),label:I(),effect:I()}))}),V({type:W(`question`),title:I().optional(),questions:B($s)})]),tc=V({requestId:To([I(),R().int()]),threadId:I(),kind:U([`approval`,`question`]),interaction:ec,request:Zs}),nc=V({id:I().min(1),clientUserMessageId:I().min(1),input:B(Zs),presentationInput:B(Zs).nullable().optional()}).passthrough();V({fields:B(V({path:B(To([I(),R().int().nonnegative()])),originalLength:R().int().nonnegative()}))});let rc=V({id:I().min(1),status:I().min(1),items:B(V({id:I().min(1),type:I().min(1)}).passthrough()),codexhostFileOperations:B(V({beforeItemId:I().nullable(),item:V({id:I().min(1),type:I().min(1)}).passthrough()})).optional(),error:V({message:I().optional()}).passthrough().nullable().optional(),fingerprint:I().min(1).optional(),unchanged:W(!0).optional()}).passthrough(),ic=V({id:I().min(1).max(512),fingerprint:I().min(1).max(128)});V({threadId:I().min(1),knownTurns:B(ic).max(64).optional(),truncateToolOutput:z().optional()});let ac=V({harnessId:I().min(1),nativeSessionId:I().min(1)});V({cursor:Qs,activeTurnId:I().min(1).nullable().optional(),command:V({name:I().min(1),turn:rc}).optional(),thread:V({id:I().min(1),cwd:I(),modelProvider:I().min(1),createdAt:R(),updatedAt:R(),status:V({type:I()}).passthrough(),name:I().nullable().optional(),preview:I().optional(),codexhostImportSource:ac.optional(),turns:B(rc).length(0)}).passthrough(),turnsPage:V({data:B(rc).max(5),nextCursor:I().nullable()}),configuration:V({native:V({model:I().min(1).max(1024).optional(),reasoningEffort:I().min(1).max(128).optional()}).optional(),effectiveModel:zs.optional(),effectiveThinkingOptionId:Bs.optional(),effectivePermissionModeId:ws.optional()}),queue:V({items:B(nc),pausedReason:U([`interrupted`,`outcome-unknown`,`failed`]).nullable()}).optional(),interactions:B(tc)}),V({version:W(1),owner:W(`service`).optional(),pid:R().int().positive(),port:R().int().min(1).max(65535),token:I().regex(/^[0-9a-f]{64}$/u),startedAt:R(),epoch:I().uuid()}),V({epoch:I().uuid(),threadId:I().min(1),requestId:To([I(),R().int()]),result:Zs}),V({includeArchived:z().optional(),officialCursor:V({live:I().nullable(),archived:I().nullable().optional()}).strict().optional()}).strict(),V({threads:B(ms),ownership:B(Xs),archivedThreadIds:B(G),officialCursor:V({live:I().nullable(),archived:I().nullable().optional()}).strict().optional()}).strict();let oc=I().regex(/^audio\/[a-z0-9.+-]+(?:\s*;[^\r\n]*)?$/i);V({available:z()}).strict(),V({path:I().min(1),mimeType:oc}).strict();let sc=U([`credentials-unavailable`,`login-expired`,`rate-limited`,`service-rejected`,`host-incompatible`,`network`,`timeout`,`audio-empty`,`audio-too-large`,`audio-format`,`audio-invalid`]);Do(`ok`,[V({ok:W(!0),text:I()}).strict(),V({ok:W(!1),error:V({code:sc}).strict()}).strict()]),V({threadId:G.optional(),cwd:I().min(1).optional()}).strict().refine(e=>!(e.threadId&&e.cwd),{message:`Specify threadId or cwd, not both`});let cc=V({name:I().min(1).regex(/^[^\s[\]]+$/u),description:I().optional(),path:I().min(1),scope:U([`project`,`global`]),source:I().min(1)}).strict();V({revision:R().int().nonnegative(),complete:z(),skills:B(cc),warnings:B(I()).optional()}).strict(),V({cwd:I().min(1).optional()}).strict();let lc=V({kind:U([`public`,`relay`,`tailscale-funnel`,`tailscale-https`,`tailscale`,`lan`,`virtual`]),url:I().min(1)}).strict(),uc=Do(`status`,[V({status:W(`not-installed`)}),V({status:W(`not-running`)}),V({status:W(`not-logged-in`)}),V({status:W(`https-disabled`)}),V({status:W(`not-serving`),command:I()}),V({status:W(`occupied`),target:I()}),V({status:W(`serving`),url:I(),funnel:z()}),V({status:W(`error`),message:I()})]);V({state:uc,error:I().optional()}).strict();let dc=Do(`status`,[V({status:W(`on`)}),V({status:W(`off`)}),V({status:W(`invalid`),reason:I()})]),fc=V({lan:z(),autostart:dc}).strict(),pc=V({expiresAt:I().optional(),issuing:z(),failure:V({detail:I().optional(),retryAt:I(),paused:z()}).optional()}),mc=Do(`status`,[V({status:W(`off`),reason:U([`invite`,`name-taken`,`banned`]).optional()}),V({status:W(`connecting`),reason:U([`full`,`unreachable`]).optional()}),V({status:W(`connected`),url:I(),certificate:pc}),V({status:W(`missing-certificate`),url:I(),certificate:pc}),V({status:W(`stopped`),reason:U([`replaced`,`rejected`,`unsupported-version`])})]);I().max(253).regex(/^(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z](?:[a-z0-9-]{0,61}[a-z0-9])?$/i).transform(e=>e.toLowerCase()),I().regex(/^(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)?$/);let hc=U([`official`,`self-hosted`]);V({secret:I().min(1),lastUsedAt:R().nullable(),networkUrls:B(lc),directCandidates:B(lc).optional(),tailscale:uc,background:fc.optional(),relay:V({state:mc,enabled:z(),kind:hc,officialHost:I(),customHost:I().optional(),officialHostname:I().optional(),customHostname:I().optional(),quotaUntil:I().optional()}).strict().optional()}).strict(),V({url:I()}).strict();let gc=H({threadId:I().min(1).max(1024),view:U([`result`,`messages`]),cursor:I().min(1).max(8192).optional(),limit:R().int().min(1).max(100).optional()}),_c=V({id:I().min(1).max(256),harnessId:I().min(1),label:I().min(1).max(512),provider:U([`openai-codex`,`xai`])}).strict(),vc=I().regex(/^[a-z][a-z0-9-]{0,47}$/),yc=V({name:vc,source:_c,importedAt:I()}).strict(),bc=Do(`action`,[V({action:W(`list`)}).strict(),V({action:W(`import`),sourceId:I().min(1).max(256),name:vc,confirmed:W(!0)}).strict(),V({action:W(`reimport`),sourceId:I().min(1).max(256),name:vc,confirmed:W(!0)}).strict(),V({action:W(`remove`),name:vc,confirmed:W(!0)}).strict()]),xc=V({provider:I().min(1).max(128),type:U([`oauth`,`api_key`,`unknown`]),label:I().min(1).max(512).optional(),vendor:U([`openai-codex`,`xai`]).optional()}).strict();V({sources:B(_c),targets:B(V({harnessId:I(),providers:B(U([`openai-codex`,`xai`])),imports:B(yc),others:B(xc).default([])}).strict())}).strict(),V({targetHarnessId:I().min(1).max(128).optional(),request:bc}).strict(),V({events:z()});let Sc=B(H({agent:I().min(1).max(128),section:U([`main`,`more`,`auto`])})).max(256).refine(e=>new Set(e.map(e=>e.agent)).size===e.length,`Duplicate Harness IDs`);H({entries:Sc.nullable()}),H({}),H({entries:Sc,initializeOnly:z().optional()});let Cc=H({enabled:z(),timeoutMinutes:R().int().min(5).max(1440)});Object.freeze({enabled:!1,timeoutMinutes:10});let wc=I().regex(/^external$/u),Tc=xs.transform(e=>String(e)),Ec=H({model:zs.optional(),thinkingOptionId:Bs.optional(),permissionModeId:ws.optional()}).refine(e=>!!(e.model||e.thinkingOptionId||e.permissionModeId),`A default configuration must contain a preference`),Dc=H({lastHarness:xs.optional(),byHarness:No(Tc,Ec)}),Oc=I().min(1).max(1024),kc=H({idleRelease:Cc.optional(),favorites:No(Tc,B(Oc).max(2048)).default({}),newThread:Dc.optional()});H({scope:wc,revision:R().int().nonnegative(),values:kc}),H({scope:wc.default(`external`)});let Ac=Do(`kind`,[H({kind:W(`idleRelease`),value:Cc}),H({kind:W(`favorite`),harnessId:xs,modelId:Oc,enabled:z()}),H({kind:W(`favorites`),harnessId:xs,modelIds:B(Oc).max(2048)}),H({kind:W(`newThread`),lastHarness:xs.optional(),harnessId:xs.optional(),configuration:Ec.optional()})]);H({scope:wc.default(`external`),operations:B(Ac).min(1).max(256),initializeOnly:z().optional(),expectedRevision:R().int().nonnegative().optional()}).superRefine((e,t)=>{for(let n of e.operations)n.kind===`newThread`&&(!n.lastHarness&&!n.configuration||!!n.harnessId!=!!n.configuration)&&t.addIssue({code:`custom`,message:`A default Harness or complete configuration is required`})}),H({version:W(1),revision:R().int().nonnegative(),scopes:No(wc,kc)});let jc=R().finite().nonnegative(),Mc=H({input:jc,output:jc,cacheRead:jc.optional(),cacheWrite:jc.optional(),cacheWrite1h:jc.optional()}),Nc=I().max(512).refine(e=>e.trim()===e&&e.length>0,`Model ID is required`);H({path:I(),entries:B(H({key:I(),price:Mc})),error:I().nullable()}),H({}),H({key:Nc,price:Mc.nullable(),previousKey:Nc.optional()}),H({model:Nc});let Pc=H({official:z().optional(),canonicalModelId:I().min(1).optional(),provider:I().min(1).max(512),model:I().min(1).max(512),price:Mc});H({price:Mc.nullable(),suggestions:B(Pc).max(6).optional()});let Fc=[`today`,`7d`,`30d`,`90d`,`all`],K=R().int().min(0).max(2**53-1),Ic=I().regex(/^\d{4}-\d{2}-\d{2}$/u),Lc=I().min(1).max(128),Rc=I().min(1).max(512),zc=I().min(1).max(4096);H({range:U(Fc),timeZone:I().min(1).max(128).refine(e=>{try{return new Intl.DateTimeFormat(`en`,{timeZone:e}),!0}catch{return!1}},`Unsupported usage statistics timezone`).optional(),harness:Lc.optional(),model:Rc.nullable().optional(),project:zc.nullable().optional(),date:Ic.optional()});let Bc=H({requests:K,inputTokens:K,cachedInputTokens:K,cacheWriteInputTokens:K,cacheKnownInputTokens:K,cacheHitCachedInputTokens:K,cacheHitInputTokens:K,outputTokens:K,reasoningOutputTokens:K,costUsd:R().finite().min(0),unpricedRequests:K,unmeteredRequests:K}),Vc=Bc.shape,Hc=H({harness:Lc,sessionId:I().min(1).max(512),project:zc.nullable(),title:I().min(1).max(200).optional(),models:B(Rc).max(16),firstAtMs:K,lastAtMs:K,...Vc});H({range:U(Fc),from:Ic.nullable(),to:Ic,filters:H({harness:Lc.nullable(),model:Rc.nullable(),unknownModel:z(),project:zc.nullable(),unknownProject:z(),date:Ic.nullable()}),reading:H({complete:z(),sources:K,read:K}),failures:B(H({harness:Lc,message:I().max(2048)})).max(256),options:H({harnesses:B(Lc).max(256),models:B(Rc.nullable()).max(4096),projects:B(zc.nullable()).max(4096)}),modelLabels:B(H({harness:Lc,model:Rc,label:Rc})).max(4096).optional(),credits:B(H({harness:Lc,model:Rc.nullable(),credits:R().finite().min(0),reportedRequests:K,requests:K})).max(4096).optional(),totals:Bc,daily:B(H({date:Ic,harness:Lc,...Vc})).max(2e5),hourly:B(H({weekday:R().int().min(0).max(6),hour:R().int().min(0).max(23),...Vc})).max(168),byHarness:B(H({harness:Lc,...Vc})).max(256),byModel:B(H({model:Rc.nullable(),...Vc,harnessPricedRequests:K})).max(4096),byProject:B(H({project:zc.nullable(),...Vc})).max(4096),sessions:B(Hc).max(100),recentSessions:B(Hc).max(100).optional()}),V({threadId:G}),V({discarded:z()});let Uc=Do(`type`,[V({id:I().min(1),type:W(`choice`),prompt:I(),options:B(V({value:I().min(1),label:I(),description:I().optional()})).min(1),multiple:z(),allowOther:z(),optional:z()}),V({id:I().min(1),type:W(`text`),prompt:I(),multiline:z(),secret:W(!1),optional:z(),placeholder:I().optional(),prefill:I().optional()})]),Wc=V({interactionId:I().min(1),turnId:I().min(1),title:I().optional(),questions:B(Uc).min(1)}).refine(({questions:e})=>e.some(e=>e.type===`choice`&&e.multiple),{message:`Shared cards require at least one multi-select question`});H({threadId:I().min(1)}),V({questions:B(Wc)}),H({threadId:I().min(1),turnId:I().min(1),interactionId:I().min(1),answers:No(I(),B(I())),cancelled:z().default(!1)}),V({accepted:W(!0)});let Gc=V({path:I(),oldText:I().nullable(),newText:I()});V({sessionId:I().min(1),turn:R().int().nonnegative(),path:I().min(1).optional()}),V({diffs:B(Gc)}),H({}),H({}),V({reference:V({sessionId:I().min(1),epoch:I().min(1),turn:R().int().nonnegative(),seq:R().int().nonnegative(),callId:I().min(1),part:R().int().nonnegative(),version:I().min(1)}),length:R().int().nonnegative(),bytes:R().int().nonnegative()});let Kc=I().min(1).max(128).regex(/^[a-z][a-z0-9]*(?:[._-][a-z0-9]+)*$/u).pipe(xs),qc=Kc.refine(e=>e!==`codex`,`The official Codex identity is reserved`),Jc=I().min(1).max(512).refine(e=>!/[\\\u0000:#?]/u.test(e)&&!e.startsWith(`/`)&&!e.split(`/`).some(e=>e===`..`||e===``),`Plugin resources must be relative paths inside the plugin`),Yc=Ya().refine(e=>/^https:\/\/[^/?#@]+(?:[/?#]|$)/iu.test(e),`Plugin documentation links must be credential-free HTTPS URLs`),Xc=V({en:I().max(4096),"zh-CN":I().max(4096).optional()}).strict(),Zc=V({commands:B(V({terminal:I().max(256),command:I().max(4096)}).strict()).max(8),before:Xc.optional(),after:Xc.optional(),downloads:B(V({label:I().max(128),url:Yc}).strict()).max(8).optional()}).strict(),Qc={id:Kc,name:I().trim().min(1).max(128),version:I().min(1).max(128),kind:W(`usage`).optional(),iconStyle:V({vector:V({viewBox:I().max(128).regex(/^-?\d+(?:\.\d+)?(?: +-?\d+(?:\.\d+)?){3}$/u),color:I().regex(/^(?:currentColor|#[a-f0-9]{6})$/iu),paths:B(V({d:I().min(1).max(32768).regex(/^[MmLlHhVvCcSsQqTtAaZz\d.,+eE\s-]+$/u),fillRule:U([`evenodd`,`nonzero`]).optional(),fill:I().regex(/^(?:currentColor|#[a-f0-9]{6})$/iu).optional()}).strict()).min(1).max(32)}).strict().optional(),background:I().regex(/^#[a-f0-9]{6}$/iu).optional(),borderRadius:R().min(0).max(50).optional(),paddingRatio:R().min(0).max(.25).optional()}).strict().optional(),installation:Zc.optional(),notice:Xc.optional(),launchCommand:W(!0).optional(),links:V({website:Yc.optional(),documentation:Yc.optional(),installation:Yc.optional()}).strict().optional()};V({manifestVersion:W(1),...Qc,adapterApiVersion:R().int().positive(),entry:Jc,icon:Jc.optional()}).strict();let $c=I().max(174828).regex(/^data:image\/(?:png|jpeg|webp|svg\+xml);base64,[A-Za-z0-9+/]+={0,2}$/u),el=V({...Qc,icon:$c.optional()}).strict();V({}).strict(),V({plugins:B(el.extend({id:qc})).max(128)}).strict(),V({version:W(1),enabled:B(Kc).max(128)}).strict().refine(e=>new Set(e.enabled).size===e.enabled.length,{message:`Enabled plugin IDs must be unique`,path:[`enabled`]}),V({harnessId:qc}).strict().extend({enabled:z()}),V({enabled:z()}).strict(),H({title:I().trim().min(1).max(200),type:U([`info`,`warning`,`danger`]),body:I().trim().min(1).max(16384)}),H({}),H({url:I().max(2048).regex(/^http:\/\/(?:127\.0\.0\.1|localhost):\d{1,5}\/(?:\?.*)?$/u)}),Object.freeze(/* @__PURE__ */ `codexhost/console/remote-connections.codexhost/runtime/status.codexhost/remote/ssh-setup.codexhost/harness/plugins/list.codexhost/harness/display-settings/capabilities.codexhost/harness/display-settings/get.codexhost/harness/display-settings/set.codexhost/harness/inspect.codexhost/harness/installation.codexhost/harness/installation/start.codexhost/harness/installation/status.codexhost/harness/launch-settings/get.codexhost/harness/launch-settings/set.codexhost/harness/long-context/get.codexhost/harness/long-context/set.codexhost/harness/web-ui/open.codexhost/harness/accounts/sources.codexhost/harness/accounts/list.codexhost/harness/accounts/inspect.codexhost/harness/credential-imports.codexhost/harness/session-import/sources.codexhost/harness/session-import/list.codexhost/harness/session-import/import.codexhost/account/list.codexhost/account/refresh.codexhost/account/usage/inspect.codexhost/usage/model-prices/get.codexhost/usage/model-prices/set.codexhost/usage/model-prices/default.codexhost/usage/statistics/get.codexhost/update/check.codexhost/update/start.codexhost/update/status`.split(`.`));let tl=U([`idle`,`running`,`busy`,`closing`,`failed`,`blocked`]),nl=U([`none`,`disabled`,`timeout`,`operation`,`background`,`identity`,`persistence`,`closeFailed`]);H({threadId:I(),title:I(),harnessId:I(),state:tl,reason:nl,inactiveMs:R().nonnegative()}),H({threadId:G,turnId:Ss});let rl=V({amount:R().finite().nonnegative(),currency:I().trim().min(1).max(8),label:I().trim().min(1).max(128).optional()}).strict(),il=V({email:I().trim().min(1).max(320).optional(),label:I().trim().min(1).max(256).optional(),plan:I().trim().min(1).max(128).optional(),credits:Ls.optional(),balance:rl.optional()}).strict();function al(e){return e.refine(e=>{let t=e;return t.credits!==void 0||t.balance!==void 0},{message:`Account must report either credits or a balance`})}let ol=al(il),sl={harnessId:xs,harnessName:I().trim().min(1).max(128)},cl=V(sl).strict();V({}).strict(),V({sources:B(cl).max(128)}).strict(),V({harnessId:xs,refresh:z().optional()}).strict(),V({...sl,account:ol.nullable(),accounts:B(ol).max(8).optional()}).strict(),V({refresh:z().optional()}).strict(),V({accounts:B(al(il.extend(sl))).max(128)}).strict(),V({harnessId:qc,model:zs.optional(),thinkingOptionId:Bs.optional(),permissionModeId:ws.optional(),prewarm:W(!0).optional()}).strict();let ll=I().trim().min(1).max(4096).refine(e=>!/[\u0000\r\n]/u.test(e),`Invalid entrypoint path`);V({harnessId:qc}).strict().extend({path:ll.nullable()}),V({path:ll.nullable(),restartRequired:z()}).strict(),V({harnessId:xs,action:U([`check`,`update`,`install`])}).strict();let ul=V({currentVersion:I().min(1).max(128),latestVersion:I().min(1).max(128),updateAvailable:z(),canUpdate:z(),versionKind:U([`cli`,`application`]).optional(),manualUpdateUrl:Ya().max(2048).refine(e=>/^https:\/\/[^/?#@]+(?:[/?#]|$)/iu.test(e),`Manual updates require a credential-free HTTPS URL`).optional(),message:I().max(2048).optional(),messageCode:I().min(1).max(128).optional(),notice:ys.optional(),latestVersionKind:U([`unknown`,`tracking-branch`]).optional()}).strict();V({taskId:I().uuid()}).strict(),Do(`status`,[V({taskId:I().uuid(),status:W(`running`)}).strict(),V({taskId:I().uuid(),status:W(`succeeded`),result:ul}).strict(),V({taskId:I().uuid(),status:W(`failed`),error:V({code:R().int(),message:I().min(1).max(2048)}).strict()}).strict()]);let dl=I().min(1).max(256).regex(/^[A-Za-z0-9._~-]+$/u),fl=I().trim().min(1),pl=U([`api`,`chatgpt`]),ml=/^https?:\/\/(?:\[[0-9a-fA-F:]+\]|[^/\s:@?#]+)(?::\d{1,5})?(?:[/?#][^\s]*)?$/u;function hl(e){return e.length>0&&e.length<=2048&&ml.test(e)}V({url:I().max(2048).refine(hl,`External URL must be http(s)`)}).strict(),V({}).strict();let gl=U([`free`,`go`,`plus`,`pro`,`prolite`,`team`,`self_serve_business_prolite`,`self_serve_business_usage_based`,`business`,`ent26`,`enterprise_cbp_automation`,`enterprise_cbp_usage_based`,`enterprise`,`edu`,`edu_plus`,`edu_pro`,`unknown`]),_l=V({accountId:dl,label:fl.max(256),email:I().email().max(320).optional(),planType:gl.optional(),authKind:pl.optional(),authIdentity:fl.max(256).optional(),siteUrl:I().refine(hl,`Account site URL must be http(s)`).optional()}).strict(),vl=U([`ready`,`unavailable`]);V({version:W(2),currentAccountId:dl.nullable(),phase:vl,revision:R().int().nonnegative(),instanceId:fl.max(1024).optional(),accounts:B(_l).max(1)}).strict(),V({accountId:dl,refresh:z().optional()}).strict(),V({accountId:dl,usage:js.nullable(),accountCredits:Ls.optional(),freshness:U([`live`,`cached`]),observedAt:I().datetime().nullable()}).strict();let yl=1e3,bl=I().refine(e=>e.trim().length>0,`Value must not be empty or whitespace`).refine(e=>!e.includes(`\0`),`Value must not contain NUL`),xl=bl.max(1024),Sl=V({nativeSessionId:xl,title:bl.max(4096).nullable(),updatedAt:R().int().nonnegative().max(864e13),cwd:bl.max(16384),running:z().nullable()}).strict();V({}).strict(),V({harnesses:B(V({harnessId:qc,name:bl.max(128)}).strict()).max(128)}).strict(),V({harnessId:qc,query:I().trim().max(4096).refine(e=>!e.includes(`\0`)).optional(),offset:R().int().nonnegative().safe().optional(),limit:R().int().min(1).max(yl).optional()}).strict(),V({candidates:B(Sl).max(yl),total:R().int().nonnegative().safe()}).strict(),V({harnessId:qc,nativeSessionId:xl}).strict(),V({threadId:bl.max(1024).pipe(G)}).strict();let Cl=I().refine(e=>e.trim().length>0,`Value must not be empty or whitespace`).refine(e=>!e.includes(`\0`),`Value must not contain NUL`),wl=xl,Tl=Sl;V({}).strict(),V({candidates:B(Tl).max(1e3)}).strict(),V({nativeSessionId:wl}).strict(),V({threadId:Cl.max(1024).pipe(G)}).strict(),V({threadId:G,lastTurnId:Ss}).strict(),V({threadId:G}).strict();let El=I().trim().min(1).max(128).regex(/^[A-Za-z0-9._:-]+$/u).brand();V({commands:B(V({id:El,invocation:I().min(1).max(128),label:I().trim().min(1).max(128),description:I().trim().min(1).max(512).optional(),localizations:vs.optional(),argumentMode:U([`none`,`text`]),kind:U([`command`,`skill`]).optional()}).strict()),warnings:B(I().min(1)).optional(),source:U([`live`,`static`]).optional()}).strict().superRefine((e,t)=>{let n=/* @__PURE__ */ new Set;for(let[r,i]of e.commands.entries())n.has(i.id)&&t.addIssue({code:`custom`,message:`Harness command IDs must be unique`,path:[`commands`,r,`id`]}),n.add(i.id)}),V({harnessId:xs,cwd:I().min(1).optional()}).strict(),V({threadId:G}).strict(),V({threadId:G,commandId:El,turnId:Ss.optional(),arguments:ms.optional()}).strict(),V({accepted:W(!0),turnId:Ss.optional()}).strict();let Dl=W(`2.0`).optional(),Ol=xo().optional(),kl=I().min(1),Al=To([I(),R().int()]),jl=V({code:R().int(),message:I(),data:ps.optional()}).catchall(ps).superRefine(cs([`data`]));To([V({jsonrpc:Dl,id:Al,method:kl,params:ps.optional(),result:Ol,error:Ol}).catchall(ps).superRefine(cs([`jsonrpc`,`params`,`result`,`error`])),V({jsonrpc:Dl,id:Ol,method:kl,params:ps.optional(),result:Ol,error:Ol}).catchall(ps).superRefine(cs([`jsonrpc`,`id`,`params`,`result`,`error`])),V({jsonrpc:Dl,id:Al,method:Ol,params:Ol,result:ps,error:Ol}).catchall(ps).superRefine(cs([`jsonrpc`,`method`,`params`,`error`])),V({jsonrpc:Dl,id:Al,method:Ol,params:Ol,result:Ol,error:jl}).catchall(ps).superRefine(cs([`jsonrpc`,`method`,`params`,`result`]))]);let Ml=I().refine(e=>e.trim().length>0,{message:`Native identifier must not be empty or whitespace`});H({harnessId:xs,nativeSessionId:Ml,locator:ps.optional(),formatVersion:W(1)}).superRefine(cs([`locator`])),H({harnessId:xs,nativeSessionId:Ml,nativeTurnKey:Ml,formatVersion:W(1)}),H({harnessId:xs,nativeSessionId:Ml,checkpointId:Ml,locator:ps.optional(),formatVersion:W(1)}).superRefine(cs([`locator`]));let Nl=I().regex(/^\d+\.\d+\.\d+(?:-[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?(?:\+[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/u),Pl=U([`npm`,`windows-installer`,`macos-dmg`]),Fl=H({version:Nl,installation:Pl,phase:U([`prepared`,`downloading`,`waiting-for-exit`,`installing`,`restarting`,`succeeded`,`failed`]),updatedAt:R().int().nonnegative(),downloadedBytes:R().int().nonnegative().optional(),totalBytes:R().int().positive().optional(),error:I().min(1).max(500).nullable(),serviceStopOutput:I().optional()}).superRefine((e,t)=>{e.downloadedBytes!==void 0&&e.totalBytes!==void 0&&e.downloadedBytes>e.totalBytes&&t.addIssue({code:`custom`,path:[`downloadedBytes`],message:`downloadedBytes must not exceed totalBytes`})});H({});let Il=I().max(300).regex(/^https:\/\/github\.com\/(LiberSeek|LIBERSEEK)\/BOFT-CLI\/releases\/tag\/v[0-9A-Za-z.+-]+$/u,`release notes URL must identify a codexhost GitHub Release`);H({currentVersion:Nl,installation:Pl.nullable(),latestVersion:Nl.nullable(),updateAvailable:z(),installationAvailable:z(),releaseNotes:I().min(1).max(2e4).nullable(),releaseNotesUrl:Il.nullable(),status:Fl.nullable(),error:I().min(1).max(500).nullable()}),H({status:Fl}),H({status:Fl.nullable()});let Ll=RegExp(String.raw`^- \[([^\]\n]+)\]\(thread://([^\s()<>"?#/]+)\): `+`(${[`completed`,`failed`,`interrupted`,`timedOut`,`unreadable`,`notFound`].join(`|`)})(?:\. (.+))?$`,`u`);function Rl(e){let[t,...n]=e.trim().split(/\r?\n/u);if(t!==`[codexhost thread watch] Read each Thread's result, then continue your task:`)return;let r=[];for(let e of n){if(!e.trim())continue;let t=Ll.exec(e);if(!t)return;let[,n=``,i=``,a,o]=t;r.push({threadId:i,label:n,outcome:a,...o?{note:o}:{}})}return r.length>0?r:void 0}let zl=U([`idle`,`installing`,`restarting`,`succeeded`,`failed`]);V({runningVersion:I().nullable(),installedVersion:I().nullable(),restartRequired:z(),remote:z(),updateSupported:z(),update:V({phase:zl,targetVersion:I().nullable(),error:I().nullable()})});let Bl=V({version:I().regex(/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/u)}).strict();V({hostname:I().min(1).max(1024).refine(e=>!e.startsWith(`-`)&&!/\s/u.test(e)),port:R().int().min(1).max(65535).nullable(),identity:I().max(4096).nullable(),action:U([`inspect`,`install`,`update`,`repair`,`uninstall`]),uninstallPackage:z().optional(),version:I().regex(/^\d+\.\d+\.\d+$/u).nullable()}).strict(),V({state:U([`installed`,`not-installed`])}).strict();let Vl=I().min(1).max(1024),Hl={hostId:Vl.regex(/^remote-(?:ssh(?:-|:)|control:)/u)},Ul={...Hl,threadId:Vl},Wl=Do(`kind`,[H({kind:W(`hosts`)}),H({kind:W(`list`),...Hl,cursor:I().nullable(),archived:z()}),H({kind:W(`read`),...Ul}),H({kind:W(`configure`),...Ul,epoch:Vl,modelId:Vl.optional(),thinkingOptionId:Vl.optional(),permissionModeId:Vl.optional()}).refine(e=>[e.modelId,e.thinkingOptionId,e.permissionModeId].filter(e=>e!==void 0).length===1,`Select exactly one remote setting`),H({kind:W(`prompt`),...Ul,epoch:Vl,text:I().min(1).max(8e3),requestId:Vl.optional()}),H({kind:W(`interrupt`),...Ul,epoch:Vl,turnId:Vl}),H({kind:W(`rename`),...Ul,epoch:Vl,name:I().min(1).max(512)}),H({kind:W(`archive`),...Ul,epoch:Vl,archived:z()}),H({kind:W(`respond`),...Ul,epoch:Vl,requestId:To([Vl,R().int()]),result:No(I(),yo())})]),Gl=I().min(1).max(1024),Kl=V({hostId:Gl,displayName:I().min(1).max(1024),source:U([`codex-managed`,`discovered`]),sshAlias:I().max(1024).nullable(),sshHost:I().min(1).max(1024),sshPort:R().int().min(1).max(65535).nullable(),identity:I().max(4096).nullable(),autoConnect:z(),connectionAnalyticsId:I().max(1024).optional()}),ql=H({displayName:I().min(1).max(1024),hostname:I().min(1).max(1024),sshPort:R().int().min(1).max(65535).nullable(),identity:I().max(4096).nullable()});Do(`action`,[H({action:W(`session`),operation:Wl}),H({action:W(`list`)}),H({action:W(`catalog`)}),H({action:W(`read-thread`),hostId:Gl.refine(e=>e!==`local`),input:gc}),H({action:W(`save`),draft:ql,previous:Kl.nullable()}),H({action:W(`remove`),previous:Kl}),H({action:W(`connect`),hostId:Gl,enabled:z()}),H({action:W(`state`),hostId:Gl}),H({action:W(`runtime`),hostId:Gl}),H({action:W(`update`),hostId:Gl.refine(e=>e!==`local`),version:Bl.shape.version})]),To([H({result:ps}),H({error:H({code:R().int(),message:I()})})]);let Jl=I().max(214).regex(/^(?:@[a-z0-9][a-z0-9._-]*\/)?[a-z0-9][a-z0-9._-]*$/u),Yl=To([I(),V({en:I()}).catchall(I())]),Xl=V({title:Yl.optional(),description:Yl.optional(),icon:I().max(349592).regex(/^data:image\/(?:svg\+xml|png|jpeg|webp);base64,[A-Za-z0-9+/]*={0,2}$/u).optional(),error:I().optional()});V({extensions:B(V({id:Jl,name:I().min(1).max(214),version:I().min(1).max(128),format:W(`dsh`),supportedTargets:jo([W(`web`)]),enabledTargets:B(W(`web`)).max(1),source:I().min(1).max(4096),projectUrl:I().max(4096).url({protocol:/^https?$/u}).optional(),installedAt:I(),meta:Xl.optional(),loadError:I().optional()})),loadedIds:B(Jl),safeMode:z(),storeError:I().optional()});let Zl=I().trim().max(2048).url({protocol:/^https?$/u,normalize:!0}).refine(e=>!/[\s\\?#]/u.test(e)&&!e.split(`/`)[2]?.includes(`@`),`Use an HTTP(S) registry URL without credentials, a query, or a fragment.`).transform(e=>e.endsWith(`/`)?e:`${e}/`);V({spec:I().trim().min(1).max(4096),registry:Zl.optional()}).strict(),V({id:Jl,enabled:z()}).strict(),V({id:Jl}).strict(),W(1);let Ql=`@deepseek-ai/dsh-client-ui-chat/ThreadWatchNotice.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(Ql)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=Ql,e.textContent=`._5CV-Fq_card{box-sizing:border-box;border:1px solid var(--dsw-alias-border-l2);border-radius:var(--dsw-radius-lg);background:var(--dsw-alias-bg-base);width:fit-content;max-width:100%;color:var(--dsw-alias-label-secondary);font-size:var(--dsh-content-font-size-secondary,13px);align-items:flex-start;gap:10px;padding:10px 14px;line-height:20px;display:flex}._5CV-Fq_list{min-width:0;margin:0;padding:0;list-style:none}._5CV-Fq_entry+._5CV-Fq_entry{margin-top:10px}._5CV-Fq_line{align-items:center;gap:8px;min-width:0;display:flex}._5CV-Fq_line>svg,._5CV-Fq_bell{flex-shrink:0}._5CV-Fq_bell{color:var(--dsw-alias-label-tertiary);margin-top:3px}._5CV-Fq_title{text-overflow:ellipsis;white-space:nowrap;min-width:0;color:var(--dsw-alias-label-primary);overflow:hidden}._5CV-Fq_outcome,._5CV-Fq_open{white-space:nowrap;flex-shrink:0}._5CV-Fq_outcome[data-outcome=completed]{color:var(--dsw-alias-state-success-primary)}._5CV-Fq_outcome[data-outcome=failed]{color:var(--dsw-alias-state-error-primary)}._5CV-Fq_open a{color:var(--dsw-alias-state-business-primary);text-decoration:none}._5CV-Fq_open a:hover{text-decoration:underline}._5CV-Fq_open a:focus-visible{outline:2px solid var(--dsw-alias-state-business-primary);outline-offset:2px}._5CV-Fq_note{color:var(--dsw-alias-label-tertiary);overflow-wrap:anywhere;margin:4px 0 0 24px}@media (width<=480px){._5CV-Fq_line{flex-wrap:wrap}._5CV-Fq_title{flex:calc(100% - 52px)}._5CV-Fq_outcome{margin-left:24px}}`,document.head.appendChild(e)}var $l={bell:`_5CV-Fq_bell`,card:`_5CV-Fq_card`,entry:`_5CV-Fq_entry`,line:`_5CV-Fq_line`,list:`_5CV-Fq_list`,note:`_5CV-Fq_note`,open:`_5CV-Fq_open`,outcome:`_5CV-Fq_outcome`,title:`_5CV-Fq_title`};let eu=()=>()=>{};function tu({entry:e,links:t,t:n}){let r=`codex://threads/${e.threadId}`,i=()=>t?.describe?.(r)?.title,a=(0,d.useSyncExternalStore)(t?.resolve.subscribe??eu,i,i),o=a!==void 0;return/* @__PURE__ */ (0,f.jsxs)(`li`,{className:$l.entry,"data-thread-watch-entry":e.threadId,children:[/* @__PURE__ */ (0,f.jsxs)(`div`,{className:$l.line,children:[o?t?.describe?.(r)?.icon:/* @__PURE__ */ (0,f.jsx)(p.ReferenceIconRegular,{kind:`session`,size:14}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:$l.title,title:a??e.label,children:a??e.label}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:$l.outcome,"data-outcome":e.outcome,children:n(`message.watch.${e.outcome}`)}),o&&/* @__PURE__ */ (0,f.jsx)(`span`,{className:$l.open,children:/* @__PURE__ */ (0,f.jsx)(p.MarkdownAnchor,{href:r,glyph:!1,children:[n(`message.watch.open`)]})})]}),e.note!==void 0&&/* @__PURE__ */ (0,f.jsx)(`div`,{className:$l.note,children:e.note})]})}function nu({entries:e,links:t,t:n}){return/* @__PURE__ */ (0,f.jsxs)(`div`,{className:$l.card,"data-thread-watch-notice":!0,children:[/* @__PURE__ */ (0,f.jsx)(p.IconBellOutlineRegular,{className:$l.bell}),/* @__PURE__ */ (0,f.jsx)(`ul`,{className:$l.list,children:e.map((e,r)=>/* @__PURE__ */ (0,f.jsx)(tu,{entry:e,links:t,t:n},r))})]})}function ru(e){return{code:{copyLabel:e(`copy`),copiedLabel:e(`copied`),toolbarLabels:{codeLabel:e(`codeBlock.title`),wrapLabel:e(`codeBlock.wrap`),unwrapLabel:e(`codeBlock.unwrap`)}},footnotes:e(`markdown.footnotes`)}}let iu=`@deepseek-ai/dsh-client-ui-chat/MessageItem.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(iu)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=iu,e.textContent=`._1ED1FG_userRow{flex-direction:column;align-items:flex-end;gap:6px;display:flex}._1ED1FG_noticeRow{flex-direction:column;align-items:center;gap:6px;min-width:0;display:flex}._1ED1FG_noticeStack{min-width:0;max-width:100%}._1ED1FG_userStack{min-width:0;max-width:min(calc(var(--dsh-chat-content-width,748px) * .702), 82%);flex-direction:column;align-items:flex-end;gap:8px;display:flex}._1ED1FG_bubble{background:var(--dsw-specific-bubble);border-radius:var(--dsw-radius-xl);max-width:100%;font-size:var(--dsh-content-font-size,14px);line-height:calc(22px + var(--dsh-content-font-delta,0px));color:var(--dsw-alias-label-primary);white-space:pre-wrap;word-break:break-word;padding:10px 16px}._1ED1FG_referenceSummary{color:var(--dsw-alias-label-tertiary);font-size:var(--dsh-content-font-size-secondary,13px);line-height:calc(18px + var(--dsh-content-font-delta-secondary,0px))}._1ED1FG_contextRow{padding:2px 0}._1ED1FG_compactionRow{--dsh-compaction-header-height:calc(24px + var(--dsh-content-font-delta,0px));padding:2px 0}._1ED1FG_compactionButton{width:100%;height:var(--dsh-compaction-header-height);border-radius:var(--dsw-radius-sm);min-width:0;color:var(--dsw-alias-label-tertiary);font:inherit;text-align:left;background:0 0;border:none;align-items:center;padding:0;transition:color .1s;display:flex}._1ED1FG_compactionRow:has(._1ED1FG_compactionBody) ._1ED1FG_compactionButton{z-index:7;background:var(--dsw-alias-bg-base);border-radius:0;position:sticky;top:0}._1ED1FG_compactionBody :has(>[data-code-block-banner]){top:var(--dsh-compaction-header-height)}._1ED1FG_compactionRow:has(._1ED1FG_compactionBody) ._1ED1FG_compactionButton:hover{background:var(--dsw-alias-interactive-bg-hover-solid)}._1ED1FG_compactionButton:not(:disabled){cursor:pointer}._1ED1FG_compactionButton:hover{color:var(--dsw-alias-label-secondary)}._1ED1FG_compactionButton:not(:disabled):hover{background:var(--dsw-alias-interactive-bg-hover)}._1ED1FG_compactionLeading{width:calc(16px + var(--dsh-content-font-delta,0px));height:calc(16px + var(--dsh-content-font-delta,0px));color:inherit;flex:none;place-items:center;margin-right:6px;display:inline-grid}._1ED1FG_compactionLeading svg{width:calc(14px + var(--dsh-content-font-delta,0px));height:calc(14px + var(--dsh-content-font-delta,0px))}._1ED1FG_compactionContextIcon,._1ED1FG_compactionDisclosureIcon{grid-area:1/1;justify-content:center;align-items:center;display:inline-flex}._1ED1FG_compactionDisclosureIcon,._1ED1FG_compactionButton:not(:disabled):hover ._1ED1FG_compactionContextIcon,._1ED1FG_compactionButton:not(:disabled):focus-visible ._1ED1FG_compactionContextIcon{opacity:0}._1ED1FG_compactionButton:not(:disabled):hover ._1ED1FG_compactionDisclosureIcon,._1ED1FG_compactionButton:not(:disabled):focus-visible ._1ED1FG_compactionDisclosureIcon{opacity:1}._1ED1FG_compactionTitle{font-size:var(--dsh-content-font-size-secondary,13px);line-height:calc(24px + var(--dsh-content-font-delta,0px));color:inherit;flex:none}._1ED1FG_compactionSep{background:var(--dsw-alias-label-caption);border-radius:1px;flex:none;width:2px;height:2px;margin:0 8px}._1ED1FG_compactionSummary{min-width:0;color:inherit;font-size:var(--dsh-content-font-size-secondary,13px);line-height:calc(24px + var(--dsh-content-font-delta,0px));text-overflow:ellipsis;white-space:nowrap;flex:auto;overflow:hidden}._1ED1FG_compactionBody{padding:4px 0 4px calc(22px + var(--dsh-content-font-delta,0px));color:var(--dsw-alias-label-tertiary);font-size:var(--dsh-content-font-size-secondary,13px);line-height:calc(24px + var(--dsh-content-font-delta,0px))}._1ED1FG_retryRow{color:var(--dsw-alias-label-tertiary);font-size:var(--dsh-content-font-size-secondary,13px);line-height:calc(20px + var(--dsh-content-font-delta-secondary,0px))}._1ED1FG_retrySummary{border-radius:var(--dsw-radius-sm);width:fit-content;max-width:100%;color:inherit;cursor:pointer;user-select:none;align-items:center;gap:7px;padding:2px 0;list-style:none;display:inline-flex}._1ED1FG_retrySummary::-webkit-details-marker{display:none}._1ED1FG_retrySummary:after{content:"";border-bottom:1.5px solid;border-right:1.5px solid;flex:none;width:6px;height:6px;margin-right:2px;transition:transform .12s;transform:rotate(-45deg)}._1ED1FG_retrySummary:hover{color:var(--dsw-alias-label-secondary)}@media (prefers-reduced-motion:reduce){._1ED1FG_compactionButton{transition:none}}._1ED1FG_retrySummary:focus-visible{outline:1.5px solid var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary));outline-offset:2px}._1ED1FG_retryText{overflow-wrap:anywhere;min-width:0}._1ED1FG_retryRow[open] ._1ED1FG_retrySummary:after{transform:rotate(45deg)}._1ED1FG_retryDetails{overflow-wrap:anywhere;font-size:var(--dsh-content-font-size-secondary,13px);line-height:calc(18px + var(--dsh-content-font-delta-secondary,0px));gap:2px;margin-top:3px;padding-left:14px;display:grid}._1ED1FG_retryDetailLabel{color:var(--dsw-alias-label-secondary)}._1ED1FG_turnErrorRow{font-size:var(--dsh-content-font-size-secondary,13px);line-height:calc(20px + var(--dsh-content-font-delta-secondary,0px));grid-template-columns:10px minmax(0,1fr) auto;align-items:start;gap:8px;padding:2px 0;display:grid}._1ED1FG_turnErrorDot{margin-top:5px}._1ED1FG_turnErrorCopy{overflow-wrap:anywhere;min-width:0}._1ED1FG_turnErrorTitle{color:var(--dsw-alias-state-error-primary);margin-right:6px;font-weight:600}._1ED1FG_turnErrorMessage{color:var(--dsw-alias-label-secondary)}._1ED1FG_turnErrorCode{color:var(--dsw-alias-label-tertiary);font:var(--dsw-font-markdown-code-block-small)}._1ED1FG_maxTokensTitle{color:var(--dsw-alias-state-warn-primary);margin-right:6px;font-weight:600}._1ED1FG_attachmentRow{flex-wrap:wrap;justify-content:flex-end;gap:8px;max-width:100%;display:flex}._1ED1FG_pendingAttachment{flex-direction:column;align-items:flex-end;gap:4px;min-width:0;display:flex}._1ED1FG_fileCard{border:.5px solid var(--dsw-alias-border-l2,#0000001f);border-radius:var(--dsw-radius-xl);background:var(--dsw-specific-input-major,transparent);box-sizing:border-box;flex:none;align-items:center;gap:10px;width:240px;min-height:64px;padding:8px 12px;display:inline-flex}._1ED1FG_fileIcon{flex:none;width:28px;height:28px}._1ED1FG_fileContent{flex-direction:column;flex:1;min-width:0;display:flex}._1ED1FG_fileName{white-space:nowrap;text-overflow:ellipsis;color:var(--dsw-alias-label-primary);font-size:14px;font-weight:500;line-height:22px;overflow:hidden}._1ED1FG_fileMeta{white-space:nowrap;text-overflow:ellipsis;color:var(--dsw-alias-label-tertiary,#00000073);font-size:12px;line-height:15px;overflow:hidden}._1ED1FG_editAction{color:inherit;cursor:pointer;border-radius:var(--dsw-radius-sm);background:0 0;border:0;justify-content:center;align-items:center;width:28px;height:28px;padding:6px;display:inline-flex}._1ED1FG_editAction:hover{background:var(--dsw-alias-interactive-bg-hover)}._1ED1FG_editAction svg{width:15px;height:15px}._1ED1FG_userStack:has(._1ED1FG_sentEditor){width:100%}._1ED1FG_sentEditor{box-sizing:border-box;border:1px solid var(--dsw-alias-border-main);border-radius:12px;width:100%;min-width:0;padding:12px}._1ED1FG_sentEditor textarea{resize:vertical;width:100%;min-height:100px;color:inherit;font:inherit;box-sizing:border-box;background:0 0;border:0;outline:0;line-height:1.6}._1ED1FG_sentEditor:focus-within{outline:1.5px solid var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary))}._1ED1FG_sentEditorActions{justify-content:flex-end;gap:8px;margin-top:8px;display:flex}`,document.head.appendChild(e)}var q={attachmentRow:`_1ED1FG_attachmentRow`,bubble:`_1ED1FG_bubble`,compactionBody:`_1ED1FG_compactionBody`,compactionButton:`_1ED1FG_compactionButton`,compactionContextIcon:`_1ED1FG_compactionContextIcon`,compactionDisclosureIcon:`_1ED1FG_compactionDisclosureIcon`,compactionLeading:`_1ED1FG_compactionLeading`,compactionRow:`_1ED1FG_compactionRow`,compactionSep:`_1ED1FG_compactionSep`,compactionSummary:`_1ED1FG_compactionSummary`,compactionTitle:`_1ED1FG_compactionTitle`,contextRow:`_1ED1FG_contextRow`,editAction:`_1ED1FG_editAction`,fileCard:`_1ED1FG_fileCard`,fileContent:`_1ED1FG_fileContent`,fileIcon:`_1ED1FG_fileIcon`,fileMeta:`_1ED1FG_fileMeta`,fileName:`_1ED1FG_fileName`,maxTokensTitle:`_1ED1FG_maxTokensTitle`,noticeRow:`_1ED1FG_noticeRow`,noticeStack:`_1ED1FG_noticeStack`,pendingAttachment:`_1ED1FG_pendingAttachment`,referenceSummary:`_1ED1FG_referenceSummary`,retryDetailLabel:`_1ED1FG_retryDetailLabel`,retryDetails:`_1ED1FG_retryDetails`,retryRow:`_1ED1FG_retryRow`,retrySummary:`_1ED1FG_retrySummary`,retryText:`_1ED1FG_retryText`,sentEditor:`_1ED1FG_sentEditor`,sentEditorActions:`_1ED1FG_sentEditorActions`,turnErrorCode:`_1ED1FG_turnErrorCode`,turnErrorCopy:`_1ED1FG_turnErrorCopy`,turnErrorDot:`_1ED1FG_turnErrorDot`,turnErrorMessage:`_1ED1FG_turnErrorMessage`,turnErrorRow:`_1ED1FG_turnErrorRow`,turnErrorTitle:`_1ED1FG_turnErrorTitle`,userRow:`_1ED1FG_userRow`,userStack:`_1ED1FG_userStack`};let au=(0,d.memo)(function({node:e,title:t,fallbackSummary:n,t:r}){let[i,a]=(0,d.useState)(!1),o=(0,d.useMemo)(()=>ru(r),[r]),s=e.summary!==null,c=s&&i,l=e.shadowedItemCount!==null&&e.shadowedTokenCount!==null?r(`message.compaction.completed`,{items:e.shadowedItemCount,tokens:e.shadowedTokenCount}):n??r(s?`message.compaction.expand`:`message.compaction.unavailable`);return/* @__PURE__ */ (0,f.jsxs)(`div`,{className:q.compactionRow,children:[/* @__PURE__ */ (0,f.jsxs)(`button`,{type:`button`,className:q.compactionButton,disabled:!s,"aria-expanded":s?c:void 0,onClick:()=>{a(e=>!e)},children:[/* @__PURE__ */ (0,f.jsxs)(`span`,{className:q.compactionLeading,"aria-hidden":!0,children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:q.compactionContextIcon,"data-compaction-icon":`context`,children:/* @__PURE__ */ (0,f.jsx)(p.IconApiOutlineRegular,{})}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:q.compactionDisclosureIcon,"data-compaction-disclosure":c?`expanded`:`collapsed`,children:c?/* @__PURE__ */ (0,f.jsx)(p.IconChevronDownOutlineRegular,{}):/* @__PURE__ */ (0,f.jsx)(p.IconChevronRightOutlineRegular,{})})]}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:q.compactionTitle,children:t??r(`message.compaction`)}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:q.compactionSep,"aria-hidden":!0}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:q.compactionSummary,children:l})]}),c&&e.summary!==null&&/* @__PURE__ */ (0,f.jsx)(`div`,{className:q.compactionBody,children:/* @__PURE__ */ (0,f.jsx)(p.MarkdownText,{text:e.summary,labels:o})})]})}),ou=`@deepseek-ai/dsh-client-ui-chat/ContextBody.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(ou)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=ou,e.textContent=`.H8WTnW_text{color:var(--dsw-alias-label-secondary);font:inherit;white-space:pre-wrap;overflow-wrap:anywhere;margin:0}.H8WTnW_fields{border-top:.5px solid var(--dsw-alias-border-l2);flex-direction:column;gap:2px;margin:8px 0 0;padding-top:8px;display:flex}.H8WTnW_field{gap:8px;min-width:0;display:flex}.H8WTnW_fieldKey{min-width:96px;color:var(--dsw-alias-label-caption);flex:none}.H8WTnW_fieldValue{min-width:0;color:var(--dsw-alias-label-tertiary);overflow-wrap:anywhere;flex:auto;margin:0}.H8WTnW_files{flex-wrap:wrap;gap:4px 12px;margin:0 0 8px;padding:0;list-style:none;display:flex}.H8WTnW_file{align-items:baseline;gap:6px;min-width:0;display:flex}.H8WTnW_filePath{color:var(--dsw-alias-label-secondary);overflow-wrap:anywhere}.H8WTnW_fileAction{color:var(--dsw-alias-label-caption)}.H8WTnW_catalogNotice{color:var(--dsw-alias-label-caption);margin:0 0 6px}.H8WTnW_entries{flex-direction:column;gap:4px;margin:0;padding:0;list-style:none;display:flex}.H8WTnW_entry{gap:8px;min-width:0;display:flex}.H8WTnW_entryName{color:var(--dsw-alias-label-secondary);flex:none}.H8WTnW_entryDescription{min-width:0;color:var(--dsw-alias-label-tertiary);text-overflow:ellipsis;white-space:nowrap;flex:auto;overflow:hidden}.H8WTnW_sections{flex-direction:column;gap:8px;margin:0;display:flex}.H8WTnW_section{flex-direction:column;gap:2px;min-width:0;display:flex}.H8WTnW_sectionName{color:var(--dsw-alias-label-caption)}.H8WTnW_sectionText{color:var(--dsw-alias-label-secondary);white-space:pre-wrap;overflow-wrap:anywhere;margin:0}.H8WTnW_relaySender{color:var(--dsw-alias-label-caption);overflow-wrap:anywhere;margin:0 0 6px}.H8WTnW_recalls{flex-direction:column;gap:2px;margin:0 0 8px;padding:0;list-style:none;display:flex}.H8WTnW_recall{gap:8px;min-width:0;display:flex}.H8WTnW_recallLabel{color:var(--dsw-alias-label-secondary);overflow-wrap:anywhere}.H8WTnW_recallCounts{color:var(--dsw-alias-label-caption);flex:none}`,document.head.appendChild(e)}var J={catalogNotice:`H8WTnW_catalogNotice`,entries:`H8WTnW_entries`,entry:`H8WTnW_entry`,entryDescription:`H8WTnW_entryDescription`,entryName:`H8WTnW_entryName`,field:`H8WTnW_field`,fieldKey:`H8WTnW_fieldKey`,fieldValue:`H8WTnW_fieldValue`,fields:`H8WTnW_fields`,file:`H8WTnW_file`,fileAction:`H8WTnW_fileAction`,filePath:`H8WTnW_filePath`,files:`H8WTnW_files`,recall:`H8WTnW_recall`,recallCounts:`H8WTnW_recallCounts`,recallLabel:`H8WTnW_recallLabel`,recalls:`H8WTnW_recalls`,relaySender:`H8WTnW_relaySender`,section:`H8WTnW_section`,sectionName:`H8WTnW_sectionName`,sectionText:`H8WTnW_sectionText`,sections:`H8WTnW_sections`,text:`H8WTnW_text`};let su=2e4;function cu(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:null}function lu(e){let t=[];for(let n of e){if(n.type!==`text`){t.push({block:n});continue}let e=t[t.length-1];e!==void 0&&`text`in e?e.text+=n.text:t.push({text:n.text})}return t}function uu(e){return lu(e).flatMap(e=>`block`in e?[e.block]:[])}function du(e,t){return e.length>su?`${e.slice(0,su)}\n${t(`json.truncated`,{total:e.length})}`:e}function fu(e,t){return du(typeof e==`string`?e:typeof e==`number`||typeof e==`boolean`?String(e):JSON.stringify(e),t)}function pu({source:e,formRendered:t,t:n}){let r=cu(e);if(r===null)return null;let i=t?[`kind`,`form`]:[`kind`],a=Object.entries(r).filter(([e])=>!i.includes(e));return a.length===0?null:/* @__PURE__ */ (0,f.jsx)(`dl`,{className:J.fields,"data-context-fields":!0,children:a.map(([e,t])=>/* @__PURE__ */ (0,f.jsxs)(`div`,{className:J.field,children:[/* @__PURE__ */ (0,f.jsx)(`dt`,{className:J.fieldKey,children:e}),/* @__PURE__ */ (0,f.jsx)(`dd`,{className:J.fieldValue,children:fu(t,n)})]},e))})}function mu({blocks:e,t}){return/* @__PURE__ */ (0,f.jsx)(f.Fragment,{children:e.map((e,n)=>/* @__PURE__ */ (0,f.jsx)(p.JsonBlock,{label:t(`message.unknownBlock`),payload:e,truncatedLabel:e=>t(`json.truncated`,{total:e})},n))})}function hu({content:e,t}){return/* @__PURE__ */ (0,f.jsx)(f.Fragment,{children:lu(e).map((e,n)=>`text`in e?e.text!==``&&/* @__PURE__ */ (0,f.jsx)(`pre`,{className:J.text,"data-context-text":!0,children:du(e.text,t)},n):/* @__PURE__ */ (0,f.jsx)(p.JsonBlock,{label:t(`message.unknownBlock`),payload:e.block,truncatedLabel:e=>t(`json.truncated`,{total:e})},n))})}function gu({content:e,source:t,t:n}){return/* @__PURE__ */ (0,f.jsxs)(f.Fragment,{children:[/* @__PURE__ */ (0,f.jsx)(hu,{content:e,t:n}),/* @__PURE__ */ (0,f.jsx)(pu,{source:t,formRendered:!1,t:n})]})}function _u(e){let t=cu(e),n=t===null?void 0:t.changes;if(!Array.isArray(n))return null;let r=[],i=/* @__PURE__ */ new Set;for(let e of n){let t=cu(e);if(t===null)return null;let n=t.path;if(typeof n!=`string`||n===``)return null;let a=t.action;if(a!==`set`&&a!==`replace`&&a!==`remove`)return null;let o=t.digest;i.has(n)||(i.add(n),r.push({action:a,path:n,...typeof o==`string`?{digest:o}:{}}))}return r.length===0?null:r}function vu(e,t){return e===`remove`?`message.context.instructions.removed`:t?`message.context.instructions.loaded`:e===`set`?`message.context.instructions.added`:`message.context.instructions.updated`}function yu({content:e,source:t,t:n}){let r=_u(t);if(r===null)return/* @__PURE__ */ (0,f.jsx)(gu,{content:e,source:t,t:n});let i=cu(t)?.baseline===!0;return/* @__PURE__ */ (0,f.jsxs)(f.Fragment,{children:[/* @__PURE__ */ (0,f.jsx)(`ul`,{className:J.files,"data-context-files":!0,children:r.map(e=>/* @__PURE__ */ (0,f.jsxs)(`li`,{className:J.file,title:e.digest,children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:J.filePath,children:e.path}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:J.fileAction,children:n(vu(e.action,i))})]},e.path))}),/* @__PURE__ */ (0,f.jsx)(hu,{content:e,t:n})]})}function bu(e){let t=cu(e),n=t===null?void 0:t.entries;if(!Array.isArray(n))return null;let r=[];for(let e of n){let t=cu(e);if(t===null)return null;let n=t.name,i=t.description;if(typeof n!=`string`||n===``||typeof i!=`string`)return null;r.push({name:n,description:i})}return r}function xu({content:e,source:t,t:n}){let r=bu(t);if(r===null)return/* @__PURE__ */ (0,f.jsx)(gu,{content:e,source:t,t:n});let i=cu(t)?.update===!0,a=r.slice(0,200),o=uu(e);return/* @__PURE__ */ (0,f.jsxs)(f.Fragment,{children:[i&&/* @__PURE__ */ (0,f.jsx)(`p`,{className:J.catalogNotice,"data-context-catalog-update":!0,children:n(`message.context.catalog.replaced`)}),/* @__PURE__ */ (0,f.jsx)(`ul`,{className:J.entries,"data-context-entries":!0,children:a.map((e,t)=>/* @__PURE__ */ (0,f.jsxs)(`li`,{className:J.entry,children:[/* @__PURE__ */ (0,f.jsx)(`code`,{className:J.entryName,children:e.name}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:J.entryDescription,children:e.description})]},t))}),a.length<r.length&&/* @__PURE__ */ (0,f.jsx)(`p`,{className:J.catalogNotice,"data-context-entries-truncated":!0,children:n(`message.context.catalog.more`,{count:r.length-a.length})}),/* @__PURE__ */ (0,f.jsx)(mu,{blocks:o,t:n})]})}function Su(e){let t=cu(e),n=t===null?void 0:t.sections;if(!Array.isArray(n))return null;let r=[];for(let e of n){let t=cu(e);if(t===null)return null;let n=t.name,i=t.text;if(typeof n!=`string`||n===``||typeof i!=`string`)return null;r.push({name:n,text:i})}return r.length===0?null:r}function Cu({content:e,source:t,t:n}){let r=Su(t);return r===null?/* @__PURE__ */ (0,f.jsx)(gu,{content:e,source:t,t:n}):/* @__PURE__ */ (0,f.jsxs)(f.Fragment,{children:[/* @__PURE__ */ (0,f.jsx)(`p`,{className:J.catalogNotice,"data-context-snapshot-supersedes":!0,children:n(`message.context.snapshot.supersedes`)}),/* @__PURE__ */ (0,f.jsx)(`dl`,{className:J.sections,"data-context-sections":!0,children:r.map((e,t)=>/* @__PURE__ */ (0,f.jsxs)(`div`,{className:J.section,children:[/* @__PURE__ */ (0,f.jsx)(`dt`,{className:J.sectionName,children:e.name}),/* @__PURE__ */ (0,f.jsx)(`dd`,{className:J.sectionText,children:du(e.text,n)})]},t))})]})}function wu({content:e,t}){return/* @__PURE__ */ (0,f.jsx)(hu,{content:e,t})}function Tu({content:e,source:t,t:n}){let r=Eu(t);return r===null?/* @__PURE__ */ (0,f.jsx)(gu,{content:e,source:t,t:n}):/* @__PURE__ */ (0,f.jsxs)(f.Fragment,{children:[/* @__PURE__ */ (0,f.jsx)(`p`,{className:J.relaySender,"data-context-relay-sender":!0,children:n(`message.context.relay.from`,{session:r})}),/* @__PURE__ */ (0,f.jsx)(hu,{content:e,t:n})]})}function Eu(e){let t=cu(e)?.senderSessionId;return typeof t==`string`&&t!==``?t:null}function Du(e){let t=cu(e),n=t===null?void 0:t.references;if(!Array.isArray(n))return null;let r=[];for(let e of n){let t=cu(e);if(t===null)return null;let n=t.label,i=t.retainedMessages,a=t.omittedMessages,o=t.truncated;if(typeof n!=`string`||n===``||typeof i!=`number`||typeof a!=`number`||typeof o!=`boolean`)return null;r.push({label:n,retained:i,omitted:a,truncated:o})}return r.length===0?null:r}function Ou({content:e,source:t,t:n}){let r=Du(t);return r===null?/* @__PURE__ */ (0,f.jsx)(gu,{content:e,source:t,t:n}):/* @__PURE__ */ (0,f.jsxs)(f.Fragment,{children:[/* @__PURE__ */ (0,f.jsx)(`ul`,{className:J.recalls,"data-context-recalls":!0,children:r.map((e,t)=>/* @__PURE__ */ (0,f.jsxs)(`li`,{className:J.recall,children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:J.recallLabel,children:e.label}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:J.recallCounts,children:n(`message.context.recall.counts`,{retained:e.retained,omitted:e.omitted})}),e.truncated&&/* @__PURE__ */ (0,f.jsx)(`span`,{className:J.recallCounts,children:n(`message.context.recall.truncated`)})]},t))}),/* @__PURE__ */ (0,f.jsx)(hu,{content:e,t:n})]})}function ku(e){let t=cu(e)?.summary;return typeof t==`string`&&t!==``?t:null}function Au(e,t){let n={rendered:null,summary:null,body:/* @__PURE__ */ (0,f.jsx)(gu,{...t})};switch(e){case`instructions`:return _u(t.source)===null?n:{rendered:`instructions`,summary:null,body:/* @__PURE__ */ (0,f.jsx)(yu,{...t})};case`catalog`:return bu(t.source)===null?n:{rendered:`catalog`,summary:null,body:/* @__PURE__ */ (0,f.jsx)(xu,{...t})};case`snapshot`:return Su(t.source)===null?n:{rendered:`snapshot`,summary:null,body:/* @__PURE__ */ (0,f.jsx)(Cu,{...t})};case`notice`:{let e=ku(t.source);return e===null?n:{rendered:`notice`,summary:e,body:/* @__PURE__ */ (0,f.jsx)(wu,{...t})}}case`relay`:return Eu(t.source)===null?n:{rendered:`relay`,summary:null,body:/* @__PURE__ */ (0,f.jsx)(Tu,{...t})};case`recall`:return Du(t.source)===null?n:{rendered:`recall`,summary:null,body:/* @__PURE__ */ (0,f.jsx)(Ou,{...t})};case null:return n;
122
+ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let n of e.seen.entries()){let r=n[1];if(t===n[0])a(n);else{if(e.external){let r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){a(n);continue}}(e.metadataRegistry.get(n[0])?.id||r.cycle||r.count>1&&e.reused===`ref`)&&a(n)}}}function Wi(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=t=>{let n=e.seen.get(t);if(n.ref===null)return;let i=n.def??n.schema,a={...i},o=n.ref;if(n.ref=null,o){r(o);let n=e.seen.get(o),s=n.schema;if(s.$ref&&(e.target===`draft-07`||e.target===`draft-04`||e.target===`openapi-3.0`)?(i.allOf=i.allOf??[],i.allOf.push(s)):Object.assign(i,s),Object.assign(i,a),t._zod.parent===o)for(let e in i)e!==`$ref`&&e!==`allOf`&&(e in a||delete i[e]);if(s.$ref&&n.def)for(let e in i)e!==`$ref`&&e!==`allOf`&&e in n.def&&JSON.stringify(i[e])===JSON.stringify(n.def[e])&&delete i[e]}let s=t._zod.parent;if(s&&s!==o){r(s);let t=e.seen.get(s);if(t?.schema.$ref&&(i.$ref=t.schema.$ref,t.def))for(let e in i)e!==`$ref`&&e!==`allOf`&&e in t.def&&JSON.stringify(i[e])===JSON.stringify(t.def[e])&&delete i[e]}e.override({zodSchema:t,jsonSchema:i,path:n.path??[]})};for(let t of[...e.seen.entries()].reverse())r(t[0]);let i={};if(e.target===`draft-2020-12`?i.$schema=`https://json-schema.org/draft/2020-12/schema`:e.target===`draft-07`?i.$schema=`http://json-schema.org/draft-07/schema#`:e.target===`draft-04`?i.$schema=`http://json-schema.org/draft-04/schema#`:e.target,e.external?.uri){let n=e.external.registry.get(t)?.id;if(!n)throw Error("Schema is missing an `id` property");i.$id=e.external.uri(n)}Object.assign(i,n.def??n.schema);let a=e.metadataRegistry.get(t)?.id;a!==void 0&&i.id===a&&delete i.id;let o=e.external?.defs??{};for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(e.def.id===e.defId&&delete e.def.id,o[e.defId]=e.def)}e.external||Object.keys(o).length>0&&(e.target===`draft-2020-12`?i.$defs=o:i.definitions=o);try{let n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,"~standard",{value:{...t[`~standard`],jsonSchema:{input:qi(t,`input`,e.processors),output:qi(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function Gi(e,t){let n=t??{seen:/* @__PURE__ */ new Set};if(n.seen.has(e))return!1;n.seen.add(e);let r=e._zod.def;if(r.type===`transform`)return!0;if(r.type===`array`)return Gi(r.element,n);if(r.type===`set`)return Gi(r.valueType,n);if(r.type===`lazy`)return Gi(r.getter(),n);if(r.type===`promise`||r.type===`optional`||r.type===`nonoptional`||r.type===`nullable`||r.type===`readonly`||r.type==="default"||r.type===`prefault`)return Gi(r.innerType,n);if(r.type===`intersection`)return Gi(r.left,n)||Gi(r.right,n);if(r.type===`record`||r.type===`map`)return Gi(r.keyType,n)||Gi(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:Gi(r.in,n)||Gi(r.out,n);if(r.type===`object`){for(let e in r.shape)if(Gi(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(Gi(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(Gi(e,n))return!0;return!!(r.rest&&Gi(r.rest,n))}return!1}let Ki=(e,t={})=>n=>{let r=Hi({...n,processors:t});return F(e,r),Ui(r,e),Wi(r,e)},qi=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=Hi({...i??{},target:a,io:t,processors:n});return F(e,o),Ui(o,e),Wi(o,e)},Ji={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},Yi=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l}=e._zod.bag;if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=Ji[s]??s,i.format===``&&delete i.format,s===`time`&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let e=[...c];e.length===1?i.pattern=e[0].source:e.length>1&&(i.allOf=[...e.map(e=>({...t.target===`draft-07`||t.target===`draft-04`||t.target===`openapi-3.0`?{type:`string`}:{},pattern:e.source}))])}},Xi=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,format:s,multipleOf:c,exclusiveMaximum:l,exclusiveMinimum:u}=e._zod.bag;i.type=typeof s==`string`&&s.includes(`int`)?`integer`:`number`;let d=typeof u==`number`&&u>=(a??-1/0),f=typeof l==`number`&&l<=(o??1/0),p=t.target===`draft-04`||t.target===`openapi-3.0`;d?p?(i.minimum=u,i.exclusiveMinimum=!0):i.exclusiveMinimum=u:typeof a==`number`&&(i.minimum=a),f?p?(i.maximum=l,i.exclusiveMaximum=!0):i.exclusiveMaximum=l:typeof o==`number`&&(i.maximum=o),typeof c==`number`&&(i.multipleOf=c)},Zi=(e,t,n,r)=>{n.type=`boolean`},Qi=(e,t,n,r)=>{t.target===`openapi-3.0`?(n.type=`string`,n.nullable=!0,n.enum=[null]):n.type=`null`},$i=(e,t,n,r)=>{n.not={}},ea=(e,t,n,r)=>{let i=e._zod.def,a=be(i.entries);a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a},ta=(e,t,n,r)=>{let i=e._zod.def,a=[];for(let e of i.values)if(e===void 0){if(t.unrepresentable===`throw`)throw Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof e==`bigint`){if(t.unrepresentable===`throw`)throw Error(`BigInt literals cannot be represented in JSON Schema`);a.push(Number(e))}else a.push(e);if(a.length!==0){if(a.length===1){let e=a[0];n.type=e===null?`null`:typeof e,t.target===`draft-04`||t.target===`openapi-3.0`?n.enum=[e]:n.const=e}else a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),a.every(e=>typeof e==`boolean`)&&(n.type=`boolean`),a.every(e=>e===null)&&(n.type=`null`),n.enum=a}},na=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Custom types cannot be represented in JSON Schema`)},ra=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Transforms cannot be represented in JSON Schema`)},ia=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=e._zod.bag;typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=F(a.element,t,{...r,path:[...r.path,`items`]})},aa=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`,i.properties={};let o=a.shape;for(let e in o)i.properties[e]=F(o[e],t,{...r,path:[...r.path,`properties`,e]});let s=new Set(Object.keys(o)),c=new Set([...s].filter(e=>{let n=a.shape[e]._zod;return t.io===`input`?n.optin===void 0:n.optout===void 0}));c.size>0&&(i.required=Array.from(c)),a.catchall?._zod.def.type===`never`?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=F(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},oa=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>F(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},sa=(e,t,n,r)=>{let i=e._zod.def,a=F(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=F(i.right,t,{...r,path:[...r.path,`allOf`,1]}),s=e=>`allOf`in e&&Object.keys(e).length===1;n.allOf=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]]},ca=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`array`;let o=t.target===`draft-2020-12`?`prefixItems`:`items`,s=t.target===`draft-2020-12`||t.target===`openapi-3.0`?`items`:`additionalItems`,c=a.items.map((e,n)=>F(e,t,{...r,path:[...r.path,o,n]})),l=a.rest?F(a.rest,t,{...r,path:[...r.path,s,...t.target===`openapi-3.0`?[a.items.length]:[]]}):null;t.target===`draft-2020-12`?(i.prefixItems=c,l&&(i.items=l)):t.target===`openapi-3.0`?(i.items={anyOf:c},l&&i.items.anyOf.push(l),i.minItems=c.length,l||(i.maxItems=c.length)):(i.items=c,l&&(i.additionalItems=l));let{minimum:u,maximum:d}=e._zod.bag;typeof u==`number`&&(i.minItems=u),typeof d==`number`&&(i.maxItems=d)},la=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`;let o=a.keyType,s=o._zod.bag?.patterns;if(a.mode===`loose`&&s&&s.size>0){let e=F(a.valueType,t,{...r,path:[...r.path,`patternProperties`,`*`]});i.patternProperties={};for(let t of s)i.patternProperties[t.source]=e}else(t.target===`draft-07`||t.target===`draft-2020-12`)&&(i.propertyNames=F(a.keyType,t,{...r,path:[...r.path,`propertyNames`]})),i.additionalProperties=F(a.valueType,t,{...r,path:[...r.path,`additionalProperties`]});let c=o._zod.values;if(c){let e=[...c].filter(e=>typeof e==`string`||typeof e==`number`);e.length>0&&(i.required=e)}},ua=(e,t,n,r)=>{let i=e._zod.def,a=F(i.innerType,t,r),o=t.seen.get(e);t.target===`openapi-3.0`?(o.ref=i.innerType,n.nullable=!0):n.anyOf=[a,{type:`null`}]},da=(e,t,n,r)=>{let i=e._zod.def;F(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},fa=(e,t,n,r)=>{let i=e._zod.def;F(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.default=JSON.parse(JSON.stringify(i.defaultValue))},pa=(e,t,n,r)=>{let i=e._zod.def;F(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,t.io===`input`&&(n._prefault=JSON.parse(JSON.stringify(i.defaultValue)))},ma=(e,t,n,r)=>{let i=e._zod.def;F(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{throw Error(`Dynamic catch values are not supported in JSON Schema`)}n.default=o},ha=(e,t,n,r)=>{let i=e._zod.def,a=i.in._zod.traits.has(`$ZodTransform`),o=t.io===`input`?a?i.out:i.in:i.out;F(o,t,r);let s=t.seen.get(e);s.ref=o},ga=(e,t,n,r)=>{let i=e._zod.def;F(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},_a=(e,t,n,r)=>{let i=e._zod.def;F(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},va=(e,t,n,r)=>{let i=e._zod.innerType;F(i,t,r);let a=t.seen.get(e);a.ref=i},ya=/*@__PURE__*/ A(`ZodISODateTime`,(e,t)=>{kn.init(e,t),R.init(e,t)});function ba(e){return/* @__PURE__ */ si(ya,e)}let xa=/*@__PURE__*/ A(`ZodISODate`,(e,t)=>{An.init(e,t),R.init(e,t)});function Sa(e){return/* @__PURE__ */ ci(xa,e)}let Ca=/*@__PURE__*/ A(`ZodISOTime`,(e,t)=>{jn.init(e,t),R.init(e,t)});function wa(e){return/* @__PURE__ */ li(Ca,e)}let Ta=/*@__PURE__*/ A(`ZodISODuration`,(e,t)=>{Mn.init(e,t),R.init(e,t)});function Ea(e){return/* @__PURE__ */ ui(Ta,e)}let Da=/*@__PURE__*/ A(`ZodError`,(e,t)=>{nt.init(e,t),e.name=`ZodError`,Object.defineProperties(e,{format:{value:t=>at(e,t)},flatten:{value:t=>it(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,xe,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,xe,2)}},isEmpty:{get(){return e.issues.length===0}}})},{Parent:Error}),Oa=/* @__PURE__ */ ot(Da),ka=/* @__PURE__ */ st(Da),Aa=/* @__PURE__ */ ct(Da),ja=/* @__PURE__ */ ut(Da),Ma=/* @__PURE__ */ ft(Da),Na=/* @__PURE__ */ pt(Da),Pa=/* @__PURE__ */ mt(Da),Fa=/* @__PURE__ */ ht(Da),Ia=/* @__PURE__ */ gt(Da),La=/* @__PURE__ */ _t(Da),Ra=/* @__PURE__ */ vt(Da),za=/* @__PURE__ */ yt(Da),Ba=/* @__PURE__ */ new WeakMap;function Va(e,t,n){let r=Object.getPrototypeOf(e),i=Ba.get(r);if(i||(i=/* @__PURE__ */ new Set,Ba.set(r,i)),!i.has(t)){i.add(t);for(let e in n){let t=n[e];Object.defineProperty(r,e,{configurable:!0,enumerable:!1,get(){let n=t.bind(this);return Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:n}),n},set(t){Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:t})}})}}}let I=/*@__PURE__*/ A(`ZodType`,(e,t)=>(N.init(e,t),Object.assign(e[`~standard`],{jsonSchema:{input:qi(e,`input`),output:qi(e,`output`)}}),e.toJSONSchema=Ki(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(t,n)=>Oa(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>Aa(e,t,n),e.parseAsync=async(t,n)=>ka(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>ja(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>Ma(e,t,n),e.decode=(t,n)=>Na(e,t,n),e.encodeAsync=async(t,n)=>Pa(e,t,n),e.decodeAsync=async(t,n)=>Fa(e,t,n),e.safeEncode=(t,n)=>Ia(e,t,n),e.safeDecode=(t,n)=>La(e,t,n),e.safeEncodeAsync=async(t,n)=>Ra(e,t,n),e.safeDecodeAsync=async(t,n)=>za(e,t,n),Va(e,`ZodType`,{check(...e){let t=this.def;return this.clone(Oe(t,{checks:[...t.checks??[],...e.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return Re(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(as(e,t))},superRefine(e,t){return this.check(os(e,t))},overwrite(e){return this.check(/* @__PURE__ */ ji(e))},optional(){return Ro(this)},exactOptional(){return Bo(this)},nullable(){return Ho(this)},nullish(){return Ro(Ho(this))},nonoptional(e){return Jo(this,e)},array(){return V(this)},or(e){return wo([this,e])},and(e){return Oo(this,e)},transform(e){return Qo(this,Io(e))},default(e){return Wo(this,e)},prefault(e){return Ko(this,e)},catch(e){return Xo(this,e)},pipe(e){return Qo(this,e)},readonly(){return es(this)},describe(e){let t=this.clone();return Lr.add(t,{description:e}),t},meta(...e){if(e.length===0)return Lr.get(this);let t=this.clone();return Lr.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e){return e(this)}}),Object.defineProperty(e,"description",{get(){return Lr.get(e)?.description},configurable:!0}),e)),Ha=/*@__PURE__*/ A(`_ZodString`,(e,t)=>{_n.init(e,t),I.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Yi(e,t,n,r);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,Va(e,`_ZodString`,{regex(...e){return this.check(/* @__PURE__ */ Ti(...e))},includes(...e){return this.check(/* @__PURE__ */ Oi(...e))},startsWith(...e){return this.check(/* @__PURE__ */ ki(...e))},endsWith(...e){return this.check(/* @__PURE__ */ Ai(...e))},min(...e){return this.check(/* @__PURE__ */ Ci(...e))},max(...e){return this.check(/* @__PURE__ */ Si(...e))},length(...e){return this.check(/* @__PURE__ */ wi(...e))},nonempty(...e){return this.check(/* @__PURE__ */ Ci(1,...e))},lowercase(e){return this.check(/* @__PURE__ */ Ei(e))},uppercase(e){return this.check(/* @__PURE__ */ Di(e))},trim(){return this.check(/* @__PURE__ */ Ni())},normalize(...e){return this.check(/* @__PURE__ */ Mi(...e))},toLowerCase(){return this.check(/* @__PURE__ */ Pi())},toUpperCase(){return this.check(/* @__PURE__ */ Fi())},slugify(){return this.check(/* @__PURE__ */ Ii())}})}),Ua=/*@__PURE__*/ A(`ZodString`,(e,t)=>{_n.init(e,t),Ha.init(e,t),e.email=t=>e.check(/* @__PURE__ */ zr(Wa,t)),e.url=t=>e.check(/* @__PURE__ */ Gr(qa,t)),e.jwt=t=>e.check(/* @__PURE__ */ oi(lo,t)),e.emoji=t=>e.check(/* @__PURE__ */ Kr(Ya,t)),e.guid=t=>e.check(/* @__PURE__ */ Br(Ga,t)),e.uuid=t=>e.check(/* @__PURE__ */ Vr(Ka,t)),e.uuidv4=t=>e.check(/* @__PURE__ */ Hr(Ka,t)),e.uuidv6=t=>e.check(/* @__PURE__ */ Ur(Ka,t)),e.uuidv7=t=>e.check(/* @__PURE__ */ Wr(Ka,t)),e.nanoid=t=>e.check(/* @__PURE__ */ qr(Xa,t)),e.guid=t=>e.check(/* @__PURE__ */ Br(Ga,t)),e.cuid=t=>e.check(/* @__PURE__ */ Jr(Za,t)),e.cuid2=t=>e.check(/* @__PURE__ */ Yr(Qa,t)),e.ulid=t=>e.check(/* @__PURE__ */ Xr($a,t)),e.base64=t=>e.check(/* @__PURE__ */ ri(oo,t)),e.base64url=t=>e.check(/* @__PURE__ */ ii(so,t)),e.xid=t=>e.check(/* @__PURE__ */ Zr(eo,t)),e.ksuid=t=>e.check(/* @__PURE__ */ Qr(to,t)),e.ipv4=t=>e.check(/* @__PURE__ */ $r(no,t)),e.ipv6=t=>e.check(/* @__PURE__ */ ei(ro,t)),e.cidrv4=t=>e.check(/* @__PURE__ */ ti(io,t)),e.cidrv6=t=>e.check(/* @__PURE__ */ ni(ao,t)),e.e164=t=>e.check(/* @__PURE__ */ ai(co,t)),e.datetime=t=>e.check(ba(t)),e.date=t=>e.check(Sa(t)),e.time=t=>e.check(wa(t)),e.duration=t=>e.check(Ea(t))});function L(e){return/* @__PURE__ */ Rr(Ua,e)}let R=/*@__PURE__*/ A(`ZodStringFormat`,(e,t)=>{P.init(e,t),Ha.init(e,t)}),Wa=/*@__PURE__*/ A(`ZodEmail`,(e,t)=>{bn.init(e,t),R.init(e,t)}),Ga=/*@__PURE__*/ A(`ZodGUID`,(e,t)=>{vn.init(e,t),R.init(e,t)}),Ka=/*@__PURE__*/ A(`ZodUUID`,(e,t)=>{yn.init(e,t),R.init(e,t)}),qa=/*@__PURE__*/ A(`ZodURL`,(e,t)=>{xn.init(e,t),R.init(e,t)});function Ja(e){return/* @__PURE__ */ Gr(qa,e)}let Ya=/*@__PURE__*/ A(`ZodEmoji`,(e,t)=>{Sn.init(e,t),R.init(e,t)}),Xa=/*@__PURE__*/ A(`ZodNanoID`,(e,t)=>{Cn.init(e,t),R.init(e,t)}),Za=/*@__PURE__*/ A(`ZodCUID`,(e,t)=>{wn.init(e,t),R.init(e,t)}),Qa=/*@__PURE__*/ A(`ZodCUID2`,(e,t)=>{Tn.init(e,t),R.init(e,t)}),$a=/*@__PURE__*/ A(`ZodULID`,(e,t)=>{En.init(e,t),R.init(e,t)}),eo=/*@__PURE__*/ A(`ZodXID`,(e,t)=>{Dn.init(e,t),R.init(e,t)}),to=/*@__PURE__*/ A(`ZodKSUID`,(e,t)=>{On.init(e,t),R.init(e,t)}),no=/*@__PURE__*/ A(`ZodIPv4`,(e,t)=>{Nn.init(e,t),R.init(e,t)}),ro=/*@__PURE__*/ A(`ZodIPv6`,(e,t)=>{Pn.init(e,t),R.init(e,t)}),io=/*@__PURE__*/ A(`ZodCIDRv4`,(e,t)=>{Fn.init(e,t),R.init(e,t)}),ao=/*@__PURE__*/ A(`ZodCIDRv6`,(e,t)=>{In.init(e,t),R.init(e,t)}),oo=/*@__PURE__*/ A(`ZodBase64`,(e,t)=>{Rn.init(e,t),R.init(e,t)}),so=/*@__PURE__*/ A(`ZodBase64URL`,(e,t)=>{Bn.init(e,t),R.init(e,t)}),co=/*@__PURE__*/ A(`ZodE164`,(e,t)=>{Vn.init(e,t),R.init(e,t)}),lo=/*@__PURE__*/ A(`ZodJWT`,(e,t)=>{Un.init(e,t),R.init(e,t)}),uo=/*@__PURE__*/ A(`ZodNumber`,(e,t)=>{Wn.init(e,t),I.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Xi(e,t,n,r),Va(e,`ZodNumber`,{gt(e,t){return this.check(/* @__PURE__ */ yi(e,t))},gte(e,t){return this.check(/* @__PURE__ */ bi(e,t))},min(e,t){return this.check(/* @__PURE__ */ bi(e,t))},lt(e,t){return this.check(/* @__PURE__ */ _i(e,t))},lte(e,t){return this.check(/* @__PURE__ */ vi(e,t))},max(e,t){return this.check(/* @__PURE__ */ vi(e,t))},int(e){return this.check(po(e))},safe(e){return this.check(po(e))},positive(e){return this.check(/* @__PURE__ */ yi(0,e))},nonnegative(e){return this.check(/* @__PURE__ */ bi(0,e))},negative(e){return this.check(/* @__PURE__ */ _i(0,e))},nonpositive(e){return this.check(/* @__PURE__ */ vi(0,e))},multipleOf(e,t){return this.check(/* @__PURE__ */ xi(e,t))},step(e,t){return this.check(/* @__PURE__ */ xi(e,t))},finite(){return this}});let n=e._zod.bag;e.minValue=Math.max(n.minimum??-1/0,n.exclusiveMinimum??-1/0)??null,e.maxValue=Math.min(n.maximum??1/0,n.exclusiveMaximum??1/0)??null,e.isInt=(n.format??``).includes(`int`)||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function z(e){return/* @__PURE__ */ di(uo,e)}let fo=/*@__PURE__*/ A(`ZodNumberFormat`,(e,t)=>{Gn.init(e,t),uo.init(e,t)});function po(e){return/* @__PURE__ */ fi(fo,e)}let mo=/*@__PURE__*/ A(`ZodBoolean`,(e,t)=>{Kn.init(e,t),I.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Zi(e,t,n,r)});function B(e){return/* @__PURE__ */ pi(mo,e)}let ho=/*@__PURE__*/ A(`ZodNull`,(e,t)=>{qn.init(e,t),I.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Qi(e,t,n,r)});function go(e){return/* @__PURE__ */ mi(ho,e)}let _o=/*@__PURE__*/ A(`ZodUnknown`,(e,t)=>{Jn.init(e,t),I.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function vo(){return/* @__PURE__ */ hi(_o)}let yo=/*@__PURE__*/ A(`ZodNever`,(e,t)=>{Yn.init(e,t),I.init(e,t),e._zod.processJSONSchema=(t,n,r)=>$i(e,t,n,r)});function bo(e){return/* @__PURE__ */ gi(yo,e)}let xo=/*@__PURE__*/ A(`ZodArray`,(e,t)=>{Zn.init(e,t),I.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ia(e,t,n,r),e.element=t.element,Va(e,`ZodArray`,{min(e,t){return this.check(/* @__PURE__ */ Ci(e,t))},nonempty(e){return this.check(/* @__PURE__ */ Ci(1,e))},max(e,t){return this.check(/* @__PURE__ */ Si(e,t))},length(e,t){return this.check(/* @__PURE__ */ wi(e,t))},unwrap(){return this.element}})});function V(e,t){return/* @__PURE__ */ Li(xo,e,t)}let So=/*@__PURE__*/ A(`ZodObject`,(e,t)=>{nr.init(e,t),I.init(e,t),e._zod.processJSONSchema=(t,n,r)=>aa(e,t,n,r),j(e,`shape`,()=>t.shape),Va(e,`ZodObject`,{keyof(){return W(Object.keys(this._zod.def.shape))},catchall(e){return this.clone({...this._zod.def,catchall:e})},passthrough(){return this.clone({...this._zod.def,catchall:vo()})},loose(){return this.clone({...this._zod.def,catchall:vo()})},strict(){return this.clone({...this._zod.def,catchall:bo()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(e){return Ue(this,e)},safeExtend(e){return We(this,e)},merge(e){return Ge(this,e)},pick(e){return Ve(this,e)},omit(e){return He(this,e)},partial(...e){return Ke(Lo,this,e[0])},required(...e){return qe(qo,this,e[0])}})});function H(e,t){let n={type:`object`,shape:e??{},...M(t)};return new So(n)}function U(e,t){return new So({type:`object`,shape:e,catchall:bo(),...M(t)})}let Co=/*@__PURE__*/ A(`ZodUnion`,(e,t)=>{ir.init(e,t),I.init(e,t),e._zod.processJSONSchema=(t,n,r)=>oa(e,t,n,r),e.options=t.options});function wo(e,t){return new Co({type:`union`,options:e,...M(t)})}let To=/*@__PURE__*/ A(`ZodDiscriminatedUnion`,(e,t)=>{Co.init(e,t),ar.init(e,t)});function Eo(e,t,n){return new To({type:`union`,options:t,discriminator:e,...M(n)})}let Do=/*@__PURE__*/ A(`ZodIntersection`,(e,t)=>{or.init(e,t),I.init(e,t),e._zod.processJSONSchema=(t,n,r)=>sa(e,t,n,r)});function Oo(e,t){return new Do({type:`intersection`,left:e,right:t})}let ko=/*@__PURE__*/ A(`ZodTuple`,(e,t)=>{lr.init(e,t),I.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ca(e,t,n,r),e.rest=t=>e.clone({...e._zod.def,rest:t})});function Ao(e,t,n){let r=t instanceof N;return new ko({type:`tuple`,items:e,rest:r?t:null,...M(r?n:t)})}let jo=/*@__PURE__*/ A(`ZodRecord`,(e,t)=>{pr.init(e,t),I.init(e,t),e._zod.processJSONSchema=(t,n,r)=>la(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType});function Mo(e,t,n){return!t||!t._zod?new jo({type:`record`,keyType:L(),valueType:e,...M(t)}):new jo({type:`record`,keyType:e,valueType:t,...M(n)})}let No=/*@__PURE__*/ A(`ZodEnum`,(e,t)=>{mr.init(e,t),I.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ea(e,t,n,r),e.enum=t.entries,e.options=Object.values(t.entries);let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new No({...t,checks:[],...M(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new No({...t,checks:[],...M(r),entries:i})}});function W(e,t){let n=Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e;return new No({type:`enum`,entries:n,...M(t)})}let Po=/*@__PURE__*/ A(`ZodLiteral`,(e,t)=>{hr.init(e,t),I.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ta(e,t,n,r),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function G(e,t){return new Po({type:`literal`,values:Array.isArray(e)?e:[e],...M(t)})}let Fo=/*@__PURE__*/ A(`ZodTransform`,(e,t)=>{gr.init(e,t),I.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ra(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new _e(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(et(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,t.input??=n.value,t.inst??=e,n.issues.push(et(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n.fallback=!0,n)):(n.value=i,n.fallback=!0,n)}});function Io(e){return new Fo({type:`transform`,transform:e})}let Lo=/*@__PURE__*/ A(`ZodOptional`,(e,t)=>{vr.init(e,t),I.init(e,t),e._zod.processJSONSchema=(t,n,r)=>_a(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Ro(e){return new Lo({type:`optional`,innerType:e})}let zo=/*@__PURE__*/ A(`ZodExactOptional`,(e,t)=>{yr.init(e,t),I.init(e,t),e._zod.processJSONSchema=(t,n,r)=>_a(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Bo(e){return new zo({type:`optional`,innerType:e})}let Vo=/*@__PURE__*/ A(`ZodNullable`,(e,t)=>{br.init(e,t),I.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ua(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Ho(e){return new Vo({type:`nullable`,innerType:e})}let Uo=/*@__PURE__*/ A(`ZodDefault`,(e,t)=>{xr.init(e,t),I.init(e,t),e._zod.processJSONSchema=(t,n,r)=>fa(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Wo(e,t){return new Uo({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():Fe(t)}})}let Go=/*@__PURE__*/ A(`ZodPrefault`,(e,t)=>{Cr.init(e,t),I.init(e,t),e._zod.processJSONSchema=(t,n,r)=>pa(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Ko(e,t){return new Go({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():Fe(t)}})}let qo=/*@__PURE__*/ A(`ZodNonOptional`,(e,t)=>{wr.init(e,t),I.init(e,t),e._zod.processJSONSchema=(t,n,r)=>da(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Jo(e,t){return new qo({type:`nonoptional`,innerType:e,...M(t)})}let Yo=/*@__PURE__*/ A(`ZodCatch`,(e,t)=>{Er.init(e,t),I.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ma(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Xo(e,t){return new Yo({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:()=>t})}let Zo=/*@__PURE__*/ A(`ZodPipe`,(e,t)=>{Dr.init(e,t),I.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ha(e,t,n,r),e.in=t.in,e.out=t.out});function Qo(e,t){return new Zo({type:`pipe`,in:e,out:t})}let $o=/*@__PURE__*/ A(`ZodReadonly`,(e,t)=>{kr.init(e,t),I.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ga(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function es(e){return new $o({type:`readonly`,innerType:e})}let ts=/*@__PURE__*/ A(`ZodLazy`,(e,t)=>{jr.init(e,t),I.init(e,t),e._zod.processJSONSchema=(t,n,r)=>va(e,t,n,r),e.unwrap=()=>e._zod.def.getter()});function ns(e){return new ts({type:`lazy`,getter:e})}let rs=/*@__PURE__*/ A(`ZodCustom`,(e,t)=>{Mr.init(e,t),I.init(e,t),e._zod.processJSONSchema=(t,n,r)=>na(e,t,n,r)});function is(e,t){return/* @__PURE__ */ Ri(rs,e??(()=>!0),t)}function as(e,t={}){return/* @__PURE__ */ zi(rs,e,t)}function os(e,t){return/* @__PURE__ */ Bi(e,t)}function ss(e){return(t,n)=>{for(let r of e)Object.hasOwn(t,r)&&t[r]===void 0&&n.addIssue({code:`custom`,path:[r],message:`Explicit undefined is not valid JSON`})}}let cs=wo([L(),z(),B(),go()]);function ls(e){let t=/* @__PURE__ */ new WeakSet,n=[{value:e,leaving:!1}];try{for(;n.length>0;){let e=n.pop();if(!e)break;if(e.leaving)t.delete(e.value);else if(typeof e.value==`object`&&e.value!==null){if(t.has(e.value))return!1;t.add(e.value),n.push({value:e.value,leaving:!0});for(let t of Object.values(e.value))n.push({value:t,leaving:!1})}}}catch{return!1}return!0}let us=is(ls,{message:`JSON value must not contain circular references`}),ds=ns(()=>wo([cs,V(ds),Mo(L(),ds)])),fs=us.pipe(ds);us.pipe(V(ds));let ps=us.pipe(Mo(L(),ds)),ms=U({code:L().min(1),message:L().min(1),retryable:B(),diagnostic:L().min(1).optional(),stage:L().min(1).optional(),durationMs:z().int().nonnegative().optional(),stderrTail:L().min(1).optional()}).superRefine(ss([`diagnostic`,`stage`,`durationMs`,`stderrTail`])),hs=L().max(64).regex(/^[a-z]{2,3}(?:-[A-Za-z0-9]{2,8})*$/u),gs=e=>L().min(1).max(e).refine(e=>e.trim().length>0),_s=Mo(hs,H({label:gs(256).optional(),description:gs(1024).optional()}).strict()).refine(e=>Object.keys(e).length<=16,`Too many locales`),vs=Mo(hs,gs(4096)).refine(e=>typeof e.en==`string`,`English fallback is required`).refine(e=>Object.keys(e).length<=16,`Too many locales`),ys=L().refine(e=>e.trim().length>0,{message:`Identifier must not be empty or whitespace`}),bs=ys.brand(),K=ys.brand(),xs=ys.brand();ys.brand(),ys.brand();let Ss=L().refine(e=>e.trim().length>0,{message:`Value must not be empty or whitespace`}),Cs=Ss.max(128).regex(/^[A-Za-z0-9._~:-]+$/u,`Permission Mode ID must use transport-safe characters`).brand(),ws=H({modes:V(H({id:Cs,label:Ss.max(256),description:Ss.max(1024).optional(),dangerous:B().optional(),localizations:_s.optional()}).strict()).min(1).max(32),defaultModeId:Cs}).strict().superRefine((e,t)=>{let n=/* @__PURE__ */ new Set;for(let[r,i]of e.modes.entries())n.has(i.id)&&t.addIssue({code:`custom`,message:`Permission Mode IDs must be unique`,path:[`modes`,r,`id`]}),n.add(i.id);n.has(e.defaultModeId)||t.addIssue({code:`custom`,message:`Default Permission Mode must exist in the catalog`,path:[`defaultModeId`]})});H({threadId:K,permissionModeId:Cs}).strict();let Ts=z().int().safe().nonnegative(),Es=z().finite().nonnegative(),Ds=z().finite().min(0).max(100),Os=H({version:wo([G(3),G(4)]).optional(),requestId:L().min(1),turnId:L().min(1).max(1024),outputTokens:Ts,startedAtMs:Ts,completedAtMs:Ts}).strict().refine(e=>e.completedAtMs>e.startedAtMs),ks=H({version:wo([G(2),G(3),G(4)]).optional(),value:Es,turnId:L().min(1).max(1024),at:Ts}).strict();H({outputTimings:V(Os).transform(e=>e.filter(e=>e.version===4)).optional(),outputTokensPerSecond:ks.refine(e=>e.version===4).optional().catch(void 0),timeToFirstOutputMs:ks.extend({value:Ts}).optional()}).strict();let As=e=>vs.refine(t=>Object.values(t).every(t=>t.length<=e)),js=H({composerIndicators:V(H({kind:G(`countdown`),id:L().min(1).max(64),expiresAtUnix:Ts,label:As(256).optional(),tooltip:As(1024).optional()}).strict()).max(2).refine(e=>new Set(e.map(({id:e})=>e)).size===e.length,{message:`Composer indicator IDs must be unique`}).optional(),inputTokens:Ts.optional(),cachedInputTokens:Ts.optional(),cacheWriteInputTokens:Ts.optional(),outputTokens:Ts.optional(),outputTokensPerSecond:Es.optional(),sessionOutputTokensPerSecond:Es.optional(),apiOutputTokensPerSecond:Es.optional(),reasoningOutputTokens:Ts.optional(),totalTokens:Ts.optional(),totalCostUsd:Es.optional(),totalCredits:Es.optional(),contextUsagePercent:Es.optional(),cacheHitRatePercent:Ds.optional(),contextWindowTokens:Ts.optional(),contextUsedTokens:Ts.optional(),planFiveHourUsedPercent:Ds.optional(),planFiveHourResetsAtUnix:Ts.optional(),planSevenDayUsedPercent:Ds.optional(),planSevenDayResetsAtUnix:Ts.optional(),sessionCacheHitRatePercent:Ds.optional(),timeToFirstOutputMs:Ts.optional(),costSource:W([`publicPrice`,`native`]).optional(),unpricedModels:V(L().min(1)).min(1).optional()}).strict().superRefine((e,t)=>{Object.keys(e).length===0&&t.addIssue({code:`custom`,message:`Thread Usage must contain a reliable field`});let n=e.contextUsedTokens!==void 0;n!==(e.contextWindowTokens!==void 0)&&t.addIssue({code:`custom`,message:`Thread Usage context fields must be provided together`,path:[n?`contextWindowTokens`:`contextUsedTokens`]}),e.contextWindowTokens===0&&t.addIssue({code:`custom`,message:`Thread Usage contextWindowTokens must be greater than zero`,path:[`contextWindowTokens`]}),e.costSource!==void 0&&e.totalCostUsd===void 0&&t.addIssue({code:`custom`,message:`Thread Usage costSource must be provided with totalCostUsd`,path:[`costSource`]}),e.unpricedModels!==void 0&&e.costSource!==`publicPrice`&&t.addIssue({code:`custom`,message:`Thread Usage unpricedModels must be provided with a publicPrice cost`,path:[`unpricedModels`]}),e.planFiveHourResetsAtUnix!==void 0&&e.planFiveHourUsedPercent===void 0&&t.addIssue({code:`custom`,message:`Thread Usage planFiveHourResetsAtUnix must be provided with planFiveHourUsedPercent`,path:[`planFiveHourResetsAtUnix`]}),e.planSevenDayResetsAtUnix!==void 0&&e.planSevenDayUsedPercent===void 0&&t.addIssue({code:`custom`,message:`Thread Usage planSevenDayResetsAtUnix must be provided with planSevenDayUsedPercent`,path:[`planSevenDayResetsAtUnix`]})}),Ms=z().finite().min(0).max(100),Ns=W([`weekly`,`monthly`,`five_hour`,`seven_day`,`unknown`]),Ps=H({id:L().min(1).max(256),label:L().min(1).max(256),localizations:_s.optional()}).strict(),Fs=H({product:L().min(1),periodType:Ns.optional(),scope:Ps.optional(),localizations:_s.optional(),used:z().finite().nonnegative().optional(),limit:z().finite().nonnegative().optional(),unit:L().min(1).max(32).optional(),usagePercent:Ms,resetsAt:L().min(1).optional()}).strict(),Is=H({availableCount:z().int().safe().positive(),nextExpiresAt:L().min(1).optional(),expiresAt:V(L().min(1)).min(1).max(32).optional()}).strict(),Ls=H({used:z().finite().nonnegative().optional(),limit:z().finite().nonnegative().optional(),unit:L().trim().min(1).max(32).optional(),label:L().min(1).optional(),usedPercent:Ms.optional(),remaining:z().finite().optional(),scope:Ps.optional(),localizations:_s.optional(),resetsAt:L().min(1).optional(),periodType:Ns,productUsage:V(Fs).min(1).optional(),resetCredits:Is.optional()}).strict().superRefine((e,t)=>{e.usedPercent===void 0&&e.remaining===void 0&&t.addIssue({code:`custom`,message:`Account credits must include usedPercent or remaining`}),e.remaining!==void 0&&!e.unit&&t.addIssue({code:`custom`,message:`Account remaining credits require a unit`,path:[`unit`]})});H({threadId:K,refresh:G(`exact`).optional()}).strict(),H({threadId:K,usage:js.nullable(),accountCredits:Ls.optional(),accountCreditsSupported:B().optional()}).strict();let Rs=L().refine(e=>e.trim().length>0,{message:`Value must not be empty or whitespace`}),zs=H({id:Rs.max(512).regex(/^[A-Za-z0-9._~-]+$/u,`Model Ref must use transport-safe opaque characters`).brand()}).strict(),Bs=Rs.max(128).regex(/^[A-Za-z0-9._~-]+$/u,`Thinking option ID must use transport-safe characters`).brand(),Vs=Rs.max(256),Hs=H({id:Bs,label:Rs.max(256)}).strict(),Us=H({ref:zs,label:Rs.max(256),resolvedModelLabel:Vs.optional(),fastModel:zs.optional(),supportedThinkingOptionIds:V(Bs).optional()}).strict(),Ws=V(Hs).superRefine((e,t)=>{let n=/* @__PURE__ */ new Set;for(let[r,i]of e.entries())n.has(i.id)&&t.addIssue({code:`custom`,message:`Thinking option IDs must be unique`,path:[r,`id`]}),n.add(i.id)}),Gs=H({models:V(Us),defaultModel:zs.optional(),thinkingOptions:Ws,defaultThinkingOptionId:Bs.optional()}).strict().superRefine((e,t)=>{let n=/* @__PURE__ */ new Set,r=new Set(e.thinkingOptions.map(({id:e})=>e));for(let[i,a]of e.models.entries()){n.has(a.ref.id)&&t.addIssue({code:`custom`,message:`Model Catalog refs must be unique`,path:[`models`,i,`ref`,`id`]}),n.add(a.ref.id),a.fastModel&&((n.has(a.fastModel.id)||e.models.some(e=>e.ref.id===a.fastModel?.id))&&t.addIssue({code:`custom`,message:`Fast Model refs must be distinct and unique`,path:[`models`,i,`fastModel`]}),n.add(a.fastModel.id));let o=/* @__PURE__ */ new Set;for(let[e,n]of(a.supportedThinkingOptionIds??[]).entries())o.has(n)&&t.addIssue({code:`custom`,message:`Supported Thinking option IDs must be unique per Model`,path:[`models`,i,`supportedThinkingOptionIds`,e]}),o.add(n),r.has(n)||t.addIssue({code:`custom`,message:`Supported Thinking option must exist in the catalog`,path:[`models`,i,`supportedThinkingOptionIds`,e]})}e.defaultModel&&!n.has(e.defaultModel.id)&&t.addIssue({code:`custom`,message:`Default Model must exist in the Model Catalog`,path:[`defaultModel`,`id`]}),e.defaultThinkingOptionId&&!r.has(e.defaultThinkingOptionId)&&t.addIssue({code:`custom`,message:`Default Thinking option must exist in the catalog`,path:[`defaultThinkingOptionId`]})}),Ks=H({fork:B(),forkAcrossCwd:B(),rollbackLastTurn:B()}).strict().refine(e=>e.fork||!e.forkAcrossCwd,{path:[`forkAcrossCwd`],message:`Cross-cwd Fork requires exact history Fork support`}),qs=W([`live`,`atCreate`]),Js=H({configuration:H({selectModel:B(),selectThinkingOption:B(),selectPermissionMode:B(),permissionModeScope:qs.default(`live`)}).strict(),history:Ks,subagents:H({observe:B(),readTranscript:B()}).strict().optional(),autonomousTurns:H({observe:B()}).strict().optional(),input:H({image:B()}).strict().optional(),steer:B().optional()}).strict();H({effectiveModel:zs.optional(),resolvedModelLabel:Vs.optional(),effectiveThinkingOptionId:Bs.optional(),availableThinkingOptions:Ws.optional(),effectivePermissionModeId:Cs.optional()}).strict().superRefine((e,t)=>{e.effectiveThinkingOptionId&&e.availableThinkingOptions&&!e.availableThinkingOptions.some(({id:t})=>t===e.effectiveThinkingOptionId)&&t.addIssue({code:`custom`,message:`Effective Thinking option must be currently available`,path:[`effectiveThinkingOptionId`]})});let Ys=H({open:G(!0)}).strict();wo([H({status:G(`ready`),catalog:Gs,permissionModes:ws.optional(),capabilities:Js,webUi:Ys.optional()}).strict().superRefine((e,t)=>{let n=e.capabilities.configuration.selectPermissionMode;n!==!!e.permissionModes&&t.addIssue({code:`custom`,message:`Permission Mode catalog and capability must agree`,path:n?[`permissionModes`]:[`capabilities`,`configuration`,`selectPermissionMode`]})}),H({status:W([`notInstalled`,`unavailable`,`error`]),error:ms}).strict()]),H({harnessId:bs,cwd:Rs.max(16384).optional(),refresh:B().optional(),purpose:G(`availability`).optional()}).strict(),H({harnessId:bs}).strict(),H({}).strict(),H({threadId:K,model:zs}).strict(),H({threadId:K,thinkingOptionId:Bs}).strict(),H({threadId:K,includeReferenceCapability:B().optional()}).strict(),Eo(`owner`,[H({owner:G(`codex`),locked:B(),effectiveModel:zs.optional(),resolvedModelLabel:Vs.optional(),effectiveThinkingOptionId:Bs.optional(),effectivePermissionModeId:Cs.optional(),history:Ks.optional(),supportsThreadReferences:G(!0).optional()}).strict(),H({owner:G(`external`),harnessId:Rs.max(256),transportModelId:Rs.max(1024),effectiveModel:zs.optional(),resolvedModelLabel:Vs.optional(),effectiveThinkingOptionId:Bs.optional(),availableThinkingOptions:Ws.optional(),effectivePermissionModeId:Cs.optional(),history:Ks,usage:js.optional(),subagent:B().optional(),locked:G(!0)}).strict()]),H({threadIds:V(K).min(1).max(100)}).strict().superRefine(({threadIds:e},t)=>{let n=/* @__PURE__ */ new Set;for(let[r,i]of e.entries())n.has(i)&&t.addIssue({code:`custom`,message:`Thread ownership-list IDs must be unique`,path:[`threadIds`,r]}),n.add(i)});let Xs=Eo(`owner`,[H({threadId:K,owner:G(`codex`)}).strict(),H({threadId:K,owner:G(`external`),harnessId:L().max(256).pipe(bs)}).strict()]);H({threads:V(Xs).min(1).max(100)}).strict().superRefine(({threads:e},t)=>{let n=/* @__PURE__ */ new Set;for(let[r,i]of e.entries())n.has(i.threadId)&&t.addIssue({code:`custom`,message:`Thread ownership-list results must be unique`,path:[`threads`,r,`threadId`]}),n.add(i.threadId)}),H({threadId:K,text:L().optional()}).strict(),H({kind:G(`application`),value:L().transform((e,t)=>{try{return JSON.parse(e)}catch{return t.addIssue({code:`custom`,message:`Invalid steering context JSON`}),he}}).pipe(H({expectedTurnId:xs,clientUserMessageId:L().min(1),delivery:W([`newTurn`,`activeTurn`])}).strict())}).strict().transform(e=>e.value),W([`activeTurn`,`newTurn`]),H({delivery:W([`official`,`activeTurn`,`newTurn`])}).strict(),H({threadId:K}).strict(),H({confirmed:B()}).strict(),H({threadIds:V(L().min(1))}).strict(),H({threadId:L().min(1).max(1024),pinned:B()}).strict(),H({}).strict(),H({parents:Mo(L().min(1),L().min(1))}).strict(),H({prompt:L().max(16384).optional()}).strict(),H({projects:V(H({id:L(),name:L(),rootPaths:V(L())})),assignments:Mo(L(),L()),projectless:V(L()),pinned:V(L())});let Zs=Mo(L(),vo()),Qs=H({epoch:L().uuid(),sequence:z().int().nonnegative()});Eo(`type`,[H({type:G(`skills-changed`),cursor:Qs,cwd:L().optional()}),H({type:G(`harness-inspection-changed`),cursor:Qs,harnessId:L().min(1)}),H({type:G(`display-settings-changed`),cursor:Qs}),H({type:G(`preferences-changed`),cursor:Qs,revision:z().int().nonnegative()}),H({type:G(`hello`),version:G(1),cursor:Qs,reset:B()}),H({type:G(`changed`),cursor:Qs,threadId:L().min(1),method:L().min(1)})]);let $s=Eo(`type`,[H({type:G(`text`),id:L(),prompt:L(),secret:B().optional(),optional:B().optional()}),H({type:G(`choice`),id:L(),prompt:L(),multiple:B(),allowOther:B(),optional:B().optional(),options:V(H({value:L(),label:L(),description:L().optional()}))})]),ec=Eo(`type`,[H({type:G(`approval`),title:L(),description:L().optional(),subject:vo().optional(),actions:V(H({id:L(),label:L(),effect:L()}))}),H({type:G(`question`),title:L().optional(),questions:V($s)})]),tc=H({requestId:wo([L(),z().int()]),threadId:L(),kind:W([`approval`,`question`]),interaction:ec,request:Zs}),nc=H({id:L().min(1),clientUserMessageId:L().min(1),input:V(Zs),presentationInput:V(Zs).nullable().optional()}).passthrough();H({fields:V(H({path:V(wo([L(),z().int().nonnegative()])),originalLength:z().int().nonnegative()}))});let rc=H({id:L().min(1),status:L().min(1),codexhostTurnOutcome:H({status:G(`unknown`),reason:L()}).optional(),items:V(H({id:L().min(1),type:L().min(1)}).passthrough()),codexhostFileOperations:V(H({beforeItemId:L().nullable(),item:H({id:L().min(1),type:L().min(1)}).passthrough()})).optional(),error:H({message:L().optional()}).passthrough().nullable().optional(),fingerprint:L().min(1).optional(),unchanged:G(!0).optional()}).passthrough(),ic=H({id:L().min(1).max(512),fingerprint:L().min(1).max(128)});H({threadId:L().min(1),knownTurns:V(ic).max(64).optional(),truncateToolOutput:B().optional()});let ac=H({harnessId:L().min(1),nativeSessionId:L().min(1)});H({cursor:Qs,activeTurnId:L().min(1).nullable().optional(),command:H({name:L().min(1),turn:rc,subsequentTurnId:L().min(1).optional()}).optional(),thread:H({id:L().min(1),cwd:L(),modelProvider:L().min(1),createdAt:z(),updatedAt:z(),status:H({type:L()}).passthrough(),name:L().nullable().optional(),preview:L().optional(),codexhostImportSource:ac.optional(),turns:V(rc).length(0)}).passthrough(),turnsPage:H({data:V(rc).max(5),nextCursor:L().nullable()}),configuration:H({native:H({model:L().min(1).max(1024).optional(),reasoningEffort:L().min(1).max(128).optional()}).optional(),effectiveModel:zs.optional(),effectiveThinkingOptionId:Bs.optional(),effectivePermissionModeId:Cs.optional()}),queue:H({items:V(nc),pausedReason:W([`interrupted`,`outcome-unknown`,`failed`]).nullable()}).optional(),interactions:V(tc)}),H({version:G(1),owner:G(`service`).optional(),pid:z().int().positive(),port:z().int().min(1).max(65535),token:L().regex(/^[0-9a-f]{64}$/u),startedAt:z(),epoch:L().uuid()}),H({epoch:L().uuid(),threadId:L().min(1),requestId:wo([L(),z().int()]),result:Zs}),H({includeArchived:B().optional(),officialCursor:H({live:L().nullable(),archived:L().nullable().optional()}).strict().optional()}).strict(),H({threads:V(ps),ownership:V(Xs),archivedThreadIds:V(K),officialCursor:H({live:L().nullable(),archived:L().nullable().optional()}).strict().optional()}).strict();let oc=L().regex(/^audio\/[a-z0-9.+-]+(?:\s*;[^\r\n]*)?$/i);H({available:B()}).strict(),H({path:L().min(1),mimeType:oc}).strict();let sc=W([`credentials-unavailable`,`login-expired`,`rate-limited`,`service-rejected`,`host-incompatible`,`network`,`timeout`,`audio-empty`,`audio-too-large`,`audio-format`,`audio-invalid`]);Eo(`ok`,[H({ok:G(!0),text:L()}).strict(),H({ok:G(!1),error:H({code:sc}).strict()}).strict()]),H({threadId:K.optional(),cwd:L().min(1).optional()}).strict().refine(e=>!(e.threadId&&e.cwd),{message:`Specify threadId or cwd, not both`});let cc=H({name:L().min(1).regex(/^[^\s[\]]+$/u),description:L().optional(),path:L().min(1),scope:W([`project`,`global`]),source:L().min(1)}).strict();H({revision:z().int().nonnegative(),complete:B(),skills:V(cc),warnings:V(L()).optional()}).strict(),H({cwd:L().min(1).optional()}).strict();let lc=H({kind:W([`public`,`relay`,`tailscale-funnel`,`tailscale-https`,`tailscale`,`lan`,`virtual`]),url:L().min(1)}).strict(),uc=Eo(`status`,[H({status:G(`not-installed`)}),H({status:G(`not-running`)}),H({status:G(`not-logged-in`)}),H({status:G(`https-disabled`)}),H({status:G(`not-serving`),command:L()}),H({status:G(`occupied`),target:L()}),H({status:G(`serving`),url:L(),funnel:B()}),H({status:G(`error`),message:L()})]);H({state:uc,error:L().optional()}).strict();let dc=Eo(`status`,[H({status:G(`on`)}),H({status:G(`off`)}),H({status:G(`invalid`),reason:L()})]),fc=H({lan:B(),autostart:dc}).strict(),pc=H({expiresAt:L().optional(),issuing:B(),failure:H({detail:L().optional(),retryAt:L(),paused:B()}).optional()}),mc=Eo(`status`,[H({status:G(`off`),reason:W([`invite`,`name-taken`,`banned`]).optional()}),H({status:G(`connecting`),reason:W([`full`,`unreachable`]).optional()}),H({status:G(`connected`),url:L(),certificate:pc}),H({status:G(`missing-certificate`),url:L(),certificate:pc}),H({status:G(`stopped`),reason:W([`replaced`,`rejected`,`unsupported-version`])})]);L().max(253).regex(/^(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z](?:[a-z0-9-]{0,61}[a-z0-9])?$/i).transform(e=>e.toLowerCase()),L().regex(/^(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)?$/);let hc=W([`official`,`self-hosted`]);H({secret:L().min(1),lastUsedAt:z().nullable(),networkUrls:V(lc),directCandidates:V(lc).optional(),tailscale:uc,background:fc.optional(),relay:H({state:mc,enabled:B(),kind:hc,officialHost:L(),customHost:L().optional(),officialHostname:L().optional(),customHostname:L().optional(),quotaUntil:L().optional()}).strict().optional()}).strict();let gc=U({threadId:L().min(1).max(1024),view:W([`result`,`messages`]),from:z().int().min(1).max(2**53-1).optional(),to:z().int().min(1).max(2**53-1).optional()}),_c=H({id:L().min(1).max(256),harnessId:L().min(1),label:L().min(1).max(512),provider:W([`openai-codex`,`xai`])}).strict(),vc=L().regex(/^[a-z][a-z0-9-]{0,47}$/),yc=H({name:vc,source:_c,importedAt:L()}).strict(),bc=Eo(`action`,[H({action:G(`list`)}).strict(),H({action:G(`import`),sourceId:L().min(1).max(256),name:vc,confirmed:G(!0)}).strict(),H({action:G(`reimport`),sourceId:L().min(1).max(256),name:vc,confirmed:G(!0)}).strict(),H({action:G(`remove`),name:vc,confirmed:G(!0)}).strict()]),xc=H({provider:L().min(1).max(128),type:W([`oauth`,`api_key`,`unknown`]),label:L().min(1).max(512).optional(),vendor:W([`openai-codex`,`xai`]).optional()}).strict();H({sources:V(_c),targets:V(H({harnessId:L(),providers:V(W([`openai-codex`,`xai`])),imports:V(yc),others:V(xc).default([])}).strict())}).strict(),H({targetHarnessId:L().min(1).max(128).optional(),request:bc}).strict(),H({events:B()});let Sc=V(U({agent:L().min(1).max(128),section:W([`main`,`more`,`auto`])})).max(256).refine(e=>new Set(e.map(e=>e.agent)).size===e.length,`Duplicate Harness IDs`);U({entries:Sc.nullable()}),U({}),U({entries:Sc,initializeOnly:B().optional()});let Cc=U({enabled:B(),timeoutMinutes:z().int().min(5).max(1440)});Object.freeze({enabled:!1,timeoutMinutes:10});let wc=L().regex(/^external$/u),Tc=bs.transform(e=>String(e)),Ec=U({model:zs.optional(),thinkingOptionId:Bs.optional(),permissionModeId:Cs.optional()}).refine(e=>!!(e.model||e.thinkingOptionId||e.permissionModeId),`A default configuration must contain a preference`),Dc=U({lastHarness:bs.optional(),byHarness:Mo(Tc,Ec)}),Oc=L().min(1).max(1024),kc=U({idleRelease:Cc.optional(),favorites:Mo(Tc,V(Oc).max(2048)).default({}),newThread:Dc.optional()});U({scope:wc,revision:z().int().nonnegative(),values:kc}),U({scope:wc.default(`external`)});let Ac=Eo(`kind`,[U({kind:G(`idleRelease`),value:Cc}),U({kind:G(`favorite`),harnessId:bs,modelId:Oc,enabled:B()}),U({kind:G(`favorites`),harnessId:bs,modelIds:V(Oc).max(2048)}),U({kind:G(`newThread`),lastHarness:bs.optional(),harnessId:bs.optional(),configuration:Ec.optional()})]);U({scope:wc.default(`external`),operations:V(Ac).min(1).max(256),initializeOnly:B().optional(),expectedRevision:z().int().nonnegative().optional()}).superRefine((e,t)=>{for(let n of e.operations)n.kind===`newThread`&&(!n.lastHarness&&!n.configuration||!!n.harnessId!=!!n.configuration)&&t.addIssue({code:`custom`,message:`A default Harness or complete configuration is required`})}),U({version:G(1),revision:z().int().nonnegative(),scopes:Mo(wc,kc)});let jc=z().finite().nonnegative(),Mc=U({input:jc,output:jc,cacheRead:jc.optional(),cacheWrite:jc.optional(),cacheWrite1h:jc.optional()}),Nc=L().max(512).refine(e=>e.trim()===e&&e.length>0,`Model ID is required`);U({path:L(),entries:V(U({key:L(),price:Mc})),error:L().nullable()}),U({}),U({key:Nc,price:Mc.nullable(),previousKey:Nc.optional()}),U({model:Nc});let Pc=U({official:B().optional(),canonicalModelId:L().min(1).optional(),provider:L().min(1).max(512),model:L().min(1).max(512),price:Mc});U({price:Mc.nullable(),suggestions:V(Pc).max(6).optional()});let Fc=[`today`,`7d`,`30d`,`90d`,`all`],Ic=z().int().min(0).max(2**53-1),Lc=L().regex(/^\d{4}-\d{2}-\d{2}$/u),Rc=L().min(1).max(128),zc=L().min(1).max(512),Bc=L().min(1).max(4096);U({range:W(Fc),timeZone:L().min(1).max(128).refine(e=>{try{return new Intl.DateTimeFormat(`en`,{timeZone:e}),!0}catch{return!1}},`Unsupported usage statistics timezone`).optional(),harness:Rc.optional(),model:zc.nullable().optional(),project:Bc.nullable().optional(),date:Lc.optional()});let Vc=U({requests:Ic,inputTokens:Ic,cachedInputTokens:Ic,cacheWriteInputTokens:Ic,cacheKnownInputTokens:Ic,cacheHitCachedInputTokens:Ic,cacheHitInputTokens:Ic,outputTokens:Ic,reasoningOutputTokens:Ic,costUsd:z().finite().min(0),unpricedRequests:Ic,unmeteredRequests:Ic}),Hc=Vc.shape,Uc=U({harness:Rc,sessionId:L().min(1).max(512),project:Bc.nullable(),title:L().min(1).max(200).optional(),models:V(zc).max(16),firstAtMs:Ic,lastAtMs:Ic,...Hc});U({range:W(Fc),from:Lc.nullable(),to:Lc,filters:U({harness:Rc.nullable(),model:zc.nullable(),unknownModel:B(),project:Bc.nullable(),unknownProject:B(),date:Lc.nullable()}),reading:U({complete:B(),sources:Ic,read:Ic}),failures:V(U({harness:Rc,message:L().max(2048)})).max(256),options:U({harnesses:V(Rc).max(256),models:V(zc.nullable()).max(4096),projects:V(Bc.nullable()).max(4096)}),modelLabels:V(U({harness:Rc,model:zc,label:zc})).max(4096).optional(),credits:V(U({harness:Rc,model:zc.nullable(),credits:z().finite().min(0),reportedRequests:Ic,requests:Ic})).max(4096).optional(),totals:Vc,daily:V(U({date:Lc,harness:Rc,...Hc})).max(2e5),hourly:V(U({weekday:z().int().min(0).max(6),hour:z().int().min(0).max(23),...Hc})).max(168),byHarness:V(U({harness:Rc,...Hc})).max(256),byModel:V(U({model:zc.nullable(),...Hc,harnessPricedRequests:Ic})).max(4096),byProject:V(U({project:Bc.nullable(),...Hc})).max(4096),sessions:V(Uc).max(100),recentSessions:V(Uc).max(100).optional()}),H({threadId:K}),H({discarded:B()});let Wc=Eo(`type`,[H({id:L().min(1),type:G(`choice`),prompt:L(),options:V(H({value:L().min(1),label:L(),description:L().optional()})).min(1),multiple:B(),allowOther:B(),optional:B()}),H({id:L().min(1),type:G(`text`),prompt:L(),multiline:B(),secret:G(!1),optional:B(),placeholder:L().optional(),prefill:L().optional()})]),Gc=H({interactionId:L().min(1),turnId:L().min(1),title:L().optional(),questions:V(Wc).min(1)}).refine(({questions:e})=>e.some(e=>e.type===`choice`&&e.multiple),{message:`Shared cards require at least one multi-select question`});U({threadId:L().min(1)}),H({questions:V(Gc)}),U({threadId:L().min(1),turnId:L().min(1),interactionId:L().min(1),answers:Mo(L(),V(L())),cancelled:B().default(!1)}),H({accepted:G(!0)});let Kc=H({path:L(),oldText:L().nullable(),newText:L()});H({sessionId:L().min(1),turn:z().int().nonnegative(),path:L().min(1).optional()}),H({diffs:V(Kc)}),U({}),U({}),H({reference:H({sessionId:L().min(1),epoch:L().min(1),turn:z().int().nonnegative(),seq:z().int().nonnegative(),callId:L().min(1),part:z().int().nonnegative(),version:L().min(1)}),length:z().int().nonnegative(),bytes:z().int().nonnegative()});let qc=L().min(1).max(128).regex(/^[a-z][a-z0-9]*(?:[._-][a-z0-9]+)*$/u).pipe(bs),Jc=qc.refine(e=>e!==`codex`,`The official Codex identity is reserved`),Yc=L().min(1).max(512).refine(e=>!/[\\\u0000:#?]/u.test(e)&&!e.startsWith(`/`)&&!e.split(`/`).some(e=>e===`..`||e===``),`Plugin resources must be relative paths inside the plugin`),Xc=Ja().refine(e=>/^https:\/\/[^/?#@]+(?:[/?#]|$)/iu.test(e),`Plugin documentation links must be credential-free HTTPS URLs`),Zc=H({en:L().max(4096),"zh-CN":L().max(4096).optional()}).strict(),Qc=H({commands:V(H({terminal:L().max(256),command:L().max(4096)}).strict()).max(8),before:Zc.optional(),after:Zc.optional(),downloads:V(H({label:L().max(128),url:Xc}).strict()).max(8).optional()}).strict(),$c={id:qc,name:L().trim().min(1).max(128),version:L().min(1).max(128),kind:G(`usage`).optional(),iconStyle:H({vector:H({viewBox:L().max(128).regex(/^-?\d+(?:\.\d+)?(?: +-?\d+(?:\.\d+)?){3}$/u),color:L().regex(/^(?:currentColor|#[a-f0-9]{6})$/iu),paths:V(H({d:L().min(1).max(32768).regex(/^[MmLlHhVvCcSsQqTtAaZz\d.,+eE\s-]+$/u),fillRule:W([`evenodd`,`nonzero`]).optional(),fill:L().regex(/^(?:currentColor|#[a-f0-9]{6})$/iu).optional()}).strict()).min(1).max(32)}).strict().optional(),background:L().regex(/^#[a-f0-9]{6}$/iu).optional(),borderRadius:z().min(0).max(50).optional(),paddingRatio:z().min(0).max(.25).optional()}).strict().optional(),installation:Qc.optional(),notice:Zc.optional(),launchCommand:G(!0).optional(),links:H({website:Xc.optional(),documentation:Xc.optional(),installation:Xc.optional()}).strict().optional()};H({manifestVersion:G(1),...$c,adapterApiVersion:z().int().positive(),entry:Yc,icon:Yc.optional()}).strict();let el=L().max(174828).regex(/^data:image\/(?:png|jpeg|webp|svg\+xml);base64,[A-Za-z0-9+/]+={0,2}$/u),tl=H({...$c,icon:el.optional()}).strict();H({}).strict(),H({plugins:V(tl.extend({id:Jc})).max(128)}).strict(),H({version:G(1),enabled:V(qc).max(128)}).strict().refine(e=>new Set(e.enabled).size===e.enabled.length,{message:`Enabled plugin IDs must be unique`,path:[`enabled`]}),H({harnessId:Jc}).strict().extend({enabled:B()}),H({enabled:B()}).strict(),U({title:L().trim().min(1).max(200),type:W([`info`,`warning`,`danger`]),body:L().trim().min(1).max(16384)}),U({}),U({url:L().max(2048).regex(/^http:\/\/(?:127\.0\.0\.1|localhost):\d{1,5}\/(?:\?.*)?$/u)}),Object.freeze(/* @__PURE__ */ `codexhost/console/remote-connections.codexhost/runtime/status.codexhost/remote/ssh-setup.codexhost/harness/plugins/list.codexhost/harness/display-settings/capabilities.codexhost/harness/display-settings/get.codexhost/harness/display-settings/set.codexhost/harness/inspect.codexhost/harness/installation.codexhost/harness/installation/start.codexhost/harness/installation/status.codexhost/harness/launch-settings/get.codexhost/harness/launch-settings/set.codexhost/harness/long-context/get.codexhost/harness/long-context/set.codexhost/harness/web-ui/open.codexhost/harness/accounts/sources.codexhost/harness/accounts/list.codexhost/harness/accounts/inspect.codexhost/harness/credential-imports.codexhost/harness/session-import/sources.codexhost/harness/session-import/list.codexhost/harness/session-import/import.codexhost/account/list.codexhost/account/refresh.codexhost/account/usage/inspect.codexhost/usage/model-prices/get.codexhost/usage/model-prices/set.codexhost/usage/model-prices/default.codexhost/usage/statistics/get.codexhost/update/check.codexhost/update/start.codexhost/update/status`.split(`.`));let nl=W([`idle`,`running`,`busy`,`closing`,`failed`,`blocked`]),rl=W([`none`,`disabled`,`timeout`,`operation`,`background`,`identity`,`persistence`,`closeFailed`]);U({threadId:L(),title:L(),harnessId:L(),state:nl,reason:rl,inactiveMs:z().nonnegative()}),U({threadId:K,turnId:xs});let il=H({amount:z().finite().nonnegative(),currency:L().trim().min(1).max(8),label:L().trim().min(1).max(128).optional()}).strict(),al=H({email:L().trim().min(1).max(320).optional(),label:L().trim().min(1).max(256).optional(),plan:L().trim().min(1).max(128).optional(),credits:Ls.optional(),balance:il.optional()}).strict();function ol(e){return e.refine(e=>{let t=e;return t.credits!==void 0||t.balance!==void 0},{message:`Account must report either credits or a balance`})}let sl=ol(al),cl={harnessId:bs,harnessName:L().trim().min(1).max(128)},ll=H(cl).strict();H({}).strict(),H({sources:V(ll).max(128)}).strict(),H({harnessId:bs,refresh:B().optional()}).strict(),H({...cl,account:sl.nullable(),accounts:V(sl).max(8).optional()}).strict(),H({refresh:B().optional()}).strict(),H({accounts:V(ol(al.extend(cl))).max(128)}).strict(),H({harnessId:Jc,model:zs.optional(),thinkingOptionId:Bs.optional(),permissionModeId:Cs.optional(),prewarm:G(!0).optional()}).strict();let ul=L().trim().min(1).max(4096).refine(e=>!/[\u0000\r\n]/u.test(e),`Invalid entrypoint path`);H({harnessId:Jc}).strict().extend({path:ul.nullable()}),H({path:ul.nullable(),restartRequired:B()}).strict(),H({harnessId:bs,action:W([`check`,`update`,`install`])}).strict();let dl=H({currentVersion:L().min(1).max(128),latestVersion:L().min(1).max(128),updateAvailable:B(),canUpdate:B(),versionKind:W([`cli`,`application`]).optional(),manualUpdateUrl:Ja().max(2048).refine(e=>/^https:\/\/[^/?#@]+(?:[/?#]|$)/iu.test(e),`Manual updates require a credential-free HTTPS URL`).optional(),message:L().max(2048).optional(),messageCode:L().min(1).max(128).optional(),notice:vs.optional(),latestVersionKind:W([`unknown`,`tracking-branch`]).optional()}).strict();H({taskId:L().uuid()}).strict(),Eo(`status`,[H({taskId:L().uuid(),status:G(`running`)}).strict(),H({taskId:L().uuid(),status:G(`succeeded`),result:dl}).strict(),H({taskId:L().uuid(),status:G(`failed`),error:H({code:z().int(),message:L().min(1).max(2048)}).strict()}).strict()]);let fl=L().min(1).max(256).regex(/^[A-Za-z0-9._~-]+$/u),pl=L().trim().min(1),ml=W([`api`,`chatgpt`]),hl=/^https?:\/\/(?:\[[0-9a-fA-F:]+\]|[^/\s:@?#]+)(?::\d{1,5})?(?:[/?#][^\s]*)?$/u;function gl(e){return e.length>0&&e.length<=2048&&hl.test(e)}H({url:L().max(2048).refine(gl,`External URL must be http(s)`)}).strict(),H({}).strict();let _l=W([`free`,`go`,`plus`,`pro`,`prolite`,`team`,`self_serve_business_prolite`,`self_serve_business_usage_based`,`business`,`ent26`,`enterprise_cbp_automation`,`enterprise_cbp_usage_based`,`enterprise`,`edu`,`edu_plus`,`edu_pro`,`unknown`]),vl=H({accountId:fl,label:pl.max(256),email:L().email().max(320).optional(),planType:_l.optional(),authKind:ml.optional(),authIdentity:pl.max(256).optional(),siteUrl:L().refine(gl,`Account site URL must be http(s)`).optional()}).strict(),yl=W([`ready`,`unavailable`]);H({version:G(2),currentAccountId:fl.nullable(),phase:yl,revision:z().int().nonnegative(),instanceId:pl.max(1024).optional(),accounts:V(vl).max(1)}).strict(),H({accountId:fl,refresh:B().optional()}).strict(),H({accountId:fl,usage:js.nullable(),accountCredits:Ls.optional(),freshness:W([`live`,`cached`]),observedAt:L().datetime().nullable()}).strict();let bl=1e3,xl=L().refine(e=>e.trim().length>0,`Value must not be empty or whitespace`).refine(e=>!e.includes(`\0`),`Value must not contain NUL`),Sl=xl.max(1024),Cl=H({nativeSessionId:Sl,title:xl.max(4096).nullable(),updatedAt:z().int().nonnegative().max(864e13),cwd:xl.max(16384),running:B().nullable()}).strict();H({}).strict(),H({harnesses:V(H({harnessId:Jc,name:xl.max(128)}).strict()).max(128)}).strict(),H({harnessId:Jc,query:L().trim().max(4096).refine(e=>!e.includes(`\0`)).optional(),offset:z().int().nonnegative().safe().optional(),limit:z().int().min(1).max(bl).optional()}).strict(),H({candidates:V(Cl).max(bl),total:z().int().nonnegative().safe()}).strict(),H({harnessId:Jc,nativeSessionId:Sl}).strict(),H({threadId:xl.max(1024).pipe(K)}).strict();let wl=L().refine(e=>e.trim().length>0,`Value must not be empty or whitespace`).refine(e=>!e.includes(`\0`),`Value must not contain NUL`),Tl=Sl,El=Cl;H({}).strict(),H({candidates:V(El).max(1e3)}).strict(),H({nativeSessionId:Tl}).strict(),H({threadId:wl.max(1024).pipe(K)}).strict(),H({threadId:K,lastTurnId:xs}).strict(),H({threadId:K}).strict();let Dl=L().trim().min(1).max(128).regex(/^[A-Za-z0-9._:-]+$/u).brand();H({commands:V(H({id:Dl,invocation:L().min(1).max(128),label:L().trim().min(1).max(128),description:L().trim().min(1).max(512).optional(),localizations:_s.optional(),argumentMode:W([`none`,`text`]),kind:W([`command`,`skill`]).optional()}).strict()),warnings:V(L().min(1)).optional(),source:W([`live`,`static`]).optional()}).strict().superRefine((e,t)=>{let n=/* @__PURE__ */ new Set;for(let[r,i]of e.commands.entries())n.has(i.id)&&t.addIssue({code:`custom`,message:`Harness command IDs must be unique`,path:[`commands`,r,`id`]}),n.add(i.id)}),H({harnessId:bs,cwd:L().min(1).optional()}).strict(),H({threadId:K}).strict(),H({threadId:K,commandId:Dl,turnId:xs.optional(),arguments:ps.optional()}).strict(),H({accepted:G(!0),turnId:xs.optional()}).strict();let Ol=G(`2.0`).optional(),kl=bo().optional(),Al=L().min(1),jl=wo([L(),z().int()]),Ml=H({code:z().int(),message:L(),data:fs.optional()}).catchall(fs).superRefine(ss([`data`]));wo([H({jsonrpc:Ol,id:jl,method:Al,params:fs.optional(),result:kl,error:kl}).catchall(fs).superRefine(ss([`jsonrpc`,`params`,`result`,`error`])),H({jsonrpc:Ol,id:kl,method:Al,params:fs.optional(),result:kl,error:kl}).catchall(fs).superRefine(ss([`jsonrpc`,`id`,`params`,`result`,`error`])),H({jsonrpc:Ol,id:jl,method:kl,params:kl,result:fs,error:kl}).catchall(fs).superRefine(ss([`jsonrpc`,`method`,`params`,`error`])),H({jsonrpc:Ol,id:jl,method:kl,params:kl,result:kl,error:Ml}).catchall(fs).superRefine(ss([`jsonrpc`,`method`,`params`,`result`]))]);let Nl=L().refine(e=>e.trim().length>0,{message:`Native identifier must not be empty or whitespace`});U({harnessId:bs,nativeSessionId:Nl,locator:fs.optional(),formatVersion:G(1)}).superRefine(ss([`locator`])),U({harnessId:bs,nativeSessionId:Nl,nativeTurnKey:Nl,formatVersion:G(1)}),U({harnessId:bs,nativeSessionId:Nl,checkpointId:Nl,locator:fs.optional(),formatVersion:G(1)}).superRefine(ss([`locator`]));let Pl=L().regex(/^\d+\.\d+\.\d+(?:-[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?(?:\+[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/u),Fl=W([`npm`,`windows-installer`,`macos-dmg`]),Il=U({version:Pl,installation:Fl,phase:W([`prepared`,`downloading`,`waiting-for-exit`,`installing`,`restarting`,`succeeded`,`failed`]),updatedAt:z().int().nonnegative(),downloadedBytes:z().int().nonnegative().optional(),totalBytes:z().int().positive().optional(),error:L().min(1).max(500).nullable(),serviceStopOutput:L().optional()}).superRefine((e,t)=>{e.downloadedBytes!==void 0&&e.totalBytes!==void 0&&e.downloadedBytes>e.totalBytes&&t.addIssue({code:`custom`,path:[`downloadedBytes`],message:`downloadedBytes must not exceed totalBytes`})});U({});let Ll=L().max(300).regex(/^https:\/\/github\.com\/(LiberSeek|LIBERSEEK)\/BOFT-CLI\/releases\/tag\/v[0-9A-Za-z.+-]+$/u,`release notes URL must identify a codexhost GitHub Release`);U({currentVersion:Pl,installation:Fl.nullable(),latestVersion:Pl.nullable(),updateAvailable:B(),installationAvailable:B(),releaseNotes:L().min(1).max(2e4).nullable(),releaseNotesUrl:Ll.nullable(),status:Il.nullable(),error:L().min(1).max(500).nullable()}),U({status:Il}),U({status:Il.nullable()});let Rl=RegExp(String.raw`^- \[([^\]\n]+)\]\(thread://([^\s()<>"?#/]+)\): `+`(${[`completed`,`failed`,`interrupted`,`needsInput`,`timedOut`,`unreadable`,`notFound`].join(`|`)})(?:\. (.+))?$`,`u`);function zl(e){let[t,...n]=e.trim().split(/\r?\n/u);if(t!==`[codexhost thread watch] Read each Thread's result, then continue your task:`)return;let r=[];for(let e of n){if(!e.trim())continue;let t=Rl.exec(e);if(!t)return;let[,n=``,i=``,a,o]=t;r.push({threadId:i,label:n,outcome:a,...o?{note:o}:{}})}return r.length>0?r:void 0}let Bl=`<response-annotations>`,Vl=`</response-annotations>`,Hl=/## My request(?: for Codex)?:/gu;function Ul(e){if(e.length===0)return``;let t=e.map(({text:e,annotation:t})=>({text:e,...t===void 0?{}:{annotation:t}}));return`\n# Response annotations:\nEach item contains text selected from an earlier Codex response and may include a user comment. Treat items as Annotation 1, Annotation 2, and so on in array order. Use every selection as context and address every comment. For every annotation you address, include its inline directive \`:codex-annotation{index="N"}\`, where N is its one-based array position (for example, \`:codex-annotation{index="1"}\`). Do not use unstructured annotation labels.\n${Bl}\n${JSON.stringify(t)}\n${Vl}\n`}function Wl(e,t){let n=Ul(e);return n===``?t:`${n}\n## My request:\n${t}\n`}function Gl(e){let t=e.trimStart().startsWith(`# Response annotations:`)?0:e.length,n=e.indexOf(`\n${Bl}\n`,t);if(n<0)return``;let r=n+1+22+1,i=e.indexOf(`\n${Vl}`,r);return i<0?``:e.slice(r,i)}function Kl(e){return{annotations:Yl(e),body:ql(e)}}function ql(e){let t=0;for(let n of e.matchAll(Hl))t=n.index+n[0].length;return e.slice(t).trim()}function Jl(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Yl(e){let t=Gl(e);if(t===``)return[];let n;try{n=JSON.parse(t)}catch{return[]}if(!Array.isArray(n)||n.length===0)return[];let r=[];for(let e of n){if(!Jl(e))return[];let{text:t,annotation:n}=e;if(typeof t!=`string`||t.length===0||n!==void 0&&(typeof n!=`string`||n.length===0))return[];r.push({text:t,...n===void 0?{}:{annotation:n}})}return r}function Xl(e){return Yl(e)}let Zl=W([`idle`,`installing`,`restarting`,`succeeded`,`failed`]);H({runningVersion:L().nullable(),installedVersion:L().nullable(),restartRequired:B(),remote:B(),updateSupported:B(),update:H({phase:Zl,targetVersion:L().nullable(),error:L().nullable()})});let Ql=H({version:L().regex(/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/u)}).strict();H({hostname:L().min(1).max(1024).refine(e=>!e.startsWith(`-`)&&!/\s/u.test(e)),port:z().int().min(1).max(65535).nullable(),identity:L().max(4096).nullable(),action:W([`inspect`,`install`,`update`,`repair`,`uninstall`]),uninstallPackage:B().optional(),version:L().regex(/^\d+\.\d+\.\d+$/u).nullable()}).strict(),H({state:W([`installed`,`not-installed`])}).strict();let $l=L().min(1).max(1024),eu={hostId:$l.regex(/^remote-(?:ssh(?:-|:)|control:)/u)},tu={...eu,threadId:$l},nu=Eo(`kind`,[U({kind:G(`hosts`)}),U({kind:G(`status`),...tu}),U({kind:G(`list`),...eu,cursor:L().nullable(),archived:B()}),U({kind:G(`read`),...tu,page:U({cursor:L().min(1).max(8192).nullable(),epoch:$l.optional(),sortDirection:W([`asc`,`desc`]).optional(),limit:z().int().min(1).max(20).optional()}).refine(e=>e.cursor===null||e.epoch!==void 0,{message:`A history continuation requires its connection epoch`}).optional()}),U({kind:G(`usage`),...tu,epoch:$l}),U({kind:G(`configure`),...tu,epoch:$l,modelId:$l.optional(),thinkingOptionId:$l.optional(),permissionModeId:$l.optional()}).refine(e=>[e.modelId,e.thinkingOptionId,e.permissionModeId].filter(e=>e!==void 0).length===1,`Select exactly one remote setting`),U({kind:G(`prompt`),...tu,epoch:$l,text:L().min(1).max(8e3),requestId:$l.optional()}),U({kind:G(`interrupt`),...tu,epoch:$l,turnId:$l}),U({kind:G(`rename`),...tu,epoch:$l,name:L().min(1).max(512)}),U({kind:G(`archive`),...tu,epoch:$l,archived:B()}),U({kind:G(`respond`),...tu,epoch:$l,requestId:wo([$l,z().int()]),result:Mo(L(),vo())})]),ru=L().min(1).max(1024),iu=H({hostId:ru,displayName:L().min(1).max(1024),source:W([`codex-managed`,`discovered`]),sshAlias:L().max(1024).nullable(),sshHost:L().min(1).max(1024),sshPort:z().int().min(1).max(65535).nullable(),identity:L().max(4096).nullable(),autoConnect:B(),connectionAnalyticsId:L().max(1024).optional()}),au=U({displayName:L().min(1).max(1024),hostname:L().min(1).max(1024),sshPort:z().int().min(1).max(65535).nullable(),identity:L().max(4096).nullable()});Eo(`action`,[U({action:G(`session`),operation:nu}),U({action:G(`list`)}),U({action:G(`catalog`)}),U({action:G(`read-thread`),hostId:ru.refine(e=>e!==`local`),input:gc}),U({action:G(`save`),draft:au,previous:iu.nullable()}),U({action:G(`remove`),previous:iu}),U({action:G(`connect`),hostId:ru,enabled:B()}),U({action:G(`state`),hostId:ru}),U({action:G(`runtime`),hostId:ru}),U({action:G(`update`),hostId:ru.refine(e=>e!==`local`),version:Ql.shape.version})]),wo([U({result:fs}),U({error:U({code:z().int(),message:L()})})]),U({prompt:L().trim().min(1).max(2e3),cwd:L().max(4096).nullable()}),L().trim().min(1).max(60).nullable();let ou=L().max(214).regex(/^(?:@[a-z0-9][a-z0-9._-]*\/)?[a-z0-9][a-z0-9._-]*$/u),su=wo([L(),H({en:L()}).catchall(L())]),cu=H({title:su.optional(),description:su.optional(),icon:L().max(349592).regex(/^data:image\/(?:svg\+xml|png|jpeg|webp);base64,[A-Za-z0-9+/]*={0,2}$/u).optional(),error:L().optional()});H({extensions:V(H({id:ou,name:L().min(1).max(214),version:L().min(1).max(128),format:G(`dsh`),supportedTargets:Ao([G(`web`)]),enabledTargets:V(G(`web`)).max(1),source:L().min(1).max(4096),projectUrl:L().max(4096).url({protocol:/^https?$/u}).optional(),installedAt:L(),meta:cu.optional(),loadError:L().optional()})),loadedIds:V(ou),safeMode:B(),storeError:L().optional()});let lu=L().trim().max(2048).url({protocol:/^https?$/u,normalize:!0}).refine(e=>!/[\s\\?#]/u.test(e)&&!e.split(`/`)[2]?.includes(`@`),`Use an HTTP(S) registry URL without credentials, a query, or a fragment.`).transform(e=>e.endsWith(`/`)?e:`${e}/`);H({spec:L().trim().min(1).max(4096),registry:lu.optional()}).strict(),H({id:ou,enabled:B()}).strict(),H({id:ou}).strict(),G(1);function uu(e){return{code:{copyLabel:e(`copy`),copiedLabel:e(`copied`),toolbarLabels:{codeLabel:e(`codeBlock.title`),wrapLabel:e(`codeBlock.wrap`),unwrapLabel:e(`codeBlock.unwrap`)}},footnotes:e(`markdown.footnotes`)}}function du(e){return{label:t=>e(`annotation.label`,{index:t}),railLabel:t=>e(`annotation.chipLabel`,{index:t}),railTitle:(t,n)=>e(`annotation.title`,{index:t,excerpt:n}),remove:t=>e(`annotation.remove`,{index:t}),selectedText:e(`annotation.selectedText`),userComment:e(`annotation.userComment`)}}let fu=`@deepseek-ai/dsh-client-ui-chat/ThreadWatchNotice.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(fu)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=fu,e.textContent=`._5CV-Fq_card{box-sizing:border-box;border:1px solid var(--dsw-alias-border-l2);border-radius:var(--dsw-radius-lg);background:var(--dsw-alias-bg-base);width:fit-content;max-width:100%;color:var(--dsw-alias-label-secondary);font-size:var(--dsh-content-font-size-secondary,13px);align-items:flex-start;gap:10px;padding:10px 14px;line-height:20px;display:flex}._5CV-Fq_list{min-width:0;margin:0;padding:0;list-style:none}._5CV-Fq_entry+._5CV-Fq_entry{margin-top:10px}._5CV-Fq_line{align-items:center;gap:8px;min-width:0;display:flex}._5CV-Fq_line>svg,._5CV-Fq_bell{flex-shrink:0}._5CV-Fq_bell{color:var(--dsw-alias-label-tertiary);margin-top:3px}._5CV-Fq_title{text-overflow:ellipsis;white-space:nowrap;min-width:0;color:var(--dsw-alias-label-primary);overflow:hidden}._5CV-Fq_outcome,._5CV-Fq_open{white-space:nowrap;flex-shrink:0}._5CV-Fq_outcome[data-outcome=completed]{color:var(--dsw-alias-state-success-primary)}._5CV-Fq_outcome[data-outcome=failed]{color:var(--dsw-alias-state-error-primary)}._5CV-Fq_open a{color:var(--dsw-alias-state-business-primary);text-decoration:none}._5CV-Fq_open a:hover{text-decoration:underline}._5CV-Fq_open a:focus-visible{outline:2px solid var(--dsw-alias-state-business-primary);outline-offset:2px}._5CV-Fq_note{color:var(--dsw-alias-label-tertiary);overflow-wrap:anywhere;margin:4px 0 0 24px}@media (width<=480px){._5CV-Fq_line{flex-wrap:wrap}._5CV-Fq_title{flex:calc(100% - 52px)}._5CV-Fq_outcome{margin-left:24px}}`,document.head.appendChild(e)}var pu={bell:`_5CV-Fq_bell`,card:`_5CV-Fq_card`,entry:`_5CV-Fq_entry`,line:`_5CV-Fq_line`,list:`_5CV-Fq_list`,note:`_5CV-Fq_note`,open:`_5CV-Fq_open`,outcome:`_5CV-Fq_outcome`,title:`_5CV-Fq_title`};let mu=()=>()=>{};function hu({entry:e,links:t,t:n}){let r=`codex://threads/${e.threadId}`,i=()=>t?.describe?.(r)?.title,a=(0,d.useSyncExternalStore)(t?.resolve.subscribe??mu,i,i),o=a!==void 0;return/* @__PURE__ */ (0,f.jsxs)(`li`,{className:pu.entry,"data-thread-watch-entry":e.threadId,children:[/* @__PURE__ */ (0,f.jsxs)(`div`,{className:pu.line,children:[o?t?.describe?.(r)?.icon:/* @__PURE__ */ (0,f.jsx)(p.ReferenceIconRegular,{kind:`session`,size:14}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:pu.title,title:a??e.label,children:a??e.label}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:pu.outcome,"data-outcome":e.outcome,children:n(`message.watch.${e.outcome}`)}),o&&/* @__PURE__ */ (0,f.jsx)(`span`,{className:pu.open,children:/* @__PURE__ */ (0,f.jsx)(p.MarkdownAnchor,{href:r,glyph:!1,children:[n(`message.watch.open`)]})})]}),e.note!==void 0&&/* @__PURE__ */ (0,f.jsx)(`div`,{className:pu.note,children:e.note})]})}function gu({entries:e,links:t,t:n}){return/* @__PURE__ */ (0,f.jsxs)(`div`,{className:pu.card,"data-thread-watch-notice":!0,children:[/* @__PURE__ */ (0,f.jsx)(p.IconBellOutlineRegular,{className:pu.bell}),/* @__PURE__ */ (0,f.jsx)(`ul`,{className:pu.list,children:e.map((e,r)=>/* @__PURE__ */ (0,f.jsx)(hu,{entry:e,links:t,t:n},r))})]})}let _u=`@deepseek-ai/dsh-client-ui-chat/MessageItem.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(_u)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=_u,e.textContent=`._1ED1FG_userRow{flex-direction:column;align-items:flex-end;gap:6px;display:flex}._1ED1FG_noticeRow{flex-direction:column;align-items:center;gap:6px;min-width:0;display:flex}._1ED1FG_noticeStack{min-width:0;max-width:100%}._1ED1FG_userStack{min-width:0;max-width:min(calc(var(--dsh-chat-content-width,748px) * .702), 82%);flex-direction:column;align-items:flex-end;gap:8px;display:flex}._1ED1FG_annotationRow{flex-wrap:wrap;justify-content:flex-end;gap:6px;display:flex}._1ED1FG_bubble{background:var(--dsw-specific-bubble);border-radius:var(--dsw-radius-xl);max-width:100%;font-size:var(--dsh-content-font-size,14px);line-height:calc(22px + var(--dsh-content-font-delta,0px));color:var(--dsw-alias-label-primary);white-space:pre-wrap;word-break:break-word;padding:10px 16px}body[data-codexhost-wallpaper] ._1ED1FG_bubble{background:color-mix(in srgb, var(--dsw-specific-bubble) 84%, transparent);backdrop-filter:blur(12px)}._1ED1FG_referenceSummary{color:var(--dsw-alias-label-tertiary);font-size:var(--dsh-content-font-size-secondary,13px);line-height:calc(18px + var(--dsh-content-font-delta-secondary,0px))}._1ED1FG_contextRow{padding:2px 0}._1ED1FG_compactionRow{--dsh-compaction-header-height:calc(24px + var(--dsh-content-font-delta,0px));padding:2px 0}._1ED1FG_compactionButton{width:100%;height:var(--dsh-compaction-header-height);border-radius:var(--dsw-radius-sm);min-width:0;color:var(--dsw-alias-label-tertiary);font:inherit;text-align:left;background:0 0;border:none;align-items:center;padding:0;transition:color .1s;display:flex}._1ED1FG_compactionRow:has(._1ED1FG_compactionBody) ._1ED1FG_compactionButton{z-index:7;background:var(--dsw-alias-bg-base);border-radius:0;position:sticky;top:0}body[data-codexhost-wallpaper] ._1ED1FG_compactionRow:has(._1ED1FG_compactionBody) ._1ED1FG_compactionButton{background:color-mix(in srgb, var(--dsw-alias-bg-base) 78%, transparent);backdrop-filter:blur(12px)}._1ED1FG_compactionBody :has(>[data-code-block-banner]){top:var(--dsh-compaction-header-height)}._1ED1FG_compactionRow:has(._1ED1FG_compactionBody) ._1ED1FG_compactionButton:hover{background:var(--dsw-alias-interactive-bg-hover-solid)}._1ED1FG_compactionButton:not(:disabled){cursor:pointer}._1ED1FG_compactionButton:hover{color:var(--dsw-alias-label-secondary)}._1ED1FG_compactionButton:not(:disabled):hover{background:var(--dsw-alias-interactive-bg-hover)}._1ED1FG_compactionLeading{width:calc(16px + var(--dsh-content-font-delta,0px));height:calc(16px + var(--dsh-content-font-delta,0px));color:inherit;flex:none;place-items:center;margin-right:6px;display:inline-grid}._1ED1FG_compactionLeading svg{width:calc(14px + var(--dsh-content-font-delta,0px));height:calc(14px + var(--dsh-content-font-delta,0px))}._1ED1FG_compactionContextIcon,._1ED1FG_compactionDisclosureIcon{grid-area:1/1;justify-content:center;align-items:center;display:inline-flex}._1ED1FG_compactionDisclosureIcon,._1ED1FG_compactionButton:not(:disabled):hover ._1ED1FG_compactionContextIcon,._1ED1FG_compactionButton:not(:disabled):focus-visible ._1ED1FG_compactionContextIcon{opacity:0}._1ED1FG_compactionButton:not(:disabled):hover ._1ED1FG_compactionDisclosureIcon,._1ED1FG_compactionButton:not(:disabled):focus-visible ._1ED1FG_compactionDisclosureIcon{opacity:1}._1ED1FG_compactionTitle{font-size:var(--dsh-content-font-size-secondary,13px);line-height:calc(24px + var(--dsh-content-font-delta,0px));color:inherit;flex:none}._1ED1FG_compactionSep{background:var(--dsw-alias-label-caption);border-radius:1px;flex:none;width:2px;height:2px;margin:0 8px}._1ED1FG_compactionSummary{min-width:0;color:inherit;font-size:var(--dsh-content-font-size-secondary,13px);line-height:calc(24px + var(--dsh-content-font-delta,0px));text-overflow:ellipsis;white-space:nowrap;flex:auto;overflow:hidden}._1ED1FG_compactionBody{padding:4px 0 4px calc(22px + var(--dsh-content-font-delta,0px));color:var(--dsw-alias-label-tertiary);font-size:var(--dsh-content-font-size-secondary,13px);line-height:calc(24px + var(--dsh-content-font-delta,0px))}._1ED1FG_retryRow{color:var(--dsw-alias-label-tertiary);font-size:var(--dsh-content-font-size-secondary,13px);line-height:calc(20px + var(--dsh-content-font-delta-secondary,0px))}._1ED1FG_retrySummary{border-radius:var(--dsw-radius-sm);width:fit-content;max-width:100%;color:inherit;cursor:pointer;user-select:none;align-items:center;gap:7px;padding:2px 0;list-style:none;display:inline-flex}._1ED1FG_retrySummary::-webkit-details-marker{display:none}._1ED1FG_retrySummary:after{content:"";border-bottom:1.5px solid;border-right:1.5px solid;flex:none;width:6px;height:6px;margin-right:2px;transition:transform .12s;transform:rotate(-45deg)}._1ED1FG_retrySummary:hover{color:var(--dsw-alias-label-secondary)}@media (prefers-reduced-motion:reduce){._1ED1FG_compactionButton{transition:none}}._1ED1FG_retrySummary:focus-visible{outline:1.5px solid var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary));outline-offset:2px}._1ED1FG_retryText{overflow-wrap:anywhere;min-width:0}._1ED1FG_retryRow[open] ._1ED1FG_retrySummary:after{transform:rotate(45deg)}._1ED1FG_retryDetails{overflow-wrap:anywhere;font-size:var(--dsh-content-font-size-secondary,13px);line-height:calc(18px + var(--dsh-content-font-delta-secondary,0px));gap:2px;margin-top:3px;padding-left:14px;display:grid}._1ED1FG_retryDetailLabel{color:var(--dsw-alias-label-secondary)}._1ED1FG_turnErrorRow{font-size:var(--dsh-content-font-size-secondary,13px);line-height:calc(20px + var(--dsh-content-font-delta-secondary,0px));grid-template-columns:10px minmax(0,1fr) auto;align-items:start;gap:8px;padding:2px 0;display:grid}._1ED1FG_turnErrorDot{margin-top:5px}._1ED1FG_turnErrorCopy{overflow-wrap:anywhere;min-width:0}._1ED1FG_turnErrorTitle{color:var(--dsw-alias-state-error-primary);margin-right:6px;font-weight:600}._1ED1FG_turnErrorMessage{color:var(--dsw-alias-label-secondary)}._1ED1FG_turnErrorCode{color:var(--dsw-alias-label-tertiary);font:var(--dsw-font-markdown-code-block-small)}._1ED1FG_maxTokensTitle{color:var(--dsw-alias-state-warn-primary);margin-right:6px;font-weight:600}._1ED1FG_attachmentRow{flex-wrap:wrap;justify-content:flex-end;gap:8px;max-width:100%;display:flex}._1ED1FG_pendingAttachment{flex-direction:column;align-items:flex-end;gap:4px;min-width:0;display:flex}._1ED1FG_fileCard{border:.5px solid var(--dsw-alias-border-l2,#0000001f);border-radius:var(--dsw-radius-xl);background:var(--dsw-specific-input-major,transparent);box-sizing:border-box;flex:none;align-items:center;gap:10px;width:240px;min-height:64px;padding:8px 12px;display:inline-flex}._1ED1FG_fileIcon{flex:none;width:28px;height:28px}._1ED1FG_fileContent{flex-direction:column;flex:1;min-width:0;display:flex}._1ED1FG_fileName{white-space:nowrap;text-overflow:ellipsis;color:var(--dsw-alias-label-primary);font-size:14px;font-weight:500;line-height:22px;overflow:hidden}._1ED1FG_fileMeta{white-space:nowrap;text-overflow:ellipsis;color:var(--dsw-alias-label-tertiary,#00000073);font-size:12px;line-height:15px;overflow:hidden}._1ED1FG_editAction{color:inherit;cursor:pointer;border-radius:var(--dsw-radius-sm);background:0 0;border:0;justify-content:center;align-items:center;width:28px;height:28px;padding:6px;display:inline-flex}._1ED1FG_editAction:hover{background:var(--dsw-alias-interactive-bg-hover)}._1ED1FG_editAction svg{width:15px;height:15px}._1ED1FG_userStack:has(._1ED1FG_sentEditor){width:100%}._1ED1FG_sentEditor{box-sizing:border-box;border:1px solid var(--dsw-alias-border-main);border-radius:12px;width:100%;min-width:0;padding:12px}._1ED1FG_sentEditor textarea{resize:vertical;width:100%;min-height:100px;color:inherit;font:inherit;box-sizing:border-box;background:0 0;border:0;outline:0;line-height:1.6}._1ED1FG_sentEditor:focus-within{outline:1.5px solid var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary))}._1ED1FG_sentEditorActions{justify-content:flex-end;gap:8px;margin-top:8px;display:flex}`,document.head.appendChild(e)}var q={annotationRow:`_1ED1FG_annotationRow`,attachmentRow:`_1ED1FG_attachmentRow`,bubble:`_1ED1FG_bubble`,compactionBody:`_1ED1FG_compactionBody`,compactionButton:`_1ED1FG_compactionButton`,compactionContextIcon:`_1ED1FG_compactionContextIcon`,compactionDisclosureIcon:`_1ED1FG_compactionDisclosureIcon`,compactionLeading:`_1ED1FG_compactionLeading`,compactionRow:`_1ED1FG_compactionRow`,compactionSep:`_1ED1FG_compactionSep`,compactionSummary:`_1ED1FG_compactionSummary`,compactionTitle:`_1ED1FG_compactionTitle`,contextRow:`_1ED1FG_contextRow`,editAction:`_1ED1FG_editAction`,fileCard:`_1ED1FG_fileCard`,fileContent:`_1ED1FG_fileContent`,fileIcon:`_1ED1FG_fileIcon`,fileMeta:`_1ED1FG_fileMeta`,fileName:`_1ED1FG_fileName`,maxTokensTitle:`_1ED1FG_maxTokensTitle`,noticeRow:`_1ED1FG_noticeRow`,noticeStack:`_1ED1FG_noticeStack`,pendingAttachment:`_1ED1FG_pendingAttachment`,referenceSummary:`_1ED1FG_referenceSummary`,retryDetailLabel:`_1ED1FG_retryDetailLabel`,retryDetails:`_1ED1FG_retryDetails`,retryRow:`_1ED1FG_retryRow`,retrySummary:`_1ED1FG_retrySummary`,retryText:`_1ED1FG_retryText`,sentEditor:`_1ED1FG_sentEditor`,sentEditorActions:`_1ED1FG_sentEditorActions`,turnErrorCode:`_1ED1FG_turnErrorCode`,turnErrorCopy:`_1ED1FG_turnErrorCopy`,turnErrorDot:`_1ED1FG_turnErrorDot`,turnErrorMessage:`_1ED1FG_turnErrorMessage`,turnErrorRow:`_1ED1FG_turnErrorRow`,turnErrorTitle:`_1ED1FG_turnErrorTitle`,userRow:`_1ED1FG_userRow`,userStack:`_1ED1FG_userStack`};let vu=(0,d.memo)(function({node:e,title:t,fallbackSummary:n,t:r}){let[i,a]=(0,d.useState)(!1),o=(0,d.useMemo)(()=>uu(r),[r]),s=e.summary!==null,c=s&&i,l=e.shadowedItemCount!==null&&e.shadowedTokenCount!==null?r(`message.compaction.completed`,{items:e.shadowedItemCount,tokens:e.shadowedTokenCount}):n??r(s?`message.compaction.expand`:`message.compaction.unavailable`);return/* @__PURE__ */ (0,f.jsxs)(`div`,{className:q.compactionRow,children:[/* @__PURE__ */ (0,f.jsxs)(`button`,{type:`button`,className:q.compactionButton,disabled:!s,"aria-expanded":s?c:void 0,onClick:()=>{a(e=>!e)},children:[/* @__PURE__ */ (0,f.jsxs)(`span`,{className:q.compactionLeading,"aria-hidden":!0,children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:q.compactionContextIcon,"data-compaction-icon":`context`,children:/* @__PURE__ */ (0,f.jsx)(p.IconApiOutlineRegular,{})}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:q.compactionDisclosureIcon,"data-compaction-disclosure":c?`expanded`:`collapsed`,children:c?/* @__PURE__ */ (0,f.jsx)(p.IconChevronDownOutlineRegular,{}):/* @__PURE__ */ (0,f.jsx)(p.IconChevronRightOutlineRegular,{})})]}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:q.compactionTitle,children:t??r(`message.compaction`)}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:q.compactionSep,"aria-hidden":!0}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:q.compactionSummary,children:l})]}),c&&e.summary!==null&&/* @__PURE__ */ (0,f.jsx)(`div`,{className:q.compactionBody,children:/* @__PURE__ */ (0,f.jsx)(p.MarkdownText,{text:e.summary,labels:o})})]})}),yu=`@deepseek-ai/dsh-client-ui-chat/ContextBody.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(yu)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=yu,e.textContent=`.H8WTnW_text{color:var(--dsw-alias-label-secondary);font:inherit;white-space:pre-wrap;overflow-wrap:anywhere;margin:0}.H8WTnW_fields{border-top:.5px solid var(--dsw-alias-border-l2);flex-direction:column;gap:2px;margin:8px 0 0;padding-top:8px;display:flex}.H8WTnW_field{gap:8px;min-width:0;display:flex}.H8WTnW_fieldKey{min-width:96px;color:var(--dsw-alias-label-caption);flex:none}.H8WTnW_fieldValue{min-width:0;color:var(--dsw-alias-label-tertiary);overflow-wrap:anywhere;flex:auto;margin:0}.H8WTnW_files{flex-wrap:wrap;gap:4px 12px;margin:0 0 8px;padding:0;list-style:none;display:flex}.H8WTnW_file{align-items:baseline;gap:6px;min-width:0;display:flex}.H8WTnW_filePath{color:var(--dsw-alias-label-secondary);overflow-wrap:anywhere}.H8WTnW_fileAction{color:var(--dsw-alias-label-caption)}.H8WTnW_catalogNotice{color:var(--dsw-alias-label-caption);margin:0 0 6px}.H8WTnW_entries{flex-direction:column;gap:4px;margin:0;padding:0;list-style:none;display:flex}.H8WTnW_entry{gap:8px;min-width:0;display:flex}.H8WTnW_entryName{color:var(--dsw-alias-label-secondary);flex:none}.H8WTnW_entryDescription{min-width:0;color:var(--dsw-alias-label-tertiary);text-overflow:ellipsis;white-space:nowrap;flex:auto;overflow:hidden}.H8WTnW_sections{flex-direction:column;gap:8px;margin:0;display:flex}.H8WTnW_section{flex-direction:column;gap:2px;min-width:0;display:flex}.H8WTnW_sectionName{color:var(--dsw-alias-label-caption)}.H8WTnW_sectionText{color:var(--dsw-alias-label-secondary);white-space:pre-wrap;overflow-wrap:anywhere;margin:0}.H8WTnW_relaySender{color:var(--dsw-alias-label-caption);overflow-wrap:anywhere;margin:0 0 6px}.H8WTnW_recalls{flex-direction:column;gap:2px;margin:0 0 8px;padding:0;list-style:none;display:flex}.H8WTnW_recall{gap:8px;min-width:0;display:flex}.H8WTnW_recallLabel{color:var(--dsw-alias-label-secondary);overflow-wrap:anywhere}.H8WTnW_recallCounts{color:var(--dsw-alias-label-caption);flex:none}`,document.head.appendChild(e)}var J={catalogNotice:`H8WTnW_catalogNotice`,entries:`H8WTnW_entries`,entry:`H8WTnW_entry`,entryDescription:`H8WTnW_entryDescription`,entryName:`H8WTnW_entryName`,field:`H8WTnW_field`,fieldKey:`H8WTnW_fieldKey`,fieldValue:`H8WTnW_fieldValue`,fields:`H8WTnW_fields`,file:`H8WTnW_file`,fileAction:`H8WTnW_fileAction`,filePath:`H8WTnW_filePath`,files:`H8WTnW_files`,recall:`H8WTnW_recall`,recallCounts:`H8WTnW_recallCounts`,recallLabel:`H8WTnW_recallLabel`,recalls:`H8WTnW_recalls`,relaySender:`H8WTnW_relaySender`,section:`H8WTnW_section`,sectionName:`H8WTnW_sectionName`,sectionText:`H8WTnW_sectionText`,sections:`H8WTnW_sections`,text:`H8WTnW_text`};let bu=2e4;function xu(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:null}function Su(e){let t=[];for(let n of e){if(n.type!==`text`){t.push({block:n});continue}let e=t[t.length-1];e!==void 0&&`text`in e?e.text+=n.text:t.push({text:n.text})}return t}function Cu(e){return Su(e).flatMap(e=>`block`in e?[e.block]:[])}function wu(e,t){return e.length>bu?`${e.slice(0,bu)}\n${t(`json.truncated`,{total:e.length})}`:e}function Tu(e,t){return wu(typeof e==`string`?e:typeof e==`number`||typeof e==`boolean`?String(e):JSON.stringify(e),t)}function Eu({source:e,formRendered:t,t:n}){let r=xu(e);if(r===null)return null;let i=t?[`kind`,`form`]:[`kind`],a=Object.entries(r).filter(([e])=>!i.includes(e));return a.length===0?null:/* @__PURE__ */ (0,f.jsx)(`dl`,{className:J.fields,"data-context-fields":!0,children:a.map(([e,t])=>/* @__PURE__ */ (0,f.jsxs)(`div`,{className:J.field,children:[/* @__PURE__ */ (0,f.jsx)(`dt`,{className:J.fieldKey,children:e}),/* @__PURE__ */ (0,f.jsx)(`dd`,{className:J.fieldValue,children:Tu(t,n)})]},e))})}function Du({blocks:e,t}){return/* @__PURE__ */ (0,f.jsx)(f.Fragment,{children:e.map((e,n)=>/* @__PURE__ */ (0,f.jsx)(p.JsonBlock,{label:t(`message.unknownBlock`),payload:e,truncatedLabel:e=>t(`json.truncated`,{total:e})},n))})}function Ou({content:e,t}){return/* @__PURE__ */ (0,f.jsx)(f.Fragment,{children:Su(e).map((e,n)=>`text`in e?e.text!==``&&/* @__PURE__ */ (0,f.jsx)(`pre`,{className:J.text,"data-context-text":!0,children:wu(e.text,t)},n):/* @__PURE__ */ (0,f.jsx)(p.JsonBlock,{label:t(`message.unknownBlock`),payload:e.block,truncatedLabel:e=>t(`json.truncated`,{total:e})},n))})}function ku({content:e,source:t,t:n}){return/* @__PURE__ */ (0,f.jsxs)(f.Fragment,{children:[/* @__PURE__ */ (0,f.jsx)(Ou,{content:e,t:n}),/* @__PURE__ */ (0,f.jsx)(Eu,{source:t,formRendered:!1,t:n})]})}function Au(e){let t=xu(e),n=t===null?void 0:t.changes;if(!Array.isArray(n))return null;let r=[],i=/* @__PURE__ */ new Set;for(let e of n){let t=xu(e);if(t===null)return null;let n=t.path;if(typeof n!=`string`||n===``)return null;let a=t.action;if(a!==`set`&&a!==`replace`&&a!==`remove`)return null;let o=t.digest;i.has(n)||(i.add(n),r.push({action:a,path:n,...typeof o==`string`?{digest:o}:{}}))}return r.length===0?null:r}function ju(e,t){return e===`remove`?`message.context.instructions.removed`:t?`message.context.instructions.loaded`:e===`set`?`message.context.instructions.added`:`message.context.instructions.updated`}function Mu({content:e,source:t,t:n}){let r=Au(t);if(r===null)return/* @__PURE__ */ (0,f.jsx)(ku,{content:e,source:t,t:n});let i=xu(t)?.baseline===!0;return/* @__PURE__ */ (0,f.jsxs)(f.Fragment,{children:[/* @__PURE__ */ (0,f.jsx)(`ul`,{className:J.files,"data-context-files":!0,children:r.map(e=>/* @__PURE__ */ (0,f.jsxs)(`li`,{className:J.file,title:e.digest,children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:J.filePath,children:e.path}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:J.fileAction,children:n(ju(e.action,i))})]},e.path))}),/* @__PURE__ */ (0,f.jsx)(Ou,{content:e,t:n})]})}function Nu(e){let t=xu(e),n=t===null?void 0:t.entries;if(!Array.isArray(n))return null;let r=[];for(let e of n){let t=xu(e);if(t===null)return null;let n=t.name,i=t.description;if(typeof n!=`string`||n===``||typeof i!=`string`)return null;r.push({name:n,description:i})}return r}function Pu({content:e,source:t,t:n}){let r=Nu(t);if(r===null)return/* @__PURE__ */ (0,f.jsx)(ku,{content:e,source:t,t:n});let i=xu(t)?.update===!0,a=r.slice(0,200),o=Cu(e);return/* @__PURE__ */ (0,f.jsxs)(f.Fragment,{children:[i&&/* @__PURE__ */ (0,f.jsx)(`p`,{className:J.catalogNotice,"data-context-catalog-update":!0,children:n(`message.context.catalog.replaced`)}),/* @__PURE__ */ (0,f.jsx)(`ul`,{className:J.entries,"data-context-entries":!0,children:a.map((e,t)=>/* @__PURE__ */ (0,f.jsxs)(`li`,{className:J.entry,children:[/* @__PURE__ */ (0,f.jsx)(`code`,{className:J.entryName,children:e.name}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:J.entryDescription,children:e.description})]},t))}),a.length<r.length&&/* @__PURE__ */ (0,f.jsx)(`p`,{className:J.catalogNotice,"data-context-entries-truncated":!0,children:n(`message.context.catalog.more`,{count:r.length-a.length})}),/* @__PURE__ */ (0,f.jsx)(Du,{blocks:o,t:n})]})}function Fu(e){let t=xu(e),n=t===null?void 0:t.sections;if(!Array.isArray(n))return null;let r=[];for(let e of n){let t=xu(e);if(t===null)return null;let n=t.name,i=t.text;if(typeof n!=`string`||n===``||typeof i!=`string`)return null;r.push({name:n,text:i})}return r.length===0?null:r}function Iu({content:e,source:t,t:n}){let r=Fu(t);return r===null?/* @__PURE__ */ (0,f.jsx)(ku,{content:e,source:t,t:n}):/* @__PURE__ */ (0,f.jsxs)(f.Fragment,{children:[/* @__PURE__ */ (0,f.jsx)(`p`,{className:J.catalogNotice,"data-context-snapshot-supersedes":!0,children:n(`message.context.snapshot.supersedes`)}),/* @__PURE__ */ (0,f.jsx)(`dl`,{className:J.sections,"data-context-sections":!0,children:r.map((e,t)=>/* @__PURE__ */ (0,f.jsxs)(`div`,{className:J.section,children:[/* @__PURE__ */ (0,f.jsx)(`dt`,{className:J.sectionName,children:e.name}),/* @__PURE__ */ (0,f.jsx)(`dd`,{className:J.sectionText,children:wu(e.text,n)})]},t))})]})}function Lu({content:e,t}){return/* @__PURE__ */ (0,f.jsx)(Ou,{content:e,t})}function Ru({content:e,source:t,t:n}){let r=zu(t);return r===null?/* @__PURE__ */ (0,f.jsx)(ku,{content:e,source:t,t:n}):/* @__PURE__ */ (0,f.jsxs)(f.Fragment,{children:[/* @__PURE__ */ (0,f.jsx)(`p`,{className:J.relaySender,"data-context-relay-sender":!0,children:n(`message.context.relay.from`,{session:r})}),/* @__PURE__ */ (0,f.jsx)(Ou,{content:e,t:n})]})}function zu(e){let t=xu(e)?.senderSessionId;return typeof t==`string`&&t!==``?t:null}function Bu(e){let t=xu(e),n=t===null?void 0:t.references;if(!Array.isArray(n))return null;let r=[];for(let e of n){let t=xu(e);if(t===null)return null;let n=t.label,i=t.retainedMessages,a=t.omittedMessages,o=t.truncated;if(typeof n!=`string`||n===``||typeof i!=`number`||typeof a!=`number`||typeof o!=`boolean`)return null;r.push({label:n,retained:i,omitted:a,truncated:o})}return r.length===0?null:r}function Vu({content:e,source:t,t:n}){let r=Bu(t);return r===null?/* @__PURE__ */ (0,f.jsx)(ku,{content:e,source:t,t:n}):/* @__PURE__ */ (0,f.jsxs)(f.Fragment,{children:[/* @__PURE__ */ (0,f.jsx)(`ul`,{className:J.recalls,"data-context-recalls":!0,children:r.map((e,t)=>/* @__PURE__ */ (0,f.jsxs)(`li`,{className:J.recall,children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:J.recallLabel,children:e.label}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:J.recallCounts,children:n(`message.context.recall.counts`,{retained:e.retained,omitted:e.omitted})}),e.truncated&&/* @__PURE__ */ (0,f.jsx)(`span`,{className:J.recallCounts,children:n(`message.context.recall.truncated`)})]},t))}),/* @__PURE__ */ (0,f.jsx)(Ou,{content:e,t:n})]})}function Hu(e){let t=xu(e)?.summary;return typeof t==`string`&&t!==``?t:null}function Uu(e,t){let n={rendered:null,summary:null,body:/* @__PURE__ */ (0,f.jsx)(ku,{...t})};switch(e){case`instructions`:return Au(t.source)===null?n:{rendered:`instructions`,summary:null,body:/* @__PURE__ */ (0,f.jsx)(Mu,{...t})};case`catalog`:return Nu(t.source)===null?n:{rendered:`catalog`,summary:null,body:/* @__PURE__ */ (0,f.jsx)(Pu,{...t})};case`snapshot`:return Fu(t.source)===null?n:{rendered:`snapshot`,summary:null,body:/* @__PURE__ */ (0,f.jsx)(Iu,{...t})};case`notice`:{let e=Hu(t.source);return e===null?n:{rendered:`notice`,summary:e,body:/* @__PURE__ */ (0,f.jsx)(Lu,{...t})}}case`relay`:return zu(t.source)===null?n:{rendered:`relay`,summary:null,body:/* @__PURE__ */ (0,f.jsx)(Ru,{...t})};case`recall`:return Bu(t.source)===null?n:{rendered:`recall`,summary:null,body:/* @__PURE__ */ (0,f.jsx)(Vu,{...t})};case null:return n;
123
123
  /* v8 ignore next 4 -- closed-union backstop; the compiler rejects a new
124
124
  KnownContextForm here rather than letting it degrade to opaque silently. */
125
- default:throw Error(`unreachable context form: ${String(e)}`)}}let ju=`@deepseek-ai/dsh-client-ui-chat/ContextInjectionRow.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(ju)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=ju,e.textContent=`._5q-cza_root{min-width:0}._5q-cza_root[data-open]{padding-bottom:4px}._5q-cza_chevron{color:var(--dsw-alias-label-secondary)}._5q-cza_sep{background:var(--dsw-alias-label-caption);border-radius:1px;flex:none;width:2px;height:2px;margin:0 8px}._5q-cza_source{min-width:0;color:var(--dsw-alias-label-tertiary);font-size:var(--dsh-content-font-size-secondary,13px);line-height:calc(24px + var(--dsh-content-font-delta,0px));text-overflow:ellipsis;white-space:nowrap;flex:none;overflow:hidden}._5q-cza_summary{min-width:0;color:var(--dsw-alias-label-tertiary);font-size:var(--dsh-content-font-size-secondary,13px);line-height:calc(24px + var(--dsh-content-font-delta,0px));text-overflow:ellipsis;white-space:nowrap;flex:auto;overflow:hidden}._5q-cza_body{box-sizing:border-box;width:calc(100% - 22px - var(--dsh-content-font-delta,0px));max-height:141px;margin:4px 0 0 calc(22px + var(--dsh-content-font-delta,0px));border-radius:var(--dsw-radius-md);background:var(--dsw-alias-markdown-code-block);color:var(--dsw-alias-label-tertiary);font:400 11px/16px var(--ds-font-family-code);border:none;padding:10px 16px 12px 12px;overflow:auto}._5q-cza_toolChanges{white-space:nowrap}`,document.head.appendChild(e)}var Mu={body:`_5q-cza_body`,chevron:`_5q-cza_chevron`,root:`_5q-cza_root`,sep:`_5q-cza_sep`,source:`_5q-cza_source`,summary:`_5q-cza_summary`,toolChanges:`_5q-cza_toolChanges`};function Nu({content:e,source:t,producer:n,form:r,t:i}){let[a,o]=(0,d.useState)(!1),{rendered:s,summary:c,body:l}=Au(r,{content:e,source:t,t:i}),u=e.length>0&&e.every(e=>e.type===`tool-addition`||e.type===`tool-removal`)?e:void 0,m=u?.flatMap(e=>e.type===`tool-addition`?[e.toolName]:[])??[],h=u?.flatMap(e=>e.type===`tool-removal`?[e.toolName]:[])??[],g=u?.length===1?u[0]:void 0,_=u===void 0||g!==void 0?null:m.length>0&&h.length>0?i(`message.toolsChanged`,{added:m.length,removed:h.length}):m.length>0?i(`message.toolsAddedCount`,{count:m.length}):i(`message.toolsRemovedCount`,{count:h.length});return/* @__PURE__ */ (0,f.jsx)(p.DisclosureRow,{className:Mu.root,icon:u===void 0?n.role===`recall`?/* @__PURE__ */ (0,f.jsx)(`span`,{"data-context-recall-icon":!0,children:/* @__PURE__ */ (0,f.jsx)(p.ReferenceIconRegular,{kind:`session`})}):/* @__PURE__ */ (0,f.jsx)(p.IconContextInjectionOutlineRegular,{size:14}):/* @__PURE__ */ (0,f.jsx)(p.IconBrowseOutlineRegular,{size:14}),chevronClassName:Mu.chevron,title:g===void 0?i(u===void 0?n.role===`recall`?`message.contextRecall`:`message.contextInjection`:`message.toolsUpdated`):i(g.type===`tool-addition`?`message.toolAdded`:`message.toolRemoved`,{name:g.toolName}),collapsedContent:_===null?u!==void 0||n.label===null?void 0:/* @__PURE__ */ (0,f.jsxs)(f.Fragment,{children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:Mu.sep,"aria-hidden":!0}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:Mu.source,"data-context-source":!0,children:n.label}),c!==null&&/* @__PURE__ */ (0,f.jsxs)(f.Fragment,{children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:Mu.sep,"aria-hidden":!0}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:Mu.summary,"data-context-summary":!0,children:c})]})]}):/* @__PURE__ */ (0,f.jsxs)(f.Fragment,{children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:Mu.sep,"aria-hidden":!0}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:Mu.summary,children:_})]}),keepContentWhenOpen:!0,open:a&&g===void 0,expandable:g===void 0,expandOnRowClick:!0,onToggle:()=>{o(e=>!e)},children:/* @__PURE__ */ (0,f.jsx)(`div`,{className:Mu.body,"data-context-injection-body":!0,"data-context-form":s??void 0,children:u===void 0?l:/* @__PURE__ */ (0,f.jsxs)(`div`,{className:Mu.toolChanges,children:[m.length>0&&/* @__PURE__ */ (0,f.jsx)(`div`,{children:i(`message.toolsAdded`,{names:m.join(`, `)})}),h.length>0&&/* @__PURE__ */ (0,f.jsx)(`div`,{children:i(`message.toolsRemoved`,{names:h.join(`, `)})})]})})})}function Pu(e){return String(e).padStart(2,`0`)}function Fu(e){let t=new Date(e);return t.setHours(0,0,0,0),t.getTime()}function Iu(e){let t=new Date(e);return t.setHours(24,0,0,0),Math.max(t.getTime()-e,1)}function Lu(e,t){let n=Math.max(0,Math.floor(e/1e3)),r=Math.floor(n/3600),i=Math.floor(n/60)%60,a=n%60,o=[];return r>0&&o.push({text:String(r),numeric:!0},{text:t(`duration.hourUnit`),numeric:!1}),n>=60&&o.push({text:String(i),numeric:!0},{text:t(`duration.minuteUnit`),numeric:!1}),o.push({text:String(a),numeric:!0},{text:t(`duration.secondUnit`),numeric:!1}),o}function Ru(e,t,n=Date.now()){let r=new Date(e),i=new Date(n),a=`${Pu(r.getHours())}:${Pu(r.getMinutes())}`;if(r.getFullYear()===i.getFullYear()&&r.getMonth()===i.getMonth()&&r.getDate()===i.getDate())return a;let o={y:r.getFullYear(),m:r.getMonth()+1,d:r.getDate()};return`${r.getFullYear()===i.getFullYear()?t(`clock.md`,o):t(`clock.ymd`,o)} ${a}`}function zu(){let[e,t]=(0,d.useState)(()=>Fu(Date.now()));return(0,d.useEffect)(()=>{let e,n=()=>{let r=Date.now();t(Fu(r)),e=setTimeout(n,Iu(r))};return e=setTimeout(n,Iu(Date.now())),()=>{clearTimeout(e)}},[]),e}let Bu=`@deepseek-ai/dsh-client-ui-chat/MessageIconActions.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(Bu)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=Bu,e.textContent=`.PV4BtG_actions{height:calc(28px + var(--dsh-content-font-delta,0px));align-items:center;gap:8px;display:flex}.PV4BtG_timeStart{font-size:var(--dsh-content-font-size-secondary,13px);line-height:calc(24px + var(--dsh-content-font-delta,0px));color:var(--dsw-alias-label-tertiary);white-space:nowrap;padding-right:12px}.PV4BtG_timeEnd{font-size:calc(var(--dsh-content-font-size-secondary,13px) - 1px);line-height:calc(24px + var(--dsh-content-font-delta,0px));color:inherit;white-space:nowrap}.PV4BtG_endInfo{min-width:0;color:var(--dsw-alias-label-tertiary);align-items:center;gap:8px;margin-left:8px;display:inline-flex}@media (hover:hover){[data-actions-reveal=hover] .PV4BtG_actions,:is([data-chat-flow-kind=user],[data-chat-flow-kind=steering]):has(~:is([data-chat-flow-kind=user],[data-chat-flow-kind=steering])) .PV4BtG_actions{opacity:0;transition:opacity 80ms}[data-actions-reveal=hover]:hover .PV4BtG_actions,[data-actions-reveal=hover]:focus-within .PV4BtG_actions,:is([data-chat-flow-kind=user],[data-chat-flow-kind=steering]):has(~:is([data-chat-flow-kind=user],[data-chat-flow-kind=steering])):hover .PV4BtG_actions,:is([data-chat-flow-kind=user],[data-chat-flow-kind=steering]):has(~:is([data-chat-flow-kind=user],[data-chat-flow-kind=steering])):focus-within .PV4BtG_actions{opacity:1}}.PV4BtG_action{width:calc(28px + var(--dsh-content-font-delta,0px));height:calc(28px + var(--dsh-content-font-delta,0px));border-radius:var(--dsw-radius-sm);color:var(--dsw-alias-label-tertiary);cursor:pointer;background:0 0;border:none;justify-content:center;align-items:center;padding:6px;display:inline-flex}.PV4BtG_action svg{width:calc(15px + var(--dsh-content-font-delta,0px));height:calc(15px + var(--dsh-content-font-delta,0px))}.PV4BtG_actions[data-clock=end] .PV4BtG_action svg{width:calc(17px + var(--dsh-content-font-delta,0px));height:calc(17px + var(--dsh-content-font-delta,0px))}.PV4BtG_action:hover{background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-label-secondary)}.PV4BtG_action[data-unavailable]{cursor:default;opacity:.4}.PV4BtG_action[data-unavailable]:hover{color:var(--dsw-alias-label-tertiary);background:0 0}.PV4BtG_visuallyHidden{clip:rect(0 0 0 0);white-space:nowrap;width:1px;height:1px;position:absolute;overflow:hidden}`,document.head.appendChild(e)}var Vu={action:`PV4BtG_action`,actions:`PV4BtG_actions`,endInfo:`PV4BtG_endInfo`,timeEnd:`PV4BtG_timeEnd`,timeStart:`PV4BtG_timeStart`,visuallyHidden:`PV4BtG_visuallyHidden`};function Hu({text:e,time:t,clock:n,onBranch:r,branchUnavailable:i=!1,className:a,extraActions:o,t:s}){let c=zu(),l=(0,d.useId)(),[u,m]=(0,d.useState)(!1),h=(0,d.useRef)(!1),g=(0,d.useRef)(null),_=(0,d.useRef)(0);(0,d.useEffect)(()=>()=>{_.current+=1,h.current=!1,g.current!==null&&clearTimeout(g.current)},[]);let v=(0,d.useCallback)(()=>{if(u||h.current)return;let t=_.current;h.current=!0,(0,p.writeClipboard)(e).then(e=>{t===_.current&&(h.current=!1,e&&(m(!0),g.current=window.setTimeout(()=>{g.current=null,m(!1)},1e3)))})},[u,e]),y=t===void 0?null:/* @__PURE__ */ (0,f.jsx)(`span`,{className:n===`start`?Vu.timeStart:Vu.timeEnd,children:Ru(t,s,c)});return/* @__PURE__ */ (0,f.jsxs)(`div`,{className:a===void 0?Vu.actions:`${Vu.actions} ${a}`,"data-clock":n,children:[n===`start`?y:null,/* @__PURE__ */ (0,f.jsx)(p.Tooltip,{label:s(u?`copied`:`copy`),side:`bottom`,children:/* @__PURE__ */ (0,f.jsx)(`button`,{type:`button`,className:Vu.action,"aria-label":s(u?`copied`:`copy`),onClick:v,children:u?/* @__PURE__ */ (0,f.jsx)(p.IconCheckOutlineRegular,{}):/* @__PURE__ */ (0,f.jsx)(p.IconCopyOutlineRegular,{})})}),o,r!==void 0&&/* @__PURE__ */ (0,f.jsx)(p.Tooltip,{label:s(i?`message.branchUnavailable`:`message.branch`),side:`bottom`,children:/* @__PURE__ */ (0,f.jsx)(`button`,{type:`button`,className:Vu.action,"aria-label":s(`message.branch`),"aria-disabled":i||void 0,"aria-describedby":i?l:void 0,"data-unavailable":i||void 0,onClick:i?void 0:r,children:/* @__PURE__ */ (0,f.jsx)(p.IconBranchOutlineRegular,{})})}),r!==void 0&&i&&/* @__PURE__ */ (0,f.jsx)(`span`,{id:l,className:Vu.visuallyHidden,children:s(`message.branchUnavailable`)}),n===`end`?/* @__PURE__ */ (0,f.jsx)(`span`,{className:Vu.endInfo,children:y}):null]})}function Uu(e,t,n){return e(`codexhostTurnTimes`,e=>t===void 0?void 0:e?.[t]?.[n]??void 0)}function Wu(e,t,n){let[r,i]=(0,d.useState)(null),a=(0,d.useRef)(!1);return{targetSeq:e&&!n?t:null,draft:r,begin(e,r,o){a.current||n||e!==t||i({seq:e,text:r,content:o,pending:!1,blocked:!1})},change(e){i(t=>t&&!t.pending?{...t,text:e}:t)},cancel(){a.current||i(null)},send(){e&&r&&!r.blocked&&!a.current&&!n&&r.text.trim()&&(a.current=!0,i({...r,pending:!0,error:void 0}),e(r.seq,r.text).then(e=>{e.status===`accepted`?i(null):i({...r,pending:!1,blocked:e.status!==`rejected`,error:e.message})},e=>{i({...r,pending:!1,blocked:!0,error:e instanceof Error?e.message:String(e)})}).finally(()=>{a.current=!1}))}}}function Gu({editing:e,t}){let n=e.draft;return n?/* @__PURE__ */ (0,f.jsxs)(`form`,{className:q.sentEditor,"data-sent-message-editor":!0,onSubmit:t=>{t.preventDefault(),e.send()},children:[/* @__PURE__ */ (0,f.jsx)(`textarea`,{autoFocus:!0,"aria-label":t(`message.edit`),value:n.text,disabled:n.pending,onChange:t=>e.change(t.target.value),onKeyDown:t=>{t.nativeEvent.isComposing||t.keyCode===229||(t.key===`Enter`&&!t.shiftKey&&(t.preventDefault(),e.send()),t.key===`Escape`&&(t.preventDefault(),e.cancel()))}}),!n.pending&&!n.error&&e.targetSeq!==n.seq&&/* @__PURE__ */ (0,f.jsx)(`div`,{role:`status`,children:t(`message.edit.changed`)}),n.error&&/* @__PURE__ */ (0,f.jsxs)(`div`,{role:`alert`,children:[n.error,n.blocked?` ${t(`message.edit.checkHistory`)}`:``]}),/* @__PURE__ */ (0,f.jsxs)(`div`,{className:q.sentEditorActions,children:[/* @__PURE__ */ (0,f.jsx)(p.Button,{variant:`outline`,size:`sm`,disabled:n.pending,onClick:e.cancel,children:t(`message.edit.cancel`)}),/* @__PURE__ */ (0,f.jsx)(p.Button,{variant:`primary`,size:`sm`,type:`submit`,disabled:n.pending||n.blocked||!n.text.trim()||e.targetSeq!==n.seq,children:n.pending?t(`message.edit.sending`):t(`message.edit.send`)})]})]}):null}function Ku(e){return`nativePath`in e&&typeof e.nativePath==`string`?e.nativePath:void 0}function qu({upload:e,t}){let n=(0,d.useSyncExternalStore)(e.subscribe,e.getSnapshot);return n?.status===`uploading`?/* @__PURE__ */ (0,f.jsx)(`span`,{className:q.fileMeta,role:`status`,"data-upload-progress":!0,children:n.total===void 0||n.total===0?t(`message.uploading`):t(`message.uploadingPercent`,{percent:Math.round(Math.min(1,(n.loaded??0)/n.total)*100)})}):null}function Ju(e){let t=[],n=[],r=[];for(let i of e){let e=i;e.type===`text`&&typeof e.text==`string`?t.push(e.text):e.type===`image`&&e.attachment!==void 0?n.push({type:`image`,image:{attachment:e.attachment}}):e.type===`file`&&e.attachment!==void 0?n.push({type:`file`,file:e.attachment}):r.push(i)}return{text:t.join(``),attachments:n,rest:r}}function Yu(e){return Math.max(1,Math.ceil(e/1e3))}function Xu(e,t,n){return t===`ACCOUNT_SIGNED_OUT`?n(`message.failure.accountSignedOut`):t===`ACCOUNT_SIGN_IN_REQUIRED`?n(`message.failure.accountSignInRequired`):t===`QUOTA`||t===`ACCOUNT_QUOTA`?n(`message.failure.quota`):t===`AUTH`?n(`message.failure.auth`):e}function Zu({node:e,active:t,t:n}){let r=(0,d.useMemo)(()=>Date.now()+e.delayMs,[e.delayMs,e.seq]),i=Yu(e.delayMs),a=e.mode===`normal`?e.maxRetries:`∞`,[o,s]=(0,d.useState)(()=>({deadline:r,seconds:Yu(r-Date.now())})),c=o.deadline===r?o.seconds:Yu(r-Date.now());(0,d.useEffect)(()=>{if(!t)return;let e=()=>{let e=Yu(r-Date.now());return s(t=>t.deadline===r&&t.seconds===e?t:{deadline:r,seconds:e}),e};if(e()===1)return;let n=window.setInterval(()=>{e()===1&&window.clearInterval(n)},250);return()=>{window.clearInterval(n)}},[t,r]);let l=t?n(`message.retry.active`):e.retryState===`cancelled`?n(`message.retry.cancelled`):e.retryState===`started`?n(`message.retry.started`):n(`message.retry.scheduled`),u=t?c:i;return/* @__PURE__ */ (0,f.jsxs)(`details`,{className:q.retryRow,"data-active":t||void 0,children:[/* @__PURE__ */ (0,f.jsx)(`summary`,{className:q.retrySummary,children:/* @__PURE__ */ (0,f.jsx)(`span`,{className:q.retryText,role:`status`,children:/* @__PURE__ */ (0,f.jsx)(p.TextShimmer,{active:t,children:n(`message.retry.status`,{label:l,retry:e.retry,maximum:a,seconds:u})})})}),/* @__PURE__ */ (0,f.jsxs)(`div`,{className:q.retryDetails,children:[/* @__PURE__ */ (0,f.jsxs)(`div`,{children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:q.retryDetailLabel,children:n(`message.retry.delay`)}),n(`duration.milliseconds`,{milliseconds:Math.round(e.delayMs)})]}),/* @__PURE__ */ (0,f.jsxs)(`div`,{children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:q.retryDetailLabel,children:n(`message.retry.failure`)}),Xu(e.failure.message,e.failure.code,n)]})]})]})}function Qu({node:e,t}){return/* @__PURE__ */ (0,f.jsxs)(`div`,{className:q.turnErrorRow,role:`status`,children:[/* @__PURE__ */ (0,f.jsx)(p.StateDot,{state:`error`,className:q.turnErrorDot}),/* @__PURE__ */ (0,f.jsxs)(`div`,{className:q.turnErrorCopy,children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:q.turnErrorTitle,children:e.code===`ACCOUNT_SIGNED_OUT`?t(`message.accountStopped`):t(`message.turnError`)}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:q.turnErrorMessage,children:Xu(e.message,e.code,t)})]}),e.code!==void 0&&/* @__PURE__ */ (0,f.jsx)(`code`,{className:q.turnErrorCode,children:e.code})]})}function $u({t:e}){return/* @__PURE__ */ (0,f.jsxs)(`div`,{className:q.turnErrorRow,role:`status`,children:[/* @__PURE__ */ (0,f.jsx)(p.StateDot,{state:`warning`,className:q.turnErrorDot}),/* @__PURE__ */ (0,f.jsxs)(`div`,{className:q.turnErrorCopy,children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:q.maxTokensTitle,children:e(`message.maxTokens`)}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:q.turnErrorMessage,children:e(`message.maxTokens.hint`)})]})]})}function ed({content:e,renderMessageImages:t,actions:n,pending:r=!1,echo:i=!1,referenceLabels:a=[],skillNames:o=[],previewAttachments:s,references:c,links:l,editor:u,t:d}){let{text:m,attachments:h,rest:g}=Ju(e),_=s??h,v=_.length>1,y=e=>d(`json.truncated`,{total:e}),b=m!==``||g.length>0,x=Rl(m);return/* @__PURE__ */ (0,f.jsxs)(`div`,{className:x?q.noticeRow:q.userRow,"data-pending-steering":r||void 0,"data-submission-echo":i||void 0,children:[/* @__PURE__ */ (0,f.jsxs)(`div`,{className:x?q.noticeStack:q.userStack,children:[_.length>0&&/* @__PURE__ */ (0,f.jsx)(`div`,{className:q.attachmentRow,"data-message-attachments":!0,children:_.map((e,n)=>/* @__PURE__ */ (0,f.jsxs)(`div`,{className:q.pendingAttachment,children:[e.type===`image`?t({images:[e.image],align:`end`,compact:v}):/* @__PURE__ */ (0,f.jsxs)(`span`,{className:q.fileCard,title:Ku(e.file)??e.file.name,children:[/* @__PURE__ */ (0,f.jsx)(p.FileTypeIcon,{path:e.file.name,className:q.fileIcon}),/* @__PURE__ */ (0,f.jsxs)(`span`,{className:q.fileContent,children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:q.fileName,children:e.file.name}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:q.fileMeta,children:[(0,p.fileExtension)(e.file.name).toUpperCase().slice(0,8),Ku(e.file)===void 0?(0,p.fileSizeText)(e.file.bytes):void 0].filter(Boolean).join(` `)})]})]}),e.upload&&/* @__PURE__ */ (0,f.jsx)(qu,{upload:e.upload,t:d})]},n))}),u??(b&&/* @__PURE__ */ (0,f.jsxs)(`div`,{className:x?void 0:q.bubble,children:[x?/* @__PURE__ */ (0,f.jsx)(nu,{entries:x,links:l,t:d}):(0,p.projectUserText)(m,a,o,`skill`,c),g.map((e,t)=>/* @__PURE__ */ (0,f.jsx)(p.JsonBlock,{label:d(`message.extraBlock`),payload:e,truncatedLabel:y},t))]})),a.length>0&&/* @__PURE__ */ (0,f.jsx)(`div`,{className:q.referenceSummary,children:d(`message.referenceSummary`,{labels:a.join(d(`message.referenceSeparator`))})})]}),!x&&n?.(m)]})}function td({content:e,renderMessageImages:t,t:n}){return/* @__PURE__ */ (0,f.jsx)(ed,{content:e,renderMessageImages:t,pending:!0,t:n,actions:e=>/* @__PURE__ */ (0,f.jsx)(Hu,{text:e,clock:`start`,className:q.actions,t:n})})}function nd({submission:e,renderMessageImages:t,t:n}){let r=(0,d.useMemo)(()=>e.text===``?[]:[{type:`text`,text:e.text}],[e.text]),i=(0,d.useMemo)(()=>e.attachments.map(e=>({upload:e.upload,...e.type===`image`?{type:`image`,image:{preview:{url:e.value.previewUrl,...e.value.name===void 0?{}:{name:e.value.name},...e.value.width===void 0?{}:{width:e.value.width},...e.value.height===void 0?{}:{height:e.value.height}}}}:{type:`file`,file:e.value}})),[e.attachments]);return/* @__PURE__ */ (0,f.jsx)(ed,{content:r,previewAttachments:i,renderMessageImages:t,pending:e.placement===`steering`,echo:!0,t:n,actions:t=>/* @__PURE__ */ (0,f.jsx)(Hu,{text:t,time:e.time,clock:`start`,className:q.actions,t:n})})}let rd=(0,d.memo)(function({node:e,renderMessageImages:t,openFile:n,openSkill:r,messageEditing:i,useProjection:a,links:o,t:s}){let c=e.data,l=Uu(a,e.location.kind===`turn`||e.location.kind===`step`?e.location.turn.turn:void 0,`start`);return/* @__PURE__ */ (0,f.jsx)(ed,{content:c.content,editor:i?.draft?.seq===c.seq?/* @__PURE__ */ (0,f.jsx)(Gu,{editing:i,t:s}):void 0,references:{openFile:n,openSkill:r},links:o,renderMessageImages:t,...c.referenceLabels===void 0?{}:{referenceLabels:c.referenceLabels},...c.skillNames===void 0?{}:{skillNames:c.skillNames},t:s,actions:t=>/* @__PURE__ */ (0,f.jsx)(Hu,{extraActions:e.kind===`user`&&i?.targetSeq===c.seq&&!i.draft?/* @__PURE__ */ (0,f.jsx)(`button`,{type:`button`,className:q.editAction,"aria-label":s(`message.edit`),title:s(`message.edit`),onClick:()=>i.begin(c.seq,t,c.content),children:/* @__PURE__ */ (0,f.jsx)(p.IconEditOutlineRegular,{})}):null,text:t,time:e.kind===`user`?l:void 0,clock:`start`,className:q.actions,t:s})})});function id({editing:e,renderMessageImages:t,t:n}){return/* @__PURE__ */ (0,f.jsx)(ed,{content:e.draft?.content??[],renderMessageImages:t,editor:/* @__PURE__ */ (0,f.jsx)(Gu,{editing:e,t:n}),t:n})}let ad=(0,d.memo)(function({node:e,t}){let n=e.data;return/* @__PURE__ */ (0,f.jsx)(Nu,{content:n.content,source:n.source,producer:n.producer,form:n.form,t})}),od=(0,d.memo)(function({node:e,t}){return/* @__PURE__ */ (0,f.jsx)(au,{node:e.data,t})}),sd=(0,d.memo)(function({node:e,t}){let n=e.data;return/* @__PURE__ */ (0,f.jsx)(Zu,{node:n.current,active:n.current.retryState===`scheduled`,t})}),cd=(0,d.memo)(function({node:e,t}){return/* @__PURE__ */ (0,f.jsx)(Qu,{node:e.data,t})}),ld=(0,d.memo)(function({t:e}){return/* @__PURE__ */ (0,f.jsx)($u,{t:e})}),ud=(0,d.memo)(function({node:e,t}){let n=e.data;return/* @__PURE__ */ (0,f.jsx)(`div`,{className:q.contextRow,children:/* @__PURE__ */ (0,f.jsx)(p.JsonBlock,{label:t(`message.unknownSurface`,{type:n.type}),payload:n.data,truncatedLabel:e=>t(`json.truncated`,{total:e})})})}),dd=/* @__PURE__ */ new Set([`system-prompt`,`user`,`steering`,`turn-trigger`,`turn-process`,`turn-error`,`turn-max-tokens`,`turn-tail`]);function fd(e,t){return e.turn===t.turn&&e.controlAnchorSeq===t.controlAnchorSeq&&e.processStartSeq===t.processStartSeq&&e.answerAnchorSeq===t.answerAnchorSeq&&e.answerStep===t.answerStep&&e.inlineReasoning===t.inlineReasoning&&e.messageCount===t.messageCount&&e.toolCallCount===t.toolCallCount&&e.subagentCount===t.subagentCount}function pd(e){return e===`subagent`||e.startsWith(`subagent_`)}function md(e){return e===`compact_context`}function hd(e){let t=e?.location;if(t?.kind!==`turn`&&t?.kind!==`step`)return!1;let n=t.turn.end?.data.reason.kind;return t.turn.status===`open`||t.turn.end?.data.finalAssistantStep===null||n===`aborted`||n===`error`}function gd(e,t){return e.turnProcesses.find(e=>e.turn===t)}function _d(){return(0,m.defineStore)({init:()=>({turnProcesses:[]}),actions:{setTurnProcessOpen:(e,t,n,r)=>{let i=e.turnProcesses.findIndex(e=>e.turn===t);if(!r){i>=0&&e.turnProcesses.splice(i,1);return}let a={turn:t,answerStep:n};i<0?e.turnProcesses.push(a):e.turnProcesses[i]=a}}})}function vd(e,t){let n=(0,d.useRef)(null);return(0,d.useLayoutEffect)(()=>{let r=n.current;r!==null&&(e&&r.contains(r.ownerDocument.activeElement)?t():e?r.setAttribute(`hidden`,`until-found`):r.removeAttribute(`hidden`))},[e,t]),(0,d.useEffect)(()=>{let e=n.current;if(e!==null)return e.addEventListener(`beforematch`,t),()=>{e.removeEventListener(`beforematch`,t)}},[t]),n}let yd=`@deepseek-ai/dsh-client-ui-chat/ChatView.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(yd)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=yd,e.textContent=`.ChmFAW_frame{flex-direction:column;flex:auto;min-height:0;display:flex;position:relative;container-type:inline-size}.ChmFAW_root{flex-direction:column;flex:auto;min-height:0;display:flex;position:relative;overflow:visible clip}.ChmFAW_scroll{min-height:0;padding:16px calc(var(--dsh-composer-side-clearance) + 16px);flex:auto;overflow-y:auto;container-type:inline-size}.ChmFAW_root[data-chat-following-tail] .ChmFAW_scroll,[data-conversation-scroll]:has(.ChmFAW_root[data-chat-following-tail]){overflow-anchor:none}[data-conversation-scroll] .ChmFAW_frame,[data-conversation-scroll] .ChmFAW_root{flex:none;height:auto;min-height:auto}[data-conversation-scroll] .ChmFAW_scroll{flex:none;min-height:auto;overflow:visible}.ChmFAW_column{max-width:var(--dsh-chat-content-width);flex-direction:column;width:100%;margin:0 auto;display:flex}.ChmFAW_column>:not([hidden]):not(.ChmFAW_flowItem:is(:empty,:has(>[data-slot="conversation.chat.node"]:empty)))~:not([hidden]):not(.ChmFAW_flowItem:is(:empty,:has(>[data-slot="conversation.chat.node"]:empty))){margin-top:var(--dsh-chat-flow-gap,6px)}.ChmFAW_flowItem[data-chat-group-part=response],.ChmFAW_column>[data-chat-group-part=response]:not([hidden]):not(:empty)+:not([hidden]):not(.ChmFAW_flowItem:is(:empty,:has(>[data-slot="conversation.chat.node"]:empty))):not(.ChmFAW_running){--dsh-chat-flow-gap:12px}.ChmFAW_flowItem{min-width:0}.ChmFAW_flowItem[data-chat-flow-kind=turn-process],.ChmFAW_flowItem[data-turn-process-answer],.ChmFAW_column>[data-chat-flow-kind=turn-process]+:not([hidden]):not(.ChmFAW_flowItem:is(:empty,:has(>[data-slot="conversation.chat.node"]:empty))):not(.ChmFAW_running){--dsh-chat-flow-gap:16px}.ChmFAW_flowItem:is(:empty,:has(>[data-slot="conversation.chat.node"]:empty)){height:0}.ChmFAW_callRow{border-radius:var(--dsw-radius-sm)}.ChmFAW_syncing{color:var(--dsw-alias-label-secondary);font-size:var(--dsh-content-font-size-secondary,13px);line-height:calc(18px + var(--dsh-content-font-delta-secondary,0px));align-items:center;gap:6px;padding-block:8px;display:flex}@media (prefers-reduced-motion:reduce){.ChmFAW_syncingIcon{display:none}}.ChmFAW_hint{color:var(--dsw-alias-label-tertiary);font-size:var(--dsh-content-font-size-secondary,13px);line-height:calc(18px + var(--dsh-content-font-delta-secondary,0px))}.ChmFAW_running{--dsh-chat-flow-gap:12px;--dsw-alias-label-shimmer:var(--dsw-alias-label-deep-diving-shimmer);color:var(--dsw-alias-label-deep-diving);font-size:calc(var(--dsh-content-font-size,14px) - 2px);line-height:calc(22px + var(--dsh-content-font-delta,0px));flex-direction:column;align-items:flex-start;display:flex}.ChmFAW_column>:nth-last-child(2 of :not([hidden]):not(.ChmFAW_flowItem:is(:empty,:has(>[data-slot="conversation.chat.node"]:empty)))):is(.ChmFAW_flowItem:not([data-chat-flow-kind=user]):not([data-chat-flow-kind=steering]):not([data-chat-flow-kind=turn-trigger]),[data-chat-group-key])~.ChmFAW_running>.ChmFAW_runningDivider{display:block}.ChmFAW_runningDivider{background:color-mix(in srgb, var(--dsw-alias-border-l1) 75%, var(--dsw-alias-border-l2));pointer-events:none;width:100%;height:.5px;margin:8px 0 10px;display:none}.ChmFAW_runningContent{align-items:center;gap:6px;min-width:0;display:inline-flex}.ChmFAW_runningText{font-variant-numeric:tabular-nums;min-width:0}.ChmFAW_runningIcon{width:calc(16px + var(--dsh-content-font-delta,0px));height:calc(16px + var(--dsh-content-font-delta,0px));contain:strict;flex:none;display:inline-flex;overflow:hidden}.ChmFAW_runningIconMotion{transform-origin:50% 60%;width:100%;height:100%;display:inline-flex}@keyframes ChmFAW_runningIconSway{0%,to{transform:translateY(.5px)rotate(-20deg)}50%{transform:translateY(-.6px)rotate(20deg)}}@media (prefers-reduced-motion:no-preference) and (forced-colors:none){.ChmFAW_runningIconMotion{animation:1.6s ease-in-out infinite ChmFAW_runningIconSway}}.ChmFAW_openError{color:var(--dsw-alias-state-error-primary);font-size:var(--dsh-content-font-size-secondary,13px);line-height:calc(18px + var(--dsh-content-font-delta-secondary,0px))}.ChmFAW_older{min-height:28px;color:var(--dsw-alias-label-secondary);flex-wrap:wrap;justify-content:center;align-items:center;gap:8px;font-size:12px;display:flex}.ChmFAW_older button{border-radius:var(--dsw-radius-sm);color:var(--dsw-alias-label-secondary);background:var(--dsw-alias-interactive-bg-hover-solid);cursor:pointer;border:none;padding:4px 12px;font-size:12px}.ChmFAW_older button:disabled{cursor:default;opacity:.6}.ChmFAW_toBottomSlot{z-index:8;height:0;padding-right:max(calc(var(--dsh-composer-side-clearance) + 16px), calc((100% - var(--dsh-chat-content-width)) / 2));pointer-events:none;justify-content:flex-end;display:flex;position:absolute;bottom:16px;left:0;right:0}[data-conversation-scroll] .ChmFAW_toBottomSlot{bottom:calc(var(--dsh-composer-height,152px) + 16px);position:sticky}.ChmFAW_toBottom{--dsw-elevation-stroke-color:var(--dsw-alias-border-l3);corner-shape:round;width:34px;height:34px;color:var(--dsw-alias-label-primary);background:var(--dsw-alias-button-floating-fill);box-shadow:var(--dsw-elevation-panel);cursor:pointer;pointer-events:auto;border:0;border-radius:100px;justify-content:center;align-items:center;margin-top:-34px;padding:0;display:flex}.ChmFAW_toBottom:hover{background:var(--dsw-alias-button-floating-hover)}.ChmFAW_modalAction{min-width:72px}`,document.head.appendChild(e)}var Y={callRow:`ChmFAW_callRow`,column:`ChmFAW_column`,flowItem:`ChmFAW_flowItem`,frame:`ChmFAW_frame`,hint:`ChmFAW_hint`,modalAction:`ChmFAW_modalAction`,older:`ChmFAW_older`,openError:`ChmFAW_openError`,root:`ChmFAW_root`,running:`ChmFAW_running`,runningContent:`ChmFAW_runningContent`,runningDivider:`ChmFAW_runningDivider`,runningIcon:`ChmFAW_runningIcon`,runningIconMotion:`ChmFAW_runningIconMotion`,runningIconSway:`ChmFAW_runningIconSway`,runningText:`ChmFAW_runningText`,scroll:`ChmFAW_scroll`,syncing:`ChmFAW_syncing`,syncingIcon:`ChmFAW_syncingIcon`,toBottom:`ChmFAW_toBottom`,toBottomSlot:`ChmFAW_toBottomSlot`};function bd(e){let t=e?.location;return t?.kind===`turn`||t?.kind===`step`?t.turn.data:void 0}function xd(e){let t=e?.location;return t?.kind===`turn`||t?.kind===`step`?t.turn.turn:void 0}function Sd(e){return e?.kind===`tool-call`&&md(e.data.root.name)}let Cd=(0,d.memo)(function({nodeKey:e,groupPart:t,useChatNode:n,useChatNodeProcess:r,usePresentation:i,cwd:a,openFile:o,openSkill:s,inspectCall:c,forkAt:l,loadTurnDiffs:u,messageEditing:h,loadImage:g,renderMessageImages:_,fileMentions:v,useStore:y,actions:b,renderSlot:x,t:ee}){let S=n(e),C=S,te=xd(C),w=r(e),T=w?.spec,ne=y(e=>T===void 0?void 0:gd(e,T.turn)),re=T!==void 0&&ne?.answerStep===(T.answerStep??0)?ne:void 0,E=w!==void 0&&!w.turnClosed,ie=w?.hasInterleavedInput===!0,D=E||ie||hd(C),ae=D||re!==void 0,oe=(0,d.useCallback)(e=>{T!==void 0&&!D&&b.setTurnProcessOpen(T.turn,T.answerStep??0,e)},[b,T,D]),se=i(e=>e.foldCompletedTurns),O=T!==void 0&&w!==void 0&&se&&w.turn===T.turn&&(w.turnStarted||w.turnClosed),ce=C!==void 0&&O&&!E&&t!==`reasoning`&&C.kind===`assistant-step`&&C.data.step===T.answerStep,le=C!==void 0&&O&&!ce&&!dd.has(C.kind)&&!Sd(C)&&C.anchorSeq>=T.processStartSeq,ue=C?.kind===`turn-process`||ce,de=O&&(E||le||ue),fe=(0,d.useMemo)(()=>T===void 0?void 0:{spec:T,foldable:de,hasContent:!ie&&(w?.hasExternalProcess===!0||T.inlineReasoning),open:ae,setOpen:oe},[de,ie,ae,T,w?.hasExternalProcess,oe]),pe=C?.kind===`turn-process`&&se&&!de,me=ce&&de&&w.compactAnswer&&!ae,he=pe||de&&le&&!ae,ge=vd(he,(0,d.useCallback)(()=>{le&&oe(!0)},[le,oe])),[k]=(0,d.useState)(()=>(0,m.createSnapshotStore)(0)),_e=bd(C),ve=(0,d.useMemo)(()=>({turnData:_e,disclosureReset:k}),[_e,k]);(0,d.useEffect)(()=>{le&&he&&ge.current?.hasAttribute(`hidden`)&&k.set(k.getSnapshot()+1)},[le,he,ge,k]);let ye=(0,d.useMemo)(()=>S===void 0?null:{...t===void 0?{}:{groupPart:t},cwd:a,openFile:o,openSkill:s,inspectCall:c,forkAt:l,loadTurnDiffs:u,messageEditing:h,loadImage:g,renderMessageImages:_,fileMentions:v,turnProcess:fe},[S,t,a,o,s,c,l,u,h,g,_,v,fe]);if(C===void 0||ye===null)return null;let be={...ye,node:C},xe=t===void 0||t===`response`?C.key:JSON.stringify([C.key,t]);return/* @__PURE__ */ (0,f.jsx)(`div`,{ref:ge,className:Y.flowItem,"data-chat-anchor-key":xe,"data-chat-flow-key":xe,"data-chat-paging-anchor":C.kind!==`turn-process`||void 0,"data-chat-node-key":C.key,"data-chat-group-part":t,"data-chat-flow-kind":C.kind,"data-chat-turn":te,"data-turn-process-member":le||void 0,"data-turn-process-hidden":he||void 0,"data-turn-process-answer":me||void 0,children:x(`conversation.chat.node`,be,{entryKey:C.kind,hookContext:ve,fallback:/* @__PURE__ */ (0,f.jsx)(p.JsonBlock,{label:ee(`message.unknownSurface`,{type:C.kind}),payload:C.data,truncatedLabel:e=>ee(`json.truncated`,{total:e})})})})}),wd={'"':`"`,"\\":`\\`,"/":`/`,b:`\b`,f:`\f`,n:`
126
- `,r:`\r`,t:` `},Td=/[\\\u0000-\u001f]/u;function Ed(e){return e===` `||e===`
127
- `||e===`\r`||e===` `}function Dd(e){return e>=`0`&&e<=`9`||e>=`a`&&e<=`f`||e>=`A`&&e<=`F`}var Od=class e{static EMPTY=e.fromObject({});static fromText(t){let n=new e;return n.append(t),n.sealed=!0,n}static fromObject(t){let n=new e;return n.object=typeof t==`object`&&t&&!Array.isArray(t)?t:{},n.sealed=!0,n}chunks=[];object;sealed=!1;#e=[];#t=0;#n=0;#r=`root`;#i=!1;#a=0;#o=!1;#s=``;#c=null;#l=[];#u=!1;#d;#f=!1;#p=/* @__PURE__ */ new Map;#m=[];#h=/* @__PURE__ */ new Map;get isSealed(){return this.sealed}get invalid(){return this.scan(),this.#r===`invalid`||this.#f}append(e){if(this.sealed)throw Error(`PartialArguments: cannot append to a sealed view`);e.length!==0&&(this.chunks.push(e),this.#t+=e.length,this.#e.push(this.#t))}settle(t){if(this.object!==void 0||t.length!==this.#t)return e.fromText(t);let n=0;for(let r of this.chunks){if(!t.startsWith(r,n))return e.fromText(t);n+=r.length}return this.chunks=t.length===0?[]:[t],this.#e=t.length===0?[]:[t.length],this.sealed=!0,this}refresh(){if(this.#h.size===0)return!1;this.scan();let e=!1,t=!1;for(let n of this.#h.values())n.completion?t=!0:e=this.refreshRead(n)||e;if(t)for(let t of this.#h.values())t.completion&&(e=this.refreshRead(t)||e);return this.sealed&&this.#h.clear(),e}refreshRead(e){let t=e.answer();return!Object.is(t,e.last)&&(e.last=t,!0)}closed(){return this.remember(`closed`,``,()=>this.closedNow())}keys(){return this.remember(`keys`,``,()=>this.keysNow(),e=>e.length)}has(e){return this.remember(`has`,e,()=>this.hasNow(e))}complete(e){return this.remember(`complete`,e,()=>this.completeNow(e))}stringLength(e,t){let n=Math.max(1,Math.floor(t?.step??1)),r=t?.offset??0;return this.remember(`length:${n}:${r}`,e,()=>this.lengthNow(e),e=>e===void 0?void 0:Math.ceil((e+r)/n))}stringExceeds(e,t){let n=Math.max(0,Math.floor(t));return this.remember(`exceeds:${n}`,e,()=>(this.lengthNow(e,n+1)??0)>n)}text(e){return this.remember(`text`,e,()=>this.textNow(e))}textPrefix(e,t){let n=Math.max(1,Math.floor(t));return this.remember(`prefix:${n}`,e,()=>this.textPrefixNow(e,n))}value(e){return this.remember(`value`,e,()=>this.valueNow(e))}remember(e,t,n,r){this.scan();let i=n();if(!this.sealed){let a=`${e}/${t}`;this.#h.has(a)||this.#h.set(a,{completion:e===`complete`,answer:r===void 0?n:()=>r(n()),last:r===void 0?i:r(i)})}return i}closedNow(){return this.sealed||this.#r===`closed`||this.#r===`invalid`}keysNow(){return this.object===void 0?this.#m:Object.keys(this.object)}hasNow(e){return this.object===void 0?this.#p.has(e):Object.hasOwn(this.object,e)}completeNow(e){if(this.object!==void 0)return Object.hasOwn(this.object,e);let t=this.#p.get(e);return t!==void 0&&t.end>=0&&(t.kind===`string`?t.invalidAt===void 0:!t.invalid)}lengthNow(e,t=1/0){if(this.object!==void 0){let t=Object.hasOwn(this.object,e)?this.object[e]:void 0;return typeof t==`string`?t.length:void 0}let n=this.#p.get(e);if(n?.kind!==`string`)return;if(n.text!==void 0&&n.text.at===n.end)return n.text.length;let r=n.length??={at:n.start,length:0,text:``};return this.readString(n,r,t,!1),r.length}textNow(e){if(this.object!==void 0){let t=Object.hasOwn(this.object,e)?this.object[e]:void 0;return typeof t==`string`?t:void 0}let t=this.#p.get(e);if(t?.kind!==`string`)return;if(t.text===void 0&&t.end>=0&&t.needsDecoding&&t.invalidAt===void 0){let e;try{e=JSON.parse(`"${this.slice(t.start,t.end)}"`)}catch{}e!==void 0&&(t.text={at:t.end,length:e.length,text:e})}let n=t.text??={at:t.start,length:0,text:``};return this.readString(t,n,1/0,!0),n.text}textPrefixNow(e,t){if(this.object!==void 0){let n=Object.hasOwn(this.object,e)?this.object[e]:void 0;return typeof n==`string`?n.slice(0,t):void 0}let n=this.#p.get(e);if(n?.kind!==`string`)return;let r=n.prefixes??=/* @__PURE__ */ new Map,i=r.get(t);return i===void 0&&(i={at:n.start,length:0,text:``},r.set(t,i)),this.readString(n,i,t,!0),i.text}valueNow(e){if(this.object!==void 0){if(!Object.hasOwn(this.object,e))return;let t=this.object[e];return typeof t==`string`?void 0:t}let t=this.#p.get(e);if(!(t?.kind!==`value`||t.end<0||t.invalid)){if(t.parsed===void 0)try{t.parsed=JSON.parse(this.slice(t.start,t.end))}catch{t.invalid=!0,this.#f=!0}return t.parsed}}chunkAt(e){let t=0,n=this.#e.length;for(;t<n;){let r=t+n>>>1;this.#e[r]<=e?t=r+1:n=r}return t}slice(e,t){if(e>=t)return``;let n=this.chunkAt(e),r=this.chunkAt(t-1),i=n===0?0:this.#e[n-1];if(n===r)return this.chunks[n].slice(e-i,t-i);let a=[this.chunks[n].slice(e-i)];for(let e=n+1;e<r;e++)a.push(this.chunks[e]);return a.push(this.chunks[r].slice(0,t-this.#e[r-1])),a.join(``)}readString(e,t,n,r){let i=Math.min(e.end<0?this.#n:e.end,e.invalidAt??1/0,this.#d??1/0);if(!e.needsDecoding){let e=Math.min(i-t.at,n-t.length);if(e<=0)return;r&&(t.text+=this.slice(t.at,t.at+e)),t.at+=e,t.length+=e;return}let a=this.chunkAt(t.at);for(;t.at<i&&t.length<n;){let o=a===0?0:this.#e[a-1],s=this.chunks[a],c=s.slice(t.at-o,Math.min(s.length,i-o)),l=c.search(Td),u=Math.min(l<0?c.length:l,n-t.length);if(u>0){r&&(t.text+=c.slice(0,u)),t.at+=u,t.length+=u,t.at===o+s.length&&a++;continue}let d=c.length>1?c[1]:t.at+1<i?this.chunks[a+1][0]:void 0,f,p=2;if(c[0]===`\\`&&d===void 0&&e.end<0)return;if(c[0]===`\\`&&d===`u`){let n=this.slice(t.at+2,Math.min(i,t.at+6)),r=!0;for(let e=0;e<n.length;e++)Dd(n[e])||(r=!1);if(r){if(n.length<4&&e.end<0)return;n.length===4&&(f=String.fromCharCode(Number.parseInt(n,16)))}p=6}else c[0]===`\\`&&d!==void 0&&(f=wd[d]);if(f===void 0){e.invalidAt=t.at,this.#f=!0;return}for(r&&(t.text+=f),t.length++,t.at+=p;a<this.chunks.length&&t.at>=this.#e[a];)a++}}scan(){if(this.object===void 0&&this.#n!==this.#t)for(let e=this.chunkAt(this.#n);e<this.chunks.length&&this.#d===void 0;e++){let t=this.chunks[e],n=e===0?0:this.#e[e-1];for(let e=this.#n-n;e<t.length&&this.#r!==`invalid`;e++){if(this.#r===`string`||this.#r===`nested`&&this.#u){let n=this.stringBoundary(t,e);if(this.#n+=n-e,e=n,e===t.length)break}this.step(t[e],this.#n),this.#n++}}}stringBoundary(e,t){let n=t;for(;;){let t=e.indexOf(`"`,n),r=t<0?e.length:t;if(this.#r===`string`){let t=this.#c;!t.needsDecoding&&Td.test(e.slice(n,r))&&(t.needsDecoding=!0)}let i=r;for(;i>n&&e[i-1]===`\\`;)i--;let a=(r-i)%2==1!==(i===n&&this.#i);if(this.#i=t<0&&a,t<0||!a)return r;n=t+1}}step(e,t){switch(this.#r){case`root`:if(Ed(e))return;if(e===`{`){this.#r=`key-or-end`;return}this.fail();return;case`key-or-end`:if(Ed(e))return;if(e===`}`){this.#r=`closed`;return}if(e===`"`){this.beginKey(t);return}this.fail();return;case`key-only`:if(Ed(e))return;if(e===`"`){this.beginKey(t);return}this.fail();return;case`key`:this.stepKey(e,t);return;case`colon`:if(Ed(e))return;if(e===`:`){this.#r=`value`;return}this.fail();return;case`value`:this.beginValue(e,t);return;case`string`:{let e=this.#c;e.end=t,this.#c=null,this.#r=`comma-or-end`;return}case`scalar`:this.stepScalar(e,t);return;case`nested`:this.stepNested(e,t);return;case`comma-or-end`:if(Ed(e))return;if(e===`,`){this.#r=`key-only`;return}if(e===`}`){this.#r=`closed`;return}this.fail();return;case`closed`:if(Ed(e))return;this.fail();return;
125
+ default:throw Error(`unreachable context form: ${String(e)}`)}}let Wu=`@deepseek-ai/dsh-client-ui-chat/ContextInjectionRow.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(Wu)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=Wu,e.textContent=`._5q-cza_root{min-width:0}._5q-cza_root[data-open]{padding-bottom:4px}._5q-cza_chevron{color:var(--dsw-alias-label-secondary)}._5q-cza_sep{background:var(--dsw-alias-label-caption);border-radius:1px;flex:none;width:2px;height:2px;margin:0 8px}._5q-cza_source{min-width:0;color:var(--dsw-alias-label-tertiary);font-size:var(--dsh-content-font-size-secondary,13px);line-height:calc(24px + var(--dsh-content-font-delta,0px));text-overflow:ellipsis;white-space:nowrap;flex:none;overflow:hidden}._5q-cza_summary{min-width:0;color:var(--dsw-alias-label-tertiary);font-size:var(--dsh-content-font-size-secondary,13px);line-height:calc(24px + var(--dsh-content-font-delta,0px));text-overflow:ellipsis;white-space:nowrap;flex:auto;overflow:hidden}._5q-cza_body{box-sizing:border-box;width:calc(100% - 22px - var(--dsh-content-font-delta,0px));max-height:141px;margin:4px 0 0 calc(22px + var(--dsh-content-font-delta,0px));border-radius:var(--dsw-radius-md);background:var(--dsw-alias-markdown-code-block);color:var(--dsw-alias-label-tertiary);font:400 11px/16px var(--ds-font-family-code);border:none;padding:10px 16px 12px 12px;overflow:auto}._5q-cza_toolChanges{white-space:nowrap}`,document.head.appendChild(e)}var Gu={body:`_5q-cza_body`,chevron:`_5q-cza_chevron`,root:`_5q-cza_root`,sep:`_5q-cza_sep`,source:`_5q-cza_source`,summary:`_5q-cza_summary`,toolChanges:`_5q-cza_toolChanges`};function Ku({content:e,source:t,producer:n,form:r,t:i}){let[a,o]=(0,d.useState)(!1),{rendered:s,summary:c,body:l}=Uu(r,{content:e,source:t,t:i}),u=e.length>0&&e.every(e=>e.type===`tool-addition`||e.type===`tool-removal`)?e:void 0,m=u?.flatMap(e=>e.type===`tool-addition`?[e.toolName]:[])??[],h=u?.flatMap(e=>e.type===`tool-removal`?[e.toolName]:[])??[],g=u?.length===1?u[0]:void 0,_=u===void 0||g!==void 0?null:m.length>0&&h.length>0?i(`message.toolsChanged`,{added:m.length,removed:h.length}):m.length>0?i(`message.toolsAddedCount`,{count:m.length}):i(`message.toolsRemovedCount`,{count:h.length});return/* @__PURE__ */ (0,f.jsx)(p.DisclosureRow,{className:Gu.root,icon:u===void 0?n.role===`recall`?/* @__PURE__ */ (0,f.jsx)(`span`,{"data-context-recall-icon":!0,children:/* @__PURE__ */ (0,f.jsx)(p.ReferenceIconRegular,{kind:`session`})}):/* @__PURE__ */ (0,f.jsx)(p.IconContextInjectionOutlineRegular,{size:14}):/* @__PURE__ */ (0,f.jsx)(p.IconBrowseOutlineRegular,{size:14}),chevronClassName:Gu.chevron,title:g===void 0?i(u===void 0?n.role===`recall`?`message.contextRecall`:`message.contextInjection`:`message.toolsUpdated`):i(g.type===`tool-addition`?`message.toolAdded`:`message.toolRemoved`,{name:g.toolName}),collapsedContent:_===null?u!==void 0||n.label===null?void 0:/* @__PURE__ */ (0,f.jsxs)(f.Fragment,{children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:Gu.sep,"aria-hidden":!0}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:Gu.source,"data-context-source":!0,children:n.label}),c!==null&&/* @__PURE__ */ (0,f.jsxs)(f.Fragment,{children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:Gu.sep,"aria-hidden":!0}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:Gu.summary,"data-context-summary":!0,children:c})]})]}):/* @__PURE__ */ (0,f.jsxs)(f.Fragment,{children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:Gu.sep,"aria-hidden":!0}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:Gu.summary,children:_})]}),keepContentWhenOpen:!0,open:a&&g===void 0,expandable:g===void 0,expandOnRowClick:!0,onToggle:()=>{o(e=>!e)},children:/* @__PURE__ */ (0,f.jsx)(`div`,{className:Gu.body,"data-context-injection-body":!0,"data-context-form":s??void 0,children:u===void 0?l:/* @__PURE__ */ (0,f.jsxs)(`div`,{className:Gu.toolChanges,children:[m.length>0&&/* @__PURE__ */ (0,f.jsx)(`div`,{children:i(`message.toolsAdded`,{names:m.join(`, `)})}),h.length>0&&/* @__PURE__ */ (0,f.jsx)(`div`,{children:i(`message.toolsRemoved`,{names:h.join(`, `)})})]})})})}function qu(e){return String(e).padStart(2,`0`)}function Ju(e){let t=new Date(e);return t.setHours(0,0,0,0),t.getTime()}function Yu(e){let t=new Date(e);return t.setHours(24,0,0,0),Math.max(t.getTime()-e,1)}function Xu(e,t){let n=Math.max(0,Math.floor(e/1e3)),r=Math.floor(n/3600),i=Math.floor(n/60)%60,a=n%60,o=[];return r>0&&o.push({text:String(r),numeric:!0},{text:t(`duration.hourUnit`),numeric:!1}),n>=60&&o.push({text:String(i),numeric:!0},{text:t(`duration.minuteUnit`),numeric:!1}),o.push({text:String(a),numeric:!0},{text:t(`duration.secondUnit`),numeric:!1}),o}function Zu(e,t,n=Date.now()){let r=new Date(e),i=new Date(n),a=`${qu(r.getHours())}:${qu(r.getMinutes())}`;if(r.getFullYear()===i.getFullYear()&&r.getMonth()===i.getMonth()&&r.getDate()===i.getDate())return a;let o={y:r.getFullYear(),m:r.getMonth()+1,d:r.getDate()};return`${r.getFullYear()===i.getFullYear()?t(`clock.md`,o):t(`clock.ymd`,o)} ${a}`}function Qu(){let[e,t]=(0,d.useState)(()=>Ju(Date.now()));return(0,d.useEffect)(()=>{let e,n=()=>{let r=Date.now();t(Ju(r)),e=setTimeout(n,Yu(r))};return e=setTimeout(n,Yu(Date.now())),()=>{clearTimeout(e)}},[]),e}let $u=`@deepseek-ai/dsh-client-ui-chat/MessageIconActions.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify($u)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=$u,e.textContent=`.PV4BtG_actions{height:calc(28px + var(--dsh-content-font-delta,0px));align-items:center;gap:8px;display:flex}.PV4BtG_timeStart{font-size:var(--dsh-content-font-size-secondary,13px);line-height:calc(24px + var(--dsh-content-font-delta,0px));color:var(--dsw-alias-label-tertiary);white-space:nowrap;padding-right:12px}.PV4BtG_timeEnd{font-size:calc(var(--dsh-content-font-size-secondary,13px) - 1px);line-height:calc(24px + var(--dsh-content-font-delta,0px));color:inherit;white-space:nowrap}.PV4BtG_endInfo{min-width:0;color:var(--dsw-alias-label-tertiary);align-items:center;gap:8px;margin-left:8px;display:inline-flex}@media (hover:hover){[data-actions-reveal=hover] .PV4BtG_actions,:is([data-chat-flow-kind=user],[data-chat-flow-kind=steering]):has(~:is([data-chat-flow-kind=user],[data-chat-flow-kind=steering])) .PV4BtG_actions{opacity:0;transition:opacity 80ms}[data-actions-reveal=hover]:hover .PV4BtG_actions,[data-actions-reveal=hover]:focus-within .PV4BtG_actions,:is([data-chat-flow-kind=user],[data-chat-flow-kind=steering]):has(~:is([data-chat-flow-kind=user],[data-chat-flow-kind=steering])):hover .PV4BtG_actions,:is([data-chat-flow-kind=user],[data-chat-flow-kind=steering]):has(~:is([data-chat-flow-kind=user],[data-chat-flow-kind=steering])):focus-within .PV4BtG_actions{opacity:1}}.PV4BtG_action{width:calc(28px + var(--dsh-content-font-delta,0px));height:calc(28px + var(--dsh-content-font-delta,0px));border-radius:var(--dsw-radius-sm);color:var(--dsw-alias-label-tertiary);cursor:pointer;background:0 0;border:none;justify-content:center;align-items:center;padding:6px;display:inline-flex}.PV4BtG_action svg{width:calc(15px + var(--dsh-content-font-delta,0px));height:calc(15px + var(--dsh-content-font-delta,0px))}.PV4BtG_actions[data-clock=end] .PV4BtG_action svg{width:calc(17px + var(--dsh-content-font-delta,0px));height:calc(17px + var(--dsh-content-font-delta,0px))}.PV4BtG_action:hover{background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-label-secondary)}.PV4BtG_action[data-unavailable]{cursor:default;opacity:.4}.PV4BtG_action[data-unavailable]:hover{color:var(--dsw-alias-label-tertiary);background:0 0}.PV4BtG_visuallyHidden{clip:rect(0 0 0 0);white-space:nowrap;width:1px;height:1px;position:absolute;overflow:hidden}`,document.head.appendChild(e)}var ed={action:`PV4BtG_action`,actions:`PV4BtG_actions`,endInfo:`PV4BtG_endInfo`,timeEnd:`PV4BtG_timeEnd`,timeStart:`PV4BtG_timeStart`,visuallyHidden:`PV4BtG_visuallyHidden`};function td({text:e,time:t,clock:n,onBranch:r,branchUnavailable:i=!1,className:a,extraActions:o,t:s}){let c=Qu(),l=(0,d.useId)(),[u,m]=(0,d.useState)(!1),h=(0,d.useRef)(!1),g=(0,d.useRef)(null),_=(0,d.useRef)(0);(0,d.useEffect)(()=>()=>{_.current+=1,h.current=!1,g.current!==null&&clearTimeout(g.current)},[]);let v=(0,d.useCallback)(()=>{if(u||h.current)return;let t=_.current;h.current=!0,(0,p.writeClipboard)(e).then(e=>{t===_.current&&(h.current=!1,e&&(m(!0),g.current=window.setTimeout(()=>{g.current=null,m(!1)},1e3)))})},[u,e]),y=t===void 0?null:/* @__PURE__ */ (0,f.jsx)(`span`,{className:n===`start`?ed.timeStart:ed.timeEnd,children:Zu(t,s,c)});return/* @__PURE__ */ (0,f.jsxs)(`div`,{className:a===void 0?ed.actions:`${ed.actions} ${a}`,"data-clock":n,children:[n===`start`?y:null,/* @__PURE__ */ (0,f.jsx)(p.Tooltip,{label:s(u?`copied`:`copy`),side:`bottom`,children:/* @__PURE__ */ (0,f.jsx)(`button`,{type:`button`,className:ed.action,"aria-label":s(u?`copied`:`copy`),onClick:v,children:u?/* @__PURE__ */ (0,f.jsx)(p.IconCheckOutlineRegular,{}):/* @__PURE__ */ (0,f.jsx)(p.IconCopyOutlineRegular,{})})}),o,r!==void 0&&/* @__PURE__ */ (0,f.jsx)(p.Tooltip,{label:s(i?`message.branchUnavailable`:`message.branch`),side:`bottom`,children:/* @__PURE__ */ (0,f.jsx)(`button`,{type:`button`,className:ed.action,"aria-label":s(`message.branch`),"aria-disabled":i||void 0,"aria-describedby":i?l:void 0,"data-unavailable":i||void 0,onClick:i?void 0:r,children:/* @__PURE__ */ (0,f.jsx)(p.IconBranchOutlineRegular,{})})}),r!==void 0&&i&&/* @__PURE__ */ (0,f.jsx)(`span`,{id:l,className:ed.visuallyHidden,children:s(`message.branchUnavailable`)}),n===`end`?/* @__PURE__ */ (0,f.jsx)(`span`,{className:ed.endInfo,children:y}):null]})}function nd(e,t,n){return e(`codexhostTurnTimes`,e=>t===void 0?void 0:e?.[t]?.[n]??void 0)}function rd(e,t,n){let[r,i]=(0,d.useState)(null),a=(0,d.useRef)(!1);return{targetSeq:e&&!n?t:null,draft:r,begin(e,r,o,s=[]){a.current||n||e!==t||i({seq:e,text:r,content:o,responseAnnotations:s,pending:!1,blocked:!1})},change(e){i(t=>t&&!t.pending?{...t,text:e}:t)},cancel(){a.current||i(null)},send(){!e||!r||r.blocked||a.current||n||!r.text.trim()&&r.responseAnnotations.length===0||(a.current=!0,i({...r,pending:!0,error:void 0}),e(r.seq,Wl(r.responseAnnotations,r.text)).then(e=>{e.status===`accepted`?i(null):i({...r,pending:!1,blocked:e.status!==`rejected`,error:e.message})},e=>{i({...r,pending:!1,blocked:!0,error:e instanceof Error?e.message:String(e)})}).finally(()=>{a.current=!1}))}}}function id({editing:e,t}){let n=e.draft;return n?/* @__PURE__ */ (0,f.jsxs)(`form`,{className:q.sentEditor,"data-sent-message-editor":!0,onSubmit:t=>{t.preventDefault(),e.send()},children:[/* @__PURE__ */ (0,f.jsx)(`textarea`,{autoFocus:!0,"aria-label":t(`message.edit`),value:n.text,disabled:n.pending,onChange:t=>e.change(t.target.value),onKeyDown:t=>{t.nativeEvent.isComposing||t.keyCode===229||(t.key===`Enter`&&!t.shiftKey&&(t.preventDefault(),e.send()),t.key===`Escape`&&(t.preventDefault(),e.cancel()))}}),!n.pending&&!n.error&&e.targetSeq!==n.seq&&/* @__PURE__ */ (0,f.jsx)(`div`,{role:`status`,children:t(`message.edit.changed`)}),n.error&&/* @__PURE__ */ (0,f.jsxs)(`div`,{role:`alert`,children:[n.error,n.blocked?` ${t(`message.edit.checkHistory`)}`:``]}),/* @__PURE__ */ (0,f.jsxs)(`div`,{className:q.sentEditorActions,children:[/* @__PURE__ */ (0,f.jsx)(p.Button,{variant:`outline`,size:`sm`,disabled:n.pending,onClick:e.cancel,children:t(`message.edit.cancel`)}),/* @__PURE__ */ (0,f.jsx)(p.Button,{variant:`primary`,size:`sm`,type:`submit`,disabled:n.pending||n.blocked||!n.text.trim()&&n.responseAnnotations.length===0||e.targetSeq!==n.seq,children:n.pending?t(`message.edit.sending`):t(`message.edit.send`)})]})]}):null}function ad(e){return`nativePath`in e&&typeof e.nativePath==`string`?e.nativePath:void 0}function od({upload:e,t}){let n=(0,d.useSyncExternalStore)(e.subscribe,e.getSnapshot);return n?.status===`uploading`?/* @__PURE__ */ (0,f.jsx)(`span`,{className:q.fileMeta,role:`status`,"data-upload-progress":!0,children:n.total===void 0||n.total===0?t(`message.uploading`):t(`message.uploadingPercent`,{percent:Math.round(Math.min(1,(n.loaded??0)/n.total)*100)})}):null}function sd(e){let t=[],n=[],r=[];for(let i of e){let e=i;e.type===`text`&&typeof e.text==`string`?t.push(Kl(e.text).body):e.type===`image`&&e.attachment!==void 0?n.push({type:`image`,image:{attachment:e.attachment}}):e.type===`file`&&e.attachment!==void 0?n.push({type:`file`,file:e.attachment}):r.push(i)}return{text:t.join(``),attachments:n,rest:r}}function cd(e){return Math.max(1,Math.ceil(e/1e3))}function ld(e,t,n){return t===`ACCOUNT_SIGNED_OUT`?n(`message.failure.accountSignedOut`):t===`ACCOUNT_SIGN_IN_REQUIRED`?n(`message.failure.accountSignInRequired`):t===`QUOTA`||t===`ACCOUNT_QUOTA`?n(`message.failure.quota`):t===`AUTH`?n(`message.failure.auth`):e}function ud({node:e,active:t,t:n}){let r=(0,d.useMemo)(()=>Date.now()+e.delayMs,[e.delayMs,e.seq]),i=cd(e.delayMs),a=e.mode===`normal`?e.maxRetries:`∞`,[o,s]=(0,d.useState)(()=>({deadline:r,seconds:cd(r-Date.now())})),c=o.deadline===r?o.seconds:cd(r-Date.now());(0,d.useEffect)(()=>{if(!t)return;let e=()=>{let e=cd(r-Date.now());return s(t=>t.deadline===r&&t.seconds===e?t:{deadline:r,seconds:e}),e};if(e()===1)return;let n=window.setInterval(()=>{e()===1&&window.clearInterval(n)},250);return()=>{window.clearInterval(n)}},[t,r]);let l=t?n(`message.retry.active`):e.retryState===`cancelled`?n(`message.retry.cancelled`):e.retryState===`started`?n(`message.retry.started`):n(`message.retry.scheduled`),u=t?c:i;return/* @__PURE__ */ (0,f.jsxs)(`details`,{className:q.retryRow,"data-active":t||void 0,children:[/* @__PURE__ */ (0,f.jsx)(`summary`,{className:q.retrySummary,children:/* @__PURE__ */ (0,f.jsx)(`span`,{className:q.retryText,role:`status`,children:/* @__PURE__ */ (0,f.jsx)(p.TextShimmer,{active:t,children:n(`message.retry.status`,{label:l,retry:e.retry,maximum:a,seconds:u})})})}),/* @__PURE__ */ (0,f.jsxs)(`div`,{className:q.retryDetails,children:[/* @__PURE__ */ (0,f.jsxs)(`div`,{children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:q.retryDetailLabel,children:n(`message.retry.delay`)}),n(`duration.milliseconds`,{milliseconds:Math.round(e.delayMs)})]}),/* @__PURE__ */ (0,f.jsxs)(`div`,{children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:q.retryDetailLabel,children:n(`message.retry.failure`)}),ld(e.failure.message,e.failure.code,n)]})]})]})}function dd({node:e,t}){return/* @__PURE__ */ (0,f.jsxs)(`div`,{className:q.turnErrorRow,role:`status`,children:[/* @__PURE__ */ (0,f.jsx)(p.StateDot,{state:`error`,className:q.turnErrorDot}),/* @__PURE__ */ (0,f.jsxs)(`div`,{className:q.turnErrorCopy,children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:q.turnErrorTitle,children:e.code===`ACCOUNT_SIGNED_OUT`?t(`message.accountStopped`):t(`message.turnError`)}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:q.turnErrorMessage,children:ld(e.message,e.code,t)})]}),e.code!==void 0&&/* @__PURE__ */ (0,f.jsx)(`code`,{className:q.turnErrorCode,children:e.code})]})}function fd({t:e}){return/* @__PURE__ */ (0,f.jsxs)(`div`,{className:q.turnErrorRow,role:`status`,children:[/* @__PURE__ */ (0,f.jsx)(p.StateDot,{state:`warning`,className:q.turnErrorDot}),/* @__PURE__ */ (0,f.jsxs)(`div`,{className:q.turnErrorCopy,children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:q.maxTokensTitle,children:e(`message.maxTokens`)}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:q.turnErrorMessage,children:e(`message.maxTokens.hint`)})]})]})}function pd({content:e,renderMessageImages:t,actions:n,pending:r=!1,echo:i=!1,referenceLabels:a=[],skillNames:o=[],responseAnnotations:s=[],previewAttachments:c,references:l,links:u,editor:d,t:m}){let{text:h,attachments:g,rest:_}=sd(e),v=c??g,y=v.length>1,ee=e=>m(`json.truncated`,{total:e}),b=h!==``||_.length>0,te=zl(h);return/* @__PURE__ */ (0,f.jsxs)(`div`,{className:te?q.noticeRow:q.userRow,"data-pending-steering":r||void 0,"data-submission-echo":i||void 0,children:[/* @__PURE__ */ (0,f.jsxs)(`div`,{className:te?q.noticeStack:q.userStack,children:[s.length>0&&/* @__PURE__ */ (0,f.jsx)(`div`,{className:q.annotationRow,"data-message-annotations":!0,children:s.map((e,t)=>/* @__PURE__ */ (0,f.jsx)(p.ResponseAnnotationChip,{index:t+1,annotation:e,labels:du(m)},`${String(t)}:${e.text}`))}),v.length>0&&/* @__PURE__ */ (0,f.jsx)(`div`,{className:q.attachmentRow,"data-message-attachments":!0,children:v.map((e,n)=>/* @__PURE__ */ (0,f.jsxs)(`div`,{className:q.pendingAttachment,children:[e.type===`image`?t({images:[e.image],align:`end`,compact:y}):/* @__PURE__ */ (0,f.jsxs)(`span`,{className:q.fileCard,title:ad(e.file)??e.file.name,children:[/* @__PURE__ */ (0,f.jsx)(p.FileTypeIcon,{path:e.file.name,className:q.fileIcon}),/* @__PURE__ */ (0,f.jsxs)(`span`,{className:q.fileContent,children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:q.fileName,children:e.file.name}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:q.fileMeta,children:[(0,p.fileExtension)(e.file.name).toUpperCase().slice(0,8),ad(e.file)===void 0?(0,p.fileSizeText)(e.file.bytes):void 0].filter(Boolean).join(` `)})]})]}),e.upload&&/* @__PURE__ */ (0,f.jsx)(od,{upload:e.upload,t:m})]},n))}),d??(b&&/* @__PURE__ */ (0,f.jsxs)(`div`,{className:te?void 0:q.bubble,children:[te?/* @__PURE__ */ (0,f.jsx)(gu,{entries:te,links:u,t:m}):(0,p.projectUserText)(h,a,o,`skill`,l),_.map((e,t)=>/* @__PURE__ */ (0,f.jsx)(p.JsonBlock,{label:m(`message.extraBlock`),payload:e,truncatedLabel:ee},t))]})),a.length>0&&/* @__PURE__ */ (0,f.jsx)(`div`,{className:q.referenceSummary,children:m(`message.referenceSummary`,{labels:a.join(m(`message.referenceSeparator`))})})]}),!te&&n?.(h)]})}function md({content:e,renderMessageImages:t,t:n}){return/* @__PURE__ */ (0,f.jsx)(pd,{content:e,renderMessageImages:t,pending:!0,t:n,actions:e=>/* @__PURE__ */ (0,f.jsx)(td,{text:e,clock:`start`,className:q.actions,t:n})})}function hd({submission:e,renderMessageImages:t,t:n}){let r=(0,d.useMemo)(()=>e.text===``?[]:[{type:`text`,text:e.text}],[e.text]),i=(0,d.useMemo)(()=>e.attachments.map(e=>({upload:e.upload,...e.type===`image`?{type:`image`,image:{preview:{url:e.value.previewUrl,...e.value.name===void 0?{}:{name:e.value.name},...e.value.width===void 0?{}:{width:e.value.width},...e.value.height===void 0?{}:{height:e.value.height}}}}:{type:`file`,file:e.value}})),[e.attachments]);return/* @__PURE__ */ (0,f.jsx)(pd,{content:r,previewAttachments:i,renderMessageImages:t,pending:e.placement===`steering`,echo:!0,t:n,actions:t=>/* @__PURE__ */ (0,f.jsx)(td,{text:t,time:e.time,clock:`start`,className:q.actions,t:n})})}let gd=(0,d.memo)(function({node:e,renderMessageImages:t,openFile:n,openSkill:r,messageEditing:i,useProjection:a,links:o,t:s}){let c=e.data,l=nd(a,e.location.kind===`turn`||e.location.kind===`step`?e.location.turn.turn:void 0,`start`);return/* @__PURE__ */ (0,f.jsx)(pd,{content:c.content,editor:i?.draft?.seq===c.seq?/* @__PURE__ */ (0,f.jsx)(id,{editing:i,t:s}):void 0,references:{openFile:n,openSkill:r},links:o,renderMessageImages:t,responseAnnotations:c.responseAnnotations,...c.referenceLabels===void 0?{}:{referenceLabels:c.referenceLabels},...c.skillNames===void 0?{}:{skillNames:c.skillNames},t:s,actions:t=>/* @__PURE__ */ (0,f.jsx)(td,{extraActions:e.kind===`user`&&i?.targetSeq===c.seq&&!i.draft?/* @__PURE__ */ (0,f.jsx)(`button`,{type:`button`,className:q.editAction,"aria-label":s(`message.edit`),title:s(`message.edit`),onClick:()=>i.begin(c.seq,t,c.content,c.responseAnnotations),children:/* @__PURE__ */ (0,f.jsx)(p.IconEditOutlineRegular,{})}):null,text:t,time:e.kind===`user`?l:void 0,clock:`start`,className:q.actions,t:s})})});function _d({editing:e,renderMessageImages:t,t:n}){return/* @__PURE__ */ (0,f.jsx)(pd,{content:e.draft?.content??[],responseAnnotations:e.draft?.responseAnnotations,renderMessageImages:t,editor:/* @__PURE__ */ (0,f.jsx)(id,{editing:e,t:n}),t:n})}let vd=(0,d.memo)(function({node:e,t}){let n=e.data;return/* @__PURE__ */ (0,f.jsx)(Ku,{content:n.content,source:n.source,producer:n.producer,form:n.form,t})}),yd=(0,d.memo)(function({node:e,t}){return/* @__PURE__ */ (0,f.jsx)(vu,{node:e.data,t})}),bd=(0,d.memo)(function({node:e,t}){let n=e.data;return/* @__PURE__ */ (0,f.jsx)(ud,{node:n.current,active:n.current.retryState===`scheduled`,t})}),xd=(0,d.memo)(function({node:e,t}){return/* @__PURE__ */ (0,f.jsx)(dd,{node:e.data,t})}),Sd=(0,d.memo)(function({t:e}){return/* @__PURE__ */ (0,f.jsx)(fd,{t:e})}),Cd=(0,d.memo)(function({node:e,t}){let n=e.data;return/* @__PURE__ */ (0,f.jsx)(`div`,{className:q.contextRow,children:/* @__PURE__ */ (0,f.jsx)(p.JsonBlock,{label:t(`message.unknownSurface`,{type:n.type}),payload:n.data,truncatedLabel:e=>t(`json.truncated`,{total:e})})})}),wd=/* @__PURE__ */ new Set([`system-prompt`,`user`,`steering`,`turn-trigger`,`turn-process`,`turn-error`,`turn-max-tokens`,`turn-tail`]);function Td(e,t){return e.turn===t.turn&&e.controlAnchorSeq===t.controlAnchorSeq&&e.processStartSeq===t.processStartSeq&&e.answerAnchorSeq===t.answerAnchorSeq&&e.answerStep===t.answerStep&&e.inlineReasoning===t.inlineReasoning&&e.messageCount===t.messageCount&&e.toolCallCount===t.toolCallCount&&e.subagentCount===t.subagentCount}function Ed(e){return e===`subagent`||e.startsWith(`subagent_`)}function Dd(e){return e===`compact_context`}function Od(e){let t=e?.location;if(t?.kind!==`turn`&&t?.kind!==`step`)return!1;let n=t.turn.end?.data.reason.kind;return t.turn.status===`open`||t.turn.end?.data.finalAssistantStep===null||n===`aborted`||n===`error`}function kd(e,t){return e.turnProcesses.find(e=>e.turn===t)}function Ad(){return(0,m.defineStore)({init:()=>({turnProcesses:[]}),actions:{setTurnProcessOpen:(e,t,n,r)=>{let i=e.turnProcesses.findIndex(e=>e.turn===t);if(!r){i>=0&&e.turnProcesses.splice(i,1);return}let a={turn:t,answerStep:n};i<0?e.turnProcesses.push(a):e.turnProcesses[i]=a}}})}function jd(e,t){let n=(0,d.useRef)(null);return(0,d.useLayoutEffect)(()=>{let r=n.current;r!==null&&(e&&r.contains(r.ownerDocument.activeElement)?t():e?r.setAttribute(`hidden`,`until-found`):r.removeAttribute(`hidden`))},[e,t]),(0,d.useEffect)(()=>{let e=n.current;if(e!==null)return e.addEventListener(`beforematch`,t),()=>{e.removeEventListener(`beforematch`,t)}},[t]),n}let Md=[],Nd={getSnapshot:()=>Md,subscribe:()=>()=>{}};function Pd(e){let t=Md;return{getSnapshot:()=>{let n=e.getSnapshot().flatMap(e=>e.responseAnnotations??[]);return n.length===t.length&&n.every((e,n)=>e===t[n])||(t=n.length===0?Md:n),t},subscribe:e.subscribe}}function Fd(e,t){let n=(0,d.useMemo)(()=>t===void 0?Nd:Pd(e.turnDataSource(t,`user`)),[e,t]);return(0,d.useSyncExternalStore)(n.subscribe,n.getSnapshot)}let Id=`@deepseek-ai/dsh-client-ui-chat/ChatView.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(Id)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=Id,e.textContent=`.ChmFAW_frame{flex-direction:column;flex:auto;min-height:0;display:flex;position:relative;container-type:inline-size}.ChmFAW_root{flex-direction:column;flex:auto;min-height:0;display:flex;position:relative;overflow:visible clip}.ChmFAW_scroll{min-height:0;padding:16px calc(var(--dsh-composer-side-clearance) + 16px);flex:auto;overflow-y:auto;container-type:inline-size}.ChmFAW_root[data-chat-following-tail] .ChmFAW_scroll,[data-conversation-scroll]:has(.ChmFAW_root[data-chat-following-tail]){overflow-anchor:none}[data-conversation-scroll] .ChmFAW_frame,[data-conversation-scroll] .ChmFAW_root{flex:none;height:auto;min-height:auto}[data-conversation-scroll] .ChmFAW_scroll{flex:none;min-height:auto;overflow:visible}.ChmFAW_column{max-width:var(--dsh-chat-content-width);flex-direction:column;width:100%;margin:0 auto;display:flex}.ChmFAW_column>:not([hidden]):not(.ChmFAW_flowItem:is(:empty,:has(>[data-slot="conversation.chat.node"]:empty)))~:not([hidden]):not(.ChmFAW_flowItem:is(:empty,:has(>[data-slot="conversation.chat.node"]:empty))){margin-top:var(--dsh-chat-flow-gap,6px)}.ChmFAW_flowItem[data-chat-group-part=response],.ChmFAW_column>[data-chat-group-part=response]:not([hidden]):not(:empty)+:not([hidden]):not(.ChmFAW_flowItem:is(:empty,:has(>[data-slot="conversation.chat.node"]:empty))):not(.ChmFAW_running){--dsh-chat-flow-gap:12px}.ChmFAW_flowItem{min-width:0}.ChmFAW_flowItem[data-chat-flow-kind=turn-process],.ChmFAW_flowItem[data-turn-process-answer],.ChmFAW_column>[data-chat-flow-kind=turn-process]+:not([hidden]):not(.ChmFAW_flowItem:is(:empty,:has(>[data-slot="conversation.chat.node"]:empty))):not(.ChmFAW_running){--dsh-chat-flow-gap:16px}.ChmFAW_flowItem:is(:empty,:has(>[data-slot="conversation.chat.node"]:empty)){height:0}.ChmFAW_callRow{border-radius:var(--dsw-radius-sm)}.ChmFAW_syncing{color:var(--dsw-alias-label-secondary);font-size:var(--dsh-content-font-size-secondary,13px);line-height:calc(18px + var(--dsh-content-font-delta-secondary,0px));align-items:center;gap:6px;padding-block:8px;display:flex}@media (prefers-reduced-motion:reduce){.ChmFAW_syncingIcon{display:none}}.ChmFAW_hint{color:var(--dsw-alias-label-tertiary);font-size:var(--dsh-content-font-size-secondary,13px);line-height:calc(18px + var(--dsh-content-font-delta-secondary,0px))}.ChmFAW_running{--dsh-chat-flow-gap:12px;--dsw-alias-label-shimmer:var(--dsw-alias-label-deep-diving-shimmer);color:var(--dsw-alias-label-deep-diving);font-size:calc(var(--dsh-content-font-size,14px) - 2px);line-height:calc(22px + var(--dsh-content-font-delta,0px));flex-direction:column;align-items:flex-start;display:flex}.ChmFAW_column>:nth-last-child(2 of :not([hidden]):not(.ChmFAW_flowItem:is(:empty,:has(>[data-slot="conversation.chat.node"]:empty)))):is(.ChmFAW_flowItem:not([data-chat-flow-kind=user]):not([data-chat-flow-kind=steering]):not([data-chat-flow-kind=turn-trigger]),[data-chat-group-key])~.ChmFAW_running>.ChmFAW_runningDivider{display:block}.ChmFAW_runningDivider{background:color-mix(in srgb, var(--dsw-alias-border-l1) 75%, var(--dsw-alias-border-l2));pointer-events:none;width:100%;height:.5px;margin:8px 0 10px;display:none}.ChmFAW_runningContent{align-items:center;gap:6px;min-width:0;display:inline-flex}.ChmFAW_runningText{font-variant-numeric:tabular-nums;min-width:0}.ChmFAW_runningIcon{width:calc(16px + var(--dsh-content-font-delta,0px));height:calc(16px + var(--dsh-content-font-delta,0px));contain:strict;flex:none;display:inline-flex;overflow:hidden}.ChmFAW_runningIconMotion{transform-origin:50% 60%;width:100%;height:100%;display:inline-flex}@keyframes ChmFAW_runningIconSway{0%,to{transform:translateY(.5px)rotate(-20deg)}50%{transform:translateY(-.6px)rotate(20deg)}}@media (prefers-reduced-motion:no-preference) and (forced-colors:none){.ChmFAW_runningIconMotion{animation:1.6s ease-in-out infinite ChmFAW_runningIconSway}}.ChmFAW_openError{color:var(--dsw-alias-state-error-primary);font-size:var(--dsh-content-font-size-secondary,13px);line-height:calc(18px + var(--dsh-content-font-delta-secondary,0px))}.ChmFAW_older{min-height:28px;color:var(--dsw-alias-label-secondary);flex-wrap:wrap;justify-content:center;align-items:center;gap:8px;font-size:12px;display:flex}.ChmFAW_older button{border-radius:var(--dsw-radius-sm);color:var(--dsw-alias-label-secondary);background:var(--dsw-alias-interactive-bg-hover-solid);cursor:pointer;border:none;padding:4px 12px;font-size:12px}.ChmFAW_older button:disabled{cursor:default;opacity:.6}.ChmFAW_toBottomSlot{z-index:8;height:0;padding-right:max(calc(var(--dsh-composer-side-clearance) + 16px), calc((100% - var(--dsh-chat-content-width)) / 2));pointer-events:none;justify-content:flex-end;display:flex;position:absolute;bottom:16px;left:0;right:0}[data-conversation-scroll] .ChmFAW_toBottomSlot{bottom:calc(var(--dsh-composer-height,152px) + 16px);position:sticky}.ChmFAW_toBottom{--dsw-elevation-stroke-color:var(--dsw-alias-border-l3);corner-shape:round;width:34px;height:34px;color:var(--dsw-alias-label-primary);background:var(--dsw-alias-button-floating-fill);box-shadow:var(--dsw-elevation-panel);cursor:pointer;pointer-events:auto;border:0;border-radius:100px;justify-content:center;align-items:center;margin-top:-34px;padding:0;display:flex}.ChmFAW_toBottom:hover{background:var(--dsw-alias-button-floating-hover)}.ChmFAW_modalAction{min-width:72px}`,document.head.appendChild(e)}var Y={callRow:`ChmFAW_callRow`,column:`ChmFAW_column`,flowItem:`ChmFAW_flowItem`,frame:`ChmFAW_frame`,hint:`ChmFAW_hint`,modalAction:`ChmFAW_modalAction`,older:`ChmFAW_older`,openError:`ChmFAW_openError`,root:`ChmFAW_root`,running:`ChmFAW_running`,runningContent:`ChmFAW_runningContent`,runningDivider:`ChmFAW_runningDivider`,runningIcon:`ChmFAW_runningIcon`,runningIconMotion:`ChmFAW_runningIconMotion`,runningIconSway:`ChmFAW_runningIconSway`,runningText:`ChmFAW_runningText`,scroll:`ChmFAW_scroll`,syncing:`ChmFAW_syncing`,syncingIcon:`ChmFAW_syncingIcon`,toBottom:`ChmFAW_toBottom`,toBottomSlot:`ChmFAW_toBottomSlot`};function Ld(e){let t=e?.location;return t?.kind===`turn`||t?.kind===`step`?t.turn.data:void 0}function Rd(e){let t=e?.location;return t?.kind===`turn`||t?.kind===`step`?t.turn.turn:void 0}function zd(e){return e?.kind===`tool-call`&&Dd(e.data.root.name)}let Bd=(0,d.memo)(function({nodeKey:e,groupPart:t,nodeStore:n,useChatNode:r,useChatNodeProcess:i,usePresentation:a,cwd:o,openFile:s,openSkill:c,inspectCall:l,forkAt:u,loadTurnDiffs:h,messageEditing:g,loadImage:_,renderMessageImages:v,fileMentions:y,useStore:ee,actions:b,renderSlot:te,t:x}){let S=r(e),C=S,w=Rd(C),T=i(e),E=T?.spec,ne=ee(e=>E===void 0?void 0:kd(e,E.turn)),re=E!==void 0&&ne?.answerStep===(E.answerStep??0)?ne:void 0,ie=T!==void 0&&!T.turnClosed,D=T?.hasInterleavedInput===!0,ae=ie||D||Od(C),O=ae||re!==void 0,oe=(0,d.useCallback)(e=>{E!==void 0&&!ae&&b.setTurnProcessOpen(E.turn,E.answerStep??0,e)},[b,E,ae]),k=a(e=>e.foldCompletedTurns),se=E!==void 0&&T!==void 0&&k&&T.turn===E.turn&&(T.turnStarted||T.turnClosed),ce=C!==void 0&&se&&!ie&&t!==`reasoning`&&C.kind===`assistant-step`&&C.data.step===E.answerStep,le=C!==void 0&&se&&!ce&&!wd.has(C.kind)&&!zd(C)&&C.anchorSeq>=E.processStartSeq,ue=C?.kind===`turn-process`||ce,de=se&&(ie||le||ue),fe=(0,d.useMemo)(()=>E===void 0?void 0:{spec:E,foldable:de,hasContent:!D&&(T?.hasExternalProcess===!0||E.inlineReasoning),open:O,setOpen:oe},[de,D,O,E,T?.hasExternalProcess,oe]),pe=C?.kind===`turn-process`&&k&&!de,me=ce&&de&&T.compactAnswer&&!O,he=pe||de&&le&&!O,A=jd(he,(0,d.useCallback)(()=>{le&&oe(!0)},[le,oe])),[ge]=(0,d.useState)(()=>(0,m.createSnapshotStore)(0)),_e=Fd(n,w),ve=Ld(C),ye=(0,d.useMemo)(()=>({turnData:ve,disclosureReset:ge}),[ve,ge]);(0,d.useEffect)(()=>{le&&he&&A.current?.hasAttribute(`hidden`)&&ge.set(ge.getSnapshot()+1)},[le,he,A,ge]);let be=(0,d.useMemo)(()=>S===void 0?null:{...t===void 0?{}:{groupPart:t},cwd:o,openFile:s,openSkill:c,inspectCall:l,forkAt:u,loadTurnDiffs:h,messageEditing:g,loadImage:_,renderMessageImages:v,fileMentions:y,turnProcess:fe,responseAnnotations:_e},[S,t,o,s,c,l,u,h,g,_,v,y,fe,_e]);if(C===void 0||be===null)return null;let xe={...be,node:C},Se=t===void 0||t===`response`?C.key:JSON.stringify([C.key,t]);return/* @__PURE__ */ (0,f.jsx)(`div`,{ref:A,className:Y.flowItem,"data-chat-anchor-key":Se,"data-chat-flow-key":Se,"data-chat-paging-anchor":C.kind!==`turn-process`||void 0,"data-chat-node-key":C.key,"data-chat-group-part":t,"data-chat-flow-kind":C.kind,"data-chat-turn":w,"data-turn-process-member":le||void 0,"data-turn-process-hidden":he||void 0,"data-turn-process-answer":me||void 0,children:te(`conversation.chat.node`,xe,{entryKey:C.kind,hookContext:ye,fallback:/* @__PURE__ */ (0,f.jsx)(p.JsonBlock,{label:x(`message.unknownSurface`,{type:C.kind}),payload:C.data,truncatedLabel:e=>x(`json.truncated`,{total:e})})})})}),Vd={'"':`"`,"\\":`\\`,"/":`/`,b:`\b`,f:`\f`,n:`
126
+ `,r:`\r`,t:` `},Hd=/[\\\u0000-\u001f]/u;function Ud(e){return e===` `||e===`
127
+ `||e===`\r`||e===` `}function Wd(e){return e>=`0`&&e<=`9`||e>=`a`&&e<=`f`||e>=`A`&&e<=`F`}var Gd=class e{static EMPTY=e.fromObject({});static fromText(t){let n=new e;return n.append(t),n.sealed=!0,n}static fromObject(t){let n=new e;return n.object=typeof t==`object`&&t&&!Array.isArray(t)?t:{},n.sealed=!0,n}chunks=[];object;sealed=!1;#e=[];#t=0;#n=0;#r=`root`;#i=!1;#a=0;#o=!1;#s=``;#c=null;#l=[];#u=!1;#d;#f=!1;#p=/* @__PURE__ */ new Map;#m=[];#h=/* @__PURE__ */ new Map;get isSealed(){return this.sealed}get invalid(){return this.scan(),this.#r===`invalid`||this.#f}append(e){if(this.sealed)throw Error(`PartialArguments: cannot append to a sealed view`);e.length!==0&&(this.chunks.push(e),this.#t+=e.length,this.#e.push(this.#t))}settle(t){if(this.object!==void 0||t.length!==this.#t)return e.fromText(t);let n=0;for(let r of this.chunks){if(!t.startsWith(r,n))return e.fromText(t);n+=r.length}return this.chunks=t.length===0?[]:[t],this.#e=t.length===0?[]:[t.length],this.sealed=!0,this}refresh(){if(this.#h.size===0)return!1;this.scan();let e=!1,t=!1;for(let n of this.#h.values())n.completion?t=!0:e=this.refreshRead(n)||e;if(t)for(let t of this.#h.values())t.completion&&(e=this.refreshRead(t)||e);return this.sealed&&this.#h.clear(),e}refreshRead(e){let t=e.answer();return!Object.is(t,e.last)&&(e.last=t,!0)}closed(){return this.remember(`closed`,``,()=>this.closedNow())}keys(){return this.remember(`keys`,``,()=>this.keysNow(),e=>e.length)}has(e){return this.remember(`has`,e,()=>this.hasNow(e))}complete(e){return this.remember(`complete`,e,()=>this.completeNow(e))}stringLength(e,t){let n=Math.max(1,Math.floor(t?.step??1)),r=t?.offset??0;return this.remember(`length:${n}:${r}`,e,()=>this.lengthNow(e),e=>e===void 0?void 0:Math.ceil((e+r)/n))}stringExceeds(e,t){let n=Math.max(0,Math.floor(t));return this.remember(`exceeds:${n}`,e,()=>(this.lengthNow(e,n+1)??0)>n)}text(e){return this.remember(`text`,e,()=>this.textNow(e))}textPrefix(e,t){let n=Math.max(1,Math.floor(t));return this.remember(`prefix:${n}`,e,()=>this.textPrefixNow(e,n))}value(e){return this.remember(`value`,e,()=>this.valueNow(e))}remember(e,t,n,r){this.scan();let i=n();if(!this.sealed){let a=`${e}/${t}`;this.#h.has(a)||this.#h.set(a,{completion:e===`complete`,answer:r===void 0?n:()=>r(n()),last:r===void 0?i:r(i)})}return i}closedNow(){return this.sealed||this.#r===`closed`||this.#r===`invalid`}keysNow(){return this.object===void 0?this.#m:Object.keys(this.object)}hasNow(e){return this.object===void 0?this.#p.has(e):Object.hasOwn(this.object,e)}completeNow(e){if(this.object!==void 0)return Object.hasOwn(this.object,e);let t=this.#p.get(e);return t!==void 0&&t.end>=0&&(t.kind===`string`?t.invalidAt===void 0:!t.invalid)}lengthNow(e,t=1/0){if(this.object!==void 0){let t=Object.hasOwn(this.object,e)?this.object[e]:void 0;return typeof t==`string`?t.length:void 0}let n=this.#p.get(e);if(n?.kind!==`string`)return;if(n.text!==void 0&&n.text.at===n.end)return n.text.length;let r=n.length??={at:n.start,length:0,text:``};return this.readString(n,r,t,!1),r.length}textNow(e){if(this.object!==void 0){let t=Object.hasOwn(this.object,e)?this.object[e]:void 0;return typeof t==`string`?t:void 0}let t=this.#p.get(e);if(t?.kind!==`string`)return;if(t.text===void 0&&t.end>=0&&t.needsDecoding&&t.invalidAt===void 0){let e;try{e=JSON.parse(`"${this.slice(t.start,t.end)}"`)}catch{}e!==void 0&&(t.text={at:t.end,length:e.length,text:e})}let n=t.text??={at:t.start,length:0,text:``};return this.readString(t,n,1/0,!0),n.text}textPrefixNow(e,t){if(this.object!==void 0){let n=Object.hasOwn(this.object,e)?this.object[e]:void 0;return typeof n==`string`?n.slice(0,t):void 0}let n=this.#p.get(e);if(n?.kind!==`string`)return;let r=n.prefixes??=/* @__PURE__ */ new Map,i=r.get(t);return i===void 0&&(i={at:n.start,length:0,text:``},r.set(t,i)),this.readString(n,i,t,!0),i.text}valueNow(e){if(this.object!==void 0){if(!Object.hasOwn(this.object,e))return;let t=this.object[e];return typeof t==`string`?void 0:t}let t=this.#p.get(e);if(!(t?.kind!==`value`||t.end<0||t.invalid)){if(t.parsed===void 0)try{t.parsed=JSON.parse(this.slice(t.start,t.end))}catch{t.invalid=!0,this.#f=!0}return t.parsed}}chunkAt(e){let t=0,n=this.#e.length;for(;t<n;){let r=t+n>>>1;this.#e[r]<=e?t=r+1:n=r}return t}slice(e,t){if(e>=t)return``;let n=this.chunkAt(e),r=this.chunkAt(t-1),i=n===0?0:this.#e[n-1];if(n===r)return this.chunks[n].slice(e-i,t-i);let a=[this.chunks[n].slice(e-i)];for(let e=n+1;e<r;e++)a.push(this.chunks[e]);return a.push(this.chunks[r].slice(0,t-this.#e[r-1])),a.join(``)}readString(e,t,n,r){let i=Math.min(e.end<0?this.#n:e.end,e.invalidAt??1/0,this.#d??1/0);if(!e.needsDecoding){let e=Math.min(i-t.at,n-t.length);if(e<=0)return;r&&(t.text+=this.slice(t.at,t.at+e)),t.at+=e,t.length+=e;return}let a=this.chunkAt(t.at);for(;t.at<i&&t.length<n;){let o=a===0?0:this.#e[a-1],s=this.chunks[a],c=s.slice(t.at-o,Math.min(s.length,i-o)),l=c.search(Hd),u=Math.min(l<0?c.length:l,n-t.length);if(u>0){r&&(t.text+=c.slice(0,u)),t.at+=u,t.length+=u,t.at===o+s.length&&a++;continue}let d=c.length>1?c[1]:t.at+1<i?this.chunks[a+1][0]:void 0,f,p=2;if(c[0]===`\\`&&d===void 0&&e.end<0)return;if(c[0]===`\\`&&d===`u`){let n=this.slice(t.at+2,Math.min(i,t.at+6)),r=!0;for(let e=0;e<n.length;e++)Wd(n[e])||(r=!1);if(r){if(n.length<4&&e.end<0)return;n.length===4&&(f=String.fromCharCode(Number.parseInt(n,16)))}p=6}else c[0]===`\\`&&d!==void 0&&(f=Vd[d]);if(f===void 0){e.invalidAt=t.at,this.#f=!0;return}for(r&&(t.text+=f),t.length++,t.at+=p;a<this.chunks.length&&t.at>=this.#e[a];)a++}}scan(){if(this.object===void 0&&this.#n!==this.#t)for(let e=this.chunkAt(this.#n);e<this.chunks.length&&this.#d===void 0;e++){let t=this.chunks[e],n=e===0?0:this.#e[e-1];for(let e=this.#n-n;e<t.length&&this.#r!==`invalid`;e++){if(this.#r===`string`||this.#r===`nested`&&this.#u){let n=this.stringBoundary(t,e);if(this.#n+=n-e,e=n,e===t.length)break}this.step(t[e],this.#n),this.#n++}}}stringBoundary(e,t){let n=t;for(;;){let t=e.indexOf(`"`,n),r=t<0?e.length:t;if(this.#r===`string`){let t=this.#c;!t.needsDecoding&&Hd.test(e.slice(n,r))&&(t.needsDecoding=!0)}let i=r;for(;i>n&&e[i-1]===`\\`;)i--;let a=(r-i)%2==1!==(i===n&&this.#i);if(this.#i=t<0&&a,t<0||!a)return r;n=t+1}}step(e,t){switch(this.#r){case`root`:if(Ud(e))return;if(e===`{`){this.#r=`key-or-end`;return}this.fail();return;case`key-or-end`:if(Ud(e))return;if(e===`}`){this.#r=`closed`;return}if(e===`"`){this.beginKey(t);return}this.fail();return;case`key-only`:if(Ud(e))return;if(e===`"`){this.beginKey(t);return}this.fail();return;case`key`:this.stepKey(e,t);return;case`colon`:if(Ud(e))return;if(e===`:`){this.#r=`value`;return}this.fail();return;case`value`:this.beginValue(e,t);return;case`string`:{let e=this.#c;e.end=t,this.#c=null,this.#r=`comma-or-end`;return}case`scalar`:this.stepScalar(e,t);return;case`nested`:this.stepNested(e,t);return;case`comma-or-end`:if(Ud(e))return;if(e===`,`){this.#r=`key-only`;return}if(e===`}`){this.#r=`closed`;return}this.fail();return;case`closed`:if(Ud(e))return;this.fail();return;
128
128
  /* v8 ignore next 2 -- scan() stops stepping once the view is invalid. */
129
129
  case`invalid`:return;
130
130
  /* v8 ignore next 2 -- Every scanner mode has a handler above. */
131
- default:kd(this.#r)}}fail(){this.#d=this.#n,this.#r=`invalid`,this.#c=null}beginKey(e){this.#r=`key`,this.#a=e+1,this.#o=!1,this.#i=!1}stepKey(e,t){if(e<` `){this.fail();return}if(this.#i){this.#i=!1;return}if(e===`\\`){this.#i=!0,this.#o=!0;return}if(e!==`"`)return;let n=this.slice(this.#a,t);if(this.#o)try{this.#s=JSON.parse(`"${n}"`)}catch{this.fail();return}else this.#s=n;this.#r=`colon`}open(e){this.#p.has(this.#s)||this.#m.push(this.#s),this.#p.set(this.#s,e),this.#c=e}beginValue(e,t){Ed(e)||(e===`"`?(this.open({kind:`string`,start:t+1,end:-1,needsDecoding:!1,invalidAt:void 0,length:void 0,text:void 0,prefixes:void 0}),this.#i=!1,this.#r=`string`):e===`}`||e===`,`||e===`:`||e===`]`?this.fail():(this.open({kind:`value`,start:t,end:-1,parsed:void 0,invalid:!1}),e===`{`||e===`[`?(this.#r=`nested`,this.#l=[e===`{`?`}`:`]`],this.#u=!1,this.#i=!1):this.#r=`scalar`))}stepScalar(e,t){(e===`,`||e===`}`||Ed(e))&&(this.closeValue(t),this.#r=e===`,`?`key-only`:e===`}`?`closed`:`comma-or-end`)}stepNested(e,t){if(this.#u)this.#u=!1;else if(e===`"`)this.#u=!0;else if(e===`{`||e===`[`)this.#l.push(e===`{`?`}`:`]`);else if(e===`}`||e===`]`){if(this.#l.pop()!==e){this.fail();return}this.#l.length===0&&(this.closeValue(t+1),this.#r=`comma-or-end`)}}closeValue(e){let t=this.#c;t.end=e,this.#c=null}};function kd(e,t){let n=JSON.stringify(e)??String(e);throw Error(`unreachable variant${t?` in ${t}`:``}: ${n}`)}function Ad(e){switch(e.kind){case`node`:return JSON.stringify([`node`,e.key,e.groupPart??null]);case`group`:return JSON.stringify([`group`,e.key]);default:return kd(e)}}function jd(e,t){let n=e.counts.slice(0,3).map(({kind:e})=>t(`message.stepProcess.done.${e}`)),r=n[0];if(r===void 0)return t(`message.stepProcess.done.thinking`);let i=e=>e.charAt(0).toLowerCase()+e.slice(1),a=n[1];if(a===void 0)return r;if(n.length===2){let e=t(`message.stepProcess.sharedPrefix`);return t(`message.stepProcess.joinTwo`,{first:r,second:i(e!==``&&r.startsWith(e)&&a.startsWith(e)?a.slice(e.length):a)})}let o=[r,...n.slice(1).map(i)].join(t(`message.stepProcess.comma`));return e.counts.length>3?t(`message.stepProcess.more`,{title:o}):o}function Md(e=0){let[t,n]=(0,d.useState)(null);return{expanded:t===e,setExpanded:(0,d.useCallback)(t=>{n(t?e:null)},[e]),toggle:(0,d.useCallback)(()=>{n(t=>t===e?null:e)},[e])}}function Nd(e){let t=t=>e.subscribe(t),n=()=>e.getSnapshot();return function(){return Md((0,d.useSyncExternalStore)(t,n))}}function Pd(e){let t=e.clientHeight;return{top:e.scrollTop,height:t,floor:Math.max(0,e.scrollHeight-t)}}var Fd=class e{following;threshold;static owners=/* @__PURE__ */ new WeakMap;target=null;sampledTop;constructor(e,t){this.following=e,this.threshold=t}static forElement(e){return this.owners.get(e)}bind(t){return e.owners.set(t,this),()=>{e.owners.get(t)===this&&e.owners.delete(t)}}get active(){return this.following}get animating(){return this.target!==null}nearBottom(e){return e.floor-e.top<=this.threshold}setFollowing(e){this.following=e,e||(this.target=null)}reset(){this.setFollowing(!1),this.sampledTop=void 0}sample(e,t=this.sampledTop===void 0||Math.abs(e.top-this.sampledTop)>.5){return this.sampledTop=e.top,!this.animating&&t&&(this.following=this.nearBottom(e)),this.active}settle(e){let t=this.target;return this.target=null,this.sample(e,t===null?void 0:Math.abs(e.top-Math.min(t,e.floor))>this.threshold)}jump(e,t,n){let r=this.animating;this.target=null;let i=Math.max(0,Math.min(t.floor,n));r?e.scrollTo({top:i,behavior:`instant`}):i!==t.top&&(e.scrollTop=i);let a={...t,top:e.scrollTop};return this.sampledTop=a.top,this.following=this.nearBottom(a),a}toBottom(e,t,n){return this.following=!0,n===`instant`||t.top>=t.floor||!this.animating&&this.nearBottom(t)||typeof matchMedia==`function`&&matchMedia(`(prefers-reduced-motion: reduce)`).matches?this.jump(e,t,t.floor):(this.target===null&&(this.target=t.floor,e.scrollTo({top:t.floor,behavior:`smooth`})),t)}interrupt(e,t){this.animating&&(this.target=null,this.sampledTop=t.top,e.scrollTo({top:t.top,behavior:`instant`}))}};function Id(e,t){let[n]=(0,d.useState)(()=>new Fd(e,t));return n}let Ld={canScrollUp:!1,canScrollDown:!1},Rd=/* @__PURE__ */ new Set([`ArrowUp`,`ArrowDown`,`PageUp`,`PageDown`,`Home`,`End`,` `]);function zd(e,t,n,r){let i=Id(!1,1),a=(0,d.useRef)(null),[o,s]=(0,d.useState)(Ld),c=(0,d.useCallback)(e=>{a.current=e},[]),l=(0,d.useCallback)(t=>{let n=e.current,r=Ld;if(n!==null&&n.closest(`[hidden], [data-group-expanded-mode]`)===null){let e=Pd(n),o=t===`resize`?a.current:null;if(o!==null)e=i.jump(n,e,o===`bottom`?e.floor:0),o===`top`&&i.setFollowing(!1),a.current=null;else{let r=i.animating;t===`scrollend`?i.settle(e):i.sample(e),i.active&&(t===`resize`||t===`scrollend`&&r)&&(e=i.toBottom(n,e,`smooth`))}r={canScrollUp:e.top>1,canScrollDown:e.top<e.floor-1}}else i.reset();s(e=>e.canScrollUp===r.canScrollUp&&e.canScrollDown===r.canScrollDown?e:r)},[e,i]),u=(0,d.useCallback)(()=>{let t=e.current;t!==null&&i.animating&&i.interrupt(t,Pd(t))},[e,i]),f=(0,d.useMemo)(()=>({onScroll:()=>{l(`scroll`)},onWheel:u,onTouchStart:u,onPointerDown:u,onKeyDown:e=>{!e.defaultPrevented&&Rd.has(e.key)&&u()}}),[u,l]);return(0,d.useLayoutEffect)(()=>{u(),i.reset(),(!r||!n)&&(a.current=null)},[i,r,u,n]),(0,d.useLayoutEffect)(()=>{let r=e.current;if(r===null||!n||typeof ResizeObserver>`u`)return;let a=i.bind(r),o=new ResizeObserver(()=>{l(`resize`)}),s=e=>{e.target===r&&l(`scrollend`)};return r.addEventListener(`scrollend`,s),o.observe(r),t.current!==null&&o.observe(t.current),()=>{a(),o.disconnect(),r.removeEventListener(`scrollend`,s)}},[e,t,i,n,l]),{edges:o,events:f,initialize:c}}let Bd=`@deepseek-ai/dsh-client-ui-chat/ChatGroupSeat.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(Bd)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=Bd,e.textContent=`.d7zOOa_root{min-width:0}.d7zOOa_title{max-width:100%;color:var(--dsw-alias-label-tertiary);font:inherit;font-size:var(--dsh-content-font-size,14px);text-align:left;cursor:pointer;background:0 0;border:0;align-items:center;gap:6px;padding:0;transition:color .1s;display:flex}.d7zOOa_title:hover{color:var(--dsw-alias-label-secondary)}.d7zOOa_leading{width:calc(16px + var(--dsh-content-font-delta,0px));height:calc(16px + var(--dsh-content-font-delta,0px));color:inherit;flex:none;justify-content:center;align-items:center;display:inline-flex;position:relative}.d7zOOa_leading svg{width:calc(14px + var(--dsh-content-font-delta,0px));height:calc(14px + var(--dsh-content-font-delta,0px))}.d7zOOa_leading svg[width="16"]{width:calc(16px + var(--dsh-content-font-delta,0px));height:calc(16px + var(--dsh-content-font-delta,0px))}.d7zOOa_activityIcon,.d7zOOa_chevron{justify-content:center;align-items:center;transition:opacity .1s;display:inline-flex;position:absolute;inset:0}.d7zOOa_activityIcon{opacity:1}.d7zOOa_chevron,.d7zOOa_title:is(:hover,:focus-visible) .d7zOOa_activityIcon{opacity:0}.d7zOOa_title:is(:hover,:focus-visible) .d7zOOa_chevron{opacity:1}.d7zOOa_title[aria-expanded=true] .d7zOOa_activityIcon{opacity:0}.d7zOOa_title[aria-expanded=true] .d7zOOa_chevron{opacity:1}.d7zOOa_title[aria-expanded=true]{padding-bottom:8px}.d7zOOa_body{--dsh-chat-flow-gap:6px;overscroll-behavior-y:auto;scrollbar-gutter:stable;max-height:min(400px,50vh);overflow-y:auto}.d7zOOa_label{text-overflow:ellipsis;white-space:nowrap;min-width:0;overflow:hidden}.d7zOOa_fadeTop{mask-image:linear-gradient(#0000 0,#000 24px 100%)}.d7zOOa_fadeBottom{mask-image:linear-gradient(#000 0 calc(100% - 24px),#0000 100%)}.d7zOOa_fadeTop.d7zOOa_fadeBottom{mask-image:linear-gradient(#0000 0,#000 24px calc(100% - 24px),#0000 100%)}@media (prefers-reduced-motion:reduce){.d7zOOa_title,.d7zOOa_activityIcon,.d7zOOa_chevron{transition:none}}.d7zOOa_content{flex-direction:column;display:flex}.d7zOOa_content>*{flex-shrink:0}.d7zOOa_content>:not([hidden]):not(:empty)~:not([hidden]):not(:empty){margin-top:var(--dsh-chat-flow-gap,6px)}.d7zOOa_expandedBody{scrollbar-gutter:auto;max-height:none;overflow:visible}`,document.head.appendChild(e)}var Vd={activityIcon:`d7zOOa_activityIcon`,body:`d7zOOa_body`,chevron:`d7zOOa_chevron`,content:`d7zOOa_content`,expandedBody:`d7zOOa_expandedBody`,fadeBottom:`d7zOOa_fadeBottom`,fadeTop:`d7zOOa_fadeTop`,label:`d7zOOa_label`,leading:`d7zOOa_leading`,root:`d7zOOa_root`,title:`d7zOOa_title`};let Hd={thinking:/* @__PURE__ */ (0,f.jsx)(p.IconThinkOutlineRegular,{}),read:/* @__PURE__ */ (0,f.jsx)(p.IconBrowseOutlineRegular,{size:14}),readImage:/* @__PURE__ */ (0,f.jsx)(p.IconBrowseOutlineRegular,{size:14}),search:/* @__PURE__ */ (0,f.jsx)(p.IconSearchOutlineRegular,{size:14}),edit:/* @__PURE__ */ (0,f.jsx)(p.IconEditOutlineRegular,{size:14}),write:/* @__PURE__ */ (0,f.jsx)(p.IconEditOutlineRegular,{size:14}),commands:/* @__PURE__ */ (0,f.jsx)(p.IconApiOutlineRegular,{}),code:/* @__PURE__ */ (0,f.jsx)(p.IconCodeOutlineRegular,{size:14}),webSearch:/* @__PURE__ */ (0,f.jsx)(p.IconGlobeOutlineRegular,{}),webFetch:/* @__PURE__ */ (0,f.jsx)(p.IconBrowseOutlineRegular,{size:14}),subagents:/* @__PURE__ */ (0,f.jsx)(p.IconAgentPresetOutlineRegular,{size:14}),plan:/* @__PURE__ */ (0,f.jsx)(p.IconPlanOutlineRegular,{}),questions:/* @__PURE__ */ (0,f.jsx)(p.IconQuestionOutlineRegular,{}),tools:/* @__PURE__ */ (0,f.jsx)(p.IconSparkleRegular,{size:14})};function Ud(e,t){return e.activity===t.activity&&e.detail===t.detail&&e.preparing===t.preparing}function Wd(e,t){let[n,r]=(0,d.useState)(e),i=(0,d.useRef)(n),a=(0,d.useRef)(e),o=(0,d.useRef)(Date.now());return(0,d.useEffect)(()=>{if(a.current=e,!t||Ud(i.current,e))return;let n=150-(Date.now()-o.current),s=()=>{let e=a.current;i.current=e,o.current=Date.now(),r(e)};if(n<=0){s();return}let c=setTimeout(s,n);return()=>{clearTimeout(c)}},[t,e.activity,e.detail,e.preparing]),t?n:e}let Gd=(0,d.memo)(function({members:e,...t}){return e.map(e=>/* @__PURE__ */ (0,d.createElement)(Cd,{...t,key:Ad(e),nodeKey:e.key,...e.groupPart===void 0?{}:{groupPart:e.groupPart}}))}),Kd=(0,d.memo)(function({groupKey:e,useChatGroup:t,usePresentation:n,t:r,open:i,bodyId:a,toggle:o}){let s=t(e,e=>e?.data),c=n(e=>s?.closed===!1&&e.liveProcessDetail),l=Wd({activity:s?.summary.running??`thinking`,detail:s?.summary.runningDetail??``,preparing:s?.summary.preparing===!0},s!==void 0&&!s.closed);if(s===void 0)return null;let u=s.closed?jd(s.summary,r):l.preparing?r(`message.stepProcess.prepare.${l.activity===`thinking`?`tools`:l.activity}`):r(`message.stepProcess.${l.activity}`),d=c&&!s.closed?l.detail:``,m=d===``?u:`${u}${r(`message.turnProcess.separator`)}${d}`,h=s.closed?s.summary.counts[0]?.kind??`thinking`:l.activity;return/* @__PURE__ */ (0,f.jsxs)(`button`,{type:`button`,className:Vd.title,"aria-expanded":i,"aria-controls":a,"data-process-activity":h,onClick:e=>{e.currentTarget.focus(),o()},children:[/* @__PURE__ */ (0,f.jsxs)(`span`,{className:Vd.leading,"aria-hidden":`true`,children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:Vd.activityIcon,"data-step-process-icon":!0,children:Hd[h]}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:Vd.chevron,"data-step-process-chevron":!0,children:i?/* @__PURE__ */ (0,f.jsx)(p.IconChevronUpOutlineRegular,{}):/* @__PURE__ */ (0,f.jsx)(p.IconChevronDownOutlineRegular,{})})]}),/* @__PURE__ */ (0,f.jsx)(p.TextShimmer,{active:!s.closed,children:/* @__PURE__ */ (0,f.jsx)(p.TextShimmer,{className:Vd.label,children:m})})]})}),qd=(0,d.memo)(function({groupKey:e,useChatGroup:t,...n}){let r=t(e,e=>e?.members),i=t(e,e=>e?.data.turn),a=t(e,e=>e?.data.closed),o=n.usePresentation(e=>e.foldCompletedTurns),{expanded:s,setExpanded:c}=Md(),l=r?.[0]?.key??``,u=n.useChatNodeProcess(l),p=n.useChatNode(l,e=>{let t=e?.location;return t?.kind===`turn`||t?.kind===`step`?t.turn:void 0}),m=n.usePresentation(e=>e.stepGrouping===`collapsed`||e.stepGrouping===`history`&&p?.status!==`open`),h=p?.end?.data.reason.kind,g=u?.turnClosed===!1||u?.hasInterleavedInput===!0||p?.end?.data.finalAssistantStep===null||h===`aborted`||h===`error`,_=u?.spec,v=(0,d.useCallback)(e=>i===void 0?void 0:gd(e,i),[i]),y=n.useStore(v),b=o&&u?.turnClosed===!0&&_!==void 0&&!g&&y?.answerStep!==(_.answerStep??0),x=vd(b,(0,d.useCallback)(()=>{_!==void 0&&!g&&n.actions.setTurnProcessOpen(_.turn,_.answerStep??0,!0)},[n.actions,_,g]));(0,d.useEffect)(()=>{b&&x.current?.hasAttribute(`hidden`)&&c(!1)},[b,x,c]);let ee=(0,d.useCallback)(()=>{c(!0)},[c]),S=vd(m&&!s,ee),C=(0,d.useRef)(null),te=(0,d.useId)(),{edges:w,events:T,initialize:ne}=zd(S,C,s,m),re=(0,d.useCallback)(()=>{s||ne(a===!1?`bottom`:`top`),c(!s)},[a,ne,s,c]);if(r===void 0)return null;let E=[Vd.body,m?``:Vd.expandedBody,m&&w.canScrollUp?Vd.fadeTop:``,m&&w.canScrollDown?Vd.fadeBottom:``];return/* @__PURE__ */ (0,f.jsxs)(`div`,{ref:x,className:Vd.root,"data-chat-group-key":e,"data-chat-flow-key":e,"data-chat-anchor-key":`group:${e}`,"data-chat-turn":i,"data-chat-paging-anchor":m&&!s||void 0,"data-step-process":!0,"data-group-expanded-mode":!m||void 0,children:[/* @__PURE__ */ (0,f.jsx)(`div`,{hidden:!m,children:/* @__PURE__ */ (0,f.jsx)(Kd,{groupKey:e,useChatGroup:t,usePresentation:n.usePresentation,t:n.t,open:s,bodyId:te,toggle:re})}),/* @__PURE__ */ (0,f.jsx)(`div`,{ref:S,id:te,className:E.join(` `),"data-step-process-body":!0,"data-scroll-up":w.canScrollUp||void 0,"data-scroll-down":w.canScrollDown||void 0,...T,children:/* @__PURE__ */ (0,f.jsx)(`div`,{ref:C,className:Vd.content,"data-step-process-content":!0,"data-chat-flow":``,children:/* @__PURE__ */ (0,f.jsx)(Gd,{...n,members:r})})})]})});function Jd(e){return typeof e==`object`?e.key:e}function Yd(e,t){let n=e.length;return new Proxy(e,{get(e,r,i){if(typeof r==`string`){let i=r.charCodeAt(0);if(i>=48&&i<=57){let i=+r;if(Number.isInteger(i)&&i>=0&&i<n){let n=e[i];if(typeof n!=`object`){let r=t[i*2];n=e[i]={index:i,key:n,start:r,size:t[i*2+1],end:r+t[i*2+1],lane:0}}return n}}if(r===`length`)return n}return Reflect.get(e,r,i)}})}function Xd(e,t,n){let r=n.initialDeps??[],i,a=!0;function o(){let o=e();return(o.length!==r.length||o.some((e,t)=>r[t]!==e))&&(r=o,i=t(...o),n?.onChange&&!(a&&n.skipInitialOnChange)&&n.onChange(i),a=!1),i}return o.updateDeps=e=>{r=e},o}function Zd(e,t){if(e===void 0)throw Error(`Unexpected undefined${t?`: ${t}`:``}`);return e}let Qd=(e,t)=>Math.abs(e-t)<1.01,$d=(e,t,n)=>{let r;return Object.assign(function(...i){e.clearTimeout(r),r=e.setTimeout(()=>t.apply(this,i),n)},{cancel:()=>{e.clearTimeout(r)}})},ef,tf=()=>{if(ef!==void 0)return ef;if(typeof navigator>`u`)return ef=!1;if(/iP(hone|od|ad)/.test(navigator.userAgent))return ef=!0;let e=navigator.maxTouchPoints;return ef=navigator.platform===`MacIntel`&&e!==void 0&&e>0},nf=e=>{let{offsetWidth:t,offsetHeight:n}=e;return{width:t,height:n}},rf=e=>e,af=e=>{let t=Math.max(e.startIndex-e.overscan,0),n=Math.min(e.endIndex+e.overscan,e.count-1)-t+1,r=Array(n);for(let e=0;e<n;e++)r[e]=t+e;return r},of=(e,t)=>{let n=e.scrollElement;if(!n)return;let r=e.targetWindow;if(!r)return;let i=e=>{let{width:n,height:r}=e;t({width:Math.round(n),height:Math.round(r)})};if(i(nf(n)),!r.ResizeObserver)return()=>{};let a=new r.ResizeObserver(t=>{let r=()=>{let e=t[0];if(e?.borderBoxSize){let t=e.borderBoxSize[0];if(t){i({width:t.inlineSize,height:t.blockSize});return}}i(nf(n))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(r):r()});return a.observe(n,{box:`border-box`}),()=>{a.unobserve(n)}},sf={passive:!0},cf=typeof window>`u`||`onscrollend`in window,lf=(e,t,n)=>{let r=e.scrollElement;if(!r)return;let i=e.targetWindow;if(!i)return;let a=e.options.useScrollendEvent&&cf,o=0,s=a?null:$d(i,()=>t(n(r),!1),e.options.isScrollingResetDelay),c=e=>()=>{o=n(r),s?.(),t(o,e)},l=c(!0),u=c(!1);return r.addEventListener(`scroll`,l,sf),a&&r.addEventListener(`scrollend`,u,sf),()=>{r.removeEventListener(`scroll`,l),a&&r.removeEventListener(`scrollend`,u),s?.cancel()}},uf=(e,t)=>lf(e,t,t=>{let{horizontal:n,isRtl:r}=e.options;return n?t.scrollLeft*(r&&-1||1):t.scrollTop}),df=(e,t,n)=>{if(n.options.useCachedMeasurements){let t=n.indexFromElement(e),r=n.options.getItemKey(t);return n.itemSizeCache.get(r)??n.options.estimateSize(t)}if(t?.borderBoxSize){let e=t.borderBoxSize[0];if(e)return Math.round(e[n.options.horizontal?`inlineSize`:`blockSize`])}if(!t){let t=n.indexFromElement(e),r=n.options.getItemKey(t),i=n.itemSizeCache.get(r);if(i!==void 0)return i}return e[n.options.horizontal?`offsetWidth`:`offsetHeight`]},ff=(e,{adjustments:t=0,behavior:n},r)=>{var i,a;(a=(i=r.scrollElement)?.scrollTo)==null||a.call(i,{[r.options.horizontal?`left`:`top`]:e+t,behavior:n})};function pf(e,t,n,r){if(t===0)return!1;let i=r(0),a=/* @__PURE__ */ new Set,o=0;for(;o<e;){let e=n(o);if(e===i)break;a.add(e),o++}let s=e-o;if(s===0||s>=t)return!1;for(let e=0;e<s;e++)if(r(e)!==n(o+e))return!1;for(let e=s;e<t;e++)if(a.has(r(e)))return!1;return!0}var mf=class{constructor(e){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this._singleLaneMeasurements=null,this.itemSizeCache=/* @__PURE__ */ new Map,this.itemSizeCacheVersion=0,this.laneAssignments=/* @__PURE__ */ new Map,this.pendingMin=null,this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.pendingScrollAnchor=null,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this._iosDeferredAdjustment=0,this._iosTouching=!1,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._intendedScrollOffset=null,this._clampedAdjustment=null,this.elementsCache=/* @__PURE__ */ new Map,this.now=()=>{var e;return((e=this.targetWindow?.performance)?.now)?.call(e)??Date.now()},this.observer=/* @__PURE__ */ (()=>{let e=null,t=()=>e||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:e=new this.targetWindow.ResizeObserver(e=>{e.forEach(e=>{let t=()=>{let t=e.target,n=this.indexFromElement(t);if(t.isConnected)this.isIndexInRange(n)&&this.shouldMeasureDuringScroll(n)&&this.resizeItem(n,this.options.measureElement(t,e,this));else{this.observer.unobserve(t);for(let[e,n]of this.elementsCache)if(n===t){this.elementsCache.delete(e);break}}};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(t):t()})}));return{disconnect:()=>{var n;(n=t())==null||n.disconnect(),e=null},observe:e=>t()?.observe(e,{box:`border-box`}),unobserve:e=>t()?.unobserve(e)}})(),this.range=null,this.setOptions=e=>{let t={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:rf,rangeExtractor:af,onChange:()=>{},measureElement:df,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:`data-index`,initialMeasurementsCache:[],lanes:1,anchorTo:`start`,followOnAppend:!1,scrollEndThreshold:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,laneAssignmentMode:`estimate`,useCachedMeasurements:!1};for(let n in e){let r=e[n];r!==void 0&&(t[n]=r)}let n=this.options,r=null,i=null,a=!1;if(n!==void 0&&n.enabled&&t.enabled&&t.anchorTo===`end`&&this.scrollElement!==null){let e=n.count,o=t.count,s=this.getMeasurements(),c=this._singleLaneMeasurements?.items??s,l=e=>Jd(c[e]),u=e>0?l(0):null,d=e>0?l(e-1):null;if(o!==e||e>0&&o>0&&(t.getItemKey(0)!==u||t.getItemKey(o-1)!==d)){a=!0;let c=e>0?this.getVirtualItemForOffset(this.getScrollOffset())??s[0]:null;c&&(r=[c.key,this.getScrollOffset()-c.start]);let u=t.followOnAppend===!0?`auto`:t.followOnAppend||null;u&&o>0&&this.isAtEnd(n.scrollEndThreshold)&&(e===0||t.getItemKey(o-1)!==d)&&(o>e||pf(e,o,l,t.getItemKey))&&(i=u)}}this.options=t,a&&(this.pendingMin=0,this.itemSizeCacheVersion++);let o=!1,s=0;if(r&&this.scrollOffset!==null){let[e,t]=r,n=this.getMeasurements(),{count:a,getItemKey:c}=this.options,l=0;for(;l<a&&c(l)!==e;)l++;if(l<a){let e=n[l];if(e){let n=Math.max(0,e.start+t);!i&&n!==this.scrollOffset&&(s=n-this.scrollOffset,this.scrollOffset=n,o=!0)}}}(o||i)&&(this.pendingScrollAnchor=[o?r[0]:null,o?r[1]:0,i,s])},this.notify=e=>{var t,n;(n=(t=this.options).onChange)==null||n.call(t,this,e)},this.maybeNotify=Xd(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),e=>{this.notify(e)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(e=>e()),this.unsubs=[],this.observer.disconnect(),this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,this.isScrolling=!1,this.scrollDirection=null,this._iosDeferredAdjustment=0,this._iosTouching=!1,this._iosJustTouchEnded=!1,this._clampedAdjustment=null,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{let e=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==e){if(this.cleanup(),!e){this.maybeNotify();return}if(this.scrollElement=e,this.targetWindow=this.scrollElement&&`ownerDocument`in this.scrollElement?this.scrollElement.ownerDocument.defaultView:this.scrollElement?.window??null,this.elementsCache.forEach(e=>{this.observer.observe(e)}),this.unsubs.push(this.options.observeElementRect(this,e=>{this.scrollRect=e,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(e,t)=>{if(t&&this._intendedScrollOffset===null&&e===this.scrollOffset)return;this._intendedScrollOffset!==null&&Math.abs(e-this._intendedScrollOffset)<1.5&&(e=this._intendedScrollOffset),this._intendedScrollOffset=null,this._clampedAdjustment!==null&&Math.abs(e-this._clampedAdjustment.maxAtWrite)>=1.5&&(this._clampedAdjustment=null),this.scrollAdjustments=0;let n=this.getScrollOffset();this.scrollDirection=t?n===e?this.scrollDirection:n<e?`forward`:`backward`:null,this.scrollOffset=e,this.isScrolling=t,this._flushIosDeferredIfReady(),this.scrollState&&this.scheduleScrollReconcile(),this.maybeNotify()})),`addEventListener`in this.scrollElement){let e=this.scrollElement,t=()=>{this._iosTouching=!0,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)},n=()=>{this._iosTouching=!1,tf()&&this.targetWindow!=null&&(this._iosJustTouchEnded=!0,this._iosTouchEndTimerId=this.targetWindow.setTimeout(()=>{this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._flushIosDeferredIfReady()},150))};e.addEventListener(`touchstart`,t,sf),e.addEventListener(`touchend`,n,sf),this.unsubs.push(()=>{e.removeEventListener(`touchstart`,t),e.removeEventListener(`touchend`,n),this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)})}this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}let t=this.pendingScrollAnchor;if(this.pendingScrollAnchor=null,t&&this.scrollElement&&this.options.enabled){let[e,n,r,i]=t;e!==null&&!r&&(tf()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?i!==0&&(this._iosDeferredAdjustment+=i):this.scrollState?.behavior===`smooth`&&!Qd(this.getScrollOffset()-i,this.scrollState.lastTargetOffset)||this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})),r&&this.scrollToEnd({behavior:r})}this._retryClampedAdjustment()},this._retryClampedAdjustment=()=>{if(this._clampedAdjustment===null||!this.scrollElement||!this.options.enabled)return;let{target:e,maxAtWrite:t}=this._clampedAdjustment,n=this.getMaxScrollOffset();n>t+.5&&(this._clampedAdjustment=e>n+.5?{target:e,maxAtWrite:n}:null,this._scrollToOffset(e,{adjustments:void 0,behavior:void 0}))},this._flushIosDeferredIfReady=()=>{if(this._iosDeferredAdjustment===0||this.isScrolling||this._iosTouching||this._iosJustTouchEnded)return;let e=this.getScrollOffset(),t=this.getMaxScrollOffset();if(e<0||e>t)return;if(this._iosDeferredAdjustment<0&&e>=t-1){this._iosDeferredAdjustment=0;return}let n=this._iosDeferredAdjustment;this._iosDeferredAdjustment=0,this._scrollToOffset(e,{adjustments:this.scrollAdjustments+=n,behavior:void 0})},this.rafId=null,this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?`width`:`height`]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset==`function`?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getMeasurementOptions=Xd(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes,this.options.laneAssignmentMode,this.options.gap],(e,t,n,r,i,a,o,s)=>(this.prevLanes!==void 0&&this.prevLanes!==a&&(this.lanesChangedFlag=!0),this.prevLanes=a,this.pendingMin=null,{count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:i,lanes:a,laneAssignmentMode:o,gap:s}),{key:!1}),this.isIndexInRange=e=>e>=0&&e<this.options.count,this.getMeasurements=Xd(()=>[this.getMeasurementOptions(),this.itemSizeCacheVersion],({count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:i,lanes:a,laneAssignmentMode:o,gap:s},c)=>{let l=this.itemSizeCache;if(!i)return this.measurementsCache=[],this._singleLaneMeasurements=null,this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>e)for(let t of this.laneAssignments.keys())t>=e&&this.laneAssignments.delete(t);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this._singleLaneMeasurements=null,this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMin=null),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(e=>{this.itemSizeCache.set(e.key,e.size)}));let u=this.lanesSettling?0:this.pendingMin??0;if(this.pendingMin=null,this.lanesSettling&&this.measurementsCache.length===e&&(this.lanesSettling=!1),a===1){let i=e*2,a=this._singleLaneMeasurements?.flat;if(!a||a.length<i){let e=new Float64Array(i);a&&u>0&&e.set(a.subarray(0,u*2)),a=e}let o=u===0?Array(e):this._singleLaneMeasurements.items.slice(),c;if(u===0)c=t+n;else{let e=u-1;c=a[e*2]+a[e*2+1]+s}for(let t=u;t<e;t++){let e=r(t);o[t]=e;let n=l.get(e),i=typeof n==`number`?n:this.options.estimateSize(t);a[t*2]=c,a[t*2+1]=i,c+=i+s}this._singleLaneMeasurements={flat:a,items:o};let d=Yd(o,a);return this.measurementsCache=d,d}let d=this.measurementsCache.slice(0,u),f=Array(a).fill(void 0),p=new Float64Array(a),m=0;for(let e=0;e<u;e++){let t=d[e];t&&(f[t.lane]===void 0&&m++,f[t.lane]=e,p[t.lane]=t.end)}for(let i=u;i<e;i++){let e=r(i),c=this.laneAssignments.get(i),u,h,g=o===`estimate`||l.has(e);if(c!==void 0&&this.options.lanes>1){u=c;let e=f[u],r=e===void 0?void 0:d[e];h=r?r.end+s:t+n}else if(m===a){let e=0,t=p[0],n=f[0];for(let r=1;r<a;r++){let i=p[r];(i<t||i===t&&f[r]<n)&&(e=r,t=i,n=f[r])}u=e,h=t+s,g&&this.laneAssignments.set(i,u)}else u=i%this.options.lanes,h=t+n,g&&this.laneAssignments.set(i,u);let _=l.get(e),v=typeof _==`number`?_:this.options.estimateSize(i),y=h+v;d[i]={index:i,start:h,size:v,end:y,key:e,lane:u},f[u]===void 0&&m++,f[u]=i,p[u]=y}return this.measurementsCache=d,d},{key:!1,debug:()=>this.options.debug}),this.calculateRange=Xd(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(e,t,n,r)=>e.length===0||t===0?(this.range=null,null):(this.range=_f(e,t,n,r,r===1&&this._singleLaneMeasurements!==null?this._singleLaneMeasurements.flat:null),this.range),{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=Xd(()=>{let e=null,t=null,n=this.calculateRange();return n&&(e=n.startIndex,t=n.endIndex),this.maybeNotify.updateDeps([this.isScrolling,e,t]),[this.options.rangeExtractor,this.options.overscan,this.options.count,e,t]},(e,t,n,r,i)=>r===null||i===null?[]:e({startIndex:r,endIndex:i,overscan:t,count:n}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=e=>{let t=this.options.indexAttribute,n=e.getAttribute(t);return n?parseInt(n,10):(console.warn(`Missing attribute name '${t}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=e=>{if(!this.scrollState||this.scrollState.behavior!==`smooth`)return!0;let t=this.scrollState.index??this.getVirtualItemForOffset(this.scrollState.lastTargetOffset)?.index;if(t!==void 0&&this.range){let n=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),r=Math.max(0,t-n),i=Math.min(this.options.count-1,t+n);return e>=r&&e<=i}return!0},this.measureElement=e=>{if(!e){this.elementsCache.forEach((e,t)=>{e.isConnected||(this.observer.unobserve(e),this.elementsCache.delete(t))});return}let t=this.indexFromElement(e);if(!this.isIndexInRange(t))return;let n=this.options.getItemKey(t),r=this.elementsCache.get(n);r!==e&&(r&&this.observer.unobserve(r),this.observer.observe(e),this.elementsCache.set(n,e)),(!this.isScrolling||this.scrollState)&&this.shouldMeasureDuringScroll(t)&&this.resizeItem(t,this.options.measureElement(e,void 0,this))},this.resizeItem=(e,t)=>{if(!this.isIndexInRange(e))return;let n,r,i,a=this._singleLaneMeasurements?.flat;if(this.options.lanes===1&&a!=null)i=this.options.getItemKey(e),r=a[e*2],n=a[e*2+1];else{let t=this.measurementsCache[e];if(!t)return;i=t.key,r=t.start,n=t.size}let o=this.itemSizeCache.get(i)??n,s=t-o;if(s!==0){let a=this.options.anchorTo===`end`&&this.scrollState?.behavior!==`smooth`&&this.getVirtualDistanceFromEnd()<=this.options.scrollEndThreshold,c=a?this.getTotalSize():0,l=this.getScrollOffset()+this.scrollAdjustments,u=this.itemSizeCache.has(i)?r+o<=l&&this.scrollDirection!==`backward`:r<l,d=this.scrollState?.behavior!==`smooth`&&(this.shouldAdjustScrollPositionOnItemSizeChange===void 0?u:this.shouldAdjustScrollPositionOnItemSizeChange(this.measurementsCache[e]??{index:e,key:i,start:r,size:n,end:r+n,lane:0},s,this));(this.pendingMin===null||e<this.pendingMin)&&(this.pendingMin=e),this.itemSizeCache.set(i,t),this.itemSizeCacheVersion++;let f=!1;a?f=this.applyScrollAdjustment(this.getTotalSize()-c):d&&(f=this.applyScrollAdjustment(s)),this.notify(f),this._retryClampedAdjustment()}},this.getVirtualItems=Xd(()=>[this.getVirtualIndexes(),this.getMeasurements()],(e,t)=>{let n=[];for(let r=0,i=e.length;r<i;r++){let i=t[e[r]];n.push(i)}return n},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=e=>{let t=this.getMeasurements();if(t.length===0)return;let n=this._singleLaneMeasurements?.flat,r=this.options.lanes===1&&n!=null;return Zd(t[hf(0,t.length-1,r?e=>n[e*2]:e=>Zd(t[e]).start,e)])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if(`scrollHeight`in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{let e=this.scrollElement.document.documentElement;return this.options.horizontal?e.scrollWidth-this.scrollElement.innerWidth:e.scrollHeight-this.scrollElement.innerHeight}},this.getVirtualDistanceFromEnd=()=>Math.max(this.getTotalSize()-this.getSize()-this.getScrollOffset(),0),this.getDistanceFromEnd=()=>Math.max(this.getMaxScrollOffset()-this.getScrollOffset(),0),this.isAtEnd=(e=this.options.scrollEndThreshold)=>this.getDistanceFromEnd()<=e,this.getOffsetForAlignment=(e,t,n=0)=>{if(!this.scrollElement)return 0;let r=this.getSize(),i=this.getScrollOffset();t===`auto`&&(t=e>=i+r?`end`:`start`),t===`center`?e+=(n-r)/2:t===`end`&&(e-=r);let a=this.getMaxScrollOffset();return Math.max(Math.min(a,e),0)},this.getOffsetForIndex=(e,t=`auto`)=>{e=Math.max(0,Math.min(e,this.options.count-1));let n=this.getSize(),r=this.getScrollOffset(),i=this.measurementsCache[e];if(!i)return;if(t===`auto`){if(i.end>=r+n-this.options.scrollPaddingEnd)t=`end`;else if(i.start<=r+this.options.scrollPaddingStart)t=`start`;else return[r,t]}if(t===`end`&&e===this.options.count-1)return[this.getMaxScrollOffset(),t];let a=t===`end`?i.end+this.options.scrollPaddingEnd:i.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(a,t,i.size),t]},this.scrollToOffset=(e,{align:t=`start`,behavior:n=`auto`}={})=>{this._iosDeferredAdjustment=0;let r=this.getOffsetForAlignment(e,t),i=this.now();this.scrollState={index:null,align:t,behavior:n,startedAt:i,lastTargetOffset:r,stableFrames:0},this._scrollToOffset(r,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollToIndex=(e,{align:t=`auto`,behavior:n=`auto`}={})=>{this._iosDeferredAdjustment=0,e=Math.max(0,Math.min(e,this.options.count-1));let r=this.getOffsetForIndex(e,t);if(!r)return;let[i,a]=r,o=this.now();this.scrollState={index:e,align:a,behavior:n,startedAt:o,lastTargetOffset:i,stableFrames:0},this._scrollToOffset(i,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollBy=(e,{behavior:t=`auto`}={})=>{let n=this.getScrollOffset()+e,r=this.now();this.scrollState={index:null,align:`start`,behavior:t,startedAt:r,lastTargetOffset:n,stableFrames:0},this._scrollToOffset(n,{adjustments:void 0,behavior:t}),this.scheduleScrollReconcile()},this.scrollToEnd=({behavior:e=`auto`}={})=>{this.options.count>0?this.scrollToIndex(this.options.count-1,{align:`end`,behavior:e}):this.scrollToOffset(Math.max(this.getTotalSize()-this.getSize(),0),{behavior:e})},this.getTotalSize=()=>{let e=this.getMeasurements(),t;if(e.length===0)t=this.options.paddingStart;else if(this.options.lanes===1){let n=e.length-1,r=this._singleLaneMeasurements?.flat;t=r==null?e[n]?.end??0:r[n*2]+r[n*2+1]}else{let n=Array(this.options.lanes).fill(null),r=e.length-1;for(;r>=0&&n.some(e=>e===null);){let t=e[r];n[t.lane]===null&&(n[t.lane]=t.end),r--}t=Math.max(...n.filter(e=>e!==null))}return Math.max(t-this.options.scrollMargin+this.options.paddingEnd,0)},this.takeSnapshot=()=>{let e=[];if(this.itemSizeCache.size===0)return e;let t=this.getMeasurements();for(let n of t)n&&this.itemSizeCache.has(n.key)&&e.push({index:n.index,key:n.key,start:n.start,size:n.size,end:n.end,lane:n.lane});return e},this._scrollToOffset=(e,{adjustments:t,behavior:n})=>{this._intendedScrollOffset=e+(t??0),this.options.scrollToFn(e,{behavior:n,adjustments:t},this)},this.measure=()=>{this.pendingMin=null,this.itemSizeCache.clear(),this.laneAssignments.clear(),this.itemSizeCacheVersion++,this.notify(!1)},this.setOptions(e)}applyScrollAdjustment(e,t){if(e===0)return!1;if(tf()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded))return this._iosDeferredAdjustment+=e,!1;{let n=this.getScrollOffset()+this.scrollAdjustments+e,r=this.scrollElement,i=r!==null&&(`scrollHeight`in r||`document`in r)?this.getMaxScrollOffset():null;return this._clampedAdjustment=i!==null&&n>i+.5?{target:n,maxAtWrite:i}:null,this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=e,behavior:t}),this.scrollOffset!==null&&(this.scrollOffset+=this.scrollAdjustments,this.scrollOffset<0&&(this.scrollOffset=0),this.scrollAdjustments=0),!0}}scheduleScrollReconcile(){this.targetWindow?this.rafId??=this.targetWindow.requestAnimationFrame(()=>{this.rafId=null,this.reconcileScroll()}):this.scrollState=null}reconcileScroll(){if(!this.scrollState||!this.scrollElement)return;if(this.now()-this.scrollState.startedAt>5e3){this.scrollState=null;return}let e=this.scrollState.index==null?void 0:this.getOffsetForIndex(this.scrollState.index,this.scrollState.align),t=e?e[0]:this.scrollState.lastTargetOffset,n=t!==this.scrollState.lastTargetOffset;if(!n&&Qd(t,this.getScrollOffset())){if(this.scrollState.stableFrames++,this.scrollState.stableFrames>=1){this.getScrollOffset()!==t&&this._scrollToOffset(t,{adjustments:void 0,behavior:`auto`}),this.scrollState=null;return}}else if(this.scrollState.stableFrames=0,n){let e=this.getSize()||600,n=Math.abs(t-this.getScrollOffset()),r=this.scrollState.behavior===`smooth`&&n>e;this.scrollState.lastTargetOffset=t,r||(this.scrollState.behavior=`auto`),this._scrollToOffset(t,{adjustments:void 0,behavior:r?`smooth`:`auto`})}this.scheduleScrollReconcile()}};let hf=(e,t,n,r)=>{for(;e<=t;){let i=(e+t)/2|0,a=n(i);if(a<r)e=i+1;else if(a>r)t=i-1;else return i}return e>0?e-1:0};function gf(e,t,n){let r=0;for(;r<=t;){let i=(r+t)/2|0,a=e[i*2];if(a<n)r=i+1;else if(a>n)t=i-1;else return i}return r>0?r-1:0}function _f(e,t,n,r,i){let a=e.length-1;if(e.length<=r)return{startIndex:0,endIndex:a};if(r===1&&i!==null){let e=gf(i,a,n),r=e,o=n+t;for(;r<a&&i[r*2]+i[r*2+1]<o;)r++;return{startIndex:e,endIndex:r}}let o=hf(0,a,t=>e[t].start,n),s=o;if(r===1)for(;s<a&&e[s].end<n+t;)s++;else if(r>1){let i=Array(r).fill(0);for(;s<a&&i.some(e=>e<n+t);){let t=e[s];i[t.lane]=t.end,s++}let c=Array(r).fill(n+t);for(;o>=0&&c.some(e=>e>=n);){let t=e[o];c[t.lane]=t.start,o--}o=Math.max(0,o-o%r),s=Math.min(a,s+(r-1-s%r))}return{startIndex:o,endIndex:s}}let vf=typeof document<`u`?d.useLayoutEffect:d.useEffect;function yf({useFlushSync:e=!0,directDomUpdates:t=!1,directDomUpdatesMode:n=`transform`,...r}){let i=d.useReducer(e=>e+1,0)[1],a=d.useRef({enabled:t,mode:n,container:null,lastSize:null,lastPositions:/* @__PURE__ */ new WeakMap,prevRange:null});a.current.enabled=t,a.current.mode=n;let o=d.useRef(!1),s=e=>{let t=a.current;if(!t.enabled||!t.container)return;let n=e.getTotalSize();if(n!==t.lastSize){t.lastSize=n;let r=e.options.horizontal?`width`:`height`;t.container.style[r]=`${n}px`}},c=e=>{let t=a.current;if(!t.enabled||!t.container)return;s(e);let n=!!e.options.horizontal,r=t.mode===`transform`,i=n?`left`:`top`,o=e.options.scrollMargin,c=e.getVirtualItems();for(let a of c){let s=a.start-o,c=e.elementsCache.get(a.key);c&&t.lastPositions.get(c)!==s&&(t.lastPositions.set(c,s),r?c.style.transform=n?`translate3d(${s}px, 0, 0)`:`translate3d(0, ${s}px, 0)`:c.style[i]=`${s}px`)}},l={...r,onChange:(t,n)=>{var s;let l=a.current,u=!0;if(l.enabled){c(t);let e=t.range,n=l.prevRange;u=!n||n.isScrolling!==t.isScrolling||n.startIndex!==e?.startIndex||n.endIndex!==e?.endIndex,u&&(l.prevRange=e?{startIndex:e.startIndex,endIndex:e.endIndex,isScrolling:t.isScrolling}:null)}u&&(e&&n&&!o.current?(0,h.flushSync)(i):i()),(s=r.onChange)==null||s.call(r,t,n)}},[u]=d.useState(()=>{let e=new mf(l),t=e.measureElement;return e.measureElement=e=>{o.current=!0;try{t(e)}finally{o.current=!1}},Object.assign(e,{containerRef:t=>{let n=a.current;if(n.container=t,n.lastSize=null,t&&n.enabled){let r=e.getTotalSize();n.lastSize=r;let i=e.options.horizontal?`width`:`height`;t.style[i]=`${r}px`}}})});return u.setOptions(l),vf(()=>u._didMount(),[]),vf(()=>(s(u),u._willUpdate())),vf(()=>{c(u)}),u}function bf(e){return yf({observeElementRect:of,observeElementOffset:uf,scrollToFn:ff,...e})}let xf=`@deepseek-ai/dsh-client-ui-chat/TurnNavigator.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(xf)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=xf,e.textContent=`.t5gL7q_slot{z-index:7;height:0;padding-inline:calc(var(--dsh-composer-side-clearance) + 16px);pointer-events:none;position:absolute;top:0;left:0;right:0;container-type:inline-size}[data-conversation-scroll] .t5gL7q_slot{position:sticky}.t5gL7q_frame{--turn-rail-band:calc(var(--dsh-conversation-viewport-height,100dvh) - var(--dsh-composer-height,152px));--turn-preview-height:104px;top:calc(var(--turn-rail-band) / 2);width:36px;max-height:min(max(0px, calc(var(--turn-rail-band) - 64px)), 70vh, 640px);contain:layout;cursor:pointer;pointer-events:auto;position:absolute;left:12px;transform:translateY(-50%)}.t5gL7q_frame[hidden]{display:none}.t5gL7q_scroller{max-height:inherit;overscroll-behavior:contain;scrollbar-width:none;position:relative;overflow-y:auto}.t5gL7q_scroller::-webkit-scrollbar{display:none}.t5gL7q_fadeTop{mask-image:linear-gradient(#0000 0,#000 40px 100%)}.t5gL7q_fadeBottom{mask-image:linear-gradient(#000 0 calc(100% - 40px),#0000 100%)}.t5gL7q_fadeTop.t5gL7q_fadeBottom{mask-image:linear-gradient(#0000 0,#000 40px calc(100% - 40px),#0000 100%)}.t5gL7q_marks{position:relative}.t5gL7q_mark{cursor:pointer;background:0 0;border:0;border-radius:8px;height:10px;padding:0;position:absolute;top:0;left:0;right:0}.t5gL7q_mark:before{background:var(--dsw-alias-label-tertiary);opacity:.4;content:"";transform-origin:0;width:26px;height:2px;transition:transform .16s cubic-bezier(.2,.8,.2,1),background-color .16s,opacity .16s;position:absolute;top:50%;left:0;transform:translateY(-50%)scaleX(.230769)}.t5gL7q_markUnloaded:before{opacity:.25}.t5gL7q_mark[data-neighbor-distance="3"]:before{transform:translateY(-50%)scaleX(.384615)}.t5gL7q_mark[data-neighbor-distance="2"]:before{transform:translateY(-50%)scaleX(.538462)}.t5gL7q_mark[data-neighbor-distance="1"]:before{transform:translateY(-50%)scaleX(.769231)}.t5gL7q_markBusy:before{animation:1s ease-in-out infinite t5gL7q_dsh-turn-mark-busy}.t5gL7q_markActive:before{background:var(--dsw-alias-label-primary);opacity:.6}.t5gL7q_frame[data-previewing] .t5gL7q_markActive:not(.t5gL7q_markPreview):not(:focus-visible):before{background:var(--dsw-alias-label-tertiary);opacity:.4}.t5gL7q_markPreview:before{background:var(--dsw-alias-label-primary);opacity:1;transform:translateY(-50%)scaleX(1)}.t5gL7q_frame[data-scrubbing] .t5gL7q_mark:before{transition:none}.t5gL7q_mark:focus-visible:before{background:var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary));opacity:1;transform:translateY(-50%)scaleX(1)}.t5gL7q_mark:focus-visible{outline:none}.t5gL7q_mark:focus-visible:after{border-radius:inherit;outline:1px solid var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary));outline-offset:-1px;content:"";width:28px;position:absolute;inset:0 auto 0 0}.t5gL7q_preview{top:clamp(0px, calc(var(--turn-preview-center) - var(--turn-preview-height) / 2), calc(100% - var(--turn-preview-height)));box-sizing:border-box;width:min(320px,100cqw - 48px);max-height:var(--turn-preview-height);border:.5px solid var(--dsw-alias-border-l4);color:var(--dsw-alias-label-primary);background:var(--dsw-alias-bg-layer-1);box-shadow:var(--dsw-elevation-panel);pointer-events:none;border-radius:12px;padding:8px;transition:top .14s cubic-bezier(.2,.8,.2,1);animation:.12s ease-out t5gL7q_dsh-turn-preview-enter;position:absolute;left:100%;overflow:hidden}.t5gL7q_previewPrompt,.t5gL7q_previewResponse{-webkit-box-orient:vertical;display:-webkit-box;overflow:hidden}.t5gL7q_previewPrompt{-webkit-line-clamp:1;font-size:14px;font-weight:500;line-height:20px}.t5gL7q_previewResponse{color:var(--dsw-alias-label-caption);-webkit-line-clamp:3;margin-top:4px;font-size:14px;line-height:20px}@keyframes t5gL7q_dsh-turn-preview-enter{0%{opacity:0;transform:translate(-4px)}to{opacity:1;transform:translate(0)}}@keyframes t5gL7q_dsh-turn-mark-busy{0%,to{opacity:1}50%{opacity:.35}}@media (prefers-reduced-motion:reduce){.t5gL7q_frame,.t5gL7q_scroller,.t5gL7q_mark:before,.t5gL7q_markBusy:before,.t5gL7q_preview{scroll-behavior:auto;transition:none;animation:none}}`,document.head.appendChild(e)}var Sf={"dsh-turn-mark-busy":`t5gL7q_dsh-turn-mark-busy`,"dsh-turn-preview-enter":`t5gL7q_dsh-turn-preview-enter`,fadeBottom:`t5gL7q_fadeBottom`,fadeTop:`t5gL7q_fadeTop`,frame:`t5gL7q_frame`,mark:`t5gL7q_mark`,markActive:`t5gL7q_markActive`,markBusy:`t5gL7q_markBusy`,markPreview:`t5gL7q_markPreview`,markUnloaded:`t5gL7q_markUnloaded`,marks:`t5gL7q_marks`,preview:`t5gL7q_preview`,previewPrompt:`t5gL7q_previewPrompt`,previewResponse:`t5gL7q_previewResponse`,scroller:`t5gL7q_scroller`,slot:`t5gL7q_slot`};function Cf(){return typeof matchMedia==`function`&&matchMedia(`(prefers-reduced-motion: reduce)`).matches?`auto`:`smooth`}let wf=(0,d.memo)(function({item:e,index:t,active:n,busy:r,previewId:i,neighborDistance:a,registerElement:o,onNavigate:s,onPreview:c,onFocusChange:l,t:u}){let d=[Sf.mark];return e.anchor.kind===`unloaded`&&d.push(Sf.markUnloaded),n&&d.push(Sf.markActive),a===0&&d.push(Sf.markPreview),r&&d.push(Sf.markBusy),/* @__PURE__ */ (0,f.jsx)(`button`,{ref:o,"data-index":t,"data-neighbor-distance":a,type:`button`,className:d.join(` `),"aria-label":u(e.anchor.kind===`loaded`?`chat.turnNavigation.jump`:`chat.turnNavigation.jumpLoad`,{turn:t+1}),"aria-current":n?`true`:void 0,"aria-busy":r?`true`:void 0,"aria-describedby":i,onPointerMove:t=>{t.buttons===0&&c(e.turn)},onClick:()=>{s(e)},onFocus:()=>{l(e.turn)},onBlur:()=>{l(null)}})});function Tf({items:e,activeTurn:t,busyTurn:n,onNavigate:r,t:i},a){let[o,s]=(0,d.useState)(null),[c,l]=(0,d.useState)(null),[u,p]=(0,d.useState)(!1),[m,h]=(0,d.useState)(!1),[g,_]=(0,d.useState)(!1),v=(0,d.useRef)(null),y=(0,d.useRef)(null),b=(0,d.useRef)(!1),x=(0,d.useRef)(void 0),ee=(0,d.useRef)(null),S=(0,d.useRef)({placed:!1,index:0,follow:null,publishOffset:null}),C=(0,d.useRef)(!1),te=(0,d.useId)(),w=e.length>=2;(0,d.useLayoutEffect)(()=>{let e=v.current,t=e?.parentElement?.querySelector(`[data-chat-flow]`),n=e?.closest(`[data-conversation-scroll]`)??e?.parentElement;if(!t||!n)return;let r=()=>{let e=n.getBoundingClientRect(),r=n.offsetWidth>0?e.width/n.offsetWidth:1;h((t.getBoundingClientRect().left-e.left)/(r||1)>=48)},i=new ResizeObserver(r);return i.observe(t),i.observe(n),r(),()=>i.disconnect()},[w]),(0,d.useEffect)(()=>{if(o===null){p(!1);return}if(u)return;let e=setTimeout(()=>p(!0),150);return()=>clearTimeout(e)},[o,u]),(0,d.useEffect)(()=>()=>{clearTimeout(x.current);let e=y.current;y.current=null,e?.button.hasPointerCapture(e.pointerId)&&e.button.releasePointerCapture(e.pointerId)},[]);let T=(0,d.useMemo)(()=>{let t=/* @__PURE__ */ new Map;return e.forEach((e,n)=>{t.set(e.turn,n)}),t},[e]),ne=t===null?void 0:T.get(t);(0,d.useLayoutEffect)(()=>{S.current.index=ne??0},[ne]);let re=c===null?void 0:T.get(c),E=o===null?void 0:T.get(o),ie=(0,d.useCallback)(e=>{l(e),s(e),p(e!==null)},[]),D=bf({count:e.length,enabled:w,directDomUpdates:!0,directDomUpdatesMode:`transform`,useScrollendEvent:!0,getScrollElement:(0,d.useCallback)(()=>ee.current,[]),getItemKey:(0,d.useCallback)(t=>e[t]?.turn??t,[e]),estimateSize:()=>10,measureElement:()=>10,initialRect:{width:0,height:0},initialOffset:0,scrollToFn:(e,t,n)=>{S.current.placed&&ff(e,t,n)},observeElementOffset:(e,t)=>{S.current.publishOffset=t;let n=uf(e,t);return()=>{n?.(),S.current.placed=!1,S.current.follow=null,S.current.publishOffset=null}},observeElementRect:(e,t)=>{let n=e.scrollElement,r=e.targetWindow?.ResizeObserver;if(n===null||r===void 0)return;let i=new r(([r])=>{if(r===void 0)return;let i=r.borderBoxSize[0],a={width:Math.round(i?.inlineSize??r.contentRect.width),height:Math.round(i?.blockSize??r.contentRect.height)},o=S.current;if(!o.placed&&a.height>0){let t=Math.max(0,e.getTotalSize()-a.height),r=o.index*10+6,i=Math.max(0,Math.min(t,r-a.height/2));o.placed=!0,o.follow={index:o.index,count:e.options.count,height:a.height},n.scrollTop=i,o.publishOffset?.(i,!1)}t(a)});return i.observe(n,{box:`border-box`}),()=>{i.disconnect()}},paddingStart:1,paddingEnd:1,scrollPaddingStart:40,scrollPaddingEnd:40,overscan:3,rangeExtractor:(0,d.useCallback)(e=>{let t=af(e);if(re!==void 0){let n=Math.min(e.count-1,re+1);for(let e=Math.max(0,re-1);e<=n;e++)t.includes(e)||t.push(e);t.sort((e,t)=>e-t)}return t},[re])}),ae=D.scrollOffset??0,oe=D.scrollRect?.height??0,se=D.getVirtualItems(),O=(0,d.useCallback)((e,t,n=Cf())=>{let r=D.measurementsCache[e],i=D.scrollRect?.height??0;if(r===void 0||i<=0)return;let a=D.scrollOffset??0,o=r.start+r.size/2;if(t===`if-needed`){let{scrollPaddingStart:e,scrollPaddingEnd:t}=D.options;if(o>=a+e&&o<=a+i-t)return}let s=o-i/2,c=Math.max(0,D.getTotalSize()-i),l=Math.max(0,Math.min(c,s))-a;l!==0&&D.scrollBy(l,{behavior:n})},[D]);(0,d.useImperativeHandle)(a,()=>({activateTurn(t){let n=T.get(t),i=n===void 0?void 0:e[n];i!==void 0&&r(i)},scrollToTurn(e){let t=T.get(e);t!==void 0&&O(t,`always`)}}),[e,T,r,O]),(0,d.useEffect)(()=>{if(oe<=0){S.current.follow=null;return}if(ne===void 0||C.current)return;let t=S.current.follow;if(t?.index===ne&&t.count===e.length&&t.height===oe)return;S.current.follow={index:ne,count:e.length,height:oe};let n=t?.count===e.length&&t.height===oe?Cf():`instant`;O(ne,`if-needed`,n)},[ne,e.length,oe,O]);let ce=(0,d.useCallback)(e=>{b.current?b.current=!1:r(e)},[r]),le=t=>{if(t.button!==0||!(t.target instanceof Element))return;let n=t.target.closest(`button[data-index]`);if(!n||!ee.current?.contains(n))return;let r=e[Number(n.dataset.index)];r&&(clearTimeout(x.current),b.current=!1,y.current={pointerId:t.pointerId,button:n,turn:r.turn,moved:!1},n.setPointerCapture(t.pointerId),_(!0),s(r.turn),p(!0))},ue=t=>{let n=y.current,i=ee.current;if(!n||!i||t.pointerId!==n.pointerId||!(t.buttons&1))return;let a=i.getBoundingClientRect(),o=Math.max(a.top,Math.min(t.clientY,a.bottom-1)),c=e[Math.max(0,Math.min(e.length-1,Math.round((o-a.top+i.scrollTop-6)/10)))];c&&c.turn!==n.turn&&(n.turn=c.turn,n.moved=!0,s(c.turn),c.anchor.kind===`loaded`&&r(c))},de=e=>{let t=y.current;t&&e.pointerId===t.pointerId&&(y.current=null,_(!1),b.current=t.moved,t.button.hasPointerCapture(e.pointerId)&&t.button.releasePointerCapture(e.pointerId),x.current=setTimeout(()=>{b.current=!1},0),C.current||s(null))};if(!w)return null;let fe=!u||E===void 0?void 0:e[E],pe=se.find(e=>e.index===E),me=[Sf.scroller];return ae>1&&me.push(Sf.fadeTop),ae<D.getTotalSize()-oe-1&&me.push(Sf.fadeBottom),/* @__PURE__ */ (0,f.jsx)(`div`,{ref:v,className:Sf.slot,children:/* @__PURE__ */ (0,f.jsxs)(`nav`,{className:Sf.frame,hidden:!m,"data-turn-navigation":``,"data-previewing":E!==void 0||void 0,"data-scrubbing":g||void 0,onPointerDownCapture:le,onPointerMove:ue,onPointerUpCapture:de,onPointerCancelCapture:de,onLostPointerCapture:de,"aria-label":i(`chat.turnNavigation.label`),onPointerEnter:()=>{C.current=!0},onPointerLeave:()=>{C.current=!1,y.current||s(null)},children:[/* @__PURE__ */ (0,f.jsx)(`div`,{ref:ee,className:me.join(` `),children:/* @__PURE__ */ (0,f.jsx)(`div`,{ref:D.containerRef,className:Sf.marks,children:se.map(({index:r,key:a})=>{let c=e[r];return c===void 0?null:/* @__PURE__ */ (0,f.jsx)(wf,{item:c,index:r,active:c.turn===t,busy:c.turn===n,previewId:u&&c.turn===o?te:void 0,neighborDistance:E!==void 0&&Math.abs(r-E)<=3?Math.abs(r-E):void 0,registerElement:D.measureElement,onNavigate:ce,onPreview:s,onFocusChange:ie,t:i},a)})})}),fe!==void 0&&pe!==void 0&&/* @__PURE__ */ (0,f.jsxs)(`div`,{id:te,role:`tooltip`,className:Sf.preview,style:{"--turn-preview-center":`${String(pe.start+pe.size/2-ae)}px`},children:[/* @__PURE__ */ (0,f.jsx)(`div`,{className:Sf.previewPrompt,children:fe.prompt||i(`chat.turnNavigation.turn`,{turn:(E??0)+1})}),fe.response!==``&&/* @__PURE__ */ (0,f.jsx)(`div`,{className:Sf.previewResponse,children:fe.response})]})]})})}let Ef=(0,d.memo)((0,d.forwardRef)(Tf));function Df(){return/* @__PURE__ */ (0,f.jsx)(`span`,{className:Y.runningIcon,"aria-hidden":`true`,children:/* @__PURE__ */ (0,f.jsx)(`span`,{className:Y.runningIconMotion,children:/* @__PURE__ */ (0,f.jsxs)(`svg`,{width:`100%`,height:`100%`,viewBox:`2 2 20 20`,fill:`none`,stroke:`currentColor`,strokeWidth:1.2,strokeLinecap:`round`,strokeLinejoin:`round`,children:[/* @__PURE__ */ (0,f.jsx)(`path`,{d:`M16.1 5.3C11.8 2.9 6.6 5 5.1 9.4c-1.8 5.4 1.7 10.2 6.9 10.3 4.8.2 8-3.8 7.2-8.3-.4 3.2-2 5.1-4.2 5.8`}),/* @__PURE__ */ (0,f.jsx)(`rect`,{x:`9.5`,y:`9.1`,width:`4.6`,height:`4.6`,rx:`1`,transform:`rotate(-10 11.8 11.4)`})]})})})}let Of=`@deepseek-ai/dsh-client-ui-chat/accessibility.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(Of)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=Of,e.textContent=`.Tawwdq_visuallyHidden{clip:rect(0 0 0 0);white-space:nowrap;width:1px;height:1px;position:absolute;overflow:hidden}`,document.head.appendChild(e)}var kf={visuallyHidden:`Tawwdq_visuallyHidden`};let Af=(0,d.memo)(function({startTime:e,compacting:t,stale:n,t:r}){let[i,a]=(0,d.useState)(Date.now);(0,d.useEffect)(()=>{if(e===void 0||t||n)return;a(Date.now());let r=setInterval(()=>{a(Date.now())},1e3);return()=>{clearInterval(r)}},[e,t,n]);let o=n?r(`chat.statusUnconfirmed`):t?r(`message.compaction.running`):e===void 0?r(`chat.deepDiving`):r(`chat.deepDivingFor`,{duration:Lu(Math.max(1e3,i-e),r).map(e=>e.text).join(``)});return/* @__PURE__ */ (0,f.jsxs)(`div`,{className:Y.running,"data-chat-running":!0,children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:kf.visuallyHidden,role:`status`,"aria-live":`polite`,"aria-atomic":`true`,children:r(n?`chat.statusUnconfirmed`:t?`message.compaction.running`:`chat.deepDiving`)}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:Y.runningDivider,"aria-hidden":`true`}),/* @__PURE__ */ (0,f.jsxs)(`span`,{className:Y.runningContent,children:[n?null:/* @__PURE__ */ (0,f.jsx)(Df,{}),/* @__PURE__ */ (0,f.jsx)(p.TextShimmer,{active:!n,className:Y.runningText,children:o})]})]})});function jf(e){return e}function Mf(e){return e}function Nf(e){if(!Number.isSafeInteger(e)||e<0||Object.is(e,-0))throw TypeError(`SessionSeq must be a non-negative safe integer, got ${String(e)}`);return Mf(e)}let Pf=[];function Ff(e){if(typeof e!=`object`||!e)return;let t=e;if(!(typeof t.turn!=`number`||!Number.isSafeInteger(t.turn)||t.turn<0)&&!(typeof t.seq!=`number`||!Number.isSafeInteger(t.seq)||t.seq<0||Object.is(t.seq,-0)))return{turn:t.turn,seq:Nf(t.seq),prompt:typeof t.prompt==`string`?t.prompt:``,response:typeof t.response==`string`?t.response:``}}function If(e){return Array.isArray(e)?e:Pf}function Lf(e,t){let n=/* @__PURE__ */ new Map;for(let e of If(t)){let t=Ff(e);t!==void 0&&n.set(t.turn,{turn:t.turn,prompt:t.prompt,response:t.response,anchor:{kind:`unloaded`,seq:t.seq}})}for(let t of e){let e=n.get(t.turn);n.set(t.turn,{turn:t.turn,prompt:t.prompt===``?e?.prompt??``:t.prompt,response:t.response===``?e?.response??``:t.response,anchor:{kind:`loaded`,key:t.anchorKey}})}return n.size===0?Pf:[...n.values()].sort((e,t)=>e.turn-t.turn)}var Rf=class{viewport;reading;input;onBusyTurn;jump=null;settleFrame=null;requestedHead;constructor(e,t,n,r){this.viewport=e,this.reading=t,this.input=n,this.onBusyTurn=r}setInput(e){this.input=e}reset(){this.requestedHead=void 0,this.cancel()}dispose(){this.clearTask()}cancel(){this.clearTask(),this.onBusyTurn(null)}clearTask(){this.cancelFrame(),this.jump=null,this.viewport.stopPreserving()}navigateToTurn=e=>{if(e.anchor.kind===`loaded`){this.cancel();let t=this.viewport.scrollToTurn(e.turn);if(t===null)return;this.reading.acceptNavigation(t),this.input.loadingOlder&&this.viewport.beginPreserving(t.position);return}if(!this.input.historyReady)return;this.cancel(),this.viewport.beginPreserving(),this.reading.pauseFollowing();let t={turn:e.turn,seq:e.anchor.seq,phase:`loading`,landing:`pending`,repageHead:null};this.jump=t,this.onBusyTurn(t.turn),this.request(t)};autoLoadEarlier=()=>{if(this.jump!==null||this.input.olderFailed||this.requestedHead===this.input.firstSeq)return;let e=this.viewport.readScroll();e===null||e.metrics.top>240||this.loadEarlier()};loadEarlier=()=>{this.input.historyReady&&this.input.hasMore&&!this.input.loadingOlder&&(this.requestedHead=this.input.firstSeq,this.cancel(),this.viewport.beginPaging(),this.reading.pauseFollowing(),this.input.loadOlder())};readerSampled(e){e.movedByReader&&this.jump?.landing===`landed`&&(this.jump.landing=`interrupted`),(e.followingTail||e.movedByReader)&&this.viewport.stopPreserving()}contentCommitted(){if(!this.viewport.preserving||this.reading.pending)return!1;if(this.landJump(!1))return!0;let e=this.viewport.preserve();return e!==null&&(this.reading.preservePosition(e),!0)}readerSettled(){this.input.loadingOlder&&this.jump===null&&!this.viewport.preserving&&!this.reading.followingTail&&this.viewport.beginPreserving()}reconcile(){let e=this.jump;if(!this.input.historyReady||e===null||this.reading.pending)return;if(e.phase===`loading`){e.landing===`pending`&&this.landJump(!1);return}if(this.input.loadingOlder||this.landJump(!0))return;if((this.input.firstSeq===null||this.input.firstSeq>e.seq)&&this.input.hasMore&&e.repageHead!==this.input.firstSeq){e.repageHead=this.input.firstSeq,this.viewport.beginPreserving(),this.request(e);return}let t=this.viewport.scrollToTurnAtOrAfter(e.turn);this.cancel(),t!==null&&this.reading.acceptNavigation(t)}landJump(e){let t=this.jump;if(t===null)return!1;if(t.landing===`interrupted`)return e?(this.cancel(),!0):!1;let n=this.viewport.scrollToTurn(t.turn);return n!==null&&(this.reading.acceptNavigation(n),e?this.cancel():(this.viewport.beginPreserving(n.position),t.landing=`landed`),!0)}request(e){e.phase=`loading`;let t=()=>{this.jump===e&&(e.phase=`settled`,this.cancelFrame(),typeof requestAnimationFrame==`function`?this.settleFrame=requestAnimationFrame(()=>{this.settleFrame=null,this.jump===e&&this.reconcile()}):this.reconcile())};this.input.loadThrough(e.seq).then(t,t)}cancelFrame(){this.settleFrame!==null&&typeof cancelAnimationFrame==`function`&&cancelAnimationFrame(this.settleFrame),this.settleFrame=null}};function zf(e,t,n){let[r,i]=(0,d.useState)(null),[a]=(0,d.useState)(()=>new Rf(e,t,n,i));return(0,d.useLayoutEffect)(()=>{a.setInput(n)},[a,n]),(0,d.useLayoutEffect)(()=>()=>{a.dispose()},[a]),{navigation:a,busyTurn:r}}var Bf=class{viewport;store;state;onChange;follow;sampleTimer=null;probeFrame=null;sampled=null;constructor(e,t,n,r,i){this.viewport=e,this.store=t,this.state=n,this.onChange=r,this.follow=i}get pending(){return this.sampleTimer!==null}get followingTail(){return this.state.followingTail}setStore(e){this.store=e}connect(e){return this.sampled=e,()=>{this.sampled===e&&(this.sampled=null)}}dispose(){this.cancelPending(),this.sampled=null}pauseFollowing(){this.cancelPending(),this.publish({...this.state,followingTail:!1})}followTail(){let e=this.viewport.scrollToBottom(this.follow);e!==null&&(this.cancelPending(),this.commit(e,!0,this.viewport.latestTurn))}restore(){let e=this.store.read();if(e===null){this.followTail();return}let t=this.viewport.restore(e);if(t===null)return;this.cancelPending();let n=this.follow.nearBottom(t.metrics);if(this.commit(t,n,n?this.viewport.latestTurn:this.state.activeTurn,n),!this.state.followingTail&&t.position===null){let e=this.viewport.capturePosition();e!==null&&this.store.save(e)}this.refreshActiveTurn()}acceptNavigation(e){this.cancelPending();let t=this.follow.nearBottom(e.metrics);this.commit(e,t,e.turn??(t?this.viewport.latestTurn:this.state.activeTurn))}preservePosition(e){this.cancelPending(),this.commit(e,this.state.followingTail,this.state.activeTurn)}onScroll=e=>{!e.movedByReader&&this.state.followingTail||e.movedByReader&&e.metrics.top>=e.metrics.floor?(this.followTail(),this.sampled?.({position:null,movedByReader:e.movedByReader,followingTail:!0})):this.sampleTimer??=window.setTimeout(this.flushSample,500)};onScrollEnd=()=>{this.flushSample()};onResize(){this.pending||(this.state.followingTail?this.followTail():this.refreshActiveTurn())}refreshActiveTurn(){this.pending||(this.state.followingTail?this.publish({...this.state,initialized:!0,activeTurn:this.viewport.latestTurn}):this.probeFrame===null&&(typeof requestAnimationFrame==`function`?this.probeFrame=requestAnimationFrame(this.probe):this.probe()))}commit(e,t,n,r=!0){t?this.store.save(null):e.position!==null&&this.store.save(e.position),this.publish({initialized:r,followingTail:t,activeTurn:n})}publish(e){this.follow.setFollowing(e.followingTail),(e.initialized!==this.state.initialized||e.followingTail!==this.state.followingTail||e.activeTurn!==this.state.activeTurn)&&(this.state=e,this.onChange(e))}cancelPending(){this.sampleTimer!==null&&window.clearTimeout(this.sampleTimer),this.probeFrame!==null&&typeof cancelAnimationFrame==`function`&&cancelAnimationFrame(this.probeFrame),this.sampleTimer=null,this.probeFrame=null}probe=()=>{if(this.probeFrame=null,this.pending)return;let e=this.viewport.readScroll();if(e===null)return;let t=this.follow.nearBottom(e.metrics)?this.viewport.latestTurn:this.viewport.readVisibleTurn(e.metrics);this.publish({...this.state,initialized:!0,activeTurn:t})};flushSample=()=>{if(!this.pending)return;this.cancelPending();let e=this.viewport.readScroll();if(e===null)return;let t=this.follow.sample(e.metrics,e.movedByReader),n=null;if(!e.movedByReader&&t)this.followTail();else{n=t?null:this.viewport.capturePosition(),this.viewport.acknowledge(e.metrics),(t||n!==null)&&this.store.save(n);let r=this.follow.nearBottom(e.metrics)?this.viewport.latestTurn:this.viewport.readVisibleTurn(e.metrics);this.publish({initialized:!0,followingTail:t,activeTurn:r})}this.sampled?.({position:n,movedByReader:e.movedByReader,followingTail:t})}};function Vf(e,t,n){let[r,i]=(0,d.useState)(()=>({initialized:!1,followingTail:t.read()===null,activeTurn:n})),a=Id(r.followingTail,25),[o]=(0,d.useState)(()=>new Bf(e,t,r,i,a));return(0,d.useLayoutEffect)(()=>{o.setStore(t)},[o,t]),(0,d.useLayoutEffect)(()=>()=>{o.dispose()},[o]),{reading:o,state:r}}let Hf=[`wheel`,`touchstart`,`touchmove`,`touchend`,`touchcancel`,`pointerdown`,`keydown`,`beforematch`],Uf=/* @__PURE__ */ new Set([`ArrowUp`,`ArrowDown`,`PageUp`,`PageDown`,`Home`,`End`,` `]);var Wf=class{elements=null;observer=null;events=null;turns=[];observation={top:0,landing:null};paging=null;touchY=null;attach(e,t){this.detach();let n=e.closest(`[data-conversation-scroll]`)??e,r=n.querySelector(`[data-composer-seat]`),i={list:e,column:t,scroller:n,composer:r};this.elements=i,n.addEventListener(`scroll`,this.onScroll,{passive:!0}),n.addEventListener(`scrollend`,this.onScrollEnd,{passive:!0,capture:!0});for(let e of Hf)n.addEventListener(e,this.onIntent,{passive:!0,capture:!0});typeof ResizeObserver<`u`&&(this.observer=new ResizeObserver(()=>{this.elements===i&&(this.invalidate(),this.events?.resize())}),this.observer.observe(t),this.observer.observe(n),r!==null&&this.observer.observe(r))}detach(){this.stopPreserving(),this.elements?.scroller.removeEventListener(`scroll`,this.onScroll),this.elements?.scroller.removeEventListener(`scrollend`,this.onScrollEnd,!0);for(let e of Hf)this.elements?.scroller.removeEventListener(e,this.onIntent,!0);this.observer?.disconnect(),this.observer=null,this.elements=null,this.events=null,this.turns=[],this.touchY=null,this.observation={top:0,landing:null}}connect(e){return this.events=e,()=>{this.events===e&&(this.events=null)}}updateTurns(e){this.turns=e}get latestTurn(){return this.turns.at(-1)?.turn??null}invalidate(){this.observation.landing=null}acknowledge(e){this.observation={top:e.top,landing:null}}readScroll(){let e=this.metrics();return e===null?null:{metrics:e,movedByReader:Math.abs(e.top-Math.min(this.observation.top,e.floor))>.5,towardStart:e.top<Math.min(this.observation.top,e.floor)-.5}}metrics(){let e=this.elements?.scroller;return e===void 0?null:Pd(e)}anchor(e,t=`position`){if(this.elements===null)return null;let n=null;for(let r of this.elements.list.querySelectorAll(`[data-chat-anchor-key]:not([hidden]):not([hidden] *)`)){if(r.dataset.chatAnchorKey===e||t===`node`&&r.dataset.chatNodeKey===e)return r;n===null&&r.dataset.chatNodeKey===e&&(n=r)}return n}capturePosition(){let e=this.elements;if(e===null)return null;let{list:t,scroller:n,composer:r}=e,i=n.getBoundingClientRect(),a=r?.getBoundingClientRect().top??i.bottom,o=null;if(typeof document.elementsFromPoint==`function`&&a>i.top){let e=t.getBoundingClientRect(),n=Math.max(i.left,e.left),r=Math.min(i.right,e.right);for(let e of document.elementsFromPoint(n+Math.max(0,r-n)/2,i.top+1)){let n=e instanceof HTMLElement?e.closest(`[data-chat-anchor-key]`):null;if(n!==null&&n.dataset.chatFlowKind!==`turn-process`&&t.contains(n)){o=n.dataset.chatGroupKey===void 0?n:n.querySelector(`[data-step-process-content] > [data-chat-anchor-key]:not(:empty):not([hidden]):not([hidden] *)`)??n;break}}}if(o===null){let e=t.querySelectorAll(`[data-chat-flow-key]:not([data-chat-group-key]):not([data-chat-flow-kind="turn-process"]):not(:empty):not([hidden]):not([hidden] *)`),n=0,r=e.length;for(;n<r;){let t=n+r>>>1;e.item(t).getBoundingClientRect().bottom>i.top?r=t:n=t+1}let s=e[n];o=s!==void 0&&s.getBoundingClientRect().top<a?s:e[0]??null}let s=o?.dataset.chatAnchorKey;return o===null||s===void 0?null:{anchorKey:s,anchorTop:o.getBoundingClientRect().top-i.top,scrollTop:n.scrollTop}}readVisibleTurn(e=this.metrics()){let t=this.observation.landing?.turn;if(t!=null&&e?.top===this.observation.top)return t;let n=this.elements,r=this.turns[0];if(n===null||e===null||r===void 0)return null;let i=n.scroller.getBoundingClientRect().top+Math.min(96,e.height*.2),a=n.column.children,o=0,s=a.length,c=r.turn;for(;o<s;){let e=o+s>>>1,t=a[e];if(t.getBoundingClientRect().top>i)s=e;else{let n=t.getAttribute(`data-chat-turn`),r=n===null?NaN:Number(n);Number.isSafeInteger(r)&&(c=r),o=e+1}}return c}scrollToTurn(e){let t=this.turns.find(t=>t.turn===e);if(t===void 0)return null;let n=this.anchor(t.anchorKey,`node`);return n===null?null:this.align(n,24,e)}scrollToTurnAtOrAfter(e){if(this.elements===null)return null;for(let t of this.elements.list.querySelectorAll(`[data-chat-turn]:not([hidden]):not([hidden] *)`)){let n=Number(t.dataset.chatTurn);if(Number.isSafeInteger(n)&&n>=e)return this.align(t,24,n)}return null}restore(e){let t=this.anchor(e.anchorKey);if(t!==null)return this.align(t,e.anchorTop,null);let n=this.metrics();return n===null?null:this.write(e.scrollTop,n,null)}beginPaging(){this.stopPreserving();let e=this.elements?.list.querySelector(`[data-chat-paging-anchor]:not(:empty):not([hidden]):not([hidden] *)`);e!=null&&this.retain(e)}beginPreserving(e=this.capturePosition()){if(this.stopPreserving(),e===null)return;let t=this.anchor(e.anchorKey);t!==null&&this.retain(t,e)}retain(e,t,n){let r=this.elements,i=e.dataset.chatAnchorKey;if(r===null||i===void 0)return null;let a=this.paging?.group;a!=null&&this.observer?.unobserve(a.content);let o=e.getBoundingClientRect().top,s=e.closest(`[data-step-process-body]`),c=s?.querySelector(`[data-step-process-content]`),l=s===null||c==null?null:{body:s,content:c,top:n??o-s.getBoundingClientRect().top};return this.paging={row:e,group:l,position:t??{anchorKey:i,anchorTop:o-r.scroller.getBoundingClientRect().top,scrollTop:r.scroller.scrollTop}},l!==null&&this.observer?.observe(l.content),this.paging}stopPreserving(){let e=this.paging?.group;e!=null&&this.observer?.unobserve(e.content),this.paging=null}get preserving(){return this.paging!==null}preserve(){let e=this.paging,t=this.elements;if(e===null||t===null)return null;if(!t.list.contains(e.row)){let t=this.anchor(e.position.anchorKey);if(t===null)return this.stopPreserving(),null;if(e=this.retain(t,e.position,e.group?.top),e===null)return null}let{row:n,group:r,position:i}=e;if(n.closest(`[hidden]`)!==null||n.matches(`:empty`))return this.stopPreserving(),null;if(r!==null&&r.body.contains(n)){let e=n.getBoundingClientRect().top-r.body.getBoundingClientRect().top,t=Pd(r.body),i=Math.max(0,Math.min(t.floor,t.top+e-r.top));if(t.top!==i){let e=Fd.forElement(r.body);e===void 0?r.body.scrollTop=i:(e.jump(r.body,t,i),e.setFollowing(!1))}}let a=this.metrics();if(a===null)return null;let o=n.getBoundingClientRect().top-t.scroller.getBoundingClientRect().top,s=a.top+o-i.anchorTop;return this.write(s,a,null,{key:i.anchorKey,top:o})}scrollToBottom(e){let t=this.metrics();if(t===null||this.elements===null)return null;let n={metrics:t.top>t.floor?t:e.toBottom(this.elements.scroller,t,`instant`),position:null,turn:this.latestTurn};return this.observation={top:n.metrics.top,landing:n},n}align(e,t,n){let r=this.metrics();if(r===null||this.elements===null)return null;let i=e.getBoundingClientRect().top-this.elements.scroller.getBoundingClientRect().top;return this.write(r.top+i-t,r,n,{key:e.dataset.chatAnchorKey,top:i})}write(e,t,n,r){if(this.elements===null)return null;let i=Math.max(0,Math.min(t.floor,e));i!==t.top&&(this.elements.scroller.scrollTop=i);let a=this.elements.scroller.scrollTop,o={metrics:{...t,top:a},turn:n,position:r?.key===void 0?null:{anchorKey:r.key,anchorTop:r.top-(a-t.top),scrollTop:a}};return this.observation={top:a,landing:o},o}onScroll=e=>{if(this.elements===null||e.target!==this.elements.scroller||this.observation.landing!==null&&this.elements.scroller.scrollTop===this.observation.top)return;this.invalidate();let t=this.readScroll();t!==null&&this.events?.scroll(t)};onScrollEnd=e=>{(e.target===this.elements?.scroller||e.target instanceof HTMLElement&&e.target.hasAttribute(`data-step-process-body`))&&this.events?.scrollEnd()};onIntent=e=>{if(e.type===`touchend`||e.type===`touchcancel`){this.touchY=null;return}if(e.target instanceof Element&&e.target.closest(`[data-composer-seat], [data-turn-navigation], input, textarea, [contenteditable="true"]`)||e.type===`keydown`&&(!(e instanceof KeyboardEvent)||!Uf.has(e.key)))return;let t=e instanceof WheelEvent?e.deltaY<0:e instanceof KeyboardEvent&&([`ArrowUp`,`PageUp`,`Home`].includes(e.key)||e.key===` `&&e.shiftKey);if(typeof TouchEvent<`u`&&e instanceof TouchEvent){let n=e.touches[0]?.clientY;if(t=e.type===`touchmove`&&n!==void 0&&this.touchY!==null&&n>this.touchY,this.touchY=n??null,e.type===`touchstart`)return}if(!(e instanceof PointerEvent&&e.pointerType===`touch`)){if(t&&e.target instanceof Element){for(let n=e.target;n&&n!==this.elements?.scroller;n=n.parentElement)if(n instanceof HTMLElement&&n.scrollTop>0&&n.scrollHeight>n.clientHeight&&/auto|scroll/.test(getComputedStyle(n).overflowY)){t=!1;break}}this.paging!==null&&!(t&&this.observation.top<=0&&(this.elements?.scroller.scrollTop??0)<=0)&&(this.stopPreserving(),this.events?.interact()),t&&this.events?.olderIntent()}}};function Gf(){let e=(0,d.useRef)(null),t=(0,d.useRef)(null),[n]=(0,d.useState)(()=>new Wf);return(0,d.useLayoutEffect)(()=>{if(e.current!==null&&t.current!==null)return n.attach(e.current,t.current),()=>{n.detach()}},[n]),{viewport:n,listRef:e,columnRef:t}}function Kf(e){let{displayReady:t,historyReady:n,order:r,firstSeq:i,lastKey:a,lastIsUser:o,steeringId:s,submissionId:c,running:l,loadedTurns:u,chatScroll:f,hasMore:p,loadingOlder:m,olderFailed:h,loadOlder:g,loadThrough:_}=e,{viewport:v,listRef:y,columnRef:b}=Gf(),{reading:x,state:ee}=Vf(v,f,u.at(-1)?.turn??null),S=(0,d.useMemo)(()=>({historyReady:n,firstSeq:i,loadingOlder:m,olderFailed:h,hasMore:p,loadOlder:g,loadThrough:_}),[n,i,m,h,p,g,_]),{navigation:C,busyTurn:te}=zf(v,x,S),w=(0,d.useRef)({input:e,applied:null,opened:!1}),T=(0,d.useCallback)(()=>{let e=w.current.input,t=w.current.applied,n=e.lastIsUser&&e.lastKey!==t?.lastKey||e.steeringId!==null&&e.steeringId!==t?.steeringId&&e.steeringId!==t?.submissionId||e.submissionId!==null&&e.submissionId!==t?.submissionId&&e.submissionId!==t?.steeringId;(!x.pending||n)&&(w.current.applied=e,e.displayReady&&!w.current.opened?(w.current.opened=!0,C.reset(),x.restore()):n?(C.cancel(),x.followTail()):C.contentCommitted()?C.reconcile():(t===null||e.displayReady!==t.displayReady||e.firstSeq!==t.firstSeq||e.lastKey!==t.lastKey||e.order.length!==t.order.length||e.running!==t.running||e.steeringId!==t.steeringId||e.submissionId!==t.submissionId)&&x.followingTail?(C.cancel(),x.followTail()):C.reconcile())},[x,C]);(0,d.useLayoutEffect)(()=>{let e=null,t=()=>{e===null&&w.current.opened&&w.current.input.historyReady&&(e=requestAnimationFrame(()=>{e=null,w.current.opened&&w.current.input.historyReady&&C.autoLoadEarlier()}))},n=v.connect({scroll:e=>{x.onScroll(e),e.movedByReader&&e.towardStart&&t()},olderIntent:t,scrollEnd:()=>{x.onScrollEnd(),C.readerSettled()},interact:()=>{C.cancel()},resize:()=>{C.contentCommitted()||x.onResize(),C.reconcile()}}),r=x.connect(e=>{C.readerSampled(e),T()});return()=>{e!==null&&cancelAnimationFrame(e),n(),r(),w.current.opened=!1,w.current.applied=null}},[v,x,C,T]),(0,d.useLayoutEffect)(()=>{let e=w.current.input;w.current.input={displayReady:t,order:r,lastKey:a,lastIsUser:o,steeringId:s,submissionId:c,running:l,loadedTurns:u,chatScroll:f,...S},v.updateTurns(u);let n=e.order!==r||e.displayReady!==t;n&&v.invalidate(),T(),n&&x.refreshActiveTurn()},[v,x,T,S,t,r,a,o,s,c,l,u,f]);let ne=(0,d.useCallback)(()=>{C.cancel(),x.followTail()},[C,x]);return{listRef:y,columnRef:b,...ee,busyTurn:te,navigateToTurn:C.navigateToTurn,loadEarlier:C.loadEarlier,returnToBottom:ne}}function qf(e,t){let n=e instanceof Error?e.message:String(e);return n===``?t:n}function Jf(e,t){let n=/* @__PURE__ */ new Set,r;for(let i of e){let e=t.get(i);if(e===void 0||e.kind!==`user`&&e.kind!==`steering`&&e.kind!==`turn-trigger`||((e.location.kind===`turn`||e.location.kind===`step`)&&(r=e.location.turn.turn),e.kind===`turn-trigger`))continue;let a=e.data.source;a?.kind===`user`&&typeof a.rpcId==`string`&&n.add(a.rpcId)}return{rpcIds:n,lastInputTurn:r}}let Yf=(0,d.memo)(function({entries:e,useChatGroup:t,pendingInputs:n,lastInputTurn:r,...i}){let a=e.map(e=>{switch(e.kind){case`node`:return/* @__PURE__ */ (0,d.createElement)(Cd,{...i,key:Ad(e),nodeKey:e.key,...e.groupPart===void 0?{}:{groupPart:e.groupPart}});case`group`:return/* @__PURE__ */ (0,d.createElement)(qd,{...i,key:Ad(e),groupKey:e.key,useChatGroup:t});default:return kd(e)}}),o=n.map(e=>`requestId`in e?/* @__PURE__ */ (0,f.jsx)(nd,{submission:e,renderMessageImages:i.renderMessageImages,t:i.t},e.requestId):/* @__PURE__ */ (0,f.jsx)(td,{content:e.content,renderMessageImages:i.renderMessageImages,t:i.t},e.id)),s=e.at(-1),c=s?.kind===`node`?i.nodeStore.get(s.key):void 0;if(c?.kind===`turn-process`&&c.location.kind===`turn`&&c.location.turn.status===`open`&&c.location.turn.turn!==r){let e=n.findIndex(e=>`requestId`in e&&e.placement===`transcript`);e!==-1&&a.splice(a.length-1,0,...o.splice(e,1))}return[...a,...o]});function Xf({connection:e,useSession:t,useChat:n,useChatNode:r,useChatNodeProcess:i,useChatGroup:a,useConversation:o,useSessions:s,useStore:c,actions:l,renderSlot:u,sessionId:m,openFile:h,openSkill:g,openExternalLink:_,resolveLink:v,loadOlder:y,loadThrough:b,loadImage:x,inspectCall:ee,chatScroll:S,forkAt:C,loadTurnDiffs:te,editMessage:w,fileMentions:T,usePresentation:ne,useProjection:re,t:E}){let ie=n(e=>e.order),D=o(e=>e.views.grouped(`chat`)?.entries),oe=(0,d.useMemo)(()=>D??ie.map(e=>({kind:`node`,key:e})),[D,ie]),O=n(e=>e.nodes),ce=n(e=>e.navigation.items()),le=ce.at(-1)?.anchorKey,ue=r(le??``,e=>{let t=e?.location;return(t?.kind===`turn`||t?.kind===`step`)&&t.turn.status===`open`?t.turn.start?.time:void 0}),de=re(`turnOutline`),fe=(0,d.useMemo)(()=>Lf(ce,de),[ce,de]),pe=re(`inbox`),me=s(e=>e.byId[m]?.cwd),he=s(e=>!!e.byId[m]?.projectionValues?.remoteHost),ge=(0,d.useMemo)(()=>({resolve:e=>he?void 0:se(document.baseURI,ae(me,e)),labels:{open:E(`image.open`),loading:E(`image.loading`),failed:E(`image.failed`),dialog:E(`image.dialog`),close:E(`image.close`)}}),[me,he,E]),k=t(e=>e.running),_e=(0,d.useSyncExternalStore)(e.state.subscribe,e.state.getSnapshot),ve=(0,p.useSustainedRecovery)(_e!==`connected`),ye=re(`compacting`),be=t(e=>e.openState),xe=_e===`disconnected`||ve||be===`error`,Se=t(e=>e.openError),Ce=t(e=>e.hasMore),we=t(e=>e.loadingOlder),Te=t(e=>e.olderError),[Ee,De]=(0,d.useState)(null),[A,Oe]=(0,d.useState)(!1),ke=(0,d.useRef)(0),Ae=(0,d.useCallback)((e,t)=>{let n=++ke.current;Oe(!0),(t===void 0?h(e):h(e,t)).then(()=>{n===ke.current&&(De(null),Oe(!1))},t=>{n===ke.current&&(De({path:e,message:qf(t,E(`fileOpen.unknown`))}),Oe(!1))})},[h,E]),je=(0,d.useCallback)(()=>{ke.current+=1,De(null),Oe(!1)},[]),Me=(0,d.useMemo)(()=>pe?.[`next-step`].filter(e=>e.source.kind===`user`)??[],[pe]),Ne=t(e=>e.pendingSubmissions),Pe=Wu(w,re(`sentMessageEdit`)?.seq??null,be!==`open`||k||Ne.length>0||(pe?.[`next-turn`].length??0)>0),Fe=Pe.draft&&ie.some(e=>{let t=O.get(e);return t?.kind===`user`&&t.data.seq===Pe.draft?.seq}),Ie=k||Ne.some(e=>e.placement!==`queued`),[Le,Re]=(0,d.useMemo)(()=>{if(Ne.length===0)return[Ne,void 0];let e=Jf(ie,O);return[Ne.filter(t=>t.placement!==`queued`&&!e.rpcIds.has(t.requestId)),e.lastInputTurn]},[Ne,ie,O]),ze=(0,d.useMemo)(()=>{let e=new Map(Le.map(e=>[e.requestId,e])),t=new Set(Ne.filter(e=>e.placement!==`queued`).map(e=>e.requestId));return[...Me.flatMap(n=>{let r=n.source;if(r.kind!==`user`||!(`rpcId`in r))return[n];let i=e.get(r.rpcId);return i===void 0?t.has(r.rpcId)?[]:[n]:(e.delete(r.rpcId),[i])}),...e.values()]},[Me,Ne,Le]),j=(0,d.useCallback)(e=>u(`conversation.message.images`,{...e,loadImage:x}),[x,u]),Be=ie[0],Ve=Be===void 0?null:O.get(Be)?.anchorSeq??null,He=ie.at(-1)??null,Ue=ze.findLast(e=>`source`in e),We=Ue?.source.kind===`user`&&`rpcId`in Ue.source?Ue.source.rpcId:Ue?.id??null,Ge=Kf({displayReady:be===`open`||ie.length>0,historyReady:be===`open`,order:ie,firstSeq:Ve,lastKey:He,running:k,loadingOlder:we,olderFailed:Te!=null,hasMore:Ce,chatScroll:S,loadOlder:y,loadThrough:b,lastIsUser:He!==null&&O.get(He)?.kind===`user`,steeringId:We,submissionId:Le.at(-1)?.requestId??null,loadedTurns:ce});return/* @__PURE__ */ (0,f.jsxs)(`div`,{className:Y.frame,children:[Ge.initialized&&/* @__PURE__ */ (0,f.jsx)(Ef,{items:fe,activeTurn:Ge.activeTurn,busyTurn:Ge.busyTurn,onNavigate:Ge.navigateToTurn,t:E}),/* @__PURE__ */ (0,f.jsx)(`div`,{className:Y.root,"data-chat-following-tail":Ge.followingTail?``:void 0,children:/* @__PURE__ */ (0,f.jsx)(`div`,{ref:Ge.listRef,className:Y.scroll,children:/* @__PURE__ */ (0,f.jsxs)(`div`,{ref:Ge.columnRef,className:Y.column,"data-chat-flow":``,children:[be===`loading`&&ie.length===0&&/* @__PURE__ */ (0,f.jsx)(`div`,{className:Y.hint,children:E(`chat.loadingHistory`)}),be===`error`&&Se!==null&&/* @__PURE__ */ (0,f.jsx)(`div`,{className:Y.openError,children:E(`chat.loadError`,{message:Se.message,code:Se.code})}),Ce&&/* @__PURE__ */ (0,f.jsx)(`div`,{className:Y.older,children:Te==null?/* @__PURE__ */ (0,f.jsx)(`span`,{role:we?`status`:void 0,children:E(we?`chat.loadingOlder`:`chat.scrollOlder`)}):/* @__PURE__ */ (0,f.jsxs)(f.Fragment,{children:[/* @__PURE__ */ (0,f.jsx)(`span`,{role:`alert`,children:E(`chat.loadOlderError`,{message:Te.message})}),/* @__PURE__ */ (0,f.jsx)(`button`,{type:`button`,disabled:we,onClick:Ge.loadEarlier,children:E(`chat.retryOlder`)})]})}),/* @__PURE__ */ (0,f.jsx)(p.MarkdownDelegateProvider,{openExternalLink:_,resolveLink:v,openFile:Ae,fileImages:ge,children:/* @__PURE__ */ (0,f.jsx)(Yf,{entries:oe,pendingInputs:ze,lastInputTurn:Re,nodeStore:O,useChatGroup:a,useChatNode:r,useChatNodeProcess:i,usePresentation:ne,useStore:c,actions:l,cwd:me,openFile:Ae,openSkill:g,inspectCall:ee,forkAt:C,loadTurnDiffs:te,messageEditing:Pe,loadImage:x,renderMessageImages:j,fileMentions:T,renderSlot:u,t:E})}),Pe.draft&&!Fe&&/* @__PURE__ */ (0,f.jsx)(id,{editing:Pe,renderMessageImages:j,t:E}),Ie&&/* @__PURE__ */ (0,f.jsx)(Af,{startTime:ue,compacting:ye,stale:xe,t:E}),be===`loading`&&ie.length>0&&/* @__PURE__ */ (0,f.jsxs)(`div`,{className:Y.syncing,role:`status`,"data-history-syncing":!0,children:[/* @__PURE__ */ (0,f.jsx)(p.StateDot,{state:`ongoing`,className:Y.syncingIcon}),/* @__PURE__ */ (0,f.jsx)(`span`,{children:E(`chat.syncing`)})]})]})})}),!Ge.followingTail&&/* @__PURE__ */ (0,f.jsx)(`div`,{className:Y.toBottomSlot,children:/* @__PURE__ */ (0,f.jsx)(`button`,{type:`button`,className:Y.toBottom,"aria-label":E(`chat.toBottom`),onClick:Ge.returnToBottom,children:/* @__PURE__ */ (0,f.jsx)(p.IconChevronDownOutlineRegular,{})})}),Ee!==null&&/* @__PURE__ */ (0,f.jsx)(Zf,{message:Ee.message,busy:A,onClose:je,onRetry:()=>{Ae(Ee.path)},t:E})]})}function Zf({message:e,busy:t,onClose:n,onRetry:r,t:i}){return/* @__PURE__ */ (0,f.jsx)(p.Modal,{open:!0,onClose:n,closeLabel:i(`close`),title:i(`fileOpen.title`),description:e,footer:/* @__PURE__ */ (0,f.jsxs)(f.Fragment,{children:[/* @__PURE__ */ (0,f.jsx)(p.Button,{variant:`outline`,className:Y.modalAction,onClick:n,children:i(`cancel`)}),/* @__PURE__ */ (0,f.jsx)(p.Button,{variant:`primary`,className:Y.modalAction,disabled:t,onClick:r,children:i(`retry`)})]})})}let X=`chat`,Qf={"message.stepProcess.thinking":`正在分析请求`,"message.stepProcess.read":`正在读取文件`,"message.stepProcess.readImage":`正在读取图片`,"message.stepProcess.write":`正在写入文件`,"message.stepProcess.search":`正在搜索代码`,"message.stepProcess.edit":`正在编辑文件`,"message.stepProcess.commands":`正在运行命令`,"message.stepProcess.code":`正在运行代码`,"message.stepProcess.webSearch":`正在搜索网页`,"message.stepProcess.webFetch":`正在访问网页`,"message.stepProcess.subagents":`正在协调子智能体`,"message.stepProcess.plan":`正在更新计划`,"message.stepProcess.questions":`等待你的操作`,"message.stepProcess.tools":`正在调用工具`,"message.stepProcess.prepare.read":`准备读取文件`,"message.stepProcess.prepare.readImage":`准备读取图片`,"message.stepProcess.prepare.write":`准备写入文件`,"message.stepProcess.prepare.search":`准备搜索代码`,"message.stepProcess.prepare.edit":`准备编辑文件`,"message.stepProcess.prepare.commands":`准备运行命令`,"message.stepProcess.prepare.code":`准备运行代码`,"message.stepProcess.prepare.webSearch":`准备搜索网页`,"message.stepProcess.prepare.webFetch":`准备访问网页`,"message.stepProcess.prepare.subagents":`准备协调子智能体`,"message.stepProcess.prepare.plan":`准备更新计划`,"message.stepProcess.prepare.questions":`准备提问`,"message.stepProcess.prepare.tools":`准备调用工具`,"message.stepProcess.done.thinking":`已完成分析`,"message.stepProcess.done.read":`已读取文件`,"message.stepProcess.done.readImage":`已读取图片`,"message.stepProcess.done.write":`已写入文件`,"message.stepProcess.done.search":`已搜索代码`,"message.stepProcess.done.edit":`修改了文件`,"message.stepProcess.done.commands":`执行了命令`,"message.stepProcess.done.code":`运行了代码`,"message.stepProcess.done.webSearch":`已搜索网页`,"message.stepProcess.done.webFetch":`已访问网页`,"message.stepProcess.done.subagents":`已协调子智能体`,"message.stepProcess.done.plan":`更新了计划`,"message.stepProcess.done.questions":`向用户提出了问题`,"message.stepProcess.done.tools":`已调用工具`,"message.stepProcess.joinTwo":`{first}并{second}`,"message.stepProcess.comma":`,`,"message.stepProcess.sharedPrefix":`已`,"message.stepProcess.more":`{title}等`,"message.trigger.request":`收到执行请求`,"message.trigger.goal":`继续执行目标`,"message.trigger.agent":`收到任务消息`,"message.trigger.team":`收到团队消息`,"message.trigger.subagent":`子任务状态更新`,"message.trigger.github":`收到 GitHub 事件`,"message.trigger.webhook":`收到外部事件`,"message.trigger.schedule":`自动化任务`,"message.trigger.job":`后台任务状态更新`,"message.trigger.plugin":`插件状态更新`,"message.trigger.explanation":`这条通知触发了本轮回复。`,"message.turnProcess.worked":`已完成`,"message.turnProcess.took":`已完成,用时 `,"message.turnProcess.failed":`处理失败`,"view.chat":`对话`,"image.open":`查看大图`,"image.loading":`加载图片…`,"image.failed":`图片无法预览`,"image.dialog":`图片预览`,"image.close":`关闭图片预览`,"duration.milliseconds":`{milliseconds}毫秒`,"chat.loadingHistory":`载入历史…`,"chat.syncing":`正在获取最新消息…`,"chat.loadingDiff":`载入差异…`,"chat.retryDiff":`重试`,"chat.loadError":`历史加载失败:{message}({code})`,"chat.loadOlder":`加载更早`,"chat.scrollOlder":`向上滚动查看更早消息`,"chat.loadingOlder":`正在加载更早消息…`,"chat.loadOlderError":`更早消息加载失败:{message}`,"chat.retryOlder":`重试加载`,"chat.toBottom":`回到底部`,"chat.filesChanged":`{count} 个文件已更改`,"chat.fileEdited":`已编辑 {name}`,"chat.filesEdited":`已编辑 {count} 个文件`,"chat.viewChanges":`查看变更`,"chat.hideChanges":`收起变更`,"chat.showMoreFiles":`再显示 {count} 个文件`,"chat.collapseFiles":`收起文件`,"diff.code":`代码`,"diff.wrap":`自动换行`,"diff.unwrap":`取消换行`,"diff.copy":`复制`,"diff.copied":`已复制`,"diff.collapseAria":`折叠差异`,"diff.expandAria":`展开 {count} 行隐藏内容`,"diff.collapse":`折叠`,"diff.expand":`展开 {count} 行`,"chat.deepDiving":`正在处理`,"chat.statusUnconfirmed":`连接中断,任务状态待确认`,"chat.deepDivingFor":`正在处理 · {duration}`,"chat.turnNavigation.label":`轮次导航`,"chat.turnNavigation.jump":`跳转到用户消息 {turn}`,"chat.turnNavigation.jumpLoad":`加载并跳转到用户消息 {turn}`,"chat.turnNavigation.turn":`用户消息 {turn}`,"settings.links.title":`网页链接默认打开方式`,"settings.links.description":`对话中网页链接的打开位置`,"settings.links.sidebar":`应用内侧边栏`,"settings.links.newTab":`默认浏览器`,"settings.transcript.title":`工作步骤展示`,"settings.transcript.description":`选择希望看到多少工具调用细节`,"settings.transcript.compact":`简洁`,"settings.transcript.standard":`标准`,"settings.transcript.detailed":`详细`,"settings.transcript.verbose":`完全展开`,"fileOpen.title":`无法打开文件`,"fileOpen.unknown":`无法打开此文件`,"message.watch.completed":`已完成`,"message.watch.failed":`失败`,"message.watch.interrupted":`已中断`,"message.watch.timedOut":`监听已到期`,"message.watch.unreadable":`状态未知`,"message.watch.notFound":`会话不存在`,"message.watch.open":`打开会话`,"message.extraBlock":`附加内容块`,"message.uploading":`上传中…`,"message.uploadingPercent":`上传中 {percent}%`,"message.systemPrompt":`系统提示词`,"message.systemPromptUpdate":`系统提示词更新`,"message.toolAdded":`已添加工具:{name}`,"message.toolRemoved":`已移除工具:{name}`,"message.toolsAdded":`新增:{names}`,"message.toolsAddedCount":`新增 {count} 个`,"message.toolsChanged":`新增 {added} 个,移除 {removed} 个`,"message.toolsRemoved":`移除:{names}`,"message.toolsRemovedCount":`移除 {count} 个`,"message.toolsUpdated":`工具已更新`,"message.contextInjection":`上下文注入`,"message.contextRecall":`跨会话召回`,"message.referenceSummary":`引用会话 · {labels}`,"message.referenceSeparator":`、`,"message.context.instructions.loaded":`已载入`,"message.context.instructions.added":`已新增`,"message.context.instructions.updated":`已更新`,"message.context.instructions.removed":`已移除`,"message.context.catalog.replaced":`替换目录`,"message.context.catalog.more":`…还有 {count} 条`,"message.context.snapshot.supersedes":`取代先前的快照`,"message.context.relay.from":`来自会话 {session}`,"message.context.recall.counts":`保留 {retained} 条 · 省略 {omitted} 条`,"message.context.recall.truncated":`已截断`,"message.compaction":`上下文已压缩`,"message.compaction.running":`正在压缩…`,"message.compaction.completed":`已压缩 {items} 条历史记录(约 {tokens} tokens)`,"message.compaction.expand":`点击查看压缩摘要`,"message.compaction.unavailable":`压缩摘要不可用`,"message.compaction.commandTitle":`compact`,"message.think":`思考`,"message.unknownSurface":`未知 surface 事件:{type}`,"message.unknownBlock":`未知内容块`,"message.turnProcess.toolCalls.one":`{count} 次工具调用`,"message.turnProcess.toolCalls.other":`{count} 次工具调用`,"message.turnProcess.messages.one":`{count} 条消息`,"message.turnProcess.messages.other":`{count} 条消息`,"message.turnProcess.subagents.one":`{count} 个 subagent`,"message.turnProcess.subagents.other":`{count} 个 subagent`,"message.turnProcess.thoughtForAWhile":`已思考`,"message.turnProcess.separator":` · `,"message.stopped":`已停止`,"message.edit":`编辑消息`,"message.edit.changed":`会话状态已变化,请核对当前历史后继续。`,"message.edit.cancel":`取消`,"message.edit.send":`发送`,"message.edit.sending":`正在回退并重跑…`,"message.edit.checkHistory":`请核对当前历史后再继续;编辑文本已保留,不会自动重发。`,"message.branch":`在新对话中分支`,"message.branchFailed":`分叉未完成:{message}`,"message.branchUnavailable":`仅可从已完成轮次的最后一条消息分支`,"message.retry.active":`正在重试模型请求`,"message.retry.cancelled":`模型请求重试已取消`,"message.retry.started":`已重试模型请求`,"message.retry.scheduled":`等待重试模型请求`,"message.retry.status":`{label}({retry}/{maximum}) · {seconds}s`,"message.retry.delay":`重试延迟:`,"message.retry.failure":`失败原因:`,"message.failure.auth":`API 密钥无效`,"message.accountStopped":`任务已停止`,"message.failure.accountSignedOut":`任务已因退出 DeepSeek 登录而停止。`,"message.failure.accountSignInRequired":`请先登录 DeepSeek,并确认请求地址支持账号认证。`,"message.failure.quota":`当前请求的额度已用尽`,"message.turnError":`本轮运行失败`,"message.maxTokens":`已达到输出 token 上限`,"message.maxTokens.hint":`回答被截断,已有输出保留在对话中。发送“继续”可让模型接着输出。`,"duration.secondUnit":`秒`,"duration.minuteUnit":`分`,"duration.hourUnit":`小时`,"command.running":`执行中…`,"command.failed":`指令失败`,"command.done":`已完成`,"command.title":`指令`,"row.running":`运行中`,"row.failed":`失败`,"json.truncated":`… 已截断,共 {total} 字符`,"clock.md":`{m}月{d}日`,"clock.ymd":`{y}年{m}月{d}日`},$f={"message.stepProcess.thinking":`Analyzing the request`,"message.stepProcess.read":`Reading files`,"message.stepProcess.readImage":`Reading images`,"message.stepProcess.write":`Writing files`,"message.stepProcess.search":`Searching code`,"message.stepProcess.edit":`Editing files`,"message.stepProcess.commands":`Running commands`,"message.stepProcess.code":`Running code`,"message.stepProcess.webSearch":`Searching the web`,"message.stepProcess.webFetch":`Visiting web pages`,"message.stepProcess.subagents":`Coordinating subagents`,"message.stepProcess.plan":`Updating the plan`,"message.stepProcess.questions":`Waiting for your action`,"message.stepProcess.tools":`Calling tools`,"message.stepProcess.prepare.read":`Preparing to read files`,"message.stepProcess.prepare.readImage":`Preparing to read images`,"message.stepProcess.prepare.write":`Preparing to write files`,"message.stepProcess.prepare.search":`Preparing to search code`,"message.stepProcess.prepare.edit":`Preparing to edit files`,"message.stepProcess.prepare.commands":`Preparing to run commands`,"message.stepProcess.prepare.code":`Preparing to run code`,"message.stepProcess.prepare.webSearch":`Preparing to search the web`,"message.stepProcess.prepare.webFetch":`Preparing to visit web pages`,"message.stepProcess.prepare.subagents":`Preparing to coordinate subagents`,"message.stepProcess.prepare.plan":`Preparing to update the plan`,"message.stepProcess.prepare.questions":`Preparing questions`,"message.stepProcess.prepare.tools":`Preparing tool calls`,"message.stepProcess.done.thinking":`Analysis completed`,"message.stepProcess.done.read":`Read files`,"message.stepProcess.done.readImage":`Read images`,"message.stepProcess.done.write":`Wrote files`,"message.stepProcess.done.search":`Searched code`,"message.stepProcess.done.edit":`Edited files`,"message.stepProcess.done.commands":`Ran commands`,"message.stepProcess.done.code":`Ran code`,"message.stepProcess.done.webSearch":`Searched the web`,"message.stepProcess.done.webFetch":`Visited web pages`,"message.stepProcess.done.subagents":`Coordinated subagents`,"message.stepProcess.done.plan":`Updated the plan`,"message.stepProcess.done.questions":`Asked questions`,"message.stepProcess.done.tools":`Called tools`,"message.stepProcess.joinTwo":`{first} and {second}`,"message.stepProcess.comma":`, `,"message.stepProcess.sharedPrefix":``,"message.stepProcess.more":`{title}, etc.`,"message.trigger.request":`Execution requested`,"message.trigger.goal":`Continuing goal`,"message.trigger.agent":`Task message received`,"message.trigger.team":`Team message received`,"message.trigger.subagent":`Subtask status updated`,"message.trigger.github":`GitHub event received`,"message.trigger.webhook":`External event received`,"message.trigger.schedule":`Automation task`,"message.trigger.job":`Background task updated`,"message.trigger.plugin":`Plugin status updated`,"message.trigger.explanation":`This notification triggered this response.`,"message.turnProcess.worked":`Completed`,"message.turnProcess.took":`Completed in `,"message.turnProcess.failed":`Failed`,"view.chat":`Chat`,"image.open":`View full image`,"image.loading":`Loading image…`,"image.failed":`Image preview unavailable`,"image.dialog":`Image preview`,"image.close":`Close image preview`,"duration.milliseconds":`{milliseconds}ms`,"chat.loadingHistory":`Loading history…`,"chat.syncing":`Fetching latest messages…`,"chat.loadingDiff":`Loading diff…`,"chat.retryDiff":`Retry`,"chat.loadError":`Failed to load history: {message} ({code})`,"chat.loadOlder":`Load earlier`,"chat.scrollOlder":`Scroll up for earlier messages`,"chat.loadingOlder":`Loading earlier messages…`,"chat.loadOlderError":`Could not load earlier messages: {message}`,"chat.retryOlder":`Retry loading`,"chat.toBottom":`Back to bottom`,"chat.filesChanged":`{count} files changed`,"chat.fileEdited":`Edited {name}`,"chat.filesEdited":`Edited {count} files`,"chat.viewChanges":`View changes`,"chat.hideChanges":`Hide changes`,"chat.showMoreFiles":`Show {count} more`,"chat.collapseFiles":`Collapse files`,"diff.code":`Code`,"diff.wrap":`Wrap lines`,"diff.unwrap":`Unwrap lines`,"diff.copy":`Copy`,"diff.copied":`Copied`,"diff.collapseAria":`Collapse diff`,"diff.expandAria":`Expand {count} hidden lines`,"diff.collapse":`Collapse`,"diff.expand":`Expand {count} lines`,"chat.deepDiving":`Working`,"chat.statusUnconfirmed":`Connection interrupted; task status unconfirmed`,"chat.deepDivingFor":`Working · {duration}`,"chat.turnNavigation.label":`Turn navigation`,"chat.turnNavigation.jump":`Jump to user message {turn}`,"chat.turnNavigation.jumpLoad":`Load and jump to user message {turn}`,"chat.turnNavigation.turn":`User message {turn}`,"settings.links.title":`Open chat links in`,"settings.links.description":`Choose where to open web links`,"settings.links.sidebar":`In-App Sidebar`,"settings.links.newTab":`Default Browser`,"settings.transcript.title":`Work details`,"settings.transcript.description":`Choose how much detail to show for tool calls`,"settings.transcript.compact":`Compact`,"settings.transcript.standard":`Standard`,"settings.transcript.detailed":`Detailed`,"settings.transcript.verbose":`Verbose`,"fileOpen.title":`Couldn’t open file`,"fileOpen.unknown":`Couldn’t open this file`,"message.watch.completed":`Completed`,"message.watch.failed":`Failed`,"message.watch.interrupted":`Interrupted`,"message.watch.timedOut":`Watch expired`,"message.watch.unreadable":`State unknown`,"message.watch.notFound":`Session not found`,"message.watch.open":`Open session`,"message.extraBlock":`Extra content block`,"message.uploading":`Uploading…`,"message.uploadingPercent":`Uploading {percent}%`,"message.systemPrompt":`System prompt`,"message.systemPromptUpdate":`System prompt update`,"message.toolAdded":`Tool added: {name}`,"message.toolRemoved":`Tool removed: {name}`,"message.toolsAdded":`Added: {names}`,"message.toolsAddedCount":`{count} added`,"message.toolsChanged":`{added} added, {removed} removed`,"message.toolsRemoved":`Removed: {names}`,"message.toolsRemovedCount":`{count} removed`,"message.toolsUpdated":`Tools updated`,"message.contextInjection":`Context injection`,"message.contextRecall":`Session recall`,"message.referenceSummary":`Referenced session · {labels}`,"message.referenceSeparator":`, `,"message.context.instructions.loaded":`loaded`,"message.context.instructions.added":`added`,"message.context.instructions.updated":`updated`,"message.context.instructions.removed":`removed`,"message.context.catalog.replaced":`Replacement catalog`,"message.context.catalog.more":`… {count} more`,"message.context.snapshot.supersedes":`Supersedes earlier snapshots`,"message.context.relay.from":`From session {session}`,"message.context.recall.counts":`{retained} kept · {omitted} omitted`,"message.context.recall.truncated":`truncated`,"message.compaction":`Context compacted`,"message.compaction.running":`Compacting context…`,"message.compaction.completed":`Compacted {items} history items (~{tokens} tokens)`,"message.compaction.expand":`View compaction summary`,"message.compaction.unavailable":`Compaction summary unavailable`,"message.compaction.commandTitle":`compact`,"message.think":`Think`,"message.unknownSurface":`Unknown surface event: {type}`,"message.unknownBlock":`Unknown content block`,"message.turnProcess.toolCalls.one":`{count} tool call`,"message.turnProcess.toolCalls.other":`{count} tool calls`,"message.turnProcess.messages.one":`{count} message`,"message.turnProcess.messages.other":`{count} messages`,"message.turnProcess.subagents.one":`{count} subagent`,"message.turnProcess.subagents.other":`{count} subagents`,"message.turnProcess.thoughtForAWhile":`Thought for a while`,"message.turnProcess.separator":` · `,"message.stopped":`Stopped`,"message.edit":`Edit message`,"message.edit.changed":`Conversation state changed. Check current history before continuing.`,"message.edit.cancel":`Cancel`,"message.edit.send":`Send`,"message.edit.sending":`Reverting and rerunning…`,"message.edit.checkHistory":`Check current history before continuing. Your edit is retained and will not be resent automatically.`,"message.branch":`Branch into a new conversation`,"message.branchFailed":`Fork did not complete: {message}`,"message.branchUnavailable":`Available only on the last message of a completed turn`,"message.retry.active":`Retrying model request`,"message.retry.cancelled":`Model request retry cancelled`,"message.retry.started":`Retried model request`,"message.retry.scheduled":`Waiting to retry model request`,"message.retry.status":`{label} ({retry}/{maximum}) · {seconds}s`,"message.retry.delay":`Retry delay: `,"message.retry.failure":`Failure reason: `,"message.failure.auth":`API key is invalid`,"message.accountStopped":`Task stopped`,"message.failure.accountSignedOut":`Stopped because you signed out of DeepSeek.`,"message.failure.accountSignInRequired":`Sign in to DeepSeek and ensure the request destination supports account authentication.`,"message.failure.quota":`Request quota exhausted.`,"message.turnError":`This turn failed`,"message.maxTokens":`Output token limit reached`,"message.maxTokens.hint":`The reply was cut off; earlier output is preserved in the conversation. Send "continue" to let the model resume.`,"duration.secondUnit":`s`,"duration.minuteUnit":`m `,"duration.hourUnit":`h `,"command.running":`Running…`,"command.failed":`Command failed`,"command.done":`Completed`,"command.title":`Command`,"row.running":`Running`,"row.failed":`Failed`,"json.truncated":`… truncated, {total} characters total`,"clock.md":`{m}/{d}`,"clock.ymd":`{y}-{m}-{d}`},ep=`@deepseek-ai/dsh-client-ui-chat/ReasoningRow.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(ep)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=ep,e.textContent=`.Eedvza_root{flex-direction:column;display:flex}.Eedvza_root:not([data-expanded]){contain:size layout;height:calc(24px + var(--dsh-content-font-delta,0px))}.Eedvza_row{overflow:hidden}.Eedvza_root[data-expanded] [data-open] [data-disclosure-row]{z-index:1;background:var(--dsw-alias-bg-base);position:sticky;top:0}.Eedvza_leading{flex-shrink:0}.Eedvza_title{font-weight:400}.Eedvza_separator{background:var(--dsw-alias-label-caption);border-radius:1px;flex:none;width:2px;height:2px;margin:0 8px}.Eedvza_summary{min-width:0;font-size:var(--dsh-content-font-size-secondary,13px);line-height:calc(20px + var(--dsh-content-font-delta-secondary,0px));white-space:nowrap;flex:auto;overflow:hidden}.Eedvza_summaryText{text-overflow:ellipsis;display:block;overflow:hidden}.Eedvza_summary[data-streaming]{mask-image:linear-gradient(90deg,#000 calc(100% - 48px),#0000)}.Eedvza_summary[data-streaming] .Eedvza_summaryText{text-overflow:clip;overflow:visible}.Eedvza_root:not([data-preview]) .Eedvza_separator,.Eedvza_root:not([data-preview]) .Eedvza_summary{display:none}.Eedvza_thinkBody{padding:4px 0 4px calc(22px + var(--dsh-content-font-delta,0px));min-width:0}`,document.head.appendChild(e)}var tp={leading:`Eedvza_leading`,root:`Eedvza_root`,row:`Eedvza_row`,separator:`Eedvza_separator`,summary:`Eedvza_summary`,summaryText:`Eedvza_summaryText`,thinkBody:`Eedvza_thinkBody`,title:`Eedvza_title`};let np=/* @__PURE__ */ (0,f.jsx)(p.IconThinkOutlineRegular,{size:14});function rp(e){let t=e.indexOf(`
132
- `);return t===-1?e:e.slice(0,t)}function ip(e){let t=``,n=0,r=/\r?\n(?:[\t ]*\r?\n)+/g;for(;;){let i=r.exec(e),a=i===null?e.length:i.index+i[0].indexOf(`
131
+ default:Kd(this.#r)}}fail(){this.#d=this.#n,this.#r=`invalid`,this.#c=null}beginKey(e){this.#r=`key`,this.#a=e+1,this.#o=!1,this.#i=!1}stepKey(e,t){if(e<` `){this.fail();return}if(this.#i){this.#i=!1;return}if(e===`\\`){this.#i=!0,this.#o=!0;return}if(e!==`"`)return;let n=this.slice(this.#a,t);if(this.#o)try{this.#s=JSON.parse(`"${n}"`)}catch{this.fail();return}else this.#s=n;this.#r=`colon`}open(e){this.#p.has(this.#s)||this.#m.push(this.#s),this.#p.set(this.#s,e),this.#c=e}beginValue(e,t){Ud(e)||(e===`"`?(this.open({kind:`string`,start:t+1,end:-1,needsDecoding:!1,invalidAt:void 0,length:void 0,text:void 0,prefixes:void 0}),this.#i=!1,this.#r=`string`):e===`}`||e===`,`||e===`:`||e===`]`?this.fail():(this.open({kind:`value`,start:t,end:-1,parsed:void 0,invalid:!1}),e===`{`||e===`[`?(this.#r=`nested`,this.#l=[e===`{`?`}`:`]`],this.#u=!1,this.#i=!1):this.#r=`scalar`))}stepScalar(e,t){(e===`,`||e===`}`||Ud(e))&&(this.closeValue(t),this.#r=e===`,`?`key-only`:e===`}`?`closed`:`comma-or-end`)}stepNested(e,t){if(this.#u)this.#u=!1;else if(e===`"`)this.#u=!0;else if(e===`{`||e===`[`)this.#l.push(e===`{`?`}`:`]`);else if(e===`}`||e===`]`){if(this.#l.pop()!==e){this.fail();return}this.#l.length===0&&(this.closeValue(t+1),this.#r=`comma-or-end`)}}closeValue(e){let t=this.#c;t.end=e,this.#c=null}};function Kd(e,t){let n=JSON.stringify(e)??String(e);throw Error(`unreachable variant${t?` in ${t}`:``}: ${n}`)}function qd(e){switch(e.kind){case`node`:return JSON.stringify([`node`,e.key,e.groupPart??null]);case`group`:return JSON.stringify([`group`,e.key]);default:return Kd(e)}}function Jd(e,t){let n=e.counts.slice(0,3).map(({kind:e})=>t(`message.stepProcess.done.${e}`)),r=n[0];if(r===void 0)return t(`message.stepProcess.done.thinking`);let i=e=>e.charAt(0).toLowerCase()+e.slice(1),a=n[1];if(a===void 0)return r;if(n.length===2){let e=t(`message.stepProcess.sharedPrefix`);return t(`message.stepProcess.joinTwo`,{first:r,second:i(e!==``&&r.startsWith(e)&&a.startsWith(e)?a.slice(e.length):a)})}let o=[r,...n.slice(1).map(i)].join(t(`message.stepProcess.comma`));return e.counts.length>3?t(`message.stepProcess.more`,{title:o}):o}function Yd(e=0){let[t,n]=(0,d.useState)(null);return{expanded:t===e,setExpanded:(0,d.useCallback)(t=>{n(t?e:null)},[e]),toggle:(0,d.useCallback)(()=>{n(t=>t===e?null:e)},[e])}}function Xd(e){let t=t=>e.subscribe(t),n=()=>e.getSnapshot();return function(){return Yd((0,d.useSyncExternalStore)(t,n))}}function Zd(e){let t=e.clientHeight;return{top:e.scrollTop,height:t,floor:Math.max(0,e.scrollHeight-t)}}var Qd=class e{following;threshold;static owners=/* @__PURE__ */ new WeakMap;target=null;sampledTop;constructor(e,t){this.following=e,this.threshold=t}static forElement(e){return this.owners.get(e)}bind(t){return e.owners.set(t,this),()=>{e.owners.get(t)===this&&e.owners.delete(t)}}get active(){return this.following}get animating(){return this.target!==null}nearBottom(e){return e.floor-e.top<=this.threshold}setFollowing(e){this.following=e,e||(this.target=null)}reset(){this.setFollowing(!1),this.sampledTop=void 0}sample(e,t=this.sampledTop===void 0||Math.abs(e.top-this.sampledTop)>.5){return this.sampledTop=e.top,!this.animating&&t&&(this.following=this.nearBottom(e)),this.active}settle(e){let t=this.target;return this.target=null,this.sample(e,t===null?void 0:Math.abs(e.top-Math.min(t,e.floor))>this.threshold)}jump(e,t,n){let r=this.animating;this.target=null;let i=Math.max(0,Math.min(t.floor,n));r?e.scrollTo({top:i,behavior:`instant`}):i!==t.top&&(e.scrollTop=i);let a={...t,top:e.scrollTop};return this.sampledTop=a.top,this.following=this.nearBottom(a),a}toBottom(e,t,n){return this.following=!0,n===`instant`||t.top>=t.floor||!this.animating&&this.nearBottom(t)||typeof matchMedia==`function`&&matchMedia(`(prefers-reduced-motion: reduce)`).matches?this.jump(e,t,t.floor):(this.target===null&&(this.target=t.floor,e.scrollTo({top:t.floor,behavior:`smooth`})),t)}interrupt(e,t){this.animating&&(this.target=null,this.sampledTop=t.top,e.scrollTo({top:t.top,behavior:`instant`}))}};function $d(e,t){let[n]=(0,d.useState)(()=>new Qd(e,t));return n}let ef={canScrollUp:!1,canScrollDown:!1},tf=/* @__PURE__ */ new Set([`ArrowUp`,`ArrowDown`,`PageUp`,`PageDown`,`Home`,`End`,` `]);function nf(e,t,n,r){let i=$d(!1,1),a=(0,d.useRef)(null),[o,s]=(0,d.useState)(ef),c=(0,d.useCallback)(e=>{a.current=e},[]),l=(0,d.useCallback)(t=>{let n=e.current,r=ef;if(n!==null&&n.closest(`[hidden], [data-group-expanded-mode]`)===null){let e=Zd(n),o=t===`resize`?a.current:null;if(o!==null)e=i.jump(n,e,o===`bottom`?e.floor:0),o===`top`&&i.setFollowing(!1),a.current=null;else{let r=i.animating;t===`scrollend`?i.settle(e):i.sample(e),i.active&&(t===`resize`||t===`scrollend`&&r)&&(e=i.toBottom(n,e,`smooth`))}r={canScrollUp:e.top>1,canScrollDown:e.top<e.floor-1}}else i.reset();s(e=>e.canScrollUp===r.canScrollUp&&e.canScrollDown===r.canScrollDown?e:r)},[e,i]),u=(0,d.useCallback)(()=>{let t=e.current;t!==null&&i.animating&&i.interrupt(t,Zd(t))},[e,i]),f=(0,d.useMemo)(()=>({onScroll:()=>{l(`scroll`)},onWheel:u,onTouchStart:u,onPointerDown:u,onKeyDown:e=>{!e.defaultPrevented&&tf.has(e.key)&&u()}}),[u,l]);return(0,d.useLayoutEffect)(()=>{u(),i.reset(),(!r||!n)&&(a.current=null)},[i,r,u,n]),(0,d.useLayoutEffect)(()=>{let r=e.current;if(r===null||!n||typeof ResizeObserver>`u`)return;let a=i.bind(r),o=new ResizeObserver(()=>{l(`resize`)}),s=e=>{e.target===r&&l(`scrollend`)};return r.addEventListener(`scrollend`,s),o.observe(r),t.current!==null&&o.observe(t.current),()=>{a(),o.disconnect(),r.removeEventListener(`scrollend`,s)}},[e,t,i,n,l]),{edges:o,events:f,initialize:c}}let rf=`@deepseek-ai/dsh-client-ui-chat/ChatGroupSeat.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(rf)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=rf,e.textContent=`.d7zOOa_root{min-width:0}.d7zOOa_title{max-width:100%;color:var(--dsw-alias-label-tertiary);font:inherit;font-size:var(--dsh-content-font-size,14px);text-align:left;cursor:pointer;background:0 0;border:0;align-items:center;gap:6px;padding:0;transition:color .1s;display:flex}.d7zOOa_title:hover{color:var(--dsw-alias-label-secondary)}.d7zOOa_leading{width:calc(16px + var(--dsh-content-font-delta,0px));height:calc(16px + var(--dsh-content-font-delta,0px));color:inherit;flex:none;justify-content:center;align-items:center;display:inline-flex;position:relative}.d7zOOa_leading svg{width:calc(14px + var(--dsh-content-font-delta,0px));height:calc(14px + var(--dsh-content-font-delta,0px))}.d7zOOa_leading svg[width="16"]{width:calc(16px + var(--dsh-content-font-delta,0px));height:calc(16px + var(--dsh-content-font-delta,0px))}.d7zOOa_activityIcon,.d7zOOa_chevron{justify-content:center;align-items:center;transition:opacity .1s;display:inline-flex;position:absolute;inset:0}.d7zOOa_activityIcon{opacity:1}.d7zOOa_chevron,.d7zOOa_title:is(:hover,:focus-visible) .d7zOOa_activityIcon{opacity:0}.d7zOOa_title:is(:hover,:focus-visible) .d7zOOa_chevron{opacity:1}.d7zOOa_title[aria-expanded=true] .d7zOOa_activityIcon{opacity:0}.d7zOOa_title[aria-expanded=true] .d7zOOa_chevron{opacity:1}.d7zOOa_title[aria-expanded=true]{padding-bottom:8px}.d7zOOa_body{--dsh-chat-flow-gap:6px;overscroll-behavior-y:auto;scrollbar-gutter:stable;max-height:min(400px,50vh);overflow-y:auto}.d7zOOa_label{text-overflow:ellipsis;white-space:nowrap;min-width:0;overflow:hidden}.d7zOOa_fadeTop{mask-image:linear-gradient(#0000 0,#000 24px 100%)}.d7zOOa_fadeBottom{mask-image:linear-gradient(#000 0 calc(100% - 24px),#0000 100%)}.d7zOOa_fadeTop.d7zOOa_fadeBottom{mask-image:linear-gradient(#0000 0,#000 24px calc(100% - 24px),#0000 100%)}@media (prefers-reduced-motion:reduce){.d7zOOa_title,.d7zOOa_activityIcon,.d7zOOa_chevron{transition:none}}.d7zOOa_content{flex-direction:column;display:flex}.d7zOOa_content>*{flex-shrink:0}.d7zOOa_content>:not([hidden]):not(:empty)~:not([hidden]):not(:empty){margin-top:var(--dsh-chat-flow-gap,6px)}.d7zOOa_expandedBody{scrollbar-gutter:auto;max-height:none;overflow:visible}`,document.head.appendChild(e)}var af={activityIcon:`d7zOOa_activityIcon`,body:`d7zOOa_body`,chevron:`d7zOOa_chevron`,content:`d7zOOa_content`,expandedBody:`d7zOOa_expandedBody`,fadeBottom:`d7zOOa_fadeBottom`,fadeTop:`d7zOOa_fadeTop`,label:`d7zOOa_label`,leading:`d7zOOa_leading`,root:`d7zOOa_root`,title:`d7zOOa_title`};let of={thinking:/* @__PURE__ */ (0,f.jsx)(p.IconThinkOutlineRegular,{}),read:/* @__PURE__ */ (0,f.jsx)(p.IconBrowseOutlineRegular,{size:14}),readImage:/* @__PURE__ */ (0,f.jsx)(p.IconBrowseOutlineRegular,{size:14}),search:/* @__PURE__ */ (0,f.jsx)(p.IconSearchOutlineRegular,{size:14}),edit:/* @__PURE__ */ (0,f.jsx)(p.IconEditOutlineRegular,{size:14}),write:/* @__PURE__ */ (0,f.jsx)(p.IconEditOutlineRegular,{size:14}),commands:/* @__PURE__ */ (0,f.jsx)(p.IconApiOutlineRegular,{}),code:/* @__PURE__ */ (0,f.jsx)(p.IconCodeOutlineRegular,{size:14}),webSearch:/* @__PURE__ */ (0,f.jsx)(p.IconGlobeOutlineRegular,{}),webFetch:/* @__PURE__ */ (0,f.jsx)(p.IconBrowseOutlineRegular,{size:14}),subagents:/* @__PURE__ */ (0,f.jsx)(p.IconAgentPresetOutlineRegular,{size:14}),plan:/* @__PURE__ */ (0,f.jsx)(p.IconPlanOutlineRegular,{}),questions:/* @__PURE__ */ (0,f.jsx)(p.IconQuestionOutlineRegular,{}),tools:/* @__PURE__ */ (0,f.jsx)(p.IconSparkleRegular,{size:14})};function sf(e,t){return e.activity===t.activity&&e.detail===t.detail&&e.preparing===t.preparing}function cf(e,t){let[n,r]=(0,d.useState)(e),i=(0,d.useRef)(n),a=(0,d.useRef)(e),o=(0,d.useRef)(Date.now());return(0,d.useEffect)(()=>{if(a.current=e,!t||sf(i.current,e))return;let n=150-(Date.now()-o.current),s=()=>{let e=a.current;i.current=e,o.current=Date.now(),r(e)};if(n<=0){s();return}let c=setTimeout(s,n);return()=>{clearTimeout(c)}},[t,e.activity,e.detail,e.preparing]),t?n:e}let lf=(0,d.memo)(function({members:e,...t}){return e.map(e=>/* @__PURE__ */ (0,d.createElement)(Bd,{...t,key:qd(e),nodeKey:e.key,...e.groupPart===void 0?{}:{groupPart:e.groupPart}}))}),uf=(0,d.memo)(function({groupKey:e,useChatGroup:t,usePresentation:n,t:r,open:i,bodyId:a,toggle:o}){let s=t(e,e=>e?.data),c=n(e=>s?.closed===!1&&e.liveProcessDetail),l=cf({activity:s?.summary.running??`thinking`,detail:s?.summary.runningDetail??``,preparing:s?.summary.preparing===!0},s!==void 0&&!s.closed);if(s===void 0)return null;let u=s.closed?Jd(s.summary,r):l.preparing?r(`message.stepProcess.prepare.${l.activity===`thinking`?`tools`:l.activity}`):r(`message.stepProcess.${l.activity}`),d=c&&!s.closed?l.detail:``,m=d===``?u:`${u}${r(`message.turnProcess.separator`)}${d}`,h=s.closed?s.summary.counts[0]?.kind??`thinking`:l.activity;return/* @__PURE__ */ (0,f.jsxs)(`button`,{type:`button`,className:af.title,"aria-expanded":i,"aria-controls":a,"data-process-activity":h,onClick:e=>{e.currentTarget.focus(),o()},children:[/* @__PURE__ */ (0,f.jsxs)(`span`,{className:af.leading,"aria-hidden":`true`,children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:af.activityIcon,"data-step-process-icon":!0,children:of[h]}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:af.chevron,"data-step-process-chevron":!0,children:i?/* @__PURE__ */ (0,f.jsx)(p.IconChevronUpOutlineRegular,{}):/* @__PURE__ */ (0,f.jsx)(p.IconChevronDownOutlineRegular,{})})]}),/* @__PURE__ */ (0,f.jsx)(p.TextShimmer,{active:!s.closed,children:/* @__PURE__ */ (0,f.jsx)(p.TextShimmer,{className:af.label,children:m})})]})}),df=(0,d.memo)(function({groupKey:e,useChatGroup:t,...n}){let r=t(e,e=>e?.members),i=t(e,e=>e?.data.turn),a=t(e,e=>e?.data.closed),o=n.usePresentation(e=>e.foldCompletedTurns),{expanded:s,setExpanded:c}=Yd(),l=r?.[0]?.key??``,u=n.useChatNodeProcess(l),p=n.useChatNode(l,e=>{let t=e?.location;return t?.kind===`turn`||t?.kind===`step`?t.turn:void 0}),m=n.usePresentation(e=>e.stepGrouping===`collapsed`||e.stepGrouping===`history`&&p?.status!==`open`),h=p?.end?.data.reason.kind,g=u?.turnClosed===!1||u?.hasInterleavedInput===!0||p?.end?.data.finalAssistantStep===null||h===`aborted`||h===`error`,_=u?.spec,v=(0,d.useCallback)(e=>i===void 0?void 0:kd(e,i),[i]),y=n.useStore(v),ee=o&&u?.turnClosed===!0&&_!==void 0&&!g&&y?.answerStep!==(_.answerStep??0),b=jd(ee,(0,d.useCallback)(()=>{_!==void 0&&!g&&n.actions.setTurnProcessOpen(_.turn,_.answerStep??0,!0)},[n.actions,_,g]));(0,d.useEffect)(()=>{ee&&b.current?.hasAttribute(`hidden`)&&c(!1)},[ee,b,c]);let te=(0,d.useCallback)(()=>{c(!0)},[c]),x=jd(m&&!s,te),S=(0,d.useRef)(null),C=(0,d.useId)(),{edges:w,events:T,initialize:E}=nf(x,S,s,m),ne=(0,d.useCallback)(()=>{s||E(a===!1?`bottom`:`top`),c(!s)},[a,E,s,c]);if(r===void 0)return null;let re=[af.body,m?``:af.expandedBody,m&&w.canScrollUp?af.fadeTop:``,m&&w.canScrollDown?af.fadeBottom:``];return/* @__PURE__ */ (0,f.jsxs)(`div`,{ref:b,className:af.root,"data-chat-group-key":e,"data-chat-flow-key":e,"data-chat-anchor-key":`group:${e}`,"data-chat-turn":i,"data-chat-paging-anchor":m&&!s||void 0,"data-step-process":!0,"data-group-expanded-mode":!m||void 0,children:[/* @__PURE__ */ (0,f.jsx)(`div`,{hidden:!m,children:/* @__PURE__ */ (0,f.jsx)(uf,{groupKey:e,useChatGroup:t,usePresentation:n.usePresentation,t:n.t,open:s,bodyId:C,toggle:ne})}),/* @__PURE__ */ (0,f.jsx)(`div`,{ref:x,id:C,className:re.join(` `),"data-step-process-body":!0,"data-scroll-up":w.canScrollUp||void 0,"data-scroll-down":w.canScrollDown||void 0,...T,children:/* @__PURE__ */ (0,f.jsx)(`div`,{ref:S,className:af.content,"data-step-process-content":!0,"data-chat-flow":``,children:/* @__PURE__ */ (0,f.jsx)(lf,{...n,members:r})})})]})});function ff(e){return typeof e==`object`?e.key:e}function pf(e,t){let n=e.length;return new Proxy(e,{get(e,r,i){if(typeof r==`string`){let i=r.charCodeAt(0);if(i>=48&&i<=57){let i=+r;if(Number.isInteger(i)&&i>=0&&i<n){let n=e[i];if(typeof n!=`object`){let r=t[i*2];n=e[i]={index:i,key:n,start:r,size:t[i*2+1],end:r+t[i*2+1],lane:0}}return n}}if(r===`length`)return n}return Reflect.get(e,r,i)}})}function mf(e,t,n){let r=n.initialDeps??[],i,a=!0;function o(){let o=e();return(o.length!==r.length||o.some((e,t)=>r[t]!==e))&&(r=o,i=t(...o),n?.onChange&&!(a&&n.skipInitialOnChange)&&n.onChange(i),a=!1),i}return o.updateDeps=e=>{r=e},o}function hf(e,t){if(e===void 0)throw Error(`Unexpected undefined${t?`: ${t}`:``}`);return e}let gf=(e,t)=>Math.abs(e-t)<1.01,_f=(e,t,n)=>{let r;return Object.assign(function(...i){e.clearTimeout(r),r=e.setTimeout(()=>t.apply(this,i),n)},{cancel:()=>{e.clearTimeout(r)}})},vf,yf=()=>{if(vf!==void 0)return vf;if(typeof navigator>`u`)return vf=!1;if(/iP(hone|od|ad)/.test(navigator.userAgent))return vf=!0;let e=navigator.maxTouchPoints;return vf=navigator.platform===`MacIntel`&&e!==void 0&&e>0},bf=e=>{let{offsetWidth:t,offsetHeight:n}=e;return{width:t,height:n}},xf=e=>e,Sf=e=>{let t=Math.max(e.startIndex-e.overscan,0),n=Math.min(e.endIndex+e.overscan,e.count-1)-t+1,r=Array(n);for(let e=0;e<n;e++)r[e]=t+e;return r},Cf=(e,t)=>{let n=e.scrollElement;if(!n)return;let r=e.targetWindow;if(!r)return;let i=e=>{let{width:n,height:r}=e;t({width:Math.round(n),height:Math.round(r)})};if(i(bf(n)),!r.ResizeObserver)return()=>{};let a=new r.ResizeObserver(t=>{let r=()=>{let e=t[0];if(e?.borderBoxSize){let t=e.borderBoxSize[0];if(t){i({width:t.inlineSize,height:t.blockSize});return}}i(bf(n))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(r):r()});return a.observe(n,{box:`border-box`}),()=>{a.unobserve(n)}},wf={passive:!0},Tf=typeof window>`u`||`onscrollend`in window,Ef=(e,t,n)=>{let r=e.scrollElement;if(!r)return;let i=e.targetWindow;if(!i)return;let a=e.options.useScrollendEvent&&Tf,o=0,s=a?null:_f(i,()=>t(n(r),!1),e.options.isScrollingResetDelay),c=e=>()=>{o=n(r),s?.(),t(o,e)},l=c(!0),u=c(!1);return r.addEventListener(`scroll`,l,wf),a&&r.addEventListener(`scrollend`,u,wf),()=>{r.removeEventListener(`scroll`,l),a&&r.removeEventListener(`scrollend`,u),s?.cancel()}},Df=(e,t)=>Ef(e,t,t=>{let{horizontal:n,isRtl:r}=e.options;return n?t.scrollLeft*(r&&-1||1):t.scrollTop}),Of=(e,t,n)=>{if(n.options.useCachedMeasurements){let t=n.indexFromElement(e),r=n.options.getItemKey(t);return n.itemSizeCache.get(r)??n.options.estimateSize(t)}if(t?.borderBoxSize){let e=t.borderBoxSize[0];if(e)return Math.round(e[n.options.horizontal?`inlineSize`:`blockSize`])}if(!t){let t=n.indexFromElement(e),r=n.options.getItemKey(t),i=n.itemSizeCache.get(r);if(i!==void 0)return i}return e[n.options.horizontal?`offsetWidth`:`offsetHeight`]},kf=(e,{adjustments:t=0,behavior:n},r)=>{var i,a;(a=(i=r.scrollElement)?.scrollTo)==null||a.call(i,{[r.options.horizontal?`left`:`top`]:e+t,behavior:n})};function Af(e,t,n,r){if(t===0)return!1;let i=r(0),a=/* @__PURE__ */ new Set,o=0;for(;o<e;){let e=n(o);if(e===i)break;a.add(e),o++}let s=e-o;if(s===0||s>=t)return!1;for(let e=0;e<s;e++)if(r(e)!==n(o+e))return!1;for(let e=s;e<t;e++)if(a.has(r(e)))return!1;return!0}var jf=class{constructor(e){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this._singleLaneMeasurements=null,this.itemSizeCache=/* @__PURE__ */ new Map,this.itemSizeCacheVersion=0,this.laneAssignments=/* @__PURE__ */ new Map,this.pendingMin=null,this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.pendingScrollAnchor=null,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this._iosDeferredAdjustment=0,this._iosTouching=!1,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._intendedScrollOffset=null,this._clampedAdjustment=null,this.elementsCache=/* @__PURE__ */ new Map,this.now=()=>{var e;return((e=this.targetWindow?.performance)?.now)?.call(e)??Date.now()},this.observer=/* @__PURE__ */ (()=>{let e=null,t=()=>e||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:e=new this.targetWindow.ResizeObserver(e=>{e.forEach(e=>{let t=()=>{let t=e.target,n=this.indexFromElement(t);if(t.isConnected)this.isIndexInRange(n)&&this.shouldMeasureDuringScroll(n)&&this.resizeItem(n,this.options.measureElement(t,e,this));else{this.observer.unobserve(t);for(let[e,n]of this.elementsCache)if(n===t){this.elementsCache.delete(e);break}}};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(t):t()})}));return{disconnect:()=>{var n;(n=t())==null||n.disconnect(),e=null},observe:e=>t()?.observe(e,{box:`border-box`}),unobserve:e=>t()?.unobserve(e)}})(),this.range=null,this.setOptions=e=>{let t={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:xf,rangeExtractor:Sf,onChange:()=>{},measureElement:Of,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:`data-index`,initialMeasurementsCache:[],lanes:1,anchorTo:`start`,followOnAppend:!1,scrollEndThreshold:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,laneAssignmentMode:`estimate`,useCachedMeasurements:!1};for(let n in e){let r=e[n];r!==void 0&&(t[n]=r)}let n=this.options,r=null,i=null,a=!1;if(n!==void 0&&n.enabled&&t.enabled&&t.anchorTo===`end`&&this.scrollElement!==null){let e=n.count,o=t.count,s=this.getMeasurements(),c=this._singleLaneMeasurements?.items??s,l=e=>ff(c[e]),u=e>0?l(0):null,d=e>0?l(e-1):null;if(o!==e||e>0&&o>0&&(t.getItemKey(0)!==u||t.getItemKey(o-1)!==d)){a=!0;let c=e>0?this.getVirtualItemForOffset(this.getScrollOffset())??s[0]:null;c&&(r=[c.key,this.getScrollOffset()-c.start]);let u=t.followOnAppend===!0?`auto`:t.followOnAppend||null;u&&o>0&&this.isAtEnd(n.scrollEndThreshold)&&(e===0||t.getItemKey(o-1)!==d)&&(o>e||Af(e,o,l,t.getItemKey))&&(i=u)}}this.options=t,a&&(this.pendingMin=0,this.itemSizeCacheVersion++);let o=!1,s=0;if(r&&this.scrollOffset!==null){let[e,t]=r,n=this.getMeasurements(),{count:a,getItemKey:c}=this.options,l=0;for(;l<a&&c(l)!==e;)l++;if(l<a){let e=n[l];if(e){let n=Math.max(0,e.start+t);!i&&n!==this.scrollOffset&&(s=n-this.scrollOffset,this.scrollOffset=n,o=!0)}}}(o||i)&&(this.pendingScrollAnchor=[o?r[0]:null,o?r[1]:0,i,s])},this.notify=e=>{var t,n;(n=(t=this.options).onChange)==null||n.call(t,this,e)},this.maybeNotify=mf(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),e=>{this.notify(e)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(e=>e()),this.unsubs=[],this.observer.disconnect(),this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,this.isScrolling=!1,this.scrollDirection=null,this._iosDeferredAdjustment=0,this._iosTouching=!1,this._iosJustTouchEnded=!1,this._clampedAdjustment=null,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{let e=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==e){if(this.cleanup(),!e){this.maybeNotify();return}if(this.scrollElement=e,this.targetWindow=this.scrollElement&&`ownerDocument`in this.scrollElement?this.scrollElement.ownerDocument.defaultView:this.scrollElement?.window??null,this.elementsCache.forEach(e=>{this.observer.observe(e)}),this.unsubs.push(this.options.observeElementRect(this,e=>{this.scrollRect=e,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(e,t)=>{if(t&&this._intendedScrollOffset===null&&e===this.scrollOffset)return;this._intendedScrollOffset!==null&&Math.abs(e-this._intendedScrollOffset)<1.5&&(e=this._intendedScrollOffset),this._intendedScrollOffset=null,this._clampedAdjustment!==null&&Math.abs(e-this._clampedAdjustment.maxAtWrite)>=1.5&&(this._clampedAdjustment=null),this.scrollAdjustments=0;let n=this.getScrollOffset();this.scrollDirection=t?n===e?this.scrollDirection:n<e?`forward`:`backward`:null,this.scrollOffset=e,this.isScrolling=t,this._flushIosDeferredIfReady(),this.scrollState&&this.scheduleScrollReconcile(),this.maybeNotify()})),`addEventListener`in this.scrollElement){let e=this.scrollElement,t=()=>{this._iosTouching=!0,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)},n=()=>{this._iosTouching=!1,yf()&&this.targetWindow!=null&&(this._iosJustTouchEnded=!0,this._iosTouchEndTimerId=this.targetWindow.setTimeout(()=>{this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._flushIosDeferredIfReady()},150))};e.addEventListener(`touchstart`,t,wf),e.addEventListener(`touchend`,n,wf),this.unsubs.push(()=>{e.removeEventListener(`touchstart`,t),e.removeEventListener(`touchend`,n),this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)})}this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}let t=this.pendingScrollAnchor;if(this.pendingScrollAnchor=null,t&&this.scrollElement&&this.options.enabled){let[e,n,r,i]=t;e!==null&&!r&&(yf()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?i!==0&&(this._iosDeferredAdjustment+=i):this.scrollState?.behavior===`smooth`&&!gf(this.getScrollOffset()-i,this.scrollState.lastTargetOffset)||this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})),r&&this.scrollToEnd({behavior:r})}this._retryClampedAdjustment()},this._retryClampedAdjustment=()=>{if(this._clampedAdjustment===null||!this.scrollElement||!this.options.enabled)return;let{target:e,maxAtWrite:t}=this._clampedAdjustment,n=this.getMaxScrollOffset();n>t+.5&&(this._clampedAdjustment=e>n+.5?{target:e,maxAtWrite:n}:null,this._scrollToOffset(e,{adjustments:void 0,behavior:void 0}))},this._flushIosDeferredIfReady=()=>{if(this._iosDeferredAdjustment===0||this.isScrolling||this._iosTouching||this._iosJustTouchEnded)return;let e=this.getScrollOffset(),t=this.getMaxScrollOffset();if(e<0||e>t)return;if(this._iosDeferredAdjustment<0&&e>=t-1){this._iosDeferredAdjustment=0;return}let n=this._iosDeferredAdjustment;this._iosDeferredAdjustment=0,this._scrollToOffset(e,{adjustments:this.scrollAdjustments+=n,behavior:void 0})},this.rafId=null,this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?`width`:`height`]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset==`function`?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getMeasurementOptions=mf(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes,this.options.laneAssignmentMode,this.options.gap],(e,t,n,r,i,a,o,s)=>(this.prevLanes!==void 0&&this.prevLanes!==a&&(this.lanesChangedFlag=!0),this.prevLanes=a,this.pendingMin=null,{count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:i,lanes:a,laneAssignmentMode:o,gap:s}),{key:!1}),this.isIndexInRange=e=>e>=0&&e<this.options.count,this.getMeasurements=mf(()=>[this.getMeasurementOptions(),this.itemSizeCacheVersion],({count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:i,lanes:a,laneAssignmentMode:o,gap:s},c)=>{let l=this.itemSizeCache;if(!i)return this.measurementsCache=[],this._singleLaneMeasurements=null,this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>e)for(let t of this.laneAssignments.keys())t>=e&&this.laneAssignments.delete(t);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this._singleLaneMeasurements=null,this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMin=null),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(e=>{this.itemSizeCache.set(e.key,e.size)}));let u=this.lanesSettling?0:this.pendingMin??0;if(this.pendingMin=null,this.lanesSettling&&this.measurementsCache.length===e&&(this.lanesSettling=!1),a===1){let i=e*2,a=this._singleLaneMeasurements?.flat;if(!a||a.length<i){let e=new Float64Array(i);a&&u>0&&e.set(a.subarray(0,u*2)),a=e}let o=u===0?Array(e):this._singleLaneMeasurements.items.slice(),c;if(u===0)c=t+n;else{let e=u-1;c=a[e*2]+a[e*2+1]+s}for(let t=u;t<e;t++){let e=r(t);o[t]=e;let n=l.get(e),i=typeof n==`number`?n:this.options.estimateSize(t);a[t*2]=c,a[t*2+1]=i,c+=i+s}this._singleLaneMeasurements={flat:a,items:o};let d=pf(o,a);return this.measurementsCache=d,d}let d=this.measurementsCache.slice(0,u),f=Array(a).fill(void 0),p=new Float64Array(a),m=0;for(let e=0;e<u;e++){let t=d[e];t&&(f[t.lane]===void 0&&m++,f[t.lane]=e,p[t.lane]=t.end)}for(let i=u;i<e;i++){let e=r(i),c=this.laneAssignments.get(i),u,h,g=o===`estimate`||l.has(e);if(c!==void 0&&this.options.lanes>1){u=c;let e=f[u],r=e===void 0?void 0:d[e];h=r?r.end+s:t+n}else if(m===a){let e=0,t=p[0],n=f[0];for(let r=1;r<a;r++){let i=p[r];(i<t||i===t&&f[r]<n)&&(e=r,t=i,n=f[r])}u=e,h=t+s,g&&this.laneAssignments.set(i,u)}else u=i%this.options.lanes,h=t+n,g&&this.laneAssignments.set(i,u);let _=l.get(e),v=typeof _==`number`?_:this.options.estimateSize(i),y=h+v;d[i]={index:i,start:h,size:v,end:y,key:e,lane:u},f[u]===void 0&&m++,f[u]=i,p[u]=y}return this.measurementsCache=d,d},{key:!1,debug:()=>this.options.debug}),this.calculateRange=mf(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(e,t,n,r)=>e.length===0||t===0?(this.range=null,null):(this.range=Pf(e,t,n,r,r===1&&this._singleLaneMeasurements!==null?this._singleLaneMeasurements.flat:null),this.range),{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=mf(()=>{let e=null,t=null,n=this.calculateRange();return n&&(e=n.startIndex,t=n.endIndex),this.maybeNotify.updateDeps([this.isScrolling,e,t]),[this.options.rangeExtractor,this.options.overscan,this.options.count,e,t]},(e,t,n,r,i)=>r===null||i===null?[]:e({startIndex:r,endIndex:i,overscan:t,count:n}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=e=>{let t=this.options.indexAttribute,n=e.getAttribute(t);return n?parseInt(n,10):(console.warn(`Missing attribute name '${t}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=e=>{if(!this.scrollState||this.scrollState.behavior!==`smooth`)return!0;let t=this.scrollState.index??this.getVirtualItemForOffset(this.scrollState.lastTargetOffset)?.index;if(t!==void 0&&this.range){let n=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),r=Math.max(0,t-n),i=Math.min(this.options.count-1,t+n);return e>=r&&e<=i}return!0},this.measureElement=e=>{if(!e){this.elementsCache.forEach((e,t)=>{e.isConnected||(this.observer.unobserve(e),this.elementsCache.delete(t))});return}let t=this.indexFromElement(e);if(!this.isIndexInRange(t))return;let n=this.options.getItemKey(t),r=this.elementsCache.get(n);r!==e&&(r&&this.observer.unobserve(r),this.observer.observe(e),this.elementsCache.set(n,e)),(!this.isScrolling||this.scrollState)&&this.shouldMeasureDuringScroll(t)&&this.resizeItem(t,this.options.measureElement(e,void 0,this))},this.resizeItem=(e,t)=>{if(!this.isIndexInRange(e))return;let n,r,i,a=this._singleLaneMeasurements?.flat;if(this.options.lanes===1&&a!=null)i=this.options.getItemKey(e),r=a[e*2],n=a[e*2+1];else{let t=this.measurementsCache[e];if(!t)return;i=t.key,r=t.start,n=t.size}let o=this.itemSizeCache.get(i)??n,s=t-o;if(s!==0){let a=this.options.anchorTo===`end`&&this.scrollState?.behavior!==`smooth`&&this.getVirtualDistanceFromEnd()<=this.options.scrollEndThreshold,c=a?this.getTotalSize():0,l=this.getScrollOffset()+this.scrollAdjustments,u=this.itemSizeCache.has(i)?r+o<=l&&this.scrollDirection!==`backward`:r<l,d=this.scrollState?.behavior!==`smooth`&&(this.shouldAdjustScrollPositionOnItemSizeChange===void 0?u:this.shouldAdjustScrollPositionOnItemSizeChange(this.measurementsCache[e]??{index:e,key:i,start:r,size:n,end:r+n,lane:0},s,this));(this.pendingMin===null||e<this.pendingMin)&&(this.pendingMin=e),this.itemSizeCache.set(i,t),this.itemSizeCacheVersion++;let f=!1;a?f=this.applyScrollAdjustment(this.getTotalSize()-c):d&&(f=this.applyScrollAdjustment(s)),this.notify(f),this._retryClampedAdjustment()}},this.getVirtualItems=mf(()=>[this.getVirtualIndexes(),this.getMeasurements()],(e,t)=>{let n=[];for(let r=0,i=e.length;r<i;r++){let i=t[e[r]];n.push(i)}return n},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=e=>{let t=this.getMeasurements();if(t.length===0)return;let n=this._singleLaneMeasurements?.flat,r=this.options.lanes===1&&n!=null;return hf(t[Mf(0,t.length-1,r?e=>n[e*2]:e=>hf(t[e]).start,e)])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if(`scrollHeight`in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{let e=this.scrollElement.document.documentElement;return this.options.horizontal?e.scrollWidth-this.scrollElement.innerWidth:e.scrollHeight-this.scrollElement.innerHeight}},this.getVirtualDistanceFromEnd=()=>Math.max(this.getTotalSize()-this.getSize()-this.getScrollOffset(),0),this.getDistanceFromEnd=()=>Math.max(this.getMaxScrollOffset()-this.getScrollOffset(),0),this.isAtEnd=(e=this.options.scrollEndThreshold)=>this.getDistanceFromEnd()<=e,this.getOffsetForAlignment=(e,t,n=0)=>{if(!this.scrollElement)return 0;let r=this.getSize(),i=this.getScrollOffset();t===`auto`&&(t=e>=i+r?`end`:`start`),t===`center`?e+=(n-r)/2:t===`end`&&(e-=r);let a=this.getMaxScrollOffset();return Math.max(Math.min(a,e),0)},this.getOffsetForIndex=(e,t=`auto`)=>{e=Math.max(0,Math.min(e,this.options.count-1));let n=this.getSize(),r=this.getScrollOffset(),i=this.measurementsCache[e];if(!i)return;if(t===`auto`){if(i.end>=r+n-this.options.scrollPaddingEnd)t=`end`;else if(i.start<=r+this.options.scrollPaddingStart)t=`start`;else return[r,t]}if(t===`end`&&e===this.options.count-1)return[this.getMaxScrollOffset(),t];let a=t===`end`?i.end+this.options.scrollPaddingEnd:i.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(a,t,i.size),t]},this.scrollToOffset=(e,{align:t=`start`,behavior:n=`auto`}={})=>{this._iosDeferredAdjustment=0;let r=this.getOffsetForAlignment(e,t),i=this.now();this.scrollState={index:null,align:t,behavior:n,startedAt:i,lastTargetOffset:r,stableFrames:0},this._scrollToOffset(r,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollToIndex=(e,{align:t=`auto`,behavior:n=`auto`}={})=>{this._iosDeferredAdjustment=0,e=Math.max(0,Math.min(e,this.options.count-1));let r=this.getOffsetForIndex(e,t);if(!r)return;let[i,a]=r,o=this.now();this.scrollState={index:e,align:a,behavior:n,startedAt:o,lastTargetOffset:i,stableFrames:0},this._scrollToOffset(i,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollBy=(e,{behavior:t=`auto`}={})=>{let n=this.getScrollOffset()+e,r=this.now();this.scrollState={index:null,align:`start`,behavior:t,startedAt:r,lastTargetOffset:n,stableFrames:0},this._scrollToOffset(n,{adjustments:void 0,behavior:t}),this.scheduleScrollReconcile()},this.scrollToEnd=({behavior:e=`auto`}={})=>{this.options.count>0?this.scrollToIndex(this.options.count-1,{align:`end`,behavior:e}):this.scrollToOffset(Math.max(this.getTotalSize()-this.getSize(),0),{behavior:e})},this.getTotalSize=()=>{let e=this.getMeasurements(),t;if(e.length===0)t=this.options.paddingStart;else if(this.options.lanes===1){let n=e.length-1,r=this._singleLaneMeasurements?.flat;t=r==null?e[n]?.end??0:r[n*2]+r[n*2+1]}else{let n=Array(this.options.lanes).fill(null),r=e.length-1;for(;r>=0&&n.some(e=>e===null);){let t=e[r];n[t.lane]===null&&(n[t.lane]=t.end),r--}t=Math.max(...n.filter(e=>e!==null))}return Math.max(t-this.options.scrollMargin+this.options.paddingEnd,0)},this.takeSnapshot=()=>{let e=[];if(this.itemSizeCache.size===0)return e;let t=this.getMeasurements();for(let n of t)n&&this.itemSizeCache.has(n.key)&&e.push({index:n.index,key:n.key,start:n.start,size:n.size,end:n.end,lane:n.lane});return e},this._scrollToOffset=(e,{adjustments:t,behavior:n})=>{this._intendedScrollOffset=e+(t??0),this.options.scrollToFn(e,{behavior:n,adjustments:t},this)},this.measure=()=>{this.pendingMin=null,this.itemSizeCache.clear(),this.laneAssignments.clear(),this.itemSizeCacheVersion++,this.notify(!1)},this.setOptions(e)}applyScrollAdjustment(e,t){if(e===0)return!1;if(yf()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded))return this._iosDeferredAdjustment+=e,!1;{let n=this.getScrollOffset()+this.scrollAdjustments+e,r=this.scrollElement,i=r!==null&&(`scrollHeight`in r||`document`in r)?this.getMaxScrollOffset():null;return this._clampedAdjustment=i!==null&&n>i+.5?{target:n,maxAtWrite:i}:null,this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=e,behavior:t}),this.scrollOffset!==null&&(this.scrollOffset+=this.scrollAdjustments,this.scrollOffset<0&&(this.scrollOffset=0),this.scrollAdjustments=0),!0}}scheduleScrollReconcile(){this.targetWindow?this.rafId??=this.targetWindow.requestAnimationFrame(()=>{this.rafId=null,this.reconcileScroll()}):this.scrollState=null}reconcileScroll(){if(!this.scrollState||!this.scrollElement)return;if(this.now()-this.scrollState.startedAt>5e3){this.scrollState=null;return}let e=this.scrollState.index==null?void 0:this.getOffsetForIndex(this.scrollState.index,this.scrollState.align),t=e?e[0]:this.scrollState.lastTargetOffset,n=t!==this.scrollState.lastTargetOffset;if(!n&&gf(t,this.getScrollOffset())){if(this.scrollState.stableFrames++,this.scrollState.stableFrames>=1){this.getScrollOffset()!==t&&this._scrollToOffset(t,{adjustments:void 0,behavior:`auto`}),this.scrollState=null;return}}else if(this.scrollState.stableFrames=0,n){let e=this.getSize()||600,n=Math.abs(t-this.getScrollOffset()),r=this.scrollState.behavior===`smooth`&&n>e;this.scrollState.lastTargetOffset=t,r||(this.scrollState.behavior=`auto`),this._scrollToOffset(t,{adjustments:void 0,behavior:r?`smooth`:`auto`})}this.scheduleScrollReconcile()}};let Mf=(e,t,n,r)=>{for(;e<=t;){let i=(e+t)/2|0,a=n(i);if(a<r)e=i+1;else if(a>r)t=i-1;else return i}return e>0?e-1:0};function Nf(e,t,n){let r=0;for(;r<=t;){let i=(r+t)/2|0,a=e[i*2];if(a<n)r=i+1;else if(a>n)t=i-1;else return i}return r>0?r-1:0}function Pf(e,t,n,r,i){let a=e.length-1;if(e.length<=r)return{startIndex:0,endIndex:a};if(r===1&&i!==null){let e=Nf(i,a,n),r=e,o=n+t;for(;r<a&&i[r*2]+i[r*2+1]<o;)r++;return{startIndex:e,endIndex:r}}let o=Mf(0,a,t=>e[t].start,n),s=o;if(r===1)for(;s<a&&e[s].end<n+t;)s++;else if(r>1){let i=Array(r).fill(0);for(;s<a&&i.some(e=>e<n+t);){let t=e[s];i[t.lane]=t.end,s++}let c=Array(r).fill(n+t);for(;o>=0&&c.some(e=>e>=n);){let t=e[o];c[t.lane]=t.start,o--}o=Math.max(0,o-o%r),s=Math.min(a,s+(r-1-s%r))}return{startIndex:o,endIndex:s}}let Ff=typeof document<`u`?d.useLayoutEffect:d.useEffect;function If({useFlushSync:e=!0,directDomUpdates:t=!1,directDomUpdatesMode:n=`transform`,...r}){let i=d.useReducer(e=>e+1,0)[1],a=d.useRef({enabled:t,mode:n,container:null,lastSize:null,lastPositions:/* @__PURE__ */ new WeakMap,prevRange:null});a.current.enabled=t,a.current.mode=n;let o=d.useRef(!1),s=e=>{let t=a.current;if(!t.enabled||!t.container)return;let n=e.getTotalSize();if(n!==t.lastSize){t.lastSize=n;let r=e.options.horizontal?`width`:`height`;t.container.style[r]=`${n}px`}},c=e=>{let t=a.current;if(!t.enabled||!t.container)return;s(e);let n=!!e.options.horizontal,r=t.mode===`transform`,i=n?`left`:`top`,o=e.options.scrollMargin,c=e.getVirtualItems();for(let a of c){let s=a.start-o,c=e.elementsCache.get(a.key);c&&t.lastPositions.get(c)!==s&&(t.lastPositions.set(c,s),r?c.style.transform=n?`translate3d(${s}px, 0, 0)`:`translate3d(0, ${s}px, 0)`:c.style[i]=`${s}px`)}},l={...r,onChange:(t,n)=>{var s;let l=a.current,u=!0;if(l.enabled){c(t);let e=t.range,n=l.prevRange;u=!n||n.isScrolling!==t.isScrolling||n.startIndex!==e?.startIndex||n.endIndex!==e?.endIndex,u&&(l.prevRange=e?{startIndex:e.startIndex,endIndex:e.endIndex,isScrolling:t.isScrolling}:null)}u&&(e&&n&&!o.current?(0,h.flushSync)(i):i()),(s=r.onChange)==null||s.call(r,t,n)}},[u]=d.useState(()=>{let e=new jf(l),t=e.measureElement;return e.measureElement=e=>{o.current=!0;try{t(e)}finally{o.current=!1}},Object.assign(e,{containerRef:t=>{let n=a.current;if(n.container=t,n.lastSize=null,t&&n.enabled){let r=e.getTotalSize();n.lastSize=r;let i=e.options.horizontal?`width`:`height`;t.style[i]=`${r}px`}}})});return u.setOptions(l),Ff(()=>u._didMount(),[]),Ff(()=>(s(u),u._willUpdate())),Ff(()=>{c(u)}),u}function Lf(e){return If({observeElementRect:Cf,observeElementOffset:Df,scrollToFn:kf,...e})}let Rf=`@deepseek-ai/dsh-client-ui-chat/TurnNavigator.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(Rf)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=Rf,e.textContent=`.t5gL7q_slot{z-index:7;height:0;padding-inline:calc(var(--dsh-composer-side-clearance) + 16px);pointer-events:none;position:absolute;top:0;left:0;right:0;container-type:inline-size}[data-conversation-scroll] .t5gL7q_slot{position:sticky}.t5gL7q_frame{--turn-rail-band:calc(var(--dsh-conversation-viewport-height,100dvh) - var(--dsh-composer-height,152px));--turn-preview-height:104px;top:calc(var(--turn-rail-band) / 2);width:36px;max-height:min(max(0px, calc(var(--turn-rail-band) - 64px)), 70vh, 640px);contain:layout;cursor:pointer;pointer-events:auto;position:absolute;left:12px;transform:translateY(-50%)}.t5gL7q_frame[hidden]{display:none}.t5gL7q_scroller{max-height:inherit;overscroll-behavior:contain;scrollbar-width:none;position:relative;overflow-y:auto}.t5gL7q_scroller::-webkit-scrollbar{display:none}.t5gL7q_fadeTop{mask-image:linear-gradient(#0000 0,#000 40px 100%)}.t5gL7q_fadeBottom{mask-image:linear-gradient(#000 0 calc(100% - 40px),#0000 100%)}.t5gL7q_fadeTop.t5gL7q_fadeBottom{mask-image:linear-gradient(#0000 0,#000 40px calc(100% - 40px),#0000 100%)}.t5gL7q_marks{position:relative}.t5gL7q_mark{cursor:pointer;background:0 0;border:0;border-radius:8px;height:10px;padding:0;position:absolute;top:0;left:0;right:0}.t5gL7q_mark:before{background:var(--dsw-alias-label-tertiary);opacity:.4;content:"";transform-origin:0;width:26px;height:2px;transition:transform .16s cubic-bezier(.2,.8,.2,1),background-color .16s,opacity .16s;position:absolute;top:50%;left:0;transform:translateY(-50%)scaleX(.230769)}.t5gL7q_markUnloaded:before{opacity:.25}.t5gL7q_mark[data-neighbor-distance="3"]:before{transform:translateY(-50%)scaleX(.384615)}.t5gL7q_mark[data-neighbor-distance="2"]:before{transform:translateY(-50%)scaleX(.538462)}.t5gL7q_mark[data-neighbor-distance="1"]:before{transform:translateY(-50%)scaleX(.769231)}.t5gL7q_markBusy:before{animation:1s ease-in-out infinite t5gL7q_dsh-turn-mark-busy}.t5gL7q_markActive:before{background:var(--dsw-alias-label-primary);opacity:.6}.t5gL7q_frame[data-previewing] .t5gL7q_markActive:not(.t5gL7q_markPreview):not(:focus-visible):before{background:var(--dsw-alias-label-tertiary);opacity:.4}.t5gL7q_markPreview:before{background:var(--dsw-alias-label-primary);opacity:1;transform:translateY(-50%)scaleX(1)}.t5gL7q_frame[data-scrubbing] .t5gL7q_mark:before{transition:none}.t5gL7q_mark:focus-visible:before{background:var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary));opacity:1;transform:translateY(-50%)scaleX(1)}.t5gL7q_mark:focus-visible{outline:none}.t5gL7q_mark:focus-visible:after{border-radius:inherit;outline:1px solid var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary));outline-offset:-1px;content:"";width:28px;position:absolute;inset:0 auto 0 0}.t5gL7q_preview{top:clamp(0px, calc(var(--turn-preview-center) - var(--turn-preview-height) / 2), calc(100% - var(--turn-preview-height)));box-sizing:border-box;width:min(320px,100cqw - 48px);max-height:var(--turn-preview-height);border:.5px solid var(--dsw-alias-border-l4);color:var(--dsw-alias-label-primary);background:var(--dsw-alias-bg-layer-1);box-shadow:var(--dsw-elevation-panel);pointer-events:none;border-radius:12px;padding:8px;transition:top .14s cubic-bezier(.2,.8,.2,1);animation:.12s ease-out t5gL7q_dsh-turn-preview-enter;position:absolute;left:100%;overflow:hidden}.t5gL7q_previewPrompt,.t5gL7q_previewResponse{-webkit-box-orient:vertical;display:-webkit-box;overflow:hidden}.t5gL7q_previewPrompt{-webkit-line-clamp:1;font-size:14px;font-weight:500;line-height:20px}.t5gL7q_previewResponse{color:var(--dsw-alias-label-caption);-webkit-line-clamp:3;margin-top:4px;font-size:14px;line-height:20px}@keyframes t5gL7q_dsh-turn-preview-enter{0%{opacity:0;transform:translate(-4px)}to{opacity:1;transform:translate(0)}}@keyframes t5gL7q_dsh-turn-mark-busy{0%,to{opacity:1}50%{opacity:.35}}@media (prefers-reduced-motion:reduce){.t5gL7q_frame,.t5gL7q_scroller,.t5gL7q_mark:before,.t5gL7q_markBusy:before,.t5gL7q_preview{scroll-behavior:auto;transition:none;animation:none}}`,document.head.appendChild(e)}var zf={"dsh-turn-mark-busy":`t5gL7q_dsh-turn-mark-busy`,"dsh-turn-preview-enter":`t5gL7q_dsh-turn-preview-enter`,fadeBottom:`t5gL7q_fadeBottom`,fadeTop:`t5gL7q_fadeTop`,frame:`t5gL7q_frame`,mark:`t5gL7q_mark`,markActive:`t5gL7q_markActive`,markBusy:`t5gL7q_markBusy`,markPreview:`t5gL7q_markPreview`,markUnloaded:`t5gL7q_markUnloaded`,marks:`t5gL7q_marks`,preview:`t5gL7q_preview`,previewPrompt:`t5gL7q_previewPrompt`,previewResponse:`t5gL7q_previewResponse`,scroller:`t5gL7q_scroller`,slot:`t5gL7q_slot`};function Bf(){return typeof matchMedia==`function`&&matchMedia(`(prefers-reduced-motion: reduce)`).matches?`auto`:`smooth`}let Vf=(0,d.memo)(function({item:e,index:t,active:n,busy:r,previewId:i,neighborDistance:a,registerElement:o,onNavigate:s,onPreview:c,onFocusChange:l,t:u}){let d=[zf.mark];return e.anchor.kind===`unloaded`&&d.push(zf.markUnloaded),n&&d.push(zf.markActive),a===0&&d.push(zf.markPreview),r&&d.push(zf.markBusy),/* @__PURE__ */ (0,f.jsx)(`button`,{ref:o,"data-index":t,"data-neighbor-distance":a,type:`button`,className:d.join(` `),"aria-label":u(e.anchor.kind===`loaded`?`chat.turnNavigation.jump`:`chat.turnNavigation.jumpLoad`,{turn:t+1}),"aria-current":n?`true`:void 0,"aria-busy":r?`true`:void 0,"aria-describedby":i,onPointerMove:t=>{t.buttons===0&&c(e.turn)},onClick:()=>{s(e)},onFocus:()=>{l(e.turn)},onBlur:()=>{l(null)}})});function Hf({items:e,activeTurn:t,busyTurn:n,onNavigate:r,t:i},a){let[o,s]=(0,d.useState)(null),[c,l]=(0,d.useState)(null),[u,p]=(0,d.useState)(!1),[m,h]=(0,d.useState)(!1),[g,_]=(0,d.useState)(!1),v=(0,d.useRef)(null),y=(0,d.useRef)(null),ee=(0,d.useRef)(!1),b=(0,d.useRef)(void 0),te=(0,d.useRef)(null),x=(0,d.useRef)({placed:!1,index:0,follow:null,publishOffset:null}),S=(0,d.useRef)(!1),C=(0,d.useId)(),w=e.length>=2;(0,d.useLayoutEffect)(()=>{let e=v.current,t=e?.parentElement?.querySelector(`[data-chat-flow]`),n=e?.closest(`[data-conversation-scroll]`)??e?.parentElement;if(!t||!n)return;let r=()=>{let e=n.getBoundingClientRect(),r=n.offsetWidth>0?e.width/n.offsetWidth:1;h((t.getBoundingClientRect().left-e.left)/(r||1)>=48)},i=new ResizeObserver(r);return i.observe(t),i.observe(n),r(),()=>i.disconnect()},[w]),(0,d.useEffect)(()=>{if(o===null){p(!1);return}if(u)return;let e=setTimeout(()=>p(!0),150);return()=>clearTimeout(e)},[o,u]),(0,d.useEffect)(()=>()=>{clearTimeout(b.current);let e=y.current;y.current=null,e?.button.hasPointerCapture(e.pointerId)&&e.button.releasePointerCapture(e.pointerId)},[]);let T=(0,d.useMemo)(()=>{let t=/* @__PURE__ */ new Map;return e.forEach((e,n)=>{t.set(e.turn,n)}),t},[e]),E=t===null?void 0:T.get(t);(0,d.useLayoutEffect)(()=>{x.current.index=E??0},[E]);let ne=c===null?void 0:T.get(c),re=o===null?void 0:T.get(o),ie=(0,d.useCallback)(e=>{l(e),s(e),p(e!==null)},[]),D=Lf({count:e.length,enabled:w,directDomUpdates:!0,directDomUpdatesMode:`transform`,useScrollendEvent:!0,getScrollElement:(0,d.useCallback)(()=>te.current,[]),getItemKey:(0,d.useCallback)(t=>e[t]?.turn??t,[e]),estimateSize:()=>10,measureElement:()=>10,initialRect:{width:0,height:0},initialOffset:0,scrollToFn:(e,t,n)=>{x.current.placed&&kf(e,t,n)},observeElementOffset:(e,t)=>{x.current.publishOffset=t;let n=Df(e,t);return()=>{n?.(),x.current.placed=!1,x.current.follow=null,x.current.publishOffset=null}},observeElementRect:(e,t)=>{let n=e.scrollElement,r=e.targetWindow?.ResizeObserver;if(n===null||r===void 0)return;let i=new r(([r])=>{if(r===void 0)return;let i=r.borderBoxSize[0],a={width:Math.round(i?.inlineSize??r.contentRect.width),height:Math.round(i?.blockSize??r.contentRect.height)},o=x.current;if(!o.placed&&a.height>0){let t=Math.max(0,e.getTotalSize()-a.height),r=o.index*10+6,i=Math.max(0,Math.min(t,r-a.height/2));o.placed=!0,o.follow={index:o.index,count:e.options.count,height:a.height},n.scrollTop=i,o.publishOffset?.(i,!1)}t(a)});return i.observe(n,{box:`border-box`}),()=>{i.disconnect()}},paddingStart:1,paddingEnd:1,scrollPaddingStart:40,scrollPaddingEnd:40,overscan:3,rangeExtractor:(0,d.useCallback)(e=>{let t=Sf(e);if(ne!==void 0){let n=Math.min(e.count-1,ne+1);for(let e=Math.max(0,ne-1);e<=n;e++)t.includes(e)||t.push(e);t.sort((e,t)=>e-t)}return t},[ne])}),ae=D.scrollOffset??0,O=D.scrollRect?.height??0,oe=D.getVirtualItems(),k=(0,d.useCallback)((e,t,n=Bf())=>{let r=D.measurementsCache[e],i=D.scrollRect?.height??0;if(r===void 0||i<=0)return;let a=D.scrollOffset??0,o=r.start+r.size/2;if(t===`if-needed`){let{scrollPaddingStart:e,scrollPaddingEnd:t}=D.options;if(o>=a+e&&o<=a+i-t)return}let s=o-i/2,c=Math.max(0,D.getTotalSize()-i),l=Math.max(0,Math.min(c,s))-a;l!==0&&D.scrollBy(l,{behavior:n})},[D]);(0,d.useImperativeHandle)(a,()=>({activateTurn(t){let n=T.get(t),i=n===void 0?void 0:e[n];i!==void 0&&r(i)},scrollToTurn(e){let t=T.get(e);t!==void 0&&k(t,`always`)}}),[e,T,r,k]),(0,d.useEffect)(()=>{if(O<=0){x.current.follow=null;return}if(E===void 0||S.current)return;let t=x.current.follow;if(t?.index===E&&t.count===e.length&&t.height===O)return;x.current.follow={index:E,count:e.length,height:O};let n=t?.count===e.length&&t.height===O?Bf():`instant`;k(E,`if-needed`,n)},[E,e.length,O,k]);let se=(0,d.useCallback)(e=>{ee.current?ee.current=!1:r(e)},[r]),ce=t=>{if(t.button!==0||!(t.target instanceof Element))return;let n=t.target.closest(`button[data-index]`);if(!n||!te.current?.contains(n))return;let r=e[Number(n.dataset.index)];r&&(clearTimeout(b.current),ee.current=!1,y.current={pointerId:t.pointerId,button:n,turn:r.turn,moved:!1},n.setPointerCapture(t.pointerId),_(!0),s(r.turn),p(!0))},le=t=>{let n=y.current,i=te.current;if(!n||!i||t.pointerId!==n.pointerId||!(t.buttons&1))return;let a=i.getBoundingClientRect(),o=Math.max(a.top,Math.min(t.clientY,a.bottom-1)),c=e[Math.max(0,Math.min(e.length-1,Math.round((o-a.top+i.scrollTop-6)/10)))];c&&c.turn!==n.turn&&(n.turn=c.turn,n.moved=!0,s(c.turn),c.anchor.kind===`loaded`&&r(c))},ue=e=>{let t=y.current;t&&e.pointerId===t.pointerId&&(y.current=null,_(!1),ee.current=t.moved,t.button.hasPointerCapture(e.pointerId)&&t.button.releasePointerCapture(e.pointerId),b.current=setTimeout(()=>{ee.current=!1},0),S.current||s(null))};if(!w)return null;let de=!u||re===void 0?void 0:e[re],fe=oe.find(e=>e.index===re),pe=[zf.scroller];return ae>1&&pe.push(zf.fadeTop),ae<D.getTotalSize()-O-1&&pe.push(zf.fadeBottom),/* @__PURE__ */ (0,f.jsx)(`div`,{ref:v,className:zf.slot,children:/* @__PURE__ */ (0,f.jsxs)(`nav`,{className:zf.frame,hidden:!m,"data-turn-navigation":``,"data-previewing":re!==void 0||void 0,"data-scrubbing":g||void 0,onPointerDownCapture:ce,onPointerMove:le,onPointerUpCapture:ue,onPointerCancelCapture:ue,onLostPointerCapture:ue,"aria-label":i(`chat.turnNavigation.label`),onPointerEnter:()=>{S.current=!0},onPointerLeave:()=>{S.current=!1,y.current||s(null)},children:[/* @__PURE__ */ (0,f.jsx)(`div`,{ref:te,className:pe.join(` `),children:/* @__PURE__ */ (0,f.jsx)(`div`,{ref:D.containerRef,className:zf.marks,children:oe.map(({index:r,key:a})=>{let c=e[r];return c===void 0?null:/* @__PURE__ */ (0,f.jsx)(Vf,{item:c,index:r,active:c.turn===t,busy:c.turn===n,previewId:u&&c.turn===o?C:void 0,neighborDistance:re!==void 0&&Math.abs(r-re)<=3?Math.abs(r-re):void 0,registerElement:D.measureElement,onNavigate:se,onPreview:s,onFocusChange:ie,t:i},a)})})}),de!==void 0&&fe!==void 0&&/* @__PURE__ */ (0,f.jsxs)(`div`,{id:C,role:`tooltip`,className:zf.preview,style:{"--turn-preview-center":`${String(fe.start+fe.size/2-ae)}px`},children:[/* @__PURE__ */ (0,f.jsx)(`div`,{className:zf.previewPrompt,children:de.prompt||i(`chat.turnNavigation.turn`,{turn:(re??0)+1})}),de.response!==``&&/* @__PURE__ */ (0,f.jsx)(`div`,{className:zf.previewResponse,children:de.response})]})]})})}let Uf=(0,d.memo)((0,d.forwardRef)(Hf));function Wf(){return/* @__PURE__ */ (0,f.jsx)(`span`,{className:Y.runningIcon,"aria-hidden":`true`,children:/* @__PURE__ */ (0,f.jsx)(`span`,{className:Y.runningIconMotion,children:/* @__PURE__ */ (0,f.jsxs)(`svg`,{width:`100%`,height:`100%`,viewBox:`2 2 20 20`,fill:`none`,stroke:`currentColor`,strokeWidth:1.2,strokeLinecap:`round`,strokeLinejoin:`round`,children:[/* @__PURE__ */ (0,f.jsx)(`path`,{d:`M16.1 5.3C11.8 2.9 6.6 5 5.1 9.4c-1.8 5.4 1.7 10.2 6.9 10.3 4.8.2 8-3.8 7.2-8.3-.4 3.2-2 5.1-4.2 5.8`}),/* @__PURE__ */ (0,f.jsx)(`rect`,{x:`9.5`,y:`9.1`,width:`4.6`,height:`4.6`,rx:`1`,transform:`rotate(-10 11.8 11.4)`})]})})})}let Gf=`@deepseek-ai/dsh-client-ui-chat/accessibility.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(Gf)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=Gf,e.textContent=`.Tawwdq_visuallyHidden{clip:rect(0 0 0 0);white-space:nowrap;width:1px;height:1px;position:absolute;overflow:hidden}`,document.head.appendChild(e)}var Kf={visuallyHidden:`Tawwdq_visuallyHidden`};let qf=(0,d.memo)(function({startTime:e,compacting:t,stale:n,t:r}){let[i,a]=(0,d.useState)(Date.now);(0,d.useEffect)(()=>{if(e===void 0||t||n)return;a(Date.now());let r=setInterval(()=>{a(Date.now())},1e3);return()=>{clearInterval(r)}},[e,t,n]);let o=n?r(`chat.statusUnconfirmed`):t?r(`message.compaction.running`):e===void 0?r(`chat.deepDiving`):r(`chat.deepDivingFor`,{duration:Xu(Math.max(1e3,i-e),r).map(e=>e.text).join(``)});return/* @__PURE__ */ (0,f.jsxs)(`div`,{className:Y.running,"data-chat-running":!0,children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:Kf.visuallyHidden,role:`status`,"aria-live":`polite`,"aria-atomic":`true`,children:r(n?`chat.statusUnconfirmed`:t?`message.compaction.running`:`chat.deepDiving`)}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:Y.runningDivider,"aria-hidden":`true`}),/* @__PURE__ */ (0,f.jsxs)(`span`,{className:Y.runningContent,children:[n?null:/* @__PURE__ */ (0,f.jsx)(Wf,{}),/* @__PURE__ */ (0,f.jsx)(p.TextShimmer,{active:!n,className:Y.runningText,children:o})]})]})});function Jf(e){return e}function Yf(e){return e}function Xf(e){if(!Number.isSafeInteger(e)||e<0||Object.is(e,-0))throw TypeError(`SessionSeq must be a non-negative safe integer, got ${String(e)}`);return Yf(e)}let Zf=[];function Qf(e){if(typeof e!=`object`||!e)return;let t=e;if(!(typeof t.turn!=`number`||!Number.isSafeInteger(t.turn)||t.turn<0)&&!(typeof t.seq!=`number`||!Number.isSafeInteger(t.seq)||t.seq<0||Object.is(t.seq,-0)))return{turn:t.turn,seq:Xf(t.seq),prompt:typeof t.prompt==`string`?t.prompt:``,response:typeof t.response==`string`?t.response:``}}function $f(e){return Array.isArray(e)?e:Zf}function ep(e,t){let n=/* @__PURE__ */ new Map;for(let e of $f(t)){let t=Qf(e);t!==void 0&&n.set(t.turn,{turn:t.turn,prompt:t.prompt,response:t.response,anchor:{kind:`unloaded`,seq:t.seq}})}for(let t of e){let e=n.get(t.turn);n.set(t.turn,{turn:t.turn,prompt:t.prompt===``?e?.prompt??``:t.prompt,response:t.response===``?e?.response??``:t.response,anchor:{kind:`loaded`,key:t.anchorKey}})}return n.size===0?Zf:[...n.values()].sort((e,t)=>e.turn-t.turn)}var tp=class{viewport;reading;input;onBusyTurn;jump=null;settleFrame=null;requestedHead;constructor(e,t,n,r){this.viewport=e,this.reading=t,this.input=n,this.onBusyTurn=r}setInput(e){this.input=e}reset(){this.requestedHead=void 0,this.cancel()}dispose(){this.clearTask()}cancel(){this.clearTask(),this.onBusyTurn(null)}clearTask(){this.cancelFrame(),this.jump=null,this.viewport.stopPreserving()}navigateToTurn=e=>{if(e.anchor.kind===`loaded`){this.cancel();let t=this.viewport.scrollToTurn(e.turn);if(t===null)return;this.reading.acceptNavigation(t),this.input.loadingOlder&&this.viewport.beginPreserving(t.position);return}if(!this.input.historyReady)return;this.cancel(),this.viewport.beginPreserving(),this.reading.pauseFollowing();let t={turn:e.turn,seq:e.anchor.seq,phase:`loading`,landing:`pending`,repageHead:null};this.jump=t,this.onBusyTurn(t.turn),this.request(t)};autoLoadEarlier=()=>{if(this.jump!==null||this.input.olderFailed||this.requestedHead===this.input.firstSeq)return;let e=this.viewport.readScroll();e===null||e.metrics.top>240||this.loadEarlier()};loadEarlier=()=>{this.input.historyReady&&this.input.hasMore&&!this.input.loadingOlder&&(this.requestedHead=this.input.firstSeq,this.cancel(),this.viewport.beginPaging(),this.reading.pauseFollowing(),this.input.loadOlder())};readerSampled(e){e.movedByReader&&this.jump?.landing===`landed`&&(this.jump.landing=`interrupted`),(e.followingTail||e.movedByReader)&&this.viewport.stopPreserving()}contentCommitted(){if(!this.viewport.preserving||this.reading.pending)return!1;if(this.landJump(!1))return!0;let e=this.viewport.preserve();return e!==null&&(this.reading.preservePosition(e),!0)}readerSettled(){this.input.loadingOlder&&this.jump===null&&!this.viewport.preserving&&!this.reading.followingTail&&this.viewport.beginPreserving()}reconcile(){let e=this.jump;if(!this.input.historyReady||e===null||this.reading.pending)return;if(e.phase===`loading`){e.landing===`pending`&&this.landJump(!1);return}if(this.input.loadingOlder||this.landJump(!0))return;if((this.input.firstSeq===null||this.input.firstSeq>e.seq)&&this.input.hasMore&&e.repageHead!==this.input.firstSeq){e.repageHead=this.input.firstSeq,this.viewport.beginPreserving(),this.request(e);return}let t=this.viewport.scrollToTurnAtOrAfter(e.turn);this.cancel(),t!==null&&this.reading.acceptNavigation(t)}landJump(e){let t=this.jump;if(t===null)return!1;if(t.landing===`interrupted`)return e?(this.cancel(),!0):!1;let n=this.viewport.scrollToTurn(t.turn);return n!==null&&(this.reading.acceptNavigation(n),e?this.cancel():(this.viewport.beginPreserving(n.position),t.landing=`landed`),!0)}request(e){e.phase=`loading`;let t=()=>{this.jump===e&&(e.phase=`settled`,this.cancelFrame(),typeof requestAnimationFrame==`function`?this.settleFrame=requestAnimationFrame(()=>{this.settleFrame=null,this.jump===e&&this.reconcile()}):this.reconcile())};this.input.loadThrough(e.seq).then(t,t)}cancelFrame(){this.settleFrame!==null&&typeof cancelAnimationFrame==`function`&&cancelAnimationFrame(this.settleFrame),this.settleFrame=null}};function np(e,t,n){let[r,i]=(0,d.useState)(null),[a]=(0,d.useState)(()=>new tp(e,t,n,i));return(0,d.useLayoutEffect)(()=>{a.setInput(n)},[a,n]),(0,d.useLayoutEffect)(()=>()=>{a.dispose()},[a]),{navigation:a,busyTurn:r}}var rp=class{viewport;store;state;onChange;follow;sampleTimer=null;probeFrame=null;sampled=null;constructor(e,t,n,r,i){this.viewport=e,this.store=t,this.state=n,this.onChange=r,this.follow=i}get pending(){return this.sampleTimer!==null}get followingTail(){return this.state.followingTail}setStore(e){this.store=e}connect(e){return this.sampled=e,()=>{this.sampled===e&&(this.sampled=null)}}dispose(){this.cancelPending(),this.sampled=null}pauseFollowing(){this.cancelPending(),this.publish({...this.state,followingTail:!1})}followTail(){let e=this.viewport.scrollToBottom(this.follow);e!==null&&(this.cancelPending(),this.commit(e,!0,this.viewport.latestTurn))}restore(){let e=this.store.read();if(e===null){this.followTail();return}let t=this.viewport.restore(e);if(t===null)return;this.cancelPending();let n=this.follow.nearBottom(t.metrics);if(this.commit(t,n,n?this.viewport.latestTurn:this.state.activeTurn,n),!this.state.followingTail&&t.position===null){let e=this.viewport.capturePosition();e!==null&&this.store.save(e)}this.refreshActiveTurn()}acceptNavigation(e){this.cancelPending();let t=this.follow.nearBottom(e.metrics);this.commit(e,t,e.turn??(t?this.viewport.latestTurn:this.state.activeTurn))}preservePosition(e){this.cancelPending(),this.commit(e,this.state.followingTail,this.state.activeTurn)}onScroll=e=>{!e.movedByReader&&this.state.followingTail||e.movedByReader&&e.metrics.top>=e.metrics.floor?(this.followTail(),this.sampled?.({position:null,movedByReader:e.movedByReader,followingTail:!0})):this.sampleTimer??=window.setTimeout(this.flushSample,500)};onScrollEnd=()=>{this.flushSample()};onResize(){this.pending||(this.state.followingTail?this.followTail():this.refreshActiveTurn())}refreshActiveTurn(){this.pending||(this.state.followingTail?this.publish({...this.state,initialized:!0,activeTurn:this.viewport.latestTurn}):this.probeFrame===null&&(typeof requestAnimationFrame==`function`?this.probeFrame=requestAnimationFrame(this.probe):this.probe()))}commit(e,t,n,r=!0){t?this.store.save(null):e.position!==null&&this.store.save(e.position),this.publish({initialized:r,followingTail:t,activeTurn:n})}publish(e){this.follow.setFollowing(e.followingTail),(e.initialized!==this.state.initialized||e.followingTail!==this.state.followingTail||e.activeTurn!==this.state.activeTurn)&&(this.state=e,this.onChange(e))}cancelPending(){this.sampleTimer!==null&&window.clearTimeout(this.sampleTimer),this.probeFrame!==null&&typeof cancelAnimationFrame==`function`&&cancelAnimationFrame(this.probeFrame),this.sampleTimer=null,this.probeFrame=null}probe=()=>{if(this.probeFrame=null,this.pending)return;let e=this.viewport.readScroll();if(e===null)return;let t=this.follow.nearBottom(e.metrics)?this.viewport.latestTurn:this.viewport.readVisibleTurn(e.metrics);this.publish({...this.state,initialized:!0,activeTurn:t})};flushSample=()=>{if(!this.pending)return;this.cancelPending();let e=this.viewport.readScroll();if(e===null)return;let t=this.follow.sample(e.metrics,e.movedByReader),n=null;if(!e.movedByReader&&t)this.followTail();else{n=t?null:this.viewport.capturePosition(),this.viewport.acknowledge(e.metrics),(t||n!==null)&&this.store.save(n);let r=this.follow.nearBottom(e.metrics)?this.viewport.latestTurn:this.viewport.readVisibleTurn(e.metrics);this.publish({initialized:!0,followingTail:t,activeTurn:r})}this.sampled?.({position:n,movedByReader:e.movedByReader,followingTail:t})}};function ip(e,t,n){let[r,i]=(0,d.useState)(()=>({initialized:!1,followingTail:t.read()===null,activeTurn:n})),a=$d(r.followingTail,25),[o]=(0,d.useState)(()=>new rp(e,t,r,i,a));return(0,d.useLayoutEffect)(()=>{o.setStore(t)},[o,t]),(0,d.useLayoutEffect)(()=>()=>{o.dispose()},[o]),{reading:o,state:r}}let ap=[`wheel`,`touchstart`,`touchmove`,`touchend`,`touchcancel`,`pointerdown`,`keydown`,`beforematch`],op=/* @__PURE__ */ new Set([`ArrowUp`,`ArrowDown`,`PageUp`,`PageDown`,`Home`,`End`,` `]);var sp=class{elements=null;observer=null;events=null;turns=[];observation={top:0,landing:null};paging=null;touchY=null;attach(e,t){this.detach();let n=e.closest(`[data-conversation-scroll]`)??e,r=n.querySelector(`[data-composer-seat]`),i={list:e,column:t,scroller:n,composer:r};this.elements=i,n.addEventListener(`scroll`,this.onScroll,{passive:!0}),n.addEventListener(`scrollend`,this.onScrollEnd,{passive:!0,capture:!0});for(let e of ap)n.addEventListener(e,this.onIntent,{passive:!0,capture:!0});typeof ResizeObserver<`u`&&(this.observer=new ResizeObserver(()=>{this.elements===i&&(this.invalidate(),this.events?.resize())}),this.observer.observe(t),this.observer.observe(n),r!==null&&this.observer.observe(r))}detach(){this.stopPreserving(),this.elements?.scroller.removeEventListener(`scroll`,this.onScroll),this.elements?.scroller.removeEventListener(`scrollend`,this.onScrollEnd,!0);for(let e of ap)this.elements?.scroller.removeEventListener(e,this.onIntent,!0);this.observer?.disconnect(),this.observer=null,this.elements=null,this.events=null,this.turns=[],this.touchY=null,this.observation={top:0,landing:null}}connect(e){return this.events=e,()=>{this.events===e&&(this.events=null)}}updateTurns(e){this.turns=e}get latestTurn(){return this.turns.at(-1)?.turn??null}invalidate(){this.observation.landing=null}acknowledge(e){this.observation={top:e.top,landing:null}}readScroll(){let e=this.metrics();return e===null?null:{metrics:e,movedByReader:Math.abs(e.top-Math.min(this.observation.top,e.floor))>.5,towardStart:e.top<Math.min(this.observation.top,e.floor)-.5}}metrics(){let e=this.elements?.scroller;return e===void 0?null:Zd(e)}anchor(e,t=`position`){if(this.elements===null)return null;let n=null;for(let r of this.elements.list.querySelectorAll(`[data-chat-anchor-key]:not([hidden]):not([hidden] *)`)){if(r.dataset.chatAnchorKey===e||t===`node`&&r.dataset.chatNodeKey===e)return r;n===null&&r.dataset.chatNodeKey===e&&(n=r)}return n}capturePosition(){let e=this.elements;if(e===null)return null;let{list:t,scroller:n,composer:r}=e,i=n.getBoundingClientRect(),a=r?.getBoundingClientRect().top??i.bottom,o=null;if(typeof document.elementsFromPoint==`function`&&a>i.top){let e=t.getBoundingClientRect(),n=Math.max(i.left,e.left),r=Math.min(i.right,e.right);for(let e of document.elementsFromPoint(n+Math.max(0,r-n)/2,i.top+1)){let n=e instanceof HTMLElement?e.closest(`[data-chat-anchor-key]`):null;if(n!==null&&n.dataset.chatFlowKind!==`turn-process`&&t.contains(n)){o=n.dataset.chatGroupKey===void 0?n:n.querySelector(`[data-step-process-content] > [data-chat-anchor-key]:not(:empty):not([hidden]):not([hidden] *)`)??n;break}}}if(o===null){let e=t.querySelectorAll(`[data-chat-flow-key]:not([data-chat-group-key]):not([data-chat-flow-kind="turn-process"]):not(:empty):not([hidden]):not([hidden] *)`),n=0,r=e.length;for(;n<r;){let t=n+r>>>1;e.item(t).getBoundingClientRect().bottom>i.top?r=t:n=t+1}let s=e[n];o=s!==void 0&&s.getBoundingClientRect().top<a?s:e[0]??null}let s=o?.dataset.chatAnchorKey;return o===null||s===void 0?null:{anchorKey:s,anchorTop:o.getBoundingClientRect().top-i.top,scrollTop:n.scrollTop}}readVisibleTurn(e=this.metrics()){let t=this.observation.landing?.turn;if(t!=null&&e?.top===this.observation.top)return t;let n=this.elements,r=this.turns[0];if(n===null||e===null||r===void 0)return null;let i=n.scroller.getBoundingClientRect().top+Math.min(96,e.height*.2),a=n.column.children,o=0,s=a.length,c=r.turn;for(;o<s;){let e=o+s>>>1,t=a[e];if(t.getBoundingClientRect().top>i)s=e;else{let n=t.getAttribute(`data-chat-turn`),r=n===null?NaN:Number(n);Number.isSafeInteger(r)&&(c=r),o=e+1}}return c}scrollToTurn(e){let t=this.turns.find(t=>t.turn===e);if(t===void 0)return null;let n=this.anchor(t.anchorKey,`node`);return n===null?null:this.align(n,24,e)}scrollToTurnAtOrAfter(e){if(this.elements===null)return null;for(let t of this.elements.list.querySelectorAll(`[data-chat-turn]:not([hidden]):not([hidden] *)`)){let n=Number(t.dataset.chatTurn);if(Number.isSafeInteger(n)&&n>=e)return this.align(t,24,n)}return null}restore(e){let t=this.anchor(e.anchorKey);if(t!==null)return this.align(t,e.anchorTop,null);let n=this.metrics();return n===null?null:this.write(e.scrollTop,n,null)}beginPaging(){this.stopPreserving();let e=this.elements?.list.querySelector(`[data-chat-paging-anchor]:not(:empty):not([hidden]):not([hidden] *)`);e!=null&&this.retain(e)}beginPreserving(e=this.capturePosition()){if(this.stopPreserving(),e===null)return;let t=this.anchor(e.anchorKey);t!==null&&this.retain(t,e)}retain(e,t,n){let r=this.elements,i=e.dataset.chatAnchorKey;if(r===null||i===void 0)return null;let a=this.paging?.group;a!=null&&this.observer?.unobserve(a.content);let o=e.getBoundingClientRect().top,s=e.closest(`[data-step-process-body]`),c=s?.querySelector(`[data-step-process-content]`),l=s===null||c==null?null:{body:s,content:c,top:n??o-s.getBoundingClientRect().top};return this.paging={row:e,group:l,position:t??{anchorKey:i,anchorTop:o-r.scroller.getBoundingClientRect().top,scrollTop:r.scroller.scrollTop}},l!==null&&this.observer?.observe(l.content),this.paging}stopPreserving(){let e=this.paging?.group;e!=null&&this.observer?.unobserve(e.content),this.paging=null}get preserving(){return this.paging!==null}preserve(){let e=this.paging,t=this.elements;if(e===null||t===null)return null;if(!t.list.contains(e.row)){let t=this.anchor(e.position.anchorKey);if(t===null)return this.stopPreserving(),null;if(e=this.retain(t,e.position,e.group?.top),e===null)return null}let{row:n,group:r,position:i}=e;if(n.closest(`[hidden]`)!==null||n.matches(`:empty`))return this.stopPreserving(),null;if(r!==null&&r.body.contains(n)){let e=n.getBoundingClientRect().top-r.body.getBoundingClientRect().top,t=Zd(r.body),i=Math.max(0,Math.min(t.floor,t.top+e-r.top));if(t.top!==i){let e=Qd.forElement(r.body);e===void 0?r.body.scrollTop=i:(e.jump(r.body,t,i),e.setFollowing(!1))}}let a=this.metrics();if(a===null)return null;let o=n.getBoundingClientRect().top-t.scroller.getBoundingClientRect().top,s=a.top+o-i.anchorTop;return this.write(s,a,null,{key:i.anchorKey,top:o})}scrollToBottom(e){let t=this.metrics();if(t===null||this.elements===null)return null;let n={metrics:t.top>t.floor?t:e.toBottom(this.elements.scroller,t,`instant`),position:null,turn:this.latestTurn};return this.observation={top:n.metrics.top,landing:n},n}align(e,t,n){let r=this.metrics();if(r===null||this.elements===null)return null;let i=e.getBoundingClientRect().top-this.elements.scroller.getBoundingClientRect().top;return this.write(r.top+i-t,r,n,{key:e.dataset.chatAnchorKey,top:i})}write(e,t,n,r){if(this.elements===null)return null;let i=Math.max(0,Math.min(t.floor,e));i!==t.top&&(this.elements.scroller.scrollTop=i);let a=this.elements.scroller.scrollTop,o={metrics:{...t,top:a},turn:n,position:r?.key===void 0?null:{anchorKey:r.key,anchorTop:r.top-(a-t.top),scrollTop:a}};return this.observation={top:a,landing:o},o}onScroll=e=>{if(this.elements===null||e.target!==this.elements.scroller||this.observation.landing!==null&&this.elements.scroller.scrollTop===this.observation.top)return;this.invalidate();let t=this.readScroll();t!==null&&this.events?.scroll(t)};onScrollEnd=e=>{(e.target===this.elements?.scroller||e.target instanceof HTMLElement&&e.target.hasAttribute(`data-step-process-body`))&&this.events?.scrollEnd()};onIntent=e=>{if(e.type===`touchend`||e.type===`touchcancel`){this.touchY=null;return}if(e.target instanceof Element&&e.target.closest(`[data-composer-seat], [data-turn-navigation], input, textarea, [contenteditable="true"]`)||e.type===`keydown`&&(!(e instanceof KeyboardEvent)||!op.has(e.key)))return;let t=e instanceof WheelEvent?e.deltaY<0:e instanceof KeyboardEvent&&([`ArrowUp`,`PageUp`,`Home`].includes(e.key)||e.key===` `&&e.shiftKey);if(typeof TouchEvent<`u`&&e instanceof TouchEvent){let n=e.touches[0]?.clientY;if(t=e.type===`touchmove`&&n!==void 0&&this.touchY!==null&&n>this.touchY,this.touchY=n??null,e.type===`touchstart`)return}if(!(e instanceof PointerEvent&&e.pointerType===`touch`)){if(t&&e.target instanceof Element){for(let n=e.target;n&&n!==this.elements?.scroller;n=n.parentElement)if(n instanceof HTMLElement&&n.scrollTop>0&&n.scrollHeight>n.clientHeight&&/auto|scroll/.test(getComputedStyle(n).overflowY)){t=!1;break}}this.paging!==null&&!(t&&this.observation.top<=0&&(this.elements?.scroller.scrollTop??0)<=0)&&(this.stopPreserving(),this.events?.interact()),t&&this.events?.olderIntent()}}};function cp(){let e=(0,d.useRef)(null),t=(0,d.useRef)(null),[n]=(0,d.useState)(()=>new sp);return(0,d.useLayoutEffect)(()=>{if(e.current!==null&&t.current!==null)return n.attach(e.current,t.current),()=>{n.detach()}},[n]),{viewport:n,listRef:e,columnRef:t}}function lp(e){let{displayReady:t,historyReady:n,order:r,firstSeq:i,lastKey:a,lastIsUser:o,steeringId:s,submissionId:c,running:l,loadedTurns:u,chatScroll:f,hasMore:p,loadingOlder:m,olderFailed:h,loadOlder:g,loadThrough:_}=e,{viewport:v,listRef:y,columnRef:ee}=cp(),{reading:b,state:te}=ip(v,f,u.at(-1)?.turn??null),x=(0,d.useMemo)(()=>({historyReady:n,firstSeq:i,loadingOlder:m,olderFailed:h,hasMore:p,loadOlder:g,loadThrough:_}),[n,i,m,h,p,g,_]),{navigation:S,busyTurn:C}=np(v,b,x),w=(0,d.useRef)({input:e,applied:null,opened:!1}),T=(0,d.useCallback)(()=>{let e=w.current.input,t=w.current.applied,n=e.lastIsUser&&e.lastKey!==t?.lastKey||e.steeringId!==null&&e.steeringId!==t?.steeringId&&e.steeringId!==t?.submissionId||e.submissionId!==null&&e.submissionId!==t?.submissionId&&e.submissionId!==t?.steeringId;(!b.pending||n)&&(w.current.applied=e,e.displayReady&&!w.current.opened?(w.current.opened=!0,S.reset(),b.restore()):n?(S.cancel(),b.followTail()):S.contentCommitted()?S.reconcile():(t===null||e.displayReady!==t.displayReady||e.firstSeq!==t.firstSeq||e.lastKey!==t.lastKey||e.order.length!==t.order.length||e.running!==t.running||e.steeringId!==t.steeringId||e.submissionId!==t.submissionId)&&b.followingTail?(S.cancel(),b.followTail()):S.reconcile())},[b,S]);(0,d.useLayoutEffect)(()=>{let e=null,t=()=>{e===null&&w.current.opened&&w.current.input.historyReady&&(e=requestAnimationFrame(()=>{e=null,w.current.opened&&w.current.input.historyReady&&S.autoLoadEarlier()}))},n=v.connect({scroll:e=>{b.onScroll(e),e.movedByReader&&e.towardStart&&t()},olderIntent:t,scrollEnd:()=>{b.onScrollEnd(),S.readerSettled()},interact:()=>{S.cancel()},resize:()=>{S.contentCommitted()||b.onResize(),S.reconcile()}}),r=b.connect(e=>{S.readerSampled(e),T()});return()=>{e!==null&&cancelAnimationFrame(e),n(),r(),w.current.opened=!1,w.current.applied=null}},[v,b,S,T]),(0,d.useLayoutEffect)(()=>{let e=w.current.input;w.current.input={displayReady:t,order:r,lastKey:a,lastIsUser:o,steeringId:s,submissionId:c,running:l,loadedTurns:u,chatScroll:f,...x},v.updateTurns(u);let n=e.order!==r||e.displayReady!==t;n&&v.invalidate(),T(),n&&b.refreshActiveTurn()},[v,b,T,x,t,r,a,o,s,c,l,u,f]);let E=(0,d.useCallback)(()=>{S.cancel(),b.followTail()},[S,b]);return{listRef:y,columnRef:ee,...te,busyTurn:C,navigateToTurn:S.navigateToTurn,loadEarlier:S.loadEarlier,returnToBottom:E}}let up=`@deepseek-ai/dsh-client-ui-chat/SelectionActions.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(up)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=up,e.textContent=`.QtzT2q_popover{z-index:30;background:#000;border:.5px solid #ffffff38;border-radius:9999px;animation:.14s cubic-bezier(.175,.885,.32,1.275) QtzT2q_selection-island-in;display:flex;position:fixed;overflow:hidden;box-shadow:inset 0 1px #ffffff52,0 6px 18px #000000bf,0 2px 6px #0006}.QtzT2q_action{color:#f5f5f7;letter-spacing:-.01em;white-space:nowrap;cursor:pointer;background:0 0;border:none;border-radius:9999px;align-items:center;gap:5px;height:25px;padding:0 9px;font-family:-apple-system,BlinkMacSystemFont,SF Pro Text,system-ui,sans-serif;font-size:11.5px;font-weight:500;transition:background-color .12s,transform .12s cubic-bezier(.175,.885,.32,1.275);display:inline-flex}.QtzT2q_action svg{color:#fff;flex-shrink:0}.QtzT2q_action:hover{background:#ffffff1f}.QtzT2q_action:active{background:#fff3;transform:scale(.96)}@keyframes QtzT2q_selection-island-in{0%{opacity:0;scale:.9}to{opacity:1;scale:1}}`,document.head.appendChild(e)}var dp={action:`QtzT2q_action`,popover:`QtzT2q_popover`,"selection-island-in":`QtzT2q_selection-island-in`};let fp=[`[data-code-block-controls]`,`[data-selection-actions]`,`[contenteditable='true']`].join(`,`);function pp(e){if(e===null||typeof window>`u`)return;let t=window.getSelection();if(t===null||t.rangeCount===0||t.isCollapsed)return;let n=t.getRangeAt(0),r=t=>{let n=t instanceof Element?t:t?.parentElement??void 0;if(n==null)return;let r=n.closest(`[data-selection-answer]`);return r!==null&&e.contains(r)?r:void 0},i=r(n.startContainer);if(i===void 0||r(n.endContainer)!==i||i.closest(`[data-selection-answer-streaming]`)!==null)return;let a=n.startContainer instanceof Element?n.startContainer:n.startContainer.parentElement,o=n.endContainer instanceof Element?n.endContainer:n.endContainer.parentElement;if(a?.closest(fp)!=null||o?.closest(fp)!=null)return;let s=hp(n);if(s===``)return;let c=n.getClientRects(),l=c.length===0?n.getBoundingClientRect():c[c.length-1];if(l.width!==0||l.height!==0)return{text:s,rect:l,host:i}}let mp=/* @__PURE__ */ new Set([`BLOCKQUOTE`,`DIV`,`H1`,`H2`,`H3`,`H4`,`H5`,`H6`,`LI`,`P`,`PRE`]);function hp(e){let t=e.cloneContents(),n=document.createElement(`div`);n.append(t);for(let e of n.querySelectorAll(fp))e.remove();for(let e of n.querySelectorAll(`ol, ul`))e.replaceWith(`
132
+ `,...e.childNodes);return gp(n).trim()}function gp(e){let t=``;for(let n of e.childNodes)t+=_p(n,e);return t}function _p(e,t){if(e.nodeType===Node.TEXT_NODE)return e.textContent??``;if(!(e instanceof Element))return``;switch(e.tagName){case`BR`:return`
133
+ `;case`TABLE`:return Array.from(e.querySelectorAll(`tr`)).map(vp).join(`
134
+ `);case`TD`:case`TH`:return`${e.previousElementSibling?.matches(`td, th`)?` `:``}${gp(e).trimEnd()}`;case`TR`:return vp(e);case`THEAD`:case`TBODY`:case`TFOOT`:return gp(e);case`P`:return yp(e,t);default:{let t=gp(e);return mp.has(e.tagName)?`${t}\n`:t}}}function vp(e){return Array.from(e.children).filter(e=>e.tagName===`TH`||e.tagName===`TD`).map(e=>gp(e).trim()).join(` `)}function yp(e,t){let n=e.previousElementSibling;return`${n?.tagName===`P`&&n.textContent?.trim()!==``&&e.textContent?.trim()!==``&&t.tagName!==`LI`?`
135
+ `:``}${gp(e)}\n`}function bp(e){let t=window.visualViewport,n=t?.width??window.innerWidth,r=t?.offsetLeft??0,i=e.right-r,a=window.matchMedia(`(hover: none)`).matches,o=n-8-i;return{left:i,top:a?e.bottom+8:e.top-8,maxWidth:n-16,transform:`translateX(clamp(${String(8-i)}px, -100%, calc(${String(o)}px - 100%)))`+(a?``:` translateY(-100%)`),below:a}}function xp({labels:e,onAdd:t,container:n}){let[r,i]=(0,d.useState)(null),a=(0,d.useRef)(null),o=(0,d.useRef)(!1),s=(0,d.useCallback)(()=>{if(a.current=null,o.current)return;let e=pp(n());i(t=>t?.text===e?.text&&t?.rect.top===e?.rect.top?t:e??null)},[n]),c=(0,d.useCallback)(()=>{a.current===null&&(a.current=window.requestAnimationFrame(s))},[s]);if((0,d.useEffect)(()=>{let e=()=>{o.current=!1,c()},t=e=>{let t=e.target;t instanceof Node&&t.parentElement?.closest(`[data-selection-actions]`)!=null||(o.current=!0,i(null))},n=()=>{let e=window.getSelection();e===null||e.rangeCount===0||e.isCollapsed?i(null):c()},r=()=>{i(null)};return document.addEventListener(`pointerdown`,t,!0),document.addEventListener(`pointerup`,e,!0),document.addEventListener(`selectionchange`,n),window.addEventListener(`keyup`,c),window.addEventListener(`scroll`,r,!0),()=>{document.removeEventListener(`pointerdown`,t,!0),document.removeEventListener(`pointerup`,e,!0),document.removeEventListener(`selectionchange`,n),window.removeEventListener(`keyup`,c),window.removeEventListener(`scroll`,r,!0),a.current!==null&&window.cancelAnimationFrame(a.current),a.current=null}},[c]),r===null)return null;let l=bp(r.rect);return(0,h.createPortal)(/* @__PURE__ */ (0,f.jsx)(`div`,{className:dp.popover,"data-placement":l.below?`below`:`above`,style:{left:l.left,top:l.top,maxWidth:l.maxWidth,transform:`${l.transform} translateZ(0)`},"data-selection-actions":!0,children:/* @__PURE__ */ (0,f.jsxs)(`button`,{type:`button`,className:dp.action,onPointerDown:e=>{e.preventDefault(),e.stopPropagation()},onClick:()=>{if(!r.host.isConnected||!n()?.contains(r.host)||!t(r.text))return;let e=window.getSelection();e?.anchorNode!=null&&e.focusNode!==null&&r.host.contains(e.anchorNode)&&r.host.contains(e.focusNode)&&e.removeAllRanges(),i(null)},children:[/* @__PURE__ */ (0,f.jsxs)(`svg`,{width:`13`,height:`13`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[/* @__PURE__ */ (0,f.jsx)(`path`,{d:`M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z`}),/* @__PURE__ */ (0,f.jsx)(`path`,{d:`M12 7v6`}),/* @__PURE__ */ (0,f.jsx)(`path`,{d:`M9 10h6`})]}),/* @__PURE__ */ (0,f.jsx)(`span`,{children:e.addToChat})]})}),document.body)}let Sp=`@deepseek-ai/dsh-client-ui-chat/ChatMarkdown.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(Sp)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=Sp,e.textContent=`.kidqqG_linkMenu[data-menu-material]{--link-menu-fill:color-mix(in srgb, var(--dsw-alias-bg-layer-2) 68%, var(--dsw-alias-bg-overlay));--dsw-menu-surface-fill:color-mix(in srgb, var(--link-menu-fill) 78%, transparent);--dsw-menu-backdrop-filter:blur(20px) saturate(140%);--dsw-alias-interactive-bg-hover:color-mix(in srgb, var(--dsw-alias-link) 18%, transparent);--dsw-alias-menu-icon:var(--dsw-alias-label-primary);border:1px solid var(--dsw-alias-border-l4);min-width:148px;padding:4px;box-shadow:inset 0 1px #fff3,0 2px 5px #0000001a,0 9px 22px #0000002e}.kidqqG_linkMenu[data-menu-material] [role=menuitem]{min-height:24px;font:500 13px/18px var(--dsw-font-family);border-radius:6px;gap:8px;padding:2px 8px}.kidqqG_linkMenu[data-menu-material] [role=menuitem]>span:has(>svg),.kidqqG_linkMenu[data-menu-material] [role=menuitem] svg{width:14px;height:14px}@media (pointer:coarse){.kidqqG_linkMenu[data-menu-material] [role=menuitem]{min-height:44px}}@media (prefers-reduced-transparency:reduce),(prefers-contrast:more){.kidqqG_linkMenu[data-menu-material]{--dsw-menu-surface-fill:var(--link-menu-fill);--dsw-menu-backdrop-filter:none}}@media (forced-colors:active){.kidqqG_linkMenu[data-menu-material]{--dsw-menu-surface-fill:Canvas;--dsw-menu-backdrop-filter:none;border-color:canvastext}.kidqqG_linkMenu[data-menu-material] [role=menuitem]:is(:hover,:focus-visible){outline-offset:-1px;outline:1px solid highlight}}`,document.head.appendChild(e)}var Cp={linkMenu:`kidqqG_linkMenu`};function wp({children:e,openFile:t,openLinkInSidebar:n,t:r,...i}){let[a,o]=(0,d.useState)(null),[s,c]=(0,d.useState)(!1),l=(0,d.useCallback)(()=>o(null),[]),u=(0,d.useCallback)(()=>a?.position??null,[a]);return/* @__PURE__ */ (0,f.jsxs)(f.Fragment,{children:[/* @__PURE__ */ (0,f.jsx)(p.MarkdownDelegateProvider,{...i,openFile:t,onLinkContextMenu:o,children:e}),/* @__PURE__ */ (0,f.jsx)(p.Menu,{anchor:null,open:a!==null,portal:!0,compact:!0,autoFocus:!0,listClassName:Cp.linkMenu,getAnchorRect:u,focusReturnTarget:a?.trigger,onClose:l,children:a!==null&&/* @__PURE__ */ (0,f.jsxs)(f.Fragment,{children:[(a.kind===`file`||n!==void 0)&&/* @__PURE__ */ (0,f.jsx)(p.MenuItemButton,{icon:a.kind===`file`?/* @__PURE__ */ (0,f.jsx)(p.LinkIconMedium,{kind:`document`}):/* @__PURE__ */ (0,f.jsx)(p.IconBrowseOutlineMedium,{}),onSelect:()=>{l(),a.kind===`file`?t(a.path,a.line===void 0?void 0:{line:a.line}):n?.(a.href)},children:r(`linkMenu.openInCodexhost`)}),/* @__PURE__ */ (0,f.jsx)(p.MenuItemButton,{icon:/* @__PURE__ */ (0,f.jsx)(p.IconLinkOutlineMedium,{}),onSelect:()=>{l(),(0,p.writeClipboard)(a.href).then(e=>c(!e))},children:r(`linkMenu.copy`)}),/* @__PURE__ */ (0,f.jsx)(p.MenuItemButton,{icon:/* @__PURE__ */ (0,f.jsx)(p.IconRightUpOutlineMedium,{}),onSelect:()=>{l(),a.kind===`web`?window.open(a.href,`_blank`,`noopener,noreferrer`):t(a.path,{external:!0,...a.line===void 0?{}:{line:a.line}})},children:r(a.kind===`web`?`linkMenu.openBrowser`:`linkMenu.openFile`)}),a.kind===`file`&&/* @__PURE__ */ (0,f.jsx)(p.MenuItemButton,{icon:/* @__PURE__ */ (0,f.jsx)(p.IconFolderOpenOutlineMedium,{}),onSelect:()=>{l(),t(a.path,{reveal:!0})},children:r(`linkMenu.openFolder`)})]})}),s&&/* @__PURE__ */ (0,f.jsx)(p.Toast,{text:r(`linkMenu.copyFailed`),onDone:()=>c(!1)})]})}function Tp(e,t){let n=e instanceof Error?e.message:String(e);return n===``?t:n}function Ep(e,t){let n=/* @__PURE__ */ new Set,r;for(let i of e){let e=t.get(i);if(e===void 0||e.kind!==`user`&&e.kind!==`steering`&&e.kind!==`turn-trigger`||((e.location.kind===`turn`||e.location.kind===`step`)&&(r=e.location.turn.turn),e.kind===`turn-trigger`))continue;let a=e.data.source;a?.kind===`user`&&typeof a.rpcId==`string`&&n.add(a.rpcId)}return{rpcIds:n,lastInputTurn:r}}let Dp=(0,d.memo)(function({entries:e,useChatGroup:t,pendingInputs:n,lastInputTurn:r,...i}){let a=e.map(e=>{switch(e.kind){case`node`:return/* @__PURE__ */ (0,d.createElement)(Bd,{...i,key:qd(e),nodeKey:e.key,...e.groupPart===void 0?{}:{groupPart:e.groupPart}});case`group`:return/* @__PURE__ */ (0,d.createElement)(df,{...i,key:qd(e),groupKey:e.key,useChatGroup:t});default:return Kd(e)}}),o=n.map(e=>`requestId`in e?/* @__PURE__ */ (0,f.jsx)(hd,{submission:e,renderMessageImages:i.renderMessageImages,t:i.t},e.requestId):/* @__PURE__ */ (0,f.jsx)(md,{content:e.content,renderMessageImages:i.renderMessageImages,t:i.t},e.id)),s=e.at(-1),c=s?.kind===`node`?i.nodeStore.get(s.key):void 0;if(c?.kind===`turn-process`&&c.location.kind===`turn`&&c.location.turn.status===`open`&&c.location.turn.turn!==r){let e=n.findIndex(e=>`requestId`in e&&e.placement===`transcript`);e!==-1&&a.splice(a.length-1,0,...o.splice(e,1))}return[...a,...o]});function Op({connection:e,useSession:t,useChat:n,useChatNode:r,useChatNodeProcess:i,useChatGroup:a,useConversation:o,useSessions:s,useStore:c,actions:l,renderSlot:u,sessionId:m,openFile:h,openSkill:g,openExternalLink:_,openLinkInSidebar:v,useBrowserAvailable:y,resolveLink:ee,loadOlder:b,loadThrough:te,loadImage:x,inspectCall:S,chatScroll:C,forkAt:w,loadTurnDiffs:T,editMessage:E,fileMentions:ne,usePresentation:re,useProjection:ie,inputActions:D,t:O}){let k=n(e=>e.order),se=y(e=>e),ce=o(e=>e.views.grouped(`chat`)?.entries),le=(0,d.useMemo)(()=>ce??k.map(e=>({kind:`node`,key:e})),[ce,k]),ue=n(e=>e.nodes),de=n(e=>e.navigation.items()),fe=de.at(-1)?.anchorKey,pe=r(fe??``,e=>{let t=e?.location;return(t?.kind===`turn`||t?.kind===`step`)&&t.turn.status===`open`?t.turn.start?.time:void 0}),me=ie(`turnOutline`),he=(0,d.useMemo)(()=>ep(de,me),[de,me]),A=ie(`inbox`),ge=s(e=>e.byId[m]?.cwd),_e=s(e=>!!e.byId[m]?.projectionValues?.remoteHost),ve=(0,d.useMemo)(()=>({resolve:e=>_e?void 0:oe(document.baseURI,ae(ge,e)),labels:{open:O(`image.open`),loading:O(`image.loading`),failed:O(`image.failed`),dialog:O(`image.dialog`),close:O(`image.close`)}}),[ge,_e,O]),ye=(0,d.useCallback)(e=>D?.addResponseAnnotation({text:e},{focus:`end`})!==void 0,[D]),be=t(e=>e.running),xe=(0,d.useSyncExternalStore)(e.state.subscribe,e.state.getSnapshot),Se=(0,p.useSustainedRecovery)(xe!==`connected`),Ce=ie(`compacting`),we=t(e=>e.openState),Te=ie(`remoteHistoryError`),Ee=ie(`nativeConnection`),j=xe===`disconnected`||Se||we===`error`||!!Te||Ee?.state===`reconnecting`,De=t(e=>e.openError),Oe=t(e=>e.hasMore),ke=t(e=>e.loadingOlder),Ae=t(e=>e.olderError),[je,Me]=(0,d.useState)(null),[Ne,Pe]=(0,d.useState)(!1),Fe=(0,d.useRef)(0),Ie=(0,d.useCallback)((e,t)=>{let n=++Fe.current;Pe(!0),(t===void 0?h(e):h(e,t)).then(()=>{n===Fe.current&&(Me(null),Pe(!1))},r=>{n===Fe.current&&(Me({path:e,options:t,message:Tp(r,O(t?.reveal?`fileOpen.folder`:`fileOpen.unknown`))}),Pe(!1))})},[h,O]),Le=(0,d.useCallback)(()=>{Fe.current+=1,Me(null),Pe(!1)},[]),Re=(0,d.useMemo)(()=>A?.[`next-step`].filter(e=>e.source.kind===`user`)??[],[A]),M=t(e=>e.pendingSubmissions),ze=rd(E,ie(`sentMessageEdit`)?.seq??null,we!==`open`||be||M.length>0||(A?.[`next-turn`].length??0)>0),Be=ze.draft&&k.some(e=>{let t=ue.get(e);return t?.kind===`user`&&t.data.seq===ze.draft?.seq}),Ve=be||M.some(e=>e.placement!==`queued`),[He,Ue]=(0,d.useMemo)(()=>{if(M.length===0)return[M,void 0];let e=Ep(k,ue);return[M.filter(t=>t.placement!==`queued`&&!e.rpcIds.has(t.requestId)),e.lastInputTurn]},[M,k,ue]),We=(0,d.useMemo)(()=>{let e=new Map(He.map(e=>[e.requestId,e])),t=new Set(M.filter(e=>e.placement!==`queued`).map(e=>e.requestId));return[...Re.flatMap(n=>{let r=n.source;if(r.kind!==`user`||!(`rpcId`in r))return[n];let i=e.get(r.rpcId);return i===void 0?t.has(r.rpcId)?[]:[n]:(e.delete(r.rpcId),[i])}),...e.values()]},[Re,M,He]),Ge=(0,d.useCallback)(e=>u(`conversation.message.images`,{...e,loadImage:x}),[x,u]),Ke=k[0],qe=Ke===void 0?null:ue.get(Ke)?.anchorSeq??null,Je=k.at(-1)??null,Ye=We.findLast(e=>`source`in e),Xe=Ye?.source.kind===`user`&&`rpcId`in Ye.source?Ye.source.rpcId:Ye?.id??null,Ze=lp({displayReady:we===`open`||k.length>0,historyReady:we===`open`,order:k,firstSeq:qe,lastKey:Je,running:be,loadingOlder:ke,olderFailed:Ae!=null,hasMore:Oe,chatScroll:C,loadOlder:b,loadThrough:te,lastIsUser:Je!==null&&ue.get(Je)?.kind===`user`,steeringId:Xe,submissionId:He.at(-1)?.requestId??null,loadedTurns:de});return/* @__PURE__ */ (0,f.jsxs)(`div`,{className:Y.frame,children:[Ze.initialized&&/* @__PURE__ */ (0,f.jsx)(Uf,{items:he,activeTurn:Ze.activeTurn,busyTurn:Ze.busyTurn,onNavigate:Ze.navigateToTurn,t:O}),/* @__PURE__ */ (0,f.jsx)(`div`,{className:Y.root,"data-chat-following-tail":Ze.followingTail?``:void 0,children:/* @__PURE__ */ (0,f.jsx)(`div`,{ref:Ze.listRef,className:Y.scroll,children:/* @__PURE__ */ (0,f.jsxs)(`div`,{ref:Ze.columnRef,className:Y.column,"data-chat-flow":``,children:[we===`loading`&&k.length===0&&/* @__PURE__ */ (0,f.jsx)(`div`,{className:Y.hint,children:O(`chat.loadingHistory`)}),we===`error`&&De!==null&&/* @__PURE__ */ (0,f.jsx)(`div`,{className:Y.openError,children:O(`chat.loadError`,{message:De.message,code:De.code})}),Oe&&/* @__PURE__ */ (0,f.jsx)(`div`,{className:Y.older,children:Ae==null?/* @__PURE__ */ (0,f.jsx)(`span`,{role:ke?`status`:void 0,children:O(ke?`chat.loadingOlder`:`chat.scrollOlder`)}):/* @__PURE__ */ (0,f.jsxs)(f.Fragment,{children:[/* @__PURE__ */ (0,f.jsx)(`span`,{role:`alert`,children:O(`chat.loadOlderError`,{message:Ae.message})}),/* @__PURE__ */ (0,f.jsx)(`button`,{type:`button`,disabled:ke,onClick:Ze.loadEarlier,children:O(`chat.retryOlder`)})]})}),/* @__PURE__ */ (0,f.jsx)(wp,{openExternalLink:_,openLinkInSidebar:se?v:void 0,resolveLink:ee,openFile:Ie,fileImages:ve,t:O,children:/* @__PURE__ */ (0,f.jsx)(Dp,{entries:le,pendingInputs:We,lastInputTurn:Ue,nodeStore:ue,useChatGroup:a,useChatNode:r,useChatNodeProcess:i,usePresentation:re,useStore:c,actions:l,cwd:ge,openFile:Ie,openSkill:g,inspectCall:S,forkAt:w,loadTurnDiffs:T,messageEditing:ze,loadImage:x,renderMessageImages:Ge,fileMentions:ne,renderSlot:u,t:O})},m),ze.draft&&!Be&&/* @__PURE__ */ (0,f.jsx)(_d,{editing:ze,renderMessageImages:Ge,t:O}),Ve&&/* @__PURE__ */ (0,f.jsx)(qf,{startTime:pe,compacting:Ce,stale:j,t:O}),we===`loading`&&k.length>0&&/* @__PURE__ */ (0,f.jsxs)(`div`,{className:Y.syncing,role:`status`,"data-history-syncing":!0,children:[/* @__PURE__ */ (0,f.jsx)(p.StateDot,{state:`ongoing`,className:Y.syncingIcon}),/* @__PURE__ */ (0,f.jsx)(`span`,{children:O(`chat.syncing`)})]})]})})}),/* @__PURE__ */ (0,f.jsx)(xp,{labels:{addToChat:O(`selection.addToChat`)},onAdd:ye,container:()=>Ze.columnRef.current}),!Ze.followingTail&&/* @__PURE__ */ (0,f.jsx)(`div`,{className:Y.toBottomSlot,children:/* @__PURE__ */ (0,f.jsx)(`button`,{type:`button`,className:Y.toBottom,"aria-label":O(`chat.toBottom`),onClick:Ze.returnToBottom,children:/* @__PURE__ */ (0,f.jsx)(p.IconChevronDownOutlineRegular,{})})}),je!==null&&/* @__PURE__ */ (0,f.jsx)(kp,{title:O(je.options?.reveal?`fileOpen.folder`:`fileOpen.title`),message:je.message,busy:Ne,onClose:Le,onRetry:()=>{Ie(je.path,je.options)},t:O})]})}function kp({title:e,message:t,busy:n,onClose:r,onRetry:i,t:a}){return/* @__PURE__ */ (0,f.jsx)(p.Modal,{open:!0,onClose:r,closeLabel:a(`close`),title:e,description:t,footer:/* @__PURE__ */ (0,f.jsxs)(f.Fragment,{children:[/* @__PURE__ */ (0,f.jsx)(p.Button,{variant:`outline`,className:Y.modalAction,onClick:r,children:a(`cancel`)}),/* @__PURE__ */ (0,f.jsx)(p.Button,{variant:`primary`,className:Y.modalAction,disabled:n,onClick:i,children:a(`retry`)})]})})}let X=`chat`,Ap={"message.stepProcess.thinking":`正在分析请求`,"message.stepProcess.read":`正在读取文件`,"message.stepProcess.readImage":`正在读取图片`,"message.stepProcess.write":`正在写入文件`,"message.stepProcess.search":`正在搜索代码`,"message.stepProcess.edit":`正在编辑文件`,"message.stepProcess.commands":`正在运行命令`,"message.stepProcess.code":`正在运行代码`,"message.stepProcess.webSearch":`正在搜索网页`,"message.stepProcess.webFetch":`正在访问网页`,"message.stepProcess.subagents":`正在协调子智能体`,"message.stepProcess.plan":`正在更新计划`,"message.stepProcess.questions":`等待你的操作`,"message.stepProcess.tools":`正在调用工具`,"message.stepProcess.prepare.read":`准备读取文件`,"message.stepProcess.prepare.readImage":`准备读取图片`,"message.stepProcess.prepare.write":`准备写入文件`,"message.stepProcess.prepare.search":`准备搜索代码`,"message.stepProcess.prepare.edit":`准备编辑文件`,"message.stepProcess.prepare.commands":`准备运行命令`,"message.stepProcess.prepare.code":`准备运行代码`,"message.stepProcess.prepare.webSearch":`准备搜索网页`,"message.stepProcess.prepare.webFetch":`准备访问网页`,"message.stepProcess.prepare.subagents":`准备协调子智能体`,"message.stepProcess.prepare.plan":`准备更新计划`,"message.stepProcess.prepare.questions":`准备提问`,"message.stepProcess.prepare.tools":`准备调用工具`,"message.stepProcess.done.thinking":`已完成分析`,"message.stepProcess.done.read":`已读取文件`,"message.stepProcess.done.readImage":`已读取图片`,"message.stepProcess.done.write":`已写入文件`,"message.stepProcess.done.search":`已搜索代码`,"message.stepProcess.done.edit":`修改了文件`,"message.stepProcess.done.commands":`执行了命令`,"message.stepProcess.done.code":`运行了代码`,"message.stepProcess.done.webSearch":`已搜索网页`,"message.stepProcess.done.webFetch":`已访问网页`,"message.stepProcess.done.subagents":`已协调子智能体`,"message.stepProcess.done.plan":`更新了计划`,"message.stepProcess.done.questions":`向用户提出了问题`,"message.stepProcess.done.tools":`已调用工具`,"message.stepProcess.joinTwo":`{first}并{second}`,"message.stepProcess.comma":`,`,"message.stepProcess.sharedPrefix":`已`,"message.stepProcess.more":`{title}等`,"message.trigger.request":`收到执行请求`,"message.trigger.goal":`继续执行目标`,"message.trigger.agent":`收到任务消息`,"message.trigger.team":`收到团队消息`,"message.trigger.subagent":`子任务状态更新`,"message.trigger.github":`收到 GitHub 事件`,"message.trigger.webhook":`收到外部事件`,"message.trigger.schedule":`自动化任务`,"message.trigger.job":`后台任务状态更新`,"message.trigger.plugin":`插件状态更新`,"message.trigger.explanation":`这条通知触发了本轮回复。`,"message.turnProcess.worked":`已完成`,"message.turnProcess.unknown":`已结束(状态未知)`,"message.turnProcess.took":`已完成,用时 `,"message.turnProcess.failed":`处理失败`,"view.chat":`对话`,"image.open":`查看大图`,"image.loading":`加载图片…`,"image.failed":`图片无法预览`,"image.dialog":`图片预览`,"image.close":`关闭图片预览`,"duration.milliseconds":`{milliseconds}毫秒`,"chat.loadingHistory":`载入历史…`,"selection.addToChat":`添加到对话`,"annotation.label":`批注 {index}`,"annotation.chipLabel":`{index}.`,"annotation.title":`批注 {index}:{excerpt}`,"annotation.remove":`移除批注 {index}`,"annotation.selectedText":`选中文字:`,"annotation.userComment":`你的批注:`,"chat.syncing":`正在获取最新消息…`,"chat.loadingDiff":`载入差异…`,"chat.retryDiff":`重试`,"chat.loadError":`历史加载失败:{message}({code})`,"chat.loadOlder":`加载更早`,"chat.scrollOlder":`向上滚动查看更早消息`,"chat.loadingOlder":`正在加载更早消息…`,"chat.loadOlderError":`更早消息加载失败:{message}`,"chat.retryOlder":`重试加载`,"chat.toBottom":`回到底部`,"chat.filesChanged":`{count} 个文件已更改`,"chat.fileEdited":`已编辑 {name}`,"chat.filesEdited":`已编辑 {count} 个文件`,"chat.viewChanges":`查看变更`,"chat.hideChanges":`收起变更`,"chat.showMoreFiles":`再显示 {count} 个文件`,"chat.collapseFiles":`收起文件`,"diff.code":`代码`,"diff.wrap":`自动换行`,"diff.unwrap":`取消换行`,"diff.copy":`复制`,"diff.copied":`已复制`,"diff.collapseAria":`折叠差异`,"diff.expandAria":`展开 {count} 行隐藏内容`,"diff.collapse":`折叠`,"diff.expand":`展开 {count} 行`,"chat.deepDiving":`正在处理`,"chat.statusUnconfirmed":`任务状态待确认`,"chat.deepDivingFor":`正在处理 · {duration}`,"chat.turnNavigation.label":`轮次导航`,"chat.turnNavigation.jump":`跳转到用户消息 {turn}`,"chat.turnNavigation.jumpLoad":`加载并跳转到用户消息 {turn}`,"chat.turnNavigation.turn":`用户消息 {turn}`,"settings.links.title":`网页链接默认打开方式`,"settings.links.description":`对话中网页链接的打开位置`,"settings.links.sidebar":`应用内侧边栏`,"settings.links.newTab":`默认浏览器`,"settings.transcript.title":`工作步骤展示`,"settings.transcript.description":`选择希望看到多少工具调用细节`,"settings.transcript.compact":`简洁`,"settings.transcript.standard":`标准`,"settings.transcript.detailed":`详细`,"settings.transcript.verbose":`完全展开`,"fileOpen.title":`无法打开文件`,"fileOpen.folder":`无法打开所在文件夹`,"fileOpen.unknown":`无法打开此文件`,"linkMenu.copy":`复制链接`,"linkMenu.copyFailed":`无法复制链接`,"linkMenu.openBrowser":`在浏览器中打开`,"linkMenu.openFile":`用默认应用打开`,"linkMenu.openFolder":`打开所在文件夹`,"linkMenu.openInCodexhost":`在 codexhost 中打开`,"message.watch.completed":`已完成`,"message.watch.failed":`失败`,"message.watch.interrupted":`已中断`,"message.watch.timedOut":`监听已到期`,"message.watch.unreadable":`状态未知`,"message.watch.notFound":`会话不存在`,"message.watch.open":`打开会话`,"message.extraBlock":`附加内容块`,"message.uploading":`上传中…`,"message.uploadingPercent":`上传中 {percent}%`,"message.systemPrompt":`系统提示词`,"message.systemPromptUpdate":`系统提示词更新`,"message.toolAdded":`已添加工具:{name}`,"message.toolRemoved":`已移除工具:{name}`,"message.toolsAdded":`新增:{names}`,"message.toolsAddedCount":`新增 {count} 个`,"message.toolsChanged":`新增 {added} 个,移除 {removed} 个`,"message.toolsRemoved":`移除:{names}`,"message.toolsRemovedCount":`移除 {count} 个`,"message.toolsUpdated":`工具已更新`,"message.contextInjection":`上下文注入`,"message.contextRecall":`跨会话召回`,"message.referenceSummary":`引用会话 · {labels}`,"message.referenceSeparator":`、`,"message.context.instructions.loaded":`已载入`,"message.context.instructions.added":`已新增`,"message.context.instructions.updated":`已更新`,"message.context.instructions.removed":`已移除`,"message.context.catalog.replaced":`替换目录`,"message.context.catalog.more":`…还有 {count} 条`,"message.context.snapshot.supersedes":`取代先前的快照`,"message.context.relay.from":`来自会话 {session}`,"message.context.recall.counts":`保留 {retained} 条 · 省略 {omitted} 条`,"message.context.recall.truncated":`已截断`,"message.compaction":`上下文已压缩`,"message.compaction.running":`正在压缩…`,"message.compaction.completed":`已压缩 {items} 条历史记录(约 {tokens} tokens)`,"message.compaction.expand":`点击查看压缩摘要`,"message.compaction.unavailable":`压缩摘要不可用`,"message.compaction.commandTitle":`compact`,"message.think":`思考`,"message.unknownSurface":`未知 surface 事件:{type}`,"message.unknownBlock":`未知内容块`,"message.turnProcess.toolCalls.one":`{count} 次工具调用`,"message.turnProcess.toolCalls.other":`{count} 次工具调用`,"message.turnProcess.messages.one":`{count} 条消息`,"message.turnProcess.messages.other":`{count} 条消息`,"message.turnProcess.subagents.one":`{count} 个 subagent`,"message.turnProcess.subagents.other":`{count} 个 subagent`,"message.turnProcess.thoughtForAWhile":`已思考`,"message.turnProcess.separator":` · `,"message.stopped":`已停止`,"message.edit":`编辑消息`,"message.edit.changed":`会话状态已变化,请核对当前历史后继续。`,"message.edit.cancel":`取消`,"message.edit.send":`发送`,"message.edit.sending":`正在回退并重跑…`,"message.edit.checkHistory":`请核对当前历史后再继续;编辑文本已保留,不会自动重发。`,"message.branch":`在新对话中分支`,"message.branchFailed":`分叉未完成:{message}`,"message.branchUnavailable":`仅可从已完成轮次的最后一条消息分支`,"message.retry.active":`正在重试模型请求`,"message.retry.cancelled":`模型请求重试已取消`,"message.retry.started":`已重试模型请求`,"message.retry.scheduled":`等待重试模型请求`,"message.retry.status":`{label}({retry}/{maximum}) · {seconds}s`,"message.retry.delay":`重试延迟:`,"message.retry.failure":`失败原因:`,"message.failure.auth":`API 密钥无效`,"message.accountStopped":`任务已停止`,"message.failure.accountSignedOut":`任务已因退出 DeepSeek 登录而停止。`,"message.failure.accountSignInRequired":`请先登录 DeepSeek,并确认请求地址支持账号认证。`,"message.failure.quota":`当前请求的额度已用尽`,"message.turnError":`本轮运行失败`,"message.maxTokens":`已达到输出 token 上限`,"message.maxTokens.hint":`回答被截断,已有输出保留在对话中。发送“继续”可让模型接着输出。`,"duration.secondUnit":`秒`,"duration.minuteUnit":`分`,"duration.hourUnit":`小时`,"command.running":`执行中…`,"command.failed":`指令失败`,"command.done":`已完成`,"command.title":`指令`,"row.running":`运行中`,"row.failed":`失败`,"json.truncated":`… 已截断,共 {total} 字符`,"clock.md":`{m}月{d}日`,"clock.ymd":`{y}年{m}月{d}日`},jp={"message.stepProcess.thinking":`Analyzing the request`,"message.stepProcess.read":`Reading files`,"message.stepProcess.readImage":`Reading images`,"message.stepProcess.write":`Writing files`,"message.stepProcess.search":`Searching code`,"message.stepProcess.edit":`Editing files`,"message.stepProcess.commands":`Running commands`,"message.stepProcess.code":`Running code`,"message.stepProcess.webSearch":`Searching the web`,"message.stepProcess.webFetch":`Visiting web pages`,"message.stepProcess.subagents":`Coordinating subagents`,"message.stepProcess.plan":`Updating the plan`,"message.stepProcess.questions":`Waiting for your action`,"message.stepProcess.tools":`Calling tools`,"message.stepProcess.prepare.read":`Preparing to read files`,"message.stepProcess.prepare.readImage":`Preparing to read images`,"message.stepProcess.prepare.write":`Preparing to write files`,"message.stepProcess.prepare.search":`Preparing to search code`,"message.stepProcess.prepare.edit":`Preparing to edit files`,"message.stepProcess.prepare.commands":`Preparing to run commands`,"message.stepProcess.prepare.code":`Preparing to run code`,"message.stepProcess.prepare.webSearch":`Preparing to search the web`,"message.stepProcess.prepare.webFetch":`Preparing to visit web pages`,"message.stepProcess.prepare.subagents":`Preparing to coordinate subagents`,"message.stepProcess.prepare.plan":`Preparing to update the plan`,"message.stepProcess.prepare.questions":`Preparing questions`,"message.stepProcess.prepare.tools":`Preparing tool calls`,"message.stepProcess.done.thinking":`Analysis completed`,"message.stepProcess.done.read":`Read files`,"message.stepProcess.done.readImage":`Read images`,"message.stepProcess.done.write":`Wrote files`,"message.stepProcess.done.search":`Searched code`,"message.stepProcess.done.edit":`Edited files`,"message.stepProcess.done.commands":`Ran commands`,"message.stepProcess.done.code":`Ran code`,"message.stepProcess.done.webSearch":`Searched the web`,"message.stepProcess.done.webFetch":`Visited web pages`,"message.stepProcess.done.subagents":`Coordinated subagents`,"message.stepProcess.done.plan":`Updated the plan`,"message.stepProcess.done.questions":`Asked questions`,"message.stepProcess.done.tools":`Called tools`,"message.stepProcess.joinTwo":`{first} and {second}`,"message.stepProcess.comma":`, `,"message.stepProcess.sharedPrefix":``,"message.stepProcess.more":`{title}, etc.`,"message.trigger.request":`Execution requested`,"message.trigger.goal":`Continuing goal`,"message.trigger.agent":`Task message received`,"message.trigger.team":`Team message received`,"message.trigger.subagent":`Subtask status updated`,"message.trigger.github":`GitHub event received`,"message.trigger.webhook":`External event received`,"message.trigger.schedule":`Automation task`,"message.trigger.job":`Background task updated`,"message.trigger.plugin":`Plugin status updated`,"message.trigger.explanation":`This notification triggered this response.`,"message.turnProcess.worked":`Completed`,"message.turnProcess.unknown":`Ended (outcome unknown)`,"message.turnProcess.took":`Completed in `,"message.turnProcess.failed":`Failed`,"view.chat":`Chat`,"image.open":`View full image`,"image.loading":`Loading image…`,"image.failed":`Image preview unavailable`,"image.dialog":`Image preview`,"image.close":`Close image preview`,"duration.milliseconds":`{milliseconds}ms`,"chat.loadingHistory":`Loading history…`,"selection.addToChat":`Add to chat`,"annotation.label":`Annotation {index}`,"annotation.chipLabel":`{index}.`,"annotation.title":`Annotation {index}: {excerpt}`,"annotation.remove":`Remove annotation {index}`,"annotation.selectedText":`Selected text:`,"annotation.userComment":`Your comment:`,"chat.syncing":`Fetching latest messages…`,"chat.loadingDiff":`Loading diff…`,"chat.retryDiff":`Retry`,"chat.loadError":`Failed to load history: {message} ({code})`,"chat.loadOlder":`Load earlier`,"chat.scrollOlder":`Scroll up for earlier messages`,"chat.loadingOlder":`Loading earlier messages…`,"chat.loadOlderError":`Could not load earlier messages: {message}`,"chat.retryOlder":`Retry loading`,"chat.toBottom":`Back to bottom`,"chat.filesChanged":`{count} files changed`,"chat.fileEdited":`Edited {name}`,"chat.filesEdited":`Edited {count} files`,"chat.viewChanges":`View changes`,"chat.hideChanges":`Hide changes`,"chat.showMoreFiles":`Show {count} more`,"chat.collapseFiles":`Collapse files`,"diff.code":`Code`,"diff.wrap":`Wrap lines`,"diff.unwrap":`Unwrap lines`,"diff.copy":`Copy`,"diff.copied":`Copied`,"diff.collapseAria":`Collapse diff`,"diff.expandAria":`Expand {count} hidden lines`,"diff.collapse":`Collapse`,"diff.expand":`Expand {count} lines`,"chat.deepDiving":`Working`,"chat.statusUnconfirmed":`Task status unconfirmed`,"chat.deepDivingFor":`Working · {duration}`,"chat.turnNavigation.label":`Turn navigation`,"chat.turnNavigation.jump":`Jump to user message {turn}`,"chat.turnNavigation.jumpLoad":`Load and jump to user message {turn}`,"chat.turnNavigation.turn":`User message {turn}`,"settings.links.title":`Open chat links in`,"settings.links.description":`Choose where to open web links`,"settings.links.sidebar":`In-App Sidebar`,"settings.links.newTab":`Default Browser`,"settings.transcript.title":`Work details`,"settings.transcript.description":`Choose how much detail to show for tool calls`,"settings.transcript.compact":`Compact`,"settings.transcript.standard":`Standard`,"settings.transcript.detailed":`Detailed`,"settings.transcript.verbose":`Verbose`,"fileOpen.title":`Couldn’t open file`,"fileOpen.folder":`Couldn’t open containing folder`,"fileOpen.unknown":`Couldn’t open this file`,"linkMenu.copy":`Copy link`,"linkMenu.copyFailed":`Couldn’t copy link`,"linkMenu.openBrowser":`Open in browser`,"linkMenu.openFile":`Open in default app`,"linkMenu.openFolder":`Open containing folder`,"linkMenu.openInCodexhost":`Open in codexhost`,"message.watch.completed":`Completed`,"message.watch.failed":`Failed`,"message.watch.interrupted":`Interrupted`,"message.watch.timedOut":`Watch expired`,"message.watch.unreadable":`State unknown`,"message.watch.notFound":`Session not found`,"message.watch.open":`Open session`,"message.extraBlock":`Extra content block`,"message.uploading":`Uploading…`,"message.uploadingPercent":`Uploading {percent}%`,"message.systemPrompt":`System prompt`,"message.systemPromptUpdate":`System prompt update`,"message.toolAdded":`Tool added: {name}`,"message.toolRemoved":`Tool removed: {name}`,"message.toolsAdded":`Added: {names}`,"message.toolsAddedCount":`{count} added`,"message.toolsChanged":`{added} added, {removed} removed`,"message.toolsRemoved":`Removed: {names}`,"message.toolsRemovedCount":`{count} removed`,"message.toolsUpdated":`Tools updated`,"message.contextInjection":`Context injection`,"message.contextRecall":`Session recall`,"message.referenceSummary":`Referenced session · {labels}`,"message.referenceSeparator":`, `,"message.context.instructions.loaded":`loaded`,"message.context.instructions.added":`added`,"message.context.instructions.updated":`updated`,"message.context.instructions.removed":`removed`,"message.context.catalog.replaced":`Replacement catalog`,"message.context.catalog.more":`… {count} more`,"message.context.snapshot.supersedes":`Supersedes earlier snapshots`,"message.context.relay.from":`From session {session}`,"message.context.recall.counts":`{retained} kept · {omitted} omitted`,"message.context.recall.truncated":`truncated`,"message.compaction":`Context compacted`,"message.compaction.running":`Compacting context…`,"message.compaction.completed":`Compacted {items} history items (~{tokens} tokens)`,"message.compaction.expand":`View compaction summary`,"message.compaction.unavailable":`Compaction summary unavailable`,"message.compaction.commandTitle":`compact`,"message.think":`Think`,"message.unknownSurface":`Unknown surface event: {type}`,"message.unknownBlock":`Unknown content block`,"message.turnProcess.toolCalls.one":`{count} tool call`,"message.turnProcess.toolCalls.other":`{count} tool calls`,"message.turnProcess.messages.one":`{count} message`,"message.turnProcess.messages.other":`{count} messages`,"message.turnProcess.subagents.one":`{count} subagent`,"message.turnProcess.subagents.other":`{count} subagents`,"message.turnProcess.thoughtForAWhile":`Thought for a while`,"message.turnProcess.separator":` · `,"message.stopped":`Stopped`,"message.edit":`Edit message`,"message.edit.changed":`Conversation state changed. Check current history before continuing.`,"message.edit.cancel":`Cancel`,"message.edit.send":`Send`,"message.edit.sending":`Reverting and rerunning…`,"message.edit.checkHistory":`Check current history before continuing. Your edit is retained and will not be resent automatically.`,"message.branch":`Branch into a new conversation`,"message.branchFailed":`Fork did not complete: {message}`,"message.branchUnavailable":`Available only on the last message of a completed turn`,"message.retry.active":`Retrying model request`,"message.retry.cancelled":`Model request retry cancelled`,"message.retry.started":`Retried model request`,"message.retry.scheduled":`Waiting to retry model request`,"message.retry.status":`{label} ({retry}/{maximum}) · {seconds}s`,"message.retry.delay":`Retry delay: `,"message.retry.failure":`Failure reason: `,"message.failure.auth":`API key is invalid`,"message.accountStopped":`Task stopped`,"message.failure.accountSignedOut":`Stopped because you signed out of DeepSeek.`,"message.failure.accountSignInRequired":`Sign in to DeepSeek and ensure the request destination supports account authentication.`,"message.failure.quota":`Request quota exhausted.`,"message.turnError":`This turn failed`,"message.maxTokens":`Output token limit reached`,"message.maxTokens.hint":`The reply was cut off; earlier output is preserved in the conversation. Send "continue" to let the model resume.`,"duration.secondUnit":`s`,"duration.minuteUnit":`m `,"duration.hourUnit":`h `,"command.running":`Running…`,"command.failed":`Command failed`,"command.done":`Completed`,"command.title":`Command`,"row.running":`Running`,"row.failed":`Failed`,"json.truncated":`… truncated, {total} characters total`,"clock.md":`{m}/{d}`,"clock.ymd":`{y}-{m}-{d}`},Mp=`@deepseek-ai/dsh-client-ui-chat/ReasoningRow.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(Mp)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=Mp,e.textContent=`.Eedvza_root{flex-direction:column;display:flex}.Eedvza_root:not([data-expanded]){contain:size layout;height:calc(24px + var(--dsh-content-font-delta,0px))}.Eedvza_row{overflow:hidden}.Eedvza_root[data-expanded] [data-open] [data-disclosure-row]{z-index:1;background:var(--dsw-alias-bg-base);position:sticky;top:0}body[data-codexhost-wallpaper] .Eedvza_root[data-expanded] [data-open] [data-disclosure-row]{background:color-mix(in srgb, var(--dsw-alias-bg-base) 76%, transparent);backdrop-filter:blur(12px);border-radius:var(--dsw-radius-sm,8px)}.Eedvza_leading{flex-shrink:0}.Eedvza_title{font-weight:400}.Eedvza_separator{background:var(--dsw-alias-label-caption);border-radius:1px;flex:none;width:2px;height:2px;margin:0 8px}.Eedvza_summary{min-width:0;font-size:var(--dsh-content-font-size-secondary,13px);line-height:calc(20px + var(--dsh-content-font-delta-secondary,0px));white-space:nowrap;flex:auto;overflow:hidden}.Eedvza_summaryText{text-overflow:ellipsis;display:block;overflow:hidden}.Eedvza_summary[data-streaming]{mask-image:linear-gradient(90deg,#000 calc(100% - 48px),#0000)}.Eedvza_summary[data-streaming] .Eedvza_summaryText{text-overflow:clip;overflow:visible}.Eedvza_root:not([data-preview]) .Eedvza_separator,.Eedvza_root:not([data-preview]) .Eedvza_summary{display:none}.Eedvza_thinkBody{padding:4px 0 4px calc(22px + var(--dsh-content-font-delta,0px));min-width:0}`,document.head.appendChild(e)}var Np={leading:`Eedvza_leading`,root:`Eedvza_root`,row:`Eedvza_row`,separator:`Eedvza_separator`,summary:`Eedvza_summary`,summaryText:`Eedvza_summaryText`,thinkBody:`Eedvza_thinkBody`,title:`Eedvza_title`};let Pp=/* @__PURE__ */ (0,f.jsx)(p.IconThinkOutlineRegular,{size:14});function Fp(e){let t=e.indexOf(`
136
+ `);return t===-1?e:e.slice(0,t)}function Ip(e){let t=``,n=0,r=/\r?\n(?:[\t ]*\r?\n)+/g;for(;;){let i=r.exec(e),a=i===null?e.length:i.index+i[0].indexOf(`
133
137
  `),o=e.indexOf(`
134
- `,n);if(o!==-1&&o<=a){let r=e.slice(n,o).trim();r!==``&&(t=r)}if(i===null)return t;n=i.index+i[0].length}}let ap=(0,d.memo)(function({text:e,running:t,usePresentation:n,useDisclosure:r,t:i}){let{expanded:a,toggle:o}=r(),s=(0,d.useMemo)(()=>ru(i),[i]),c=t?ip(e):rp(e),l=(0,d.useMemo)(()=>c.replaceAll(`**`,``),[c]),u=n(e=>!a&&l!==``&&(t||e.settledReasoningPreview)),m=(0,d.useMemo)(()=>/* @__PURE__ */ (0,f.jsxs)(f.Fragment,{children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:tp.separator,"data-shimmer-decoration":!0,"aria-hidden":!0}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:tp.summary,"data-streaming":t||void 0,children:/* @__PURE__ */ (0,f.jsx)(`span`,{className:tp.summaryText,children:/* @__PURE__ */ (0,f.jsx)(p.TextShimmer,{children:l})})})]}),[t,l]),h=(0,d.useMemo)(()=>a?/* @__PURE__ */ (0,f.jsx)(`div`,{className:tp.thinkBody,children:/* @__PURE__ */ (0,f.jsx)(p.MarkdownText,{text:e,streaming:t,labels:s,variant:`compact`})}):void 0,[a,s,t,e]);return/* @__PURE__ */ (0,f.jsxs)(`div`,{className:tp.root,"data-variant":`think`,"data-state":t?`running`:`ok`,"data-expanded":a||void 0,"data-preview":u||void 0,children:[t&&/* @__PURE__ */ (0,f.jsx)(`span`,{className:kf.visuallyHidden,children:i(`row.running`)}),/* @__PURE__ */ (0,f.jsx)(p.DisclosureRow,{rowClassName:tp.row,leadingClassName:tp.leading,titleClassName:tp.title,icon:np,title:i(`message.think`),running:t,open:a,expandable:!0,expandOnRowClick:!0,onToggle:o,collapsedContent:m,children:h})]})}),op=`@deepseek-ai/dsh-client-ui-chat/AssistantMarkdown.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(op)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=op,e.textContent=`.B4Qqwq_root{font-size:var(--dsh-content-font-size,14px);line-height:calc(24px + var(--dsh-content-font-delta,0px));color:var(--dsw-alias-label-primary);flex-direction:column;display:flex}.B4Qqwq_body{flex-direction:column;gap:16px;display:flex}.B4Qqwq_body .md-table-wide{--dsh-table-spare:max(0px, calc((100cqw - var(--dsh-chat-content-width)) / 2));--dsh-table-lead:calc(var(--dsh-table-spare) + min(var(--dsh-chat-content-width), 100cqw) - 100%);box-sizing:border-box;width:calc(100% + var(--dsh-table-lead) + var(--dsh-table-spare));max-width:none;margin-left:calc(-1 * var(--dsh-table-lead));padding-left:var(--dsh-table-lead)}.B4Qqwq_body .md-table-wide>table{z-index:1;position:relative}.B4Qqwq_body>[data-turn-process-inline][hidden]{margin-bottom:-16px}.B4Qqwq_stopped{border-radius:var(--dsw-radius-sm);background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-label-tertiary);align-self:flex-start;padding:0 6px;font-size:11px;line-height:18px}.B4Qqwq_actions{margin-top:16px;margin-left:-6px}`,document.head.appendChild(e)}var sp={actions:`B4Qqwq_actions`,body:`B4Qqwq_body`,root:`B4Qqwq_root`,stopped:`B4Qqwq_stopped`};function cp(e,t,n){let r;try{r=decodeURIComponent(t.split(/[?#]/u)[0]??``)}catch{return}return n===void 0?se(e,r):n(r)}let lp=(0,d.memo)(function({blocks:e,streaming:t,interrupted:n,renderMessageImages:r,groupPart:i,useDisclosure:a,reasoningHidden:o=!1,usePresentation:s,revealProcess:c,mentions:l,t:u}){let m=(0,d.useMemo)(()=>ru(u),[u]),{fileImages:h}=(0,p.useMarkdownDelegate)(),g=(0,d.useMemo)(()=>({resolve:e=>cp(document.baseURI,e,h?.resolve)}),[h]),_=e.length-1;if(!(t||n===!0||e.some(e=>e.kind!==`tool-call`)))return null;let v=[];for(let n=0;n<e.length;n++){let h=e[n];if(h!==void 0&&(i!==`reasoning`||h.kind===`reasoning`)&&(i!==`response`||h.kind!==`reasoning`))switch(h.kind){case`text`:v.push(/* @__PURE__ */ (0,f.jsx)(p.MarkdownText,{text:h.text,streaming:t,labels:m,fileMentions:l,pathImages:g},n));break;case`reasoning`:v.push(/* @__PURE__ */ (0,f.jsx)(up,{hidden:o,reveal:c,children:/* @__PURE__ */ (0,f.jsx)(ap,{text:h.text,running:t&&n===_,usePresentation:s,useDisclosure:a,t:u})},n));break;case`image`:{let t=n,i=[h];for(;n+1<e.length;){let t=e[n+1];if(t===void 0||t.kind!==`image`)break;i.push(t),n+=1}v.push(/* @__PURE__ */ (0,f.jsx)(d.Fragment,{children:r({images:i.map(({attachment:e})=>({attachment:e})),align:`start`})},t));break}case`tool-call`:break;default:v.push(/* @__PURE__ */ (0,f.jsx)(p.JsonBlock,{label:u(`message.unknownBlock`),payload:h.block,truncatedLabel:e=>u(`json.truncated`,{total:e})},n))}}return/* @__PURE__ */ (0,f.jsx)(`div`,{className:sp.root,"data-streaming":t||void 0,children:/* @__PURE__ */ (0,f.jsxs)(`div`,{className:sp.body,children:[v,n&&(i===void 0||i===`response`||!e.some(e=>e.kind!==`reasoning`&&e.kind!==`tool-call`))&&/* @__PURE__ */ (0,f.jsx)(`span`,{className:sp.stopped,children:u(`message.stopped`)})]})})});function up({hidden:e,reveal:t,children:n}){let r=vd(e,t??dp);return/* @__PURE__ */ (0,f.jsx)(`div`,{ref:r,"data-turn-process-inline":e||void 0,children:n})}let dp=()=>{},fp=(0,d.memo)(function({node:e,groupPart:t,useDisclosure:n,useTurnData:r,turnProcess:i,openFile:a,renderMessageImages:o,fileMentions:s,usePresentation:c,t:l}){let u=e.data,p=e.location.kind===`turn`||e.location.kind===`step`?e.location.turn:void 0,m=r(`turn-tail`),h=(0,d.useMemo)(()=>{if(p?.status===`closed`&&u.finalNode!==void 0&&m?.closing?.finalNode.seq===u.finalNode.seq)return{turn:p,seq:u.finalNode.seq,openFile:a}},[u.finalNode,a,m,p]),g=(0,d.useMemo)(()=>h===void 0?void 0:s(h),[s,h]),_=i!==void 0&&i.foldable&&i.spec.answerStep===u.step&&i.spec.inlineReasoning&&!i.open,v=(0,d.useCallback)(()=>{i?.setOpen(!0)},[i]);return/* @__PURE__ */ (0,f.jsx)(lp,{blocks:u.blocks,groupPart:t,useDisclosure:n,streaming:u.status===`running`,interrupted:u.status===`interrupted`,renderMessageImages:o,reasoningHidden:_,usePresentation:c,revealProcess:v,mentions:g,t:l})}),pp=`@deepseek-ai/dsh-client-ui-chat/GenericCommandCard.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(pp)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=pp,e.textContent=`.zcz1WW_root{flex-direction:column;display:flex}.zcz1WW_leading{flex-shrink:0}.zcz1WW_title{font-weight:400}.zcz1WW_separator{background:var(--dsw-alias-label-caption);border-radius:1px;flex:none;width:2px;height:2px;margin:0 8px}.zcz1WW_summary{min-width:0;font-size:var(--dsh-content-font-size-secondary,13px);line-height:calc(24px + var(--dsh-content-font-delta,0px));text-overflow:ellipsis;white-space:nowrap;flex:auto;overflow:hidden}.zcz1WW_summary[data-error],.zcz1WW_body[data-error]{color:var(--dsw-alias-state-error-primary)}.zcz1WW_body{border:.5px solid var(--dsw-alias-border-l1);border-radius:var(--dsw-radius-lg);background:var(--dsw-alias-markdown-code-block);max-height:260px;color:var(--dsw-alias-label-primary);font:var(--dsw-font-markdown-code-block-small);white-space:pre-wrap;margin:4px 0 4px 4px;padding:12px 16px;overflow:auto}`,document.head.appendChild(e)}var mp={body:`zcz1WW_body`,leading:`zcz1WW_leading`,root:`zcz1WW_root`,separator:`zcz1WW_separator`,summary:`zcz1WW_summary`,title:`zcz1WW_title`};let hp=/* @__PURE__ */ (0,f.jsx)(p.IconApiOutlineRegular,{size:14});function gp(e){return e===null?`running`:e.kind===`error`?`error`:`ok`}let _p=(0,d.memo)(function({node:e,t,runningSummary:n,successSummary:r}){let[i,a]=(0,d.useState)(!1),o=e.outcome?.text,s=e.outcome===null?n??t(`command.running`):o??(e.outcome.kind===`error`?t(`command.failed`):r??t(`command.done`)),c=e.name??t(`command.title`),l=gp(e.outcome),u=l===`running`,m=o!==void 0&&o.includes(`
135
- `)?o:null,h=i&&m!==null,g=(0,d.useCallback)(()=>{a(e=>!e)},[]),_=(0,d.useMemo)(()=>/* @__PURE__ */ (0,f.jsxs)(f.Fragment,{children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:mp.separator,"data-shimmer-decoration":!0,"aria-hidden":!0}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:mp.summary,"data-error":l===`error`||void 0,children:/* @__PURE__ */ (0,f.jsx)(p.TextShimmer,{children:s})})]}),[u,l,s]),v=(0,d.useMemo)(()=>h?/* @__PURE__ */ (0,f.jsx)(`pre`,{className:mp.body,"data-error":l===`error`||void 0,children:m}):void 0,[m,h,l]);return/* @__PURE__ */ (0,f.jsxs)(`div`,{className:mp.root,"data-variant":`others`,"data-command":e.name??void 0,"data-state":l,children:[l===`running`&&/* @__PURE__ */ (0,f.jsx)(`span`,{className:kf.visuallyHidden,children:t(`row.running`)}),l===`error`&&/* @__PURE__ */ (0,f.jsx)(`span`,{className:kf.visuallyHidden,children:t(`row.failed`)}),/* @__PURE__ */ (0,f.jsx)(p.DisclosureRow,{leadingClassName:mp.leading,titleClassName:mp.title,icon:hp,title:c,running:u,open:h,expandable:m!==null,expandOnRowClick:!0,keepContentWhenOpen:!0,onToggle:g,collapsedContent:_,children:v})]})});function vp({node:e,compaction:t,t:n}){return t===void 0?/* @__PURE__ */ (0,f.jsx)(_p,{node:e,t:n,runningSummary:n(`message.compaction.running`),successSummary:n(`message.compaction`)}):/* @__PURE__ */ (0,f.jsx)(au,{node:t,title:n(`message.compaction.commandTitle`),fallbackSummary:e.outcome?.text??null,t:n})}let yp=(0,d.memo)(function({node:e,renderSlot:t,t:n}){let r=e.data,i=(0,d.useMemo)(()=>({node:r}),[r]);return/* @__PURE__ */ (0,f.jsx)(`div`,{className:Y.callRow,children:t(`conversation.chat.commandview`,i,{entryKey:r.name??``,fallback:/* @__PURE__ */ (0,f.jsx)(_p,{...i,t:n})})})}),bp=(0,d.memo)(function({node:e,t}){let n=e.data;return/* @__PURE__ */ (0,f.jsx)(`div`,{className:Y.callRow,children:/* @__PURE__ */ (0,f.jsx)(vp,{node:n.command,...n.compaction===null?{}:{compaction:n.compaction},t})})});function xp({text:e,update:t=!1,t:n}){let[r,i]=(0,d.useState)(!1);return/* @__PURE__ */ (0,f.jsx)(p.DisclosureRow,{className:Mu.root,icon:/* @__PURE__ */ (0,f.jsx)(p.IconBrowseOutlineRegular,{size:14}),chevronClassName:Mu.chevron,title:n(t?`message.systemPromptUpdate`:`message.systemPrompt`),open:r,expandable:!0,expandOnRowClick:!0,onToggle:()=>{i(e=>!e)},children:/* @__PURE__ */ (0,f.jsx)(`div`,{className:Mu.body,"data-system-prompt-body":!0,children:/* @__PURE__ */ (0,f.jsx)(gu,{content:[{type:`text`,text:e}],source:null,t:n})})})}let Sp=(0,d.memo)(function({node:e,t}){return/* @__PURE__ */ (0,f.jsx)(xp,{text:e.data.text,update:e.data.update===!0,t})}),Cp=`@deepseek-ai/dsh-client-ui-chat/TurnProcessNodeView.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(Cp)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=Cp,e.textContent=`.kKEWTq_root{box-sizing:border-box;width:100%;min-width:0;height:calc(33px + var(--dsh-content-font-delta,0px));border:none;border-bottom:.5px solid var(--dsw-alias-border-l2);color:var(--dsw-alias-label-tertiary);font:inherit;font-size:var(--dsh-content-font-size,14px);cursor:pointer;text-align:left;background:0 0;align-items:center;padding:0 0 8px;transition:color .1s;display:flex}.kKEWTq_root:disabled{cursor:default}.kKEWTq_root:hover:not(:disabled){color:var(--dsw-alias-label-secondary)}.kKEWTq_chevron{width:14px;height:14px;color:inherit;flex:none;margin-left:4px;transition:transform .1s}.kKEWTq_root[data-open] .kKEWTq_chevron{transform:rotate(180deg)}.kKEWTq_label{min-width:0;font-size:inherit;line-height:calc(24px + var(--dsh-content-font-delta,0px));text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.kKEWTq_durationNumber{font-family:var(--ds-font-family-code);font-variant-numeric:tabular-nums}@media (prefers-reduced-motion:reduce){.kKEWTq_root,.kKEWTq_chevron{transition:none}}`,document.head.appendChild(e)}var wp={chevron:`kKEWTq_chevron`,durationNumber:`kKEWTq_durationNumber`,label:`kKEWTq_label`,root:`kKEWTq_root`};let Tp=(0,d.memo)(function({node:e,turnProcess:t,t:n}){if(t===void 0)throw Error(`turn-process node requires Turn process owner state`);let r=!t.foldable||t.open,i=e.location.kind===`turn`||e.location.kind===`step`?e.location.turn:void 0;if(i?.status!==`closed`)return null;let a=t.foldable&&t.hasContent&&!hd(e),o=i.end?.data.reason.kind,s=i.start===void 0||i.end===void 0||i.end.time<=i.start.time?void 0:Math.max(1e3,i.end.time-i.start.time),c=s===void 0||o===`aborted`||o===`error`?void 0:Lu(s,n),l=n(o===`aborted`?`message.stopped`:o===`error`?`message.turnProcess.failed`:c===void 0?`message.turnProcess.worked`:`message.turnProcess.took`),u=n(o===`aborted`?`message.stopped`:o===`error`?`message.turnProcess.failed`:`message.turnProcess.worked`);return/* @__PURE__ */ (0,f.jsxs)(f.Fragment,{children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:kf.visuallyHidden,role:`status`,"aria-live":`polite`,"aria-atomic":`true`,children:u}),/* @__PURE__ */ (0,f.jsxs)(`button`,{type:`button`,className:wp.root,"data-open":r||void 0,"data-turn-process":e.data.turn,"data-turn-process-messages":e.data.messageCount,"data-turn-process-tool-calls":e.data.toolCallCount,"data-turn-process-subagents":e.data.subagentCount,disabled:!a,"aria-expanded":t.hasContent?r:void 0,onClick:e=>{e.currentTarget.focus(),t.setOpen(!r)},children:[/* @__PURE__ */ (0,f.jsxs)(`span`,{className:wp.label,children:[l,c?.map((e,t)=>/* @__PURE__ */ (0,f.jsx)(`span`,{className:e.numeric?wp.durationNumber:void 0,children:e.text},t))]}),a&&/* @__PURE__ */ (0,f.jsx)(p.IconChevronDownOutlineRegular,{className:wp.chevron})]})]})});function Ep(e,t,n,r){let[i,a]=(0,d.useState)({}),[o,s]=(0,d.useState)(),[c,l]=(0,d.useState)(0),u=JSON.stringify(t.filter(e=>n.has(e.path)&&e.hunks===void 0).map(e=>[e.path,e.revision]));return(0,d.useEffect)(()=>{let t=JSON.parse(u).filter(([e,t])=>i[e]?.revision!==t);if(!r||t.length===0)return;let n=!0;return s(void 0),Promise.all(t.map(async([t,n])=>[t,{revision:n,diffs:(await r(e,t)).filter(e=>e.path===t)}])).then(e=>{n&&a(t=>({...t,...Object.fromEntries(e)}))},e=>{n&&s(e instanceof Error?e.message:String(e))}),()=>{n=!1}},[e,u,r,i,c]),{diffs:e=>e.hunks??(i[e.path]?.revision===e.revision?i[e.path]?.diffs:void 0),error:o,retry:()=>l(e=>e+1)}}let Dp=`@deepseek-ai/dsh-client-ui-chat/TurnChangesCard.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(Dp)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=Dp,e.textContent=`.cLLDhG_card{border:1px solid var(--dsw-alias-border-l2);corner-shape:round;color:var(--dsw-alias-label-primary);font-size:calc(var(--dsh-content-font-size-secondary,13px) + 2px);--dsh-change-stat-font-size:calc(var(--dsh-content-font-size-secondary,13px) + 1px);--dsw-alias-state-success-primary:var(--dsw-alias-file-diff-added-marker);--dsw-alias-state-error-primary:var(--dsw-alias-file-diff-deleted-marker);border-radius:12px;margin:8px 0;line-height:20px;overflow:hidden}.cLLDhG_header{align-items:center;gap:12px;padding:12px;display:flex}.cLLDhG_icon{corner-shape:round;background:color-mix(in srgb, var(--dsw-alias-label-primary) 4%, transparent);width:44px;height:44px;color:var(--dsw-alias-label-secondary);border-radius:12px;flex:none;place-items:center;display:grid}.cLLDhG_text{flex-direction:column;flex:auto;gap:2px;min-width:0;display:flex}.cLLDhG_title{text-overflow:ellipsis;white-space:nowrap;font-weight:600;overflow:hidden}.cLLDhG_review,.cLLDhG_fileHead,.cLLDhG_more{color:inherit;font:inherit;text-align:left;cursor:pointer;background:0 0;border:0}.cLLDhG_review{border:1px solid var(--dsw-alias-border-l2);corner-shape:round;font-size:var(--dsh-content-font-size,14px);white-space:nowrap;border-radius:12px;flex:none;padding:4px 8px;font-weight:500}.cLLDhG_review:hover,.cLLDhG_fileHead:hover,.cLLDhG_more:hover{background:var(--dsw-alias-interactive-bg-hover)}.cLLDhG_review:focus-visible,.cLLDhG_fileHead:focus-visible,.cLLDhG_more:focus-visible{outline:2px solid var(--dsw-alias-label-tertiary);outline-offset:-2px}.cLLDhG_files{border-top:1px solid var(--dsw-alias-border-l2);margin:0;padding:0;list-style:none}.cLLDhG_fileHead{justify-content:space-between;align-items:center;gap:12px;width:100%;min-height:40px;padding:8px 12px;display:flex}.cLLDhG_fileHead .cLLDhG_path{min-width:0;font-size:inherit;--dsw-alias-label-tertiary:var(--dsw-alias-label-secondary);flex:1}.cLLDhG_diff{padding:0 12px 12px}.cLLDhG_file:first-child .cLLDhG_diff:first-child{padding-top:12px}.cLLDhG_more{align-items:center;gap:8px;width:100%;min-height:40px;padding:8px 12px;font-weight:500;display:flex}.cLLDhG_mobileChevron,.cLLDhG_mobileFileIcon,.cLLDhG_mobilePath,.cLLDhG_mobileFullPath{display:none}.cLLDhG_chevron{flex:none;transition:transform .15s}.cLLDhG_chevron[data-open=true]{transform:rotate(180deg)}@media (width<=480px){.cLLDhG_header{grid-template-columns:36px minmax(0,1fr);gap:8px;display:grid}.cLLDhG_icon{width:36px;height:36px}.cLLDhG_review{grid-column:2;justify-self:start}}[data-phone] .cLLDhG_card{-webkit-text-size-adjust:100%;text-size-adjust:100%;min-width:0;max-width:100%;font-size:var(--dsh-content-font-size-secondary,13px);line-height:calc(20px + var(--dsh-content-font-delta-secondary,0px));--dsh-change-stat-font-size:calc(var(--dsh-content-font-size-secondary,13px) - 1px);--dsh-diff-inline-padding:12px;--dsh-diff-body-padding:4px 0 8px}[data-phone] .cLLDhG_header{grid-template-columns:20px minmax(0,1fr) 44px;gap:8px;min-height:52px;padding:0 4px 0 12px;display:grid}[data-phone] .cLLDhG_icon{background:0 0;border-radius:0;width:20px;height:20px}[data-phone] .cLLDhG_icon>svg{width:16px;height:16px}[data-phone] .cLLDhG_text{flex-direction:row;align-items:center;gap:8px}[data-phone] .cLLDhG_title{flex:auto;min-width:0;font-weight:500}[data-phone] .cLLDhG_review{border-radius:var(--dsw-radius-sm);border:0;grid-column:auto;justify-self:stretch;place-items:center;width:44px;height:44px;padding:0;display:grid}[data-phone] .cLLDhG_reviewLabel{display:none}[data-phone] .cLLDhG_mobileChevron,[data-phone] .cLLDhG_mobileFileIcon{color:var(--dsw-alias-label-secondary);flex:none;display:block}[data-phone] .cLLDhG_mobileChevron{transition:transform .15s}[data-phone] .cLLDhG_mobileChevron[data-open=true]{transform:rotate(180deg)}[data-phone] .cLLDhG_fileHead,[data-phone] .cLLDhG_more{gap:8px;min-height:44px;padding:0 12px}[data-phone] .cLLDhG_file+.cLLDhG_file{border-top:1px solid var(--dsw-alias-border-l2)}[data-phone] .cLLDhG_path{display:none}[data-phone] .cLLDhG_mobilePath{flex-direction:column;flex:1;min-width:0;padding-block:4px;display:flex}[data-phone] .cLLDhG_fileName{text-overflow:ellipsis;white-space:nowrap;font-weight:500;overflow:hidden}[data-phone] .cLLDhG_directory,[data-phone] .cLLDhG_mobileFullPath{color:var(--dsw-alias-label-secondary);font-size:calc(11px + var(--dsh-content-font-delta-secondary,0px));line-height:calc(16px + var(--dsh-content-font-delta-secondary,0px));white-space:normal;overflow-wrap:anywhere}[data-phone] .cLLDhG_mobileFullPath{user-select:text;padding:4px 12px;display:block}[data-phone] .cLLDhG_diff,[data-phone] .cLLDhG_file:first-child .cLLDhG_diff:first-child{padding:0}[data-phone] .cLLDhG_diffStatus{overflow-wrap:anywhere;padding:12px;display:block}[data-phone] .cLLDhG_diffStatus button{min-width:44px;min-height:44px}[data-phone] .cLLDhG_inlineDiff{border-radius:0;min-width:0;max-width:100%;margin:0}[data-phone] .cLLDhG_inlineDiff [data-diff-body]{box-sizing:border-box;-webkit-text-size-adjust:100%;text-size-adjust:100%;width:100%;min-width:0;font-size:calc(var(--dsw-font-markdown-code-block-font-size,11px) + var(--dsh-content-font-delta,0px));line-height:calc(var(--dsw-font-markdown-code-block-line-height,19px) + var(--dsh-content-font-delta,0px));tab-size:2;overscroll-behavior-x:contain}[data-phone] .cLLDhG_inlineDiff [data-diff-row=path]{display:none}[data-phone] .cLLDhG_inlineDiff [data-code-block-banner]{gap:8px;min-height:44px;padding:0 8px 0 12px}[data-phone] .cLLDhG_inlineDiff [data-code-block-banner] button{width:44px;height:44px}@media (prefers-reduced-motion:reduce){[data-phone] .cLLDhG_mobileChevron{transition:none}}`,document.head.appendChild(e)}var Z={card:`cLLDhG_card`,chevron:`cLLDhG_chevron`,diff:`cLLDhG_diff`,diffStatus:`cLLDhG_diffStatus`,directory:`cLLDhG_directory`,file:`cLLDhG_file`,fileHead:`cLLDhG_fileHead`,fileName:`cLLDhG_fileName`,files:`cLLDhG_files`,header:`cLLDhG_header`,icon:`cLLDhG_icon`,inlineDiff:`cLLDhG_inlineDiff`,mobileChevron:`cLLDhG_mobileChevron`,mobileFileIcon:`cLLDhG_mobileFileIcon`,mobileFullPath:`cLLDhG_mobileFullPath`,mobilePath:`cLLDhG_mobilePath`,more:`cLLDhG_more`,path:`cLLDhG_path`,review:`cLLDhG_review`,reviewLabel:`cLLDhG_reviewLabel`,text:`cLLDhG_text`,title:`cLLDhG_title`};let Op=(0,d.memo)(function({nodeStore:e,turn:t,t:n,useProjection:r,loadTurnDiffs:i}){let a=ee(e,t,r),o=(0,d.useMemo)(()=>{let e=/* @__PURE__ */ new Map;for(let t of a){let n=C(t.path);e.set(n,(e.get(n)??0)+1)}return e},[a]),[s,c]=(0,d.useState)(()=>/* @__PURE__ */ new Set),[l,u]=(0,d.useState)(!1),m=Ep(t,a,s,i),h=(0,d.useMemo)(()=>({codeLabel:n(`diff.code`),wrapLabel:n(`diff.wrap`),unwrapLabel:n(`diff.unwrap`),copy:n(`diff.copy`),copied:n(`diff.copied`),collapseAria:n(`diff.collapseAria`),expandAria:e=>n(`diff.expandAria`,{count:e}),collapse:n(`diff.collapse`),expand:e=>n(`diff.expand`,{count:e})}),[n]);if(a.length===0)return null;let{added:g,removed:_}=S(a),[y]=a,b=a.length===1&&y!==void 0?n(`chat.fileEdited`,{name:C(y.path)}):n(`chat.filesEdited`,{count:a.length}),x=a.some(e=>s.has(e.path)),te=l?a:a.slice(0,3),w=a.length-te.length;return/* @__PURE__ */ (0,f.jsxs)(`section`,{className:Z.card,"data-turn-changes":t,children:[/* @__PURE__ */ (0,f.jsxs)(`div`,{className:Z.header,children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:Z.icon,"aria-hidden":`true`,children:/* @__PURE__ */ (0,f.jsx)(p.IconFileDiffOutlineRegular,{size:24})}),/* @__PURE__ */ (0,f.jsxs)(`span`,{className:Z.text,children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:Z.title,title:b,children:b}),/* @__PURE__ */ (0,f.jsx)(v,{added:g,removed:_})]}),/* @__PURE__ */ (0,f.jsxs)(`button`,{type:`button`,className:Z.review,"aria-expanded":x,"aria-label":n(x?`chat.hideChanges`:`chat.viewChanges`),onClick:()=>{c(new Set(x?[]:a.map(e=>e.path))),x||u(!0)},children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:Z.reviewLabel,children:n(x?`chat.hideChanges`:`chat.viewChanges`)}),/* @__PURE__ */ (0,f.jsx)(p.IconChevronDownOutlineRegular,{size:16,className:Z.mobileChevron,"data-open":x})]})]}),(a.length>1||x)&&/* @__PURE__ */ (0,f.jsxs)(`ul`,{className:Z.files,children:[te.map(e=>{let t=m.diffs(e),r=C(e.path);return/* @__PURE__ */ (0,f.jsxs)(`li`,{className:Z.file,children:[a.length>1&&/* @__PURE__ */ (0,f.jsxs)(`button`,{type:`button`,className:Z.fileHead,"aria-expanded":s.has(e.path),onClick:()=>{c(t=>{let n=new Set(t);return n.has(e.path)?n.delete(e.path):n.add(e.path),n})},children:[/* @__PURE__ */ (0,f.jsx)(p.IconFileDiffOutlineRegular,{size:16,className:Z.mobileFileIcon}),/* @__PURE__ */ (0,f.jsx)(p.PathLabel,{path:e.path,className:Z.path}),/* @__PURE__ */ (0,f.jsxs)(`span`,{className:Z.mobilePath,children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:Z.fileName,"aria-hidden":`true`,children:r}),(o.get(r)??0)>1&&/* @__PURE__ */ (0,f.jsx)(`span`,{className:Z.directory,"aria-hidden":`true`,children:e.path.slice(0,e.path.length-r.length)}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:kf.visuallyHidden,children:e.path})]}),/* @__PURE__ */ (0,f.jsx)(v,{added:e.added,removed:e.removed}),/* @__PURE__ */ (0,f.jsx)(p.IconChevronDownOutlineRegular,{size:16,className:Z.mobileChevron,"data-open":s.has(e.path)})]}),s.has(e.path)&&/* @__PURE__ */ (0,f.jsxs)(`div`,{className:Z.diff,children:[/* @__PURE__ */ (0,f.jsx)(`div`,{className:Z.mobileFullPath,children:e.path}),t===void 0?m.error?/* @__PURE__ */ (0,f.jsxs)(`div`,{role:`alert`,className:Z.diffStatus,children:[m.error,` `,/* @__PURE__ */ (0,f.jsx)(`button`,{type:`button`,onClick:m.retry,children:n(`chat.retryDiff`)})]}):/* @__PURE__ */ (0,f.jsx)(`span`,{role:`status`,className:Z.diffStatus,children:n(`chat.loadingDiff`)}):/* @__PURE__ */ (0,f.jsx)(p.DiffBlock,{diffs:[...t],labels:h,maxLines:1/0,className:Z.inlineDiff})]})]},e.path)}),a.length>3&&/* @__PURE__ */ (0,f.jsx)(`li`,{children:/* @__PURE__ */ (0,f.jsxs)(`button`,{type:`button`,className:Z.more,"aria-expanded":l,onClick:()=>u(e=>!e),children:[w>0?n(`chat.showMoreFiles`,{count:w}):n(`chat.collapseFiles`),/* @__PURE__ */ (0,f.jsx)(p.IconChevronDownOutlineRegular,{size:16,className:Z.chevron,"data-open":l})]})})]})]})});function kp(e){return e.flatMap(e=>e.kind===`text`?[e.text]:[]).join(``)}function Ap(e){return e.some(e=>e.kind===`reasoning`||e.kind===`tool-call`?!1:e.kind!==`text`||e.text.trim()!==``)}let jp=`@deepseek-ai/dsh-client-ui-chat/TurnTailNodeView.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(jp)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=jp,e.textContent=`.Lw1WLW_root{flex-direction:column;gap:16px;display:flex}.Lw1WLW_actions{margin-top:4px;margin-left:-6px}`,document.head.appendChild(e)}var Mp={actions:`Lw1WLW_actions`,root:`Lw1WLW_root`};function Np(e,t,n){let r=e.locations.getTurn(t);for(let t=r.length-1;t>=0;t--){let i=e.nodes.get(r[t]);if(!(i===void 0||i.kind===`turn-tail`||i.kind===`turn-process`||n&&i.kind===`turn-max-tokens`))return i}}let Pp=(0,d.memo)(function({node:e,openFile:t,forkAt:n,loadTurnDiffs:r,renderSlot:i,t:a,useChat:o,useSession:s,useProjection:c}){let l=s(e=>e.openState===`open`),u=(0,d.useRef)(!1),[p,m]=(0,d.useState)(!1),[h,g]=(0,d.useState)(),_=e.data,v=o(e=>e.nodes),y=o(e=>(Np(e,_.turn,!0)?.anchorSeq??-1)>(_.closing?.finalNode.seq??_.seq)),b=o(e=>{if(e.timeline.turnOrder.at(-1)!==_.turn)return!1;let t=Np(e,_.turn,!1),n=t?.kind===`assistant-step`?t.data.blocks.findLast(e=>e.kind!==`text`&&e.kind!==`reasoning`||e.text.trim()!==``):void 0;return n!==void 0&&Ap([n])}),x=e.location.kind===`turn`||e.location.kind===`step`?e.location.turn:void 0,ee=Uu(c,x?.turn,`end`);if(x===void 0)return null;let S=_.closing,C=i(`conversation.chat.turnTail`,{turn:x,seq:S?.finalNode.seq??_.seq,openFile:t});if(S===null)return C===null?null:/* @__PURE__ */ (0,f.jsx)(`div`,{className:Mp.root,"data-turn-tail":_.turn,children:C});let te=S.finalNode.messageId,w=te===void 0?null:i(`conversation.chat.assistant-actions`,{messageId:te});return/* @__PURE__ */ (0,f.jsxs)(`div`,{className:Mp.root,"data-turn-tail":_.turn,"data-actions-reveal":b?`always`:`hover`,children:[/* @__PURE__ */ (0,f.jsx)(Op,{nodeStore:v,turn:_.turn,t:a,useProjection:c,loadTurnDiffs:r}),C,/* @__PURE__ */ (0,f.jsx)(Hu,{text:kp(S.blocks),time:ee,clock:`end`,onBranch:()=>{!u.current&&l&&(u.current=!0,m(!0),g(void 0),n(_.seq).catch(e=>{g(e instanceof Error?e.message:String(e))}).finally(()=>{u.current=!1,m(!1)}))},branchUnavailable:!l||p||_.branchUnavailable||y,className:Mp.actions,extraActions:w,t:a}),h!==void 0&&/* @__PURE__ */ (0,f.jsx)(`p`,{role:`alert`,children:a(`message.branchFailed`,{message:h})})]})});function Fp(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:{}}function Ip(e,t){return typeof e[t]==`string`?e[t]:``}function Lp(e){let t=Fp(e.source),n=Ip(t,`kind`),r=`message.trigger.request`,i=`request`;switch(n){case`goal`:r=`message.trigger.goal`,i=`goal`;break;case`agent-message`:r=`message.trigger.agent`,i=`agent`;break;case`team-message`:r=`message.trigger.team`,i=`team`;break;case`subagent-settled`:r=`message.trigger.subagent`,i=`subagent`;break;case`webhook`:{let e=Ip(t,`provider`)===`github`;r=e?`message.trigger.github`:`message.trigger.webhook`,i=e?`github`:`webhook`;break}case`schedule`:r=`message.trigger.schedule`,i=`schedule`;break;case`tool-jobs`:r=`message.trigger.job`,i=`job`;break;case`cordis-host-runner`:r=`message.trigger.plugin`,i=`plugin`}return{title:r,icon:i}}let Rp=`@deepseek-ai/dsh-client-ui-chat/TurnTriggerNodeView.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(Rp)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=Rp,e.textContent=`.eHX24W_root{border:.5px solid var(--dsw-alias-border-l1);border-radius:var(--dsw-radius-xl);background:var(--dsw-alias-turn-trigger-bg,var(--dsw-alias-markdown-code-block));min-width:0;transition:background-color .1s}.eHX24W_root:hover{background:var(--dsw-alias-turn-trigger-bg-hover,var(--dsw-alias-interactive-bg-hover))}.eHX24W_header{width:100%;color:var(--dsw-alias-label-tertiary);font:inherit;text-align:left;cursor:pointer;background:0 0;border:0;align-items:center;gap:10px;padding:12px 16px;transition:color .1s;display:flex}.eHX24W_header:hover{color:var(--dsw-alias-label-secondary)}.eHX24W_icon{color:inherit;flex:none;display:inline-flex}.eHX24W_title{font-size:var(--dsh-content-font-size,14px);flex:none}.eHX24W_time{color:inherit;font:var(--dsw-font-xxs-12);flex:none;margin-left:auto}.eHX24W_chevron,.eHX24W_openChevron{color:inherit;flex:none}.eHX24W_openChevron{transform:rotate(180deg)}.eHX24W_body{padding:0 16px 12px 40px}.eHX24W_explanation{color:var(--dsw-alias-label-secondary);font:var(--dsw-font-xxs-12);margin:8px 0}.eHX24W_content{white-space:pre-wrap;overflow-wrap:anywhere;max-height:240px;font:var(--dsw-font-xxs-12);overflow:auto}@media (prefers-reduced-motion:reduce){.eHX24W_root,.eHX24W_header{transition:none}}`,document.head.appendChild(e)}var zp={body:`eHX24W_body`,chevron:`eHX24W_chevron`,content:`eHX24W_content`,explanation:`eHX24W_explanation`,header:`eHX24W_header`,icon:`eHX24W_icon`,openChevron:`eHX24W_openChevron`,root:`eHX24W_root`,time:`eHX24W_time`,title:`eHX24W_title`};let Bp={request:p.IconContextInjectionOutlineRegular,goal:p.IconGoalOutlineRegular,agent:p.IconPaperPlaneOutlineRegular,team:p.IconAgentPresetOutlineRegular,subagent:p.IconAgentPresetOutlineRegular,github:p.IconBranchOutlineRegular,webhook:p.IconGlobeOutlineRegular,schedule:p.IconClockOutlineRegular,job:p.IconQueueOutlineRegular,plugin:p.IconCordisPluginOutlineRegular};function Vp({node:e,t}){let[n,r]=(0,d.useState)(!1),i=(0,d.useId)(),a=Lp(e.data),o=Bp[a.icon],s=new Date(e.data.time),c=Ru(e.data.time,t);return/* @__PURE__ */ (0,f.jsxs)(`section`,{className:zp.root,"data-turn-trigger":!0,children:[/* @__PURE__ */ (0,f.jsxs)(`button`,{className:zp.header,type:`button`,"aria-expanded":n,"aria-controls":i,onClick:()=>{r(!n)},children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:zp.icon,"aria-hidden":!0,children:/* @__PURE__ */ (0,f.jsx)(o,{size:14})}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:zp.title,children:t(a.title)}),/* @__PURE__ */ (0,f.jsx)(`time`,{className:zp.time,dateTime:s.toISOString(),children:c}),/* @__PURE__ */ (0,f.jsx)(p.IconChevronDownOutlineRegular,{size:12,className:n?zp.openChevron:zp.chevron})]}),n&&/* @__PURE__ */ (0,f.jsxs)(`div`,{id:i,className:zp.body,children:[/* @__PURE__ */ (0,f.jsx)(`p`,{className:zp.explanation,children:t(`message.trigger.explanation`)}),/* @__PURE__ */ (0,f.jsx)(`div`,{className:zp.content,children:/* @__PURE__ */ (0,f.jsx)(wu,{content:e.data.content,source:e.data.source,t})})]})]})}function Hp(e,t){e.slots.inject(`conversation.chat.node`,()=>e.slots.register({name:`conversation.chat.node`,key:`user`,locale:X,inject:()=>({links:e.get(`chatLinks`)})},rd)),e.slots.inject(`conversation.chat.node`,()=>e.slots.register({name:`conversation.chat.node`,key:`steering`,locale:X,inject:()=>({links:e.get(`chatLinks`)})},rd)),e.slots.inject(`conversation.chat.node`,()=>e.slots.register({name:`conversation.chat.node`,key:`context`,locale:X},ad)),e.slots.inject(`conversation.chat.node`,()=>e.slots.register({name:`conversation.chat.node`,key:`turn-trigger`,locale:X},Vp)),e.slots.inject(`conversation.chat.node`,()=>e.slots.register({name:`conversation.chat.node`,key:`system-prompt`,locale:X},Sp)),e.slots.inject(`conversation.chat.node`,()=>e.slots.register({name:`conversation.chat.node`,key:`assistant-step`,locale:X,inject:()=>({hooks:{presentation:t}})},fp)),e.slots.inject(`conversation.chat.node`,()=>e.slots.register({name:`conversation.chat.node`,key:`command`,locale:X,children:{"conversation.chat.commandview":{kind:`keyed`,scope:`session`}}},yp)),e.slots.inject(`conversation.chat.node`,()=>e.slots.register({name:`conversation.chat.node`,key:`manual-compaction`,locale:X},bp)),e.slots.inject(`conversation.chat.node`,()=>e.slots.register({name:`conversation.chat.node`,key:`compaction`,locale:X},od)),e.slots.inject(`conversation.chat.node`,()=>e.slots.register({name:`conversation.chat.node`,key:`model-retry`,locale:X},sd)),e.slots.inject(`conversation.chat.node`,()=>e.slots.register({name:`conversation.chat.node`,key:`turn-error`,locale:X},cd)),e.slots.inject(`conversation.chat.node`,()=>e.slots.register({name:`conversation.chat.node`,key:`turn-max-tokens`,locale:X},ld)),e.slots.inject(`conversation.chat.node`,()=>e.slots.register({name:`conversation.chat.node`,key:`turn-process`,locale:X},Tp)),e.slots.inject(`conversation.chat.node`,()=>e.slots.register({name:`conversation.chat.node`,key:`turn-tail`,locale:X,children:{"conversation.chat.turnTail":{kind:`list`,scope:`session`},"conversation.chat.assistant-actions":{kind:`list`,scope:`session`}}},Pp)),e.slots.inject(`conversation.chat.node`,()=>e.slots.register({name:`conversation.chat.node`,key:`unknown`,locale:X},ud))}let Up={interruptedAssistant:-.9,interruptedFollowup:-.8,processControl:-.1,maxTokensNotice:.05,finalizedFollowup:.1};function Wp(e){return e.start?.location??e.matches[0]?.location??{kind:`unresolved`}}function Gp(e,t,n,r,i={}){return{key:e.key,kind:t,id:e.id,target:`chat`,anchorSeq:n,location:i.location??Wp(e),visibility:i.visibility??`visible`,data:r}}function Kp(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:null}function qp(e,t){let n=e[t];return typeof n==`string`&&n.length>0?n:null}function Jp(e,t,n){let r=e[t];if(!Array.isArray(r))return[];let i=[];for(let e of r){let t=Kp(e),r=t===null?null:qp(t,n);r!==null&&!i.includes(r)&&i.push(r)}return i}function Yp(e){return e.length>0?e.join(`, `):null}let Xp=[`instructions`,`catalog`,`snapshot`,`notice`,`relay`,`recall`];function Zp(e){let t=Kp(e),n=t===null?null:qp(t,`form`);return n!==null&&Xp.includes(n)?n:null}function Qp(e){let t=Kp(e),n=t===null?null:qp(t,`kind`);if(t===null||n===null)return{role:`inject`,label:null};switch(n){case`session-reference`:return{role:`recall`,label:Yp(Jp(t,`references`,`label`))??n};case`agent-instructions`:return{role:`inject`,label:Yp(Jp(t,`changes`,`path`))??n};case`skill-invocation`:return{role:`inject`,label:qp(t,`name`)??n};default:return{role:`inject`,label:n}}}function $p(e){let t=Kp(e);return t===null||qp(t,`kind`)!==`session-reference`?[]:Jp(t,`references`,`label`)}function em(e){let t=Kp(e);return t===null||qp(t,`kind`)!==`skill-invocation`?null:qp(t,`name`)}function tm(e){return e.map(nm)}function nm(e){switch(e.type){case`text`:return{kind:`text`,text:e.text};case`reasoning`:return{kind:`reasoning`,text:e.text};case`image`:return{kind:`image`,attachment:e.attachment};case`tool-call`:return{kind:`tool-call`,callId:String(e.id),name:e.name,argsRaw:e.arguments};default:return{kind:`other`,block:e}}}function rm(e){switch(e){case`text`:return{kind:`text`,text:``};case`reasoning`:return{kind:`reasoning`,text:``};case`tool-call`:return{kind:`tool-call`,callId:``,name:``,argsRaw:``};default:return{kind:`other`,block:null}}}function im(e){if(typeof e!=`object`||!e)return{message:String(e)};let t=e,n=typeof t.code==`string`?t.code:void 0;return n===`AUTH`?{code:n,message:``}:{...n===void 0?{}:{code:n},message:typeof t.message==`string`?t.message:JSON.stringify(e)}}function am(e){switch(e.type){case`text-delta`:case`reasoning-delta`:return e.text!==``;case`tool-call-delta`:return e.argumentsDelta!==``||e.name!==void 0;default:return!1}}function om(e,t){return{turn:e,step:t,blocks:[],visibleByIndex:[],visibleBlocks:0,firstVisibleSeq:void 0,firstVisibleTime:void 0,firstTokenTime:void 0,final:void 0,usage:void 0}}function sm(e){return e.filter(e=>e!==void 0)}function cm(e){return e===void 0||e.kind===`tool-call`?!1:e.kind===`text`||e.kind===`reasoning`?e.text.trim()!==``:!0}function lm(e){return e.some(cm)}function um(e){return e.some(e=>e.kind===`text`||e.kind===`reasoning`?e.text.trim()!==``:!0)}function dm(e){return{...om(e.turn,e.step),firstTokenTime:e.firstTokenTime}}function fm(e,t,n,r){if(t.type===`tool-call-delta`){let n=e.blocks[t.index];if(n?.kind===`tool-call`&&n.callId!==``&&(t.name===void 0||t.name===n.name)&&(e.firstTokenTime!==void 0||!am(t)))return e}let i=[...e.blocks],a=-1,o=!1,s=!1;switch(t.type){case`block-start`:a=t.index,o=e.visibleByIndex[t.index]===!0,i[t.index]=rm(t.blockType),s=cm(i[t.index]);break;case`text-delta`:{let n=i[t.index];a=t.index,o=e.visibleByIndex[t.index]===!0,i[t.index]={kind:`text`,text:(n?.kind===`text`?n.text:``)+t.text},s=n?.kind===`text`&&o||t.text.trim()!==``;break}case`reasoning-delta`:{let n=i[t.index];a=t.index,o=e.visibleByIndex[t.index]===!0,i[t.index]={kind:`reasoning`,text:(n?.kind===`reasoning`?n.text:``)+t.text},s=n?.kind===`reasoning`&&o||t.text.trim()!==``;break}case`tool-call-delta`:{let n=i[t.index];a=t.index,o=e.visibleByIndex[t.index]===!0,i[t.index]={kind:`tool-call`,callId:(n?.kind===`tool-call`?n.callId:``)||String(t.id),name:t.name??(n?.kind===`tool-call`?n.name:``),argsRaw:n?.kind===`tool-call`?n.argsRaw:``};break}case`block-end`:a=t.index,o=e.visibleByIndex[t.index]===!0,i[t.index]=nm(t.block),s=cm(i[t.index]);break;case`usage`:return{...e,usage:t.usage};default:return e}let c=e.visibleBlocks-Number(o)+Number(s),l=e.visibleByIndex;if(o!==s){let e=[...l];e[a]=s,l=e}let u=am(t);return{...e,blocks:i,visibleByIndex:l,visibleBlocks:c,...c>0&&e.firstVisibleSeq===void 0?{firstVisibleSeq:n,firstVisibleTime:r}:{},...u&&e.firstTokenTime===void 0?{firstTokenTime:r}:{}}}function pm(e,t,n){let r=tm(n.data.message.content),i=r.map(cm);return{...e,blocks:r,visibleByIndex:i,visibleBlocks:i.reduce((e,t)=>e+Number(t),0),final:t,usage:n.data.usage}}function mm(e){if(e.kind===`step`&&e.step.status===`closed`&&e.step.end!==void 0)return e.step.end;if((e.kind===`step`||e.kind===`turn`)&&e.turn.status===`closed`&&e.turn.end!==void 0)return e.turn.end}function hm(e,t){let n=e.final;if(n?.event.type===`assistant/message`){let r=n.event;return{kind:`assistant`,seq:r.seq,messageId:r.data.message.id,time:r.time,turn:e.turn,step:e.step,blocks:tm(r.data.message.content),usage:r.data.usage,timing:{stepStartTime:t.start?.event.time??null,firstTokenTime:e.firstTokenTime??null,completedTime:r.time},...r.data.interrupted===!0?{interrupted:!0}:{}}}let r=t.start?.location??t.matches.at(-1)?.location,i=r===void 0?void 0:mm(r);if(i===void 0)return;let a=sm(e.blocks);if(um(a))return{kind:`assistant`,seq:i.seq+Up.interruptedAssistant,time:i.time,turn:e.turn,step:e.step,blocks:a,interrupted:!0}}function gm(e){let t;for(let n of e.matches)n.event.type===`assistant/live-chunk`?(t??=om(n.event.data.turn,n.event.data.step),t=fm(t,n.event.data.chunk,n.event.seq,n.event.time)):n.event.type===`assistant/message`?(t??=om(n.event.data.turn,n.event.data.step),t=pm(t,n,n.event)):n.event.type===`llm/retry`&&t!==void 0&&(t=dm(t));return t}function _m(e){let t=e.state??gm(e);if(t===void 0)return;let n=hm(t,e),r=n?.blocks??sm(t.blocks),i=n===void 0?t.visibleBlocks>0:lm(r),a=n?.interrupted===!0?`interrupted`:n===void 0?`running`:`settled`,o=(n?.interrupted===!0?n.seq:t.firstVisibleSeq??n?.seq)??e.matches[0]?.event.seq??0,s=n?.time??t.firstVisibleTime??e.matches[0]?.event.time??0;return{anchorSeq:o,visible:i,settled:n,data:{status:a,turn:t.turn,step:t.step,blocks:r,time:s,...t.usage===void 0?{}:{usage:t.usage},...n===void 0?{}:{finalNode:n}}}}function vm(e){let t=e.start?.location??e.matches.at(-1)?.location;return t?.kind===`step`?t.step.data.get(`assistant-step`):void 0}let ym={kind:`assistant-step`,target:`chat`,match:e=>e.type===`step/start`?{id:`${e.data.turn}:${e.data.step}`,role:`start`}:e.type===`assistant/live-chunk`||e.type===`assistant/message`&&e.surfaceOp===`append`||e.type===`llm/retry`?{id:`${e.data.turn}:${e.data.step}`,role:`update`}:null,start:(e,t)=>{if(t.event.type!==`step/start`)throw Error(`assistant-step start requires step/start`);return om(t.event.data.turn,t.event.data.step)},update:(e,t)=>t.event.type===`assistant/live-chunk`?fm(e.state,t.event.data.chunk,t.event.seq,t.event.time):t.event.type===`assistant/message`?pm(e.state,t,t.event):t.event.type===`llm/retry`?dm(e.state):e.state,publication:e=>{if(e.event.type===`step/start`)return`none`;if(e.event.type!==`assistant/live-chunk`)return`immediate`;let t=e.event.data.chunk.type;return t===`usage`||t===`finish`?`none`:`animation-frame`},buildLocationData:(e,t)=>{if(t!==`step`)return null;let n=_m(e);return n===void 0?null:{kind:`step`,turn:n.data.turn,step:n.data.step,key:`assistant-step`,value:n.data}},buildViewNode:e=>{let t=e.current.get(`chat`),n=e.state??gm(e),r=vm(e);if(n===void 0||r===void 0)return t==null?null:{...t,visibility:`hidden`};let i=r.finalNode,a=i===void 0?n.visibleBlocks>0:lm(r.blocks);return i===void 0&&!a&&t==null?null:Gp(e,`assistant-step`,(i?.interrupted===!0?i.seq:n.firstVisibleSeq??i?.seq)??e.matches[0]?.event.seq??0,r,{visibility:i?.interrupted===!0||a?`visible`:`hidden`})}};function bm(e){let t=ym.match.bind(ym);e.uiConversation.events.register({...ym,match:{"step/start":t,"assistant/live-chunk":t,"assistant/message":t,"llm/retry":t}})}function xm(e){return`kind`in e}function Sm(e){return!xm(e)}function Cm(e){return e.visibility===`visible`&&e.kind!==`system-prompt`&&(e.kind!==`context`||e.data.content.some(e=>e.type===`tool-addition`||e.type===`tool-removal`))&&(e.kind!==`command`||e.data.name!==`permission`)}function wm(e,t){let n=``,r=!1;for(let i of e){if(n.length>=t*2){r=!0;break}let e=i.length>t*2,a=e?i.slice(0,t*2):i;if(n+=n===``?a:` ${a}`,e){r=!0;break}}let i=n.replace(/\s+/g,` `).trim();return i.length>t-1?`${i.slice(0,t-1).trimEnd()}…`:r?`${i}…`:i}function Tm(e){return e.kind===`user`?wm(e.data.content.flatMap(e=>e.type===`text`?[e.text]:[]),50):``}function Em(e){return e.kind===`assistant-step`?wm(e.data.blocks.flatMap(e=>e.kind===`text`?[e.text]:[]),120):``}function Dm(e,t){return e===void 0||t===void 0?e===t:e.turn===t.turn&&e.anchorKey===t.anchorKey&&e.prompt===t.prompt&&e.response===t.response}function Om(e,t,n){let r=t.getTurn(e).map(e=>n.get(e)).filter(e=>e!==void 0&&Cm(e)),i=r.find(e=>e.kind===`user`),a=i??r[0];if(a===void 0)return;let o=r.findLast(e=>Em(e)!==``);return{turn:e,anchorKey:a.key,prompt:i===void 0?``:Tm(i),response:o===void 0?``:Em(o)}}function km(e){let t=e?.location;return t?.kind===`turn`||t?.kind===`step`?t.turn.turn:void 0}function Am(e,t){return e===t||e!==void 0&&t!==void 0&&e.spec===t.spec&&e.turn===t.turn&&e.turnStarted===t.turnStarted&&e.turnClosed===t.turnClosed&&e.hasExternalProcess===t.hasExternalProcess&&e.hasInterleavedInput===t.hasInterleavedInput&&e.compactAnswer===t.compactAnswer}function jm(e,t,n){let r=t.getTurn(e),i=r.map(e=>n.get(e)).find(e=>e?.kind===`turn-process`);if(i===void 0)return;let a=i.data,o=i.location;if(o.kind!==`turn`&&o.kind!==`step`)return;let s;for(let e of r){let t=n.get(e);(t?.kind===`user`||t?.kind===`steering`||t?.kind===`turn-trigger`)&&(a.controlAnchorSeq===o.turn.start?.seq||t.anchorSeq<a.controlAnchorSeq)&&(s=Math.max(s??t.anchorSeq,t.anchorSeq))}let c=!1,l=!1,u=!0;for(let e of r){let t=n.get(e);t!==void 0&&Cm(t)&&t.kind!==`turn-process`&&((t.kind===`user`||t.kind===`steering`||t.kind===`turn-trigger`)&&(s===void 0||t.anchorSeq>s)&&(l=!0,(a.answerAnchorSeq===null||t.anchorSeq<a.answerAnchorSeq)&&(u=!1)),!(dd.has(t.kind)||t.anchorSeq<a.processStartSeq)&&(t.kind!==`assistant-step`||a.answerStep===null||t.data.step!==a.answerStep)&&(c=!0))}return{turn:e,spec:a,turnStarted:o.turn.start!==void 0,turnClosed:o.turn.status===`closed`,hasExternalProcess:c,hasInterleavedInput:l,compactAnswer:u}}var Mm=class{presentations=/* @__PURE__ */ new Map;get(e){let t=km(e);return t===void 0?void 0:this.presentations.get(t)}replace(e,t,n){let r=/* @__PURE__ */ new Set;for(let t of e){let e=km(n.get(t));e!==void 0&&r.add(e)}let i=/* @__PURE__ */ new Set;for(let e of/* @__PURE__ */ new Set([...this.presentations.keys(),...r]))this.set(e,r.has(e)?jm(e,t,n):void 0)&&i.add(e);return i}update(e,t,n){let r=/* @__PURE__ */ new Set;for(let i of e)this.set(i,jm(i,t,n))&&r.add(i);return r}set(e,t){return!Am(this.presentations.get(e),t)&&(t===void 0?this.presentations.delete(e):this.presentations.set(e,t),!0)}};let Nm=[],Pm=[],Fm=[],Im=[];function Lm(e,t){return e.length===t.length&&e.every((e,n)=>e===t[n])}function Rm(e,t,n){let r=e.get(t);return r===void 0&&(r=n(),e.set(t,r)),r}var zm=class{read;label;listeners=/* @__PURE__ */ new Set;published;constructor(e,t){this.read=e,this.label=t,this.published=e()}getSnapshot=()=>this.read();subscribe=e=>(this.listeners.add(e),()=>{this.listeners.delete(e)});publish(){let e=this.getSnapshot();this.published!==e&&(this.published=e,(0,m.notifySubscribers)(this.listeners,this.label))}},Bm=class{nodes=/* @__PURE__ */ new Map;current=Im;dirty=!1;observable;source(){return this.observable??=new zm(()=>this.read(),`[ui-chat] turn kind nodes`)}set(e){let t=this.nodes.get(e.key);this.nodes.set(e.key,e),(t===void 0||t.data!==e.data||t.anchorSeq!==e.anchorSeq)&&(this.dirty=!0)}delete(e){this.nodes.delete(e),this.dirty=!0}publish(){this.observable?.publish()}read(){return this.dirty&&=(this.current=[...this.nodes.values()].sort((e,t)=>e.anchorSeq-t.anchorSeq).map(e=>e.data),!1),this.current}},Vm=class{byKey=/* @__PURE__ */ new Map;turnProcesses=new Mm;sources=/* @__PURE__ */ new Map;processSources=/* @__PURE__ */ new Map;dirtyKeys=/* @__PURE__ */ new Set;dirtyProcessKeys=/* @__PURE__ */ new Set;turnKinds=/* @__PURE__ */ new Map;dirtyTurnKinds=/* @__PURE__ */ new Set;valuesCache=Im;valuesDirty=!1;get(e){return this.byKey.get(e)}source(e){return Rm(this.sources,e,()=>new zm(()=>this.get(e),`[ui-chat] node source ${e}`))}turnDataSource(e,t){return this.turnKind(e,t).source()}turnKind(e,t){return Rm(Rm(this.turnKinds,e,()=>/* @__PURE__ */ new Map),t,()=>new Bm)}updateTurnKind(e,t){let n=e===void 0?void 0:Km(e.location).turn,r=t===void 0?void 0:Km(t.location).turn;if(e!==void 0&&n!==void 0&&(n!==r||e.kind!==t?.kind)){let t=this.turnKind(n,e.kind);t.delete(e.key),this.dirtyTurnKinds.add(t)}if(t!==void 0&&r!==void 0){let e=this.turnKind(r,t.kind);e.set(t),this.dirtyTurnKinds.add(e)}}processSource(e){return Rm(this.processSources,e,()=>new zm(()=>this.process(e),`[ui-chat] node process source ${e}`))}process(e){return this.turnProcesses.get(this.get(e))}values(){return this.valuesDirty&&=(this.valuesCache=[...this.byKey.values()],!1),this.valuesCache}replace(e){let t=new Map(this.byKey);this.byKey.clear();for(let n of e)this.byKey.set(n.key,n),t.get(n.key)!==n&&(this.updateTurnKind(t.get(n.key),n),this.dirtyKeys.add(n.key),this.dirtyProcessKeys.add(n.key)),t.delete(n.key);for(let e of t.keys())this.updateTurnKind(t.get(e),void 0),this.dirtyKeys.add(e),this.dirtyProcessKeys.add(e);this.valuesCache=[...this.byKey.values()],this.valuesDirty=!1}upsert(e){let t=!1;for(let n of e)this.byKey.get(n.key)!==n&&(this.updateTurnKind(this.byKey.get(n.key),n),this.byKey.set(n.key,n),this.dirtyKeys.add(n.key),this.dirtyProcessKeys.add(n.key),t=!0);t&&(this.valuesDirty=!0)}touchProcesses(e,t){for(let n of e)for(let e of t.getTurn(n))this.dirtyProcessKeys.add(e)}replaceProcesses(e,t){this.touchProcesses(this.turnProcesses.replace(e,t,this),t)}updateProcesses(e,t){this.touchProcesses(this.turnProcesses.update(e,t,this),t)}publish(){let e=[...this.dirtyKeys],t=[...this.dirtyProcessKeys],n=[...this.dirtyTurnKinds];this.dirtyKeys.clear(),this.dirtyProcessKeys.clear(),this.dirtyTurnKinds.clear();for(let t of e)this.sources.get(t)?.publish();for(let e of t)this.processSources.get(e)?.publish();for(let e of n)e.publish()}},Hm=class{turns=/* @__PURE__ */ new Map;steps=/* @__PURE__ */ new Map;positions=/* @__PURE__ */ new Map;getTurn(e){return this.turns.get(e)??Nm}getStep(e,t){return this.steps.get(Gm(e,t))??Nm}getPosition(e){return this.positions.get(e)}rebuild(e,t){let n=/* @__PURE__ */ new Map,r=/* @__PURE__ */ new Map,i=/* @__PURE__ */ new Map,a=/* @__PURE__ */ new Set;for(let[o,s]of e.entries()){let c=t.get(s)?.location;if(c===void 0)continue;let l=Km(c),u=this.positions.get(s),d={turn:l.turn,previous:e[o-1],next:e[o+1]},f=u!==void 0&&u.turn===d.turn&&u.previous===d.previous&&u.next===d.next;if(i.set(s,f?u:d),f||(u?.turn!==void 0&&a.add(u.turn),d.turn!==void 0&&a.add(d.turn)),l.turn===void 0)continue;let p=n.get(l.turn)??[];if(p.push(s),n.set(l.turn,p),l.step===void 0)continue;let m=Gm(l.turn,l.step),h=r.get(m)??[];h.push(s),r.set(m,h)}for(let[e,t]of this.positions)!i.has(e)&&t.turn!==void 0&&a.add(t.turn);return this.positions=i,this.turns=Um(this.turns,n),this.steps=Um(this.steps,r),[...a]}touch(e){let t=/* @__PURE__ */ new Set,n=/* @__PURE__ */ new Set;for(let r of e){let e=Km(r.location);e.turn!==void 0&&this.turns.get(e.turn)?.includes(r.key)&&(t.add(e.turn),e.step!==void 0&&n.add(Gm(e.turn,e.step)))}for(let e of t){let t=this.turns.get(e);t!==void 0&&this.turns.set(e,[...t])}for(let e of n){let t=this.steps.get(e);t!==void 0&&this.steps.set(e,[...t])}}};function Um(e,t){let n=/* @__PURE__ */ new Map,r=/* @__PURE__ */ new Set([...e.keys(),...t.keys()]);for(let i of r){let r=e.get(i)??Nm,a=t.get(i)??Nm,o=Lm(r,a)?r:a;a.length>0&&n.set(i,o)}return n}var Wm=class{current=Fm;byTurn=/* @__PURE__ */ new Map;items(){return this.current}rebuild(e,t,n){let r=[],i=/* @__PURE__ */ new Map;for(let a of e.turnOrder){let e=Om(a,t,n);if(e===void 0)continue;let o=this.byTurn.get(a),s=o!==void 0&&Dm(o,e)?o:e;r.push(s),i.set(a,s)}this.byTurn=i,r.length===this.current.length&&r.every((e,t)=>e===this.current[t])||(this.current=r)}touch(e,t,n){if(e.size===0)return;let r=this.current.map(r=>{if(!e.has(r.turn))return r;let i=Om(r.turn,t,n);return i===void 0||Dm(r,i)?r:(this.byTurn.set(r.turn,i),i)});r.some((e,t)=>e!==this.current[t])&&(this.current=r)}};function Gm(e,t){return`${e}:${t}`}function Km(e){return e.kind===`step`?{turn:e.turn.turn,step:e.step.step}:e.kind===`turn`?{turn:e.turn.turn}:{}}function qm(e){return e.kind===`turn`||e.kind===`step`?e.turn.status:void 0}function Jm(e,t,n){return n||e===void 0||qm(e.location)!==qm(t.location)?!0:e.kind===`turn-process`&&t.kind===`turn-process`?e.data!==t.data:e.kind===`assistant-step`&&t.kind===`assistant-step`&&e.data.step!==t.data.step}function Ym(e){let t=/* @__PURE__ */ new Map;for(let n of e){let e=n;e.kind===`turn-process`&&t.set(e.data.turn,{...t.get(e.data.turn),control:e})}for(let n of e){let e=n,r=e.location;if(r.kind!==`turn`&&r.kind!==`step`)continue;let i=t.get(r.turn.turn)??{},a=i.control?.data.controlAnchorSeq;(e.kind===`user`||e.kind===`turn-trigger`||e.kind===`steering`)&&a!==void 0&&(a===r.turn.start?.seq||e.anchorSeq<a)?t.set(r.turn.turn,{...i,openingInputAnchor:Math.max(i.openingInputAnchor??e.anchorSeq,e.anchorSeq)}):dd.has(e.kind)||t.set(r.turn.turn,{...i,earliestProcessAnchor:Math.min(i.earliestProcessAnchor??e.anchorSeq,e.anchorSeq)})}return t}function Xm(e,t){let n=e,r=n.location;if(r.kind!==`turn`&&r.kind!==`step`)return{anchor:n.anchorSeq,rank:0,originalAnchor:n.anchorSeq};let i=t.get(r.turn.turn);if(i===void 0)return{anchor:n.anchorSeq,rank:0,originalAnchor:n.anchorSeq};let a=i.openingInputAnchor;return a!==void 0&&n.anchorSeq<a&&!dd.has(n.kind)?{anchor:a,rank:2,originalAnchor:n.anchorSeq}:i.control!==void 0&&n.key===i.control.key?a===void 0?{anchor:i.earliestProcessAnchor??n.anchorSeq,rank:-1,originalAnchor:n.anchorSeq}:{anchor:a,rank:1,originalAnchor:n.anchorSeq}:{anchor:n.anchorSeq,rank:0,originalAnchor:n.anchorSeq}}function Zm(e){let t=e.filter(e=>Cm(e)),n=Ym(t);return t.sort((e,t)=>{let r=Xm(e,n),i=Xm(t,n);return r.anchor-i.anchor||r.rank-i.rank||r.originalAnchor-i.originalAnchor||e.key.localeCompare(t.key)})}function Qm(e){let t=e;return t.kind===`user`||t.kind===`steering`?t.data.seq:void 0}function $m(e){let t=e;if(t.kind===`context`)return{messageSeq:t.data.seq-1,labels:$p(t.data.source)}}function eh(e,t){let n=e;if(n.kind!==`user`&&n.kind!==`steering`)return e;let r=n.data.referenceLabels??Nm,i=Object.hasOwn(n.data,`referenceLabels`);if(Lm(r,t)&&i===t.length>0)return e;let a={...n.data};return t.length===0?delete a.referenceLabels:a.referenceLabels=t,{...n,data:a}}var th=class{messagesBySeq=/* @__PURE__ */ new Map;labelsByMessageSeq=/* @__PURE__ */ new Map;replace(e){this.messagesBySeq.clear(),this.labelsByMessageSeq.clear();for(let t of e){let e=Qm(t);e!==void 0&&this.messagesBySeq.set(e,t.key);let n=$m(t);n!==void 0&&n.labels.length>0&&this.labelsByMessageSeq.set(n.messageSeq,n.labels)}return e.map(e=>{let t=Qm(e);return t===void 0?e:eh(e,this.labelsByMessageSeq.get(t)??Nm)})}apply(e,t){let n=new Map(e.map(e=>[e.key,e])),r=/* @__PURE__ */ new Set;for(let t of e){let e=Qm(t);e!==void 0&&(this.messagesBySeq.set(e,t.key),r.add(e));let n=$m(t);if(n===void 0)continue;let i=this.labelsByMessageSeq.get(n.messageSeq);n.labels.length===0?this.labelsByMessageSeq.delete(n.messageSeq):this.labelsByMessageSeq.set(n.messageSeq,i!==void 0&&Lm(i,n.labels)?i:n.labels),r.add(n.messageSeq)}for(let e of r){let r=this.messagesBySeq.get(e);if(r===void 0)continue;let i=n.get(r)??t.get(r);i!==void 0&&n.set(r,eh(i,this.labelsByMessageSeq.get(e)??Nm))}return[...n.values()]}};function nh(e,t){let n=e;if(n.kind!==`user`&&n.kind!==`steering`)return e;let r=n.data.skillNames??Nm,i=Object.hasOwn(n.data,`skillNames`);if(Lm(r,t)&&i===t.length>0)return e;let a={...n.data};return t.length===0?delete a.skillNames:a.skillNames=t,{...n,data:a}}function rh(e){let t=e;if(t.kind===`user`||t.kind===`steering`)return{key:e.key,seq:e.anchorSeq,kind:`message`,name:null};if(t.kind===`context`){let n=em(t.data.source);return n===null?null:{key:e.key,seq:e.anchorSeq,kind:`skill`,name:n}}return{key:e.key,seq:e.anchorSeq,kind:`boundary`,name:null}}function ih(e,t){return e.seq===t.seq&&e.kind===t.kind&&e.name===t.name}var ah=class{entries=/* @__PURE__ */ new Map;sorted=[];replace(e){this.entries.clear(),this.sorted=[];for(let t of e){let e=rh(t);e!==null&&(this.entries.set(e.key,e),this.sorted.push(e))}this.sorted.sort((e,t)=>e.seq-t.seq);let t=/* @__PURE__ */ new Map;for(let e=0;e<this.sorted.length;e++){if(this.sorted[e]?.kind===`boundary`)continue;let n=this.runEnd(e);this.assignRun(e,n,t),e=n}return e.map(e=>nh(e,t.get(e.key)??Nm))}apply(e,t){let n=[];for(let t of e){let e=rh(t),r=this.entries.get(t.key);if(r!==void 0){if(e!==null&&ih(r,e)){e.kind===`message`&&n.push(e.seq);continue}this.remove(r),n.push(r.seq)}e!==null&&(this.insert(e),n.push(e.seq))}if(n.length===0)return e;let r=/* @__PURE__ */ new Map;for(let e of n)this.collectAround(e,r);let i=new Map(e.map(e=>[e.key,e]));for(let[e,n]of r){let r=i.get(e)??t.get(e);if(r===void 0)continue;let a=nh(r,n);(a!==r||i.has(e))&&i.set(e,a)}return[...i.values()]}insert(e){this.sorted.splice(this.lowerBound(e.seq),0,e),this.entries.set(e.key,e)}remove(e){this.sorted.splice(this.sorted.indexOf(e),1),this.entries.delete(e.key)}lowerBound(e){let t=0,n=this.sorted.length;for(;t<n;){let r=t+n>>>1;(this.sorted[r]?.seq??1/0)<e?t=r+1:n=r}return t}runEnd(e){let t=e;for(;t+1<this.sorted.length&&this.sorted[t+1]?.kind!==`boundary`;)t++;return t}runStart(e){let t=e;for(;t-1>=0&&this.sorted[t-1]?.kind!==`boundary`;)t--;return t}assignRun(e,t,n){let r=[];for(let n=e;n<=t;n++){let e=this.sorted[n];e?.kind===`skill`&&e.name!==null&&!r.includes(e.name)&&r.push(e.name)}for(let i=e;i<=t;i++){let e=this.sorted[i];e?.kind===`message`&&n.set(e.key,r)}}collectAround(e,t){let n=this.lowerBound(e),r=this.sorted[n];if(r!==void 0&&r.seq===e&&r.kind!==`boundary`){this.assignRun(this.runStart(n),this.runEnd(n),t);return}n-1>=0&&this.sorted[n-1]?.kind!==`boundary`&&this.assignRun(this.runStart(n-1),n-1,t);let i=r!==void 0&&r.seq===e?n+1:n;i<this.sorted.length&&this.sorted[i]?.kind!==`boundary`&&this.assignRun(i,this.runEnd(i),t)}};let oh={anchorSeq:0,nodes:Im,partial:null,running:null};function sh(e){let t=e;if(e.visibility!==`visible`&&t.kind!==`assistant-step`)return oh;switch(t.kind){case`user`:case`steering`:case`context`:case`command`:case`compaction`:case`turn-error`:case`turn-max-tokens`:case`unknown`:return{anchorSeq:t.anchorSeq,nodes:[t.data],partial:null,running:null};case`assistant-step`:{let n=t.data;return n.status===`running`?e.visibility===`visible`?{anchorSeq:t.anchorSeq,nodes:Im,partial:{turn:n.turn,step:n.step,blocks:n.blocks},running:null}:oh:{anchorSeq:t.anchorSeq,nodes:n.finalNode===void 0?Im:[n.finalNode],partial:null,running:null}}case`tool-call`:{let e=t.data.root;return Sm(e)?{anchorSeq:t.anchorSeq,nodes:Im,partial:null,running:e}:{anchorSeq:t.anchorSeq,nodes:[e],partial:null,running:null}}case`manual-compaction`:{let e=t.data;return{anchorSeq:t.anchorSeq,nodes:e.compaction===null?[e.command]:[e.command,e.compaction],partial:null,running:null}}case`model-retry`:return{anchorSeq:t.anchorSeq,nodes:t.data.attempts,partial:null,running:null};case`turn-tail`:case`system-prompt`:return oh;default:return oh}}function ch(e,t){return e!==void 0&&e.anchorSeq===t.anchorSeq&&e.partial?.blocks===t.partial?.blocks&&e.partial?.turn===t.partial?.turn&&e.partial?.step===t.partial?.step&&e.running===t.running&&Lm(e.nodes,t.nodes)}var lh=class{contributions=/* @__PURE__ */ new Map;finalizedContributions=/* @__PURE__ */ new Map;runningContributions=/* @__PURE__ */ new Map;partialContributions=/* @__PURE__ */ new Map;finalized=Im;runningCalls=Im;partial=null;timeline;turnTimings=/* @__PURE__ */ new Map;turnEnds=/* @__PURE__ */ new Map;replace(e,t){this.contributions.clear(),this.finalizedContributions.clear(),this.runningContributions.clear(),this.partialContributions.clear();for(let t of e){let e=sh(t);this.contributions.set(t.key,e),this.indexContribution(t.key,e)}return this.rebuildFinalized(),this.rebuildRunning(),this.rebuildPartial(),this.updateTimeline(t),this.snapshot()}apply(e,t){let n=!1,r=!1,i=!1;for(let t of e){let e=sh(t),a=this.contributions.get(t.key);ch(a,e)||(n||=dh(a,e),r||=fh(a,e),i||=ph(a,e),this.contributions.set(t.key,e),this.indexContribution(t.key,e))}return n&&this.rebuildFinalized(),r&&this.rebuildRunning(),i&&this.rebuildPartial(),this.updateTimeline(t),this.snapshot()}indexContribution(e,t){uh(this.finalizedContributions,e,t,t.nodes.length>0),uh(this.runningContributions,e,t,t.running!==null),uh(this.partialContributions,e,t,t.partial!==null)}rebuildFinalized(){let e=[...this.finalizedContributions.values()].flatMap(e=>e.nodes).sort((e,t)=>e.seq-t.seq);Lm(this.finalized,e)||(this.finalized=e)}rebuildRunning(){let e=[...this.runningContributions.values()].sort((e,t)=>e.anchorSeq-t.anchorSeq).flatMap(e=>e.running===null?[]:[e.running]);Lm(this.runningCalls,e)||(this.runningCalls=e)}rebuildPartial(){let e=[...this.partialContributions.values()].sort((e,t)=>e.anchorSeq-t.anchorSeq).findLast(e=>e.partial!==null)?.partial??null;(this.partial?.blocks!==e?.blocks||this.partial?.turn!==e?.turn||this.partial?.step!==e?.step)&&(this.partial=e)}updateTimeline(e){if(this.timeline===e)return;this.timeline=e;let t=/* @__PURE__ */ new Map,n=/* @__PURE__ */ new Map;for(let r of e.turns.values())r.start!==void 0&&t.set(r.turn,{startTime:r.start.time,...r.end===void 0?{}:{endTime:r.end.time}}),r.end!==void 0&&n.set(r.turn,r.end.seq);this.turnTimings=t,this.turnEnds=n}snapshot(){return{nodes:this.finalized,turnTimings:this.turnTimings,turnEnds:this.turnEnds,partial:this.partial,runningCalls:this.runningCalls}}};function uh(e,t,n,r){r?e.set(t,n):e.delete(t)}function dh(e,t){let n=e?.nodes??Im;return!Lm(n,t.nodes)||(n.length>0||t.nodes.length>0)&&e?.anchorSeq!==t.anchorSeq}function fh(e,t){return e?.running!==t.running||(e.running!==null||t.running!==null)&&e.anchorSeq!==t.anchorSeq}function ph(e,t){return e?.partial?.blocks!==t.partial?.blocks||e?.partial?.turn!==t.partial?.turn||e?.partial?.step!==t.partial?.step||((e?.partial??null)!==null||t.partial!==null)&&e?.anchorSeq!==t.anchorSeq}var mh=class{store=new Vm;locations=new Hm;navigation=new Wm;legacy=new lh;referenceLabels=new th;skillNames=new ah;order=Nm;latestGroupInput;readGroupNode=e=>this.store.get(e);readGroupTurn=e=>this.locations.getTurn(e);readGroupPosition=e=>this.locations.getPosition(e);timeline=null;empty;constructor(){this.empty=this.snapshot({turnOrder:Pm,turns:/* @__PURE__ */ new Map}),this.latestGroupInput={kind:`replace`,order:this.order,readNode:this.readGroupNode,readTurn:this.readGroupTurn,readPosition:this.readGroupPosition,timeline:this.empty.timeline}}replace(e){let t=this.skillNames.replace(this.referenceLabels.replace(e.nodes));return this.store.replace(t),this.order=Zm(t).map(e=>e.key),this.locations.rebuild(this.order,this.store),this.store.replaceProcesses(this.order,this.locations),this.navigation.rebuild(e.timeline,this.locations,this.store),this.timeline=e.timeline,this.latestGroupInput={kind:`replace`,order:this.order,readNode:this.readGroupNode,readTurn:this.readGroupTurn,readPosition:this.readGroupPosition,timeline:e.timeline},this.snapshot(e.timeline,this.legacy.replace(t,e.timeline))}apply(e){let t=this.skillNames.apply(this.referenceLabels.apply(e.upserts,this.store),this.store),n=/* @__PURE__ */ new Set,r=!1,i=[],a=[];for(let e of t){let t=this.store.get(e.key);t!==e&&a.push({previous:t,current:e});let o=t===void 0||t.kind!==e.kind||t.anchorSeq!==e.anchorSeq||t.visibility!==e.visibility||gh(t.location)!==gh(e.location);if(r||=o,o||i.push(e),Jm(t,e,o)){let r=t===void 0?void 0:Km(t.location).turn,i=Km(e.location).turn;r!==void 0&&n.add(r),i!==void 0&&n.add(i)}}this.store.upsert(t);let o=Pm;if(r){let e=Zm(this.store.values()).map(e=>e.key);this.order=Lm(this.order,e)?this.order:e,o=this.locations.rebuild(this.order,this.store)}return this.locations.touch(i),this.store.updateProcesses(n,this.locations),r||e.timeline!==this.timeline?this.navigation.rebuild(e.timeline,this.locations,this.store):this.navigation.touch(hh(i),this.locations,this.store),this.timeline=e.timeline,this.latestGroupInput={kind:`apply`,changes:a,order:this.order,readNode:this.readGroupNode,readTurn:this.readGroupTurn,readPosition:this.readGroupPosition,timeline:e.timeline,changedTurns:e.changedTurns??Pm,changedTurnOrders:o},this.snapshot(e.timeline,this.legacy.apply(t,e.timeline))}groupInput(){return this.latestGroupInput}publish(){this.store.publish()}snapshot(e,t=this.legacy.replace(Im,e)){return{order:this.order,nodes:this.store,locations:this.locations,navigation:this.navigation,timeline:e,legacy:t}}};function hh(e){let t=/* @__PURE__ */ new Set;for(let n of e){let e=Km(n.location).turn;e!==void 0&&t.add(e)}return t}function gh(e){let t=Km(e);return`${e.kind}:${t.turn??``}:${t.step??``}`}let _h={target:`chat`,create:()=>new mh,isActive:e=>e.order.some(t=>e.nodes.get(t)?.kind!==`command`)};function vh(e){e.uiConversation.views.register(_h)}let yh=/* @__PURE__ */ new Set([`system/message`,`developer/message`,`user/message`,`assistant/message`,`tool/result`]);function bh(e){return yh.has(e.type)?e.surfaceOp!==void 0:!1}function xh(e){return bh(e)&&e.surfaceOp===`append`}function Sh(e){return bh(e)&&e.surfaceOp!==`append`}function Ch(e){if(e.event.type!==`command/run`)throw Error(`command start requires command/run`);let t=e.event.data;return{kind:`command`,seq:e.event.seq,time:e.event.time,commandId:t.commandId,name:t.name,args:t.args??null,outcome:null}}function wh(e,t){if(e.event.type!==`command/done`)throw Error(`command update requires command/done`);let n=e.event.data,r=n.kind===`success`&&n.sourceEventSeq!==void 0&&Number.isSafeInteger(n.sourceEventSeq)&&n.sourceEventSeq>=0?n.sourceEventSeq:void 0;return{kind:`command`,seq:t?.seq??e.event.seq,time:t?.time??e.event.time,commandId:n.commandId,name:t?.name??null,args:t?.args??null,outcome:{kind:n.kind,...n.text===void 0?{}:{text:n.text},...r===void 0?{}:{sourceEventSeq:r}}}}function Th(e){if(e.type!==`user/message`||!Sh(e))return;let t=e.data.source;if(t.kind===`compact-checkpoint`&&typeof t.compactionId==`string`)return{compactionId:t.compactionId,...t.sourceCommandId===void 0?{}:{sourceCommandId:t.sourceCommandId}}}function Eh(e,t){let n=null,r=null,i=null;if(e?.event.type===`compaction/summary`){let t=e.event.data;if(Array.isArray(t.summary)){let e=t.summary.map(e=>e.type===`text`?e.text:``).join(``);n=e.trim()===``?null:e}r=Array.isArray(t.shadowedSeqs)&&t.shadowedSeqs.every(e=>Number.isSafeInteger(e)&&e>=0)?t.shadowedSeqs.length:null,i=Number.isSafeInteger(t.shadowedTokenCount)&&t.shadowedTokenCount>=0?t.shadowedTokenCount:null}return{kind:`compaction`,seq:t.event.seq,time:t.event.time,summary:n,summaryEventSeq:e?.event.seq??null,shadowedItemCount:r,shadowedTokenCount:i}}function Dh(e){let t=e.matches.find(e=>e.event.type===`command/done`),n=e.matches.find(e=>Th(e.event)!==void 0),r=e.matches.find(e=>e.event.type===`compaction/summary`);if(n===void 0)return t===void 0?void 0:{command:wh(t)};let i=Th(n.event);return i?.sourceCommandId===void 0?t===void 0?void 0:{command:wh(t)}:{command:t===void 0?{kind:`command`,seq:n.event.seq,time:n.event.time,commandId:i.sourceCommandId,name:`compact`,args:null,outcome:null}:{...wh(t),name:`compact`},checkpoint:n,...r===void 0?{}:{summary:r}}}function Oh(e,t){return t.event.type===`compaction/summary`?{...e,summary:t}:Th(t.event)===void 0?e:{...e,checkpoint:t}}let kh={kind:`command`,target:`chat`,match:e=>{if(e.type===`command/run`)return{id:String(e.data.commandId),role:`start`};if(e.type===`command/done`)return{id:String(e.data.commandId),role:`update`};let t=Th(e);return t?.sourceCommandId===void 0?(e.type===`compaction/start`||e.type===`compaction/summary`||e.type===`compaction/end`)&&e.data.sourceCommandId!==void 0?{id:String(e.data.sourceCommandId),role:`update`}:null:{id:String(t.sourceCommandId),role:`update`}},start:(e,t)=>({command:Ch(t)}),update:(e,t)=>t.event.type===`command/done`?{...e.state,command:wh(t,e.state.command)}:Oh(e.state,t),buildViewNode:e=>{let t=e.state??Dh(e);if(t===void 0)return null;if(t.command.name!==`compact`)return Gp(e,`command`,t.command.seq,t.command);let n=t.checkpoint===void 0?null:Eh(t.summary,t.checkpoint),r={command:t.command,compaction:n};return Gp(e,`manual-compaction`,n?.seq??t.command.seq,r)}};function Ah(e){e.uiConversation.events.register(kh)}function jh(e){let t=e.matches.find(e=>e.event.type===`compaction/summary`),n=e.matches.find(e=>Th(e.event)!==void 0);return{...t===void 0?{}:{summary:t},...n===void 0?{}:{checkpoint:n}}}let Mh={kind:`compaction`,target:`chat`,match:e=>{let t=Th(e);if(t!==void 0&&t.sourceCommandId===void 0)return{id:t.compactionId,role:`update`};if(e.type===`compaction/start`||e.type===`compaction/summary`||e.type===`compaction/end`){if(e.data.sourceCommandId!==void 0)return null;let t=e.data.compactionId;return typeof t!=`string`||t===``?null:{id:t,role:e.type===`compaction/start`?`start`:`update`}}return null},start:()=>({}),update:(e,t)=>Oh(e.state,t),buildViewNode:e=>{let t=e.state??jh(e);if(t.checkpoint===void 0)return null;let n=Eh(t.summary,t.checkpoint);return Gp(e,`compaction`,n.seq,n)}};function Nh(e){e.uiConversation.events.register(Mh)}let Ph={kind:`unknown-surface`,target:`chat`,match:e=>e.type!==`assistant/live-chunk`&&xh(e)?{id:String(e.seq),role:`start`}:null,start:(e,t)=>({kind:`unknown`,seq:t.event.seq,time:t.event.time,type:t.event.type,data:t.event.data}),update:e=>e.state,buildViewNode:e=>e.state===void 0?null:Gp(e,`unknown`,e.state.seq,e.state)};function Fh(e){e.uiConversation.events.registerFallback(Ph)}let Ih={kind:`snapshot`,ids:[]},Lh=/* @__PURE__ */ new Set;function Rh(e){let t=[],n=e;for(;n.kind===`splice`;)t.push(n),n=n.previous;let r=[...n.ids];for(let e of t.reverse())r.splice(e.start,e.removedCount,...e.inserted);return r}function zh(e,t){let n;for(let{id:r}of t)e.has(r)&&(n??=new Set(e),n.delete(r));return n??e}function Bh(e,t,n){let r=e?.state.pending??Ih,i=t.inserted,a=t.removedCount??0;if(a>0&&t.outcome!==`canceled`){let e=Rh(r),o=e.splice(t.start,a,...i);return{pending:{kind:`snapshot`,ids:e},currentClaimed:new Set(o.map(e=>e.id)),claimSeq:n,claimedHuman:o.some(e=>e.source.kind===`user`)}}let o=zh(e?.state.currentClaimed??Lh,i);return{pending:{kind:`splice`,previous:r,start:t.start,removedCount:a,inserted:i},currentClaimed:o,claimSeq:e?.state.claimSeq??-1,claimedHuman:e?.state.claimedHuman??!1}}function Vh(e){let t=`inbox-${e}`;return{kind:t,match:t=>t.type===`agent/inbox/spliced`&&t.data.target===e?{id:String(t.seq),role:`start`}:null,start:(e,n,r)=>{if(n.event.type!==`agent/inbox/spliced`)throw Error(`inbox start requires agent/inbox/spliced`);return Bh(r.previous(t),n.event.data,n.event.seq)},update:e=>e.state,publication:()=>`none`}}let Hh=Vh(`next-step`),Uh=Vh(`next-turn`);function Wh(e){e.uiConversation.events.register(Hh),e.uiConversation.events.register(Uh)}function Gh(e){return e.type!==`user/message`||!Sh(e)?!1:e.data.source.kind===`compact-checkpoint`}function Kh(e,t){return{kind:`context`,seq:e.seq,time:e.time,content:t.content,source:t.source,producer:Qp(t.source),form:Zp(t.source)}}let qh={kind:`input-message`,target:`chat`,match:e=>e.type===`user/message`&&xh(e)&&!Gh(e)?{id:String(e.data.id),role:`start`}:null,start:(e,t,n)=>{let r=t.event;if(r.type!==`user/message`)throw Error(`input-message start requires user/message`);if(r.data.source.kind!==`user`){let e=n.previous(`inbox-next-turn`)?.state,i=n.previous(`inbox-next-step`)?.state,a=t.location,o=a.kind===`step`?a.turn.start?.seq:void 0,s=a.kind===`step`&&a.step.step===1&&o!==void 0&&(i?.claimSeq??-1)>o&&(e?.claimSeq??-1)<o&&i?.claimedHuman===!1&&i.currentClaimed.has(String(r.data.id));return{...Kh(r,r.data),waking:e?.currentClaimed.has(String(r.data.id))===!0||s}}return n.previous(`inbox-next-step`)?.state.currentClaimed.has(String(r.data.id))===!0?{kind:`steering`,messageId:r.data.id,seq:r.seq,time:r.time,content:r.data.content,source:r.data.source}:{kind:`user`,seq:r.seq,time:r.time,content:r.data.content,source:r.data.source}},update:e=>e.state,buildViewNode:e=>e.state===void 0?null:Gp(e,e.state.kind===`context`&&e.start?.event.type===`user/message`&&e.state.waking===!0?`turn-trigger`:e.state.kind,e.state.seq,e.state)},Jh={...qh,kind:`developer-message`,match:e=>e.type===`developer/message`?{id:String(e.data.message.id),role:`start`}:null,start:(e,t)=>{let n=t.event;if(n.type!==`developer/message`)throw Error(`developer-message start requires developer/message`);return Kh(n,n.data.message)}};function Yh(e){e.uiConversation.events.register(qh),e.uiConversation.events.register(Jh)}function Xh(e,t,n){return e.location.kind!==`step`||t===void 0&&!n||t?.turn===e.location.turn.turn&&t.step===e.location.step.step?e.event.seq:e.location.step.step===1?e.location.turn.start?.seq??e.location.step.start?.seq??e.event.seq:e.location.step.start?.seq??e.event.seq}function Zh(e,t,n,r){let i=e.current.get(`chat`);return i?.kind===`system-prompt`?i.anchorSeq:Xh(t,n,r)}function Qh(e){return{kind:`system-message`,target:`chat`,match:e=>e.type===`system/message`||`surfaceOp`in e&&e.surfaceOp!==`append`?{id:String(e.seq),role:`start`}:null,start:(t,n,r)=>{if(n.event.type===`assistant/live-chunk`)throw Error(`system-message requires a durable event`);return e(r.previous(`system-message`)?.state,n.event)},update:e=>e.state,buildViewNode:e=>{let t=e.state?.introduced;return t===void 0||t.text===``||e.start?.event.type!==`system/message`||e.start.event.surfaceOp!==`append`?null:Gp(e,`system-prompt`,t.update?t.seq:Xh(e.start,void 0,!0),{text:t.text,...t.update?{update:!0}:{}})}}}function $h(e){return{kind:`request-prompt`,target:`chat`,match:e=>e.type===`request/header`?{id:String(e.seq),role:`start`}:null,start:(t,n,r)=>{if(n.event.type!==`request/header`)throw Error(`request-prompt start requires request/header`);let i=r.previous(`request-prompt`)?.state,a=r.previous(`system-message`),o=a?.state.effective,s=n.location.kind===`step`?{turn:n.location.turn.turn,step:n.location.step.step}:{},c=e(i?.prompt,n.event,o),l=c.change?.kind,u=a?.matches[0]?.event,d=o!==void 0&&u?.type===`system/message`&&u.surfaceOp===`append`&&(o.update||i===void 0)&&o.turn===s.turn&&o.step===s.step;return{anchorSeq:Zh(t,n,i,n.event.data.reason===`initial`),showsPrompt:!d&&(i===void 0||n.event.data.reason!==`change`||n.event.data.startsSeries===!0||l===`system`||l===`system-and-tools`),...s,...c}},update:e=>e.state,buildViewNode:e=>{let t=e.state;if(t===void 0)return null;let n=e.current.get(`chat`),r=t.showsPrompt&&t.prompt.system!==``;return!r&&n?.kind!==`system-prompt`?null:Gp(e,`system-prompt`,t.anchorSeq,{text:t.prompt.system},{visibility:r?`visible`:`hidden`})}}}function eg(e){e.uiConversation.events.register(Qh((t,n)=>e.uiConversation.inspectSystemPrompt(t,n))),e.uiConversation.events.register($h((t,n,r)=>e.uiConversation.inspectRequestPrompt(t,n,r)))}function tg(e){if(e.event.type===`llm/retry`)return{kind:`model-retry`,seq:e.event.seq,time:e.event.time,retryState:`scheduled`,...e.event.data}}function ng(e){return e.kind===`step`&&e.step.status===`closed`||(e.kind===`step`||e.kind===`turn`)&&e.turn.status===`closed`}let rg={kind:`model-retry`,target:`chat`,match:e=>{if(e.type===`llm/retry`){let t=e.data.retryId;return typeof t!=`string`||t===``?null:{id:t,role:e.data.retry===1?`start`:`update`}}if(e.type===`llm/retry-started`){let t=e.data.retryId;return typeof t==`string`&&t!==``?{id:t,role:`update`}:null}return null},start:(e,t)=>{let n=tg(t);if(n===void 0)throw Error(`model-retry start requires a valid llm/retry event`);return{turn:n.turn,step:n.step,attempts:[n]}},update:(e,t)=>{if(t.event.type===`llm/retry`){let n=tg(t);return n===void 0?e.state:{...e.state,attempts:[...e.state.attempts,n]}}if(t.event.type!==`llm/retry-started`)return e.state;let n=t.event.data.retry;return{...e.state,attempts:e.state.attempts.map(e=>e.retry===n?{...e,retryState:`started`}:e)}},buildViewNode:e=>{if(e.state===void 0||e.state.attempts.length===0)return null;let t=e.start?.location??e.matches[0]?.location??{kind:`unresolved`},n=e.state.attempts,r=n.map((e,r)=>r===n.length-1&&e.retryState===`scheduled`&&ng(t)?{...e,retryState:`cancelled`}:e),i=r.at(-1);if(i===void 0)return null;let a={attempts:r,current:i};return Gp(e,`model-retry`,r[0]?.seq??i.seq,a)}};function ig(e){e.uiConversation.events.register(rg)}let ag=/* @__PURE__ */ new WeakMap;function og(e){return JSON.stringify(e)}function sg(e,t){if(e.event.type!==`tool/call`)throw Error(`tool-call start requires tool/call`);return{phase:`start`,callId:String(e.event.data.callId),name:e.event.data.name,argsRaw:e.event.data.arguments,args:t===void 0?Od.fromText(e.event.data.arguments):t.args.settle(e.event.data.arguments),turn:e.event.data.turn,step:e.event.data.step,time:e.event.time,subCalls:[]}}function cg(e,t){let n=t.event;if(n.type!==`assistant/live-chunk`)return e;let r=n.data.chunk,i=e.root;if(r.type===`block-end`&&r.block.type===`tool-call`)return i===void 0||`kind`in i||i.phase!==`preparing`?e:{...e,root:{...i,name:r.block.name,args:i.args.settle(r.block.arguments)}};if(r.type!==`tool-call-delta`)return e;if(i===void 0){if(!r.name)return e;let t=new Od;return t.append(r.argumentsDelta),{...e,root:{phase:`preparing`,callId:String(r.id),name:r.name,turn:n.data.turn,step:n.data.step,time:n.time,subCalls:[],args:t}}}return`kind`in i||i.phase!==`preparing`||i.args.isSealed||i.args.append(r.argumentsDelta),e}function lg(e,t){let n=e.args.refresh();return!n&&t!==void 0&&!(`kind`in t)&&t.phase===`preparing`&&t.name===e.name&&t.args===e.args?t:n?{...e}:e}function ug(e,t){if(e.event.type!==`tool/result`)return;let n=e.event.data.message;return{kind:`tool-result`,seq:e.event.seq,time:e.event.time,callId:String(n.source.callId),name:t?.name??``,args:t?.args??Od.EMPTY,call:t===void 0?null:{name:t.name,argsRaw:t.argsRaw},callTime:t?.time??null,content:n.content,isError:n.isError===!0,...e.event.data.error===void 0?{}:{error:e.event.data.error},meta:e.event.data.meta,subCalls:[]}}function dg(e,t){return{phase:`start`,callId:t.subCallId,parentCallId:t.parentCallId,name:t.name,argsRaw:og(t.arguments),args:Od.fromObject(t.arguments),turn:pg(e),step:mg(e),time:e.event.time,subCalls:[]}}function fg(e,t,n){return{kind:`tool-result`,seq:e.event.seq,time:e.event.time,callId:t.subCallId,parentCallId:t.parentCallId,name:t.name,args:n!==void 0&&!(`kind`in n)?n.args:Od.fromObject(t.arguments),call:{name:t.name,argsRaw:og(t.arguments)},callTime:n?.time??null,content:t.content??[],isError:t.isError===!0,...t.error===void 0?{}:{error:t.error},subCalls:[]}}function pg(e){return e.location.kind===`step`||e.location.kind===`turn`?e.location.turn.turn:0}function mg(e){return e.location.kind===`step`?e.location.step.step:0}function hg(e,t,n){if(t===n||e.parents.has(n))return!1;let r=t,i=0,a=/* @__PURE__ */ new Set;for(;r!==void 0;){if(r===n||a.has(r))return!1;a.add(r),i++,r=e.parents.get(r)}let o=[{callId:n,depth:1}],s=/* @__PURE__ */ new Set,c=0;for(let t of o){if(s.has(t.callId))return!1;s.add(t.callId),c=Math.max(c,t.depth);for(let n of e.children.get(t.callId)??[])o.push({callId:n.callId,depth:t.depth+1})}return i+c<=256}function gg(e,t){let n=t.event;if(n.type!==`tool/ptc-dispatch-start`&&n.type!==`tool/ptc-dispatch`)return e;let r=n.data,i=String(r.parentCallId),a=String(r.subCallId),o=e.children.get(i)??[],s=o.findIndex(e=>e.callId===a);if(n.type===`tool/ptc-dispatch-start`){if(s>=0||!hg(e,i,a))return e;let n=new Map(e.children);n.set(i,[...o,dg(t,r)]);let c=new Map(e.parents);return c.set(a,i),{...e,children:n,parents:c}}if(s<0&&!hg(e,i,a))return e;let c=fg(t,r,s<0?void 0:o[s]),l=new Map(e.children);l.set(i,s<0?[...o,c]:o.map((e,t)=>t===s?c:e));let u=new Map(e.parents);return s<0&&u.set(a,i),{...e,children:l,parents:u}}function _g(e,t,n,r=/* @__PURE__ */ new Set,i=1){if(!(`kind`in e)&&e.phase===`preparing`)return e;if(r.has(e.callId)||i>256)return{...e,subCalls:[]};let a=new Set(r);a.add(e.callId);let o=(t.children.get(e.callId)??e.subCalls).map(e=>_g(e,t,n,a,i+1)),s=`kind`in e?void 0:n?.seq,c=`kind`in e?void 0:n?.time,l=ag.get(e);if(l!==void 0&&l.interruptionSeq===s&&l.interruptionTime===c&&vg(l.children,o))return l.value;let u=`kind`in e||n===void 0?vg(e.subCalls,o)?e:{...e,subCalls:o}:{kind:`tool-result`,seq:n.seq+Up.interruptedFollowup,time:n.time,callId:e.callId,...e.parentCallId===void 0?{}:{parentCallId:e.parentCallId},name:e.name,args:e.args,call:{name:e.name,argsRaw:e.argsRaw},callTime:e.time,content:[],isError:!0,error:{name:`Interrupted`,code:`interrupted`},subCalls:o};return ag.set(e,{children:o,interruptionSeq:s,interruptionTime:c,value:u}),u}function vg(e,t){return e.length===t.length&&e.every((e,n)=>e===t[n])}function yg(e){let t=e.start?.location;if(t?.kind===`step`&&t.step.status===`closed`)return t.step.end;if((t?.kind===`step`||t?.kind===`turn`)&&t.turn.status===`closed`)return t.turn.end}function bg(e){let t=e.matches.find(e=>e.event.type===`tool/result`),n=t===void 0?void 0:ug(t);if(n===void 0)return;let r={root:n,children:/* @__PURE__ */ new Map,parents:/* @__PURE__ */ new Map};for(let t of e.matches)r=gg(r,t);return r}let xg={kind:`tool-call`,target:`chat`,match:e=>{if(e.type===`assistant/live-chunk`){let t=e.data.chunk;return t.type===`block-end`&&t.block.type===`tool-call`?{id:String(t.block.id),role:`start`}:t.type===`tool-call-delta`?{id:String(t.id),role:`start`}:null}if(e.type===`tool/call`)return{id:String(e.data.callId),role:`start`};if(e.type===`tool/result`&&xh(e))return{id:String(e.data.message.source.callId),role:`update`};if(e.type===`tool/ptc-dispatch-start`||e.type===`tool/ptc-dispatch`){let t=e.data.rootCallId;return typeof t==`string`&&t!==``?{id:t,role:`update`}:null}return null},start:(e,t)=>{let n={root:void 0,children:/* @__PURE__ */ new Map,parents:/* @__PURE__ */ new Map};return t.event.type===`tool/call`?{...n,root:sg(t)}:cg(n,t)},update:(e,t)=>{if(t.event.type===`assistant/live-chunk`)return cg(e.state,t);if(t.event.type===`tool/call`)return{...e.state,root:sg(t,e.state.root)};if(t.event.type===`tool/result`){let n=e.state.root,r=ug(t,n!==void 0&&!(`kind`in n)&&n.phase===`start`?n:void 0);return r===void 0?e.state:{...e.state,root:r}}return gg(e.state,t)},publication:e=>e.event.type===`assistant/live-chunk`?`animation-frame`:`immediate`,buildViewNode:e=>{let t=e.current.get(`chat`),n=e.state??bg(e);if(n?.root===void 0)return t==null?null:t.visibility===`hidden`?t:{...t,visibility:`hidden`};let r=yg(e),i=_g(!(`kind`in n.root)&&n.root.phase===`preparing`?lg(n.root,t?.data.root):n.root,n,r),a=e.start?.event.seq??(`kind`in n.root?n.root.seq:e.matches[0]?.event.seq??0),o=!(`kind`in i)&&i.phase===`preparing`&&r!==void 0?`hidden`:`visible`,s=Wp(e),c=md(i.name)&&s.kind===`step`?{kind:`turn`,turn:s.turn}:s,l=t?.data.root===i?t.data:{root:i};return t?.data===l&&t.anchorSeq===a&&t.visibility===o&&t.location===c?t:Gp(e,`tool-call`,a,l,{visibility:o,location:c})}};function Sg(e){let t=xg.match.bind(xg);e.uiConversation.events.register({...xg,match:{"assistant/live-chunk":t,"tool/call":t,"tool/result":t,"tool/ptc-dispatch-start":t,"tool/ptc-dispatch":t}})}function Cg(e){let t=e.start?.location??e.matches[0]?.location;return t?.kind!==`turn`&&t?.kind!==`step`?0:t.turn.steps.at(-1)?.step??0}function wg(e){if(e.event.type!==`turn/end`)return;let t=e.event.data.reason,n=t.kind===`error`?t.error:t.kind===`aborted`&&t.reason.kind===`hook`&&t.reason.reason===`deepseek-account/signed-out`?{message:`Stopped because you signed out of DeepSeek.`,code:`ACCOUNT_SIGNED_OUT`}:void 0;if(n===void 0)return;let r=im(n);return{seq:e.event.seq,time:e.event.time,message:r.message,...r.code===void 0?{}:{code:r.code}}}function Tg(e){let t=e.matches.find(e=>wg(e)!==void 0);if(t?.event.type!==`turn/end`)return;let n=wg(t);if(n!==void 0)return{turn:t.event.data.turn,failure:n}}let Eg={kind:`turn-error`,target:`chat`,match:e=>e.type===`turn/start`?{id:String(e.data.turn),role:`start`}:e.type===`turn/end`&&(e.data.reason.kind===`error`||e.data.reason.kind===`aborted`&&e.data.reason.reason.kind===`hook`&&e.data.reason.reason.reason===`deepseek-account/signed-out`)?{id:String(e.data.turn),role:`update`}:null,start:(e,t)=>{if(t.event.type!==`turn/start`)throw Error(`turn-error start requires turn/start`);return{turn:t.event.data.turn}},update:(e,t)=>{let n=wg(t);return n===void 0?e.state:{...e.state,failure:n}},buildViewNode:e=>{let t=e.state??Tg(e);if(t?.failure===void 0)return null;let n=t.failure,r={kind:`turn-error`,seq:n.seq,time:n.time,turn:t.turn,step:Cg(e),message:n.message,...n.code===void 0?{}:{code:n.code}};return Gp(e,`turn-error`,r.seq,r)}};function Dg(e){e.uiConversation.events.register(Eg)}function Og(e){let t=e.start?.location??e.matches[0]?.location;return t?.kind!==`turn`&&t?.kind!==`step`?0:t.turn.steps.at(-1)?.step??0}function kg(e,t){let n=e.start?.location??e.matches[0]?.location;if(n?.kind!==`turn`&&n?.kind!==`step`)return t;let r=n.turn.data.get(`turn-tail`)?.closing;return r==null?t:r.finalNode.seq+Up.maxTokensNotice}function Ag(e){if(e.event.type===`turn/end`&&e.event.data.reason.kind===`max-tokens`)return{turn:e.event.data.turn,seq:e.event.seq,time:e.event.time}}let jg={kind:`turn-max-tokens`,target:`chat`,match:e=>e.type===`turn/end`&&e.data.reason.kind===`max-tokens`?{id:String(e.data.turn),role:`start`}:null,start:(e,t)=>{let n=Ag(t);if(n===void 0)throw Error(`turn-max-tokens start requires a max-tokens turn/end`);return n},update:e=>e.state,buildViewNode:e=>{let t=e.state;if(t===void 0)return null;let n={kind:`turn-max-tokens`,seq:t.seq,time:t.time,turn:t.turn,step:Og(e)};return Gp(e,`turn-max-tokens`,kg(e,t.seq),n)}};function Mg(e){e.uiConversation.events.register(jg)}function Ng(e){let t=e.data;return typeof t.turn==`number`?t.turn:void 0}function Pg(e){if(e.type===`text-delta`||e.type===`reasoning-delta`)return e.text.trim()!==``;if(e.type===`block-start`)return e.blockType!==`text`&&e.blockType!==`reasoning`&&e.blockType!==`tool-call`;if(e.type!==`block-end`)return!1;let t=e.block;return t.type===`tool-call`?!1:t.type===`text`||t.type===`reasoning`?t.text.trim()!==``:!0}function Fg(e){return e.type===`assistant/live-chunk`?Pg(e.data.chunk):e.type!==`assistant/attempt`&&e.type===`assistant/message`&&e.surfaceOp===`append`&&tm(e.data.message.content).some(e=>e.kind===`tool-call`?!1:e.kind===`text`||e.kind===`reasoning`?e.text.trim()!==``:!0)}function Ig(e,t){return e.type===`tool/call`?md(e.data.name):e.type===`tool/result`&&t.has(String(e.data.message.source.callId))}function Lg(e,t){if(Fg(e))return e.type!==`assistant/live-chunk`&&e.type!==`assistant/message`&&e.type!==`assistant/attempt`?void 0:{kind:`assistant`,seq:e.seq,step:e.data.step};if(!Ig(e,t)&&(e.type===`tool/call`||e.type===`tool/result`&&e.surfaceOp===`append`||e.type===`llm/retry`))return{kind:`other`,seq:e.seq}}function Rg(e){let t=e.start?.location??e.matches.at(-1)?.location;return t?.kind===`turn`||t?.kind===`step`?t.turn:void 0}function zg(e){let t=e.matches.map(e=>Ng(e.event)).find(e=>e!==void 0);if(t===void 0)return;let n={turn:t,assistantStartByStep:/* @__PURE__ */ new Map,messageCountByStep:/* @__PURE__ */ new Map,messageCount:0,toolCallCount:0,subagentCount:0,contextCompactionCalls:/* @__PURE__ */ new Set};for(let t of e.matches)n=Ug(n,t.event);return n}function Bg(e){return e?.finalNode!==void 0}function Vg(e){let t=e.end?.data.finalAssistantStep;if(t===null)return null;let n=(t===void 0?e.steps.at(-1):e.steps.find(e=>e.step===t))?.data.get(`assistant-step`);return!Bg(n)||n.finalNode.interrupted===!0||!Ap(n.blocks)||t===void 0&&n.blocks.some(e=>e.kind===`tool-call`)?null:n}function Hg(e,t){let n=e.controlAnchorSeq??t.start?.seq;if(n===void 0)return null;let r=Vg(t),i={messageCount:r===null?e.messageCount:[...e.messageCountByStep].filter(([e])=>e!==r.step).reduce((e,[,t])=>e+t,0),toolCallCount:e.toolCallCount,subagentCount:e.subagentCount};if(r===null)return{turn:t.turn,controlAnchorSeq:n,processStartSeq:n,answerAnchorSeq:null,answerStep:null,inlineReasoning:!1,...i};let a=r.blocks.some(e=>e.kind===`reasoning`&&e.text.trim()!==``),o=Math.min(...[...e.assistantStartByStep].filter(([e])=>e<r.step).map(([,e])=>e)),s=Math.min(e.otherStartSeq??1/0,o);return{turn:t.turn,controlAnchorSeq:n,processStartSeq:t.start?.seq??(Number.isFinite(s)?s:r.finalNode.seq),answerAnchorSeq:r.finalNode.seq,answerStep:r.step,inlineReasoning:a,...i}}function Ug(e,t){let n=e;if(t.type===`assistant/message`&&t.surfaceOp===`append`&&Ap(tm(t.data.message.content))){let e=new Map(n.messageCountByStep);e.set(t.data.step,(e.get(t.data.step)??0)+1),n={...n,messageCountByStep:e,messageCount:n.messageCount+1}}if(t.type===`tool/call`){if(md(t.data.name)){let e=new Set(n.contextCompactionCalls);e.add(String(t.data.callId)),n={...n,contextCompactionCalls:e}}else{let e=pd(t.data.name);n={...n,toolCallCount:n.toolCallCount+ +!e,subagentCount:n.subagentCount+ +!!e}}}let r=Lg(t,n.contextCompactionCalls);if(r===void 0)return n;if(r.kind===`other`)return n.otherStartSeq===void 0?{...n,otherStartSeq:r.seq,controlAnchorSeq:Math.min(n.controlAnchorSeq??1/0,r.seq)}:n;if(n.assistantStartByStep.has(r.step))return n;let i=new Map(n.assistantStartByStep);return i.set(r.step,r.seq),{...n,assistantStartByStep:i,controlAnchorSeq:Math.min(n.controlAnchorSeq??1/0,r.seq)}}let Wg={kind:`turn-process`,target:`chat`,match:e=>{if(e.type===`turn/start`)return{id:String(e.data.turn),role:`start`};let t=Ng(e);return t===void 0?null:e.type===`assistant/live-chunk`||e.type===`assistant/message`||e.type===`tool/call`||e.type===`tool/result`||e.type===`llm/retry`||e.type===`step/start`||e.type===`step/end`||e.type===`turn/end`?{id:String(t),role:`update`}:null},start:(e,t)=>{if(t.event.type!==`turn/start`)throw Error(`turn-process start requires turn/start`);return{turn:t.event.data.turn,assistantStartByStep:/* @__PURE__ */ new Map,messageCountByStep:/* @__PURE__ */ new Map,messageCount:0,toolCallCount:0,subagentCount:0,contextCompactionCalls:/* @__PURE__ */ new Set}},update:(e,t)=>Ug(e.state,t.event),publication:e=>{if(e.event.type===`assistant/live-chunk`){let t=e.event.data.chunk.type;return t===`usage`||t===`finish`?`none`:`animation-frame`}return`immediate`},buildLocationData:(e,t,n)=>{if(t!==`turn`)return null;let r=e.state??zg(e);if(r===void 0)return null;let i=Rg(e);if(i===void 0)return null;let a=e.current.get(`chat`),o=i.steps.at(-1);if(n?.kind===`turn`&&n.key===`turn-process`&&a?.kind===`turn-process`&&a.data.answerAnchorSeq===null&&a.data.controlAnchorSeq===r.controlAnchorSeq&&a.data.messageCount===r.messageCount&&a.data.toolCallCount===r.toolCallCount&&a.data.subagentCount===r.subagentCount&&i.status!==`closed`&&o?.status!==`closed`)return n;let s=Hg(r,i);return s===null?null:n?.kind===`turn`&&n.turn===s.turn&&n.key===`turn-process`&&fd(n.value,s)?n:{kind:`turn`,turn:i.turn,key:`turn-process`,value:s}},buildViewNode:e=>{let t=Rg(e),n=t?.data.get(`turn-process`);if(t===void 0||n===void 0)return null;let r=e.current.get(`chat`),i=e.state;return r?.kind===`turn-process`&&i!==void 0&&r.data.answerAnchorSeq===null&&r.data.controlAnchorSeq===i.controlAnchorSeq&&r.data.messageCount===i.messageCount&&r.data.toolCallCount===i.toolCallCount&&r.data.subagentCount===i.subagentCount&&t.status!==`closed`&&t.steps.at(-1)?.status!==`closed`&&r.location===(e.start?.location??e.matches[0]?.location)?r:Gp(e,`turn-process`,n.controlAnchorSeq+Up.processControl,n)}};function Gg(e){let t=Wg.match.bind(Wg);e.uiConversation.events.register({...Wg,match:{"turn/start":t,"assistant/live-chunk":t,"assistant/message":t,"tool/call":t,"tool/result":t,"llm/retry":t,"step/start":t,"step/end":t,"turn/end":t}})}function Kg(e,t){for(let n=e.length-1;n>=0;--n){let r=e[n];if(r.type===`chunk`&&r.chunk.type===t)return r.chunk}}function qg(e){return typeof e==`number`&&Number.isSafeInteger(e)&&e>=0}function Jg(e){let t=0;for(let n of e)if(t+=n,!Number.isSafeInteger(t))return;return t}function Yg(e){let{provider:t,model:n}=e.source;return t.length>0&&n.length>0?{provider:t,model:n}:void 0}function Xg(e){return Kg(e,`usage`)?.usage}function Zg(e,t){let{inputTokens:n,outputTokens:r,cacheReadTokens:i,cacheWriteTokens:a,reasoningTokens:o,totalTokens:s}=e;if(!qg(n)||!qg(r)||i!==void 0&&!qg(i)||a!==void 0&&!qg(a)||o!==void 0&&(!qg(o)||o>r))return;let c=Jg([n,...i===void 0?[]:[i],...a===void 0?[]:[a]]);if(c===void 0)return;let l;if(s!==void 0){if(!qg(s))return;let e=s-r;if(!qg(e)||e<c||i!==void 0&&a!==void 0&&e!==c)return;l=s}else{if(i===void 0||a===void 0)return;let e=Jg([c,r]);if(e===void 0)return;l=e}return{inputTokens:n,outputTokens:r,totalTokens:l,...i===void 0?{}:{cacheReadTokens:i},...a===void 0?{}:{cacheWriteTokens:a},...o===void 0?{}:{reasoningTokens:o},...t===void 0?{}:{route:t}}}function Qg(e){if(e.length===0)return;let t=Jg(e.map(e=>e.inputTokens)),n=Jg(e.map(e=>e.outputTokens)),r=Jg(e.map(e=>e.totalTokens));if(t===void 0||n===void 0||r===void 0)return;let i=e.map(e=>e.cacheReadTokens),a=e.map(e=>e.cacheWriteTokens),o=e.map(e=>e.reasoningTokens),s=i.every(qg)?Jg(i):void 0,c=a.every(qg)?Jg(a):void 0,l=o.every(qg)?Jg(o):void 0,u,d=e.map(e=>e.route);if(d.every(e=>e!==void 0)){let e=/* @__PURE__ */ new Map;for(let t of d)e.set(`${t.provider}\0${t.model}`,t);u=[...e.values()]}return{uncachedInputTokens:t,outputTokens:n,totalTokens:r,...s===void 0?{}:{cacheReadTokens:s},...c===void 0?{}:{cacheWriteTokens:c},...l===void 0?{}:{reasoningTokens:l},...u===void 0?{}:{routes:u}}}function $g(e,t,n){return e.turn===t&&e.step===n}function e_(e){let t={kind:`idle`},n=[],r,i=!1,a=!1,o=e=>{if(t.kind!==`open`||t.sample===void 0)return!1;let r=Zg(t.sample,e);return r!==void 0&&(n.push(r),!0)};for(let n of e){if(a)break;if(n.type===`turn/start`)r!==void 0||t.kind!==`idle`?a=!0:r=n.data.turn;else{if(r===void 0){a=!0;break}if(n.type===`turn/end`)n.data.turn!==r||t.kind!==`idle`||i?a=!0:i=!0;else{if(i){a=!0;break}if(n.type===`step/start`)n.data.turn!==r||t.kind!==`idle`?a=!0:t={kind:`open`,turn:r,step:n.data.step};else if(n.type===`llm/retry-started`)n.data.turn!==r||t.kind!==`settled`||t.by!==`retry`||!$g(t,n.data.turn,n.data.step)?a=!0:t={kind:`open`,turn:r,step:n.data.step};else if(n.type===`assistant/attempt`){if(n.data.turn!==r||t.kind!==`open`||!$g(t,n.data.turn,n.data.step)){a=!0;continue}let e=Xg(n.data.stream)??t.sample;t={kind:`open`,turn:r,step:n.data.step,...e===void 0?{}:{sample:e}},o()?t={kind:`finishClosed`,turn:r,step:n.data.step}:a=!0}else if(n.type===`assistant/message`){if(n.data.turn!==r||t.kind!==`open`||!$g(t,n.data.turn,n.data.step)){a=!0;continue}let e=n.data.usage??Xg(n.data.stream);e!==void 0&&(t={...t,sample:e}),o(Yg(n.data.message))?t={kind:`settled`,turn:r,step:n.data.step,by:`message`}:a=!0}else if(n.type===`llm/retry`){if(n.data.turn!==r||t.kind===`idle`||!$g(t,n.data.turn,n.data.step)){a=!0;continue}(t.kind===`settled`||t.kind===`open`&&!o())&&(a=!0),a||(t={kind:`settled`,turn:r,step:n.data.step,by:`retry`})}else if(n.type===`step/end`){if(n.data.turn!==r||t.kind===`idle`||!$g(t,n.data.turn,n.data.step)){a=!0;continue}t.kind===`open`&&!o()&&(a=!0),a||(t={kind:`idle`})}}}}return a||!i||t.kind!==`idle`?void 0:Qg(n)}function t_(e){return e.type!==`assistant/live-chunk`}function n_(e){if(e.type===`assistant/message`||e.type===`assistant/attempt`||e.type===`assistant/live-chunk`||e.type===`step/start`||e.type===`step/end`||e.type===`llm/retry`||e.type===`llm/retry-started`)return{turn:e.data.turn,step:e.data.step}}function r_(e){let t=e.start?.location??e.matches[0]?.location;return t?.kind===`turn`||t?.kind===`step`?t.turn:void 0}function i_(e){return e.finalNode!==void 0&&e.blocks.some(e=>e.kind===`text`&&e.text.trim()!==``)}function a_(e){let t=e.state===void 0?e.matches.find(e=>e.event.type===`turn/end`):e.state.end;if(t?.event.type!==`turn/end`)return null;let n=r_(e);if(n===void 0)return null;let r=n.steps.map(e=>e.data.get(`assistant-step`)).filter(e=>e!==void 0).filter(e=>e.finalNode!==void 0).sort((e,t)=>e.finalNode.seq-t.finalNode.seq),i=r.findLast(i_)??null,a=r.at(-1)?.finalNode.seq;for(let t of e.matches){let e=t.event,n=e.type===`tool/call`||e.type===`tool/result`&&e.surfaceOp===`append`||e.type===`turn/end`&&e.data.reason.kind===`error`||e.type===`llm/retry`?e.seq:void 0;n!==void 0&&(a===void 0||n>a)&&(a=n)}let o=e.start?.event.type===`turn/start`?e_(e.matches.map(e=>e.event).filter(t_)):void 0;return{turn:t.event.data.turn,seq:t.event.seq,time:t.event.time,closing:i,branchUnavailable:i===null||a!==i.finalNode.seq,...o===void 0?{}:{tokenUsage:o}}}let o_={kind:`turn-tail`,target:`chat`,match:e=>{if(e.type===`turn/start`)return{id:String(e.data.turn),role:`start`};if(e.type===`turn/end`||e.type===`tool/call`||e.type===`tool/result`)return{id:String(e.data.turn),role:`update`};let t=n_(e);return t===void 0?null:{id:String(t.turn),role:`update`}},start:(e,t)=>{if(t.event.type!==`turn/start`)throw Error(`turn-tail start requires turn/start`);return{turn:t.event.data.turn}},update:(e,t)=>t.event.type===`turn/end`?{...e.state,end:t}:e.state,publication:e=>e.event.type===`turn/end`?`immediate`:`none`,buildLocationData:(e,t)=>{if(t!==`turn`)return null;let n=a_(e);return n===null?null:{kind:`turn`,turn:n.turn,key:`turn-tail`,value:n}},buildViewNode:e=>{let t=r_(e)?.data.get(`turn-tail`);return t===void 0?null:Gp(e,`turn-tail`,t.seq+Up.finalizedFollowup,t)}};function s_(e){let t=o_.match.bind(o_);e.uiConversation.events.register({...o_,match:{"turn/start":t,"turn/end":t,"tool/call":t,"tool/result":t,"assistant/message":t,"assistant/attempt":t,"assistant/live-chunk":t,"step/start":t,"step/end":t,"llm/retry":t,"llm/retry-started":t}})}function c_(e){return e===`read`?`read`:e===`read_image`?`readImage`:e===`grep`||e===`glob`||e.endsWith(`_inspect`)?`search`:e===`write`?`write`:e===`edit`||e===`apply_patch`?`edit`:[`bash`,`pwsh`,`exec_command`,`write_stdin`].includes(e)||e.startsWith(`terminal_`)?`commands`:e===`run_code`?`code`:e===`web_search`?`webSearch`:e===`web_fetch`?`webFetch`:e===`subagent`||e.startsWith(`subagent_`)?`subagents`:[`todo_write`,`create_goal`,`update_goal`,`get_goal`].includes(e)?`plan`:e===`ask_user_question`||e===`request_user_input`?`questions`:`tools`}let l_=new Intl.Segmenter(void 0,{granularity:`grapheme`}),u_=[`title`,`description`,`objective`,`task`,`task_name`,`name`,`question`,`questions`,`prompt`,`message`,`command`,`cmd`,`queries`,`query`,`pattern`,`url`,`uri`,`file_path`,`path`,`target`,`action`,`status`];function d_(e){let t=e.replace(/\s+/g,` `).trim();if(t.length<=160)return{text:t,truncated:!1};let n=[];for(let{segment:e}of l_.segment(t)){if(n.length===160)return{text:`${n.slice(0,159).join(``).trimEnd()}…`,truncated:!0};n.push(e)}return{text:t,truncated:!1}}function f_(e){return d_(typeof e==`string`?e:Array.isArray(e)&&e.every(e=>typeof e==`string`)?e.join(`, `):``).text}function p_(e,t){let n=512;for(;;){let r=e.textPrefix(t,n);if(r===void 0)return;let i=r.charCodeAt(r.length-1);if(i>=55296&&i<=56319){let i=e.textPrefix(t,n+1),a=i.charCodeAt(r.length);a>=56320&&a<=57343?(r=i,n++):i.length===r.length&&!e.isSealed&&!e.complete(t)&&(r=r.slice(0,-1))}let a=d_(r);if(a.truncated||!e.stringExceeds(t,n))return a.text;n*=2}}function m_(e){if(!Array.isArray(e))return``;for(let t of e){if(typeof t!=`object`||!t)continue;let e=f_(Reflect.get(t,`question`));if(e!==``)return e}return``}function h_(e){for(let t=e.length-1;t>=0;t--){let n=e[t];if(n?.kind===`assistant-step`&&n.data.status===`running`)for(let e=n.data.blocks.length-1;e>=0;e--){let t=n.data.blocks[e];if(t?.kind!==`reasoning`)continue;let r=t.text.split(/\r?\n[\t ]*\r?\n/);for(let e=r.length-1;e>=0;e--){let t=f_(r[e]?.replaceAll(`**`,``));if(t!==``)return t}}}return``}function g_(e,t){for(let e of u_){if(!t.has(e))continue;let n=e===`questions`?m_(t.value(e)):p_(t,e)??f_(t.value(e));if(n!==``)return n}return t.closed()?f_(e):``}function __(e){let t=/* @__PURE__ */ new Map,n=/* @__PURE__ */ new Set,r,i=``,a=-1/0,o,s=e=>{if(n.has(e.callId))return;n.add(e.callId);let c=Sm(e)?e:e.call;if(c!==null){let n=c_(c.name);Sm(e)&&e.time>=a&&(r=n,o=e.phase===`preparing`,i=g_(e.name,e.args),a=e.time),t.set(n,(t.get(n)??0)+1)}for(let t of e.subCalls)s(t)};for(let t of e)t.kind===`tool-call`&&s(t.data.root);return r===void 0&&(i=h_(e)),{counts:[...t].map(([e,t])=>({kind:e,count:t})).sort((e,t)=>t.count-e.count),running:r,runningDetail:i,...o?{preparing:!0}:{}}}let v_=/* @__PURE__ */ new Set([`user`,`steering`,`turn-trigger`,`model-retry`,`turn-error`,`turn-max-tokens`,`turn-tail`]);function y_(e){let t=e.location;return t.kind===`turn`||t.kind===`step`?t.turn.turn:void 0}function b_(e){return v_.has(e.kind)||e.kind===`tool-call`&&md(e.data.root.name)}function x_(e){return e.kind===`assistant-step`&&e.data.blocks.some(e=>e.kind===`reasoning`&&e.text.trim()!==``)}function S_(e){return e.kind===`assistant-step`&&Ap(e.data.blocks)}function C_(e,t){return e.running===t.running&&e.runningDetail===t.runningDetail&&e.preparing===t.preparing&&e.counts.length===t.counts.length&&e.counts.every((e,n)=>e.kind===t.counts[n]?.kind&&e.count===t.counts[n].count)}function w_(e,t){return e.length===t.length&&e.every((e,n)=>e.key===t[n]?.key&&e.groupPart===t[n].groupPart)}function T_(e,t){return!Cm(t)&&(e===void 0||!Cm(e))?!1:e===void 0||e.kind!==t.kind||y_(e)!==y_(t)||Cm(e)!==Cm(t)||x_(e)!==x_(t)||S_(e)!==S_(t)}function E_(e,t){let n=e.readNode(t);if(n===void 0)throw Error(`Chat grouping input is missing Node ${t}`);return n}function D_(e,t){let n=/* @__PURE__ */ new Set;for(let r of t){let t=E_(e,r);t.kind===`question-reply`&&n.add(t.id)}return n}var O_=class{key;turn;members;nodes=[];snapshot;constructor(e,t,n){this.key=e,this.turn=t,this.members=n,this.snapshot={key:e,members:n,data:{turn:t,closed:!1,summary:{counts:[],running:void 0,runningDetail:``}}}}refresh(e,t){let n=this.members.map(t=>E_(e,t.key)),r=n.length===this.nodes.length&&n.every((e,t)=>e===this.nodes[t]),i=this.snapshot.data,a=r&&i.closed===t?i.summary:__(n),o=t?{counts:a.counts,running:void 0,runningDetail:``}:a;this.nodes=n,(i.closed!==t||!C_(i.summary,o))&&(this.snapshot={key:this.key,members:this.members,data:{turn:this.turn,closed:t,summary:o}})}},k_=class{turn;groups=/* @__PURE__ */ new Map;membership=/* @__PURE__ */ new Map;roots=/* @__PURE__ */ new Map;constructor(e){this.turn=e}references(e){return this.roots.get(e)??[]}snapshots(){return[...this.groups.values()].map(e=>e.snapshot)}refresh(e,t){let n=/* @__PURE__ */ new Set;for(let e of t){let t=this.membership.get(e);t!==void 0&&n.add(t)}let r=e.timeline.turns.get(this.turn)?.status===`closed`;if(r)for(let e of this.groups.values())e.snapshot.data.closed||n.add(e.key);let i=[];for(let t of n){let n=this.groups.get(t),a=n.snapshot;n.refresh(e,a.data.closed||r),n.snapshot!==a&&i.push(n.snapshot)}return i}rebuild(e,t){let n=/* @__PURE__ */ new Map,r=/* @__PURE__ */ new Map,i=/* @__PURE__ */ new Map,a=[],o=[],s=(e,t)=>{n.set(e,[...n.get(e)??[],t])},c=n=>{let c=a[0];if(c===void 0)return;let l=this.extendedGroup(a,t)?.key??jf(JSON.stringify([`process`,c.key,c.groupPart??null])),u=this.groups.get(l),d=u?.snapshot,f=u!==void 0&&w_(u.members,a)?u:new O_(l,this.turn,a);f.refresh(e,n||e.timeline.turns.get(this.turn)?.status===`closed`),r.set(f.key,f),s(c.key,{kind:`group`,key:f.key});for(let e of a)i.set(e.key,f.key);f.snapshot!==d&&o.push(f.snapshot),a=[]},l,u=!1,d=e.readTurn(this.turn),f=D_(e,d);for(let t of d){let n=A_(e,t);l!==void 0&&n.previous!==l&&c(!0),l=t,u=n.next!==void 0;let r=E_(e,t);r.kind===`turn-trigger`&&f.has(r.id)||(b_(r)?(c(!0),s(t,{kind:`node`,key:t})):r.kind===`turn-process`?s(a[0]?.key??t,{kind:`node`,key:t}):r.kind===`assistant-step`?(x_(r)&&a.push({kind:`node`,key:t,groupPart:`reasoning`}),S_(r)&&(c(!0),s(t,{kind:`node`,key:t,groupPart:`response`}))):a.push({kind:`node`,key:t}))}c(u);let p=[...this.groups.keys()].filter(e=>!r.has(e));return this.groups=r,this.membership=i,this.roots=n,{upserts:o,removes:p}}extendedGroup(e,t){let n=e.findIndex(e=>!t.has(e.key)),r=e[n];if(r===void 0)return;let i=this.membership.get(r.key),a=i===void 0?void 0:this.groups.get(i);if(!(a===void 0||n+a.members.length>e.length)){for(let t=0;t<a.members.length;t++){let r=a.members[t],i=e[n+t];if(r.key!==i.key||r.groupPart!==i.groupPart)return}for(let r=n+a.members.length;r<e.length;r++)if(!t.has(e[r].key))return;return a}}};function A_(e,t){let n=e.readPosition(t);if(n===void 0)throw Error(`Chat grouping order is missing position for Node ${t}`);return n}var j_=class{turns=/* @__PURE__ */ new Map;order=[];pending=null;accept(e){if(e.kind===`replace`){let t=new Set(this.order),n=new Set(e.order.filter(e=>!t.has(e))),r=/* @__PURE__ */ new Map;for(let t of e.order){let i=A_(e,t).turn;if(i===void 0||r.has(i))continue;let a=this.turns.get(i)??new k_(i);a.rebuild(e,n),r.set(i,a)}this.turns=r,this.order=e.order,this.pending={entries:this.rootEntries(e),groups:{kind:`replace`,snapshots:[...r.values()].flatMap(e=>e.snapshots())}};return}let t=new Set(e.changedTurnOrders),n=/* @__PURE__ */ new Set,r=/* @__PURE__ */ new Map,i=e=>{let t=r.get(e);return t===void 0&&(t=/* @__PURE__ */ new Set,r.set(e,t)),t};for(let r of e.changes){let e=r.previous,a=r.current,o=y_(a);if((e===void 0||!Cm(e))&&n.add(a.key),T_(e,a)){let n=e===void 0?void 0:y_(e);n!==void 0&&t.add(n),o!==void 0&&t.add(o)}o!==void 0&&i(o).add(a.key)}for(let t of e.changedTurns)i(t);let a=[],o=[];for(let r of t){let t=this.turns.get(r)??new k_(r),i=t.rebuild(e,n);a.push(...i.upserts),o.push(...i.removes),e.readTurn(r).length===0?this.turns.delete(r):this.turns.set(r,t)}for(let[n,i]of r)t.has(n)||a.push(...this.turns.get(n)?.refresh(e,i)??[]);let s=e.order!==this.order||t.size>0;this.order=e.order;let c=new Set(a.map(e=>e.key));this.pending=s||a.length>0||o.length>0?{...s?{entries:this.rootEntries(e)}:{},groups:{kind:`apply`,upserts:a,removes:o.filter(e=>!c.has(e))}}:null}rootEntries(e){let t=D_(e,e.order.filter(t=>A_(e,t).turn===void 0));return e.order.flatMap(n=>{let r=A_(e,n).turn;if(r===void 0){let r=E_(e,n);return r.kind===`turn-trigger`&&t.has(r.id)?[]:[{kind:`node`,key:n}]}let i=this.turns.get(r);if(i===void 0)throw Error(`Chat grouping order is missing Turn ${r}`);return i.references(n)})}output(){return this.pending}};let M_={kind:`process-groups`,target:`chat`,create:()=>new j_,update:(e,t)=>(e.state.accept(t),e.state),buildGroups:e=>e.state.output()};function N_(e){Wh(e),Yh(e),eg(e),bm(e),Gg(e),Sg(e),Ah(e),Nh(e),ig(e),Dg(e),Mg(e),s_(e),Fh(e),vh(e),e.uiConversation.groups.register(M_)}function P_({useNotice:e,dismissNotice:t,keepNoticeOpen:n,renderSlotChain:r,t:i}){let a=e(e=>e);if(a===null)return null;let o={code:a.code,message:i(`message.failure.quota`),dismiss:t,keepOpen:n};return/* @__PURE__ */ (0,f.jsx)(d.Fragment,{children:r(`shell.quota-notice`,o,{fallback:/* @__PURE__ */ (0,f.jsx)(p.Toast,{text:o.message,icon:/* @__PURE__ */ (0,f.jsx)(p.IconWarningOutlineRegular,{size:18}),onDone:t})})},`quota-notice-${String(a.seq)}`)}function F_(e){return e==null}function I_(e){return e&&typeof e==`object`&&!Array.isArray(e)}function L_(e,t){return Object.fromEntries(Object.entries(e).filter(([e,n])=>t(e,n)))}function R_(e,t){return Object.fromEntries(Object.entries(e).map(([e,n])=>[e,t(n,e)]))}function z_(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 B_=Symbol.for(`cosmokit.volatile.write`);function V_(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=>V_(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,V_(n,t)])))}finally{t.delete(e)}}function H_(e){let t=V_(e);return Object.freeze({get:()=>t,[B_]:e=>{t=e}})}function U_(e){return typeof e==`object`&&!!e&&B_ in e}function W_(e,t){return arguments.length===1?t=>W_(e,t):e in globalThis&&t instanceof globalThis[e]||Object.prototype.toString.call(t).slice(8,-1)===e}function G_(e){return W_(`ArrayBuffer`,e)||W_(`SharedArrayBuffer`,e)}function K_(e){return G_(e)||ArrayBuffer.isView(e)}let q_;(function(e){e.is=G_,e.isSource=K_;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})(q_||={}),q_.fromBase64,q_.toBase64,q_.fromHex,q_.toHex;function J_(e,t=/* @__PURE__ */ new Map){if(!e||typeof e!=`object`)return e;if(W_(`Date`,e))return new Date(e.valueOf());if(W_(`RegExp`,e))return new RegExp(e.source,e.flags);if(G_(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(J_,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(J_,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(U_(e)||U_(t))return U_(e)&&U_(t);if(!n&&F_(e)&&F_(t))return!0;if(typeof e!=typeof t||typeof e!=`object`||!e||!t||r.has(e))return!1;function a(n,r){return n(e)?n(t)?r(e,t):!1:!n(t)&&void 0}r.add(e);try{return a(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})??a(W_(`Date`),(e,t)=>e.valueOf()===t.valueOf())??a(W_(`URL`),(e,t)=>e.href===t.href)??a(W_(`RegExp`),(e,t)=>e.source===t.source&&e.flags===t.flags)??a(G_,(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 X_;(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})(X_||={});let Z_=Symbol.for(`schemastery`),Q_=Symbol.for(`ValidationError`);globalThis.__schemastery_index__??=0,globalThis.__schemastery_refs__=void 0;var Q=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?.[Q_]}};Object.defineProperty(Q.prototype,Q_,{value:!0});let $=function(e){let t=function(e,n={}){return $.resolve(e,t,n)[0]};if(e.refs){let t=R_(e.refs,e=>new $(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&&R_(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,$.prototype),t.meta||={},t.toString=t.toString.bind(t),t};$.prototype=Object.create(Function.prototype),$.prototype[Z_]=!0,Object.defineProperty($.prototype,"~standard",{get(){return{version:1,vendor:`schemastery`,validate:e=>{try{return{value:$.resolve(e,this,{})[0]}}catch(e){if(Q.is(e))return{issues:[{message:e.message,path:e.options.path}]};throw e}}}}}),$.ValidationError=Q,$.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},$.prototype.set=function(e,t){return this.dict[e]=t,this},$.prototype.push=function(e){return this.list.push(e),this};function $_(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 ev(e){return e?.$value??e?.$inner}function tv(e){return L_(e??{},e=>!e.startsWith(`$`))}$.prototype.i18n=function(e){let t=$(this),n=$_(t.meta.description,e);return Object.keys(n).length&&(t.meta.description=n),t.dict&&=R_(t.dict,(t,n)=>t.i18n(R_(e,e=>ev(e)?.[n]??e?.[n]))),t.list&&=t.list.map((t,n)=>t.i18n(R_(e,(e={})=>Array.isArray(ev(e))?ev(e)[n]:Array.isArray(e)?e[n]:tv(e)))),t.inner&&=t.inner.i18n(R_(e,e=>ev(e)?ev(e):tv(e))),t.sKey&&=t.sKey.i18n(R_(e,e=>e?.$key)),t},$.prototype.extra=function(e,t){let n=$(this);return n.meta={...n.meta,[e]:t},n};for(let e of[`required`,`disabled`,`collapse`,`hidden`,`loose`])Object.assign($.prototype,{[e](t=!0){let n=$(this);return n.meta={...n.meta,[e]:t},n}});$.prototype.deprecated=function(){let e=$(this);return e.meta.badges||=[],e.meta.badges.push({text:`deprecated`,type:`danger`}),e},$.prototype.experimental=function(){let e=$(this);return e.meta.badges||=[],e.meta.badges.push({text:`experimental`,type:`warning`}),e},$.prototype.pattern=function(e){let t=$(this),n=z_(e,[`source`,`flags`]);return t.meta={...t.meta,pattern:n},t},$.prototype.simplify=function(e){if(U_(e)&&(e=e.get()),Y_(e,this.meta.default,this.type===`dict`))return null;if(F_(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`||!F_(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 $.resolve(e,t,{}),t.simplify(e)}catch{}return e},$.prototype.toString=function(e){return uv[this.type]?.(this,e)??`Schema<${this.type}>`},$.prototype.role=function(e,t){let n=$(this);return n.meta={...n.meta,role:e,extra:t},n};for(let e of[`default`,`link`,`comment`,`description`,`max`,`min`,`step`])Object.assign($.prototype,{[e](t){let n=$(this);return n.meta={...n.meta,[e]:t},n}});$.prototype.volatile=function(){if(this.meta.volatile)throw TypeError(`volatile schema is already wrapped`);return this.extra(`volatile`,!0)};let nv={},rv=Symbol(`checked-volatile-schema`);function iv(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 Q(`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))iv(i,[...t,n],a,r);if(e.sKey&&iv(e.sKey,[...t,`<key>`],!0,r),e.inner&&(e.type!==`lazy`||e.inner[Z_])&&iv(e.inner,[...t,`*`],!0,r),e.list)for(let n=0;n<e.list.length;n++)iv(e.list[n],[...t,String(n)],!0,r)}$.extend=function(e,t){nv[e]=t},$.resolve=function(e,t,n={},r=!1){if(!t)return[e];if(n[rv]||(iv(t,n.path),n={...n,[rv]:!0}),t.meta?.volatile){let i=$(t);i.meta={...t.meta,volatile:!1};let[a,o]=$.resolve(e,i,n,r);try{return[H_(a),o]}catch(e){throw new Q(e instanceof Error?e.message:String(e),n)}}if(n.ignore?.(e,t))return[e];if(F_(e)&&t.type!==`lazy`){if(t.meta.required)throw new Q(`missing required value`,n);let r=t,i=t.meta.default;for(;r?.type===`intersect`&&F_(i);)r=r.list[0],i=r?.meta.default;if(F_(i))return[e];e=J_(i)}let i=nv[t.type];if(!i)throw new Q(`unsupported type "${t.type}"`,n);try{return i(e,t,n,r)}catch(e){if(!t.meta.loose)throw e;return[t.meta.default]}},$.from=function(e){if(F_(e))return $.any();if([`string`,`number`,`boolean`].includes(typeof e))return $.const(e).required();if(e[Z_])return e;if(typeof e==`function`)switch(e){case String:return $.string().required();case Number:return $.number().required();case Boolean:return $.boolean().required();case Function:return $.function().required();default:return $.is(e).required()}else throw TypeError(`cannot infer schema from ${e}`)},$.lazy=function(e){let t=new $({type:`lazy`,builder:e,inner:{toJSON:()=>(t.inner[Z_]||(t.inner=t.builder(),t.inner.meta={...t.meta,...t.inner.meta}),t.inner.toJSON())}});return t},$.natural=function(){return $.number().step(1).min(0)},$.percent=function(){return $.number().step(.01).min(0).max(1).role(`slider`)},$.date=function(){return $.union([$.is(Date),$.transform($.string().role(`datetime`),(e,t)=>{let n=new Date(e);if(isNaN(+n))throw new Q(`invalid date "${e}"`,t);return n},!0)])},$.regExp=function(e=``){return $.union([$.is(RegExp),$.transform($.string().role(`regexp`,{flag:e}),(t,n)=>{try{return new RegExp(t,e)}catch(e){throw new Q(e.message,n)}},!0)])},$.arrayBuffer=function(e){return $.union([$.is(ArrayBuffer),$.is(SharedArrayBuffer),$.transform($.any(),(e,t)=>{if(q_.isSource(e))return q_.fromSource(e);throw new Q(`expected ArrayBufferSource but got ${e}`,t)},!0),...e?[$.transform($.string(),(t,n)=>{try{return e===`base64`?q_.fromBase64(t):q_.fromHex(t)}catch(e){throw new Q(e.message,n)}},!0)]:[]])},$.extend(`lazy`,(e,t,n,r)=>(t.inner[Z_]||(t.inner=t.builder(),t.inner.meta={...t.meta,...t.inner.meta},iv(t.inner,n.path,!0)),$.resolve(e,t.inner,n,r))),$.extend(`any`,e=>[e]),$.extend(`never`,(e,t,n)=>{throw new Q(`expected nullable but got ${e}`,n)}),$.extend(`const`,(e,{value:t},n)=>{if(Y_(e,t))return[t];throw new Q(`expected ${t} but got ${e}`,n)});function av(e,t,n,r,i=!1){let{max:a=1/0,min:o=-1/0}=t;if(e>a)throw new Q(`expected ${n} <= ${a} but got ${e}`,r);if(e<o&&!i)throw new Q(`expected ${n} >= ${o} but got ${e}`,r)}$.extend(`string`,(e,{meta:t},n)=>{if(typeof e!=`string`)throw new Q(`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 Q(`expect string to match regexp ${r}`,n)}return av(e.length,t,`string length`,n),[e]});function ov(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 sv(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(ov(e,i)-ov(t,i))%ov(n,i)===0}$.extend(`number`,(e,{meta:t},n)=>{if(typeof e!=`number`)throw new Q(`expected number but got ${e}`,n);av(e,t,`number`,n);let{step:r}=t;if(r&&!sv(e,t.min??0,r))throw new Q(`expected number multiple of ${r} but got ${e}`,n);return[e]}),$.extend(`boolean`,(e,t,n)=>{if(typeof e==`boolean`)return[e];throw new Q(`expected boolean but got ${e}`,n)}),$.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 Q(`expected string but got ${e}`,r);e in t&&(i|=t[e])}}else throw new Q(`expected number or array but got ${e}`,r);return i===n.default?[i]:[i,a]}),$.extend(`function`,(e,t,n)=>{if(typeof e==`function`)return[e];throw new Q(`expected function but got ${e}`,n)}),$.extend(`is`,(e,{constructor:t},n)=>{if(typeof t==`function`){if(e instanceof t)return[e];throw new Q(`expected ${t.name} but got ${e}`,n)}{if(F_(e))throw new Q(`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 Q(`expected ${t} but got ${e}`,n)}});function cv(e,t,n,r){try{let[i,a]=$.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?H_(n.meta.default):n.meta.default}}$.extend(`array`,(e,{inner:t,meta:n},r)=>{if(!Array.isArray(e))throw new Q(`expected array but got ${e}`,r);return av(e.length,n,`array length`,r,!F_(t.meta.default)),[e.map((n,i)=>cv(e,i,t,r))]}),$.extend(`dict`,(e,{inner:t,sKey:n},r,i)=>{if(!I_(e))throw new Q(`expected object but got ${e}`,r);let a={};for(let o in e){let s;try{s=$.resolve(o,n,r)[0]}catch(e){if(i)continue;throw e}a[s]=cv(e,o,t,r),e[s]=e[o],o!==s&&delete e[o]}return[a]}),$.extend(`tuple`,(e,{list:t},n,r)=>{if(!Array.isArray(e))throw new Q(`expected array but got ${e}`,n);let i=t.map((t,r)=>cv(e,r,t,n));return r||i.push(...e.slice(t.length)),[i]});function lv(e,t){for(let n in t)n in e||(e[n]=t[n])}$.extend(`object`,(e,{dict:t},n,r)=>{if(!I_(e))throw new Q(`expected object but got ${e}`,n);let i={};for(let r in t){let a=cv(e,r,t[r],n);(!F_(a)||r in e)&&(i[r]=a)}return r||lv(i,e),[i]}),$.extend(`union`,(e,{list:t,toString:n},r,i)=>{let a=[];for(let n of t)try{return $.resolve(e,n,r,i)}catch(e){a.push(e)}throw new Q(`expected ${n()} but got ${JSON.stringify(e)}`,r)}),$.extend(`intersect`,(e,{list:t,toString:n},r,i)=>{if(!t.length)return[e];let a;for(let i of t){let t=$.resolve(e,i,r,!0)[0];if(!F_(t)){if(F_(a))a=t;else if(typeof a!=typeof t)throw new Q(`expected ${n()} but got ${JSON.stringify(e)}`,r);else if(typeof t==`object`)lv(a??={},t);else if(a!==t)throw new Q(`expected ${n()} but got ${JSON.stringify(e)}`,r)}}return!i&&I_(e)&&lv(a,e),[a]}),$.extend(`transform`,(e,{inner:t,callback:n,preserve:r},i)=>{let[a,o=e]=$.resolve(e,t,i,!0);return r?[n(a)]:[n(a),n(o)]});let uv={};function dv(e,t,n){uv[e]=n,Object.assign($,{[e](...n){let r=new $({type:e});return t.forEach((e,t)=>{switch(e){case`sKey`:r.sKey=n[t]??$.string();break;case`inner`:r.inner=$.from(n[t]);break;case`list`:r.list=n[t].map($.from);break;case`dict`:r.dict=R_(n[t],$.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}})}dv(`is`,[`constructor`],({constructor:e})=>typeof e==`function`?e.name:e),dv(`any`,[],()=>`any`),dv(`never`,[],()=>`never`),dv(`const`,[`value`],({value:e})=>typeof e==`string`?JSON.stringify(e):e),dv(`string`,[],()=>`string`),dv(`number`,[],()=>`number`),dv(`boolean`,[],()=>`boolean`),dv(`bitset`,[`bits`],()=>`bitset`),dv(`function`,[],()=>`function`),dv(`array`,[`inner`],({inner:e})=>`${e.toString(!0)}[]`),dv(`dict`,[`inner`,`sKey`],({inner:e,sKey:t})=>`{ [key: ${t.toString()}]: ${e.toString()} }`),dv(`tuple`,[`list`],({list:e})=>`[${e.map(e=>e.toString()).join(`, `)}]`),dv(`object`,[`dict`],({dict:e})=>Object.keys(e).length===0?`{}`:`{ ${Object.entries(e).map(([e,t])=>`${e}${t.meta.required?``:`?`}: ${t.toString()}`).join(`, `)} }`),dv(`union`,[`list`],({list:e},t)=>{let n=e.map(({toString:e})=>e()).join(` | `);return t?`(${n})`:n}),dv(`intersect`,[`list`],({list:e})=>`${e.map(e=>e.toString(!0)).join(` & `)}`),dv(`transform`,[`inner`,`callback`,`preserve`],({inner:e},t)=>e.toString(t));let fv=`transcriptView`,pv=[`compact`,`standard`,`detailed`,`verbose`],mv=[...pv,`normal`,`expanded`],hv=`standard`,gv={linkOpening:$.union([`sidebar`,`new-tab`]).default(`sidebar`),[fv]:$.union([...mv]).loose()};$.object(gv);let _v=`@deepseek-ai/dsh-client-ui-chat/PreferenceRow.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(_v)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=_v,e.textContent=`.W6wRnW_row{border-bottom:.5px solid var(--dsw-alias-border-l2);align-items:center;gap:8px;padding:16px 0;display:flex}.W6wRnW_rowText{flex-direction:column;flex:1;gap:4px;min-width:0;padding-right:48px;display:flex}.W6wRnW_title{color:var(--dsw-alias-label-primary);font-size:14px;font-weight:400;line-height:22px}.W6wRnW_desc{color:var(--dsw-alias-label-tertiary);font-size:12px;font-weight:400;line-height:18px}.W6wRnW_selector{border-radius:var(--dsw-radius-md);background:var(--dsw-alias-bg-module-platform);height:36px;font:inherit;color:var(--dsw-alias-label-primary);cursor:pointer;border:none;align-items:center;gap:12px;padding:0 14px;font-size:14px;line-height:22px;display:inline-flex}.W6wRnW_selector:hover{background:var(--dsw-alias-interactive-bg-hover)}.W6wRnW_chevron{flex:none}`,document.head.appendChild(e)}var vv={chevron:`W6wRnW_chevron`,desc:`W6wRnW_desc`,row:`W6wRnW_row`,rowText:`W6wRnW_rowText`,selector:`W6wRnW_selector`,title:`W6wRnW_title`};function yv({title:e,description:t,value:n,selectedLabel:r,options:i,onSelect:a}){let[o,s]=(0,d.useState)(!1),c=(0,d.useRef)(null),l=()=>{s(!1)},u=e=>{c.current?.focus({preventScroll:!0}),l(),a(e)},m=/* @__PURE__ */ (0,f.jsxs)(`button`,{ref:c,type:`button`,className:vv.selector,"aria-haspopup":`menu`,"aria-expanded":o,onClick:()=>{s(e=>!e)},children:[r,/* @__PURE__ */ (0,f.jsx)(p.IconChevronDownOutlineRegular,{className:vv.chevron})]});return/* @__PURE__ */ (0,f.jsxs)(`div`,{className:vv.row,children:[/* @__PURE__ */ (0,f.jsxs)(`div`,{className:vv.rowText,children:[/* @__PURE__ */ (0,f.jsx)(`div`,{className:vv.title,children:e}),/* @__PURE__ */ (0,f.jsx)(`div`,{className:vv.desc,children:t})]}),/* @__PURE__ */ (0,f.jsx)(p.Menu,{open:o,onClose:l,items:i,selectedId:n,onSelect:u,align:`end`,portal:!0,anchor:m})]})}let bv={compact:`settings.transcript.compact`,standard:`settings.transcript.standard`,detailed:`settings.transcript.detailed`,verbose:`settings.transcript.verbose`};function xv({useTranscriptView:e,setTranscriptView:t,t:n}){let r=e(e=>e);return/* @__PURE__ */ (0,f.jsx)(yv,{title:n(`settings.transcript.title`),description:n(`settings.transcript.description`),value:r,selectedLabel:n(bv[r]),options:pv.map(e=>({id:e,label:n(bv[e])})),onSelect:e=>{t(e)}})}var Sv=class{host;defaultMode;unsubscribe;mode;constructor(e,t=hv){this.host=e,this.defaultMode=t,this.mode=(0,m.createSnapshotStore)(t),this.unsubscribe=e.subscribe(()=>{this.adopt()}),this.adopt()}dispose(){this.unsubscribe()}setMode(e){this.mode.getSnapshot()!==e&&(this.mode.set(e),this.host.set(fv,e))}adopt(){let e=this.host.getSnapshot().value;if(e===void 0)return;let t=e.transcriptView,n=t===`normal`||t===`expanded`?`detailed`:t??this.defaultMode;this.mode.getSnapshot()!==n&&this.mode.set(n)}};let Cv={compact:{mode:`compact`,foldCompletedTurns:!0,stepGrouping:`collapsed`,liveProcessDetail:!1,settledReasoningPreview:!1},standard:{mode:`standard`,foldCompletedTurns:!0,stepGrouping:`collapsed`,liveProcessDetail:!0,settledReasoningPreview:!0},detailed:{mode:`detailed`,foldCompletedTurns:!0,stepGrouping:`history`,liveProcessDetail:!0,settledReasoningPreview:!0},verbose:{mode:`verbose`,foldCompletedTurns:!1,stepGrouping:`none`,liveProcessDetail:!1,settledReasoningPreview:!0}};function wv(e){return{getSnapshot:()=>Cv[e.getSnapshot()],subscribe:t=>e.subscribe(t)}}function Tv({useLinkOpening:e,useBrowserAvailable:t,setLinkOpening:n,t:r}){let i=e(e=>e);return t(e=>e)?/* @__PURE__ */ (0,f.jsx)(yv,{title:r(`settings.links.title`),description:r(`settings.links.description`),value:i,selectedLabel:r(i===`sidebar`?`settings.links.sidebar`:`settings.links.newTab`),options:[{id:`sidebar`,label:r(`settings.links.sidebar`)},{id:`new-tab`,label:r(`settings.links.newTab`)}],onSelect:e=>{n(e)}}):null}let Ev={getSnapshot:()=>void 0,subscribe:()=>()=>{}};function Dv(e,t){let n=e?.source(t)??Ev;return(0,d.useSyncExternalStore)(n.subscribe,n.getSnapshot)}let Ov={hooks:{turnData:(e,{turnData:t})=>function(e){return Dv(t,e)},disclosure:(e,{disclosureReset:t})=>Nd(t)}},kv=[`slots`,`sessions`,`uiWorkspace`,`uiSession`,`uiConversation`,`locale`,`configForms`,`remote`,`remote.session`,`sidebarRight`];function Av(e){let t=(0,m.createSnapshotStore)(null),n=0,r=/* @__PURE__ */ new Set,i=/* @__PURE__ */ new WeakMap,a=/* @__PURE__ */ new Set;e.effect(()=>async()=>{await Promise.all([...a].map(e=>e()))},`ui-chat: live quota notices`);let o=o=>{let s=i.get(o);if(s===void 0){let c=o.ctx.effect(()=>{let e=o.eventSource.subscribe(()=>{let{change:e}=o.eventSource.getSnapshot();if(e.kind===`append`)for(let{event:i}of e.entries){if(i.type!==`turn/end`||i.data.reason.kind!==`error`)continue;let{code:e}=i.data.reason.error;r.size>0||e!==`QUOTA`&&e!==`ACCOUNT_QUOTA`||t.set({code:e,seq:++n})}});return()=>{e(),i.delete(o),a.delete(c)}},`ui-chat: Provider binding quota notices`);a.add(c);let l=e.uiConversation.binding(o).target(`chat`);s={getSnapshot:()=>l.getSnapshot()??fe,subscribe:e=>l.subscribe(e)},i.set(o,s)}return s};N_(e),e.uiSession.provide({hooks:[`chat`],resolve:e=>({hooks:{chat:o(e)}})}),e.effect(()=>e.locale.register(X,{zh:Qf,en:$f}),`ui-chat: dictionaries`);let s=e.locale.bind(X),c=_d(),l=/* @__PURE__ */ new Map,u=e.configForms.get(`ui-chat`),d=(0,m.createSnapshotStore)(u.getSnapshot().value?.linkOpening??`sidebar`);e.effect(()=>u.subscribe(()=>{let e=u.getSnapshot().value?.linkOpening;e!==void 0&&d.set(e)})),e.inject([`sidebarRightTabs`],e=>{let t=e.sidebarRightTabs,n={getSnapshot:()=>t.get(`browser`)!==void 0,subscribe:e=>t.subscribe(e)};e.slots.inject(`settings.general.item`,()=>e.slots.register({name:`settings.general.item`,id:`link-opening`,order:17,locale:X,inject:()=>({hooks:{linkOpening:d,browserAvailable:n},setLinkOpening:e=>{d.set(e),u.set(`linkOpening`,e).catch(()=>{})}})},Tv))});let f=new Sv(u,`dshDesktop`in globalThis?`standard`:hv),p=wv(f.mode);e.effect(()=>()=>{f.dispose()}),Hp(e,p),e.slots.inject(`settings.general.item`,()=>e.slots.register({name:`settings.general.item`,id:`transcript-view`,order:12,locale:X,inject:()=>({hooks:{transcriptView:f.mode},setTranscriptView:e=>{f.setMode(e)}})},xv)),e.slots.inject(`conversation.view`,()=>e.slots.register({name:`conversation.view`,id:`chat`,order:0,label:()=>s(`view.chat`),locale:X,children:{"conversation.chat.node":{kind:`keyed`,scope:`session`,inject:Ov},"conversation.message.images":{kind:`single`,scope:`session`}},store:c,inject:t=>{let n=e.sessions.binding(t);if(n===void 0)throw Error(`ui-chat: unknown session "${t}"`);let r=n.session,i=o(n),a=e.uiConversation.binding(n),s=e.get(`chatMessageEditing`),c=e.get(`chatTurnDiffs`);return{connection:e.get(`connection`),hooks:{presentation:p},keyedHooks:{chatNode:e=>i.getSnapshot().nodes.source(e),chatNodeProcess:e=>i.getSnapshot().nodes.processSource(e),chatGroup:e=>a.snapshot.getSnapshot().views.grouped(`chat`)?.groupSource(e)},fileMentions:n=>e.get(`chatFileMentions`)?.forClosing(n,t),openFile:async(n,r)=>{let i=e.sessions.list.getSnapshot().byId[t]?.cwd,a=oe(t,i,n);r?.line===void 0?e.sidebarRight.openResource(a):e.sidebarRight.openResource(a,{params:{line:r.line}}),await Promise.resolve()},openSkill:n=>{let r=e.sessions.scope(t);r!==void 0&&e.get(`inputTriggers`)?.sessionOf(r).openReference(`skill`,{ref:`/${n}`})},resolveLink:e.get(`chatLinks`)?.resolve,openExternalLink:t=>{d.getSnapshot()===`sidebar`&&e.get(`sidebarRightTabs`)?.get(`browser`)!==void 0?e.sidebarRight.openTab(`browser`,{params:{url:t}}):window.open(t,`_blank`,`noopener,noreferrer`)},loadOlder:()=>{r.loadOlder()},loadThrough:e=>r.loadThrough(e),loadImage:Object.assign(n=>e.uiConversation.imageUrl(t,n),{peek:n=>e.uiConversation.peekImageUrl(t,n)}),chatScroll:{save:e=>{e===null?l.delete(t):l.set(t,e)},read:()=>l.get(t)??null},loadTurnDiffs:c?(e,n)=>c.read(t,e,n):void 0,editMessage:s?(e,n)=>s.send(t,e,n):void 0,forkAt:n=>{let r=[...i.getSnapshot().timeline.turns.values()].find(e=>e.end?.seq===n)?.data.get(`turn-tail`)?.closing?.finalNode.messageId;return e.sessions.fork({sessionId:t,atSeq:n,increaseTitle:!0,onCreated:n=>{e.get(`productAnalytics`)?.track(`branch_session_click`,{session_id:n,parent_session_id:t,...r===void 0?{}:{parent_message_id:r},click_position:`footer`})}}).then(t=>{e.uiWorkspace.openSession(t)})}}}},Xf)),e.slots.inject(`shell.overlay`,()=>e.slots.register({name:`shell.overlay`,id:`chat.quota-notice`,locale:X,children:{"shell.quota-notice":{kind:`chain`,scope:`root`}},inject:()=>({hooks:{notice:t},dismissNotice:()=>{r.clear(),t.set(null)},keepNoticeOpen:()=>{if(t.getSnapshot()===null)return()=>{};let e=Symbol(`ui-chat quota notice hold`);return r.add(e),()=>{r.delete(e)}}})},P_)),e.slots.inject(`conversation.input.dock`,()=>e.slots.register({name:`conversation.input.dock`,id:`file-changes`,order:5,locale:X},T)),e.slots.inject(`conversation.approval.detail`,()=>e.slots.register({name:`conversation.approval.detail`},me))}return n.EMPTY_CHAT_SNAPSHOT=fe,n.apply=Av,n.inject=kv,n.isRunningTool=Sm,n.isSettledTool=xm,t.exports}});
138
+ `,n);if(o!==-1&&o<=a){let r=e.slice(n,o).trim();r!==``&&(t=r)}if(i===null)return t;n=i.index+i[0].length}}let Lp=(0,d.memo)(function({text:e,running:t,usePresentation:n,useDisclosure:r,t:i}){let{expanded:a,toggle:o}=r(),s=(0,d.useMemo)(()=>uu(i),[i]),c=t?Ip(e):Fp(e),l=(0,d.useMemo)(()=>c.replaceAll(`**`,``),[c]),u=n(e=>!a&&l!==``&&(t||e.settledReasoningPreview)),m=(0,d.useMemo)(()=>/* @__PURE__ */ (0,f.jsxs)(f.Fragment,{children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:Np.separator,"data-shimmer-decoration":!0,"aria-hidden":!0}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:Np.summary,"data-streaming":t||void 0,children:/* @__PURE__ */ (0,f.jsx)(`span`,{className:Np.summaryText,children:/* @__PURE__ */ (0,f.jsx)(p.TextShimmer,{children:l})})})]}),[t,l]),h=(0,d.useMemo)(()=>a?/* @__PURE__ */ (0,f.jsx)(`div`,{className:Np.thinkBody,children:/* @__PURE__ */ (0,f.jsx)(p.MarkdownText,{text:e,streaming:t,labels:s,variant:`compact`})}):void 0,[a,s,t,e]);return/* @__PURE__ */ (0,f.jsxs)(`div`,{className:Np.root,"data-variant":`think`,"data-state":t?`running`:`ok`,"data-expanded":a||void 0,"data-preview":u||void 0,children:[t&&/* @__PURE__ */ (0,f.jsx)(`span`,{className:Kf.visuallyHidden,children:i(`row.running`)}),/* @__PURE__ */ (0,f.jsx)(p.DisclosureRow,{rowClassName:Np.row,leadingClassName:Np.leading,titleClassName:Np.title,icon:Pp,title:i(`message.think`),running:t,open:a,expandable:!0,expandOnRowClick:!0,onToggle:o,collapsedContent:m,children:h})]})}),Rp=`@deepseek-ai/dsh-client-ui-chat/AssistantMarkdown.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(Rp)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=Rp,e.textContent=`.B4Qqwq_root{font-size:var(--dsh-content-font-size,14px);line-height:calc(24px + var(--dsh-content-font-delta,0px));color:var(--dsw-alias-label-primary);flex-direction:column;display:flex}.B4Qqwq_body{flex-direction:column;gap:16px;display:flex}.B4Qqwq_body .md-table-wide{--dsh-table-spare:max(0px, calc((100cqw - var(--dsh-chat-content-width)) / 2));--dsh-table-lead:calc(var(--dsh-table-spare) + min(var(--dsh-chat-content-width), 100cqw) - 100%);box-sizing:border-box;width:calc(100% + var(--dsh-table-lead) + var(--dsh-table-spare));max-width:none;margin-left:calc(-1 * var(--dsh-table-lead));padding-left:var(--dsh-table-lead)}.B4Qqwq_body .md-table-wide>table{z-index:1;position:relative}.B4Qqwq_body>[data-turn-process-inline][hidden]{margin-bottom:-16px}.B4Qqwq_stopped{border-radius:var(--dsw-radius-sm);background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-label-tertiary);align-self:flex-start;padding:0 6px;font-size:11px;line-height:18px}.B4Qqwq_actions{margin-top:16px;margin-left:-6px}`,document.head.appendChild(e)}var zp={actions:`B4Qqwq_actions`,body:`B4Qqwq_body`,root:`B4Qqwq_root`,stopped:`B4Qqwq_stopped`};function Bp(e,t,n){let r;try{r=decodeURIComponent(t.split(/[?#]/u)[0]??``)}catch{return}return n===void 0?oe(e,r):n(r)}let Vp=(0,d.memo)(function({blocks:e,streaming:t,interrupted:n,renderMessageImages:r,groupPart:i,useDisclosure:a,reasoningHidden:o=!1,usePresentation:s,revealProcess:c,mentions:l,responseAnnotations:u,t:m}){let h=(0,d.useMemo)(()=>uu(m),[m]),{fileImages:g}=(0,p.useMarkdownDelegate)(),_=(0,d.useMemo)(()=>({resolve:e=>Bp(document.baseURI,e,g?.resolve)}),[g]),v=e.length-1;if(!(t||n===!0||e.some(e=>e.kind!==`tool-call`)))return null;let y=[];for(let n=0;n<e.length;n++){let g=e[n];if(g!==void 0&&(i!==`reasoning`||g.kind===`reasoning`)&&(i!==`response`||g.kind!==`reasoning`))switch(g.kind){case`text`:y.push(/* @__PURE__ */ (0,f.jsx)(p.MarkdownText,{text:g.text,streaming:t,labels:h,fileMentions:l,pathImages:_,responseAnnotations:u},n));break;case`reasoning`:y.push(/* @__PURE__ */ (0,f.jsx)(Hp,{hidden:o,reveal:c,children:/* @__PURE__ */ (0,f.jsx)(Lp,{text:g.text,running:t&&n===v,usePresentation:s,useDisclosure:a,t:m})},n));break;case`image`:{let t=n,i=[g];for(;n+1<e.length;){let t=e[n+1];if(t===void 0||t.kind!==`image`)break;i.push(t),n+=1}y.push(/* @__PURE__ */ (0,f.jsx)(d.Fragment,{children:r({images:i.map(({attachment:e})=>({attachment:e})),align:`start`})},t));break}case`tool-call`:break;default:y.push(/* @__PURE__ */ (0,f.jsx)(p.JsonBlock,{label:m(`message.unknownBlock`),payload:g.block,truncatedLabel:e=>m(`json.truncated`,{total:e})},n))}}return/* @__PURE__ */ (0,f.jsx)(`div`,{className:zp.root,"data-streaming":t||void 0,children:/* @__PURE__ */ (0,f.jsxs)(`div`,{className:zp.body,children:[y,n&&(i===void 0||i===`response`||!e.some(e=>e.kind!==`reasoning`&&e.kind!==`tool-call`))&&/* @__PURE__ */ (0,f.jsx)(`span`,{className:zp.stopped,children:m(`message.stopped`)})]})})});function Hp({hidden:e,reveal:t,children:n}){let r=jd(e,t??Up);return/* @__PURE__ */ (0,f.jsx)(`div`,{ref:r,"data-turn-process-inline":e||void 0,children:n})}let Up=()=>{},Wp=(0,d.memo)(function({node:e,groupPart:t,useDisclosure:n,useTurnData:r,turnProcess:i,openFile:a,renderMessageImages:o,fileMentions:s,responseAnnotations:c,usePresentation:l,t:u}){let p=e.data,m=e.location.kind===`turn`||e.location.kind===`step`?e.location.turn:void 0,h=r(`turn-tail`),g=(0,d.useMemo)(()=>{if(m?.status===`closed`&&p.finalNode!==void 0&&h?.closing?.finalNode.seq===p.finalNode.seq)return{turn:m,seq:p.finalNode.seq,openFile:a}},[p.finalNode,a,h,m]),_=(0,d.useMemo)(()=>g===void 0?void 0:s(g),[s,g]),v=i!==void 0&&i.foldable&&i.spec.answerStep===p.step&&i.spec.inlineReasoning&&!i.open,y=(0,d.useCallback)(()=>{i?.setOpen(!0)},[i]),ee=(0,d.useMemo)(()=>du(u),[u]),b=(0,d.useMemo)(()=>({labels:ee,resolve:e=>c[e-1]}),[ee,c]);return/* @__PURE__ */ (0,f.jsx)(`div`,{"data-selection-answer":``,"data-selection-answer-streaming":p.status===`running`||void 0,children:/* @__PURE__ */ (0,f.jsx)(Vp,{blocks:p.blocks,groupPart:t,useDisclosure:n,streaming:p.status===`running`,interrupted:p.status===`interrupted`,renderMessageImages:o,reasoningHidden:v,usePresentation:l,revealProcess:y,mentions:_,responseAnnotations:b,t:u})})}),Gp=`@deepseek-ai/dsh-client-ui-chat/GenericCommandCard.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(Gp)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=Gp,e.textContent=`.zcz1WW_root{flex-direction:column;display:flex}.zcz1WW_leading{flex-shrink:0}.zcz1WW_title{font-weight:400}.zcz1WW_separator{background:var(--dsw-alias-label-caption);border-radius:1px;flex:none;width:2px;height:2px;margin:0 8px}.zcz1WW_summary{min-width:0;font-size:var(--dsh-content-font-size-secondary,13px);line-height:calc(24px + var(--dsh-content-font-delta,0px));text-overflow:ellipsis;white-space:nowrap;flex:auto;overflow:hidden}.zcz1WW_summary[data-error],.zcz1WW_body[data-error]{color:var(--dsw-alias-state-error-primary)}.zcz1WW_body{border:.5px solid var(--dsw-alias-border-l1);border-radius:var(--dsw-radius-lg);background:var(--dsw-alias-markdown-code-block);max-height:260px;color:var(--dsw-alias-label-primary);font:var(--dsw-font-markdown-code-block-small);white-space:pre-wrap;margin:4px 0 4px 4px;padding:12px 16px;overflow:auto}`,document.head.appendChild(e)}var Kp={body:`zcz1WW_body`,leading:`zcz1WW_leading`,root:`zcz1WW_root`,separator:`zcz1WW_separator`,summary:`zcz1WW_summary`,title:`zcz1WW_title`};let qp=/* @__PURE__ */ (0,f.jsx)(p.IconApiOutlineRegular,{size:14});function Jp(e){return e===null?`running`:e.kind===`error`?`error`:`ok`}let Yp=(0,d.memo)(function({node:e,t,runningSummary:n,successSummary:r}){let[i,a]=(0,d.useState)(!1),o=e.outcome?.text,s=e.outcome===null?n??t(`command.running`):o??(e.outcome.kind===`error`?t(`command.failed`):r??t(`command.done`)),c=e.name??t(`command.title`),l=Jp(e.outcome),u=l===`running`,m=o!==void 0&&o.includes(`
139
+ `)?o:null,h=i&&m!==null,g=(0,d.useCallback)(()=>{a(e=>!e)},[]),_=(0,d.useMemo)(()=>/* @__PURE__ */ (0,f.jsxs)(f.Fragment,{children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:Kp.separator,"data-shimmer-decoration":!0,"aria-hidden":!0}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:Kp.summary,"data-error":l===`error`||void 0,children:/* @__PURE__ */ (0,f.jsx)(p.TextShimmer,{children:s})})]}),[u,l,s]),v=(0,d.useMemo)(()=>h?/* @__PURE__ */ (0,f.jsx)(`pre`,{className:Kp.body,"data-error":l===`error`||void 0,children:m}):void 0,[m,h,l]);return/* @__PURE__ */ (0,f.jsxs)(`div`,{className:Kp.root,"data-variant":`others`,"data-command":e.name??void 0,"data-state":l,children:[l===`running`&&/* @__PURE__ */ (0,f.jsx)(`span`,{className:Kf.visuallyHidden,children:t(`row.running`)}),l===`error`&&/* @__PURE__ */ (0,f.jsx)(`span`,{className:Kf.visuallyHidden,children:t(`row.failed`)}),/* @__PURE__ */ (0,f.jsx)(p.DisclosureRow,{leadingClassName:Kp.leading,titleClassName:Kp.title,icon:qp,title:c,running:u,open:h,expandable:m!==null,expandOnRowClick:!0,keepContentWhenOpen:!0,onToggle:g,collapsedContent:_,children:v})]})});function Xp({node:e,compaction:t,t:n}){return t===void 0?/* @__PURE__ */ (0,f.jsx)(Yp,{node:e,t:n,runningSummary:n(`message.compaction.running`),successSummary:n(`message.compaction`)}):/* @__PURE__ */ (0,f.jsx)(vu,{node:t,title:n(`message.compaction.commandTitle`),fallbackSummary:e.outcome?.text??null,t:n})}let Zp=(0,d.memo)(function({node:e,renderSlot:t,t:n}){let r=e.data,i=(0,d.useMemo)(()=>({node:r}),[r]);return/* @__PURE__ */ (0,f.jsx)(`div`,{className:Y.callRow,children:t(`conversation.chat.commandview`,i,{entryKey:r.name??``,fallback:/* @__PURE__ */ (0,f.jsx)(Yp,{...i,t:n})})})}),Qp=(0,d.memo)(function({node:e,t}){let n=e.data;return/* @__PURE__ */ (0,f.jsx)(`div`,{className:Y.callRow,children:/* @__PURE__ */ (0,f.jsx)(Xp,{node:n.command,...n.compaction===null?{}:{compaction:n.compaction},t})})});function $p({text:e,update:t=!1,t:n}){let[r,i]=(0,d.useState)(!1);return/* @__PURE__ */ (0,f.jsx)(p.DisclosureRow,{className:Gu.root,icon:/* @__PURE__ */ (0,f.jsx)(p.IconBrowseOutlineRegular,{size:14}),chevronClassName:Gu.chevron,title:n(t?`message.systemPromptUpdate`:`message.systemPrompt`),open:r,expandable:!0,expandOnRowClick:!0,onToggle:()=>{i(e=>!e)},children:/* @__PURE__ */ (0,f.jsx)(`div`,{className:Gu.body,"data-system-prompt-body":!0,children:/* @__PURE__ */ (0,f.jsx)(ku,{content:[{type:`text`,text:e}],source:null,t:n})})})}let em=(0,d.memo)(function({node:e,t}){return/* @__PURE__ */ (0,f.jsx)($p,{text:e.data.text,update:e.data.update===!0,t})}),tm=`@deepseek-ai/dsh-client-ui-chat/TurnProcessNodeView.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(tm)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=tm,e.textContent=`.kKEWTq_root{box-sizing:border-box;width:100%;min-width:0;height:calc(33px + var(--dsh-content-font-delta,0px));border:none;border-bottom:.5px solid var(--dsw-alias-border-l2);color:var(--dsw-alias-label-tertiary);font:inherit;font-size:var(--dsh-content-font-size,14px);cursor:pointer;text-align:left;background:0 0;align-items:center;padding:0 0 8px;transition:color .1s;display:flex}.kKEWTq_root:disabled{cursor:default}.kKEWTq_root:hover:not(:disabled){color:var(--dsw-alias-label-secondary)}.kKEWTq_chevron{width:14px;height:14px;color:inherit;flex:none;margin-left:4px;transition:transform .1s}.kKEWTq_root[data-open] .kKEWTq_chevron{transform:rotate(180deg)}.kKEWTq_label{min-width:0;font-size:inherit;line-height:calc(24px + var(--dsh-content-font-delta,0px));text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.kKEWTq_durationNumber{font-family:var(--ds-font-family-code);font-variant-numeric:tabular-nums}@media (prefers-reduced-motion:reduce){.kKEWTq_root,.kKEWTq_chevron{transition:none}}`,document.head.appendChild(e)}var nm={chevron:`kKEWTq_chevron`,durationNumber:`kKEWTq_durationNumber`,label:`kKEWTq_label`,root:`kKEWTq_root`};let rm=(0,d.memo)(function({node:e,turnProcess:t,t:n}){if(t===void 0)throw Error(`turn-process node requires Turn process owner state`);let r=!t.foldable||t.open,i=e.location.kind===`turn`||e.location.kind===`step`?e.location.turn:void 0;if(i?.status!==`closed`)return null;let a=t.foldable&&t.hasContent&&!Od(e),o=i.end?.data.reason.kind,s=i.start===void 0||i.end===void 0||i.end.time<=i.start.time?void 0:Math.max(1e3,i.end.time-i.start.time),c=s===void 0||o===`aborted`||o===`error`||o===`unknown`?void 0:Xu(s,n),l=n(o===`unknown`?`message.turnProcess.unknown`:o===`aborted`?`message.stopped`:o===`error`?`message.turnProcess.failed`:c===void 0?`message.turnProcess.worked`:`message.turnProcess.took`),u=n(o===`unknown`?`message.turnProcess.unknown`:o===`aborted`?`message.stopped`:o===`error`?`message.turnProcess.failed`:`message.turnProcess.worked`);return/* @__PURE__ */ (0,f.jsxs)(f.Fragment,{children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:Kf.visuallyHidden,role:`status`,"aria-live":`polite`,"aria-atomic":`true`,children:u}),/* @__PURE__ */ (0,f.jsxs)(`button`,{type:`button`,className:nm.root,"data-open":r||void 0,"data-turn-process":e.data.turn,"data-turn-process-messages":e.data.messageCount,"data-turn-process-tool-calls":e.data.toolCallCount,"data-turn-process-subagents":e.data.subagentCount,disabled:!a,"aria-expanded":t.hasContent?r:void 0,onClick:e=>{e.currentTarget.focus(),t.setOpen(!r)},children:[/* @__PURE__ */ (0,f.jsxs)(`span`,{className:nm.label,children:[l,c?.map((e,t)=>/* @__PURE__ */ (0,f.jsx)(`span`,{className:e.numeric?nm.durationNumber:void 0,children:e.text},t))]}),a&&/* @__PURE__ */ (0,f.jsx)(p.IconChevronDownOutlineRegular,{className:nm.chevron})]})]})});function im(e,t,n,r){let[i,a]=(0,d.useState)({}),[o,s]=(0,d.useState)(),[c,l]=(0,d.useState)(0),u=JSON.stringify(t.filter(e=>n.has(e.path)&&e.hunks===void 0).map(e=>[e.path,e.revision]));return(0,d.useEffect)(()=>{let t=JSON.parse(u).filter(([e,t])=>i[e]?.revision!==t);if(!r||t.length===0)return;let n=!0;return s(void 0),Promise.all(t.map(async([t,n])=>[t,{revision:n,diffs:(await r(e,t)).filter(e=>e.path===t)}])).then(e=>{n&&a(t=>({...t,...Object.fromEntries(e)}))},e=>{n&&s(e instanceof Error?e.message:String(e))}),()=>{n=!1}},[e,u,r,i,c]),{diffs:e=>e.hunks??(i[e.path]?.revision===e.revision?i[e.path]?.diffs:void 0),error:o,retry:()=>l(e=>e+1)}}let am=`@deepseek-ai/dsh-client-ui-chat/TurnChangesCard.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(am)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=am,e.textContent=`.cLLDhG_card{border:1px solid var(--dsw-alias-border-l2);corner-shape:round;color:var(--dsw-alias-label-primary);font-size:calc(var(--dsh-content-font-size-secondary,13px) + 2px);--dsh-change-stat-font-size:calc(var(--dsh-content-font-size-secondary,13px) + 1px);--dsw-alias-state-success-primary:var(--dsw-alias-file-diff-added-marker);--dsw-alias-state-error-primary:var(--dsw-alias-file-diff-deleted-marker);border-radius:12px;margin:8px 0;line-height:20px;overflow:hidden}.cLLDhG_header{align-items:center;gap:12px;padding:12px;display:flex}.cLLDhG_icon{corner-shape:round;background:color-mix(in srgb, var(--dsw-alias-label-primary) 4%, transparent);width:44px;height:44px;color:var(--dsw-alias-label-secondary);border-radius:12px;flex:none;place-items:center;display:grid}.cLLDhG_text{flex-direction:column;flex:auto;gap:2px;min-width:0;display:flex}.cLLDhG_title{text-overflow:ellipsis;white-space:nowrap;font-weight:600;overflow:hidden}.cLLDhG_review,.cLLDhG_fileHead,.cLLDhG_more{color:inherit;font:inherit;text-align:left;cursor:pointer;background:0 0;border:0}.cLLDhG_review{border:1px solid var(--dsw-alias-border-l2);corner-shape:round;font-size:var(--dsh-content-font-size,14px);white-space:nowrap;border-radius:12px;flex:none;padding:4px 8px;font-weight:500}.cLLDhG_review:hover,.cLLDhG_fileHead:hover,.cLLDhG_more:hover{background:var(--dsw-alias-interactive-bg-hover)}.cLLDhG_review:focus-visible,.cLLDhG_fileHead:focus-visible,.cLLDhG_more:focus-visible{outline:2px solid var(--dsw-alias-label-tertiary);outline-offset:-2px}.cLLDhG_files{border-top:1px solid var(--dsw-alias-border-l2);margin:0;padding:0;list-style:none}.cLLDhG_fileHead{justify-content:space-between;align-items:center;gap:12px;width:100%;min-height:40px;padding:8px 12px;display:flex}.cLLDhG_fileHead .cLLDhG_path{min-width:0;font-size:inherit;--dsw-alias-label-tertiary:var(--dsw-alias-label-secondary);flex:1}.cLLDhG_diff{padding:0 12px 12px}.cLLDhG_file:first-child .cLLDhG_diff:first-child{padding-top:12px}.cLLDhG_more{align-items:center;gap:8px;width:100%;min-height:40px;padding:8px 12px;font-weight:500;display:flex}.cLLDhG_mobileChevron,.cLLDhG_mobileFileIcon,.cLLDhG_mobilePath,.cLLDhG_mobileFullPath{display:none}.cLLDhG_chevron{flex:none;transition:transform .15s}.cLLDhG_chevron[data-open=true]{transform:rotate(180deg)}@media (width<=480px){.cLLDhG_header{grid-template-columns:36px minmax(0,1fr);gap:8px;display:grid}.cLLDhG_icon{width:36px;height:36px}.cLLDhG_review{grid-column:2;justify-self:start}}[data-phone] .cLLDhG_card{-webkit-text-size-adjust:100%;text-size-adjust:100%;min-width:0;max-width:100%;font-size:var(--dsh-content-font-size-secondary,13px);line-height:calc(20px + var(--dsh-content-font-delta-secondary,0px));--dsh-change-stat-font-size:calc(var(--dsh-content-font-size-secondary,13px) - 1px);--dsh-diff-inline-padding:12px;--dsh-diff-body-padding:4px 0 8px}[data-phone] .cLLDhG_header{grid-template-columns:20px minmax(0,1fr) 44px;gap:8px;min-height:52px;padding:0 4px 0 12px;display:grid}[data-phone] .cLLDhG_icon{background:0 0;border-radius:0;width:20px;height:20px}[data-phone] .cLLDhG_icon>svg{width:16px;height:16px}[data-phone] .cLLDhG_text{flex-direction:row;align-items:center;gap:8px}[data-phone] .cLLDhG_title{flex:auto;min-width:0;font-weight:500}[data-phone] .cLLDhG_review{border-radius:var(--dsw-radius-sm);border:0;grid-column:auto;justify-self:stretch;place-items:center;width:44px;height:44px;padding:0;display:grid}[data-phone] .cLLDhG_reviewLabel{display:none}[data-phone] .cLLDhG_mobileChevron,[data-phone] .cLLDhG_mobileFileIcon{color:var(--dsw-alias-label-secondary);flex:none;display:block}[data-phone] .cLLDhG_mobileChevron{transition:transform .15s}[data-phone] .cLLDhG_mobileChevron[data-open=true]{transform:rotate(180deg)}[data-phone] .cLLDhG_fileHead,[data-phone] .cLLDhG_more{gap:8px;min-height:44px;padding:0 12px}[data-phone] .cLLDhG_file+.cLLDhG_file{border-top:1px solid var(--dsw-alias-border-l2)}[data-phone] .cLLDhG_path{display:none}[data-phone] .cLLDhG_mobilePath{flex-direction:column;flex:1;min-width:0;padding-block:4px;display:flex}[data-phone] .cLLDhG_fileName{text-overflow:ellipsis;white-space:nowrap;font-weight:500;overflow:hidden}[data-phone] .cLLDhG_directory,[data-phone] .cLLDhG_mobileFullPath{color:var(--dsw-alias-label-secondary);font-size:calc(11px + var(--dsh-content-font-delta-secondary,0px));line-height:calc(16px + var(--dsh-content-font-delta-secondary,0px));white-space:normal;overflow-wrap:anywhere}[data-phone] .cLLDhG_mobileFullPath{user-select:text;padding:4px 12px;display:block}[data-phone] .cLLDhG_diff,[data-phone] .cLLDhG_file:first-child .cLLDhG_diff:first-child{padding:0}[data-phone] .cLLDhG_diffStatus{overflow-wrap:anywhere;padding:12px;display:block}[data-phone] .cLLDhG_diffStatus button{min-width:44px;min-height:44px}[data-phone] .cLLDhG_inlineDiff{border-radius:0;min-width:0;max-width:100%;margin:0}[data-phone] .cLLDhG_inlineDiff [data-diff-body]{box-sizing:border-box;-webkit-text-size-adjust:100%;text-size-adjust:100%;width:100%;min-width:0;font-size:calc(var(--dsw-font-markdown-code-block-font-size,11px) + var(--dsh-content-font-delta,0px));line-height:calc(var(--dsw-font-markdown-code-block-line-height,19px) + var(--dsh-content-font-delta,0px));tab-size:2;overscroll-behavior-x:contain}[data-phone] .cLLDhG_inlineDiff [data-diff-row=path]{display:none}[data-phone] .cLLDhG_inlineDiff [data-code-block-banner]{gap:8px;min-height:44px;padding:0 8px 0 12px}[data-phone] .cLLDhG_inlineDiff [data-code-block-banner] button{width:44px;height:44px}@media (prefers-reduced-motion:reduce){[data-phone] .cLLDhG_mobileChevron{transition:none}}`,document.head.appendChild(e)}var Z={card:`cLLDhG_card`,chevron:`cLLDhG_chevron`,diff:`cLLDhG_diff`,diffStatus:`cLLDhG_diffStatus`,directory:`cLLDhG_directory`,file:`cLLDhG_file`,fileHead:`cLLDhG_fileHead`,fileName:`cLLDhG_fileName`,files:`cLLDhG_files`,header:`cLLDhG_header`,icon:`cLLDhG_icon`,inlineDiff:`cLLDhG_inlineDiff`,mobileChevron:`cLLDhG_mobileChevron`,mobileFileIcon:`cLLDhG_mobileFileIcon`,mobileFullPath:`cLLDhG_mobileFullPath`,mobilePath:`cLLDhG_mobilePath`,more:`cLLDhG_more`,path:`cLLDhG_path`,review:`cLLDhG_review`,reviewLabel:`cLLDhG_reviewLabel`,text:`cLLDhG_text`,title:`cLLDhG_title`};let om=(0,d.memo)(function({nodeStore:e,turn:t,t:n,useProjection:r,loadTurnDiffs:i}){let a=te(e,t,r),o=(0,d.useMemo)(()=>{let e=/* @__PURE__ */ new Map;for(let t of a){let n=S(t.path);e.set(n,(e.get(n)??0)+1)}return e},[a]),[s,c]=(0,d.useState)(()=>/* @__PURE__ */ new Set),[l,u]=(0,d.useState)(!1),m=im(t,a,s,i),h=(0,d.useMemo)(()=>({codeLabel:n(`diff.code`),wrapLabel:n(`diff.wrap`),unwrapLabel:n(`diff.unwrap`),copy:n(`diff.copy`),copied:n(`diff.copied`),collapseAria:n(`diff.collapseAria`),expandAria:e=>n(`diff.expandAria`,{count:e}),collapse:n(`diff.collapse`),expand:e=>n(`diff.expand`,{count:e})}),[n]);if(a.length===0)return null;let{added:g,removed:_}=x(a),[y]=a,ee=a.length===1&&y!==void 0?n(`chat.fileEdited`,{name:S(y.path)}):n(`chat.filesEdited`,{count:a.length}),b=a.some(e=>s.has(e.path)),C=l?a:a.slice(0,3),w=a.length-C.length;return/* @__PURE__ */ (0,f.jsxs)(`section`,{className:Z.card,"data-turn-changes":t,children:[/* @__PURE__ */ (0,f.jsxs)(`div`,{className:Z.header,children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:Z.icon,"aria-hidden":`true`,children:/* @__PURE__ */ (0,f.jsx)(p.IconFileDiffOutlineRegular,{size:24})}),/* @__PURE__ */ (0,f.jsxs)(`span`,{className:Z.text,children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:Z.title,title:ee,children:ee}),/* @__PURE__ */ (0,f.jsx)(v,{added:g,removed:_})]}),/* @__PURE__ */ (0,f.jsxs)(`button`,{type:`button`,className:Z.review,"aria-expanded":b,"aria-label":n(b?`chat.hideChanges`:`chat.viewChanges`),onClick:()=>{c(new Set(b?[]:a.map(e=>e.path))),b||u(!0)},children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:Z.reviewLabel,children:n(b?`chat.hideChanges`:`chat.viewChanges`)}),/* @__PURE__ */ (0,f.jsx)(p.IconChevronDownOutlineRegular,{size:16,className:Z.mobileChevron,"data-open":b})]})]}),(a.length>1||b)&&/* @__PURE__ */ (0,f.jsxs)(`ul`,{className:Z.files,children:[C.map(e=>{let t=m.diffs(e),r=S(e.path);return/* @__PURE__ */ (0,f.jsxs)(`li`,{className:Z.file,children:[a.length>1&&/* @__PURE__ */ (0,f.jsxs)(`button`,{type:`button`,className:Z.fileHead,"aria-expanded":s.has(e.path),onClick:()=>{c(t=>{let n=new Set(t);return n.has(e.path)?n.delete(e.path):n.add(e.path),n})},children:[/* @__PURE__ */ (0,f.jsx)(p.IconFileDiffOutlineRegular,{size:16,className:Z.mobileFileIcon}),/* @__PURE__ */ (0,f.jsx)(p.PathLabel,{path:e.path,className:Z.path}),/* @__PURE__ */ (0,f.jsxs)(`span`,{className:Z.mobilePath,children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:Z.fileName,"aria-hidden":`true`,children:r}),(o.get(r)??0)>1&&/* @__PURE__ */ (0,f.jsx)(`span`,{className:Z.directory,"aria-hidden":`true`,children:e.path.slice(0,e.path.length-r.length)}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:Kf.visuallyHidden,children:e.path})]}),/* @__PURE__ */ (0,f.jsx)(v,{added:e.added,removed:e.removed}),/* @__PURE__ */ (0,f.jsx)(p.IconChevronDownOutlineRegular,{size:16,className:Z.mobileChevron,"data-open":s.has(e.path)})]}),s.has(e.path)&&/* @__PURE__ */ (0,f.jsxs)(`div`,{className:Z.diff,children:[/* @__PURE__ */ (0,f.jsx)(`div`,{className:Z.mobileFullPath,children:e.path}),t===void 0?m.error?/* @__PURE__ */ (0,f.jsxs)(`div`,{role:`alert`,className:Z.diffStatus,children:[m.error,` `,/* @__PURE__ */ (0,f.jsx)(`button`,{type:`button`,onClick:m.retry,children:n(`chat.retryDiff`)})]}):/* @__PURE__ */ (0,f.jsx)(`span`,{role:`status`,className:Z.diffStatus,children:n(`chat.loadingDiff`)}):/* @__PURE__ */ (0,f.jsx)(p.DiffBlock,{diffs:[...t],labels:h,maxLines:1/0,className:Z.inlineDiff})]})]},e.path)}),a.length>3&&/* @__PURE__ */ (0,f.jsx)(`li`,{children:/* @__PURE__ */ (0,f.jsxs)(`button`,{type:`button`,className:Z.more,"aria-expanded":l,onClick:()=>u(e=>!e),children:[w>0?n(`chat.showMoreFiles`,{count:w}):n(`chat.collapseFiles`),/* @__PURE__ */ (0,f.jsx)(p.IconChevronDownOutlineRegular,{size:16,className:Z.chevron,"data-open":l})]})})]})]})});function sm(e){return e.flatMap(e=>e.kind===`text`?[e.text]:[]).join(``)}function cm(e){return e.some(e=>e.kind===`reasoning`||e.kind===`tool-call`?!1:e.kind!==`text`||e.text.trim()!==``)}let lm=`@deepseek-ai/dsh-client-ui-chat/TurnTailNodeView.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(lm)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=lm,e.textContent=`.Lw1WLW_root{flex-direction:column;gap:16px;display:flex}.Lw1WLW_actions{margin-top:4px;margin-left:-6px}`,document.head.appendChild(e)}var um={actions:`Lw1WLW_actions`,root:`Lw1WLW_root`};function dm(e,t,n){let r=e.locations.getTurn(t);for(let t=r.length-1;t>=0;t--){let i=e.nodes.get(r[t]);if(!(i===void 0||i.kind===`turn-tail`||i.kind===`turn-process`||n&&i.kind===`turn-max-tokens`))return i}}let fm=(0,d.memo)(function({node:e,openFile:t,forkAt:n,loadTurnDiffs:r,renderSlot:i,t:a,useChat:o,useSession:s,useProjection:c}){let l=s(e=>e.openState===`open`),u=(0,d.useRef)(!1),[p,m]=(0,d.useState)(!1),[h,g]=(0,d.useState)(),_=e.data,v=o(e=>e.nodes),y=o(e=>(dm(e,_.turn,!0)?.anchorSeq??-1)>(_.closing?.finalNode.seq??_.seq)),ee=o(e=>{if(e.timeline.turnOrder.at(-1)!==_.turn)return!1;let t=dm(e,_.turn,!1),n=t?.kind===`assistant-step`?t.data.blocks.findLast(e=>e.kind!==`text`&&e.kind!==`reasoning`||e.text.trim()!==``):void 0;return n!==void 0&&cm([n])}),b=e.location.kind===`turn`||e.location.kind===`step`?e.location.turn:void 0,te=nd(c,b?.turn,`end`);if(b===void 0)return null;let x=_.closing,S=i(`conversation.chat.turnTail`,{turn:b,seq:x?.finalNode.seq??_.seq,openFile:t});if(x===null)return S===null?null:/* @__PURE__ */ (0,f.jsx)(`div`,{className:um.root,"data-turn-tail":_.turn,children:S});let C=x.finalNode.messageId,w=C===void 0?null:i(`conversation.chat.assistant-actions`,{messageId:C});return/* @__PURE__ */ (0,f.jsxs)(`div`,{className:um.root,"data-turn-tail":_.turn,"data-actions-reveal":ee?`always`:`hover`,children:[/* @__PURE__ */ (0,f.jsx)(om,{nodeStore:v,turn:_.turn,t:a,useProjection:c,loadTurnDiffs:r}),S,/* @__PURE__ */ (0,f.jsx)(td,{text:sm(x.blocks),time:te,clock:`end`,onBranch:()=>{!u.current&&l&&(u.current=!0,m(!0),g(void 0),n(_.seq).catch(e=>{g(e instanceof Error?e.message:String(e))}).finally(()=>{u.current=!1,m(!1)}))},branchUnavailable:!l||p||_.branchUnavailable||y,className:um.actions,extraActions:w,t:a}),h!==void 0&&/* @__PURE__ */ (0,f.jsx)(`p`,{role:`alert`,children:a(`message.branchFailed`,{message:h})})]})});function pm(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:{}}function mm(e,t){return typeof e[t]==`string`?e[t]:``}function hm(e){let t=pm(e.source),n=mm(t,`kind`),r=`message.trigger.request`,i=`request`;switch(n){case`goal`:r=`message.trigger.goal`,i=`goal`;break;case`agent-message`:r=`message.trigger.agent`,i=`agent`;break;case`team-message`:r=`message.trigger.team`,i=`team`;break;case`subagent-settled`:r=`message.trigger.subagent`,i=`subagent`;break;case`webhook`:{let e=mm(t,`provider`)===`github`;r=e?`message.trigger.github`:`message.trigger.webhook`,i=e?`github`:`webhook`;break}case`schedule`:r=`message.trigger.schedule`,i=`schedule`;break;case`tool-jobs`:r=`message.trigger.job`,i=`job`;break;case`cordis-host-runner`:r=`message.trigger.plugin`,i=`plugin`}return{title:r,icon:i}}let gm=`@deepseek-ai/dsh-client-ui-chat/TurnTriggerNodeView.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(gm)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=gm,e.textContent=`.eHX24W_root{border:.5px solid var(--dsw-alias-border-l1);border-radius:var(--dsw-radius-xl);background:var(--dsw-alias-turn-trigger-bg,var(--dsw-alias-markdown-code-block));min-width:0;transition:background-color .1s}.eHX24W_root:hover{background:var(--dsw-alias-turn-trigger-bg-hover,var(--dsw-alias-interactive-bg-hover))}.eHX24W_header{width:100%;color:var(--dsw-alias-label-tertiary);font:inherit;text-align:left;cursor:pointer;background:0 0;border:0;align-items:center;gap:10px;padding:12px 16px;transition:color .1s;display:flex}.eHX24W_header:hover{color:var(--dsw-alias-label-secondary)}.eHX24W_icon{color:inherit;flex:none;display:inline-flex}.eHX24W_title{font-size:var(--dsh-content-font-size,14px);flex:none}.eHX24W_time{color:inherit;font:var(--dsw-font-xxs-12);flex:none;margin-left:auto}.eHX24W_chevron,.eHX24W_openChevron{color:inherit;flex:none}.eHX24W_openChevron{transform:rotate(180deg)}.eHX24W_body{padding:0 16px 12px 40px}.eHX24W_explanation{color:var(--dsw-alias-label-secondary);font:var(--dsw-font-xxs-12);margin:8px 0}.eHX24W_content{white-space:pre-wrap;overflow-wrap:anywhere;max-height:240px;font:var(--dsw-font-xxs-12);overflow:auto}@media (prefers-reduced-motion:reduce){.eHX24W_root,.eHX24W_header{transition:none}}`,document.head.appendChild(e)}var _m={body:`eHX24W_body`,chevron:`eHX24W_chevron`,content:`eHX24W_content`,explanation:`eHX24W_explanation`,header:`eHX24W_header`,icon:`eHX24W_icon`,openChevron:`eHX24W_openChevron`,root:`eHX24W_root`,time:`eHX24W_time`,title:`eHX24W_title`};let vm={request:p.IconContextInjectionOutlineRegular,goal:p.IconGoalOutlineRegular,agent:p.IconPaperPlaneOutlineRegular,team:p.IconAgentPresetOutlineRegular,subagent:p.IconAgentPresetOutlineRegular,github:p.IconBranchOutlineRegular,webhook:p.IconGlobeOutlineRegular,schedule:p.IconClockOutlineRegular,job:p.IconQueueOutlineRegular,plugin:p.IconCordisPluginOutlineRegular};function ym({node:e,t}){let[n,r]=(0,d.useState)(!1),i=(0,d.useId)(),a=hm(e.data),o=vm[a.icon],s=new Date(e.data.time),c=Zu(e.data.time,t);return/* @__PURE__ */ (0,f.jsxs)(`section`,{className:_m.root,"data-turn-trigger":!0,children:[/* @__PURE__ */ (0,f.jsxs)(`button`,{className:_m.header,type:`button`,"aria-expanded":n,"aria-controls":i,onClick:()=>{r(!n)},children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:_m.icon,"aria-hidden":!0,children:/* @__PURE__ */ (0,f.jsx)(o,{size:14})}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:_m.title,children:t(a.title)}),/* @__PURE__ */ (0,f.jsx)(`time`,{className:_m.time,dateTime:s.toISOString(),children:c}),/* @__PURE__ */ (0,f.jsx)(p.IconChevronDownOutlineRegular,{size:12,className:n?_m.openChevron:_m.chevron})]}),n&&/* @__PURE__ */ (0,f.jsxs)(`div`,{id:i,className:_m.body,children:[/* @__PURE__ */ (0,f.jsx)(`p`,{className:_m.explanation,children:t(`message.trigger.explanation`)}),/* @__PURE__ */ (0,f.jsx)(`div`,{className:_m.content,children:/* @__PURE__ */ (0,f.jsx)(Lu,{content:e.data.content,source:e.data.source,t})})]})]})}function bm(e,t){e.slots.inject(`conversation.chat.node`,()=>e.slots.register({name:`conversation.chat.node`,key:`user`,locale:X,inject:()=>({links:e.get(`chatLinks`)})},gd)),e.slots.inject(`conversation.chat.node`,()=>e.slots.register({name:`conversation.chat.node`,key:`steering`,locale:X,inject:()=>({links:e.get(`chatLinks`)})},gd)),e.slots.inject(`conversation.chat.node`,()=>e.slots.register({name:`conversation.chat.node`,key:`context`,locale:X},vd)),e.slots.inject(`conversation.chat.node`,()=>e.slots.register({name:`conversation.chat.node`,key:`turn-trigger`,locale:X},ym)),e.slots.inject(`conversation.chat.node`,()=>e.slots.register({name:`conversation.chat.node`,key:`system-prompt`,locale:X},em)),e.slots.inject(`conversation.chat.node`,()=>e.slots.register({name:`conversation.chat.node`,key:`assistant-step`,locale:X,inject:()=>({hooks:{presentation:t}})},Wp)),e.slots.inject(`conversation.chat.node`,()=>e.slots.register({name:`conversation.chat.node`,key:`command`,locale:X,children:{"conversation.chat.commandview":{kind:`keyed`,scope:`session`}}},Zp)),e.slots.inject(`conversation.chat.node`,()=>e.slots.register({name:`conversation.chat.node`,key:`manual-compaction`,locale:X},Qp)),e.slots.inject(`conversation.chat.node`,()=>e.slots.register({name:`conversation.chat.node`,key:`compaction`,locale:X},yd)),e.slots.inject(`conversation.chat.node`,()=>e.slots.register({name:`conversation.chat.node`,key:`model-retry`,locale:X},bd)),e.slots.inject(`conversation.chat.node`,()=>e.slots.register({name:`conversation.chat.node`,key:`turn-error`,locale:X},xd)),e.slots.inject(`conversation.chat.node`,()=>e.slots.register({name:`conversation.chat.node`,key:`turn-max-tokens`,locale:X},Sd)),e.slots.inject(`conversation.chat.node`,()=>e.slots.register({name:`conversation.chat.node`,key:`turn-process`,locale:X},rm)),e.slots.inject(`conversation.chat.node`,()=>e.slots.register({name:`conversation.chat.node`,key:`turn-tail`,locale:X,children:{"conversation.chat.turnTail":{kind:`list`,scope:`session`},"conversation.chat.assistant-actions":{kind:`list`,scope:`session`}}},fm)),e.slots.inject(`conversation.chat.node`,()=>e.slots.register({name:`conversation.chat.node`,key:`unknown`,locale:X},Cd))}let xm={interruptedAssistant:-.9,interruptedFollowup:-.8,processControl:-.1,maxTokensNotice:.05,finalizedFollowup:.1};function Sm(e){return e.start?.location??e.matches[0]?.location??{kind:`unresolved`}}function Cm(e,t,n,r,i={}){return{key:e.key,kind:t,id:e.id,target:`chat`,anchorSeq:n,location:i.location??Sm(e),visibility:i.visibility??`visible`,data:r}}function wm(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:null}function Tm(e,t){let n=e[t];return typeof n==`string`&&n.length>0?n:null}function Em(e,t,n){let r=e[t];if(!Array.isArray(r))return[];let i=[];for(let e of r){let t=wm(e),r=t===null?null:Tm(t,n);r!==null&&!i.includes(r)&&i.push(r)}return i}function Dm(e){return e.length>0?e.join(`, `):null}let Om=[`instructions`,`catalog`,`snapshot`,`notice`,`relay`,`recall`];function km(e){let t=wm(e),n=t===null?null:Tm(t,`form`);return n!==null&&Om.includes(n)?n:null}function Am(e){let t=wm(e),n=t===null?null:Tm(t,`kind`);if(t===null||n===null)return{role:`inject`,label:null};switch(n){case`session-reference`:return{role:`recall`,label:Dm(Em(t,`references`,`label`))??n};case`agent-instructions`:return{role:`inject`,label:Dm(Em(t,`changes`,`path`))??n};case`skill-invocation`:return{role:`inject`,label:Tm(t,`name`)??n};default:return{role:`inject`,label:n}}}function jm(e){let t=wm(e);return t===null||Tm(t,`kind`)!==`session-reference`?[]:Em(t,`references`,`label`)}function Mm(e){let t=wm(e);return t===null||Tm(t,`kind`)!==`skill-invocation`?null:Tm(t,`name`)}function Nm(e){return e.map(Pm)}function Pm(e){switch(e.type){case`text`:return{kind:`text`,text:e.text};case`reasoning`:return{kind:`reasoning`,text:e.text};case`image`:return{kind:`image`,attachment:e.attachment};case`tool-call`:return{kind:`tool-call`,callId:String(e.id),name:e.name,argsRaw:e.arguments};default:return{kind:`other`,block:e}}}function Fm(e){switch(e){case`text`:return{kind:`text`,text:``};case`reasoning`:return{kind:`reasoning`,text:``};case`tool-call`:return{kind:`tool-call`,callId:``,name:``,argsRaw:``};default:return{kind:`other`,block:null}}}function Im(e){if(typeof e!=`object`||!e)return{message:String(e)};let t=e,n=typeof t.code==`string`?t.code:void 0;return n===`AUTH`?{code:n,message:``}:{...n===void 0?{}:{code:n},message:typeof t.message==`string`?t.message:JSON.stringify(e)}}function Lm(e){switch(e.type){case`text-delta`:case`reasoning-delta`:return e.text!==``;case`tool-call-delta`:return e.argumentsDelta!==``||e.name!==void 0;default:return!1}}function Rm(e,t){return{turn:e,step:t,blocks:[],visibleByIndex:[],visibleBlocks:0,firstVisibleSeq:void 0,firstVisibleTime:void 0,firstTokenTime:void 0,final:void 0,usage:void 0}}function zm(e){return e.filter(e=>e!==void 0)}function Bm(e){return e===void 0||e.kind===`tool-call`?!1:e.kind===`text`||e.kind===`reasoning`?e.text.trim()!==``:!0}function Vm(e){return e.some(Bm)}function Hm(e){return e.some(e=>e.kind===`text`||e.kind===`reasoning`?e.text.trim()!==``:!0)}function Um(e){return{...Rm(e.turn,e.step),firstTokenTime:e.firstTokenTime}}function Wm(e,t,n,r){if(t.type===`tool-call-delta`){let n=e.blocks[t.index];if(n?.kind===`tool-call`&&n.callId!==``&&(t.name===void 0||t.name===n.name)&&(e.firstTokenTime!==void 0||!Lm(t)))return e}let i=[...e.blocks],a=-1,o=!1,s=!1;switch(t.type){case`block-start`:a=t.index,o=e.visibleByIndex[t.index]===!0,i[t.index]=Fm(t.blockType),s=Bm(i[t.index]);break;case`text-delta`:{let n=i[t.index];a=t.index,o=e.visibleByIndex[t.index]===!0,i[t.index]={kind:`text`,text:(n?.kind===`text`?n.text:``)+t.text},s=n?.kind===`text`&&o||t.text.trim()!==``;break}case`reasoning-delta`:{let n=i[t.index];a=t.index,o=e.visibleByIndex[t.index]===!0,i[t.index]={kind:`reasoning`,text:(n?.kind===`reasoning`?n.text:``)+t.text},s=n?.kind===`reasoning`&&o||t.text.trim()!==``;break}case`tool-call-delta`:{let n=i[t.index];a=t.index,o=e.visibleByIndex[t.index]===!0,i[t.index]={kind:`tool-call`,callId:(n?.kind===`tool-call`?n.callId:``)||String(t.id),name:t.name??(n?.kind===`tool-call`?n.name:``),argsRaw:n?.kind===`tool-call`?n.argsRaw:``};break}case`block-end`:a=t.index,o=e.visibleByIndex[t.index]===!0,i[t.index]=Pm(t.block),s=Bm(i[t.index]);break;case`usage`:return{...e,usage:t.usage};default:return e}let c=e.visibleBlocks-Number(o)+Number(s),l=e.visibleByIndex;if(o!==s){let e=[...l];e[a]=s,l=e}let u=Lm(t);return{...e,blocks:i,visibleByIndex:l,visibleBlocks:c,...c>0&&e.firstVisibleSeq===void 0?{firstVisibleSeq:n,firstVisibleTime:r}:{},...u&&e.firstTokenTime===void 0?{firstTokenTime:r}:{}}}function Gm(e,t,n){let r=Nm(n.data.message.content),i=r.map(Bm);return{...e,blocks:r,visibleByIndex:i,visibleBlocks:i.reduce((e,t)=>e+Number(t),0),final:t,usage:n.data.usage}}function Km(e){if(e.kind===`step`&&e.step.status===`closed`&&e.step.end!==void 0)return e.step.end;if((e.kind===`step`||e.kind===`turn`)&&e.turn.status===`closed`&&e.turn.end!==void 0)return e.turn.end}function qm(e,t){let n=e.final;if(n?.event.type===`assistant/message`){let r=n.event;return{kind:`assistant`,seq:r.seq,messageId:r.data.message.id,time:r.time,turn:e.turn,step:e.step,blocks:Nm(r.data.message.content),usage:r.data.usage,timing:{stepStartTime:t.start?.event.time??null,firstTokenTime:e.firstTokenTime??null,completedTime:r.time},...r.data.interrupted===!0?{interrupted:!0}:{}}}let r=t.start?.location??t.matches.at(-1)?.location,i=r===void 0?void 0:Km(r);if(i===void 0)return;let a=zm(e.blocks);if(Hm(a))return{kind:`assistant`,seq:i.seq+xm.interruptedAssistant,time:i.time,turn:e.turn,step:e.step,blocks:a,interrupted:!0}}function Jm(e){let t;for(let n of e.matches)n.event.type===`assistant/live-chunk`?(t??=Rm(n.event.data.turn,n.event.data.step),t=Wm(t,n.event.data.chunk,n.event.seq,n.event.time)):n.event.type===`assistant/message`?(t??=Rm(n.event.data.turn,n.event.data.step),t=Gm(t,n,n.event)):n.event.type===`llm/retry`&&t!==void 0&&(t=Um(t));return t}function Ym(e){let t=e.state??Jm(e);if(t===void 0)return;let n=qm(t,e),r=n?.blocks??zm(t.blocks),i=n===void 0?t.visibleBlocks>0:Vm(r),a=n?.interrupted===!0?`interrupted`:n===void 0?`running`:`settled`,o=(n?.interrupted===!0?n.seq:t.firstVisibleSeq??n?.seq)??e.matches[0]?.event.seq??0,s=n?.time??t.firstVisibleTime??e.matches[0]?.event.time??0;return{anchorSeq:o,visible:i,settled:n,data:{status:a,turn:t.turn,step:t.step,blocks:r,time:s,...t.usage===void 0?{}:{usage:t.usage},...n===void 0?{}:{finalNode:n}}}}function Xm(e){let t=e.start?.location??e.matches.at(-1)?.location;return t?.kind===`step`?t.step.data.get(`assistant-step`):void 0}let Zm={kind:`assistant-step`,target:`chat`,match:e=>e.type===`step/start`?{id:`${e.data.turn}:${e.data.step}`,role:`start`}:e.type===`assistant/live-chunk`||e.type===`assistant/message`&&e.surfaceOp===`append`||e.type===`llm/retry`?{id:`${e.data.turn}:${e.data.step}`,role:`update`}:null,start:(e,t)=>{if(t.event.type!==`step/start`)throw Error(`assistant-step start requires step/start`);return Rm(t.event.data.turn,t.event.data.step)},update:(e,t)=>t.event.type===`assistant/live-chunk`?Wm(e.state,t.event.data.chunk,t.event.seq,t.event.time):t.event.type===`assistant/message`?Gm(e.state,t,t.event):t.event.type===`llm/retry`?Um(e.state):e.state,publication:e=>{if(e.event.type===`step/start`)return`none`;if(e.event.type!==`assistant/live-chunk`)return`immediate`;let t=e.event.data.chunk.type;return t===`usage`||t===`finish`?`none`:`animation-frame`},buildLocationData:(e,t)=>{if(t!==`step`)return null;let n=Ym(e);return n===void 0?null:{kind:`step`,turn:n.data.turn,step:n.data.step,key:`assistant-step`,value:n.data}},buildViewNode:e=>{let t=e.current.get(`chat`),n=e.state??Jm(e),r=Xm(e);if(n===void 0||r===void 0)return t==null?null:{...t,visibility:`hidden`};let i=r.finalNode,a=i===void 0?n.visibleBlocks>0:Vm(r.blocks);return i===void 0&&!a&&t==null?null:Cm(e,`assistant-step`,(i?.interrupted===!0?i.seq:n.firstVisibleSeq??i?.seq)??e.matches[0]?.event.seq??0,r,{visibility:i?.interrupted===!0||a?`visible`:`hidden`})}};function Qm(e){let t=Zm.match.bind(Zm);e.uiConversation.events.register({...Zm,match:{"step/start":t,"assistant/live-chunk":t,"assistant/message":t,"llm/retry":t}})}function $m(e){return`kind`in e}function eh(e){return!$m(e)}function th(e){return e.visibility===`visible`&&e.kind!==`system-prompt`&&(e.kind!==`context`||e.data.content.some(e=>e.type===`tool-addition`||e.type===`tool-removal`))&&(e.kind!==`command`||e.data.name!==`permission`)}function nh(e,t){let n=``,r=!1;for(let i of e){if(n.length>=t*2){r=!0;break}let e=i.length>t*2,a=e?i.slice(0,t*2):i;if(n+=n===``?a:` ${a}`,e){r=!0;break}}let i=n.replace(/\s+/g,` `).trim();return i.length>t-1?`${i.slice(0,t-1).trimEnd()}…`:r?`${i}…`:i}function rh(e){return e.kind===`user`?nh(e.data.content.flatMap(e=>e.type===`text`?[e.text]:[]),50):``}function ih(e){return e.kind===`assistant-step`?nh(e.data.blocks.flatMap(e=>e.kind===`text`?[e.text]:[]),120):``}function ah(e,t){return e===void 0||t===void 0?e===t:e.turn===t.turn&&e.anchorKey===t.anchorKey&&e.prompt===t.prompt&&e.response===t.response}function oh(e,t,n){let r=t.getTurn(e).map(e=>n.get(e)).filter(e=>e!==void 0&&th(e)),i=r.find(e=>e.kind===`user`),a=i??r[0];if(a===void 0)return;let o=r.findLast(e=>ih(e)!==``);return{turn:e,anchorKey:a.key,prompt:i===void 0?``:rh(i),response:o===void 0?``:ih(o)}}function sh(e){let t=e?.location;return t?.kind===`turn`||t?.kind===`step`?t.turn.turn:void 0}function ch(e,t){return e===t||e!==void 0&&t!==void 0&&e.spec===t.spec&&e.turn===t.turn&&e.turnStarted===t.turnStarted&&e.turnClosed===t.turnClosed&&e.hasExternalProcess===t.hasExternalProcess&&e.hasInterleavedInput===t.hasInterleavedInput&&e.compactAnswer===t.compactAnswer}function lh(e,t,n){let r=t.getTurn(e),i=r.map(e=>n.get(e)).find(e=>e?.kind===`turn-process`);if(i===void 0)return;let a=i.data,o=i.location;if(o.kind!==`turn`&&o.kind!==`step`)return;let s;for(let e of r){let t=n.get(e);(t?.kind===`user`||t?.kind===`steering`||t?.kind===`turn-trigger`)&&(a.controlAnchorSeq===o.turn.start?.seq||t.anchorSeq<a.controlAnchorSeq)&&(s=Math.max(s??t.anchorSeq,t.anchorSeq))}let c=!1,l=!1,u=!0;for(let e of r){let t=n.get(e);t!==void 0&&th(t)&&t.kind!==`turn-process`&&((t.kind===`user`||t.kind===`steering`||t.kind===`turn-trigger`)&&(s===void 0||t.anchorSeq>s)&&(l=!0,(a.answerAnchorSeq===null||t.anchorSeq<a.answerAnchorSeq)&&(u=!1)),!(wd.has(t.kind)||t.anchorSeq<a.processStartSeq)&&(t.kind!==`assistant-step`||a.answerStep===null||t.data.step!==a.answerStep)&&(c=!0))}return{turn:e,spec:a,turnStarted:o.turn.start!==void 0,turnClosed:o.turn.status===`closed`,hasExternalProcess:c,hasInterleavedInput:l,compactAnswer:u}}var uh=class{presentations=/* @__PURE__ */ new Map;get(e){let t=sh(e);return t===void 0?void 0:this.presentations.get(t)}replace(e,t,n){let r=/* @__PURE__ */ new Set;for(let t of e){let e=sh(n.get(t));e!==void 0&&r.add(e)}let i=/* @__PURE__ */ new Set;for(let e of/* @__PURE__ */ new Set([...this.presentations.keys(),...r]))this.set(e,r.has(e)?lh(e,t,n):void 0)&&i.add(e);return i}update(e,t,n){let r=/* @__PURE__ */ new Set;for(let i of e)this.set(i,lh(i,t,n))&&r.add(i);return r}set(e,t){return!ch(this.presentations.get(e),t)&&(t===void 0?this.presentations.delete(e):this.presentations.set(e,t),!0)}};let dh=[],fh=[],ph=[],mh=[];function hh(e,t){return e.length===t.length&&e.every((e,n)=>e===t[n])}function gh(e,t,n){let r=e.get(t);return r===void 0&&(r=n(),e.set(t,r)),r}var _h=class{read;label;listeners=/* @__PURE__ */ new Set;published;constructor(e,t){this.read=e,this.label=t,this.published=e()}getSnapshot=()=>this.read();subscribe=e=>(this.listeners.add(e),()=>{this.listeners.delete(e)});publish(){let e=this.getSnapshot();this.published!==e&&(this.published=e,(0,m.notifySubscribers)(this.listeners,this.label))}},vh=class{nodes=/* @__PURE__ */ new Map;current=mh;dirty=!1;observable;source(){return this.observable??=new _h(()=>this.read(),`[ui-chat] turn kind nodes`)}set(e){let t=this.nodes.get(e.key);this.nodes.set(e.key,e),(t===void 0||t.data!==e.data||t.anchorSeq!==e.anchorSeq)&&(this.dirty=!0)}delete(e){this.nodes.delete(e),this.dirty=!0}publish(){this.observable?.publish()}read(){return this.dirty&&=(this.current=[...this.nodes.values()].sort((e,t)=>e.anchorSeq-t.anchorSeq).map(e=>e.data),!1),this.current}},yh=class{byKey=/* @__PURE__ */ new Map;turnProcesses=new uh;sources=/* @__PURE__ */ new Map;processSources=/* @__PURE__ */ new Map;dirtyKeys=/* @__PURE__ */ new Set;dirtyProcessKeys=/* @__PURE__ */ new Set;turnKinds=/* @__PURE__ */ new Map;dirtyTurnKinds=/* @__PURE__ */ new Set;valuesCache=mh;valuesDirty=!1;get(e){return this.byKey.get(e)}source(e){return gh(this.sources,e,()=>new _h(()=>this.get(e),`[ui-chat] node source ${e}`))}turnDataSource(e,t){return this.turnKind(e,t).source()}turnKind(e,t){return gh(gh(this.turnKinds,e,()=>/* @__PURE__ */ new Map),t,()=>new vh)}updateTurnKind(e,t){let n=e===void 0?void 0:wh(e.location).turn,r=t===void 0?void 0:wh(t.location).turn;if(e!==void 0&&n!==void 0&&(n!==r||e.kind!==t?.kind)){let t=this.turnKind(n,e.kind);t.delete(e.key),this.dirtyTurnKinds.add(t)}if(t!==void 0&&r!==void 0){let e=this.turnKind(r,t.kind);e.set(t),this.dirtyTurnKinds.add(e)}}processSource(e){return gh(this.processSources,e,()=>new _h(()=>this.process(e),`[ui-chat] node process source ${e}`))}process(e){return this.turnProcesses.get(this.get(e))}values(){return this.valuesDirty&&=(this.valuesCache=[...this.byKey.values()],!1),this.valuesCache}replace(e){let t=new Map(this.byKey);this.byKey.clear();for(let n of e)this.byKey.set(n.key,n),t.get(n.key)!==n&&(this.updateTurnKind(t.get(n.key),n),this.dirtyKeys.add(n.key),this.dirtyProcessKeys.add(n.key)),t.delete(n.key);for(let e of t.keys())this.updateTurnKind(t.get(e),void 0),this.dirtyKeys.add(e),this.dirtyProcessKeys.add(e);this.valuesCache=[...this.byKey.values()],this.valuesDirty=!1}upsert(e){let t=!1;for(let n of e)this.byKey.get(n.key)!==n&&(this.updateTurnKind(this.byKey.get(n.key),n),this.byKey.set(n.key,n),this.dirtyKeys.add(n.key),this.dirtyProcessKeys.add(n.key),t=!0);t&&(this.valuesDirty=!0)}touchProcesses(e,t){for(let n of e)for(let e of t.getTurn(n))this.dirtyProcessKeys.add(e)}replaceProcesses(e,t){this.touchProcesses(this.turnProcesses.replace(e,t,this),t)}updateProcesses(e,t){this.touchProcesses(this.turnProcesses.update(e,t,this),t)}publish(){let e=[...this.dirtyKeys],t=[...this.dirtyProcessKeys],n=[...this.dirtyTurnKinds];this.dirtyKeys.clear(),this.dirtyProcessKeys.clear(),this.dirtyTurnKinds.clear();for(let t of e)this.sources.get(t)?.publish();for(let e of t)this.processSources.get(e)?.publish();for(let e of n)e.publish()}},bh=class{turns=/* @__PURE__ */ new Map;steps=/* @__PURE__ */ new Map;positions=/* @__PURE__ */ new Map;getTurn(e){return this.turns.get(e)??dh}getStep(e,t){return this.steps.get(Ch(e,t))??dh}getPosition(e){return this.positions.get(e)}rebuild(e,t){let n=/* @__PURE__ */ new Map,r=/* @__PURE__ */ new Map,i=/* @__PURE__ */ new Map,a=/* @__PURE__ */ new Set;for(let[o,s]of e.entries()){let c=t.get(s)?.location;if(c===void 0)continue;let l=wh(c),u=this.positions.get(s),d={turn:l.turn,previous:e[o-1],next:e[o+1]},f=u!==void 0&&u.turn===d.turn&&u.previous===d.previous&&u.next===d.next;if(i.set(s,f?u:d),f||(u?.turn!==void 0&&a.add(u.turn),d.turn!==void 0&&a.add(d.turn)),l.turn===void 0)continue;let p=n.get(l.turn)??[];if(p.push(s),n.set(l.turn,p),l.step===void 0)continue;let m=Ch(l.turn,l.step),h=r.get(m)??[];h.push(s),r.set(m,h)}for(let[e,t]of this.positions)!i.has(e)&&t.turn!==void 0&&a.add(t.turn);return this.positions=i,this.turns=xh(this.turns,n),this.steps=xh(this.steps,r),[...a]}touch(e){let t=/* @__PURE__ */ new Set,n=/* @__PURE__ */ new Set;for(let r of e){let e=wh(r.location);e.turn!==void 0&&this.turns.get(e.turn)?.includes(r.key)&&(t.add(e.turn),e.step!==void 0&&n.add(Ch(e.turn,e.step)))}for(let e of t){let t=this.turns.get(e);t!==void 0&&this.turns.set(e,[...t])}for(let e of n){let t=this.steps.get(e);t!==void 0&&this.steps.set(e,[...t])}}};function xh(e,t){let n=/* @__PURE__ */ new Map,r=/* @__PURE__ */ new Set([...e.keys(),...t.keys()]);for(let i of r){let r=e.get(i)??dh,a=t.get(i)??dh,o=hh(r,a)?r:a;a.length>0&&n.set(i,o)}return n}var Sh=class{current=ph;byTurn=/* @__PURE__ */ new Map;items(){return this.current}rebuild(e,t,n){let r=[],i=/* @__PURE__ */ new Map;for(let a of e.turnOrder){let e=oh(a,t,n);if(e===void 0)continue;let o=this.byTurn.get(a),s=o!==void 0&&ah(o,e)?o:e;r.push(s),i.set(a,s)}this.byTurn=i,r.length===this.current.length&&r.every((e,t)=>e===this.current[t])||(this.current=r)}touch(e,t,n){if(e.size===0)return;let r=this.current.map(r=>{if(!e.has(r.turn))return r;let i=oh(r.turn,t,n);return i===void 0||ah(r,i)?r:(this.byTurn.set(r.turn,i),i)});r.some((e,t)=>e!==this.current[t])&&(this.current=r)}};function Ch(e,t){return`${e}:${t}`}function wh(e){return e.kind===`step`?{turn:e.turn.turn,step:e.step.step}:e.kind===`turn`?{turn:e.turn.turn}:{}}function Th(e){return e.kind===`turn`||e.kind===`step`?e.turn.status:void 0}function Eh(e,t,n){return n||e===void 0||Th(e.location)!==Th(t.location)?!0:e.kind===`turn-process`&&t.kind===`turn-process`?e.data!==t.data:e.kind===`assistant-step`&&t.kind===`assistant-step`&&e.data.step!==t.data.step}function Dh(e){let t=/* @__PURE__ */ new Map;for(let n of e){let e=n;e.kind===`turn-process`&&t.set(e.data.turn,{...t.get(e.data.turn),control:e})}for(let n of e){let e=n,r=e.location;if(r.kind!==`turn`&&r.kind!==`step`)continue;let i=t.get(r.turn.turn)??{},a=i.control?.data.controlAnchorSeq;(e.kind===`user`||e.kind===`turn-trigger`||e.kind===`steering`)&&a!==void 0&&(a===r.turn.start?.seq||e.anchorSeq<a)?t.set(r.turn.turn,{...i,openingInputAnchor:Math.max(i.openingInputAnchor??e.anchorSeq,e.anchorSeq)}):wd.has(e.kind)||t.set(r.turn.turn,{...i,earliestProcessAnchor:Math.min(i.earliestProcessAnchor??e.anchorSeq,e.anchorSeq)})}return t}function Oh(e,t){let n=e,r=n.location;if(r.kind!==`turn`&&r.kind!==`step`)return{anchor:n.anchorSeq,rank:0,originalAnchor:n.anchorSeq};let i=t.get(r.turn.turn);if(i===void 0)return{anchor:n.anchorSeq,rank:0,originalAnchor:n.anchorSeq};let a=i.openingInputAnchor;return a!==void 0&&n.anchorSeq<a&&!wd.has(n.kind)?{anchor:a,rank:2,originalAnchor:n.anchorSeq}:i.control!==void 0&&n.key===i.control.key?a===void 0?{anchor:i.earliestProcessAnchor??n.anchorSeq,rank:-1,originalAnchor:n.anchorSeq}:{anchor:a,rank:1,originalAnchor:n.anchorSeq}:{anchor:n.anchorSeq,rank:0,originalAnchor:n.anchorSeq}}function kh(e){let t=e.filter(e=>th(e)),n=Dh(t);return t.sort((e,t)=>{let r=Oh(e,n),i=Oh(t,n);return r.anchor-i.anchor||r.rank-i.rank||r.originalAnchor-i.originalAnchor||e.key.localeCompare(t.key)})}function Ah(e){let t=e;return t.kind===`user`||t.kind===`steering`?t.data.seq:void 0}function jh(e){let t=e;if(t.kind===`context`)return{messageSeq:t.data.seq-1,labels:jm(t.data.source)}}function Mh(e,t){let n=e;if(n.kind!==`user`&&n.kind!==`steering`)return e;let r=n.data.referenceLabels??dh,i=Object.hasOwn(n.data,`referenceLabels`);if(hh(r,t)&&i===t.length>0)return e;let a={...n.data};return t.length===0?delete a.referenceLabels:a.referenceLabels=t,{...n,data:a}}var Nh=class{messagesBySeq=/* @__PURE__ */ new Map;labelsByMessageSeq=/* @__PURE__ */ new Map;replace(e){this.messagesBySeq.clear(),this.labelsByMessageSeq.clear();for(let t of e){let e=Ah(t);e!==void 0&&this.messagesBySeq.set(e,t.key);let n=jh(t);n!==void 0&&n.labels.length>0&&this.labelsByMessageSeq.set(n.messageSeq,n.labels)}return e.map(e=>{let t=Ah(e);return t===void 0?e:Mh(e,this.labelsByMessageSeq.get(t)??dh)})}apply(e,t){let n=new Map(e.map(e=>[e.key,e])),r=/* @__PURE__ */ new Set;for(let t of e){let e=Ah(t);e!==void 0&&(this.messagesBySeq.set(e,t.key),r.add(e));let n=jh(t);if(n===void 0)continue;let i=this.labelsByMessageSeq.get(n.messageSeq);n.labels.length===0?this.labelsByMessageSeq.delete(n.messageSeq):this.labelsByMessageSeq.set(n.messageSeq,i!==void 0&&hh(i,n.labels)?i:n.labels),r.add(n.messageSeq)}for(let e of r){let r=this.messagesBySeq.get(e);if(r===void 0)continue;let i=n.get(r)??t.get(r);i!==void 0&&n.set(r,Mh(i,this.labelsByMessageSeq.get(e)??dh))}return[...n.values()]}};function Ph(e,t){let n=e;if(n.kind!==`user`&&n.kind!==`steering`)return e;let r=n.data.skillNames??dh,i=Object.hasOwn(n.data,`skillNames`);if(hh(r,t)&&i===t.length>0)return e;let a={...n.data};return t.length===0?delete a.skillNames:a.skillNames=t,{...n,data:a}}function Fh(e){let t=e;if(t.kind===`user`||t.kind===`steering`)return{key:e.key,seq:e.anchorSeq,kind:`message`,name:null};if(t.kind===`context`){let n=Mm(t.data.source);return n===null?null:{key:e.key,seq:e.anchorSeq,kind:`skill`,name:n}}return{key:e.key,seq:e.anchorSeq,kind:`boundary`,name:null}}function Ih(e,t){return e.seq===t.seq&&e.kind===t.kind&&e.name===t.name}var Lh=class{entries=/* @__PURE__ */ new Map;sorted=[];replace(e){this.entries.clear(),this.sorted=[];for(let t of e){let e=Fh(t);e!==null&&(this.entries.set(e.key,e),this.sorted.push(e))}this.sorted.sort((e,t)=>e.seq-t.seq);let t=/* @__PURE__ */ new Map;for(let e=0;e<this.sorted.length;e++){if(this.sorted[e]?.kind===`boundary`)continue;let n=this.runEnd(e);this.assignRun(e,n,t),e=n}return e.map(e=>Ph(e,t.get(e.key)??dh))}apply(e,t){let n=[];for(let t of e){let e=Fh(t),r=this.entries.get(t.key);if(r!==void 0){if(e!==null&&Ih(r,e)){e.kind===`message`&&n.push(e.seq);continue}this.remove(r),n.push(r.seq)}e!==null&&(this.insert(e),n.push(e.seq))}if(n.length===0)return e;let r=/* @__PURE__ */ new Map;for(let e of n)this.collectAround(e,r);let i=new Map(e.map(e=>[e.key,e]));for(let[e,n]of r){let r=i.get(e)??t.get(e);if(r===void 0)continue;let a=Ph(r,n);(a!==r||i.has(e))&&i.set(e,a)}return[...i.values()]}insert(e){this.sorted.splice(this.lowerBound(e.seq),0,e),this.entries.set(e.key,e)}remove(e){this.sorted.splice(this.sorted.indexOf(e),1),this.entries.delete(e.key)}lowerBound(e){let t=0,n=this.sorted.length;for(;t<n;){let r=t+n>>>1;(this.sorted[r]?.seq??1/0)<e?t=r+1:n=r}return t}runEnd(e){let t=e;for(;t+1<this.sorted.length&&this.sorted[t+1]?.kind!==`boundary`;)t++;return t}runStart(e){let t=e;for(;t-1>=0&&this.sorted[t-1]?.kind!==`boundary`;)t--;return t}assignRun(e,t,n){let r=[];for(let n=e;n<=t;n++){let e=this.sorted[n];e?.kind===`skill`&&e.name!==null&&!r.includes(e.name)&&r.push(e.name)}for(let i=e;i<=t;i++){let e=this.sorted[i];e?.kind===`message`&&n.set(e.key,r)}}collectAround(e,t){let n=this.lowerBound(e),r=this.sorted[n];if(r!==void 0&&r.seq===e&&r.kind!==`boundary`){this.assignRun(this.runStart(n),this.runEnd(n),t);return}n-1>=0&&this.sorted[n-1]?.kind!==`boundary`&&this.assignRun(this.runStart(n-1),n-1,t);let i=r!==void 0&&r.seq===e?n+1:n;i<this.sorted.length&&this.sorted[i]?.kind!==`boundary`&&this.assignRun(i,this.runEnd(i),t)}};let Rh={anchorSeq:0,nodes:mh,partial:null,running:null};function zh(e){let t=e;if(e.visibility!==`visible`&&t.kind!==`assistant-step`)return Rh;switch(t.kind){case`user`:case`steering`:case`context`:case`command`:case`compaction`:case`turn-error`:case`turn-max-tokens`:case`unknown`:return{anchorSeq:t.anchorSeq,nodes:[t.data],partial:null,running:null};case`assistant-step`:{let n=t.data;return n.status===`running`?e.visibility===`visible`?{anchorSeq:t.anchorSeq,nodes:mh,partial:{turn:n.turn,step:n.step,blocks:n.blocks},running:null}:Rh:{anchorSeq:t.anchorSeq,nodes:n.finalNode===void 0?mh:[n.finalNode],partial:null,running:null}}case`tool-call`:{let e=t.data.root;return eh(e)?{anchorSeq:t.anchorSeq,nodes:mh,partial:null,running:e}:{anchorSeq:t.anchorSeq,nodes:[e],partial:null,running:null}}case`manual-compaction`:{let e=t.data;return{anchorSeq:t.anchorSeq,nodes:e.compaction===null?[e.command]:[e.command,e.compaction],partial:null,running:null}}case`model-retry`:return{anchorSeq:t.anchorSeq,nodes:t.data.attempts,partial:null,running:null};case`turn-tail`:case`system-prompt`:return Rh;default:return Rh}}function Bh(e,t){return e!==void 0&&e.anchorSeq===t.anchorSeq&&e.partial?.blocks===t.partial?.blocks&&e.partial?.turn===t.partial?.turn&&e.partial?.step===t.partial?.step&&e.running===t.running&&hh(e.nodes,t.nodes)}var Vh=class{contributions=/* @__PURE__ */ new Map;finalizedContributions=/* @__PURE__ */ new Map;runningContributions=/* @__PURE__ */ new Map;partialContributions=/* @__PURE__ */ new Map;finalized=mh;runningCalls=mh;partial=null;timeline;turnTimings=/* @__PURE__ */ new Map;turnEnds=/* @__PURE__ */ new Map;replace(e,t){this.contributions.clear(),this.finalizedContributions.clear(),this.runningContributions.clear(),this.partialContributions.clear();for(let t of e){let e=zh(t);this.contributions.set(t.key,e),this.indexContribution(t.key,e)}return this.rebuildFinalized(),this.rebuildRunning(),this.rebuildPartial(),this.updateTimeline(t),this.snapshot()}apply(e,t){let n=!1,r=!1,i=!1;for(let t of e){let e=zh(t),a=this.contributions.get(t.key);Bh(a,e)||(n||=Uh(a,e),r||=Wh(a,e),i||=Gh(a,e),this.contributions.set(t.key,e),this.indexContribution(t.key,e))}return n&&this.rebuildFinalized(),r&&this.rebuildRunning(),i&&this.rebuildPartial(),this.updateTimeline(t),this.snapshot()}indexContribution(e,t){Hh(this.finalizedContributions,e,t,t.nodes.length>0),Hh(this.runningContributions,e,t,t.running!==null),Hh(this.partialContributions,e,t,t.partial!==null)}rebuildFinalized(){let e=[...this.finalizedContributions.values()].flatMap(e=>e.nodes).sort((e,t)=>e.seq-t.seq);hh(this.finalized,e)||(this.finalized=e)}rebuildRunning(){let e=[...this.runningContributions.values()].sort((e,t)=>e.anchorSeq-t.anchorSeq).flatMap(e=>e.running===null?[]:[e.running]);hh(this.runningCalls,e)||(this.runningCalls=e)}rebuildPartial(){let e=[...this.partialContributions.values()].sort((e,t)=>e.anchorSeq-t.anchorSeq).findLast(e=>e.partial!==null)?.partial??null;(this.partial?.blocks!==e?.blocks||this.partial?.turn!==e?.turn||this.partial?.step!==e?.step)&&(this.partial=e)}updateTimeline(e){if(this.timeline===e)return;this.timeline=e;let t=/* @__PURE__ */ new Map,n=/* @__PURE__ */ new Map;for(let r of e.turns.values())r.start!==void 0&&t.set(r.turn,{startTime:r.start.time,...r.end===void 0?{}:{endTime:r.end.time}}),r.end!==void 0&&n.set(r.turn,r.end.seq);this.turnTimings=t,this.turnEnds=n}snapshot(){return{nodes:this.finalized,turnTimings:this.turnTimings,turnEnds:this.turnEnds,partial:this.partial,runningCalls:this.runningCalls}}};function Hh(e,t,n,r){r?e.set(t,n):e.delete(t)}function Uh(e,t){let n=e?.nodes??mh;return!hh(n,t.nodes)||(n.length>0||t.nodes.length>0)&&e?.anchorSeq!==t.anchorSeq}function Wh(e,t){return e?.running!==t.running||(e.running!==null||t.running!==null)&&e.anchorSeq!==t.anchorSeq}function Gh(e,t){return e?.partial?.blocks!==t.partial?.blocks||e?.partial?.turn!==t.partial?.turn||e?.partial?.step!==t.partial?.step||((e?.partial??null)!==null||t.partial!==null)&&e?.anchorSeq!==t.anchorSeq}var Kh=class{store=new yh;locations=new bh;navigation=new Sh;legacy=new Vh;referenceLabels=new Nh;skillNames=new Lh;order=dh;latestGroupInput;readGroupNode=e=>this.store.get(e);readGroupTurn=e=>this.locations.getTurn(e);readGroupPosition=e=>this.locations.getPosition(e);timeline=null;empty;constructor(){this.empty=this.snapshot({turnOrder:fh,turns:/* @__PURE__ */ new Map}),this.latestGroupInput={kind:`replace`,order:this.order,readNode:this.readGroupNode,readTurn:this.readGroupTurn,readPosition:this.readGroupPosition,timeline:this.empty.timeline}}replace(e){let t=this.skillNames.replace(this.referenceLabels.replace(e.nodes));return this.store.replace(t),this.order=kh(t).map(e=>e.key),this.locations.rebuild(this.order,this.store),this.store.replaceProcesses(this.order,this.locations),this.navigation.rebuild(e.timeline,this.locations,this.store),this.timeline=e.timeline,this.latestGroupInput={kind:`replace`,order:this.order,readNode:this.readGroupNode,readTurn:this.readGroupTurn,readPosition:this.readGroupPosition,timeline:e.timeline},this.snapshot(e.timeline,this.legacy.replace(t,e.timeline))}apply(e){let t=this.skillNames.apply(this.referenceLabels.apply(e.upserts,this.store),this.store),n=/* @__PURE__ */ new Set,r=!1,i=[],a=[];for(let e of t){let t=this.store.get(e.key);t!==e&&a.push({previous:t,current:e});let o=t===void 0||t.kind!==e.kind||t.anchorSeq!==e.anchorSeq||t.visibility!==e.visibility||Jh(t.location)!==Jh(e.location);if(r||=o,o||i.push(e),Eh(t,e,o)){let r=t===void 0?void 0:wh(t.location).turn,i=wh(e.location).turn;r!==void 0&&n.add(r),i!==void 0&&n.add(i)}}this.store.upsert(t);let o=fh;if(r){let e=kh(this.store.values()).map(e=>e.key);this.order=hh(this.order,e)?this.order:e,o=this.locations.rebuild(this.order,this.store)}return this.locations.touch(i),this.store.updateProcesses(n,this.locations),r||e.timeline!==this.timeline?this.navigation.rebuild(e.timeline,this.locations,this.store):this.navigation.touch(qh(i),this.locations,this.store),this.timeline=e.timeline,this.latestGroupInput={kind:`apply`,changes:a,order:this.order,readNode:this.readGroupNode,readTurn:this.readGroupTurn,readPosition:this.readGroupPosition,timeline:e.timeline,changedTurns:e.changedTurns??fh,changedTurnOrders:o},this.snapshot(e.timeline,this.legacy.apply(t,e.timeline))}groupInput(){return this.latestGroupInput}publish(){this.store.publish()}snapshot(e,t=this.legacy.replace(mh,e)){return{order:this.order,nodes:this.store,locations:this.locations,navigation:this.navigation,timeline:e,legacy:t}}};function qh(e){let t=/* @__PURE__ */ new Set;for(let n of e){let e=wh(n.location).turn;e!==void 0&&t.add(e)}return t}function Jh(e){let t=wh(e);return`${e.kind}:${t.turn??``}:${t.step??``}`}let Yh={target:`chat`,create:()=>new Kh,isActive:e=>e.order.some(t=>e.nodes.get(t)?.kind!==`command`)};function Xh(e){e.uiConversation.views.register(Yh)}let Zh=/* @__PURE__ */ new Set([`system/message`,`developer/message`,`user/message`,`assistant/message`,`tool/result`]);function Qh(e){return Zh.has(e.type)?e.surfaceOp!==void 0:!1}function $h(e){return Qh(e)&&e.surfaceOp===`append`}function eg(e){return Qh(e)&&e.surfaceOp!==`append`}function tg(e){if(e.event.type!==`command/run`)throw Error(`command start requires command/run`);let t=e.event.data;return{kind:`command`,seq:e.event.seq,time:e.event.time,commandId:t.commandId,name:t.name,args:t.args??null,outcome:null}}function ng(e,t){if(e.event.type!==`command/done`)throw Error(`command update requires command/done`);let n=e.event.data,r=n.kind===`success`&&n.sourceEventSeq!==void 0&&Number.isSafeInteger(n.sourceEventSeq)&&n.sourceEventSeq>=0?n.sourceEventSeq:void 0;return{kind:`command`,seq:t?.seq??e.event.seq,time:t?.time??e.event.time,commandId:n.commandId,name:t?.name??null,args:t?.args??null,outcome:{kind:n.kind,...n.text===void 0?{}:{text:n.text},...r===void 0?{}:{sourceEventSeq:r}}}}function rg(e){if(e.type!==`user/message`||!eg(e))return;let t=e.data.source;if(t.kind===`compact-checkpoint`&&typeof t.compactionId==`string`)return{compactionId:t.compactionId,...t.sourceCommandId===void 0?{}:{sourceCommandId:t.sourceCommandId}}}function ig(e,t){let n=null,r=null,i=null;if(e?.event.type===`compaction/summary`){let t=e.event.data;if(Array.isArray(t.summary)){let e=t.summary.map(e=>e.type===`text`?e.text:``).join(``);n=e.trim()===``?null:e}r=Array.isArray(t.shadowedSeqs)&&t.shadowedSeqs.every(e=>Number.isSafeInteger(e)&&e>=0)?t.shadowedSeqs.length:null,i=Number.isSafeInteger(t.shadowedTokenCount)&&t.shadowedTokenCount>=0?t.shadowedTokenCount:null}return{kind:`compaction`,seq:t.event.seq,time:t.event.time,summary:n,summaryEventSeq:e?.event.seq??null,shadowedItemCount:r,shadowedTokenCount:i}}function ag(e){let t=e.matches.find(e=>e.event.type===`command/done`),n=e.matches.find(e=>rg(e.event)!==void 0),r=e.matches.find(e=>e.event.type===`compaction/summary`);if(n===void 0)return t===void 0?void 0:{command:ng(t)};let i=rg(n.event);return i?.sourceCommandId===void 0?t===void 0?void 0:{command:ng(t)}:{command:t===void 0?{kind:`command`,seq:n.event.seq,time:n.event.time,commandId:i.sourceCommandId,name:`compact`,args:null,outcome:null}:{...ng(t),name:`compact`},checkpoint:n,...r===void 0?{}:{summary:r}}}function og(e,t){return t.event.type===`compaction/summary`?{...e,summary:t}:rg(t.event)===void 0?e:{...e,checkpoint:t}}let sg={kind:`command`,target:`chat`,match:e=>{if(e.type===`command/run`)return{id:String(e.data.commandId),role:`start`};if(e.type===`command/done`)return{id:String(e.data.commandId),role:`update`};let t=rg(e);return t?.sourceCommandId===void 0?(e.type===`compaction/start`||e.type===`compaction/summary`||e.type===`compaction/end`)&&e.data.sourceCommandId!==void 0?{id:String(e.data.sourceCommandId),role:`update`}:null:{id:String(t.sourceCommandId),role:`update`}},start:(e,t)=>({command:tg(t)}),update:(e,t)=>t.event.type===`command/done`?{...e.state,command:ng(t,e.state.command)}:og(e.state,t),buildViewNode:e=>{let t=e.state??ag(e);if(t===void 0)return null;if(t.command.name!==`compact`)return Cm(e,`command`,t.command.seq,t.command);let n=t.checkpoint===void 0?null:ig(t.summary,t.checkpoint),r={command:t.command,compaction:n};return Cm(e,`manual-compaction`,n?.seq??t.command.seq,r)}};function cg(e){e.uiConversation.events.register(sg)}function lg(e){let t=e.matches.find(e=>e.event.type===`compaction/summary`),n=e.matches.find(e=>rg(e.event)!==void 0);return{...t===void 0?{}:{summary:t},...n===void 0?{}:{checkpoint:n}}}let ug={kind:`compaction`,target:`chat`,match:e=>{let t=rg(e);if(t!==void 0&&t.sourceCommandId===void 0)return{id:t.compactionId,role:`update`};if(e.type===`compaction/start`||e.type===`compaction/summary`||e.type===`compaction/end`){if(e.data.sourceCommandId!==void 0)return null;let t=e.data.compactionId;return typeof t!=`string`||t===``?null:{id:t,role:e.type===`compaction/start`?`start`:`update`}}return null},start:()=>({}),update:(e,t)=>og(e.state,t),buildViewNode:e=>{let t=e.state??lg(e);if(t.checkpoint===void 0)return null;let n=ig(t.summary,t.checkpoint);return Cm(e,`compaction`,n.seq,n)}};function dg(e){e.uiConversation.events.register(ug)}let fg={kind:`unknown-surface`,target:`chat`,match:e=>e.type!==`assistant/live-chunk`&&$h(e)?{id:String(e.seq),role:`start`}:null,start:(e,t)=>({kind:`unknown`,seq:t.event.seq,time:t.event.time,type:t.event.type,data:t.event.data}),update:e=>e.state,buildViewNode:e=>e.state===void 0?null:Cm(e,`unknown`,e.state.seq,e.state)};function pg(e){e.uiConversation.events.registerFallback(fg)}let mg={kind:`snapshot`,ids:[]},hg=/* @__PURE__ */ new Set;function gg(e){let t=[],n=e;for(;n.kind===`splice`;)t.push(n),n=n.previous;let r=[...n.ids];for(let e of t.reverse())r.splice(e.start,e.removedCount,...e.inserted);return r}function _g(e,t){let n;for(let{id:r}of t)e.has(r)&&(n??=new Set(e),n.delete(r));return n??e}function vg(e,t,n){let r=e?.state.pending??mg,i=t.inserted,a=t.removedCount??0;if(a>0&&t.outcome!==`canceled`){let e=gg(r),o=e.splice(t.start,a,...i);return{pending:{kind:`snapshot`,ids:e},currentClaimed:new Set(o.map(e=>e.id)),claimSeq:n,claimedHuman:o.some(e=>e.source.kind===`user`)}}let o=_g(e?.state.currentClaimed??hg,i);return{pending:{kind:`splice`,previous:r,start:t.start,removedCount:a,inserted:i},currentClaimed:o,claimSeq:e?.state.claimSeq??-1,claimedHuman:e?.state.claimedHuman??!1}}function yg(e){let t=`inbox-${e}`;return{kind:t,match:t=>t.type===`agent/inbox/spliced`&&t.data.target===e?{id:String(t.seq),role:`start`}:null,start:(e,n,r)=>{if(n.event.type!==`agent/inbox/spliced`)throw Error(`inbox start requires agent/inbox/spliced`);return vg(r.previous(t),n.event.data,n.event.seq)},update:e=>e.state,publication:()=>`none`}}let bg=yg(`next-step`),xg=yg(`next-turn`);function Sg(e){e.uiConversation.events.register(bg),e.uiConversation.events.register(xg)}function Cg(e){return e.type!==`user/message`||!eg(e)?!1:e.data.source.kind===`compact-checkpoint`}function wg(e,t){return{kind:`context`,seq:e.seq,time:e.time,content:t.content,source:t.source,producer:Am(t.source),form:km(t.source)}}let Tg={kind:`input-message`,target:`chat`,match:e=>e.type===`user/message`&&$h(e)&&!Cg(e)?{id:String(e.data.id),role:`start`}:null,start:(e,t,n)=>{let r=t.event;if(r.type!==`user/message`)throw Error(`input-message start requires user/message`);if(r.data.source.kind!==`user`){let e=n.previous(`inbox-next-turn`)?.state,i=n.previous(`inbox-next-step`)?.state,a=t.location,o=a.kind===`step`?a.turn.start?.seq:void 0,s=a.kind===`step`&&a.step.step===1&&o!==void 0&&(i?.claimSeq??-1)>o&&(e?.claimSeq??-1)<o&&i?.claimedHuman===!1&&i.currentClaimed.has(String(r.data.id));return{...wg(r,r.data),waking:e?.currentClaimed.has(String(r.data.id))===!0||s}}return n.previous(`inbox-next-step`)?.state.currentClaimed.has(String(r.data.id))===!0?{kind:`steering`,messageId:r.data.id,seq:r.seq,time:r.time,content:r.data.content,source:r.data.source}:{kind:`user`,seq:r.seq,time:r.time,content:r.data.content,source:r.data.source}},update:e=>e.state,buildViewNode:e=>{if(e.state===void 0)return null;let t=e.state.kind===`context`&&e.start?.event.type===`user/message`&&e.state.waking===!0,n=e.state.kind===`user`||e.state.kind===`steering`?{...e.state,...Eg(e.state)}:e.state;return Cm(e,t?`turn-trigger`:e.state.kind,e.state.seq,n)}};function Eg(e){let t=Xl(e.content.flatMap(e=>e.type===`text`?[e.text]:[]).join(`
140
+ `));return t.length===0?{}:{responseAnnotations:t}}let Dg={...Tg,kind:`developer-message`,match:e=>e.type===`developer/message`?{id:String(e.data.message.id),role:`start`}:null,start:(e,t)=>{let n=t.event;if(n.type!==`developer/message`)throw Error(`developer-message start requires developer/message`);return wg(n,n.data.message)}};function Og(e){e.uiConversation.events.register(Tg),e.uiConversation.events.register(Dg)}function kg(e,t,n){return e.location.kind!==`step`||t===void 0&&!n||t?.turn===e.location.turn.turn&&t.step===e.location.step.step?e.event.seq:e.location.step.step===1?e.location.turn.start?.seq??e.location.step.start?.seq??e.event.seq:e.location.step.start?.seq??e.event.seq}function Ag(e,t,n,r){let i=e.current.get(`chat`);return i?.kind===`system-prompt`?i.anchorSeq:kg(t,n,r)}function jg(e){return{kind:`system-message`,target:`chat`,match:e=>e.type===`system/message`||`surfaceOp`in e&&e.surfaceOp!==`append`?{id:String(e.seq),role:`start`}:null,start:(t,n,r)=>{if(n.event.type===`assistant/live-chunk`)throw Error(`system-message requires a durable event`);return e(r.previous(`system-message`)?.state,n.event)},update:e=>e.state,buildViewNode:e=>{let t=e.state?.introduced;return t===void 0||t.text===``||e.start?.event.type!==`system/message`||e.start.event.surfaceOp!==`append`?null:Cm(e,`system-prompt`,t.update?t.seq:kg(e.start,void 0,!0),{text:t.text,...t.update?{update:!0}:{}})}}}function Mg(e){return{kind:`request-prompt`,target:`chat`,match:e=>e.type===`request/header`?{id:String(e.seq),role:`start`}:null,start:(t,n,r)=>{if(n.event.type!==`request/header`)throw Error(`request-prompt start requires request/header`);let i=r.previous(`request-prompt`)?.state,a=r.previous(`system-message`),o=a?.state.effective,s=n.location.kind===`step`?{turn:n.location.turn.turn,step:n.location.step.step}:{},c=e(i?.prompt,n.event,o),l=c.change?.kind,u=a?.matches[0]?.event,d=o!==void 0&&u?.type===`system/message`&&u.surfaceOp===`append`&&(o.update||i===void 0)&&o.turn===s.turn&&o.step===s.step;return{anchorSeq:Ag(t,n,i,n.event.data.reason===`initial`),showsPrompt:!d&&(i===void 0||n.event.data.reason!==`change`||n.event.data.startsSeries===!0||l===`system`||l===`system-and-tools`),...s,...c}},update:e=>e.state,buildViewNode:e=>{let t=e.state;if(t===void 0)return null;let n=e.current.get(`chat`),r=t.showsPrompt&&t.prompt.system!==``;return!r&&n?.kind!==`system-prompt`?null:Cm(e,`system-prompt`,t.anchorSeq,{text:t.prompt.system},{visibility:r?`visible`:`hidden`})}}}function Ng(e){e.uiConversation.events.register(jg((t,n)=>e.uiConversation.inspectSystemPrompt(t,n))),e.uiConversation.events.register(Mg((t,n,r)=>e.uiConversation.inspectRequestPrompt(t,n,r)))}function Pg(e){if(e.event.type===`llm/retry`)return{kind:`model-retry`,seq:e.event.seq,time:e.event.time,retryState:`scheduled`,...e.event.data}}function Fg(e){return e.kind===`step`&&e.step.status===`closed`||(e.kind===`step`||e.kind===`turn`)&&e.turn.status===`closed`}let Ig={kind:`model-retry`,target:`chat`,match:e=>{if(e.type===`llm/retry`){let t=e.data.retryId;return typeof t!=`string`||t===``?null:{id:t,role:e.data.retry===1?`start`:`update`}}if(e.type===`llm/retry-started`){let t=e.data.retryId;return typeof t==`string`&&t!==``?{id:t,role:`update`}:null}return null},start:(e,t)=>{let n=Pg(t);if(n===void 0)throw Error(`model-retry start requires a valid llm/retry event`);return{turn:n.turn,step:n.step,attempts:[n]}},update:(e,t)=>{if(t.event.type===`llm/retry`){let n=Pg(t);return n===void 0?e.state:{...e.state,attempts:[...e.state.attempts,n]}}if(t.event.type!==`llm/retry-started`)return e.state;let n=t.event.data.retry;return{...e.state,attempts:e.state.attempts.map(e=>e.retry===n?{...e,retryState:`started`}:e)}},buildViewNode:e=>{if(e.state===void 0||e.state.attempts.length===0)return null;let t=e.start?.location??e.matches[0]?.location??{kind:`unresolved`},n=e.state.attempts,r=n.map((e,r)=>r===n.length-1&&e.retryState===`scheduled`&&Fg(t)?{...e,retryState:`cancelled`}:e),i=r.at(-1);if(i===void 0)return null;let a={attempts:r,current:i};return Cm(e,`model-retry`,r[0]?.seq??i.seq,a)}};function Lg(e){e.uiConversation.events.register(Ig)}let Rg=/* @__PURE__ */ new WeakMap;function zg(e){return JSON.stringify(e)}function Bg(e,t){if(e.event.type!==`tool/call`)throw Error(`tool-call start requires tool/call`);return{phase:`start`,callId:String(e.event.data.callId),name:e.event.data.name,argsRaw:e.event.data.arguments,args:t===void 0?Gd.fromText(e.event.data.arguments):t.args.settle(e.event.data.arguments),turn:e.event.data.turn,step:e.event.data.step,time:e.event.time,subCalls:[]}}function Vg(e,t){let n=t.event;if(n.type!==`assistant/live-chunk`)return e;let r=n.data.chunk,i=e.root;if(r.type===`block-end`&&r.block.type===`tool-call`)return i===void 0||`kind`in i||i.phase!==`preparing`?e:{...e,root:{...i,name:r.block.name,args:i.args.settle(r.block.arguments)}};if(r.type!==`tool-call-delta`)return e;if(i===void 0){if(!r.name)return e;let t=new Gd;return t.append(r.argumentsDelta),{...e,root:{phase:`preparing`,callId:String(r.id),name:r.name,turn:n.data.turn,step:n.data.step,time:n.time,subCalls:[],args:t}}}return`kind`in i||i.phase!==`preparing`||i.args.isSealed||i.args.append(r.argumentsDelta),e}function Hg(e,t){let n=e.args.refresh();return!n&&t!==void 0&&!(`kind`in t)&&t.phase===`preparing`&&t.name===e.name&&t.args===e.args?t:n?{...e}:e}function Ug(e,t){if(e.event.type!==`tool/result`)return;let n=e.event.data.message;return{kind:`tool-result`,seq:e.event.seq,time:e.event.time,callId:String(n.source.callId),name:t?.name??``,args:t?.args??Gd.EMPTY,call:t===void 0?null:{name:t.name,argsRaw:t.argsRaw},callTime:t?.time??null,content:n.content,isError:n.isError===!0,...e.event.data.error===void 0?{}:{error:e.event.data.error},meta:e.event.data.meta,subCalls:[]}}function Wg(e,t){return{phase:`start`,callId:t.subCallId,parentCallId:t.parentCallId,name:t.name,argsRaw:zg(t.arguments),args:Gd.fromObject(t.arguments),turn:Kg(e),step:qg(e),time:e.event.time,subCalls:[]}}function Gg(e,t,n){return{kind:`tool-result`,seq:e.event.seq,time:e.event.time,callId:t.subCallId,parentCallId:t.parentCallId,name:t.name,args:n!==void 0&&!(`kind`in n)?n.args:Gd.fromObject(t.arguments),call:{name:t.name,argsRaw:zg(t.arguments)},callTime:n?.time??null,content:t.content??[],isError:t.isError===!0,...t.error===void 0?{}:{error:t.error},subCalls:[]}}function Kg(e){return e.location.kind===`step`||e.location.kind===`turn`?e.location.turn.turn:0}function qg(e){return e.location.kind===`step`?e.location.step.step:0}function Jg(e,t,n){if(t===n||e.parents.has(n))return!1;let r=t,i=0,a=/* @__PURE__ */ new Set;for(;r!==void 0;){if(r===n||a.has(r))return!1;a.add(r),i++,r=e.parents.get(r)}let o=[{callId:n,depth:1}],s=/* @__PURE__ */ new Set,c=0;for(let t of o){if(s.has(t.callId))return!1;s.add(t.callId),c=Math.max(c,t.depth);for(let n of e.children.get(t.callId)??[])o.push({callId:n.callId,depth:t.depth+1})}return i+c<=256}function Yg(e,t){let n=t.event;if(n.type!==`tool/ptc-dispatch-start`&&n.type!==`tool/ptc-dispatch`)return e;let r=n.data,i=String(r.parentCallId),a=String(r.subCallId),o=e.children.get(i)??[],s=o.findIndex(e=>e.callId===a);if(n.type===`tool/ptc-dispatch-start`){if(s>=0||!Jg(e,i,a))return e;let n=new Map(e.children);n.set(i,[...o,Wg(t,r)]);let c=new Map(e.parents);return c.set(a,i),{...e,children:n,parents:c}}if(s<0&&!Jg(e,i,a))return e;let c=Gg(t,r,s<0?void 0:o[s]),l=new Map(e.children);l.set(i,s<0?[...o,c]:o.map((e,t)=>t===s?c:e));let u=new Map(e.parents);return s<0&&u.set(a,i),{...e,children:l,parents:u}}function Xg(e,t,n,r=/* @__PURE__ */ new Set,i=1){if(!(`kind`in e)&&e.phase===`preparing`)return e;if(r.has(e.callId)||i>256)return{...e,subCalls:[]};let a=new Set(r);a.add(e.callId);let o=(t.children.get(e.callId)??e.subCalls).map(e=>Xg(e,t,n,a,i+1)),s=`kind`in e?void 0:n?.seq,c=`kind`in e?void 0:n?.time,l=Rg.get(e);if(l!==void 0&&l.interruptionSeq===s&&l.interruptionTime===c&&Zg(l.children,o))return l.value;let u=`kind`in e||n===void 0?Zg(e.subCalls,o)?e:{...e,subCalls:o}:{kind:`tool-result`,seq:n.seq+xm.interruptedFollowup,time:n.time,callId:e.callId,...e.parentCallId===void 0?{}:{parentCallId:e.parentCallId},name:e.name,args:e.args,call:{name:e.name,argsRaw:e.argsRaw},callTime:e.time,content:[],isError:!0,error:{name:`Interrupted`,code:`interrupted`},subCalls:o};return Rg.set(e,{children:o,interruptionSeq:s,interruptionTime:c,value:u}),u}function Zg(e,t){return e.length===t.length&&e.every((e,n)=>e===t[n])}function Qg(e){let t=e.start?.location;if(t?.kind===`step`&&t.step.status===`closed`)return t.step.end;if((t?.kind===`step`||t?.kind===`turn`)&&t.turn.status===`closed`)return t.turn.end}function $g(e){let t=e.matches.find(e=>e.event.type===`tool/result`),n=t===void 0?void 0:Ug(t);if(n===void 0)return;let r={root:n,children:/* @__PURE__ */ new Map,parents:/* @__PURE__ */ new Map};for(let t of e.matches)r=Yg(r,t);return r}let e_={kind:`tool-call`,target:`chat`,match:e=>{if(e.type===`assistant/live-chunk`){let t=e.data.chunk;return t.type===`block-end`&&t.block.type===`tool-call`?{id:String(t.block.id),role:`start`}:t.type===`tool-call-delta`?{id:String(t.id),role:`start`}:null}if(e.type===`tool/call`)return{id:String(e.data.callId),role:`start`};if(e.type===`tool/result`&&$h(e))return{id:String(e.data.message.source.callId),role:`update`};if(e.type===`tool/ptc-dispatch-start`||e.type===`tool/ptc-dispatch`){let t=e.data.rootCallId;return typeof t==`string`&&t!==``?{id:t,role:`update`}:null}return null},start:(e,t)=>{let n={root:void 0,children:/* @__PURE__ */ new Map,parents:/* @__PURE__ */ new Map};return t.event.type===`tool/call`?{...n,root:Bg(t)}:Vg(n,t)},update:(e,t)=>{if(t.event.type===`assistant/live-chunk`)return Vg(e.state,t);if(t.event.type===`tool/call`)return{...e.state,root:Bg(t,e.state.root)};if(t.event.type===`tool/result`){let n=e.state.root,r=Ug(t,n!==void 0&&!(`kind`in n)&&n.phase===`start`?n:void 0);return r===void 0?e.state:{...e.state,root:r}}return Yg(e.state,t)},publication:e=>e.event.type===`assistant/live-chunk`?`animation-frame`:`immediate`,buildViewNode:e=>{let t=e.current.get(`chat`),n=e.state??$g(e);if(n?.root===void 0)return t==null?null:t.visibility===`hidden`?t:{...t,visibility:`hidden`};let r=Qg(e),i=Xg(!(`kind`in n.root)&&n.root.phase===`preparing`?Hg(n.root,t?.data.root):n.root,n,r),a=e.start?.event.seq??(`kind`in n.root?n.root.seq:e.matches[0]?.event.seq??0),o=!(`kind`in i)&&i.phase===`preparing`&&r!==void 0?`hidden`:`visible`,s=Sm(e),c=Dd(i.name)&&s.kind===`step`?{kind:`turn`,turn:s.turn}:s,l=t?.data.root===i?t.data:{root:i};return t?.data===l&&t.anchorSeq===a&&t.visibility===o&&t.location===c?t:Cm(e,`tool-call`,a,l,{visibility:o,location:c})}};function t_(e){let t=e_.match.bind(e_);e.uiConversation.events.register({...e_,match:{"assistant/live-chunk":t,"tool/call":t,"tool/result":t,"tool/ptc-dispatch-start":t,"tool/ptc-dispatch":t}})}function n_(e){let t=e.start?.location??e.matches[0]?.location;return t?.kind!==`turn`&&t?.kind!==`step`?0:t.turn.steps.at(-1)?.step??0}function r_(e){if(e.event.type!==`turn/end`)return;let t=e.event.data.reason,n=t.kind===`error`?t.error:t.kind===`aborted`&&t.reason.kind===`hook`&&t.reason.reason===`deepseek-account/signed-out`?{message:`Stopped because you signed out of DeepSeek.`,code:`ACCOUNT_SIGNED_OUT`}:void 0;if(n===void 0)return;let r=Im(n);return{seq:e.event.seq,time:e.event.time,message:r.message,...r.code===void 0?{}:{code:r.code}}}function i_(e){let t=e.matches.find(e=>r_(e)!==void 0);if(t?.event.type!==`turn/end`)return;let n=r_(t);if(n!==void 0)return{turn:t.event.data.turn,failure:n}}let a_={kind:`turn-error`,target:`chat`,match:e=>e.type===`turn/start`?{id:String(e.data.turn),role:`start`}:e.type===`turn/end`&&(e.data.reason.kind===`error`||e.data.reason.kind===`aborted`&&e.data.reason.reason.kind===`hook`&&e.data.reason.reason.reason===`deepseek-account/signed-out`)?{id:String(e.data.turn),role:`update`}:null,start:(e,t)=>{if(t.event.type!==`turn/start`)throw Error(`turn-error start requires turn/start`);return{turn:t.event.data.turn}},update:(e,t)=>{let n=r_(t);return n===void 0?e.state:{...e.state,failure:n}},buildViewNode:e=>{let t=e.state??i_(e);if(t?.failure===void 0)return null;let n=t.failure,r={kind:`turn-error`,seq:n.seq,time:n.time,turn:t.turn,step:n_(e),message:n.message,...n.code===void 0?{}:{code:n.code}};return Cm(e,`turn-error`,r.seq,r)}};function o_(e){e.uiConversation.events.register(a_)}function s_(e){let t=e.start?.location??e.matches[0]?.location;return t?.kind!==`turn`&&t?.kind!==`step`?0:t.turn.steps.at(-1)?.step??0}function c_(e,t){let n=e.start?.location??e.matches[0]?.location;if(n?.kind!==`turn`&&n?.kind!==`step`)return t;let r=n.turn.data.get(`turn-tail`)?.closing;return r==null?t:r.finalNode.seq+xm.maxTokensNotice}function l_(e){if(e.event.type===`turn/end`&&e.event.data.reason.kind===`max-tokens`)return{turn:e.event.data.turn,seq:e.event.seq,time:e.event.time}}let u_={kind:`turn-max-tokens`,target:`chat`,match:e=>e.type===`turn/end`&&e.data.reason.kind===`max-tokens`?{id:String(e.data.turn),role:`start`}:null,start:(e,t)=>{let n=l_(t);if(n===void 0)throw Error(`turn-max-tokens start requires a max-tokens turn/end`);return n},update:e=>e.state,buildViewNode:e=>{let t=e.state;if(t===void 0)return null;let n={kind:`turn-max-tokens`,seq:t.seq,time:t.time,turn:t.turn,step:s_(e)};return Cm(e,`turn-max-tokens`,c_(e,t.seq),n)}};function d_(e){e.uiConversation.events.register(u_)}function f_(e){let t=e.data;return typeof t.turn==`number`?t.turn:void 0}function p_(e){if(e.type===`text-delta`||e.type===`reasoning-delta`)return e.text.trim()!==``;if(e.type===`block-start`)return e.blockType!==`text`&&e.blockType!==`reasoning`&&e.blockType!==`tool-call`;if(e.type!==`block-end`)return!1;let t=e.block;return t.type===`tool-call`?!1:t.type===`text`||t.type===`reasoning`?t.text.trim()!==``:!0}function m_(e){return e.type===`assistant/live-chunk`?p_(e.data.chunk):e.type!==`assistant/attempt`&&e.type===`assistant/message`&&e.surfaceOp===`append`&&Nm(e.data.message.content).some(e=>e.kind===`tool-call`?!1:e.kind===`text`||e.kind===`reasoning`?e.text.trim()!==``:!0)}function h_(e,t){return e.type===`tool/call`?Dd(e.data.name):e.type===`tool/result`&&t.has(String(e.data.message.source.callId))}function g_(e,t){if(m_(e))return e.type!==`assistant/live-chunk`&&e.type!==`assistant/message`&&e.type!==`assistant/attempt`?void 0:{kind:`assistant`,seq:e.seq,step:e.data.step};if(!h_(e,t)&&(e.type===`tool/call`||e.type===`tool/result`&&e.surfaceOp===`append`||e.type===`llm/retry`))return{kind:`other`,seq:e.seq}}function __(e){let t=e.start?.location??e.matches.at(-1)?.location;return t?.kind===`turn`||t?.kind===`step`?t.turn:void 0}function v_(e){let t=e.matches.map(e=>f_(e.event)).find(e=>e!==void 0);if(t===void 0)return;let n={turn:t,assistantStartByStep:/* @__PURE__ */ new Map,messageCountByStep:/* @__PURE__ */ new Map,messageCount:0,toolCallCount:0,subagentCount:0,contextCompactionCalls:/* @__PURE__ */ new Set};for(let t of e.matches)n=S_(n,t.event);return n}function y_(e){return e?.finalNode!==void 0}function b_(e){let t=e.end?.data.finalAssistantStep;if(t===null)return null;let n=(t===void 0?e.steps.at(-1):e.steps.find(e=>e.step===t))?.data.get(`assistant-step`);return!y_(n)||n.finalNode.interrupted===!0||!cm(n.blocks)||t===void 0&&n.blocks.some(e=>e.kind===`tool-call`)?null:n}function x_(e,t){let n=e.controlAnchorSeq??t.start?.seq;if(n===void 0)return null;let r=b_(t),i={messageCount:r===null?e.messageCount:[...e.messageCountByStep].filter(([e])=>e!==r.step).reduce((e,[,t])=>e+t,0),toolCallCount:e.toolCallCount,subagentCount:e.subagentCount};if(r===null)return{turn:t.turn,controlAnchorSeq:n,processStartSeq:n,answerAnchorSeq:null,answerStep:null,inlineReasoning:!1,...i};let a=r.blocks.some(e=>e.kind===`reasoning`&&e.text.trim()!==``),o=Math.min(...[...e.assistantStartByStep].filter(([e])=>e<r.step).map(([,e])=>e)),s=Math.min(e.otherStartSeq??1/0,o);return{turn:t.turn,controlAnchorSeq:n,processStartSeq:t.start?.seq??(Number.isFinite(s)?s:r.finalNode.seq),answerAnchorSeq:r.finalNode.seq,answerStep:r.step,inlineReasoning:a,...i}}function S_(e,t){let n=e;if(t.type===`assistant/message`&&t.surfaceOp===`append`&&cm(Nm(t.data.message.content))){let e=new Map(n.messageCountByStep);e.set(t.data.step,(e.get(t.data.step)??0)+1),n={...n,messageCountByStep:e,messageCount:n.messageCount+1}}if(t.type===`tool/call`){if(Dd(t.data.name)){let e=new Set(n.contextCompactionCalls);e.add(String(t.data.callId)),n={...n,contextCompactionCalls:e}}else{let e=Ed(t.data.name);n={...n,toolCallCount:n.toolCallCount+ +!e,subagentCount:n.subagentCount+ +!!e}}}let r=g_(t,n.contextCompactionCalls);if(r===void 0)return n;if(r.kind===`other`)return n.otherStartSeq===void 0?{...n,otherStartSeq:r.seq,controlAnchorSeq:Math.min(n.controlAnchorSeq??1/0,r.seq)}:n;if(n.assistantStartByStep.has(r.step))return n;let i=new Map(n.assistantStartByStep);return i.set(r.step,r.seq),{...n,assistantStartByStep:i,controlAnchorSeq:Math.min(n.controlAnchorSeq??1/0,r.seq)}}let C_={kind:`turn-process`,target:`chat`,match:e=>{if(e.type===`turn/start`)return{id:String(e.data.turn),role:`start`};let t=f_(e);return t===void 0?null:e.type===`assistant/live-chunk`||e.type===`assistant/message`||e.type===`tool/call`||e.type===`tool/result`||e.type===`llm/retry`||e.type===`step/start`||e.type===`step/end`||e.type===`turn/end`?{id:String(t),role:`update`}:null},start:(e,t)=>{if(t.event.type!==`turn/start`)throw Error(`turn-process start requires turn/start`);return{turn:t.event.data.turn,assistantStartByStep:/* @__PURE__ */ new Map,messageCountByStep:/* @__PURE__ */ new Map,messageCount:0,toolCallCount:0,subagentCount:0,contextCompactionCalls:/* @__PURE__ */ new Set}},update:(e,t)=>S_(e.state,t.event),publication:e=>{if(e.event.type===`assistant/live-chunk`){let t=e.event.data.chunk.type;return t===`usage`||t===`finish`?`none`:`animation-frame`}return`immediate`},buildLocationData:(e,t,n)=>{if(t!==`turn`)return null;let r=e.state??v_(e);if(r===void 0)return null;let i=__(e);if(i===void 0)return null;let a=e.current.get(`chat`),o=i.steps.at(-1);if(n?.kind===`turn`&&n.key===`turn-process`&&a?.kind===`turn-process`&&a.data.answerAnchorSeq===null&&a.data.controlAnchorSeq===r.controlAnchorSeq&&a.data.messageCount===r.messageCount&&a.data.toolCallCount===r.toolCallCount&&a.data.subagentCount===r.subagentCount&&i.status!==`closed`&&o?.status!==`closed`)return n;let s=x_(r,i);return s===null?null:n?.kind===`turn`&&n.turn===s.turn&&n.key===`turn-process`&&Td(n.value,s)?n:{kind:`turn`,turn:i.turn,key:`turn-process`,value:s}},buildViewNode:e=>{let t=__(e),n=t?.data.get(`turn-process`);if(t===void 0||n===void 0)return null;let r=e.current.get(`chat`),i=e.state;return r?.kind===`turn-process`&&i!==void 0&&r.data.answerAnchorSeq===null&&r.data.controlAnchorSeq===i.controlAnchorSeq&&r.data.messageCount===i.messageCount&&r.data.toolCallCount===i.toolCallCount&&r.data.subagentCount===i.subagentCount&&t.status!==`closed`&&t.steps.at(-1)?.status!==`closed`&&r.location===(e.start?.location??e.matches[0]?.location)?r:Cm(e,`turn-process`,n.controlAnchorSeq+xm.processControl,n)}};function w_(e){let t=C_.match.bind(C_);e.uiConversation.events.register({...C_,match:{"turn/start":t,"assistant/live-chunk":t,"assistant/message":t,"tool/call":t,"tool/result":t,"llm/retry":t,"step/start":t,"step/end":t,"turn/end":t}})}function T_(e,t){for(let n=e.length-1;n>=0;--n){let r=e[n];if(r.type===`chunk`&&r.chunk.type===t)return r.chunk}}function E_(e){return typeof e==`number`&&Number.isSafeInteger(e)&&e>=0}function D_(e){let t=0;for(let n of e)if(t+=n,!Number.isSafeInteger(t))return;return t}function O_(e){let{provider:t,model:n}=e.source;return t.length>0&&n.length>0?{provider:t,model:n}:void 0}function k_(e){return T_(e,`usage`)?.usage}function A_(e,t){let{inputTokens:n,outputTokens:r,cacheReadTokens:i,cacheWriteTokens:a,reasoningTokens:o,totalTokens:s}=e;if(!E_(n)||!E_(r)||i!==void 0&&!E_(i)||a!==void 0&&!E_(a)||o!==void 0&&(!E_(o)||o>r))return;let c=D_([n,...i===void 0?[]:[i],...a===void 0?[]:[a]]);if(c===void 0)return;let l;if(s!==void 0){if(!E_(s))return;let e=s-r;if(!E_(e)||e<c||i!==void 0&&a!==void 0&&e!==c)return;l=s}else{if(i===void 0||a===void 0)return;let e=D_([c,r]);if(e===void 0)return;l=e}return{inputTokens:n,outputTokens:r,totalTokens:l,...i===void 0?{}:{cacheReadTokens:i},...a===void 0?{}:{cacheWriteTokens:a},...o===void 0?{}:{reasoningTokens:o},...t===void 0?{}:{route:t}}}function j_(e){if(e.length===0)return;let t=D_(e.map(e=>e.inputTokens)),n=D_(e.map(e=>e.outputTokens)),r=D_(e.map(e=>e.totalTokens));if(t===void 0||n===void 0||r===void 0)return;let i=e.map(e=>e.cacheReadTokens),a=e.map(e=>e.cacheWriteTokens),o=e.map(e=>e.reasoningTokens),s=i.every(E_)?D_(i):void 0,c=a.every(E_)?D_(a):void 0,l=o.every(E_)?D_(o):void 0,u,d=e.map(e=>e.route);if(d.every(e=>e!==void 0)){let e=/* @__PURE__ */ new Map;for(let t of d)e.set(`${t.provider}\0${t.model}`,t);u=[...e.values()]}return{uncachedInputTokens:t,outputTokens:n,totalTokens:r,...s===void 0?{}:{cacheReadTokens:s},...c===void 0?{}:{cacheWriteTokens:c},...l===void 0?{}:{reasoningTokens:l},...u===void 0?{}:{routes:u}}}function M_(e,t,n){return e.turn===t&&e.step===n}function N_(e){let t={kind:`idle`},n=[],r,i=!1,a=!1,o=e=>{if(t.kind!==`open`||t.sample===void 0)return!1;let r=A_(t.sample,e);return r!==void 0&&(n.push(r),!0)};for(let n of e){if(a)break;if(n.type===`turn/start`)r!==void 0||t.kind!==`idle`?a=!0:r=n.data.turn;else{if(r===void 0){a=!0;break}if(n.type===`turn/end`)n.data.turn!==r||t.kind!==`idle`||i?a=!0:i=!0;else{if(i){a=!0;break}if(n.type===`step/start`)n.data.turn!==r||t.kind!==`idle`?a=!0:t={kind:`open`,turn:r,step:n.data.step};else if(n.type===`llm/retry-started`)n.data.turn!==r||t.kind!==`settled`||t.by!==`retry`||!M_(t,n.data.turn,n.data.step)?a=!0:t={kind:`open`,turn:r,step:n.data.step};else if(n.type===`assistant/attempt`){if(n.data.turn!==r||t.kind!==`open`||!M_(t,n.data.turn,n.data.step)){a=!0;continue}let e=k_(n.data.stream)??t.sample;t={kind:`open`,turn:r,step:n.data.step,...e===void 0?{}:{sample:e}},o()?t={kind:`finishClosed`,turn:r,step:n.data.step}:a=!0}else if(n.type===`assistant/message`){if(n.data.turn!==r||t.kind!==`open`||!M_(t,n.data.turn,n.data.step)){a=!0;continue}let e=n.data.usage??k_(n.data.stream);e!==void 0&&(t={...t,sample:e}),o(O_(n.data.message))?t={kind:`settled`,turn:r,step:n.data.step,by:`message`}:a=!0}else if(n.type===`llm/retry`){if(n.data.turn!==r||t.kind===`idle`||!M_(t,n.data.turn,n.data.step)){a=!0;continue}(t.kind===`settled`||t.kind===`open`&&!o())&&(a=!0),a||(t={kind:`settled`,turn:r,step:n.data.step,by:`retry`})}else if(n.type===`step/end`){if(n.data.turn!==r||t.kind===`idle`||!M_(t,n.data.turn,n.data.step)){a=!0;continue}t.kind===`open`&&!o()&&(a=!0),a||(t={kind:`idle`})}}}}return a||!i||t.kind!==`idle`?void 0:j_(n)}function P_(e){return e.type!==`assistant/live-chunk`}function F_(e){if(e.type===`assistant/message`||e.type===`assistant/attempt`||e.type===`assistant/live-chunk`||e.type===`step/start`||e.type===`step/end`||e.type===`llm/retry`||e.type===`llm/retry-started`)return{turn:e.data.turn,step:e.data.step}}function I_(e){let t=e.start?.location??e.matches[0]?.location;return t?.kind===`turn`||t?.kind===`step`?t.turn:void 0}function L_(e){return e.finalNode!==void 0&&e.blocks.some(e=>e.kind===`text`&&e.text.trim()!==``)}function R_(e){let t=e.state===void 0?e.matches.find(e=>e.event.type===`turn/end`):e.state.end;if(t?.event.type!==`turn/end`)return null;let n=I_(e);if(n===void 0)return null;let r=n.steps.map(e=>e.data.get(`assistant-step`)).filter(e=>e!==void 0).filter(e=>e.finalNode!==void 0).sort((e,t)=>e.finalNode.seq-t.finalNode.seq),i=r.findLast(L_)??null,a=r.at(-1)?.finalNode.seq;for(let t of e.matches){let e=t.event,n=e.type===`tool/call`||e.type===`tool/result`&&e.surfaceOp===`append`||e.type===`turn/end`&&e.data.reason.kind===`error`||e.type===`llm/retry`?e.seq:void 0;n!==void 0&&(a===void 0||n>a)&&(a=n)}let o=e.start?.event.type===`turn/start`?N_(e.matches.map(e=>e.event).filter(P_)):void 0;return{turn:t.event.data.turn,seq:t.event.seq,time:t.event.time,closing:i,branchUnavailable:i===null||a!==i.finalNode.seq,...o===void 0?{}:{tokenUsage:o}}}let z_={kind:`turn-tail`,target:`chat`,match:e=>{if(e.type===`turn/start`)return{id:String(e.data.turn),role:`start`};if(e.type===`turn/end`||e.type===`tool/call`||e.type===`tool/result`)return{id:String(e.data.turn),role:`update`};let t=F_(e);return t===void 0?null:{id:String(t.turn),role:`update`}},start:(e,t)=>{if(t.event.type!==`turn/start`)throw Error(`turn-tail start requires turn/start`);return{turn:t.event.data.turn}},update:(e,t)=>t.event.type===`turn/end`?{...e.state,end:t}:e.state,publication:e=>e.event.type===`turn/end`?`immediate`:`none`,buildLocationData:(e,t)=>{if(t!==`turn`)return null;let n=R_(e);return n===null?null:{kind:`turn`,turn:n.turn,key:`turn-tail`,value:n}},buildViewNode:e=>{let t=I_(e)?.data.get(`turn-tail`);return t===void 0?null:Cm(e,`turn-tail`,t.seq+xm.finalizedFollowup,t)}};function B_(e){let t=z_.match.bind(z_);e.uiConversation.events.register({...z_,match:{"turn/start":t,"turn/end":t,"tool/call":t,"tool/result":t,"assistant/message":t,"assistant/attempt":t,"assistant/live-chunk":t,"step/start":t,"step/end":t,"llm/retry":t,"llm/retry-started":t}})}function V_(e){return e===`read`?`read`:e===`read_image`?`readImage`:e===`grep`||e===`glob`||e.endsWith(`_inspect`)?`search`:e===`write`?`write`:e===`edit`||e===`apply_patch`?`edit`:[`bash`,`pwsh`,`exec_command`,`write_stdin`].includes(e)||e.startsWith(`terminal_`)?`commands`:e===`run_code`?`code`:e===`web_search`?`webSearch`:e===`web_fetch`?`webFetch`:e===`subagent`||e.startsWith(`subagent_`)?`subagents`:[`todo_write`,`create_goal`,`update_goal`,`get_goal`].includes(e)?`plan`:e===`ask_user_question`||e===`request_user_input`?`questions`:`tools`}let H_=new Intl.Segmenter(void 0,{granularity:`grapheme`}),U_=[`title`,`description`,`objective`,`task`,`task_name`,`name`,`question`,`questions`,`prompt`,`message`,`command`,`cmd`,`queries`,`query`,`pattern`,`url`,`uri`,`file_path`,`path`,`target`,`action`,`status`];function W_(e){let t=e.replace(/\s+/g,` `).trim();if(t.length<=160)return{text:t,truncated:!1};let n=[];for(let{segment:e}of H_.segment(t)){if(n.length===160)return{text:`${n.slice(0,159).join(``).trimEnd()}…`,truncated:!0};n.push(e)}return{text:t,truncated:!1}}function G_(e){return W_(typeof e==`string`?e:Array.isArray(e)&&e.every(e=>typeof e==`string`)?e.join(`, `):``).text}function K_(e,t){let n=512;for(;;){let r=e.textPrefix(t,n);if(r===void 0)return;let i=r.charCodeAt(r.length-1);if(i>=55296&&i<=56319){let i=e.textPrefix(t,n+1),a=i.charCodeAt(r.length);a>=56320&&a<=57343?(r=i,n++):i.length===r.length&&!e.isSealed&&!e.complete(t)&&(r=r.slice(0,-1))}let a=W_(r);if(a.truncated||!e.stringExceeds(t,n))return a.text;n*=2}}function q_(e){if(!Array.isArray(e))return``;for(let t of e){if(typeof t!=`object`||!t)continue;let e=G_(Reflect.get(t,`question`));if(e!==``)return e}return``}function J_(e){for(let t=e.length-1;t>=0;t--){let n=e[t];if(n?.kind===`assistant-step`&&n.data.status===`running`)for(let e=n.data.blocks.length-1;e>=0;e--){let t=n.data.blocks[e];if(t?.kind!==`reasoning`)continue;let r=t.text.split(/\r?\n[\t ]*\r?\n/);for(let e=r.length-1;e>=0;e--){let t=G_(r[e]?.replaceAll(`**`,``));if(t!==``)return t}}}return``}function Y_(e,t){for(let e of U_){if(!t.has(e))continue;let n=e===`questions`?q_(t.value(e)):K_(t,e)??G_(t.value(e));if(n!==``)return n}return t.closed()?G_(e):``}function X_(e){let t=/* @__PURE__ */ new Map,n=/* @__PURE__ */ new Set,r,i=``,a=-1/0,o,s=e=>{if(n.has(e.callId))return;n.add(e.callId);let c=eh(e)?e:e.call;if(c!==null){let n=V_(c.name);eh(e)&&e.time>=a&&(r=n,o=e.phase===`preparing`,i=Y_(e.name,e.args),a=e.time),t.set(n,(t.get(n)??0)+1)}for(let t of e.subCalls)s(t)};for(let t of e)t.kind===`tool-call`&&s(t.data.root);return r===void 0&&(i=J_(e)),{counts:[...t].map(([e,t])=>({kind:e,count:t})).sort((e,t)=>t.count-e.count),running:r,runningDetail:i,...o?{preparing:!0}:{}}}let Z_=/* @__PURE__ */ new Set([`user`,`steering`,`turn-trigger`,`model-retry`,`turn-error`,`turn-max-tokens`,`turn-tail`]);function Q_(e){let t=e.location;return t.kind===`turn`||t.kind===`step`?t.turn.turn:void 0}function $_(e){return Z_.has(e.kind)||e.kind===`tool-call`&&Dd(e.data.root.name)}function ev(e){return e.kind===`assistant-step`&&e.data.blocks.some(e=>e.kind===`reasoning`&&e.text.trim()!==``)}function tv(e){return e.kind===`assistant-step`&&cm(e.data.blocks)}function nv(e,t){return e.running===t.running&&e.runningDetail===t.runningDetail&&e.preparing===t.preparing&&e.counts.length===t.counts.length&&e.counts.every((e,n)=>e.kind===t.counts[n]?.kind&&e.count===t.counts[n].count)}function rv(e,t){return e.length===t.length&&e.every((e,n)=>e.key===t[n]?.key&&e.groupPart===t[n].groupPart)}function iv(e,t){return!th(t)&&(e===void 0||!th(e))?!1:e===void 0||e.kind!==t.kind||Q_(e)!==Q_(t)||th(e)!==th(t)||ev(e)!==ev(t)||tv(e)!==tv(t)}function av(e,t){let n=e.readNode(t);if(n===void 0)throw Error(`Chat grouping input is missing Node ${t}`);return n}function ov(e,t){let n=/* @__PURE__ */ new Set;for(let r of t){let t=av(e,r);t.kind===`question-reply`&&n.add(t.id)}return n}var sv=class{key;turn;members;nodes=[];snapshot;constructor(e,t,n){this.key=e,this.turn=t,this.members=n,this.snapshot={key:e,members:n,data:{turn:t,closed:!1,summary:{counts:[],running:void 0,runningDetail:``}}}}refresh(e,t){let n=this.members.map(t=>av(e,t.key)),r=n.length===this.nodes.length&&n.every((e,t)=>e===this.nodes[t]),i=this.snapshot.data,a=r&&i.closed===t?i.summary:X_(n),o=t?{counts:a.counts,running:void 0,runningDetail:``}:a;this.nodes=n,(i.closed!==t||!nv(i.summary,o))&&(this.snapshot={key:this.key,members:this.members,data:{turn:this.turn,closed:t,summary:o}})}},cv=class{turn;groups=/* @__PURE__ */ new Map;membership=/* @__PURE__ */ new Map;roots=/* @__PURE__ */ new Map;constructor(e){this.turn=e}references(e){return this.roots.get(e)??[]}snapshots(){return[...this.groups.values()].map(e=>e.snapshot)}refresh(e,t){let n=/* @__PURE__ */ new Set;for(let e of t){let t=this.membership.get(e);t!==void 0&&n.add(t)}let r=e.timeline.turns.get(this.turn)?.status===`closed`;if(r)for(let e of this.groups.values())e.snapshot.data.closed||n.add(e.key);let i=[];for(let t of n){let n=this.groups.get(t),a=n.snapshot;n.refresh(e,a.data.closed||r),n.snapshot!==a&&i.push(n.snapshot)}return i}rebuild(e,t){let n=/* @__PURE__ */ new Map,r=/* @__PURE__ */ new Map,i=/* @__PURE__ */ new Map,a=[],o=[],s=(e,t)=>{n.set(e,[...n.get(e)??[],t])},c=n=>{let c=a[0];if(c===void 0)return;let l=this.extendedGroup(a,t)?.key??Jf(JSON.stringify([`process`,c.key,c.groupPart??null])),u=this.groups.get(l),d=u?.snapshot,f=u!==void 0&&rv(u.members,a)?u:new sv(l,this.turn,a);f.refresh(e,n||e.timeline.turns.get(this.turn)?.status===`closed`),r.set(f.key,f),s(c.key,{kind:`group`,key:f.key});for(let e of a)i.set(e.key,f.key);f.snapshot!==d&&o.push(f.snapshot),a=[]},l,u=!1,d=e.readTurn(this.turn),f=ov(e,d);for(let t of d){let n=lv(e,t);l!==void 0&&n.previous!==l&&c(!0),l=t,u=n.next!==void 0;let r=av(e,t);r.kind===`turn-trigger`&&f.has(r.id)||($_(r)?(c(!0),s(t,{kind:`node`,key:t})):r.kind===`turn-process`?s(a[0]?.key??t,{kind:`node`,key:t}):r.kind===`assistant-step`?(ev(r)&&a.push({kind:`node`,key:t,groupPart:`reasoning`}),tv(r)&&(c(!0),s(t,{kind:`node`,key:t,groupPart:`response`}))):a.push({kind:`node`,key:t}))}c(u);let p=[...this.groups.keys()].filter(e=>!r.has(e));return this.groups=r,this.membership=i,this.roots=n,{upserts:o,removes:p}}extendedGroup(e,t){let n=e.findIndex(e=>!t.has(e.key)),r=e[n];if(r===void 0)return;let i=this.membership.get(r.key),a=i===void 0?void 0:this.groups.get(i);if(!(a===void 0||n+a.members.length>e.length)){for(let t=0;t<a.members.length;t++){let r=a.members[t],i=e[n+t];if(r.key!==i.key||r.groupPart!==i.groupPart)return}for(let r=n+a.members.length;r<e.length;r++)if(!t.has(e[r].key))return;return a}}};function lv(e,t){let n=e.readPosition(t);if(n===void 0)throw Error(`Chat grouping order is missing position for Node ${t}`);return n}var uv=class{turns=/* @__PURE__ */ new Map;order=[];pending=null;accept(e){if(e.kind===`replace`){let t=new Set(this.order),n=new Set(e.order.filter(e=>!t.has(e))),r=/* @__PURE__ */ new Map;for(let t of e.order){let i=lv(e,t).turn;if(i===void 0||r.has(i))continue;let a=this.turns.get(i)??new cv(i);a.rebuild(e,n),r.set(i,a)}this.turns=r,this.order=e.order,this.pending={entries:this.rootEntries(e),groups:{kind:`replace`,snapshots:[...r.values()].flatMap(e=>e.snapshots())}};return}let t=new Set(e.changedTurnOrders),n=/* @__PURE__ */ new Set,r=/* @__PURE__ */ new Map,i=e=>{let t=r.get(e);return t===void 0&&(t=/* @__PURE__ */ new Set,r.set(e,t)),t};for(let r of e.changes){let e=r.previous,a=r.current,o=Q_(a);if((e===void 0||!th(e))&&n.add(a.key),iv(e,a)){let n=e===void 0?void 0:Q_(e);n!==void 0&&t.add(n),o!==void 0&&t.add(o)}o!==void 0&&i(o).add(a.key)}for(let t of e.changedTurns)i(t);let a=[],o=[];for(let r of t){let t=this.turns.get(r)??new cv(r),i=t.rebuild(e,n);a.push(...i.upserts),o.push(...i.removes),e.readTurn(r).length===0?this.turns.delete(r):this.turns.set(r,t)}for(let[n,i]of r)t.has(n)||a.push(...this.turns.get(n)?.refresh(e,i)??[]);let s=e.order!==this.order||t.size>0;this.order=e.order;let c=new Set(a.map(e=>e.key));this.pending=s||a.length>0||o.length>0?{...s?{entries:this.rootEntries(e)}:{},groups:{kind:`apply`,upserts:a,removes:o.filter(e=>!c.has(e))}}:null}rootEntries(e){let t=ov(e,e.order.filter(t=>lv(e,t).turn===void 0));return e.order.flatMap(n=>{let r=lv(e,n).turn;if(r===void 0){let r=av(e,n);return r.kind===`turn-trigger`&&t.has(r.id)?[]:[{kind:`node`,key:n}]}let i=this.turns.get(r);if(i===void 0)throw Error(`Chat grouping order is missing Turn ${r}`);return i.references(n)})}output(){return this.pending}};let dv={kind:`process-groups`,target:`chat`,create:()=>new uv,update:(e,t)=>(e.state.accept(t),e.state),buildGroups:e=>e.state.output()};function fv(e){Sg(e),Og(e),Ng(e),Qm(e),w_(e),t_(e),cg(e),dg(e),Lg(e),o_(e),d_(e),B_(e),pg(e),Xh(e),e.uiConversation.groups.register(dv)}function pv({useNotice:e,dismissNotice:t,keepNoticeOpen:n,renderSlotChain:r,t:i}){let a=e(e=>e);if(a===null)return null;let o={code:a.code,message:i(`message.failure.quota`),dismiss:t,keepOpen:n};return/* @__PURE__ */ (0,f.jsx)(d.Fragment,{children:r(`shell.quota-notice`,o,{fallback:/* @__PURE__ */ (0,f.jsx)(p.Toast,{text:o.message,icon:/* @__PURE__ */ (0,f.jsx)(p.IconWarningOutlineRegular,{size:18}),onDone:t})})},`quota-notice-${String(a.seq)}`)}function mv(e){return e==null}function hv(e){return e&&typeof e==`object`&&!Array.isArray(e)}function gv(e,t){return Object.fromEntries(Object.entries(e).filter(([e,n])=>t(e,n)))}function _v(e,t){return Object.fromEntries(Object.entries(e).map(([e,n])=>[e,t(n,e)]))}function vv(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 yv=Symbol.for(`cosmokit.volatile.write`);function bv(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=>bv(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,bv(n,t)])))}finally{t.delete(e)}}function xv(e){let t=bv(e);return Object.freeze({get:()=>t,[yv]:e=>{t=e}})}function Sv(e){return typeof e==`object`&&!!e&&yv in e}function Cv(e,t){return arguments.length===1?t=>Cv(e,t):e in globalThis&&t instanceof globalThis[e]||Object.prototype.toString.call(t).slice(8,-1)===e}function wv(e){return Cv(`ArrayBuffer`,e)||Cv(`SharedArrayBuffer`,e)}function Tv(e){return wv(e)||ArrayBuffer.isView(e)}let Ev;(function(e){e.is=wv,e.isSource=Tv;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})(Ev||={}),Ev.fromBase64,Ev.toBase64,Ev.fromHex,Ev.toHex;function Dv(e,t=/* @__PURE__ */ new Map){if(!e||typeof e!=`object`)return e;if(Cv(`Date`,e))return new Date(e.valueOf());if(Cv(`RegExp`,e))return new RegExp(e.source,e.flags);if(wv(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(Dv,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(Dv,null,[i.value,t])),Reflect.defineProperty(r,n,i)}return r}function Ov(e,t,n){let r=/* @__PURE__ */ new Set;function i(e,t){if(e===t)return!0;if(Sv(e)||Sv(t))return Sv(e)&&Sv(t);if(!n&&mv(e)&&mv(t))return!0;if(typeof e!=typeof t||typeof e!=`object`||!e||!t||r.has(e))return!1;function a(n,r){return n(e)?n(t)?r(e,t):!1:!n(t)&&void 0}r.add(e);try{return a(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})??a(Cv(`Date`),(e,t)=>e.valueOf()===t.valueOf())??a(Cv(`URL`),(e,t)=>e.href===t.href)??a(Cv(`RegExp`),(e,t)=>e.source===t.source&&e.flags===t.flags)??a(wv,(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 kv;(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})(kv||={});let Av=Symbol.for(`schemastery`),jv=Symbol.for(`ValidationError`);globalThis.__schemastery_index__??=0,globalThis.__schemastery_refs__=void 0;var Q=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?.[jv]}};Object.defineProperty(Q.prototype,jv,{value:!0});let $=function(e){let t=function(e,n={}){return $.resolve(e,t,n)[0]};if(e.refs){let t=_v(e.refs,e=>new $(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&&_v(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,$.prototype),t.meta||={},t.toString=t.toString.bind(t),t};$.prototype=Object.create(Function.prototype),$.prototype[Av]=!0,Object.defineProperty($.prototype,"~standard",{get(){return{version:1,vendor:`schemastery`,validate:e=>{try{return{value:$.resolve(e,this,{})[0]}}catch(e){if(Q.is(e))return{issues:[{message:e.message,path:e.options.path}]};throw e}}}}}),$.ValidationError=Q,$.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},$.prototype.set=function(e,t){return this.dict[e]=t,this},$.prototype.push=function(e){return this.list.push(e),this};function Mv(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 Nv(e){return e?.$value??e?.$inner}function Pv(e){return gv(e??{},e=>!e.startsWith(`$`))}$.prototype.i18n=function(e){let t=$(this),n=Mv(t.meta.description,e);return Object.keys(n).length&&(t.meta.description=n),t.dict&&=_v(t.dict,(t,n)=>t.i18n(_v(e,e=>Nv(e)?.[n]??e?.[n]))),t.list&&=t.list.map((t,n)=>t.i18n(_v(e,(e={})=>Array.isArray(Nv(e))?Nv(e)[n]:Array.isArray(e)?e[n]:Pv(e)))),t.inner&&=t.inner.i18n(_v(e,e=>Nv(e)?Nv(e):Pv(e))),t.sKey&&=t.sKey.i18n(_v(e,e=>e?.$key)),t},$.prototype.extra=function(e,t){let n=$(this);return n.meta={...n.meta,[e]:t},n};for(let e of[`required`,`disabled`,`collapse`,`hidden`,`loose`])Object.assign($.prototype,{[e](t=!0){let n=$(this);return n.meta={...n.meta,[e]:t},n}});$.prototype.deprecated=function(){let e=$(this);return e.meta.badges||=[],e.meta.badges.push({text:`deprecated`,type:`danger`}),e},$.prototype.experimental=function(){let e=$(this);return e.meta.badges||=[],e.meta.badges.push({text:`experimental`,type:`warning`}),e},$.prototype.pattern=function(e){let t=$(this),n=vv(e,[`source`,`flags`]);return t.meta={...t.meta,pattern:n},t},$.prototype.simplify=function(e){if(Sv(e)&&(e=e.get()),Ov(e,this.meta.default,this.type===`dict`))return null;if(mv(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`||!mv(r))&&(t[n]=r)}return Ov(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 $.resolve(e,t,{}),t.simplify(e)}catch{}return e},$.prototype.toString=function(e){return Uv[this.type]?.(this,e)??`Schema<${this.type}>`},$.prototype.role=function(e,t){let n=$(this);return n.meta={...n.meta,role:e,extra:t},n};for(let e of[`default`,`link`,`comment`,`description`,`max`,`min`,`step`])Object.assign($.prototype,{[e](t){let n=$(this);return n.meta={...n.meta,[e]:t},n}});$.prototype.volatile=function(){if(this.meta.volatile)throw TypeError(`volatile schema is already wrapped`);return this.extra(`volatile`,!0)};let Fv={},Iv=Symbol(`checked-volatile-schema`);function Lv(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 Q(`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))Lv(i,[...t,n],a,r);if(e.sKey&&Lv(e.sKey,[...t,`<key>`],!0,r),e.inner&&(e.type!==`lazy`||e.inner[Av])&&Lv(e.inner,[...t,`*`],!0,r),e.list)for(let n=0;n<e.list.length;n++)Lv(e.list[n],[...t,String(n)],!0,r)}$.extend=function(e,t){Fv[e]=t},$.resolve=function(e,t,n={},r=!1){if(!t)return[e];if(n[Iv]||(Lv(t,n.path),n={...n,[Iv]:!0}),t.meta?.volatile){let i=$(t);i.meta={...t.meta,volatile:!1};let[a,o]=$.resolve(e,i,n,r);try{return[xv(a),o]}catch(e){throw new Q(e instanceof Error?e.message:String(e),n)}}if(n.ignore?.(e,t))return[e];if(mv(e)&&t.type!==`lazy`){if(t.meta.required)throw new Q(`missing required value`,n);let r=t,i=t.meta.default;for(;r?.type===`intersect`&&mv(i);)r=r.list[0],i=r?.meta.default;if(mv(i))return[e];e=Dv(i)}let i=Fv[t.type];if(!i)throw new Q(`unsupported type "${t.type}"`,n);try{return i(e,t,n,r)}catch(e){if(!t.meta.loose)throw e;return[t.meta.default]}},$.from=function(e){if(mv(e))return $.any();if([`string`,`number`,`boolean`].includes(typeof e))return $.const(e).required();if(e[Av])return e;if(typeof e==`function`)switch(e){case String:return $.string().required();case Number:return $.number().required();case Boolean:return $.boolean().required();case Function:return $.function().required();default:return $.is(e).required()}else throw TypeError(`cannot infer schema from ${e}`)},$.lazy=function(e){let t=new $({type:`lazy`,builder:e,inner:{toJSON:()=>(t.inner[Av]||(t.inner=t.builder(),t.inner.meta={...t.meta,...t.inner.meta}),t.inner.toJSON())}});return t},$.natural=function(){return $.number().step(1).min(0)},$.percent=function(){return $.number().step(.01).min(0).max(1).role(`slider`)},$.date=function(){return $.union([$.is(Date),$.transform($.string().role(`datetime`),(e,t)=>{let n=new Date(e);if(isNaN(+n))throw new Q(`invalid date "${e}"`,t);return n},!0)])},$.regExp=function(e=``){return $.union([$.is(RegExp),$.transform($.string().role(`regexp`,{flag:e}),(t,n)=>{try{return new RegExp(t,e)}catch(e){throw new Q(e.message,n)}},!0)])},$.arrayBuffer=function(e){return $.union([$.is(ArrayBuffer),$.is(SharedArrayBuffer),$.transform($.any(),(e,t)=>{if(Ev.isSource(e))return Ev.fromSource(e);throw new Q(`expected ArrayBufferSource but got ${e}`,t)},!0),...e?[$.transform($.string(),(t,n)=>{try{return e===`base64`?Ev.fromBase64(t):Ev.fromHex(t)}catch(e){throw new Q(e.message,n)}},!0)]:[]])},$.extend(`lazy`,(e,t,n,r)=>(t.inner[Av]||(t.inner=t.builder(),t.inner.meta={...t.meta,...t.inner.meta},Lv(t.inner,n.path,!0)),$.resolve(e,t.inner,n,r))),$.extend(`any`,e=>[e]),$.extend(`never`,(e,t,n)=>{throw new Q(`expected nullable but got ${e}`,n)}),$.extend(`const`,(e,{value:t},n)=>{if(Ov(e,t))return[t];throw new Q(`expected ${t} but got ${e}`,n)});function Rv(e,t,n,r,i=!1){let{max:a=1/0,min:o=-1/0}=t;if(e>a)throw new Q(`expected ${n} <= ${a} but got ${e}`,r);if(e<o&&!i)throw new Q(`expected ${n} >= ${o} but got ${e}`,r)}$.extend(`string`,(e,{meta:t},n)=>{if(typeof e!=`string`)throw new Q(`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 Q(`expect string to match regexp ${r}`,n)}return Rv(e.length,t,`string length`,n),[e]});function zv(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 Bv(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(zv(e,i)-zv(t,i))%zv(n,i)===0}$.extend(`number`,(e,{meta:t},n)=>{if(typeof e!=`number`)throw new Q(`expected number but got ${e}`,n);Rv(e,t,`number`,n);let{step:r}=t;if(r&&!Bv(e,t.min??0,r))throw new Q(`expected number multiple of ${r} but got ${e}`,n);return[e]}),$.extend(`boolean`,(e,t,n)=>{if(typeof e==`boolean`)return[e];throw new Q(`expected boolean but got ${e}`,n)}),$.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 Q(`expected string but got ${e}`,r);e in t&&(i|=t[e])}}else throw new Q(`expected number or array but got ${e}`,r);return i===n.default?[i]:[i,a]}),$.extend(`function`,(e,t,n)=>{if(typeof e==`function`)return[e];throw new Q(`expected function but got ${e}`,n)}),$.extend(`is`,(e,{constructor:t},n)=>{if(typeof t==`function`){if(e instanceof t)return[e];throw new Q(`expected ${t.name} but got ${e}`,n)}{if(mv(e))throw new Q(`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 Q(`expected ${t} but got ${e}`,n)}});function Vv(e,t,n,r){try{let[i,a]=$.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?xv(n.meta.default):n.meta.default}}$.extend(`array`,(e,{inner:t,meta:n},r)=>{if(!Array.isArray(e))throw new Q(`expected array but got ${e}`,r);return Rv(e.length,n,`array length`,r,!mv(t.meta.default)),[e.map((n,i)=>Vv(e,i,t,r))]}),$.extend(`dict`,(e,{inner:t,sKey:n},r,i)=>{if(!hv(e))throw new Q(`expected object but got ${e}`,r);let a={};for(let o in e){let s;try{s=$.resolve(o,n,r)[0]}catch(e){if(i)continue;throw e}a[s]=Vv(e,o,t,r),e[s]=e[o],o!==s&&delete e[o]}return[a]}),$.extend(`tuple`,(e,{list:t},n,r)=>{if(!Array.isArray(e))throw new Q(`expected array but got ${e}`,n);let i=t.map((t,r)=>Vv(e,r,t,n));return r||i.push(...e.slice(t.length)),[i]});function Hv(e,t){for(let n in t)n in e||(e[n]=t[n])}$.extend(`object`,(e,{dict:t},n,r)=>{if(!hv(e))throw new Q(`expected object but got ${e}`,n);let i={};for(let r in t){let a=Vv(e,r,t[r],n);(!mv(a)||r in e)&&(i[r]=a)}return r||Hv(i,e),[i]}),$.extend(`union`,(e,{list:t,toString:n},r,i)=>{let a=[];for(let n of t)try{return $.resolve(e,n,r,i)}catch(e){a.push(e)}throw new Q(`expected ${n()} but got ${JSON.stringify(e)}`,r)}),$.extend(`intersect`,(e,{list:t,toString:n},r,i)=>{if(!t.length)return[e];let a;for(let i of t){let t=$.resolve(e,i,r,!0)[0];if(!mv(t)){if(mv(a))a=t;else if(typeof a!=typeof t)throw new Q(`expected ${n()} but got ${JSON.stringify(e)}`,r);else if(typeof t==`object`)Hv(a??={},t);else if(a!==t)throw new Q(`expected ${n()} but got ${JSON.stringify(e)}`,r)}}return!i&&hv(e)&&Hv(a,e),[a]}),$.extend(`transform`,(e,{inner:t,callback:n,preserve:r},i)=>{let[a,o=e]=$.resolve(e,t,i,!0);return r?[n(a)]:[n(a),n(o)]});let Uv={};function Wv(e,t,n){Uv[e]=n,Object.assign($,{[e](...n){let r=new $({type:e});return t.forEach((e,t)=>{switch(e){case`sKey`:r.sKey=n[t]??$.string();break;case`inner`:r.inner=$.from(n[t]);break;case`list`:r.list=n[t].map($.from);break;case`dict`:r.dict=_v(n[t],$.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}})}Wv(`is`,[`constructor`],({constructor:e})=>typeof e==`function`?e.name:e),Wv(`any`,[],()=>`any`),Wv(`never`,[],()=>`never`),Wv(`const`,[`value`],({value:e})=>typeof e==`string`?JSON.stringify(e):e),Wv(`string`,[],()=>`string`),Wv(`number`,[],()=>`number`),Wv(`boolean`,[],()=>`boolean`),Wv(`bitset`,[`bits`],()=>`bitset`),Wv(`function`,[],()=>`function`),Wv(`array`,[`inner`],({inner:e})=>`${e.toString(!0)}[]`),Wv(`dict`,[`inner`,`sKey`],({inner:e,sKey:t})=>`{ [key: ${t.toString()}]: ${e.toString()} }`),Wv(`tuple`,[`list`],({list:e})=>`[${e.map(e=>e.toString()).join(`, `)}]`),Wv(`object`,[`dict`],({dict:e})=>Object.keys(e).length===0?`{}`:`{ ${Object.entries(e).map(([e,t])=>`${e}${t.meta.required?``:`?`}: ${t.toString()}`).join(`, `)} }`),Wv(`union`,[`list`],({list:e},t)=>{let n=e.map(({toString:e})=>e()).join(` | `);return t?`(${n})`:n}),Wv(`intersect`,[`list`],({list:e})=>`${e.map(e=>e.toString(!0)).join(` & `)}`),Wv(`transform`,[`inner`,`callback`,`preserve`],({inner:e},t)=>e.toString(t));let Gv=`transcriptView`,Kv=[`compact`,`standard`,`detailed`,`verbose`],qv=[...Kv,`normal`,`expanded`],Jv=`standard`,Yv={linkOpening:$.union([`sidebar`,`new-tab`]).default(`sidebar`),[Gv]:$.union([...qv]).loose()};$.object(Yv);let Xv=`@deepseek-ai/dsh-client-ui-chat/PreferenceRow.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(Xv)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=Xv,e.textContent=`.W6wRnW_row{border-bottom:.5px solid var(--dsw-alias-border-l2);align-items:center;gap:8px;padding:16px 0;display:flex}.W6wRnW_rowText{flex-direction:column;flex:1;gap:4px;min-width:0;padding-right:48px;display:flex}.W6wRnW_title{color:var(--dsw-alias-label-primary);font-size:14px;font-weight:400;line-height:22px}.W6wRnW_desc{color:var(--dsw-alias-label-tertiary);font-size:12px;font-weight:400;line-height:18px}.W6wRnW_selector{border-radius:var(--dsw-radius-md);background:var(--dsw-alias-bg-module-platform);height:36px;font:inherit;color:var(--dsw-alias-label-primary);cursor:pointer;border:none;align-items:center;gap:12px;padding:0 14px;font-size:14px;line-height:22px;display:inline-flex}.W6wRnW_selector:hover{background:var(--dsw-alias-interactive-bg-hover)}.W6wRnW_chevron{flex:none}`,document.head.appendChild(e)}var Zv={chevron:`W6wRnW_chevron`,desc:`W6wRnW_desc`,row:`W6wRnW_row`,rowText:`W6wRnW_rowText`,selector:`W6wRnW_selector`,title:`W6wRnW_title`};function Qv({title:e,description:t,value:n,selectedLabel:r,options:i,onSelect:a}){let[o,s]=(0,d.useState)(!1),c=(0,d.useRef)(null),l=()=>{s(!1)},u=e=>{c.current?.focus({preventScroll:!0}),l(),a(e)},m=/* @__PURE__ */ (0,f.jsxs)(`button`,{ref:c,type:`button`,className:Zv.selector,"aria-haspopup":`menu`,"aria-expanded":o,onClick:()=>{s(e=>!e)},children:[r,/* @__PURE__ */ (0,f.jsx)(p.IconChevronDownOutlineRegular,{className:Zv.chevron})]});return/* @__PURE__ */ (0,f.jsxs)(`div`,{className:Zv.row,children:[/* @__PURE__ */ (0,f.jsxs)(`div`,{className:Zv.rowText,children:[/* @__PURE__ */ (0,f.jsx)(`div`,{className:Zv.title,children:e}),/* @__PURE__ */ (0,f.jsx)(`div`,{className:Zv.desc,children:t})]}),/* @__PURE__ */ (0,f.jsx)(p.Menu,{open:o,onClose:l,items:i,selectedId:n,onSelect:u,align:`end`,portal:!0,anchor:m})]})}let $v={compact:`settings.transcript.compact`,standard:`settings.transcript.standard`,detailed:`settings.transcript.detailed`,verbose:`settings.transcript.verbose`};function ey({useTranscriptView:e,setTranscriptView:t,t:n}){let r=e(e=>e);return/* @__PURE__ */ (0,f.jsx)(Qv,{title:n(`settings.transcript.title`),description:n(`settings.transcript.description`),value:r,selectedLabel:n($v[r]),options:Kv.map(e=>({id:e,label:n($v[e])})),onSelect:e=>{t(e)}})}var ty=class{host;defaultMode;unsubscribe;mode;constructor(e,t=Jv){this.host=e,this.defaultMode=t,this.mode=(0,m.createSnapshotStore)(t),this.unsubscribe=e.subscribe(()=>{this.adopt()}),this.adopt()}dispose(){this.unsubscribe()}setMode(e){this.mode.getSnapshot()!==e&&(this.mode.set(e),this.host.set(Gv,e))}adopt(){let e=this.host.getSnapshot().value;if(e===void 0)return;let t=e.transcriptView,n=t===`normal`||t===`expanded`?`detailed`:t??this.defaultMode;this.mode.getSnapshot()!==n&&this.mode.set(n)}};let ny={compact:{mode:`compact`,foldCompletedTurns:!0,stepGrouping:`collapsed`,liveProcessDetail:!1,settledReasoningPreview:!1},standard:{mode:`standard`,foldCompletedTurns:!0,stepGrouping:`collapsed`,liveProcessDetail:!0,settledReasoningPreview:!0},detailed:{mode:`detailed`,foldCompletedTurns:!0,stepGrouping:`history`,liveProcessDetail:!0,settledReasoningPreview:!0},verbose:{mode:`verbose`,foldCompletedTurns:!1,stepGrouping:`none`,liveProcessDetail:!1,settledReasoningPreview:!0}};function ry(e){return{getSnapshot:()=>ny[e.getSnapshot()],subscribe:t=>e.subscribe(t)}}function iy({useLinkOpening:e,useBrowserAvailable:t,setLinkOpening:n,t:r}){let i=e(e=>e);return t(e=>e)?/* @__PURE__ */ (0,f.jsx)(Qv,{title:r(`settings.links.title`),description:r(`settings.links.description`),value:i,selectedLabel:r(i===`sidebar`?`settings.links.sidebar`:`settings.links.newTab`),options:[{id:`sidebar`,label:r(`settings.links.sidebar`)},{id:`new-tab`,label:r(`settings.links.newTab`)}],onSelect:e=>{n(e)}}):null}let ay={getSnapshot:()=>void 0,subscribe:()=>()=>{}};function oy(e,t){let n=e?.source(t)??ay;return(0,d.useSyncExternalStore)(n.subscribe,n.getSnapshot)}let sy={hooks:{turnData:(e,{turnData:t})=>function(e){return oy(t,e)},disclosure:(e,{disclosureReset:t})=>Xd(t)}},cy=[`slots`,`sessions`,`uiWorkspace`,`uiSession`,`uiConversation`,`locale`,`configForms`,`remote`,`remote.session`,`remote.workspaceFiles`,`sidebarRight`];function ly(e){let t=(0,m.createSnapshotStore)(null),n=0,r=/* @__PURE__ */ new Set,i=/* @__PURE__ */ new WeakMap,a=/* @__PURE__ */ new Set;e.effect(()=>async()=>{await Promise.all([...a].map(e=>e()))},`ui-chat: live quota notices`);let o=o=>{let s=i.get(o);if(s===void 0){let c=o.ctx.effect(()=>{let e=o.eventSource.subscribe(()=>{let{change:e}=o.eventSource.getSnapshot();if(e.kind===`append`)for(let{event:i}of e.entries){if(i.type!==`turn/end`||i.data.reason.kind!==`error`)continue;let{code:e}=i.data.reason.error;r.size>0||e!==`QUOTA`&&e!==`ACCOUNT_QUOTA`||t.set({code:e,seq:++n})}});return()=>{e(),i.delete(o),a.delete(c)}},`ui-chat: Provider binding quota notices`);a.add(c);let l=e.uiConversation.binding(o).target(`chat`);s={getSnapshot:()=>l.getSnapshot()??de,subscribe:e=>l.subscribe(e)},i.set(o,s)}return s};fv(e),e.uiSession.provide({hooks:[`chat`],resolve:e=>({hooks:{chat:o(e)}})}),e.effect(()=>e.locale.register(X,{zh:Ap,en:jp}),`ui-chat: dictionaries`);let s=e.locale.bind(X),c=Ad(),l=/* @__PURE__ */ new Map,u=e.configForms.get(`ui-chat`),d=(0,m.createSnapshotStore)(u.getSnapshot().value?.linkOpening??`sidebar`);e.effect(()=>u.subscribe(()=>{let e=u.getSnapshot().value?.linkOpening;e!==void 0&&d.set(e)}));let f={getSnapshot:()=>e.get(`sidebarRightTabs`)?.get(`browser`)!==void 0,subscribe:t=>e.get(`sidebarRightTabs`)?.subscribe(t)??(()=>{})},p=t=>f.getSnapshot()?(e.sidebarRight.openTab(`browser`,{params:{url:t}}),!0):!1;e.inject([`sidebarRightTabs`],e=>{e.slots.inject(`settings.general.item`,()=>e.slots.register({name:`settings.general.item`,id:`link-opening`,order:17,locale:X,inject:()=>({hooks:{linkOpening:d,browserAvailable:f},setLinkOpening:e=>{d.set(e),u.set(`linkOpening`,e).catch(()=>{})}})},iy))});let h=new ty(u,`dshDesktop`in globalThis?`standard`:Jv),g=ry(h.mode);e.effect(()=>()=>{h.dispose()}),bm(e,g),e.slots.inject(`settings.general.item`,()=>e.slots.register({name:`settings.general.item`,id:`transcript-view`,order:12,locale:X,inject:()=>({hooks:{transcriptView:h.mode},setTranscriptView:e=>{h.setMode(e)}})},ey)),e.slots.inject(`conversation.view`,()=>e.slots.register({name:`conversation.view`,id:`chat`,order:0,label:()=>s(`view.chat`),locale:X,children:{"conversation.chat.node":{kind:`keyed`,scope:`session`,inject:sy},"conversation.message.images":{kind:`single`,scope:`session`}},store:c,inject:t=>{let n=e.sessions.binding(t);if(n===void 0)throw Error(`ui-chat: unknown session "${t}"`);let r=n.session,i=o(n),a=e.uiConversation.binding(n),s=e.get(`chatMessageEditing`),c=e.get(`chatTurnDiffs`);return{connection:e.get(`connection`),hooks:{presentation:g,browserAvailable:f},keyedHooks:{chatNode:e=>i.getSnapshot().nodes.source(e),chatNodeProcess:e=>i.getSnapshot().nodes.processSource(e),chatGroup:e=>a.snapshot.getSnapshot().views.grouped(`chat`)?.groupSource(e)},fileMentions:n=>e.get(`chatFileMentions`)?.forClosing(n,t),openFile:async(n,r)=>{let i=e.sessions.list.getSnapshot().byId[t]?.cwd;if(r?.external||r?.reveal){let a=ae(i,n);if(!r.reveal||!D(a)){let r=await e.remote.workspaceFiles.stat(t,n);if(!r.ok)throw Error(r.error.message);a=r.value.absolutePath}let o=await e.remote.session.openWorkspacePath({path:a,...r.reveal?{action:`reveal`}:{}});if(!o.ok)throw Error(o.error.message);return}let a=O(t,i,n);r?.line===void 0?e.sidebarRight.openResource(a):e.sidebarRight.openResource(a,{params:{line:r.line}}),await Promise.resolve()},openSkill:n=>{let r=e.sessions.scope(t);r!==void 0&&e.get(`inputTriggers`)?.sessionOf(r).openReference(`skill`,{ref:`/${n}`})},resolveLink:e.get(`chatLinks`)?.resolve,openLinkInSidebar:p,openExternalLink:e=>{d.getSnapshot()===`sidebar`&&p(e)||window.open(e,`_blank`,`noopener,noreferrer`)},loadOlder:()=>{r.loadOlder()},loadThrough:e=>r.loadThrough(e),loadImage:Object.assign(n=>e.uiConversation.imageUrl(t,n),{peek:n=>e.uiConversation.peekImageUrl(t,n)}),chatScroll:{save:e=>{e===null?l.delete(t):l.set(t,e)},read:()=>l.get(t)??null},loadTurnDiffs:c?(e,n)=>c.read(t,e,n):void 0,editMessage:s?(e,n)=>s.send(t,e,n):void 0,forkAt:n=>{let r=[...i.getSnapshot().timeline.turns.values()].find(e=>e.end?.seq===n)?.data.get(`turn-tail`)?.closing?.finalNode.messageId;return e.sessions.fork({sessionId:t,atSeq:n,increaseTitle:!0,onCreated:n=>{e.get(`productAnalytics`)?.track(`branch_session_click`,{session_id:n,parent_session_id:t,...r===void 0?{}:{parent_message_id:r},click_position:`footer`})}}).then(t=>{e.uiWorkspace.openSession(t)})}}}},Op)),e.slots.inject(`shell.overlay`,()=>e.slots.register({name:`shell.overlay`,id:`chat.quota-notice`,locale:X,children:{"shell.quota-notice":{kind:`chain`,scope:`root`}},inject:()=>({hooks:{notice:t},dismissNotice:()=>{r.clear(),t.set(null)},keepNoticeOpen:()=>{if(t.getSnapshot()===null)return()=>{};let e=Symbol(`ui-chat quota notice hold`);return r.add(e),()=>{r.delete(e)}}})},pv)),e.slots.inject(`conversation.input.dock`,()=>e.slots.register({name:`conversation.input.dock`,id:`file-changes`,order:5,locale:X},T)),e.slots.inject(`conversation.approval.detail`,()=>e.slots.register({name:`conversation.approval.detail`},pe))}return n.EMPTY_CHAT_SNAPSHOT=de,n.apply=ly,n.inject=cy,n.isRunningTool=eh,n.isSettledTool=$m,t.exports}});