@codexhost/cli-win32-x64 0.32.0 → 0.33.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (150) hide show
  1. package/README.md +1 -1
  2. package/app/codexhost-distribution.json +1 -1
  3. package/app/console-server.mjs +589 -30
  4. package/app/console-web.js +558 -30
  5. package/app/desktop-controller.mjs +883 -150
  6. package/app/host-runtime.mjs +8165 -3548
  7. package/app/plugins/antigravity/plugin.mjs +493 -55
  8. package/app/plugins/claude-code/assets/icon.svg +1 -1
  9. package/app/plugins/claude-code/manifest.json +1 -1
  10. package/app/plugins/claude-code/plugin.mjs +1106 -193
  11. package/app/plugins/codebuddy/plugin.mjs +465 -27
  12. package/app/plugins/codex-usage/plugin.mjs +367 -7
  13. package/app/plugins/copilot/assets/icon.svg +1 -1
  14. package/app/plugins/copilot/manifest.json +1 -1
  15. package/app/plugins/copilot/plugin.mjs +369 -9
  16. package/app/plugins/cursor-cli/plugin.mjs +367 -7
  17. package/app/plugins/deepseek-harness/assets/icon.svg +1 -1
  18. package/app/plugins/deepseek-harness/manifest.json +1 -1
  19. package/app/plugins/deepseek-harness/plugin.mjs +806 -148
  20. package/app/plugins/devin/assets/icon.svg +1 -1
  21. package/app/plugins/devin/manifest.json +1 -1
  22. package/app/plugins/devin/plugin.mjs +369 -8
  23. package/app/plugins/grok/plugin.mjs +367 -7
  24. package/app/plugins/hermes/plugin.mjs +367 -7
  25. package/app/plugins/kimi-code/plugin.mjs +367 -7
  26. package/app/plugins/kiro-cli/plugin.mjs +367 -7
  27. package/app/plugins/omp/assets/icon.svg +1 -1
  28. package/app/plugins/omp/plugin.mjs +393 -7
  29. package/app/plugins/opencode/plugin.mjs +371 -8
  30. package/app/plugins/pi/assets/icon.svg +1 -1
  31. package/app/plugins/pi/manifest.json +1 -1
  32. package/app/plugins/pi/plugin.mjs +395 -9
  33. package/app/plugins/qoder/assets/icon.svg +1 -1
  34. package/app/plugins/qoder/plugin.mjs +393 -7
  35. package/app/plugins/qoder-cn/assets/icon.svg +1 -1
  36. package/app/plugins/qoder-cn/plugin.mjs +393 -7
  37. package/app/plugins/qwen-code/assets/icon.svg +1 -1
  38. package/app/plugins/qwen-code/plugin.mjs +396 -7
  39. package/app/plugins/workbuddy/plugin.mjs +465 -27
  40. package/app/plugins/zcode/plugin.mjs +387 -14
  41. package/app/renderer-extension.js +581 -41
  42. package/app/web/assets/{abnfDiagram-XWFEHMT6-CnJyN70L.js → abnfDiagram-XWFEHMT6-VnfRaHM6.js} +1 -1
  43. package/app/web/assets/{architectureDiagram-CSQXQB3N-DH0ITYVE.js → architectureDiagram-CSQXQB3N-BA1ehtvi.js} +1 -1
  44. package/app/web/assets/{blockDiagram-BEDRHYPZ-WL3ZKoKg.js → blockDiagram-BEDRHYPZ-31BZSfd4.js} +1 -1
  45. package/app/web/assets/{c4Diagram-M2UUVUY5-XwSPKj5H.js → c4Diagram-M2UUVUY5-CNzGWc5k.js} +1 -1
  46. package/app/web/assets/{chunk-2Q5K7J3B-CKEzexjg.js → chunk-2Q5K7J3B-ahAIR-NM.js} +1 -1
  47. package/app/web/assets/{chunk-3GCGMST5-BdEgLpab.js → chunk-3GCGMST5-BIV5YeRJ.js} +1 -1
  48. package/app/web/assets/{chunk-5VM5RSS4-DyxL5-Ts.js → chunk-5VM5RSS4-CluTMPJG.js} +1 -1
  49. package/app/web/assets/{chunk-7U7NFRK5-FXLb4tYa.js → chunk-7U7NFRK5-4NIQuFbE.js} +1 -1
  50. package/app/web/assets/{chunk-CNRTWJTD-DcdC1OYr.js → chunk-CNRTWJTD-_0bEfGn3.js} +1 -1
  51. package/app/web/assets/{chunk-D5HYT7QG-BOz9vBX9.js → chunk-D5HYT7QG-_kTC6f8F.js} +1 -1
  52. package/app/web/assets/{chunk-EBZ3SEQC-Dmc_Z53x.js → chunk-EBZ3SEQC-CykaYOrL.js} +2 -2
  53. package/app/web/assets/{chunk-JWPE2WC7-CrFwSwYi.js → chunk-JWPE2WC7-3vVOQ_py.js} +1 -1
  54. package/app/web/assets/{chunk-KTR4FSNJ-BY3AzFaI.js → chunk-KTR4FSNJ-aVg5vgrm.js} +1 -1
  55. package/app/web/assets/{chunk-XXDRQBXY-CHgNy82n.js → chunk-XXDRQBXY-_gVwGeSp.js} +1 -1
  56. package/app/web/assets/{classDiagram-v2-KXABOMEV-ClM3-y5Z.js → classDiagram-v2-KXABOMEV-fI1LfeBf.js} +1 -1
  57. package/app/web/assets/{cose-bilkent-JH36ORCC-I7nd8GgO.js → cose-bilkent-JH36ORCC-DFXMlWov.js} +1 -1
  58. package/app/web/assets/{cynefin-EF2NZ3EQ-DzsXmyBH.js → cynefin-EF2NZ3EQ-lZy7X6FO.js} +1 -1
  59. package/app/web/assets/{cynefinDiagram-NJNITYFG-DLHq6igy.js → cynefinDiagram-NJNITYFG-N4DwFSW1.js} +1 -1
  60. package/app/web/assets/{dagre-KIHZ2IZ3-BK991Mno.js → dagre-KIHZ2IZ3-B7-8baTH.js} +1 -1
  61. package/app/web/assets/{diagram-7YQZDPLS-C4qiWdQU.js → diagram-7YQZDPLS-DLfjiBXV.js} +1 -1
  62. package/app/web/assets/{diagram-QBROCOUO-C_ZyBohC.js → diagram-QBROCOUO-CQnRzSTi.js} +1 -1
  63. package/app/web/assets/{diagram-RJJCUUZO-C5Aezm94.js → diagram-RJJCUUZO-DPnxazRT.js} +1 -1
  64. package/app/web/assets/{diagram-WERXNKYE-Ckc_umlF.js → diagram-WERXNKYE-BBuEFRvD.js} +1 -1
  65. package/app/web/assets/{diagram-YHHI257C-BHjReoZZ.js → diagram-YHHI257C-BQ92JNJs.js} +1 -1
  66. package/app/web/assets/{diagram-YR4HJLHV-DVTGi_y9.js → diagram-YR4HJLHV-Ce6BQO3J.js} +1 -1
  67. package/app/web/assets/{ebnfDiagram-N527522P-getuz1AR.js → ebnfDiagram-N527522P-DYknE2Jy.js} +1 -1
  68. package/app/web/assets/{elk-O5DQBFGD-C7mhTIuK.js → elk-O5DQBFGD-4S6_JJFF.js} +1 -1
  69. package/app/web/assets/{erDiagram-K3K3BIDK-sV-HZvUV.js → erDiagram-K3K3BIDK-DRtF7JVQ.js} +1 -1
  70. package/app/web/assets/{flowDiagram-Z6JWZHQI-D0L4wXUs.js → flowDiagram-Z6JWZHQI-7Ho8CyR9.js} +1 -1
  71. package/app/web/assets/{ganttDiagram-3PRQTZWP-BNt9Bjjo.js → ganttDiagram-3PRQTZWP-CW8Ig5y4.js} +1 -1
  72. package/app/web/assets/{gitGraphDiagram-VXDFKS5L-BABZzhHw.js → gitGraphDiagram-VXDFKS5L-CzS8Xg2D.js} +1 -1
  73. package/app/web/assets/{grid-E2QIVN74-DLe2FQ_d.js → grid-E2QIVN74-Cq284lCe.js} +1 -1
  74. package/app/web/assets/index-CINZ6P-q.css +1 -0
  75. package/app/web/assets/index-CvV6veuY.js +208 -0
  76. package/app/web/assets/{infoDiagram-EZ3ZOAHP-BKDuUqcr.js → infoDiagram-EZ3ZOAHP-BZgN6qlY.js} +1 -1
  77. package/app/web/assets/{ishikawaDiagram-S3EKX5GW-C75EGghg.js → ishikawaDiagram-S3EKX5GW-BH9YHc-1.js} +1 -1
  78. package/app/web/assets/{journeyDiagram-POQNLL5X-q7Obruqa.js → journeyDiagram-POQNLL5X-D50KYOLe.js} +1 -1
  79. package/app/web/assets/{kanban-definition-BH5XI6FM-CzAqhFED.js → kanban-definition-BH5XI6FM-Crw_5mMP.js} +1 -1
  80. package/app/web/assets/langs/{graphql-D6Z3qcRW.js → graphql-2R4AZ1iu.js} +1 -1
  81. package/app/web/assets/langs/{http-XiU9G9In.js → http-q2Qm0vBh.js} +1 -1
  82. package/app/web/assets/langs/{php-DL3xwS-7.js → php-Cz2gDBnd.js} +1 -1
  83. package/app/web/assets/langs/{rst-DudRVJ9g.js → rst-_9muvx-X.js} +1 -1
  84. package/app/web/assets/langs/{ruby-_FqsfqJi.js → ruby-cn7REk4H.js} +1 -1
  85. package/app/web/assets/langs/{svelte-ClsVJoBT.js → svelte-CPnL2mcy.js} +1 -1
  86. package/app/web/assets/langs/{vue-BiKMXCyK.js → vue-DO0YwyVz.js} +1 -1
  87. package/app/web/assets/{mermaid.core-Bysx44LR.js → mermaid.core-o2Qjrppc.js} +5 -5
  88. package/app/web/assets/{mindmap-definition-WVAN44T4-Ds5rXTrF.js → mindmap-definition-WVAN44T4-B_bEbpAH.js} +1 -1
  89. package/app/web/assets/{pegDiagram-D4NLKWP3-hmdERwtT.js → pegDiagram-D4NLKWP3-VecAHoyw.js} +1 -1
  90. package/app/web/assets/{pieDiagram-36ENHN4W-DfTnyG8D.js → pieDiagram-36ENHN4W-o3ei2T-6.js} +1 -1
  91. package/app/web/assets/{quadrantDiagram-ZQUDMS73-CreQWjZQ.js → quadrantDiagram-ZQUDMS73-DHndOAcn.js} +1 -1
  92. package/app/web/assets/{railroadDiagram-JIZHGYPL-Bhc_eO9G.js → railroadDiagram-JIZHGYPL-DRd_lfii.js} +1 -1
  93. package/app/web/assets/{render-VIF2ZAQL-BS1Zgk8K.js → render-VIF2ZAQL-awM3hUqB.js} +2 -2
  94. package/app/web/assets/{requirementDiagram-AXW2TVFA-Dlp7d6QT.js → requirementDiagram-AXW2TVFA-Ce1ePsOe.js} +1 -1
  95. package/app/web/assets/{sankeyDiagram-FBCJTAIF-DGBchL30.js → sankeyDiagram-FBCJTAIF-cP-LtgW-.js} +1 -1
  96. package/app/web/assets/{sequenceDiagram-3LA2ROMG-DauFg5_R.js → sequenceDiagram-3LA2ROMG-C3JStTuW.js} +1 -1
  97. package/app/web/assets/{sizeCapture-2Q2CQKSF-DR-zy7an.js → sizeCapture-2Q2CQKSF-Dyyelr9K.js} +1 -1
  98. package/app/web/assets/{stateDiagram-v2-ATKHQDJO-BSRBSGUi.js → stateDiagram-v2-ATKHQDJO-DkYRBVTd.js} +1 -1
  99. package/app/web/assets/{swimlanes-YQL5WMAO-BwzOr5Dv.js → swimlanes-YQL5WMAO-B2FwJU5_.js} +1 -1
  100. package/app/web/assets/swimlanesDiagram-UCCPES4V-BkMsxCPb.js +8 -0
  101. package/app/web/assets/{timeline-definition-7Z437IG3-BoZ-mNKc.js → timeline-definition-7Z437IG3-Di-qRIIi.js} +1 -1
  102. package/app/web/assets/{usecaseDiagram-RDK6N6HP-DikhgH2m.js → usecaseDiagram-RDK6N6HP-yAImn62t.js} +1 -1
  103. package/app/web/assets/{vendor-BKfNgqAm.js → vendor-BMCjWFMy.js} +20 -20
  104. package/app/web/assets/{vennDiagram-SHRQU5PJ-DY_oIxwl.js → vennDiagram-SHRQU5PJ-BEv8jpfv.js} +1 -1
  105. package/app/web/assets/{wardleyDiagram-F3OXNVQS-DrRIiB_M.js → wardleyDiagram-F3OXNVQS-7irksA0b.js} +1 -1
  106. package/app/web/assets/{xychartDiagram-GDYJKCDI-CzSPgHV7.js → xychartDiagram-GDYJKCDI-BokJGG2y.js} +1 -1
  107. package/app/web/codex-agent.png +0 -0
  108. package/app/web/codex.png +0 -0
  109. package/app/web/codexhost-settings.js +66 -66
  110. package/app/web/index.html +3 -3
  111. package/app/web/plugins/deepseek-ai__dsh-api-remotes/client.js +65 -65
  112. package/app/web/plugins/deepseek-ai__dsh-api-session-controller/client.js +69 -69
  113. package/app/web/plugins/deepseek-ai__dsh-client-ui-attachment/client.js +1 -1
  114. package/app/web/plugins/deepseek-ai__dsh-client-ui-chat/client.js +75 -75
  115. package/app/web/plugins/deepseek-ai__dsh-client-ui-codexhost/client.js +78 -73
  116. package/app/web/plugins/deepseek-ai__dsh-client-ui-conversation/client.js +92 -92
  117. package/app/web/plugins/deepseek-ai__dsh-client-ui-input-trigger/client.js +1 -1
  118. package/app/web/plugins/deepseek-ai__dsh-client-ui-model-selection/client.js +114 -2
  119. package/app/web/plugins/deepseek-ai__dsh-client-ui-settings-general/client.js +1 -1
  120. package/app/web/plugins/deepseek-ai__dsh-client-ui-tool/client.js +79 -79
  121. package/app/web/plugins/deepseek-ai__dsh-client-ui-user-questions/client.js +1 -1
  122. package/app/web/plugins/deepseek-ai__dsh-client-ui-workspace/client.js +70 -70
  123. package/app/web/role-avatars/builtin/architect-otter.webp +0 -0
  124. package/app/web/role-avatars/builtin/audio-otter.webp +0 -0
  125. package/app/web/role-avatars/builtin/backend-otter.webp +0 -0
  126. package/app/web/role-avatars/builtin/classic-otter.webp +0 -0
  127. package/app/web/role-avatars/builtin/data-otter.webp +0 -0
  128. package/app/web/role-avatars/builtin/debugger-otter.webp +0 -0
  129. package/app/web/role-avatars/builtin/frontend-otter.webp +0 -0
  130. package/app/web/role-avatars/builtin/idea-otter.webp +0 -0
  131. package/app/web/role-avatars/builtin/ops-otter.webp +0 -0
  132. package/app/web/role-avatars/builtin/pm-otter.webp +0 -0
  133. package/app/web/role-avatars/builtin/researcher-otter.webp +0 -0
  134. package/app/web/role-avatars/builtin/reviewer-otter.webp +0 -0
  135. package/app/web/role-avatars/builtin/scholar-otter.webp +0 -0
  136. package/app/web/role-avatars/builtin/security-otter.webp +0 -0
  137. package/app/web/role-avatars/builtin/tester-otter.webp +0 -0
  138. package/app/web/role-avatars/builtin/writer-otter.webp +0 -0
  139. package/app/web-modules/node_modules/@deepseek-ai/dsh-host-webserver/index.js +7 -1
  140. package/app/web-modules/server.mjs +1324 -252
  141. package/bin/codexhost.exe +0 -0
  142. package/libexec/codexhost-node-repl.exe +0 -0
  143. package/libexec/codexhost-screenshot.exe +0 -0
  144. package/libexec/codexhost-shell.exe +0 -0
  145. package/libexec/codexhost-shim.exe +0 -0
  146. package/libexec/codexhost-updater.exe +0 -0
  147. package/package.json +1 -1
  148. package/app/web/assets/index-BLmkBEoq.js +0 -205
  149. package/app/web/assets/index-Dwdnvinl.css +0 -1
  150. package/app/web/assets/swimlanesDiagram-UCCPES4V-CNV63-us.js +0 -8
@@ -8,9 +8,9 @@ default:Me(this.#r)}}fail(){this.#d=this.#n,this.#r=`invalid`,this.#c=null}begin
8
8
  /* v8 ignore next -- an empty replacement never reads a Node reference. */
9
9
  ()=>void 0)}collectRootGroups(e){let t=/* @__PURE__ */ new Set;for(let n of e)if(n.kind===`group`){if(t.has(n.key))throw Error(`conversation group "${n.key}" has duplicate root references`);t.add(n.key)}return t}collectChanges(e){let t=/* @__PURE__ */ new Map,n=/* @__PURE__ */ new Set,r=e=>{if(t.has(e.key))throw Error(`conversation group "${e.key}" has duplicate upserts`);let n=this.groups.get(e.key);if(n===void 0){t.set(e.key,e);return}let r=He(n.members,e.members,Be);t.set(e.key,n.data===e.data&&n.members===r?n:{...e,members:r})};switch(e.groups.kind){case`replace`:for(let t of e.groups.snapshots)r(t);for(let e of this.groups.keys())t.has(e)||n.add(e);break;case`apply`:for(let t of e.groups.upserts)r(t);for(let r of e.groups.removes){if(n.has(r))throw Error(`conversation group "${r}" has duplicate removals`);if(!this.groups.has(r))throw Error(`conversation group "${r}" cannot be removed because it is absent`);if(t.has(r))throw Error(`conversation group "${r}" cannot be upserted and removed together`);n.add(r)}break;
10
10
  /* v8 ignore next 2 -- closed update union; TypeScript rejects other operation tags. */
11
- default:Me(e.groups)}return{upserts:t,removes:n}}},We=class{store;key;listeners=/* @__PURE__ */ new Set;published;constructor(e,t){this.store=e,this.key=t,this.published=e.get(t)}getSnapshot=()=>this.store.get(this.key);subscribe=e=>(this.listeners.add(e),()=>{this.listeners.delete(e)});publish(){let e=this.getSnapshot();this.published!==e&&(this.published=e,(0,f.notifySubscribers)(this.listeners,`[ui-conversation] Location data ${this.key}`))}},Ge=class{markDirty;entries=/* @__PURE__ */ new Map;sources=/* @__PURE__ */ new Map;dirtyKeys=/* @__PURE__ */ new Set;constructor(e){this.markDirty=e}get(e){return this.entries.get(e)?.value}source(e){let t=this.sources.get(e);return t===void 0&&(t=new We(this,e),this.sources.set(e,t)),t}remove(e,t){return this.entries.get(t)?.owner===e&&(this.entries.delete(t),this.changed(t),!0)}set(e,t,n){let r=this.entries.get(t);if(r!==void 0&&r.owner!==e)throw Error(`conversation Location data "${t}" is already owned by ${r.owner}`);return r?.value!==n&&(this.entries.set(t,{owner:e,value:n}),this.changed(t),!0)}replace(e){let t=[];for(let n of/* @__PURE__ */ new Set([...this.entries.keys(),...e.keys()])){let r=this.entries.get(n),i=e.get(n);(r?.owner!==i?.owner||r?.value!==i?.value)&&t.push(n)}if(t.length===0)return!1;this.entries=new Map(e);for(let e of t)this.changed(e);return!0}publish(){let e=[...this.dirtyKeys];this.dirtyKeys.clear();for(let t of e)this.sources.get(t)?.publish()}changed(e){this.dirtyKeys.add(e),this.markDirty(this)}};let Ke={kind:`session`},qe={kind:`unresolved`};function Je(e){let t=e.data;if(t.turn===null)return{session:!0,location:void 0};let n=Number.isSafeInteger(t.turn)&&t.turn>=0?t.turn:void 0,r=Number.isSafeInteger(t.step)&&t.step>=0?t.step:void 0;return n===void 0?r===void 0?{location:void 0}:{step:r,location:void 0}:r===void 0?{turn:n,location:void 0}:{turn:n,step:r,location:void 0}}function Ye(e,t){return e.length===t.length&&e.every((e,n)=>e===t[n])}function Xe(e,t){return e!==void 0&&e.start===t.start&&e.end===t.end&&e.status===t.status&&e.data===t.data}function Ze(e,t){return e!==void 0&&e.start===t.start&&e.end===t.end&&e.status===t.status&&e.data===t.data&&Ye(e.steps,t.steps)}function Qe(e,t){return e===void 0||t===void 0||e.kind!==t.kind?e===t:e.kind===`session`||e.kind===`unresolved`?!0:t.kind===`session`||t.kind===`unresolved`?!1:e.kind===`turn`||t.kind===`turn`?e.kind===`turn`&&t.kind===`turn`&&e.turn===t.turn:e.turn===t.turn&&e.step===t.step}var $e=class{coordinates=/* @__PURE__ */ new Map;eventKeysByTurn=/* @__PURE__ */ new Map;stepsByTurn=/* @__PURE__ */ new Map;timeline={turnOrder:[],turns:/* @__PURE__ */ new Map};turnDataStores=/* @__PURE__ */ new Map;stepDataStores=/* @__PURE__ */ new Map;dirtyDataStores=/* @__PURE__ */ new Set;changedTurns=/* @__PURE__ */ new Set;currentTurn;currentStep;snapshot(){return this.timeline}takeChangedTurns(){let e=[...this.changedTurns];return this.changedTurns.clear(),e}replaceData(e){let t=/* @__PURE__ */ new Map,n=/* @__PURE__ */ new Map;for(let{owner:r,data:i}of e){let e=i.kind===`turn`?t.get(i.turn)??/* @__PURE__ */ new Map:n.get(et(i.turn,tt(i)))??/* @__PURE__ */ new Map,a=e.get(i.key);if(a!==void 0&&a.owner!==r)throw Error(`conversation Location data "${i.key}" is already owned by ${a.owner}`);e.set(i.key,{owner:r,value:i.value}),i.kind===`turn`?t.set(i.turn,e):n.set(et(i.turn,tt(i)),e)}let r=!1;for(let e of/* @__PURE__ */ new Set([...this.turnDataStores.keys(),...t.keys()]))r=this.mutableTurnData(e).replace(t.get(e)??/* @__PURE__ */ new Map)||r;for(let e of/* @__PURE__ */ new Set([...this.stepDataStores.keys(),...n.keys()]))r=this.mutableStepData(e).replace(n.get(e)??/* @__PURE__ */ new Map)||r;return r}applyData(e){let t=!1;for(let n of e){let e=n.previous;e!==null&&(t=this.storeFor(e).remove(n.owner,e.key)||t)}for(let n of e){let e=n.next;e!==null&&(t=this.storeFor(e).set(n.owner,e.key,e.value)||t)}return t}publishData(){let e=[...this.dirtyDataStores];this.dirtyDataStores.clear();for(let t of e)t.publish()}locationOf(e){return this.coordinates.get(ze(e))?.location??Ke}rebuild(e){let t=this.coordinates,n=/* @__PURE__ */ new Map,r=/* @__PURE__ */ new Map,i,a,o=(e,t)=>{let r=n.get(e);return r===void 0?(r={turn:e,firstSeq:t,steps:/* @__PURE__ */ new Map},n.set(e,r)):r.firstSeq=Math.min(r.firstSeq,t),r},s=(e,t,n)=>{let r=o(e,n),i=r.steps.get(t);return i===void 0?(i={turn:e,step:t,firstSeq:n},r.steps.set(t,i)):i.firstSeq=Math.min(i.firstSeq,n),i};for(let{event:t}of e){let e=Je(t);t.type===`turn/start`&&(i=t.data.turn,a=void 0),t.type===`step/start`&&(i=t.data.turn,a=t.data.step),e.session!==!0&&e.turn!==void 0&&(i!==e.turn&&(a=void 0),i=e.turn,e.step!==void 0&&(a=e.step));let n=e.session===!0?void 0:e.turn??i,c=e.session===!0||t.type===`turn/start`||t.type===`turn/end`?void 0:e.step??(n===i?a:void 0);r.set(ze(t),{...n===void 0?{}:{turn:n},...n===void 0||c===void 0?{}:{step:c},location:void 0}),n!==void 0&&o(n,t.seq),n!==void 0&&c!==void 0&&s(n,c,t.seq),t.type===`turn/start`?o(t.data.turn,t.seq).start=t:t.type===`turn/end`?o(t.data.turn,t.seq).end=t:t.type===`step/start`?s(t.data.turn,t.data.step,t.seq).start=t:t.type===`step/end`&&(s(t.data.turn,t.data.step,t.seq).end=t),t.type===`step/end`&&i===t.data.turn&&a===t.data.step&&(a=void 0),t.type===`turn/end`&&i===t.data.turn&&(i=void 0,a=void 0)}let c=this.timeline.turns,l=/* @__PURE__ */ new Map,u=[...n.values()].sort((e,t)=>e.firstSeq-t.firstSeq);for(let e of u){let t=c.get(e.turn),n=new Map(t?.steps.map(e=>[e.step,e])??[]),r=[...e.steps.values()].sort((e,t)=>e.firstSeq-t.firstSeq).map(e=>{let t={turn:e.turn,step:e.step,start:e.start,end:e.end,status:e.end===void 0?e.start===void 0?`unknown`:`open`:`closed`,data:this.stepData(e.turn,e.step)},r=n.get(e.step);return Xe(r,t)?r:t}),i={turn:e.turn,start:e.start,end:e.end,status:e.end===void 0?e.start===void 0?`unknown`:`open`:`closed`,steps:r,data:this.turnData(e.turn)};l.set(e.turn,Ze(t,i)?t:i)}let d=u.map(e=>e.turn),f=this.timeline.turnOrder.length===d.length&&this.timeline.turnOrder.every((e,t)=>e===d[t])?this.timeline.turnOrder:d,p=c.size===l.size;if(p){for(let[e,t]of l)if(c.get(e)!==t){p=!1;break}}for(let e of/* @__PURE__ */ new Set([...c.keys(),...l.keys()]))c.get(e)!==l.get(e)&&this.changedTurns.add(e);this.timeline=p&&f===this.timeline.turnOrder?this.timeline:{turnOrder:f,turns:l},this.stepsByTurn.clear();for(let[e,t]of this.timeline.turns)this.stepsByTurn.set(e,new Map(t.steps.map(e=>[e.step,e])));this.coordinates=r,this.eventKeysByTurn=/* @__PURE__ */ new Map;for(let{event:t}of e){let e=ze(t),n=this.coordinates.get(e);n.turn!==void 0&&this.indexTurnEvent(n.turn,e),n.location=this.resolve(e)}this.currentTurn=i,this.currentStep=a;let m=/* @__PURE__ */ new Set;for(let{event:n}of e){let e=ze(n);Qe(t.get(e)?.location,this.coordinates.get(e)?.location)||m.add(e)}return m}appendBoundary(e){if(e.type!==`turn/start`&&e.type!==`turn/end`&&e.type!==`step/start`&&e.type!==`step/end`)throw Error(`conversation Location boundary expected, received ${e.type}`);let t=Je(e);e.type===`turn/start`?(this.currentTurn=e.data.turn,this.currentStep=void 0):e.type===`step/start`&&(this.currentTurn=e.data.turn,this.currentStep=e.data.step),t.turn!==void 0&&(this.currentTurn!==t.turn&&(this.currentStep=void 0),this.currentTurn=t.turn,t.step!==void 0&&(this.currentStep=t.step));let n=t.turn??this.currentTurn;if(n===void 0)throw Error(`conversation boundary ${e.type} has no turn`);let r=e.type===`turn/start`||e.type===`turn/end`?void 0:t.step??(n===this.currentTurn?this.currentStep:void 0);this.coordinates.set(e.seq,{turn:n,...r===void 0?{}:{step:r},location:this.coordinates.get(e.seq)?.location}),this.indexTurnEvent(n,e.seq);let i=this.timeline.turns.get(n),a=i?.steps??[];if(e.type===`step/start`||e.type===`step/end`){let t=e.data.step,r=this.stepsByTurn.get(n)??/* @__PURE__ */ new Map,i=r.get(t),o={turn:n,step:t,start:e.type===`step/start`?e:i?.start,end:e.type===`step/end`?e:i?.end,status:e.type===`step/end`||i?.end!==void 0?`closed`:`open`,data:this.stepData(n,t)},s=Xe(i,o)?i:o;r.set(t,s),this.stepsByTurn.set(n,r);let c=a.findIndex(e=>e.step===t);a=c<0?[...a,s]:a.map((e,t)=>t===c?s:e)}let o={turn:n,start:e.type===`turn/start`?e:i?.start,end:e.type===`turn/end`?e:i?.end,status:e.type===`turn/end`||i?.end!==void 0?`closed`:e.type===`turn/start`||i?.start!==void 0?`open`:`unknown`,steps:a,data:this.turnData(n)},s=Ze(i,o)?i:o,c=new Map(this.timeline.turns);c.set(n,s);let l=i===void 0?[...this.timeline.turnOrder,n]:this.timeline.turnOrder;this.timeline={turnOrder:l,turns:c},s!==i&&this.changedTurns.add(n);let u=/* @__PURE__ */ new Set;for(let e of this.eventKeysByTurn.get(n)??[]){let t=this.coordinates.get(e),n=t.location,r=this.resolve(e);t.location=r,Qe(n,r)||u.add(e)}return e.type===`step/end`&&this.currentTurn===e.data.turn&&this.currentStep===e.data.step&&(this.currentStep=void 0),e.type===`turn/end`&&this.currentTurn===e.data.turn&&(this.currentTurn=void 0,this.currentStep=void 0),u}appendNonBoundary(e){let t=ze(e),n=Je(e);if(n.session===!0){this.coordinates.set(t,{location:Ke});return}n.turn!==void 0&&(this.currentTurn!==n.turn&&(this.currentStep=void 0),this.currentTurn=n.turn,n.step!==void 0&&(this.currentStep=n.step));let r=n.turn??this.currentTurn,i=n.step??(r===this.currentTurn?this.currentStep:void 0),a=n.turn!==void 0&&n.step!==void 0?n:{...r===void 0?{}:{turn:r},...r===void 0||i===void 0?{}:{step:i},location:void 0};this.coordinates.set(t,a),r!==void 0&&this.indexTurnEvent(r,t),a.location=this.resolve(t)}removeAssistantTransients(e){for(let t of e){let e=ze(t),n=this.coordinates.get(e)?.turn;if(n!==void 0){let t=this.eventKeysByTurn.get(n);t?.delete(e),t?.size===0&&this.eventKeysByTurn.delete(n)}this.coordinates.delete(e)}}insertAssistantSettlement(e){let t={turn:e.data.turn,step:e.data.step,location:void 0};this.coordinates.set(e.seq,t),this.indexTurnEvent(e.data.turn,e.seq),t.location=this.resolve(e.seq)}indexTurnEvent(e,t){let n=this.eventKeysByTurn.get(e);n===void 0&&(n=/* @__PURE__ */ new Set,this.eventKeysByTurn.set(e,n)),n.add(t)}turnData(e){return this.mutableTurnData(e)}stepData(e,t){return this.mutableStepData(et(e,t))}mutableTurnData(e){let t=this.turnDataStores.get(e)??this.createDataStore(e);return this.turnDataStores.set(e,t),t}mutableStepData(e){let t=this.stepDataStores.get(e)??this.createDataStore(Number(e.slice(0,e.indexOf(`:`))));return this.stepDataStores.set(e,t),t}createDataStore(e){return new Ge(t=>{this.dirtyDataStores.add(t),this.changedTurns.add(e)})}storeFor(e){return e.kind===`turn`?this.mutableTurnData(e.turn):this.mutableStepData(et(e.turn,tt(e)))}resolve(e){let t=this.coordinates.get(e);if(t?.turn===void 0)return Ke;let n=this.timeline.turns.get(t.turn);if(n===void 0)return qe;if(t.step===void 0)return{kind:`turn`,turn:n};let r=this.stepsByTurn.get(t.turn)?.get(t.step);return r===void 0?{kind:`turn`,turn:n}:{kind:`step`,turn:n,step:r}}};function et(e,t){return`${e}:${t}`}function tt(e){if(e.kind===`step`&&e.step!==void 0)return e.step;throw Error(`conversation Step data "${e.key}" requires a step`)}let nt={none:0,"animation-frame":1,immediate:2},rt=[`step`,`turn`];function it(){return{step:null,turn:null}}function at(e,t){return nt[e]>=nt[t]?e:t}function ot(e,t){return e.start===void 0?t.start===void 0?0:1:t.start===void 0?-1:C(e.start.event,t.start.event)}function st(e,t){let n=0,r=e.length;for(;n<r;){let i=n+Math.floor((r-n)/2),a=e[i]?.start;a!==void 0&&C(a.event,t)<0?n=i+1:r=i}return n}function ct(e){return{key:e.key,kind:e.kind,id:e.id,matches:e.matches,start:e.start,state:e.state,current:e.current}}function lt(e,t,n){let r=[],i=0,a=0;for(;i<t.length||a<n.length;){let o=t[i],s=n[a],c=o===void 0?1:s===void 0?-1:C(o.event,s.event);if(c===0)throw Error(`conversation Context ${e} received duplicate Match ${o?.event.seq}`);c<0?(r.push(o),i++):(r.push(s),a++)}return r}function ut(e,t,n){return{event:e.event,role:t,location:n}}let dt={entries:()=>[],forTarget:()=>void 0};var ft=class{eventDefinitions;viewDefinitions;groupDefinitions;contexts=/* @__PURE__ */ new Map;contextsByKind=/* @__PURE__ */ new Map;contextsByEventKey=/* @__PURE__ */ new Map;contextsByTarget=/* @__PURE__ */ new Map;inputs=/* @__PURE__ */ new Map;locationIndex=new $e;dirty=/* @__PURE__ */ new Set;dirtyByTarget=/* @__PURE__ */ new Map;revised=/* @__PURE__ */ new Set;dependents=/* @__PURE__ */ new Map;views=/* @__PURE__ */ new Map;groups=/* @__PURE__ */ new Map;pendingGroupStores=/* @__PURE__ */ new Set;activeTargets=/* @__PURE__ */ new Set;hasMore=!1;replacePending=!0;timelineDirty=!0;constructor(e,t,n=dt){this.eventDefinitions=e,this.viewDefinitions=t,this.groupDefinitions=n,this.resetViewBuilders()}openTurn(){let e=this.locationIndex.snapshot(),t=e.turnOrder.at(-1),n=t===void 0?void 0:e.turns.get(t);return n?.status===`open`&&n.start!==void 0?n.turn:void 0}replaceWindow(e,t){this.contexts.clear(),this.contextsByKind.clear(),this.contextsByEventKey.clear(),this.contextsByTarget.clear(),this.inputs.clear(),this.dirty.clear(),this.dirtyByTarget.clear(),this.revised.clear(),this.dependents.clear(),this.hasMore=t;let n=[...e].sort((e,t)=>C(e.event,t.event));for(let e of n)this.inputs.set(ze(e.event),e);this.locationIndex.rebuild(n),this.timelineDirty=!0;for(let e of n)this.matchInput(e);this.replayDependencies(),this.revised.clear();for(let e of this.contexts.values())this.markDirty(e);return this.replacePending=!0,`immediate`}append(e){let t=e.event,n=ze(t);if(this.inputs.has(n))return`none`;this.revised.size>0&&this.revised.clear(),this.inputs.set(n,e);let r=`none`;if(t.type!==`assistant/live-chunk`&&pt(t.type)){let e=this.locationIndex.snapshot(),n=this.locationIndex.appendBoundary(t);this.locationIndex.snapshot()!==e&&(this.timelineDirty=!0,r=`immediate`),this.replayContexts(this.refreshMatchLocations(n)),n.size>0&&(r=`immediate`)}else this.locationIndex.appendNonBoundary(t);return r=at(r,this.matchInput(e)),this.replayRevisedDependents()&&(r=`immediate`),this.revised.size>0&&this.revised.clear(),r}settleAssistant(e,t){this.revised.clear();let n=[...this.inputs.values()].filter(t=>t.type===`transient`&&t.event.data.attemptId===e),r=new Set(n.map(e=>ze(e.event))),i=/* @__PURE__ */ new Set;for(let e of r){this.inputs.delete(e);for(let t of this.contextsByEventKey.get(e)??[])i.add(t);this.contextsByEventKey.delete(e)}for(let e of i)e.matches=e.matches.filter(e=>!r.has(ze(e.event)));this.locationIndex.removeAssistantTransients(n.map(e=>e.event));let a=n.length===0?`none`:`immediate`;if(t!==void 0&&!this.inputs.has(t.event.seq)){this.inputs.set(t.event.seq,t),this.locationIndex.insertAssistantSettlement(t.event);let e=/* @__PURE__ */ new Map;a=at(a,this.collectInput(t,e)),this.applyPendingMatches(e,i)}return this.replayContexts(i),this.replayRevisedDependents()&&(a=`immediate`),this.revised.clear(),a}prepend(e,t){this.revised.clear();let n=`none`,r=this.hasMore,i=e.filter(e=>!this.inputs.has(ze(e.event))).sort((e,t)=>C(e.event,t.event));for(let e of i)this.inputs.set(ze(e.event),e);this.hasMore=t;let a=this.locationIndex.snapshot(),o=this.locationIndex.rebuild(this.sortedInputs());this.locationIndex.snapshot()!==a&&(this.timelineDirty=!0);let s=this.refreshMatchLocations(o),c=/* @__PURE__ */ new Map;for(let e of i)n=at(n,this.collectInput(e,c));return this.applyPendingMatches(c,s),this.replayContexts(s),(this.revised.size>0||r!==t)&&this.replayDependencies()&&(n=`immediate`),o.size>0&&(n=`immediate`),this.revised.clear(),n}rebuildRegistry(){return this.resetViewBuilders(),this.replaceWindow(this.sortedInputs(),this.hasMore)}flush(){if(!this.replacePending&&this.dirty.size===0&&!this.timelineDirty)return!1;if(this.replacePending){this.replaceLocationData();let e=[],t=this.locationIndex.takeChangedTurns();for(let n of this.activeTargets){let r=this.views.get(n);r!==void 0&&(this.updateView(r,!0,this.buildTargetNodes(n,this.contextsByTarget.get(n)),t),e.push(r))}return this.replacePending=!1,this.dirty.clear(),this.dirtyByTarget.clear(),this.timelineDirty=!1,this.publishViews(e)}let e=[];this.applyDirtyLocationData()&&(this.timelineDirty=!0);let t=this.locationIndex.takeChangedTurns(),n=this.timelineDirty;for(let r of this.activeTargets){let i=this.views.get(r);if(i===void 0||i.builder===void 0)continue;let a=this.buildTargetUpserts(r,this.dirtyByTarget.get(r));(a.length!==0||n)&&(this.updateView(i,!1,a,t),e.push(i))}return this.dirty.clear(),this.dirtyByTarget.clear(),this.timelineDirty=!1,this.publishViews(e)}activateTarget(e){let t=this.views.get(e);if(this.activeTargets.has(e))return!1;let n=this.flush();return this.activeTargets.add(e),t===void 0?n:(this.replaceView(t),this.publishViews([t]),!0)}snapshot(e){return this.views.get(e)?.snapshot}get(e){return this.snapshot(e)}grouped(e){return this.groups.get(e)?.store}activityTargets(){let e=/* @__PURE__ */ new Set;for(let t of this.activeTargets){let n=this.views.get(t);n!==void 0&&n.isActive?.(n.snapshot)===!0&&e.add(n.target)}return e}sortedInputs(){return[...this.inputs.values()].sort((e,t)=>C(e.event,t.event))}matchInput(e){return this.dispatchInput(e,this.acceptMatch)}collectInput(e,t){return this.dispatchInput(e,(e,n,r)=>{let i=Re(e.kind,n),a=t.get(i)??[];return a.push({definition:e,id:n,match:r}),t.set(i,a),e.publication?.(r)??`immediate`})}dispatchInput(e,t){let n=e.event,r,i,a,o=t=>(a??=this.locationIndex.locationOf(n),t===`start`?r??=ut(e,t,a):i??=ut(e,t,a)),s,c,l,u=`none`,d=this.eventDefinitions.forEvent?.(n.type);if(d===void 0)for(let e of this.eventDefinitions.entries()){let r=e.match(n);r!==null&&(e.target!==void 0&&e.target!==s&&e.target!==c&&(s===void 0?s=e.target:c===void 0?c=e.target:(l??=/* @__PURE__ */ new Set).add(e.target)),u=at(u,t.call(this,e,r.id,o(r.role))))}else for(let{definition:e,match:r}of d){let i=r(n);i!==null&&(e.target!==void 0&&e.target!==s&&e.target!==c&&(s===void 0?s=e.target:c===void 0?c=e.target:(l??=/* @__PURE__ */ new Set).add(e.target)),u=at(u,t.call(this,e,i.id,o(i.role))))}let f=this.eventDefinitions.fallbackEntry(),p=f?.target;if(f!==void 0&&p!==void 0&&p!==s&&p!==c&&l?.has(p)!==!0){let e=f.match(n);e!==null&&(u=at(u,t.call(this,f,e.id,o(e.role))))}return u}createContext(e,t,n){let r={key:n,kind:e.kind,id:t,definition:e,start:void 0,matches:[],state:void 0,revision:0,current:/* @__PURE__ */ new Map,locationData:it(),dependencies:/* @__PURE__ */ new Map};return this.contexts.set(n,r),this.indexTargetContext(r),r}acceptMatch(e,t,n){let r=this.contextsByKind.get(e.kind)?.at(-1),i=r?.id===t?r.key:Re(e.kind,t),a=this.contexts.get(i);a??=this.createContext(e,t,i);let o=n.role===`start`&&a.start===void 0,s=a.matches.at(-1);if(s!==void 0&&C(s.event,n.event)>=0)throw Error(`conversation Context ${i} received non-appended Match ${n.event.seq}`);if(o&&a.matches.length>0)throw Error(`conversation Context ${i} received an update before its start Match`);if(a.matches.push(n),o&&(a.start=n,this.indexStartedContext(a)),this.indexMatch(a,n),o)this.replayContext(a);else if(a.state!==void 0){let t=ct(a);a.state=mt(e,`update`,e.update(t,n)),a.revision++,this.revised.add(a)}return this.markDirty(a),e.publication?.(n)??`immediate`}indexMatch(e,t){let n=ze(t.event),r=this.contextsByEventKey.get(n);r===void 0&&(r=[],this.contextsByEventKey.set(n,r)),r.push(e)}applyPendingMatches(e,t){for(let[n,r]of e){let e=r[0];if(e===void 0)continue;let i=this.contexts.get(n);i??=this.createContext(e.definition,e.id,n);let a=r.map(e=>{if(e.definition!==i.definition||e.id!==i.id)throw Error(`conversation Context ${n} received inconsistent Definition identity`);return this.indexMatch(i,e.match),e.match}).sort((e,t)=>C(e.event,t.event));i.matches=lt(i.key,a,i.matches),t.add(i),this.markDirty(i)}}replayContexts(e){this.refreshStarts(e);let t=[...e].sort(ot);for(let e of t)e.start===void 0?(e.state=void 0,this.replaceDependencies(e,/* @__PURE__ */ new Map),e.revision++,this.revised.add(e),this.markDirty(e)):this.replayContext(e)}refreshStarts(e){let t=/* @__PURE__ */ new Set,n=/* @__PURE__ */ new Map;for(let r of e){let e=r.matches.find(e=>e.role===`start`);if(e===r.start)continue;r.start=e,t.add(r);let i=n.get(r.kind)??[];e!==void 0&&i.push(r),n.set(r.kind,i)}for(let[e,r]of n){let n=this.contextsByKind.get(e)??[];this.contextsByKind.set(e,n.filter(e=>!t.has(e))),this.indexStartedContexts(e,r)}}replayContext(e){let t=e.start;if(t===void 0){e.state=void 0;return}if(e.matches[0]!==t)throw Error(`conversation Context ${e.key} received an update before its start Match`);let n=/* @__PURE__ */ new Map,r=this.readerFor(t.event,n);e.state=void 0,e.state=mt(e.definition,`start`,e.definition.start(ct(e),t,r)),this.replaceDependencies(e,n);for(let t=1;t<e.matches.length;t++){let n=e.matches[t];if(n===void 0)continue;let r=ct(e);e.state=mt(e.definition,`update`,e.definition.update(r,n))}e.revision++,this.revised.add(e),this.markDirty(e)}indexTargetContext(e){let t=e.definition.target;if(t===void 0)return;let n=this.contextsByTarget.get(t)??/* @__PURE__ */ new Set;n.add(e),this.contextsByTarget.set(t,n)}markDirty(e){if(this.dirty.has(e))return;this.dirty.add(e);let t=e.definition.target;if(t===void 0||!this.activeTargets.has(t))return;let n=this.dirtyByTarget.get(t);n===void 0&&(n=/* @__PURE__ */ new Set,this.dirtyByTarget.set(t,n)),n.add(e)}replaceDependencies(e,t){for(let t of e.dependencies.values()){if(t.key===void 0)continue;let n=this.dependents.get(t.key);n?.delete(e),n?.size===0&&this.dependents.delete(t.key)}e.dependencies=t;for(let n of t.values()){if(n.key===void 0)continue;let t=this.dependents.get(n.key)??/* @__PURE__ */ new Set;t.add(e),this.dependents.set(n.key,t)}}replayRevisedDependents(){if(this.dependents.size===0)return!1;let e=[...this.revised],t=/* @__PURE__ */ new Set;for(let n=0;n<e.length;n++){let r=e[n];if(r!==void 0)for(let n of this.dependents.get(r.key)??[])t.has(n)||(t.add(n),e.push(n))}return t.size>0&&this.replayContexts(t),t.size>0}readerFor(e,t){return{previous:n=>{let r=this.previousContext(n,e);if(t.set(n,{kind:n,key:r?.key,revision:r?.revision,windowGap:r===void 0&&this.hasMore}),r?.state===void 0)return;let i=r.start?.event.seq;if(i!==void 0)return{key:r.key,kind:r.kind,id:r.id,startSeq:i,state:r.state,matches:r.matches}}}}previousContext(e,t){let n=this.contextsByKind.get(e)??[],r=st(n,t);for(let e=r-1;e>=0;e--){let t=n[e];if(t?.state!==void 0)return t}}indexStartedContext(e){let t=e.start;if(t===void 0)return;let n=this.contextsByKind.get(e.kind)??[],r=n.at(-1);r===void 0||ot(r,e)<0?n.push(e):n.splice(st(n,t.event),0,e),this.contextsByKind.set(e.kind,n)}indexStartedContexts(e,t){if(t.length===0)return;let n=[...t].sort(ot),r=this.contextsByKind.get(e)??[],i=[],a=0,o=0;for(;a<r.length||o<n.length;){let e=r[a],t=n[o];t===void 0||e!==void 0&&ot(e,t)<0?(i.push(e),a++):(i.push(t),o++)}this.contextsByKind.set(e,i)}replayDependencies(){let e=!1,t=[...this.contexts.values()].filter(e=>e.start!==void 0).sort(ot);for(let n of t){if(n.state===void 0||n.dependencies.size===0)continue;let t=n.start?.event;if(t===void 0)continue;let r=!1;for(let e of n.dependencies.values()){let n=this.previousContext(e.kind,t),i=n===void 0&&this.hasMore;if(n?.key!==e.key||n?.revision!==e.revision||i!==e.windowGap){r=!0;break}}r&&(this.replayContext(n),e=!0)}return e}refreshMatchLocations(e){let t=/* @__PURE__ */ new Set;if(e.size===0)return t;for(let n of e)for(let e of this.contextsByEventKey.get(n)??[])t.add(e);for(let n of t){let t=n.start;n.matches=n.matches.map(n=>{if(!e.has(ze(n.event)))return n;if(n.role===`start`){let e={...n,location:this.locationIndex.locationOf(n.event)};return n===t&&(t=e),e}return{...n,location:this.locationIndex.locationOf(n.event)}}),n.start=t}return t}buildNode(e,t){if(e.definition.target!==t||e.definition.buildViewNode===void 0)return null;let n=e.definition.buildViewNode(ct(e));if(n===null)return null;if(n.key!==e.key)throw Error(`conversation Definition "${e.kind}" returned unstable key "${n.key}"; expected "${e.key}"`);if(n.target!==t)throw Error(`conversation Definition "${e.kind}" returned target "${n.target}" while building "${t}"`);return n}replaceView(e){this.updateView(e,!0,this.buildTargetNodes(e.target,this.contextsByTarget.get(e.target)),[])}updateView(e,t,n,r){let i=e.builder??e.definition.create(),a=e.groupDefinition;if(a!==void 0&&i.groupInput===void 0)throw Error(`conversation group target "${e.target}" requires builder.groupInput()`);e.builder=i;let o=this.locationIndex.snapshot(),s=t?i.replace({nodes:n,timeline:o,changedTurns:r}):i.apply({upserts:n,timeline:o,changedTurns:r});if(a!==void 0&&i.groupInput!==void 0){let t=this.groups.get(e.target),n=t===void 0;t===void 0&&(t={definition:a,state:a.create(),store:new Ue});let r=i.groupInput();t.state=a.update(t,r);let o=a.buildGroups(t);if((n||r.kind===`replace`)&&(o===null||o.entries===void 0||o.groups.kind!==`replace`))throw Error(`conversation group target "${e.target}" requires complete grouping for replacement input`);o!==null&&(t.store.prepareAndInstall(o,r.readNode),this.pendingGroupStores.add(t.store)),this.groups.set(e.target,t)}e.snapshot=s}publishViews(e){let t=e.length>0||this.pendingGroupStores.size>0,n=[...this.pendingGroupStores];this.pendingGroupStores.clear();for(let t of e)t.builder?.publish?.();for(let e of n)e.publish();return this.locationIndex.publishData(),t}buildTargetNodes(e,t){let n=[];for(let r of t??[]){let t=this.buildNode(r,e);r.current.set(e,t),t!==null&&n.push(t)}return n}buildTargetUpserts(e,t){let n=[];for(let r of t??[]){let t=r.current.get(e)??null,i=this.buildNode(r,e);if(i===null&&t!==null)throw Error(`conversation Definition "${r.kind}" withdrew materialized target "${e}"; return the same key with hidden visibility instead`);r.current.set(e,i),i!==null&&n.push(i)}return n}buildLocationData(e,t,n){if(e.definition.buildLocationData===void 0)return null;let r=e.definition.buildLocationData(ct(e),t,n);if(r===null)return null;if(r.kind!==t)throw Error(`conversation Definition "${e.kind}" published ${r.kind} data through its ${t} scope`);if(r.key!==e.kind)throw Error(`conversation Definition "${e.kind}" published Location data key "${r.key}"; expected its owned kind`);if(!Number.isSafeInteger(r.turn)||r.turn<0)throw Error(`conversation Definition "${e.kind}" published invalid turn ${r.turn}`);if(r.kind===`step`&&(!Number.isSafeInteger(r.step)||r.step<0))throw Error(`conversation Definition "${e.kind}" published invalid step ${String(r.step)}`);return r}replaceLocationData(){let e=[];for(let t of rt){for(let n of this.contexts.values()){let r=this.buildLocationData(n,t,n.locationData[t]);n.locationData[t]=r,r!==null&&e.push({owner:n.key,data:r})}this.locationIndex.replaceData(e)}}applyDirtyLocationData(){let e=!1;for(let t of rt){let n=[];for(let e of this.dirty){let r=e.locationData[t],i=this.buildLocationData(e,t,r);r!==i&&(e.locationData[t]=i,n.push({owner:e.key,previous:r,next:i}))}e=this.locationIndex.applyData(n)||e}return e}resetViewBuilders(){let e=this.viewDefinitions.entries(),t=new Set(e.map(e=>e.target));for(let[e,n]of this.groups)(!t.has(e)||this.groupDefinitions.forTarget(e)!==n.definition)&&(n.store.clear(),this.pendingGroupStores.add(n.store),this.groups.delete(e));this.views.clear();for(let t of e){let e={target:t.target,definition:t,groupDefinition:this.groupDefinitions.forTarget(t.target),isActive:t.isActive===void 0?void 0:e=>t.isActive?.(e)===!0,builder:void 0,snapshot:void 0};this.views.set(t.target,e)}this.replacePending=!0}};function pt(e){return e===`turn/start`||e===`turn/end`||e===`step/start`||e===`step/end`}function mt(e,t,n){if(n===void 0)throw Error(`conversation Definition "${e.kind}" returned undefined from ${t}()`);return n}var ht=class{ctx;definitions=/* @__PURE__ */ new Map;listeners=/* @__PURE__ */ new Set;cached=[];constructor(e){this.ctx=e,Object.defineProperty(this,m.Service.tracker,{value:{property:`ctx`}})}entries(){return this.cached}subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}registerDefinition(e,t,n,r){if(this.definitions.has(e))throw Error(n);let i=this.ctx.effect(()=>(this.definitions.set(e,t),this.refresh(),()=>{this.definitions.get(e)===t&&(this.definitions.delete(e),this.refresh())}),r);return()=>{i()}}refresh(){this.cached=[...this.definitions.values()],(0,f.notifySubscribers)(this.listeners,`[ui-conversation] definition registry`)}},gt=class extends ht{fallback;routes=/* @__PURE__ */ new Map;unrestricted=/* @__PURE__ */ new Set;tables=/* @__PURE__ */ new WeakMap;register(e){return _t(e),this.registerDefinition(e.kind,this.resolve(e),`conversation Definition "${e.kind}" is already registered`,`uiConversation.events.register(${JSON.stringify(e.kind)})`)}registerFallback(e){if(_t(e),e.target===void 0)throw Error(`conversation fallback Definition must declare a target`);if(this.fallback!==void 0)throw Error(`conversation fallback Definition is already registered`);let t=this.resolve(e),n=this.ctx.effect(()=>(this.fallback=t,this.refresh(),()=>{this.fallback===t&&(this.fallback=void 0,this.refresh())}),`uiConversation.events.registerFallback(${JSON.stringify(t.kind)})`);return()=>{n()}}fallbackEntry(){return this.fallback}forEvent(e){return this.routes.get(e)??this.unrestricted}resolve(e){if(typeof e.match==`function`)return e;let t=new Map(Object.entries(e.match)),n={...e,match:e=>t.get(e.type)?.call(n,e)??null};return this.tables.set(n,t),n}refresh(){let e=/* @__PURE__ */ new Map,t=/* @__PURE__ */ new Set;for(let n of this.definitions.values()){let r=this.tables.get(n);if(r===void 0){let r={definition:n,match:n.match.bind(n)};t.add(r);for(let t of e.values())t.add(r)}else for(let[i,a]of r){let r=e.get(i);r===void 0&&(r=new Set(t),e.set(i,r)),r.add({definition:n,match:a.bind(n)})}}this.routes=e,this.unrestricted=t,super.refresh()}};function _t(e){if(e.target===void 0!=(e.buildViewNode===void 0))throw Error(`conversation Definition "${e.kind}" must declare target and buildViewNode together`)}function vt(e){let t=``,n=32768;for(let r=0;r<e.length;r+=n)t+=String.fromCharCode(...e.subarray(r,r+n));return btoa(t)}function yt(){let e=globalThis.crypto.getRandomValues(/* @__PURE__ */ new Uint8Array(16)),t=Array.from(e,(e,t)=>(t===6?e&15|64:t===8?e&63|128:e).toString(16).padStart(2,`0`)).join(``);return`${t.slice(0,8)}-${t.slice(8,12)}-${t.slice(12,16)}-${t.slice(16,20)}-${t.slice(20)}`}var bt=class{sessions;maxEntries;maxBytes;maxDecodedBytes;lru=/* @__PURE__ */ new Set;byKey=/* @__PURE__ */ new Map;byLeaf=/* @__PURE__ */ new Map;byNameBytes=/* @__PURE__ */ new Map;byPendingName=/* @__PURE__ */ new Map;inflight=/* @__PURE__ */ new Map;urls=/* @__PURE__ */ new Set;totalBytes=0;totalDecodedBytes=0;disposed=!1;constructor(e,t,n={}){this.sessions=t,this.maxEntries=Math.max(1,Math.floor(n.maxEntries??20)),this.maxBytes=Math.max(1,Math.floor(n.maxBytes??25165824)),this.maxDecodedBytes=Math.max(1,Math.floor(n.maxDecodedBytes??100663296)),e.effect(()=>()=>{this.dispose()},`ui-conversation historical image cache`)}resolve(e,t){if(this.disposed)return Promise.reject(/* @__PURE__ */ Error(`ui-conversation image cache is disposed`));let n=this.sessions.binding(e);if(n===void 0)return Promise.reject(/* @__PURE__ */ Error(`ui-conversation: unknown session "${e}"`));let r=this.lookup(e,t,!0);if(r!==void 0)return Promise.resolve(r.url);let i=xt(e,t.attachmentId),a=this.inflight.get(i);if(a!==void 0)return a;let o=n.session.readAttachment(t.attachmentId).then(e=>{if(!e.ok)throw Object.assign(Error(e.error.message),e.error);if(this.disposed)throw Error(`ui-conversation image cache was disposed before loading completed`);let n=this.byKey.get(i);if(n!==void 0)return this.touch(n),n.url;let r;r=typeof URL.createObjectURL==`function`?URL.createObjectURL(new Blob([Ot(e.value.data)],{type:e.value.attachment.mediaType})):`data:${e.value.attachment.mediaType};base64,${vt(e.value.data)}`;let a=Tt(e.value.data.byteLength),o=Dt(a,e.value.attachment.width??t.width,e.value.attachment.height??t.height);return this.insertRecord(i,r,a,o).url}).finally(()=>{this.inflight.get(i)===o&&this.inflight.delete(i)});return this.inflight.set(i,o),o}peek(e,t){if(!(this.disposed||this.sessions.binding(e)===void 0))return this.lookup(e,t,!0)?.url}cacheUploaded(e,t){if(this.disposed||this.sessions.binding(e)===void 0||typeof URL.createObjectURL!=`function`)return!1;let n=xt(e,t.attachmentId),r=Tt(t.bytes??t.blob.size),i=this.byKey.get(n);if(i!==void 0)return this.touch(i),this.indexUploadedFallbacks(e,t.attachmentId,t.name,r,i),!0;let a=URL.createObjectURL(t.blob),o=Dt(r,t.width,t.height),s=this.insertRecord(n,a,r,o);return this.indexUploadedFallbacks(e,t.attachmentId,t.name,r,s),!0}aliasUploaded(e,t,n){if(this.disposed||this.sessions.binding(e)===void 0)return!1;let r=this.byKey.get(xt(e,t));return r!==void 0&&(this.bindKey(xt(e,n.attachmentId),r),this.clearPendingNameIndexes(r),this.touch(r),!0)}clearPendingUploaded(e,t){if(this.disposed)return;let n=this.byKey.get(xt(e,t));n!==void 0&&this.clearPendingNameIndexes(n)}seed(e,t,n,r){if(this.disposed||this.sessions.binding(e)===void 0)return!1;let i=xt(e,t.attachmentId),a=this.byKey.get(i);if(a!==void 0)return this.touch(a),!1;let o=Tt(r??t.bytes),s=Dt(o,t.width,t.height);return this.insertRecord(i,n,o,s),!0}lookup(e,t,n){let r=xt(e,t.attachmentId),i=this.byKey.get(r);if(i!==void 0)return this.touch(i),i;let a=this.findUploadedFallback(e,t);if(a!==void 0)return n&&(this.bindKey(r,a.record),a.consumedPendingName&&this.clearPendingNameIndexes(a.record)),this.touch(a.record),a.record}findUploadedFallback(e,t){let n=t.name;if(n===void 0||n===``)return;let r=this.byLeaf.get(St(e,n));if(r!==void 0)return{record:r,consumedPendingName:!0};let i=Tt(t.bytes);if(i>0){let t=jt(this.byNameBytes.get(Ct(e,n,i)));if(t!==void 0)return{record:t,consumedPendingName:!0}}if(i===0){let t=jt(this.byPendingName.get(wt(e,n)));if(t!==void 0)return{record:t,consumedPendingName:!0}}}indexUploadedFallbacks(e,t,n,r,i){if(t.startsWith(`web-image:`)){let n=t.slice(10);if(n!==``){let t=St(e,n);this.byLeaf.set(t,i),i.leafKeys.add(t)}}if(n!==void 0&&n!==``){if(r>0){let t=Ct(e,n,r);kt(this.byNameBytes,t,i),i.nameBytesKeys.add(t)}let t=wt(e,n);kt(this.byPendingName,t,i),i.pendingNameKeys.add(t)}}insertRecord(e,t,n,r){let i={url:t,bytes:n,decodedBytes:r,keys:/* @__PURE__ */ new Set([e]),leafKeys:/* @__PURE__ */ new Set,nameBytesKeys:/* @__PURE__ */ new Set,pendingNameKeys:/* @__PURE__ */ new Set};return this.urls.add(t),this.byKey.set(e,i),this.lru.add(i),this.totalBytes+=n,this.totalDecodedBytes+=r,this.enforceBudget(i),i}bindKey(e,t){let n=this.byKey.get(e);n!==t&&(n!==void 0&&(n.keys.delete(e),n.keys.size===0&&this.deleteRecord(n)),this.byKey.set(e,t),t.keys.add(e))}touch(e){this.lru.delete(e)&&this.lru.add(e)}enforceBudget(e){for(let t of this.lru){if(this.lru.size<=this.maxEntries&&this.totalBytes<=this.maxBytes&&this.totalDecodedBytes<=this.maxDecodedBytes)break;t!==e&&this.deleteRecord(t)}}clearPendingNameIndexes(e){for(let t of e.pendingNameKeys)At(this.byPendingName,t,e);e.pendingNameKeys.clear()}deleteRecord(e){if(this.lru.delete(e)){this.totalBytes=Math.max(0,this.totalBytes-e.bytes),this.totalDecodedBytes=Math.max(0,this.totalDecodedBytes-e.decodedBytes);for(let t of e.keys)this.byKey.get(t)===e&&this.byKey.delete(t);e.keys.clear();for(let t of e.leafKeys)this.byLeaf.get(t)===e&&this.byLeaf.delete(t);e.leafKeys.clear();for(let t of e.nameBytesKeys)At(this.byNameBytes,t,e);e.nameBytesKeys.clear(),this.clearPendingNameIndexes(e),this.releaseUrl(e.url)}}releaseUrl(e){this.urls.delete(e)&&Mt(e)}dispose(){if(!this.disposed){this.disposed=!0,this.inflight.clear();for(let e of this.urls)Mt(e);this.urls.clear(),this.lru.clear(),this.byKey.clear(),this.byLeaf.clear(),this.byNameBytes.clear(),this.byPendingName.clear(),this.totalBytes=0,this.totalDecodedBytes=0}}};function xt(e,t){return`${e}\0${t}`}function St(e,t){return`${e}\0${t}`}function Ct(e,t,n){return`${e}\0${n}\0${t}`}function wt(e,t){return`${e}\0${t}`}function Tt(e){return typeof e==`number`&&Number.isFinite(e)&&e>0?Math.floor(e):0}function Et(e){return typeof e==`number`&&Number.isFinite(e)&&e>0?Math.floor(e):void 0}function Dt(e,t,n){let r=Et(t),i=Et(n);return r!==void 0&&i!==void 0?Math.min(2**53-1,r*i*4):e*8}function Ot(e){return e.buffer instanceof ArrayBuffer?e.byteOffset===0&&e.byteLength===e.buffer.byteLength?e.buffer:new Uint8Array(e.buffer,e.byteOffset,e.byteLength):Uint8Array.from(e)}function kt(e,t,n){let r=e.get(t);r===void 0&&(r=/* @__PURE__ */ new Set,e.set(t,r)),r.add(n)}function At(e,t,n){let r=e.get(t);r!==void 0&&(r.delete(n),r.size===0&&e.delete(t))}function jt(e){if(e!==void 0&&e.size===1)return e.values().next().value}function Mt(e){e.startsWith(`blob:`)&&URL.revokeObjectURL(e)}var Nt=class extends ht{register(e){return this.registerDefinition(e.target,e,`conversation view target "${e.target}" is already registered`,`uiConversation.views.register(${JSON.stringify(e.target)})`)}},Pt=class extends ht{views;constructor(e,t){super(e),this.views=t}register(e){if(!this.views.entries().some(t=>t.target===e.target))throw Error(`conversation group target "${e.target}" is not registered`);return this.registerDefinition(e.target,e,`conversation group target "${e.target}" is already registered`,`uiConversation.groups.register(${JSON.stringify(e.target)})`)}forTarget(e){return this.definitions.get(e)}};let Ft=`codexhost:window-hidden-change`;function It(e){let t=e?.detail;if(typeof t?.hidden==`boolean`)return t.hidden;let n=typeof window<`u`?window.__codexhostWindowHidden:void 0;return typeof n==`boolean`?n:globalThis.__codexhostWindowHidden===!0}function Lt(e){return typeof document<`u`&&document.hidden===!0||It(e)}var Rt=class{assembler;snapshot;openTurn;viewStore;targetSources=/* @__PURE__ */ new Map;revision=-1;timer;frame;deferredWhileHidden=!1;disposed=!1;disposeVisibilityListeners;disposeFeed=()=>{};constructor(e,t){this.assembler=t,this.viewStore=t,this.snapshot=(0,f.createSnapshotStore)(this.currentSnapshot()),this.openTurn=(0,f.createSnapshotStore)(t.openTurn()),this.replace(e.getSnapshot()),this.disposeFeed=e.subscribe(()=>{this.accept(e.getSnapshot())})}target(e){let t=this.targetSources.get(e);if(t===void 0){let n=this.viewStore;t={getSnapshot:()=>n.get(e),subscribe:t=>{let n=this.snapshot.subscribe(t);return this.activate(e),n}},this.targetSources.set(e,t)}return t}activate(e){this.assembler.activateTarget(e)&&(this.cancelScheduledFlush(),this.snapshot.set(this.currentSnapshot())),this.openTurn.set(this.assembler.openTurn())}rebuild(){this.publish(this.assembler.rebuildRegistry())}dispose(){this.disposed||(this.disposed=!0,this.cancelScheduledFlush(),this.disposeFeed())}replace(e){this.revision=e.revision,this.publish(this.assembler.replaceWindow(e.entries,e.hasMore))}accept(e){if(e.revision!==this.revision){if(e.revision!==this.revision+1||e.change.kind===`replace`)this.replace(e);else switch(this.revision=e.revision,e.change.kind){case`prepend`:this.publish(this.assembler.prepend(e.change.entries,e.hasMore));return;case`append`:{let t=`none`;for(let n of e.change.entries){let e=this.assembler.append(n);(e===`immediate`||t===`none`)&&(t=e)}this.publish(t);return}case`settle-assistant`:this.publish(this.assembler.settleAssistant(e.change.attemptId,e.change.entry));return}}}publish(e){if(!(this.disposed||e===`none`)){if(e===`animation-frame`){if(Lt()){this.deferWhileHidden();return}this.scheduleCoalescedFlush()}else this.cancelScheduledFlush(),this.flush()}}scheduleCoalescedFlush(){this.disposed||this.timer!==void 0||this.frame!==void 0||(this.detachVisibilityListeners(),this.deferredWhileHidden=!1,this.timer=setTimeout(()=>{this.timer=void 0,!this.disposed&&(Lt()?this.deferWhileHidden():typeof requestAnimationFrame==`function`?this.frame=requestAnimationFrame(()=>{this.frame=void 0,!this.disposed&&(Lt()?this.deferWhileHidden():this.flush())}):this.flush())},40))}deferWhileHidden(){this.disposed||(this.clearTimers(),this.deferredWhileHidden=!0,this.attachVisibilityListeners())}attachVisibilityListeners(){if(this.disposed||this.disposeVisibilityListeners!==void 0)return;let e=e=>{this.disposed||!this.deferredWhileHidden||Lt(e)||(this.deferredWhileHidden=!1,this.detachVisibilityListeners(),this.flush())},t=()=>e(),n=t=>e(t),r=typeof document<`u`&&typeof document.addEventListener==`function`?document:void 0,i=typeof window<`u`&&typeof window.addEventListener==`function`?window:void 0;r?.addEventListener(`visibilitychange`,t),i?.addEventListener(Ft,n),this.disposeVisibilityListeners=()=>{r?.removeEventListener(`visibilitychange`,t),i?.removeEventListener(Ft,n)}}detachVisibilityListeners(){let e=this.disposeVisibilityListeners;e!==void 0&&(this.disposeVisibilityListeners=void 0,e())}clearTimers(){this.timer!==void 0&&(clearTimeout(this.timer),this.timer=void 0),this.frame!==void 0&&typeof cancelAnimationFrame==`function`&&cancelAnimationFrame(this.frame),this.frame=void 0}cancelScheduledFlush(){this.clearTimers(),this.deferredWhileHidden=!1,this.detachVisibilityListeners()}flush(){this.assembler.flush()&&this.snapshot.set(this.currentSnapshot()),this.openTurn.set(this.assembler.openTurn())}currentSnapshot(){return{views:this.viewStore,activeTargets:this.assembler.activityTargets()}}},zt=class extends m.Service{sessions;events;views;groups;bindings=new Ne;images;constructor(e,t){super(e,`uiConversation`),this.sessions=t,this.events=new gt(e),this.views=new Nt(e),this.groups=new Pt(e,this.views),this.images=new bt(e,t);let n=()=>{for(let e of this.bindings.values)e.binding.rebuild()},r=!1,i=()=>{r||(r=!0,queueMicrotask(()=>{r=!1,n()}))};e.effect(()=>{let e=this.events.subscribe(i),t=this.views.subscribe(i),n=this.groups.subscribe(i);return()=>{n(),t(),e();for(let e of[...this.bindings.values])this.drop(e,!0)}},`ui-conversation assembly`)}binding(e){let t=typeof e==`string`?e:e.sessionId,n=typeof e==`string`?this.sessions.binding(e):e;if(n===void 0)throw Error(`uiConversation.binding: unknown session "${t}"`);if(this.sessions.binding(t)!==n)throw Error(`uiConversation.binding: inactive session "${t}"`);let r=this.bindings.get(n);if(r!==void 0)return r.binding;let i=new Rt(n.eventSource,new ft(this.events,this.views,this.groups)),a={source:n,binding:i,disposeScope:()=>{}};this.bindings.set(n,a);let o=n.ctx.effect(()=>()=>{this.drop(a,!1)},`ui-conversation binding`);return a.disposeScope=()=>{o()},i}imageUrl(e,t){return this.images.resolve(e,t)}peekImageUrl(e,t){return this.images.peek(e,t)}seedImageUrl(e,t,n,r){return this.images.seed(e,t,n,r)}cacheUploadedImage(e,t){return this.images.cacheUploaded(e,t)}aliasUploadedImage(e,t,n){return this.images.aliasUploaded(e,t,n)}clearPendingUploadedImage(e,t){this.images.clearPendingUploaded(e,t)}inspectSystemPrompt(e,t){return Le(e,t)}inspectRequestPrompt(e,t,n){return Pe(e,t,n)}drop(e,t){this.bindings.get(e.source)===e&&(this.bindings.delete(e.source),e.binding.dispose(),t&&e.disposeScope())}};function Bt(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 Vt(e,t=`|`){return e.map(e=>hn(e)).join(t)}function Ht(e,t){return typeof t==`bigint`?t.toString():t}var Ut=class{constructor(e){this._getter=e,this._value=void 0}get value(){let e=this._getter;return e!==void 0&&(this._value=e(),this._getter=void 0),this._value}};function Wt(e){return new Ut(e)}function Gt(e){return e==null}function Kt(e){let t=+!!e.startsWith(`^`),n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function qt(e,t){let n=e/t,r=Math.round(n),i=4*2**-52*Math.max(Math.abs(n),1);return Math.abs(n-r)<i?0:n-r}let Jt=/* @__PURE__*/ Symbol(`evaluating`);function Yt(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==Jt)return r===void 0&&(r=Jt,r=n()),r},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function Xt(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function Zt(e){let t=Object.getOwnPropertyDescriptor(e,`shape`);return t?.get?t.get.raw:t?.value}function Qt(e){return Zt(e._zod.def)??e._zod.def.shape}function $t(e,t,n){Object.defineProperty(e,t,{get(){let e=n();return Xt(this,t,e),e},enumerable:!0,configurable:!0})}function en(e,t,n){t in e?Xt(e,t,n):e[t]=n}function tn(e,t,n,r){let i=Qt(t);for(let a of n){let n=Object.getOwnPropertyDescriptor(i,a);n.enumerable&&(n.get?$t(e,a,()=>{let e=t._zod.def.shape[a];return r?r(e,a):e}):en(e,a,r?r(n.value,a):n.value))}}function nn(e,t){for(let n of Reflect.ownKeys(t)){let r=Object.getOwnPropertyDescriptor(t,n);r.enumerable&&(r.get?$t(e,n,()=>t[n]):en(e,n,r.value))}}function rn(...e){let t={};for(let n of e){let e=Object.getOwnPropertyDescriptors(n);Object.assign(t,e)}return Object.defineProperties({},t)}function an(e){return JSON.stringify(e)}function on(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,``).replace(/[\s_-]+/g,`-`).replace(/^-+|-+$/g,``)}let sn=`captureStackTrace`in Error?Error.captureStackTrace:(...e)=>{};function cn(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}let ln=/* @__PURE__*/ Wt(()=>{if(ir.jitless||typeof navigator<`u`&&navigator?.userAgent?.includes(`Cloudflare`))return!1;try{return Function(``),!0}catch{return!1}});function un(e){if(cn(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!=`function`)return!0;let n=t.prototype;return cn(n)!==!1&&Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)!==!1}function dn(e){return un(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}let fn=/* @__PURE__*/ new Set([`string`,`number`,`symbol`]);function pn(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function mn(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function w(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 hn(e){return typeof e==`bigint`?e.toString()+`n`:typeof e==`string`?`"${e}"`:`${e}`}function gn(e){return Object.keys(e).filter(t=>e[t]._zod.optin!==void 0&&e[t]._zod.optout===`optional`)}let _n={safeint:[-(2**53-1),2**53-1],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},vn={int64:[/* @__PURE__*/ BigInt(`-9223372036854775808`),/* @__PURE__*/ BigInt(`9223372036854775807`)],uint64:[/* @__PURE__*/ BigInt(0),/* @__PURE__*/ BigInt(`18446744073709551615`)]};function yn(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`);let i={};return tn(i,e,bn(e,t)),mn(e,rn(n,{shape:i,checks:[]}))}function bn(e,t){let n=Qt(e),r=[];for(let e of Reflect.ownKeys(t)){if(!Object.getOwnPropertyDescriptor(n,e)?.enumerable)throw Error(`Unrecognized key: "${String(e)}"`);t[e]&&r.push(e)}return r}function xn(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`);let i=new Set(bn(e,t)),a={};return tn(a,e,Reflect.ownKeys(Qt(e)).filter(e=>!i.has(e))),mn(e,rn(n,{shape:a,checks:[]}))}function Sn(e,t){if(!un(t))throw Error(`Invalid input to extend: expected a plain object`);let n=e._zod.def.checks;if(n&&n.length>0){let n=Qt(e);for(let e of Reflect.ownKeys(t))if(Object.getOwnPropertyDescriptor(n,e)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return mn(e,rn(e._zod.def,{shape:Cn(e,t)}))}function Cn(e,t){let n={};return tn(n,e,Reflect.ownKeys(Qt(e))),nn(n,t),n}function wn(e,t){if(!un(t))throw Error(`Invalid input to safeExtend: expected a plain object`);return mn(e,rn(e._zod.def,{shape:Cn(e,t)}))}function Tn(e,t){if(!t?._zod?.def)throw Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");if(e._zod.def.checks?.length)throw Error(`.merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.`);let n={};return tn(n,e,Reflect.ownKeys(Qt(e))),tn(n,t,Reflect.ownKeys(Qt(t))),mn(e,rn(e._zod.def,{shape:n,get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]}))}function En(e,t,n,r=`partial`){let i=t._zod.def.checks;if(i&&i.length>0)throw Error(`.${r}() cannot be used on object schemas containing refinements`);let a=n?new Set(bn(t,n)):void 0,o={};return tn(o,t,Reflect.ownKeys(Qt(t)),e&&((t,n)=>a&&!a.has(n)?t:new e({type:`optional`,innerType:t}))),mn(t,rn(t._zod.def,{shape:o,checks:[]}))}function Dn(e,t,n){let r=n?new Set(bn(t,n)):void 0,i={};return tn(i,t,Reflect.ownKeys(Qt(t)),(t,n)=>r&&!r.has(n)?t:new e({type:`nonoptional`,innerType:t})),mn(t,rn(t._zod.def,{shape:i}))}function On(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 kn(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 An(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function jn(e){return typeof e==`string`?e:e?.message}function Mn(e){let t=[];for(let n of e??[]){let e=n._zod.def;if(!/_(length|size)$|_equals$/.test(e.check))break;let r=e.maximum??e.length??e.size;r>=0&&t.push([r,n])}return t}function Nn(e,t,n){var r;for(let i=t;i<e.length;i++)(r=e[i]).schema??(r.schema=n)}function Pn(e,t,n){var r;let i=e.inst?._zod?.traits;i?.has(`$ZodType`)&&(i.has(`$ZodCheck`)?(r=e).schema??(r.schema=e.inst):e.schema=e.inst);let a=e.schema===e.inst?void 0:e.schema?._zod.def?.error,o=e.message?e.message:jn(e.inst?._zod.def?.error?.(e))??jn(a?.(e))??jn(t?.error?.(e))??jn(n.customError?.(e))??jn(n.localeError?.(e))??`Invalid input`,s={};for(let t of Object.keys(e))t!==`inst`&&t!==`schema`&&t!==`continue`&&t!==`input`&&t!==`__proto__`&&(s[t]=e[t]);return s.path??=[],s.message=o,t?.reportInput&&(s.input=e.input),s}let Fn=/[\uD800-\uDBFF]/;function In(e){let t=e.length;if(!Fn.test(e))return t;let n=t;for(let r=0;r<t-1;r++)(e.charCodeAt(r)&64512)==55296&&(e.charCodeAt(r+1)&64512)==56320&&(n--,r++);return n}function Ln(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function Rn(e){let t=typeof e;switch(t){case`number`:return Number.isNaN(e)?`nan`:`number`;case`object`:{if(e===null)return`null`;if(Array.isArray(e))return`array`;let t=e;if(t&&Object.getPrototypeOf(t)!==Object.prototype&&`constructor`in t&&t.constructor)return t.constructor.name}}return t}function zn(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}function Bn(e,t){for(let n in t){let r=Object.getOwnPropertyDescriptor(t,n);r.get?Object.defineProperty(e,n,{...r,enumerable:!1}):Wn(e,n,r.value)}}function Vn(e,t,n,r=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:r,value:n}),n}function Hn(e,t,n){return Vn(e,t,n,!1)}function Un(e,t){for(let n in e){let r=e[n];Object.defineProperty(t,n,{configurable:!0,enumerable:!0,get(){return Vn(this,n,r(this))},set(e){Vn(this,n,e)}})}return t}function Wn(e,t,n){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?n:Vn(this,t,n.bind(this))},set(e){Vn(this,t,e)}})}function Gn(e,t){let n=Object.getPrototypeOf(e);return t in n?void 0:n}let Kn,qn=!1,Jn={configurable:!0,get(){qn=!0}};function T(e,t,n){let r=Object.getPrototypeOf(e._zod);t in r&&Kn!==e._zod?Kn=void 0:(Kn=e._zod,Object.defineProperty(r,t,{configurable:!0,get(){Object.defineProperty(this,t,Jn);let e=qn;qn=!1;try{let r=n(this);return qn?delete this[t]:Object.defineProperty(this,t,{configurable:!0,writable:!0,value:r}),qn||=e,r}catch(n){throw delete this[t],qn||=e,n}},set(e){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:e})}}))}function Yn(e,t,n,r){let i=Gn(e,t);i&&Object.defineProperty(i,t,{configurable:!0,get(){let e={configurable:!0,writable:!0,enumerable:r,value:void 0};return Object.defineProperty(this,t,e),e.value=n(this),Object.defineProperty(this,t,e),e.value},set(e){Object.defineProperty(this,t,{configurable:!0,writable:!0,enumerable:r,value:e})}})}function Xn(e){let t=()=>e;return t[`~constantCatch`]=!0,t}var Zn;let Qn=/*@__PURE__*/ Object.freeze({status:`aborted`}),$n={value:void 0,enumerable:!1},er=`captureStackTrace`in Error?Error:null;function tr(e){let t=er;if(t){let n=t.stackTraceLimit;if(typeof n==`number`){try{t.stackTraceLimit=0}catch{return er=null,new e}try{return new e}finally{t.stackTraceLimit=n}}}return new e}function E(e,t,n,r){let i={};function a(e){this.def=e,this.constr=d,this.traits=/* @__PURE__ */ new Set}a.prototype=i;let o=n,s=o&&/* @__PURE__ */ new WeakSet;function c(n,r){if(!n._zod){$n.value=new a(r);try{Object.defineProperty(n,"_zod",$n)}finally{$n.value=void 0}}else if(n._zod.traits.has(e))return;if(n._zod.traits.add(e),t(n,r),s){let e=Object.getPrototypeOf(n),t=n._zod.constr.prototype,r=e;for(;r&&r!==t;)r=Object.getPrototypeOf(r);let i=r??e;s.has(i)||(s.add(i),Bn(i,o))}let i=d.prototype;for(let e in i)Object.prototype.hasOwnProperty.call(i,e)&&(e in n||(n[e]=i[e].bind(n)))}let l=r?.Parent??Object;class u extends l{}Object.defineProperty(u,"name",{value:e});function d(e){let t=r?.Parent?tr(u):this;c(t,e);let n=t._zod.deferred;if(n){for(let e of n)e();t._zod.deferred=void 0}let i=globalThis.__zod_globalConfig?.postProcessor;return i&&i(t),t}return Object.defineProperty(d,"init",{value:c}),Object.defineProperty(d,Symbol.hasInstance,{value:t=>r?.Parent&&t instanceof r.Parent?!0:t?._zod?.traits?.has(e)}),Object.defineProperty(d,"name",{value:e}),d}var nr=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}},rr=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name=`ZodEncodeError`}};(Zn=globalThis).__zod_globalConfig??(Zn.__zod_globalConfig={});let ir=globalThis.__zod_globalConfig;function ar(e){return e&&Object.assign(ir,e),ir}function or(){let e=this._zod;return e.message??=JSON.stringify(e.def,Ht,2),e.message}function sr(e){this._zod.message=e}let cr={get:or,set:sr,enumerable:!0,configurable:!0},lr={value:void 0,enumerable:!1},ur=/* @__PURE__ */ new WeakSet([Object.prototype,Error.prototype]),dr=(e,t)=>{e.name=`$ZodError`,lr.value=t,Object.defineProperty(e,"issues",lr),lr.value=void 0,Object.defineProperty(e,"message",cr);let n=Object.getPrototypeOf(e);ur.has(n)||(ur.add(n),Object.defineProperty(n,"toString",{configurable:!0,enumerable:!1,get(){let e=()=>this.message;return Object.defineProperty(this,"toString",{value:e,configurable:!0,writable:!0}),e},set(e){Object.defineProperty(this,"toString",{value:e,configurable:!0,writable:!0})}}))},fr=E(`$ZodError`,dr);E(`$ZodError`,dr,void 0,{Parent:Error});function pr(e,t,n){return Object.prototype.hasOwnProperty.call(e,t)||(t===`__proto__`?Object.defineProperty(e,t,{value:n(),writable:!0,enumerable:!0,configurable:!0}):e[t]=n()),e[t]}function mr(e,t=e=>e.message){let n={},r=[];for(let i of e.issues)i.path.length>0?pr(n,i.path[0],()=>[]).push(t(i)):r.push(t(i));return{formErrors:r,fieldErrors:n}}function hr(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],o=i===e.length-1;if(n===`_errors`){o&&r._errors.push(t(a)),i++;continue}Object.prototype.hasOwnProperty.call(r,n)||Object.defineProperty(r,n,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});let s=r[n];o&&s._errors.push(t(a)),r=s,i++}}}};return r(e),n}function gr(e,t){return{callee:t?.callee??e,Err:t?.Err}}let _r=e=>{let t=(n,r,i,a)=>{let o=i?{...i,async:!1}:{async:!1},s=n._zod.run({value:r,issues:[]},o);if(s instanceof Promise)throw new nr;if(s.issues.length){let n=new((a?.Err)??e)(s.issues.map(e=>Pn(e,o,ar())));throw sn(n,a?.callee??t),n}return s.value};return t},vr=e=>{let t=async(n,r,i,a)=>{let o=i?{...i,async:!0}:{async:!0},s=n._zod.run({value:r,issues:[]},o);if(s instanceof Promise&&(s=await s),s.issues.length){let n=new((a?.Err)??e)(s.issues.map(e=>Pn(e,o,ar())));throw sn(n,a?.callee??t),n}return s.value};return t},yr=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 nr;return a.issues.length?br(e,a.issues,i):{success:!0,data:a.value}};function br(e,t,n){let r;return{success:!1,get error(){return r||(r=new e(t.map(e=>Pn(e,n,ar()))),t=void 0,n=void 0),r},set error(e){r=e,t=void 0,n=void 0}}}let xr=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?br(e,a.issues,i):{success:!0,data:a.value}},Sr=/* @__PURE__ */ Symbol.for(`zod.compile.invalid`),Cr=/* @__PURE__ */ Symbol.for(`zod.compile.fallback`),wr=((e,t,n)=>{let r=e._zod.bag.validator;if(r!==void 0){if(r(t)!==Sr)return!0;if(r.definite===!0&&n===void 0)return!1}return Tr(e,t,n)});function Tr(e,t,n){let r=n?{...n,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},i=e._zod.bag.fallbackRun,a;if(i?(r[Cr]=!0,a=i({value:t,issues:[]},r)):a=e._zod.run({value:t,issues:[]},r),a instanceof Promise)throw new nr;return a.issues.length===0}let Er=async(e,t,n)=>{let r=n?{...n,async:!0,abortEarly:!0}:{async:!0,abortEarly:!0},i=e._zod.run({value:t,issues:[]},r);return i instanceof Promise&&(i=await i),i.issues.length===0},Dr=e=>{let t=_r(e),n=(e,r,i,a)=>{let o=i?{...i,direction:`backward`}:{direction:`backward`};return t(e,r,o,gr(n,a))};return n},Or=e=>{let t=_r(e),n=(e,r,i,a)=>t(e,r,i,gr(n,a));return n},kr=e=>{let t=vr(e),n=async(e,r,i,a)=>{let o=i?{...i,direction:`backward`}:{direction:`backward`};return await t(e,r,o,gr(n,a))};return n},Ar=e=>{let t=vr(e),n=async(e,r,i,a)=>await t(e,r,i,gr(n,a));return n},jr=e=>(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return yr(e)(t,n,i)},Mr=e=>(t,n,r)=>yr(e)(t,n,r),Nr=e=>async(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return xr(e)(t,n,i)},Pr=e=>async(t,n,r)=>xr(e)(t,n,r),Fr=/^[cC][0-9a-z]{6,}$/,Ir=/^[0-9a-z]+$/,Lr=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,Rr=/^[0-9a-vA-V]{20}$/,zr=/^[A-Za-z0-9]{27}$/,Br=/^[a-zA-Z0-9_-]{21}$/;function Vr(e){return RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}let Hr=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Ur=/^([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})$/,Wr=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)$/,Gr=/^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;function Kr(){return RegExp(`^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$`,`u`)}let qr=/^(?:(?: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])$/,Jr=/^(([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}|:))$/,Yr=/^((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])$/,Xr=/^(([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}|:))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Zr=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Qr=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/,$r=/^https?$/,ei=/^\+[1-9]\d{6,14}$/,ti=`(?:(?:\\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])))`;function ni(e){return RegExp(`^${e}$`)}let ri=/*@__PURE__*/ ni(ti);function ii(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}}`:e.seconds?`${t}:[0-5]\\d(?:\\.\\d+)?`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function ai(e){return RegExp(`^${ii(e)}$`)}function oi(e){let t=[`Z`];e.offset&&t.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);let n=`${ii({precision:e.precision,seconds:!0})}(?:${t.join(`|`)})`,r=e.local?`${n}|${ii({precision:e.precision})}`:n;return RegExp(`^${ti}T(?:${r})$`)}let si=/^[\s\S]{0,}$/,ci=/^-?\d+$/,li=/^-?\d+(?:\.\d+)?$/,ui=/^(?:true|false)$/i,di=/^null$/i,fi=/^[^A-Z]*$/,pi=/^[^a-z]*$/,mi=/*@__PURE__*/ E(`$ZodCheck`,(e,t)=>{var n;e._zod??={},e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),hi=e=>{let t=e.value;return!Gt(t)&&t.length!==void 0},gi={number:`number`,bigint:`bigint`,object:`date`},_i=/*@__PURE__*/ E(`$ZodCheckLessThan`,(e,t)=>{mi.init(e,t);let n=gi[typeof t.value];e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:gi[typeof r.value]??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})}}),vi=/*@__PURE__*/ E(`$ZodCheckGreaterThan`,(e,t)=>{mi.init(e,t);let n=gi[typeof t.value];e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:gi[typeof r.value]??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})}}),yi=/*@__PURE__*/ E(`$ZodCheckMultipleOf`,(e,t)=>{mi.init(e,t),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`?t.value!==BigInt(0)&&n.value%t.value===BigInt(0):qt(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})}}),bi=/*@__PURE__*/ E(`$ZodCheckNumberFormat`,(e,t)=>{mi.init(e,t),t.format=t.format||`float64`;let n=t.format?.includes(`int`),r=n?`int`:`number`,[i,a]=_n[t.format];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})}}),xi=/*@__PURE__*/ E(`$ZodCheckMaxLength`,(e,t)=>{var n;mi.init(e,t),(n=e._zod.def).when??(n.when=hi),e._zod.check=n=>{let r=n.value,i=r.length;if((typeof r==`string`&&i>t.maximum?In(r):i)<=t.maximum)return;let a=Ln(r);n.issues.push({origin:a,code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Si=/*@__PURE__*/ E(`$ZodCheckMinLength`,(e,t)=>{var n;mi.init(e,t),(n=e._zod.def).when??(n.when=hi),e._zod.check=n=>{let r=n.value,i=r.length;if((typeof r==`string`&&i>=t.minimum&&i<t.minimum*2?In(r):i)>=t.minimum)return;let a=Ln(r);n.issues.push({origin:a,code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Ci=/*@__PURE__*/ E(`$ZodCheckLengthEquals`,(e,t)=>{var n;mi.init(e,t),(n=e._zod.def).when??(n.when=hi),e._zod.check=n=>{let r=n.value,i=r.length,a=typeof r==`string`&&i>=t.length&&i<=t.length*2?In(r):i;if(a===t.length)return;let o=Ln(r),s=a>t.length;n.issues.push({origin:o,...s?{code:`too_big`,maximum:t.length}:{code:`too_small`,minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),wi=/*@__PURE__*/ E(`$ZodCheckStringFormat`,(e,t)=>{var n,r;mi.init(e,t),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=()=>{})}),Ti=/*@__PURE__*/ E(`$ZodCheckRegex`,(e,t)=>{wi.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})}}),Ei=/*@__PURE__*/ E(`$ZodCheckLowerCase`,(e,t)=>{t.pattern??=fi,wi.init(e,t)}),Di=/*@__PURE__*/ E(`$ZodCheckUpperCase`,(e,t)=>{t.pattern??=pi,wi.init(e,t)}),Oi=/*@__PURE__*/ E(`$ZodCheckIncludes`,(e,t)=>{mi.init(e,t);let n=pn(t.includes);t.pattern=new RegExp(typeof t.position==`number`?`^.{${t.position},}${n}`:n),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})}}),ki=/*@__PURE__*/ E(`$ZodCheckStartsWith`,(e,t)=>{mi.init(e,t);let n=RegExp(`^${pn(t.prefix)}.*`);t.pattern??=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})}}),Ai=/*@__PURE__*/ E(`$ZodCheckEndsWith`,(e,t)=>{mi.init(e,t);let n=RegExp(`.*${pn(t.suffix)}$`);t.pattern??=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})}}),ji=/*@__PURE__*/ E(`$ZodCheckOverwrite`,(e,t)=>{mi.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}});var Mi=class{constructor(e=[],t={}){this.content=[],this.indent=0,this.args=e,this.closed=t}indented(e){this.indent+=1;try{e(this)}finally{--this.indent}}write(e){if(typeof e==`function`){e(this,{execution:`sync`}),e(this,{execution:`async`});return}let t=e.split(`
11
+ default:Me(e.groups)}return{upserts:t,removes:n}}},We=class{store;key;listeners=/* @__PURE__ */ new Set;published;constructor(e,t){this.store=e,this.key=t,this.published=e.get(t)}getSnapshot=()=>this.store.get(this.key);subscribe=e=>(this.listeners.add(e),()=>{this.listeners.delete(e)});publish(){let e=this.getSnapshot();this.published!==e&&(this.published=e,(0,f.notifySubscribers)(this.listeners,`[ui-conversation] Location data ${this.key}`))}},Ge=class{markDirty;entries=/* @__PURE__ */ new Map;sources=/* @__PURE__ */ new Map;dirtyKeys=/* @__PURE__ */ new Set;constructor(e){this.markDirty=e}get(e){return this.entries.get(e)?.value}source(e){let t=this.sources.get(e);return t===void 0&&(t=new We(this,e),this.sources.set(e,t)),t}remove(e,t){return this.entries.get(t)?.owner===e&&(this.entries.delete(t),this.changed(t),!0)}set(e,t,n){let r=this.entries.get(t);if(r!==void 0&&r.owner!==e)throw Error(`conversation Location data "${t}" is already owned by ${r.owner}`);return r?.value!==n&&(this.entries.set(t,{owner:e,value:n}),this.changed(t),!0)}replace(e){let t=[];for(let n of/* @__PURE__ */ new Set([...this.entries.keys(),...e.keys()])){let r=this.entries.get(n),i=e.get(n);(r?.owner!==i?.owner||r?.value!==i?.value)&&t.push(n)}if(t.length===0)return!1;this.entries=new Map(e);for(let e of t)this.changed(e);return!0}publish(){let e=[...this.dirtyKeys];this.dirtyKeys.clear();for(let t of e)this.sources.get(t)?.publish()}changed(e){this.dirtyKeys.add(e),this.markDirty(this)}};let Ke={kind:`session`},qe={kind:`unresolved`};function Je(e){let t=e.data;if(t.turn===null)return{session:!0,location:void 0};let n=Number.isSafeInteger(t.turn)&&t.turn>=0?t.turn:void 0,r=Number.isSafeInteger(t.step)&&t.step>=0?t.step:void 0;return n===void 0?r===void 0?{location:void 0}:{step:r,location:void 0}:r===void 0?{turn:n,location:void 0}:{turn:n,step:r,location:void 0}}function Ye(e,t){return e.length===t.length&&e.every((e,n)=>e===t[n])}function Xe(e,t){return e!==void 0&&e.start===t.start&&e.end===t.end&&e.status===t.status&&e.data===t.data}function Ze(e,t){return e!==void 0&&e.start===t.start&&e.end===t.end&&e.status===t.status&&e.data===t.data&&Ye(e.steps,t.steps)}function Qe(e,t){return e===void 0||t===void 0||e.kind!==t.kind?e===t:e.kind===`session`||e.kind===`unresolved`?!0:t.kind===`session`||t.kind===`unresolved`?!1:e.kind===`turn`||t.kind===`turn`?e.kind===`turn`&&t.kind===`turn`&&e.turn===t.turn:e.turn===t.turn&&e.step===t.step}var $e=class{coordinates=/* @__PURE__ */ new Map;eventKeysByTurn=/* @__PURE__ */ new Map;stepsByTurn=/* @__PURE__ */ new Map;timeline={turnOrder:[],turns:/* @__PURE__ */ new Map};turnDataStores=/* @__PURE__ */ new Map;stepDataStores=/* @__PURE__ */ new Map;dirtyDataStores=/* @__PURE__ */ new Set;changedTurns=/* @__PURE__ */ new Set;currentTurn;currentStep;snapshot(){return this.timeline}takeChangedTurns(){let e=[...this.changedTurns];return this.changedTurns.clear(),e}replaceData(e){let t=/* @__PURE__ */ new Map,n=/* @__PURE__ */ new Map;for(let{owner:r,data:i}of e){let e=i.kind===`turn`?t.get(i.turn)??/* @__PURE__ */ new Map:n.get(et(i.turn,tt(i)))??/* @__PURE__ */ new Map,a=e.get(i.key);if(a!==void 0&&a.owner!==r)throw Error(`conversation Location data "${i.key}" is already owned by ${a.owner}`);e.set(i.key,{owner:r,value:i.value}),i.kind===`turn`?t.set(i.turn,e):n.set(et(i.turn,tt(i)),e)}let r=!1;for(let e of/* @__PURE__ */ new Set([...this.turnDataStores.keys(),...t.keys()]))r=this.mutableTurnData(e).replace(t.get(e)??/* @__PURE__ */ new Map)||r;for(let e of/* @__PURE__ */ new Set([...this.stepDataStores.keys(),...n.keys()]))r=this.mutableStepData(e).replace(n.get(e)??/* @__PURE__ */ new Map)||r;return r}applyData(e){let t=!1;for(let n of e){let e=n.previous;e!==null&&(t=this.storeFor(e).remove(n.owner,e.key)||t)}for(let n of e){let e=n.next;e!==null&&(t=this.storeFor(e).set(n.owner,e.key,e.value)||t)}return t}publishData(){let e=[...this.dirtyDataStores];this.dirtyDataStores.clear();for(let t of e)t.publish()}locationOf(e){return this.coordinates.get(ze(e))?.location??Ke}rebuild(e){let t=this.coordinates,n=/* @__PURE__ */ new Map,r=/* @__PURE__ */ new Map,i,a,o=(e,t)=>{let r=n.get(e);return r===void 0?(r={turn:e,firstSeq:t,steps:/* @__PURE__ */ new Map},n.set(e,r)):r.firstSeq=Math.min(r.firstSeq,t),r},s=(e,t,n)=>{let r=o(e,n),i=r.steps.get(t);return i===void 0?(i={turn:e,step:t,firstSeq:n},r.steps.set(t,i)):i.firstSeq=Math.min(i.firstSeq,n),i};for(let{event:t}of e){let e=Je(t);t.type===`turn/start`&&(i=t.data.turn,a=void 0),t.type===`step/start`&&(i=t.data.turn,a=t.data.step),e.session!==!0&&e.turn!==void 0&&(i!==e.turn&&(a=void 0),i=e.turn,e.step!==void 0&&(a=e.step));let n=e.session===!0?void 0:e.turn??i,c=e.session===!0||t.type===`turn/start`||t.type===`turn/end`?void 0:e.step??(n===i?a:void 0);r.set(ze(t),{...n===void 0?{}:{turn:n},...n===void 0||c===void 0?{}:{step:c},location:void 0}),n!==void 0&&o(n,t.seq),n!==void 0&&c!==void 0&&s(n,c,t.seq),t.type===`turn/start`?o(t.data.turn,t.seq).start=t:t.type===`turn/end`?o(t.data.turn,t.seq).end=t:t.type===`step/start`?s(t.data.turn,t.data.step,t.seq).start=t:t.type===`step/end`&&(s(t.data.turn,t.data.step,t.seq).end=t),t.type===`step/end`&&i===t.data.turn&&a===t.data.step&&(a=void 0),t.type===`turn/end`&&i===t.data.turn&&(i=void 0,a=void 0)}let c=this.timeline.turns,l=/* @__PURE__ */ new Map,u=[...n.values()].sort((e,t)=>e.firstSeq-t.firstSeq);for(let e of u){let t=c.get(e.turn),n=new Map(t?.steps.map(e=>[e.step,e])??[]),r=[...e.steps.values()].sort((e,t)=>e.firstSeq-t.firstSeq).map(e=>{let t={turn:e.turn,step:e.step,start:e.start,end:e.end,status:e.end===void 0?e.start===void 0?`unknown`:`open`:`closed`,data:this.stepData(e.turn,e.step)},r=n.get(e.step);return Xe(r,t)?r:t}),i={turn:e.turn,start:e.start,end:e.end,status:e.end===void 0?e.start===void 0?`unknown`:`open`:`closed`,steps:r,data:this.turnData(e.turn)};l.set(e.turn,Ze(t,i)?t:i)}let d=u.map(e=>e.turn),f=this.timeline.turnOrder.length===d.length&&this.timeline.turnOrder.every((e,t)=>e===d[t])?this.timeline.turnOrder:d,p=c.size===l.size;if(p){for(let[e,t]of l)if(c.get(e)!==t){p=!1;break}}for(let e of/* @__PURE__ */ new Set([...c.keys(),...l.keys()]))c.get(e)!==l.get(e)&&this.changedTurns.add(e);this.timeline=p&&f===this.timeline.turnOrder?this.timeline:{turnOrder:f,turns:l},this.stepsByTurn.clear();for(let[e,t]of this.timeline.turns)this.stepsByTurn.set(e,new Map(t.steps.map(e=>[e.step,e])));this.coordinates=r,this.eventKeysByTurn=/* @__PURE__ */ new Map;for(let{event:t}of e){let e=ze(t),n=this.coordinates.get(e);n.turn!==void 0&&this.indexTurnEvent(n.turn,e),n.location=this.resolve(e)}this.currentTurn=i,this.currentStep=a;let m=/* @__PURE__ */ new Set;for(let{event:n}of e){let e=ze(n);Qe(t.get(e)?.location,this.coordinates.get(e)?.location)||m.add(e)}return m}appendBoundary(e){if(e.type!==`turn/start`&&e.type!==`turn/end`&&e.type!==`step/start`&&e.type!==`step/end`)throw Error(`conversation Location boundary expected, received ${e.type}`);let t=Je(e);e.type===`turn/start`?(this.currentTurn=e.data.turn,this.currentStep=void 0):e.type===`step/start`&&(this.currentTurn=e.data.turn,this.currentStep=e.data.step),t.turn!==void 0&&(this.currentTurn!==t.turn&&(this.currentStep=void 0),this.currentTurn=t.turn,t.step!==void 0&&(this.currentStep=t.step));let n=t.turn??this.currentTurn;if(n===void 0)throw Error(`conversation boundary ${e.type} has no turn`);let r=e.type===`turn/start`||e.type===`turn/end`?void 0:t.step??(n===this.currentTurn?this.currentStep:void 0);this.coordinates.set(e.seq,{turn:n,...r===void 0?{}:{step:r},location:this.coordinates.get(e.seq)?.location}),this.indexTurnEvent(n,e.seq);let i=this.timeline.turns.get(n),a=i?.steps??[];if(e.type===`step/start`||e.type===`step/end`){let t=e.data.step,r=this.stepsByTurn.get(n)??/* @__PURE__ */ new Map,i=r.get(t),o={turn:n,step:t,start:e.type===`step/start`?e:i?.start,end:e.type===`step/end`?e:i?.end,status:e.type===`step/end`||i?.end!==void 0?`closed`:`open`,data:this.stepData(n,t)},s=Xe(i,o)?i:o;r.set(t,s),this.stepsByTurn.set(n,r);let c=a.findIndex(e=>e.step===t);a=c<0?[...a,s]:a.map((e,t)=>t===c?s:e)}let o={turn:n,start:e.type===`turn/start`?e:i?.start,end:e.type===`turn/end`?e:i?.end,status:e.type===`turn/end`||i?.end!==void 0?`closed`:e.type===`turn/start`||i?.start!==void 0?`open`:`unknown`,steps:a,data:this.turnData(n)},s=Ze(i,o)?i:o,c=new Map(this.timeline.turns);c.set(n,s);let l=i===void 0?[...this.timeline.turnOrder,n]:this.timeline.turnOrder;this.timeline={turnOrder:l,turns:c},s!==i&&this.changedTurns.add(n);let u=/* @__PURE__ */ new Set;for(let e of this.eventKeysByTurn.get(n)??[]){let t=this.coordinates.get(e),n=t.location,r=this.resolve(e);t.location=r,Qe(n,r)||u.add(e)}return e.type===`step/end`&&this.currentTurn===e.data.turn&&this.currentStep===e.data.step&&(this.currentStep=void 0),e.type===`turn/end`&&this.currentTurn===e.data.turn&&(this.currentTurn=void 0,this.currentStep=void 0),u}appendNonBoundary(e){let t=ze(e),n=Je(e);if(n.session===!0){this.coordinates.set(t,{location:Ke});return}n.turn!==void 0&&(this.currentTurn!==n.turn&&(this.currentStep=void 0),this.currentTurn=n.turn,n.step!==void 0&&(this.currentStep=n.step));let r=n.turn??this.currentTurn,i=n.step??(r===this.currentTurn?this.currentStep:void 0),a=n.turn!==void 0&&n.step!==void 0?n:{...r===void 0?{}:{turn:r},...r===void 0||i===void 0?{}:{step:i},location:void 0};this.coordinates.set(t,a),r!==void 0&&this.indexTurnEvent(r,t),a.location=this.resolve(t)}removeAssistantTransients(e){for(let t of e){let e=ze(t),n=this.coordinates.get(e)?.turn;if(n!==void 0){let t=this.eventKeysByTurn.get(n);t?.delete(e),t?.size===0&&this.eventKeysByTurn.delete(n)}this.coordinates.delete(e)}}insertAssistantSettlement(e){let t={turn:e.data.turn,step:e.data.step,location:void 0};this.coordinates.set(e.seq,t),this.indexTurnEvent(e.data.turn,e.seq),t.location=this.resolve(e.seq)}indexTurnEvent(e,t){let n=this.eventKeysByTurn.get(e);n===void 0&&(n=/* @__PURE__ */ new Set,this.eventKeysByTurn.set(e,n)),n.add(t)}turnData(e){return this.mutableTurnData(e)}stepData(e,t){return this.mutableStepData(et(e,t))}mutableTurnData(e){let t=this.turnDataStores.get(e)??this.createDataStore(e);return this.turnDataStores.set(e,t),t}mutableStepData(e){let t=this.stepDataStores.get(e)??this.createDataStore(Number(e.slice(0,e.indexOf(`:`))));return this.stepDataStores.set(e,t),t}createDataStore(e){return new Ge(t=>{this.dirtyDataStores.add(t),this.changedTurns.add(e)})}storeFor(e){return e.kind===`turn`?this.mutableTurnData(e.turn):this.mutableStepData(et(e.turn,tt(e)))}resolve(e){let t=this.coordinates.get(e);if(t?.turn===void 0)return Ke;let n=this.timeline.turns.get(t.turn);if(n===void 0)return qe;if(t.step===void 0)return{kind:`turn`,turn:n};let r=this.stepsByTurn.get(t.turn)?.get(t.step);return r===void 0?{kind:`turn`,turn:n}:{kind:`step`,turn:n,step:r}}};function et(e,t){return`${e}:${t}`}function tt(e){if(e.kind===`step`&&e.step!==void 0)return e.step;throw Error(`conversation Step data "${e.key}" requires a step`)}let nt={none:0,"animation-frame":1,immediate:2},rt=[`step`,`turn`];function it(){return{step:null,turn:null}}function at(e,t){return nt[e]>=nt[t]?e:t}function ot(e,t){return e.start===void 0?t.start===void 0?0:1:t.start===void 0?-1:C(e.start.event,t.start.event)}function st(e,t){let n=0,r=e.length;for(;n<r;){let i=n+Math.floor((r-n)/2),a=e[i]?.start;a!==void 0&&C(a.event,t)<0?n=i+1:r=i}return n}function ct(e){return{key:e.key,kind:e.kind,id:e.id,matches:e.matches,start:e.start,state:e.state,current:e.current}}function lt(e,t,n){let r=[],i=0,a=0;for(;i<t.length||a<n.length;){let o=t[i],s=n[a],c=o===void 0?1:s===void 0?-1:C(o.event,s.event);if(c===0)throw Error(`conversation Context ${e} received duplicate Match ${o?.event.seq}`);c<0?(r.push(o),i++):(r.push(s),a++)}return r}function ut(e,t,n){return{event:e.event,role:t,location:n}}let dt={entries:()=>[],forTarget:()=>void 0};var ft=class{eventDefinitions;viewDefinitions;groupDefinitions;contexts=/* @__PURE__ */ new Map;contextsByKind=/* @__PURE__ */ new Map;contextsByEventKey=/* @__PURE__ */ new Map;contextsByTarget=/* @__PURE__ */ new Map;inputs=/* @__PURE__ */ new Map;locationIndex=new $e;dirty=/* @__PURE__ */ new Set;dirtyByTarget=/* @__PURE__ */ new Map;revised=/* @__PURE__ */ new Set;dependents=/* @__PURE__ */ new Map;views=/* @__PURE__ */ new Map;groups=/* @__PURE__ */ new Map;pendingGroupStores=/* @__PURE__ */ new Set;activeTargets=/* @__PURE__ */ new Set;hasMore=!1;replacePending=!0;timelineDirty=!0;constructor(e,t,n=dt){this.eventDefinitions=e,this.viewDefinitions=t,this.groupDefinitions=n,this.resetViewBuilders()}openTurn(){let e=this.locationIndex.snapshot(),t=e.turnOrder.at(-1),n=t===void 0?void 0:e.turns.get(t);return n?.status===`open`&&n.start!==void 0?n.turn:void 0}replaceWindow(e,t){this.contexts.clear(),this.contextsByKind.clear(),this.contextsByEventKey.clear(),this.contextsByTarget.clear(),this.inputs.clear(),this.dirty.clear(),this.dirtyByTarget.clear(),this.revised.clear(),this.dependents.clear(),this.hasMore=t;let n=[...e].sort((e,t)=>C(e.event,t.event));for(let e of n)this.inputs.set(ze(e.event),e);this.locationIndex.rebuild(n),this.timelineDirty=!0;for(let e of n)this.matchInput(e);this.replayDependencies(),this.revised.clear();for(let e of this.contexts.values())this.markDirty(e);return this.replacePending=!0,`immediate`}append(e){let t=e.event,n=ze(t);if(this.inputs.has(n))return`none`;this.revised.size>0&&this.revised.clear(),this.inputs.set(n,e);let r=`none`;if(t.type!==`assistant/live-chunk`&&pt(t.type)){let e=this.locationIndex.snapshot(),n=this.locationIndex.appendBoundary(t);this.locationIndex.snapshot()!==e&&(this.timelineDirty=!0,r=`immediate`),this.replayContexts(this.refreshMatchLocations(n)),n.size>0&&(r=`immediate`)}else this.locationIndex.appendNonBoundary(t);return r=at(r,this.matchInput(e)),this.replayRevisedDependents()&&(r=`immediate`),this.revised.size>0&&this.revised.clear(),r}settleAssistant(e,t){this.revised.clear();let n=[...this.inputs.values()].filter(t=>t.type===`transient`&&t.event.data.attemptId===e),r=new Set(n.map(e=>ze(e.event))),i=/* @__PURE__ */ new Set;for(let e of r){this.inputs.delete(e);for(let t of this.contextsByEventKey.get(e)??[])i.add(t);this.contextsByEventKey.delete(e)}for(let e of i)e.matches=e.matches.filter(e=>!r.has(ze(e.event)));this.locationIndex.removeAssistantTransients(n.map(e=>e.event));let a=n.length===0?`none`:`immediate`;if(t!==void 0&&!this.inputs.has(t.event.seq)){this.inputs.set(t.event.seq,t),this.locationIndex.insertAssistantSettlement(t.event);let e=/* @__PURE__ */ new Map;a=at(a,this.collectInput(t,e)),this.applyPendingMatches(e,i)}return this.replayContexts(i),this.replayRevisedDependents()&&(a=`immediate`),this.revised.clear(),a}prepend(e,t){this.revised.clear();let n=`none`,r=this.hasMore,i=e.filter(e=>!this.inputs.has(ze(e.event))).sort((e,t)=>C(e.event,t.event));for(let e of i)this.inputs.set(ze(e.event),e);this.hasMore=t;let a=this.locationIndex.snapshot(),o=this.locationIndex.rebuild(this.sortedInputs());this.locationIndex.snapshot()!==a&&(this.timelineDirty=!0);let s=this.refreshMatchLocations(o),c=/* @__PURE__ */ new Map;for(let e of i)n=at(n,this.collectInput(e,c));return this.applyPendingMatches(c,s),this.replayContexts(s),(this.revised.size>0||r!==t)&&this.replayDependencies()&&(n=`immediate`),o.size>0&&(n=`immediate`),this.revised.clear(),n}rebuildRegistry(){return this.resetViewBuilders(),this.replaceWindow(this.sortedInputs(),this.hasMore)}flush(){if(!this.replacePending&&this.dirty.size===0&&!this.timelineDirty)return!1;if(this.replacePending){this.replaceLocationData();let e=[],t=this.locationIndex.takeChangedTurns();for(let n of this.activeTargets){let r=this.views.get(n);r!==void 0&&(this.updateView(r,!0,this.buildTargetNodes(n,this.contextsByTarget.get(n)),t),e.push(r))}return this.replacePending=!1,this.dirty.clear(),this.dirtyByTarget.clear(),this.timelineDirty=!1,this.publishViews(e)}let e=[];this.applyDirtyLocationData()&&(this.timelineDirty=!0);let t=this.locationIndex.takeChangedTurns(),n=this.timelineDirty;for(let r of this.activeTargets){let i=this.views.get(r);if(i===void 0||i.builder===void 0)continue;let a=this.buildTargetUpserts(r,this.dirtyByTarget.get(r));(a.length!==0||n)&&(this.updateView(i,!1,a,t),e.push(i))}return this.dirty.clear(),this.dirtyByTarget.clear(),this.timelineDirty=!1,this.publishViews(e)}activateTarget(e){let t=this.views.get(e);if(this.activeTargets.has(e))return!1;let n=this.flush();return this.activeTargets.add(e),t===void 0?n:(this.replaceView(t),this.publishViews([t]),!0)}snapshot(e){return this.views.get(e)?.snapshot}get(e){return this.snapshot(e)}grouped(e){return this.groups.get(e)?.store}activityTargets(){let e=/* @__PURE__ */ new Set;for(let t of this.activeTargets){let n=this.views.get(t);n!==void 0&&n.isActive?.(n.snapshot)===!0&&e.add(n.target)}return e}sortedInputs(){return[...this.inputs.values()].sort((e,t)=>C(e.event,t.event))}matchInput(e){return this.dispatchInput(e,this.acceptMatch)}collectInput(e,t){return this.dispatchInput(e,(e,n,r)=>{let i=Re(e.kind,n),a=t.get(i)??[];return a.push({definition:e,id:n,match:r}),t.set(i,a),e.publication?.(r)??`immediate`})}dispatchInput(e,t){let n=e.event,r,i,a,o=t=>(a??=this.locationIndex.locationOf(n),t===`start`?r??=ut(e,t,a):i??=ut(e,t,a)),s,c,l,u=`none`,d=this.eventDefinitions.forEvent?.(n.type);if(d===void 0)for(let e of this.eventDefinitions.entries()){let r=e.match(n);r!==null&&(e.target!==void 0&&e.target!==s&&e.target!==c&&(s===void 0?s=e.target:c===void 0?c=e.target:(l??=/* @__PURE__ */ new Set).add(e.target)),u=at(u,t.call(this,e,r.id,o(r.role))))}else for(let{definition:e,match:r}of d){let i=r(n);i!==null&&(e.target!==void 0&&e.target!==s&&e.target!==c&&(s===void 0?s=e.target:c===void 0?c=e.target:(l??=/* @__PURE__ */ new Set).add(e.target)),u=at(u,t.call(this,e,i.id,o(i.role))))}let f=this.eventDefinitions.fallbackEntry(),p=f?.target;if(f!==void 0&&p!==void 0&&p!==s&&p!==c&&l?.has(p)!==!0){let e=f.match(n);e!==null&&(u=at(u,t.call(this,f,e.id,o(e.role))))}return u}createContext(e,t,n){let r={key:n,kind:e.kind,id:t,definition:e,start:void 0,matches:[],state:void 0,revision:0,current:/* @__PURE__ */ new Map,locationData:it(),dependencies:/* @__PURE__ */ new Map};return this.contexts.set(n,r),this.indexTargetContext(r),r}acceptMatch(e,t,n){let r=this.contextsByKind.get(e.kind)?.at(-1),i=r?.id===t?r.key:Re(e.kind,t),a=this.contexts.get(i);a??=this.createContext(e,t,i);let o=n.role===`start`&&a.start===void 0,s=a.matches.at(-1);if(s!==void 0&&C(s.event,n.event)>=0)throw Error(`conversation Context ${i} received non-appended Match ${n.event.seq}`);if(o&&a.matches.length>0)throw Error(`conversation Context ${i} received an update before its start Match`);if(a.matches.push(n),o&&(a.start=n,this.indexStartedContext(a)),this.indexMatch(a,n),o)this.replayContext(a);else if(a.state!==void 0){let t=ct(a);a.state=mt(e,`update`,e.update(t,n)),a.revision++,this.revised.add(a)}return this.markDirty(a),e.publication?.(n)??`immediate`}indexMatch(e,t){let n=ze(t.event),r=this.contextsByEventKey.get(n);r===void 0&&(r=[],this.contextsByEventKey.set(n,r)),r.push(e)}applyPendingMatches(e,t){for(let[n,r]of e){let e=r[0];if(e===void 0)continue;let i=this.contexts.get(n);i??=this.createContext(e.definition,e.id,n);let a=r.map(e=>{if(e.definition!==i.definition||e.id!==i.id)throw Error(`conversation Context ${n} received inconsistent Definition identity`);return this.indexMatch(i,e.match),e.match}).sort((e,t)=>C(e.event,t.event));i.matches=lt(i.key,a,i.matches),t.add(i),this.markDirty(i)}}replayContexts(e){this.refreshStarts(e);let t=[...e].sort(ot);for(let e of t)e.start===void 0?(e.state=void 0,this.replaceDependencies(e,/* @__PURE__ */ new Map),e.revision++,this.revised.add(e),this.markDirty(e)):this.replayContext(e)}refreshStarts(e){let t=/* @__PURE__ */ new Set,n=/* @__PURE__ */ new Map;for(let r of e){let e=r.matches.find(e=>e.role===`start`);if(e===r.start)continue;r.start=e,t.add(r);let i=n.get(r.kind)??[];e!==void 0&&i.push(r),n.set(r.kind,i)}for(let[e,r]of n){let n=this.contextsByKind.get(e)??[];this.contextsByKind.set(e,n.filter(e=>!t.has(e))),this.indexStartedContexts(e,r)}}replayContext(e){let t=e.start;if(t===void 0){e.state=void 0;return}if(e.matches[0]!==t)throw Error(`conversation Context ${e.key} received an update before its start Match`);let n=/* @__PURE__ */ new Map,r=this.readerFor(t.event,n);e.state=void 0,e.state=mt(e.definition,`start`,e.definition.start(ct(e),t,r)),this.replaceDependencies(e,n);for(let t=1;t<e.matches.length;t++){let n=e.matches[t];if(n===void 0)continue;let r=ct(e);e.state=mt(e.definition,`update`,e.definition.update(r,n))}e.revision++,this.revised.add(e),this.markDirty(e)}indexTargetContext(e){let t=e.definition.target;if(t===void 0)return;let n=this.contextsByTarget.get(t)??/* @__PURE__ */ new Set;n.add(e),this.contextsByTarget.set(t,n)}markDirty(e){if(this.dirty.has(e))return;this.dirty.add(e);let t=e.definition.target;if(t===void 0||!this.activeTargets.has(t))return;let n=this.dirtyByTarget.get(t);n===void 0&&(n=/* @__PURE__ */ new Set,this.dirtyByTarget.set(t,n)),n.add(e)}replaceDependencies(e,t){for(let t of e.dependencies.values()){if(t.key===void 0)continue;let n=this.dependents.get(t.key);n?.delete(e),n?.size===0&&this.dependents.delete(t.key)}e.dependencies=t;for(let n of t.values()){if(n.key===void 0)continue;let t=this.dependents.get(n.key)??/* @__PURE__ */ new Set;t.add(e),this.dependents.set(n.key,t)}}replayRevisedDependents(){if(this.dependents.size===0)return!1;let e=[...this.revised],t=/* @__PURE__ */ new Set;for(let n=0;n<e.length;n++){let r=e[n];if(r!==void 0)for(let n of this.dependents.get(r.key)??[])t.has(n)||(t.add(n),e.push(n))}return t.size>0&&this.replayContexts(t),t.size>0}readerFor(e,t){return{previous:n=>{let r=this.previousContext(n,e);if(t.set(n,{kind:n,key:r?.key,revision:r?.revision,windowGap:r===void 0&&this.hasMore}),r?.state===void 0)return;let i=r.start?.event.seq;if(i!==void 0)return{key:r.key,kind:r.kind,id:r.id,startSeq:i,state:r.state,matches:r.matches}}}}previousContext(e,t){let n=this.contextsByKind.get(e)??[],r=st(n,t);for(let e=r-1;e>=0;e--){let t=n[e];if(t?.state!==void 0)return t}}indexStartedContext(e){let t=e.start;if(t===void 0)return;let n=this.contextsByKind.get(e.kind)??[],r=n.at(-1);r===void 0||ot(r,e)<0?n.push(e):n.splice(st(n,t.event),0,e),this.contextsByKind.set(e.kind,n)}indexStartedContexts(e,t){if(t.length===0)return;let n=[...t].sort(ot),r=this.contextsByKind.get(e)??[],i=[],a=0,o=0;for(;a<r.length||o<n.length;){let e=r[a],t=n[o];t===void 0||e!==void 0&&ot(e,t)<0?(i.push(e),a++):(i.push(t),o++)}this.contextsByKind.set(e,i)}replayDependencies(){let e=!1,t=[...this.contexts.values()].filter(e=>e.start!==void 0).sort(ot);for(let n of t){if(n.state===void 0||n.dependencies.size===0)continue;let t=n.start?.event;if(t===void 0)continue;let r=!1;for(let e of n.dependencies.values()){let n=this.previousContext(e.kind,t),i=n===void 0&&this.hasMore;if(n?.key!==e.key||n?.revision!==e.revision||i!==e.windowGap){r=!0;break}}r&&(this.replayContext(n),e=!0)}return e}refreshMatchLocations(e){let t=/* @__PURE__ */ new Set;if(e.size===0)return t;for(let n of e)for(let e of this.contextsByEventKey.get(n)??[])t.add(e);for(let n of t){let t=n.start;n.matches=n.matches.map(n=>{if(!e.has(ze(n.event)))return n;if(n.role===`start`){let e={...n,location:this.locationIndex.locationOf(n.event)};return n===t&&(t=e),e}return{...n,location:this.locationIndex.locationOf(n.event)}}),n.start=t}return t}buildNode(e,t){if(e.definition.target!==t||e.definition.buildViewNode===void 0)return null;let n=e.definition.buildViewNode(ct(e));if(n===null)return null;if(n.key!==e.key)throw Error(`conversation Definition "${e.kind}" returned unstable key "${n.key}"; expected "${e.key}"`);if(n.target!==t)throw Error(`conversation Definition "${e.kind}" returned target "${n.target}" while building "${t}"`);return n}replaceView(e){this.updateView(e,!0,this.buildTargetNodes(e.target,this.contextsByTarget.get(e.target)),[])}updateView(e,t,n,r){let i=e.builder??e.definition.create(),a=e.groupDefinition;if(a!==void 0&&i.groupInput===void 0)throw Error(`conversation group target "${e.target}" requires builder.groupInput()`);e.builder=i;let o=this.locationIndex.snapshot(),s=t?i.replace({nodes:n,timeline:o,changedTurns:r}):i.apply({upserts:n,timeline:o,changedTurns:r});if(a!==void 0&&i.groupInput!==void 0){let t=this.groups.get(e.target),n=t===void 0;t===void 0&&(t={definition:a,state:a.create(),store:new Ue});let r=i.groupInput();t.state=a.update(t,r);let o=a.buildGroups(t);if((n||r.kind===`replace`)&&(o===null||o.entries===void 0||o.groups.kind!==`replace`))throw Error(`conversation group target "${e.target}" requires complete grouping for replacement input`);o!==null&&(t.store.prepareAndInstall(o,r.readNode),this.pendingGroupStores.add(t.store)),this.groups.set(e.target,t)}e.snapshot=s}publishViews(e){let t=e.length>0||this.pendingGroupStores.size>0,n=[...this.pendingGroupStores];this.pendingGroupStores.clear();for(let t of e)t.builder?.publish?.();for(let e of n)e.publish();return this.locationIndex.publishData(),t}buildTargetNodes(e,t){let n=[];for(let r of t??[]){let t=this.buildNode(r,e);r.current.set(e,t),t!==null&&n.push(t)}return n}buildTargetUpserts(e,t){let n=[];for(let r of t??[]){let t=r.current.get(e)??null,i=this.buildNode(r,e);if(i===null&&t!==null)throw Error(`conversation Definition "${r.kind}" withdrew materialized target "${e}"; return the same key with hidden visibility instead`);r.current.set(e,i),i!==null&&n.push(i)}return n}buildLocationData(e,t,n){if(e.definition.buildLocationData===void 0)return null;let r=e.definition.buildLocationData(ct(e),t,n);if(r===null)return null;if(r.kind!==t)throw Error(`conversation Definition "${e.kind}" published ${r.kind} data through its ${t} scope`);if(r.key!==e.kind)throw Error(`conversation Definition "${e.kind}" published Location data key "${r.key}"; expected its owned kind`);if(!Number.isSafeInteger(r.turn)||r.turn<0)throw Error(`conversation Definition "${e.kind}" published invalid turn ${r.turn}`);if(r.kind===`step`&&(!Number.isSafeInteger(r.step)||r.step<0))throw Error(`conversation Definition "${e.kind}" published invalid step ${String(r.step)}`);return r}replaceLocationData(){let e=[];for(let t of rt){for(let n of this.contexts.values()){let r=this.buildLocationData(n,t,n.locationData[t]);n.locationData[t]=r,r!==null&&e.push({owner:n.key,data:r})}this.locationIndex.replaceData(e)}}applyDirtyLocationData(){let e=!1;for(let t of rt){let n=[];for(let e of this.dirty){let r=e.locationData[t],i=this.buildLocationData(e,t,r);r!==i&&(e.locationData[t]=i,n.push({owner:e.key,previous:r,next:i}))}e=this.locationIndex.applyData(n)||e}return e}resetViewBuilders(){let e=this.viewDefinitions.entries(),t=new Set(e.map(e=>e.target));for(let[e,n]of this.groups)(!t.has(e)||this.groupDefinitions.forTarget(e)!==n.definition)&&(n.store.clear(),this.pendingGroupStores.add(n.store),this.groups.delete(e));this.views.clear();for(let t of e){let e={target:t.target,definition:t,groupDefinition:this.groupDefinitions.forTarget(t.target),isActive:t.isActive===void 0?void 0:e=>t.isActive?.(e)===!0,builder:void 0,snapshot:void 0};this.views.set(t.target,e)}this.replacePending=!0}};function pt(e){return e===`turn/start`||e===`turn/end`||e===`step/start`||e===`step/end`}function mt(e,t,n){if(n===void 0)throw Error(`conversation Definition "${e.kind}" returned undefined from ${t}()`);return n}var ht=class{ctx;definitions=/* @__PURE__ */ new Map;listeners=/* @__PURE__ */ new Set;cached=[];constructor(e){this.ctx=e,Object.defineProperty(this,m.Service.tracker,{value:{property:`ctx`}})}entries(){return this.cached}subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}registerDefinition(e,t,n,r){if(this.definitions.has(e))throw Error(n);let i=this.ctx.effect(()=>(this.definitions.set(e,t),this.refresh(),()=>{this.definitions.get(e)===t&&(this.definitions.delete(e),this.refresh())}),r);return()=>{i()}}refresh(){this.cached=[...this.definitions.values()],(0,f.notifySubscribers)(this.listeners,`[ui-conversation] definition registry`)}},gt=class extends ht{fallback;routes=/* @__PURE__ */ new Map;unrestricted=/* @__PURE__ */ new Set;tables=/* @__PURE__ */ new WeakMap;register(e){return _t(e),this.registerDefinition(e.kind,this.resolve(e),`conversation Definition "${e.kind}" is already registered`,`uiConversation.events.register(${JSON.stringify(e.kind)})`)}registerFallback(e){if(_t(e),e.target===void 0)throw Error(`conversation fallback Definition must declare a target`);if(this.fallback!==void 0)throw Error(`conversation fallback Definition is already registered`);let t=this.resolve(e),n=this.ctx.effect(()=>(this.fallback=t,this.refresh(),()=>{this.fallback===t&&(this.fallback=void 0,this.refresh())}),`uiConversation.events.registerFallback(${JSON.stringify(t.kind)})`);return()=>{n()}}fallbackEntry(){return this.fallback}forEvent(e){return this.routes.get(e)??this.unrestricted}resolve(e){if(typeof e.match==`function`)return e;let t=new Map(Object.entries(e.match)),n={...e,match:e=>t.get(e.type)?.call(n,e)??null};return this.tables.set(n,t),n}refresh(){let e=/* @__PURE__ */ new Map,t=/* @__PURE__ */ new Set;for(let n of this.definitions.values()){let r=this.tables.get(n);if(r===void 0){let r={definition:n,match:n.match.bind(n)};t.add(r);for(let t of e.values())t.add(r)}else for(let[i,a]of r){let r=e.get(i);r===void 0&&(r=new Set(t),e.set(i,r)),r.add({definition:n,match:a.bind(n)})}}this.routes=e,this.unrestricted=t,super.refresh()}};function _t(e){if(e.target===void 0!=(e.buildViewNode===void 0))throw Error(`conversation Definition "${e.kind}" must declare target and buildViewNode together`)}function vt(e){let t=``,n=32768;for(let r=0;r<e.length;r+=n)t+=String.fromCharCode(...e.subarray(r,r+n));return btoa(t)}function yt(){let e=globalThis.crypto.getRandomValues(/* @__PURE__ */ new Uint8Array(16)),t=Array.from(e,(e,t)=>(t===6?e&15|64:t===8?e&63|128:e).toString(16).padStart(2,`0`)).join(``);return`${t.slice(0,8)}-${t.slice(8,12)}-${t.slice(12,16)}-${t.slice(16,20)}-${t.slice(20)}`}var bt=class{sessions;maxEntries;maxBytes;maxDecodedBytes;lru=/* @__PURE__ */ new Set;byKey=/* @__PURE__ */ new Map;byLeaf=/* @__PURE__ */ new Map;byNameBytes=/* @__PURE__ */ new Map;byPendingName=/* @__PURE__ */ new Map;inflight=/* @__PURE__ */ new Map;urls=/* @__PURE__ */ new Set;totalBytes=0;totalDecodedBytes=0;disposed=!1;constructor(e,t,n={}){this.sessions=t,this.maxEntries=Math.max(1,Math.floor(n.maxEntries??20)),this.maxBytes=Math.max(1,Math.floor(n.maxBytes??25165824)),this.maxDecodedBytes=Math.max(1,Math.floor(n.maxDecodedBytes??100663296)),e.effect(()=>()=>{this.dispose()},`ui-conversation historical image cache`)}resolve(e,t){if(this.disposed)return Promise.reject(/* @__PURE__ */ Error(`ui-conversation image cache is disposed`));let n=this.sessions.binding(e);if(n===void 0)return Promise.reject(/* @__PURE__ */ Error(`ui-conversation: unknown session "${e}"`));let r=this.lookup(e,t,!0);if(r!==void 0)return Promise.resolve(r.url);let i=xt(e,t.attachmentId),a=this.inflight.get(i);if(a!==void 0)return a;let o=n.session.readAttachment(t.attachmentId).then(e=>{if(!e.ok)throw Object.assign(Error(e.error.message),e.error);if(this.disposed)throw Error(`ui-conversation image cache was disposed before loading completed`);let n=this.byKey.get(i);if(n!==void 0)return this.touch(n),n.url;let r;r=typeof URL.createObjectURL==`function`?URL.createObjectURL(new Blob([Ot(e.value.data)],{type:e.value.attachment.mediaType})):`data:${e.value.attachment.mediaType};base64,${vt(e.value.data)}`;let a=Tt(e.value.data.byteLength),o=Dt(a,e.value.attachment.width??t.width,e.value.attachment.height??t.height);return this.insertRecord(i,r,a,o).url}).finally(()=>{this.inflight.get(i)===o&&this.inflight.delete(i)});return this.inflight.set(i,o),o}peek(e,t){if(!(this.disposed||this.sessions.binding(e)===void 0))return this.lookup(e,t,!0)?.url}cacheUploaded(e,t){if(this.disposed||this.sessions.binding(e)===void 0||typeof URL.createObjectURL!=`function`)return!1;let n=xt(e,t.attachmentId),r=Tt(t.bytes??t.blob.size),i=this.byKey.get(n);if(i!==void 0)return this.touch(i),this.indexUploadedFallbacks(e,t.attachmentId,t.name,r,i),!0;let a=URL.createObjectURL(t.blob),o=Dt(r,t.width,t.height),s=this.insertRecord(n,a,r,o);return this.indexUploadedFallbacks(e,t.attachmentId,t.name,r,s),!0}aliasUploaded(e,t,n){if(this.disposed||this.sessions.binding(e)===void 0)return!1;let r=this.byKey.get(xt(e,t));return r!==void 0&&(this.bindKey(xt(e,n.attachmentId),r),this.clearPendingNameIndexes(r),this.touch(r),!0)}clearPendingUploaded(e,t){if(this.disposed)return;let n=this.byKey.get(xt(e,t));n!==void 0&&this.clearPendingNameIndexes(n)}seed(e,t,n,r){if(this.disposed||this.sessions.binding(e)===void 0)return!1;let i=xt(e,t.attachmentId),a=this.byKey.get(i);if(a!==void 0)return this.touch(a),!1;let o=Tt(r??t.bytes),s=Dt(o,t.width,t.height);return this.insertRecord(i,n,o,s),!0}lookup(e,t,n){let r=xt(e,t.attachmentId),i=this.byKey.get(r);if(i!==void 0)return this.touch(i),i;let a=this.findUploadedFallback(e,t);if(a!==void 0)return n&&(this.bindKey(r,a.record),a.consumedPendingName&&this.clearPendingNameIndexes(a.record)),this.touch(a.record),a.record}findUploadedFallback(e,t){let n=t.name;if(n===void 0||n===``)return;let r=this.byLeaf.get(St(e,n));if(r!==void 0)return{record:r,consumedPendingName:!0};let i=Tt(t.bytes);if(i>0){let t=jt(this.byNameBytes.get(Ct(e,n,i)));if(t!==void 0)return{record:t,consumedPendingName:!0}}if(i===0){let t=jt(this.byPendingName.get(wt(e,n)));if(t!==void 0)return{record:t,consumedPendingName:!0}}}indexUploadedFallbacks(e,t,n,r,i){if(t.startsWith(`web-image:`)){let n=t.slice(10);if(n!==``){let t=St(e,n);this.byLeaf.set(t,i),i.leafKeys.add(t)}}if(n!==void 0&&n!==``){if(r>0){let t=Ct(e,n,r);kt(this.byNameBytes,t,i),i.nameBytesKeys.add(t)}let t=wt(e,n);kt(this.byPendingName,t,i),i.pendingNameKeys.add(t)}}insertRecord(e,t,n,r){let i={url:t,bytes:n,decodedBytes:r,keys:/* @__PURE__ */ new Set([e]),leafKeys:/* @__PURE__ */ new Set,nameBytesKeys:/* @__PURE__ */ new Set,pendingNameKeys:/* @__PURE__ */ new Set};return this.urls.add(t),this.byKey.set(e,i),this.lru.add(i),this.totalBytes+=n,this.totalDecodedBytes+=r,this.enforceBudget(i),i}bindKey(e,t){let n=this.byKey.get(e);n!==t&&(n!==void 0&&(n.keys.delete(e),n.keys.size===0&&this.deleteRecord(n)),this.byKey.set(e,t),t.keys.add(e))}touch(e){this.lru.delete(e)&&this.lru.add(e)}enforceBudget(e){for(let t of this.lru){if(this.lru.size<=this.maxEntries&&this.totalBytes<=this.maxBytes&&this.totalDecodedBytes<=this.maxDecodedBytes)break;t!==e&&this.deleteRecord(t)}}clearPendingNameIndexes(e){for(let t of e.pendingNameKeys)At(this.byPendingName,t,e);e.pendingNameKeys.clear()}deleteRecord(e){if(this.lru.delete(e)){this.totalBytes=Math.max(0,this.totalBytes-e.bytes),this.totalDecodedBytes=Math.max(0,this.totalDecodedBytes-e.decodedBytes);for(let t of e.keys)this.byKey.get(t)===e&&this.byKey.delete(t);e.keys.clear();for(let t of e.leafKeys)this.byLeaf.get(t)===e&&this.byLeaf.delete(t);e.leafKeys.clear();for(let t of e.nameBytesKeys)At(this.byNameBytes,t,e);e.nameBytesKeys.clear(),this.clearPendingNameIndexes(e),this.releaseUrl(e.url)}}releaseUrl(e){this.urls.delete(e)&&Mt(e)}dispose(){if(!this.disposed){this.disposed=!0,this.inflight.clear();for(let e of this.urls)Mt(e);this.urls.clear(),this.lru.clear(),this.byKey.clear(),this.byLeaf.clear(),this.byNameBytes.clear(),this.byPendingName.clear(),this.totalBytes=0,this.totalDecodedBytes=0}}};function xt(e,t){return`${e}\0${t}`}function St(e,t){return`${e}\0${t}`}function Ct(e,t,n){return`${e}\0${n}\0${t}`}function wt(e,t){return`${e}\0${t}`}function Tt(e){return typeof e==`number`&&Number.isFinite(e)&&e>0?Math.floor(e):0}function Et(e){return typeof e==`number`&&Number.isFinite(e)&&e>0?Math.floor(e):void 0}function Dt(e,t,n){let r=Et(t),i=Et(n);return r!==void 0&&i!==void 0?Math.min(2**53-1,r*i*4):e*8}function Ot(e){return e.buffer instanceof ArrayBuffer?e.byteOffset===0&&e.byteLength===e.buffer.byteLength?e.buffer:new Uint8Array(e.buffer,e.byteOffset,e.byteLength):Uint8Array.from(e)}function kt(e,t,n){let r=e.get(t);r===void 0&&(r=/* @__PURE__ */ new Set,e.set(t,r)),r.add(n)}function At(e,t,n){let r=e.get(t);r!==void 0&&(r.delete(n),r.size===0&&e.delete(t))}function jt(e){if(e!==void 0&&e.size===1)return e.values().next().value}function Mt(e){e.startsWith(`blob:`)&&URL.revokeObjectURL(e)}var Nt=class extends ht{register(e){return this.registerDefinition(e.target,e,`conversation view target "${e.target}" is already registered`,`uiConversation.views.register(${JSON.stringify(e.target)})`)}},Pt=class extends ht{views;constructor(e,t){super(e),this.views=t}register(e){if(!this.views.entries().some(t=>t.target===e.target))throw Error(`conversation group target "${e.target}" is not registered`);return this.registerDefinition(e.target,e,`conversation group target "${e.target}" is already registered`,`uiConversation.groups.register(${JSON.stringify(e.target)})`)}forTarget(e){return this.definitions.get(e)}};let Ft=`codexhost:window-hidden-change`;function It(e){let t=e?.detail;if(typeof t?.hidden==`boolean`)return t.hidden;let n=typeof window<`u`?window.__codexhostWindowHidden:void 0;return typeof n==`boolean`?n:globalThis.__codexhostWindowHidden===!0}function Lt(e){return typeof document<`u`&&document.hidden===!0||It(e)}var Rt=class{assembler;snapshot;openTurn;viewStore;targetSources=/* @__PURE__ */ new Map;revision=-1;timer;frame;deferredWhileHidden=!1;disposed=!1;disposeVisibilityListeners;disposeFeed=()=>{};constructor(e,t){this.assembler=t,this.viewStore=t,this.snapshot=(0,f.createSnapshotStore)(this.currentSnapshot()),this.openTurn=(0,f.createSnapshotStore)(t.openTurn()),this.replace(e.getSnapshot()),this.disposeFeed=e.subscribe(()=>{this.accept(e.getSnapshot())})}target(e){let t=this.targetSources.get(e);if(t===void 0){let n=this.viewStore;t={getSnapshot:()=>n.get(e),subscribe:t=>{let n=this.snapshot.subscribe(t);return this.activate(e),n}},this.targetSources.set(e,t)}return t}activate(e){this.assembler.activateTarget(e)&&(this.cancelScheduledFlush(),this.snapshot.set(this.currentSnapshot())),this.openTurn.set(this.assembler.openTurn())}rebuild(){this.publish(this.assembler.rebuildRegistry())}dispose(){this.disposed||(this.disposed=!0,this.cancelScheduledFlush(),this.disposeFeed())}replace(e){this.revision=e.revision,this.publish(this.assembler.replaceWindow(e.entries,e.hasMore))}accept(e){if(e.revision!==this.revision){if(e.revision!==this.revision+1||e.change.kind===`replace`)this.replace(e);else switch(this.revision=e.revision,e.change.kind){case`prepend`:this.publish(this.assembler.prepend(e.change.entries,e.hasMore));return;case`append`:{let t=`none`;for(let n of e.change.entries){let e=this.assembler.append(n);(e===`immediate`||t===`none`)&&(t=e)}this.publish(t);return}case`settle-assistant`:this.publish(this.assembler.settleAssistant(e.change.attemptId,e.change.entry));return}}}publish(e){if(!(this.disposed||e===`none`)){if(e===`animation-frame`){if(Lt()){this.deferWhileHidden();return}this.scheduleCoalescedFlush()}else this.cancelScheduledFlush(),this.flush()}}scheduleCoalescedFlush(){this.disposed||this.timer!==void 0||this.frame!==void 0||(this.detachVisibilityListeners(),this.deferredWhileHidden=!1,this.timer=setTimeout(()=>{this.timer=void 0,!this.disposed&&(Lt()?this.deferWhileHidden():typeof requestAnimationFrame==`function`?this.frame=requestAnimationFrame(()=>{this.frame=void 0,!this.disposed&&(Lt()?this.deferWhileHidden():this.flush())}):this.flush())},40))}deferWhileHidden(){this.disposed||(this.clearTimers(),this.deferredWhileHidden=!0,this.attachVisibilityListeners())}attachVisibilityListeners(){if(this.disposed||this.disposeVisibilityListeners!==void 0)return;let e=e=>{this.disposed||!this.deferredWhileHidden||Lt(e)||(this.deferredWhileHidden=!1,this.detachVisibilityListeners(),this.flush())},t=()=>e(),n=t=>e(t),r=typeof document<`u`&&typeof document.addEventListener==`function`?document:void 0,i=typeof window<`u`&&typeof window.addEventListener==`function`?window:void 0;r?.addEventListener(`visibilitychange`,t),i?.addEventListener(Ft,n),this.disposeVisibilityListeners=()=>{r?.removeEventListener(`visibilitychange`,t),i?.removeEventListener(Ft,n)}}detachVisibilityListeners(){let e=this.disposeVisibilityListeners;e!==void 0&&(this.disposeVisibilityListeners=void 0,e())}clearTimers(){this.timer!==void 0&&(clearTimeout(this.timer),this.timer=void 0),this.frame!==void 0&&typeof cancelAnimationFrame==`function`&&cancelAnimationFrame(this.frame),this.frame=void 0}cancelScheduledFlush(){this.clearTimers(),this.deferredWhileHidden=!1,this.detachVisibilityListeners()}flush(){this.assembler.flush()&&this.snapshot.set(this.currentSnapshot()),this.openTurn.set(this.assembler.openTurn())}currentSnapshot(){return{views:this.viewStore,activeTargets:this.assembler.activityTargets()}}},zt=class extends m.Service{sessions;events;views;groups;bindings=new Ne;images;constructor(e,t){super(e,`uiConversation`),this.sessions=t,this.events=new gt(e),this.views=new Nt(e),this.groups=new Pt(e,this.views),this.images=new bt(e,t);let n=()=>{for(let e of this.bindings.values)e.binding.rebuild()},r=!1,i=()=>{r||(r=!0,queueMicrotask(()=>{r=!1,n()}))};e.effect(()=>{let e=this.events.subscribe(i),t=this.views.subscribe(i),n=this.groups.subscribe(i);return()=>{n(),t(),e();for(let e of[...this.bindings.values])this.drop(e,!0)}},`ui-conversation assembly`)}binding(e){let t=typeof e==`string`?e:e.sessionId,n=typeof e==`string`?this.sessions.binding(e):e;if(n===void 0)throw Error(`uiConversation.binding: unknown session "${t}"`);if(this.sessions.binding(t)!==n)throw Error(`uiConversation.binding: inactive session "${t}"`);let r=this.bindings.get(n);if(r!==void 0)return r.binding;let i=new Rt(n.eventSource,new ft(this.events,this.views,this.groups)),a={source:n,binding:i,disposeScope:()=>{}};this.bindings.set(n,a);let o=n.ctx.effect(()=>()=>{this.drop(a,!1)},`ui-conversation binding`);return a.disposeScope=()=>{o()},i}imageUrl(e,t){return this.images.resolve(e,t)}peekImageUrl(e,t){return this.images.peek(e,t)}seedImageUrl(e,t,n,r){return this.images.seed(e,t,n,r)}cacheUploadedImage(e,t){return this.images.cacheUploaded(e,t)}aliasUploadedImage(e,t,n){return this.images.aliasUploaded(e,t,n)}clearPendingUploadedImage(e,t){this.images.clearPendingUploaded(e,t)}inspectSystemPrompt(e,t){return Le(e,t)}inspectRequestPrompt(e,t,n){return Pe(e,t,n)}drop(e,t){this.bindings.get(e.source)===e&&(this.bindings.delete(e.source),e.binding.dispose(),t&&e.disposeScope())}};function Bt(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 Vt(e,t=`|`){return e.map(e=>gn(e)).join(t)}function Ht(e,t){return typeof t==`bigint`?t.toString():t}var Ut=class{constructor(e){this._getter=e,this._value=void 0}get value(){let e=this._getter;return e!==void 0&&(this._value=e(),this._getter=void 0),this._value}};function Wt(e){return new Ut(e)}function Gt(e){return e==null}function Kt(e){let t=+!!e.startsWith(`^`),n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function qt(e,t){let n=e/t,r=Math.round(n),i=4*2**-52*Math.max(Math.abs(n),1);return Math.abs(n-r)<i?0:n-r}let Jt=/* @__PURE__*/ Symbol(`evaluating`);function Yt(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==Jt)return r===void 0&&(r=Jt,r=n()),r},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function Xt(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function Zt(e){let t=Object.getOwnPropertyDescriptor(e,`shape`);return t?.get?t.get.raw:t?.value}function Qt(e){return Zt(e._zod.def)??e._zod.def.shape}function $t(e,t,n){Object.defineProperty(e,t,{get(){let e=n();return Xt(this,t,e),e},enumerable:!0,configurable:!0})}function en(e,t,n){t in e?Xt(e,t,n):e[t]=n}function tn(e,t,n,r){let i=Qt(t);for(let a of n){let n=Object.getOwnPropertyDescriptor(i,a);n.enumerable&&(n.get?$t(e,a,()=>{let e=t._zod.def.shape[a];return r?r(e,a):e}):en(e,a,r?r(n.value,a):n.value))}}function nn(e,t){for(let n of Reflect.ownKeys(t)){let r=Object.getOwnPropertyDescriptor(t,n);r.enumerable&&(r.get?$t(e,n,()=>t[n]):en(e,n,r.value))}}function rn(...e){let t={};for(let n of e){let e=Object.getOwnPropertyDescriptors(n);Object.assign(t,e)}return Object.defineProperties({},t)}function an(e){return JSON.stringify(e)}function on(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,``).replace(/[\s_-]+/g,`-`).replace(/^-+|-+$/g,``)}let sn=`captureStackTrace`in Error?Error.captureStackTrace:(...e)=>{};function cn(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}let ln=/* @__PURE__*/ Wt(()=>{if(ar.jitless||typeof navigator<`u`&&navigator?.userAgent?.includes(`Cloudflare`))return!1;try{return Function(``),!0}catch{return!1}});function un(e){if(cn(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!=`function`)return!0;let n=t.prototype;return cn(n)!==!1&&Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)!==!1}function dn(e){return un(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}let fn=/* @__PURE__*/ new Set([`string`,`number`,`symbol`]),pn=/* @__PURE__*/ new Set([`string`,`number`,`bigint`,`boolean`,`symbol`,`undefined`]);function mn(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function hn(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function w(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 gn(e){return typeof e==`bigint`?e.toString()+`n`:typeof e==`string`?`"${e}"`:`${e}`}function _n(e){return Object.keys(e).filter(t=>e[t]._zod.optin!==void 0&&e[t]._zod.optout===`optional`)}let vn={safeint:[-(2**53-1),2**53-1],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},yn={int64:[/* @__PURE__*/ BigInt(`-9223372036854775808`),/* @__PURE__*/ BigInt(`9223372036854775807`)],uint64:[/* @__PURE__*/ BigInt(0),/* @__PURE__*/ BigInt(`18446744073709551615`)]};function bn(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`);let i={};return tn(i,e,xn(e,t)),hn(e,rn(n,{shape:i,checks:[]}))}function xn(e,t){let n=Qt(e),r=[];for(let e of Reflect.ownKeys(t)){if(!Object.getOwnPropertyDescriptor(n,e)?.enumerable)throw Error(`Unrecognized key: "${String(e)}"`);t[e]&&r.push(e)}return r}function Sn(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`);let i=new Set(xn(e,t)),a={};return tn(a,e,Reflect.ownKeys(Qt(e)).filter(e=>!i.has(e))),hn(e,rn(n,{shape:a,checks:[]}))}function Cn(e,t){if(!un(t))throw Error(`Invalid input to extend: expected a plain object`);let n=e._zod.def.checks;if(n&&n.length>0){let n=Qt(e);for(let e of Reflect.ownKeys(t))if(Object.getOwnPropertyDescriptor(n,e)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return hn(e,rn(e._zod.def,{shape:wn(e,t)}))}function wn(e,t){let n={};return tn(n,e,Reflect.ownKeys(Qt(e))),nn(n,t),n}function Tn(e,t){if(!un(t))throw Error(`Invalid input to safeExtend: expected a plain object`);return hn(e,rn(e._zod.def,{shape:wn(e,t)}))}function En(e,t){if(!t?._zod?.def)throw Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");if(e._zod.def.checks?.length)throw Error(`.merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.`);let n={};return tn(n,e,Reflect.ownKeys(Qt(e))),tn(n,t,Reflect.ownKeys(Qt(t))),hn(e,rn(e._zod.def,{shape:n,get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]}))}function Dn(e,t,n,r=`partial`){let i=t._zod.def.checks;if(i&&i.length>0)throw Error(`.${r}() cannot be used on object schemas containing refinements`);let a=n?new Set(xn(t,n)):void 0,o={};return tn(o,t,Reflect.ownKeys(Qt(t)),e&&((t,n)=>a&&!a.has(n)?t:new e({type:`optional`,innerType:t}))),hn(t,rn(t._zod.def,{shape:o,checks:[]}))}function On(e,t,n){let r=n?new Set(xn(t,n)):void 0,i={};return tn(i,t,Reflect.ownKeys(Qt(t)),(t,n)=>r&&!r.has(n)?t:new e({type:`nonoptional`,innerType:t})),hn(t,rn(t._zod.def,{shape:i}))}function kn(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 An(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 jn(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function Mn(e){return typeof e==`string`?e:e?.message}function Nn(e){let t=[];for(let n of e??[]){let e=n._zod.def;if(!/_(length|size)$|_equals$/.test(e.check))break;let r=e.maximum??e.length??e.size;r>=0&&t.push([r,n])}return t}function Pn(e,t,n){var r;for(let i=t;i<e.length;i++)(r=e[i]).schema??(r.schema=n)}function Fn(e,t,n){var r;let i=e.inst?._zod?.traits;i?.has(`$ZodType`)&&(i.has(`$ZodCheck`)?(r=e).schema??(r.schema=e.inst):e.schema=e.inst);let a=e.schema===e.inst?void 0:e.schema?._zod.def?.error,o=e.message?e.message:Mn(e.inst?._zod.def?.error?.(e))??Mn(a?.(e))??Mn(t?.error?.(e))??Mn(n.customError?.(e))??Mn(n.localeError?.(e))??`Invalid input`,s={};for(let t of Object.keys(e))t!==`inst`&&t!==`schema`&&t!==`continue`&&t!==`input`&&t!==`__proto__`&&(s[t]=e[t]);return s.path??=[],s.message=o,t?.reportInput&&(s.input=e.input),s}let In=/[\uD800-\uDBFF]/;function Ln(e){let t=e.length;if(!In.test(e))return t;let n=t;for(let r=0;r<t-1;r++)(e.charCodeAt(r)&64512)==55296&&(e.charCodeAt(r+1)&64512)==56320&&(n--,r++);return n}function Rn(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function zn(e){let t=typeof e;switch(t){case`number`:return Number.isNaN(e)?`nan`:`number`;case`object`:{if(e===null)return`null`;if(Array.isArray(e))return`array`;let t=e;if(t&&Object.getPrototypeOf(t)!==Object.prototype&&`constructor`in t&&t.constructor)return t.constructor.name}}return t}function Bn(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}function Vn(e,t){for(let n in t){let r=Object.getOwnPropertyDescriptor(t,n);r.get?Object.defineProperty(e,n,{...r,enumerable:!1}):Gn(e,n,r.value)}}function Hn(e,t,n,r=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:r,value:n}),n}function Un(e,t,n){return Hn(e,t,n,!1)}function Wn(e,t){for(let n in e){let r=e[n];Object.defineProperty(t,n,{configurable:!0,enumerable:!0,get(){return Hn(this,n,r(this))},set(e){Hn(this,n,e)}})}return t}function Gn(e,t,n){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?n:Hn(this,t,n.bind(this))},set(e){Hn(this,t,e)}})}function Kn(e,t){let n=Object.getPrototypeOf(e);return t in n?void 0:n}let qn,Jn=!1,Yn={configurable:!0,get(){Jn=!0}};function T(e,t,n){let r=Object.getPrototypeOf(e._zod);t in r&&qn!==e._zod?qn=void 0:(qn=e._zod,Object.defineProperty(r,t,{configurable:!0,get(){Object.defineProperty(this,t,Yn);let e=Jn;Jn=!1;try{let r=n(this);return Jn?delete this[t]:Object.defineProperty(this,t,{configurable:!0,writable:!0,value:r}),Jn||=e,r}catch(n){throw delete this[t],Jn||=e,n}},set(e){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:e})}}))}function Xn(e,t,n,r){let i=Kn(e,t);i&&Object.defineProperty(i,t,{configurable:!0,get(){let e={configurable:!0,writable:!0,enumerable:r,value:void 0};return Object.defineProperty(this,t,e),e.value=n(this),Object.defineProperty(this,t,e),e.value},set(e){Object.defineProperty(this,t,{configurable:!0,writable:!0,enumerable:r,value:e})}})}function Zn(e){let t=()=>e;return t[`~constantCatch`]=!0,t}var Qn;let $n=/*@__PURE__*/ Object.freeze({status:`aborted`}),er={value:void 0,enumerable:!1},tr=`captureStackTrace`in Error?Error:null;function nr(e){let t=tr;if(t){let n=t.stackTraceLimit;if(typeof n==`number`){try{t.stackTraceLimit=0}catch{return tr=null,new e}try{return new e}finally{t.stackTraceLimit=n}}}return new e}function E(e,t,n,r){let i={};function a(e){this.def=e,this.constr=d,this.traits=/* @__PURE__ */ new Set}a.prototype=i;let o=n,s=o&&/* @__PURE__ */ new WeakSet;function c(n,r){if(!n._zod){er.value=new a(r);try{Object.defineProperty(n,"_zod",er)}finally{er.value=void 0}}else if(n._zod.traits.has(e))return;if(n._zod.traits.add(e),t(n,r),s){let e=Object.getPrototypeOf(n),t=n._zod.constr.prototype,r=e;for(;r&&r!==t;)r=Object.getPrototypeOf(r);let i=r??e;s.has(i)||(s.add(i),Vn(i,o))}let i=d.prototype;for(let e in i)Object.prototype.hasOwnProperty.call(i,e)&&(e in n||(n[e]=i[e].bind(n)))}let l=r?.Parent??Object;class u extends l{}Object.defineProperty(u,"name",{value:e});function d(e){let t=r?.Parent?nr(u):this;c(t,e);let n=t._zod.deferred;if(n){for(let e of n)e();t._zod.deferred=void 0}let i=globalThis.__zod_globalConfig?.postProcessor;return i&&i(t),t}return Object.defineProperty(d,"init",{value:c}),Object.defineProperty(d,Symbol.hasInstance,{value:t=>r?.Parent&&t instanceof r.Parent?!0:t?._zod?.traits?.has(e)}),Object.defineProperty(d,"name",{value:e}),d}var rr=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}},ir=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name=`ZodEncodeError`}};(Qn=globalThis).__zod_globalConfig??(Qn.__zod_globalConfig={});let ar=globalThis.__zod_globalConfig;function or(e){return e&&Object.assign(ar,e),ar}function sr(){let e=this._zod;return e.message??=JSON.stringify(e.def,Ht,2),e.message}function cr(e){this._zod.message=e}let lr={get:sr,set:cr,enumerable:!0,configurable:!0},ur={value:void 0,enumerable:!1},dr=/* @__PURE__ */ new WeakSet([Object.prototype,Error.prototype]),fr=(e,t)=>{e.name=`$ZodError`,ur.value=t,Object.defineProperty(e,"issues",ur),ur.value=void 0,Object.defineProperty(e,"message",lr);let n=Object.getPrototypeOf(e);dr.has(n)||(dr.add(n),Object.defineProperty(n,"toString",{configurable:!0,enumerable:!1,get(){let e=()=>this.message;return Object.defineProperty(this,"toString",{value:e,configurable:!0,writable:!0}),e},set(e){Object.defineProperty(this,"toString",{value:e,configurable:!0,writable:!0})}}))},pr=E(`$ZodError`,fr);E(`$ZodError`,fr,void 0,{Parent:Error});function mr(e,t,n){return Object.prototype.hasOwnProperty.call(e,t)||(t===`__proto__`?Object.defineProperty(e,t,{value:n(),writable:!0,enumerable:!0,configurable:!0}):e[t]=n()),e[t]}function hr(e,t=e=>e.message){let n={},r=[];for(let i of e.issues)i.path.length>0?mr(n,i.path[0],()=>[]).push(t(i)):r.push(t(i));return{formErrors:r,fieldErrors:n}}function gr(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],o=i===e.length-1;if(n===`_errors`){o&&r._errors.push(t(a)),i++;continue}Object.prototype.hasOwnProperty.call(r,n)||Object.defineProperty(r,n,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});let s=r[n];o&&s._errors.push(t(a)),r=s,i++}}}};return r(e),n}function _r(e,t){return{callee:t?.callee??e,Err:t?.Err}}let vr=e=>{let t=(n,r,i,a)=>{let o=i?{...i,async:!1}:{async:!1},s=n._zod.run({value:r,issues:[]},o);if(s instanceof Promise)throw new rr;if(s.issues.length){let n=new((a?.Err)??e)(s.issues.map(e=>Fn(e,o,or())));throw sn(n,a?.callee??t),n}return s.value};return t},yr=e=>{let t=async(n,r,i,a)=>{let o=i?{...i,async:!0}:{async:!0},s=n._zod.run({value:r,issues:[]},o);if(s instanceof Promise&&(s=await s),s.issues.length){let n=new((a?.Err)??e)(s.issues.map(e=>Fn(e,o,or())));throw sn(n,a?.callee??t),n}return s.value};return t},br=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 rr;return a.issues.length?xr(e,a.issues,i):{success:!0,data:a.value}};function xr(e,t,n){let r;return{success:!1,get error(){return r||(r=new e(t.map(e=>Fn(e,n,or()))),t=void 0,n=void 0),r},set error(e){r=e,t=void 0,n=void 0}}}let Sr=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?xr(e,a.issues,i):{success:!0,data:a.value}},Cr=/* @__PURE__ */ Symbol.for(`zod.compile.invalid`),wr=/* @__PURE__ */ Symbol.for(`zod.compile.fallback`),Tr=((e,t,n)=>{let r=e._zod.bag.validator;if(r!==void 0){if(r(t)!==Cr)return!0;if(r.definite===!0&&n===void 0)return!1}return Er(e,t,n)});function Er(e,t,n){let r=n?{...n,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},i=e._zod.bag.fallbackRun,a;if(i?(r[wr]=!0,a=i({value:t,issues:[]},r)):a=e._zod.run({value:t,issues:[]},r),a instanceof Promise)throw new rr;return a.issues.length===0}let Dr=async(e,t,n)=>{let r=n?{...n,async:!0,abortEarly:!0}:{async:!0,abortEarly:!0},i=e._zod.run({value:t,issues:[]},r);return i instanceof Promise&&(i=await i),i.issues.length===0},Or=e=>{let t=vr(e),n=(e,r,i,a)=>{let o=i?{...i,direction:`backward`}:{direction:`backward`};return t(e,r,o,_r(n,a))};return n},kr=e=>{let t=vr(e),n=(e,r,i,a)=>t(e,r,i,_r(n,a));return n},Ar=e=>{let t=yr(e),n=async(e,r,i,a)=>{let o=i?{...i,direction:`backward`}:{direction:`backward`};return await t(e,r,o,_r(n,a))};return n},jr=e=>{let t=yr(e),n=async(e,r,i,a)=>await t(e,r,i,_r(n,a));return n},Mr=e=>(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return br(e)(t,n,i)},Nr=e=>(t,n,r)=>br(e)(t,n,r),Pr=e=>async(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return Sr(e)(t,n,i)},Fr=e=>async(t,n,r)=>Sr(e)(t,n,r),Ir=/^[cC][0-9a-z]{6,}$/,Lr=/^[0-9a-z]+$/,Rr=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,zr=/^[0-9a-vA-V]{20}$/,Br=/^[A-Za-z0-9]{27}$/,Vr=/^[a-zA-Z0-9_-]{21}$/;function Hr(e){return RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}let Ur=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Wr=/^([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})$/,Gr=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)$/,Kr=/^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;function qr(){return RegExp(`^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$`,`u`)}let Jr=/^(?:(?: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])$/,Yr=/^(([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}|:))$/,Xr=/^((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])$/,Zr=/^(([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}|:))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Qr=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,$r=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/,ei=/^https?$/,ti=/^\+[1-9]\d{6,14}$/,ni=`(?:(?:\\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])))`;function ri(e){return RegExp(`^${e}$`)}let ii=/*@__PURE__*/ ri(ni);function ai(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}}`:e.seconds?`${t}:[0-5]\\d(?:\\.\\d+)?`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function oi(e){return RegExp(`^${ai(e)}$`)}function si(e){let t=[`Z`];e.offset&&t.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);let n=`${ai({precision:e.precision,seconds:!0})}(?:${t.join(`|`)})`,r=e.local?`${n}|${ai({precision:e.precision})}`:n;return RegExp(`^${ni}T(?:${r})$`)}let ci=/^[\s\S]{0,}$/,li=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??``}}`:`[\\s\\S]*`;return RegExp(`^${t}$`)},ui=/^-?\d+$/,di=/^-?\d+(?:\.\d+)?$/,fi=/^(?:true|false)$/i,pi=/^null$/i,mi=/^[^A-Z]*$/,hi=/^[^a-z]*$/,gi=/*@__PURE__*/ E(`$ZodCheck`,(e,t)=>{var n;e._zod??={},e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),_i=e=>{let t=e.value;return!Gt(t)&&t.length!==void 0},vi={number:`number`,bigint:`bigint`,object:`date`},yi=/*@__PURE__*/ E(`$ZodCheckLessThan`,(e,t)=>{gi.init(e,t);let n=vi[typeof t.value];e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:vi[typeof r.value]??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})}}),bi=/*@__PURE__*/ E(`$ZodCheckGreaterThan`,(e,t)=>{gi.init(e,t);let n=vi[typeof t.value];e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:vi[typeof r.value]??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})}}),xi=/*@__PURE__*/ E(`$ZodCheckMultipleOf`,(e,t)=>{gi.init(e,t),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`?t.value!==BigInt(0)&&n.value%t.value===BigInt(0):qt(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})}}),Si=/*@__PURE__*/ E(`$ZodCheckNumberFormat`,(e,t)=>{gi.init(e,t),t.format=t.format||`float64`;let n=t.format?.includes(`int`),r=n?`int`:`number`,[i,a]=vn[t.format];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})}}),Ci=/*@__PURE__*/ E(`$ZodCheckMaxLength`,(e,t)=>{var n;gi.init(e,t),(n=e._zod.def).when??(n.when=_i),e._zod.check=n=>{let r=n.value,i=r.length;if((typeof r==`string`&&i>t.maximum?Ln(r):i)<=t.maximum)return;let a=Rn(r);n.issues.push({origin:a,code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),wi=/*@__PURE__*/ E(`$ZodCheckMinLength`,(e,t)=>{var n;gi.init(e,t),(n=e._zod.def).when??(n.when=_i),e._zod.check=n=>{let r=n.value,i=r.length;if((typeof r==`string`&&i>=t.minimum&&i<t.minimum*2?Ln(r):i)>=t.minimum)return;let a=Rn(r);n.issues.push({origin:a,code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Ti=/*@__PURE__*/ E(`$ZodCheckLengthEquals`,(e,t)=>{var n;gi.init(e,t),(n=e._zod.def).when??(n.when=_i),e._zod.check=n=>{let r=n.value,i=r.length,a=typeof r==`string`&&i>=t.length&&i<=t.length*2?Ln(r):i;if(a===t.length)return;let o=Rn(r),s=a>t.length;n.issues.push({origin:o,...s?{code:`too_big`,maximum:t.length}:{code:`too_small`,minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),Ei=/*@__PURE__*/ E(`$ZodCheckStringFormat`,(e,t)=>{var n,r;gi.init(e,t),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=()=>{})}),Di=/*@__PURE__*/ E(`$ZodCheckRegex`,(e,t)=>{Ei.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})}}),Oi=/*@__PURE__*/ E(`$ZodCheckLowerCase`,(e,t)=>{t.pattern??=mi,Ei.init(e,t)}),ki=/*@__PURE__*/ E(`$ZodCheckUpperCase`,(e,t)=>{t.pattern??=hi,Ei.init(e,t)}),Ai=/*@__PURE__*/ E(`$ZodCheckIncludes`,(e,t)=>{gi.init(e,t);let n=mn(t.includes);t.pattern=new RegExp(typeof t.position==`number`?`^.{${t.position},}${n}`:n),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})}}),ji=/*@__PURE__*/ E(`$ZodCheckStartsWith`,(e,t)=>{gi.init(e,t);let n=RegExp(`^${mn(t.prefix)}.*`);t.pattern??=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})}}),Mi=/*@__PURE__*/ E(`$ZodCheckEndsWith`,(e,t)=>{gi.init(e,t);let n=RegExp(`.*${mn(t.suffix)}$`);t.pattern??=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})}}),Ni=/*@__PURE__*/ E(`$ZodCheckOverwrite`,(e,t)=>{gi.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}});var Pi=class{constructor(e=[],t={}){this.content=[],this.indent=0,this.args=e,this.closed=t}indented(e){this.indent+=1;try{e(this)}finally{--this.indent}}write(e){if(typeof e==`function`){e(this,{execution:`sync`}),e(this,{execution:`async`});return}let t=e.split(`
12
12
  `).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?.content??[``];return new e(...Object.keys(this.closed),`return function (${this.args.join(`, `)}) {\n${t.join(`
13
- `)}\n};`)(...Object.values(this.closed))}};let Ni={major:4,minor:6,patch:7},Pi=/*@__PURE__*/ E(`$ZodType`,(e,t)=>{var n;e??={},e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Ni;let r=e._zod.def.checks,i=e._zod.traits.has(`$ZodCheck`)?[e,...r??[]]:r?.length?[...r]:[];for(let t of i)for(let n of t._zod.onattach)n(e);if(i.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let t=(t,n,r)=>{if(t.memo)return t;let i=On(t),a;for(let o of n){if(o._zod.def.when){if(kn(t)||!o._zod.def.when(t))continue}else if(i)continue;let n=t.issues.length,s=o._zod.check(t);if(s instanceof Promise&&r?.async===!1)throw new nr;if(a||s instanceof Promise)a=(a??Promise.resolve()).then(async()=>{await s,t.issues.length!==n&&(Nn(t.issues,n,e),i||=On(t,n))});else{if(t.issues.length===n)continue;Nn(t.issues,n,e),i||=On(t,n)}}return a?a.then(()=>t):t},n=(n,r,a)=>{if(On(n))return n.aborted=!0,n;let o=t(r,i,a);if(o instanceof Promise){if(a.async===!1)throw new nr;return o.then(t=>e._zod.parse(t,a))}return e._zod.parse(o,a)};e._zod.run=(r,a)=>{if(a.skipChecks)return e._zod.parse(r,a);if(a.direction===`backward`){let t=e._zod.parse({value:r.value,issues:[]},{...a,skipChecks:!0});return t instanceof Promise?t.then(e=>n(e,r,a)):n(t,r,a)}let o=e._zod.parse(r,a);if(o instanceof Promise){if(a.async===!1)throw new nr;return o.then(e=>t(e,i,a))}return t(o,i,a)}}},{get"~standard"(){return Hn(this,`~standard`,Li(this))},set"~standard"(e){Vn(this,`~standard`,e)}}),Fi=(e,t)=>e.issues.length?{issues:e.issues.map(e=>Pn(e,t,ar()))}:{value:e.value};async function Ii(e,t){let n={async:!0};return Fi(await e._zod.run({value:t,issues:[]},n),n)}function Li(e){return{validate:t=>{let n={async:!1};try{let r=e._zod.run({value:t,issues:[]},n);if(!(r instanceof Promise))return Fi(r,n)}catch{}return Ii(e,t)},vendor:`zod`,version:1}}let Ri=/*@__PURE__*/ E(`$ZodString`,(e,t)=>{Pi.init(e,t),e._zod.pattern=t.pattern??si,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}}),zi=/*@__PURE__*/ E(`$ZodStringFormat`,(e,t)=>{wi.init(e,t),Ri.init(e,t)}),Bi=/*@__PURE__*/ E(`$ZodGUID`,(e,t)=>{t.pattern??=Ur,zi.init(e,t)}),Vi=/*@__PURE__*/ E(`$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??=Wr(e)}else t.pattern??=Wr();zi.init(e,t)}),Hi=/*@__PURE__*/ E(`$ZodEmail`,(e,t)=>{t.pattern??=Gr,zi.init(e,t)});function Ui(e){try{return typeof URL<`u`&&typeof URL.canParse==`function`?URL.canParse(e):(new URL(e),!0)}catch{return!1}}function Wi(e,t){return!(`normalize`in t)&&!(`hostname`in t)&&!(`protocol`in t)?Ui(e)||2:Gi(e,t)}function Gi(e,t){if(!t.normalize&&t.protocol?.source===$r.source&&!/^https?:\/\//i.test(e))return 1;try{if(typeof URL<`u`){let t=URL;if(typeof t.parse==`function`)return t.parse(e)??2}return new URL(e)}catch{return 2}}let Ki=/[\t\n\r]/g;function qi(e){return e.replace(Ki,``)}function Ji(e,t){return t.lastIndex=0,t.test(e.hostname)}function Yi(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(`:`)?e.protocol.slice(0,-1):e.protocol)}let Xi=/*@__PURE__*/ E(`$ZodURL`,(e,t)=>{zi.init(e,t),e._zod.check=n=>{try{let r=n.value.trim(),i=Wi(r,t);if(i===1){n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid URL format`,input:n.value,inst:e,continue:!t.abort});return}if(i===2){n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort});return}if(i===!0){n.value=qi(r);return}t.hostname&&!Ji(i,t.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&&!Yi(i,t.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:qi(r);return}catch{n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort})}}}),Zi=/*@__PURE__*/ E(`$ZodEmoji`,(e,t)=>{t.pattern??=Kr(),zi.init(e,t)}),Qi=/*@__PURE__*/ E(`$ZodNanoID`,(e,t)=>{if(t.length!==void 0&&(!Number.isInteger(t.length)||t.length<1))throw Error(`Invalid nanoid length: ${t.length}`);t.pattern??=t.length===void 0?Br:Vr(t.length),zi.init(e,t)}),$i=/*@__PURE__*/ E(`$ZodCUID`,(e,t)=>{t.pattern??=Fr,zi.init(e,t)}),ea=/*@__PURE__*/ E(`$ZodCUID2`,(e,t)=>{t.pattern??=Ir,zi.init(e,t)}),ta=/*@__PURE__*/ E(`$ZodULID`,(e,t)=>{t.pattern??=Lr,zi.init(e,t)}),na=/*@__PURE__*/ E(`$ZodXID`,(e,t)=>{t.pattern??=Rr,zi.init(e,t)}),ra=/*@__PURE__*/ E(`$ZodKSUID`,(e,t)=>{t.pattern??=zr,zi.init(e,t)}),ia=/*@__PURE__*/ E(`$ZodISODateTime`,(e,t)=>{t.pattern??=oi(t),zi.init(e,t)}),aa=/*@__PURE__*/ E(`$ZodISODate`,(e,t)=>{t.pattern??=ri,zi.init(e,t)}),oa=/*@__PURE__*/ E(`$ZodISOTime`,(e,t)=>{t.pattern??=ai(t),zi.init(e,t)}),sa=/*@__PURE__*/ E(`$ZodISODuration`,(e,t)=>{t.pattern??=Hr,zi.init(e,t)}),ca=/*@__PURE__*/ E(`$ZodIPv4`,(e,t)=>{t.pattern??=qr,zi.init(e,t)}),la=/^[0-9a-fA-F:.]+$/;function ua(e){return la.test(e)?Ui(`http://[${e}]`):!1}let da=/*@__PURE__*/ E(`$ZodIPv6`,(e,t)=>{t.pattern??=Jr,zi.init(e,t),e._zod.check=n=>{ua(n.value)||n.issues.push({code:`invalid_format`,format:`ipv6`,input:n.value,inst:e,continue:!t.abort})}}),fa=/*@__PURE__*/ E(`$ZodCIDRv4`,(e,t)=>{t.pattern??=Yr,zi.init(e,t)});function pa(e){let t=e.split(`/`);if(t.length!==2)return!1;let[n,r]=t;if(!r)return!1;let i=Number(r);return`${i}`!==r||i<0||i>128?!1:ua(n)}let ma=/*@__PURE__*/ E(`$ZodCIDRv6`,(e,t)=>{t.pattern??=Xr,zi.init(e,t),e._zod.check=n=>{pa(n.value)||n.issues.push({code:`invalid_format`,format:`cidrv6`,input:n.value,inst:e,continue:!t.abort})}});function ha(e){if(e===``)return!0;if(/\s/.test(e)||e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}let ga=/^[0-9a-zA-Z+/]*={0,2}$/,_a=/*@__PURE__*/ E(`$ZodBase64`,(e,t)=>{t.pattern??=ga,zi.init(e,t),e._zod.check=n=>{ha(n.value)||n.issues.push({code:`invalid_format`,format:`base64`,input:n.value,inst:e,continue:!t.abort})}}),va=/^[A-Za-z0-9_-]*$/;function ya(e){if(!va.test(e))return!1;let t=e.replace(/[-_]/g,e=>e===`-`?`+`:`/`);return ha(t.padEnd(Math.ceil(t.length/4)*4,`=`))}let ba=/*@__PURE__*/ E(`$ZodBase64URL`,(e,t)=>{t.pattern??=va,zi.init(e,t),e._zod.check=n=>{ya(n.value)||n.issues.push({code:`invalid_format`,format:`base64url`,input:n.value,inst:e,continue:!t.abort})}}),xa=/*@__PURE__*/ E(`$ZodE164`,(e,t)=>{t.pattern??=ei,zi.init(e,t)});function Sa(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 Ca=/*@__PURE__*/ E(`$ZodJWT`,(e,t)=>{zi.init(e,t),e._zod.check=n=>{Sa(n.value,t.alg)||n.issues.push({code:`invalid_format`,format:`jwt`,input:n.value,inst:e,continue:!t.abort})}}),wa=/*@__PURE__*/ E(`$ZodNumber`,(e,t)=>{Pi.init(e,t),e._zod.pattern=li,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:String(i):void 0;return n.issues.push({expected:`number`,code:`invalid_type`,input:i,inst:e,...a?{received:a}:{}}),n}}),Ta=/*@__PURE__*/ E(`$ZodNumberFormat`,(e,t)=>{bi.init(e,t),wa.init(e,t)}),Ea=/*@__PURE__*/ E(`$ZodBoolean`,(e,t)=>{Pi.init(e,t),e._zod.pattern=ui,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}}),Da=/*@__PURE__*/ E(`$ZodNull`,(e,t)=>{Pi.init(e,t),e._zod.pattern=di,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}}),Oa=/*@__PURE__*/ E(`$ZodUnknown`,(e,t)=>{Pi.init(e,t),e._zod.parse=e=>e}),ka=/*@__PURE__*/ E(`$ZodNever`,(e,t)=>{Pi.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:`never`,code:`invalid_type`,input:t.value,inst:e}),t)});function Aa(e,t){let n=Mn(e._zod.def.checks);if(!n.length)return;let r=Math.min(...n.map(e=>e[0])),i=e._zod.parse;e._zod.parse=(n,a)=>{let o=t(n.value);if(o>r&&!a?.skipChecks&&a?.direction!==`backward`){for(let[t,r]of Mn(e._zod.def.checks))if(o>t&&r._zod.def.when(n)){let t=n.issues.length;return r._zod.check(n),n.issues[t].continue=!1,Nn(n.issues,t,e),n}}return i(n,a)}}let ja=e=>Array.isArray(e)?e.length:-1;function Ma(e,t,n){e.issues.length&&t.issues.push(...An(n,e.issues)),t.value[n]=e.value}let Na=/*@__PURE__*/ E(`$ZodArray`,(e,t)=>{Pi.init(e,t);let n=ir.memoizer;n?.attach(e),e._zod.parse=(r,i)=>{let a=r.value;if(!Array.isArray(a))return r.issues.push({expected:`array`,code:`invalid_type`,input:a,inst:e}),r;r.value=n?n.alloc(e,r,Array(a.length),i):Array(a.length);let o=[],s=i?.abortEarly;for(let e=0;e<a.length;e++){let n=a[e],c=t.element._zod.run({value:n,issues:[]},i);if(c instanceof Promise)o.push(c.then(t=>Ma(t,r,e)));else if(Ma(c,r,e),s&&c.issues.length!==0&&On(c))break}return o.length?Promise.all(o).then(()=>r):r},Aa(e,ja)});function Pa(e,t,n,r,i,a){let o=n in r,s=a===`optional`;if(o||!s||i!==`optional`){if(e.issues.length){if(i!==void 0&&s&&!o)return;t.issues.push(...An(n,e.issues))}!o&&i===void 0?e.issues.length||t.issues.push({code:`invalid_type`,expected:`nonoptional`,input:void 0,path:[n]}):e.value===void 0?(o||i===`defaulted`&&!s)&&(t.value[n]=void 0):t.value[n]=e.value}}let Fa=[];function Ia(e){let t=Object.keys(e.shape),n=Object.getOwnPropertySymbols(e.shape),r=n.length?n:Fa,i=r.length?[...t,...r]:t;for(let t of i)if(!e.shape?.[t]?._zod?.traits?.has(`$ZodType`))throw Error(`Invalid element at key "${String(t)}": expected a Zod schema`);let a=gn(e.shape);return{...e,allKeys:i,symbolKeys:r,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(a)}}function La(e,t,n,r,i,a,o){let s=[],c=i.keySet,l=i.catchall._zod,u=l.def.type,d=l.optin,f=l.optout,p=0;for(let i in t){if(o&&n.issues.length!==p){if(On(n,p))break;p=n.issues.length}if(c.has(i))continue;if(i===`__proto__`){u===`never`&&s.push(i);continue}if(u===`never`){s.push(i);continue}let a=l.run({value:t[i],issues:[]},r);a instanceof Promise?e.push(a.then(e=>Pa(e,n,i,t,d,f))):Pa(a,n,i,t,d,f)}return s.length&&n.issues.push({code:`unrecognized_keys`,keys:s,input:t,inst:a,continue:!0}),e.length?Promise.all(e).then(()=>n):n}let Ra=/*@__PURE__*/ E(`$ZodObject`,(e,t)=>{Pi.init(e,t);let n=Object.getOwnPropertyDescriptor(t,`shape`),r=n?.get?n.get.raw:t.shape??{};if(r){let e=()=>{let n={...r};return Object.defineProperty(t,"shape",{value:n}),e.raw=n,n};e.raw=r,Object.defineProperty(t,"shape",{get:e})}let i=Wt(()=>Ia(t));T(e,`propValues`,e=>{let t=e.def.shape,n={};for(let e in t){let r=t[e]._zod;if(r.values){Object.prototype.hasOwnProperty.call(n,e)||Xt(n,e,/* @__PURE__ */ new Set);for(let t of r.values)n[e].add(t);r.optin!==void 0&&n[e].add(void 0)}}return n});let a=cn,o=t.catchall,s,c=ir.memoizer;c?.attach(e),e._zod.parse=(t,n)=>{s??=i.value;let r=t.value;if(!a(r))return t.issues.push({expected:`object`,code:`invalid_type`,input:r,inst:e}),t;t.value=c?c.alloc(e,t,{},n):{};let l=[],u=s.shape,d=n?.abortEarly,f=t.issues.length;for(let e of s.allKeys){if(d&&t.issues.length!==f){if(On(t,f))break;f=t.issues.length}if(e===`__proto__`)continue;let i=u[e],a=i._zod.optin,o=i._zod.optout,s=i._zod.run({value:r[e],issues:[]},n);s instanceof Promise?l.push(s.then(n=>Pa(n,t,e,r,a,o))):Pa(s,t,e,r,a,o)}return o?La(l,r,t,n,i.value,e,d===!0):l.length?Promise.all(l).then(()=>t):t}}),za=/*@__PURE__*/ E(`$ZodObjectJIT`,(e,t)=>{Ra.init(e,t);let n=e._zod.parse,r=Wt(()=>Ia(t)),i=ir.memoizer,a=t=>{let n=r.value,a=n.symbolKeys,o=new Mi([`payload`,`ctx`],{shape:t,inst:e,memo:i,syms:a}),s=e=>`shape[${e}]._zod.run({ value: input[${e}], issues: [] }, ctx)`,c=(e,t)=>`
13
+ `)}\n};`)(...Object.values(this.closed))}};let Fi={major:4,minor:6,patch:7},Ii=/*@__PURE__*/ E(`$ZodType`,(e,t)=>{var n;e??={},e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Fi;let r=e._zod.def.checks,i=e._zod.traits.has(`$ZodCheck`)?[e,...r??[]]:r?.length?[...r]:[];for(let t of i)for(let n of t._zod.onattach)n(e);if(i.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let t=(t,n,r)=>{if(t.memo)return t;let i=kn(t),a;for(let o of n){if(o._zod.def.when){if(An(t)||!o._zod.def.when(t))continue}else if(i)continue;let n=t.issues.length,s=o._zod.check(t);if(s instanceof Promise&&r?.async===!1)throw new rr;if(a||s instanceof Promise)a=(a??Promise.resolve()).then(async()=>{await s,t.issues.length!==n&&(Pn(t.issues,n,e),i||=kn(t,n))});else{if(t.issues.length===n)continue;Pn(t.issues,n,e),i||=kn(t,n)}}return a?a.then(()=>t):t},n=(n,r,a)=>{if(kn(n))return n.aborted=!0,n;let o=t(r,i,a);if(o instanceof Promise){if(a.async===!1)throw new rr;return o.then(t=>e._zod.parse(t,a))}return e._zod.parse(o,a)};e._zod.run=(r,a)=>{if(a.skipChecks)return e._zod.parse(r,a);if(a.direction===`backward`){let t=e._zod.parse({value:r.value,issues:[]},{...a,skipChecks:!0});return t instanceof Promise?t.then(e=>n(e,r,a)):n(t,r,a)}let o=e._zod.parse(r,a);if(o instanceof Promise){if(a.async===!1)throw new rr;return o.then(e=>t(e,i,a))}return t(o,i,a)}}},{get"~standard"(){return Un(this,`~standard`,zi(this))},set"~standard"(e){Hn(this,`~standard`,e)}}),Li=(e,t)=>e.issues.length?{issues:e.issues.map(e=>Fn(e,t,or()))}:{value:e.value};async function Ri(e,t){let n={async:!0};return Li(await e._zod.run({value:t,issues:[]},n),n)}function zi(e){return{validate:t=>{let n={async:!1};try{let r=e._zod.run({value:t,issues:[]},n);if(!(r instanceof Promise))return Li(r,n)}catch{}return Ri(e,t)},vendor:`zod`,version:1}}let Bi=/*@__PURE__*/ E(`$ZodString`,(e,t)=>{Ii.init(e,t),e._zod.pattern=t.pattern??ci,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}}),Vi=/*@__PURE__*/ E(`$ZodStringFormat`,(e,t)=>{Ei.init(e,t),Bi.init(e,t)}),Hi=/*@__PURE__*/ E(`$ZodGUID`,(e,t)=>{t.pattern??=Wr,Vi.init(e,t)}),Ui=/*@__PURE__*/ E(`$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??=Gr(e)}else t.pattern??=Gr();Vi.init(e,t)}),Wi=/*@__PURE__*/ E(`$ZodEmail`,(e,t)=>{t.pattern??=Kr,Vi.init(e,t)});function Gi(e){try{return typeof URL<`u`&&typeof URL.canParse==`function`?URL.canParse(e):(new URL(e),!0)}catch{return!1}}function Ki(e,t){return!(`normalize`in t)&&!(`hostname`in t)&&!(`protocol`in t)?Gi(e)||2:qi(e,t)}function qi(e,t){if(!t.normalize&&t.protocol?.source===ei.source&&!/^https?:\/\//i.test(e))return 1;try{if(typeof URL<`u`){let t=URL;if(typeof t.parse==`function`)return t.parse(e)??2}return new URL(e)}catch{return 2}}let Ji=/[\t\n\r]/g;function Yi(e){return e.replace(Ji,``)}function Xi(e,t){return t.lastIndex=0,t.test(e.hostname)}function Zi(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(`:`)?e.protocol.slice(0,-1):e.protocol)}let Qi=/*@__PURE__*/ E(`$ZodURL`,(e,t)=>{Vi.init(e,t),e._zod.check=n=>{try{let r=n.value.trim(),i=Ki(r,t);if(i===1){n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid URL format`,input:n.value,inst:e,continue:!t.abort});return}if(i===2){n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort});return}if(i===!0){n.value=Yi(r);return}t.hostname&&!Xi(i,t.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&&!Zi(i,t.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:Yi(r);return}catch{n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort})}}}),$i=/*@__PURE__*/ E(`$ZodEmoji`,(e,t)=>{t.pattern??=qr(),Vi.init(e,t)}),ea=/*@__PURE__*/ E(`$ZodNanoID`,(e,t)=>{if(t.length!==void 0&&(!Number.isInteger(t.length)||t.length<1))throw Error(`Invalid nanoid length: ${t.length}`);t.pattern??=t.length===void 0?Vr:Hr(t.length),Vi.init(e,t)}),ta=/*@__PURE__*/ E(`$ZodCUID`,(e,t)=>{t.pattern??=Ir,Vi.init(e,t)}),na=/*@__PURE__*/ E(`$ZodCUID2`,(e,t)=>{t.pattern??=Lr,Vi.init(e,t)}),ra=/*@__PURE__*/ E(`$ZodULID`,(e,t)=>{t.pattern??=Rr,Vi.init(e,t)}),ia=/*@__PURE__*/ E(`$ZodXID`,(e,t)=>{t.pattern??=zr,Vi.init(e,t)}),aa=/*@__PURE__*/ E(`$ZodKSUID`,(e,t)=>{t.pattern??=Br,Vi.init(e,t)}),oa=/*@__PURE__*/ E(`$ZodISODateTime`,(e,t)=>{t.pattern??=si(t),Vi.init(e,t)}),sa=/*@__PURE__*/ E(`$ZodISODate`,(e,t)=>{t.pattern??=ii,Vi.init(e,t)}),ca=/*@__PURE__*/ E(`$ZodISOTime`,(e,t)=>{t.pattern??=oi(t),Vi.init(e,t)}),la=/*@__PURE__*/ E(`$ZodISODuration`,(e,t)=>{t.pattern??=Ur,Vi.init(e,t)}),ua=/*@__PURE__*/ E(`$ZodIPv4`,(e,t)=>{t.pattern??=Jr,Vi.init(e,t)}),da=/^[0-9a-fA-F:.]+$/;function fa(e){return da.test(e)?Gi(`http://[${e}]`):!1}let pa=/*@__PURE__*/ E(`$ZodIPv6`,(e,t)=>{t.pattern??=Yr,Vi.init(e,t),e._zod.check=n=>{fa(n.value)||n.issues.push({code:`invalid_format`,format:`ipv6`,input:n.value,inst:e,continue:!t.abort})}}),ma=/*@__PURE__*/ E(`$ZodCIDRv4`,(e,t)=>{t.pattern??=Xr,Vi.init(e,t)});function ha(e){let t=e.split(`/`);if(t.length!==2)return!1;let[n,r]=t;if(!r)return!1;let i=Number(r);return`${i}`!==r||i<0||i>128?!1:fa(n)}let ga=/*@__PURE__*/ E(`$ZodCIDRv6`,(e,t)=>{t.pattern??=Zr,Vi.init(e,t),e._zod.check=n=>{ha(n.value)||n.issues.push({code:`invalid_format`,format:`cidrv6`,input:n.value,inst:e,continue:!t.abort})}});function _a(e){if(e===``)return!0;if(/\s/.test(e)||e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}let va=/^[0-9a-zA-Z+/]*={0,2}$/,ya=/*@__PURE__*/ E(`$ZodBase64`,(e,t)=>{t.pattern??=va,Vi.init(e,t),e._zod.check=n=>{_a(n.value)||n.issues.push({code:`invalid_format`,format:`base64`,input:n.value,inst:e,continue:!t.abort})}}),ba=/^[A-Za-z0-9_-]*$/;function xa(e){if(!ba.test(e))return!1;let t=e.replace(/[-_]/g,e=>e===`-`?`+`:`/`);return _a(t.padEnd(Math.ceil(t.length/4)*4,`=`))}let Sa=/*@__PURE__*/ E(`$ZodBase64URL`,(e,t)=>{t.pattern??=ba,Vi.init(e,t),e._zod.check=n=>{xa(n.value)||n.issues.push({code:`invalid_format`,format:`base64url`,input:n.value,inst:e,continue:!t.abort})}}),Ca=/*@__PURE__*/ E(`$ZodE164`,(e,t)=>{t.pattern??=ti,Vi.init(e,t)});function wa(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 Ta=/*@__PURE__*/ E(`$ZodJWT`,(e,t)=>{Vi.init(e,t),e._zod.check=n=>{wa(n.value,t.alg)||n.issues.push({code:`invalid_format`,format:`jwt`,input:n.value,inst:e,continue:!t.abort})}}),Ea=/*@__PURE__*/ E(`$ZodNumber`,(e,t)=>{Ii.init(e,t),e._zod.pattern=di,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:String(i):void 0;return n.issues.push({expected:`number`,code:`invalid_type`,input:i,inst:e,...a?{received:a}:{}}),n}}),Da=/*@__PURE__*/ E(`$ZodNumberFormat`,(e,t)=>{Si.init(e,t),Ea.init(e,t)}),Oa=/*@__PURE__*/ E(`$ZodBoolean`,(e,t)=>{Ii.init(e,t),e._zod.pattern=fi,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}}),ka=/*@__PURE__*/ E(`$ZodNull`,(e,t)=>{Ii.init(e,t),e._zod.pattern=pi,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}}),Aa=/*@__PURE__*/ E(`$ZodUnknown`,(e,t)=>{Ii.init(e,t),e._zod.parse=e=>e}),ja=/*@__PURE__*/ E(`$ZodNever`,(e,t)=>{Ii.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:`never`,code:`invalid_type`,input:t.value,inst:e}),t)});function Ma(e,t){let n=Nn(e._zod.def.checks);if(!n.length)return;let r=Math.min(...n.map(e=>e[0])),i=e._zod.parse;e._zod.parse=(n,a)=>{let o=t(n.value);if(o>r&&!a?.skipChecks&&a?.direction!==`backward`){for(let[t,r]of Nn(e._zod.def.checks))if(o>t&&r._zod.def.when(n)){let t=n.issues.length;return r._zod.check(n),n.issues[t].continue=!1,Pn(n.issues,t,e),n}}return i(n,a)}}let Na=e=>Array.isArray(e)?e.length:-1;function Pa(e,t,n){e.issues.length&&t.issues.push(...jn(n,e.issues)),t.value[n]=e.value}let Fa=/*@__PURE__*/ E(`$ZodArray`,(e,t)=>{Ii.init(e,t);let n=ar.memoizer;n?.attach(e),e._zod.parse=(r,i)=>{let a=r.value;if(!Array.isArray(a))return r.issues.push({expected:`array`,code:`invalid_type`,input:a,inst:e}),r;r.value=n?n.alloc(e,r,Array(a.length),i):Array(a.length);let o=[],s=i?.abortEarly;for(let e=0;e<a.length;e++){let n=a[e],c=t.element._zod.run({value:n,issues:[]},i);if(c instanceof Promise)o.push(c.then(t=>Pa(t,r,e)));else if(Pa(c,r,e),s&&c.issues.length!==0&&kn(c))break}return o.length?Promise.all(o).then(()=>r):r},Ma(e,Na)});function Ia(e,t,n,r,i,a){let o=n in r,s=a===`optional`;if(o||!s||i!==`optional`){if(e.issues.length){if(i!==void 0&&s&&!o)return;t.issues.push(...jn(n,e.issues))}!o&&i===void 0?e.issues.length||t.issues.push({code:`invalid_type`,expected:`nonoptional`,input:void 0,path:[n]}):e.value===void 0?(o||i===`defaulted`&&!s)&&(t.value[n]=void 0):t.value[n]=e.value}}let La=[];function Ra(e){let t=Object.keys(e.shape),n=Object.getOwnPropertySymbols(e.shape),r=n.length?n:La,i=r.length?[...t,...r]:t;for(let t of i)if(!e.shape?.[t]?._zod?.traits?.has(`$ZodType`))throw Error(`Invalid element at key "${String(t)}": expected a Zod schema`);let a=_n(e.shape);return{...e,allKeys:i,symbolKeys:r,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(a)}}function za(e,t,n,r,i,a,o){let s=[],c=i.keySet,l=i.catchall._zod,u=l.def.type,d=l.optin,f=l.optout,p=0;for(let i in t){if(o&&n.issues.length!==p){if(kn(n,p))break;p=n.issues.length}if(c.has(i))continue;if(i===`__proto__`){u===`never`&&s.push(i);continue}if(u===`never`){s.push(i);continue}let a=l.run({value:t[i],issues:[]},r);a instanceof Promise?e.push(a.then(e=>Ia(e,n,i,t,d,f))):Ia(a,n,i,t,d,f)}return s.length&&n.issues.push({code:`unrecognized_keys`,keys:s,input:t,inst:a,continue:!0}),e.length?Promise.all(e).then(()=>n):n}let Ba=/*@__PURE__*/ E(`$ZodObject`,(e,t)=>{Ii.init(e,t);let n=Object.getOwnPropertyDescriptor(t,`shape`),r=n?.get?n.get.raw:t.shape??{};if(r){let e=()=>{let n={...r};return Object.defineProperty(t,"shape",{value:n}),e.raw=n,n};e.raw=r,Object.defineProperty(t,"shape",{get:e})}let i=Wt(()=>Ra(t));T(e,`propValues`,e=>{let t=e.def.shape,n={};for(let e in t){let r=t[e]._zod;if(r.values){Object.prototype.hasOwnProperty.call(n,e)||Xt(n,e,/* @__PURE__ */ new Set);for(let t of r.values)n[e].add(t);r.optin!==void 0&&n[e].add(void 0)}}return n});let a=cn,o=t.catchall,s,c=ar.memoizer;c?.attach(e),e._zod.parse=(t,n)=>{s??=i.value;let r=t.value;if(!a(r))return t.issues.push({expected:`object`,code:`invalid_type`,input:r,inst:e}),t;t.value=c?c.alloc(e,t,{},n):{};let l=[],u=s.shape,d=n?.abortEarly,f=t.issues.length;for(let e of s.allKeys){if(d&&t.issues.length!==f){if(kn(t,f))break;f=t.issues.length}if(e===`__proto__`)continue;let i=u[e],a=i._zod.optin,o=i._zod.optout,s=i._zod.run({value:r[e],issues:[]},n);s instanceof Promise?l.push(s.then(n=>Ia(n,t,e,r,a,o))):Ia(s,t,e,r,a,o)}return o?za(l,r,t,n,i.value,e,d===!0):l.length?Promise.all(l).then(()=>t):t}}),Va=/*@__PURE__*/ E(`$ZodObjectJIT`,(e,t)=>{Ba.init(e,t);let n=e._zod.parse,r=Wt(()=>Ra(t)),i=ar.memoizer,a=t=>{let n=r.value,a=n.symbolKeys,o=new Pi([`payload`,`ctx`],{shape:t,inst:e,memo:i,syms:a}),s=e=>`shape[${e}]._zod.run({ value: input[${e}], issues: [] }, ctx)`,c=(e,t)=>`
14
14
  let ${e}_ab = false;
15
15
  for (let i = 0; i < ${e}.issues.length; i++) {
16
16
  const iss = ${e}.issues[i];
@@ -60,120 +60,120 @@ default:Me(e.groups)}return{upserts:t,removes:n}}},We=class{store;key;listeners=
60
60
  newResult[${r}] = ${n}.value;
61
61
  }
62
62
 
63
- `)}return o.write(`payload.value = newResult;`),o.write(`return payload;`),o.compile()},o,s=cn,c=!ir.jitless,l=c&&ln.value,u=t.catchall,d;e._zod.parse=(i,f)=>{d??=r.value;let p=i.value;return s(p)?c&&l&&f?.async===!1&&f.jitless!==!0?(o||=a(t.shape),i=o(i,f),u?La([],p,i,f,d,e,f?.abortEarly===!0):i):n(i,f):(i.issues.push({expected:`object`,code:`invalid_type`,input:p,inst:e}),i)}});function Ba(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=>!On(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=>Pn(e,r,ar())))}),t)}let Va=/*@__PURE__*/ E(`$ZodUnion`,(e,t)=>{Pi.init(e,t),T(e,`optin`,e=>e.def.options.some(e=>e._zod.optin===`defaulted`)?`defaulted`:e.def.options.some(e=>e._zod.optin!==void 0)?`optional`:void 0),T(e,`optout`,e=>e.def.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),T(e,`values`,e=>{if(e.def.options.every(e=>e._zod.values))return new Set(e.def.options.flatMap(e=>Array.from(e._zod.values)))}),T(e,`pattern`,e=>{if(e.def.options.every(e=>e._zod.pattern)){let t=e.def.options.map(e=>e._zod.pattern);return RegExp(`^(${t.map(e=>Kt(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=>Ba(t,r,e,i)):Ba(o,r,e,i)}});function Ha(e){let t=/* @__PURE__ */ new Map;for(let n of e.options){let r=n._zod.propValues?.[e.discriminator];if(!r||r.size===0)throw Error(`Invalid discriminated union option at index "${e.options.indexOf(n)}"`);for(let e of r)if(t.has(e)){if(e!==void 0)throw Error(`Duplicate discriminator value "${String(e)}"`);t.set(e,null)}else t.set(e,n)}return t}let Ua=/*@__PURE__*/ E(`$ZodDiscriminatedUnion`,(e,t)=>{t.inclusive=!1,Va.init(e,t);let n=e._zod.parse;T(e,`propValues`,e=>{let t={},n=0;for(let r of e.def.options){let i=r._zod.propValues;if(!i||Object.keys(i).length===0)throw Error(`Invalid discriminated union option at index "${e.def.options.indexOf(r)}"`);i[e.def.discriminator]?.has(void 0)&&n++;for(let[e,n]of Object.entries(i)){Object.prototype.hasOwnProperty.call(t,e)||Xt(t,e,/* @__PURE__ */ new Set);for(let r of n)t[e].add(r)}}return!e.def.unionFallback&&n>1&&t[e.def.discriminator]?.delete(void 0),t}),t.options.forEach((e,n)=>{let r=Zt(e._zod.def);if(r&&!Object.prototype.hasOwnProperty.call(r,t.discriminator))throw Error(`Invalid discriminated union option at index "${n}"`)});let r=Wt(()=>Ha(t));e._zod.parse=(i,a)=>{let o=i.value;if(!cn(o))return i.issues.push({code:`invalid_type`,expected:`object`,input:o,inst:e}),i;let s=o?.[t.discriminator],c=r.value.get(s);return c&&(s!==void 0||a.direction!==`backward`)?c._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()).filter(e=>r.value.get(e)!==null),input:o,path:[t.discriminator],inst:e}),i)}}),Wa=/*@__PURE__*/ E(`$ZodIntersection`,(e,t)=>{Pi.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])=>Ka(e,t,n)):Ka(e,i,a)}});function Ga(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(un(e)&&un(t)){let n=Object.keys(t),r=Object.keys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};Object.prototype.hasOwnProperty.call(i,`__proto__`)&&delete i.__proto__;for(let n of r){if(n===`__proto__`)continue;let r=Ga(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=Ga(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 Ka(e,t,n){let r=/* @__PURE__ */ new Map,i,a=/* @__PURE__ */ new Map,o=(e,t)=>{let n;if(e.code===`unrecognized_keys`&&!e.path?.length)i??=e,n=e.keys;else if(e.code===`invalid_key`&&e.origin===`record`&&e.path?.length===1){let t=String(e.path[0]);a.has(t)||a.set(t,e),n=[t]}else return!1;for(let e of n)r.has(e)||r.set(e,{}),r.get(e)[t]=!0;return!0};for(let n of t.issues)o(n,`l`)||e.issues.push(n);for(let t of n.issues)o(t,`r`)||e.issues.push(t);let s=[...r].filter(([,e])=>e.l&&e.r).map(([e])=>e);if(s.length){let t=i?s.filter(e=>i.keys.includes(e)):[];t.length&&e.issues.push({...i,keys:t});for(let n of s)!t.includes(n)&&a.has(n)&&e.issues.push(a.get(n))}let c=Ga(t.value,n.value);if(!c.valid){if(On(e))return e;throw Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`)}return e.value=c.data,e}let qa=/*@__PURE__*/ E(`$ZodTuple`,(e,t)=>{Pi.init(e,t);let n=t.items,r=ir.memoizer;r?.attach(e),e._zod.parse=(i,a)=>{let o=i.value;if(!Array.isArray(o))return i.issues.push({input:o,inst:e,expected:`tuple`,code:`invalid_type`}),i;i.value=r?r.alloc(e,i,[],a):[];let s=[],c=Ja(n,`optin`),l=Ja(n,`optout`);if(!t.rest){if(o.length<c)return i.issues.push({code:`too_small`,minimum:c,inclusive:!0,input:o,inst:e,origin:`array`}),i;o.length>n.length&&i.issues.push({code:`too_big`,maximum:n.length,inclusive:!0,input:o,inst:e,origin:`array`})}let u=Array(n.length),d=t.rest?a?.abortEarly:void 0,f=!1;for(let e=0;e<n.length;e++){let t=n[e]._zod.run({value:o[e],issues:[]},a);t instanceof Promise?s.push(t.then(t=>{u[e]=t})):(u[e]=t,d&&!f&&t.issues.length&&(f=On(t)))}if(t.rest&&!f){let e=n.length-1,r=o.slice(n.length),c=i.issues.length;for(let n of r){if(d&&i.issues.length!==c){if(On(i,c))break;c=i.issues.length}e++;let r=t.rest._zod.run({value:n,issues:[]},a);r instanceof Promise?s.push(r.then(t=>Ya(t,i,e))):Ya(r,i,e)}}return s.length?Promise.all(s).then(()=>Xa(u,i,n,o,l)):Xa(u,i,n,o,l)}});function Ja(e,t){for(let n=e.length-1;n>=0;n--)if(!(t===`optin`?e[n]._zod.optin!==void 0:e[n]._zod.optout===`optional`))return n+1;return 0}function Ya(e,t,n){e.issues.length&&t.issues.push(...An(n,e.issues)),t.value[n]=e.value}function Xa(e,t,n,r,i){for(let a=0;a<n.length;a++){let o=e[a],s=a<r.length;if(!s&&a>=i&&n[a]._zod.optin===`optional`){t.value.length=a;break}if(o.issues.length){if(!s&&a>=i){t.value.length=a;break}t.issues.push(...An(a,o.issues))}t.value[a]=o.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 Za=/*@__PURE__*/ E(`$ZodRecord`,(e,t)=>{Pi.init(e,t);let n=ir.memoizer;n?.attach(e),e._zod.parse=(r,i)=>{let a=r.value;if(!un(a))return r.issues.push({expected:`record`,code:`invalid_type`,input:a,inst:e}),r;let o=[],s=t.keyType._zod.values;if(s&&!t.partial){r.value=n?n.alloc(e,r,{},i):{};let c=/* @__PURE__ */ new Set;for(let n of s)if(typeof n==`string`||typeof n==`number`||typeof n==`symbol`){if(c.add(typeof n==`number`?n.toString():n),n===`__proto__`)continue;let s=t.keyType._zod.run({value:n,issues:[]},i);if(s instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(s.issues.length){r.issues.push({code:`invalid_key`,origin:`record`,issues:s.issues.map(e=>Pn(e,i,ar())),input:n,path:[n],inst:e});continue}let l=s.value;if(l===`__proto__`)continue;let u=t.valueType._zod.run({value:a[n],issues:[]},i);u instanceof Promise?o.push(u.then(e=>{e.issues.length&&r.issues.push(...An(n,e.issues)),r.value[l]=e.value})):(u.issues.length&&r.issues.push(...An(n,u.issues)),r.value[l]=u.value)}let l;for(let e in a)if(!c.has(e)){if(t.mode===`loose`){if(e===`__proto__`)continue;r.value[e]=a[e]}else l??=[],l.push(e)}l&&l.length>0&&r.issues.push({code:`unrecognized_keys`,input:a,inst:e,keys:l,continue:!0})}else{r.value=n?n.alloc(e,r,{},i):{};let c;for(let n of Reflect.ownKeys(a)){if(n===`__proto__`||!Object.prototype.propertyIsEnumerable.call(a,n))continue;let l=t.keyType._zod.run({value:n,issues:[]},i);if(l instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(typeof n==`string`&&li.test(n)&&l.issues.length){let e=t.keyType._zod.run({value:Number(n),issues:[]},i);if(e instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);e.issues.length===0&&(l=e)}if(l.issues.length){t.mode===`loose`?r.value[n]=a[n]:s?(c??=[],c.push(n)):r.issues.push({code:`invalid_key`,origin:`record`,issues:l.issues.map(e=>Pn(e,i,ar())),input:n,path:[n],inst:e});continue}let u=l.value;if(u===`__proto__`)continue;let d=t.valueType._zod.run({value:a[n],issues:[]},i);d instanceof Promise?o.push(d.then(e=>{e.issues.length&&r.issues.push(...An(n,e.issues)),r.value[u]=e.value})):(d.issues.length&&r.issues.push(...An(n,d.issues)),r.value[u]=d.value)}c&&c.length>0&&r.issues.push({code:`unrecognized_keys`,input:a,inst:e,keys:c,continue:!0})}return o.length?Promise.all(o).then(()=>r):r}}),Qa=/*@__PURE__*/ E(`$ZodEnum`,(e,t)=>{Pi.init(e,t);let n=Bt(t.entries),r=new Set(n);e._zod.values=r,T(e,`pattern`,e=>{let t=Bt(e.def.entries).filter(e=>fn.has(typeof e));return RegExp(t.length?`^(${t.map(e=>pn(e.toString())).join(`|`)})$`:`^[^\\s\\S]$`)}),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}}),$a=/*@__PURE__*/ E(`$ZodLiteral`,(e,t)=>{Pi.init(e,t);let n=new Set(t.values);e._zod.values=n,T(e,`pattern`,e=>{let t=e.def.values;return RegExp(t.length?`^(${t.map(e=>typeof e==`string`?pn(e):e?pn(e.toString()):String(e)).join(`|`)})$`:`^[^\\s\\S]$`)}),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}}),eo=/*@__PURE__*/ E(`$ZodTransform`,(e,t)=>{Pi.init(e,t),e._zod.optin=`optional`,ir.memoizer?.guard(e),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new rr(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));if(i instanceof Promise)throw new nr;return n.value=i,n}});function to(e,t){return e.value=t.issues.length?void 0:t.value,e}let no=/*@__PURE__*/ E(`$ZodOptional`,(e,t)=>{Pi.init(e,t),T(e,`optin`,e=>e.def.innerType._zod.optin===`defaulted`?`defaulted`:`optional`),e._zod.optout=`optional`,T(e,`values`,e=>{let t=e.def.innerType._zod.values;return t?/* @__PURE__ */ new Set([...t,void 0]):void 0}),T(e,`pattern`,e=>{let t=e.def.innerType._zod.pattern;return t?RegExp(`^(${Kt(t.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if(e.value===void 0){if(t.innerType._zod.optin!==`defaulted`)return e;let r=t.innerType._zod.run({value:e.value,issues:[]},n);return r instanceof Promise?r.then(t=>to(e,t)):to(e,r)}return t.innerType._zod.run(e,n)}}),ro=/*@__PURE__*/ E(`$ZodExactOptional`,(e,t)=>{no.init(e,t),T(e,`values`,e=>e.def.innerType._zod.values),T(e,`pattern`,e=>e.def.innerType._zod.pattern),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),io=/*@__PURE__*/ E(`$ZodNullable`,(e,t)=>{Pi.init(e,t),T(e,`optin`,e=>e.def.innerType._zod.optin),T(e,`optout`,e=>e.def.innerType._zod.optout),T(e,`pattern`,e=>{let t=e.def.innerType._zod.pattern;return t?RegExp(`^(${Kt(t.source)}|null)$`):void 0}),T(e,`values`,e=>e.def.innerType._zod.values?/* @__PURE__ */ new Set([...e.def.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>e.value===null?e:t.innerType._zod.run(e,n)}),ao=/*@__PURE__*/ E(`$ZodDefault`,(e,t)=>{Pi.init(e,t),e._zod.optin=`defaulted`,T(e,`values`,e=>e.def.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=>oo(e,t)):oo(r,t)}});function oo(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}let so=/*@__PURE__*/ E(`$ZodPrefault`,(e,t)=>{Pi.init(e,t),e._zod.optin=`defaulted`,T(e,`values`,e=>e.def.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))}),co=/*@__PURE__*/ E(`$ZodNonOptional`,(e,t)=>{Pi.init(e,t),T(e,`values`,e=>{let t=e.def.innerType._zod.values;return t?new Set([...t].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=>lo(t,e)):lo(i,e)}});function lo(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:`invalid_type`,expected:`nonoptional`,input:e.value,inst:t}),e}function uo(e,t,n,r){return t.issues.length?(e.value=n.catchValue({...t,value:e.value,error:{issues:t.issues.map(e=>Pn(e,r,ar()))},input:e.value}),e):(e.value=t.value,t.memo&&(e.memo=!0),e)}let fo=/*@__PURE__*/ E(`$ZodCatch`,(e,t)=>{Pi.init(e,t),T(e,`optin`,e=>e.def.innerType._zod.optin===`defaulted`?`defaulted`:`optional`),T(e,`optout`,e=>e.def.innerType._zod.optout),T(e,`values`,e=>e.def.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({value:e.value,issues:[]},n);return r instanceof Promise?r.then(r=>uo(e,r,t,n)):uo(e,r,t,n)}}),po=/*@__PURE__*/ E(`$ZodPipe`,(e,t)=>{Pi.init(e,t),T(e,`values`,e=>e.def.in._zod.values),T(e,`optin`,e=>e.def.in._zod.optin),T(e,`optout`,e=>e.def.out._zod.optout),T(e,`propValues`,e=>e.def.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=>mo(e,t.in,n)):mo(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>mo(e,t.out,n)):mo(r,t.out,n)}});function mo(e,t,n){return e.issues.some(e=>e.code!==`unrecognized_keys`)?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}let ho=/*@__PURE__*/ E(`$ZodReadonly`,(e,t)=>{Pi.init(e,t),T(e,`propValues`,e=>e.def.innerType._zod.propValues),T(e,`values`,e=>e.def.innerType._zod.values),T(e,`optin`,e=>e.def.innerType?._zod?.optin),T(e,`optout`,e=>e.def.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(go):go(r)}});function go(e){return e.memo||(e.value=Object.freeze(e.value)),e}let _o=/*@__PURE__*/ E(`$ZodLazy`,(e,t)=>{Pi.init(e,t),Yt(e._zod,`innerType`,()=>{let e=t;return e._cachedInner||=t.getter(),e._cachedInner}),T(e,`pattern`,e=>e.innerType?._zod?.pattern),T(e,`propValues`,e=>e.innerType?._zod?.propValues),T(e,`optin`,e=>e.innerType?._zod?.optin??void 0),T(e,`optout`,e=>e.innerType?._zod?.optout??void 0),e._zod.parse=(t,n)=>e._zod.innerType._zod.run(t,n)}),vo=/*@__PURE__*/ E(`$ZodCustom`,(e,t)=>{mi.init(e,t),Pi.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=>yo(t,n,r,e));yo(i,n,r,e)}});function yo(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(zn(e))}}var bo=class extends Error{constructor(){super(`Cannot parse a reference cycle that closes through a transform`),this.name=`ZodCyclicError`}};let xo=`~memo`,So=[];function Co(e){return typeof e==`object`&&!!e}function wo(e){return e.map(e=>e.path?{...e,path:e.path.slice()}:{...e})}let To=/*@__PURE__*/ new WeakMap;function Eo(e,t,n){let r=To.get(e);if(r!==void 0)return r?2:0;if(t.has(e))return 2;t.add(e);let i=0,a=e=>{if(i!==2&&e?._zod){let r=Eo(e,t,n);r>i&&(i=r)}},o=(e,r)=>{let i=0;for(let a of Reflect.ownKeys(e)){let o=Object.getOwnPropertyDescriptor(e,a);if(r&&!o.enumerable)continue;let s=o.get?1:o.value?._zod?Eo(o.value,t,n):0;s>i&&(i=s)}return i},s=e=>{e>i&&(i=e)},c=e._zod.def;switch(c.type){case`object`:{let e=Zt(c);s(e?o(e,!0):1),a(c.catchall);break}case`array`:a(c.element);break;case`tuple`:for(let e of c.items)a(e);a(c.rest);break;case`record`:case`map`:a(c.keyType),a(c.valueType);break;case`set`:a(c.valueType);break;case`union`:for(let e of c.options)a(e);break;case`intersection`:a(c.left),a(c.right);break;case`optional`:case`nullable`:case`default`:case`prefault`:case`catch`:case`readonly`:case`nonoptional`:case`promise`:case`success`:a(c.innerType);break;case`pipe`:a(c.in),a(c.out);break;case`function`:a(c.input),a(c.output);break;case`lazy`:{let r=c._cachedInner??(n?e._zod.innerType:void 0);s(r?Eo(r,t,!1):1);break}case`template_literal`:case`string`:case`number`:case`int`:case`boolean`:case`bigint`:case`symbol`:case`undefined`:case`null`:case`void`:case`never`:case`any`:case`unknown`:case`date`:case`nan`:case`enum`:case`literal`:case`file`:case`transform`:case`custom`:break;default:for(let e in c){let t=Object.getOwnPropertyDescriptor(c,e);if(!t||t.get)continue;let n=t.value;if(n&&typeof n==`object`){if(n._zod)a(n);else if(Array.isArray(n))for(let e of n)a(e)}}}return t.delete(e),Do(e,i)}function Do(e,t){return t!==1&&To.set(e,t===2),t}function Oo(e,t){let n=e.buckets.get(t);return n||(n=/* @__PURE__ */ new WeakMap,e.buckets.set(t,n)),n}let ko,Ao=[],jo={alloc(e,t,n){let r=ko;if(!r)return n;ko=void 0;let i={value:n,issues:null};return r.set(t.value,i),Ao.push(i),n},guard(e){var t;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let t=e._zod.parse,n=(e,n)=>{if(n.direction!==`backward`&&No(n,e.value))throw new bo;return t(e,n)};e._zod.parse=n,e._zod.run===t&&(e._zod.run=n)})},attach(e){var t;let n,r=!1,i,a;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let t=e._zod.parse,o=(s,c)=>{if(n===void 0){let i=Eo(e,/* @__PURE__ */ new Set,!1);if(i===0)return e._zod.parse=t,e._zod.run===o&&(e._zod.run=t),t(s,c);i===2||r?n=!0:r=!0}let l=s.value;if(!Co(l))return t(s,c);let u=c[xo];u||(u={buckets:/* @__PURE__ */ new WeakMap,backEdges:void 0},c[xo]=u);let d;i===c?d=a:(d=Oo(u,e),i=c,a=d);let f=d.get(l);if(f)return s.value=f.value,f.issues?f.issues.length&&s.issues.push(...wo(f.issues)):(s.memo=!0,u.backEdges??(u.backEdges=/* @__PURE__ */ new WeakSet),u.backEdges.add(f.value)),s;ko=d;let p=Ao.length,m=t(s,c);ko=void 0;let h=Ao.length>p?Ao.pop():void 0;return m instanceof Promise?m.then(e=>(h&&(h.issues=e.issues.length?wo(e.issues):So),e)):(h&&(h.issues=m.issues.length?wo(m.issues):So),m)};e._zod.parse=o,e._zod.run===t&&(e._zod.run=o)})}};function Mo(){return jo}function No(e,t){let n=e[xo]?.backEdges;return n!==void 0&&Co(t)&&n.has(t)}let Po=()=>{let e={string:{unit:`characters`,verb:`to have`},file:{unit:`bytes`,verb:`to have`},array:{unit:`items`,verb:`to have`},set:{unit:`items`,verb:`to have`},map:{unit:`entries`,verb:`to have`}};function t(t){return e[t]??null}let n={regex:`input`,email:`email address`,url:`URL`,emoji:`emoji`,uuid:`UUID`,uuidv4:`UUIDv4`,uuidv6:`UUIDv6`,nanoid:`nanoid`,guid:`GUID`,cuid:`cuid`,cuid2:`cuid2`,ulid:`ULID`,xid:`XID`,ksuid:`KSUID`,datetime:`ISO datetime`,date:`ISO date`,time:`ISO time`,duration:`ISO duration`,ipv4:`IPv4 address`,ipv6:`IPv6 address`,mac:`MAC address`,cidrv4:`IPv4 range`,cidrv6:`IPv6 range`,base64:`base64-encoded string`,base64url:`base64url-encoded string`,json_string:`JSON string`,e164:`E.164 number`,currency_code:`currency code`,credit_card:`credit card number`,iban:`IBAN`,jwt:`JWT`,template_literal:`input`},r={nan:`NaN`};function i(e,t){return e===`number`&&typeof t==`number`&&!Number.isFinite(t)?String(t):r[e]??e}return e=>{switch(e.code){case`invalid_type`:return`Invalid input: expected ${i(e.expected)}, received ${i(Rn(e.input),e.input)}`;case`invalid_value`:return e.values.length===1?`Invalid input: expected ${hn(e.values[0])}`:`Invalid option: expected one of ${Vt(e.values,`|`)}`;case`too_big`:{let n=e.exact?`exactly `:e.inclusive?`<=`:`<`,r=t(e.origin);return r?`Too big: expected ${e.origin??`value`} to have ${n}${e.maximum.toString()} ${r.unit??`elements`}`:`Too big: expected ${e.origin??`value`} to be ${n}${e.maximum.toString()}`}case`too_small`:{let n=e.exact?`exactly `:e.inclusive?`>=`:`>`,r=t(e.origin);return r?`Too small: expected ${e.origin} to have ${n}${e.minimum.toString()} ${r.unit}`:`Too small: expected ${e.origin} to be ${n}${e.minimum.toString()}`}case`invalid_format`:{let t=e;return t.format===`starts_with`?`Invalid string: must start with "${t.prefix}"`:t.format===`ends_with`?`Invalid string: must end with "${t.suffix}"`:t.format===`includes`?`Invalid string: must include "${t.includes}"`:t.format===`regex`?`Invalid string: must match pattern ${t.pattern}`:`Invalid ${n[t.format]??e.format}`}case`not_multiple_of`:return`Invalid number: must be a multiple of ${e.divisor}`;case`unrecognized_keys`:return`Unrecognized key${e.keys.length>1?`s`:``}: ${Vt(e.keys,`, `)}`;case`invalid_key`:return`Invalid key in ${e.origin}`;case`invalid_union`:return e.options&&Array.isArray(e.options)&&e.options.length>0?`Invalid discriminator value. Expected ${e.options.map(e=>`'${e}'`).join(` | `)}`:e.inclusive===!1?`Invalid input: more than one option matched`:`Invalid input`;case`invalid_element`:return`Invalid value in ${e.origin}`;default:return`Invalid input`}}};function Fo(){return{localeError:Po()}}var Io,Lo=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 Ro(){return new Lo}(Io=globalThis).__zod_globalRegistry??(Io.__zod_globalRegistry=Ro());let zo=globalThis.__zod_globalRegistry;function Bo(e){return e.checks&&=[...e.checks],e}// @__NO_SIDE_EFFECTS__
64
- function Vo(e,t){return new e(Bo({type:`string`,...w(t)}))}// @__NO_SIDE_EFFECTS__
65
- function Ho(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...w(t)})}// @__NO_SIDE_EFFECTS__
66
- function Uo(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...w(t)})}// @__NO_SIDE_EFFECTS__
67
- function Wo(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...w(t)})}// @__NO_SIDE_EFFECTS__
68
- function Go(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...w(t)})}// @__NO_SIDE_EFFECTS__
69
- function Ko(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...w(t)})}// @__NO_SIDE_EFFECTS__
70
- function qo(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...w(t)})}// @__NO_SIDE_EFFECTS__
71
- function Jo(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...w(t)})}// @__NO_SIDE_EFFECTS__
72
- function Yo(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...w(t)})}// @__NO_SIDE_EFFECTS__
73
- function Xo(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...w(t)})}// @__NO_SIDE_EFFECTS__
74
- function Zo(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...w(t)})}// @__NO_SIDE_EFFECTS__
75
- function Qo(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...w(t)})}// @__NO_SIDE_EFFECTS__
76
- function $o(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...w(t)})}// @__NO_SIDE_EFFECTS__
77
- function es(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...w(t)})}// @__NO_SIDE_EFFECTS__
78
- function ts(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...w(t)})}// @__NO_SIDE_EFFECTS__
79
- function ns(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...w(t)})}// @__NO_SIDE_EFFECTS__
80
- function rs(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...w(t)})}// @__NO_SIDE_EFFECTS__
81
- function is(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...w(t)})}// @__NO_SIDE_EFFECTS__
82
- function as(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...w(t)})}// @__NO_SIDE_EFFECTS__
83
- function os(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...w(t)})}// @__NO_SIDE_EFFECTS__
84
- function ss(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...w(t)})}// @__NO_SIDE_EFFECTS__
85
- function cs(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...w(t)})}// @__NO_SIDE_EFFECTS__
86
- function ls(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...w(t)})}// @__NO_SIDE_EFFECTS__
87
- function us(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...w(t)})}// @__NO_SIDE_EFFECTS__
88
- function ds(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...w(t)})}// @__NO_SIDE_EFFECTS__
89
- function fs(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...w(t)})}// @__NO_SIDE_EFFECTS__
90
- function ps(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...w(t)})}// @__NO_SIDE_EFFECTS__
91
- function ms(e,t){return new e(Bo({type:`number`,checks:[],...w(t)}))}// @__NO_SIDE_EFFECTS__
92
- function hs(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...w(t)})}// @__NO_SIDE_EFFECTS__
93
- function gs(e,t){return new e({type:`boolean`,...w(t)})}// @__NO_SIDE_EFFECTS__
94
- function _s(e,t){return new e({type:`null`,...w(t)})}// @__NO_SIDE_EFFECTS__
95
- function vs(e){return new e({type:`unknown`})}// @__NO_SIDE_EFFECTS__
96
- function ys(e,t){return new e({type:`never`,...w(t)})}// @__NO_SIDE_EFFECTS__
97
- function bs(e,t){return new _i({check:`less_than`,...w(t),value:e,inclusive:!1})}// @__NO_SIDE_EFFECTS__
98
- function xs(e,t){return new _i({check:`less_than`,...w(t),value:e,inclusive:!0})}// @__NO_SIDE_EFFECTS__
99
- function Ss(e,t){return new vi({check:`greater_than`,...w(t),value:e,inclusive:!1})}// @__NO_SIDE_EFFECTS__
100
- function Cs(e,t){return new vi({check:`greater_than`,...w(t),value:e,inclusive:!0})}// @__NO_SIDE_EFFECTS__
101
- function ws(e,t){return new yi({check:`multiple_of`,...w(t),value:e})}// @__NO_SIDE_EFFECTS__
102
- function Ts(e,t){return new xi({check:`max_length`,...w(t),maximum:e})}// @__NO_SIDE_EFFECTS__
103
- function Es(e,t){return new Si({check:`min_length`,...w(t),minimum:e})}// @__NO_SIDE_EFFECTS__
104
- function Ds(e,t){return new Ci({check:`length_equals`,...w(t),length:e})}// @__NO_SIDE_EFFECTS__
105
- function Os(e,t){return new Ti({check:`string_format`,format:`regex`,...w(t),pattern:e})}// @__NO_SIDE_EFFECTS__
106
- function ks(e){return new Ei({check:`string_format`,format:`lowercase`,...w(e)})}// @__NO_SIDE_EFFECTS__
107
- function As(e){return new Di({check:`string_format`,format:`uppercase`,...w(e)})}// @__NO_SIDE_EFFECTS__
108
- function js(e,t){return new Oi({check:`string_format`,format:`includes`,...w(t),includes:e})}// @__NO_SIDE_EFFECTS__
109
- function Ms(e,t){return new ki({check:`string_format`,format:`starts_with`,...w(t),prefix:e})}// @__NO_SIDE_EFFECTS__
110
- function Ns(e,t){return new Ai({check:`string_format`,format:`ends_with`,...w(t),suffix:e})}// @__NO_SIDE_EFFECTS__
111
- function Ps(e){return new ji({check:`overwrite`,tx:e})}// @__NO_SIDE_EFFECTS__
112
- function Fs(e){return/* @__PURE__ */ Ps(t=>t.normalize(e))}// @__NO_SIDE_EFFECTS__
113
- function Is(){return/* @__PURE__ */ Ps(e=>e.trim())}// @__NO_SIDE_EFFECTS__
114
- function Ls(){return/* @__PURE__ */ Ps(e=>e.toLowerCase())}// @__NO_SIDE_EFFECTS__
115
- function Rs(){return/* @__PURE__ */ Ps(e=>e.toUpperCase())}// @__NO_SIDE_EFFECTS__
116
- function zs(){return/* @__PURE__ */ Ps(e=>on(e))}// @__NO_SIDE_EFFECTS__
117
- function Bs(e,t,n){return new e({type:`array`,element:t,...w(n)})}// @__NO_SIDE_EFFECTS__
118
- function Vs(e,t,n){let r=w(n);return r.abort??=!0,new e({type:`custom`,check:`custom`,fn:t,...r})}// @__NO_SIDE_EFFECTS__
119
- function Hs(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...w(n)})}// @__NO_SIDE_EFFECTS__
120
- function Us(e,t){let n=/* @__PURE__ */ Ws(t=>(t.addIssue=e=>{if(typeof e==`string`)t.issues.push(zn(e,t.value,n._zod.def));else{let r=e;r.fatal&&(r.continue=!1),r.code??=`custom`,`input`in r||(r.input=t.value),r.inst??=n,r.continue??=!n._zod.def.abort,t.issues.push(zn(r))}},e(t.value,t)),t);return n}// @__NO_SIDE_EFFECTS__
121
- function Ws(e,t){let n=new mi({check:`custom`,...w(t)});return n._zod.check=e,n}function Gs(e,...t){for(let n of t)for(let t of Reflect.ownKeys(n))Object.prototype.propertyIsEnumerable.call(n,t)&&Xt(e,t,n[t]);return e}function Ks(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??zo,target:t,unrepresentable:e?.unrepresentable??`throw`,override:e?.override??(()=>{}),io:e?.io??`output`,counter:0,seen:/* @__PURE__ */ new Map,sharedDefsExtractedFor:void 0,sharedEmitDoneFor:void 0,cycles:e?.cycles??`ref`,reused:e?.reused??`inline`,intersections:[],deferred:[],external:e?.external??void 0}}function qs(e,t,n,r,i){let a=typeof t.unrepresentable==`function`?t.unrepresentable({zodSchema:e,path:r.path,message:i}):t.unrepresentable;if(a===`any`)return!1;if(a===void 0||a===`throw`)throw Error(i);return Object.assign(n,a),!0}function Js(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),t.sharedDefsExtractedFor=void 0,t.sharedEmitDoneFor=void 0;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,Js(a,t,r),t.seen.get(a).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&Gs(o.schema,c),t.io===`input`&&ic(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 Ys(e){return e.replace(/~/g,`~0`).replace(/\//g,`~1`)}function Xs(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);if(e.external&&e.sharedDefsExtractedFor===e.external)return;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}/${Ys(a)}`}}let i=`#/${r}/`;if(t[1]===n&&!t[1].schema.id)return{ref:`#`};let a=t[1].schema.id??`__schema${e.counter++}`;return{defId:a,ref:i+Ys(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>
63
+ `)}return o.write(`payload.value = newResult;`),o.write(`return payload;`),o.compile()},o,s=cn,c=!ar.jitless,l=c&&ln.value,u=t.catchall,d;e._zod.parse=(i,f)=>{d??=r.value;let p=i.value;return s(p)?c&&l&&f?.async===!1&&f.jitless!==!0?(o||=a(t.shape),i=o(i,f),u?za([],p,i,f,d,e,f?.abortEarly===!0):i):n(i,f):(i.issues.push({expected:`object`,code:`invalid_type`,input:p,inst:e}),i)}});function Ha(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=>!kn(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=>Fn(e,r,or())))}),t)}let Ua=/*@__PURE__*/ E(`$ZodUnion`,(e,t)=>{Ii.init(e,t),T(e,`optin`,e=>e.def.options.some(e=>e._zod.optin===`defaulted`)?`defaulted`:e.def.options.some(e=>e._zod.optin!==void 0)?`optional`:void 0),T(e,`optout`,e=>e.def.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),T(e,`values`,e=>{if(e.def.options.every(e=>e._zod.values))return new Set(e.def.options.flatMap(e=>Array.from(e._zod.values)))}),T(e,`pattern`,e=>{if(e.def.options.every(e=>e._zod.pattern)){let t=e.def.options.map(e=>e._zod.pattern);return RegExp(`^(${t.map(e=>Kt(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=>Ha(t,r,e,i)):Ha(o,r,e,i)}});function Wa(e){let t=/* @__PURE__ */ new Map;for(let n of e.options){let r=n._zod.propValues?.[e.discriminator];if(!r||r.size===0)throw Error(`Invalid discriminated union option at index "${e.options.indexOf(n)}"`);for(let e of r)if(t.has(e)){if(e!==void 0)throw Error(`Duplicate discriminator value "${String(e)}"`);t.set(e,null)}else t.set(e,n)}return t}let Ga=/*@__PURE__*/ E(`$ZodDiscriminatedUnion`,(e,t)=>{t.inclusive=!1,Ua.init(e,t);let n=e._zod.parse;T(e,`propValues`,e=>{let t={},n=0;for(let r of e.def.options){let i=r._zod.propValues;if(!i||Object.keys(i).length===0)throw Error(`Invalid discriminated union option at index "${e.def.options.indexOf(r)}"`);i[e.def.discriminator]?.has(void 0)&&n++;for(let[e,n]of Object.entries(i)){Object.prototype.hasOwnProperty.call(t,e)||Xt(t,e,/* @__PURE__ */ new Set);for(let r of n)t[e].add(r)}}return!e.def.unionFallback&&n>1&&t[e.def.discriminator]?.delete(void 0),t}),t.options.forEach((e,n)=>{let r=Zt(e._zod.def);if(r&&!Object.prototype.hasOwnProperty.call(r,t.discriminator))throw Error(`Invalid discriminated union option at index "${n}"`)});let r=Wt(()=>Wa(t));e._zod.parse=(i,a)=>{let o=i.value;if(!cn(o))return i.issues.push({code:`invalid_type`,expected:`object`,input:o,inst:e}),i;let s=o?.[t.discriminator],c=r.value.get(s);return c&&(s!==void 0||a.direction!==`backward`)?c._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()).filter(e=>r.value.get(e)!==null),input:o,path:[t.discriminator],inst:e}),i)}}),Ka=/*@__PURE__*/ E(`$ZodIntersection`,(e,t)=>{Ii.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])=>Ja(e,t,n)):Ja(e,i,a)}});function qa(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(un(e)&&un(t)){let n=Object.keys(t),r=Object.keys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};Object.prototype.hasOwnProperty.call(i,`__proto__`)&&delete i.__proto__;for(let n of r){if(n===`__proto__`)continue;let r=qa(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=qa(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 Ja(e,t,n){let r=/* @__PURE__ */ new Map,i,a=/* @__PURE__ */ new Map,o=(e,t)=>{let n;if(e.code===`unrecognized_keys`&&!e.path?.length)i??=e,n=e.keys;else if(e.code===`invalid_key`&&e.origin===`record`&&e.path?.length===1){let t=String(e.path[0]);a.has(t)||a.set(t,e),n=[t]}else return!1;for(let e of n)r.has(e)||r.set(e,{}),r.get(e)[t]=!0;return!0};for(let n of t.issues)o(n,`l`)||e.issues.push(n);for(let t of n.issues)o(t,`r`)||e.issues.push(t);let s=[...r].filter(([,e])=>e.l&&e.r).map(([e])=>e);if(s.length){let t=i?s.filter(e=>i.keys.includes(e)):[];t.length&&e.issues.push({...i,keys:t});for(let n of s)!t.includes(n)&&a.has(n)&&e.issues.push(a.get(n))}let c=qa(t.value,n.value);if(!c.valid){if(kn(e))return e;throw Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`)}return e.value=c.data,e}let Ya=/*@__PURE__*/ E(`$ZodTuple`,(e,t)=>{Ii.init(e,t);let n=t.items,r=ar.memoizer;r?.attach(e),e._zod.parse=(i,a)=>{let o=i.value;if(!Array.isArray(o))return i.issues.push({input:o,inst:e,expected:`tuple`,code:`invalid_type`}),i;i.value=r?r.alloc(e,i,[],a):[];let s=[],c=Xa(n,`optin`),l=Xa(n,`optout`);if(!t.rest){if(o.length<c)return i.issues.push({code:`too_small`,minimum:c,inclusive:!0,input:o,inst:e,origin:`array`}),i;o.length>n.length&&i.issues.push({code:`too_big`,maximum:n.length,inclusive:!0,input:o,inst:e,origin:`array`})}let u=Array(n.length),d=t.rest?a?.abortEarly:void 0,f=!1;for(let e=0;e<n.length;e++){let t=n[e]._zod.run({value:o[e],issues:[]},a);t instanceof Promise?s.push(t.then(t=>{u[e]=t})):(u[e]=t,d&&!f&&t.issues.length&&(f=kn(t)))}if(t.rest&&!f){let e=n.length-1,r=o.slice(n.length),c=i.issues.length;for(let n of r){if(d&&i.issues.length!==c){if(kn(i,c))break;c=i.issues.length}e++;let r=t.rest._zod.run({value:n,issues:[]},a);r instanceof Promise?s.push(r.then(t=>Za(t,i,e))):Za(r,i,e)}}return s.length?Promise.all(s).then(()=>Qa(u,i,n,o,l)):Qa(u,i,n,o,l)}});function Xa(e,t){for(let n=e.length-1;n>=0;n--)if(!(t===`optin`?e[n]._zod.optin!==void 0:e[n]._zod.optout===`optional`))return n+1;return 0}function Za(e,t,n){e.issues.length&&t.issues.push(...jn(n,e.issues)),t.value[n]=e.value}function Qa(e,t,n,r,i){for(let a=0;a<n.length;a++){let o=e[a],s=a<r.length;if(!s&&a>=i&&n[a]._zod.optin===`optional`){t.value.length=a;break}if(o.issues.length){if(!s&&a>=i){t.value.length=a;break}t.issues.push(...jn(a,o.issues))}t.value[a]=o.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 $a=/*@__PURE__*/ E(`$ZodRecord`,(e,t)=>{Ii.init(e,t);let n=ar.memoizer;n?.attach(e),e._zod.parse=(r,i)=>{let a=r.value;if(!un(a))return r.issues.push({expected:`record`,code:`invalid_type`,input:a,inst:e}),r;let o=[],s=t.keyType._zod.values;if(s&&!t.partial){r.value=n?n.alloc(e,r,{},i):{};let c=/* @__PURE__ */ new Set;for(let n of s)if(typeof n==`string`||typeof n==`number`||typeof n==`symbol`){if(c.add(typeof n==`number`?n.toString():n),n===`__proto__`)continue;let s=t.keyType._zod.run({value:n,issues:[]},i);if(s instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(s.issues.length){r.issues.push({code:`invalid_key`,origin:`record`,issues:s.issues.map(e=>Fn(e,i,or())),input:n,path:[n],inst:e});continue}let l=s.value;if(l===`__proto__`)continue;let u=t.valueType._zod.run({value:a[n],issues:[]},i);u instanceof Promise?o.push(u.then(e=>{e.issues.length&&r.issues.push(...jn(n,e.issues)),r.value[l]=e.value})):(u.issues.length&&r.issues.push(...jn(n,u.issues)),r.value[l]=u.value)}let l;for(let e in a)if(!c.has(e)){if(t.mode===`loose`){if(e===`__proto__`)continue;r.value[e]=a[e]}else l??=[],l.push(e)}l&&l.length>0&&r.issues.push({code:`unrecognized_keys`,input:a,inst:e,keys:l,continue:!0})}else{r.value=n?n.alloc(e,r,{},i):{};let c;for(let n of Reflect.ownKeys(a)){if(n===`__proto__`||!Object.prototype.propertyIsEnumerable.call(a,n))continue;let l=t.keyType._zod.run({value:n,issues:[]},i);if(l instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(typeof n==`string`&&di.test(n)&&l.issues.length){let e=t.keyType._zod.run({value:Number(n),issues:[]},i);if(e instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);e.issues.length===0&&(l=e)}if(l.issues.length){t.mode===`loose`?r.value[n]=a[n]:s?(c??=[],c.push(n)):r.issues.push({code:`invalid_key`,origin:`record`,issues:l.issues.map(e=>Fn(e,i,or())),input:n,path:[n],inst:e});continue}let u=l.value;if(u===`__proto__`)continue;let d=t.valueType._zod.run({value:a[n],issues:[]},i);d instanceof Promise?o.push(d.then(e=>{e.issues.length&&r.issues.push(...jn(n,e.issues)),r.value[u]=e.value})):(d.issues.length&&r.issues.push(...jn(n,d.issues)),r.value[u]=d.value)}c&&c.length>0&&r.issues.push({code:`unrecognized_keys`,input:a,inst:e,keys:c,continue:!0})}return o.length?Promise.all(o).then(()=>r):r}}),eo=/*@__PURE__*/ E(`$ZodEnum`,(e,t)=>{Ii.init(e,t);let n=Bt(t.entries),r=new Set(n);e._zod.values=r,T(e,`pattern`,e=>{let t=Bt(e.def.entries).filter(e=>fn.has(typeof e));return RegExp(t.length?`^(${t.map(e=>mn(e.toString())).join(`|`)})$`:`^[^\\s\\S]$`)}),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}}),to=/*@__PURE__*/ E(`$ZodLiteral`,(e,t)=>{Ii.init(e,t);let n=new Set(t.values);e._zod.values=n,T(e,`pattern`,e=>{let t=e.def.values;return RegExp(t.length?`^(${t.map(e=>typeof e==`string`?mn(e):e?mn(e.toString()):String(e)).join(`|`)})$`:`^[^\\s\\S]$`)}),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}}),no=/*@__PURE__*/ E(`$ZodTransform`,(e,t)=>{Ii.init(e,t),e._zod.optin=`optional`,ar.memoizer?.guard(e),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new ir(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));if(i instanceof Promise)throw new rr;return n.value=i,n}});function ro(e,t){return e.value=t.issues.length?void 0:t.value,e}let io=/*@__PURE__*/ E(`$ZodOptional`,(e,t)=>{Ii.init(e,t),T(e,`optin`,e=>e.def.innerType._zod.optin===`defaulted`?`defaulted`:`optional`),e._zod.optout=`optional`,T(e,`values`,e=>{let t=e.def.innerType._zod.values;return t?/* @__PURE__ */ new Set([...t,void 0]):void 0}),T(e,`pattern`,e=>{let t=e.def.innerType._zod.pattern;return t?RegExp(`^(${Kt(t.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if(e.value===void 0){if(t.innerType._zod.optin!==`defaulted`)return e;let r=t.innerType._zod.run({value:e.value,issues:[]},n);return r instanceof Promise?r.then(t=>ro(e,t)):ro(e,r)}return t.innerType._zod.run(e,n)}}),ao=/*@__PURE__*/ E(`$ZodExactOptional`,(e,t)=>{io.init(e,t),T(e,`values`,e=>e.def.innerType._zod.values),T(e,`pattern`,e=>e.def.innerType._zod.pattern),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),oo=/*@__PURE__*/ E(`$ZodNullable`,(e,t)=>{Ii.init(e,t),T(e,`optin`,e=>e.def.innerType._zod.optin),T(e,`optout`,e=>e.def.innerType._zod.optout),T(e,`pattern`,e=>{let t=e.def.innerType._zod.pattern;return t?RegExp(`^(${Kt(t.source)}|null)$`):void 0}),T(e,`values`,e=>e.def.innerType._zod.values?/* @__PURE__ */ new Set([...e.def.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>e.value===null?e:t.innerType._zod.run(e,n)}),so=/*@__PURE__*/ E(`$ZodDefault`,(e,t)=>{Ii.init(e,t),e._zod.optin=`defaulted`,T(e,`values`,e=>e.def.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=>co(e,t)):co(r,t)}});function co(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}let lo=/*@__PURE__*/ E(`$ZodPrefault`,(e,t)=>{Ii.init(e,t),e._zod.optin=`defaulted`,T(e,`values`,e=>e.def.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))}),uo=/*@__PURE__*/ E(`$ZodNonOptional`,(e,t)=>{Ii.init(e,t),T(e,`values`,e=>{let t=e.def.innerType._zod.values;return t?new Set([...t].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=>fo(t,e)):fo(i,e)}});function fo(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:`invalid_type`,expected:`nonoptional`,input:e.value,inst:t}),e}function po(e,t,n,r){return t.issues.length?(e.value=n.catchValue({...t,value:e.value,error:{issues:t.issues.map(e=>Fn(e,r,or()))},input:e.value}),e):(e.value=t.value,t.memo&&(e.memo=!0),e)}let mo=/*@__PURE__*/ E(`$ZodCatch`,(e,t)=>{Ii.init(e,t),T(e,`optin`,e=>e.def.innerType._zod.optin===`defaulted`?`defaulted`:`optional`),T(e,`optout`,e=>e.def.innerType._zod.optout),T(e,`values`,e=>e.def.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({value:e.value,issues:[]},n);return r instanceof Promise?r.then(r=>po(e,r,t,n)):po(e,r,t,n)}}),ho=/*@__PURE__*/ E(`$ZodPipe`,(e,t)=>{Ii.init(e,t),T(e,`values`,e=>e.def.in._zod.values),T(e,`optin`,e=>e.def.in._zod.optin),T(e,`optout`,e=>e.def.out._zod.optout),T(e,`propValues`,e=>e.def.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=>go(e,t.in,n)):go(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>go(e,t.out,n)):go(r,t.out,n)}});function go(e,t,n){return e.issues.some(e=>e.code!==`unrecognized_keys`)?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}let _o=/*@__PURE__*/ E(`$ZodReadonly`,(e,t)=>{Ii.init(e,t),T(e,`propValues`,e=>e.def.innerType._zod.propValues),T(e,`values`,e=>e.def.innerType._zod.values),T(e,`optin`,e=>e.def.innerType?._zod?.optin),T(e,`optout`,e=>e.def.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(vo):vo(r)}});function vo(e){return e.memo||(e.value=Object.freeze(e.value)),e}function yo(e){let t=e._zod.def,n=t.pattern,r=!!t.format?.includes(`int`),i,a;for(let e of t.checks??[]){let t=e._zod.def;t.pattern&&(n=t.pattern),r||=!!t.format?.includes(`int`);let o=t.minimum??t.length,s=t.maximum??t.length;o!==void 0&&(i===void 0||o>i)&&(i=o),s!==void 0&&(a===void 0||s<a)&&(a=s)}if(n)return n.source;if(i!==void 0&&a!==void 0&&i>a)return`(?!)`;if(i!==void 0||a!==void 0)return li({minimum:i,maximum:a}).source;let o=e._zod.pattern;return(r&&o===di?ui:o)?.source}function bo(e){let t=e._zod.def,n=e._zod.pattern?.source,r=t.innerType??e._zod.innerType;if(r){let e=r._zod.pattern?.source,t=bo(r);return n&&e&&t&&t!==e?n.replace(Kt(e),()=>Kt(t)):n}if(t.options){let e=t.options.map(bo);if(e.every(Boolean))return`^(${e.map(e=>Kt(e)).join(`|`)})$`}return yo(e)}let xo=/*@__PURE__*/ E(`$ZodTemplateLiteral`,(e,t)=>{Ii.init(e,t);let n=[];for(let e of t.parts)if(typeof e==`object`&&e){let t=bo(e);if(!t)throw Error(`Invalid template literal part, no pattern found: ${[...e._zod.traits].shift()}`);n.push(Kt(t))}else if(e===null||pn.has(typeof e))n.push(mn(`${e}`));else throw Error(`Invalid template literal part: ${e}`);e._zod.pattern=RegExp(`^${n.join(``)}$`),e._zod.parse=(n,r)=>typeof n.value==`string`?(e._zod.pattern.lastIndex=0,e._zod.pattern.test(n.value)||n.issues.push({input:n.value,inst:e,code:`invalid_format`,format:t.format??`template_literal`,pattern:e._zod.pattern.source}),n):(n.issues.push({input:n.value,inst:e,expected:`string`,code:`invalid_type`}),n)}),So=/*@__PURE__*/ E(`$ZodLazy`,(e,t)=>{Ii.init(e,t),Yt(e._zod,`innerType`,()=>{let e=t;return e._cachedInner||=t.getter(),e._cachedInner}),T(e,`pattern`,e=>e.innerType?._zod?.pattern),T(e,`propValues`,e=>e.innerType?._zod?.propValues),T(e,`optin`,e=>e.innerType?._zod?.optin??void 0),T(e,`optout`,e=>e.innerType?._zod?.optout??void 0),e._zod.parse=(t,n)=>e._zod.innerType._zod.run(t,n)}),Co=/*@__PURE__*/ E(`$ZodCustom`,(e,t)=>{gi.init(e,t),Ii.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=>wo(t,n,r,e));wo(i,n,r,e)}});function wo(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(Bn(e))}}var To=class extends Error{constructor(){super(`Cannot parse a reference cycle that closes through a transform`),this.name=`ZodCyclicError`}};let Eo=`~memo`,Do=[];function Oo(e){return typeof e==`object`&&!!e}function ko(e){return e.map(e=>e.path?{...e,path:e.path.slice()}:{...e})}let Ao=/*@__PURE__*/ new WeakMap;function jo(e,t,n){let r=Ao.get(e);if(r!==void 0)return r?2:0;if(t.has(e))return 2;t.add(e);let i=0,a=e=>{if(i!==2&&e?._zod){let r=jo(e,t,n);r>i&&(i=r)}},o=(e,r)=>{let i=0;for(let a of Reflect.ownKeys(e)){let o=Object.getOwnPropertyDescriptor(e,a);if(r&&!o.enumerable)continue;let s=o.get?1:o.value?._zod?jo(o.value,t,n):0;s>i&&(i=s)}return i},s=e=>{e>i&&(i=e)},c=e._zod.def;switch(c.type){case`object`:{let e=Zt(c);s(e?o(e,!0):1),a(c.catchall);break}case`array`:a(c.element);break;case`tuple`:for(let e of c.items)a(e);a(c.rest);break;case`record`:case`map`:a(c.keyType),a(c.valueType);break;case`set`:a(c.valueType);break;case`union`:for(let e of c.options)a(e);break;case`intersection`:a(c.left),a(c.right);break;case`optional`:case`nullable`:case`default`:case`prefault`:case`catch`:case`readonly`:case`nonoptional`:case`promise`:case`success`:a(c.innerType);break;case`pipe`:a(c.in),a(c.out);break;case`function`:a(c.input),a(c.output);break;case`lazy`:{let r=c._cachedInner??(n?e._zod.innerType:void 0);s(r?jo(r,t,!1):1);break}case`template_literal`:case`string`:case`number`:case`int`:case`boolean`:case`bigint`:case`symbol`:case`undefined`:case`null`:case`void`:case`never`:case`any`:case`unknown`:case`date`:case`nan`:case`enum`:case`literal`:case`file`:case`transform`:case`custom`:break;default:for(let e in c){let t=Object.getOwnPropertyDescriptor(c,e);if(!t||t.get)continue;let n=t.value;if(n&&typeof n==`object`){if(n._zod)a(n);else if(Array.isArray(n))for(let e of n)a(e)}}}return t.delete(e),Mo(e,i)}function Mo(e,t){return t!==1&&Ao.set(e,t===2),t}function No(e,t){let n=e.buckets.get(t);return n||(n=/* @__PURE__ */ new WeakMap,e.buckets.set(t,n)),n}let Po,Fo=[],Io={alloc(e,t,n){let r=Po;if(!r)return n;Po=void 0;let i={value:n,issues:null};return r.set(t.value,i),Fo.push(i),n},guard(e){var t;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let t=e._zod.parse,n=(e,n)=>{if(n.direction!==`backward`&&Ro(n,e.value))throw new To;return t(e,n)};e._zod.parse=n,e._zod.run===t&&(e._zod.run=n)})},attach(e){var t;let n,r=!1,i,a;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let t=e._zod.parse,o=(s,c)=>{if(n===void 0){let i=jo(e,/* @__PURE__ */ new Set,!1);if(i===0)return e._zod.parse=t,e._zod.run===o&&(e._zod.run=t),t(s,c);i===2||r?n=!0:r=!0}let l=s.value;if(!Oo(l))return t(s,c);let u=c[Eo];u||(u={buckets:/* @__PURE__ */ new WeakMap,backEdges:void 0},c[Eo]=u);let d;i===c?d=a:(d=No(u,e),i=c,a=d);let f=d.get(l);if(f)return s.value=f.value,f.issues?f.issues.length&&s.issues.push(...ko(f.issues)):(s.memo=!0,u.backEdges??(u.backEdges=/* @__PURE__ */ new WeakSet),u.backEdges.add(f.value)),s;Po=d;let p=Fo.length,m=t(s,c);Po=void 0;let h=Fo.length>p?Fo.pop():void 0;return m instanceof Promise?m.then(e=>(h&&(h.issues=e.issues.length?ko(e.issues):Do),e)):(h&&(h.issues=m.issues.length?ko(m.issues):Do),m)};e._zod.parse=o,e._zod.run===t&&(e._zod.run=o)})}};function Lo(){return Io}function Ro(e,t){let n=e[Eo]?.backEdges;return n!==void 0&&Oo(t)&&n.has(t)}let zo=()=>{let e={string:{unit:`characters`,verb:`to have`},file:{unit:`bytes`,verb:`to have`},array:{unit:`items`,verb:`to have`},set:{unit:`items`,verb:`to have`},map:{unit:`entries`,verb:`to have`}};function t(t){return e[t]??null}let n={regex:`input`,email:`email address`,url:`URL`,emoji:`emoji`,uuid:`UUID`,uuidv4:`UUIDv4`,uuidv6:`UUIDv6`,nanoid:`nanoid`,guid:`GUID`,cuid:`cuid`,cuid2:`cuid2`,ulid:`ULID`,xid:`XID`,ksuid:`KSUID`,datetime:`ISO datetime`,date:`ISO date`,time:`ISO time`,duration:`ISO duration`,ipv4:`IPv4 address`,ipv6:`IPv6 address`,mac:`MAC address`,cidrv4:`IPv4 range`,cidrv6:`IPv6 range`,base64:`base64-encoded string`,base64url:`base64url-encoded string`,json_string:`JSON string`,e164:`E.164 number`,currency_code:`currency code`,credit_card:`credit card number`,iban:`IBAN`,jwt:`JWT`,template_literal:`input`},r={nan:`NaN`};function i(e,t){return e===`number`&&typeof t==`number`&&!Number.isFinite(t)?String(t):r[e]??e}return e=>{switch(e.code){case`invalid_type`:return`Invalid input: expected ${i(e.expected)}, received ${i(zn(e.input),e.input)}`;case`invalid_value`:return e.values.length===1?`Invalid input: expected ${gn(e.values[0])}`:`Invalid option: expected one of ${Vt(e.values,`|`)}`;case`too_big`:{let n=e.exact?`exactly `:e.inclusive?`<=`:`<`,r=t(e.origin);return r?`Too big: expected ${e.origin??`value`} to have ${n}${e.maximum.toString()} ${r.unit??`elements`}`:`Too big: expected ${e.origin??`value`} to be ${n}${e.maximum.toString()}`}case`too_small`:{let n=e.exact?`exactly `:e.inclusive?`>=`:`>`,r=t(e.origin);return r?`Too small: expected ${e.origin} to have ${n}${e.minimum.toString()} ${r.unit}`:`Too small: expected ${e.origin} to be ${n}${e.minimum.toString()}`}case`invalid_format`:{let t=e;return t.format===`starts_with`?`Invalid string: must start with "${t.prefix}"`:t.format===`ends_with`?`Invalid string: must end with "${t.suffix}"`:t.format===`includes`?`Invalid string: must include "${t.includes}"`:t.format===`regex`?`Invalid string: must match pattern ${t.pattern}`:`Invalid ${n[t.format]??e.format}`}case`not_multiple_of`:return`Invalid number: must be a multiple of ${e.divisor}`;case`unrecognized_keys`:return`Unrecognized key${e.keys.length>1?`s`:``}: ${Vt(e.keys,`, `)}`;case`invalid_key`:return`Invalid key in ${e.origin}`;case`invalid_union`:return e.options&&Array.isArray(e.options)&&e.options.length>0?`Invalid discriminator value. Expected ${e.options.map(e=>`'${e}'`).join(` | `)}`:e.inclusive===!1?`Invalid input: more than one option matched`:`Invalid input`;case`invalid_element`:return`Invalid value in ${e.origin}`;default:return`Invalid input`}}};function Bo(){return{localeError:zo()}}var Vo,Ho=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 Uo(){return new Ho}(Vo=globalThis).__zod_globalRegistry??(Vo.__zod_globalRegistry=Uo());let Wo=globalThis.__zod_globalRegistry;function Go(e){return e.checks&&=[...e.checks],e}// @__NO_SIDE_EFFECTS__
64
+ function Ko(e,t){return new e(Go({type:`string`,...w(t)}))}// @__NO_SIDE_EFFECTS__
65
+ function qo(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...w(t)})}// @__NO_SIDE_EFFECTS__
66
+ function Jo(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...w(t)})}// @__NO_SIDE_EFFECTS__
67
+ function Yo(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...w(t)})}// @__NO_SIDE_EFFECTS__
68
+ function Xo(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...w(t)})}// @__NO_SIDE_EFFECTS__
69
+ function Zo(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...w(t)})}// @__NO_SIDE_EFFECTS__
70
+ function Qo(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...w(t)})}// @__NO_SIDE_EFFECTS__
71
+ function $o(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...w(t)})}// @__NO_SIDE_EFFECTS__
72
+ function es(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...w(t)})}// @__NO_SIDE_EFFECTS__
73
+ function ts(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...w(t)})}// @__NO_SIDE_EFFECTS__
74
+ function ns(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...w(t)})}// @__NO_SIDE_EFFECTS__
75
+ function rs(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...w(t)})}// @__NO_SIDE_EFFECTS__
76
+ function is(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...w(t)})}// @__NO_SIDE_EFFECTS__
77
+ function as(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...w(t)})}// @__NO_SIDE_EFFECTS__
78
+ function os(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...w(t)})}// @__NO_SIDE_EFFECTS__
79
+ function ss(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...w(t)})}// @__NO_SIDE_EFFECTS__
80
+ function cs(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...w(t)})}// @__NO_SIDE_EFFECTS__
81
+ function ls(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...w(t)})}// @__NO_SIDE_EFFECTS__
82
+ function us(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...w(t)})}// @__NO_SIDE_EFFECTS__
83
+ function ds(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...w(t)})}// @__NO_SIDE_EFFECTS__
84
+ function fs(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...w(t)})}// @__NO_SIDE_EFFECTS__
85
+ function ps(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...w(t)})}// @__NO_SIDE_EFFECTS__
86
+ function ms(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...w(t)})}// @__NO_SIDE_EFFECTS__
87
+ function hs(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...w(t)})}// @__NO_SIDE_EFFECTS__
88
+ function gs(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...w(t)})}// @__NO_SIDE_EFFECTS__
89
+ function _s(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...w(t)})}// @__NO_SIDE_EFFECTS__
90
+ function vs(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...w(t)})}// @__NO_SIDE_EFFECTS__
91
+ function ys(e,t){return new e(Go({type:`number`,checks:[],...w(t)}))}// @__NO_SIDE_EFFECTS__
92
+ function bs(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...w(t)})}// @__NO_SIDE_EFFECTS__
93
+ function xs(e,t){return new e({type:`boolean`,...w(t)})}// @__NO_SIDE_EFFECTS__
94
+ function Ss(e,t){return new e({type:`null`,...w(t)})}// @__NO_SIDE_EFFECTS__
95
+ function Cs(e){return new e({type:`unknown`})}// @__NO_SIDE_EFFECTS__
96
+ function ws(e,t){return new e({type:`never`,...w(t)})}// @__NO_SIDE_EFFECTS__
97
+ function Ts(e,t){return new yi({check:`less_than`,...w(t),value:e,inclusive:!1})}// @__NO_SIDE_EFFECTS__
98
+ function Es(e,t){return new yi({check:`less_than`,...w(t),value:e,inclusive:!0})}// @__NO_SIDE_EFFECTS__
99
+ function Ds(e,t){return new bi({check:`greater_than`,...w(t),value:e,inclusive:!1})}// @__NO_SIDE_EFFECTS__
100
+ function Os(e,t){return new bi({check:`greater_than`,...w(t),value:e,inclusive:!0})}// @__NO_SIDE_EFFECTS__
101
+ function ks(e,t){return new xi({check:`multiple_of`,...w(t),value:e})}// @__NO_SIDE_EFFECTS__
102
+ function As(e,t){return new Ci({check:`max_length`,...w(t),maximum:e})}// @__NO_SIDE_EFFECTS__
103
+ function js(e,t){return new wi({check:`min_length`,...w(t),minimum:e})}// @__NO_SIDE_EFFECTS__
104
+ function Ms(e,t){return new Ti({check:`length_equals`,...w(t),length:e})}// @__NO_SIDE_EFFECTS__
105
+ function Ns(e,t){return new Di({check:`string_format`,format:`regex`,...w(t),pattern:e})}// @__NO_SIDE_EFFECTS__
106
+ function Ps(e){return new Oi({check:`string_format`,format:`lowercase`,...w(e)})}// @__NO_SIDE_EFFECTS__
107
+ function Fs(e){return new ki({check:`string_format`,format:`uppercase`,...w(e)})}// @__NO_SIDE_EFFECTS__
108
+ function Is(e,t){return new Ai({check:`string_format`,format:`includes`,...w(t),includes:e})}// @__NO_SIDE_EFFECTS__
109
+ function Ls(e,t){return new ji({check:`string_format`,format:`starts_with`,...w(t),prefix:e})}// @__NO_SIDE_EFFECTS__
110
+ function Rs(e,t){return new Mi({check:`string_format`,format:`ends_with`,...w(t),suffix:e})}// @__NO_SIDE_EFFECTS__
111
+ function zs(e){return new Ni({check:`overwrite`,tx:e})}// @__NO_SIDE_EFFECTS__
112
+ function Bs(e){return/* @__PURE__ */ zs(t=>t.normalize(e))}// @__NO_SIDE_EFFECTS__
113
+ function Vs(){return/* @__PURE__ */ zs(e=>e.trim())}// @__NO_SIDE_EFFECTS__
114
+ function Hs(){return/* @__PURE__ */ zs(e=>e.toLowerCase())}// @__NO_SIDE_EFFECTS__
115
+ function Us(){return/* @__PURE__ */ zs(e=>e.toUpperCase())}// @__NO_SIDE_EFFECTS__
116
+ function Ws(){return/* @__PURE__ */ zs(e=>on(e))}// @__NO_SIDE_EFFECTS__
117
+ function Gs(e,t,n){return new e({type:`array`,element:t,...w(n)})}// @__NO_SIDE_EFFECTS__
118
+ function Ks(e,t,n){let r=w(n);return r.abort??=!0,new e({type:`custom`,check:`custom`,fn:t,...r})}// @__NO_SIDE_EFFECTS__
119
+ function qs(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...w(n)})}// @__NO_SIDE_EFFECTS__
120
+ function Js(e,t){let n=/* @__PURE__ */ Ys(t=>(t.addIssue=e=>{if(typeof e==`string`)t.issues.push(Bn(e,t.value,n._zod.def));else{let r=e;r.fatal&&(r.continue=!1),r.code??=`custom`,`input`in r||(r.input=t.value),r.inst??=n,r.continue??=!n._zod.def.abort,t.issues.push(Bn(r))}},e(t.value,t)),t);return n}// @__NO_SIDE_EFFECTS__
121
+ function Ys(e,t){let n=new gi({check:`custom`,...w(t)});return n._zod.check=e,n}function Xs(e,...t){for(let n of t)for(let t of Reflect.ownKeys(n))Object.prototype.propertyIsEnumerable.call(n,t)&&Xt(e,t,n[t]);return e}function Zs(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??Wo,target:t,unrepresentable:e?.unrepresentable??`throw`,override:e?.override??(()=>{}),io:e?.io??`output`,counter:0,seen:/* @__PURE__ */ new Map,sharedDefsExtractedFor:void 0,sharedEmitDoneFor:void 0,cycles:e?.cycles??`ref`,reused:e?.reused??`inline`,intersections:[],deferred:[],external:e?.external??void 0}}function Qs(e,t,n,r,i){let a=typeof t.unrepresentable==`function`?t.unrepresentable({zodSchema:e,path:r.path,message:i}):t.unrepresentable;if(a===`any`)return!1;if(a===void 0||a===`throw`)throw Error(i);return Object.assign(n,a),!0}function $s(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),t.sharedDefsExtractedFor=void 0,t.sharedEmitDoneFor=void 0;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,$s(a,t,r),t.seen.get(a).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&Xs(o.schema,c),t.io===`input`&&lc(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 ec(e){return e.replace(/~/g,`~0`).replace(/\//g,`~1`)}function tc(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);if(e.external&&e.sharedDefsExtractedFor===e.external)return;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}/${ec(a)}`}}let i=`#/${r}/`;if(t[1]===n&&!t[1].schema.id)return{ref:`#`};let a=t[1].schema.id??`__schema${e.counter++}`;return{defId:a,ref:i+ec(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>
122
122
 
123
- 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)}}e.external&&(e.sharedDefsExtractedFor=e.external)}function Zs(e){let t=e.anyOf;if(!Array.isArray(t)||t.length===0||e.type!==void 0)return;let n=[];for(let e of t){if(!e||typeof e!=`object`)return;Zs(e);let t=Object.keys(e);if(t.length!==1||t[0]!==`type`)return;let r=e.type;for(let e of Array.isArray(r)?r:[r]){if(typeof e!=`string`)return;n.includes(e)||n.push(e)}}delete e.anyOf,e.type=n.length===1?n[0]:n}let Qs=/* @__PURE__ */ new Set([`type`,`properties`,`required`,`additionalProperties`]),$s=[`oneOf`,`anyOf`];function ec(e){let t=e.additionalProperties;return t===void 0||t===!1||typeof t!=`object`||!t?null:Object.keys(t).length?t:null}function tc(e){let t=[];for(let n of e){if(typeof n!=`object`||n.type!==`object`)return null;for(let e in n)if(!Qs.has(e))return null;t.push(n)}let n={},r=/* @__PURE__ */ new Set;for(let e of t){for(let r in e.properties){if(Object.prototype.hasOwnProperty.call(n,r))continue;let e=[];for(let n of t){let t=n.properties?.[r]??ec(n);t!=null&&(e.some(e=>JSON.stringify(e)===JSON.stringify(t))||e.push(t))}Xt(n,r,e.length===1?e[0]:tc(e)??{allOf:e})}for(let t of e.required??[])r.add(t)}let i={type:`object`,properties:n};if(r.size&&(i.required=[...r]),t.every(e=>e.additionalProperties===!1))i.additionalProperties=!1;else{let e=[];for(let n of t){let t=ec(n);t&&!e.some(e=>JSON.stringify(e)===JSON.stringify(t))&&e.push(t)}e.length===1?i.additionalProperties=e[0]:e.length>1&&(i.additionalProperties={allOf:e})}return i}function nc(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let t of Qs)if(t in e)return;let n=t.filter(e=>$s.some(t=>Array.isArray(e[t]))),r=null;if(!n.length)r=tc(t);else{let e=n[0],i=$s.find(t=>Array.isArray(e[t]));if(Object.keys(e).length!==1)return;let a=t.filter(t=>t!==e),o=e[i].map(e=>tc([...a,e]));if(o.some(e=>!e))return;r={[i]:o}}r&&(delete e.allOf,Gs(e,r))}function rc(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)):Gs(i,s),Gs(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??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(let t of[...e.seen.entries()].reverse())r(t[0]);if(e.target!==`openapi-3.0`)for(let t of e.seen.entries())Zs(t[1].def??t[1].schema);for(let t of e.deferred)t();if(e.intersections.length){let t=/* @__PURE__ */ new Map;for(let n of e.seen.values())for(let e of[n.schema,n.def]){let n=e?.allOf;if(!Array.isArray(n))continue;let r=t.get(n);r?r.push(e):t.set(n,[e])}for(let n of e.intersections)for(let e of t.get(n)??[])nc(e)}}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)}Gs(i,n.defId?n.schema: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??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(e.def.id===e.defId&&delete e.def.id,Xt(o,e.defId,e.def))}e.external&&(e.sharedEmitDoneFor=e.external),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:oc(t,`input`,e.processors),output:oc(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function ic(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 ic(r.element,n);if(r.type===`set`)return ic(r.valueType,n);if(r.type===`lazy`)return ic(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`||r.type===`catch`)return ic(r.innerType,n);if(r.type===`intersection`)return ic(r.left,n)||ic(r.right,n);if(r.type===`record`||r.type===`map`)return ic(r.keyType,n)||ic(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:ic(r.in,n)||ic(r.out,n);if(r.type===`object`){for(let e in r.shape)if(ic(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(ic(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(ic(e,n))return!0;return!!(r.rest&&ic(r.rest,n))}return!1}let ac=(e,t={})=>n=>{let r=Ks({...n,processors:t});return Js(e,r),Xs(r,e),rc(r,e)},oc=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=Ks({...i??{},target:a,io:t,processors:n});return Js(e,o),Xs(o,e),rc(o,e)},sc=(e,t,n)=>{(e[t]===void 0||n>e[t])&&(e[t]=n)},cc=(e,t,n)=>{(e[t]===void 0||n<e[t])&&(e[t]=n)},lc=(e,t)=>{sc(e,`minimum`,t),cc(e,`maximum`,t)},uc=(e,t)=>{e.multipleOf??=[],e.multipleOf.includes(t)||e.multipleOf.push(t)},dc=(e,t)=>{e.patterns??=/* @__PURE__ */ new Set,e.patterns.add(t)},fc=(e,t)=>{e.mime=e.mime?e.mime.filter(e=>t.includes(e)):[...t]},pc=(e,t)=>{e.format=t,t.includes(`int`)&&(e.isInt=!0)},mc=(e,t)=>sc(e,`minimum`,t.minimum),hc=(e,t)=>cc(e,`maximum`,t.maximum),gc=e=>(t,n)=>{pc(t,n.format);let[r,i]=e[n.format];sc(t,`minimum`,r),cc(t,`maximum`,i)},_c={greater_than:(e,t)=>sc(e,t.inclusive?`minimum`:`exclusiveMinimum`,t.value),less_than:(e,t)=>cc(e,t.inclusive?`maximum`:`exclusiveMaximum`,t.value),multiple_of:(e,t)=>uc(e,t.value),number_format:gc(_n),bigint_format:gc(vn),min_length:mc,max_length:hc,length_equals:(e,t)=>lc(e,t.length),min_size:mc,max_size:hc,size_equals:(e,t)=>lc(e,t.size),string_format:(e,t)=>{pc(e,t.format),t.pattern&&dc(e,t.pattern),(t.format===`base64`||t.format===`base64url`)&&(e.contentEncoding=t.format),(t.local||t.precision===-1)&&(e.laxFormat=!0)},mime_type:(e,t)=>fc(e,t.mime)};function vc(e){let t={},n=e._zod.def,r=e._zod.traits.has(`$ZodCheck`)?[e,...n.checks??[]]:n.checks??[];for(let e of r)_c[e._zod.def.check]?.(t,e._zod.def);let i=e._zod.bag;i.minimum!==void 0&&sc(t,`minimum`,i.minimum),i.exclusiveMinimum!==void 0&&sc(t,`exclusiveMinimum`,i.exclusiveMinimum),i.maximum!==void 0&&cc(t,`maximum`,i.maximum),i.exclusiveMaximum!==void 0&&cc(t,`exclusiveMaximum`,i.exclusiveMaximum),i.multipleOf!==void 0&&uc(t,i.multipleOf),i.format!==void 0&&(t.format??=i.format,i.format.includes(`int`)&&(t.isInt=!0)),i.mime&&fc(t,i.mime);for(let e of i.patterns??[])dc(t,e);return t}let yc={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},bc=/* @__PURE__ */ new Map([[ga,Zr],[va,Qr]]),xc=e=>bc.get(e)??e,Sc=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l,laxFormat:u}=vc(e);if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=yc[s]??s,i.format===``&&delete i.format,(s===`time`||u)&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let e=[...c].map(xc);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}))])}},Cc=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,multipleOf:s,exclusiveMaximum:c,exclusiveMinimum:l,isInt:u}=vc(e);i.type=u?`integer`:`number`;let d=typeof l==`number`&&l>=(a??-1/0),f=typeof c==`number`&&c<=(o??1/0),p=t.target===`draft-04`||t.target===`openapi-3.0`;if(d?p?(i.minimum=l,i.exclusiveMinimum=!0):i.exclusiveMinimum=l:typeof a==`number`&&(i.minimum=a),f?p?(i.maximum=c,i.exclusiveMaximum=!0):i.exclusiveMaximum=c:typeof o==`number`&&(i.maximum=o),s){let n=/* @__PURE__ */ new Set;for(let a of s)Number.isFinite(a)&&a!==0?n.add(Math.abs(a)):qs(e,t,i,r,`A multipleOf divisor of ${a} cannot be represented in JSON Schema`);let[a,...o]=n;a!==void 0&&(i.multipleOf=a),o.length&&(i.allOf=[...i.allOf??[],...o.map(e=>({multipleOf:e}))])}},wc=(e,t,n,r)=>{n.type=`boolean`},Tc=(e,t,n,r)=>{t.target===`openapi-3.0`?(n.type=`string`,n.nullable=!0,n.enum=[null]):n.type=`null`},Ec=(e,t,n,r)=>{n.not={}},Dc=(e,t,n,r)=>{let i=e._zod.def,a=Bt(i.entries);a.length===0?n.not={}:(a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a)},Oc=(e,t,n,r)=>{let i=e._zod.def;if(i.values.length===0){n.not={};return}let a=[];for(let o of i.values)if(o===void 0){if(qs(e,t,n,r,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof o==`bigint`){if(qs(e,t,n,r,`BigInt literals cannot be represented in JSON Schema`))return;a.push(Number(o))}else a.push(o);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}},kc=(e,t,n,r)=>{qs(e,t,n,r,`Custom types cannot be represented in JSON Schema`)},Ac=(e,t,n,r)=>{qs(e,t,n,r,`Transforms cannot be represented in JSON Schema`)},jc=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=vc(e);typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=Js(a.element,t,{...r,path:[...r.path,`items`]})};function Mc(e){let t=e._zod.def;return t.type===`pipe`&&t.in._zod.traits.has(`$ZodTransform`)?Mc(t.out):t.type===`catch`?Mc(t.innerType):e._zod.optin}let Nc=(e,t,n,r)=>{let i=n,a=e._zod.def,o=a.shape;if(Object.getOwnPropertySymbols(o).length&&qs(e,t,i,r,`Symbol keys cannot be represented in JSON Schema`))return;i.type=`object`,i.properties={};for(let e in o)Xt(i.properties,e,Js(o[e],t,{...r,path:[...r.path,`properties`,e]}));let s=[];for(let e of Object.keys(o)){let n=a.shape[e];(t.io===`input`?Mc(n)===void 0:n._zod.optout===void 0)&&s.push(e)}s.length>0&&(i.required=s),a.catchall?._zod.def.type===`never`?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=Js(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},Pc=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>Js(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},Fc=(e,t,n,r)=>{let i=e._zod.def,a=Js(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=Js(i.right,t,{...r,path:[...r.path,`allOf`,1]}),s=e=>`allOf`in e&&Object.keys(e).length===1,c=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]];n.allOf=c,t.intersections.push(c)},Ic=(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)=>Js(e,t,{...r,path:[...r.path,o,n]})),l=a.rest?Js(a.rest,t,{...r,path:[...r.path,s,...t.target===`openapi-3.0`?[a.items.length]:[]]}):null,u=a.items.length;for(;u>0;){let e=a.items[u-1];if(!(t.io===`input`?Mc(e)!==void 0:e._zod.optout===`optional`))break;u--}let d=a.items.length,f=!a.rest;t.target===`draft-2020-12`?(i.prefixItems=c,f?i.items=!1:l&&(i.items=l),u>0&&(i.minItems=u),f&&(i.maxItems=d)):t.target===`openapi-3.0`?(i.items={anyOf:c},l&&i.items.anyOf.push(l),u>0&&(i.minItems=u),f&&(i.maxItems=d)):(i.items=c,f?i.additionalItems=!1:l&&(i.additionalItems=l),u>0&&(i.minItems=u),f&&(i.maxItems=d));let{minimum:p,maximum:m}=vc(e);typeof p==`number`&&(i.minItems=p),typeof m==`number`&&(i.maxItems=m)};function Lc(e,t,n){if(t.$ref){if(n.has(t))return t;n.add(t);let r=e.get(t)?.def;if(!r)return t;let i=Lc(e,r,n);return i===r?t:i}for(let r of[`anyOf`,`oneOf`]){let i=t[r];if(!Array.isArray(i))continue;let a=i.map(t=>Lc(e,t,n));a.some((e,t)=>e!==i[t])&&(t={...t,[r]:a})}let r=Array.isArray(t.type)?t.type:[t.type],i=!r.includes(`string`)&&r.some(e=>e===`number`||e===`integer`),a=t.enum??(t.const===void 0?void 0:[t.const]);if(!i&&!a?.some(e=>typeof e==`number`))return t;let{minimum:o,maximum:s,exclusiveMinimum:c,exclusiveMaximum:l,multipleOf:u,format:d,id:f,...p}=t;return p.enum?p.enum=p.enum.map(e=>typeof e==`number`?String(e):e):typeof p.const==`number`&&(p.const=String(p.const)),i&&(p.type=`string`,a||(p.pattern=(r.includes(`number`)?li:ci).source)),p}let Rc=/* @__PURE__ */ new WeakMap;function zc(e){let t=/* @__PURE__ */ new Map;for(let n of e.seen.values())n.def&&!t.has(n.schema)&&t.set(n.schema,n);let n=/* @__PURE__ */ new Map;for(let r of Rc.get(e)??[]){let i=e.seen.get(r),a=(i?.def??i?.schema)?.propertyNames;if(!a||a===!0||n.has(a))continue;let o=Lc(t,a,/* @__PURE__ */ new Set);o!==a&&n.set(a,o)}if(n.size)for(let t of e.seen.values())for(let e of[t.schema,t.def]){let t=e&&n.get(e.propertyNames);t&&(e.propertyNames=t)}}let Bc=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`;let o=a.keyType,s=vc(o).patterns;if(a.mode===`loose`&&s&&s.size>0){let e=Js(a.valueType,t,{...r,path:[...r.path,`patternProperties`,`*`]});i.patternProperties={};for(let t of s)Xt(i.patternProperties,xc(t).source,e)}else{if(t.target===`draft-07`||t.target===`draft-2020-12`){i.propertyNames=Js(a.keyType,t,{...r,path:[...r.path,`propertyNames`]});let n=Rc.get(t);n||(n=[],Rc.set(t,n),t.deferred.push(()=>zc(t))),n.push(e)}i.additionalProperties=Js(a.valueType,t,{...r,path:[...r.path,`additionalProperties`]})}let c=o._zod.values,l=t.io===`input`&&Mc(a.valueType)!==void 0;if(c&&!a.partial&&!l){let e=[...c].filter(e=>typeof e==`string`||typeof e==`number`);e.length>0&&(i.required=e.map(String))}},Vc=(e,t,n,r)=>{let i=e._zod.def,a=Js(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`}]},Hc=(e,t,n,r)=>{let i=e._zod.def;Js(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Uc=Symbol();function Wc(e,t,n,r,i){let a=!1,o=JSON.stringify(e,(e,t)=>typeof t==`bigint`?(a=!0,null):t);return a?(qs(t,n,r,i,`BigInt defaults cannot be represented in JSON Schema`),Uc):JSON.parse(o)}let Gc=(e,t,n,r)=>{let i=e._zod.def;Js(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o=Wc(i.defaultValue,e,t,n,r);o!==Uc&&(n.default=o)},Kc=(e,t,n,r)=>{let i=e._zod.def;Js(i.innerType,t,r);let a=t.seen.get(e);if(a.ref=i.innerType,t.io!==`input`)return;let o=Wc(i.defaultValue,e,t,n,r);o!==Uc&&(n._prefault=o)},qc=(e,t,n,r)=>{let i=e._zod.def;Js(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{qs(e,t,n,r,`Dynamic catch values are not supported in JSON Schema`);return}n.default=o},Jc=(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;Js(o,t,r);let s=t.seen.get(e);s.ref=o},Yc=(e,t,n,r)=>{let i=e._zod.def;Js(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},Xc=(e,t,n,r)=>{let i=e._zod.def;Js(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Zc=(e,t,n,r)=>{let i=e._zod.innerType;Js(i,t,r);let a=t.seen.get(e);a.ref=i},Qc=/* @__PURE__ */ new WeakSet([Object.prototype,Error.prototype]);function $c(e,t,n){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){let e=n(this);return Object.defineProperty(this,t,{value:e,configurable:!0,writable:!0}),e},set(e){Object.defineProperty(this,t,{value:e,configurable:!0,writable:!0})}})}let el=/*@__PURE__*/ E(`ZodError`,(e,t)=>{fr.init(e,t),e.name=`ZodError`;let n=Object.getPrototypeOf(e);Qc.has(n)||(Qc.add(n),$c(n,`format`,e=>t=>hr(e,t)),$c(n,`flatten`,e=>t=>mr(e,t)),$c(n,`addIssue`,e=>t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,Ht,2)}),$c(n,`addIssues`,e=>t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,Ht,2)}),Object.defineProperty(n,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))},void 0,{Parent:Error}),tl=/* @__PURE__ */ _r(el),nl=/* @__PURE__ */ vr(el),rl=/* @__PURE__ */ yr(el),il=/* @__PURE__ */ xr(el),al=/* @__PURE__ */ Dr(el),ol=/* @__PURE__ */ Or(el),sl=/* @__PURE__ */ kr(el),cl=/* @__PURE__ */ Ar(el),ll=/* @__PURE__ */ jr(el),ul=/* @__PURE__ */ Mr(el),dl=/* @__PURE__ */ Nr(el),fl=/* @__PURE__ */ Pr(el);function pl(){ir.localeError||ar(Fo())}function ml(){ir.memoizer||ar({memoizer:Mo()})}let hl=/*@__PURE__*/ E(`ZodType`,(e,t)=>(pl(),Pi.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(rn(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 mn(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(Ru(e,t))},superRefine(e,t){return this.check(zu(e,t))},overwrite(e){return this.check(/* @__PURE__ */ Ps(e))},optional(){return _u(this)},exactOptional(){return yu(this)},nullable(){return xu(this)},nullish(){return _u(xu(this))},nonoptional(e){return Du(this,e)},array(){return A(this)},or(e){return ru([this,e])},and(e){return su(this,e)},transform(e){return ju(this,hu(e))},default(e){return Cu(this,e)},prefault(e){return Tu(this,e)},catch(e){return ku(this,e)},pipe(e){return ju(this,e)},readonly(){return Nu(this)},describe(e){let t=this.clone();return zo.add(t,{description:e}),t},meta(...e){if(e.length===0)return zo.get(this);let t=this.clone();return zo.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...t){return t.length===0?e(this):e(this,...t)},get"~standard"(){return Hn(this,`~standard`,{...Li(this),jsonSchema:{input:oc(this,`input`),output:oc(this,`output`)}})},set"~standard"(e){Vn(this,`~standard`,e)},parse:function e(t,n){return tl(this,t,n,{callee:e})},parseAsync:async function e(t,n){return await nl(this,t,n,{callee:e})},safeParse(e,t){return rl(this,e,t)},async safeParseAsync(e,t){return il(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){Vn(this,`spa`,e)},validate(e,t){return wr(this,e,t)},validateAsync(e,t){return Er(this,e,t)},encode:function e(t,n){return al(this,t,n,{callee:e})},decode:function e(t,n){return ol(this,t,n,{callee:e})},encodeAsync:async function e(t,n){return await sl(this,t,n,{callee:e})},decodeAsync:async function e(t,n){return await cl(this,t,n,{callee:e})},safeEncode(e,t){return ll(this,e,t)},safeDecode(e,t){return ul(this,e,t)},async safeEncodeAsync(e,t){return dl(this,e,t)},async safeDecodeAsync(e,t){return fl(this,e,t)},toJSONSchema(e){return ac(this,{})(e)},get description(){return zo.get(this)?.description},get _def(){return this._zod.def}}),gl=/*@__PURE__*/ E(`_ZodString`,(e,t)=>{Ri.init(e,t),hl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Sc(e,t,n,r)},/*@__PURE__*/ Un({format:e=>vc(e).format??null,minLength:e=>vc(e).minimum??null,maxLength:e=>vc(e).maximum??null},{regex(...e){return this.check(/* @__PURE__ */ Os(...e))},includes(...e){return this.check(/* @__PURE__ */ js(...e))},startsWith(...e){return this.check(/* @__PURE__ */ Ms(...e))},endsWith(...e){return this.check(/* @__PURE__ */ Ns(...e))},min(...e){return this.check(/* @__PURE__ */ Es(...e))},max(...e){return this.check(/* @__PURE__ */ Ts(...e))},length(...e){return this.check(/* @__PURE__ */ Ds(...e))},nonempty(...e){return this.check(/* @__PURE__ */ Es(1,...e))},lowercase(e){return this.check(/* @__PURE__ */ ks(e))},uppercase(e){return this.check(/* @__PURE__ */ As(e))},trim(){return this.check(/* @__PURE__ */ Is())},normalize(...e){return this.check(/* @__PURE__ */ Fs(...e))},toLowerCase(){return this.check(/* @__PURE__ */ Ls())},toUpperCase(){return this.check(/* @__PURE__ */ Rs())},slugify(){return this.check(/* @__PURE__ */ zs())}})),_l=/*@__PURE__*/ E(`ZodString`,(e,t)=>{Ri.init(e,t),gl.init(e,t)},{email(e){return this.check(/* @__PURE__ */ Ho(Cl,e))},url(e){return this.check(/* @__PURE__ */ Jo(Dl,e))},jwt(e){return this.check(/* @__PURE__ */ ls(Ul,e))},emoji(e){return this.check(/* @__PURE__ */ Yo(kl,e))},guid(e){return this.check(/* @__PURE__ */ Uo(wl,e))},uuid(e){return this.check(/* @__PURE__ */ Wo(Tl,e))},uuidv4(e){return this.check(/* @__PURE__ */ Go(Tl,e))},uuidv6(e){return this.check(/* @__PURE__ */ Ko(Tl,e))},uuidv7(e){return this.check(/* @__PURE__ */ qo(Tl,e))},nanoid(e){return this.check(/* @__PURE__ */ Xo(Al,e))},cuid(e){return this.check(/* @__PURE__ */ Zo(jl,e))},cuid2(e){return this.check(/* @__PURE__ */ Qo(Ml,e))},ulid(e){return this.check(/* @__PURE__ */ $o(Nl,e))},base64(e){return this.check(/* @__PURE__ */ os(Bl,e))},base64url(e){return this.check(/* @__PURE__ */ ss(Vl,e))},xid(e){return this.check(/* @__PURE__ */ es(Pl,e))},ksuid(e){return this.check(/* @__PURE__ */ ts(Fl,e))},ipv4(e){return this.check(/* @__PURE__ */ ns(Il,e))},ipv6(e){return this.check(/* @__PURE__ */ rs(Ll,e))},cidrv4(e){return this.check(/* @__PURE__ */ is(Rl,e))},cidrv6(e){return this.check(/* @__PURE__ */ as(zl,e))},e164(e){return this.check(/* @__PURE__ */ cs(Hl,e))},datetime(e){return this.check(/* @__PURE__ */ us(yl,e))},date(e){return this.check(/* @__PURE__ */ ds(bl,e))},time(e){return this.check(/* @__PURE__ */ fs(xl,e))},duration(e){return this.check(/* @__PURE__ */ ps(Sl,e))}});function D(e){return/* @__PURE__ */ Vo(_l,e)}let vl=/*@__PURE__*/ E(`ZodStringFormat`,(e,t)=>{zi.init(e,t),gl.init(e,t)}),yl=/*@__PURE__*/ E(`ZodISODateTime`,(e,t)=>{ia.init(e,t),vl.init(e,t)}),bl=/*@__PURE__*/ E(`ZodISODate`,(e,t)=>{aa.init(e,t),vl.init(e,t)}),xl=/*@__PURE__*/ E(`ZodISOTime`,(e,t)=>{oa.init(e,t),vl.init(e,t)}),Sl=/*@__PURE__*/ E(`ZodISODuration`,(e,t)=>{sa.init(e,t),vl.init(e,t)}),Cl=/*@__PURE__*/ E(`ZodEmail`,(e,t)=>{Hi.init(e,t),vl.init(e,t)}),wl=/*@__PURE__*/ E(`ZodGUID`,(e,t)=>{Bi.init(e,t),vl.init(e,t)}),Tl=/*@__PURE__*/ E(`ZodUUID`,(e,t)=>{Vi.init(e,t),vl.init(e,t)});function El(e){return/* @__PURE__ */ Wo(Tl,e)}let Dl=/*@__PURE__*/ E(`ZodURL`,(e,t)=>{Xi.init(e,t),vl.init(e,t)});function Ol(e){return/* @__PURE__ */ Jo(Dl,e)}let kl=/*@__PURE__*/ E(`ZodEmoji`,(e,t)=>{Zi.init(e,t),vl.init(e,t)}),Al=/*@__PURE__*/ E(`ZodNanoID`,(e,t)=>{Qi.init(e,t),vl.init(e,t)}),jl=/*@__PURE__*/ E(`ZodCUID`,(e,t)=>{$i.init(e,t),vl.init(e,t)}),Ml=/*@__PURE__*/ E(`ZodCUID2`,(e,t)=>{ea.init(e,t),vl.init(e,t)}),Nl=/*@__PURE__*/ E(`ZodULID`,(e,t)=>{ta.init(e,t),vl.init(e,t)}),Pl=/*@__PURE__*/ E(`ZodXID`,(e,t)=>{na.init(e,t),vl.init(e,t)}),Fl=/*@__PURE__*/ E(`ZodKSUID`,(e,t)=>{ra.init(e,t),vl.init(e,t)}),Il=/*@__PURE__*/ E(`ZodIPv4`,(e,t)=>{ca.init(e,t),vl.init(e,t)}),Ll=/*@__PURE__*/ E(`ZodIPv6`,(e,t)=>{da.init(e,t),vl.init(e,t)}),Rl=/*@__PURE__*/ E(`ZodCIDRv4`,(e,t)=>{fa.init(e,t),vl.init(e,t)}),zl=/*@__PURE__*/ E(`ZodCIDRv6`,(e,t)=>{ma.init(e,t),vl.init(e,t)}),Bl=/*@__PURE__*/ E(`ZodBase64`,(e,t)=>{_a.init(e,t),vl.init(e,t)}),Vl=/*@__PURE__*/ E(`ZodBase64URL`,(e,t)=>{ba.init(e,t),vl.init(e,t)}),Hl=/*@__PURE__*/ E(`ZodE164`,(e,t)=>{xa.init(e,t),vl.init(e,t)}),Ul=/*@__PURE__*/ E(`ZodJWT`,(e,t)=>{Ca.init(e,t),vl.init(e,t)}),Wl=/*@__PURE__*/ E(`ZodNumber`,(e,t)=>{wa.init(e,t),hl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Cc(e,t,n,r),e.isFinite=!0},/*@__PURE__*/ Un({minValue:e=>{let{minimum:t,exclusiveMinimum:n}=vc(e);return Math.max(t??-1/0,n??-1/0)},maxValue:e=>{let{maximum:t,exclusiveMaximum:n}=vc(e);return Math.min(t??1/0,n??1/0)},isInt:e=>{let{isInt:t,multipleOf:n}=vc(e);return!!t||!!n?.some(Number.isSafeInteger)},format:e=>vc(e).format??null},{gt(e,t){return this.check(/* @__PURE__ */ Ss(e,t))},gte(e,t){return this.check(/* @__PURE__ */ Cs(e,t))},min(e,t){return this.check(/* @__PURE__ */ Cs(e,t))},lt(e,t){return this.check(/* @__PURE__ */ bs(e,t))},lte(e,t){return this.check(/* @__PURE__ */ xs(e,t))},max(e,t){return this.check(/* @__PURE__ */ xs(e,t))},int(e){return this.check(Kl(e))},safe(e){return this.check(Kl(e))},positive(e){return this.check(/* @__PURE__ */ Ss(0,e))},nonnegative(e){return this.check(/* @__PURE__ */ Cs(0,e))},negative(e){return this.check(/* @__PURE__ */ bs(0,e))},nonpositive(e){return this.check(/* @__PURE__ */ xs(0,e))},multipleOf(e,t){return this.check(/* @__PURE__ */ ws(e,t))},step(e,t){return this.check(/* @__PURE__ */ ws(e,t))},finite(){return this}}));function O(e){return/* @__PURE__ */ ms(Wl,e)}let Gl=/*@__PURE__*/ E(`ZodNumberFormat`,(e,t)=>{Ta.init(e,t),Wl.init(e,t)});function Kl(e){return/* @__PURE__ */ hs(Gl,e)}let ql=/*@__PURE__*/ E(`ZodBoolean`,(e,t)=>{Ea.init(e,t),hl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>wc(e,t,n,r)});function k(e){return/* @__PURE__ */ gs(ql,e)}let Jl=/*@__PURE__*/ E(`ZodNull`,(e,t)=>{Da.init(e,t),hl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Tc(e,t,n,r)});function Yl(e){return/* @__PURE__ */ _s(Jl,e)}let Xl=/*@__PURE__*/ E(`ZodUnknown`,(e,t)=>{Oa.init(e,t),hl.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function Zl(){return/* @__PURE__ */ vs(Xl)}let Ql=/*@__PURE__*/ E(`ZodNever`,(e,t)=>{ka.init(e,t),hl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ec(e,t,n,r)});function $l(e){return/* @__PURE__ */ ys(Ql,e)}let eu=/*@__PURE__*/ E(`ZodArray`,(e,t)=>{ml(),Na.init(e,t),hl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>jc(e,t,n,r),e.element=t.element},{min(e,t){return this.check(/* @__PURE__ */ Es(e,t))},nonempty(e){return this.check(/* @__PURE__ */ Es(1,e))},max(e,t){return this.check(/* @__PURE__ */ Ts(e,t))},length(e,t){return this.check(/* @__PURE__ */ Ds(e,t))},unwrap(){return this.element}});function A(e,t){return/* @__PURE__ */ Bs(eu,e,t)}let tu=/*@__PURE__*/ E(`ZodObject`,(e,t)=>{ml(),za.init(e,t),hl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Nc(e,t,n,r),Yn(e,`shape`,e=>e._zod.def.shape,!1)},{keyof(){return N(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(rn(this._zod.def,{catchall:e}))},passthrough(){return this.clone(rn(this._zod.def,{catchall:Zl()}))},loose(){return this.clone(rn(this._zod.def,{catchall:Zl()}))},strict(){return this.clone(rn(this._zod.def,{catchall:$l()}))},strip(){return this.clone(rn(this._zod.def,{catchall:void 0}))},extend(e){return Sn(this,e)},safeExtend(e){return wn(this,e)},merge(e){return Tn(this,e)},pick(e){return yn(this,e)},omit(e){return xn(this,e)},partial(...e){return En(gu,this,e[0])},exactPartial(...e){return En(vu,this,e[0],`exactPartial`)},required(...e){return Dn(Eu,this,e[0])}});function j(e,t){let n={type:`object`,shape:e??{},...w(t)};return new tu(n)}function M(e,t){return new tu({type:`object`,shape:e,catchall:$l(),...w(t)})}let nu=/*@__PURE__*/ E(`ZodUnion`,(e,t)=>{Va.init(e,t),hl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Pc(e,t,n,r),e.options=t.options});function ru(e,t){return new nu({type:`union`,options:e,...w(t)})}let iu=/*@__PURE__*/ E(`ZodDiscriminatedUnion`,(e,t)=>{nu.init(e,t),Ua.init(e,t)});function au(e,t,n){return new iu({type:`union`,options:t,discriminator:e,...w(n)})}let ou=/*@__PURE__*/ E(`ZodIntersection`,(e,t)=>{Wa.init(e,t),hl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Fc(e,t,n,r)});function su(e,t){return new ou({type:`intersection`,left:e,right:t})}let cu=/*@__PURE__*/ E(`ZodTuple`,(e,t)=>{ml(),qa.init(e,t),hl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ic(e,t,n,r)},{rest(e){return this.clone({...this._zod.def,rest:e})},partial(){let e=this._zod.def;if(e.checks?.length)throw Error(`.partial() cannot be used on tuple schemas containing refinements`);return this.clone({...e,items:e.items.map(e=>new gu({type:`optional`,innerType:e}))})}});function lu(e,t,n){let r=t instanceof Pi;return new cu({type:`tuple`,items:e,rest:r?t:null,...w(r?n:t)})}let uu=/*@__PURE__*/ E(`ZodRecord`,(e,t)=>{ml(),Za.init(e,t),hl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Bc(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType});function du(e,t,n){return!t||!t._zod?new uu({type:`record`,keyType:D(),valueType:e,...w(t)}):new uu({type:`record`,keyType:e,valueType:t,...w(n)})}let fu=/*@__PURE__*/ E(`ZodEnum`,(e,t)=>{Qa.init(e,t),hl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Dc(e,t,n,r),e.enum=t.entries,e.options=[...e._zod.values];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 fu({...t,checks:[],...w(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 fu({...t,checks:[],...w(r),entries:i})}});function N(e,t){let n=Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e;return new fu({type:`enum`,entries:n,...w(t)})}let pu=/*@__PURE__*/ E(`ZodLiteral`,(e,t)=>{$a.init(e,t),hl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Oc(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 P(e,t){return new pu({type:`literal`,values:Array.isArray(e)?e:[e],...w(t)})}let mu=/*@__PURE__*/ E(`ZodTransform`,(e,t)=>{ml(),eo.init(e,t),hl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ac(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new rr(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(zn(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,`input`in t||(t.input=n.value),t.inst??=e,n.issues.push(zn(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n)):(n.value=i,n)}});function hu(e){return new mu({type:`transform`,transform:e})}let gu=/*@__PURE__*/ E(`ZodOptional`,(e,t)=>{no.init(e,t),hl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Xc(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function _u(e){return new gu({type:`optional`,innerType:e})}let vu=/*@__PURE__*/ E(`ZodExactOptional`,(e,t)=>{ro.init(e,t),hl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Xc(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function yu(e){return new vu({type:`optional`,innerType:e})}let bu=/*@__PURE__*/ E(`ZodNullable`,(e,t)=>{io.init(e,t),hl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Vc(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function xu(e){return new bu({type:`nullable`,innerType:e})}let Su=/*@__PURE__*/ E(`ZodDefault`,(e,t)=>{ao.init(e,t),hl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Gc(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Cu(e,t){return new Su({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():dn(t)}})}let wu=/*@__PURE__*/ E(`ZodPrefault`,(e,t)=>{so.init(e,t),hl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Kc(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Tu(e,t){return new wu({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():dn(t)}})}let Eu=/*@__PURE__*/ E(`ZodNonOptional`,(e,t)=>{co.init(e,t),hl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Hc(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Du(e,t){return new Eu({type:`nonoptional`,innerType:e,...w(t)})}let Ou=/*@__PURE__*/ E(`ZodCatch`,(e,t)=>{fo.init(e,t),hl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>qc(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function ku(e,t){return new Ou({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:Xn(t)})}let Au=/*@__PURE__*/ E(`ZodPipe`,(e,t)=>{po.init(e,t),hl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Jc(e,t,n,r),e.in=t.in,e.out=t.out});function ju(e,t){return new Au({type:`pipe`,in:e,out:t})}let Mu=/*@__PURE__*/ E(`ZodReadonly`,(e,t)=>{ho.init(e,t),hl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Yc(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Nu(e){return new Mu({type:`readonly`,innerType:e})}let Pu=/*@__PURE__*/ E(`ZodLazy`,(e,t)=>{_o.init(e,t),hl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Zc(e,t,n,r),e.unwrap=()=>e._zod.def.getter()});function Fu(e){return new Pu({type:`lazy`,getter:e})}let Iu=/*@__PURE__*/ E(`ZodCustom`,(e,t)=>{vo.init(e,t),hl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>kc(e,t,n,r)});function Lu(e,t){return/* @__PURE__ */ Vs(Iu,e??(()=>!0),t)}function Ru(e,t={}){return/* @__PURE__ */ Hs(Iu,e,t)}function zu(e,t){return/* @__PURE__ */ Us(e,t)}function Bu(e){return/* @__PURE__ */ us(yl,e)}let Vu=j({source:D(),ref:D(),offset:O().int().nonnegative(),length:O().int().positive(),label:D(),appearance:N([`session`,`file`,`folder`,`skill`]).optional(),clipboardText:D(),invalid:k().optional()}),Hu=j({text:D(),references:A(Vu)}).refine(e=>{let t=0;for(let n of e.references)if(n.offset<t||n.length!==n.clipboardText.length||(t=n.offset+n.length,t>e.text.length||e.text.slice(n.offset,t)!==n.clipboardText))return!1;return!0},`Draft references must identify ordered, non-overlapping text spans`);function Uu(e){return typeof e==`string`?{text:e,references:[]}:{text:e.text,references:e.references.map(Ku)}}function Wu(e){if(typeof e==`string`)return Uu(e);let t=Hu.safeParse(e);if(t.success)return{text:t.data.text,references:t.data.references.map(({appearance:e,invalid:t,...n})=>({...n,...e===void 0?{}:{appearance:e},...t===void 0?{}:{invalid:t}}))}}function Gu(e,t){return{text:e,references:t.map(Ku)}}function Ku(e){return{source:e.source,ref:e.ref,offset:e.offset,length:e.length,label:e.label,clipboardText:e.clipboardText,...e.appearance===void 0?{}:{appearance:e.appearance},...e.invalid===void 0?{}:{invalid:e.invalid}}}let qu=`dsh.conversation`;function Ju(){return(0,f.defineStore)({init:()=>({draft:``,view:null,viewRequest:null}),persist:qu,actions:{setDraft:(e,t)=>{e.draft=t},setView:(e,t)=>{e.view=t},openView:(e,t,n)=>{e.view=t,e.viewRequest={view:t,focus:n}},completeViewRequest:e=>{e.viewRequest=null}}})}function Yu(e){let t={text:``,references:[]};if(typeof localStorage>`u`)return t;try{let n=localStorage.getItem(`${qu}.${e}`);if(n===null)return t;let r=JSON.parse(n);return typeof r!=`object`||!r||!(`draft`in r)?t:Wu(r.draft)??t}catch{return t}}function Xu(e){if(typeof localStorage>`u`)return null;try{let t=localStorage.getItem(`${qu}.${e}`);if(t===null)return null;let n=JSON.parse(t);return typeof n!=`object`||!n||!(`view`in n)?null:typeof n.view==`string`?n.view:null}catch{return null}}function Zu(e,t){let n=e.kind===`directory`?`${e.path}/`:e.path;if(!/[\u0000-\u001f\u007f-\u009f"]/u.test(n))return t||/\s/u.test(n)?e.kind===`directory`?`@"${n}`:`@"${n}"`:`@${n}`}function Qu(e){let t=e.replace(/[/\\]+$/,``),n=Math.max(t.lastIndexOf(`/`),t.lastIndexOf(`\\`));return t.slice(n+1)}function $u(e,t){if(t===void 0||t===``)return e;let n=t.replace(/[/\\]+$/,``);return e.startsWith(`${n}/`)||e.startsWith(`${n}\\`)?e.slice(n.length+1):e}let ed=`conversation`,td=`描述你的任务以生成计划`,nd=`describe your task to generate plan`,rd={"shortcut.newline":`换行`,"shortcut.complementary":`使用互补的 Queue/Steer 方式`,"shortcut.slash":`打开命令菜单`,"shortcut.mention":`打开引用菜单`,"hint.plan":td,"hint.goal":`输入目标,智能体将持续执行`,"hint.goal.active":`当前目标进行中。可输入 edit 修改 / pause 暂停 / resume 继续 / clear 清除`,"placeholder.plan":td,"placeholder.default":`发消息或创建任务, / 调用指令, @ 文件或对话`,"placeholder.unavailable":`会话不可用`,"placeholder.parentOffline":`父会话已离线,无法继续发送;仍可停止当前运行`,"placeholder.hero":`描述你想要构建的内容, / 调用指令, @ 文件或对话`,"placeholder.workspace":`选择一个工作区开始`,"placeholder.preparing":`正在准备对话…`,"placeholder.loadFailed":`会话加载失败,请重试连接或检查远端主机`,"placeholder.loadUnsupported":`远端主机版本不支持加载此会话,请升级远端后再试`,"placeholder.steerQueue":`Cmd/Ctrl+Enter 插话发送全部排队消息`,"newSession.loadingModel":`模型加载中…`,"newSession.loadingHarness":`正在加载 Harness…`,"newSession.createFailedTitle":`无法创建新会话`,"newSession.createFailed.noHarness":`没有可用的 Harness,请检查设置后重试。`,"newSession.createFailed.workspaceRequired":`请先选择一个工作区再开始新会话。`,"newSession.createFailed.generic":`暂时无法创建新会话,请稍后重试。`,"newSession.retry":`重试`,"newSession.uploadUnavailable":`新会话准备完成后才能添加文件`,"input.commands":`添加文件或调用指令`,"input.commandsOnly":`调用指令`,"input.imagesAndCommands":`添加图片或调用指令`,"attachment.unavailable":`当前 Web 连接不支持附件上传。`,"input.file":`文件`,"input.stop":`停止生成`,"input.send":`发送消息`,"input.send.queue":`排队发送`,"input.send.steer":`插话发送`,"attachment.pending":`待发送附件`,"annotation.rail":`已附加的选中文字`,"annotation.remove":`移除批注 {index}`,"annotation.trayCount":`{count} 条批注`,"annotation.clearAll":`清空全部`,"annotation.emptyComment":`仅引用原文 · 点击补充批注`,"annotation.editHint":`点击原地编辑批注 {index}`,"annotation.revealHint":`定位原文 {index}`,"attachment.scrollLeft":`向左滚动附件`,"attachment.scrollRight":`向右滚动附件`,"reference.dropTitle":`松开以引用聊天`,"attachment.dropTitle":`文件或图片拖动到此处即可添加`,"attachment.dropDesc":`图片限制:最多 {count} 张,每张 {size}`,"attachment.dropBlocked":`当前无法添加文件或图片`,"attachment.directoryDesktopOnly":`只有桌面端支持添加文件夹,浏览器里请添加单个文件`,"attachment.pathUnavailable":`无法获取文件夹路径,请重新拖入`,"attachment.pathUnsupported":`路径含有无法引用的字符,请改名后再试`,"image.pending":`待发送图片`,"image.openOriginal":`查看原图`,"image.openOriginalLabel":`{label},点击查看原图`,"image.remove":`移除图片 {name}`,"image.retry":`重试`,"image.original":`原图`,"image.label":`图片`,"image.loadFailed":`图片不可用,点击重试`,"image.previewTooLarge":`图片过大,无法预览(单张最多 50 MiB、6400 万像素)`,"image.loading":`图片加载中…`,"image.preview":`原图预览`,"image.closePreview":`关闭原图预览`,"image.unsupportedType":`仅支持 PNG、JPG、WebP、GIF 格式的图片`,"image.tooMany":`一条消息最多添加 {count} 张图片`,"image.fileTooLarge":`单张图片不能超过 {size}`,"image.totalTooLarge":`图片总大小超过 {size},请移除部分图片`,"image.tooManyPixels":`图片分辨率过大,请压缩后重试`,"image.modelUnsupported":`当前模型不支持图片,请切换支持图片的模型`,"image.sendFailed":`图片发送失败({reason}),请重新添加图片后再试`,"file.unavailable":`已上传文件不可用或被修改,请重新选择`,"file.pending":`待发送文件`,"file.remove":`移除文件 {name}`,"file.uploading":`上传中…`,"file.uploadingPercent":`上传中 {percent}%`,"file.uploadFailed":`上传失败,点击重试`,"file.retry":`重试上传 {name}`,"file.retryOrRemove":`请先重试或移除上传失败的附件`,"file.sessionUnavailable":`会话不可用,无法上传文件`,"file.notStaged":`文件尚未上传成功,请重新添加后再试`,"file.label":`文件`,"context.aria":`上下文已用 {percent}`,"context.used":`上下文已用`,"context.system":`系统提示词`,"context.tools":`工具定义`,"context.messages":`对话消息`,"settings.enter.title":`繁忙时的发送行为`,"settings.enter.description":`智能体运行时 Enter 键和发送按钮的行为;Cmd/Ctrl+Enter 使用另一行为`,"settings.enter.queue":`排队发送`,"settings.enter.steer":`插话发送`,"hero.headline":`今天想做点什么?`,"hero.preview":`Web`,"hero.previewDesktop":`CH Desktop`,"hero.chooseWorkspace":`选择工作区`,"hero.noWorkspace":`不选择工作区`,"session.hierarchy":`会话层级`,"todo.title":`任务`,"todo.progress.done":`{done} 已完成`,"todo.progress.active":`{active} 进行中`,"todo.progress.pending":`{pending} 待处理`,"todo.status.completed":`已完成`,"todo.status.inProgress":`进行中`,"todo.status.pending":`待处理`,"todo.rowTitle":`更新任务清单`,"tool.title.createGoal":`创建目标`,"tool.title.getGoal":`查看目标`,"tool.title.updateGoal":`更新目标`,"tool.preparing.content":`{kilobytes}KB`,"tool.title.createSchedule":`创建定时任务`,"tool.title.listSchedules":`查看定时任务`,"tool.title.deleteSchedule":`删除定时任务`,"tool.title.updateSchedule":`修改定时任务`,"detail.state":`状态`,"detail.todo.completed":`已完成`,"detail.todo.in_progress":`进行中`,"detail.todo.pending":`待处理`,"detail.todo.empty":`任务清单为空`,"todo.diff.initial":`首次记录`,"todo.diff.compare":`与上次清单相比`,"todo.diff.unavailable":`旧清单不可用`,"todo.diff.noChanges":`清单没有变化`,"todo.diff.added":`新增 {count}`,"todo.diff.updated":`更新 {count}`,"todo.diff.removed":`移除 {count}`,"todo.diff.unchanged":`{count} 项未变化`,"todo.diff.addedItem":`新增`,"todo.diff.updatedItem":`状态变化`,"todo.diff.movedItem":`顺序调整`,"todo.diff.removedItem":`移除`,"detail.goal.empty":`没有目标`,"detail.goal.active":`进行中`,"detail.goal.disarmed":`等待继续`,"detail.goal.paused":`已暂停`,"detail.goal.blocked":`受阻`,"detail.goal.complete":`已完成`,"detail.goal.rounds":`执行轮次`,"detail.goal.reason":`受阻原因`,"detail.days":`{count} 天`,"detail.hours":`{count} 小时`,"detail.minutes":`{count} 分钟`,"detail.seconds":`{count} 秒`,"detail.schedule.once":`单次`,"detail.schedule.every":`每 {interval}`,"detail.schedule.when":`计划时间`,"detail.schedule.frequency":`重复`,"detail.schedule.scheduled":`等待触发`,"detail.schedule.overdue":`已到期,等待会话恢复`,"detail.schedule.empty":`没有定时任务`,"detail.schedule.deleted":`已删除`,"detail.schedule.count":`{count} 个定时任务`,"detail.schedule.daily":`每天 {time}({zone})`,"detail.schedule.weekly":`每周 {days} {time}({zone})`,"detail.schedule.cron":`Cron {expression}({zone})`,"detail.weekday.1":`周一`,"detail.weekday.2":`周二`,"detail.weekday.3":`周三`,"detail.weekday.4":`周四`,"detail.weekday.5":`周五`,"detail.weekday.6":`周六`,"detail.weekday.7":`周日`,"detail.weekday.join":`、`,"tool.title.inspectProviders":`检查提供方`,"tool.title.queryRuntime":`查询运行时`,"tool.title.inspectPlugins":`检查动态插件`,"tool.title.workflow":`运行工作流`,"tool.title.ralph":`运行循环工作流`,"tool.title.readEvent":`读取事件`,"tool.title.searchEvents":`搜索事件`,"tool.title.traceEvent":`追踪事件`,"tool.title.searchSessions":`搜索会话`,"tool.title.traceSession":`追踪会话`,"tool.title.listModels":`查看可用模型`,"tool.title.subagent":`创建子智能体`,"tool.title.listAgents":`查看子智能体`,"tool.title.sendMessage":`发送消息`,"tool.title.interruptAgent":`中断智能体`,"tool.title.listJobs":`查看后台任务`,"tool.title.readJob":`读取任务输出`,"tool.title.killJob":`取消后台任务`,"tool.title.openTerminal":`创建终端`,"tool.title.readTerminal":`读取终端`,"tool.title.listTerminals":`查看终端`,"tool.title.signalTerminal":`发送终端信号`,"tool.title.closeTerminal":`关闭终端`,"tool.title.lsp":`查询代码符号`,"tool.title.findDefinition":`查找定义`,"tool.title.findReferences":`查找引用`,"tool.title.findImplementation":`查找实现`,"tool.title.hoverSymbol":`查看符号信息`,"tool.title.spawnTeammate":`创建队友`,"tool.title.createTeamTask":`创建团队任务`,"tool.title.getTeamTask":`读取团队任务`,"tool.title.updateTeamTask":`更新团队任务`,"tool.title.listTeamTasks":`查看团队任务`,"tool.title.waitAgent":`等待子智能体`,"detail.recordedResult":`调用结果`,"detail.empty":`暂无结果`,"detail.none":`无`,"detail.yes":`是`,"detail.no":`否`,"detail.moreInInspect":`另有 {count} 项,可在「查看」中读取`,"detail.status.running":`运行中`,"detail.status.idle":`空闲`,"detail.status.ready":`就绪`,"detail.status.inactive":`未运行`,"detail.status.provisioning":`准备中`,"detail.status.failed":`失败`,"detail.status.completed":`已完成`,"detail.status.deleted":`已删除`,"detail.status.killed":`已取消`,"detail.status.accepted":`已接收`,"detail.status.queued":`已入队`,"detail.status.exited":`已退出`,"detail.field.id":`ID`,"detail.field.revision":`版本`,"detail.field.platform":`平台`,"detail.field.provider":`提供方`,"detail.field.model":`模型`,"detail.field.role":`角色`,"detail.field.context":`上下文`,"detail.field.owner":`负责人`,"detail.field.ready":`可开始`,"detail.field.dependencies":`前置任务`,"detail.field.writeScopes":`文件范围`,"detail.field.warnings":`提示`,"detail.field.diagnostics":`诊断`,"detail.field.methods":`方法`,"detail.field.inputSchema":`输入 Schema`,"detail.field.outputSchema":`输出 Schema`,"detail.field.currentPackage":`当前包`,"detail.field.nextPackage":`待运行的包`,"detail.field.latestRun":`最近运行`,"detail.field.packages":`版本包`,"detail.field.registrations":`注册项`,"detail.field.props":`属性`,"detail.field.data":`数据`,"detail.field.source":`来源`,"detail.field.content":`内容`,"detail.field.message":`消息`,"detail.field.messageId":`消息 ID`,"detail.field.root":`根节点`,"detail.field.pid":`进程 ID`,"detail.field.type":`类型`,"detail.field.time":`时间`,"detail.field.seq":`事件序号`,"detail.field.turn":`轮次`,"detail.field.step":`步骤`,"detail.field.callId":`调用 ID`,"detail.field.agents":`启动智能体数`,"detail.field.result":`结果`,"detail.field.parent":`父级`,"detail.field.depth":`层级`,"detail.field.exitCode":`退出码`,"detail.field.signal":`信号`,"detail.field.previousStatus":`中断前状态`,"detail.field.agent":`智能体 ID`,"detail.field.job":`任务 ID`,"detail.field.task":`任务内容`,"detail.field.processGroup":`进程组`,"detail.field.availability":`可用状态`,"detail.field.bestMatch":`最相关事件`,"detail.field.target":`目标事件`,"detail.field.surface":`记录状态`,"detail.agents.count":`{count} 个智能体`,"detail.jobs.count":`{count} 个后台任务`,"detail.terminals.count":`{count} 个终端`,"detail.tasks.count":`{count} 个团队任务`,"detail.tasks.nextPage":`后面还有任务;下一页位置为 {cursor}`,"detail.locations.count":`{count} 个位置`,"detail.location":`第 {line} 行,第 {column} 列`,"detail.receipt.delivered":`消息已送达`,"detail.receipt.interrupt":`已请求中断`,"detail.receipt.started":`已启动`,"detail.receipt.cancel":`已请求取消`,"detail.receipt.alreadyFinished":`任务已结束`,"detail.receipt.signal":`信号已发送`,"detail.receipt.closed":`已关闭`,"detail.receipt.closing":`关闭中`,"detail.wait.noProgress":`没有正在运行的子智能体`,"detail.wait.title":`子智能体状态`,"detail.wait.timeout":`等待超时`,"detail.wait.changed":`检测到变化`,"detail.agent.reply":`智能体回复`,"detail.models.title":`可用模型`,"detail.output.lines":`第 {begin}–{end} 行,共 {total} 行`,"detail.output.truncated":`输出已截断`,"detail.providers.count":`{count} 个检查提供方`,"detail.plugins.count":`{count} 个动态插件`,"detail.workflow.script":`工作流脚本`,"detail.ralph.reportedComplete":`智能体报告完成`,"detail.ralph.reportedBlocker":`智能体报告受阻`,"detail.ralph.limit":`已达到轮次上限`,"detail.report.nextSteps":`待完成事项`,"detail.trace.replacedBy":`被替换为`,"detail.trace.replacementChain":`替换链`,"detail.trace.replaces":`替换的事件`,"detail.trace.sources":`引用来源`,"detail.trace.derived":`派生事件`,"detail.trace.ancestors":`祖先会话`,"detail.trace.descendants":`后代会话`,"detail.matches.count":`{count} 条匹配`,"detail.matches.capped":`已达到结果上限,可缩小搜索范围`,"detail.event.neighbors":`前后事件`,"todo.completed":`{done}/{total} 已完成`,"command.attachmentsUnsupported":`/{command} 不接受附件,请先移除附件`,"ask.rowTitle":`提问`,"ask.waiting":`等待回答`,"ask.pending":`已继续工作,仍可回答`,"ask.pendingDetail":`等待中的问题仍可在输入框中回答`,"ask.reopen":`回答`,"ask.review":`查看回答`,"ask.closed":`已结束`,"ask.closedDetail":`该问题已结束,结果见下方对话`,"ask.cancelled":`已取消`,"ask.cancelledDetail":`本轮已取消,未提交回答`,"ask.interrupted":`已中断`,"ask.interruptedDetail":`本轮已中断,未提交回答`,"ask.answered":`{answered}/{total} 已回答`,"ask.skipped":`未回答`,"bash.running":`运行中`,"bash.failed":`失败`,"bash.stopped":`已停止`,"tool.output.showFull":`显示完整输出(共 {size} KB)`,"tool.output.loading":`正在加载完整输出…`,"tool.output.retry":`重试加载完整输出`,"tool.output.failed":`加载失败,请重试。`,"tool.output.stale":`工具输出已变化,请刷新会话。`,"row.running":`运行中`,"row.preparing":`正在准备调用`,"row.failed":`失败`,"row.stopped":`已停止`,"row.input":`输入`,"row.output":`输出`,"row.inspect":`查看`,"tool.title.search":`搜索`,"tool.title.read":`读取`,"tool.title.bash":`运行命令`,"tool.title.write":`写入`,"tool.title.edit":`编辑`,"tool.title.filesChanging":`{count} 个文件已更改`,"tool.title.filesEdited":`已编辑 {count} 个文件`,"tool.title.code":`代码`,"tool.title.generic":`工具调用`,"tool.contextCompaction.action":`压缩上下文`,"tool.contextCompaction.running":`正在压缩…`,"tool.contextCompaction.completed":`上下文已压缩`,"tool.title.inspect":`查询 Cordis 环境`,"tool.title.runCordis":`运行 Cordis 插件`,"tool.title.stopCordis":`停止 Cordis 插件`,"tool.title.removeCordis":`移除 Cordis 插件`,"tool.title.pwsh":`运行命令`,"tool.title.readImage":`读取图片`,"tool.title.grep":`搜索文件内容`,"tool.title.glob":`查找文件`,"tool.title.webSearch":`网页搜索`,"tool.title.webFetch":`网页获取`,"tool.autoReviewRejected":`Auto review 已拒绝`,"tool.autoReviewNotExecuted":`工具未执行。原因:{reason}`,"tool.autoReviewReasonFallback":`Auto review 未授权此次操作`,"diff.collapseAria":`收起差异`,"diff.expandAria":`展开其余 {count} 行差异`,"diff.expandRest":`… 其余 {count} 行`,"read.window":`显示 {shown} / {total} 行`,"read.collapseAria":`收起内容`,"read.expandAria":`展开其余 {count} 行`,"read.expandRest":`… 其余 {count} 行`,"search.paths":`{shown} 个路径`,"search.paths.truncated":`显示 {shown} / 共 {total} 个路径`,"search.matches":`{shown} 处匹配 · {files} 个文件`,"search.matches.truncated":`显示 {shown} / 共 {total} 处匹配 · {files} 个文件`,"search.noResults":`无结果`,"search.collapseAria":`收起结果`,"search.expandAria":`展开其余 {count} 行结果`,"search.expandRest":`… 其余 {count} 行`,"web.noResults":`未找到结果`,"web.sourcesTruncated":`来源列表已截断`,"web.http":`HTTP`,"web.contentTruncated":`内容已截断`,"details.running":`运行中…`,"queue.count":`{n} 条排队消息`,"queue.sending":`发送中…`,"queue.image":`排队消息图片`,"queue.file":`排队文件 {name}`,"queue.edit":`编辑排队消息`,"queue.edit.unsupported":`包含暂不支持编辑的内容`,"queue.save":`保存排队消息`,"queue.cancelEdit":`取消编辑`,"queue.remove":`删除排队消息`,"queue.steer":`插话发送`,"queue.steer.unavailable":`仅运行中可插话发送`,"queue.resume":`继续队列`,"queue.paused.interrupted":`队列已因你中断当前任务而暂停。请选择一条继续。`,"queue.paused.unknown":`任务结果未知,队列已暂停且不会自动重试。`,"queue.paused.failed":`上一项未正常完成,队列已暂停。`,"error.sessionInUse":`当前会话已被占用,可能是其他正在运行的 DSH 导致的(如其他 dsh web、桌面端),请退出其他正在运行的 DSH 后重试。`,"error.steerTurnChanged":`你要插话的这一轮已经结束或切换,草稿已保留。`,"error.remoteSteerUnavailable":`当前连接无法确认插话的目标轮次,草稿已保留。`,"queue.editFailed":`编辑失败:这条消息可能已经开始发送。`,"queue.removeFailed":`删除失败:这条消息可能已经开始发送。`,"queue.steerFailed":`插话发送失败,请重试。`,"queue.resumeFailed":`继续队列失败,请重试。`,"queue.remoteActionFailed":`远程队列操作未确认,请先查看队列和会话状态。`,"queue.remoteStartUnconfirmed":`消息已入队,启动尚未确认。请查看队列和会话,勿重发。`,"queue.remoteStale":`暂时无法刷新远程队列。`,"terminal.signal":`信号 {signal}`,"terminal.exitCode":`退出码 {code}`,"terminal.noExitCode":`未正常退出`,"terminal.running":`运行中`,"terminal.failed":`失败`,"terminal.done":`已完成`,"terminal.noOutput":`无输出`,"terminal.collapseAria":`收起输出`,"terminal.expandAria":`展开其余 {n} 行输出`,"terminal.expandRest":`… 其余 {n} 行`,"terminal.sendInput":`(发送输入)`,"terminal.session":`终端 {sessionId}`},id={"shortcut.newline":`New line`,"shortcut.complementary":`Use the complementary Queue / Steer action`,"shortcut.slash":`Open command menu`,"shortcut.mention":`Open reference menu`,"hint.plan":nd,"hint.goal":`describe the objective for a long-running task`,"hint.goal.active":`goal active — edit / pause / resume / clear`,"placeholder.plan":nd,"placeholder.default":`Message or run a task, / commands, @ files or sessions`,"placeholder.unavailable":`Session unavailable`,"placeholder.parentOffline":`Parent session offline; sending is unavailable but you can still stop the run`,"placeholder.hero":`Describe what you want to build, / commands, @ files or sessions`,"placeholder.workspace":`Choose a workspace to start`,"placeholder.preparing":`Preparing conversation…`,"placeholder.loadFailed":`Failed to load session. Retry or check the remote host.`,"placeholder.loadUnsupported":`Remote host version does not support loading this session. Update the remote host and retry.`,"placeholder.steerQueue":`Cmd/Ctrl+Enter steers all queued messages`,"newSession.loadingModel":`Loading models…`,"newSession.loadingHarness":`Loading Harness…`,"newSession.createFailedTitle":`Couldn’t start a new session`,"newSession.createFailed.noHarness":`No Harness is available. Check your settings and try again.`,"newSession.createFailed.workspaceRequired":`Choose a workspace before starting a new session.`,"newSession.createFailed.generic":`Unable to start a new session right now. Please try again.`,"newSession.retry":`Retry`,"newSession.uploadUnavailable":`Wait for the new session to finish loading before adding files`,"input.commands":`Add files or run commands`,"input.commandsOnly":`Run commands`,"input.imagesAndCommands":`Add images or run commands`,"attachment.unavailable":`Attachment uploads are unavailable on this Web connection.`,"input.file":`File`,"input.stop":`Stop generating`,"input.send":`Send message`,"input.send.queue":`Queue message`,"input.send.steer":`Steer message`,"attachment.pending":`Pending attachments`,"annotation.rail":`Selected text attached to this message`,"annotation.remove":`Remove annotation {index}`,"annotation.trayCount":`Comments ({count})`,"annotation.clearAll":`Clear all`,"annotation.emptyComment":`Quote only · click to add a note`,"annotation.editHint":`Edit annotation {index}`,"annotation.revealHint":`Reveal annotation {index} in response`,"attachment.scrollLeft":`Scroll attachments left`,"attachment.scrollRight":`Scroll attachments right`,"reference.dropTitle":`Release to reference chat`,"attachment.dropTitle":`Drag files or images here to add them`,"attachment.dropDesc":`Image limit: up to {count} images, {size} each`,"attachment.dropBlocked":`Files and images cannot be added right now`,"attachment.directoryDesktopOnly":`Folders can only be added in the desktop app; add individual files in the browser`,"attachment.pathUnavailable":`Could not obtain the folder path; drag it in again`,"attachment.pathUnsupported":`The path contains characters a reference cannot carry; rename it and try again`,"image.pending":`Pending images`,"image.openOriginal":`View original`,"image.openOriginalLabel":`{label}, click to view original`,"image.remove":`Remove image {name}`,"image.retry":`Retry`,"image.original":`Original image`,"image.label":`Image`,"image.loadFailed":`Image unavailable; click to retry`,"image.previewTooLarge":`Image too large to preview (maximum 50 MiB and 64 million pixels)`,"image.loading":`Loading image…`,"image.preview":`Original image preview`,"image.closePreview":`Close original image preview`,"image.unsupportedType":`Only PNG, JPG, WebP, and GIF images are supported`,"image.tooMany":`A message can include up to {count} images`,"image.fileTooLarge":`Each image must be smaller than {size}`,"image.totalTooLarge":`Images exceed {size} in total; remove some and try again`,"image.tooManyPixels":`Image resolution is too high; compress it and try again`,"image.modelUnsupported":`The current model does not support images; switch to a model that does`,"image.sendFailed":`Sending images failed ({reason}); re-add them and try again`,"file.unavailable":`The uploaded file is unavailable or changed; select it again`,"file.pending":`Pending files`,"file.remove":`Remove file {name}`,"file.uploading":`Uploading…`,"file.uploadingPercent":`Uploading {percent}%`,"file.uploadFailed":`Upload failed; click to retry`,"file.retry":`Retry uploading {name}`,"file.retryOrRemove":`Retry or remove failed attachments before sending`,"file.sessionUnavailable":`Session unavailable; files cannot be uploaded`,"file.notStaged":`The file has not finished uploading; re-add it and try again`,"file.label":`File`,"context.aria":`{percent} of context used`,"context.used":`of context used`,"context.system":`System prompt`,"context.tools":`Tool definitions`,"context.messages":`Messages`,"settings.enter.title":`Send behavior while busy`,"settings.enter.description":`What Enter and the Send button do while the agent is running; Cmd/Ctrl+Enter uses the other behavior`,"settings.enter.queue":`Queue`,"settings.enter.steer":`Steer`,"hero.headline":`What should we build today?`,"hero.preview":`Web`,"hero.previewDesktop":`CH Desktop`,"hero.chooseWorkspace":`Choose workspace`,"hero.noWorkspace":`No workspace`,"session.hierarchy":`Session hierarchy`,"todo.title":`To-dos`,"todo.progress.done":`{done} completed`,"todo.progress.active":`{active} in progress`,"todo.progress.pending":`{pending} pending`,"todo.status.completed":`Completed`,"todo.status.inProgress":`In progress`,"todo.status.pending":`Pending`,"todo.rowTitle":`Update to-do list`,"tool.title.createGoal":`Create goal`,"tool.title.getGoal":`View goal`,"tool.title.updateGoal":`Update goal`,"tool.preparing.content":`{kilobytes}KB`,"tool.title.createSchedule":`Create reminder`,"tool.title.listSchedules":`List reminders`,"tool.title.deleteSchedule":`Delete reminder`,"tool.title.updateSchedule":`Update reminder`,"detail.state":`Status`,"detail.todo.completed":`Completed`,"detail.todo.in_progress":`In progress`,"detail.todo.pending":`Pending`,"detail.todo.empty":`The to-do list is empty`,"todo.diff.initial":`Initial list`,"todo.diff.compare":`Changes since the previous list`,"todo.diff.unavailable":`Previous list unavailable`,"todo.diff.noChanges":`No changes to the list`,"todo.diff.added":`{count} added`,"todo.diff.updated":`{count} updated`,"todo.diff.removed":`{count} removed`,"todo.diff.unchanged":`{count} unchanged`,"todo.diff.addedItem":`Added`,"todo.diff.updatedItem":`Status changed`,"todo.diff.movedItem":`Reordered`,"todo.diff.removedItem":`Removed`,"detail.goal.empty":`No goal`,"detail.goal.active":`Active`,"detail.goal.disarmed":`Awaiting continuation`,"detail.goal.paused":`Paused`,"detail.goal.blocked":`Blocked`,"detail.goal.complete":`Completed`,"detail.goal.rounds":`Rounds`,"detail.goal.reason":`Blocker`,"detail.days":`{count} d`,"detail.hours":`{count} h`,"detail.minutes":`{count} min`,"detail.seconds":`{count} s`,"detail.schedule.once":`Once`,"detail.schedule.every":`Every {interval}`,"detail.schedule.when":`Scheduled for`,"detail.schedule.frequency":`Repeat`,"detail.schedule.scheduled":`Scheduled`,"detail.schedule.overdue":`Overdue, awaiting session resume`,"detail.schedule.empty":`No reminders`,"detail.schedule.deleted":`Deleted`,"detail.schedule.count":`{count} reminders`,"detail.schedule.daily":`Every day at {time} ({zone})`,"detail.schedule.weekly":`Weekly on {days} at {time} ({zone})`,"detail.schedule.cron":`Cron {expression} ({zone})`,"detail.weekday.1":`Mon`,"detail.weekday.2":`Tue`,"detail.weekday.3":`Wed`,"detail.weekday.4":`Thu`,"detail.weekday.5":`Fri`,"detail.weekday.6":`Sat`,"detail.weekday.7":`Sun`,"detail.weekday.join":`, `,"tool.title.inspectProviders":`Inspect providers`,"tool.title.queryRuntime":`Query runtime`,"tool.title.inspectPlugins":`Inspect plugins`,"tool.title.workflow":`Run workflow`,"tool.title.ralph":`Run ralph loop`,"tool.title.readEvent":`Read event`,"tool.title.searchEvents":`Search events`,"tool.title.traceEvent":`Trace event`,"tool.title.searchSessions":`Search sessions`,"tool.title.traceSession":`Trace session`,"tool.title.listModels":`List models`,"tool.title.subagent":`Create subagent`,"tool.title.listAgents":`List subagents`,"tool.title.sendMessage":`Send message`,"tool.title.interruptAgent":`Interrupt agent`,"tool.title.listJobs":`List background jobs`,"tool.title.readJob":`Read job output`,"tool.title.killJob":`Cancel background job`,"tool.title.openTerminal":`Open terminal`,"tool.title.readTerminal":`Read terminal`,"tool.title.listTerminals":`List terminals`,"tool.title.signalTerminal":`Signal terminal`,"tool.title.closeTerminal":`Close terminal`,"tool.title.lsp":`Query code symbols`,"tool.title.findDefinition":`Find definition`,"tool.title.findReferences":`Find references`,"tool.title.findImplementation":`Find implementation`,"tool.title.hoverSymbol":`Inspect symbol`,"tool.title.spawnTeammate":`Create teammate`,"tool.title.createTeamTask":`Create team task`,"tool.title.getTeamTask":`Read team task`,"tool.title.updateTeamTask":`Update team task`,"tool.title.listTeamTasks":`List team tasks`,"tool.title.waitAgent":`Wait for subagent`,"detail.recordedResult":`Recorded result`,"detail.empty":`No results`,"detail.none":`None`,"detail.yes":`Yes`,"detail.no":`No`,"detail.moreInInspect":`{count} more items available in Inspect`,"detail.status.running":`Running`,"detail.status.idle":`Idle`,"detail.status.ready":`Ready`,"detail.status.inactive":`Inactive`,"detail.status.provisioning":`Provisioning`,"detail.status.failed":`Failed`,"detail.status.completed":`Completed`,"detail.status.deleted":`Deleted`,"detail.status.killed":`Cancelled`,"detail.status.accepted":`Accepted`,"detail.status.queued":`Queued`,"detail.status.exited":`Exited`,"detail.field.id":`ID`,"detail.field.revision":`Revision`,"detail.field.platform":`Platform`,"detail.field.provider":`Provider`,"detail.field.model":`Model`,"detail.field.role":`Role`,"detail.field.context":`Context`,"detail.field.owner":`Owner`,"detail.field.ready":`Ready`,"detail.field.dependencies":`Dependencies`,"detail.field.writeScopes":`Write scopes`,"detail.field.warnings":`Warnings`,"detail.field.diagnostics":`Diagnostics`,"detail.field.methods":`Methods`,"detail.field.inputSchema":`Input schema`,"detail.field.outputSchema":`Output schema`,"detail.field.currentPackage":`Current package`,"detail.field.nextPackage":`Next package`,"detail.field.latestRun":`Latest run`,"detail.field.packages":`Packages`,"detail.field.registrations":`Registrations`,"detail.field.props":`Props`,"detail.field.data":`Data`,"detail.field.source":`Source`,"detail.field.content":`Content`,"detail.field.message":`Message`,"detail.field.messageId":`Message ID`,"detail.field.root":`Root`,"detail.field.pid":`Process ID`,"detail.field.type":`Type`,"detail.field.time":`Time`,"detail.field.seq":`Event sequence`,"detail.field.turn":`Turn`,"detail.field.step":`Step`,"detail.field.callId":`Call ID`,"detail.field.agents":`Agents started`,"detail.field.result":`Result`,"detail.field.parent":`Parent`,"detail.field.depth":`Depth`,"detail.field.exitCode":`Exit code`,"detail.field.signal":`Signal`,"detail.field.previousStatus":`Previous status`,"detail.field.agent":`Agent ID`,"detail.field.job":`Job ID`,"detail.field.task":`Task`,"detail.field.processGroup":`Process group`,"detail.field.availability":`Availability`,"detail.field.bestMatch":`Best match`,"detail.field.target":`Target event`,"detail.field.surface":`Record status`,"detail.agents.count":`{count} agents`,"detail.jobs.count":`{count} background jobs`,"detail.terminals.count":`{count} terminals`,"detail.tasks.count":`{count} team tasks`,"detail.tasks.nextPage":`More tasks available; next cursor is {cursor}`,"detail.locations.count":`{count} locations`,"detail.location":`Line {line}, column {column}`,"detail.receipt.delivered":`Message delivered`,"detail.receipt.interrupt":`Interrupt requested`,"detail.receipt.started":`Started`,"detail.receipt.cancel":`Cancellation requested`,"detail.receipt.alreadyFinished":`Already finished`,"detail.receipt.signal":`Signal delivered`,"detail.receipt.closed":`Closed`,"detail.receipt.closing":`Closing`,"detail.wait.noProgress":`No active subagents`,"detail.wait.title":`Subagent activity`,"detail.wait.timeout":`Wait timed out`,"detail.wait.changed":`Change detected`,"detail.agent.reply":`Agent response`,"detail.models.title":`Available models`,"detail.output.lines":`Lines {begin}–{end} of {total}`,"detail.output.truncated":`Output truncated`,"detail.providers.count":`{count} inspect providers`,"detail.plugins.count":`{count} dynamic plugins`,"detail.workflow.script":`Workflow script`,"detail.ralph.reportedComplete":`Worker reported completion`,"detail.ralph.reportedBlocker":`Worker reported a blocker`,"detail.ralph.limit":`Round limit reached`,"detail.report.nextSteps":`Remaining work`,"detail.trace.replacedBy":`Replaced by`,"detail.trace.replacementChain":`Replacement chain`,"detail.trace.replaces":`Replaced events`,"detail.trace.sources":`Source events`,"detail.trace.derived":`Derived events`,"detail.trace.ancestors":`Ancestor sessions`,"detail.trace.descendants":`Descendant sessions`,"detail.matches.count":`{count} matches`,"detail.matches.capped":`Result limit reached; narrow the search for more`,"detail.event.neighbors":`Surrounding events`,"todo.completed":`{done}/{total} completed`,"command.attachmentsUnsupported":`/{command} does not accept attachments; remove them first`,"ask.rowTitle":`Ask question`,"ask.waiting":`waiting`,"ask.pending":`continued; answer still available`,"ask.pendingDetail":`These pending questions remain answerable from the composer.`,"ask.reopen":`Answer`,"ask.review":`View answers`,"ask.closed":`closed`,"ask.closedDetail":`This question is closed; its outcome is in the conversation below.`,"ask.cancelled":`cancelled`,"ask.cancelledDetail":`This question set was cancelled before answers were submitted.`,"ask.interrupted":`interrupted`,"ask.interruptedDetail":`This question set was interrupted before answers were submitted.`,"ask.answered":`{answered}/{total} answered`,"ask.skipped":`Not answered`,"bash.running":`Running`,"bash.failed":`Failed`,"bash.stopped":`Stopped`,"tool.output.showFull":`Show full output ({size} KB total)`,"tool.output.loading":`Loading full output…`,"tool.output.retry":`Retry loading full output`,"tool.output.failed":`Could not load output. Please retry.`,"tool.output.stale":`Tool output changed. Refresh the conversation.`,"row.running":`Running`,"row.preparing":`Preparing tool call`,"row.failed":`Failed`,"row.stopped":`Stopped`,"row.input":`IN`,"row.output":`OUT`,"row.inspect":`Inspect`,"tool.title.search":`Search`,"tool.title.read":`Read`,"tool.title.bash":`Bash`,"tool.title.write":`Write`,"tool.title.edit":`Edit`,"tool.title.filesChanging":`{count} files changed`,"tool.title.filesEdited":`Edited {count} files`,"tool.title.code":`Code`,"tool.title.generic":`Tool call`,"tool.contextCompaction.action":`Compact context`,"tool.contextCompaction.running":`Compacting context…`,"tool.contextCompaction.completed":`Context compacted`,"tool.title.inspect":`Query Cordis environment`,"tool.title.runCordis":`Run Cordis Plugin`,"tool.title.stopCordis":`Stop Cordis Plugin`,"tool.title.removeCordis":`Remove Cordis Plugin`,"tool.title.pwsh":`Pwsh`,"tool.title.readImage":`Read image`,"tool.title.grep":`Grep`,"tool.title.glob":`Glob`,"tool.title.webSearch":`Search`,"tool.title.webFetch":`Fetch`,"tool.autoReviewRejected":`Rejected by Auto review`,"tool.autoReviewNotExecuted":`Tool was not executed. Reason: {reason}`,"tool.autoReviewReasonFallback":`Auto review did not authorize this action`,"diff.collapseAria":`Collapse diff`,"diff.expandAria":`Expand {count} more diff lines`,"diff.expandRest":`… {count} more lines`,"read.window":`Showing {shown} of {total} lines`,"read.collapseAria":`Collapse content`,"read.expandAria":`Expand {count} more lines`,"read.expandRest":`… {count} more lines`,"search.paths":`{shown} paths`,"search.paths.truncated":`Showing {shown} of {total} paths`,"search.matches":`{shown} matches · {files} files`,"search.matches.truncated":`Showing {shown} of {total} matches · {files} files`,"search.noResults":`No results`,"search.collapseAria":`Collapse results`,"search.expandAria":`Expand {count} more result lines`,"search.expandRest":`… {count} more lines`,"web.noResults":`No results found`,"web.sourcesTruncated":`Source list truncated`,"web.http":`HTTP`,"web.contentTruncated":`Content truncated`,"details.running":`Running…`,"queue.count":`{n} queued messages`,"queue.sending":`Sending…`,"queue.image":`Queued message image`,"queue.file":`Queued file {name}`,"queue.edit":`Edit queued message`,"queue.edit.unsupported":`Contains content that cannot be edited yet`,"queue.save":`Save queued message`,"queue.cancelEdit":`Cancel editing`,"queue.remove":`Remove queued message`,"queue.steer":`Steer queued message`,"queue.steer.unavailable":`Steering is available only while the agent is running`,"queue.resume":`Resume queue`,"queue.paused.interrupted":`Queue paused because you interrupted. Choose a message to resume.`,"queue.paused.unknown":`Outcome unknown. The queue is paused and will not retry automatically.`,"queue.paused.failed":`The previous turn did not finish normally. The queue is paused.`,"error.sessionInUse":`This session is already in use, possibly by another running DSH instance (such as dsh web or the desktop app). Quit other running DSH instances and try again.`,"error.steerTurnChanged":`The turn you tried to steer ended or changed. Your draft was kept.`,"error.remoteSteerUnavailable":`This connection cannot confirm the target turn for steering. Your draft was kept.`,"queue.editFailed":`Edit failed: this message may have already started sending.`,"queue.removeFailed":`Removal failed: this message may have already started sending.`,"queue.steerFailed":`Steering failed. Try again.`,"queue.resumeFailed":`Could not resume the queue. Try again.`,"queue.remoteActionFailed":`Remote queue action was not confirmed. Check the queue and chat.`,"queue.remoteStartUnconfirmed":`Message queued. Its start is unconfirmed. Check the queue and chat. Do not resend.`,"queue.remoteStale":`The remote queue could not be refreshed.`,"terminal.signal":`signal {signal}`,"terminal.exitCode":`exit code {code}`,"terminal.noExitCode":`no exit code`,"terminal.running":`Running`,"terminal.failed":`Failed`,"terminal.done":`Done`,"terminal.noOutput":`No output`,"terminal.collapseAria":`Collapse output`,"terminal.expandAria":`Expand the remaining {n} output lines`,"terminal.expandRest":`… {n} more lines`,"terminal.sendInput":`(send input)`,"terminal.session":`Terminal {sessionId}`},ad=2048;function od(e){return e===`image/jpeg`||e===`image/webp`||e===`image/png`}function sd(e,t){return e===``?``:`${e.replace(/\.[^.]*$/u,``)}${t}`}function cd(e,t,n){if(typeof OffscreenCanvas==`function`&&typeof OffscreenCanvas.prototype.convertToBlob==`function`){let r=new OffscreenCanvas(t,n),i=r.getContext(`2d`);return i===null?(r.width=0,r.height=0,null):(i.drawImage(e,0,0,t,n),r)}if(typeof document>`u`||typeof document.createElement!=`function`)return null;let r=document.createElement(`canvas`);r.width=t,r.height=n;let i=r.getContext(`2d`);return i===null?(r.width=0,r.height=0,null):(i.drawImage(e,0,0,t,n),r)}async function ld(e,t,n){try{if(`convertToBlob`in e&&typeof e.convertToBlob==`function`)return await e.convertToBlob(n===void 0?{type:t}:{type:t,quality:n});let r=e;return await new Promise(e=>r.toBlob(e,t,n))}catch{return null}}async function ud(e){if(!od(e.type))return e;let t,n=null;try{t=await createImageBitmap(e,{imageOrientation:`from-image`});let r=Math.max(t.width,t.height);if(r<=ad&&e.size<=1048576)return e;let i=Math.min(1,ad/r),a=Math.max(1,Math.round(t.width*i)),o=Math.max(1,Math.round(t.height*i));if(n=cd(t,a,o),n===null)return e;if(e.type===`image/png`){let t=await ld(n,`image/webp`,.9);if(t!==null&&t.type===`image/webp`)return t.size===0||t.size>=e.size?e:new File([t],sd(e.name,`.webp`),{type:`image/webp`,lastModified:e.lastModified});if(i<1){let r=t!==null&&t.type===`image/png`?t:await ld(n,`image/png`);if(r!==null&&r.type===`image/png`&&r.size>0&&r.size<e.size)return new File([r],e.name,{type:`image/png`,lastModified:e.lastModified})}return e}let s=await ld(n,`image/jpeg`,.85);return s===null||s.type!==`image/jpeg`||s.size===0||s.size>=e.size?e:new File([s],sd(e.name,`.jpg`),{type:`image/jpeg`,lastModified:e.lastModified})}catch{return e}finally{n!==null&&(n.width=0,n.height=0),t?.close()}}function dd(e){return{kind:`image`,id:yt(),previewUrl:URL.createObjectURL(e),file:e}}function fd(e){if(typeof Image!=`function`)return;let t=new Image,n=()=>{t.onload=null,t.onerror=null,t.src=``};t.onload=()=>{try{e.width=t.naturalWidth,e.height=t.naturalHeight}finally{n()}},t.onerror=()=>{n()};try{t.src=e.previewUrl}catch{n()}}function pd(){return new Promise(e=>{if(typeof requestAnimationFrame==`function`){if(typeof document<`u`&&document.visibilityState===`hidden`){setTimeout(e,0);return}let t=!1,n=()=>{t||(t=!0,clearTimeout(r),setTimeout(e,0))},r=setTimeout(n,100);requestAnimationFrame(n)}else setTimeout(e,0)})}var md=class extends m.Service{input;blocks;fileUploads=(0,f.createSnapshotStore)({});draftAttachments=/* @__PURE__ */ new Map;preparedPhotos=/* @__PURE__ */ new WeakMap;fileUploadOperations=/* @__PURE__ */ new Map;pendingFileUploads=/* @__PURE__ */ new Set;fileUploadQueue=[];uploadSessions=/* @__PURE__ */ new Map;foregroundRetried=/* @__PURE__ */ new Set;activeFileUploads=0;maxConcurrentFileUploads;constructor(e,t){super(e,`conversation`),this.input=t.input,this.blocks=t.blocks,this.maxConcurrentFileUploads=t.maxConcurrentFileUploads,e.effect(()=>{if(typeof document>`u`)return;let e=()=>{if(document.visibilityState===`visible`)for(let[e,t]of this.uploadSessions){let n=this.fileUploads.getSnapshot()[e];n?.status===`error`&&n.transport&&!this.foregroundRetried.has(e)&&(this.foregroundRetried.add(e),this.retryFileUpload(t,e))}};return document.addEventListener(`visibilitychange`,e),()=>document.removeEventListener(`visibilitychange`,e)},`conversation foreground upload retry`),e.effect(()=>async()=>{let e=[...this.fileUploadOperations.values()];for(let t of e)t.controller.abort();await Promise.allSettled([...this.pendingFileUploads]),this.fileUploadOperations.clear(),this.fileUploadQueue.length=0;for(let e of this.draftAttachments.values())e.kind===`image`&&gd(e.previewUrl);this.draftAttachments.clear(),this.uploadSessions.clear(),this.foregroundRetried.clear(),this.fileUploads.set({})},`conversation draft attachments`)}async send(e){let t=await this.scopedSession(`send`).prompt([{type:`text`,text:e}],`queue`);if(!t.ok)throw Error(`conversation.send failed: ${t.error.code}: ${t.error.message}`)}async sendSession(e,t,n,r,i,a){let o=n.length===0?void 0:this.requireSessions().retain(e.sessionId,{source:`controllerOperation`});try{let o=this.resolveDraftAttachments(n);if(o.length!==n.length)throw Error(`conversation.sendSession: one or more draft attachments are no longer available`);this.assertUploadsNotFailed(n);let s=o.map(e=>({upload:{subscribe:this.fileUploads.subscribe,getSnapshot:()=>this.fileUploads.getSnapshot()[e.id]},...e.kind===`image`?{type:`image`,value:{previewUrl:e.previewUrl,...e.file.name===``?{}:{name:e.file.name},...e.width===void 0?{}:{width:e.width},...e.height===void 0?{}:{height:e.height}}}:{type:`file`,value:{attachmentId:e.id,name:`file`in e?e.file.name:e.stored.name,bytes:`file`in e?e.file.size:e.stored.bytes}}})),c=async()=>(await this.serializeDraftAttachments(n)).attachments;if(e.getSnapshot().subagent!==null){let n=[...await c(),...t===``?[]:[{type:`text`,text:t}]];return(await e.prompt(n,r,i)).ok?{kind:`success`}:{kind:`error`}}let l,u=o.length===0?void 0:new Promise(e=>{l=e}),d=e.beginSubmission({mode:r,text:t,attachments:s,onObserved:t=>{this.aliasObservedAttachments(e.sessionId,o,t)},onRetire:t=>{this.settleSubmittedAttachments(e.sessionId,o,t),l?.(t)}});a?.(d.requestId);let f;try{await pd(),f=[...await c(),...t===``?[]:[{type:`text`,text:t}]]}catch(e){throw d.abandon(),e}let p=await e.prompt(f,r,i,d.requestId);return!p.ok||u!==void 0&&(await u).reason!==`observed`?{kind:`error`}:p.value.queueStartUnconfirmed?{kind:`success`,text:this.ctx.locale.bind(ed)(`queue.remoteStartUnconfirmed`)}:{kind:`success`}}finally{o?.release()}}createDrafts(e,t){return t.map(t=>{if(hd(t.type)){let n=dd(t);return this.draftAttachments.set(n.id,n),fd(n),this.beginFileUpload(e,n),n}let n={kind:`file`,id:yt(),file:t};return this.draftAttachments.set(n.id,n),this.beginFileUpload(e,n),n})}restoreStagedDrafts(e,t){let n=[],r=[];for(let i of t){let t;if(i.kind===`image`&&i.imageFile!==void 0){let n=dd(i.imageFile);fd(n),t=n,this.ctx.get(`uiConversation`)?.cacheUploadedImage(e,{attachmentId:i.file.attachmentId,blob:i.imageFile,name:i.file.name,bytes:i.file.bytes,...n.width===void 0?{}:{width:n.width},...n.height===void 0?{}:{height:n.height}})}else t={kind:`file`,id:yt(),stored:i.file};this.draftAttachments.set(t.id,t),this.uploadSessions.set(t.id,e),n.push([t.id,{status:`ready`,receiptId:i.receiptId,file:i.file}]),r.push(t)}return n.length>0&&this.fileUploads.update(e=>{for(let[t,r]of n)e[t]=r}),r}retryFileUpload(e,t){let n=this.draftAttachments.get(t);n!==void 0&&(n.kind!==`file`||`file`in n)&&this.fileUploads.getSnapshot()[t]?.status===`error`&&this.beginFileUpload(e,n)}rebindDraftFiles(e,t){for(let n of t){let t=this.draftAttachments.get(n);t!==void 0&&(t.kind===`file`&&!(`file`in t)?(this.uploadSessions.delete(n),this.fileUploads.update(e=>{e[n]={status:`error`,message:this.ctx.locale.bind(ed)(`file.unavailable`),transport:!1}})):this.beginFileUpload(e,t))}}beginFileUpload(e,t){this.uploadSessions.set(t.id,e),this.fileUploadOperations.get(t.id)?.controller.abort();let n=new AbortController;this.fileUploads.update(e=>{e[t.id]={status:`uploading`,loaded:0,total:t.file.size}});let r,i=new Promise(e=>{r=e});this.fileUploadOperations.set(t.id,{controller:n,done:i}),this.pendingFileUploads.add(i),i.then(()=>{this.pendingFileUploads.delete(i)}),this.fileUploadQueue.push({run:async()=>{try{if(n.signal.aborted||this.fileUploadOperations.get(t.id)?.controller!==n)return;let r=t.file;if(t.kind===`image`&&od(r.type)){let e=this.preparedPhotos.get(t);if(e===void 0&&(e=ud(r),this.preparedPhotos.set(t,e)),r=await e,n.signal.aborted||this.fileUploadOperations.get(t.id)?.controller!==n)return;this.fileUploads.update(e=>{t.id in e&&(e[t.id]={status:`uploading`,loaded:0,total:r.size})})}let i=await this.ctx.fileUpload.upload(e,r,r.name===``?void 0:r.name,n.signal,e=>{this.fileUploadOperations.get(t.id)?.controller===n&&this.fileUploads.update(n=>{t.id in n&&(n[t.id]={status:`uploading`,loaded:e.loaded,...e.total===void 0?{}:{total:e.total}})})},t.kind===`image`?r.type:void 0);if(this.fileUploadOperations.get(t.id)?.controller!==n)return;i.ok&&t.kind===`image`&&this.ctx.get(`uiConversation`)?.cacheUploadedImage(e,{attachmentId:i.value.file.attachmentId,blob:r,name:i.value.file.name,bytes:i.value.file.bytes,...t.width===void 0?{}:{width:t.width},...t.height===void 0?{}:{height:t.height}}),this.fileUploads.update(e=>{t.id in e&&(e[t.id]=i.ok?{status:`ready`,receiptId:i.value.receiptId,file:i.value.file}:{status:`error`,message:i.error.message,transport:!1})})}catch(e){if(this.fileUploadOperations.get(t.id)?.controller!==n)return;this.fileUploads.update(n=>{t.id in n&&(n[t.id]={status:`error`,message:e instanceof Error?e.message:String(e),transport:!0})})}finally{this.fileUploadOperations.get(t.id)?.controller===n&&this.fileUploadOperations.delete(t.id)}},settle:r}),this.pumpFileUploads()}pumpFileUploads(){for(;this.activeFileUploads<this.maxConcurrentFileUploads;){let e=this.fileUploadQueue.shift();if(e===void 0)return;this.activeFileUploads+=1,e.run().finally(()=>{--this.activeFileUploads,e.settle(),this.pumpFileUploads()})}}resolveDraftAttachments(e){let t=[];for(let n of e){let e=this.draftAttachments.get(n);e!==void 0&&t.push(e)}return t}async serializeDraftAttachments(e){let t=this.resolveDraftAttachments(e);if(t.length!==e.length)throw Error(`conversation.serializeDraftAttachments: one or more draft attachments are no longer available`);await this.waitForUploads(e);let n=this.fileUploads.getSnapshot();return{attachments:t.map(e=>({type:`file`,receiptId:n[e.id].receiptId}))}}releaseDraftAttachment(e){let t=this.draftAttachments.get(e);if(t===void 0)return;let n=this.uploadSessions.get(e),r=this.fileUploads.getSnapshot()[e],i=this.fileUploadOperations.get(e);this.fileUploadOperations.delete(e),i?.controller.abort(),this.draftAttachments.delete(e),this.uploadSessions.delete(e),this.foregroundRetried.delete(e),t.kind===`image`&&(n!==void 0&&r?.status===`ready`&&this.ctx.get(`uiConversation`)?.clearPendingUploadedImage(n,r.file.attachmentId),gd(t.previewUrl)),this.fileUploads.set(Object.fromEntries(Object.entries(this.fileUploads.getSnapshot()).filter(([t])=>t!==e)))}releaseDraftAttachments(e){for(let t of e)this.releaseDraftAttachment(t.id)}async updateQueue(e,t){let n=await this.scopedSession(`updateQueue`).updateQueue(e,t);if(!n.ok){if(t.kind===`steer`&&(n.error.code===`session/steer-unavailable`||n.error.code===`session/queue-item-not-found`))return;throw Error(`conversation.updateQueue failed: ${n.error.code}: ${n.error.message}`)}}async cancel(){let e=await this.scopedSession(`cancel`).cancel();if(!e.ok)throw Error(`conversation.cancel failed: ${e.error.code}: ${e.error.message}`)}async loadOlder(){await this.scopedSession(`loadOlder`).loadOlder()}scopedSession(e){let t=this.scopeId(e),n=this.requireSessions().binding(t);if(n===void 0)throw Error(`conversation.${e}: session "${t}" resolved no binding`);return n.session}scopeId(e){let t=this.requireSessions().scopeOf(this.ctx);if(t===void 0)throw Error(`conversation.${e} requires a session scope — address one via ctx.sessions.scope(id).conversation`);return t}requireSessions(){let e=this.ctx.get(`sessions`);if(e===void 0)throw Error(`conversation: sessions service unavailable`);return e}aliasObservedAttachments(e,t,n){let r=this.ctx.get(`uiConversation`);if(r===void 0)return;let i=this.fileUploads.getSnapshot(),a=0;for(let o of t){let t=n[a++];if(this.draftAttachments.get(o.id)===void 0||o.kind!==`image`||t===void 0||!(`mediaType`in t))continue;let s=i[o.id],c=s?.status===`ready`?s.file.attachmentId:void 0;c!==void 0&&r.aliasUploadedImage(e,c,t)}}settleSubmittedAttachments(e,t,n){if(n.reason!==`observed`)return;let r=this.ctx.get(`uiConversation`),i=0;for(let a of t){let t=this.draftAttachments.get(a.id),o=n.attachments[i++];if(t===void 0)continue;if(a.kind===`file`){this.releaseDraftAttachment(a.id);continue}let s=this.fileUploads.getSnapshot()[a.id],c=s?.status===`ready`?s.file.attachmentId:void 0;if(this.uploadSessions.delete(a.id),this.foregroundRetried.delete(a.id),this.fileUploads.update(e=>{delete e[a.id]}),this.draftAttachments.delete(a.id),o!==void 0&&`mediaType`in o){if(c!==void 0&&r?.aliasUploadedImage(e,c,o)===!0){gd(a.previewUrl);continue}if(r?.seedImageUrl(e,o,a.previewUrl,a.file.size)===!0)continue}gd(a.previewUrl)}}assertUploadsNotFailed(e){if(e.some(e=>this.fileUploads.getSnapshot()[e]?.status===`error`))throw Error(this.ctx.locale.bind(ed)(`file.retryOrRemove`))}waitForUploads(e){return new Promise((t,n)=>{let r=()=>{let r=this.fileUploads.getSnapshot();e.some(e=>r[e]===void 0||r[e]?.status===`error`)?(i(),n(Error(this.ctx.locale.bind(ed)(`file.retryOrRemove`)))):e.every(e=>r[e]?.status===`ready`)&&(i(),t())},i=this.fileUploads.subscribe(r);r()})}};function hd(e){return e===`image/png`||e===`image/jpeg`||e===`image/webp`||e===`image/gif`}function gd(e){e.startsWith(`blob:`)&&URL.revokeObjectURL(e)}var _d=class{stores=/* @__PURE__ */ new Map;set(e,t){let n=this.storeFor(e);n.getSnapshot()?.reason!==t?.reason&&n.set(t)}storeFor(e){let t=this.stores.get(e);if(t!==void 0)return t;let n=(0,f.createSnapshotStore)(void 0);return this.stores.set(e,n),n}forget(e){this.stores.delete(e)}};function F(e,...t){let n=new URL(`https://lexical.dev/docs/error`),r=new URLSearchParams;r.append(`code`,e);for(let e of t)r.append(`v`,e);throw n.search=r.toString(),Error(`Minified Lexical error #${e}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}function vd(e,...t){let n=new URL(`https://lexical.dev/docs/error`),r=new URLSearchParams;r.append(`code`,e);for(let e of t)r.append(`v`,e);n.search=r.toString(),console.warn(`Minified Lexical warning #${e}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}let yd=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0,bd=yd&&`documentMode`in document?document.documentMode:null,xd=yd&&/Mac|iPod|iPhone|iPad/.test(navigator.platform),Sd=yd&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent),Cd=!(!yd||!(`InputEvent`in window)||bd)&&`getTargetRanges`in new window.InputEvent(`input`),wd=yd&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,Td=yd&&/Android/.test(navigator.userAgent),Ed=yd&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent)&&!Td,Dd=yd&&/^(?=.*Chrome).*/i.test(navigator.userAgent),Od=yd&&Td&&Dd,kd=yd&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&xd&&!Dd,Ad=Ed||wd||kd?`\xA0`:`​`,jd=Sd?`\xA0`:Ad,Md=`֑-߿יִ-﷽ﹰ-ﻼ`,Nd=`A-Za-zÀ-ÖØ-öø-ʸ̀-֐ࠀ-῿‎Ⰰ-﬜︀-﹯﻽-￿`;RegExp(`^[^`+Nd+`]*[`+Md+`]`),RegExp(`^[^`+Md+`]*[`+Nd+`]`);let Pd={bold:1,capitalize:1024,code:16,highlight:128,italic:2,lowercase:256,strikethrough:4,subscript:32,superscript:64,underline:8,uppercase:512},Fd={directionless:1,unmergeable:2},Id={center:2,end:6,justify:4,left:1,right:3,start:5},Ld={2:`center`,6:`end`,4:`justify`,1:`left`,3:`right`,5:`start`},Rd={normal:0,segmented:2,token:1},zd={0:`normal`,2:`segmented`,1:`token`},Bd=`$config`;function Vd(){return oy()._blockCursorElement}function Hd(e){return e!==null&&e.nodeType===1&&e.hasAttribute(`data-lexical-slot`)}var Ud=class e{element;before;after;constructor(e,t,n){this.element=e,this.before=t||null,this.after=n||null}withBefore(t){return new e(this.element,t,this.after)}withAfter(t){return new e(this.element,this.before,t)}withElement(t){return this.element===t?this:new e(t,this.before,this.after)}insertChild(e){let t=this.getInsertionAnchor();return t!==null&&t.parentElement!==this.element&&F(357),this.element.insertBefore(e,t),this}removeChild(e){return e.parentElement!==this.element&&F(358),this.element.removeChild(e),this}replaceChild(e,t){return t.parentElement!==this.element&&F(359),this.element.replaceChild(e,t),this}getFirstChild(){let e=this.getFirstChildAnchor(),t=e?e.nextSibling:this.element.firstChild;return t===this.getInsertionAnchor()?null:t}getFirstChildAnchor(){return this.after}resolveLeafPosition(e,t,n){if(this.element===e)return t===e&&n===0?`before`:`after`;let r=Wd(e,this.element);if(r===null)return`after`;let i=Array.prototype.indexOf.call(e.childNodes,r);if(i<0)return`after`;if(t===e)return n<=i?`before`:`after`;let a=Wd(e,t);if(a===null)return`after`;let o=Array.prototype.indexOf.call(e.childNodes,a);return o>=0&&o<=i?`before`:`after`}getInsertionAnchor(){return this.before}};function Wd(e,t){let n=t;for(;n!==null&&n.parentNode!==e;)n=n.parentNode;return n}var Gd=class e extends Ud{withBefore(t){return new e(this.element,t,this.after)}withAfter(t){return new e(this.element,this.before,t)}withElement(t){return this.element===t?this:new e(t,this.before,this.after)}getInsertionAnchor(){return super.getInsertionAnchor()||this.getManagedLineBreak()}getFirstChildAnchor(){let e=super.getFirstChildAnchor(),t=e?e.nextSibling:this.element.firstChild;for(;Hd(t);)e=t,t=t.nextSibling;let n=e?e.nextSibling:this.element.firstChild;return n!==null&&n===Vd()?n:e}getManagedLineBreak(){return this.element.__lexicalLineBreak||null}setManagedLineBreak(e){if(this.element.__lexicalLastChildKind=e,e===null)this.removeManagedLineBreak();else{let t=e===`decorator`&&(kd||wd||Ed);this.insertManagedLineBreak(t)}}removeManagedLineBreak(){let e=this.getManagedLineBreak();if(e){let t=this.element,n=e.nodeName===`IMG`?e.nextSibling:null;n&&t.removeChild(n),t.removeChild(e),t.__lexicalLineBreak=void 0}}insertManagedLineBreak(e){let t=this.getManagedLineBreak();if(t){if(e===(t.nodeName===`IMG`))return;this.removeManagedLineBreak()}let n=this.element,r=this.before,i=Uv().createElement(`br`);if(i.setAttribute(`data-lexical-managed-linebreak`,`true`),n.insertBefore(i,r),e){let e=Uv().createElement(`img`);e.setAttribute(`data-lexical-managed-linebreak`,`true`),e.style.setProperty(`display`,`inline`,`important`),e.style.setProperty(`border`,`0px`,`important`),e.style.setProperty(`margin`,`0px`,`important`),e.alt=``,n.insertBefore(e,i),n.__lexicalLineBreak=e}else n.__lexicalLineBreak=i}getFirstChildOffset(){let e=this.getFirstChild(),t=this.getInsertionAnchor(),n=0;for(let r=this.element.firstChild;r!==null&&r!==e&&r!==t;r=r.nextSibling)n++;return n}resolveChildIndex(e,t,n,r){if(n===this.element){let t=this.getFirstChildOffset(),n=Vd(),i=this.element.childNodes,a=Math.min(r,i.length),o=0;for(let e=t;e<a;e++)i[e]!==n&&o++;return[e,Math.min(o,e.getChildrenSize())]}let i=Kd(t,n);i.push(r);let a=Kd(t,this.element),o=e.getIndexWithinParent();for(let e=0;e<a.length;e++){let t=i[e],n=a[e];if(t===void 0||t<n)break;if(t>n){o+=1;break}}return[e.getParentOrThrow(),o]}};function Kd(e,t){let n=[],r=t;for(;r!==e&&r!==null;r=r.parentNode){let e=0;for(let t=r.previousSibling;t!==null;t=t.previousSibling)e++;n.push(e)}return r!==e&&F(225),n.reverse()}let qd;try{qd=`0.49.0+prod.esm`}catch{}let Jd=qd??`"<unknown>+source"`;var Yd=class{_front=/* @__PURE__ */ new Set;_back=/* @__PURE__ */ new Set;_cache;get size(){return this._front.size+this._back.size}addBack(e){return delete this._cache,this._front.has(e)||this._back.add(e),this}addFront(e){return delete this._cache,this._back.has(e)||this._front.add(e),this}delete(e){return delete this._cache,this._front.delete(e)||this._back.delete(e)}toArray(){let e=Array.from(this._front).reverse();for(let t of this._back)e.push(t);return e}toReadonlyArray(){return this._cache=this._cache||this.toArray(),this._cache}[Symbol.iterator](){return this.toReadonlyArray()[Symbol.iterator]()}};function Xd(e,t=1e3){return e instanceof Zd?e.clone():e.size<t?new Map(e):new Zd().init(new Map(e),void 0,e.size)}var Zd=class e{_mutable=!1;_old=void 0;_nursery=void 0;_size=0;clone(){return this._mutable=!1,new e().init(this._old,this._nursery,this._size)}init(e,t,n){return this._old=e,this._nursery=t,this._size=n,this}get size(){return this._size}has(e){return this.get(e)!==void 0}getWithTombstone(e){let t=this._nursery&&this._nursery.get(e);return t===void 0?this._old&&this._old.get(e):t}get(e){let t=this.getWithTombstone(e);return t===null?void 0:t}shouldCompact(){return this._nursery!==void 0&&2*this._nursery.size>this._size}getNursery(){return this._mutable&&this._nursery||(this.compact(),this._nursery=new Map(this._nursery),this._mutable=!0),this._nursery}compact(e=!1){if(this._nursery&&this._nursery.size>0&&(e||this.shouldCompact())){let e=new Map(this._old);for(let[t,n]of this._nursery)n===null?e.delete(t):e.set(t,n);this._old=e,this._nursery=void 0}return this._mutable=!1,this}set(e,t){let n=this.getWithTombstone(e);if(n===t)return this;let r=this.getNursery();return n??(this._size++,n===null&&r.delete(e)),r.set(e,t),this}delete(e){let t=this.has(e);return t&&(this.getNursery().set(e,null),this._size--),t}getOrInsert(e,t){let n=this.get(e);return n===void 0?(this.set(e,t),t):n}getOrInsertComputed(e,t){let n=this.get(e);if(n!==void 0)return n;let r=t(e);return this.set(e,r),r}clear(){this._mutable=!1,this._old=void 0,this._nursery=void 0,this._size=0}*keys(){for(let e of this.entries())yield e[0]}*values(){for(let e of this.entries())yield e[1]}*entries(){let e=this._nursery,t=this._old;if(t)for(let n of t){let t=n[0],r=e?e.get(t):void 0;r!==null&&(r!==void 0&&(n[1]=r),yield n)}if(e)for(let n of e)n[1]===null||t&&t.has(n[0])||(yield n)}forEach(e,t){t!==void 0&&(e=e.bind(t));for(let[t,n]of this.entries())e(n,t,this)}get[Symbol.toStringTag](){return`GenMap`}[Symbol.iterator](){return this.entries()}};function Qd(e,t,n,r,i,a){if(U(e)){let o=e.getFirstChild();for(;o!==null;){let e=o.__key;o.__parent===t&&((U(o)||Ny(o)&&o.__slots!==null)&&Qd(o,e,n,r,i,a),n.has(e)||a.delete(e),i.push(e)),o=o.getNextSibling()}}for(let o of Ny(e)&&e.__slots!==null?e.__slots.values():[]){let e=r.get(o);e!==void 0&&Py(e)&&e.__slotHost===t&&((U(e)||Ny(e)&&e.__slots!==null)&&Qd(e,o,n,r,i,a),n.has(o)||a.delete(o),i.push(o))}}let $d=!1,ef=0;function tf(e){ef=e.timeStamp}function nf(e,t,n){let r=e.nodeName===`BR`,i=t.__lexicalLineBreak;return i&&(e===i||r&&e.previousSibling===i)||r&&K_(e,n)!==void 0}function rf(e,t,n){let r=Iv(Tv(n)),i=r&&Kv(r,n._rootElement),a=null,o=null;i!==null&&i.anchorNode===e&&(a=i.anchorOffset,o=i.focusOffset);let s=e.nodeValue;s!==null&&av(t,s,a,o,!1)}function af(e,t,n){if(B(e)){let t=e.anchor.getNode();if(t.is(n)&&e.format!==t.getFormat())return!1}return P_(t)&&n.isAttached()}function of(e,t,n){for(let r=e;r&&!by(r);r=yv(r)){let e=K_(r,t);if(e!==void 0){let t=U_(e,n);if(t)return W(t)||!q(r)?void 0:[r,t]}}}function sf(e,t,n){$d=!0;let r=performance.now()-ef>100;try{Hg(e,()=>{let i=V()||function(e){return e.read(`latest`,()=>{let e=V();return e===null?null:e.clone()})}(e),a=/* @__PURE__ */ new Map,o=e._editorState,s=e._blockCursorElement,c=!1,l=``;for(let n=0;n<t.length;n++){let u=t[n],d=u.type,f=u.target,p=of(f,e,o);if(!p)continue;let[m,h]=p;if(d===`characterData`)r&&z(h)&&P_(f)&&af(i,f,h)&&rf(f,h,e);else if(d===`childList`){c=!0;let t=u.addedNodes;for(let n=0;n<t.length;n++){let r=t[n],i=W_(r),a=r.parentNode;if(!(a==null||r===s||i!==null||nf(r,a,e)||e._slotsUsed&&q(r)&&r.hasAttribute(`data-lexical-slot`)||by(r))){if(Sd){let e=(q(r)?r.innerText:null)||r.nodeValue;e&&(l+=e)}a.removeChild(r)}}let n=u.removedNodes,r=n.length;if(r>0){let t=0;for(let i=0;i<r;i++){let r=n[i];(nf(r,f,e)||s===r)&&(f.appendChild(r),t++)}r!==t&&a.set(m,h)}}}if(a.size>0)for(let[t,n]of a)n.reconcileObservedMutation(t,e);let u=n.takeRecords();if(u.length>0){for(let t=0;t<u.length;t++){let n=u[t],r=n.addedNodes,i=n.target;for(let t=0;t<r.length;t++){let n=r[t],a=n.parentNode;a==null||n.nodeName!==`BR`||nf(n,i,e)||a.removeChild(n)}}n.takeRecords()}i!==null&&(c&&Z_(i),Sd&&_v(e)&&i.insertRawText(l))})}finally{$d=!1}}function cf(e){let t=e._observer;t!==null&&sf(e,t.takeRecords(),t)}function lf(e){(function(e){ef===0&&Tv(e).addEventListener(`textInput`,tf,!0)})(e),e._observer=new MutationObserver((t,n)=>{sf(e,t,n)})}var uf=class{key;parse;unparse;isEqual;defaultValue;resetOnCopyNode;constructor(e,t){this.key=e,this.parse=t.parse.bind(t),this.unparse=(t.unparse||vf).bind(t),this.isEqual=(t.isEqual||Object.is).bind(t),this.defaultValue=this.parse(void 0),this.resetOnCopyNode=t.resetOnCopyNode||!1}};function df(e,t){return new uf(e,t)}function ff(e){let t=/* @__PURE__ */ new Map,n=/* @__PURE__ */ new Set;for(let{ownNodeConfig:r}of Dy(typeof e==`function`?e:e.replace))if(r&&r.stateConfigs)for(let e of r.stateConfigs){let r;`stateConfig`in e?(r=e.stateConfig,e.flat&&n.add(r.key)):r=e,t.set(r.key,r)}return{flatKeys:n,sharedConfigMap:t}}let pf=/* @__PURE__ */ new Set([`__proto__`,`constructor`,`prototype`]);var mf=class e{node;knownState;unknownState;sharedNodeState;size;constructor(e,t,n=void 0,r=/* @__PURE__ */ new Map,i=void 0){this.node=e,this.sharedNodeState=t,this.unknownState=n,this.knownState=r;let{sharedConfigMap:a}=this.sharedNodeState,o=i===void 0?function(e,t,n){let r=n.size;if(t)for(let i in t){let t=e.get(i);t&&n.has(t)||r++}return r}(a,n,r):i;this.size=o}getValue(e){let t=this.knownState.get(e);if(t!==void 0)return t;this.sharedNodeState.sharedConfigMap.set(e.key,e);let n=e.defaultValue;if(this.unknownState&&e.key in this.unknownState){let t=this.unknownState[e.key];t!==void 0&&(n=e.parse(t)),this.updateFromKnown(e,n)}return n}getInternalState(){return[this.unknownState,this.knownState]}toJSON(){let e={...this.unknownState},t={};for(let[t,n]of this.knownState)t.isEqual(n,t.defaultValue)?delete e[t.key]:e[t.key]=t.unparse(n);for(let n of this.sharedNodeState.flatKeys)n in e&&(t[n]=e[n],delete e[n]);return _f(e)&&(t.$=e),t}getWritable(t){if(this.node===t)return this;let{sharedNodeState:n,unknownState:r}=this,i=new Map(this.knownState);return new e(t,n,function(e,t,n){let r;if(n)for(let[i,a]of Object.entries(n)){if(pf.has(i))continue;let n=e.get(i);n?t.has(n)||t.set(n,n.parse(a)):(r||={},r[i]=a)}return r}(n.sharedConfigMap,i,r),i,this.size)}resetOnCopyNode(){for(let e of this.knownState.keys())e.resetOnCopyNode&&this.knownState.set(e,e.defaultValue);return this}updateFromKnown(e,t){let n=e.key;this.sharedNodeState.sharedConfigMap.set(n,e);let{knownState:r,unknownState:i}=this;r.has(e)||i&&n in i||(i&&(delete i[n],this.unknownState=_f(i)),this.size++),r.set(e,t)}updateFromUnknown(e,t){if(pf.has(e))return;let n=this.sharedNodeState.sharedConfigMap.get(e);n?this.updateFromKnown(n,n.parse(t)):(this.unknownState=this.unknownState||{},e in this.unknownState||this.size++,this.unknownState[e]=t)}updateFromJSON(e){let{knownState:t}=this;for(let e of t.keys())t.set(e,e.defaultValue);if(this.size=t.size,this.unknownState=void 0,e)for(let[t,n]of Object.entries(e))this.updateFromUnknown(t,n)}};function hf(e){let t=e.getWritable(),n=t.__state?t.__state.getWritable(t):new mf(t,gf(t));return t.__state=n,n}function gf(e){return e.__state?e.__state.sharedNodeState:w_(oy(),e.getType()).sharedNodeState}function _f(e){if(e)for(let t in e)return e}function vf(e){return e}function yf(e,t,n){for(let[r,i]of t.knownState){if(e.has(r.key))continue;e.add(r.key);let t=n?n.getValue(r):r.defaultValue;if(t!==i&&!r.isEqual(t,i))return!0}return!1}function bf(e,t,n){let{unknownState:r}=t,i=n?n.unknownState:void 0;if(r){for(let[t,n]of Object.entries(r))if(!e.has(t)&&(e.add(t),n!==(i?i[t]:void 0)))return!0}return!1}function xf(e,t){let n=e.__state;return n&&n.node===e?n.getWritable(t):n}function Sf(e,t){let n=e.__mode,r=e.__format,i=e.__style,a=t.__mode,o=t.__format,s=t.__style,c=e.__state,l=t.__state;return(n===null||n===a)&&(r===null||r===o)&&(i===null||i===s)&&(e.__state===null||c===l||function(e,t){if(e===t)return!0;let n=/* @__PURE__ */ new Set;return!(e&&yf(n,e,t)||t&&yf(n,t,e)||e&&bf(n,e,t)||t&&bf(n,t,e))}(c,l))}function Cf(e,t){let n=e.mergeWithSibling(t),r=H()._normalizedNodes;return r.add(e.__key),r.add(t.__key),n}function wf(e){let t,n,r=e;if(r.__text!==``||!r.isSimpleText()||r.isUnmergeable()){for(;(t=r.getPreviousSibling())!==null&&z(t)&&t.isSimpleText()&&!t.isUnmergeable();){if(t.__text!==``){if(Sf(t,r)){r=Cf(t,r);break}break}t.remove()}for(;(n=r.getNextSibling())!==null&&z(n)&&n.isSimpleText()&&!n.isUnmergeable();){if(n.__text!==``){if(Sf(r,n)){r=Cf(r,n);break}break}n.remove()}}else r.remove()}function Tf(e){return Ef(e.anchor),Ef(e.focus),e}function Ef(e){for(;e.type===`element`;){let t=e.getNode(),n=e.offset,r,i;if(n===t.getChildrenSize()?(r=t.getChildAtIndex(n-1),i=!0):(r=t.getChildAtIndex(n),i=!1),z(r)){e.set(r.__key,i?r.getTextContentSize():0,`text`,!0);break}if(!U(r))break;e.set(r.__key,i?r.getChildrenSize():0,`element`,!0)}}let Df=Symbol.for(`@lexical/CachedTextSize`);function Of(e,t){return Hf.read(()=>{let n=0,r=e;for(let e=0;e<t&&r!==null;e++){let i=Vf.get(r);if(i===void 0&&F(345,r),U(i)){let a=Uf.get(r);if(a!==void 0&&U(a)&&a.__parent!==i.__parent)n+=i.getTextContentSize();else{let e=Wf.get(r),t=e&&e.__lexicalTextContent;typeof t!=`string`&&F(346,i.getType()),n+=t.length}e<t-1&&!i.isInline()&&(n+=2)}else{let e=i[Df];e===void 0&&F(347,i.getType(),r),n+=e}r=i.__next}return n},{editor:I})}function kf(e){U(e)||e[Df]===void 0&&(e[Df]=z(e)?e.__text.length:e.getTextContentSize())}let Af,I,jf,L=``,Mf=null,Nf=null,Pf=null;function Ff(){return{firstTextKey:Pf,format:Mf,style:Nf}}function If(e){e.firstTextKey!==null&&(Mf=e.format,Nf=e.style,Pf=e.firstTextKey)}function Lf(e){if(Pf!==null)return;let t=e.__lexicalFirstTextKey;if(t===void 0&&F(348),t===null)return;let n=Uf.get(t);z(n)&&(Mf=n.getFormat(),Nf=n.getStyle(),Pf=t)}let Rf,zf,Bf,Vf,Hf,Uf,Wf,Gf,Kf,qf,Jf=!1,Yf=!1;function Xf(e,t){let n=Vf.get(e),r=Uf.has(e);if(t!==null){let n=yp(e);n.parentNode===t&&t.removeChild(n)}if(!r){if(I._keyToDOMMap.delete(e),U(n)){let e=Ay(n,Vf);Zf(e,0,e.length-1,null)}if(n!==void 0){for(let e of ap(n).values()){let t=sp(e);Xf(e,null),t!==null&&t.remove()}mv(Kf,jf,Rf,n,`destroyed`)}}}function Zf(e,t,n,r){for(let i=t;i<=n;++i){let t=e[i];t!==void 0&&Xf(t,r)}}function Qf(e,t){e.setProperty(`text-align`,t)}function $f(e,t){let n=Af.theme.indent;if(typeof n==`string`){let r=e.classList.contains(n);t>0&&!r?e.classList.add(n):t<1&&r&&e.classList.remove(n)}e.style.setProperty(`padding-inline-start`,t===0?``:`calc(${t} * var(--lexical-indent-base-value, 40px))`)}function ep(e,t){let n=e.style;t===0?Qf(n,``):t===1?Qf(n,`left`):t===2?Qf(n,`center`):t===3?Qf(n,`right`):t===4?Qf(n,`justify`):t===5?Qf(n,`start`):t===6&&Qf(n,`end`)}function tp(e,t){let n=function(e){let t=e.__dir;if(t!==null)return t;if(Jg(e))return null;let n=e.getParent();return n===null||kv(n)&&n.__dir===null?`auto`:null}(t);n===null?e.removeAttribute(`dir`):e.dir=n}function np(e){let t=Uv().createElement(`div`);return t.setAttribute(`data-lexical-slot`,e),t.style.display=`none`,t}function rp(e,t,n){t||e.contentEditable===`false`?xy(n,I):n.removeAttribute(`contenteditable`)}function ip(e,t,n){let r=L,i=Ff();L=``;let a=``,o=W(e);for(let[r,i]of n){let n=np(r);rp(t,o,n),t.appendChild(n),L=``;let s=Ff();lp(i,cy(e,n,I)),If(s),op(e,r,t,n),a+=L}return If(i),L=r,a}function ap(e){return Ny(e)&&e.__slots!==null?e.__slots:My}function op(e,t,n,r){let i=qf.$getSlotTargetElement(e,t,n,I);i!==null&&(r.parentElement!==i&&i.appendChild(r),r.style.display=``)}function sp(e){let t=Wf.get(e);return t===void 0?null:t.parentElement}function cp(e,t,n){let r=ap(e),i=ap(t);for(let[e,t]of r)if(!i.has(e)){let e=sp(t);Xf(t,null),e!==null&&e.remove()}let a=L,o=Ff(),s=``,c=null,l=W(t);for(let[e,a]of i){let i=r.get(e),o=i===void 0?null:sp(i);L=``;let u=Ff();if(o===null){o=np(e);let r=null;for(let e of n.children)if(!e.hasAttribute(`data-lexical-slot`)){r=e;break}n.insertBefore(o,r),lp(a,cy(t,o,I))}else i===a?mp(a,o):(i!==void 0&&Xf(i,o),lp(a,cy(t,o,I)));if(If(u),rp(n,l,o),op(t,e,n,o),s+=L,o.parentElement===n){let e=c===null?n.firstChild:c.nextSibling;e!==o&&n.insertBefore(o,e),c=o}}return If(o),L=a,s}function lp(e,t){let n=Uf.get(e);if(n===void 0&&F(60),t!==null){let r=Vf.get(e);if(r!==void 0){let i=Wf.get(e);if(i!==void 0){let a=Py(r)?r.__slotHost:null,o=Py(n)?n.__slotHost:null,s=r.__parent!==n.__parent||a!==o,c=o!==null&&i.parentElement!==t.element;if(s||c)return t.insertChild(i),mp(e,t.element)}}}let r=qf.$createDOM(n,I);if(function(e,t,n){let r=n._keyToDOMMap;G_(t,n,e),r.set(e,t)}(e,r,I),z(n)?r.setAttribute(`data-lexical-text`,`true`):W(n)&&(r.setAttribute(`data-lexical-decorator`,`true`),yy(r,{captureSelection:!0})),U(n)){let e=n.__indent,t=n.__size;tp(r,n),e!==0&&$f(r,e);let i=ap(n),a=i.size>0?ip(n,r,i):``;if(t===0)r.__lexicalTextContent=a,r.__lexicalFirstTextKey=null,L+=a,i.size>0&&(r.__lexicalSlotTextLength=a.length);else{let e=L,o=t-1;if(up(Ay(n,Uf),n,0,o,cy(n,r,I)),a!==``){let t=r.__lexicalTextContent||``;r.__lexicalTextContent=a+t,L=e+a+t}i.size>0&&(r.__lexicalSlotTextLength=a.length)}let o=n.__format;o!==0&&ep(r,o),n.isInline()||dp(null,n,r)}else{let t=n.getTextContent();if(W(n)){let t=n.decorate(I,Af);t!==null&&hp(e,t),r.contentEditable=`false`;let i=ap(n);i.size>0&&ip(n,r,i)}L+=t}return t!==null&&t.insertChild(r),qf.$decorateDOM(n,null,r,I),kf(n),mv(Kf,jf,Rf,n,`created`),r}function up(e,t,n,r,i){let a=L,o=Ff();L=``,Mf=null,Nf=null,Pf=null;let s=n;for(;s<=r;++s){let t=Ff();lp(e[s],i);let n=Uf.get(e[s]);n!==null&&z(n)?Mf===null&&(Mf=n.getFormat(),Nf=n.getStyle(),Pf=n.__key):U(n)&&s<r&&!n.isInline()&&(L+=`
123
+ 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)}}e.external&&(e.sharedDefsExtractedFor=e.external)}function nc(e){let t=e.anyOf;if(!Array.isArray(t)||t.length===0||e.type!==void 0)return;let n=[];for(let e of t){if(!e||typeof e!=`object`)return;nc(e);let t=Object.keys(e);if(t.length!==1||t[0]!==`type`)return;let r=e.type;for(let e of Array.isArray(r)?r:[r]){if(typeof e!=`string`)return;n.includes(e)||n.push(e)}}delete e.anyOf,e.type=n.length===1?n[0]:n}let rc=/* @__PURE__ */ new Set([`type`,`properties`,`required`,`additionalProperties`]),ic=[`oneOf`,`anyOf`];function ac(e){let t=e.additionalProperties;return t===void 0||t===!1||typeof t!=`object`||!t?null:Object.keys(t).length?t:null}function oc(e){let t=[];for(let n of e){if(typeof n!=`object`||n.type!==`object`)return null;for(let e in n)if(!rc.has(e))return null;t.push(n)}let n={},r=/* @__PURE__ */ new Set;for(let e of t){for(let r in e.properties){if(Object.prototype.hasOwnProperty.call(n,r))continue;let e=[];for(let n of t){let t=n.properties?.[r]??ac(n);t!=null&&(e.some(e=>JSON.stringify(e)===JSON.stringify(t))||e.push(t))}Xt(n,r,e.length===1?e[0]:oc(e)??{allOf:e})}for(let t of e.required??[])r.add(t)}let i={type:`object`,properties:n};if(r.size&&(i.required=[...r]),t.every(e=>e.additionalProperties===!1))i.additionalProperties=!1;else{let e=[];for(let n of t){let t=ac(n);t&&!e.some(e=>JSON.stringify(e)===JSON.stringify(t))&&e.push(t)}e.length===1?i.additionalProperties=e[0]:e.length>1&&(i.additionalProperties={allOf:e})}return i}function sc(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let t of rc)if(t in e)return;let n=t.filter(e=>ic.some(t=>Array.isArray(e[t]))),r=null;if(!n.length)r=oc(t);else{let e=n[0],i=ic.find(t=>Array.isArray(e[t]));if(Object.keys(e).length!==1)return;let a=t.filter(t=>t!==e),o=e[i].map(e=>oc([...a,e]));if(o.some(e=>!e))return;r={[i]:o}}r&&(delete e.allOf,Xs(e,r))}function cc(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)):Xs(i,s),Xs(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??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(let t of[...e.seen.entries()].reverse())r(t[0]);if(e.target!==`openapi-3.0`)for(let t of e.seen.entries())nc(t[1].def??t[1].schema);for(let t of e.deferred)t();if(e.intersections.length){let t=/* @__PURE__ */ new Map;for(let n of e.seen.values())for(let e of[n.schema,n.def]){let n=e?.allOf;if(!Array.isArray(n))continue;let r=t.get(n);r?r.push(e):t.set(n,[e])}for(let n of e.intersections)for(let e of t.get(n)??[])sc(e)}}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)}Xs(i,n.defId?n.schema: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??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(e.def.id===e.defId&&delete e.def.id,Xt(o,e.defId,e.def))}e.external&&(e.sharedEmitDoneFor=e.external),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:dc(t,`input`,e.processors),output:dc(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function lc(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 lc(r.element,n);if(r.type===`set`)return lc(r.valueType,n);if(r.type===`lazy`)return lc(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`||r.type===`catch`)return lc(r.innerType,n);if(r.type===`intersection`)return lc(r.left,n)||lc(r.right,n);if(r.type===`record`||r.type===`map`)return lc(r.keyType,n)||lc(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:lc(r.in,n)||lc(r.out,n);if(r.type===`object`){for(let e in r.shape)if(lc(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(lc(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(lc(e,n))return!0;return!!(r.rest&&lc(r.rest,n))}return!1}let uc=(e,t={})=>n=>{let r=Zs({...n,processors:t});return $s(e,r),tc(r,e),cc(r,e)},dc=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=Zs({...i??{},target:a,io:t,processors:n});return $s(e,o),tc(o,e),cc(o,e)},fc=(e,t,n)=>{(e[t]===void 0||n>e[t])&&(e[t]=n)},pc=(e,t,n)=>{(e[t]===void 0||n<e[t])&&(e[t]=n)},mc=(e,t)=>{fc(e,`minimum`,t),pc(e,`maximum`,t)},hc=(e,t)=>{e.multipleOf??=[],e.multipleOf.includes(t)||e.multipleOf.push(t)},gc=(e,t)=>{e.patterns??=/* @__PURE__ */ new Set,e.patterns.add(t)},_c=(e,t)=>{e.mime=e.mime?e.mime.filter(e=>t.includes(e)):[...t]},vc=(e,t)=>{e.format=t,t.includes(`int`)&&(e.isInt=!0)},yc=(e,t)=>fc(e,`minimum`,t.minimum),bc=(e,t)=>pc(e,`maximum`,t.maximum),xc=e=>(t,n)=>{vc(t,n.format);let[r,i]=e[n.format];fc(t,`minimum`,r),pc(t,`maximum`,i)},Sc={greater_than:(e,t)=>fc(e,t.inclusive?`minimum`:`exclusiveMinimum`,t.value),less_than:(e,t)=>pc(e,t.inclusive?`maximum`:`exclusiveMaximum`,t.value),multiple_of:(e,t)=>hc(e,t.value),number_format:xc(vn),bigint_format:xc(yn),min_length:yc,max_length:bc,length_equals:(e,t)=>mc(e,t.length),min_size:yc,max_size:bc,size_equals:(e,t)=>mc(e,t.size),string_format:(e,t)=>{vc(e,t.format),t.pattern&&gc(e,t.pattern),(t.format===`base64`||t.format===`base64url`)&&(e.contentEncoding=t.format),(t.local||t.precision===-1)&&(e.laxFormat=!0)},mime_type:(e,t)=>_c(e,t.mime)};function Cc(e){let t={},n=e._zod.def,r=e._zod.traits.has(`$ZodCheck`)?[e,...n.checks??[]]:n.checks??[];for(let e of r)Sc[e._zod.def.check]?.(t,e._zod.def);let i=e._zod.bag;i.minimum!==void 0&&fc(t,`minimum`,i.minimum),i.exclusiveMinimum!==void 0&&fc(t,`exclusiveMinimum`,i.exclusiveMinimum),i.maximum!==void 0&&pc(t,`maximum`,i.maximum),i.exclusiveMaximum!==void 0&&pc(t,`exclusiveMaximum`,i.exclusiveMaximum),i.multipleOf!==void 0&&hc(t,i.multipleOf),i.format!==void 0&&(t.format??=i.format,i.format.includes(`int`)&&(t.isInt=!0)),i.mime&&_c(t,i.mime);for(let e of i.patterns??[])gc(t,e);return t}let wc={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},Tc=/* @__PURE__ */ new Map([[va,Qr],[ba,$r]]),Ec=e=>Tc.get(e)??e,Dc=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l,laxFormat:u}=Cc(e);if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=wc[s]??s,i.format===``&&delete i.format,(s===`time`||u)&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let e=[...c].map(Ec);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}))])}},Oc=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,multipleOf:s,exclusiveMaximum:c,exclusiveMinimum:l,isInt:u}=Cc(e);i.type=u?`integer`:`number`;let d=typeof l==`number`&&l>=(a??-1/0),f=typeof c==`number`&&c<=(o??1/0),p=t.target===`draft-04`||t.target===`openapi-3.0`;if(d?p?(i.minimum=l,i.exclusiveMinimum=!0):i.exclusiveMinimum=l:typeof a==`number`&&(i.minimum=a),f?p?(i.maximum=c,i.exclusiveMaximum=!0):i.exclusiveMaximum=c:typeof o==`number`&&(i.maximum=o),s){let n=/* @__PURE__ */ new Set;for(let a of s)Number.isFinite(a)&&a!==0?n.add(Math.abs(a)):Qs(e,t,i,r,`A multipleOf divisor of ${a} cannot be represented in JSON Schema`);let[a,...o]=n;a!==void 0&&(i.multipleOf=a),o.length&&(i.allOf=[...i.allOf??[],...o.map(e=>({multipleOf:e}))])}},kc=(e,t,n,r)=>{n.type=`boolean`},Ac=(e,t,n,r)=>{t.target===`openapi-3.0`?(n.type=`string`,n.nullable=!0,n.enum=[null]):n.type=`null`},jc=(e,t,n,r)=>{n.not={}},Mc=(e,t,n,r)=>{let i=e._zod.def,a=Bt(i.entries);a.length===0?n.not={}:(a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a)},Nc=(e,t,n,r)=>{let i=e._zod.def;if(i.values.length===0){n.not={};return}let a=[];for(let o of i.values)if(o===void 0){if(Qs(e,t,n,r,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof o==`bigint`){if(Qs(e,t,n,r,`BigInt literals cannot be represented in JSON Schema`))return;a.push(Number(o))}else a.push(o);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}},Pc=(e,t,n,r)=>{let i=n,a=e._zod.pattern;if(!a)throw Error(`Pattern not found in template literal`);i.type=`string`,i.pattern=a.source},Fc=(e,t,n,r)=>{Qs(e,t,n,r,`Custom types cannot be represented in JSON Schema`)},Ic=(e,t,n,r)=>{Qs(e,t,n,r,`Transforms cannot be represented in JSON Schema`)},Lc=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=Cc(e);typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=$s(a.element,t,{...r,path:[...r.path,`items`]})};function Rc(e){let t=e._zod.def;return t.type===`pipe`&&t.in._zod.traits.has(`$ZodTransform`)?Rc(t.out):t.type===`catch`?Rc(t.innerType):e._zod.optin}let zc=(e,t,n,r)=>{let i=n,a=e._zod.def,o=a.shape;if(Object.getOwnPropertySymbols(o).length&&Qs(e,t,i,r,`Symbol keys cannot be represented in JSON Schema`))return;i.type=`object`,i.properties={};for(let e in o)Xt(i.properties,e,$s(o[e],t,{...r,path:[...r.path,`properties`,e]}));let s=[];for(let e of Object.keys(o)){let n=a.shape[e];(t.io===`input`?Rc(n)===void 0:n._zod.optout===void 0)&&s.push(e)}s.length>0&&(i.required=s),a.catchall?._zod.def.type===`never`?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=$s(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},Bc=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>$s(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},Vc=(e,t,n,r)=>{let i=e._zod.def,a=$s(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=$s(i.right,t,{...r,path:[...r.path,`allOf`,1]}),s=e=>`allOf`in e&&Object.keys(e).length===1,c=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]];n.allOf=c,t.intersections.push(c)},Hc=(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)=>$s(e,t,{...r,path:[...r.path,o,n]})),l=a.rest?$s(a.rest,t,{...r,path:[...r.path,s,...t.target===`openapi-3.0`?[a.items.length]:[]]}):null,u=a.items.length;for(;u>0;){let e=a.items[u-1];if(!(t.io===`input`?Rc(e)!==void 0:e._zod.optout===`optional`))break;u--}let d=a.items.length,f=!a.rest;t.target===`draft-2020-12`?(i.prefixItems=c,f?i.items=!1:l&&(i.items=l),u>0&&(i.minItems=u),f&&(i.maxItems=d)):t.target===`openapi-3.0`?(i.items={anyOf:c},l&&i.items.anyOf.push(l),u>0&&(i.minItems=u),f&&(i.maxItems=d)):(i.items=c,f?i.additionalItems=!1:l&&(i.additionalItems=l),u>0&&(i.minItems=u),f&&(i.maxItems=d));let{minimum:p,maximum:m}=Cc(e);typeof p==`number`&&(i.minItems=p),typeof m==`number`&&(i.maxItems=m)};function Uc(e,t,n){if(t.$ref){if(n.has(t))return t;n.add(t);let r=e.get(t)?.def;if(!r)return t;let i=Uc(e,r,n);return i===r?t:i}for(let r of[`anyOf`,`oneOf`]){let i=t[r];if(!Array.isArray(i))continue;let a=i.map(t=>Uc(e,t,n));a.some((e,t)=>e!==i[t])&&(t={...t,[r]:a})}let r=Array.isArray(t.type)?t.type:[t.type],i=!r.includes(`string`)&&r.some(e=>e===`number`||e===`integer`),a=t.enum??(t.const===void 0?void 0:[t.const]);if(!i&&!a?.some(e=>typeof e==`number`))return t;let{minimum:o,maximum:s,exclusiveMinimum:c,exclusiveMaximum:l,multipleOf:u,format:d,id:f,...p}=t;return p.enum?p.enum=p.enum.map(e=>typeof e==`number`?String(e):e):typeof p.const==`number`&&(p.const=String(p.const)),i&&(p.type=`string`,a||(p.pattern=(r.includes(`number`)?di:ui).source)),p}let Wc=/* @__PURE__ */ new WeakMap;function Gc(e){let t=/* @__PURE__ */ new Map;for(let n of e.seen.values())n.def&&!t.has(n.schema)&&t.set(n.schema,n);let n=/* @__PURE__ */ new Map;for(let r of Wc.get(e)??[]){let i=e.seen.get(r),a=(i?.def??i?.schema)?.propertyNames;if(!a||a===!0||n.has(a))continue;let o=Uc(t,a,/* @__PURE__ */ new Set);o!==a&&n.set(a,o)}if(n.size)for(let t of e.seen.values())for(let e of[t.schema,t.def]){let t=e&&n.get(e.propertyNames);t&&(e.propertyNames=t)}}let Kc=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`;let o=a.keyType,s=Cc(o).patterns;if(a.mode===`loose`&&s&&s.size>0){let e=$s(a.valueType,t,{...r,path:[...r.path,`patternProperties`,`*`]});i.patternProperties={};for(let t of s)Xt(i.patternProperties,Ec(t).source,e)}else{if(t.target===`draft-07`||t.target===`draft-2020-12`){i.propertyNames=$s(a.keyType,t,{...r,path:[...r.path,`propertyNames`]});let n=Wc.get(t);n||(n=[],Wc.set(t,n),t.deferred.push(()=>Gc(t))),n.push(e)}i.additionalProperties=$s(a.valueType,t,{...r,path:[...r.path,`additionalProperties`]})}let c=o._zod.values,l=t.io===`input`&&Rc(a.valueType)!==void 0;if(c&&!a.partial&&!l){let e=[...c].filter(e=>typeof e==`string`||typeof e==`number`);e.length>0&&(i.required=e.map(String))}},qc=(e,t,n,r)=>{let i=e._zod.def,a=$s(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`}]},Jc=(e,t,n,r)=>{let i=e._zod.def;$s(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Yc=Symbol();function Xc(e,t,n,r,i){let a=!1,o=JSON.stringify(e,(e,t)=>typeof t==`bigint`?(a=!0,null):t);return a?(Qs(t,n,r,i,`BigInt defaults cannot be represented in JSON Schema`),Yc):JSON.parse(o)}let Zc=(e,t,n,r)=>{let i=e._zod.def;$s(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o=Xc(i.defaultValue,e,t,n,r);o!==Yc&&(n.default=o)},Qc=(e,t,n,r)=>{let i=e._zod.def;$s(i.innerType,t,r);let a=t.seen.get(e);if(a.ref=i.innerType,t.io!==`input`)return;let o=Xc(i.defaultValue,e,t,n,r);o!==Yc&&(n._prefault=o)},$c=(e,t,n,r)=>{let i=e._zod.def;$s(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{Qs(e,t,n,r,`Dynamic catch values are not supported in JSON Schema`);return}n.default=o},el=(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;$s(o,t,r);let s=t.seen.get(e);s.ref=o},tl=(e,t,n,r)=>{let i=e._zod.def;$s(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},nl=(e,t,n,r)=>{let i=e._zod.def;$s(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},rl=(e,t,n,r)=>{let i=e._zod.innerType;$s(i,t,r);let a=t.seen.get(e);a.ref=i},il=/* @__PURE__ */ new WeakSet([Object.prototype,Error.prototype]);function al(e,t,n){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){let e=n(this);return Object.defineProperty(this,t,{value:e,configurable:!0,writable:!0}),e},set(e){Object.defineProperty(this,t,{value:e,configurable:!0,writable:!0})}})}let ol=/*@__PURE__*/ E(`ZodError`,(e,t)=>{pr.init(e,t),e.name=`ZodError`;let n=Object.getPrototypeOf(e);il.has(n)||(il.add(n),al(n,`format`,e=>t=>gr(e,t)),al(n,`flatten`,e=>t=>hr(e,t)),al(n,`addIssue`,e=>t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,Ht,2)}),al(n,`addIssues`,e=>t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,Ht,2)}),Object.defineProperty(n,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))},void 0,{Parent:Error}),sl=/* @__PURE__ */ vr(ol),cl=/* @__PURE__ */ yr(ol),ll=/* @__PURE__ */ br(ol),ul=/* @__PURE__ */ Sr(ol),dl=/* @__PURE__ */ Or(ol),fl=/* @__PURE__ */ kr(ol),pl=/* @__PURE__ */ Ar(ol),ml=/* @__PURE__ */ jr(ol),hl=/* @__PURE__ */ Mr(ol),gl=/* @__PURE__ */ Nr(ol),_l=/* @__PURE__ */ Pr(ol),vl=/* @__PURE__ */ Fr(ol);function yl(){ar.localeError||or(Bo())}function bl(){ar.memoizer||or({memoizer:Lo()})}let xl=/*@__PURE__*/ E(`ZodType`,(e,t)=>(yl(),Ii.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(rn(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 hn(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(qu(e,t))},superRefine(e,t){return this.check(Ju(e,t))},overwrite(e){return this.check(/* @__PURE__ */ zs(e))},optional(){return wu(this)},exactOptional(){return Eu(this)},nullable(){return Ou(this)},nullish(){return wu(Ou(this))},nonoptional(e){return Pu(this,e)},array(){return A(this)},or(e){return uu([this,e])},and(e){return mu(this,e)},transform(e){return Ru(this,Su(e))},default(e){return Au(this,e)},prefault(e){return Mu(this,e)},catch(e){return Iu(this,e)},pipe(e){return Ru(this,e)},readonly(){return Bu(this)},describe(e){let t=this.clone();return Wo.add(t,{description:e}),t},meta(...e){if(e.length===0)return Wo.get(this);let t=this.clone();return Wo.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...t){return t.length===0?e(this):e(this,...t)},get"~standard"(){return Un(this,`~standard`,{...zi(this),jsonSchema:{input:dc(this,`input`),output:dc(this,`output`)}})},set"~standard"(e){Hn(this,`~standard`,e)},parse:function e(t,n){return sl(this,t,n,{callee:e})},parseAsync:async function e(t,n){return await cl(this,t,n,{callee:e})},safeParse(e,t){return ll(this,e,t)},async safeParseAsync(e,t){return ul(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){Hn(this,`spa`,e)},validate(e,t){return Tr(this,e,t)},validateAsync(e,t){return Dr(this,e,t)},encode:function e(t,n){return dl(this,t,n,{callee:e})},decode:function e(t,n){return fl(this,t,n,{callee:e})},encodeAsync:async function e(t,n){return await pl(this,t,n,{callee:e})},decodeAsync:async function e(t,n){return await ml(this,t,n,{callee:e})},safeEncode(e,t){return hl(this,e,t)},safeDecode(e,t){return gl(this,e,t)},async safeEncodeAsync(e,t){return _l(this,e,t)},async safeDecodeAsync(e,t){return vl(this,e,t)},toJSONSchema(e){return uc(this,{})(e)},get description(){return Wo.get(this)?.description},get _def(){return this._zod.def}}),Sl=/*@__PURE__*/ E(`_ZodString`,(e,t)=>{Bi.init(e,t),xl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Dc(e,t,n,r)},/*@__PURE__*/ Wn({format:e=>Cc(e).format??null,minLength:e=>Cc(e).minimum??null,maxLength:e=>Cc(e).maximum??null},{regex(...e){return this.check(/* @__PURE__ */ Ns(...e))},includes(...e){return this.check(/* @__PURE__ */ Is(...e))},startsWith(...e){return this.check(/* @__PURE__ */ Ls(...e))},endsWith(...e){return this.check(/* @__PURE__ */ Rs(...e))},min(...e){return this.check(/* @__PURE__ */ js(...e))},max(...e){return this.check(/* @__PURE__ */ As(...e))},length(...e){return this.check(/* @__PURE__ */ Ms(...e))},nonempty(...e){return this.check(/* @__PURE__ */ js(1,...e))},lowercase(e){return this.check(/* @__PURE__ */ Ps(e))},uppercase(e){return this.check(/* @__PURE__ */ Fs(e))},trim(){return this.check(/* @__PURE__ */ Vs())},normalize(...e){return this.check(/* @__PURE__ */ Bs(...e))},toLowerCase(){return this.check(/* @__PURE__ */ Hs())},toUpperCase(){return this.check(/* @__PURE__ */ Us())},slugify(){return this.check(/* @__PURE__ */ Ws())}})),Cl=/*@__PURE__*/ E(`ZodString`,(e,t)=>{Bi.init(e,t),Sl.init(e,t)},{email(e){return this.check(/* @__PURE__ */ qo(kl,e))},url(e){return this.check(/* @__PURE__ */ $o(Pl,e))},jwt(e){return this.check(/* @__PURE__ */ ms(Xl,e))},emoji(e){return this.check(/* @__PURE__ */ es(Il,e))},guid(e){return this.check(/* @__PURE__ */ Jo(Al,e))},uuid(e){return this.check(/* @__PURE__ */ Yo(jl,e))},uuidv4(e){return this.check(/* @__PURE__ */ Xo(jl,e))},uuidv6(e){return this.check(/* @__PURE__ */ Zo(jl,e))},uuidv7(e){return this.check(/* @__PURE__ */ Qo(jl,e))},nanoid(e){return this.check(/* @__PURE__ */ ts(Ll,e))},cuid(e){return this.check(/* @__PURE__ */ ns(Rl,e))},cuid2(e){return this.check(/* @__PURE__ */ rs(zl,e))},ulid(e){return this.check(/* @__PURE__ */ is(Bl,e))},base64(e){return this.check(/* @__PURE__ */ ds(ql,e))},base64url(e){return this.check(/* @__PURE__ */ fs(Jl,e))},xid(e){return this.check(/* @__PURE__ */ as(Vl,e))},ksuid(e){return this.check(/* @__PURE__ */ os(Hl,e))},ipv4(e){return this.check(/* @__PURE__ */ ss(Ul,e))},ipv6(e){return this.check(/* @__PURE__ */ cs(Wl,e))},cidrv4(e){return this.check(/* @__PURE__ */ ls(Gl,e))},cidrv6(e){return this.check(/* @__PURE__ */ us(Kl,e))},e164(e){return this.check(/* @__PURE__ */ ps(Yl,e))},datetime(e){return this.check(/* @__PURE__ */ hs(Tl,e))},date(e){return this.check(/* @__PURE__ */ gs(El,e))},time(e){return this.check(/* @__PURE__ */ _s(Dl,e))},duration(e){return this.check(/* @__PURE__ */ vs(Ol,e))}});function D(e){return/* @__PURE__ */ Ko(Cl,e)}let wl=/*@__PURE__*/ E(`ZodStringFormat`,(e,t)=>{Vi.init(e,t),Sl.init(e,t)}),Tl=/*@__PURE__*/ E(`ZodISODateTime`,(e,t)=>{oa.init(e,t),wl.init(e,t)}),El=/*@__PURE__*/ E(`ZodISODate`,(e,t)=>{sa.init(e,t),wl.init(e,t)}),Dl=/*@__PURE__*/ E(`ZodISOTime`,(e,t)=>{ca.init(e,t),wl.init(e,t)}),Ol=/*@__PURE__*/ E(`ZodISODuration`,(e,t)=>{la.init(e,t),wl.init(e,t)}),kl=/*@__PURE__*/ E(`ZodEmail`,(e,t)=>{Wi.init(e,t),wl.init(e,t)}),Al=/*@__PURE__*/ E(`ZodGUID`,(e,t)=>{Hi.init(e,t),wl.init(e,t)}),jl=/*@__PURE__*/ E(`ZodUUID`,(e,t)=>{Ui.init(e,t),wl.init(e,t)});function Ml(e){return/* @__PURE__ */ Yo(jl,e)}function Nl(e){return/* @__PURE__ */ Xo(jl,e)}let Pl=/*@__PURE__*/ E(`ZodURL`,(e,t)=>{Qi.init(e,t),wl.init(e,t)});function Fl(e){return/* @__PURE__ */ $o(Pl,e)}let Il=/*@__PURE__*/ E(`ZodEmoji`,(e,t)=>{$i.init(e,t),wl.init(e,t)}),Ll=/*@__PURE__*/ E(`ZodNanoID`,(e,t)=>{ea.init(e,t),wl.init(e,t)}),Rl=/*@__PURE__*/ E(`ZodCUID`,(e,t)=>{ta.init(e,t),wl.init(e,t)}),zl=/*@__PURE__*/ E(`ZodCUID2`,(e,t)=>{na.init(e,t),wl.init(e,t)}),Bl=/*@__PURE__*/ E(`ZodULID`,(e,t)=>{ra.init(e,t),wl.init(e,t)}),Vl=/*@__PURE__*/ E(`ZodXID`,(e,t)=>{ia.init(e,t),wl.init(e,t)}),Hl=/*@__PURE__*/ E(`ZodKSUID`,(e,t)=>{aa.init(e,t),wl.init(e,t)}),Ul=/*@__PURE__*/ E(`ZodIPv4`,(e,t)=>{ua.init(e,t),wl.init(e,t)}),Wl=/*@__PURE__*/ E(`ZodIPv6`,(e,t)=>{pa.init(e,t),wl.init(e,t)}),Gl=/*@__PURE__*/ E(`ZodCIDRv4`,(e,t)=>{ma.init(e,t),wl.init(e,t)}),Kl=/*@__PURE__*/ E(`ZodCIDRv6`,(e,t)=>{ga.init(e,t),wl.init(e,t)}),ql=/*@__PURE__*/ E(`ZodBase64`,(e,t)=>{ya.init(e,t),wl.init(e,t)}),Jl=/*@__PURE__*/ E(`ZodBase64URL`,(e,t)=>{Sa.init(e,t),wl.init(e,t)}),Yl=/*@__PURE__*/ E(`ZodE164`,(e,t)=>{Ca.init(e,t),wl.init(e,t)}),Xl=/*@__PURE__*/ E(`ZodJWT`,(e,t)=>{Ta.init(e,t),wl.init(e,t)}),Zl=/*@__PURE__*/ E(`ZodNumber`,(e,t)=>{Ea.init(e,t),xl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Oc(e,t,n,r),e.isFinite=!0},/*@__PURE__*/ Wn({minValue:e=>{let{minimum:t,exclusiveMinimum:n}=Cc(e);return Math.max(t??-1/0,n??-1/0)},maxValue:e=>{let{maximum:t,exclusiveMaximum:n}=Cc(e);return Math.min(t??1/0,n??1/0)},isInt:e=>{let{isInt:t,multipleOf:n}=Cc(e);return!!t||!!n?.some(Number.isSafeInteger)},format:e=>Cc(e).format??null},{gt(e,t){return this.check(/* @__PURE__ */ Ds(e,t))},gte(e,t){return this.check(/* @__PURE__ */ Os(e,t))},min(e,t){return this.check(/* @__PURE__ */ Os(e,t))},lt(e,t){return this.check(/* @__PURE__ */ Ts(e,t))},lte(e,t){return this.check(/* @__PURE__ */ Es(e,t))},max(e,t){return this.check(/* @__PURE__ */ Es(e,t))},int(e){return this.check($l(e))},safe(e){return this.check($l(e))},positive(e){return this.check(/* @__PURE__ */ Ds(0,e))},nonnegative(e){return this.check(/* @__PURE__ */ Os(0,e))},negative(e){return this.check(/* @__PURE__ */ Ts(0,e))},nonpositive(e){return this.check(/* @__PURE__ */ Es(0,e))},multipleOf(e,t){return this.check(/* @__PURE__ */ ks(e,t))},step(e,t){return this.check(/* @__PURE__ */ ks(e,t))},finite(){return this}}));function O(e){return/* @__PURE__ */ ys(Zl,e)}let Ql=/*@__PURE__*/ E(`ZodNumberFormat`,(e,t)=>{Da.init(e,t),Zl.init(e,t)});function $l(e){return/* @__PURE__ */ bs(Ql,e)}let eu=/*@__PURE__*/ E(`ZodBoolean`,(e,t)=>{Oa.init(e,t),xl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>kc(e,t,n,r)});function k(e){return/* @__PURE__ */ xs(eu,e)}let tu=/*@__PURE__*/ E(`ZodNull`,(e,t)=>{ka.init(e,t),xl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ac(e,t,n,r)});function nu(e){return/* @__PURE__ */ Ss(tu,e)}let ru=/*@__PURE__*/ E(`ZodUnknown`,(e,t)=>{Aa.init(e,t),xl.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function iu(){return/* @__PURE__ */ Cs(ru)}let au=/*@__PURE__*/ E(`ZodNever`,(e,t)=>{ja.init(e,t),xl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>jc(e,t,n,r)});function ou(e){return/* @__PURE__ */ ws(au,e)}let su=/*@__PURE__*/ E(`ZodArray`,(e,t)=>{bl(),Fa.init(e,t),xl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Lc(e,t,n,r),e.element=t.element},{min(e,t){return this.check(/* @__PURE__ */ js(e,t))},nonempty(e){return this.check(/* @__PURE__ */ js(1,e))},max(e,t){return this.check(/* @__PURE__ */ As(e,t))},length(e,t){return this.check(/* @__PURE__ */ Ms(e,t))},unwrap(){return this.element}});function A(e,t){return/* @__PURE__ */ Gs(su,e,t)}let cu=/*@__PURE__*/ E(`ZodObject`,(e,t)=>{bl(),Va.init(e,t),xl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>zc(e,t,n,r),Xn(e,`shape`,e=>e._zod.def.shape,!1)},{keyof(){return N(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(rn(this._zod.def,{catchall:e}))},passthrough(){return this.clone(rn(this._zod.def,{catchall:iu()}))},loose(){return this.clone(rn(this._zod.def,{catchall:iu()}))},strict(){return this.clone(rn(this._zod.def,{catchall:ou()}))},strip(){return this.clone(rn(this._zod.def,{catchall:void 0}))},extend(e){return Cn(this,e)},safeExtend(e){return Tn(this,e)},merge(e){return En(this,e)},pick(e){return bn(this,e)},omit(e){return Sn(this,e)},partial(...e){return Dn(Cu,this,e[0])},exactPartial(...e){return Dn(Tu,this,e[0],`exactPartial`)},required(...e){return On(Nu,this,e[0])}});function j(e,t){let n={type:`object`,shape:e??{},...w(t)};return new cu(n)}function M(e,t){return new cu({type:`object`,shape:e,catchall:ou(),...w(t)})}let lu=/*@__PURE__*/ E(`ZodUnion`,(e,t)=>{Ua.init(e,t),xl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Bc(e,t,n,r),e.options=t.options});function uu(e,t){return new lu({type:`union`,options:e,...w(t)})}let du=/*@__PURE__*/ E(`ZodDiscriminatedUnion`,(e,t)=>{lu.init(e,t),Ga.init(e,t)});function fu(e,t,n){return new du({type:`union`,options:t,discriminator:e,...w(n)})}let pu=/*@__PURE__*/ E(`ZodIntersection`,(e,t)=>{Ka.init(e,t),xl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Vc(e,t,n,r)});function mu(e,t){return new pu({type:`intersection`,left:e,right:t})}let hu=/*@__PURE__*/ E(`ZodTuple`,(e,t)=>{bl(),Ya.init(e,t),xl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Hc(e,t,n,r)},{rest(e){return this.clone({...this._zod.def,rest:e})},partial(){let e=this._zod.def;if(e.checks?.length)throw Error(`.partial() cannot be used on tuple schemas containing refinements`);return this.clone({...e,items:e.items.map(e=>new Cu({type:`optional`,innerType:e}))})}});function gu(e,t,n){let r=t instanceof Ii;return new hu({type:`tuple`,items:e,rest:r?t:null,...w(r?n:t)})}let _u=/*@__PURE__*/ E(`ZodRecord`,(e,t)=>{bl(),$a.init(e,t),xl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Kc(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType});function vu(e,t,n){return!t||!t._zod?new _u({type:`record`,keyType:D(),valueType:e,...w(t)}):new _u({type:`record`,keyType:e,valueType:t,...w(n)})}let yu=/*@__PURE__*/ E(`ZodEnum`,(e,t)=>{eo.init(e,t),xl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Mc(e,t,n,r),e.enum=t.entries,e.options=[...e._zod.values];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 yu({...t,checks:[],...w(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 yu({...t,checks:[],...w(r),entries:i})}});function N(e,t){let n=Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e;return new yu({type:`enum`,entries:n,...w(t)})}let bu=/*@__PURE__*/ E(`ZodLiteral`,(e,t)=>{to.init(e,t),xl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Nc(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 P(e,t){return new bu({type:`literal`,values:Array.isArray(e)?e:[e],...w(t)})}let xu=/*@__PURE__*/ E(`ZodTransform`,(e,t)=>{bl(),no.init(e,t),xl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ic(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new ir(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(Bn(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,`input`in t||(t.input=n.value),t.inst??=e,n.issues.push(Bn(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n)):(n.value=i,n)}});function Su(e){return new xu({type:`transform`,transform:e})}let Cu=/*@__PURE__*/ E(`ZodOptional`,(e,t)=>{io.init(e,t),xl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>nl(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function wu(e){return new Cu({type:`optional`,innerType:e})}let Tu=/*@__PURE__*/ E(`ZodExactOptional`,(e,t)=>{ao.init(e,t),xl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>nl(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Eu(e){return new Tu({type:`optional`,innerType:e})}let Du=/*@__PURE__*/ E(`ZodNullable`,(e,t)=>{oo.init(e,t),xl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>qc(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Ou(e){return new Du({type:`nullable`,innerType:e})}let ku=/*@__PURE__*/ E(`ZodDefault`,(e,t)=>{so.init(e,t),xl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Zc(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Au(e,t){return new ku({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():dn(t)}})}let ju=/*@__PURE__*/ E(`ZodPrefault`,(e,t)=>{lo.init(e,t),xl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Qc(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Mu(e,t){return new ju({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():dn(t)}})}let Nu=/*@__PURE__*/ E(`ZodNonOptional`,(e,t)=>{uo.init(e,t),xl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Jc(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Pu(e,t){return new Nu({type:`nonoptional`,innerType:e,...w(t)})}let Fu=/*@__PURE__*/ E(`ZodCatch`,(e,t)=>{mo.init(e,t),xl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>$c(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Iu(e,t){return new Fu({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:Zn(t)})}let Lu=/*@__PURE__*/ E(`ZodPipe`,(e,t)=>{ho.init(e,t),xl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>el(e,t,n,r),e.in=t.in,e.out=t.out});function Ru(e,t){return new Lu({type:`pipe`,in:e,out:t})}let zu=/*@__PURE__*/ E(`ZodReadonly`,(e,t)=>{_o.init(e,t),xl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>tl(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Bu(e){return new zu({type:`readonly`,innerType:e})}let Vu=/*@__PURE__*/ E(`ZodTemplateLiteral`,(e,t)=>{xo.init(e,t),xl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Pc(e,t,n,r)});function Hu(e,t){return new Vu({type:`template_literal`,parts:e,...w(t)})}let Uu=/*@__PURE__*/ E(`ZodLazy`,(e,t)=>{So.init(e,t),xl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>rl(e,t,n,r),e.unwrap=()=>e._zod.def.getter()});function Wu(e){return new Uu({type:`lazy`,getter:e})}let Gu=/*@__PURE__*/ E(`ZodCustom`,(e,t)=>{Co.init(e,t),xl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Fc(e,t,n,r)});function Ku(e,t){return/* @__PURE__ */ Ks(Gu,e??(()=>!0),t)}function qu(e,t={}){return/* @__PURE__ */ qs(Gu,e,t)}function Ju(e,t){return/* @__PURE__ */ Js(e,t)}function Yu(e){return/* @__PURE__ */ hs(Tl,e)}let Xu=j({source:D(),ref:D(),offset:O().int().nonnegative(),length:O().int().positive(),label:D(),appearance:N([`session`,`file`,`folder`,`skill`]).optional(),clipboardText:D(),invalid:k().optional()}),Zu=j({text:D(),references:A(Xu)}).refine(e=>{let t=0;for(let n of e.references)if(n.offset<t||n.length!==n.clipboardText.length||(t=n.offset+n.length,t>e.text.length||e.text.slice(n.offset,t)!==n.clipboardText))return!1;return!0},`Draft references must identify ordered, non-overlapping text spans`);function Qu(e){return typeof e==`string`?{text:e,references:[]}:{text:e.text,references:e.references.map(td)}}function $u(e){if(typeof e==`string`)return Qu(e);let t=Zu.safeParse(e);if(t.success)return{text:t.data.text,references:t.data.references.map(({appearance:e,invalid:t,...n})=>({...n,...e===void 0?{}:{appearance:e},...t===void 0?{}:{invalid:t}}))}}function ed(e,t){return{text:e,references:t.map(td)}}function td(e){return{source:e.source,ref:e.ref,offset:e.offset,length:e.length,label:e.label,clipboardText:e.clipboardText,...e.appearance===void 0?{}:{appearance:e.appearance},...e.invalid===void 0?{}:{invalid:e.invalid}}}let nd=`dsh.conversation`;function rd(){return(0,f.defineStore)({init:()=>({draft:``,view:null,viewRequest:null}),persist:nd,actions:{setDraft:(e,t)=>{e.draft=t},setView:(e,t)=>{e.view=t},openView:(e,t,n)=>{e.view=t,e.viewRequest={view:t,focus:n}},completeViewRequest:e=>{e.viewRequest=null}}})}function id(e){let t={text:``,references:[]};if(typeof localStorage>`u`)return t;try{let n=localStorage.getItem(`${nd}.${e}`);if(n===null)return t;let r=JSON.parse(n);return typeof r!=`object`||!r||!(`draft`in r)?t:$u(r.draft)??t}catch{return t}}function ad(e){if(typeof localStorage>`u`)return null;try{let t=localStorage.getItem(`${nd}.${e}`);if(t===null)return null;let n=JSON.parse(t);return typeof n!=`object`||!n||!(`view`in n)?null:typeof n.view==`string`?n.view:null}catch{return null}}function od(e,t){let n=e.kind===`directory`?`${e.path}/`:e.path;if(!/[\u0000-\u001f\u007f-\u009f"]/u.test(n))return t||/\s/u.test(n)?e.kind===`directory`?`@"${n}`:`@"${n}"`:`@${n}`}function sd(e){let t=e.replace(/[/\\]+$/,``),n=Math.max(t.lastIndexOf(`/`),t.lastIndexOf(`\\`));return t.slice(n+1)}function cd(e,t){if(t===void 0||t===``)return e;let n=t.replace(/[/\\]+$/,``);return e.startsWith(`${n}/`)||e.startsWith(`${n}\\`)?e.slice(n.length+1):e}let ld=`conversation`,ud=`描述你的任务以生成计划`,dd=`describe your task to generate plan`,fd={"shortcut.newline":`换行`,"shortcut.complementary":`使用互补的 Queue/Steer 方式`,"shortcut.slash":`打开命令菜单`,"shortcut.mention":`打开引用菜单`,"hint.plan":ud,"hint.goal":`输入目标,智能体将持续执行`,"hint.goal.active":`当前目标进行中。可输入 edit 修改 / pause 暂停 / resume 继续 / clear 清除`,"placeholder.plan":ud,"placeholder.default":`发消息或创建任务, / 调用指令, @ 文件或对话`,"placeholder.unavailable":`会话不可用`,"placeholder.parentOffline":`父会话已离线,无法继续发送;仍可停止当前运行`,"placeholder.hero":`描述你想要构建的内容, / 调用指令, @ 文件或对话`,"placeholder.workspace":`选择一个工作区开始`,"placeholder.preparing":`正在准备对话…`,"placeholder.loadFailed":`会话加载失败,请重试连接或检查远端主机`,"placeholder.loadUnsupported":`远端主机版本不支持加载此会话,请升级远端后再试`,"placeholder.steerQueue":`Cmd/Ctrl+Enter 插话发送全部排队消息`,"newSession.loadingModel":`模型加载中…`,"newSession.loadingHarness":`正在加载 Harness…`,"newSession.createFailedTitle":`无法创建新会话`,"newSession.createFailed.noHarness":`没有可用的 Harness,请检查设置后重试。`,"newSession.createFailed.workspaceRequired":`请先选择一个工作区再开始新会话。`,"newSession.createFailed.generic":`暂时无法创建新会话,请稍后重试。`,"newSession.retry":`重试`,"newSession.uploadUnavailable":`新会话准备完成后才能添加文件`,"input.commands":`添加文件或调用指令`,"input.commandsOnly":`调用指令`,"input.imagesAndCommands":`添加图片或调用指令`,"attachment.unavailable":`当前 Web 连接不支持附件上传。`,"input.file":`文件`,"input.stop":`停止生成`,"input.send":`发送消息`,"input.send.queue":`排队发送`,"input.send.steer":`插话发送`,"attachment.pending":`待发送附件`,"annotation.rail":`已附加的选中文字`,"annotation.remove":`移除批注 {index}`,"annotation.trayCount":`{count} 条批注`,"annotation.clearAll":`清空全部`,"annotation.emptyComment":`仅引用原文 · 点击补充批注`,"annotation.editHint":`点击原地编辑批注 {index}`,"annotation.revealHint":`定位原文 {index}`,"attachment.scrollLeft":`向左滚动附件`,"attachment.scrollRight":`向右滚动附件`,"reference.dropTitle":`松开以引用聊天`,"attachment.dropTitle":`文件或图片拖动到此处即可添加`,"attachment.dropDesc":`图片限制:最多 {count} 张,每张 {size}`,"attachment.dropBlocked":`当前无法添加文件或图片`,"attachment.directoryDesktopOnly":`只有桌面端支持添加文件夹,浏览器里请添加单个文件`,"attachment.pathUnavailable":`无法获取文件夹路径,请重新拖入`,"attachment.pathUnsupported":`路径含有无法引用的字符,请改名后再试`,"image.pending":`待发送图片`,"image.openOriginal":`查看原图`,"image.openOriginalLabel":`{label},点击查看原图`,"image.remove":`移除图片 {name}`,"image.retry":`重试`,"image.original":`原图`,"image.label":`图片`,"image.loadFailed":`图片不可用,点击重试`,"image.previewTooLarge":`图片过大,无法预览(单张最多 50 MiB、6400 万像素)`,"image.loading":`图片加载中…`,"image.preview":`原图预览`,"image.closePreview":`关闭原图预览`,"image.unsupportedType":`仅支持 PNG、JPG、WebP、GIF 格式的图片`,"image.tooMany":`一条消息最多添加 {count} 张图片`,"image.fileTooLarge":`单张图片不能超过 {size}`,"image.totalTooLarge":`图片总大小超过 {size},请移除部分图片`,"image.tooManyPixels":`图片分辨率过大,请压缩后重试`,"image.modelUnsupported":`当前模型不支持图片,请切换支持图片的模型`,"image.sendFailed":`图片发送失败({reason}),请重新添加图片后再试`,"file.unavailable":`已上传文件不可用或被修改,请重新选择`,"file.pending":`待发送文件`,"file.remove":`移除文件 {name}`,"file.uploading":`上传中…`,"file.uploadingPercent":`上传中 {percent}%`,"file.uploadFailed":`上传失败,点击重试`,"file.retry":`重试上传 {name}`,"file.retryOrRemove":`请先重试或移除上传失败的附件`,"file.sessionUnavailable":`会话不可用,无法上传文件`,"file.notStaged":`文件尚未上传成功,请重新添加后再试`,"file.label":`文件`,"context.aria":`上下文已用 {percent}`,"context.used":`上下文已用`,"context.system":`系统提示词`,"context.tools":`工具定义`,"context.messages":`对话消息`,"settings.enter.title":`繁忙时的发送行为`,"settings.enter.description":`智能体运行时 Enter 键和发送按钮的行为;Cmd/Ctrl+Enter 使用另一行为`,"settings.enter.queue":`排队发送`,"settings.enter.steer":`插话发送`,"hero.headline":`今天想做点什么?`,"hero.preview":`Web`,"hero.previewDesktop":`CH Desktop`,"hero.chooseWorkspace":`选择工作区`,"hero.noWorkspace":`不选择工作区`,"session.hierarchy":`会话层级`,"todo.title":`任务`,"todo.progress.done":`{done} 已完成`,"todo.progress.active":`{active} 进行中`,"todo.progress.pending":`{pending} 待处理`,"todo.status.completed":`已完成`,"todo.status.inProgress":`进行中`,"todo.status.pending":`待处理`,"todo.rowTitle":`更新任务清单`,"tool.title.createGoal":`创建目标`,"tool.title.getGoal":`查看目标`,"tool.title.updateGoal":`更新目标`,"tool.preparing.content":`{kilobytes}KB`,"tool.title.createSchedule":`创建定时任务`,"tool.title.listSchedules":`查看定时任务`,"tool.title.deleteSchedule":`删除定时任务`,"tool.title.updateSchedule":`修改定时任务`,"detail.state":`状态`,"detail.todo.completed":`已完成`,"detail.todo.in_progress":`进行中`,"detail.todo.pending":`待处理`,"detail.todo.empty":`任务清单为空`,"todo.diff.initial":`首次记录`,"todo.diff.compare":`与上次清单相比`,"todo.diff.unavailable":`旧清单不可用`,"todo.diff.noChanges":`清单没有变化`,"todo.diff.added":`新增 {count}`,"todo.diff.updated":`更新 {count}`,"todo.diff.removed":`移除 {count}`,"todo.diff.unchanged":`{count} 项未变化`,"todo.diff.addedItem":`新增`,"todo.diff.updatedItem":`状态变化`,"todo.diff.movedItem":`顺序调整`,"todo.diff.removedItem":`移除`,"detail.goal.empty":`没有目标`,"detail.goal.active":`进行中`,"detail.goal.disarmed":`等待继续`,"detail.goal.paused":`已暂停`,"detail.goal.blocked":`受阻`,"detail.goal.complete":`已完成`,"detail.goal.rounds":`执行轮次`,"detail.goal.reason":`受阻原因`,"detail.days":`{count} 天`,"detail.hours":`{count} 小时`,"detail.minutes":`{count} 分钟`,"detail.seconds":`{count} 秒`,"detail.schedule.once":`单次`,"detail.schedule.every":`每 {interval}`,"detail.schedule.when":`计划时间`,"detail.schedule.frequency":`重复`,"detail.schedule.scheduled":`等待触发`,"detail.schedule.overdue":`已到期,等待会话恢复`,"detail.schedule.empty":`没有定时任务`,"detail.schedule.deleted":`已删除`,"detail.schedule.count":`{count} 个定时任务`,"detail.schedule.daily":`每天 {time}({zone})`,"detail.schedule.weekly":`每周 {days} {time}({zone})`,"detail.schedule.cron":`Cron {expression}({zone})`,"detail.weekday.1":`周一`,"detail.weekday.2":`周二`,"detail.weekday.3":`周三`,"detail.weekday.4":`周四`,"detail.weekday.5":`周五`,"detail.weekday.6":`周六`,"detail.weekday.7":`周日`,"detail.weekday.join":`、`,"tool.title.inspectProviders":`检查提供方`,"tool.title.queryRuntime":`查询运行时`,"tool.title.inspectPlugins":`检查动态插件`,"tool.title.workflow":`运行工作流`,"tool.title.ralph":`运行循环工作流`,"tool.title.readEvent":`读取事件`,"tool.title.searchEvents":`搜索事件`,"tool.title.traceEvent":`追踪事件`,"tool.title.searchSessions":`搜索会话`,"tool.title.traceSession":`追踪会话`,"tool.title.listModels":`查看可用模型`,"tool.title.subagent":`创建子智能体`,"tool.title.listAgents":`查看子智能体`,"tool.title.sendMessage":`发送消息`,"tool.title.interruptAgent":`中断智能体`,"tool.title.listJobs":`查看后台任务`,"tool.title.readJob":`读取任务输出`,"tool.title.killJob":`取消后台任务`,"tool.title.openTerminal":`创建终端`,"tool.title.readTerminal":`读取终端`,"tool.title.listTerminals":`查看终端`,"tool.title.signalTerminal":`发送终端信号`,"tool.title.closeTerminal":`关闭终端`,"tool.title.lsp":`查询代码符号`,"tool.title.findDefinition":`查找定义`,"tool.title.findReferences":`查找引用`,"tool.title.findImplementation":`查找实现`,"tool.title.hoverSymbol":`查看符号信息`,"tool.title.spawnTeammate":`创建队友`,"tool.title.createTeamTask":`创建团队任务`,"tool.title.getTeamTask":`读取团队任务`,"tool.title.updateTeamTask":`更新团队任务`,"tool.title.listTeamTasks":`查看团队任务`,"tool.title.waitAgent":`等待子智能体`,"detail.recordedResult":`调用结果`,"detail.empty":`暂无结果`,"detail.none":`无`,"detail.yes":`是`,"detail.no":`否`,"detail.moreInInspect":`另有 {count} 项,可在「查看」中读取`,"detail.status.running":`运行中`,"detail.status.idle":`空闲`,"detail.status.ready":`就绪`,"detail.status.inactive":`未运行`,"detail.status.provisioning":`准备中`,"detail.status.failed":`失败`,"detail.status.completed":`已完成`,"detail.status.deleted":`已删除`,"detail.status.killed":`已取消`,"detail.status.accepted":`已接收`,"detail.status.queued":`已入队`,"detail.status.exited":`已退出`,"detail.field.id":`ID`,"detail.field.revision":`版本`,"detail.field.platform":`平台`,"detail.field.provider":`提供方`,"detail.field.model":`模型`,"detail.field.role":`角色`,"detail.field.context":`上下文`,"detail.field.owner":`负责人`,"detail.field.ready":`可开始`,"detail.field.dependencies":`前置任务`,"detail.field.writeScopes":`文件范围`,"detail.field.warnings":`提示`,"detail.field.diagnostics":`诊断`,"detail.field.methods":`方法`,"detail.field.inputSchema":`输入 Schema`,"detail.field.outputSchema":`输出 Schema`,"detail.field.currentPackage":`当前包`,"detail.field.nextPackage":`待运行的包`,"detail.field.latestRun":`最近运行`,"detail.field.packages":`版本包`,"detail.field.registrations":`注册项`,"detail.field.props":`属性`,"detail.field.data":`数据`,"detail.field.source":`来源`,"detail.field.content":`内容`,"detail.field.message":`消息`,"detail.field.messageId":`消息 ID`,"detail.field.root":`根节点`,"detail.field.pid":`进程 ID`,"detail.field.type":`类型`,"detail.field.time":`时间`,"detail.field.seq":`事件序号`,"detail.field.turn":`轮次`,"detail.field.step":`步骤`,"detail.field.callId":`调用 ID`,"detail.field.agents":`启动智能体数`,"detail.field.result":`结果`,"detail.field.parent":`父级`,"detail.field.depth":`层级`,"detail.field.exitCode":`退出码`,"detail.field.signal":`信号`,"detail.field.previousStatus":`中断前状态`,"detail.field.agent":`智能体 ID`,"detail.field.job":`任务 ID`,"detail.field.task":`任务内容`,"detail.field.processGroup":`进程组`,"detail.field.availability":`可用状态`,"detail.field.bestMatch":`最相关事件`,"detail.field.target":`目标事件`,"detail.field.surface":`记录状态`,"detail.agents.count":`{count} 个智能体`,"detail.jobs.count":`{count} 个后台任务`,"detail.terminals.count":`{count} 个终端`,"detail.tasks.count":`{count} 个团队任务`,"detail.tasks.nextPage":`后面还有任务;下一页位置为 {cursor}`,"detail.locations.count":`{count} 个位置`,"detail.location":`第 {line} 行,第 {column} 列`,"detail.receipt.delivered":`消息已送达`,"detail.receipt.interrupt":`已请求中断`,"detail.receipt.started":`已启动`,"detail.receipt.cancel":`已请求取消`,"detail.receipt.alreadyFinished":`任务已结束`,"detail.receipt.signal":`信号已发送`,"detail.receipt.closed":`已关闭`,"detail.receipt.closing":`关闭中`,"detail.wait.noProgress":`没有正在运行的子智能体`,"detail.wait.title":`子智能体状态`,"detail.wait.timeout":`等待超时`,"detail.wait.changed":`检测到变化`,"detail.agent.reply":`智能体回复`,"detail.models.title":`可用模型`,"detail.output.lines":`第 {begin}–{end} 行,共 {total} 行`,"detail.output.truncated":`输出已截断`,"detail.providers.count":`{count} 个检查提供方`,"detail.plugins.count":`{count} 个动态插件`,"detail.workflow.script":`工作流脚本`,"detail.ralph.reportedComplete":`智能体报告完成`,"detail.ralph.reportedBlocker":`智能体报告受阻`,"detail.ralph.limit":`已达到轮次上限`,"detail.report.nextSteps":`待完成事项`,"detail.trace.replacedBy":`被替换为`,"detail.trace.replacementChain":`替换链`,"detail.trace.replaces":`替换的事件`,"detail.trace.sources":`引用来源`,"detail.trace.derived":`派生事件`,"detail.trace.ancestors":`祖先会话`,"detail.trace.descendants":`后代会话`,"detail.matches.count":`{count} 条匹配`,"detail.matches.capped":`已达到结果上限,可缩小搜索范围`,"detail.event.neighbors":`前后事件`,"todo.completed":`{done}/{total} 已完成`,"command.attachmentsUnsupported":`/{command} 不接受附件,请先移除附件`,"ask.rowTitle":`提问`,"ask.waiting":`等待回答`,"ask.pending":`已继续工作,仍可回答`,"ask.pendingDetail":`等待中的问题仍可在输入框中回答`,"ask.reopen":`回答`,"ask.review":`查看回答`,"ask.closed":`已结束`,"ask.closedDetail":`该问题已结束,结果见下方对话`,"ask.cancelled":`已取消`,"ask.cancelledDetail":`本轮已取消,未提交回答`,"ask.interrupted":`已中断`,"ask.interruptedDetail":`本轮已中断,未提交回答`,"ask.answered":`{answered}/{total} 已回答`,"ask.skipped":`未回答`,"bash.running":`运行中`,"bash.failed":`失败`,"bash.stopped":`已停止`,"tool.output.showFull":`显示完整输出(共 {size} KB)`,"tool.output.loading":`正在加载完整输出…`,"tool.output.retry":`重试加载完整输出`,"tool.output.failed":`加载失败,请重试。`,"tool.output.stale":`工具输出已变化,请刷新会话。`,"row.running":`运行中`,"row.preparing":`正在准备调用`,"row.failed":`失败`,"row.stopped":`已停止`,"row.input":`输入`,"row.output":`输出`,"row.inspect":`查看`,"tool.title.search":`搜索`,"tool.title.read":`读取`,"tool.title.bash":`运行命令`,"tool.title.write":`写入`,"tool.title.edit":`编辑`,"tool.title.filesChanging":`{count} 个文件已更改`,"tool.title.filesEdited":`已编辑 {count} 个文件`,"tool.title.code":`代码`,"tool.title.generic":`工具调用`,"tool.contextCompaction.action":`压缩上下文`,"tool.contextCompaction.running":`正在压缩…`,"tool.contextCompaction.completed":`上下文已压缩`,"tool.title.inspect":`查询 Cordis 环境`,"tool.title.runCordis":`运行 Cordis 插件`,"tool.title.stopCordis":`停止 Cordis 插件`,"tool.title.removeCordis":`移除 Cordis 插件`,"tool.title.pwsh":`运行命令`,"tool.title.readImage":`读取图片`,"tool.title.grep":`搜索文件内容`,"tool.title.glob":`查找文件`,"tool.title.webSearch":`网页搜索`,"tool.title.webFetch":`网页获取`,"tool.autoReviewRejected":`Auto review 已拒绝`,"tool.autoReviewNotExecuted":`工具未执行。原因:{reason}`,"tool.autoReviewReasonFallback":`Auto review 未授权此次操作`,"diff.collapseAria":`收起差异`,"diff.expandAria":`展开其余 {count} 行差异`,"diff.expandRest":`… 其余 {count} 行`,"read.window":`显示 {shown} / {total} 行`,"read.collapseAria":`收起内容`,"read.expandAria":`展开其余 {count} 行`,"read.expandRest":`… 其余 {count} 行`,"search.paths":`{shown} 个路径`,"search.paths.truncated":`显示 {shown} / 共 {total} 个路径`,"search.matches":`{shown} 处匹配 · {files} 个文件`,"search.matches.truncated":`显示 {shown} / 共 {total} 处匹配 · {files} 个文件`,"search.noResults":`无结果`,"search.collapseAria":`收起结果`,"search.expandAria":`展开其余 {count} 行结果`,"search.expandRest":`… 其余 {count} 行`,"web.noResults":`未找到结果`,"web.sourcesTruncated":`来源列表已截断`,"web.http":`HTTP`,"web.contentTruncated":`内容已截断`,"details.running":`运行中…`,"queue.count":`{n} 条排队消息`,"queue.sending":`发送中…`,"queue.image":`排队消息图片`,"queue.file":`排队文件 {name}`,"queue.edit":`编辑排队消息`,"queue.edit.unsupported":`包含暂不支持编辑的内容`,"queue.save":`保存排队消息`,"queue.cancelEdit":`取消编辑`,"queue.remove":`删除排队消息`,"queue.steer":`插话发送`,"queue.steer.unavailable":`仅运行中可插话发送`,"queue.resume":`继续队列`,"queue.paused.interrupted":`队列已因你中断当前任务而暂停。请选择一条继续。`,"queue.paused.unknown":`任务结果未知,队列已暂停且不会自动重试。`,"queue.paused.failed":`上一项未正常完成,队列已暂停。`,"error.sessionInUse":`当前会话已被占用,可能是其他正在运行的 DSH 导致的(如其他 dsh web、桌面端),请退出其他正在运行的 DSH 后重试。`,"error.steerTurnChanged":`你要插话的这一轮已经结束或切换,草稿已保留。`,"error.remoteSteerUnavailable":`当前连接无法确认插话的目标轮次,草稿已保留。`,"queue.editFailed":`编辑失败:这条消息可能已经开始发送。`,"queue.removeFailed":`删除失败:这条消息可能已经开始发送。`,"queue.steerFailed":`插话发送失败,请重试。`,"queue.resumeFailed":`继续队列失败,请重试。`,"queue.remoteActionFailed":`远程队列操作未确认,请先查看队列和会话状态。`,"queue.remoteStartUnconfirmed":`消息已入队,启动尚未确认。请查看队列和会话,勿重发。`,"queue.remoteStale":`暂时无法刷新远程队列。`,"terminal.signal":`信号 {signal}`,"terminal.exitCode":`退出码 {code}`,"terminal.noExitCode":`未正常退出`,"terminal.running":`运行中`,"terminal.failed":`失败`,"terminal.done":`已完成`,"terminal.noOutput":`无输出`,"terminal.collapseAria":`收起输出`,"terminal.expandAria":`展开其余 {n} 行输出`,"terminal.expandRest":`… 其余 {n} 行`,"terminal.sendInput":`(发送输入)`,"terminal.session":`终端 {sessionId}`},pd={"shortcut.newline":`New line`,"shortcut.complementary":`Use the complementary Queue / Steer action`,"shortcut.slash":`Open command menu`,"shortcut.mention":`Open reference menu`,"hint.plan":dd,"hint.goal":`describe the objective for a long-running task`,"hint.goal.active":`goal active — edit / pause / resume / clear`,"placeholder.plan":dd,"placeholder.default":`Message or run a task, / commands, @ files or sessions`,"placeholder.unavailable":`Session unavailable`,"placeholder.parentOffline":`Parent session offline; sending is unavailable but you can still stop the run`,"placeholder.hero":`Describe what you want to build, / commands, @ files or sessions`,"placeholder.workspace":`Choose a workspace to start`,"placeholder.preparing":`Preparing conversation…`,"placeholder.loadFailed":`Failed to load session. Retry or check the remote host.`,"placeholder.loadUnsupported":`Remote host version does not support loading this session. Update the remote host and retry.`,"placeholder.steerQueue":`Cmd/Ctrl+Enter steers all queued messages`,"newSession.loadingModel":`Loading models…`,"newSession.loadingHarness":`Loading Harness…`,"newSession.createFailedTitle":`Couldn’t start a new session`,"newSession.createFailed.noHarness":`No Harness is available. Check your settings and try again.`,"newSession.createFailed.workspaceRequired":`Choose a workspace before starting a new session.`,"newSession.createFailed.generic":`Unable to start a new session right now. Please try again.`,"newSession.retry":`Retry`,"newSession.uploadUnavailable":`Wait for the new session to finish loading before adding files`,"input.commands":`Add files or run commands`,"input.commandsOnly":`Run commands`,"input.imagesAndCommands":`Add images or run commands`,"attachment.unavailable":`Attachment uploads are unavailable on this Web connection.`,"input.file":`File`,"input.stop":`Stop generating`,"input.send":`Send message`,"input.send.queue":`Queue message`,"input.send.steer":`Steer message`,"attachment.pending":`Pending attachments`,"annotation.rail":`Selected text attached to this message`,"annotation.remove":`Remove annotation {index}`,"annotation.trayCount":`Comments ({count})`,"annotation.clearAll":`Clear all`,"annotation.emptyComment":`Quote only · click to add a note`,"annotation.editHint":`Edit annotation {index}`,"annotation.revealHint":`Reveal annotation {index} in response`,"attachment.scrollLeft":`Scroll attachments left`,"attachment.scrollRight":`Scroll attachments right`,"reference.dropTitle":`Release to reference chat`,"attachment.dropTitle":`Drag files or images here to add them`,"attachment.dropDesc":`Image limit: up to {count} images, {size} each`,"attachment.dropBlocked":`Files and images cannot be added right now`,"attachment.directoryDesktopOnly":`Folders can only be added in the desktop app; add individual files in the browser`,"attachment.pathUnavailable":`Could not obtain the folder path; drag it in again`,"attachment.pathUnsupported":`The path contains characters a reference cannot carry; rename it and try again`,"image.pending":`Pending images`,"image.openOriginal":`View original`,"image.openOriginalLabel":`{label}, click to view original`,"image.remove":`Remove image {name}`,"image.retry":`Retry`,"image.original":`Original image`,"image.label":`Image`,"image.loadFailed":`Image unavailable; click to retry`,"image.previewTooLarge":`Image too large to preview (maximum 50 MiB and 64 million pixels)`,"image.loading":`Loading image…`,"image.preview":`Original image preview`,"image.closePreview":`Close original image preview`,"image.unsupportedType":`Only PNG, JPG, WebP, and GIF images are supported`,"image.tooMany":`A message can include up to {count} images`,"image.fileTooLarge":`Each image must be smaller than {size}`,"image.totalTooLarge":`Images exceed {size} in total; remove some and try again`,"image.tooManyPixels":`Image resolution is too high; compress it and try again`,"image.modelUnsupported":`The current model does not support images; switch to a model that does`,"image.sendFailed":`Sending images failed ({reason}); re-add them and try again`,"file.unavailable":`The uploaded file is unavailable or changed; select it again`,"file.pending":`Pending files`,"file.remove":`Remove file {name}`,"file.uploading":`Uploading…`,"file.uploadingPercent":`Uploading {percent}%`,"file.uploadFailed":`Upload failed; click to retry`,"file.retry":`Retry uploading {name}`,"file.retryOrRemove":`Retry or remove failed attachments before sending`,"file.sessionUnavailable":`Session unavailable; files cannot be uploaded`,"file.notStaged":`The file has not finished uploading; re-add it and try again`,"file.label":`File`,"context.aria":`{percent} of context used`,"context.used":`of context used`,"context.system":`System prompt`,"context.tools":`Tool definitions`,"context.messages":`Messages`,"settings.enter.title":`Send behavior while busy`,"settings.enter.description":`What Enter and the Send button do while the agent is running; Cmd/Ctrl+Enter uses the other behavior`,"settings.enter.queue":`Queue`,"settings.enter.steer":`Steer`,"hero.headline":`What should we build today?`,"hero.preview":`Web`,"hero.previewDesktop":`CH Desktop`,"hero.chooseWorkspace":`Choose workspace`,"hero.noWorkspace":`No workspace`,"session.hierarchy":`Session hierarchy`,"todo.title":`To-dos`,"todo.progress.done":`{done} completed`,"todo.progress.active":`{active} in progress`,"todo.progress.pending":`{pending} pending`,"todo.status.completed":`Completed`,"todo.status.inProgress":`In progress`,"todo.status.pending":`Pending`,"todo.rowTitle":`Update to-do list`,"tool.title.createGoal":`Create goal`,"tool.title.getGoal":`View goal`,"tool.title.updateGoal":`Update goal`,"tool.preparing.content":`{kilobytes}KB`,"tool.title.createSchedule":`Create reminder`,"tool.title.listSchedules":`List reminders`,"tool.title.deleteSchedule":`Delete reminder`,"tool.title.updateSchedule":`Update reminder`,"detail.state":`Status`,"detail.todo.completed":`Completed`,"detail.todo.in_progress":`In progress`,"detail.todo.pending":`Pending`,"detail.todo.empty":`The to-do list is empty`,"todo.diff.initial":`Initial list`,"todo.diff.compare":`Changes since the previous list`,"todo.diff.unavailable":`Previous list unavailable`,"todo.diff.noChanges":`No changes to the list`,"todo.diff.added":`{count} added`,"todo.diff.updated":`{count} updated`,"todo.diff.removed":`{count} removed`,"todo.diff.unchanged":`{count} unchanged`,"todo.diff.addedItem":`Added`,"todo.diff.updatedItem":`Status changed`,"todo.diff.movedItem":`Reordered`,"todo.diff.removedItem":`Removed`,"detail.goal.empty":`No goal`,"detail.goal.active":`Active`,"detail.goal.disarmed":`Awaiting continuation`,"detail.goal.paused":`Paused`,"detail.goal.blocked":`Blocked`,"detail.goal.complete":`Completed`,"detail.goal.rounds":`Rounds`,"detail.goal.reason":`Blocker`,"detail.days":`{count} d`,"detail.hours":`{count} h`,"detail.minutes":`{count} min`,"detail.seconds":`{count} s`,"detail.schedule.once":`Once`,"detail.schedule.every":`Every {interval}`,"detail.schedule.when":`Scheduled for`,"detail.schedule.frequency":`Repeat`,"detail.schedule.scheduled":`Scheduled`,"detail.schedule.overdue":`Overdue, awaiting session resume`,"detail.schedule.empty":`No reminders`,"detail.schedule.deleted":`Deleted`,"detail.schedule.count":`{count} reminders`,"detail.schedule.daily":`Every day at {time} ({zone})`,"detail.schedule.weekly":`Weekly on {days} at {time} ({zone})`,"detail.schedule.cron":`Cron {expression} ({zone})`,"detail.weekday.1":`Mon`,"detail.weekday.2":`Tue`,"detail.weekday.3":`Wed`,"detail.weekday.4":`Thu`,"detail.weekday.5":`Fri`,"detail.weekday.6":`Sat`,"detail.weekday.7":`Sun`,"detail.weekday.join":`, `,"tool.title.inspectProviders":`Inspect providers`,"tool.title.queryRuntime":`Query runtime`,"tool.title.inspectPlugins":`Inspect plugins`,"tool.title.workflow":`Run workflow`,"tool.title.ralph":`Run ralph loop`,"tool.title.readEvent":`Read event`,"tool.title.searchEvents":`Search events`,"tool.title.traceEvent":`Trace event`,"tool.title.searchSessions":`Search sessions`,"tool.title.traceSession":`Trace session`,"tool.title.listModels":`List models`,"tool.title.subagent":`Create subagent`,"tool.title.listAgents":`List subagents`,"tool.title.sendMessage":`Send message`,"tool.title.interruptAgent":`Interrupt agent`,"tool.title.listJobs":`List background jobs`,"tool.title.readJob":`Read job output`,"tool.title.killJob":`Cancel background job`,"tool.title.openTerminal":`Open terminal`,"tool.title.readTerminal":`Read terminal`,"tool.title.listTerminals":`List terminals`,"tool.title.signalTerminal":`Signal terminal`,"tool.title.closeTerminal":`Close terminal`,"tool.title.lsp":`Query code symbols`,"tool.title.findDefinition":`Find definition`,"tool.title.findReferences":`Find references`,"tool.title.findImplementation":`Find implementation`,"tool.title.hoverSymbol":`Inspect symbol`,"tool.title.spawnTeammate":`Create teammate`,"tool.title.createTeamTask":`Create team task`,"tool.title.getTeamTask":`Read team task`,"tool.title.updateTeamTask":`Update team task`,"tool.title.listTeamTasks":`List team tasks`,"tool.title.waitAgent":`Wait for subagent`,"detail.recordedResult":`Recorded result`,"detail.empty":`No results`,"detail.none":`None`,"detail.yes":`Yes`,"detail.no":`No`,"detail.moreInInspect":`{count} more items available in Inspect`,"detail.status.running":`Running`,"detail.status.idle":`Idle`,"detail.status.ready":`Ready`,"detail.status.inactive":`Inactive`,"detail.status.provisioning":`Provisioning`,"detail.status.failed":`Failed`,"detail.status.completed":`Completed`,"detail.status.deleted":`Deleted`,"detail.status.killed":`Cancelled`,"detail.status.accepted":`Accepted`,"detail.status.queued":`Queued`,"detail.status.exited":`Exited`,"detail.field.id":`ID`,"detail.field.revision":`Revision`,"detail.field.platform":`Platform`,"detail.field.provider":`Provider`,"detail.field.model":`Model`,"detail.field.role":`Role`,"detail.field.context":`Context`,"detail.field.owner":`Owner`,"detail.field.ready":`Ready`,"detail.field.dependencies":`Dependencies`,"detail.field.writeScopes":`Write scopes`,"detail.field.warnings":`Warnings`,"detail.field.diagnostics":`Diagnostics`,"detail.field.methods":`Methods`,"detail.field.inputSchema":`Input schema`,"detail.field.outputSchema":`Output schema`,"detail.field.currentPackage":`Current package`,"detail.field.nextPackage":`Next package`,"detail.field.latestRun":`Latest run`,"detail.field.packages":`Packages`,"detail.field.registrations":`Registrations`,"detail.field.props":`Props`,"detail.field.data":`Data`,"detail.field.source":`Source`,"detail.field.content":`Content`,"detail.field.message":`Message`,"detail.field.messageId":`Message ID`,"detail.field.root":`Root`,"detail.field.pid":`Process ID`,"detail.field.type":`Type`,"detail.field.time":`Time`,"detail.field.seq":`Event sequence`,"detail.field.turn":`Turn`,"detail.field.step":`Step`,"detail.field.callId":`Call ID`,"detail.field.agents":`Agents started`,"detail.field.result":`Result`,"detail.field.parent":`Parent`,"detail.field.depth":`Depth`,"detail.field.exitCode":`Exit code`,"detail.field.signal":`Signal`,"detail.field.previousStatus":`Previous status`,"detail.field.agent":`Agent ID`,"detail.field.job":`Job ID`,"detail.field.task":`Task`,"detail.field.processGroup":`Process group`,"detail.field.availability":`Availability`,"detail.field.bestMatch":`Best match`,"detail.field.target":`Target event`,"detail.field.surface":`Record status`,"detail.agents.count":`{count} agents`,"detail.jobs.count":`{count} background jobs`,"detail.terminals.count":`{count} terminals`,"detail.tasks.count":`{count} team tasks`,"detail.tasks.nextPage":`More tasks available; next cursor is {cursor}`,"detail.locations.count":`{count} locations`,"detail.location":`Line {line}, column {column}`,"detail.receipt.delivered":`Message delivered`,"detail.receipt.interrupt":`Interrupt requested`,"detail.receipt.started":`Started`,"detail.receipt.cancel":`Cancellation requested`,"detail.receipt.alreadyFinished":`Already finished`,"detail.receipt.signal":`Signal delivered`,"detail.receipt.closed":`Closed`,"detail.receipt.closing":`Closing`,"detail.wait.noProgress":`No active subagents`,"detail.wait.title":`Subagent activity`,"detail.wait.timeout":`Wait timed out`,"detail.wait.changed":`Change detected`,"detail.agent.reply":`Agent response`,"detail.models.title":`Available models`,"detail.output.lines":`Lines {begin}–{end} of {total}`,"detail.output.truncated":`Output truncated`,"detail.providers.count":`{count} inspect providers`,"detail.plugins.count":`{count} dynamic plugins`,"detail.workflow.script":`Workflow script`,"detail.ralph.reportedComplete":`Worker reported completion`,"detail.ralph.reportedBlocker":`Worker reported a blocker`,"detail.ralph.limit":`Round limit reached`,"detail.report.nextSteps":`Remaining work`,"detail.trace.replacedBy":`Replaced by`,"detail.trace.replacementChain":`Replacement chain`,"detail.trace.replaces":`Replaced events`,"detail.trace.sources":`Source events`,"detail.trace.derived":`Derived events`,"detail.trace.ancestors":`Ancestor sessions`,"detail.trace.descendants":`Descendant sessions`,"detail.matches.count":`{count} matches`,"detail.matches.capped":`Result limit reached; narrow the search for more`,"detail.event.neighbors":`Surrounding events`,"todo.completed":`{done}/{total} completed`,"command.attachmentsUnsupported":`/{command} does not accept attachments; remove them first`,"ask.rowTitle":`Ask question`,"ask.waiting":`waiting`,"ask.pending":`continued; answer still available`,"ask.pendingDetail":`These pending questions remain answerable from the composer.`,"ask.reopen":`Answer`,"ask.review":`View answers`,"ask.closed":`closed`,"ask.closedDetail":`This question is closed; its outcome is in the conversation below.`,"ask.cancelled":`cancelled`,"ask.cancelledDetail":`This question set was cancelled before answers were submitted.`,"ask.interrupted":`interrupted`,"ask.interruptedDetail":`This question set was interrupted before answers were submitted.`,"ask.answered":`{answered}/{total} answered`,"ask.skipped":`Not answered`,"bash.running":`Running`,"bash.failed":`Failed`,"bash.stopped":`Stopped`,"tool.output.showFull":`Show full output ({size} KB total)`,"tool.output.loading":`Loading full output…`,"tool.output.retry":`Retry loading full output`,"tool.output.failed":`Could not load output. Please retry.`,"tool.output.stale":`Tool output changed. Refresh the conversation.`,"row.running":`Running`,"row.preparing":`Preparing tool call`,"row.failed":`Failed`,"row.stopped":`Stopped`,"row.input":`IN`,"row.output":`OUT`,"row.inspect":`Inspect`,"tool.title.search":`Search`,"tool.title.read":`Read`,"tool.title.bash":`Bash`,"tool.title.write":`Write`,"tool.title.edit":`Edit`,"tool.title.filesChanging":`{count} files changed`,"tool.title.filesEdited":`Edited {count} files`,"tool.title.code":`Code`,"tool.title.generic":`Tool call`,"tool.contextCompaction.action":`Compact context`,"tool.contextCompaction.running":`Compacting context…`,"tool.contextCompaction.completed":`Context compacted`,"tool.title.inspect":`Query Cordis environment`,"tool.title.runCordis":`Run Cordis Plugin`,"tool.title.stopCordis":`Stop Cordis Plugin`,"tool.title.removeCordis":`Remove Cordis Plugin`,"tool.title.pwsh":`Pwsh`,"tool.title.readImage":`Read image`,"tool.title.grep":`Grep`,"tool.title.glob":`Glob`,"tool.title.webSearch":`Search`,"tool.title.webFetch":`Fetch`,"tool.autoReviewRejected":`Rejected by Auto review`,"tool.autoReviewNotExecuted":`Tool was not executed. Reason: {reason}`,"tool.autoReviewReasonFallback":`Auto review did not authorize this action`,"diff.collapseAria":`Collapse diff`,"diff.expandAria":`Expand {count} more diff lines`,"diff.expandRest":`… {count} more lines`,"read.window":`Showing {shown} of {total} lines`,"read.collapseAria":`Collapse content`,"read.expandAria":`Expand {count} more lines`,"read.expandRest":`… {count} more lines`,"search.paths":`{shown} paths`,"search.paths.truncated":`Showing {shown} of {total} paths`,"search.matches":`{shown} matches · {files} files`,"search.matches.truncated":`Showing {shown} of {total} matches · {files} files`,"search.noResults":`No results`,"search.collapseAria":`Collapse results`,"search.expandAria":`Expand {count} more result lines`,"search.expandRest":`… {count} more lines`,"web.noResults":`No results found`,"web.sourcesTruncated":`Source list truncated`,"web.http":`HTTP`,"web.contentTruncated":`Content truncated`,"details.running":`Running…`,"queue.count":`{n} queued messages`,"queue.sending":`Sending…`,"queue.image":`Queued message image`,"queue.file":`Queued file {name}`,"queue.edit":`Edit queued message`,"queue.edit.unsupported":`Contains content that cannot be edited yet`,"queue.save":`Save queued message`,"queue.cancelEdit":`Cancel editing`,"queue.remove":`Remove queued message`,"queue.steer":`Steer queued message`,"queue.steer.unavailable":`Steering is available only while the agent is running`,"queue.resume":`Resume queue`,"queue.paused.interrupted":`Queue paused because you interrupted. Choose a message to resume.`,"queue.paused.unknown":`Outcome unknown. The queue is paused and will not retry automatically.`,"queue.paused.failed":`The previous turn did not finish normally. The queue is paused.`,"error.sessionInUse":`This session is already in use, possibly by another running DSH instance (such as dsh web or the desktop app). Quit other running DSH instances and try again.`,"error.steerTurnChanged":`The turn you tried to steer ended or changed. Your draft was kept.`,"error.remoteSteerUnavailable":`This connection cannot confirm the target turn for steering. Your draft was kept.`,"queue.editFailed":`Edit failed: this message may have already started sending.`,"queue.removeFailed":`Removal failed: this message may have already started sending.`,"queue.steerFailed":`Steering failed. Try again.`,"queue.resumeFailed":`Could not resume the queue. Try again.`,"queue.remoteActionFailed":`Remote queue action was not confirmed. Check the queue and chat.`,"queue.remoteStartUnconfirmed":`Message queued. Its start is unconfirmed. Check the queue and chat. Do not resend.`,"queue.remoteStale":`The remote queue could not be refreshed.`,"terminal.signal":`signal {signal}`,"terminal.exitCode":`exit code {code}`,"terminal.noExitCode":`no exit code`,"terminal.running":`Running`,"terminal.failed":`Failed`,"terminal.done":`Done`,"terminal.noOutput":`No output`,"terminal.collapseAria":`Collapse output`,"terminal.expandAria":`Expand the remaining {n} output lines`,"terminal.expandRest":`… {n} more lines`,"terminal.sendInput":`(send input)`,"terminal.session":`Terminal {sessionId}`},md=2048;function hd(e){return e===`image/jpeg`||e===`image/webp`||e===`image/png`}function gd(e,t){return e===``?``:`${e.replace(/\.[^.]*$/u,``)}${t}`}function _d(e,t,n){if(typeof OffscreenCanvas==`function`&&typeof OffscreenCanvas.prototype.convertToBlob==`function`){let r=new OffscreenCanvas(t,n),i=r.getContext(`2d`);return i===null?(r.width=0,r.height=0,null):(i.drawImage(e,0,0,t,n),r)}if(typeof document>`u`||typeof document.createElement!=`function`)return null;let r=document.createElement(`canvas`);r.width=t,r.height=n;let i=r.getContext(`2d`);return i===null?(r.width=0,r.height=0,null):(i.drawImage(e,0,0,t,n),r)}async function vd(e,t,n){try{if(`convertToBlob`in e&&typeof e.convertToBlob==`function`)return await e.convertToBlob(n===void 0?{type:t}:{type:t,quality:n});let r=e;return await new Promise(e=>r.toBlob(e,t,n))}catch{return null}}async function yd(e){if(!hd(e.type))return e;let t,n=null;try{t=await createImageBitmap(e,{imageOrientation:`from-image`});let r=Math.max(t.width,t.height);if(r<=md&&e.size<=1048576)return e;let i=Math.min(1,md/r),a=Math.max(1,Math.round(t.width*i)),o=Math.max(1,Math.round(t.height*i));if(n=_d(t,a,o),n===null)return e;if(e.type===`image/png`){let t=await vd(n,`image/webp`,.9);if(t!==null&&t.type===`image/webp`)return t.size===0||t.size>=e.size?e:new File([t],gd(e.name,`.webp`),{type:`image/webp`,lastModified:e.lastModified});if(i<1){let r=t!==null&&t.type===`image/png`?t:await vd(n,`image/png`);if(r!==null&&r.type===`image/png`&&r.size>0&&r.size<e.size)return new File([r],e.name,{type:`image/png`,lastModified:e.lastModified})}return e}let s=await vd(n,`image/jpeg`,.85);return s===null||s.type!==`image/jpeg`||s.size===0||s.size>=e.size?e:new File([s],gd(e.name,`.jpg`),{type:`image/jpeg`,lastModified:e.lastModified})}catch{return e}finally{n!==null&&(n.width=0,n.height=0),t?.close()}}function bd(e){return{kind:`image`,id:yt(),previewUrl:URL.createObjectURL(e),file:e}}function xd(e){if(typeof Image!=`function`)return;let t=new Image,n=()=>{t.onload=null,t.onerror=null,t.src=``};t.onload=()=>{try{e.width=t.naturalWidth,e.height=t.naturalHeight}finally{n()}},t.onerror=()=>{n()};try{t.src=e.previewUrl}catch{n()}}function Sd(){return new Promise(e=>{if(typeof requestAnimationFrame==`function`){if(typeof document<`u`&&document.visibilityState===`hidden`){setTimeout(e,0);return}let t=!1,n=()=>{t||(t=!0,clearTimeout(r),setTimeout(e,0))},r=setTimeout(n,100);requestAnimationFrame(n)}else setTimeout(e,0)})}var Cd=class extends m.Service{input;blocks;fileUploads=(0,f.createSnapshotStore)({});draftAttachments=/* @__PURE__ */ new Map;preparedPhotos=/* @__PURE__ */ new WeakMap;fileUploadOperations=/* @__PURE__ */ new Map;pendingFileUploads=/* @__PURE__ */ new Set;fileUploadQueue=[];uploadSessions=/* @__PURE__ */ new Map;foregroundRetried=/* @__PURE__ */ new Set;activeFileUploads=0;maxConcurrentFileUploads;constructor(e,t){super(e,`conversation`),this.input=t.input,this.blocks=t.blocks,this.maxConcurrentFileUploads=t.maxConcurrentFileUploads,e.effect(()=>{if(typeof document>`u`)return;let e=()=>{if(document.visibilityState===`visible`)for(let[e,t]of this.uploadSessions){let n=this.fileUploads.getSnapshot()[e];n?.status===`error`&&n.transport&&!this.foregroundRetried.has(e)&&(this.foregroundRetried.add(e),this.retryFileUpload(t,e))}};return document.addEventListener(`visibilitychange`,e),()=>document.removeEventListener(`visibilitychange`,e)},`conversation foreground upload retry`),e.effect(()=>async()=>{let e=[...this.fileUploadOperations.values()];for(let t of e)t.controller.abort();await Promise.allSettled([...this.pendingFileUploads]),this.fileUploadOperations.clear(),this.fileUploadQueue.length=0;for(let e of this.draftAttachments.values())e.kind===`image`&&Td(e.previewUrl);this.draftAttachments.clear(),this.uploadSessions.clear(),this.foregroundRetried.clear(),this.fileUploads.set({})},`conversation draft attachments`)}async send(e){let t=await this.scopedSession(`send`).prompt([{type:`text`,text:e}],`queue`);if(!t.ok)throw Error(`conversation.send failed: ${t.error.code}: ${t.error.message}`)}async sendSession(e,t,n,r,i,a){let o=n.length===0?void 0:this.requireSessions().retain(e.sessionId,{source:`controllerOperation`});try{let o=this.resolveDraftAttachments(n);if(o.length!==n.length)throw Error(`conversation.sendSession: one or more draft attachments are no longer available`);this.assertUploadsNotFailed(n);let s=o.map(e=>({upload:{subscribe:this.fileUploads.subscribe,getSnapshot:()=>this.fileUploads.getSnapshot()[e.id]},...e.kind===`image`?{type:`image`,value:{previewUrl:e.previewUrl,...e.file.name===``?{}:{name:e.file.name},...e.width===void 0?{}:{width:e.width},...e.height===void 0?{}:{height:e.height}}}:{type:`file`,value:{attachmentId:e.id,name:`file`in e?e.file.name:e.stored.name,bytes:`file`in e?e.file.size:e.stored.bytes}}})),c=async()=>(await this.serializeDraftAttachments(n)).attachments;if(e.getSnapshot().subagent!==null){let n=[...await c(),...t===``?[]:[{type:`text`,text:t}]];return(await e.prompt(n,r,i)).ok?{kind:`success`}:{kind:`error`}}let l,u=o.length===0?void 0:new Promise(e=>{l=e}),d=e.beginSubmission({mode:r,text:t,attachments:s,onObserved:t=>{this.aliasObservedAttachments(e.sessionId,o,t)},onRetire:t=>{this.settleSubmittedAttachments(e.sessionId,o,t),l?.(t)}});a?.(d.requestId);let f;try{await Sd(),f=[...await c(),...t===``?[]:[{type:`text`,text:t}]]}catch(e){throw d.abandon(),e}let p=await e.prompt(f,r,i,d.requestId);return!p.ok||u!==void 0&&(await u).reason!==`observed`?{kind:`error`}:p.value.queueStartUnconfirmed?{kind:`success`,text:this.ctx.locale.bind(ld)(`queue.remoteStartUnconfirmed`)}:{kind:`success`}}finally{o?.release()}}createDrafts(e,t){return t.map(t=>{if(wd(t.type)){let n=bd(t);return this.draftAttachments.set(n.id,n),xd(n),this.beginFileUpload(e,n),n}let n={kind:`file`,id:yt(),file:t};return this.draftAttachments.set(n.id,n),this.beginFileUpload(e,n),n})}restoreStagedDrafts(e,t){let n=[],r=[];for(let i of t){let t;if(i.kind===`image`&&i.imageFile!==void 0){let n=bd(i.imageFile);xd(n),t=n,this.ctx.get(`uiConversation`)?.cacheUploadedImage(e,{attachmentId:i.file.attachmentId,blob:i.imageFile,name:i.file.name,bytes:i.file.bytes,...n.width===void 0?{}:{width:n.width},...n.height===void 0?{}:{height:n.height}})}else t={kind:`file`,id:yt(),stored:i.file};this.draftAttachments.set(t.id,t),this.uploadSessions.set(t.id,e),n.push([t.id,{status:`ready`,receiptId:i.receiptId,file:i.file}]),r.push(t)}return n.length>0&&this.fileUploads.update(e=>{for(let[t,r]of n)e[t]=r}),r}retryFileUpload(e,t){let n=this.draftAttachments.get(t);n!==void 0&&(n.kind!==`file`||`file`in n)&&this.fileUploads.getSnapshot()[t]?.status===`error`&&this.beginFileUpload(e,n)}rebindDraftFiles(e,t){for(let n of t){let t=this.draftAttachments.get(n);t!==void 0&&(t.kind===`file`&&!(`file`in t)?(this.uploadSessions.delete(n),this.fileUploads.update(e=>{e[n]={status:`error`,message:this.ctx.locale.bind(ld)(`file.unavailable`),transport:!1}})):this.beginFileUpload(e,t))}}beginFileUpload(e,t){this.uploadSessions.set(t.id,e),this.fileUploadOperations.get(t.id)?.controller.abort();let n=new AbortController;this.fileUploads.update(e=>{e[t.id]={status:`uploading`,loaded:0,total:t.file.size}});let r,i=new Promise(e=>{r=e});this.fileUploadOperations.set(t.id,{controller:n,done:i}),this.pendingFileUploads.add(i),i.then(()=>{this.pendingFileUploads.delete(i)}),this.fileUploadQueue.push({run:async()=>{try{if(n.signal.aborted||this.fileUploadOperations.get(t.id)?.controller!==n)return;let r=t.file;if(t.kind===`image`&&hd(r.type)){let e=this.preparedPhotos.get(t);if(e===void 0&&(e=yd(r),this.preparedPhotos.set(t,e)),r=await e,n.signal.aborted||this.fileUploadOperations.get(t.id)?.controller!==n)return;this.fileUploads.update(e=>{t.id in e&&(e[t.id]={status:`uploading`,loaded:0,total:r.size})})}let i=await this.ctx.fileUpload.upload(e,r,r.name===``?void 0:r.name,n.signal,e=>{this.fileUploadOperations.get(t.id)?.controller===n&&this.fileUploads.update(n=>{t.id in n&&(n[t.id]={status:`uploading`,loaded:e.loaded,...e.total===void 0?{}:{total:e.total}})})},t.kind===`image`?r.type:void 0);if(this.fileUploadOperations.get(t.id)?.controller!==n)return;i.ok&&t.kind===`image`&&this.ctx.get(`uiConversation`)?.cacheUploadedImage(e,{attachmentId:i.value.file.attachmentId,blob:r,name:i.value.file.name,bytes:i.value.file.bytes,...t.width===void 0?{}:{width:t.width},...t.height===void 0?{}:{height:t.height}}),this.fileUploads.update(e=>{t.id in e&&(e[t.id]=i.ok?{status:`ready`,receiptId:i.value.receiptId,file:i.value.file}:{status:`error`,message:i.error.message,transport:!1})})}catch(e){if(this.fileUploadOperations.get(t.id)?.controller!==n)return;this.fileUploads.update(n=>{t.id in n&&(n[t.id]={status:`error`,message:e instanceof Error?e.message:String(e),transport:!0})})}finally{this.fileUploadOperations.get(t.id)?.controller===n&&this.fileUploadOperations.delete(t.id)}},settle:r}),this.pumpFileUploads()}pumpFileUploads(){for(;this.activeFileUploads<this.maxConcurrentFileUploads;){let e=this.fileUploadQueue.shift();if(e===void 0)return;this.activeFileUploads+=1,e.run().finally(()=>{--this.activeFileUploads,e.settle(),this.pumpFileUploads()})}}resolveDraftAttachments(e){let t=[];for(let n of e){let e=this.draftAttachments.get(n);e!==void 0&&t.push(e)}return t}async serializeDraftAttachments(e){let t=this.resolveDraftAttachments(e);if(t.length!==e.length)throw Error(`conversation.serializeDraftAttachments: one or more draft attachments are no longer available`);await this.waitForUploads(e);let n=this.fileUploads.getSnapshot();return{attachments:t.map(e=>({type:`file`,receiptId:n[e.id].receiptId}))}}releaseDraftAttachment(e){let t=this.draftAttachments.get(e);if(t===void 0)return;let n=this.uploadSessions.get(e),r=this.fileUploads.getSnapshot()[e],i=this.fileUploadOperations.get(e);this.fileUploadOperations.delete(e),i?.controller.abort(),this.draftAttachments.delete(e),this.uploadSessions.delete(e),this.foregroundRetried.delete(e),t.kind===`image`&&(n!==void 0&&r?.status===`ready`&&this.ctx.get(`uiConversation`)?.clearPendingUploadedImage(n,r.file.attachmentId),Td(t.previewUrl)),this.fileUploads.set(Object.fromEntries(Object.entries(this.fileUploads.getSnapshot()).filter(([t])=>t!==e)))}releaseDraftAttachments(e){for(let t of e)this.releaseDraftAttachment(t.id)}async updateQueue(e,t){let n=await this.scopedSession(`updateQueue`).updateQueue(e,t);if(!n.ok){if(t.kind===`steer`&&(n.error.code===`session/steer-unavailable`||n.error.code===`session/queue-item-not-found`))return;throw Error(`conversation.updateQueue failed: ${n.error.code}: ${n.error.message}`)}}async cancel(){let e=await this.scopedSession(`cancel`).cancel();if(!e.ok)throw Error(`conversation.cancel failed: ${e.error.code}: ${e.error.message}`)}async loadOlder(){await this.scopedSession(`loadOlder`).loadOlder()}scopedSession(e){let t=this.scopeId(e),n=this.requireSessions().binding(t);if(n===void 0)throw Error(`conversation.${e}: session "${t}" resolved no binding`);return n.session}scopeId(e){let t=this.requireSessions().scopeOf(this.ctx);if(t===void 0)throw Error(`conversation.${e} requires a session scope — address one via ctx.sessions.scope(id).conversation`);return t}requireSessions(){let e=this.ctx.get(`sessions`);if(e===void 0)throw Error(`conversation: sessions service unavailable`);return e}aliasObservedAttachments(e,t,n){let r=this.ctx.get(`uiConversation`);if(r===void 0)return;let i=this.fileUploads.getSnapshot(),a=0;for(let o of t){let t=n[a++];if(this.draftAttachments.get(o.id)===void 0||o.kind!==`image`||t===void 0||!(`mediaType`in t))continue;let s=i[o.id],c=s?.status===`ready`?s.file.attachmentId:void 0;c!==void 0&&r.aliasUploadedImage(e,c,t)}}settleSubmittedAttachments(e,t,n){if(n.reason!==`observed`)return;let r=this.ctx.get(`uiConversation`),i=0;for(let a of t){let t=this.draftAttachments.get(a.id),o=n.attachments[i++];if(t===void 0)continue;if(a.kind===`file`){this.releaseDraftAttachment(a.id);continue}let s=this.fileUploads.getSnapshot()[a.id],c=s?.status===`ready`?s.file.attachmentId:void 0;if(this.uploadSessions.delete(a.id),this.foregroundRetried.delete(a.id),this.fileUploads.update(e=>{delete e[a.id]}),this.draftAttachments.delete(a.id),o!==void 0&&`mediaType`in o){if(c!==void 0&&r?.aliasUploadedImage(e,c,o)===!0){Td(a.previewUrl);continue}if(r?.seedImageUrl(e,o,a.previewUrl,a.file.size)===!0)continue}Td(a.previewUrl)}}assertUploadsNotFailed(e){if(e.some(e=>this.fileUploads.getSnapshot()[e]?.status===`error`))throw Error(this.ctx.locale.bind(ld)(`file.retryOrRemove`))}waitForUploads(e){return new Promise((t,n)=>{let r=()=>{let r=this.fileUploads.getSnapshot();e.some(e=>r[e]===void 0||r[e]?.status===`error`)?(i(),n(Error(this.ctx.locale.bind(ld)(`file.retryOrRemove`)))):e.every(e=>r[e]?.status===`ready`)&&(i(),t())},i=this.fileUploads.subscribe(r);r()})}};function wd(e){return e===`image/png`||e===`image/jpeg`||e===`image/webp`||e===`image/gif`}function Td(e){e.startsWith(`blob:`)&&URL.revokeObjectURL(e)}var Ed=class{stores=/* @__PURE__ */ new Map;set(e,t){let n=this.storeFor(e);n.getSnapshot()?.reason!==t?.reason&&n.set(t)}storeFor(e){let t=this.stores.get(e);if(t!==void 0)return t;let n=(0,f.createSnapshotStore)(void 0);return this.stores.set(e,n),n}forget(e){this.stores.delete(e)}};function F(e,...t){let n=new URL(`https://lexical.dev/docs/error`),r=new URLSearchParams;r.append(`code`,e);for(let e of t)r.append(`v`,e);throw n.search=r.toString(),Error(`Minified Lexical error #${e}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}function Dd(e,...t){let n=new URL(`https://lexical.dev/docs/error`),r=new URLSearchParams;r.append(`code`,e);for(let e of t)r.append(`v`,e);n.search=r.toString(),console.warn(`Minified Lexical warning #${e}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}let Od=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0,kd=Od&&`documentMode`in document?document.documentMode:null,Ad=Od&&/Mac|iPod|iPhone|iPad/.test(navigator.platform),jd=Od&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent),Md=!(!Od||!(`InputEvent`in window)||kd)&&`getTargetRanges`in new window.InputEvent(`input`),Nd=Od&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,Pd=Od&&/Android/.test(navigator.userAgent),Fd=Od&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent)&&!Pd,Id=Od&&/^(?=.*Chrome).*/i.test(navigator.userAgent),Ld=Od&&Pd&&Id,Rd=Od&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&Ad&&!Id,zd=Fd||Nd||Rd?`\xA0`:`​`,Bd=jd?`\xA0`:zd,Vd=`֑-߿יִ-﷽ﹰ-ﻼ`,Hd=`A-Za-zÀ-ÖØ-öø-ʸ̀-֐ࠀ-῿‎Ⰰ-﬜︀-﹯﻽-￿`;RegExp(`^[^`+Hd+`]*[`+Vd+`]`),RegExp(`^[^`+Vd+`]*[`+Hd+`]`);let Ud={bold:1,capitalize:1024,code:16,highlight:128,italic:2,lowercase:256,strikethrough:4,subscript:32,superscript:64,underline:8,uppercase:512},Wd={directionless:1,unmergeable:2},Gd={center:2,end:6,justify:4,left:1,right:3,start:5},Kd={2:`center`,6:`end`,4:`justify`,1:`left`,3:`right`,5:`start`},qd={normal:0,segmented:2,token:1},Jd={0:`normal`,2:`segmented`,1:`token`},Yd=`$config`;function Xd(){return hy()._blockCursorElement}function Zd(e){return e!==null&&e.nodeType===1&&e.hasAttribute(`data-lexical-slot`)}var Qd=class e{element;before;after;constructor(e,t,n){this.element=e,this.before=t||null,this.after=n||null}withBefore(t){return new e(this.element,t,this.after)}withAfter(t){return new e(this.element,this.before,t)}withElement(t){return this.element===t?this:new e(t,this.before,this.after)}insertChild(e){let t=this.getInsertionAnchor();return t!==null&&t.parentElement!==this.element&&F(357),this.element.insertBefore(e,t),this}removeChild(e){return e.parentElement!==this.element&&F(358),this.element.removeChild(e),this}replaceChild(e,t){return t.parentElement!==this.element&&F(359),this.element.replaceChild(e,t),this}getFirstChild(){let e=this.getFirstChildAnchor(),t=e?e.nextSibling:this.element.firstChild;return t===this.getInsertionAnchor()?null:t}getFirstChildAnchor(){return this.after}resolveLeafPosition(e,t,n){if(this.element===e)return t===e&&n===0?`before`:`after`;let r=$d(e,this.element);if(r===null)return`after`;let i=Array.prototype.indexOf.call(e.childNodes,r);if(i<0)return`after`;if(t===e)return n<=i?`before`:`after`;let a=$d(e,t);if(a===null)return`after`;let o=Array.prototype.indexOf.call(e.childNodes,a);return o>=0&&o<=i?`before`:`after`}getInsertionAnchor(){return this.before}};function $d(e,t){let n=t;for(;n!==null&&n.parentNode!==e;)n=n.parentNode;return n}var ef=class e extends Qd{withBefore(t){return new e(this.element,t,this.after)}withAfter(t){return new e(this.element,this.before,t)}withElement(t){return this.element===t?this:new e(t,this.before,this.after)}getInsertionAnchor(){return super.getInsertionAnchor()||this.getManagedLineBreak()}getFirstChildAnchor(){let e=super.getFirstChildAnchor(),t=e?e.nextSibling:this.element.firstChild;for(;Zd(t);)e=t,t=t.nextSibling;let n=e?e.nextSibling:this.element.firstChild;return n!==null&&n===Xd()?n:e}getManagedLineBreak(){return this.element.__lexicalLineBreak||null}setManagedLineBreak(e){if(this.element.__lexicalLastChildKind=e,e===null)this.removeManagedLineBreak();else{let t=e===`decorator`&&(Rd||Nd||Fd);this.insertManagedLineBreak(t)}}removeManagedLineBreak(){let e=this.getManagedLineBreak();if(e){let t=this.element,n=e.nodeName===`IMG`?e.nextSibling:null;n&&t.removeChild(n),t.removeChild(e),t.__lexicalLineBreak=void 0}}insertManagedLineBreak(e){let t=this.getManagedLineBreak();if(t){if(e===(t.nodeName===`IMG`))return;this.removeManagedLineBreak()}let n=this.element,r=this.before,i=Qv().createElement(`br`);if(i.setAttribute(`data-lexical-managed-linebreak`,`true`),n.insertBefore(i,r),e){let e=Qv().createElement(`img`);e.setAttribute(`data-lexical-managed-linebreak`,`true`),e.style.setProperty(`display`,`inline`,`important`),e.style.setProperty(`border`,`0px`,`important`),e.style.setProperty(`margin`,`0px`,`important`),e.alt=``,n.insertBefore(e,i),n.__lexicalLineBreak=e}else n.__lexicalLineBreak=i}getFirstChildOffset(){let e=this.getFirstChild(),t=this.getInsertionAnchor(),n=0;for(let r=this.element.firstChild;r!==null&&r!==e&&r!==t;r=r.nextSibling)n++;return n}resolveChildIndex(e,t,n,r){if(n===this.element){let t=this.getFirstChildOffset(),n=Xd(),i=this.element.childNodes,a=Math.min(r,i.length),o=0;for(let e=t;e<a;e++)i[e]!==n&&o++;return[e,Math.min(o,e.getChildrenSize())]}let i=tf(t,n);i.push(r);let a=tf(t,this.element),o=e.getIndexWithinParent();for(let e=0;e<a.length;e++){let t=i[e],n=a[e];if(t===void 0||t<n)break;if(t>n){o+=1;break}}return[e.getParentOrThrow(),o]}};function tf(e,t){let n=[],r=t;for(;r!==e&&r!==null;r=r.parentNode){let e=0;for(let t=r.previousSibling;t!==null;t=t.previousSibling)e++;n.push(e)}return r!==e&&F(225),n.reverse()}let nf;try{nf=`0.49.0+prod.esm`}catch{}let rf=nf??`"<unknown>+source"`;var af=class{_front=/* @__PURE__ */ new Set;_back=/* @__PURE__ */ new Set;_cache;get size(){return this._front.size+this._back.size}addBack(e){return delete this._cache,this._front.has(e)||this._back.add(e),this}addFront(e){return delete this._cache,this._back.has(e)||this._front.add(e),this}delete(e){return delete this._cache,this._front.delete(e)||this._back.delete(e)}toArray(){let e=Array.from(this._front).reverse();for(let t of this._back)e.push(t);return e}toReadonlyArray(){return this._cache=this._cache||this.toArray(),this._cache}[Symbol.iterator](){return this.toReadonlyArray()[Symbol.iterator]()}};function of(e,t=1e3){return e instanceof sf?e.clone():e.size<t?new Map(e):new sf().init(new Map(e),void 0,e.size)}var sf=class e{_mutable=!1;_old=void 0;_nursery=void 0;_size=0;clone(){return this._mutable=!1,new e().init(this._old,this._nursery,this._size)}init(e,t,n){return this._old=e,this._nursery=t,this._size=n,this}get size(){return this._size}has(e){return this.get(e)!==void 0}getWithTombstone(e){let t=this._nursery&&this._nursery.get(e);return t===void 0?this._old&&this._old.get(e):t}get(e){let t=this.getWithTombstone(e);return t===null?void 0:t}shouldCompact(){return this._nursery!==void 0&&2*this._nursery.size>this._size}getNursery(){return this._mutable&&this._nursery||(this.compact(),this._nursery=new Map(this._nursery),this._mutable=!0),this._nursery}compact(e=!1){if(this._nursery&&this._nursery.size>0&&(e||this.shouldCompact())){let e=new Map(this._old);for(let[t,n]of this._nursery)n===null?e.delete(t):e.set(t,n);this._old=e,this._nursery=void 0}return this._mutable=!1,this}set(e,t){let n=this.getWithTombstone(e);if(n===t)return this;let r=this.getNursery();return n??(this._size++,n===null&&r.delete(e)),r.set(e,t),this}delete(e){let t=this.has(e);return t&&(this.getNursery().set(e,null),this._size--),t}getOrInsert(e,t){let n=this.get(e);return n===void 0?(this.set(e,t),t):n}getOrInsertComputed(e,t){let n=this.get(e);if(n!==void 0)return n;let r=t(e);return this.set(e,r),r}clear(){this._mutable=!1,this._old=void 0,this._nursery=void 0,this._size=0}*keys(){for(let e of this.entries())yield e[0]}*values(){for(let e of this.entries())yield e[1]}*entries(){let e=this._nursery,t=this._old;if(t)for(let n of t){let t=n[0],r=e?e.get(t):void 0;r!==null&&(r!==void 0&&(n[1]=r),yield n)}if(e)for(let n of e)n[1]===null||t&&t.has(n[0])||(yield n)}forEach(e,t){t!==void 0&&(e=e.bind(t));for(let[t,n]of this.entries())e(n,t,this)}get[Symbol.toStringTag](){return`GenMap`}[Symbol.iterator](){return this.entries()}};function cf(e,t,n,r,i,a){if(U(e)){let o=e.getFirstChild();for(;o!==null;){let e=o.__key;o.__parent===t&&((U(o)||Hy(o)&&o.__slots!==null)&&cf(o,e,n,r,i,a),n.has(e)||a.delete(e),i.push(e)),o=o.getNextSibling()}}for(let o of Hy(e)&&e.__slots!==null?e.__slots.values():[]){let e=r.get(o);e!==void 0&&Uy(e)&&e.__slotHost===t&&((U(e)||Hy(e)&&e.__slots!==null)&&cf(e,o,n,r,i,a),n.has(o)||a.delete(o),i.push(o))}}let lf=!1,uf=0;function df(e){uf=e.timeStamp}function ff(e,t,n){let r=e.nodeName===`BR`,i=t.__lexicalLineBreak;return i&&(e===i||r&&e.previousSibling===i)||r&&tv(e,n)!==void 0}function pf(e,t,n){let r=Gv(Pv(n)),i=r&&ty(r,n._rootElement),a=null,o=null;i!==null&&i.anchorNode===e&&(a=i.anchorOffset,o=i.focusOffset);let s=e.nodeValue;s!==null&&mv(t,s,a,o,!1)}function mf(e,t,n){if(B(e)){let t=e.anchor.getNode();if(t.is(n)&&e.format!==t.getFormat())return!1}return U_(t)&&n.isAttached()}function hf(e,t,n){for(let r=e;r&&!ky(r);r=Ov(r)){let e=tv(r,t);if(e!==void 0){let t=Q_(e,n);if(t)return W(t)||!q(r)?void 0:[r,t]}}}function gf(e,t,n){lf=!0;let r=performance.now()-uf>100;try{Zg(e,()=>{let i=V()||function(e){return e.read(`latest`,()=>{let e=V();return e===null?null:e.clone()})}(e),a=/* @__PURE__ */ new Map,o=e._editorState,s=e._blockCursorElement,c=!1,l=``;for(let n=0;n<t.length;n++){let u=t[n],d=u.type,f=u.target,p=hf(f,e,o);if(!p)continue;let[m,h]=p;if(d===`characterData`)r&&z(h)&&U_(f)&&mf(i,f,h)&&pf(f,h,e);else if(d===`childList`){c=!0;let t=u.addedNodes;for(let n=0;n<t.length;n++){let r=t[n],i=$_(r),a=r.parentNode;if(!(a==null||r===s||i!==null||ff(r,a,e)||e._slotsUsed&&q(r)&&r.hasAttribute(`data-lexical-slot`)||ky(r))){if(jd){let e=(q(r)?r.innerText:null)||r.nodeValue;e&&(l+=e)}a.removeChild(r)}}let n=u.removedNodes,r=n.length;if(r>0){let t=0;for(let i=0;i<r;i++){let r=n[i];(ff(r,f,e)||s===r)&&(f.appendChild(r),t++)}r!==t&&a.set(m,h)}}}if(a.size>0)for(let[t,n]of a)n.reconcileObservedMutation(t,e);let u=n.takeRecords();if(u.length>0){for(let t=0;t<u.length;t++){let n=u[t],r=n.addedNodes,i=n.target;for(let t=0;t<r.length;t++){let n=r[t],a=n.parentNode;a==null||n.nodeName!==`BR`||ff(n,i,e)||a.removeChild(n)}}n.takeRecords()}i!==null&&(c&&ov(i),jd&&Ev(e)&&i.insertRawText(l))})}finally{lf=!1}}function _f(e){let t=e._observer;t!==null&&gf(e,t.takeRecords(),t)}function vf(e){(function(e){uf===0&&Pv(e).addEventListener(`textInput`,df,!0)})(e),e._observer=new MutationObserver((t,n)=>{gf(e,t,n)})}var yf=class{key;parse;unparse;isEqual;defaultValue;resetOnCopyNode;constructor(e,t){this.key=e,this.parse=t.parse.bind(t),this.unparse=(t.unparse||Df).bind(t),this.isEqual=(t.isEqual||Object.is).bind(t),this.defaultValue=this.parse(void 0),this.resetOnCopyNode=t.resetOnCopyNode||!1}};function bf(e,t){return new yf(e,t)}function xf(e){let t=/* @__PURE__ */ new Map,n=/* @__PURE__ */ new Set;for(let{ownNodeConfig:r}of Iy(typeof e==`function`?e:e.replace))if(r&&r.stateConfigs)for(let e of r.stateConfigs){let r;`stateConfig`in e?(r=e.stateConfig,e.flat&&n.add(r.key)):r=e,t.set(r.key,r)}return{flatKeys:n,sharedConfigMap:t}}let Sf=/* @__PURE__ */ new Set([`__proto__`,`constructor`,`prototype`]);var Cf=class e{node;knownState;unknownState;sharedNodeState;size;constructor(e,t,n=void 0,r=/* @__PURE__ */ new Map,i=void 0){this.node=e,this.sharedNodeState=t,this.unknownState=n,this.knownState=r;let{sharedConfigMap:a}=this.sharedNodeState,o=i===void 0?function(e,t,n){let r=n.size;if(t)for(let i in t){let t=e.get(i);t&&n.has(t)||r++}return r}(a,n,r):i;this.size=o}getValue(e){let t=this.knownState.get(e);if(t!==void 0)return t;this.sharedNodeState.sharedConfigMap.set(e.key,e);let n=e.defaultValue;if(this.unknownState&&e.key in this.unknownState){let t=this.unknownState[e.key];t!==void 0&&(n=e.parse(t)),this.updateFromKnown(e,n)}return n}getInternalState(){return[this.unknownState,this.knownState]}toJSON(){let e={...this.unknownState},t={};for(let[t,n]of this.knownState)t.isEqual(n,t.defaultValue)?delete e[t.key]:e[t.key]=t.unparse(n);for(let n of this.sharedNodeState.flatKeys)n in e&&(t[n]=e[n],delete e[n]);return Ef(e)&&(t.$=e),t}getWritable(t){if(this.node===t)return this;let{sharedNodeState:n,unknownState:r}=this,i=new Map(this.knownState);return new e(t,n,function(e,t,n){let r;if(n)for(let[i,a]of Object.entries(n)){if(Sf.has(i))continue;let n=e.get(i);n?t.has(n)||t.set(n,n.parse(a)):(r||={},r[i]=a)}return r}(n.sharedConfigMap,i,r),i,this.size)}resetOnCopyNode(){for(let e of this.knownState.keys())e.resetOnCopyNode&&this.knownState.set(e,e.defaultValue);return this}updateFromKnown(e,t){let n=e.key;this.sharedNodeState.sharedConfigMap.set(n,e);let{knownState:r,unknownState:i}=this;r.has(e)||i&&n in i||(i&&(delete i[n],this.unknownState=Ef(i)),this.size++),r.set(e,t)}updateFromUnknown(e,t){if(Sf.has(e))return;let n=this.sharedNodeState.sharedConfigMap.get(e);n?this.updateFromKnown(n,n.parse(t)):(this.unknownState=this.unknownState||{},e in this.unknownState||this.size++,this.unknownState[e]=t)}updateFromJSON(e){let{knownState:t}=this;for(let e of t.keys())t.set(e,e.defaultValue);if(this.size=t.size,this.unknownState=void 0,e)for(let[t,n]of Object.entries(e))this.updateFromUnknown(t,n)}};function wf(e){let t=e.getWritable(),n=t.__state?t.__state.getWritable(t):new Cf(t,Tf(t));return t.__state=n,n}function Tf(e){return e.__state?e.__state.sharedNodeState:N_(hy(),e.getType()).sharedNodeState}function Ef(e){if(e)for(let t in e)return e}function Df(e){return e}function Of(e,t,n){for(let[r,i]of t.knownState){if(e.has(r.key))continue;e.add(r.key);let t=n?n.getValue(r):r.defaultValue;if(t!==i&&!r.isEqual(t,i))return!0}return!1}function kf(e,t,n){let{unknownState:r}=t,i=n?n.unknownState:void 0;if(r){for(let[t,n]of Object.entries(r))if(!e.has(t)&&(e.add(t),n!==(i?i[t]:void 0)))return!0}return!1}function Af(e,t){let n=e.__state;return n&&n.node===e?n.getWritable(t):n}function jf(e,t){let n=e.__mode,r=e.__format,i=e.__style,a=t.__mode,o=t.__format,s=t.__style,c=e.__state,l=t.__state;return(n===null||n===a)&&(r===null||r===o)&&(i===null||i===s)&&(e.__state===null||c===l||function(e,t){if(e===t)return!0;let n=/* @__PURE__ */ new Set;return!(e&&Of(n,e,t)||t&&Of(n,t,e)||e&&kf(n,e,t)||t&&kf(n,t,e))}(c,l))}function Mf(e,t){let n=e.mergeWithSibling(t),r=H()._normalizedNodes;return r.add(e.__key),r.add(t.__key),n}function Nf(e){let t,n,r=e;if(r.__text!==``||!r.isSimpleText()||r.isUnmergeable()){for(;(t=r.getPreviousSibling())!==null&&z(t)&&t.isSimpleText()&&!t.isUnmergeable();){if(t.__text!==``){if(jf(t,r)){r=Mf(t,r);break}break}t.remove()}for(;(n=r.getNextSibling())!==null&&z(n)&&n.isSimpleText()&&!n.isUnmergeable();){if(n.__text!==``){if(jf(r,n)){r=Mf(r,n);break}break}n.remove()}}else r.remove()}function Pf(e){return Ff(e.anchor),Ff(e.focus),e}function Ff(e){for(;e.type===`element`;){let t=e.getNode(),n=e.offset,r,i;if(n===t.getChildrenSize()?(r=t.getChildAtIndex(n-1),i=!0):(r=t.getChildAtIndex(n),i=!1),z(r)){e.set(r.__key,i?r.getTextContentSize():0,`text`,!0);break}if(!U(r))break;e.set(r.__key,i?r.getChildrenSize():0,`element`,!0)}}let If=Symbol.for(`@lexical/CachedTextSize`);function Lf(e,t){return Zf.read(()=>{let n=0,r=e;for(let e=0;e<t&&r!==null;e++){let i=Xf.get(r);if(i===void 0&&F(345,r),U(i)){let a=Qf.get(r);if(a!==void 0&&U(a)&&a.__parent!==i.__parent)n+=i.getTextContentSize();else{let e=$f.get(r),t=e&&e.__lexicalTextContent;typeof t!=`string`&&F(346,i.getType()),n+=t.length}e<t-1&&!i.isInline()&&(n+=2)}else{let e=i[If];e===void 0&&F(347,i.getType(),r),n+=e}r=i.__next}return n},{editor:I})}function Rf(e){U(e)||e[If]===void 0&&(e[If]=z(e)?e.__text.length:e.getTextContentSize())}let zf,I,Bf,L=``,Vf=null,Hf=null,Uf=null;function Wf(){return{firstTextKey:Uf,format:Vf,style:Hf}}function Gf(e){e.firstTextKey!==null&&(Vf=e.format,Hf=e.style,Uf=e.firstTextKey)}function Kf(e){if(Uf!==null)return;let t=e.__lexicalFirstTextKey;if(t===void 0&&F(348),t===null)return;let n=Qf.get(t);z(n)&&(Vf=n.getFormat(),Hf=n.getStyle(),Uf=t)}let qf,Jf,Yf,Xf,Zf,Qf,$f,ep,tp,np,rp=!1,ip=!1;function ap(e,t){let n=Xf.get(e),r=Qf.has(e);if(t!==null){let n=Op(e);n.parentNode===t&&t.removeChild(n)}if(!r){if(I._keyToDOMMap.delete(e),U(n)){let e=zy(n,Xf);op(e,0,e.length-1,null)}if(n!==void 0){for(let e of mp(n).values()){let t=gp(e);ap(e,null),t!==null&&t.remove()}Cv(tp,Bf,qf,n,`destroyed`)}}}function op(e,t,n,r){for(let i=t;i<=n;++i){let t=e[i];t!==void 0&&ap(t,r)}}function sp(e,t){e.setProperty(`text-align`,t)}function cp(e,t){let n=zf.theme.indent;if(typeof n==`string`){let r=e.classList.contains(n);t>0&&!r?e.classList.add(n):t<1&&r&&e.classList.remove(n)}e.style.setProperty(`padding-inline-start`,t===0?``:`calc(${t} * var(--lexical-indent-base-value, 40px))`)}function lp(e,t){let n=e.style;t===0?sp(n,``):t===1?sp(n,`left`):t===2?sp(n,`center`):t===3?sp(n,`right`):t===4?sp(n,`justify`):t===5?sp(n,`start`):t===6&&sp(n,`end`)}function up(e,t){let n=function(e){let t=e.__dir;if(t!==null)return t;if(r_(e))return null;let n=e.getParent();return n===null||Rv(n)&&n.__dir===null?`auto`:null}(t);n===null?e.removeAttribute(`dir`):e.dir=n}function dp(e){let t=Qv().createElement(`div`);return t.setAttribute(`data-lexical-slot`,e),t.style.display=`none`,t}function fp(e,t,n){t||e.contentEditable===`false`?Ay(n,I):n.removeAttribute(`contenteditable`)}function pp(e,t,n){let r=L,i=Wf();L=``;let a=``,o=W(e);for(let[r,i]of n){let n=dp(r);fp(t,o,n),t.appendChild(n),L=``;let s=Wf();vp(i,_y(e,n,I)),Gf(s),hp(e,r,t,n),a+=L}return Gf(i),L=r,a}function mp(e){return Hy(e)&&e.__slots!==null?e.__slots:Vy}function hp(e,t,n,r){let i=np.$getSlotTargetElement(e,t,n,I);i!==null&&(r.parentElement!==i&&i.appendChild(r),r.style.display=``)}function gp(e){let t=$f.get(e);return t===void 0?null:t.parentElement}function _p(e,t,n){let r=mp(e),i=mp(t);for(let[e,t]of r)if(!i.has(e)){let e=gp(t);ap(t,null),e!==null&&e.remove()}let a=L,o=Wf(),s=``,c=null,l=W(t);for(let[e,a]of i){let i=r.get(e),o=i===void 0?null:gp(i);L=``;let u=Wf();if(o===null){o=dp(e);let r=null;for(let e of n.children)if(!e.hasAttribute(`data-lexical-slot`)){r=e;break}n.insertBefore(o,r),vp(a,_y(t,o,I))}else i===a?Cp(a,o):(i!==void 0&&ap(i,o),vp(a,_y(t,o,I)));if(Gf(u),fp(n,l,o),hp(t,e,n,o),s+=L,o.parentElement===n){let e=c===null?n.firstChild:c.nextSibling;e!==o&&n.insertBefore(o,e),c=o}}return Gf(o),L=a,s}function vp(e,t){let n=Qf.get(e);if(n===void 0&&F(60),t!==null){let r=Xf.get(e);if(r!==void 0){let i=$f.get(e);if(i!==void 0){let a=Uy(r)?r.__slotHost:null,o=Uy(n)?n.__slotHost:null,s=r.__parent!==n.__parent||a!==o,c=o!==null&&i.parentElement!==t.element;if(s||c)return t.insertChild(i),Cp(e,t.element)}}}let r=np.$createDOM(n,I);if(function(e,t,n){let r=n._keyToDOMMap;ev(t,n,e),r.set(e,t)}(e,r,I),z(n)?r.setAttribute(`data-lexical-text`,`true`):W(n)&&(r.setAttribute(`data-lexical-decorator`,`true`),Oy(r,{captureSelection:!0})),U(n)){let e=n.__indent,t=n.__size;up(r,n),e!==0&&cp(r,e);let i=mp(n),a=i.size>0?pp(n,r,i):``;if(t===0)r.__lexicalTextContent=a,r.__lexicalFirstTextKey=null,L+=a,i.size>0&&(r.__lexicalSlotTextLength=a.length);else{let e=L,o=t-1;if(yp(zy(n,Qf),n,0,o,_y(n,r,I)),a!==``){let t=r.__lexicalTextContent||``;r.__lexicalTextContent=a+t,L=e+a+t}i.size>0&&(r.__lexicalSlotTextLength=a.length)}let o=n.__format;o!==0&&lp(r,o),n.isInline()||bp(null,n,r)}else{let t=n.getTextContent();if(W(n)){let t=n.decorate(I,zf);t!==null&&wp(e,t),r.contentEditable=`false`;let i=mp(n);i.size>0&&pp(n,r,i)}L+=t}return t!==null&&t.insertChild(r),np.$decorateDOM(n,null,r,I),Rf(n),Cv(tp,Bf,qf,n,`created`),r}function yp(e,t,n,r,i){let a=L,o=Wf();L=``,Vf=null,Hf=null,Uf=null;let s=n;for(;s<=r;++s){let t=Wf();vp(e[s],i);let n=Qf.get(e[s]);n!==null&&z(n)?Vf===null&&(Vf=n.getFormat(),Hf=n.getStyle(),Uf=n.__key):U(n)&&s<r&&!n.isInline()&&(L+=`
124
124
 
125
- `),If(t)}let c=I._keyToDOMMap.get(t.__key);c===void 0&&F(349,t.__key),c.__lexicalTextContent=L,c.__lexicalFirstTextKey=Pf,L=a+L,If(o)}function dp(e,t,n){let r=cy(t,n,I),i=r.element.__lexicalLastChildKind??null,a=function(e,t){if(e){let n=e.__last;if(n){let e=t.get(n);if(e)return i_(e)?`line-break`:W(e)&&e.isInline()?`decorator`:null}return ap(e).size>0?null:`empty`}return null}(t,Uf);i!==a&&r.setManagedLineBreak(a)}function fp(e,t,n){var r;Mf=null,Nf=null,Pf=null,function(e,t,n){let r=L,i=e.__size,a=t.__size;L=``;let o=n.element,s=I._keyToDOMMap.get(t.__key);s===void 0&&F(351,t.__key);let c=a-i;if(!Jf&&Math.abs(c)<=1&&i>=4&&e.__first===t.__first&&(c!==0||!I._cloneNotNeeded.has(e.__key))){let i=s.__lexicalTextContent,l=Gf.get(e.__key);if(!Jf&&typeof i==`string`&&l!==void 0){let a=function(e,t){let n=t.size;if(n===0||n>=e.__size)return null;let r=e.__last,i=null,a=0;for(;r!==null&&a<n;){if(!t.has(r))return null;i=r;let e=Uf.get(r);if(e===void 0)return null;r=e.__prev,a++}return a!==n||r!==null&&t.has(r)?null:i}(t,l);if(a!==null){let u=l.size;if(c===0){let e=Of(a,u),n=a,c=0;for(;n!==null&&c<u;){let e=Uf.get(n);if(e===void 0)break;let t=Ff();mp(n,o),z(e)&&Mf===null&&(Mf=e.getFormat(),Nf=e.getStyle(),Pf=e.__key),If(t),n=e.__next,c++}let d=``;for(n=a,c=0;n!==null&&c<u;){let e=Uf.get(n);if(e===void 0)break;let t;if(U(e)){let r=I._keyToDOMMap.get(n),i=r&&r.__lexicalTextContent;typeof i!=`string`&&F(352,e.getType()),t=i}else t=e.getTextContent();d+=t,c<u-1&&U(e)&&!e.isInline()&&(d+=`
125
+ `),Gf(t)}let c=I._keyToDOMMap.get(t.__key);c===void 0&&F(349,t.__key),c.__lexicalTextContent=L,c.__lexicalFirstTextKey=Uf,L=a+L,Gf(o)}function bp(e,t,n){let r=_y(t,n,I),i=r.element.__lexicalLastChildKind??null,a=function(e,t){if(e){let n=e.__last;if(n){let e=t.get(n);if(e)return p_(e)?`line-break`:W(e)&&e.isInline()?`decorator`:null}return mp(e).size>0?null:`empty`}return null}(t,Qf);i!==a&&r.setManagedLineBreak(a)}function xp(e,t,n){var r;Vf=null,Hf=null,Uf=null,function(e,t,n){let r=L,i=e.__size,a=t.__size;L=``;let o=n.element,s=I._keyToDOMMap.get(t.__key);s===void 0&&F(351,t.__key);let c=a-i;if(!rp&&Math.abs(c)<=1&&i>=4&&e.__first===t.__first&&(c!==0||!I._cloneNotNeeded.has(e.__key))){let i=s.__lexicalTextContent,l=ep.get(e.__key);if(!rp&&typeof i==`string`&&l!==void 0){let a=function(e,t){let n=t.size;if(n===0||n>=e.__size)return null;let r=e.__last,i=null,a=0;for(;r!==null&&a<n;){if(!t.has(r))return null;i=r;let e=Qf.get(r);if(e===void 0)return null;r=e.__prev,a++}return a!==n||r!==null&&t.has(r)?null:i}(t,l);if(a!==null){let u=l.size;if(c===0){let e=Lf(a,u),n=a,c=0;for(;n!==null&&c<u;){let e=Qf.get(n);if(e===void 0)break;let t=Wf();Cp(n,o),z(e)&&Vf===null&&(Vf=e.getFormat(),Hf=e.getStyle(),Uf=e.__key),Gf(t),n=e.__next,c++}let d=``;for(n=a,c=0;n!==null&&c<u;){let e=Qf.get(n);if(e===void 0)break;let t;if(U(e)){let r=I._keyToDOMMap.get(n),i=r&&r.__lexicalTextContent;typeof i!=`string`&&F(352,e.getType()),t=i}else t=e.getTextContent();d+=t,c<u-1&&U(e)&&!e.isInline()&&(d+=`
126
126
 
127
- `),n=e.__next,c++}let f=s.__lexicalSlotTextLength||0,p=f>0?i.slice(f):i,m=p.slice(0,p.length-e)+d;s.__lexicalTextContent=m,L=r+m,pp(t,s,l);return}if(function(e,t,n,r,i,a,o,s){if(s!==1&&s!==-1||o!==(s===1?2:1))return!1;let c=o-s,l=e.__last;for(let e=0;e<c-1;e++){if(l===null)return!1;let e=Vf.get(l);if(e===void 0)return!1;l=e.__prev}if(l===null)return!1;let u=Uf.get(a),d=Vf.get(l);if(u===void 0||d===void 0||u.__prev!==d.__prev)return!1;let f=[],p=a;for(let e=0;e<o;e++){if(p===null)return!1;f.push(p);let e=Uf.get(p);p=e?e.__next:null}let m=[];p=l;for(let e=0;e<c;e++){if(p===null)return!1;m.push(p);let e=Vf.get(p);p=e?e.__next:null}let h=new Set(m),g=new Set(f),_=[],v=0,y=0;for(;v<c&&y<o;)if(f[y]===m[v])_.push({key:f[y],kind:`reconcile`}),v++,y++;else if(g.has(m[v])){if(h.has(f[y]))return!1;_.push({key:f[y],kind:`create`,nextIndex:y}),y++}else _.push({key:m[v],kind:`destroy`}),v++;for(;v<c;)_.push({key:m[v++],kind:`destroy`});for(;y<o;)_.push({key:f[y],kind:`create`,nextIndex:y}),y++;let b=Of(l,c);for(let e of _){let t=Ff();if(e.kind===`reconcile`)mp(e.key,n.element);else if(e.kind===`destroy`)Xf(e.key,n.element);else{let t=null;for(let n=e.nextIndex+1;n<o;n++){let e=I._keyToDOMMap.get(f[n]);if(e!==void 0){t=e;break}}lp(e.key,n.withBefore(t??n.before))}if(e.kind!==`destroy`){let t=Uf.get(e.key);t&&z(t)&&Mf===null&&(Mf=t.getFormat(),Nf=t.getStyle(),Pf=t.__key)}If(t)}let ee=``;for(let e=0;e<o;e++){let t=Uf.get(f[e]);if(t===void 0)return!1;let n;if(U(t)){let r=I._keyToDOMMap.get(f[e]),i=r&&r.__lexicalTextContent;typeof i!=`string`&&F(350,t.getType()),n=i}else n=t.getTextContent();ee+=n,e<o-1&&U(t)&&!t.isInline()&&(ee+=`
127
+ `),n=e.__next,c++}let f=s.__lexicalSlotTextLength||0,p=f>0?i.slice(f):i,m=p.slice(0,p.length-e)+d;s.__lexicalTextContent=m,L=r+m,Sp(t,s,l);return}if(function(e,t,n,r,i,a,o,s){if(s!==1&&s!==-1||o!==(s===1?2:1))return!1;let c=o-s,l=e.__last;for(let e=0;e<c-1;e++){if(l===null)return!1;let e=Xf.get(l);if(e===void 0)return!1;l=e.__prev}if(l===null)return!1;let u=Qf.get(a),d=Xf.get(l);if(u===void 0||d===void 0||u.__prev!==d.__prev)return!1;let f=[],p=a;for(let e=0;e<o;e++){if(p===null)return!1;f.push(p);let e=Qf.get(p);p=e?e.__next:null}let m=[];p=l;for(let e=0;e<c;e++){if(p===null)return!1;m.push(p);let e=Xf.get(p);p=e?e.__next:null}let h=new Set(m),g=new Set(f),_=[],v=0,y=0;for(;v<c&&y<o;)if(f[y]===m[v])_.push({key:f[y],kind:`reconcile`}),v++,y++;else if(g.has(m[v])){if(h.has(f[y]))return!1;_.push({key:f[y],kind:`create`,nextIndex:y}),y++}else _.push({key:m[v],kind:`destroy`}),v++;for(;v<c;)_.push({key:m[v++],kind:`destroy`});for(;y<o;)_.push({key:f[y],kind:`create`,nextIndex:y}),y++;let b=Lf(l,c);for(let e of _){let t=Wf();if(e.kind===`reconcile`)Cp(e.key,n.element);else if(e.kind===`destroy`)ap(e.key,n.element);else{let t=null;for(let n=e.nextIndex+1;n<o;n++){let e=I._keyToDOMMap.get(f[n]);if(e!==void 0){t=e;break}}vp(e.key,n.withBefore(t??n.before))}if(e.kind!==`destroy`){let t=Qf.get(e.key);t&&z(t)&&Vf===null&&(Vf=t.getFormat(),Hf=t.getStyle(),Uf=t.__key)}Gf(t)}let ee=``;for(let e=0;e<o;e++){let t=Qf.get(f[e]);if(t===void 0)return!1;let n;if(U(t)){let r=I._keyToDOMMap.get(f[e]),i=r&&r.__lexicalTextContent;typeof i!=`string`&&F(350,t.getType()),n=i}else n=t.getTextContent();ee+=n,e<o-1&&U(t)&&!t.isInline()&&(ee+=`
128
128
 
129
- `)}let te=r.__lexicalSlotTextLength||0,ne=te>0?i.slice(te):i;return r.__lexicalTextContent=ne.slice(0,ne.length-b)+ee,!0}(e,0,n,s,i,a,u,c)){let e=s.__lexicalTextContent;typeof e!=`string`&&F(353),L=r+e,pp(t,s,l);return}}}if(c===0){let t=e.__first,n=0;for(;t!==null;){let e=Uf.get(t);if(e===void 0)break;let r=Jf||Bf.has(t)||zf.has(t),i=Ff();if(r)mp(t,o);else{let n,r;if(U(e)){r=Wf.get(t);let i=r&&r.__lexicalTextContent;typeof i!=`string`&&F(354,e.getType()),n=i}else n=e.getTextContent();L+=n,r!==void 0&&Lf(r)}z(e)?Mf===null&&(Mf=e.getFormat(),Nf=e.getStyle(),Pf=e.__key):U(e)&&n<a-1&&!e.isInline()&&(L+=`
129
+ `)}let te=r.__lexicalSlotTextLength||0,ne=te>0?i.slice(te):i;return r.__lexicalTextContent=ne.slice(0,ne.length-b)+ee,!0}(e,0,n,s,i,a,u,c)){let e=s.__lexicalTextContent;typeof e!=`string`&&F(353),L=r+e,Sp(t,s,l);return}}}if(c===0){let t=e.__first,n=0;for(;t!==null;){let e=Qf.get(t);if(e===void 0)break;let r=rp||Yf.has(t)||Jf.has(t),i=Wf();if(r)Cp(t,o);else{let n,r;if(U(e)){r=$f.get(t);let i=r&&r.__lexicalTextContent;typeof i!=`string`&&F(354,e.getType()),n=i}else n=e.getTextContent();L+=n,r!==void 0&&Kf(r)}z(e)?Vf===null&&(Vf=e.getFormat(),Hf=e.getStyle(),Uf=e.__key):U(e)&&n<a-1&&!e.isInline()&&(L+=`
130
130
 
131
- `),If(i),t=e.__next,n++}s.__lexicalTextContent=L,s.__lexicalFirstTextKey=Pf,L=r+L;return}}if(i===1&&a===1){let r=e.__first,i=t.__first;if(r===i)mp(r,o);else{let e=yp(r),t=lp(i,null);try{e.parentNode===o?o.replaceChild(t,e):n.insertChild(t)}catch(n){if(typeof n==`object`&&n){let a=`${n.toString()} Parent: ${o.tagName}, new child: {tag: ${t.tagName} key: ${i}}, old child: {tag: ${e.tagName}, key: ${r}}.`;throw Error(a)}throw n}Xf(r,null)}let a=Uf.get(i);z(a)&&Mf===null&&(Mf=a.getFormat(),Nf=a.getStyle(),Pf=a.__key)}else{let r=Ay(e,Vf),s=Ay(t,Uf);if(r.length!==i&&F(227),s.length!==a&&F(228),i===0)a!==0&&up(s,t,0,a-1,n);else if(a===0){if(i!==0){let e=n.after==null&&n.before==null&&ap(t).size===0&&n.element.__lexicalLineBreak==null;Zf(r,0,i-1,e?null:o),e&&(o.textContent=``)}}else(function(e,t,n,r,i,a){let o=r-1,s=i-1,c,l,u=a.getFirstChild(),d=0,f=0;for(;d<=o&&f<=s;){let e=t[d],r=n[f],i=Ff();if(e===r)u=gp(mp(r,a.element)),d++,f++;else{if(l===void 0&&(l=_p(n,f)),c===void 0)c=_p(t,d);else if(!c.has(e)){d++,If(i);continue}if(!l.has(e)){u=gp(yp(e)),Xf(e,a.element),d++,c.delete(e),If(i);continue}if(c.has(r)){let e=vv(I,r);e!==u&&a.withBefore(u??a.before).insertChild(e),u=gp(mp(r,a.element)),d++,f++}else lp(r,a.withBefore(u??a.before)),f++}let o=Uf.get(r);o!==null&&z(o)?Mf===null&&(Mf=o.getFormat(),Nf=o.getStyle(),Pf=o.__key):U(o)&&f<=s&&!o.isInline()&&(L+=`
131
+ `),Gf(i),t=e.__next,n++}s.__lexicalTextContent=L,s.__lexicalFirstTextKey=Uf,L=r+L;return}}if(i===1&&a===1){let r=e.__first,i=t.__first;if(r===i)Cp(r,o);else{let e=Op(r),t=vp(i,null);try{e.parentNode===o?o.replaceChild(t,e):n.insertChild(t)}catch(n){if(typeof n==`object`&&n){let a=`${n.toString()} Parent: ${o.tagName}, new child: {tag: ${t.tagName} key: ${i}}, old child: {tag: ${e.tagName}, key: ${r}}.`;throw Error(a)}throw n}ap(r,null)}let a=Qf.get(i);z(a)&&Vf===null&&(Vf=a.getFormat(),Hf=a.getStyle(),Uf=a.__key)}else{let r=zy(e,Xf),s=zy(t,Qf);if(r.length!==i&&F(227),s.length!==a&&F(228),i===0)a!==0&&yp(s,t,0,a-1,n);else if(a===0){if(i!==0){let e=n.after==null&&n.before==null&&mp(t).size===0&&n.element.__lexicalLineBreak==null;op(r,0,i-1,e?null:o),e&&(o.textContent=``)}}else(function(e,t,n,r,i,a){let o=r-1,s=i-1,c,l,u=a.getFirstChild(),d=0,f=0;for(;d<=o&&f<=s;){let e=t[d],r=n[f],i=Wf();if(e===r)u=Tp(Cp(r,a.element)),d++,f++;else{if(l===void 0&&(l=Ep(n,f)),c===void 0)c=Ep(t,d);else if(!c.has(e)){d++,Gf(i);continue}if(!l.has(e)){u=Tp(Op(e)),ap(e,a.element),d++,c.delete(e),Gf(i);continue}if(c.has(r)){let e=Dv(I,r);e!==u&&a.withBefore(u??a.before).insertChild(e),u=Tp(Cp(r,a.element)),d++,f++}else vp(r,a.withBefore(u??a.before)),f++}let o=Qf.get(r);o!==null&&z(o)?Vf===null&&(Vf=o.getFormat(),Hf=o.getStyle(),Uf=o.__key):U(o)&&f<=s&&!o.isInline()&&(L+=`
132
132
 
133
- `),If(i)}let p=d>o,m=f>s;if(p&&!m){let t=n[s+1],r=t===void 0?null:I.getElementByKey(t);up(n,e,f,s,a.withBefore(r??a.before))}else m&&!p&&Zf(t,d,o,a.element)})(t,r,s,i,a,n)}s.__lexicalTextContent=L,s.__lexicalFirstTextKey=Pf,L=r+L}(e,t,cy(t,n,I)),kv(t)||(r=t,Mf==null||Mf===r.__textFormat||Yf||r.setTextFormat(Mf),function(e){Nf==null||Nf===e.__textStyle||Yf||e.setTextStyle(Nf)}(t))}function pp(e,t,n){let r=t.__lexicalFirstTextKey;if(r!=null){let t=e.__key,i=r;for(;i!==null;){let e=Uf.get(i);if(e===void 0){i=null;break}if(e.__parent===t)break;i=e.__parent}if(i!==null&&!n.has(i)){let e=Uf.get(r);if(z(e))return Mf=e.getFormat(),void(Nf=e.getStyle())}}t.__lexicalFirstTextKey=Pf}function mp(e,t){let n=Vf.get(e),r=Uf.get(e);n!==void 0&&r!==void 0||F(61);let i=Jf||Bf.has(e)||zf.has(e),a=vv(I,e);if(n===r&&!i){let e;if(U(n)){let t=a.__lexicalTextContent;typeof t!=`string`&&F(355,n.getType()),e=t,Lf(a)}else e=n.getTextContent();return L+=e,a}if(n!==r&&i&&mv(Kf,jf,Rf,r,`updated`),qf.$updateDOM(r,n,a,I)){let n=lp(e,null);return t===null&&F(62),t.replaceChild(n,a),Xf(e,null),n}if(U(n)){U(r)||F(334,e);let t=r.__indent;(Jf||t!==n.__indent)&&$f(a,t);let o=r.__format;(Jf||o!==n.__format)&&ep(a,o);let s=i&&(ap(r).size>0||ap(n).size>0)?cp(n,r,a):``;if(i){let e=L;if(fp(n,r,a),Jg(r)||r.isInline()||dp(0,r,a),s!==``){let t=a.__lexicalTextContent||``;a.__lexicalTextContent=s+t,L=e+s+t,a.__lexicalSlotTextLength=s.length}else(ap(r).size>0||ap(n).size>0)&&(a.__lexicalSlotTextLength=0)}else{let e=a.__lexicalTextContent;typeof e!=`string`&&F(356,n.getType()),L+=e,Lf(a)}if((Jf||r.__dir!==n.__dir||r.__parent!==n.__parent)&&(tp(a,r),Jg(r)&&!Jf))for(let e of r.getChildren())U(e)&&tp(vv(I,e.getKey()),e)}else{let t=r.getTextContent();if(W(r)){let t=r.decorate(I,Af);t!==null&&hp(e,t),i&&(ap(r).size>0||ap(n).size>0)&&cp(n,r,a)}L+=t}if(!Yf&&Jg(r)){let e=r.getLatest();if(e.__cachedText!==L){let t=e.getWritable();t.__cachedText=L,r=t}}return qf.$decorateDOM(r,n,a,I),kf(r),a}function hp(e,t){let n=I._pendingDecorators,r=I._decorators;if(n===null){if(r[e]===t)return;n=J_(I)}n[e]=t}function gp(e){let t=e.nextSibling;return t!==null&&t===I._blockCursorElement&&(t=t.nextSibling),t}function _p(e,t){let n=/* @__PURE__ */ new Set;for(let r=t;r<e.length;r++)n.add(e[r]);return n}function vp(e,t,n,r,i,a){L=``,Mf=null,Nf=null,Pf=null,Jf=r===2,I=n,Af=n._config,qf=n._config.dom||h_,jf=n._nodes,Rf=I._listeners.mutation,zf=i,Bf=a,Vf=e._nodeMap,Hf=e,Uf=t._nodeMap,Yf=t._readOnly,Wf=Xd(n._keyToDOMMap),Gf=function(){let e=/* @__PURE__ */ new Map,t=t=>{for(let n of t){let t=Uf.get(n);if(t===void 0)continue;let r=t.__parent;if(r===null)continue;let i=e.get(r);i===void 0&&(i=/* @__PURE__ */ new Set,e.set(r,i)),i.add(n)}};return t(zf.keys()),t(Bf),e}();let o=/* @__PURE__ */ new Map;return Kf=o,mp(`root`,null),I=void 0,jf=void 0,zf=void 0,Bf=void 0,Vf=void 0,Hf=void 0,Uf=void 0,Af=void 0,Wf=void 0,Gf=void 0,Kf=void 0,qf=h_,o}function yp(e){let t=Wf.get(e);return t===void 0&&F(75,e),t}function R(e){return{type:e}}let bp=/* @__PURE__ */ R(`SELECTION_CHANGE_COMMAND`),xp=/* @__PURE__ */ R(`CLICK_COMMAND`),Sp=/* @__PURE__ */ R(`BEFORE_INPUT_COMMAND`),Cp=/* @__PURE__ */ R(`INPUT_COMMAND`),wp=/* @__PURE__ */ R(`COMPOSITION_START_COMMAND`),Tp=/* @__PURE__ */ R(`COMPOSITION_END_COMMAND`),Ep=/* @__PURE__ */ R(`DELETE_CHARACTER_COMMAND`),Dp=/* @__PURE__ */ R(`INSERT_LINE_BREAK_COMMAND`),Op=/* @__PURE__ */ R(`INSERT_PARAGRAPH_COMMAND`),kp=/* @__PURE__ */ R(`CONTROLLED_TEXT_INSERTION_COMMAND`),Ap=/* @__PURE__ */ R(`PASTE_COMMAND`),jp=/* @__PURE__ */ R(`REMOVE_TEXT_COMMAND`),Mp=/* @__PURE__ */ R(`DELETE_WORD_COMMAND`),Np=/* @__PURE__ */ R(`DELETE_LINE_COMMAND`),Pp=/* @__PURE__ */ R(`FORMAT_TEXT_COMMAND`),Fp=/* @__PURE__ */ R(`UNDO_COMMAND`),Ip=/* @__PURE__ */ R(`REDO_COMMAND`),Lp=/* @__PURE__ */ R(`KEYDOWN_COMMAND`),Rp=/* @__PURE__ */ R(`KEY_ARROW_RIGHT_COMMAND`),zp=/* @__PURE__ */ R(`MOVE_TO_END`),Bp=/* @__PURE__ */ R(`KEY_ARROW_LEFT_COMMAND`),Vp=/* @__PURE__ */ R(`MOVE_TO_START`),Hp=/* @__PURE__ */ R(`KEY_ARROW_UP_COMMAND`),Up=/* @__PURE__ */ R(`KEY_ARROW_DOWN_COMMAND`),Wp=/* @__PURE__ */ R(`KEY_ENTER_COMMAND`),Gp=/* @__PURE__ */ R(`KEY_SPACE_COMMAND`),Kp=/* @__PURE__ */ R(`KEY_BACKSPACE_COMMAND`),qp=/* @__PURE__ */ R(`KEY_ESCAPE_COMMAND`),Jp=/* @__PURE__ */ R(`KEY_DELETE_COMMAND`),Yp=/* @__PURE__ */ R(`KEY_TAB_COMMAND`),Xp=/* @__PURE__ */ R(`DROP_COMMAND`),Zp=/* @__PURE__ */ R(`DRAGSTART_COMMAND`),Qp=/* @__PURE__ */ R(`DRAGOVER_COMMAND`),$p=/* @__PURE__ */ R(`DRAGEND_COMMAND`),em=/* @__PURE__ */ R(`COPY_COMMAND`),tm=/* @__PURE__ */ R(`CUT_COMMAND`),nm=/* @__PURE__ */ R(`SELECT_ALL_COMMAND`),rm=/* @__PURE__ */ R(`CLEAR_EDITOR_COMMAND`),im=/* @__PURE__ */ R(`CLEAR_HISTORY_COMMAND`),am=/* @__PURE__ */ R(`CAN_REDO_COMMAND`),om=/* @__PURE__ */ R(`CAN_UNDO_COMMAND`),sm=/* @__PURE__ */ R(`FOCUS_COMMAND`),cm=/* @__PURE__ */ R(`BLUR_COMMAND`),lm=/* @__PURE__ */ R(`KEY_MODIFIER_COMMAND`);function um(e){let t=/* @__PURE__ */ new Map;return{dispose(){for(let e of t.values())e.dispose();t.clear()},register(n,r){let i=t.get(n);i===void 0&&(i={dispose:e(n,r),holders:/* @__PURE__ */ new Set},t.set(n,i));let a=()=>{let e=t.get(n);e&&e.holders.delete(a)&&e.holders.size===0&&(t.delete(n),e.dispose())};return i.holders.add(a),a}}}function dm(e,t,n,r){return e.addEventListener(t,n,r),e.removeEventListener.bind(e,t,n,r)}let fm=Object.freeze({}),pm=[[`keydown`,function(e,t){let n=t._inputState;n.lastKeyDownTimeStamp=e.timeStamp,n.lastKeyCode=e.key,e.key!==`Backspace`&&wm(n),!t.isComposing()&&K(t,Lp,e)}],[`pointerdown`,function(e,t){let n=Qv(e),r=e.pointerType;$v(n)&&r!==`touch`&&r!==`pen`&&e.button===0&&Hg(t,()=>{Sy(n,t)||(t._inputState.isSelectionChangeFromMouseDown=!0)})}],[`compositionstart`,function(e,t){K(t,wp,e)}],[`compositionend`,function(e,t){let n=t._inputState;Sd?n.compositionPhase=`ending-firefox`:wd||!Ed&&!kd?K(t,Tp,e):(n.compositionPhase=`ending-safari`,n.compositionEndData=e.data)}],[`input`,function(e,t){e.stopPropagation();let n=t._inputState;wm(n),Hg(t,()=>{Em(e,t)||t.dispatchCommand(Cp,e)},{event:e}),n.unprocessedBeforeInputData=null}],[`click`,function(e,t){Hg(t,()=>{let n=V(),r=Iv(Tv(t)),i=$h();if(r){if(B(n)){let e=n.anchor,t=e.getNode();e.type===`element`&&e.offset===0&&n.isCollapsed()&&!Jg(t)&&X_().getChildrenSize()===1&&t.getTopLevelElementOrThrow().isEmpty()&&i!==null&&n.is(i)&&(r.removeAllRanges(),n.dirty=!0)}else if(e.pointerType===`touch`||e.pointerType===`pen`){let n=Kv(r,t._rootElement).anchorNode;(q(n)||P_(n))&&Z_(Qh(i,r,t,e))}}if(Sd&&r!==null&&r.rangeCount===0){let n=t._rootElement;if(n!==null&&e.target===n){let a=e.clientY,o=n.childNodes.length;for(let e=0;e<n.childNodes.length;e++){let t=n.childNodes[e];if(q(t)){let n=t.getBoundingClientRect();if(a<=(n.top+n.bottom)/2){o=e;break}}}r.setBaseAndExtent(n,o,n,o);let s=Qh(i,r,t,e);s===null?r.removeAllRanges():Z_(s)}}K(t,xp,e)})}],[`cut`,fm],[`copy`,fm],[`dragstart`,fm],[`dragover`,fm],[`dragend`,fm],[`paste`,fm],[`focus`,fm],[`blur`,fm],[`drop`,fm]];Cd&&pm.push([`beforeinput`,(e,t)=>function(e,t){let n=e.inputType;n===`deleteCompositionText`||Sd&&_v(t)||n!==`insertCompositionText`&&Hg(t,()=>{Em(e,t)||K(t,Sp,e)},{event:e})}(e,t)]);let mm=/* @__PURE__ */ new WeakMap,hm=/* @__PURE__ */ new WeakMap,gm=um(e=>(e.addEventListener(`selectionchange`,Im),()=>e.removeEventListener(`selectionchange`,Im)));function _m(e,t,n,r,i,a){let o=e.anchor,s=e.focus,c=o.getNode(),l=H(),u;if(a!==void 0)u=a;else{let e=Iv(Tv(l));u=e===null?null:Kv(e,l._rootElement)}let d=u===null?null:u.anchorNode,f=o.key,p=l.getElementByKey(f),m=n.length;return f!==s.key||!z(c)||(!i&&(!Cd||l._inputState.lastBeforeInputInsertTextTimeStamp<r+50)||c.isDirty()&&m<2||ev(n))&&o.offset!==s.offset&&!c.isComposing()||N_(c)||c.isDirty()&&m>1||(i||!Cd)&&p!==null&&!c.isComposing()&&d!==uy(c,p,l)||u!==null&&t!==null&&(!t.collapsed||t.startContainer!==u.anchorNode||t.startOffset!==u.anchorOffset)||!c.isComposing()&&(c.getFormat()!==e.format||c.getStyle()!==e.style)||function(e,t){if(t.isSegmented())return!0;if(!e.isCollapsed())return!1;let n=e.anchor.offset,r=t.getParentOrThrow(),i=M_(t);return n===0?!t.canInsertTextBefore()||!r.canInsertTextBefore()&&!t.isComposing()||i||function(e){let t=e.getPreviousSibling();return(z(t)||U(t)&&t.isInline())&&!t.canInsertTextAfter()}(t):n===t.getTextContentSize()&&(!t.canInsertTextAfter()||!r.canInsertTextAfter()&&!t.isComposing()||i)}(e,c)}function vm(e,t){return P_(e)&&e.nodeValue!==null&&t!==0&&t!==e.nodeValue.length}function ym(e,t,n){let{anchorNode:r,anchorOffset:i,focusNode:a,focusOffset:o}=Kv(e,t._rootElement),s=t._inputState;s.isSelectionChangeFromDOMUpdate&&(s.isSelectionChangeFromDOMUpdate=!1,vm(r,i)&&vm(a,o)&&!s.postDeleteSelectionToRestore)||Hg(t,()=>{if(!n)return void Z_(null);if(!O_(t,r,a))return;let c=V();if(s.postDeleteSelectionToRestore&&B(c)&&c.isCollapsed()){let e=c.anchor,t=s.postDeleteSelectionToRestore.anchor;(e.key===t.key&&e.offset===t.offset+1||e.offset===1&&t.getNode().is(e.getNode().getPreviousSibling()))&&(c=s.postDeleteSelectionToRestore.clone(),Z_(c))}if(s.postDeleteSelectionToRestore=null,B(c)){let n=c.anchor,l=n.getNode();if(c.isCollapsed()){e.type===`Range`&&r===a&&(c.dirty=!0);let i=Tv(t).event,o=i?i.timeStamp:performance.now(),{format:u,style:d,offset:f,key:p,timeStamp:m}=s.collapsedSelectionFormat,h=X_(),g=!1===t.isComposing()&&h.getTextContent()===``;if(o<m+200&&n.offset===f&&n.key===p)bm(c,u,d);else if(n.type===`text`)z(l)||F(141),xm(c,l);else if(n.type===`element`&&!g){U(l)||F(259);let e=n.getNode();e.isEmpty()?function(e,t){bm(e,t.getTextFormat(),t.getTextStyle())}(c,e):bm(c,c.format,``)}}else{let e=n.key,t=c.focus.key,r=c.getNodes(),a=r.length,s=c.isBackward(),l=s?o:i,u=s?i:o,d=s?t:e,f=s?e:t,p=2047,m=!1;for(let e=0;e<a;e++){let t=r[e],n=t.getTextContentSize();if(z(t)&&n!==0&&!(e===0&&t.__key===d&&l===n||e===a-1&&t.__key===f&&u===0)&&(m=!0,p&=t.getFormat(),p===0))break}c.format=m?p:0}}K(t,bp)})}function bm(e,t,n){e.format===t&&e.style===n||(e.format=t,e.style=n,e.dirty=!0)}function xm(e,t){bm(e,t.getFormat(),t.getStyle())}function Sm(e){if(!e.getTargetRanges)return null;let t=e.getTargetRanges();return t.length===0?null:t[0]}function Cm(e){let{lastKeyCode:t}=H()._inputState;if(e==null||e.length<=1||t==null)return;let n=t.length===1?t:t===`Enter`?`
133
+ `),Gf(i)}let p=d>o,m=f>s;if(p&&!m){let t=n[s+1],r=t===void 0?null:I.getElementByKey(t);yp(n,e,f,s,a.withBefore(r??a.before))}else m&&!p&&op(t,d,o,a.element)})(t,r,s,i,a,n)}s.__lexicalTextContent=L,s.__lexicalFirstTextKey=Uf,L=r+L}(e,t,_y(t,n,I)),Rv(t)||(r=t,Vf==null||Vf===r.__textFormat||ip||r.setTextFormat(Vf),function(e){Hf==null||Hf===e.__textStyle||ip||e.setTextStyle(Hf)}(t))}function Sp(e,t,n){let r=t.__lexicalFirstTextKey;if(r!=null){let t=e.__key,i=r;for(;i!==null;){let e=Qf.get(i);if(e===void 0){i=null;break}if(e.__parent===t)break;i=e.__parent}if(i!==null&&!n.has(i)){let e=Qf.get(r);if(z(e))return Vf=e.getFormat(),void(Hf=e.getStyle())}}t.__lexicalFirstTextKey=Uf}function Cp(e,t){let n=Xf.get(e),r=Qf.get(e);n!==void 0&&r!==void 0||F(61);let i=rp||Yf.has(e)||Jf.has(e),a=Dv(I,e);if(n===r&&!i){let e;if(U(n)){let t=a.__lexicalTextContent;typeof t!=`string`&&F(355,n.getType()),e=t,Kf(a)}else e=n.getTextContent();return L+=e,a}if(n!==r&&i&&Cv(tp,Bf,qf,r,`updated`),np.$updateDOM(r,n,a,I)){let n=vp(e,null);return t===null&&F(62),t.replaceChild(n,a),ap(e,null),n}if(U(n)){U(r)||F(334,e);let t=r.__indent;(rp||t!==n.__indent)&&cp(a,t);let o=r.__format;(rp||o!==n.__format)&&lp(a,o);let s=i&&(mp(r).size>0||mp(n).size>0)?_p(n,r,a):``;if(i){let e=L;if(xp(n,r,a),r_(r)||r.isInline()||bp(0,r,a),s!==``){let t=a.__lexicalTextContent||``;a.__lexicalTextContent=s+t,L=e+s+t,a.__lexicalSlotTextLength=s.length}else(mp(r).size>0||mp(n).size>0)&&(a.__lexicalSlotTextLength=0)}else{let e=a.__lexicalTextContent;typeof e!=`string`&&F(356,n.getType()),L+=e,Kf(a)}if((rp||r.__dir!==n.__dir||r.__parent!==n.__parent)&&(up(a,r),r_(r)&&!rp))for(let e of r.getChildren())U(e)&&up(Dv(I,e.getKey()),e)}else{let t=r.getTextContent();if(W(r)){let t=r.decorate(I,zf);t!==null&&wp(e,t),i&&(mp(r).size>0||mp(n).size>0)&&_p(n,r,a)}L+=t}if(!ip&&r_(r)){let e=r.getLatest();if(e.__cachedText!==L){let t=e.getWritable();t.__cachedText=L,r=t}}return np.$decorateDOM(r,n,a,I),Rf(r),a}function wp(e,t){let n=I._pendingDecorators,r=I._decorators;if(n===null){if(r[e]===t)return;n=rv(I)}n[e]=t}function Tp(e){let t=e.nextSibling;return t!==null&&t===I._blockCursorElement&&(t=t.nextSibling),t}function Ep(e,t){let n=/* @__PURE__ */ new Set;for(let r=t;r<e.length;r++)n.add(e[r]);return n}function Dp(e,t,n,r,i,a){L=``,Vf=null,Hf=null,Uf=null,rp=r===2,I=n,zf=n._config,np=n._config.dom||w_,Bf=n._nodes,qf=I._listeners.mutation,Jf=i,Yf=a,Xf=e._nodeMap,Zf=e,Qf=t._nodeMap,ip=t._readOnly,$f=of(n._keyToDOMMap),ep=function(){let e=/* @__PURE__ */ new Map,t=t=>{for(let n of t){let t=Qf.get(n);if(t===void 0)continue;let r=t.__parent;if(r===null)continue;let i=e.get(r);i===void 0&&(i=/* @__PURE__ */ new Set,e.set(r,i)),i.add(n)}};return t(Jf.keys()),t(Yf),e}();let o=/* @__PURE__ */ new Map;return tp=o,Cp(`root`,null),I=void 0,Bf=void 0,Jf=void 0,Yf=void 0,Xf=void 0,Zf=void 0,Qf=void 0,zf=void 0,$f=void 0,ep=void 0,tp=void 0,np=w_,o}function Op(e){let t=$f.get(e);return t===void 0&&F(75,e),t}function R(e){return{type:e}}let kp=/* @__PURE__ */ R(`SELECTION_CHANGE_COMMAND`),Ap=/* @__PURE__ */ R(`CLICK_COMMAND`),jp=/* @__PURE__ */ R(`BEFORE_INPUT_COMMAND`),Mp=/* @__PURE__ */ R(`INPUT_COMMAND`),Np=/* @__PURE__ */ R(`COMPOSITION_START_COMMAND`),Pp=/* @__PURE__ */ R(`COMPOSITION_END_COMMAND`),Fp=/* @__PURE__ */ R(`DELETE_CHARACTER_COMMAND`),Ip=/* @__PURE__ */ R(`INSERT_LINE_BREAK_COMMAND`),Lp=/* @__PURE__ */ R(`INSERT_PARAGRAPH_COMMAND`),Rp=/* @__PURE__ */ R(`CONTROLLED_TEXT_INSERTION_COMMAND`),zp=/* @__PURE__ */ R(`PASTE_COMMAND`),Bp=/* @__PURE__ */ R(`REMOVE_TEXT_COMMAND`),Vp=/* @__PURE__ */ R(`DELETE_WORD_COMMAND`),Hp=/* @__PURE__ */ R(`DELETE_LINE_COMMAND`),Up=/* @__PURE__ */ R(`FORMAT_TEXT_COMMAND`),Wp=/* @__PURE__ */ R(`UNDO_COMMAND`),Gp=/* @__PURE__ */ R(`REDO_COMMAND`),Kp=/* @__PURE__ */ R(`KEYDOWN_COMMAND`),qp=/* @__PURE__ */ R(`KEY_ARROW_RIGHT_COMMAND`),Jp=/* @__PURE__ */ R(`MOVE_TO_END`),Yp=/* @__PURE__ */ R(`KEY_ARROW_LEFT_COMMAND`),Xp=/* @__PURE__ */ R(`MOVE_TO_START`),Zp=/* @__PURE__ */ R(`KEY_ARROW_UP_COMMAND`),Qp=/* @__PURE__ */ R(`KEY_ARROW_DOWN_COMMAND`),$p=/* @__PURE__ */ R(`KEY_ENTER_COMMAND`),em=/* @__PURE__ */ R(`KEY_SPACE_COMMAND`),tm=/* @__PURE__ */ R(`KEY_BACKSPACE_COMMAND`),nm=/* @__PURE__ */ R(`KEY_ESCAPE_COMMAND`),rm=/* @__PURE__ */ R(`KEY_DELETE_COMMAND`),im=/* @__PURE__ */ R(`KEY_TAB_COMMAND`),am=/* @__PURE__ */ R(`DROP_COMMAND`),om=/* @__PURE__ */ R(`DRAGSTART_COMMAND`),sm=/* @__PURE__ */ R(`DRAGOVER_COMMAND`),cm=/* @__PURE__ */ R(`DRAGEND_COMMAND`),lm=/* @__PURE__ */ R(`COPY_COMMAND`),um=/* @__PURE__ */ R(`CUT_COMMAND`),dm=/* @__PURE__ */ R(`SELECT_ALL_COMMAND`),fm=/* @__PURE__ */ R(`CLEAR_EDITOR_COMMAND`),pm=/* @__PURE__ */ R(`CLEAR_HISTORY_COMMAND`),mm=/* @__PURE__ */ R(`CAN_REDO_COMMAND`),hm=/* @__PURE__ */ R(`CAN_UNDO_COMMAND`),gm=/* @__PURE__ */ R(`FOCUS_COMMAND`),_m=/* @__PURE__ */ R(`BLUR_COMMAND`),vm=/* @__PURE__ */ R(`KEY_MODIFIER_COMMAND`);function ym(e){let t=/* @__PURE__ */ new Map;return{dispose(){for(let e of t.values())e.dispose();t.clear()},register(n,r){let i=t.get(n);i===void 0&&(i={dispose:e(n,r),holders:/* @__PURE__ */ new Set},t.set(n,i));let a=()=>{let e=t.get(n);e&&e.holders.delete(a)&&e.holders.size===0&&(t.delete(n),e.dispose())};return i.holders.add(a),a}}}function bm(e,t,n,r){return e.addEventListener(t,n,r),e.removeEventListener.bind(e,t,n,r)}let xm=Object.freeze({}),Sm=[[`keydown`,function(e,t){let n=t._inputState;n.lastKeyDownTimeStamp=e.timeStamp,n.lastKeyCode=e.key,e.key!==`Backspace`&&Nm(n),!t.isComposing()&&K(t,Kp,e)}],[`pointerdown`,function(e,t){let n=sy(e),r=e.pointerType;cy(n)&&r!==`touch`&&r!==`pen`&&e.button===0&&Zg(t,()=>{jy(n,t)||(t._inputState.isSelectionChangeFromMouseDown=!0)})}],[`compositionstart`,function(e,t){K(t,Np,e)}],[`compositionend`,function(e,t){let n=t._inputState;jd?n.compositionPhase=`ending-firefox`:Nd||!Fd&&!Rd?K(t,Pp,e):(n.compositionPhase=`ending-safari`,n.compositionEndData=e.data)}],[`input`,function(e,t){e.stopPropagation();let n=t._inputState;Nm(n),Zg(t,()=>{Fm(e,t)||t.dispatchCommand(Mp,e)},{event:e}),n.unprocessedBeforeInputData=null}],[`click`,function(e,t){Zg(t,()=>{let n=V(),r=Gv(Pv(t)),i=cg();if(r){if(B(n)){let e=n.anchor,t=e.getNode();e.type===`element`&&e.offset===0&&n.isCollapsed()&&!r_(t)&&av().getChildrenSize()===1&&t.getTopLevelElementOrThrow().isEmpty()&&i!==null&&n.is(i)&&(r.removeAllRanges(),n.dirty=!0)}else if(e.pointerType===`touch`||e.pointerType===`pen`){let n=ty(r,t._rootElement).anchorNode;(q(n)||U_(n))&&ov(sg(i,r,t,e))}}if(jd&&r!==null&&r.rangeCount===0){let n=t._rootElement;if(n!==null&&e.target===n){let a=e.clientY,o=n.childNodes.length;for(let e=0;e<n.childNodes.length;e++){let t=n.childNodes[e];if(q(t)){let n=t.getBoundingClientRect();if(a<=(n.top+n.bottom)/2){o=e;break}}}r.setBaseAndExtent(n,o,n,o);let s=sg(i,r,t,e);s===null?r.removeAllRanges():ov(s)}}K(t,Ap,e)})}],[`cut`,xm],[`copy`,xm],[`dragstart`,xm],[`dragover`,xm],[`dragend`,xm],[`paste`,xm],[`focus`,xm],[`blur`,xm],[`drop`,xm]];Md&&Sm.push([`beforeinput`,(e,t)=>function(e,t){let n=e.inputType;n===`deleteCompositionText`||jd&&Ev(t)||n!==`insertCompositionText`&&Zg(t,()=>{Fm(e,t)||K(t,jp,e)},{event:e})}(e,t)]);let Cm=/* @__PURE__ */ new WeakMap,wm=/* @__PURE__ */ new WeakMap,Tm=ym(e=>(e.addEventListener(`selectionchange`,Gm),()=>e.removeEventListener(`selectionchange`,Gm)));function Em(e,t,n,r,i,a){let o=e.anchor,s=e.focus,c=o.getNode(),l=H(),u;if(a!==void 0)u=a;else{let e=Gv(Pv(l));u=e===null?null:ty(e,l._rootElement)}let d=u===null?null:u.anchorNode,f=o.key,p=l.getElementByKey(f),m=n.length;return f!==s.key||!z(c)||(!i&&(!Md||l._inputState.lastBeforeInputInsertTextTimeStamp<r+50)||c.isDirty()&&m<2||lv(n))&&o.offset!==s.offset&&!c.isComposing()||H_(c)||c.isDirty()&&m>1||(i||!Md)&&p!==null&&!c.isComposing()&&d!==yy(c,p,l)||u!==null&&t!==null&&(!t.collapsed||t.startContainer!==u.anchorNode||t.startOffset!==u.anchorOffset)||!c.isComposing()&&(c.getFormat()!==e.format||c.getStyle()!==e.style)||function(e,t){if(t.isSegmented())return!0;if(!e.isCollapsed())return!1;let n=e.anchor.offset,r=t.getParentOrThrow(),i=V_(t);return n===0?!t.canInsertTextBefore()||!r.canInsertTextBefore()&&!t.isComposing()||i||function(e){let t=e.getPreviousSibling();return(z(t)||U(t)&&t.isInline())&&!t.canInsertTextAfter()}(t):n===t.getTextContentSize()&&(!t.canInsertTextAfter()||!r.canInsertTextAfter()&&!t.isComposing()||i)}(e,c)}function Dm(e,t){return U_(e)&&e.nodeValue!==null&&t!==0&&t!==e.nodeValue.length}function Om(e,t,n){let{anchorNode:r,anchorOffset:i,focusNode:a,focusOffset:o}=ty(e,t._rootElement),s=t._inputState;s.isSelectionChangeFromDOMUpdate&&(s.isSelectionChangeFromDOMUpdate=!1,Dm(r,i)&&Dm(a,o)&&!s.postDeleteSelectionToRestore)||Zg(t,()=>{if(!n)return void ov(null);if(!L_(t,r,a))return;let c=V();if(s.postDeleteSelectionToRestore&&B(c)&&c.isCollapsed()){let e=c.anchor,t=s.postDeleteSelectionToRestore.anchor;(e.key===t.key&&e.offset===t.offset+1||e.offset===1&&t.getNode().is(e.getNode().getPreviousSibling()))&&(c=s.postDeleteSelectionToRestore.clone(),ov(c))}if(s.postDeleteSelectionToRestore=null,B(c)){let n=c.anchor,l=n.getNode();if(c.isCollapsed()){e.type===`Range`&&r===a&&(c.dirty=!0);let i=Pv(t).event,o=i?i.timeStamp:performance.now(),{format:u,style:d,offset:f,key:p,timeStamp:m}=s.collapsedSelectionFormat,h=av(),g=!1===t.isComposing()&&h.getTextContent()===``;if(o<m+200&&n.offset===f&&n.key===p)km(c,u,d);else if(n.type===`text`)z(l)||F(141),Am(c,l);else if(n.type===`element`&&!g){U(l)||F(259);let e=n.getNode();e.isEmpty()?function(e,t){km(e,t.getTextFormat(),t.getTextStyle())}(c,e):km(c,c.format,``)}}else{let e=n.key,t=c.focus.key,r=c.getNodes(),a=r.length,s=c.isBackward(),l=s?o:i,u=s?i:o,d=s?t:e,f=s?e:t,p=2047,m=!1;for(let e=0;e<a;e++){let t=r[e],n=t.getTextContentSize();if(z(t)&&n!==0&&!(e===0&&t.__key===d&&l===n||e===a-1&&t.__key===f&&u===0)&&(m=!0,p&=t.getFormat(),p===0))break}c.format=m?p:0}}K(t,kp)})}function km(e,t,n){e.format===t&&e.style===n||(e.format=t,e.style=n,e.dirty=!0)}function Am(e,t){km(e,t.getFormat(),t.getStyle())}function jm(e){if(!e.getTargetRanges)return null;let t=e.getTargetRanges();return t.length===0?null:t[0]}function Mm(e){let{lastKeyCode:t}=H()._inputState;if(e==null||e.length<=1||t==null)return;let n=t.length===1?t:t===`Enter`?`
134
134
  `:t===`Tab`?` `:null;if(!n)return;let r=V();if(!B(r)||!r.isCollapsed())return;let i=r.anchor.getNode();if(!z(i))return;let{offset:a}=r.anchor;if(i.getTextContentSize()===a){let e=i.getNextSibling();if(n===`
135
- `){if(i_(e))e.selectEnd();else if(!e){let e=ky(i,Jh),t=e&&e.getNextSibling();U(t)&&t.selectStart()}}else n===` `?bh(e)&&e.selectEnd():z(e)&&e.getTextContent()[0]===n&&e.select(1,1)}else i.getTextContent()[a]===n&&i.select(a+1,a+1)}function wm(e){e.isInsertTextAfterHandledSelectionCommand=!1,e.handledSelectionCommandTimeoutId!==null&&(clearTimeout(e.handledSelectionCommandTimeoutId),e.handledSelectionCommandTimeoutId=null)}function Tm(e){wm(e),e.isInsertTextAfterHandledSelectionCommand=!0,e.handledSelectionCommandTimeoutId=setTimeout(()=>wm(e),0)}function Em(e,t){let n=Qv(e);if(q(n)&&Sy(n,t))return!0;let r=t.getRootElement();if(r===null)return!1;let i=Zv(r.ownerDocument);return i!==null&&r.contains(i)&&Sy(i,t)}function Dm(e){let t=e.inputType,n=Sm(e),r=H(),i=r._inputState,a=V();if(t===`insertText`&&e.data&&i.isInsertTextAfterHandledSelectionCommand){if(wm(i),e.preventDefault(),B(a)&&!a.isCollapsed()){let e=a.isBackward()?a.anchor:a.focus;a.anchor.set(e.key,e.offset,e.type),a.focus.set(e.key,e.offset,e.type)}return!0}if(t===`deleteContentBackward`){if(a===null){let e=$h();if(!B(e))return!0;Z_(e.clone())}if(B(a)){let t=a.anchor.key===a.focus.key;if(function(e,t){return e.lastKeyCode===`MediaLast`&&t<e.lastKeyDownTimeStamp+30}(i,e.timeStamp)&&r.isComposing()&&t){if(V_(null),i.lastKeyDownTimeStamp=0,setTimeout(()=>{Hg(r,()=>{V_(null)})},30),B(a)){let e=a.anchor.getNode();e.markDirty(),z(e)||F(142),xm(a,e)}}else{if(V_(null),wd&&n!==null&&!n.collapsed&&(a.applyDOMRange(n),!a.isCollapsed()))return e.preventDefault(),a.removeText(),!0;e.preventDefault();let o=a.anchor.getNode(),s=o.getTextContent(),c=o.canInsertTextAfter(),l=a.anchor.offset===0&&a.focus.offset===s.length,u=Od&&t&&!l&&c;if(u&&a.isCollapsed()&&(u=!W(gv(a.anchor,!0))),!u){K(r,Ep,!0);let e=V();Od&&B(e)&&e.isCollapsed()&&(i.postDeleteSelectionToRestore=e,setTimeout(()=>i.postDeleteSelectionToRestore=null))}}return!0}}if(!B(a))return!0;let o=e.data;i.unprocessedBeforeInputData!==null&&iv(!1,r,i.unprocessedBeforeInputData),a.dirty&&i.unprocessedBeforeInputData===null||!a.isCollapsed()||Jg(a.anchor.getNode())||n===null||a.applyDOMRange(n),i.unprocessedBeforeInputData=null;let s=a.anchor,c=a.focus,l=s.getNode(),u=c.getNode();if(t===`insertText`||t===`insertTranspose`){if(o===`
136
- `)e.preventDefault(),K(r,Dp,!1);else if(o===`
135
+ `){if(p_(e))e.selectEnd();else if(!e){let e=Ry(i,rg),t=e&&e.getNextSibling();U(t)&&t.selectStart()}}else n===` `?kh(e)&&e.selectEnd():z(e)&&e.getTextContent()[0]===n&&e.select(1,1)}else i.getTextContent()[a]===n&&i.select(a+1,a+1)}function Nm(e){e.isInsertTextAfterHandledSelectionCommand=!1,e.handledSelectionCommandTimeoutId!==null&&(clearTimeout(e.handledSelectionCommandTimeoutId),e.handledSelectionCommandTimeoutId=null)}function Pm(e){Nm(e),e.isInsertTextAfterHandledSelectionCommand=!0,e.handledSelectionCommandTimeoutId=setTimeout(()=>Nm(e),0)}function Fm(e,t){let n=sy(e);if(q(n)&&jy(n,t))return!0;let r=t.getRootElement();if(r===null)return!1;let i=oy(r.ownerDocument);return i!==null&&r.contains(i)&&jy(i,t)}function Im(e){let t=e.inputType,n=jm(e),r=H(),i=r._inputState,a=V();if(t===`insertText`&&e.data&&i.isInsertTextAfterHandledSelectionCommand){if(Nm(i),e.preventDefault(),B(a)&&!a.isCollapsed()){let e=a.isBackward()?a.anchor:a.focus;a.anchor.set(e.key,e.offset,e.type),a.focus.set(e.key,e.offset,e.type)}return!0}if(t===`deleteContentBackward`){if(a===null){let e=cg();if(!B(e))return!0;ov(e.clone())}if(B(a)){let t=a.anchor.key===a.focus.key;if(function(e,t){return e.lastKeyCode===`MediaLast`&&t<e.lastKeyDownTimeStamp+30}(i,e.timeStamp)&&r.isComposing()&&t){if(X_(null),i.lastKeyDownTimeStamp=0,setTimeout(()=>{Zg(r,()=>{X_(null)})},30),B(a)){let e=a.anchor.getNode();e.markDirty(),z(e)||F(142),Am(a,e)}}else{if(X_(null),Nd&&n!==null&&!n.collapsed&&(a.applyDOMRange(n),!a.isCollapsed()))return e.preventDefault(),a.removeText(),!0;e.preventDefault();let o=a.anchor.getNode(),s=o.getTextContent(),c=o.canInsertTextAfter(),l=a.anchor.offset===0&&a.focus.offset===s.length,u=Ld&&t&&!l&&c;if(u&&a.isCollapsed()&&(u=!W(Tv(a.anchor,!0))),!u){K(r,Fp,!0);let e=V();Ld&&B(e)&&e.isCollapsed()&&(i.postDeleteSelectionToRestore=e,setTimeout(()=>i.postDeleteSelectionToRestore=null))}}return!0}}if(!B(a))return!0;let o=e.data;i.unprocessedBeforeInputData!==null&&pv(!1,r,i.unprocessedBeforeInputData),a.dirty&&i.unprocessedBeforeInputData===null||!a.isCollapsed()||r_(a.anchor.getNode())||n===null||a.applyDOMRange(n),i.unprocessedBeforeInputData=null;let s=a.anchor,c=a.focus,l=s.getNode(),u=c.getNode();if(t===`insertText`||t===`insertTranspose`){if(o===`
136
+ `)e.preventDefault(),K(r,Ip,!1);else if(o===`
137
137
 
138
- `)e.preventDefault(),K(r,Op);else if(o==null&&e.dataTransfer){let t=e.dataTransfer.getData(`text/plain`);e.preventDefault(),a.insertRawText(t)}else o!=null&&_m(a,n,o,e.timeStamp,!0)?(e.preventDefault(),K(r,kp,o),Cm(o)):i.unprocessedBeforeInputData=o;return i.lastBeforeInputInsertTextTimeStamp=e.timeStamp,!0}switch(e.preventDefault(),t){case`insertFromYank`:case`insertFromDrop`:case`insertReplacementText`:K(r,kp,e),Cm((e.dataTransfer?e.dataTransfer.getData(`text/plain`):null)??e.data);break;case`insertFromComposition`:{let t=i.hadOrphanedCompositionEvents;i.hadOrphanedCompositionEvents=!1;let n=r._compositionKey;V_(null),t||K(r,kp,e),jm(n);break}case`insertLineBreak`:V_(null),K(r,Dp,!1);break;case`insertParagraph`:V_(null),i.isInsertLineBreak&&!wd?(i.isInsertLineBreak=!1,K(r,Dp,!1)):K(r,Op);break;case`insertFromPaste`:case`insertFromPasteAsQuotation`:K(r,Ap,e);break;case`deleteByComposition`:(function(e,t){return e!==t||U(e)||U(t)||!M_(e)||!M_(t)})(l,u)&&K(r,jp,e);break;case`deleteByDrag`:xv(Ym),K(r,jp,e);break;case`deleteByCut`:K(r,jp,e);break;case`deleteContent`:K(r,Ep,!1);break;case`deleteWordBackward`:K(r,Mp,!0);break;case`deleteWordForward`:K(r,Mp,!1);break;case`deleteHardLineBackward`:case`deleteSoftLineBackward`:K(r,Np,!0);break;case`deleteContentForward`:case`deleteHardLineForward`:case`deleteSoftLineForward`:K(r,Np,!1);break;case`formatStrikeThrough`:K(r,Pp,`strikethrough`);break;case`formatBold`:K(r,Pp,`bold`);break;case`formatItalic`:K(r,Pp,`italic`);break;case`formatUnderline`:K(r,Pp,`underline`);break;case`historyUndo`:K(r,Fp);break;case`historyRedo`:K(r,Ip)}return!0}function Om(e){let t=H(),n=t._inputState,r=V(),i=e.data,a=Sm(e),o=!1;if(i!=null&&B(r)){let s=Iv(Tv(t)),c=s===null?null:Kv(s,t._rootElement),l=e.inputType===`insertCompositionText`&&n.compositionPhase!==`ending-firefox`&&!t.isComposing();l&&(n.hadOrphanedCompositionEvents=!0);let u=r.anchor.getNode(),d=e.inputType===`insertCompositionText`&&n.compositionPhase!==`ending-firefox`&&t.isComposing()&&z(u)&&N_(u);if(!l&&!d&&_m(r,a,i,e.timeStamp,!1,c)){if(o=!0,n.compositionPhase===`ending-firefox`){let e=Mm(t,i);if(n.compositionPhase=`idle`,e)return xv(Xm),Q_(),!0}let a=r.anchor.getNode();if(s===null||c===null)return!0;let l=r.isBackward(),u=l?r.anchor.offset:r.focus.offset,d=l?r.focus.offset:r.anchor.offset;Cd&&!r.isCollapsed()&&z(a)&&c.anchorNode!==null&&a.getTextContent().slice(0,u)+i+a.getTextContent().slice(u+d)===rv(c.anchorNode)||K(t,kp,i);let f=i.length;Sd&&f>1&&e.inputType===`insertCompositionText`&&!t.isComposing()&&(r.anchor.offset-=f,r._cachedNodes=null,r._cachedIsBackward=null),Od&&t.isComposing()&&(n.lastKeyDownTimeStamp=0,V_(null))}}return o||(iv(!1,t,i===null?void 0:i),n.compositionPhase===`ending-firefox`&&(Mm(t,i||void 0),xv(`composition-end`),n.compositionPhase=`idle`)),Q_(),!0}function km(e){let t=H(),n=t._inputState,r=V();if(B(r)&&!t.isComposing()){n.compositionPhase=`composing`,n.hadOrphanedCompositionEvents=!1;let i=r.anchor,a=r.anchor.getNode();if(V_(i.key),xv(`composition-start`),e.timeStamp<n.lastKeyDownTimeStamp+30||i.type===`element`||!r.isCollapsed()||!Od&&(a.getFormat()!==r.format||z(a)&&a.getStyle()!==r.style)||z(a)&&(N_(a)||i.offset===0&&!a.canInsertTextBefore()||i.offset===a.getTextContentSize()&&!a.canInsertTextAfter())){K(t,kp,jd);let e=V();B(e)&&V_(e.anchor.key)}}return!0}function Am(e){let t=H();return t._inputState.compositionPhase=`idle`,Mm(t,e.data),xv(Xm),!0}function jm(e){if(e===null)return;let t=U_(e);if(!z(t)||t.getType()===`text`||N_(t)||!t.isAttached())return;let n=V(),r=B(n)&&n.anchor.key===e?n.anchor.offset:null,i=gh(t.getTextContent());if(i.setFormat(t.getFormat()),i.setStyle(t.getStyle()),t.replace(i),r!==null){let e=Math.min(r,i.getTextContentSize());i.select(e,e)}}function Mm(e,t){let n=e._compositionKey;if(V_(null),n!==null&&t!=null){if(t===``){let t=U_(n),r=e.getElementByKey(n),i=r!==null&&z(t)?uy(t,r,e):null;if(i!==null&&i.nodeValue!==null&&z(t)){let n=Iv(Tv(e)),r=n&&Kv(n,e._rootElement),a=null,o=null;r!==null&&r.anchorNode===i&&(a=r.anchorOffset,o=r.focusOffset),av(t,i.nodeValue,a,o,!0)}return jm(n),!1}if(t[t.length-1]===`
139
- `){let t=V();if(B(t)||Ah(t)){if(B(t)){let e=t.focus;t.anchor.set(e.key,e.offset,e.type)}return K(e,Wp,null),jm(n),!1}}let r=U_(n);if(r!==null&&z(r)&&N_(r)){r.markDirty();let e=V(),i=r.getTextContentSize(),a=B(e)&&e.anchor.key===n?e.anchor.offset:i;return r.select(a,a).insertText(t),!0}}return iv(!0,e,t),jm(n),!1}function Nm(e){let t=H(),n=t._inputState;if(e.key==null)return!0;if(n.compositionPhase===`ending-safari`){let r=dv(e);if(r&&Hg(t,()=>{Mm(t,n.compositionEndData)}),n.compositionPhase=`idle`,n.compositionEndData=``,r)return!0}if(function(e){return G(e,`ArrowRight`,{shiftKey:`any`})}(e))K(t,Rp,e);else if(function(e){return G(e,`ArrowRight`,{...lv,shiftKey:`any`})}(e))K(t,zp,e);else if(function(e){return G(e,`ArrowLeft`,{shiftKey:`any`})}(e))K(t,Bp,e);else if(function(e){return G(e,`ArrowLeft`,{...lv,shiftKey:`any`})}(e))K(t,Vp,e);else if(function(e){return G(e,`ArrowUp`,{altKey:`any`,shiftKey:`any`})}(e))K(t,Hp,e);else if(function(e){return G(e,`ArrowDown`,{altKey:`any`,shiftKey:`any`})}(e))K(t,Up,e);else if(function(e){return G(e,`Enter`,{altKey:`any`,ctrlKey:`any`,metaKey:`any`,shiftKey:!0})}(e))n.isInsertLineBreak=!0,K(t,Wp,e);else if(function(e){return e.key===` `}(e))K(t,Gp,e);else if(function(e){return xd&&G(e,`o`,{ctrlKey:!0})}(e))e.preventDefault(),n.isInsertLineBreak=!0,K(t,Dp,!0);else if(function(e){return G(e,`Enter`,{altKey:`any`,ctrlKey:`any`,metaKey:`any`})}(e))n.isInsertLineBreak=!1,K(t,Wp,e);else if(function(e){return G(e,`Backspace`,{shiftKey:`any`})||xd&&G(e,`h`,{ctrlKey:!0})}(e))dv(e)?K(t,Kp,e)&&Tm(n):(e.preventDefault(),K(t,Ep,!0));else if(function(e){return e.key===`Escape`}(e))K(t,qp,e);else if(function(e){return G(e,`Delete`,{})||xd&&G(e,`d`,{ctrlKey:!0})}(e))(function(e){return e.key===`Delete`})(e)?K(t,Jp,e):(e.preventDefault(),K(t,Ep,!1));else if(function(e){return G(e,`Backspace`,uv)}(e))e.preventDefault(),K(t,Mp,!0);else if(function(e){return G(e,`Delete`,uv)}(e))e.preventDefault(),K(t,Mp,!1);else if(function(e){return xd&&G(e,`Backspace`,{metaKey:!0})}(e))e.preventDefault(),K(t,Np,!0);else if(function(e){return xd&&(G(e,`Delete`,{metaKey:!0})||G(e,`k`,{ctrlKey:!0}))}(e))e.preventDefault(),K(t,Np,!1);else if(function(e){return G(e,`b`,lv)}(e))e.preventDefault(),K(t,Pp,`bold`);else if(function(e){return G(e,`u`,lv)}(e))e.preventDefault(),K(t,Pp,`underline`);else if(function(e){return G(e,`i`,lv)}(e))e.preventDefault(),K(t,Pp,`italic`);else if(function(e){return G(e,`Tab`,{shiftKey:`any`})}(e))K(t,Yp,e);else if(function(e){return G(e,`z`,lv)}(e))e.preventDefault(),K(t,Fp);else if(function(e){return xd?G(e,`z`,{metaKey:!0,shiftKey:!0}):G(e,`y`,{ctrlKey:!0})||G(e,`z`,{ctrlKey:!0,shiftKey:!0})}(e))e.preventDefault(),K(t,Ip);else{let r=t._editorState._selection;(function(e){return G(e,`a`,lv)})(e)?(e.preventDefault(),K(t,nm,e)&&Tm(n)):r===null||B(r)||(function(e){return G(e,`c`,lv)}(e)?(e.preventDefault(),K(t,em,e)):function(e){return G(e,`x`,lv)}(e)&&(e.preventDefault(),K(t,tm,e)))}return function(e){return e.ctrlKey||e.shiftKey||e.altKey||e.metaKey}(e)&&t.dispatchCommand(lm,e),!0}function Pm(e){let t=e.__lexicalEventHandles;return t===void 0&&(t=[],e.__lexicalEventHandles=t),t}let Fm=/* @__PURE__ */ new Map;function Im(e){let t=Lv(e.target);if(t===null)return;let n=bv(e.target),r=null,i=null,a=n===null?void 0:hm.get(n);if(n!==null){if(a!==void 0){let e=a.editors,n=a.hasShadowEditor;if(n===void 0){n=!1;for(let t of e)if(t._rootElement!==null&&Rv(t._rootElement.getRootNode())){n=!0;break}a.hasShadowEditor=n}if(n){let n=null,a=null;for(let o of e){let e=o._rootElement;if(e===null)continue;let s=Kv(t,e).anchorNode;if(s!==null&&A_(s)===o){if(Rv(e.getRootNode())){r=o,i=s;break}n===null&&(n=o,a=s)}}r===null&&n!==null&&(r=n,i=a)}else{let e=t.anchorNode;e===null||q(e)&&e.shadowRoot!==null||(r=A_(e),r!==null&&(i=e))}}if(r===null){let e=Zv(n);r=e===null?null:A_(e)}}if(r===null)return;if(r._inputState.isSelectionChangeFromMouseDown){if(a!==void 0)for(let e of a.editors)e._inputState.isSelectionChangeFromMouseDown=!1;Hg(r,()=>{let n=$h(),a=i??Kv(t,r._rootElement).anchorNode;(q(a)||P_(a))&&Z_(Qh(n,t,r,e))})}let o=tv(r),s=o[o.length-1],c=s._key,l=Fm.get(c),u=l||s;u!==r&&ym(t,u,!1),ym(t,r,!0),r===s?l&&Fm.delete(c):Fm.set(c,r)}function Lm(e){e._lexicalHandled=!0}function Rm(e){return!0===e._lexicalHandled}function zm(e){let t=mm.get(e);if(t===void 0)return;let n=hm.get(t);if(n===void 0)return;mm.delete(e);let r=j_(e);k_(r)?(function(e){if(e._parentEditor!==null){let t=tv(e),n=t[t.length-1]._key;Fm.get(n)===e&&Fm.delete(n)}else Fm.delete(e._key)}(r),n.editors.delete(r),n.hasShadowEditor=void 0,e.__lexicalEditor=null):r&&F(198);let i=Pm(e);for(let e=0;e<i.length;e++)i[e]();e.__lexicalEventHandles=[]}function Bm(e,t,n){wg();let r=e.__key,i=e.getParent();if(i===null)return void(Fy(e)!==null&&F(367,r,String(Fy(e))));let a=function(e){let t=V();if(!B(t)||!U(e))return t;let{anchor:n,focus:r}=t,i=n.getNode(),a=r.getNode();return Cv(i,e)&&n.set(e.__key,0,`element`),Cv(a,e)&&r.set(e.__key,0,`element`),t}(e),o=!1;if(B(a)&&t){let t=a.anchor,n=a.focus;t.key===r&&(ng(t,e,i,e.getPreviousSibling(),e.getNextSibling()),o=!0),n.key===r&&(ng(n,e,i,e.getPreviousSibling(),e.getNextSibling()),o=!0)}else Ah(a)&&t&&e.isSelected()&&e.selectPrevious();if(B(a)&&t&&!o){let t=e.getIndexWithinParent();z_(e),eg(a,i,t,-1)}else z_(e);n||kv(i)||i.canBeEmpty()||!i.isEmpty()||Bm(i,t),t&&a&&Jg(i)&&i.isEmpty()&&i.selectEnd()}let Vm=Symbol.for(`ephemeral`);function Hm(e){return e[Vm]||!1}let Um={configurable:!0,enumerable:!1,value:void 0,writable:!0};var Wm=class{__type;__key;__parent;__prev;__next;__state;[Df];static getType(){let{ownNodeType:e}=Ey(this);return e===void 0&&F(64,this.name),e}static clone(e){F(65,this.name)}$config(){return{}}config(e,t){let n=t.extends||jy(this.constructor);return Object.assign(t,{extends:n}),typeof e==`string`&&Object.assign(t,{type:e}),{[e]:t}}afterCloneFrom(e){this.__key===e.__key?(this.__parent=e.__parent,this.__next=e.__next,this.__prev=e.__prev,this.__state=e.__state):e.__state&&(this.__state=e.__state.getWritable(this))}resetOnCopyNodeFrom(e){this.__state&&=this.__state.getWritable(this).resetOnCopyNode()}static importDOM;constructor(e){this.__type=this.constructor.getType(),this.__parent=null,this.__prev=null,this.__next=null,Object.defineProperty(this,"__state",Um),Object.defineProperty(this,Df,Um),R_(this,e)}getType(){return this.__type}isInline(){F(137,this.constructor.name)}isAttached(){let e=this.__key;for(;e!==null;){if(e===`root`)return!0;let t=U_(e);if(t===null)break;e=t.__parent===null?Fy(t):t.__parent}return!1}isSelected(e){let t=e||V();if(t==null)return!1;let n=t.getNodes().some(e=>e.__key===this.__key);if(z(this))return n;if(B(t)&&t.anchor.type===`element`&&t.focus.type===`element`){if(t.isCollapsed())return!1;let e=this.getParent();if(W(this)&&this.isInline()&&e){let n=t.isBackward()?t.focus:t.anchor;if(e.is(n.getNode())&&n.offset===e.getChildrenSize()&&this.is(e.getLastChild()))return!1}}return n}getKey(){return this.__key}getIndexWithinParent(){let e=this.getParent();if(e===null)return-1;let t=e.getFirstChild(),n=0;for(;t!==null;){if(this.is(t))return n;n++,t=t.getNextSibling()}return-1}getParent(){let e=this.getLatest().__parent;return e===null?null:U_(e)}getParentOrThrow(){let e=this.getParent();return e===null&&F(66,this.__key),e}getTopLevelElement(){let e=this;for(;e!==null;){let t=e.getParent();if(kv(t)||Fy(e)!==null)return U(e)||e===this&&W(e)||F(194),e;e=t}return null}getTopLevelElementOrThrow(){let e=this.getTopLevelElement();return e===null&&F(67,this.__key),e}getParents(){let e=[],t=this.getParent();for(;t!==null;)e.push(t),t=t.getParent();return e}getParentKeys(){let e=[],t=this.getParent();for(;t!==null;)e.push(t.__key),t=t.getParent();return e}getPreviousSibling(){let e=this.getLatest().__prev;return e===null?null:U_(e)}getPreviousSiblings(){let e=[],t=this.getParent();if(t===null)return e;let n=t.getFirstChild();for(;n!==null&&!n.is(this);)e.push(n),n=n.getNextSibling();return e}getNextSibling(){let e=this.getLatest().__next;return e===null?null:U_(e)}getNextSiblings(){let e=[],t=this.getNextSibling();for(;t!==null;)e.push(t),t=t.getNextSibling();return e}getCommonAncestor(e){let t=U(this)?this:this.getParent(),n=U(e)?e:e.getParent(),r=t&&n?jb(t,n):null;return r?r.commonAncestor:null}is(e){return e!=null&&this.__key===e.__key}isBefore(e){let t=jb(this,e);return t!==null&&(t.type===`descendant`||(t.type===`branch`?Ob(t)===-1:(t.type!==`same`&&t.type!==`ancestor`&&F(279),!1)))}isParentOf(e){return Cv(e,this)}getNodesBetween(e){let t=this.isBefore(e),n=[],r=/* @__PURE__ */ new Set,i=this;for(;i!==null;){let a=i.__key;if(r.has(a)||(r.add(a),n.push(i)),i===e)break;let o=U(i)?t?i.getFirstChild():i.getLastChild():null;if(o!==null){i=o;continue}let s=t?i.getNextSibling():i.getPreviousSibling();if(s!==null){i=s;continue}let c=i.getParentOrThrow();if(r.has(c.__key)||n.push(c),c===e)break;let l=null,u=c;do{if(u===null&&F(68),l=t?u.getNextSibling():u.getPreviousSibling(),u=u.getParent(),u===null)break;l!==null||r.has(u.__key)||n.push(u)}while(l===null);i=l}return t||n.reverse(),n}isDirty(){let e=H()._dirtyLeaves;return e!==null&&e.has(this.__key)}getLatest(){if(Hm(this))return this;let e=U_(this.__key);return e===null&&F(113),e}getWritable(){if(Hm(this))return this;wg();let e=Eg(),t=H(),n=e._nodeMap,r=this.__key,i=this.getLatest(),a=t._cloneNotNeeded,o=V();if(o!==null&&o.setCachedNodes(null),a.has(r))return B_(i),i;let s=my(i);return a.add(r),B_(s),n.set(r,s),s}getTextContent(){return Jy(this)}getTextContentSize(){return this.getTextContent().length}createDOM(e,t){F(70)}updateDOM(e,t,n){F(71)}getDOMSlot(e){return new Ud(e)}exportDOM(e){return{element:this.createDOM(e._config,e)}}exportJSON(){let e=this.__state?this.__state.toJSON():void 0;return{type:this.__type,version:1,...e}}static importJSON(e){F(18,this.name)}updateFromJSON(e){return function(e,t){let n=e.getWritable(),r=t.$,i=r;for(let e of gf(n).flatKeys)e in t&&(i!==void 0&&i!==r||(i={...r}),i[e]=t[e]);return(n.__state||i)&&hf(e).updateFromJSON(i),n}(this,e)}static transform(){return null}remove(e){Bm(this,!0,e)}replace(e,t){wg();let n=V();n!==null&&(n=n.clone()),Mv(this,e);let r=this.getLatest(),i=this.__key,a=e.__key,o=e.getWritable(),s=this.getParentOrThrow().getWritable(),c=s.__size,l=o.getParent(),u=l===null?-1:o.getIndexWithinParent();z_(o),l!==null&&B(n)&&eg(n,l,u,-1);let d=r.getPreviousSibling(),f=r.getNextSibling(),p=r.__prev,m=r.__next,h=r.__parent;Bm(r,!1,!0),d===null?s.__first=a:d.getWritable().__next=a,o.__prev=p,f===null?s.__last=a:f.getWritable().__prev=a,o.__next=m,o.__parent=h,s.__size=c;let g=0;t&&(U(this)&&U(o)||F(139),g=o.getChildrenSize(),o.splice(g,0,this.getChildren()));let _=By(this);if(_.length>0){Ny(this)&&Ny(o)||F(368,this.__key,o.__key);for(let e of _){let t=Vy(this,e);t!==null&&(Qy(this,e),Zy(o,e,t))}}if(B(n)){Z_(n);let e=n.anchor,r=n.focus;e.key===i&&(t&&e.type===`element`?e.set(o.__key,g+e.offset,`element`):wh(e,o)),r.key===i&&(t&&r.type===`element`?r.set(o.__key,g+r.offset,`element`):wh(r,o))}return H_()===i&&V_(a),o}insertAfter(e,t=!0){wg(),Mv(this,e);let n=this.getWritable(),r=e.getWritable();this.getParentOrThrow();let i=r.getParent(),a=V(),o=!1,s=!1;if(i!==null){let n=e.getIndexWithinParent();if(B(a)){let e=i.__key,t=a.anchor,r=a.focus;o=t.type===`element`&&t.key===e&&t.offset===n+1,s=r.type===`element`&&r.key===e&&r.offset===n+1}z_(r),t&&B(a)&&eg(a,i,n,-1)}else z_(r);let c=this.getNextSibling(),l=this.getParentOrThrow().getWritable(),u=r.__key,d=n.__next;if(c===null?l.__last=u:c.getWritable().__prev=u,l.__size++,n.__next=u,r.__next=d,r.__prev=n.__key,r.__parent=n.__parent,t&&B(a)){let e=this.getIndexWithinParent();eg(a,l,e+1);let t=l.__key;o&&a.anchor.set(t,e+2,`element`),s&&a.focus.set(t,e+2,`element`)}return e}insertBefore(e,t=!0){wg(),Mv(this,e);let n=this.getWritable(),r=e.getWritable();this.getParentOrThrow();let i=r.__key,a=V(),o=r.getParent(),s=o===null?-1:r.getIndexWithinParent();z_(r),o!==null&&t&&B(a)&&eg(a,o,s,-1);let c=this.getPreviousSibling(),l=this.getParentOrThrow().getWritable(),u=n.__prev,d=this.getIndexWithinParent();return c===null?l.__first=i:c.getWritable().__next=i,l.__size++,n.__prev=i,r.__prev=u,r.__next=n.__key,r.__parent=n.__parent,t&&B(a)&&eg(a,this.getParentOrThrow(),d),e}isParentRequired(){return!1}createParentElementNode(){return u_()}selectStart(){return this.selectPrevious()}selectEnd(){return this.selectNext(0,0)}selectPrevious(e,t){wg();let n=Iy(this);if(n!==null)return n.selectPrevious(e,t);let r=this.getPreviousSibling(),i=this.getParentOrThrow();if(r===null)return i.select(0,0);if(U(r))return r.select();if(!z(r)){let e=r.getIndexWithinParent()+1;return i.select(e,e)}return r.select(e,t)}selectNext(e,t){wg();let n=Iy(this);if(n!==null)return n.selectNext(e,t);let r=this.getNextSibling(),i=this.getParentOrThrow();if(r===null)return i.select();if(U(r))return r.select(0,0);if(!z(r)){let e=r.getIndexWithinParent();return i.select(e,e)}return r.select(e,t)}markDirty(){this.getWritable()}reconcileObservedMutation(e,t){this.markDirty()}};function Gm(e){return e instanceof Wm}let Km=`history-merge`,qm=`paste`,Jm=`skip-dom-selection`,Ym=`skip-selection-focus`,Xm=`composition-end`;function Zm(e){let t={};if(!e)return t;let n=``,r=``,i=null,a=!1,o=!1,s=!1,c=0,l=e.length,u=-1;for(let d=0;d<l;d++){let l=e[d];if(a)l===`*`&&e[d+1]===`/`&&(a=!1,d++);else if(o)u===-1&&(u=d),o=!1;else if(i===null){if(l!==`/`||e[d+1]!==`*`){if(l!==`"`&&l!==`'`){if(l!==`(`){if(l!==`)`){if(s||l!==`:`||c!==0){if(l===`;`&&c===0){u!==-1&&(s?r+=e.slice(u,d):n+=e.slice(u,d),u=-1);let i=n.trim(),a=r.trim();i!==``&&a!==``&&(t[i]=a),n=``,r=``,s=!1;continue}u===-1&&(u=d)}else u!==-1&&(n+=e.slice(u,d),u=-1),s=!0}else u===-1&&(u=d),c=Math.max(0,c-1)}else u===-1&&(u=d),c++}else u===-1&&(u=d),i=l}else u!==-1&&(s?r+=e.slice(u,d):n+=e.slice(u,d),u=-1),a=!0,d++}else u===-1&&(u=d),l===`\\`?o=!0:l===i&&(i=null)}u!==-1&&(s?r+=e.slice(u,l):n+=e.slice(u,l));let d=n.trim(),f=r.trim();return d!==``&&f!==``&&(t[d]=f),t}function Qm(e,t,n){let r=n.trimEnd(),i=r.length-10;i>=0&&r.slice(i).toLowerCase()===`!important`?e.setProperty(t,r.slice(0,i).trim(),`important`):e.setProperty(t,n,``)}function $m(e,t,n=``){if(t===n)return;let r=Zm(n),i=Zm(t);for(let t in i)delete r[t],Qm(e,t,i[t]);for(let t in r)e.removeProperty(t)}function eh(e,t){return 16&t?`code`:t&128?`mark`:32&t?`sub`:64&t?`sup`:null}function th(e,t){return 1&t?`strong`:2&t?`em`:`span`}function nh(e,t,n,r,i){let a=r.classList,o=pv(i,`base`);o!==void 0&&a.add(...o),o=pv(i,`underlineStrikethrough`);let s=!1,c=8&t&&4&t;o!==void 0&&(8&n&&4&n?(s=!0,c||a.add(...o)):c&&a.remove(...o));for(let e in Pd){let r=Pd[e];if(o=pv(i,e),o!==void 0){if(n&r){if(s&&(e===`underline`||e===`strikethrough`)){t&r&&a.remove(...o);continue}((t&r)===0||c&&e===`underline`||e===`strikethrough`)&&a.add(...o)}else t&r&&a.remove(...o)}}}function rh(e,t,n){let r=n.isComposing(),i=e+(r?Ad:``),a=oy(),o=sy(a).$getDOMSlot(n,t,a),s=o.getFirstChild();if(s===null||s.nodeType!==Node.TEXT_NODE)return void o.insertChild(Uv().createTextNode(i));let c=s,l=c.nodeValue;if(l!==i){if(r||Sd){let[e,t,n]=function(e,t){let n=e.length,r=t.length,i=0,a=0;for(;i<n&&i<r&&e[i]===t[i];)i++;for(;a+i<n&&a+i<r&&e[n-a-1]===t[r-a-1];)a++;return[i,n-i-a,t.slice(i,r-a)]}(l,i);t!==0&&c.deleteData(e,t),c.insertData(e,n)}else c.nodeValue=i}}function ih(e,t,n,r,i,a){rh(i,e,t);let o=a.theme.text;o!==void 0&&nh(0,0,r,e,o)}function ah(e,t){let n=Uv().createElement(t);return n.appendChild(e),n}function oh(e){return e!=null&&!0===e.__isInlineFormattable}var sh=class extends Wm{__text;__format;__style;__mode;__detail;get __isInlineFormattable(){return!0}$config(){return this.config(`text`,{importDOM:{"#text":()=>({conversion:fh,priority:0}),b:()=>({conversion:lh,priority:0}),code:()=>({conversion:hh,priority:0}),em:()=>({conversion:hh,priority:0}),i:()=>({conversion:hh,priority:0}),mark:()=>({conversion:hh,priority:0}),s:()=>({conversion:hh,priority:0}),span:()=>({conversion:ch,priority:0}),strong:()=>({conversion:hh,priority:0}),sub:()=>({conversion:hh,priority:0}),sup:()=>({conversion:hh,priority:0}),u:()=>({conversion:hh,priority:0})}})}afterCloneFrom(e){super.afterCloneFrom(e),this.__text=e.__text,this.__format=e.__format,this.__style=e.__style,this.__mode=e.__mode,this.__detail=e.__detail}constructor(e=``,t){super(t),this.__text=e,this.__format=0,this.__style=``,this.__mode=0,this.__detail=0}getFormat(){return this.getLatest().__format}getDetail(){return this.getLatest().__detail}getMode(){let e=this.getLatest();return zd[e.__mode]}getStyle(){return this.getLatest().__style}isToken(){return this.getLatest().__mode===1}isComposing(){return this.__key===H_()}isSegmented(){return this.getLatest().__mode===2}isDirectionless(){return!!(1&this.getLatest().__detail)}isUnmergeable(){return!!(2&this.getLatest().__detail)}hasFormat(e){let t=Pd[e];return(this.getFormat()&t)!==0}isSimpleText(){return this.__type===`text`&&this.__mode===0}getTextContent(){return this.getLatest().__text}getFormatFlags(e,t){return L_(this.getLatest().__format,e,t)}canHaveFormat(){return!0}isInline(){return!0}createDOM(e,t){let n=this.__format,r=eh(0,n),i=th(0,n),a=r===null?i:r,o=Uv().createElement(a),s=o;this.hasFormat(`code`)&&o.setAttribute(`spellcheck`,`false`),r!==null&&(s=Uv().createElement(i),o.appendChild(s)),ih(s,this,0,n,this.__text,e);let c=this.__style;return c!==``&&$m(o.style,c),o}updateDOM(e,t,n){let r=this.__text,i=e.__format,a=this.__format,o=eh(0,i),s=eh(0,a),c=th(0,i),l=th(0,a);if((o===null?c:o)!==(s===null?l:s))return!0;if(o===s&&c!==l){let e=t.firstChild;e??F(48);let i=Uv().createElement(l);return ih(i,this,0,a,r,n),t.replaceChild(i,e),!1}let u=t;s!==null&&o!==null&&(u=t.firstChild,u??F(49)),rh(r,u,this);let d=n.theme.text;d!==void 0&&i!==a&&nh(0,i,a,u,d);let f=e.__style,p=this.__style;return f!==p&&$m(t.style,p,f),!1}updateFromJSON(e){return super.updateFromJSON(e).setTextContent(e.text).setFormat(e.format).setDetail(e.detail).setMode(e.mode).setStyle(e.style)}exportDOM(e){let{element:t}=super.exportDOM(e);return q(t)||F(132),t.style.whiteSpace=`pre-wrap`,this.hasFormat(`lowercase`)?t.style.textTransform=`lowercase`:this.hasFormat(`uppercase`)?t.style.textTransform=`uppercase`:this.hasFormat(`capitalize`)&&(t.style.textTransform=`capitalize`),this.hasFormat(`bold`)&&(t=ah(t,`b`)),this.hasFormat(`italic`)&&(t=ah(t,`i`)),this.hasFormat(`strikethrough`)&&(t=ah(t,`s`)),this.hasFormat(`underline`)&&(t=ah(t,`u`)),{element:t}}exportJSON(){return{detail:this.getDetail(),format:this.getFormat(),mode:this.getMode(),style:this.getStyle(),text:this.getTextContent(),...super.exportJSON()}}selectionTransform(e,t){}setFormat(e){let t=this.getWritable();return t.__format=typeof e==`string`?Pd[e]:e,t}setDetail(e){let t=this.getWritable();return t.__detail=typeof e==`string`?Fd[e]:e,t}setStyle(e){let t=this.getWritable();return t.__style=e,t}toggleFormat(e){let t=L_(this.getFormat(),e,null);return this.setFormat(t)}toggleDirectionless(){let e=this.getWritable();return e.__detail^=1,e}toggleUnmergeable(){let e=this.getWritable();return e.__detail^=2,e}setMode(e){let t=Rd[e];if(this.__mode===t)return this;let n=this.getWritable();return n.__mode=t,n}setTextContent(e){if(this.__text===e)return this;let t=this.getWritable();return t.__text=e,t}select(e,t){wg();let n=e,r=t,i=V(),a=this.getTextContent(),o=this.__key;if(typeof a==`string`){let e=a.length;n===void 0&&(n=e),r===void 0&&(r=e)}else n=0,r=0;if(!B(i))return Yh(o,n,o,r,`text`,`text`);{let e=H_();e!==i.anchor.key&&e!==i.focus.key||V_(o),i.setTextNodeRange(this,n,this,r)}return i}selectStart(){return this.select(0,0)}selectEnd(){let e=this.getTextContentSize();return this.select(e,e)}spliceText(e,t,n,r){let i=this.getWritable(),a=i.__text,o=n.length,s=e;s<0&&(s=o+s,s<0&&(s=0));let c=V();if(r&&B(c)){let t=e+o;c.setTextNodeRange(i,t,i,t)}return i.__text=a.slice(0,s)+n+a.slice(s+t),i}canInsertTextBefore(){return!0}canInsertTextAfter(){return!0}splitText(...e){wg();let t=this.getLatest(),n=t.getTextContent();if(n===``)return[];let r=t.__key,i=H_(),a=n.length;e.sort((e,t)=>e-t),e.push(a);let o=[],s=e.length;for(let t=0,r=0;t<a&&r<=s;r++){let i=e[r];i>t&&(o.push(n.slice(t,i)),t=i)}let c=o.length;if(c===1)return[t];let l=o[0],u=t.getParent(),d,f=t.getFormat(),p=t.getStyle(),m=t.__detail,h=!1,g=null,_=null,v=V();if(B(v)){let[e,t]=v.isBackward()?[v.focus,v.anchor]:[v.anchor,v.focus];e.type===`text`&&e.key===r&&(g=e),t.type===`text`&&t.key===r&&(_=t)}t.isSegmented()?(d=gh(l),d.__format=f,d.__style=p,d.__detail=m,d.__state=xf(t,d),h=!0):d=t.setTextContent(l);let y=[d];for(let e=1;e<c;e++){let n=gh(o[e]);n.__format=f,n.__style=p,n.__detail=m,n.__state=xf(t,n);let a=n.__key;i===r&&V_(a),y.push(n)}let b=g?g.offset:null,ee=_?_.offset:null,te=0;for(let e of y){if(!g&&!_)break;let t=te+e.getTextContentSize();if(g!==null&&b!==null&&b<=t&&b>=te&&(g.set(e.getKey(),b-te,`text`),b<t&&(g=null)),_!==null&&ee!==null&&ee<=t&&ee>=te){_.set(e.getKey(),ee-te,`text`);break}te=t}if(u!==null){(function(e){let t=e.getPreviousSibling(),n=e.getNextSibling();t!==null&&B_(t),n!==null&&B_(n)})(this);let e=u.getWritable(),t=this.getIndexWithinParent();h?(e.splice(t,0,y),this.remove()):e.splice(t,1,y),B(v)&&eg(v,u,t,c-1)}return y}mergeWithSibling(e){let t=e===this.getPreviousSibling();t||e===this.getNextSibling()||F(50);let n=this.__key,r=e.__key,i=this.__text,a=i.length;H_()===r&&V_(n);let o=V();if(B(o)){let i=o.anchor,s=o.focus;i!==null&&i.key===r&&rg(i,t,n,e,a),s!==null&&s.key===r&&rg(s,t,n,e,a)}let s=e.__text,c=t?s+i:i+s;this.setTextContent(c);let l=this.getWritable();return e.remove(),l}isTextEntity(){return!1}};function ch(e){return{forChild:_h(e.style),node:null}}function lh(e){let t=e,n=t.style.fontWeight===`normal`;return{forChild:_h(t.style,n?void 0:`bold`),node:null}}let uh=/* @__PURE__ */ new WeakMap;function dh(e){if(!q(e))return!1;if(e.nodeName===`PRE`)return!0;let t=e.style.whiteSpace;return typeof t==`string`&&t.startsWith(`pre`)}function fh(e){let t=e;e.parentElement===null&&F(129);let n=t.textContent||``;if(function(e){let t,n=e.parentNode,r=[e];for(;n!==null&&(t=uh.get(n))===void 0&&!dh(n);)r.push(n),n=n.parentNode;let i=t===void 0?n:t;for(let e=0;e<r.length;e++)uh.set(r[e],i);return i}(t)!==null)return{node:cg(n)};if(n=n.replace(/\r/g,``).replace(/[ \t\n]+/g,` `),n===``)return{node:null};if(n[0]===` `){let e=t,r=!0;for(;e!==null&&(e=ph(e,!1))!==null;){let t=e.textContent||``;if(t.length>0){/[ \t\n]$/.test(t)&&(n=n.slice(1)),r=!1;break}}r&&(n=n.slice(1))}if(n[n.length-1]===` `){let e=t,r=!0;for(;e!==null&&(e=ph(e,!0))!==null;)if((e.textContent||``).replace(/^( |\t|\r?\n)+/,``).length>0){r=!1;break}r&&(n=n.slice(0,n.length-1))}return n===``?{node:null}:{node:gh(n)}}function ph(e,t){let n=e;for(;;){let e;for(;(e=t?n.nextSibling:n.previousSibling)===null;){let e=n.parentElement;if(e===null)return null;n=e}if(n=e,q(n)){let e=n.style.display;if(e===``&&!ny(n)||e!==``&&!e.startsWith(`inline`))return null}let r=n;for(;(r=t?n.firstChild:n.lastChild)!==null;)n=r;if(P_(n))return n;if(n.nodeName===`BR`)return null}}let mh={code:`code`,em:`italic`,i:`italic`,mark:`highlight`,s:`strikethrough`,strong:`bold`,sub:`subscript`,sup:`superscript`,u:`underline`};function hh(e){let t=mh[e.nodeName.toLowerCase()];return t===void 0?{node:null}:{forChild:_h(e.style,t),node:null}}function gh(e=``){return jv(new sh(e))}function z(e){return e instanceof sh}function _h(e,t){let n=e.fontWeight,r=e.textDecoration.split(` `),i=n===`700`||n===`bold`,a=r.includes(`line-through`),o=e.fontStyle===`italic`,s=r.includes(`underline`),c=e.verticalAlign;return e=>((z(e)||oh(e))&&(i&&!e.hasFormat(`bold`)&&e.toggleFormat(`bold`),a&&!e.hasFormat(`strikethrough`)&&e.toggleFormat(`strikethrough`),o&&!e.hasFormat(`italic`)&&e.toggleFormat(`italic`),s&&!e.hasFormat(`underline`)&&e.toggleFormat(`underline`),c!==`sub`||e.hasFormat(`subscript`)||e.toggleFormat(`subscript`),c!==`super`||e.hasFormat(`superscript`)||e.toggleFormat(`superscript`),t&&!e.hasFormat(t)&&e.toggleFormat(t)),e)}var vh=class extends sh{$config(){return this.config(`tab`,{extends:sh})}constructor(e=void 0){super(` `,e),this.__detail=2}createDOM(e){let t=super.createDOM(e),n=pv(e.theme,`tab`);return n!==void 0&&t.classList.add(...n),t}setTextContent(e){return super.setTextContent(` `)}spliceText(e,t,n,r){return n===``&&t===0||n===` `&&t===1||F(286),this}setDetail(e){return e!==2&&F(127),this}setMode(e){return e!==`normal`&&F(128),this}canInsertTextBefore(){return!1}canInsertTextAfter(){return!1}};function yh(){return jv(new vh)}function bh(e){return e instanceof vh}var xh=class{key;offset;type;_selection;constructor(e,t,n){this._selection=null,this.key=e,this.offset=t,this.type=n}is(e){return this.key===e.key&&this.offset===e.offset&&this.type===e.type}isBefore(e){return this.key===e.key?this.offset<e.offset:Db(Vb(Mb(this,`next`)),Vb(Mb(e,`next`)))<0}getNode(){let e=U_(this.key);return e===null&&F(20),e}set(e,t,n,r){let i=this._selection,a=this.key;r&&this.key===e&&this.offset===t&&this.type===n||(this.key=e,this.offset=t,this.type=n,Cg()||(H_()===a&&V_(e),i!==null&&(i.setCachedNodes(null),B(i)&&(i._cachedIsBackward=null),i.dirty=!0)))}};function Sh(e,t,n){return new xh(e,t,n)}function Ch(e,t){let n=t.__key,r=e.offset,i=`element`;if(z(t)){i=`text`;let e=t.getTextContentSize();r>e&&(r=e)}else if(!U(t)){let e=t.getNextSibling();if(z(e))n=e.__key,r=0,i=`text`;else{let e=t.getParent();e&&(n=e.__key,r=t.getIndexWithinParent()+1)}}e.set(n,r,i)}function wh(e,t){if(U(t)){let n=t.getLastDescendant();U(n)||z(n)?Ch(e,n):Ch(e,t)}else Ch(e,t)}function Th(e,t,n,r){let i=e.getNode(),a=i.getChildAtIndex(e.offset),o=gh();if(o.setFormat(n),o.setStyle(r),d_(a))a.splice(0,0,[o]);else if(a!==null){let e=kv(i)?u_().append(o):o;a.insertBefore(e)}else if(kv(i)){let e=i.getLastChild();U(e)&&!e.isInline()&&e.isEmpty()?e.append(o):i.append(u_().append(o))}else i.append(o);e.is(t)&&t.set(o.__key,0,`text`),e.set(o.__key,0,`text`)}function Eh(e,t,n,r){let i=e.anchor.getNode();z(i)||F(398);let a=e.anchor.offset,o=gh(t);o.setFormat(n),o.setStyle(r);let s=i.getParentOrThrow();if(a===0)s.isInline()&&!i.__prev?s.insertBefore(o):i.insertBefore(o,!1);else if(a===i.getTextContentSize())s.isInline()&&!i.__next?s.insertAfter(o):i.insertAfter(o,!1);else{let[e]=i.splitText(a);e.insertAfter(o,!1)}i.getTextContent()===``&&i.isAttached()&&i.remove(),o.selectEnd(),o.isComposing()&&e.anchor.type===`text`&&e.anchor.set(e.anchor.key,e.anchor.offset-t.length,e.anchor.type)}var Dh=class e{_nodes;_cachedNodes;dirty;constructor(e){this._cachedNodes=null,this._nodes=e,this.dirty=!1}getCachedNodes(){return this._cachedNodes}setCachedNodes(e){this._cachedNodes=e}is(e){if(!Ah(e))return!1;let t=this._nodes,n=e._nodes;return t.size===n.size&&Array.from(t).every(e=>n.has(e))}isCollapsed(){return!1}isBackward(){return!1}getStartEndPoints(){return null}add(e){this.dirty=!0,this._nodes.add(e),this._cachedNodes=null}delete(e){this.dirty=!0,this._nodes.delete(e),this._cachedNodes=null}clear(){this.dirty=!0,this._nodes.clear(),this._cachedNodes=null}has(e){return this._nodes.has(e)}clone(){return new e(new Set(this._nodes))}extract(){return this.getNodes()}insertRawText(e){}insertText(){}insertNodes(e){let t=this.getNodes().filter(e=>Fy(e)===null),n=t.length;if(n===0)return;let r=t[n-1],i;if(z(r))i=r.select();else{let e=r.getIndexWithinParent()+1;i=r.getParentOrThrow().select(e,e)}i.insertNodes(e);for(let e=0;e<n;e++)t[e].remove()}getNodes(){let e=this._cachedNodes;if(e!==null)return e;let t=this._nodes,n=[];for(let e of t){let t=U_(e);t!==null&&n.push(t)}return Cg()||(this._cachedNodes=n),n}getTextContent(){let e=this.getNodes(),t=``;for(let n=0;n<e.length;n++)t+=e[n].getTextContent();return t}deleteNodes(){let e=this.getNodes().filter(e=>Fy(e)===null);if((V()||$h())===this&&e[0]){let t=mb(e[0],`next`);Pb(Tb(t,t))}for(let t of e)t.remove();Oh()}};function Oh(){let e=X_();if(e.isEmpty()){let t=u_();e.append(t),t.select()}}function B(e){return e instanceof kh}var kh=class e{format;style;anchor;focus;_cachedNodes;_cachedIsBackward;dirty;constructor(e,t,n,r){this.anchor=e,this.focus=t,e._selection=this,t._selection=this,this._cachedNodes=null,this._cachedIsBackward=null,this.format=n,this.style=r,this.dirty=!1}getCachedNodes(){return this._cachedNodes}setCachedNodes(e){this._cachedNodes=e}is(e){return!!B(e)&&this.anchor.is(e.anchor)&&this.focus.is(e.focus)&&this.format===e.format&&this.style===e.style}isCollapsed(){return this.anchor.is(this.focus)}getNodes(){let e=this._cachedNodes;if(e!==null)return e;let t=function(e){let t=[],[n,r]=e.getTextSlices();n&&t.push(n.caret.origin);let i=/* @__PURE__ */ new Set,a=/* @__PURE__ */ new Set;for(let n of e)if(ub(n)){let{origin:e}=n;t.length===0?i.add(e):(a.add(e),t.push(e))}else{let{origin:e}=n;U(e)&&a.has(e)||t.push(e)}if(r&&t.push(r.caret.origin),lb(e.focus)&&U(e.focus.origin)&&e.focus.getNodeAtCaret()===null)for(let n=vb(e.focus.origin,`previous`);ub(n)&&i.has(n.origin)&&!n.origin.isEmpty()&&n.origin.is(t[t.length-1]);n=bb(n))i.delete(n.origin),t.pop();for(;t.length>1;){let e=t[t.length-1];if(!U(e)||a.has(e)||e.isEmpty()||i.has(e))break;t.pop()}if(t.length===0&&e.isCollapsed()){let n=Vb(e.anchor),r=Vb(e.anchor.getFlipped()),i=e=>cb(e)?e.origin:e.getNodeAtCaret(),a=i(n)||i(r)||(e.anchor.getNodeAtCaret()?n.origin:r.origin);t.push(a)}return t}(Wb(Ib(this),`next`));return Cg()||(this._cachedNodes=t),t}setTextNodeRange(e,t,n,r){return this.anchor.set(e.__key,t,`text`),this.focus.set(n.__key,r,`text`),this}getTextContent(){let e=this.getNodes();if(e.length===0)return``;let t=e[0],n=e[e.length-1],r=this.anchor,i=this.focus,a=r.isBefore(i),[o,s]=Ph(this),c=``,l=!0;for(let u=0;u<e.length;u++){let d=e[u];if(U(d)&&!d.isInline()){l||(c+=`
140
- `);let e=``;for(let t of By(d)){let n=Vy(d,t);n!==null&&(e+=n.getTextContent())}e===``?l=!d.isEmpty():(c+=e,l=!1)}else if(l=!1,z(d)){let e=d.getTextContent();d===t?d===n?r.type===`element`&&i.type===`element`&&i.offset!==r.offset||(e=o<s?e.slice(o,s):e.slice(s,o)):e=a?e.slice(o):e.slice(s):d===n&&(e=a?e.slice(0,s):e.slice(0,o)),c+=e}else!W(d)&&!i_(d)||d===n&&this.isCollapsed()||(c+=d.getTextContent())}return c}applyDOMRange(e){let t=H(),n=t.getEditorState()._selection,r=qh(e.startContainer,e.startOffset,e.endContainer,e.endOffset,t,n);if(r===null)return;let[i,a,o]=r;this.anchor.set(i.key,i.offset,i.type,!0),this.focus.set(a.key,a.offset,a.type,!0),o&&(this.dirty=!0),Tf(this)}clone(){let t=this.anchor,n=this.focus;return new e(Sh(t.key,t.offset,t.type),Sh(n.key,n.offset,n.type),this.format,this.style)}toggleFormat(e){this.format=L_(this.format,e,null),this.dirty=!0}setFormat(e){this.format=e,this.dirty=!0}setStyle(e){this.style=e,this.dirty=!0}hasFormat(e){let t=Pd[e];return(this.format&t)!==0}insertRawText(e){this.insertNodes(cg(e))}insertText(e){let t=this.format,n=this.style;if(!this.isCollapsed()){let r=(this.focus.isBefore(this.anchor)?this.focus:this.anchor).getNode();if(z(r)&&(t=r.getFormat(),n=r.getStyle()),this.removeText(),this.format=t,this.style=n,e===``)return;if(H_()===null)return this.anchor.type===`element`&&Th(this.anchor,this.focus,t,n),void Eh(this,e,t,n)}this.anchor.type===`element`&&Th(this.anchor,this.focus,t,n);let r=this.anchor.getNode();z(r)||F(398);let i=this.anchor.offset,a=r.getParentOrThrow(),o=r.getTextContentSize();if(N_(r)||i===0&&(!r.canInsertTextBefore()||!a.canInsertTextBefore()&&!r.__prev)||i===o&&(!r.canInsertTextAfter()||!a.canInsertTextAfter()&&!r.__next)){if(r.isSegmented()&&i!==0&&i!==o){if(H_()!==null)r.setMode(`normal`).setFormat(t).setStyle(n);else{let e=gh(r.getTextContent());e.setFormat(t),e.setStyle(n),r.replace(e),e.select(i,i)}e!==``&&this.insertText(e);return}if(e===``)return;if(i===0){let i=r.getPreviousSibling();if(z(i)&&i.canInsertTextAfter()&&!N_(i))i.select();else{let e=gh();e.setFormat(t),e.setStyle(n),a.canInsertTextBefore()?r.insertBefore(e):a.insertBefore(e),e.select()}this.insertText(e);return}if(i===o){let i=r.getNextSibling();if(z(i)&&i.canInsertTextBefore()&&!N_(i))i.select(0,0);else{let e=gh();e.setFormat(t),e.setStyle(n),a.canInsertTextAfter()?r.insertAfter(e):a.insertAfter(e),e.select(0,0)}this.insertText(e);return}let s=gh(e);s.setFormat(t),s.setStyle(n),r.replace(s),s.select();return}if(e===``)return;let s=a.isInline()&&i===0&&!r.__prev,c=a.isInline()&&i===o&&!r.__next,l=r.getFormat()!==t||r.getStyle()!==n;if(s||c||l){if(r.getTextContent()!==``||s||c)return void Eh(this,e,t,n);r.setFormat(t),r.setStyle(n)}r.spliceText(i,0,e,!0),r.isComposing()&&this.anchor.type===`text`&&this.anchor.set(this.anchor.key,this.anchor.offset-e.length,this.anchor.type)}removeText(){let e=V()===this;Fb(this,Bb(Ib(this))),e&&V()!==this&&Z_(this)}formatText(e,t=null){Mh(this,e,t)}insertNodes(e){if(e.length===0)return;this.isCollapsed()||this.removeText();let t=this.anchor.getNode();if(this.anchor.type===`element`&&U(t)&&Fy(t)!==null){let n=t.isShadowRoot()?t.getFirstChild()??t.append(u_()).getFirstChild():t.getFirstChild();if(t.isShadowRoot()&&n!==null&&!U(n)){let e=u_();n.insertBefore(e),n=e}if(n!==null){n.selectStart();let t=V();return B(t)||F(369),t.insertNodes(e)}}if(this.anchor.type===`element`&&kv(t)){let n=pg(e),r=n.getLastDescendant();t.splice(this.anchor.offset,0,n.getChildren()),r!==null&&r.selectEnd();return}let n=(this.isBackward()?this.focus:this.anchor).getNode(),r=ky(n,ay),i=e[e.length-1];if(U(r)&&`__language`in r){if(`__language`in e[0])this.insertText(e[0].getTextContent());else{let t=ug(this);r.splice(t,0,e),i.selectEnd()}return}if(!e.some(e=>(U(e)||W(e))&&!e.isInline())){U(r)||F(211,n.constructor.name,n.getType());let t=ug(this);r.splice(t,0,e),i.selectEnd();return}if(U(r)&&Fy(r)!==null){let t=ug(this),n=lg(e);r.splice(t,0,n);let i=n[n.length-1];i===void 0?r.select(t,t):i.selectEnd();return}if(r===null){let t=pg(e),n=t.getLastDescendant(),r=Mb(this.anchor,`next`);for(let e of t.getChildren())r=Yb(e,r);n!==null&&n.selectEnd();return}if(U(r)&&!r.isParentRequired()&&!kv(r.getParentOrThrow())){let t=ug(this),n=lg(e);r.splice(t,0,n);let i=n[n.length-1];i===void 0?r.select(t,t):i.selectEnd();return}let a=pg(e),o=a.getLastDescendant(),s=a.getChildren(),c=!U(r)||!r.isEmpty()?this.insertParagraph():null;c&&!r.isAttached()&&(n=this.anchor.getNode(),r=ky(n,ay));let l=s[s.length-1],u=s[0];var d;U(d=u)&&ay(d)&&!d.isEmpty()&&U(r)&&(!r.isEmpty()||r.canMergeWhenEmpty())&&(U(r)||F(211,n.constructor.name,n.getType()),r.append(...u.getChildren()),u=s[1]),u&&(r===null&&F(212,n.constructor.name,n.getType()),function(e,t){let n=t.getParentOrThrow().getLastChild(),r=t,i=[t];for(;r!==n;)r.getNextSibling()||F(140),r=r.getNextSibling(),i.push(r);let a=e;for(let e of i)a=a.insertAfter(e)}(r,u));let f=ky(o,ay);c&&U(f)&&(c.canMergeWhenEmpty()||ay(l))&&(f.append(...c.getChildren()),c.remove()),U(r)&&r.isEmpty()&&r.remove(),o.selectEnd();let p=U(r)?r.getLastChild():null;i_(p)&&f!==r&&p.remove()}insertParagraph(){let e=this.anchor.getNode();if(this.anchor.type===`element`&&kv(e)){let t=u_();return e.splice(this.anchor.offset,0,[t]),t.select(),t}let t=ug(this),n=ky(this.anchor.getNode(),ay);if(n!==null&&Fy(n)!==null)return null;U(n)||F(213);let r=n.getChildAtIndex(t),i=r?[r,...r.getNextSiblings()]:[],a=n.insertNewAfter(this,!1);return a?(a.append(...i),a.selectStart(),a):null}insertLineBreak(e){let t=r_();if(this.insertNodes([t]),e){let e=t.getParentOrThrow(),n=t.getIndexWithinParent();e.select(n,n)}}extract(){let e=[...this.getNodes()],t=e.length,n=e[0],r=e[t-1],[i,a]=Ph(this),o=this.isBackward(),[s,c]=o?[this.focus,this.anchor]:[this.anchor,this.focus],[l,u]=o?[a,i]:[i,a];if(t===0)return[];if(t===1){if(z(n)&&!this.isCollapsed()){let e=n.splitText(l,u),t=l===0?e[0]:e[1];return t?(s.set(t.getKey(),0,`text`),c.set(t.getKey(),t.getTextContentSize(),`text`),[t]):[]}return[n]}if(z(n)&&(l===n.getTextContentSize()?e.shift():l!==0&&([,n]=n.splitText(l),e[0]=n,s.set(n.getKey(),0,`text`))),z(r)){let t=r.getTextContent().length;u===0?e.pop():u!==t&&([r]=r.splitText(u),e[e.length-1]=r,c.set(r.getKey(),r.getTextContentSize(),`text`))}return e}modify(e,t,n){if(mg(this,e,t,n))return;let r=e===`move`,i=H(),a=Iv(Tv(i));if(!a)return;let o=i._blockCursorElement,s=i._rootElement,c=this.focus.getNode();s===null||o===null||!U(c)||c.isInline()||c.canBeEmpty()||Fv(o,i,s);let l=vv(i,this.focus.key),u=l;if(this.focus.type===`text`&&(u=z(c)?uy(c,l,i):null),this.dirty){let e=vv(i,this.anchor.key),t=e;if(this.anchor.type===`text`){let n=this.anchor.getNode();t=z(n)?uy(n,e,i):null}t&&u&&ig(a,t,this.anchor.offset,u,this.focus.offset)}if(n===`character`&&z(c)&&c.isUnmergeable()&&(t?this.focus.offset===0:this.focus.offset===c.getTextContentSize())){let e=mb(c,t?`previous`:`next`).getNodeAtCaret();if(z(e)){if(!r){let n=e.getTextContentSize();t?this.focus.set(e.__key,n-1,`text`):this.focus.set(e.__key,1,`text`),this.dirty=!0;return}{let n=i.getElementByKey(e.getKey()),r=n?uy(e,n,i):null;if(r){let e=t?r.length:0;ig(a,r,e,r,e)}}}}if(Lh(a,e,t?`backward`:`forward`,n),a.rangeCount>0){let e=Wv(a,i._rootElement),n=e||a.getRangeAt(0),o=this.anchor.getNode(),s=Jg(o)?o:Dv(o);this.applyDOMRange(n),this.dirty=!0,!r&&(Rh(this,t,s),(e?a.direction!==`backward`:a.anchorNode===n.startContainer&&a.anchorOffset===n.startOffset)||Ih(this))}n===`lineboundary`&&mg(this,e,t,n,`decorators`)}forwardDeletion(e,t,n){if(!n&&(e.type===`element`&&U(t)&&e.offset===t.getChildrenSize()||e.type===`text`&&e.offset===t.getTextContentSize())){let e=t.getParent(),n=t.getNextSibling()||(e===null?null:e.getNextSibling());if(U(n)&&n.isShadowRoot())return!0}return!1}deleteCharacter(e){let t=this.isCollapsed();if(this.isCollapsed()){let t=this.anchor,n=t.getNode();if(this.forwardDeletion(t,n,e))return;let r=Cb(Mb(t,e?`previous`:`next`));if(r.getTextSlices().every(e=>e===null||e.distance===0)){let e={type:`initial`};for(let t of r.iterNodeCarets(`shadowRoot`))if(ub(t)){if(!t.origin.isInline()){if(t.origin.isShadowRoot()){if(e.type===`merge-block`)break;if(U(r.anchor.origin)&&r.anchor.origin.isEmpty()){let e=Vb(t);Fb(this,Tb(e,e)),r.anchor.origin.remove()}return}e.type!==`merge-next-block`&&e.type!==`merge-block`||(e={block:e.block,caret:t,type:`merge-block`})}}else{if(e.type===`merge-block`)break;if(lb(t)){if(U(t.origin)){if(t.origin.isInline()){if(!t.origin.isParentOf(r.anchor.origin))break}else e={block:t.origin,type:`merge-next-block`};continue}if(W(t.origin)){if(!t.origin.isIsolated()){if(By(t.origin).length>0){if(U(r.anchor.origin)&&r.anchor.origin.isEmpty()){r.anchor.origin.remove();let e=Zh();e.add(t.origin.getKey()),Z_(e)}}else if(e.type===`merge-next-block`&&(t.origin.isKeyboardSelectable()||!t.origin.isInline())&&U(r.anchor.origin)&&r.anchor.origin.isEmpty()){r.anchor.origin.remove();let e=Zh();e.add(t.origin.getKey()),Z_(e)}else t.origin.remove()}return}break}}if(e.type===`merge-block`){let{caret:t,block:n}=e;return By(n).length>0?void 0:t.origin.isEmpty()&&!n.isEmpty()&&t.origin.getParent()===n.getParent()?void t.origin.remove(!0):(Fb(this,Tb(!t.origin.isEmpty()&&n.isEmpty()?Lb(mb(n,t.direction)):r.anchor,t)),this.removeText())}for(let e=t.getNode();e!==null;){if(Fy(e)!==null)return;if(U(e)&&e.isShadowRoot())break;e=e.getParent()}}let i=this.focus;if(zh(this,e,`character`),this.isCollapsed()){if(e&&t.offset===0&&Fh(this,t.getNode()))return}else{let r=i.type===`text`?i.getNode():null;if(n=t.type===`text`?t.getNode():null,r!==null&&r.isSegmented()){let t=i.offset,a=r.getTextContentSize();if(r.is(n)||e&&t!==a||!e&&t!==0)return void Vh(r,e,t)}else if(n!==null&&n.isSegmented()){let i=t.offset,a=n.getTextContentSize();if(n.is(r)||e&&i!==0||!e&&i!==a)return void Vh(n,e,i)}(function(e,t){let n=e.anchor,r=e.focus,i=n.getNode();if(i===r.getNode()&&n.type===`text`&&r.type===`text`){let e=n.offset,a=r.offset,o=e<a,s=o?e:a,c=o?a:e,l=c-1;s!==l&&(function(e){return!(ev(e)||Bh(e))})(i.getTextContent().slice(s,c))&&(t?r.set(r.key,l,r.type):n.set(n.key,l,n.type))}})(this,e)}}if(this.removeText(),e&&!t&&this.isCollapsed()&&this.anchor.type===`element`&&this.anchor.offset===0){let e=this.anchor.getNode();e.isEmpty()&&Jg(e.getParent())&&e.getPreviousSibling()===null&&Fh(this,e),Oh()}}deleteLine(e){let t=Wh(this.anchor);if(t!==null&&W(Iy(t)))return this.isCollapsed()||this.focus.set(this.anchor.key,this.anchor.offset,this.anchor.type),void this.deleteCharacter(e);this.isCollapsed()&&zh(this,e,`lineboundary`),this.isCollapsed()?this.deleteCharacter(e):ky(this.anchor.getNode(),ay)===ky(this.focus.getNode(),ay)?this.removeText():(this.focus.set(this.anchor.key,this.anchor.offset,this.anchor.type),this.deleteCharacter(e))}deleteWord(e){if(this.isCollapsed()){let t=this.anchor,n=t.getNode();if(this.forwardDeletion(t,n,e))return;zh(this,e,`word`)}this.isCollapsed()?this.deleteCharacter(e):this.removeText()}isBackward(){let e=this._cachedIsBackward;if(e!==null)return e;let t=this.focus.isBefore(this.anchor);return Cg()||(this._cachedIsBackward=t),t}getStartEndPoints(){return[this.anchor,this.focus]}};function Ah(e){return e instanceof Dh}function jh(e,t){if(Ah(e)){for(let n of e.getNodes())oh(n)&&n.setFormat(t(n.getFormat()));return}if(e.isCollapsed())return e.setFormat(t(e.format)),void V_(null);let n=[];for(let r of e.getNodes())z(r)?n.push(r):U(r)?r.setTextFormat(t(r.getTextFormat())):oh(r)&&r.setFormat(t(r.getFormat()));let r=n.length;if(r===0)return e.setFormat(t(e.format)),void V_(null);let i=e.anchor,a=e.focus,o=e.isBackward(),s=o?a:i,c=o?i:a,l=0,u=n[0],d=s.type===`element`?0:s.offset;if(s.type===`text`&&d===u.getTextContentSize()&&(l=1,u=n[1],d=0),u==null)return;let f=r-1,p=n[f],m=c.type===`text`?c.offset:p.getTextContentSize();if(u.is(p)){if(d===m)return;let n=t(u.getFormat());if(N_(u)||d===0&&m===u.getTextContentSize())u.setFormat(n);else{let e=u.splitText(d,m),t=d===0?e[0]:e[1];t.setFormat(n),s.type===`text`&&s.set(t.__key,0,`text`),c.type===`text`&&c.set(t.__key,m-d,`text`)}e.format=n;return}d===0||N_(u)||([,u]=u.splitText(d),d=0);let h=t(u.getFormat());u.setFormat(h);let g=t(p.getFormat());m>0&&(m===p.getTextContentSize()||N_(p)||([p]=p.splitText(m)),p.setFormat(g));for(let e=l+1;e<f;e++){let r=n[e];r.setFormat(t(r.getFormat()))}s.type===`text`&&s.set(u.__key,d,`text`),c.type===`text`&&c.set(p.__key,m,`text`),e.format=h|g}function Mh(e,t,n=null){let r=n===null&&B(e)?L_(e.format,t,null):n;jh(e,e=>L_(e,t,r))}function Nh(e){let t=e.offset;if(e.type===`text`)return t;let n=e.getNode();return t===n.getChildrenSize()?n.getTextContent().length:0}function Ph(e){let t=e.getStartEndPoints();if(t===null)return[0,0];let[n,r]=t;return n.type===`element`&&r.type===`element`&&n.key===r.key&&n.offset===r.offset?[0,0]:[Nh(n),Nh(r)]}function Fh(e,t){for(let n=t;n;n=n.getParent()){if(U(n)){if(n.collapseAtStart(e))return!0;if(kv(n))break}if(n.getPreviousSibling())break}return!1}function Ih(e){let t=e.focus,n=e.anchor,r=n.key,i=n.offset,a=n.type;n.set(t.key,t.offset,t.type,!0),t.set(r,i,a,!0)}function Lh(e,t,n,r){e.modify(t,n,r)}function Rh(e,t,n){let r=e.getNodes(),i=r.filter(e=>Cv(e,n));if(i.length===0||i.length===r.length)return!1;let a=t?i[0]:i[i.length-1],o=U(a)?a:a.getParentOrThrow();return t?o.selectStart():o.selectEnd(),!0}function zh(e,t,n){if(mg(e,`extend`,t,n))return;let r=H(),i=Iv(Tv(r));if(!i||typeof i.modify!=`function`)return;let a=r._blockCursorElement,o=r._rootElement,s=e.anchor,c=e.focus.getNode();o===null||a===null||!U(c)||c.isInline()||c.canBeEmpty()||Fv(a,r,o);let l=e=>{let t=e.getNode(),n=r.getElementByKey(e.key);return n!==null&&e.type===`text`&&z(t)?uy(t,n,r):n},u=s.getNode(),d=l(s);if(d===null)return;let f=s.offset,p=e.isCollapsed(),m=e.focus,h=p?d:l(m);if(h===null)return;let g=m.offset;if(ig(i,h,g,h,g),Lh(i,`move`,t?`backward`:`forward`,n),i.rangeCount===0)return;let _=Wv(i,o)||i.getRangeAt(0),v=_.startContainer,y=_.startOffset;if(p&&n===`character`&&s.type===`text`&&z(u)&&u.isUnmergeable()&&f===(t?0:u.getTextContentSize())){let n=mb(u,t?`previous`:`next`).getNodeAtCaret();if(z(n)){let r=t?n.getTextContentSize()-1:1;e.focus.set(n.__key,r,`text`),e.dirty=!0;return}}if(p&&n===`character`&&s.type===`text`){let n=t?0:u.getTextContentSize(),r=v===d?y:f===n?-1:n;if(r>=0)return void(r!==f&&(e.focus.set(s.key,r,`text`),e.dirty=!0))}let[b,ee,te,ne]=t?[v,y,d,f]:[d,f,v,y],re=Jg(u)?u:Dv(u);e.applyDOMRange({collapsed:!1,endContainer:te,endOffset:ne,startContainer:b,startOffset:ee}),e.dirty=!0,!Rh(e,t,re)&&t&&Ih(e),n===`lineboundary`&&mg(e,`extend`,t,n,`decorators`)}let Bh=(()=>{try{let e=RegExp(`\\p{Emoji}`,`u`),t=e.test.bind(e);if(t(`❤️`)&&t(`#️⃣`)&&t(`👍`))return t}catch{}return()=>!1})();function Vh(e,t,n){let r=e,i=r.getTextContent().split(/(?=\s)/g),a=i.length,o=0,s=0;for(let e=0;e<a;e++){let r=e===a-1;if(s=o,o+=i[e].length,t&&o===n||o>n||r){i.splice(e,1),r&&(s=void 0);break}}let c=i.join(``).trim();c===``?r.remove():(r.setTextContent(c),r.select(s,s))}function Hh(e,t,n,r){let i,a=t,o=!1;if(q(e)){let s=!1,c=e.childNodes,l=c.length,u=r._blockCursorElement;a===l&&l>0&&(s=!0,a=l-1),K_(e,r)!==void 0||Sy(e,r)||(o=!0);let d=c[a],f=!1;if(d===u)d=c[a+1],f=!0;else if(u!==null){let n=u.parentNode;e===n&&t>Array.prototype.indexOf.call(n.children,u)&&a--}if(i=$_(d),z(i))a=gb(i,s?`next`:`previous`);else{let c=$_(e);if(c===null)return null;if(U(c)){let o=r.getElementByKey(c.getKey());o===null&&F(214);let l=cy(c,o,r);[c,a]=l.resolveChildIndex(c,o,e,t),U(c)||F(215),s&&a>=c.getChildrenSize()&&(a=Math.max(0,c.getChildrenSize()-1));let u=c.getChildAtIndex(a);if(U(u)&&function(e,t,n){let r=e.getParent();return n===null||r===null||!r.canBeEmpty()||r!==n.getNode()}(u,0,n)){let e=s?u.getLastDescendant():u.getFirstDescendant();e===null?c=u:(u=e,c=U(u)?u:u.getParentOrThrow()),a=0}z(u)?(i=u,c=null,a=gb(u,s?`next`:`previous`)):u!==c&&s&&!f&&(U(c)||F(216),a=Math.min(c.getChildrenSize(),a+1))}else{let n=Iy(c),i=n===null?c:n,o=i.getIndexWithinParent(),s=r.getElementByKey(c.getKey()),l=`after`;if(s!==null&&$_(e)===c){let n=cy(c,s,r);n.element===s?t===0&&W(c)&&(l=`before`):l=n.resolveLeafPosition(s,e,t)}a=l===`before`?o:o+1,c=i.getParentOrThrow()}if(U(c))return[Sh(c.__key,a,`element`),o]}}else i=$_(e);return z(i)?[Sh(i.__key,gb(i,a,`clamp`),`text`),o]:null}function Uh(e,t,n){let r=e.offset,i=e.getNode();if(r===0){let r=i.getPreviousSibling(),a=i.getParent();if(t){if((n||!t)&&r===null&&U(a)&&a.isInline()){let t=a.getPreviousSibling();z(t)&&e.set(t.__key,t.getTextContent().length,`text`)}}else U(r)&&!n&&r.isInline()?e.set(r.__key,r.getChildrenSize(),`element`):z(r)&&!i.isUnmergeable()&&e.set(r.__key,r.getTextContent().length,`text`)}else if(r===i.getTextContent().length){let r=i.getNextSibling(),a=i.getParent();if(t&&U(r)&&r.isInline())e.set(r.__key,0,`element`);else if((n||t)&&r===null&&U(a)&&a.isInline()&&!a.canInsertTextAfter()&&a.getTextContentSize()>1){let t=a.getNextSibling();z(t)&&e.set(t.__key,0,`text`)}}}function Wh(e){let t=U_(e.key);return t===null?null:Ry(t)}function Gh(e,t,n){let r=Wh(e),i=Wh(t);if(r===i||r!==null&&i!==null&&r.is(i))return!1;let a=n(r,i);if(r!==null)return U(r)?t.set(r.getKey(),a?r.getChildrenSize():0,`element`):t.set(r.getKey(),a?r.getTextContentSize():0,`text`),!0;let o=Iy(i);if(o===null)return!1;let s=o.getParent();if(s===null)return!1;let c=o.getIndexWithinParent();return t.set(s.getKey(),a?c+1:c,`element`),!0}function Kh(e){let t=Gh(e.anchor,e.focus,(t,n)=>function(e,t,n,r){if(n!==null&&r!==null){let e=Iy(n),t=Iy(r);if(e!==null&&e.is(t)){for(let t of zy(e).values()){if(t===n.getKey())return!0;if(t===r.getKey())return!1}return!0}return e===null||t===null||e.isBefore(t)}if(n!==null){let e=Iy(n),r=U_(t.key);return e===null||r===null||!(!e.is(r)&&!e.isParentOf(r))||e.isBefore(r)}let i=Iy(r),a=U_(e.key);return i!==null&&a!==null&&!i.is(a)&&!i.isParentOf(a)&&a.isBefore(i)}(e.anchor,e.focus,t,n));return t&&(e.dirty=!0),t}function qh(e,t,n,r,i,a){if(e===null||n===null||!O_(i,e,n))return null;let o=Hh(e,t,B(a)?a.anchor:null,i);if(o===null)return null;let s=Hh(n,r,B(a)?a.focus:null,i);if(s===null)return null;let[c,l]=o,[u,d]=s;if(c.type===`element`&&u.type===`element`){let t=$_(e),r=$_(n);if(W(t)&&W(r))return null}let f=i._slotsUsed&&Gh(c,u,()=>(e.compareDocumentPosition(n)&Node.DOCUMENT_POSITION_FOLLOWING)!==0);return function(e,t){if(e.type===`text`&&t.type===`text`){let n=e.isBefore(t),r=e.is(t);Uh(e,n,r),Uh(t,!n,r),r&&t.set(e.key,e.offset,e.type)}}(c,u),[c,u,l||d||f]}function Jh(e){return U(e)&&!e.isInline()}function Yh(e,t,n,r,i,a){let o=Eg(),s=new kh(Sh(e,t,i),Sh(n,r,a),0,``);return s.dirty=!0,o._selection=s,s}function Xh(){return new kh(Sh(`root`,0,`element`),Sh(`root`,0,`element`),0,``)}function Zh(){return new Dh(/* @__PURE__ */ new Set)}function Qh(e,t,n,r){let i=n._window;if(i===null)return null;let a=r||i.event,o=a?a.type:void 0,s=o===`selectionchange`,c=!$d&&(s||o===`beforeinput`||o===`compositionstart`||o===`compositionend`||o===`click`&&a&&a.detail===3||o===`drop`||o===void 0),l,u,d,f;if(B(e)&&!c)return e.clone();{if(t===null)return null;let r=Kv(t,n._rootElement);if(l=r.anchorNode,u=r.focusNode,d=r.anchorOffset,f=r.focusOffset,(s||o===void 0)&&B(e)&&!O_(n,l,u))return e.clone()}let p=qh(l,d,u,f,n,e);if(p===null)return null;let[m,h,g]=p,_=0,v=``;if(B(e)){let t=e.anchor;if(m.key===t.key)_=e.format,v=e.style;else{let e=m.getNode();z(e)?(_=e.getFormat(),v=e.getStyle()):U(e)&&(_=e.getTextFormat(),v=e.getTextStyle())}}let y=new kh(m,h,_,v);return g&&(y.dirty=!0),y}function V(){return Eg()._selection}function $h(){return H()._editorState._selection}function eg(e,t,n,r=1){let i=e.anchor,a=e.focus,o=i.getNode(),s=a.getNode();if(!t.is(o)&&!t.is(s))return;let c=t.__key;if(e.isCollapsed()){let t=i.offset;if(n<=t&&r>0||n<t&&r<0){let n=Math.max(0,t+r);i.set(c,n,`element`),a.set(c,n,`element`),tg(e)}}else{let o=e.isBackward(),s=o?a:i,l=s.getNode(),u=o?i:a,d=u.getNode();if(t.is(l)){let e=s.offset;(n<=e&&r>0||n<e&&r<0)&&s.set(c,Math.max(0,e+r),`element`)}if(t.is(d)){let e=u.offset;(n<=e&&r>0||n<e&&r<0)&&u.set(c,Math.max(0,e+r),`element`)}}tg(e)}function tg(e){let t=e.anchor,n=t.offset,r=e.focus,i=r.offset,a=t.getNode(),o=r.getNode();if(e.isCollapsed()){if(!U(a))return;let e=a.getChildrenSize(),i=n>=e,o=i?a.getChildAtIndex(e-1):a.getChildAtIndex(n);if(z(o)){let e=0;i&&(e=o.getTextContentSize()),t.set(o.__key,e,`text`),r.set(o.__key,e,`text`)}}else{if(U(a)){let e=a.getChildrenSize(),r=n>=e,i=r?a.getChildAtIndex(e-1):a.getChildAtIndex(n);if(z(i)){let e=0;r&&(e=i.getTextContentSize()),t.set(i.__key,e,`text`)}}if(U(o)){let e=o.getChildrenSize(),t=i>=e,n=t?o.getChildAtIndex(e-1):o.getChildAtIndex(i);if(z(n)){let e=0;t&&(e=n.getTextContentSize()),r.set(n.__key,e,`text`)}}}}function ng(e,t,n,r,i){let a=null,o=0,s=null;r===null?i!==null&&(a=i.__key,z(i)?s=`text`:U(i)&&(s=`element`)):(a=r.__key,z(r)?(o=r.getTextContentSize(),s=`text`):U(r)&&(o=r.getChildrenSize(),s=`element`)),a!==null&&s!==null?e.set(a,o,s):(o=t.getIndexWithinParent(),o===-1&&(o=n.getChildrenSize()),e.set(n.__key,o,`element`))}function rg(e,t,n,r,i){e.type===`text`?e.set(n,e.offset+(t?0:i),`text`):e.offset>r.getIndexWithinParent()&&e.set(e.key,e.offset-1,`element`)}function ig(e,t,n,r,i){try{e.setBaseAndExtent(t,n,r,i)}catch{}}function ag(e,t,n){let r=vv(e,t.getKey());if(U(t)){let i=cy(t,r,e);return[i.element,n+i.getFirstChildOffset()]}return[r,n]}function og(e,t,n,r,i,a){let o=a.getRootNode(),s=F_(o)||Rv(o)?Zv(o):null;if(i.has(`collaboration`)&&s!==a||s!==null&&D_(s,s))return;let c=Kv(r,a),l;if(!B(t))return void(e!==null&&O_(n,c.anchorNode,c.focusNode)&&r.removeAllRanges());let u=t.anchor,d=t.focus,f=u.getNode(),p=d.getNode(),[m,h]=ag(n,f,u.offset),[g,_]=ag(n,p,d.offset),v=t.format,y=t.style,b=t.isCollapsed(),ee=m,te=g,ne=!1;if(u.type===`text`?(ee=z(f)?uy(f,m,n):null,ne=f.getFormat()!==v||f.getStyle()!==y):B(e)&&e.anchor.type===`text`&&(ne=!0),d.type===`text`&&(te=z(p)?uy(p,g,n):null),ee!==null&&te!==null){if(b&&(e===null||ne||B(e)&&(e.format!==v||e.style!==y))&&function(e,t,n,r,i,a){e._inputState.collapsedSelectionFormat={format:t,key:i,offset:r,style:n,timeStamp:a}}(n,v,y,h,u.key,performance.now()),(r.type!==`Range`||!b)&&c.anchorOffset===h&&c.focusOffset===_&&c.anchorNode===ee&&c.focusNode===te){if(s===null||!a.contains(s)){let e=s===null?null:A_(s);e!==null&&e!==n||i.has(`skip-selection-focus`)||a.focus({preventScroll:!0})}if(u.type!==`element`)return}if(ig(r,ee,h,te,_),Sd&&t.isCollapsed()&&a!==null&&!i.has(`skip-selection-focus`)){let e=Xv(a);if(e===null||!a.contains(e)){let e=Zv(a.ownerDocument),t=e===null?null:A_(e);t!==null&&t!==n||a.focus({preventScroll:!0})}}if(!i.has(`skip-scroll-into-view`)&&t.isCollapsed()&&a!==null&&a===Xv(a)){let e=B(t)&&t.anchor.type===`element`?ee.childNodes[h]||null:(l===void 0&&(l=Gv(r,a)),l);if(e!==null){let t;if(P_(e)){let n=e.ownerDocument.createRange();n.selectNode(e),t=n.getBoundingClientRect()}else t=e.getBoundingClientRect();(function(e,t,n){let r=bv(n),i=wv(r);if(r===null||i===null)return;let a=n.getBoundingClientRect();if(t.bottom<a.top)return;let{top:o,bottom:s}=t,c=0,l=0,u=n;for(;u!==null;){let t=u===r.body;if(t){let t=i.visualViewport;if(t){let e=t.pageTop-i.scrollY;c=e,l=e+t.height}else c=0,l=Tv(e).innerHeight;let n=i.getComputedStyle(r.documentElement),a=parseFloat(n.scrollPaddingTop),o=parseFloat(n.scrollPaddingBottom);isFinite(a)&&(c+=a),isFinite(o)&&(l-=o)}else{let e=u===n?a:u.getBoundingClientRect();c=e.top,l=e.bottom}let d=0;if(o<c?d=-(c-o):s>l&&(d=s-l),d!==0){if(t)i.scrollBy(0,d);else{let e=u.scrollTop;u.scrollTop+=d;let t=u.scrollTop-e;o-=t,s-=t}}if(t)break;u=yv(u)}})(n,t,a)}}(function(e){e._inputState.isSelectionChangeFromDOMUpdate=!0})(n)}}function sg(e,t){for(let n of e.split(/(\r?\n|\t)/))n===`
138
+ `)e.preventDefault(),K(r,Lp);else if(o==null&&e.dataTransfer){let t=e.dataTransfer.getData(`text/plain`);e.preventDefault(),a.insertRawText(t)}else o!=null&&Em(a,n,o,e.timeStamp,!0)?(e.preventDefault(),K(r,Rp,o),Mm(o)):i.unprocessedBeforeInputData=o;return i.lastBeforeInputInsertTextTimeStamp=e.timeStamp,!0}switch(e.preventDefault(),t){case`insertFromYank`:case`insertFromDrop`:case`insertReplacementText`:K(r,Rp,e),Mm((e.dataTransfer?e.dataTransfer.getData(`text/plain`):null)??e.data);break;case`insertFromComposition`:{let t=i.hadOrphanedCompositionEvents;i.hadOrphanedCompositionEvents=!1;let n=r._compositionKey;X_(null),t||K(r,Rp,e),Bm(n);break}case`insertLineBreak`:X_(null),K(r,Ip,!1);break;case`insertParagraph`:X_(null),i.isInsertLineBreak&&!Nd?(i.isInsertLineBreak=!1,K(r,Ip,!1)):K(r,Lp);break;case`insertFromPaste`:case`insertFromPasteAsQuotation`:K(r,zp,e);break;case`deleteByComposition`:(function(e,t){return e!==t||U(e)||U(t)||!V_(e)||!V_(t)})(l,u)&&K(r,Bp,e);break;case`deleteByDrag`:Av(ih),K(r,Bp,e);break;case`deleteByCut`:K(r,Bp,e);break;case`deleteContent`:K(r,Fp,!1);break;case`deleteWordBackward`:K(r,Vp,!0);break;case`deleteWordForward`:K(r,Vp,!1);break;case`deleteHardLineBackward`:case`deleteSoftLineBackward`:K(r,Hp,!0);break;case`deleteContentForward`:case`deleteHardLineForward`:case`deleteSoftLineForward`:K(r,Hp,!1);break;case`formatStrikeThrough`:K(r,Up,`strikethrough`);break;case`formatBold`:K(r,Up,`bold`);break;case`formatItalic`:K(r,Up,`italic`);break;case`formatUnderline`:K(r,Up,`underline`);break;case`historyUndo`:K(r,Wp);break;case`historyRedo`:K(r,Gp)}return!0}function Lm(e){let t=H(),n=t._inputState,r=V(),i=e.data,a=jm(e),o=!1;if(i!=null&&B(r)){let s=Gv(Pv(t)),c=s===null?null:ty(s,t._rootElement),l=e.inputType===`insertCompositionText`&&n.compositionPhase!==`ending-firefox`&&!t.isComposing();l&&(n.hadOrphanedCompositionEvents=!0);let u=r.anchor.getNode(),d=e.inputType===`insertCompositionText`&&n.compositionPhase!==`ending-firefox`&&t.isComposing()&&z(u)&&H_(u);if(!l&&!d&&Em(r,a,i,e.timeStamp,!1,c)){if(o=!0,n.compositionPhase===`ending-firefox`){let e=Vm(t,i);if(n.compositionPhase=`idle`,e)return Av(ah),sv(),!0}let a=r.anchor.getNode();if(s===null||c===null)return!0;let l=r.isBackward(),u=l?r.anchor.offset:r.focus.offset,d=l?r.focus.offset:r.anchor.offset;Md&&!r.isCollapsed()&&z(a)&&c.anchorNode!==null&&a.getTextContent().slice(0,u)+i+a.getTextContent().slice(u+d)===fv(c.anchorNode)||K(t,Rp,i);let f=i.length;jd&&f>1&&e.inputType===`insertCompositionText`&&!t.isComposing()&&(r.anchor.offset-=f,r._cachedNodes=null,r._cachedIsBackward=null),Ld&&t.isComposing()&&(n.lastKeyDownTimeStamp=0,X_(null))}}return o||(pv(!1,t,i===null?void 0:i),n.compositionPhase===`ending-firefox`&&(Vm(t,i||void 0),Av(`composition-end`),n.compositionPhase=`idle`)),sv(),!0}function Rm(e){let t=H(),n=t._inputState,r=V();if(B(r)&&!t.isComposing()){n.compositionPhase=`composing`,n.hadOrphanedCompositionEvents=!1;let i=r.anchor,a=r.anchor.getNode();if(X_(i.key),Av(`composition-start`),e.timeStamp<n.lastKeyDownTimeStamp+30||i.type===`element`||!r.isCollapsed()||!Ld&&(a.getFormat()!==r.format||z(a)&&a.getStyle()!==r.style)||z(a)&&(H_(a)||i.offset===0&&!a.canInsertTextBefore()||i.offset===a.getTextContentSize()&&!a.canInsertTextAfter())){K(t,Rp,Bd);let e=V();B(e)&&X_(e.anchor.key)}}return!0}function zm(e){let t=H();return t._inputState.compositionPhase=`idle`,Vm(t,e.data),Av(ah),!0}function Bm(e){if(e===null)return;let t=Q_(e);if(!z(t)||t.getType()===`text`||H_(t)||!t.isAttached())return;let n=V(),r=B(n)&&n.anchor.key===e?n.anchor.offset:null,i=Th(t.getTextContent());if(i.setFormat(t.getFormat()),i.setStyle(t.getStyle()),t.replace(i),r!==null){let e=Math.min(r,i.getTextContentSize());i.select(e,e)}}function Vm(e,t){let n=e._compositionKey;if(X_(null),n!==null&&t!=null){if(t===``){let t=Q_(n),r=e.getElementByKey(n),i=r!==null&&z(t)?yy(t,r,e):null;if(i!==null&&i.nodeValue!==null&&z(t)){let n=Gv(Pv(e)),r=n&&ty(n,e._rootElement),a=null,o=null;r!==null&&r.anchorNode===i&&(a=r.anchorOffset,o=r.focusOffset),mv(t,i.nodeValue,a,o,!0)}return Bm(n),!1}if(t[t.length-1]===`
139
+ `){let t=V();if(B(t)||zh(t)){if(B(t)){let e=t.focus;t.anchor.set(e.key,e.offset,e.type)}return K(e,$p,null),Bm(n),!1}}let r=Q_(n);if(r!==null&&z(r)&&H_(r)){r.markDirty();let e=V(),i=r.getTextContentSize(),a=B(e)&&e.anchor.key===n?e.anchor.offset:i;return r.select(a,a).insertText(t),!0}}return pv(!0,e,t),Bm(n),!1}function Hm(e){let t=H(),n=t._inputState;if(e.key==null)return!0;if(n.compositionPhase===`ending-safari`){let r=bv(e);if(r&&Zg(t,()=>{Vm(t,n.compositionEndData)}),n.compositionPhase=`idle`,n.compositionEndData=``,r)return!0}if(function(e){return G(e,`ArrowRight`,{shiftKey:`any`})}(e))K(t,qp,e);else if(function(e){return G(e,`ArrowRight`,{...vv,shiftKey:`any`})}(e))K(t,Jp,e);else if(function(e){return G(e,`ArrowLeft`,{shiftKey:`any`})}(e))K(t,Yp,e);else if(function(e){return G(e,`ArrowLeft`,{...vv,shiftKey:`any`})}(e))K(t,Xp,e);else if(function(e){return G(e,`ArrowUp`,{altKey:`any`,shiftKey:`any`})}(e))K(t,Zp,e);else if(function(e){return G(e,`ArrowDown`,{altKey:`any`,shiftKey:`any`})}(e))K(t,Qp,e);else if(function(e){return G(e,`Enter`,{altKey:`any`,ctrlKey:`any`,metaKey:`any`,shiftKey:!0})}(e))n.isInsertLineBreak=!0,K(t,$p,e);else if(function(e){return e.key===` `}(e))K(t,em,e);else if(function(e){return Ad&&G(e,`o`,{ctrlKey:!0})}(e))e.preventDefault(),n.isInsertLineBreak=!0,K(t,Ip,!0);else if(function(e){return G(e,`Enter`,{altKey:`any`,ctrlKey:`any`,metaKey:`any`})}(e))n.isInsertLineBreak=!1,K(t,$p,e);else if(function(e){return G(e,`Backspace`,{shiftKey:`any`})||Ad&&G(e,`h`,{ctrlKey:!0})}(e))bv(e)?K(t,tm,e)&&Pm(n):(e.preventDefault(),K(t,Fp,!0));else if(function(e){return e.key===`Escape`}(e))K(t,nm,e);else if(function(e){return G(e,`Delete`,{})||Ad&&G(e,`d`,{ctrlKey:!0})}(e))(function(e){return e.key===`Delete`})(e)?K(t,rm,e):(e.preventDefault(),K(t,Fp,!1));else if(function(e){return G(e,`Backspace`,yv)}(e))e.preventDefault(),K(t,Vp,!0);else if(function(e){return G(e,`Delete`,yv)}(e))e.preventDefault(),K(t,Vp,!1);else if(function(e){return Ad&&G(e,`Backspace`,{metaKey:!0})}(e))e.preventDefault(),K(t,Hp,!0);else if(function(e){return Ad&&(G(e,`Delete`,{metaKey:!0})||G(e,`k`,{ctrlKey:!0}))}(e))e.preventDefault(),K(t,Hp,!1);else if(function(e){return G(e,`b`,vv)}(e))e.preventDefault(),K(t,Up,`bold`);else if(function(e){return G(e,`u`,vv)}(e))e.preventDefault(),K(t,Up,`underline`);else if(function(e){return G(e,`i`,vv)}(e))e.preventDefault(),K(t,Up,`italic`);else if(function(e){return G(e,`Tab`,{shiftKey:`any`})}(e))K(t,im,e);else if(function(e){return G(e,`z`,vv)}(e))e.preventDefault(),K(t,Wp);else if(function(e){return Ad?G(e,`z`,{metaKey:!0,shiftKey:!0}):G(e,`y`,{ctrlKey:!0})||G(e,`z`,{ctrlKey:!0,shiftKey:!0})}(e))e.preventDefault(),K(t,Gp);else{let r=t._editorState._selection;(function(e){return G(e,`a`,vv)})(e)?(e.preventDefault(),K(t,dm,e)&&Pm(n)):r===null||B(r)||(function(e){return G(e,`c`,vv)}(e)?(e.preventDefault(),K(t,lm,e)):function(e){return G(e,`x`,vv)}(e)&&(e.preventDefault(),K(t,um,e)))}return function(e){return e.ctrlKey||e.shiftKey||e.altKey||e.metaKey}(e)&&t.dispatchCommand(vm,e),!0}function Um(e){let t=e.__lexicalEventHandles;return t===void 0&&(t=[],e.__lexicalEventHandles=t),t}let Wm=/* @__PURE__ */ new Map;function Gm(e){let t=Kv(e.target);if(t===null)return;let n=kv(e.target),r=null,i=null,a=n===null?void 0:wm.get(n);if(n!==null){if(a!==void 0){let e=a.editors,n=a.hasShadowEditor;if(n===void 0){n=!1;for(let t of e)if(t._rootElement!==null&&qv(t._rootElement.getRootNode())){n=!0;break}a.hasShadowEditor=n}if(n){let n=null,a=null;for(let o of e){let e=o._rootElement;if(e===null)continue;let s=ty(t,e).anchorNode;if(s!==null&&z_(s)===o){if(qv(e.getRootNode())){r=o,i=s;break}n===null&&(n=o,a=s)}}r===null&&n!==null&&(r=n,i=a)}else{let e=t.anchorNode;e===null||q(e)&&e.shadowRoot!==null||(r=z_(e),r!==null&&(i=e))}}if(r===null){let e=oy(n);r=e===null?null:z_(e)}}if(r===null)return;if(r._inputState.isSelectionChangeFromMouseDown){if(a!==void 0)for(let e of a.editors)e._inputState.isSelectionChangeFromMouseDown=!1;Zg(r,()=>{let n=cg(),a=i??ty(t,r._rootElement).anchorNode;(q(a)||U_(a))&&ov(sg(n,t,r,e))})}let o=uv(r),s=o[o.length-1],c=s._key,l=Wm.get(c),u=l||s;u!==r&&Om(t,u,!1),Om(t,r,!0),r===s?l&&Wm.delete(c):Wm.set(c,r)}function Km(e){e._lexicalHandled=!0}function qm(e){return!0===e._lexicalHandled}function Jm(e){let t=Cm.get(e);if(t===void 0)return;let n=wm.get(t);if(n===void 0)return;Cm.delete(e);let r=B_(e);R_(r)?(function(e){if(e._parentEditor!==null){let t=uv(e),n=t[t.length-1]._key;Wm.get(n)===e&&Wm.delete(n)}else Wm.delete(e._key)}(r),n.editors.delete(r),n.hasShadowEditor=void 0,e.__lexicalEditor=null):r&&F(198);let i=Um(e);for(let e=0;e<i.length;e++)i[e]();e.__lexicalEventHandles=[]}function Ym(e,t,n){Ng();let r=e.__key,i=e.getParent();if(i===null)return void(Wy(e)!==null&&F(367,r,String(Wy(e))));let a=function(e){let t=V();if(!B(t)||!U(e))return t;let{anchor:n,focus:r}=t,i=n.getNode(),a=r.getNode();return Mv(i,e)&&n.set(e.__key,0,`element`),Mv(a,e)&&r.set(e.__key,0,`element`),t}(e),o=!1;if(B(a)&&t){let t=a.anchor,n=a.focus;t.key===r&&(dg(t,e,i,e.getPreviousSibling(),e.getNextSibling()),o=!0),n.key===r&&(dg(n,e,i,e.getPreviousSibling(),e.getNextSibling()),o=!0)}else zh(a)&&t&&e.isSelected()&&e.selectPrevious();if(B(a)&&t&&!o){let t=e.getIndexWithinParent();J_(e),lg(a,i,t,-1)}else J_(e);n||Rv(i)||i.canBeEmpty()||!i.isEmpty()||Ym(i,t),t&&a&&r_(i)&&i.isEmpty()&&i.selectEnd()}let Xm=Symbol.for(`ephemeral`);function Zm(e){return e[Xm]||!1}let Qm={configurable:!0,enumerable:!1,value:void 0,writable:!0};var $m=class{__type;__key;__parent;__prev;__next;__state;[If];static getType(){let{ownNodeType:e}=Fy(this);return e===void 0&&F(64,this.name),e}static clone(e){F(65,this.name)}$config(){return{}}config(e,t){let n=t.extends||By(this.constructor);return Object.assign(t,{extends:n}),typeof e==`string`&&Object.assign(t,{type:e}),{[e]:t}}afterCloneFrom(e){this.__key===e.__key?(this.__parent=e.__parent,this.__next=e.__next,this.__prev=e.__prev,this.__state=e.__state):e.__state&&(this.__state=e.__state.getWritable(this))}resetOnCopyNodeFrom(e){this.__state&&=this.__state.getWritable(this).resetOnCopyNode()}static importDOM;constructor(e){this.__type=this.constructor.getType(),this.__parent=null,this.__prev=null,this.__next=null,Object.defineProperty(this,"__state",Qm),Object.defineProperty(this,If,Qm),q_(this,e)}getType(){return this.__type}isInline(){F(137,this.constructor.name)}isAttached(){let e=this.__key;for(;e!==null;){if(e===`root`)return!0;let t=Q_(e);if(t===null)break;e=t.__parent===null?Wy(t):t.__parent}return!1}isSelected(e){let t=e||V();if(t==null)return!1;let n=t.getNodes().some(e=>e.__key===this.__key);if(z(this))return n;if(B(t)&&t.anchor.type===`element`&&t.focus.type===`element`){if(t.isCollapsed())return!1;let e=this.getParent();if(W(this)&&this.isInline()&&e){let n=t.isBackward()?t.focus:t.anchor;if(e.is(n.getNode())&&n.offset===e.getChildrenSize()&&this.is(e.getLastChild()))return!1}}return n}getKey(){return this.__key}getIndexWithinParent(){let e=this.getParent();if(e===null)return-1;let t=e.getFirstChild(),n=0;for(;t!==null;){if(this.is(t))return n;n++,t=t.getNextSibling()}return-1}getParent(){let e=this.getLatest().__parent;return e===null?null:Q_(e)}getParentOrThrow(){let e=this.getParent();return e===null&&F(66,this.__key),e}getTopLevelElement(){let e=this;for(;e!==null;){let t=e.getParent();if(Rv(t)||Wy(e)!==null)return U(e)||e===this&&W(e)||F(194),e;e=t}return null}getTopLevelElementOrThrow(){let e=this.getTopLevelElement();return e===null&&F(67,this.__key),e}getParents(){let e=[],t=this.getParent();for(;t!==null;)e.push(t),t=t.getParent();return e}getParentKeys(){let e=[],t=this.getParent();for(;t!==null;)e.push(t.__key),t=t.getParent();return e}getPreviousSibling(){let e=this.getLatest().__prev;return e===null?null:Q_(e)}getPreviousSiblings(){let e=[],t=this.getParent();if(t===null)return e;let n=t.getFirstChild();for(;n!==null&&!n.is(this);)e.push(n),n=n.getNextSibling();return e}getNextSibling(){let e=this.getLatest().__next;return e===null?null:Q_(e)}getNextSiblings(){let e=[],t=this.getNextSibling();for(;t!==null;)e.push(t),t=t.getNextSibling();return e}getCommonAncestor(e){let t=U(this)?this:this.getParent(),n=U(e)?e:e.getParent(),r=t&&n?Bb(t,n):null;return r?r.commonAncestor:null}is(e){return e!=null&&this.__key===e.__key}isBefore(e){let t=Bb(this,e);return t!==null&&(t.type===`descendant`||(t.type===`branch`?Lb(t)===-1:(t.type!==`same`&&t.type!==`ancestor`&&F(279),!1)))}isParentOf(e){return Mv(e,this)}getNodesBetween(e){let t=this.isBefore(e),n=[],r=/* @__PURE__ */ new Set,i=this;for(;i!==null;){let a=i.__key;if(r.has(a)||(r.add(a),n.push(i)),i===e)break;let o=U(i)?t?i.getFirstChild():i.getLastChild():null;if(o!==null){i=o;continue}let s=t?i.getNextSibling():i.getPreviousSibling();if(s!==null){i=s;continue}let c=i.getParentOrThrow();if(r.has(c.__key)||n.push(c),c===e)break;let l=null,u=c;do{if(u===null&&F(68),l=t?u.getNextSibling():u.getPreviousSibling(),u=u.getParent(),u===null)break;l!==null||r.has(u.__key)||n.push(u)}while(l===null);i=l}return t||n.reverse(),n}isDirty(){let e=H()._dirtyLeaves;return e!==null&&e.has(this.__key)}getLatest(){if(Zm(this))return this;let e=Q_(this.__key);return e===null&&F(113),e}getWritable(){if(Zm(this))return this;Ng();let e=Fg(),t=H(),n=e._nodeMap,r=this.__key,i=this.getLatest(),a=t._cloneNotNeeded,o=V();if(o!==null&&o.setCachedNodes(null),a.has(r))return Y_(i),i;let s=Cy(i);return a.add(r),Y_(s),n.set(r,s),s}getTextContent(){return rb(this)}getTextContentSize(){return this.getTextContent().length}createDOM(e,t){F(70)}updateDOM(e,t,n){F(71)}getDOMSlot(e){return new Qd(e)}exportDOM(e){return{element:this.createDOM(e._config,e)}}exportJSON(){let e=this.__state?this.__state.toJSON():void 0;return{type:this.__type,version:1,...e}}static importJSON(e){F(18,this.name)}updateFromJSON(e){return function(e,t){let n=e.getWritable(),r=t.$,i=r;for(let e of Tf(n).flatKeys)e in t&&(i!==void 0&&i!==r||(i={...r}),i[e]=t[e]);return(n.__state||i)&&wf(e).updateFromJSON(i),n}(this,e)}static transform(){return null}remove(e){Ym(this,!0,e)}replace(e,t){Ng();let n=V();n!==null&&(n=n.clone()),Vv(this,e);let r=this.getLatest(),i=this.__key,a=e.__key,o=e.getWritable(),s=this.getParentOrThrow().getWritable(),c=s.__size,l=o.getParent(),u=l===null?-1:o.getIndexWithinParent();J_(o),l!==null&&B(n)&&lg(n,l,u,-1);let d=r.getPreviousSibling(),f=r.getNextSibling(),p=r.__prev,m=r.__next,h=r.__parent;Ym(r,!1,!0),d===null?s.__first=a:d.getWritable().__next=a,o.__prev=p,f===null?s.__last=a:f.getWritable().__prev=a,o.__next=m,o.__parent=h,s.__size=c;let g=0;t&&(U(this)&&U(o)||F(139),g=o.getChildrenSize(),o.splice(g,0,this.getChildren()));let _=Yy(this);if(_.length>0){Hy(this)&&Hy(o)||F(368,this.__key,o.__key);for(let e of _){let t=Xy(this,e);t!==null&&(sb(this,e),ob(o,e,t))}}if(B(n)){ov(n);let e=n.anchor,r=n.focus;e.key===i&&(t&&e.type===`element`?e.set(o.__key,g+e.offset,`element`):Nh(e,o)),r.key===i&&(t&&r.type===`element`?r.set(o.__key,g+r.offset,`element`):Nh(r,o))}return Z_()===i&&X_(a),o}insertAfter(e,t=!0){Ng(),Vv(this,e);let n=this.getWritable(),r=e.getWritable();this.getParentOrThrow();let i=r.getParent(),a=V(),o=!1,s=!1;if(i!==null){let n=e.getIndexWithinParent();if(B(a)){let e=i.__key,t=a.anchor,r=a.focus;o=t.type===`element`&&t.key===e&&t.offset===n+1,s=r.type===`element`&&r.key===e&&r.offset===n+1}J_(r),t&&B(a)&&lg(a,i,n,-1)}else J_(r);let c=this.getNextSibling(),l=this.getParentOrThrow().getWritable(),u=r.__key,d=n.__next;if(c===null?l.__last=u:c.getWritable().__prev=u,l.__size++,n.__next=u,r.__next=d,r.__prev=n.__key,r.__parent=n.__parent,t&&B(a)){let e=this.getIndexWithinParent();lg(a,l,e+1);let t=l.__key;o&&a.anchor.set(t,e+2,`element`),s&&a.focus.set(t,e+2,`element`)}return e}insertBefore(e,t=!0){Ng(),Vv(this,e);let n=this.getWritable(),r=e.getWritable();this.getParentOrThrow();let i=r.__key,a=V(),o=r.getParent(),s=o===null?-1:r.getIndexWithinParent();J_(r),o!==null&&t&&B(a)&&lg(a,o,s,-1);let c=this.getPreviousSibling(),l=this.getParentOrThrow().getWritable(),u=n.__prev,d=this.getIndexWithinParent();return c===null?l.__first=i:c.getWritable().__next=i,l.__size++,n.__prev=i,r.__prev=u,r.__next=n.__key,r.__parent=n.__parent,t&&B(a)&&lg(a,this.getParentOrThrow(),d),e}isParentRequired(){return!1}createParentElementNode(){return y_()}selectStart(){return this.selectPrevious()}selectEnd(){return this.selectNext(0,0)}selectPrevious(e,t){Ng();let n=Gy(this);if(n!==null)return n.selectPrevious(e,t);let r=this.getPreviousSibling(),i=this.getParentOrThrow();if(r===null)return i.select(0,0);if(U(r))return r.select();if(!z(r)){let e=r.getIndexWithinParent()+1;return i.select(e,e)}return r.select(e,t)}selectNext(e,t){Ng();let n=Gy(this);if(n!==null)return n.selectNext(e,t);let r=this.getNextSibling(),i=this.getParentOrThrow();if(r===null)return i.select();if(U(r))return r.select(0,0);if(!z(r)){let e=r.getIndexWithinParent();return i.select(e,e)}return r.select(e,t)}markDirty(){this.getWritable()}reconcileObservedMutation(e,t){this.markDirty()}};function eh(e){return e instanceof $m}let th=`history-merge`,nh=`paste`,rh=`skip-dom-selection`,ih=`skip-selection-focus`,ah=`composition-end`;function oh(e){let t={};if(!e)return t;let n=``,r=``,i=null,a=!1,o=!1,s=!1,c=0,l=e.length,u=-1;for(let d=0;d<l;d++){let l=e[d];if(a)l===`*`&&e[d+1]===`/`&&(a=!1,d++);else if(o)u===-1&&(u=d),o=!1;else if(i===null){if(l!==`/`||e[d+1]!==`*`){if(l!==`"`&&l!==`'`){if(l!==`(`){if(l!==`)`){if(s||l!==`:`||c!==0){if(l===`;`&&c===0){u!==-1&&(s?r+=e.slice(u,d):n+=e.slice(u,d),u=-1);let i=n.trim(),a=r.trim();i!==``&&a!==``&&(t[i]=a),n=``,r=``,s=!1;continue}u===-1&&(u=d)}else u!==-1&&(n+=e.slice(u,d),u=-1),s=!0}else u===-1&&(u=d),c=Math.max(0,c-1)}else u===-1&&(u=d),c++}else u===-1&&(u=d),i=l}else u!==-1&&(s?r+=e.slice(u,d):n+=e.slice(u,d),u=-1),a=!0,d++}else u===-1&&(u=d),l===`\\`?o=!0:l===i&&(i=null)}u!==-1&&(s?r+=e.slice(u,l):n+=e.slice(u,l));let d=n.trim(),f=r.trim();return d!==``&&f!==``&&(t[d]=f),t}function sh(e,t,n){let r=n.trimEnd(),i=r.length-10;i>=0&&r.slice(i).toLowerCase()===`!important`?e.setProperty(t,r.slice(0,i).trim(),`important`):e.setProperty(t,n,``)}function ch(e,t,n=``){if(t===n)return;let r=oh(n),i=oh(t);for(let t in i)delete r[t],sh(e,t,i[t]);for(let t in r)e.removeProperty(t)}function lh(e,t){return 16&t?`code`:t&128?`mark`:32&t?`sub`:64&t?`sup`:null}function uh(e,t){return 1&t?`strong`:2&t?`em`:`span`}function dh(e,t,n,r,i){let a=r.classList,o=Sv(i,`base`);o!==void 0&&a.add(...o),o=Sv(i,`underlineStrikethrough`);let s=!1,c=8&t&&4&t;o!==void 0&&(8&n&&4&n?(s=!0,c||a.add(...o)):c&&a.remove(...o));for(let e in Ud){let r=Ud[e];if(o=Sv(i,e),o!==void 0){if(n&r){if(s&&(e===`underline`||e===`strikethrough`)){t&r&&a.remove(...o);continue}((t&r)===0||c&&e===`underline`||e===`strikethrough`)&&a.add(...o)}else t&r&&a.remove(...o)}}}function fh(e,t,n){let r=n.isComposing(),i=e+(r?zd:``),a=hy(),o=gy(a).$getDOMSlot(n,t,a),s=o.getFirstChild();if(s===null||s.nodeType!==Node.TEXT_NODE)return void o.insertChild(Qv().createTextNode(i));let c=s,l=c.nodeValue;if(l!==i){if(r||jd){let[e,t,n]=function(e,t){let n=e.length,r=t.length,i=0,a=0;for(;i<n&&i<r&&e[i]===t[i];)i++;for(;a+i<n&&a+i<r&&e[n-a-1]===t[r-a-1];)a++;return[i,n-i-a,t.slice(i,r-a)]}(l,i);t!==0&&c.deleteData(e,t),c.insertData(e,n)}else c.nodeValue=i}}function ph(e,t,n,r,i,a){fh(i,e,t);let o=a.theme.text;o!==void 0&&dh(0,0,r,e,o)}function mh(e,t){let n=Qv().createElement(t);return n.appendChild(e),n}function hh(e){return e!=null&&!0===e.__isInlineFormattable}var gh=class extends $m{__text;__format;__style;__mode;__detail;get __isInlineFormattable(){return!0}$config(){return this.config(`text`,{importDOM:{"#text":()=>({conversion:xh,priority:0}),b:()=>({conversion:vh,priority:0}),code:()=>({conversion:wh,priority:0}),em:()=>({conversion:wh,priority:0}),i:()=>({conversion:wh,priority:0}),mark:()=>({conversion:wh,priority:0}),s:()=>({conversion:wh,priority:0}),span:()=>({conversion:_h,priority:0}),strong:()=>({conversion:wh,priority:0}),sub:()=>({conversion:wh,priority:0}),sup:()=>({conversion:wh,priority:0}),u:()=>({conversion:wh,priority:0})}})}afterCloneFrom(e){super.afterCloneFrom(e),this.__text=e.__text,this.__format=e.__format,this.__style=e.__style,this.__mode=e.__mode,this.__detail=e.__detail}constructor(e=``,t){super(t),this.__text=e,this.__format=0,this.__style=``,this.__mode=0,this.__detail=0}getFormat(){return this.getLatest().__format}getDetail(){return this.getLatest().__detail}getMode(){let e=this.getLatest();return Jd[e.__mode]}getStyle(){return this.getLatest().__style}isToken(){return this.getLatest().__mode===1}isComposing(){return this.__key===Z_()}isSegmented(){return this.getLatest().__mode===2}isDirectionless(){return!!(1&this.getLatest().__detail)}isUnmergeable(){return!!(2&this.getLatest().__detail)}hasFormat(e){let t=Ud[e];return(this.getFormat()&t)!==0}isSimpleText(){return this.__type===`text`&&this.__mode===0}getTextContent(){return this.getLatest().__text}getFormatFlags(e,t){return K_(this.getLatest().__format,e,t)}canHaveFormat(){return!0}isInline(){return!0}createDOM(e,t){let n=this.__format,r=lh(0,n),i=uh(0,n),a=r===null?i:r,o=Qv().createElement(a),s=o;this.hasFormat(`code`)&&o.setAttribute(`spellcheck`,`false`),r!==null&&(s=Qv().createElement(i),o.appendChild(s)),ph(s,this,0,n,this.__text,e);let c=this.__style;return c!==``&&ch(o.style,c),o}updateDOM(e,t,n){let r=this.__text,i=e.__format,a=this.__format,o=lh(0,i),s=lh(0,a),c=uh(0,i),l=uh(0,a);if((o===null?c:o)!==(s===null?l:s))return!0;if(o===s&&c!==l){let e=t.firstChild;e??F(48);let i=Qv().createElement(l);return ph(i,this,0,a,r,n),t.replaceChild(i,e),!1}let u=t;s!==null&&o!==null&&(u=t.firstChild,u??F(49)),fh(r,u,this);let d=n.theme.text;d!==void 0&&i!==a&&dh(0,i,a,u,d);let f=e.__style,p=this.__style;return f!==p&&ch(t.style,p,f),!1}updateFromJSON(e){return super.updateFromJSON(e).setTextContent(e.text).setFormat(e.format).setDetail(e.detail).setMode(e.mode).setStyle(e.style)}exportDOM(e){let{element:t}=super.exportDOM(e);return q(t)||F(132),t.style.whiteSpace=`pre-wrap`,this.hasFormat(`lowercase`)?t.style.textTransform=`lowercase`:this.hasFormat(`uppercase`)?t.style.textTransform=`uppercase`:this.hasFormat(`capitalize`)&&(t.style.textTransform=`capitalize`),this.hasFormat(`bold`)&&(t=mh(t,`b`)),this.hasFormat(`italic`)&&(t=mh(t,`i`)),this.hasFormat(`strikethrough`)&&(t=mh(t,`s`)),this.hasFormat(`underline`)&&(t=mh(t,`u`)),{element:t}}exportJSON(){return{detail:this.getDetail(),format:this.getFormat(),mode:this.getMode(),style:this.getStyle(),text:this.getTextContent(),...super.exportJSON()}}selectionTransform(e,t){}setFormat(e){let t=this.getWritable();return t.__format=typeof e==`string`?Ud[e]:e,t}setDetail(e){let t=this.getWritable();return t.__detail=typeof e==`string`?Wd[e]:e,t}setStyle(e){let t=this.getWritable();return t.__style=e,t}toggleFormat(e){let t=K_(this.getFormat(),e,null);return this.setFormat(t)}toggleDirectionless(){let e=this.getWritable();return e.__detail^=1,e}toggleUnmergeable(){let e=this.getWritable();return e.__detail^=2,e}setMode(e){let t=qd[e];if(this.__mode===t)return this;let n=this.getWritable();return n.__mode=t,n}setTextContent(e){if(this.__text===e)return this;let t=this.getWritable();return t.__text=e,t}select(e,t){Ng();let n=e,r=t,i=V(),a=this.getTextContent(),o=this.__key;if(typeof a==`string`){let e=a.length;n===void 0&&(n=e),r===void 0&&(r=e)}else n=0,r=0;if(!B(i))return ig(o,n,o,r,`text`,`text`);{let e=Z_();e!==i.anchor.key&&e!==i.focus.key||X_(o),i.setTextNodeRange(this,n,this,r)}return i}selectStart(){return this.select(0,0)}selectEnd(){let e=this.getTextContentSize();return this.select(e,e)}spliceText(e,t,n,r){let i=this.getWritable(),a=i.__text,o=n.length,s=e;s<0&&(s=o+s,s<0&&(s=0));let c=V();if(r&&B(c)){let t=e+o;c.setTextNodeRange(i,t,i,t)}return i.__text=a.slice(0,s)+n+a.slice(s+t),i}canInsertTextBefore(){return!0}canInsertTextAfter(){return!0}splitText(...e){Ng();let t=this.getLatest(),n=t.getTextContent();if(n===``)return[];let r=t.__key,i=Z_(),a=n.length;e.sort((e,t)=>e-t),e.push(a);let o=[],s=e.length;for(let t=0,r=0;t<a&&r<=s;r++){let i=e[r];i>t&&(o.push(n.slice(t,i)),t=i)}let c=o.length;if(c===1)return[t];let l=o[0],u=t.getParent(),d,f=t.getFormat(),p=t.getStyle(),m=t.__detail,h=!1,g=null,_=null,v=V();if(B(v)){let[e,t]=v.isBackward()?[v.focus,v.anchor]:[v.anchor,v.focus];e.type===`text`&&e.key===r&&(g=e),t.type===`text`&&t.key===r&&(_=t)}t.isSegmented()?(d=Th(l),d.__format=f,d.__style=p,d.__detail=m,d.__state=Af(t,d),h=!0):d=t.setTextContent(l);let y=[d];for(let e=1;e<c;e++){let n=Th(o[e]);n.__format=f,n.__style=p,n.__detail=m,n.__state=Af(t,n);let a=n.__key;i===r&&X_(a),y.push(n)}let b=g?g.offset:null,ee=_?_.offset:null,te=0;for(let e of y){if(!g&&!_)break;let t=te+e.getTextContentSize();if(g!==null&&b!==null&&b<=t&&b>=te&&(g.set(e.getKey(),b-te,`text`),b<t&&(g=null)),_!==null&&ee!==null&&ee<=t&&ee>=te){_.set(e.getKey(),ee-te,`text`);break}te=t}if(u!==null){(function(e){let t=e.getPreviousSibling(),n=e.getNextSibling();t!==null&&Y_(t),n!==null&&Y_(n)})(this);let e=u.getWritable(),t=this.getIndexWithinParent();h?(e.splice(t,0,y),this.remove()):e.splice(t,1,y),B(v)&&lg(v,u,t,c-1)}return y}mergeWithSibling(e){let t=e===this.getPreviousSibling();t||e===this.getNextSibling()||F(50);let n=this.__key,r=e.__key,i=this.__text,a=i.length;Z_()===r&&X_(n);let o=V();if(B(o)){let i=o.anchor,s=o.focus;i!==null&&i.key===r&&fg(i,t,n,e,a),s!==null&&s.key===r&&fg(s,t,n,e,a)}let s=e.__text,c=t?s+i:i+s;this.setTextContent(c);let l=this.getWritable();return e.remove(),l}isTextEntity(){return!1}};function _h(e){return{forChild:Eh(e.style),node:null}}function vh(e){let t=e,n=t.style.fontWeight===`normal`;return{forChild:Eh(t.style,n?void 0:`bold`),node:null}}let yh=/* @__PURE__ */ new WeakMap;function bh(e){if(!q(e))return!1;if(e.nodeName===`PRE`)return!0;let t=e.style.whiteSpace;return typeof t==`string`&&t.startsWith(`pre`)}function xh(e){let t=e;e.parentElement===null&&F(129);let n=t.textContent||``;if(function(e){let t,n=e.parentNode,r=[e];for(;n!==null&&(t=yh.get(n))===void 0&&!bh(n);)r.push(n),n=n.parentNode;let i=t===void 0?n:t;for(let e=0;e<r.length;e++)yh.set(r[e],i);return i}(t)!==null)return{node:_g(n)};if(n=n.replace(/\r/g,``).replace(/[ \t\n]+/g,` `),n===``)return{node:null};if(n[0]===` `){let e=t,r=!0;for(;e!==null&&(e=Sh(e,!1))!==null;){let t=e.textContent||``;if(t.length>0){/[ \t\n]$/.test(t)&&(n=n.slice(1)),r=!1;break}}r&&(n=n.slice(1))}if(n[n.length-1]===` `){let e=t,r=!0;for(;e!==null&&(e=Sh(e,!0))!==null;)if((e.textContent||``).replace(/^( |\t|\r?\n)+/,``).length>0){r=!1;break}r&&(n=n.slice(0,n.length-1))}return n===``?{node:null}:{node:Th(n)}}function Sh(e,t){let n=e;for(;;){let e;for(;(e=t?n.nextSibling:n.previousSibling)===null;){let e=n.parentElement;if(e===null)return null;n=e}if(n=e,q(n)){let e=n.style.display;if(e===``&&!dy(n)||e!==``&&!e.startsWith(`inline`))return null}let r=n;for(;(r=t?n.firstChild:n.lastChild)!==null;)n=r;if(U_(n))return n;if(n.nodeName===`BR`)return null}}let Ch={code:`code`,em:`italic`,i:`italic`,mark:`highlight`,s:`strikethrough`,strong:`bold`,sub:`subscript`,sup:`superscript`,u:`underline`};function wh(e){let t=Ch[e.nodeName.toLowerCase()];return t===void 0?{node:null}:{forChild:Eh(e.style,t),node:null}}function Th(e=``){return Bv(new gh(e))}function z(e){return e instanceof gh}function Eh(e,t){let n=e.fontWeight,r=e.textDecoration.split(` `),i=n===`700`||n===`bold`,a=r.includes(`line-through`),o=e.fontStyle===`italic`,s=r.includes(`underline`),c=e.verticalAlign;return e=>((z(e)||hh(e))&&(i&&!e.hasFormat(`bold`)&&e.toggleFormat(`bold`),a&&!e.hasFormat(`strikethrough`)&&e.toggleFormat(`strikethrough`),o&&!e.hasFormat(`italic`)&&e.toggleFormat(`italic`),s&&!e.hasFormat(`underline`)&&e.toggleFormat(`underline`),c!==`sub`||e.hasFormat(`subscript`)||e.toggleFormat(`subscript`),c!==`super`||e.hasFormat(`superscript`)||e.toggleFormat(`superscript`),t&&!e.hasFormat(t)&&e.toggleFormat(t)),e)}var Dh=class extends gh{$config(){return this.config(`tab`,{extends:gh})}constructor(e=void 0){super(` `,e),this.__detail=2}createDOM(e){let t=super.createDOM(e),n=Sv(e.theme,`tab`);return n!==void 0&&t.classList.add(...n),t}setTextContent(e){return super.setTextContent(` `)}spliceText(e,t,n,r){return n===``&&t===0||n===` `&&t===1||F(286),this}setDetail(e){return e!==2&&F(127),this}setMode(e){return e!==`normal`&&F(128),this}canInsertTextBefore(){return!1}canInsertTextAfter(){return!1}};function Oh(){return Bv(new Dh)}function kh(e){return e instanceof Dh}var Ah=class{key;offset;type;_selection;constructor(e,t,n){this._selection=null,this.key=e,this.offset=t,this.type=n}is(e){return this.key===e.key&&this.offset===e.offset&&this.type===e.type}isBefore(e){return this.key===e.key?this.offset<e.offset:Ib(Xb(Vb(this,`next`)),Xb(Vb(e,`next`)))<0}getNode(){let e=Q_(this.key);return e===null&&F(20),e}set(e,t,n,r){let i=this._selection,a=this.key;r&&this.key===e&&this.offset===t&&this.type===n||(this.key=e,this.offset=t,this.type=n,Mg()||(Z_()===a&&X_(e),i!==null&&(i.setCachedNodes(null),B(i)&&(i._cachedIsBackward=null),i.dirty=!0)))}};function jh(e,t,n){return new Ah(e,t,n)}function Mh(e,t){let n=t.__key,r=e.offset,i=`element`;if(z(t)){i=`text`;let e=t.getTextContentSize();r>e&&(r=e)}else if(!U(t)){let e=t.getNextSibling();if(z(e))n=e.__key,r=0,i=`text`;else{let e=t.getParent();e&&(n=e.__key,r=t.getIndexWithinParent()+1)}}e.set(n,r,i)}function Nh(e,t){if(U(t)){let n=t.getLastDescendant();U(n)||z(n)?Mh(e,n):Mh(e,t)}else Mh(e,t)}function Ph(e,t,n,r){let i=e.getNode(),a=i.getChildAtIndex(e.offset),o=Th();if(o.setFormat(n),o.setStyle(r),b_(a))a.splice(0,0,[o]);else if(a!==null){let e=Rv(i)?y_().append(o):o;a.insertBefore(e)}else if(Rv(i)){let e=i.getLastChild();U(e)&&!e.isInline()&&e.isEmpty()?e.append(o):i.append(y_().append(o))}else i.append(o);e.is(t)&&t.set(o.__key,0,`text`),e.set(o.__key,0,`text`)}function Fh(e,t,n,r){let i=e.anchor.getNode();z(i)||F(398);let a=e.anchor.offset,o=Th(t);o.setFormat(n),o.setStyle(r);let s=i.getParentOrThrow();if(a===0)s.isInline()&&!i.__prev?s.insertBefore(o):i.insertBefore(o,!1);else if(a===i.getTextContentSize())s.isInline()&&!i.__next?s.insertAfter(o):i.insertAfter(o,!1);else{let[e]=i.splitText(a);e.insertAfter(o,!1)}i.getTextContent()===``&&i.isAttached()&&i.remove(),o.selectEnd(),o.isComposing()&&e.anchor.type===`text`&&e.anchor.set(e.anchor.key,e.anchor.offset-t.length,e.anchor.type)}var Ih=class e{_nodes;_cachedNodes;dirty;constructor(e){this._cachedNodes=null,this._nodes=e,this.dirty=!1}getCachedNodes(){return this._cachedNodes}setCachedNodes(e){this._cachedNodes=e}is(e){if(!zh(e))return!1;let t=this._nodes,n=e._nodes;return t.size===n.size&&Array.from(t).every(e=>n.has(e))}isCollapsed(){return!1}isBackward(){return!1}getStartEndPoints(){return null}add(e){this.dirty=!0,this._nodes.add(e),this._cachedNodes=null}delete(e){this.dirty=!0,this._nodes.delete(e),this._cachedNodes=null}clear(){this.dirty=!0,this._nodes.clear(),this._cachedNodes=null}has(e){return this._nodes.has(e)}clone(){return new e(new Set(this._nodes))}extract(){return this.getNodes()}insertRawText(e){}insertText(){}insertNodes(e){let t=this.getNodes().filter(e=>Wy(e)===null),n=t.length;if(n===0)return;let r=t[n-1],i;if(z(r))i=r.select();else{let e=r.getIndexWithinParent()+1;i=r.getParentOrThrow().select(e,e)}i.insertNodes(e);for(let e=0;e<n;e++)t[e].remove()}getNodes(){let e=this._cachedNodes;if(e!==null)return e;let t=this._nodes,n=[];for(let e of t){let t=Q_(e);t!==null&&n.push(t)}return Mg()||(this._cachedNodes=n),n}getTextContent(){let e=this.getNodes(),t=``;for(let n=0;n<e.length;n++)t+=e[n].getTextContent();return t}deleteNodes(){let e=this.getNodes().filter(e=>Wy(e)===null);if((V()||cg())===this&&e[0]){let t=Cb(e[0],`next`);Ub(Pb(t,t))}for(let t of e)t.remove();Lh()}};function Lh(){let e=av();if(e.isEmpty()){let t=y_();e.append(t),t.select()}}function B(e){return e instanceof Rh}var Rh=class e{format;style;anchor;focus;_cachedNodes;_cachedIsBackward;dirty;constructor(e,t,n,r){this.anchor=e,this.focus=t,e._selection=this,t._selection=this,this._cachedNodes=null,this._cachedIsBackward=null,this.format=n,this.style=r,this.dirty=!1}getCachedNodes(){return this._cachedNodes}setCachedNodes(e){this._cachedNodes=e}is(e){return!!B(e)&&this.anchor.is(e.anchor)&&this.focus.is(e.focus)&&this.format===e.format&&this.style===e.style}isCollapsed(){return this.anchor.is(this.focus)}getNodes(){let e=this._cachedNodes;if(e!==null)return e;let t=function(e){let t=[],[n,r]=e.getTextSlices();n&&t.push(n.caret.origin);let i=/* @__PURE__ */ new Set,a=/* @__PURE__ */ new Set;for(let n of e)if(yb(n)){let{origin:e}=n;t.length===0?i.add(e):(a.add(e),t.push(e))}else{let{origin:e}=n;U(e)&&a.has(e)||t.push(e)}if(r&&t.push(r.caret.origin),vb(e.focus)&&U(e.focus.origin)&&e.focus.getNodeAtCaret()===null)for(let n=Db(e.focus.origin,`previous`);yb(n)&&i.has(n.origin)&&!n.origin.isEmpty()&&n.origin.is(t[t.length-1]);n=kb(n))i.delete(n.origin),t.pop();for(;t.length>1;){let e=t[t.length-1];if(!U(e)||a.has(e)||e.isEmpty()||i.has(e))break;t.pop()}if(t.length===0&&e.isCollapsed()){let n=Xb(e.anchor),r=Xb(e.anchor.getFlipped()),i=e=>_b(e)?e.origin:e.getNodeAtCaret(),a=i(n)||i(r)||(e.anchor.getNodeAtCaret()?n.origin:r.origin);t.push(a)}return t}($b(Gb(this),`next`));return Mg()||(this._cachedNodes=t),t}setTextNodeRange(e,t,n,r){return this.anchor.set(e.__key,t,`text`),this.focus.set(n.__key,r,`text`),this}getTextContent(){let e=this.getNodes();if(e.length===0)return``;let t=e[0],n=e[e.length-1],r=this.anchor,i=this.focus,a=r.isBefore(i),[o,s]=Uh(this),c=``,l=!0;for(let u=0;u<e.length;u++){let d=e[u];if(U(d)&&!d.isInline()){l||(c+=`
140
+ `);let e=``;for(let t of Yy(d)){let n=Xy(d,t);n!==null&&(e+=n.getTextContent())}e===``?l=!d.isEmpty():(c+=e,l=!1)}else if(l=!1,z(d)){let e=d.getTextContent();d===t?d===n?r.type===`element`&&i.type===`element`&&i.offset!==r.offset||(e=o<s?e.slice(o,s):e.slice(s,o)):e=a?e.slice(o):e.slice(s):d===n&&(e=a?e.slice(0,s):e.slice(0,o)),c+=e}else!W(d)&&!p_(d)||d===n&&this.isCollapsed()||(c+=d.getTextContent())}return c}applyDOMRange(e){let t=H(),n=t.getEditorState()._selection,r=ng(e.startContainer,e.startOffset,e.endContainer,e.endOffset,t,n);if(r===null)return;let[i,a,o]=r;this.anchor.set(i.key,i.offset,i.type,!0),this.focus.set(a.key,a.offset,a.type,!0),o&&(this.dirty=!0),Pf(this)}clone(){let t=this.anchor,n=this.focus;return new e(jh(t.key,t.offset,t.type),jh(n.key,n.offset,n.type),this.format,this.style)}toggleFormat(e){this.format=K_(this.format,e,null),this.dirty=!0}setFormat(e){this.format=e,this.dirty=!0}setStyle(e){this.style=e,this.dirty=!0}hasFormat(e){let t=Ud[e];return(this.format&t)!==0}insertRawText(e){this.insertNodes(_g(e))}insertText(e){let t=this.format,n=this.style;if(!this.isCollapsed()){let r=(this.focus.isBefore(this.anchor)?this.focus:this.anchor).getNode();if(z(r)&&(t=r.getFormat(),n=r.getStyle()),this.removeText(),this.format=t,this.style=n,e===``)return;if(Z_()===null)return this.anchor.type===`element`&&Ph(this.anchor,this.focus,t,n),void Fh(this,e,t,n)}this.anchor.type===`element`&&Ph(this.anchor,this.focus,t,n);let r=this.anchor.getNode();z(r)||F(398);let i=this.anchor.offset,a=r.getParentOrThrow(),o=r.getTextContentSize();if(H_(r)||i===0&&(!r.canInsertTextBefore()||!a.canInsertTextBefore()&&!r.__prev)||i===o&&(!r.canInsertTextAfter()||!a.canInsertTextAfter()&&!r.__next)){if(r.isSegmented()&&i!==0&&i!==o){if(Z_()!==null)r.setMode(`normal`).setFormat(t).setStyle(n);else{let e=Th(r.getTextContent());e.setFormat(t),e.setStyle(n),r.replace(e),e.select(i,i)}e!==``&&this.insertText(e);return}if(e===``)return;if(i===0){let i=r.getPreviousSibling();if(z(i)&&i.canInsertTextAfter()&&!H_(i))i.select();else{let e=Th();e.setFormat(t),e.setStyle(n),a.canInsertTextBefore()?r.insertBefore(e):a.insertBefore(e),e.select()}this.insertText(e);return}if(i===o){let i=r.getNextSibling();if(z(i)&&i.canInsertTextBefore()&&!H_(i))i.select(0,0);else{let e=Th();e.setFormat(t),e.setStyle(n),a.canInsertTextAfter()?r.insertAfter(e):a.insertAfter(e),e.select(0,0)}this.insertText(e);return}let s=Th(e);s.setFormat(t),s.setStyle(n),r.replace(s),s.select();return}if(e===``)return;let s=a.isInline()&&i===0&&!r.__prev,c=a.isInline()&&i===o&&!r.__next,l=r.getFormat()!==t||r.getStyle()!==n;if(s||c||l){if(r.getTextContent()!==``||s||c)return void Fh(this,e,t,n);r.setFormat(t),r.setStyle(n)}r.spliceText(i,0,e,!0),r.isComposing()&&this.anchor.type===`text`&&this.anchor.set(this.anchor.key,this.anchor.offset-e.length,this.anchor.type)}removeText(){let e=V()===this;Wb(this,Yb(Gb(this))),e&&V()!==this&&ov(this)}formatText(e,t=null){Vh(this,e,t)}insertNodes(e){if(e.length===0)return;this.isCollapsed()||this.removeText();let t=this.anchor.getNode();if(this.anchor.type===`element`&&U(t)&&Wy(t)!==null){let n=t.isShadowRoot()?t.getFirstChild()??t.append(y_()).getFirstChild():t.getFirstChild();if(t.isShadowRoot()&&n!==null&&!U(n)){let e=y_();n.insertBefore(e),n=e}if(n!==null){n.selectStart();let t=V();return B(t)||F(369),t.insertNodes(e)}}if(this.anchor.type===`element`&&Rv(t)){let n=Sg(e),r=n.getLastDescendant();t.splice(this.anchor.offset,0,n.getChildren()),r!==null&&r.selectEnd();return}let n=(this.isBackward()?this.focus:this.anchor).getNode(),r=Ry(n,my),i=e[e.length-1];if(U(r)&&`__language`in r){if(`__language`in e[0])this.insertText(e[0].getTextContent());else{let t=yg(this);r.splice(t,0,e),i.selectEnd()}return}if(!e.some(e=>(U(e)||W(e))&&!e.isInline())){U(r)||F(211,n.constructor.name,n.getType());let t=yg(this);r.splice(t,0,e),i.selectEnd();return}if(U(r)&&Wy(r)!==null){let t=yg(this),n=vg(e);r.splice(t,0,n);let i=n[n.length-1];i===void 0?r.select(t,t):i.selectEnd();return}if(r===null){let t=Sg(e),n=t.getLastDescendant(),r=Vb(this.anchor,`next`);for(let e of t.getChildren())r=ix(e,r);n!==null&&n.selectEnd();return}if(U(r)&&!r.isParentRequired()&&!Rv(r.getParentOrThrow())){let t=yg(this),n=vg(e);r.splice(t,0,n);let i=n[n.length-1];i===void 0?r.select(t,t):i.selectEnd();return}let a=Sg(e),o=a.getLastDescendant(),s=a.getChildren(),c=!U(r)||!r.isEmpty()?this.insertParagraph():null;c&&!r.isAttached()&&(n=this.anchor.getNode(),r=Ry(n,my));let l=s[s.length-1],u=s[0];var d;U(d=u)&&my(d)&&!d.isEmpty()&&U(r)&&(!r.isEmpty()||r.canMergeWhenEmpty())&&(U(r)||F(211,n.constructor.name,n.getType()),r.append(...u.getChildren()),u=s[1]),u&&(r===null&&F(212,n.constructor.name,n.getType()),function(e,t){let n=t.getParentOrThrow().getLastChild(),r=t,i=[t];for(;r!==n;)r.getNextSibling()||F(140),r=r.getNextSibling(),i.push(r);let a=e;for(let e of i)a=a.insertAfter(e)}(r,u));let f=Ry(o,my);c&&U(f)&&(c.canMergeWhenEmpty()||my(l))&&(f.append(...c.getChildren()),c.remove()),U(r)&&r.isEmpty()&&r.remove(),o.selectEnd();let p=U(r)?r.getLastChild():null;p_(p)&&f!==r&&p.remove()}insertParagraph(){let e=this.anchor.getNode();if(this.anchor.type===`element`&&Rv(e)){let t=y_();return e.splice(this.anchor.offset,0,[t]),t.select(),t}let t=yg(this),n=Ry(this.anchor.getNode(),my);if(n!==null&&Wy(n)!==null)return null;U(n)||F(213);let r=n.getChildAtIndex(t),i=r?[r,...r.getNextSiblings()]:[],a=n.insertNewAfter(this,!1);return a?(a.append(...i),a.selectStart(),a):null}insertLineBreak(e){let t=f_();if(this.insertNodes([t]),e){let e=t.getParentOrThrow(),n=t.getIndexWithinParent();e.select(n,n)}}extract(){let e=[...this.getNodes()],t=e.length,n=e[0],r=e[t-1],[i,a]=Uh(this),o=this.isBackward(),[s,c]=o?[this.focus,this.anchor]:[this.anchor,this.focus],[l,u]=o?[a,i]:[i,a];if(t===0)return[];if(t===1){if(z(n)&&!this.isCollapsed()){let e=n.splitText(l,u),t=l===0?e[0]:e[1];return t?(s.set(t.getKey(),0,`text`),c.set(t.getKey(),t.getTextContentSize(),`text`),[t]):[]}return[n]}if(z(n)&&(l===n.getTextContentSize()?e.shift():l!==0&&([,n]=n.splitText(l),e[0]=n,s.set(n.getKey(),0,`text`))),z(r)){let t=r.getTextContent().length;u===0?e.pop():u!==t&&([r]=r.splitText(u),e[e.length-1]=r,c.set(r.getKey(),r.getTextContentSize(),`text`))}return e}modify(e,t,n){if(Cg(this,e,t,n))return;let r=e===`move`,i=H(),a=Gv(Pv(i));if(!a)return;let o=i._blockCursorElement,s=i._rootElement,c=this.focus.getNode();s===null||o===null||!U(c)||c.isInline()||c.canBeEmpty()||Wv(o,i,s);let l=Dv(i,this.focus.key),u=l;if(this.focus.type===`text`&&(u=z(c)?yy(c,l,i):null),this.dirty){let e=Dv(i,this.anchor.key),t=e;if(this.anchor.type===`text`){let n=this.anchor.getNode();t=z(n)?yy(n,e,i):null}t&&u&&pg(a,t,this.anchor.offset,u,this.focus.offset)}if(n===`character`&&z(c)&&c.isUnmergeable()&&(t?this.focus.offset===0:this.focus.offset===c.getTextContentSize())){let e=Cb(c,t?`previous`:`next`).getNodeAtCaret();if(z(e)){if(!r){let n=e.getTextContentSize();t?this.focus.set(e.__key,n-1,`text`):this.focus.set(e.__key,1,`text`),this.dirty=!0;return}{let n=i.getElementByKey(e.getKey()),r=n?yy(e,n,i):null;if(r){let e=t?r.length:0;pg(a,r,e,r,e)}}}}if(Kh(a,e,t?`backward`:`forward`,n),a.rangeCount>0){let e=$v(a,i._rootElement),n=e||a.getRangeAt(0),o=this.anchor.getNode(),s=r_(o)?o:Iv(o);this.applyDOMRange(n),this.dirty=!0,!r&&(qh(this,t,s),(e?a.direction!==`backward`:a.anchorNode===n.startContainer&&a.anchorOffset===n.startOffset)||Gh(this))}n===`lineboundary`&&Cg(this,e,t,n,`decorators`)}forwardDeletion(e,t,n){if(!n&&(e.type===`element`&&U(t)&&e.offset===t.getChildrenSize()||e.type===`text`&&e.offset===t.getTextContentSize())){let e=t.getParent(),n=t.getNextSibling()||(e===null?null:e.getNextSibling());if(U(n)&&n.isShadowRoot())return!0}return!1}deleteCharacter(e){let t=this.isCollapsed();if(this.isCollapsed()){let t=this.anchor,n=t.getNode();if(this.forwardDeletion(t,n,e))return;let r=Mb(Vb(t,e?`previous`:`next`));if(r.getTextSlices().every(e=>e===null||e.distance===0)){let e={type:`initial`};for(let t of r.iterNodeCarets(`shadowRoot`))if(yb(t)){if(!t.origin.isInline()){if(t.origin.isShadowRoot()){if(e.type===`merge-block`)break;if(U(r.anchor.origin)&&r.anchor.origin.isEmpty()){let e=Xb(t);Wb(this,Pb(e,e)),r.anchor.origin.remove()}return}e.type!==`merge-next-block`&&e.type!==`merge-block`||(e={block:e.block,caret:t,type:`merge-block`})}}else{if(e.type===`merge-block`)break;if(vb(t)){if(U(t.origin)){if(t.origin.isInline()){if(!t.origin.isParentOf(r.anchor.origin))break}else e={block:t.origin,type:`merge-next-block`};continue}if(W(t.origin)){if(!t.origin.isIsolated()){if(Yy(t.origin).length>0){if(U(r.anchor.origin)&&r.anchor.origin.isEmpty()){r.anchor.origin.remove();let e=og();e.add(t.origin.getKey()),ov(e)}}else if(e.type===`merge-next-block`&&(t.origin.isKeyboardSelectable()||!t.origin.isInline())&&U(r.anchor.origin)&&r.anchor.origin.isEmpty()){r.anchor.origin.remove();let e=og();e.add(t.origin.getKey()),ov(e)}else t.origin.remove()}return}break}}if(e.type===`merge-block`){let{caret:t,block:n}=e;return Yy(n).length>0?void 0:t.origin.isEmpty()&&!n.isEmpty()&&t.origin.getParent()===n.getParent()?void t.origin.remove(!0):(Wb(this,Pb(!t.origin.isEmpty()&&n.isEmpty()?Kb(Cb(n,t.direction)):r.anchor,t)),this.removeText())}for(let e=t.getNode();e!==null;){if(Wy(e)!==null)return;if(U(e)&&e.isShadowRoot())break;e=e.getParent()}}let i=this.focus;if(Jh(this,e,`character`),this.isCollapsed()){if(e&&t.offset===0&&Wh(this,t.getNode()))return}else{let r=i.type===`text`?i.getNode():null;if(n=t.type===`text`?t.getNode():null,r!==null&&r.isSegmented()){let t=i.offset,a=r.getTextContentSize();if(r.is(n)||e&&t!==a||!e&&t!==0)return void Xh(r,e,t)}else if(n!==null&&n.isSegmented()){let i=t.offset,a=n.getTextContentSize();if(n.is(r)||e&&i!==0||!e&&i!==a)return void Xh(n,e,i)}(function(e,t){let n=e.anchor,r=e.focus,i=n.getNode();if(i===r.getNode()&&n.type===`text`&&r.type===`text`){let e=n.offset,a=r.offset,o=e<a,s=o?e:a,c=o?a:e,l=c-1;s!==l&&(function(e){return!(lv(e)||Yh(e))})(i.getTextContent().slice(s,c))&&(t?r.set(r.key,l,r.type):n.set(n.key,l,n.type))}})(this,e)}}if(this.removeText(),e&&!t&&this.isCollapsed()&&this.anchor.type===`element`&&this.anchor.offset===0){let e=this.anchor.getNode();e.isEmpty()&&r_(e.getParent())&&e.getPreviousSibling()===null&&Wh(this,e),Lh()}}deleteLine(e){let t=$h(this.anchor);if(t!==null&&W(Gy(t)))return this.isCollapsed()||this.focus.set(this.anchor.key,this.anchor.offset,this.anchor.type),void this.deleteCharacter(e);this.isCollapsed()&&Jh(this,e,`lineboundary`),this.isCollapsed()?this.deleteCharacter(e):Ry(this.anchor.getNode(),my)===Ry(this.focus.getNode(),my)?this.removeText():(this.focus.set(this.anchor.key,this.anchor.offset,this.anchor.type),this.deleteCharacter(e))}deleteWord(e){if(this.isCollapsed()){let t=this.anchor,n=t.getNode();if(this.forwardDeletion(t,n,e))return;Jh(this,e,`word`)}this.isCollapsed()?this.deleteCharacter(e):this.removeText()}isBackward(){let e=this._cachedIsBackward;if(e!==null)return e;let t=this.focus.isBefore(this.anchor);return Mg()||(this._cachedIsBackward=t),t}getStartEndPoints(){return[this.anchor,this.focus]}};function zh(e){return e instanceof Ih}function Bh(e,t){if(zh(e)){for(let n of e.getNodes())hh(n)&&n.setFormat(t(n.getFormat()));return}if(e.isCollapsed())return e.setFormat(t(e.format)),void X_(null);let n=[];for(let r of e.getNodes())z(r)?n.push(r):U(r)?r.setTextFormat(t(r.getTextFormat())):hh(r)&&r.setFormat(t(r.getFormat()));let r=n.length;if(r===0)return e.setFormat(t(e.format)),void X_(null);let i=e.anchor,a=e.focus,o=e.isBackward(),s=o?a:i,c=o?i:a,l=0,u=n[0],d=s.type===`element`?0:s.offset;if(s.type===`text`&&d===u.getTextContentSize()&&(l=1,u=n[1],d=0),u==null)return;let f=r-1,p=n[f],m=c.type===`text`?c.offset:p.getTextContentSize();if(u.is(p)){if(d===m)return;let n=t(u.getFormat());if(H_(u)||d===0&&m===u.getTextContentSize())u.setFormat(n);else{let e=u.splitText(d,m),t=d===0?e[0]:e[1];t.setFormat(n),s.type===`text`&&s.set(t.__key,0,`text`),c.type===`text`&&c.set(t.__key,m-d,`text`)}e.format=n;return}d===0||H_(u)||([,u]=u.splitText(d),d=0);let h=t(u.getFormat());u.setFormat(h);let g=t(p.getFormat());m>0&&(m===p.getTextContentSize()||H_(p)||([p]=p.splitText(m)),p.setFormat(g));for(let e=l+1;e<f;e++){let r=n[e];r.setFormat(t(r.getFormat()))}s.type===`text`&&s.set(u.__key,d,`text`),c.type===`text`&&c.set(p.__key,m,`text`),e.format=h|g}function Vh(e,t,n=null){let r=n===null&&B(e)?K_(e.format,t,null):n;Bh(e,e=>K_(e,t,r))}function Hh(e){let t=e.offset;if(e.type===`text`)return t;let n=e.getNode();return t===n.getChildrenSize()?n.getTextContent().length:0}function Uh(e){let t=e.getStartEndPoints();if(t===null)return[0,0];let[n,r]=t;return n.type===`element`&&r.type===`element`&&n.key===r.key&&n.offset===r.offset?[0,0]:[Hh(n),Hh(r)]}function Wh(e,t){for(let n=t;n;n=n.getParent()){if(U(n)){if(n.collapseAtStart(e))return!0;if(Rv(n))break}if(n.getPreviousSibling())break}return!1}function Gh(e){let t=e.focus,n=e.anchor,r=n.key,i=n.offset,a=n.type;n.set(t.key,t.offset,t.type,!0),t.set(r,i,a,!0)}function Kh(e,t,n,r){e.modify(t,n,r)}function qh(e,t,n){let r=e.getNodes(),i=r.filter(e=>Mv(e,n));if(i.length===0||i.length===r.length)return!1;let a=t?i[0]:i[i.length-1],o=U(a)?a:a.getParentOrThrow();return t?o.selectStart():o.selectEnd(),!0}function Jh(e,t,n){if(Cg(e,`extend`,t,n))return;let r=H(),i=Gv(Pv(r));if(!i||typeof i.modify!=`function`)return;let a=r._blockCursorElement,o=r._rootElement,s=e.anchor,c=e.focus.getNode();o===null||a===null||!U(c)||c.isInline()||c.canBeEmpty()||Wv(a,r,o);let l=e=>{let t=e.getNode(),n=r.getElementByKey(e.key);return n!==null&&e.type===`text`&&z(t)?yy(t,n,r):n},u=s.getNode(),d=l(s);if(d===null)return;let f=s.offset,p=e.isCollapsed(),m=e.focus,h=p?d:l(m);if(h===null)return;let g=m.offset;if(pg(i,h,g,h,g),Kh(i,`move`,t?`backward`:`forward`,n),i.rangeCount===0)return;let _=$v(i,o)||i.getRangeAt(0),v=_.startContainer,y=_.startOffset;if(p&&n===`character`&&s.type===`text`&&z(u)&&u.isUnmergeable()&&f===(t?0:u.getTextContentSize())){let n=Cb(u,t?`previous`:`next`).getNodeAtCaret();if(z(n)){let r=t?n.getTextContentSize()-1:1;e.focus.set(n.__key,r,`text`),e.dirty=!0;return}}if(p&&n===`character`&&s.type===`text`){let n=t?0:u.getTextContentSize(),r=v===d?y:f===n?-1:n;if(r>=0)return void(r!==f&&(e.focus.set(s.key,r,`text`),e.dirty=!0))}let[b,ee,te,ne]=t?[v,y,d,f]:[d,f,v,y],re=r_(u)?u:Iv(u);e.applyDOMRange({collapsed:!1,endContainer:te,endOffset:ne,startContainer:b,startOffset:ee}),e.dirty=!0,!qh(e,t,re)&&t&&Gh(e),n===`lineboundary`&&Cg(e,`extend`,t,n,`decorators`)}let Yh=(()=>{try{let e=RegExp(`\\p{Emoji}`,`u`),t=e.test.bind(e);if(t(`❤️`)&&t(`#️⃣`)&&t(`👍`))return t}catch{}return()=>!1})();function Xh(e,t,n){let r=e,i=r.getTextContent().split(/(?=\s)/g),a=i.length,o=0,s=0;for(let e=0;e<a;e++){let r=e===a-1;if(s=o,o+=i[e].length,t&&o===n||o>n||r){i.splice(e,1),r&&(s=void 0);break}}let c=i.join(``).trim();c===``?r.remove():(r.setTextContent(c),r.select(s,s))}function Zh(e,t,n,r){let i,a=t,o=!1;if(q(e)){let s=!1,c=e.childNodes,l=c.length,u=r._blockCursorElement;a===l&&l>0&&(s=!0,a=l-1),tv(e,r)!==void 0||jy(e,r)||(o=!0);let d=c[a],f=!1;if(d===u)d=c[a+1],f=!0;else if(u!==null){let n=u.parentNode;e===n&&t>Array.prototype.indexOf.call(n.children,u)&&a--}if(i=cv(d),z(i))a=Tb(i,s?`next`:`previous`);else{let c=cv(e);if(c===null)return null;if(U(c)){let o=r.getElementByKey(c.getKey());o===null&&F(214);let l=_y(c,o,r);[c,a]=l.resolveChildIndex(c,o,e,t),U(c)||F(215),s&&a>=c.getChildrenSize()&&(a=Math.max(0,c.getChildrenSize()-1));let u=c.getChildAtIndex(a);if(U(u)&&function(e,t,n){let r=e.getParent();return n===null||r===null||!r.canBeEmpty()||r!==n.getNode()}(u,0,n)){let e=s?u.getLastDescendant():u.getFirstDescendant();e===null?c=u:(u=e,c=U(u)?u:u.getParentOrThrow()),a=0}z(u)?(i=u,c=null,a=Tb(u,s?`next`:`previous`)):u!==c&&s&&!f&&(U(c)||F(216),a=Math.min(c.getChildrenSize(),a+1))}else{let n=Gy(c),i=n===null?c:n,o=i.getIndexWithinParent(),s=r.getElementByKey(c.getKey()),l=`after`;if(s!==null&&cv(e)===c){let n=_y(c,s,r);n.element===s?t===0&&W(c)&&(l=`before`):l=n.resolveLeafPosition(s,e,t)}a=l===`before`?o:o+1,c=i.getParentOrThrow()}if(U(c))return[jh(c.__key,a,`element`),o]}}else i=cv(e);return z(i)?[jh(i.__key,Tb(i,a,`clamp`),`text`),o]:null}function Qh(e,t,n){let r=e.offset,i=e.getNode();if(r===0){let r=i.getPreviousSibling(),a=i.getParent();if(t){if((n||!t)&&r===null&&U(a)&&a.isInline()){let t=a.getPreviousSibling();z(t)&&e.set(t.__key,t.getTextContent().length,`text`)}}else U(r)&&!n&&r.isInline()?e.set(r.__key,r.getChildrenSize(),`element`):z(r)&&!i.isUnmergeable()&&e.set(r.__key,r.getTextContent().length,`text`)}else if(r===i.getTextContent().length){let r=i.getNextSibling(),a=i.getParent();if(t&&U(r)&&r.isInline())e.set(r.__key,0,`element`);else if((n||t)&&r===null&&U(a)&&a.isInline()&&!a.canInsertTextAfter()&&a.getTextContentSize()>1){let t=a.getNextSibling();z(t)&&e.set(t.__key,0,`text`)}}}function $h(e){let t=Q_(e.key);return t===null?null:qy(t)}function eg(e,t,n){let r=$h(e),i=$h(t);if(r===i||r!==null&&i!==null&&r.is(i))return!1;let a=n(r,i);if(r!==null)return U(r)?t.set(r.getKey(),a?r.getChildrenSize():0,`element`):t.set(r.getKey(),a?r.getTextContentSize():0,`text`),!0;let o=Gy(i);if(o===null)return!1;let s=o.getParent();if(s===null)return!1;let c=o.getIndexWithinParent();return t.set(s.getKey(),a?c+1:c,`element`),!0}function tg(e){let t=eg(e.anchor,e.focus,(t,n)=>function(e,t,n,r){if(n!==null&&r!==null){let e=Gy(n),t=Gy(r);if(e!==null&&e.is(t)){for(let t of Jy(e).values()){if(t===n.getKey())return!0;if(t===r.getKey())return!1}return!0}return e===null||t===null||e.isBefore(t)}if(n!==null){let e=Gy(n),r=Q_(t.key);return e===null||r===null||!(!e.is(r)&&!e.isParentOf(r))||e.isBefore(r)}let i=Gy(r),a=Q_(e.key);return i!==null&&a!==null&&!i.is(a)&&!i.isParentOf(a)&&a.isBefore(i)}(e.anchor,e.focus,t,n));return t&&(e.dirty=!0),t}function ng(e,t,n,r,i,a){if(e===null||n===null||!L_(i,e,n))return null;let o=Zh(e,t,B(a)?a.anchor:null,i);if(o===null)return null;let s=Zh(n,r,B(a)?a.focus:null,i);if(s===null)return null;let[c,l]=o,[u,d]=s;if(c.type===`element`&&u.type===`element`){let t=cv(e),r=cv(n);if(W(t)&&W(r))return null}let f=i._slotsUsed&&eg(c,u,()=>(e.compareDocumentPosition(n)&Node.DOCUMENT_POSITION_FOLLOWING)!==0);return function(e,t){if(e.type===`text`&&t.type===`text`){let n=e.isBefore(t),r=e.is(t);Qh(e,n,r),Qh(t,!n,r),r&&t.set(e.key,e.offset,e.type)}}(c,u),[c,u,l||d||f]}function rg(e){return U(e)&&!e.isInline()}function ig(e,t,n,r,i,a){let o=Fg(),s=new Rh(jh(e,t,i),jh(n,r,a),0,``);return s.dirty=!0,o._selection=s,s}function ag(){return new Rh(jh(`root`,0,`element`),jh(`root`,0,`element`),0,``)}function og(){return new Ih(/* @__PURE__ */ new Set)}function sg(e,t,n,r){let i=n._window;if(i===null)return null;let a=r||i.event,o=a?a.type:void 0,s=o===`selectionchange`,c=!lf&&(s||o===`beforeinput`||o===`compositionstart`||o===`compositionend`||o===`click`&&a&&a.detail===3||o===`drop`||o===void 0),l,u,d,f;if(B(e)&&!c)return e.clone();{if(t===null)return null;let r=ty(t,n._rootElement);if(l=r.anchorNode,u=r.focusNode,d=r.anchorOffset,f=r.focusOffset,(s||o===void 0)&&B(e)&&!L_(n,l,u))return e.clone()}let p=ng(l,d,u,f,n,e);if(p===null)return null;let[m,h,g]=p,_=0,v=``;if(B(e)){let t=e.anchor;if(m.key===t.key)_=e.format,v=e.style;else{let e=m.getNode();z(e)?(_=e.getFormat(),v=e.getStyle()):U(e)&&(_=e.getTextFormat(),v=e.getTextStyle())}}let y=new Rh(m,h,_,v);return g&&(y.dirty=!0),y}function V(){return Fg()._selection}function cg(){return H()._editorState._selection}function lg(e,t,n,r=1){let i=e.anchor,a=e.focus,o=i.getNode(),s=a.getNode();if(!t.is(o)&&!t.is(s))return;let c=t.__key;if(e.isCollapsed()){let t=i.offset;if(n<=t&&r>0||n<t&&r<0){let n=Math.max(0,t+r);i.set(c,n,`element`),a.set(c,n,`element`),ug(e)}}else{let o=e.isBackward(),s=o?a:i,l=s.getNode(),u=o?i:a,d=u.getNode();if(t.is(l)){let e=s.offset;(n<=e&&r>0||n<e&&r<0)&&s.set(c,Math.max(0,e+r),`element`)}if(t.is(d)){let e=u.offset;(n<=e&&r>0||n<e&&r<0)&&u.set(c,Math.max(0,e+r),`element`)}}ug(e)}function ug(e){let t=e.anchor,n=t.offset,r=e.focus,i=r.offset,a=t.getNode(),o=r.getNode();if(e.isCollapsed()){if(!U(a))return;let e=a.getChildrenSize(),i=n>=e,o=i?a.getChildAtIndex(e-1):a.getChildAtIndex(n);if(z(o)){let e=0;i&&(e=o.getTextContentSize()),t.set(o.__key,e,`text`),r.set(o.__key,e,`text`)}}else{if(U(a)){let e=a.getChildrenSize(),r=n>=e,i=r?a.getChildAtIndex(e-1):a.getChildAtIndex(n);if(z(i)){let e=0;r&&(e=i.getTextContentSize()),t.set(i.__key,e,`text`)}}if(U(o)){let e=o.getChildrenSize(),t=i>=e,n=t?o.getChildAtIndex(e-1):o.getChildAtIndex(i);if(z(n)){let e=0;t&&(e=n.getTextContentSize()),r.set(n.__key,e,`text`)}}}}function dg(e,t,n,r,i){let a=null,o=0,s=null;r===null?i!==null&&(a=i.__key,z(i)?s=`text`:U(i)&&(s=`element`)):(a=r.__key,z(r)?(o=r.getTextContentSize(),s=`text`):U(r)&&(o=r.getChildrenSize(),s=`element`)),a!==null&&s!==null?e.set(a,o,s):(o=t.getIndexWithinParent(),o===-1&&(o=n.getChildrenSize()),e.set(n.__key,o,`element`))}function fg(e,t,n,r,i){e.type===`text`?e.set(n,e.offset+(t?0:i),`text`):e.offset>r.getIndexWithinParent()&&e.set(e.key,e.offset-1,`element`)}function pg(e,t,n,r,i){try{e.setBaseAndExtent(t,n,r,i)}catch{}}function mg(e,t,n){let r=Dv(e,t.getKey());if(U(t)){let i=_y(t,r,e);return[i.element,n+i.getFirstChildOffset()]}return[r,n]}function hg(e,t,n,r,i,a){let o=a.getRootNode(),s=W_(o)||qv(o)?oy(o):null;if(i.has(`collaboration`)&&s!==a||s!==null&&I_(s,s))return;let c=ty(r,a),l;if(!B(t))return void(e!==null&&L_(n,c.anchorNode,c.focusNode)&&r.removeAllRanges());let u=t.anchor,d=t.focus,f=u.getNode(),p=d.getNode(),[m,h]=mg(n,f,u.offset),[g,_]=mg(n,p,d.offset),v=t.format,y=t.style,b=t.isCollapsed(),ee=m,te=g,ne=!1;if(u.type===`text`?(ee=z(f)?yy(f,m,n):null,ne=f.getFormat()!==v||f.getStyle()!==y):B(e)&&e.anchor.type===`text`&&(ne=!0),d.type===`text`&&(te=z(p)?yy(p,g,n):null),ee!==null&&te!==null){if(b&&(e===null||ne||B(e)&&(e.format!==v||e.style!==y))&&function(e,t,n,r,i,a){e._inputState.collapsedSelectionFormat={format:t,key:i,offset:r,style:n,timeStamp:a}}(n,v,y,h,u.key,performance.now()),(r.type!==`Range`||!b)&&c.anchorOffset===h&&c.focusOffset===_&&c.anchorNode===ee&&c.focusNode===te){if(s===null||!a.contains(s)){let e=s===null?null:z_(s);e!==null&&e!==n||i.has(`skip-selection-focus`)||a.focus({preventScroll:!0})}if(u.type!==`element`)return}if(pg(r,ee,h,te,_),jd&&t.isCollapsed()&&a!==null&&!i.has(`skip-selection-focus`)){let e=ay(a);if(e===null||!a.contains(e)){let e=oy(a.ownerDocument),t=e===null?null:z_(e);t!==null&&t!==n||a.focus({preventScroll:!0})}}if(!i.has(`skip-scroll-into-view`)&&t.isCollapsed()&&a!==null&&a===ay(a)){let e=B(t)&&t.anchor.type===`element`?ee.childNodes[h]||null:(l===void 0&&(l=ey(r,a)),l);if(e!==null){let t;if(U_(e)){let n=e.ownerDocument.createRange();n.selectNode(e),t=n.getBoundingClientRect()}else t=e.getBoundingClientRect();(function(e,t,n){let r=kv(n),i=Nv(r);if(r===null||i===null)return;let a=n.getBoundingClientRect();if(t.bottom<a.top)return;let{top:o,bottom:s}=t,c=0,l=0,u=n;for(;u!==null;){let t=u===r.body;if(t){let t=i.visualViewport;if(t){let e=t.pageTop-i.scrollY;c=e,l=e+t.height}else c=0,l=Pv(e).innerHeight;let n=i.getComputedStyle(r.documentElement),a=parseFloat(n.scrollPaddingTop),o=parseFloat(n.scrollPaddingBottom);isFinite(a)&&(c+=a),isFinite(o)&&(l-=o)}else{let e=u===n?a:u.getBoundingClientRect();c=e.top,l=e.bottom}let d=0;if(o<c?d=-(c-o):s>l&&(d=s-l),d!==0){if(t)i.scrollBy(0,d);else{let e=u.scrollTop;u.scrollTop+=d;let t=u.scrollTop-e;o-=t,s-=t}}if(t)break;u=Ov(u)}})(n,t,a)}}(function(e){e._inputState.isSelectionChangeFromDOMUpdate=!0})(n)}}function gg(e,t){for(let n of e.split(/(\r?\n|\t)/))n===`
141
141
  `||n===`\r
142
- `?t.linebreak():n===` `?t.tab():n!==``&&t.text(n)}function cg(e){let t=[];return sg(e,{linebreak:()=>t.push(r_()),tab:()=>t.push(yh()),text:e=>t.push(gh(e))}),t}function lg(e){let t=[];for(let n of e)i_(n)||(!U(n)&&!W(n)||n.isInline()?t.push(n):U(n)&&t.push(...lg(n.getChildren())));return t}function ug(e){let t=e;e.isCollapsed()||t.removeText();let n=V();B(n)&&(t=n),B(t)||F(161);let r=t.anchor,i=r.getNode(),a=r.offset;for(;!ay(i)&&Fy(i)===null;){let e=i;if([i,a]=dg(i,a),e.is(i))break}return a}function dg(e,t){let n=e.getParent();if(!n){let e=u_();return X_().append(e),e.select(),[X_(),0]}if(z(e)){let r=e.splitText(t);if(r.length===0)return[n,e.getIndexWithinParent()];let i=t===0?0:1;return[n,r[0].getIndexWithinParent()+i]}if(!U(e)||t===0)return[n,e.getIndexWithinParent()];let r=e.getChildAtIndex(t);if(r){let n=new kh(Sh(e.__key,t,`element`),Sh(e.__key,t,`element`),0,``),i=e.insertNewAfter(n);i&&i.append(r,...r.getNextSiblings())}return[n,e.getIndexWithinParent()+1]}function fg(e){return i_(e)||Ev(e)||z(e)||e.isParentRequired()}function pg(e){let t=u_(),n=null;for(let r=0;r<e.length;r++){let i=e[r];if(fg(i)){if(n===null){n=i.createParentElementNode(),t.append(n);let a=e[r+1];if(i_(i)&&(a===void 0||!fg(a)))continue}n.append(i)}else t.append(i),n=null}return t}function mg(e,t,n,r,i=`decorators-and-blocks`){if(t===`move`&&r===`character`&&!e.isCollapsed()){let[t,r]=n===e.isBackward()?[e.focus,e.anchor]:[e.anchor,e.focus];return r.set(t.key,t.offset,t.type),!0}let a=Mb(e.focus,n?`previous`:`next`),o=r===`lineboundary`,s=t===`move`,c=a,l=i===`decorators-and-blocks`;if(!Hb(c)){for(let e of c){l=!1;let{origin:t}=e;if(!W(t)||t.isIsolated()||(c=e,!o||!t.isInline()))break}if(l)for(let e of Cb(a).iterNodeCarets(t===`extend`?`shadowRoot`:`root`)){if(ub(e))e.origin.isInline()||(c=e);else{if(U(e.origin))continue;W(e.origin)&&!e.origin.isInline()&&(c=e)}break}}if(c===a)return!1;if(s&&!o&&W(c.origin)&&c.origin.isKeyboardSelectable()){let e=Zh();return e.add(c.origin.getKey()),Z_(e),!0}return c=Vb(c),s&&Nb(e.anchor,c),Nb(e.focus,c),l||!o}let hg=null,gg=null,_g=!1,vg=!1,yg=!1,bg=/* @__PURE__ */ new Set,xg=0,Sg={characterData:!0,childList:!0,subtree:!0};function Cg(){return _g||hg!==null&&hg._readOnly}function wg(){_g&&F(13)}function Tg(){xg>99&&F(14)}function Eg(){return hg===null&&F(195,kg()),hg}function Dg(e){Eg()!==null&&gg===null&&(gg=e),gg!==e&&vd(378)}function H(){return gg===null&&F(337,kg()),gg}function Og(){H()._dirtyType=2}function kg(){let e=0,t=/* @__PURE__ */ new Set,n=y_.version;if(typeof window<`u`)for(let r of Vv(document)){let i=j_(r);if(k_(i))e++;else if(i){let e=String(i.constructor.version||`<0.17.1`);e===n&&(e+=` (separately built, likely a bundler configuration issue)`),t.add(e)}}let r=` Detected on the page: ${e} compatible editor(s) with version ${n}`;return t.size&&(r+=` and incompatible editors with versions ${Array.from(t).join(`, `)}`),r}function Ag(){return gg}function jg(e,t,n){let r=t.__type,i=w_(e,r),a=n.get(r);a===void 0&&(a=Array.from(i.transforms),n.set(r,a));let o=a.length;for(let e=0;e<o&&(a[e](t),t.isAttached());e++);}function Mg(e,t){return e!==void 0&&e.__key!==t&&e.isAttached()}function Ng(e,t){if(!t)return;let n=e._updateTags,r=t;Array.isArray(t)||(r=[t]);for(let e of r)n.add(e)}function Pg(e,t){let n=e.type,r=t.get(n);r===void 0&&F(17,n);let i=r.klass;e.type!==i.getType()&&F(18,i.name);let a=i.importJSON(e),o=e.children;if(U(a)&&Array.isArray(o))for(let e=0;e<o.length;e++){let n=Pg(o[e],t);a.append(n)}let s=e.$slots;if(s){Ny(a)||F(379,i.name);for(let e in s)Zy(a,e,Pg(s[e],t))}return a}function Fg(e,t,n){let r=hg,i=_g,a=gg;hg=t,_g=!0,gg=e;try{return n()}finally{hg=r,_g=i,gg=a}}function Ig(e,t){let n=yg;yg=!0;try{(function(e,t){let n=e._pendingEditorState,r=e._rootElement,i=e._headless||r===null;if(n===null)return void(!e._updating&&e._deferred.length>0&&zg(e,e._deferred));let a=e._editorState,o=a._selection,s=n._selection,c=e._dirtyType!==0,l=hg,u=_g,d=gg,f=e._updating,p=e._observer,m=null;if(e._pendingEditorState=null,e._editorState=n,!i&&c&&p!==null){gg=e,hg=n,_g=!1,e._updating=!0;try{let t=e._dirtyType,r=e._dirtyElements,i=e._dirtyLeaves;p.disconnect(),m=vp(a,n,e,t,r,i)}catch(t){if(t instanceof Error&&e._onError(t),vg)throw t;p_(e,null,r,n),lf(e),e._dirtyType=2,vg=!0,Ig(e,a),vg=!1;return}finally{p.observe(r,Sg),e._updating=f,hg=l,_g=u,gg=d}}n._readOnly||=!0;let h=e._dirtyLeaves,g=e._dirtyElements,_=e._normalizedNodes,v=e._updateTags;c&&(e._dirtyType=0,e._cloneNotNeeded.clear(),e._dirtyLeaves=/* @__PURE__ */ new Set,e._dirtyElements=/* @__PURE__ */ new Map,e._normalizedNodes=/* @__PURE__ */ new Set),e._updateTags=/* @__PURE__ */ new Set,function(e,t){let n=e._decorators,r=e._pendingDecorators||n,i=t._nodeMap,a;for(a in r)i.has(a)||(r===n&&(r=J_(e)),delete r[a])}(e,n);let y=i?null:Iv(Tv(e));if(e._editable&&y!==null&&(c||s===null||s.dirty||!s.is(o))&&r!==null&&!v.has(`skip-dom-selection`)){gg=e,hg=n;try{if(p!==null&&p.disconnect(),c||s===null||s.dirty){let t=e._blockCursorElement;t!==null&&Fv(t,e,r),og(o,s,e,y,v,r)}(function(e,t,n){let r=e._blockCursorElement;if(B(n)&&n.isCollapsed()&&n.anchor.type===`element`&&t.contains(Xv(t))){let i=n.anchor,a=i.getNode(),o=i.offset,s=!1,c=null;if(o===a.getChildrenSize())Pv(a.getChildAtIndex(o-1))&&(s=!0);else{let t=a.getChildAtIndex(o);if(t!==null&&Pv(t)){let n=t.getPreviousSibling();(n===null||Pv(n))&&(s=!0,c=e.getElementByKey(t.__key))}}if(s){let n=cy(a,e.getElementByKey(a.__key),e).element;r===null&&(e._blockCursorElement=r=function(e){let t=e.theme,n=Uv().createElement(`div`);n.contentEditable=`false`,n.setAttribute(`data-lexical-cursor`,`true`);let r=t.blockCursor;return r!==void 0&&(typeof r==`string`&&(r=t.blockCursor=$b(r)),r!==void 0&&n.classList.add(...r)),n}(e._config)),t.style.caretColor=`transparent`,c===null?n.appendChild(r):n.insertBefore(r,c);return}}r!==null&&Fv(r,e,t)})(e,r,s)}finally{p!==null&&p.observe(r,Sg),gg=d,hg=l}}m!==null&&function(e,t,n,r,i){let a=Array.from(e._listeners.mutation),o=a.length;for(let e=0;e<o;e++){let[o,s]=a[e];for(let e of s){let a=t.get(e);a!==void 0&&o(a,{dirtyLeaves:r,prevEditorState:i,updateTags:n})}}}(e,m,v,h,a),B(s)||s===null||o!==null&&o.is(s)||e.dispatchCommand(bp);let b=e._pendingDecorators;b!==null&&(e._decorators=b,e._pendingDecorators=null,Lg(`decorator`,e,!0,b)),function(e,t,n){let r=Y_(t),i=Y_(n);r!==i&&Lg(`textcontent`,e,!0,i)}(e,t||a,n),Lg(`update`,e,!0,{dirtyElements:g,dirtyLeaves:h,editorState:n,mutatedNodes:m,normalizedNodes:_,prevEditorState:t||a,tags:v}),!f&&zg(e,e._deferred),(function(e){let t=e._updates;if(t.length===0)return void(e._cascadeCount=0);if(function(e){bg.has(e)||(bg.add(e),setTimeout(()=>{bg.delete(e),e._cascadeCount=0},0))}(e),e._cascadeCount++>99)return e._updates=[],e._cascadeCount=0,void e._onWarn(/* @__PURE__ */ Error(`One or more update listeners are endlessly enqueueing more updates. May have encountered infinite recursion caused by update listeners that trigger additional updates without a stop condition. Editor namespace: ${e._config.namespace}`));let n=t.shift();if(n){let[t,r]=n;Vg(e,t,r)}})(e)})(e,t)}finally{yg=n}}function Lg(e,t,n,...r){let i=t._updating;t._updating=n;try{let n=t._listeners[e],i=Array.from(n);for(let[e,t]of i){t&&t();let i=e(...r);n.has(e)?n.set(e,i):i&&i()}}finally{t._updating=i}}function Rg(e,t,n,r){let i=tv(e),a;if(!yg)for(let e=0;e<i.length;e++)i[e]._updating||(i[e]._cascadeCount=0);for(let e=4;e>=0;e--)for(let o=0;o<i.length;o++){let s=i[o];if(o>0&&s._updating){a=s;break}let c=s._commands.get(t);if(c!==void 0){let t=c[e];if(t.size>0){let e=!1;if(Hg(s,()=>{for(let i of t)if(i(n,r))return void(e=!0)}),e)return e}}}return a&&a.update(()=>{Rg(a,t,n,r)}),!1}function zg(e,t){if(e._deferred=[],t.length!==0){let n=e._updating;e._updating=!0;try{for(let e=0;e<t.length;e++)t[e]()}finally{e._updating=n}}}function Bg(e,t){let n=e._updates,r=t||!1;for(;n.length!==0;){let t=n.shift();if(t){let[n,i]=t,a=e._pendingEditorState,o;i!==void 0&&(o=i.onUpdate,i.skipTransforms&&(r=!0),i.discrete&&(a===null&&F(191),a._flushSync=!0),o&&e._deferred.push(o),Ng(e,i.tag)),a==null?Vg(e,n,i):n()}}return r}function Vg(e,t,n){let r=e._updateTags,i,a=!1,o=!1;n!==void 0&&(i=n.onUpdate,Ng(e,n.tag),a=n.skipTransforms||!1,o=n.discrete||!1),i&&e._deferred.push(i);let s=e._editorState,c=e._pendingEditorState,l=!1;(c===null||c._readOnly)&&(c=e._pendingEditorState=Yg(c||s),l=!0),c._flushSync=o;let u=hg,d=_g,f=gg,p=e._updating;hg=c,_g=!1,e._updating=!0,gg=e;let m=e._headless||e.getRootElement()===null;x_(null);try{l&&(m?s._selection!==null&&(c._selection=s._selection.clone()):c._selection=function(e,t){let n=e.getEditorState()._selection,r=Iv(Tv(e));return B(n)||n==null?Qh(n,r,e,t):n.clone()}(e,n&&n.event||null));let r=e._compositionKey;t(),a=Bg(e,a),function(e,t){let n=t.getEditorState()._selection,r=e._selection;if(B(r)){let e=r.anchor,t=r.focus,i;if(e.type===`text`&&(i=e.getNode(),i.selectionTransform(n,r)),t.type===`text`){let e=t.getNode();i!==e&&e.selectionTransform(n,r)}}}(c,e),e._dirtyType!==0&&(a?function(e,t){let n=t._dirtyLeaves,r=e._nodeMap;for(let e of n){let t=r.get(e);z(t)&&t.isAttached()&&t.isSimpleText()&&!t.isUnmergeable()&&wf(t)}}(c,e):function(e,t){let n=t._dirtyLeaves,r=t._dirtyElements,i=e._nodeMap,a=H_(),o=/* @__PURE__ */ new Map,s=n,c=s.size,l=r,u=l.size;for(;c>0||u>0;){if(c>0){t._dirtyLeaves=/* @__PURE__ */ new Set;for(let e of s){let r=i.get(e);z(r)&&r.isAttached()&&r.isSimpleText()&&!r.isUnmergeable()&&wf(r),r!==void 0&&Mg(r,a)&&jg(t,r,o),n.add(e)}if(s=t._dirtyLeaves,c=s.size,c>0){xg++;continue}}t._dirtyLeaves=/* @__PURE__ */ new Set,t._dirtyElements=/* @__PURE__ */ new Map,l.delete(`root`)&&l.set(`root`,!0);for(let e of l){let n=e[0],s=e[1];if(r.set(n,s),!s)continue;let c=i.get(n);c!==void 0&&Mg(c,a)&&jg(t,c,o)}s=t._dirtyLeaves,c=s.size,l=t._dirtyElements,u=l.size,xg++}t._dirtyLeaves=n,t._dirtyElements=r}(c,e),Bg(e),function(e,t,n,r){let i=e._nodeMap,a=t._nodeMap,o=[];for(let[e]of r){let t=a.get(e);t!==void 0&&(t.isAttached()||(U(t)&&Qd(t,e,i,a,o,r),i.has(e)||r.delete(e),o.push(e)))}for(let e of n){let t=a.get(e);t===void 0||t.isAttached()||(Ny(t)&&t.__slots!==null&&Qd(t,e,i,a,o,n),i.has(e)||n.delete(e),o.push(e))}for(let e of o)a.delete(e);let s=H(),c=s._compositionKey;c===null||a.has(c)||(s._compositionKey=null)}(s,c,e._dirtyLeaves,e._dirtyElements)),r!==e._compositionKey&&(c._flushSync=!0);let i=c._selection;if(B(i)){e._slotsUsed&&Kh(i);let t=c._nodeMap,n=i.anchor.key,r=i.focus.key;t.get(n)!==void 0&&t.get(r)!==void 0||F(19)}else Ah(i)&&i._nodes.size===0&&(c._selection=null)}catch(t){t instanceof Error&&e._onError(t),e._pendingEditorState=s,e._dirtyType=2,e._cloneNotNeeded.clear(),e._dirtyLeaves=/* @__PURE__ */ new Set,e._dirtyElements.clear(),Ig(e);return}finally{hg=u,_g=d,gg=f,e._updating=p,xg=0}e._dirtyType!==0||e._deferred.length>0||function(e,t){let n=t.getEditorState()._selection,r=e._selection;if(r!==null){if(r.dirty||!r.is(n))return!0}else if(n!==null)return!0;return!1}(c,e)?c._flushSync?(c._flushSync=!1,Ig(e)):l&&E_(()=>{Ig(e)}):(c._flushSync=!1,l&&(r.clear(),e._deferred=[],e._pendingEditorState=null))}function Hg(e,t,n){gg===e&&n===void 0?Cg()?Vg(e,t,n):t():Vg(e,t,n)}function Ug(e){if(kv(e)){let t=null;for(let n of e.getChildren())t=n.isInline()?(t||n.replace(n.createParentElementNode())).append(n):null}}var Wg=class extends Wm{__first;__last;__size;__format;__style;__indent;__dir;__textFormat;__textStyle;__slotHost;__slots;$config(){return this.config(Symbol.for(`ElementNode`),{$transform:Ug,extends:Wm})}constructor(e){super(e),this.__first=null,this.__last=null,this.__size=0,this.__format=0,this.__style=``,this.__indent=0,this.__dir=null,this.__textFormat=0,this.__textStyle=``,this.__slotHost=null,this.__slots=null}afterCloneFrom(e){super.afterCloneFrom(e),this.__key===e.__key&&(this.__first=e.__first,this.__last=e.__last,this.__size=e.__size,this.__slotHost=e.__slotHost,this.__slotHost!==null&&this.__parent!==null&&F(384,this.__key,String(this.__slotHost),String(this.__parent)),this.__slots=e.__slots),this.__indent=e.__indent,this.__format=e.__format,this.__style=e.__style,this.__dir=e.__dir,this.__textFormat=e.__textFormat,this.__textStyle=e.__textStyle}getFormat(){return this.getLatest().__format}getFormatType(){let e=this.getFormat();return Ld[e]||``}getStyle(){return this.getLatest().__style}getIndent(){return this.getLatest().__indent}getChildren(){let e=[],t=this.getFirstChild();for(;t!==null;)e.push(t),t=t.getNextSibling();return e}getChildrenKeys(){let e=[],t=this.getFirstChild();for(;t!==null;)e.push(t.__key),t=t.getNextSibling();return e}getChildrenSize(){return this.getLatest().__size}isEmpty(){return this.getChildrenSize()===0&&By(this).length===0}isDirty(){let e=H()._dirtyElements;return e!==null&&e.has(this.__key)}isLastChild(){let e=this.getLatest(),t=this.getParentOrThrow().getLastChild();return t!==null&&t.is(e)}getAllTextNodes(){let e=[];for(let t of By(this)){let n=Vy(this,t);U(n)&&e.push(...n.getAllTextNodes())}let t=this.getFirstChild();for(;t!==null;){if(z(t)&&e.push(t),U(t)){let n=t.getAllTextNodes();e.push(...n)}t=t.getNextSibling()}return e}getFirstDescendant(){let e=this.getFirstChild();for(;U(e);){let t=e.getFirstChild();if(t===null)break;e=t}return e}getLastDescendant(){let e=this.getLastChild();for(;U(e);){let t=e.getLastChild();if(t===null)break;e=t}return e}getDescendantByIndex(e){let t=this.getChildren(),n=t.length;if(e>=n){let e=t[n-1];return U(e)&&e.getLastDescendant()||e||null}let r=t[e];return U(r)&&r.getFirstDescendant()||r||null}getFirstChild(){let e=this.getLatest().__first;return e===null?null:U_(e)}getFirstChildOrThrow(){let e=this.getFirstChild();return e===null&&F(45,this.__key),e}getLastChild(){let e=this.getLatest().__last;return e===null?null:U_(e)}getLastChildOrThrow(){let e=this.getLastChild();return e===null&&F(96,this.__key),e}getChildAtIndex(e){let t=this.getChildrenSize(),n,r;if(e<t/2){for(n=this.getFirstChild(),r=0;n!==null&&r<=e;){if(r===e)return n;n=n.getNextSibling(),r++}return null}for(n=this.getLastChild(),r=t-1;n!==null&&r>=e;){if(r===e)return n;n=n.getPreviousSibling(),r--}return null}getTextContent(){let e=Jy(this),t=this.getChildren(),n=t.length;for(let r=0;r<n;r++){let i=t[r];e+=i.getTextContent(),U(i)&&r!==n-1&&!i.isInline()&&(e+=`
142
+ `?t.linebreak():n===` `?t.tab():n!==``&&t.text(n)}function _g(e){let t=[];return gg(e,{linebreak:()=>t.push(f_()),tab:()=>t.push(Oh()),text:e=>t.push(Th(e))}),t}function vg(e){let t=[];for(let n of e)p_(n)||(!U(n)&&!W(n)||n.isInline()?t.push(n):U(n)&&t.push(...vg(n.getChildren())));return t}function yg(e){let t=e;e.isCollapsed()||t.removeText();let n=V();B(n)&&(t=n),B(t)||F(161);let r=t.anchor,i=r.getNode(),a=r.offset;for(;!my(i)&&Wy(i)===null;){let e=i;if([i,a]=bg(i,a),e.is(i))break}return a}function bg(e,t){let n=e.getParent();if(!n){let e=y_();return av().append(e),e.select(),[av(),0]}if(z(e)){let r=e.splitText(t);if(r.length===0)return[n,e.getIndexWithinParent()];let i=t===0?0:1;return[n,r[0].getIndexWithinParent()+i]}if(!U(e)||t===0)return[n,e.getIndexWithinParent()];let r=e.getChildAtIndex(t);if(r){let n=new Rh(jh(e.__key,t,`element`),jh(e.__key,t,`element`),0,``),i=e.insertNewAfter(n);i&&i.append(r,...r.getNextSiblings())}return[n,e.getIndexWithinParent()+1]}function xg(e){return p_(e)||Fv(e)||z(e)||e.isParentRequired()}function Sg(e){let t=y_(),n=null;for(let r=0;r<e.length;r++){let i=e[r];if(xg(i)){if(n===null){n=i.createParentElementNode(),t.append(n);let a=e[r+1];if(p_(i)&&(a===void 0||!xg(a)))continue}n.append(i)}else t.append(i),n=null}return t}function Cg(e,t,n,r,i=`decorators-and-blocks`){if(t===`move`&&r===`character`&&!e.isCollapsed()){let[t,r]=n===e.isBackward()?[e.focus,e.anchor]:[e.anchor,e.focus];return r.set(t.key,t.offset,t.type),!0}let a=Vb(e.focus,n?`previous`:`next`),o=r===`lineboundary`,s=t===`move`,c=a,l=i===`decorators-and-blocks`;if(!Zb(c)){for(let e of c){l=!1;let{origin:t}=e;if(!W(t)||t.isIsolated()||(c=e,!o||!t.isInline()))break}if(l)for(let e of Mb(a).iterNodeCarets(t===`extend`?`shadowRoot`:`root`)){if(yb(e))e.origin.isInline()||(c=e);else{if(U(e.origin))continue;W(e.origin)&&!e.origin.isInline()&&(c=e)}break}}if(c===a)return!1;if(s&&!o&&W(c.origin)&&c.origin.isKeyboardSelectable()){let e=og();return e.add(c.origin.getKey()),ov(e),!0}return c=Xb(c),s&&Hb(e.anchor,c),Hb(e.focus,c),l||!o}let wg=null,Tg=null,Eg=!1,Dg=!1,Og=!1,kg=/* @__PURE__ */ new Set,Ag=0,jg={characterData:!0,childList:!0,subtree:!0};function Mg(){return Eg||wg!==null&&wg._readOnly}function Ng(){Eg&&F(13)}function Pg(){Ag>99&&F(14)}function Fg(){return wg===null&&F(195,Rg()),wg}function Ig(e){Fg()!==null&&Tg===null&&(Tg=e),Tg!==e&&Dd(378)}function H(){return Tg===null&&F(337,Rg()),Tg}function Lg(){H()._dirtyType=2}function Rg(){let e=0,t=/* @__PURE__ */ new Set,n=O_.version;if(typeof window<`u`)for(let r of Xv(document)){let i=B_(r);if(R_(i))e++;else if(i){let e=String(i.constructor.version||`<0.17.1`);e===n&&(e+=` (separately built, likely a bundler configuration issue)`),t.add(e)}}let r=` Detected on the page: ${e} compatible editor(s) with version ${n}`;return t.size&&(r+=` and incompatible editors with versions ${Array.from(t).join(`, `)}`),r}function zg(){return Tg}function Bg(e,t,n){let r=t.__type,i=N_(e,r),a=n.get(r);a===void 0&&(a=Array.from(i.transforms),n.set(r,a));let o=a.length;for(let e=0;e<o&&(a[e](t),t.isAttached());e++);}function Vg(e,t){return e!==void 0&&e.__key!==t&&e.isAttached()}function Hg(e,t){if(!t)return;let n=e._updateTags,r=t;Array.isArray(t)||(r=[t]);for(let e of r)n.add(e)}function Ug(e,t){let n=e.type,r=t.get(n);r===void 0&&F(17,n);let i=r.klass;e.type!==i.getType()&&F(18,i.name);let a=i.importJSON(e),o=e.children;if(U(a)&&Array.isArray(o))for(let e=0;e<o.length;e++){let n=Ug(o[e],t);a.append(n)}let s=e.$slots;if(s){Hy(a)||F(379,i.name);for(let e in s)ob(a,e,Ug(s[e],t))}return a}function Wg(e,t,n){let r=wg,i=Eg,a=Tg;wg=t,Eg=!0,Tg=e;try{return n()}finally{wg=r,Eg=i,Tg=a}}function Gg(e,t){let n=Og;Og=!0;try{(function(e,t){let n=e._pendingEditorState,r=e._rootElement,i=e._headless||r===null;if(n===null)return void(!e._updating&&e._deferred.length>0&&Jg(e,e._deferred));let a=e._editorState,o=a._selection,s=n._selection,c=e._dirtyType!==0,l=wg,u=Eg,d=Tg,f=e._updating,p=e._observer,m=null;if(e._pendingEditorState=null,e._editorState=n,!i&&c&&p!==null){Tg=e,wg=n,Eg=!1,e._updating=!0;try{let t=e._dirtyType,r=e._dirtyElements,i=e._dirtyLeaves;p.disconnect(),m=Dp(a,n,e,t,r,i)}catch(t){if(t instanceof Error&&e._onError(t),Dg)throw t;S_(e,null,r,n),vf(e),e._dirtyType=2,Dg=!0,Gg(e,a),Dg=!1;return}finally{p.observe(r,jg),e._updating=f,wg=l,Eg=u,Tg=d}}n._readOnly||=!0;let h=e._dirtyLeaves,g=e._dirtyElements,_=e._normalizedNodes,v=e._updateTags;c&&(e._dirtyType=0,e._cloneNotNeeded.clear(),e._dirtyLeaves=/* @__PURE__ */ new Set,e._dirtyElements=/* @__PURE__ */ new Map,e._normalizedNodes=/* @__PURE__ */ new Set),e._updateTags=/* @__PURE__ */ new Set,function(e,t){let n=e._decorators,r=e._pendingDecorators||n,i=t._nodeMap,a;for(a in r)i.has(a)||(r===n&&(r=rv(e)),delete r[a])}(e,n);let y=i?null:Gv(Pv(e));if(e._editable&&y!==null&&(c||s===null||s.dirty||!s.is(o))&&r!==null&&!v.has(`skip-dom-selection`)){Tg=e,wg=n;try{if(p!==null&&p.disconnect(),c||s===null||s.dirty){let t=e._blockCursorElement;t!==null&&Wv(t,e,r),hg(o,s,e,y,v,r)}(function(e,t,n){let r=e._blockCursorElement;if(B(n)&&n.isCollapsed()&&n.anchor.type===`element`&&t.contains(ay(t))){let i=n.anchor,a=i.getNode(),o=i.offset,s=!1,c=null;if(o===a.getChildrenSize())Uv(a.getChildAtIndex(o-1))&&(s=!0);else{let t=a.getChildAtIndex(o);if(t!==null&&Uv(t)){let n=t.getPreviousSibling();(n===null||Uv(n))&&(s=!0,c=e.getElementByKey(t.__key))}}if(s){let n=_y(a,e.getElementByKey(a.__key),e).element;r===null&&(e._blockCursorElement=r=function(e){let t=e.theme,n=Qv().createElement(`div`);n.contentEditable=`false`,n.setAttribute(`data-lexical-cursor`,`true`);let r=t.blockCursor;return r!==void 0&&(typeof r==`string`&&(r=t.blockCursor=cx(r)),r!==void 0&&n.classList.add(...r)),n}(e._config)),t.style.caretColor=`transparent`,c===null?n.appendChild(r):n.insertBefore(r,c);return}}r!==null&&Wv(r,e,t)})(e,r,s)}finally{p!==null&&p.observe(r,jg),Tg=d,wg=l}}m!==null&&function(e,t,n,r,i){let a=Array.from(e._listeners.mutation),o=a.length;for(let e=0;e<o;e++){let[o,s]=a[e];for(let e of s){let a=t.get(e);a!==void 0&&o(a,{dirtyLeaves:r,prevEditorState:i,updateTags:n})}}}(e,m,v,h,a),B(s)||s===null||o!==null&&o.is(s)||e.dispatchCommand(kp);let b=e._pendingDecorators;b!==null&&(e._decorators=b,e._pendingDecorators=null,Kg(`decorator`,e,!0,b)),function(e,t,n){let r=iv(t),i=iv(n);r!==i&&Kg(`textcontent`,e,!0,i)}(e,t||a,n),Kg(`update`,e,!0,{dirtyElements:g,dirtyLeaves:h,editorState:n,mutatedNodes:m,normalizedNodes:_,prevEditorState:t||a,tags:v}),!f&&Jg(e,e._deferred),(function(e){let t=e._updates;if(t.length===0)return void(e._cascadeCount=0);if(function(e){kg.has(e)||(kg.add(e),setTimeout(()=>{kg.delete(e),e._cascadeCount=0},0))}(e),e._cascadeCount++>99)return e._updates=[],e._cascadeCount=0,void e._onWarn(/* @__PURE__ */ Error(`One or more update listeners are endlessly enqueueing more updates. May have encountered infinite recursion caused by update listeners that trigger additional updates without a stop condition. Editor namespace: ${e._config.namespace}`));let n=t.shift();if(n){let[t,r]=n;Xg(e,t,r)}})(e)})(e,t)}finally{Og=n}}function Kg(e,t,n,...r){let i=t._updating;t._updating=n;try{let n=t._listeners[e],i=Array.from(n);for(let[e,t]of i){t&&t();let i=e(...r);n.has(e)?n.set(e,i):i&&i()}}finally{t._updating=i}}function qg(e,t,n,r){let i=uv(e),a;if(!Og)for(let e=0;e<i.length;e++)i[e]._updating||(i[e]._cascadeCount=0);for(let e=4;e>=0;e--)for(let o=0;o<i.length;o++){let s=i[o];if(o>0&&s._updating){a=s;break}let c=s._commands.get(t);if(c!==void 0){let t=c[e];if(t.size>0){let e=!1;if(Zg(s,()=>{for(let i of t)if(i(n,r))return void(e=!0)}),e)return e}}}return a&&a.update(()=>{qg(a,t,n,r)}),!1}function Jg(e,t){if(e._deferred=[],t.length!==0){let n=e._updating;e._updating=!0;try{for(let e=0;e<t.length;e++)t[e]()}finally{e._updating=n}}}function Yg(e,t){let n=e._updates,r=t||!1;for(;n.length!==0;){let t=n.shift();if(t){let[n,i]=t,a=e._pendingEditorState,o;i!==void 0&&(o=i.onUpdate,i.skipTransforms&&(r=!0),i.discrete&&(a===null&&F(191),a._flushSync=!0),o&&e._deferred.push(o),Hg(e,i.tag)),a==null?Xg(e,n,i):n()}}return r}function Xg(e,t,n){let r=e._updateTags,i,a=!1,o=!1;n!==void 0&&(i=n.onUpdate,Hg(e,n.tag),a=n.skipTransforms||!1,o=n.discrete||!1),i&&e._deferred.push(i);let s=e._editorState,c=e._pendingEditorState,l=!1;(c===null||c._readOnly)&&(c=e._pendingEditorState=i_(c||s),l=!0),c._flushSync=o;let u=wg,d=Eg,f=Tg,p=e._updating;wg=c,Eg=!1,e._updating=!0,Tg=e;let m=e._headless||e.getRootElement()===null;A_(null);try{l&&(m?s._selection!==null&&(c._selection=s._selection.clone()):c._selection=function(e,t){let n=e.getEditorState()._selection,r=Gv(Pv(e));return B(n)||n==null?sg(n,r,e,t):n.clone()}(e,n&&n.event||null));let r=e._compositionKey;t(),a=Yg(e,a),function(e,t){let n=t.getEditorState()._selection,r=e._selection;if(B(r)){let e=r.anchor,t=r.focus,i;if(e.type===`text`&&(i=e.getNode(),i.selectionTransform(n,r)),t.type===`text`){let e=t.getNode();i!==e&&e.selectionTransform(n,r)}}}(c,e),e._dirtyType!==0&&(a?function(e,t){let n=t._dirtyLeaves,r=e._nodeMap;for(let e of n){let t=r.get(e);z(t)&&t.isAttached()&&t.isSimpleText()&&!t.isUnmergeable()&&Nf(t)}}(c,e):function(e,t){let n=t._dirtyLeaves,r=t._dirtyElements,i=e._nodeMap,a=Z_(),o=/* @__PURE__ */ new Map,s=n,c=s.size,l=r,u=l.size;for(;c>0||u>0;){if(c>0){t._dirtyLeaves=/* @__PURE__ */ new Set;for(let e of s){let r=i.get(e);z(r)&&r.isAttached()&&r.isSimpleText()&&!r.isUnmergeable()&&Nf(r),r!==void 0&&Vg(r,a)&&Bg(t,r,o),n.add(e)}if(s=t._dirtyLeaves,c=s.size,c>0){Ag++;continue}}t._dirtyLeaves=/* @__PURE__ */ new Set,t._dirtyElements=/* @__PURE__ */ new Map,l.delete(`root`)&&l.set(`root`,!0);for(let e of l){let n=e[0],s=e[1];if(r.set(n,s),!s)continue;let c=i.get(n);c!==void 0&&Vg(c,a)&&Bg(t,c,o)}s=t._dirtyLeaves,c=s.size,l=t._dirtyElements,u=l.size,Ag++}t._dirtyLeaves=n,t._dirtyElements=r}(c,e),Yg(e),function(e,t,n,r){let i=e._nodeMap,a=t._nodeMap,o=[];for(let[e]of r){let t=a.get(e);t!==void 0&&(t.isAttached()||(U(t)&&cf(t,e,i,a,o,r),i.has(e)||r.delete(e),o.push(e)))}for(let e of n){let t=a.get(e);t===void 0||t.isAttached()||(Hy(t)&&t.__slots!==null&&cf(t,e,i,a,o,n),i.has(e)||n.delete(e),o.push(e))}for(let e of o)a.delete(e);let s=H(),c=s._compositionKey;c===null||a.has(c)||(s._compositionKey=null)}(s,c,e._dirtyLeaves,e._dirtyElements)),r!==e._compositionKey&&(c._flushSync=!0);let i=c._selection;if(B(i)){e._slotsUsed&&tg(i);let t=c._nodeMap,n=i.anchor.key,r=i.focus.key;t.get(n)!==void 0&&t.get(r)!==void 0||F(19)}else zh(i)&&i._nodes.size===0&&(c._selection=null)}catch(t){t instanceof Error&&e._onError(t),e._pendingEditorState=s,e._dirtyType=2,e._cloneNotNeeded.clear(),e._dirtyLeaves=/* @__PURE__ */ new Set,e._dirtyElements.clear(),Gg(e);return}finally{wg=u,Eg=d,Tg=f,e._updating=p,Ag=0}e._dirtyType!==0||e._deferred.length>0||function(e,t){let n=t.getEditorState()._selection,r=e._selection;if(r!==null){if(r.dirty||!r.is(n))return!0}else if(n!==null)return!0;return!1}(c,e)?c._flushSync?(c._flushSync=!1,Gg(e)):l&&F_(()=>{Gg(e)}):(c._flushSync=!1,l&&(r.clear(),e._deferred=[],e._pendingEditorState=null))}function Zg(e,t,n){Tg===e&&n===void 0?Mg()?Xg(e,t,n):t():Xg(e,t,n)}function Qg(e){if(Rv(e)){let t=null;for(let n of e.getChildren())t=n.isInline()?(t||n.replace(n.createParentElementNode())).append(n):null}}var $g=class extends $m{__first;__last;__size;__format;__style;__indent;__dir;__textFormat;__textStyle;__slotHost;__slots;$config(){return this.config(Symbol.for(`ElementNode`),{$transform:Qg,extends:$m})}constructor(e){super(e),this.__first=null,this.__last=null,this.__size=0,this.__format=0,this.__style=``,this.__indent=0,this.__dir=null,this.__textFormat=0,this.__textStyle=``,this.__slotHost=null,this.__slots=null}afterCloneFrom(e){super.afterCloneFrom(e),this.__key===e.__key&&(this.__first=e.__first,this.__last=e.__last,this.__size=e.__size,this.__slotHost=e.__slotHost,this.__slotHost!==null&&this.__parent!==null&&F(384,this.__key,String(this.__slotHost),String(this.__parent)),this.__slots=e.__slots),this.__indent=e.__indent,this.__format=e.__format,this.__style=e.__style,this.__dir=e.__dir,this.__textFormat=e.__textFormat,this.__textStyle=e.__textStyle}getFormat(){return this.getLatest().__format}getFormatType(){let e=this.getFormat();return Kd[e]||``}getStyle(){return this.getLatest().__style}getIndent(){return this.getLatest().__indent}getChildren(){let e=[],t=this.getFirstChild();for(;t!==null;)e.push(t),t=t.getNextSibling();return e}getChildrenKeys(){let e=[],t=this.getFirstChild();for(;t!==null;)e.push(t.__key),t=t.getNextSibling();return e}getChildrenSize(){return this.getLatest().__size}isEmpty(){return this.getChildrenSize()===0&&Yy(this).length===0}isDirty(){let e=H()._dirtyElements;return e!==null&&e.has(this.__key)}isLastChild(){let e=this.getLatest(),t=this.getParentOrThrow().getLastChild();return t!==null&&t.is(e)}getAllTextNodes(){let e=[];for(let t of Yy(this)){let n=Xy(this,t);U(n)&&e.push(...n.getAllTextNodes())}let t=this.getFirstChild();for(;t!==null;){if(z(t)&&e.push(t),U(t)){let n=t.getAllTextNodes();e.push(...n)}t=t.getNextSibling()}return e}getFirstDescendant(){let e=this.getFirstChild();for(;U(e);){let t=e.getFirstChild();if(t===null)break;e=t}return e}getLastDescendant(){let e=this.getLastChild();for(;U(e);){let t=e.getLastChild();if(t===null)break;e=t}return e}getDescendantByIndex(e){let t=this.getChildren(),n=t.length;if(e>=n){let e=t[n-1];return U(e)&&e.getLastDescendant()||e||null}let r=t[e];return U(r)&&r.getFirstDescendant()||r||null}getFirstChild(){let e=this.getLatest().__first;return e===null?null:Q_(e)}getFirstChildOrThrow(){let e=this.getFirstChild();return e===null&&F(45,this.__key),e}getLastChild(){let e=this.getLatest().__last;return e===null?null:Q_(e)}getLastChildOrThrow(){let e=this.getLastChild();return e===null&&F(96,this.__key),e}getChildAtIndex(e){let t=this.getChildrenSize(),n,r;if(e<t/2){for(n=this.getFirstChild(),r=0;n!==null&&r<=e;){if(r===e)return n;n=n.getNextSibling(),r++}return null}for(n=this.getLastChild(),r=t-1;n!==null&&r>=e;){if(r===e)return n;n=n.getPreviousSibling(),r--}return null}getTextContent(){let e=rb(this),t=this.getChildren(),n=t.length;for(let r=0;r<n;r++){let i=t[r];e+=i.getTextContent(),U(i)&&r!==n-1&&!i.isInline()&&(e+=`
143
143
 
144
- `)}return e}getTextContentSize(){let e=function(e){let t=0;for(let n of By(e)){let r=Vy(e,n);r!==null&&(t+=r.getTextContentSize())}return t}(this),t=this.getChildren(),n=t.length;for(let r=0;r<n;r++){let i=t[r];e+=i.getTextContentSize(),U(i)&&r!==n-1&&!i.isInline()&&(e+=2)}return e}getDirection(){return this.getLatest().__dir}getTextFormat(){return this.getLatest().__textFormat}hasFormat(e){if(e!==``){let t=Id[e];return(this.getFormat()&t)!==0}return!1}hasTextFormat(e){let t=Pd[e];return(this.getTextFormat()&t)!==0}getFormatFlags(e,t){return L_(this.getLatest().__textFormat,e,t)}getTextStyle(){return this.getLatest().__textStyle}select(e,t){wg();let n=V(),r=e,i=t,a=this.getChildrenSize();if(!this.canBeEmpty()){if(e===0&&t===0){let e=this.getFirstChild();if(z(e)||U(e))return e.select(0,0)}else if(!(e!==void 0&&e!==a||t!==void 0&&t!==a)){let e=this.getLastChild();if(z(e)||U(e))return e.select()}}r===void 0&&(r=a),i===void 0&&(i=a);let o=this.__key;return B(n)?(n.anchor.set(o,r,`element`),n.focus.set(o,i,`element`),n.dirty=!0,n):Yh(o,r,o,i,`element`,`element`)}selectStart(){let e=this.getFirstDescendant();return e?e.selectStart():this.select()}selectEnd(){let e=this.getLastDescendant();return e?e.selectEnd():this.select()}clear(){let e=this.getWritable();return this.getChildren().forEach(e=>e.remove()),e}append(...e){return this.splice(this.getChildrenSize(),0,e)}setDirection(e){let t=this.getWritable();return t.__dir=e,t}setFormat(e){return this.getWritable().__format=e!==``&&Id[e]||0,this}setStyle(e){return this.getWritable().__style=e||``,this}setTextFormat(e){let t=this.getWritable();return t.__textFormat=e,t}setTextStyle(e){let t=this.getWritable();return t.__textStyle=e,t}setIndent(e){return this.getWritable().__indent=e,this}splice(e,t,n){Hm(this)&&F(324,this.__key,this.__type);let r=this.getChildrenSize(),i=this.getWritable();e+t<=r||F(226,String(e),String(t),String(r));for(let e of n);let a=i.__key,o=[],s=[],c=this.getChildAtIndex(e+t),l=null,u=r-t+n.length;if(e!==0){if(e===r)l=this.getLastChild();else{let t=this.getChildAtIndex(e);t!==null&&(l=t.getPreviousSibling())}}if(t>0){let e=l===null?this.getFirstChild():l.getNextSibling();for(let n=0;n<t;n++){e===null&&F(100);let t=e.getNextSibling(),n=e.__key;z_(e.getWritable()),s.push(n),e=t}}let d=l;for(let e of n){d!==null&&e.is(d)&&(l=d=d.getPreviousSibling());let t=e.getWritable();t.__parent===a&&u--,z_(t);let n=e.__key;if(d===null)i.__first=n,t.__prev=null;else{let e=d.getWritable();e.__next=n,t.__prev=e.__key}e.__key===a&&F(76),t.__parent=a,o.push(n),d=e}if(e+t===r)d!==null&&(d.getWritable().__next=null,i.__last=d.__key);else if(c!==null){let e=c.getWritable();if(d!==null){let t=d.getWritable();e.__prev=d.__key,t.__next=c.__key}else e.__prev=null}if(i.__size=u,s.length){let e=V();if(B(e)){let t=new Set(s),n=new Set(o),{anchor:r,focus:i}=e;Gg(r,t,n)&&ng(r,r.getNode(),this,l,c),Gg(i,t,n)&&ng(i,i.getNode(),this,l,c),u!==0||this.canBeEmpty()||kv(this)||this.remove()}}return i}getDOMSlot(e){return new Gd(e)}exportDOM(e){let{element:t}=super.exportDOM(e);if(q(t)){let e=this.getIndent();e>0&&(t.style.paddingInlineStart=40*e+`px`,t.setAttribute(`data-lexical-indent`,String(e)));let n=this.getDirection();n&&(t.dir=n)}return{element:t}}exportJSON(){let e={children:[],direction:this.getDirection(),format:this.getFormatType(),indent:this.getIndent(),...super.exportJSON()},t=this.getTextFormat(),n=this.getTextStyle();return t===0&&n===``||kv(this)||this.getChildren().some(z)||(t!==0&&(e.textFormat=t),n!==``&&(e.textStyle=n)),e}updateFromJSON(e){return super.updateFromJSON(e).setFormat(e.format).setIndent(e.indent).setDirection(e.direction).setTextFormat(e.textFormat||0).setTextStyle(e.textStyle||``)}insertNewAfter(e,t){return null}canIndent(){return!0}collapseAtStart(e){return!1}excludeFromCopy(e){return!1}canReplaceWith(e){return!0}canInsertAfter(e){return!0}canBeEmpty(){return!0}canInsertTextBefore(){return!0}canInsertTextAfter(){return!0}isInline(){return!1}isShadowRoot(){return!1}canMergeWith(e){return!1}extractWithChild(e,t,n){return!1}canMergeWhenEmpty(){return!1}reconcileObservedMutation(e,t){let n=cy(this,e,t),r=n.getFirstChild();for(let e=this.getFirstChild();e;e=e.getNextSibling()){let i=t.getElementByKey(e.getKey());i!==null&&(r==null?(n.insertChild(i),r=i):r!==i&&n.replaceChild(i,r),r=r.nextSibling)}}};function U(e){return e instanceof Wg}function Gg(e,t,n){let r=e.getNode();for(;r;){let e=r.__key;if(t.has(e)&&!n.has(e))return!0;r=r.getParent()}return!1}var Kg=class extends Wm{__slotHost;__slots;constructor(e){super(e),this.__slotHost=null,this.__slots=null}afterCloneFrom(e){super.afterCloneFrom(e),this.__key===e.__key&&(this.__slotHost=e.__slotHost,this.__slotHost!==null&&this.__parent!==null&&F(383,this.__key,String(this.__slotHost),String(this.__parent)),this.__slots=e.__slots)}decorate(e,t){return null}isIsolated(){return!1}isInline(){return!0}isKeyboardSelectable(){return!0}};function W(e){return e instanceof Kg}var qg=class extends Wg{__cachedText;$config(){return this.config(`root`,{extends:Wg})}constructor(){super(`root`),this.__cachedText=null}getTopLevelElementOrThrow(){F(51)}getTextContent(){let e=this.__cachedText;return e===null||!Cg()&&H()._dirtyType!==0?super.getTextContent():e}remove(){F(52)}replace(e){F(53)}insertBefore(e){F(54)}insertAfter(e){F(55)}updateDOM(e,t){return!1}splice(e,t,n){for(let e of n)U(e)||W(e)||F(282);return super.splice(e,t,n)}static importJSON(e){return X_().updateFromJSON(e)}collapseAtStart(){return!0}};function Jg(e){return e instanceof qg}function Yg(e){return new $g(Xd(e._nodeMap),null,e._slotsUsed)}function Xg(){return new $g(/* @__PURE__ */ new Map([[`root`,new qg]]),null,!1)}function Zg(e){let t=e.exportJSON(),n=e.constructor;if(t.type!==n.getType()&&F(130,n.name),U(e)){let r=t.children;Array.isArray(r)||F(59,n.name);let i=e.getChildren();for(let e=0;e<i.length;e++){let t=Zg(i[e]);r.push(t)}}let r=By(e);if(r.length>0){let i={};for(let t of r){let r=Vy(e,t);r===null&&F(366,n.name,t),i[t]=Zg(r)}t.$slots=i}return t}function Qg(e){return e instanceof $g}var $g=class e{_nodeMap;_selection;_flushSync;_readOnly;_parsed;_slotsUsed;constructor(e,t=null,n=!1){this._nodeMap=e,this._selection=t||null,this._flushSync=!1,this._readOnly=!1,this._parsed=!1,this._slotsUsed=n}isEmpty(){return this._nodeMap.size===1&&this._selection===null}read(e,t){return Fg(t&&t.editor||null,this,e)}clone(t){let n=new e(this._nodeMap,t===void 0?this._selection:t,this._slotsUsed);return n._readOnly=!0,n}toJSON(){return Fg(null,this,()=>({root:Zg(X_())}))}},e_=class extends Wg{$config(){return this.config(`artificial`,{extends:Wg})}createDOM(e){return Uv().createElement(`div`)}},t_=class extends Wm{$config(){return this.config(`linebreak`,{importDOM:{br:e=>a_(e)||o_(e)?null:{conversion:n_,priority:0}}})}getTextContent(){return`
145
- `}createDOM(){return Uv().createElement(`br`)}updateDOM(){return!1}isInline(){return!0}};function n_(e){return{node:r_()}}function r_(){return jv(new t_)}function i_(e){return e instanceof t_}function a_(e){let t=e.parentElement;if(t!==null&&iy(t)){let n=t.firstChild;if(n===e||n.nextSibling===e&&s_(n)){let n=t.lastChild;if(n===e||n.previousSibling===e&&s_(n))return!0}}return!1}function o_(e){let t=e.parentElement;if(t!==null&&iy(t)){let n=t.firstChild;if(n===e||n.nextSibling===e&&s_(n))return!1;let r=t.lastChild;if(r===e||r.previousSibling===e&&s_(r))return!0}return!1}function s_(e){return P_(e)&&/^( |\t|\r?\n)+$/.test(e.textContent||``)}var c_=class extends Wg{$config(){return this.config(`paragraph`,{extends:Wg,importDOM:{p:()=>({conversion:l_,priority:0})}})}createDOM(e){let t=Uv().createElement(`p`),n=pv(e.theme,`paragraph`);return n!==void 0&&t.classList.add(...n),t}updateDOM(e,t,n){return!1}exportDOM(e){let{element:t}=super.exportDOM(e);if(q(t)){this.isEmpty()&&t.append(Uv().createElement(`br`));let e=this.getFormatType();e&&(t.style.textAlign=e)}return{element:t}}exportJSON(){let e=super.exportJSON();if(e.textFormat===void 0||e.textStyle===void 0){let t=this.getChildren().find(z);t?(e.textFormat=t.getFormat(),e.textStyle=t.getStyle()):(e.textFormat=this.getTextFormat(),e.textStyle=this.getTextStyle())}return e}insertNewAfter(e,t){let n=u_();n.setTextFormat(e.format),n.setTextStyle(e.style);let r=this.getDirection();return n.setDirection(r),n.setFormat(this.getFormatType()),n.setStyle(this.getStyle()),this.insertAfter(n,t),n}collapseAtStart(){let e=this.getChildren();if(e.length===0||z(e[0])&&e[0].getTextContent().trim()===``){if(this.getNextSibling()!==null)return this.selectNext(),this.remove(),!0;if(this.getPreviousSibling()!==null)return this.selectPrevious(),this.remove(),!0}return!1}};function l_(e){let t=u_();if(vy(t,e),gy(e,t),t.getFormatType()===``){let n=e.getAttribute(`align`);n&&n&&n in Id&&t.setFormat(n)}return _y(t,e),{node:t}}function u_(){return jv(new c_)}function d_(e){return e instanceof c_}function f_(e){console.warn(e)}function p_(e,t,n,r,i){let a=e._keyToDOMMap;a.clear(),e._editorState=Xg(),e._pendingEditorState=r,e._compositionKey=null,e._dirtyType=0,e._cloneNotNeeded.clear(),e._dirtyLeaves=/* @__PURE__ */ new Set,e._dirtyElements.clear(),e._normalizedNodes=/* @__PURE__ */ new Set,i&&i.preserveUpdateQueue||(e._updateTags=/* @__PURE__ */ new Set,e._updates=[],e._cascadeCount=0),e._blockCursorElement=null,e._inputState.handledSelectionCommandTimeoutId!==null&&clearTimeout(e._inputState.handledSelectionCommandTimeoutId),e._inputState={collapsedSelectionFormat:{format:0,key:`root`,offset:0,style:``,timeStamp:0},compositionEndData:``,compositionPhase:`idle`,hadOrphanedCompositionEvents:!1,handledSelectionCommandTimeoutId:null,isInsertLineBreak:!1,isInsertTextAfterHandledSelectionCommand:!1,isSelectionChangeFromDOMUpdate:!1,isSelectionChangeFromMouseDown:!1,lastBeforeInputInsertTextTimeStamp:0,lastKeyCode:null,lastKeyDownTimeStamp:0,postDeleteSelectionToRestore:null,unprocessedBeforeInputData:null};let o=e._observer;o!==null&&(o.disconnect(),e._observer=null),t!==null&&(t.textContent=``,function(e,t){let n=`__lexicalKey_${t._key}`;delete e[n]}(t,e)),n!==null&&(n.textContent=``,a.set(`root`,n),G_(n,e,`root`))}function m_(e){let t=/* @__PURE__ */ new Set,n=/* @__PURE__ */ new Set;for(let{klass:r,ownNodeConfig:i}of Dy(e)){let e=r.transform;if(!n.has(e)){n.add(e);let i=r.transform();i&&t.add(i)}if(i){let e=i.$transform;e&&t.add(e)}}return t}let h_={$createDOM:(e,t)=>e.createDOM(t._config,t),$decorateDOM:(e,t,n,r)=>{},$exportDOM:(e,t)=>{let n=T_(t,e.getType());return n&&n.exportDOM!==void 0?n.exportDOM(t,e):e.exportDOM(t)},$extractWithChild:(e,t,n,r,i)=>U(e)&&e.extractWithChild(t,n,r),$getDOMSlot:(e,t,n)=>e.getDOMSlot(t),$getSlotTargetElement:(e,t,n,r)=>null,$shouldExclude:(e,t,n)=>U(e)&&e.excludeFromCopy(`html`),$shouldInclude:(e,t,n)=>!t||e.isSelected(t),$updateDOM:(e,t,n,r)=>e.updateDOM(t,n,r._config)};function g_(e){let t=e||{},n=Ag(),r=t.theme||{},i=e===void 0?n:t.parentEditor||null,a=t.disableEvents||!1,o=Xg(),s=t.namespace||(i===null?nv():i._config.namespace),c=t.editorState,l=[qg,sh,t_,vh,c_,e_,...t.nodes||[]],{onError:u,onWarn:d,html:f}=t,p=t.editable===void 0||t.editable,m;if(e===void 0&&n!==null)m=n._nodes;else{m=/* @__PURE__ */ new Map;for(let e=0;e<l.length;e++){let n=l[e],r=null,i=null;if(n&&typeof n==`object`){let e=n;n=e.replace,r=e.with,i=e.withKlass||null}if(typeof n!=`function`||!n.prototype||!(n===Wm||n.prototype instanceof Wm)){let r=`<unknown>`;try{r=JSON.parse(Jd)}catch{}F(365,String(e-l.length+(t.nodes?t.nodes.length:0)),typeof n==`function`?`${n.name}${typeof n.getType==`function`?` (type ${String(n.getType())})`:``}`:String(n),String(r))}Ey(n);let a=n.getType(),o=m_(n);m.set(a,{exportDOM:f&&f.export?f.export.get(n):void 0,klass:n,replace:r,replaceWithKlass:i,sharedNodeState:ff(l[e]),transforms:o})}}let h=new y_(o,i,m,{disableEvents:a,dom:{...h_,...e&&e.dom},namespace:s,theme:r},u||console.error,d||f_,function(e,t){let n=/* @__PURE__ */ new Map,r=/* @__PURE__ */ new Set,i=e=>{Object.keys(e).forEach(t=>{let r=n.get(t);r===void 0&&(r=[],n.set(t,r)),r.push(e[t])})};return e.forEach(e=>{let t=e.klass.importDOM;if(t==null||r.has(t))return;r.add(t);let n=t.call(e.klass);n!==null&&i(n)}),t&&i(t),n}(m,f?f.import:void 0),p,e);return c!==void 0&&(h._pendingEditorState=c,h._dirtyType=2),function(e){e.registerCommand(Sp,Dm,0),e.registerCommand(Cp,Om,0),e.registerCommand(wp,km,0),e.registerCommand(Tp,Am,0),e.registerCommand(Lp,Nm,0)}(h),h}function __(e,t){let n=e.get(t);e.delete(t),n&&n()}function v_(e,t,n){return e.set(t,n),__.bind(null,e,t)}var y_=class{static version;_headless;_parentEditor;_rootElement;_editorState;_pendingEditorState;_compositionKey;_deferred;_keyToDOMMap;_updates;_updating;_cascadeCount;_listeners;_commands;_nodes;_decorators;_pendingDecorators;_config;_dirtyType;_cloneNotNeeded;_dirtyLeaves;_dirtyElements;_normalizedNodes;_updateTags;_observer;_key;_onError;_onWarn;_htmlConversions;_window;_editable;_blockCursorElement;_slotsUsed;_inputState;_createEditorArgs;constructor(e,t,n,r,i,a,o,s,c){this._createEditorArgs=c,this._parentEditor=t,this._rootElement=null,this._editorState=e,this._pendingEditorState=null,this._compositionKey=null,this._deferred=[],this._keyToDOMMap=new Zd,this._updates=[],this._updating=!1,this._cascadeCount=0,this._listeners={decorator:/* @__PURE__ */ new Map,editable:/* @__PURE__ */ new Map,mutation:/* @__PURE__ */ new Map,root:/* @__PURE__ */ new Map,textcontent:/* @__PURE__ */ new Map,update:/* @__PURE__ */ new Map},this._commands=/* @__PURE__ */ new Map,this._config=r,this._nodes=n,this._decorators={},this._pendingDecorators=null,this._dirtyType=0,this._cloneNotNeeded=/* @__PURE__ */ new Set,this._dirtyLeaves=/* @__PURE__ */ new Set,this._dirtyElements=/* @__PURE__ */ new Map,this._normalizedNodes=/* @__PURE__ */ new Set,this._updateTags=/* @__PURE__ */ new Set,this._observer=null,this._key=nv(),this._onError=i,this._onWarn=a,this._htmlConversions=o,this._editable=s,this._headless=t!==null&&t._headless,this._window=null,this._blockCursorElement=null,this._slotsUsed=!1,this._inputState={collapsedSelectionFormat:{format:0,key:`root`,offset:0,style:``,timeStamp:0},compositionEndData:``,compositionPhase:`idle`,hadOrphanedCompositionEvents:!1,handledSelectionCommandTimeoutId:null,isInsertLineBreak:!1,isInsertTextAfterHandledSelectionCommand:!1,isSelectionChangeFromDOMUpdate:!1,isSelectionChangeFromMouseDown:!1,lastBeforeInputInsertTextTimeStamp:0,lastKeyCode:null,lastKeyDownTimeStamp:0,postDeleteSelectionToRestore:null,unprocessedBeforeInputData:null}}isComposing(){return this._compositionKey!=null}registerUpdateListener(e){return v_(this._listeners.update,e)}registerEditableListener(e){return v_(this._listeners.editable,e)}registerDecoratorListener(e){return v_(this._listeners.decorator,e)}registerTextContentListener(e){return v_(this._listeners.textcontent,e)}registerRootListener(e){let t=this._listeners.root;return tx(v_(t,e,e(this._rootElement,null)||void 0),()=>function(e,t,n){let r=e.get(t);r&&r(),e.set(t,t(...n)||void 0)}(t,e,[null,this._rootElement]))}registerCommand(e,t,n){n===void 0&&F(35);let r=this._commands;r.has(e)||r.set(e,[new Yd,new Yd,new Yd,new Yd,new Yd]);let i=r.get(e);i===void 0&&F(36,String(e));let a=function(e){return 7&e}(n),o=i[a];return a===n?o.addBack(t):o.addFront(t),()=>{o.delete(t),i.every(e=>e.size===0)&&r.delete(e)}}registerMutationListener(e,t,n){let r=this.resolveRegisteredNodeAfterReplacements(this.getRegisteredNode(e)).klass,i=this._listeners.mutation,a=i.get(t);a===void 0&&(a=/* @__PURE__ */ new Set,i.set(t,a)),a.add(r);let o=n&&n.skipInitialization;return o!==void 0&&o||this.initializeMutationListener(t,r),()=>{a.delete(r),a.size===0&&i.delete(t)}}getRegisteredNode(e){let t=this._nodes.get(e.getType());return t===void 0&&F(37,e.name),t}resolveRegisteredNodeAfterReplacements(e){for(;e.replaceWithKlass;)e=this.getRegisteredNode(e.replaceWithKlass);return e}initializeMutationListener(e,t){let n=this._editorState,r=py(n).get(t.getType());if(!r)return;let i=/* @__PURE__ */ new Map;for(let e of r.keys())i.set(e,`created`);i.size>0&&e(i,{dirtyLeaves:/* @__PURE__ */ new Set,prevEditorState:n,updateTags:/* @__PURE__ */ new Set([`registerMutationListener`])})}registerNodeTransformToKlass(e,t){let n=this.getRegisteredNode(e);return n.transforms.add(t),n}registerNodeTransform(e,t){let n=this.registerNodeTransformToKlass(e,t),r=[n],i=n.replaceWithKlass;if(i!=null){let e=this.registerNodeTransformToKlass(i,t);r.push(e)}return function(e,t){let n=py(e.getEditorState()),r=[];for(let e of t){let t=n.get(e);t&&r.push(t)}r.length!==0&&e.update(()=>{for(let e of r)for(let t of e.keys()){let e=U_(t);e&&e.markDirty()}},e._pendingEditorState===null?{tag:Km}:void 0)}(this,r.map(e=>e.klass.getType())),()=>{r.forEach(e=>e.transforms.delete(t))}}hasNode(e){return this._nodes.has(e.getType())}hasNodes(e){return e.every(this.hasNode.bind(this))}dispatchCommand(e,...t){return K(this,e,...t)}getDecorators(){return this._decorators}getRootElement(){return this._rootElement}getKey(){return this._key}setRootElement(e){let t=this._rootElement;if(e!==t){let n=pv(this._config.theme,`root`),r=this._pendingEditorState||this._editorState;if(this._rootElement=e,p_(this,t,e,r,{preserveUpdateQueue:!0}),t!==null&&(this._config.disableEvents||zm(t),n!=null&&t.classList.remove(...n)),e!==null){let t=wv(e),r=e.style;r.userSelect=`text`,r.whiteSpace=`pre-wrap`,r.wordBreak=`break-word`,e.setAttribute(`data-lexical-editor`,`true`),this._window=t,this._dirtyType=2,lf(this),this._updateTags.add(Km),Ig(this),this._config.disableEvents||function(e,t){let n=e.ownerDocument;mm.set(e,n);let r=hm.get(n);r===void 0&&(r={editors:/* @__PURE__ */ new Set,hasShadowEditor:void 0},hm.set(n,r)),r.editors.add(t),r.hasShadowEditor=void 0,e.__lexicalEditor=t;let i=Pm(e);i.push(gm.register(n));for(let n=0;n<pm.length;n++){let[r,a]=pm[n],o=typeof a==`function`?e=>{Rm(e)||(Lm(e),(t.isEditable()||r===`click`)&&a(e,t))}:e=>{if(Rm(e))return;Lm(e);let n=t.isEditable();switch(r){case`cut`:return n&&K(t,tm,e);case`copy`:return K(t,em,e);case`paste`:return n&&K(t,Ap,e);case`dragstart`:return n&&K(t,Zp,e);case`dragover`:return n&&K(t,Qp,e);case`dragend`:return n&&K(t,$p,e);case`focus`:return n&&K(t,sm,e);case`blur`:return n&&K(t,cm,e);case`drop`:return n&&K(t,Xp,e)}};i.push(dm(e,r,o))}}(e,this),n!=null&&e.classList.add(...n)}else this._window=null,this._updateTags.add(Km),Ig(this);Lg(`root`,this,!1,e,t)}}getElementByKey(e){return this._keyToDOMMap.get(e)||null}getEditorState(){return this._editorState}setEditorState(e,t){e.isEmpty()&&F(38);let n=e;n._readOnly&&(n=Yg(e),n._selection=e._selection?e._selection.clone():null),cf(this);let r=this._pendingEditorState,i=t===void 0?null:t.tag;r===null||r.isEmpty()||(i!=null&&this._updateTags.add(i),Ig(this)),this._pendingEditorState=n,this._dirtyType=2,this._dirtyElements.set(`root`,!1),this._compositionKey=null,this._slotsUsed=this._slotsUsed||e._slotsUsed,Hg(this,()=>{if(i&&this._updateTags.add(i),e._parsed)for(let[e,t]of n._nodeMap.entries())U(t)?this._dirtyElements.set(e,!0):this._dirtyLeaves.add(e)},{discrete:!this._updating||void 0})}parseEditorState(e,t){return function(e,t,n){let r=Xg(),i=hg,a=_g,o=gg,s=t._dirtyElements,c=t._dirtyLeaves,l=t._cloneNotNeeded,u=t._dirtyType;t._dirtyElements=/* @__PURE__ */ new Map,t._dirtyLeaves=/* @__PURE__ */ new Set,t._cloneNotNeeded=/* @__PURE__ */ new Set,t._dirtyType=0,hg=r,_g=!1,gg=t,x_(null);try{let i=t._nodes;Pg(e.root,i),n&&n(),r._readOnly=!0,r._parsed=!0}catch(e){e instanceof Error&&t._onError(e)}finally{t._dirtyElements=s,t._dirtyLeaves=c,t._cloneNotNeeded=l,t._dirtyType=u,hg=i,_g=a,gg=o}return r}(typeof e==`string`?JSON.parse(e):e,this,t)}read(...e){let[t,n]=e.length===1?[`force-commit`,e[0]]:e;return t===`force-commit`&&Ig(this),(t===`pending`?this._pendingEditorState||this._editorState:this.getEditorState()).read(n,{editor:this})}update(e,t){(function(e,t,n){e._updating?e._updates.push([t,n]):Vg(e,t,n)})(this,e,t)}focus(e,t={}){let n=this._rootElement;n!==null&&(n.setAttribute(`autocapitalize`,`off`),Hg(this,()=>{let r=V(),i=X_();r===null?i.getChildrenSize()!==0&&(t.defaultSelection===`rootStart`?i.selectStart():i.selectEnd()):r.dirty||Z_(r.clone()),xv(`focus`),Sv(()=>{n.removeAttribute(`autocapitalize`),e&&e()})}),this._pendingEditorState===null&&n.removeAttribute(`autocapitalize`))}blur(){let e=this._rootElement;e!==null&&e.blur();let t=Iv(this._window);t!==null&&t.removeAllRanges()}isEditable(){return this._editable}setEditable(e){this._editable!==e&&(this._editable=e,Lg(`editable`,this,!0,e),this._slotsUsed&&this.update(()=>Og()))}toJSON(){return{editorState:this._editorState.toJSON()}}};y_.version=Jd;let b_=null;function x_(e){b_=e}let S_=Symbol(`INTERNAL_SKIP_AFTER_CLONE_FROM`),C_=1;function w_(e,t){let n=T_(e,t);return n===void 0&&F(30,t),n}function T_(e,t){return e._nodes.get(t)}let E_=typeof queueMicrotask==`function`?queueMicrotask:e=>{Promise.resolve().then(e)};function D_(e,t){let n=t===void 0?(()=>{let t=e.getRootNode();return F_(t)||Rv(t)?Zv(t):null})():t;if(!q(n)||n.hasAttribute(`data-lexical-slot`))return!1;let r=q_(n),i=n.nodeName;return Gm(r)&&(i===`INPUT`||i===`TEXTAREA`||n.contentEditable===`true`&&j_(n)==null)}function O_(e,t,n){let r=e.getRootElement();if(!r)return!1;try{if(!t||!r.contains(t)||!r.contains(n))return!1}catch{return!1}return A_(t)===e&&e.read(`latest`,()=>!D_(t))}function k_(e){return e instanceof y_}function A_(e){let t=e;for(;t!=null;){let e=j_(t);if(k_(e))return e;t=yv(t)}return null}function j_(e){return e?e.__lexicalEditor:null}function M_(e){return bh(e)||e.isToken()}function N_(e){return M_(e)||e.isSegmented()}function P_(e){return $v(e)&&e.nodeType===3}function F_(e){return $v(e)&&e.nodeType===9}function I_(e){let t=e;for(;t!=null;){if(P_(t))return t;t=t.firstChild}return null}function L_(e,t,n){let r=Pd[t];if(n!==null&&(e&r)===(n&r))return e;let i=e^r;return t===`subscript`?i&=~Pd.superscript:t===`superscript`?i&=~Pd.subscript:t===`lowercase`?(i&=~Pd.uppercase,i&=~Pd.capitalize):t===`uppercase`?(i&=~Pd.lowercase,i&=~Pd.capitalize):t===`capitalize`&&(i&=~Pd.lowercase,i&=~Pd.uppercase),i}function R_(e,t){let n=function(){let e=b_;return b_=null,e}();if((t||=n&&n.__key)!=null)return void(e.__key=t);wg(),Tg();let r=H(),i=Eg(),a=``+C_++;i._nodeMap.set(a,e),U(e)?r._dirtyElements.set(a,!0):r._dirtyLeaves.add(a),r._cloneNotNeeded.add(a),r._dirtyType===0&&(r._dirtyType=1),e.__key=a}function z_(e){Fy(e)!==null&&F(380,e.__key,String(Fy(e)));let t=e.getParent();if(t!==null){let n=e.getWritable(),r=t.getWritable(),i=e.getPreviousSibling(),a=e.getNextSibling(),o=a===null?null:a.__key,s=i===null?null:i.__key,c=i===null?null:i.getWritable(),l=a===null?null:a.getWritable();i===null&&(r.__first=o),a===null&&(r.__last=s),c!==null&&(c.__next=o),l!==null&&(l.__prev=s),n.__prev=null,n.__next=null,n.__parent=null,r.__size--}}function B_(e){Tg(),Hm(e)&&F(323,e.__key,e.__type);let t=e.getLatest(),n=t.__parent===null?Py(t)?t.__slotHost:null:t.__parent,r=Eg(),i=H(),a=r._nodeMap,o=i._dirtyElements;n!==null&&function(e,t,n){let r=e;for(;r!==null;){if(n.has(r))return;let e=t.get(r);if(e===void 0)break;n.set(r,!1),r=e.__parent===null?Py(e)?e.__slotHost:null:e.__parent}}(n,a,o);let s=t.__key;i._dirtyType===0&&(i._dirtyType=1),U(e)?o.set(s,!0):i._dirtyLeaves.add(s)}function V_(e){wg();let t=H(),n=t._compositionKey;if(e!==n){if(t._compositionKey=e,n!==null){let e=U_(n);e!==null&&e.getWritable()}if(e!==null){let t=U_(e);t!==null&&t.getWritable()}}}function H_(){return Cg()?null:H()._compositionKey}function U_(e,t){let n=(t||Eg())._nodeMap.get(e);return n===void 0?null:n}function W_(e,t){let n=K_(e,H());return n===void 0?null:U_(n,t)}function G_(e,t,n){e[`__lexicalKey_${t._key}`]=n}function K_(e,t){return e[`__lexicalKey_${t._key}`]}function q_(e,t){let n=e;for(;n!=null;){let e=W_(n,t);if(e!==null)return e;n=yv(n)}return null}function J_(e){let t=e._decorators,n=Object.assign({},t);return e._pendingDecorators=n,n}function Y_(e){return e.read(()=>X_().getTextContent())}function X_(){return Eg()._nodeMap.get(`root`)}function Z_(e){wg();let t=Eg();e!==null&&(e.dirty=!0,e.setCachedNodes(null),B(e)&&H()._slotsUsed&&Kh(e)),t._selection=e}function Q_(){wg(),cf(H())}function $_(e){let t=function(e,t){let n=e;for(;n!=null;){let e=K_(n,t);if(e!==void 0)return e;n=yv(n)}return null}(e,H());return t===null?null:U_(t)}function ev(e){return/[\uD800-\uDBFF][\uDC00-\uDFFF]/g.test(e)}function tv(e){let t=[];for(let n=e;n!==null;n=n._parentEditor)t.push(n);return t}function nv(){return Math.random().toString(36).replace(/[^a-z]+/g,``).substring(0,5)}function rv(e){return P_(e)?e.nodeValue:null}function iv(e,t,n){let r=Iv(Tv(t));if(r===null)return;let i=Kv(r,t._rootElement),a=i.anchorNode,{anchorOffset:o,focusOffset:s}=i;if(a!==null){let t=rv(a),r=q_(a);if(t!==null&&z(r)){if((t===Ad||t===jd)&&n){let e=n.length;t=n,o=e,s=e}t!==null&&av(r,t,o,s,e)}}}function av(e,t,n,r,i){let a=e;if(a.isAttached()&&(i||!a.isDirty())){let o=a.isComposing();if(a.isToken()&&o)return;let s=t;if((o||i)&&(t.endsWith(Ad)&&(s=t.slice(0,-Ad.length)),i)){let e=jd,t;for(;(t=s.indexOf(e))!==-1;)s=s.slice(0,t)+s.slice(t+e.length),n!==null&&n>t&&(n=Math.max(t,n-e.length)),r!==null&&r>t&&(r=Math.max(t,r-e.length))}let c=a.getTextContent();if(i||s!==c){let t=V();if(s===``){if(V_(null),Ed||wd||kd)a.remove();else{let e=H();ov(a,``,t),setTimeout(()=>{e.update(()=>{a.isAttached()&&a.getTextContent()===``&&a.remove()})},20)}return}let i=a.getParent(),c=$h(),l=a.getTextContentSize(),u=H_(),d=a.getKey();if(a.isToken()&&!o||u!==null&&d===u&&!o||B(c)&&(i!==null&&!i.canInsertTextBefore()&&c.anchor.offset===0||c.anchor.key===e.__key&&c.anchor.offset===0&&!a.canInsertTextBefore()&&!o||c.focus.key===e.__key&&c.focus.offset===l&&!a.canInsertTextAfter()&&!o))return void a.markDirty();if(!B(t)||n===null||r===null)return void ov(a,s,t);if(t.setTextNodeRange(a,n,a,r),a.isSegmented()){let e=gh(a.getTextContent());a.replace(e),a=e}ov(a,s,t)}}}function ov(e,t,n){if(e.setTextContent(t),B(n)){let t=e.getKey(),r=!1;for(let i of[`anchor`,`focus`]){let a=n[i];a.type===`text`&&a.key===t&&(a.offset=gb(e,a.offset,`clamp`),r=!0)}r&&(n._cachedNodes=null,n._cachedIsBackward=null)}}function sv(e,t,n){let r=t[n]||!1;return r===`any`||r===e[n]}function cv(e,t){return sv(e,t,`altKey`)&&sv(e,t,`ctrlKey`)&&sv(e,t,`shiftKey`)&&sv(e,t,`metaKey`)}function G(e,t,n){if(!cv(e,n))return!1;if(e.key.toLowerCase()===t.toLowerCase())return!0;if(t.length>1||e.key.length===1&&e.key.charCodeAt(0)<=127)return!1;if(e.code.startsWith(`Digit`)&&/^\d$/.test(t))return e.code===`Digit${t}`;let r=`Key`+t.toUpperCase();return e.code===r}let lv={ctrlKey:!xd,metaKey:xd},uv={altKey:xd,ctrlKey:!xd};function dv(e){return e.key===`Backspace`}function fv(e){let t=X_();if(B(e)){let t=e.anchor,n=e.focus,r=t.getNode();if(Jg(r))return t.set(r.getKey(),0,`element`),n.set(r.getKey(),r.getChildrenSize(),`element`),Tf(e),e;let i=r.getTopLevelElementOrThrow(),a=i.getParent();if(a===null)return U(i)&&(t.set(i.getKey(),0,`element`),n.set(i.getKey(),i.getChildrenSize(),`element`),Tf(e)),e;let o=a;return t.set(o.getKey(),0,`element`),n.set(o.getKey(),o.getChildrenSize(),`element`),Tf(e),e}{let e=t.select(0,t.getChildrenSize());return Z_(Tf(e)),e}}function pv(e,t){e.__lexicalClassNameCache===void 0&&(e.__lexicalClassNameCache={});let n=e.__lexicalClassNameCache,r=n[t];if(r!==void 0)return r;let i=e[t];if(typeof i==`string`){let e=$b(i);return n[t]=e,e}return i}function mv(e,t,n,r,i){if(n.size===0)return;let a=r.__type,o=r.__key,s=t.get(a);s===void 0&&F(33,a);let c=s.klass,l=e.get(c);l===void 0&&(l=/* @__PURE__ */ new Map,e.set(c,l));let u=l.get(o),d=u===`destroyed`&&i===`created`;(u===void 0||d)&&l.set(o,d?`updated`:i)}function hv(e,t,n){let r=e.getParent(),i=n,a=e;return r!==null&&(t&&n===0?(i=a.getIndexWithinParent(),a=r):t||n!==a.getChildrenSize()||(i=a.getIndexWithinParent()+1,a=r)),a.getChildAtIndex(t?i-1:i)}function gv(e,t){let n=e.offset;if(e.type===`element`)return hv(e.getNode(),t,n);{let r=e.getNode();if(t&&n===0||!t&&n===r.getTextContentSize()){let e=t?r.getPreviousSibling():r.getNextSibling();return e===null?hv(r.getParentOrThrow(),t,r.getIndexWithinParent()+ +!t):e}}return null}function _v(e){let t=Tv(e).event,n=t&&t.inputType;return n===`insertFromPaste`||n===`insertFromPasteAsQuotation`}function K(e,t,...n){return Rg(e,t,n[0],e)}function vv(e,t){let n=e._keyToDOMMap.get(t);return n===void 0&&F(75,t),n}function yv(e){let t=e.assignedSlot||e.parentElement;if(t!==null)return t;let n=e.parentNode;return Rv(n)?n.host:null}function bv(e){return F_(e)?e:q(e)?e.ownerDocument:null}function xv(e){wg(),H()._updateTags.add(e)}function Sv(e){wg(),H()._deferred.push(e)}function Cv(e,t){let n=e.getParent();for(;n!==null;){if(n.is(t))return!0;n=n.getParent()}return!1}function wv(e){let t=bv(e);return t?t.defaultView:null}function Tv(e){let t=e._window;return t===null&&F(78),t}function Ev(e){return U(e)&&e.isInline()||W(e)&&e.isInline()}function Dv(e){let t=e.getLatest();for(;t!==null;){if(Fy(t)!==null&&U(t))return t;let e=t.getParentOrThrow();if(kv(e))return e;t=e}return t}function Ov(e){return U(e)&&e.isShadowRoot()}function kv(e){return Jg(e)||Ov(e)}function Av(e,t=!1){let n=e.constructor.clone(e,S_);return R_(n,null),n.afterCloneFrom(e),t||n.resetOnCopyNodeFrom(e),n}function jv(e){let t=H(),n=e.getType(),r=T_(t,n);r===void 0&&F(200,e.constructor.name,n);let{replace:i,replaceWithKlass:a}=r;if(i!==null){let t=i(e),r=t.constructor;return a===null?t instanceof e.constructor&&r!==e.constructor||F(202,r.name,r.getType(),e.constructor.name,n):t instanceof a||F(201,a.name,a.getType(),r.name,r.getType(),e.constructor.name,n),t.__key===e.__key&&F(203,e.constructor.name,n,r.name,r.getType()),t}return e}function Mv(e,t){!Jg(e.getParent())||U(t)||W(t)||F(99)}function Nv(e){let t=U_(e);return t===null&&F(63,e),t}function Pv(e){if(!e||e.isInline())return!1;if(W(e))return!0;if(U(e)){if(e.isShadowRoot()){let t=e.getParent();return!(U(t)&&t.isShadowRoot())}return!e.canBeEmpty()}return!1}function Fv(e,t,n){n.style.removeProperty(`caret-color`),t._blockCursorElement=null;let r=e.parentElement;r!==null&&r.removeChild(e)}function Iv(e){return yd?(e||window).getSelection():null}function Lv(e){let t=wv(e);return t?t.getSelection():null}function Rv(e){return ey(e)&&`host`in e}let zv=[];function Bv(e){let t=e.getRootNode();if(t===e||!Rv(t))return zv;let n=[t],r=t.host;for(;;){let e=r.getRootNode();if(e===r||!Rv(e))break;n.push(e),r=e.host}return n}function*Vv(e){let t=[e],n;for(;n=t.pop();){yield*n.querySelectorAll(`[data-lexical-editor="true"]`);let e=(F_(n)?n:n.ownerDocument).createTreeWalker(n,NodeFilter.SHOW_ELEMENT),r;for(;r=e.nextNode();)r.shadowRoot&&t.push(r.shadowRoot)}}function Hv(e){return e===null?document:e.ownerDocument}function Uv(){let e=Ag();return Hv(e===null?null:e._rootElement)}function Wv(e,t){if(t===null||typeof e.getComposedRanges!=`function`)return null;let n=Bv(t);if(n.length===0)return null;let r=e.getComposedRanges;try{let t=r.call(e,{shadowRoots:n})[0];if(t!==void 0)return t}catch{}try{let t=r.apply(e,n)[0];if(t!==void 0)return t}catch{}return null}function Gv(e,t){let n=Wv(e,t);if(n!==null){let e=qv(n);if(e!==null)return e}return e.rangeCount>0?e.getRangeAt(0):null}function Kv(e,t){let n=Wv(e,t);return n===null?e:Jv(n,Yv(e))}function qv(e){let t=e.startContainer.ownerDocument;if(t===null)return null;let n=t.createRange();try{return n.setStart(e.startContainer,e.startOffset),n.setEnd(e.endContainer,e.endOffset),n}catch{return null}}function Jv(e,t){let{startContainer:n,startOffset:r,endContainer:i,endOffset:a}=e;return t===`backward`?{anchorNode:i,anchorOffset:a,direction:t,focusNode:n,focusOffset:r}:{anchorNode:n,anchorOffset:r,direction:t,focusNode:i,focusOffset:a}}function Yv(e){return e.direction}function Xv(e){let t=e.getRootNode();return F_(t)||Rv(t)?t.activeElement:null}function Zv(e){let t=e.activeElement;for(;t!==null&&t.shadowRoot!==null;){let e=t.shadowRoot.activeElement;if(e===null)break;t=e}return t}function Qv(e){let t=e.target;if(t!==null&&q(t)&&t.shadowRoot!==null&&typeof e.composedPath==`function`){let t=e.composedPath();if(t.length>0)return t[0]}return t}function q(e){return $v(e)&&e.nodeType===1}function $v(e){return typeof e==`object`&&!!e&&`nodeType`in e&&typeof e.nodeType==`number`}function ey(e){return $v(e)&&e.nodeType===11}let ty=/^(a|abbr|acronym|b|cite|code|del|em|i|ins|kbd|label|mark|output|q|ruby|s|samp|span|strong|sub|sup|time|u|tt|var|#text)$/i;function ny(e){return!(!q(e)||!e.style.display.startsWith(`inline`))||ty.test(e.nodeName)}let ry=/^(address|article|aside|blockquote|canvas|dd|div|dl|dt|fieldset|figcaption|figure|footer|form|h1|h2|h3|h4|h5|h6|header|hr|li|main|nav|noscript|ol|p|pre|section|table|td|tfoot|ul|video)$/i;function iy(e){return(!q(e)||!e.style.display.startsWith(`inline`))&&ry.test(e.nodeName)}function ay(e){if(W(e)&&!e.isInline())return!0;if(!U(e)||kv(e))return!1;let t=e.getFirstChild(),n=t===null||i_(t)||z(t)||t.isInline();return!e.isInline()&&!1!==e.canBeEmpty()&&n}function oy(){return H()}function sy(e=oy()){return e._config.dom||h_}function cy(e,t,n=oy()){let r=sy(n).$getDOMSlot(e,t,n);return U(e)&&(ly(r)||F(344,e.getKey(),e.getType())),r}function ly(e){return e instanceof Gd}function uy(e,t,n=oy()){return I_(cy(e,t,n).element)}let dy=/* @__PURE__ */ new WeakMap,fy=/* @__PURE__ */ new Map;function py(e){if(!e._readOnly&&e.isEmpty())return fy;e._readOnly||F(192);let t=dy.get(e);return t||(t=function(e){let t=/* @__PURE__ */ new Map;for(let[n,r]of e._nodeMap){let e=r.__type,i=t.get(e);i||(i=/* @__PURE__ */ new Map,t.set(e,i)),i.set(n,r)}return t}(e),dy.set(e,t)),t}function my(e){let t=e.constructor.clone(e,S_);return t.afterCloneFrom(e),t}function hy(e){return(t=my(e))[Vm]=!0,t;var t}function gy(e,t){let n=e.getAttribute(`data-lexical-indent`);if(n!==null){let e=parseInt(n,10);if(Number.isFinite(e)&&e>=0)return void t.setIndent(e)}let r=parseInt(e.style.paddingInlineStart,10)||0,i=Math.round(r/40);t.setIndent(i)}function _y(e,t){let n=t.getAttribute(`dir`);return n===`ltr`||n===`rtl`?e.setDirection(n):e}function vy(e,t){let n=t.style.textAlign;return n&&n in Id?e.setFormat(n):e}function yy(e,t){e.__lexicalUnmanaged=!0,t&&t.captureSelection!==void 0&&(e.__lexicalCapturedSelection=t.captureSelection)}function by(e){return!0===e.__lexicalUnmanaged}function xy(e,t=oy()){let n=t.isEditable();e.contentEditable=n?`true`:`false`,n?e.__lexicalEditor=t:delete e.__lexicalEditor}function Sy(e,t){let n=e;for(;n!=null;){if(!0===n.__lexicalCapturedSelection)return!0;if(q(n)&&n.hasAttribute(`data-lexical-slot`)||K_(n,t)!==void 0)return!1;n=yv(n)}return!1}function Cy(e,t){return function(e,t){return Object.prototype.hasOwnProperty.call(e,t)}(e,t)&&e[t]!==Wm[t]}let wy=/* @__PURE__ */ new WeakMap,Ty=Symbol(`lexical.synthesizedGetType`);function Ey(e){let t=wy.get(e);if(t)return t;let n=e.prototype!=null&&Bd in e.prototype?e.prototype[Bd]():void 0,r=function(e){if(!(e===Wm||e.prototype instanceof Wm)){let t=`<unknown>`,n=`<unknown>`;try{t=e.getType()}catch{}try{y_.version&&(n=JSON.parse(y_.version))}catch{}F(290,e.name,t,n)}return e===Kg||e===Wg||e===Wm}(e),i=!r&&Cy(e,`getType`)?e.getType:void 0,a=i&&!(Ty in i)?i.call(e):void 0,o,s=a;if(n){if(a)o=n[a];else{for(let[e,t]of Object.entries(n))s=e,o=t;if(!o)for(let e of Object.getOwnPropertySymbols(n)){let t=n[e];if(t){o=t;break}}}}if(!r&&s){if(!Cy(e,`getType`)){let t=e,n=function(){return this===t?s:Wm.getType.call(this)};n[Ty]=!0,e.getType=n}if(Cy(e,`clone`)||(e.clone=(t,n)=>{x_(t);let r=new e;return n!==S_&&r.afterCloneFrom(t),r}),Cy(e,`importJSON`)||(e.importJSON=o&&o.$importJSON||(t=>new e().updateFromJSON(t))),!Cy(e,`importDOM`)&&o){let{importDOM:t}=o;t&&(e.importDOM=()=>t)}}let c={klass:e,ownNodeConfig:o,ownNodeType:s};return wy.set(e,c),c}function*Dy(e){for(let t=e;t&&(t===Wm||Gm(t.prototype));){let e=Ey(t);yield e,t=e.ownNodeConfig&&e.ownNodeConfig.extends||jy(t)}}function Oy(e){let t=oy();return wg(),new(t.resolveRegisteredNodeAfterReplacements(t.getRegisteredNode(e))).klass}let ky=(e,t)=>{let n=e;for(;n!=null&&!Jg(n);){if(t(n))return n;n=n.getParent()}return null};function Ay(e,t){let n=[],r=e.__first;for(;r!==null;){let e=t===null?U_(r):t.get(r);e??F(174),n.push(r),r=e.__next}return n}function jy(e){let t=Object.getPrototypeOf(e);if(typeof t==`function`&&t!==Function.prototype)return t;let n=e.prototype&&Object.getPrototypeOf(e.prototype);return n?n.constructor:null}let My=/* @__PURE__ */ new Map;function Ny(e){return U(e)||W(e)}function Py(e){return U(e)||W(e)}function Fy(e){let t=e.getLatest();return Py(t)?t.__slotHost:null}function Iy(e){let t=Fy(e);if(t===null)return null;let n=U_(t);return U(n)||W(n)||F(370),n}function Ly(e){let t=Iy(e);if(t===null)return null;let n=e.getLatest().__key;for(let[e,r]of zy(t))if(r===n)return e;return null}function Ry(e){let t=e.getLatest();for(;t!==null;){if(Fy(t)!==null)return t;t=t.getParent()}return null}function zy(e){let t=e.getLatest();return Ny(t)&&t.__slots!==null?t.__slots:My}function By(e){return Array.from(zy(e).keys())}function Vy(e,t){let n=zy(e).get(t);return n===void 0?null:U_(n)}let Hy=[`__proto__`,`constructor`,`prototype`],Uy=Symbol(`slotMapOwner`);function Wy(e){let t=e.__slots;return t!==null&&t[Uy]===e||(t=new Map(t),t[Uy]=e,e.__slots=t),t}let Gy=/* @__PURE__ */ new WeakMap,Ky=[];function qy(e){for(let{ownNodeConfig:t}of Dy(e)){let e=t&&t.slots;if(e)return e}return Ky}function Jy(e){let t=``;for(let n of By(e)){let r=Vy(e,n);r!==null&&(t+=r.getTextContent())}return t}function Yy(e,t,n){let r=n.get(e),i=n.get(t);return r===void 0?i===void 0?e<t?-1:+(e>t):1:i===void 0?-1:r-i}function Xy(e){let t=e.__slots;if(t===null||t.size<2)return;let n=function(e){let t=Gy.get(e);if(t===void 0){let n=qy(e),r=/* @__PURE__ */ new Map;for(let t of n)Hy.includes(t)&&F(371,e.name,t),r.has(t)&&F(372,e.name,t),r.set(t,r.size);t=r,Gy.set(e,t)}return t}(e.constructor),r=null,i=!0;for(let e of t.keys()){if(r!==null&&Yy(r,e,n)>0){i=!1;break}r=e}if(i)return;let a=Array.from(t).sort(([e],[t])=>Yy(e,t,n));t.clear();for(let[e,n]of a)t.set(e,n)}function Zy(e,t,n){t!==`__proto__`&&t!==`constructor`&&t!==`prototype`||F(373,t);let r=e.getLatest();if(r.__slots!==null&&r.__slots.get(t)===n.getLatest().__key)return r;(!U(n)&&!W(n)||n.isInline())&&F(374,n.__key);let i=e.getWritable(),a=Wy(i),o=a.get(t);o!==void 0&&$y(o);let s=n.getWritable(),c=Iy(s);if(c!==null){let e=Ly(s);e!==null&&Wy(c.getWritable()).delete(e),s.__slotHost=null}return z_(s),s.__slotHost=i.__key,a.set(t,s.__key),Xy(i),function(){let e=oy();e._slotsUsed=!0,e._pendingEditorState&&(e._pendingEditorState._slotsUsed=!0)}(),i}function Qy(e,t){let n=e.getWritable();if(n.__slots===null)return n;let r=n.__slots.get(t);return r!==void 0&&($y(r),Wy(n).delete(t)),n}function $y(e){let t=U_(e);if(t===null)return;let n=t.getWritable();Py(n)||F(377,e),n.__slotHost=null,n.remove()}let eb={next:`previous`,previous:`next`};var tb=class{origin;constructor(e){this.origin=e}[Symbol.iterator](){return Eb({hasNext:lb,initial:this.getAdjacentCaret(),map:e=>e,step:e=>e.getAdjacentCaret()})}getAdjacentCaret(){return mb(this.getNodeAtCaret(),this.direction)}getSiblingCaret(){return mb(this.origin,this.direction)}remove(){let e=this.getNodeAtCaret();return e&&e.remove(),this}replaceOrInsert(e,t){let n=this.getNodeAtCaret();return e.is(this.origin)||e.is(n)||(n===null?this.insert(e):n.replace(e,t)),this}splice(e,t,n=`next`){let r=n===this.direction?t:Array.from(t).reverse(),i=this,a=this.getParentAtCaret(),o=/* @__PURE__ */ new Map;for(let t=i.getAdjacentCaret();t!==null&&o.size<e;t=t.getAdjacentCaret()){let e=t.origin.getWritable();o.set(e.getKey(),e)}for(let e of r){if(o.size>0){let t=i.getNodeAtCaret();if(t){if(o.delete(t.getKey()),o.delete(e.getKey()),!(t.is(e)||i.origin.is(e))){let n=e.getParent();n&&n.is(a)&&e.remove(),t.replace(e)}}else t===null&&F(263,Array.from(o).join(` `))}else i.insert(e);i=mb(e,this.direction)}for(let e of o.values())e.remove();return this}},nb=class e extends tb{type=`child`;getLatest(){let e=this.origin.getLatest();return e===this.origin?this:vb(e,this.direction)}getParentCaret(e=`root`){return mb(ab(this.getParentAtCaret(),e),this.direction)}getFlipped(){let e=ib(this.direction);return mb(this.getNodeAtCaret(),e)||vb(this.origin,e)}getParentAtCaret(){return this.origin}getChildCaret(){return this}isSameNodeCaret(t){return t instanceof e&&this.direction===t.direction&&this.origin.is(t.origin)}isSamePointCaret(e){return this.isSameNodeCaret(e)}};let rb={root:Jg,shadowRoot:kv};function ib(e){return eb[e]}function ab(e,t=`root`){return e===null||rb[t](e)?null:Fy(e)===null?e:null}var ob=class e extends tb{type=`sibling`;getLatest(){let e=this.origin.getLatest();return e===this.origin?this:mb(e,this.direction)}getSiblingCaret(){return this}getParentAtCaret(){return this.origin.getParent()}getChildCaret(){return U(this.origin)?vb(this.origin,this.direction):null}getParentCaret(e=`root`){return mb(ab(this.getParentAtCaret(),e),this.direction)}getFlipped(){let e=ib(this.direction);return mb(this.getNodeAtCaret(),e)||vb(this.origin.getParentOrThrow(),e)}isSamePointCaret(t){return t instanceof e&&this.direction===t.direction&&this.origin.is(t.origin)}isSameNodeCaret(t){return(t instanceof e||t instanceof sb)&&this.direction===t.direction&&this.origin.is(t.origin)}},sb=class e extends tb{type=`text`;offset;constructor(e,t){super(e),this.offset=t}getLatest(){let e=this.origin.getLatest();return e===this.origin?this:hb(e,this.direction,this.offset)}getParentAtCaret(){return this.origin.getParent()}getChildCaret(){return null}getParentCaret(e=`root`){return mb(ab(this.getParentAtCaret(),e),this.direction)}getFlipped(){return hb(this.origin,ib(this.direction),this.offset)}isSamePointCaret(t){return t instanceof e&&this.direction===t.direction&&this.origin.is(t.origin)&&this.offset===t.offset}isSameNodeCaret(t){return(t instanceof ob||t instanceof e)&&this.direction===t.direction&&this.origin.is(t.origin)}getSiblingCaret(){return mb(this.origin,this.direction)}};function cb(e){return e instanceof sb}function lb(e){return e instanceof ob}function ub(e){return e instanceof nb}let db={next:class extends sb{direction=`next`;getNodeAtCaret(){return this.origin.getNextSibling()}insert(e){return this.origin.insertAfter(e),this}},previous:class extends sb{direction=`previous`;getNodeAtCaret(){return this.origin.getPreviousSibling()}insert(e){return this.origin.insertBefore(e),this}}},fb={next:class extends ob{direction=`next`;getNodeAtCaret(){return this.origin.getNextSibling()}insert(e){return this.origin.insertAfter(e),this}},previous:class extends ob{direction=`previous`;getNodeAtCaret(){return this.origin.getPreviousSibling()}insert(e){return this.origin.insertBefore(e),this}}},pb={next:class extends nb{direction=`next`;getNodeAtCaret(){return this.origin.getFirstChild()}insert(e){return this.origin.splice(0,0,[e]),this}},previous:class extends nb{direction=`previous`;getNodeAtCaret(){return this.origin.getLastChild()}insert(e){return this.origin.splice(this.origin.getChildrenSize(),0,[e]),this}}};function mb(e,t){return e?new fb[t](e):null}function hb(e,t,n){return e?new db[t](e,gb(e,n)):null}function gb(e,t,n=`error`){let r=e.getTextContentSize(),i=t===`next`?r:t===`previous`?0:t;return(i<0||i>r)&&(n!==`clamp`&&vd(284,String(t),String(r),e.getKey()),i=i<0?0:r),i}function _b(e,t){return new Sb(e,t)}function vb(e,t){return U(e)?new pb[t](e):null}function yb(e){return e&&e.getChildCaret()||e}function bb(e){return e&&yb(e.getAdjacentCaret())}var xb=class e{type=`node-caret-range`;direction;anchor;focus;constructor(e,t,n){this.anchor=e,this.focus=t,this.direction=n}getLatest(){let t=this.anchor.getLatest(),n=this.focus.getLatest();return t===this.anchor&&n===this.focus?this:new e(t,n,this.direction)}isCollapsed(){return this.anchor.isSamePointCaret(this.focus)}getTextSlices(){let e=e=>{let t=this[e].getLatest();return cb(t)?function(e,t){let{direction:n,origin:r}=e;return _b(e,gb(r,t===`focus`?ib(n):n)-e.offset)}(t,e):null},t=e(`anchor`),n=e(`focus`);if(t&&n){let{caret:e}=t,{caret:r}=n;if(e.isSameNodeCaret(r))return[_b(e,r.offset-e.offset),null]}return[t,n]}iterNodeCarets(e=`root`){let t=cb(this.anchor)?this.anchor.getSiblingCaret():this.anchor.getLatest(),n=this.focus.getLatest(),r=cb(n),i=t=>t.isSameNodeCaret(n)?null:bb(t)||t.getParentCaret(e);return Eb({hasNext:e=>e!==null&&!(r&&n.isSameNodeCaret(e)),initial:t.isSameNodeCaret(n)?null:i(t),map:e=>e,step:i})}[Symbol.iterator](){return this.iterNodeCarets(`root`)}},Sb=class{type=`slice`;caret;distance;constructor(e,t){this.caret=e,this.distance=t}getSliceIndices(){let{distance:e,caret:{offset:t}}=this,n=t+e;return n<t?[n,t]:[t,n]}getTextContent(){let[e,t]=this.getSliceIndices();return this.caret.origin.getTextContent().slice(e,t)}getTextContentSize(){return Math.abs(this.distance)}removeTextSlice(){let{caret:{origin:e,direction:t}}=this,[n,r]=this.getSliceIndices(),i=e.getTextContent();return hb(e.setTextContent(i.slice(0,n)+i.slice(r)),t,n)}};function Cb(e){return Tb(e,mb(X_(),e.direction))}function wb(e){return Tb(e,e)}function Tb(e,t){return e.direction!==t.direction&&F(265),new xb(e,t,e.direction)}function Eb(e){let{initial:t,hasNext:n,step:r,map:i}=e,a=t;return{[Symbol.iterator](){return this},next(){if(!n(a))return{done:!0,value:void 0};let e={done:!1,value:i(a)};return a=r(a),e}}}function Db(e,t){let n=jb(e.origin,t.origin);switch(n===null&&F(275,e.origin.getKey(),t.origin.getKey()),n.type){case`same`:{let n=e.type===`text`,r=t.type===`text`;return n&&r?function(e,t){return Math.sign(e-t)}(e.offset,t.offset):e.type===t.type?0:n?-1:r?1:e.type===`child`?-1:1}case`ancestor`:return e.type===`child`?-1:1;case`descendant`:return t.type===`child`?1:-1;case`branch`:return Ob(n)}}function Ob(e){let{a:t,b:n}=e,r=t.__key,i=n.__key,a=t,o=n;for(;a&&o;a=a.getNextSibling(),o=o.getNextSibling()){if(a.__key===i)return-1;if(o.__key===r)return 1}return a===null?1:-1}function kb(e,t){return t.is(e)}function Ab(e){return U(e)?[e.getLatest(),null]:[e.getParent(),e.getLatest()]}function jb(e,t){if(e.is(t))return{commonAncestor:e,type:`same`};let n=/* @__PURE__ */ new Map;for(let[t,r]=Ab(e);t;r=t,t=t.getParent())n.set(t,r);for(let[r,i]=Ab(t);r;i=r,r=r.getParent()){let a=n.get(r);if(a!==void 0)return a===null?(kb(e,r)||F(276),{commonAncestor:r,type:`ancestor`}):i===null?(kb(t,r)||F(277),{commonAncestor:r,type:`descendant`}):((U(a)||kb(e,a))&&(U(i)||kb(t,i))&&r.is(a.getParent())&&r.is(i.getParent())||F(278),{a,b:i,commonAncestor:r,type:`branch`})}return null}function Mb(e,t){let{type:n,key:r,offset:i}=e,a=Nv(e.key);return n===`text`?(z(a)||F(266,a.getType(),r),hb(a,t,i)):(U(a)||F(267,a.getType(),r),Gb(a,e.offset,t))}function Nb(e,t){let{origin:n,direction:r}=t,i=r===`next`;cb(t)?e.set(n.getKey(),t.offset,`text`):lb(t)?z(n)?e.set(n.getKey(),gb(n,r),`text`):e.set(n.getParentOrThrow().getKey(),n.getIndexWithinParent()+ +!!i,`element`):(ub(t)&&U(n)||F(268),e.set(n.getKey(),i?0:n.getChildrenSize(),`element`))}function Pb(e){let t=V(),n=B(t)?t:Xh();return Fb(n,e),Z_(n),n}function Fb(e,t){Nb(e.anchor,t.anchor),Nb(e.focus,t.focus)}function Ib(e){let{anchor:t,focus:n}=e,r=Mb(t,`next`),i=Mb(n,`next`),a=Db(r,i)<=0?`next`:`previous`;return Tb(Ub(r,a),Ub(i,a))}function Lb(e){let{direction:t,origin:n}=e,r=mb(n,ib(t)).getNodeAtCaret();return r?mb(r,t):vb(n.getParentOrThrow(),t)}function Rb(e,t=`root`){let n=[e];for(let r=ub(e)?e.getParentCaret(t):e.getSiblingCaret();r!==null;r=r.getParentCaret(t))n.push(Lb(r));return n}function zb(e){return!!e&&e.origin.isAttached()}function Bb(e,t=`removeEmptySlices`){if(e.isCollapsed())return e;let n=`root`,r=`next`,i=t,a=Wb(e,r),o=Rb(a.anchor,n),s=Rb(a.focus.getFlipped(),n),c=/* @__PURE__ */ new Set,l=[];for(let e of a.iterNodeCarets(n))if(ub(e))c.add(e.origin.getKey());else if(lb(e)){let{origin:t}=e;U(t)&&!c.has(t.getKey())||l.push(t)}let u=/* @__PURE__ */ new Set;for(let e of l){let t=e.getParent();t===null||c.has(t.getKey())||u.add(t),z_(e)}for(let e of u)!e.canBeEmpty()&&!kv(e)&&e.isEmpty()&&e.isAttached()&&e.remove();for(let e of a.getTextSlices()){if(!e)continue;let{origin:t}=e.caret,n=t.getTextContentSize(),a=Lb(mb(t,r)),c=t.getMode();if(Math.abs(e.distance)===n&&i===`removeEmptySlices`||c===`token`&&e.distance!==0)a.remove();else if(e.distance!==0){i=`removeEmptySlices`;let t=e.removeTextSlice(),n=e.caret.origin;if(c===`segmented`){let e=t.origin,n=gh(e.getTextContent()).setStyle(e.getStyle()).setFormat(e.getFormat());a.replaceOrInsert(n),t=hb(n,r,t.offset)}n.is(o[0].origin)&&(o[0]=t),n.is(s[0].origin)&&(s[0]=t.getFlipped())}}let d,f;for(let e of o)if(zb(e)){d=Vb(e);break}for(let e of s)if(zb(e)){f=Vb(e);break}let p=function(e,t,n){if(!e||!t)return null;let r=e.getParentAtCaret(),i=t.getParentAtCaret();if(!r||!i)return null;let a=r.getParents().reverse();a.push(r);let o=i.getParents().reverse();o.push(i);let s=Math.min(a.length,o.length),c=0;for(;c<s&&a[c]===o[c];c++);let l=(e,t)=>{let n;for(let r=c;r<e.length;r++){let i=e[r];if(kv(i))return;!n&&t(i)&&(n=i)}return n},u=l(a,ay),d=u&&l(o,e=>n.has(e.getKey())&&ay(e));return d&&By(d).length>0?null:u&&d?[u,d]:null}(d,f,c);if(p){let[e,t]=p;vb(e,`previous`).splice(0,t.getChildren());let n=t.getParent();for(t.remove(!0);n&&n.isEmpty();){let e=n;n=n.getParent(),e.remove(!0)}}else if(f){let e=function(e){if(ub(e)){let t=e.origin;if(ay(t))return t}else{let t=e.getParentAtCaret();if(t&&ay(t))return t}return null}(f),t=e&&e.getParent(),n=e&&e.getParents().findLast(Ov);if(e&&t&&!Jg(t)&&e.isEmpty()&&c.has(e.getKey())&&By(e).length===0&&(!n||c.has(n.getKey()))){e.remove(!0);let n=t;for(;n&&!Jg(n)&&n.isEmpty();){let e=n.getParent();if(e&&Jg(e)&&e.getChildrenSize()<=1)break;let t=n;n=e,t.remove(!0)}}}let m=[d,f,...o,...s].find(zb);if(m)return wb(Ub(Vb(m),e.direction));F(269,JSON.stringify(o.map(e=>e.origin.__key)))}function Vb(e){let t=function(e){let t=e;for(;ub(t);){let e=bb(t);if(!ub(e))break;t=e}return t}(e.getLatest()),{direction:n}=t;if(z(t.origin))return cb(t)?t:hb(t.origin,n,n);let r=t.getAdjacentCaret();return lb(r)&&z(r.origin)?hb(r.origin,n,ib(n)):t}function Hb(e){return cb(e)&&e.offset!==gb(e.origin,e.direction)}function Ub(e,t){return e.direction===t?e:e.getFlipped()}function Wb(e,t){return e.direction===t?e:Tb(Ub(e.focus,t),Ub(e.anchor,t))}function Gb(e,t,n){let r=vb(e,`next`);for(let e=0;e<t;e++){let e=r.getAdjacentCaret();if(e===null)break;r=e}return Ub(r,n)}function Kb(e){let{origin:t,offset:n,direction:r}=e;if(n===gb(t,r))return e.getSiblingCaret();if(n===gb(t,ib(r)))return Lb(e.getSiblingCaret());let[i]=t.splitText(n);return z(i)||F(281),Ub(mb(i,`next`),r)}function qb(e,t){return!0}function Jb(e,{$copyElementNode:t=Av,$splitTextPointCaretNext:n=Kb,rootMode:r=`shadowRoot`,$shouldSplit:i=qb,removeEmptyDestination:a=!1}={}){if(cb(e))return n(e);let o=e.getParentCaret(r);if(o){let{origin:n}=o;if(ub(e)){let e=Lb(o);if(a&&n.isEmpty())return n.remove(),e;if(!n.canBeEmpty()||!i(n,`first`))return e}let r=function(e){let t=[];for(let n=e.getAdjacentCaret();n;n=n.getAdjacentCaret())t.push(n.origin);return t}(e);(r.length>0||!a&&n.canBeEmpty()&&i(n,`last`))&&o.insert(t(n).splice(0,0,r))}return o}function Yb(e,t,n){let r=Ub(t,`next`);cb(r)&&(r.offset===0?r=mb(r.origin,`previous`).getFlipped():r.offset===r.origin.getTextContentSize()&&(r=mb(r.origin,`next`))),r.origin.is(e)&&(lb(r)||F(342,e.getKey(),e.getType()),r=Lb(r)),(e.is(r.getNodeAtCaret())||e.is(r.getFlipped().getNodeAtCaret()))&&e.remove(!0);for(let e=r;e;e=Jb(e,n))r=e;return cb(r)&&F(283),r.insert(e.isInline()?u_().append(e):e),Ub(mb(e.getLatest(),`next`),t.direction)}function Xb(e){return e}function Zb(e){return e}function Qb(e,t){if(!t||e===t)return e;for(let n in t)if(e[n]!==t[n])return{...e,...t};return e}function $b(...e){let t=[];for(let n of e)if(n&&typeof n==`string`)for(let[e]of n.matchAll(/\S+/g))t.push(e);return t}function ex(e,...t){let n=$b(...t);n.length>0&&e.classList.add(...n)}function tx(...e){return()=>{for(let t=e.length-1;t>=0;t--)e[t]();e.length=0}}function nx(e){throw Error(`unreachable input event: ${JSON.stringify(e)}`)}function rx(e,t){let n=e.trimStart();if(n.startsWith(t))return n.slice(t.length);let r=t.trimEnd();if(n.startsWith(r)){let e=n.slice(r.length);return/^\s/.test(e)?e.slice(1):e}return``}function ix(e,t){return e.startsWith(t)||e===t.trimEnd()}var ax=class{phase=`plain`;claim;seq=0;inflight;detached=/* @__PURE__ */ new Map;get state(){let e=this.claim;return{phase:this.phase,...e?{claim:{name:e.name,token:e.token,...e.hint===void 0?{}:{hint:e.hint},...e.attachments===!0?{attachments:!0}:{}}}:{}}}dispatch(e){switch(e.type){case`draft-changed`:return this.onDraftChanged(e.draft);case`claim`:return this.onClaim(e.claim);case`enter`:return this.onEnter(e.mode,e.draft,e.annotated,e.submission);case`adjudicated`:return this.onAdjudicated(e.attempt,e.outcome);case`adjudication-failed`:return this.onAdjudicationFailed(e.attempt,e.message);case`submit-settled`:return this.onSubmitSettled(e);case`sink-settled`:return this.onSinkSettled(e);case`send-committed`:return this.onSendCommitted();case`release`:return this.onRelease();default:return nx(e)}}onDraftChanged(e){return this.phase===`claimed`&&this.claim!==void 0&&!ix(e,this.claim.token)&&(this.phase=`plain`,this.claim=void 0),[]}onClaim(e){return this.phase!==`plain`&&this.phase!==`claimed`||(this.claim=e,this.phase=`claimed`),[]}mintAttempt(e,t,n){let r=new AbortController;return this.seq+=1,{attempt:{seq:this.seq,signal:r.signal,draftSnapshot:t,mode:e,...n===void 0?{}:{submission:n}},controller:r}}beginAttempt(e,t,n){let r=this.mintAttempt(e,t,n);return this.inflight=r,r.attempt}beginDetached(e,t,n){let r=this.mintAttempt(e,t,n);return this.detached.set(r.attempt.seq,r.controller),this.claim=void 0,this.phase=`plain`,r.attempt}detachedEffects(e){return[{type:`default-sink`,attempt:e,draft:e.draftSnapshot,mode:e.mode},{type:`commit-draft`,retainSuffixOf:e.draftSnapshot}]}onEnter(e,t,n,r){if(this.phase===`adjudicating`||this.phase===`submitting`)return[];if(this.phase===`claimed`&&this.claim!==void 0){let n=this.beginAttempt(e,t,r);return this.phase=`submitting`,[{type:`begin-submit`,attempt:n,claim:this.claim,args:rx(t,this.claim.token)}]}let i=t.trim();if(i===``&&!n)return[];if(i.startsWith(`/`)){let n=this.beginAttempt(e,t,r);return this.phase=`adjudicating`,[{type:`adjudicate`,attempt:n,draft:t}]}return this.detachedEffects(this.beginDetached(e,t,r))}onAdjudicated(e,t){let n=this.inflight;return this.phase!==`adjudicating`||n===void 0||n.attempt.seq!==e.seq?[]:t!==void 0&&t!==`handled`&&t!==`refresh`&&`claim`in t?(this.claim=t.claim,this.phase=`submitting`,[{type:`begin-submit`,attempt:e,claim:t.claim,args:rx(e.draftSnapshot,t.claim.token)}]):(this.inflight=void 0,this.phase=`plain`,t===void 0?(this.detached.set(e.seq,n.controller),this.detachedEffects(e)):[])}onAdjudicationFailed(e,t){return this.phase!==`adjudicating`||this.inflight?.attempt.seq!==e.seq?[]:(this.inflight=void 0,this.phase=`plain`,[{type:`notice`,level:`error`,text:t}])}onSubmitSettled(e){let t=this.inflight;if(this.phase!==`submitting`||t===void 0||t.attempt.seq!==e.attempt.seq)return[];if(this.inflight=void 0,e.ok){this.phase=`plain`,this.claim=void 0;let n=[{type:`commit-draft`,retainSuffixOf:t.attempt.draftSnapshot}];return e.outcome?.text!==void 0&&n.push({type:`notice`,level:e.outcome.kind===`error`?`error`:`info`,text:e.outcome.text}),n}let n=e.message??e.outcome?.text;return e.draft===t.attempt.draftSnapshot&&this.claim!==void 0&&ix(e.draft,this.claim.token)?(this.phase=`claimed`,n===void 0?[]:[{type:`notice`,level:`error`,text:n}]):(this.phase=`plain`,this.claim=void 0,n===void 0?[]:[{type:`notice`,level:`error`,text:n}])}onSinkSettled(e){if(!this.detached.delete(e.attempt.seq))return[];let t=e.message??e.outcome?.text;return t===void 0?[]:[{type:`notice`,level:e.ok&&e.outcome?.kind!==`error`?`info`:`error`,text:t}]}onSendCommitted(){return this.phase===`plain`?(this.claim=void 0,[{type:`commit-draft`,retainSuffixOf:null}]):[]}onRelease(){this.inflight!==void 0&&(this.inflight.controller.abort(),this.inflight=void 0);for(let e of this.detached.values())e.abort();return this.detached.clear(),this.phase=`plain`,this.claim=void 0,[]}};function ox(e){let t=oy().getElementByKey(e.getKey());if(t===null)return null;let n=t.ownerDocument.defaultView;return n===null?null:n.getComputedStyle(t)}function sx(e){return ox(Jg(e)?e:e.getParentOrThrow())}function cx(e,t,n=`self`){let r=e.getStartEndPoints();if(t.isSelected(e)&&!N_(t)&&r!==null){let[i,a]=r,o=e.isBackward(),s=i.getNode(),c=a.getNode(),l=t.is(s),u=t.is(c);if(l||u){let[r,i]=Ph(e),a=s.is(c),l=t.is(o?c:s),u=t.is(o?s:c),d,f=0;a?(f=r>i?i:r,d=r>i?r:i):l?(f=o?i:r,d=void 0):u&&(f=0,d=o?r:i);let p=t.__text.slice(f,d);p!==t.__text&&(n===`clone`&&(t=hy(t)),t.__text=p)}}return t}function lx(e){let t=ux(e);return t!==null&&t.writingMode===`vertical-rl`}function ux(e){let t=e.anchor.getNode();return U(t)?ox(t):sx(t)}function dx(e,t){let n=lx(e)?!t:t;px(e)&&(n=!n);let r=Mb(e.focus,n?`previous`:`next`);if(Hb(r))return!1;if(cb(r)&&!bh(r.origin)&&r.origin.isUnmergeable()){let e=r.getNodeAtCaret();if(z(e)&&!bh(e))return!0}for(let e of Cb(r)){if(ub(e))return!e.origin.isInline();if(!U(e.origin)){if(W(e.origin))return!0;break}}return!1}function fx(e,t,n,r){e.modify(t?`extend`:`move`,n,r)}function px(e){let t=ux(e);return t!==null&&t.direction===`rtl`}function mx(e,t,n){let r=px(e),i;i=lx(e)||r?!n:n,fx(e,t,i,`character`)}function hx(e,t){return e!==null&&Object.getPrototypeOf(e).constructor.name===t.name}let gx=Symbol.for(`preact-signals`);function _x(){if(xx>1)return void xx--;let e,t=!1;for(function(){let e=bx;for(bx=void 0;e!==void 0;)e.S.v===e.v&&(e.S.i=e.i),e=e.o}();vx!==void 0;){let n=vx;for(vx=void 0,Sx++;n!==void 0;){let r=n.u;if(n.u=void 0,n.f&=-3,!(8&n.f)&&Ex(n))try{n.c()}catch(n){t||=(e=n,!0)}n=r}}if(Sx=0,xx--,t)throw e}let J,vx;function yx(e){let t=J;J=void 0;try{return e()}finally{J=t}}let bx,xx=0,Sx=0,Cx=0;function wx(e){if(J===void 0)return;let t=e.n;return t===void 0||t.t!==J?(t={i:0,S:e,p:J.s,n:void 0,t:J,e:void 0,x:void 0,r:t},J.s!==void 0&&(J.s.n=t),J.s=t,e.n=t,32&J.f&&e.S(t),t):t.i===-1?(t.i=0,t.n!==void 0&&(t.n.p=t.p,t.p!==void 0&&(t.p.n=t.n),t.p=J.s,t.n=void 0,J.s.n=t,J.s=t),t):void 0}function Tx(e,t){this.v=e,this.i=0,this.n=void 0,this.t=void 0,this.l=0,this.W=t?.watched,this.Z=t?.unwatched,this.name=t?.name}function Ex(e){for(let t=e.s;t!==void 0;t=t.n)if(t.S.i!==t.i||!t.S.h()||t.S.i!==t.i)return!0;return!1}function Dx(e){for(let t=e.s;t!==void 0;t=t.n){let n=t.S.n;if(n!==void 0&&(t.r=n),t.S.n=t,t.i=-1,t.n===void 0){e.s=t;break}}}function Ox(e){let t,n=e.s;for(;n!==void 0;){let e=n.p;n.i===-1?(n.S.U(n),e!==void 0&&(e.n=n.n),n.n!==void 0&&(n.n.p=e)):t=n,n.S.n=n.r,n.r!==void 0&&(n.r=void 0),n=e}e.s=t}function kx(e,t){Tx.call(this,void 0),this.x=e,this.s=void 0,this.g=Cx-1,this.f=4,this.W=t?.watched,this.Z=t?.unwatched,this.name=t?.name}function Ax(e){let t=e.m;if(e.m=void 0,typeof t==`function`){xx++;let n=J;J=void 0;try{t()}catch(t){throw e.f&=-2,e.f|=8,jx(e),t}finally{J=n,_x()}}}function jx(e){for(let t=e.s;t!==void 0;t=t.n)t.S.U(t);e.x=void 0,e.s=void 0,Ax(e)}function Mx(e){if(J!==this)throw Error(`Out-of-order effect`);Ox(this),J=e,this.f&=-2,8&this.f&&jx(this),_x()}function Nx(e,t){this.x=e,this.m=void 0,this.s=void 0,this.u=void 0,this.f=32,this.name=t?.name}function Px(e,t){let n=new Nx(e,t);try{n.c()}catch(e){throw n.d(),e}let r=n.d.bind(n);return r[Symbol.dispose]=r,r}Tx.prototype.brand=gx,Tx.prototype.h=function(){return!0},Tx.prototype.S=function(e){let t=this.t;t!==e&&e.e===void 0&&(e.x=t,this.t=e,t===void 0?yx(()=>{var e;(e=this.W)==null||e.call(this)}):t.e=e)},Tx.prototype.U=function(e){if(this.t!==void 0){let t=e.e,n=e.x;t!==void 0&&(t.x=n,e.e=void 0),n!==void 0&&(n.e=t,e.x=void 0),e===this.t&&(this.t=n,n===void 0&&yx(()=>{var e;(e=this.Z)==null||e.call(this)}))}},Tx.prototype.subscribe=function(e){return Px(()=>{let t=this.value,n=J;J=void 0;try{e(t)}finally{J=n}},{name:`sub`})},Tx.prototype.valueOf=function(){return this.value},Tx.prototype.toString=function(){return this.value+``},Tx.prototype.toJSON=function(){return this.value},Tx.prototype.peek=function(){let e=J;J=void 0;try{return this.value}finally{J=e}},Object.defineProperty(Tx.prototype,"value",{get(){let e=wx(this);return e!==void 0&&(e.i=this.i),this.v},set(e){if(e!==this.v){if(Sx>100)throw Error(`Cycle detected`);(function(e){xx!==0&&Sx===0&&e.l!==0&&(e.l=0,bx={S:e,v:e.v,i:e.i,o:bx})})(this),this.v=e,this.i++,Cx++,xx++;try{for(let e=this.t;e!==void 0;e=e.x)e.t.N()}finally{_x()}}}}),kx.prototype=new Tx,kx.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===Cx))return!0;if(this.g=Cx,this.f|=1,this.i>0&&!Ex(this))return this.f&=-2,!0;let e=J;try{Dx(this),J=this;let e=this.x();(16&this.f||this.v!==e||this.i===0)&&(this.v=e,this.f&=-17,this.i++)}catch(e){this.v=e,this.f|=16,this.i++}return J=e,Ox(this),this.f&=-2,!0},kx.prototype.S=function(e){if(this.t===void 0){this.f|=36;for(let e=this.s;e!==void 0;e=e.n)e.S.S(e)}Tx.prototype.S.call(this,e)},kx.prototype.U=function(e){if(this.t!==void 0&&(Tx.prototype.U.call(this,e),this.t===void 0)){this.f&=-33;for(let e=this.s;e!==void 0;e=e.n)e.S.U(e)}},kx.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(let e=this.t;e!==void 0;e=e.x)e.t.N()}},Object.defineProperty(kx.prototype,"value",{get(){if(1&this.f)throw Error(`Cycle detected`);let e=wx(this);if(this.h(),e!==void 0&&(e.i=this.i),16&this.f)throw this.v;return this.v}}),Nx.prototype.c=function(){let e=this.S();try{if(8&this.f||this.x===void 0)return;let e=this.x();typeof e==`function`&&(this.m=e)}finally{e()}},Nx.prototype.S=function(){if(1&this.f)throw Error(`Cycle detected`);this.f|=1,this.f&=-9,Ax(this),Dx(this),xx++;let e=J;return J=this,Mx.bind(this,e)},Nx.prototype.N=function(){2&this.f||(this.f|=2,this.u=vx,vx=this)},Nx.prototype.d=function(){this.f|=8,1&this.f||jx(this)},Nx.prototype.dispose=function(){this.d()};function Fx(e){return(typeof e.nodes==`function`?e.nodes():e.nodes)||[]}function Ix(e,...t){let n=new URL(`https://lexical.dev/docs/error`),r=new URLSearchParams;r.append(`code`,e);for(let e of t)r.append(`v`,e);throw n.search=r.toString(),Error(`Minified Lexical error #${e}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}let Lx;try{Lx=`0.49.0+prod.esm`}catch{}let Rx=Lx??`"<unknown>+source"`,zx=/* @__PURE__ */ new Set([`__proto__`,`constructor`,`prototype`]);function Bx(e,t){if(e&&t&&!Array.isArray(t)&&typeof e==`object`&&typeof t==`object`){let n=e,r=t;for(let e in r)!zx.has(e)&&Object.prototype.hasOwnProperty.call(r,e)&&(n[e]=Bx(n[e],r[e]));return e}return t}function Vx(e){return e.id===0}function Hx(e){return e.id===2}function Ux(e){return function(e){return e.id===1}(e)||Ix(305,String(e.id),`1`),Object.assign(e,{id:2})}let Wx=/* @__PURE__ */ new Set;var Gx=class{builder;configs;_dependency;_peerNameSet;extension;state;_signal;constructor(e,t){this.builder=e,this.extension=t,this.configs=/* @__PURE__ */ new Set,this.state={id:0}}mergeConfigs(){let e=this.extension.config||{},t=this.extension.mergeConfig?this.extension.mergeConfig.bind(this.extension):Qb;for(let n of this.configs)e=t(e,n);return e}init(e){let t=this.state;Hx(t)||Ix(306,String(t.id));let n={getDependency:this.getInitDependency.bind(this),getDirectDependentNames:this.getDirectDependentNames.bind(this),getPeer:this.getInitPeer.bind(this),getPeerNameSet:this.getPeerNameSet.bind(this)},r={...n,getDependency:this.getDependency.bind(this),getInitResult:this.getInitResult.bind(this),getPeer:this.getPeer.bind(this)},i=function(e,t,n){return Object.assign(e,{config:t,id:3,registerState:n})}(t,this.mergeConfigs(),n),a;this.state=i,this.extension.init&&(a=this.extension.init(e,i.config,n)),this.state=function(e,t,n){return Object.assign(e,{id:4,initResult:t,registerState:n})}(i,a,r)}build(e){let t=this.state,n;t.id!==4&&Ix(307,String(t.id),`5`),this.extension.build&&(n=this.extension.build(e,t.config,t.registerState));let r={...t.registerState,getOutput:()=>n,getSignal:this.getSignal.bind(this)};this.state=function(e,t,n){return Object.assign(e,{id:5,output:t,registerState:n})}(t,n,r)}register(e,t){this._signal=t;let n=this.state;n.id!==5&&Ix(308,String(n.id),`5`);let r=this.extension.register&&this.extension.register(e,n.config,n.registerState);return this.state=function(e){return Object.assign(e,{id:6})}(n),()=>{let e=this.state;e.id!==7&&Ix(309,String(n.id),`7`),this.state=function(e){return Object.assign(e,{id:5})}(e),r&&r()}}afterRegistration(e){let t=this.state,n;return t.id!==6&&Ix(310,String(t.id),`6`),this.extension.afterRegistration&&(n=this.extension.afterRegistration(e,t.config,t.registerState)),this.state=function(e){return Object.assign(e,{id:7})}(t),n}getSignal(){return this._signal===void 0&&Ix(311),this._signal}getInitResult(){this.extension.init===void 0&&Ix(312,this.extension.name);let e=this.state;return function(e){return e.id>=4}(e)||Ix(313,String(e.id),`4`),e.initResult}getInitPeer(e){let t=this.builder.extensionNameMap.get(e);return t?t.getExtensionInitDependency():void 0}getExtensionInitDependency(){let e=this.state;return function(e){return e.id>=3}(e)||Ix(314,String(e.id),`3`),{config:e.config}}getPeer(e){let t=this.builder.extensionNameMap.get(e);return t?t.getExtensionDependency():void 0}getInitDependency(e){let t=this.builder.getExtensionRep(e);return t===void 0&&Ix(315,this.extension.name,e.name),t.getExtensionInitDependency()}getDependency(e){let t=this.builder.getExtensionRep(e);return t===void 0&&Ix(315,this.extension.name,e.name),t.getExtensionDependency()}getState(){let e=this.state;return function(e){return e.id>=7}(e)||Ix(316,String(e.id),`7`),e}getDirectDependentNames(){return this.builder.incomingEdges.get(this.extension.name)||Wx}getPeerNameSet(){let e=this._peerNameSet;return e||(e=new Set((this.extension.peerDependencies||[]).map(([e])=>e)),this._peerNameSet=e),e}getExtensionDependency(){if(!this._dependency){let e=this.state;(function(e){return e.id>=5})(e)||Ix(317,this.extension.name),this._dependency={config:e.config,init:e.initResult,output:e.output}}return this._dependency}};let Kx={tag:Km};function qx(){let e=X_();e.isEmpty()&&e.append(u_())}let Jx=/* @__PURE__ */ Xb({config:/* @__PURE__ */ Zb({setOptions:Kx,updateOptions:Kx}),init:({$initialEditorState:e=qx})=>({$initialEditorState:e,initialized:!1}),afterRegistration(e,{updateOptions:t,setOptions:n},r){let i=r.getInitResult();if(!i.initialized){i.initialized=!0;let{$initialEditorState:r}=i;if(Qg(r))e.setEditorState(r,n);else if(typeof r==`function`)e.update(()=>{r(e)},t);else if(r&&(typeof r==`string`||typeof r==`object`)){let t=e.parseEditorState(r);e.setEditorState(t,n)}}return()=>{}},name:`@lexical/extension/InitialState`,nodes:[qg,sh,t_,vh,c_]}),Yx=Symbol.for(`@lexical/extension/LexicalBuilder`);function Xx(){}function Zx(e){throw e}function Qx(e){return Array.isArray(e)?e:[e]}let $x=Rx;var eS=class e{roots;extensionNameMap;outgoingConfigEdges;incomingEdges;conflicts;_sortedExtensionReps;PACKAGE_VERSION;constructor(e){this.outgoingConfigEdges=/* @__PURE__ */ new Map,this.incomingEdges=/* @__PURE__ */ new Map,this.extensionNameMap=/* @__PURE__ */ new Map,this.conflicts=/* @__PURE__ */ new Map,this.PACKAGE_VERSION=$x,this.roots=e;for(let t of e)this.addExtension(t)}static fromExtensions(t){let n=[Qx(Jx)];for(let e of t)n.push(Qx(e));return new e(n)}static maybeFromEditor(t){let n=t[Yx];return n&&(n.PACKAGE_VERSION!==$x&&Ix(292,n.PACKAGE_VERSION,$x),n instanceof e||Ix(293)),n}static fromEditor(t){let n=e.maybeFromEditor(t);return n===void 0&&Ix(294),n}constructEditor(){let{$initialEditorState:e,onError:t,onWarn:n,...r}=this.buildCreateEditorArgs(),i=Object.assign(g_({...r,...t?{onError:e=>{t(e,i)}}:{},...n?{onWarn:e=>{n(e,i)}}:{}}),{[Yx]:this});for(let e of this.sortedExtensionReps())e.build(i);return i}buildEditor(){let e=Xx;function t(){try{e()}finally{e=Xx}}let n=Object.assign(this.constructEditor(),{dispose:t,[Symbol.dispose]:t});return e=tx(this.registerEditor(n),()=>n.setRootElement(null)),n}hasExtensionByName(e){return this.extensionNameMap.has(e)}getExtensionRep(e){let t=this.extensionNameMap.get(e.name);if(t)return t.extension!==e&&Ix(295,e.name),t}addEdge(e,t,n){let r=this.outgoingConfigEdges.get(e);r?r.set(t,n):this.outgoingConfigEdges.set(e,/* @__PURE__ */ new Map([[t,n]]));let i=this.incomingEdges.get(t);i?i.add(e):this.incomingEdges.set(t,/* @__PURE__ */ new Set([e]))}addExtension(e){this._sortedExtensionReps!==void 0&&Ix(296);let[t]=Qx(e);typeof t.name!=`string`&&Ix(297,typeof t.name);let n=this.extensionNameMap.get(t.name);if(n!==void 0&&n.extension!==t&&Ix(298,t.name),!n){n=new Gx(this,t),this.extensionNameMap.set(t.name,n);let e=this.conflicts.get(t.name);typeof e==`string`&&Ix(299,t.name,e);for(let e of t.conflictsWith||[])this.extensionNameMap.has(e)&&Ix(299,t.name,e),this.conflicts.set(e,t.name);for(let e of t.dependencies||[]){let n=Qx(e);this.addEdge(t.name,n[0].name,n.slice(1)),this.addExtension(n)}for(let[e,n]of t.peerDependencies||[])this.addEdge(t.name,e,n?[n]:[])}}sortedExtensionReps(){if(this._sortedExtensionReps)return this._sortedExtensionReps;let e=[],t=(n,r)=>{let i=n.state;if(Hx(i))return;let a=n.extension.name;var o;Vx(i)||Ix(300,a,r||`[unknown]`),Vx(o=i)||Ix(304,String(o.id),`0`),i=Object.assign(o,{id:1}),n.state=i;let s=this.outgoingConfigEdges.get(a);if(s)for(let e of s.keys()){let n=this.extensionNameMap.get(e);n&&t(n,a)}i=Ux(i),n.state=i,e.push(n)};for(let e of this.extensionNameMap.values())Vx(e.state)&&t(e);for(let t of e)for(let[e,n]of this.outgoingConfigEdges.get(t.extension.name)||[])if(n.length>0){let t=this.extensionNameMap.get(e);if(t)for(let e of n)t.configs.add(e)}for(let[e,...t]of this.roots)if(t.length>0){let n=this.extensionNameMap.get(e.name);n===void 0&&Ix(301,e.name);for(let e of t)n.configs.add(e)}return this._sortedExtensionReps=e,this._sortedExtensionReps}registerEditor(e){let t=this.sortedExtensionReps(),n=new AbortController,r=[()=>n.abort()],i=n.signal;for(let n of t){let t=n.register(e,i);t&&r.push(t)}for(let n of t){let t=n.afterRegistration(e);t&&r.push(t)}return tx(...r)}buildCreateEditorArgs(){let e={},t=/* @__PURE__ */ new Set,n=/* @__PURE__ */ new Map,r=/* @__PURE__ */ new Map,i={},a={},o=this.sortedExtensionReps();for(let s of o){let{extension:o}=s;if(o.onError!==void 0&&(e.onError=o.onError),o.onWarn!==void 0&&(e.onWarn=o.onWarn),o.disableEvents!==void 0&&(e.disableEvents=o.disableEvents),o.parentEditor!==void 0&&(e.parentEditor=o.parentEditor),o.editable!==void 0&&(e.editable=o.editable),o.namespace!==void 0&&(e.namespace=o.namespace),o.$initialEditorState!==void 0&&(e.$initialEditorState=o.$initialEditorState),o.nodes)for(let e of Fx(o)){if(typeof e!=`function`){let t=n.get(e.replace);t&&Ix(302,o.name,e.replace.name,t.extension.name),n.set(e.replace,s)}t.add(e)}if(o.html){if(o.html.export)for(let[e,t]of o.html.export.entries())r.set(e,t);o.html.import&&Object.assign(i,o.html.import)}o.theme&&Bx(a,o.theme)}Object.keys(a).length>0&&(e.theme=a),t.size&&(e.nodes=[...t]);let s=Object.keys(i).length>0,c=r.size>0;(s||c)&&(e.html={},s&&(e.html.import=i),c&&(e.html.export=r));for(let t of o)t.init(e);return e.onError||=Zx,e}};function tS(e,t){let n=eS.maybeFromEditor(e);if(!n)return;let r=n.extensionNameMap.get(t);return r?r.getExtensionDependency():void 0}var nS=class extends Kg{$config(){return this.config(`horizontalrule`,{importDOM:{hr:()=>({conversion:rS,priority:0})}})}exportDOM(){return{element:Uv().createElement(`hr`)}}createDOM(e){let t=Uv().createElement(`hr`);return ex(t,e.theme.hr),t}getTextContent(){return`
146
- `}isInline(){return!1}updateDOM(){return!1}};function rS(){return{node:iS()}}function iS(){return Oy(nS)}Date.now;function aS(e,...t){let n=new URL(`https://lexical.dev/docs/error`),r=new URLSearchParams;r.append(`code`,e);for(let e of t)r.append(`v`,e);throw n.search=r.toString(),Error(`Minified Lexical error #${e}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}let oS;function sS(e,t){let{key:n}=t;return e&&n in e?e[n]:t.defaultValue}function cS(e){return oS&&oS.editor===e?oS:void 0}function lS(e,t){if(`cfg`in t){let{cfg:n,updater:r}=t;return[n,r(sS(e,n))]}return t}function uS(e,t){let n=t;for(let r of e){let[e,i]=lS(n,r),a=e.key;if(n===t&&sS(n,e)===i)continue;let o=n===t||n===void 0?dS(t):n;o[a]=i,n=o}return n}function dS(e){return Object.create(e||null)}function fS(e,t){return[e,t]}function pS(e,t,n,r=oy()){let i=oS,a=cS(r);try{return oS={...a,editor:r,[e]:t},n()}finally{oS=i}}function mS(e,t=()=>{}){return(n,r=oy())=>i=>{let a=cS(r),o=a&&a[e],s=uS(n,o||t(r));return s&&s!==o?pS(e,s,i,r):i()}}function hS(e,t,n,r){return Object.assign(df(Symbol(t),{isEqual:r,parse:n}),{[e]:!0})}let gS=`@lexical/html/DOM`,_S=Symbol.for(`@lexical/html/DOMExportContext`);function vS(e,t,n){return hS(_S,e,t,n)}let yS=/* @__PURE__ */ vS(`isExport`,Boolean);function bS(e){let t=tS(e,gS);return t?t.output.defaults:void 0}function xS(e){let t=tS(e,gS);return t?t.output.runtime:void 0}function SS(e=oy()){let t=xS(e);return t?t.getSessionConfig():sy(e)}let CS=mS(_S,bS),wS=Symbol.for(`@lexical/html/SelectorImpl`);function TS(e,t){let n={kind:`element`,predicate:(r=t,r.length===0?q:r.length===1?r[0]:(e,t)=>{for(let n of r)if(!n(e,t))return!1;return!0}),tags:e};var r;let i=n=>TS(e,[...t,n]);return{[wS]:n,attr:(e,t,n)=>i(OS(e,t,n)),classAll:(...e)=>i(DS(e)),classAny:(...e)=>i(function(e){let t=ES(e);return t.length===0?()=>!1:e=>{if(!q(e))return!1;let n=e.classList;for(let e of t)if(n.contains(e))return!0;return!1}}(e)),styleAny:(e,t,n)=>i(function(e,t,n){if(typeof t==`string`)return n=>q(n)&&n.style.getPropertyValue(e)===t;if(t instanceof RegExp){let r=n&&n.capture,i=t;return(t,n)=>{if(!q(t))return!1;let a=t.style.getPropertyValue(e);if(!a)return!1;let o=a.match(i);return o!==null&&(r!==void 0&&(n[r]=o),!0)}}aS(362,JSON.stringify(e))}(e,t,n))}}function ES(e){let t=[];for(let n of e)n&&t.push(n);return t}function DS(e){let t=ES(e);return t.length===0?()=>!0:e=>{if(!q(e))return!1;let n=e.classList;for(let e of t)if(!n.contains(e))return!1;return!0}}function OS(e,t,n){if(!0===t)return t=>q(t)&&t.hasAttribute(e);if(typeof t==`string`)return n=>q(n)&&n.getAttribute(e)===t;if(t instanceof RegExp){let r=n&&n.capture,i=t;return(t,n)=>{if(!q(t))return!1;let a=t.getAttribute(e);if(a==null)return!1;let o=a.match(i);return o!==null&&(r!==void 0&&(n[r]=o),!0)}}aS(361,JSON.stringify(e))}let kS={kind:`text`,predicate:P_,tags:/* @__PURE__ */ new Set},AS={[wS]:kS},jS={kind:`comment`,predicate:e=>e.nodeType===8,tags:/* @__PURE__ */ new Set},MS={[wS]:jS},NS={any:()=>TS(/* @__PURE__ */ new Set,[]),comment:()=>MS,tag(...e){e.length>0||aS(363);let t=/* @__PURE__ */ new Set;for(let n of e)t.add(n.toUpperCase());return TS(t,[])},text:()=>AS},PS=NS;PS.tag(`b`,`strong`,`em`,`i`,`code`,`mark`,`s`,`sub`,`sup`,`u`,`span`),PS.text(),PS.tag(`script`,`style`),PS.tag(`br`),PS.tag(`p`),PS.tag(`hr`),PS.any(),Object.freeze([]),Object.freeze({}),NS.any(),NS.any,NS.comment,NS.tag,NS.text;function FS(e,t=null,n=oy()){return CS([fS(yS,!0)],n)(()=>{let r=X_(),i=SS(n),a=B(t)?Ry(t.anchor.getNode()):null,o=e.append.bind(e);for(let e of(U(a)?a:r).getChildren())LS(n,e,o,t,i);return e})}function IS(e,t=null){return(typeof document>`u`||typeof window>`u`&&global.window===void 0)&&aS(338),Dg(e),FS(Uv().createElement(`div`),t,e).innerHTML}function LS(e,t,n,r=null,i=sy(e)){let a=i.$shouldInclude(t,r,e),o=i.$shouldExclude(t,r,e),s=t;r!==null&&z(t)&&(s=cx(r,t,`clone`));let{element:c,after:l,append:u,$getChildNodes:d}=i.$exportDOM(s,e);if(!c)return!1;let f=Uv().createDocumentFragment(),p=d?d():U(s)?s.getChildren():[],m=a&&Ah(r)&&U(t)?null:r,h=f.append.bind(f);for(let n of p){let o=LS(e,n,h,m,i);!a&&o&&i.$extractWithChild(t,n,r,`html`,e)&&(a=!0)}if(a&&!o){if((q(c)||ey(c))&&(u?u(f):c.append(f)),n(c),l){let e=l.call(s,c);e&&(ey(c)?c.replaceChildren(e):c.replaceWith(e))}}else n(f);return a}function RS(e,t,n=null){let r=Hv(n),i=n?Bv(n):[],a=n!==null&&i.length>0;if(a&&typeof r.caretPositionFromPoint==`function`){let a=r.caretPositionFromPoint(e,t,{shadowRoots:i});if(a!==null&&function(e,t){for(let n=e;n!==null;){if(n===t)return!0;n=yv(n)}return!1}(a.offsetNode,n))return{node:a.offsetNode,offset:a.offset}}if(a){let i=n.getRootNode();if(Rv(i)){let a=i.elementFromPoint(e,t);if(a!==null&&n.contains(a)){let n=function(e,t,n,r){let i=r.createRange(),a=e=>t<e.top?e.top-t:t>e.bottom?t-e.bottom:0,o=t=>e<t.left?t.left-e:e>t.right?e-t.right:0,s=r.createTreeWalker(n,NodeFilter.SHOW_TEXT),c=null,l=1/0,u=1/0;for(let e=s.nextNode();e;e=s.nextNode()){i.selectNodeContents(e);for(let t of i.getClientRects()){let n=a(t),r=o(t);(n<l||n===l&&r<u)&&(l=n,u=r,c=e)}}if(c===null)return null;let d=0,f=1/0,p=1/0;for(let t=0;t<=c.length;t++){i.setStart(c,t),i.collapse(!0);let n=i.getBoundingClientRect(),r=a(n),o=Math.abs(e-n.left);(r<f||r===f&&o<p)&&(f=r,p=o,d=t)}return{node:c,offset:d}}(e,t,a,r);if(n!==null)return n}}}if(typeof r.caretRangeFromPoint==`function`){let n=r.caretRangeFromPoint(e,t);return n===null?null:{node:n.startContainer,offset:n.startOffset}}if(typeof r.caretPositionFromPoint==`function`){let n=r.caretPositionFromPoint(e,t);return n===null?null:{node:n.offsetNode,offset:n.offset}}return null}function zS(e,...t){let n=new URL(`https://lexical.dev/docs/error`),r=new URLSearchParams;r.append(`code`,e);for(let e of t)r.append(`v`,e);throw n.search=r.toString(),Error(`Minified Lexical error #${e}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}function BS(e,t=V()){return t??zS(166),B(t)&&t.isCollapsed()||t.getNodes().length===0?``:IS(e,t)}function VS(e,t){let n=e.getData(`text/plain`)||e.getData(`text/uri-list`);n!=null&&t.insertRawText(n)}let HS=`application/x-lexical-drag`;function US(e,t){let n={editorKey:t.getKey()};e.setData(HS,JSON.stringify(n))}function WS(e,t,n){let r=e.dataTransfer;if(r===null)return!1;let i=function(e){let t=e.getData(HS);if(!t)return null;let n;try{n=JSON.parse(t)}catch{return null}return(r=n)!==null&&typeof r==`object`&&`editorKey`in r&&typeof r.editorKey==`string`?n:null;var r}(r);if(i===null)return!1;let a=function(e,t){let n=RS(e.clientX,e.clientY,t.getRootElement());if(n===null)return null;let r=q_(n.node);if(r===null)return null;if(z(r))return hb(r,`next`,n.offset);if(U(r))return Gb(r,n.offset,`next`);let i=r.getParent();return i===null?null:Gb(i,r.getIndexWithinParent()+1,`next`)}(e,t);if(a===null)return!1;let o=Jb(a);if(o===null)return!1;let s=i.editorKey===t.getKey(),c=V();if(s){if(!B(c)||c.isCollapsed())return!1;if(function(e,t){let{anchor:n,focus:r}=Wb(Ib(t),`next`);return Db(n,e)<0&&Db(e,r)<0}(a,c))return e.preventDefault(),!0;c.removeText()}if(!o.origin.isAttached())return e.preventDefault(),!0;if(n(r,Pb(wb(o)),t),!s){let e=t.getRootElement(),n=e?e.ownerDocument:null,r=n?function(e,t){for(let n of Vv(t)){let t=j_(n);if(k_(t)&&t.getKey()===e&&q(n))return n}return null}(i.editorKey,n):null;r!==null&&r.dispatchEvent(new InputEvent(`beforeinput`,{bubbles:!0,cancelable:!0,inputType:`deleteByDrag`}))}return e.preventDefault(),!0}function GS(e,t){return WS(e,t,(e,t)=>VS(e,t))}function KS(e,t){t.update(()=>{if(e!==null){let n=hx(e,KeyboardEvent)?null:e.clipboardData,r=V();if(r!==null&&!r.isCollapsed()&&n!=null){e.preventDefault();let i=BS(t);i!==null&&n.setData(`text/html`,i),n.setData(`text/plain`,r.getTextContent())}}})}function qS(e){return tx(e.registerCommand(Ep,e=>{let t=V();return!!B(t)&&(t.deleteCharacter(e),!0)},0),e.registerCommand(Mp,e=>{let t=V();return!!B(t)&&(t.deleteWord(e),!0)},0),e.registerCommand(Np,e=>{let t=V();return!!B(t)&&(t.deleteLine(e),!0)},0),e.registerCommand(kp,e=>{let t=V();if(!B(t))return!1;if(typeof e==`string`)t.insertText(e);else{let n=e.dataTransfer;if(n!=null)VS(n,t);else{let n=e.data;n&&t.insertText(n)}}return!0},0),e.registerCommand(jp,()=>{let e=V();return!!B(e)&&(e.removeText(),!0)},0),e.registerCommand(Dp,e=>{let t=V();return!!B(t)&&(t.insertLineBreak(e),!0)},0),e.registerCommand(Op,()=>{let e=V();return!!B(e)&&(e.insertLineBreak(),!0)},0),e.registerCommand(Bp,e=>{let t=V();if(!B(t))return!1;let n=e,r=n.shiftKey;return!!dx(t,!0)&&(n.preventDefault(),mx(t,r,!0),!0)},0),e.registerCommand(Rp,e=>{let t=V();if(!B(t))return!1;let n=e,r=n.shiftKey;return!!dx(t,!1)&&(n.preventDefault(),mx(t,r,!1),!0)},0),e.registerCommand(Kp,t=>!!B(V())&&(!wd||!Cd)&&(t.preventDefault(),e.dispatchCommand(Ep,!0)),0),e.registerCommand(Jp,t=>!!B(V())&&(t.preventDefault(),e.dispatchCommand(Ep,!1)),0),e.registerCommand(Wp,t=>{if(!B(V()))return!1;if(t!==null){if((wd||Ed||kd)&&Cd)return!1;t.preventDefault()}return e.dispatchCommand(Dp,!1)},0),e.registerCommand(nm,()=>{let e=V();return fv(B(e)&&Ry(e.anchor.getNode())!==null?e:null),!0},0),e.registerCommand(em,t=>!!B(V())&&(KS(t,e),!0),0),e.registerCommand(tm,t=>!!B(V())&&(function(e,t){KS(e,t),t.update(()=>{let e=V();B(e)&&e.removeText()},{tag:`cut`})}(t,e),!0),0),e.registerCommand(Ap,t=>!!B(V())&&(function(e,t){e.preventDefault(),t.update(()=>{let t=V(),n=hx(e,ClipboardEvent)?e.clipboardData:null;n!=null&&B(t)&&VS(n,t)},{tag:`paste`})}(t,e),!0),0),e.registerCommand(Xp,t=>GS(t,e),0),e.registerCommand(Zp,t=>{let n=V();return!!B(n)&&(n.isCollapsed()||t.dataTransfer===null||US(t.dataTransfer,e),!0)},0))}function JS(e,t,n,r,i){if(e===null||n.size===0&&r.size===0&&!i)return 0;let a=t._selection,o=e._selection;if(i)return 1;if(!(B(a)&&B(o)&&o.isCollapsed()&&a.isCollapsed()))return 0;let s=function(e,t,n){let r=e._nodeMap,i=[];for(let e of t){let t=r.get(e);t!==void 0&&i.push(t)}for(let[e,t]of n){if(!t)continue;let n=r.get(e);n===void 0||Jg(n)||i.push(n)}return i}(t,n,r);if(s.length===0)return 0;if(s.length>1){let n=t._nodeMap,r=n.get(a.anchor.key),i=n.get(o.anchor.key);return r&&i&&!e._nodeMap.has(r.__key)&&z(r)&&r.__text.length===1&&a.anchor.offset===1?2:0}let c=s[0],l=e._nodeMap.get(c.__key);if(!z(l)||!z(c)||l.__mode!==c.__mode)return 0;let u=l.__text,d=c.__text;if(u===d)return 0;let f=a.anchor,p=o.anchor;if(f.key!==p.key||f.type!==`text`)return 0;let m=f.offset,h=p.offset,g=d.length-u.length;return g===1&&h===m-1?2:g===-1&&h===m+1?3:g===-1&&h===m?4:0}function YS(e,t,n){let r=n(),i=0,a=r,o=0,s=null;return(c,l,u,d,f,p)=>{let m=n();if(p.has(`composition-start`)&&(a=r,o=i,s=c),p.has(`historic`))return i=0,r=m,2;p.has(`composition-end`)&&s&&(r=a,i=o,c=s);let h=p.has(`paste`)||p.has(`cut`)?0:JS(c,l,d,f,e.isComposing()),g=(()=>{let n=u===null||u.editor===e,a=p.has(`history-push`);if(!a&&n&&p.has(`history-merge`))return 0;if(h===1)return 2;if(c===null)return 1;let o=l._selection;if(!(d.size>0||f.size>0))return o===null?2:0;let s=typeof t==`number`?t:t.peek();return!1===a&&h!==0&&h===i&&m<r+s&&n||d.size===1&&function(e,t,n){let r=t._nodeMap.get(e),i=n._nodeMap.get(e),a=t._selection,o=n._selection;return!(B(a)&&B(o)&&a.anchor.type===`element`&&a.focus.type===`element`&&o.anchor.type===`text`&&o.focus.type===`text`||!z(r)||!z(i)||r.__parent!==i.__parent)&&JSON.stringify(t.read(()=>r.exportJSON()))===JSON.stringify(n.read(()=>i.exportJSON()))}(Array.from(d)[0],c,l)?0:1})();return r=m,i=h,g}}function XS(e,t){e.undoStack=[],e.redoStack=[],e.current=null,t&&t(e)}function ZS(e,t,n,r=Date.now,i,a=null){let o=YS(e,n,r),s=()=>{i&&i(t)};return s(),tx(e.registerCommand(Fp,()=>(function(e,t,n){let r=t.redoStack,i=t.undoStack;if(i.length!==0){let a=t.current,o=i.pop();a!==null&&(r.push(a),e.dispatchCommand(am,!0)),i.length===0&&e.dispatchCommand(om,!1),t.current=o||null,n&&n(t),o&&o.editor.setEditorState(o.editorState,{tag:`historic`})}}(e,t,i),!0),0),e.registerCommand(Ip,()=>(function(e,t,n){let r=t.redoStack,i=t.undoStack;if(r.length!==0){let a=t.current;a!==null&&(i.push(a),e.dispatchCommand(om,!0));let o=r.pop();r.length===0&&e.dispatchCommand(am,!1),t.current=o||null,n&&n(t),o&&o.editor.setEditorState(o.editorState,{tag:`historic`})}}(e,t,i),!0),0),e.registerCommand(rm,()=>(XS(t,i),!1),0),e.registerCommand(im,()=>(XS(t,i),e.dispatchCommand(am,!1),e.dispatchCommand(om,!1),!0),0),e.registerUpdateListener(({editorState:n,prevEditorState:r,dirtyLeaves:i,dirtyElements:c,tags:l})=>{let u=t.current,d=t.redoStack,f=t.undoStack,p=u===null?null:u.editorState;if(u!==null&&n===p)return;let m=o(r,n,u,i,c,l);if(m===1){if(d.length!==0&&(t.redoStack=[],e.dispatchCommand(am,!1)),u!==null){f.push({...u});let t=typeof a==`number`||a===null?a:a.peek();t!==null&&f.length>t&&f.splice(0,f.length-t),e.dispatchCommand(om,!0)}}else if(m===2)return;t.current={editor:e,editorState:n},s()}))}function QS(){return{current:null,redoStack:[],undoStack:[]}}Date.now;let $S=`application/x-codexhost-thread-reference`,eC=/^remote-(?:peer:|ssh(?:-|:)|control:).+/u;function tC(e){let t=e.projectionValues?.threadReference;if(!e.blank&&t?.hostId&&(t.hostId===`local`||eC.test(t.hostId)&&t.threadId))return{threadId:t.threadId??e.id,hostId:t.hostId,title:e.title?.replace(/[\s\u0000-\u001f\u007f]+/gu,` `).trim()||e.id.slice(0,8)}}function nC(e){return`thread://${encodeURIComponent(e.threadId).replace(/[!'()*]/gu,e=>`%${e.charCodeAt(0).toString(16).toUpperCase()}`)}?hostId=${encodeURIComponent(e.hostId)}`}function rC(e){if(e.trim()!==e)return;let t=/^codex:\/\/threads\/([^/?#\s<>]+)$/u.exec(e)??/^thread:\/\/([^/?#\s<>]+)\?hostId=([^&#\s]+)$/u.exec(e);if(t?.[1]!==void 0)try{let e=decodeURIComponent(t[1]),n=decodeURIComponent(t[2]??`local`);if(!e||!n||/[\u0000-\u001f\u007f]/u.test(e+n))return;if(n===`local`)return e;if(!eC.test(n))return;let r=new TextEncoder().encode(JSON.stringify([n,e]));return`web-remote:`+btoa(Array.from(r,e=>String.fromCharCode(e)).join(``)).replaceAll(`+`,`-`).replaceAll(`/`,`_`).replace(/=+$/u,``)}catch{return}}function iC(e){let t=`[@${e.title.replace(/[\\`*{}[\]()#+.!_<>|~-]/gu,e=>`\\${e}`)}](${nC(e)})`;return{source:`codexhost-thread`,ref:t,label:e.title,appearance:`session`,clipboardText:t}}function aC(e){try{let t=JSON.parse(e);if(typeof t!=`object`||!t)return;let{threadId:n,hostId:r,title:i}=t;return typeof n!=`string`||!n||typeof r!=`string`||!r||r!==`local`&&!eC.test(r)||typeof i!=`string`?void 0:tC({id:n,blank:!1,title:i,projectionValues:{threadReference:{hostId:r,threadId:n}}})}catch{return}}function oC(e){var t,n,r=``;if(typeof e==`string`||typeof e==`number`)r+=e;else if(typeof e==`object`){if(Array.isArray(e)){var i=e.length;for(t=0;t<i;t++)e[t]&&(n=oC(e[t]))&&(r&&(r+=` `),r+=n)}else for(n in e)e[n]&&(r&&(r+=` `),r+=n)}return r}function sC(){for(var e,t,n=0,r=``,i=arguments.length;n<i;n++)(e=arguments[n])&&(t=oC(e))&&(r&&(r+=` `),r+=t);return r}let cC=`@deepseek-ai/dsh-client-ui-conversation/ReferenceChip.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(cC)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-conversation`,e.dataset.pluginCss=cC,e.textContent=`.s8J5YG_chip{max-width:240px;color:var(--dsw-alias-state-business-primary);user-select:none;align-items:baseline;gap:3px;display:inline-flex}.s8J5YG_marker{flex:none;font-weight:500}.s8J5YG_icon{flex:none;align-self:center}.s8J5YG_label{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.s8J5YG_invalid{color:var(--dsw-alias-state-error-primary);opacity:.7;text-decoration:line-through}`,document.head.appendChild(e)}var lC={chip:`s8J5YG_chip`,icon:`s8J5YG_icon`,invalid:`s8J5YG_invalid`,label:`s8J5YG_label`,marker:`s8J5YG_marker`};let uC=`@deepseek-ai/dsh-client-ui-conversation/composer-editor.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(uC)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-conversation`,e.dataset.pluginCss=uC,e.textContent=`._VTzna_reference{border-radius:var(--dsw-radius-sm);line-height:inherit;vertical-align:baseline;color:var(--dsw-alias-state-business-primary);-webkit-box-decoration-break:clone;box-decoration-break:clone;background:0 0;padding:0 4px}._VTzna_reference:hover{background:var(--dsw-alias-state-business-tertiary)}._VTzna_openable{cursor:pointer}._VTzna_textRef{max-width:100%;display:inline-block}`,document.head.appendChild(e)}var dC={openable:`_VTzna_openable`,reference:`_VTzna_reference`,textRef:`_VTzna_textRef`};function fC({label:e,reference:t,appearance:n,invalid:r}){return/* @__PURE__ */ (0,h.jsxs)(`span`,{className:sC(dC.reference,lC.chip,n===`file`&&!r&&dC.openable,r&&lC.invalid),title:e,children:[n===void 0?/* @__PURE__ */ (0,h.jsx)(`span`,{className:lC.marker,"aria-hidden":!0,children:`@`}):/* @__PURE__ */ (0,h.jsx)(d.ReferenceIconRegular,{kind:n,reference:t,size:14,className:lC.icon}),/* @__PURE__ */ (0,h.jsx)(`span`,{className:lC.label,children:e})]})}var pC=class e extends Kg{__source;__ref;__label;__appearance;__clipboardText;__invalid;static getType(){return`reference-chip`}static clone(t){return new e({source:t.__source,ref:t.__ref,label:t.__label,appearance:t.__appearance,clipboardText:t.__clipboardText},t.__invalid,t.__key)}static importJSON(t){return new e({source:t.source,ref:t.ref,label:t.label,appearance:t.appearance,clipboardText:t.clipboardText},t.invalid)}constructor(e,t=!1,n){super(n),this.__source=e.source,this.__ref=e.ref,this.__label=e.label,this.__appearance=e.appearance,this.__clipboardText=e.clipboardText,this.__invalid=t}exportJSON(){return{...super.exportJSON(),type:`reference-chip`,version:1,source:this.__source,ref:this.__ref,label:this.__label,...this.__appearance===void 0?{}:{appearance:this.__appearance},clipboardText:this.__clipboardText,invalid:this.__invalid}}createDOM(e){let t=document.createElement(`span`);return t.setAttribute(`data-composer-chip`,this.__source),t.setAttribute(`contenteditable`,`false`),t}updateDOM(){return!1}isInline(){return!0}isKeyboardSelectable(){return!1}getTextContent(){return this.__clipboardText}setInvalid(e){let t=this.getWritable();t.__invalid=e}isInvalid(){return this.getLatest().__invalid}getSource(){return this.getLatest().__source}getReference(){return this.getLatest().__ref}getLabel(){return this.getLatest().__label}getAppearance(){return this.getLatest().__appearance}decorate(){return/* @__PURE__ */ (0,h.jsx)(fC,{label:this.__label,reference:this.__ref,appearance:this.__appearance,invalid:this.__invalid})}};function mC(e){return new pC(e)}function hC(e){return e instanceof pC}function gC(e,...t){let n=new URL(`https://lexical.dev/docs/error`),r=new URLSearchParams;r.append(`code`,e);for(let e of t)r.append(`v`,e);throw n.search=r.toString(),Error(`Minified Lexical error #${e}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}function _C(e,t,n,r){let i=e=>e instanceof n,a=e=>{let t=gh(e.getTextContent());t.setFormat(e.getFormat()),e.replace(t)};return[e.registerNodeTransform(sh,e=>{if(!e.isSimpleText())return;let n,o=e.getPreviousSibling(),s=e.getTextContent(),c=e;if(z(o)){let n=o.getTextContent(),r=t(n+s);if(i(o)){if(r===null||(e=>e.getLatest().__mode)(o)!==0)return void a(o);{let t=r.end-n.length;if(t>0){let r=n+s.slice(0,t);if(o.select(),o.setTextContent(r),t===s.length)e.remove();else{let n=s.slice(t);e.setTextContent(n)}return}}}else if(r===null||r.start<n.length)return}let l=0;for(;;){n=t(s);let e,u=n===null?``:s.slice(n.end);if(s=u,u===``){let e=c.getNextSibling();if(z(e)){u=c.getTextContent()+e.getTextContent();let n=t(u);if(n===null)return void(i(e)?a(e):e.markDirty());if(n.start!==0)return}}if(n===null)return;if(n.start===0&&z(o)&&o.isTextEntity()){l+=n.end;continue}n.start===0?[e,c]=c.splitText(n.end):[,e,c]=c.splitText(n.start+l,n.end+l),e===void 0&&gC(165,`nodeToReplace`);let d=r(e);if(d.setFormat(e.getFormat()),e.replace(d),c==null)return;l=0,o=d}}),e.registerNodeTransform(n,e=>{let n=e.getTextContent(),r=t(n);if(r===null||r.start!==0)return void a(e);if(n.length>r.end)return void e.splitText(r.end);let o=e.getPreviousSibling();z(o)&&o.isTextEntity()&&(a(o),a(e));let s=e.getNextSibling();z(s)&&s.isTextEntity()&&(a(s),i(e)&&a(e))})]}let vC=/(^|\s)([/@])([\w-]+)/g,yC=/(^|\s)(@(?:"[^"\n]*"?|[^\s"]\S*))/g,bC=/* @__PURE__ */ new Set(`.,;:!?,。;:!?`),xC=/^@.*[/\\.]/u;function SC(e,t,n){if(!n.startsWith(`@"`)){let e=n.length;for(;bC.has(n.charAt(e-1));)--e;return xC.test(n.slice(0,e))?t+e:void 0}if(n.length>3&&n.endsWith(`"`))return t+n.length;let r=n.lastIndexOf(`/`);if(r<0)return;let i=t+r+1;for(;bC.has(e.charAt(i));)i+=1;return i===e.length||/\s/u.test(e.charAt(i))?t+r+1:void 0}let CC=/^(?:\s|$)/;function wC(e,t){if(e===``)return[];let n=[];vC.lastIndex=0;let r;for(;(r=vC.exec(e))!==null;){let i=r[2],a=r[3]??``;if((i!==`/`||CC.test(e.slice(r.index+r[0].length)))&&t.get(i)?.includes(a)){let e=r.index+(r[1]?.length??0);n.push({start:e,end:e+1+a.length,trigger:i})}}yC.lastIndex=0;let i;for(;(i=yC.exec(e))!==null;){let t=i.index+(i[1]?.length??0),r=SC(e,t,i[2]??``);r!==void 0&&!n.some(e=>e.start<r&&e.end>t)&&n.push({start:t,end:r,trigger:`@`})}return n.sort((e,t)=>e.start-t.start)}var TC=class e extends sh{static getType(){return`composer-text-ref`}static clone(t){return new e(t.__text,t.__key)}static importJSON(t){let n=new e(t.text);return n.setFormat(t.format),n.setDetail(t.detail),n.setMode(t.mode),n.setStyle(t.style),n}exportJSON(){return{...super.exportJSON(),type:`composer-text-ref`}}createDOM(e){let t=super.createDOM(e);return t.className=sC(t.className,dC.reference,dC.textRef,this.getTextContent().startsWith(`/`)&&dC.openable),t.setAttribute(`spellcheck`,`false`),t.setAttribute(`data-composer-text-ref`,``),t}isTextEntity(){return!0}canInsertTextBefore(){return!0}};function EC(e,t,n){return tx(..._C(e,e=>{let r=n();for(let n of wC(e,t()))if(r===null||n.start!==0||e.slice(n.start,n.end)!==r.trimEnd())return{start:n.start,end:n.end};return null},TC,e=>new TC(e.getTextContent())))}function DC(e){e.update(()=>{for(let e of X_().getAllTextNodes())(e instanceof TC||e.getPreviousSibling()instanceof TC||/[/@]/u.test(e.getTextContent()))&&e.markDirty()},{tag:Km})}function OC(e,t){return e.registerCommand(xp,e=>{if(e.target===null||e.button!==0||e.detail>1)return!1;let n=V();if(B(n)&&!n.isCollapsed())return!1;let r=q_(e.target);if(hC(r)){if(r.isInvalid())return!1;let e=r.getAppearance();return t(r.getSource(),{ref:r.getReference(),...e===void 0?{}:{appearance:e}})}return r instanceof TC&&t(void 0,{ref:r.getTextContent()})},1)}function kC(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 AC=ru([D(),O(),k(),Yl()]);function jC(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 MC=Lu(jC,{message:`JSON value must not contain circular references`}),NC=Fu(()=>ru([AC,A(NC),du(D(),NC)])),PC=MC.pipe(NC);MC.pipe(A(NC));let FC=MC.pipe(du(D(),NC)),IC=M({code:D().min(1),message:D().min(1),retryable:k(),diagnostic:D().min(1).optional(),stage:D().min(1).optional(),durationMs:O().int().nonnegative().optional(),stderrTail:D().min(1).optional()}).superRefine(kC([`diagnostic`,`stage`,`durationMs`,`stderrTail`])),LC=D().max(64).regex(/^[a-z]{2,3}(?:-[A-Za-z0-9]{2,8})*$/u),RC=e=>D().min(1).max(e).refine(e=>e.trim().length>0),zC=du(LC,j({label:RC(256).optional(),description:RC(1024).optional()}).strict()).refine(e=>Object.keys(e).length<=16,`Too many locales`),BC=du(LC,RC(4096)).refine(e=>typeof e.en==`string`,`English fallback is required`).refine(e=>Object.keys(e).length<=16,`Too many locales`),VC=D().refine(e=>e.trim().length>0,{message:`Identifier must not be empty or whitespace`}),HC=VC.brand(),Y=VC.brand(),UC=VC.brand();VC.brand(),VC.brand();let WC=D().refine(e=>e.trim().length>0,{message:`Value must not be empty or whitespace`}),GC=WC.max(128).regex(/^[A-Za-z0-9._~:-]+$/u,`Permission Mode ID must use transport-safe characters`).brand(),KC=j({modes:A(j({id:GC,label:WC.max(256),description:WC.max(1024).optional(),dangerous:k().optional(),localizations:zC.optional()}).strict()).min(1).max(32),defaultModeId:GC}).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`]})});j({threadId:Y,permissionModeId:GC}).strict();let qC=D().refine(e=>e.trim().length>0,{message:`Value must not be empty or whitespace`});j({sourceThreadId:Y,lastTurnId:UC.optional(),targetHarnessId:HC,targetModel:qC.max(1024).optional(),targetThinkingOptionId:qC.max(128).regex(/^[A-Za-z0-9._~-]+$/u,`Thinking option ID must use transport-safe characters`).optional()}).strict();let JC=j({sourceThreadId:Y,sourceHarnessId:HC,sourceHarnessLabel:qC.max(256).optional(),sourceModel:qC.max(1024).optional(),targetHarnessId:HC,targetHarnessLabel:qC.max(256).optional(),targetModel:qC.max(1024).optional(),totalTurns:O().int().min(1),boundaryTurnNumber:O().int().min(1),includedTurnNumbers:A(O().int().min(1)),omittedTurns:O().int().min(0),preview:D().max(32e3),createdAtMs:O().int().nonnegative()}).strict();j({threadId:Y,handoff:JC}).strict();let YC=O().int().safe().nonnegative(),XC=O().finite().nonnegative(),ZC=O().finite().min(0).max(100),QC=j({version:ru([P(3),P(4)]).optional(),requestId:D().min(1),turnId:D().min(1).max(1024),outputTokens:YC,startedAtMs:YC,completedAtMs:YC}).strict().refine(e=>e.completedAtMs>e.startedAtMs),$C=j({version:ru([P(2),P(3),P(4)]).optional(),value:XC,turnId:D().min(1).max(1024),at:YC}).strict();j({outputTimings:A(QC).transform(e=>e.filter(e=>e.version===4)).optional(),outputTokensPerSecond:$C.refine(e=>e.version===4).optional().catch(void 0),timeToFirstOutputMs:$C.extend({value:YC}).optional()}).strict();let ew=e=>BC.refine(t=>Object.values(t).every(t=>t.length<=e)),tw=j({composerIndicators:A(j({kind:P(`countdown`),id:D().min(1).max(64),expiresAtUnix:YC,label:ew(256).optional(),tooltip:ew(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:YC.optional(),cachedInputTokens:YC.optional(),cacheWriteInputTokens:YC.optional(),outputTokens:YC.optional(),outputTokensPerSecond:XC.optional(),sessionOutputTokensPerSecond:XC.optional(),apiOutputTokensPerSecond:XC.optional(),reasoningOutputTokens:YC.optional(),totalTokens:YC.optional(),totalCostUsd:XC.optional(),totalCredits:XC.optional(),contextUsagePercent:XC.optional(),cacheHitRatePercent:ZC.optional(),contextWindowTokens:YC.optional(),contextUsedTokens:YC.optional(),planFiveHourUsedPercent:ZC.optional(),planFiveHourResetsAtUnix:YC.optional(),planSevenDayUsedPercent:ZC.optional(),planSevenDayResetsAtUnix:YC.optional(),sessionCacheHitRatePercent:ZC.optional(),timeToFirstOutputMs:YC.optional(),latestRequestTimeToFirstOutputMs:YC.optional(),costSource:N([`publicPrice`,`native`]).optional(),unpricedModels:A(D().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`]})}),nw=O().finite().min(0).max(100),rw=N([`weekly`,`monthly`,`five_hour`,`seven_day`,`unknown`]),iw=j({id:D().min(1).max(256),label:D().min(1).max(256),localizations:zC.optional()}).strict(),aw=j({product:D().min(1),periodType:rw.optional(),scope:iw.optional(),localizations:zC.optional(),used:O().finite().nonnegative().optional(),limit:O().finite().nonnegative().optional(),unit:D().min(1).max(32).optional(),usagePercent:nw,resetsAt:D().min(1).optional()}).strict(),ow=j({availableCount:O().int().safe().positive(),nextExpiresAt:D().min(1).optional(),expiresAt:A(D().min(1)).min(1).max(32).optional()}).strict(),sw=j({used:O().finite().nonnegative().optional(),limit:O().finite().nonnegative().optional(),unit:D().min(1).max(32).optional(),label:D().min(1).optional(),scope:iw.optional(),localizations:zC.optional(),usedPercent:nw,resetsAt:D().min(1).optional(),periodType:rw,productUsage:A(aw).min(1).optional(),resetCredits:ow.optional()}).strict(),cw=j({amount:O().finite().nonnegative(),currency:D().trim().min(1).max(8),label:D().trim().min(1).max(128).optional()}).strict();j({threadId:Y,refresh:P(`exact`).optional()}).strict(),j({threadId:Y,usage:tw.nullable(),accountCredits:sw.optional(),accountBalance:cw.optional(),accountCreditsSupported:k().optional()}).strict();let lw=D().refine(e=>e.trim().length>0,{message:`Value must not be empty or whitespace`}),uw=D().min(1).max(512).refine(e=>!/\p{Cc}/u.test(e),`Model Ref must not contain control characters`).brand(),dw=N([`priority`,`ultrafast`]),fw=j({id:uw,serviceTier:dw.optional()}).strict();function pw(e,t){return e?.id===t?.id&&e?.serviceTier===t?.serviceTier}let mw=lw.max(128).regex(/^[A-Za-z0-9._~-]+$/u,`Thinking option ID must use transport-safe characters`).brand(),hw=lw.max(256),gw=j({id:mw,label:lw.max(256)}).strict(),_w=j({ref:fw,label:lw.max(256),resolvedModelLabel:hw.optional(),fastModel:fw.optional(),supportedThinkingOptionIds:A(mw).optional()}).strict().refine(e=>e.fastModel?.serviceTier===void 0||e.fastModel.id===e.ref.id,{path:[`fastModel`,`id`],message:`A tiered Fast Model must share the base Model ID`});function vw(e,t){if(t)return e?.models.find(e=>pw(e.ref,t)||pw(e.fastModel,t))}let yw=A(gw).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)}),bw=N([`catalog`,`activeModel`]),xw=j({models:A(_w),defaultModel:fw.optional(),thinkingOptions:yw,defaultThinkingOptionId:mw.optional(),thinkingOptionsScope:bw.optional()}).strict().superRefine((e,t)=>{let n=[],r=new Set(e.thinkingOptions.map(({id:e})=>e));for(let[i,a]of e.models.entries()){n.some(e=>pw(e,a.ref))&&t.addIssue({code:`custom`,message:`Model Catalog refs must be unique`,path:[`models`,i,`ref`,`id`]}),n.push(a.ref),a.fastModel&&(n.some(e=>pw(e,a.fastModel))&&t.addIssue({code:`custom`,message:`Fast Model refs must be distinct and unique`,path:[`models`,i,`fastModel`]}),n.push(a.fastModel));let e=/* @__PURE__ */ new Set;for(let[n,o]of(a.supportedThinkingOptionIds??[]).entries())e.has(o)&&t.addIssue({code:`custom`,message:`Supported Thinking option IDs must be unique per Model`,path:[`models`,i,`supportedThinkingOptionIds`,n]}),e.add(o),r.has(o)||t.addIssue({code:`custom`,message:`Supported Thinking option must exist in the catalog`,path:[`models`,i,`supportedThinkingOptionIds`,n]})}e.defaultModel&&!vw(e,e.defaultModel)&&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`]})}),Sw=j({fork:k(),forkAcrossCwd:k(),rollbackLastTurn:k()}).strict().refine(e=>e.fork||!e.forkAcrossCwd,{path:[`forkAcrossCwd`],message:`Cross-cwd Fork requires exact history Fork support`}),Cw=N([`live`,`atCreate`]),ww=j({configuration:j({selectModel:k(),selectThinkingOption:k(),selectPermissionMode:k(),permissionModeScope:Cw.default(`live`)}).strict(),history:Sw,subagents:j({observe:k(),readTranscript:k()}).strict().optional(),autonomousTurns:j({observe:k()}).strict().optional(),steer:k().optional(),persistentPlan:k().optional()}).strict();j({effectiveModel:fw.optional(),resolvedModelLabel:hw.optional(),effectiveThinkingOptionId:mw.optional(),availableThinkingOptions:yw.optional(),effectivePermissionModeId:GC.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 Tw=j({open:P(!0)}).strict();ru([j({status:P(`ready`),catalog:xw,permissionModes:KC.optional(),capabilities:ww,webUi:Tw.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`]})}),j({status:N([`notInstalled`,`unavailable`,`error`]),error:IC}).strict()]),j({harnessId:HC,cwd:lw.max(16384).optional(),refresh:k().optional(),purpose:P(`availability`).optional(),credentialAccess:N([`allow`,`retry`]).optional()}).strict(),j({harnessId:HC}).strict(),j({}).strict(),j({threadId:Y,model:fw}).strict(),j({threadId:Y,thinkingOptionId:mw}).strict(),j({threadId:Y,includeReferenceCapability:k().optional()}).strict(),au(`owner`,[j({owner:P(`codex`),locked:k(),effectiveModel:fw.optional(),resolvedModelLabel:hw.optional(),effectiveThinkingOptionId:mw.optional(),effectivePermissionModeId:GC.optional(),history:Sw.optional(),supportsThreadReferences:P(!0).optional(),handoff:JC.optional()}).strict(),j({owner:P(`external`),harnessId:lw.max(256),transportModelId:lw.max(8192),effectiveModel:fw.optional(),resolvedModelLabel:hw.optional(),effectiveThinkingOptionId:mw.optional(),availableThinkingOptions:yw.optional(),effectivePermissionModeId:GC.optional(),catalog:xw.optional(),history:Sw,usage:tw.optional(),handoff:JC.optional(),locked:P(!0)}).strict()]),j({threadIds:A(Y).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 Ew=au(`owner`,[j({threadId:Y,owner:P(`codex`)}).strict(),j({threadId:Y,owner:P(`external`),harnessId:D().max(256).pipe(HC)}).strict()]);j({threads:A(Ew).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)}),j({threadId:Y,text:D().optional()}).strict(),j({kind:P(`application`),value:D().transform((e,t)=>{try{return JSON.parse(e)}catch{return t.addIssue({code:`custom`,message:`Invalid steering context JSON`}),Qn}}).pipe(j({expectedTurnId:UC,clientUserMessageId:D().min(1),delivery:N([`newTurn`,`activeTurn`])}).strict())}).strict().transform(e=>e.value),N([`activeTurn`,`newTurn`]),j({delivery:N([`official`,`activeTurn`,`newTurn`])}).strict();let Dw=D().min(1).max(128).regex(/^[a-z][a-z0-9]*(?:[._-][a-z0-9]+)*$/u),Ow=Dw.pipe(HC),kw=Ow.refine(e=>e!==`codex`,`The official Codex identity is reserved`),Aw=D().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`),jw=Ol().refine(e=>/^https:\/\/[^/?#@]+(?:[/?#]|$)/iu.test(e),`Plugin documentation links must be credential-free HTTPS URLs`),Mw=j({en:D().max(4096),"zh-CN":D().max(4096).optional()}).strict(),Nw=j({commands:A(j({terminal:D().max(256),command:D().max(4096)}).strict()).max(8),before:Mw.optional(),after:Mw.optional(),downloads:A(j({label:D().max(128),url:jw}).strict()).max(8).optional()}).strict(),Pw={id:Ow,name:D().trim().min(1).max(128),version:D().min(1).max(128),kind:P(`usage`).optional(),iconStyle:j({vector:j({viewBox:D().max(128).regex(/^-?\d+(?:\.\d+)?(?: +-?\d+(?:\.\d+)?){3}$/u),color:D().regex(/^(?:currentColor|#[a-f0-9]{6})$/iu),paths:A(j({d:D().min(1).max(32768).regex(/^[MmLlHhVvCcSsQqTtAaZz\d.,+eE\s-]+$/u),fillRule:N([`evenodd`,`nonzero`]).optional(),fill:D().regex(/^(?:currentColor|#[a-f0-9]{6})$/iu).optional()}).strict()).min(1).max(32)}).strict().optional(),background:D().regex(/^#[a-f0-9]{6}$/iu).optional(),borderRadius:O().min(0).max(50).optional(),paddingRatio:O().min(0).max(.25).optional()}).strict().optional(),installation:Nw.optional(),notice:Mw.optional(),launchCommand:P(!0).optional(),links:j({website:jw.optional(),documentation:jw.optional(),installation:jw.optional()}).strict().optional()};j({manifestVersion:P(1),...Pw,adapterApiVersion:O().int().positive(),entry:Aw,icon:Aw.optional()}).strict();let Fw=D().max(174828).regex(/^data:image\/(?:png|jpeg|webp|svg\+xml);base64,[A-Za-z0-9+/]+={0,2}$/u),Iw=j({...Pw,icon:Fw.optional()}).strict();j({}).strict(),j({plugins:A(Iw.extend({id:kw})).max(128)}).strict(),j({version:P(1),enabled:A(Ow).max(128)}).strict().refine(e=>new Set(e.enabled).size===e.enabled.length,{message:`Enabled plugin IDs must be unique`,path:[`enabled`]});let Lw=131072,Rw=Dw,zw=N([`sidebar.thread-layout`,`sidebar.thread-badge`,`appearance.theme`]),Bw=N([`appearance`,`interface`,`workflow`,`analytics`,`integrations`,`tools`]),Vw=D().trim().min(1).max(128);function Hw(e){switch(e.match(/\.([^./]+)$/u)?.[1]?.toLowerCase()){case`png`:return`image/png`;case`jpg`:case`jpeg`:return`image/jpeg`;case`webp`:return`image/webp`;default:return}}let Uw=e=>e.split(`/`).every(e=>!/[. ]$/u.test(e)),Ww=Aw.refine(e=>Hw(e)!==void 0&&Uw(e),`Images must be relative .png, .jpg, .jpeg, or .webp paths with no segments ending in a dot or space`),Gw=D().trim().max(2048).regex(/^https?:\/\/[^/?#\\\s]+/iu,`Expected an HTTP(S) URL`).pipe(Ol({protocol:/^https?$/u})).refine(e=>{let{username:t,password:n}=new URL(e);return!t&&!n&&!/[\\\s]/u.test(e)},`URL must not contain credentials, backslashes, or whitespace`);function Kw(e){return M({en:e,"zh-CN":e})}let qw=Kw(D().trim().min(1)),Jw=A(Bw).max(Bw.options.length).refine(e=>new Set(e).size===e.length,`Duplicate categories`),Yw=A(zw).max(zw.options.length).refine(e=>new Set(e).size===e.length,`Duplicate slots`),Xw={key:D().regex(/^[A-Za-z_][A-Za-z0-9_]*$/u),label:qw,description:qw.optional()},Zw={...Xw,step:O().positive().optional(),default:O().optional()},Qw=M({value:D(),label:qw}),$w=au(`type`,[M({...Xw,type:P(`boolean`),default:k().optional()}),M({...Xw,type:P(`string`),placeholder:qw.optional(),default:D().optional()}),M({...Zw,type:P(`number`),min:O().optional(),max:O().optional()}),M({...Zw,type:P(`range`),min:O(),max:O()}),M({...Xw,type:P(`select`),options:A(Qw).min(1),default:D().optional()})]).superRefine((e,t)=>{let n=(e,n)=>t.addIssue({code:`custom`,path:[e],message:n});if(e.type===`number`||e.type===`range`){let{min:t=-1/0,max:r=1/0,default:i}=e;t>r&&n(`max`,`Must be at least min`),i!==void 0&&(i<t||i>r)&&n(`default`,`Must be within min and max`)}else if(e.type===`select`){let t=new Set(e.options.map(({value:e})=>e));t.size!==e.options.length&&n(`options`,`Duplicate option values`),e.default!==void 0&&!t.has(e.default)&&n(`default`,`Must match an option value`)}}),eT=j({manifestVersion:Kl().positive(),id:Rw,name:ru([Vw,Kw(Vw)]),version:D().min(1).max(128),desktopApi:Kl().positive()}).passthrough().extend({manifestVersion:P(1),desktopApi:P(1),description:M({en:D().max(4096),"zh-CN":D().max(4096).optional()}).optional(),author:D().trim().min(1).max(128).optional(),repository:Gw.optional(),details:M({en:D().max(16384),"zh-CN":D().max(16384).optional()}).optional(),icon:Ww.optional(),screenshots:A(Ww).max(4).refine(e=>new Set(e).size===e.length,`Duplicate screenshots`).optional(),desktop:M({script:Aw,style:Aw.optional()}).optional(),backend:M({script:Aw.refine(Uw)}).optional(),slots:Yw.default(()=>[]),settingsSchema:A($w).max(32).refine(e=>new Set(e.map(({key:e})=>e)).size===e.length,`Duplicate setting keys`).optional(),categories:Jw.optional()}).strict().refine(e=>e.desktop!==void 0||e.backend!==void 0,`Expected at least one desktop or backend entry`),tT=D().regex(/^[a-f0-9]{64}$/u),nT=M({state:N([`running`,`disabled`,`invalid`,`incompatible`,`conflict`,`failed`,`waiting`]),hash:tT.optional(),error:D().optional(),conflictWith:Rw.optional()});M({controllerPid:Kl().positive(),targetId:D().nullable(),updatedAt:Bu(),handledReloadToken:El().optional(),extensions:du(D(),nT),surfaces:du(D(),nT).optional()});let rT=N([`official`,`community`]);function iT(e){return e.origin===`https://api.github.com`&&/^\/repos\/[\w-]+\/[\w.-]+\/zipball(?:\/[^/]+)?\/?$/u.test(e.pathname)}let aT=Gw.refine(e=>{let t=new URL(e);return/\.zip$/iu.test(t.pathname)||iT(t)||t.origin===`https://github.com`&&/^\/[\w-]+\/[\w.-]+\/zipball(?:\/.+)?\/?$/u.test(t.pathname)||t.origin===`https://codeload.github.com`&&/^\/[\w-]+\/[\w.-]+\/(?:zip|zipball|legacy\.zip)\/.+$/u.test(t.pathname)},`Expected a .zip download URL or a GitHub zipball URL`),oT=M({id:Rw,version:D().trim().min(1).max(128),name:qw.extend({en:Vw,"zh-CN":Vw}),description:Kw(D().trim().min(1).max(4096)),details:Kw(D().trim().min(1).max(16384)).optional(),author:D().trim().min(1).max(128),repository:Gw,stars:O().int().min(0).optional(),downloads:O().int().min(0).optional(),categories:Jw.optional(),trustTier:rT.default(`community`),icon:Gw.optional(),screenshots:A(Gw).max(4).optional(),downloadUrl:aT,sha256:tT,slots:Yw.optional(),publishedAt:D().optional(),updatedAt:D().optional(),minCodexHostVersion:D().optional()});M({schemaVersion:P(1),generatedAt:D(),extensions:A(oT).refine(e=>new Set(e.map(({id:e})=>e)).size===e.length,`Duplicate extension IDs`)});let sT=D().trim().min(1).max(128),cT=/^(?:con|prn|aux|nul|com[1-9¹²³]|lpt[1-9¹²³]) *(?:\.|$)/iu,lT=Rw.refine(e=>!cT.test(e),`Reserved extension ID`),uT=N([`desktop`,`web`]),dT=tT,fT=El(),pT=Aw.refine(e=>!/[\x00-\x1f\x7f<>"|*]/u.test(e)&&e.split(`/`).every(e=>!/[. ]$/u.test(e)&&!cT.test(e)),`Expected a portable relative resource path`).refine(e=>e.split(`/`).length<=32,`Extension resources may be at most 32 segments deep`),mT=eT.shape,hT=(e,t=0)=>M({en:D().trim().min(t).max(e),"zh-CN":D().trim().min(t).max(e)}),gT=e=>pT.refine(t=>t.endsWith(e),`Expected a ${e} file`),_T=gT(`.mjs`),vT=gT(`.css`).optional(),yT=e=>e.normalize(`NFC`).toLowerCase(),bT=M({manifestVersion:P(2),id:lT,name:hT(128,1),version:D().trim().min(1).max(128),description:hT(4096),details:hT(16384).optional(),author:mT.author,repository:mT.repository,icon:mT.icon.refine(e=>e===void 0||pT.safeParse(e).success),screenshots:mT.screenshots.refine(e=>e===void 0||e.every(e=>pT.safeParse(e).success)),categories:mT.categories,settingsSchema:mT.settingsSchema,slots:mT.slots.removeDefault().optional(),page:M({apiVersion:P(1),entry:_T,style:vT,title:hT(128,1).optional()}).optional(),widget:M({apiVersion:P(1),entry:_T,style:vT}).optional(),desktop:M({apiVersion:P(1),script:gT(`.js`),style:vT}).optional(),web:M({apiVersion:P(1),entry:_T.optional(),style:vT}).refine(({entry:e,style:t})=>e!==void 0||t!==void 0,`Expected a Web entry or style`).optional(),backend:M({apiVersion:P(1),entry:_T}).optional()}).refine(({page:e,widget:t,desktop:n,web:r,backend:i})=>!!(e||t||n||r||i),`Expected at least one page, widget, desktop, web, or backend entry`).refine(({page:e,widget:t,web:n,backend:r})=>!r||[e?.entry,t?.entry,n?.entry].every(e=>e===void 0||yT(e)!==yT(r.entry)),{path:[`backend`,`entry`],message:`A backend entry cannot also be a frontend entry`});function xT({hasPage:e,hasWidget:t,hasDesktop:n,hasWeb:r,hasBackend:i}){if(e||t||i&&!n&&!r)return[`desktop`,`web`];let a=[];return n&&a.push(`desktop`),r&&a.push(`web`),a}let ST=sT,CT=N([`running`,`waiting`,`idle`,`unknown`]),wT=M({sourceThreadId:Y,createdAtMs:O().int().nonnegative()}),TT=M({harnessId:HC,title:D().optional(),status:CT,archived:k(),updatedAtMs:O().int().nonnegative().optional()}),ET=M({revision:Kl().nonnegative(),parents:du(Y,Y),handoffs:du(Y,wT).optional(),nodes:du(Y,TT),truncated:k()}).refine(e=>Object.keys(e.nodes).length<=5e3,`Too many Thread tree nodes`).refine(({parents:e,handoffs:t,nodes:n})=>Object.entries(e).every(([e,t])=>Object.hasOwn(n,e)&&Object.hasOwn(n,t))&&Object.entries(t??{}).every(([e,{sourceThreadId:t}])=>Object.hasOwn(n,e)&&Object.hasOwn(n,t)),`Missing Thread tree node`),DT=D().min(1).max(128);M({});let OT=M({subscriptionId:DT});M({}),OT.extend({snapshot:ET});let kT=Kl().nonnegative(),AT=M({revision:kT,enabled:A(lT).max(64).refine(e=>new Set(e).size===e.length,`Duplicate extension IDs`)});M({version:P(1),seeded:A(lT).max(64).refine(e=>new Set(e).size===e.length,`Duplicate extension IDs`)});let jT=j({version:D().trim().min(1).max(128),publishedAt:D().trim().min(1).max(64).optional(),notes:D().trim().min(1).max(8192),url:Gw.optional()}),{downloadUrl:MT,...NT}=oT.shape,PT=j({...NT,id:lT,format:P(`codexhost`),targets:A(uT).min(1).max(2).refine(e=>new Set(e).size===e.length,`Duplicate targets`),apis:M({page:Kl().positive().optional(),widget:Kl().positive().optional(),desktop:Kl().positive().optional(),web:Kl().positive().optional(),backend:Kl().positive().optional()}),downloadUrl:MT.refine(e=>e.startsWith(`https://`),`Expected HTTPS`),featured:k().optional(),featuredOrder:Kl().nonnegative().optional(),changelog:A(jT).max(20).optional()}).refine(({targets:e,apis:t})=>{let n=xT({hasPage:!!t.page,hasWidget:!!t.widget,hasDesktop:!!t.desktop,hasWeb:!!t.web,hasBackend:!!t.backend});return e.length===n.length&&n.every(t=>e.includes(t))},`Catalog targets must match the declared APIs`);j({schemaVersion:P(2),generatedAt:D().min(1),extensions:A(PT).max(1e4).refine(e=>new Set(e.map(({id:e})=>e)).size===e.length,`Duplicate extension IDs`)}).extend({catalogUrl:Gw,fetchedAt:Bu(),cached:k(),stale:k().optional()});let FT={id:lT},IT={...FT,activationId:fT,digest:dT},LT={...FT,activationId:IT.activationId.optional()},RT=D().min(1).max(4096).refine(e=>/^(?:\/|[a-z]:[/\\])/iu.test(e)&&!e.includes(`\0`)&&!e.split(/[/\\]/u).some(e=>e===`.`||e===`..`),`Expected an absolute local path without dot segments`),zT=D().min(1).max(256).refine(e=>e.split(`/`).every(e=>e&&/^[a-z0-9_.-]+$/iu.test(e)&&e!==`.`&&e!==`..`),`Invalid GitHub ref`);function BT(e){return D().max(4*Math.ceil(e/3)).refine(t=>{let n=t.endsWith(`==`)?2:+!!t.endsWith(`=`);return t.length%4==0&&t.length*3/4-n<=e&&/^[A-Za-z0-9+/]*={0,2}$/u.test(t)},`Expected bounded standard padded base64`)}let VT=M({type:P(`github`),repository:D().max(150).regex(/^[a-z0-9-]+\/[a-z0-9_-][a-z0-9_.-]*$/iu),ref:zT.optional(),tag:zT.optional(),asset:D().max(255).regex(/^[a-z0-9_.-]+\.zip$/iu).optional(),subpath:pT.optional()}).refine(({ref:e,tag:t,asset:n})=>!e||!t&&!n,`Use either a zipball ref or a release tag/asset`),HT=ru([M({type:P(`catalog`),...FT}),VT,M({type:P(`zip`),base64:BT(67108864).min(4)}),M({type:P(`zip`),localZipPath:RT}),M({type:P(`localDir`),localDir:RT})]),UT=au(`type`,[M({type:P(`catalog`),...FT}),VT,M({type:P(`zip`)}),M({type:P(`localDir`)})]),WT=M({...IT,manifest:bT,installedAt:Bu(),source:UT.optional()}),GT=e=>D().max(23+4*Math.ceil(e/3)).regex(/^data:image\/(?:png|jpeg|webp);base64,[A-Za-z0-9+/]+={0,2}$/u),KT={desktopConflictWith:lT.optional()},qT=N([`none`,`inactive`,`starting`,`running`,`failed`]),JT=au(`state`,[WT.extend({state:P(`valid`),enabled:k(),...KT,iconDataUrl:GT(Lw).optional(),screenshotDataUrls:A(GT(524288)).max(4).optional(),backendState:qT.optional(),backendError:D().optional()}),M({state:N([`invalid`,`incompatible`]),id:D().min(1),enabled:k(),error:D()})]);M({revision:kT,configuration:AT,diagnostics:A(D()),extensions:A(JT)}),M({revision:kT,extensions:A(WT.extend({...KT,settingsRevision:kT})).max(64)});let YT={list:`codexhost/extensions/list`,snapshot:`codexhost/extensions/snapshot`,catalog:`codexhost/extensions/catalog`,catalogIcon:`codexhost/extensions/catalogIcon`,install:`codexhost/extensions/install`,update:`codexhost/extensions/update`,enable:`codexhost/extensions/enable`,disable:`codexhost/extensions/disable`,uninstall:`codexhost/extensions/uninstall`,recover:`codexhost/extensions/recover`,asset:`codexhost/extensions/asset`,settingsGet:`codexhost/extensions/settings/get`,settingsSet:`codexhost/extensions/settings/set`,backendInvoke:`codexhost/extensions/backend/invoke`,threadTree:`codexhost/extensions/threadTree`},XT=Object.freeze(Object.values(YT));new Set(XT),M({});let ZT={expectedRevision:kT};M({...FT,...ZT}),WT.extend({replaced:k()}),au(`state`,[M({state:P(`saved`),configuration:AT}),M({state:P(`revision-conflict`),revision:kT})]),M({...LT,digest:IT.digest.optional(),path:pT}),M({mimeType:D().min(1),base64:BT(16777216),digest:IT.digest}),M({mimeType:N([`image/png`,`image/jpeg`,`image/webp`]),base64:BT(Lw)}),M({settingsRevision:kT,values:FC}),YT.list,YT.snapshot,YT.catalog,M({forceRefresh:k().optional(),staleWhileRevalidate:k().optional()}),YT.catalogIcon,M({...FT}),YT.install,M({source:HT}),YT.update,M({...FT,expectedDigest:IT.digest,expectedActivationId:IT.activationId.optional(),source:HT.optional()}),YT.enable,YT.disable,YT.uninstall,M({...FT,removeData:k().optional(),expectedDigest:IT.digest.optional()}),M({...FT,removed:k()}),YT.recover,M({expectedRevision:ZT.expectedRevision.optional()}),YT.asset,YT.settingsGet,M(LT),YT.settingsSet,M({...LT,expectedSettingsRevision:kT,values:FC}),YT.backendInvoke,M({...LT,method:ST,params:PC.optional()}),M({result:PC}),YT.threadTree,j({threadId:Y}).strict(),j({confirmed:k()}).strict();let QT=[`codex-desktop`,`web`,`web-desktop-shell`,`web-mobile`,`ssh-remote`,`cli`],$T=[`darwin`,`win32`,`linux`],eE=[`arm64`,`x64`,`ia32`,`arm`],tE=[`zh`,`en`,`ja`,`ko`,`de`,`fr`,`es`,`pt`,`ru`,`other`],nE=[`codex`,`claude-code`,`antigravity`,`pi`,`opencode`,`cursor-cli`,`deepseek-harness`,`grok`,`omp`,`qwen-code`,`kiro-cli`,`codebuddy`,`workbuddy`,`devin`,`hermes`,`qoder`,`qoder-cn`,`kimi-code`,`zcode`,`copilot`,`custom`],rE=[`official-relay`,`self-hosted-relay`,`tailscale-serve`,`tailscale-funnel`,`tailscale-ip`,`lan`,`custom-proxy`,`remote-peer`],iE=D().min(1).max(40).regex(/^[0-9A-Za-z._+-]+$/u),aE=N(QT),oE=N(tE),sE=N(nE),cE=N(rE);new Set(nE),new Set(tE),j({enabled:k(),forcedOffByEnv:k()}).strict(),j({enabled:k()}).strict(),j({surfaces:A(aE).max(12).optional(),harnesses:A(sE).max(32).optional(),remoteAccess:A(cE).max(12).optional()}).strict(),j({dailyActive:P(!0).optional(),weeklyActive:P(!0).optional(),monthlyActive:P(!0).optional(),newInstall:P(!0).optional(),retainedD1:P(!0).optional(),retainedD7:P(!0).optional(),remoteAny:P(!0).optional(),appVersion:iE.optional(),codexDesktopVersion:iE.optional(),os:N($T).optional(),arch:N(eE).optional(),uiLanguage:oE.optional(),surfaces:A(aE).min(1).max(12).optional(),harnesses:A(sE).min(1).max(32).optional(),remoteAccess:A(cE).min(1).max(12).optional()}).strict().refine(e=>Object.keys(e).length>0,{message:`Telemetry heartbeat must contain at least one countable field`});let lE=4e3,uE={threadId:Y};au(`action`,[M({...uE,action:N([`get`,`pause`,`resume`,`clear`])}),M({...uE,action:N([`create`,`edit`]),objective:D().trim().min(1).refine(e=>Array.from(e).length<=lE,`A goal objective can have up to ${lE} characters.`)})]),j({goal:j({threadId:Y,objective:D(),status:N([`active`,`paused`,`blocked`,`usageLimited`,`budgetLimited`,`complete`]),tokenBudget:Kl().positive().nullable().default(null),tokensUsed:Kl().nonnegative(),timeUsedSeconds:Kl().nonnegative()}).nullable()});let dE=D().trim().min(1),fE=D().min(1),pE=j({icon:D().nullable(),color:D().nullable()}),mE=pE.nullable(),hE={create:{method:`codexhost/thread/sections/create`,params:j({name:dE}).strict()},update:{method:`codexhost/thread/sections/update`,params:j({sectionId:fE,name:dE,appearance:pE.strict().nullable().optional()}).strict()},delete:{method:`codexhost/thread/sections/delete`,params:j({sectionId:fE}).strict()}};au(`status`,[j({status:P(`unknown`)}),j({status:P(`confirmed`),sectionId:fE,section:j({id:fE,name:D().min(1),appearance:mE}).nullable(),syncPending:k()})]),[hE.create.method,hE.update.method,hE.delete.method,...XT],j({threadSectionsV1:P(!0).optional(),complete:P(!1).optional(),sections:A(j({id:D().min(1),name:D().min(1),appearance:mE.optional(),threads:A(FC)}))}),j({threadId:D().min(1).max(1024),sectionId:D().min(1).max(1024).nullable(),beforeThreadId:D().min(1).max(1024).nullable().optional(),expectedSourceSectionId:D().min(1).max(1024).optional()}).refine(e=>e.expectedSourceSectionId===void 0||e.sectionId===null),j({threadIds:A(D().min(1))}).strict(),j({threadId:D().min(1).max(1024),pinned:k()}).strict(),j({}).strict(),j({parents:du(D().min(1),D().min(1))}).strict(),j({prompt:D().max(16384).optional()}).strict(),j({projects:A(j({id:D(),name:D(),rootPaths:A(D()),createdAt:O().int().optional()})),nativeProjects:P(!0).optional(),assignments:du(D(),D()),projectless:A(D()),pinned:A(D()),sectionProjects:du(D(),A(D())).optional(),pinnedProjects:A(D()).optional()});let gE=du(D(),Zl()),_E=j({epoch:D().uuid(),sequence:O().int().nonnegative()});au(`type`,[j({type:P(`projects-changed`),cursor:_E}),j({type:P(`skills-changed`),cursor:_E,cwd:D().optional()}),j({type:P(`harness-inspection-changed`),cursor:_E,harnessId:D().min(1)}),j({type:P(`display-settings-changed`),cursor:_E}),j({type:P(`sections-changed`),cursor:_E}),j({type:P(`preferences-changed`),cursor:_E,revision:O().int().nonnegative()}),j({type:P(`extensions-changed`),cursor:_E,revision:kT}),j({type:P(`hello`),version:P(1),cursor:_E,reset:k()}),j({type:P(`changed`),cursor:_E,threadId:D().min(1),method:D().min(1)})]);let vE=au(`type`,[j({type:P(`text`),id:D(),prompt:D(),secret:k().optional(),optional:k().optional()}),j({type:P(`choice`),id:D(),prompt:D(),multiple:k(),allowOther:k(),optional:k().optional(),options:A(j({value:D(),label:D(),description:D().optional()}))})]),yE=au(`type`,[j({type:P(`approval`),title:D(),description:D().optional(),subject:Zl().optional(),actions:A(j({id:D(),label:D(),effect:D()}))}),j({type:P(`question`),title:D().optional(),questions:A(vE)})]),bE=j({requestId:ru([D(),O().int()]),threadId:D(),kind:N([`approval`,`question`]),interaction:yE,request:gE}),xE=j({id:D().min(1),clientUserMessageId:D().min(1),input:A(gE),presentationInput:A(gE).nullable().optional()}).passthrough();j({fields:A(j({path:A(ru([D(),O().int().nonnegative()])),originalLength:O().int().nonnegative()}))});let SE=j({id:D().min(1),status:D().min(1),codexhostTurnOutcome:j({status:P(`unknown`),reason:D()}).optional(),items:A(j({id:D().min(1),type:D().min(1)}).passthrough()),codexhostFileOperations:A(j({beforeItemId:D().nullable(),item:j({id:D().min(1),type:D().min(1)}).passthrough()})).optional(),error:j({message:D().optional()}).passthrough().nullable().optional(),fingerprint:D().min(1).optional(),unchanged:P(!0).optional()}).passthrough(),CE=j({id:D().min(1).max(512),fingerprint:D().min(1).max(128)});j({threadId:D().min(1),knownTurns:A(CE).max(64).optional(),truncateToolOutput:k().optional()});let wE=j({harnessId:D().min(1),nativeSessionId:D().min(1)});j({cursor:_E,activeTurnId:D().min(1).nullable().optional(),command:j({name:D().min(1),turn:SE,subsequentTurnId:D().min(1).optional()}).optional(),thread:j({id:D().min(1),cwd:D(),modelProvider:D().min(1),createdAt:O(),updatedAt:O(),recencyAt:O().nullable().optional(),status:j({type:D()}).passthrough(),name:D().nullable().optional(),preview:D().optional(),codexhostImportSource:wE.optional(),turns:A(SE).length(0)}).passthrough(),turnsPage:j({data:A(SE).max(5),nextCursor:D().nullable()}),configuration:j({codexCollaborationMode:N([`plan`,`default`]).optional(),native:j({model:D().min(1).max(1024).optional(),reasoningEffort:D().min(1).max(128).optional()}).optional(),effectiveModel:fw.optional(),effectiveThinkingOptionId:mw.optional(),effectivePermissionModeId:GC.optional()}),queue:j({items:A(xE),pausedReason:N([`interrupted`,`outcome-unknown`,`failed`]).nullable()}).optional(),interactions:A(bE),handoff:JC.optional()}),j({version:P(1),owner:P(`service`).optional(),pid:O().int().positive(),port:O().int().min(1).max(65535),token:D().regex(/^[0-9a-f]{64}$/u),startedAt:O(),epoch:D().uuid(),capabilities:j({peerDelegation:P(1).optional(),threadReferenceContext:P(1).optional()}).optional()}),j({epoch:D().uuid(),threadId:D().min(1),requestId:ru([D(),O().int()]),result:gE}),j({includeArchived:k().optional(),officialCursor:j({live:D().nullable(),archived:D().nullable().optional()}).strict().optional(),scope:ru([j({cwd:D().min(1).max(4096),excludeCwds:A(D().min(1).max(4096)).max(1024)}).strict(),j({projectId:D().min(1).max(1024),legacyThreadIds:A(D().min(1).max(1024)).max(1024),rootPaths:A(D().min(1).max(4096)).max(1024).optional()}).strict()]).optional()}).strict(),j({threads:A(FC),ownership:A(Ew),archivedThreadIds:A(Y),officialCursor:j({live:D().nullable(),archived:D().nullable().optional()}).strict().optional()}).strict(),Iw.pick({id:!0,name:!0,icon:!0,iconStyle:!0});let TE=M({threadId:D().max(1024),title:D().max(240),project:D().max(240),harness:M({id:D().min(1).max(128),name:D().min(1).max(128)}).optional(),state:N([`idle`,`running`,`waiting`,`completed`,`failed`]),updatedAt:O().nonnegative()});M({epoch:D().max(128),revision:Kl().nonnegative(),running:Kl().nonnegative(),waiting:Kl().nonnegative(),sessions:A(TE).max(32).default([]),notifications:A(M({threadId:D().max(1024),key:D().max(4096),kind:N([`completed`,`failed`,`approval`,`question`]),revision:Kl().nonnegative()})).max(256)});let EE=D().regex(/^audio\/[a-z0-9.+-]+(?:\s*;[^\r\n]*)?$/i);j({available:k()}).strict(),j({path:D().min(1),mimeType:EE}).strict();let DE=N([`credentials-unavailable`,`login-expired`,`rate-limited`,`service-rejected`,`host-incompatible`,`network`,`timeout`,`audio-empty`,`audio-too-large`,`audio-format`,`audio-invalid`]);au(`ok`,[j({ok:P(!0),text:D()}).strict(),j({ok:P(!1),error:j({code:DE}).strict()}).strict()]),j({threadId:Y.optional(),cwd:D().min(1).optional()}).strict().refine(e=>!(e.threadId&&e.cwd),{message:`Specify threadId or cwd, not both`});let OE=j({name:D().min(1).regex(/^[^\s[\]]+$/u),description:D().optional(),path:D().min(1),scope:N([`project`,`global`]),source:D().min(1)}).strict();j({revision:O().int().nonnegative(),complete:k(),skills:A(OE),warnings:A(D()).optional()}).strict(),j({cwd:D().min(1).optional()}).strict();let kE=/\[\$([^\]\r\n]+)\]\((?:<([^<>\r\n]+)>|([^\s()]+))(?:[ \t]+(?:"[^"\r\n]*"|'[^'\r\n]*'))?\)/gu;function AE(e){return[...e.matchAll(kE)].flatMap(e=>{let t=e[2]??e[3]??``;return!/^(?:\/|[A-Za-z]:[\\/]|\\\\)/u.test(t)||!/[\\/]SKILL\.md$/u.test(t)?[]:[{start:e.index,end:e.index+e[0].length,name:e[1]??``,path:t,text:e[0]}]})}let jE=j({kind:N([`public`,`relay`,`tailscale-funnel`,`tailscale-https`,`tailscale`,`lan`,`virtual`]),url:D().min(1)}).strict(),ME=au(`status`,[j({status:P(`not-installed`)}),j({status:P(`not-running`)}),j({status:P(`not-logged-in`)}),j({status:P(`https-disabled`)}),j({status:P(`not-serving`),command:D()}),j({status:P(`occupied`),target:D()}),j({status:P(`serving`),url:D(),funnel:k()}),j({status:P(`error`),message:D()})]);j({state:ME,error:D().optional()}).strict();let NE=au(`status`,[j({status:P(`on`)}),j({status:P(`off`)}),j({status:P(`invalid`),reason:D()})]),PE=j({lan:k(),autostart:NE}).strict(),FE=j({expiresAt:D().optional(),issuing:k(),failure:j({detail:D().optional(),retryAt:D(),paused:k()}).optional()}),IE=au(`status`,[j({status:P(`off`),reason:N([`invite`,`name-taken`,`banned`]).optional()}),j({status:P(`connecting`),reason:N([`full`,`unreachable`]).optional()}),j({status:P(`connected`),url:D(),certificate:FE}),j({status:P(`missing-certificate`),url:D(),certificate:FE}),j({status:P(`stopped`),reason:N([`replaced`,`rejected`,`unsupported-version`])})]);D().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()),D().regex(/^(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)?$/);let LE=N([`official`,`self-hosted`]);j({secret:D().min(1),lastUsedAt:O().nullable(),networkUrls:A(jE),directCandidates:A(jE).optional(),tailscale:ME,background:PE.optional(),relay:j({state:IE,enabled:k(),kind:LE,officialHost:D(),customHost:D().optional(),officialHostname:D().optional(),customHostname:D().optional(),quotaUntil:D().optional()}).strict().optional()}).strict();let RE=M({threadId:D().min(1).max(1024),view:N([`result`,`messages`]),from:O().int().min(1).max(2**53-1).optional(),to:O().int().min(1).max(2**53-1).optional()}),zE=/^[a-zA-Z0-9_-]{1,64}$/u,BE=D().regex(zE),VE=D().regex(zE),HE=D().regex(/^remote-peer:[a-zA-Z0-9_-]{1,64}$/u),UE=N([`relay`,`tailscale`,`lan`,`custom`]),WE=[`blue`,`purple`,`cyan`,`green`,`amber`,`rose`,`slate`],GE=N(WE);new Set(WE);let KE=N([`connected`,`connecting`,`auth-error`,`offline`,`disabled`]),qE=j({peerId:BE,hostId:HE,nodeId:VE.optional(),name:D().min(1).max(120),color:GE.optional(),origin:D().min(1).max(2048),transportKind:UE,encrypted:k(),enabled:k(),state:KE,supportsPeerPairing:k().optional(),pairedBack:k().optional(),linkedPeerIds:A(BE).max(128).optional(),latencyMs:O().int().nonnegative().optional(),version:D().max(128).optional(),platform:D().max(64).optional(),hostname:D().max(255).optional(),homeDir:D().max(4096).optional(),lastError:D().max(1e3).optional(),projectCount:O().int().nonnegative(),createdAt:D(),updatedAt:D()});j({localPlatform:D().max(64).optional(),peers:A(qE)}),j({connectionUrl:D().min(1).max(4096).optional(),origin:D().min(1).max(2048).optional(),token:D().min(1).max(2048).optional(),name:D().trim().min(1).max(120).optional(),color:GE.optional(),pairBack:k().optional(),meshPeerIds:A(BE).max(64).optional(),selfOrigin:D().min(1).max(2048).optional()}).refine(e=>!!e.connectionUrl||!!e.origin&&!!e.token,`Provide either connectionUrl or both origin and token`),M({origin:D().min(1).max(2048),token:D().min(1).max(2048),name:D().trim().min(1).max(120).optional(),color:GE.optional(),expectedNodeId:VE.optional()}),j({status:N([`added`,`updated`,`existing`]),peerId:BE,hostId:HE,nodeId:VE.optional()});let JE=N([`added`,`updated`,`existing`,`failed`,`skipped`]);j({results:A(j({targetPeerId:BE,targetName:D().min(1).max(120),introducedHost:ru([P(`local`),BE]),introducedName:D().min(1).max(120),status:JE,error:D().max(1e3).optional()}))}),j({peerIds:A(BE).max(64).optional(),includeSelf:k().optional(),includeMesh:k().optional(),selfOrigin:D().min(1).max(2048).optional()}),j({peerId:BE,name:D().trim().min(1).max(120).optional(),color:GE.nullable().optional(),connectionUrl:D().min(1).max(4096).optional(),origin:D().min(1).max(2048).optional(),token:D().min(1).max(2048).optional(),enabled:k().optional()}),j({peerId:BE}),j({removed:k()}),j({peerId:BE.optional(),connectionUrl:D().min(1).max(4096).optional(),origin:D().min(1).max(2048).optional(),token:D().min(1).max(2048).optional()}).refine(e=>!!e.peerId||!!e.connectionUrl||!!e.origin&&!!e.token,`Provide peerId, connectionUrl, or both origin and token`);let YE=j({id:D().min(1).max(1024),name:D().min(1).max(512),path:D().min(1).max(8192)});j({ok:k(),nodeId:VE.optional(),supportsPeerPairing:k().optional(),pairedBack:k().optional(),latencyMs:O().int().nonnegative().optional(),origin:D().max(2048).optional(),transportKind:UE.optional(),encrypted:k().optional(),version:D().max(128).optional(),platform:D().max(64).optional(),hostname:D().max(255).optional(),homeDir:D().max(4096).optional(),projectCount:O().int().nonnegative().optional(),projects:A(YE).optional(),error:D().max(1e3).optional()});let XE=j({id:D().min(1).max(1024),name:D().min(1).max(512),path:D().min(1).max(8192),threadIds:A(D().min(1).max(1024))}),ZE=j({attachments:P(1).optional(),workspaceFiles:P(1).optional(),officePreview:P(1).optional(),delegation:P(1).optional(),peerPairing:P(1).optional()}),QE=j({version:D().max(128),platform:D().max(64),hostname:D().max(255),homeDir:D().max(4096).optional(),epoch:D().min(1).max(256),nodeId:VE.optional(),peerNodes:du(HE,VE).refine(e=>Object.keys(e).length<=128).optional(),projects:A(XE),capabilities:ZE.optional()});M({threadId:D().min(1).max(1024),scope:D().regex(/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/u).optional(),requestId:D().min(1).max(256).optional(),mode:N([`queue`,`steer`]).optional(),expectedTurnId:D().min(1).max(1024).nullable().optional(),content:A(au(`type`,[M({type:P(`text`),text:D()}),M({type:P(`file`),receiptId:D().min(1).max(128)})])).min(1).max(64)});let $E=j({ok:P(!1),error:j({code:D(),message:D(),details:du(D(),Zl()).optional()})});ru([j({ok:P(!0),value:j({receiptId:D().min(1),file:j({attachmentId:D(),name:D(),bytes:O().int().nonnegative()})})}),$E]),ru([j({ok:P(!0),value:j({accepted:P(!0)})}),$E]);let eD=j({name:D().min(1).max(512),path:D().min(1).max(8192),kind:P(`directory`)});j({peerId:BE,path:D().min(1).max(8192).optional()}),j({path:D().min(1).max(8192),parentPath:D().min(1).max(8192).nullable(),homeDir:D().min(1).max(8192).optional(),entries:A(eD)}),j({peerId:BE,parentPath:D().min(1).max(8192),name:D().min(1).max(255).refine(e=>e.trim().length>0,`Directory name cannot be blank`)}),j({path:D().min(1).max(8192),name:D().min(1).max(255)}),j({peerId:BE,path:D().min(1).max(8192),title:D().trim().min(1).max(255).optional()}),j({peerId:BE,workspaceId:D().min(1).max(1024),title:D().trim().min(1).max(255)}),j({peerId:BE,workspaceId:D().min(1).max(1024)}),j({workspaceId:D().min(1).max(1024).optional(),manifest:QE}),j({sessionHostId:D().min(1).max(128).optional()}),j({hosts:A(j({hostId:ru([P(`local`),HE]),name:D().min(1).max(120),isLocal:k().optional(),color:GE.optional(),hostname:D().max(255).optional()}))}),j({hostId:ru([P(`local`),HE])}),j({harnesses:A(j({id:D().regex(/^[a-z0-9][a-z0-9-]*$/u),name:D().min(1).max(120)}))});let tD=N([`listHarnesses`,`inspect`,`start`,`send`,`cancel`,`read`,`answer`,`list`]);M({operation:tD,hopCount:O().int().min(0).max(16),sourceId:BE.optional(),input:FC});let nD=M({code:D().min(1).max(128),message:D().max(4096),details:FC.optional()});ru([M({ok:P(!0),value:PC}),M({ok:P(!1),error:nD})]);let rD=M({id:D().min(1).max(1024),name:D().min(1).max(512),path:D().min(1).max(8192)});M({hosts:A(M({hostId:HE,nodeId:VE.optional(),displayName:D().min(1).max(120),online:k(),state:KE,delegation:k(),projects:A(rD),platform:D().max(64).optional(),hostname:D().max(255).optional(),homeDir:D().max(4096).optional()}))}),M({version:P(1),instanceId:D().min(1).max(128),pid:O().int().positive(),endpoint:D().min(1).max(256),token:D().regex(/^[0-9a-f]{64}$/u),startedAt:O().int().nonnegative()}),ru([M({operation:P(`hosts`)}),M({operation:tD,hostId:HE,hopCount:O().int().min(0).max(16),timeoutMs:O().int().min(1).max(12e4).optional(),input:FC})]);let iD=j({id:D().min(1).max(256),harnessId:D().min(1),label:D().min(1).max(512),provider:N([`openai-codex`,`xai`])}).strict(),aD=D().regex(/^[a-z][a-z0-9-]{0,47}$/),oD=j({name:aD,source:iD,importedAt:D()}).strict(),sD=au(`action`,[j({action:P(`list`)}).strict(),j({action:P(`import`),sourceId:D().min(1).max(256),name:aD,confirmed:P(!0)}).strict(),j({action:P(`reimport`),sourceId:D().min(1).max(256),name:aD,confirmed:P(!0)}).strict(),j({action:P(`remove`),name:aD,confirmed:P(!0)}).strict()]),cD=j({provider:D().min(1).max(128),type:N([`oauth`,`api_key`,`unknown`]),label:D().min(1).max(512).optional(),vendor:N([`openai-codex`,`xai`]).optional()}).strict();j({sources:A(iD),targets:A(j({harnessId:D(),providers:A(N([`openai-codex`,`xai`])),imports:A(oD),others:A(cD).default([])}).strict())}).strict(),j({targetHarnessId:D().min(1).max(128).optional(),request:sD}).strict(),j({events:k()});let lD=A(M({agent:D().min(1).max(128),section:N([`main`,`more`,`auto`])})).max(256).refine(e=>new Set(e.map(e=>e.agent)).size===e.length,`Duplicate Harness IDs`);M({entries:lD.nullable()}),M({}),M({entries:lD,initializeOnly:k().optional()});let uD=M({enabled:k(),timeoutMinutes:O().int().min(5).max(1440)});Object.freeze({enabled:!0,timeoutMinutes:10});let dD=D().regex(/^external$/u),fD=HC.transform(e=>String(e)),pD=M({model:fw.optional(),thinkingOptionId:mw.optional(),permissionModeId:GC.optional()}).refine(e=>!!(e.model||e.thinkingOptionId||e.permissionModeId),`A default configuration must contain a preference`);au(`mode`,[M({mode:P(`global`)}),M({mode:P(`last`)}),M({mode:P(`manual`),harnessId:HC})]);let mD=M({lastHarness:HC.optional(),byHarness:du(fD,pD)}),hD=M({model:fw.optional(),thinkingOptionId:mw.optional()}).refine(e=>!!(e.model||e.thinkingOptionId),`A delegation default must contain a Model or Thinking option`),gD=M({byHarness:du(fD,hD)}),_D=D().min(1).max(1024),vD=M({idleRelease:uD.optional(),favorites:du(fD,A(_D).max(2048)).default({}),newThread:mD.optional(),delegation:gD.optional()});M({scope:dD,revision:O().int().nonnegative(),values:vD}),M({scope:dD.default(`external`)});let yD=au(`kind`,[M({kind:P(`idleRelease`),value:uD}),M({kind:P(`favorite`),harnessId:HC,modelId:_D,enabled:k()}),M({kind:P(`favorites`),harnessId:HC,modelIds:A(_D).max(2048)}),M({kind:P(`newThread`),lastHarness:HC.optional(),harnessId:HC.optional(),configuration:pD.optional()}),M({kind:P(`delegation`),harnessId:HC,configuration:hD.nullable()})]);M({scope:dD.default(`external`),operations:A(yD).min(1).max(256),initializeOnly:k().optional(),expectedRevision:O().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`})}),M({version:P(1),revision:O().int().nonnegative(),scopes:du(dD,vD)});let bD=O().finite().nonnegative(),xD=M({input:bD,output:bD,cacheRead:bD.optional(),cacheWrite:bD.optional(),cacheWrite1h:bD.optional()}),SD=D().max(512).refine(e=>e.trim()===e&&e.length>0,`Model ID is required`);M({path:D(),entries:A(M({key:D(),price:xD})),error:D().nullable()}),M({}),M({key:SD,price:xD.nullable(),previousKey:SD.optional()}),M({model:SD});let CD=M({official:k().optional(),canonicalModelId:D().min(1).optional(),provider:D().min(1).max(512),model:D().min(1).max(512),price:xD});M({price:xD.nullable(),suggestions:A(CD).max(6).optional()});let wD=[`today`,`7d`,`30d`,`90d`,`all`],TD=O().int().min(0).max(2**53-1),ED=D().regex(/^\d{4}-\d{2}-\d{2}$/u),DD=D().min(1).max(128),OD=D().min(1).max(512),kD=D().min(1).max(4096);M({range:N(wD),timeZone:D().min(1).max(128).refine(e=>{try{return new Intl.DateTimeFormat(`en`,{timeZone:e}),!0}catch{return!1}},`Unsupported usage statistics timezone`).optional(),harness:DD.optional(),model:OD.nullable().optional(),project:kD.nullable().optional(),date:ED.optional()});let AD=M({requests:TD,inputTokens:TD,cachedInputTokens:TD,cacheWriteInputTokens:TD,cacheKnownInputTokens:TD,cacheHitCachedInputTokens:TD,cacheHitInputTokens:TD,outputTokens:TD,reasoningOutputTokens:TD,costUsd:O().finite().min(0),unpricedRequests:TD,unmeteredRequests:TD}),jD=AD.shape,MD=M({harness:DD,sessionId:D().min(1).max(512),project:kD.nullable(),title:D().min(1).max(200).optional(),models:A(OD).max(16),firstAtMs:TD,lastAtMs:TD,...jD});M({range:N(wD),from:ED.nullable(),to:ED,filters:M({harness:DD.nullable(),model:OD.nullable(),unknownModel:k(),project:kD.nullable(),unknownProject:k(),date:ED.nullable()}),reading:M({complete:k(),sources:TD,read:TD}),failures:A(M({harness:DD,message:D().max(2048)})).max(256),options:M({harnesses:A(DD).max(256),models:A(OD.nullable()).max(4096),projects:A(kD.nullable()).max(4096)}),modelLabels:A(M({harness:DD,model:OD,label:OD})).max(4096).optional(),credits:A(M({harness:DD,model:OD.nullable(),credits:O().finite().min(0),reportedRequests:TD,requests:TD})).max(4096).optional(),totals:AD,daily:A(M({date:ED,harness:DD,...jD})).max(2e5),hourly:A(M({weekday:O().int().min(0).max(6),hour:O().int().min(0).max(23),...jD})).max(168),byHarness:A(M({harness:DD,...jD})).max(256),byModel:A(M({model:OD.nullable(),...jD,harnessPricedRequests:TD})).max(4096),byProject:A(M({project:kD.nullable(),...jD})).max(4096),sessions:A(MD).max(100),recentSessions:A(MD).max(100).optional()}),j({threadId:Y}),j({discarded:k()});let ND=au(`type`,[j({id:D().min(1),type:P(`choice`),prompt:D(),options:A(j({value:D().min(1),label:D(),description:D().optional()})).min(1),multiple:k(),allowOther:k(),optional:k()}),j({id:D().min(1),type:P(`text`),prompt:D(),multiline:k(),secret:P(!1),optional:k(),placeholder:D().optional(),prefill:D().optional()})]),PD=j({interactionId:D().min(1),turnId:D().min(1),title:D().optional(),questions:A(ND).min(1)}).refine(({questions:e})=>e.some(e=>e.type===`choice`&&e.multiple),{message:`Shared cards require at least one multi-select question`});M({threadId:D().min(1)}),j({questions:A(PD)}),M({threadId:D().min(1),turnId:D().min(1),interactionId:D().min(1),answers:du(D(),A(D())),cancelled:k().default(!1)}),j({accepted:P(!0)});let FD=j({path:D(),oldText:D().nullable(),newText:D()});j({sessionId:D().min(1),turn:O().int().nonnegative(),path:D().min(1).optional()}),j({diffs:A(FD)}),M({}),M({}),j({reference:j({sessionId:D().min(1),epoch:D().min(1),turn:O().int().nonnegative(),seq:O().int().nonnegative(),callId:D().min(1),part:O().int().nonnegative(),version:D().min(1)}),length:O().int().nonnegative(),bytes:O().int().nonnegative()}),M({title:D().trim().min(1).max(200),type:N([`info`,`warning`,`danger`]),body:D().trim().min(1).max(16384)}),M({}),M({url:D().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/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.codexhost/update/macos-signing/status.codexhost/update/macos-signing/setup.codexhost/update/macos-signing/remove`.split(`.`));let ID=N([`idle`,`running`,`busy`,`closing`,`failed`,`blocked`]),LD=N([`none`,`disabled`,`timeout`,`operation`,`background`,`identity`,`persistence`,`closeFailed`]);M({threadId:D(),title:D(),harnessId:D(),state:ID,reason:LD,inactiveMs:O().nonnegative()}),M({threadId:Y,turnId:UC});let RD=j({email:D().trim().min(1).max(320).optional(),label:D().trim().min(1).max(256).optional(),plan:D().trim().min(1).max(128).optional(),credits:sw.optional(),balance:cw.optional()}).strict();function zD(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 BD=zD(RD),VD={harnessId:HC,harnessName:D().trim().min(1).max(128)},HD=j(VD).strict();j({}).strict(),j({sources:A(HD).max(128)}).strict(),j({harnessId:HC,refresh:k().optional()}).strict(),j({...VD,account:BD.nullable(),accounts:A(BD).max(8).optional()}).strict(),j({refresh:k().optional()}).strict(),j({accounts:A(zD(RD.extend(VD))).max(128)}).strict(),j({harnessId:kw,model:fw.optional(),thinkingOptionId:mw.optional(),permissionModeId:GC.optional(),prewarm:P(!0).optional()}).strict();let UD=D().trim().min(1).max(4096).refine(e=>!/[\u0000\r\n]/u.test(e),`Invalid entrypoint path`);j({harnessId:kw}).strict().extend({path:UD.nullable()}),j({path:UD.nullable(),restartRequired:k()}).strict(),j({harnessId:HC,action:N([`check`,`update`,`install`]),confirmedVersion:D().min(1).max(128).optional()}).strict().refine(({action:e,confirmedVersion:t})=>e===`update`||t===void 0);let WD=j({currentVersion:D().min(1).max(128),latestVersion:D().min(1).max(128),updateAvailable:k(),canUpdate:k(),latestVerifiedVersion:D().min(1).max(128).optional(),confirmationRequired:P(!0).optional(),versionKind:N([`cli`,`application`]).optional(),manualUpdateUrl:Ol().max(2048).refine(e=>/^https:\/\/[^/?#@]+(?:[/?#]|$)/iu.test(e),`Manual updates require a credential-free HTTPS URL`).optional(),message:D().max(2048).optional(),messageCode:D().min(1).max(128).optional(),notice:BC.optional(),latestVersionKind:N([`unknown`,`tracking-branch`]).optional()}).strict();j({taskId:D().uuid()}).strict(),au(`status`,[j({taskId:D().uuid(),status:P(`running`)}).strict(),j({taskId:D().uuid(),status:P(`succeeded`),result:WD}).strict(),j({taskId:D().uuid(),status:P(`failed`),error:j({code:O().int(),message:D().min(1).max(2048)}).strict()}).strict()]);let GD=D().min(1).max(256).regex(/^[A-Za-z0-9._~-]+$/u),KD=D().trim().min(1),qD=N([`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`]),JD=j({accountId:GD,label:KD.max(256),email:D().email().max(320).optional(),planType:qD.optional()}).strict(),YD=N([`ready`,`unavailable`]);j({version:P(2),currentAccountId:GD.nullable(),phase:YD,revision:O().int().nonnegative(),instanceId:KD.max(1024).optional(),accounts:A(JD).max(1)}).strict(),j({accountId:GD,refresh:k().optional()}).strict(),j({accountId:GD,usage:tw.nullable(),accountCredits:sw.optional(),freshness:N([`live`,`cached`]),observedAt:D().datetime().nullable()}).strict();let XD=1e3,ZD=D().refine(e=>e.trim().length>0,`Value must not be empty or whitespace`).refine(e=>!e.includes(`\0`),`Value must not contain NUL`),QD=ZD.max(1024),$D=j({nativeSessionId:QD,title:ZD.max(4096).nullable(),updatedAt:O().int().nonnegative().max(864e13),cwd:ZD.max(16384),running:k().nullable()}).strict();j({}).strict(),j({harnesses:A(j({harnessId:kw,name:ZD.max(128)}).strict()).max(128)}).strict(),j({harnessId:kw,query:D().trim().max(4096).refine(e=>!e.includes(`\0`)).optional(),offset:O().int().nonnegative().safe().optional(),limit:O().int().min(1).max(XD).optional()}).strict(),j({candidates:A($D).max(XD),total:O().int().nonnegative().safe()}).strict(),j({harnessId:kw,nativeSessionId:QD}).strict(),j({threadId:ZD.max(1024).pipe(Y)}).strict();let eO=D().refine(e=>e.trim().length>0,`Value must not be empty or whitespace`).refine(e=>!e.includes(`\0`),`Value must not contain NUL`),tO=QD,nO=$D;j({}).strict(),j({candidates:A(nO).max(1e3)}).strict(),j({nativeSessionId:tO}).strict(),j({threadId:eO.max(1024).pipe(Y)}).strict(),j({threadId:Y,lastTurnId:UC}).strict(),j({threadId:Y}).strict();let rO=D().trim().min(1).max(128).regex(/^[A-Za-z0-9._:-]+$/u).brand();j({commands:A(j({id:rO,invocation:D().min(1).max(128),label:D().trim().min(1).max(128),description:D().trim().min(1).max(512).optional(),localizations:zC.optional(),argumentMode:N([`none`,`text`]),kind:N([`command`,`skill`]).optional()}).strict()),warnings:A(D().min(1)).optional(),source:N([`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)}),j({harnessId:HC,cwd:D().min(1).optional()}).strict(),j({threadId:Y}).strict(),j({threadId:Y,commandId:rO,turnId:UC.optional(),arguments:FC.optional()}).strict(),j({accepted:P(!0),turnId:UC.optional()}).strict();let iO=P(`2.0`).optional(),aO=$l().optional(),oO=D().min(1),sO=ru([D(),O().int()]),cO=j({code:O().int(),message:D(),data:PC.optional()}).catchall(PC).superRefine(kC([`data`]));ru([j({jsonrpc:iO,id:sO,method:oO,params:PC.optional(),result:aO,error:aO}).catchall(PC).superRefine(kC([`jsonrpc`,`params`,`result`,`error`])),j({jsonrpc:iO,id:aO,method:oO,params:PC.optional(),result:aO,error:aO}).catchall(PC).superRefine(kC([`jsonrpc`,`id`,`params`,`result`,`error`])),j({jsonrpc:iO,id:sO,method:aO,params:aO,result:PC,error:aO}).catchall(PC).superRefine(kC([`jsonrpc`,`method`,`params`,`error`])),j({jsonrpc:iO,id:sO,method:aO,params:aO,result:aO,error:cO}).catchall(PC).superRefine(kC([`jsonrpc`,`method`,`params`,`result`]))]);let lO=D().refine(e=>e.trim().length>0,{message:`Native identifier must not be empty or whitespace`});M({harnessId:HC,nativeSessionId:lO,locator:PC.optional(),formatVersion:P(1)}).superRefine(kC([`locator`])),M({harnessId:HC,nativeSessionId:lO,nativeTurnKey:lO,formatVersion:P(1)}),M({harnessId:HC,nativeSessionId:lO,checkpointId:lO,locator:PC.optional(),formatVersion:P(1)}).superRefine(kC([`locator`]));let uO=D().regex(/^\d+\.\d+\.\d+(?:-[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?(?:\+[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/u),dO=N([`npm`,`windows-installer`,`macos-dmg`,`linux-archive`]),fO=N([`prepared`,`downloading`,`waiting-for-exit`,`installing`,`restarting`,`succeeded`,`failed`]),pO=M({completed:O().int().nonnegative(),total:O().int().positive()}).refine(e=>e.completed<=e.total,{path:[`completed`],message:`completed must not exceed total`}),mO=M({version:uO,installation:dO,phase:fO,updatedAt:O().int().nonnegative(),downloadedBytes:O().int().nonnegative().optional(),totalBytes:O().int().positive().optional(),npmDownload:pO.optional(),error:D().min(1).max(500).nullable(),serviceStopOutput:D().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`})});M({});let hO=D().max(300).regex(/^https:\/\/github\.com\/BytePioneer-AI\/codex-host\/releases\/tag\/v[0-9A-Za-z.+-]+$/u,`release notes URL must identify a codexhost GitHub Release`),gO=N([`idle`,`downloading`,`ready`,`failed`]),_O=M({downloadedBytes:O().int().nonnegative(),totalBytes:O().int().positive()}).refine(e=>e.downloadedBytes<=e.totalBytes,{path:[`downloadedBytes`],message:`downloadedBytes must not exceed totalBytes`});j({currentVersion:uO,installation:dO.nullable(),latestVersion:uO.nullable(),updateAvailable:k(),installationAvailable:k(),releaseNotes:D().min(1).max(2e4).nullable(),releaseNotesUrl:hO.nullable(),status:mO.nullable(),error:D().min(1).max(500).nullable(),stagedVersion:uO.nullable().optional(),backgroundPhase:gO.optional(),backgroundDownload:_O.nullable().optional(),backgroundError:D().min(1).max(500).nullable().optional(),runningTaskCount:O().int().nonnegative().optional()}),M({status:mO}),M({status:mO.nullable()}),M({supported:k(),enabled:k(),certificatePresent:k(),appSignedWithLocalCert:k(),appPath:D().min(1).nullable(),certificateName:D().min(1),certificateSha1:D().regex(/^[0-9A-Fa-f]{40}$/u).nullable()});let vO=M({icon:D().min(1).max(16).optional(),title:D().min(1).max(120),body:D().min(1).max(1200),contributors:A(D().min(1).max(39)).max(30)}),yO=M({summary:D().min(1).max(600).optional(),themes:A(vO).min(1).max(12)}),bO=M({version:uO,publishedAt:Bu(),url:D().max(300).regex(/^https:\/\/github\.com\/BytePioneer-AI\/codex-host\/releases\/tag\/v[0-9A-Za-z.+-]+$/u),zh:yO.nullable(),en:yO.nullable()}).refine(e=>e.zh!==null||e.en!==null,{message:`an announcement needs at least one language`});M({manual:k().optional()}),M({announcement:bO.nullable(),unread:k()}),M({version:uO}),RegExp(String.raw`^- \[([^\]\n]+)\]\(thread://([^\s()<>"?#/]+)\): `+`(${[`completed`,`failed`,`interrupted`,`needsInput`,`timedOut`,`unreadable`,`notFound`].join(`|`)})(?:\. (.+))?$`,`u`);let xO=`<response-annotations>`,SO=`</response-annotations>`,CO=/^\s*## My request(?: for Codex)?:[ \t]*(?:\r?\n|$)/u;function wO(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${xO}\n${JSON.stringify(t)}\n${SO}\n`}function TO(e,t){let n=wO(e);return n===``?t:`${n}\n## My request:\n${t}\n`}function EO(e){let t=e.trimStart().startsWith(`# Response annotations:`)?0:e.length,n=e.indexOf(`\n${xO}\n`,t);if(n<0)return;let r=n+1+22+1,i=e.indexOf(`\n${SO}`,r);if(!(i<0))return{json:e.slice(r,i),closeEnd:i+1+23}}function DO(e){let t=EO(e);if(t===void 0)return{annotations:[],body:e};let n=kO(t.json);if(n.length===0)return{annotations:[],body:e};let r=e.slice(t.closeEnd),i=CO.exec(r);if(i===null)return{annotations:[],body:e};let a=r.slice(i[0].length);return{annotations:n,body:i[0].endsWith(`\r
144
+ `)}return e}getTextContentSize(){let e=function(e){let t=0;for(let n of Yy(e)){let r=Xy(e,n);r!==null&&(t+=r.getTextContentSize())}return t}(this),t=this.getChildren(),n=t.length;for(let r=0;r<n;r++){let i=t[r];e+=i.getTextContentSize(),U(i)&&r!==n-1&&!i.isInline()&&(e+=2)}return e}getDirection(){return this.getLatest().__dir}getTextFormat(){return this.getLatest().__textFormat}hasFormat(e){if(e!==``){let t=Gd[e];return(this.getFormat()&t)!==0}return!1}hasTextFormat(e){let t=Ud[e];return(this.getTextFormat()&t)!==0}getFormatFlags(e,t){return K_(this.getLatest().__textFormat,e,t)}getTextStyle(){return this.getLatest().__textStyle}select(e,t){Ng();let n=V(),r=e,i=t,a=this.getChildrenSize();if(!this.canBeEmpty()){if(e===0&&t===0){let e=this.getFirstChild();if(z(e)||U(e))return e.select(0,0)}else if(!(e!==void 0&&e!==a||t!==void 0&&t!==a)){let e=this.getLastChild();if(z(e)||U(e))return e.select()}}r===void 0&&(r=a),i===void 0&&(i=a);let o=this.__key;return B(n)?(n.anchor.set(o,r,`element`),n.focus.set(o,i,`element`),n.dirty=!0,n):ig(o,r,o,i,`element`,`element`)}selectStart(){let e=this.getFirstDescendant();return e?e.selectStart():this.select()}selectEnd(){let e=this.getLastDescendant();return e?e.selectEnd():this.select()}clear(){let e=this.getWritable();return this.getChildren().forEach(e=>e.remove()),e}append(...e){return this.splice(this.getChildrenSize(),0,e)}setDirection(e){let t=this.getWritable();return t.__dir=e,t}setFormat(e){return this.getWritable().__format=e!==``&&Gd[e]||0,this}setStyle(e){return this.getWritable().__style=e||``,this}setTextFormat(e){let t=this.getWritable();return t.__textFormat=e,t}setTextStyle(e){let t=this.getWritable();return t.__textStyle=e,t}setIndent(e){return this.getWritable().__indent=e,this}splice(e,t,n){Zm(this)&&F(324,this.__key,this.__type);let r=this.getChildrenSize(),i=this.getWritable();e+t<=r||F(226,String(e),String(t),String(r));for(let e of n);let a=i.__key,o=[],s=[],c=this.getChildAtIndex(e+t),l=null,u=r-t+n.length;if(e!==0){if(e===r)l=this.getLastChild();else{let t=this.getChildAtIndex(e);t!==null&&(l=t.getPreviousSibling())}}if(t>0){let e=l===null?this.getFirstChild():l.getNextSibling();for(let n=0;n<t;n++){e===null&&F(100);let t=e.getNextSibling(),n=e.__key;J_(e.getWritable()),s.push(n),e=t}}let d=l;for(let e of n){d!==null&&e.is(d)&&(l=d=d.getPreviousSibling());let t=e.getWritable();t.__parent===a&&u--,J_(t);let n=e.__key;if(d===null)i.__first=n,t.__prev=null;else{let e=d.getWritable();e.__next=n,t.__prev=e.__key}e.__key===a&&F(76),t.__parent=a,o.push(n),d=e}if(e+t===r)d!==null&&(d.getWritable().__next=null,i.__last=d.__key);else if(c!==null){let e=c.getWritable();if(d!==null){let t=d.getWritable();e.__prev=d.__key,t.__next=c.__key}else e.__prev=null}if(i.__size=u,s.length){let e=V();if(B(e)){let t=new Set(s),n=new Set(o),{anchor:r,focus:i}=e;e_(r,t,n)&&dg(r,r.getNode(),this,l,c),e_(i,t,n)&&dg(i,i.getNode(),this,l,c),u!==0||this.canBeEmpty()||Rv(this)||this.remove()}}return i}getDOMSlot(e){return new ef(e)}exportDOM(e){let{element:t}=super.exportDOM(e);if(q(t)){let e=this.getIndent();e>0&&(t.style.paddingInlineStart=40*e+`px`,t.setAttribute(`data-lexical-indent`,String(e)));let n=this.getDirection();n&&(t.dir=n)}return{element:t}}exportJSON(){let e={children:[],direction:this.getDirection(),format:this.getFormatType(),indent:this.getIndent(),...super.exportJSON()},t=this.getTextFormat(),n=this.getTextStyle();return t===0&&n===``||Rv(this)||this.getChildren().some(z)||(t!==0&&(e.textFormat=t),n!==``&&(e.textStyle=n)),e}updateFromJSON(e){return super.updateFromJSON(e).setFormat(e.format).setIndent(e.indent).setDirection(e.direction).setTextFormat(e.textFormat||0).setTextStyle(e.textStyle||``)}insertNewAfter(e,t){return null}canIndent(){return!0}collapseAtStart(e){return!1}excludeFromCopy(e){return!1}canReplaceWith(e){return!0}canInsertAfter(e){return!0}canBeEmpty(){return!0}canInsertTextBefore(){return!0}canInsertTextAfter(){return!0}isInline(){return!1}isShadowRoot(){return!1}canMergeWith(e){return!1}extractWithChild(e,t,n){return!1}canMergeWhenEmpty(){return!1}reconcileObservedMutation(e,t){let n=_y(this,e,t),r=n.getFirstChild();for(let e=this.getFirstChild();e;e=e.getNextSibling()){let i=t.getElementByKey(e.getKey());i!==null&&(r==null?(n.insertChild(i),r=i):r!==i&&n.replaceChild(i,r),r=r.nextSibling)}}};function U(e){return e instanceof $g}function e_(e,t,n){let r=e.getNode();for(;r;){let e=r.__key;if(t.has(e)&&!n.has(e))return!0;r=r.getParent()}return!1}var t_=class extends $m{__slotHost;__slots;constructor(e){super(e),this.__slotHost=null,this.__slots=null}afterCloneFrom(e){super.afterCloneFrom(e),this.__key===e.__key&&(this.__slotHost=e.__slotHost,this.__slotHost!==null&&this.__parent!==null&&F(383,this.__key,String(this.__slotHost),String(this.__parent)),this.__slots=e.__slots)}decorate(e,t){return null}isIsolated(){return!1}isInline(){return!0}isKeyboardSelectable(){return!0}};function W(e){return e instanceof t_}var n_=class extends $g{__cachedText;$config(){return this.config(`root`,{extends:$g})}constructor(){super(`root`),this.__cachedText=null}getTopLevelElementOrThrow(){F(51)}getTextContent(){let e=this.__cachedText;return e===null||!Mg()&&H()._dirtyType!==0?super.getTextContent():e}remove(){F(52)}replace(e){F(53)}insertBefore(e){F(54)}insertAfter(e){F(55)}updateDOM(e,t){return!1}splice(e,t,n){for(let e of n)U(e)||W(e)||F(282);return super.splice(e,t,n)}static importJSON(e){return av().updateFromJSON(e)}collapseAtStart(){return!0}};function r_(e){return e instanceof n_}function i_(e){return new c_(of(e._nodeMap),null,e._slotsUsed)}function a_(){return new c_(/* @__PURE__ */ new Map([[`root`,new n_]]),null,!1)}function o_(e){let t=e.exportJSON(),n=e.constructor;if(t.type!==n.getType()&&F(130,n.name),U(e)){let r=t.children;Array.isArray(r)||F(59,n.name);let i=e.getChildren();for(let e=0;e<i.length;e++){let t=o_(i[e]);r.push(t)}}let r=Yy(e);if(r.length>0){let i={};for(let t of r){let r=Xy(e,t);r===null&&F(366,n.name,t),i[t]=o_(r)}t.$slots=i}return t}function s_(e){return e instanceof c_}var c_=class e{_nodeMap;_selection;_flushSync;_readOnly;_parsed;_slotsUsed;constructor(e,t=null,n=!1){this._nodeMap=e,this._selection=t||null,this._flushSync=!1,this._readOnly=!1,this._parsed=!1,this._slotsUsed=n}isEmpty(){return this._nodeMap.size===1&&this._selection===null}read(e,t){return Wg(t&&t.editor||null,this,e)}clone(t){let n=new e(this._nodeMap,t===void 0?this._selection:t,this._slotsUsed);return n._readOnly=!0,n}toJSON(){return Wg(null,this,()=>({root:o_(av())}))}},l_=class extends $g{$config(){return this.config(`artificial`,{extends:$g})}createDOM(e){return Qv().createElement(`div`)}},u_=class extends $m{$config(){return this.config(`linebreak`,{importDOM:{br:e=>m_(e)||h_(e)?null:{conversion:d_,priority:0}}})}getTextContent(){return`
145
+ `}createDOM(){return Qv().createElement(`br`)}updateDOM(){return!1}isInline(){return!0}};function d_(e){return{node:f_()}}function f_(){return Bv(new u_)}function p_(e){return e instanceof u_}function m_(e){let t=e.parentElement;if(t!==null&&py(t)){let n=t.firstChild;if(n===e||n.nextSibling===e&&g_(n)){let n=t.lastChild;if(n===e||n.previousSibling===e&&g_(n))return!0}}return!1}function h_(e){let t=e.parentElement;if(t!==null&&py(t)){let n=t.firstChild;if(n===e||n.nextSibling===e&&g_(n))return!1;let r=t.lastChild;if(r===e||r.previousSibling===e&&g_(r))return!0}return!1}function g_(e){return U_(e)&&/^( |\t|\r?\n)+$/.test(e.textContent||``)}var __=class extends $g{$config(){return this.config(`paragraph`,{extends:$g,importDOM:{p:()=>({conversion:v_,priority:0})}})}createDOM(e){let t=Qv().createElement(`p`),n=Sv(e.theme,`paragraph`);return n!==void 0&&t.classList.add(...n),t}updateDOM(e,t,n){return!1}exportDOM(e){let{element:t}=super.exportDOM(e);if(q(t)){this.isEmpty()&&t.append(Qv().createElement(`br`));let e=this.getFormatType();e&&(t.style.textAlign=e)}return{element:t}}exportJSON(){let e=super.exportJSON();if(e.textFormat===void 0||e.textStyle===void 0){let t=this.getChildren().find(z);t?(e.textFormat=t.getFormat(),e.textStyle=t.getStyle()):(e.textFormat=this.getTextFormat(),e.textStyle=this.getTextStyle())}return e}insertNewAfter(e,t){let n=y_();n.setTextFormat(e.format),n.setTextStyle(e.style);let r=this.getDirection();return n.setDirection(r),n.setFormat(this.getFormatType()),n.setStyle(this.getStyle()),this.insertAfter(n,t),n}collapseAtStart(){let e=this.getChildren();if(e.length===0||z(e[0])&&e[0].getTextContent().trim()===``){if(this.getNextSibling()!==null)return this.selectNext(),this.remove(),!0;if(this.getPreviousSibling()!==null)return this.selectPrevious(),this.remove(),!0}return!1}};function v_(e){let t=y_();if(Dy(t,e),Ty(e,t),t.getFormatType()===``){let n=e.getAttribute(`align`);n&&n&&n in Gd&&t.setFormat(n)}return Ey(t,e),{node:t}}function y_(){return Bv(new __)}function b_(e){return e instanceof __}function x_(e){console.warn(e)}function S_(e,t,n,r,i){let a=e._keyToDOMMap;a.clear(),e._editorState=a_(),e._pendingEditorState=r,e._compositionKey=null,e._dirtyType=0,e._cloneNotNeeded.clear(),e._dirtyLeaves=/* @__PURE__ */ new Set,e._dirtyElements.clear(),e._normalizedNodes=/* @__PURE__ */ new Set,i&&i.preserveUpdateQueue||(e._updateTags=/* @__PURE__ */ new Set,e._updates=[],e._cascadeCount=0),e._blockCursorElement=null,e._inputState.handledSelectionCommandTimeoutId!==null&&clearTimeout(e._inputState.handledSelectionCommandTimeoutId),e._inputState={collapsedSelectionFormat:{format:0,key:`root`,offset:0,style:``,timeStamp:0},compositionEndData:``,compositionPhase:`idle`,hadOrphanedCompositionEvents:!1,handledSelectionCommandTimeoutId:null,isInsertLineBreak:!1,isInsertTextAfterHandledSelectionCommand:!1,isSelectionChangeFromDOMUpdate:!1,isSelectionChangeFromMouseDown:!1,lastBeforeInputInsertTextTimeStamp:0,lastKeyCode:null,lastKeyDownTimeStamp:0,postDeleteSelectionToRestore:null,unprocessedBeforeInputData:null};let o=e._observer;o!==null&&(o.disconnect(),e._observer=null),t!==null&&(t.textContent=``,function(e,t){let n=`__lexicalKey_${t._key}`;delete e[n]}(t,e)),n!==null&&(n.textContent=``,a.set(`root`,n),ev(n,e,`root`))}function C_(e){let t=/* @__PURE__ */ new Set,n=/* @__PURE__ */ new Set;for(let{klass:r,ownNodeConfig:i}of Iy(e)){let e=r.transform;if(!n.has(e)){n.add(e);let i=r.transform();i&&t.add(i)}if(i){let e=i.$transform;e&&t.add(e)}}return t}let w_={$createDOM:(e,t)=>e.createDOM(t._config,t),$decorateDOM:(e,t,n,r)=>{},$exportDOM:(e,t)=>{let n=P_(t,e.getType());return n&&n.exportDOM!==void 0?n.exportDOM(t,e):e.exportDOM(t)},$extractWithChild:(e,t,n,r,i)=>U(e)&&e.extractWithChild(t,n,r),$getDOMSlot:(e,t,n)=>e.getDOMSlot(t),$getSlotTargetElement:(e,t,n,r)=>null,$shouldExclude:(e,t,n)=>U(e)&&e.excludeFromCopy(`html`),$shouldInclude:(e,t,n)=>!t||e.isSelected(t),$updateDOM:(e,t,n,r)=>e.updateDOM(t,n,r._config)};function T_(e){let t=e||{},n=zg(),r=t.theme||{},i=e===void 0?n:t.parentEditor||null,a=t.disableEvents||!1,o=a_(),s=t.namespace||(i===null?dv():i._config.namespace),c=t.editorState,l=[n_,gh,u_,Dh,__,l_,...t.nodes||[]],{onError:u,onWarn:d,html:f}=t,p=t.editable===void 0||t.editable,m;if(e===void 0&&n!==null)m=n._nodes;else{m=/* @__PURE__ */ new Map;for(let e=0;e<l.length;e++){let n=l[e],r=null,i=null;if(n&&typeof n==`object`){let e=n;n=e.replace,r=e.with,i=e.withKlass||null}if(typeof n!=`function`||!n.prototype||!(n===$m||n.prototype instanceof $m)){let r=`<unknown>`;try{r=JSON.parse(rf)}catch{}F(365,String(e-l.length+(t.nodes?t.nodes.length:0)),typeof n==`function`?`${n.name}${typeof n.getType==`function`?` (type ${String(n.getType())})`:``}`:String(n),String(r))}Fy(n);let a=n.getType(),o=C_(n);m.set(a,{exportDOM:f&&f.export?f.export.get(n):void 0,klass:n,replace:r,replaceWithKlass:i,sharedNodeState:xf(l[e]),transforms:o})}}let h=new O_(o,i,m,{disableEvents:a,dom:{...w_,...e&&e.dom},namespace:s,theme:r},u||console.error,d||x_,function(e,t){let n=/* @__PURE__ */ new Map,r=/* @__PURE__ */ new Set,i=e=>{Object.keys(e).forEach(t=>{let r=n.get(t);r===void 0&&(r=[],n.set(t,r)),r.push(e[t])})};return e.forEach(e=>{let t=e.klass.importDOM;if(t==null||r.has(t))return;r.add(t);let n=t.call(e.klass);n!==null&&i(n)}),t&&i(t),n}(m,f?f.import:void 0),p,e);return c!==void 0&&(h._pendingEditorState=c,h._dirtyType=2),function(e){e.registerCommand(jp,Im,0),e.registerCommand(Mp,Lm,0),e.registerCommand(Np,Rm,0),e.registerCommand(Pp,zm,0),e.registerCommand(Kp,Hm,0)}(h),h}function E_(e,t){let n=e.get(t);e.delete(t),n&&n()}function D_(e,t,n){return e.set(t,n),E_.bind(null,e,t)}var O_=class{static version;_headless;_parentEditor;_rootElement;_editorState;_pendingEditorState;_compositionKey;_deferred;_keyToDOMMap;_updates;_updating;_cascadeCount;_listeners;_commands;_nodes;_decorators;_pendingDecorators;_config;_dirtyType;_cloneNotNeeded;_dirtyLeaves;_dirtyElements;_normalizedNodes;_updateTags;_observer;_key;_onError;_onWarn;_htmlConversions;_window;_editable;_blockCursorElement;_slotsUsed;_inputState;_createEditorArgs;constructor(e,t,n,r,i,a,o,s,c){this._createEditorArgs=c,this._parentEditor=t,this._rootElement=null,this._editorState=e,this._pendingEditorState=null,this._compositionKey=null,this._deferred=[],this._keyToDOMMap=new sf,this._updates=[],this._updating=!1,this._cascadeCount=0,this._listeners={decorator:/* @__PURE__ */ new Map,editable:/* @__PURE__ */ new Map,mutation:/* @__PURE__ */ new Map,root:/* @__PURE__ */ new Map,textcontent:/* @__PURE__ */ new Map,update:/* @__PURE__ */ new Map},this._commands=/* @__PURE__ */ new Map,this._config=r,this._nodes=n,this._decorators={},this._pendingDecorators=null,this._dirtyType=0,this._cloneNotNeeded=/* @__PURE__ */ new Set,this._dirtyLeaves=/* @__PURE__ */ new Set,this._dirtyElements=/* @__PURE__ */ new Map,this._normalizedNodes=/* @__PURE__ */ new Set,this._updateTags=/* @__PURE__ */ new Set,this._observer=null,this._key=dv(),this._onError=i,this._onWarn=a,this._htmlConversions=o,this._editable=s,this._headless=t!==null&&t._headless,this._window=null,this._blockCursorElement=null,this._slotsUsed=!1,this._inputState={collapsedSelectionFormat:{format:0,key:`root`,offset:0,style:``,timeStamp:0},compositionEndData:``,compositionPhase:`idle`,hadOrphanedCompositionEvents:!1,handledSelectionCommandTimeoutId:null,isInsertLineBreak:!1,isInsertTextAfterHandledSelectionCommand:!1,isSelectionChangeFromDOMUpdate:!1,isSelectionChangeFromMouseDown:!1,lastBeforeInputInsertTextTimeStamp:0,lastKeyCode:null,lastKeyDownTimeStamp:0,postDeleteSelectionToRestore:null,unprocessedBeforeInputData:null}}isComposing(){return this._compositionKey!=null}registerUpdateListener(e){return D_(this._listeners.update,e)}registerEditableListener(e){return D_(this._listeners.editable,e)}registerDecoratorListener(e){return D_(this._listeners.decorator,e)}registerTextContentListener(e){return D_(this._listeners.textcontent,e)}registerRootListener(e){let t=this._listeners.root;return ux(D_(t,e,e(this._rootElement,null)||void 0),()=>function(e,t,n){let r=e.get(t);r&&r(),e.set(t,t(...n)||void 0)}(t,e,[null,this._rootElement]))}registerCommand(e,t,n){n===void 0&&F(35);let r=this._commands;r.has(e)||r.set(e,[new af,new af,new af,new af,new af]);let i=r.get(e);i===void 0&&F(36,String(e));let a=function(e){return 7&e}(n),o=i[a];return a===n?o.addBack(t):o.addFront(t),()=>{o.delete(t),i.every(e=>e.size===0)&&r.delete(e)}}registerMutationListener(e,t,n){let r=this.resolveRegisteredNodeAfterReplacements(this.getRegisteredNode(e)).klass,i=this._listeners.mutation,a=i.get(t);a===void 0&&(a=/* @__PURE__ */ new Set,i.set(t,a)),a.add(r);let o=n&&n.skipInitialization;return o!==void 0&&o||this.initializeMutationListener(t,r),()=>{a.delete(r),a.size===0&&i.delete(t)}}getRegisteredNode(e){let t=this._nodes.get(e.getType());return t===void 0&&F(37,e.name),t}resolveRegisteredNodeAfterReplacements(e){for(;e.replaceWithKlass;)e=this.getRegisteredNode(e.replaceWithKlass);return e}initializeMutationListener(e,t){let n=this._editorState,r=Sy(n).get(t.getType());if(!r)return;let i=/* @__PURE__ */ new Map;for(let e of r.keys())i.set(e,`created`);i.size>0&&e(i,{dirtyLeaves:/* @__PURE__ */ new Set,prevEditorState:n,updateTags:/* @__PURE__ */ new Set([`registerMutationListener`])})}registerNodeTransformToKlass(e,t){let n=this.getRegisteredNode(e);return n.transforms.add(t),n}registerNodeTransform(e,t){let n=this.registerNodeTransformToKlass(e,t),r=[n],i=n.replaceWithKlass;if(i!=null){let e=this.registerNodeTransformToKlass(i,t);r.push(e)}return function(e,t){let n=Sy(e.getEditorState()),r=[];for(let e of t){let t=n.get(e);t&&r.push(t)}r.length!==0&&e.update(()=>{for(let e of r)for(let t of e.keys()){let e=Q_(t);e&&e.markDirty()}},e._pendingEditorState===null?{tag:th}:void 0)}(this,r.map(e=>e.klass.getType())),()=>{r.forEach(e=>e.transforms.delete(t))}}hasNode(e){return this._nodes.has(e.getType())}hasNodes(e){return e.every(this.hasNode.bind(this))}dispatchCommand(e,...t){return K(this,e,...t)}getDecorators(){return this._decorators}getRootElement(){return this._rootElement}getKey(){return this._key}setRootElement(e){let t=this._rootElement;if(e!==t){let n=Sv(this._config.theme,`root`),r=this._pendingEditorState||this._editorState;if(this._rootElement=e,S_(this,t,e,r,{preserveUpdateQueue:!0}),t!==null&&(this._config.disableEvents||Jm(t),n!=null&&t.classList.remove(...n)),e!==null){let t=Nv(e),r=e.style;r.userSelect=`text`,r.whiteSpace=`pre-wrap`,r.wordBreak=`break-word`,e.setAttribute(`data-lexical-editor`,`true`),this._window=t,this._dirtyType=2,vf(this),this._updateTags.add(th),Gg(this),this._config.disableEvents||function(e,t){let n=e.ownerDocument;Cm.set(e,n);let r=wm.get(n);r===void 0&&(r={editors:/* @__PURE__ */ new Set,hasShadowEditor:void 0},wm.set(n,r)),r.editors.add(t),r.hasShadowEditor=void 0,e.__lexicalEditor=t;let i=Um(e);i.push(Tm.register(n));for(let n=0;n<Sm.length;n++){let[r,a]=Sm[n],o=typeof a==`function`?e=>{qm(e)||(Km(e),(t.isEditable()||r===`click`)&&a(e,t))}:e=>{if(qm(e))return;Km(e);let n=t.isEditable();switch(r){case`cut`:return n&&K(t,um,e);case`copy`:return K(t,lm,e);case`paste`:return n&&K(t,zp,e);case`dragstart`:return n&&K(t,om,e);case`dragover`:return n&&K(t,sm,e);case`dragend`:return n&&K(t,cm,e);case`focus`:return n&&K(t,gm,e);case`blur`:return n&&K(t,_m,e);case`drop`:return n&&K(t,am,e)}};i.push(bm(e,r,o))}}(e,this),n!=null&&e.classList.add(...n)}else this._window=null,this._updateTags.add(th),Gg(this);Kg(`root`,this,!1,e,t)}}getElementByKey(e){return this._keyToDOMMap.get(e)||null}getEditorState(){return this._editorState}setEditorState(e,t){e.isEmpty()&&F(38);let n=e;n._readOnly&&(n=i_(e),n._selection=e._selection?e._selection.clone():null),_f(this);let r=this._pendingEditorState,i=t===void 0?null:t.tag;r===null||r.isEmpty()||(i!=null&&this._updateTags.add(i),Gg(this)),this._pendingEditorState=n,this._dirtyType=2,this._dirtyElements.set(`root`,!1),this._compositionKey=null,this._slotsUsed=this._slotsUsed||e._slotsUsed,Zg(this,()=>{if(i&&this._updateTags.add(i),e._parsed)for(let[e,t]of n._nodeMap.entries())U(t)?this._dirtyElements.set(e,!0):this._dirtyLeaves.add(e)},{discrete:!this._updating||void 0})}parseEditorState(e,t){return function(e,t,n){let r=a_(),i=wg,a=Eg,o=Tg,s=t._dirtyElements,c=t._dirtyLeaves,l=t._cloneNotNeeded,u=t._dirtyType;t._dirtyElements=/* @__PURE__ */ new Map,t._dirtyLeaves=/* @__PURE__ */ new Set,t._cloneNotNeeded=/* @__PURE__ */ new Set,t._dirtyType=0,wg=r,Eg=!1,Tg=t,A_(null);try{let i=t._nodes;Ug(e.root,i),n&&n(),r._readOnly=!0,r._parsed=!0}catch(e){e instanceof Error&&t._onError(e)}finally{t._dirtyElements=s,t._dirtyLeaves=c,t._cloneNotNeeded=l,t._dirtyType=u,wg=i,Eg=a,Tg=o}return r}(typeof e==`string`?JSON.parse(e):e,this,t)}read(...e){let[t,n]=e.length===1?[`force-commit`,e[0]]:e;return t===`force-commit`&&Gg(this),(t===`pending`?this._pendingEditorState||this._editorState:this.getEditorState()).read(n,{editor:this})}update(e,t){(function(e,t,n){e._updating?e._updates.push([t,n]):Xg(e,t,n)})(this,e,t)}focus(e,t={}){let n=this._rootElement;n!==null&&(n.setAttribute(`autocapitalize`,`off`),Zg(this,()=>{let r=V(),i=av();r===null?i.getChildrenSize()!==0&&(t.defaultSelection===`rootStart`?i.selectStart():i.selectEnd()):r.dirty||ov(r.clone()),Av(`focus`),jv(()=>{n.removeAttribute(`autocapitalize`),e&&e()})}),this._pendingEditorState===null&&n.removeAttribute(`autocapitalize`))}blur(){let e=this._rootElement;e!==null&&e.blur();let t=Gv(this._window);t!==null&&t.removeAllRanges()}isEditable(){return this._editable}setEditable(e){this._editable!==e&&(this._editable=e,Kg(`editable`,this,!0,e),this._slotsUsed&&this.update(()=>Lg()))}toJSON(){return{editorState:this._editorState.toJSON()}}};O_.version=rf;let k_=null;function A_(e){k_=e}let j_=Symbol(`INTERNAL_SKIP_AFTER_CLONE_FROM`),M_=1;function N_(e,t){let n=P_(e,t);return n===void 0&&F(30,t),n}function P_(e,t){return e._nodes.get(t)}let F_=typeof queueMicrotask==`function`?queueMicrotask:e=>{Promise.resolve().then(e)};function I_(e,t){let n=t===void 0?(()=>{let t=e.getRootNode();return W_(t)||qv(t)?oy(t):null})():t;if(!q(n)||n.hasAttribute(`data-lexical-slot`))return!1;let r=nv(n),i=n.nodeName;return eh(r)&&(i===`INPUT`||i===`TEXTAREA`||n.contentEditable===`true`&&B_(n)==null)}function L_(e,t,n){let r=e.getRootElement();if(!r)return!1;try{if(!t||!r.contains(t)||!r.contains(n))return!1}catch{return!1}return z_(t)===e&&e.read(`latest`,()=>!I_(t))}function R_(e){return e instanceof O_}function z_(e){let t=e;for(;t!=null;){let e=B_(t);if(R_(e))return e;t=Ov(t)}return null}function B_(e){return e?e.__lexicalEditor:null}function V_(e){return kh(e)||e.isToken()}function H_(e){return V_(e)||e.isSegmented()}function U_(e){return cy(e)&&e.nodeType===3}function W_(e){return cy(e)&&e.nodeType===9}function G_(e){let t=e;for(;t!=null;){if(U_(t))return t;t=t.firstChild}return null}function K_(e,t,n){let r=Ud[t];if(n!==null&&(e&r)===(n&r))return e;let i=e^r;return t===`subscript`?i&=~Ud.superscript:t===`superscript`?i&=~Ud.subscript:t===`lowercase`?(i&=~Ud.uppercase,i&=~Ud.capitalize):t===`uppercase`?(i&=~Ud.lowercase,i&=~Ud.capitalize):t===`capitalize`&&(i&=~Ud.lowercase,i&=~Ud.uppercase),i}function q_(e,t){let n=function(){let e=k_;return k_=null,e}();if((t||=n&&n.__key)!=null)return void(e.__key=t);Ng(),Pg();let r=H(),i=Fg(),a=``+M_++;i._nodeMap.set(a,e),U(e)?r._dirtyElements.set(a,!0):r._dirtyLeaves.add(a),r._cloneNotNeeded.add(a),r._dirtyType===0&&(r._dirtyType=1),e.__key=a}function J_(e){Wy(e)!==null&&F(380,e.__key,String(Wy(e)));let t=e.getParent();if(t!==null){let n=e.getWritable(),r=t.getWritable(),i=e.getPreviousSibling(),a=e.getNextSibling(),o=a===null?null:a.__key,s=i===null?null:i.__key,c=i===null?null:i.getWritable(),l=a===null?null:a.getWritable();i===null&&(r.__first=o),a===null&&(r.__last=s),c!==null&&(c.__next=o),l!==null&&(l.__prev=s),n.__prev=null,n.__next=null,n.__parent=null,r.__size--}}function Y_(e){Pg(),Zm(e)&&F(323,e.__key,e.__type);let t=e.getLatest(),n=t.__parent===null?Uy(t)?t.__slotHost:null:t.__parent,r=Fg(),i=H(),a=r._nodeMap,o=i._dirtyElements;n!==null&&function(e,t,n){let r=e;for(;r!==null;){if(n.has(r))return;let e=t.get(r);if(e===void 0)break;n.set(r,!1),r=e.__parent===null?Uy(e)?e.__slotHost:null:e.__parent}}(n,a,o);let s=t.__key;i._dirtyType===0&&(i._dirtyType=1),U(e)?o.set(s,!0):i._dirtyLeaves.add(s)}function X_(e){Ng();let t=H(),n=t._compositionKey;if(e!==n){if(t._compositionKey=e,n!==null){let e=Q_(n);e!==null&&e.getWritable()}if(e!==null){let t=Q_(e);t!==null&&t.getWritable()}}}function Z_(){return Mg()?null:H()._compositionKey}function Q_(e,t){let n=(t||Fg())._nodeMap.get(e);return n===void 0?null:n}function $_(e,t){let n=tv(e,H());return n===void 0?null:Q_(n,t)}function ev(e,t,n){e[`__lexicalKey_${t._key}`]=n}function tv(e,t){return e[`__lexicalKey_${t._key}`]}function nv(e,t){let n=e;for(;n!=null;){let e=$_(n,t);if(e!==null)return e;n=Ov(n)}return null}function rv(e){let t=e._decorators,n=Object.assign({},t);return e._pendingDecorators=n,n}function iv(e){return e.read(()=>av().getTextContent())}function av(){return Fg()._nodeMap.get(`root`)}function ov(e){Ng();let t=Fg();e!==null&&(e.dirty=!0,e.setCachedNodes(null),B(e)&&H()._slotsUsed&&tg(e)),t._selection=e}function sv(){Ng(),_f(H())}function cv(e){let t=function(e,t){let n=e;for(;n!=null;){let e=tv(n,t);if(e!==void 0)return e;n=Ov(n)}return null}(e,H());return t===null?null:Q_(t)}function lv(e){return/[\uD800-\uDBFF][\uDC00-\uDFFF]/g.test(e)}function uv(e){let t=[];for(let n=e;n!==null;n=n._parentEditor)t.push(n);return t}function dv(){return Math.random().toString(36).replace(/[^a-z]+/g,``).substring(0,5)}function fv(e){return U_(e)?e.nodeValue:null}function pv(e,t,n){let r=Gv(Pv(t));if(r===null)return;let i=ty(r,t._rootElement),a=i.anchorNode,{anchorOffset:o,focusOffset:s}=i;if(a!==null){let t=fv(a),r=nv(a);if(t!==null&&z(r)){if((t===zd||t===Bd)&&n){let e=n.length;t=n,o=e,s=e}t!==null&&mv(r,t,o,s,e)}}}function mv(e,t,n,r,i){let a=e;if(a.isAttached()&&(i||!a.isDirty())){let o=a.isComposing();if(a.isToken()&&o)return;let s=t;if((o||i)&&(t.endsWith(zd)&&(s=t.slice(0,-zd.length)),i)){let e=Bd,t;for(;(t=s.indexOf(e))!==-1;)s=s.slice(0,t)+s.slice(t+e.length),n!==null&&n>t&&(n=Math.max(t,n-e.length)),r!==null&&r>t&&(r=Math.max(t,r-e.length))}let c=a.getTextContent();if(i||s!==c){let t=V();if(s===``){if(X_(null),Fd||Nd||Rd)a.remove();else{let e=H();hv(a,``,t),setTimeout(()=>{e.update(()=>{a.isAttached()&&a.getTextContent()===``&&a.remove()})},20)}return}let i=a.getParent(),c=cg(),l=a.getTextContentSize(),u=Z_(),d=a.getKey();if(a.isToken()&&!o||u!==null&&d===u&&!o||B(c)&&(i!==null&&!i.canInsertTextBefore()&&c.anchor.offset===0||c.anchor.key===e.__key&&c.anchor.offset===0&&!a.canInsertTextBefore()&&!o||c.focus.key===e.__key&&c.focus.offset===l&&!a.canInsertTextAfter()&&!o))return void a.markDirty();if(!B(t)||n===null||r===null)return void hv(a,s,t);if(t.setTextNodeRange(a,n,a,r),a.isSegmented()){let e=Th(a.getTextContent());a.replace(e),a=e}hv(a,s,t)}}}function hv(e,t,n){if(e.setTextContent(t),B(n)){let t=e.getKey(),r=!1;for(let i of[`anchor`,`focus`]){let a=n[i];a.type===`text`&&a.key===t&&(a.offset=Tb(e,a.offset,`clamp`),r=!0)}r&&(n._cachedNodes=null,n._cachedIsBackward=null)}}function gv(e,t,n){let r=t[n]||!1;return r===`any`||r===e[n]}function _v(e,t){return gv(e,t,`altKey`)&&gv(e,t,`ctrlKey`)&&gv(e,t,`shiftKey`)&&gv(e,t,`metaKey`)}function G(e,t,n){if(!_v(e,n))return!1;if(e.key.toLowerCase()===t.toLowerCase())return!0;if(t.length>1||e.key.length===1&&e.key.charCodeAt(0)<=127)return!1;if(e.code.startsWith(`Digit`)&&/^\d$/.test(t))return e.code===`Digit${t}`;let r=`Key`+t.toUpperCase();return e.code===r}let vv={ctrlKey:!Ad,metaKey:Ad},yv={altKey:Ad,ctrlKey:!Ad};function bv(e){return e.key===`Backspace`}function xv(e){let t=av();if(B(e)){let t=e.anchor,n=e.focus,r=t.getNode();if(r_(r))return t.set(r.getKey(),0,`element`),n.set(r.getKey(),r.getChildrenSize(),`element`),Pf(e),e;let i=r.getTopLevelElementOrThrow(),a=i.getParent();if(a===null)return U(i)&&(t.set(i.getKey(),0,`element`),n.set(i.getKey(),i.getChildrenSize(),`element`),Pf(e)),e;let o=a;return t.set(o.getKey(),0,`element`),n.set(o.getKey(),o.getChildrenSize(),`element`),Pf(e),e}{let e=t.select(0,t.getChildrenSize());return ov(Pf(e)),e}}function Sv(e,t){e.__lexicalClassNameCache===void 0&&(e.__lexicalClassNameCache={});let n=e.__lexicalClassNameCache,r=n[t];if(r!==void 0)return r;let i=e[t];if(typeof i==`string`){let e=cx(i);return n[t]=e,e}return i}function Cv(e,t,n,r,i){if(n.size===0)return;let a=r.__type,o=r.__key,s=t.get(a);s===void 0&&F(33,a);let c=s.klass,l=e.get(c);l===void 0&&(l=/* @__PURE__ */ new Map,e.set(c,l));let u=l.get(o),d=u===`destroyed`&&i===`created`;(u===void 0||d)&&l.set(o,d?`updated`:i)}function wv(e,t,n){let r=e.getParent(),i=n,a=e;return r!==null&&(t&&n===0?(i=a.getIndexWithinParent(),a=r):t||n!==a.getChildrenSize()||(i=a.getIndexWithinParent()+1,a=r)),a.getChildAtIndex(t?i-1:i)}function Tv(e,t){let n=e.offset;if(e.type===`element`)return wv(e.getNode(),t,n);{let r=e.getNode();if(t&&n===0||!t&&n===r.getTextContentSize()){let e=t?r.getPreviousSibling():r.getNextSibling();return e===null?wv(r.getParentOrThrow(),t,r.getIndexWithinParent()+ +!t):e}}return null}function Ev(e){let t=Pv(e).event,n=t&&t.inputType;return n===`insertFromPaste`||n===`insertFromPasteAsQuotation`}function K(e,t,...n){return qg(e,t,n[0],e)}function Dv(e,t){let n=e._keyToDOMMap.get(t);return n===void 0&&F(75,t),n}function Ov(e){let t=e.assignedSlot||e.parentElement;if(t!==null)return t;let n=e.parentNode;return qv(n)?n.host:null}function kv(e){return W_(e)?e:q(e)?e.ownerDocument:null}function Av(e){Ng(),H()._updateTags.add(e)}function jv(e){Ng(),H()._deferred.push(e)}function Mv(e,t){let n=e.getParent();for(;n!==null;){if(n.is(t))return!0;n=n.getParent()}return!1}function Nv(e){let t=kv(e);return t?t.defaultView:null}function Pv(e){let t=e._window;return t===null&&F(78),t}function Fv(e){return U(e)&&e.isInline()||W(e)&&e.isInline()}function Iv(e){let t=e.getLatest();for(;t!==null;){if(Wy(t)!==null&&U(t))return t;let e=t.getParentOrThrow();if(Rv(e))return e;t=e}return t}function Lv(e){return U(e)&&e.isShadowRoot()}function Rv(e){return r_(e)||Lv(e)}function zv(e,t=!1){let n=e.constructor.clone(e,j_);return q_(n,null),n.afterCloneFrom(e),t||n.resetOnCopyNodeFrom(e),n}function Bv(e){let t=H(),n=e.getType(),r=P_(t,n);r===void 0&&F(200,e.constructor.name,n);let{replace:i,replaceWithKlass:a}=r;if(i!==null){let t=i(e),r=t.constructor;return a===null?t instanceof e.constructor&&r!==e.constructor||F(202,r.name,r.getType(),e.constructor.name,n):t instanceof a||F(201,a.name,a.getType(),r.name,r.getType(),e.constructor.name,n),t.__key===e.__key&&F(203,e.constructor.name,n,r.name,r.getType()),t}return e}function Vv(e,t){!r_(e.getParent())||U(t)||W(t)||F(99)}function Hv(e){let t=Q_(e);return t===null&&F(63,e),t}function Uv(e){if(!e||e.isInline())return!1;if(W(e))return!0;if(U(e)){if(e.isShadowRoot()){let t=e.getParent();return!(U(t)&&t.isShadowRoot())}return!e.canBeEmpty()}return!1}function Wv(e,t,n){n.style.removeProperty(`caret-color`),t._blockCursorElement=null;let r=e.parentElement;r!==null&&r.removeChild(e)}function Gv(e){return Od?(e||window).getSelection():null}function Kv(e){let t=Nv(e);return t?t.getSelection():null}function qv(e){return ly(e)&&`host`in e}let Jv=[];function Yv(e){let t=e.getRootNode();if(t===e||!qv(t))return Jv;let n=[t],r=t.host;for(;;){let e=r.getRootNode();if(e===r||!qv(e))break;n.push(e),r=e.host}return n}function*Xv(e){let t=[e],n;for(;n=t.pop();){yield*n.querySelectorAll(`[data-lexical-editor="true"]`);let e=(W_(n)?n:n.ownerDocument).createTreeWalker(n,NodeFilter.SHOW_ELEMENT),r;for(;r=e.nextNode();)r.shadowRoot&&t.push(r.shadowRoot)}}function Zv(e){return e===null?document:e.ownerDocument}function Qv(){let e=zg();return Zv(e===null?null:e._rootElement)}function $v(e,t){if(t===null||typeof e.getComposedRanges!=`function`)return null;let n=Yv(t);if(n.length===0)return null;let r=e.getComposedRanges;try{let t=r.call(e,{shadowRoots:n})[0];if(t!==void 0)return t}catch{}try{let t=r.apply(e,n)[0];if(t!==void 0)return t}catch{}return null}function ey(e,t){let n=$v(e,t);if(n!==null){let e=ny(n);if(e!==null)return e}return e.rangeCount>0?e.getRangeAt(0):null}function ty(e,t){let n=$v(e,t);return n===null?e:ry(n,iy(e))}function ny(e){let t=e.startContainer.ownerDocument;if(t===null)return null;let n=t.createRange();try{return n.setStart(e.startContainer,e.startOffset),n.setEnd(e.endContainer,e.endOffset),n}catch{return null}}function ry(e,t){let{startContainer:n,startOffset:r,endContainer:i,endOffset:a}=e;return t===`backward`?{anchorNode:i,anchorOffset:a,direction:t,focusNode:n,focusOffset:r}:{anchorNode:n,anchorOffset:r,direction:t,focusNode:i,focusOffset:a}}function iy(e){return e.direction}function ay(e){let t=e.getRootNode();return W_(t)||qv(t)?t.activeElement:null}function oy(e){let t=e.activeElement;for(;t!==null&&t.shadowRoot!==null;){let e=t.shadowRoot.activeElement;if(e===null)break;t=e}return t}function sy(e){let t=e.target;if(t!==null&&q(t)&&t.shadowRoot!==null&&typeof e.composedPath==`function`){let t=e.composedPath();if(t.length>0)return t[0]}return t}function q(e){return cy(e)&&e.nodeType===1}function cy(e){return typeof e==`object`&&!!e&&`nodeType`in e&&typeof e.nodeType==`number`}function ly(e){return cy(e)&&e.nodeType===11}let uy=/^(a|abbr|acronym|b|cite|code|del|em|i|ins|kbd|label|mark|output|q|ruby|s|samp|span|strong|sub|sup|time|u|tt|var|#text)$/i;function dy(e){return!(!q(e)||!e.style.display.startsWith(`inline`))||uy.test(e.nodeName)}let fy=/^(address|article|aside|blockquote|canvas|dd|div|dl|dt|fieldset|figcaption|figure|footer|form|h1|h2|h3|h4|h5|h6|header|hr|li|main|nav|noscript|ol|p|pre|section|table|td|tfoot|ul|video)$/i;function py(e){return(!q(e)||!e.style.display.startsWith(`inline`))&&fy.test(e.nodeName)}function my(e){if(W(e)&&!e.isInline())return!0;if(!U(e)||Rv(e))return!1;let t=e.getFirstChild(),n=t===null||p_(t)||z(t)||t.isInline();return!e.isInline()&&!1!==e.canBeEmpty()&&n}function hy(){return H()}function gy(e=hy()){return e._config.dom||w_}function _y(e,t,n=hy()){let r=gy(n).$getDOMSlot(e,t,n);return U(e)&&(vy(r)||F(344,e.getKey(),e.getType())),r}function vy(e){return e instanceof ef}function yy(e,t,n=hy()){return G_(_y(e,t,n).element)}let by=/* @__PURE__ */ new WeakMap,xy=/* @__PURE__ */ new Map;function Sy(e){if(!e._readOnly&&e.isEmpty())return xy;e._readOnly||F(192);let t=by.get(e);return t||(t=function(e){let t=/* @__PURE__ */ new Map;for(let[n,r]of e._nodeMap){let e=r.__type,i=t.get(e);i||(i=/* @__PURE__ */ new Map,t.set(e,i)),i.set(n,r)}return t}(e),by.set(e,t)),t}function Cy(e){let t=e.constructor.clone(e,j_);return t.afterCloneFrom(e),t}function wy(e){return(t=Cy(e))[Xm]=!0,t;var t}function Ty(e,t){let n=e.getAttribute(`data-lexical-indent`);if(n!==null){let e=parseInt(n,10);if(Number.isFinite(e)&&e>=0)return void t.setIndent(e)}let r=parseInt(e.style.paddingInlineStart,10)||0,i=Math.round(r/40);t.setIndent(i)}function Ey(e,t){let n=t.getAttribute(`dir`);return n===`ltr`||n===`rtl`?e.setDirection(n):e}function Dy(e,t){let n=t.style.textAlign;return n&&n in Gd?e.setFormat(n):e}function Oy(e,t){e.__lexicalUnmanaged=!0,t&&t.captureSelection!==void 0&&(e.__lexicalCapturedSelection=t.captureSelection)}function ky(e){return!0===e.__lexicalUnmanaged}function Ay(e,t=hy()){let n=t.isEditable();e.contentEditable=n?`true`:`false`,n?e.__lexicalEditor=t:delete e.__lexicalEditor}function jy(e,t){let n=e;for(;n!=null;){if(!0===n.__lexicalCapturedSelection)return!0;if(q(n)&&n.hasAttribute(`data-lexical-slot`)||tv(n,t)!==void 0)return!1;n=Ov(n)}return!1}function My(e,t){return function(e,t){return Object.prototype.hasOwnProperty.call(e,t)}(e,t)&&e[t]!==$m[t]}let Ny=/* @__PURE__ */ new WeakMap,Py=Symbol(`lexical.synthesizedGetType`);function Fy(e){let t=Ny.get(e);if(t)return t;let n=e.prototype!=null&&Yd in e.prototype?e.prototype[Yd]():void 0,r=function(e){if(!(e===$m||e.prototype instanceof $m)){let t=`<unknown>`,n=`<unknown>`;try{t=e.getType()}catch{}try{O_.version&&(n=JSON.parse(O_.version))}catch{}F(290,e.name,t,n)}return e===t_||e===$g||e===$m}(e),i=!r&&My(e,`getType`)?e.getType:void 0,a=i&&!(Py in i)?i.call(e):void 0,o,s=a;if(n){if(a)o=n[a];else{for(let[e,t]of Object.entries(n))s=e,o=t;if(!o)for(let e of Object.getOwnPropertySymbols(n)){let t=n[e];if(t){o=t;break}}}}if(!r&&s){if(!My(e,`getType`)){let t=e,n=function(){return this===t?s:$m.getType.call(this)};n[Py]=!0,e.getType=n}if(My(e,`clone`)||(e.clone=(t,n)=>{A_(t);let r=new e;return n!==j_&&r.afterCloneFrom(t),r}),My(e,`importJSON`)||(e.importJSON=o&&o.$importJSON||(t=>new e().updateFromJSON(t))),!My(e,`importDOM`)&&o){let{importDOM:t}=o;t&&(e.importDOM=()=>t)}}let c={klass:e,ownNodeConfig:o,ownNodeType:s};return Ny.set(e,c),c}function*Iy(e){for(let t=e;t&&(t===$m||eh(t.prototype));){let e=Fy(t);yield e,t=e.ownNodeConfig&&e.ownNodeConfig.extends||By(t)}}function Ly(e){let t=hy();return Ng(),new(t.resolveRegisteredNodeAfterReplacements(t.getRegisteredNode(e))).klass}let Ry=(e,t)=>{let n=e;for(;n!=null&&!r_(n);){if(t(n))return n;n=n.getParent()}return null};function zy(e,t){let n=[],r=e.__first;for(;r!==null;){let e=t===null?Q_(r):t.get(r);e??F(174),n.push(r),r=e.__next}return n}function By(e){let t=Object.getPrototypeOf(e);if(typeof t==`function`&&t!==Function.prototype)return t;let n=e.prototype&&Object.getPrototypeOf(e.prototype);return n?n.constructor:null}let Vy=/* @__PURE__ */ new Map;function Hy(e){return U(e)||W(e)}function Uy(e){return U(e)||W(e)}function Wy(e){let t=e.getLatest();return Uy(t)?t.__slotHost:null}function Gy(e){let t=Wy(e);if(t===null)return null;let n=Q_(t);return U(n)||W(n)||F(370),n}function Ky(e){let t=Gy(e);if(t===null)return null;let n=e.getLatest().__key;for(let[e,r]of Jy(t))if(r===n)return e;return null}function qy(e){let t=e.getLatest();for(;t!==null;){if(Wy(t)!==null)return t;t=t.getParent()}return null}function Jy(e){let t=e.getLatest();return Hy(t)&&t.__slots!==null?t.__slots:Vy}function Yy(e){return Array.from(Jy(e).keys())}function Xy(e,t){let n=Jy(e).get(t);return n===void 0?null:Q_(n)}let Zy=[`__proto__`,`constructor`,`prototype`],Qy=Symbol(`slotMapOwner`);function $y(e){let t=e.__slots;return t!==null&&t[Qy]===e||(t=new Map(t),t[Qy]=e,e.__slots=t),t}let eb=/* @__PURE__ */ new WeakMap,tb=[];function nb(e){for(let{ownNodeConfig:t}of Iy(e)){let e=t&&t.slots;if(e)return e}return tb}function rb(e){let t=``;for(let n of Yy(e)){let r=Xy(e,n);r!==null&&(t+=r.getTextContent())}return t}function ib(e,t,n){let r=n.get(e),i=n.get(t);return r===void 0?i===void 0?e<t?-1:+(e>t):1:i===void 0?-1:r-i}function ab(e){let t=e.__slots;if(t===null||t.size<2)return;let n=function(e){let t=eb.get(e);if(t===void 0){let n=nb(e),r=/* @__PURE__ */ new Map;for(let t of n)Zy.includes(t)&&F(371,e.name,t),r.has(t)&&F(372,e.name,t),r.set(t,r.size);t=r,eb.set(e,t)}return t}(e.constructor),r=null,i=!0;for(let e of t.keys()){if(r!==null&&ib(r,e,n)>0){i=!1;break}r=e}if(i)return;let a=Array.from(t).sort(([e],[t])=>ib(e,t,n));t.clear();for(let[e,n]of a)t.set(e,n)}function ob(e,t,n){t!==`__proto__`&&t!==`constructor`&&t!==`prototype`||F(373,t);let r=e.getLatest();if(r.__slots!==null&&r.__slots.get(t)===n.getLatest().__key)return r;(!U(n)&&!W(n)||n.isInline())&&F(374,n.__key);let i=e.getWritable(),a=$y(i),o=a.get(t);o!==void 0&&cb(o);let s=n.getWritable(),c=Gy(s);if(c!==null){let e=Ky(s);e!==null&&$y(c.getWritable()).delete(e),s.__slotHost=null}return J_(s),s.__slotHost=i.__key,a.set(t,s.__key),ab(i),function(){let e=hy();e._slotsUsed=!0,e._pendingEditorState&&(e._pendingEditorState._slotsUsed=!0)}(),i}function sb(e,t){let n=e.getWritable();if(n.__slots===null)return n;let r=n.__slots.get(t);return r!==void 0&&(cb(r),$y(n).delete(t)),n}function cb(e){let t=Q_(e);if(t===null)return;let n=t.getWritable();Uy(n)||F(377,e),n.__slotHost=null,n.remove()}let lb={next:`previous`,previous:`next`};var ub=class{origin;constructor(e){this.origin=e}[Symbol.iterator](){return Fb({hasNext:vb,initial:this.getAdjacentCaret(),map:e=>e,step:e=>e.getAdjacentCaret()})}getAdjacentCaret(){return Cb(this.getNodeAtCaret(),this.direction)}getSiblingCaret(){return Cb(this.origin,this.direction)}remove(){let e=this.getNodeAtCaret();return e&&e.remove(),this}replaceOrInsert(e,t){let n=this.getNodeAtCaret();return e.is(this.origin)||e.is(n)||(n===null?this.insert(e):n.replace(e,t)),this}splice(e,t,n=`next`){let r=n===this.direction?t:Array.from(t).reverse(),i=this,a=this.getParentAtCaret(),o=/* @__PURE__ */ new Map;for(let t=i.getAdjacentCaret();t!==null&&o.size<e;t=t.getAdjacentCaret()){let e=t.origin.getWritable();o.set(e.getKey(),e)}for(let e of r){if(o.size>0){let t=i.getNodeAtCaret();if(t){if(o.delete(t.getKey()),o.delete(e.getKey()),!(t.is(e)||i.origin.is(e))){let n=e.getParent();n&&n.is(a)&&e.remove(),t.replace(e)}}else t===null&&F(263,Array.from(o).join(` `))}else i.insert(e);i=Cb(e,this.direction)}for(let e of o.values())e.remove();return this}},db=class e extends ub{type=`child`;getLatest(){let e=this.origin.getLatest();return e===this.origin?this:Db(e,this.direction)}getParentCaret(e=`root`){return Cb(mb(this.getParentAtCaret(),e),this.direction)}getFlipped(){let e=pb(this.direction);return Cb(this.getNodeAtCaret(),e)||Db(this.origin,e)}getParentAtCaret(){return this.origin}getChildCaret(){return this}isSameNodeCaret(t){return t instanceof e&&this.direction===t.direction&&this.origin.is(t.origin)}isSamePointCaret(e){return this.isSameNodeCaret(e)}};let fb={root:r_,shadowRoot:Rv};function pb(e){return lb[e]}function mb(e,t=`root`){return e===null||fb[t](e)?null:Wy(e)===null?e:null}var hb=class e extends ub{type=`sibling`;getLatest(){let e=this.origin.getLatest();return e===this.origin?this:Cb(e,this.direction)}getSiblingCaret(){return this}getParentAtCaret(){return this.origin.getParent()}getChildCaret(){return U(this.origin)?Db(this.origin,this.direction):null}getParentCaret(e=`root`){return Cb(mb(this.getParentAtCaret(),e),this.direction)}getFlipped(){let e=pb(this.direction);return Cb(this.getNodeAtCaret(),e)||Db(this.origin.getParentOrThrow(),e)}isSamePointCaret(t){return t instanceof e&&this.direction===t.direction&&this.origin.is(t.origin)}isSameNodeCaret(t){return(t instanceof e||t instanceof gb)&&this.direction===t.direction&&this.origin.is(t.origin)}},gb=class e extends ub{type=`text`;offset;constructor(e,t){super(e),this.offset=t}getLatest(){let e=this.origin.getLatest();return e===this.origin?this:wb(e,this.direction,this.offset)}getParentAtCaret(){return this.origin.getParent()}getChildCaret(){return null}getParentCaret(e=`root`){return Cb(mb(this.getParentAtCaret(),e),this.direction)}getFlipped(){return wb(this.origin,pb(this.direction),this.offset)}isSamePointCaret(t){return t instanceof e&&this.direction===t.direction&&this.origin.is(t.origin)&&this.offset===t.offset}isSameNodeCaret(t){return(t instanceof hb||t instanceof e)&&this.direction===t.direction&&this.origin.is(t.origin)}getSiblingCaret(){return Cb(this.origin,this.direction)}};function _b(e){return e instanceof gb}function vb(e){return e instanceof hb}function yb(e){return e instanceof db}let bb={next:class extends gb{direction=`next`;getNodeAtCaret(){return this.origin.getNextSibling()}insert(e){return this.origin.insertAfter(e),this}},previous:class extends gb{direction=`previous`;getNodeAtCaret(){return this.origin.getPreviousSibling()}insert(e){return this.origin.insertBefore(e),this}}},xb={next:class extends hb{direction=`next`;getNodeAtCaret(){return this.origin.getNextSibling()}insert(e){return this.origin.insertAfter(e),this}},previous:class extends hb{direction=`previous`;getNodeAtCaret(){return this.origin.getPreviousSibling()}insert(e){return this.origin.insertBefore(e),this}}},Sb={next:class extends db{direction=`next`;getNodeAtCaret(){return this.origin.getFirstChild()}insert(e){return this.origin.splice(0,0,[e]),this}},previous:class extends db{direction=`previous`;getNodeAtCaret(){return this.origin.getLastChild()}insert(e){return this.origin.splice(this.origin.getChildrenSize(),0,[e]),this}}};function Cb(e,t){return e?new xb[t](e):null}function wb(e,t,n){return e?new bb[t](e,Tb(e,n)):null}function Tb(e,t,n=`error`){let r=e.getTextContentSize(),i=t===`next`?r:t===`previous`?0:t;return(i<0||i>r)&&(n!==`clamp`&&Dd(284,String(t),String(r),e.getKey()),i=i<0?0:r),i}function Eb(e,t){return new jb(e,t)}function Db(e,t){return U(e)?new Sb[t](e):null}function Ob(e){return e&&e.getChildCaret()||e}function kb(e){return e&&Ob(e.getAdjacentCaret())}var Ab=class e{type=`node-caret-range`;direction;anchor;focus;constructor(e,t,n){this.anchor=e,this.focus=t,this.direction=n}getLatest(){let t=this.anchor.getLatest(),n=this.focus.getLatest();return t===this.anchor&&n===this.focus?this:new e(t,n,this.direction)}isCollapsed(){return this.anchor.isSamePointCaret(this.focus)}getTextSlices(){let e=e=>{let t=this[e].getLatest();return _b(t)?function(e,t){let{direction:n,origin:r}=e;return Eb(e,Tb(r,t===`focus`?pb(n):n)-e.offset)}(t,e):null},t=e(`anchor`),n=e(`focus`);if(t&&n){let{caret:e}=t,{caret:r}=n;if(e.isSameNodeCaret(r))return[Eb(e,r.offset-e.offset),null]}return[t,n]}iterNodeCarets(e=`root`){let t=_b(this.anchor)?this.anchor.getSiblingCaret():this.anchor.getLatest(),n=this.focus.getLatest(),r=_b(n),i=t=>t.isSameNodeCaret(n)?null:kb(t)||t.getParentCaret(e);return Fb({hasNext:e=>e!==null&&!(r&&n.isSameNodeCaret(e)),initial:t.isSameNodeCaret(n)?null:i(t),map:e=>e,step:i})}[Symbol.iterator](){return this.iterNodeCarets(`root`)}},jb=class{type=`slice`;caret;distance;constructor(e,t){this.caret=e,this.distance=t}getSliceIndices(){let{distance:e,caret:{offset:t}}=this,n=t+e;return n<t?[n,t]:[t,n]}getTextContent(){let[e,t]=this.getSliceIndices();return this.caret.origin.getTextContent().slice(e,t)}getTextContentSize(){return Math.abs(this.distance)}removeTextSlice(){let{caret:{origin:e,direction:t}}=this,[n,r]=this.getSliceIndices(),i=e.getTextContent();return wb(e.setTextContent(i.slice(0,n)+i.slice(r)),t,n)}};function Mb(e){return Pb(e,Cb(av(),e.direction))}function Nb(e){return Pb(e,e)}function Pb(e,t){return e.direction!==t.direction&&F(265),new Ab(e,t,e.direction)}function Fb(e){let{initial:t,hasNext:n,step:r,map:i}=e,a=t;return{[Symbol.iterator](){return this},next(){if(!n(a))return{done:!0,value:void 0};let e={done:!1,value:i(a)};return a=r(a),e}}}function Ib(e,t){let n=Bb(e.origin,t.origin);switch(n===null&&F(275,e.origin.getKey(),t.origin.getKey()),n.type){case`same`:{let n=e.type===`text`,r=t.type===`text`;return n&&r?function(e,t){return Math.sign(e-t)}(e.offset,t.offset):e.type===t.type?0:n?-1:r?1:e.type===`child`?-1:1}case`ancestor`:return e.type===`child`?-1:1;case`descendant`:return t.type===`child`?1:-1;case`branch`:return Lb(n)}}function Lb(e){let{a:t,b:n}=e,r=t.__key,i=n.__key,a=t,o=n;for(;a&&o;a=a.getNextSibling(),o=o.getNextSibling()){if(a.__key===i)return-1;if(o.__key===r)return 1}return a===null?1:-1}function Rb(e,t){return t.is(e)}function zb(e){return U(e)?[e.getLatest(),null]:[e.getParent(),e.getLatest()]}function Bb(e,t){if(e.is(t))return{commonAncestor:e,type:`same`};let n=/* @__PURE__ */ new Map;for(let[t,r]=zb(e);t;r=t,t=t.getParent())n.set(t,r);for(let[r,i]=zb(t);r;i=r,r=r.getParent()){let a=n.get(r);if(a!==void 0)return a===null?(Rb(e,r)||F(276),{commonAncestor:r,type:`ancestor`}):i===null?(Rb(t,r)||F(277),{commonAncestor:r,type:`descendant`}):((U(a)||Rb(e,a))&&(U(i)||Rb(t,i))&&r.is(a.getParent())&&r.is(i.getParent())||F(278),{a,b:i,commonAncestor:r,type:`branch`})}return null}function Vb(e,t){let{type:n,key:r,offset:i}=e,a=Hv(e.key);return n===`text`?(z(a)||F(266,a.getType(),r),wb(a,t,i)):(U(a)||F(267,a.getType(),r),ex(a,e.offset,t))}function Hb(e,t){let{origin:n,direction:r}=t,i=r===`next`;_b(t)?e.set(n.getKey(),t.offset,`text`):vb(t)?z(n)?e.set(n.getKey(),Tb(n,r),`text`):e.set(n.getParentOrThrow().getKey(),n.getIndexWithinParent()+ +!!i,`element`):(yb(t)&&U(n)||F(268),e.set(n.getKey(),i?0:n.getChildrenSize(),`element`))}function Ub(e){let t=V(),n=B(t)?t:ag();return Wb(n,e),ov(n),n}function Wb(e,t){Hb(e.anchor,t.anchor),Hb(e.focus,t.focus)}function Gb(e){let{anchor:t,focus:n}=e,r=Vb(t,`next`),i=Vb(n,`next`),a=Ib(r,i)<=0?`next`:`previous`;return Pb(Qb(r,a),Qb(i,a))}function Kb(e){let{direction:t,origin:n}=e,r=Cb(n,pb(t)).getNodeAtCaret();return r?Cb(r,t):Db(n.getParentOrThrow(),t)}function qb(e,t=`root`){let n=[e];for(let r=yb(e)?e.getParentCaret(t):e.getSiblingCaret();r!==null;r=r.getParentCaret(t))n.push(Kb(r));return n}function Jb(e){return!!e&&e.origin.isAttached()}function Yb(e,t=`removeEmptySlices`){if(e.isCollapsed())return e;let n=`root`,r=`next`,i=t,a=$b(e,r),o=qb(a.anchor,n),s=qb(a.focus.getFlipped(),n),c=/* @__PURE__ */ new Set,l=[];for(let e of a.iterNodeCarets(n))if(yb(e))c.add(e.origin.getKey());else if(vb(e)){let{origin:t}=e;U(t)&&!c.has(t.getKey())||l.push(t)}let u=/* @__PURE__ */ new Set;for(let e of l){let t=e.getParent();t===null||c.has(t.getKey())||u.add(t),J_(e)}for(let e of u)!e.canBeEmpty()&&!Rv(e)&&e.isEmpty()&&e.isAttached()&&e.remove();for(let e of a.getTextSlices()){if(!e)continue;let{origin:t}=e.caret,n=t.getTextContentSize(),a=Kb(Cb(t,r)),c=t.getMode();if(Math.abs(e.distance)===n&&i===`removeEmptySlices`||c===`token`&&e.distance!==0)a.remove();else if(e.distance!==0){i=`removeEmptySlices`;let t=e.removeTextSlice(),n=e.caret.origin;if(c===`segmented`){let e=t.origin,n=Th(e.getTextContent()).setStyle(e.getStyle()).setFormat(e.getFormat());a.replaceOrInsert(n),t=wb(n,r,t.offset)}n.is(o[0].origin)&&(o[0]=t),n.is(s[0].origin)&&(s[0]=t.getFlipped())}}let d,f;for(let e of o)if(Jb(e)){d=Xb(e);break}for(let e of s)if(Jb(e)){f=Xb(e);break}let p=function(e,t,n){if(!e||!t)return null;let r=e.getParentAtCaret(),i=t.getParentAtCaret();if(!r||!i)return null;let a=r.getParents().reverse();a.push(r);let o=i.getParents().reverse();o.push(i);let s=Math.min(a.length,o.length),c=0;for(;c<s&&a[c]===o[c];c++);let l=(e,t)=>{let n;for(let r=c;r<e.length;r++){let i=e[r];if(Rv(i))return;!n&&t(i)&&(n=i)}return n},u=l(a,my),d=u&&l(o,e=>n.has(e.getKey())&&my(e));return d&&Yy(d).length>0?null:u&&d?[u,d]:null}(d,f,c);if(p){let[e,t]=p;Db(e,`previous`).splice(0,t.getChildren());let n=t.getParent();for(t.remove(!0);n&&n.isEmpty();){let e=n;n=n.getParent(),e.remove(!0)}}else if(f){let e=function(e){if(yb(e)){let t=e.origin;if(my(t))return t}else{let t=e.getParentAtCaret();if(t&&my(t))return t}return null}(f),t=e&&e.getParent(),n=e&&e.getParents().findLast(Lv);if(e&&t&&!r_(t)&&e.isEmpty()&&c.has(e.getKey())&&Yy(e).length===0&&(!n||c.has(n.getKey()))){e.remove(!0);let n=t;for(;n&&!r_(n)&&n.isEmpty();){let e=n.getParent();if(e&&r_(e)&&e.getChildrenSize()<=1)break;let t=n;n=e,t.remove(!0)}}}let m=[d,f,...o,...s].find(Jb);if(m)return Nb(Qb(Xb(m),e.direction));F(269,JSON.stringify(o.map(e=>e.origin.__key)))}function Xb(e){let t=function(e){let t=e;for(;yb(t);){let e=kb(t);if(!yb(e))break;t=e}return t}(e.getLatest()),{direction:n}=t;if(z(t.origin))return _b(t)?t:wb(t.origin,n,n);let r=t.getAdjacentCaret();return vb(r)&&z(r.origin)?wb(r.origin,n,pb(n)):t}function Zb(e){return _b(e)&&e.offset!==Tb(e.origin,e.direction)}function Qb(e,t){return e.direction===t?e:e.getFlipped()}function $b(e,t){return e.direction===t?e:Pb(Qb(e.focus,t),Qb(e.anchor,t))}function ex(e,t,n){let r=Db(e,`next`);for(let e=0;e<t;e++){let e=r.getAdjacentCaret();if(e===null)break;r=e}return Qb(r,n)}function tx(e){let{origin:t,offset:n,direction:r}=e;if(n===Tb(t,r))return e.getSiblingCaret();if(n===Tb(t,pb(r)))return Kb(e.getSiblingCaret());let[i]=t.splitText(n);return z(i)||F(281),Qb(Cb(i,`next`),r)}function nx(e,t){return!0}function rx(e,{$copyElementNode:t=zv,$splitTextPointCaretNext:n=tx,rootMode:r=`shadowRoot`,$shouldSplit:i=nx,removeEmptyDestination:a=!1}={}){if(_b(e))return n(e);let o=e.getParentCaret(r);if(o){let{origin:n}=o;if(yb(e)){let e=Kb(o);if(a&&n.isEmpty())return n.remove(),e;if(!n.canBeEmpty()||!i(n,`first`))return e}let r=function(e){let t=[];for(let n=e.getAdjacentCaret();n;n=n.getAdjacentCaret())t.push(n.origin);return t}(e);(r.length>0||!a&&n.canBeEmpty()&&i(n,`last`))&&o.insert(t(n).splice(0,0,r))}return o}function ix(e,t,n){let r=Qb(t,`next`);_b(r)&&(r.offset===0?r=Cb(r.origin,`previous`).getFlipped():r.offset===r.origin.getTextContentSize()&&(r=Cb(r.origin,`next`))),r.origin.is(e)&&(vb(r)||F(342,e.getKey(),e.getType()),r=Kb(r)),(e.is(r.getNodeAtCaret())||e.is(r.getFlipped().getNodeAtCaret()))&&e.remove(!0);for(let e=r;e;e=rx(e,n))r=e;return _b(r)&&F(283),r.insert(e.isInline()?y_().append(e):e),Qb(Cb(e.getLatest(),`next`),t.direction)}function ax(e){return e}function ox(e){return e}function sx(e,t){if(!t||e===t)return e;for(let n in t)if(e[n]!==t[n])return{...e,...t};return e}function cx(...e){let t=[];for(let n of e)if(n&&typeof n==`string`)for(let[e]of n.matchAll(/\S+/g))t.push(e);return t}function lx(e,...t){let n=cx(...t);n.length>0&&e.classList.add(...n)}function ux(...e){return()=>{for(let t=e.length-1;t>=0;t--)e[t]();e.length=0}}function dx(e){throw Error(`unreachable input event: ${JSON.stringify(e)}`)}function fx(e,t){let n=e.trimStart();if(n.startsWith(t))return n.slice(t.length);let r=t.trimEnd();if(n.startsWith(r)){let e=n.slice(r.length);return/^\s/.test(e)?e.slice(1):e}return``}function px(e,t){return e.startsWith(t)||e===t.trimEnd()}var mx=class{phase=`plain`;claim;seq=0;inflight;detached=/* @__PURE__ */ new Map;get state(){let e=this.claim;return{phase:this.phase,...e?{claim:{name:e.name,token:e.token,...e.hint===void 0?{}:{hint:e.hint},...e.attachments===!0?{attachments:!0}:{}}}:{}}}dispatch(e){switch(e.type){case`draft-changed`:return this.onDraftChanged(e.draft);case`claim`:return this.onClaim(e.claim);case`enter`:return this.onEnter(e.mode,e.draft,e.annotated,e.submission);case`adjudicated`:return this.onAdjudicated(e.attempt,e.outcome);case`adjudication-failed`:return this.onAdjudicationFailed(e.attempt,e.message);case`submit-settled`:return this.onSubmitSettled(e);case`sink-settled`:return this.onSinkSettled(e);case`send-committed`:return this.onSendCommitted();case`release`:return this.onRelease();default:return dx(e)}}onDraftChanged(e){return this.phase===`claimed`&&this.claim!==void 0&&!px(e,this.claim.token)&&(this.phase=`plain`,this.claim=void 0),[]}onClaim(e){return this.phase!==`plain`&&this.phase!==`claimed`||(this.claim=e,this.phase=`claimed`),[]}mintAttempt(e,t,n){let r=new AbortController;return this.seq+=1,{attempt:{seq:this.seq,signal:r.signal,draftSnapshot:t,mode:e,...n===void 0?{}:{submission:n}},controller:r}}beginAttempt(e,t,n){let r=this.mintAttempt(e,t,n);return this.inflight=r,r.attempt}beginDetached(e,t,n){let r=this.mintAttempt(e,t,n);return this.detached.set(r.attempt.seq,r.controller),this.claim=void 0,this.phase=`plain`,r.attempt}detachedEffects(e){return[{type:`default-sink`,attempt:e,draft:e.draftSnapshot,mode:e.mode},{type:`commit-draft`,retainSuffixOf:e.draftSnapshot}]}onEnter(e,t,n,r){if(this.phase===`adjudicating`||this.phase===`submitting`)return[];if(this.phase===`claimed`&&this.claim!==void 0){let n=this.beginAttempt(e,t,r);return this.phase=`submitting`,[{type:`begin-submit`,attempt:n,claim:this.claim,args:fx(t,this.claim.token)}]}let i=t.trim();if(i===``&&!n)return[];if(i.startsWith(`/`)){let n=this.beginAttempt(e,t,r);return this.phase=`adjudicating`,[{type:`adjudicate`,attempt:n,draft:t}]}return this.detachedEffects(this.beginDetached(e,t,r))}onAdjudicated(e,t){let n=this.inflight;return this.phase!==`adjudicating`||n===void 0||n.attempt.seq!==e.seq?[]:t!==void 0&&t!==`handled`&&t!==`refresh`&&`claim`in t?(this.claim=t.claim,this.phase=`submitting`,[{type:`begin-submit`,attempt:e,claim:t.claim,args:fx(e.draftSnapshot,t.claim.token)}]):(this.inflight=void 0,this.phase=`plain`,t===void 0?(this.detached.set(e.seq,n.controller),this.detachedEffects(e)):[])}onAdjudicationFailed(e,t){return this.phase!==`adjudicating`||this.inflight?.attempt.seq!==e.seq?[]:(this.inflight=void 0,this.phase=`plain`,[{type:`notice`,level:`error`,text:t}])}onSubmitSettled(e){let t=this.inflight;if(this.phase!==`submitting`||t===void 0||t.attempt.seq!==e.attempt.seq)return[];if(this.inflight=void 0,e.ok){this.phase=`plain`,this.claim=void 0;let n=[{type:`commit-draft`,retainSuffixOf:t.attempt.draftSnapshot}];return e.outcome?.text!==void 0&&n.push({type:`notice`,level:e.outcome.kind===`error`?`error`:`info`,text:e.outcome.text}),n}let n=e.message??e.outcome?.text;return e.draft===t.attempt.draftSnapshot&&this.claim!==void 0&&px(e.draft,this.claim.token)?(this.phase=`claimed`,n===void 0?[]:[{type:`notice`,level:`error`,text:n}]):(this.phase=`plain`,this.claim=void 0,n===void 0?[]:[{type:`notice`,level:`error`,text:n}])}onSinkSettled(e){if(!this.detached.delete(e.attempt.seq))return[];let t=e.message??e.outcome?.text;return t===void 0?[]:[{type:`notice`,level:e.ok&&e.outcome?.kind!==`error`?`info`:`error`,text:t}]}onSendCommitted(){return this.phase===`plain`?(this.claim=void 0,[{type:`commit-draft`,retainSuffixOf:null}]):[]}onRelease(){this.inflight!==void 0&&(this.inflight.controller.abort(),this.inflight=void 0);for(let e of this.detached.values())e.abort();return this.detached.clear(),this.phase=`plain`,this.claim=void 0,[]}};function hx(e){let t=hy().getElementByKey(e.getKey());if(t===null)return null;let n=t.ownerDocument.defaultView;return n===null?null:n.getComputedStyle(t)}function gx(e){return hx(r_(e)?e:e.getParentOrThrow())}function _x(e,t,n=`self`){let r=e.getStartEndPoints();if(t.isSelected(e)&&!H_(t)&&r!==null){let[i,a]=r,o=e.isBackward(),s=i.getNode(),c=a.getNode(),l=t.is(s),u=t.is(c);if(l||u){let[r,i]=Uh(e),a=s.is(c),l=t.is(o?c:s),u=t.is(o?s:c),d,f=0;a?(f=r>i?i:r,d=r>i?r:i):l?(f=o?i:r,d=void 0):u&&(f=0,d=o?r:i);let p=t.__text.slice(f,d);p!==t.__text&&(n===`clone`&&(t=wy(t)),t.__text=p)}}return t}function vx(e){let t=yx(e);return t!==null&&t.writingMode===`vertical-rl`}function yx(e){let t=e.anchor.getNode();return U(t)?hx(t):gx(t)}function bx(e,t){let n=vx(e)?!t:t;Sx(e)&&(n=!n);let r=Vb(e.focus,n?`previous`:`next`);if(Zb(r))return!1;if(_b(r)&&!kh(r.origin)&&r.origin.isUnmergeable()){let e=r.getNodeAtCaret();if(z(e)&&!kh(e))return!0}for(let e of Mb(r)){if(yb(e))return!e.origin.isInline();if(!U(e.origin)){if(W(e.origin))return!0;break}}return!1}function xx(e,t,n,r){e.modify(t?`extend`:`move`,n,r)}function Sx(e){let t=yx(e);return t!==null&&t.direction===`rtl`}function Cx(e,t,n){let r=Sx(e),i;i=vx(e)||r?!n:n,xx(e,t,i,`character`)}function wx(e,t){return e!==null&&Object.getPrototypeOf(e).constructor.name===t.name}let Tx=Symbol.for(`preact-signals`);function Ex(){if(Ax>1)return void Ax--;let e,t=!1;for(function(){let e=kx;for(kx=void 0;e!==void 0;)e.S.v===e.v&&(e.S.i=e.i),e=e.o}();Dx!==void 0;){let n=Dx;for(Dx=void 0,jx++;n!==void 0;){let r=n.u;if(n.u=void 0,n.f&=-3,!(8&n.f)&&Fx(n))try{n.c()}catch(n){t||=(e=n,!0)}n=r}}if(jx=0,Ax--,t)throw e}let J,Dx;function Ox(e){let t=J;J=void 0;try{return e()}finally{J=t}}let kx,Ax=0,jx=0,Mx=0;function Nx(e){if(J===void 0)return;let t=e.n;return t===void 0||t.t!==J?(t={i:0,S:e,p:J.s,n:void 0,t:J,e:void 0,x:void 0,r:t},J.s!==void 0&&(J.s.n=t),J.s=t,e.n=t,32&J.f&&e.S(t),t):t.i===-1?(t.i=0,t.n!==void 0&&(t.n.p=t.p,t.p!==void 0&&(t.p.n=t.n),t.p=J.s,t.n=void 0,J.s.n=t,J.s=t),t):void 0}function Px(e,t){this.v=e,this.i=0,this.n=void 0,this.t=void 0,this.l=0,this.W=t?.watched,this.Z=t?.unwatched,this.name=t?.name}function Fx(e){for(let t=e.s;t!==void 0;t=t.n)if(t.S.i!==t.i||!t.S.h()||t.S.i!==t.i)return!0;return!1}function Ix(e){for(let t=e.s;t!==void 0;t=t.n){let n=t.S.n;if(n!==void 0&&(t.r=n),t.S.n=t,t.i=-1,t.n===void 0){e.s=t;break}}}function Lx(e){let t,n=e.s;for(;n!==void 0;){let e=n.p;n.i===-1?(n.S.U(n),e!==void 0&&(e.n=n.n),n.n!==void 0&&(n.n.p=e)):t=n,n.S.n=n.r,n.r!==void 0&&(n.r=void 0),n=e}e.s=t}function Rx(e,t){Px.call(this,void 0),this.x=e,this.s=void 0,this.g=Mx-1,this.f=4,this.W=t?.watched,this.Z=t?.unwatched,this.name=t?.name}function zx(e){let t=e.m;if(e.m=void 0,typeof t==`function`){Ax++;let n=J;J=void 0;try{t()}catch(t){throw e.f&=-2,e.f|=8,Bx(e),t}finally{J=n,Ex()}}}function Bx(e){for(let t=e.s;t!==void 0;t=t.n)t.S.U(t);e.x=void 0,e.s=void 0,zx(e)}function Vx(e){if(J!==this)throw Error(`Out-of-order effect`);Lx(this),J=e,this.f&=-2,8&this.f&&Bx(this),Ex()}function Hx(e,t){this.x=e,this.m=void 0,this.s=void 0,this.u=void 0,this.f=32,this.name=t?.name}function Ux(e,t){let n=new Hx(e,t);try{n.c()}catch(e){throw n.d(),e}let r=n.d.bind(n);return r[Symbol.dispose]=r,r}Px.prototype.brand=Tx,Px.prototype.h=function(){return!0},Px.prototype.S=function(e){let t=this.t;t!==e&&e.e===void 0&&(e.x=t,this.t=e,t===void 0?Ox(()=>{var e;(e=this.W)==null||e.call(this)}):t.e=e)},Px.prototype.U=function(e){if(this.t!==void 0){let t=e.e,n=e.x;t!==void 0&&(t.x=n,e.e=void 0),n!==void 0&&(n.e=t,e.x=void 0),e===this.t&&(this.t=n,n===void 0&&Ox(()=>{var e;(e=this.Z)==null||e.call(this)}))}},Px.prototype.subscribe=function(e){return Ux(()=>{let t=this.value,n=J;J=void 0;try{e(t)}finally{J=n}},{name:`sub`})},Px.prototype.valueOf=function(){return this.value},Px.prototype.toString=function(){return this.value+``},Px.prototype.toJSON=function(){return this.value},Px.prototype.peek=function(){let e=J;J=void 0;try{return this.value}finally{J=e}},Object.defineProperty(Px.prototype,"value",{get(){let e=Nx(this);return e!==void 0&&(e.i=this.i),this.v},set(e){if(e!==this.v){if(jx>100)throw Error(`Cycle detected`);(function(e){Ax!==0&&jx===0&&e.l!==0&&(e.l=0,kx={S:e,v:e.v,i:e.i,o:kx})})(this),this.v=e,this.i++,Mx++,Ax++;try{for(let e=this.t;e!==void 0;e=e.x)e.t.N()}finally{Ex()}}}}),Rx.prototype=new Px,Rx.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===Mx))return!0;if(this.g=Mx,this.f|=1,this.i>0&&!Fx(this))return this.f&=-2,!0;let e=J;try{Ix(this),J=this;let e=this.x();(16&this.f||this.v!==e||this.i===0)&&(this.v=e,this.f&=-17,this.i++)}catch(e){this.v=e,this.f|=16,this.i++}return J=e,Lx(this),this.f&=-2,!0},Rx.prototype.S=function(e){if(this.t===void 0){this.f|=36;for(let e=this.s;e!==void 0;e=e.n)e.S.S(e)}Px.prototype.S.call(this,e)},Rx.prototype.U=function(e){if(this.t!==void 0&&(Px.prototype.U.call(this,e),this.t===void 0)){this.f&=-33;for(let e=this.s;e!==void 0;e=e.n)e.S.U(e)}},Rx.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(let e=this.t;e!==void 0;e=e.x)e.t.N()}},Object.defineProperty(Rx.prototype,"value",{get(){if(1&this.f)throw Error(`Cycle detected`);let e=Nx(this);if(this.h(),e!==void 0&&(e.i=this.i),16&this.f)throw this.v;return this.v}}),Hx.prototype.c=function(){let e=this.S();try{if(8&this.f||this.x===void 0)return;let e=this.x();typeof e==`function`&&(this.m=e)}finally{e()}},Hx.prototype.S=function(){if(1&this.f)throw Error(`Cycle detected`);this.f|=1,this.f&=-9,zx(this),Ix(this),Ax++;let e=J;return J=this,Vx.bind(this,e)},Hx.prototype.N=function(){2&this.f||(this.f|=2,this.u=Dx,Dx=this)},Hx.prototype.d=function(){this.f|=8,1&this.f||Bx(this)},Hx.prototype.dispose=function(){this.d()};function Wx(e){return(typeof e.nodes==`function`?e.nodes():e.nodes)||[]}function Gx(e,...t){let n=new URL(`https://lexical.dev/docs/error`),r=new URLSearchParams;r.append(`code`,e);for(let e of t)r.append(`v`,e);throw n.search=r.toString(),Error(`Minified Lexical error #${e}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}let Kx;try{Kx=`0.49.0+prod.esm`}catch{}let qx=Kx??`"<unknown>+source"`,Jx=/* @__PURE__ */ new Set([`__proto__`,`constructor`,`prototype`]);function Yx(e,t){if(e&&t&&!Array.isArray(t)&&typeof e==`object`&&typeof t==`object`){let n=e,r=t;for(let e in r)!Jx.has(e)&&Object.prototype.hasOwnProperty.call(r,e)&&(n[e]=Yx(n[e],r[e]));return e}return t}function Xx(e){return e.id===0}function Zx(e){return e.id===2}function Qx(e){return function(e){return e.id===1}(e)||Gx(305,String(e.id),`1`),Object.assign(e,{id:2})}let $x=/* @__PURE__ */ new Set;var eS=class{builder;configs;_dependency;_peerNameSet;extension;state;_signal;constructor(e,t){this.builder=e,this.extension=t,this.configs=/* @__PURE__ */ new Set,this.state={id:0}}mergeConfigs(){let e=this.extension.config||{},t=this.extension.mergeConfig?this.extension.mergeConfig.bind(this.extension):sx;for(let n of this.configs)e=t(e,n);return e}init(e){let t=this.state;Zx(t)||Gx(306,String(t.id));let n={getDependency:this.getInitDependency.bind(this),getDirectDependentNames:this.getDirectDependentNames.bind(this),getPeer:this.getInitPeer.bind(this),getPeerNameSet:this.getPeerNameSet.bind(this)},r={...n,getDependency:this.getDependency.bind(this),getInitResult:this.getInitResult.bind(this),getPeer:this.getPeer.bind(this)},i=function(e,t,n){return Object.assign(e,{config:t,id:3,registerState:n})}(t,this.mergeConfigs(),n),a;this.state=i,this.extension.init&&(a=this.extension.init(e,i.config,n)),this.state=function(e,t,n){return Object.assign(e,{id:4,initResult:t,registerState:n})}(i,a,r)}build(e){let t=this.state,n;t.id!==4&&Gx(307,String(t.id),`5`),this.extension.build&&(n=this.extension.build(e,t.config,t.registerState));let r={...t.registerState,getOutput:()=>n,getSignal:this.getSignal.bind(this)};this.state=function(e,t,n){return Object.assign(e,{id:5,output:t,registerState:n})}(t,n,r)}register(e,t){this._signal=t;let n=this.state;n.id!==5&&Gx(308,String(n.id),`5`);let r=this.extension.register&&this.extension.register(e,n.config,n.registerState);return this.state=function(e){return Object.assign(e,{id:6})}(n),()=>{let e=this.state;e.id!==7&&Gx(309,String(n.id),`7`),this.state=function(e){return Object.assign(e,{id:5})}(e),r&&r()}}afterRegistration(e){let t=this.state,n;return t.id!==6&&Gx(310,String(t.id),`6`),this.extension.afterRegistration&&(n=this.extension.afterRegistration(e,t.config,t.registerState)),this.state=function(e){return Object.assign(e,{id:7})}(t),n}getSignal(){return this._signal===void 0&&Gx(311),this._signal}getInitResult(){this.extension.init===void 0&&Gx(312,this.extension.name);let e=this.state;return function(e){return e.id>=4}(e)||Gx(313,String(e.id),`4`),e.initResult}getInitPeer(e){let t=this.builder.extensionNameMap.get(e);return t?t.getExtensionInitDependency():void 0}getExtensionInitDependency(){let e=this.state;return function(e){return e.id>=3}(e)||Gx(314,String(e.id),`3`),{config:e.config}}getPeer(e){let t=this.builder.extensionNameMap.get(e);return t?t.getExtensionDependency():void 0}getInitDependency(e){let t=this.builder.getExtensionRep(e);return t===void 0&&Gx(315,this.extension.name,e.name),t.getExtensionInitDependency()}getDependency(e){let t=this.builder.getExtensionRep(e);return t===void 0&&Gx(315,this.extension.name,e.name),t.getExtensionDependency()}getState(){let e=this.state;return function(e){return e.id>=7}(e)||Gx(316,String(e.id),`7`),e}getDirectDependentNames(){return this.builder.incomingEdges.get(this.extension.name)||$x}getPeerNameSet(){let e=this._peerNameSet;return e||(e=new Set((this.extension.peerDependencies||[]).map(([e])=>e)),this._peerNameSet=e),e}getExtensionDependency(){if(!this._dependency){let e=this.state;(function(e){return e.id>=5})(e)||Gx(317,this.extension.name),this._dependency={config:e.config,init:e.initResult,output:e.output}}return this._dependency}};let tS={tag:th};function nS(){let e=av();e.isEmpty()&&e.append(y_())}let rS=/* @__PURE__ */ ax({config:/* @__PURE__ */ ox({setOptions:tS,updateOptions:tS}),init:({$initialEditorState:e=nS})=>({$initialEditorState:e,initialized:!1}),afterRegistration(e,{updateOptions:t,setOptions:n},r){let i=r.getInitResult();if(!i.initialized){i.initialized=!0;let{$initialEditorState:r}=i;if(s_(r))e.setEditorState(r,n);else if(typeof r==`function`)e.update(()=>{r(e)},t);else if(r&&(typeof r==`string`||typeof r==`object`)){let t=e.parseEditorState(r);e.setEditorState(t,n)}}return()=>{}},name:`@lexical/extension/InitialState`,nodes:[n_,gh,u_,Dh,__]}),iS=Symbol.for(`@lexical/extension/LexicalBuilder`);function aS(){}function oS(e){throw e}function sS(e){return Array.isArray(e)?e:[e]}let cS=qx;var lS=class e{roots;extensionNameMap;outgoingConfigEdges;incomingEdges;conflicts;_sortedExtensionReps;PACKAGE_VERSION;constructor(e){this.outgoingConfigEdges=/* @__PURE__ */ new Map,this.incomingEdges=/* @__PURE__ */ new Map,this.extensionNameMap=/* @__PURE__ */ new Map,this.conflicts=/* @__PURE__ */ new Map,this.PACKAGE_VERSION=cS,this.roots=e;for(let t of e)this.addExtension(t)}static fromExtensions(t){let n=[sS(rS)];for(let e of t)n.push(sS(e));return new e(n)}static maybeFromEditor(t){let n=t[iS];return n&&(n.PACKAGE_VERSION!==cS&&Gx(292,n.PACKAGE_VERSION,cS),n instanceof e||Gx(293)),n}static fromEditor(t){let n=e.maybeFromEditor(t);return n===void 0&&Gx(294),n}constructEditor(){let{$initialEditorState:e,onError:t,onWarn:n,...r}=this.buildCreateEditorArgs(),i=Object.assign(T_({...r,...t?{onError:e=>{t(e,i)}}:{},...n?{onWarn:e=>{n(e,i)}}:{}}),{[iS]:this});for(let e of this.sortedExtensionReps())e.build(i);return i}buildEditor(){let e=aS;function t(){try{e()}finally{e=aS}}let n=Object.assign(this.constructEditor(),{dispose:t,[Symbol.dispose]:t});return e=ux(this.registerEditor(n),()=>n.setRootElement(null)),n}hasExtensionByName(e){return this.extensionNameMap.has(e)}getExtensionRep(e){let t=this.extensionNameMap.get(e.name);if(t)return t.extension!==e&&Gx(295,e.name),t}addEdge(e,t,n){let r=this.outgoingConfigEdges.get(e);r?r.set(t,n):this.outgoingConfigEdges.set(e,/* @__PURE__ */ new Map([[t,n]]));let i=this.incomingEdges.get(t);i?i.add(e):this.incomingEdges.set(t,/* @__PURE__ */ new Set([e]))}addExtension(e){this._sortedExtensionReps!==void 0&&Gx(296);let[t]=sS(e);typeof t.name!=`string`&&Gx(297,typeof t.name);let n=this.extensionNameMap.get(t.name);if(n!==void 0&&n.extension!==t&&Gx(298,t.name),!n){n=new eS(this,t),this.extensionNameMap.set(t.name,n);let e=this.conflicts.get(t.name);typeof e==`string`&&Gx(299,t.name,e);for(let e of t.conflictsWith||[])this.extensionNameMap.has(e)&&Gx(299,t.name,e),this.conflicts.set(e,t.name);for(let e of t.dependencies||[]){let n=sS(e);this.addEdge(t.name,n[0].name,n.slice(1)),this.addExtension(n)}for(let[e,n]of t.peerDependencies||[])this.addEdge(t.name,e,n?[n]:[])}}sortedExtensionReps(){if(this._sortedExtensionReps)return this._sortedExtensionReps;let e=[],t=(n,r)=>{let i=n.state;if(Zx(i))return;let a=n.extension.name;var o;Xx(i)||Gx(300,a,r||`[unknown]`),Xx(o=i)||Gx(304,String(o.id),`0`),i=Object.assign(o,{id:1}),n.state=i;let s=this.outgoingConfigEdges.get(a);if(s)for(let e of s.keys()){let n=this.extensionNameMap.get(e);n&&t(n,a)}i=Qx(i),n.state=i,e.push(n)};for(let e of this.extensionNameMap.values())Xx(e.state)&&t(e);for(let t of e)for(let[e,n]of this.outgoingConfigEdges.get(t.extension.name)||[])if(n.length>0){let t=this.extensionNameMap.get(e);if(t)for(let e of n)t.configs.add(e)}for(let[e,...t]of this.roots)if(t.length>0){let n=this.extensionNameMap.get(e.name);n===void 0&&Gx(301,e.name);for(let e of t)n.configs.add(e)}return this._sortedExtensionReps=e,this._sortedExtensionReps}registerEditor(e){let t=this.sortedExtensionReps(),n=new AbortController,r=[()=>n.abort()],i=n.signal;for(let n of t){let t=n.register(e,i);t&&r.push(t)}for(let n of t){let t=n.afterRegistration(e);t&&r.push(t)}return ux(...r)}buildCreateEditorArgs(){let e={},t=/* @__PURE__ */ new Set,n=/* @__PURE__ */ new Map,r=/* @__PURE__ */ new Map,i={},a={},o=this.sortedExtensionReps();for(let s of o){let{extension:o}=s;if(o.onError!==void 0&&(e.onError=o.onError),o.onWarn!==void 0&&(e.onWarn=o.onWarn),o.disableEvents!==void 0&&(e.disableEvents=o.disableEvents),o.parentEditor!==void 0&&(e.parentEditor=o.parentEditor),o.editable!==void 0&&(e.editable=o.editable),o.namespace!==void 0&&(e.namespace=o.namespace),o.$initialEditorState!==void 0&&(e.$initialEditorState=o.$initialEditorState),o.nodes)for(let e of Wx(o)){if(typeof e!=`function`){let t=n.get(e.replace);t&&Gx(302,o.name,e.replace.name,t.extension.name),n.set(e.replace,s)}t.add(e)}if(o.html){if(o.html.export)for(let[e,t]of o.html.export.entries())r.set(e,t);o.html.import&&Object.assign(i,o.html.import)}o.theme&&Yx(a,o.theme)}Object.keys(a).length>0&&(e.theme=a),t.size&&(e.nodes=[...t]);let s=Object.keys(i).length>0,c=r.size>0;(s||c)&&(e.html={},s&&(e.html.import=i),c&&(e.html.export=r));for(let t of o)t.init(e);return e.onError||=oS,e}};function uS(e,t){let n=lS.maybeFromEditor(e);if(!n)return;let r=n.extensionNameMap.get(t);return r?r.getExtensionDependency():void 0}var dS=class extends t_{$config(){return this.config(`horizontalrule`,{importDOM:{hr:()=>({conversion:fS,priority:0})}})}exportDOM(){return{element:Qv().createElement(`hr`)}}createDOM(e){let t=Qv().createElement(`hr`);return lx(t,e.theme.hr),t}getTextContent(){return`
146
+ `}isInline(){return!1}updateDOM(){return!1}};function fS(){return{node:pS()}}function pS(){return Ly(dS)}Date.now;function mS(e,...t){let n=new URL(`https://lexical.dev/docs/error`),r=new URLSearchParams;r.append(`code`,e);for(let e of t)r.append(`v`,e);throw n.search=r.toString(),Error(`Minified Lexical error #${e}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}let hS;function gS(e,t){let{key:n}=t;return e&&n in e?e[n]:t.defaultValue}function _S(e){return hS&&hS.editor===e?hS:void 0}function vS(e,t){if(`cfg`in t){let{cfg:n,updater:r}=t;return[n,r(gS(e,n))]}return t}function yS(e,t){let n=t;for(let r of e){let[e,i]=vS(n,r),a=e.key;if(n===t&&gS(n,e)===i)continue;let o=n===t||n===void 0?bS(t):n;o[a]=i,n=o}return n}function bS(e){return Object.create(e||null)}function xS(e,t){return[e,t]}function SS(e,t,n,r=hy()){let i=hS,a=_S(r);try{return hS={...a,editor:r,[e]:t},n()}finally{hS=i}}function CS(e,t=()=>{}){return(n,r=hy())=>i=>{let a=_S(r),o=a&&a[e],s=yS(n,o||t(r));return s&&s!==o?SS(e,s,i,r):i()}}function wS(e,t,n,r){return Object.assign(bf(Symbol(t),{isEqual:r,parse:n}),{[e]:!0})}let TS=`@lexical/html/DOM`,ES=Symbol.for(`@lexical/html/DOMExportContext`);function DS(e,t,n){return wS(ES,e,t,n)}let OS=/* @__PURE__ */ DS(`isExport`,Boolean);function kS(e){let t=uS(e,TS);return t?t.output.defaults:void 0}function AS(e){let t=uS(e,TS);return t?t.output.runtime:void 0}function jS(e=hy()){let t=AS(e);return t?t.getSessionConfig():gy(e)}let MS=CS(ES,kS),NS=Symbol.for(`@lexical/html/SelectorImpl`);function PS(e,t){let n={kind:`element`,predicate:(r=t,r.length===0?q:r.length===1?r[0]:(e,t)=>{for(let n of r)if(!n(e,t))return!1;return!0}),tags:e};var r;let i=n=>PS(e,[...t,n]);return{[NS]:n,attr:(e,t,n)=>i(LS(e,t,n)),classAll:(...e)=>i(IS(e)),classAny:(...e)=>i(function(e){let t=FS(e);return t.length===0?()=>!1:e=>{if(!q(e))return!1;let n=e.classList;for(let e of t)if(n.contains(e))return!0;return!1}}(e)),styleAny:(e,t,n)=>i(function(e,t,n){if(typeof t==`string`)return n=>q(n)&&n.style.getPropertyValue(e)===t;if(t instanceof RegExp){let r=n&&n.capture,i=t;return(t,n)=>{if(!q(t))return!1;let a=t.style.getPropertyValue(e);if(!a)return!1;let o=a.match(i);return o!==null&&(r!==void 0&&(n[r]=o),!0)}}mS(362,JSON.stringify(e))}(e,t,n))}}function FS(e){let t=[];for(let n of e)n&&t.push(n);return t}function IS(e){let t=FS(e);return t.length===0?()=>!0:e=>{if(!q(e))return!1;let n=e.classList;for(let e of t)if(!n.contains(e))return!1;return!0}}function LS(e,t,n){if(!0===t)return t=>q(t)&&t.hasAttribute(e);if(typeof t==`string`)return n=>q(n)&&n.getAttribute(e)===t;if(t instanceof RegExp){let r=n&&n.capture,i=t;return(t,n)=>{if(!q(t))return!1;let a=t.getAttribute(e);if(a==null)return!1;let o=a.match(i);return o!==null&&(r!==void 0&&(n[r]=o),!0)}}mS(361,JSON.stringify(e))}let RS={kind:`text`,predicate:U_,tags:/* @__PURE__ */ new Set},zS={[NS]:RS},BS={kind:`comment`,predicate:e=>e.nodeType===8,tags:/* @__PURE__ */ new Set},VS={[NS]:BS},HS={any:()=>PS(/* @__PURE__ */ new Set,[]),comment:()=>VS,tag(...e){e.length>0||mS(363);let t=/* @__PURE__ */ new Set;for(let n of e)t.add(n.toUpperCase());return PS(t,[])},text:()=>zS},US=HS;US.tag(`b`,`strong`,`em`,`i`,`code`,`mark`,`s`,`sub`,`sup`,`u`,`span`),US.text(),US.tag(`script`,`style`),US.tag(`br`),US.tag(`p`),US.tag(`hr`),US.any(),Object.freeze([]),Object.freeze({}),HS.any(),HS.any,HS.comment,HS.tag,HS.text;function WS(e,t=null,n=hy()){return MS([xS(OS,!0)],n)(()=>{let r=av(),i=jS(n),a=B(t)?qy(t.anchor.getNode()):null,o=e.append.bind(e);for(let e of(U(a)?a:r).getChildren())KS(n,e,o,t,i);return e})}function GS(e,t=null){return(typeof document>`u`||typeof window>`u`&&global.window===void 0)&&mS(338),Ig(e),WS(Qv().createElement(`div`),t,e).innerHTML}function KS(e,t,n,r=null,i=gy(e)){let a=i.$shouldInclude(t,r,e),o=i.$shouldExclude(t,r,e),s=t;r!==null&&z(t)&&(s=_x(r,t,`clone`));let{element:c,after:l,append:u,$getChildNodes:d}=i.$exportDOM(s,e);if(!c)return!1;let f=Qv().createDocumentFragment(),p=d?d():U(s)?s.getChildren():[],m=a&&zh(r)&&U(t)?null:r,h=f.append.bind(f);for(let n of p){let o=KS(e,n,h,m,i);!a&&o&&i.$extractWithChild(t,n,r,`html`,e)&&(a=!0)}if(a&&!o){if((q(c)||ly(c))&&(u?u(f):c.append(f)),n(c),l){let e=l.call(s,c);e&&(ly(c)?c.replaceChildren(e):c.replaceWith(e))}}else n(f);return a}function qS(e,t,n=null){let r=Zv(n),i=n?Yv(n):[],a=n!==null&&i.length>0;if(a&&typeof r.caretPositionFromPoint==`function`){let a=r.caretPositionFromPoint(e,t,{shadowRoots:i});if(a!==null&&function(e,t){for(let n=e;n!==null;){if(n===t)return!0;n=Ov(n)}return!1}(a.offsetNode,n))return{node:a.offsetNode,offset:a.offset}}if(a){let i=n.getRootNode();if(qv(i)){let a=i.elementFromPoint(e,t);if(a!==null&&n.contains(a)){let n=function(e,t,n,r){let i=r.createRange(),a=e=>t<e.top?e.top-t:t>e.bottom?t-e.bottom:0,o=t=>e<t.left?t.left-e:e>t.right?e-t.right:0,s=r.createTreeWalker(n,NodeFilter.SHOW_TEXT),c=null,l=1/0,u=1/0;for(let e=s.nextNode();e;e=s.nextNode()){i.selectNodeContents(e);for(let t of i.getClientRects()){let n=a(t),r=o(t);(n<l||n===l&&r<u)&&(l=n,u=r,c=e)}}if(c===null)return null;let d=0,f=1/0,p=1/0;for(let t=0;t<=c.length;t++){i.setStart(c,t),i.collapse(!0);let n=i.getBoundingClientRect(),r=a(n),o=Math.abs(e-n.left);(r<f||r===f&&o<p)&&(f=r,p=o,d=t)}return{node:c,offset:d}}(e,t,a,r);if(n!==null)return n}}}if(typeof r.caretRangeFromPoint==`function`){let n=r.caretRangeFromPoint(e,t);return n===null?null:{node:n.startContainer,offset:n.startOffset}}if(typeof r.caretPositionFromPoint==`function`){let n=r.caretPositionFromPoint(e,t);return n===null?null:{node:n.offsetNode,offset:n.offset}}return null}function JS(e,...t){let n=new URL(`https://lexical.dev/docs/error`),r=new URLSearchParams;r.append(`code`,e);for(let e of t)r.append(`v`,e);throw n.search=r.toString(),Error(`Minified Lexical error #${e}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}function YS(e,t=V()){return t??JS(166),B(t)&&t.isCollapsed()||t.getNodes().length===0?``:GS(e,t)}function XS(e,t){let n=e.getData(`text/plain`)||e.getData(`text/uri-list`);n!=null&&t.insertRawText(n)}let ZS=`application/x-lexical-drag`;function QS(e,t){let n={editorKey:t.getKey()};e.setData(ZS,JSON.stringify(n))}function $S(e,t,n){let r=e.dataTransfer;if(r===null)return!1;let i=function(e){let t=e.getData(ZS);if(!t)return null;let n;try{n=JSON.parse(t)}catch{return null}return(r=n)!==null&&typeof r==`object`&&`editorKey`in r&&typeof r.editorKey==`string`?n:null;var r}(r);if(i===null)return!1;let a=function(e,t){let n=qS(e.clientX,e.clientY,t.getRootElement());if(n===null)return null;let r=nv(n.node);if(r===null)return null;if(z(r))return wb(r,`next`,n.offset);if(U(r))return ex(r,n.offset,`next`);let i=r.getParent();return i===null?null:ex(i,r.getIndexWithinParent()+1,`next`)}(e,t);if(a===null)return!1;let o=rx(a);if(o===null)return!1;let s=i.editorKey===t.getKey(),c=V();if(s){if(!B(c)||c.isCollapsed())return!1;if(function(e,t){let{anchor:n,focus:r}=$b(Gb(t),`next`);return Ib(n,e)<0&&Ib(e,r)<0}(a,c))return e.preventDefault(),!0;c.removeText()}if(!o.origin.isAttached())return e.preventDefault(),!0;if(n(r,Ub(Nb(o)),t),!s){let e=t.getRootElement(),n=e?e.ownerDocument:null,r=n?function(e,t){for(let n of Xv(t)){let t=B_(n);if(R_(t)&&t.getKey()===e&&q(n))return n}return null}(i.editorKey,n):null;r!==null&&r.dispatchEvent(new InputEvent(`beforeinput`,{bubbles:!0,cancelable:!0,inputType:`deleteByDrag`}))}return e.preventDefault(),!0}function eC(e,t){return $S(e,t,(e,t)=>XS(e,t))}function tC(e,t){t.update(()=>{if(e!==null){let n=wx(e,KeyboardEvent)?null:e.clipboardData,r=V();if(r!==null&&!r.isCollapsed()&&n!=null){e.preventDefault();let i=YS(t);i!==null&&n.setData(`text/html`,i),n.setData(`text/plain`,r.getTextContent())}}})}function nC(e){return ux(e.registerCommand(Fp,e=>{let t=V();return!!B(t)&&(t.deleteCharacter(e),!0)},0),e.registerCommand(Vp,e=>{let t=V();return!!B(t)&&(t.deleteWord(e),!0)},0),e.registerCommand(Hp,e=>{let t=V();return!!B(t)&&(t.deleteLine(e),!0)},0),e.registerCommand(Rp,e=>{let t=V();if(!B(t))return!1;if(typeof e==`string`)t.insertText(e);else{let n=e.dataTransfer;if(n!=null)XS(n,t);else{let n=e.data;n&&t.insertText(n)}}return!0},0),e.registerCommand(Bp,()=>{let e=V();return!!B(e)&&(e.removeText(),!0)},0),e.registerCommand(Ip,e=>{let t=V();return!!B(t)&&(t.insertLineBreak(e),!0)},0),e.registerCommand(Lp,()=>{let e=V();return!!B(e)&&(e.insertLineBreak(),!0)},0),e.registerCommand(Yp,e=>{let t=V();if(!B(t))return!1;let n=e,r=n.shiftKey;return!!bx(t,!0)&&(n.preventDefault(),Cx(t,r,!0),!0)},0),e.registerCommand(qp,e=>{let t=V();if(!B(t))return!1;let n=e,r=n.shiftKey;return!!bx(t,!1)&&(n.preventDefault(),Cx(t,r,!1),!0)},0),e.registerCommand(tm,t=>!!B(V())&&(!Nd||!Md)&&(t.preventDefault(),e.dispatchCommand(Fp,!0)),0),e.registerCommand(rm,t=>!!B(V())&&(t.preventDefault(),e.dispatchCommand(Fp,!1)),0),e.registerCommand($p,t=>{if(!B(V()))return!1;if(t!==null){if((Nd||Fd||Rd)&&Md)return!1;t.preventDefault()}return e.dispatchCommand(Ip,!1)},0),e.registerCommand(dm,()=>{let e=V();return xv(B(e)&&qy(e.anchor.getNode())!==null?e:null),!0},0),e.registerCommand(lm,t=>!!B(V())&&(tC(t,e),!0),0),e.registerCommand(um,t=>!!B(V())&&(function(e,t){tC(e,t),t.update(()=>{let e=V();B(e)&&e.removeText()},{tag:`cut`})}(t,e),!0),0),e.registerCommand(zp,t=>!!B(V())&&(function(e,t){e.preventDefault(),t.update(()=>{let t=V(),n=wx(e,ClipboardEvent)?e.clipboardData:null;n!=null&&B(t)&&XS(n,t)},{tag:`paste`})}(t,e),!0),0),e.registerCommand(am,t=>eC(t,e),0),e.registerCommand(om,t=>{let n=V();return!!B(n)&&(n.isCollapsed()||t.dataTransfer===null||QS(t.dataTransfer,e),!0)},0))}function rC(e,t,n,r,i){if(e===null||n.size===0&&r.size===0&&!i)return 0;let a=t._selection,o=e._selection;if(i)return 1;if(!(B(a)&&B(o)&&o.isCollapsed()&&a.isCollapsed()))return 0;let s=function(e,t,n){let r=e._nodeMap,i=[];for(let e of t){let t=r.get(e);t!==void 0&&i.push(t)}for(let[e,t]of n){if(!t)continue;let n=r.get(e);n===void 0||r_(n)||i.push(n)}return i}(t,n,r);if(s.length===0)return 0;if(s.length>1){let n=t._nodeMap,r=n.get(a.anchor.key),i=n.get(o.anchor.key);return r&&i&&!e._nodeMap.has(r.__key)&&z(r)&&r.__text.length===1&&a.anchor.offset===1?2:0}let c=s[0],l=e._nodeMap.get(c.__key);if(!z(l)||!z(c)||l.__mode!==c.__mode)return 0;let u=l.__text,d=c.__text;if(u===d)return 0;let f=a.anchor,p=o.anchor;if(f.key!==p.key||f.type!==`text`)return 0;let m=f.offset,h=p.offset,g=d.length-u.length;return g===1&&h===m-1?2:g===-1&&h===m+1?3:g===-1&&h===m?4:0}function iC(e,t,n){let r=n(),i=0,a=r,o=0,s=null;return(c,l,u,d,f,p)=>{let m=n();if(p.has(`composition-start`)&&(a=r,o=i,s=c),p.has(`historic`))return i=0,r=m,2;p.has(`composition-end`)&&s&&(r=a,i=o,c=s);let h=p.has(`paste`)||p.has(`cut`)?0:rC(c,l,d,f,e.isComposing()),g=(()=>{let n=u===null||u.editor===e,a=p.has(`history-push`);if(!a&&n&&p.has(`history-merge`))return 0;if(h===1)return 2;if(c===null)return 1;let o=l._selection;if(!(d.size>0||f.size>0))return o===null?2:0;let s=typeof t==`number`?t:t.peek();return!1===a&&h!==0&&h===i&&m<r+s&&n||d.size===1&&function(e,t,n){let r=t._nodeMap.get(e),i=n._nodeMap.get(e),a=t._selection,o=n._selection;return!(B(a)&&B(o)&&a.anchor.type===`element`&&a.focus.type===`element`&&o.anchor.type===`text`&&o.focus.type===`text`||!z(r)||!z(i)||r.__parent!==i.__parent)&&JSON.stringify(t.read(()=>r.exportJSON()))===JSON.stringify(n.read(()=>i.exportJSON()))}(Array.from(d)[0],c,l)?0:1})();return r=m,i=h,g}}function aC(e,t){e.undoStack=[],e.redoStack=[],e.current=null,t&&t(e)}function oC(e,t,n,r=Date.now,i,a=null){let o=iC(e,n,r),s=()=>{i&&i(t)};return s(),ux(e.registerCommand(Wp,()=>(function(e,t,n){let r=t.redoStack,i=t.undoStack;if(i.length!==0){let a=t.current,o=i.pop();a!==null&&(r.push(a),e.dispatchCommand(mm,!0)),i.length===0&&e.dispatchCommand(hm,!1),t.current=o||null,n&&n(t),o&&o.editor.setEditorState(o.editorState,{tag:`historic`})}}(e,t,i),!0),0),e.registerCommand(Gp,()=>(function(e,t,n){let r=t.redoStack,i=t.undoStack;if(r.length!==0){let a=t.current;a!==null&&(i.push(a),e.dispatchCommand(hm,!0));let o=r.pop();r.length===0&&e.dispatchCommand(mm,!1),t.current=o||null,n&&n(t),o&&o.editor.setEditorState(o.editorState,{tag:`historic`})}}(e,t,i),!0),0),e.registerCommand(fm,()=>(aC(t,i),!1),0),e.registerCommand(pm,()=>(aC(t,i),e.dispatchCommand(mm,!1),e.dispatchCommand(hm,!1),!0),0),e.registerUpdateListener(({editorState:n,prevEditorState:r,dirtyLeaves:i,dirtyElements:c,tags:l})=>{let u=t.current,d=t.redoStack,f=t.undoStack,p=u===null?null:u.editorState;if(u!==null&&n===p)return;let m=o(r,n,u,i,c,l);if(m===1){if(d.length!==0&&(t.redoStack=[],e.dispatchCommand(mm,!1)),u!==null){f.push({...u});let t=typeof a==`number`||a===null?a:a.peek();t!==null&&f.length>t&&f.splice(0,f.length-t),e.dispatchCommand(hm,!0)}}else if(m===2)return;t.current={editor:e,editorState:n},s()}))}function sC(){return{current:null,redoStack:[],undoStack:[]}}Date.now;let cC=`application/x-codexhost-thread-reference`,lC=/^remote-(?:peer:|ssh(?:-|:)|control:).+/u;function uC(e){let t=e.projectionValues?.threadReference;if(!e.blank&&t?.hostId&&(t.hostId===`local`||lC.test(t.hostId)&&t.threadId))return{threadId:t.threadId??e.id,hostId:t.hostId,title:e.title?.replace(/[\s\u0000-\u001f\u007f]+/gu,` `).trim()||e.id.slice(0,8)}}function dC(e){return`thread://${encodeURIComponent(e.threadId).replace(/[!'()*]/gu,e=>`%${e.charCodeAt(0).toString(16).toUpperCase()}`)}?hostId=${encodeURIComponent(e.hostId)}`}function fC(e){if(e.trim()!==e)return;let t=/^codex:\/\/threads\/([^/?#\s<>]+)$/u.exec(e)??/^thread:\/\/([^/?#\s<>]+)\?hostId=([^&#\s]+)$/u.exec(e);if(t?.[1]!==void 0)try{let e=decodeURIComponent(t[1]),n=decodeURIComponent(t[2]??`local`);if(!e||!n||/[\u0000-\u001f\u007f]/u.test(e+n))return;if(n===`local`)return e;if(!lC.test(n))return;let r=new TextEncoder().encode(JSON.stringify([n,e]));return`web-remote:`+btoa(Array.from(r,e=>String.fromCharCode(e)).join(``)).replaceAll(`+`,`-`).replaceAll(`/`,`_`).replace(/=+$/u,``)}catch{return}}function pC(e){let t=`[@${e.title.replace(/[\\`*{}[\]()#+.!_<>|~-]/gu,e=>`\\${e}`)}](${dC(e)})`;return{source:`codexhost-thread`,ref:t,label:e.title,appearance:`session`,clipboardText:t}}function mC(e){try{let t=JSON.parse(e);if(typeof t!=`object`||!t)return;let{threadId:n,hostId:r,title:i}=t;return typeof n!=`string`||!n||typeof r!=`string`||!r||r!==`local`&&!lC.test(r)||typeof i!=`string`?void 0:uC({id:n,blank:!1,title:i,projectionValues:{threadReference:{hostId:r,threadId:n}}})}catch{return}}function hC(e){var t,n,r=``;if(typeof e==`string`||typeof e==`number`)r+=e;else if(typeof e==`object`){if(Array.isArray(e)){var i=e.length;for(t=0;t<i;t++)e[t]&&(n=hC(e[t]))&&(r&&(r+=` `),r+=n)}else for(n in e)e[n]&&(r&&(r+=` `),r+=n)}return r}function gC(){for(var e,t,n=0,r=``,i=arguments.length;n<i;n++)(e=arguments[n])&&(t=hC(e))&&(r&&(r+=` `),r+=t);return r}let _C=`@deepseek-ai/dsh-client-ui-conversation/ReferenceChip.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-conversation`,e.dataset.pluginCss=_C,e.textContent=`.s8J5YG_chip{max-width:240px;color:var(--dsw-alias-state-business-primary);user-select:none;align-items:baseline;gap:3px;display:inline-flex}.s8J5YG_marker{flex:none;font-weight:500}.s8J5YG_icon{flex:none;align-self:center}.s8J5YG_label{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.s8J5YG_invalid{color:var(--dsw-alias-state-error-primary);opacity:.7;text-decoration:line-through}`,document.head.appendChild(e)}var vC={chip:`s8J5YG_chip`,icon:`s8J5YG_icon`,invalid:`s8J5YG_invalid`,label:`s8J5YG_label`,marker:`s8J5YG_marker`};let yC=`@deepseek-ai/dsh-client-ui-conversation/composer-editor.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(yC)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-conversation`,e.dataset.pluginCss=yC,e.textContent=`._VTzna_reference{border-radius:var(--dsw-radius-sm);line-height:inherit;vertical-align:baseline;color:var(--dsw-alias-state-business-primary);-webkit-box-decoration-break:clone;box-decoration-break:clone;background:0 0;padding:0 4px}._VTzna_reference:hover{background:var(--dsw-alias-state-business-tertiary)}._VTzna_openable{cursor:pointer}._VTzna_textRef{max-width:100%;display:inline-block}`,document.head.appendChild(e)}var bC={openable:`_VTzna_openable`,reference:`_VTzna_reference`,textRef:`_VTzna_textRef`};function xC({label:e,reference:t,appearance:n,invalid:r}){return/* @__PURE__ */ (0,h.jsxs)(`span`,{className:gC(bC.reference,vC.chip,n===`file`&&!r&&bC.openable,r&&vC.invalid),title:e,children:[n===void 0?/* @__PURE__ */ (0,h.jsx)(`span`,{className:vC.marker,"aria-hidden":!0,children:`@`}):/* @__PURE__ */ (0,h.jsx)(d.ReferenceIconRegular,{kind:n,reference:t,size:14,className:vC.icon}),/* @__PURE__ */ (0,h.jsx)(`span`,{className:vC.label,children:e})]})}var SC=class e extends t_{__source;__ref;__label;__appearance;__clipboardText;__invalid;static getType(){return`reference-chip`}static clone(t){return new e({source:t.__source,ref:t.__ref,label:t.__label,appearance:t.__appearance,clipboardText:t.__clipboardText},t.__invalid,t.__key)}static importJSON(t){return new e({source:t.source,ref:t.ref,label:t.label,appearance:t.appearance,clipboardText:t.clipboardText},t.invalid)}constructor(e,t=!1,n){super(n),this.__source=e.source,this.__ref=e.ref,this.__label=e.label,this.__appearance=e.appearance,this.__clipboardText=e.clipboardText,this.__invalid=t}exportJSON(){return{...super.exportJSON(),type:`reference-chip`,version:1,source:this.__source,ref:this.__ref,label:this.__label,...this.__appearance===void 0?{}:{appearance:this.__appearance},clipboardText:this.__clipboardText,invalid:this.__invalid}}createDOM(e){let t=document.createElement(`span`);return t.setAttribute(`data-composer-chip`,this.__source),t.setAttribute(`contenteditable`,`false`),t}updateDOM(){return!1}isInline(){return!0}isKeyboardSelectable(){return!1}getTextContent(){return this.__clipboardText}setInvalid(e){let t=this.getWritable();t.__invalid=e}isInvalid(){return this.getLatest().__invalid}getSource(){return this.getLatest().__source}getReference(){return this.getLatest().__ref}getLabel(){return this.getLatest().__label}getAppearance(){return this.getLatest().__appearance}decorate(){return/* @__PURE__ */ (0,h.jsx)(xC,{label:this.__label,reference:this.__ref,appearance:this.__appearance,invalid:this.__invalid})}};function CC(e){return new SC(e)}function wC(e){return e instanceof SC}function TC(e,...t){let n=new URL(`https://lexical.dev/docs/error`),r=new URLSearchParams;r.append(`code`,e);for(let e of t)r.append(`v`,e);throw n.search=r.toString(),Error(`Minified Lexical error #${e}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}function EC(e,t,n,r){let i=e=>e instanceof n,a=e=>{let t=Th(e.getTextContent());t.setFormat(e.getFormat()),e.replace(t)};return[e.registerNodeTransform(gh,e=>{if(!e.isSimpleText())return;let n,o=e.getPreviousSibling(),s=e.getTextContent(),c=e;if(z(o)){let n=o.getTextContent(),r=t(n+s);if(i(o)){if(r===null||(e=>e.getLatest().__mode)(o)!==0)return void a(o);{let t=r.end-n.length;if(t>0){let r=n+s.slice(0,t);if(o.select(),o.setTextContent(r),t===s.length)e.remove();else{let n=s.slice(t);e.setTextContent(n)}return}}}else if(r===null||r.start<n.length)return}let l=0;for(;;){n=t(s);let e,u=n===null?``:s.slice(n.end);if(s=u,u===``){let e=c.getNextSibling();if(z(e)){u=c.getTextContent()+e.getTextContent();let n=t(u);if(n===null)return void(i(e)?a(e):e.markDirty());if(n.start!==0)return}}if(n===null)return;if(n.start===0&&z(o)&&o.isTextEntity()){l+=n.end;continue}n.start===0?[e,c]=c.splitText(n.end):[,e,c]=c.splitText(n.start+l,n.end+l),e===void 0&&TC(165,`nodeToReplace`);let d=r(e);if(d.setFormat(e.getFormat()),e.replace(d),c==null)return;l=0,o=d}}),e.registerNodeTransform(n,e=>{let n=e.getTextContent(),r=t(n);if(r===null||r.start!==0)return void a(e);if(n.length>r.end)return void e.splitText(r.end);let o=e.getPreviousSibling();z(o)&&o.isTextEntity()&&(a(o),a(e));let s=e.getNextSibling();z(s)&&s.isTextEntity()&&(a(s),i(e)&&a(e))})]}let DC=/(^|\s)([/@])([\w-]+)/g,OC=/(^|\s)(@(?:"[^"\n]*"?|[^\s"]\S*))/g,kC=/* @__PURE__ */ new Set(`.,;:!?,。;:!?`),AC=/^@.*[/\\.]/u;function jC(e,t,n){if(!n.startsWith(`@"`)){let e=n.length;for(;kC.has(n.charAt(e-1));)--e;return AC.test(n.slice(0,e))?t+e:void 0}if(n.length>3&&n.endsWith(`"`))return t+n.length;let r=n.lastIndexOf(`/`);if(r<0)return;let i=t+r+1;for(;kC.has(e.charAt(i));)i+=1;return i===e.length||/\s/u.test(e.charAt(i))?t+r+1:void 0}let MC=/^(?:\s|$)/;function NC(e,t){if(e===``)return[];let n=[];DC.lastIndex=0;let r;for(;(r=DC.exec(e))!==null;){let i=r[2],a=r[3]??``;if((i!==`/`||MC.test(e.slice(r.index+r[0].length)))&&t.get(i)?.includes(a)){let e=r.index+(r[1]?.length??0);n.push({start:e,end:e+1+a.length,trigger:i})}}OC.lastIndex=0;let i;for(;(i=OC.exec(e))!==null;){let t=i.index+(i[1]?.length??0),r=jC(e,t,i[2]??``);r!==void 0&&!n.some(e=>e.start<r&&e.end>t)&&n.push({start:t,end:r,trigger:`@`})}return n.sort((e,t)=>e.start-t.start)}var PC=class e extends gh{static getType(){return`composer-text-ref`}static clone(t){return new e(t.__text,t.__key)}static importJSON(t){let n=new e(t.text);return n.setFormat(t.format),n.setDetail(t.detail),n.setMode(t.mode),n.setStyle(t.style),n}exportJSON(){return{...super.exportJSON(),type:`composer-text-ref`}}createDOM(e){let t=super.createDOM(e);return t.className=gC(t.className,bC.reference,bC.textRef,this.getTextContent().startsWith(`/`)&&bC.openable),t.setAttribute(`spellcheck`,`false`),t.setAttribute(`data-composer-text-ref`,``),t}isTextEntity(){return!0}canInsertTextBefore(){return!0}};function FC(e,t,n){return ux(...EC(e,e=>{let r=n();for(let n of NC(e,t()))if(r===null||n.start!==0||e.slice(n.start,n.end)!==r.trimEnd())return{start:n.start,end:n.end};return null},PC,e=>new PC(e.getTextContent())))}function IC(e){e.update(()=>{for(let e of av().getAllTextNodes())(e instanceof PC||e.getPreviousSibling()instanceof PC||/[/@]/u.test(e.getTextContent()))&&e.markDirty()},{tag:th})}function LC(e,t){return e.registerCommand(Ap,e=>{if(e.target===null||e.button!==0||e.detail>1)return!1;let n=V();if(B(n)&&!n.isCollapsed())return!1;let r=nv(e.target);if(wC(r)){if(r.isInvalid())return!1;let e=r.getAppearance();return t(r.getSource(),{ref:r.getReference(),...e===void 0?{}:{appearance:e}})}return r instanceof PC&&t(void 0,{ref:r.getTextContent()})},1)}function RC(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 zC=uu([D(),O(),k(),nu()]);function BC(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 VC=Ku(BC,{message:`JSON value must not contain circular references`}),HC=Wu(()=>uu([zC,A(HC),vu(D(),HC)])),UC=VC.pipe(HC);VC.pipe(A(HC));let WC=VC.pipe(vu(D(),HC)),GC=M({code:D().min(1),message:D().min(1),retryable:k(),diagnostic:D().min(1).optional(),stage:D().min(1).optional(),durationMs:O().int().nonnegative().optional(),stderrTail:D().min(1).optional()}).superRefine(RC([`diagnostic`,`stage`,`durationMs`,`stderrTail`])),KC=D().max(64).regex(/^[a-z]{2,3}(?:-[A-Za-z0-9]{2,8})*$/u),qC=e=>D().min(1).max(e).refine(e=>e.trim().length>0),JC=vu(KC,j({label:qC(256).optional(),description:qC(1024).optional()}).strict()).refine(e=>Object.keys(e).length<=16,`Too many locales`),YC=vu(KC,qC(4096)).refine(e=>typeof e.en==`string`,`English fallback is required`).refine(e=>Object.keys(e).length<=16,`Too many locales`),XC=D().refine(e=>e.trim().length>0,{message:`Identifier must not be empty or whitespace`}),ZC=XC.brand(),Y=XC.brand(),QC=XC.brand();XC.brand();let $C=XC.max(128).regex(/^[A-Za-z0-9._~-]+$/u,`Thinking option ID must use transport-safe characters`).brand();XC.brand();let ew=D().refine(e=>e.trim().length>0,{message:`Value must not be empty or whitespace`}),tw=ew.max(128).regex(/^[A-Za-z0-9._~:-]+$/u,`Permission Mode ID must use transport-safe characters`).brand(),nw=j({modes:A(j({id:tw,label:ew.max(256),description:ew.max(1024).optional(),dangerous:k().optional(),localizations:JC.optional()}).strict()).min(1).max(32),defaultModeId:tw}).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`]})});j({threadId:Y,permissionModeId:tw}).strict();let rw=D().refine(e=>e.trim().length>0,{message:`Value must not be empty or whitespace`});j({sourceThreadId:Y,lastTurnId:QC.optional(),targetHarnessId:ZC,targetModel:rw.max(1024).optional(),targetThinkingOptionId:rw.max(128).regex(/^[A-Za-z0-9._~-]+$/u,`Thinking option ID must use transport-safe characters`).optional()}).strict();let iw=j({sourceThreadId:Y,sourceHarnessId:ZC,sourceHarnessLabel:rw.max(256).optional(),sourceModel:rw.max(1024).optional(),targetHarnessId:ZC,targetHarnessLabel:rw.max(256).optional(),targetModel:rw.max(1024).optional(),totalTurns:O().int().min(1),boundaryTurnNumber:O().int().min(1),includedTurnNumbers:A(O().int().min(1)),omittedTurns:O().int().min(0),preview:D().max(32e3),createdAtMs:O().int().nonnegative()}).strict();j({threadId:Y,handoff:iw}).strict();let aw=D().regex(/^[a-z0-9][a-z0-9-]{0,63}$/u),ow=D().min(1).max(512).refine(e=>!/\p{Cc}/u.test(e),`Role model must not contain control characters`),sw=N([`stone`,`rose`,`mist`,`sage`,`amber`,`aqua`]),cw=Hu([`builtin:`,N([`pm-otter`,`frontend-otter`,`backend-otter`,`reviewer-otter`,`idea-otter`,`researcher-otter`,`writer-otter`,`architect-otter`,`debugger-otter`,`tester-otter`,`classic-otter`,`ops-otter`,`security-otter`,`audio-otter`,`scholar-otter`,`data-otter`])]),lw=/^[a-zA-Z0-9_-]{1,64}\.(png|jpg|jpeg|webp)$/u,uw=Hu([`custom:`,D().regex(lw)]),dw=Hu([`catalog:`,D().regex(lw)]),fw=uu([cw,uw]),pw=uu([cw,dw]),mw=uu([fw,dw]),hw=D().url().max(2048).refine(e=>/^https:\/\//i.test(e),`URL must use https://`),gw=j({en:D().trim().min(1).max(2e3),"zh-CN":D().trim().min(1).max(2e3)}),_w=j({slug:aw,name:gw,description:gw,avatar:pw,accentColor:sw,recommendedHarnessId:ZC.optional(),author:D().trim().min(1).max(128),authorUrl:hw.optional(),sourceUrl:hw.optional(),license:D().trim().min(1).max(64).optional(),official:k().optional(),instructions:D().trim().min(1).max(1e5),updatedAt:Yu()});j({formatVersion:P(1),generatedAt:Yu(),roles:A(_w)});let vw=j({slug:aw,name:D().refine(e=>e.trim().length>0),avatar:fw,accentColor:sw}),yw=vw.readonly(),bw=vw.extend({description:D(),harnessId:ZC,model:ow.optional(),thinkingOptionId:$C.optional(),instructions:D(),updatedAt:Yu()});bw.omit({updatedAt:!0,avatar:!0}).extend({avatar:mw}).partial({slug:!0}),j({locale:D().trim().min(1).max(64).optional()}),j({roles:A(bw)}),j({slug:aw}),j({role:bw.nullable()}),j({role:bw}),j({deleted:k()}),j({refresh:k().optional()}),j({roles:A(_w),fetchedAt:Yu(),likes:vu(aw,O().int().nonnegative()).optional(),myLikes:vu(aw,O().int().min(0).max(5)).optional(),stale:k().optional(),error:D().optional()}),j({slug:aw}),j({slug:aw,likes:O().int().nonnegative(),myLikes:O().int().min(0).max(5),maxLikes:P(5),limitReached:k().optional()});let xw=O().int().safe().nonnegative(),Sw=O().finite().nonnegative(),Cw=O().finite().min(0).max(100),ww=j({version:uu([P(3),P(4)]).optional(),requestId:D().min(1),turnId:D().min(1).max(1024),outputTokens:xw,startedAtMs:xw,completedAtMs:xw}).strict().refine(e=>e.completedAtMs>e.startedAtMs),Tw=j({version:uu([P(2),P(3),P(4)]).optional(),value:Sw,turnId:D().min(1).max(1024),at:xw}).strict();j({outputTimings:A(ww).transform(e=>e.filter(e=>e.version===4)).optional(),outputTokensPerSecond:Tw.refine(e=>e.version===4).optional().catch(void 0),timeToFirstOutputMs:Tw.extend({value:xw}).optional()}).strict();let Ew=e=>YC.refine(t=>Object.values(t).every(t=>t.length<=e)),Dw=j({composerIndicators:A(j({kind:P(`countdown`),id:D().min(1).max(64),expiresAtUnix:xw,label:Ew(256).optional(),tooltip:Ew(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:xw.optional(),cachedInputTokens:xw.optional(),cacheWriteInputTokens:xw.optional(),outputTokens:xw.optional(),outputTokensPerSecond:Sw.optional(),sessionOutputTokensPerSecond:Sw.optional(),apiOutputTokensPerSecond:Sw.optional(),reasoningOutputTokens:xw.optional(),totalTokens:xw.optional(),totalCostUsd:Sw.optional(),totalCredits:Sw.optional(),contextUsagePercent:Sw.optional(),cacheHitRatePercent:Cw.optional(),contextWindowTokens:xw.optional(),contextUsedTokens:xw.optional(),planFiveHourUsedPercent:Cw.optional(),planFiveHourResetsAtUnix:xw.optional(),planSevenDayUsedPercent:Cw.optional(),planSevenDayResetsAtUnix:xw.optional(),sessionCacheHitRatePercent:Cw.optional(),timeToFirstOutputMs:xw.optional(),latestRequestTimeToFirstOutputMs:xw.optional(),costSource:N([`publicPrice`,`native`]).optional(),unpricedModels:A(D().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`]})}),Ow=O().finite().min(0).max(100),kw=N([`weekly`,`monthly`,`five_hour`,`seven_day`,`unknown`]),Aw=j({id:D().min(1).max(256),label:D().min(1).max(256),localizations:JC.optional()}).strict(),jw=j({product:D().min(1),periodType:kw.optional(),scope:Aw.optional(),localizations:JC.optional(),used:O().finite().nonnegative().optional(),limit:O().finite().nonnegative().optional(),unit:D().min(1).max(32).optional(),usagePercent:Ow,resetsAt:D().min(1).optional()}).strict(),Mw=j({availableCount:O().int().safe().positive(),nextExpiresAt:D().min(1).optional(),expiresAt:A(D().min(1)).min(1).max(32).optional()}).strict(),Nw=j({used:O().finite().nonnegative().optional(),limit:O().finite().nonnegative().optional(),unit:D().min(1).max(32).optional(),label:D().min(1).optional(),scope:Aw.optional(),localizations:JC.optional(),usedPercent:Ow,resetsAt:D().min(1).optional(),periodType:kw,productUsage:A(jw).min(1).optional(),resetCredits:Mw.optional()}).strict(),Pw=j({amount:O().finite().nonnegative(),currency:D().trim().min(1).max(8),label:D().trim().min(1).max(128).optional()}).strict();j({threadId:Y,refresh:P(`exact`).optional()}).strict(),j({threadId:Y,usage:Dw.nullable(),accountCredits:Nw.optional(),accountBalance:Pw.optional(),accountCreditsSupported:k().optional()}).strict();let Fw=D().refine(e=>e.trim().length>0,{message:`Value must not be empty or whitespace`}),Iw=D().min(1).max(512).refine(e=>!/\p{Cc}/u.test(e),`Model Ref must not contain control characters`).brand(),Lw=N([`priority`,`ultrafast`]),Rw=j({id:Iw,serviceTier:Lw.optional()}).strict();function zw(e,t){return e?.id===t?.id&&e?.serviceTier===t?.serviceTier}let Bw=Fw.max(256),Vw=j({id:$C,label:Fw.max(256)}).strict(),Hw=j({ref:Rw,label:Fw.max(256),resolvedModelLabel:Bw.optional(),fastModel:Rw.optional(),supportedThinkingOptionIds:A($C).optional()}).strict().refine(e=>e.fastModel?.serviceTier===void 0||e.fastModel.id===e.ref.id,{path:[`fastModel`,`id`],message:`A tiered Fast Model must share the base Model ID`});function Uw(e,t){if(t)return e?.models.find(e=>zw(e.ref,t)||zw(e.fastModel,t))}let Ww=A(Vw).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)}),Gw=N([`catalog`,`activeModel`]),Kw=j({models:A(Hw),defaultModel:Rw.optional(),thinkingOptions:Ww,defaultThinkingOptionId:$C.optional(),thinkingOptionsScope:Gw.optional()}).strict().superRefine((e,t)=>{let n=[],r=new Set(e.thinkingOptions.map(({id:e})=>e));for(let[i,a]of e.models.entries()){n.some(e=>zw(e,a.ref))&&t.addIssue({code:`custom`,message:`Model Catalog refs must be unique`,path:[`models`,i,`ref`,`id`]}),n.push(a.ref),a.fastModel&&(n.some(e=>zw(e,a.fastModel))&&t.addIssue({code:`custom`,message:`Fast Model refs must be distinct and unique`,path:[`models`,i,`fastModel`]}),n.push(a.fastModel));let e=/* @__PURE__ */ new Set;for(let[n,o]of(a.supportedThinkingOptionIds??[]).entries())e.has(o)&&t.addIssue({code:`custom`,message:`Supported Thinking option IDs must be unique per Model`,path:[`models`,i,`supportedThinkingOptionIds`,n]}),e.add(o),r.has(o)||t.addIssue({code:`custom`,message:`Supported Thinking option must exist in the catalog`,path:[`models`,i,`supportedThinkingOptionIds`,n]})}e.defaultModel&&!Uw(e,e.defaultModel)&&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`]})}),qw=j({fork:k(),forkAcrossCwd:k(),rollbackLastTurn:k()}).strict().refine(e=>e.fork||!e.forkAcrossCwd,{path:[`forkAcrossCwd`],message:`Cross-cwd Fork requires exact history Fork support`}),Jw=N([`live`,`atCreate`]),Yw=j({configuration:j({selectModel:k(),selectThinkingOption:k(),selectPermissionMode:k(),permissionModeScope:Jw.default(`live`)}).strict(),history:qw,subagents:j({observe:k(),readTranscript:k()}).strict().optional(),autonomousTurns:j({observe:k()}).strict().optional(),steer:k().optional(),persistentPlan:k().optional()}).strict();j({effectiveModel:Rw.optional(),resolvedModelLabel:Bw.optional(),effectiveThinkingOptionId:$C.optional(),availableThinkingOptions:Ww.optional(),effectivePermissionModeId:tw.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 Xw=j({open:P(!0)}).strict();uu([j({status:P(`ready`),catalog:Kw,permissionModes:nw.optional(),capabilities:Yw,webUi:Xw.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`]})}),j({status:N([`notInstalled`,`unavailable`,`error`]),error:GC}).strict()]),j({harnessId:ZC,cwd:Fw.max(16384).optional(),refresh:k().optional(),purpose:P(`availability`).optional(),credentialAccess:N([`allow`,`retry`]).optional()}).strict(),j({harnessId:ZC}).strict(),j({}).strict(),j({threadId:Y,model:Rw}).strict(),j({threadId:Y,thinkingOptionId:$C}).strict(),j({threadId:Y,includeReferenceCapability:k().optional()}).strict(),fu(`owner`,[j({owner:P(`codex`),locked:k(),effectiveModel:Rw.optional(),resolvedModelLabel:Bw.optional(),effectiveThinkingOptionId:$C.optional(),effectivePermissionModeId:tw.optional(),history:qw.optional(),supportsThreadReferences:P(!0).optional(),handoff:iw.optional(),roleSnapshot:yw.optional(),nativeSessionRef:ou().optional()}),j({owner:P(`external`),harnessId:Fw.max(256),transportModelId:Fw.max(8192),effectiveModel:Rw.optional(),resolvedModelLabel:Bw.optional(),effectiveThinkingOptionId:$C.optional(),availableThinkingOptions:Ww.optional(),effectivePermissionModeId:tw.optional(),catalog:Kw.optional(),history:qw,usage:Dw.optional(),handoff:iw.optional(),roleSnapshot:yw.optional(),nativeSessionRef:ou().optional(),locked:P(!0)})]),j({threadIds:A(Y).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 Zw=fu(`owner`,[j({threadId:Y,owner:P(`codex`)}).strict(),j({threadId:Y,owner:P(`external`),harnessId:D().max(256).pipe(ZC)}).strict()]);j({threads:A(Zw).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)}),j({threadId:Y,text:D().optional()}).strict(),j({kind:P(`application`),value:D().transform((e,t)=>{try{return JSON.parse(e)}catch{return t.addIssue({code:`custom`,message:`Invalid steering context JSON`}),$n}}).pipe(j({expectedTurnId:QC,clientUserMessageId:D().min(1),delivery:N([`newTurn`,`activeTurn`])}).strict())}).strict().transform(e=>e.value),N([`activeTurn`,`newTurn`]),j({delivery:N([`official`,`activeTurn`,`newTurn`])}).strict();let Qw=D().min(1).max(128).regex(/^[a-z][a-z0-9]*(?:[._-][a-z0-9]+)*$/u),$w=Qw.pipe(ZC),eT=$w.refine(e=>e!==`codex`,`The official Codex identity is reserved`),tT=D().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`),nT=Fl().refine(e=>/^https:\/\/[^/?#@]+(?:[/?#]|$)/iu.test(e),`Plugin documentation links must be credential-free HTTPS URLs`),rT=j({en:D().max(4096),"zh-CN":D().max(4096).optional()}).strict(),iT=j({commands:A(j({terminal:D().max(256),command:D().max(4096)}).strict()).max(8),before:rT.optional(),after:rT.optional(),downloads:A(j({label:D().max(128),url:nT}).strict()).max(8).optional()}).strict(),aT={id:$w,name:D().trim().min(1).max(128),version:D().min(1).max(128),kind:P(`usage`).optional(),iconStyle:j({vector:j({viewBox:D().max(128).regex(/^-?\d+(?:\.\d+)?(?: +-?\d+(?:\.\d+)?){3}$/u),color:D().regex(/^(?:currentColor|#[a-f0-9]{6})$/iu),paths:A(j({d:D().min(1).max(32768).regex(/^[MmLlHhVvCcSsQqTtAaZz\d.,+eE\s-]+$/u),fillRule:N([`evenodd`,`nonzero`]).optional(),fill:D().regex(/^(?:currentColor|#[a-f0-9]{6})$/iu).optional()}).strict()).min(1).max(32)}).strict().optional(),background:D().regex(/^#[a-f0-9]{6}$/iu).optional(),borderRadius:O().min(0).max(50).optional(),paddingRatio:O().min(0).max(.25).optional()}).strict().optional(),installation:iT.optional(),notice:rT.optional(),launchCommand:P(!0).optional(),links:j({website:nT.optional(),documentation:nT.optional(),installation:nT.optional()}).strict().optional()};j({manifestVersion:P(1),...aT,adapterApiVersion:O().int().positive(),entry:tT,icon:tT.optional()}).strict();let oT=D().max(174828).regex(/^data:image\/(?:png|jpeg|webp|svg\+xml);base64,[A-Za-z0-9+/]+={0,2}$/u),sT=j({...aT,icon:oT.optional()}).strict();j({}).strict(),j({plugins:A(sT.extend({id:eT})).max(128)}).strict(),j({version:P(1),enabled:A($w).max(128)}).strict().refine(e=>new Set(e.enabled).size===e.enabled.length,{message:`Enabled plugin IDs must be unique`,path:[`enabled`]});let cT=131072,lT=524288,uT=Qw,dT=N([`sidebar.thread-layout`,`sidebar.thread-badge`,`appearance.theme`]),fT=N([`appearance`,`interface`,`workflow`,`analytics`,`integrations`,`tools`]),pT=D().trim().min(1).max(128);function mT(e){switch(e.match(/\.([^./]+)$/u)?.[1]?.toLowerCase()){case`png`:return`image/png`;case`jpg`:case`jpeg`:return`image/jpeg`;case`webp`:return`image/webp`;default:return}}let hT=e=>e.split(`/`).every(e=>!/[. ]$/u.test(e)),gT=tT.refine(e=>mT(e)!==void 0&&hT(e),`Images must be relative .png, .jpg, .jpeg, or .webp paths with no segments ending in a dot or space`),_T=D().trim().max(2048).regex(/^https?:\/\/[^/?#\\\s]+/iu,`Expected an HTTP(S) URL`).pipe(Fl({protocol:/^https?$/u})).refine(e=>{let{username:t,password:n}=new URL(e);return!t&&!n&&!/[\\\s]/u.test(e)},`URL must not contain credentials, backslashes, or whitespace`);function vT(e){return M({en:e,"zh-CN":e})}let yT=vT(D().trim().min(1)),bT=A(fT).max(fT.options.length).refine(e=>new Set(e).size===e.length,`Duplicate categories`),xT=A(dT).max(dT.options.length).refine(e=>new Set(e).size===e.length,`Duplicate slots`),ST={key:D().regex(/^[A-Za-z_][A-Za-z0-9_]*$/u),label:yT,description:yT.optional()},CT={...ST,step:O().positive().optional(),default:O().optional()},wT=M({value:D(),label:yT}),TT=fu(`type`,[M({...ST,type:P(`boolean`),default:k().optional()}),M({...ST,type:P(`string`),placeholder:yT.optional(),default:D().optional()}),M({...CT,type:P(`number`),min:O().optional(),max:O().optional()}),M({...CT,type:P(`range`),min:O(),max:O()}),M({...ST,type:P(`select`),options:A(wT).min(1),default:D().optional()})]).superRefine((e,t)=>{let n=(e,n)=>t.addIssue({code:`custom`,path:[e],message:n});if(e.type===`number`||e.type===`range`){let{min:t=-1/0,max:r=1/0,default:i}=e;t>r&&n(`max`,`Must be at least min`),i!==void 0&&(i<t||i>r)&&n(`default`,`Must be within min and max`)}else if(e.type===`select`){let t=new Set(e.options.map(({value:e})=>e));t.size!==e.options.length&&n(`options`,`Duplicate option values`),e.default!==void 0&&!t.has(e.default)&&n(`default`,`Must match an option value`)}}),ET=j({manifestVersion:$l().positive(),id:uT,name:uu([pT,vT(pT)]),version:D().min(1).max(128),desktopApi:$l().positive()}).passthrough().extend({manifestVersion:P(1),desktopApi:P(1),description:M({en:D().max(4096),"zh-CN":D().max(4096).optional()}).optional(),author:D().trim().min(1).max(128).optional(),repository:_T.optional(),details:M({en:D().max(16384),"zh-CN":D().max(16384).optional()}).optional(),icon:gT.optional(),screenshots:A(gT).max(4).refine(e=>new Set(e).size===e.length,`Duplicate screenshots`).optional(),desktop:M({script:tT,style:tT.optional()}).optional(),backend:M({script:tT.refine(hT)}).optional(),slots:xT.default(()=>[]),settingsSchema:A(TT).max(32).refine(e=>new Set(e.map(({key:e})=>e)).size===e.length,`Duplicate setting keys`).optional(),categories:bT.optional()}).strict().refine(e=>e.desktop!==void 0||e.backend!==void 0,`Expected at least one desktop or backend entry`),DT=D().regex(/^[a-f0-9]{64}$/u),OT=M({state:N([`running`,`disabled`,`invalid`,`incompatible`,`conflict`,`failed`,`waiting`]),hash:DT.optional(),error:D().optional(),conflictWith:uT.optional()});M({controllerPid:$l().positive(),targetId:D().nullable(),updatedAt:Yu(),handledReloadToken:Ml().optional(),extensions:vu(D(),OT),surfaces:vu(D(),OT).optional()});let kT=N([`official`,`community`]);function AT(e){return e.origin===`https://api.github.com`&&/^\/repos\/[\w-]+\/[\w.-]+\/zipball(?:\/[^/]+)?\/?$/u.test(e.pathname)}let jT=_T.refine(e=>{let t=new URL(e);return/\.zip$/iu.test(t.pathname)||AT(t)||t.origin===`https://github.com`&&/^\/[\w-]+\/[\w.-]+\/zipball(?:\/.+)?\/?$/u.test(t.pathname)||t.origin===`https://codeload.github.com`&&/^\/[\w-]+\/[\w.-]+\/(?:zip|zipball|legacy\.zip)\/.+$/u.test(t.pathname)},`Expected a .zip download URL or a GitHub zipball URL`),MT=M({id:uT,version:D().trim().min(1).max(128),name:yT.extend({en:pT,"zh-CN":pT}),description:vT(D().trim().min(1).max(4096)),details:vT(D().trim().min(1).max(16384)).optional(),author:D().trim().min(1).max(128),repository:_T,stars:O().int().min(0).optional(),downloads:O().int().min(0).optional(),categories:bT.optional(),trustTier:kT.default(`community`),icon:_T.optional(),screenshots:A(_T).max(4).optional(),downloadUrl:jT,sha256:DT,slots:xT.optional(),publishedAt:D().optional(),updatedAt:D().optional(),minCodexHostVersion:D().optional()});M({schemaVersion:P(1),generatedAt:D(),extensions:A(MT).refine(e=>new Set(e.map(({id:e})=>e)).size===e.length,`Duplicate extension IDs`)});let NT=D().trim().min(1).max(128),PT=/^(?:con|prn|aux|nul|com[1-9¹²³]|lpt[1-9¹²³]) *(?:\.|$)/iu,FT=uT.refine(e=>!PT.test(e),`Reserved extension ID`),IT=N([`desktop`,`web`]),LT=DT,RT=Ml(),zT=tT.refine(e=>!/[\x00-\x1f\x7f<>"|*]/u.test(e)&&e.split(`/`).every(e=>!/[. ]$/u.test(e)&&!PT.test(e)),`Expected a portable relative resource path`).refine(e=>e.split(`/`).length<=32,`Extension resources may be at most 32 segments deep`),BT=ET.shape,VT=(e,t=0)=>M({en:D().trim().min(t).max(e),"zh-CN":D().trim().min(t).max(e)}),HT=e=>zT.refine(t=>t.endsWith(e),`Expected a ${e} file`),UT=HT(`.mjs`),WT=HT(`.css`).optional(),GT=e=>e.normalize(`NFC`).toLowerCase(),KT=M({manifestVersion:P(2),id:FT,name:VT(128,1),version:D().trim().min(1).max(128),description:VT(4096),details:VT(16384).optional(),author:BT.author,repository:BT.repository,icon:BT.icon.refine(e=>e===void 0||zT.safeParse(e).success),screenshots:BT.screenshots.refine(e=>e===void 0||e.every(e=>zT.safeParse(e).success)),categories:BT.categories,settingsSchema:BT.settingsSchema,slots:BT.slots.removeDefault().optional(),page:M({apiVersion:P(1),entry:UT,style:WT,title:VT(128,1).optional()}).optional(),widget:M({apiVersion:P(1),entry:UT,style:WT}).optional(),desktop:M({apiVersion:P(1),script:HT(`.js`),style:WT}).optional(),web:M({apiVersion:P(1),entry:UT.optional(),style:WT}).refine(({entry:e,style:t})=>e!==void 0||t!==void 0,`Expected a Web entry or style`).optional(),backend:M({apiVersion:P(1),entry:UT}).optional()}).refine(({page:e,widget:t,desktop:n,web:r,backend:i})=>!!(e||t||n||r||i),`Expected at least one page, widget, desktop, web, or backend entry`).refine(({page:e,widget:t,web:n,backend:r})=>!r||[e?.entry,t?.entry,n?.entry].every(e=>e===void 0||GT(e)!==GT(r.entry)),{path:[`backend`,`entry`],message:`A backend entry cannot also be a frontend entry`});function qT({hasPage:e,hasWidget:t,hasDesktop:n,hasWeb:r,hasBackend:i}){if(e||t||i&&!n&&!r)return[`desktop`,`web`];let a=[];return n&&a.push(`desktop`),r&&a.push(`web`),a}let JT=NT,YT=N([`running`,`waiting`,`idle`,`unknown`]),XT=j({createdAtMs:O().int().nonnegative()}),ZT=M({sourceThreadId:Y,createdAtMs:O().int().nonnegative()}),QT=M({harnessId:ZC,title:D().optional(),status:YT,archived:k(),updatedAtMs:O().int().nonnegative().optional()}),$T=j({revision:$l().nonnegative(),parents:vu(Y,Y),delegations:vu(Y,XT).optional(),handoffs:vu(Y,ZT).optional(),nodes:vu(Y,QT),truncated:k()}).refine(e=>Object.keys(e.nodes).length<=5e3,`Too many Thread tree nodes`).refine(({parents:e,handoffs:t,nodes:n})=>Object.entries(e).every(([e,t])=>Object.hasOwn(n,e)&&Object.hasOwn(n,t))&&Object.entries(t??{}).every(([e,{sourceThreadId:t}])=>Object.hasOwn(n,e)&&Object.hasOwn(n,t)),`Missing Thread tree node`).refine(({parents:e,delegations:t})=>Object.keys(t??{}).every(t=>Object.hasOwn(e,t)),`Delegation metadata requires a matching parent edge`),eE=D().min(1).max(128);M({});let tE=M({subscriptionId:eE});M({}),tE.extend({snapshot:$T});let nE=$l().nonnegative(),rE=M({revision:nE,enabled:A(FT).max(64).refine(e=>new Set(e).size===e.length,`Duplicate extension IDs`)});M({version:P(1),seeded:A(FT).max(64).refine(e=>new Set(e).size===e.length,`Duplicate extension IDs`)});let iE=j({version:D().trim().min(1).max(128),publishedAt:D().trim().min(1).max(64).optional(),notes:D().trim().min(1).max(8192),url:_T.optional()}),{downloadUrl:aE,...oE}=MT.shape,sE=j({...oE,id:FT,format:P(`codexhost`),targets:A(IT).min(1).max(2).refine(e=>new Set(e).size===e.length,`Duplicate targets`),apis:M({page:$l().positive().optional(),widget:$l().positive().optional(),desktop:$l().positive().optional(),web:$l().positive().optional(),backend:$l().positive().optional()}),downloadUrl:aE.refine(e=>e.startsWith(`https://`),`Expected HTTPS`),featured:k().optional(),featuredOrder:$l().nonnegative().optional(),changelog:A(iE).max(20).optional()}).refine(({targets:e,apis:t})=>{let n=qT({hasPage:!!t.page,hasWidget:!!t.widget,hasDesktop:!!t.desktop,hasWeb:!!t.web,hasBackend:!!t.backend});return e.length===n.length&&n.every(t=>e.includes(t))},`Catalog targets must match the declared APIs`);j({schemaVersion:P(2),generatedAt:D().min(1),extensions:A(sE).max(1e4).refine(e=>new Set(e.map(({id:e})=>e)).size===e.length,`Duplicate extension IDs`)}).extend({catalogUrl:_T,fetchedAt:Yu(),cached:k(),stale:k().optional()});let cE={id:FT},lE={...cE,activationId:RT,digest:LT},uE={...cE,activationId:lE.activationId.optional()},dE=D().min(1).max(4096).refine(e=>/^(?:\/|[a-z]:[/\\])/iu.test(e)&&!e.includes(`\0`)&&!e.split(/[/\\]/u).some(e=>e===`.`||e===`..`),`Expected an absolute local path without dot segments`),fE=D().min(1).max(256).refine(e=>e.split(`/`).every(e=>e&&/^[a-z0-9_.-]+$/iu.test(e)&&e!==`.`&&e!==`..`),`Invalid GitHub ref`);function pE(e){return D().max(4*Math.ceil(e/3)).refine(t=>{let n=t.endsWith(`==`)?2:+!!t.endsWith(`=`);return t.length%4==0&&t.length*3/4-n<=e&&/^[A-Za-z0-9+/]*={0,2}$/u.test(t)},`Expected bounded standard padded base64`)}let mE=M({type:P(`github`),repository:D().max(150).regex(/^[a-z0-9-]+\/[a-z0-9_-][a-z0-9_.-]*$/iu),ref:fE.optional(),tag:fE.optional(),asset:D().max(255).regex(/^[a-z0-9_.-]+\.zip$/iu).optional(),subpath:zT.optional()}).refine(({ref:e,tag:t,asset:n})=>!e||!t&&!n,`Use either a zipball ref or a release tag/asset`),hE=uu([M({type:P(`catalog`),...cE}),mE,M({type:P(`zip`),base64:pE(67108864).min(4)}),M({type:P(`zip`),localZipPath:dE}),M({type:P(`localDir`),localDir:dE})]),gE=fu(`type`,[M({type:P(`catalog`),...cE}),mE,M({type:P(`zip`)}),M({type:P(`localDir`)})]),_E=M({...lE,manifest:KT,installedAt:Yu(),source:gE.optional()}),vE=e=>D().max(23+4*Math.ceil(e/3)).regex(/^data:image\/(?:png|jpeg|webp);base64,[A-Za-z0-9+/]+={0,2}$/u),yE={desktopConflictWith:FT.optional()},bE=N([`none`,`inactive`,`starting`,`running`,`failed`]),xE=fu(`state`,[_E.extend({state:P(`valid`),enabled:k(),...yE,iconDataUrl:vE(cT).optional(),screenshotDataUrls:A(vE(lT)).max(4).optional(),backendState:bE.optional(),backendError:D().optional()}),M({state:N([`invalid`,`incompatible`]),id:D().min(1),enabled:k(),error:D()})]);M({revision:nE,configuration:rE,diagnostics:A(D()),extensions:A(xE)}),M({revision:nE,extensions:A(_E.extend({...yE,settingsRevision:nE})).max(64)});let SE={list:`codexhost/extensions/list`,snapshot:`codexhost/extensions/snapshot`,catalog:`codexhost/extensions/catalog`,catalogIcon:`codexhost/extensions/catalogIcon`,catalogScreenshot:`codexhost/extensions/catalogScreenshot`,install:`codexhost/extensions/install`,update:`codexhost/extensions/update`,enable:`codexhost/extensions/enable`,disable:`codexhost/extensions/disable`,uninstall:`codexhost/extensions/uninstall`,recover:`codexhost/extensions/recover`,asset:`codexhost/extensions/asset`,settingsGet:`codexhost/extensions/settings/get`,settingsSet:`codexhost/extensions/settings/set`,backendInvoke:`codexhost/extensions/backend/invoke`,threadTree:`codexhost/extensions/threadTree`},CE=Object.freeze(Object.values(SE));new Set(CE),M({});let wE={expectedRevision:nE};M({...cE,...wE}),_E.extend({replaced:k()}),fu(`state`,[M({state:P(`saved`),configuration:rE}),M({state:P(`revision-conflict`),revision:nE})]),M({...uE,digest:lE.digest.optional(),path:zT}),M({mimeType:D().min(1),base64:pE(16777216),digest:lE.digest}),M({mimeType:N([`image/png`,`image/jpeg`,`image/webp`]),base64:pE(cT)});let TE=$l().min(0).max(3);M({mimeType:N([`image/png`,`image/jpeg`,`image/webp`]),base64:pE(lT)}),M({settingsRevision:nE,values:WC}),SE.list,SE.snapshot,SE.catalog,M({forceRefresh:k().optional(),staleWhileRevalidate:k().optional()}),SE.catalogIcon,M({...cE}),SE.catalogScreenshot,M({...cE,index:TE}),SE.install,M({source:hE}),SE.update,M({...cE,expectedDigest:lE.digest,expectedActivationId:lE.activationId.optional(),source:hE.optional()}),SE.enable,SE.disable,SE.uninstall,M({...cE,removeData:k().optional(),expectedDigest:lE.digest.optional()}),M({...cE,removed:k()}),SE.recover,M({expectedRevision:wE.expectedRevision.optional()}),SE.asset,SE.settingsGet,M(uE),SE.settingsSet,M({...uE,expectedSettingsRevision:nE,values:WC}),SE.backendInvoke,M({...uE,method:JT,params:UC.optional()}),M({result:UC}),SE.threadTree;let EE=D().regex(/^remote:[A-Za-z0-9_-]{8,512}$/u),DE=uu([Nl(),EE]),OE=Nl(),kE=D().regex(/^[a-z0-9][a-z0-9_-]{0,47}$/u),AE=N([`none`,`last_speaker`,`all`]),jE=N([`active`,`muted`,`removed`]),ME=$l().nonnegative(),NE=$l().positive(),PE=NE.max(20),FE=D().refine(e=>e.trim().length>0),IE=Yu(),LE={handle:kE.optional(),displayName:FE.optional(),note:D().optional()},RE=j({memberId:OE,threadId:Y,handle:kE,displayName:FE,note:D().optional(),roleSlug:aw.optional(),roleSnapshot:yw.optional(),harnessId:ZC,status:jE,joinedAtSeq:ME,lastDeliveredSeq:ME,lastRosterVersion:ME,createdAt:IE}),zE=j({hostId:FE,displayName:FE,state:FE.optional(),color:D().optional(),filePreview:k().optional()}),BE=j({roomId:DE,title:FE,defaultCwd:FE,unmentionedPolicy:AE.default(`none`),allowAgentMentions:k().default(!0),maxAgentHops:PE.default(5),lastSeq:ME,lastSpeakerMemberId:OE.optional(),rosterVersion:ME,humanEpoch:ME,relayPaused:k(),pinned:k(),createdAt:IE,updatedAt:IE,members:A(RE),remote:zE.optional()}).superRefine(({members:e},t)=>{let n=/* @__PURE__ */ new Set;for(let[r,{handle:i,status:a}]of e.entries())a!==`removed`&&(n.has(i)&&t.addIssue({code:`custom`,path:[`members`,r,`handle`],message:`Handle must be unique among non-removed members`}),n.add(i))}),VE=j({kind:N([`image`,`file`]),attachmentId:FE.max(256),name:FE.max(256),path:FE.max(4096),bytes:ME,mediaType:FE.max(128).optional(),width:NE.optional(),height:NE.optional()}),HE=j({roomId:DE,seq:NE,messageId:FE,senderType:N([`user`,`agent`,`system`]),senderMemberId:OE.optional(),senderHandle:kE.optional(),senderName:D().optional(),senderThreadId:Y.optional(),sourceTurnId:FE.optional(),replyToSeq:NE.optional(),content:D(),attachments:A(VE).max(12).optional(),mentionedMemberIds:A(OE),mentionAll:k().optional(),hopCount:ME,createdAt:IE}),UE={...LE,model:ow.optional(),thinkingOptionId:$C.optional(),worktree:k().optional()},WE=fu(`kind`,[M({kind:P(`role`),roleSlug:aw,...UE}),M({kind:P(`harness`),harnessId:ZC,...UE}),M({kind:P(`existing`),threadId:Y,...LE,includeRecentHistory:k().default(!0).optional()})]),GE={roomId:DE},KE={...GE,memberId:OE},qE={title:FE.optional(),unmentionedPolicy:AE.optional(),allowAgentMentions:k().optional(),maxAgentHops:PE.optional()};M({}),j({rooms:A(BE)}),M({...GE,limit:NE.optional(),beforeSeq:NE.optional()}),j({room:BE.nullable(),messages:A(HE),hasMore:k()}),M({...qE,defaultCwd:FE,members:A(WE)}),j({room:BE}),M({...GE,...qE,pinned:k().optional(),relayPaused:k().optional()}),M(GE),j({deleted:k()}),M({...GE,member:WE}),j({room:BE,member:RE}),M({...KE,...LE,status:jE.optional()}),M(KE),M({...GE,content:D().max(64e3),attachments:A(VE).max(12).optional(),replyToSeq:NE.optional(),targetMemberIds:A(OE).optional(),mentionAll:k().optional()}).refine(e=>e.content.trim().length>0||(e.attachments?.length??0)>0,`Message content or at least one attachment is required`),j({room:BE,message:HE,awakenedMemberIds:A(OE)}),M({...GE,fromSeq:NE.optional(),toSeq:NE.optional(),limit:NE.optional()}),j({...GE,messages:A(HE),totalSeq:ME}),j({threadId:Y}).strict(),j({confirmed:k()}).strict();let JE=[`codex-desktop`,`web`,`web-desktop-shell`,`web-mobile`,`ssh-remote`,`cli`],YE=[`darwin`,`win32`,`linux`],XE=[`arm64`,`x64`,`ia32`,`arm`],ZE=[`zh`,`en`,`ja`,`ko`,`de`,`fr`,`es`,`pt`,`ru`,`other`],QE=[`codex`,`claude-code`,`antigravity`,`pi`,`opencode`,`cursor-cli`,`deepseek-harness`,`grok`,`omp`,`qwen-code`,`kiro-cli`,`codebuddy`,`workbuddy`,`devin`,`hermes`,`qoder`,`qoder-cn`,`kimi-code`,`zcode`,`copilot`,`custom`],$E=[`official-relay`,`self-hosted-relay`,`tailscale-serve`,`tailscale-funnel`,`tailscale-ip`,`lan`,`custom-proxy`,`remote-peer`],eD=D().min(1).max(40).regex(/^[0-9A-Za-z._+-]+$/u),tD=N(JE),nD=N(ZE),rD=N(QE),iD=N($E);new Set(QE),new Set(ZE),j({enabled:k(),forcedOffByEnv:k()}).strict(),j({enabled:k()}).strict(),j({surfaces:A(tD).max(12).optional(),harnesses:A(rD).max(32).optional(),remoteAccess:A(iD).max(12).optional()}).strict(),j({dailyActive:P(!0).optional(),weeklyActive:P(!0).optional(),monthlyActive:P(!0).optional(),newInstall:P(!0).optional(),retainedD1:P(!0).optional(),retainedD7:P(!0).optional(),remoteAny:P(!0).optional(),appVersion:eD.optional(),codexDesktopVersion:eD.optional(),os:N(YE).optional(),arch:N(XE).optional(),uiLanguage:nD.optional(),surfaces:A(tD).min(1).max(12).optional(),harnesses:A(rD).min(1).max(32).optional(),remoteAccess:A(iD).min(1).max(12).optional()}).strict().refine(e=>Object.keys(e).length>0,{message:`Telemetry heartbeat must contain at least one countable field`});let aD=4e3,oD={threadId:Y};fu(`action`,[M({...oD,action:N([`get`,`pause`,`resume`,`clear`])}),M({...oD,action:N([`create`,`edit`]),objective:D().trim().min(1).refine(e=>Array.from(e).length<=aD,`A goal objective can have up to ${aD} characters.`)})]),j({goal:j({threadId:Y,objective:D(),status:N([`active`,`paused`,`blocked`,`usageLimited`,`budgetLimited`,`complete`]),tokenBudget:$l().positive().nullable().default(null),tokensUsed:$l().nonnegative(),timeUsedSeconds:$l().nonnegative()}).nullable()});let sD=D().trim().min(1),cD=D().min(1),lD=j({icon:D().nullable(),color:D().nullable()}),uD=lD.nullable(),dD={create:{method:`codexhost/thread/sections/create`,params:j({name:sD}).strict()},update:{method:`codexhost/thread/sections/update`,params:j({sectionId:cD,name:sD,appearance:lD.strict().nullable().optional()}).strict()},delete:{method:`codexhost/thread/sections/delete`,params:j({sectionId:cD}).strict()}};fu(`status`,[j({status:P(`unknown`)}),j({status:P(`confirmed`),sectionId:cD,section:j({id:cD,name:D().min(1),appearance:uD}).nullable(),syncPending:k()})]),[dD.create.method,dD.update.method,dD.delete.method,...CE],j({threadSectionsV1:P(!0).optional(),complete:P(!1).optional(),sections:A(j({id:D().min(1),name:D().min(1),appearance:uD.optional(),threads:A(WC)}))}),j({threadId:D().min(1).max(1024),sectionId:D().min(1).max(1024).nullable(),beforeThreadId:D().min(1).max(1024).nullable().optional(),expectedSourceSectionId:D().min(1).max(1024).optional()}).refine(e=>e.expectedSourceSectionId===void 0||e.sectionId===null),j({threadIds:A(D().min(1))}).strict(),j({threadId:D().min(1).max(1024),pinned:k()}).strict(),j({}).strict(),j({parents:vu(D().min(1),D().min(1))}).strict(),j({prompt:D().max(16384).optional()}).strict(),j({projects:A(j({id:D(),name:D(),rootPaths:A(D()),createdAt:O().int().optional()})),nativeProjects:P(!0).optional(),assignments:vu(D(),D()),projectless:A(D()),pinned:A(D()),sectionProjects:vu(D(),A(D())).optional(),pinnedProjects:A(D()).optional()});let fD=vu(D(),iu()),pD=j({epoch:D().uuid(),sequence:O().int().nonnegative()});fu(`type`,[j({type:P(`projects-changed`),cursor:pD}),j({type:P(`skills-changed`),cursor:pD,cwd:D().optional()}),j({type:P(`harness-inspection-changed`),cursor:pD,harnessId:D().min(1)}),j({type:P(`display-settings-changed`),cursor:pD}),j({type:P(`sections-changed`),cursor:pD}),j({type:P(`groups-changed`),cursor:pD,roomId:D().optional()}),j({type:P(`preferences-changed`),cursor:pD,revision:O().int().nonnegative()}),j({type:P(`extensions-changed`),cursor:pD,revision:nE}),j({type:P(`hello`),version:P(1),cursor:pD,reset:k()}),j({type:P(`changed`),cursor:pD,threadId:D().min(1),method:D().min(1)})]);let mD=fu(`type`,[j({type:P(`text`),id:D(),prompt:D(),secret:k().optional(),optional:k().optional()}),j({type:P(`choice`),id:D(),prompt:D(),multiple:k(),allowOther:k(),optional:k().optional(),options:A(j({value:D(),label:D(),description:D().optional()}))})]),hD=fu(`type`,[j({type:P(`approval`),title:D(),description:D().optional(),subject:iu().optional(),actions:A(j({id:D(),label:D(),effect:D()}))}),j({type:P(`question`),title:D().optional(),questions:A(mD)})]),gD=j({requestId:uu([D(),O().int()]),threadId:D(),kind:N([`approval`,`question`]),interaction:hD,request:fD}),_D=j({id:D().min(1),clientUserMessageId:D().min(1),input:A(fD),presentationInput:A(fD).nullable().optional()}).passthrough();j({fields:A(j({path:A(uu([D(),O().int().nonnegative()])),originalLength:O().int().nonnegative()}))});let vD=j({id:D().min(1),status:D().min(1),codexhostTurnOutcome:j({status:P(`unknown`),reason:D()}).optional(),items:A(j({id:D().min(1),type:D().min(1)}).passthrough()),codexhostFileOperations:A(j({beforeItemId:D().nullable(),item:j({id:D().min(1),type:D().min(1)}).passthrough()})).optional(),error:j({message:D().optional()}).passthrough().nullable().optional(),fingerprint:D().min(1).optional(),unchanged:P(!0).optional()}).passthrough(),yD=j({id:D().min(1).max(512),fingerprint:D().min(1).max(128)});j({threadId:D().min(1),knownTurns:A(yD).max(64).optional(),truncateToolOutput:k().optional()});let bD=j({harnessId:D().min(1),nativeSessionId:D().min(1)});j({cursor:pD,activeTurnId:D().min(1).nullable().optional(),command:j({name:D().min(1),turn:vD,subsequentTurnId:D().min(1).optional()}).optional(),thread:j({id:D().min(1),cwd:D(),modelProvider:D().min(1),createdAt:O(),updatedAt:O(),recencyAt:O().nullable().optional(),status:j({type:D()}).passthrough(),name:D().nullable().optional(),preview:D().optional(),roleSnapshot:yw.optional(),codexhostImportSource:bD.optional(),turns:A(vD).length(0)}).passthrough(),turnsPage:j({data:A(vD).max(5),nextCursor:D().nullable()}),configuration:j({codexCollaborationMode:N([`plan`,`default`]).optional(),native:j({model:D().min(1).max(1024).optional(),reasoningEffort:D().min(1).max(128).optional()}).optional(),effectiveModel:Rw.optional(),effectiveThinkingOptionId:$C.optional(),effectivePermissionModeId:tw.optional()}),queue:j({items:A(_D),pausedReason:N([`interrupted`,`outcome-unknown`,`failed`]).nullable()}).optional(),interactions:A(gD),handoff:iw.optional()}),j({version:P(1),owner:P(`service`).optional(),pid:O().int().positive(),port:O().int().min(1).max(65535),token:D().regex(/^[0-9a-f]{64}$/u),startedAt:O(),epoch:D().uuid(),capabilities:j({peerDelegation:P(1).optional(),threadReferenceContext:P(1).optional()}).optional()}),j({epoch:D().uuid(),threadId:D().min(1),requestId:uu([D(),O().int()]),result:fD}),j({includeArchived:k().optional(),officialCursor:j({live:D().nullable(),archived:D().nullable().optional()}).strict().optional(),scope:uu([j({cwd:D().min(1).max(4096),excludeCwds:A(D().min(1).max(4096)).max(1024)}).strict(),j({projectId:D().min(1).max(1024),legacyThreadIds:A(D().min(1).max(1024)).max(1024),rootPaths:A(D().min(1).max(4096)).max(1024).optional()}).strict()]).optional()}).strict(),j({threads:A(WC),ownership:A(Zw),archivedThreadIds:A(Y),officialCursor:j({live:D().nullable(),archived:D().nullable().optional()}).strict().optional()}).strict(),sT.pick({id:!0,name:!0,icon:!0,iconStyle:!0});let xD=M({threadId:D().max(1024),title:D().max(240),project:D().max(240),harness:M({id:D().min(1).max(128),name:D().min(1).max(128)}).optional(),state:N([`idle`,`running`,`waiting`,`completed`,`failed`]),updatedAt:O().nonnegative()});M({epoch:D().max(128),revision:$l().nonnegative(),running:$l().nonnegative(),waiting:$l().nonnegative(),sessions:A(xD).max(32).default([]),notifications:A(M({threadId:D().max(1024),key:D().max(4096),kind:N([`completed`,`failed`,`approval`,`question`]),revision:$l().nonnegative()})).max(256)});let SD=D().regex(/^audio\/[a-z0-9.+-]+(?:\s*;[^\r\n]*)?$/i);j({available:k()}).strict(),j({path:D().min(1),mimeType:SD}).strict();let CD=N([`credentials-unavailable`,`login-expired`,`rate-limited`,`service-rejected`,`host-incompatible`,`network`,`timeout`,`audio-empty`,`audio-too-large`,`audio-format`,`audio-invalid`]);fu(`ok`,[j({ok:P(!0),text:D()}).strict(),j({ok:P(!1),error:j({code:CD}).strict()}).strict()]),j({threadId:Y.optional(),cwd:D().min(1).optional()}).strict().refine(e=>!(e.threadId&&e.cwd),{message:`Specify threadId or cwd, not both`});let wD=j({name:D().min(1).regex(/^[^\s[\]]+$/u),description:D().optional(),path:D().min(1),scope:N([`project`,`global`]),source:D().min(1)}).strict();j({revision:O().int().nonnegative(),complete:k(),skills:A(wD),warnings:A(D()).optional()}).strict(),j({cwd:D().min(1).optional()}).strict();let TD=/\[\$([^\]\r\n]+)\]\((?:<([^<>\r\n]+)>|([^\s()]+))(?:[ \t]+(?:"[^"\r\n]*"|'[^'\r\n]*'))?\)/gu;function ED(e){return[...e.matchAll(TD)].flatMap(e=>{let t=e[2]??e[3]??``;return!/^(?:\/|[A-Za-z]:[\\/]|\\\\)/u.test(t)||!/[\\/]SKILL\.md$/u.test(t)?[]:[{start:e.index,end:e.index+e[0].length,name:e[1]??``,path:t,text:e[0]}]})}let DD=j({kind:N([`public`,`relay`,`tailscale-funnel`,`tailscale-https`,`tailscale`,`lan`,`virtual`]),url:D().min(1)}).strict(),OD=fu(`status`,[j({status:P(`not-installed`)}),j({status:P(`not-running`)}),j({status:P(`not-logged-in`)}),j({status:P(`https-disabled`)}),j({status:P(`not-serving`),command:D()}),j({status:P(`occupied`),target:D()}),j({status:P(`serving`),url:D(),funnel:k()}),j({status:P(`error`),message:D()})]);j({state:OD,error:D().optional()}).strict();let kD=fu(`status`,[j({status:P(`on`)}),j({status:P(`off`)}),j({status:P(`invalid`),reason:D()})]),AD=j({lan:k(),autostart:kD}).strict(),jD=j({expiresAt:D().optional(),issuing:k(),failure:j({detail:D().optional(),retryAt:D(),paused:k()}).optional()}),MD=fu(`status`,[j({status:P(`off`),reason:N([`invite`,`name-taken`,`banned`]).optional()}),j({status:P(`connecting`),reason:N([`full`,`unreachable`]).optional()}),j({status:P(`connected`),url:D(),certificate:jD}),j({status:P(`missing-certificate`),url:D(),certificate:jD}),j({status:P(`stopped`),reason:N([`replaced`,`rejected`,`unsupported-version`])})]);D().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()),D().regex(/^(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)?$/);let ND=N([`official`,`self-hosted`]);j({secret:D().min(1),lastUsedAt:O().nullable(),networkUrls:A(DD),directCandidates:A(DD).optional(),tailscale:OD,background:AD.optional(),relay:j({state:MD,enabled:k(),kind:ND,officialHost:D(),customHost:D().optional(),officialHostname:D().optional(),customHostname:D().optional(),quotaUntil:D().optional()}).strict().optional()}).strict();let PD=M({threadId:D().min(1).max(1024),view:N([`result`,`messages`]),from:O().int().min(1).max(2**53-1).optional(),to:O().int().min(1).max(2**53-1).optional()}),FD=/^[a-zA-Z0-9_-]{1,64}$/u,ID=D().regex(FD),LD=D().regex(FD),RD=D().regex(/^remote-peer:[a-zA-Z0-9_-]{1,64}$/u),zD=N([`relay`,`tailscale`,`lan`,`custom`]),BD=[`blue`,`purple`,`cyan`,`green`,`amber`,`rose`,`slate`],VD=N(BD);new Set(BD);let HD=N([`connected`,`connecting`,`auth-error`,`offline`,`disabled`]),UD=j({peerId:ID,hostId:RD,nodeId:LD.optional(),name:D().min(1).max(120),color:VD.optional(),origin:D().min(1).max(2048),transportKind:zD,encrypted:k(),enabled:k(),state:HD,supportsPeerPairing:k().optional(),pairedBack:k().optional(),linkedPeerIds:A(ID).max(128).optional(),latencyMs:O().int().nonnegative().optional(),version:D().max(128).optional(),platform:D().max(64).optional(),hostname:D().max(255).optional(),homeDir:D().max(4096).optional(),lastError:D().max(1e3).optional(),projectCount:O().int().nonnegative(),createdAt:D(),updatedAt:D()});j({localPlatform:D().max(64).optional(),peers:A(UD)}),j({connectionUrl:D().min(1).max(4096).optional(),origin:D().min(1).max(2048).optional(),token:D().min(1).max(2048).optional(),name:D().trim().min(1).max(120).optional(),color:VD.optional(),pairBack:k().optional(),meshPeerIds:A(ID).max(64).optional(),selfOrigin:D().min(1).max(2048).optional()}).refine(e=>!!e.connectionUrl||!!e.origin&&!!e.token,`Provide either connectionUrl or both origin and token`),M({origin:D().min(1).max(2048),token:D().min(1).max(2048),name:D().trim().min(1).max(120).optional(),color:VD.optional(),expectedNodeId:LD.optional()}),j({status:N([`added`,`updated`,`existing`]),peerId:ID,hostId:RD,nodeId:LD.optional()});let WD=N([`added`,`updated`,`existing`,`failed`,`skipped`]);j({results:A(j({targetPeerId:ID,targetName:D().min(1).max(120),introducedHost:uu([P(`local`),ID]),introducedName:D().min(1).max(120),status:WD,error:D().max(1e3).optional()}))}),j({peerIds:A(ID).max(64).optional(),includeSelf:k().optional(),includeMesh:k().optional(),selfOrigin:D().min(1).max(2048).optional()}),j({peerId:ID,name:D().trim().min(1).max(120).optional(),color:VD.nullable().optional(),connectionUrl:D().min(1).max(4096).optional(),origin:D().min(1).max(2048).optional(),token:D().min(1).max(2048).optional(),enabled:k().optional()}),j({peerId:ID}),j({removed:k()}),j({peerId:ID.optional(),connectionUrl:D().min(1).max(4096).optional(),origin:D().min(1).max(2048).optional(),token:D().min(1).max(2048).optional()}).refine(e=>!!e.peerId||!!e.connectionUrl||!!e.origin&&!!e.token,`Provide peerId, connectionUrl, or both origin and token`);let GD=j({id:D().min(1).max(1024),name:D().min(1).max(512),path:D().min(1).max(8192)});j({ok:k(),nodeId:LD.optional(),supportsPeerPairing:k().optional(),pairedBack:k().optional(),latencyMs:O().int().nonnegative().optional(),origin:D().max(2048).optional(),transportKind:zD.optional(),encrypted:k().optional(),version:D().max(128).optional(),platform:D().max(64).optional(),hostname:D().max(255).optional(),homeDir:D().max(4096).optional(),projectCount:O().int().nonnegative().optional(),projects:A(GD).optional(),error:D().max(1e3).optional()});let KD=j({id:D().min(1).max(1024),name:D().min(1).max(512),path:D().min(1).max(8192),threadIds:A(D().min(1).max(1024))}),qD=j({attachments:P(1).optional(),workspaceFiles:P(1).optional(),officePreview:P(1).optional(),delegation:P(1).optional(),peerPairing:P(1).optional()}),JD=j({version:D().max(128),platform:D().max(64),hostname:D().max(255),homeDir:D().max(4096).optional(),epoch:D().min(1).max(256),nodeId:LD.optional(),peerNodes:vu(RD,LD).refine(e=>Object.keys(e).length<=128).optional(),projects:A(KD),capabilities:qD.optional()});M({threadId:D().min(1).max(1024),scope:D().regex(/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/u).optional(),requestId:D().min(1).max(256).optional(),mode:N([`queue`,`steer`]).optional(),expectedTurnId:D().min(1).max(1024).nullable().optional(),content:A(fu(`type`,[M({type:P(`text`),text:D()}),M({type:P(`file`),receiptId:D().min(1).max(128)})])).min(1).max(64)});let YD=j({ok:P(!1),error:j({code:D(),message:D(),details:vu(D(),iu()).optional()})});uu([j({ok:P(!0),value:j({receiptId:D().min(1),file:j({attachmentId:D(),name:D(),bytes:O().int().nonnegative()})})}),YD]),uu([j({ok:P(!0),value:j({accepted:P(!0)})}),YD]);let XD=j({name:D().min(1).max(512),path:D().min(1).max(8192),kind:P(`directory`)});j({peerId:ID,path:D().min(1).max(8192).optional()}),j({path:D().min(1).max(8192),parentPath:D().min(1).max(8192).nullable(),homeDir:D().min(1).max(8192).optional(),entries:A(XD)}),j({peerId:ID,parentPath:D().min(1).max(8192),name:D().min(1).max(255).refine(e=>e.trim().length>0,`Directory name cannot be blank`)}),j({path:D().min(1).max(8192),name:D().min(1).max(255)}),j({peerId:ID,path:D().min(1).max(8192),title:D().trim().min(1).max(255).optional()}),j({peerId:ID,workspaceId:D().min(1).max(1024),title:D().trim().min(1).max(255)}),j({peerId:ID,workspaceId:D().min(1).max(1024)}),j({workspaceId:D().min(1).max(1024).optional(),manifest:JD}),j({sessionHostId:D().min(1).max(128).optional()}),j({hosts:A(j({hostId:uu([P(`local`),RD]),name:D().min(1).max(120),isLocal:k().optional(),color:VD.optional(),hostname:D().max(255).optional()}))}),j({hostId:uu([P(`local`),RD])}),j({harnesses:A(j({id:D().regex(/^[a-z0-9][a-z0-9-]*$/u),name:D().min(1).max(120)}))});let ZD=N([`listHarnesses`,`inspect`,`start`,`send`,`cancel`,`read`,`answer`,`list`]);M({operation:ZD,hopCount:O().int().min(0).max(16),sourceId:ID.optional(),input:WC});let QD=M({code:D().min(1).max(128),message:D().max(4096),details:WC.optional()});uu([M({ok:P(!0),value:UC}),M({ok:P(!1),error:QD})]);let $D=M({id:D().min(1).max(1024),name:D().min(1).max(512),path:D().min(1).max(8192)});M({hosts:A(M({hostId:RD,nodeId:LD.optional(),displayName:D().min(1).max(120),online:k(),state:HD,delegation:k(),projects:A($D),platform:D().max(64).optional(),hostname:D().max(255).optional(),homeDir:D().max(4096).optional()}))}),M({version:P(1),instanceId:D().min(1).max(128),pid:O().int().positive(),endpoint:D().min(1).max(256),token:D().regex(/^[0-9a-f]{64}$/u),startedAt:O().int().nonnegative()}),uu([M({operation:P(`hosts`)}),M({operation:ZD,hostId:RD,hopCount:O().int().min(0).max(16),timeoutMs:O().int().min(1).max(12e4).optional(),input:WC})]);let eO=j({id:D().min(1).max(256),harnessId:D().min(1),label:D().min(1).max(512),provider:N([`openai-codex`,`xai`])}).strict(),tO=D().regex(/^[a-z][a-z0-9-]{0,47}$/),nO=j({name:tO,source:eO,importedAt:D()}).strict(),rO=fu(`action`,[j({action:P(`list`)}).strict(),j({action:P(`import`),sourceId:D().min(1).max(256),name:tO,confirmed:P(!0)}).strict(),j({action:P(`reimport`),sourceId:D().min(1).max(256),name:tO,confirmed:P(!0)}).strict(),j({action:P(`remove`),name:tO,confirmed:P(!0)}).strict()]),iO=j({provider:D().min(1).max(128),type:N([`oauth`,`api_key`,`unknown`]),label:D().min(1).max(512).optional(),vendor:N([`openai-codex`,`xai`]).optional()}).strict();j({sources:A(eO),targets:A(j({harnessId:D(),providers:A(N([`openai-codex`,`xai`])),imports:A(nO),others:A(iO).default([])}).strict())}).strict(),j({targetHarnessId:D().min(1).max(128).optional(),request:rO}).strict(),j({events:k()});let aO=A(M({agent:D().min(1).max(128),section:N([`main`,`more`,`auto`])})).max(256).refine(e=>new Set(e.map(e=>e.agent)).size===e.length,`Duplicate Harness IDs`);M({entries:aO.nullable()}),M({}),M({entries:aO,initializeOnly:k().optional()});let oO=M({enabled:k(),timeoutMinutes:O().int().min(5).max(1440)});Object.freeze({enabled:!0,timeoutMinutes:10});let sO=D().regex(/^external$/u),cO=ZC.transform(e=>String(e)),lO=M({model:Rw.optional(),thinkingOptionId:$C.optional(),permissionModeId:tw.optional()}).refine(e=>!!(e.model||e.thinkingOptionId||e.permissionModeId),`A default configuration must contain a preference`);fu(`mode`,[M({mode:P(`global`)}),M({mode:P(`last`)}),M({mode:P(`manual`),harnessId:ZC})]);let uO=M({lastHarness:ZC.optional(),byHarness:vu(cO,lO)}),dO=M({model:Rw.optional(),thinkingOptionId:$C.optional()}).refine(e=>!!(e.model||e.thinkingOptionId),`A delegation default must contain a Model or Thinking option`),fO=M({byHarness:vu(cO,dO)}),pO=D().min(1).max(1024),mO=M({idleRelease:oO.optional(),favorites:vu(cO,A(pO).max(2048)).default({}),newThread:uO.optional(),delegation:fO.optional()});M({scope:sO,revision:O().int().nonnegative(),values:mO}),M({scope:sO.default(`external`)});let hO=fu(`kind`,[M({kind:P(`idleRelease`),value:oO}),M({kind:P(`favorite`),harnessId:ZC,modelId:pO,enabled:k()}),M({kind:P(`favorites`),harnessId:ZC,modelIds:A(pO).max(2048)}),M({kind:P(`newThread`),lastHarness:ZC.optional(),harnessId:ZC.optional(),configuration:lO.optional()}),M({kind:P(`delegation`),harnessId:ZC,configuration:dO.nullable()})]);M({scope:sO.default(`external`),operations:A(hO).min(1).max(256),initializeOnly:k().optional(),expectedRevision:O().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`})}),M({version:P(1),revision:O().int().nonnegative(),scopes:vu(sO,mO)});let gO=O().finite().nonnegative(),_O=M({input:gO,output:gO,cacheRead:gO.optional(),cacheWrite:gO.optional(),cacheWrite1h:gO.optional()}),vO=D().max(512).refine(e=>e.trim()===e&&e.length>0,`Model ID is required`);M({path:D(),entries:A(M({key:D(),price:_O})),error:D().nullable()}),M({}),M({key:vO,price:_O.nullable(),previousKey:vO.optional()}),M({model:vO});let yO=M({official:k().optional(),canonicalModelId:D().min(1).optional(),provider:D().min(1).max(512),model:D().min(1).max(512),price:_O});M({price:_O.nullable(),suggestions:A(yO).max(6).optional()});let bO=[`today`,`7d`,`30d`,`90d`,`all`],xO=O().int().min(0).max(2**53-1),SO=D().regex(/^\d{4}-\d{2}-\d{2}$/u),CO=D().min(1).max(128),wO=D().min(1).max(512),TO=D().min(1).max(4096);M({range:N(bO),timeZone:D().min(1).max(128).refine(e=>{try{return new Intl.DateTimeFormat(`en`,{timeZone:e}),!0}catch{return!1}},`Unsupported usage statistics timezone`).optional(),harness:CO.optional(),model:wO.nullable().optional(),project:TO.nullable().optional(),date:SO.optional()});let EO=M({requests:xO,inputTokens:xO,cachedInputTokens:xO,cacheWriteInputTokens:xO,cacheKnownInputTokens:xO,cacheHitCachedInputTokens:xO,cacheHitInputTokens:xO,outputTokens:xO,reasoningOutputTokens:xO,costUsd:O().finite().min(0),unpricedRequests:xO,unmeteredRequests:xO}),DO=EO.shape,OO=M({harness:CO,sessionId:D().min(1).max(512),project:TO.nullable(),title:D().min(1).max(200).optional(),models:A(wO).max(16),firstAtMs:xO,lastAtMs:xO,...DO});M({range:N(bO),from:SO.nullable(),to:SO,filters:M({harness:CO.nullable(),model:wO.nullable(),unknownModel:k(),project:TO.nullable(),unknownProject:k(),date:SO.nullable()}),reading:M({complete:k(),sources:xO,read:xO}),failures:A(M({harness:CO,message:D().max(2048)})).max(256),options:M({harnesses:A(CO).max(256),models:A(wO.nullable()).max(4096),projects:A(TO.nullable()).max(4096)}),modelLabels:A(M({harness:CO,model:wO,label:wO})).max(4096).optional(),credits:A(M({harness:CO,model:wO.nullable(),credits:O().finite().min(0),reportedRequests:xO,requests:xO})).max(4096).optional(),totals:EO,daily:A(M({date:SO,harness:CO,...DO})).max(2e5),hourly:A(M({weekday:O().int().min(0).max(6),hour:O().int().min(0).max(23),...DO})).max(168),byHarness:A(M({harness:CO,...DO})).max(256),byModel:A(M({model:wO.nullable(),...DO,harnessPricedRequests:xO})).max(4096),byProject:A(M({project:TO.nullable(),...DO})).max(4096),sessions:A(OO).max(100),recentSessions:A(OO).max(100).optional()}),j({threadId:Y}),j({discarded:k()});let kO=fu(`type`,[j({id:D().min(1),type:P(`choice`),prompt:D(),options:A(j({value:D().min(1),label:D(),description:D().optional()})).min(1),multiple:k(),allowOther:k(),optional:k()}),j({id:D().min(1),type:P(`text`),prompt:D(),multiline:k(),secret:P(!1),optional:k(),placeholder:D().optional(),prefill:D().optional()})]),AO=j({interactionId:D().min(1),turnId:D().min(1),title:D().optional(),questions:A(kO).min(1)}).refine(({questions:e})=>e.some(e=>e.type===`choice`&&e.multiple),{message:`Shared cards require at least one multi-select question`});M({threadId:D().min(1)}),j({questions:A(AO)}),M({threadId:D().min(1),turnId:D().min(1),interactionId:D().min(1),answers:vu(D(),A(D())),cancelled:k().default(!1)}),j({accepted:P(!0)});let jO=j({path:D(),oldText:D().nullable(),newText:D()});j({sessionId:D().min(1),turn:O().int().nonnegative(),path:D().min(1).optional()}),j({diffs:A(jO)}),M({}),M({}),j({reference:j({sessionId:D().min(1),epoch:D().min(1),turn:O().int().nonnegative(),seq:O().int().nonnegative(),callId:D().min(1),part:O().int().nonnegative(),version:D().min(1)}),length:O().int().nonnegative(),bytes:O().int().nonnegative()}),M({}),M({}),M({title:D().trim().min(1).max(200),type:N([`info`,`warning`,`danger`]),body:D().trim().min(1).max(16384)}),M({}),M({url:D().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/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.codexhost/update/macos-signing/status.codexhost/update/macos-signing/setup.codexhost/update/macos-signing/remove`.split(`.`));let MO=N([`idle`,`running`,`busy`,`closing`,`failed`,`blocked`]),NO=N([`none`,`disabled`,`timeout`,`operation`,`background`,`identity`,`persistence`,`closeFailed`]);M({threadId:D(),title:D(),harnessId:D(),state:MO,reason:NO,inactiveMs:O().nonnegative()}),M({threadId:Y,turnId:QC});let PO=j({email:D().trim().min(1).max(320).optional(),label:D().trim().min(1).max(256).optional(),plan:D().trim().min(1).max(128).optional(),credits:Nw.optional(),balance:Pw.optional()}).strict();function FO(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 IO=FO(PO),LO={harnessId:ZC,harnessName:D().trim().min(1).max(128)},RO=j(LO).strict();j({}).strict(),j({sources:A(RO).max(128)}).strict(),j({harnessId:ZC,refresh:k().optional()}).strict(),j({...LO,account:IO.nullable(),accounts:A(IO).max(8).optional()}).strict(),j({refresh:k().optional()}).strict(),j({accounts:A(FO(PO.extend(LO))).max(128)}).strict(),j({harnessId:eT,model:Rw.optional(),thinkingOptionId:$C.optional(),permissionModeId:tw.optional(),prewarm:P(!0).optional()}).strict();let zO=D().trim().min(1).max(4096).refine(e=>!/[\u0000\r\n]/u.test(e),`Invalid entrypoint path`);j({harnessId:eT}).strict().extend({path:zO.nullable()}),j({path:zO.nullable(),restartRequired:k()}).strict(),j({harnessId:ZC,action:N([`check`,`update`,`install`]),confirmedVersion:D().min(1).max(128).optional()}).strict().refine(({action:e,confirmedVersion:t})=>e===`update`||t===void 0);let BO=j({currentVersion:D().min(1).max(128),latestVersion:D().min(1).max(128),updateAvailable:k(),canUpdate:k(),latestVerifiedVersion:D().min(1).max(128).optional(),confirmationRequired:P(!0).optional(),versionKind:N([`cli`,`application`]).optional(),manualUpdateUrl:Fl().max(2048).refine(e=>/^https:\/\/[^/?#@]+(?:[/?#]|$)/iu.test(e),`Manual updates require a credential-free HTTPS URL`).optional(),message:D().max(2048).optional(),messageCode:D().min(1).max(128).optional(),notice:YC.optional(),latestVersionKind:N([`unknown`,`tracking-branch`]).optional()}).strict();j({taskId:D().uuid()}).strict(),fu(`status`,[j({taskId:D().uuid(),status:P(`running`)}).strict(),j({taskId:D().uuid(),status:P(`succeeded`),result:BO}).strict(),j({taskId:D().uuid(),status:P(`failed`),error:j({code:O().int(),message:D().min(1).max(2048)}).strict()}).strict()]);let VO=D().min(1).max(256).regex(/^[A-Za-z0-9._~-]+$/u),HO=D().trim().min(1),UO=N([`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`]),WO=j({accountId:VO,label:HO.max(256),email:D().email().max(320).optional(),planType:UO.optional()}).strict(),GO=N([`ready`,`unavailable`]);j({version:P(2),currentAccountId:VO.nullable(),phase:GO,revision:O().int().nonnegative(),instanceId:HO.max(1024).optional(),accounts:A(WO).max(1)}).strict(),j({accountId:VO,refresh:k().optional()}).strict(),j({accountId:VO,usage:Dw.nullable(),accountCredits:Nw.optional(),freshness:N([`live`,`cached`]),observedAt:D().datetime().nullable()}).strict();let KO=1e3,qO=D().refine(e=>e.trim().length>0,`Value must not be empty or whitespace`).refine(e=>!e.includes(`\0`),`Value must not contain NUL`),JO=qO.max(1024),YO=j({nativeSessionId:JO,title:qO.max(4096).nullable(),updatedAt:O().int().nonnegative().max(864e13),cwd:qO.max(16384),running:k().nullable()}).strict();j({}).strict(),j({harnesses:A(j({harnessId:eT,name:qO.max(128)}).strict()).max(128)}).strict(),j({harnessId:eT,query:D().trim().max(4096).refine(e=>!e.includes(`\0`)).optional(),offset:O().int().nonnegative().safe().optional(),limit:O().int().min(1).max(KO).optional()}).strict(),j({candidates:A(YO).max(KO),total:O().int().nonnegative().safe()}).strict(),j({harnessId:eT,nativeSessionId:JO}).strict(),j({threadId:qO.max(1024).pipe(Y)}).strict();let XO=D().refine(e=>e.trim().length>0,`Value must not be empty or whitespace`).refine(e=>!e.includes(`\0`),`Value must not contain NUL`),ZO=JO,QO=YO;j({}).strict(),j({candidates:A(QO).max(1e3)}).strict(),j({nativeSessionId:ZO}).strict(),j({threadId:XO.max(1024).pipe(Y)}).strict(),j({threadId:Y,lastTurnId:QC}).strict(),j({threadId:Y}).strict();let $O=D().trim().min(1).max(128).regex(/^[A-Za-z0-9._:-]+$/u).brand();j({commands:A(j({id:$O,invocation:D().min(1).max(128),label:D().trim().min(1).max(128),description:D().trim().min(1).max(512).optional(),localizations:JC.optional(),argumentMode:N([`none`,`text`]),kind:N([`command`,`skill`]).optional()}).strict()),warnings:A(D().min(1)).optional(),source:N([`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)}),j({harnessId:ZC,cwd:D().min(1).optional()}).strict(),j({threadId:Y}).strict(),j({threadId:Y,commandId:$O,turnId:QC.optional(),arguments:WC.optional()}).strict(),j({accepted:P(!0),turnId:QC.optional()}).strict();let ek=P(`2.0`).optional(),tk=ou().optional(),nk=D().min(1),rk=uu([D(),O().int()]),ik=j({code:O().int(),message:D(),data:UC.optional()}).catchall(UC).superRefine(RC([`data`]));uu([j({jsonrpc:ek,id:rk,method:nk,params:UC.optional(),result:tk,error:tk}).catchall(UC).superRefine(RC([`jsonrpc`,`params`,`result`,`error`])),j({jsonrpc:ek,id:tk,method:nk,params:UC.optional(),result:tk,error:tk}).catchall(UC).superRefine(RC([`jsonrpc`,`id`,`params`,`result`,`error`])),j({jsonrpc:ek,id:rk,method:tk,params:tk,result:UC,error:tk}).catchall(UC).superRefine(RC([`jsonrpc`,`method`,`params`,`error`])),j({jsonrpc:ek,id:rk,method:tk,params:tk,result:tk,error:ik}).catchall(UC).superRefine(RC([`jsonrpc`,`method`,`params`,`result`]))]);let ak=D().refine(e=>e.trim().length>0,{message:`Native identifier must not be empty or whitespace`});M({harnessId:ZC,nativeSessionId:ak,locator:UC.optional(),formatVersion:P(1)}).superRefine(RC([`locator`])),M({harnessId:ZC,nativeSessionId:ak,nativeTurnKey:ak,formatVersion:P(1)}),M({harnessId:ZC,nativeSessionId:ak,checkpointId:ak,locator:UC.optional(),formatVersion:P(1)}).superRefine(RC([`locator`]));let ok=D().regex(/^\d+\.\d+\.\d+(?:-[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?(?:\+[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/u),sk=N([`npm`,`windows-installer`,`macos-dmg`,`linux-archive`]),ck=N([`prepared`,`downloading`,`waiting-for-exit`,`installing`,`restarting`,`succeeded`,`failed`]),lk=M({completed:O().int().nonnegative(),total:O().int().positive()}).refine(e=>e.completed<=e.total,{path:[`completed`],message:`completed must not exceed total`}),uk=M({version:ok,installation:sk,phase:ck,updatedAt:O().int().nonnegative(),downloadedBytes:O().int().nonnegative().optional(),totalBytes:O().int().positive().optional(),npmDownload:lk.optional(),error:D().min(1).max(500).nullable(),serviceStopOutput:D().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`})});M({});let dk=D().max(300).regex(/^https:\/\/github\.com\/BytePioneer-AI\/codex-host\/releases\/tag\/v[0-9A-Za-z.+-]+$/u,`release notes URL must identify a codexhost GitHub Release`),fk=N([`idle`,`downloading`,`ready`,`failed`]),pk=M({downloadedBytes:O().int().nonnegative(),totalBytes:O().int().positive()}).refine(e=>e.downloadedBytes<=e.totalBytes,{path:[`downloadedBytes`],message:`downloadedBytes must not exceed totalBytes`});j({currentVersion:ok,installation:sk.nullable(),latestVersion:ok.nullable(),updateAvailable:k(),installationAvailable:k(),releaseNotes:D().min(1).max(2e4).nullable(),releaseNotesUrl:dk.nullable(),status:uk.nullable(),error:D().min(1).max(500).nullable(),stagedVersion:ok.nullable().optional(),backgroundPhase:fk.optional(),backgroundDownload:pk.nullable().optional(),backgroundError:D().min(1).max(500).nullable().optional(),runningTaskCount:O().int().nonnegative().optional()}),M({status:uk}),M({status:uk.nullable()}),M({supported:k(),enabled:k(),certificatePresent:k(),appSignedWithLocalCert:k(),appPath:D().min(1).nullable(),certificateName:D().min(1),certificateSha1:D().regex(/^[0-9A-Fa-f]{40}$/u).nullable()});let mk=M({icon:D().min(1).max(16).optional(),title:D().min(1).max(120),body:D().min(1).max(1200),contributors:A(D().min(1).max(39)).max(30)}),hk=M({summary:D().min(1).max(600).optional(),themes:A(mk).min(1).max(12)}),gk=M({version:ok,publishedAt:Yu(),url:D().max(300).regex(/^https:\/\/github\.com\/BytePioneer-AI\/codex-host\/releases\/tag\/v[0-9A-Za-z.+-]+$/u),zh:hk.nullable(),en:hk.nullable()}).refine(e=>e.zh!==null||e.en!==null,{message:`an announcement needs at least one language`});M({manual:k().optional()}),M({announcement:gk.nullable(),unread:k()}),M({version:ok}),RegExp(String.raw`^- \[([^\]\n]+)\]\(thread://([^\s()<>"?#/]+)\): `+`(${[`completed`,`failed`,`interrupted`,`needsInput`,`timedOut`,`unreadable`,`notFound`].join(`|`)})(?:\. (.+))?$`,`u`);let _k=`<response-annotations>`,vk=`</response-annotations>`,yk=/^\s*## My request(?: for Codex)?:[ \t]*(?:\r?\n|$)/u;function bk(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${_k}\n${JSON.stringify(t)}\n${vk}\n`}function xk(e,t){let n=bk(e);return n===``?t:`${n}\n## My request:\n${t}\n`}function Sk(e){let t=e.trimStart().startsWith(`# Response annotations:`)?0:e.length,n=e.indexOf(`\n${_k}\n`,t);if(n<0)return;let r=n+1+22+1,i=e.indexOf(`\n${vk}`,r);if(!(i<0))return{json:e.slice(r,i),closeEnd:i+1+23}}function Ck(e){let t=Sk(e);if(t===void 0)return{annotations:[],body:e};let n=Tk(t.json);if(n.length===0)return{annotations:[],body:e};let r=e.slice(t.closeEnd),i=yk.exec(r);if(i===null)return{annotations:[],body:e};let a=r.slice(i[0].length);return{annotations:n,body:i[0].endsWith(`\r
147
147
  `)&&a.endsWith(`\r
148
148
  `)?a.slice(0,-2):a.endsWith(`
149
- `)?a.slice(0,-1):a}}function OO(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function kO(e){if(e===``)return[];let t;try{t=JSON.parse(e)}catch{return[]}if(!Array.isArray(t)||t.length===0)return[];let n=[];for(let e of t){if(!OO(e))return[];let{text:t,annotation:r}=e;if(typeof t!=`string`||t.length===0||r!==void 0&&(typeof r!=`string`||r.length===0))return[];n.push({text:t,...r===void 0?{}:{annotation:r}})}return n}let AO=N([`idle`,`installing`,`restarting`,`succeeded`,`failed`]);j({runningVersion:D().nullable(),installedVersion:D().nullable(),restartRequired:k(),remote:k(),updateSupported:k(),update:j({phase:AO,targetVersion:D().nullable(),error:D().nullable()})});let jO=j({version:D().regex(/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/u)}).strict();j({hostname:D().min(1).max(1024).refine(e=>!e.startsWith(`-`)&&!/\s/u.test(e)),port:O().int().min(1).max(65535).nullable(),identity:D().max(4096).nullable(),action:N([`inspect`,`install`,`update`,`repair`,`uninstall`]),uninstallPackage:k().optional(),version:D().regex(/^\d+\.\d+\.\d+$/u).nullable()}).strict(),j({state:N([`installed`,`not-installed`])}).strict();let X=D().min(1).max(1024),MO={hostId:X.regex(/^(?:remote-(?:ssh(?:-|:)|control:)|remote-peer:[a-zA-Z0-9_-]{1,64}$)/u)},NO={...MO,threadId:X},PO=D().min(1).max(8e3),FO={text:PO,requestId:X};au(`accepted`,[j({accepted:P(!0),startQueuedItemId:X.optional()}),j({accepted:P(!1),code:N([`remote/queue-unavailable`,`remote/steer-unavailable`,`remote/turn-changed`,`remote/send-rejected`,`session/queue-item-not-found`,`session/queue-item-starting`]),message:D()})]),au(`available`,[j({available:P(!1)}),j({available:P(!0),items:A(j({id:X,clientUserMessageId:X,preview:D().max(801)})).max(100)})]);let IO=au(`kind`,[M({kind:P(`hosts`)}),M({kind:P(`create`),...MO,cwd:D().min(1).max(8192),epoch:X}),M({kind:P(`projectHarnesses`),...MO,epoch:X}),M({kind:P(`inspectHarness`),...MO,epoch:X,cwd:D().min(1).max(8192),harnessId:X}),M({kind:P(`startSelected`),...MO,epoch:X,cwd:D().min(1).max(8192),harnessId:X,model:D().min(1).max(4096),serviceTier:N([`priority`,`ultrafast`]).optional(),reasoningEffort:X.optional()}),M({kind:P(`status`),...NO}),M({kind:P(`list`),...MO,cursor:D().nullable(),archived:k(),includeLoaded:P(!0).optional()}),M({kind:P(`read`),...NO,page:M({cursor:D().min(1).max(8192).nullable(),epoch:X.optional(),sortDirection:N([`asc`,`desc`]).optional(),limit:O().int().min(1).max(20).optional()}).refine(e=>e.cursor===null||e.epoch!==void 0,{message:`A history continuation requires its connection epoch`}).optional()}),M({kind:P(`usage`),...NO,epoch:X}),M({kind:P(`configure`),...NO,epoch:X,modelId:X.optional(),serviceTier:dw.optional(),thinkingOptionId:X.optional(),permissionModeId:X.optional()}).refine(e=>[e.modelId,e.thinkingOptionId,e.permissionModeId].filter(e=>e!==void 0).length===1,`Select exactly one remote setting`).refine(e=>e.serviceTier===void 0||e.modelId!==void 0,{message:`A service tier requires a Model ID`}),M({kind:P(`prompt`),...NO,epoch:X,text:PO,requestId:X.optional()}),M({kind:P(`queue`),...NO,epoch:X}),M({kind:P(`delivery`),...NO,epoch:X,action:au(`kind`,[M({kind:P(`enqueue`),...FO}),M({kind:P(`steer`),...FO,turnId:X}),M({kind:P(`remove`),itemId:X}),M({kind:P(`start`),itemId:X,onlyIfHead:P(!0).optional()}),M({kind:P(`sendNow`),itemId:X})])}),M({kind:P(`interrupt`),...NO,epoch:X,turnId:X}),M({kind:P(`rename`),...NO,epoch:X,name:D().min(1).max(512)}),M({kind:P(`archive`),...NO,epoch:X,archived:k()}),M({kind:P(`respond`),...NO,epoch:X,requestId:ru([X,O().int()]),result:du(D(),Zl())})]),LO=D().min(1).max(1024),RO=j({hostId:LO,displayName:D().min(1).max(1024),source:N([`codex-managed`,`discovered`]),sshAlias:D().max(1024).nullable(),sshHost:D().min(1).max(1024),sshPort:O().int().min(1).max(65535).nullable(),identity:D().max(4096).nullable(),autoConnect:k(),connectionAnalyticsId:D().max(1024).optional()}),zO=M({displayName:D().min(1).max(1024),hostname:D().min(1).max(1024),sshPort:O().int().min(1).max(65535).nullable(),identity:D().max(4096).nullable()});au(`action`,[M({action:P(`session`),operation:IO}),M({action:P(`list`)}),M({action:P(`catalog`)}),M({action:P(`read-thread`),hostId:LO.refine(e=>e!==`local`),input:RE}),M({action:P(`save`),draft:zO,previous:RO.nullable()}),M({action:P(`remove`),previous:RO}),M({action:P(`connect`),hostId:LO,enabled:k()}),M({action:P(`state`),hostId:LO}),M({action:P(`runtime`),hostId:LO}),M({action:P(`update`),hostId:LO.refine(e=>e!==`local`),version:jO.shape.version})]),ru([M({result:PC}),M({error:M({code:O().int(),message:D()})})]),M({prompt:D().trim().min(1).max(2e3),cwd:D().max(4096).nullable()}),D().trim().min(1).max(60).nullable();let BO=D().max(214).regex(/^(?:@[a-z0-9][a-z0-9._-]*\/)?[a-z0-9][a-z0-9._-]*$/u),VO=ru([D(),j({en:D()}).catchall(D())]),HO=j({title:VO.optional(),description:VO.optional(),icon:D().max(349592).regex(/^data:image\/(?:svg\+xml|png|jpeg|webp);base64,[A-Za-z0-9+/]*={0,2}$/u).optional(),error:D().optional()});j({extensions:A(j({id:BO,name:D().min(1).max(214),version:D().min(1).max(128),format:P(`dsh`),supportedTargets:lu([P(`web`)]),enabledTargets:A(P(`web`)).max(1),source:D().min(1).max(4096),projectUrl:D().max(4096).url({protocol:/^https?$/u}).optional(),installedAt:D(),meta:HO.optional(),loadError:D().optional()})),loadedIds:A(BO),safeMode:k(),storeError:D().optional()});let UO=D().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}/`);j({spec:D().trim().min(1).max(4096),registry:UO.optional()}).strict(),j({id:BO,enabled:k()}).strict(),j({id:BO}).strict(),P(1);function WO(e){return e.registerNodeTransform(sh,e=>{let t=AE(e.getTextContent())[0];t&&e.splitText(t.start,t.end)[t.start===0?0:1]?.replace(new pC({source:`codexhost-skill`,ref:t.text,label:t.name,appearance:`skill`,clipboardText:t.text}))})}let GO=`color: var(--dsw-alias-state-business-primary)`;function KO(){let e=X_().getFirstChild();if(!U(e))return null;let t=e.getFirstChild();return z(t)?t:null}function qO(e,t){return e.registerNodeTransform(sh,e=>{let n=KO();if(n===null||e.getKey()!==n.getKey()){e.getStyle()===GO&&e.setStyle(``);return}let r=e.getTextContent(),i=t(),a=r===i?.trimEnd()?r:i;if(a===null||!r.startsWith(a))e.getStyle()===GO&&e.setStyle(``);else if(r.length>a.length){let[t,n]=e.splitText(a.length);t!==void 0&&t.getStyle()!==GO&&t.setStyle(GO),n?.setStyle(``)}else e.getStyle()!==GO&&e.setStyle(GO)})}function JO(e){e.update(()=>{KO()?.markDirty()})}function YO(){let e=[],t=/* @__PURE__ */ new Map,n=/* @__PURE__ */ new Map,r=/* @__PURE__ */ new Map,i=``,a=``,o=(n,r,o,s)=>{let c={kind:n,node:r,detectStart:i.length,detectLength:o.length,clipboardStart:a.length,clipboardLength:s.length};e.push(c),t.set(r.getKey(),c),i+=o,a+=s},s=e=>{let t=i.length,a=e.getChildren();n.set(e.getKey(),a.map(e=>e.getKey()));for(let e of a)if(hC(e))o(`chip`,e,``,e.getTextContent());else if(z(e)){let t=e.getTextContent();o(`text`,e,t,t)}else i_(e)?o(`linebreak`,e,`
149
+ `)?a.slice(0,-1):a}}function wk(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Tk(e){if(e===``)return[];let t;try{t=JSON.parse(e)}catch{return[]}if(!Array.isArray(t)||t.length===0)return[];let n=[];for(let e of t){if(!wk(e))return[];let{text:t,annotation:r}=e;if(typeof t!=`string`||t.length===0||r!==void 0&&(typeof r!=`string`||r.length===0))return[];n.push({text:t,...r===void 0?{}:{annotation:r}})}return n}let Ek=N([`idle`,`installing`,`restarting`,`succeeded`,`failed`]);j({runningVersion:D().nullable(),installedVersion:D().nullable(),restartRequired:k(),remote:k(),updateSupported:k(),update:j({phase:Ek,targetVersion:D().nullable(),error:D().nullable()})});let Dk=j({version:D().regex(/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/u)}).strict();j({hostname:D().min(1).max(1024).refine(e=>!e.startsWith(`-`)&&!/\s/u.test(e)),port:O().int().min(1).max(65535).nullable(),identity:D().max(4096).nullable(),action:N([`inspect`,`install`,`update`,`repair`,`uninstall`]),uninstallPackage:k().optional(),version:D().regex(/^\d+\.\d+\.\d+$/u).nullable()}).strict(),j({state:N([`installed`,`not-installed`])}).strict();let X=D().min(1).max(1024),Ok={hostId:X.regex(/^(?:remote-(?:ssh(?:-|:)|control:)|remote-peer:[a-zA-Z0-9_-]{1,64}$)/u)},kk={...Ok,threadId:X},Ak=D().min(1).max(8e3),jk={text:Ak,requestId:X};fu(`accepted`,[j({accepted:P(!0),startQueuedItemId:X.optional()}),j({accepted:P(!1),code:N([`remote/queue-unavailable`,`remote/steer-unavailable`,`remote/turn-changed`,`remote/send-rejected`,`session/queue-item-not-found`,`session/queue-item-starting`]),message:D()})]),fu(`available`,[j({available:P(!1)}),j({available:P(!0),items:A(j({id:X,clientUserMessageId:X,preview:D().max(801)})).max(100)})]);let Mk=fu(`kind`,[M({kind:P(`hosts`)}),M({kind:P(`create`),...Ok,cwd:D().min(1).max(8192),epoch:X}),M({kind:P(`projectHarnesses`),...Ok,epoch:X}),M({kind:P(`inspectHarness`),...Ok,epoch:X,cwd:D().min(1).max(8192),harnessId:X}),M({kind:P(`startSelected`),...Ok,epoch:X,cwd:D().min(1).max(8192),harnessId:X,model:D().min(1).max(4096),serviceTier:N([`priority`,`ultrafast`]).optional(),reasoningEffort:X.optional()}),M({kind:P(`status`),...kk}),M({kind:P(`list`),...Ok,cursor:D().nullable(),archived:k(),includeLoaded:P(!0).optional()}),M({kind:P(`read`),...kk,page:M({cursor:D().min(1).max(8192).nullable(),epoch:X.optional(),sortDirection:N([`asc`,`desc`]).optional(),limit:O().int().min(1).max(20).optional()}).refine(e=>e.cursor===null||e.epoch!==void 0,{message:`A history continuation requires its connection epoch`}).optional()}),M({kind:P(`usage`),...kk,epoch:X}),M({kind:P(`configure`),...kk,epoch:X,modelId:X.optional(),serviceTier:Lw.optional(),thinkingOptionId:X.optional(),permissionModeId:X.optional()}).refine(e=>[e.modelId,e.thinkingOptionId,e.permissionModeId].filter(e=>e!==void 0).length===1,`Select exactly one remote setting`).refine(e=>e.serviceTier===void 0||e.modelId!==void 0,{message:`A service tier requires a Model ID`}),M({kind:P(`prompt`),...kk,epoch:X,text:Ak,requestId:X.optional()}),M({kind:P(`queue`),...kk,epoch:X}),M({kind:P(`delivery`),...kk,epoch:X,action:fu(`kind`,[M({kind:P(`enqueue`),...jk}),M({kind:P(`steer`),...jk,turnId:X}),M({kind:P(`remove`),itemId:X}),M({kind:P(`start`),itemId:X,onlyIfHead:P(!0).optional()}),M({kind:P(`sendNow`),itemId:X})])}),M({kind:P(`interrupt`),...kk,epoch:X,turnId:X}),M({kind:P(`rename`),...kk,epoch:X,name:D().min(1).max(512)}),M({kind:P(`archive`),...kk,epoch:X,archived:k()}),M({kind:P(`respond`),...kk,epoch:X,requestId:uu([X,O().int()]),result:vu(D(),iu())})]),Nk=D().min(1).max(1024),Pk=j({hostId:Nk,displayName:D().min(1).max(1024),source:N([`codex-managed`,`discovered`]),sshAlias:D().max(1024).nullable(),sshHost:D().min(1).max(1024),sshPort:O().int().min(1).max(65535).nullable(),identity:D().max(4096).nullable(),autoConnect:k(),connectionAnalyticsId:D().max(1024).optional()}),Fk=M({displayName:D().min(1).max(1024),hostname:D().min(1).max(1024),sshPort:O().int().min(1).max(65535).nullable(),identity:D().max(4096).nullable()});fu(`action`,[M({action:P(`session`),operation:Mk}),M({action:P(`list`)}),M({action:P(`catalog`)}),M({action:P(`read-thread`),hostId:Nk.refine(e=>e!==`local`),input:PD}),M({action:P(`save`),draft:Fk,previous:Pk.nullable()}),M({action:P(`remove`),previous:Pk}),M({action:P(`connect`),hostId:Nk,enabled:k()}),M({action:P(`state`),hostId:Nk}),M({action:P(`runtime`),hostId:Nk}),M({action:P(`update`),hostId:Nk.refine(e=>e!==`local`),version:Dk.shape.version})]),uu([M({result:UC}),M({error:M({code:O().int(),message:D()})})]),M({prompt:D().trim().min(1).max(2e3),cwd:D().max(4096).nullable()}),D().trim().min(1).max(60).nullable();let Ik=D().max(214).regex(/^(?:@[a-z0-9][a-z0-9._-]*\/)?[a-z0-9][a-z0-9._-]*$/u),Lk=uu([D(),j({en:D()}).catchall(D())]),Rk=j({title:Lk.optional(),description:Lk.optional(),icon:D().max(349592).regex(/^data:image\/(?:svg\+xml|png|jpeg|webp);base64,[A-Za-z0-9+/]*={0,2}$/u).optional(),error:D().optional()});j({extensions:A(j({id:Ik,name:D().min(1).max(214),version:D().min(1).max(128),format:P(`dsh`),supportedTargets:gu([P(`web`)]),enabledTargets:A(P(`web`)).max(1),source:D().min(1).max(4096),projectUrl:D().max(4096).url({protocol:/^https?$/u}).optional(),installedAt:D(),meta:Rk.optional(),loadError:D().optional()})),loadedIds:A(Ik),safeMode:k(),storeError:D().optional()});let zk=D().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}/`);j({spec:D().trim().min(1).max(4096),registry:zk.optional()}).strict(),j({id:Ik,enabled:k()}).strict(),j({id:Ik}).strict(),P(1);function Bk(e){return e.registerNodeTransform(gh,e=>{let t=ED(e.getTextContent())[0];t&&e.splitText(t.start,t.end)[t.start===0?0:1]?.replace(new SC({source:`codexhost-skill`,ref:t.text,label:t.name,appearance:`skill`,clipboardText:t.text}))})}let Vk=`color: var(--dsw-alias-state-business-primary)`;function Hk(){let e=av().getFirstChild();if(!U(e))return null;let t=e.getFirstChild();return z(t)?t:null}function Uk(e,t){return e.registerNodeTransform(gh,e=>{let n=Hk();if(n===null||e.getKey()!==n.getKey()){e.getStyle()===Vk&&e.setStyle(``);return}let r=e.getTextContent(),i=t(),a=r===i?.trimEnd()?r:i;if(a===null||!r.startsWith(a))e.getStyle()===Vk&&e.setStyle(``);else if(r.length>a.length){let[t,n]=e.splitText(a.length);t!==void 0&&t.getStyle()!==Vk&&t.setStyle(Vk),n?.setStyle(``)}else e.getStyle()!==Vk&&e.setStyle(Vk)})}function Wk(e){e.update(()=>{Hk()?.markDirty()})}function Gk(){let e=[],t=/* @__PURE__ */ new Map,n=/* @__PURE__ */ new Map,r=/* @__PURE__ */ new Map,i=``,a=``,o=(n,r,o,s)=>{let c={kind:n,node:r,detectStart:i.length,detectLength:o.length,clipboardStart:a.length,clipboardLength:s.length};e.push(c),t.set(r.getKey(),c),i+=o,a+=s},s=e=>{let t=i.length,a=e.getChildren();n.set(e.getKey(),a.map(e=>e.getKey()));for(let e of a)if(wC(e))o(`chip`,e,``,e.getTextContent());else if(z(e)){let t=e.getTextContent();o(`text`,e,t,t)}else p_(e)?o(`linebreak`,e,`
150
150
  `,`
151
151
  `):U(e)&&
152
152
  /* v8 ignore next 4 -- plain-text composition nests no block elements today; the walk stays total for imported states. */
153
- s(e);r.set(e.getKey(),{start:t,end:i.length})},c=X_(),l=c.getChildren();n.set(c.getKey(),l.map(e=>e.getKey()));let u=i.length;return l.forEach((t,n)=>{let r=l[n-1];n>0&&r!==void 0&&(e.push({kind:`gap`,node:null,detectStart:i.length,detectLength:1,clipboardStart:a.length,clipboardLength:1,gapBetween:{before:r.getKey(),after:t.getKey()}}),i+=`
153
+ s(e);r.set(e.getKey(),{start:t,end:i.length})},c=av(),l=c.getChildren();n.set(c.getKey(),l.map(e=>e.getKey()));let u=i.length;return l.forEach((t,n)=>{let r=l[n-1];n>0&&r!==void 0&&(e.push({kind:`gap`,node:null,detectStart:i.length,detectLength:1,clipboardStart:a.length,clipboardLength:1,gapBetween:{before:r.getKey(),after:t.getKey()}}),i+=`
154
154
  `,a+=`
155
- `),U(t)&&s(t)}),r.set(c.getKey(),{start:u,end:i.length}),{segments:e,detectLength:i.length,detectText:i,clipboardText:a,byKey:t,children:n,bounds:r}}function XO(e,t){for(let n of e.segments){let e=n.clipboardStart+n.clipboardLength;if(!(t>e))return t===e||n.kind===`chip`?n.detectStart+n.detectLength:n.detectStart+(t-n.clipboardStart)}return e.detectLength}function ZO(e,t){if(t.type===`text`){let n=e.byKey.get(t.key);return n===void 0?null:n.detectStart+Math.min(t.offset,n.detectLength)}let n=e.children.get(t.key),r=e.bounds.get(t.key);if(n===void 0||r===void 0)return null;if(t.offset>=n.length)return r.end;let i=n[t.offset];if(i===void 0)return r.end;let a=e.byKey.get(i);if(a!==void 0)return a.detectStart;let o=e.bounds.get(i);return o===void 0?null:o.start}function QO(e){let t=YO(),n=[];for(let r of t.segments){if(r.kind!==`chip`||!hC(r.node))continue;let t=r.node;n.push({occurrenceId:e(t.getKey()),source:t.getSource(),ref:t.getReference(),offset:r.clipboardStart,length:r.clipboardLength,label:t.getLabel(),...t.getAppearance()===void 0?{}:{appearance:t.getAppearance()},clipboardText:t.getTextContent(),...t.isInvalid()?{invalid:!0}:{}})}let r=V(),i=null;if(B(r)){let e=ZO(t,r.anchor),n=ZO(t,r.focus);e!==null&&n!==null&&(i={start:Math.min(e,n),end:Math.max(e,n)})}return{detectText:t.detectText,clipboardText:t.clipboardText,occurrences:n,selection:i,caret:i!==null&&i.start===i.end?i.start:null}}function $O(e,t){if(t<0||t>e.detectLength)return null;for(let n of e.segments){if(t>=n.detectStart+n.detectLength)continue;if(n.kind===`text`&&n.node!==null)return{key:n.node.getKey(),offset:t-n.detectStart,type:`text`};if(n.kind===`gap`&&n.gapBetween!==void 0){let t=n.gapBetween.before;return{key:t,offset:e.children.get(t)?.length??0,type:`element`}}
155
+ `),U(t)&&s(t)}),r.set(c.getKey(),{start:u,end:i.length}),{segments:e,detectLength:i.length,detectText:i,clipboardText:a,byKey:t,children:n,bounds:r}}function Kk(e,t){for(let n of e.segments){let e=n.clipboardStart+n.clipboardLength;if(!(t>e))return t===e||n.kind===`chip`?n.detectStart+n.detectLength:n.detectStart+(t-n.clipboardStart)}return e.detectLength}function qk(e,t){if(t.type===`text`){let n=e.byKey.get(t.key);return n===void 0?null:n.detectStart+Math.min(t.offset,n.detectLength)}let n=e.children.get(t.key),r=e.bounds.get(t.key);if(n===void 0||r===void 0)return null;if(t.offset>=n.length)return r.end;let i=n[t.offset];if(i===void 0)return r.end;let a=e.byKey.get(i);if(a!==void 0)return a.detectStart;let o=e.bounds.get(i);return o===void 0?null:o.start}function Jk(e){let t=Gk(),n=[];for(let r of t.segments){if(r.kind!==`chip`||!wC(r.node))continue;let t=r.node;n.push({occurrenceId:e(t.getKey()),source:t.getSource(),ref:t.getReference(),offset:r.clipboardStart,length:r.clipboardLength,label:t.getLabel(),...t.getAppearance()===void 0?{}:{appearance:t.getAppearance()},clipboardText:t.getTextContent(),...t.isInvalid()?{invalid:!0}:{}})}let r=V(),i=null;if(B(r)){let e=qk(t,r.anchor),n=qk(t,r.focus);e!==null&&n!==null&&(i={start:Math.min(e,n),end:Math.max(e,n)})}return{detectText:t.detectText,clipboardText:t.clipboardText,occurrences:n,selection:i,caret:i!==null&&i.start===i.end?i.start:null}}function Yk(e,t){if(t<0||t>e.detectLength)return null;for(let n of e.segments){if(t>=n.detectStart+n.detectLength)continue;if(n.kind===`text`&&n.node!==null)return{key:n.node.getKey(),offset:t-n.detectStart,type:`text`};if(n.kind===`gap`&&n.gapBetween!==void 0){let t=n.gapBetween.before;return{key:t,offset:e.children.get(t)?.length??0,type:`element`}}
156
156
  /* v8 ignore next -- non-gap segments always carry their node. */
157
- if(n.node===null)return null;let r=n.node.getParent();return r===null?null:{key:r.getKey(),offset:n.node.getIndexWithinParent(),type:`element`}}let n=X_().getChildren(),r=n[n.length-1];return r===void 0?{key:X_().getKey(),offset:0,type:`element`}:{key:r.getKey(),offset:e.children.get(r.getKey())?.length??0,type:`element`}}function ek(e,t){if(t.start<0||t.start>t.end||t.end>e.detectLength)return null;let n=$O(e,t.start),r=$O(e,t.end);
157
+ if(n.node===null)return null;let r=n.node.getParent();return r===null?null:{key:r.getKey(),offset:n.node.getIndexWithinParent(),type:`element`}}let n=av().getChildren(),r=n[n.length-1];return r===void 0?{key:av().getKey(),offset:0,type:`element`}:{key:r.getKey(),offset:e.children.get(r.getKey())?.length??0,type:`element`}}function Xk(e,t){if(t.start<0||t.start>t.end||t.end>e.detectLength)return null;let n=Yk(e,t.start),r=Yk(e,t.end);
158
158
  /* v8 ignore next -- bounds were checked above; resolvePoint only fails out of bounds. */
159
- if(n===null||r===null)return null;let i=Xh();return i.anchor.set(n.key,n.offset,n.type),i.focus.set(r.key,r.offset,r.type),Z_(i),i}function tk(e,t){let n=ek(YO(),e);if(n===null)return!1;if(t===``)n.isCollapsed()||n.removeText();else{let e=t.replace(/\r\n?/gu,`
159
+ if(n===null||r===null)return null;let i=ag();return i.anchor.set(n.key,n.offset,n.type),i.focus.set(r.key,r.offset,r.type),ov(i),i}function Zk(e,t){let n=Xk(Gk(),e);if(n===null)return!1;if(t===``)n.isCollapsed()||n.removeText();else{let e=t.replace(/\r\n?/gu,`
160
160
  `);e.includes(`
161
- `)?n.insertRawText(e):n.insertText(e)}return!0}function nk(e,t){let n=ek(YO(),e);return n!==null&&(n.insertNodes([...t]),!0)}let rk=/[\uE100-\uE11D\uFFFC]/gu;var ik=class{deps;editor;projected={detectText:``,clipboardText:``,occurrences:[],selection:null,caret:null};occurrenceIds=/* @__PURE__ */ new Map;occurrenceSeq=0;lexiconOff;lexiconSource;domComposing=!1;constructor(e){this.deps=e,this.editor=g_({namespace:`dsh-composer`,nodes:[pC,TC],onError:e=>{throw e}}),this.editor.update(()=>{let e=X_();e.getChildrenSize()===0&&e.append(u_())},{discrete:!0,tag:Jm})}register(){let e=()=>{let e=this.editor.getRootElement();return e!==null&&!e.contains(e.ownerDocument.activeElement)&&xv(Jm),!1},t=()=>{this.domComposing=!0},n=()=>{this.domComposing=!1,this.deps.onCompositionEnd?.()},r=tx(qS(this.editor),this.editor.registerRootListener((e,r)=>{r?.removeEventListener(`compositionstart`,t),r?.removeEventListener(`compositionend`,n),this.domComposing=!1,e?.addEventListener(`compositionstart`,t),e?.addEventListener(`compositionend`,n)}),this.editor.registerCommand(Qp,e=>!this.editor.isEditable()||!e.dataTransfer?.types.includes(`application/x-codexhost-thread-reference`)||e.dataTransfer.types.includes(`Files`)?!1:(e.preventDefault(),e.stopPropagation(),e.dataTransfer.dropEffect=`copy`,!0),4),this.editor.registerCommand(Xp,e=>{if(!this.editor.isEditable()||!e.dataTransfer||e.dataTransfer.types.includes(`Files`))return!1;let t=aC(e.dataTransfer.getData($S));return t!==void 0&&(e.preventDefault(),e.stopPropagation(),e.dataTransfer.dropEffect=`copy`,this.insertFileReferences([iC(t)]))},4),this.editor.registerCommand(cm,()=>(this.editor.update(e,{discrete:!0}),!1),4),this.editor.registerCommand(bp,e,4),this.editor.registerNodeTransform(qg,e),OC(this.editor,(e,t)=>this.deps.openReference(e,t)),ZS(this.editor,QS(),1e3),this.editor.registerUpdateListener(()=>{this.deps.onUpdate()}),WO(this.editor),qO(this.editor,()=>this.deps.activeClaimToken()),EC(this.editor,()=>this.deps.lexicon(),()=>this.deps.activeClaimToken()),()=>{this.lexiconOff?.(),this.lexiconOff=void 0,this.lexiconSource=void 0});return()=>{r(),this.editor.setRootElement(null)}}get projection(){return this.projected}isComposing(){return this.domComposing||this.editor.isComposing()}applyEdit(e,t){this.editor._updating?(t!==void 0&&xv(t),e()):this.editor.update(e,{discrete:!0,...t===void 0?{}:{tag:t}})}refreshLexiconSubscription(){let e=this.deps.resolveLexicon();e!==this.lexiconSource&&(this.lexiconOff?.(),this.lexiconSource=e,this.lexiconOff=e?.subscribe(()=>{DC(this.editor)}),DC(this.editor))}refreshProjection(){let e=this.projected;return this.projected=this.editor.getEditorState().read(()=>QO(e=>this.occurrenceIdOf(e))),e}occurrenceIdOf(e){let t=this.occurrenceIds.get(e);return t===void 0?(this.occurrenceSeq+=1,this.occurrenceIds.set(e,this.occurrenceSeq),this.occurrenceSeq):t}setDraft(e){let t=e.replace(rk,``);(t!==this.projection.clipboardText||this.projection.occurrences.length!==0)&&this.editor.update(()=>{let e=X_();e.clear();for(let n of t.split(`
162
- `)){let t=u_();n!==``&&t.append(gh(n)),e.append(t)}e.selectEnd()},{discrete:!0,tag:Km})}paste(e){let t=e.replace(rk,``).replace(/\r\n?/gu,`
163
- `);t!==``&&this.applyEdit(()=>{let e=V();if(B(e)){e.insertRawText(t);return}let n=X_();n.getChildrenSize()===0&&n.append(u_()),n.selectEnd().insertRawText(t)},qm)}caretSpan(){if(this.projection.selection!==null)return this.projection.selection;let e=this.projection.detectText.length;return{start:e,end:e}}replaceText(e,t){let n=!1;return this.applyEdit(()=>{n=tk(e,t)}),n}insertAsyncText(e,t){let n=!1,r=t.replace(rk,``);return this.applyEdit(()=>{n=tk(e,r)},qm),n}insertReference(e,t,n){let r=!1;return this.applyEdit(()=>{r=nk(e,n===` `?[mC(t)]:[mC(t),gh(` `)])}),r}insertFileReferences(e,t){if(e.length===0)return!0;let n=!1;return this.applyEdit(()=>{let r=QO(e=>this.occurrenceIdOf(e)),i=t?.end??r.selection?.end??r.detectText.length,a=r.detectText.slice(0,i),o=e.flatMap(e=>[mC(e),gh(` `)]);a!==``&&!/\s$/u.test(a)&&o.unshift(gh(` `)),n=nk({start:i,end:i},o)},qm),n}refreshClaimDecoration(){JO(this.editor)}clearCommittedDraft(e){this.editor.update(()=>{let t=YO(),n=e(t.clipboardText);if(n!==null){tk({start:0,end:XO(t,n)},``);return}let r=X_();r.clear(),r.append(u_()),r.selectEnd()},{discrete:!0,tag:Km})}restoreDraft(e,t){this.editor.update(()=>{let n=X_();n.clear();let r=u_();n.append(r);let i=e=>{let t=e.replace(rk,``).split(`
164
- `);for(let e=0;e<t.length;e+=1){let i=t[e];i!==``&&r.append(gh(i)),e<t.length-1&&(r=u_(),n.append(r))}},a=0;for(let n of t)i(e.slice(a,n.offset)),r.append(new pC({source:n.source,ref:n.ref,label:n.label,...n.appearance===void 0?{}:{appearance:n.appearance},clipboardText:n.clipboardText},n.invalid===!0)),a=n.offset+n.length;i(e.slice(a)),n.selectEnd()},{discrete:!0,tag:Km})}clearHistory(){this.editor.dispatchCommand(im,void 0)}};function ak(e){switch(e){case`plain`:return`plain`;case`claimed`:return`claimed`;default:return`frozen`}}function ok(e,t){return e.clipboardText!==t.clipboardText||e.detectText!==t.detectText||e.occurrences.length!==t.occurrences.length||t.occurrences.some((t,n)=>{let r=e.occurrences[n];return r===void 0||r.occurrenceId!==t.occurrenceId||r.invalid!==t.invalid})}let sk=[],ck=/* @__PURE__ */ new Map;var lk=class{deps;state;notices=(0,f.createSnapshotStore)(null);get editor(){return this.draftEditor.editor}get isDisposed(){return this.disposed}actions={captureInsertion:e=>{let t=this.projection.detectText.length;return{...e===`end`?{start:t,end:t}:this.caretSpan(),draftRev:this.rev}},bindPrimaryAction:e=>(this.primaryAction=e,this.publish(),()=>{this.primaryAction===e&&(this.primaryAction=void 0,this.publish())}),insertText:(e,t)=>this.snapshot.phase===`adjudicating`||this.snapshot.phase===`submitting`||this.disposed||t.draftRev!==this.rev?!1:this.draftEditor.insertAsyncText(t,e),setDraft:e=>{this.setDraft(e)},persistDraft:()=>{this.persistCurrentDraft()},addAttachments:e=>this.addAttachments(e),removeAttachment:e=>{this.removeAttachment(e)},pruneAttachments:e=>{this.pruneAttachments(e)},addResponseAnnotation:(e,t)=>{let n=this.addResponseAnnotation(e);return n!==void 0&&t?.focus===`end`&&this.canInsertReferences()&&this.focus(`end`),n},updateResponseAnnotation:(e,t)=>{this.updateResponseAnnotation(e,t)},removeResponseAnnotation:e=>{this.removeResponseAnnotation(e)},clearResponseAnnotations:()=>{this.clearResponseAnnotations()},hoverResponseAnnotation:e=>{this.hoverResponseAnnotation(e)},submit:()=>{this.submit(`queue`)}};primaryAction;core=new ax;draftEditor;get projection(){return this.draftEditor.projection}rev=0;unregister;noticeSeq=0;lastPublishedDraft;draftSnapshotCache;attachmentIds=[];responseAnnotations=[];hoveredResponseAnnotationId;annotationSeq=0;submittedAnnotationAnchors=/* @__PURE__ */ new Map;adjudication;disposed=!1;persistDraft;persistDraftTimer;pendingPersistDraft;removeUnloadFlush;deferredTriggerTrack=!1;filePicker;detachedDrafts=/* @__PURE__ */ new Map;failedDetached=/* @__PURE__ */ new Map;failedRestoreRev;failedRestorePrefix;restoringFailures=!1;attachmentFlightSeq=0;attachmentFlights=/* @__PURE__ */ new Map;unsubscribeInbox;constructor(e){this.deps=e,this.draftEditor=new ik({onUpdate:()=>{this.onEditorUpdate()},onCompositionEnd:()=>{this.onCompositionEnd()},openReference:(e,t)=>this.deps.inputTriggers?.()?.openReference(e,t)??!1,activeClaimToken:()=>this.activeClaimToken(),lexicon:()=>this.lexicon.getSnapshot(),resolveLexicon:()=>this.deps.inputTriggers?.()?.lexicon}),this.unregister=this.draftEditor.register(),this.state=(0,f.createSnapshotStore)(this.compose()),this.unsubscribeInbox=e.inbox?.subscribe(()=>{this.publish()})}onEditorUpdate(){ok(this.draftEditor.refreshProjection(),this.projection)&&(this.rev+=1,!this.restoringFailures&&this.failedRestoreRev!==void 0&&(this.failedDetached.clear(),this.failedRestorePrefix=void 0,this.failedRestoreRev=void 0),this.dispatchRun({type:`draft-changed`,draft:this.projection.clipboardText})),this.draftEditor.isComposing()?this.deferredTriggerTrack=!0:(this.deferredTriggerTrack=!1,this.trackCurrentTriggers())}onCompositionEnd(){this.disposed||(this.draftEditor.refreshProjection(),(this.deferredTriggerTrack||this.projection.caret!==null)&&(this.deferredTriggerTrack=!1,this.trackCurrentTriggers()))}trackCurrentTriggers(){let e=this.projection.caret;e!==null&&this.deps.inputTriggers?.()?.track(this.projection.detectText,e,{tier:ak(this.core.state.phase)},this.rev)}setDraft(e){let t=Uu(e);t.references.length===0?this.draftEditor.setDraft(t.text):this.draftEditor.restoreDraft(t.text,t.references)}refreshLexiconSubscription(){this.disposed||this.draftEditor.refreshLexiconSubscription()}get draftSnapshot(){if(this.draftSnapshotCache?.revision===this.rev)return this.draftSnapshotCache.value;let e=Gu(this.projection.clipboardText,this.projection.occurrences);return this.draftSnapshotCache={revision:this.rev,value:e},e}persistCurrentDraft(){let e=this.draftSnapshot;this.lastPublishedDraft=e,this.clearPersistTimer(),this.pendingPersistDraft=void 0,this.persistDraft?.(e)}flushDraftPersistence(){this.clearPersistTimer();let e=this.pendingPersistDraft;e!==void 0&&(this.pendingPersistDraft=void 0,this.persistDraft?.(e))}scheduleDraftPersistence(e){this.persistDraft!==void 0&&(this.pendingPersistDraft=e,this.persistDraftTimer!==void 0&&clearTimeout(this.persistDraftTimer),this.armUnloadFlush(),this.persistDraftTimer=setTimeout(()=>{this.persistDraftTimer=void 0,this.flushDraftPersistence()},180))}clearPersistTimer(){this.persistDraftTimer!==void 0&&(clearTimeout(this.persistDraftTimer),this.persistDraftTimer=void 0),this.disarmUnloadFlush()}armUnloadFlush(){if(this.removeUnloadFlush!==void 0||typeof window>`u`)return;let e=()=>{this.flushDraftPersistence()};window.addEventListener(`pagehide`,e),window.addEventListener(`beforeunload`,e),this.removeUnloadFlush=()=>{window.removeEventListener(`pagehide`,e),window.removeEventListener(`beforeunload`,e)}}disarmUnloadFlush(){this.removeUnloadFlush?.(),this.removeUnloadFlush=void 0}requestDraftInitialization(e){return this.draftInitializationBlocked()?`blocked`:e.prompt===void 0&&e.clearPreviousDraft!==!0||e.clearPreviousDraft!==!0&&(this.snapshot.draft!==``||this.attachmentIds.length>0)?`preserved`:(this.setDraft(e.prompt??``),`applied`)}draftInitializationBlocked(){let{phase:e}=this.core.state;return this.disposed||e===`adjudicating`||e===`submitting`||this.detachedDrafts.size>0||this.attachmentFlights.size>0}canInsertReferences(){let e=this.editor.getRootElement();return!this.disposed&&this.editor.isEditable()&&e!==null&&e.isConnected&&e.getClientRects().length>0&&(this.snapshot.phase===`plain`||this.snapshot.phase===`claimed`)}insertReferences(e,t){return!this.canInsertReferences()||t.draftRev!==this.rev?!1:this.draftEditor.insertFileReferences(e,t)}addAttachments(e){return this.disposed||this.snapshot.phase===`adjudicating`||this.snapshot.phase===`submitting`?!1:(e.length===0||(this.attachmentIds=[...this.attachmentIds,...e],this.publish()),!0)}addFiles(e,t){return this.snapshot.phase===`adjudicating`||this.snapshot.phase===`submitting`||!this.draftEditor.insertFileReferences(e)?!1:(this.attachmentIds=[...this.attachmentIds,...t],this.publish(),!0)}removeAttachment(e){if(this.snapshot.phase===`adjudicating`||this.snapshot.phase===`submitting`)return!1;let t=this.attachmentIds.filter(t=>t!==e);return t.length!==this.attachmentIds.length&&(this.attachmentIds=t,this.publish(),!0)}pruneAttachments(e){let t=new Set(e),n=this.attachmentIds.filter(e=>t.has(e));n.length!==this.attachmentIds.length&&(this.attachmentIds=n,this.publish())}addResponseAnnotation(e){if(this.disposed||this.snapshot.phase===`adjudicating`||this.snapshot.phase===`submitting`)return;this.annotationSeq+=1;let t=`response-annotation-${String(this.annotationSeq)}`;return this.responseAnnotations=[...this.responseAnnotations,{id:t,text:e.text.trim(),...e.annotation===void 0?{}:{annotation:e.annotation},...e.anchor===void 0?{}:{anchor:e.anchor}}],this.publish(),t}addResponseAnnotations(e){if(this.disposed||e.length===0||this.snapshot.phase===`adjudicating`||this.snapshot.phase===`submitting`)return[];let t=[],n=[];for(let r of e){this.annotationSeq+=1;let e=`response-annotation-${String(this.annotationSeq)}`;t.push(e),n.push({id:e,text:r.text.trim(),...r.annotation===void 0?{}:{annotation:r.annotation},...r.anchor===void 0?{}:{anchor:r.anchor}})}return this.responseAnnotations=[...this.responseAnnotations,...n],this.publish(),t}takeSubmittedAnnotationAnchors(e,t){if(e===void 0)return t;let n=this.submittedAnnotationAnchors.get(e);if(this.submittedAnnotationAnchors.delete(e),n===void 0||n.length!==t.length)return t;for(let e=0;e<t.length;e+=1)if(n[e]?.text!==t[e]?.text)return t;return t.map((e,t)=>{let r=n[t]?.anchor;return r===void 0?e:{...e,anchor:r}})}rememberSubmittedAnnotations(e,t){let n=t.map(e=>({text:e.text,...e.annotation===void 0?{}:{annotation:e.annotation},...e.anchor===void 0?{}:{anchor:e.anchor}}));for(this.submittedAnnotationAnchors.delete(e),this.submittedAnnotationAnchors.set(e,n);this.submittedAnnotationAnchors.size>32;){let e=this.submittedAnnotationAnchors.keys().next().value;if(e===void 0)break;this.submittedAnnotationAnchors.delete(e)}}updateResponseAnnotation(e,t){if(this.disposed||this.snapshot.phase===`adjudicating`||this.snapshot.phase===`submitting`)return!1;let n=t?.trim()??``,r,i=this.responseAnnotations.map(t=>{if(t.id!==e)return t;let i=n===``?void 0:n;return t.annotation===i?t:(r={id:t.id,text:t.text,...i===void 0?{}:{annotation:i},...t.anchor===void 0?{}:{anchor:t.anchor}},r)});return r!==void 0&&(this.responseAnnotations=i,this.syncFailedAnnotation(r),this.publish(),!0)}removeResponseAnnotation(e){if(this.disposed||this.snapshot.phase===`adjudicating`||this.snapshot.phase===`submitting`)return!1;let t=this.responseAnnotations.filter(t=>t.id!==e);return t.length!==this.responseAnnotations.length&&(this.responseAnnotations=t,this.hoveredResponseAnnotationId===e&&(this.hoveredResponseAnnotationId=void 0),this.forgetFailedAnnotation(e),this.publish(),!0)}clearResponseAnnotations(){if(this.disposed||this.snapshot.phase===`adjudicating`||this.snapshot.phase===`submitting`||this.responseAnnotations.length===0)return!1;let e=this.responseAnnotations;this.responseAnnotations=[],this.hoveredResponseAnnotationId=void 0;for(let t of e)this.forgetFailedAnnotation(t.id);return this.publish(),!0}hoverResponseAnnotation(e){if(this.disposed)return;let t=e!==null&&this.responseAnnotations.some(t=>t.id===e)?e:void 0;this.hoveredResponseAnnotationId!==t&&(this.hoveredResponseAnnotationId=t,this.state.set(this.compose()))}syncFailedAnnotation(e){let t=t=>{let n=!1,r=t.map(t=>t.id===e.id?(n=!0,e):t);return n?r:null};if(this.failedRestorePrefix!==void 0){let e=t(this.failedRestorePrefix.responseAnnotations);e!==null&&(this.failedRestorePrefix={...this.failedRestorePrefix,responseAnnotations:e})}for(let[e,n]of this.failedDetached){let r=t(n.responseAnnotations);r!==null&&this.failedDetached.set(e,{...n,responseAnnotations:r})}}forgetFailedAnnotation(e){this.failedRestorePrefix!==void 0&&(this.failedRestorePrefix={...this.failedRestorePrefix,responseAnnotations:this.failedRestorePrefix.responseAnnotations.filter(t=>t.id!==e)});for(let[t,n]of this.failedDetached){let r=n.responseAnnotations.filter(t=>t.id!==e);r.length!==n.responseAnnotations.length&&this.failedDetached.set(t,{...n,responseAnnotations:r})}}commitSend(e){let t=new Set(e);this.attachmentIds=this.attachmentIds.filter(e=>!t.has(e)),this.dispatchRun({type:`send-committed`})}paste(e){this.draftEditor.paste(e)}submit(e=`queue`,t){if(this.disposed)return;let n=Date.now(),r;if(this.snapshot.phase===`plain`&&(this.snapshot.draft.trim()!==``||this.attachmentIds.length>0||this.responseAnnotations.length>0))try{r=this.deps.submissionState?.()}catch{}let i=Object.freeze({timestamp:n,mode:e,...t===void 0?{}:{source:t},...r===void 0?{}:{state:r}});if(this.snapshot.draft.trim()===``&&this.attachmentIds.length>0&&this.responseAnnotations.length===0){if(this.snapshot.phase===`plain`){let t=[...this.attachmentIds],n=new AbortController;this.attachmentFlightSeq+=1;let r=this.attachmentFlightSeq;this.attachmentFlights.set(r,{controller:n,attachmentIds:t}),this.commitSend(t),this.notifySubmission(i),this.deps.defaultSink(``,t,e,n.signal).then(e=>{!this.disposed&&this.attachmentFlights.delete(r)&&e.kind!==`success`&&(this.restoreAttachments(t),e.text!==void 0&&this.notify(`error`,e.text))},e=>{!this.disposed&&this.attachmentFlights.delete(r)&&(this.restoreAttachments(t),this.notify(`error`,e instanceof Error?e.message:String(e)))})}return}let a=this.snapshot;if(a.phase===`claimed`&&this.attachmentIds.length>0&&a.claim?.attachments!==!0){this.notify(`error`,this.deps.commandAttachments.unsupportedNotice(a.claim?.token??a.draft));return}this.dispatchRun({type:`enter`,mode:e,draft:this.projection.clipboardText,annotated:this.responseAnnotations.length>0,submission:i});let o=this.snapshot.phase;(o===`adjudicating`||o===`submitting`)&&(this.deps.popup?.()?.dismiss(),this.deps.inputTriggers?.()?.track(this.projection.detectText,0,{tier:`frozen`},this.rev)),this.flushDraftPersistence()}arbitrate(e,t){return this.deps.inputTriggers?.()?.arbitrate(e,t)??`pass`}steerQueue(){this.deps.steerQueue?.()}space(){let e=this.deps.inputTriggers?.();return e!==void 0&&e.onSpace()}dismissPopup(){this.deps.popup?.()?.dismiss()}caretSpan(){return this.draftEditor.caretSpan()}lexicon={getSnapshot:()=>this.deps.inputTriggers?.()?.lexicon.getSnapshot()??ck,subscribe:e=>this.deps.inputTriggers?.()?.lexicon.subscribe(e)??(()=>{})};beginCommand(e,t){let n=this.core.state.phase;return n!==`plain`&&n!==`claimed`||t.draftRev!==this.rev||this.projection.detectText.slice(0,t.start).trim()!==``||!this.draftEditor.replaceText({start:0,end:t.end},e.token)?!1:(this.dispatchRun({type:`claim`,claim:e}),!0)}insertReference(e,t){let n=this.core.state.phase;if(n!==`plain`&&n!==`claimed`||t.draftRev!==this.rev)return!1;let r=this.projection.detectText.slice(t.end,t.end+1);return this.draftEditor.insertReference(t,e,r)}consumeToken(e){return e.kind===`span`?e.span.draftRev!==this.rev||e.span.start===e.span.end?!1:this.draftEditor.replaceText(e.span,``):e.token===``||this.projection.clipboardText.trim()!==e.token?!1:(this.setDraft(``),!0)}insertText(e,t,n=!1){return t.draftRev===this.rev&&this.draftEditor.replaceText(t,e)}notify(e,t){this.noticeSeq+=1,this.notices.set({level:e,text:t,seq:this.noticeSeq})}focus(e){this.editor.getRootElement()?.focus({preventScroll:!0}),e===`end`?this.editor.update(()=>{X_().selectEnd()},{discrete:!0}):this.editor.focus()}dispose(){if(this.disposed)return[];this.flushDraftPersistence(),this.persistDraft=void 0;let e=new Set(this.attachmentIds);for(let t of this.detachedDrafts.values())for(let n of t.attachmentIds)e.add(n);for(let t of this.attachmentFlights.values()){for(let n of t.attachmentIds)e.add(n);t.controller.abort()}return this.disposed=!0,this.dispatchRun({type:`release`}),this.unsubscribeInbox?.(),this.unregister(),this.detachedDrafts.clear(),this.failedDetached.clear(),this.failedRestorePrefix=void 0,this.hoveredResponseAnnotationId=void 0,this.submittedAnnotationAnchors.clear(),this.attachmentFlights.clear(),[...e]}get snapshot(){return this.state.getSnapshot()}bindDraftPersistence(e){return this.persistDraft=e,()=>{this.persistDraft===e&&(this.flushDraftPersistence(),this.persistDraft=void 0)}}bindFilePicker(e){return this.filePicker=e,()=>{this.filePicker===e&&(this.filePicker=void 0)}}canPickFiles(){return this.filePicker?.available()===!0}pickFiles(){return this.filePicker===void 0||!this.filePicker.available()?!1:(this.filePicker.open(),!0)}activeClaimToken(){let e=this.core.state;return(e.phase===`claimed`||e.phase===`submitting`)&&e.claim!==void 0?e.claim.token:null}dispatchRun(e){let t=this.activeClaimToken(),n=this.core.dispatch(e);this.run(n),this.activeClaimToken()!==t&&this.draftEditor.refreshClaimDecoration()}run(e){for(let t of e)this.execute(t);this.publish()}execute(e){switch(e.type){case`notice`:this.noticeSeq+=1,this.notices.set({level:e.level,text:e.text,seq:this.noticeSeq});return;case`adjudicate`:this.adjudicate(e.attempt,e.draft);return;case`begin-submit`:this.beginSubmit(e.attempt,e.claim,e.args);return;case`default-sink`:this.sinkSerialized(e.attempt,e.draft,e.mode);return;case`commit-draft`:this.commitDraft(e.retainSuffixOf);return}}commitDraft(e){this.draftEditor.clearCommittedDraft(t=>e!==null&&t!==e&&t.startsWith(e)?e.length:null),this.draftEditor.clearHistory(),this.flushDraftPersistence()}sinkSerialized(e,t,n){this.notifySubmission(e.submission);let r=[...this.attachmentIds];this.attachmentIds=[];let i=[...this.responseAnnotations];this.responseAnnotations=[],this.hoveredResponseAnnotationId=void 0;let a=this.projection.occurrences,o={draft:t,occurrences:a,attachmentIds:r,responseAnnotations:i};this.detachedDrafts.set(e.seq,o),this.failedRestoreRev===this.rev&&(this.failedDetached.clear(),this.failedRestorePrefix=void 0,this.failedRestoreRev=void 0);let s=i.some(e=>e.anchor!==void 0)?e=>{this.rememberSubmittedAnnotations(e,i)}:void 0,c=t=>this.deps.defaultSink(TO(i,t.trim()),r,n,e.signal,s);if(a.length===0){this.settleSink(e,c(t));return}let l=this.deps.inputTriggers?.();Promise.all(a.map(async t=>{if(l===void 0)throw Error(`no serializer for reference source "${t.source}"`);return{offset:t.offset,length:t.length,text:await l.serializeReference(t.source,t.ref,e.signal)}})).then(n=>{if(this.disposed)return;let r=``,i=0;for(let e of n)r+=t.slice(i,e.offset)+e.text,i=e.offset+e.length;r+=t.slice(i),this.settleSink(e,c(r))},t=>{if(this.dead(e))return;let n=t instanceof Error?t.message:String(t);this.settleDetachedFailure(e,n)})}notifySubmission(e){if(e!==void 0)try{this.deps.messageSubmitted?.(e)}catch{}}settleSink(e,t){t.then(t=>{this.dead(e)||(t.kind===`success`?(this.detachedDrafts.delete(e.seq),this.dispatchRun({type:`sink-settled`,attempt:e,ok:!0,outcome:t})):this.settleDetachedFailure(e,t.text))},t=>{this.dead(e)||this.settleDetachedFailure(e,t instanceof Error?t.message:String(t))})}settleDetachedFailure(e,t){if(this.adjudication!==void 0){let n=()=>{this.dead(e)||this.settleDetachedFailure(e,t)};this.adjudication.then(n,n);return}let n=this.detachedDrafts.get(e.seq);if(n===void 0)return;this.detachedDrafts.delete(e.seq),this.restoreAttachments(n.attachmentIds);let r=n.draft!==``||n.responseAnnotations.length>0||this.failedRestorePrefix!==void 0,i=this.projection.clipboardText;i!==``&&this.failedRestoreRev!==this.rev&&r&&(this.failedDetached.clear(),this.failedRestorePrefix={draft:i,occurrences:this.projection.occurrences,responseAnnotations:[]}),(n.draft!==``||n.responseAnnotations.length>0)&&this.failedDetached.set(e.seq,n),this.restoreFailedDrafts(),this.dispatchRun({type:`sink-settled`,attempt:e,ok:!1,...t===void 0?{}:{message:t}})}restoreFailedDrafts(){let e=[...this.failedRestorePrefix===void 0?[]:[this.failedRestorePrefix],...[...this.failedDetached.entries()].sort(([e],[t])=>e-t).map(([,e])=>e)];if(e.length===0)return;let t=``,n=[],r=[];for(let i of e){if(r.push(...i.responseAnnotations),i.draft===``)continue;let e=t.length+(t===``?0:2);t!==``&&(t+=`
161
+ `)?n.insertRawText(e):n.insertText(e)}return!0}function Qk(e,t){let n=Xk(Gk(),e);return n!==null&&(n.insertNodes([...t]),!0)}let $k=/[\uE100-\uE11D\uFFFC]/gu;var eA=class{deps;editor;projected={detectText:``,clipboardText:``,occurrences:[],selection:null,caret:null};occurrenceIds=/* @__PURE__ */ new Map;occurrenceSeq=0;lexiconOff;lexiconSource;domComposing=!1;constructor(e){this.deps=e,this.editor=T_({namespace:`dsh-composer`,nodes:[SC,PC],onError:e=>{throw e}}),this.editor.update(()=>{let e=av();e.getChildrenSize()===0&&e.append(y_())},{discrete:!0,tag:rh})}register(){let e=()=>{let e=this.editor.getRootElement();return e!==null&&!e.contains(e.ownerDocument.activeElement)&&Av(rh),!1},t=()=>{this.domComposing=!0},n=()=>{this.domComposing=!1,this.deps.onCompositionEnd?.()},r=ux(nC(this.editor),this.editor.registerRootListener((e,r)=>{r?.removeEventListener(`compositionstart`,t),r?.removeEventListener(`compositionend`,n),this.domComposing=!1,e?.addEventListener(`compositionstart`,t),e?.addEventListener(`compositionend`,n)}),this.editor.registerCommand(sm,e=>!this.editor.isEditable()||!e.dataTransfer?.types.includes(`application/x-codexhost-thread-reference`)||e.dataTransfer.types.includes(`Files`)?!1:(e.preventDefault(),e.stopPropagation(),e.dataTransfer.dropEffect=`copy`,!0),4),this.editor.registerCommand(am,e=>{if(!this.editor.isEditable()||!e.dataTransfer||e.dataTransfer.types.includes(`Files`))return!1;let t=mC(e.dataTransfer.getData(cC));return t!==void 0&&(e.preventDefault(),e.stopPropagation(),e.dataTransfer.dropEffect=`copy`,this.insertFileReferences([pC(t)]))},4),this.editor.registerCommand(_m,()=>(this.editor.update(e,{discrete:!0}),!1),4),this.editor.registerCommand(kp,e,4),this.editor.registerNodeTransform(n_,e),LC(this.editor,(e,t)=>this.deps.openReference(e,t)),oC(this.editor,sC(),1e3),this.editor.registerUpdateListener(()=>{this.deps.onUpdate()}),Bk(this.editor),Uk(this.editor,()=>this.deps.activeClaimToken()),FC(this.editor,()=>this.deps.lexicon(),()=>this.deps.activeClaimToken()),()=>{this.lexiconOff?.(),this.lexiconOff=void 0,this.lexiconSource=void 0});return()=>{r(),this.editor.setRootElement(null)}}get projection(){return this.projected}isComposing(){return this.domComposing||this.editor.isComposing()}applyEdit(e,t){this.editor._updating?(t!==void 0&&Av(t),e()):this.editor.update(e,{discrete:!0,...t===void 0?{}:{tag:t}})}refreshLexiconSubscription(){let e=this.deps.resolveLexicon();e!==this.lexiconSource&&(this.lexiconOff?.(),this.lexiconSource=e,this.lexiconOff=e?.subscribe(()=>{IC(this.editor)}),IC(this.editor))}refreshProjection(){let e=this.projected;return this.projected=this.editor.getEditorState().read(()=>Jk(e=>this.occurrenceIdOf(e))),e}occurrenceIdOf(e){let t=this.occurrenceIds.get(e);return t===void 0?(this.occurrenceSeq+=1,this.occurrenceIds.set(e,this.occurrenceSeq),this.occurrenceSeq):t}setDraft(e){let t=e.replace($k,``);(t!==this.projection.clipboardText||this.projection.occurrences.length!==0)&&this.editor.update(()=>{let e=av();e.clear();for(let n of t.split(`
162
+ `)){let t=y_();n!==``&&t.append(Th(n)),e.append(t)}e.selectEnd()},{discrete:!0,tag:th})}paste(e){let t=e.replace($k,``).replace(/\r\n?/gu,`
163
+ `);t!==``&&this.applyEdit(()=>{let e=V();if(B(e)){e.insertRawText(t);return}let n=av();n.getChildrenSize()===0&&n.append(y_()),n.selectEnd().insertRawText(t)},nh)}caretSpan(){if(this.projection.selection!==null)return this.projection.selection;let e=this.projection.detectText.length;return{start:e,end:e}}replaceText(e,t){let n=!1;return this.applyEdit(()=>{n=Zk(e,t)}),n}insertAsyncText(e,t){let n=!1,r=t.replace($k,``);return this.applyEdit(()=>{n=Zk(e,r)},nh),n}insertReference(e,t,n){let r=!1;return this.applyEdit(()=>{r=Qk(e,n===` `?[CC(t)]:[CC(t),Th(` `)])}),r}insertFileReferences(e,t){if(e.length===0)return!0;let n=!1;return this.applyEdit(()=>{let r=Jk(e=>this.occurrenceIdOf(e)),i=t?.end??r.selection?.end??r.detectText.length,a=r.detectText.slice(0,i),o=e.flatMap(e=>[CC(e),Th(` `)]);a!==``&&!/\s$/u.test(a)&&o.unshift(Th(` `)),n=Qk({start:i,end:i},o)},nh),n}refreshClaimDecoration(){Wk(this.editor)}clearCommittedDraft(e){this.editor.update(()=>{let t=Gk(),n=e(t.clipboardText);if(n!==null){Zk({start:0,end:Kk(t,n)},``);return}let r=av();r.clear(),r.append(y_()),r.selectEnd()},{discrete:!0,tag:th})}restoreDraft(e,t){this.editor.update(()=>{let n=av();n.clear();let r=y_();n.append(r);let i=e=>{let t=e.replace($k,``).split(`
164
+ `);for(let e=0;e<t.length;e+=1){let i=t[e];i!==``&&r.append(Th(i)),e<t.length-1&&(r=y_(),n.append(r))}},a=0;for(let n of t)i(e.slice(a,n.offset)),r.append(new SC({source:n.source,ref:n.ref,label:n.label,...n.appearance===void 0?{}:{appearance:n.appearance},clipboardText:n.clipboardText},n.invalid===!0)),a=n.offset+n.length;i(e.slice(a)),n.selectEnd()},{discrete:!0,tag:th})}clearHistory(){this.editor.dispatchCommand(pm,void 0)}};function tA(e){switch(e){case`plain`:return`plain`;case`claimed`:return`claimed`;default:return`frozen`}}function nA(e,t){return e.clipboardText!==t.clipboardText||e.detectText!==t.detectText||e.occurrences.length!==t.occurrences.length||t.occurrences.some((t,n)=>{let r=e.occurrences[n];return r===void 0||r.occurrenceId!==t.occurrenceId||r.invalid!==t.invalid})}let rA=[],iA=/* @__PURE__ */ new Map;var aA=class{deps;state;notices=(0,f.createSnapshotStore)(null);get editor(){return this.draftEditor.editor}get isDisposed(){return this.disposed}actions={captureInsertion:e=>{let t=this.projection.detectText.length;return{...e===`end`?{start:t,end:t}:this.caretSpan(),draftRev:this.rev}},bindPrimaryAction:e=>(this.primaryAction=e,this.publish(),()=>{this.primaryAction===e&&(this.primaryAction=void 0,this.publish())}),insertText:(e,t)=>this.snapshot.phase===`adjudicating`||this.snapshot.phase===`submitting`||this.disposed||t.draftRev!==this.rev?!1:this.draftEditor.insertAsyncText(t,e),setDraft:e=>{this.setDraft(e)},persistDraft:()=>{this.persistCurrentDraft()},addAttachments:e=>this.addAttachments(e),removeAttachment:e=>{this.removeAttachment(e)},pruneAttachments:e=>{this.pruneAttachments(e)},addResponseAnnotation:(e,t)=>{let n=this.addResponseAnnotation(e);return n!==void 0&&t?.focus===`end`&&this.canInsertReferences()&&this.focus(`end`),n},updateResponseAnnotation:(e,t)=>{this.updateResponseAnnotation(e,t)},removeResponseAnnotation:e=>{this.removeResponseAnnotation(e)},clearResponseAnnotations:()=>{this.clearResponseAnnotations()},hoverResponseAnnotation:e=>{this.hoverResponseAnnotation(e)},submit:()=>{this.submit(`queue`)}};primaryAction;core=new mx;draftEditor;get projection(){return this.draftEditor.projection}rev=0;unregister;noticeSeq=0;lastPublishedDraft;draftSnapshotCache;attachmentIds=[];responseAnnotations=[];hoveredResponseAnnotationId;annotationSeq=0;submittedAnnotationAnchors=/* @__PURE__ */ new Map;adjudication;disposed=!1;persistDraft;persistDraftTimer;pendingPersistDraft;removeUnloadFlush;deferredTriggerTrack=!1;filePicker;detachedDrafts=/* @__PURE__ */ new Map;failedDetached=/* @__PURE__ */ new Map;failedRestoreRev;failedRestorePrefix;restoringFailures=!1;attachmentFlightSeq=0;attachmentFlights=/* @__PURE__ */ new Map;unsubscribeInbox;constructor(e){this.deps=e,this.draftEditor=new eA({onUpdate:()=>{this.onEditorUpdate()},onCompositionEnd:()=>{this.onCompositionEnd()},openReference:(e,t)=>this.deps.inputTriggers?.()?.openReference(e,t)??!1,activeClaimToken:()=>this.activeClaimToken(),lexicon:()=>this.lexicon.getSnapshot(),resolveLexicon:()=>this.deps.inputTriggers?.()?.lexicon}),this.unregister=this.draftEditor.register(),this.state=(0,f.createSnapshotStore)(this.compose()),this.unsubscribeInbox=e.inbox?.subscribe(()=>{this.publish()})}onEditorUpdate(){nA(this.draftEditor.refreshProjection(),this.projection)&&(this.rev+=1,!this.restoringFailures&&this.failedRestoreRev!==void 0&&(this.failedDetached.clear(),this.failedRestorePrefix=void 0,this.failedRestoreRev=void 0),this.dispatchRun({type:`draft-changed`,draft:this.projection.clipboardText})),this.draftEditor.isComposing()?this.deferredTriggerTrack=!0:(this.deferredTriggerTrack=!1,this.trackCurrentTriggers())}onCompositionEnd(){this.disposed||(this.draftEditor.refreshProjection(),(this.deferredTriggerTrack||this.projection.caret!==null)&&(this.deferredTriggerTrack=!1,this.trackCurrentTriggers()))}trackCurrentTriggers(){let e=this.projection.caret;e!==null&&this.deps.inputTriggers?.()?.track(this.projection.detectText,e,{tier:tA(this.core.state.phase)},this.rev)}setDraft(e){let t=Qu(e);t.references.length===0?this.draftEditor.setDraft(t.text):this.draftEditor.restoreDraft(t.text,t.references)}refreshLexiconSubscription(){this.disposed||this.draftEditor.refreshLexiconSubscription()}get draftSnapshot(){if(this.draftSnapshotCache?.revision===this.rev)return this.draftSnapshotCache.value;let e=ed(this.projection.clipboardText,this.projection.occurrences);return this.draftSnapshotCache={revision:this.rev,value:e},e}persistCurrentDraft(){let e=this.draftSnapshot;this.lastPublishedDraft=e,this.clearPersistTimer(),this.pendingPersistDraft=void 0,this.persistDraft?.(e)}flushDraftPersistence(){this.clearPersistTimer();let e=this.pendingPersistDraft;e!==void 0&&(this.pendingPersistDraft=void 0,this.persistDraft?.(e))}scheduleDraftPersistence(e){this.persistDraft!==void 0&&(this.pendingPersistDraft=e,this.persistDraftTimer!==void 0&&clearTimeout(this.persistDraftTimer),this.armUnloadFlush(),this.persistDraftTimer=setTimeout(()=>{this.persistDraftTimer=void 0,this.flushDraftPersistence()},180))}clearPersistTimer(){this.persistDraftTimer!==void 0&&(clearTimeout(this.persistDraftTimer),this.persistDraftTimer=void 0),this.disarmUnloadFlush()}armUnloadFlush(){if(this.removeUnloadFlush!==void 0||typeof window>`u`)return;let e=()=>{this.flushDraftPersistence()};window.addEventListener(`pagehide`,e),window.addEventListener(`beforeunload`,e),this.removeUnloadFlush=()=>{window.removeEventListener(`pagehide`,e),window.removeEventListener(`beforeunload`,e)}}disarmUnloadFlush(){this.removeUnloadFlush?.(),this.removeUnloadFlush=void 0}requestDraftInitialization(e){return this.draftInitializationBlocked()?`blocked`:e.prompt===void 0&&e.clearPreviousDraft!==!0||e.clearPreviousDraft!==!0&&(this.snapshot.draft!==``||this.attachmentIds.length>0)?`preserved`:(this.setDraft(e.prompt??``),`applied`)}draftInitializationBlocked(){let{phase:e}=this.core.state;return this.disposed||e===`adjudicating`||e===`submitting`||this.detachedDrafts.size>0||this.attachmentFlights.size>0}canInsertReferences(){let e=this.editor.getRootElement();return!this.disposed&&this.editor.isEditable()&&e!==null&&e.isConnected&&e.getClientRects().length>0&&(this.snapshot.phase===`plain`||this.snapshot.phase===`claimed`)}insertReferences(e,t){return!this.canInsertReferences()||t.draftRev!==this.rev?!1:this.draftEditor.insertFileReferences(e,t)}addAttachments(e){return this.disposed||this.snapshot.phase===`adjudicating`||this.snapshot.phase===`submitting`?!1:(e.length===0||(this.attachmentIds=[...this.attachmentIds,...e],this.publish()),!0)}addFiles(e,t){return this.snapshot.phase===`adjudicating`||this.snapshot.phase===`submitting`||!this.draftEditor.insertFileReferences(e)?!1:(this.attachmentIds=[...this.attachmentIds,...t],this.publish(),!0)}removeAttachment(e){if(this.snapshot.phase===`adjudicating`||this.snapshot.phase===`submitting`)return!1;let t=this.attachmentIds.filter(t=>t!==e);return t.length!==this.attachmentIds.length&&(this.attachmentIds=t,this.publish(),!0)}pruneAttachments(e){let t=new Set(e),n=this.attachmentIds.filter(e=>t.has(e));n.length!==this.attachmentIds.length&&(this.attachmentIds=n,this.publish())}addResponseAnnotation(e){if(this.disposed||this.snapshot.phase===`adjudicating`||this.snapshot.phase===`submitting`)return;this.annotationSeq+=1;let t=`response-annotation-${String(this.annotationSeq)}`;return this.responseAnnotations=[...this.responseAnnotations,{id:t,text:e.text.trim(),...e.annotation===void 0?{}:{annotation:e.annotation},...e.anchor===void 0?{}:{anchor:e.anchor}}],this.publish(),t}addResponseAnnotations(e){if(this.disposed||e.length===0||this.snapshot.phase===`adjudicating`||this.snapshot.phase===`submitting`)return[];let t=[],n=[];for(let r of e){this.annotationSeq+=1;let e=`response-annotation-${String(this.annotationSeq)}`;t.push(e),n.push({id:e,text:r.text.trim(),...r.annotation===void 0?{}:{annotation:r.annotation},...r.anchor===void 0?{}:{anchor:r.anchor}})}return this.responseAnnotations=[...this.responseAnnotations,...n],this.publish(),t}takeSubmittedAnnotationAnchors(e,t){if(e===void 0)return t;let n=this.submittedAnnotationAnchors.get(e);if(this.submittedAnnotationAnchors.delete(e),n===void 0||n.length!==t.length)return t;for(let e=0;e<t.length;e+=1)if(n[e]?.text!==t[e]?.text)return t;return t.map((e,t)=>{let r=n[t]?.anchor;return r===void 0?e:{...e,anchor:r}})}rememberSubmittedAnnotations(e,t){let n=t.map(e=>({text:e.text,...e.annotation===void 0?{}:{annotation:e.annotation},...e.anchor===void 0?{}:{anchor:e.anchor}}));for(this.submittedAnnotationAnchors.delete(e),this.submittedAnnotationAnchors.set(e,n);this.submittedAnnotationAnchors.size>32;){let e=this.submittedAnnotationAnchors.keys().next().value;if(e===void 0)break;this.submittedAnnotationAnchors.delete(e)}}updateResponseAnnotation(e,t){if(this.disposed||this.snapshot.phase===`adjudicating`||this.snapshot.phase===`submitting`)return!1;let n=t?.trim()??``,r,i=this.responseAnnotations.map(t=>{if(t.id!==e)return t;let i=n===``?void 0:n;return t.annotation===i?t:(r={id:t.id,text:t.text,...i===void 0?{}:{annotation:i},...t.anchor===void 0?{}:{anchor:t.anchor}},r)});return r!==void 0&&(this.responseAnnotations=i,this.syncFailedAnnotation(r),this.publish(),!0)}removeResponseAnnotation(e){if(this.disposed||this.snapshot.phase===`adjudicating`||this.snapshot.phase===`submitting`)return!1;let t=this.responseAnnotations.filter(t=>t.id!==e);return t.length!==this.responseAnnotations.length&&(this.responseAnnotations=t,this.hoveredResponseAnnotationId===e&&(this.hoveredResponseAnnotationId=void 0),this.forgetFailedAnnotation(e),this.publish(),!0)}clearResponseAnnotations(){if(this.disposed||this.snapshot.phase===`adjudicating`||this.snapshot.phase===`submitting`||this.responseAnnotations.length===0)return!1;let e=this.responseAnnotations;this.responseAnnotations=[],this.hoveredResponseAnnotationId=void 0;for(let t of e)this.forgetFailedAnnotation(t.id);return this.publish(),!0}hoverResponseAnnotation(e){if(this.disposed)return;let t=e!==null&&this.responseAnnotations.some(t=>t.id===e)?e:void 0;this.hoveredResponseAnnotationId!==t&&(this.hoveredResponseAnnotationId=t,this.state.set(this.compose()))}syncFailedAnnotation(e){let t=t=>{let n=!1,r=t.map(t=>t.id===e.id?(n=!0,e):t);return n?r:null};if(this.failedRestorePrefix!==void 0){let e=t(this.failedRestorePrefix.responseAnnotations);e!==null&&(this.failedRestorePrefix={...this.failedRestorePrefix,responseAnnotations:e})}for(let[e,n]of this.failedDetached){let r=t(n.responseAnnotations);r!==null&&this.failedDetached.set(e,{...n,responseAnnotations:r})}}forgetFailedAnnotation(e){this.failedRestorePrefix!==void 0&&(this.failedRestorePrefix={...this.failedRestorePrefix,responseAnnotations:this.failedRestorePrefix.responseAnnotations.filter(t=>t.id!==e)});for(let[t,n]of this.failedDetached){let r=n.responseAnnotations.filter(t=>t.id!==e);r.length!==n.responseAnnotations.length&&this.failedDetached.set(t,{...n,responseAnnotations:r})}}commitSend(e){let t=new Set(e);this.attachmentIds=this.attachmentIds.filter(e=>!t.has(e)),this.dispatchRun({type:`send-committed`})}paste(e){this.draftEditor.paste(e)}submit(e=`queue`,t){if(this.disposed)return;let n=Date.now(),r;if(this.snapshot.phase===`plain`&&(this.snapshot.draft.trim()!==``||this.attachmentIds.length>0||this.responseAnnotations.length>0))try{r=this.deps.submissionState?.()}catch{}let i=Object.freeze({timestamp:n,mode:e,...t===void 0?{}:{source:t},...r===void 0?{}:{state:r}});if(this.snapshot.draft.trim()===``&&this.attachmentIds.length>0&&this.responseAnnotations.length===0){if(this.snapshot.phase===`plain`){let t=[...this.attachmentIds],n=new AbortController;this.attachmentFlightSeq+=1;let r=this.attachmentFlightSeq;this.attachmentFlights.set(r,{controller:n,attachmentIds:t}),this.commitSend(t),this.notifySubmission(i),this.deps.defaultSink(``,t,e,n.signal).then(e=>{!this.disposed&&this.attachmentFlights.delete(r)&&e.kind!==`success`&&(this.restoreAttachments(t),e.text!==void 0&&this.notify(`error`,e.text))},e=>{!this.disposed&&this.attachmentFlights.delete(r)&&(this.restoreAttachments(t),this.notify(`error`,e instanceof Error?e.message:String(e)))})}return}let a=this.snapshot;if(a.phase===`claimed`&&this.attachmentIds.length>0&&a.claim?.attachments!==!0){this.notify(`error`,this.deps.commandAttachments.unsupportedNotice(a.claim?.token??a.draft));return}this.dispatchRun({type:`enter`,mode:e,draft:this.projection.clipboardText,annotated:this.responseAnnotations.length>0,submission:i});let o=this.snapshot.phase;(o===`adjudicating`||o===`submitting`)&&(this.deps.popup?.()?.dismiss(),this.deps.inputTriggers?.()?.track(this.projection.detectText,0,{tier:`frozen`},this.rev)),this.flushDraftPersistence()}arbitrate(e,t){return this.deps.inputTriggers?.()?.arbitrate(e,t)??`pass`}steerQueue(){this.deps.steerQueue?.()}space(){let e=this.deps.inputTriggers?.();return e!==void 0&&e.onSpace()}dismissPopup(){this.deps.popup?.()?.dismiss()}caretSpan(){return this.draftEditor.caretSpan()}lexicon={getSnapshot:()=>this.deps.inputTriggers?.()?.lexicon.getSnapshot()??iA,subscribe:e=>this.deps.inputTriggers?.()?.lexicon.subscribe(e)??(()=>{})};beginCommand(e,t){let n=this.core.state.phase;return n!==`plain`&&n!==`claimed`||t.draftRev!==this.rev||this.projection.detectText.slice(0,t.start).trim()!==``||!this.draftEditor.replaceText({start:0,end:t.end},e.token)?!1:(this.dispatchRun({type:`claim`,claim:e}),!0)}insertReference(e,t){let n=this.core.state.phase;if(n!==`plain`&&n!==`claimed`||t.draftRev!==this.rev)return!1;let r=this.projection.detectText.slice(t.end,t.end+1);return this.draftEditor.insertReference(t,e,r)}consumeToken(e){return e.kind===`span`?e.span.draftRev!==this.rev||e.span.start===e.span.end?!1:this.draftEditor.replaceText(e.span,``):e.token===``||this.projection.clipboardText.trim()!==e.token?!1:(this.setDraft(``),!0)}insertText(e,t,n=!1){return t.draftRev===this.rev&&this.draftEditor.replaceText(t,e)}notify(e,t){this.noticeSeq+=1,this.notices.set({level:e,text:t,seq:this.noticeSeq})}focus(e){this.editor.getRootElement()?.focus({preventScroll:!0}),e===`end`?this.editor.update(()=>{av().selectEnd()},{discrete:!0}):this.editor.focus()}dispose(){if(this.disposed)return[];this.flushDraftPersistence(),this.persistDraft=void 0;let e=new Set(this.attachmentIds);for(let t of this.detachedDrafts.values())for(let n of t.attachmentIds)e.add(n);for(let t of this.attachmentFlights.values()){for(let n of t.attachmentIds)e.add(n);t.controller.abort()}return this.disposed=!0,this.dispatchRun({type:`release`}),this.unsubscribeInbox?.(),this.unregister(),this.detachedDrafts.clear(),this.failedDetached.clear(),this.failedRestorePrefix=void 0,this.hoveredResponseAnnotationId=void 0,this.submittedAnnotationAnchors.clear(),this.attachmentFlights.clear(),[...e]}get snapshot(){return this.state.getSnapshot()}bindDraftPersistence(e){return this.persistDraft=e,()=>{this.persistDraft===e&&(this.flushDraftPersistence(),this.persistDraft=void 0)}}bindFilePicker(e){return this.filePicker=e,()=>{this.filePicker===e&&(this.filePicker=void 0)}}canPickFiles(){return this.filePicker?.available()===!0}pickFiles(){return this.filePicker===void 0||!this.filePicker.available()?!1:(this.filePicker.open(),!0)}activeClaimToken(){let e=this.core.state;return(e.phase===`claimed`||e.phase===`submitting`)&&e.claim!==void 0?e.claim.token:null}dispatchRun(e){let t=this.activeClaimToken(),n=this.core.dispatch(e);this.run(n),this.activeClaimToken()!==t&&this.draftEditor.refreshClaimDecoration()}run(e){for(let t of e)this.execute(t);this.publish()}execute(e){switch(e.type){case`notice`:this.noticeSeq+=1,this.notices.set({level:e.level,text:e.text,seq:this.noticeSeq});return;case`adjudicate`:this.adjudicate(e.attempt,e.draft);return;case`begin-submit`:this.beginSubmit(e.attempt,e.claim,e.args);return;case`default-sink`:this.sinkSerialized(e.attempt,e.draft,e.mode);return;case`commit-draft`:this.commitDraft(e.retainSuffixOf);return}}commitDraft(e){this.draftEditor.clearCommittedDraft(t=>e!==null&&t!==e&&t.startsWith(e)?e.length:null),this.draftEditor.clearHistory(),this.flushDraftPersistence()}sinkSerialized(e,t,n){this.notifySubmission(e.submission);let r=[...this.attachmentIds];this.attachmentIds=[];let i=[...this.responseAnnotations];this.responseAnnotations=[],this.hoveredResponseAnnotationId=void 0;let a=this.projection.occurrences,o={draft:t,occurrences:a,attachmentIds:r,responseAnnotations:i};this.detachedDrafts.set(e.seq,o),this.failedRestoreRev===this.rev&&(this.failedDetached.clear(),this.failedRestorePrefix=void 0,this.failedRestoreRev=void 0);let s=i.some(e=>e.anchor!==void 0)?e=>{this.rememberSubmittedAnnotations(e,i)}:void 0,c=t=>this.deps.defaultSink(xk(i,t.trim()),r,n,e.signal,s);if(a.length===0){this.settleSink(e,c(t));return}let l=this.deps.inputTriggers?.();Promise.all(a.map(async t=>{if(l===void 0)throw Error(`no serializer for reference source "${t.source}"`);return{offset:t.offset,length:t.length,text:await l.serializeReference(t.source,t.ref,e.signal)}})).then(n=>{if(this.disposed)return;let r=``,i=0;for(let e of n)r+=t.slice(i,e.offset)+e.text,i=e.offset+e.length;r+=t.slice(i),this.settleSink(e,c(r))},t=>{if(this.dead(e))return;let n=t instanceof Error?t.message:String(t);this.settleDetachedFailure(e,n)})}notifySubmission(e){if(e!==void 0)try{this.deps.messageSubmitted?.(e)}catch{}}settleSink(e,t){t.then(t=>{this.dead(e)||(t.kind===`success`?(this.detachedDrafts.delete(e.seq),this.dispatchRun({type:`sink-settled`,attempt:e,ok:!0,outcome:t})):this.settleDetachedFailure(e,t.text))},t=>{this.dead(e)||this.settleDetachedFailure(e,t instanceof Error?t.message:String(t))})}settleDetachedFailure(e,t){if(this.adjudication!==void 0){let n=()=>{this.dead(e)||this.settleDetachedFailure(e,t)};this.adjudication.then(n,n);return}let n=this.detachedDrafts.get(e.seq);if(n===void 0)return;this.detachedDrafts.delete(e.seq),this.restoreAttachments(n.attachmentIds);let r=n.draft!==``||n.responseAnnotations.length>0||this.failedRestorePrefix!==void 0,i=this.projection.clipboardText;i!==``&&this.failedRestoreRev!==this.rev&&r&&(this.failedDetached.clear(),this.failedRestorePrefix={draft:i,occurrences:this.projection.occurrences,responseAnnotations:[]}),(n.draft!==``||n.responseAnnotations.length>0)&&this.failedDetached.set(e.seq,n),this.restoreFailedDrafts(),this.dispatchRun({type:`sink-settled`,attempt:e,ok:!1,...t===void 0?{}:{message:t}})}restoreFailedDrafts(){let e=[...this.failedRestorePrefix===void 0?[]:[this.failedRestorePrefix],...[...this.failedDetached.entries()].sort(([e],[t])=>e-t).map(([,e])=>e)];if(e.length===0)return;let t=``,n=[],r=[];for(let i of e){if(r.push(...i.responseAnnotations),i.draft===``)continue;let e=t.length+(t===``?0:2);t!==``&&(t+=`
165
165
 
166
- `),t+=i.draft;for(let t of i.occurrences)n.push({...t,offset:e+t.offset})}let i=new Set(r.map(e=>e.id));this.responseAnnotations=[...r,...this.responseAnnotations.filter(e=>!i.has(e.id))],this.restoringFailures=!0;try{this.draftEditor.restoreDraft(t,n),this.draftEditor.clearHistory(),this.failedRestoreRev=this.rev}finally{this.restoringFailures=!1}this.publish()}restoreAttachments(e){if(e.length===0)return;let t=new Set(this.attachmentIds),n=e.filter(e=>!t.has(e));n.length!==0&&(this.attachmentIds=[...n,...this.attachmentIds],this.publish())}adjudicate(e,t){let n=this.deps.inputTriggers?.();n===void 0?this.dispatchRun({type:`adjudicated`,attempt:e,outcome:void 0}):(this.adjudication=n.adjudicate(t.trim(),e.signal,{attachments:this.attachmentIds.length}),this.adjudication.then(t=>{this.adjudication=void 0,!this.dead(e)&&this.dispatchRun({type:`adjudicated`,attempt:e,outcome:t})},t=>{if(this.adjudication=void 0,this.dead(e))return;let n=t instanceof Error?t.message:String(t);this.dispatchRun({type:`adjudication-failed`,attempt:e,message:n})}))}beginSubmit(e,t,n){let r=t.attachments===!0?[...this.attachmentIds]:[];Promise.resolve().then(async()=>{let i=r.length>0?await this.deps.commandAttachments.serialize(r):[];if(!this.dead(e))return t.submit(n,this.deps.actx,i)}).then(t=>{if(!(t===void 0||this.dead(e))){if(t.kind===`success`&&r.length>0){let e=new Set(r);this.attachmentIds=this.attachmentIds.filter(t=>!e.has(t)),this.deps.commandAttachments.release(r)}this.dispatchRun({type:`submit-settled`,attempt:e,ok:t.kind===`success`,draft:this.projection.clipboardText,outcome:t,...t.kind===`error`&&t.text===void 0?{message:`command failed`}:{}})}},t=>{if(this.dead(e))return;let n=t instanceof Error?t.message:String(t);this.dispatchRun({type:`submit-settled`,attempt:e,ok:!1,draft:this.projection.clipboardText,message:n})})}dead(e){return this.disposed||e.signal.aborted}compose(){let e=this.core.state;return{draft:this.projection.clipboardText,attachmentIds:this.attachmentIds,responseAnnotations:this.responseAnnotations,...this.hoveredResponseAnnotationId===void 0?{}:{hoveredResponseAnnotationId:this.hoveredResponseAnnotationId},draftRev:this.rev,...this.primaryAction===void 0?{}:{primaryAction:this.primaryAction},phase:e.phase,...e.claim===void 0?{}:{claim:e.claim},occurrences:this.projection.occurrences,queue:this.deps.inbox?.getSnapshot()?.[`next-turn`]??sk}}publish(){let e=this.compose();this.state.set(e);let t=this.draftSnapshot;t!==this.lastPublishedDraft&&(this.lastPublishedDraft=t,this.scheduleDraftPersistence(t))}};function uk(e,t){let{state:n,timestamp:r,mode:i}=t;if(n===void 0)return;let a=n.model;e.get(`productAnalytics`)?.track(`send_button_click`,{...n.sessionId===void 0?{}:{session_id:n.sessionId},...a===void 0?{}:{model_name:`${a.provider}/${a.name}`,...a.effort===void 0?{}:{thinking_effort:a.effort}},run_mode:n.runMode,msg_type:n.running?i:`default`},r)}var dk=class{rootCtx;t;pendingDraft;shells=/* @__PURE__ */ new WeakMap;constructor(e,t,n){this.rootCtx=e,this.t=t,this.pendingDraft=n}for(e){let t=this.sessions(),n=t.sessionOf(e),r=n===void 0?void 0:t.binding(n.sessionId);if(r===void 0||r.session!==n)throw Error(`conversation.input.for requires a retained Session scope`);return this.shellFor(r)}captureReferenceInsertion(e){let t=this.sessions(),n=this.shells.get(e);if(t.binding(e.sessionId)!==e||n===void 0)return;let r=this.rootCtx.get(`conversation`);if(r===void 0)return;let i=n.actions.captureInsertion(),a=r.blocks.storeFor(e.sessionId),o=this.rootCtx.uiSession.sessionStatus,s=!1,c=()=>{let r=e.session.getSnapshot();return!s&&t.binding(e.sessionId)===e&&r.openState===`open`&&!r.removed&&a.getSnapshot()===void 0&&o.getSnapshot().get(e.sessionId)?.pendingInteraction===void 0&&n.snapshot.draftRev===i.draftRev&&n.canInsertReferences()};return{getSnapshot:c,subscribe:r=>{let i=[t.list.subscribe(r),e.session.subscribe(r),n.state.subscribe(r),a.subscribe(r),o.subscribe(r),n.editor.registerEditableListener(r),n.editor.registerRootListener(r)];return()=>i.forEach(e=>e())},insert:e=>{let t=c();return s=!0,t&&n.insertReferences([e],i)}}}requestDraftInitialization(e,t){if(this.sessions().binding(e.sessionId)!==e)throw Error(`conversation.input.requestDraftInitialization requires a retained Session binding`);return this.shellFor(e).requestDraftInitialization(t)}adoptPendingDraft(e,t){if(this.sessions().binding(e.sessionId)!==e)throw Error(`conversation.input.adoptPendingDraft requires a retained Session binding`);let n=this.pendingDraft?.take(),r=this.shellFor(e);return t===void 0?n!==void 0&&n.text!==``?(r.setDraft(n.text),`applied`):`preserved`:n?.modified?r.requestDraftInitialization({prompt:n.text,clearPreviousDraft:!0}):r.requestDraftInitialization(t)}shellFor(e){let t=this.shells.get(e);if(t!==void 0)return t;let{session:n,ctx:r}=e,i=new lk({actx:r,submissionState:()=>{let e=n.getSnapshot(),t=n.projections.faceOf(`modelSelection`).getSnapshot(),r=n.projections.faceOf(`plan`).getSnapshot(),i=n.projections.faceOf(`goal`).getSnapshot(),a=t?.next??t?.lastUsed;return Object.freeze({...e.blank?{}:{sessionId:e.sessionId},...a==null?{}:{model:Object.freeze({provider:a.provider,name:a.model,...a.reasoningEffort===void 0?{}:{effort:a.reasoningEffort}})},runMode:r?.active?`plan`:i?.goal.phase===`active`?`goal`:`default`,running:e.running})},messageSubmitted:e=>{uk(this.rootCtx,e)},inputTriggers:()=>this.controller(r),popup:()=>this.popup(r),inbox:n.projections.faceOf(`inbox`),defaultSink:(e,t,r,i,a)=>this.sink(n,e,t,r,i,a),steerQueue:()=>{this.steerQueue(n,i)},commandAttachments:{serialize:async e=>(await this.conversation().serializeDraftAttachments(e)).attachments,release:e=>{let t=this.rootCtx.get(`conversation`);for(let n of e)t?.releaseDraftAttachment(n)},unsupportedNotice:e=>this.t(`command.attachmentsUnsupported`,{command:e.trim().replace(/^\//u,``)})}});return this.shells.set(e,i),r.effect(()=>{let t=[r.on(`slash/input-begin-command`,e=>i.beginCommand(e.claim,e.span)?!0:void 0),r.on(`slash/input-insert-reference`,e=>i.insertReference(e.reference,e.span)?!0:void 0),r.on(`slash/input-consume-token`,e=>i.consumeToken(e.guard)?!0:void 0),r.on(`slash/input-insert-text`,e=>i.insertText(e.text,e.span,e.continue===!0)?!0:void 0)];return()=>{for(let e of t)e();let n=i.dispose();this.shells.delete(e);let r=this.rootCtx.get(`conversation`);for(let e of n)r?.releaseDraftAttachment(e)}},`conversation.input: session shell`),r.inject([`inputTriggers`],e=>{e.effect(()=>(i.refreshLexiconSubscription(),()=>{i.refreshLexiconSubscription()}),`conversation.input: reference catalogs`)}),i.setDraft(Yu(e.sessionId)),i}shell(e){let t=this.sessions().binding(e);if(t===void 0)throw Error(`conversation.input: session "${e}" resolved no binding`);return this.shellFor(t)}keyboard(e){return this.shell(e)}canPickFiles(e){let t=this.sessions().binding(e);return t!==void 0&&this.shells.get(t)?.canPickFiles()===!0}pickFiles(e){let t=this.sessions().binding(e);t!==void 0&&this.shells.get(t)?.pickFiles()}inputTriggers(e){let t=this.sessions().binding(e);return t===void 0?void 0:this.controller(t.ctx)}sink(e,t,n,r,i,a){return t===``&&n.length===0?Promise.resolve({kind:`success`}):this.conversation().sendSession(e,t,n,r,i,a)}async steerQueue(e,t){let n=e.projections.faceOf(`inbox`).getSnapshot()?.[`next-turn`]??[];if(n.length!==0)for(let r of n){let n=await e.updateQueue(r.id,{kind:`steer`});if(!n.ok){if(n.error.code===`session/steer-unavailable`||n.error.code===`session/queue-item-not-found`)return;t.notify(`error`,this.t(`queue.steerFailed`));return}}}controller(e){if(this.sessions().sessionOf(e)!==void 0)return this.rootCtx.get(`inputTriggers`)?.sessionOf(e)}popup(e){if(this.sessions().sessionOf(e)!==void 0)return this.rootCtx.get(`commandUi`)?.popupFor(e)}sessions(){let e=this.rootCtx.get(`sessions`);if(e===void 0)throw Error(`conversation.input: sessions service unavailable`);return e}conversation(){let e=this.rootCtx.get(`conversation`);if(e===void 0)throw Error(`conversation.input: conversation service unavailable`);return e}};let fk=/* @__PURE__ */ new Map;var pk=class{runtime;unregister;textStore=(0,f.createSnapshotStore)(``);activeToken=null;modified=!1;seeding=!1;text=this.textStore;constructor(){this.runtime=new ik({onUpdate:()=>{let e=this.runtime.refreshProjection(),t=this.runtime.projection.clipboardText;e.clipboardText!==t&&(this.seeding||(this.modified=!0),this.textStore.set(t))},openReference:()=>!1,activeClaimToken:()=>null,lexicon:()=>fk,resolveLexicon:()=>void 0}),this.unregister=this.runtime.register()}get editor(){return this.runtime.editor}syncCreation(e){if(e.state===`idle`){(this.activeToken!==null||this.textStore.getSnapshot()!==``)&&(this.activeToken=null,this.clearEditor());return}let t=e.token??null;t!==this.activeToken&&(this.activeToken=t,this.seed(e.initialPrompt??``))}paste(e){this.runtime.paste(e)}take(){if(this.activeToken===null)return;let e={text:this.runtime.projection.clipboardText,modified:this.modified};return this.activeToken=null,this.clearEditor(),e}dispose(){this.activeToken=null,this.unregister()}seed(e){this.seeding=!0;try{this.modified=!1,this.runtime.setDraft(e),this.runtime.clearHistory(),this.textStore.set(this.runtime.projection.clipboardText)}finally{this.seeding=!1}}clearEditor(){this.seed(``)}};let mk=`busyEnter`,hk=[`queue`,`steer`],gk=`queue`,_k={[mk]:S.union([...hk]).default(gk)};S.object(_k);function vk(e,t,n,r){return!t||!r?`queue`:n===`enter`?e:e===`queue`?`steer`:`queue`}var yk=class{busyEnter=(0,f.createSnapshotStore)(gk);unsubscribe;host;constructor(e){this.host=e,e!==void 0&&(this.unsubscribe=e.subscribe(()=>{this.adopt(e)}),this.adopt(e))}dispose(){this.unsubscribe?.()}setBusyEnter(e){this.busyEnter.getSnapshot()!==e&&(this.busyEnter.set(e),this.host?.set(mk,e))}adopt(e){let t=e.getSnapshot().value;t!==void 0&&this.busyEnter.getSnapshot()!==t.busyEnter&&this.busyEnter.set(t.busyEnter)}};async function bk(e,t){let n=/* @__PURE__ */ new Map;for(let t of e)n.has(t.attachmentId)||n.set(t.attachmentId,t);let r=/* @__PURE__ */ new Map;return await Promise.all([...n.entries()].map(async([e,n])=>{let i=await t(n),a=await fetch(i);if(!a.ok)throw Error(`Queued image preview fetch failed (${a.status})`);r.set(e,{blob:await a.blob(),mediaType:n.mediaType})})),r}function xk(e,t,n){let{annotations:r,body:i}=DO(t);if(r.length>0&&e.addResponseAnnotations(e.takeSubmittedAnnotationAnchors(n,r)),i!==``){let t=e.draftSnapshot;e.setDraft({...t,text:t.text===``?i:`${t.text}\n${i}`})}}function Sk(e){let{sessionId:t,shell:n,conversation:r,message:i,imageBlobs:a,rpcId:o}=e,s=()=>{if(n.isDisposed)throw Error(`Queued message was removed, but the session composer was closed before restoring.`);let{phase:e}=n.snapshot;if(e!==`plain`&&e!==`claimed`)return!1;if(i.attachments.length>0){if(r===void 0)throw Error(`Queued attachments cannot be restored without a conversation controller.`);let e=i.attachments.map(e=>{if(e.kind!==`image`)return e;let t=a.get(e.file.attachmentId);if(t===void 0)return e;let n=new File([t.blob],e.file.name,{type:t.blob.type||t.mediaType||`image/png`});return{...e,imageFile:n}}),o=r.restoreStagedDrafts(t,e);if(!n.addAttachments(o.map(e=>e.id))){if(r.releaseDraftAttachments(o),n.isDisposed)throw Error(`Queued message was removed, but the session composer was closed before restoring.`);return!1}}return i.text!==``&&xk(n,i.text,o),n.actions.persistDraft(),n.focus(`end`),!0};try{if(s())return Promise.resolve()}catch(e){return Promise.reject(e)}return new Promise((e,t)=>{let r=!1,i=!1,a,o=()=>{if(!(r||i)){i=!0;try{if(!s())return;r=!0,a?.(),e()}catch(e){r=!0,a?.(),t(e)}finally{i=!1}}};a=n.state.subscribe(o),o()})}let Ck=`@deepseek-ai/dsh-client-ui-conversation/QueueDock.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(Ck)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-conversation`,e.dataset.pluginCss=Ck,e.textContent=`.ZMI-0G_dock{box-sizing:border-box;width:calc(100% - var(--dsh-composer-side-clearance) - var(--dsh-composer-side-clearance) - var(--dsh-composer-dock-inset) - var(--dsh-composer-dock-inset));max-width:calc(var(--dsh-composer-card-max-width) - var(--dsh-composer-dock-inset) - var(--dsh-composer-dock-inset));margin:0 auto calc(0px - var(--dsh-composer-stack-gap) - 3px);padding:0 var(--dsh-composer-dock-inset);flex:none}.ZMI-0G_pendingAttachment{flex-direction:column;gap:2px;display:inline-flex}.ZMI-0G_panel{z-index:0;border-radius:var(--dsw-radius-lg) var(--dsw-radius-lg) 0 0;--dsh-scrollbar-thumb:var(--dsw-alias-scrollbar-bg-l2);--dsh-scrollbar-thumb-hover:var(--dsw-alias-scrollbar-hover-l2);width:100%;padding:2px 0;position:relative;overflow:hidden}.ZMI-0G_panel:before{z-index:-1;border-radius:inherit;background:var(--dsw-specific-menu);backdrop-filter:var(--dsw-menu-backdrop-filter);content:"";pointer-events:none;position:absolute;inset:0}.ZMI-0G_panel:after{border:.5px solid var(--dsw-alias-border-l1);border-radius:inherit;content:"";pointer-events:none;border-bottom:none;position:absolute;inset:0}.ZMI-0G_paused{color:var(--dsw-alias-label-tertiary);font:var(--dsw-font-xs-13);padding:6px 12px 2px}.ZMI-0G_header{box-sizing:border-box;border-radius:var(--dsw-radius-md);width:100%;height:36px;color:var(--dsw-alias-label-primary);text-align:left;cursor:pointer;background:0 0;border:none;align-items:center;gap:10px;padding:4px 12px;display:flex}.ZMI-0G_header:focus-visible{outline:var(--dsw-focus-ring-width) solid var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary));outline-offset:-2px}.ZMI-0G_header:disabled{cursor:default}.ZMI-0G_lead{color:var(--dsw-alias-label-tertiary);flex:none;place-items:center;display:grid}.ZMI-0G_count{min-width:0;font-family:Inter, var(--dsw-font-family);flex:auto;font-size:13px;font-weight:500;line-height:24px}.ZMI-0G_chevron{width:14px;height:14px;color:var(--dsw-alias-label-tertiary);flex:none;place-items:center;display:grid}.ZMI-0G_list{max-height:180px;margin:0;padding:0;list-style:none;overflow-y:auto}.ZMI-0G_row{box-sizing:border-box;border-radius:var(--dsw-radius-md);align-items:center;gap:10px;width:100%;min-height:36px;padding:4px 5px 4px 12px;display:flex}.ZMI-0G_row+.ZMI-0G_row{box-shadow:inset 0 1px 0 var(--dsw-alias-border-l1)}.ZMI-0G_attachments{flex:none;gap:4px;min-width:0;max-width:55%;display:flex;overflow:hidden}.ZMI-0G_pendingRow .ZMI-0G_attachments{flex-shrink:1}.ZMI-0G_file{border:.5px solid var(--dsw-alias-border-l1);border-radius:var(--dsw-radius-sm);background:var(--dsw-alias-bg-base);box-sizing:border-box;flex:0 180px;align-items:center;gap:4px;min-width:74px;height:24px;padding:0 6px;display:inline-flex;overflow:hidden}.ZMI-0G_fileIcon{flex:none;width:16px;height:16px;display:inline-flex}.ZMI-0G_fileName{min-width:0;color:var(--dsw-alias-label-primary-dimmed);font:var(--dsw-font-xs-13);text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.ZMI-0G_fileSize{color:var(--dsw-alias-label-tertiary);white-space:nowrap;flex:none;font-size:10px}.ZMI-0G_thumb{border:.5px solid var(--dsw-alias-border-l1);border-radius:var(--dsw-radius-xs);background:var(--dsw-alias-bg-base);object-fit:cover;width:24px;height:24px}.ZMI-0G_annotationBadge{background:color-mix(in srgb, var(--dsw-alias-state-business-primary) 14%, transparent);height:20px;color:var(--dsw-alias-state-business-primary);white-space:nowrap;border-radius:999px;flex:none;align-items:center;padding:0 7px;font-size:11px;font-weight:500;line-height:1;display:inline-flex}.ZMI-0G_preview{min-width:0;font:var(--dsw-font-xs-13);font-family:Inter, var(--dsw-font-family);color:var(--dsw-alias-label-primary-dimmed);text-overflow:ellipsis;white-space:nowrap;word-break:break-word;flex:auto;overflow:hidden}.ZMI-0G_previewFallback{color:var(--dsw-alias-label-tertiary)}.ZMI-0G_actions{flex:none;align-items:center;gap:10px;display:flex}.ZMI-0G_actionWrap{flex:none;display:inline-flex}.ZMI-0G_actionWrap>.ZMI-0G_action:disabled{pointer-events:none}.ZMI-0G_status{color:var(--dsw-alias-label-tertiary);font:var(--dsw-font-xs-13);white-space:nowrap;flex:none}.ZMI-0G_action{corner-shape:round;width:28px;height:28px;color:var(--dsw-alias-label-tertiary);cursor:pointer;background:0 0;border:none;border-radius:999px;flex:none;place-items:center;padding:0;display:grid}.ZMI-0G_action:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-hover)}.ZMI-0G_action:focus-visible{outline:var(--dsw-focus-ring-width) solid var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary));outline-offset:-2px}.ZMI-0G_action:disabled{cursor:default;opacity:.45}`,document.head.appendChild(e)}var Z={action:`ZMI-0G_action`,actionWrap:`ZMI-0G_actionWrap`,actions:`ZMI-0G_actions`,annotationBadge:`ZMI-0G_annotationBadge`,attachments:`ZMI-0G_attachments`,chevron:`ZMI-0G_chevron`,count:`ZMI-0G_count`,dock:`ZMI-0G_dock`,file:`ZMI-0G_file`,fileIcon:`ZMI-0G_fileIcon`,fileName:`ZMI-0G_fileName`,fileSize:`ZMI-0G_fileSize`,header:`ZMI-0G_header`,lead:`ZMI-0G_lead`,list:`ZMI-0G_list`,panel:`ZMI-0G_panel`,paused:`ZMI-0G_paused`,pendingAttachment:`ZMI-0G_pendingAttachment`,pendingRow:`ZMI-0G_pendingRow`,preview:`ZMI-0G_preview`,previewFallback:`ZMI-0G_previewFallback`,row:`ZMI-0G_row`,status:`ZMI-0G_status`,thumb:`ZMI-0G_thumb`};let wk=[];function Tk(e){let t=e.replace(/\s+/g,` `).trim(),n=Array.from(t);return n.length>200?`${n.slice(0,200).join(``)}…`:t}function Ek(e,t){let n=Tk(t);if(e.length===0)return{annotations:e,preview:n,fallbackPreview:``,annotationTooltip:``};let r=e[0];return{annotations:e,preview:n,fallbackPreview:n===``?Tk(r.annotation??r.text):``,annotationTooltip:e.map((e,t)=>`${String(t+1)}. ${Tk(e.annotation??e.text)}`).join(`
167
- `)}}function Dk(e){let t=[],n=[];for(let r of e)if(r.type!==`image`&&r.type!==`file`){if(r.type===`text`){let e=DO(r.text);t.push(...e.annotations),e.body!==``&&n.push(e.body)}else n.push(`[${r.type}]`)}return Ek(t,n.join(` `))}function Ok(e){let t=DO(e);return Ek(t.annotations,t.body)}function kk({display:e,t}){return/* @__PURE__ */ (0,h.jsxs)(h.Fragment,{children:[e.annotations.length>0&&/* @__PURE__ */ (0,h.jsx)(`span`,{className:Z.annotationBadge,"data-queue-annotations":e.annotations.length,title:e.annotationTooltip,children:t(`annotation.trayCount`,{count:e.annotations.length})}),/* @__PURE__ */ (0,h.jsx)(`span`,{className:e.preview===``&&e.fallbackPreview!==``?`${Z.preview} ${Z.previewFallback}`:Z.preview,children:e.preview===``?e.fallbackPreview:(0,d.projectUserText)(e.preview,[])})]})}function Ak(e){return e.every(e=>e.type===`text`)?e.map(e=>e.text).join(``):null}function jk(e){let t=[];for(let n of e){if(n.type===`image`){let{attachment:e}=n;e!==void 0&&t.push({type:`image`,attachment:e})}if(n.type===`file`){let{attachment:e}=n;e!==void 0&&t.push({type:`file`,attachment:e})}}return t}function Mk({attachment:e,label:t}){return/* @__PURE__ */ (0,h.jsxs)(`span`,{className:Z.file,"aria-label":t,title:e.name,children:[/* @__PURE__ */ (0,h.jsx)(`span`,{className:Z.fileIcon,"aria-hidden":!0,children:/* @__PURE__ */ (0,h.jsx)(d.FileTypeIcon,{path:e.name,size:16})}),/* @__PURE__ */ (0,h.jsx)(`span`,{className:Z.fileName,children:e.name}),/* @__PURE__ */ (0,h.jsx)(`span`,{className:Z.fileSize,children:(0,d.fileSizeText)(e.bytes)})]})}function Nk({attachment:e,loadImage:t,label:n}){let[r,i]=(0,g.useState)(null);return(0,g.useEffect)(()=>{let n=!0;return t(e).then(e=>{n&&i(e)},()=>{}),()=>{n=!1}},[e,t]),r===null?/* @__PURE__ */ (0,h.jsx)(`span`,{className:Z.thumb,"aria-hidden":!0}):/* @__PURE__ */ (0,h.jsx)(`img`,{className:Z.thumb,src:r,alt:n})}function Pk({upload:e,t}){let n=(0,g.useSyncExternalStore)(e.subscribe,e.getSnapshot);return n?.status===`uploading`?/* @__PURE__ */ (0,h.jsx)(`span`,{className:Z.status,role:`status`,"data-upload-progress":!0,children:n.total===void 0||n.total===0?t(`file.uploading`):t(`file.uploadingPercent`,{percent:Math.round(Math.min(1,(n.loaded??0)/n.total)*100)})}):null}function Fk({useSession:e,useProjection:t,updateQueue:n,editQueue:r,hasStructuredQueueEdit:i,notify:a,loadImage:o,t:s}){let c=t(`inbox`),l=t(`queueState`),u=e(e=>e.pendingSubmissions),f=(0,g.useMemo)(()=>{let e=c?.[`next-turn`]??wk,t=new Set(u.filter(e=>e.placement===`transcript`).map(e=>e.requestId));return t.size===0?e:e.filter(({source:e})=>e.kind!==`user`||!(`rpcId`in e)||!t.has(e.rpcId))},[c,u]),p=(0,g.useMemo)(()=>{let e=new Set(f.flatMap(({source:e})=>e.kind===`user`&&`rpcId`in e?[e.rpcId]:[]));return u.filter(t=>t.placement===`queued`&&!e.has(t.requestId))},[u,f]),m=f.length+p.length,_=e(e=>e.running),v=e(e=>e.subagent===null||e.subagent.address.mode===`continuable`)&&l?.stale!==!0,y=l?.previewOnly===!0,b=(0,g.useRef)(!1),[ee,te]=(0,g.useState)(null),[ne,re]=(0,g.useState)(!0),ie=(0,g.useId)(),ae=l?.pausedReason??null,oe=ae===`interrupted`?s(`queue.paused.interrupted`):ae===`outcome-unknown`?s(`queue.paused.unknown`):ae===`failed`?s(`queue.paused.failed`):null;if((0,g.useEffect)(()=>{m===0&&!ne&&re(!0)},[ne,m]),m===0)return null;let se=v&&ee!==null,ce=!ne||se,le=m===1||ce,ue=async(e,t,r)=>{if(b.current)return!1;b.current=!0,te(e);try{return typeof t==`function`?await t():await n(e,t),!0}catch{return a(`error`,y?s(`queue.remoteActionFailed`):r),!1}finally{b.current=!1,te(t=>t===e?null:t)}};return/* @__PURE__ */ (0,h.jsx)(`div`,{className:Z.dock,"data-queue-dock":``,children:/* @__PURE__ */ (0,h.jsxs)(`div`,{className:Z.panel,children:[l?.stale&&/* @__PURE__ */ (0,h.jsx)(`div`,{className:Z.paused,role:`status`,children:s(`queue.remoteStale`)}),oe!==null&&/* @__PURE__ */ (0,h.jsx)(`div`,{className:Z.paused,role:`status`,children:oe}),m>1&&/* @__PURE__ */ (0,h.jsxs)(`button`,{type:`button`,className:Z.header,"aria-controls":ie,"aria-expanded":ce,disabled:se,onClick:()=>{re(e=>!e)},children:[/* @__PURE__ */ (0,h.jsx)(`span`,{className:Z.lead,"aria-hidden":!0,children:/* @__PURE__ */ (0,h.jsx)(d.IconQueueOutlineRegular,{})}),/* @__PURE__ */ (0,h.jsx)(`span`,{className:Z.count,children:s(`queue.count`,{n:m})}),!le&&p.length>0&&/* @__PURE__ */ (0,h.jsx)(`span`,{className:Z.status,role:`status`,children:s(`queue.sending`)}),/* @__PURE__ */ (0,h.jsx)(`span`,{className:Z.chevron,"aria-hidden":!0,children:ce?/* @__PURE__ */ (0,h.jsx)(d.IconChevronDownOutlineRegular,{}):/* @__PURE__ */ (0,h.jsx)(d.IconChevronUpOutlineRegular,{})})]}),/* @__PURE__ */ (0,h.jsxs)(`ul`,{id:ie,className:Z.list,hidden:!le,children:[le&&f.map(e=>{let t=jk(e.content),n=Dk(e.content),a=e.source.kind===`user`&&`rpcId`in e.source?e.source.rpcId:void 0,c=l?.editable===void 0?(()=>{let t=Ak(e.content);return t===null?null:{kind:`legacyText`,text:t,...a===void 0?{}:{rpcId:a}}})():(()=>{let n=l.editable?.[e.id];return n===void 0||!i()?null:{kind:`structured`,revision:n,images:t.flatMap(e=>e.type===`image`?[e.attachment]:[]),...a===void 0?{}:{rpcId:a}}})(),u=c!==null;return/* @__PURE__ */ (0,h.jsxs)(`li`,{className:Z.row,children:[m===1&&/* @__PURE__ */ (0,h.jsx)(`span`,{className:Z.lead,"aria-hidden":!0,children:/* @__PURE__ */ (0,h.jsx)(d.IconQueueOutlineRegular,{})}),t.length>0&&/* @__PURE__ */ (0,h.jsx)(`span`,{className:Z.attachments,children:t.map((e,t)=>e.type===`image`?/* @__PURE__ */ (0,h.jsx)(Nk,{attachment:e.attachment,loadImage:o,label:s(`queue.image`)},`${e.attachment.attachmentId}:${t}`):/* @__PURE__ */ (0,h.jsx)(Mk,{attachment:e.attachment,label:s(`queue.file`,{name:e.attachment.name})},`${e.attachment.attachmentId}:${e.attachment.name}:${t}`))}),/* @__PURE__ */ (0,h.jsx)(kk,{display:n,t:s}),v&&/* @__PURE__ */ (0,h.jsxs)(`div`,{className:Z.actions,children:[!y&&/* @__PURE__ */ (0,h.jsx)(d.Tooltip,{portal:!0,label:s(u?`queue.edit`:`queue.edit.unsupported`),side:`bottom`,delayMs:500,children:/* @__PURE__ */ (0,h.jsx)(`span`,{className:Z.actionWrap,children:/* @__PURE__ */ (0,h.jsx)(`button`,{type:`button`,className:Z.action,"aria-label":s(`queue.edit`),disabled:ee!==null||!u,onClick:()=>{c!==null&&ue(e.id,()=>r(e.id,c),s(`queue.editFailed`))},children:/* @__PURE__ */ (0,h.jsx)(d.IconEditOutlineRegular,{size:14})})})}),/* @__PURE__ */ (0,h.jsx)(d.Tooltip,{portal:!0,label:s(`queue.remove`),side:`bottom`,delayMs:500,children:/* @__PURE__ */ (0,h.jsx)(`button`,{type:`button`,className:Z.action,"aria-label":s(`queue.remove`),disabled:ee!==null,onClick:()=>{ue(e.id,{kind:`remove`},s(`queue.removeFailed`))},children:/* @__PURE__ */ (0,h.jsx)(d.IconTrashOutlineRegular,{size:14})})}),(!y||!_)&&/* @__PURE__ */ (0,h.jsx)(d.Tooltip,{portal:!0,label:s(_?`queue.steer`:`queue.resume`),side:`bottom`,delayMs:500,children:/* @__PURE__ */ (0,h.jsx)(`button`,{type:`button`,className:Z.action,"aria-label":s(_?`queue.steer`:`queue.resume`),disabled:ee!==null,onClick:()=>{ue(e.id,{kind:`steer`},s(_?`queue.steerFailed`:`queue.resumeFailed`))},children:/* @__PURE__ */ (0,h.jsx)(d.IconSendOutlineRegular,{})})})]})]},e.id)}),le&&p.map(e=>{let t=Ok(e.text);return/* @__PURE__ */ (0,h.jsxs)(`li`,{className:`${Z.row} ${Z.pendingRow}`,"data-submission-echo":``,children:[m===1&&/* @__PURE__ */ (0,h.jsx)(`span`,{className:Z.lead,"aria-hidden":!0,children:/* @__PURE__ */ (0,h.jsx)(d.IconQueueOutlineRegular,{})}),e.attachments.length>0&&/* @__PURE__ */ (0,h.jsx)(`span`,{className:Z.attachments,children:e.attachments.map((e,t)=>/* @__PURE__ */ (0,h.jsxs)(`span`,{className:Z.pendingAttachment,children:[e.type===`image`?/* @__PURE__ */ (0,h.jsx)(`img`,{className:Z.thumb,src:e.value.previewUrl,alt:s(`queue.image`)}):/* @__PURE__ */ (0,h.jsx)(Mk,{attachment:e.value,label:s(`queue.file`,{name:e.value.name})}),e.upload&&/* @__PURE__ */ (0,h.jsx)(Pk,{upload:e.upload,t:s})]},t))}),/* @__PURE__ */ (0,h.jsx)(kk,{display:t,t:s}),/* @__PURE__ */ (0,h.jsx)(`span`,{className:Z.status,role:`status`,children:s(`queue.sending`)}),v&&!y&&/* @__PURE__ */ (0,h.jsxs)(`div`,{className:Z.actions,children:[/* @__PURE__ */ (0,h.jsx)(`button`,{type:`button`,className:Z.action,"aria-label":s(`queue.edit`),title:s(`queue.sending`),disabled:!0,children:/* @__PURE__ */ (0,h.jsx)(d.IconEditOutlineRegular,{size:14})}),/* @__PURE__ */ (0,h.jsx)(`button`,{type:`button`,className:Z.action,"aria-label":s(`queue.remove`),title:s(`queue.sending`),disabled:!0,children:/* @__PURE__ */ (0,h.jsx)(d.IconTrashOutlineRegular,{size:14})}),/* @__PURE__ */ (0,h.jsx)(`button`,{type:`button`,className:Z.action,"aria-label":s(`queue.steer`),title:s(`queue.sending`),disabled:!0,children:/* @__PURE__ */ (0,h.jsx)(d.IconSendOutlineRegular,{})})]})]},e.requestId)})]})]})})}let Ik={name:`conversation-queue-dock`,inject:[`slots`,`conversation`,`sessions`,`uiConversation`],apply(e,t){e.slots.inject(`conversation.input.dock`,()=>e.slots.register({name:`conversation.input.dock`,id:`queue`,order:20,locale:ed,inject:n=>{let r=e.sessions.scope(n);if(r===void 0)throw Error(`queue dock: session "${n}" resolved no scope`);let i=r.get(`conversation`);if(i===void 0)throw Error(`queue dock: conversation service unavailable`);let a=t=>e.uiConversation.imageUrl(n,t);return{updateQueue:(e,t)=>i.updateQueue(e,t),hasStructuredQueueEdit:()=>{let t=e.get(`conversation`);return e.get(`queueMessageEditing`)!==void 0&&typeof t?.restoreStagedDrafts==`function`},editQueue:async(r,o)=>{let s=e.sessions.retain(n,{source:`controllerOperation`});try{let s=t.shell(n);if(o.kind===`legacyText`){await i.updateQueue(r,{kind:`remove`}),await Sk({sessionId:n,shell:s,message:{text:o.text,attachments:[]},imageBlobs:/* @__PURE__ */ new Map,...o.rpcId===void 0?{}:{rpcId:o.rpcId}});return}let c=e.get(`queueMessageEditing`),l=e.get(`conversation`);if(c===void 0||typeof l?.restoreStagedDrafts!=`function`)throw Error(`queue dock: structured queue editing unavailable`);let u=o.images.length>0?await bk(o.images,a):/* @__PURE__ */ new Map;if(s.isDisposed)throw Error(`queue dock: session composer closed before editing`);await Sk({sessionId:n,shell:s,conversation:l,message:await c.takeForEdit(n,r,o.revision),imageBlobs:u,...o.rpcId===void 0?{}:{rpcId:o.rpcId}})}finally{s.release()}},notify:(t,a)=>{e.sessions.scope(n)===r&&i.input.for(r).notify(t,a)},loadImage:a}}},Fk))}},Lk=`@deepseek-ai/dsh-client-ui-conversation/EnterBehaviorRow.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(Lk)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-conversation`,e.dataset.pluginCss=Lk,e.textContent=`.v-9l-a_row{border-bottom:.5px solid var(--dsw-alias-border-l2);align-items:center;gap:8px;padding:16px 0;display:flex}.v-9l-a_rowText{flex-direction:column;flex:1;gap:4px;min-width:0;padding-right:48px;display:flex}.v-9l-a_title{color:var(--dsw-alias-label-primary);font-size:14px;font-weight:400;line-height:22px}.v-9l-a_desc{color:var(--dsw-alias-label-tertiary);font-size:12px;font-weight:400;line-height:18px}.v-9l-a_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}.v-9l-a_selector:hover{background:var(--dsw-alias-interactive-bg-hover)}.v-9l-a_chevron{flex:none}`,document.head.appendChild(e)}var Rk={chevron:`v-9l-a_chevron`,desc:`v-9l-a_desc`,row:`v-9l-a_row`,rowText:`v-9l-a_rowText`,selector:`v-9l-a_selector`,title:`v-9l-a_title`};let zk=[{id:`queue`,label:`settings.enter.queue`},{id:`steer`,label:`settings.enter.steer`}];function Bk({useBusyEnter:e,setBusyEnter:t,t:n}){let r=e(e=>e),[i,a]=(0,g.useState)(!1),o=r===`queue`?`settings.enter.queue`:`settings.enter.steer`;return/* @__PURE__ */ (0,h.jsxs)(`div`,{className:Rk.row,children:[/* @__PURE__ */ (0,h.jsxs)(`div`,{className:Rk.rowText,children:[/* @__PURE__ */ (0,h.jsx)(`div`,{className:Rk.title,children:n(`settings.enter.title`)}),/* @__PURE__ */ (0,h.jsx)(`div`,{className:Rk.desc,children:n(`settings.enter.description`)})]}),/* @__PURE__ */ (0,h.jsx)(d.Menu,{open:i,onClose:()=>{a(!1)},items:zk.map(e=>({id:e.id,label:n(e.label)})),selectedId:r,onSelect:e=>{a(!1),t(e)},align:`end`,portal:!0,anchor:/* @__PURE__ */ (0,h.jsxs)(`button`,{type:`button`,className:Rk.selector,"aria-haspopup":`menu`,"aria-expanded":i,onClick:()=>{a(e=>!e)},children:[n(o),/* @__PURE__ */ (0,h.jsx)(d.IconChevronDownOutlineRegular,{className:Rk.chevron})]})})]})}let Vk={views:{get:()=>void 0,grouped:()=>void 0},activeTargets:/* @__PURE__ */ new Set};function Hk(e,t){return t.activeTargets.size>0||!e.blank&&!e.awaitingFirstTurn||e.running?`active`:e.promptAttempted?`engaging`:`blank`}let Uk=`@deepseek-ai/dsh-client-ui-conversation/ConversationRoot.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(Uk)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-conversation`,e.dataset.pluginCss=Uk,e.textContent=`.vbpo1q_root{background:var(--dsw-alias-bg-base);flex-direction:column;min-width:0;height:100%;display:flex;position:relative}body[data-codexhost-wallpaper] .vbpo1q_root{background:0 0}.vbpo1q_header{box-sizing:border-box;flex:none;grid-template-columns:auto minmax(0,1fr);min-height:76px;padding:10px 28px 0 20px;display:grid}.vbpo1q_header:where(:not(:has(.vbpo1q_tabs))){min-height:0;padding:10px 24px 6px 20px}[data-windows-titlebar] .vbpo1q_header:where(:not(:has(.vbpo1q_tabs))){padding-top:8px;padding-bottom:4px}.vbpo1q_headerBlank{border-bottom:none;min-height:0;padding-bottom:0}.vbpo1q_headerBlank .vbpo1q_headerCorner{margin-left:auto}html:not([data-platform=darwin]) .vbpo1q_headerSessionless{padding-top:0}html:not([data-platform=darwin]) .vbpo1q_headerSessionless .vbpo1q_titleRow{min-height:0}[data-platform=darwin] .vbpo1q_headerLeading,[data-platform=darwin] .vbpo1q_headerActions,[data-platform=darwin] .vbpo1q_headerUtilities,[data-platform=darwin] .vbpo1q_headerCorner{-webkit-app-region:no-drag}.vbpo1q_titleRow{min-height:30px;grid-column:2;align-items:center;gap:0;padding-inline-start:max(0px, calc(var(--dsh-frame-leading-clearance,0px) - 20px));display:flex;container-type:inline-size}.vbpo1q_titleCenter{display:contents}.vbpo1q_phoneTrailingAction{display:none}.vbpo1q_titleCluster{flex:1;align-items:center;gap:10px;min-width:0;display:flex}.vbpo1q_headerLeading{flex:none;grid-area:1/1;align-items:center;gap:8px;display:flex}.vbpo1q_crumbs{white-space:nowrap;align-items:center;gap:4px;min-width:0;display:flex;overflow:hidden}.vbpo1q_crumbSeg{align-items:center;gap:4px;min-width:0;display:inline-flex}.vbpo1q_crumbSep{color:var(--dsw-alias-label-caption);font-size:14px;line-height:20px}.vbpo1q_crumb{border-radius:var(--dsw-radius-md);max-width:220px;color:var(--dsw-alias-label-tertiary);text-overflow:ellipsis;white-space:nowrap;cursor:pointer;background:0 0;border:none;padding:4px 8px;font-size:14px;line-height:20px;display:inline-block;overflow:hidden}.vbpo1q_crumbSubagent{font-size:12px;line-height:18px}button.vbpo1q_crumb:hover{background:var(--dsw-alias-interactive-bg-hover)}.vbpo1q_crumbCurrent{color:var(--dsw-alias-label-primary);cursor:default;font-weight:500}.vbpo1q_headerActions{flex:none;align-items:center;gap:8px;display:flex}.vbpo1q_headerUtilities{flex:none;align-items:center;gap:8px;margin-left:20px;display:flex}.vbpo1q_headerUtilities:empty{display:none}.vbpo1q_headerCorner{flex:none;align-items:center;margin-left:8px;margin-right:-16px;display:flex}.vbpo1q_headerCorner:empty,.vbpo1q_headerCorner:not(:has([data-slot="conversation.session.header.corner"]>*)){display:none}[data-phone] .vbpo1q_root[data-phase=active]{--dsh-phone-header-height:calc(env(safe-area-inset-top) + 44px)}[data-phone] .vbpo1q_root[data-phase=active]:has([data-slot="conversation.header.shortcuts"] nav){--dsh-phone-header-height:calc(env(safe-area-inset-top) + 88px)}[data-phone] .vbpo1q_header{z-index:8;padding-top:env(safe-area-inset-top);background:0 0;border-bottom:none;row-gap:0;padding-bottom:0;position:relative}[data-phone] .vbpo1q_root[data-phase=active] .vbpo1q_header{pointer-events:none;position:absolute;top:0;left:0;right:0}[data-phone] .vbpo1q_root[data-phase=active] .vbpo1q_header [data-slot="conversation.header.shortcuts"]{pointer-events:auto}[data-phone] .vbpo1q_root[data-phase=active]:not(:has([data-slot="conversation.header.notice"]>*)) .vbpo1q_scrollBody{padding-top:var(--dsh-phone-header-height)}[data-phone] .vbpo1q_root[data-phase=active]>[data-slot="conversation.header.notice"]>*{z-index:5;position:relative}[data-phone] .vbpo1q_root[data-phase=active]>[data-slot="conversation.header.notice"]>:first-child{margin-top:var(--dsh-phone-header-height)}[data-phone] .vbpo1q_root[data-phase=active] .vbpo1q_header:before{content:"";height:calc(var(--dsh-phone-header-height) + 32px);z-index:-1;background:linear-gradient(180deg, color-mix(in srgb, var(--dsw-alias-bg-base) 78%, transparent) 0%, color-mix(in srgb, var(--dsw-alias-bg-base) 58%, transparent) 44%, color-mix(in srgb, var(--dsw-alias-bg-base) 24%, transparent) 74%, transparent 100%);pointer-events:none;position:absolute;top:0;left:0;right:0}@supports (backdrop-filter:blur(16px)){[data-phone] .vbpo1q_root[data-phase=active] .vbpo1q_header:before{backdrop-filter:blur(16px)saturate(140%);-webkit-mask-image:linear-gradient(#000 0%,#000000eb 42%,#0000008f 62%,#00000038 78%,#0000000d 91%,#0000 100%);mask-image:linear-gradient(#000 0%,#000000eb 42%,#0000008f 62%,#00000038 78%,#0000000d 91%,#0000 100%)}}body[data-codexhost-wallpaper] [data-phone] .vbpo1q_root[data-phase=active] .vbpo1q_header:before{background:linear-gradient(180deg, color-mix(in srgb, var(--dsw-alias-bg-base) 64%, transparent) 0%, color-mix(in srgb, var(--dsw-alias-bg-base) 42%, transparent) 44%, color-mix(in srgb, var(--dsw-alias-bg-base) 16%, transparent) 74%, transparent 100%)}[data-phone] .vbpo1q_headerLeading{display:none}[data-phone] .vbpo1q_titleRow{grid-area:1/1/auto/-1;grid-template-columns:minmax(80px,1fr) minmax(0,auto) minmax(80px,1fr);align-items:center;gap:6px;min-height:44px;margin-inline:-8px -16px;padding-inline-start:0;display:grid}[data-phone] .vbpo1q_titleCluster{grid-column:2;justify-content:center;align-items:center;gap:4px;min-width:0;max-width:100%;display:flex}[data-phone] .vbpo1q_titleCenter{pointer-events:auto;border-radius:8px;justify-content:center;align-items:center;gap:4px;min-width:0;max-width:100%;min-height:36px;padding:0 2px;transition:opacity .12s;display:inline-flex;position:relative}[data-phone] .vbpo1q_root[data-phase=active] .vbpo1q_titleCenter:before{content:"";z-index:-1;background:radial-gradient(closest-side, color-mix(in srgb, var(--dsw-alias-bg-base) 88%, transparent) 38%, color-mix(in srgb, var(--dsw-alias-bg-base) 42%, transparent) 72%, transparent 100%);pointer-events:none;position:absolute;inset:-4px -22px}body[data-codexhost-wallpaper] [data-phone] .vbpo1q_root[data-phase=active] .vbpo1q_titleCenter:before{background:radial-gradient(closest-side, color-mix(in srgb, var(--dsw-alias-bg-base) 68%, transparent) 38%, color-mix(in srgb, var(--dsw-alias-bg-base) 28%, transparent) 72%, transparent 100%)}body[data-codexhost-wallpaper][data-ds-dark-theme] [data-phone] .vbpo1q_titleCenter{text-shadow:0 1px 10px #0000006b}[data-phone] .vbpo1q_titleCenter:has([data-navigation-focus-return]){cursor:pointer;-webkit-tap-highlight-color:transparent}[data-phone] .vbpo1q_titleRow>.vbpo1q_titleCenter,[data-phone] .vbpo1q_titleRow>[data-slot="conversation.header.navigation"]{pointer-events:auto;grid-column:2;justify-self:center}[data-phone] .vbpo1q_titleCenter>[data-slot="conversation.header.navigation"]{display:contents}[data-phone] .vbpo1q_titleCenter:has([data-navigation-focus-return]):active{opacity:.52}[data-phone] .vbpo1q_titleCenter:has([data-navigation-focus-return]:focus-visible){outline:none}@media (hover:hover) and (pointer:fine){[data-phone] .vbpo1q_titleCenter:has([data-navigation-focus-return]:focus-visible){outline:2px solid var(--dsw-alias-label-primary);outline-offset:2px}}[data-phone] .vbpo1q_crumbs{justify-content:center;gap:3px}[data-phone] .vbpo1q_crumb{letter-spacing:-.015em;max-width:none;padding:0;font-size:15px;font-weight:600;line-height:20px}[data-phone] button.vbpo1q_crumb{z-index:1;position:relative}[data-phone] .vbpo1q_headerActions:not(:has(button)),[data-phone] .vbpo1q_headerUtilities{display:none}[data-phone] .vbpo1q_phoneTrailingAction,[data-phone] .vbpo1q_headerCorner>[data-slot="conversation.session.header.corner"],[data-phone] .vbpo1q_phoneTrailingAction>[data-slot="conversation.header.trailing"]{display:contents}[data-phone] .vbpo1q_headerCorner:has(button){box-sizing:border-box;corner-shape:round;pointer-events:auto;background:#ffffffd6;border:.5px solid #0f11151a;border-radius:9999px;grid-column:3;justify-content:center;justify-self:end;align-items:center;gap:2px;height:36px;margin:0;padding:0 3px;display:inline-flex;box-shadow:inset 0 1px #ffffffb8,inset 0 -.5px #ffffff47,inset 0 0 0 .5px #ffffff38,0 1px 2px #0f11150d,0 6px 18px -4px #0f11151c}[data-phone] .vbpo1q_headerCorner:has(button):not(:has([data-phone-new-session]):has([data-sidebar-right-expand])){width:36px;padding:0}[data-ds-dark-theme] [data-phone] .vbpo1q_headerCorner:has(button){background:#24262cc7;border-color:#ffffff24;box-shadow:inset 0 1px #ffffff47,inset 0 -.5px #ffffff14,0 2px 8px #00000042,0 8px 22px -6px #0000006b}@supports (backdrop-filter:blur(8px)){[data-phone] .vbpo1q_headerCorner:has(button){backdrop-filter:blur(8px)saturate(180%);background:linear-gradient(#ffffff38 0%,#ffffff17 100%);box-shadow:inset 0 1px .5px #ffffffd9,inset 0 -.5px #0f11150f,0 1px 2px #0f11150f,0 6px 16px -4px #0f11151f}[data-ds-dark-theme] [data-phone] .vbpo1q_headerCorner:has(button){backdrop-filter:blur(10px)saturate(180%);background:linear-gradient(#ffffff1f 0%,#ffffff0d 100%)}}@media (prefers-reduced-motion:reduce){[data-phone] .vbpo1q_titleCenter{transition:none}}@media (prefers-reduced-transparency:reduce),(prefers-contrast:more){[data-phone] .vbpo1q_root[data-phase=active] .vbpo1q_header{pointer-events:auto;background:var(--dsw-alias-bg-base);border-bottom:.5px solid var(--dsw-alias-border-l3);position:relative}[data-phone] .vbpo1q_root[data-phase=active] .vbpo1q_header:before{display:none}[data-phone] .vbpo1q_root[data-phase=active]:not(:has([data-slot="conversation.header.notice"]>*)) .vbpo1q_scrollBody{padding-top:0}[data-phone] .vbpo1q_root[data-phase=active]>[data-slot="conversation.header.notice"]>:first-child{margin-top:0}[data-phone] .vbpo1q_headerCorner:has(button),[data-ds-dark-theme] [data-phone] .vbpo1q_headerCorner:has(button){border:1px solid var(--dsw-alias-border-l3);background:var(--dsw-alias-bg-layer-1);backdrop-filter:none;box-shadow:0 1px 2px #00000014}}@media (prefers-contrast:more){[data-phone] .vbpo1q_headerCorner:has(button),[data-ds-dark-theme] [data-phone] .vbpo1q_headerCorner:has(button){border-color:var(--dsw-alias-label-secondary);box-shadow:none}}@media (forced-colors:active){[data-phone] .vbpo1q_root[data-phase=active] .vbpo1q_header{pointer-events:auto;background:canvas;border-bottom:1px solid canvastext;position:relative}[data-phone] .vbpo1q_root[data-phase=active] .vbpo1q_header:before{display:none}[data-phone] .vbpo1q_root[data-phase=active]:not(:has([data-slot="conversation.header.notice"]>*)) .vbpo1q_scrollBody{padding-top:0}[data-phone] .vbpo1q_root[data-phase=active]>[data-slot="conversation.header.notice"]>:first-child{margin-top:0}[data-phone] .vbpo1q_headerCorner:has(button),[data-ds-dark-theme] [data-phone] .vbpo1q_headerCorner:has(button){backdrop-filter:none;box-shadow:none;background:buttonface;border:1px solid buttontext}}.vbpo1q_tabs{z-index:1;grid-column:1/-1;gap:36px;margin-top:10px;padding-left:8px;display:flex;position:relative}.vbpo1q_tab{color:var(--dsw-alias-label-tertiary);cursor:pointer;background:0 0;border:none;padding:0 0 9px;font-size:13px;font-weight:500;line-height:16px;position:relative}.vbpo1q_tab:after{content:"";background:0 0;border-radius:2px;height:2px;position:absolute;bottom:0;left:0;right:0}.vbpo1q_tabActive{color:var(--dsw-alias-state-business-primary)}.vbpo1q_tabActive:after{background:var(--dsw-alias-state-business-primary)}.vbpo1q_viewArea{flex-direction:column;flex:1;min-height:0;display:flex}.vbpo1q_widthHandle{z-index:0;width:min(10px, calc((100% - var(--dsh-chat-content-width)) / 2 - 24px - 24px));cursor:col-resize;position:absolute;top:0;bottom:0}.vbpo1q_widthHandle[data-side=left]{right:calc(50% + var(--dsh-chat-content-width) / 2 + 24px)}.vbpo1q_widthHandle[data-side=right]{left:calc(50% + var(--dsh-chat-content-width) / 2 + 24px)}.vbpo1q_widthHandle:after{content:"";background:linear-gradient(to bottom, transparent calc(var(--dsh-width-handle-pointer-y,50%) - 36px), var(--dsw-alias-scrollbar-bg-l1) calc(var(--dsh-width-handle-pointer-y,50%) - 8px), var(--dsw-alias-scrollbar-bg-l1) calc(var(--dsh-width-handle-pointer-y,50%) + 8px), transparent calc(var(--dsh-width-handle-pointer-y,50%) + 36px));opacity:0;pointer-events:none;border-radius:2px;width:2px;position:absolute;top:0;bottom:0}.vbpo1q_widthHandle[data-side=left]:after{right:4px}.vbpo1q_widthHandle[data-side=right]:after{left:4px}.vbpo1q_widthHandle:hover:after,.vbpo1q_widthHandle[data-dragging]:after{opacity:1}.vbpo1q_widthHandle[data-dragging]{z-index:8}.vbpo1q_root:has([data-conversation-composer-overlay]) .vbpo1q_widthHandle{display:none}.vbpo1q_composerStack{--dsh-composer-stack-gap:6px;gap:var(--dsh-composer-stack-gap);flex-direction:column;display:flex}.vbpo1q_composerSeat{-webkit-user-select:none;user-select:none;--dsh-composer-text-max-height:336px;flex-direction:column;flex:none;display:flex}.vbpo1q_composerSeat :is(input,textarea,[contenteditable=true],[contenteditable=""]){-webkit-user-select:text;user-select:text}.vbpo1q_root[data-phase=active]{overflow:hidden}.vbpo1q_root[data-phase=active] .vbpo1q_header{flex:none}.vbpo1q_body{--dsh-chat-content-width:var(--dsh-chat-user-width,clamp(680px, calc(var(--dsh-conversation-column-width,0px) * .64), 920px));--dsh-composer-card-max-width:calc(var(--dsh-chat-content-width) + 32px);--dsh-composer-side-clearance:16px;--dsh-composer-dock-inset:8px;flex-direction:column;flex:1;min-height:0;display:flex;position:relative}.vbpo1q_embeddedBody{--dsh-chat-content-width:min(calc(100% - 32px), 920px);--dsh-composer-card-max-width:min(calc(100% - 16px), 952px);--dsh-composer-side-clearance:8px;--dsh-composer-dock-inset:8px;overflow:hidden}.vbpo1q_scrollBody{scrollbar-gutter:stable;flex-direction:column;flex:1;min-height:0;margin-right:2px;display:flex;overflow:hidden auto}.vbpo1q_scrollBody::-webkit-scrollbar-track{margin:2px}.vbpo1q_root[data-phase=active] .vbpo1q_viewArea,.vbpo1q_embeddedBody[data-content-phase=active] .vbpo1q_viewArea{flex:1 0 auto;min-height:auto}.vbpo1q_root[data-phase=active] .vbpo1q_composerSeat,.vbpo1q_embeddedBody[data-content-phase=active] .vbpo1q_composerSeat{z-index:7;background:var(--dsh-phone-composer-mask,linear-gradient(180deg, color-mix(in srgb, var(--dsw-alias-bg-base) 0%, transparent) 0px, var(--dsw-alias-bg-base) 36px));margin-top:auto;position:sticky;bottom:0}@supports (backdrop-filter:blur(14px)){[data-phone] .vbpo1q_composerSeat:where(:has([data-chain-overlay-fallback=conversation\\.composer]:only-child [data-composer-card])){--dsh-phone-composer-mask:linear-gradient(180deg, transparent 0px, color-mix(in srgb, var(--dsw-alias-bg-base) 60%, transparent) 36px, color-mix(in srgb, var(--dsw-alias-bg-base) 60%, transparent) calc(100% - 28px), var(--dsw-alias-bg-base) 100%)}}@media (prefers-reduced-transparency:reduce),(prefers-contrast:more),(forced-colors:active){[data-phone] .vbpo1q_composerSeat{--dsh-phone-composer-mask:initial}}body[data-codexhost-wallpaper] .vbpo1q_root[data-phase=active] .vbpo1q_composerSeat,body[data-codexhost-wallpaper] .vbpo1q_embeddedBody[data-content-phase=active] .vbpo1q_composerSeat{background:0 0}.vbpo1q_root[data-phase=active] .vbpo1q_composerSeat:has([data-trigger-menu]){z-index:9}.vbpo1q_scrollBody[data-selection-drag]{scroll-padding-bottom:var(--dsh-composer-height,0px)}.vbpo1q_scrollBody[data-selection-drag]>.vbpo1q_composerSeat :is(input,textarea,[contenteditable=true],[contenteditable=""]){pointer-events:none}.vbpo1q_scrollBody:has([data-conversation-composer-overlay]){scrollbar-gutter:auto;position:relative;overflow:hidden auto}.vbpo1q_scrollBody:has([data-conversation-composer-overlay])>[data-slot=conversation\\.session]>.vbpo1q_viewArea{flex:1 1 0;min-height:0;overflow:hidden}.vbpo1q_scrollBody:has([data-conversation-composer-overlay])>.vbpo1q_composerSeat{right:var(--dsh-scrollbar-width);position:absolute;bottom:0;left:0}.vbpo1q_composerHero{width:min(calc(var(--dsh-composer-card-max-width) + 2 * var(--dsh-composer-side-clearance)), 100%);z-index:1;align-self:center;gap:16px;padding-bottom:32px}.vbpo1q_heroTopBarInner{align-items:center;gap:4px;width:100%;min-width:0;display:flex}.vbpo1q_heroAgentPresetSeat{flex:none;align-items:center;margin-left:auto;display:flex}.vbpo1q_heroAgentPresetSeat:empty{display:none}.vbpo1q_root[data-phase=hero] .vbpo1q_scrollBody,.vbpo1q_embeddedBody[data-content-phase=hero] .vbpo1q_scrollBody{justify-content:center;overflow-y:auto}.vbpo1q_root[data-phase=settling] .vbpo1q_composerSeat,.vbpo1q_embeddedBody[data-content-phase=settling] .vbpo1q_composerSeat{visibility:hidden}`,document.head.appendChild(e)}var Q={body:`vbpo1q_body`,composerHero:`vbpo1q_composerHero`,composerSeat:`vbpo1q_composerSeat`,composerStack:`vbpo1q_composerStack`,crumb:`vbpo1q_crumb`,crumbCurrent:`vbpo1q_crumbCurrent`,crumbSeg:`vbpo1q_crumbSeg`,crumbSep:`vbpo1q_crumbSep`,crumbSubagent:`vbpo1q_crumbSubagent`,crumbs:`vbpo1q_crumbs`,embeddedBody:`vbpo1q_embeddedBody`,header:`vbpo1q_header`,headerActions:`vbpo1q_headerActions`,headerBlank:`vbpo1q_headerBlank`,headerCorner:`vbpo1q_headerCorner`,headerLeading:`vbpo1q_headerLeading`,headerSessionless:`vbpo1q_headerSessionless`,headerUtilities:`vbpo1q_headerUtilities`,heroAgentPresetSeat:`vbpo1q_heroAgentPresetSeat`,heroTopBarInner:`vbpo1q_heroTopBarInner`,phoneTrailingAction:`vbpo1q_phoneTrailingAction`,root:`vbpo1q_root`,scrollBody:`vbpo1q_scrollBody`,tab:`vbpo1q_tab`,tabActive:`vbpo1q_tabActive`,tabs:`vbpo1q_tabs`,titleCenter:`vbpo1q_titleCenter`,titleCluster:`vbpo1q_titleCluster`,titleRow:`vbpo1q_titleRow`,viewArea:`vbpo1q_viewArea`,widthHandle:`vbpo1q_widthHandle`};let Wk=`dsh.conversation.contentWidth`;function Gk(){let e=localStorage.getItem(Wk);if(e===null)return null;let t=Number(e);return Number.isFinite(t)&&t>0?t:null}function Kk(e,t){let n=Math.max(640,e-176);return t===null?Math.max(680,Math.min(e*.64,920)):Math.min(Math.max(t,640),n)}function qk(e,t){if(e.deltaMode===1){let n=Number.parseFloat(getComputedStyle(t).lineHeight);return e.deltaY*(Number.isFinite(n)?n:16)}return e.deltaMode===2?e.deltaY*t.clientHeight:e.deltaY}function Jk(e){let t=(0,g.useRef)(!1),n=(0,g.useRef)(0),r=(0,g.useRef)(0),i=(0,g.useRef)(0),a=(0,g.useRef)(null),o=(0,g.useRef)(e);o.current=e;let s=()=>{let e=i.current-r.current,t=o.current.side===`right`?e:-e;return n.current+t*2},c=()=>{a.current!==null&&(cancelAnimationFrame(a.current),a.current=null)},l=(0,g.useCallback)(e=>{e.button===0&&(e.preventDefault(),e.currentTarget.setPointerCapture(e.pointerId),r.current=e.clientX,i.current=e.clientX,n.current=o.current.onStart(),t.current=!0,e.currentTarget.toggleAttribute(`data-dragging`,!0))},[]),u=(0,g.useCallback)(e=>{if(!t.current||!e.currentTarget.hasPointerCapture(e.pointerId))return;let n=e.currentTarget.getBoundingClientRect();e.currentTarget.style.setProperty(`--dsh-width-handle-pointer-y`,`${e.clientY-n.top}px`),i.current=e.clientX,a.current??=requestAnimationFrame(()=>{a.current=null,o.current.onDrag(s())})},[]),d=(0,g.useCallback)(e=>{t.current&&e.currentTarget.hasPointerCapture(e.pointerId)&&(t.current=!1,e.currentTarget.toggleAttribute(`data-dragging`,!1),e.currentTarget.releasePointerCapture(e.pointerId),c(),i.current=e.clientX,i.current!==r.current&&o.current.onCommit(s()),o.current.onEnd())},[]),f=(0,g.useCallback)(e=>{t.current&&(t.current=!1,e.currentTarget.toggleAttribute(`data-dragging`,!1),c(),o.current.onEnd())},[]),p=(0,g.useCallback)(e=>{let t=e.currentTarget.parentElement;
166
+ `),t+=i.draft;for(let t of i.occurrences)n.push({...t,offset:e+t.offset})}let i=new Set(r.map(e=>e.id));this.responseAnnotations=[...r,...this.responseAnnotations.filter(e=>!i.has(e.id))],this.restoringFailures=!0;try{this.draftEditor.restoreDraft(t,n),this.draftEditor.clearHistory(),this.failedRestoreRev=this.rev}finally{this.restoringFailures=!1}this.publish()}restoreAttachments(e){if(e.length===0)return;let t=new Set(this.attachmentIds),n=e.filter(e=>!t.has(e));n.length!==0&&(this.attachmentIds=[...n,...this.attachmentIds],this.publish())}adjudicate(e,t){let n=this.deps.inputTriggers?.();n===void 0?this.dispatchRun({type:`adjudicated`,attempt:e,outcome:void 0}):(this.adjudication=n.adjudicate(t.trim(),e.signal,{attachments:this.attachmentIds.length}),this.adjudication.then(t=>{this.adjudication=void 0,!this.dead(e)&&this.dispatchRun({type:`adjudicated`,attempt:e,outcome:t})},t=>{if(this.adjudication=void 0,this.dead(e))return;let n=t instanceof Error?t.message:String(t);this.dispatchRun({type:`adjudication-failed`,attempt:e,message:n})}))}beginSubmit(e,t,n){let r=t.attachments===!0?[...this.attachmentIds]:[];Promise.resolve().then(async()=>{let i=r.length>0?await this.deps.commandAttachments.serialize(r):[];if(!this.dead(e))return t.submit(n,this.deps.actx,i)}).then(t=>{if(!(t===void 0||this.dead(e))){if(t.kind===`success`&&r.length>0){let e=new Set(r);this.attachmentIds=this.attachmentIds.filter(t=>!e.has(t)),this.deps.commandAttachments.release(r)}this.dispatchRun({type:`submit-settled`,attempt:e,ok:t.kind===`success`,draft:this.projection.clipboardText,outcome:t,...t.kind===`error`&&t.text===void 0?{message:`command failed`}:{}})}},t=>{if(this.dead(e))return;let n=t instanceof Error?t.message:String(t);this.dispatchRun({type:`submit-settled`,attempt:e,ok:!1,draft:this.projection.clipboardText,message:n})})}dead(e){return this.disposed||e.signal.aborted}compose(){let e=this.core.state;return{draft:this.projection.clipboardText,attachmentIds:this.attachmentIds,responseAnnotations:this.responseAnnotations,...this.hoveredResponseAnnotationId===void 0?{}:{hoveredResponseAnnotationId:this.hoveredResponseAnnotationId},draftRev:this.rev,...this.primaryAction===void 0?{}:{primaryAction:this.primaryAction},phase:e.phase,...e.claim===void 0?{}:{claim:e.claim},occurrences:this.projection.occurrences,queue:this.deps.inbox?.getSnapshot()?.[`next-turn`]??rA}}publish(){let e=this.compose();this.state.set(e);let t=this.draftSnapshot;t!==this.lastPublishedDraft&&(this.lastPublishedDraft=t,this.scheduleDraftPersistence(t))}};function oA(e,t){let{state:n,timestamp:r,mode:i}=t;if(n===void 0)return;let a=n.model;e.get(`productAnalytics`)?.track(`send_button_click`,{...n.sessionId===void 0?{}:{session_id:n.sessionId},...a===void 0?{}:{model_name:`${a.provider}/${a.name}`,...a.effort===void 0?{}:{thinking_effort:a.effort}},run_mode:n.runMode,msg_type:n.running?i:`default`},r)}var sA=class{rootCtx;t;pendingDraft;shells=/* @__PURE__ */ new WeakMap;constructor(e,t,n){this.rootCtx=e,this.t=t,this.pendingDraft=n}for(e){let t=this.sessions(),n=t.sessionOf(e),r=n===void 0?void 0:t.binding(n.sessionId);if(r===void 0||r.session!==n)throw Error(`conversation.input.for requires a retained Session scope`);return this.shellFor(r)}captureReferenceInsertion(e){let t=this.sessions(),n=this.shells.get(e);if(t.binding(e.sessionId)!==e||n===void 0)return;let r=this.rootCtx.get(`conversation`);if(r===void 0)return;let i=n.actions.captureInsertion(),a=r.blocks.storeFor(e.sessionId),o=this.rootCtx.uiSession.sessionStatus,s=!1,c=()=>{let r=e.session.getSnapshot();return!s&&t.binding(e.sessionId)===e&&r.openState===`open`&&!r.removed&&a.getSnapshot()===void 0&&o.getSnapshot().get(e.sessionId)?.pendingInteraction===void 0&&n.snapshot.draftRev===i.draftRev&&n.canInsertReferences()};return{getSnapshot:c,subscribe:r=>{let i=[t.list.subscribe(r),e.session.subscribe(r),n.state.subscribe(r),a.subscribe(r),o.subscribe(r),n.editor.registerEditableListener(r),n.editor.registerRootListener(r)];return()=>i.forEach(e=>e())},insert:e=>{let t=c();return s=!0,t&&n.insertReferences([e],i)}}}requestDraftInitialization(e,t){if(this.sessions().binding(e.sessionId)!==e)throw Error(`conversation.input.requestDraftInitialization requires a retained Session binding`);return this.shellFor(e).requestDraftInitialization(t)}adoptPendingDraft(e,t){if(this.sessions().binding(e.sessionId)!==e)throw Error(`conversation.input.adoptPendingDraft requires a retained Session binding`);let n=this.pendingDraft?.take(),r=this.shellFor(e);return t===void 0?n!==void 0&&n.text!==``?(r.setDraft(n.text),`applied`):`preserved`:n?.modified?r.requestDraftInitialization({prompt:n.text,clearPreviousDraft:!0}):r.requestDraftInitialization(t)}shellFor(e){let t=this.shells.get(e);if(t!==void 0)return t;let{session:n,ctx:r}=e,i=new aA({actx:r,submissionState:()=>{let e=n.getSnapshot(),t=n.projections.faceOf(`modelSelection`).getSnapshot(),r=n.projections.faceOf(`plan`).getSnapshot(),i=n.projections.faceOf(`goal`).getSnapshot(),a=t?.next??t?.lastUsed;return Object.freeze({...e.blank?{}:{sessionId:e.sessionId},...a==null?{}:{model:Object.freeze({provider:a.provider,name:a.model,...a.reasoningEffort===void 0?{}:{effort:a.reasoningEffort}})},runMode:r?.active?`plan`:i?.goal.phase===`active`?`goal`:`default`,running:e.running})},messageSubmitted:e=>{oA(this.rootCtx,e)},inputTriggers:()=>this.controller(r),popup:()=>this.popup(r),inbox:n.projections.faceOf(`inbox`),defaultSink:(e,t,r,i,a)=>this.sink(n,e,t,r,i,a),steerQueue:()=>{this.steerQueue(n,i)},commandAttachments:{serialize:async e=>(await this.conversation().serializeDraftAttachments(e)).attachments,release:e=>{let t=this.rootCtx.get(`conversation`);for(let n of e)t?.releaseDraftAttachment(n)},unsupportedNotice:e=>this.t(`command.attachmentsUnsupported`,{command:e.trim().replace(/^\//u,``)})}});return this.shells.set(e,i),r.effect(()=>{let t=[r.on(`slash/input-begin-command`,e=>i.beginCommand(e.claim,e.span)?!0:void 0),r.on(`slash/input-insert-reference`,e=>i.insertReference(e.reference,e.span)?!0:void 0),r.on(`slash/input-consume-token`,e=>i.consumeToken(e.guard)?!0:void 0),r.on(`slash/input-insert-text`,e=>i.insertText(e.text,e.span,e.continue===!0)?!0:void 0)];return()=>{for(let e of t)e();let n=i.dispose();this.shells.delete(e);let r=this.rootCtx.get(`conversation`);for(let e of n)r?.releaseDraftAttachment(e)}},`conversation.input: session shell`),r.inject([`inputTriggers`],e=>{e.effect(()=>(i.refreshLexiconSubscription(),()=>{i.refreshLexiconSubscription()}),`conversation.input: reference catalogs`)}),i.setDraft(id(e.sessionId)),i}shell(e){let t=this.sessions().binding(e);if(t===void 0)throw Error(`conversation.input: session "${e}" resolved no binding`);return this.shellFor(t)}keyboard(e){return this.shell(e)}canPickFiles(e){let t=this.sessions().binding(e);return t!==void 0&&this.shells.get(t)?.canPickFiles()===!0}pickFiles(e){let t=this.sessions().binding(e);t!==void 0&&this.shells.get(t)?.pickFiles()}inputTriggers(e){let t=this.sessions().binding(e);return t===void 0?void 0:this.controller(t.ctx)}sink(e,t,n,r,i,a){return t===``&&n.length===0?Promise.resolve({kind:`success`}):this.conversation().sendSession(e,t,n,r,i,a)}async steerQueue(e,t){let n=e.projections.faceOf(`inbox`).getSnapshot()?.[`next-turn`]??[];if(n.length!==0)for(let r of n){let n=await e.updateQueue(r.id,{kind:`steer`});if(!n.ok){if(n.error.code===`session/steer-unavailable`||n.error.code===`session/queue-item-not-found`)return;t.notify(`error`,this.t(`queue.steerFailed`));return}}}controller(e){if(this.sessions().sessionOf(e)!==void 0)return this.rootCtx.get(`inputTriggers`)?.sessionOf(e)}popup(e){if(this.sessions().sessionOf(e)!==void 0)return this.rootCtx.get(`commandUi`)?.popupFor(e)}sessions(){let e=this.rootCtx.get(`sessions`);if(e===void 0)throw Error(`conversation.input: sessions service unavailable`);return e}conversation(){let e=this.rootCtx.get(`conversation`);if(e===void 0)throw Error(`conversation.input: conversation service unavailable`);return e}};let cA=/* @__PURE__ */ new Map;var lA=class{runtime;unregister;textStore=(0,f.createSnapshotStore)(``);activeToken=null;modified=!1;seeding=!1;text=this.textStore;constructor(){this.runtime=new eA({onUpdate:()=>{let e=this.runtime.refreshProjection(),t=this.runtime.projection.clipboardText;e.clipboardText!==t&&(this.seeding||(this.modified=!0),this.textStore.set(t))},openReference:()=>!1,activeClaimToken:()=>null,lexicon:()=>cA,resolveLexicon:()=>void 0}),this.unregister=this.runtime.register()}get editor(){return this.runtime.editor}syncCreation(e){if(e.state===`idle`){(this.activeToken!==null||this.textStore.getSnapshot()!==``)&&(this.activeToken=null,this.clearEditor());return}let t=e.token??null;t!==this.activeToken&&(this.activeToken=t,this.seed(e.initialPrompt??``))}paste(e){this.runtime.paste(e)}take(){if(this.activeToken===null)return;let e={text:this.runtime.projection.clipboardText,modified:this.modified};return this.activeToken=null,this.clearEditor(),e}dispose(){this.activeToken=null,this.unregister()}seed(e){this.seeding=!0;try{this.modified=!1,this.runtime.setDraft(e),this.runtime.clearHistory(),this.textStore.set(this.runtime.projection.clipboardText)}finally{this.seeding=!1}}clearEditor(){this.seed(``)}};let uA=`busyEnter`,dA=[`queue`,`steer`],fA=`queue`,pA={[uA]:S.union([...dA]).default(fA)};S.object(pA);function mA(e,t,n,r){return!t||!r?`queue`:n===`enter`?e:e===`queue`?`steer`:`queue`}var hA=class{busyEnter=(0,f.createSnapshotStore)(fA);unsubscribe;host;constructor(e){this.host=e,e!==void 0&&(this.unsubscribe=e.subscribe(()=>{this.adopt(e)}),this.adopt(e))}dispose(){this.unsubscribe?.()}setBusyEnter(e){this.busyEnter.getSnapshot()!==e&&(this.busyEnter.set(e),this.host?.set(uA,e))}adopt(e){let t=e.getSnapshot().value;t!==void 0&&this.busyEnter.getSnapshot()!==t.busyEnter&&this.busyEnter.set(t.busyEnter)}};async function gA(e,t){let n=/* @__PURE__ */ new Map;for(let t of e)n.has(t.attachmentId)||n.set(t.attachmentId,t);let r=/* @__PURE__ */ new Map;return await Promise.all([...n.entries()].map(async([e,n])=>{let i=await t(n),a=await fetch(i);if(!a.ok)throw Error(`Queued image preview fetch failed (${a.status})`);r.set(e,{blob:await a.blob(),mediaType:n.mediaType})})),r}function _A(e,t,n){let{annotations:r,body:i}=Ck(t);if(r.length>0&&e.addResponseAnnotations(e.takeSubmittedAnnotationAnchors(n,r)),i!==``){let t=e.draftSnapshot;e.setDraft({...t,text:t.text===``?i:`${t.text}\n${i}`})}}function vA(e){let{sessionId:t,shell:n,conversation:r,message:i,imageBlobs:a,rpcId:o}=e,s=()=>{if(n.isDisposed)throw Error(`Queued message was removed, but the session composer was closed before restoring.`);let{phase:e}=n.snapshot;if(e!==`plain`&&e!==`claimed`)return!1;if(i.attachments.length>0){if(r===void 0)throw Error(`Queued attachments cannot be restored without a conversation controller.`);let e=i.attachments.map(e=>{if(e.kind!==`image`)return e;let t=a.get(e.file.attachmentId);if(t===void 0)return e;let n=new File([t.blob],e.file.name,{type:t.blob.type||t.mediaType||`image/png`});return{...e,imageFile:n}}),o=r.restoreStagedDrafts(t,e);if(!n.addAttachments(o.map(e=>e.id))){if(r.releaseDraftAttachments(o),n.isDisposed)throw Error(`Queued message was removed, but the session composer was closed before restoring.`);return!1}}return i.text!==``&&_A(n,i.text,o),n.actions.persistDraft(),n.focus(`end`),!0};try{if(s())return Promise.resolve()}catch(e){return Promise.reject(e)}return new Promise((e,t)=>{let r=!1,i=!1,a,o=()=>{if(!(r||i)){i=!0;try{if(!s())return;r=!0,a?.(),e()}catch(e){r=!0,a?.(),t(e)}finally{i=!1}}};a=n.state.subscribe(o),o()})}let yA=`@deepseek-ai/dsh-client-ui-conversation/QueueDock.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(yA)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-conversation`,e.dataset.pluginCss=yA,e.textContent=`.ZMI-0G_dock{box-sizing:border-box;width:calc(100% - var(--dsh-composer-side-clearance) - var(--dsh-composer-side-clearance) - var(--dsh-composer-dock-inset) - var(--dsh-composer-dock-inset));max-width:calc(var(--dsh-composer-card-max-width) - var(--dsh-composer-dock-inset) - var(--dsh-composer-dock-inset));margin:0 auto calc(0px - var(--dsh-composer-stack-gap) - 3px);padding:0 var(--dsh-composer-dock-inset);flex:none}.ZMI-0G_pendingAttachment{flex-direction:column;gap:2px;display:inline-flex}.ZMI-0G_panel{z-index:0;border-radius:var(--dsw-radius-lg) var(--dsw-radius-lg) 0 0;--dsh-scrollbar-thumb:var(--dsw-alias-scrollbar-bg-l2);--dsh-scrollbar-thumb-hover:var(--dsw-alias-scrollbar-hover-l2);width:100%;padding:2px 0;position:relative;overflow:hidden}.ZMI-0G_panel:before{z-index:-1;border-radius:inherit;background:var(--dsw-specific-menu);backdrop-filter:var(--dsw-menu-backdrop-filter);content:"";pointer-events:none;position:absolute;inset:0}.ZMI-0G_panel:after{border:.5px solid var(--dsw-alias-border-l1);border-radius:inherit;content:"";pointer-events:none;border-bottom:none;position:absolute;inset:0}.ZMI-0G_paused{color:var(--dsw-alias-label-tertiary);font:var(--dsw-font-xs-13);padding:6px 12px 2px}.ZMI-0G_header{box-sizing:border-box;border-radius:var(--dsw-radius-md);width:100%;height:36px;color:var(--dsw-alias-label-primary);text-align:left;cursor:pointer;background:0 0;border:none;align-items:center;gap:10px;padding:4px 12px;display:flex}.ZMI-0G_header:focus-visible{outline:var(--dsw-focus-ring-width) solid var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary));outline-offset:-2px}.ZMI-0G_header:disabled{cursor:default}.ZMI-0G_lead{color:var(--dsw-alias-label-tertiary);flex:none;place-items:center;display:grid}.ZMI-0G_count{min-width:0;font-family:Inter, var(--dsw-font-family);flex:auto;font-size:13px;font-weight:500;line-height:24px}.ZMI-0G_chevron{width:14px;height:14px;color:var(--dsw-alias-label-tertiary);flex:none;place-items:center;display:grid}.ZMI-0G_list{max-height:180px;margin:0;padding:0;list-style:none;overflow-y:auto}.ZMI-0G_row{box-sizing:border-box;border-radius:var(--dsw-radius-md);align-items:center;gap:10px;width:100%;min-height:36px;padding:4px 5px 4px 12px;display:flex}.ZMI-0G_row+.ZMI-0G_row{box-shadow:inset 0 1px 0 var(--dsw-alias-border-l1)}.ZMI-0G_attachments{flex:none;gap:4px;min-width:0;max-width:55%;display:flex;overflow:hidden}.ZMI-0G_pendingRow .ZMI-0G_attachments{flex-shrink:1}.ZMI-0G_file{border:.5px solid var(--dsw-alias-border-l1);border-radius:var(--dsw-radius-sm);background:var(--dsw-alias-bg-base);box-sizing:border-box;flex:0 180px;align-items:center;gap:4px;min-width:74px;height:24px;padding:0 6px;display:inline-flex;overflow:hidden}.ZMI-0G_fileIcon{flex:none;width:16px;height:16px;display:inline-flex}.ZMI-0G_fileName{min-width:0;color:var(--dsw-alias-label-primary-dimmed);font:var(--dsw-font-xs-13);text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.ZMI-0G_fileSize{color:var(--dsw-alias-label-tertiary);white-space:nowrap;flex:none;font-size:10px}.ZMI-0G_thumb{border:.5px solid var(--dsw-alias-border-l1);border-radius:var(--dsw-radius-xs);background:var(--dsw-alias-bg-base);object-fit:cover;width:24px;height:24px}.ZMI-0G_annotationBadge{background:color-mix(in srgb, var(--dsw-alias-state-business-primary) 14%, transparent);height:20px;color:var(--dsw-alias-state-business-primary);white-space:nowrap;border-radius:999px;flex:none;align-items:center;padding:0 7px;font-size:11px;font-weight:500;line-height:1;display:inline-flex}.ZMI-0G_preview{min-width:0;font:var(--dsw-font-xs-13);font-family:Inter, var(--dsw-font-family);color:var(--dsw-alias-label-primary-dimmed);text-overflow:ellipsis;white-space:nowrap;word-break:break-word;flex:auto;overflow:hidden}.ZMI-0G_previewFallback{color:var(--dsw-alias-label-tertiary)}.ZMI-0G_actions{flex:none;align-items:center;gap:10px;display:flex}.ZMI-0G_actionWrap{flex:none;display:inline-flex}.ZMI-0G_actionWrap>.ZMI-0G_action:disabled{pointer-events:none}.ZMI-0G_status{color:var(--dsw-alias-label-tertiary);font:var(--dsw-font-xs-13);white-space:nowrap;flex:none}.ZMI-0G_action{corner-shape:round;width:28px;height:28px;color:var(--dsw-alias-label-tertiary);cursor:pointer;background:0 0;border:none;border-radius:999px;flex:none;place-items:center;padding:0;display:grid}.ZMI-0G_action:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-hover)}.ZMI-0G_action:focus-visible{outline:var(--dsw-focus-ring-width) solid var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary));outline-offset:-2px}.ZMI-0G_action:disabled{cursor:default;opacity:.45}`,document.head.appendChild(e)}var Z={action:`ZMI-0G_action`,actionWrap:`ZMI-0G_actionWrap`,actions:`ZMI-0G_actions`,annotationBadge:`ZMI-0G_annotationBadge`,attachments:`ZMI-0G_attachments`,chevron:`ZMI-0G_chevron`,count:`ZMI-0G_count`,dock:`ZMI-0G_dock`,file:`ZMI-0G_file`,fileIcon:`ZMI-0G_fileIcon`,fileName:`ZMI-0G_fileName`,fileSize:`ZMI-0G_fileSize`,header:`ZMI-0G_header`,lead:`ZMI-0G_lead`,list:`ZMI-0G_list`,panel:`ZMI-0G_panel`,paused:`ZMI-0G_paused`,pendingAttachment:`ZMI-0G_pendingAttachment`,pendingRow:`ZMI-0G_pendingRow`,preview:`ZMI-0G_preview`,previewFallback:`ZMI-0G_previewFallback`,row:`ZMI-0G_row`,status:`ZMI-0G_status`,thumb:`ZMI-0G_thumb`};let bA=[];function xA(e){let t=e.replace(/\s+/g,` `).trim(),n=Array.from(t);return n.length>200?`${n.slice(0,200).join(``)}…`:t}function SA(e,t){let n=xA(t);if(e.length===0)return{annotations:e,preview:n,fallbackPreview:``,annotationTooltip:``};let r=e[0];return{annotations:e,preview:n,fallbackPreview:n===``?xA(r.annotation??r.text):``,annotationTooltip:e.map((e,t)=>`${String(t+1)}. ${xA(e.annotation??e.text)}`).join(`
167
+ `)}}function CA(e){let t=[],n=[];for(let r of e)if(r.type!==`image`&&r.type!==`file`){if(r.type===`text`){let e=Ck(r.text);t.push(...e.annotations),e.body!==``&&n.push(e.body)}else n.push(`[${r.type}]`)}return SA(t,n.join(` `))}function wA(e){let t=Ck(e);return SA(t.annotations,t.body)}function TA({display:e,t}){return/* @__PURE__ */ (0,h.jsxs)(h.Fragment,{children:[e.annotations.length>0&&/* @__PURE__ */ (0,h.jsx)(`span`,{className:Z.annotationBadge,"data-queue-annotations":e.annotations.length,title:e.annotationTooltip,children:t(`annotation.trayCount`,{count:e.annotations.length})}),/* @__PURE__ */ (0,h.jsx)(`span`,{className:e.preview===``&&e.fallbackPreview!==``?`${Z.preview} ${Z.previewFallback}`:Z.preview,children:e.preview===``?e.fallbackPreview:(0,d.projectUserText)(e.preview,[])})]})}function EA(e){return e.every(e=>e.type===`text`)?e.map(e=>e.text).join(``):null}function DA(e){let t=[];for(let n of e){if(n.type===`image`){let{attachment:e}=n;e!==void 0&&t.push({type:`image`,attachment:e})}if(n.type===`file`){let{attachment:e}=n;e!==void 0&&t.push({type:`file`,attachment:e})}}return t}function OA({attachment:e,label:t}){return/* @__PURE__ */ (0,h.jsxs)(`span`,{className:Z.file,"aria-label":t,title:e.name,children:[/* @__PURE__ */ (0,h.jsx)(`span`,{className:Z.fileIcon,"aria-hidden":!0,children:/* @__PURE__ */ (0,h.jsx)(d.FileTypeIcon,{path:e.name,size:16})}),/* @__PURE__ */ (0,h.jsx)(`span`,{className:Z.fileName,children:e.name}),/* @__PURE__ */ (0,h.jsx)(`span`,{className:Z.fileSize,children:(0,d.fileSizeText)(e.bytes)})]})}function kA({attachment:e,loadImage:t,label:n}){let[r,i]=(0,g.useState)(null);return(0,g.useEffect)(()=>{let n=!0;return t(e).then(e=>{n&&i(e)},()=>{}),()=>{n=!1}},[e,t]),r===null?/* @__PURE__ */ (0,h.jsx)(`span`,{className:Z.thumb,"aria-hidden":!0}):/* @__PURE__ */ (0,h.jsx)(`img`,{className:Z.thumb,src:r,alt:n})}function AA({upload:e,t}){let n=(0,g.useSyncExternalStore)(e.subscribe,e.getSnapshot);return n?.status===`uploading`?/* @__PURE__ */ (0,h.jsx)(`span`,{className:Z.status,role:`status`,"data-upload-progress":!0,children:n.total===void 0||n.total===0?t(`file.uploading`):t(`file.uploadingPercent`,{percent:Math.round(Math.min(1,(n.loaded??0)/n.total)*100)})}):null}function jA({useSession:e,useProjection:t,updateQueue:n,editQueue:r,hasStructuredQueueEdit:i,notify:a,loadImage:o,t:s}){let c=t(`inbox`),l=t(`queueState`),u=e(e=>e.pendingSubmissions),f=(0,g.useMemo)(()=>{let e=c?.[`next-turn`]??bA,t=new Set(u.filter(e=>e.placement===`transcript`).map(e=>e.requestId));return t.size===0?e:e.filter(({source:e})=>e.kind!==`user`||!(`rpcId`in e)||!t.has(e.rpcId))},[c,u]),p=(0,g.useMemo)(()=>{let e=new Set(f.flatMap(({source:e})=>e.kind===`user`&&`rpcId`in e?[e.rpcId]:[]));return u.filter(t=>t.placement===`queued`&&!e.has(t.requestId))},[u,f]),m=f.length+p.length,_=e(e=>e.running),v=e(e=>e.subagent===null||e.subagent.address.mode===`continuable`)&&l?.stale!==!0,y=l?.previewOnly===!0,b=(0,g.useRef)(!1),[ee,te]=(0,g.useState)(null),[ne,re]=(0,g.useState)(!0),ie=(0,g.useId)(),ae=l?.pausedReason??null,oe=ae===`interrupted`?s(`queue.paused.interrupted`):ae===`outcome-unknown`?s(`queue.paused.unknown`):ae===`failed`?s(`queue.paused.failed`):null;if((0,g.useEffect)(()=>{m===0&&!ne&&re(!0)},[ne,m]),m===0)return null;let se=v&&ee!==null,ce=!ne||se,le=m===1||ce,ue=async(e,t,r)=>{if(b.current)return!1;b.current=!0,te(e);try{return typeof t==`function`?await t():await n(e,t),!0}catch{return a(`error`,y?s(`queue.remoteActionFailed`):r),!1}finally{b.current=!1,te(t=>t===e?null:t)}};return/* @__PURE__ */ (0,h.jsx)(`div`,{className:Z.dock,"data-queue-dock":``,children:/* @__PURE__ */ (0,h.jsxs)(`div`,{className:Z.panel,children:[l?.stale&&/* @__PURE__ */ (0,h.jsx)(`div`,{className:Z.paused,role:`status`,children:s(`queue.remoteStale`)}),oe!==null&&/* @__PURE__ */ (0,h.jsx)(`div`,{className:Z.paused,role:`status`,children:oe}),m>1&&/* @__PURE__ */ (0,h.jsxs)(`button`,{type:`button`,className:Z.header,"aria-controls":ie,"aria-expanded":ce,disabled:se,onClick:()=>{re(e=>!e)},children:[/* @__PURE__ */ (0,h.jsx)(`span`,{className:Z.lead,"aria-hidden":!0,children:/* @__PURE__ */ (0,h.jsx)(d.IconQueueOutlineRegular,{})}),/* @__PURE__ */ (0,h.jsx)(`span`,{className:Z.count,children:s(`queue.count`,{n:m})}),!le&&p.length>0&&/* @__PURE__ */ (0,h.jsx)(`span`,{className:Z.status,role:`status`,children:s(`queue.sending`)}),/* @__PURE__ */ (0,h.jsx)(`span`,{className:Z.chevron,"aria-hidden":!0,children:ce?/* @__PURE__ */ (0,h.jsx)(d.IconChevronDownOutlineRegular,{}):/* @__PURE__ */ (0,h.jsx)(d.IconChevronUpOutlineRegular,{})})]}),/* @__PURE__ */ (0,h.jsxs)(`ul`,{id:ie,className:Z.list,hidden:!le,children:[le&&f.map(e=>{let t=DA(e.content),n=CA(e.content),a=e.source.kind===`user`&&`rpcId`in e.source?e.source.rpcId:void 0,c=l?.editable===void 0?(()=>{let t=EA(e.content);return t===null?null:{kind:`legacyText`,text:t,...a===void 0?{}:{rpcId:a}}})():(()=>{let n=l.editable?.[e.id];return n===void 0||!i()?null:{kind:`structured`,revision:n,images:t.flatMap(e=>e.type===`image`?[e.attachment]:[]),...a===void 0?{}:{rpcId:a}}})(),u=c!==null;return/* @__PURE__ */ (0,h.jsxs)(`li`,{className:Z.row,children:[m===1&&/* @__PURE__ */ (0,h.jsx)(`span`,{className:Z.lead,"aria-hidden":!0,children:/* @__PURE__ */ (0,h.jsx)(d.IconQueueOutlineRegular,{})}),t.length>0&&/* @__PURE__ */ (0,h.jsx)(`span`,{className:Z.attachments,children:t.map((e,t)=>e.type===`image`?/* @__PURE__ */ (0,h.jsx)(kA,{attachment:e.attachment,loadImage:o,label:s(`queue.image`)},`${e.attachment.attachmentId}:${t}`):/* @__PURE__ */ (0,h.jsx)(OA,{attachment:e.attachment,label:s(`queue.file`,{name:e.attachment.name})},`${e.attachment.attachmentId}:${e.attachment.name}:${t}`))}),/* @__PURE__ */ (0,h.jsx)(TA,{display:n,t:s}),v&&/* @__PURE__ */ (0,h.jsxs)(`div`,{className:Z.actions,children:[!y&&/* @__PURE__ */ (0,h.jsx)(d.Tooltip,{portal:!0,label:s(u?`queue.edit`:`queue.edit.unsupported`),side:`bottom`,delayMs:500,children:/* @__PURE__ */ (0,h.jsx)(`span`,{className:Z.actionWrap,children:/* @__PURE__ */ (0,h.jsx)(`button`,{type:`button`,className:Z.action,"aria-label":s(`queue.edit`),disabled:ee!==null||!u,onClick:()=>{c!==null&&ue(e.id,()=>r(e.id,c),s(`queue.editFailed`))},children:/* @__PURE__ */ (0,h.jsx)(d.IconEditOutlineRegular,{size:14})})})}),/* @__PURE__ */ (0,h.jsx)(d.Tooltip,{portal:!0,label:s(`queue.remove`),side:`bottom`,delayMs:500,children:/* @__PURE__ */ (0,h.jsx)(`button`,{type:`button`,className:Z.action,"aria-label":s(`queue.remove`),disabled:ee!==null,onClick:()=>{ue(e.id,{kind:`remove`},s(`queue.removeFailed`))},children:/* @__PURE__ */ (0,h.jsx)(d.IconTrashOutlineRegular,{size:14})})}),(!y||!_)&&/* @__PURE__ */ (0,h.jsx)(d.Tooltip,{portal:!0,label:s(_?`queue.steer`:`queue.resume`),side:`bottom`,delayMs:500,children:/* @__PURE__ */ (0,h.jsx)(`button`,{type:`button`,className:Z.action,"aria-label":s(_?`queue.steer`:`queue.resume`),disabled:ee!==null,onClick:()=>{ue(e.id,{kind:`steer`},s(_?`queue.steerFailed`:`queue.resumeFailed`))},children:/* @__PURE__ */ (0,h.jsx)(d.IconSendOutlineRegular,{})})})]})]},e.id)}),le&&p.map(e=>{let t=wA(e.text);return/* @__PURE__ */ (0,h.jsxs)(`li`,{className:`${Z.row} ${Z.pendingRow}`,"data-submission-echo":``,children:[m===1&&/* @__PURE__ */ (0,h.jsx)(`span`,{className:Z.lead,"aria-hidden":!0,children:/* @__PURE__ */ (0,h.jsx)(d.IconQueueOutlineRegular,{})}),e.attachments.length>0&&/* @__PURE__ */ (0,h.jsx)(`span`,{className:Z.attachments,children:e.attachments.map((e,t)=>/* @__PURE__ */ (0,h.jsxs)(`span`,{className:Z.pendingAttachment,children:[e.type===`image`?/* @__PURE__ */ (0,h.jsx)(`img`,{className:Z.thumb,src:e.value.previewUrl,alt:s(`queue.image`)}):/* @__PURE__ */ (0,h.jsx)(OA,{attachment:e.value,label:s(`queue.file`,{name:e.value.name})}),e.upload&&/* @__PURE__ */ (0,h.jsx)(AA,{upload:e.upload,t:s})]},t))}),/* @__PURE__ */ (0,h.jsx)(TA,{display:t,t:s}),/* @__PURE__ */ (0,h.jsx)(`span`,{className:Z.status,role:`status`,children:s(`queue.sending`)}),v&&!y&&/* @__PURE__ */ (0,h.jsxs)(`div`,{className:Z.actions,children:[/* @__PURE__ */ (0,h.jsx)(`button`,{type:`button`,className:Z.action,"aria-label":s(`queue.edit`),title:s(`queue.sending`),disabled:!0,children:/* @__PURE__ */ (0,h.jsx)(d.IconEditOutlineRegular,{size:14})}),/* @__PURE__ */ (0,h.jsx)(`button`,{type:`button`,className:Z.action,"aria-label":s(`queue.remove`),title:s(`queue.sending`),disabled:!0,children:/* @__PURE__ */ (0,h.jsx)(d.IconTrashOutlineRegular,{size:14})}),/* @__PURE__ */ (0,h.jsx)(`button`,{type:`button`,className:Z.action,"aria-label":s(`queue.steer`),title:s(`queue.sending`),disabled:!0,children:/* @__PURE__ */ (0,h.jsx)(d.IconSendOutlineRegular,{})})]})]},e.requestId)})]})]})})}let MA={name:`conversation-queue-dock`,inject:[`slots`,`conversation`,`sessions`,`uiConversation`],apply(e,t){e.slots.inject(`conversation.input.dock`,()=>e.slots.register({name:`conversation.input.dock`,id:`queue`,order:20,locale:ld,inject:n=>{let r=e.sessions.scope(n);if(r===void 0)throw Error(`queue dock: session "${n}" resolved no scope`);let i=r.get(`conversation`);if(i===void 0)throw Error(`queue dock: conversation service unavailable`);let a=t=>e.uiConversation.imageUrl(n,t);return{updateQueue:(e,t)=>i.updateQueue(e,t),hasStructuredQueueEdit:()=>{let t=e.get(`conversation`);return e.get(`queueMessageEditing`)!==void 0&&typeof t?.restoreStagedDrafts==`function`},editQueue:async(r,o)=>{let s=e.sessions.retain(n,{source:`controllerOperation`});try{let s=t.shell(n);if(o.kind===`legacyText`){await i.updateQueue(r,{kind:`remove`}),await vA({sessionId:n,shell:s,message:{text:o.text,attachments:[]},imageBlobs:/* @__PURE__ */ new Map,...o.rpcId===void 0?{}:{rpcId:o.rpcId}});return}let c=e.get(`queueMessageEditing`),l=e.get(`conversation`);if(c===void 0||typeof l?.restoreStagedDrafts!=`function`)throw Error(`queue dock: structured queue editing unavailable`);let u=o.images.length>0?await gA(o.images,a):/* @__PURE__ */ new Map;if(s.isDisposed)throw Error(`queue dock: session composer closed before editing`);await vA({sessionId:n,shell:s,conversation:l,message:await c.takeForEdit(n,r,o.revision),imageBlobs:u,...o.rpcId===void 0?{}:{rpcId:o.rpcId}})}finally{s.release()}},notify:(t,a)=>{e.sessions.scope(n)===r&&i.input.for(r).notify(t,a)},loadImage:a}}},jA))}},NA=`@deepseek-ai/dsh-client-ui-conversation/EnterBehaviorRow.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(NA)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-conversation`,e.dataset.pluginCss=NA,e.textContent=`.v-9l-a_row{border-bottom:.5px solid var(--dsw-alias-border-l2);align-items:center;gap:8px;padding:16px 0;display:flex}.v-9l-a_rowText{flex-direction:column;flex:1;gap:4px;min-width:0;padding-right:48px;display:flex}.v-9l-a_title{color:var(--dsw-alias-label-primary);font-size:14px;font-weight:400;line-height:22px}.v-9l-a_desc{color:var(--dsw-alias-label-tertiary);font-size:12px;font-weight:400;line-height:18px}.v-9l-a_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}.v-9l-a_selector:hover{background:var(--dsw-alias-interactive-bg-hover)}.v-9l-a_chevron{flex:none}`,document.head.appendChild(e)}var PA={chevron:`v-9l-a_chevron`,desc:`v-9l-a_desc`,row:`v-9l-a_row`,rowText:`v-9l-a_rowText`,selector:`v-9l-a_selector`,title:`v-9l-a_title`};let FA=[{id:`queue`,label:`settings.enter.queue`},{id:`steer`,label:`settings.enter.steer`}];function IA({useBusyEnter:e,setBusyEnter:t,t:n}){let r=e(e=>e),[i,a]=(0,g.useState)(!1),o=r===`queue`?`settings.enter.queue`:`settings.enter.steer`;return/* @__PURE__ */ (0,h.jsxs)(`div`,{className:PA.row,children:[/* @__PURE__ */ (0,h.jsxs)(`div`,{className:PA.rowText,children:[/* @__PURE__ */ (0,h.jsx)(`div`,{className:PA.title,children:n(`settings.enter.title`)}),/* @__PURE__ */ (0,h.jsx)(`div`,{className:PA.desc,children:n(`settings.enter.description`)})]}),/* @__PURE__ */ (0,h.jsx)(d.Menu,{open:i,onClose:()=>{a(!1)},items:FA.map(e=>({id:e.id,label:n(e.label)})),selectedId:r,onSelect:e=>{a(!1),t(e)},align:`end`,portal:!0,anchor:/* @__PURE__ */ (0,h.jsxs)(`button`,{type:`button`,className:PA.selector,"aria-haspopup":`menu`,"aria-expanded":i,onClick:()=>{a(e=>!e)},children:[n(o),/* @__PURE__ */ (0,h.jsx)(d.IconChevronDownOutlineRegular,{className:PA.chevron})]})})]})}let LA={views:{get:()=>void 0,grouped:()=>void 0},activeTargets:/* @__PURE__ */ new Set};function RA(e,t){return t.activeTargets.size>0||!e.blank&&!e.awaitingFirstTurn||e.running?`active`:e.promptAttempted?`engaging`:`blank`}let zA=`@deepseek-ai/dsh-client-ui-conversation/ConversationRoot.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(zA)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-conversation`,e.dataset.pluginCss=zA,e.textContent=`.vbpo1q_root{background:var(--dsw-alias-bg-base);flex-direction:column;min-width:0;height:100%;display:flex;position:relative}body[data-codexhost-wallpaper] .vbpo1q_root{background:0 0}.vbpo1q_header{box-sizing:border-box;flex:none;grid-template-columns:auto minmax(0,1fr);min-height:76px;padding:10px 28px 0 20px;display:grid}.vbpo1q_header:where(:not(:has(.vbpo1q_tabs))){min-height:0;padding:10px 24px 6px 20px}[data-windows-titlebar] .vbpo1q_header:where(:not(:has(.vbpo1q_tabs))){padding-top:8px;padding-bottom:4px}.vbpo1q_headerBlank{border-bottom:none;min-height:0;padding-bottom:0}.vbpo1q_headerBlank .vbpo1q_headerCorner{margin-left:auto}html:not([data-platform=darwin]) .vbpo1q_headerSessionless{padding-top:0}html:not([data-platform=darwin]) .vbpo1q_headerSessionless .vbpo1q_titleRow{min-height:0}[data-platform=darwin] .vbpo1q_headerLeading,[data-platform=darwin] .vbpo1q_headerActions,[data-platform=darwin] .vbpo1q_headerUtilities,[data-platform=darwin] .vbpo1q_headerCorner{-webkit-app-region:no-drag}.vbpo1q_titleRow{min-height:30px;grid-column:2;align-items:center;gap:0;padding-inline-start:max(0px, calc(var(--dsh-frame-leading-clearance,0px) - 20px));display:flex;container-type:inline-size}.vbpo1q_titleCenter{display:contents}.vbpo1q_phoneTrailingAction{display:none}.vbpo1q_titleCluster{flex:1;align-items:center;gap:10px;min-width:0;display:flex}.vbpo1q_headerLeading{flex:none;grid-area:1/1;align-items:center;gap:8px;display:flex}.vbpo1q_crumbs{white-space:nowrap;align-items:center;gap:4px;min-width:0;display:flex;overflow:hidden}.vbpo1q_crumbSeg{align-items:center;gap:4px;min-width:0;display:inline-flex}.vbpo1q_crumbRoleAvatar{margin-left:2px}.vbpo1q_crumbSep{color:var(--dsw-alias-label-caption);font-size:14px;line-height:20px}.vbpo1q_crumb{border-radius:var(--dsw-radius-md);max-width:220px;color:var(--dsw-alias-label-tertiary);text-overflow:ellipsis;white-space:nowrap;cursor:pointer;background:0 0;border:none;padding:4px 8px;font-size:14px;line-height:20px;display:inline-block;overflow:hidden}.vbpo1q_crumbSubagent{font-size:12px;line-height:18px}button.vbpo1q_crumb:hover{background:var(--dsw-alias-interactive-bg-hover)}.vbpo1q_crumbCurrent{color:var(--dsw-alias-label-primary);cursor:default;font-weight:500}.vbpo1q_headerActions{flex:none;align-items:center;gap:8px;display:flex}.vbpo1q_headerUtilities{flex:none;align-items:center;gap:8px;margin-left:20px;display:flex}.vbpo1q_headerUtilities:empty{display:none}.vbpo1q_headerCorner{flex:none;align-items:center;margin-left:8px;margin-right:-16px;display:flex}.vbpo1q_headerCorner:empty,.vbpo1q_headerCorner:not(:has([data-slot="conversation.session.header.corner"]>*)){display:none}[data-phone] .vbpo1q_root[data-phase=active]{--dsh-phone-header-height:calc(env(safe-area-inset-top) + 44px)}[data-phone] .vbpo1q_root[data-phase=active]:has([data-slot="conversation.header.shortcuts"] nav){--dsh-phone-header-height:calc(env(safe-area-inset-top) + 88px)}[data-phone] .vbpo1q_header{z-index:8;padding-top:env(safe-area-inset-top);background:0 0;border-bottom:none;row-gap:0;padding-bottom:0;position:relative}[data-phone] .vbpo1q_root[data-phase=active] .vbpo1q_header{pointer-events:none;position:absolute;top:0;left:0;right:0}[data-phone] .vbpo1q_root[data-phase=active] .vbpo1q_header [data-slot="conversation.header.shortcuts"]{pointer-events:auto}[data-phone] .vbpo1q_root[data-phase=active]:not(:has([data-slot="conversation.header.notice"]>*)) .vbpo1q_scrollBody{padding-top:var(--dsh-phone-header-height)}[data-phone] .vbpo1q_root[data-phase=active]>[data-slot="conversation.header.notice"]>*{z-index:5;position:relative}[data-phone] .vbpo1q_root[data-phase=active]>[data-slot="conversation.header.notice"]>:first-child{margin-top:var(--dsh-phone-header-height)}[data-phone] .vbpo1q_root[data-phase=active] .vbpo1q_header:before{content:"";height:calc(var(--dsh-phone-header-height) + 32px);z-index:-1;background:linear-gradient(180deg, color-mix(in srgb, var(--dsw-alias-bg-base) 78%, transparent) 0%, color-mix(in srgb, var(--dsw-alias-bg-base) 58%, transparent) 44%, color-mix(in srgb, var(--dsw-alias-bg-base) 24%, transparent) 74%, transparent 100%);pointer-events:none;position:absolute;top:0;left:0;right:0}@supports (backdrop-filter:blur(16px)){[data-phone] .vbpo1q_root[data-phase=active] .vbpo1q_header:before{backdrop-filter:blur(16px)saturate(140%);-webkit-mask-image:linear-gradient(#000 0%,#000000eb 42%,#0000008f 62%,#00000038 78%,#0000000d 91%,#0000 100%);mask-image:linear-gradient(#000 0%,#000000eb 42%,#0000008f 62%,#00000038 78%,#0000000d 91%,#0000 100%)}}body[data-codexhost-wallpaper] [data-phone] .vbpo1q_root[data-phase=active] .vbpo1q_header:before{background:linear-gradient(180deg, color-mix(in srgb, var(--dsw-alias-bg-base) 64%, transparent) 0%, color-mix(in srgb, var(--dsw-alias-bg-base) 42%, transparent) 44%, color-mix(in srgb, var(--dsw-alias-bg-base) 16%, transparent) 74%, transparent 100%)}[data-phone] .vbpo1q_headerLeading{display:none}[data-phone] .vbpo1q_titleRow{grid-area:1/1/auto/-1;grid-template-columns:minmax(80px,1fr) minmax(0,auto) minmax(80px,1fr);align-items:center;gap:6px;min-height:44px;margin-inline:-8px -16px;padding-inline-start:0;display:grid}[data-phone] .vbpo1q_titleCluster{grid-column:2;justify-content:center;align-items:center;gap:4px;min-width:0;max-width:100%;display:flex}[data-phone] .vbpo1q_titleCenter{pointer-events:auto;border-radius:8px;justify-content:center;align-items:center;gap:4px;min-width:0;max-width:100%;min-height:36px;padding:0 2px;transition:opacity .12s;display:inline-flex;position:relative}[data-phone] .vbpo1q_root[data-phase=active] .vbpo1q_titleCenter:before{content:"";z-index:-1;background:radial-gradient(closest-side, color-mix(in srgb, var(--dsw-alias-bg-base) 88%, transparent) 38%, color-mix(in srgb, var(--dsw-alias-bg-base) 42%, transparent) 72%, transparent 100%);pointer-events:none;position:absolute;inset:-4px -22px}body[data-codexhost-wallpaper] [data-phone] .vbpo1q_root[data-phase=active] .vbpo1q_titleCenter:before{background:radial-gradient(closest-side, color-mix(in srgb, var(--dsw-alias-bg-base) 68%, transparent) 38%, color-mix(in srgb, var(--dsw-alias-bg-base) 28%, transparent) 72%, transparent 100%)}body[data-codexhost-wallpaper][data-ds-dark-theme] [data-phone] .vbpo1q_titleCenter{text-shadow:0 1px 10px #0000006b}[data-phone] .vbpo1q_titleCenter:has([data-navigation-focus-return]){cursor:pointer;-webkit-tap-highlight-color:transparent}[data-phone] .vbpo1q_titleRow>.vbpo1q_titleCenter,[data-phone] .vbpo1q_titleRow>[data-slot="conversation.header.navigation"]{pointer-events:auto;grid-column:2;justify-self:center}[data-phone] .vbpo1q_titleCenter>[data-slot="conversation.header.navigation"]{display:contents}[data-phone] .vbpo1q_titleCenter:has([data-navigation-focus-return]):active{opacity:.52}[data-phone] .vbpo1q_titleCenter:has([data-navigation-focus-return]:focus-visible){outline:none}@media (hover:hover) and (pointer:fine){[data-phone] .vbpo1q_titleCenter:has([data-navigation-focus-return]:focus-visible){outline:2px solid var(--dsw-alias-label-primary);outline-offset:2px}}[data-phone] .vbpo1q_crumbs{justify-content:center;gap:3px}[data-phone] .vbpo1q_crumb{letter-spacing:-.015em;max-width:none;padding:0;font-size:15px;font-weight:600;line-height:20px}[data-phone] button.vbpo1q_crumb{z-index:1;position:relative}[data-phone] .vbpo1q_headerActions:not(:has(button)),[data-phone] .vbpo1q_headerUtilities{display:none}[data-phone] .vbpo1q_phoneTrailingAction,[data-phone] .vbpo1q_headerCorner>[data-slot="conversation.session.header.corner"],[data-phone] .vbpo1q_phoneTrailingAction>[data-slot="conversation.header.trailing"]{display:contents}[data-phone] .vbpo1q_headerCorner:has(button){box-sizing:border-box;corner-shape:round;pointer-events:auto;background:#ffffffd6;border:.5px solid #0f11151a;border-radius:9999px;grid-column:3;justify-content:center;justify-self:end;align-items:center;gap:2px;height:36px;margin:0;padding:0 3px;display:inline-flex;box-shadow:inset 0 1px #ffffffb8,inset 0 -.5px #ffffff47,inset 0 0 0 .5px #ffffff38,0 1px 2px #0f11150d,0 6px 18px -4px #0f11151c}[data-phone] .vbpo1q_headerCorner:has(button):not(:has([data-phone-new-session]):has([data-sidebar-right-expand])){width:36px;padding:0}[data-ds-dark-theme] [data-phone] .vbpo1q_headerCorner:has(button){background:#24262cc7;border-color:#ffffff24;box-shadow:inset 0 1px #ffffff47,inset 0 -.5px #ffffff14,0 2px 8px #00000042,0 8px 22px -6px #0000006b}@supports (backdrop-filter:blur(8px)){[data-phone] .vbpo1q_headerCorner:has(button){backdrop-filter:blur(8px)saturate(180%);background:linear-gradient(#ffffff38 0%,#ffffff17 100%);box-shadow:inset 0 1px .5px #ffffffd9,inset 0 -.5px #0f11150f,0 1px 2px #0f11150f,0 6px 16px -4px #0f11151f}[data-ds-dark-theme] [data-phone] .vbpo1q_headerCorner:has(button){backdrop-filter:blur(10px)saturate(180%);background:linear-gradient(#ffffff1f 0%,#ffffff0d 100%)}}@media (prefers-reduced-motion:reduce){[data-phone] .vbpo1q_titleCenter{transition:none}}@media (prefers-reduced-transparency:reduce),(prefers-contrast:more){[data-phone] .vbpo1q_root[data-phase=active] .vbpo1q_header{pointer-events:auto;background:var(--dsw-alias-bg-base);border-bottom:.5px solid var(--dsw-alias-border-l3);position:relative}[data-phone] .vbpo1q_root[data-phase=active] .vbpo1q_header:before{display:none}[data-phone] .vbpo1q_root[data-phase=active]:not(:has([data-slot="conversation.header.notice"]>*)) .vbpo1q_scrollBody{padding-top:0}[data-phone] .vbpo1q_root[data-phase=active]>[data-slot="conversation.header.notice"]>:first-child{margin-top:0}[data-phone] .vbpo1q_headerCorner:has(button),[data-ds-dark-theme] [data-phone] .vbpo1q_headerCorner:has(button){border:1px solid var(--dsw-alias-border-l3);background:var(--dsw-alias-bg-layer-1);backdrop-filter:none;box-shadow:0 1px 2px #00000014}}@media (prefers-contrast:more){[data-phone] .vbpo1q_headerCorner:has(button),[data-ds-dark-theme] [data-phone] .vbpo1q_headerCorner:has(button){border-color:var(--dsw-alias-label-secondary);box-shadow:none}}@media (forced-colors:active){[data-phone] .vbpo1q_root[data-phase=active] .vbpo1q_header{pointer-events:auto;background:canvas;border-bottom:1px solid canvastext;position:relative}[data-phone] .vbpo1q_root[data-phase=active] .vbpo1q_header:before{display:none}[data-phone] .vbpo1q_root[data-phase=active]:not(:has([data-slot="conversation.header.notice"]>*)) .vbpo1q_scrollBody{padding-top:0}[data-phone] .vbpo1q_root[data-phase=active]>[data-slot="conversation.header.notice"]>:first-child{margin-top:0}[data-phone] .vbpo1q_headerCorner:has(button),[data-ds-dark-theme] [data-phone] .vbpo1q_headerCorner:has(button){backdrop-filter:none;box-shadow:none;background:buttonface;border:1px solid buttontext}}.vbpo1q_tabs{z-index:1;grid-column:1/-1;gap:36px;margin-top:10px;padding-left:8px;display:flex;position:relative}.vbpo1q_tab{color:var(--dsw-alias-label-tertiary);cursor:pointer;background:0 0;border:none;padding:0 0 9px;font-size:13px;font-weight:500;line-height:16px;position:relative}.vbpo1q_tab:after{content:"";background:0 0;border-radius:2px;height:2px;position:absolute;bottom:0;left:0;right:0}.vbpo1q_tabActive{color:var(--dsw-alias-state-business-primary)}.vbpo1q_tabActive:after{background:var(--dsw-alias-state-business-primary)}.vbpo1q_viewArea{flex-direction:column;flex:1;min-height:0;display:flex}.vbpo1q_widthHandle{z-index:0;width:min(10px, calc((100% - var(--dsh-chat-content-width)) / 2 - 24px - 24px));cursor:col-resize;position:absolute;top:0;bottom:0}.vbpo1q_widthHandle[data-side=left]{right:calc(50% + var(--dsh-chat-content-width) / 2 + 24px)}.vbpo1q_widthHandle[data-side=right]{left:calc(50% + var(--dsh-chat-content-width) / 2 + 24px)}.vbpo1q_widthHandle:after{content:"";background:linear-gradient(to bottom, transparent calc(var(--dsh-width-handle-pointer-y,50%) - 36px), var(--dsw-alias-scrollbar-bg-l1) calc(var(--dsh-width-handle-pointer-y,50%) - 8px), var(--dsw-alias-scrollbar-bg-l1) calc(var(--dsh-width-handle-pointer-y,50%) + 8px), transparent calc(var(--dsh-width-handle-pointer-y,50%) + 36px));opacity:0;pointer-events:none;border-radius:2px;width:2px;position:absolute;top:0;bottom:0}.vbpo1q_widthHandle[data-side=left]:after{right:4px}.vbpo1q_widthHandle[data-side=right]:after{left:4px}.vbpo1q_widthHandle:hover:after,.vbpo1q_widthHandle[data-dragging]:after{opacity:1}.vbpo1q_widthHandle[data-dragging]{z-index:8}.vbpo1q_root:has([data-conversation-composer-overlay]) .vbpo1q_widthHandle{display:none}.vbpo1q_composerStack{--dsh-composer-stack-gap:6px;gap:var(--dsh-composer-stack-gap);flex-direction:column;display:flex}.vbpo1q_composerSeat{-webkit-user-select:none;user-select:none;--dsh-composer-text-max-height:336px;flex-direction:column;flex:none;display:flex}.vbpo1q_composerSeat :is(input,textarea,[contenteditable=true],[contenteditable=""]){-webkit-user-select:text;user-select:text}.vbpo1q_root[data-phase=active]{overflow:hidden}.vbpo1q_root[data-phase=active] .vbpo1q_header{flex:none}.vbpo1q_body{--dsh-chat-content-width:var(--dsh-chat-user-width,clamp(680px, calc(var(--dsh-conversation-column-width,0px) * .64), 920px));--dsh-composer-card-max-width:calc(var(--dsh-chat-content-width) + 32px);--dsh-composer-side-clearance:16px;--dsh-composer-dock-inset:8px;flex-direction:column;flex:1;min-height:0;display:flex;position:relative}.vbpo1q_embeddedBody{--dsh-chat-content-width:min(calc(100% - 32px), 920px);--dsh-composer-card-max-width:min(calc(100% - 16px), 952px);--dsh-composer-side-clearance:8px;--dsh-composer-dock-inset:8px;overflow:hidden}.vbpo1q_scrollBody{scrollbar-gutter:stable;flex-direction:column;flex:1;min-height:0;margin-right:2px;display:flex;overflow:hidden auto}html[data-tauri-shell] .vbpo1q_scrollBody{overscroll-behavior-y:none}.vbpo1q_scrollBody::-webkit-scrollbar-track{margin:2px}.vbpo1q_root[data-phase=active] .vbpo1q_viewArea,.vbpo1q_embeddedBody[data-content-phase=active] .vbpo1q_viewArea{flex:1 0 auto;min-height:auto}.vbpo1q_root[data-phase=active] .vbpo1q_composerSeat,.vbpo1q_embeddedBody[data-content-phase=active] .vbpo1q_composerSeat{z-index:7;background:var(--dsh-phone-composer-mask,linear-gradient(180deg, color-mix(in srgb, var(--dsw-alias-bg-base) 0%, transparent) 0px, var(--dsw-alias-bg-base) 36px));margin-top:auto;position:sticky;bottom:0}@supports (backdrop-filter:blur(14px)){[data-phone] .vbpo1q_composerSeat:where(:has([data-chain-overlay-fallback=conversation\\.composer]:only-child [data-composer-card])){--dsh-phone-composer-mask:linear-gradient(180deg, transparent 0px, color-mix(in srgb, var(--dsw-alias-bg-base) 60%, transparent) 36px, color-mix(in srgb, var(--dsw-alias-bg-base) 60%, transparent) calc(100% - 28px), var(--dsw-alias-bg-base) 100%)}}@media (prefers-reduced-transparency:reduce),(prefers-contrast:more),(forced-colors:active){[data-phone] .vbpo1q_composerSeat{--dsh-phone-composer-mask:initial}}body[data-codexhost-wallpaper] .vbpo1q_root[data-phase=active] .vbpo1q_composerSeat,body[data-codexhost-wallpaper] .vbpo1q_embeddedBody[data-content-phase=active] .vbpo1q_composerSeat{background:0 0}.vbpo1q_root[data-phase=active] .vbpo1q_composerSeat:has([data-trigger-menu]){z-index:9}.vbpo1q_scrollBody[data-selection-drag]{scroll-padding-bottom:var(--dsh-composer-height,0px)}.vbpo1q_scrollBody[data-selection-drag]>.vbpo1q_composerSeat :is(input,textarea,[contenteditable=true],[contenteditable=""]){pointer-events:none}.vbpo1q_scrollBody:has([data-conversation-composer-overlay]){scrollbar-gutter:auto;position:relative;overflow:hidden auto}.vbpo1q_scrollBody:has([data-conversation-composer-overlay])>[data-slot=conversation\\.session]>.vbpo1q_viewArea{flex:1 1 0;min-height:0;overflow:hidden}.vbpo1q_scrollBody:has([data-conversation-composer-overlay])>.vbpo1q_composerSeat{right:var(--dsh-scrollbar-width);position:absolute;bottom:0;left:0}.vbpo1q_composerHero{width:min(calc(var(--dsh-composer-card-max-width) + 2 * var(--dsh-composer-side-clearance)), 100%);z-index:1;align-self:center;gap:16px;padding-bottom:32px}.vbpo1q_heroTopBarInner{align-items:center;gap:4px;width:100%;min-width:0;display:flex}.vbpo1q_heroAgentPresetSeat{flex:none;align-items:center;margin-left:auto;display:flex}.vbpo1q_heroAgentPresetSeat:empty{display:none}.vbpo1q_root[data-phase=hero] .vbpo1q_scrollBody,.vbpo1q_embeddedBody[data-content-phase=hero] .vbpo1q_scrollBody{justify-content:center;overflow-y:auto}.vbpo1q_root[data-phase=settling] .vbpo1q_composerSeat,.vbpo1q_embeddedBody[data-content-phase=settling] .vbpo1q_composerSeat{visibility:hidden}`,document.head.appendChild(e)}var Q={body:`vbpo1q_body`,composerHero:`vbpo1q_composerHero`,composerSeat:`vbpo1q_composerSeat`,composerStack:`vbpo1q_composerStack`,crumb:`vbpo1q_crumb`,crumbCurrent:`vbpo1q_crumbCurrent`,crumbRoleAvatar:`vbpo1q_crumbRoleAvatar`,crumbSeg:`vbpo1q_crumbSeg`,crumbSep:`vbpo1q_crumbSep`,crumbSubagent:`vbpo1q_crumbSubagent`,crumbs:`vbpo1q_crumbs`,embeddedBody:`vbpo1q_embeddedBody`,header:`vbpo1q_header`,headerActions:`vbpo1q_headerActions`,headerBlank:`vbpo1q_headerBlank`,headerCorner:`vbpo1q_headerCorner`,headerLeading:`vbpo1q_headerLeading`,headerSessionless:`vbpo1q_headerSessionless`,headerUtilities:`vbpo1q_headerUtilities`,heroAgentPresetSeat:`vbpo1q_heroAgentPresetSeat`,heroTopBarInner:`vbpo1q_heroTopBarInner`,phoneTrailingAction:`vbpo1q_phoneTrailingAction`,root:`vbpo1q_root`,scrollBody:`vbpo1q_scrollBody`,tab:`vbpo1q_tab`,tabActive:`vbpo1q_tabActive`,tabs:`vbpo1q_tabs`,titleCenter:`vbpo1q_titleCenter`,titleCluster:`vbpo1q_titleCluster`,titleRow:`vbpo1q_titleRow`,viewArea:`vbpo1q_viewArea`,widthHandle:`vbpo1q_widthHandle`};let BA=`dsh.conversation.contentWidth`;function VA(){let e=localStorage.getItem(BA);if(e===null)return null;let t=Number(e);return Number.isFinite(t)&&t>0?t:null}function HA(e,t){let n=Math.max(640,e-176);return t===null?Math.max(680,Math.min(e*.64,920)):Math.min(Math.max(t,640),n)}function UA(e,t){if(e.deltaMode===1){let n=Number.parseFloat(getComputedStyle(t).lineHeight);return e.deltaY*(Number.isFinite(n)?n:16)}return e.deltaMode===2?e.deltaY*t.clientHeight:e.deltaY}function WA(e){let t=(0,g.useRef)(!1),n=(0,g.useRef)(0),r=(0,g.useRef)(0),i=(0,g.useRef)(0),a=(0,g.useRef)(null),o=(0,g.useRef)(e);o.current=e;let s=()=>{let e=i.current-r.current,t=o.current.side===`right`?e:-e;return n.current+t*2},c=()=>{a.current!==null&&(cancelAnimationFrame(a.current),a.current=null)},l=(0,g.useCallback)(e=>{e.button===0&&(e.preventDefault(),e.currentTarget.setPointerCapture(e.pointerId),r.current=e.clientX,i.current=e.clientX,n.current=o.current.onStart(),t.current=!0,e.currentTarget.toggleAttribute(`data-dragging`,!0))},[]),u=(0,g.useCallback)(e=>{if(!t.current||!e.currentTarget.hasPointerCapture(e.pointerId))return;let n=e.currentTarget.getBoundingClientRect();e.currentTarget.style.setProperty(`--dsh-width-handle-pointer-y`,`${e.clientY-n.top}px`),i.current=e.clientX,a.current??=requestAnimationFrame(()=>{a.current=null,o.current.onDrag(s())})},[]),d=(0,g.useCallback)(e=>{t.current&&e.currentTarget.hasPointerCapture(e.pointerId)&&(t.current=!1,e.currentTarget.toggleAttribute(`data-dragging`,!1),e.currentTarget.releasePointerCapture(e.pointerId),c(),i.current=e.clientX,i.current!==r.current&&o.current.onCommit(s()),o.current.onEnd())},[]),f=(0,g.useCallback)(e=>{t.current&&(t.current=!1,e.currentTarget.toggleAttribute(`data-dragging`,!1),c(),o.current.onEnd())},[]),p=(0,g.useCallback)(e=>{let t=e.currentTarget.parentElement;
168
168
  /* v8 ignore next -- a width handle renders only inside the Conversation body. */
169
169
  if(t===null)return;let n=t.querySelector(`:scope > [data-conversation-scroll]`);
170
170
  /* v8 ignore next -- the Conversation body always contains its direct scroll element. */
171
- n!==null&&(e.ctrlKey||e.deltaY===0||n.scrollBy({top:qk(e,n)}))},[]);return/* @__PURE__ */ (0,h.jsx)(`div`,{className:Q.widthHandle,"data-side":e.side,"data-width-handle":e.side,onPointerDown:l,onPointerMove:u,onPointerUp:d,onPointerCancel:f,onLostPointerCapture:f,onWheel:p})}function Yk({container:e,phase:t}){let n=(0,g.useCallback)(e=>{let t=e.parentElement??e,n=e.offsetWidth;t.style.setProperty(`--dsh-conversation-column-width`,`${n}px`);let r=Gk();r===null?t.style.removeProperty(`--dsh-chat-user-width`):t.style.setProperty(`--dsh-chat-user-width`,`${Kk(n,r)}px`)},[]);(0,g.useLayoutEffect)(()=>{if(e===null)return;let t=new ResizeObserver(()=>{n(e)});return t.observe(e),n(e),()=>{t.disconnect()}},[e,n]);let r=(0,g.useCallback)(()=>e===null?680:Kk(e.offsetWidth,Gk()),[e]),i=(0,g.useCallback)(t=>{e!==null&&(e.parentElement??e).style.setProperty(`--dsh-chat-user-width`,`${Kk(e.offsetWidth,t)}px`)},[e]),a=(0,g.useCallback)(t=>{e!==null&&localStorage.setItem(Wk,`${Kk(e.offsetWidth,t)}`)},[e]),o=(0,g.useCallback)(()=>{e!==null&&n(e)},[e,n]);return e===null||t!==`active`?null:[`left`,`right`].map(e=>/* @__PURE__ */ (0,h.jsx)(Jk,{side:e,onStart:r,onDrag:i,onCommit:a,onEnd:o},e))}let Xk={widthControls:Yk};function Zk(e){let{sessionId:t,useSession:n,useSessions:r,useConversation:i,renderSlot:a,renderFactorySlot:o}=e,s=n(e=>e),c=i(e=>e),l=s===void 0||c===void 0?`blank`:Hk(s,c),u=s?.openState,d=r(e=>t===void 0?void 0:e.byId[t]?.blank),f=s?.subagent?.address.mode===`continuable`&&s.subagent.parentAvailable===void 0,p=t!==void 0&&(l===`blank`&&u===`loading`&&d!==!0||f),m=t===void 0||l===`blank`&&(u===`open`||d===!0),g=p?`settling`:m?`hero`:`active`;return/* @__PURE__ */ (0,h.jsxs)(`div`,{className:Q.root,"data-phase":g,"data-cx-region":`conversation`,children:[a(`conversation.header`,{}),a(`conversation.header.notice`,{}),o(`conversation.content`,{variant:`main`,phase:g,hero:m},{slots:Xk})]})}function Qk(e){return/* @__PURE__ */ (0,h.jsx)(Zk,{...e})}function $k(e,t){return e===`default-workspace`?t:e}let eA=`@deepseek-ai/dsh-client-ui-conversation/HeroShell.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(eA)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-conversation`,e.dataset.pluginCss=eA,e.textContent=`.Dgrl1G_root{justify-content:center;align-items:center;min-width:0;height:100%;padding:0 24px;display:flex}.Dgrl1G_stack{width:100%;max-width:var(--dsh-composer-card-max-width);flex-direction:column;align-items:stretch;gap:12px;display:flex;overflow:visible}.Dgrl1G_headline{color:var(--dsw-alias-label-primary);flex-wrap:wrap;justify-content:center;align-items:center;gap:12px 10px;font-size:26px;font-weight:500;line-height:32px;display:flex}.Dgrl1G_titleGroup{flex-wrap:wrap;justify-content:center;align-items:center;gap:4px 7px;min-width:0;display:flex}.Dgrl1G_previewBadge{border:.5px solid var(--dsw-alias-interactive-bg-hover);corner-shape:round;background:var(--dsw-alias-state-business-tertiary);color:var(--dsw-alias-label-primary-bluish);font-family:var(--ds-font-family-code);white-space:nowrap;border-radius:999px;align-self:flex-start;margin-top:2px;padding:1px 7px 0;font-size:12px;font-weight:500;line-height:18px}.Dgrl1G_previewBadgeDesktop{display:none}html[data-codexhost-shell] .Dgrl1G_previewBadgeWeb,html[data-tauri-shell] .Dgrl1G_previewBadgeWeb{display:none}html[data-codexhost-shell] .Dgrl1G_previewBadgeDesktop,html[data-tauri-shell] .Dgrl1G_previewBadgeDesktop{display:inline}.Dgrl1G_fishHitbox{flex:none;justify-content:center;align-items:center;display:inline-flex}.Dgrl1G_fish{transform-origin:50% 60%;color:var(--dsw-alias-label-primary);display:block;overflow:visible}@keyframes Dgrl1G_hero-fish-swim{0%,to{transform:none}35%{transform:rotate(-4deg)translate(-.4px,-.9px)}70%{transform:rotate(1.6deg)translate(.3px,.2px)}}@media (hover:hover) and (prefers-reduced-motion:no-preference){.Dgrl1G_fishHitbox:hover .Dgrl1G_fish{animation:1.6s ease-in-out infinite Dgrl1G_hero-fish-swim}}.Dgrl1G_body{flex-direction:column;gap:12px;min-width:0;display:flex;position:relative;overflow:visible}.Dgrl1G_body>*{z-index:1;position:relative}.Dgrl1G_body>.Dgrl1G_workspaceRow{z-index:10;align-items:center;min-width:0;padding-left:8px;display:flex}.Dgrl1G_workspace{border-radius:var(--dsw-radius-sm);max-width:min(100%,360px);min-height:28px;color:var(--dsw-alias-label-primary);cursor:pointer;background:0 0;border:none;align-items:center;gap:4px;padding:0 8px;font-size:13px;font-weight:500;line-height:20px;display:inline-flex}.Dgrl1G_workspace:not(:disabled):hover,.Dgrl1G_workspace[aria-expanded=true]{background:var(--dsw-alias-interactive-bg-hover)}.Dgrl1G_workspace:disabled{cursor:default}.Dgrl1G_folder{color:var(--dsw-alias-label-primary);flex:none}.Dgrl1G_workspaceLabel{text-overflow:ellipsis;white-space:nowrap;min-width:0;overflow:hidden}.Dgrl1G_chevron{color:var(--dsw-alias-label-caption);flex:none}.Dgrl1G_modalInput{box-sizing:border-box;border:.5px solid var(--dsw-alias-border-l4);border-radius:var(--dsw-radius-lg);width:100%;height:44px;color:var(--dsw-alias-label-primary);background:0 0;outline:none;padding:7px 14px;font-size:14px;font-weight:400;line-height:22px}.Dgrl1G_modalInput::placeholder{color:var(--dsw-alias-label-caption)}.Dgrl1G_modalInput:disabled{color:var(--dsw-alias-label-dimmed)}.Dgrl1G_modalAction{min-width:72px}.Dgrl1G_modalError{color:var(--dsw-alias-state-error-primary);margin-top:8px;font-size:12px;line-height:18px}`,document.head.appendChild(e)}var tA={body:`Dgrl1G_body`,chevron:`Dgrl1G_chevron`,fish:`Dgrl1G_fish`,fishHitbox:`Dgrl1G_fishHitbox`,folder:`Dgrl1G_folder`,headline:`Dgrl1G_headline`,"hero-fish-swim":`Dgrl1G_hero-fish-swim`,modalAction:`Dgrl1G_modalAction`,modalError:`Dgrl1G_modalError`,modalInput:`Dgrl1G_modalInput`,previewBadge:`Dgrl1G_previewBadge`,previewBadgeDesktop:`Dgrl1G_previewBadgeDesktop`,previewBadgeWeb:`Dgrl1G_previewBadgeWeb`,root:`Dgrl1G_root`,stack:`Dgrl1G_stack`,titleGroup:`Dgrl1G_titleGroup`,workspace:`Dgrl1G_workspace`,workspaceLabel:`Dgrl1G_workspaceLabel`,workspaceRow:`Dgrl1G_workspaceRow`};function nA(e){let t=Qu(e);return t===``?e:t}function rA({buttonRef:e,label:t,projectless:n=!1,menuOpen:r=!1,onClick:i,t:a}){return/* @__PURE__ */ (0,h.jsxs)(`button`,{ref:e,type:`button`,className:tA.workspace,"aria-label":a(`hero.chooseWorkspace`),"aria-haspopup":`menu`,"aria-expanded":r,onClick:i,children:[t===void 0||n?/* @__PURE__ */ (0,h.jsx)(d.IconFolderCloseRegular,{className:tA.folder,size:16}):/* @__PURE__ */ (0,h.jsx)(d.IconFolderOpenRegular,{className:tA.folder,size:16}),/* @__PURE__ */ (0,h.jsx)(`span`,{className:tA.workspaceLabel,children:t??a(`hero.chooseWorkspace`)}),/* @__PURE__ */ (0,h.jsx)(d.IconChevronDownOutlineRegular,{className:tA.chevron,size:12})]})}function iA({hovering:e}){return/* @__PURE__ */ (0,h.jsx)(`svg`,{className:tA.fish,width:34,height:34*d.FISH_LOGO_VIEWBOX.height/d.FISH_LOGO_VIEWBOX.width,viewBox:`0 0 ${d.FISH_LOGO_VIEWBOX.width} ${d.FISH_LOGO_VIEWBOX.height}`,fill:`none`,"aria-hidden":`true`,children:/* @__PURE__ */ (0,h.jsx)(`path`,{d:d.FISH_LOGO_PATH,fill:`currentColor`,children:e&&/* @__PURE__ */ (0,h.jsx)(`animate`,{attributeName:`d`,values:`${d.FISH_LOGO_PATH};M22.403 0.567C22.145 0.477 22.068 0.718 21.939 0.85C21.895 0.893 21.86 0.947 21.824 0.997C21.515 1.421 21.13 1.721 20.591 1.77C19.829 1.867 19.221 2.244 18.712 2.958C18.535 2.227 18.116 1.839 17.516 1.626C17.203 1.506 16.887 1.379 16.663 1.064C16.508 0.839 16.462 0.581 16.383 0.329C16.332 0.176 16.283 0.02 16.121 -0.002C15.944 -0.029 15.875 0.133 15.805 0.269C15.52 0.822 15.408 1.43 15.42 2.046C15.449 3.432 16.031 4.532 17.202 5.274C17.337 5.356 17.374 5.445 17.335 5.582C17.261 5.862 17.169 6.134 17.086 6.413C17.032 6.59 16.952 6.63 16.764 6.558C16.118 6.301 15.562 5.909 15.074 5.433C14.248 4.633 13.5 3.751 12.568 3.06C12.349 2.898 12.13 2.748 11.903 2.605C10.952 1.682 12.028 0.923 12.277 0.833C12.537 0.739 12.367 0.416 11.526 0.42C10.684 0.424 9.914 0.706 8.933 1.081C8.789 1.138 8.638 1.179 8.484 1.213C7.593 1.044 6.668 1.006 5.702 1.115C3.883 1.318 2.43 2.178 1.362 3.646C0.079 5.41 -0.223 7.415 0.147 9.506C0.535 11.71 1.66 13.535 3.389 14.962C5.181 16.441 7.246 17.166 9.601 17.027C11.032 16.944 12.624 16.753 14.421 15.232C14.874 15.458 15.35 15.548 16.138 15.615C16.746 15.672 17.331 15.585 17.784 15.491C18.493 15.341 18.444 14.684 18.188 14.564C16.108 13.595 16.565 13.989 16.15 13.67C17.206 12.42 18.82 10.198 19.363 7.086C19.421 6.709 19.484 6.171 19.469 5.866C19.458 5.681 19.493 5.604 19.681 5.556C20.199 5.412 20.691 5.172 21.125 4.806C22.366 3.824 22.758 2.554 22.708 1.1C22.7 0.878 22.649 0.654 22.403 0.567ZM11.175 14.451C9.159 12.726 8.182 12.088 7.778 12.067C7.401 12.047 7.469 12.505 7.552 12.807C7.639 13.103 7.752 13.313 7.91 13.581C8.02 13.758 8.095 14.01 7.801 14.16C7.152 14.487 6.023 13.806 5.97 13.772C4.657 12.85 3.559 11.766 2.785 10.369C2.037 9.025 1.603 7.583 1.532 6.044C1.513 5.672 1.622 5.541 1.992 5.473C2.479 5.383 2.981 5.364 3.468 5.436C5.525 5.736 7.276 6.675 8.744 8.323C9.582 9.299 10.216 10.425 10.869 11.496C11.563 12.592 12.31 13.603 13.262 14.414C13.598 14.696 13.866 14.91 14.123 15.068C13.349 15.154 12.058 15.167 11.175 14.452L11.175 14.451ZM12.141 8.26C12.141 8.095 12.273 7.963 12.439 7.963C12.476 7.963 12.511 7.971 12.541 7.982C12.582 7.997 12.62 8.019 12.65 8.053C12.704 8.106 12.733 8.181 12.733 8.26C12.733 8.425 12.601 8.556 12.435 8.556C12.27 8.556 12.141 8.425 12.141 8.26ZM15.142 9.799C14.949 9.878 14.757 9.945 14.572 9.953C14.284 9.968 13.972 9.851 13.802 9.709C13.537 9.487 13.348 9.363 13.27 8.977C13.236 8.812 13.255 8.556 13.284 8.41C13.352 8.094 13.277 7.892 13.055 7.708C12.873 7.558 12.643 7.516 12.39 7.516C12.296 7.516 12.209 7.475 12.145 7.441C12.039 7.389 11.952 7.257 12.035 7.096C12.062 7.043 12.19 6.916 12.22 6.893C12.563 6.698 12.96 6.762 13.326 6.908C13.665 7.047 13.922 7.302 14.292 7.663C14.669 8.098 14.738 8.218 14.953 8.545C15.123 8.801 15.277 9.063 15.383 9.364C15.447 9.551 15.364 9.705 15.142 9.799Z;${d.FISH_LOGO_PATH};M23.271 2.216C23.039 2.071 22.91 2.287 22.755 2.388C22.703 2.42 22.656 2.464 22.61 2.505C22.214 2.848 21.771 3.054 21.225 2.956C20.412 2.784 19.68 2.919 19.005 3.435C18.92 2.663 18.493 2.157 17.808 1.798C17.446 1.621 17.08 1.449 16.83 1.111C16.656 0.872 16.611 0.612 16.524 0.354C16.469 0.198 16.414 0.039 16.223 0.009C16.017 -0.024 15.936 0.137 15.856 0.271C15.539 0.822 15.418 1.43 15.429 2.046C15.454 3.432 16.041 4.538 17.196 5.36C17.325 5.456 17.356 5.547 17.312 5.674C17.229 5.936 17.134 6.191 17.051 6.454C16.999 6.623 16.921 6.659 16.738 6.58C16.107 6.306 15.56 5.909 15.074 5.433C14.248 4.633 13.5 3.751 12.568 3.06C12.349 2.898 12.13 2.748 11.903 2.605C10.952 1.682 12.028 0.923 12.277 0.833C12.537 0.739 12.367 0.416 11.526 0.42C10.684 0.424 9.914 0.706 8.933 1.081C8.789 1.138 8.638 1.179 8.484 1.213C7.593 1.044 6.668 1.006 5.702 1.115C3.883 1.318 2.43 2.178 1.362 3.646C0.079 5.41 -0.223 7.415 0.147 9.506C0.535 11.71 1.66 13.535 3.389 14.962C5.181 16.441 7.246 17.166 9.601 17.027C11.032 16.944 12.624 16.753 14.421 15.232C14.874 15.458 15.35 15.548 16.138 15.615C16.746 15.672 17.331 15.585 17.784 15.491C18.493 15.341 18.444 14.684 18.188 14.564C16.108 13.595 16.565 13.989 16.15 13.67C17.206 12.42 18.82 10.198 19.278 7.246C19.318 6.948 19.375 6.534 19.371 6.293C19.371 6.145 19.411 6.092 19.597 6.098C20.113 6.109 20.619 6.051 21.096 5.891C22.503 5.375 23.169 4.232 23.448 2.804C23.49 2.586 23.491 2.356 23.271 2.216ZM11.175 14.49C9.159 13.005 8.182 12.567 7.778 12.621C7.401 12.673 7.469 13.087 7.552 13.354C7.639 13.619 7.752 13.797 7.91 14.024C8.02 14.175 8.095 14.406 7.801 14.609C7.152 15.063 6.023 14.63 5.97 14.609C4.657 13.941 3.559 12.965 2.785 11.569C2.037 10.225 1.603 8.783 1.532 7.244C1.513 6.872 1.622 6.741 1.992 6.673C2.479 6.583 2.981 6.564 3.468 6.636C5.525 6.936 7.276 7.843 8.744 9.163C9.582 9.888 10.216 10.783 10.869 11.679C11.563 12.659 12.31 13.617 13.262 14.415C13.598 14.696 13.866 14.91 14.123 15.068C13.349 15.155 12.058 15.177 11.175 14.491L11.175 14.49ZM12.141 8.26C12.141 8.095 12.273 7.963 12.439 7.963C12.476 7.963 12.511 7.971 12.541 7.982C12.582 7.997 12.62 8.019 12.65 8.053C12.704 8.106 12.733 8.181 12.733 8.26C12.733 8.425 12.601 8.556 12.435 8.556C12.27 8.556 12.141 8.425 12.141 8.26ZM15.142 9.799C14.949 9.878 14.757 9.945 14.572 9.953C14.284 9.968 13.972 9.851 13.802 9.709C13.537 9.487 13.348 9.363 13.27 8.977C13.236 8.812 13.255 8.556 13.284 8.41C13.352 8.094 13.277 7.892 13.055 7.708C12.873 7.558 12.643 7.516 12.39 7.516C12.296 7.516 12.209 7.475 12.145 7.441C12.039 7.389 11.952 7.257 12.035 7.096C12.062 7.043 12.19 6.916 12.22 6.893C12.563 6.698 12.96 6.762 13.326 6.908C13.665 7.047 13.922 7.302 14.292 7.663C14.669 8.098 14.738 8.218 14.953 8.545C15.123 8.801 15.277 9.063 15.383 9.364C15.447 9.551 15.364 9.705 15.142 9.799Z;${d.FISH_LOGO_PATH}`,keyTimes:`0;0.35;0.55;0.75;1`,calcMode:`spline`,keySplines:`0.45 0 0.55 1;0.45 0 0.55 1;0.45 0 0.55 1;0.45 0 0.55 1`,dur:`1.6s`,repeatCount:`indefinite`})})})}function aA({t:e,renderSlot:t,children:n}){let[r,i]=(0,g.useState)(!1);return/* @__PURE__ */ (0,h.jsxs)(`div`,{className:tA.root,children:[/* @__PURE__ */ (0,h.jsxs)(`div`,{className:tA.stack,children:[/* @__PURE__ */ (0,h.jsxs)(`div`,{className:tA.headline,children:[/* @__PURE__ */ (0,h.jsx)(`span`,{className:tA.fishHitbox,onMouseEnter:()=>{window.matchMedia(`(hover: hover) and (prefers-reduced-motion: no-preference)`).matches&&i(!0)},onMouseLeave:()=>{i(!1)},children:t(`conversation.hero.brand.mark`,{size:34,className:tA.fish},{fallback:/* @__PURE__ */ (0,h.jsx)(iA,{hovering:r})})}),/* @__PURE__ */ (0,h.jsxs)(`span`,{className:tA.titleGroup,children:[/* @__PURE__ */ (0,h.jsx)(`span`,{children:e(`hero.headline`)}),/* @__PURE__ */ (0,h.jsxs)(`span`,{className:tA.previewBadge,children:[/* @__PURE__ */ (0,h.jsx)(`span`,{className:tA.previewBadgeWeb,children:e(`hero.preview`)}),/* @__PURE__ */ (0,h.jsx)(`span`,{className:tA.previewBadgeDesktop,children:e(`hero.previewDesktop`)})]})]})]}),/* @__PURE__ */ (0,h.jsx)(`div`,{className:tA.body})]}),n]})}let oA=`@deepseek-ai/dsh-client-ui-conversation/ThreadReferenceDropTarget.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(oA)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-conversation`,e.dataset.pluginCss=oA,e.textContent=`.tWXKHq_overlay{z-index:30;pointer-events:none;background:color-mix(in srgb, var(--dsw-alias-state-business-tertiary) 88%, transparent);place-items:center;display:grid;position:absolute;inset:0}.tWXKHq_invitation{flex-direction:column;align-items:center;gap:8px;max-width:calc(100% - 40px);display:flex}.tWXKHq_hint{border:1px solid color-mix(in srgb, var(--dsw-alias-state-business-primary) 15%, transparent);background:var(--dsw-alias-state-business-tertiary);color:var(--dsw-alias-label-primary);border-radius:10px;padding:8px 16px;font-size:16px;line-height:24px;box-shadow:0 1px 4px #00000014}.tWXKHq_preview{box-sizing:border-box;border:1px solid var(--dsw-alias-border-l3);background:var(--dsw-alias-bg-base);max-width:min(440px,100%);color:var(--dsw-alias-label-primary);border-radius:12px;align-items:center;gap:10px;padding:10px 14px;font-size:14px;line-height:20px;display:flex;box-shadow:0 4px 14px #00000014}.tWXKHq_preview svg{flex:none}.tWXKHq_title{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}`,document.head.appendChild(e)}var sA={hint:`tWXKHq_hint`,invitation:`tWXKHq_invitation`,overlay:`tWXKHq_overlay`,preview:`tWXKHq_preview`,title:`tWXKHq_title`};function cA({container:e,editor:t,useSessions:n,t:r}){let i=n(e=>e.byId),a=(0,g.useRef)(i);a.current=i;let[o,s]=(0,g.useState)(null);return(0,g.useEffect)(()=>{if(e===null||t===void 0)return;let n,r=()=>{n=void 0,s(null)},i=()=>t.isEditable()&&t.getRootElement()!==null,o=e=>{let t=e.dataTransfer;return t?.types.includes(`application/x-codexhost-thread-reference`)&&!t.types.includes(`Files`)?t:null},c=e=>{let t=e===void 0?void 0:rC(nC(e)),n=t===void 0?void 0:a.current[t];return n!==void 0&&tC(n)!==void 0},l=t=>!(t instanceof Node)||!e.contains(t)?!1:(t instanceof Element?t:t.parentElement)?.closest(`[data-conversation-content]`)===e,u=e=>{r();let t=o(e),i=t===null?void 0:aC(t.getData($S));c(i)&&(n=i)},d=e=>{let r=o(e);r===null||!l(e.target)?s(null):!i()||!c(n)?(e.preventDefault(),e.stopPropagation(),r.dropEffect=`none`,s(null)):t.dispatchCommand(Qp,e)&&s(n??null)},f=t=>{if(t.relatedTarget instanceof Node&&e.contains(t.relatedTarget))return;let n=e.getBoundingClientRect();(t.relatedTarget!==null||t.target===e||t.clientX<=n.left||t.clientX>=n.right||t.clientY<=n.top||t.clientY>=n.bottom)&&s(null)},p=e=>{let a=o(e);if(a!==null&&l(e.target)){let r=aC(a.getData($S));i()&&c(r)&&r?.threadId===n?.threadId&&r?.hostId===n?.hostId?t.dispatchCommand(Xp,e):(e.preventDefault(),e.stopPropagation(),a.dropEffect=`none`)}r()},m=e=>{e.key===`Escape`&&r()},h=t.registerEditableListener(e=>{e||r()});return document.addEventListener(`dragstart`,u),document.addEventListener(`dragenter`,d,!0),document.addEventListener(`dragover`,d,!0),document.addEventListener(`dragleave`,f,!0),document.addEventListener(`drop`,p,!0),window.addEventListener(`dragend`,r),window.addEventListener(`blur`,r),window.addEventListener(`keydown`,m,!0),()=>{h(),document.removeEventListener(`dragstart`,u),document.removeEventListener(`dragenter`,d,!0),document.removeEventListener(`dragover`,d,!0),document.removeEventListener(`dragleave`,f,!0),document.removeEventListener(`drop`,p,!0),window.removeEventListener(`dragend`,r),window.removeEventListener(`blur`,r),window.removeEventListener(`keydown`,m,!0)}},[e,t]),o===null?null:/* @__PURE__ */ (0,h.jsx)(`div`,{className:sA.overlay,"data-thread-reference-drop":!0,role:`status`,"aria-live":`polite`,children:/* @__PURE__ */ (0,h.jsxs)(`div`,{className:sA.invitation,children:[/* @__PURE__ */ (0,h.jsx)(`div`,{className:sA.hint,children:r(`reference.dropTitle`)}),/* @__PURE__ */ (0,h.jsxs)(`div`,{className:sA.preview,"data-thread-reference-preview":!0,children:[/* @__PURE__ */ (0,h.jsx)(d.ReferenceIconRegular,{kind:`session`,size:20}),/* @__PURE__ */ (0,h.jsx)(`span`,{className:sA.title,children:o.title})]})]})})}let lA=`data-selection-drag`,uA=[`pointerup`,`pointercancel`,`dragstart`,`contextmenu`];function dA(e){let t=e.ownerDocument.defaultView;if(t===null)return()=>{};let n=()=>{e.removeAttribute(lA);for(let e of uA)t.removeEventListener(e,n,!0);t.removeEventListener(`blur`,n)},r=r=>{if(r.pointerType!==`mouse`||r.button!==0)return;let i=r.target instanceof Element?r.target:null;if(i!==null&&i.closest(`[data-composer-seat]`)===null){e.setAttribute(lA,``);for(let e of uA)t.addEventListener(e,n,!0);t.addEventListener(`blur`,n)}};return e.addEventListener(`pointerdown`,r,!0),()=>{e.removeEventListener(`pointerdown`,r,!0),n()}}function fA({renderSlot:e}){return e(`conversation.session`,{})}function pA({session:e,useInput:t,renderSlot:n}){let r=t(e=>e);return e===void 0||r===void 0?null:n(`conversation.input.dock`,{session:e,input:r})}function mA(){return null}function hA(e){let{sessionId:t,phase:n,hero:r,useSession:i,useSessions:a,useSessionStatus:o,useWorkspaces:s,useInput:c,useComposerBlock:l,useSessionCreation:u,renderSlot:d,renderSlotChain:f,selectWorkspace:p,retrySessionCreation:m,referenceEditor:_,t:v,useFactorySlot:y}=e,b=i(e=>e),ee=y(`views`,fA),te=y(`widthControls`,mA),[ne,re]=(0,g.useState)(null),ie=o(e=>t===void 0?void 0:e.get(t)?.pendingInteraction),ae=a(e=>t===void 0?void 0:e.byId[t]?.cwd),oe=s(e=>e),se=l(e=>e),ce=u(e=>e),le=t===void 0&&ce.state!==`idle`?ce.workspaceId:void 0,[ue,de]=(0,g.useState)(!1),[fe,pe]=(0,g.useState)(),me=(0,g.useRef)(null),x=(0,g.useRef)(null),S=(0,g.useCallback)(e=>{x.current?.disconnect(),x.current=null;let t=e?.parentElement??null;e!==null&&t!==null&&(x.current=new ResizeObserver(()=>{t.style.setProperty(`--dsh-composer-height`,`${e.offsetHeight}px`),t.style.setProperty(`--dsh-conversation-viewport-height`,`${t.clientHeight}px`)}),x.current.observe(e),x.current.observe(t))},[]);(0,g.useEffect)(()=>{let e=ne?.querySelector(`:scope > [data-conversation-scroll]`);return e==null?void 0:dA(e)},[ne]);let he=t===void 0?void 0:oe.items.find(e=>e.sessionIds.includes(t)),ge=fe?fe.id:le,_e=oe.items.find(e=>e.workspaceId===ge),ve=(ge===null?void 0:_e?.title)??(ge===null||t===void 0?void 0:he?.title??(oe.phase===`ready`||ae===void 0||ae===``?void 0:nA(ae))),ye=ve===void 0?void 0:$k(ve,v(`workspace.defaultName`)),be=/* @__PURE__ */ (0,h.jsxs)(`div`,{className:Q.heroTopBarInner,children:[d(`conversation.hero.workspace`,{open:ue,anchorRef:me,selectedId:ge===null?void 0:ge??he?.workspaceId,fallbackLabel:ye,onOpenChange:de,onPick:e=>{de(!1);let t={id:e};pe(t);let n=()=>pe(e=>e===t?void 0:e);p(e).then(n,n)},onClose:()=>{de(!1)}},{fallback:/* @__PURE__ */ (0,h.jsx)(rA,{buttonRef:me,label:ye??(oe.canStartProjectless?v(`hero.noWorkspace`):void 0),projectless:oe.canStartProjectless===!0&&ye===void 0,menuOpen:ue,onClick:()=>{de(e=>!e)},t:v})}),/* @__PURE__ */ (0,h.jsx)(`div`,{className:Q.heroAgentPresetSeat,children:d(`conversation.hero.agentPreset`,{})})]}),xe=oe.phase===`ready`&&!oe.canStartProjectless&&ye===void 0,Se=t===void 0&&ce.state!==`idle`,Ce=t!==void 0&&r&&b?.openState===`loading`&&!xe,we=r&&fe!==void 0,Te=!we&&t!==void 0&&b?.openState===`error`,Ee=Te&&b?.openError?.code===`remote/unsupported`,De=we||!Te&&(t===void 0||b?.openState!==`open`)&&!xe,Oe=we||t===void 0||b?.openState!==`open`||r&&xe,ke=!Oe&&se!==void 0,Ae=d(`conversation.composer.bar`,{variant:r?`hero`:`composer`,...r?{topBar:be}:{},...Se?{sessionCreation:ce,onRetrySessionCreation:m,placeholder:v(`placeholder.hero`)}:Ce?{disabled:!0,preparingDraft:!0,placeholder:v(`placeholder.hero`)}:Oe?Te?{disabled:!0,placeholder:v(Ee?`placeholder.loadUnsupported`:`placeholder.loadFailed`)}:{disabled:!0,placeholder:v(De?`placeholder.preparing`:`placeholder.workspace`),...De?{}:{workspacePickerOpen:ue,onRequestWorkspace:()=>{de(!0)}}}:ke?{blocked:se,placeholder:se.reason}:r?{placeholder:v(`placeholder.hero`)}:{}}),je=/* @__PURE__ */ (0,h.jsxs)(`div`,{className:sC(Q.composerStack,r&&Q.composerHero),children:[r&&/* @__PURE__ */ (0,h.jsx)(aA,{t:v,renderSlot:d}),/* @__PURE__ */ (0,h.jsx)(pA,{session:b,useInput:c,renderSlot:d}),Ae]}),Me=f(`conversation.composer`,{sessionId:t,session:b,pendingInteraction:b?.openState===`open`?ie:void 0},{fallback:je,fallbackOnly:t===void 0,overlay:!0}),Ne=/* @__PURE__ */ (0,h.jsx)(`div`,{ref:S,className:Q.composerSeat,"data-composer-seat":``,"data-conversation-region":`composer`,children:Me});return/* @__PURE__ */ (0,h.jsxs)(`div`,{ref:re,className:sC(Q.body,e.variant===`embedded`&&Q.embeddedBody),"data-conversation-content":``,"data-conversation-session":t,"data-conversation-region":`chat`,"data-content-phase":n,children:[/* @__PURE__ */ (0,h.jsxs)(`div`,{className:Q.scrollBody,"data-conversation-scroll":``,children:[t===void 0?null:/* @__PURE__ */ (0,h.jsx)(ee,{}),Ne]}),/* @__PURE__ */ (0,h.jsx)(te,{container:ne,phase:n}),/* @__PURE__ */ (0,h.jsx)(cA,{container:ne,editor:_,useSessions:a,t:v},t)]})}function gA({renderSlot:e}){return e(`main.conversation`,{})}function _A(){let e=()=>{let e=document.querySelector(`[data-conversation-navigation-focus]`),t=e?.querySelector(`[data-navigation-focus-return]`);(t!=null&&t.getClientRects().length>0?t:e)?.focus({preventScroll:!0})};e(),requestAnimationFrame(()=>{document.activeElement===document.body&&e()})}function vA({sessionId:e,useSession:t,useConversation:n,renderSlot:r}){let i=t(e=>e),a=n(e=>e),o=i===void 0||a===void 0||i.blank&&Hk(i,a)===`blank`;return/* @__PURE__ */ (0,h.jsxs)(`header`,{className:sC(Q.header,o&&Q.headerBlank,e===void 0&&Q.headerSessionless),"data-window-drag":!0,"data-conversation-navigation-focus":!0,"data-cx-region":`topbar`,tabIndex:-1,children:[/* @__PURE__ */ (0,h.jsx)(`div`,{className:Q.headerLeading,"data-conversation-header-leading":``,children:r(`conversation.header.leading`,{})}),e===void 0?/* @__PURE__ */ (0,h.jsxs)(`div`,{className:Q.titleRow,children:[r(`conversation.header.navigation`,{restoreNavigationFocus:_A}),/* @__PURE__ */ (0,h.jsx)(`div`,{className:Q.headerCorner,"data-conversation-header-corner":``,children:/* @__PURE__ */ (0,h.jsx)(`span`,{className:Q.phoneTrailingAction,children:r(`conversation.header.trailing`,{})})})]}):r(`conversation.session.header`,{hideChrome:o,titleNavigation:r(`conversation.header.navigation`,{restoreNavigationFocus:_A}),trailingAction:r(`conversation.header.trailing`,{})}),r(`conversation.header.shortcuts`,{restoreNavigationFocus:_A})]})}function yA(e,t){return(t===null?void 0:e.find(e=>e.id===t))??e.find(e=>e.id===`chat`)}function bA({view:e,useSession:t,useConversation:n,useConversationViews:r,inputActions:i,useStore:a,actions:o,renderSlot:s,bindDraftPersistence:c,onRevealResponseAnnotation:l,openView:u,useInspectCall:d}){let f=r(e=>e),p=d(e=>e),m=yA(f,a(e=>e.view)),_=t(e=>e),v=n(e=>e),y=a(e=>e.viewRequest??null);if((0,g.useEffect)(()=>{let e=c(o.setDraft);return i.persistDraft(),()=>{e()}},[i]),(0,g.useEffect)(()=>l(e=>u(`chat`,e)),[l,u]),_.blank&&Hk(_,v)===`blank`)return null;let b=e??m?.id;return/* @__PURE__ */ (0,h.jsx)(`div`,{className:Q.viewArea,children:b!==void 0&&s(`conversation.view`,{inspectCall:p,viewRequest:y,openView:u,completeViewRequest:o.completeViewRequest},{only:b})})}function xA(e,t){let n=[],r=/* @__PURE__ */ new Set,i=t;for(;i!==void 0&&!r.has(i);){r.add(i);let t=e.byId[i];if(t===void 0||(n.unshift({id:t.id,displayTitle:t.displayTitle,subagent:t.origin===`subagent`}),t.origin!==`subagent`))break;i=t.parentId}return n}function SA(e,t){return e.length===t.length&&e.every((e,n)=>{let r=t.at(n);return r!==void 0&&e.id===r.id&&e.displayTitle===r.displayTitle})}function CA({sessionId:e,hideChrome:t,titleNavigation:n,trailingAction:r,useSessions:i,useConversationViews:a,useStore:o,renderSlot:s,open:c,selectView:l,t:u}){let d=a(e=>e),f=yA(d,o(e=>e.view)),p=i(t=>xA(t,e),SA),m=!t&&d.length>1;return/* @__PURE__ */ (0,h.jsxs)(h.Fragment,{children:[/* @__PURE__ */ (0,h.jsxs)(`div`,{className:Q.titleRow,children:[!t&&/* @__PURE__ */ (0,h.jsxs)(h.Fragment,{children:[/* @__PURE__ */ (0,h.jsxs)(`div`,{className:Q.titleCluster,children:[/* @__PURE__ */ (0,h.jsxs)(`div`,{className:Q.titleCenter,onClick:e=>{if(e.target?.closest(`button, a, input, [role='button']`))return;let t=e.currentTarget.querySelector(`[data-navigation-focus-return]`);t!==null&&t.getClientRects().length>0&&t.click()},children:[/* @__PURE__ */ (0,h.jsxs)(`nav`,{className:Q.crumbs,"aria-label":u(`session.hierarchy`),children:[p.map((e,t)=>{let n=t===p.length-1,r=n?/* @__PURE__ */ (0,h.jsx)(`span`,{className:sC(Q.crumb,e.subagent&&Q.crumbSubagent,Q.crumbCurrent),children:e.displayTitle}):/* @__PURE__ */ (0,h.jsx)(`button`,{type:`button`,className:sC(Q.crumb,e.subagent&&Q.crumbSubagent),onClick:()=>{c(e.id)},children:e.displayTitle}),i=n||e.subagent,a={lineageSessionId:e.id,displayTitle:e.displayTitle,...n?{}:{openTitle:()=>{c(e.id)}}};return/* @__PURE__ */ (0,h.jsxs)(`span`,{className:Q.crumbSeg,children:[t>0&&/* @__PURE__ */ (0,h.jsx)(`span`,{className:Q.crumbSep,children:`/`}),i?e.subagent?s(`conversation.session.header.lineage`,a,{fallback:r}):/* @__PURE__ */ (0,h.jsxs)(h.Fragment,{children:[r,s(`conversation.session.header.lineage`,a,{fallback:null})]}):r]},e.id)}),p.length===0&&/* @__PURE__ */ (0,h.jsx)(`span`,{className:Q.crumbCurrent,children:e})]}),n]}),/* @__PURE__ */ (0,h.jsx)(`div`,{className:Q.headerActions,children:s(`conversation.session.header.actions`,{})})]}),/* @__PURE__ */ (0,h.jsx)(`div`,{className:Q.headerUtilities,children:s(`conversation.session.header.utilities`,{})})]}),t&&/* @__PURE__ */ (0,h.jsx)(`div`,{className:Q.titleCenter,children:n}),/* @__PURE__ */ (0,h.jsxs)(`div`,{className:Q.headerCorner,"data-conversation-header-corner":``,children:[/* @__PURE__ */ (0,h.jsx)(`span`,{className:Q.phoneTrailingAction,children:r}),s(`conversation.session.header.corner`,{})]})]}),m&&/* @__PURE__ */ (0,h.jsx)(`div`,{className:Q.tabs,role:`tablist`,"data-conversation-tabs":``,children:d.map(e=>/* @__PURE__ */ (0,h.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":e.id===f?.id,className:sC(Q.tab,e.id===f?.id&&Q.tabActive),onClick:()=>{l(e.id)},children:e.label},e.id))})]})}function wA(e){return/* @__PURE__ */ (0,h.jsx)(bA,{...e})}function TA({editor:e,editable:t,preserveFocus:n=!1,...r}){let i=(0,g.useRef)(null),a=(0,g.useRef)(n);return a.current=n,(0,g.useLayoutEffect)(()=>{let t=i.current;if(t!==null&&(!(0,d.shouldAutoFocusTextInput)()&&!a.current&&(t.ownerDocument.activeElement===t&&t.blur(),e?.setEditable(!1)),e!==null))return e.setRootElement(t),()=>{e.setRootElement(null)}},[e]),(0,g.useLayoutEffect)(()=>{e!==null&&e.setEditable(t)},[e,t]),/* @__PURE__ */ (0,h.jsx)(`div`,{ref:i,contentEditable:e!==null&&t,suppressContentEditableWarning:!0,role:`textbox`,"aria-multiline":`true`,"data-composer-input":!0,...r})}function EA({editor:e}){let[t,n]=g.useState(()=>e===null?{}:e.getDecorators());return g.useLayoutEffect(()=>{if(e!==null)return n(e.getDecorators()),e.registerDecoratorListener(e=>{n(e)})},[e]),e===null?null:/* @__PURE__ */ (0,h.jsx)(h.Fragment,{children:Object.entries(t).map(([t,n])=>{let r=e.getElementByKey(t);return r===null?null:(0,_.createPortal)(n,r,t)})})}function DA({classNames:e,editor:t,scrollRef:n,editable:r,editorDisabled:i,preserveFocus:a=!1,phase:o,placeholderText:s,ariaLabel:c,workspaceTrigger:l,workspacePickerOpen:u,onWorkspaceKeyDown:d,hint:f,showPlaceholder:p}){return/* @__PURE__ */ (0,h.jsx)(`div`,{ref:n,className:e.scroll,"data-input-scroll":!0,children:/* @__PURE__ */ (0,h.jsxs)(`div`,{className:e.grow,children:[/* @__PURE__ */ (0,h.jsx)(TA,{editor:l?null:t,editable:r,preserveFocus:a,className:sC(e.input,i&&e.inputDisabled),"data-phase":o,"aria-disabled":i||void 0,"data-placeholder":s,"aria-label":c,"aria-haspopup":l?`menu`:void 0,"aria-expanded":l?u:void 0,tabIndex:l?0:void 0,onKeyDown:l?d:void 0,style:f===null?void 0:{"--dsh-composer-hint":JSON.stringify(f)}}),p&&/* @__PURE__ */ (0,h.jsx)(`div`,{"aria-hidden":!0,className:e.placeholder,"data-composer-placeholder":!0,children:s}),/* @__PURE__ */ (0,h.jsx)(EA,{editor:l?null:t})]})})}function OA(){return typeof window<`u`&&typeof window.matchMedia==`function`&&window.matchMedia(`(pointer: coarse)`).matches}function kA(e,t){return e.isComposing||e.keyCode===229||t()}function AA(e,t){let n=!1,r=0,i=null,a=()=>{i?.toggleAttribute(`data-composer-composing`,n||e.isComposing())},o=()=>{n=!0,a()},s=()=>{n=!1,r=Date.now()+10,e.update(()=>{},{onUpdate:a})},c=()=>n||Date.now()<r,l=e=>n=>{let r=n!==null&&kA(n,c);return t.arbitrate(e,r)!==`pass`&&(n?.preventDefault(),!0)};return tx(e.registerRootListener((e,t)=>{t?.removeEventListener(`compositionstart`,o),t?.removeEventListener(`compositionend`,s),t?.removeAttribute(`data-composer-composing`),n=!1,r=0,i=e,e?.addEventListener(`compositionstart`,o),e?.addEventListener(`compositionend`,s),a()}),e.registerUpdateListener(a),e.registerCommand(Hp,l(`up`),4),e.registerCommand(Up,l(`down`),4),e.registerCommand(Rp,t=>e.getEditorState().read(()=>{let e=V();if(!B(e)||!e.isCollapsed())return!1;let t=e.anchor,n=t.getNode();if(!z(n))return!0;let r=n.getTextContent().charAt(t.offset);return r===``||/\s/u.test(r)})?l(`right`)(t):!1,4),e.registerCommand(Bp,t=>e.getEditorState().read(()=>{let e=V();return B(e)&&e.isCollapsed()})?l(`left`)(t):!1,4),e.registerCommand(Yp,e=>l(e.shiftKey?`tabBack`:`tab`)(e),4),e.registerCommand(qp,e=>(t.dismissPopup(),t.arbitrate(`escape`,kA(e,c))===`consumed`&&(e.preventDefault(),!0)),4),e.registerCommand(Gp,e=>kA(e,c)?!1:t.space()?(e.preventDefault(),!0):!1,4),e.registerCommand(Wp,e=>e!==null&&(e.altKey||e.getModifierState(`AltGraph`)||e.ctrlKey&&e.metaKey||e.shiftKey&&(e.ctrlKey||e.metaKey))?!0:e?.shiftKey===!0?!1:e!==null&&kA(e,c)?!0:t.arbitrate(`enter`,!1)===`pass`?OA()&&e?.ctrlKey!==!0&&e?.metaKey!==!0?!1:(e?.preventDefault(),e?.repeat===!0||!t.canSubmit()||t.submit(e?.ctrlKey===!0||e?.metaKey===!0),!0):(e?.preventDefault(),!0),4),e.registerCommand(Ap,e=>{let n=e.clipboardData??null;if(n===null)return!1;let r=[],i=/* @__PURE__ */ new Set;for(let e of n.items){if(e.kind!==`file`)continue;let t=e.getAsFile();t!==null&&(r.push(t),typeof e.webkitGetAsEntry==`function`&&e.webkitGetAsEntry()?.isDirectory===!0&&i.add(t))}r.length>0&&t.intakeFiles(r,i.size===0?void 0:i);let a=n.getData(`text/plain`);return a===``?r.length!==0&&(e.preventDefault(),!0):(e.preventDefault(),t.pasteText(a),!0)},4))}function jA(e){let t=e.current;if(t===null||t.scrollHeight<=t.clientHeight)return;let n=window.getSelection();if(n===null||n.rangeCount===0)return;let r=n.getRangeAt(0).getBoundingClientRect();if(r.height===0&&r.width===0){let e=n.anchorNode,t=e instanceof HTMLElement?e:e?.parentElement;if(t==null)return;r=t.getBoundingClientRect()}let i=t.getBoundingClientRect();r.bottom>i.bottom?t.scrollTop+=r.bottom-i.bottom:r.top<i.top&&(t.scrollTop-=i.top-r.top)}function MA(e,t){e.getRootElement()?.focus({preventScroll:!0}),e.focus(()=>{t()})}function NA(e){let t=e.getRootElement();if(t===null||e.isComposing())return;let n=t.ownerDocument;if(n.activeElement!==t&&!t.contains(n.activeElement))return;let r=n.defaultView?.getSelection();if(r==null)return;if(r.rangeCount>0){if(!r.isCollapsed)return;let e=r.getRangeAt(0).cloneRange();if(t.contains(e.startContainer)&&t.contains(e.endContainer)){r.removeAllRanges(),r.addRange(e);return}}let i=t.firstChild??t,a=n.createRange();a.setStart(i,0),a.collapse(!0),r.removeAllRanges(),r.addRange(a)}function PA(e){let t=e.current;if(t===null)return;let n=e=>{let n=t.closest(`[data-conversation-scroll]`);if(!(n instanceof HTMLElement)||e.deltaY===0)return;let r=t.scrollTop<=0,i=t.scrollTop+t.clientHeight>=t.scrollHeight-1;e.deltaY<0&&!r||e.deltaY>0&&!i||(e.preventDefault(),n.scrollTop+=e.deltaY)};return t.addEventListener(`wheel`,n,{passive:!1}),()=>{t.removeEventListener(`wheel`,n)}}function FA(e,t,n){return e.bindFilePicker({available:()=>t.current.canAcceptDrop&&n.current!==null,open:()=>{n.current?.click()}})}function IA(e,t,n){return AA(e,{arbitrate:(e,r)=>e===`enter`&&n.current.primaryAction!==void 0?`pass`:t.arbitrate(e,r),space:()=>n.current.machineBusy||n.current.locked?!1:t.space(),dismissPopup:()=>{t.dismissPopup()},canSubmit:()=>!n.current.locked&&!n.current.machineBusy&&n.current.primaryAction?.disabled!==!0,submit:e=>{let r=n.current;r.uploadsFailed?r.showToast(r.t(`file.retryOrRemove`)):r.primaryAction===void 0?e&&r.canSteerQueue?t.steerQueue():t.submit(vk(r.busyEnter,r.running,e?`accelerated`:`enter`,r.steeringAvailable),`enter`):r.primaryAction.run()},intakeFiles:(e,t)=>{n.current.intakeFiles(e,t)},pasteText:e=>{!n.current.machineBusy&&n.current.canPasteText&&t.paste(e)}})}function LA(e){let t=e.activeElement,n=e.defaultView?.HTMLTextAreaElement??globalThis.HTMLTextAreaElement;return n!==void 0&&t instanceof n&&t.closest(`[data-composer-annotations]`)!==null&&(t.blur(),!0)}function RA(e){let t=e?.getRootElement()??null;if(t===null)return!1;let n=t.ownerDocument.activeElement;return n===null||!t.contains(n)?!1:(typeof n.blur==`function`?n.blur():t.blur(),!0)}function zA(e,t){(0,d.shouldAutoFocusTextInput)()&&(e.preventDefault(),t?.getRootElement()?.focus({preventScroll:!0}))}function BA(e){let t=e/1048576;return`${Number.isInteger(t)?String(t):t.toFixed(1)}MB`}function VA(e,t,n){switch(t){case`MODEL_DOES_NOT_SUPPORT_IMAGES`:return e(`image.modelUnsupported`);case`FILE_NOT_STAGED`:return e(`file.notStaged`);case`FILE_UNAVAILABLE`:return e(`file.unavailable`);case`IMAGE_TOO_MANY_PIXELS`:return e(`image.tooManyPixels`);case`INVALID_IMAGE`:case`IMAGE_TYPE_MISMATCH`:return e(`image.unsupportedType`);case`TOO_MANY_IMAGES`:if(n!==void 0)return e(`image.tooMany`,{count:n.maxImagesPerMessage});break;case`IMAGE_TOO_LARGE`:if(n!==void 0)return e(`image.fileTooLarge`,{size:BA(n.maxImageBytes)});break;case`IMAGES_TOO_LARGE`:if(n!==void 0)return e(`image.totalTooLarge`,{size:BA(n.maxMessageImageBytes)})}return e(`image.sendFailed`,{reason:t})}function HA(e){let t=e?.projectedTokens??e?.pressureTokens;return t===void 0||e?.contextWindow===void 0?null:{percent:Math.min(100,Math.round(t/e.contextWindow*100)),usedTokens:t,contextWindow:e.contextWindow}}let UA=`@deepseek-ai/dsh-client-ui-conversation/ContextMeter.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(UA)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-conversation`,e.dataset.pluginCss=UA,e.textContent=`.h1Hkra_root{flex:none;display:inline-flex}.h1Hkra_trigger{border-radius:var(--dsw-radius-sm);color:var(--dsw-alias-label-tertiary);font-family:inherit;font-size:var(--dsh-content-font-size-secondary,13px);font-variant-numeric:tabular-nums;line-height:calc(20px + var(--dsh-content-font-delta-secondary,0px));white-space:nowrap;cursor:pointer;background:0 0;border:none;flex:none;align-items:center;gap:6px;padding:1px 8px;display:inline-flex}.h1Hkra_trigger:hover,.h1Hkra_trigger[aria-expanded=true]{background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-label-secondary)}.h1Hkra_track{fill:none;stroke:var(--dsw-alias-border-l3);stroke-width:2px}.h1Hkra_fill{fill:none;stroke:var(--dsw-alias-label-tertiary);stroke-width:2px;stroke-linecap:round}.h1Hkra_panel{z-index:1100;box-sizing:border-box;border-radius:var(--dsw-radius-lg);background:var(--dsw-specific-menu);width:min(264px,100vw - 24px);backdrop-filter:var(--dsw-menu-backdrop-filter);--dsw-elevation-stroke-color:var(--dsw-alias-border-l1);box-shadow:var(--dsw-elevation-prominent);color:var(--dsw-alias-label-secondary);cursor:default;border:0;padding:12px;font-size:12px;line-height:20px;position:fixed}.h1Hkra_header{align-items:center;gap:6px;display:flex}.h1Hkra_figures{font-variant-numeric:tabular-nums;color:var(--dsw-alias-label-primary);margin-left:auto;font-weight:500}.h1Hkra_percent{color:var(--dsw-alias-label-primary);font-weight:500}.h1Hkra_headline{color:var(--dsw-alias-label-tertiary)}.h1Hkra_headline:empty{display:none}.h1Hkra_bar{corner-shape:round;background:var(--dsw-alias-interactive-bg-hover);border-radius:999px;gap:1px;height:4px;margin:10px 0 12px;display:flex;overflow:hidden}.h1Hkra_segment{background:var(--meter-tint,var(--dsw-alias-label-tertiary));border-radius:1px;flex:none;min-width:2px;height:100%}.h1Hkra_swatch{background:var(--meter-tint);vertical-align:baseline;border-radius:2px;width:8px;height:8px;margin-right:6px;display:inline-block}.h1Hkra_colorSystem{--meter-tint:var(--dsw-static-neutral-bluish-400)}.h1Hkra_colorTools{--meter-tint:#a78bfa}.h1Hkra_colorMessages{--meter-tint:var(--dsw-static-blue-450)}.h1Hkra_rows{margin:6px 0 0}.h1Hkra_row{justify-content:space-between;align-items:center;gap:12px;padding:2px 0;display:flex}.h1Hkra_row dt{color:var(--dsw-alias-label-secondary)}.h1Hkra_row dd{font-variant-numeric:tabular-nums;color:var(--dsw-alias-label-primary);margin:0}`,document.head.appendChild(e)}var WA={bar:`h1Hkra_bar`,colorMessages:`h1Hkra_colorMessages`,colorSystem:`h1Hkra_colorSystem`,colorTools:`h1Hkra_colorTools`,figures:`h1Hkra_figures`,fill:`h1Hkra_fill`,header:`h1Hkra_header`,headline:`h1Hkra_headline`,panel:`h1Hkra_panel`,percent:`h1Hkra_percent`,root:`h1Hkra_root`,row:`h1Hkra_row`,rows:`h1Hkra_rows`,segment:`h1Hkra_segment`,swatch:`h1Hkra_swatch`,track:`h1Hkra_track`,trigger:`h1Hkra_trigger`};let GA=5.5,KA=2*Math.PI*GA,qA=[{key:`systemTokens`,label:`context.system`,color:WA.colorSystem},{key:`toolsTokens`,label:`context.tools`,color:WA.colorTools},{key:`messageTokens`,label:`context.messages`,color:WA.colorMessages}];function JA(e,t){let n=e=>String(e>=100?Math.round(e):Math.round(e*10)/10);return e<1e3?String(e):e<1e6?t(`number.thousand`,{value:n(e/1e3)}):t(`number.million`,{value:n(e/1e6)})}function YA({useProjection:e,t}){let n=e(`contextPressure`),r=e(`contextBreakdown`),[i,a]=(0,g.useState)(!1),o=(0,g.useRef)(null),s=(0,g.useRef)(null),c=HA(n),l=c!==null,u=(0,d.useAnchoredPosition)({open:i&&l,anchorRef:o,panelRef:s,side:`top`,gap:8,margin:12});if((0,d.useDismissOnOutsidePointer)(o,i&&l,a,s),(0,g.useEffect)(()=>{!l&&i&&a(!1)},[l,i]),(0,g.useEffect)(()=>{if(!i||!l)return;let e=e=>{e.key===`Escape`&&a(!1)};return document.addEventListener(`keydown`,e),()=>{document.removeEventListener(`keydown`,e)}},[l,i]),c===null)return null;let f=c.percent,p=`${f}%`,[m=``,v=``]=t(`context.aria`,{percent:`\0`}).split(`\0`).map(e=>e.trim()),y=r===void 0?0:r.systemTokens+r.toolsTokens+r.messageTokens,b=(r===void 0||y===0?[{key:`total`,color:void 0,width:f}]:qA.map(e=>({key:e.key,color:e.color,width:f*r[e.key]/y}))).filter(e=>e.width>0);return/* @__PURE__ */ (0,h.jsxs)(`span`,{ref:o,className:WA.root,children:[/* @__PURE__ */ (0,h.jsx)(d.Tooltip,{label:t(`context.aria`,{percent:p}),side:`top`,delayMs:200,disabled:i,children:/* @__PURE__ */ (0,h.jsxs)(`button`,{type:`button`,className:WA.trigger,"aria-label":t(`context.aria`,{percent:p}),"aria-haspopup":`dialog`,"aria-expanded":i,onClick:()=>{a(!i)},children:[/* @__PURE__ */ (0,h.jsxs)(`svg`,{viewBox:`0 0 14 14`,width:`14`,height:`14`,"aria-hidden":!0,children:[/* @__PURE__ */ (0,h.jsx)(`circle`,{className:WA.track,cx:`7`,cy:`7`,r:GA}),/* @__PURE__ */ (0,h.jsx)(`circle`,{className:WA.fill,cx:`7`,cy:`7`,r:GA,strokeDasharray:`${KA*f/100} ${KA}`,transform:`rotate(-90 7 7)`})]}),/* @__PURE__ */ (0,h.jsx)(`span`,{children:p})]})}),i&&(0,_.createPortal)(/* @__PURE__ */ (0,h.jsxs)(`div`,{ref:s,className:WA.panel,style:u??{visibility:`hidden`,left:0,top:0},role:`dialog`,"aria-label":t(`context.used`),children:[/* @__PURE__ */ (0,h.jsxs)(`div`,{className:WA.header,children:[/* @__PURE__ */ (0,h.jsx)(`span`,{className:WA.headline,children:m}),/* @__PURE__ */ (0,h.jsx)(`span`,{className:WA.percent,children:p}),/* @__PURE__ */ (0,h.jsx)(`span`,{className:WA.headline,children:v}),/* @__PURE__ */ (0,h.jsx)(`span`,{className:WA.figures,children:`~${JA(c.usedTokens,t)} / ${JA(c.contextWindow,t)}`})]}),/* @__PURE__ */ (0,h.jsx)(`div`,{className:WA.bar,children:b.map(e=>/* @__PURE__ */ (0,h.jsx)(`div`,{className:e.color===void 0?WA.segment:`${WA.segment} ${e.color}`,style:{width:`${e.width}%`}},e.key))}),r!==void 0&&/* @__PURE__ */ (0,h.jsx)(`dl`,{className:WA.rows,children:qA.map(e=>/* @__PURE__ */ (0,h.jsxs)(`div`,{className:WA.row,children:[/* @__PURE__ */ (0,h.jsxs)(`dt`,{children:[/* @__PURE__ */ (0,h.jsx)(`span`,{className:`${WA.swatch} ${e.color}`,"aria-hidden":!0}),t(e.label)]}),/* @__PURE__ */ (0,h.jsx)(`dd`,{children:`~${JA(r[e.key],t)}`})]},e.key))})]}),document.body)]})}function XA(e,t){let n=e.querySelector(`[data-toolbar-scroll]`);if(n===null)return()=>{};let r=e.querySelector(`[data-toolbar-fixed="start"]`),i=e.querySelector(`[data-toolbar-fixed="end"]`),a={phone:!1,overflowActions:!1},o=!1,s=/* @__PURE__ */ new Set,c=()=>{if(!a.phone||e.hasAttribute(`data-toolbar-activity`))return;let t=e.ownerDocument.activeElement;if(!(t instanceof HTMLElement)||!e.contains(t)||t.closest(`[data-toolbar-fixed]`))return;let{left:r,right:i}=n.getBoundingClientRect(),o=t.getBoundingClientRect();o.left<r?n.scrollLeft+=o.left-r:o.right>i&&(n.scrollLeft+=Math.min(o.right-i,o.left-r))},l=()=>{if(o)return;let s=e.closest(`[data-phone]`)!==null;if(e.toggleAttribute(`data-phone-toolbar`,s),e.hasAttribute(`data-toolbar-activity`)){s!==a.phone&&(a={...a,phone:s},t?.(a));return}let l=e.hasAttribute(`data-actions-overflow`);if(e.removeAttribute(`data-model-compact`),e.removeAttribute(`data-actions-overflow`),e.toggleAttribute(`data-toolbar-measuring`,s),s)for(let[t,n]of[[`start`,r],[`end`,i]]){if(n===null)continue;let r=`--dsh-composer-${t}-width`,i=`${n.getBoundingClientRect().width}px`;e.style.getPropertyValue(r)!==i&&e.style.setProperty(r,i)}let u=getComputedStyle(e),d=e.getBoundingClientRect().width-parseFloat(u.paddingLeft)-parseFloat(u.paddingRight),f=s?(()=>{let t=e=>Array.from(e.children).flatMap(e=>{let r=getComputedStyle(e).display;return r===`none`?[]:e===n||r===`contents`?t(e):[e]}),r=t(e);return r.reduce((e,t)=>{let n=getComputedStyle(t);return e+t.getBoundingClientRect().width+(parseFloat(n.marginLeft)||0)+(parseFloat(n.marginRight)||0)},0)+Math.max(0,r.length-1)*(parseFloat(u.columnGap)||0)})():(()=>{let e=Array.from(n.children,e=>e.getBoundingClientRect().width).filter(e=>e>0);return e.reduce((e,t)=>e+t,0)+Math.max(0,e.length-1)*parseFloat(u.columnGap)})();e.toggleAttribute(`data-model-compact`,!s&&f>d);let p=e.querySelector(`[data-composer-overflow-action]`),m=e.querySelector(`[data-toolbar-fixed="start"] button`),h=s&&p!==null&&m?.disabled===!1&&f>d-(l?2:0),g=e.hasAttribute(`data-command-menu-open`)||p!==null&&p.contains(e.ownerDocument.activeElement)?l:h;e.removeAttribute(`data-toolbar-measuring`),e.toggleAttribute(`data-actions-overflow`,g),(s!==a.phone||g!==a.overflowActions)&&(a={phone:s,overflowActions:g},t?.(a)),(!s||n.scrollWidth<=n.clientWidth)&&(n.scrollLeft=0),c()},u=new ResizeObserver(l),d=()=>{let t=/* @__PURE__ */ new Set([e,...e.querySelectorAll(`*`)]);for(let e of s)t.has(e)||(u.unobserve(e),s.delete(e));for(let e of t)s.has(e)||(u.observe(e),s.add(e))},f=new MutationObserver(()=>{d(),l()});f.observe(e,{subtree:!0,childList:!0,characterData:!0,attributes:!0,attributeFilter:[`hidden`,`class`,`style`,`aria-label`,`aria-busy`,`disabled`,`data-command-menu-open`,`data-toolbar-activity`]});let p=new MutationObserver(l);for(let t=e.parentElement;t!==null;t=t.parentElement)p.observe(t,{attributes:!0,attributeFilter:t===e.ownerDocument.body||t===e.ownerDocument.documentElement?[`data-phone`,`class`,`style`,`lang`,`dir`]:[`data-phone`,`lang`,`dir`]});let m=()=>{queueMicrotask(()=>{o||l()})};e.addEventListener(`focusin`,c),e.addEventListener(`focusout`,m);let h=document.fonts;return h.addEventListener(`loadingdone`,l),d(),l(),()=>{o=!0,u.disconnect(),f.disconnect(),p.disconnect(),e.removeEventListener(`focusin`,c),e.removeEventListener(`focusout`,m),h.removeEventListener(`loadingdone`,l)}}let ZA=`@deepseek-ai/dsh-client-ui-conversation/InputBar.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(ZA)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-conversation`,e.dataset.pluginCss=ZA,e.textContent=`.SFO4UW_root{padding:0 var(--dsh-composer-side-clearance) 4px;flex-direction:column;align-items:center;display:flex}[data-phone] .SFO4UW_root{padding-bottom:max(4px, calc(env(safe-area-inset-bottom) - 23px))}.SFO4UW_dock{-webkit-user-select:none;user-select:none;justify-content:center;align-items:center;gap:12px;max-width:100%;padding-top:4px;display:flex}.SFO4UW_hero .SFO4UW_dock:empty{display:none}.SFO4UW_hero{padding:0 var(--dsh-composer-side-clearance)}.SFO4UW_notice{width:100%;max-width:var(--dsh-composer-card-max-width);border-radius:var(--dsw-radius-md);background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-label-secondary);-webkit-user-select:text;user-select:text;margin-bottom:6px;padding:4px 8px;font-size:12px;line-height:18px}.SFO4UW_cardStack{width:100%;max-width:var(--dsh-composer-card-max-width);flex-direction:column;display:flex;position:relative}.SFO4UW_topRail{z-index:0;box-sizing:border-box;margin-inline:16px;background:color-mix(in srgb, var(--dsw-alias-label-primary) 5%, var(--dsw-alias-bg-base));-webkit-user-select:none;user-select:none;border:0;border-radius:16px 16px 0 0;align-items:center;margin-bottom:-16px;padding:5px 10px 21px;display:flex;position:relative}.SFO4UW_card{box-sizing:border-box;z-index:1;width:100%;max-width:var(--dsh-composer-card-max-width);--dsw-elevation-stroke-color:var(--dsw-alias-border-l2);border-radius:var(--dsw-radius-panel);background:var(--dsw-specific-input-major);box-shadow:var(--dsw-elevation-soft);font-size:var(--dsh-content-font-size,14px);line-height:calc(24px + var(--dsh-content-font-delta,0px));--dsh-scrollbar-thumb:var(--dsw-alias-scrollbar-bg-l2);--dsh-scrollbar-thumb-hover:var(--dsw-alias-scrollbar-hover-l2);border:0;flex-direction:column;gap:12px;padding-top:8px;display:flex;position:relative}@supports (backdrop-filter:blur(14px)){body[data-codexhost-wallpaper] .SFO4UW_card,[data-phone] .SFO4UW_card{box-shadow:none;background:0 0}body[data-codexhost-wallpaper] .SFO4UW_card:before,[data-phone] .SFO4UW_card:before{content:"";z-index:-1;border-radius:inherit;background:color-mix(in srgb, var(--dsw-specific-input-major) 60%, transparent);backdrop-filter:blur(16px);box-shadow:inset 0 1px 0 color-mix(in srgb, var(--dsw-alias-bg-layer-3) 65%, transparent), var(--dsw-elevation-soft), 0 8px 24px -12px var(--dsw-alias-bg-mask-2);pointer-events:none;position:absolute;inset:0}body:not([data-codexhost-wallpaper]) [data-phone] .SFO4UW_card:before{background:color-mix(in srgb, var(--dsw-specific-input-major) 24%, transparent);backdrop-filter:blur(14px)}}@media (prefers-reduced-transparency:reduce),(prefers-contrast:more),(forced-colors:active){body[data-codexhost-wallpaper] .SFO4UW_card,[data-phone] .SFO4UW_card{background:var(--dsw-specific-input-major);box-shadow:var(--dsw-elevation-soft)}body[data-codexhost-wallpaper] .SFO4UW_card:before,[data-phone] .SFO4UW_card:before{display:none}}@media (prefers-contrast:more),(forced-colors:active){[data-phone] .SFO4UW_card:not(.SFO4UW_cardWorkspaceTrigger){outline:1px solid var(--dsw-alias-label-primary);outline-offset:-1px}}.SFO4UW_cardWorkspaceTrigger{--dsw-elevation-stroke-color:transparent;cursor:pointer}.SFO4UW_cardWorkspaceTrigger:after{content:"";box-sizing:border-box;border-radius:var(--dsw-radius-panel);color:var(--dsw-alias-border-l4);pointer-events:none;border:1px dashed;transition:color .1s;position:absolute;inset:0}.SFO4UW_cardWorkspaceTrigger :disabled{pointer-events:none}.SFO4UW_cardWorkspaceTrigger:hover:after{color:var(--dsw-alias-state-business-primary)}.SFO4UW_inlineNotices{-webkit-user-select:text;user-select:text;flex-direction:column;gap:8px;display:flex}.SFO4UW_inlineNotices>[data-slot]>*{margin:10px 10px 0}.SFO4UW_accessory{align-items:center;gap:8px;padding:10px 12px 0;display:flex}.SFO4UW_overlayAnchor{height:0;position:absolute;inset:0 0 auto}.SFO4UW_scroll{max-height:var(--dsh-composer-text-max-height);margin-right:4px;overflow-y:auto}.SFO4UW_scroll::-webkit-scrollbar-track{margin-top:8px}.SFO4UW_grow{position:relative}.SFO4UW_pending{corner-shape:round;background:var(--dsw-alias-state-business-primary);border-radius:50%;width:8px;height:8px;animation:1s ease-in-out infinite alternate SFO4UW_input-pending}@keyframes SFO4UW_input-pending{0%{opacity:.35}to{opacity:1}}.SFO4UW_input{box-sizing:border-box;min-height:36px;font-family:var(--dsw-font-family);font-size:inherit;line-height:inherit;white-space:pre-wrap;word-break:break-word;overflow-wrap:anywhere;color:var(--dsw-alias-label-primary);caret-color:var(--dsw-alias-state-business-primary);-webkit-user-select:text;user-select:text;outline:none;padding:4px 8px 0 14px}.SFO4UW_input p{margin:0}.SFO4UW_input p:last-child:after{content:var(--dsh-composer-hint);color:var(--dsw-alias-label-caption)}.SFO4UW_input[data-composer-composing] p:last-child:after{content:none}.SFO4UW_input[data-composer-composing]+.SFO4UW_placeholder{visibility:hidden}.SFO4UW_placeholder{color:var(--dsw-alias-label-caption);white-space:nowrap;text-overflow:ellipsis;pointer-events:none;-webkit-user-select:none;user-select:none;position:absolute;inset:4px 8px auto 14px;overflow:hidden}.SFO4UW_inputDisabled{color:var(--dsw-alias-label-tertiary);cursor:not-allowed}.SFO4UW_input[aria-haspopup=menu]{cursor:pointer}.SFO4UW_hero .SFO4UW_input{min-height:52px}.SFO4UW_hero .SFO4UW_placeholder{white-space:normal;-webkit-line-clamp:2;line-clamp:2;-webkit-box-orient:vertical;display:-webkit-box}@media (width<=600px){.SFO4UW_hero .SFO4UW_input{min-height:36px}.SFO4UW_hero .SFO4UW_placeholder{white-space:nowrap;display:block}}.SFO4UW_row{-webkit-user-select:none;user-select:none;flex-wrap:wrap;justify-content:space-between;align-items:center;gap:12px;min-width:0;padding:2px 8px 6px;display:flex;container-type:inline-size}.SFO4UW_row[data-model-compact]{--dsh-composer-model-text-display:none;--dsh-composer-model-icon-display:block}.SFO4UW_tools,.SFO4UW_modes,.SFO4UW_trailing{align-items:center;min-width:0;display:flex}.SFO4UW_tools,.SFO4UW_modes{gap:12px}.SFO4UW_trailing{flex:none;gap:12px;margin-left:auto}@container (width<=560px){.SFO4UW_tools,.SFO4UW_modes,.SFO4UW_trailing{gap:8px}}.SFO4UW_add{corner-shape:round;background:var(--dsw-specific-selector);width:28px;height:28px;color:var(--dsw-alias-label-primary);cursor:pointer;border:none;border-radius:999px;flex:none;place-items:center;display:grid}.SFO4UW_add:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-hover-solid)}.SFO4UW_add:disabled{opacity:.5;cursor:default}.SFO4UW_select{border-radius:var(--dsw-radius-sm);max-width:220px;height:28px;color:var(--dsw-alias-label-secondary);white-space:nowrap;cursor:pointer;appearance:none;background-color:#0000;background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12' fill='none'%3E%3Cpath d='M3 4.5L6 7.5L9 4.5' stroke='%2381858C' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");background-position:right 4px center;background-repeat:no-repeat;background-size:12px 12px;border:none;outline:none;padding:0 20px 0 8px;font-size:13px;font-weight:500;line-height:20px}.SFO4UW_select:hover:not(:disabled){background-color:var(--dsw-alias-interactive-bg-hover)}.SFO4UW_select:disabled{opacity:.5;cursor:default}.SFO4UW_primary{corner-shape:round;background:var(--dsw-alias-button-info-fill);color:#fff;cursor:pointer;border:none;border-radius:999px;flex:none;place-items:center;width:30px;height:30px;transition:background-color .1s;display:grid;transform:translateY(-2px)}.SFO4UW_primary:hover:not(:disabled){background:var(--dsw-alias-button-info-hover)}.SFO4UW_primary:disabled{opacity:.4;cursor:default}.SFO4UW_retry{border-radius:var(--dsw-radius-sm);color:inherit;cursor:pointer;background:0 0;border:1px solid;margin-left:8px;padding:1px 8px;font-size:12px}.SFO4UW_addSeat,.SFO4UW_submitSeat,.SFO4UW_controlScroll{display:contents}.SFO4UW_row[data-phone-toolbar]{flex-wrap:nowrap;gap:4px;position:relative}.SFO4UW_row[data-phone-toolbar] .SFO4UW_controlScroll{--dsh-composer-edge-gap:4px;align-items:center;gap:inherit;min-width:0;min-height:44px;margin-left:calc(var(--dsh-composer-start-width,44px) + var(--dsh-composer-edge-gap));margin-right:calc(var(--dsh-composer-end-width,44px) + var(--dsh-composer-edge-gap));overscroll-behavior-x:contain;scrollbar-width:none;flex:1;display:flex;overflow-x:auto}.SFO4UW_row[data-phone-toolbar] .SFO4UW_controlScroll::-webkit-scrollbar{display:none}.SFO4UW_row[data-phone-toolbar] .SFO4UW_tools:not([hidden]),.SFO4UW_row[data-phone-toolbar] .SFO4UW_trailing:not(.SFO4UW_trailingActive){display:contents}.SFO4UW_row[data-phone-toolbar] .SFO4UW_tools>*,.SFO4UW_row[data-phone-toolbar] [data-slot="conversation.input.left"]>*,.SFO4UW_row[data-phone-toolbar] [data-slot="conversation.input.right"]>*{flex-shrink:0}.SFO4UW_row[data-phone-toolbar] button:focus-visible{outline-offset:-2px}.SFO4UW_row[data-phone-toolbar] .SFO4UW_modes{flex:none;gap:4px;width:max-content}.SFO4UW_row[data-phone-toolbar] .SFO4UW_standardControls{flex:0 auto;gap:4px;min-width:0;margin-left:0}.SFO4UW_row[data-phone-toolbar][data-toolbar-measuring] .SFO4UW_standardControls{flex:none;width:max-content}.SFO4UW_row[data-phone-toolbar] .SFO4UW_addSeat,.SFO4UW_row[data-phone-toolbar] .SFO4UW_submitSeat{z-index:1;flex:none;align-items:center;gap:4px;display:flex;position:absolute;inset-block:2px 6px}.SFO4UW_row[data-phone-toolbar] .SFO4UW_addSeat{left:8px}.SFO4UW_row[data-phone-toolbar] .SFO4UW_submitSeat{margin-left:0;right:8px}.SFO4UW_row[data-phone-toolbar] .SFO4UW_add,.SFO4UW_row[data-phone-toolbar] .SFO4UW_primary{box-sizing:border-box;background-clip:padding-box;width:44px;height:44px}.SFO4UW_row[data-phone-toolbar] .SFO4UW_add{border:8px solid #0000}.SFO4UW_row[data-phone-toolbar] .SFO4UW_primary{border:7px solid #0000}.SFO4UW_row[data-phone-toolbar][data-toolbar-activity] .SFO4UW_controlScroll{display:contents}.SFO4UW_row[data-phone-toolbar][data-toolbar-activity] .SFO4UW_submitSeat{position:static}.SFO4UW_row[data-actions-overflow] [data-composer-overflow-action]{display:none}.SFO4UW_standardControls{align-items:center;gap:12px;min-width:0;display:flex}.SFO4UW_tools[hidden],.SFO4UW_standardControls[hidden]{display:none}.SFO4UW_trailingActive{flex:1;margin-left:0}.SFO4UW_activity{flex:none;align-items:center;display:flex}.SFO4UW_activity:empty{display:none}.SFO4UW_activityExpanded{flex:1;min-width:0}.SFO4UW_annotations{padding:8px 8px 2px}.SFO4UW_creationError{border-radius:var(--dsw-radius-md);background:var(--dsw-alias-interactive-bg-hover-danger);color:var(--dsw-alias-state-error-primary);align-items:center;gap:8px;margin:2px 10px 0;padding:8px 10px;font-size:13px;line-height:18px;display:flex}.SFO4UW_creationErrorIcon{flex:none}.SFO4UW_creationErrorCopy{overflow-wrap:anywhere;-webkit-user-select:text;user-select:text;flex-direction:column;flex:1;gap:2px;min-width:0;display:flex}.SFO4UW_creationErrorTitle{font-weight:500}.SFO4UW_creationErrorDetail{color:var(--dsw-alias-label-secondary);font-size:12px;line-height:17px}.SFO4UW_creationRetry{border-radius:var(--dsw-radius-sm);min-height:28px;color:var(--dsw-alias-state-error-primary);font:inherit;cursor:pointer;touch-action:manipulation;background:0 0;border:1px solid;flex:none;padding:4px 10px;font-size:12px;font-weight:500;line-height:16px}.SFO4UW_creationRetry:hover{background:color-mix(in srgb, currentColor 10%, transparent)}.SFO4UW_creationRetry:focus-visible{outline-offset:2px;outline:2px solid}.SFO4UW_pendingControls{align-items:center;gap:6px;min-width:0;display:inline-flex}.SFO4UW_pendingModel{border-radius:var(--dsw-radius-sm);min-width:0;max-width:min(220px,45cqw);height:28px;color:var(--dsw-alias-label-tertiary);white-space:nowrap;user-select:none;align-items:center;gap:6px;padding:0 8px;font-size:13px;line-height:20px;display:inline-flex}.SFO4UW_pendingModelLabel{text-overflow:ellipsis;min-width:0;overflow:hidden}.SFO4UW_pendingHarness{width:30px;height:28px;color:var(--dsw-alias-label-tertiary);opacity:.7;user-select:none;border-radius:6px;flex-shrink:0;justify-content:center;align-items:center;display:inline-flex}[data-phone] .SFO4UW_creationRetry{min-height:36px;padding:6px 12px}[data-phone] .SFO4UW_pendingModel{max-width:100%}[data-phone] .SFO4UW_pendingModelLabel{flex:0 auto;min-width:0;max-width:120px}[data-phone] .SFO4UW_pendingHarness{width:36px;height:36px}`,document.head.appendChild(e)}var $={accessory:`SFO4UW_accessory`,activity:`SFO4UW_activity`,activityExpanded:`SFO4UW_activityExpanded`,add:`SFO4UW_add`,addSeat:`SFO4UW_addSeat`,annotations:`SFO4UW_annotations`,card:`SFO4UW_card`,cardStack:`SFO4UW_cardStack`,cardWorkspaceTrigger:`SFO4UW_cardWorkspaceTrigger`,controlScroll:`SFO4UW_controlScroll`,creationError:`SFO4UW_creationError`,creationErrorCopy:`SFO4UW_creationErrorCopy`,creationErrorDetail:`SFO4UW_creationErrorDetail`,creationErrorIcon:`SFO4UW_creationErrorIcon`,creationErrorTitle:`SFO4UW_creationErrorTitle`,creationRetry:`SFO4UW_creationRetry`,dock:`SFO4UW_dock`,grow:`SFO4UW_grow`,hero:`SFO4UW_hero`,inlineNotices:`SFO4UW_inlineNotices`,input:`SFO4UW_input`,"input-pending":`SFO4UW_input-pending`,inputDisabled:`SFO4UW_inputDisabled`,modes:`SFO4UW_modes`,notice:`SFO4UW_notice`,overlayAnchor:`SFO4UW_overlayAnchor`,pending:`SFO4UW_pending`,pendingControls:`SFO4UW_pendingControls`,pendingHarness:`SFO4UW_pendingHarness`,pendingModel:`SFO4UW_pendingModel`,pendingModelLabel:`SFO4UW_pendingModelLabel`,placeholder:`SFO4UW_placeholder`,primary:`SFO4UW_primary`,retry:`SFO4UW_retry`,root:`SFO4UW_root`,row:`SFO4UW_row`,scroll:`SFO4UW_scroll`,select:`SFO4UW_select`,standardControls:`SFO4UW_standardControls`,submitSeat:`SFO4UW_submitSeat`,tools:`SFO4UW_tools`,topRail:`SFO4UW_topRail`,trailing:`SFO4UW_trailing`,trailingActive:`SFO4UW_trailingActive`};let QA=[],$A=(0,g.memo)(function({useSession:e,useInput:t,inputActions:n,keyboard:r,pendingDraft:i,addFiles:a,removeAttachment:o,resolveDraftAttachments:s,retryFileUpload:c,revealResponseAnnotation:l,toggleCommandMenu:u,stop:f,t:p,renderSlot:m,usePendingDraftText:_,useBusyEnter:v,useFileUploads:y,useNotices:b,useLexicon:ee,useMenuLauncher:te,useStopShortcut:ne,useProjection:re,sessionId:ie,variant:ae,disabled:oe=!1,preparingDraft:se=!1,sessionCreation:ce,onRetrySessionCreation:le,blocked:ue,workspacePickerOpen:de=!1,onRequestWorkspace:fe,placeholder:pe,topBar:me,accessory:x}){let S=t(e=>e),he=_(e=>e),ge=S?.responseAnnotations??QA,_e=S?.hoveredResponseAnnotationId,ve=(0,g.useMemo)(()=>({regionAria:p(`annotation.rail`),count:e=>p(`annotation.trayCount`,{count:e}),clearAll:p(`annotation.clearAll`),emptyComment:p(`annotation.emptyComment`),editHint:e=>p(`annotation.editHint`,{index:e}),revealHint:e=>p(`annotation.revealHint`,{index:e}),remove:e=>p(`annotation.remove`,{index:e})}),[p]),ye=(0,g.useMemo)(()=>ge.map(e=>({id:e.id,text:e.text,...e.annotation===void 0?{}:{annotation:e.annotation},canReveal:e.anchor!==void 0})),[ge]),be=b(e=>e),xe=v(e=>e),Se=ne(e=>e),Ce=te(e=>e===`command`),[we,Te]=(0,g.useState)(!1);(0,g.useEffect)(()=>{Te(!1)},[ie]);let Ee=e(e=>e.promptError)??null,De=e(e=>e.running)??!1,Oe=e(e=>e.subagent)??null,ke=e(e=>e.removed)??!1,Ae=re(`plan`,e=>e!==void 0&&(e.pending?!e.active:e.active)),je=re(`codexPlanMode`),Me=re(`goal`,e=>e!=null),Ne=ie===void 0&&i!==void 0&&ce!==void 0&&ce.state!==`idle`,Pe=Ne&&ce.state===`creating`,Fe=Ne&&ce.state===`error`,Ie=Ne?ce.token:void 0,Le=S!==void 0&&r!==void 0&&n!==void 0,Re=Ne?he:S?.draft??``,ze=S?.primaryAction,C=Ne?i.editor:r?.editor??null,Be=(0,g.useMemo)(()=>S===void 0||s===void 0?[]:s(S.attachmentIds),[s,S?.attachmentIds]),Ve=Re.trim()===``&&Be.length===0&&ge.length===0,He=y(e=>e),Ue=Be.some(e=>He[e.id]?.status===`error`),[We,Ge]=(0,g.useState)(null),Ke=(0,g.useRef)(0),qe=(0,g.useCallback)(e=>{Ke.current+=1,Ge({seq:Ke.current,text:e})},[]),Je=(0,g.useCallback)(()=>{Ge(null)},[]),Ye=re(`imageLimits`),Xe=re(`attachmentInput`),Ze=re(`queueState`),Qe=Xe?.enabled!==!1,$e=Xe?.imagesOnly===!0;(0,g.useEffect)(()=>{if(Ee===null)return;let{error:e}=Ee;e.code===`session/writer-held`?qe(p(`error.sessionInUse`)):e.code===`remote/turn-changed`?qe(p(`error.steerTurnChanged`)):e.code===`remote/steer-unavailable`?qe(p(`error.remoteSteerUnavailable`)):qe(e.code===`session/attachment-invalid`||e.code===`subagent/attachment-invalid`?VA(p,e.details.reason,Ye):`${e.message} (${e.code})`)},[Ee,qe,p,Ye]),(0,g.useEffect)(()=>{be?.level===`error`&&qe(be.text)},[be,qe]);let et=(0,g.useRef)(null),[tt,nt]=(0,g.useState)({phone:!1,overflowActions:!1});(0,g.useLayoutEffect)(()=>{let e=et.current;if(e!==null)return XA(e,nt)},[]);let rt=(0,g.useRef)(null),it=(0,g.useRef)(null),at=Oe?.address.mode===`continuable`,ot=at&&Oe.parentAvailable!==!0,st=Ne||ke||oe||!Le||ue!==void 0||ot,ct=st,lt=Ne||ke||oe||!Le,ut=S?.phase===`adjudicating`||S?.phase===`submitting`,dt=!Ne&&oe&&!ke&&fe!==void 0,ft=Ne||Le&&!ut&&(!ct||!Ne&&se&&Le&&!ke&&!ot&&!dt),pt=ke||!ft&&!dt,mt=Oe===null||Oe.address.mode===`continuable`,ht=!ct&&!ut&&Ve&&De&&mt&&Ze?.previewOnly!==!0&&S.queue.length>0,gt=(0,g.useRef)(Ne),_t=(0,g.useRef)(!1);if(gt.current&&!Ne&&ie!==void 0){let e=document.activeElement;e!==null&&rt.current?.contains(e)&&(_t.current=!0)}(0,g.useLayoutEffect)(()=>{gt.current=Ne},[Ne]),(0,g.useEffect)(()=>{S!==void 0&&n!==void 0&&Be.length!==S.attachmentIds.length&&n.pruneAttachments(Be.map(e=>e.id))},[Be,S?.attachmentIds,n]);let vt=()=>{jA(it)};(0,g.useEffect)(()=>{Ne?C!==null&&(0,d.shouldAutoFocusTextInput)()&&MA(C,vt):C!==null&&ft&&(_t.current?(_t.current=!1,MA(C,vt)):!ct&&(0,d.shouldAutoFocusTextInput)()&&MA(C,vt))},[Ne,Ie,ct,ft,ie,C]),(0,g.useEffect)(()=>{ct||Re===``||vt()},[Re!==``]),(0,g.useEffect)(()=>PA(it),[]);let yt=(0,g.useRef)({sessionId:ie,ids:new Set(Be.map(e=>e.id)),count:Be.length}),[bt,xt]=(0,g.useState)(0),St=(0,g.useRef)(0);(0,g.useEffect)(()=>{let e=yt.current,t=e.sessionId!==ie,n=bt!==St.current;if(St.current=bt,t){yt.current={sessionId:ie,ids:new Set(Be.map(e=>e.id)),count:Be.length};return}let r=!1;for(let t of Be)e.ids.has(t.id)||(e.ids.add(t.id),r=!0);let i=e.count!==Be.length;e.count=Be.length;let a=(r||n)&&(0,d.shouldAutoFocusTextInput)();if(!a&&!i&&!r&&!n||C===null||!ft||ct)return;a&&MA(C,vt);let o=window.requestAnimationFrame(()=>{let e=C.getRootElement();if(e===null)return;let t=e.ownerDocument.activeElement;a&&(t===null||t===e.ownerDocument.body||t===e.ownerDocument.documentElement)&&MA(C,vt),NA(C),vt()});return()=>{window.cancelAnimationFrame(o)}},[ie,Be,bt,C,ft,ct]);let Ct=(0,g.useCallback)((e,t)=>{if(Oe!==null||a===void 0||e.length===0)return;if(!Qe){qe(p(`attachment.unavailable`));return}let n=(()=>{if($e&&e.some(e=>!(Ye?.mediaTypes)?.includes(e.type)))return p(`image.unsupportedType`);if(Ye!==void 0){let t=Ye.mediaTypes,n=e.filter(e=>t.includes(e.type)),r=Be.filter(e=>e.kind===`image`);if(r.length+n.length>Ye.maxImagesPerMessage)return p(`image.tooMany`,{count:Ye.maxImagesPerMessage});if(n.some(e=>e.size>Ye.maxImageBytes))return p(`image.fileTooLarge`,{size:BA(Ye.maxImageBytes)});if(r.reduce((e,t)=>e+t.file.size,0)+n.reduce((e,t)=>e+t.size,0)>Ye.maxMessageImageBytes)return p(`image.totalTooLarge`,{size:BA(Ye.maxMessageImageBytes)})}return a(e,t)})();n===null?xt(e=>e+1):qe(n)},[Oe,a,Qe,$e,Be,Ye,qe,p]),wt=Qe&&Oe===null&&!ct&&!ut&&a!==void 0,Tt=p(Qe?$e?`input.imagesAndCommands`:`input.commands`:`input.commandsOnly`),Et=(0,g.useRef)(null),Dt=e=>{let t=e.target.files===null?[]:[...e.target.files];e.target.value=``,t.length>0&&Ct(t)},Ot=(0,g.useRef)({locked:ct,canPasteText:ft,machineBusy:ut,primaryAction:ze,canSteerQueue:ht,running:De,steeringAvailable:mt,busyEnter:xe,intakeFiles:Ct,uploadsFailed:Ue,showToast:qe,t:p,canAcceptDrop:wt});Ot.current={locked:ct,canPasteText:ft,machineBusy:ut,primaryAction:ze,canSteerQueue:ht,running:De,steeringAvailable:mt,busyEnter:xe,intakeFiles:Ct,uploadsFailed:Ue,showToast:qe,t:p,canAcceptDrop:wt},(0,g.useEffect)(()=>{if(r!==void 0)return FA(r,Ot,Et)},[r]),(0,g.useEffect)(()=>{if(C!==null){if(Ne&&i!==void 0)return AA(C,{arbitrate:()=>`pass`,space:()=>!1,dismissPopup:()=>{},canSubmit:()=>!1,submit:()=>{},intakeFiles:()=>{Ot.current.showToast(Ot.current.t(`newSession.uploadUnavailable`))},pasteText:e=>{i.paste(e)}});if(r!==void 0)return IA(C,r,Ot)}},[C,r,Ne,i]);let kt=e=>{zA(e,C)},At=e=>{!Nt&&e.button===0&&LA(e.currentTarget.ownerDocument),zA(e,C)},jt=()=>{r!==void 0&&(C!==null&&(0,d.shouldAutoFocusTextInput)()&&MA(C,vt),u?.(r.caretSpan()))},Mt=e=>{dt&&(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),fe())},Nt=ze===void 0&&De&&Oe===null&&(Ve||ue!==void 0),Pt=Nt?f===void 0:(ze===void 0?Ve:ze.disabled)||st||ut,Ft=De&&at,It=vk(xe,De,`enter`,mt),Lt=!Ve&&S?.phase===`plain`&&!Re.trimStart().startsWith(`/`),Rt=p(Nt?`input.stop`:ze===void 0&&De&&mt&&!st&&!Ue&&Lt?It===`steer`?`input.send.steer`:`input.send.queue`:`input.send`),zt=()=>{(0,d.shouldAutoFocusTextInput)()||RA(C)},Bt=()=>{zt(),f?.()},Vt=()=>{Nt?Bt():Ue?qe(p(`file.retryOrRemove`)):ze===void 0?r!==void 0&&!Ve&&!st&&!ut&&(zt(),r.submit(It,`click`)):Pt||(zt(),ze.run())},Ht=(S?.phase===`claimed`||S?.phase===`submitting`)&&S.claim!==void 0&&Re.startsWith(S.claim.token),Ut=Ht&&S.claim.hint!==void 0&&Re.slice(S.claim.token.length).trim()===``?S.claim.hint:null,Wt=(()=>{if(Ut===null)return null;let e=S?.claim?.name??``,t=`hint.${e===`goal`&&Me?`goal.active`:e}`,n=p(t);return n===t?Ut:n})(),Gt=pe??p(ot?`placeholder.parentOffline`:st?`placeholder.unavailable`:ht?`placeholder.steerQueue`:je??Ae?`placeholder.plan`:`placeholder.default`);return/* @__PURE__ */ (0,h.jsxs)(`div`,{className:sC($.root,ae===`hero`&&$.hero),"data-composer-variant":ae,children:[We!==null&&/* @__PURE__ */ (0,h.jsx)(d.Toast,{text:We.text,icon:/* @__PURE__ */ (0,h.jsx)(d.IconWarningOutlineRegular,{}),anchor:rt.current,onDone:Je},We.seq),be?.level===`info`&&/* @__PURE__ */ (0,h.jsx)(`div`,{className:$.notice,role:`status`,children:be.text}),/* @__PURE__ */ (0,h.jsxs)(`div`,{className:$.cardStack,children:[me!==void 0&&/* @__PURE__ */ (0,h.jsx)(`div`,{className:$.topRail,"data-composer-top-bar":``,onClick:e=>{e.stopPropagation()},onPointerDown:e=>{e.stopPropagation()},children:me}),/* @__PURE__ */ (0,h.jsxs)(`div`,{ref:rt,className:sC($.card,dt&&$.cardWorkspaceTrigger),"data-composer-card":!0,onClick:dt?fe:void 0,onPointerDown:dt?e=>{e.stopPropagation()}:void 0,children:[ie!==void 0&&/* @__PURE__ */ (0,h.jsx)(`div`,{className:$.overlayAnchor,children:m(`conversation.input.overlay`,{})}),x!==void 0&&/* @__PURE__ */ (0,h.jsx)(`div`,{className:$.accessory,children:x}),Fe&&/* @__PURE__ */ (0,h.jsxs)(`div`,{className:$.creationError,role:`alert`,"data-new-session-error":``,children:[/* @__PURE__ */ (0,h.jsx)(d.IconWarningOutlineRegular,{className:$.creationErrorIcon,size:16}),/* @__PURE__ */ (0,h.jsxs)(`div`,{className:$.creationErrorCopy,children:[/* @__PURE__ */ (0,h.jsx)(`span`,{className:$.creationErrorTitle,children:p(`newSession.createFailedTitle`)}),/* @__PURE__ */ (0,h.jsx)(`span`,{className:$.creationErrorDetail,children:ce.reason===`no-harness`?p(`newSession.createFailed.noHarness`):ce.reason===`workspace-required`?p(`newSession.createFailed.workspaceRequired`):ce.message??p(`newSession.createFailed.generic`)})]}),le!==void 0&&/* @__PURE__ */ (0,h.jsx)(`button`,{type:`button`,className:$.creationRetry,onMouseDown:kt,onClick:le,children:p(`newSession.retry`)})]}),ye.length===0?null:/* @__PURE__ */ (0,h.jsx)(`div`,{className:$.annotations,children:/* @__PURE__ */ (0,h.jsx)(d.ResponseAnnotationTray,{annotations:ye,hoveredId:_e,disabled:ct||ut,labels:ve,onHover:e=>{n?.hoverResponseAnnotation(e)},onReveal:l===void 0?void 0:e=>{l(e)},onUpdate:(e,t)=>{n?.updateResponseAnnotation(e,t)},onRemove:e=>{n?.removeResponseAnnotation(e)},onClearAll:()=>{n?.clearResponseAnnotations()}})}),S===void 0||ie===void 0?null:/* @__PURE__ */ (0,h.jsx)(`div`,{className:$.inlineNotices,children:m(`conversation.input.notice`,{})}),m(`conversation.input.attachments`,{attachments:Be,canAcceptDrop:wt,onAddFiles:Ct,onRemoveAttachment:e=>{o?.(e)},uploads:He,onRetryFile:e=>{c?.(e)},dropLimits:Ye===void 0?void 0:{count:Ye.maxImagesPerMessage,size:BA(Ye.maxImageBytes)}}),/* @__PURE__ */ (0,h.jsx)(DA,{classNames:$,editor:C,scrollRef:it,editable:ft,editorDisabled:pt,preserveFocus:_t.current,phase:Ne?`plain`:S?.phase??`inert`,placeholderText:Gt,ariaLabel:dt?p(`hero.chooseWorkspace`):Gt,workspaceTrigger:dt,workspacePickerOpen:de,onWorkspaceKeyDown:Mt,hint:Wt,showPlaceholder:Re===``&&Be.length===0&&!Ht}),/* @__PURE__ */ (0,h.jsx)(`div`,{ref:et,className:$.row,"data-composer-toolbar":!0,"data-command-menu-open":Ce||void 0,"data-toolbar-activity":we||void 0,children:/* @__PURE__ */ (0,h.jsxs)(`div`,{className:$.controlScroll,"data-toolbar-scroll":!0,children:[/* @__PURE__ */ (0,h.jsxs)(`div`,{className:$.tools,hidden:we,"data-composer-tools":!0,children:[/* @__PURE__ */ (0,h.jsx)(`div`,{className:$.addSeat,"data-toolbar-fixed":`start`,children:/* @__PURE__ */ (0,h.jsx)(d.Tooltip,{portal:tt.phone,label:Tt,side:`top`,delayMs:500,children:/* @__PURE__ */ (0,h.jsx)(`button`,{type:`button`,className:$.add,"aria-label":Tt,"aria-haspopup":`listbox`,"aria-expanded":Ce,disabled:ct||ut||u===void 0,onMouseDown:kt,onClick:jt,children:/* @__PURE__ */ (0,h.jsx)(d.IconPlusOutlineMedium,{size:14})})})}),/* @__PURE__ */ (0,h.jsx)(`input`,{ref:Et,type:`file`,accept:$e?Ye?.mediaTypes.join(`,`):void 0,multiple:!0,disabled:!Qe||Oe!==null,hidden:!0,onChange:Dt}),/* @__PURE__ */ (0,h.jsxs)(`div`,{className:$.modes,children:[ie===void 0?null:m(`conversation.input.permission`,{locked:ct}),ie===void 0?null:m(`conversation.input.plan`,{locked:ct})]}),S===void 0||ie===void 0?null:m(`conversation.input.left`,{})]}),/* @__PURE__ */ (0,h.jsxs)(`div`,{className:sC($.trailing,we&&$.trailingActive),children:[/* @__PURE__ */ (0,h.jsxs)(`div`,{className:$.standardControls,hidden:we,children:[S===void 0||ie===void 0?null:m(`conversation.input.right`,{overflowActions:tt.overflowActions}),ie===void 0?Pe?/* @__PURE__ */ (0,h.jsxs)(`div`,{className:$.pendingControls,role:`status`,"aria-live":`polite`,"data-new-session-loading":``,children:[/* @__PURE__ */ (0,h.jsxs)(`span`,{className:$.pendingModel,children:[/* @__PURE__ */ (0,h.jsx)(d.StateDot,{state:`ongoing`}),/* @__PURE__ */ (0,h.jsx)(`span`,{className:$.pendingModelLabel,children:p(`newSession.loadingModel`)})]}),/* @__PURE__ */ (0,h.jsx)(`span`,{className:$.pendingHarness,role:`img`,"aria-label":p(`newSession.loadingHarness`),"aria-busy":`true`,title:p(`newSession.loadingHarness`),children:/* @__PURE__ */ (0,h.jsx)(d.StateDot,{state:`ongoing`})})]}):null:m(`conversation.input.model`,{locked:lt})]}),S===void 0||ie===void 0?null:/* @__PURE__ */ (0,h.jsx)(`div`,{className:we?$.activityExpanded:$.activity,children:m(`conversation.input.activity`,{locked:ct,onActiveChange:Te})}),/* @__PURE__ */ (0,h.jsxs)(`div`,{className:$.submitSeat,"data-toolbar-fixed":`end`,children:[Ft&&/* @__PURE__ */ (0,h.jsx)(d.Tooltip,{portal:tt.phone,label:p(`input.stop`),shortcutKeys:Se,side:`top`,delayMs:500,disabled:f===void 0,children:/* @__PURE__ */ (0,h.jsx)(`button`,{type:`button`,className:$.primary,"aria-label":p(`input.stop`),disabled:f===void 0,onMouseDown:kt,onClick:Bt,children:/* @__PURE__ */ (0,h.jsx)(`svg`,{viewBox:`0 0 16 16`,width:`14`,height:`14`,"aria-hidden":!0,children:/* @__PURE__ */ (0,h.jsx)(`rect`,{x:`3`,y:`3`,width:`10`,height:`10`,rx:`3`,fill:`currentColor`})})})}),/* @__PURE__ */ (0,h.jsx)(d.Tooltip,{portal:tt.phone,label:Nt?p(`input.stop`):Rt,shortcutKeys:Nt?Se:void 0,side:`top`,delayMs:500,disabled:Pt,children:/* @__PURE__ */ (0,h.jsx)(`button`,{type:`button`,className:$.primary,"aria-label":Rt,disabled:Pt,onMouseDown:At,onClick:Vt,children:Nt?/* @__PURE__ */ (0,h.jsx)(`svg`,{viewBox:`0 0 16 16`,width:`14`,height:`14`,"aria-hidden":!0,children:/* @__PURE__ */ (0,h.jsx)(`rect`,{x:`3`,y:`3`,width:`10`,height:`10`,rx:`3`,fill:`currentColor`})}):/* @__PURE__ */ (0,h.jsx)(`svg`,{viewBox:`0 0 16 16`,width:`14`,height:`14`,"aria-hidden":!0,children:/* @__PURE__ */ (0,h.jsx)(`path`,{d:`M8.3125 0.980183C8.66767 1.0531 8.97902 1.20418 9.2627 1.43233C9.48724 1.61297 9.73029 1.85793 9.97949 2.10714L14.707 6.83468L13.293 8.24874L9 3.95577V15.0417H7V3.95577L2.70703 8.24874L1.29297 6.83468L6.02051 2.10714C6.26971 1.85793 6.51277 1.61297 6.7373 1.43233C6.97662 1.23986 7.28445 1.04402 7.6875 0.980183C7.8973 0.947006 8.1031 0.95516 8.3125 0.980183Z`,fill:`currentColor`})})})})]})]})]})})]})]}),/* @__PURE__ */ (0,h.jsxs)(`div`,{className:$.dock,"data-composer-dock":!0,"data-cx-region":`composer-dock`,children:[ae===`composer`&&S!==void 0&&ie!==void 0?m(`conversation.composer.dock`,{}):null,we?null:/* @__PURE__ */ (0,h.jsx)(YA,{useProjection:re,t:p})]})]})}),ej=`@deepseek-ai/dsh-client-ui-conversation/TodoPanel.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(ej)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-conversation`,e.dataset.pluginCss=ej,e.textContent=`.OKyn-W_root{box-sizing:border-box;width:calc(100% - var(--dsh-composer-side-clearance) - var(--dsh-composer-side-clearance) - var(--dsh-composer-dock-inset) - var(--dsh-composer-dock-inset) - var(--dsh-composer-dock-inset) - var(--dsh-composer-dock-inset));max-width:calc(var(--dsh-composer-card-max-width) - var(--dsh-composer-dock-inset) - var(--dsh-composer-dock-inset) - var(--dsh-composer-dock-inset) - var(--dsh-composer-dock-inset));--dsw-elevation-stroke-color:var(--dsw-alias-border-l1);border-radius:var(--dsw-radius-lg);background:var(--dsw-specific-menu);backdrop-filter:var(--dsw-menu-backdrop-filter);box-shadow:var(--dsw-elevation-panel);--dsh-scrollbar-thumb:var(--dsw-alias-scrollbar-bg-l2);--dsh-scrollbar-thumb-hover:var(--dsw-alias-scrollbar-hover-l2);border:0;flex:none;margin:0 auto;overflow:hidden}.OKyn-W_body{flex-direction:column;gap:8px;padding:6px 12px;display:flex}.OKyn-W_header{text-align:left;cursor:pointer;background:0 0;border:none;align-items:center;gap:10px;width:100%;padding:0;display:flex}.OKyn-W_lead{color:var(--dsw-alias-label-tertiary);flex:none;place-items:center;display:grid}.OKyn-W_title{color:var(--dsw-alias-label-primary);flex:none;font-size:13px;font-weight:500;line-height:24px}.OKyn-W_progress{min-width:0;color:var(--dsw-alias-label-tertiary);text-overflow:ellipsis;white-space:nowrap;flex:auto;font-size:13px;font-weight:400;line-height:20px;overflow:hidden}.OKyn-W_chevron{color:var(--dsw-alias-label-tertiary);flex:none;place-items:center;display:grid}.OKyn-W_list{flex-direction:column;gap:8px;max-height:180px;margin:0;padding:0;list-style:none;display:flex;overflow-y:auto}.OKyn-W_item{min-width:0;color:var(--dsw-alias-label-secondary);align-items:center;gap:10px;font-size:13px;line-height:20px;display:flex}.OKyn-W_glyph{flex:none;place-items:center;width:16px;height:16px;display:grid}.OKyn-W_content{text-overflow:ellipsis;white-space:nowrap;min-width:0;overflow:hidden}`,document.head.appendChild(e)}var tj={body:`OKyn-W_body`,chevron:`OKyn-W_chevron`,content:`OKyn-W_content`,glyph:`OKyn-W_glyph`,header:`OKyn-W_header`,item:`OKyn-W_item`,lead:`OKyn-W_lead`,list:`OKyn-W_list`,progress:`OKyn-W_progress`,root:`OKyn-W_root`,title:`OKyn-W_title`};
171
+ n!==null&&(e.ctrlKey||e.deltaY===0||n.scrollBy({top:UA(e,n)}))},[]);return/* @__PURE__ */ (0,h.jsx)(`div`,{className:Q.widthHandle,"data-side":e.side,"data-width-handle":e.side,onPointerDown:l,onPointerMove:u,onPointerUp:d,onPointerCancel:f,onLostPointerCapture:f,onWheel:p})}function GA({container:e,phase:t}){let n=(0,g.useCallback)(e=>{let t=e.parentElement??e,n=e.offsetWidth;t.style.setProperty(`--dsh-conversation-column-width`,`${n}px`);let r=VA();r===null?t.style.removeProperty(`--dsh-chat-user-width`):t.style.setProperty(`--dsh-chat-user-width`,`${HA(n,r)}px`)},[]);(0,g.useLayoutEffect)(()=>{if(e===null)return;let t=new ResizeObserver(()=>{n(e)});return t.observe(e),n(e),()=>{t.disconnect()}},[e,n]);let r=(0,g.useCallback)(()=>e===null?680:HA(e.offsetWidth,VA()),[e]),i=(0,g.useCallback)(t=>{e!==null&&(e.parentElement??e).style.setProperty(`--dsh-chat-user-width`,`${HA(e.offsetWidth,t)}px`)},[e]),a=(0,g.useCallback)(t=>{e!==null&&localStorage.setItem(BA,`${HA(e.offsetWidth,t)}`)},[e]),o=(0,g.useCallback)(()=>{e!==null&&n(e)},[e,n]);return e===null||t!==`active`?null:[`left`,`right`].map(e=>/* @__PURE__ */ (0,h.jsx)(WA,{side:e,onStart:r,onDrag:i,onCommit:a,onEnd:o},e))}let KA={widthControls:GA};function qA(e){let{sessionId:t,useSession:n,useSessions:r,useConversation:i,renderSlot:a,renderFactorySlot:o}=e,s=n(e=>e),c=i(e=>e),l=s===void 0||c===void 0?`blank`:RA(s,c),u=s?.openState,d=r(e=>t===void 0?void 0:e.byId[t]?.blank),f=s?.subagent?.address.mode===`continuable`&&s.subagent.parentAvailable===void 0,p=t!==void 0&&(l===`blank`&&u===`loading`&&d!==!0||f),m=t===void 0||l===`blank`&&(u===`open`||d===!0),g=p?`settling`:m?`hero`:`active`;return/* @__PURE__ */ (0,h.jsxs)(`div`,{className:Q.root,"data-phase":g,"data-cx-region":`conversation`,children:[a(`conversation.header`,{}),a(`conversation.header.notice`,{}),o(`conversation.content`,{variant:`main`,phase:g,hero:m},{slots:KA})]})}function JA(e){return/* @__PURE__ */ (0,h.jsx)(qA,{...e})}function YA(e,t){return e===`default-workspace`?t:e}let XA=`@deepseek-ai/dsh-client-ui-conversation/HeroShell.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(XA)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-conversation`,e.dataset.pluginCss=XA,e.textContent=`.Dgrl1G_root{justify-content:center;align-items:center;min-width:0;height:100%;padding:0 24px;display:flex}.Dgrl1G_stack{width:100%;max-width:var(--dsh-composer-card-max-width);flex-direction:column;align-items:stretch;gap:12px;display:flex;overflow:visible}.Dgrl1G_headline{color:var(--dsw-alias-label-primary);flex-wrap:wrap;justify-content:center;align-items:center;gap:12px 10px;font-size:26px;font-weight:500;line-height:32px;display:flex}.Dgrl1G_titleGroup{flex-wrap:wrap;justify-content:center;align-items:center;gap:4px 7px;min-width:0;display:flex}.Dgrl1G_previewBadge{border:.5px solid var(--dsw-alias-interactive-bg-hover);corner-shape:round;background:var(--dsw-alias-state-business-tertiary);color:var(--dsw-alias-label-primary-bluish);font-family:var(--ds-font-family-code);white-space:nowrap;border-radius:999px;align-self:flex-start;margin-top:2px;padding:1px 7px 0;font-size:12px;font-weight:500;line-height:18px}.Dgrl1G_previewBadgeDesktop{display:none}html[data-codexhost-shell] .Dgrl1G_previewBadgeWeb,html[data-tauri-shell] .Dgrl1G_previewBadgeWeb{display:none}html[data-codexhost-shell] .Dgrl1G_previewBadgeDesktop,html[data-tauri-shell] .Dgrl1G_previewBadgeDesktop{display:inline}.Dgrl1G_fishHitbox{flex:none;justify-content:center;align-items:center;display:inline-flex}.Dgrl1G_fish{transform-origin:50% 60%;color:var(--dsw-alias-label-primary);display:block;overflow:visible}@keyframes Dgrl1G_hero-fish-swim{0%,to{transform:none}35%{transform:rotate(-4deg)translate(-.4px,-.9px)}70%{transform:rotate(1.6deg)translate(.3px,.2px)}}@media (hover:hover) and (prefers-reduced-motion:no-preference){.Dgrl1G_fishHitbox:hover .Dgrl1G_fish{animation:1.6s ease-in-out infinite Dgrl1G_hero-fish-swim}}.Dgrl1G_body{flex-direction:column;gap:12px;min-width:0;display:flex;position:relative;overflow:visible}.Dgrl1G_body>*{z-index:1;position:relative}.Dgrl1G_body>.Dgrl1G_workspaceRow{z-index:10;align-items:center;min-width:0;padding-left:8px;display:flex}.Dgrl1G_workspace{border-radius:var(--dsw-radius-sm);max-width:min(100%,360px);min-height:28px;color:var(--dsw-alias-label-primary);cursor:pointer;background:0 0;border:none;align-items:center;gap:4px;padding:0 8px;font-size:13px;font-weight:500;line-height:20px;display:inline-flex}.Dgrl1G_workspace:not(:disabled):hover,.Dgrl1G_workspace[aria-expanded=true]{background:var(--dsw-alias-interactive-bg-hover)}.Dgrl1G_workspace:disabled{cursor:default}.Dgrl1G_folder{color:var(--dsw-alias-label-primary);flex:none}.Dgrl1G_workspaceLabel{text-overflow:ellipsis;white-space:nowrap;min-width:0;overflow:hidden}.Dgrl1G_chevron{color:var(--dsw-alias-label-caption);flex:none}.Dgrl1G_modalInput{box-sizing:border-box;border:.5px solid var(--dsw-alias-border-l4);border-radius:var(--dsw-radius-lg);width:100%;height:44px;color:var(--dsw-alias-label-primary);background:0 0;outline:none;padding:7px 14px;font-size:14px;font-weight:400;line-height:22px}.Dgrl1G_modalInput::placeholder{color:var(--dsw-alias-label-caption)}.Dgrl1G_modalInput:disabled{color:var(--dsw-alias-label-dimmed)}.Dgrl1G_modalAction{min-width:72px}.Dgrl1G_modalError{color:var(--dsw-alias-state-error-primary);margin-top:8px;font-size:12px;line-height:18px}`,document.head.appendChild(e)}var ZA={body:`Dgrl1G_body`,chevron:`Dgrl1G_chevron`,fish:`Dgrl1G_fish`,fishHitbox:`Dgrl1G_fishHitbox`,folder:`Dgrl1G_folder`,headline:`Dgrl1G_headline`,"hero-fish-swim":`Dgrl1G_hero-fish-swim`,modalAction:`Dgrl1G_modalAction`,modalError:`Dgrl1G_modalError`,modalInput:`Dgrl1G_modalInput`,previewBadge:`Dgrl1G_previewBadge`,previewBadgeDesktop:`Dgrl1G_previewBadgeDesktop`,previewBadgeWeb:`Dgrl1G_previewBadgeWeb`,root:`Dgrl1G_root`,stack:`Dgrl1G_stack`,titleGroup:`Dgrl1G_titleGroup`,workspace:`Dgrl1G_workspace`,workspaceLabel:`Dgrl1G_workspaceLabel`,workspaceRow:`Dgrl1G_workspaceRow`};function QA(e){let t=sd(e);return t===``?e:t}function $A({buttonRef:e,label:t,projectless:n=!1,menuOpen:r=!1,onClick:i,t:a}){return/* @__PURE__ */ (0,h.jsxs)(`button`,{ref:e,type:`button`,className:ZA.workspace,"aria-label":a(`hero.chooseWorkspace`),"aria-haspopup":`menu`,"aria-expanded":r,onClick:i,children:[t===void 0||n?/* @__PURE__ */ (0,h.jsx)(d.IconFolderCloseRegular,{className:ZA.folder,size:16}):/* @__PURE__ */ (0,h.jsx)(d.IconFolderOpenRegular,{className:ZA.folder,size:16}),/* @__PURE__ */ (0,h.jsx)(`span`,{className:ZA.workspaceLabel,children:t??a(`hero.chooseWorkspace`)}),/* @__PURE__ */ (0,h.jsx)(d.IconChevronDownOutlineRegular,{className:ZA.chevron,size:12})]})}function ej({hovering:e}){return/* @__PURE__ */ (0,h.jsx)(`svg`,{className:ZA.fish,width:34,height:34*d.FISH_LOGO_VIEWBOX.height/d.FISH_LOGO_VIEWBOX.width,viewBox:`0 0 ${d.FISH_LOGO_VIEWBOX.width} ${d.FISH_LOGO_VIEWBOX.height}`,fill:`none`,"aria-hidden":`true`,children:/* @__PURE__ */ (0,h.jsx)(`path`,{d:d.FISH_LOGO_PATH,fill:`currentColor`,children:e&&/* @__PURE__ */ (0,h.jsx)(`animate`,{attributeName:`d`,values:`${d.FISH_LOGO_PATH};M22.403 0.567C22.145 0.477 22.068 0.718 21.939 0.85C21.895 0.893 21.86 0.947 21.824 0.997C21.515 1.421 21.13 1.721 20.591 1.77C19.829 1.867 19.221 2.244 18.712 2.958C18.535 2.227 18.116 1.839 17.516 1.626C17.203 1.506 16.887 1.379 16.663 1.064C16.508 0.839 16.462 0.581 16.383 0.329C16.332 0.176 16.283 0.02 16.121 -0.002C15.944 -0.029 15.875 0.133 15.805 0.269C15.52 0.822 15.408 1.43 15.42 2.046C15.449 3.432 16.031 4.532 17.202 5.274C17.337 5.356 17.374 5.445 17.335 5.582C17.261 5.862 17.169 6.134 17.086 6.413C17.032 6.59 16.952 6.63 16.764 6.558C16.118 6.301 15.562 5.909 15.074 5.433C14.248 4.633 13.5 3.751 12.568 3.06C12.349 2.898 12.13 2.748 11.903 2.605C10.952 1.682 12.028 0.923 12.277 0.833C12.537 0.739 12.367 0.416 11.526 0.42C10.684 0.424 9.914 0.706 8.933 1.081C8.789 1.138 8.638 1.179 8.484 1.213C7.593 1.044 6.668 1.006 5.702 1.115C3.883 1.318 2.43 2.178 1.362 3.646C0.079 5.41 -0.223 7.415 0.147 9.506C0.535 11.71 1.66 13.535 3.389 14.962C5.181 16.441 7.246 17.166 9.601 17.027C11.032 16.944 12.624 16.753 14.421 15.232C14.874 15.458 15.35 15.548 16.138 15.615C16.746 15.672 17.331 15.585 17.784 15.491C18.493 15.341 18.444 14.684 18.188 14.564C16.108 13.595 16.565 13.989 16.15 13.67C17.206 12.42 18.82 10.198 19.363 7.086C19.421 6.709 19.484 6.171 19.469 5.866C19.458 5.681 19.493 5.604 19.681 5.556C20.199 5.412 20.691 5.172 21.125 4.806C22.366 3.824 22.758 2.554 22.708 1.1C22.7 0.878 22.649 0.654 22.403 0.567ZM11.175 14.451C9.159 12.726 8.182 12.088 7.778 12.067C7.401 12.047 7.469 12.505 7.552 12.807C7.639 13.103 7.752 13.313 7.91 13.581C8.02 13.758 8.095 14.01 7.801 14.16C7.152 14.487 6.023 13.806 5.97 13.772C4.657 12.85 3.559 11.766 2.785 10.369C2.037 9.025 1.603 7.583 1.532 6.044C1.513 5.672 1.622 5.541 1.992 5.473C2.479 5.383 2.981 5.364 3.468 5.436C5.525 5.736 7.276 6.675 8.744 8.323C9.582 9.299 10.216 10.425 10.869 11.496C11.563 12.592 12.31 13.603 13.262 14.414C13.598 14.696 13.866 14.91 14.123 15.068C13.349 15.154 12.058 15.167 11.175 14.452L11.175 14.451ZM12.141 8.26C12.141 8.095 12.273 7.963 12.439 7.963C12.476 7.963 12.511 7.971 12.541 7.982C12.582 7.997 12.62 8.019 12.65 8.053C12.704 8.106 12.733 8.181 12.733 8.26C12.733 8.425 12.601 8.556 12.435 8.556C12.27 8.556 12.141 8.425 12.141 8.26ZM15.142 9.799C14.949 9.878 14.757 9.945 14.572 9.953C14.284 9.968 13.972 9.851 13.802 9.709C13.537 9.487 13.348 9.363 13.27 8.977C13.236 8.812 13.255 8.556 13.284 8.41C13.352 8.094 13.277 7.892 13.055 7.708C12.873 7.558 12.643 7.516 12.39 7.516C12.296 7.516 12.209 7.475 12.145 7.441C12.039 7.389 11.952 7.257 12.035 7.096C12.062 7.043 12.19 6.916 12.22 6.893C12.563 6.698 12.96 6.762 13.326 6.908C13.665 7.047 13.922 7.302 14.292 7.663C14.669 8.098 14.738 8.218 14.953 8.545C15.123 8.801 15.277 9.063 15.383 9.364C15.447 9.551 15.364 9.705 15.142 9.799Z;${d.FISH_LOGO_PATH};M23.271 2.216C23.039 2.071 22.91 2.287 22.755 2.388C22.703 2.42 22.656 2.464 22.61 2.505C22.214 2.848 21.771 3.054 21.225 2.956C20.412 2.784 19.68 2.919 19.005 3.435C18.92 2.663 18.493 2.157 17.808 1.798C17.446 1.621 17.08 1.449 16.83 1.111C16.656 0.872 16.611 0.612 16.524 0.354C16.469 0.198 16.414 0.039 16.223 0.009C16.017 -0.024 15.936 0.137 15.856 0.271C15.539 0.822 15.418 1.43 15.429 2.046C15.454 3.432 16.041 4.538 17.196 5.36C17.325 5.456 17.356 5.547 17.312 5.674C17.229 5.936 17.134 6.191 17.051 6.454C16.999 6.623 16.921 6.659 16.738 6.58C16.107 6.306 15.56 5.909 15.074 5.433C14.248 4.633 13.5 3.751 12.568 3.06C12.349 2.898 12.13 2.748 11.903 2.605C10.952 1.682 12.028 0.923 12.277 0.833C12.537 0.739 12.367 0.416 11.526 0.42C10.684 0.424 9.914 0.706 8.933 1.081C8.789 1.138 8.638 1.179 8.484 1.213C7.593 1.044 6.668 1.006 5.702 1.115C3.883 1.318 2.43 2.178 1.362 3.646C0.079 5.41 -0.223 7.415 0.147 9.506C0.535 11.71 1.66 13.535 3.389 14.962C5.181 16.441 7.246 17.166 9.601 17.027C11.032 16.944 12.624 16.753 14.421 15.232C14.874 15.458 15.35 15.548 16.138 15.615C16.746 15.672 17.331 15.585 17.784 15.491C18.493 15.341 18.444 14.684 18.188 14.564C16.108 13.595 16.565 13.989 16.15 13.67C17.206 12.42 18.82 10.198 19.278 7.246C19.318 6.948 19.375 6.534 19.371 6.293C19.371 6.145 19.411 6.092 19.597 6.098C20.113 6.109 20.619 6.051 21.096 5.891C22.503 5.375 23.169 4.232 23.448 2.804C23.49 2.586 23.491 2.356 23.271 2.216ZM11.175 14.49C9.159 13.005 8.182 12.567 7.778 12.621C7.401 12.673 7.469 13.087 7.552 13.354C7.639 13.619 7.752 13.797 7.91 14.024C8.02 14.175 8.095 14.406 7.801 14.609C7.152 15.063 6.023 14.63 5.97 14.609C4.657 13.941 3.559 12.965 2.785 11.569C2.037 10.225 1.603 8.783 1.532 7.244C1.513 6.872 1.622 6.741 1.992 6.673C2.479 6.583 2.981 6.564 3.468 6.636C5.525 6.936 7.276 7.843 8.744 9.163C9.582 9.888 10.216 10.783 10.869 11.679C11.563 12.659 12.31 13.617 13.262 14.415C13.598 14.696 13.866 14.91 14.123 15.068C13.349 15.155 12.058 15.177 11.175 14.491L11.175 14.49ZM12.141 8.26C12.141 8.095 12.273 7.963 12.439 7.963C12.476 7.963 12.511 7.971 12.541 7.982C12.582 7.997 12.62 8.019 12.65 8.053C12.704 8.106 12.733 8.181 12.733 8.26C12.733 8.425 12.601 8.556 12.435 8.556C12.27 8.556 12.141 8.425 12.141 8.26ZM15.142 9.799C14.949 9.878 14.757 9.945 14.572 9.953C14.284 9.968 13.972 9.851 13.802 9.709C13.537 9.487 13.348 9.363 13.27 8.977C13.236 8.812 13.255 8.556 13.284 8.41C13.352 8.094 13.277 7.892 13.055 7.708C12.873 7.558 12.643 7.516 12.39 7.516C12.296 7.516 12.209 7.475 12.145 7.441C12.039 7.389 11.952 7.257 12.035 7.096C12.062 7.043 12.19 6.916 12.22 6.893C12.563 6.698 12.96 6.762 13.326 6.908C13.665 7.047 13.922 7.302 14.292 7.663C14.669 8.098 14.738 8.218 14.953 8.545C15.123 8.801 15.277 9.063 15.383 9.364C15.447 9.551 15.364 9.705 15.142 9.799Z;${d.FISH_LOGO_PATH}`,keyTimes:`0;0.35;0.55;0.75;1`,calcMode:`spline`,keySplines:`0.45 0 0.55 1;0.45 0 0.55 1;0.45 0 0.55 1;0.45 0 0.55 1`,dur:`1.6s`,repeatCount:`indefinite`})})})}function tj({t:e,renderSlot:t,children:n}){let[r,i]=(0,g.useState)(!1);return/* @__PURE__ */ (0,h.jsxs)(`div`,{className:ZA.root,children:[/* @__PURE__ */ (0,h.jsxs)(`div`,{className:ZA.stack,children:[/* @__PURE__ */ (0,h.jsxs)(`div`,{className:ZA.headline,children:[/* @__PURE__ */ (0,h.jsx)(`span`,{className:ZA.fishHitbox,onMouseEnter:()=>{window.matchMedia(`(hover: hover) and (prefers-reduced-motion: no-preference)`).matches&&i(!0)},onMouseLeave:()=>{i(!1)},children:t(`conversation.hero.brand.mark`,{size:34,className:ZA.fish},{fallback:/* @__PURE__ */ (0,h.jsx)(ej,{hovering:r})})}),/* @__PURE__ */ (0,h.jsxs)(`span`,{className:ZA.titleGroup,children:[/* @__PURE__ */ (0,h.jsx)(`span`,{children:e(`hero.headline`)}),/* @__PURE__ */ (0,h.jsxs)(`span`,{className:ZA.previewBadge,children:[/* @__PURE__ */ (0,h.jsx)(`span`,{className:ZA.previewBadgeWeb,children:e(`hero.preview`)}),/* @__PURE__ */ (0,h.jsx)(`span`,{className:ZA.previewBadgeDesktop,children:e(`hero.previewDesktop`)})]})]})]}),/* @__PURE__ */ (0,h.jsx)(`div`,{className:ZA.body})]}),n]})}let nj=`@deepseek-ai/dsh-client-ui-conversation/ThreadReferenceDropTarget.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(nj)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-conversation`,e.dataset.pluginCss=nj,e.textContent=`.tWXKHq_overlay{z-index:30;pointer-events:none;background:color-mix(in srgb, var(--dsw-alias-state-business-tertiary) 88%, transparent);place-items:center;display:grid;position:absolute;inset:0}.tWXKHq_invitation{flex-direction:column;align-items:center;gap:8px;max-width:calc(100% - 40px);display:flex}.tWXKHq_hint{border:1px solid color-mix(in srgb, var(--dsw-alias-state-business-primary) 15%, transparent);background:var(--dsw-alias-state-business-tertiary);color:var(--dsw-alias-label-primary);border-radius:10px;padding:8px 16px;font-size:16px;line-height:24px;box-shadow:0 1px 4px #00000014}.tWXKHq_preview{box-sizing:border-box;border:1px solid var(--dsw-alias-border-l3);background:var(--dsw-alias-bg-base);max-width:min(440px,100%);color:var(--dsw-alias-label-primary);border-radius:12px;align-items:center;gap:10px;padding:10px 14px;font-size:14px;line-height:20px;display:flex;box-shadow:0 4px 14px #00000014}.tWXKHq_preview svg{flex:none}.tWXKHq_title{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}`,document.head.appendChild(e)}var rj={hint:`tWXKHq_hint`,invitation:`tWXKHq_invitation`,overlay:`tWXKHq_overlay`,preview:`tWXKHq_preview`,title:`tWXKHq_title`};function ij({container:e,editor:t,useSessions:n,t:r}){let i=n(e=>e.byId),a=(0,g.useRef)(i);a.current=i;let[o,s]=(0,g.useState)(null);return(0,g.useEffect)(()=>{if(e===null||t===void 0)return;let n,r=()=>{n=void 0,s(null)},i=()=>t.isEditable()&&t.getRootElement()!==null,o=e=>{let t=e.dataTransfer;return t?.types.includes(`application/x-codexhost-thread-reference`)&&!t.types.includes(`Files`)?t:null},c=e=>{let t=e===void 0?void 0:fC(dC(e)),n=t===void 0?void 0:a.current[t];return n!==void 0&&uC(n)!==void 0},l=t=>!(t instanceof Node)||!e.contains(t)?!1:(t instanceof Element?t:t.parentElement)?.closest(`[data-conversation-content]`)===e,u=e=>{r();let t=o(e),i=t===null?void 0:mC(t.getData(cC));c(i)&&(n=i)},d=e=>{let r=o(e);r===null||!l(e.target)?s(null):!i()||!c(n)?(e.preventDefault(),e.stopPropagation(),r.dropEffect=`none`,s(null)):t.dispatchCommand(sm,e)&&s(n??null)},f=t=>{if(t.relatedTarget instanceof Node&&e.contains(t.relatedTarget))return;let n=e.getBoundingClientRect();(t.relatedTarget!==null||t.target===e||t.clientX<=n.left||t.clientX>=n.right||t.clientY<=n.top||t.clientY>=n.bottom)&&s(null)},p=e=>{let a=o(e);if(a!==null&&l(e.target)){let r=mC(a.getData(cC));i()&&c(r)&&r?.threadId===n?.threadId&&r?.hostId===n?.hostId?t.dispatchCommand(am,e):(e.preventDefault(),e.stopPropagation(),a.dropEffect=`none`)}r()},m=e=>{e.key===`Escape`&&r()},h=t.registerEditableListener(e=>{e||r()});return document.addEventListener(`dragstart`,u),document.addEventListener(`dragenter`,d,!0),document.addEventListener(`dragover`,d,!0),document.addEventListener(`dragleave`,f,!0),document.addEventListener(`drop`,p,!0),window.addEventListener(`dragend`,r),window.addEventListener(`blur`,r),window.addEventListener(`keydown`,m,!0),()=>{h(),document.removeEventListener(`dragstart`,u),document.removeEventListener(`dragenter`,d,!0),document.removeEventListener(`dragover`,d,!0),document.removeEventListener(`dragleave`,f,!0),document.removeEventListener(`drop`,p,!0),window.removeEventListener(`dragend`,r),window.removeEventListener(`blur`,r),window.removeEventListener(`keydown`,m,!0)}},[e,t]),o===null?null:/* @__PURE__ */ (0,h.jsx)(`div`,{className:rj.overlay,"data-thread-reference-drop":!0,role:`status`,"aria-live":`polite`,children:/* @__PURE__ */ (0,h.jsxs)(`div`,{className:rj.invitation,children:[/* @__PURE__ */ (0,h.jsx)(`div`,{className:rj.hint,children:r(`reference.dropTitle`)}),/* @__PURE__ */ (0,h.jsxs)(`div`,{className:rj.preview,"data-thread-reference-preview":!0,children:[/* @__PURE__ */ (0,h.jsx)(d.ReferenceIconRegular,{kind:`session`,size:20}),/* @__PURE__ */ (0,h.jsx)(`span`,{className:rj.title,children:o.title})]})]})})}let aj=`data-selection-drag`,oj=[`pointerup`,`pointercancel`,`dragstart`,`contextmenu`];function sj(e){let t=e.ownerDocument.defaultView;if(t===null)return()=>{};let n=()=>{e.removeAttribute(aj);for(let e of oj)t.removeEventListener(e,n,!0);t.removeEventListener(`blur`,n)},r=r=>{if(r.pointerType!==`mouse`||r.button!==0)return;let i=r.target instanceof Element?r.target:null;if(i!==null&&i.closest(`[data-composer-seat]`)===null){e.setAttribute(aj,``);for(let e of oj)t.addEventListener(e,n,!0);t.addEventListener(`blur`,n)}};return e.addEventListener(`pointerdown`,r,!0),()=>{e.removeEventListener(`pointerdown`,r,!0),n()}}function cj({renderSlot:e}){return e(`conversation.session`,{})}function lj({session:e,useInput:t,renderSlot:n}){let r=t(e=>e);return e===void 0||r===void 0?null:n(`conversation.input.dock`,{session:e,input:r})}function uj(){return null}function dj(e){let{sessionId:t,phase:n,hero:r,useSession:i,useSessions:a,useSessionStatus:o,useWorkspaces:s,useInput:c,useComposerBlock:l,useSessionCreation:u,renderSlot:d,renderSlotChain:f,selectWorkspace:p,retrySessionCreation:m,referenceEditor:_,t:v,useFactorySlot:y}=e,b=i(e=>e),ee=y(`views`,cj),te=y(`widthControls`,uj),[ne,re]=(0,g.useState)(null),ie=o(e=>t===void 0?void 0:e.get(t)?.pendingInteraction),ae=a(e=>t===void 0?void 0:e.byId[t]?.cwd),oe=s(e=>e),se=l(e=>e),ce=u(e=>e),le=t===void 0&&ce.state!==`idle`?ce.workspaceId:void 0,[ue,de]=(0,g.useState)(!1),[fe,pe]=(0,g.useState)(),me=(0,g.useRef)(null),x=(0,g.useRef)(null),S=(0,g.useCallback)(e=>{x.current?.disconnect(),x.current=null;let t=e?.parentElement??null;e!==null&&t!==null&&(x.current=new ResizeObserver(()=>{t.style.setProperty(`--dsh-composer-height`,`${e.offsetHeight}px`),t.style.setProperty(`--dsh-conversation-viewport-height`,`${t.clientHeight}px`)}),x.current.observe(e),x.current.observe(t))},[]);(0,g.useEffect)(()=>{let e=ne?.querySelector(`:scope > [data-conversation-scroll]`);return e==null?void 0:sj(e)},[ne]);let he=t===void 0?void 0:oe.items.find(e=>e.sessionIds.includes(t)),ge=fe?fe.id:le,_e=oe.items.find(e=>e.workspaceId===ge),ve=(ge===null?void 0:_e?.title)??(ge===null||t===void 0?void 0:he?.title??(oe.phase===`ready`||ae===void 0||ae===``?void 0:QA(ae))),ye=ve===void 0?void 0:YA(ve,v(`workspace.defaultName`)),be=/* @__PURE__ */ (0,h.jsxs)(`div`,{className:Q.heroTopBarInner,children:[d(`conversation.hero.workspace`,{open:ue,anchorRef:me,selectedId:ge===null?void 0:ge??he?.workspaceId,fallbackLabel:ye,onOpenChange:de,onPick:e=>{de(!1);let t={id:e};pe(t);let n=()=>pe(e=>e===t?void 0:e);p(e).then(n,n)},onClose:()=>{de(!1)}},{fallback:/* @__PURE__ */ (0,h.jsx)($A,{buttonRef:me,label:ye??(oe.canStartProjectless?v(`hero.noWorkspace`):void 0),projectless:oe.canStartProjectless===!0&&ye===void 0,menuOpen:ue,onClick:()=>{de(e=>!e)},t:v})}),/* @__PURE__ */ (0,h.jsx)(`div`,{className:Q.heroAgentPresetSeat,children:d(`conversation.hero.agentPreset`,{})})]}),xe=oe.phase===`ready`&&!oe.canStartProjectless&&ye===void 0,Se=t===void 0&&ce.state!==`idle`,Ce=t!==void 0&&r&&b?.openState===`loading`&&!xe,we=r&&fe!==void 0,Te=!we&&t!==void 0&&b?.openState===`error`,Ee=Te&&b?.openError?.code===`remote/unsupported`,De=we||!Te&&(t===void 0||b?.openState!==`open`)&&!xe,Oe=we||t===void 0||b?.openState!==`open`||r&&xe,ke=!Oe&&se!==void 0,Ae=d(`conversation.composer.bar`,{variant:r?`hero`:`composer`,...r?{topBar:be}:{},...Se?{sessionCreation:ce,onRetrySessionCreation:m,placeholder:v(`placeholder.hero`)}:Ce?{disabled:!0,preparingDraft:!0,placeholder:v(`placeholder.hero`)}:Oe?Te?{disabled:!0,placeholder:v(Ee?`placeholder.loadUnsupported`:`placeholder.loadFailed`)}:{disabled:!0,placeholder:v(De?`placeholder.preparing`:`placeholder.workspace`),...De?{}:{workspacePickerOpen:ue,onRequestWorkspace:()=>{de(!0)}}}:ke?{blocked:se,placeholder:se.reason}:r?{placeholder:v(`placeholder.hero`)}:{}}),je=/* @__PURE__ */ (0,h.jsxs)(`div`,{className:gC(Q.composerStack,r&&Q.composerHero),children:[r&&/* @__PURE__ */ (0,h.jsx)(tj,{t:v,renderSlot:d}),/* @__PURE__ */ (0,h.jsx)(lj,{session:b,useInput:c,renderSlot:d}),Ae]}),Me=f(`conversation.composer`,{sessionId:t,session:b,pendingInteraction:b?.openState===`open`?ie:void 0},{fallback:je,fallbackOnly:t===void 0,overlay:!0}),Ne=/* @__PURE__ */ (0,h.jsx)(`div`,{ref:S,className:Q.composerSeat,"data-composer-seat":``,"data-conversation-region":`composer`,children:Me});return/* @__PURE__ */ (0,h.jsxs)(`div`,{ref:re,className:gC(Q.body,e.variant===`embedded`&&Q.embeddedBody),"data-conversation-content":``,"data-conversation-session":t,"data-conversation-region":`chat`,"data-content-phase":n,children:[/* @__PURE__ */ (0,h.jsxs)(`div`,{className:Q.scrollBody,"data-conversation-scroll":``,children:[t===void 0?null:/* @__PURE__ */ (0,h.jsx)(ee,{}),Ne]}),/* @__PURE__ */ (0,h.jsx)(te,{container:ne,phase:n}),/* @__PURE__ */ (0,h.jsx)(ij,{container:ne,editor:_,useSessions:a,t:v},t)]})}function fj({renderSlot:e}){return e(`main.conversation`,{})}function pj(){let e=()=>{let e=document.querySelector(`[data-conversation-navigation-focus]`),t=e?.querySelector(`[data-navigation-focus-return]`);(t!=null&&t.getClientRects().length>0?t:e)?.focus({preventScroll:!0})};e(),requestAnimationFrame(()=>{document.activeElement===document.body&&e()})}function mj({sessionId:e,useSession:t,useConversation:n,renderSlot:r}){let i=t(e=>e),a=n(e=>e),o=i===void 0||a===void 0||i.blank&&RA(i,a)===`blank`;return/* @__PURE__ */ (0,h.jsxs)(`header`,{className:gC(Q.header,o&&Q.headerBlank,e===void 0&&Q.headerSessionless),"data-window-drag":!0,"data-conversation-navigation-focus":!0,"data-cx-region":`topbar`,tabIndex:-1,children:[/* @__PURE__ */ (0,h.jsx)(`div`,{className:Q.headerLeading,"data-conversation-header-leading":``,children:r(`conversation.header.leading`,{})}),e===void 0?/* @__PURE__ */ (0,h.jsxs)(`div`,{className:Q.titleRow,children:[r(`conversation.header.navigation`,{restoreNavigationFocus:pj}),/* @__PURE__ */ (0,h.jsx)(`div`,{className:Q.headerCorner,"data-conversation-header-corner":``,children:/* @__PURE__ */ (0,h.jsx)(`span`,{className:Q.phoneTrailingAction,children:r(`conversation.header.trailing`,{})})})]}):r(`conversation.session.header`,{hideChrome:o,titleNavigation:r(`conversation.header.navigation`,{restoreNavigationFocus:pj}),trailingAction:r(`conversation.header.trailing`,{})}),r(`conversation.header.shortcuts`,{restoreNavigationFocus:pj})]})}function hj(e,t){return(t===null?void 0:e.find(e=>e.id===t))??e.find(e=>e.id===`chat`)}function gj({view:e,useSession:t,useConversation:n,useConversationViews:r,inputActions:i,useStore:a,actions:o,renderSlot:s,bindDraftPersistence:c,onRevealResponseAnnotation:l,openView:u,useInspectCall:d}){let f=r(e=>e),p=d(e=>e),m=hj(f,a(e=>e.view)),_=t(e=>e),v=n(e=>e),y=a(e=>e.viewRequest??null);if((0,g.useEffect)(()=>{let e=c(o.setDraft);return i.persistDraft(),()=>{e()}},[i]),(0,g.useEffect)(()=>l(e=>u(`chat`,e)),[l,u]),_.blank&&RA(_,v)===`blank`)return null;let b=e??m?.id;return/* @__PURE__ */ (0,h.jsx)(`div`,{className:Q.viewArea,children:b!==void 0&&s(`conversation.view`,{inspectCall:p,viewRequest:y,openView:u,completeViewRequest:o.completeViewRequest},{only:b})})}function _j(e){return e.projectionValues?.roleSnapshot??void 0}function vj(e){return e.projectionValues?.harnessIdentity?.name}function yj(e,t){let n=[],r=/* @__PURE__ */ new Set,i=t;for(;i!==void 0&&!r.has(i);){r.add(i);let t=e.byId[i];if(t===void 0||(n.unshift({id:t.id,displayTitle:t.displayTitle,subagent:t.origin===`subagent`,roleSnapshot:_j(t),harnessName:vj(t)}),t.origin!==`subagent`))break;i=t.parentId}return n}function bj(e,t){return e.length===t.length&&e.every((e,n)=>{let r=t.at(n);return r!==void 0&&e.id===r.id&&e.displayTitle===r.displayTitle&&e.harnessName===r.harnessName&&e.roleSnapshot?.slug===r.roleSnapshot?.slug&&e.roleSnapshot?.avatar===r.roleSnapshot?.avatar&&e.roleSnapshot?.accentColor===r.roleSnapshot?.accentColor&&e.roleSnapshot?.name===r.roleSnapshot?.name})}function xj({sessionId:e,hideChrome:t,titleNavigation:n,trailingAction:r,useSessions:i,useConversationViews:a,useStore:o,renderSlot:s,open:c,selectView:l,t:u}){let f=a(e=>e),p=hj(f,o(e=>e.view)),m=i(t=>yj(t,e),bj);(0,g.useSyncExternalStore)(d.subscribeRoleAvatars,d.roleAvatarsVersion);let _=!t&&f.length>1;return/* @__PURE__ */ (0,h.jsxs)(h.Fragment,{children:[/* @__PURE__ */ (0,h.jsxs)(`div`,{className:Q.titleRow,children:[!t&&/* @__PURE__ */ (0,h.jsxs)(h.Fragment,{children:[/* @__PURE__ */ (0,h.jsxs)(`div`,{className:Q.titleCluster,children:[/* @__PURE__ */ (0,h.jsxs)(`div`,{className:Q.titleCenter,onClick:e=>{if(e.target?.closest(`button, a, input, [role='button']`))return;let t=e.currentTarget.querySelector(`[data-navigation-focus-return]`);t!==null&&t.getClientRects().length>0&&t.click()},children:[/* @__PURE__ */ (0,h.jsxs)(`nav`,{className:Q.crumbs,"aria-label":u(`session.hierarchy`),children:[m.map((e,t)=>{let n=t===m.length-1,r=e.roleSnapshot===void 0?void 0:(0,d.knownRoleAvatar)(e.roleSnapshot.slug)??e.roleSnapshot,i=r===void 0?void 0:e.harnessName?`${r.name} · ${e.harnessName}`:r.name,a=r===void 0?null:/* @__PURE__ */ (0,h.jsx)(d.RoleAvatar,{avatar:r.avatar,accentColor:r.accentColor,size:24,title:i,label:i,className:Q.crumbRoleAvatar}),o=n?/* @__PURE__ */ (0,h.jsx)(`span`,{className:gC(Q.crumb,e.subagent&&Q.crumbSubagent,Q.crumbCurrent),children:e.displayTitle}):/* @__PURE__ */ (0,h.jsx)(`button`,{type:`button`,className:gC(Q.crumb,e.subagent&&Q.crumbSubagent),onClick:()=>{c(e.id)},children:e.displayTitle}),l=n||e.subagent,u={lineageSessionId:e.id,displayTitle:e.displayTitle,...n?{}:{openTitle:()=>{c(e.id)}}};return/* @__PURE__ */ (0,h.jsxs)(`span`,{className:Q.crumbSeg,children:[t>0&&/* @__PURE__ */ (0,h.jsx)(`span`,{className:Q.crumbSep,children:`/`}),a,l?e.subagent?s(`conversation.session.header.lineage`,u,{fallback:o}):/* @__PURE__ */ (0,h.jsxs)(h.Fragment,{children:[o,s(`conversation.session.header.lineage`,u,{fallback:null})]}):o]},e.id)}),m.length===0&&/* @__PURE__ */ (0,h.jsx)(`span`,{className:Q.crumbCurrent,children:e})]}),n]}),/* @__PURE__ */ (0,h.jsx)(`div`,{className:Q.headerActions,children:s(`conversation.session.header.actions`,{})})]}),/* @__PURE__ */ (0,h.jsx)(`div`,{className:Q.headerUtilities,children:s(`conversation.session.header.utilities`,{})})]}),t&&/* @__PURE__ */ (0,h.jsx)(`div`,{className:Q.titleCenter,children:n}),/* @__PURE__ */ (0,h.jsxs)(`div`,{className:Q.headerCorner,"data-conversation-header-corner":``,children:[/* @__PURE__ */ (0,h.jsx)(`span`,{className:Q.phoneTrailingAction,children:r}),s(`conversation.session.header.corner`,{})]})]}),_&&/* @__PURE__ */ (0,h.jsx)(`div`,{className:Q.tabs,role:`tablist`,"data-conversation-tabs":``,children:f.map(e=>/* @__PURE__ */ (0,h.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":e.id===p?.id,className:gC(Q.tab,e.id===p?.id&&Q.tabActive),onClick:()=>{l(e.id)},children:e.label},e.id))})]})}function Sj(e){return/* @__PURE__ */ (0,h.jsx)(gj,{...e})}function Cj({editor:e,editable:t,preserveFocus:n=!1,...r}){let i=(0,g.useRef)(null),a=(0,g.useRef)(n);return a.current=n,(0,g.useLayoutEffect)(()=>{let t=i.current;if(t!==null&&(!(0,d.shouldAutoFocusTextInput)()&&!a.current&&(t.ownerDocument.activeElement===t&&t.blur(),e?.setEditable(!1)),e!==null))return e.setRootElement(t),()=>{e.setRootElement(null)}},[e]),(0,g.useLayoutEffect)(()=>{e!==null&&e.setEditable(t)},[e,t]),/* @__PURE__ */ (0,h.jsx)(`div`,{ref:i,contentEditable:e!==null&&t,suppressContentEditableWarning:!0,role:`textbox`,"aria-multiline":`true`,"data-composer-input":!0,...r})}function wj({editor:e}){let[t,n]=g.useState(()=>e===null?{}:e.getDecorators());return g.useLayoutEffect(()=>{if(e!==null)return n(e.getDecorators()),e.registerDecoratorListener(e=>{n(e)})},[e]),e===null?null:/* @__PURE__ */ (0,h.jsx)(h.Fragment,{children:Object.entries(t).map(([t,n])=>{let r=e.getElementByKey(t);return r===null?null:(0,_.createPortal)(n,r,t)})})}function Tj({classNames:e,editor:t,scrollRef:n,editable:r,editorDisabled:i,preserveFocus:a=!1,phase:o,placeholderText:s,ariaLabel:c,workspaceTrigger:l,workspacePickerOpen:u,onWorkspaceKeyDown:d,hint:f,showPlaceholder:p}){return/* @__PURE__ */ (0,h.jsx)(`div`,{ref:n,className:e.scroll,"data-input-scroll":!0,children:/* @__PURE__ */ (0,h.jsxs)(`div`,{className:e.grow,children:[/* @__PURE__ */ (0,h.jsx)(Cj,{editor:l?null:t,editable:r,preserveFocus:a,className:gC(e.input,i&&e.inputDisabled),"data-phase":o,"aria-disabled":i||void 0,"data-placeholder":s,"aria-label":c,"aria-haspopup":l?`menu`:void 0,"aria-expanded":l?u:void 0,tabIndex:l?0:void 0,onKeyDown:l?d:void 0,style:f===null?void 0:{"--dsh-composer-hint":JSON.stringify(f)}}),p&&/* @__PURE__ */ (0,h.jsx)(`div`,{"aria-hidden":!0,className:e.placeholder,"data-composer-placeholder":!0,children:s}),/* @__PURE__ */ (0,h.jsx)(wj,{editor:l?null:t})]})})}function Ej(e,t){return e.isComposing||e.keyCode===229||t()}function Dj(e,t){let n=!1,r=0,i=null,a=()=>{i?.toggleAttribute(`data-composer-composing`,n||e.isComposing())},o=()=>{n=!0,a()},s=()=>{n=!1,r=Date.now()+10,e.update(()=>{},{onUpdate:a})},c=()=>n||Date.now()<r,l=e=>n=>{let r=n!==null&&Ej(n,c);return t.arbitrate(e,r)!==`pass`&&(n?.preventDefault(),!0)};return ux(e.registerRootListener((e,t)=>{t?.removeEventListener(`compositionstart`,o),t?.removeEventListener(`compositionend`,s),t?.removeAttribute(`data-composer-composing`),n=!1,r=0,i=e,e?.addEventListener(`compositionstart`,o),e?.addEventListener(`compositionend`,s),a()}),e.registerUpdateListener(a),e.registerCommand(Zp,l(`up`),4),e.registerCommand(Qp,l(`down`),4),e.registerCommand(qp,t=>e.getEditorState().read(()=>{let e=V();if(!B(e)||!e.isCollapsed())return!1;let t=e.anchor,n=t.getNode();if(!z(n))return!0;let r=n.getTextContent().charAt(t.offset);return r===``||/\s/u.test(r)})?l(`right`)(t):!1,4),e.registerCommand(Yp,t=>e.getEditorState().read(()=>{let e=V();return B(e)&&e.isCollapsed()})?l(`left`)(t):!1,4),e.registerCommand(im,e=>l(e.shiftKey?`tabBack`:`tab`)(e),4),e.registerCommand(nm,e=>(t.dismissPopup(),t.arbitrate(`escape`,Ej(e,c))===`consumed`&&(e.preventDefault(),!0)),4),e.registerCommand(em,e=>Ej(e,c)?!1:t.space()?(e.preventDefault(),!0):!1,4),e.registerCommand($p,e=>e!==null&&(e.altKey||e.getModifierState(`AltGraph`)||e.ctrlKey&&e.metaKey||e.shiftKey&&(e.ctrlKey||e.metaKey))?!0:e?.shiftKey===!0?!1:e!==null&&Ej(e,c)?!0:t.arbitrate(`enter`,!1)===`pass`?(0,d.hasCoarsePrimaryPointer)()&&e?.ctrlKey!==!0&&e?.metaKey!==!0?!1:(e?.preventDefault(),e?.repeat===!0||!t.canSubmit()||t.submit(e?.ctrlKey===!0||e?.metaKey===!0),!0):(e?.preventDefault(),!0),4),e.registerCommand(zp,e=>{let n=e.clipboardData??null;if(n===null)return!1;let r=[],i=/* @__PURE__ */ new Set;for(let e of n.items){if(e.kind!==`file`)continue;let t=e.getAsFile();t!==null&&(r.push(t),typeof e.webkitGetAsEntry==`function`&&e.webkitGetAsEntry()?.isDirectory===!0&&i.add(t))}r.length>0&&t.intakeFiles(r,i.size===0?void 0:i);let a=n.getData(`text/plain`);return a===``?r.length!==0&&(e.preventDefault(),!0):(e.preventDefault(),t.pasteText(a),!0)},4))}function Oj(e){let t=e.current;if(t===null||t.scrollHeight<=t.clientHeight)return;let n=window.getSelection();if(n===null||n.rangeCount===0)return;let r=n.getRangeAt(0).getBoundingClientRect();if(r.height===0&&r.width===0){let e=n.anchorNode,t=e instanceof HTMLElement?e:e?.parentElement;if(t==null)return;r=t.getBoundingClientRect()}let i=t.getBoundingClientRect();r.bottom>i.bottom?t.scrollTop+=r.bottom-i.bottom:r.top<i.top&&(t.scrollTop-=i.top-r.top)}function kj(e,t){e.getRootElement()?.focus({preventScroll:!0}),e.focus(()=>{t()})}function Aj(e){let t=e.getRootElement();if(t===null||e.isComposing())return;let n=t.ownerDocument;if(n.activeElement!==t&&!t.contains(n.activeElement))return;let r=n.defaultView?.getSelection();if(r==null)return;if(r.rangeCount>0){if(!r.isCollapsed)return;let e=r.getRangeAt(0).cloneRange();if(t.contains(e.startContainer)&&t.contains(e.endContainer)){r.removeAllRanges(),r.addRange(e);return}}let i=t.firstChild??t,a=n.createRange();a.setStart(i,0),a.collapse(!0),r.removeAllRanges(),r.addRange(a)}function jj(e){let t=e.current;if(t===null)return;let n=e=>{let n=t.closest(`[data-conversation-scroll]`);if(!(n instanceof HTMLElement)||e.deltaY===0)return;let r=t.scrollTop<=0,i=t.scrollTop+t.clientHeight>=t.scrollHeight-1;e.deltaY<0&&!r||e.deltaY>0&&!i||(e.preventDefault(),n.scrollTop+=e.deltaY)};return t.addEventListener(`wheel`,n,{passive:!1}),()=>{t.removeEventListener(`wheel`,n)}}function Mj(e,t,n){return e.bindFilePicker({available:()=>t.current.canAcceptDrop&&n.current!==null,open:()=>{n.current?.click()}})}function Nj(e,t,n){return Dj(e,{arbitrate:(e,r)=>e===`enter`&&n.current.primaryAction!==void 0?`pass`:t.arbitrate(e,r),space:()=>n.current.machineBusy||n.current.locked?!1:t.space(),dismissPopup:()=>{t.dismissPopup()},canSubmit:()=>!n.current.locked&&!n.current.machineBusy&&n.current.primaryAction?.disabled!==!0,submit:e=>{let r=n.current;r.uploadsFailed?r.showToast(r.t(`file.retryOrRemove`)):r.primaryAction===void 0?e&&r.canSteerQueue?t.steerQueue():t.submit(mA(r.busyEnter,r.running,e?`accelerated`:`enter`,r.steeringAvailable),`enter`):r.primaryAction.run()},intakeFiles:(e,t)=>{n.current.intakeFiles(e,t)},pasteText:e=>{!n.current.machineBusy&&n.current.canPasteText&&t.paste(e)}})}function Pj(e){let t=e.activeElement,n=e.defaultView?.HTMLTextAreaElement??globalThis.HTMLTextAreaElement;return n!==void 0&&t instanceof n&&t.closest(`[data-composer-annotations]`)!==null&&(t.blur(),!0)}function Fj(e){let t=e?.getRootElement()??null;if(t===null)return!1;let n=t.ownerDocument.activeElement;return n===null||!t.contains(n)?!1:(typeof n.blur==`function`?n.blur():t.blur(),!0)}function Ij(e,t){(0,d.shouldAutoFocusTextInput)()&&(e.preventDefault(),t?.getRootElement()?.focus({preventScroll:!0}))}function Lj(e){let t=e/1048576;return`${Number.isInteger(t)?String(t):t.toFixed(1)}MB`}function Rj(e,t,n){switch(t){case`MODEL_DOES_NOT_SUPPORT_IMAGES`:return e(`image.modelUnsupported`);case`FILE_NOT_STAGED`:return e(`file.notStaged`);case`FILE_UNAVAILABLE`:return e(`file.unavailable`);case`IMAGE_TOO_MANY_PIXELS`:return e(`image.tooManyPixels`);case`INVALID_IMAGE`:case`IMAGE_TYPE_MISMATCH`:return e(`image.unsupportedType`);case`TOO_MANY_IMAGES`:if(n!==void 0)return e(`image.tooMany`,{count:n.maxImagesPerMessage});break;case`IMAGE_TOO_LARGE`:if(n!==void 0)return e(`image.fileTooLarge`,{size:Lj(n.maxImageBytes)});break;case`IMAGES_TOO_LARGE`:if(n!==void 0)return e(`image.totalTooLarge`,{size:Lj(n.maxMessageImageBytes)})}return e(`image.sendFailed`,{reason:t})}function zj(e){let t=e?.projectedTokens??e?.pressureTokens;return t===void 0||e?.contextWindow===void 0?null:{percent:Math.min(100,Math.round(t/e.contextWindow*100)),usedTokens:t,contextWindow:e.contextWindow}}let Bj=`@deepseek-ai/dsh-client-ui-conversation/ContextMeter.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(Bj)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-conversation`,e.dataset.pluginCss=Bj,e.textContent=`.h1Hkra_root{flex:none;display:inline-flex}.h1Hkra_trigger{border-radius:var(--dsw-radius-sm);color:var(--dsw-alias-label-tertiary);font-family:inherit;font-size:var(--dsh-content-font-size-secondary,13px);font-variant-numeric:tabular-nums;line-height:calc(20px + var(--dsh-content-font-delta-secondary,0px));white-space:nowrap;cursor:pointer;background:0 0;border:none;flex:none;align-items:center;gap:6px;padding:1px 8px;display:inline-flex}.h1Hkra_trigger:hover,.h1Hkra_trigger[aria-expanded=true]{background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-label-secondary)}.h1Hkra_track{fill:none;stroke:var(--dsw-alias-border-l3);stroke-width:2px}.h1Hkra_fill{fill:none;stroke:var(--dsw-alias-label-tertiary);stroke-width:2px;stroke-linecap:round}.h1Hkra_panel{z-index:1100;box-sizing:border-box;border-radius:var(--dsw-radius-lg);background:var(--dsw-specific-menu);width:min(264px,100vw - 24px);backdrop-filter:var(--dsw-menu-backdrop-filter);--dsw-elevation-stroke-color:var(--dsw-alias-border-l1);box-shadow:var(--dsw-elevation-prominent);color:var(--dsw-alias-label-secondary);cursor:default;border:0;padding:12px;font-size:12px;line-height:20px;position:fixed}.h1Hkra_header{align-items:center;gap:6px;display:flex}.h1Hkra_figures{font-variant-numeric:tabular-nums;color:var(--dsw-alias-label-primary);margin-left:auto;font-weight:500}.h1Hkra_percent{color:var(--dsw-alias-label-primary);font-weight:500}.h1Hkra_headline{color:var(--dsw-alias-label-tertiary)}.h1Hkra_headline:empty{display:none}.h1Hkra_bar{corner-shape:round;background:var(--dsw-alias-interactive-bg-hover);border-radius:999px;gap:1px;height:4px;margin:10px 0 12px;display:flex;overflow:hidden}.h1Hkra_segment{background:var(--meter-tint,var(--dsw-alias-label-tertiary));border-radius:1px;flex:none;min-width:2px;height:100%}.h1Hkra_swatch{background:var(--meter-tint);vertical-align:baseline;border-radius:2px;width:8px;height:8px;margin-right:6px;display:inline-block}.h1Hkra_colorSystem{--meter-tint:var(--dsw-static-neutral-bluish-400)}.h1Hkra_colorTools{--meter-tint:#a78bfa}.h1Hkra_colorMessages{--meter-tint:var(--dsw-static-blue-450)}.h1Hkra_rows{margin:6px 0 0}.h1Hkra_row{justify-content:space-between;align-items:center;gap:12px;padding:2px 0;display:flex}.h1Hkra_row dt{color:var(--dsw-alias-label-secondary)}.h1Hkra_row dd{font-variant-numeric:tabular-nums;color:var(--dsw-alias-label-primary);margin:0}`,document.head.appendChild(e)}var Vj={bar:`h1Hkra_bar`,colorMessages:`h1Hkra_colorMessages`,colorSystem:`h1Hkra_colorSystem`,colorTools:`h1Hkra_colorTools`,figures:`h1Hkra_figures`,fill:`h1Hkra_fill`,header:`h1Hkra_header`,headline:`h1Hkra_headline`,panel:`h1Hkra_panel`,percent:`h1Hkra_percent`,root:`h1Hkra_root`,row:`h1Hkra_row`,rows:`h1Hkra_rows`,segment:`h1Hkra_segment`,swatch:`h1Hkra_swatch`,track:`h1Hkra_track`,trigger:`h1Hkra_trigger`};let Hj=5.5,Uj=2*Math.PI*Hj,Wj=[{key:`systemTokens`,label:`context.system`,color:Vj.colorSystem},{key:`toolsTokens`,label:`context.tools`,color:Vj.colorTools},{key:`messageTokens`,label:`context.messages`,color:Vj.colorMessages}];function Gj(e,t){let n=e=>String(e>=100?Math.round(e):Math.round(e*10)/10);return e<1e3?String(e):e<1e6?t(`number.thousand`,{value:n(e/1e3)}):t(`number.million`,{value:n(e/1e6)})}function Kj({useProjection:e,t}){let n=e(`contextPressure`),r=e(`contextBreakdown`),[i,a]=(0,g.useState)(!1),o=(0,g.useRef)(null),s=(0,g.useRef)(null),c=zj(n),l=c!==null,u=(0,d.useAnchoredPosition)({open:i&&l,anchorRef:o,panelRef:s,side:`top`,gap:8,margin:12});if((0,d.useDismissOnOutsidePointer)(o,i&&l,a,s),(0,g.useEffect)(()=>{!l&&i&&a(!1)},[l,i]),(0,g.useEffect)(()=>{if(!i||!l)return;let e=e=>{e.key===`Escape`&&a(!1)};return document.addEventListener(`keydown`,e),()=>{document.removeEventListener(`keydown`,e)}},[l,i]),c===null)return null;let f=c.percent,p=`${f}%`,[m=``,v=``]=t(`context.aria`,{percent:`\0`}).split(`\0`).map(e=>e.trim()),y=r===void 0?0:r.systemTokens+r.toolsTokens+r.messageTokens,b=(r===void 0||y===0?[{key:`total`,color:void 0,width:f}]:Wj.map(e=>({key:e.key,color:e.color,width:f*r[e.key]/y}))).filter(e=>e.width>0);return/* @__PURE__ */ (0,h.jsxs)(`span`,{ref:o,className:Vj.root,children:[/* @__PURE__ */ (0,h.jsx)(d.Tooltip,{label:t(`context.aria`,{percent:p}),side:`top`,delayMs:200,disabled:i,children:/* @__PURE__ */ (0,h.jsxs)(`button`,{type:`button`,className:Vj.trigger,"aria-label":t(`context.aria`,{percent:p}),"aria-haspopup":`dialog`,"aria-expanded":i,onClick:()=>{a(!i)},children:[/* @__PURE__ */ (0,h.jsxs)(`svg`,{viewBox:`0 0 14 14`,width:`14`,height:`14`,"aria-hidden":!0,children:[/* @__PURE__ */ (0,h.jsx)(`circle`,{className:Vj.track,cx:`7`,cy:`7`,r:Hj}),/* @__PURE__ */ (0,h.jsx)(`circle`,{className:Vj.fill,cx:`7`,cy:`7`,r:Hj,strokeDasharray:`${Uj*f/100} ${Uj}`,transform:`rotate(-90 7 7)`})]}),/* @__PURE__ */ (0,h.jsx)(`span`,{children:p})]})}),i&&(0,_.createPortal)(/* @__PURE__ */ (0,h.jsxs)(`div`,{ref:s,className:Vj.panel,style:u??{visibility:`hidden`,left:0,top:0},role:`dialog`,"aria-label":t(`context.used`),children:[/* @__PURE__ */ (0,h.jsxs)(`div`,{className:Vj.header,children:[/* @__PURE__ */ (0,h.jsx)(`span`,{className:Vj.headline,children:m}),/* @__PURE__ */ (0,h.jsx)(`span`,{className:Vj.percent,children:p}),/* @__PURE__ */ (0,h.jsx)(`span`,{className:Vj.headline,children:v}),/* @__PURE__ */ (0,h.jsx)(`span`,{className:Vj.figures,children:`~${Gj(c.usedTokens,t)} / ${Gj(c.contextWindow,t)}`})]}),/* @__PURE__ */ (0,h.jsx)(`div`,{className:Vj.bar,children:b.map(e=>/* @__PURE__ */ (0,h.jsx)(`div`,{className:e.color===void 0?Vj.segment:`${Vj.segment} ${e.color}`,style:{width:`${e.width}%`}},e.key))}),r!==void 0&&/* @__PURE__ */ (0,h.jsx)(`dl`,{className:Vj.rows,children:Wj.map(e=>/* @__PURE__ */ (0,h.jsxs)(`div`,{className:Vj.row,children:[/* @__PURE__ */ (0,h.jsxs)(`dt`,{children:[/* @__PURE__ */ (0,h.jsx)(`span`,{className:`${Vj.swatch} ${e.color}`,"aria-hidden":!0}),t(e.label)]}),/* @__PURE__ */ (0,h.jsx)(`dd`,{children:`~${Gj(r[e.key],t)}`})]},e.key))})]}),document.body)]})}function qj(e,t){let n=e.querySelector(`[data-toolbar-scroll]`);if(n===null)return()=>{};let r=e.querySelector(`[data-toolbar-fixed="start"]`),i=e.querySelector(`[data-toolbar-fixed="end"]`),a={phone:!1,overflowActions:!1},o=!1,s=/* @__PURE__ */ new Set,c=()=>{if(!a.phone||e.hasAttribute(`data-toolbar-activity`))return;let t=e.ownerDocument.activeElement;if(!(t instanceof HTMLElement)||!e.contains(t)||t.closest(`[data-toolbar-fixed]`))return;let{left:r,right:i}=n.getBoundingClientRect(),o=t.getBoundingClientRect();o.left<r?n.scrollLeft+=o.left-r:o.right>i&&(n.scrollLeft+=Math.min(o.right-i,o.left-r))},l=()=>{if(o)return;let s=e.closest(`[data-phone]`)!==null;if(e.toggleAttribute(`data-phone-toolbar`,s),e.hasAttribute(`data-toolbar-activity`)){s!==a.phone&&(a={...a,phone:s},t?.(a));return}let l=e.hasAttribute(`data-actions-overflow`);if(e.removeAttribute(`data-model-compact`),e.removeAttribute(`data-actions-overflow`),e.toggleAttribute(`data-toolbar-measuring`,s),s)for(let[t,n]of[[`start`,r],[`end`,i]]){if(n===null)continue;let r=`--dsh-composer-${t}-width`,i=`${n.getBoundingClientRect().width}px`;e.style.getPropertyValue(r)!==i&&e.style.setProperty(r,i)}let u=getComputedStyle(e),d=e.getBoundingClientRect().width-parseFloat(u.paddingLeft)-parseFloat(u.paddingRight),f=s?(()=>{let t=e=>Array.from(e.children).flatMap(e=>{let r=getComputedStyle(e).display;return r===`none`?[]:e===n||r===`contents`?t(e):[e]}),r=t(e);return r.reduce((e,t)=>{let n=getComputedStyle(t);return e+t.getBoundingClientRect().width+(parseFloat(n.marginLeft)||0)+(parseFloat(n.marginRight)||0)},0)+Math.max(0,r.length-1)*(parseFloat(u.columnGap)||0)})():(()=>{let e=Array.from(n.children,e=>e.getBoundingClientRect().width).filter(e=>e>0);return e.reduce((e,t)=>e+t,0)+Math.max(0,e.length-1)*parseFloat(u.columnGap)})();e.toggleAttribute(`data-model-compact`,!s&&f>d);let p=e.querySelector(`[data-composer-overflow-action]`),m=e.querySelector(`[data-toolbar-fixed="start"] button`),h=s&&p!==null&&m?.disabled===!1&&f>d-(l?2:0),g=e.hasAttribute(`data-command-menu-open`)||p!==null&&p.contains(e.ownerDocument.activeElement)?l:h;e.removeAttribute(`data-toolbar-measuring`),e.toggleAttribute(`data-actions-overflow`,g),(s!==a.phone||g!==a.overflowActions)&&(a={phone:s,overflowActions:g},t?.(a)),(!s||n.scrollWidth<=n.clientWidth)&&(n.scrollLeft=0),c()},u=new ResizeObserver(l),d=()=>{let t=/* @__PURE__ */ new Set([e,...e.querySelectorAll(`*`)]);for(let e of s)t.has(e)||(u.unobserve(e),s.delete(e));for(let e of t)s.has(e)||(u.observe(e),s.add(e))},f=new MutationObserver(()=>{d(),l()});f.observe(e,{subtree:!0,childList:!0,characterData:!0,attributes:!0,attributeFilter:[`hidden`,`class`,`style`,`aria-label`,`aria-busy`,`disabled`,`data-command-menu-open`,`data-toolbar-activity`]});let p=new MutationObserver(l);for(let t=e.parentElement;t!==null;t=t.parentElement)p.observe(t,{attributes:!0,attributeFilter:t===e.ownerDocument.body||t===e.ownerDocument.documentElement?[`data-phone`,`class`,`style`,`lang`,`dir`]:[`data-phone`,`lang`,`dir`]});let m=()=>{queueMicrotask(()=>{o||l()})};e.addEventListener(`focusin`,c),e.addEventListener(`focusout`,m);let h=document.fonts;return h.addEventListener(`loadingdone`,l),d(),l(),()=>{o=!0,u.disconnect(),f.disconnect(),p.disconnect(),e.removeEventListener(`focusin`,c),e.removeEventListener(`focusout`,m),h.removeEventListener(`loadingdone`,l)}}let Jj=`@deepseek-ai/dsh-client-ui-conversation/InputBar.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(Jj)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-conversation`,e.dataset.pluginCss=Jj,e.textContent=`.SFO4UW_root{padding:0 var(--dsh-composer-side-clearance) 4px;flex-direction:column;align-items:center;display:flex}[data-phone] .SFO4UW_root{padding-bottom:max(4px, calc(env(safe-area-inset-bottom) - 23px))}.SFO4UW_dock{-webkit-user-select:none;user-select:none;justify-content:center;align-items:center;gap:12px;max-width:100%;padding-top:4px;display:flex}.SFO4UW_hero .SFO4UW_dock:empty{display:none}.SFO4UW_hero{padding:0 var(--dsh-composer-side-clearance)}.SFO4UW_notice{width:100%;max-width:var(--dsh-composer-card-max-width);border-radius:var(--dsw-radius-md);background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-label-secondary);-webkit-user-select:text;user-select:text;margin-bottom:6px;padding:4px 8px;font-size:12px;line-height:18px}.SFO4UW_cardStack{width:100%;max-width:var(--dsh-composer-card-max-width);flex-direction:column;display:flex;position:relative}.SFO4UW_topRail{z-index:0;box-sizing:border-box;margin-inline:16px;background:color-mix(in srgb, var(--dsw-alias-label-primary) 5%, var(--dsw-alias-bg-base));-webkit-user-select:none;user-select:none;border:0;border-radius:16px 16px 0 0;align-items:center;margin-bottom:-16px;padding:5px 10px 21px;display:flex;position:relative}.SFO4UW_card{box-sizing:border-box;z-index:1;width:100%;max-width:var(--dsh-composer-card-max-width);--dsw-elevation-stroke-color:var(--dsw-alias-border-l2);border-radius:var(--dsw-radius-panel);background:var(--dsw-specific-input-major);box-shadow:var(--dsw-elevation-soft);font-size:var(--dsh-content-font-size,14px);line-height:calc(24px + var(--dsh-content-font-delta,0px));--dsh-scrollbar-thumb:var(--dsw-alias-scrollbar-bg-l2);--dsh-scrollbar-thumb-hover:var(--dsw-alias-scrollbar-hover-l2);border:0;flex-direction:column;gap:12px;padding-top:8px;display:flex;position:relative}@supports (backdrop-filter:blur(14px)){body[data-codexhost-wallpaper] .SFO4UW_card,[data-phone] .SFO4UW_card{box-shadow:none;background:0 0}body[data-codexhost-wallpaper] .SFO4UW_card:before,[data-phone] .SFO4UW_card:before{content:"";z-index:-1;border-radius:inherit;background:color-mix(in srgb, var(--dsw-specific-input-major) 60%, transparent);backdrop-filter:blur(16px);box-shadow:inset 0 1px 0 color-mix(in srgb, var(--dsw-alias-bg-layer-3) 65%, transparent), var(--dsw-elevation-soft), 0 8px 24px -12px var(--dsw-alias-bg-mask-2);pointer-events:none;position:absolute;inset:0}body:not([data-codexhost-wallpaper]) [data-phone] .SFO4UW_card:before{background:color-mix(in srgb, var(--dsw-specific-input-major) 24%, transparent);backdrop-filter:blur(14px)}}@media (prefers-reduced-transparency:reduce),(prefers-contrast:more),(forced-colors:active){body[data-codexhost-wallpaper] .SFO4UW_card,[data-phone] .SFO4UW_card{background:var(--dsw-specific-input-major);box-shadow:var(--dsw-elevation-soft)}body[data-codexhost-wallpaper] .SFO4UW_card:before,[data-phone] .SFO4UW_card:before{display:none}}@media (prefers-contrast:more),(forced-colors:active){[data-phone] .SFO4UW_card:not(.SFO4UW_cardWorkspaceTrigger){outline:1px solid var(--dsw-alias-label-primary);outline-offset:-1px}}.SFO4UW_cardWorkspaceTrigger{--dsw-elevation-stroke-color:transparent;cursor:pointer}.SFO4UW_cardWorkspaceTrigger:after{content:"";box-sizing:border-box;border-radius:var(--dsw-radius-panel);color:var(--dsw-alias-border-l4);pointer-events:none;border:1px dashed;transition:color .1s;position:absolute;inset:0}.SFO4UW_cardWorkspaceTrigger :disabled{pointer-events:none}.SFO4UW_cardWorkspaceTrigger:hover:after{color:var(--dsw-alias-state-business-primary)}.SFO4UW_inlineNotices{-webkit-user-select:text;user-select:text;flex-direction:column;gap:8px;display:flex}.SFO4UW_inlineNotices>[data-slot]>*{margin:10px 10px 0}.SFO4UW_accessory{align-items:center;gap:8px;padding:10px 12px 0;display:flex}.SFO4UW_overlayAnchor{height:0;position:absolute;inset:0 0 auto}.SFO4UW_scroll{max-height:var(--dsh-composer-text-max-height);margin-right:4px;overflow-y:auto}.SFO4UW_scroll::-webkit-scrollbar-track{margin-top:8px}.SFO4UW_grow{position:relative}.SFO4UW_pending{corner-shape:round;background:var(--dsw-alias-state-business-primary);border-radius:50%;width:8px;height:8px;animation:1s ease-in-out infinite alternate SFO4UW_input-pending}@keyframes SFO4UW_input-pending{0%{opacity:.35}to{opacity:1}}.SFO4UW_input{box-sizing:border-box;min-height:36px;font-family:var(--dsw-font-family);font-size:inherit;line-height:inherit;white-space:pre-wrap;word-break:break-word;overflow-wrap:anywhere;color:var(--dsw-alias-label-primary);caret-color:var(--dsw-alias-state-business-primary);-webkit-user-select:text;user-select:text;outline:none;padding:4px 8px 0 14px}.SFO4UW_input p{margin:0}.SFO4UW_input p:last-child:after{content:var(--dsh-composer-hint);color:var(--dsw-alias-label-caption)}.SFO4UW_input[data-composer-composing] p:last-child:after{content:none}.SFO4UW_input[data-composer-composing]+.SFO4UW_placeholder{visibility:hidden}.SFO4UW_placeholder{color:var(--dsw-alias-label-caption);white-space:nowrap;text-overflow:ellipsis;pointer-events:none;-webkit-user-select:none;user-select:none;position:absolute;inset:4px 8px auto 14px;overflow:hidden}.SFO4UW_inputDisabled{color:var(--dsw-alias-label-tertiary);cursor:not-allowed}.SFO4UW_input[aria-haspopup=menu]{cursor:pointer}.SFO4UW_hero .SFO4UW_input{min-height:52px}.SFO4UW_hero .SFO4UW_placeholder{white-space:normal;-webkit-line-clamp:2;line-clamp:2;-webkit-box-orient:vertical;display:-webkit-box}@media (width<=600px){.SFO4UW_hero .SFO4UW_input{min-height:36px}.SFO4UW_hero .SFO4UW_placeholder{white-space:nowrap;display:block}}.SFO4UW_row{-webkit-user-select:none;user-select:none;flex-wrap:wrap;justify-content:space-between;align-items:center;gap:12px;min-width:0;padding:2px 8px 6px;display:flex;container-type:inline-size}.SFO4UW_row[data-model-compact]{--dsh-composer-model-text-display:none;--dsh-composer-model-icon-display:block}.SFO4UW_tools,.SFO4UW_modes,.SFO4UW_trailing{align-items:center;min-width:0;display:flex}.SFO4UW_tools,.SFO4UW_modes{gap:12px}.SFO4UW_trailing{flex:none;gap:12px;margin-left:auto}@container (width<=560px){.SFO4UW_tools,.SFO4UW_modes,.SFO4UW_trailing{gap:8px}}.SFO4UW_add{corner-shape:round;background:var(--dsw-specific-selector);width:28px;height:28px;color:var(--dsw-alias-label-primary);cursor:pointer;border:none;border-radius:999px;flex:none;place-items:center;display:grid}.SFO4UW_add:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-hover-solid)}.SFO4UW_add:disabled{opacity:.5;cursor:default}.SFO4UW_select{border-radius:var(--dsw-radius-sm);max-width:220px;height:28px;color:var(--dsw-alias-label-secondary);white-space:nowrap;cursor:pointer;appearance:none;background-color:#0000;background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12' fill='none'%3E%3Cpath d='M3 4.5L6 7.5L9 4.5' stroke='%2381858C' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");background-position:right 4px center;background-repeat:no-repeat;background-size:12px 12px;border:none;outline:none;padding:0 20px 0 8px;font-size:13px;font-weight:500;line-height:20px}.SFO4UW_select:hover:not(:disabled){background-color:var(--dsw-alias-interactive-bg-hover)}.SFO4UW_select:disabled{opacity:.5;cursor:default}.SFO4UW_primary{corner-shape:round;background:var(--dsw-alias-button-info-fill);color:#fff;cursor:pointer;border:none;border-radius:999px;flex:none;place-items:center;width:30px;height:30px;transition:background-color .1s;display:grid;transform:translateY(-2px)}.SFO4UW_primary:hover:not(:disabled){background:var(--dsw-alias-button-info-hover)}.SFO4UW_primary:disabled{opacity:.4;cursor:default}.SFO4UW_retry{border-radius:var(--dsw-radius-sm);color:inherit;cursor:pointer;background:0 0;border:1px solid;margin-left:8px;padding:1px 8px;font-size:12px}.SFO4UW_addSeat,.SFO4UW_submitSeat,.SFO4UW_controlScroll{display:contents}.SFO4UW_row[data-phone-toolbar]{flex-wrap:nowrap;gap:4px;position:relative}.SFO4UW_row[data-phone-toolbar] .SFO4UW_controlScroll{--dsh-composer-edge-gap:4px;align-items:center;gap:inherit;min-width:0;min-height:44px;margin-left:calc(var(--dsh-composer-start-width,44px) + var(--dsh-composer-edge-gap));margin-right:calc(var(--dsh-composer-end-width,44px) + var(--dsh-composer-edge-gap));overscroll-behavior-x:contain;scrollbar-width:none;flex:1;display:flex;overflow-x:auto}.SFO4UW_row[data-phone-toolbar] .SFO4UW_controlScroll::-webkit-scrollbar{display:none}.SFO4UW_row[data-phone-toolbar] .SFO4UW_tools:not([hidden]),.SFO4UW_row[data-phone-toolbar] .SFO4UW_trailing:not(.SFO4UW_trailingActive){display:contents}.SFO4UW_row[data-phone-toolbar] .SFO4UW_tools>*,.SFO4UW_row[data-phone-toolbar] [data-slot="conversation.input.left"]>*,.SFO4UW_row[data-phone-toolbar] [data-slot="conversation.input.right"]>*{flex-shrink:0}.SFO4UW_row[data-phone-toolbar] button:focus-visible{outline-offset:-2px}.SFO4UW_row[data-phone-toolbar] .SFO4UW_modes{flex:none;gap:4px;width:max-content}.SFO4UW_row[data-phone-toolbar] .SFO4UW_standardControls{flex:0 auto;gap:4px;min-width:0;margin-left:0}.SFO4UW_row[data-phone-toolbar][data-toolbar-measuring] .SFO4UW_standardControls{flex:none;width:max-content}.SFO4UW_row[data-phone-toolbar] .SFO4UW_addSeat,.SFO4UW_row[data-phone-toolbar] .SFO4UW_submitSeat{z-index:1;flex:none;align-items:center;gap:4px;display:flex;position:absolute;inset-block:2px 6px}.SFO4UW_row[data-phone-toolbar] .SFO4UW_addSeat{left:8px}.SFO4UW_row[data-phone-toolbar] .SFO4UW_submitSeat{margin-left:0;right:8px}.SFO4UW_row[data-phone-toolbar] .SFO4UW_add,.SFO4UW_row[data-phone-toolbar] .SFO4UW_primary{box-sizing:border-box;background-clip:padding-box;width:44px;height:44px}.SFO4UW_row[data-phone-toolbar] .SFO4UW_add{border:8px solid #0000}.SFO4UW_row[data-phone-toolbar] .SFO4UW_primary{border:7px solid #0000}.SFO4UW_row[data-phone-toolbar][data-toolbar-activity] .SFO4UW_controlScroll{display:contents}.SFO4UW_row[data-phone-toolbar][data-toolbar-activity] .SFO4UW_submitSeat{position:static}.SFO4UW_row[data-actions-overflow] [data-composer-overflow-action]{display:none}.SFO4UW_standardControls{align-items:center;gap:12px;min-width:0;display:flex}.SFO4UW_tools[hidden],.SFO4UW_standardControls[hidden]{display:none}.SFO4UW_trailingActive{flex:1;margin-left:0}.SFO4UW_activity{flex:none;align-items:center;display:flex}.SFO4UW_activity:empty{display:none}.SFO4UW_activityExpanded{flex:1;min-width:0}.SFO4UW_annotations{padding:8px 8px 2px}.SFO4UW_creationError{border-radius:var(--dsw-radius-md);background:var(--dsw-alias-interactive-bg-hover-danger);color:var(--dsw-alias-state-error-primary);align-items:center;gap:8px;margin:2px 10px 0;padding:8px 10px;font-size:13px;line-height:18px;display:flex}.SFO4UW_creationErrorIcon{flex:none}.SFO4UW_creationErrorCopy{overflow-wrap:anywhere;-webkit-user-select:text;user-select:text;flex-direction:column;flex:1;gap:2px;min-width:0;display:flex}.SFO4UW_creationErrorTitle{font-weight:500}.SFO4UW_creationErrorDetail{color:var(--dsw-alias-label-secondary);font-size:12px;line-height:17px}.SFO4UW_creationRetry{border-radius:var(--dsw-radius-sm);min-height:28px;color:var(--dsw-alias-state-error-primary);font:inherit;cursor:pointer;touch-action:manipulation;background:0 0;border:1px solid;flex:none;padding:4px 10px;font-size:12px;font-weight:500;line-height:16px}.SFO4UW_creationRetry:hover{background:color-mix(in srgb, currentColor 10%, transparent)}.SFO4UW_creationRetry:focus-visible{outline-offset:2px;outline:2px solid}.SFO4UW_pendingControls{align-items:center;gap:6px;min-width:0;display:inline-flex}.SFO4UW_pendingModel{border-radius:var(--dsw-radius-sm);min-width:0;max-width:min(220px,45cqw);height:28px;color:var(--dsw-alias-label-tertiary);white-space:nowrap;user-select:none;align-items:center;gap:6px;padding:0 8px;font-size:13px;line-height:20px;display:inline-flex}.SFO4UW_pendingModelLabel{text-overflow:ellipsis;min-width:0;overflow:hidden}.SFO4UW_pendingHarness{width:30px;height:28px;color:var(--dsw-alias-label-tertiary);opacity:.7;user-select:none;border-radius:6px;flex-shrink:0;justify-content:center;align-items:center;display:inline-flex}[data-phone] .SFO4UW_creationRetry{min-height:36px;padding:6px 12px}[data-phone] .SFO4UW_pendingModel{max-width:100%}[data-phone] .SFO4UW_pendingModelLabel{flex:0 auto;min-width:0;max-width:120px}[data-phone] .SFO4UW_pendingHarness{width:36px;height:36px}`,document.head.appendChild(e)}var $={accessory:`SFO4UW_accessory`,activity:`SFO4UW_activity`,activityExpanded:`SFO4UW_activityExpanded`,add:`SFO4UW_add`,addSeat:`SFO4UW_addSeat`,annotations:`SFO4UW_annotations`,card:`SFO4UW_card`,cardStack:`SFO4UW_cardStack`,cardWorkspaceTrigger:`SFO4UW_cardWorkspaceTrigger`,controlScroll:`SFO4UW_controlScroll`,creationError:`SFO4UW_creationError`,creationErrorCopy:`SFO4UW_creationErrorCopy`,creationErrorDetail:`SFO4UW_creationErrorDetail`,creationErrorIcon:`SFO4UW_creationErrorIcon`,creationErrorTitle:`SFO4UW_creationErrorTitle`,creationRetry:`SFO4UW_creationRetry`,dock:`SFO4UW_dock`,grow:`SFO4UW_grow`,hero:`SFO4UW_hero`,inlineNotices:`SFO4UW_inlineNotices`,input:`SFO4UW_input`,"input-pending":`SFO4UW_input-pending`,inputDisabled:`SFO4UW_inputDisabled`,modes:`SFO4UW_modes`,notice:`SFO4UW_notice`,overlayAnchor:`SFO4UW_overlayAnchor`,pending:`SFO4UW_pending`,pendingControls:`SFO4UW_pendingControls`,pendingHarness:`SFO4UW_pendingHarness`,pendingModel:`SFO4UW_pendingModel`,pendingModelLabel:`SFO4UW_pendingModelLabel`,placeholder:`SFO4UW_placeholder`,primary:`SFO4UW_primary`,retry:`SFO4UW_retry`,root:`SFO4UW_root`,row:`SFO4UW_row`,scroll:`SFO4UW_scroll`,select:`SFO4UW_select`,standardControls:`SFO4UW_standardControls`,submitSeat:`SFO4UW_submitSeat`,tools:`SFO4UW_tools`,topRail:`SFO4UW_topRail`,trailing:`SFO4UW_trailing`,trailingActive:`SFO4UW_trailingActive`};let Yj=[],Xj=(0,g.memo)(function({useSession:e,useInput:t,inputActions:n,keyboard:r,pendingDraft:i,addFiles:a,removeAttachment:o,resolveDraftAttachments:s,retryFileUpload:c,revealResponseAnnotation:l,toggleCommandMenu:u,stop:f,t:p,renderSlot:m,usePendingDraftText:_,useBusyEnter:v,useFileUploads:y,useNotices:b,useLexicon:ee,useMenuLauncher:te,useStopShortcut:ne,useProjection:re,sessionId:ie,variant:ae,disabled:oe=!1,preparingDraft:se=!1,sessionCreation:ce,onRetrySessionCreation:le,blocked:ue,workspacePickerOpen:de=!1,onRequestWorkspace:fe,placeholder:pe,topBar:me,accessory:x}){let S=t(e=>e),he=_(e=>e),ge=S?.responseAnnotations??Yj,_e=S?.hoveredResponseAnnotationId,ve=(0,g.useMemo)(()=>({regionAria:p(`annotation.rail`),count:e=>p(`annotation.trayCount`,{count:e}),clearAll:p(`annotation.clearAll`),emptyComment:p(`annotation.emptyComment`),editHint:e=>p(`annotation.editHint`,{index:e}),revealHint:e=>p(`annotation.revealHint`,{index:e}),remove:e=>p(`annotation.remove`,{index:e})}),[p]),ye=(0,g.useMemo)(()=>ge.map(e=>({id:e.id,text:e.text,...e.annotation===void 0?{}:{annotation:e.annotation},canReveal:e.anchor!==void 0})),[ge]),be=b(e=>e),xe=v(e=>e),Se=ne(e=>e),Ce=te(e=>e===`command`),[we,Te]=(0,g.useState)(!1);(0,g.useEffect)(()=>{Te(!1)},[ie]);let Ee=e(e=>e.promptError)??null,De=e(e=>e.running)??!1,Oe=e(e=>e.subagent)??null,ke=e(e=>e.removed)??!1,Ae=re(`plan`,e=>e!==void 0&&(e.pending?!e.active:e.active)),je=re(`codexPlanMode`),Me=re(`goal`,e=>e!=null),Ne=ie===void 0&&i!==void 0&&ce!==void 0&&ce.state!==`idle`,Pe=Ne&&ce.state===`creating`,Fe=Ne&&ce.state===`error`,Ie=Ne?ce.token:void 0,Le=S!==void 0&&r!==void 0&&n!==void 0,Re=Ne?he:S?.draft??``,ze=S?.primaryAction,C=Ne?i.editor:r?.editor??null,Be=(0,g.useMemo)(()=>S===void 0||s===void 0?[]:s(S.attachmentIds),[s,S?.attachmentIds]),Ve=Re.trim()===``&&Be.length===0&&ge.length===0,He=y(e=>e),Ue=Be.some(e=>He[e.id]?.status===`error`),[We,Ge]=(0,g.useState)(null),Ke=(0,g.useRef)(0),qe=(0,g.useCallback)(e=>{Ke.current+=1,Ge({seq:Ke.current,text:e})},[]),Je=(0,g.useCallback)(()=>{Ge(null)},[]),Ye=re(`imageLimits`),Xe=re(`attachmentInput`),Ze=re(`queueState`),Qe=Xe?.enabled!==!1,$e=Xe?.imagesOnly===!0;(0,g.useEffect)(()=>{if(Ee===null)return;let{error:e}=Ee;e.code===`session/writer-held`?qe(p(`error.sessionInUse`)):e.code===`remote/turn-changed`?qe(p(`error.steerTurnChanged`)):e.code===`remote/steer-unavailable`?qe(p(`error.remoteSteerUnavailable`)):qe(e.code===`session/attachment-invalid`||e.code===`subagent/attachment-invalid`?Rj(p,e.details.reason,Ye):`${e.message} (${e.code})`)},[Ee,qe,p,Ye]),(0,g.useEffect)(()=>{be?.level===`error`&&qe(be.text)},[be,qe]);let et=(0,g.useRef)(null),[tt,nt]=(0,g.useState)({phone:!1,overflowActions:!1});(0,g.useLayoutEffect)(()=>{let e=et.current;if(e!==null)return qj(e,nt)},[]);let rt=(0,g.useRef)(null),it=(0,g.useRef)(null),at=Oe?.address.mode===`continuable`,ot=at&&Oe.parentAvailable!==!0,st=Ne||ke||oe||!Le||ue!==void 0||ot,ct=st,lt=Ne||ke||oe||!Le,ut=S?.phase===`adjudicating`||S?.phase===`submitting`,dt=!Ne&&oe&&!ke&&fe!==void 0,ft=Ne||Le&&!ut&&(!ct||!Ne&&se&&Le&&!ke&&!ot&&!dt),pt=ke||!ft&&!dt,mt=Oe===null||Oe.address.mode===`continuable`,ht=!ct&&!ut&&Ve&&De&&mt&&Ze?.previewOnly!==!0&&S.queue.length>0,gt=(0,g.useRef)(Ne),_t=(0,g.useRef)(!1);if(gt.current&&!Ne&&ie!==void 0){let e=document.activeElement;e!==null&&rt.current?.contains(e)&&(_t.current=!0)}(0,g.useLayoutEffect)(()=>{gt.current=Ne},[Ne]),(0,g.useEffect)(()=>{S!==void 0&&n!==void 0&&Be.length!==S.attachmentIds.length&&n.pruneAttachments(Be.map(e=>e.id))},[Be,S?.attachmentIds,n]);let vt=()=>{Oj(it)};(0,g.useEffect)(()=>{Ne?C!==null&&(0,d.shouldAutoFocusTextInput)()&&kj(C,vt):C!==null&&ft&&(_t.current?(_t.current=!1,kj(C,vt)):!ct&&(0,d.shouldAutoFocusTextInput)()&&kj(C,vt))},[Ne,Ie,ct,ft,ie,C]),(0,g.useEffect)(()=>{ct||Re===``||vt()},[Re!==``]),(0,g.useEffect)(()=>jj(it),[]);let yt=(0,g.useRef)({sessionId:ie,ids:new Set(Be.map(e=>e.id)),count:Be.length}),[bt,xt]=(0,g.useState)(0),St=(0,g.useRef)(0);(0,g.useEffect)(()=>{let e=yt.current,t=e.sessionId!==ie,n=bt!==St.current;if(St.current=bt,t){yt.current={sessionId:ie,ids:new Set(Be.map(e=>e.id)),count:Be.length};return}let r=!1;for(let t of Be)e.ids.has(t.id)||(e.ids.add(t.id),r=!0);let i=e.count!==Be.length;e.count=Be.length;let a=(r||n)&&(0,d.shouldAutoFocusTextInput)();if(!a&&!i&&!r&&!n||C===null||!ft||ct)return;a&&kj(C,vt);let o=window.requestAnimationFrame(()=>{let e=C.getRootElement();if(e===null)return;let t=e.ownerDocument.activeElement;a&&(t===null||t===e.ownerDocument.body||t===e.ownerDocument.documentElement)&&kj(C,vt),Aj(C),vt()});return()=>{window.cancelAnimationFrame(o)}},[ie,Be,bt,C,ft,ct]);let Ct=(0,g.useCallback)((e,t)=>{if(Oe!==null||a===void 0||e.length===0)return;if(!Qe){qe(p(`attachment.unavailable`));return}let n=(()=>{if($e&&e.some(e=>!(Ye?.mediaTypes)?.includes(e.type)))return p(`image.unsupportedType`);if(Ye!==void 0){let t=Ye.mediaTypes,n=e.filter(e=>t.includes(e.type)),r=Be.filter(e=>e.kind===`image`);if(r.length+n.length>Ye.maxImagesPerMessage)return p(`image.tooMany`,{count:Ye.maxImagesPerMessage});if(n.some(e=>e.size>Ye.maxImageBytes))return p(`image.fileTooLarge`,{size:Lj(Ye.maxImageBytes)});if(r.reduce((e,t)=>e+t.file.size,0)+n.reduce((e,t)=>e+t.size,0)>Ye.maxMessageImageBytes)return p(`image.totalTooLarge`,{size:Lj(Ye.maxMessageImageBytes)})}return a(e,t)})();n===null?xt(e=>e+1):qe(n)},[Oe,a,Qe,$e,Be,Ye,qe,p]),wt=Qe&&Oe===null&&!ct&&!ut&&a!==void 0,Tt=p(Qe?$e?`input.imagesAndCommands`:`input.commands`:`input.commandsOnly`),Et=(0,g.useRef)(null),Dt=e=>{let t=e.target.files===null?[]:[...e.target.files];e.target.value=``,t.length>0&&Ct(t)},Ot=(0,g.useRef)({locked:ct,canPasteText:ft,machineBusy:ut,primaryAction:ze,canSteerQueue:ht,running:De,steeringAvailable:mt,busyEnter:xe,intakeFiles:Ct,uploadsFailed:Ue,showToast:qe,t:p,canAcceptDrop:wt});Ot.current={locked:ct,canPasteText:ft,machineBusy:ut,primaryAction:ze,canSteerQueue:ht,running:De,steeringAvailable:mt,busyEnter:xe,intakeFiles:Ct,uploadsFailed:Ue,showToast:qe,t:p,canAcceptDrop:wt},(0,g.useEffect)(()=>{if(r!==void 0)return Mj(r,Ot,Et)},[r]),(0,g.useEffect)(()=>{if(C!==null){if(Ne&&i!==void 0)return Dj(C,{arbitrate:()=>`pass`,space:()=>!1,dismissPopup:()=>{},canSubmit:()=>!1,submit:()=>{},intakeFiles:()=>{Ot.current.showToast(Ot.current.t(`newSession.uploadUnavailable`))},pasteText:e=>{i.paste(e)}});if(r!==void 0)return Nj(C,r,Ot)}},[C,r,Ne,i]);let kt=e=>{Ij(e,C)},At=e=>{!Nt&&e.button===0&&Pj(e.currentTarget.ownerDocument),Ij(e,C)},jt=()=>{r!==void 0&&(C!==null&&(0,d.shouldAutoFocusTextInput)()&&kj(C,vt),u?.(r.caretSpan()))},Mt=e=>{dt&&(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),fe())},Nt=ze===void 0&&De&&Oe===null&&(Ve||ue!==void 0),Pt=Nt?f===void 0:(ze===void 0?Ve:ze.disabled)||st||ut,Ft=De&&at,It=mA(xe,De,`enter`,mt),Lt=!Ve&&S?.phase===`plain`&&!Re.trimStart().startsWith(`/`),Rt=p(Nt?`input.stop`:ze===void 0&&De&&mt&&!st&&!Ue&&Lt?It===`steer`?`input.send.steer`:`input.send.queue`:`input.send`),zt=()=>{(0,d.shouldAutoFocusTextInput)()||Fj(C)},Bt=()=>{zt(),f?.()},Vt=()=>{Nt?Bt():Ue?qe(p(`file.retryOrRemove`)):ze===void 0?r!==void 0&&!Ve&&!st&&!ut&&(zt(),r.submit(It,`click`)):Pt||(zt(),ze.run())},Ht=(S?.phase===`claimed`||S?.phase===`submitting`)&&S.claim!==void 0&&Re.startsWith(S.claim.token),Ut=Ht&&S.claim.hint!==void 0&&Re.slice(S.claim.token.length).trim()===``?S.claim.hint:null,Wt=(()=>{if(Ut===null)return null;let e=S?.claim?.name??``,t=`hint.${e===`goal`&&Me?`goal.active`:e}`,n=p(t);return n===t?Ut:n})(),Gt=pe??p(ot?`placeholder.parentOffline`:st?`placeholder.unavailable`:ht?`placeholder.steerQueue`:je??Ae?`placeholder.plan`:`placeholder.default`);return/* @__PURE__ */ (0,h.jsxs)(`div`,{className:gC($.root,ae===`hero`&&$.hero),"data-composer-variant":ae,children:[We!==null&&/* @__PURE__ */ (0,h.jsx)(d.Toast,{text:We.text,icon:/* @__PURE__ */ (0,h.jsx)(d.IconWarningOutlineRegular,{}),anchor:rt.current,onDone:Je},We.seq),be?.level===`info`&&/* @__PURE__ */ (0,h.jsx)(`div`,{className:$.notice,role:`status`,children:be.text}),/* @__PURE__ */ (0,h.jsxs)(`div`,{className:$.cardStack,children:[me!==void 0&&/* @__PURE__ */ (0,h.jsx)(`div`,{className:$.topRail,"data-composer-top-bar":``,onClick:e=>{e.stopPropagation()},onPointerDown:e=>{e.stopPropagation()},children:me}),/* @__PURE__ */ (0,h.jsxs)(`div`,{ref:rt,className:gC($.card,dt&&$.cardWorkspaceTrigger),"data-composer-card":!0,onClick:dt?fe:void 0,onPointerDown:dt?e=>{e.stopPropagation()}:void 0,children:[ie!==void 0&&/* @__PURE__ */ (0,h.jsx)(`div`,{className:$.overlayAnchor,children:m(`conversation.input.overlay`,{})}),x!==void 0&&/* @__PURE__ */ (0,h.jsx)(`div`,{className:$.accessory,children:x}),Fe&&/* @__PURE__ */ (0,h.jsxs)(`div`,{className:$.creationError,role:`alert`,"data-new-session-error":``,children:[/* @__PURE__ */ (0,h.jsx)(d.IconWarningOutlineRegular,{className:$.creationErrorIcon,size:16}),/* @__PURE__ */ (0,h.jsxs)(`div`,{className:$.creationErrorCopy,children:[/* @__PURE__ */ (0,h.jsx)(`span`,{className:$.creationErrorTitle,children:p(`newSession.createFailedTitle`)}),/* @__PURE__ */ (0,h.jsx)(`span`,{className:$.creationErrorDetail,children:ce.reason===`no-harness`?p(`newSession.createFailed.noHarness`):ce.reason===`workspace-required`?p(`newSession.createFailed.workspaceRequired`):ce.message??p(`newSession.createFailed.generic`)})]}),le!==void 0&&/* @__PURE__ */ (0,h.jsx)(`button`,{type:`button`,className:$.creationRetry,onMouseDown:kt,onClick:le,children:p(`newSession.retry`)})]}),ye.length===0?null:/* @__PURE__ */ (0,h.jsx)(`div`,{className:$.annotations,children:/* @__PURE__ */ (0,h.jsx)(d.ResponseAnnotationTray,{annotations:ye,hoveredId:_e,disabled:ct||ut,labels:ve,onHover:e=>{n?.hoverResponseAnnotation(e)},onReveal:l===void 0?void 0:e=>{l(e)},onUpdate:(e,t)=>{n?.updateResponseAnnotation(e,t)},onRemove:e=>{n?.removeResponseAnnotation(e)},onClearAll:()=>{n?.clearResponseAnnotations()}})}),S===void 0||ie===void 0?null:/* @__PURE__ */ (0,h.jsx)(`div`,{className:$.inlineNotices,children:m(`conversation.input.notice`,{})}),m(`conversation.input.attachments`,{attachments:Be,canAcceptDrop:wt,onAddFiles:Ct,onRemoveAttachment:e=>{o?.(e)},uploads:He,onRetryFile:e=>{c?.(e)},dropLimits:Ye===void 0?void 0:{count:Ye.maxImagesPerMessage,size:Lj(Ye.maxImageBytes)}}),/* @__PURE__ */ (0,h.jsx)(Tj,{classNames:$,editor:C,scrollRef:it,editable:ft,editorDisabled:pt,preserveFocus:_t.current,phase:Ne?`plain`:S?.phase??`inert`,placeholderText:Gt,ariaLabel:dt?p(`hero.chooseWorkspace`):Gt,workspaceTrigger:dt,workspacePickerOpen:de,onWorkspaceKeyDown:Mt,hint:Wt,showPlaceholder:Re===``&&Be.length===0&&!Ht}),/* @__PURE__ */ (0,h.jsx)(`div`,{ref:et,className:$.row,"data-composer-toolbar":!0,"data-command-menu-open":Ce||void 0,"data-toolbar-activity":we||void 0,children:/* @__PURE__ */ (0,h.jsxs)(`div`,{className:$.controlScroll,"data-toolbar-scroll":!0,children:[/* @__PURE__ */ (0,h.jsxs)(`div`,{className:$.tools,hidden:we,"data-composer-tools":!0,children:[/* @__PURE__ */ (0,h.jsx)(`div`,{className:$.addSeat,"data-toolbar-fixed":`start`,children:/* @__PURE__ */ (0,h.jsx)(d.Tooltip,{portal:tt.phone,label:Tt,side:`top`,delayMs:500,children:/* @__PURE__ */ (0,h.jsx)(`button`,{type:`button`,className:$.add,"aria-label":Tt,"aria-haspopup":`listbox`,"aria-expanded":Ce,disabled:ct||ut||u===void 0,onMouseDown:kt,onClick:jt,children:/* @__PURE__ */ (0,h.jsx)(d.IconPlusOutlineMedium,{size:14})})})}),/* @__PURE__ */ (0,h.jsx)(`input`,{ref:Et,type:`file`,accept:$e?Ye?.mediaTypes.join(`,`):void 0,multiple:!0,disabled:!Qe||Oe!==null,hidden:!0,onChange:Dt}),/* @__PURE__ */ (0,h.jsxs)(`div`,{className:$.modes,children:[ie===void 0?null:m(`conversation.input.permission`,{locked:ct}),ie===void 0?null:m(`conversation.input.plan`,{locked:ct})]}),S===void 0||ie===void 0?null:m(`conversation.input.left`,{})]}),/* @__PURE__ */ (0,h.jsxs)(`div`,{className:gC($.trailing,we&&$.trailingActive),children:[/* @__PURE__ */ (0,h.jsxs)(`div`,{className:$.standardControls,hidden:we,children:[S===void 0||ie===void 0?null:m(`conversation.input.right`,{overflowActions:tt.overflowActions}),ie===void 0?Pe?/* @__PURE__ */ (0,h.jsxs)(`div`,{className:$.pendingControls,role:`status`,"aria-live":`polite`,"data-new-session-loading":``,children:[/* @__PURE__ */ (0,h.jsxs)(`span`,{className:$.pendingModel,children:[/* @__PURE__ */ (0,h.jsx)(d.StateDot,{state:`ongoing`}),/* @__PURE__ */ (0,h.jsx)(`span`,{className:$.pendingModelLabel,children:p(`newSession.loadingModel`)})]}),/* @__PURE__ */ (0,h.jsx)(`span`,{className:$.pendingHarness,role:`img`,"aria-label":p(`newSession.loadingHarness`),"aria-busy":`true`,title:p(`newSession.loadingHarness`),children:/* @__PURE__ */ (0,h.jsx)(d.StateDot,{state:`ongoing`})})]}):null:m(`conversation.input.model`,{locked:lt})]}),S===void 0||ie===void 0?null:/* @__PURE__ */ (0,h.jsx)(`div`,{className:we?$.activityExpanded:$.activity,children:m(`conversation.input.activity`,{locked:ct,onActiveChange:Te})}),/* @__PURE__ */ (0,h.jsxs)(`div`,{className:$.submitSeat,"data-toolbar-fixed":`end`,children:[Ft&&/* @__PURE__ */ (0,h.jsx)(d.Tooltip,{portal:tt.phone,label:p(`input.stop`),shortcutKeys:Se,side:`top`,delayMs:500,disabled:f===void 0,children:/* @__PURE__ */ (0,h.jsx)(`button`,{type:`button`,className:$.primary,"aria-label":p(`input.stop`),disabled:f===void 0,onMouseDown:kt,onClick:Bt,children:/* @__PURE__ */ (0,h.jsx)(`svg`,{viewBox:`0 0 16 16`,width:`14`,height:`14`,"aria-hidden":!0,children:/* @__PURE__ */ (0,h.jsx)(`rect`,{x:`3`,y:`3`,width:`10`,height:`10`,rx:`3`,fill:`currentColor`})})})}),/* @__PURE__ */ (0,h.jsx)(d.Tooltip,{portal:tt.phone,label:Nt?p(`input.stop`):Rt,shortcutKeys:Nt?Se:void 0,side:`top`,delayMs:500,disabled:Pt,children:/* @__PURE__ */ (0,h.jsx)(`button`,{type:`button`,className:$.primary,"aria-label":Rt,disabled:Pt,onMouseDown:At,onClick:Vt,children:Nt?/* @__PURE__ */ (0,h.jsx)(`svg`,{viewBox:`0 0 16 16`,width:`14`,height:`14`,"aria-hidden":!0,children:/* @__PURE__ */ (0,h.jsx)(`rect`,{x:`3`,y:`3`,width:`10`,height:`10`,rx:`3`,fill:`currentColor`})}):/* @__PURE__ */ (0,h.jsx)(`svg`,{viewBox:`0 0 16 16`,width:`14`,height:`14`,"aria-hidden":!0,children:/* @__PURE__ */ (0,h.jsx)(`path`,{d:`M8.3125 0.980183C8.66767 1.0531 8.97902 1.20418 9.2627 1.43233C9.48724 1.61297 9.73029 1.85793 9.97949 2.10714L14.707 6.83468L13.293 8.24874L9 3.95577V15.0417H7V3.95577L2.70703 8.24874L1.29297 6.83468L6.02051 2.10714C6.26971 1.85793 6.51277 1.61297 6.7373 1.43233C6.97662 1.23986 7.28445 1.04402 7.6875 0.980183C7.8973 0.947006 8.1031 0.95516 8.3125 0.980183Z`,fill:`currentColor`})})})})]})]})]})})]})]}),/* @__PURE__ */ (0,h.jsxs)(`div`,{className:$.dock,"data-composer-dock":!0,"data-cx-region":`composer-dock`,children:[ae===`composer`&&S!==void 0&&ie!==void 0?m(`conversation.composer.dock`,{}):null,we?null:/* @__PURE__ */ (0,h.jsx)(Kj,{useProjection:re,t:p})]})]})}),Zj=`@deepseek-ai/dsh-client-ui-conversation/TodoPanel.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(Zj)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-conversation`,e.dataset.pluginCss=Zj,e.textContent=`.OKyn-W_root{box-sizing:border-box;width:calc(100% - var(--dsh-composer-side-clearance) - var(--dsh-composer-side-clearance) - var(--dsh-composer-dock-inset) - var(--dsh-composer-dock-inset) - var(--dsh-composer-dock-inset) - var(--dsh-composer-dock-inset));max-width:calc(var(--dsh-composer-card-max-width) - var(--dsh-composer-dock-inset) - var(--dsh-composer-dock-inset) - var(--dsh-composer-dock-inset) - var(--dsh-composer-dock-inset));--dsw-elevation-stroke-color:var(--dsw-alias-border-l1);border-radius:var(--dsw-radius-lg);background:var(--dsw-specific-menu);backdrop-filter:var(--dsw-menu-backdrop-filter);box-shadow:var(--dsw-elevation-panel);--dsh-scrollbar-thumb:var(--dsw-alias-scrollbar-bg-l2);--dsh-scrollbar-thumb-hover:var(--dsw-alias-scrollbar-hover-l2);border:0;flex:none;margin:0 auto;overflow:hidden}.OKyn-W_body{flex-direction:column;gap:8px;padding:6px 12px;display:flex}.OKyn-W_header{text-align:left;cursor:pointer;background:0 0;border:none;align-items:center;gap:10px;width:100%;padding:0;display:flex}.OKyn-W_lead{color:var(--dsw-alias-label-tertiary);flex:none;place-items:center;display:grid}.OKyn-W_title{color:var(--dsw-alias-label-primary);flex:none;font-size:13px;font-weight:500;line-height:24px}.OKyn-W_progress{min-width:0;color:var(--dsw-alias-label-tertiary);text-overflow:ellipsis;white-space:nowrap;flex:auto;font-size:13px;font-weight:400;line-height:20px;overflow:hidden}.OKyn-W_chevron{color:var(--dsw-alias-label-tertiary);flex:none;place-items:center;display:grid}.OKyn-W_list{flex-direction:column;gap:8px;max-height:180px;margin:0;padding:0;list-style:none;display:flex;overflow-y:auto}.OKyn-W_item{min-width:0;color:var(--dsw-alias-label-secondary);align-items:center;gap:10px;font-size:13px;line-height:20px;display:flex}.OKyn-W_glyph{flex:none;place-items:center;width:16px;height:16px;display:grid}.OKyn-W_content{text-overflow:ellipsis;white-space:nowrap;min-width:0;overflow:hidden}`,document.head.appendChild(e)}var Qj={body:`OKyn-W_body`,chevron:`OKyn-W_chevron`,content:`OKyn-W_content`,glyph:`OKyn-W_glyph`,header:`OKyn-W_header`,item:`OKyn-W_item`,lead:`OKyn-W_lead`,list:`OKyn-W_list`,progress:`OKyn-W_progress`,root:`OKyn-W_root`,title:`OKyn-W_title`};
172
172
  /* v8 ignore next 3 -- closed-union backstop; only reached if status is forged */
173
- function nj(e){throw Error(`unreachable todo status: ${String(e)}`)}function rj(e){switch(e){case`completed`:return`done`;case`in_progress`:return`ongoing`;case`pending`:return`idle`;
173
+ function $j(e){throw Error(`unreachable todo status: ${String(e)}`)}function eM(e){switch(e){case`completed`:return`done`;case`in_progress`:return`ongoing`;case`pending`:return`idle`;
174
174
  /* v8 ignore next -- closed TodoItem status union */
175
- default:return nj(e)}}function ij(e,t){switch(e){case`completed`:return t(`todo.status.completed`);case`in_progress`:return t(`todo.status.inProgress`);case`pending`:return t(`todo.status.pending`);
175
+ default:return $j(e)}}function tM(e,t){switch(e){case`completed`:return t(`todo.status.completed`);case`in_progress`:return t(`todo.status.inProgress`);case`pending`:return t(`todo.status.pending`);
176
176
  /* v8 ignore next -- closed TodoItem status union */
177
- default:return nj(e)}}function aj(e,t){let n=e.filter(e=>e.status===`completed`).length,r=e.filter(e=>e.status===`in_progress`).length,i=e.length-n-r;return[...n>0?[t(`todo.progress.done`,{done:n})]:[],...r>0?[t(`todo.progress.active`,{active:r})]:[],...i>0?[t(`todo.progress.pending`,{pending:i})]:[]].join(` · `)}function oj({todos:e,t}){let[n,r]=(0,g.useState)(!0);return e.length===0?null:/* @__PURE__ */ (0,h.jsx)(`section`,{className:tj.root,"data-testid":`todo-panel`,"aria-label":t(`todo.title`),children:/* @__PURE__ */ (0,h.jsxs)(`div`,{className:tj.body,children:[/* @__PURE__ */ (0,h.jsxs)(`button`,{type:`button`,className:tj.header,"aria-expanded":!n,onClick:()=>{r(e=>!e)},children:[/* @__PURE__ */ (0,h.jsx)(`span`,{className:tj.lead,"aria-hidden":!0,children:/* @__PURE__ */ (0,h.jsx)(d.IconChecklistOutlineRegular,{})}),/* @__PURE__ */ (0,h.jsx)(`span`,{className:tj.title,children:t(`todo.title`)}),/* @__PURE__ */ (0,h.jsx)(`span`,{className:tj.progress,children:aj(e,t)}),/* @__PURE__ */ (0,h.jsx)(`span`,{className:tj.chevron,"aria-hidden":!0,children:n?/* @__PURE__ */ (0,h.jsx)(d.IconChevronUpOutlineRegular,{}):/* @__PURE__ */ (0,h.jsx)(d.IconChevronDownOutlineRegular,{})})]}),!n&&/* @__PURE__ */ (0,h.jsx)(`ul`,{className:tj.list,children:e.map(e=>/* @__PURE__ */ (0,h.jsxs)(`li`,{className:tj.item,"data-status":e.status,children:[/* @__PURE__ */ (0,h.jsx)(`span`,{className:tj.glyph,role:`img`,"aria-label":ij(e.status,t),children:/* @__PURE__ */ (0,h.jsx)(d.StateDot,{state:rj(e.status)})}),/* @__PURE__ */ (0,h.jsx)(`span`,{className:tj.content,children:e.content})]},e.content))})]})})}function sj({useProjection:e,t}){let n=e(`todos`);return/* @__PURE__ */ (0,h.jsx)(oj,{todos:n??[],t})}let cj={name:`conversation-todo-dock`,inject:[`slots`],apply(e){e.slots.inject(`conversation.input.dock`,()=>e.slots.register({name:`conversation.input.dock`,id:`todo`,order:0,locale:ed},sj))}};var lj=class{intervalMs;release;first;timer;constructor(e,t){this.intervalMs=e,this.release=t}reset(){this.first=void 0,clearTimeout(this.timer),this.timer=void 0,this.release()}press(e){let t=this.first;return this.reset(),t!==void 0&&performance.now()<=t.deadline&&t.target.sessionId===e.sessionId&&t.target.turn===e.turn&&t.target.generation===e.generation&&t.target.region===e.region?(e.cancel(),!0):(this.first={target:e,deadline:performance.now()+this.intervalMs},this.timer=setTimeout(()=>{this.reset()},this.intervalMs+1),!1)}};function uj(e,t,n,r,i){let a=()=>{},o=new lj(e.stopSequenceMs,()=>{a(),a=()=>{}}),s=()=>{o.reset()},c=e.observeFixedInput(e=>{if(e.type===`reset`){s();return}let{gesture:c,context:l}=e;if(c.code!==`Escape`||c.repeat||c.composing||c.defaultPrevented||c.control||c.alt||c.shift||c.meta||l.modal!==null||l.region===`terminal`||l.target===null){s();return}let u=l.target,d=u.closest(`[data-conversation-session]`),f=u.closest(`[data-conversation-region]`);if(d===null||f===null||!d.contains(f)||u.closest(`[data-approval-key], iframe, .xterm, [inert]`)!==null){s();return}let p=d.dataset.conversationSession,m=t.binding(p);if(m===void 0){s();return}let h=n(m),g=()=>{let e=m.session.getSnapshot();if(!(!e.running||e.removed||e.subagent!==null&&e.subagent.address.mode!==`continuable`||r.sessionStatus.getSnapshot().get(p)?.pendingInteraction!==void 0))return h.getSnapshot()},_=g();if(_===void 0){s();return}if(e.consume(),o.press({sessionId:p,turn:_,generation:m,region:f,cancel:()=>{i(p)}}))return;let v=()=>{(t.binding(p)!==m||g()!==_)&&s()},y=[h.subscribe(v),m.session.subscribe(v),r.sessionStatus.subscribe(v)];a=()=>{for(let e of y)e()}});return()=>{c(),s()}}let dj=[`slots`,`sessions`,`fileUpload`,`uiSession`,`uiWorkspace`,`locale`,`configForms`],fj=S.object({maxConcurrentFileUploads:S.natural().min(1).default(2)}),pj={getSnapshot:()=>null,subscribe:()=>()=>{}},mj={getSnapshot:()=>void 0,subscribe:()=>()=>{}},hj=/* @__PURE__ */ new Map,gj={getSnapshot:()=>hj,subscribe:()=>()=>{}},_j={getSnapshot:()=>null,subscribe:()=>()=>{}},vj={},yj={getSnapshot:()=>vj,subscribe:()=>()=>{}},bj={state:`idle`},xj={getSnapshot:()=>bj,subscribe:()=>()=>{}},Sj={getSnapshot:()=>``,subscribe:()=>()=>{}};function Cj(){return globalThis.__DSH_HOST_PATHS__}function wj(e,t){let n=e.scope(t);if(n===void 0)throw Error(`ui-conversation: session "${t}" resolved no scope`);let r=n.get(`conversation`);if(r===void 0)throw Error(`ui-conversation: conversation service unavailable through the session scope`);return r}function Tj(e){let t=e.get(`conversation`);if(t===void 0)throw Error(`ui-conversation: conversation service unavailable`);return t}function Ej(e,t=fj({})){let n=e.sessions,r=e.slots,i=t.maxConcurrentFileUploads,a=e.get(`uiWorkspace`),o=new zt(e,n);e.effect(()=>e.locale.register(ed,{zh:rd,en:id}),`ui-conversation: dictionaries`);let s=e.locale.bind(ed),c=Ju(),l=new yk(e.configForms.get(`ui-conversation`));e.effect(()=>()=>{l.dispose()}),e.slots.inject(`settings.general.item`,()=>e.slots.register({name:`settings.general.item`,id:`composer-enter`,order:20,locale:ed,inject:()=>({hooks:{busyEnter:l.busyEnter},setBusyEnter:e=>{l.setBusyEnter(e)}})},Bk));let u=()=>{let t=[];for(let n of r.entries(`conversation.view`))
177
+ default:return $j(e)}}function nM(e,t){let n=e.filter(e=>e.status===`completed`).length,r=e.filter(e=>e.status===`in_progress`).length,i=e.length-n-r;return[...n>0?[t(`todo.progress.done`,{done:n})]:[],...r>0?[t(`todo.progress.active`,{active:r})]:[],...i>0?[t(`todo.progress.pending`,{pending:i})]:[]].join(` · `)}function rM({todos:e,t}){let[n,r]=(0,g.useState)(!0);return e.length===0?null:/* @__PURE__ */ (0,h.jsx)(`section`,{className:Qj.root,"data-testid":`todo-panel`,"aria-label":t(`todo.title`),children:/* @__PURE__ */ (0,h.jsxs)(`div`,{className:Qj.body,children:[/* @__PURE__ */ (0,h.jsxs)(`button`,{type:`button`,className:Qj.header,"aria-expanded":!n,onClick:()=>{r(e=>!e)},children:[/* @__PURE__ */ (0,h.jsx)(`span`,{className:Qj.lead,"aria-hidden":!0,children:/* @__PURE__ */ (0,h.jsx)(d.IconChecklistOutlineRegular,{})}),/* @__PURE__ */ (0,h.jsx)(`span`,{className:Qj.title,children:t(`todo.title`)}),/* @__PURE__ */ (0,h.jsx)(`span`,{className:Qj.progress,children:nM(e,t)}),/* @__PURE__ */ (0,h.jsx)(`span`,{className:Qj.chevron,"aria-hidden":!0,children:n?/* @__PURE__ */ (0,h.jsx)(d.IconChevronUpOutlineRegular,{}):/* @__PURE__ */ (0,h.jsx)(d.IconChevronDownOutlineRegular,{})})]}),!n&&/* @__PURE__ */ (0,h.jsx)(`ul`,{className:Qj.list,children:e.map(e=>/* @__PURE__ */ (0,h.jsxs)(`li`,{className:Qj.item,"data-status":e.status,children:[/* @__PURE__ */ (0,h.jsx)(`span`,{className:Qj.glyph,role:`img`,"aria-label":tM(e.status,t),children:/* @__PURE__ */ (0,h.jsx)(d.StateDot,{state:eM(e.status)})}),/* @__PURE__ */ (0,h.jsx)(`span`,{className:Qj.content,children:e.content})]},e.content))})]})})}function iM({useProjection:e,t}){let n=e(`todos`);return/* @__PURE__ */ (0,h.jsx)(rM,{todos:n??[],t})}let aM={name:`conversation-todo-dock`,inject:[`slots`],apply(e){e.slots.inject(`conversation.input.dock`,()=>e.slots.register({name:`conversation.input.dock`,id:`todo`,order:0,locale:ld},iM))}};var oM=class{intervalMs;release;first;timer;constructor(e,t){this.intervalMs=e,this.release=t}reset(){this.first=void 0,clearTimeout(this.timer),this.timer=void 0,this.release()}press(e){let t=this.first;return this.reset(),t!==void 0&&performance.now()<=t.deadline&&t.target.sessionId===e.sessionId&&t.target.turn===e.turn&&t.target.generation===e.generation&&t.target.region===e.region?(e.cancel(),!0):(this.first={target:e,deadline:performance.now()+this.intervalMs},this.timer=setTimeout(()=>{this.reset()},this.intervalMs+1),!1)}};function sM(e,t,n,r,i){let a=()=>{},o=new oM(e.stopSequenceMs,()=>{a(),a=()=>{}}),s=()=>{o.reset()},c=e.observeFixedInput(e=>{if(e.type===`reset`){s();return}let{gesture:c,context:l}=e;if(c.code!==`Escape`||c.repeat||c.composing||c.defaultPrevented||c.control||c.alt||c.shift||c.meta||l.modal!==null||l.region===`terminal`||l.target===null){s();return}let u=l.target,d=u.closest(`[data-conversation-session]`),f=u.closest(`[data-conversation-region]`);if(d===null||f===null||!d.contains(f)||u.closest(`[data-approval-key], iframe, .xterm, [inert]`)!==null){s();return}let p=d.dataset.conversationSession,m=t.binding(p);if(m===void 0){s();return}let h=n(m),g=()=>{let e=m.session.getSnapshot();if(!(!e.running||e.removed||e.subagent!==null&&e.subagent.address.mode!==`continuable`||r.sessionStatus.getSnapshot().get(p)?.pendingInteraction!==void 0))return h.getSnapshot()},_=g();if(_===void 0){s();return}if(e.consume(),o.press({sessionId:p,turn:_,generation:m,region:f,cancel:()=>{i(p)}}))return;let v=()=>{(t.binding(p)!==m||g()!==_)&&s()},y=[h.subscribe(v),m.session.subscribe(v),r.sessionStatus.subscribe(v)];a=()=>{for(let e of y)e()}});return()=>{c(),s()}}let cM=[`slots`,`sessions`,`fileUpload`,`uiSession`,`uiWorkspace`,`locale`,`configForms`],lM=S.object({maxConcurrentFileUploads:S.natural().min(1).default(2)}),uM={getSnapshot:()=>null,subscribe:()=>()=>{}},dM={getSnapshot:()=>void 0,subscribe:()=>()=>{}},fM=/* @__PURE__ */ new Map,pM={getSnapshot:()=>fM,subscribe:()=>()=>{}},mM={getSnapshot:()=>null,subscribe:()=>()=>{}},hM={},gM={getSnapshot:()=>hM,subscribe:()=>()=>{}},_M={state:`idle`},vM={getSnapshot:()=>_M,subscribe:()=>()=>{}},yM={getSnapshot:()=>``,subscribe:()=>()=>{}};function bM(){return globalThis.__DSH_HOST_PATHS__}function xM(e,t){let n=e.scope(t);if(n===void 0)throw Error(`ui-conversation: session "${t}" resolved no scope`);let r=n.get(`conversation`);if(r===void 0)throw Error(`ui-conversation: conversation service unavailable through the session scope`);return r}function SM(e){let t=e.get(`conversation`);if(t===void 0)throw Error(`ui-conversation: conversation service unavailable`);return t}function CM(e,t=lM({})){let n=e.sessions,r=e.slots,i=t.maxConcurrentFileUploads,a=e.get(`uiWorkspace`),o=new zt(e,n);e.effect(()=>e.locale.register(ld,{zh:fd,en:pd}),`ui-conversation: dictionaries`);let s=e.locale.bind(ld),c=rd(),l=new hA(e.configForms.get(`ui-conversation`));e.effect(()=>()=>{l.dispose()}),e.slots.inject(`settings.general.item`,()=>e.slots.register({name:`settings.general.item`,id:`composer-enter`,order:20,locale:ld,inject:()=>({hooks:{busyEnter:l.busyEnter},setBusyEnter:e=>{l.setBusyEnter(e)}})},IA));let u=()=>{let t=[];for(let n of r.entries(`conversation.view`))
178
178
  /* v8 ignore next -- list registration validates id at load. */
179
- n.options.id!==void 0&&(e.configForms.developerTools.enabled.getSnapshot()||n.options.id!==`trajectory`)&&t.push({id:n.options.id,label:(0,p.resolveSlotLabel)(n.options.label)??n.options.id});return t},m=(e,t)=>{let n=yA(u(),t);n!==void 0&&o.binding(e).activate(n.id)},h=e=>{m(e,Xu(e))},g=(0,f.createSnapshotStore)(u()),_=/* @__PURE__ */ new Set,v=/* @__PURE__ */ new WeakSet,y=e=>{v.has(e)||(v.add(e),_.add(e),e.ctx.effect(()=>()=>{_.delete(e)},`ui-conversation: active Provider binding`))},b=()=>{let e=g.getSnapshot(),t=u();e.length===t.length&&e.every((e,n)=>{let r=t.at(n);return r!==void 0&&e.id===r.id&&e.label===r.label})||g.set(t);for(let e of _)n.binding(e.sessionId)===e&&h(e.sessionId)};e.effect(()=>{let t=r.subscribe(`conversation.view`,b),n=e.locale.subscribe(b),i=e.configForms.developerTools.enabled.subscribe(b);return()=>{i(),n(),t()}},`ui-conversation: View selection`);let ee=e=>{wj(n,e).cancel().catch(e=>{})},te=(0,f.createSnapshotStore)([]);e.inject([`shortcuts`],t=>{let r=[{id:`fixed.send`,label:()=>s(`input.send`),keys:[`Enter`],bindings:[{code:`Enter`,modifiers:[]}],group:`input`},{id:`fixed.newline`,label:()=>s(`shortcut.newline`),keys:t.shortcuts.describeBinding({code:`Enter`,modifiers:[`shift`]}).keys,bindings:[{code:`Enter`,modifiers:[`shift`]}],group:`input`},{id:`fixed.complementary`,label:()=>s(`shortcut.complementary`),keys:t.shortcuts.describeBinding({code:`Enter`,modifiers:[`primary`]}).keys,bindings:[{code:`Enter`,modifiers:[`control`]},{code:`Enter`,modifiers:[`meta`]}],group:`input`},{id:`fixed.slash`,label:()=>s(`shortcut.slash`),keys:[`/`],bindings:[{code:`Slash`,modifiers:[]}],group:`input`},{id:`fixed.mention`,label:()=>s(`shortcut.mention`),keys:[`@`],bindings:[{code:`Digit2`,modifiers:[`shift`]}],group:`input`}];for(let e of r)t.effect(()=>t.shortcuts.registerFixed(e),`ui-conversation: ${e.id}`);t.effect(()=>uj(t.shortcuts,n,e=>o.binding(e).openTurn,e.uiSession,ee),`ui-conversation: fixed stop input`),t.effect(()=>{let e={id:`response.stop`,label:()=>s(`input.stop`),keys:[`Esc`,`Esc`],bindings:[{code:`Escape`,modifiers:[]}],group:`input`},n=t.shortcuts.registerFixed(e);return te.set(e.keys),()=>{te.set([]),n()}},`ui-conversation: fixed stop reference`)});let ne=new pk;e.effect(()=>{let e=a.creating;e!==void 0&&ne.syncCreation(e.getSnapshot());let t=e?.subscribe(()=>{ne.syncCreation(e.getSnapshot())});return()=>{t?.(),ne.dispose()}},`ui-conversation: pending new-session draft`);let re=new dk(e,s,ne),ie=new _d;e.inject([`commandUi`],e=>{let t=e.get(`commandUi`);e.effect(()=>t.register({name:`file`,label:()=>s(`input.file`),icon:d.IconPaperclipOutlineRegular,available:e=>re.canPickFiles(e.sessionId),ui:{kind:`action`,run:e=>{re.pickFiles(e.sessionId)}}}),`ui-conversation: File action`)}),e.uiSession.provide({hooks:[`conversation`,`input`],props:[`inputActions`],resolve:e=>{y(e);let t=re.shellFor(e),n=o.binding(e);return h(e.sessionId),{hooks:{conversation:n.snapshot,input:t.state},props:{inputActions:t.actions}}}});let ae=()=>r.register({name:`main.conversation`,children:{"conversation.header":{kind:`single`,scope:`session-maybe`},"conversation.header.notice":{kind:`list`,scope:`session-maybe`}}},Qk),oe=()=>r.registerFactory({name:`conversation.content`,scope:`session-maybe`,locale:ed,children:{"conversation.session":{kind:`single`,scope:`session`},"conversation.composer":{kind:`chain`,scope:`session`},"conversation.composer.bar":{kind:`single`,scope:`session-maybe`},"conversation.input.dock":{kind:`list`,scope:`session`},"conversation.hero.brand.mark":{kind:`single`,scope:`root`},"conversation.hero.workspace":{kind:`single`,scope:`root`},"conversation.hero.agentPreset":{kind:`single`,scope:`session-maybe`}},slots:{views:{scope:`session`},widthControls:{scope:`root`}},inject:t=>({referenceEditor:t===void 0?void 0:re.shell(t).editor,retrySessionCreation:()=>{a.retryCreating?.()},hooks:{composerBlock:t===void 0?mj:ie.storeFor(t),sessionCreation:a.creating??xj},selectWorkspace:r=>a.openWorkspace(r,r=>{if(t!==void 0&&r!==t){let i=re.shell(t),a=i.draftSnapshot,o=i.snapshot.attachmentIds,s=re.shell(r);if(o.length===0||s.addAttachments(o)){if(n.binding(r)===void 0)throw Error(`ui-conversation: session "${r}" resolved no binding`);if(Tj(e).rebindDraftFiles(r,o),a.text!==``&&(s.setDraft(a),i.setDraft(``)),o.length>0)for(let e of o)i.removeAttachment(e)}}})})},hA),se=()=>r.register({name:`conversation.session`,children:{"conversation.view":{kind:`list`,scope:`session`}},store:c,inject:(e,t)=>{let r=(n,r)=>{u().some(e=>e.id===n)&&(m(e,n),t.openView(n,r))},i=()=>o.views.entries().find(e=>e.toolCallFocus!==void 0&&g.getSnapshot().some(t=>t.id===e.target)),a=e=>{let t=i();t?.toolCallFocus!==void 0&&r(t.target,t.toolCallFocus(e))};return{hooks:{conversationViews:g,inspectCall:{getSnapshot:()=>i()===void 0?void 0:a,subscribe:e=>{let t=g.subscribe(e),n=o.views.subscribe(e);return()=>{t(),n()}}}},bindDraftPersistence:t=>re.shell(e).bindDraftPersistence(t),onRevealResponseAnnotation:t=>n.scope(e)?.on(`conversation/reveal-response-annotation`,t)??(()=>{}),openView:r}}},wA),ce=()=>r.register({name:`conversation.header`,children:{"conversation.header.leading":{kind:`single`,scope:`root`},"conversation.header.navigation":{kind:`single`,scope:`session-maybe`},"conversation.header.shortcuts":{kind:`single`,scope:`session-maybe`},"conversation.header.trailing":{kind:`single`,scope:`root`},"conversation.session.header":{kind:`single`,scope:`session`}}},vA),le=()=>r.register({name:`conversation.session.header`,locale:ed,children:{"conversation.session.header.lineage":{kind:`single`,scope:`session`},"conversation.session.header.actions":{kind:`list`,scope:`session`},"conversation.session.header.utilities":{kind:`list`,scope:`session`},"conversation.session.header.corner":{kind:`single`,scope:`session`}},store:c,inject:(e,t)=>({hooks:{conversationViews:g},open:e=>{a.openSession(e)},selectView:n=>{m(e,n),t.setView(n)}})},CA),ue=()=>r.register({name:`conversation.composer.bar`,locale:ed,children:{"conversation.input.attachments":{kind:`single`,scope:`session-maybe`},"conversation.input.overlay":{kind:`list`,scope:`session`},"conversation.input.notice":{kind:`list`,scope:`session`},"conversation.input.permission":{kind:`single`,scope:`session`},"conversation.input.left":{kind:`list`,scope:`session`},"conversation.input.plan":{kind:`single`,scope:`session`},"conversation.input.right":{kind:`list`,scope:`session`},"conversation.input.model":{kind:`single`,scope:`session`},"conversation.input.activity":{kind:`single`,scope:`session`},"conversation.composer.dock":{kind:`list`,scope:`session`}},inject:t=>{if(t===void 0)return{keyboard:void 0,pendingDraft:{editor:ne.editor,paste:e=>{ne.paste(e)}},addFiles:void 0,removeAttachment:void 0,resolveDraftAttachments:void 0,retryFileUpload:void 0,revealResponseAnnotation:void 0,toggleCommandMenu:void 0,stop:void 0,hooks:{pendingDraftText:ne.text,stopShortcut:te,busyEnter:l.busyEnter,fileUploads:yj,notices:pj,lexicon:gj,menuLauncher:_j}};let r=Tj(e),i=re.shell(t),a=re.inputTriggers(t),o=Cj();return{keyboard:i,pendingDraft:void 0,addFiles:(e,a=/* @__PURE__ */ new Set)=>{if(n.binding(t)===void 0)return s(`file.sessionUnavailable`);if(i.snapshot.phase===`adjudicating`||i.snapshot.phase===`submitting`)return s(`attachment.dropBlocked`);let c=[],l=[],u=n.list.getSnapshot().byId[t]?.cwd;for(let t of e){let e=a.has(t);if(o===void 0&&e)return s(`attachment.directoryDesktopOnly`);let n=o?.pathFor(t)??``;if(e&&n===``)return s(`attachment.pathUnavailable`);if(n===``||!e&&hd(t.type)){c.push(t);continue}let r=$u(n,u),i=Zu({path:e?`${r}/`:r,kind:`file`},!1);if(i===void 0)return s(`attachment.pathUnsupported`);let d=Qu(n)||t.name;l.push({source:`reference`,ref:i,label:e?`${d}/`:d,appearance:e?`folder`:`file`,clipboardText:i})}try{let e=r.createDrafts(t,c);return i.addFiles(l,e.map(e=>e.id))?null:(r.releaseDraftAttachments(e),s(`attachment.dropBlocked`))}catch(e){return e instanceof Error?e.message:String(e)}},removeAttachment:e=>{i.removeAttachment(e)&&r.releaseDraftAttachment(e)},resolveDraftAttachments:e=>r.resolveDraftAttachments(e),retryFileUpload:e=>{n.binding(t)!==void 0&&r.retryFileUpload(t,e)},revealResponseAnnotation:e=>{let r=n.scope(t);r?.emit(r,`conversation/reveal-response-annotation`,e)},toggleCommandMenu:a===void 0?void 0:e=>{i.dismissPopup();let t=i.snapshot;a.toggleSource(`command`,{trigger:`/`,query:``,quoted:!1,position:t.draft.slice(0,e.start).trim()===``?`leading`:`inline`,span:{...e,draftRev:t.draftRev}})},stop:()=>{ee(t)},hooks:{pendingDraftText:Sj,stopShortcut:te,busyEnter:l.busyEnter,fileUploads:r.fileUploads,notices:i.notices,lexicon:i.lexicon,menuLauncher:a?.launcher??_j}}}},$A);e.inject([`conversation`],e=>e.slots.inject(`main`,function*(){yield r.register({name:`main`,key:`conversation`,children:{"main.conversation":{kind:`single`,scope:`session-maybe`}}},gA),yield ae(),yield oe(),yield se(),yield ce(),yield le(),yield ue()})),e.plugin(md,{input:re,blocks:ie,maxConcurrentFileUploads:i}),e.plugin(cj),e.plugin(Ik,re)}return n.Config=fj,n.ConversationController=md,n.ConversationDefinitionRegistry=ht,n.ConversationEventRegistry=gt,n.ConversationLocationIndex=$e,n.ConversationNodeAssembler=ft,n.ConversationViewRegistry=Nt,n.EMPTY_CONVERSATION_SNAPSHOT=Vk,n.UiConversation=zt,n.apply=Ej,n.conversationPhase=Hk,n.inject=dj,n.inspectRequestPrompt=Pe,t.exports}});
179
+ n.options.id!==void 0&&(e.configForms.developerTools.enabled.getSnapshot()||n.options.id!==`trajectory`)&&t.push({id:n.options.id,label:(0,p.resolveSlotLabel)(n.options.label)??n.options.id});return t},m=(e,t)=>{let n=hj(u(),t);n!==void 0&&o.binding(e).activate(n.id)},h=e=>{m(e,ad(e))},g=(0,f.createSnapshotStore)(u()),_=/* @__PURE__ */ new Set,v=/* @__PURE__ */ new WeakSet,y=e=>{v.has(e)||(v.add(e),_.add(e),e.ctx.effect(()=>()=>{_.delete(e)},`ui-conversation: active Provider binding`))},b=()=>{let e=g.getSnapshot(),t=u();e.length===t.length&&e.every((e,n)=>{let r=t.at(n);return r!==void 0&&e.id===r.id&&e.label===r.label})||g.set(t);for(let e of _)n.binding(e.sessionId)===e&&h(e.sessionId)};e.effect(()=>{let t=r.subscribe(`conversation.view`,b),n=e.locale.subscribe(b),i=e.configForms.developerTools.enabled.subscribe(b);return()=>{i(),n(),t()}},`ui-conversation: View selection`);let ee=e=>{xM(n,e).cancel().catch(e=>{})},te=(0,f.createSnapshotStore)([]);e.inject([`shortcuts`],t=>{let r=[{id:`fixed.send`,label:()=>s(`input.send`),keys:[`Enter`],bindings:[{code:`Enter`,modifiers:[]}],group:`input`},{id:`fixed.newline`,label:()=>s(`shortcut.newline`),keys:t.shortcuts.describeBinding({code:`Enter`,modifiers:[`shift`]}).keys,bindings:[{code:`Enter`,modifiers:[`shift`]}],group:`input`},{id:`fixed.complementary`,label:()=>s(`shortcut.complementary`),keys:t.shortcuts.describeBinding({code:`Enter`,modifiers:[`primary`]}).keys,bindings:[{code:`Enter`,modifiers:[`control`]},{code:`Enter`,modifiers:[`meta`]}],group:`input`},{id:`fixed.slash`,label:()=>s(`shortcut.slash`),keys:[`/`],bindings:[{code:`Slash`,modifiers:[]}],group:`input`},{id:`fixed.mention`,label:()=>s(`shortcut.mention`),keys:[`@`],bindings:[{code:`Digit2`,modifiers:[`shift`]}],group:`input`}];for(let e of r)t.effect(()=>t.shortcuts.registerFixed(e),`ui-conversation: ${e.id}`);t.effect(()=>sM(t.shortcuts,n,e=>o.binding(e).openTurn,e.uiSession,ee),`ui-conversation: fixed stop input`),t.effect(()=>{let e={id:`response.stop`,label:()=>s(`input.stop`),keys:[`Esc`,`Esc`],bindings:[{code:`Escape`,modifiers:[]}],group:`input`},n=t.shortcuts.registerFixed(e);return te.set(e.keys),()=>{te.set([]),n()}},`ui-conversation: fixed stop reference`)});let ne=new lA;e.effect(()=>{let e=a.creating;e!==void 0&&ne.syncCreation(e.getSnapshot());let t=e?.subscribe(()=>{ne.syncCreation(e.getSnapshot())});return()=>{t?.(),ne.dispose()}},`ui-conversation: pending new-session draft`);let re=new sA(e,s,ne),ie=new Ed;e.inject([`commandUi`],e=>{let t=e.get(`commandUi`);e.effect(()=>t.register({name:`file`,label:()=>s(`input.file`),icon:d.IconPaperclipOutlineRegular,available:e=>re.canPickFiles(e.sessionId),ui:{kind:`action`,run:e=>{re.pickFiles(e.sessionId)}}}),`ui-conversation: File action`)}),e.uiSession.provide({hooks:[`conversation`,`input`],props:[`inputActions`],resolve:e=>{y(e);let t=re.shellFor(e),n=o.binding(e);return h(e.sessionId),{hooks:{conversation:n.snapshot,input:t.state},props:{inputActions:t.actions}}}});let ae=()=>r.register({name:`main.conversation`,children:{"conversation.header":{kind:`single`,scope:`session-maybe`},"conversation.header.notice":{kind:`list`,scope:`session-maybe`}}},JA),oe=()=>r.registerFactory({name:`conversation.content`,scope:`session-maybe`,locale:ld,children:{"conversation.session":{kind:`single`,scope:`session`},"conversation.composer":{kind:`chain`,scope:`session`},"conversation.composer.bar":{kind:`single`,scope:`session-maybe`},"conversation.input.dock":{kind:`list`,scope:`session`},"conversation.hero.brand.mark":{kind:`single`,scope:`root`},"conversation.hero.workspace":{kind:`single`,scope:`root`},"conversation.hero.agentPreset":{kind:`single`,scope:`session-maybe`}},slots:{views:{scope:`session`},widthControls:{scope:`root`}},inject:t=>({referenceEditor:t===void 0?void 0:re.shell(t).editor,retrySessionCreation:()=>{a.retryCreating?.()},hooks:{composerBlock:t===void 0?dM:ie.storeFor(t),sessionCreation:a.creating??vM},selectWorkspace:r=>a.openWorkspace(r,r=>{if(t!==void 0&&r!==t){let i=re.shell(t),a=i.draftSnapshot,o=i.snapshot.attachmentIds,s=re.shell(r);if(o.length===0||s.addAttachments(o)){if(n.binding(r)===void 0)throw Error(`ui-conversation: session "${r}" resolved no binding`);if(SM(e).rebindDraftFiles(r,o),a.text!==``&&(s.setDraft(a),i.setDraft(``)),o.length>0)for(let e of o)i.removeAttachment(e)}}})})},dj),se=()=>r.register({name:`conversation.session`,children:{"conversation.view":{kind:`list`,scope:`session`}},store:c,inject:(e,t)=>{let r=(n,r)=>{u().some(e=>e.id===n)&&(m(e,n),t.openView(n,r))},i=()=>o.views.entries().find(e=>e.toolCallFocus!==void 0&&g.getSnapshot().some(t=>t.id===e.target)),a=e=>{let t=i();t?.toolCallFocus!==void 0&&r(t.target,t.toolCallFocus(e))};return{hooks:{conversationViews:g,inspectCall:{getSnapshot:()=>i()===void 0?void 0:a,subscribe:e=>{let t=g.subscribe(e),n=o.views.subscribe(e);return()=>{t(),n()}}}},bindDraftPersistence:t=>re.shell(e).bindDraftPersistence(t),onRevealResponseAnnotation:t=>n.scope(e)?.on(`conversation/reveal-response-annotation`,t)??(()=>{}),openView:r}}},Sj),ce=()=>r.register({name:`conversation.header`,children:{"conversation.header.leading":{kind:`single`,scope:`root`},"conversation.header.navigation":{kind:`single`,scope:`session-maybe`},"conversation.header.shortcuts":{kind:`single`,scope:`session-maybe`},"conversation.header.trailing":{kind:`single`,scope:`root`},"conversation.session.header":{kind:`single`,scope:`session`}}},mj),le=()=>r.register({name:`conversation.session.header`,locale:ld,children:{"conversation.session.header.lineage":{kind:`single`,scope:`session`},"conversation.session.header.actions":{kind:`list`,scope:`session`},"conversation.session.header.utilities":{kind:`list`,scope:`session`},"conversation.session.header.corner":{kind:`single`,scope:`session`}},store:c,inject:(e,t)=>({hooks:{conversationViews:g},open:e=>{a.openSession(e)},selectView:n=>{m(e,n),t.setView(n)}})},xj),ue=()=>r.register({name:`conversation.composer.bar`,locale:ld,children:{"conversation.input.attachments":{kind:`single`,scope:`session-maybe`},"conversation.input.overlay":{kind:`list`,scope:`session`},"conversation.input.notice":{kind:`list`,scope:`session`},"conversation.input.permission":{kind:`single`,scope:`session`},"conversation.input.left":{kind:`list`,scope:`session`},"conversation.input.plan":{kind:`single`,scope:`session`},"conversation.input.right":{kind:`list`,scope:`session`},"conversation.input.model":{kind:`single`,scope:`session`},"conversation.input.activity":{kind:`single`,scope:`session`},"conversation.composer.dock":{kind:`list`,scope:`session`}},inject:t=>{if(t===void 0)return{keyboard:void 0,pendingDraft:{editor:ne.editor,paste:e=>{ne.paste(e)}},addFiles:void 0,removeAttachment:void 0,resolveDraftAttachments:void 0,retryFileUpload:void 0,revealResponseAnnotation:void 0,toggleCommandMenu:void 0,stop:void 0,hooks:{pendingDraftText:ne.text,stopShortcut:te,busyEnter:l.busyEnter,fileUploads:gM,notices:uM,lexicon:pM,menuLauncher:mM}};let r=SM(e),i=re.shell(t),a=re.inputTriggers(t),o=bM();return{keyboard:i,pendingDraft:void 0,addFiles:(e,a=/* @__PURE__ */ new Set)=>{if(n.binding(t)===void 0)return s(`file.sessionUnavailable`);if(i.snapshot.phase===`adjudicating`||i.snapshot.phase===`submitting`)return s(`attachment.dropBlocked`);let c=[],l=[],u=n.list.getSnapshot().byId[t]?.cwd;for(let t of e){let e=a.has(t);if(o===void 0&&e)return s(`attachment.directoryDesktopOnly`);let n=o?.pathFor(t)??``;if(e&&n===``)return s(`attachment.pathUnavailable`);if(n===``||!e&&wd(t.type)){c.push(t);continue}let r=cd(n,u),i=od({path:e?`${r}/`:r,kind:`file`},!1);if(i===void 0)return s(`attachment.pathUnsupported`);let d=sd(n)||t.name;l.push({source:`reference`,ref:i,label:e?`${d}/`:d,appearance:e?`folder`:`file`,clipboardText:i})}try{let e=r.createDrafts(t,c);return i.addFiles(l,e.map(e=>e.id))?null:(r.releaseDraftAttachments(e),s(`attachment.dropBlocked`))}catch(e){return e instanceof Error?e.message:String(e)}},removeAttachment:e=>{i.removeAttachment(e)&&r.releaseDraftAttachment(e)},resolveDraftAttachments:e=>r.resolveDraftAttachments(e),retryFileUpload:e=>{n.binding(t)!==void 0&&r.retryFileUpload(t,e)},revealResponseAnnotation:e=>{let r=n.scope(t);r?.emit(r,`conversation/reveal-response-annotation`,e)},toggleCommandMenu:a===void 0?void 0:e=>{i.dismissPopup();let t=i.snapshot;a.toggleSource(`command`,{trigger:`/`,query:``,quoted:!1,position:t.draft.slice(0,e.start).trim()===``?`leading`:`inline`,span:{...e,draftRev:t.draftRev}})},stop:()=>{ee(t)},hooks:{pendingDraftText:yM,stopShortcut:te,busyEnter:l.busyEnter,fileUploads:r.fileUploads,notices:i.notices,lexicon:i.lexicon,menuLauncher:a?.launcher??mM}}}},Xj);e.inject([`conversation`],e=>e.slots.inject(`main`,function*(){yield r.register({name:`main`,key:`conversation`,children:{"main.conversation":{kind:`single`,scope:`session-maybe`}}},fj),yield ae(),yield oe(),yield se(),yield ce(),yield le(),yield ue()})),e.plugin(Cd,{input:re,blocks:ie,maxConcurrentFileUploads:i}),e.plugin(aM),e.plugin(MA,re)}return n.Config=lM,n.ConversationController=Cd,n.ConversationDefinitionRegistry=ht,n.ConversationEventRegistry=gt,n.ConversationLocationIndex=$e,n.ConversationNodeAssembler=ft,n.ConversationViewRegistry=Nt,n.EMPTY_CONVERSATION_SNAPSHOT=LA,n.UiConversation=zt,n.apply=CM,n.conversationPhase=RA,n.inject=cM,n.inspectRequestPrompt=Pe,t.exports}});