@codexhost/cli-win32-x64 0.28.2 → 0.29.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 (100) hide show
  1. package/README.md +1 -1
  2. package/app/codexhost-distribution.json +1 -1
  3. package/app/console-server.mjs +1894 -575
  4. package/app/console-web.js +2814 -729
  5. package/app/desktop-controller.mjs +251 -36
  6. package/app/host-runtime.mjs +36528 -32793
  7. package/app/plugins/antigravity/assets/icon.svg +34 -1
  8. package/app/plugins/antigravity/plugin.mjs +1628 -657
  9. package/app/plugins/claude-code/assets/icon.svg +1 -1
  10. package/app/plugins/claude-code/manifest.json +1 -1
  11. package/app/plugins/claude-code/plugin.mjs +256 -31
  12. package/app/plugins/codebuddy/assets/icon.svg +1 -1
  13. package/app/plugins/codebuddy/plugin.mjs +230 -28
  14. package/app/plugins/codex-usage/plugin.mjs +230 -28
  15. package/app/plugins/copilot/assets/icon.svg +3 -0
  16. package/app/plugins/copilot/manifest.json +13 -1
  17. package/app/plugins/copilot/plugin.mjs +230 -28
  18. package/app/plugins/cursor-cli/assets/icon.svg +1 -1
  19. package/app/plugins/cursor-cli/plugin.mjs +304 -44
  20. package/app/plugins/deepseek-harness/assets/icon.svg +1 -1
  21. package/app/plugins/deepseek-harness/manifest.json +1 -1
  22. package/app/plugins/deepseek-harness/plugin.mjs +230 -28
  23. package/app/plugins/devin/assets/icon.svg +1 -1
  24. package/app/plugins/devin/manifest.json +20 -0
  25. package/app/plugins/devin/plugin.mjs +354 -67
  26. package/app/plugins/grok/assets/icon.svg +4 -0
  27. package/app/plugins/grok/manifest.json +16 -2
  28. package/app/plugins/grok/plugin.mjs +230 -28
  29. package/app/plugins/hermes/assets/icon.png +0 -0
  30. package/app/plugins/hermes/manifest.json +0 -5
  31. package/app/plugins/hermes/plugin.mjs +230 -28
  32. package/app/plugins/kimi-code/assets/icon.svg +1 -1
  33. package/app/plugins/kimi-code/manifest.json +20 -0
  34. package/app/plugins/kimi-code/plugin.mjs +230 -28
  35. package/app/plugins/kiro-cli/assets/kiro-agent.svg +1 -6
  36. package/app/plugins/kiro-cli/manifest.json +24 -0
  37. package/app/plugins/kiro-cli/plugin.mjs +230 -28
  38. package/app/plugins/omp/assets/icon.svg +1 -1
  39. package/app/plugins/omp/manifest.json +0 -3
  40. package/app/plugins/omp/plugin.mjs +231 -29
  41. package/app/plugins/opencode/assets/icon.svg +5 -0
  42. package/app/plugins/opencode/manifest.json +22 -1
  43. package/app/plugins/opencode/plugin.mjs +246 -40
  44. package/app/plugins/pi/assets/icon.svg +3 -3
  45. package/app/plugins/pi/plugin.mjs +272 -30
  46. package/app/plugins/qoder/assets/icon.svg +1 -1
  47. package/app/plugins/qoder/plugin.mjs +230 -28
  48. package/app/plugins/qoder-cn/assets/icon.svg +1 -1
  49. package/app/plugins/qoder-cn/plugin.mjs +230 -28
  50. package/app/plugins/qwen-code/assets/icon.svg +1 -1
  51. package/app/plugins/qwen-code/plugin.mjs +230 -28
  52. package/app/plugins/workbuddy/assets/icon.svg +7 -9
  53. package/app/plugins/workbuddy/plugin.mjs +230 -28
  54. package/app/plugins/zcode/assets/icon.svg +1 -1
  55. package/app/plugins/zcode/plugin.mjs +230 -28
  56. package/app/renderer-extension.js +4230 -783
  57. package/app/web/apple-touch-icon.png +0 -0
  58. package/app/web/assets/index-0TnaYwHS.js +205 -0
  59. package/app/web/assets/index-aSHN2MIG.css +1 -0
  60. package/app/web/codex-agent.png +0 -0
  61. package/app/web/codex.png +0 -0
  62. package/app/web/codexhost-settings.js +1225 -305
  63. package/app/web/favicon-dark.svg +37 -4
  64. package/app/web/favicon.svg +37 -3
  65. package/app/web/icon-192.png +0 -0
  66. package/app/web/icon-512.png +0 -0
  67. package/app/web/index.html +2 -2
  68. package/app/web/plugins/deepseek-ai__dsh-api-remotes/client.js +65 -65
  69. package/app/web/plugins/deepseek-ai__dsh-api-session-controller/client.js +8 -8
  70. package/app/web/plugins/deepseek-ai__dsh-api-workspace-controller/client.js +1 -1
  71. package/app/web/plugins/deepseek-ai__dsh-client-file-upload/client.js +1 -1
  72. package/app/web/plugins/deepseek-ai__dsh-client-ui-attachment/client.js +1 -1
  73. package/app/web/plugins/deepseek-ai__dsh-client-ui-chat/client.js +69 -69
  74. package/app/web/plugins/deepseek-ai__dsh-client-ui-codexhost/client.js +73 -73
  75. package/app/web/plugins/deepseek-ai__dsh-client-ui-conversation/client.js +102 -98
  76. package/app/web/plugins/deepseek-ai__dsh-client-ui-input-trigger/client.js +1 -1
  77. package/app/web/plugins/deepseek-ai__dsh-client-ui-model-selection/client.js +2 -2
  78. package/app/web/plugins/deepseek-ai__dsh-client-ui-session/client.js +1 -1
  79. package/app/web/plugins/deepseek-ai__dsh-client-ui-shortcuts/client.js +2 -2
  80. package/app/web/plugins/deepseek-ai__dsh-client-ui-sidebar/client.js +2 -2
  81. package/app/web/plugins/deepseek-ai__dsh-client-ui-sidebar-files/client.js +1 -1
  82. package/app/web/plugins/deepseek-ai__dsh-client-ui-subagent/client.js +1 -1
  83. package/app/web/plugins/deepseek-ai__dsh-client-ui-theme/client.js +1 -1
  84. package/app/web/plugins/deepseek-ai__dsh-client-ui-tool/client.js +18 -18
  85. package/app/web/plugins/deepseek-ai__dsh-client-ui-user-questions/client.js +1 -1
  86. package/app/web/plugins/deepseek-ai__dsh-client-ui-workspace/client.js +75 -81
  87. package/app/web/plugins.json +1 -0
  88. package/app/web-modules/server.mjs +1718 -573
  89. package/bin/codexhost.exe +0 -0
  90. package/libexec/codexhost-node-repl.exe +0 -0
  91. package/libexec/codexhost-screenshot.exe +0 -0
  92. package/libexec/codexhost-shell.exe +0 -0
  93. package/libexec/codexhost-shim.exe +0 -0
  94. package/libexec/codexhost-updater.exe +0 -0
  95. package/package.json +1 -1
  96. package/app/plugins/copilot/assets/icon.png +0 -0
  97. package/app/plugins/grok/assets/icon.png +0 -0
  98. package/app/plugins/opencode/assets/icon.png +0 -0
  99. package/app/web/assets/index-BJq8mT6r.js +0 -204
  100. package/app/web/assets/index-CMDliP5b.css +0 -1
@@ -1,16 +1,16 @@
1
- window.__ModuleLoader__.load({id:`@deepseek-ai/dsh-client-ui-conversation`,factory:e=>{var t={exports:{}},n=t.exports;Object.defineProperty(n,Symbol.toStringTag,{value:`Module`});var r=Object.create,i=Object.defineProperty,a=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyNames,s=Object.getPrototypeOf,c=Object.prototype.hasOwnProperty,l=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var s=o(t),l=0,u=s.length,d;l<u;l++)d=s[l],!c.call(e,d)&&d!==n&&i(e,d,{get:(e=>t[e]).bind(null,d),enumerable:!(r=a(t,d))||r.enumerable});return e},u=(e,t,n)=>(n=e==null?{}:r(s(e)),l(t||!e||!e.__esModule||!c.call(e,`default`)?i(n,`default`,{value:e,enumerable:!0}):n,e));let d=e("@deepseek-ai/dsh-client-ui-primitives"),f=e("@deepseek-ai/dsh-client-store"),p=e("@deepseek-ai/dsh-client-ui-slots"),m=e("@deepseek-ai/cordis"),h=e("react/jsx-runtime"),g=e("react");g=u(g,1);let _=e("react-dom");function v(e){return e==null}function y(e){return e&&typeof e==`object`&&!Array.isArray(e)}function b(e,t){return Object.fromEntries(Object.entries(e).filter(([e,n])=>t(e,n)))}function x(e,t){return Object.fromEntries(Object.entries(e).map(([e,n])=>[e,t(n,e)]))}function ee(e,t,n){if(!t)return{...e};let r={};for(let i of t)(n||e[i]!==void 0)&&(r[i]=e[i]);return r}let te=Symbol.for(`cosmokit.volatile.write`);function ne(e,t=/* @__PURE__ */ new Set){if(typeof e==`function`)throw TypeError(`volatile config cannot contain functions`);if(typeof e!=`object`||!e)return e;if(t.has(e))throw TypeError(`volatile config cannot contain cycles`);t.add(e);try{if(Array.isArray(e))return Object.freeze(e.map(e=>ne(e,t)));if(Object.getPrototypeOf(e)!==Object.prototype&&Object.getPrototypeOf(e)!==null)throw TypeError(`volatile config objects must be plain objects or arrays`);return Object.freeze(Object.fromEntries(Object.entries(e).map(([e,n])=>[e,ne(n,t)])))}finally{t.delete(e)}}function re(e){let t=ne(e);return Object.freeze({get:()=>t,[te]:e=>{t=e}})}function ie(e){return typeof e==`object`&&!!e&&te in e}function ae(e,t){return arguments.length===1?t=>ae(e,t):e in globalThis&&t instanceof globalThis[e]||Object.prototype.toString.call(t).slice(8,-1)===e}function oe(e){return ae(`ArrayBuffer`,e)||ae(`SharedArrayBuffer`,e)}function se(e){return oe(e)||ArrayBuffer.isView(e)}let ce;(function(e){e.is=oe,e.isSource=se;function t(e){return ArrayBuffer.isView(e)?e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength):e}e.fromSource=t;function n(e){if(e=t(e),typeof Buffer<`u`)return Buffer.from(e).toString(`base64`);let n=``,r=new Uint8Array(e);for(let e=0;e<r.byteLength;e++)n+=String.fromCharCode(r[e]);return btoa(n)}e.toBase64=n;function r(e){return typeof Buffer<`u`?t(Buffer.from(e,`base64`)):Uint8Array.from(atob(e),e=>e.charCodeAt(0))}e.fromBase64=r;function i(e){return e=t(e),typeof Buffer<`u`?Buffer.from(e).toString(`hex`):Array.from(new Uint8Array(e),e=>e.toString(16).padStart(2,`0`)).join(``)}e.toHex=i;function a(e){if(typeof Buffer<`u`)return t(Buffer.from(e,`hex`));let n=e.length%2==0?e:e.slice(0,e.length-1),r=[];for(let e=0;e<n.length;e+=2)r.push(parseInt(`${n[e]}${n[e+1]}`,16));return Uint8Array.from(r).buffer}e.fromHex=a})(ce||={}),ce.fromBase64,ce.toBase64,ce.fromHex,ce.toHex;function le(e,t=/* @__PURE__ */ new Map){if(!e||typeof e!=`object`)return e;if(ae(`Date`,e))return new Date(e.valueOf());if(ae(`RegExp`,e))return new RegExp(e.source,e.flags);if(oe(e))return e.slice(0);if(ArrayBuffer.isView(e))return e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength);let n=t.get(e);if(n)return n;if(Array.isArray(e)){let n=[];return t.set(e,n),e.forEach((e,r)=>{n[r]=Reflect.apply(le,null,[e,t])}),n}let r=Object.create(Object.getPrototypeOf(e));t.set(e,r);for(let n of Reflect.ownKeys(e)){let i={...Reflect.getOwnPropertyDescriptor(e,n)};`value`in i&&(i.value=Reflect.apply(le,null,[i.value,t])),Reflect.defineProperty(r,n,i)}return r}function ue(e,t,n){let r=/* @__PURE__ */ new Set;function i(e,t){if(e===t)return!0;if(ie(e)||ie(t))return ie(e)&&ie(t);if(!n&&v(e)&&v(t))return!0;if(typeof e!=typeof t||typeof e!=`object`||!e||!t||r.has(e))return!1;function a(n,r){return n(e)?n(t)?r(e,t):!1:!n(t)&&void 0}r.add(e);try{return a(Array.isArray,(e,t)=>{if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!i(e[n],t[n]))return!1;return!0})??a(ae(`Date`),(e,t)=>e.valueOf()===t.valueOf())??a(ae(`URL`),(e,t)=>e.href===t.href)??a(ae(`RegExp`),(e,t)=>e.source===t.source&&e.flags===t.flags)??a(oe,(e,t)=>{if(e.byteLength!==t.byteLength)return!1;let n=new Uint8Array(e),r=new Uint8Array(t);for(let e=0;e<n.length;e++)if(n[e]!==r[e])return!1;return!0})??((!n||[e,t].every(e=>Object.getPrototypeOf(e)===Object.prototype||Object.getPrototypeOf(e)===null))&&Object.keys({...e,...t}).every(n=>i(e[n],t[n])))}finally{r.delete(e)}}return i(e,t)}let de;(function(e){e.millisecond=1;let t=e.second=1e3,n=e.minute=t*60,r=e.hour=n*60,i=e.day=r*24,a=e.week=i*7,o=(/* @__PURE__ */ new Date()).getTimezoneOffset();function s(e){o=e}e.setTimezoneOffset=s;function c(){return o}e.getTimezoneOffset=c;function l(e=/* @__PURE__ */ new Date,t){return typeof e==`number`&&(e=new Date(e)),t===void 0&&(t=o),Math.floor((e.valueOf()/n-t)/1440)}e.getDateNumber=l;function u(e,t){let r=new Date(e*i);return t===void 0&&(t=o),new Date(+r+t*n)}e.fromDateNumber=u;let d=RegExp(`^${[`w(?:eek(?:s)?)?`,`d(?:ay(?:s)?)?`,`h(?:our(?:s)?)?`,`m(?:in(?:ute)?(?:s)?)?`,`s(?:ec(?:ond)?(?:s)?)?`].map(e=>`(\\d+(?:\\.\\d+)?${e})?`).join(``)}$`);function f(e){let o=d.exec(e);return o?(parseFloat(o[1])*a||0)+(parseFloat(o[2])*i||0)+(parseFloat(o[3])*r||0)+(parseFloat(o[4])*n||0)+(parseFloat(o[5])*t||0):0}e.parseTime=f;function p(e){let t=f(e);return t?e=Date.now()+t:/^\d{1,2}(:\d{1,2}){1,2}$/.test(e)?e=`${(/* @__PURE__ */ new Date()).toLocaleDateString()}-${e}`:/^\d{1,2}-\d{1,2}-\d{1,2}(:\d{1,2}){1,2}$/.test(e)&&(e=`${(/* @__PURE__ */ new Date()).getFullYear()}-${e}`),e?new Date(e):/* @__PURE__ */ new Date}e.parseDate=p;function m(e){let a=Math.abs(e);return a>=i-r/2?Math.round(e/i)+`d`:a>=r-n/2?Math.round(e/r)+`h`:a>=n-t/2?Math.round(e/n)+`m`:a>=t?Math.round(e/t)+`s`:e+`ms`}e.format=m;function h(e,t=2){return e.toString().padStart(t,`0`)}e.toDigits=h;function g(e,t=/* @__PURE__ */ new Date){return e.replace(`yyyy`,t.getFullYear().toString()).replace(`yy`,t.getFullYear().toString().slice(2)).replace(`MM`,h(t.getMonth()+1)).replace(`dd`,h(t.getDate())).replace(`hh`,h(t.getHours())).replace(`mm`,h(t.getMinutes())).replace(`ss`,h(t.getSeconds())).replace(`SSS`,h(t.getMilliseconds(),3))}e.template=g})(de||={});let fe=Symbol.for(`schemastery`),pe=Symbol.for(`ValidationError`);globalThis.__schemastery_index__??=0,globalThis.__schemastery_refs__=void 0;var S=class extends TypeError{options;name=`ValidationError`;constructor(e,t){let n=`$`;for(let e of t.path||[])typeof e==`string`?n+=`.`+e:typeof e==`number`?n+=`[`+e+`]`:typeof e==`symbol`&&(n+=`[Symbol(${e.toString()})]`);n.startsWith(`.`)&&(n=n.slice(1)),super((n===`$`?``:`${n} `)+e),this.options=t}static is(e){return!!e?.[pe]}};Object.defineProperty(S.prototype,pe,{value:!0});let C=function(e){let t=function(e,n={}){return C.resolve(e,t,n)[0]};if(e.refs){let t=x(e.refs,e=>new C(e)),n=e=>t[e];for(let e in t){let r=t[e];r.sKey=n(r.sKey),r.inner=n(r.inner),r.list=r.list&&r.list.map(n),r.dict=r.dict&&x(r.dict,n)}return t[e.uid]}if(Object.assign(t,e),typeof t.callback==`string`)try{t.callback=Function(`return `+t.callback)()}catch{}return Object.defineProperty(t,"uid",{value:globalThis.__schemastery_index__++}),Object.setPrototypeOf(t,C.prototype),t.meta||={},t.toString=t.toString.bind(t),t};C.prototype=Object.create(Function.prototype),C.prototype[fe]=!0,Object.defineProperty(C.prototype,"~standard",{get(){return{version:1,vendor:`schemastery`,validate:e=>{try{return{value:C.resolve(e,this,{})[0]}}catch(e){if(S.is(e))return{issues:[{message:e.message,path:e.options.path}]};throw e}}}}}),C.ValidationError=S,C.prototype.toJSON=function(){if(globalThis.__schemastery_refs__)return globalThis.__schemastery_refs__[this.uid]??=JSON.parse(JSON.stringify({...this})),this.uid;globalThis.__schemastery_refs__={[this.uid]:{...this}},globalThis.__schemastery_refs__[this.uid]=JSON.parse(JSON.stringify({...this}));let e={uid:this.uid,refs:globalThis.__schemastery_refs__};return globalThis.__schemastery_refs__=void 0,e},C.prototype.set=function(e,t){return this.dict[e]=t,this},C.prototype.push=function(e){return this.list.push(e),this};function me(e,t){let n=typeof e==`string`?{"":e}:{...e};for(let e in t){let r=t[e];r?.$description||r?.$desc?n[e]=r.$description||r.$desc:typeof r==`string`&&(n[e]=r)}return n}function he(e){return e?.$value??e?.$inner}function ge(e){return b(e??{},e=>!e.startsWith(`$`))}C.prototype.i18n=function(e){let t=C(this),n=me(t.meta.description,e);return Object.keys(n).length&&(t.meta.description=n),t.dict&&=x(t.dict,(t,n)=>t.i18n(x(e,e=>he(e)?.[n]??e?.[n]))),t.list&&=t.list.map((t,n)=>t.i18n(x(e,(e={})=>Array.isArray(he(e))?he(e)[n]:Array.isArray(e)?e[n]:ge(e)))),t.inner&&=t.inner.i18n(x(e,e=>he(e)?he(e):ge(e))),t.sKey&&=t.sKey.i18n(x(e,e=>e?.$key)),t},C.prototype.extra=function(e,t){let n=C(this);return n.meta={...n.meta,[e]:t},n};for(let e of[`required`,`disabled`,`collapse`,`hidden`,`loose`])Object.assign(C.prototype,{[e](t=!0){let n=C(this);return n.meta={...n.meta,[e]:t},n}});C.prototype.deprecated=function(){let e=C(this);return e.meta.badges||=[],e.meta.badges.push({text:`deprecated`,type:`danger`}),e},C.prototype.experimental=function(){let e=C(this);return e.meta.badges||=[],e.meta.badges.push({text:`experimental`,type:`warning`}),e},C.prototype.pattern=function(e){let t=C(this),n=ee(e,[`source`,`flags`]);return t.meta={...t.meta,pattern:n},t},C.prototype.simplify=function(e){if(ie(e)&&(e=e.get()),ue(e,this.meta.default,this.type===`dict`))return null;if(v(e))return e;if(this.type===`object`||this.type===`dict`){let t={};for(let n in e){let r=(this.type===`object`?this.dict[n]:this.inner)?.simplify(e[n]);(this.type===`dict`||!v(r))&&(t[n]=r)}return ue(t,this.meta.default,this.type===`dict`)?null:t}if(this.type===`array`||this.type===`tuple`){let t=[];return e.forEach((e,n)=>{let r=this.type===`array`?this.inner:this.list[n],i=r?r.simplify(e):e;t.push(i)}),t}if(this.type===`intersect`){let t={};for(let n of this.list)Object.assign(t,n.simplify(e));return t}if(this.type===`union`)for(let t of this.list)try{return C.resolve(e,t,{}),t.simplify(e)}catch{}return e},C.prototype.toString=function(e){return Te[this.type]?.(this,e)??`Schema<${this.type}>`},C.prototype.role=function(e,t){let n=C(this);return n.meta={...n.meta,role:e,extra:t},n};for(let e of[`default`,`link`,`comment`,`description`,`max`,`min`,`step`])Object.assign(C.prototype,{[e](t){let n=C(this);return n.meta={...n.meta,[e]:t},n}});C.prototype.volatile=function(){if(this.meta.volatile)throw TypeError(`volatile schema is already wrapped`);return this.extra(`volatile`,!0)};let _e={},ve=Symbol(`checked-volatile-schema`);function ye(e,t=[],n=!1,r=/* @__PURE__ */ new Map){let i=r.get(e)??/* @__PURE__ */ new Set;if(i.has(n))return;if(i.add(n),r.set(e,i),e.meta?.volatile&&n)throw new S(`volatile fields require a fixed object path without an enclosing volatile field`,{path:t});let a=n||!!e.meta?.volatile;if(e.dict)for(let[n,i]of Object.entries(e.dict))ye(i,[...t,n],a,r);if(e.sKey&&ye(e.sKey,[...t,`<key>`],!0,r),e.inner&&(e.type!==`lazy`||e.inner[fe])&&ye(e.inner,[...t,`*`],!0,r),e.list)for(let n=0;n<e.list.length;n++)ye(e.list[n],[...t,String(n)],!0,r)}C.extend=function(e,t){_e[e]=t},C.resolve=function(e,t,n={},r=!1){if(!t)return[e];if(n[ve]||(ye(t,n.path),n={...n,[ve]:!0}),t.meta?.volatile){let i=C(t);i.meta={...t.meta,volatile:!1};let[a,o]=C.resolve(e,i,n,r);try{return[re(a),o]}catch(e){throw new S(e instanceof Error?e.message:String(e),n)}}if(n.ignore?.(e,t))return[e];if(v(e)&&t.type!==`lazy`){if(t.meta.required)throw new S(`missing required value`,n);let r=t,i=t.meta.default;for(;r?.type===`intersect`&&v(i);)r=r.list[0],i=r?.meta.default;if(v(i))return[e];e=le(i)}let i=_e[t.type];if(!i)throw new S(`unsupported type "${t.type}"`,n);try{return i(e,t,n,r)}catch(e){if(!t.meta.loose)throw e;return[t.meta.default]}},C.from=function(e){if(v(e))return C.any();if([`string`,`number`,`boolean`].includes(typeof e))return C.const(e).required();if(e[fe])return e;if(typeof e==`function`)switch(e){case String:return C.string().required();case Number:return C.number().required();case Boolean:return C.boolean().required();case Function:return C.function().required();default:return C.is(e).required()}else throw TypeError(`cannot infer schema from ${e}`)},C.lazy=function(e){let t=new C({type:`lazy`,builder:e,inner:{toJSON:()=>(t.inner[fe]||(t.inner=t.builder(),t.inner.meta={...t.meta,...t.inner.meta}),t.inner.toJSON())}});return t},C.natural=function(){return C.number().step(1).min(0)},C.percent=function(){return C.number().step(.01).min(0).max(1).role(`slider`)},C.date=function(){return C.union([C.is(Date),C.transform(C.string().role(`datetime`),(e,t)=>{let n=new Date(e);if(isNaN(+n))throw new S(`invalid date "${e}"`,t);return n},!0)])},C.regExp=function(e=``){return C.union([C.is(RegExp),C.transform(C.string().role(`regexp`,{flag:e}),(t,n)=>{try{return new RegExp(t,e)}catch(e){throw new S(e.message,n)}},!0)])},C.arrayBuffer=function(e){return C.union([C.is(ArrayBuffer),C.is(SharedArrayBuffer),C.transform(C.any(),(e,t)=>{if(ce.isSource(e))return ce.fromSource(e);throw new S(`expected ArrayBufferSource but got ${e}`,t)},!0),...e?[C.transform(C.string(),(t,n)=>{try{return e===`base64`?ce.fromBase64(t):ce.fromHex(t)}catch(e){throw new S(e.message,n)}},!0)]:[]])},C.extend(`lazy`,(e,t,n,r)=>(t.inner[fe]||(t.inner=t.builder(),t.inner.meta={...t.meta,...t.inner.meta},ye(t.inner,n.path,!0)),C.resolve(e,t.inner,n,r))),C.extend(`any`,e=>[e]),C.extend(`never`,(e,t,n)=>{throw new S(`expected nullable but got ${e}`,n)}),C.extend(`const`,(e,{value:t},n)=>{if(ue(e,t))return[t];throw new S(`expected ${t} but got ${e}`,n)});function be(e,t,n,r,i=!1){let{max:a=1/0,min:o=-1/0}=t;if(e>a)throw new S(`expected ${n} <= ${a} but got ${e}`,r);if(e<o&&!i)throw new S(`expected ${n} >= ${o} but got ${e}`,r)}C.extend(`string`,(e,{meta:t},n)=>{if(typeof e!=`string`)throw new S(`expected string but got ${e}`,n);if(t.pattern){let r=new RegExp(t.pattern.source,t.pattern.flags);if(!r.test(e))throw new S(`expect string to match regexp ${r}`,n)}return be(e.length,t,`string length`,n),[e]});function xe(e,t){let n=e.toString();if(n.includes(`e`))return e*10**t;let r=n.indexOf(`.`);if(r===-1)return e*10**t;let i=n.slice(r+1),a=n.slice(0,r);return i.length<=t?+(a+i.padEnd(t,`0`)):+(a+i.slice(0,t)+`.`+i.slice(t))}function Se(e,t,n){if(n=Math.abs(n),!/^\d+\.\d+$/.test(n.toString()))return(e-t)%n===0;let r=n.toString().indexOf(`.`),i=n.toString().slice(r+1).length;return Math.abs(xe(e,i)-xe(t,i))%xe(n,i)===0}C.extend(`number`,(e,{meta:t},n)=>{if(typeof e!=`number`)throw new S(`expected number but got ${e}`,n);be(e,t,`number`,n);let{step:r}=t;if(r&&!Se(e,t.min??0,r))throw new S(`expected number multiple of ${r} but got ${e}`,n);return[e]}),C.extend(`boolean`,(e,t,n)=>{if(typeof e==`boolean`)return[e];throw new S(`expected boolean but got ${e}`,n)}),C.extend(`bitset`,(e,{bits:t,meta:n},r)=>{let i=0,a=[];if(typeof e==`number`){i=e;for(let n in t)e&t[n]&&a.push(n)}else if(Array.isArray(e)){a=e;for(let e of a){if(typeof e!=`string`)throw new S(`expected string but got ${e}`,r);e in t&&(i|=t[e])}}else throw new S(`expected number or array but got ${e}`,r);return i===n.default?[i]:[i,a]}),C.extend(`function`,(e,t,n)=>{if(typeof e==`function`)return[e];throw new S(`expected function but got ${e}`,n)}),C.extend(`is`,(e,{constructor:t},n)=>{if(typeof t==`function`){if(e instanceof t)return[e];throw new S(`expected ${t.name} but got ${e}`,n)}{if(v(e))throw new S(`expected ${t} but got ${e}`,n);let r=Object.getPrototypeOf(e);for(;r;){if(r.constructor?.name===t)return[e];r=Object.getPrototypeOf(r)}throw new S(`expected ${t} but got ${e}`,n)}});function Ce(e,t,n,r){try{let[i,a]=C.resolve(e[t],n,{...r,path:[...r.path||[],t]});return a!==void 0&&(e[t]=a),i}catch(i){if(!r?.autofix)throw i;return delete e[t],n.meta.volatile?re(n.meta.default):n.meta.default}}C.extend(`array`,(e,{inner:t,meta:n},r)=>{if(!Array.isArray(e))throw new S(`expected array but got ${e}`,r);return be(e.length,n,`array length`,r,!v(t.meta.default)),[e.map((n,i)=>Ce(e,i,t,r))]}),C.extend(`dict`,(e,{inner:t,sKey:n},r,i)=>{if(!y(e))throw new S(`expected object but got ${e}`,r);let a={};for(let o in e){let s;try{s=C.resolve(o,n,r)[0]}catch(e){if(i)continue;throw e}a[s]=Ce(e,o,t,r),e[s]=e[o],o!==s&&delete e[o]}return[a]}),C.extend(`tuple`,(e,{list:t},n,r)=>{if(!Array.isArray(e))throw new S(`expected array but got ${e}`,n);let i=t.map((t,r)=>Ce(e,r,t,n));return r||i.push(...e.slice(t.length)),[i]});function we(e,t){for(let n in t)n in e||(e[n]=t[n])}C.extend(`object`,(e,{dict:t},n,r)=>{if(!y(e))throw new S(`expected object but got ${e}`,n);let i={};for(let r in t){let a=Ce(e,r,t[r],n);(!v(a)||r in e)&&(i[r]=a)}return r||we(i,e),[i]}),C.extend(`union`,(e,{list:t,toString:n},r,i)=>{let a=[];for(let n of t)try{return C.resolve(e,n,r,i)}catch(e){a.push(e)}throw new S(`expected ${n()} but got ${JSON.stringify(e)}`,r)}),C.extend(`intersect`,(e,{list:t,toString:n},r,i)=>{if(!t.length)return[e];let a;for(let i of t){let t=C.resolve(e,i,r,!0)[0];if(!v(t)){if(v(a))a=t;else if(typeof a!=typeof t)throw new S(`expected ${n()} but got ${JSON.stringify(e)}`,r);else if(typeof t==`object`)we(a??={},t);else if(a!==t)throw new S(`expected ${n()} but got ${JSON.stringify(e)}`,r)}}return!i&&y(e)&&we(a,e),[a]}),C.extend(`transform`,(e,{inner:t,callback:n,preserve:r},i)=>{let[a,o=e]=C.resolve(e,t,i,!0);return r?[n(a)]:[n(a),n(o)]});let Te={};function Ee(e,t,n){Te[e]=n,Object.assign(C,{[e](...n){let r=new C({type:e});return t.forEach((e,t)=>{switch(e){case`sKey`:r.sKey=n[t]??C.string();break;case`inner`:r.inner=C.from(n[t]);break;case`list`:r.list=n[t].map(C.from);break;case`dict`:r.dict=x(n[t],C.from);break;case`bits`:r.bits={};for(let e in n[t])typeof n[t][e]==`number`&&(r.bits[e]=n[t][e]);break;case`callback`:{let e=r.callback=n[t];e.toJSON||=()=>e.toString();break}case`constructor`:{let e=r.constructor=n[t];typeof e==`function`&&(e.toJSON||=()=>e.name);break}default:r[e]=n[t]}}),e===`object`||e===`dict`?r.meta.default={}:e===`array`||e===`tuple`?r.meta.default=[]:e===`bitset`&&(r.meta.default=0),r}})}Ee(`is`,[`constructor`],({constructor:e})=>typeof e==`function`?e.name:e),Ee(`any`,[],()=>`any`),Ee(`never`,[],()=>`never`),Ee(`const`,[`value`],({value:e})=>typeof e==`string`?JSON.stringify(e):e),Ee(`string`,[],()=>`string`),Ee(`number`,[],()=>`number`),Ee(`boolean`,[],()=>`boolean`),Ee(`bitset`,[`bits`],()=>`bitset`),Ee(`function`,[],()=>`function`),Ee(`array`,[`inner`],({inner:e})=>`${e.toString(!0)}[]`),Ee(`dict`,[`inner`,`sKey`],({inner:e,sKey:t})=>`{ [key: ${t.toString()}]: ${e.toString()} }`),Ee(`tuple`,[`list`],({list:e})=>`[${e.map(e=>e.toString()).join(`, `)}]`),Ee(`object`,[`dict`],({dict:e})=>Object.keys(e).length===0?`{}`:`{ ${Object.entries(e).map(([e,t])=>`${e}${t.meta.required?``:`?`}: ${t.toString()}`).join(`, `)} }`),Ee(`union`,[`list`],({list:e},t)=>{let n=e.map(({toString:e})=>e()).join(` | `);return t?`(${n})`:n}),Ee(`intersect`,[`list`],({list:e})=>`${e.map(e=>e.toString(!0)).join(` & `)}`),Ee(`transform`,[`inner`,`callback`,`preserve`],({inner:e},t)=>e.toString(t));let De={'"':`"`,"\\":`\\`,"/":`/`,b:`\b`,f:`\f`,n:`
2
- `,r:`\r`,t:` `},Oe=/[\\\u0000-\u001f]/u;function ke(e){return e===` `||e===`
3
- `||e===`\r`||e===` `}function Ae(e){return e>=`0`&&e<=`9`||e>=`a`&&e<=`f`||e>=`A`&&e<=`F`}(class e{static EMPTY=e.fromObject({});static fromText(t){let n=new e;return n.append(t),n.sealed=!0,n}static fromObject(t){let n=new e;return n.object=typeof t==`object`&&t&&!Array.isArray(t)?t:{},n.sealed=!0,n}chunks=[];object;sealed=!1;#e=[];#t=0;#n=0;#r=`root`;#i=!1;#a=0;#o=!1;#s=``;#c=null;#l=[];#u=!1;#d;#f=!1;#p=/* @__PURE__ */ new Map;#m=[];#h=/* @__PURE__ */ new Map;get isSealed(){return this.sealed}get invalid(){return this.scan(),this.#r===`invalid`||this.#f}append(e){if(this.sealed)throw Error(`PartialArguments: cannot append to a sealed view`);e.length!==0&&(this.chunks.push(e),this.#t+=e.length,this.#e.push(this.#t))}settle(t){if(this.object!==void 0||t.length!==this.#t)return e.fromText(t);let n=0;for(let r of this.chunks){if(!t.startsWith(r,n))return e.fromText(t);n+=r.length}return this.chunks=t.length===0?[]:[t],this.#e=t.length===0?[]:[t.length],this.sealed=!0,this}refresh(){if(this.#h.size===0)return!1;this.scan();let e=!1,t=!1;for(let n of this.#h.values())n.completion?t=!0:e=this.refreshRead(n)||e;if(t)for(let t of this.#h.values())t.completion&&(e=this.refreshRead(t)||e);return this.sealed&&this.#h.clear(),e}refreshRead(e){let t=e.answer();return!Object.is(t,e.last)&&(e.last=t,!0)}closed(){return this.remember(`closed`,``,()=>this.closedNow())}keys(){return this.remember(`keys`,``,()=>this.keysNow(),e=>e.length)}has(e){return this.remember(`has`,e,()=>this.hasNow(e))}complete(e){return this.remember(`complete`,e,()=>this.completeNow(e))}stringLength(e,t){let n=Math.max(1,Math.floor(t?.step??1)),r=t?.offset??0;return this.remember(`length:${n}:${r}`,e,()=>this.lengthNow(e),e=>e===void 0?void 0:Math.ceil((e+r)/n))}stringExceeds(e,t){let n=Math.max(0,Math.floor(t));return this.remember(`exceeds:${n}`,e,()=>(this.lengthNow(e,n+1)??0)>n)}text(e){return this.remember(`text`,e,()=>this.textNow(e))}textPrefix(e,t){let n=Math.max(1,Math.floor(t));return this.remember(`prefix:${n}`,e,()=>this.textPrefixNow(e,n))}value(e){return this.remember(`value`,e,()=>this.valueNow(e))}remember(e,t,n,r){this.scan();let i=n();if(!this.sealed){let a=`${e}/${t}`;this.#h.has(a)||this.#h.set(a,{completion:e===`complete`,answer:r===void 0?n:()=>r(n()),last:r===void 0?i:r(i)})}return i}closedNow(){return this.sealed||this.#r===`closed`||this.#r===`invalid`}keysNow(){return this.object===void 0?this.#m:Object.keys(this.object)}hasNow(e){return this.object===void 0?this.#p.has(e):Object.hasOwn(this.object,e)}completeNow(e){if(this.object!==void 0)return Object.hasOwn(this.object,e);let t=this.#p.get(e);return t!==void 0&&t.end>=0&&(t.kind===`string`?t.invalidAt===void 0:!t.invalid)}lengthNow(e,t=1/0){if(this.object!==void 0){let t=Object.hasOwn(this.object,e)?this.object[e]:void 0;return typeof t==`string`?t.length:void 0}let n=this.#p.get(e);if(n?.kind!==`string`)return;if(n.text!==void 0&&n.text.at===n.end)return n.text.length;let r=n.length??={at:n.start,length:0,text:``};return this.readString(n,r,t,!1),r.length}textNow(e){if(this.object!==void 0){let t=Object.hasOwn(this.object,e)?this.object[e]:void 0;return typeof t==`string`?t:void 0}let t=this.#p.get(e);if(t?.kind!==`string`)return;if(t.text===void 0&&t.end>=0&&t.needsDecoding&&t.invalidAt===void 0){let e;try{e=JSON.parse(`"${this.slice(t.start,t.end)}"`)}catch{}e!==void 0&&(t.text={at:t.end,length:e.length,text:e})}let n=t.text??={at:t.start,length:0,text:``};return this.readString(t,n,1/0,!0),n.text}textPrefixNow(e,t){if(this.object!==void 0){let n=Object.hasOwn(this.object,e)?this.object[e]:void 0;return typeof n==`string`?n.slice(0,t):void 0}let n=this.#p.get(e);if(n?.kind!==`string`)return;let r=n.prefixes??=/* @__PURE__ */ new Map,i=r.get(t);return i===void 0&&(i={at:n.start,length:0,text:``},r.set(t,i)),this.readString(n,i,t,!0),i.text}valueNow(e){if(this.object!==void 0){if(!Object.hasOwn(this.object,e))return;let t=this.object[e];return typeof t==`string`?void 0:t}let t=this.#p.get(e);if(!(t?.kind!==`value`||t.end<0||t.invalid)){if(t.parsed===void 0)try{t.parsed=JSON.parse(this.slice(t.start,t.end))}catch{t.invalid=!0,this.#f=!0}return t.parsed}}chunkAt(e){let t=0,n=this.#e.length;for(;t<n;){let r=t+n>>>1;this.#e[r]<=e?t=r+1:n=r}return t}slice(e,t){if(e>=t)return``;let n=this.chunkAt(e),r=this.chunkAt(t-1),i=n===0?0:this.#e[n-1];if(n===r)return this.chunks[n].slice(e-i,t-i);let a=[this.chunks[n].slice(e-i)];for(let e=n+1;e<r;e++)a.push(this.chunks[e]);return a.push(this.chunks[r].slice(0,t-this.#e[r-1])),a.join(``)}readString(e,t,n,r){let i=Math.min(e.end<0?this.#n:e.end,e.invalidAt??1/0,this.#d??1/0);if(!e.needsDecoding){let e=Math.min(i-t.at,n-t.length);if(e<=0)return;r&&(t.text+=this.slice(t.at,t.at+e)),t.at+=e,t.length+=e;return}let a=this.chunkAt(t.at);for(;t.at<i&&t.length<n;){let o=a===0?0:this.#e[a-1],s=this.chunks[a],c=s.slice(t.at-o,Math.min(s.length,i-o)),l=c.search(Oe),u=Math.min(l<0?c.length:l,n-t.length);if(u>0){r&&(t.text+=c.slice(0,u)),t.at+=u,t.length+=u,t.at===o+s.length&&a++;continue}let d=c.length>1?c[1]:t.at+1<i?this.chunks[a+1][0]:void 0,f,p=2;if(c[0]===`\\`&&d===void 0&&e.end<0)return;if(c[0]===`\\`&&d===`u`){let n=this.slice(t.at+2,Math.min(i,t.at+6)),r=!0;for(let e=0;e<n.length;e++)Ae(n[e])||(r=!1);if(r){if(n.length<4&&e.end<0)return;n.length===4&&(f=String.fromCharCode(Number.parseInt(n,16)))}p=6}else c[0]===`\\`&&d!==void 0&&(f=De[d]);if(f===void 0){e.invalidAt=t.at,this.#f=!0;return}for(r&&(t.text+=f),t.length++,t.at+=p;a<this.chunks.length&&t.at>=this.#e[a];)a++}}scan(){if(this.object===void 0&&this.#n!==this.#t)for(let e=this.chunkAt(this.#n);e<this.chunks.length&&this.#d===void 0;e++){let t=this.chunks[e],n=e===0?0:this.#e[e-1];for(let e=this.#n-n;e<t.length&&this.#r!==`invalid`;e++){if(this.#r===`string`||this.#r===`nested`&&this.#u){let n=this.stringBoundary(t,e);if(this.#n+=n-e,e=n,e===t.length)break}this.step(t[e],this.#n),this.#n++}}}stringBoundary(e,t){let n=t;for(;;){let t=e.indexOf(`"`,n),r=t<0?e.length:t;if(this.#r===`string`){let t=this.#c;!t.needsDecoding&&Oe.test(e.slice(n,r))&&(t.needsDecoding=!0)}let i=r;for(;i>n&&e[i-1]===`\\`;)i--;let a=(r-i)%2==1!==(i===n&&this.#i);if(this.#i=t<0&&a,t<0||!a)return r;n=t+1}}step(e,t){switch(this.#r){case`root`:if(ke(e))return;if(e===`{`){this.#r=`key-or-end`;return}this.fail();return;case`key-or-end`:if(ke(e))return;if(e===`}`){this.#r=`closed`;return}if(e===`"`){this.beginKey(t);return}this.fail();return;case`key-only`:if(ke(e))return;if(e===`"`){this.beginKey(t);return}this.fail();return;case`key`:this.stepKey(e,t);return;case`colon`:if(ke(e))return;if(e===`:`){this.#r=`value`;return}this.fail();return;case`value`:this.beginValue(e,t);return;case`string`:{let e=this.#c;e.end=t,this.#c=null,this.#r=`comma-or-end`;return}case`scalar`:this.stepScalar(e,t);return;case`nested`:this.stepNested(e,t);return;case`comma-or-end`:if(ke(e))return;if(e===`,`){this.#r=`key-only`;return}if(e===`}`){this.#r=`closed`;return}this.fail();return;case`closed`:if(ke(e))return;this.fail();return;
1
+ window.__ModuleLoader__.load({id:`@deepseek-ai/dsh-client-ui-conversation`,factory:e=>{var t={exports:{}},n=t.exports;Object.defineProperty(n,Symbol.toStringTag,{value:`Module`});var r=Object.create,i=Object.defineProperty,a=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyNames,s=Object.getPrototypeOf,c=Object.prototype.hasOwnProperty,l=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var s=o(t),l=0,u=s.length,d;l<u;l++)d=s[l],!c.call(e,d)&&d!==n&&i(e,d,{get:(e=>t[e]).bind(null,d),enumerable:!(r=a(t,d))||r.enumerable});return e},u=(e,t,n)=>(n=e==null?{}:r(s(e)),l(t||!e||!e.__esModule||!c.call(e,`default`)?i(n,`default`,{value:e,enumerable:!0}):n,e));let d=e("@deepseek-ai/dsh-client-ui-primitives"),f=e("@deepseek-ai/dsh-client-store"),p=e("@deepseek-ai/dsh-client-ui-slots"),m=e("@deepseek-ai/cordis"),h=e("react/jsx-runtime"),g=e("react");g=u(g,1);let _=e("react-dom");function v(e){return e==null}function y(e){return e&&typeof e==`object`&&!Array.isArray(e)}function b(e,t){return Object.fromEntries(Object.entries(e).filter(([e,n])=>t(e,n)))}function ee(e,t){return Object.fromEntries(Object.entries(e).map(([e,n])=>[e,t(n,e)]))}function te(e,t,n){if(!t)return{...e};let r={};for(let i of t)(n||e[i]!==void 0)&&(r[i]=e[i]);return r}let ne=Symbol.for(`cosmokit.volatile.write`);function re(e,t=/* @__PURE__ */ new Set){if(typeof e==`function`)throw TypeError(`volatile config cannot contain functions`);if(typeof e!=`object`||!e)return e;if(t.has(e))throw TypeError(`volatile config cannot contain cycles`);t.add(e);try{if(Array.isArray(e))return Object.freeze(e.map(e=>re(e,t)));if(Object.getPrototypeOf(e)!==Object.prototype&&Object.getPrototypeOf(e)!==null)throw TypeError(`volatile config objects must be plain objects or arrays`);return Object.freeze(Object.fromEntries(Object.entries(e).map(([e,n])=>[e,re(n,t)])))}finally{t.delete(e)}}function ie(e){let t=re(e);return Object.freeze({get:()=>t,[ne]:e=>{t=e}})}function ae(e){return typeof e==`object`&&!!e&&ne in e}function oe(e,t){return arguments.length===1?t=>oe(e,t):e in globalThis&&t instanceof globalThis[e]||Object.prototype.toString.call(t).slice(8,-1)===e}function se(e){return oe(`ArrayBuffer`,e)||oe(`SharedArrayBuffer`,e)}function ce(e){return se(e)||ArrayBuffer.isView(e)}let le;(function(e){e.is=se,e.isSource=ce;function t(e){return ArrayBuffer.isView(e)?e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength):e}e.fromSource=t;function n(e){if(e=t(e),typeof Buffer<`u`)return Buffer.from(e).toString(`base64`);let n=``,r=new Uint8Array(e);for(let e=0;e<r.byteLength;e++)n+=String.fromCharCode(r[e]);return btoa(n)}e.toBase64=n;function r(e){return typeof Buffer<`u`?t(Buffer.from(e,`base64`)):Uint8Array.from(atob(e),e=>e.charCodeAt(0))}e.fromBase64=r;function i(e){return e=t(e),typeof Buffer<`u`?Buffer.from(e).toString(`hex`):Array.from(new Uint8Array(e),e=>e.toString(16).padStart(2,`0`)).join(``)}e.toHex=i;function a(e){if(typeof Buffer<`u`)return t(Buffer.from(e,`hex`));let n=e.length%2==0?e:e.slice(0,e.length-1),r=[];for(let e=0;e<n.length;e+=2)r.push(parseInt(`${n[e]}${n[e+1]}`,16));return Uint8Array.from(r).buffer}e.fromHex=a})(le||={}),le.fromBase64,le.toBase64,le.fromHex,le.toHex;function ue(e,t=/* @__PURE__ */ new Map){if(!e||typeof e!=`object`)return e;if(oe(`Date`,e))return new Date(e.valueOf());if(oe(`RegExp`,e))return new RegExp(e.source,e.flags);if(se(e))return e.slice(0);if(ArrayBuffer.isView(e))return e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength);let n=t.get(e);if(n)return n;if(Array.isArray(e)){let n=[];return t.set(e,n),e.forEach((e,r)=>{n[r]=Reflect.apply(ue,null,[e,t])}),n}let r=Object.create(Object.getPrototypeOf(e));t.set(e,r);for(let n of Reflect.ownKeys(e)){let i={...Reflect.getOwnPropertyDescriptor(e,n)};`value`in i&&(i.value=Reflect.apply(ue,null,[i.value,t])),Reflect.defineProperty(r,n,i)}return r}function de(e,t,n){let r=/* @__PURE__ */ new Set;function i(e,t){if(e===t)return!0;if(ae(e)||ae(t))return ae(e)&&ae(t);if(!n&&v(e)&&v(t))return!0;if(typeof e!=typeof t||typeof e!=`object`||!e||!t||r.has(e))return!1;function a(n,r){return n(e)?n(t)?r(e,t):!1:!n(t)&&void 0}r.add(e);try{return a(Array.isArray,(e,t)=>{if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!i(e[n],t[n]))return!1;return!0})??a(oe(`Date`),(e,t)=>e.valueOf()===t.valueOf())??a(oe(`URL`),(e,t)=>e.href===t.href)??a(oe(`RegExp`),(e,t)=>e.source===t.source&&e.flags===t.flags)??a(se,(e,t)=>{if(e.byteLength!==t.byteLength)return!1;let n=new Uint8Array(e),r=new Uint8Array(t);for(let e=0;e<n.length;e++)if(n[e]!==r[e])return!1;return!0})??((!n||[e,t].every(e=>Object.getPrototypeOf(e)===Object.prototype||Object.getPrototypeOf(e)===null))&&Object.keys({...e,...t}).every(n=>i(e[n],t[n])))}finally{r.delete(e)}}return i(e,t)}let fe;(function(e){e.millisecond=1;let t=e.second=1e3,n=e.minute=t*60,r=e.hour=n*60,i=e.day=r*24,a=e.week=i*7,o=(/* @__PURE__ */ new Date()).getTimezoneOffset();function s(e){o=e}e.setTimezoneOffset=s;function c(){return o}e.getTimezoneOffset=c;function l(e=/* @__PURE__ */ new Date,t){return typeof e==`number`&&(e=new Date(e)),t===void 0&&(t=o),Math.floor((e.valueOf()/n-t)/1440)}e.getDateNumber=l;function u(e,t){let r=new Date(e*i);return t===void 0&&(t=o),new Date(+r+t*n)}e.fromDateNumber=u;let d=RegExp(`^${[`w(?:eek(?:s)?)?`,`d(?:ay(?:s)?)?`,`h(?:our(?:s)?)?`,`m(?:in(?:ute)?(?:s)?)?`,`s(?:ec(?:ond)?(?:s)?)?`].map(e=>`(\\d+(?:\\.\\d+)?${e})?`).join(``)}$`);function f(e){let o=d.exec(e);return o?(parseFloat(o[1])*a||0)+(parseFloat(o[2])*i||0)+(parseFloat(o[3])*r||0)+(parseFloat(o[4])*n||0)+(parseFloat(o[5])*t||0):0}e.parseTime=f;function p(e){let t=f(e);return t?e=Date.now()+t:/^\d{1,2}(:\d{1,2}){1,2}$/.test(e)?e=`${(/* @__PURE__ */ new Date()).toLocaleDateString()}-${e}`:/^\d{1,2}-\d{1,2}-\d{1,2}(:\d{1,2}){1,2}$/.test(e)&&(e=`${(/* @__PURE__ */ new Date()).getFullYear()}-${e}`),e?new Date(e):/* @__PURE__ */ new Date}e.parseDate=p;function m(e){let a=Math.abs(e);return a>=i-r/2?Math.round(e/i)+`d`:a>=r-n/2?Math.round(e/r)+`h`:a>=n-t/2?Math.round(e/n)+`m`:a>=t?Math.round(e/t)+`s`:e+`ms`}e.format=m;function h(e,t=2){return e.toString().padStart(t,`0`)}e.toDigits=h;function g(e,t=/* @__PURE__ */ new Date){return e.replace(`yyyy`,t.getFullYear().toString()).replace(`yy`,t.getFullYear().toString().slice(2)).replace(`MM`,h(t.getMonth()+1)).replace(`dd`,h(t.getDate())).replace(`hh`,h(t.getHours())).replace(`mm`,h(t.getMinutes())).replace(`ss`,h(t.getSeconds())).replace(`SSS`,h(t.getMilliseconds(),3))}e.template=g})(fe||={});let pe=Symbol.for(`schemastery`),me=Symbol.for(`ValidationError`);globalThis.__schemastery_index__??=0,globalThis.__schemastery_refs__=void 0;var x=class extends TypeError{options;name=`ValidationError`;constructor(e,t){let n=`$`;for(let e of t.path||[])typeof e==`string`?n+=`.`+e:typeof e==`number`?n+=`[`+e+`]`:typeof e==`symbol`&&(n+=`[Symbol(${e.toString()})]`);n.startsWith(`.`)&&(n=n.slice(1)),super((n===`$`?``:`${n} `)+e),this.options=t}static is(e){return!!e?.[me]}};Object.defineProperty(x.prototype,me,{value:!0});let S=function(e){let t=function(e,n={}){return S.resolve(e,t,n)[0]};if(e.refs){let t=ee(e.refs,e=>new S(e)),n=e=>t[e];for(let e in t){let r=t[e];r.sKey=n(r.sKey),r.inner=n(r.inner),r.list=r.list&&r.list.map(n),r.dict=r.dict&&ee(r.dict,n)}return t[e.uid]}if(Object.assign(t,e),typeof t.callback==`string`)try{t.callback=Function(`return `+t.callback)()}catch{}return Object.defineProperty(t,"uid",{value:globalThis.__schemastery_index__++}),Object.setPrototypeOf(t,S.prototype),t.meta||={},t.toString=t.toString.bind(t),t};S.prototype=Object.create(Function.prototype),S.prototype[pe]=!0,Object.defineProperty(S.prototype,"~standard",{get(){return{version:1,vendor:`schemastery`,validate:e=>{try{return{value:S.resolve(e,this,{})[0]}}catch(e){if(x.is(e))return{issues:[{message:e.message,path:e.options.path}]};throw e}}}}}),S.ValidationError=x,S.prototype.toJSON=function(){if(globalThis.__schemastery_refs__)return globalThis.__schemastery_refs__[this.uid]??=JSON.parse(JSON.stringify({...this})),this.uid;globalThis.__schemastery_refs__={[this.uid]:{...this}},globalThis.__schemastery_refs__[this.uid]=JSON.parse(JSON.stringify({...this}));let e={uid:this.uid,refs:globalThis.__schemastery_refs__};return globalThis.__schemastery_refs__=void 0,e},S.prototype.set=function(e,t){return this.dict[e]=t,this},S.prototype.push=function(e){return this.list.push(e),this};function he(e,t){let n=typeof e==`string`?{"":e}:{...e};for(let e in t){let r=t[e];r?.$description||r?.$desc?n[e]=r.$description||r.$desc:typeof r==`string`&&(n[e]=r)}return n}function ge(e){return e?.$value??e?.$inner}function _e(e){return b(e??{},e=>!e.startsWith(`$`))}S.prototype.i18n=function(e){let t=S(this),n=he(t.meta.description,e);return Object.keys(n).length&&(t.meta.description=n),t.dict&&=ee(t.dict,(t,n)=>t.i18n(ee(e,e=>ge(e)?.[n]??e?.[n]))),t.list&&=t.list.map((t,n)=>t.i18n(ee(e,(e={})=>Array.isArray(ge(e))?ge(e)[n]:Array.isArray(e)?e[n]:_e(e)))),t.inner&&=t.inner.i18n(ee(e,e=>ge(e)?ge(e):_e(e))),t.sKey&&=t.sKey.i18n(ee(e,e=>e?.$key)),t},S.prototype.extra=function(e,t){let n=S(this);return n.meta={...n.meta,[e]:t},n};for(let e of[`required`,`disabled`,`collapse`,`hidden`,`loose`])Object.assign(S.prototype,{[e](t=!0){let n=S(this);return n.meta={...n.meta,[e]:t},n}});S.prototype.deprecated=function(){let e=S(this);return e.meta.badges||=[],e.meta.badges.push({text:`deprecated`,type:`danger`}),e},S.prototype.experimental=function(){let e=S(this);return e.meta.badges||=[],e.meta.badges.push({text:`experimental`,type:`warning`}),e},S.prototype.pattern=function(e){let t=S(this),n=te(e,[`source`,`flags`]);return t.meta={...t.meta,pattern:n},t},S.prototype.simplify=function(e){if(ae(e)&&(e=e.get()),de(e,this.meta.default,this.type===`dict`))return null;if(v(e))return e;if(this.type===`object`||this.type===`dict`){let t={};for(let n in e){let r=(this.type===`object`?this.dict[n]:this.inner)?.simplify(e[n]);(this.type===`dict`||!v(r))&&(t[n]=r)}return de(t,this.meta.default,this.type===`dict`)?null:t}if(this.type===`array`||this.type===`tuple`){let t=[];return e.forEach((e,n)=>{let r=this.type===`array`?this.inner:this.list[n],i=r?r.simplify(e):e;t.push(i)}),t}if(this.type===`intersect`){let t={};for(let n of this.list)Object.assign(t,n.simplify(e));return t}if(this.type===`union`)for(let t of this.list)try{return S.resolve(e,t,{}),t.simplify(e)}catch{}return e},S.prototype.toString=function(e){return Ee[this.type]?.(this,e)??`Schema<${this.type}>`},S.prototype.role=function(e,t){let n=S(this);return n.meta={...n.meta,role:e,extra:t},n};for(let e of[`default`,`link`,`comment`,`description`,`max`,`min`,`step`])Object.assign(S.prototype,{[e](t){let n=S(this);return n.meta={...n.meta,[e]:t},n}});S.prototype.volatile=function(){if(this.meta.volatile)throw TypeError(`volatile schema is already wrapped`);return this.extra(`volatile`,!0)};let ve={},ye=Symbol(`checked-volatile-schema`);function be(e,t=[],n=!1,r=/* @__PURE__ */ new Map){let i=r.get(e)??/* @__PURE__ */ new Set;if(i.has(n))return;if(i.add(n),r.set(e,i),e.meta?.volatile&&n)throw new x(`volatile fields require a fixed object path without an enclosing volatile field`,{path:t});let a=n||!!e.meta?.volatile;if(e.dict)for(let[n,i]of Object.entries(e.dict))be(i,[...t,n],a,r);if(e.sKey&&be(e.sKey,[...t,`<key>`],!0,r),e.inner&&(e.type!==`lazy`||e.inner[pe])&&be(e.inner,[...t,`*`],!0,r),e.list)for(let n=0;n<e.list.length;n++)be(e.list[n],[...t,String(n)],!0,r)}S.extend=function(e,t){ve[e]=t},S.resolve=function(e,t,n={},r=!1){if(!t)return[e];if(n[ye]||(be(t,n.path),n={...n,[ye]:!0}),t.meta?.volatile){let i=S(t);i.meta={...t.meta,volatile:!1};let[a,o]=S.resolve(e,i,n,r);try{return[ie(a),o]}catch(e){throw new x(e instanceof Error?e.message:String(e),n)}}if(n.ignore?.(e,t))return[e];if(v(e)&&t.type!==`lazy`){if(t.meta.required)throw new x(`missing required value`,n);let r=t,i=t.meta.default;for(;r?.type===`intersect`&&v(i);)r=r.list[0],i=r?.meta.default;if(v(i))return[e];e=ue(i)}let i=ve[t.type];if(!i)throw new x(`unsupported type "${t.type}"`,n);try{return i(e,t,n,r)}catch(e){if(!t.meta.loose)throw e;return[t.meta.default]}},S.from=function(e){if(v(e))return S.any();if([`string`,`number`,`boolean`].includes(typeof e))return S.const(e).required();if(e[pe])return e;if(typeof e==`function`)switch(e){case String:return S.string().required();case Number:return S.number().required();case Boolean:return S.boolean().required();case Function:return S.function().required();default:return S.is(e).required()}else throw TypeError(`cannot infer schema from ${e}`)},S.lazy=function(e){let t=new S({type:`lazy`,builder:e,inner:{toJSON:()=>(t.inner[pe]||(t.inner=t.builder(),t.inner.meta={...t.meta,...t.inner.meta}),t.inner.toJSON())}});return t},S.natural=function(){return S.number().step(1).min(0)},S.percent=function(){return S.number().step(.01).min(0).max(1).role(`slider`)},S.date=function(){return S.union([S.is(Date),S.transform(S.string().role(`datetime`),(e,t)=>{let n=new Date(e);if(isNaN(+n))throw new x(`invalid date "${e}"`,t);return n},!0)])},S.regExp=function(e=``){return S.union([S.is(RegExp),S.transform(S.string().role(`regexp`,{flag:e}),(t,n)=>{try{return new RegExp(t,e)}catch(e){throw new x(e.message,n)}},!0)])},S.arrayBuffer=function(e){return S.union([S.is(ArrayBuffer),S.is(SharedArrayBuffer),S.transform(S.any(),(e,t)=>{if(le.isSource(e))return le.fromSource(e);throw new x(`expected ArrayBufferSource but got ${e}`,t)},!0),...e?[S.transform(S.string(),(t,n)=>{try{return e===`base64`?le.fromBase64(t):le.fromHex(t)}catch(e){throw new x(e.message,n)}},!0)]:[]])},S.extend(`lazy`,(e,t,n,r)=>(t.inner[pe]||(t.inner=t.builder(),t.inner.meta={...t.meta,...t.inner.meta},be(t.inner,n.path,!0)),S.resolve(e,t.inner,n,r))),S.extend(`any`,e=>[e]),S.extend(`never`,(e,t,n)=>{throw new x(`expected nullable but got ${e}`,n)}),S.extend(`const`,(e,{value:t},n)=>{if(de(e,t))return[t];throw new x(`expected ${t} but got ${e}`,n)});function xe(e,t,n,r,i=!1){let{max:a=1/0,min:o=-1/0}=t;if(e>a)throw new x(`expected ${n} <= ${a} but got ${e}`,r);if(e<o&&!i)throw new x(`expected ${n} >= ${o} but got ${e}`,r)}S.extend(`string`,(e,{meta:t},n)=>{if(typeof e!=`string`)throw new x(`expected string but got ${e}`,n);if(t.pattern){let r=new RegExp(t.pattern.source,t.pattern.flags);if(!r.test(e))throw new x(`expect string to match regexp ${r}`,n)}return xe(e.length,t,`string length`,n),[e]});function Se(e,t){let n=e.toString();if(n.includes(`e`))return e*10**t;let r=n.indexOf(`.`);if(r===-1)return e*10**t;let i=n.slice(r+1),a=n.slice(0,r);return i.length<=t?+(a+i.padEnd(t,`0`)):+(a+i.slice(0,t)+`.`+i.slice(t))}function Ce(e,t,n){if(n=Math.abs(n),!/^\d+\.\d+$/.test(n.toString()))return(e-t)%n===0;let r=n.toString().indexOf(`.`),i=n.toString().slice(r+1).length;return Math.abs(Se(e,i)-Se(t,i))%Se(n,i)===0}S.extend(`number`,(e,{meta:t},n)=>{if(typeof e!=`number`)throw new x(`expected number but got ${e}`,n);xe(e,t,`number`,n);let{step:r}=t;if(r&&!Ce(e,t.min??0,r))throw new x(`expected number multiple of ${r} but got ${e}`,n);return[e]}),S.extend(`boolean`,(e,t,n)=>{if(typeof e==`boolean`)return[e];throw new x(`expected boolean but got ${e}`,n)}),S.extend(`bitset`,(e,{bits:t,meta:n},r)=>{let i=0,a=[];if(typeof e==`number`){i=e;for(let n in t)e&t[n]&&a.push(n)}else if(Array.isArray(e)){a=e;for(let e of a){if(typeof e!=`string`)throw new x(`expected string but got ${e}`,r);e in t&&(i|=t[e])}}else throw new x(`expected number or array but got ${e}`,r);return i===n.default?[i]:[i,a]}),S.extend(`function`,(e,t,n)=>{if(typeof e==`function`)return[e];throw new x(`expected function but got ${e}`,n)}),S.extend(`is`,(e,{constructor:t},n)=>{if(typeof t==`function`){if(e instanceof t)return[e];throw new x(`expected ${t.name} but got ${e}`,n)}{if(v(e))throw new x(`expected ${t} but got ${e}`,n);let r=Object.getPrototypeOf(e);for(;r;){if(r.constructor?.name===t)return[e];r=Object.getPrototypeOf(r)}throw new x(`expected ${t} but got ${e}`,n)}});function we(e,t,n,r){try{let[i,a]=S.resolve(e[t],n,{...r,path:[...r.path||[],t]});return a!==void 0&&(e[t]=a),i}catch(i){if(!r?.autofix)throw i;return delete e[t],n.meta.volatile?ie(n.meta.default):n.meta.default}}S.extend(`array`,(e,{inner:t,meta:n},r)=>{if(!Array.isArray(e))throw new x(`expected array but got ${e}`,r);return xe(e.length,n,`array length`,r,!v(t.meta.default)),[e.map((n,i)=>we(e,i,t,r))]}),S.extend(`dict`,(e,{inner:t,sKey:n},r,i)=>{if(!y(e))throw new x(`expected object but got ${e}`,r);let a={};for(let o in e){let s;try{s=S.resolve(o,n,r)[0]}catch(e){if(i)continue;throw e}a[s]=we(e,o,t,r),e[s]=e[o],o!==s&&delete e[o]}return[a]}),S.extend(`tuple`,(e,{list:t},n,r)=>{if(!Array.isArray(e))throw new x(`expected array but got ${e}`,n);let i=t.map((t,r)=>we(e,r,t,n));return r||i.push(...e.slice(t.length)),[i]});function Te(e,t){for(let n in t)n in e||(e[n]=t[n])}S.extend(`object`,(e,{dict:t},n,r)=>{if(!y(e))throw new x(`expected object but got ${e}`,n);let i={};for(let r in t){let a=we(e,r,t[r],n);(!v(a)||r in e)&&(i[r]=a)}return r||Te(i,e),[i]}),S.extend(`union`,(e,{list:t,toString:n},r,i)=>{let a=[];for(let n of t)try{return S.resolve(e,n,r,i)}catch(e){a.push(e)}throw new x(`expected ${n()} but got ${JSON.stringify(e)}`,r)}),S.extend(`intersect`,(e,{list:t,toString:n},r,i)=>{if(!t.length)return[e];let a;for(let i of t){let t=S.resolve(e,i,r,!0)[0];if(!v(t)){if(v(a))a=t;else if(typeof a!=typeof t)throw new x(`expected ${n()} but got ${JSON.stringify(e)}`,r);else if(typeof t==`object`)Te(a??={},t);else if(a!==t)throw new x(`expected ${n()} but got ${JSON.stringify(e)}`,r)}}return!i&&y(e)&&Te(a,e),[a]}),S.extend(`transform`,(e,{inner:t,callback:n,preserve:r},i)=>{let[a,o=e]=S.resolve(e,t,i,!0);return r?[n(a)]:[n(a),n(o)]});let Ee={};function De(e,t,n){Ee[e]=n,Object.assign(S,{[e](...n){let r=new S({type:e});return t.forEach((e,t)=>{switch(e){case`sKey`:r.sKey=n[t]??S.string();break;case`inner`:r.inner=S.from(n[t]);break;case`list`:r.list=n[t].map(S.from);break;case`dict`:r.dict=ee(n[t],S.from);break;case`bits`:r.bits={};for(let e in n[t])typeof n[t][e]==`number`&&(r.bits[e]=n[t][e]);break;case`callback`:{let e=r.callback=n[t];e.toJSON||=()=>e.toString();break}case`constructor`:{let e=r.constructor=n[t];typeof e==`function`&&(e.toJSON||=()=>e.name);break}default:r[e]=n[t]}}),e===`object`||e===`dict`?r.meta.default={}:e===`array`||e===`tuple`?r.meta.default=[]:e===`bitset`&&(r.meta.default=0),r}})}De(`is`,[`constructor`],({constructor:e})=>typeof e==`function`?e.name:e),De(`any`,[],()=>`any`),De(`never`,[],()=>`never`),De(`const`,[`value`],({value:e})=>typeof e==`string`?JSON.stringify(e):e),De(`string`,[],()=>`string`),De(`number`,[],()=>`number`),De(`boolean`,[],()=>`boolean`),De(`bitset`,[`bits`],()=>`bitset`),De(`function`,[],()=>`function`),De(`array`,[`inner`],({inner:e})=>`${e.toString(!0)}[]`),De(`dict`,[`inner`,`sKey`],({inner:e,sKey:t})=>`{ [key: ${t.toString()}]: ${e.toString()} }`),De(`tuple`,[`list`],({list:e})=>`[${e.map(e=>e.toString()).join(`, `)}]`),De(`object`,[`dict`],({dict:e})=>Object.keys(e).length===0?`{}`:`{ ${Object.entries(e).map(([e,t])=>`${e}${t.meta.required?``:`?`}: ${t.toString()}`).join(`, `)} }`),De(`union`,[`list`],({list:e},t)=>{let n=e.map(({toString:e})=>e()).join(` | `);return t?`(${n})`:n}),De(`intersect`,[`list`],({list:e})=>`${e.map(e=>e.toString(!0)).join(` & `)}`),De(`transform`,[`inner`,`callback`,`preserve`],({inner:e},t)=>e.toString(t));let Oe={'"':`"`,"\\":`\\`,"/":`/`,b:`\b`,f:`\f`,n:`
2
+ `,r:`\r`,t:` `},ke=/[\\\u0000-\u001f]/u;function Ae(e){return e===` `||e===`
3
+ `||e===`\r`||e===` `}function je(e){return e>=`0`&&e<=`9`||e>=`a`&&e<=`f`||e>=`A`&&e<=`F`}(class e{static EMPTY=e.fromObject({});static fromText(t){let n=new e;return n.append(t),n.sealed=!0,n}static fromObject(t){let n=new e;return n.object=typeof t==`object`&&t&&!Array.isArray(t)?t:{},n.sealed=!0,n}chunks=[];object;sealed=!1;#e=[];#t=0;#n=0;#r=`root`;#i=!1;#a=0;#o=!1;#s=``;#c=null;#l=[];#u=!1;#d;#f=!1;#p=/* @__PURE__ */ new Map;#m=[];#h=/* @__PURE__ */ new Map;get isSealed(){return this.sealed}get invalid(){return this.scan(),this.#r===`invalid`||this.#f}append(e){if(this.sealed)throw Error(`PartialArguments: cannot append to a sealed view`);e.length!==0&&(this.chunks.push(e),this.#t+=e.length,this.#e.push(this.#t))}settle(t){if(this.object!==void 0||t.length!==this.#t)return e.fromText(t);let n=0;for(let r of this.chunks){if(!t.startsWith(r,n))return e.fromText(t);n+=r.length}return this.chunks=t.length===0?[]:[t],this.#e=t.length===0?[]:[t.length],this.sealed=!0,this}refresh(){if(this.#h.size===0)return!1;this.scan();let e=!1,t=!1;for(let n of this.#h.values())n.completion?t=!0:e=this.refreshRead(n)||e;if(t)for(let t of this.#h.values())t.completion&&(e=this.refreshRead(t)||e);return this.sealed&&this.#h.clear(),e}refreshRead(e){let t=e.answer();return!Object.is(t,e.last)&&(e.last=t,!0)}closed(){return this.remember(`closed`,``,()=>this.closedNow())}keys(){return this.remember(`keys`,``,()=>this.keysNow(),e=>e.length)}has(e){return this.remember(`has`,e,()=>this.hasNow(e))}complete(e){return this.remember(`complete`,e,()=>this.completeNow(e))}stringLength(e,t){let n=Math.max(1,Math.floor(t?.step??1)),r=t?.offset??0;return this.remember(`length:${n}:${r}`,e,()=>this.lengthNow(e),e=>e===void 0?void 0:Math.ceil((e+r)/n))}stringExceeds(e,t){let n=Math.max(0,Math.floor(t));return this.remember(`exceeds:${n}`,e,()=>(this.lengthNow(e,n+1)??0)>n)}text(e){return this.remember(`text`,e,()=>this.textNow(e))}textPrefix(e,t){let n=Math.max(1,Math.floor(t));return this.remember(`prefix:${n}`,e,()=>this.textPrefixNow(e,n))}value(e){return this.remember(`value`,e,()=>this.valueNow(e))}remember(e,t,n,r){this.scan();let i=n();if(!this.sealed){let a=`${e}/${t}`;this.#h.has(a)||this.#h.set(a,{completion:e===`complete`,answer:r===void 0?n:()=>r(n()),last:r===void 0?i:r(i)})}return i}closedNow(){return this.sealed||this.#r===`closed`||this.#r===`invalid`}keysNow(){return this.object===void 0?this.#m:Object.keys(this.object)}hasNow(e){return this.object===void 0?this.#p.has(e):Object.hasOwn(this.object,e)}completeNow(e){if(this.object!==void 0)return Object.hasOwn(this.object,e);let t=this.#p.get(e);return t!==void 0&&t.end>=0&&(t.kind===`string`?t.invalidAt===void 0:!t.invalid)}lengthNow(e,t=1/0){if(this.object!==void 0){let t=Object.hasOwn(this.object,e)?this.object[e]:void 0;return typeof t==`string`?t.length:void 0}let n=this.#p.get(e);if(n?.kind!==`string`)return;if(n.text!==void 0&&n.text.at===n.end)return n.text.length;let r=n.length??={at:n.start,length:0,text:``};return this.readString(n,r,t,!1),r.length}textNow(e){if(this.object!==void 0){let t=Object.hasOwn(this.object,e)?this.object[e]:void 0;return typeof t==`string`?t:void 0}let t=this.#p.get(e);if(t?.kind!==`string`)return;if(t.text===void 0&&t.end>=0&&t.needsDecoding&&t.invalidAt===void 0){let e;try{e=JSON.parse(`"${this.slice(t.start,t.end)}"`)}catch{}e!==void 0&&(t.text={at:t.end,length:e.length,text:e})}let n=t.text??={at:t.start,length:0,text:``};return this.readString(t,n,1/0,!0),n.text}textPrefixNow(e,t){if(this.object!==void 0){let n=Object.hasOwn(this.object,e)?this.object[e]:void 0;return typeof n==`string`?n.slice(0,t):void 0}let n=this.#p.get(e);if(n?.kind!==`string`)return;let r=n.prefixes??=/* @__PURE__ */ new Map,i=r.get(t);return i===void 0&&(i={at:n.start,length:0,text:``},r.set(t,i)),this.readString(n,i,t,!0),i.text}valueNow(e){if(this.object!==void 0){if(!Object.hasOwn(this.object,e))return;let t=this.object[e];return typeof t==`string`?void 0:t}let t=this.#p.get(e);if(!(t?.kind!==`value`||t.end<0||t.invalid)){if(t.parsed===void 0)try{t.parsed=JSON.parse(this.slice(t.start,t.end))}catch{t.invalid=!0,this.#f=!0}return t.parsed}}chunkAt(e){let t=0,n=this.#e.length;for(;t<n;){let r=t+n>>>1;this.#e[r]<=e?t=r+1:n=r}return t}slice(e,t){if(e>=t)return``;let n=this.chunkAt(e),r=this.chunkAt(t-1),i=n===0?0:this.#e[n-1];if(n===r)return this.chunks[n].slice(e-i,t-i);let a=[this.chunks[n].slice(e-i)];for(let e=n+1;e<r;e++)a.push(this.chunks[e]);return a.push(this.chunks[r].slice(0,t-this.#e[r-1])),a.join(``)}readString(e,t,n,r){let i=Math.min(e.end<0?this.#n:e.end,e.invalidAt??1/0,this.#d??1/0);if(!e.needsDecoding){let e=Math.min(i-t.at,n-t.length);if(e<=0)return;r&&(t.text+=this.slice(t.at,t.at+e)),t.at+=e,t.length+=e;return}let a=this.chunkAt(t.at);for(;t.at<i&&t.length<n;){let o=a===0?0:this.#e[a-1],s=this.chunks[a],c=s.slice(t.at-o,Math.min(s.length,i-o)),l=c.search(ke),u=Math.min(l<0?c.length:l,n-t.length);if(u>0){r&&(t.text+=c.slice(0,u)),t.at+=u,t.length+=u,t.at===o+s.length&&a++;continue}let d=c.length>1?c[1]:t.at+1<i?this.chunks[a+1][0]:void 0,f,p=2;if(c[0]===`\\`&&d===void 0&&e.end<0)return;if(c[0]===`\\`&&d===`u`){let n=this.slice(t.at+2,Math.min(i,t.at+6)),r=!0;for(let e=0;e<n.length;e++)je(n[e])||(r=!1);if(r){if(n.length<4&&e.end<0)return;n.length===4&&(f=String.fromCharCode(Number.parseInt(n,16)))}p=6}else c[0]===`\\`&&d!==void 0&&(f=Oe[d]);if(f===void 0){e.invalidAt=t.at,this.#f=!0;return}for(r&&(t.text+=f),t.length++,t.at+=p;a<this.chunks.length&&t.at>=this.#e[a];)a++}}scan(){if(this.object===void 0&&this.#n!==this.#t)for(let e=this.chunkAt(this.#n);e<this.chunks.length&&this.#d===void 0;e++){let t=this.chunks[e],n=e===0?0:this.#e[e-1];for(let e=this.#n-n;e<t.length&&this.#r!==`invalid`;e++){if(this.#r===`string`||this.#r===`nested`&&this.#u){let n=this.stringBoundary(t,e);if(this.#n+=n-e,e=n,e===t.length)break}this.step(t[e],this.#n),this.#n++}}}stringBoundary(e,t){let n=t;for(;;){let t=e.indexOf(`"`,n),r=t<0?e.length:t;if(this.#r===`string`){let t=this.#c;!t.needsDecoding&&ke.test(e.slice(n,r))&&(t.needsDecoding=!0)}let i=r;for(;i>n&&e[i-1]===`\\`;)i--;let a=(r-i)%2==1!==(i===n&&this.#i);if(this.#i=t<0&&a,t<0||!a)return r;n=t+1}}step(e,t){switch(this.#r){case`root`:if(Ae(e))return;if(e===`{`){this.#r=`key-or-end`;return}this.fail();return;case`key-or-end`:if(Ae(e))return;if(e===`}`){this.#r=`closed`;return}if(e===`"`){this.beginKey(t);return}this.fail();return;case`key-only`:if(Ae(e))return;if(e===`"`){this.beginKey(t);return}this.fail();return;case`key`:this.stepKey(e,t);return;case`colon`:if(Ae(e))return;if(e===`:`){this.#r=`value`;return}this.fail();return;case`value`:this.beginValue(e,t);return;case`string`:{let e=this.#c;e.end=t,this.#c=null,this.#r=`comma-or-end`;return}case`scalar`:this.stepScalar(e,t);return;case`nested`:this.stepNested(e,t);return;case`comma-or-end`:if(Ae(e))return;if(e===`,`){this.#r=`key-only`;return}if(e===`}`){this.#r=`closed`;return}this.fail();return;case`closed`:if(Ae(e))return;this.fail();return;
4
4
  /* v8 ignore next 2 -- scan() stops stepping once the view is invalid. */
5
5
  case`invalid`:return;
6
6
  /* v8 ignore next 2 -- Every scanner mode has a handler above. */
7
- default:je(this.#r)}}fail(){this.#d=this.#n,this.#r=`invalid`,this.#c=null}beginKey(e){this.#r=`key`,this.#a=e+1,this.#o=!1,this.#i=!1}stepKey(e,t){if(e<` `){this.fail();return}if(this.#i){this.#i=!1;return}if(e===`\\`){this.#i=!0,this.#o=!0;return}if(e!==`"`)return;let n=this.slice(this.#a,t);if(this.#o)try{this.#s=JSON.parse(`"${n}"`)}catch{this.fail();return}else this.#s=n;this.#r=`colon`}open(e){this.#p.has(this.#s)||this.#m.push(this.#s),this.#p.set(this.#s,e),this.#c=e}beginValue(e,t){ke(e)||(e===`"`?(this.open({kind:`string`,start:t+1,end:-1,needsDecoding:!1,invalidAt:void 0,length:void 0,text:void 0,prefixes:void 0}),this.#i=!1,this.#r=`string`):e===`}`||e===`,`||e===`:`||e===`]`?this.fail():(this.open({kind:`value`,start:t,end:-1,parsed:void 0,invalid:!1}),e===`{`||e===`[`?(this.#r=`nested`,this.#l=[e===`{`?`}`:`]`],this.#u=!1,this.#i=!1):this.#r=`scalar`))}stepScalar(e,t){(e===`,`||e===`}`||ke(e))&&(this.closeValue(t),this.#r=e===`,`?`key-only`:e===`}`?`closed`:`comma-or-end`)}stepNested(e,t){if(this.#u)this.#u=!1;else if(e===`"`)this.#u=!0;else if(e===`{`||e===`[`)this.#l.push(e===`{`?`}`:`]`);else if(e===`}`||e===`]`){if(this.#l.pop()!==e){this.fail();return}this.#l.length===0&&(this.closeValue(t+1),this.#r=`comma-or-end`)}}closeValue(e){let t=this.#c;t.end=e,this.#c=null}});function je(e,t){let n=JSON.stringify(e)??String(e);throw Error(`unreachable variant${t?` in ${t}`:``}: ${n}`)}var Me=class{keys=/* @__PURE__ */ new WeakMap;valueSet=/* @__PURE__ */ new Set;values=this.valueSet;get(e){return this.keys.get(e)}has(e){return this.keys.has(e)}set(e,t){if(this.keys.has(e)){let n=this.keys.get(e);if(n===t)return this;this.valueSet.delete(n)}return this.keys.set(e,t),this.valueSet.add(t),this}delete(e){if(!this.keys.has(e))return!1;let t=this.keys.get(e),n=this.keys.delete(e);return this.valueSet.delete(t),n}clear(){this.keys=/* @__PURE__ */ new WeakMap,this.valueSet.clear()}};function Ne(e,t,n){let r=t.data.header,i=r.tools,a={config:r.config,system:n?.text??``,tools:Array.isArray(i)?i:[]};if(e===void 0&&t.data.reason!==`initial`)return{prompt:a};let o=e!==void 0&&e.system!==a.system&&n?.update!==!0,s=e!==void 0&&JSON.stringify(e.tools)!==JSON.stringify(a.tools);if(e!==void 0&&!o&&!s)return{prompt:a};let c=n!==void 0&&(e===void 0||o)?n:t;return{prompt:a,change:{seq:c.seq,time:c.time,kind:e===void 0?`initial`:o&&s?`system-and-tools`:o?`system`:`tools`,...e===void 0?{}:{previous:e}}}}let Pe=/* @__PURE__ */ new Set([`system/message`,`developer/message`,`user/message`,`assistant/message`,`tool/result`]);function Fe(e){return Pe.has(e.type)?e.surfaceOp!==void 0:!1}function Ie(e,t){let n=Fe(t)?t.surfaceOp:void 0,r=e?.firstSeq??t.seq,i=e?.nodes??[],a=e?.replacements??/* @__PURE__ */ new Map,o=e=>e<r&&!a.has(e),s=e?.uncertain===!0||n!==void 0&&n!==`append`&&(o(n.startSeq)||o(n.endSeq));if(s)return{firstSeq:r,uncertain:s,nodes:[],replacements:/* @__PURE__ */ new Map,effective:void 0,introduced:void 0};let c=t.seq;if(n!==void 0&&n!==`append`){c=a.get(n.startSeq)??n.startSeq;let e=a.get(n.endSeq)??n.endSeq;i=i.filter(t=>t.position<c||t.position>e);let r=new Map([...a].filter(([,t])=>t<c||t>e));r.set(t.seq,c),a=r}let l=t.type===`system/message`?{seq:t.seq,time:t.time,turn:t.data.turn,step:t.data.step,text:t.data.message.content.flatMap(e=>e.type===`text`?[e.text]:[]).join(``),update:n===`append`&&e?.nodes.some(e=>e.node.text!==``)===!0}:void 0;l!==void 0&&(i=[...i,{position:c,node:l}].sort((e,t)=>e.position-t.position));let u=i.findLast(e=>e.node.text!==``)?.node,d=u===e?.nodes.findLast(e=>e.node.text!==``)?.node?e?.effective:l!==void 0&&l===u?l:{seq:t.seq,time:t.time,turn:u?.turn??0,step:u?.step??0,text:u?.text??``,update:!1};return{firstSeq:r,uncertain:s,nodes:i,replacements:a,effective:d,introduced:l}}function Le(e,t){return`${e.length}:${e}${t}`}function w(e){return e.type===`assistant/live-chunk`?-e.order:e.seq}function Re(e,t){return e.seq-t.seq||(e.type===`assistant/live-chunk`?e.order:0)-(t.type===`assistant/live-chunk`?t.order:0)}function ze(e,t){return e.key===t.key&&e.groupPart===t.groupPart}function Be(e,t){return e.kind===t.kind&&e.key===t.key&&(e.kind===`group`||t.kind===`node`&&e.groupPart===t.groupPart)}function Ve(e,t,n){return e===t||e.length===t.length&&e.every((e,r)=>n(e,t[r]))?e:t}var He=class{root=[];rootGroups=/* @__PURE__ */ new Set;groups=/* @__PURE__ */ new Map;placements=/* @__PURE__ */ new Map;sources=/* @__PURE__ */ new Map;dirty=/* @__PURE__ */ new Set;get entries(){return this.root}groupSource(e){let t=this.sources.get(e);if(t===void 0){let n=(0,f.createSnapshotStore)(this.groups.get(e));t={publication:n,observable:{getSnapshot:()=>this.groups.get(e),subscribe:e=>n.subscribe(e)}},this.sources.set(e,t)}return t.observable}prepareAndInstall(e,t){let n=e.entries===void 0?this.root:Ve(this.root,e.entries,Be),r=n===this.root?this.rootGroups:this.collectRootGroups(n),{upserts:i,removes:a}=this.collectChanges(e),o=e.groups.kind===`replace`;if(this.groups.size-a.size+[...i.keys()].filter(e=>!this.groups.has(e)).length!==r.size)throw Error(`conversation group records and root references must correspond one-to-one`);for(let e of a)if(r.has(e))throw Error(`conversation group "${e}" is still referenced`);for(let e of i.keys())if(!r.has(e))throw Error(`conversation group "${e}" has no root reference`);if(r!==this.rootGroups){for(let e of r)if(!i.has(e)&&!this.groups.has(e))throw Error(`conversation root references missing group "${e}"`)}let s=/* @__PURE__ */ new Map,c=e=>{let t=s.get(e);return t===void 0&&(t=new Set(this.placements.get(e)),s.set(e,t)),t},l=e=>{c(e.key).delete(e.groupPart)},u=e=>{if(t(e.key)===void 0)throw Error(`conversation group references missing Node "${e.key}"`);let n=c(e.key);if(n.has(e.groupPart)||e.groupPart===void 0&&n.size>0||n.has(void 0))throw Error(`conversation Node "${e.key}" has overlapping rendering positions`);n.add(e.groupPart)};if(o||n!==this.root)for(let e of this.root)e.kind===`node`&&l(e);for(let e of a)for(let t of this.groups.get(e).members)l(t);for(let[e,t]of i){let n=this.groups.get(e);if(n!==void 0&&(o||n.members!==t.members))for(let e of n.members)l(e)}if(o||n!==this.root)for(let e of n)e.kind===`node`&&u(e);for(let[e,t]of i)if(o||this.groups.get(e)?.members!==t.members)for(let e of t.members)u(e);for(let[e,t]of s)t.size===0?this.placements.delete(e):this.placements.set(e,t);for(let e of a)this.groups.delete(e),this.dirty.add(e);for(let[e,t]of i)this.groups.get(e)!==t&&(this.groups.set(e,t),this.dirty.add(e));this.root=n,this.rootGroups=r}publish(){let e=[...this.dirty];this.dirty.clear();for(let t of e)this.sources.get(t)?.publication.set(this.groups.get(t))}clear(){this.prepareAndInstall({entries:[],groups:{kind:`replace`,snapshots:[]}},
7
+ default:Me(this.#r)}}fail(){this.#d=this.#n,this.#r=`invalid`,this.#c=null}beginKey(e){this.#r=`key`,this.#a=e+1,this.#o=!1,this.#i=!1}stepKey(e,t){if(e<` `){this.fail();return}if(this.#i){this.#i=!1;return}if(e===`\\`){this.#i=!0,this.#o=!0;return}if(e!==`"`)return;let n=this.slice(this.#a,t);if(this.#o)try{this.#s=JSON.parse(`"${n}"`)}catch{this.fail();return}else this.#s=n;this.#r=`colon`}open(e){this.#p.has(this.#s)||this.#m.push(this.#s),this.#p.set(this.#s,e),this.#c=e}beginValue(e,t){Ae(e)||(e===`"`?(this.open({kind:`string`,start:t+1,end:-1,needsDecoding:!1,invalidAt:void 0,length:void 0,text:void 0,prefixes:void 0}),this.#i=!1,this.#r=`string`):e===`}`||e===`,`||e===`:`||e===`]`?this.fail():(this.open({kind:`value`,start:t,end:-1,parsed:void 0,invalid:!1}),e===`{`||e===`[`?(this.#r=`nested`,this.#l=[e===`{`?`}`:`]`],this.#u=!1,this.#i=!1):this.#r=`scalar`))}stepScalar(e,t){(e===`,`||e===`}`||Ae(e))&&(this.closeValue(t),this.#r=e===`,`?`key-only`:e===`}`?`closed`:`comma-or-end`)}stepNested(e,t){if(this.#u)this.#u=!1;else if(e===`"`)this.#u=!0;else if(e===`{`||e===`[`)this.#l.push(e===`{`?`}`:`]`);else if(e===`}`||e===`]`){if(this.#l.pop()!==e){this.fail();return}this.#l.length===0&&(this.closeValue(t+1),this.#r=`comma-or-end`)}}closeValue(e){let t=this.#c;t.end=e,this.#c=null}});function Me(e,t){let n=JSON.stringify(e)??String(e);throw Error(`unreachable variant${t?` in ${t}`:``}: ${n}`)}var Ne=class{keys=/* @__PURE__ */ new WeakMap;valueSet=/* @__PURE__ */ new Set;values=this.valueSet;get(e){return this.keys.get(e)}has(e){return this.keys.has(e)}set(e,t){if(this.keys.has(e)){let n=this.keys.get(e);if(n===t)return this;this.valueSet.delete(n)}return this.keys.set(e,t),this.valueSet.add(t),this}delete(e){if(!this.keys.has(e))return!1;let t=this.keys.get(e),n=this.keys.delete(e);return this.valueSet.delete(t),n}clear(){this.keys=/* @__PURE__ */ new WeakMap,this.valueSet.clear()}};function Pe(e,t,n){let r=t.data.header,i=r.tools,a={config:r.config,system:n?.text??``,tools:Array.isArray(i)?i:[]};if(e===void 0&&t.data.reason!==`initial`)return{prompt:a};let o=e!==void 0&&e.system!==a.system&&n?.update!==!0,s=e!==void 0&&JSON.stringify(e.tools)!==JSON.stringify(a.tools);if(e!==void 0&&!o&&!s)return{prompt:a};let c=n!==void 0&&(e===void 0||o)?n:t;return{prompt:a,change:{seq:c.seq,time:c.time,kind:e===void 0?`initial`:o&&s?`system-and-tools`:o?`system`:`tools`,...e===void 0?{}:{previous:e}}}}let Fe=/* @__PURE__ */ new Set([`system/message`,`developer/message`,`user/message`,`assistant/message`,`tool/result`]);function Ie(e){return Fe.has(e.type)?e.surfaceOp!==void 0:!1}function Le(e,t){let n=Ie(t)?t.surfaceOp:void 0,r=e?.firstSeq??t.seq,i=e?.nodes??[],a=e?.replacements??/* @__PURE__ */ new Map,o=e=>e<r&&!a.has(e),s=e?.uncertain===!0||n!==void 0&&n!==`append`&&(o(n.startSeq)||o(n.endSeq));if(s)return{firstSeq:r,uncertain:s,nodes:[],replacements:/* @__PURE__ */ new Map,effective:void 0,introduced:void 0};let c=t.seq;if(n!==void 0&&n!==`append`){c=a.get(n.startSeq)??n.startSeq;let e=a.get(n.endSeq)??n.endSeq;i=i.filter(t=>t.position<c||t.position>e);let r=new Map([...a].filter(([,t])=>t<c||t>e));r.set(t.seq,c),a=r}let l=t.type===`system/message`?{seq:t.seq,time:t.time,turn:t.data.turn,step:t.data.step,text:t.data.message.content.flatMap(e=>e.type===`text`?[e.text]:[]).join(``),update:n===`append`&&e?.nodes.some(e=>e.node.text!==``)===!0}:void 0;l!==void 0&&(i=[...i,{position:c,node:l}].sort((e,t)=>e.position-t.position));let u=i.findLast(e=>e.node.text!==``)?.node,d=u===e?.nodes.findLast(e=>e.node.text!==``)?.node?e?.effective:l!==void 0&&l===u?l:{seq:t.seq,time:t.time,turn:u?.turn??0,step:u?.step??0,text:u?.text??``,update:!1};return{firstSeq:r,uncertain:s,nodes:i,replacements:a,effective:d,introduced:l}}function Re(e,t){return`${e.length}:${e}${t}`}function C(e){return e.type===`assistant/live-chunk`?-e.order:e.seq}function ze(e,t){return e.seq-t.seq||(e.type===`assistant/live-chunk`?e.order:0)-(t.type===`assistant/live-chunk`?t.order:0)}function Be(e,t){return e.key===t.key&&e.groupPart===t.groupPart}function Ve(e,t){return e.kind===t.kind&&e.key===t.key&&(e.kind===`group`||t.kind===`node`&&e.groupPart===t.groupPart)}function He(e,t,n){return e===t||e.length===t.length&&e.every((e,r)=>n(e,t[r]))?e:t}var Ue=class{root=[];rootGroups=/* @__PURE__ */ new Set;groups=/* @__PURE__ */ new Map;placements=/* @__PURE__ */ new Map;sources=/* @__PURE__ */ new Map;dirty=/* @__PURE__ */ new Set;get entries(){return this.root}groupSource(e){let t=this.sources.get(e);if(t===void 0){let n=(0,f.createSnapshotStore)(this.groups.get(e));t={publication:n,observable:{getSnapshot:()=>this.groups.get(e),subscribe:e=>n.subscribe(e)}},this.sources.set(e,t)}return t.observable}prepareAndInstall(e,t){let n=e.entries===void 0?this.root:He(this.root,e.entries,Ve),r=n===this.root?this.rootGroups:this.collectRootGroups(n),{upserts:i,removes:a}=this.collectChanges(e),o=e.groups.kind===`replace`;if(this.groups.size-a.size+[...i.keys()].filter(e=>!this.groups.has(e)).length!==r.size)throw Error(`conversation group records and root references must correspond one-to-one`);for(let e of a)if(r.has(e))throw Error(`conversation group "${e}" is still referenced`);for(let e of i.keys())if(!r.has(e))throw Error(`conversation group "${e}" has no root reference`);if(r!==this.rootGroups){for(let e of r)if(!i.has(e)&&!this.groups.has(e))throw Error(`conversation root references missing group "${e}"`)}let s=/* @__PURE__ */ new Map,c=e=>{let t=s.get(e);return t===void 0&&(t=new Set(this.placements.get(e)),s.set(e,t)),t},l=e=>{c(e.key).delete(e.groupPart)},u=e=>{if(t(e.key)===void 0)throw Error(`conversation group references missing Node "${e.key}"`);let n=c(e.key);if(n.has(e.groupPart)||e.groupPart===void 0&&n.size>0||n.has(void 0))throw Error(`conversation Node "${e.key}" has overlapping rendering positions`);n.add(e.groupPart)};if(o||n!==this.root)for(let e of this.root)e.kind===`node`&&l(e);for(let e of a)for(let t of this.groups.get(e).members)l(t);for(let[e,t]of i){let n=this.groups.get(e);if(n!==void 0&&(o||n.members!==t.members))for(let e of n.members)l(e)}if(o||n!==this.root)for(let e of n)e.kind===`node`&&u(e);for(let[e,t]of i)if(o||this.groups.get(e)?.members!==t.members)for(let e of t.members)u(e);for(let[e,t]of s)t.size===0?this.placements.delete(e):this.placements.set(e,t);for(let e of a)this.groups.delete(e),this.dirty.add(e);for(let[e,t]of i)this.groups.get(e)!==t&&(this.groups.set(e,t),this.dirty.add(e));this.root=n,this.rootGroups=r}publish(){let e=[...this.dirty];this.dirty.clear();for(let t of e)this.sources.get(t)?.publication.set(this.groups.get(t))}clear(){this.prepareAndInstall({entries:[],groups:{kind:`replace`,snapshots:[]}},
8
8
  /* v8 ignore next -- an empty replacement never reads a Node reference. */
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=Ve(n.members,e.members,ze);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;
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:je(e.groups)}return{upserts:t,removes:n}}},Ue=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}`))}},We=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 Ue(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 Ge={kind:`session`},Ke={kind:`unresolved`};function qe(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 Je(e,t){return e.length===t.length&&e.every((e,n)=>e===t[n])}function Ye(e,t){return e!==void 0&&e.start===t.start&&e.end===t.end&&e.status===t.status&&e.data===t.data}function Xe(e,t){return e!==void 0&&e.start===t.start&&e.end===t.end&&e.status===t.status&&e.data===t.data&&Je(e.steps,t.steps)}function Ze(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 Qe=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($e(i.turn,et(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($e(i.turn,et(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(w(e))?.location??Ge}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=qe(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(w(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 Ye(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,Xe(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=w(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=w(n);Ze(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=qe(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=Ye(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=Xe(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,Ze(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=w(e),n=qe(e);if(n.session===!0){this.coordinates.set(t,{location:Ge});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=w(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($e(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 We(t=>{this.dirtyDataStores.add(t),this.changedTurns.add(e)})}storeFor(e){return e.kind===`turn`?this.mutableTurnData(e.turn):this.mutableStepData($e(e.turn,et(e)))}resolve(e){let t=this.coordinates.get(e);if(t?.turn===void 0)return Ge;let n=this.timeline.turns.get(t.turn);if(n===void 0)return Ke;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 $e(e,t){return`${e}:${t}`}function et(e){if(e.kind===`step`&&e.step!==void 0)return e.step;throw Error(`conversation Step data "${e.key}" requires a step`)}let tt={none:0,"animation-frame":1,immediate:2},nt=[`step`,`turn`];function rt(){return{step:null,turn:null}}function it(e,t){return tt[e]>=tt[t]?e:t}function at(e,t){return e.start===void 0?t.start===void 0?0:1:t.start===void 0?-1:Re(e.start.event,t.start.event)}function ot(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&&Re(a.event,t)<0?n=i+1:r=i}return n}function st(e){return{key:e.key,kind:e.kind,id:e.id,matches:e.matches,start:e.start,state:e.state,current:e.current}}function ct(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:Re(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 lt(e,t,n){return{event:e.event,role:t,location:n}}let ut={entries:()=>[],forTarget:()=>void 0};var dt=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 Qe;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=ut){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)=>Re(e.event,t.event));for(let e of n)this.inputs.set(w(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=w(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`&&ft(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=it(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=>w(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(w(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=it(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(w(e.event))).sort((e,t)=>Re(e.event,t.event));for(let e of i)this.inputs.set(w(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=it(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)=>Re(e.event,t.event))}matchInput(e){return this.dispatchInput(e,this.acceptMatch)}collectInput(e,t){return this.dispatchInput(e,(e,n,r)=>{let i=Le(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??=lt(e,t,a):i??=lt(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=it(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=it(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=it(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:rt(),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:Le(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&&Re(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=st(a);a.state=pt(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=w(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)=>Re(e.event,t.event));i.matches=ct(i.key,a,i.matches),t.add(i),this.markDirty(i)}}replayContexts(e){this.refreshStarts(e);let t=[...e].sort(at);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=pt(e.definition,`start`,e.definition.start(st(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=st(e);e.state=pt(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=ot(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||at(r,e)<0?n.push(e):n.splice(ot(n,t.event),0,e),this.contextsByKind.set(e.kind,n)}indexStartedContexts(e,t){if(t.length===0)return;let n=[...t].sort(at),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&&at(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(at);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(w(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(st(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 He});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(st(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 nt){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 nt){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 ft(e){return e===`turn/start`||e===`turn/end`||e===`step/start`||e===`step/end`}function pt(e,t,n){if(n===void 0)throw Error(`conversation Definition "${e.kind}" returned undefined from ${t}()`);return n}var mt=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`)}},ht=class extends mt{fallback;routes=/* @__PURE__ */ new Map;unrestricted=/* @__PURE__ */ new Set;tables=/* @__PURE__ */ new WeakMap;register(e){return gt(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(gt(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 gt(e){if(e.target===void 0!=(e.buildViewNode===void 0))throw Error(`conversation Definition "${e.kind}" must declare target and buildViewNode together`)}function _t(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 vt(){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 yt=class{sessions;maxEntries;maxBytes;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;disposed=!1;constructor(e,t,n={}){this.sessions=t,this.maxEntries=Math.max(1,Math.floor(n.maxEntries??32)),this.maxBytes=Math.max(1,Math.floor(n.maxBytes??25165824)),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=bt(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 t=this.byKey.get(i);if(t!==void 0)return this.touch(t),t.url;let n;if(typeof URL.createObjectURL!=`function`)n=`data:${e.value.attachment.mediaType};base64,${_t(e.value.data)}`;else{let t=Uint8Array.from(e.value.data);n=URL.createObjectURL(new Blob([t.buffer],{type:e.value.attachment.mediaType}))}let r=wt(e.value.data.byteLength);return this.insertRecord(i,n,r).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=bt(e,t.attachmentId),r=wt(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=this.insertRecord(n,a,r);return this.indexUploadedFallbacks(e,t.attachmentId,t.name,r,o),!0}aliasUploaded(e,t,n){if(this.disposed||this.sessions.binding(e)===void 0)return!1;let r=this.byKey.get(bt(e,t));return r!==void 0&&(this.bindKey(bt(e,n.attachmentId),r),this.clearPendingNameIndexes(r),this.touch(r),!0)}clearPendingUploaded(e,t){if(this.disposed)return;let n=this.byKey.get(bt(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=bt(e,t.attachmentId),a=this.byKey.get(i);if(a!==void 0)return this.touch(a),!1;let o=wt(r??t.bytes);return this.insertRecord(i,n,o),!0}lookup(e,t,n){let r=bt(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(xt(e,n));if(r!==void 0)return{record:r,consumedPendingName:!0};let i=wt(t.bytes);if(i>0){let t=Dt(this.byNameBytes.get(St(e,n,i)));if(t!==void 0)return{record:t,consumedPendingName:!0}}if(i===0){let t=Dt(this.byPendingName.get(Ct(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=xt(e,n);this.byLeaf.set(t,i),i.leafKeys.add(t)}}if(n!==void 0&&n!==``){if(r>0){let t=St(e,n,r);Tt(this.byNameBytes,t,i),i.nameBytesKeys.add(t)}let t=Ct(e,n);Tt(this.byPendingName,t,i),i.pendingNameKeys.add(t)}}insertRecord(e,t,n){let r={url:t,bytes:n,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,r),this.lru.add(r),this.totalBytes+=n,this.enforceBudget(r),r}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)break;t!==e&&this.deleteRecord(t)}}clearPendingNameIndexes(e){for(let t of e.pendingNameKeys)Et(this.byPendingName,t,e);e.pendingNameKeys.clear()}deleteRecord(e){if(this.lru.delete(e)){this.totalBytes=Math.max(0,this.totalBytes-e.bytes);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)Et(this.byNameBytes,t,e);e.nameBytesKeys.clear(),this.clearPendingNameIndexes(e),this.releaseUrl(e.url)}}releaseUrl(e){this.urls.delete(e)&&Ot(e)}dispose(){if(!this.disposed){this.disposed=!0,this.inflight.clear();for(let e of this.urls)Ot(e);this.urls.clear(),this.lru.clear(),this.byKey.clear(),this.byLeaf.clear(),this.byNameBytes.clear(),this.byPendingName.clear(),this.totalBytes=0}}};function bt(e,t){return`${e}\0${t}`}function xt(e,t){return`${e}\0${t}`}function St(e,t,n){return`${e}\0${n}\0${t}`}function Ct(e,t){return`${e}\0${t}`}function wt(e){return typeof e==`number`&&Number.isFinite(e)&&e>0?Math.floor(e):0}function Tt(e,t,n){let r=e.get(t);r===void 0&&(r=/* @__PURE__ */ new Set,e.set(t,r)),r.add(n)}function Et(e,t,n){let r=e.get(t);r!==void 0&&(r.delete(n),r.size===0&&e.delete(t))}function Dt(e){if(e!==void 0&&e.size===1)return e.values().next().value}function Ot(e){e.startsWith(`blob:`)&&URL.revokeObjectURL(e)}var kt=class extends mt{register(e){return this.registerDefinition(e.target,e,`conversation view target "${e.target}" is already registered`,`uiConversation.views.register(${JSON.stringify(e.target)})`)}},At=class extends mt{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)}},jt=class{assembler;snapshot;openTurn;viewStore;targetSources=/* @__PURE__ */ new Map;revision=-1;frame;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.snapshot.set(this.currentSnapshot()),this.openTurn.set(this.assembler.openTurn())}rebuild(){this.publish(this.assembler.rebuildRegistry())}dispose(){this.cancelFrame(),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(e!==`none`){if(e===`animation-frame`&&typeof requestAnimationFrame==`function`){if(this.frame!==void 0)return;this.frame=requestAnimationFrame(()=>{this.frame=requestAnimationFrame(()=>{this.frame=requestAnimationFrame(()=>{this.frame=void 0,this.flush()})})})}else this.cancelFrame(),this.flush()}}cancelFrame(){this.frame!==void 0&&typeof cancelAnimationFrame==`function`&&cancelAnimationFrame(this.frame),this.frame=void 0}flush(){this.assembler.flush()&&this.snapshot.set(this.currentSnapshot()),this.openTurn.set(this.assembler.openTurn())}currentSnapshot(){return{views:this.viewStore,activeTargets:this.assembler.activityTargets()}}},Mt=class extends m.Service{sessions;events;views;groups;bindings=new Me;images;constructor(e,t){super(e,`uiConversation`),this.sessions=t,this.events=new ht(e),this.views=new kt(e),this.groups=new At(e,this.views),this.images=new yt(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 jt(n.eventSource,new dt(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 Ie(e,t)}inspectRequestPrompt(e,t,n){return Ne(e,t,n)}drop(e,t){this.bindings.get(e.source)===e&&(this.bindings.delete(e.source),e.binding.dispose(),t&&e.disposeScope())}};function Nt(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 Pt(e,t=`|`){return e.map(e=>cn(e)).join(t)}function Ft(e,t){return typeof t==`bigint`?t.toString():t}var It=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 Lt(e){return new It(e)}function Rt(e){return e==null}function zt(e){let t=+!!e.startsWith(`^`),n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function Bt(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 Vt=/* @__PURE__*/ Symbol(`evaluating`);function Ht(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==Vt)return r===void 0&&(r=Vt,r=n()),r},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function Ut(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function Wt(e){let t=Object.getOwnPropertyDescriptor(e,`shape`);return t?.get?t.get.raw:t?.value}function Gt(e){return Wt(e._zod.def)??e._zod.def.shape}function Kt(e,t,n){Object.defineProperty(e,t,{get(){let e=n();return Ut(this,t,e),e},enumerable:!0,configurable:!0})}function qt(e,t,n){t in e?Ut(e,t,n):e[t]=n}function Jt(e,t,n,r){let i=Gt(t);for(let a of n){let n=Object.getOwnPropertyDescriptor(i,a);n.enumerable&&(n.get?Kt(e,a,()=>{let e=t._zod.def.shape[a];return r?r(e,a):e}):qt(e,a,r?r(n.value,a):n.value))}}function Yt(e,t){for(let n of Reflect.ownKeys(t)){let r=Object.getOwnPropertyDescriptor(t,n);r.enumerable&&(r.get?Kt(e,n,()=>t[n]):qt(e,n,r.value))}}function Xt(...e){let t={};for(let n of e){let e=Object.getOwnPropertyDescriptors(n);Object.assign(t,e)}return Object.defineProperties({},t)}function Zt(e){return JSON.stringify(e)}function Qt(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,``).replace(/[\s_-]+/g,`-`).replace(/^-+|-+$/g,``)}let $t=`captureStackTrace`in Error?Error.captureStackTrace:(...e)=>{};function en(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}let tn=/* @__PURE__*/ Lt(()=>{if(Zn.jitless||typeof navigator<`u`&&navigator?.userAgent?.includes(`Cloudflare`))return!1;try{return Function(``),!0}catch{return!1}});function nn(e){if(en(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!=`function`)return!0;let n=t.prototype;return en(n)!==!1&&Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)!==!1}function rn(e){return nn(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}let an=/* @__PURE__*/ new Set([`string`,`number`,`symbol`]);function on(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function sn(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function T(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 cn(e){return typeof e==`bigint`?e.toString()+`n`:typeof e==`string`?`"${e}"`:`${e}`}function ln(e){return Object.keys(e).filter(t=>e[t]._zod.optin!==void 0&&e[t]._zod.optout===`optional`)}let un={safeint:[-(2**53-1),2**53-1],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},dn={int64:[/* @__PURE__*/ BigInt(`-9223372036854775808`),/* @__PURE__*/ BigInt(`9223372036854775807`)],uint64:[/* @__PURE__*/ BigInt(0),/* @__PURE__*/ BigInt(`18446744073709551615`)]};function fn(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 Jt(i,e,pn(e,t)),sn(e,Xt(n,{shape:i,checks:[]}))}function pn(e,t){let n=Gt(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 mn(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(pn(e,t)),a={};return Jt(a,e,Reflect.ownKeys(Gt(e)).filter(e=>!i.has(e))),sn(e,Xt(n,{shape:a,checks:[]}))}function hn(e,t){if(!nn(t))throw Error(`Invalid input to extend: expected a plain object`);let n=e._zod.def.checks;if(n&&n.length>0){let n=Gt(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 sn(e,Xt(e._zod.def,{shape:gn(e,t)}))}function gn(e,t){let n={};return Jt(n,e,Reflect.ownKeys(Gt(e))),Yt(n,t),n}function _n(e,t){if(!nn(t))throw Error(`Invalid input to safeExtend: expected a plain object`);return sn(e,Xt(e._zod.def,{shape:gn(e,t)}))}function vn(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 Jt(n,e,Reflect.ownKeys(Gt(e))),Jt(n,t,Reflect.ownKeys(Gt(t))),sn(e,Xt(e._zod.def,{shape:n,get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]}))}function yn(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(pn(t,n)):void 0,o={};return Jt(o,t,Reflect.ownKeys(Gt(t)),e&&((t,n)=>a&&!a.has(n)?t:new e({type:`optional`,innerType:t}))),sn(t,Xt(t._zod.def,{shape:o,checks:[]}))}function bn(e,t,n){let r=n?new Set(pn(t,n)):void 0,i={};return Jt(i,t,Reflect.ownKeys(Gt(t)),(t,n)=>r&&!r.has(n)?t:new e({type:`nonoptional`,innerType:t})),sn(t,Xt(t._zod.def,{shape:i}))}function xn(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 Sn(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 Cn(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function wn(e){return typeof e==`string`?e:e?.message}function Tn(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 En(e,t,n){var r;for(let i=t;i<e.length;i++)(r=e[i]).schema??(r.schema=n)}function Dn(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:wn(e.inst?._zod.def?.error?.(e))??wn(a?.(e))??wn(t?.error?.(e))??wn(n.customError?.(e))??wn(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 On=/[\uD800-\uDBFF]/;function kn(e){let t=e.length;if(!On.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 An(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function jn(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 Mn(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}function Nn(e,t){for(let n in t){let r=Object.getOwnPropertyDescriptor(t,n);r.get?Object.defineProperty(e,n,{...r,enumerable:!1}):Ln(e,n,r.value)}}function Pn(e,t,n,r=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:r,value:n}),n}function Fn(e,t,n){return Pn(e,t,n,!1)}function In(e,t){for(let n in e){let r=e[n];Object.defineProperty(t,n,{configurable:!0,enumerable:!0,get(){return Pn(this,n,r(this))},set(e){Pn(this,n,e)}})}return t}function Ln(e,t,n){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?n:Pn(this,t,n.bind(this))},set(e){Pn(this,t,e)}})}function Rn(e,t){let n=Object.getPrototypeOf(e);return t in n?void 0:n}let zn,Bn=!1,Vn={configurable:!0,get(){Bn=!0}};function E(e,t,n){let r=Object.getPrototypeOf(e._zod);t in r&&zn!==e._zod?zn=void 0:(zn=e._zod,Object.defineProperty(r,t,{configurable:!0,get(){Object.defineProperty(this,t,Vn);let e=Bn;Bn=!1;try{let r=n(this);return Bn?delete this[t]:Object.defineProperty(this,t,{configurable:!0,writable:!0,value:r}),Bn||=e,r}catch(n){throw delete this[t],Bn||=e,n}},set(e){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:e})}}))}function Hn(e,t,n,r){let i=Rn(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 Un(e){let t=()=>e;return t[`~constantCatch`]=!0,t}var Wn;let Gn=/*@__PURE__*/ Object.freeze({status:`aborted`}),Kn={value:void 0,enumerable:!1},qn=`captureStackTrace`in Error?Error:null;function Jn(e){let t=qn;if(t){let n=t.stackTraceLimit;if(typeof n==`number`){try{t.stackTraceLimit=0}catch{return qn=null,new e}try{return new e}finally{t.stackTraceLimit=n}}}return new e}function D(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){Kn.value=new a(r);try{Object.defineProperty(n,"_zod",Kn)}finally{Kn.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),Nn(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?Jn(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 Yn=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}},Xn=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name=`ZodEncodeError`}};(Wn=globalThis).__zod_globalConfig??(Wn.__zod_globalConfig={});let Zn=globalThis.__zod_globalConfig;function Qn(e){return e&&Object.assign(Zn,e),Zn}function $n(){let e=this._zod;return e.message??=JSON.stringify(e.def,Ft,2),e.message}function er(e){this._zod.message=e}let tr={get:$n,set:er,enumerable:!0,configurable:!0},nr={value:void 0,enumerable:!1},rr=/* @__PURE__ */ new WeakSet([Object.prototype,Error.prototype]),ir=(e,t)=>{e.name=`$ZodError`,nr.value=t,Object.defineProperty(e,"issues",nr),nr.value=void 0,Object.defineProperty(e,"message",tr);let n=Object.getPrototypeOf(e);rr.has(n)||(rr.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})}}))},ar=D(`$ZodError`,ir);D(`$ZodError`,ir,void 0,{Parent:Error});function or(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 sr(e,t=e=>e.message){let n={},r=[];for(let i of e.issues)i.path.length>0?or(n,i.path[0],()=>[]).push(t(i)):r.push(t(i));return{formErrors:r,fieldErrors:n}}function cr(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 lr(e,t){return{callee:t?.callee??e,Err:t?.Err}}let ur=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 Yn;if(s.issues.length){let n=new((a?.Err)??e)(s.issues.map(e=>Dn(e,o,Qn())));throw $t(n,a?.callee??t),n}return s.value};return t},dr=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=>Dn(e,o,Qn())));throw $t(n,a?.callee??t),n}return s.value};return t},fr=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 Yn;return a.issues.length?pr(e,a.issues,i):{success:!0,data:a.value}};function pr(e,t,n){let r;return{success:!1,get error(){return r||(r=new e(t.map(e=>Dn(e,n,Qn()))),t=void 0,n=void 0),r},set error(e){r=e,t=void 0,n=void 0}}}let mr=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?pr(e,a.issues,i):{success:!0,data:a.value}},hr=/* @__PURE__ */ Symbol.for(`zod.compile.invalid`),gr=/* @__PURE__ */ Symbol.for(`zod.compile.fallback`),_r=((e,t,n)=>{let r=e._zod.bag.validator;if(r!==void 0){if(r(t)!==hr)return!0;if(r.definite===!0&&n===void 0)return!1}return vr(e,t,n)});function vr(e,t,n){let r=n?{...n,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},i=e._zod.bag.fallbackRun,a;if(i?(r[gr]=!0,a=i({value:t,issues:[]},r)):a=e._zod.run({value:t,issues:[]},r),a instanceof Promise)throw new Yn;return a.issues.length===0}let yr=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},br=e=>{let t=ur(e),n=(e,r,i,a)=>{let o=i?{...i,direction:`backward`}:{direction:`backward`};return t(e,r,o,lr(n,a))};return n},xr=e=>{let t=ur(e),n=(e,r,i,a)=>t(e,r,i,lr(n,a));return n},Sr=e=>{let t=dr(e),n=async(e,r,i,a)=>{let o=i?{...i,direction:`backward`}:{direction:`backward`};return await t(e,r,o,lr(n,a))};return n},Cr=e=>{let t=dr(e),n=async(e,r,i,a)=>await t(e,r,i,lr(n,a));return n},wr=e=>(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return fr(e)(t,n,i)},Tr=e=>(t,n,r)=>fr(e)(t,n,r),Er=e=>async(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return mr(e)(t,n,i)},Dr=e=>async(t,n,r)=>mr(e)(t,n,r),Or=/^[cC][0-9a-z]{6,}$/,kr=/^[0-9a-z]+$/,Ar=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,jr=/^[0-9a-vA-V]{20}$/,Mr=/^[A-Za-z0-9]{27}$/,Nr=/^[a-zA-Z0-9_-]{21}$/;function Pr(e){return RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}let Fr=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Ir=/^([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})$/,Lr=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)$/,Rr=/^(?:[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 zr(){return RegExp(`^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$`,`u`)}let Br=/^(?:(?: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])$/,Vr=/^(([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}|:))$/,Hr=/^((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])$/,Ur=/^(([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])$/,Wr=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Gr=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/,Kr=/^https?$/,qr=/^\+[1-9]\d{6,14}$/,Jr=`(?:(?:\\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 Yr(e){return RegExp(`^${e}$`)}let Xr=/*@__PURE__*/ Yr(Jr);function Zr(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 Qr(e){return RegExp(`^${Zr(e)}$`)}function $r(e){let t=[`Z`];e.offset&&t.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);let n=`${Zr({precision:e.precision,seconds:!0})}(?:${t.join(`|`)})`,r=e.local?`${n}|${Zr({precision:e.precision})}`:n;return RegExp(`^${Jr}T(?:${r})$`)}let ei=/^[\s\S]{0,}$/,ti=/^-?\d+$/,ni=/^-?\d+(?:\.\d+)?$/,ri=/^(?:true|false)$/i,ii=/^null$/i,ai=/^[^A-Z]*$/,oi=/^[^a-z]*$/,si=/*@__PURE__*/ D(`$ZodCheck`,(e,t)=>{var n;e._zod??={},e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),ci=e=>{let t=e.value;return!Rt(t)&&t.length!==void 0},li={number:`number`,bigint:`bigint`,object:`date`},ui=/*@__PURE__*/ D(`$ZodCheckLessThan`,(e,t)=>{si.init(e,t);let n=li[typeof t.value];e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:li[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})}}),di=/*@__PURE__*/ D(`$ZodCheckGreaterThan`,(e,t)=>{si.init(e,t);let n=li[typeof t.value];e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:li[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})}}),fi=/*@__PURE__*/ D(`$ZodCheckMultipleOf`,(e,t)=>{si.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):Bt(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})}}),pi=/*@__PURE__*/ D(`$ZodCheckNumberFormat`,(e,t)=>{si.init(e,t),t.format=t.format||`float64`;let n=t.format?.includes(`int`),r=n?`int`:`number`,[i,a]=un[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})}}),mi=/*@__PURE__*/ D(`$ZodCheckMaxLength`,(e,t)=>{var n;si.init(e,t),(n=e._zod.def).when??(n.when=ci),e._zod.check=n=>{let r=n.value,i=r.length;if((typeof r==`string`&&i>t.maximum?kn(r):i)<=t.maximum)return;let a=An(r);n.issues.push({origin:a,code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),hi=/*@__PURE__*/ D(`$ZodCheckMinLength`,(e,t)=>{var n;si.init(e,t),(n=e._zod.def).when??(n.when=ci),e._zod.check=n=>{let r=n.value,i=r.length;if((typeof r==`string`&&i>=t.minimum&&i<t.minimum*2?kn(r):i)>=t.minimum)return;let a=An(r);n.issues.push({origin:a,code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),gi=/*@__PURE__*/ D(`$ZodCheckLengthEquals`,(e,t)=>{var n;si.init(e,t),(n=e._zod.def).when??(n.when=ci),e._zod.check=n=>{let r=n.value,i=r.length,a=typeof r==`string`&&i>=t.length&&i<=t.length*2?kn(r):i;if(a===t.length)return;let o=An(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})}}),_i=/*@__PURE__*/ D(`$ZodCheckStringFormat`,(e,t)=>{var n,r;si.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=()=>{})}),vi=/*@__PURE__*/ D(`$ZodCheckRegex`,(e,t)=>{_i.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})}}),yi=/*@__PURE__*/ D(`$ZodCheckLowerCase`,(e,t)=>{t.pattern??=ai,_i.init(e,t)}),bi=/*@__PURE__*/ D(`$ZodCheckUpperCase`,(e,t)=>{t.pattern??=oi,_i.init(e,t)}),xi=/*@__PURE__*/ D(`$ZodCheckIncludes`,(e,t)=>{si.init(e,t);let n=on(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})}}),Si=/*@__PURE__*/ D(`$ZodCheckStartsWith`,(e,t)=>{si.init(e,t);let n=RegExp(`^${on(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})}}),Ci=/*@__PURE__*/ D(`$ZodCheckEndsWith`,(e,t)=>{si.init(e,t);let n=RegExp(`.*${on(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})}}),wi=/*@__PURE__*/ D(`$ZodCheckOverwrite`,(e,t)=>{si.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}});var Ti=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(C(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(C(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=C(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=C(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=C(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=C(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:ze(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&&ze(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:ze(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)=>ze(e.event,t.event));for(let e of n)this.inputs.set(C(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=C(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=>C(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(C(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(C(e.event))).sort((e,t)=>ze(e.event,t.event));for(let e of i)this.inputs.set(C(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)=>ze(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&&ze(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=C(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)=>ze(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(C(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(`
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 Ei={major:4,minor:6,patch:7},Di=/*@__PURE__*/ D(`$ZodType`,(e,t)=>{var n;e??={},e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Ei;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=xn(t),a;for(let o of n){if(o._zod.def.when){if(Sn(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 Yn;if(a||s instanceof Promise)a=(a??Promise.resolve()).then(async()=>{await s,t.issues.length!==n&&(En(t.issues,n,e),i||=xn(t,n))});else{if(t.issues.length===n)continue;En(t.issues,n,e),i||=xn(t,n)}}return a?a.then(()=>t):t},n=(n,r,a)=>{if(xn(n))return n.aborted=!0,n;let o=t(r,i,a);if(o instanceof Promise){if(a.async===!1)throw new Yn;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 Yn;return o.then(e=>t(e,i,a))}return t(o,i,a)}}},{get"~standard"(){return Fn(this,`~standard`,Ai(this))},set"~standard"(e){Pn(this,`~standard`,e)}}),Oi=(e,t)=>e.issues.length?{issues:e.issues.map(e=>Dn(e,t,Qn()))}:{value:e.value};async function ki(e,t){let n={async:!0};return Oi(await e._zod.run({value:t,issues:[]},n),n)}function Ai(e){return{validate:t=>{let n={async:!1};try{let r=e._zod.run({value:t,issues:[]},n);if(!(r instanceof Promise))return Oi(r,n)}catch{}return ki(e,t)},vendor:`zod`,version:1}}let ji=/*@__PURE__*/ D(`$ZodString`,(e,t)=>{Di.init(e,t),e._zod.pattern=t.pattern??ei,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}}),Mi=/*@__PURE__*/ D(`$ZodStringFormat`,(e,t)=>{_i.init(e,t),ji.init(e,t)}),Ni=/*@__PURE__*/ D(`$ZodGUID`,(e,t)=>{t.pattern??=Ir,Mi.init(e,t)}),Pi=/*@__PURE__*/ D(`$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??=Lr(e)}else t.pattern??=Lr();Mi.init(e,t)}),Fi=/*@__PURE__*/ D(`$ZodEmail`,(e,t)=>{t.pattern??=Rr,Mi.init(e,t)});function Ii(e){try{return typeof URL<`u`&&typeof URL.canParse==`function`?URL.canParse(e):(new URL(e),!0)}catch{return!1}}function Li(e,t){return!(`normalize`in t)&&!(`hostname`in t)&&!(`protocol`in t)?Ii(e)||2:Ri(e,t)}function Ri(e,t){if(!t.normalize&&t.protocol?.source===Kr.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 zi=/[\t\n\r]/g;function Bi(e){return e.replace(zi,``)}function Vi(e,t){return t.lastIndex=0,t.test(e.hostname)}function Hi(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(`:`)?e.protocol.slice(0,-1):e.protocol)}let Ui=/*@__PURE__*/ D(`$ZodURL`,(e,t)=>{Mi.init(e,t),e._zod.check=n=>{try{let r=n.value.trim(),i=Li(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=Bi(r);return}t.hostname&&!Vi(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&&!Hi(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:Bi(r);return}catch{n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort})}}}),Wi=/*@__PURE__*/ D(`$ZodEmoji`,(e,t)=>{t.pattern??=zr(),Mi.init(e,t)}),Gi=/*@__PURE__*/ D(`$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?Nr:Pr(t.length),Mi.init(e,t)}),Ki=/*@__PURE__*/ D(`$ZodCUID`,(e,t)=>{t.pattern??=Or,Mi.init(e,t)}),qi=/*@__PURE__*/ D(`$ZodCUID2`,(e,t)=>{t.pattern??=kr,Mi.init(e,t)}),Ji=/*@__PURE__*/ D(`$ZodULID`,(e,t)=>{t.pattern??=Ar,Mi.init(e,t)}),Yi=/*@__PURE__*/ D(`$ZodXID`,(e,t)=>{t.pattern??=jr,Mi.init(e,t)}),Xi=/*@__PURE__*/ D(`$ZodKSUID`,(e,t)=>{t.pattern??=Mr,Mi.init(e,t)}),Zi=/*@__PURE__*/ D(`$ZodISODateTime`,(e,t)=>{t.pattern??=$r(t),Mi.init(e,t)}),Qi=/*@__PURE__*/ D(`$ZodISODate`,(e,t)=>{t.pattern??=Xr,Mi.init(e,t)}),$i=/*@__PURE__*/ D(`$ZodISOTime`,(e,t)=>{t.pattern??=Qr(t),Mi.init(e,t)}),ea=/*@__PURE__*/ D(`$ZodISODuration`,(e,t)=>{t.pattern??=Fr,Mi.init(e,t)}),ta=/*@__PURE__*/ D(`$ZodIPv4`,(e,t)=>{t.pattern??=Br,Mi.init(e,t)}),na=/^[0-9a-fA-F:.]+$/;function ra(e){return na.test(e)?Ii(`http://[${e}]`):!1}let ia=/*@__PURE__*/ D(`$ZodIPv6`,(e,t)=>{t.pattern??=Vr,Mi.init(e,t),e._zod.check=n=>{ra(n.value)||n.issues.push({code:`invalid_format`,format:`ipv6`,input:n.value,inst:e,continue:!t.abort})}}),aa=/*@__PURE__*/ D(`$ZodCIDRv4`,(e,t)=>{t.pattern??=Hr,Mi.init(e,t)});function oa(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:ra(n)}let sa=/*@__PURE__*/ D(`$ZodCIDRv6`,(e,t)=>{t.pattern??=Ur,Mi.init(e,t),e._zod.check=n=>{oa(n.value)||n.issues.push({code:`invalid_format`,format:`cidrv6`,input:n.value,inst:e,continue:!t.abort})}});function ca(e){if(e===``)return!0;if(/\s/.test(e)||e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}let la=/^[0-9a-zA-Z+/]*={0,2}$/,ua=/*@__PURE__*/ D(`$ZodBase64`,(e,t)=>{t.pattern??=la,Mi.init(e,t),e._zod.check=n=>{ca(n.value)||n.issues.push({code:`invalid_format`,format:`base64`,input:n.value,inst:e,continue:!t.abort})}}),da=/^[A-Za-z0-9_-]*$/;function fa(e){if(!da.test(e))return!1;let t=e.replace(/[-_]/g,e=>e===`-`?`+`:`/`);return ca(t.padEnd(Math.ceil(t.length/4)*4,`=`))}let pa=/*@__PURE__*/ D(`$ZodBase64URL`,(e,t)=>{t.pattern??=da,Mi.init(e,t),e._zod.check=n=>{fa(n.value)||n.issues.push({code:`invalid_format`,format:`base64url`,input:n.value,inst:e,continue:!t.abort})}}),ma=/*@__PURE__*/ D(`$ZodE164`,(e,t)=>{t.pattern??=qr,Mi.init(e,t)});function ha(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 ga=/*@__PURE__*/ D(`$ZodJWT`,(e,t)=>{Mi.init(e,t),e._zod.check=n=>{ha(n.value,t.alg)||n.issues.push({code:`invalid_format`,format:`jwt`,input:n.value,inst:e,continue:!t.abort})}}),_a=/*@__PURE__*/ D(`$ZodNumber`,(e,t)=>{Di.init(e,t),e._zod.pattern=ni,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}}),va=/*@__PURE__*/ D(`$ZodNumberFormat`,(e,t)=>{pi.init(e,t),_a.init(e,t)}),ya=/*@__PURE__*/ D(`$ZodBoolean`,(e,t)=>{Di.init(e,t),e._zod.pattern=ri,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}}),ba=/*@__PURE__*/ D(`$ZodNull`,(e,t)=>{Di.init(e,t),e._zod.pattern=ii,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}}),xa=/*@__PURE__*/ D(`$ZodUnknown`,(e,t)=>{Di.init(e,t),e._zod.parse=e=>e}),Sa=/*@__PURE__*/ D(`$ZodNever`,(e,t)=>{Di.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:`never`,code:`invalid_type`,input:t.value,inst:e}),t)});function Ca(e,t){let n=Tn(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 Tn(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,En(n.issues,t,e),n}}return i(n,a)}}let wa=e=>Array.isArray(e)?e.length:-1;function Ta(e,t,n){e.issues.length&&t.issues.push(...Cn(n,e.issues)),t.value[n]=e.value}let Ea=/*@__PURE__*/ D(`$ZodArray`,(e,t)=>{Di.init(e,t);let n=Zn.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=>Ta(t,r,e)));else if(Ta(c,r,e),s&&c.issues.length!==0&&xn(c))break}return o.length?Promise.all(o).then(()=>r):r},Ca(e,wa)});function Da(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(...Cn(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 Oa=[];function ka(e){let t=Object.keys(e.shape),n=Object.getOwnPropertySymbols(e.shape),r=n.length?n:Oa,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=ln(e.shape);return{...e,allKeys:i,symbolKeys:r,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(a)}}function Aa(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(xn(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=>Da(e,n,i,t,d,f))):Da(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 ja=/*@__PURE__*/ D(`$ZodObject`,(e,t)=>{Di.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=Lt(()=>ka(t));E(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)||Ut(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=en,o=t.catchall,s,c=Zn.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(xn(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=>Da(n,t,e,r,a,o))):Da(s,t,e,r,a,o)}return o?Aa(l,r,t,n,i.value,e,d===!0):l.length?Promise.all(l).then(()=>t):t}}),Ma=/*@__PURE__*/ D(`$ZodObjectJIT`,(e,t)=>{ja.init(e,t);let n=e._zod.parse,r=Lt(()=>ka(t)),i=Zn.memoizer,a=t=>{let n=r.value,a=n.symbolKeys,o=new Ti([`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 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)=>`
14
14
  let ${e}_ab = false;
15
15
  for (let i = 0; i < ${e}.issues.length; i++) {
16
16
  const iss = ${e}.issues[i];
@@ -21,7 +21,7 @@ default:je(e.groups)}return{upserts:t,removes:n}}},Ue=class{store;key;listeners=
21
21
  if (${e}_ab && ctx && ctx.abortEarly) {
22
22
  payload.value = newResult;
23
23
  return payload;
24
- }`;o.write(`const input = payload.value;`);let l=Object.create(null),u=0;for(let e of n.allKeys)l[e]=`key_${u++}`;o.write(i?`const newResult = memo.alloc(inst, payload, {}, ctx);`:`const newResult = {};`);for(let e of n.allKeys){if(e===`__proto__`)continue;let n=l[e],r=typeof e==`symbol`?`syms[${a.indexOf(e)}]`:Zt(e),i=`${r} in input`,u=t[e],d=u?._zod?.optin,f=d!==void 0,p=u?._zod?.optout===`optional`;if(o.write(`const ${n} = ${s(r)};`),f&&p){let e=d===`optional`?`${n}_present`:`${n}.value !== undefined || ${n}_present`;o.write(`
24
+ }`;o.write(`const input = payload.value;`);let l=Object.create(null),u=0;for(let e of n.allKeys)l[e]=`key_${u++}`;o.write(i?`const newResult = memo.alloc(inst, payload, {}, ctx);`:`const newResult = {};`);for(let e of n.allKeys){if(e===`__proto__`)continue;let n=l[e],r=typeof e==`symbol`?`syms[${a.indexOf(e)}]`:an(e),i=`${r} in input`,u=t[e],d=u?._zod?.optin,f=d!==void 0,p=u?._zod?.optout===`optional`;if(o.write(`const ${n} = ${s(r)};`),f&&p){let e=d===`optional`?`${n}_present`:`${n}.value !== undefined || ${n}_present`;o.write(`
25
25
  const ${n}_present = ${i};
26
26
  if (!${n}.issues.length || ${n}_present) {
27
27
  if (${n}.issues.length) {${c(n,r)}
@@ -60,116 +60,120 @@ default:je(e.groups)}return{upserts:t,removes:n}}},Ue=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=en,c=!Zn.jitless,l=c&&tn.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?Aa([],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 Na(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=>!xn(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=>Dn(e,r,Qn())))}),t)}let Pa=/*@__PURE__*/ D(`$ZodUnion`,(e,t)=>{Di.init(e,t),E(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),E(e,`optout`,e=>e.def.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),E(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)))}),E(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=>zt(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=>Na(t,r,e,i)):Na(o,r,e,i)}});function Fa(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 Ia=/*@__PURE__*/ D(`$ZodDiscriminatedUnion`,(e,t)=>{t.inclusive=!1,Pa.init(e,t);let n=e._zod.parse;E(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)||Ut(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=Wt(e._zod.def);if(r&&!Object.prototype.hasOwnProperty.call(r,t.discriminator))throw Error(`Invalid discriminated union option at index "${n}"`)});let r=Lt(()=>Fa(t));e._zod.parse=(i,a)=>{let o=i.value;if(!en(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)}}),La=/*@__PURE__*/ D(`$ZodIntersection`,(e,t)=>{Di.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])=>za(e,t,n)):za(e,i,a)}});function Ra(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(nn(e)&&nn(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=Ra(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=Ra(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 za(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=Ra(t.value,n.value);if(!c.valid){if(xn(e))return e;throw Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`)}return e.value=c.data,e}let Ba=/*@__PURE__*/ D(`$ZodTuple`,(e,t)=>{Di.init(e,t);let n=t.items,r=Zn.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=Va(n,`optin`),l=Va(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=xn(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(xn(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=>Ha(t,i,e))):Ha(r,i,e)}}return s.length?Promise.all(s).then(()=>Ua(u,i,n,o,l)):Ua(u,i,n,o,l)}});function Va(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 Ha(e,t,n){e.issues.length&&t.issues.push(...Cn(n,e.issues)),t.value[n]=e.value}function Ua(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(...Cn(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 Wa=/*@__PURE__*/ D(`$ZodRecord`,(e,t)=>{Di.init(e,t);let n=Zn.memoizer;n?.attach(e),e._zod.parse=(r,i)=>{let a=r.value;if(!nn(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=>Dn(e,i,Qn())),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(...Cn(n,e.issues)),r.value[l]=e.value})):(u.issues.length&&r.issues.push(...Cn(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`&&ni.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=>Dn(e,i,Qn())),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(...Cn(n,e.issues)),r.value[u]=e.value})):(d.issues.length&&r.issues.push(...Cn(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}}),Ga=/*@__PURE__*/ D(`$ZodEnum`,(e,t)=>{Di.init(e,t);let n=Nt(t.entries),r=new Set(n);e._zod.values=r,E(e,`pattern`,e=>{let t=Nt(e.def.entries).filter(e=>an.has(typeof e));return RegExp(t.length?`^(${t.map(e=>on(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}}),Ka=/*@__PURE__*/ D(`$ZodLiteral`,(e,t)=>{Di.init(e,t);let n=new Set(t.values);e._zod.values=n,E(e,`pattern`,e=>{let t=e.def.values;return RegExp(t.length?`^(${t.map(e=>typeof e==`string`?on(e):e?on(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}}),qa=/*@__PURE__*/ D(`$ZodTransform`,(e,t)=>{Di.init(e,t),e._zod.optin=`optional`,Zn.memoizer?.guard(e),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new Xn(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 Yn;return n.value=i,n}});function Ja(e,t){return e.value=t.issues.length?void 0:t.value,e}let Ya=/*@__PURE__*/ D(`$ZodOptional`,(e,t)=>{Di.init(e,t),E(e,`optin`,e=>e.def.innerType._zod.optin===`defaulted`?`defaulted`:`optional`),e._zod.optout=`optional`,E(e,`values`,e=>{let t=e.def.innerType._zod.values;return t?/* @__PURE__ */ new Set([...t,void 0]):void 0}),E(e,`pattern`,e=>{let t=e.def.innerType._zod.pattern;return t?RegExp(`^(${zt(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=>Ja(e,t)):Ja(e,r)}return t.innerType._zod.run(e,n)}}),Xa=/*@__PURE__*/ D(`$ZodExactOptional`,(e,t)=>{Ya.init(e,t),E(e,`values`,e=>e.def.innerType._zod.values),E(e,`pattern`,e=>e.def.innerType._zod.pattern),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),Za=/*@__PURE__*/ D(`$ZodNullable`,(e,t)=>{Di.init(e,t),E(e,`optin`,e=>e.def.innerType._zod.optin),E(e,`optout`,e=>e.def.innerType._zod.optout),E(e,`pattern`,e=>{let t=e.def.innerType._zod.pattern;return t?RegExp(`^(${zt(t.source)}|null)$`):void 0}),E(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)}),Qa=/*@__PURE__*/ D(`$ZodDefault`,(e,t)=>{Di.init(e,t),e._zod.optin=`defaulted`,E(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=>$a(e,t)):$a(r,t)}});function $a(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}let eo=/*@__PURE__*/ D(`$ZodPrefault`,(e,t)=>{Di.init(e,t),e._zod.optin=`defaulted`,E(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))}),to=/*@__PURE__*/ D(`$ZodNonOptional`,(e,t)=>{Di.init(e,t),E(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=>no(t,e)):no(i,e)}});function no(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 ro(e,t,n,r){return t.issues.length?(e.value=n.catchValue({...t,value:e.value,error:{issues:t.issues.map(e=>Dn(e,r,Qn()))},input:e.value}),e):(e.value=t.value,t.memo&&(e.memo=!0),e)}let io=/*@__PURE__*/ D(`$ZodCatch`,(e,t)=>{Di.init(e,t),E(e,`optin`,e=>e.def.innerType._zod.optin===`defaulted`?`defaulted`:`optional`),E(e,`optout`,e=>e.def.innerType._zod.optout),E(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=>ro(e,r,t,n)):ro(e,r,t,n)}}),ao=/*@__PURE__*/ D(`$ZodPipe`,(e,t)=>{Di.init(e,t),E(e,`values`,e=>e.def.in._zod.values),E(e,`optin`,e=>e.def.in._zod.optin),E(e,`optout`,e=>e.def.out._zod.optout),E(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=>oo(e,t.in,n)):oo(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>oo(e,t.out,n)):oo(r,t.out,n)}});function oo(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 so=/*@__PURE__*/ D(`$ZodReadonly`,(e,t)=>{Di.init(e,t),E(e,`propValues`,e=>e.def.innerType._zod.propValues),E(e,`values`,e=>e.def.innerType._zod.values),E(e,`optin`,e=>e.def.innerType?._zod?.optin),E(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(co):co(r)}});function co(e){return e.memo||(e.value=Object.freeze(e.value)),e}let lo=/*@__PURE__*/ D(`$ZodLazy`,(e,t)=>{Di.init(e,t),Ht(e._zod,`innerType`,()=>{let e=t;return e._cachedInner||=t.getter(),e._cachedInner}),E(e,`pattern`,e=>e.innerType?._zod?.pattern),E(e,`propValues`,e=>e.innerType?._zod?.propValues),E(e,`optin`,e=>e.innerType?._zod?.optin??void 0),E(e,`optout`,e=>e.innerType?._zod?.optout??void 0),e._zod.parse=(t,n)=>e._zod.innerType._zod.run(t,n)}),uo=/*@__PURE__*/ D(`$ZodCustom`,(e,t)=>{si.init(e,t),Di.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=>fo(t,n,r,e));fo(i,n,r,e)}});function fo(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(Mn(e))}}var po=class extends Error{constructor(){super(`Cannot parse a reference cycle that closes through a transform`),this.name=`ZodCyclicError`}};let mo=`~memo`,ho=[];function go(e){return typeof e==`object`&&!!e}function _o(e){return e.map(e=>e.path?{...e,path:e.path.slice()}:{...e})}let vo=/*@__PURE__*/ new WeakMap;function yo(e,t,n){let r=vo.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=yo(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?yo(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=Wt(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?yo(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),bo(e,i)}function bo(e,t){return t!==1&&vo.set(e,t===2),t}function xo(e,t){let n=e.buckets.get(t);return n||(n=/* @__PURE__ */ new WeakMap,e.buckets.set(t,n)),n}let So,Co=[],wo={alloc(e,t,n){let r=So;if(!r)return n;So=void 0;let i={value:n,issues:null};return r.set(t.value,i),Co.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`&&Eo(n,e.value))throw new po;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=yo(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(!go(l))return t(s,c);let u=c[mo];u||(u={buckets:/* @__PURE__ */ new WeakMap,backEdges:void 0},c[mo]=u);let d;i===c?d=a:(d=xo(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(..._o(f.issues)):(s.memo=!0,u.backEdges??(u.backEdges=/* @__PURE__ */ new WeakSet),u.backEdges.add(f.value)),s;So=d;let p=Co.length,m=t(s,c);So=void 0;let h=Co.length>p?Co.pop():void 0;return m instanceof Promise?m.then(e=>(h&&(h.issues=e.issues.length?_o(e.issues):ho),e)):(h&&(h.issues=m.issues.length?_o(m.issues):ho),m)};e._zod.parse=o,e._zod.run===t&&(e._zod.run=o)})}};function To(){return wo}function Eo(e,t){let n=e[mo]?.backEdges;return n!==void 0&&go(t)&&n.has(t)}let Do=()=>{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(jn(e.input),e.input)}`;case`invalid_value`:return e.values.length===1?`Invalid input: expected ${cn(e.values[0])}`:`Invalid option: expected one of ${Pt(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`:``}: ${Pt(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 Oo(){return{localeError:Do()}}var ko,Ao=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 jo(){return new Ao}(ko=globalThis).__zod_globalRegistry??(ko.__zod_globalRegistry=jo());let Mo=globalThis.__zod_globalRegistry;function No(e){return e.checks&&=[...e.checks],e}// @__NO_SIDE_EFFECTS__
64
- function Po(e,t){return new e(No({type:`string`,...T(t)}))}// @__NO_SIDE_EFFECTS__
65
- function Fo(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...T(t)})}// @__NO_SIDE_EFFECTS__
66
- function Io(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...T(t)})}// @__NO_SIDE_EFFECTS__
67
- function Lo(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...T(t)})}// @__NO_SIDE_EFFECTS__
68
- function Ro(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...T(t)})}// @__NO_SIDE_EFFECTS__
69
- function zo(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...T(t)})}// @__NO_SIDE_EFFECTS__
70
- function Bo(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...T(t)})}// @__NO_SIDE_EFFECTS__
71
- function Vo(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...T(t)})}// @__NO_SIDE_EFFECTS__
72
- function Ho(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...T(t)})}// @__NO_SIDE_EFFECTS__
73
- function Uo(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...T(t)})}// @__NO_SIDE_EFFECTS__
74
- function Wo(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...T(t)})}// @__NO_SIDE_EFFECTS__
75
- function Go(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...T(t)})}// @__NO_SIDE_EFFECTS__
76
- function Ko(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...T(t)})}// @__NO_SIDE_EFFECTS__
77
- function qo(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...T(t)})}// @__NO_SIDE_EFFECTS__
78
- function Jo(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...T(t)})}// @__NO_SIDE_EFFECTS__
79
- function Yo(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...T(t)})}// @__NO_SIDE_EFFECTS__
80
- function Xo(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...T(t)})}// @__NO_SIDE_EFFECTS__
81
- function Zo(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...T(t)})}// @__NO_SIDE_EFFECTS__
82
- function Qo(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...T(t)})}// @__NO_SIDE_EFFECTS__
83
- function $o(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...T(t)})}// @__NO_SIDE_EFFECTS__
84
- function es(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...T(t)})}// @__NO_SIDE_EFFECTS__
85
- function ts(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...T(t)})}// @__NO_SIDE_EFFECTS__
86
- function ns(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...T(t)})}// @__NO_SIDE_EFFECTS__
87
- function rs(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...T(t)})}// @__NO_SIDE_EFFECTS__
88
- function is(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...T(t)})}// @__NO_SIDE_EFFECTS__
89
- function as(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...T(t)})}// @__NO_SIDE_EFFECTS__
90
- function os(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...T(t)})}// @__NO_SIDE_EFFECTS__
91
- function ss(e,t){return new e(No({type:`number`,checks:[],...T(t)}))}// @__NO_SIDE_EFFECTS__
92
- function cs(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...T(t)})}// @__NO_SIDE_EFFECTS__
93
- function ls(e,t){return new e({type:`boolean`,...T(t)})}// @__NO_SIDE_EFFECTS__
94
- function us(e,t){return new e({type:`null`,...T(t)})}// @__NO_SIDE_EFFECTS__
95
- function ds(e){return new e({type:`unknown`})}// @__NO_SIDE_EFFECTS__
96
- function fs(e,t){return new e({type:`never`,...T(t)})}// @__NO_SIDE_EFFECTS__
97
- function ps(e,t){return new ui({check:`less_than`,...T(t),value:e,inclusive:!1})}// @__NO_SIDE_EFFECTS__
98
- function ms(e,t){return new ui({check:`less_than`,...T(t),value:e,inclusive:!0})}// @__NO_SIDE_EFFECTS__
99
- function hs(e,t){return new di({check:`greater_than`,...T(t),value:e,inclusive:!1})}// @__NO_SIDE_EFFECTS__
100
- function gs(e,t){return new di({check:`greater_than`,...T(t),value:e,inclusive:!0})}// @__NO_SIDE_EFFECTS__
101
- function _s(e,t){return new fi({check:`multiple_of`,...T(t),value:e})}// @__NO_SIDE_EFFECTS__
102
- function vs(e,t){return new mi({check:`max_length`,...T(t),maximum:e})}// @__NO_SIDE_EFFECTS__
103
- function ys(e,t){return new hi({check:`min_length`,...T(t),minimum:e})}// @__NO_SIDE_EFFECTS__
104
- function bs(e,t){return new gi({check:`length_equals`,...T(t),length:e})}// @__NO_SIDE_EFFECTS__
105
- function xs(e,t){return new vi({check:`string_format`,format:`regex`,...T(t),pattern:e})}// @__NO_SIDE_EFFECTS__
106
- function Ss(e){return new yi({check:`string_format`,format:`lowercase`,...T(e)})}// @__NO_SIDE_EFFECTS__
107
- function Cs(e){return new bi({check:`string_format`,format:`uppercase`,...T(e)})}// @__NO_SIDE_EFFECTS__
108
- function ws(e,t){return new xi({check:`string_format`,format:`includes`,...T(t),includes:e})}// @__NO_SIDE_EFFECTS__
109
- function Ts(e,t){return new Si({check:`string_format`,format:`starts_with`,...T(t),prefix:e})}// @__NO_SIDE_EFFECTS__
110
- function Es(e,t){return new Ci({check:`string_format`,format:`ends_with`,...T(t),suffix:e})}// @__NO_SIDE_EFFECTS__
111
- function Ds(e){return new wi({check:`overwrite`,tx:e})}// @__NO_SIDE_EFFECTS__
112
- function Os(e){return/* @__PURE__ */ Ds(t=>t.normalize(e))}// @__NO_SIDE_EFFECTS__
113
- function ks(){return/* @__PURE__ */ Ds(e=>e.trim())}// @__NO_SIDE_EFFECTS__
114
- function As(){return/* @__PURE__ */ Ds(e=>e.toLowerCase())}// @__NO_SIDE_EFFECTS__
115
- function js(){return/* @__PURE__ */ Ds(e=>e.toUpperCase())}// @__NO_SIDE_EFFECTS__
116
- function Ms(){return/* @__PURE__ */ Ds(e=>Qt(e))}// @__NO_SIDE_EFFECTS__
117
- function Ns(e,t,n){return new e({type:`array`,element:t,...T(n)})}// @__NO_SIDE_EFFECTS__
118
- function Ps(e,t,n){let r=T(n);return r.abort??=!0,new e({type:`custom`,check:`custom`,fn:t,...r})}// @__NO_SIDE_EFFECTS__
119
- function Fs(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...T(n)})}// @__NO_SIDE_EFFECTS__
120
- function Is(e,t){let n=/* @__PURE__ */ Ls(t=>(t.addIssue=e=>{if(typeof e==`string`)t.issues.push(Mn(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(Mn(r))}},e(t.value,t)),t);return n}// @__NO_SIDE_EFFECTS__
121
- function Ls(e,t){let n=new si({check:`custom`,...T(t)});return n._zod.check=e,n}function Rs(e,...t){for(let n of t)for(let t of Reflect.ownKeys(n))Object.prototype.propertyIsEnumerable.call(n,t)&&Ut(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??Mo,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 Bs(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 Vs(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,Vs(a,t,r),t.seen.get(a).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&Rs(o.schema,c),t.io===`input`&&Zs(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 Hs(e){return e.replace(/~/g,`~0`).replace(/\//g,`~1`)}function Us(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}/${Hs(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+Hs(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=!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>
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 Ws(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;Ws(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 Gs=/* @__PURE__ */ new Set([`type`,`properties`,`required`,`additionalProperties`]),Ks=[`oneOf`,`anyOf`];function qs(e){let t=e.additionalProperties;return t===void 0||t===!1||typeof t!=`object`||!t?null:Object.keys(t).length?t:null}function Js(e){let t=[];for(let n of e){if(typeof n!=`object`||n.type!==`object`)return null;for(let e in n)if(!Gs.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]??qs(n);t!=null&&(e.some(e=>JSON.stringify(e)===JSON.stringify(t))||e.push(t))}Ut(n,r,e.length===1?e[0]:Js(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=qs(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 Ys(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let t of Gs)if(t in e)return;let n=t.filter(e=>Ks.some(t=>Array.isArray(e[t]))),r=null;if(!n.length)r=Js(t);else{let e=n[0],i=Ks.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=>Js([...a,e]));if(o.some(e=>!e))return;r={[i]:o}}r&&(delete e.allOf,Rs(e,r))}function Xs(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)):Rs(i,s),Rs(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())Ws(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)??[])Ys(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)}Rs(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,Ut(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:$s(t,`input`,e.processors),output:$s(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function Zs(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 Zs(r.element,n);if(r.type===`set`)return Zs(r.valueType,n);if(r.type===`lazy`)return Zs(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 Zs(r.innerType,n);if(r.type===`intersection`)return Zs(r.left,n)||Zs(r.right,n);if(r.type===`record`||r.type===`map`)return Zs(r.keyType,n)||Zs(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:Zs(r.in,n)||Zs(r.out,n);if(r.type===`object`){for(let e in r.shape)if(Zs(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(Zs(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(Zs(e,n))return!0;return!!(r.rest&&Zs(r.rest,n))}return!1}let Qs=(e,t={})=>n=>{let r=zs({...n,processors:t});return Vs(e,r),Us(r,e),Xs(r,e)},$s=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=zs({...i??{},target:a,io:t,processors:n});return Vs(e,o),Us(o,e),Xs(o,e)},ec=(e,t,n)=>{(e[t]===void 0||n>e[t])&&(e[t]=n)},tc=(e,t,n)=>{(e[t]===void 0||n<e[t])&&(e[t]=n)},nc=(e,t)=>{ec(e,`minimum`,t),tc(e,`maximum`,t)},rc=(e,t)=>{e.multipleOf??=[],e.multipleOf.includes(t)||e.multipleOf.push(t)},ic=(e,t)=>{e.patterns??=/* @__PURE__ */ new Set,e.patterns.add(t)},ac=(e,t)=>{e.mime=e.mime?e.mime.filter(e=>t.includes(e)):[...t]},oc=(e,t)=>{e.format=t,t.includes(`int`)&&(e.isInt=!0)},sc=(e,t)=>ec(e,`minimum`,t.minimum),cc=(e,t)=>tc(e,`maximum`,t.maximum),lc=e=>(t,n)=>{oc(t,n.format);let[r,i]=e[n.format];ec(t,`minimum`,r),tc(t,`maximum`,i)},uc={greater_than:(e,t)=>ec(e,t.inclusive?`minimum`:`exclusiveMinimum`,t.value),less_than:(e,t)=>tc(e,t.inclusive?`maximum`:`exclusiveMaximum`,t.value),multiple_of:(e,t)=>rc(e,t.value),number_format:lc(un),bigint_format:lc(dn),min_length:sc,max_length:cc,length_equals:(e,t)=>nc(e,t.length),min_size:sc,max_size:cc,size_equals:(e,t)=>nc(e,t.size),string_format:(e,t)=>{oc(e,t.format),t.pattern&&ic(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)=>ac(e,t.mime)};function dc(e){let t={},n=e._zod.def,r=e._zod.traits.has(`$ZodCheck`)?[e,...n.checks??[]]:n.checks??[];for(let e of r)uc[e._zod.def.check]?.(t,e._zod.def);let i=e._zod.bag;i.minimum!==void 0&&ec(t,`minimum`,i.minimum),i.exclusiveMinimum!==void 0&&ec(t,`exclusiveMinimum`,i.exclusiveMinimum),i.maximum!==void 0&&tc(t,`maximum`,i.maximum),i.exclusiveMaximum!==void 0&&tc(t,`exclusiveMaximum`,i.exclusiveMaximum),i.multipleOf!==void 0&&rc(t,i.multipleOf),i.format!==void 0&&(t.format??=i.format,i.format.includes(`int`)&&(t.isInt=!0)),i.mime&&ac(t,i.mime);for(let e of i.patterns??[])ic(t,e);return t}let fc={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},pc=/* @__PURE__ */ new Map([[la,Wr],[da,Gr]]),mc=e=>pc.get(e)??e,hc=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l,laxFormat:u}=dc(e);if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=fc[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(mc);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}))])}},gc=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,multipleOf:s,exclusiveMaximum:c,exclusiveMinimum:l,isInt:u}=dc(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)):Bs(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}))])}},_c=(e,t,n,r)=>{n.type=`boolean`},vc=(e,t,n,r)=>{t.target===`openapi-3.0`?(n.type=`string`,n.nullable=!0,n.enum=[null]):n.type=`null`},yc=(e,t,n,r)=>{n.not={}},bc=(e,t,n,r)=>{let i=e._zod.def,a=Nt(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)},xc=(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(Bs(e,t,n,r,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof o==`bigint`){if(Bs(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}},Sc=(e,t,n,r)=>{Bs(e,t,n,r,`Custom types cannot be represented in JSON Schema`)},Cc=(e,t,n,r)=>{Bs(e,t,n,r,`Transforms cannot be represented in JSON Schema`)},wc=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=dc(e);typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=Vs(a.element,t,{...r,path:[...r.path,`items`]})};function Tc(e){let t=e._zod.def;return t.type===`pipe`&&t.in._zod.traits.has(`$ZodTransform`)?Tc(t.out):t.type===`catch`?Tc(t.innerType):e._zod.optin}let Ec=(e,t,n,r)=>{let i=n,a=e._zod.def,o=a.shape;if(Object.getOwnPropertySymbols(o).length&&Bs(e,t,i,r,`Symbol keys cannot be represented in JSON Schema`))return;i.type=`object`,i.properties={};for(let e in o)Ut(i.properties,e,Vs(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`?Tc(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=Vs(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},Dc=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>Vs(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},Oc=(e,t,n,r)=>{let i=e._zod.def,a=Vs(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=Vs(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)},kc=(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)=>Vs(e,t,{...r,path:[...r.path,o,n]})),l=a.rest?Vs(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`?Tc(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}=dc(e);typeof p==`number`&&(i.minItems=p),typeof m==`number`&&(i.maxItems=m)};function Ac(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=Ac(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=>Ac(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`)?ni:ti).source)),p}let jc=/* @__PURE__ */ new WeakMap;function Mc(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 jc.get(e)??[]){let i=e.seen.get(r),a=(i?.def??i?.schema)?.propertyNames;if(!a||a===!0||n.has(a))continue;let o=Ac(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 Nc=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`;let o=a.keyType,s=dc(o).patterns;if(a.mode===`loose`&&s&&s.size>0){let e=Vs(a.valueType,t,{...r,path:[...r.path,`patternProperties`,`*`]});i.patternProperties={};for(let t of s)Ut(i.patternProperties,mc(t).source,e)}else{if(t.target===`draft-07`||t.target===`draft-2020-12`){i.propertyNames=Vs(a.keyType,t,{...r,path:[...r.path,`propertyNames`]});let n=jc.get(t);n||(n=[],jc.set(t,n),t.deferred.push(()=>Mc(t))),n.push(e)}i.additionalProperties=Vs(a.valueType,t,{...r,path:[...r.path,`additionalProperties`]})}let c=o._zod.values,l=t.io===`input`&&Tc(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))}},Pc=(e,t,n,r)=>{let i=e._zod.def,a=Vs(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`}]},Fc=(e,t,n,r)=>{let i=e._zod.def;Vs(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Ic=Symbol();function Lc(e,t,n,r,i){let a=!1,o=JSON.stringify(e,(e,t)=>typeof t==`bigint`?(a=!0,null):t);return a?(Bs(t,n,r,i,`BigInt defaults cannot be represented in JSON Schema`),Ic):JSON.parse(o)}let Rc=(e,t,n,r)=>{let i=e._zod.def;Vs(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o=Lc(i.defaultValue,e,t,n,r);o!==Ic&&(n.default=o)},zc=(e,t,n,r)=>{let i=e._zod.def;Vs(i.innerType,t,r);let a=t.seen.get(e);if(a.ref=i.innerType,t.io!==`input`)return;let o=Lc(i.defaultValue,e,t,n,r);o!==Ic&&(n._prefault=o)},Bc=(e,t,n,r)=>{let i=e._zod.def;Vs(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{Bs(e,t,n,r,`Dynamic catch values are not supported in JSON Schema`);return}n.default=o},Vc=(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;Vs(o,t,r);let s=t.seen.get(e);s.ref=o},Hc=(e,t,n,r)=>{let i=e._zod.def;Vs(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},Uc=(e,t,n,r)=>{let i=e._zod.def;Vs(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Wc=(e,t,n,r)=>{let i=e._zod.innerType;Vs(i,t,r);let a=t.seen.get(e);a.ref=i},Gc=/* @__PURE__ */ new WeakSet([Object.prototype,Error.prototype]);function Kc(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 qc=/*@__PURE__*/ D(`ZodError`,(e,t)=>{ar.init(e,t),e.name=`ZodError`;let n=Object.getPrototypeOf(e);Gc.has(n)||(Gc.add(n),Kc(n,`format`,e=>t=>cr(e,t)),Kc(n,`flatten`,e=>t=>sr(e,t)),Kc(n,`addIssue`,e=>t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,Ft,2)}),Kc(n,`addIssues`,e=>t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,Ft,2)}),Object.defineProperty(n,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))},void 0,{Parent:Error}),Jc=/* @__PURE__ */ ur(qc),Yc=/* @__PURE__ */ dr(qc),Xc=/* @__PURE__ */ fr(qc),Zc=/* @__PURE__ */ mr(qc),Qc=/* @__PURE__ */ br(qc),$c=/* @__PURE__ */ xr(qc),el=/* @__PURE__ */ Sr(qc),tl=/* @__PURE__ */ Cr(qc),nl=/* @__PURE__ */ wr(qc),rl=/* @__PURE__ */ Tr(qc),il=/* @__PURE__ */ Er(qc),al=/* @__PURE__ */ Dr(qc);function ol(){Zn.localeError||Qn(Oo())}function sl(){Zn.memoizer||Qn({memoizer:To()})}let cl=/*@__PURE__*/ D(`ZodType`,(e,t)=>(ol(),Di.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(Xt(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 sn(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(ju(e,t))},superRefine(e,t){return this.check(Mu(e,t))},overwrite(e){return this.check(/* @__PURE__ */ Ds(e))},optional(){return uu(this)},exactOptional(){return fu(this)},nullable(){return mu(this)},nullish(){return uu(mu(this))},nonoptional(e){return bu(this,e)},array(){return j(this)},or(e){return Xl([this,e])},and(e){return eu(this,e)},transform(e){return wu(this,cu(e))},default(e){return gu(this,e)},prefault(e){return vu(this,e)},catch(e){return Su(this,e)},pipe(e){return wu(this,e)},readonly(){return Eu(this)},describe(e){let t=this.clone();return Mo.add(t,{description:e}),t},meta(...e){if(e.length===0)return Mo.get(this);let t=this.clone();return Mo.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 Fn(this,`~standard`,{...Ai(this),jsonSchema:{input:$s(this,`input`),output:$s(this,`output`)}})},set"~standard"(e){Pn(this,`~standard`,e)},parse:function e(t,n){return Jc(this,t,n,{callee:e})},parseAsync:async function e(t,n){return await Yc(this,t,n,{callee:e})},safeParse(e,t){return Xc(this,e,t)},async safeParseAsync(e,t){return Zc(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){Pn(this,`spa`,e)},validate(e,t){return _r(this,e,t)},validateAsync(e,t){return yr(this,e,t)},encode:function e(t,n){return Qc(this,t,n,{callee:e})},decode:function e(t,n){return $c(this,t,n,{callee:e})},encodeAsync:async function e(t,n){return await el(this,t,n,{callee:e})},decodeAsync:async function e(t,n){return await tl(this,t,n,{callee:e})},safeEncode(e,t){return nl(this,e,t)},safeDecode(e,t){return rl(this,e,t)},async safeEncodeAsync(e,t){return il(this,e,t)},async safeDecodeAsync(e,t){return al(this,e,t)},toJSONSchema(e){return Qs(this,{})(e)},get description(){return Mo.get(this)?.description},get _def(){return this._zod.def}}),ll=/*@__PURE__*/ D(`_ZodString`,(e,t)=>{ji.init(e,t),cl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>hc(e,t,n,r)},/*@__PURE__*/ In({format:e=>dc(e).format??null,minLength:e=>dc(e).minimum??null,maxLength:e=>dc(e).maximum??null},{regex(...e){return this.check(/* @__PURE__ */ xs(...e))},includes(...e){return this.check(/* @__PURE__ */ ws(...e))},startsWith(...e){return this.check(/* @__PURE__ */ Ts(...e))},endsWith(...e){return this.check(/* @__PURE__ */ Es(...e))},min(...e){return this.check(/* @__PURE__ */ ys(...e))},max(...e){return this.check(/* @__PURE__ */ vs(...e))},length(...e){return this.check(/* @__PURE__ */ bs(...e))},nonempty(...e){return this.check(/* @__PURE__ */ ys(1,...e))},lowercase(e){return this.check(/* @__PURE__ */ Ss(e))},uppercase(e){return this.check(/* @__PURE__ */ Cs(e))},trim(){return this.check(/* @__PURE__ */ ks())},normalize(...e){return this.check(/* @__PURE__ */ Os(...e))},toLowerCase(){return this.check(/* @__PURE__ */ As())},toUpperCase(){return this.check(/* @__PURE__ */ js())},slugify(){return this.check(/* @__PURE__ */ Ms())}})),ul=/*@__PURE__*/ D(`ZodString`,(e,t)=>{ji.init(e,t),ll.init(e,t)},{email(e){return this.check(/* @__PURE__ */ Fo(gl,e))},url(e){return this.check(/* @__PURE__ */ Vo(bl,e))},jwt(e){return this.check(/* @__PURE__ */ ns(Il,e))},emoji(e){return this.check(/* @__PURE__ */ Ho(Sl,e))},guid(e){return this.check(/* @__PURE__ */ Io(_l,e))},uuid(e){return this.check(/* @__PURE__ */ Lo(vl,e))},uuidv4(e){return this.check(/* @__PURE__ */ Ro(vl,e))},uuidv6(e){return this.check(/* @__PURE__ */ zo(vl,e))},uuidv7(e){return this.check(/* @__PURE__ */ Bo(vl,e))},nanoid(e){return this.check(/* @__PURE__ */ Uo(Cl,e))},cuid(e){return this.check(/* @__PURE__ */ Wo(wl,e))},cuid2(e){return this.check(/* @__PURE__ */ Go(Tl,e))},ulid(e){return this.check(/* @__PURE__ */ Ko(El,e))},base64(e){return this.check(/* @__PURE__ */ $o(Nl,e))},base64url(e){return this.check(/* @__PURE__ */ es(Pl,e))},xid(e){return this.check(/* @__PURE__ */ qo(Dl,e))},ksuid(e){return this.check(/* @__PURE__ */ Jo(Ol,e))},ipv4(e){return this.check(/* @__PURE__ */ Yo(kl,e))},ipv6(e){return this.check(/* @__PURE__ */ Xo(Al,e))},cidrv4(e){return this.check(/* @__PURE__ */ Zo(jl,e))},cidrv6(e){return this.check(/* @__PURE__ */ Qo(Ml,e))},e164(e){return this.check(/* @__PURE__ */ ts(Fl,e))},datetime(e){return this.check(/* @__PURE__ */ rs(fl,e))},date(e){return this.check(/* @__PURE__ */ is(pl,e))},time(e){return this.check(/* @__PURE__ */ as(ml,e))},duration(e){return this.check(/* @__PURE__ */ os(hl,e))}});function O(e){return/* @__PURE__ */ Po(ul,e)}let dl=/*@__PURE__*/ D(`ZodStringFormat`,(e,t)=>{Mi.init(e,t),ll.init(e,t)}),fl=/*@__PURE__*/ D(`ZodISODateTime`,(e,t)=>{Zi.init(e,t),dl.init(e,t)}),pl=/*@__PURE__*/ D(`ZodISODate`,(e,t)=>{Qi.init(e,t),dl.init(e,t)}),ml=/*@__PURE__*/ D(`ZodISOTime`,(e,t)=>{$i.init(e,t),dl.init(e,t)}),hl=/*@__PURE__*/ D(`ZodISODuration`,(e,t)=>{ea.init(e,t),dl.init(e,t)}),gl=/*@__PURE__*/ D(`ZodEmail`,(e,t)=>{Fi.init(e,t),dl.init(e,t)}),_l=/*@__PURE__*/ D(`ZodGUID`,(e,t)=>{Ni.init(e,t),dl.init(e,t)}),vl=/*@__PURE__*/ D(`ZodUUID`,(e,t)=>{Pi.init(e,t),dl.init(e,t)});function yl(e){return/* @__PURE__ */ Lo(vl,e)}let bl=/*@__PURE__*/ D(`ZodURL`,(e,t)=>{Ui.init(e,t),dl.init(e,t)});function xl(e){return/* @__PURE__ */ Vo(bl,e)}let Sl=/*@__PURE__*/ D(`ZodEmoji`,(e,t)=>{Wi.init(e,t),dl.init(e,t)}),Cl=/*@__PURE__*/ D(`ZodNanoID`,(e,t)=>{Gi.init(e,t),dl.init(e,t)}),wl=/*@__PURE__*/ D(`ZodCUID`,(e,t)=>{Ki.init(e,t),dl.init(e,t)}),Tl=/*@__PURE__*/ D(`ZodCUID2`,(e,t)=>{qi.init(e,t),dl.init(e,t)}),El=/*@__PURE__*/ D(`ZodULID`,(e,t)=>{Ji.init(e,t),dl.init(e,t)}),Dl=/*@__PURE__*/ D(`ZodXID`,(e,t)=>{Yi.init(e,t),dl.init(e,t)}),Ol=/*@__PURE__*/ D(`ZodKSUID`,(e,t)=>{Xi.init(e,t),dl.init(e,t)}),kl=/*@__PURE__*/ D(`ZodIPv4`,(e,t)=>{ta.init(e,t),dl.init(e,t)}),Al=/*@__PURE__*/ D(`ZodIPv6`,(e,t)=>{ia.init(e,t),dl.init(e,t)}),jl=/*@__PURE__*/ D(`ZodCIDRv4`,(e,t)=>{aa.init(e,t),dl.init(e,t)}),Ml=/*@__PURE__*/ D(`ZodCIDRv6`,(e,t)=>{sa.init(e,t),dl.init(e,t)}),Nl=/*@__PURE__*/ D(`ZodBase64`,(e,t)=>{ua.init(e,t),dl.init(e,t)}),Pl=/*@__PURE__*/ D(`ZodBase64URL`,(e,t)=>{pa.init(e,t),dl.init(e,t)}),Fl=/*@__PURE__*/ D(`ZodE164`,(e,t)=>{ma.init(e,t),dl.init(e,t)}),Il=/*@__PURE__*/ D(`ZodJWT`,(e,t)=>{ga.init(e,t),dl.init(e,t)}),Ll=/*@__PURE__*/ D(`ZodNumber`,(e,t)=>{_a.init(e,t),cl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>gc(e,t,n,r),e.isFinite=!0},/*@__PURE__*/ In({minValue:e=>{let{minimum:t,exclusiveMinimum:n}=dc(e);return Math.max(t??-1/0,n??-1/0)},maxValue:e=>{let{maximum:t,exclusiveMaximum:n}=dc(e);return Math.min(t??1/0,n??1/0)},isInt:e=>{let{isInt:t,multipleOf:n}=dc(e);return!!t||!!n?.some(Number.isSafeInteger)},format:e=>dc(e).format??null},{gt(e,t){return this.check(/* @__PURE__ */ hs(e,t))},gte(e,t){return this.check(/* @__PURE__ */ gs(e,t))},min(e,t){return this.check(/* @__PURE__ */ gs(e,t))},lt(e,t){return this.check(/* @__PURE__ */ ps(e,t))},lte(e,t){return this.check(/* @__PURE__ */ ms(e,t))},max(e,t){return this.check(/* @__PURE__ */ ms(e,t))},int(e){return this.check(zl(e))},safe(e){return this.check(zl(e))},positive(e){return this.check(/* @__PURE__ */ hs(0,e))},nonnegative(e){return this.check(/* @__PURE__ */ gs(0,e))},negative(e){return this.check(/* @__PURE__ */ ps(0,e))},nonpositive(e){return this.check(/* @__PURE__ */ ms(0,e))},multipleOf(e,t){return this.check(/* @__PURE__ */ _s(e,t))},step(e,t){return this.check(/* @__PURE__ */ _s(e,t))},finite(){return this}}));function k(e){return/* @__PURE__ */ ss(Ll,e)}let Rl=/*@__PURE__*/ D(`ZodNumberFormat`,(e,t)=>{va.init(e,t),Ll.init(e,t)});function zl(e){return/* @__PURE__ */ cs(Rl,e)}let Bl=/*@__PURE__*/ D(`ZodBoolean`,(e,t)=>{ya.init(e,t),cl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>_c(e,t,n,r)});function A(e){return/* @__PURE__ */ ls(Bl,e)}let Vl=/*@__PURE__*/ D(`ZodNull`,(e,t)=>{ba.init(e,t),cl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>vc(e,t,n,r)});function Hl(e){return/* @__PURE__ */ us(Vl,e)}let Ul=/*@__PURE__*/ D(`ZodUnknown`,(e,t)=>{xa.init(e,t),cl.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function Wl(){return/* @__PURE__ */ ds(Ul)}let Gl=/*@__PURE__*/ D(`ZodNever`,(e,t)=>{Sa.init(e,t),cl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>yc(e,t,n,r)});function Kl(e){return/* @__PURE__ */ fs(Gl,e)}let ql=/*@__PURE__*/ D(`ZodArray`,(e,t)=>{sl(),Ea.init(e,t),cl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>wc(e,t,n,r),e.element=t.element},{min(e,t){return this.check(/* @__PURE__ */ ys(e,t))},nonempty(e){return this.check(/* @__PURE__ */ ys(1,e))},max(e,t){return this.check(/* @__PURE__ */ vs(e,t))},length(e,t){return this.check(/* @__PURE__ */ bs(e,t))},unwrap(){return this.element}});function j(e,t){return/* @__PURE__ */ Ns(ql,e,t)}let Jl=/*@__PURE__*/ D(`ZodObject`,(e,t)=>{sl(),Ma.init(e,t),cl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ec(e,t,n,r),Hn(e,`shape`,e=>e._zod.def.shape,!1)},{keyof(){return P(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(Xt(this._zod.def,{catchall:e}))},passthrough(){return this.clone(Xt(this._zod.def,{catchall:Wl()}))},loose(){return this.clone(Xt(this._zod.def,{catchall:Wl()}))},strict(){return this.clone(Xt(this._zod.def,{catchall:Kl()}))},strip(){return this.clone(Xt(this._zod.def,{catchall:void 0}))},extend(e){return hn(this,e)},safeExtend(e){return _n(this,e)},merge(e){return vn(this,e)},pick(e){return fn(this,e)},omit(e){return mn(this,e)},partial(...e){return yn(lu,this,e[0])},exactPartial(...e){return yn(du,this,e[0],`exactPartial`)},required(...e){return bn(yu,this,e[0])}});function M(e,t){let n={type:`object`,shape:e??{},...T(t)};return new Jl(n)}function N(e,t){return new Jl({type:`object`,shape:e,catchall:Kl(),...T(t)})}let Yl=/*@__PURE__*/ D(`ZodUnion`,(e,t)=>{Pa.init(e,t),cl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Dc(e,t,n,r),e.options=t.options});function Xl(e,t){return new Yl({type:`union`,options:e,...T(t)})}let Zl=/*@__PURE__*/ D(`ZodDiscriminatedUnion`,(e,t)=>{Yl.init(e,t),Ia.init(e,t)});function Ql(e,t,n){return new Zl({type:`union`,options:t,discriminator:e,...T(n)})}let $l=/*@__PURE__*/ D(`ZodIntersection`,(e,t)=>{La.init(e,t),cl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Oc(e,t,n,r)});function eu(e,t){return new $l({type:`intersection`,left:e,right:t})}let tu=/*@__PURE__*/ D(`ZodTuple`,(e,t)=>{sl(),Ba.init(e,t),cl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>kc(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 lu({type:`optional`,innerType:e}))})}});function nu(e,t,n){let r=t instanceof Di;return new tu({type:`tuple`,items:e,rest:r?t:null,...T(r?n:t)})}let ru=/*@__PURE__*/ D(`ZodRecord`,(e,t)=>{sl(),Wa.init(e,t),cl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Nc(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType});function iu(e,t,n){return!t||!t._zod?new ru({type:`record`,keyType:O(),valueType:e,...T(t)}):new ru({type:`record`,keyType:e,valueType:t,...T(n)})}let au=/*@__PURE__*/ D(`ZodEnum`,(e,t)=>{Ga.init(e,t),cl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>bc(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 au({...t,checks:[],...T(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 au({...t,checks:[],...T(r),entries:i})}});function P(e,t){let n=Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e;return new au({type:`enum`,entries:n,...T(t)})}let ou=/*@__PURE__*/ D(`ZodLiteral`,(e,t)=>{Ka.init(e,t),cl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>xc(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 F(e,t){return new ou({type:`literal`,values:Array.isArray(e)?e:[e],...T(t)})}let su=/*@__PURE__*/ D(`ZodTransform`,(e,t)=>{sl(),qa.init(e,t),cl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Cc(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new Xn(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(Mn(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(Mn(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n)):(n.value=i,n)}});function cu(e){return new su({type:`transform`,transform:e})}let lu=/*@__PURE__*/ D(`ZodOptional`,(e,t)=>{Ya.init(e,t),cl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Uc(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function uu(e){return new lu({type:`optional`,innerType:e})}let du=/*@__PURE__*/ D(`ZodExactOptional`,(e,t)=>{Xa.init(e,t),cl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Uc(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function fu(e){return new du({type:`optional`,innerType:e})}let pu=/*@__PURE__*/ D(`ZodNullable`,(e,t)=>{Za.init(e,t),cl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Pc(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function mu(e){return new pu({type:`nullable`,innerType:e})}let hu=/*@__PURE__*/ D(`ZodDefault`,(e,t)=>{Qa.init(e,t),cl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Rc(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function gu(e,t){return new hu({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():rn(t)}})}let _u=/*@__PURE__*/ D(`ZodPrefault`,(e,t)=>{eo.init(e,t),cl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>zc(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function vu(e,t){return new _u({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():rn(t)}})}let yu=/*@__PURE__*/ D(`ZodNonOptional`,(e,t)=>{to.init(e,t),cl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Fc(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function bu(e,t){return new yu({type:`nonoptional`,innerType:e,...T(t)})}let xu=/*@__PURE__*/ D(`ZodCatch`,(e,t)=>{io.init(e,t),cl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Bc(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Su(e,t){return new xu({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:Un(t)})}let Cu=/*@__PURE__*/ D(`ZodPipe`,(e,t)=>{ao.init(e,t),cl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Vc(e,t,n,r),e.in=t.in,e.out=t.out});function wu(e,t){return new Cu({type:`pipe`,in:e,out:t})}let Tu=/*@__PURE__*/ D(`ZodReadonly`,(e,t)=>{so.init(e,t),cl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Hc(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Eu(e){return new Tu({type:`readonly`,innerType:e})}let Du=/*@__PURE__*/ D(`ZodLazy`,(e,t)=>{lo.init(e,t),cl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Wc(e,t,n,r),e.unwrap=()=>e._zod.def.getter()});function Ou(e){return new Du({type:`lazy`,getter:e})}let ku=/*@__PURE__*/ D(`ZodCustom`,(e,t)=>{uo.init(e,t),cl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Sc(e,t,n,r)});function Au(e,t){return/* @__PURE__ */ Ps(ku,e??(()=>!0),t)}function ju(e,t={}){return/* @__PURE__ */ Fs(ku,e,t)}function Mu(e,t){return/* @__PURE__ */ Is(e,t)}function Nu(e){return/* @__PURE__ */ rs(fl,e)}let Pu=M({source:O(),ref:O(),offset:k().int().nonnegative(),length:k().int().positive(),label:O(),appearance:P([`session`,`file`,`folder`,`skill`]).optional(),clipboardText:O(),invalid:A().optional()}),Fu=M({text:O(),references:j(Pu)}).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 Iu(e){return typeof e==`string`?{text:e,references:[]}:{text:e.text,references:e.references.map(zu)}}function Lu(e){if(typeof e==`string`)return Iu(e);let t=Fu.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 Ru(e,t){return{text:e,references:t.map(zu)}}function zu(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 Bu=`dsh.conversation`;function Vu(){return(0,f.defineStore)({init:()=>({draft:``,view:null,viewRequest:null}),persist:Bu,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 Hu(e){let t={text:``,references:[]};if(typeof localStorage>`u`)return t;try{let n=localStorage.getItem(`${Bu}.${e}`);if(n===null)return t;let r=JSON.parse(n);return typeof r!=`object`||!r||!(`draft`in r)?t:Lu(r.draft)??t}catch{return t}}function Uu(e){if(typeof localStorage>`u`)return null;try{let t=localStorage.getItem(`${Bu}.${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 Wu(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 Gu(e){let t=e.replace(/[/\\]+$/,``),n=Math.max(t.lastIndexOf(`/`),t.lastIndexOf(`\\`));return t.slice(n+1)}function Ku(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 qu=`conversation`,Ju=`描述你的任务以生成计划`,Yu=`describe your task to generate plan`,Xu={"shortcut.newline":`换行`,"shortcut.complementary":`使用互补的 Queue/Steer 方式`,"shortcut.slash":`打开命令菜单`,"shortcut.mention":`打开引用菜单`,"hint.plan":Ju,"hint.goal":`输入目标,智能体将持续执行`,"hint.goal.active":`当前目标进行中。可输入 edit 修改 / pause 暂停 / resume 继续 / clear 清除`,"placeholder.plan":Ju,"placeholder.default":`发消息或创建任务, / 调用指令, @ 文件或对话`,"placeholder.unavailable":`会话不可用`,"placeholder.parentOffline":`父会话已离线,无法继续发送;仍可停止当前运行`,"placeholder.hero":`描述你想要构建的内容, / 调用指令, @ 文件或对话`,"placeholder.workspace":`选择一个工作区开始`,"placeholder.preparing":`正在准备对话…`,"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.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}`},Zu={"shortcut.newline":`New line`,"shortcut.complementary":`Use the complementary Queue / Steer action`,"shortcut.slash":`Open command menu`,"shortcut.mention":`Open reference menu`,"hint.plan":Yu,"hint.goal":`describe the objective for a long-running task`,"hint.goal.active":`goal active — edit / pause / resume / clear`,"placeholder.plan":Yu,"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.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.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}`},Qu=2048;function $u(e){return e===`image/jpeg`||e===`image/webp`||e===`image/png`}function ed(e,t){return e===``?``:`${e.replace(/\.[^.]*$/u,``)}${t}`}function td(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?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?null:(i.drawImage(e,0,0,t,n),r)}async function nd(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 rd(e){if(!$u(e.type))return e;let t;try{t=await createImageBitmap(e,{imageOrientation:`from-image`});let n=Math.max(t.width,t.height);if(n<=Qu&&e.size<=1048576)return e;let r=Math.min(1,Qu/n),i=Math.max(1,Math.round(t.width*r)),a=Math.max(1,Math.round(t.height*r)),o=td(t,i,a);if(o===null)return e;if(e.type===`image/png`){let t=await nd(o,`image/webp`,.9);if(t!==null&&t.type===`image/webp`)return t.size===0||t.size>=e.size?e:new File([t],ed(e.name,`.webp`),{type:`image/webp`,lastModified:e.lastModified});if(r<1){let n=t!==null&&t.type===`image/png`?t:await nd(o,`image/png`);if(n!==null&&n.type===`image/png`&&n.size>0&&n.size<e.size)return new File([n],e.name,{type:`image/png`,lastModified:e.lastModified})}return e}let s=await nd(o,`image/jpeg`,.85);return s===null||s.type!==`image/jpeg`||s.size===0||s.size>=e.size?e:new File([s],ed(e.name,`.jpg`),{type:`image/jpeg`,lastModified:e.lastModified})}catch{return e}finally{t?.close()}}function id(e){return{kind:`image`,id:vt(),previewUrl:URL.createObjectURL(e),file:e}}function ad(e){if(typeof Image!=`function`)return;let t=new Image;t.onload=()=>{e.width=t.naturalWidth,e.height=t.naturalHeight},t.src=e.previewUrl}function od(){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 sd=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`&&ld(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){let a=n.length===0?void 0:this.requireSessions().retain(e.sessionId,{source:`controllerOperation`});try{let a=this.resolveDraftAttachments(n);if(a.length!==n.length)throw Error(`conversation.sendSession: one or more draft attachments are no longer available`);this.assertUploadsNotFailed(n);let o=a.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}}})),s=async()=>(await this.serializeDraftAttachments(n)).attachments;if(e.getSnapshot().subagent!==null){let n=[...await s(),...t===``?[]:[{type:`text`,text:t}]];return(await e.prompt(n,r,i)).ok?{kind:`success`}:{kind:`error`}}let c,l=a.length===0?void 0:new Promise(e=>{c=e}),u=e.beginSubmission({mode:r,text:t,attachments:o,onObserved:t=>{this.aliasObservedAttachments(e.sessionId,a,t)},onRetire:t=>{this.settleSubmittedAttachments(e.sessionId,a,t),c?.(t)}}),d;try{await od(),d=[...await s(),...t===``?[]:[{type:`text`,text:t}]]}catch(e){throw u.abandon(),e}let f=await e.prompt(d,r,i,u.requestId);return!f.ok||l!==void 0&&(await l).reason!==`observed`?{kind:`error`}:f.value.queueStartUnconfirmed?{kind:`success`,text:this.ctx.locale.bind(qu)(`queue.remoteStartUnconfirmed`)}:{kind:`success`}}finally{a?.release()}}createDrafts(e,t){return t.map(t=>{if(cd(t.type)){let n=id(t);return this.draftAttachments.set(n.id,n),ad(n),this.beginFileUpload(e,n),n}let n={kind:`file`,id:vt(),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=id(i.imageFile);ad(n),t=n,this.ctx.get(`uiConversation`)?.cacheUploadedImage(e,{attachmentId:i.file.attachmentId,blob:i.imageFile,name:i.file.name,bytes:i.file.bytes})}else t={kind:`file`,id:vt(),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(qu)(`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`&&$u(r.type)){let e=this.preparedPhotos.get(t);if(e===void 0&&(e=rd(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}),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),ld(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){ld(a.previewUrl);continue}if(r?.seedImageUrl(e,o,a.previewUrl,a.file.size)===!0)continue}ld(a.previewUrl)}}assertUploadsNotFailed(e){if(e.some(e=>this.fileUploads.getSnapshot()[e]?.status===`error`))throw Error(this.ctx.locale.bind(qu)(`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(qu)(`file.retryOrRemove`)))):e.every(e=>r[e]?.status===`ready`)&&(i(),t())},i=this.fileUploads.subscribe(r);r()})}};function cd(e){return e===`image/png`||e===`image/jpeg`||e===`image/webp`||e===`image/gif`}function ld(e){e.startsWith(`blob:`)&&URL.revokeObjectURL(e)}var ud=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 I(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 fd=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0,pd=fd&&`documentMode`in document?document.documentMode:null,md=fd&&/Mac|iPod|iPhone|iPad/.test(navigator.platform),hd=fd&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent),gd=!(!fd||!(`InputEvent`in window)||pd)&&`getTargetRanges`in new window.InputEvent(`input`),_d=fd&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,vd=fd&&/Android/.test(navigator.userAgent),yd=fd&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent)&&!vd,bd=fd&&/^(?=.*Chrome).*/i.test(navigator.userAgent),xd=fd&&vd&&bd,Sd=fd&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&md&&!bd,Cd=yd||_d||Sd?`\xA0`:`​`,wd=hd?`\xA0`:Cd,Td=`֑-߿יִ-﷽ﹰ-ﻼ`,Ed=`A-Za-zÀ-ÖØ-öø-ʸ̀-֐ࠀ-῿‎Ⰰ-﬜︀-﹯﻽-￿`;RegExp(`^[^`+Ed+`]*[`+Td+`]`),RegExp(`^[^`+Td+`]*[`+Ed+`]`);let Dd={bold:1,capitalize:1024,code:16,highlight:128,italic:2,lowercase:256,strikethrough:4,subscript:32,superscript:64,underline:8,uppercase:512},Od={directionless:1,unmergeable:2},kd={center:2,end:6,justify:4,left:1,right:3,start:5},Ad={2:`center`,6:`end`,4:`justify`,1:`left`,3:`right`,5:`start`},jd={normal:0,segmented:2,token:1},Md={0:`normal`,2:`segmented`,1:`token`},Nd=`$config`;function Pd(){return $v()._blockCursorElement}function Fd(e){return e!==null&&e.nodeType===1&&e.hasAttribute(`data-lexical-slot`)}var Id=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&&I(357),this.element.insertBefore(e,t),this}removeChild(e){return e.parentElement!==this.element&&I(358),this.element.removeChild(e),this}replaceChild(e,t){return t.parentElement!==this.element&&I(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=Ld(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=Ld(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 Ld(e,t){let n=t;for(;n!==null&&n.parentNode!==e;)n=n.parentNode;return n}var Rd=class e extends Id{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(;Fd(t);)e=t,t=t.nextSibling;let n=e?e.nextSibling:this.element.firstChild;return n!==null&&n===Pd()?n:e}getManagedLineBreak(){return this.element.__lexicalLineBreak||null}setManagedLineBreak(e){if(this.element.__lexicalLastChildKind=e,e===null)this.removeManagedLineBreak();else{let t=e===`decorator`&&(Sd||_d||yd);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=Iv().createElement(`br`);if(i.setAttribute(`data-lexical-managed-linebreak`,`true`),n.insertBefore(i,r),e){let e=Iv().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=Pd(),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=zd(t,n);i.push(r);let a=zd(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 zd(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&&I(225),n.reverse()}let Bd;try{Bd=`0.49.0+prod.esm`}catch{}let Vd=Bd??`"<unknown>+source"`;var Hd=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 Ud(e,t=1e3){return e instanceof Wd?e.clone():e.size<t?new Map(e):new Wd().init(new Map(e),void 0,e.size)}var Wd=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 Gd(e,t,n,r,i,a){if(W(e)){let o=e.getFirstChild();for(;o!==null;){let e=o.__key;o.__parent===t&&((W(o)||Ey(o)&&o.__slots!==null)&&Gd(o,e,n,r,i,a),n.has(e)||a.delete(e),i.push(e)),o=o.getNextSibling()}}for(let o of Ey(e)&&e.__slots!==null?e.__slots.values():[]){let e=r.get(o);e!==void 0&&Dy(e)&&e.__slotHost===t&&((W(e)||Ey(e)&&e.__slots!==null)&&Gd(e,o,n,r,i,a),n.has(o)||a.delete(o),i.push(o))}}let Kd=!1,qd=0;function Jd(e){qd=e.timeStamp}function Yd(e,t,n){let r=e.nodeName===`BR`,i=t.__lexicalLineBreak;return i&&(e===i||r&&e.previousSibling===i)||r&&z_(e,n)!==void 0}function Xd(e,t,n){let r=kv(vv(n)),i=r&&zv(r,n._rootElement),a=null,o=null;i!==null&&i.anchorNode===e&&(a=i.anchorOffset,o=i.focusOffset);let s=e.nodeValue;s!==null&&Q_(t,s,a,o,!1)}function Zd(e,t,n){if(V(e)){let t=e.anchor.getNode();if(t.is(n)&&e.format!==t.getFormat())return!1}return D_(t)&&n.isAttached()}function Qd(e,t,n){for(let r=e;r&&!py(r);r=fv(r)){let e=z_(r,t);if(e!==void 0){let t=I_(e,n);if(t)return G(t)||!J(r)?void 0:[r,t]}}}function $d(e,t,n){Kd=!0;let r=performance.now()-qd>100;try{Fg(e,()=>{let i=H()||function(e){return e.read(`latest`,()=>{let e=H();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=Qd(f,e,o);if(!p)continue;let[m,h]=p;if(d===`characterData`)r&&B(h)&&D_(f)&&Zd(i,f,h)&&Xd(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=L_(r),a=r.parentNode;if(!(a==null||r===s||i!==null||Yd(r,a,e)||e._slotsUsed&&J(r)&&r.hasAttribute(`data-lexical-slot`)||py(r))){if(hd){let e=(J(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];(Yd(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`||Yd(n,i,e)||a.removeChild(n)}}n.takeRecords()}i!==null&&(c&&W_(i),hd&&uv(e)&&i.insertRawText(l))})}finally{Kd=!1}}function ef(e){let t=e._observer;t!==null&&$d(e,t.takeRecords(),t)}function tf(e){(function(e){qd===0&&vv(e).addEventListener(`textInput`,Jd,!0)})(e),e._observer=new MutationObserver((t,n)=>{$d(e,t,n)})}var nf=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 rf(e,t){return new nf(e,t)}function af(e){let t=/* @__PURE__ */ new Map,n=/* @__PURE__ */ new Set;for(let{ownNodeConfig:r}of by(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 of=/* @__PURE__ */ new Set([`__proto__`,`constructor`,`prototype`]);var sf=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 uf(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(of.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=uf(i)),this.size++),r.set(e,t)}updateFromUnknown(e,t){if(of.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 cf(e){let t=e.getWritable(),n=t.__state?t.__state.getWritable(t):new sf(t,lf(t));return t.__state=n,n}function lf(e){return e.__state?e.__state.sharedNodeState:__($v(),e.getType()).sharedNodeState}function uf(e){if(e)for(let t in e)return e}function df(e){return e}function ff(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 pf(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 mf(e,t){let n=e.__state;return n&&n.node===e?n.getWritable(t):n}function hf(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&&ff(n,e,t)||t&&ff(n,t,e)||e&&pf(n,e,t)||t&&pf(n,t,e))}(c,l))}function gf(e,t){let n=e.mergeWithSibling(t),r=U()._normalizedNodes;return r.add(e.__key),r.add(t.__key),n}function _f(e){let t,n,r=e;if(r.__text!==``||!r.isSimpleText()||r.isUnmergeable()){for(;(t=r.getPreviousSibling())!==null&&B(t)&&t.isSimpleText()&&!t.isUnmergeable();){if(t.__text!==``){if(hf(t,r)){r=gf(t,r);break}break}t.remove()}for(;(n=r.getNextSibling())!==null&&B(n)&&n.isSimpleText()&&!n.isUnmergeable();){if(n.__text!==``){if(hf(r,n)){r=gf(r,n);break}break}n.remove()}}else r.remove()}function vf(e){return yf(e.anchor),yf(e.focus),e}function yf(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),B(r)){e.set(r.__key,i?r.getTextContentSize():0,`text`,!0);break}if(!W(r))break;e.set(r.__key,i?r.getChildrenSize():0,`element`,!0)}}let bf=Symbol.for(`@lexical/CachedTextSize`);function xf(e,t){return Ff.read(()=>{let n=0,r=e;for(let e=0;e<t&&r!==null;e++){let i=Pf.get(r);if(i===void 0&&I(345,r),W(i)){let a=If.get(r);if(a!==void 0&&W(a)&&a.__parent!==i.__parent)n+=i.getTextContentSize();else{let e=Lf.get(r),t=e&&e.__lexicalTextContent;typeof t!=`string`&&I(346,i.getType()),n+=t.length}e<t-1&&!i.isInline()&&(n+=2)}else{let e=i[bf];e===void 0&&I(347,i.getType(),r),n+=e}r=i.__next}return n},{editor:L})}function Sf(e){W(e)||e[bf]===void 0&&(e[bf]=B(e)?e.__text.length:e.getTextContentSize())}let Cf,L,wf,R=``,Tf=null,Ef=null,Df=null;function Of(){return{firstTextKey:Df,format:Tf,style:Ef}}function kf(e){e.firstTextKey!==null&&(Tf=e.format,Ef=e.style,Df=e.firstTextKey)}function Af(e){if(Df!==null)return;let t=e.__lexicalFirstTextKey;if(t===void 0&&I(348),t===null)return;let n=If.get(t);B(n)&&(Tf=n.getFormat(),Ef=n.getStyle(),Df=t)}let jf,Mf,Nf,Pf,Ff,If,Lf,Rf,zf,Bf,Vf=!1,Hf=!1;function Uf(e,t){let n=Pf.get(e),r=If.has(e);if(t!==null){let n=fp(e);n.parentNode===t&&t.removeChild(n)}if(!r){if(L._keyToDOMMap.delete(e),W(n)){let e=Cy(n,Pf);Wf(e,0,e.length-1,null)}if(n!==void 0){for(let e of Qf(n).values()){let t=ep(e);Uf(e,null),t!==null&&t.remove()}sv(zf,wf,jf,n,`destroyed`)}}}function Wf(e,t,n,r){for(let i=t;i<=n;++i){let t=e[i];t!==void 0&&Uf(t,r)}}function Gf(e,t){e.setProperty(`text-align`,t)}function Kf(e,t){let n=Cf.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 qf(e,t){let n=e.style;t===0?Gf(n,``):t===1?Gf(n,`left`):t===2?Gf(n,`center`):t===3?Gf(n,`right`):t===4?Gf(n,`justify`):t===5?Gf(n,`start`):t===6&&Gf(n,`end`)}function Jf(e,t){let n=function(e){let t=e.__dir;if(t!==null)return t;if(Vg(e))return null;let n=e.getParent();return n===null||Sv(n)&&n.__dir===null?`auto`:null}(t);n===null?e.removeAttribute(`dir`):e.dir=n}function Yf(e){let t=Iv().createElement(`div`);return t.setAttribute(`data-lexical-slot`,e),t.style.display=`none`,t}function Xf(e,t,n){t||e.contentEditable===`false`?my(n,L):n.removeAttribute(`contenteditable`)}function Zf(e,t,n){let r=R,i=Of();R=``;let a=``,o=G(e);for(let[r,i]of n){let n=Yf(r);Xf(t,o,n),t.appendChild(n),R=``;let s=Of();np(i,ty(e,n,L)),kf(s),$f(e,r,t,n),a+=R}return kf(i),R=r,a}function Qf(e){return Ey(e)&&e.__slots!==null?e.__slots:Ty}function $f(e,t,n,r){let i=Bf.$getSlotTargetElement(e,t,n,L);i!==null&&(r.parentElement!==i&&i.appendChild(r),r.style.display=``)}function ep(e){let t=Lf.get(e);return t===void 0?null:t.parentElement}function tp(e,t,n){let r=Qf(e),i=Qf(t);for(let[e,t]of r)if(!i.has(e)){let e=ep(t);Uf(t,null),e!==null&&e.remove()}let a=R,o=Of(),s=``,c=null,l=G(t);for(let[e,a]of i){let i=r.get(e),o=i===void 0?null:ep(i);R=``;let u=Of();if(o===null){o=Yf(e);let r=null;for(let e of n.children)if(!e.hasAttribute(`data-lexical-slot`)){r=e;break}n.insertBefore(o,r),np(a,ty(t,o,L))}else i===a?sp(a,o):(i!==void 0&&Uf(i,o),np(a,ty(t,o,L)));if(kf(u),Xf(n,l,o),$f(t,e,n,o),s+=R,o.parentElement===n){let e=c===null?n.firstChild:c.nextSibling;e!==o&&n.insertBefore(o,e),c=o}}return kf(o),R=a,s}function np(e,t){let n=If.get(e);if(n===void 0&&I(60),t!==null){let r=Pf.get(e);if(r!==void 0){let i=Lf.get(e);if(i!==void 0){let a=Dy(r)?r.__slotHost:null,o=Dy(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),sp(e,t.element)}}}let r=Bf.$createDOM(n,L);if(function(e,t,n){let r=n._keyToDOMMap;R_(t,n,e),r.set(e,t)}(e,r,L),B(n)?r.setAttribute(`data-lexical-text`,`true`):G(n)&&(r.setAttribute(`data-lexical-decorator`,`true`),fy(r,{captureSelection:!0})),W(n)){let e=n.__indent,t=n.__size;Jf(r,n),e!==0&&Kf(r,e);let i=Qf(n),a=i.size>0?Zf(n,r,i):``;if(t===0)r.__lexicalTextContent=a,r.__lexicalFirstTextKey=null,R+=a,i.size>0&&(r.__lexicalSlotTextLength=a.length);else{let e=R,o=t-1;if(rp(Cy(n,If),n,0,o,ty(n,r,L)),a!==``){let t=r.__lexicalTextContent||``;r.__lexicalTextContent=a+t,R=e+a+t}i.size>0&&(r.__lexicalSlotTextLength=a.length)}let o=n.__format;o!==0&&qf(r,o),n.isInline()||ip(null,n,r)}else{let t=n.getTextContent();if(G(n)){let t=n.decorate(L,Cf);t!==null&&cp(e,t),r.contentEditable=`false`;let i=Qf(n);i.size>0&&Zf(n,r,i)}R+=t}return t!==null&&t.insertChild(r),Bf.$decorateDOM(n,null,r,L),Sf(n),sv(zf,wf,jf,n,`created`),r}function rp(e,t,n,r,i){let a=R,o=Of();R=``,Tf=null,Ef=null,Df=null;let s=n;for(;s<=r;++s){let t=Of();np(e[s],i);let n=If.get(e[s]);n!==null&&B(n)?Tf===null&&(Tf=n.getFormat(),Ef=n.getStyle(),Df=n.__key):W(n)&&s<r&&!n.isInline()&&(R+=`
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+=`
124
124
 
125
- `),kf(t)}let c=L._keyToDOMMap.get(t.__key);c===void 0&&I(349,t.__key),c.__lexicalTextContent=R,c.__lexicalFirstTextKey=Df,R=a+R,kf(o)}function ip(e,t,n){let r=ty(t,n,L),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 Zg(e)?`line-break`:G(e)&&e.isInline()?`decorator`:null}return Qf(e).size>0?null:`empty`}return null}(t,If);i!==a&&r.setManagedLineBreak(a)}function ap(e,t,n){var r;Tf=null,Ef=null,Df=null,function(e,t,n){let r=R,i=e.__size,a=t.__size;R=``;let o=n.element,s=L._keyToDOMMap.get(t.__key);s===void 0&&I(351,t.__key);let c=a-i;if(!Vf&&Math.abs(c)<=1&&i>=4&&e.__first===t.__first&&(c!==0||!L._cloneNotNeeded.has(e.__key))){let i=s.__lexicalTextContent,l=Rf.get(e.__key);if(!Vf&&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=If.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=xf(a,u),n=a,c=0;for(;n!==null&&c<u;){let e=If.get(n);if(e===void 0)break;let t=Of();sp(n,o),B(e)&&Tf===null&&(Tf=e.getFormat(),Ef=e.getStyle(),Df=e.__key),kf(t),n=e.__next,c++}let d=``;for(n=a,c=0;n!==null&&c<u;){let e=If.get(n);if(e===void 0)break;let t;if(W(e)){let r=L._keyToDOMMap.get(n),i=r&&r.__lexicalTextContent;typeof i!=`string`&&I(352,e.getType()),t=i}else t=e.getTextContent();d+=t,c<u-1&&W(e)&&!e.isInline()&&(d+=`
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+=`
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,R=r+m,op(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=Pf.get(l);if(e===void 0)return!1;l=e.__prev}if(l===null)return!1;let u=If.get(a),d=Pf.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=If.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=Pf.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=xf(l,c);for(let e of _){let t=Of();if(e.kind===`reconcile`)sp(e.key,n.element);else if(e.kind===`destroy`)Uf(e.key,n.element);else{let t=null;for(let n=e.nextIndex+1;n<o;n++){let e=L._keyToDOMMap.get(f[n]);if(e!==void 0){t=e;break}}np(e.key,n.withBefore(t??n.before))}if(e.kind!==`destroy`){let t=If.get(e.key);t&&B(t)&&Tf===null&&(Tf=t.getFormat(),Ef=t.getStyle(),Df=t.__key)}kf(t)}let x=``;for(let e=0;e<o;e++){let t=If.get(f[e]);if(t===void 0)return!1;let n;if(W(t)){let r=L._keyToDOMMap.get(f[e]),i=r&&r.__lexicalTextContent;typeof i!=`string`&&I(350,t.getType()),n=i}else n=t.getTextContent();x+=n,e<o-1&&W(t)&&!t.isInline()&&(x+=`
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+=`
128
128
 
129
- `)}let ee=r.__lexicalSlotTextLength||0,te=ee>0?i.slice(ee):i;return r.__lexicalTextContent=te.slice(0,te.length-b)+x,!0}(e,0,n,s,i,a,u,c)){let e=s.__lexicalTextContent;typeof e!=`string`&&I(353),R=r+e,op(t,s,l);return}}}if(c===0){let t=e.__first,n=0;for(;t!==null;){let e=If.get(t);if(e===void 0)break;let r=Vf||Nf.has(t)||Mf.has(t),i=Of();if(r)sp(t,o);else{let n,r;if(W(e)){r=Lf.get(t);let i=r&&r.__lexicalTextContent;typeof i!=`string`&&I(354,e.getType()),n=i}else n=e.getTextContent();R+=n,r!==void 0&&Af(r)}B(e)?Tf===null&&(Tf=e.getFormat(),Ef=e.getStyle(),Df=e.__key):W(e)&&n<a-1&&!e.isInline()&&(R+=`
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+=`
130
130
 
131
- `),kf(i),t=e.__next,n++}s.__lexicalTextContent=R,s.__lexicalFirstTextKey=Df,R=r+R;return}}if(i===1&&a===1){let r=e.__first,i=t.__first;if(r===i)sp(r,o);else{let e=fp(r),t=np(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}Uf(r,null)}let a=If.get(i);B(a)&&Tf===null&&(Tf=a.getFormat(),Ef=a.getStyle(),Df=a.__key)}else{let r=Cy(e,Pf),s=Cy(t,If);if(r.length!==i&&I(227),s.length!==a&&I(228),i===0)a!==0&&rp(s,t,0,a-1,n);else if(a===0){if(i!==0){let e=n.after==null&&n.before==null&&Qf(t).size===0&&n.element.__lexicalLineBreak==null;Wf(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=Of();if(e===r)u=lp(sp(r,a.element)),d++,f++;else{if(l===void 0&&(l=up(n,f)),c===void 0)c=up(t,d);else if(!c.has(e)){d++,kf(i);continue}if(!l.has(e)){u=lp(fp(e)),Uf(e,a.element),d++,c.delete(e),kf(i);continue}if(c.has(r)){let e=dv(L,r);e!==u&&a.withBefore(u??a.before).insertChild(e),u=lp(sp(r,a.element)),d++,f++}else np(r,a.withBefore(u??a.before)),f++}let o=If.get(r);o!==null&&B(o)?Tf===null&&(Tf=o.getFormat(),Ef=o.getStyle(),Df=o.__key):W(o)&&f<=s&&!o.isInline()&&(R+=`
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+=`
132
132
 
133
- `),kf(i)}let p=d>o,m=f>s;if(p&&!m){let t=n[s+1],r=t===void 0?null:L.getElementByKey(t);rp(n,e,f,s,a.withBefore(r??a.before))}else m&&!p&&Wf(t,d,o,a.element)})(t,r,s,i,a,n)}s.__lexicalTextContent=R,s.__lexicalFirstTextKey=Df,R=r+R}(e,t,ty(t,n,L)),Sv(t)||(r=t,Tf==null||Tf===r.__textFormat||Hf||r.setTextFormat(Tf),function(e){Ef==null||Ef===e.__textStyle||Hf||e.setTextStyle(Ef)}(t))}function op(e,t,n){let r=t.__lexicalFirstTextKey;if(r!=null){let t=e.__key,i=r;for(;i!==null;){let e=If.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=If.get(r);if(B(e))return Tf=e.getFormat(),void(Ef=e.getStyle())}}t.__lexicalFirstTextKey=Df}function sp(e,t){let n=Pf.get(e),r=If.get(e);n!==void 0&&r!==void 0||I(61);let i=Vf||Nf.has(e)||Mf.has(e),a=dv(L,e);if(n===r&&!i){let e;if(W(n)){let t=a.__lexicalTextContent;typeof t!=`string`&&I(355,n.getType()),e=t,Af(a)}else e=n.getTextContent();return R+=e,a}if(n!==r&&i&&sv(zf,wf,jf,r,`updated`),Bf.$updateDOM(r,n,a,L)){let n=np(e,null);return t===null&&I(62),t.replaceChild(n,a),Uf(e,null),n}if(W(n)){W(r)||I(334,e);let t=r.__indent;(Vf||t!==n.__indent)&&Kf(a,t);let o=r.__format;(Vf||o!==n.__format)&&qf(a,o);let s=i&&(Qf(r).size>0||Qf(n).size>0)?tp(n,r,a):``;if(i){let e=R;if(ap(n,r,a),Vg(r)||r.isInline()||ip(0,r,a),s!==``){let t=a.__lexicalTextContent||``;a.__lexicalTextContent=s+t,R=e+s+t,a.__lexicalSlotTextLength=s.length}else(Qf(r).size>0||Qf(n).size>0)&&(a.__lexicalSlotTextLength=0)}else{let e=a.__lexicalTextContent;typeof e!=`string`&&I(356,n.getType()),R+=e,Af(a)}if((Vf||r.__dir!==n.__dir||r.__parent!==n.__parent)&&(Jf(a,r),Vg(r)&&!Vf))for(let e of r.getChildren())W(e)&&Jf(dv(L,e.getKey()),e)}else{let t=r.getTextContent();if(G(r)){let t=r.decorate(L,Cf);t!==null&&cp(e,t),i&&(Qf(r).size>0||Qf(n).size>0)&&tp(n,r,a)}R+=t}if(!Hf&&Vg(r)){let e=r.getLatest();if(e.__cachedText!==R){let t=e.getWritable();t.__cachedText=R,r=t}}return Bf.$decorateDOM(r,n,a,L),Sf(r),a}function cp(e,t){let n=L._pendingDecorators,r=L._decorators;if(n===null){if(r[e]===t)return;n=V_(L)}n[e]=t}function lp(e){let t=e.nextSibling;return t!==null&&t===L._blockCursorElement&&(t=t.nextSibling),t}function up(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){R=``,Tf=null,Ef=null,Df=null,Vf=r===2,L=n,Cf=n._config,Bf=n._config.dom||c_,wf=n._nodes,jf=L._listeners.mutation,Mf=i,Nf=a,Pf=e._nodeMap,Ff=e,If=t._nodeMap,Hf=t._readOnly,Lf=Ud(n._keyToDOMMap),Rf=function(){let e=/* @__PURE__ */ new Map,t=t=>{for(let n of t){let t=If.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(Mf.keys()),t(Nf),e}();let o=/* @__PURE__ */ new Map;return zf=o,sp(`root`,null),L=void 0,wf=void 0,Mf=void 0,Nf=void 0,Pf=void 0,Ff=void 0,If=void 0,Cf=void 0,Lf=void 0,Rf=void 0,zf=void 0,Bf=c_,o}function fp(e){let t=Lf.get(e);return t===void 0&&I(75,e),t}function z(e){return{type:e}}let pp=/* @__PURE__ */ z(`SELECTION_CHANGE_COMMAND`),mp=/* @__PURE__ */ z(`CLICK_COMMAND`),hp=/* @__PURE__ */ z(`BEFORE_INPUT_COMMAND`),gp=/* @__PURE__ */ z(`INPUT_COMMAND`),_p=/* @__PURE__ */ z(`COMPOSITION_START_COMMAND`),vp=/* @__PURE__ */ z(`COMPOSITION_END_COMMAND`),yp=/* @__PURE__ */ z(`DELETE_CHARACTER_COMMAND`),bp=/* @__PURE__ */ z(`INSERT_LINE_BREAK_COMMAND`),xp=/* @__PURE__ */ z(`INSERT_PARAGRAPH_COMMAND`),Sp=/* @__PURE__ */ z(`CONTROLLED_TEXT_INSERTION_COMMAND`),Cp=/* @__PURE__ */ z(`PASTE_COMMAND`),wp=/* @__PURE__ */ z(`REMOVE_TEXT_COMMAND`),Tp=/* @__PURE__ */ z(`DELETE_WORD_COMMAND`),Ep=/* @__PURE__ */ z(`DELETE_LINE_COMMAND`),Dp=/* @__PURE__ */ z(`FORMAT_TEXT_COMMAND`),Op=/* @__PURE__ */ z(`UNDO_COMMAND`),kp=/* @__PURE__ */ z(`REDO_COMMAND`),Ap=/* @__PURE__ */ z(`KEYDOWN_COMMAND`),jp=/* @__PURE__ */ z(`KEY_ARROW_RIGHT_COMMAND`),Mp=/* @__PURE__ */ z(`MOVE_TO_END`),Np=/* @__PURE__ */ z(`KEY_ARROW_LEFT_COMMAND`),Pp=/* @__PURE__ */ z(`MOVE_TO_START`),Fp=/* @__PURE__ */ z(`KEY_ARROW_UP_COMMAND`),Ip=/* @__PURE__ */ z(`KEY_ARROW_DOWN_COMMAND`),Lp=/* @__PURE__ */ z(`KEY_ENTER_COMMAND`),Rp=/* @__PURE__ */ z(`KEY_SPACE_COMMAND`),zp=/* @__PURE__ */ z(`KEY_BACKSPACE_COMMAND`),Bp=/* @__PURE__ */ z(`KEY_ESCAPE_COMMAND`),Vp=/* @__PURE__ */ z(`KEY_DELETE_COMMAND`),Hp=/* @__PURE__ */ z(`KEY_TAB_COMMAND`),Up=/* @__PURE__ */ z(`DROP_COMMAND`),Wp=/* @__PURE__ */ z(`DRAGSTART_COMMAND`),Gp=/* @__PURE__ */ z(`DRAGOVER_COMMAND`),Kp=/* @__PURE__ */ z(`DRAGEND_COMMAND`),qp=/* @__PURE__ */ z(`COPY_COMMAND`),Jp=/* @__PURE__ */ z(`CUT_COMMAND`),Yp=/* @__PURE__ */ z(`SELECT_ALL_COMMAND`),Xp=/* @__PURE__ */ z(`CLEAR_EDITOR_COMMAND`),Zp=/* @__PURE__ */ z(`CLEAR_HISTORY_COMMAND`),Qp=/* @__PURE__ */ z(`CAN_REDO_COMMAND`),$p=/* @__PURE__ */ z(`CAN_UNDO_COMMAND`),em=/* @__PURE__ */ z(`FOCUS_COMMAND`),tm=/* @__PURE__ */ z(`BLUR_COMMAND`),nm=/* @__PURE__ */ z(`KEY_MODIFIER_COMMAND`);function rm(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 im(e,t,n,r){return e.addEventListener(t,n,r),e.removeEventListener.bind(e,t,n,r)}let am=Object.freeze({}),om=[[`keydown`,function(e,t){let n=t._inputState;n.lastKeyDownTimeStamp=e.timeStamp,n.lastKeyCode=e.key,e.key!==`Backspace`&&_m(n),!t.isComposing()&&q(t,Ap,e)}],[`pointerdown`,function(e,t){let n=Gv(e),r=e.pointerType;Kv(n)&&r!==`touch`&&r!==`pen`&&e.button===0&&Fg(t,()=>{hy(n,t)||(t._inputState.isSelectionChangeFromMouseDown=!0)})}],[`compositionstart`,function(e,t){q(t,_p,e)}],[`compositionend`,function(e,t){let n=t._inputState;hd?n.compositionPhase=`ending-firefox`:_d||!yd&&!Sd?q(t,vp,e):(n.compositionPhase=`ending-safari`,n.compositionEndData=e.data)}],[`input`,function(e,t){e.stopPropagation();let n=t._inputState;_m(n),Fg(t,()=>{ym(e,t)||t.dispatchCommand(gp,e)},{event:e}),n.unprocessedBeforeInputData=null}],[`click`,function(e,t){Fg(t,()=>{let n=H(),r=kv(vv(t)),i=Kh();if(r){if(V(n)){let e=n.anchor,t=e.getNode();e.type===`element`&&e.offset===0&&n.isCollapsed()&&!Vg(t)&&U_().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=zv(r,t._rootElement).anchorNode;(J(n)||D_(n))&&W_(Gh(i,r,t,e))}}if(hd&&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(J(t)){let n=t.getBoundingClientRect();if(a<=(n.top+n.bottom)/2){o=e;break}}}r.setBaseAndExtent(n,o,n,o);let s=Gh(i,r,t,e);s===null?r.removeAllRanges():W_(s)}}q(t,mp,e)})}],[`cut`,am],[`copy`,am],[`dragstart`,am],[`dragover`,am],[`dragend`,am],[`paste`,am],[`focus`,am],[`blur`,am],[`drop`,am]];gd&&om.push([`beforeinput`,(e,t)=>function(e,t){let n=e.inputType;n===`deleteCompositionText`||hd&&uv(t)||n!==`insertCompositionText`&&Fg(t,()=>{ym(e,t)||q(t,hp,e)},{event:e})}(e,t)]);let sm=/* @__PURE__ */ new WeakMap,cm=/* @__PURE__ */ new WeakMap,lm=rm(e=>(e.addEventListener(`selectionchange`,km),()=>e.removeEventListener(`selectionchange`,km)));function um(e,t,n,r,i,a){let o=e.anchor,s=e.focus,c=o.getNode(),l=U(),u;if(a!==void 0)u=a;else{let e=kv(vv(l));u=e===null?null:zv(e,l._rootElement)}let d=u===null?null:u.anchorNode,f=o.key,p=l.getElementByKey(f),m=n.length;return f!==s.key||!B(c)||(!i&&(!gd||l._inputState.lastBeforeInputInsertTextTimeStamp<r+50)||c.isDirty()&&m<2||q_(n))&&o.offset!==s.offset&&!c.isComposing()||E_(c)||c.isDirty()&&m>1||(i||!gd)&&p!==null&&!c.isComposing()&&d!==ry(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=T_(t);return n===0?!t.canInsertTextBefore()||!r.canInsertTextBefore()&&!t.isComposing()||i||function(e){let t=e.getPreviousSibling();return(B(t)||W(t)&&t.isInline())&&!t.canInsertTextAfter()}(t):n===t.getTextContentSize()&&(!t.canInsertTextAfter()||!r.canInsertTextAfter()&&!t.isComposing()||i)}(e,c)}function dm(e,t){return D_(e)&&e.nodeValue!==null&&t!==0&&t!==e.nodeValue.length}function fm(e,t,n){let{anchorNode:r,anchorOffset:i,focusNode:a,focusOffset:o}=zv(e,t._rootElement),s=t._inputState;s.isSelectionChangeFromDOMUpdate&&(s.isSelectionChangeFromDOMUpdate=!1,dm(r,i)&&dm(a,o)&&!s.postDeleteSelectionToRestore)||Fg(t,()=>{if(!n)return void W_(null);if(!x_(t,r,a))return;let c=H();if(s.postDeleteSelectionToRestore&&V(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(),W_(c))}if(s.postDeleteSelectionToRestore=null,V(c)){let n=c.anchor,l=n.getNode();if(c.isCollapsed()){e.type===`Range`&&r===a&&(c.dirty=!0);let i=vv(t).event,o=i?i.timeStamp:performance.now(),{format:u,style:d,offset:f,key:p,timeStamp:m}=s.collapsedSelectionFormat,h=U_(),g=!1===t.isComposing()&&h.getTextContent()===``;if(o<m+200&&n.offset===f&&n.key===p)pm(c,u,d);else if(n.type===`text`)B(l)||I(141),mm(c,l);else if(n.type===`element`&&!g){W(l)||I(259);let e=n.getNode();e.isEmpty()?function(e,t){pm(e,t.getTextFormat(),t.getTextStyle())}(c,e):pm(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(B(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}}q(t,pp)})}function pm(e,t,n){e.format===t&&e.style===n||(e.format=t,e.style=n,e.dirty=!0)}function mm(e,t){pm(e,t.getFormat(),t.getStyle())}function hm(e){if(!e.getTargetRanges)return null;let t=e.getTargetRanges();return t.length===0?null:t[0]}function gm(e){let{lastKeyCode:t}=U()._inputState;if(e==null||e.length<=1||t==null)return;let n=t.length===1?t:t===`Enter`?`
134
- `:t===`Tab`?` `:null;if(!n)return;let r=H();if(!V(r)||!r.isCollapsed())return;let i=r.anchor.getNode();if(!B(i))return;let{offset:a}=r.anchor;if(i.getTextContentSize()===a){let e=i.getNextSibling();if(n===`
135
- `){if(Zg(e))e.selectEnd();else if(!e){let e=Sy(i,Vh),t=e&&e.getNextSibling();W(t)&&t.selectStart()}}else n===` `?ph(e)&&e.selectEnd():B(e)&&e.getTextContent()[0]===n&&e.select(1,1)}else i.getTextContent()[a]===n&&i.select(a+1,a+1)}function _m(e){e.isInsertTextAfterHandledSelectionCommand=!1,e.handledSelectionCommandTimeoutId!==null&&(clearTimeout(e.handledSelectionCommandTimeoutId),e.handledSelectionCommandTimeoutId=null)}function vm(e){_m(e),e.isInsertTextAfterHandledSelectionCommand=!0,e.handledSelectionCommandTimeoutId=setTimeout(()=>_m(e),0)}function ym(e,t){let n=Gv(e);if(J(n)&&hy(n,t))return!0;let r=t.getRootElement();if(r===null)return!1;let i=Wv(r.ownerDocument);return i!==null&&r.contains(i)&&hy(i,t)}function bm(e){let t=e.inputType,n=hm(e),r=U(),i=r._inputState,a=H();if(t===`insertText`&&e.data&&i.isInsertTextAfterHandledSelectionCommand){if(_m(i),e.preventDefault(),V(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=Kh();if(!V(e))return!0;W_(e.clone())}if(V(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(P_(null),i.lastKeyDownTimeStamp=0,setTimeout(()=>{Fg(r,()=>{P_(null)})},30),V(a)){let e=a.anchor.getNode();e.markDirty(),B(e)||I(142),mm(a,e)}}else{if(P_(null),_d&&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=xd&&t&&!l&&c;if(u&&a.isCollapsed()&&(u=!G(lv(a.anchor,!0))),!u){q(r,yp,!0);let e=H();xd&&V(e)&&e.isCollapsed()&&(i.postDeleteSelectionToRestore=e,setTimeout(()=>i.postDeleteSelectionToRestore=null))}}return!0}}if(!V(a))return!0;let o=e.data;i.unprocessedBeforeInputData!==null&&Z_(!1,r,i.unprocessedBeforeInputData),a.dirty&&i.unprocessedBeforeInputData===null||!a.isCollapsed()||Vg(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(),q(r,bp,!1);else if(o===`
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`?`
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===`
137
137
 
138
- `)e.preventDefault(),q(r,xp);else if(o==null&&e.dataTransfer){let t=e.dataTransfer.getData(`text/plain`);e.preventDefault(),a.insertRawText(t)}else o!=null&&um(a,n,o,e.timeStamp,!0)?(e.preventDefault(),q(r,Sp,o),gm(o)):i.unprocessedBeforeInputData=o;return i.lastBeforeInputInsertTextTimeStamp=e.timeStamp,!0}switch(e.preventDefault(),t){case`insertFromYank`:case`insertFromDrop`:case`insertReplacementText`:q(r,Sp,e),gm((e.dataTransfer?e.dataTransfer.getData(`text/plain`):null)??e.data);break;case`insertFromComposition`:{let t=i.hadOrphanedCompositionEvents;i.hadOrphanedCompositionEvents=!1;let n=r._compositionKey;P_(null),t||q(r,Sp,e),wm(n);break}case`insertLineBreak`:P_(null),q(r,bp,!1);break;case`insertParagraph`:P_(null),i.isInsertLineBreak&&!_d?(i.isInsertLineBreak=!1,q(r,bp,!1)):q(r,xp);break;case`insertFromPaste`:case`insertFromPasteAsQuotation`:q(r,Cp,e);break;case`deleteByComposition`:(function(e,t){return e!==t||W(e)||W(t)||!T_(e)||!T_(t)})(l,u)&&q(r,wp,e);break;case`deleteByDrag`:mv(Hm),q(r,wp,e);break;case`deleteByCut`:q(r,wp,e);break;case`deleteContent`:q(r,yp,!1);break;case`deleteWordBackward`:q(r,Tp,!0);break;case`deleteWordForward`:q(r,Tp,!1);break;case`deleteHardLineBackward`:case`deleteSoftLineBackward`:q(r,Ep,!0);break;case`deleteContentForward`:case`deleteHardLineForward`:case`deleteSoftLineForward`:q(r,Ep,!1);break;case`formatStrikeThrough`:q(r,Dp,`strikethrough`);break;case`formatBold`:q(r,Dp,`bold`);break;case`formatItalic`:q(r,Dp,`italic`);break;case`formatUnderline`:q(r,Dp,`underline`);break;case`historyUndo`:q(r,Op);break;case`historyRedo`:q(r,kp)}return!0}function xm(e){let t=U(),n=t._inputState,r=H(),i=e.data,a=hm(e),o=!1;if(i!=null&&V(r)){let s=kv(vv(t)),c=s===null?null:zv(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()&&B(u)&&E_(u);if(!l&&!d&&um(r,a,i,e.timeStamp,!1,c)){if(o=!0,n.compositionPhase===`ending-firefox`){let e=Tm(t,i);if(n.compositionPhase=`idle`,e)return mv(Um),G_(),!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;gd&&!r.isCollapsed()&&B(a)&&c.anchorNode!==null&&a.getTextContent().slice(0,u)+i+a.getTextContent().slice(u+d)===X_(c.anchorNode)||q(t,Sp,i);let f=i.length;hd&&f>1&&e.inputType===`insertCompositionText`&&!t.isComposing()&&(r.anchor.offset-=f,r._cachedNodes=null,r._cachedIsBackward=null),xd&&t.isComposing()&&(n.lastKeyDownTimeStamp=0,P_(null))}}return o||(Z_(!1,t,i===null?void 0:i),n.compositionPhase===`ending-firefox`&&(Tm(t,i||void 0),mv(`composition-end`),n.compositionPhase=`idle`)),G_(),!0}function Sm(e){let t=U(),n=t._inputState,r=H();if(V(r)&&!t.isComposing()){n.compositionPhase=`composing`,n.hadOrphanedCompositionEvents=!1;let i=r.anchor,a=r.anchor.getNode();if(P_(i.key),mv(`composition-start`),e.timeStamp<n.lastKeyDownTimeStamp+30||i.type===`element`||!r.isCollapsed()||!xd&&(a.getFormat()!==r.format||B(a)&&a.getStyle()!==r.style)||B(a)&&(E_(a)||i.offset===0&&!a.canInsertTextBefore()||i.offset===a.getTextContentSize()&&!a.canInsertTextAfter())){q(t,Sp,wd);let e=H();V(e)&&P_(e.anchor.key)}}return!0}function Cm(e){let t=U();return t._inputState.compositionPhase=`idle`,Tm(t,e.data),mv(Um),!0}function wm(e){if(e===null)return;let t=I_(e);if(!B(t)||t.getType()===`text`||E_(t)||!t.isAttached())return;let n=H(),r=V(n)&&n.anchor.key===e?n.anchor.offset:null,i=lh(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 Tm(e,t){let n=e._compositionKey;if(P_(null),n!==null&&t!=null){if(t===``){let t=I_(n),r=e.getElementByKey(n),i=r!==null&&B(t)?ry(t,r,e):null;if(i!==null&&i.nodeValue!==null&&B(t)){let n=kv(vv(e)),r=n&&zv(n,e._rootElement),a=null,o=null;r!==null&&r.anchorNode===i&&(a=r.anchorOffset,o=r.focusOffset),Q_(t,i.nodeValue,a,o,!0)}return wm(n),!1}if(t[t.length-1]===`
139
- `){let t=H();if(V(t)||Ch(t)){if(V(t)){let e=t.focus;t.anchor.set(e.key,e.offset,e.type)}return q(e,Lp,null),wm(n),!1}}let r=I_(n);if(r!==null&&B(r)&&E_(r)){r.markDirty();let e=H(),i=r.getTextContentSize(),a=V(e)&&e.anchor.key===n?e.anchor.offset:i;return r.select(a,a).insertText(t),!0}}return Z_(!0,e,t),wm(n),!1}function Em(e){let t=U(),n=t._inputState;if(e.key==null)return!0;if(n.compositionPhase===`ending-safari`){let r=iv(e);if(r&&Fg(t,()=>{Tm(t,n.compositionEndData)}),n.compositionPhase=`idle`,n.compositionEndData=``,r)return!0}if(function(e){return K(e,`ArrowRight`,{shiftKey:`any`})}(e))q(t,jp,e);else if(function(e){return K(e,`ArrowRight`,{...nv,shiftKey:`any`})}(e))q(t,Mp,e);else if(function(e){return K(e,`ArrowLeft`,{shiftKey:`any`})}(e))q(t,Np,e);else if(function(e){return K(e,`ArrowLeft`,{...nv,shiftKey:`any`})}(e))q(t,Pp,e);else if(function(e){return K(e,`ArrowUp`,{altKey:`any`,shiftKey:`any`})}(e))q(t,Fp,e);else if(function(e){return K(e,`ArrowDown`,{altKey:`any`,shiftKey:`any`})}(e))q(t,Ip,e);else if(function(e){return K(e,`Enter`,{altKey:`any`,ctrlKey:`any`,metaKey:`any`,shiftKey:!0})}(e))n.isInsertLineBreak=!0,q(t,Lp,e);else if(function(e){return e.key===` `}(e))q(t,Rp,e);else if(function(e){return md&&K(e,`o`,{ctrlKey:!0})}(e))e.preventDefault(),n.isInsertLineBreak=!0,q(t,bp,!0);else if(function(e){return K(e,`Enter`,{altKey:`any`,ctrlKey:`any`,metaKey:`any`})}(e))n.isInsertLineBreak=!1,q(t,Lp,e);else if(function(e){return K(e,`Backspace`,{shiftKey:`any`})||md&&K(e,`h`,{ctrlKey:!0})}(e))iv(e)?q(t,zp,e)&&vm(n):(e.preventDefault(),q(t,yp,!0));else if(function(e){return e.key===`Escape`}(e))q(t,Bp,e);else if(function(e){return K(e,`Delete`,{})||md&&K(e,`d`,{ctrlKey:!0})}(e))(function(e){return e.key===`Delete`})(e)?q(t,Vp,e):(e.preventDefault(),q(t,yp,!1));else if(function(e){return K(e,`Backspace`,rv)}(e))e.preventDefault(),q(t,Tp,!0);else if(function(e){return K(e,`Delete`,rv)}(e))e.preventDefault(),q(t,Tp,!1);else if(function(e){return md&&K(e,`Backspace`,{metaKey:!0})}(e))e.preventDefault(),q(t,Ep,!0);else if(function(e){return md&&(K(e,`Delete`,{metaKey:!0})||K(e,`k`,{ctrlKey:!0}))}(e))e.preventDefault(),q(t,Ep,!1);else if(function(e){return K(e,`b`,nv)}(e))e.preventDefault(),q(t,Dp,`bold`);else if(function(e){return K(e,`u`,nv)}(e))e.preventDefault(),q(t,Dp,`underline`);else if(function(e){return K(e,`i`,nv)}(e))e.preventDefault(),q(t,Dp,`italic`);else if(function(e){return K(e,`Tab`,{shiftKey:`any`})}(e))q(t,Hp,e);else if(function(e){return K(e,`z`,nv)}(e))e.preventDefault(),q(t,Op);else if(function(e){return md?K(e,`z`,{metaKey:!0,shiftKey:!0}):K(e,`y`,{ctrlKey:!0})||K(e,`z`,{ctrlKey:!0,shiftKey:!0})}(e))e.preventDefault(),q(t,kp);else{let r=t._editorState._selection;(function(e){return K(e,`a`,nv)})(e)?(e.preventDefault(),q(t,Yp,e)&&vm(n)):r===null||V(r)||(function(e){return K(e,`c`,nv)}(e)?(e.preventDefault(),q(t,qp,e)):function(e){return K(e,`x`,nv)}(e)&&(e.preventDefault(),q(t,Jp,e)))}return function(e){return e.ctrlKey||e.shiftKey||e.altKey||e.metaKey}(e)&&t.dispatchCommand(nm,e),!0}function Dm(e){let t=e.__lexicalEventHandles;return t===void 0&&(t=[],e.__lexicalEventHandles=t),t}let Om=/* @__PURE__ */ new Map;function km(e){let t=Av(e.target);if(t===null)return;let n=pv(e.target),r=null,i=null,a=n===null?void 0:cm.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&&jv(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=zv(t,e).anchorNode;if(s!==null&&C_(s)===o){if(jv(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||J(e)&&e.shadowRoot!==null||(r=C_(e),r!==null&&(i=e))}}if(r===null){let e=Wv(n);r=e===null?null:C_(e)}}if(r===null)return;if(r._inputState.isSelectionChangeFromMouseDown){if(a!==void 0)for(let e of a.editors)e._inputState.isSelectionChangeFromMouseDown=!1;Fg(r,()=>{let n=Kh(),a=i??zv(t,r._rootElement).anchorNode;(J(a)||D_(a))&&W_(Gh(n,t,r,e))})}let o=J_(r),s=o[o.length-1],c=s._key,l=Om.get(c),u=l||s;u!==r&&fm(t,u,!1),fm(t,r,!0),r===s?l&&Om.delete(c):Om.set(c,r)}function Am(e){e._lexicalHandled=!0}function jm(e){return!0===e._lexicalHandled}function Mm(e){let t=sm.get(e);if(t===void 0)return;let n=cm.get(t);if(n===void 0)return;sm.delete(e);let r=w_(e);S_(r)?(function(e){if(e._parentEditor!==null){let t=J_(e),n=t[t.length-1]._key;Om.get(n)===e&&Om.delete(n)}else Om.delete(e._key)}(r),n.editors.delete(r),n.hasShadowEditor=void 0,e.__lexicalEditor=null):r&&I(198);let i=Dm(e);for(let e=0;e<i.length;e++)i[e]();e.__lexicalEventHandles=[]}function Nm(e,t,n){_g();let r=e.__key,i=e.getParent();if(i===null)return void(Oy(e)!==null&&I(367,r,String(Oy(e))));let a=function(e){let t=H();if(!V(t)||!W(e))return t;let{anchor:n,focus:r}=t,i=n.getNode(),a=r.getNode();return gv(i,e)&&n.set(e.__key,0,`element`),gv(a,e)&&r.set(e.__key,0,`element`),t}(e),o=!1;if(V(a)&&t){let t=a.anchor,n=a.focus;t.key===r&&(Yh(t,e,i,e.getPreviousSibling(),e.getNextSibling()),o=!0),n.key===r&&(Yh(n,e,i,e.getPreviousSibling(),e.getNextSibling()),o=!0)}else Ch(a)&&t&&e.isSelected()&&e.selectPrevious();if(V(a)&&t&&!o){let t=e.getIndexWithinParent();M_(e),qh(a,i,t,-1)}else M_(e);n||Sv(i)||i.canBeEmpty()||!i.isEmpty()||Nm(i,t),t&&a&&Vg(i)&&i.isEmpty()&&i.selectEnd()}let Pm=Symbol.for(`ephemeral`);function Fm(e){return e[Pm]||!1}let Im={configurable:!0,enumerable:!1,value:void 0,writable:!0};var Lm=class{__type;__key;__parent;__prev;__next;__state;[bf];static getType(){let{ownNodeType:e}=yy(this);return e===void 0&&I(64,this.name),e}static clone(e){I(65,this.name)}$config(){return{}}config(e,t){let n=t.extends||wy(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",Im),Object.defineProperty(this,bf,Im),j_(this,e)}getType(){return this.__type}isInline(){I(137,this.constructor.name)}isAttached(){let e=this.__key;for(;e!==null;){if(e===`root`)return!0;let t=I_(e);if(t===null)break;e=t.__parent===null?Oy(t):t.__parent}return!1}isSelected(e){let t=e||H();if(t==null)return!1;let n=t.getNodes().some(e=>e.__key===this.__key);if(B(this))return n;if(V(t)&&t.anchor.type===`element`&&t.focus.type===`element`){if(t.isCollapsed())return!1;let e=this.getParent();if(G(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:I_(e)}getParentOrThrow(){let e=this.getParent();return e===null&&I(66,this.__key),e}getTopLevelElement(){let e=this;for(;e!==null;){let t=e.getParent();if(Sv(t)||Oy(e)!==null)return W(e)||e===this&&G(e)||I(194),e;e=t}return null}getTopLevelElementOrThrow(){let e=this.getTopLevelElement();return e===null&&I(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:I_(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:I_(e)}getNextSiblings(){let e=[],t=this.getNextSibling();for(;t!==null;)e.push(t),t=t.getNextSibling();return e}getCommonAncestor(e){let t=W(this)?this:this.getParent(),n=W(e)?e:e.getParent(),r=t&&n?wb(t,n):null;return r?r.commonAncestor:null}is(e){return e!=null&&this.__key===e.__key}isBefore(e){let t=wb(this,e);return t!==null&&(t.type===`descendant`||(t.type===`branch`?xb(t)===-1:(t.type!==`same`&&t.type!==`ancestor`&&I(279),!1)))}isParentOf(e){return gv(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=W(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&&I(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=U()._dirtyLeaves;return e!==null&&e.has(this.__key)}getLatest(){if(Fm(this))return this;let e=I_(this.__key);return e===null&&I(113),e}getWritable(){if(Fm(this))return this;_g();let e=yg(),t=U(),n=e._nodeMap,r=this.__key,i=this.getLatest(),a=t._cloneNotNeeded,o=H();if(o!==null&&o.setCachedNodes(null),a.has(r))return N_(i),i;let s=sy(i);return a.add(r),N_(s),n.set(r,s),s}getTextContent(){return Vy(this)}getTextContentSize(){return this.getTextContent().length}createDOM(e,t){I(70)}updateDOM(e,t,n){I(71)}getDOMSlot(e){return new Id(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){I(18,this.name)}updateFromJSON(e){return function(e,t){let n=e.getWritable(),r=t.$,i=r;for(let e of lf(n).flatKeys)e in t&&(i!==void 0&&i!==r||(i={...r}),i[e]=t[e]);return(n.__state||i)&&cf(e).updateFromJSON(i),n}(this,e)}static transform(){return null}remove(e){Nm(this,!0,e)}replace(e,t){_g();let n=H();n!==null&&(n=n.clone()),Tv(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();M_(o),l!==null&&V(n)&&qh(n,l,u,-1);let d=r.getPreviousSibling(),f=r.getNextSibling(),p=r.__prev,m=r.__next,h=r.__parent;Nm(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&&(W(this)&&W(o)||I(139),g=o.getChildrenSize(),o.splice(g,0,this.getChildren()));let _=Ny(this);if(_.length>0){Ey(this)&&Ey(o)||I(368,this.__key,o.__key);for(let e of _){let t=Py(this,e);t!==null&&(Gy(this,e),Wy(o,e,t))}}if(V(n)){W_(n);let e=n.anchor,r=n.focus;e.key===i&&(t&&e.type===`element`?e.set(o.__key,g+e.offset,`element`):_h(e,o)),r.key===i&&(t&&r.type===`element`?r.set(o.__key,g+r.offset,`element`):_h(r,o))}return F_()===i&&P_(a),o}insertAfter(e,t=!0){_g(),Tv(this,e);let n=this.getWritable(),r=e.getWritable();this.getParentOrThrow();let i=r.getParent(),a=H(),o=!1,s=!1;if(i!==null){let n=e.getIndexWithinParent();if(V(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}M_(r),t&&V(a)&&qh(a,i,n,-1)}else M_(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&&V(a)){let e=this.getIndexWithinParent();qh(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){_g(),Tv(this,e);let n=this.getWritable(),r=e.getWritable();this.getParentOrThrow();let i=r.__key,a=H(),o=r.getParent(),s=o===null?-1:r.getIndexWithinParent();M_(r),o!==null&&t&&V(a)&&qh(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&&V(a)&&qh(a,this.getParentOrThrow(),d),e}isParentRequired(){return!1}createParentElementNode(){return r_()}selectStart(){return this.selectPrevious()}selectEnd(){return this.selectNext(0,0)}selectPrevious(e,t){_g();let n=ky(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(W(r))return r.select();if(!B(r)){let e=r.getIndexWithinParent()+1;return i.select(e,e)}return r.select(e,t)}selectNext(e,t){_g();let n=ky(this);if(n!==null)return n.selectNext(e,t);let r=this.getNextSibling(),i=this.getParentOrThrow();if(r===null)return i.select();if(W(r))return r.select(0,0);if(!B(r)){let e=r.getIndexWithinParent();return i.select(e,e)}return r.select(e,t)}markDirty(){this.getWritable()}reconcileObservedMutation(e,t){this.markDirty()}};function Rm(e){return e instanceof Lm}let zm=`history-merge`,Bm=`paste`,Vm=`skip-dom-selection`,Hm=`skip-selection-focus`,Um=`composition-end`;function Wm(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 Gm(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 Km(e,t,n=``){if(t===n)return;let r=Wm(n),i=Wm(t);for(let t in i)delete r[t],Gm(e,t,i[t]);for(let t in r)e.removeProperty(t)}function qm(e,t){return 16&t?`code`:t&128?`mark`:32&t?`sub`:64&t?`sup`:null}function Jm(e,t){return 1&t?`strong`:2&t?`em`:`span`}function Ym(e,t,n,r,i){let a=r.classList,o=ov(i,`base`);o!==void 0&&a.add(...o),o=ov(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 Dd){let r=Dd[e];if(o=ov(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 Xm(e,t,n){let r=n.isComposing(),i=e+(r?Cd:``),a=$v(),o=ey(a).$getDOMSlot(n,t,a),s=o.getFirstChild();if(s===null||s.nodeType!==Node.TEXT_NODE)return void o.insertChild(Iv().createTextNode(i));let c=s,l=c.nodeValue;if(l!==i){if(r||hd){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 Zm(e,t,n,r,i,a){Xm(i,e,t);let o=a.theme.text;o!==void 0&&Ym(0,0,r,e,o)}function Qm(e,t){let n=Iv().createElement(t);return n.appendChild(e),n}function $m(e){return e!=null&&!0===e.__isInlineFormattable}var eh=class extends Lm{__text;__format;__style;__mode;__detail;get __isInlineFormattable(){return!0}$config(){return this.config(`text`,{importDOM:{"#text":()=>({conversion:ah,priority:0}),b:()=>({conversion:nh,priority:0}),code:()=>({conversion:ch,priority:0}),em:()=>({conversion:ch,priority:0}),i:()=>({conversion:ch,priority:0}),mark:()=>({conversion:ch,priority:0}),s:()=>({conversion:ch,priority:0}),span:()=>({conversion:th,priority:0}),strong:()=>({conversion:ch,priority:0}),sub:()=>({conversion:ch,priority:0}),sup:()=>({conversion:ch,priority:0}),u:()=>({conversion:ch,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 Md[e.__mode]}getStyle(){return this.getLatest().__style}isToken(){return this.getLatest().__mode===1}isComposing(){return this.__key===F_()}isSegmented(){return this.getLatest().__mode===2}isDirectionless(){return!!(1&this.getLatest().__detail)}isUnmergeable(){return!!(2&this.getLatest().__detail)}hasFormat(e){let t=Dd[e];return(this.getFormat()&t)!==0}isSimpleText(){return this.__type===`text`&&this.__mode===0}getTextContent(){return this.getLatest().__text}getFormatFlags(e,t){return A_(this.getLatest().__format,e,t)}canHaveFormat(){return!0}isInline(){return!0}createDOM(e,t){let n=this.__format,r=qm(0,n),i=Jm(0,n),a=r===null?i:r,o=Iv().createElement(a),s=o;this.hasFormat(`code`)&&o.setAttribute(`spellcheck`,`false`),r!==null&&(s=Iv().createElement(i),o.appendChild(s)),Zm(s,this,0,n,this.__text,e);let c=this.__style;return c!==``&&Km(o.style,c),o}updateDOM(e,t,n){let r=this.__text,i=e.__format,a=this.__format,o=qm(0,i),s=qm(0,a),c=Jm(0,i),l=Jm(0,a);if((o===null?c:o)!==(s===null?l:s))return!0;if(o===s&&c!==l){let e=t.firstChild;e??I(48);let i=Iv().createElement(l);return Zm(i,this,0,a,r,n),t.replaceChild(i,e),!1}let u=t;s!==null&&o!==null&&(u=t.firstChild,u??I(49)),Xm(r,u,this);let d=n.theme.text;d!==void 0&&i!==a&&Ym(0,i,a,u,d);let f=e.__style,p=this.__style;return f!==p&&Km(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 J(t)||I(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=Qm(t,`b`)),this.hasFormat(`italic`)&&(t=Qm(t,`i`)),this.hasFormat(`strikethrough`)&&(t=Qm(t,`s`)),this.hasFormat(`underline`)&&(t=Qm(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`?Dd[e]:e,t}setDetail(e){let t=this.getWritable();return t.__detail=typeof e==`string`?Od[e]:e,t}setStyle(e){let t=this.getWritable();return t.__style=e,t}toggleFormat(e){let t=A_(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=jd[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){_g();let n=e,r=t,i=H(),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(!V(i))return Hh(o,n,o,r,`text`,`text`);{let e=F_();e!==i.anchor.key&&e!==i.focus.key||P_(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=H();if(r&&V(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){_g();let t=this.getLatest(),n=t.getTextContent();if(n===``)return[];let r=t.__key,i=F_(),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=H();if(V(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=lh(l),d.__format=f,d.__style=p,d.__detail=m,d.__state=mf(t,d),h=!0):d=t.setTextContent(l);let y=[d];for(let e=1;e<c;e++){let n=lh(o[e]);n.__format=f,n.__style=p,n.__detail=m,n.__state=mf(t,n);let a=n.__key;i===r&&P_(a),y.push(n)}let b=g?g.offset:null,x=_?_.offset:null,ee=0;for(let e of y){if(!g&&!_)break;let t=ee+e.getTextContentSize();if(g!==null&&b!==null&&b<=t&&b>=ee&&(g.set(e.getKey(),b-ee,`text`),b<t&&(g=null)),_!==null&&x!==null&&x<=t&&x>=ee){_.set(e.getKey(),x-ee,`text`);break}ee=t}if(u!==null){(function(e){let t=e.getPreviousSibling(),n=e.getNextSibling();t!==null&&N_(t),n!==null&&N_(n)})(this);let e=u.getWritable(),t=this.getIndexWithinParent();h?(e.splice(t,0,y),this.remove()):e.splice(t,1,y),V(v)&&qh(v,u,t,c-1)}return y}mergeWithSibling(e){let t=e===this.getPreviousSibling();t||e===this.getNextSibling()||I(50);let n=this.__key,r=e.__key,i=this.__text,a=i.length;F_()===r&&P_(n);let o=H();if(V(o)){let i=o.anchor,s=o.focus;i!==null&&i.key===r&&Xh(i,t,n,e,a),s!==null&&s.key===r&&Xh(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 th(e){return{forChild:uh(e.style),node:null}}function nh(e){let t=e,n=t.style.fontWeight===`normal`;return{forChild:uh(t.style,n?void 0:`bold`),node:null}}let rh=/* @__PURE__ */ new WeakMap;function ih(e){if(!J(e))return!1;if(e.nodeName===`PRE`)return!0;let t=e.style.whiteSpace;return typeof t==`string`&&t.startsWith(`pre`)}function ah(e){let t=e;e.parentElement===null&&I(129);let n=t.textContent||``;if(function(e){let t,n=e.parentNode,r=[e];for(;n!==null&&(t=rh.get(n))===void 0&&!ih(n);)r.push(n),n=n.parentNode;let i=t===void 0?n:t;for(let e=0;e<r.length;e++)rh.set(r[e],i);return i}(t)!==null)return{node:tg(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=oh(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=oh(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:lh(n)}}function oh(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,J(n)){let e=n.style.display;if(e===``&&!Yv(n)||e!==``&&!e.startsWith(`inline`))return null}let r=n;for(;(r=t?n.firstChild:n.lastChild)!==null;)n=r;if(D_(n))return n;if(n.nodeName===`BR`)return null}}let sh={code:`code`,em:`italic`,i:`italic`,mark:`highlight`,s:`strikethrough`,strong:`bold`,sub:`subscript`,sup:`superscript`,u:`underline`};function ch(e){let t=sh[e.nodeName.toLowerCase()];return t===void 0?{node:null}:{forChild:uh(e.style,t),node:null}}function lh(e=``){return wv(new eh(e))}function B(e){return e instanceof eh}function uh(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=>((B(e)||$m(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 eh{$config(){return this.config(`tab`,{extends:eh})}constructor(e=void 0){super(` `,e),this.__detail=2}createDOM(e){let t=super.createDOM(e),n=ov(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||I(286),this}setDetail(e){return e!==2&&I(127),this}setMode(e){return e!==`normal`&&I(128),this}canInsertTextBefore(){return!1}canInsertTextAfter(){return!1}};function fh(){return wv(new dh)}function ph(e){return e instanceof dh}var mh=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:bb(Pb(Tb(this,`next`)),Pb(Tb(e,`next`)))<0}getNode(){let e=I_(this.key);return e===null&&I(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,gg()||(F_()===a&&P_(e),i!==null&&(i.setCachedNodes(null),V(i)&&(i._cachedIsBackward=null),i.dirty=!0)))}};function hh(e,t,n){return new mh(e,t,n)}function gh(e,t){let n=t.__key,r=e.offset,i=`element`;if(B(t)){i=`text`;let e=t.getTextContentSize();r>e&&(r=e)}else if(!W(t)){let e=t.getNextSibling();if(B(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 _h(e,t){if(W(t)){let n=t.getLastDescendant();W(n)||B(n)?gh(e,n):gh(e,t)}else gh(e,t)}function vh(e,t,n,r){let i=e.getNode(),a=i.getChildAtIndex(e.offset),o=lh();if(o.setFormat(n),o.setStyle(r),i_(a))a.splice(0,0,[o]);else if(a!==null){let e=Sv(i)?r_().append(o):o;a.insertBefore(e)}else if(Sv(i)){let e=i.getLastChild();W(e)&&!e.isInline()&&e.isEmpty()?e.append(o):i.append(r_().append(o))}else i.append(o);e.is(t)&&t.set(o.__key,0,`text`),e.set(o.__key,0,`text`)}function yh(e,t,n,r){let i=e.anchor.getNode();B(i)||I(398);let a=e.anchor.offset,o=lh(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 bh=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(!Ch(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=>Oy(e)===null),n=t.length;if(n===0)return;let r=t[n-1],i;if(B(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=I_(e);t!==null&&n.push(t)}return gg()||(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=>Oy(e)===null);if((H()||Kh())===this&&e[0]){let t=sb(e[0],`next`);Db(vb(t,t))}for(let t of e)t.remove();xh()}};function xh(){let e=U_();if(e.isEmpty()){let t=r_();e.append(t),t.select()}}function V(e){return e instanceof Sh}var Sh=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!!V(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(rb(n)){let{origin:e}=n;t.length===0?i.add(e):(a.add(e),t.push(e))}else{let{origin:e}=n;W(e)&&a.has(e)||t.push(e)}if(r&&t.push(r.caret.origin),nb(e.focus)&&W(e.focus.origin)&&e.focus.getNodeAtCaret()===null)for(let n=db(e.focus.origin,`previous`);rb(n)&&i.has(n.origin)&&!n.origin.isEmpty()&&n.origin.is(t[t.length-1]);n=pb(n))i.delete(n.origin),t.pop();for(;t.length>1;){let e=t[t.length-1];if(!W(e)||a.has(e)||e.isEmpty()||i.has(e))break;t.pop()}if(t.length===0&&e.isCollapsed()){let n=Pb(e.anchor),r=Pb(e.anchor.getFlipped()),i=e=>tb(e)?e.origin:e.getNodeAtCaret(),a=i(n)||i(r)||(e.anchor.getNodeAtCaret()?n.origin:r.origin);t.push(a)}return t}(Lb(kb(this),`next`));return gg()||(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]=Dh(this),c=``,l=!0;for(let u=0;u<e.length;u++){let d=e[u];if(W(d)&&!d.isInline()){l||(c+=`
140
- `);let e=``;for(let t of Ny(d)){let n=Py(d,t);n!==null&&(e+=n.getTextContent())}e===``?l=!d.isEmpty():(c+=e,l=!1)}else if(l=!1,B(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!G(d)&&!Zg(d)||d===n&&this.isCollapsed()||(c+=d.getTextContent())}return c}applyDOMRange(e){let t=U(),n=t.getEditorState()._selection,r=Bh(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),vf(this)}clone(){let t=this.anchor,n=this.focus;return new e(hh(t.key,t.offset,t.type),hh(n.key,n.offset,n.type),this.format,this.style)}toggleFormat(e){this.format=A_(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=Dd[e];return(this.format&t)!==0}insertRawText(e){this.insertNodes(tg(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(B(r)&&(t=r.getFormat(),n=r.getStyle()),this.removeText(),this.format=t,this.style=n,e===``)return;if(F_()===null)return this.anchor.type===`element`&&vh(this.anchor,this.focus,t,n),void yh(this,e,t,n)}this.anchor.type===`element`&&vh(this.anchor,this.focus,t,n);let r=this.anchor.getNode();B(r)||I(398);let i=this.anchor.offset,a=r.getParentOrThrow(),o=r.getTextContentSize();if(E_(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(F_()!==null)r.setMode(`normal`).setFormat(t).setStyle(n);else{let e=lh(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(B(i)&&i.canInsertTextAfter()&&!E_(i))i.select();else{let e=lh();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(B(i)&&i.canInsertTextBefore()&&!E_(i))i.select(0,0);else{let e=lh();e.setFormat(t),e.setStyle(n),a.canInsertTextAfter()?r.insertAfter(e):a.insertAfter(e),e.select(0,0)}this.insertText(e);return}let s=lh(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 yh(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=H()===this;Ob(this,Nb(kb(this))),e&&H()!==this&&W_(this)}formatText(e,t=null){Th(this,e,t)}insertNodes(e){if(e.length===0)return;this.isCollapsed()||this.removeText();let t=this.anchor.getNode();if(this.anchor.type===`element`&&W(t)&&Oy(t)!==null){let n=t.isShadowRoot()?t.getFirstChild()??t.append(r_()).getFirstChild():t.getFirstChild();if(t.isShadowRoot()&&n!==null&&!W(n)){let e=r_();n.insertBefore(e),n=e}if(n!==null){n.selectStart();let t=H();return V(t)||I(369),t.insertNodes(e)}}if(this.anchor.type===`element`&&Sv(t)){let n=og(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=Sy(n,Qv),i=e[e.length-1];if(W(r)&&`__language`in r){if(`__language`in e[0])this.insertText(e[0].getTextContent());else{let t=rg(this);r.splice(t,0,e),i.selectEnd()}return}if(!e.some(e=>(W(e)||G(e))&&!e.isInline())){W(r)||I(211,n.constructor.name,n.getType());let t=rg(this);r.splice(t,0,e),i.selectEnd();return}if(W(r)&&Oy(r)!==null){let t=rg(this),n=ng(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=og(e),n=t.getLastDescendant(),r=Tb(this.anchor,`next`);for(let e of t.getChildren())r=Hb(e,r);n!==null&&n.selectEnd();return}if(W(r)&&!r.isParentRequired()&&!Sv(r.getParentOrThrow())){let t=rg(this),n=ng(e);r.splice(t,0,n);let i=n[n.length-1];i===void 0?r.select(t,t):i.selectEnd();return}let a=og(e),o=a.getLastDescendant(),s=a.getChildren(),c=!W(r)||!r.isEmpty()?this.insertParagraph():null;c&&!r.isAttached()&&(n=this.anchor.getNode(),r=Sy(n,Qv));let l=s[s.length-1],u=s[0];var d;W(d=u)&&Qv(d)&&!d.isEmpty()&&W(r)&&(!r.isEmpty()||r.canMergeWhenEmpty())&&(W(r)||I(211,n.constructor.name,n.getType()),r.append(...u.getChildren()),u=s[1]),u&&(r===null&&I(212,n.constructor.name,n.getType()),function(e,t){let n=t.getParentOrThrow().getLastChild(),r=t,i=[t];for(;r!==n;)r.getNextSibling()||I(140),r=r.getNextSibling(),i.push(r);let a=e;for(let e of i)a=a.insertAfter(e)}(r,u));let f=Sy(o,Qv);c&&W(f)&&(c.canMergeWhenEmpty()||Qv(l))&&(f.append(...c.getChildren()),c.remove()),W(r)&&r.isEmpty()&&r.remove(),o.selectEnd();let p=W(r)?r.getLastChild():null;Zg(p)&&f!==r&&p.remove()}insertParagraph(){let e=this.anchor.getNode();if(this.anchor.type===`element`&&Sv(e)){let t=r_();return e.splice(this.anchor.offset,0,[t]),t.select(),t}let t=rg(this),n=Sy(this.anchor.getNode(),Qv);if(n!==null&&Oy(n)!==null)return null;W(n)||I(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=Xg();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]=Dh(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(B(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(B(n)&&(l===n.getTextContentSize()?e.shift():l!==0&&([,n]=n.splitText(l),e[0]=n,s.set(n.getKey(),0,`text`))),B(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(sg(this,e,t,n))return;let r=e===`move`,i=U(),a=kv(vv(i));if(!a)return;let o=i._blockCursorElement,s=i._rootElement,c=this.focus.getNode();s===null||o===null||!W(c)||c.isInline()||c.canBeEmpty()||Ov(o,i,s);let l=dv(i,this.focus.key),u=l;if(this.focus.type===`text`&&(u=B(c)?ry(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=B(n)?ry(n,e,i):null}t&&u&&Zh(a,t,this.anchor.offset,u,this.focus.offset)}if(n===`character`&&B(c)&&c.isUnmergeable()&&(t?this.focus.offset===0:this.focus.offset===c.getTextContentSize())){let e=sb(c,t?`previous`:`next`).getNodeAtCaret();if(B(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?ry(e,n,i):null;if(r){let e=t?r.length:0;Zh(a,r,e,r,e)}}}}if(Ah(a,e,t?`backward`:`forward`,n),a.rangeCount>0){let e=Lv(a,i._rootElement),n=e||a.getRangeAt(0),o=this.anchor.getNode(),s=Vg(o)?o:bv(o);this.applyDOMRange(n),this.dirty=!0,!r&&(jh(this,t,s),(e?a.direction!==`backward`:a.anchorNode===n.startContainer&&a.anchorOffset===n.startOffset)||kh(this))}n===`lineboundary`&&sg(this,e,t,n,`decorators`)}forwardDeletion(e,t,n){if(!n&&(e.type===`element`&&W(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(W(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=gb(Tb(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(rb(t)){if(!t.origin.isInline()){if(t.origin.isShadowRoot()){if(e.type===`merge-block`)break;if(W(r.anchor.origin)&&r.anchor.origin.isEmpty()){let e=Pb(t);Ob(this,vb(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(nb(t)){if(W(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(G(t.origin)){if(!t.origin.isIsolated()){if(Ny(t.origin).length>0){if(W(r.anchor.origin)&&r.anchor.origin.isEmpty()){r.anchor.origin.remove();let e=Wh();e.add(t.origin.getKey()),W_(e)}}else if(e.type===`merge-next-block`&&(t.origin.isKeyboardSelectable()||!t.origin.isInline())&&W(r.anchor.origin)&&r.anchor.origin.isEmpty()){r.anchor.origin.remove();let e=Wh();e.add(t.origin.getKey()),W_(e)}else t.origin.remove()}return}break}}if(e.type===`merge-block`){let{caret:t,block:n}=e;return Ny(n).length>0?void 0:t.origin.isEmpty()&&!n.isEmpty()&&t.origin.getParent()===n.getParent()?void t.origin.remove(!0):(Ob(this,vb(!t.origin.isEmpty()&&n.isEmpty()?Ab(sb(n,t.direction)):r.anchor,t)),this.removeText())}for(let e=t.getNode();e!==null;){if(Oy(e)!==null)return;if(W(e)&&e.isShadowRoot())break;e=e.getParent()}}let i=this.focus;if(Mh(this,e,`character`),this.isCollapsed()){if(e&&t.offset===0&&Oh(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 Ph(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 Ph(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!(q_(e)||Nh(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()&&Vg(e.getParent())&&e.getPreviousSibling()===null&&Oh(this,e),xh()}}deleteLine(e){let t=Lh(this.anchor);if(t!==null&&G(ky(t)))return this.isCollapsed()||this.focus.set(this.anchor.key,this.anchor.offset,this.anchor.type),void this.deleteCharacter(e);this.isCollapsed()&&Mh(this,e,`lineboundary`),this.isCollapsed()?this.deleteCharacter(e):Sy(this.anchor.getNode(),Qv)===Sy(this.focus.getNode(),Qv)?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;Mh(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 gg()||(this._cachedIsBackward=t),t}getStartEndPoints(){return[this.anchor,this.focus]}};function Ch(e){return e instanceof bh}function wh(e,t){if(Ch(e)){for(let n of e.getNodes())$m(n)&&n.setFormat(t(n.getFormat()));return}if(e.isCollapsed())return e.setFormat(t(e.format)),void P_(null);let n=[];for(let r of e.getNodes())B(r)?n.push(r):W(r)?r.setTextFormat(t(r.getTextFormat())):$m(r)&&r.setFormat(t(r.getFormat()));let r=n.length;if(r===0)return e.setFormat(t(e.format)),void P_(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(E_(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||E_(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()||E_(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 Th(e,t,n=null){let r=n===null&&V(e)?A_(e.format,t,null):n;wh(e,e=>A_(e,t,r))}function Eh(e){let t=e.offset;if(e.type===`text`)return t;let n=e.getNode();return t===n.getChildrenSize()?n.getTextContent().length:0}function Dh(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]:[Eh(n),Eh(r)]}function Oh(e,t){for(let n=t;n;n=n.getParent()){if(W(n)){if(n.collapseAtStart(e))return!0;if(Sv(n))break}if(n.getPreviousSibling())break}return!1}function kh(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 Ah(e,t,n,r){e.modify(t,n,r)}function jh(e,t,n){let r=e.getNodes(),i=r.filter(e=>gv(e,n));if(i.length===0||i.length===r.length)return!1;let a=t?i[0]:i[i.length-1],o=W(a)?a:a.getParentOrThrow();return t?o.selectStart():o.selectEnd(),!0}function Mh(e,t,n){if(sg(e,`extend`,t,n))return;let r=U(),i=kv(vv(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||!W(c)||c.isInline()||c.canBeEmpty()||Ov(a,r,o);let l=e=>{let t=e.getNode(),n=r.getElementByKey(e.key);return n!==null&&e.type===`text`&&B(t)?ry(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(Zh(i,h,g,h,g),Ah(i,`move`,t?`backward`:`forward`,n),i.rangeCount===0)return;let _=Lv(i,o)||i.getRangeAt(0),v=_.startContainer,y=_.startOffset;if(p&&n===`character`&&s.type===`text`&&B(u)&&u.isUnmergeable()&&f===(t?0:u.getTextContentSize())){let n=sb(u,t?`previous`:`next`).getNodeAtCaret();if(B(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,x,ee,te]=t?[v,y,d,f]:[d,f,v,y],ne=Vg(u)?u:bv(u);e.applyDOMRange({collapsed:!1,endContainer:ee,endOffset:te,startContainer:b,startOffset:x}),e.dirty=!0,!jh(e,t,ne)&&t&&kh(e),n===`lineboundary`&&sg(e,`extend`,t,n,`decorators`)}let Nh=(()=>{try{let e=RegExp(`\\p{Emoji}`,`u`),t=e.test.bind(e);if(t(`❤️`)&&t(`#️⃣`)&&t(`👍`))return t}catch{}return()=>!1})();function Ph(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 Fh(e,t,n,r){let i,a=t,o=!1;if(J(e)){let s=!1,c=e.childNodes,l=c.length,u=r._blockCursorElement;a===l&&l>0&&(s=!0,a=l-1),z_(e,r)!==void 0||hy(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=K_(d),B(i))a=lb(i,s?`next`:`previous`);else{let c=K_(e);if(c===null)return null;if(W(c)){let o=r.getElementByKey(c.getKey());o===null&&I(214);let l=ty(c,o,r);[c,a]=l.resolveChildIndex(c,o,e,t),W(c)||I(215),s&&a>=c.getChildrenSize()&&(a=Math.max(0,c.getChildrenSize()-1));let u=c.getChildAtIndex(a);if(W(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=W(u)?u:u.getParentOrThrow()),a=0}B(u)?(i=u,c=null,a=lb(u,s?`next`:`previous`)):u!==c&&s&&!f&&(W(c)||I(216),a=Math.min(c.getChildrenSize(),a+1))}else{let n=ky(c),i=n===null?c:n,o=i.getIndexWithinParent(),s=r.getElementByKey(c.getKey()),l=`after`;if(s!==null&&K_(e)===c){let n=ty(c,s,r);n.element===s?t===0&&G(c)&&(l=`before`):l=n.resolveLeafPosition(s,e,t)}a=l===`before`?o:o+1,c=i.getParentOrThrow()}if(W(c))return[hh(c.__key,a,`element`),o]}}else i=K_(e);return B(i)?[hh(i.__key,lb(i,a,`clamp`),`text`),o]:null}function Ih(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&&W(a)&&a.isInline()){let t=a.getPreviousSibling();B(t)&&e.set(t.__key,t.getTextContent().length,`text`)}}else W(r)&&!n&&r.isInline()?e.set(r.__key,r.getChildrenSize(),`element`):B(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&&W(r)&&r.isInline())e.set(r.__key,0,`element`);else if((n||t)&&r===null&&W(a)&&a.isInline()&&!a.canInsertTextAfter()&&a.getTextContentSize()>1){let t=a.getNextSibling();B(t)&&e.set(t.__key,0,`text`)}}}function Lh(e){let t=I_(e.key);return t===null?null:jy(t)}function Rh(e,t,n){let r=Lh(e),i=Lh(t);if(r===i||r!==null&&i!==null&&r.is(i))return!1;let a=n(r,i);if(r!==null)return W(r)?t.set(r.getKey(),a?r.getChildrenSize():0,`element`):t.set(r.getKey(),a?r.getTextContentSize():0,`text`),!0;let o=ky(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 zh(e){let t=Rh(e.anchor,e.focus,(t,n)=>function(e,t,n,r){if(n!==null&&r!==null){let e=ky(n),t=ky(r);if(e!==null&&e.is(t)){for(let t of My(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=ky(n),r=I_(t.key);return e===null||r===null||!(!e.is(r)&&!e.isParentOf(r))||e.isBefore(r)}let i=ky(r),a=I_(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 Bh(e,t,n,r,i,a){if(e===null||n===null||!x_(i,e,n))return null;let o=Fh(e,t,V(a)?a.anchor:null,i);if(o===null)return null;let s=Fh(n,r,V(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=K_(e),r=K_(n);if(G(t)&&G(r))return null}let f=i._slotsUsed&&Rh(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);Ih(e,n,r),Ih(t,!n,r),r&&t.set(e.key,e.offset,e.type)}}(c,u),[c,u,l||d||f]}function Vh(e){return W(e)&&!e.isInline()}function Hh(e,t,n,r,i,a){let o=yg(),s=new Sh(hh(e,t,i),hh(n,r,a),0,``);return s.dirty=!0,o._selection=s,s}function Uh(){return new Sh(hh(`root`,0,`element`),hh(`root`,0,`element`),0,``)}function Wh(){return new bh(/* @__PURE__ */ new Set)}function Gh(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=!Kd&&(s||o===`beforeinput`||o===`compositionstart`||o===`compositionend`||o===`click`&&a&&a.detail===3||o===`drop`||o===void 0),l,u,d,f;if(V(e)&&!c)return e.clone();{if(t===null)return null;let r=zv(t,n._rootElement);if(l=r.anchorNode,u=r.focusNode,d=r.anchorOffset,f=r.focusOffset,(s||o===void 0)&&V(e)&&!x_(n,l,u))return e.clone()}let p=Bh(l,d,u,f,n,e);if(p===null)return null;let[m,h,g]=p,_=0,v=``;if(V(e)){let t=e.anchor;if(m.key===t.key)_=e.format,v=e.style;else{let e=m.getNode();B(e)?(_=e.getFormat(),v=e.getStyle()):W(e)&&(_=e.getTextFormat(),v=e.getTextStyle())}}let y=new Sh(m,h,_,v);return g&&(y.dirty=!0),y}function H(){return yg()._selection}function Kh(){return U()._editorState._selection}function qh(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`),Jh(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`)}}Jh(e)}function Jh(e){let t=e.anchor,n=t.offset,r=e.focus,i=r.offset,a=t.getNode(),o=r.getNode();if(e.isCollapsed()){if(!W(a))return;let e=a.getChildrenSize(),i=n>=e,o=i?a.getChildAtIndex(e-1):a.getChildAtIndex(n);if(B(o)){let e=0;i&&(e=o.getTextContentSize()),t.set(o.__key,e,`text`),r.set(o.__key,e,`text`)}}else{if(W(a)){let e=a.getChildrenSize(),r=n>=e,i=r?a.getChildAtIndex(e-1):a.getChildAtIndex(n);if(B(i)){let e=0;r&&(e=i.getTextContentSize()),t.set(i.__key,e,`text`)}}if(W(o)){let e=o.getChildrenSize(),t=i>=e,n=t?o.getChildAtIndex(e-1):o.getChildAtIndex(i);if(B(n)){let e=0;t&&(e=n.getTextContentSize()),r.set(n.__key,e,`text`)}}}}function Yh(e,t,n,r,i){let a=null,o=0,s=null;r===null?i!==null&&(a=i.__key,B(i)?s=`text`:W(i)&&(s=`element`)):(a=r.__key,B(r)?(o=r.getTextContentSize(),s=`text`):W(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 Xh(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 Zh(e,t,n,r,i){try{e.setBaseAndExtent(t,n,r,i)}catch{}}function Qh(e,t,n){let r=dv(e,t.getKey());if(W(t)){let i=ty(t,r,e);return[i.element,n+i.getFirstChildOffset()]}return[r,n]}function $h(e,t,n,r,i,a){let o=a.getRootNode(),s=O_(o)||jv(o)?Wv(o):null;if(i.has(`collaboration`)&&s!==a||s!==null&&b_(s,s))return;let c=zv(r,a),l;if(!V(t))return void(e!==null&&x_(n,c.anchorNode,c.focusNode)&&r.removeAllRanges());let u=t.anchor,d=t.focus,f=u.getNode(),p=d.getNode(),[m,h]=Qh(n,f,u.offset),[g,_]=Qh(n,p,d.offset),v=t.format,y=t.style,b=t.isCollapsed(),x=m,ee=g,te=!1;if(u.type===`text`?(x=B(f)?ry(f,m,n):null,te=f.getFormat()!==v||f.getStyle()!==y):V(e)&&e.anchor.type===`text`&&(te=!0),d.type===`text`&&(ee=B(p)?ry(p,g,n):null),x!==null&&ee!==null){if(b&&(e===null||te||V(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===x&&c.focusNode===ee){if(s===null||!a.contains(s)){let e=s===null?null:C_(s);e!==null&&e!==n||i.has(`skip-selection-focus`)||a.focus({preventScroll:!0})}if(u.type!==`element`)return}if(Zh(r,x,h,ee,_),hd&&t.isCollapsed()&&a!==null&&!i.has(`skip-selection-focus`)){let e=Uv(a);if(e===null||!a.contains(e)){let e=Wv(a.ownerDocument),t=e===null?null:C_(e);t!==null&&t!==n||a.focus({preventScroll:!0})}}if(!i.has(`skip-scroll-into-view`)&&t.isCollapsed()&&a!==null&&a===Uv(a)){let e=V(t)&&t.anchor.type===`element`?x.childNodes[h]||null:(l===void 0&&(l=Rv(r,a)),l);if(e!==null){let t;if(D_(e)){let n=e.ownerDocument.createRange();n.selectNode(e),t=n.getBoundingClientRect()}else t=e.getBoundingClientRect();(function(e,t,n){let r=pv(n),i=_v(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=vv(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=fv(u)}})(n,t,a)}}(function(e){e._inputState.isSelectionChangeFromDOMUpdate=!0})(n)}}function eg(e,t){for(let n of e.split(/(\r?\n|\t)/))n===`
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===`
141
141
  `||n===`\r
142
- `?t.linebreak():n===` `?t.tab():n!==``&&t.text(n)}function tg(e){let t=[];return eg(e,{linebreak:()=>t.push(Xg()),tab:()=>t.push(fh()),text:e=>t.push(lh(e))}),t}function ng(e){let t=[];for(let n of e)Zg(n)||(!W(n)&&!G(n)||n.isInline()?t.push(n):W(n)&&t.push(...ng(n.getChildren())));return t}function rg(e){let t=e;e.isCollapsed()||t.removeText();let n=H();V(n)&&(t=n),V(t)||I(161);let r=t.anchor,i=r.getNode(),a=r.offset;for(;!Qv(i)&&Oy(i)===null;){let e=i;if([i,a]=ig(i,a),e.is(i))break}return a}function ig(e,t){let n=e.getParent();if(!n){let e=r_();return U_().append(e),e.select(),[U_(),0]}if(B(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(!W(e)||t===0)return[n,e.getIndexWithinParent()];let r=e.getChildAtIndex(t);if(r){let n=new Sh(hh(e.__key,t,`element`),hh(e.__key,t,`element`),0,``),i=e.insertNewAfter(n);i&&i.append(r,...r.getNextSiblings())}return[n,e.getIndexWithinParent()+1]}function ag(e){return Zg(e)||yv(e)||B(e)||e.isParentRequired()}function og(e){let t=r_(),n=null;for(let r=0;r<e.length;r++){let i=e[r];if(ag(i)){if(n===null){n=i.createParentElementNode(),t.append(n);let a=e[r+1];if(Zg(i)&&(a===void 0||!ag(a)))continue}n.append(i)}else t.append(i),n=null}return t}function sg(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=Tb(e.focus,n?`previous`:`next`),o=r===`lineboundary`,s=t===`move`,c=a,l=i===`decorators-and-blocks`;if(!Fb(c)){for(let e of c){l=!1;let{origin:t}=e;if(!G(t)||t.isIsolated()||(c=e,!o||!t.isInline()))break}if(l)for(let e of gb(a).iterNodeCarets(t===`extend`?`shadowRoot`:`root`)){if(rb(e))e.origin.isInline()||(c=e);else{if(W(e.origin))continue;G(e.origin)&&!e.origin.isInline()&&(c=e)}break}}if(c===a)return!1;if(s&&!o&&G(c.origin)&&c.origin.isKeyboardSelectable()){let e=Wh();return e.add(c.origin.getKey()),W_(e),!0}return c=Pb(c),s&&Eb(e.anchor,c),Eb(e.focus,c),l||!o}let cg=null,lg=null,ug=!1,dg=!1,fg=!1,pg=/* @__PURE__ */ new Set,mg=0,hg={characterData:!0,childList:!0,subtree:!0};function gg(){return ug||cg!==null&&cg._readOnly}function _g(){ug&&I(13)}function vg(){mg>99&&I(14)}function yg(){return cg===null&&I(195,Sg()),cg}function bg(e){yg()!==null&&lg===null&&(lg=e),lg!==e&&dd(378)}function U(){return lg===null&&I(337,Sg()),lg}function xg(){U()._dirtyType=2}function Sg(){let e=0,t=/* @__PURE__ */ new Set,n=f_.version;if(typeof window<`u`)for(let r of Pv(document)){let i=w_(r);if(S_(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 Cg(){return lg}function wg(e,t,n){let r=t.__type,i=__(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 Tg(e,t){return e!==void 0&&e.__key!==t&&e.isAttached()}function Eg(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 Dg(e,t){let n=e.type,r=t.get(n);r===void 0&&I(17,n);let i=r.klass;e.type!==i.getType()&&I(18,i.name);let a=i.importJSON(e),o=e.children;if(W(a)&&Array.isArray(o))for(let e=0;e<o.length;e++){let n=Dg(o[e],t);a.append(n)}let s=e.$slots;if(s){Ey(a)||I(379,i.name);for(let e in s)Wy(a,e,Dg(s[e],t))}return a}function Og(e,t,n){let r=cg,i=ug,a=lg;cg=t,ug=!0,lg=e;try{return n()}finally{cg=r,ug=i,lg=a}}function kg(e,t){let n=fg;fg=!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&&Mg(e,e._deferred));let a=e._editorState,o=a._selection,s=n._selection,c=e._dirtyType!==0,l=cg,u=ug,d=lg,f=e._updating,p=e._observer,m=null;if(e._pendingEditorState=null,e._editorState=n,!i&&c&&p!==null){lg=e,cg=n,ug=!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;o_(e,null,r,n),tf(e),e._dirtyType=2,dg=!0,kg(e,a),dg=!1;return}finally{p.observe(r,hg),e._updating=f,cg=l,ug=u,lg=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=V_(e)),delete r[a])}(e,n);let y=i?null:kv(vv(e));if(e._editable&&y!==null&&(c||s===null||s.dirty||!s.is(o))&&r!==null&&!v.has(`skip-dom-selection`)){lg=e,cg=n;try{if(p!==null&&p.disconnect(),c||s===null||s.dirty){let t=e._blockCursorElement;t!==null&&Ov(t,e,r),$h(o,s,e,y,v,r)}(function(e,t,n){let r=e._blockCursorElement;if(V(n)&&n.isCollapsed()&&n.anchor.type===`element`&&t.contains(Uv(t))){let i=n.anchor,a=i.getNode(),o=i.offset,s=!1,c=null;if(o===a.getChildrenSize())Dv(a.getChildAtIndex(o-1))&&(s=!0);else{let t=a.getChildAtIndex(o);if(t!==null&&Dv(t)){let n=t.getPreviousSibling();(n===null||Dv(n))&&(s=!0,c=e.getElementByKey(t.__key))}}if(s){let n=ty(a,e.getElementByKey(a.__key),e).element;r===null&&(e._blockCursorElement=r=function(e){let t=e.theme,n=Iv().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=Kb(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&&Ov(r,e,t)})(e,r,s)}finally{p!==null&&p.observe(r,hg),lg=d,cg=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),V(s)||s===null||o!==null&&o.is(s)||e.dispatchCommand(pp);let b=e._pendingDecorators;b!==null&&(e._decorators=b,e._pendingDecorators=null,Ag(`decorator`,e,!0,b)),function(e,t,n){let r=H_(t),i=H_(n);r!==i&&Ag(`textcontent`,e,!0,i)}(e,t||a,n),Ag(`update`,e,!0,{dirtyElements:g,dirtyLeaves:h,editorState:n,mutatedNodes:m,normalizedNodes:_,prevEditorState:t||a,tags:v}),!f&&Mg(e,e._deferred),(function(e){let t=e._updates;if(t.length===0)return void(e._cascadeCount=0);if(function(e){pg.has(e)||(pg.add(e),setTimeout(()=>{pg.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;Pg(e,t,r)}})(e)})(e,t)}finally{fg=n}}function Ag(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 jg(e,t,n,r){let i=J_(e),a;if(!fg)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(Fg(s,()=>{for(let i of t)if(i(n,r))return void(e=!0)}),e)return e}}}return a&&a.update(()=>{jg(a,t,n,r)}),!1}function Mg(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 Ng(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&&I(191),a._flushSync=!0),o&&e._deferred.push(o),Eg(e,i.tag)),a==null?Pg(e,n,i):n()}}return r}function Pg(e,t,n){let r=e._updateTags,i,a=!1,o=!1;n!==void 0&&(i=n.onUpdate,Eg(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=Hg(c||s),l=!0),c._flushSync=o;let u=cg,d=ug,f=lg,p=e._updating;cg=c,ug=!1,e._updating=!0,lg=e;let m=e._headless||e.getRootElement()===null;m_(null);try{l&&(m?s._selection!==null&&(c._selection=s._selection.clone()):c._selection=function(e,t){let n=e.getEditorState()._selection,r=kv(vv(e));return V(n)||n==null?Gh(n,r,e,t):n.clone()}(e,n&&n.event||null));let r=e._compositionKey;t(),a=Ng(e,a),function(e,t){let n=t.getEditorState()._selection,r=e._selection;if(V(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);B(t)&&t.isAttached()&&t.isSimpleText()&&!t.isUnmergeable()&&_f(t)}}(c,e):function(e,t){let n=t._dirtyLeaves,r=t._dirtyElements,i=e._nodeMap,a=F_(),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);B(r)&&r.isAttached()&&r.isSimpleText()&&!r.isUnmergeable()&&_f(r),r!==void 0&&Tg(r,a)&&wg(t,r,o),n.add(e)}if(s=t._dirtyLeaves,c=s.size,c>0){mg++;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&&Tg(c,a)&&wg(t,c,o)}s=t._dirtyLeaves,c=s.size,l=t._dirtyElements,u=l.size,mg++}t._dirtyLeaves=n,t._dirtyElements=r}(c,e),Ng(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()||(W(t)&&Gd(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()||(Ey(t)&&t.__slots!==null&&Gd(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=U(),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(V(i)){e._slotsUsed&&zh(i);let t=c._nodeMap,n=i.anchor.key,r=i.focus.key;t.get(n)!==void 0&&t.get(r)!==void 0||I(19)}else Ch(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(),kg(e);return}finally{cg=u,ug=d,lg=f,e._updating=p,mg=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,kg(e)):l&&y_(()=>{kg(e)}):(c._flushSync=!1,l&&(r.clear(),e._deferred=[],e._pendingEditorState=null))}function Fg(e,t,n){lg===e&&n===void 0?gg()?Pg(e,t,n):t():Pg(e,t,n)}function Ig(e){if(Sv(e)){let t=null;for(let n of e.getChildren())t=n.isInline()?(t||n.replace(n.createParentElementNode())).append(n):null}}var Lg=class extends Lm{__first;__last;__size;__format;__style;__indent;__dir;__textFormat;__textStyle;__slotHost;__slots;$config(){return this.config(Symbol.for(`ElementNode`),{$transform:Ig,extends:Lm})}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&&I(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 Ad[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&&Ny(this).length===0}isDirty(){let e=U()._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 Ny(this)){let n=Py(this,t);W(n)&&e.push(...n.getAllTextNodes())}let t=this.getFirstChild();for(;t!==null;){if(B(t)&&e.push(t),W(t)){let n=t.getAllTextNodes();e.push(...n)}t=t.getNextSibling()}return e}getFirstDescendant(){let e=this.getFirstChild();for(;W(e);){let t=e.getFirstChild();if(t===null)break;e=t}return e}getLastDescendant(){let e=this.getLastChild();for(;W(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 W(e)&&e.getLastDescendant()||e||null}let r=t[e];return W(r)&&r.getFirstDescendant()||r||null}getFirstChild(){let e=this.getLatest().__first;return e===null?null:I_(e)}getFirstChildOrThrow(){let e=this.getFirstChild();return e===null&&I(45,this.__key),e}getLastChild(){let e=this.getLatest().__last;return e===null?null:I_(e)}getLastChildOrThrow(){let e=this.getLastChild();return e===null&&I(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=Vy(this),t=this.getChildren(),n=t.length;for(let r=0;r<n;r++){let i=t[r];e+=i.getTextContent(),W(i)&&r!==n-1&&!i.isInline()&&(e+=`
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+=`
143
143
 
144
- `)}return e}getTextContentSize(){let e=function(e){let t=0;for(let n of Ny(e)){let r=Py(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(),W(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=kd[e];return(this.getFormat()&t)!==0}return!1}hasTextFormat(e){let t=Dd[e];return(this.getTextFormat()&t)!==0}getFormatFlags(e,t){return A_(this.getLatest().__textFormat,e,t)}getTextStyle(){return this.getLatest().__textStyle}select(e,t){_g();let n=H(),r=e,i=t,a=this.getChildrenSize();if(!this.canBeEmpty()){if(e===0&&t===0){let e=this.getFirstChild();if(B(e)||W(e))return e.select(0,0)}else if(!(e!==void 0&&e!==a||t!==void 0&&t!==a)){let e=this.getLastChild();if(B(e)||W(e))return e.select()}}r===void 0&&(r=a),i===void 0&&(i=a);let o=this.__key;return V(n)?(n.anchor.set(o,r,`element`),n.focus.set(o,i,`element`),n.dirty=!0,n):Hh(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!==``&&kd[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){Fm(this)&&I(324,this.__key,this.__type);let r=this.getChildrenSize(),i=this.getWritable();e+t<=r||I(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&&I(100);let t=e.getNextSibling(),n=e.__key;M_(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--,M_(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&&I(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=H();if(V(e)){let t=new Set(s),n=new Set(o),{anchor:r,focus:i}=e;Rg(r,t,n)&&Yh(r,r.getNode(),this,l,c),Rg(i,t,n)&&Yh(i,i.getNode(),this,l,c),u!==0||this.canBeEmpty()||Sv(this)||this.remove()}}return i}getDOMSlot(e){return new Rd(e)}exportDOM(e){let{element:t}=super.exportDOM(e);if(J(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===``||Sv(this)||this.getChildren().some(B)||(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=ty(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 W(e){return e instanceof Lg}function Rg(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 zg=class extends Lm{__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&&I(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 G(e){return e instanceof zg}var Bg=class extends Lg{__cachedText;$config(){return this.config(`root`,{extends:Lg})}constructor(){super(`root`),this.__cachedText=null}getTopLevelElementOrThrow(){I(51)}getTextContent(){let e=this.__cachedText;return e===null||!gg()&&U()._dirtyType!==0?super.getTextContent():e}remove(){I(52)}replace(e){I(53)}insertBefore(e){I(54)}insertAfter(e){I(55)}updateDOM(e,t){return!1}splice(e,t,n){for(let e of n)W(e)||G(e)||I(282);return super.splice(e,t,n)}static importJSON(e){return U_().updateFromJSON(e)}collapseAtStart(){return!0}};function Vg(e){return e instanceof Bg}function Hg(e){return new Kg(Ud(e._nodeMap),null,e._slotsUsed)}function Ug(){return new Kg(/* @__PURE__ */ new Map([[`root`,new Bg]]),null,!1)}function Wg(e){let t=e.exportJSON(),n=e.constructor;if(t.type!==n.getType()&&I(130,n.name),W(e)){let r=t.children;Array.isArray(r)||I(59,n.name);let i=e.getChildren();for(let e=0;e<i.length;e++){let t=Wg(i[e]);r.push(t)}}let r=Ny(e);if(r.length>0){let i={};for(let t of r){let r=Py(e,t);r===null&&I(366,n.name,t),i[t]=Wg(r)}t.$slots=i}return t}function Gg(e){return e instanceof Kg}var Kg=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 Og(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 Og(null,this,()=>({root:Wg(U_())}))}},qg=class extends Lg{$config(){return this.config(`artificial`,{extends:Lg})}createDOM(e){return Iv().createElement(`div`)}},Jg=class extends Lm{$config(){return this.config(`linebreak`,{importDOM:{br:e=>Qg(e)||$g(e)?null:{conversion:Yg,priority:0}}})}getTextContent(){return`
145
- `}createDOM(){return Iv().createElement(`br`)}updateDOM(){return!1}isInline(){return!0}};function Yg(e){return{node:Xg()}}function Xg(){return wv(new Jg)}function Zg(e){return e instanceof Jg}function Qg(e){let t=e.parentElement;if(t!==null&&Zv(t)){let n=t.firstChild;if(n===e||n.nextSibling===e&&e_(n)){let n=t.lastChild;if(n===e||n.previousSibling===e&&e_(n))return!0}}return!1}function $g(e){let t=e.parentElement;if(t!==null&&Zv(t)){let n=t.firstChild;if(n===e||n.nextSibling===e&&e_(n))return!1;let r=t.lastChild;if(r===e||r.previousSibling===e&&e_(r))return!0}return!1}function e_(e){return D_(e)&&/^( |\t|\r?\n)+$/.test(e.textContent||``)}var t_=class extends Lg{$config(){return this.config(`paragraph`,{extends:Lg,importDOM:{p:()=>({conversion:n_,priority:0})}})}createDOM(e){let t=Iv().createElement(`p`),n=ov(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(J(t)){this.isEmpty()&&t.append(Iv().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(B);t?(e.textFormat=t.getFormat(),e.textStyle=t.getStyle()):(e.textFormat=this.getTextFormat(),e.textStyle=this.getTextStyle())}return e}insertNewAfter(e,t){let n=r_();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||B(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 n_(e){let t=r_();if(dy(t,e),ly(e,t),t.getFormatType()===``){let n=e.getAttribute(`align`);n&&n&&n in kd&&t.setFormat(n)}return uy(t,e),{node:t}}function r_(){return wv(new t_)}function i_(e){return e instanceof t_}function a_(e){console.warn(e)}function o_(e,t,n,r,i){let a=e._keyToDOMMap;a.clear(),e._editorState=Ug(),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),R_(n,e,`root`))}function s_(e){let t=/* @__PURE__ */ new Set,n=/* @__PURE__ */ new Set;for(let{klass:r,ownNodeConfig:i}of by(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 c_={$createDOM:(e,t)=>e.createDOM(t._config,t),$decorateDOM:(e,t,n,r)=>{},$exportDOM:(e,t)=>{let n=v_(t,e.getType());return n&&n.exportDOM!==void 0?n.exportDOM(t,e):e.exportDOM(t)},$extractWithChild:(e,t,n,r,i)=>W(e)&&e.extractWithChild(t,n,r),$getDOMSlot:(e,t,n)=>e.getDOMSlot(t),$getSlotTargetElement:(e,t,n,r)=>null,$shouldExclude:(e,t,n)=>W(e)&&e.excludeFromCopy(`html`),$shouldInclude:(e,t,n)=>!t||e.isSelected(t),$updateDOM:(e,t,n,r)=>e.updateDOM(t,n,r._config)};function l_(e){let t=e||{},n=Cg(),r=t.theme||{},i=e===void 0?n:t.parentEditor||null,a=t.disableEvents||!1,o=Ug(),s=t.namespace||(i===null?Y_():i._config.namespace),c=t.editorState,l=[Bg,eh,Jg,dh,t_,qg,...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===Lm||n.prototype instanceof Lm)){let r=`<unknown>`;try{r=JSON.parse(Vd)}catch{}I(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))}yy(n);let a=n.getType(),o=s_(n);m.set(a,{exportDOM:f&&f.export?f.export.get(n):void 0,klass:n,replace:r,replaceWithKlass:i,sharedNodeState:af(l[e]),transforms:o})}}let h=new f_(o,i,m,{disableEvents:a,dom:{...c_,...e&&e.dom},namespace:s,theme:r},u||console.error,d||a_,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(hp,bm,0),e.registerCommand(gp,xm,0),e.registerCommand(_p,Sm,0),e.registerCommand(vp,Cm,0),e.registerCommand(Ap,Em,0)}(h),h}function u_(e,t){let n=e.get(t);e.delete(t),n&&n()}function d_(e,t,n){return e.set(t,n),u_.bind(null,e,t)}var f_=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 Wd,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=Y_(),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 Jb(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&&I(35);let r=this._commands;r.has(e)||r.set(e,[new Hd,new Hd,new Hd,new Hd,new Hd]);let i=r.get(e);i===void 0&&I(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&&I(37,e.name),t}resolveRegisteredNodeAfterReplacements(e){for(;e.replaceWithKlass;)e=this.getRegisteredNode(e.replaceWithKlass);return e}initializeMutationListener(e,t){let n=this._editorState,r=oy(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=oy(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=I_(t);e&&e.markDirty()}},e._pendingEditorState===null?{tag:zm}: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 q(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=ov(this._config.theme,`root`),r=this._pendingEditorState||this._editorState;if(this._rootElement=e,o_(this,t,e,r,{preserveUpdateQueue:!0}),t!==null&&(this._config.disableEvents||Mm(t),n!=null&&t.classList.remove(...n)),e!==null){let t=_v(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,tf(this),this._updateTags.add(zm),kg(this),this._config.disableEvents||function(e,t){let n=e.ownerDocument;sm.set(e,n);let r=cm.get(n);r===void 0&&(r={editors:/* @__PURE__ */ new Set,hasShadowEditor:void 0},cm.set(n,r)),r.editors.add(t),r.hasShadowEditor=void 0,e.__lexicalEditor=t;let i=Dm(e);i.push(lm.register(n));for(let n=0;n<om.length;n++){let[r,a]=om[n],o=typeof a==`function`?e=>{jm(e)||(Am(e),(t.isEditable()||r===`click`)&&a(e,t))}:e=>{if(jm(e))return;Am(e);let n=t.isEditable();switch(r){case`cut`:return n&&q(t,Jp,e);case`copy`:return q(t,qp,e);case`paste`:return n&&q(t,Cp,e);case`dragstart`:return n&&q(t,Wp,e);case`dragover`:return n&&q(t,Gp,e);case`dragend`:return n&&q(t,Kp,e);case`focus`:return n&&q(t,em,e);case`blur`:return n&&q(t,tm,e);case`drop`:return n&&q(t,Up,e)}};i.push(im(e,r,o))}}(e,this),n!=null&&e.classList.add(...n)}else this._window=null,this._updateTags.add(zm),kg(this);Ag(`root`,this,!1,e,t)}}getElementByKey(e){return this._keyToDOMMap.get(e)||null}getEditorState(){return this._editorState}setEditorState(e,t){e.isEmpty()&&I(38);let n=e;n._readOnly&&(n=Hg(e),n._selection=e._selection?e._selection.clone():null),ef(this);let r=this._pendingEditorState,i=t===void 0?null:t.tag;r===null||r.isEmpty()||(i!=null&&this._updateTags.add(i),kg(this)),this._pendingEditorState=n,this._dirtyType=2,this._dirtyElements.set(`root`,!1),this._compositionKey=null,this._slotsUsed=this._slotsUsed||e._slotsUsed,Fg(this,()=>{if(i&&this._updateTags.add(i),e._parsed)for(let[e,t]of n._nodeMap.entries())W(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=Ug(),i=cg,a=ug,o=lg,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,cg=r,ug=!1,lg=t,m_(null);try{let i=t._nodes;Dg(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,cg=i,ug=a,lg=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`&&kg(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]):Pg(e,t,n)})(this,e,t)}focus(e,t={}){let n=this._rootElement;n!==null&&(n.setAttribute(`autocapitalize`,`off`),Fg(this,()=>{let r=H(),i=U_();r===null?i.getChildrenSize()!==0&&(t.defaultSelection===`rootStart`?i.selectStart():i.selectEnd()):r.dirty||W_(r.clone()),mv(`focus`),hv(()=>{n.removeAttribute(`autocapitalize`),e&&e()})}),this._pendingEditorState===null&&n.removeAttribute(`autocapitalize`))}blur(){let e=this._rootElement;e!==null&&e.blur();let t=kv(this._window);t!==null&&t.removeAllRanges()}isEditable(){return this._editable}setEditable(e){this._editable!==e&&(this._editable=e,Ag(`editable`,this,!0,e),this._slotsUsed&&this.update(()=>xg()))}toJSON(){return{editorState:this._editorState.toJSON()}}};f_.version=Vd;let p_=null;function m_(e){p_=e}let h_=Symbol(`INTERNAL_SKIP_AFTER_CLONE_FROM`),g_=1;function __(e,t){let n=v_(e,t);return n===void 0&&I(30,t),n}function v_(e,t){return e._nodes.get(t)}let y_=typeof queueMicrotask==`function`?queueMicrotask:e=>{Promise.resolve().then(e)};function b_(e,t){let n=t===void 0?(()=>{let t=e.getRootNode();return O_(t)||jv(t)?Wv(t):null})():t;if(!J(n)||n.hasAttribute(`data-lexical-slot`))return!1;let r=B_(n),i=n.nodeName;return Rm(r)&&(i===`INPUT`||i===`TEXTAREA`||n.contentEditable===`true`&&w_(n)==null)}function x_(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 C_(t)===e&&e.read(`latest`,()=>!b_(t))}function S_(e){return e instanceof f_}function C_(e){let t=e;for(;t!=null;){let e=w_(t);if(S_(e))return e;t=fv(t)}return null}function w_(e){return e?e.__lexicalEditor:null}function T_(e){return ph(e)||e.isToken()}function E_(e){return T_(e)||e.isSegmented()}function D_(e){return Kv(e)&&e.nodeType===3}function O_(e){return Kv(e)&&e.nodeType===9}function k_(e){let t=e;for(;t!=null;){if(D_(t))return t;t=t.firstChild}return null}function A_(e,t,n){let r=Dd[t];if(n!==null&&(e&r)===(n&r))return e;let i=e^r;return t===`subscript`?i&=~Dd.superscript:t===`superscript`?i&=~Dd.subscript:t===`lowercase`?(i&=~Dd.uppercase,i&=~Dd.capitalize):t===`uppercase`?(i&=~Dd.lowercase,i&=~Dd.capitalize):t===`capitalize`&&(i&=~Dd.lowercase,i&=~Dd.uppercase),i}function j_(e,t){let n=function(){let e=p_;return p_=null,e}();if((t||=n&&n.__key)!=null)return void(e.__key=t);_g(),vg();let r=U(),i=yg(),a=``+g_++;i._nodeMap.set(a,e),W(e)?r._dirtyElements.set(a,!0):r._dirtyLeaves.add(a),r._cloneNotNeeded.add(a),r._dirtyType===0&&(r._dirtyType=1),e.__key=a}function M_(e){Oy(e)!==null&&I(380,e.__key,String(Oy(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 N_(e){vg(),Fm(e)&&I(323,e.__key,e.__type);let t=e.getLatest(),n=t.__parent===null?Dy(t)?t.__slotHost:null:t.__parent,r=yg(),i=U(),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?Dy(e)?e.__slotHost:null:e.__parent}}(n,a,o);let s=t.__key;i._dirtyType===0&&(i._dirtyType=1),W(e)?o.set(s,!0):i._dirtyLeaves.add(s)}function P_(e){_g();let t=U(),n=t._compositionKey;if(e!==n){if(t._compositionKey=e,n!==null){let e=I_(n);e!==null&&e.getWritable()}if(e!==null){let t=I_(e);t!==null&&t.getWritable()}}}function F_(){return gg()?null:U()._compositionKey}function I_(e,t){let n=(t||yg())._nodeMap.get(e);return n===void 0?null:n}function L_(e,t){let n=z_(e,U());return n===void 0?null:I_(n,t)}function R_(e,t,n){e[`__lexicalKey_${t._key}`]=n}function z_(e,t){return e[`__lexicalKey_${t._key}`]}function B_(e,t){let n=e;for(;n!=null;){let e=L_(n,t);if(e!==null)return e;n=fv(n)}return null}function V_(e){let t=e._decorators,n=Object.assign({},t);return e._pendingDecorators=n,n}function H_(e){return e.read(()=>U_().getTextContent())}function U_(){return yg()._nodeMap.get(`root`)}function W_(e){_g();let t=yg();e!==null&&(e.dirty=!0,e.setCachedNodes(null),V(e)&&U()._slotsUsed&&zh(e)),t._selection=e}function G_(){_g(),ef(U())}function K_(e){let t=function(e,t){let n=e;for(;n!=null;){let e=z_(n,t);if(e!==void 0)return e;n=fv(n)}return null}(e,U());return t===null?null:I_(t)}function q_(e){return/[\uD800-\uDBFF][\uDC00-\uDFFF]/g.test(e)}function J_(e){let t=[];for(let n=e;n!==null;n=n._parentEditor)t.push(n);return t}function Y_(){return Math.random().toString(36).replace(/[^a-z]+/g,``).substring(0,5)}function X_(e){return D_(e)?e.nodeValue:null}function Z_(e,t,n){let r=kv(vv(t));if(r===null)return;let i=zv(r,t._rootElement),a=i.anchorNode,{anchorOffset:o,focusOffset:s}=i;if(a!==null){let t=X_(a),r=B_(a);if(t!==null&&B(r)){if((t===Cd||t===wd)&&n){let e=n.length;t=n,o=e,s=e}t!==null&&Q_(r,t,o,s,e)}}}function Q_(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(Cd)&&(s=t.slice(0,-Cd.length)),i)){let e=wd,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=H();if(s===``){if(P_(null),yd||_d||Sd)a.remove();else{let e=U();$_(a,``,t),setTimeout(()=>{e.update(()=>{a.isAttached()&&a.getTextContent()===``&&a.remove()})},20)}return}let i=a.getParent(),c=Kh(),l=a.getTextContentSize(),u=F_(),d=a.getKey();if(a.isToken()&&!o||u!==null&&d===u&&!o||V(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(!V(t)||n===null||r===null)return void $_(a,s,t);if(t.setTextNodeRange(a,n,a,r),a.isSegmented()){let e=lh(a.getTextContent());a.replace(e),a=e}$_(a,s,t)}}}function $_(e,t,n){if(e.setTextContent(t),V(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=lb(e,a.offset,`clamp`),r=!0)}r&&(n._cachedNodes=null,n._cachedIsBackward=null)}}function ev(e,t,n){let r=t[n]||!1;return r===`any`||r===e[n]}function tv(e,t){return ev(e,t,`altKey`)&&ev(e,t,`ctrlKey`)&&ev(e,t,`shiftKey`)&&ev(e,t,`metaKey`)}function K(e,t,n){if(!tv(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 nv={ctrlKey:!md,metaKey:md},rv={altKey:md,ctrlKey:!md};function iv(e){return e.key===`Backspace`}function av(e){let t=U_();if(V(e)){let t=e.anchor,n=e.focus,r=t.getNode();if(Vg(r))return t.set(r.getKey(),0,`element`),n.set(r.getKey(),r.getChildrenSize(),`element`),vf(e),e;let i=r.getTopLevelElementOrThrow(),a=i.getParent();if(a===null)return W(i)&&(t.set(i.getKey(),0,`element`),n.set(i.getKey(),i.getChildrenSize(),`element`),vf(e)),e;let o=a;return t.set(o.getKey(),0,`element`),n.set(o.getKey(),o.getChildrenSize(),`element`),vf(e),e}{let e=t.select(0,t.getChildrenSize());return W_(vf(e)),e}}function ov(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=Kb(i);return n[t]=e,e}return i}function sv(e,t,n,r,i){if(n.size===0)return;let a=r.__type,o=r.__key,s=t.get(a);s===void 0&&I(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 cv(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 lv(e,t){let n=e.offset;if(e.type===`element`)return cv(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?cv(r.getParentOrThrow(),t,r.getIndexWithinParent()+ +!t):e}}return null}function uv(e){let t=vv(e).event,n=t&&t.inputType;return n===`insertFromPaste`||n===`insertFromPasteAsQuotation`}function q(e,t,...n){return jg(e,t,n[0],e)}function dv(e,t){let n=e._keyToDOMMap.get(t);return n===void 0&&I(75,t),n}function fv(e){let t=e.assignedSlot||e.parentElement;if(t!==null)return t;let n=e.parentNode;return jv(n)?n.host:null}function pv(e){return O_(e)?e:J(e)?e.ownerDocument:null}function mv(e){_g(),U()._updateTags.add(e)}function hv(e){_g(),U()._deferred.push(e)}function gv(e,t){let n=e.getParent();for(;n!==null;){if(n.is(t))return!0;n=n.getParent()}return!1}function _v(e){let t=pv(e);return t?t.defaultView:null}function vv(e){let t=e._window;return t===null&&I(78),t}function yv(e){return W(e)&&e.isInline()||G(e)&&e.isInline()}function bv(e){let t=e.getLatest();for(;t!==null;){if(Oy(t)!==null&&W(t))return t;let e=t.getParentOrThrow();if(Sv(e))return e;t=e}return t}function xv(e){return W(e)&&e.isShadowRoot()}function Sv(e){return Vg(e)||xv(e)}function Cv(e,t=!1){let n=e.constructor.clone(e,h_);return j_(n,null),n.afterCloneFrom(e),t||n.resetOnCopyNodeFrom(e),n}function wv(e){let t=U(),n=e.getType(),r=v_(t,n);r===void 0&&I(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||I(202,r.name,r.getType(),e.constructor.name,n):t instanceof a||I(201,a.name,a.getType(),r.name,r.getType(),e.constructor.name,n),t.__key===e.__key&&I(203,e.constructor.name,n,r.name,r.getType()),t}return e}function Tv(e,t){!Vg(e.getParent())||W(t)||G(t)||I(99)}function Ev(e){let t=I_(e);return t===null&&I(63,e),t}function Dv(e){if(!e||e.isInline())return!1;if(G(e))return!0;if(W(e)){if(e.isShadowRoot()){let t=e.getParent();return!(W(t)&&t.isShadowRoot())}return!e.canBeEmpty()}return!1}function Ov(e,t,n){n.style.removeProperty(`caret-color`),t._blockCursorElement=null;let r=e.parentElement;r!==null&&r.removeChild(e)}function kv(e){return fd?(e||window).getSelection():null}function Av(e){let t=_v(e);return t?t.getSelection():null}function jv(e){return qv(e)&&`host`in e}let Mv=[];function Nv(e){let t=e.getRootNode();if(t===e||!jv(t))return Mv;let n=[t],r=t.host;for(;;){let e=r.getRootNode();if(e===r||!jv(e))break;n.push(e),r=e.host}return n}function*Pv(e){let t=[e],n;for(;n=t.pop();){yield*n.querySelectorAll(`[data-lexical-editor="true"]`);let e=(O_(n)?n:n.ownerDocument).createTreeWalker(n,NodeFilter.SHOW_ELEMENT),r;for(;r=e.nextNode();)r.shadowRoot&&t.push(r.shadowRoot)}}function Fv(e){return e===null?document:e.ownerDocument}function Iv(){let e=Cg();return Fv(e===null?null:e._rootElement)}function Lv(e,t){if(t===null||typeof e.getComposedRanges!=`function`)return null;let n=Nv(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 Rv(e,t){let n=Lv(e,t);if(n!==null){let e=Bv(n);if(e!==null)return e}return e.rangeCount>0?e.getRangeAt(0):null}function zv(e,t){let n=Lv(e,t);return n===null?e:Vv(n,Hv(e))}function Bv(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 Vv(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 Hv(e){return e.direction}function Uv(e){let t=e.getRootNode();return O_(t)||jv(t)?t.activeElement:null}function Wv(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 Gv(e){let t=e.target;if(t!==null&&J(t)&&t.shadowRoot!==null&&typeof e.composedPath==`function`){let t=e.composedPath();if(t.length>0)return t[0]}return t}function J(e){return Kv(e)&&e.nodeType===1}function Kv(e){return typeof e==`object`&&!!e&&`nodeType`in e&&typeof e.nodeType==`number`}function qv(e){return Kv(e)&&e.nodeType===11}let Jv=/^(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 Yv(e){return!(!J(e)||!e.style.display.startsWith(`inline`))||Jv.test(e.nodeName)}let Xv=/^(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 Zv(e){return(!J(e)||!e.style.display.startsWith(`inline`))&&Xv.test(e.nodeName)}function Qv(e){if(G(e)&&!e.isInline())return!0;if(!W(e)||Sv(e))return!1;let t=e.getFirstChild(),n=t===null||Zg(t)||B(t)||t.isInline();return!e.isInline()&&!1!==e.canBeEmpty()&&n}function $v(){return U()}function ey(e=$v()){return e._config.dom||c_}function ty(e,t,n=$v()){let r=ey(n).$getDOMSlot(e,t,n);return W(e)&&(ny(r)||I(344,e.getKey(),e.getType())),r}function ny(e){return e instanceof Rd}function ry(e,t,n=$v()){return k_(ty(e,t,n).element)}let iy=/* @__PURE__ */ new WeakMap,ay=/* @__PURE__ */ new Map;function oy(e){if(!e._readOnly&&e.isEmpty())return ay;e._readOnly||I(192);let t=iy.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),iy.set(e,t)),t}function sy(e){let t=e.constructor.clone(e,h_);return t.afterCloneFrom(e),t}function cy(e){return(t=sy(e))[Pm]=!0,t;var t}function ly(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 uy(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 kd?e.setFormat(n):e}function fy(e,t){e.__lexicalUnmanaged=!0,t&&t.captureSelection!==void 0&&(e.__lexicalCapturedSelection=t.captureSelection)}function py(e){return!0===e.__lexicalUnmanaged}function my(e,t=$v()){let n=t.isEditable();e.contentEditable=n?`true`:`false`,n?e.__lexicalEditor=t:delete e.__lexicalEditor}function hy(e,t){let n=e;for(;n!=null;){if(!0===n.__lexicalCapturedSelection)return!0;if(J(n)&&n.hasAttribute(`data-lexical-slot`)||z_(n,t)!==void 0)return!1;n=fv(n)}return!1}function gy(e,t){return function(e,t){return Object.prototype.hasOwnProperty.call(e,t)}(e,t)&&e[t]!==Lm[t]}let _y=/* @__PURE__ */ new WeakMap,vy=Symbol(`lexical.synthesizedGetType`);function yy(e){let t=_y.get(e);if(t)return t;let n=e.prototype!=null&&Nd in e.prototype?e.prototype[Nd]():void 0,r=function(e){if(!(e===Lm||e.prototype instanceof Lm)){let t=`<unknown>`,n=`<unknown>`;try{t=e.getType()}catch{}try{f_.version&&(n=JSON.parse(f_.version))}catch{}I(290,e.name,t,n)}return e===zg||e===Lg||e===Lm}(e),i=!r&&gy(e,`getType`)?e.getType:void 0,a=i&&!(vy 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(!gy(e,`getType`)){let t=e,n=function(){return this===t?s:Lm.getType.call(this)};n[vy]=!0,e.getType=n}if(gy(e,`clone`)||(e.clone=(t,n)=>{m_(t);let r=new e;return n!==h_&&r.afterCloneFrom(t),r}),gy(e,`importJSON`)||(e.importJSON=o&&o.$importJSON||(t=>new e().updateFromJSON(t))),!gy(e,`importDOM`)&&o){let{importDOM:t}=o;t&&(e.importDOM=()=>t)}}let c={klass:e,ownNodeConfig:o,ownNodeType:s};return _y.set(e,c),c}function*by(e){for(let t=e;t&&(t===Lm||Rm(t.prototype));){let e=yy(t);yield e,t=e.ownNodeConfig&&e.ownNodeConfig.extends||wy(t)}}function xy(e){let t=$v();return _g(),new(t.resolveRegisteredNodeAfterReplacements(t.getRegisteredNode(e))).klass}let Sy=(e,t)=>{let n=e;for(;n!=null&&!Vg(n);){if(t(n))return n;n=n.getParent()}return null};function Cy(e,t){let n=[],r=e.__first;for(;r!==null;){let e=t===null?I_(r):t.get(r);e??I(174),n.push(r),r=e.__next}return n}function wy(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 Ty=/* @__PURE__ */ new Map;function Ey(e){return W(e)||G(e)}function Dy(e){return W(e)||G(e)}function Oy(e){let t=e.getLatest();return Dy(t)?t.__slotHost:null}function ky(e){let t=Oy(e);if(t===null)return null;let n=I_(t);return W(n)||G(n)||I(370),n}function Ay(e){let t=ky(e);if(t===null)return null;let n=e.getLatest().__key;for(let[e,r]of My(t))if(r===n)return e;return null}function jy(e){let t=e.getLatest();for(;t!==null;){if(Oy(t)!==null)return t;t=t.getParent()}return null}function My(e){let t=e.getLatest();return Ey(t)&&t.__slots!==null?t.__slots:Ty}function Ny(e){return Array.from(My(e).keys())}function Py(e,t){let n=My(e).get(t);return n===void 0?null:I_(n)}let Fy=[`__proto__`,`constructor`,`prototype`],Iy=Symbol(`slotMapOwner`);function Ly(e){let t=e.__slots;return t!==null&&t[Iy]===e||(t=new Map(t),t[Iy]=e,e.__slots=t),t}let Ry=/* @__PURE__ */ new WeakMap,zy=[];function By(e){for(let{ownNodeConfig:t}of by(e)){let e=t&&t.slots;if(e)return e}return zy}function Vy(e){let t=``;for(let n of Ny(e)){let r=Py(e,n);r!==null&&(t+=r.getTextContent())}return t}function Hy(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 Uy(e){let t=e.__slots;if(t===null||t.size<2)return;let n=function(e){let t=Ry.get(e);if(t===void 0){let n=By(e),r=/* @__PURE__ */ new Map;for(let t of n)Fy.includes(t)&&I(371,e.name,t),r.has(t)&&I(372,e.name,t),r.set(t,r.size);t=r,Ry.set(e,t)}return t}(e.constructor),r=null,i=!0;for(let e of t.keys()){if(r!==null&&Hy(r,e,n)>0){i=!1;break}r=e}if(i)return;let a=Array.from(t).sort(([e],[t])=>Hy(e,t,n));t.clear();for(let[e,n]of a)t.set(e,n)}function Wy(e,t,n){t!==`__proto__`&&t!==`constructor`&&t!==`prototype`||I(373,t);let r=e.getLatest();if(r.__slots!==null&&r.__slots.get(t)===n.getLatest().__key)return r;(!W(n)&&!G(n)||n.isInline())&&I(374,n.__key);let i=e.getWritable(),a=Ly(i),o=a.get(t);o!==void 0&&Ky(o);let s=n.getWritable(),c=ky(s);if(c!==null){let e=Ay(s);e!==null&&Ly(c.getWritable()).delete(e),s.__slotHost=null}return M_(s),s.__slotHost=i.__key,a.set(t,s.__key),Uy(i),function(){let e=$v();e._slotsUsed=!0,e._pendingEditorState&&(e._pendingEditorState._slotsUsed=!0)}(),i}function Gy(e,t){let n=e.getWritable();if(n.__slots===null)return n;let r=n.__slots.get(t);return r!==void 0&&(Ky(r),Ly(n).delete(t)),n}function Ky(e){let t=I_(e);if(t===null)return;let n=t.getWritable();Dy(n)||I(377,e),n.__slotHost=null,n.remove()}let qy={next:`previous`,previous:`next`};var Jy=class{origin;constructor(e){this.origin=e}[Symbol.iterator](){return yb({hasNext:nb,initial:this.getAdjacentCaret(),map:e=>e,step:e=>e.getAdjacentCaret()})}getAdjacentCaret(){return sb(this.getNodeAtCaret(),this.direction)}getSiblingCaret(){return sb(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&&I(263,Array.from(o).join(` `))}else i.insert(e);i=sb(e,this.direction)}for(let e of o.values())e.remove();return this}},Yy=class e extends Jy{type=`child`;getLatest(){let e=this.origin.getLatest();return e===this.origin?this:db(e,this.direction)}getParentCaret(e=`root`){return sb(Qy(this.getParentAtCaret(),e),this.direction)}getFlipped(){let e=Zy(this.direction);return sb(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 Xy={root:Vg,shadowRoot:Sv};function Zy(e){return qy[e]}function Qy(e,t=`root`){return e===null||Xy[t](e)?null:Oy(e)===null?e:null}var $y=class e extends Jy{type=`sibling`;getLatest(){let e=this.origin.getLatest();return e===this.origin?this:sb(e,this.direction)}getSiblingCaret(){return this}getParentAtCaret(){return this.origin.getParent()}getChildCaret(){return W(this.origin)?db(this.origin,this.direction):null}getParentCaret(e=`root`){return sb(Qy(this.getParentAtCaret(),e),this.direction)}getFlipped(){let e=Zy(this.direction);return sb(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 eb)&&this.direction===t.direction&&this.origin.is(t.origin)}},eb=class e extends Jy{type=`text`;offset;constructor(e,t){super(e),this.offset=t}getLatest(){let e=this.origin.getLatest();return e===this.origin?this:cb(e,this.direction,this.offset)}getParentAtCaret(){return this.origin.getParent()}getChildCaret(){return null}getParentCaret(e=`root`){return sb(Qy(this.getParentAtCaret(),e),this.direction)}getFlipped(){return cb(this.origin,Zy(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 $y||t instanceof e)&&this.direction===t.direction&&this.origin.is(t.origin)}getSiblingCaret(){return sb(this.origin,this.direction)}};function tb(e){return e instanceof eb}function nb(e){return e instanceof $y}function rb(e){return e instanceof Yy}let ib={next:class extends eb{direction=`next`;getNodeAtCaret(){return this.origin.getNextSibling()}insert(e){return this.origin.insertAfter(e),this}},previous:class extends eb{direction=`previous`;getNodeAtCaret(){return this.origin.getPreviousSibling()}insert(e){return this.origin.insertBefore(e),this}}},ab={next:class extends $y{direction=`next`;getNodeAtCaret(){return this.origin.getNextSibling()}insert(e){return this.origin.insertAfter(e),this}},previous:class extends $y{direction=`previous`;getNodeAtCaret(){return this.origin.getPreviousSibling()}insert(e){return this.origin.insertBefore(e),this}}},ob={next:class extends Yy{direction=`next`;getNodeAtCaret(){return this.origin.getFirstChild()}insert(e){return this.origin.splice(0,0,[e]),this}},previous:class extends Yy{direction=`previous`;getNodeAtCaret(){return this.origin.getLastChild()}insert(e){return this.origin.splice(this.origin.getChildrenSize(),0,[e]),this}}};function sb(e,t){return e?new ab[t](e):null}function cb(e,t,n){return e?new ib[t](e,lb(e,n)):null}function lb(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 ub(e,t){return new hb(e,t)}function db(e,t){return W(e)?new ob[t](e):null}function fb(e){return e&&e.getChildCaret()||e}function pb(e){return e&&fb(e.getAdjacentCaret())}var mb=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 tb(t)?function(e,t){let{direction:n,origin:r}=e;return ub(e,lb(r,t===`focus`?Zy(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[ub(e,r.offset-e.offset),null]}return[t,n]}iterNodeCarets(e=`root`){let t=tb(this.anchor)?this.anchor.getSiblingCaret():this.anchor.getLatest(),n=this.focus.getLatest(),r=tb(n),i=t=>t.isSameNodeCaret(n)?null:pb(t)||t.getParentCaret(e);return yb({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`)}},hb=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 cb(e.setTextContent(i.slice(0,n)+i.slice(r)),t,n)}};function gb(e){return vb(e,sb(U_(),e.direction))}function _b(e){return vb(e,e)}function vb(e,t){return e.direction!==t.direction&&I(265),new mb(e,t,e.direction)}function yb(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 bb(e,t){let n=wb(e.origin,t.origin);switch(n===null&&I(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 xb(n)}}function xb(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 Sb(e,t){return t.is(e)}function Cb(e){return W(e)?[e.getLatest(),null]:[e.getParent(),e.getLatest()]}function wb(e,t){if(e.is(t))return{commonAncestor:e,type:`same`};let n=/* @__PURE__ */ new Map;for(let[t,r]=Cb(e);t;r=t,t=t.getParent())n.set(t,r);for(let[r,i]=Cb(t);r;i=r,r=r.getParent()){let a=n.get(r);if(a!==void 0)return a===null?(Sb(e,r)||I(276),{commonAncestor:r,type:`ancestor`}):i===null?(Sb(t,r)||I(277),{commonAncestor:r,type:`descendant`}):((W(a)||Sb(e,a))&&(W(i)||Sb(t,i))&&r.is(a.getParent())&&r.is(i.getParent())||I(278),{a,b:i,commonAncestor:r,type:`branch`})}return null}function Tb(e,t){let{type:n,key:r,offset:i}=e,a=Ev(e.key);return n===`text`?(B(a)||I(266,a.getType(),r),cb(a,t,i)):(W(a)||I(267,a.getType(),r),Rb(a,e.offset,t))}function Eb(e,t){let{origin:n,direction:r}=t,i=r===`next`;tb(t)?e.set(n.getKey(),t.offset,`text`):nb(t)?B(n)?e.set(n.getKey(),lb(n,r),`text`):e.set(n.getParentOrThrow().getKey(),n.getIndexWithinParent()+ +!!i,`element`):(rb(t)&&W(n)||I(268),e.set(n.getKey(),i?0:n.getChildrenSize(),`element`))}function Db(e){let t=H(),n=V(t)?t:Uh();return Ob(n,e),W_(n),n}function Ob(e,t){Eb(e.anchor,t.anchor),Eb(e.focus,t.focus)}function kb(e){let{anchor:t,focus:n}=e,r=Tb(t,`next`),i=Tb(n,`next`),a=bb(r,i)<=0?`next`:`previous`;return vb(Ib(r,a),Ib(i,a))}function Ab(e){let{direction:t,origin:n}=e,r=sb(n,Zy(t)).getNodeAtCaret();return r?sb(r,t):db(n.getParentOrThrow(),t)}function jb(e,t=`root`){let n=[e];for(let r=rb(e)?e.getParentCaret(t):e.getSiblingCaret();r!==null;r=r.getParentCaret(t))n.push(Ab(r));return n}function Mb(e){return!!e&&e.origin.isAttached()}function Nb(e,t=`removeEmptySlices`){if(e.isCollapsed())return e;let n=`root`,r=`next`,i=t,a=Lb(e,r),o=jb(a.anchor,n),s=jb(a.focus.getFlipped(),n),c=/* @__PURE__ */ new Set,l=[];for(let e of a.iterNodeCarets(n))if(rb(e))c.add(e.origin.getKey());else if(nb(e)){let{origin:t}=e;W(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),M_(e)}for(let e of u)!e.canBeEmpty()&&!Sv(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=Ab(sb(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=lh(e.getTextContent()).setStyle(e.getStyle()).setFormat(e.getFormat());a.replaceOrInsert(n),t=cb(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(Mb(e)){d=Pb(e);break}for(let e of s)if(Mb(e)){f=Pb(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(Sv(i))return;!n&&t(i)&&(n=i)}return n},u=l(a,Qv),d=u&&l(o,e=>n.has(e.getKey())&&Qv(e));return d&&Ny(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(rb(e)){let t=e.origin;if(Qv(t))return t}else{let t=e.getParentAtCaret();if(t&&Qv(t))return t}return null}(f),t=e&&e.getParent(),n=e&&e.getParents().findLast(xv);if(e&&t&&!Vg(t)&&e.isEmpty()&&c.has(e.getKey())&&Ny(e).length===0&&(!n||c.has(n.getKey()))){e.remove(!0);let n=t;for(;n&&!Vg(n)&&n.isEmpty();){let e=n.getParent();if(e&&Vg(e)&&e.getChildrenSize()<=1)break;let t=n;n=e,t.remove(!0)}}}let m=[d,f,...o,...s].find(Mb);if(m)return _b(Ib(Pb(m),e.direction));I(269,JSON.stringify(o.map(e=>e.origin.__key)))}function Pb(e){let t=function(e){let t=e;for(;rb(t);){let e=pb(t);if(!rb(e))break;t=e}return t}(e.getLatest()),{direction:n}=t;if(B(t.origin))return tb(t)?t:cb(t.origin,n,n);let r=t.getAdjacentCaret();return nb(r)&&B(r.origin)?cb(r.origin,n,Zy(n)):t}function Fb(e){return tb(e)&&e.offset!==lb(e.origin,e.direction)}function Ib(e,t){return e.direction===t?e:e.getFlipped()}function Lb(e,t){return e.direction===t?e:vb(Ib(e.focus,t),Ib(e.anchor,t))}function Rb(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 Ib(r,n)}function zb(e){let{origin:t,offset:n,direction:r}=e;if(n===lb(t,r))return e.getSiblingCaret();if(n===lb(t,Zy(r)))return Ab(e.getSiblingCaret());let[i]=t.splitText(n);return B(i)||I(281),Ib(sb(i,`next`),r)}function Bb(e,t){return!0}function Vb(e,{$copyElementNode:t=Cv,$splitTextPointCaretNext:n=zb,rootMode:r=`shadowRoot`,$shouldSplit:i=Bb,removeEmptyDestination:a=!1}={}){if(tb(e))return n(e);let o=e.getParentCaret(r);if(o){let{origin:n}=o;if(rb(e)){let e=Ab(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 Hb(e,t,n){let r=Ib(t,`next`);tb(r)&&(r.offset===0?r=sb(r.origin,`previous`).getFlipped():r.offset===r.origin.getTextContentSize()&&(r=sb(r.origin,`next`))),r.origin.is(e)&&(nb(r)||I(342,e.getKey(),e.getType()),r=Ab(r)),(e.is(r.getNodeAtCaret())||e.is(r.getFlipped().getNodeAtCaret()))&&e.remove(!0);for(let e=r;e;e=Vb(e,n))r=e;return tb(r)&&I(283),r.insert(e.isInline()?r_().append(e):e),Ib(sb(e.getLatest(),`next`),t.direction)}function Ub(e){return e}function Wb(e){return e}function Gb(e,t){if(!t||e===t)return e;for(let n in t)if(e[n]!==t[n])return{...e,...t};return e}function Kb(...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 qb(e,...t){let n=Kb(...t);n.length>0&&e.classList.add(...n)}function Jb(...e){return()=>{for(let t=e.length-1;t>=0;t--)e[t]();e.length=0}}function Yb(e){throw Error(`unreachable input event: ${JSON.stringify(e)}`)}function Xb(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 Zb(e,t){return e.startsWith(t)||e===t.trimEnd()}var Qb=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 Yb(e)}}onDraftChanged(e){return this.phase===`claimed`&&this.claim!==void 0&&!Zb(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:Xb(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:Xb(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&&Zb(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 $b(e){let t=$v().getElementByKey(e.getKey());if(t===null)return null;let n=t.ownerDocument.defaultView;return n===null?null:n.getComputedStyle(t)}function ex(e){return $b(Vg(e)?e:e.getParentOrThrow())}function tx(e,t,n=`self`){let r=e.getStartEndPoints();if(t.isSelected(e)&&!E_(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]=Dh(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=cy(t)),t.__text=p)}}return t}function nx(e){let t=rx(e);return t!==null&&t.writingMode===`vertical-rl`}function rx(e){let t=e.anchor.getNode();return W(t)?$b(t):ex(t)}function ix(e,t){let n=nx(e)?!t:t;ox(e)&&(n=!n);let r=Tb(e.focus,n?`previous`:`next`);if(Fb(r))return!1;if(tb(r)&&!ph(r.origin)&&r.origin.isUnmergeable()){let e=r.getNodeAtCaret();if(B(e)&&!ph(e))return!0}for(let e of gb(r)){if(rb(e))return!e.origin.isInline();if(!W(e.origin)){if(G(e.origin))return!0;break}}return!1}function ax(e,t,n,r){e.modify(t?`extend`:`move`,n,r)}function ox(e){let t=rx(e);return t!==null&&t.direction===`rtl`}function sx(e,t,n){let r=ox(e),i;i=nx(e)||r?!n:n,ax(e,t,i,`character`)}function cx(e,t){return e!==null&&Object.getPrototypeOf(e).constructor.name===t.name}let lx=Symbol.for(`preact-signals`);function ux(){if(mx>1)return void mx--;let e,t=!1;for(function(){let e=px;for(px=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,hx++;n!==void 0;){let r=n.u;if(n.u=void 0,n.f&=-3,!(8&n.f)&&yx(n))try{n.c()}catch(n){t||=(e=n,!0)}n=r}}if(hx=0,mx--,t)throw e}let Y,dx;function fx(e){let t=Y;Y=void 0;try{return e()}finally{Y=t}}let px,mx=0,hx=0,gx=0;function _x(e){if(Y===void 0)return;let t=e.n;return t===void 0||t.t!==Y?(t={i:0,S:e,p:Y.s,n:void 0,t:Y,e:void 0,x:void 0,r:t},Y.s!==void 0&&(Y.s.n=t),Y.s=t,e.n=t,32&Y.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=Y.s,t.n=void 0,Y.s.n=t,Y.s=t),t):void 0}function vx(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 yx(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 bx(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 xx(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 Sx(e,t){vx.call(this,void 0),this.x=e,this.s=void 0,this.g=gx-1,this.f=4,this.W=t?.watched,this.Z=t?.unwatched,this.name=t?.name}function Cx(e){let t=e.m;if(e.m=void 0,typeof t==`function`){mx++;let n=Y;Y=void 0;try{t()}catch(t){throw e.f&=-2,e.f|=8,wx(e),t}finally{Y=n,ux()}}}function wx(e){for(let t=e.s;t!==void 0;t=t.n)t.S.U(t);e.x=void 0,e.s=void 0,Cx(e)}function Tx(e){if(Y!==this)throw Error(`Out-of-order effect`);xx(this),Y=e,this.f&=-2,8&this.f&&wx(this),ux()}function Ex(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 Dx(e,t){let n=new Ex(e,t);try{n.c()}catch(e){throw n.d(),e}let r=n.d.bind(n);return r[Symbol.dispose]=r,r}vx.prototype.brand=lx,vx.prototype.h=function(){return!0},vx.prototype.S=function(e){let t=this.t;t!==e&&e.e===void 0&&(e.x=t,this.t=e,t===void 0?fx(()=>{var e;(e=this.W)==null||e.call(this)}):t.e=e)},vx.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&&fx(()=>{var e;(e=this.Z)==null||e.call(this)}))}},vx.prototype.subscribe=function(e){return Dx(()=>{let t=this.value,n=Y;Y=void 0;try{e(t)}finally{Y=n}},{name:`sub`})},vx.prototype.valueOf=function(){return this.value},vx.prototype.toString=function(){return this.value+``},vx.prototype.toJSON=function(){return this.value},vx.prototype.peek=function(){let e=Y;Y=void 0;try{return this.value}finally{Y=e}},Object.defineProperty(vx.prototype,"value",{get(){let e=_x(this);return e!==void 0&&(e.i=this.i),this.v},set(e){if(e!==this.v){if(hx>100)throw Error(`Cycle detected`);(function(e){mx!==0&&hx===0&&e.l!==0&&(e.l=0,px={S:e,v:e.v,i:e.i,o:px})})(this),this.v=e,this.i++,gx++,mx++;try{for(let e=this.t;e!==void 0;e=e.x)e.t.N()}finally{ux()}}}}),Sx.prototype=new vx,Sx.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===gx))return!0;if(this.g=gx,this.f|=1,this.i>0&&!yx(this))return this.f&=-2,!0;let e=Y;try{bx(this),Y=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 Y=e,xx(this),this.f&=-2,!0},Sx.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)}vx.prototype.S.call(this,e)},Sx.prototype.U=function(e){if(this.t!==void 0&&(vx.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)}},Sx.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(Sx.prototype,"value",{get(){if(1&this.f)throw Error(`Cycle detected`);let e=_x(this);if(this.h(),e!==void 0&&(e.i=this.i),16&this.f)throw this.v;return this.v}}),Ex.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()}},Ex.prototype.S=function(){if(1&this.f)throw Error(`Cycle detected`);this.f|=1,this.f&=-9,Cx(this),bx(this),mx++;let e=Y;return Y=this,Tx.bind(this,e)},Ex.prototype.N=function(){2&this.f||(this.f|=2,this.u=dx,dx=this)},Ex.prototype.d=function(){this.f|=8,1&this.f||wx(this)},Ex.prototype.dispose=function(){this.d()};function Ox(e){return(typeof e.nodes==`function`?e.nodes():e.nodes)||[]}function kx(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 Ax;try{Ax=`0.49.0+prod.esm`}catch{}let jx=Ax??`"<unknown>+source"`,Mx=/* @__PURE__ */ new Set([`__proto__`,`constructor`,`prototype`]);function Nx(e,t){if(e&&t&&!Array.isArray(t)&&typeof e==`object`&&typeof t==`object`){let n=e,r=t;for(let e in r)!Mx.has(e)&&Object.prototype.hasOwnProperty.call(r,e)&&(n[e]=Nx(n[e],r[e]));return e}return t}function Px(e){return e.id===0}function Fx(e){return e.id===2}function Ix(e){return function(e){return e.id===1}(e)||kx(305,String(e.id),`1`),Object.assign(e,{id:2})}let Lx=/* @__PURE__ */ new Set;var Rx=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):Gb;for(let n of this.configs)e=t(e,n);return e}init(e){let t=this.state;Fx(t)||kx(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&&kx(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&&kx(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&&kx(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&&kx(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&&kx(311),this._signal}getInitResult(){this.extension.init===void 0&&kx(312,this.extension.name);let e=this.state;return function(e){return e.id>=4}(e)||kx(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)||kx(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&&kx(315,this.extension.name,e.name),t.getExtensionInitDependency()}getDependency(e){let t=this.builder.getExtensionRep(e);return t===void 0&&kx(315,this.extension.name,e.name),t.getExtensionDependency()}getState(){let e=this.state;return function(e){return e.id>=7}(e)||kx(316,String(e.id),`7`),e}getDirectDependentNames(){return this.builder.incomingEdges.get(this.extension.name)||Lx}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)||kx(317,this.extension.name),this._dependency={config:e.config,init:e.initResult,output:e.output}}return this._dependency}};let zx={tag:zm};function Bx(){let e=U_();e.isEmpty()&&e.append(r_())}let Vx=/* @__PURE__ */ Ub({config:/* @__PURE__ */ Wb({setOptions:zx,updateOptions:zx}),init:({$initialEditorState:e=Bx})=>({$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(Gg(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:[Bg,eh,Jg,dh,t_]}),Hx=Symbol.for(`@lexical/extension/LexicalBuilder`);function Ux(){}function Wx(e){throw e}function Gx(e){return Array.isArray(e)?e:[e]}let Kx=jx;var qx=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=Kx,this.roots=e;for(let t of e)this.addExtension(t)}static fromExtensions(t){let n=[Gx(Vx)];for(let e of t)n.push(Gx(e));return new e(n)}static maybeFromEditor(t){let n=t[Hx];return n&&(n.PACKAGE_VERSION!==Kx&&kx(292,n.PACKAGE_VERSION,Kx),n instanceof e||kx(293)),n}static fromEditor(t){let n=e.maybeFromEditor(t);return n===void 0&&kx(294),n}constructEditor(){let{$initialEditorState:e,onError:t,onWarn:n,...r}=this.buildCreateEditorArgs(),i=Object.assign(l_({...r,...t?{onError:e=>{t(e,i)}}:{},...n?{onWarn:e=>{n(e,i)}}:{}}),{[Hx]:this});for(let e of this.sortedExtensionReps())e.build(i);return i}buildEditor(){let e=Ux;function t(){try{e()}finally{e=Ux}}let n=Object.assign(this.constructEditor(),{dispose:t,[Symbol.dispose]:t});return e=Jb(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&&kx(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&&kx(296);let[t]=Gx(e);typeof t.name!=`string`&&kx(297,typeof t.name);let n=this.extensionNameMap.get(t.name);if(n!==void 0&&n.extension!==t&&kx(298,t.name),!n){n=new Rx(this,t),this.extensionNameMap.set(t.name,n);let e=this.conflicts.get(t.name);typeof e==`string`&&kx(299,t.name,e);for(let e of t.conflictsWith||[])this.extensionNameMap.has(e)&&kx(299,t.name,e),this.conflicts.set(e,t.name);for(let e of t.dependencies||[]){let n=Gx(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(Fx(i))return;let a=n.extension.name;var o;Px(i)||kx(300,a,r||`[unknown]`),Px(o=i)||kx(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=Ix(i),n.state=i,e.push(n)};for(let e of this.extensionNameMap.values())Px(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&&kx(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 Jb(...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 Ox(o)){if(typeof e!=`function`){let t=n.get(e.replace);t&&kx(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&&Nx(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||=Wx,e}};function Jx(e,t){let n=qx.maybeFromEditor(e);if(!n)return;let r=n.extensionNameMap.get(t);return r?r.getExtensionDependency():void 0}var Yx=class extends zg{$config(){return this.config(`horizontalrule`,{importDOM:{hr:()=>({conversion:Xx,priority:0})}})}exportDOM(){return{element:Iv().createElement(`hr`)}}createDOM(e){let t=Iv().createElement(`hr`);return qb(t,e.theme.hr),t}getTextContent(){return`
146
- `}isInline(){return!1}updateDOM(){return!1}};function Xx(){return{node:Zx()}}function Zx(){return xy(Yx)}Date.now;function Qx(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 $x;function eS(e,t){let{key:n}=t;return e&&n in e?e[n]:t.defaultValue}function tS(e){return $x&&$x.editor===e?$x:void 0}function nS(e,t){if(`cfg`in t){let{cfg:n,updater:r}=t;return[n,r(eS(e,n))]}return t}function rS(e,t){let n=t;for(let r of e){let[e,i]=nS(n,r),a=e.key;if(n===t&&eS(n,e)===i)continue;let o=n===t||n===void 0?iS(t):n;o[a]=i,n=o}return n}function iS(e){return Object.create(e||null)}function aS(e,t){return[e,t]}function oS(e,t,n,r=$v()){let i=$x,a=tS(r);try{return $x={...a,editor:r,[e]:t},n()}finally{$x=i}}function sS(e,t=()=>{}){return(n,r=$v())=>i=>{let a=tS(r),o=a&&a[e],s=rS(n,o||t(r));return s&&s!==o?oS(e,s,i,r):i()}}function cS(e,t,n,r){return Object.assign(rf(Symbol(t),{isEqual:r,parse:n}),{[e]:!0})}let lS=`@lexical/html/DOM`,uS=Symbol.for(`@lexical/html/DOMExportContext`);function dS(e,t,n){return cS(uS,e,t,n)}let fS=/* @__PURE__ */ dS(`isExport`,Boolean);function pS(e){let t=Jx(e,lS);return t?t.output.defaults:void 0}function mS(e){let t=Jx(e,lS);return t?t.output.runtime:void 0}function hS(e=$v()){let t=mS(e);return t?t.getSessionConfig():ey(e)}let gS=sS(uS,pS),_S=Symbol.for(`@lexical/html/SelectorImpl`);function vS(e,t){let n={kind:`element`,predicate:(r=t,r.length===0?J: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=>vS(e,[...t,n]);return{[_S]:n,attr:(e,t,n)=>i(xS(e,t,n)),classAll:(...e)=>i(bS(e)),classAny:(...e)=>i(function(e){let t=yS(e);return t.length===0?()=>!1:e=>{if(!J(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=>J(n)&&n.style.getPropertyValue(e)===t;if(t instanceof RegExp){let r=n&&n.capture,i=t;return(t,n)=>{if(!J(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)}}Qx(362,JSON.stringify(e))}(e,t,n))}}function yS(e){let t=[];for(let n of e)n&&t.push(n);return t}function bS(e){let t=yS(e);return t.length===0?()=>!0:e=>{if(!J(e))return!1;let n=e.classList;for(let e of t)if(!n.contains(e))return!1;return!0}}function xS(e,t,n){if(!0===t)return t=>J(t)&&t.hasAttribute(e);if(typeof t==`string`)return n=>J(n)&&n.getAttribute(e)===t;if(t instanceof RegExp){let r=n&&n.capture,i=t;return(t,n)=>{if(!J(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)}}Qx(361,JSON.stringify(e))}let SS={kind:`text`,predicate:D_,tags:/* @__PURE__ */ new Set},CS={[_S]:SS},wS={kind:`comment`,predicate:e=>e.nodeType===8,tags:/* @__PURE__ */ new Set},TS={[_S]:wS},ES={any:()=>vS(/* @__PURE__ */ new Set,[]),comment:()=>TS,tag(...e){e.length>0||Qx(363);let t=/* @__PURE__ */ new Set;for(let n of e)t.add(n.toUpperCase());return vS(t,[])},text:()=>CS},DS=ES;DS.tag(`b`,`strong`,`em`,`i`,`code`,`mark`,`s`,`sub`,`sup`,`u`,`span`),DS.text(),DS.tag(`script`,`style`),DS.tag(`br`),DS.tag(`p`),DS.tag(`hr`),DS.any(),Object.freeze([]),Object.freeze({}),ES.any(),ES.any,ES.comment,ES.tag,ES.text;function OS(e,t=null,n=$v()){return gS([aS(fS,!0)],n)(()=>{let r=U_(),i=hS(n),a=V(t)?jy(t.anchor.getNode()):null,o=e.append.bind(e);for(let e of(W(a)?a:r).getChildren())AS(n,e,o,t,i);return e})}function kS(e,t=null){return(typeof document>`u`||typeof window>`u`&&global.window===void 0)&&Qx(338),bg(e),OS(Iv().createElement(`div`),t,e).innerHTML}function AS(e,t,n,r=null,i=ey(e)){let a=i.$shouldInclude(t,r,e),o=i.$shouldExclude(t,r,e),s=t;r!==null&&B(t)&&(s=tx(r,t,`clone`));let{element:c,after:l,append:u,$getChildNodes:d}=i.$exportDOM(s,e);if(!c)return!1;let f=Iv().createDocumentFragment(),p=d?d():W(s)?s.getChildren():[],m=a&&Ch(r)&&W(t)?null:r,h=f.append.bind(f);for(let n of p){let o=AS(e,n,h,m,i);!a&&o&&i.$extractWithChild(t,n,r,`html`,e)&&(a=!0)}if(a&&!o){if((J(c)||qv(c))&&(u?u(f):c.append(f)),n(c),l){let e=l.call(s,c);e&&(qv(c)?c.replaceChildren(e):c.replaceWith(e))}}else n(f);return a}function jS(e,t,n=null){let r=Fv(n),i=n?Nv(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=fv(n)}return!1}(a.offsetNode,n))return{node:a.offsetNode,offset:a.offset}}if(a){let i=n.getRootNode();if(jv(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 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.`)}function NS(e,t=H()){return t??MS(166),V(t)&&t.isCollapsed()||t.getNodes().length===0?``:kS(e,t)}function PS(e,t){let n=e.getData(`text/plain`)||e.getData(`text/uri-list`);n!=null&&t.insertRawText(n)}let FS=`application/x-lexical-drag`;function IS(e,t){let n={editorKey:t.getKey()};e.setData(FS,JSON.stringify(n))}function LS(e,t,n){let r=e.dataTransfer;if(r===null)return!1;let i=function(e){let t=e.getData(FS);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=jS(e.clientX,e.clientY,t.getRootElement());if(n===null)return null;let r=B_(n.node);if(r===null)return null;if(B(r))return cb(r,`next`,n.offset);if(W(r))return Rb(r,n.offset,`next`);let i=r.getParent();return i===null?null:Rb(i,r.getIndexWithinParent()+1,`next`)}(e,t);if(a===null)return!1;let o=Vb(a);if(o===null)return!1;let s=i.editorKey===t.getKey(),c=H();if(s){if(!V(c)||c.isCollapsed())return!1;if(function(e,t){let{anchor:n,focus:r}=Lb(kb(t),`next`);return bb(n,e)<0&&bb(e,r)<0}(a,c))return e.preventDefault(),!0;c.removeText()}if(!o.origin.isAttached())return e.preventDefault(),!0;if(n(r,Db(_b(o)),t),!s){let e=t.getRootElement(),n=e?e.ownerDocument:null,r=n?function(e,t){for(let n of Pv(t)){let t=w_(n);if(S_(t)&&t.getKey()===e&&J(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 RS(e,t){return LS(e,t,(e,t)=>PS(e,t))}function zS(e,t){t.update(()=>{if(e!==null){let n=cx(e,KeyboardEvent)?null:e.clipboardData,r=H();if(r!==null&&!r.isCollapsed()&&n!=null){e.preventDefault();let i=NS(t);i!==null&&n.setData(`text/html`,i),n.setData(`text/plain`,r.getTextContent())}}})}function BS(e){return Jb(e.registerCommand(yp,e=>{let t=H();return!!V(t)&&(t.deleteCharacter(e),!0)},0),e.registerCommand(Tp,e=>{let t=H();return!!V(t)&&(t.deleteWord(e),!0)},0),e.registerCommand(Ep,e=>{let t=H();return!!V(t)&&(t.deleteLine(e),!0)},0),e.registerCommand(Sp,e=>{let t=H();if(!V(t))return!1;if(typeof e==`string`)t.insertText(e);else{let n=e.dataTransfer;if(n!=null)PS(n,t);else{let n=e.data;n&&t.insertText(n)}}return!0},0),e.registerCommand(wp,()=>{let e=H();return!!V(e)&&(e.removeText(),!0)},0),e.registerCommand(bp,e=>{let t=H();return!!V(t)&&(t.insertLineBreak(e),!0)},0),e.registerCommand(xp,()=>{let e=H();return!!V(e)&&(e.insertLineBreak(),!0)},0),e.registerCommand(Np,e=>{let t=H();if(!V(t))return!1;let n=e,r=n.shiftKey;return!!ix(t,!0)&&(n.preventDefault(),sx(t,r,!0),!0)},0),e.registerCommand(jp,e=>{let t=H();if(!V(t))return!1;let n=e,r=n.shiftKey;return!!ix(t,!1)&&(n.preventDefault(),sx(t,r,!1),!0)},0),e.registerCommand(zp,t=>!!V(H())&&(!_d||!gd)&&(t.preventDefault(),e.dispatchCommand(yp,!0)),0),e.registerCommand(Vp,t=>!!V(H())&&(t.preventDefault(),e.dispatchCommand(yp,!1)),0),e.registerCommand(Lp,t=>{if(!V(H()))return!1;if(t!==null){if((_d||yd||Sd)&&gd)return!1;t.preventDefault()}return e.dispatchCommand(bp,!1)},0),e.registerCommand(Yp,()=>{let e=H();return av(V(e)&&jy(e.anchor.getNode())!==null?e:null),!0},0),e.registerCommand(qp,t=>!!V(H())&&(zS(t,e),!0),0),e.registerCommand(Jp,t=>!!V(H())&&(function(e,t){zS(e,t),t.update(()=>{let e=H();V(e)&&e.removeText()},{tag:`cut`})}(t,e),!0),0),e.registerCommand(Cp,t=>!!V(H())&&(function(e,t){e.preventDefault(),t.update(()=>{let t=H(),n=cx(e,ClipboardEvent)?e.clipboardData:null;n!=null&&V(t)&&PS(n,t)},{tag:`paste`})}(t,e),!0),0),e.registerCommand(Up,t=>RS(t,e),0),e.registerCommand(Wp,t=>{let n=H();return!!V(n)&&(n.isCollapsed()||t.dataTransfer===null||IS(t.dataTransfer,e),!0)},0))}function VS(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(!(V(a)&&V(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||Vg(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)&&B(r)&&r.__text.length===1&&a.anchor.offset===1?2:0}let c=s[0],l=e._nodeMap.get(c.__key);if(!B(l)||!B(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 HS(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:VS(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!(V(a)&&V(o)&&a.anchor.type===`element`&&a.focus.type===`element`&&o.anchor.type===`text`&&o.focus.type===`text`||!B(r)||!B(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 US(e,t){e.undoStack=[],e.redoStack=[],e.current=null,t&&t(e)}function WS(e,t,n,r=Date.now,i,a=null){let o=HS(e,n,r),s=()=>{i&&i(t)};return s(),Jb(e.registerCommand(Op,()=>(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(Qp,!0)),i.length===0&&e.dispatchCommand($p,!1),t.current=o||null,n&&n(t),o&&o.editor.setEditorState(o.editorState,{tag:`historic`})}}(e,t,i),!0),0),e.registerCommand(kp,()=>(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($p,!0));let o=r.pop();r.length===0&&e.dispatchCommand(Qp,!1),t.current=o||null,n&&n(t),o&&o.editor.setEditorState(o.editorState,{tag:`historic`})}}(e,t,i),!0),0),e.registerCommand(Xp,()=>(US(t,i),!1),0),e.registerCommand(Zp,()=>(US(t,i),e.dispatchCommand(Qp,!1),e.dispatchCommand($p,!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(Qp,!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($p,!0)}}else if(m===2)return;t.current={editor:e,editorState:n},s()}))}function GS(){return{current:null,redoStack:[],undoStack:[]}}Date.now;let KS=`application/x-codexhost-thread-reference`,qS=/^remote-(?:peer:|ssh(?:-|:)|control:).+/u;function JS(e){let t=e.projectionValues?.threadReference;if(!e.blank&&t?.hostId&&(t.hostId===`local`||qS.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 YS(e){return`thread://${encodeURIComponent(e.threadId).replace(/[!'()*]/gu,e=>`%${e.charCodeAt(0).toString(16).toUpperCase()}`)}?hostId=${encodeURIComponent(e.hostId)}`}function XS(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(!qS.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 ZS(e){let t=`[@${e.title.replace(/[\\`*{}[\]()#+.!_<>|~-]/gu,e=>`\\${e}`)}](${YS(e)})`;return{source:`codexhost-thread`,ref:t,label:e.title,appearance:`session`,clipboardText:t}}function QS(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`&&!qS.test(r)||typeof i!=`string`?void 0:JS({id:n,blank:!1,title:i,projectionValues:{threadReference:{hostId:r,threadId:n}}})}catch{return}}function $S(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=$S(e[t]))&&(r&&(r+=` `),r+=n)}else for(n in e)e[n]&&(r&&(r+=` `),r+=n)}return r}function eC(){for(var e,t,n=0,r=``,i=arguments.length;n<i;n++)(e=arguments[n])&&(t=$S(e))&&(r&&(r+=` `),r+=t);return r}let tC=`@deepseek-ai/dsh-client-ui-conversation/ReferenceChip.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(tC)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-conversation`,e.dataset.pluginCss=tC,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 nC={chip:`s8J5YG_chip`,icon:`s8J5YG_icon`,invalid:`s8J5YG_invalid`,label:`s8J5YG_label`,marker:`s8J5YG_marker`};let rC=`@deepseek-ai/dsh-client-ui-conversation/composer-editor.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(rC)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-conversation`,e.dataset.pluginCss=rC,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 iC={openable:`_VTzna_openable`,reference:`_VTzna_reference`,textRef:`_VTzna_textRef`};function aC({label:e,reference:t,appearance:n,invalid:r}){return/* @__PURE__ */ (0,h.jsxs)(`span`,{className:eC(iC.reference,nC.chip,n===`file`&&!r&&iC.openable,r&&nC.invalid),title:e,children:[n===void 0?/* @__PURE__ */ (0,h.jsx)(`span`,{className:nC.marker,"aria-hidden":!0,children:`@`}):/* @__PURE__ */ (0,h.jsx)(d.ReferenceIconRegular,{kind:n,reference:t,size:14,className:nC.icon}),/* @__PURE__ */ (0,h.jsx)(`span`,{className:nC.label,children:e})]})}var oC=class e extends zg{__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)(aC,{label:this.__label,reference:this.__ref,appearance:this.__appearance,invalid:this.__invalid})}};function sC(e){return new oC(e)}function cC(e){return e instanceof oC}function lC(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 uC(e,t,n,r){let i=e=>e instanceof n,a=e=>{let t=lh(e.getTextContent());t.setFormat(e.getFormat()),e.replace(t)};return[e.registerNodeTransform(eh,e=>{if(!e.isSimpleText())return;let n,o=e.getPreviousSibling(),s=e.getTextContent(),c=e;if(B(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(B(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&&B(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&&lC(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();B(o)&&o.isTextEntity()&&(a(o),a(e));let s=e.getNextSibling();B(s)&&s.isTextEntity()&&(a(s),i(e)&&a(e))})]}let dC=/(^|\s)([/@])([\w-]+)/g,fC=/(^|\s)(@(?:"[^"\n]*"?|[^\s"]\S*))/g,pC=/* @__PURE__ */ new Set(`.,;:!?,。;:!?`),mC=/^@.*[/\\.]/u;function hC(e,t,n){if(!n.startsWith(`@"`)){let e=n.length;for(;pC.has(n.charAt(e-1));)--e;return mC.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(;pC.has(e.charAt(i));)i+=1;return i===e.length||/\s/u.test(e.charAt(i))?t+r+1:void 0}let gC=/^(?:\s|$)/;function _C(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!==`/`||gC.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})}}fC.lastIndex=0;let i;for(;(i=fC.exec(e))!==null;){let t=i.index+(i[1]?.length??0),r=hC(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 vC=class e extends eh{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=eC(t.className,iC.reference,iC.textRef,this.getTextContent().startsWith(`/`)&&iC.openable),t.setAttribute(`spellcheck`,`false`),t.setAttribute(`data-composer-text-ref`,``),t}isTextEntity(){return!0}canInsertTextBefore(){return!0}};function yC(e,t,n){return Jb(...uC(e,e=>{let r=n();for(let n of _C(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},vC,e=>new vC(e.getTextContent())))}function bC(e){e.update(()=>{for(let e of U_().getAllTextNodes())(e instanceof vC||e.getPreviousSibling()instanceof vC||/[/@]/u.test(e.getTextContent()))&&e.markDirty()},{tag:zm})}function xC(e,t){return e.registerCommand(mp,e=>{if(e.target===null||e.button!==0||e.detail>1)return!1;let n=H();if(V(n)&&!n.isCollapsed())return!1;let r=B_(e.target);if(cC(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 vC&&t(void 0,{ref:r.getTextContent()})},1)}function SC(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 CC=Xl([O(),k(),A(),Hl()]);function wC(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 TC=Au(wC,{message:`JSON value must not contain circular references`}),EC=Ou(()=>Xl([CC,j(EC),iu(O(),EC)])),DC=TC.pipe(EC);TC.pipe(j(EC));let OC=TC.pipe(iu(O(),EC)),kC=N({code:O().min(1),message:O().min(1),retryable:A(),diagnostic:O().min(1).optional(),stage:O().min(1).optional(),durationMs:k().int().nonnegative().optional(),stderrTail:O().min(1).optional()}).superRefine(SC([`diagnostic`,`stage`,`durationMs`,`stderrTail`])),AC=O().max(64).regex(/^[a-z]{2,3}(?:-[A-Za-z0-9]{2,8})*$/u),jC=e=>O().min(1).max(e).refine(e=>e.trim().length>0),MC=iu(AC,M({label:jC(256).optional(),description:jC(1024).optional()}).strict()).refine(e=>Object.keys(e).length<=16,`Too many locales`),NC=iu(AC,jC(4096)).refine(e=>typeof e.en==`string`,`English fallback is required`).refine(e=>Object.keys(e).length<=16,`Too many locales`),PC=O().refine(e=>e.trim().length>0,{message:`Identifier must not be empty or whitespace`}),FC=PC.brand(),IC=PC.brand(),LC=PC.brand();PC.brand(),PC.brand();let RC=O().refine(e=>e.trim().length>0,{message:`Value must not be empty or whitespace`}),zC=RC.max(128).regex(/^[A-Za-z0-9._~:-]+$/u,`Permission Mode ID must use transport-safe characters`).brand(),BC=M({modes:j(M({id:zC,label:RC.max(256),description:RC.max(1024).optional(),dangerous:A().optional(),localizations:MC.optional()}).strict()).min(1).max(32),defaultModeId:zC}).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`]})});M({threadId:IC,permissionModeId:zC}).strict();let VC=O().refine(e=>e.trim().length>0,{message:`Value must not be empty or whitespace`});M({sourceThreadId:IC,lastTurnId:LC.optional(),targetHarnessId:FC,targetModel:VC.max(1024).optional(),targetThinkingOptionId:VC.max(128).regex(/^[A-Za-z0-9._~-]+$/u,`Thinking option ID must use transport-safe characters`).optional()}).strict();let HC=M({sourceThreadId:IC,sourceHarnessId:FC,sourceHarnessLabel:VC.max(256).optional(),sourceModel:VC.max(1024).optional(),targetHarnessId:FC,targetHarnessLabel:VC.max(256).optional(),targetModel:VC.max(1024).optional(),totalTurns:k().int().min(1),boundaryTurnNumber:k().int().min(1),includedTurnNumbers:j(k().int().min(1)),omittedTurns:k().int().min(0),preview:O().max(32e3),createdAtMs:k().int().nonnegative()}).strict();M({threadId:IC,handoff:HC}).strict();let UC=k().int().safe().nonnegative(),WC=k().finite().nonnegative(),GC=k().finite().min(0).max(100),KC=M({version:Xl([F(3),F(4)]).optional(),requestId:O().min(1),turnId:O().min(1).max(1024),outputTokens:UC,startedAtMs:UC,completedAtMs:UC}).strict().refine(e=>e.completedAtMs>e.startedAtMs),qC=M({version:Xl([F(2),F(3),F(4)]).optional(),value:WC,turnId:O().min(1).max(1024),at:UC}).strict();M({outputTimings:j(KC).transform(e=>e.filter(e=>e.version===4)).optional(),outputTokensPerSecond:qC.refine(e=>e.version===4).optional().catch(void 0),timeToFirstOutputMs:qC.extend({value:UC}).optional()}).strict();let JC=e=>NC.refine(t=>Object.values(t).every(t=>t.length<=e)),YC=M({composerIndicators:j(M({kind:F(`countdown`),id:O().min(1).max(64),expiresAtUnix:UC,label:JC(256).optional(),tooltip:JC(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:UC.optional(),cachedInputTokens:UC.optional(),cacheWriteInputTokens:UC.optional(),outputTokens:UC.optional(),outputTokensPerSecond:WC.optional(),sessionOutputTokensPerSecond:WC.optional(),apiOutputTokensPerSecond:WC.optional(),reasoningOutputTokens:UC.optional(),totalTokens:UC.optional(),totalCostUsd:WC.optional(),totalCredits:WC.optional(),contextUsagePercent:WC.optional(),cacheHitRatePercent:GC.optional(),contextWindowTokens:UC.optional(),contextUsedTokens:UC.optional(),planFiveHourUsedPercent:GC.optional(),planFiveHourResetsAtUnix:UC.optional(),planSevenDayUsedPercent:GC.optional(),planSevenDayResetsAtUnix:UC.optional(),sessionCacheHitRatePercent:GC.optional(),timeToFirstOutputMs:UC.optional(),latestRequestTimeToFirstOutputMs:UC.optional(),costSource:P([`publicPrice`,`native`]).optional(),unpricedModels:j(O().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`]})}),XC=k().finite().min(0).max(100),ZC=P([`weekly`,`monthly`,`five_hour`,`seven_day`,`unknown`]),QC=M({id:O().min(1).max(256),label:O().min(1).max(256),localizations:MC.optional()}).strict(),$C=M({product:O().min(1),periodType:ZC.optional(),scope:QC.optional(),localizations:MC.optional(),used:k().finite().nonnegative().optional(),limit:k().finite().nonnegative().optional(),unit:O().min(1).max(32).optional(),usagePercent:XC,resetsAt:O().min(1).optional()}).strict(),ew=M({availableCount:k().int().safe().positive(),nextExpiresAt:O().min(1).optional(),expiresAt:j(O().min(1)).min(1).max(32).optional()}).strict(),tw=M({used:k().finite().nonnegative().optional(),limit:k().finite().nonnegative().optional(),unit:O().min(1).max(32).optional(),label:O().min(1).optional(),scope:QC.optional(),localizations:MC.optional(),usedPercent:XC,resetsAt:O().min(1).optional(),periodType:ZC,productUsage:j($C).min(1).optional(),resetCredits:ew.optional()}).strict(),nw=M({amount:k().finite().nonnegative(),currency:O().trim().min(1).max(8),label:O().trim().min(1).max(128).optional()}).strict();M({threadId:IC,refresh:F(`exact`).optional()}).strict(),M({threadId:IC,usage:YC.nullable(),accountCredits:tw.optional(),accountBalance:nw.optional(),accountCreditsSupported:A().optional()}).strict();let rw=O().refine(e=>e.trim().length>0,{message:`Value must not be empty or whitespace`}),iw=O().min(1).max(512).refine(e=>!/\p{Cc}/u.test(e),`Model Ref must not contain control characters`).brand(),aw=P([`priority`,`ultrafast`]),ow=M({id:iw,serviceTier:aw.optional()}).strict();function sw(e,t){return e?.id===t?.id&&e?.serviceTier===t?.serviceTier}let cw=rw.max(128).regex(/^[A-Za-z0-9._~-]+$/u,`Thinking option ID must use transport-safe characters`).brand(),lw=rw.max(256),uw=M({id:cw,label:rw.max(256)}).strict(),dw=M({ref:ow,label:rw.max(256),resolvedModelLabel:lw.optional(),fastModel:ow.optional(),supportedThinkingOptionIds:j(cw).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 fw(e,t){if(t)return e?.models.find(e=>sw(e.ref,t)||sw(e.fastModel,t))}let pw=j(uw).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)}),mw=P([`catalog`,`activeModel`]),hw=M({models:j(dw),defaultModel:ow.optional(),thinkingOptions:pw,defaultThinkingOptionId:cw.optional(),thinkingOptionsScope:mw.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=>sw(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=>sw(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&&!fw(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`]})}),gw=M({fork:A(),forkAcrossCwd:A(),rollbackLastTurn:A()}).strict().refine(e=>e.fork||!e.forkAcrossCwd,{path:[`forkAcrossCwd`],message:`Cross-cwd Fork requires exact history Fork support`}),_w=P([`live`,`atCreate`]),vw=M({configuration:M({selectModel:A(),selectThinkingOption:A(),selectPermissionMode:A(),permissionModeScope:_w.default(`live`)}).strict(),history:gw,subagents:M({observe:A(),readTranscript:A()}).strict().optional(),autonomousTurns:M({observe:A()}).strict().optional(),steer:A().optional(),persistentPlan:A().optional()}).strict();M({effectiveModel:ow.optional(),resolvedModelLabel:lw.optional(),effectiveThinkingOptionId:cw.optional(),availableThinkingOptions:pw.optional(),effectivePermissionModeId:zC.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 yw=M({open:F(!0)}).strict();Xl([M({status:F(`ready`),catalog:hw,permissionModes:BC.optional(),capabilities:vw,webUi:yw.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`]})}),M({status:P([`notInstalled`,`unavailable`,`error`]),error:kC}).strict()]),M({harnessId:FC,cwd:rw.max(16384).optional(),refresh:A().optional(),purpose:F(`availability`).optional(),credentialAccess:P([`allow`,`retry`]).optional()}).strict(),M({harnessId:FC}).strict(),M({}).strict(),M({threadId:IC,model:ow}).strict(),M({threadId:IC,thinkingOptionId:cw}).strict(),M({threadId:IC,includeReferenceCapability:A().optional()}).strict(),Ql(`owner`,[M({owner:F(`codex`),locked:A(),effectiveModel:ow.optional(),resolvedModelLabel:lw.optional(),effectiveThinkingOptionId:cw.optional(),effectivePermissionModeId:zC.optional(),history:gw.optional(),supportsThreadReferences:F(!0).optional(),handoff:HC.optional()}).strict(),M({owner:F(`external`),harnessId:rw.max(256),transportModelId:rw.max(8192),effectiveModel:ow.optional(),resolvedModelLabel:lw.optional(),effectiveThinkingOptionId:cw.optional(),availableThinkingOptions:pw.optional(),effectivePermissionModeId:zC.optional(),catalog:hw.optional(),history:gw,usage:YC.optional(),handoff:HC.optional(),locked:F(!0)}).strict()]),M({threadIds:j(IC).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 bw=Ql(`owner`,[M({threadId:IC,owner:F(`codex`)}).strict(),M({threadId:IC,owner:F(`external`),harnessId:O().max(256).pipe(FC)}).strict()]);M({threads:j(bw).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)}),M({threadId:IC,text:O().optional()}).strict(),M({kind:F(`application`),value:O().transform((e,t)=>{try{return JSON.parse(e)}catch{return t.addIssue({code:`custom`,message:`Invalid steering context JSON`}),Gn}}).pipe(M({expectedTurnId:LC,clientUserMessageId:O().min(1),delivery:P([`newTurn`,`activeTurn`])}).strict())}).strict().transform(e=>e.value),P([`activeTurn`,`newTurn`]),M({delivery:P([`official`,`activeTurn`,`newTurn`])}).strict();let xw=O().min(1).max(128).regex(/^[a-z][a-z0-9]*(?:[._-][a-z0-9]+)*$/u),Sw=xw.pipe(FC),Cw=Sw.refine(e=>e!==`codex`,`The official Codex identity is reserved`),ww=O().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`),Tw=xl().refine(e=>/^https:\/\/[^/?#@]+(?:[/?#]|$)/iu.test(e),`Plugin documentation links must be credential-free HTTPS URLs`),Ew=M({en:O().max(4096),"zh-CN":O().max(4096).optional()}).strict(),Dw=M({commands:j(M({terminal:O().max(256),command:O().max(4096)}).strict()).max(8),before:Ew.optional(),after:Ew.optional(),downloads:j(M({label:O().max(128),url:Tw}).strict()).max(8).optional()}).strict(),Ow={id:Sw,name:O().trim().min(1).max(128),version:O().min(1).max(128),kind:F(`usage`).optional(),iconStyle:M({vector:M({viewBox:O().max(128).regex(/^-?\d+(?:\.\d+)?(?: +-?\d+(?:\.\d+)?){3}$/u),color:O().regex(/^(?:currentColor|#[a-f0-9]{6})$/iu),paths:j(M({d:O().min(1).max(32768).regex(/^[MmLlHhVvCcSsQqTtAaZz\d.,+eE\s-]+$/u),fillRule:P([`evenodd`,`nonzero`]).optional(),fill:O().regex(/^(?:currentColor|#[a-f0-9]{6})$/iu).optional()}).strict()).min(1).max(32)}).strict().optional(),background:O().regex(/^#[a-f0-9]{6}$/iu).optional(),borderRadius:k().min(0).max(50).optional(),paddingRatio:k().min(0).max(.25).optional()}).strict().optional(),installation:Dw.optional(),notice:Ew.optional(),launchCommand:F(!0).optional(),links:M({website:Tw.optional(),documentation:Tw.optional(),installation:Tw.optional()}).strict().optional()};M({manifestVersion:F(1),...Ow,adapterApiVersion:k().int().positive(),entry:ww,icon:ww.optional()}).strict();let kw=O().max(174828).regex(/^data:image\/(?:png|jpeg|webp|svg\+xml);base64,[A-Za-z0-9+/]+={0,2}$/u),Aw=M({...Ow,icon:kw.optional()}).strict();M({}).strict(),M({plugins:j(Aw.extend({id:Cw})).max(128)}).strict(),M({version:F(1),enabled:j(Sw).max(128)}).strict().refine(e=>new Set(e.enabled).size===e.enabled.length,{message:`Enabled plugin IDs must be unique`,path:[`enabled`]});let jw=xw,Mw=P([`sidebar.thread-layout`,`sidebar.thread-badge`,`appearance.theme`]),Nw=P([`appearance`,`interface`,`workflow`,`analytics`,`integrations`,`tools`]),Pw=O().trim().min(1).max(128);function Fw(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 Iw=e=>e.split(`/`).every(e=>!/[. ]$/u.test(e)),Lw=ww.refine(e=>Fw(e)!==void 0&&Iw(e),`Images must be relative .png, .jpg, .jpeg, or .webp paths with no segments ending in a dot or space`),Rw=O().trim().max(2048).regex(/^https?:\/\/[^/?#\\\s]+/iu,`Expected an HTTP(S) URL`).pipe(xl({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 zw(e){return N({en:e,"zh-CN":e})}let Bw=zw(O().trim().min(1)),Vw=j(Nw).max(Nw.options.length).refine(e=>new Set(e).size===e.length,`Duplicate categories`),Hw=j(Mw).max(Mw.options.length).refine(e=>new Set(e).size===e.length,`Duplicate slots`),Uw={key:O().regex(/^[A-Za-z_][A-Za-z0-9_]*$/u),label:Bw,description:Bw.optional()},Ww={...Uw,step:k().positive().optional(),default:k().optional()},Gw=N({value:O(),label:Bw}),Kw=Ql(`type`,[N({...Uw,type:F(`boolean`),default:A().optional()}),N({...Uw,type:F(`string`),placeholder:Bw.optional(),default:O().optional()}),N({...Ww,type:F(`number`),min:k().optional(),max:k().optional()}),N({...Ww,type:F(`range`),min:k(),max:k()}),N({...Uw,type:F(`select`),options:j(Gw).min(1),default:O().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`)}}),qw=M({manifestVersion:zl().positive(),id:jw,name:Xl([Pw,zw(Pw)]),version:O().min(1).max(128),desktopApi:zl().positive()}).passthrough().extend({manifestVersion:F(1),desktopApi:F(1),description:N({en:O().max(4096),"zh-CN":O().max(4096).optional()}).optional(),author:O().trim().min(1).max(128).optional(),repository:Rw.optional(),details:N({en:O().max(16384),"zh-CN":O().max(16384).optional()}).optional(),icon:Lw.optional(),screenshots:j(Lw).max(4).refine(e=>new Set(e).size===e.length,`Duplicate screenshots`).optional(),desktop:N({script:ww,style:ww.optional()}).optional(),backend:N({script:ww.refine(Iw)}).optional(),slots:Hw.default(()=>[]),settingsSchema:j(Kw).max(32).refine(e=>new Set(e.map(({key:e})=>e)).size===e.length,`Duplicate setting keys`).optional(),categories:Vw.optional()}).strict().refine(e=>e.desktop!==void 0||e.backend!==void 0,`Expected at least one desktop or backend entry`),Jw=O().regex(/^[a-f0-9]{64}$/u),Yw=N({state:P([`running`,`disabled`,`invalid`,`incompatible`,`conflict`,`failed`,`waiting`]),hash:Jw.optional(),error:O().optional(),conflictWith:jw.optional()});N({controllerPid:zl().positive(),targetId:O().nullable(),updatedAt:Nu(),handledReloadToken:yl().optional(),extensions:iu(O(),Yw),surfaces:iu(O(),Yw).optional()});let Xw=P([`official`,`community`]);function Zw(e){return e.origin===`https://api.github.com`&&/^\/repos\/[\w-]+\/[\w.-]+\/zipball(?:\/[^/]+)?\/?$/u.test(e.pathname)}let Qw=Rw.refine(e=>{let t=new URL(e);return/\.zip$/iu.test(t.pathname)||Zw(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`),$w=N({id:jw,version:O().trim().min(1).max(128),name:Bw.extend({en:Pw,"zh-CN":Pw}),description:zw(O().trim().min(1).max(4096)),details:zw(O().trim().min(1).max(16384)).optional(),author:O().trim().min(1).max(128),repository:Rw,stars:k().int().min(0).optional(),downloads:k().int().min(0).optional(),categories:Vw.optional(),trustTier:Xw.default(`community`),icon:Rw.optional(),screenshots:j(Rw).max(4).optional(),downloadUrl:Qw,sha256:Jw,slots:Hw.optional(),publishedAt:O().optional(),updatedAt:O().optional(),minCodexHostVersion:O().optional()});N({schemaVersion:F(1),generatedAt:O(),extensions:j($w).refine(e=>new Set(e.map(({id:e})=>e)).size===e.length,`Duplicate extension IDs`)});let eT=O().trim().min(1).max(128),tT=/^(?:con|prn|aux|nul|com[1-9¹²³]|lpt[1-9¹²³]) *(?:\.|$)/iu,nT=jw.refine(e=>!tT.test(e),`Reserved extension ID`),rT=P([`desktop`,`web`]),iT=Jw,aT=yl(),oT=ww.refine(e=>!/[\x00-\x1f\x7f<>"|*]/u.test(e)&&e.split(`/`).every(e=>!/[. ]$/u.test(e)&&!tT.test(e)),`Expected a portable relative resource path`).refine(e=>e.split(`/`).length<=32,`Extension resources may be at most 32 segments deep`),sT=qw.shape,cT=(e,t=0)=>N({en:O().trim().min(t).max(e),"zh-CN":O().trim().min(t).max(e)}),lT=e=>oT.refine(t=>t.endsWith(e),`Expected a ${e} file`),uT=lT(`.mjs`),dT=lT(`.css`).optional(),fT=e=>e.normalize(`NFC`).toLowerCase(),pT=N({manifestVersion:F(2),id:nT,name:cT(128,1),version:O().trim().min(1).max(128),description:cT(4096),details:cT(16384).optional(),author:sT.author,repository:sT.repository,icon:sT.icon.refine(e=>e===void 0||oT.safeParse(e).success),screenshots:sT.screenshots.refine(e=>e===void 0||e.every(e=>oT.safeParse(e).success)),categories:sT.categories,settingsSchema:sT.settingsSchema,slots:sT.slots.removeDefault().optional(),page:N({apiVersion:F(1),entry:uT,style:dT,title:cT(128,1).optional()}).optional(),widget:N({apiVersion:F(1),entry:uT,style:dT}).optional(),desktop:N({apiVersion:F(1),script:lT(`.js`),style:dT}).optional(),web:N({apiVersion:F(1),entry:uT.optional(),style:dT}).refine(({entry:e,style:t})=>e!==void 0||t!==void 0,`Expected a Web entry or style`).optional(),backend:N({apiVersion:F(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||fT(e)!==fT(r.entry)),{path:[`backend`,`entry`],message:`A backend entry cannot also be a frontend entry`});function mT({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 hT=eT,gT=zl().nonnegative(),_T=N({revision:gT,enabled:j(nT).max(64).refine(e=>new Set(e).size===e.length,`Duplicate extension IDs`)}),{downloadUrl:vT,...yT}=$w.shape,bT=M({...yT,id:nT,format:F(`codexhost`),targets:j(rT).min(1).max(2).refine(e=>new Set(e).size===e.length,`Duplicate targets`),apis:N({page:zl().positive().optional(),widget:zl().positive().optional(),desktop:zl().positive().optional(),web:zl().positive().optional(),backend:zl().positive().optional()}),downloadUrl:vT.refine(e=>e.startsWith(`https://`),`Expected HTTPS`)}).refine(({targets:e,apis:t})=>{let n=mT({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`);M({schemaVersion:F(2),generatedAt:O().min(1),extensions:j(bT).max(1e4).refine(e=>new Set(e.map(({id:e})=>e)).size===e.length,`Duplicate extension IDs`)}).extend({catalogUrl:Rw,fetchedAt:Nu(),cached:A()});let xT={id:nT},ST={...xT,activationId:aT,digest:iT},CT={...xT,activationId:ST.activationId.optional()},wT=O().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`),TT=O().min(1).max(256).refine(e=>e.split(`/`).every(e=>e&&/^[a-z0-9_.-]+$/iu.test(e)&&e!==`.`&&e!==`..`),`Invalid GitHub ref`);function ET(e){return O().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 DT=N({type:F(`github`),repository:O().max(150).regex(/^[a-z0-9-]+\/[a-z0-9_-][a-z0-9_.-]*$/iu),ref:TT.optional(),tag:TT.optional(),asset:O().max(255).regex(/^[a-z0-9_.-]+\.zip$/iu).optional(),subpath:oT.optional()}).refine(({ref:e,tag:t,asset:n})=>!e||!t&&!n,`Use either a zipball ref or a release tag/asset`),OT=Xl([N({type:F(`catalog`),...xT}),DT,N({type:F(`zip`),base64:ET(67108864).min(4)}),N({type:F(`zip`),localZipPath:wT}),N({type:F(`localDir`),localDir:wT})]),kT=Ql(`type`,[N({type:F(`catalog`),...xT}),DT,N({type:F(`zip`)}),N({type:F(`localDir`)})]),AT=N({...ST,manifest:pT,installedAt:Nu(),source:kT.optional()}),jT=e=>O().max(23+4*Math.ceil(e/3)).regex(/^data:image\/(?:png|jpeg|webp);base64,[A-Za-z0-9+/]+={0,2}$/u),MT={desktopConflictWith:nT.optional()},NT=P([`none`,`inactive`,`starting`,`running`,`failed`]),PT=Ql(`state`,[AT.extend({state:F(`valid`),enabled:A(),...MT,iconDataUrl:jT(131072).optional(),screenshotDataUrls:j(jT(524288)).max(4).optional(),backendState:NT.optional(),backendError:O().optional()}),N({state:P([`invalid`,`incompatible`]),id:O().min(1),enabled:A(),error:O()})]);N({revision:gT,configuration:_T,diagnostics:j(O()),extensions:j(PT)}),N({revision:gT,extensions:j(AT.extend({...MT,settingsRevision:gT})).max(64)});let FT={list:`codexhost/extensions/list`,snapshot:`codexhost/extensions/snapshot`,catalog:`codexhost/extensions/catalog`,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`},IT=Object.freeze(Object.values(FT));new Set(IT),N({});let LT={expectedRevision:gT};N({...xT,...LT}),AT.extend({replaced:A()}),Ql(`state`,[N({state:F(`saved`),configuration:_T}),N({state:F(`revision-conflict`),revision:gT})]),N({...CT,digest:ST.digest.optional(),path:oT}),N({mimeType:O().min(1),base64:ET(16777216),digest:ST.digest}),N({settingsRevision:gT,values:OC}),FT.list,FT.snapshot,FT.catalog,N({forceRefresh:A().optional()}),FT.install,N({source:OT}),FT.update,N({...xT,expectedDigest:ST.digest,expectedActivationId:ST.activationId.optional(),source:OT.optional()}),FT.enable,FT.disable,FT.uninstall,N({...xT,removeData:A().optional(),expectedDigest:ST.digest.optional()}),N({...xT,removed:A()}),FT.recover,N({expectedRevision:LT.expectedRevision.optional()}),FT.asset,FT.settingsGet,N(CT),FT.settingsSet,N({...CT,expectedSettingsRevision:gT,values:OC}),FT.backendInvoke,N({...CT,method:hT,params:DC.optional()}),N({result:DC}),M({threadId:IC}).strict(),M({confirmed:A()}).strict(),[...IT],M({sections:j(M({id:O().min(1),name:O().min(1),threads:j(OC)}).strict())}).strict(),M({threadId:O().min(1).max(1024),sectionId:O().min(1).max(1024).nullable()}).strict(),M({threadIds:j(O().min(1))}).strict(),M({threadId:O().min(1).max(1024),pinned:A()}).strict(),M({}).strict(),M({parents:iu(O().min(1),O().min(1))}).strict(),M({prompt:O().max(16384).optional()}).strict(),M({projects:j(M({id:O(),name:O(),rootPaths:j(O()),createdAt:k().int().optional()})),nativeProjects:F(!0).optional(),assignments:iu(O(),O()),projectless:j(O()),pinned:j(O()),sectionProjects:iu(O(),j(O())).optional()});let RT=iu(O(),Wl()),zT=M({epoch:O().uuid(),sequence:k().int().nonnegative()});Ql(`type`,[M({type:F(`projects-changed`),cursor:zT}),M({type:F(`skills-changed`),cursor:zT,cwd:O().optional()}),M({type:F(`harness-inspection-changed`),cursor:zT,harnessId:O().min(1)}),M({type:F(`display-settings-changed`),cursor:zT}),M({type:F(`preferences-changed`),cursor:zT,revision:k().int().nonnegative()}),M({type:F(`extensions-changed`),cursor:zT,revision:gT}),M({type:F(`hello`),version:F(1),cursor:zT,reset:A()}),M({type:F(`changed`),cursor:zT,threadId:O().min(1),method:O().min(1)})]);let BT=Ql(`type`,[M({type:F(`text`),id:O(),prompt:O(),secret:A().optional(),optional:A().optional()}),M({type:F(`choice`),id:O(),prompt:O(),multiple:A(),allowOther:A(),optional:A().optional(),options:j(M({value:O(),label:O(),description:O().optional()}))})]),VT=Ql(`type`,[M({type:F(`approval`),title:O(),description:O().optional(),subject:Wl().optional(),actions:j(M({id:O(),label:O(),effect:O()}))}),M({type:F(`question`),title:O().optional(),questions:j(BT)})]),HT=M({requestId:Xl([O(),k().int()]),threadId:O(),kind:P([`approval`,`question`]),interaction:VT,request:RT}),UT=M({id:O().min(1),clientUserMessageId:O().min(1),input:j(RT),presentationInput:j(RT).nullable().optional()}).passthrough();M({fields:j(M({path:j(Xl([O(),k().int().nonnegative()])),originalLength:k().int().nonnegative()}))});let WT=M({id:O().min(1),status:O().min(1),codexhostTurnOutcome:M({status:F(`unknown`),reason:O()}).optional(),items:j(M({id:O().min(1),type:O().min(1)}).passthrough()),codexhostFileOperations:j(M({beforeItemId:O().nullable(),item:M({id:O().min(1),type:O().min(1)}).passthrough()})).optional(),error:M({message:O().optional()}).passthrough().nullable().optional(),fingerprint:O().min(1).optional(),unchanged:F(!0).optional()}).passthrough(),GT=M({id:O().min(1).max(512),fingerprint:O().min(1).max(128)});M({threadId:O().min(1),knownTurns:j(GT).max(64).optional(),truncateToolOutput:A().optional()});let KT=M({harnessId:O().min(1),nativeSessionId:O().min(1)});M({cursor:zT,activeTurnId:O().min(1).nullable().optional(),command:M({name:O().min(1),turn:WT,subsequentTurnId:O().min(1).optional()}).optional(),thread:M({id:O().min(1),cwd:O(),modelProvider:O().min(1),createdAt:k(),updatedAt:k(),status:M({type:O()}).passthrough(),name:O().nullable().optional(),preview:O().optional(),codexhostImportSource:KT.optional(),turns:j(WT).length(0)}).passthrough(),turnsPage:M({data:j(WT).max(5),nextCursor:O().nullable()}),configuration:M({native:M({model:O().min(1).max(1024).optional(),reasoningEffort:O().min(1).max(128).optional()}).optional(),effectiveModel:ow.optional(),effectiveThinkingOptionId:cw.optional(),effectivePermissionModeId:zC.optional()}),queue:M({items:j(UT),pausedReason:P([`interrupted`,`outcome-unknown`,`failed`]).nullable()}).optional(),interactions:j(HT),handoff:HC.optional()}),M({version:F(1),owner:F(`service`).optional(),pid:k().int().positive(),port:k().int().min(1).max(65535),token:O().regex(/^[0-9a-f]{64}$/u),startedAt:k(),epoch:O().uuid(),capabilities:M({peerDelegation:F(1).optional()}).optional()}),M({epoch:O().uuid(),threadId:O().min(1),requestId:Xl([O(),k().int()]),result:RT}),M({includeArchived:A().optional(),officialCursor:M({live:O().nullable(),archived:O().nullable().optional()}).strict().optional(),scope:Xl([M({cwd:O().min(1).max(4096),excludeCwds:j(O().min(1).max(4096)).max(1024)}).strict(),M({projectId:O().min(1).max(1024),legacyThreadIds:j(O().min(1).max(1024)).max(1024),rootPaths:j(O().min(1).max(4096)).max(1024).optional()}).strict()]).optional()}).strict(),M({threads:j(OC),ownership:j(bw),archivedThreadIds:j(IC),officialCursor:M({live:O().nullable(),archived:O().nullable().optional()}).strict().optional()}).strict();let qT=P([`running`,`waiting`,`idle`,`unknown`]),JT=N({harnessId:FC,title:O().optional(),status:qT,archived:A()}),YT=N({revision:zl().nonnegative(),parents:iu(IC,IC),nodes:iu(IC,JT),truncated:A()}).refine(e=>Object.keys(e.nodes).length<=5e3,`Too many Thread tree nodes`).refine(({parents:e,nodes:t})=>Object.entries(e).every(([e,n])=>Object.hasOwn(t,e)&&Object.hasOwn(t,n)),`Missing Thread tree node`),XT=O().min(1).max(128);N({});let ZT=N({subscriptionId:XT});N({}),ZT.extend({snapshot:YT});let QT=O().regex(/^audio\/[a-z0-9.+-]+(?:\s*;[^\r\n]*)?$/i);M({available:A()}).strict(),M({path:O().min(1),mimeType:QT}).strict();let $T=P([`credentials-unavailable`,`login-expired`,`rate-limited`,`service-rejected`,`host-incompatible`,`network`,`timeout`,`audio-empty`,`audio-too-large`,`audio-format`,`audio-invalid`]);Ql(`ok`,[M({ok:F(!0),text:O()}).strict(),M({ok:F(!1),error:M({code:$T}).strict()}).strict()]),M({threadId:IC.optional(),cwd:O().min(1).optional()}).strict().refine(e=>!(e.threadId&&e.cwd),{message:`Specify threadId or cwd, not both`});let eE=M({name:O().min(1).regex(/^[^\s[\]]+$/u),description:O().optional(),path:O().min(1),scope:P([`project`,`global`]),source:O().min(1)}).strict();M({revision:k().int().nonnegative(),complete:A(),skills:j(eE),warnings:j(O()).optional()}).strict(),M({cwd:O().min(1).optional()}).strict();let tE=/\[\$([^\]\r\n]+)\]\((?:<([^<>\r\n]+)>|([^\s()]+))(?:[ \t]+(?:"[^"\r\n]*"|'[^'\r\n]*'))?\)/gu;function nE(e){return[...e.matchAll(tE)].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 rE=M({kind:P([`public`,`relay`,`tailscale-funnel`,`tailscale-https`,`tailscale`,`lan`,`virtual`]),url:O().min(1)}).strict(),iE=Ql(`status`,[M({status:F(`not-installed`)}),M({status:F(`not-running`)}),M({status:F(`not-logged-in`)}),M({status:F(`https-disabled`)}),M({status:F(`not-serving`),command:O()}),M({status:F(`occupied`),target:O()}),M({status:F(`serving`),url:O(),funnel:A()}),M({status:F(`error`),message:O()})]);M({state:iE,error:O().optional()}).strict();let aE=Ql(`status`,[M({status:F(`on`)}),M({status:F(`off`)}),M({status:F(`invalid`),reason:O()})]),oE=M({lan:A(),autostart:aE}).strict(),sE=M({expiresAt:O().optional(),issuing:A(),failure:M({detail:O().optional(),retryAt:O(),paused:A()}).optional()}),cE=Ql(`status`,[M({status:F(`off`),reason:P([`invite`,`name-taken`,`banned`]).optional()}),M({status:F(`connecting`),reason:P([`full`,`unreachable`]).optional()}),M({status:F(`connected`),url:O(),certificate:sE}),M({status:F(`missing-certificate`),url:O(),certificate:sE}),M({status:F(`stopped`),reason:P([`replaced`,`rejected`,`unsupported-version`])})]);O().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()),O().regex(/^(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)?$/);let lE=P([`official`,`self-hosted`]);M({secret:O().min(1),lastUsedAt:k().nullable(),networkUrls:j(rE),directCandidates:j(rE).optional(),tailscale:iE,background:oE.optional(),relay:M({state:cE,enabled:A(),kind:lE,officialHost:O(),customHost:O().optional(),officialHostname:O().optional(),customHostname:O().optional(),quotaUntil:O().optional()}).strict().optional()}).strict();let uE=N({threadId:O().min(1).max(1024),view:P([`result`,`messages`]),from:k().int().min(1).max(2**53-1).optional(),to:k().int().min(1).max(2**53-1).optional()}),dE=/^[a-zA-Z0-9_-]{1,64}$/u,fE=O().regex(dE),pE=O().regex(dE),mE=O().regex(/^remote-peer:[a-zA-Z0-9_-]{1,64}$/u),hE=P([`relay`,`tailscale`,`lan`,`custom`]),gE=[`blue`,`purple`,`cyan`,`green`,`amber`,`rose`,`slate`],_E=P(gE);new Set(gE);let vE=P([`connected`,`connecting`,`auth-error`,`offline`,`disabled`]);M({peers:j(M({peerId:fE,hostId:mE,nodeId:pE.optional(),name:O().min(1).max(120),color:_E.optional(),origin:O().min(1).max(2048),transportKind:hE,encrypted:A(),enabled:A(),state:vE,supportsPeerPairing:A().optional(),pairedBack:A().optional(),linkedPeerIds:j(fE).max(128).optional(),latencyMs:k().int().nonnegative().optional(),version:O().max(128).optional(),platform:O().max(64).optional(),hostname:O().max(255).optional(),homeDir:O().max(4096).optional(),lastError:O().max(1e3).optional(),projectCount:k().int().nonnegative(),createdAt:O(),updatedAt:O()}))}),M({connectionUrl:O().min(1).max(4096).optional(),origin:O().min(1).max(2048).optional(),token:O().min(1).max(2048).optional(),name:O().trim().min(1).max(120).optional(),color:_E.optional(),pairBack:A().optional(),meshPeerIds:j(fE).max(64).optional(),selfOrigin:O().min(1).max(2048).optional()}).refine(e=>!!e.connectionUrl||!!e.origin&&!!e.token,`Provide either connectionUrl or both origin and token`),N({origin:O().min(1).max(2048),token:O().min(1).max(2048),name:O().trim().min(1).max(120).optional(),color:_E.optional(),expectedNodeId:pE.optional()}),M({status:P([`added`,`updated`,`existing`]),peerId:fE,hostId:mE,nodeId:pE.optional()});let yE=P([`added`,`updated`,`existing`,`failed`,`skipped`]);M({results:j(M({targetPeerId:fE,targetName:O().min(1).max(120),introducedHost:Xl([F(`local`),fE]),introducedName:O().min(1).max(120),status:yE,error:O().max(1e3).optional()}))}),M({peerIds:j(fE).max(64).optional(),includeSelf:A().optional(),includeMesh:A().optional(),selfOrigin:O().min(1).max(2048).optional()}),M({peerId:fE,name:O().trim().min(1).max(120).optional(),color:_E.nullable().optional(),connectionUrl:O().min(1).max(4096).optional(),origin:O().min(1).max(2048).optional(),token:O().min(1).max(2048).optional(),enabled:A().optional()}),M({peerId:fE}),M({removed:A()}),M({peerId:fE.optional(),connectionUrl:O().min(1).max(4096).optional(),origin:O().min(1).max(2048).optional(),token:O().min(1).max(2048).optional()}).refine(e=>!!e.peerId||!!e.connectionUrl||!!e.origin&&!!e.token,`Provide peerId, connectionUrl, or both origin and token`);let bE=M({id:O().min(1).max(1024),name:O().min(1).max(512),path:O().min(1).max(8192)});M({ok:A(),nodeId:pE.optional(),supportsPeerPairing:A().optional(),pairedBack:A().optional(),latencyMs:k().int().nonnegative().optional(),origin:O().max(2048).optional(),transportKind:hE.optional(),encrypted:A().optional(),version:O().max(128).optional(),platform:O().max(64).optional(),hostname:O().max(255).optional(),homeDir:O().max(4096).optional(),projectCount:k().int().nonnegative().optional(),projects:j(bE).optional(),error:O().max(1e3).optional()});let xE=M({id:O().min(1).max(1024),name:O().min(1).max(512),path:O().min(1).max(8192),threadIds:j(O().min(1).max(1024))}),SE=M({attachments:F(1).optional(),workspaceFiles:F(1).optional(),officePreview:F(1).optional(),delegation:F(1).optional(),peerPairing:F(1).optional()}),CE=M({version:O().max(128),platform:O().max(64),hostname:O().max(255),homeDir:O().max(4096).optional(),epoch:O().min(1).max(256),nodeId:pE.optional(),peerNodes:iu(mE,pE).refine(e=>Object.keys(e).length<=128).optional(),projects:j(xE),capabilities:SE.optional()});N({threadId:O().min(1).max(1024),scope:O().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:O().min(1).max(256).optional(),mode:P([`queue`,`steer`]).optional(),expectedTurnId:O().min(1).max(1024).nullable().optional(),content:j(Ql(`type`,[N({type:F(`text`),text:O()}),N({type:F(`file`),receiptId:O().min(1).max(128)})])).min(1).max(64)});let wE=M({ok:F(!1),error:M({code:O(),message:O(),details:iu(O(),Wl()).optional()})});Xl([M({ok:F(!0),value:M({receiptId:O().min(1),file:M({attachmentId:O(),name:O(),bytes:k().int().nonnegative()})})}),wE]),Xl([M({ok:F(!0),value:M({accepted:F(!0)})}),wE]);let TE=M({name:O().min(1).max(512),path:O().min(1).max(8192),kind:F(`directory`)});M({peerId:fE,path:O().min(1).max(8192).optional()}),M({path:O().min(1).max(8192),parentPath:O().min(1).max(8192).nullable(),homeDir:O().min(1).max(8192).optional(),entries:j(TE)}),M({peerId:fE,parentPath:O().min(1).max(8192),name:O().min(1).max(255).refine(e=>e.trim().length>0,`Directory name cannot be blank`)}),M({path:O().min(1).max(8192),name:O().min(1).max(255)}),M({peerId:fE,path:O().min(1).max(8192),title:O().trim().min(1).max(255).optional()}),M({peerId:fE,workspaceId:O().min(1).max(1024),title:O().trim().min(1).max(255)}),M({peerId:fE,workspaceId:O().min(1).max(1024)}),M({workspaceId:O().min(1).max(1024).optional(),manifest:CE}),M({sessionHostId:O().min(1).max(128).optional()}),M({hosts:j(M({hostId:Xl([F(`local`),mE]),name:O().min(1).max(120),isLocal:A().optional(),color:_E.optional(),hostname:O().max(255).optional()}))}),M({hostId:Xl([F(`local`),mE])}),M({harnesses:j(M({id:O().regex(/^[a-z0-9][a-z0-9-]*$/u),name:O().min(1).max(120)}))});let EE=P([`listHarnesses`,`inspect`,`start`,`send`,`cancel`,`read`,`answer`,`list`]);N({operation:EE,hopCount:k().int().min(0).max(16),sourceId:fE.optional(),input:OC});let DE=N({code:O().min(1).max(128),message:O().max(4096),details:OC.optional()});Xl([N({ok:F(!0),value:DC}),N({ok:F(!1),error:DE})]);let OE=N({id:O().min(1).max(1024),name:O().min(1).max(512),path:O().min(1).max(8192)});N({hosts:j(N({hostId:mE,nodeId:pE.optional(),displayName:O().min(1).max(120),online:A(),state:vE,delegation:A(),projects:j(OE),platform:O().max(64).optional(),hostname:O().max(255).optional(),homeDir:O().max(4096).optional()}))}),N({version:F(1),instanceId:O().min(1).max(128),pid:k().int().positive(),endpoint:O().min(1).max(256),token:O().regex(/^[0-9a-f]{64}$/u),startedAt:k().int().nonnegative()}),Xl([N({operation:F(`hosts`)}),N({operation:EE,hostId:mE,hopCount:k().int().min(0).max(16),timeoutMs:k().int().min(1).max(12e4).optional(),input:OC})]);let kE=M({id:O().min(1).max(256),harnessId:O().min(1),label:O().min(1).max(512),provider:P([`openai-codex`,`xai`])}).strict(),AE=O().regex(/^[a-z][a-z0-9-]{0,47}$/),jE=M({name:AE,source:kE,importedAt:O()}).strict(),ME=Ql(`action`,[M({action:F(`list`)}).strict(),M({action:F(`import`),sourceId:O().min(1).max(256),name:AE,confirmed:F(!0)}).strict(),M({action:F(`reimport`),sourceId:O().min(1).max(256),name:AE,confirmed:F(!0)}).strict(),M({action:F(`remove`),name:AE,confirmed:F(!0)}).strict()]),NE=M({provider:O().min(1).max(128),type:P([`oauth`,`api_key`,`unknown`]),label:O().min(1).max(512).optional(),vendor:P([`openai-codex`,`xai`]).optional()}).strict();M({sources:j(kE),targets:j(M({harnessId:O(),providers:j(P([`openai-codex`,`xai`])),imports:j(jE),others:j(NE).default([])}).strict())}).strict(),M({targetHarnessId:O().min(1).max(128).optional(),request:ME}).strict(),M({events:A()});let PE=j(N({agent:O().min(1).max(128),section:P([`main`,`more`,`auto`])})).max(256).refine(e=>new Set(e.map(e=>e.agent)).size===e.length,`Duplicate Harness IDs`);N({entries:PE.nullable()}),N({}),N({entries:PE,initializeOnly:A().optional()});let FE=N({enabled:A(),timeoutMinutes:k().int().min(5).max(1440)});Object.freeze({enabled:!0,timeoutMinutes:10});let IE=O().regex(/^external$/u),LE=FC.transform(e=>String(e)),RE=N({model:ow.optional(),thinkingOptionId:cw.optional(),permissionModeId:zC.optional()}).refine(e=>!!(e.model||e.thinkingOptionId||e.permissionModeId),`A default configuration must contain a preference`),zE=N({lastHarness:FC.optional(),byHarness:iu(LE,RE)}),BE=N({model:ow.optional(),thinkingOptionId:cw.optional()}).refine(e=>!!(e.model||e.thinkingOptionId),`A delegation default must contain a Model or Thinking option`),VE=N({byHarness:iu(LE,BE)}),HE=O().min(1).max(1024),UE=N({idleRelease:FE.optional(),favorites:iu(LE,j(HE).max(2048)).default({}),newThread:zE.optional(),delegation:VE.optional()});N({scope:IE,revision:k().int().nonnegative(),values:UE}),N({scope:IE.default(`external`)});let WE=Ql(`kind`,[N({kind:F(`idleRelease`),value:FE}),N({kind:F(`favorite`),harnessId:FC,modelId:HE,enabled:A()}),N({kind:F(`favorites`),harnessId:FC,modelIds:j(HE).max(2048)}),N({kind:F(`newThread`),lastHarness:FC.optional(),harnessId:FC.optional(),configuration:RE.optional()}),N({kind:F(`delegation`),harnessId:FC,configuration:BE.nullable()})]);N({scope:IE.default(`external`),operations:j(WE).min(1).max(256),initializeOnly:A().optional(),expectedRevision:k().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`})}),N({version:F(1),revision:k().int().nonnegative(),scopes:iu(IE,UE)});let GE=k().finite().nonnegative(),KE=N({input:GE,output:GE,cacheRead:GE.optional(),cacheWrite:GE.optional(),cacheWrite1h:GE.optional()}),qE=O().max(512).refine(e=>e.trim()===e&&e.length>0,`Model ID is required`);N({path:O(),entries:j(N({key:O(),price:KE})),error:O().nullable()}),N({}),N({key:qE,price:KE.nullable(),previousKey:qE.optional()}),N({model:qE});let JE=N({official:A().optional(),canonicalModelId:O().min(1).optional(),provider:O().min(1).max(512),model:O().min(1).max(512),price:KE});N({price:KE.nullable(),suggestions:j(JE).max(6).optional()});let YE=[`today`,`7d`,`30d`,`90d`,`all`],XE=k().int().min(0).max(2**53-1),ZE=O().regex(/^\d{4}-\d{2}-\d{2}$/u),QE=O().min(1).max(128),$E=O().min(1).max(512),eD=O().min(1).max(4096);N({range:P(YE),timeZone:O().min(1).max(128).refine(e=>{try{return new Intl.DateTimeFormat(`en`,{timeZone:e}),!0}catch{return!1}},`Unsupported usage statistics timezone`).optional(),harness:QE.optional(),model:$E.nullable().optional(),project:eD.nullable().optional(),date:ZE.optional()});let tD=N({requests:XE,inputTokens:XE,cachedInputTokens:XE,cacheWriteInputTokens:XE,cacheKnownInputTokens:XE,cacheHitCachedInputTokens:XE,cacheHitInputTokens:XE,outputTokens:XE,reasoningOutputTokens:XE,costUsd:k().finite().min(0),unpricedRequests:XE,unmeteredRequests:XE}),nD=tD.shape,rD=N({harness:QE,sessionId:O().min(1).max(512),project:eD.nullable(),title:O().min(1).max(200).optional(),models:j($E).max(16),firstAtMs:XE,lastAtMs:XE,...nD});N({range:P(YE),from:ZE.nullable(),to:ZE,filters:N({harness:QE.nullable(),model:$E.nullable(),unknownModel:A(),project:eD.nullable(),unknownProject:A(),date:ZE.nullable()}),reading:N({complete:A(),sources:XE,read:XE}),failures:j(N({harness:QE,message:O().max(2048)})).max(256),options:N({harnesses:j(QE).max(256),models:j($E.nullable()).max(4096),projects:j(eD.nullable()).max(4096)}),modelLabels:j(N({harness:QE,model:$E,label:$E})).max(4096).optional(),credits:j(N({harness:QE,model:$E.nullable(),credits:k().finite().min(0),reportedRequests:XE,requests:XE})).max(4096).optional(),totals:tD,daily:j(N({date:ZE,harness:QE,...nD})).max(2e5),hourly:j(N({weekday:k().int().min(0).max(6),hour:k().int().min(0).max(23),...nD})).max(168),byHarness:j(N({harness:QE,...nD})).max(256),byModel:j(N({model:$E.nullable(),...nD,harnessPricedRequests:XE})).max(4096),byProject:j(N({project:eD.nullable(),...nD})).max(4096),sessions:j(rD).max(100),recentSessions:j(rD).max(100).optional()}),M({threadId:IC}),M({discarded:A()});let iD=Ql(`type`,[M({id:O().min(1),type:F(`choice`),prompt:O(),options:j(M({value:O().min(1),label:O(),description:O().optional()})).min(1),multiple:A(),allowOther:A(),optional:A()}),M({id:O().min(1),type:F(`text`),prompt:O(),multiline:A(),secret:F(!1),optional:A(),placeholder:O().optional(),prefill:O().optional()})]),aD=M({interactionId:O().min(1),turnId:O().min(1),title:O().optional(),questions:j(iD).min(1)}).refine(({questions:e})=>e.some(e=>e.type===`choice`&&e.multiple),{message:`Shared cards require at least one multi-select question`});N({threadId:O().min(1)}),M({questions:j(aD)}),N({threadId:O().min(1),turnId:O().min(1),interactionId:O().min(1),answers:iu(O(),j(O())),cancelled:A().default(!1)}),M({accepted:F(!0)});let oD=M({path:O(),oldText:O().nullable(),newText:O()});M({sessionId:O().min(1),turn:k().int().nonnegative(),path:O().min(1).optional()}),M({diffs:j(oD)}),N({}),N({}),M({reference:M({sessionId:O().min(1),epoch:O().min(1),turn:k().int().nonnegative(),seq:k().int().nonnegative(),callId:O().min(1),part:k().int().nonnegative(),version:O().min(1)}),length:k().int().nonnegative(),bytes:k().int().nonnegative()}),N({title:O().trim().min(1).max(200),type:P([`info`,`warning`,`danger`]),body:O().trim().min(1).max(16384)}),N({}),N({url:O().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`.split(`.`));let sD=P([`idle`,`running`,`busy`,`closing`,`failed`,`blocked`]),cD=P([`none`,`disabled`,`timeout`,`operation`,`background`,`identity`,`persistence`,`closeFailed`]);N({threadId:O(),title:O(),harnessId:O(),state:sD,reason:cD,inactiveMs:k().nonnegative()}),N({threadId:IC,turnId:LC});let lD=M({email:O().trim().min(1).max(320).optional(),label:O().trim().min(1).max(256).optional(),plan:O().trim().min(1).max(128).optional(),credits:tw.optional(),balance:nw.optional()}).strict();function uD(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 dD=uD(lD),fD={harnessId:FC,harnessName:O().trim().min(1).max(128)},pD=M(fD).strict();M({}).strict(),M({sources:j(pD).max(128)}).strict(),M({harnessId:FC,refresh:A().optional()}).strict(),M({...fD,account:dD.nullable(),accounts:j(dD).max(8).optional()}).strict(),M({refresh:A().optional()}).strict(),M({accounts:j(uD(lD.extend(fD))).max(128)}).strict(),M({harnessId:Cw,model:ow.optional(),thinkingOptionId:cw.optional(),permissionModeId:zC.optional(),prewarm:F(!0).optional()}).strict();let mD=O().trim().min(1).max(4096).refine(e=>!/[\u0000\r\n]/u.test(e),`Invalid entrypoint path`);M({harnessId:Cw}).strict().extend({path:mD.nullable()}),M({path:mD.nullable(),restartRequired:A()}).strict(),M({harnessId:FC,action:P([`check`,`update`,`install`]),confirmedVersion:O().min(1).max(128).optional()}).strict().refine(({action:e,confirmedVersion:t})=>e===`update`||t===void 0);let hD=M({currentVersion:O().min(1).max(128),latestVersion:O().min(1).max(128),updateAvailable:A(),canUpdate:A(),latestVerifiedVersion:O().min(1).max(128).optional(),confirmationRequired:F(!0).optional(),versionKind:P([`cli`,`application`]).optional(),manualUpdateUrl:xl().max(2048).refine(e=>/^https:\/\/[^/?#@]+(?:[/?#]|$)/iu.test(e),`Manual updates require a credential-free HTTPS URL`).optional(),message:O().max(2048).optional(),messageCode:O().min(1).max(128).optional(),notice:NC.optional(),latestVersionKind:P([`unknown`,`tracking-branch`]).optional()}).strict();M({taskId:O().uuid()}).strict(),Ql(`status`,[M({taskId:O().uuid(),status:F(`running`)}).strict(),M({taskId:O().uuid(),status:F(`succeeded`),result:hD}).strict(),M({taskId:O().uuid(),status:F(`failed`),error:M({code:k().int(),message:O().min(1).max(2048)}).strict()}).strict()]);let gD=O().min(1).max(256).regex(/^[A-Za-z0-9._~-]+$/u),_D=O().trim().min(1),vD=P([`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`]),yD=M({accountId:gD,label:_D.max(256),email:O().email().max(320).optional(),planType:vD.optional()}).strict(),bD=P([`ready`,`unavailable`]);M({version:F(2),currentAccountId:gD.nullable(),phase:bD,revision:k().int().nonnegative(),instanceId:_D.max(1024).optional(),accounts:j(yD).max(1)}).strict(),M({accountId:gD,refresh:A().optional()}).strict(),M({accountId:gD,usage:YC.nullable(),accountCredits:tw.optional(),freshness:P([`live`,`cached`]),observedAt:O().datetime().nullable()}).strict();let xD=1e3,SD=O().refine(e=>e.trim().length>0,`Value must not be empty or whitespace`).refine(e=>!e.includes(`\0`),`Value must not contain NUL`),CD=SD.max(1024),wD=M({nativeSessionId:CD,title:SD.max(4096).nullable(),updatedAt:k().int().nonnegative().max(864e13),cwd:SD.max(16384),running:A().nullable()}).strict();M({}).strict(),M({harnesses:j(M({harnessId:Cw,name:SD.max(128)}).strict()).max(128)}).strict(),M({harnessId:Cw,query:O().trim().max(4096).refine(e=>!e.includes(`\0`)).optional(),offset:k().int().nonnegative().safe().optional(),limit:k().int().min(1).max(xD).optional()}).strict(),M({candidates:j(wD).max(xD),total:k().int().nonnegative().safe()}).strict(),M({harnessId:Cw,nativeSessionId:CD}).strict(),M({threadId:SD.max(1024).pipe(IC)}).strict();let TD=O().refine(e=>e.trim().length>0,`Value must not be empty or whitespace`).refine(e=>!e.includes(`\0`),`Value must not contain NUL`),ED=CD,DD=wD;M({}).strict(),M({candidates:j(DD).max(1e3)}).strict(),M({nativeSessionId:ED}).strict(),M({threadId:TD.max(1024).pipe(IC)}).strict(),M({threadId:IC,lastTurnId:LC}).strict(),M({threadId:IC}).strict();let OD=O().trim().min(1).max(128).regex(/^[A-Za-z0-9._:-]+$/u).brand();M({commands:j(M({id:OD,invocation:O().min(1).max(128),label:O().trim().min(1).max(128),description:O().trim().min(1).max(512).optional(),localizations:MC.optional(),argumentMode:P([`none`,`text`]),kind:P([`command`,`skill`]).optional()}).strict()),warnings:j(O().min(1)).optional(),source:P([`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)}),M({harnessId:FC,cwd:O().min(1).optional()}).strict(),M({threadId:IC}).strict(),M({threadId:IC,commandId:OD,turnId:LC.optional(),arguments:OC.optional()}).strict(),M({accepted:F(!0),turnId:LC.optional()}).strict();let kD=F(`2.0`).optional(),AD=Kl().optional(),jD=O().min(1),MD=Xl([O(),k().int()]),ND=M({code:k().int(),message:O(),data:DC.optional()}).catchall(DC).superRefine(SC([`data`]));Xl([M({jsonrpc:kD,id:MD,method:jD,params:DC.optional(),result:AD,error:AD}).catchall(DC).superRefine(SC([`jsonrpc`,`params`,`result`,`error`])),M({jsonrpc:kD,id:AD,method:jD,params:DC.optional(),result:AD,error:AD}).catchall(DC).superRefine(SC([`jsonrpc`,`id`,`params`,`result`,`error`])),M({jsonrpc:kD,id:MD,method:AD,params:AD,result:DC,error:AD}).catchall(DC).superRefine(SC([`jsonrpc`,`method`,`params`,`error`])),M({jsonrpc:kD,id:MD,method:AD,params:AD,result:AD,error:ND}).catchall(DC).superRefine(SC([`jsonrpc`,`method`,`params`,`result`]))]);let PD=O().refine(e=>e.trim().length>0,{message:`Native identifier must not be empty or whitespace`});N({harnessId:FC,nativeSessionId:PD,locator:DC.optional(),formatVersion:F(1)}).superRefine(SC([`locator`])),N({harnessId:FC,nativeSessionId:PD,nativeTurnKey:PD,formatVersion:F(1)}),N({harnessId:FC,nativeSessionId:PD,checkpointId:PD,locator:DC.optional(),formatVersion:F(1)}).superRefine(SC([`locator`]));let FD=O().regex(/^\d+\.\d+\.\d+(?:-[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?(?:\+[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/u),ID=P([`npm`,`windows-installer`,`macos-dmg`,`linux-archive`]),LD=P([`prepared`,`downloading`,`waiting-for-exit`,`installing`,`restarting`,`succeeded`,`failed`]),RD=N({completed:k().int().nonnegative(),total:k().int().positive()}).refine(e=>e.completed<=e.total,{path:[`completed`],message:`completed must not exceed total`}),zD=N({version:FD,installation:ID,phase:LD,updatedAt:k().int().nonnegative(),downloadedBytes:k().int().nonnegative().optional(),totalBytes:k().int().positive().optional(),npmDownload:RD.optional(),error:O().min(1).max(500).nullable(),serviceStopOutput:O().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`})});N({});let BD=O().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`);N({currentVersion:FD,installation:ID.nullable(),latestVersion:FD.nullable(),updateAvailable:A(),installationAvailable:A(),releaseNotes:O().min(1).max(2e4).nullable(),releaseNotesUrl:BD.nullable(),status:zD.nullable(),error:O().min(1).max(500).nullable()}),N({status:zD}),N({status:zD.nullable()});let VD=N({icon:O().min(1).max(16).optional(),title:O().min(1).max(120),body:O().min(1).max(1200),contributors:j(O().min(1).max(39)).max(30)}),HD=N({summary:O().min(1).max(600).optional(),themes:j(VD).min(1).max(12)}),UD=N({version:FD,publishedAt:Nu(),url:O().max(300).regex(/^https:\/\/github\.com\/BytePioneer-AI\/codex-host\/releases\/tag\/v[0-9A-Za-z.+-]+$/u),zh:HD.nullable(),en:HD.nullable()}).refine(e=>e.zh!==null||e.en!==null,{message:`an announcement needs at least one language`});N({manual:A().optional()}),N({announcement:UD.nullable(),unread:A()}),N({version:FD}),RegExp(String.raw`^- \[([^\]\n]+)\]\(thread://([^\s()<>"?#/]+)\): `+`(${[`completed`,`failed`,`interrupted`,`needsInput`,`timedOut`,`unreadable`,`notFound`].join(`|`)})(?:\. (.+))?$`,`u`);function WD(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<response-annotations>\n${JSON.stringify(t)}\n</response-annotations>\n`}function GD(e,t){let n=WD(e);return n===``?t:`${n}\n## My request:\n${t}\n`}let KD=P([`idle`,`installing`,`restarting`,`succeeded`,`failed`]);M({runningVersion:O().nullable(),installedVersion:O().nullable(),restartRequired:A(),remote:A(),updateSupported:A(),update:M({phase:KD,targetVersion:O().nullable(),error:O().nullable()})});let qD=M({version:O().regex(/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/u)}).strict();M({hostname:O().min(1).max(1024).refine(e=>!e.startsWith(`-`)&&!/\s/u.test(e)),port:k().int().min(1).max(65535).nullable(),identity:O().max(4096).nullable(),action:P([`inspect`,`install`,`update`,`repair`,`uninstall`]),uninstallPackage:A().optional(),version:O().regex(/^\d+\.\d+\.\d+$/u).nullable()}).strict(),M({state:P([`installed`,`not-installed`])}).strict();let X=O().min(1).max(1024),JD={hostId:X.regex(/^(?:remote-(?:ssh(?:-|:)|control:)|remote-peer:[a-zA-Z0-9_-]{1,64}$)/u)},YD={...JD,threadId:X},XD=O().min(1).max(8e3),ZD={text:XD,requestId:X};Ql(`accepted`,[M({accepted:F(!0),startQueuedItemId:X.optional()}),M({accepted:F(!1),code:P([`remote/queue-unavailable`,`remote/steer-unavailable`,`remote/turn-changed`,`remote/send-rejected`,`session/queue-item-not-found`,`session/queue-item-starting`]),message:O()})]),Ql(`available`,[M({available:F(!1)}),M({available:F(!0),items:j(M({id:X,clientUserMessageId:X,preview:O().max(801)})).max(100)})]);let QD=Ql(`kind`,[N({kind:F(`hosts`)}),N({kind:F(`create`),...JD,cwd:O().min(1).max(8192),epoch:X}),N({kind:F(`projectHarnesses`),...JD,epoch:X}),N({kind:F(`inspectHarness`),...JD,epoch:X,cwd:O().min(1).max(8192),harnessId:X}),N({kind:F(`startSelected`),...JD,epoch:X,cwd:O().min(1).max(8192),harnessId:X,model:O().min(1).max(4096),serviceTier:P([`priority`,`ultrafast`]).optional(),reasoningEffort:X.optional()}),N({kind:F(`status`),...YD}),N({kind:F(`list`),...JD,cursor:O().nullable(),archived:A(),includeLoaded:F(!0).optional()}),N({kind:F(`read`),...YD,page:N({cursor:O().min(1).max(8192).nullable(),epoch:X.optional(),sortDirection:P([`asc`,`desc`]).optional(),limit:k().int().min(1).max(20).optional()}).refine(e=>e.cursor===null||e.epoch!==void 0,{message:`A history continuation requires its connection epoch`}).optional()}),N({kind:F(`usage`),...YD,epoch:X}),N({kind:F(`configure`),...YD,epoch:X,modelId:X.optional(),serviceTier:aw.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`}),N({kind:F(`prompt`),...YD,epoch:X,text:XD,requestId:X.optional()}),N({kind:F(`queue`),...YD,epoch:X}),N({kind:F(`delivery`),...YD,epoch:X,action:Ql(`kind`,[N({kind:F(`enqueue`),...ZD}),N({kind:F(`steer`),...ZD,turnId:X}),N({kind:F(`remove`),itemId:X}),N({kind:F(`start`),itemId:X,onlyIfHead:F(!0).optional()}),N({kind:F(`sendNow`),itemId:X})])}),N({kind:F(`interrupt`),...YD,epoch:X,turnId:X}),N({kind:F(`rename`),...YD,epoch:X,name:O().min(1).max(512)}),N({kind:F(`archive`),...YD,epoch:X,archived:A()}),N({kind:F(`respond`),...YD,epoch:X,requestId:Xl([X,k().int()]),result:iu(O(),Wl())})]),$D=O().min(1).max(1024),eO=M({hostId:$D,displayName:O().min(1).max(1024),source:P([`codex-managed`,`discovered`]),sshAlias:O().max(1024).nullable(),sshHost:O().min(1).max(1024),sshPort:k().int().min(1).max(65535).nullable(),identity:O().max(4096).nullable(),autoConnect:A(),connectionAnalyticsId:O().max(1024).optional()}),tO=N({displayName:O().min(1).max(1024),hostname:O().min(1).max(1024),sshPort:k().int().min(1).max(65535).nullable(),identity:O().max(4096).nullable()});Ql(`action`,[N({action:F(`session`),operation:QD}),N({action:F(`list`)}),N({action:F(`catalog`)}),N({action:F(`read-thread`),hostId:$D.refine(e=>e!==`local`),input:uE}),N({action:F(`save`),draft:tO,previous:eO.nullable()}),N({action:F(`remove`),previous:eO}),N({action:F(`connect`),hostId:$D,enabled:A()}),N({action:F(`state`),hostId:$D}),N({action:F(`runtime`),hostId:$D}),N({action:F(`update`),hostId:$D.refine(e=>e!==`local`),version:qD.shape.version})]),Xl([N({result:DC}),N({error:N({code:k().int(),message:O()})})]),N({prompt:O().trim().min(1).max(2e3),cwd:O().max(4096).nullable()}),O().trim().min(1).max(60).nullable();let nO=O().max(214).regex(/^(?:@[a-z0-9][a-z0-9._-]*\/)?[a-z0-9][a-z0-9._-]*$/u),rO=Xl([O(),M({en:O()}).catchall(O())]),iO=M({title:rO.optional(),description:rO.optional(),icon:O().max(349592).regex(/^data:image\/(?:svg\+xml|png|jpeg|webp);base64,[A-Za-z0-9+/]*={0,2}$/u).optional(),error:O().optional()});M({extensions:j(M({id:nO,name:O().min(1).max(214),version:O().min(1).max(128),format:F(`dsh`),supportedTargets:nu([F(`web`)]),enabledTargets:j(F(`web`)).max(1),source:O().min(1).max(4096),projectUrl:O().max(4096).url({protocol:/^https?$/u}).optional(),installedAt:O(),meta:iO.optional(),loadError:O().optional()})),loadedIds:j(nO),safeMode:A(),storeError:O().optional()});let aO=O().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}/`);M({spec:O().trim().min(1).max(4096),registry:aO.optional()}).strict(),M({id:nO,enabled:A()}).strict(),M({id:nO}).strict(),F(1);function oO(e){return e.registerNodeTransform(eh,e=>{let t=nE(e.getTextContent())[0];t&&e.splitText(t.start,t.end)[t.start===0?0:1]?.replace(new oC({source:`codexhost-skill`,ref:t.text,label:t.name,appearance:`skill`,clipboardText:t.text}))})}let sO=`color: var(--dsw-alias-state-business-primary)`;function cO(){let e=U_().getFirstChild();if(!W(e))return null;let t=e.getFirstChild();return B(t)?t:null}function lO(e,t){return e.registerNodeTransform(eh,e=>{let n=cO();if(n===null||e.getKey()!==n.getKey()){e.getStyle()===sO&&e.setStyle(``);return}let r=e.getTextContent(),i=t(),a=r===i?.trimEnd()?r:i;if(a===null||!r.startsWith(a))e.getStyle()===sO&&e.setStyle(``);else if(r.length>a.length){let[t,n]=e.splitText(a.length);t!==void 0&&t.getStyle()!==sO&&t.setStyle(sO),n?.setStyle(``)}else e.getStyle()!==sO&&e.setStyle(sO)})}function uO(e){e.update(()=>{cO()?.markDirty()})}function dO(){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(cC(e))o(`chip`,e,``,e.getTextContent());else if(B(e)){let t=e.getTextContent();o(`text`,e,t,t)}else Zg(e)?o(`linebreak`,e,`
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`}),[...XT],j({sections:A(j({id:D().min(1),name:D().min(1),threads:A(FC)}).strict())}).strict(),j({threadId:D().min(1).max(1024),sectionId:D().min(1).max(1024).nullable()}).strict(),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 lE=du(D(),Zl()),uE=j({epoch:D().uuid(),sequence:O().int().nonnegative()});au(`type`,[j({type:P(`projects-changed`),cursor:uE}),j({type:P(`skills-changed`),cursor:uE,cwd:D().optional()}),j({type:P(`harness-inspection-changed`),cursor:uE,harnessId:D().min(1)}),j({type:P(`display-settings-changed`),cursor:uE}),j({type:P(`preferences-changed`),cursor:uE,revision:O().int().nonnegative()}),j({type:P(`extensions-changed`),cursor:uE,revision:kT}),j({type:P(`hello`),version:P(1),cursor:uE,reset:k()}),j({type:P(`changed`),cursor:uE,threadId:D().min(1),method:D().min(1)})]);let dE=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()}))})]),fE=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(dE)})]),pE=j({requestId:ru([D(),O().int()]),threadId:D(),kind:N([`approval`,`question`]),interaction:fE,request:lE}),mE=j({id:D().min(1),clientUserMessageId:D().min(1),input:A(lE),presentationInput:A(lE).nullable().optional()}).passthrough();j({fields:A(j({path:A(ru([D(),O().int().nonnegative()])),originalLength:O().int().nonnegative()}))});let hE=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(),gE=j({id:D().min(1).max(512),fingerprint:D().min(1).max(128)});j({threadId:D().min(1),knownTurns:A(gE).max(64).optional(),truncateToolOutput:k().optional()});let _E=j({harnessId:D().min(1),nativeSessionId:D().min(1)});j({cursor:uE,activeTurnId:D().min(1).nullable().optional(),command:j({name:D().min(1),turn:hE,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:_E.optional(),turns:A(hE).length(0)}).passthrough(),turnsPage:j({data:A(hE).max(5),nextCursor:D().nullable()}),configuration:j({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(mE),pausedReason:N([`interrupted`,`outcome-unknown`,`failed`]).nullable()}).optional(),interactions:A(pE),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()}).optional()}),j({epoch:D().uuid(),threadId:D().min(1),requestId:ru([D(),O().int()]),result:lE}),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 vE=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(vE).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 yE=D().regex(/^audio\/[a-z0-9.+-]+(?:\s*;[^\r\n]*)?$/i);j({available:k()}).strict(),j({path:D().min(1),mimeType:yE}).strict();let bE=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:bE}).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 xE=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(xE),warnings:A(D()).optional()}).strict(),j({cwd:D().min(1).optional()}).strict();let SE=/\[\$([^\]\r\n]+)\]\((?:<([^<>\r\n]+)>|([^\s()]+))(?:[ \t]+(?:"[^"\r\n]*"|'[^'\r\n]*'))?\)/gu;function CE(e){return[...e.matchAll(SE)].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 wE=j({kind:N([`public`,`relay`,`tailscale-funnel`,`tailscale-https`,`tailscale`,`lan`,`virtual`]),url:D().min(1)}).strict(),TE=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:TE,error:D().optional()}).strict();let EE=au(`status`,[j({status:P(`on`)}),j({status:P(`off`)}),j({status:P(`invalid`),reason:D()})]),DE=j({lan:k(),autostart:EE}).strict(),OE=j({expiresAt:D().optional(),issuing:k(),failure:j({detail:D().optional(),retryAt:D(),paused:k()}).optional()}),kE=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:OE}),j({status:P(`missing-certificate`),url:D(),certificate:OE}),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 AE=N([`official`,`self-hosted`]);j({secret:D().min(1),lastUsedAt:O().nullable(),networkUrls:A(wE),directCandidates:A(wE).optional(),tailscale:TE,background:DE.optional(),relay:j({state:kE,enabled:k(),kind:AE,officialHost:D(),customHost:D().optional(),officialHostname:D().optional(),customHostname:D().optional(),quotaUntil:D().optional()}).strict().optional()}).strict();let jE=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()}),ME=/^[a-zA-Z0-9_-]{1,64}$/u,NE=D().regex(ME),PE=D().regex(ME),FE=D().regex(/^remote-peer:[a-zA-Z0-9_-]{1,64}$/u),IE=N([`relay`,`tailscale`,`lan`,`custom`]),LE=[`blue`,`purple`,`cyan`,`green`,`amber`,`rose`,`slate`],RE=N(LE);new Set(LE);let zE=N([`connected`,`connecting`,`auth-error`,`offline`,`disabled`]),BE=j({peerId:NE,hostId:FE,nodeId:PE.optional(),name:D().min(1).max(120),color:RE.optional(),origin:D().min(1).max(2048),transportKind:IE,encrypted:k(),enabled:k(),state:zE,supportsPeerPairing:k().optional(),pairedBack:k().optional(),linkedPeerIds:A(NE).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(BE)}),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:RE.optional(),pairBack:k().optional(),meshPeerIds:A(NE).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:RE.optional(),expectedNodeId:PE.optional()}),j({status:N([`added`,`updated`,`existing`]),peerId:NE,hostId:FE,nodeId:PE.optional()});let VE=N([`added`,`updated`,`existing`,`failed`,`skipped`]);j({results:A(j({targetPeerId:NE,targetName:D().min(1).max(120),introducedHost:ru([P(`local`),NE]),introducedName:D().min(1).max(120),status:VE,error:D().max(1e3).optional()}))}),j({peerIds:A(NE).max(64).optional(),includeSelf:k().optional(),includeMesh:k().optional(),selfOrigin:D().min(1).max(2048).optional()}),j({peerId:NE,name:D().trim().min(1).max(120).optional(),color:RE.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:NE}),j({removed:k()}),j({peerId:NE.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 HE=j({id:D().min(1).max(1024),name:D().min(1).max(512),path:D().min(1).max(8192)});j({ok:k(),nodeId:PE.optional(),supportsPeerPairing:k().optional(),pairedBack:k().optional(),latencyMs:O().int().nonnegative().optional(),origin:D().max(2048).optional(),transportKind:IE.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(HE).optional(),error:D().max(1e3).optional()});let UE=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))}),WE=j({attachments:P(1).optional(),workspaceFiles:P(1).optional(),officePreview:P(1).optional(),delegation:P(1).optional(),peerPairing:P(1).optional()}),GE=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:PE.optional(),peerNodes:du(FE,PE).refine(e=>Object.keys(e).length<=128).optional(),projects:A(UE),capabilities:WE.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 KE=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()})})}),KE]),ru([j({ok:P(!0),value:j({accepted:P(!0)})}),KE]);let qE=j({name:D().min(1).max(512),path:D().min(1).max(8192),kind:P(`directory`)});j({peerId:NE,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(qE)}),j({peerId:NE,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:NE,path:D().min(1).max(8192),title:D().trim().min(1).max(255).optional()}),j({peerId:NE,workspaceId:D().min(1).max(1024),title:D().trim().min(1).max(255)}),j({peerId:NE,workspaceId:D().min(1).max(1024)}),j({workspaceId:D().min(1).max(1024).optional(),manifest:GE}),j({sessionHostId:D().min(1).max(128).optional()}),j({hosts:A(j({hostId:ru([P(`local`),FE]),name:D().min(1).max(120),isLocal:k().optional(),color:RE.optional(),hostname:D().max(255).optional()}))}),j({hostId:ru([P(`local`),FE])}),j({harnesses:A(j({id:D().regex(/^[a-z0-9][a-z0-9-]*$/u),name:D().min(1).max(120)}))});let JE=N([`listHarnesses`,`inspect`,`start`,`send`,`cancel`,`read`,`answer`,`list`]);M({operation:JE,hopCount:O().int().min(0).max(16),sourceId:NE.optional(),input:FC});let YE=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:YE})]);let XE=M({id:D().min(1).max(1024),name:D().min(1).max(512),path:D().min(1).max(8192)});M({hosts:A(M({hostId:FE,nodeId:PE.optional(),displayName:D().min(1).max(120),online:k(),state:zE,delegation:k(),projects:A(XE),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:JE,hostId:FE,hopCount:O().int().min(0).max(16),timeoutMs:O().int().min(1).max(12e4).optional(),input:FC})]);let ZE=j({id:D().min(1).max(256),harnessId:D().min(1),label:D().min(1).max(512),provider:N([`openai-codex`,`xai`])}).strict(),QE=D().regex(/^[a-z][a-z0-9-]{0,47}$/),$E=j({name:QE,source:ZE,importedAt:D()}).strict(),eD=au(`action`,[j({action:P(`list`)}).strict(),j({action:P(`import`),sourceId:D().min(1).max(256),name:QE,confirmed:P(!0)}).strict(),j({action:P(`reimport`),sourceId:D().min(1).max(256),name:QE,confirmed:P(!0)}).strict(),j({action:P(`remove`),name:QE,confirmed:P(!0)}).strict()]),tD=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(ZE),targets:A(j({harnessId:D(),providers:A(N([`openai-codex`,`xai`])),imports:A($E),others:A(tD).default([])}).strict())}).strict(),j({targetHarnessId:D().min(1).max(128).optional(),request:eD}).strict(),j({events:k()});let nD=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:nD.nullable()}),M({}),M({entries:nD,initializeOnly:k().optional()});let rD=M({enabled:k(),timeoutMinutes:O().int().min(5).max(1440)});Object.freeze({enabled:!0,timeoutMinutes:10});let iD=D().regex(/^external$/u),aD=HC.transform(e=>String(e)),oD=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`),sD=M({lastHarness:HC.optional(),byHarness:du(aD,oD)}),cD=M({model:fw.optional(),thinkingOptionId:mw.optional()}).refine(e=>!!(e.model||e.thinkingOptionId),`A delegation default must contain a Model or Thinking option`),lD=M({byHarness:du(aD,cD)}),uD=D().min(1).max(1024),dD=M({idleRelease:rD.optional(),favorites:du(aD,A(uD).max(2048)).default({}),newThread:sD.optional(),delegation:lD.optional()});M({scope:iD,revision:O().int().nonnegative(),values:dD}),M({scope:iD.default(`external`)});let fD=au(`kind`,[M({kind:P(`idleRelease`),value:rD}),M({kind:P(`favorite`),harnessId:HC,modelId:uD,enabled:k()}),M({kind:P(`favorites`),harnessId:HC,modelIds:A(uD).max(2048)}),M({kind:P(`newThread`),lastHarness:HC.optional(),harnessId:HC.optional(),configuration:oD.optional()}),M({kind:P(`delegation`),harnessId:HC,configuration:cD.nullable()})]);M({scope:iD.default(`external`),operations:A(fD).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(iD,dD)});let pD=O().finite().nonnegative(),mD=M({input:pD,output:pD,cacheRead:pD.optional(),cacheWrite:pD.optional(),cacheWrite1h:pD.optional()}),hD=D().max(512).refine(e=>e.trim()===e&&e.length>0,`Model ID is required`);M({path:D(),entries:A(M({key:D(),price:mD})),error:D().nullable()}),M({}),M({key:hD,price:mD.nullable(),previousKey:hD.optional()}),M({model:hD});let gD=M({official:k().optional(),canonicalModelId:D().min(1).optional(),provider:D().min(1).max(512),model:D().min(1).max(512),price:mD});M({price:mD.nullable(),suggestions:A(gD).max(6).optional()});let _D=[`today`,`7d`,`30d`,`90d`,`all`],vD=O().int().min(0).max(2**53-1),yD=D().regex(/^\d{4}-\d{2}-\d{2}$/u),bD=D().min(1).max(128),xD=D().min(1).max(512),SD=D().min(1).max(4096);M({range:N(_D),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:bD.optional(),model:xD.nullable().optional(),project:SD.nullable().optional(),date:yD.optional()});let CD=M({requests:vD,inputTokens:vD,cachedInputTokens:vD,cacheWriteInputTokens:vD,cacheKnownInputTokens:vD,cacheHitCachedInputTokens:vD,cacheHitInputTokens:vD,outputTokens:vD,reasoningOutputTokens:vD,costUsd:O().finite().min(0),unpricedRequests:vD,unmeteredRequests:vD}),wD=CD.shape,TD=M({harness:bD,sessionId:D().min(1).max(512),project:SD.nullable(),title:D().min(1).max(200).optional(),models:A(xD).max(16),firstAtMs:vD,lastAtMs:vD,...wD});M({range:N(_D),from:yD.nullable(),to:yD,filters:M({harness:bD.nullable(),model:xD.nullable(),unknownModel:k(),project:SD.nullable(),unknownProject:k(),date:yD.nullable()}),reading:M({complete:k(),sources:vD,read:vD}),failures:A(M({harness:bD,message:D().max(2048)})).max(256),options:M({harnesses:A(bD).max(256),models:A(xD.nullable()).max(4096),projects:A(SD.nullable()).max(4096)}),modelLabels:A(M({harness:bD,model:xD,label:xD})).max(4096).optional(),credits:A(M({harness:bD,model:xD.nullable(),credits:O().finite().min(0),reportedRequests:vD,requests:vD})).max(4096).optional(),totals:CD,daily:A(M({date:yD,harness:bD,...wD})).max(2e5),hourly:A(M({weekday:O().int().min(0).max(6),hour:O().int().min(0).max(23),...wD})).max(168),byHarness:A(M({harness:bD,...wD})).max(256),byModel:A(M({model:xD.nullable(),...wD,harnessPricedRequests:vD})).max(4096),byProject:A(M({project:SD.nullable(),...wD})).max(4096),sessions:A(TD).max(100),recentSessions:A(TD).max(100).optional()}),j({threadId:Y}),j({discarded:k()});let ED=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()})]),DD=j({interactionId:D().min(1),turnId:D().min(1),title:D().optional(),questions:A(ED).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(DD)}),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 OD=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(OD)}),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 kD=N([`idle`,`running`,`busy`,`closing`,`failed`,`blocked`]),AD=N([`none`,`disabled`,`timeout`,`operation`,`background`,`identity`,`persistence`,`closeFailed`]);M({threadId:D(),title:D(),harnessId:D(),state:kD,reason:AD,inactiveMs:O().nonnegative()}),M({threadId:Y,turnId:UC});let jD=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 MD(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 ND=MD(jD),PD={harnessId:HC,harnessName:D().trim().min(1).max(128)},FD=j(PD).strict();j({}).strict(),j({sources:A(FD).max(128)}).strict(),j({harnessId:HC,refresh:k().optional()}).strict(),j({...PD,account:ND.nullable(),accounts:A(ND).max(8).optional()}).strict(),j({refresh:k().optional()}).strict(),j({accounts:A(MD(jD.extend(PD))).max(128)}).strict(),j({harnessId:kw,model:fw.optional(),thinkingOptionId:mw.optional(),permissionModeId:GC.optional(),prewarm:P(!0).optional()}).strict();let ID=D().trim().min(1).max(4096).refine(e=>!/[\u0000\r\n]/u.test(e),`Invalid entrypoint path`);j({harnessId:kw}).strict().extend({path:ID.nullable()}),j({path:ID.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 LD=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:LD}).strict(),j({taskId:D().uuid(),status:P(`failed`),error:j({code:O().int(),message:D().min(1).max(2048)}).strict()}).strict()]);let RD=D().min(1).max(256).regex(/^[A-Za-z0-9._~-]+$/u),zD=D().trim().min(1),BD=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`]),VD=j({accountId:RD,label:zD.max(256),email:D().email().max(320).optional(),planType:BD.optional()}).strict(),HD=N([`ready`,`unavailable`]);j({version:P(2),currentAccountId:RD.nullable(),phase:HD,revision:O().int().nonnegative(),instanceId:zD.max(1024).optional(),accounts:A(VD).max(1)}).strict(),j({accountId:RD,refresh:k().optional()}).strict(),j({accountId:RD,usage:tw.nullable(),accountCredits:sw.optional(),freshness:N([`live`,`cached`]),observedAt:D().datetime().nullable()}).strict();let UD=1e3,WD=D().refine(e=>e.trim().length>0,`Value must not be empty or whitespace`).refine(e=>!e.includes(`\0`),`Value must not contain NUL`),GD=WD.max(1024),KD=j({nativeSessionId:GD,title:WD.max(4096).nullable(),updatedAt:O().int().nonnegative().max(864e13),cwd:WD.max(16384),running:k().nullable()}).strict();j({}).strict(),j({harnesses:A(j({harnessId:kw,name:WD.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(UD).optional()}).strict(),j({candidates:A(KD).max(UD),total:O().int().nonnegative().safe()}).strict(),j({harnessId:kw,nativeSessionId:GD}).strict(),j({threadId:WD.max(1024).pipe(Y)}).strict();let qD=D().refine(e=>e.trim().length>0,`Value must not be empty or whitespace`).refine(e=>!e.includes(`\0`),`Value must not contain NUL`),JD=GD,YD=KD;j({}).strict(),j({candidates:A(YD).max(1e3)}).strict(),j({nativeSessionId:JD}).strict(),j({threadId:qD.max(1024).pipe(Y)}).strict(),j({threadId:Y,lastTurnId:UC}).strict(),j({threadId:Y}).strict();let XD=D().trim().min(1).max(128).regex(/^[A-Za-z0-9._:-]+$/u).brand();j({commands:A(j({id:XD,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:XD,turnId:UC.optional(),arguments:FC.optional()}).strict(),j({accepted:P(!0),turnId:UC.optional()}).strict();let ZD=P(`2.0`).optional(),QD=$l().optional(),$D=D().min(1),eO=ru([D(),O().int()]),tO=j({code:O().int(),message:D(),data:PC.optional()}).catchall(PC).superRefine(kC([`data`]));ru([j({jsonrpc:ZD,id:eO,method:$D,params:PC.optional(),result:QD,error:QD}).catchall(PC).superRefine(kC([`jsonrpc`,`params`,`result`,`error`])),j({jsonrpc:ZD,id:QD,method:$D,params:PC.optional(),result:QD,error:QD}).catchall(PC).superRefine(kC([`jsonrpc`,`id`,`params`,`result`,`error`])),j({jsonrpc:ZD,id:eO,method:QD,params:QD,result:PC,error:QD}).catchall(PC).superRefine(kC([`jsonrpc`,`method`,`params`,`error`])),j({jsonrpc:ZD,id:eO,method:QD,params:QD,result:QD,error:tO}).catchall(PC).superRefine(kC([`jsonrpc`,`method`,`params`,`result`]))]);let nO=D().refine(e=>e.trim().length>0,{message:`Native identifier must not be empty or whitespace`});M({harnessId:HC,nativeSessionId:nO,locator:PC.optional(),formatVersion:P(1)}).superRefine(kC([`locator`])),M({harnessId:HC,nativeSessionId:nO,nativeTurnKey:nO,formatVersion:P(1)}),M({harnessId:HC,nativeSessionId:nO,checkpointId:nO,locator:PC.optional(),formatVersion:P(1)}).superRefine(kC([`locator`]));let rO=D().regex(/^\d+\.\d+\.\d+(?:-[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?(?:\+[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/u),iO=N([`npm`,`windows-installer`,`macos-dmg`,`linux-archive`]),aO=N([`prepared`,`downloading`,`waiting-for-exit`,`installing`,`restarting`,`succeeded`,`failed`]),oO=M({completed:O().int().nonnegative(),total:O().int().positive()}).refine(e=>e.completed<=e.total,{path:[`completed`],message:`completed must not exceed total`}),sO=M({version:rO,installation:iO,phase:aO,updatedAt:O().int().nonnegative(),downloadedBytes:O().int().nonnegative().optional(),totalBytes:O().int().positive().optional(),npmDownload:oO.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 cO=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`),lO=N([`idle`,`downloading`,`ready`,`failed`]),uO=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:rO,installation:iO.nullable(),latestVersion:rO.nullable(),updateAvailable:k(),installationAvailable:k(),releaseNotes:D().min(1).max(2e4).nullable(),releaseNotesUrl:cO.nullable(),status:sO.nullable(),error:D().min(1).max(500).nullable(),stagedVersion:rO.nullable().optional(),backgroundPhase:lO.optional(),backgroundDownload:uO.nullable().optional(),backgroundError:D().min(1).max(500).nullable().optional(),runningTaskCount:O().int().nonnegative().optional()}),M({status:sO}),M({status:sO.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 dO=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)}),fO=M({summary:D().min(1).max(600).optional(),themes:A(dO).min(1).max(12)}),pO=M({version:rO,publishedAt:Bu(),url:D().max(300).regex(/^https:\/\/github\.com\/BytePioneer-AI\/codex-host\/releases\/tag\/v[0-9A-Za-z.+-]+$/u),zh:fO.nullable(),en:fO.nullable()}).refine(e=>e.zh!==null||e.en!==null,{message:`an announcement needs at least one language`});M({manual:k().optional()}),M({announcement:pO.nullable(),unread:k()}),M({version:rO}),RegExp(String.raw`^- \[([^\]\n]+)\]\(thread://([^\s()<>"?#/]+)\): `+`(${[`completed`,`failed`,`interrupted`,`needsInput`,`timedOut`,`unreadable`,`notFound`].join(`|`)})(?:\. (.+))?$`,`u`);let mO=`<response-annotations>`,hO=`</response-annotations>`,gO=/^\s*## My request(?: for Codex)?:[ \t]*(?:\r?\n|$)/u;function _O(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${mO}\n${JSON.stringify(t)}\n${hO}\n`}function vO(e,t){let n=_O(e);return n===``?t:`${n}\n## My request:\n${t}\n`}function yO(e){let t=e.trimStart().startsWith(`# Response annotations:`)?0:e.length,n=e.indexOf(`\n${mO}\n`,t);if(n<0)return;let r=n+1+22+1,i=e.indexOf(`\n${hO}`,r);if(!(i<0))return{json:e.slice(r,i),closeEnd:i+1+23}}function bO(e){let t=yO(e);if(t===void 0)return{annotations:[],body:e};let n=SO(t.json);if(n.length===0)return{annotations:[],body:e};let r=e.slice(t.closeEnd),i=gO.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
+ `)&&a.endsWith(`\r
148
+ `)?a.slice(0,-2):a.endsWith(`
149
+ `)?a.slice(0,-1):a}}function xO(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function SO(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(!xO(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 CO=N([`idle`,`installing`,`restarting`,`succeeded`,`failed`]);j({runningVersion:D().nullable(),installedVersion:D().nullable(),restartRequired:k(),remote:k(),updateSupported:k(),update:j({phase:CO,targetVersion:D().nullable(),error:D().nullable()})});let wO=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),TO={hostId:X.regex(/^(?:remote-(?:ssh(?:-|:)|control:)|remote-peer:[a-zA-Z0-9_-]{1,64}$)/u)},EO={...TO,threadId:X},DO=D().min(1).max(8e3),OO={text:DO,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 kO=au(`kind`,[M({kind:P(`hosts`)}),M({kind:P(`create`),...TO,cwd:D().min(1).max(8192),epoch:X}),M({kind:P(`projectHarnesses`),...TO,epoch:X}),M({kind:P(`inspectHarness`),...TO,epoch:X,cwd:D().min(1).max(8192),harnessId:X}),M({kind:P(`startSelected`),...TO,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`),...EO}),M({kind:P(`list`),...TO,cursor:D().nullable(),archived:k(),includeLoaded:P(!0).optional()}),M({kind:P(`read`),...EO,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`),...EO,epoch:X}),M({kind:P(`configure`),...EO,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`),...EO,epoch:X,text:DO,requestId:X.optional()}),M({kind:P(`queue`),...EO,epoch:X}),M({kind:P(`delivery`),...EO,epoch:X,action:au(`kind`,[M({kind:P(`enqueue`),...OO}),M({kind:P(`steer`),...OO,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`),...EO,epoch:X,turnId:X}),M({kind:P(`rename`),...EO,epoch:X,name:D().min(1).max(512)}),M({kind:P(`archive`),...EO,epoch:X,archived:k()}),M({kind:P(`respond`),...EO,epoch:X,requestId:ru([X,O().int()]),result:du(D(),Zl())})]),AO=D().min(1).max(1024),jO=j({hostId:AO,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()}),MO=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:kO}),M({action:P(`list`)}),M({action:P(`catalog`)}),M({action:P(`read-thread`),hostId:AO.refine(e=>e!==`local`),input:jE}),M({action:P(`save`),draft:MO,previous:jO.nullable()}),M({action:P(`remove`),previous:jO}),M({action:P(`connect`),hostId:AO,enabled:k()}),M({action:P(`state`),hostId:AO}),M({action:P(`runtime`),hostId:AO}),M({action:P(`update`),hostId:AO.refine(e=>e!==`local`),version:wO.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 NO=D().max(214).regex(/^(?:@[a-z0-9][a-z0-9._-]*\/)?[a-z0-9][a-z0-9._-]*$/u),PO=ru([D(),j({en:D()}).catchall(D())]),FO=j({title:PO.optional(),description:PO.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:NO,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:FO.optional(),loadError:D().optional()})),loadedIds:A(NO),safeMode:k(),storeError:D().optional()});let IO=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:IO.optional()}).strict(),j({id:NO,enabled:k()}).strict(),j({id:NO}).strict(),P(1);function LO(e){return e.registerNodeTransform(sh,e=>{let t=CE(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 RO=`color: var(--dsw-alias-state-business-primary)`;function zO(){let e=X_().getFirstChild();if(!U(e))return null;let t=e.getFirstChild();return z(t)?t:null}function BO(e,t){return e.registerNodeTransform(sh,e=>{let n=zO();if(n===null||e.getKey()!==n.getKey()){e.getStyle()===RO&&e.setStyle(``);return}let r=e.getTextContent(),i=t(),a=r===i?.trimEnd()?r:i;if(a===null||!r.startsWith(a))e.getStyle()===RO&&e.setStyle(``);else if(r.length>a.length){let[t,n]=e.splitText(a.length);t!==void 0&&t.getStyle()!==RO&&t.setStyle(RO),n?.setStyle(``)}else e.getStyle()!==RO&&e.setStyle(RO)})}function VO(e){e.update(()=>{zO()?.markDirty()})}function HO(){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,`
147
150
  `,`
148
- `):W(e)&&
151
+ `):U(e)&&
149
152
  /* v8 ignore next 4 -- plain-text composition nests no block elements today; the walk stays total for imported states. */
150
- s(e);r.set(e.getKey(),{start:t,end:i.length})},c=U_(),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=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+=`
151
154
  `,a+=`
152
- `),W(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 fO(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 pO(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 mO(e){let t=dO(),n=[];for(let r of t.segments){if(r.kind!==`chip`||!cC(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=H(),i=null;if(V(r)){let e=pO(t,r.anchor),n=pO(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 hO(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 UO(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 WO(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 GO(e){let t=HO(),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=WO(t,r.anchor),n=WO(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 KO(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`}}
153
156
  /* v8 ignore next -- non-gap segments always carry their node. */
154
- 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=U_().getChildren(),r=n[n.length-1];return r===void 0?{key:U_().getKey(),offset:0,type:`element`}:{key:r.getKey(),offset:e.children.get(r.getKey())?.length??0,type:`element`}}function gO(e,t){if(t.start<0||t.start>t.end||t.end>e.detectLength)return null;let n=hO(e,t.start),r=hO(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=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 qO(e,t){if(t.start<0||t.start>t.end||t.end>e.detectLength)return null;let n=KO(e,t.start),r=KO(e,t.end);
155
158
  /* v8 ignore next -- bounds were checked above; resolvePoint only fails out of bounds. */
156
- if(n===null||r===null)return null;let i=Uh();return i.anchor.set(n.key,n.offset,n.type),i.focus.set(r.key,r.offset,r.type),W_(i),i}function _O(e,t){let n=gO(dO(),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=Xh();return i.anchor.set(n.key,n.offset,n.type),i.focus.set(r.key,r.offset,r.type),Z_(i),i}function JO(e,t){let n=qO(HO(),e);if(n===null)return!1;if(t===``)n.isCollapsed()||n.removeText();else{let e=t.replace(/\r\n?/gu,`
157
160
  `);e.includes(`
158
- `)?n.insertRawText(e):n.insertText(e)}return!0}function vO(e,t){let n=gO(dO(),e);return n!==null&&(n.insertNodes([...t]),!0)}let yO=/[\uE100-\uE11D\uFFFC]/gu;var bO=class{deps;editor;projected={detectText:``,clipboardText:``,occurrences:[],selection:null,caret:null};occurrenceIds=/* @__PURE__ */ new Map;occurrenceSeq=0;lexiconOff;lexiconSource;constructor(e){this.deps=e,this.editor=l_({namespace:`dsh-composer`,nodes:[oC,vC],onError:e=>{throw e}}),this.editor.update(()=>{let e=U_();e.getChildrenSize()===0&&e.append(r_())},{discrete:!0,tag:Vm})}register(){let e=()=>{let e=this.editor.getRootElement();return e!==null&&!e.contains(e.ownerDocument.activeElement)&&mv(Vm),!1},t=Jb(BS(this.editor),this.editor.registerCommand(Gp,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(Up,e=>{if(!this.editor.isEditable()||!e.dataTransfer||e.dataTransfer.types.includes(`Files`))return!1;let t=QS(e.dataTransfer.getData(KS));return t!==void 0&&(e.preventDefault(),e.stopPropagation(),e.dataTransfer.dropEffect=`copy`,this.insertFileReferences([ZS(t)]))},4),this.editor.registerCommand(tm,()=>(this.editor.update(e,{discrete:!0}),!1),4),this.editor.registerCommand(pp,e,4),this.editor.registerNodeTransform(Bg,e),xC(this.editor,(e,t)=>this.deps.openReference(e,t)),WS(this.editor,GS(),1e3),this.editor.registerUpdateListener(()=>{this.deps.onUpdate()}),oO(this.editor),lO(this.editor,()=>this.deps.activeClaimToken()),yC(this.editor,()=>this.deps.lexicon(),()=>this.deps.activeClaimToken()),()=>{this.lexiconOff?.(),this.lexiconOff=void 0,this.lexiconSource=void 0});return()=>{t(),this.editor.setRootElement(null)}}get projection(){return this.projected}applyEdit(e,t){this.editor._updating?(t!==void 0&&mv(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(()=>{bC(this.editor)}),bC(this.editor))}refreshProjection(){let e=this.projected;return this.projected=this.editor.getEditorState().read(()=>mO(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(yO,``);(t!==this.projection.clipboardText||this.projection.occurrences.length!==0)&&this.editor.update(()=>{let e=U_();e.clear();for(let n of t.split(`
159
- `)){let t=r_();n!==``&&t.append(lh(n)),e.append(t)}e.selectEnd()},{discrete:!0,tag:zm})}paste(e){let t=e.replace(yO,``).replace(/\r\n?/gu,`
160
- `);t!==``&&this.applyEdit(()=>{let e=H();if(V(e)){e.insertRawText(t);return}let n=U_();n.getChildrenSize()===0&&n.append(r_()),n.selectEnd().insertRawText(t)},Bm)}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=_O(e,t)}),n}insertAsyncText(e,t){let n=!1,r=t.replace(yO,``);return this.applyEdit(()=>{n=_O(e,r)},Bm),n}insertReference(e,t,n){let r=!1;return this.applyEdit(()=>{r=vO(e,n===` `?[sC(t)]:[sC(t),lh(` `)])}),r}insertFileReferences(e,t){if(e.length===0)return!0;let n=!1;return this.applyEdit(()=>{let r=mO(e=>this.occurrenceIdOf(e)),i=t?.end??r.selection?.end??r.detectText.length,a=r.detectText.slice(0,i),o=e.flatMap(e=>[sC(e),lh(` `)]);a!==``&&!/\s$/u.test(a)&&o.unshift(lh(` `)),n=vO({start:i,end:i},o)},Bm),n}refreshClaimDecoration(){uO(this.editor)}clearCommittedDraft(e){this.editor.update(()=>{let t=dO(),n=e(t.clipboardText);if(n!==null){_O({start:0,end:fO(t,n)},``);return}let r=U_();r.clear(),r.append(r_()),r.selectEnd()},{discrete:!0,tag:zm})}restoreDraft(e,t){this.editor.update(()=>{let n=U_();n.clear();let r=r_();n.append(r);let i=e=>{let t=e.replace(yO,``).split(`
161
- `);for(let e=0;e<t.length;e+=1){let i=t[e];i!==``&&r.append(lh(i)),e<t.length-1&&(r=r_(),n.append(r))}},a=0;for(let n of t)i(e.slice(a,n.offset)),r.append(new oC({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:zm})}clearHistory(){this.editor.dispatchCommand(Zp,void 0)}};function xO(e){switch(e){case`plain`:return`plain`;case`claimed`:return`claimed`;default:return`frozen`}}function SO(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 CO=[],wO=/* @__PURE__ */ new Map;var TO=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)=>{if(t?.focus===`end`&&!this.canInsertReferences())return;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 Qb;draftEditor;get projection(){return this.draftEditor.projection}rev=0;unregister;noticeSeq=0;lastPublishedDraft;draftSnapshotCache;attachmentIds=[];responseAnnotations=[];hoveredResponseAnnotationId;annotationSeq=0;adjudication;disposed=!1;persistDraft;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 bO({onUpdate:()=>{this.onEditorUpdate()},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(){SO(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}));let e=this.projection.caret;e!==null&&this.deps.inputTriggers?.()?.track(this.projection.detectText,e,{tier:xO(this.core.state.phase)},this.rev)}setDraft(e){let t=Iu(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=Ru(this.projection.clipboardText,this.projection.occurrences);return this.draftSnapshotCache={revision:this.rev,value:e},e}persistCurrentDraft(){this.persistDraft?.(this.draftSnapshot)}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.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}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))}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()??wO,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(()=>{U_().selectEnd()},{discrete:!0}):this.editor.focus()}dispose(){if(this.disposed)return[];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.attachmentFlights.clear(),[...e]}get snapshot(){return this.state.getSnapshot()}bindDraftPersistence(e){return this.persistDraft=e,()=>{this.persistDraft===e&&(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()}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=t=>this.deps.defaultSink(GD(i,t.trim()),r,n,e.signal);if(a.length===0){this.settleSink(e,s(t));return}let c=this.deps.inputTriggers?.();Promise.all(a.map(async t=>{if(c===void 0)throw Error(`no serializer for reference source "${t.source}"`);return{offset:t.offset,length:t.length,text:await c.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,s(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 YO(e,t){let n=qO(HO(),e);return n!==null&&(n.insertNodes([...t]),!0)}let XO=/[\uE100-\uE11D\uFFFC]/gu;var ZO=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()}),LO(this.editor),BO(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(()=>GO(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(XO,``);(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(XO,``).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=JO(e,t)}),n}insertAsyncText(e,t){let n=!1,r=t.replace(XO,``);return this.applyEdit(()=>{n=JO(e,r)},qm),n}insertReference(e,t,n){let r=!1;return this.applyEdit(()=>{r=YO(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=GO(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=YO({start:i,end:i},o)},qm),n}refreshClaimDecoration(){VO(this.editor)}clearCommittedDraft(e){this.editor.update(()=>{let t=HO(),n=e(t.clipboardText);if(n!==null){JO({start:0,end:UO(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(XO,``).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 QO(e){switch(e){case`plain`:return`plain`;case`claimed`:return`claimed`;default:return`frozen`}}function $O(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 ek=[],tk=/* @__PURE__ */ new Map;var nk=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 ZO({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(){$O(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:QO(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()??tk,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(vO(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+=`
162
165
 
163
- `),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`]??CO}}publish(){let e=this.compose();this.state.set(e);let t=this.draftSnapshot;t!==this.lastPublishedDraft&&(this.lastPublishedDraft=t,this.persistDraft?.(t))}};function EO(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 DO=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 TO({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=>{EO(this.rootCtx,e)},inputTriggers:()=>this.controller(r),popup:()=>this.popup(r),inbox:n.projections.faceOf(`inbox`),defaultSink:(e,t,r,i)=>this.sink(n,e,t,r,i),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(Hu(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){return t===``&&n.length===0?Promise.resolve({kind:`success`}):this.conversation().sendSession(e,t,n,r,i)}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 OO=/* @__PURE__ */ new Map;var kO=class{runtime;unregister;textStore=(0,f.createSnapshotStore)(``);activeToken=null;modified=!1;seeding=!1;text=this.textStore;constructor(){this.runtime=new bO({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:()=>OO,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 AO=`busyEnter`,jO=[`queue`,`steer`],MO=`queue`,NO={[AO]:C.union([...jO]).default(MO)};C.object(NO);function PO(e,t,n,r){return!t||!r?`queue`:n===`enter`?e:e===`queue`?`steer`:`queue`}var FO=class{busyEnter=(0,f.createSnapshotStore)(MO);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(AO,e))}adopt(e){let t=e.getSnapshot().value;t!==void 0&&this.busyEnter.getSnapshot()!==t.busyEnter&&this.busyEnter.set(t.busyEnter)}};async function IO(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 LO(e){let{sessionId:t,shell:n,conversation:r,message:i,imageBlobs:a}=e,o=()=>{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){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}}if(i.text!==``){let e=n.draftSnapshot;n.setDraft({...e,text:e.text===``?i.text:`${e.text}\n${i.text}`})}return n.actions.persistDraft(),n.focus(`end`),!0};try{if(o())return Promise.resolve()}catch(e){return Promise.reject(e)}return new Promise((e,t)=>{let r=!1,i=!1,a,s=()=>{if(!(r||i)){i=!0;try{if(!o())return;r=!0,a?.(),e()}catch(e){r=!0,a?.(),t(e)}finally{i=!1}}};a=n.state.subscribe(s),s()})}let RO=`@deepseek-ai/dsh-client-ui-conversation/QueueDock.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(RO)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-conversation`,e.dataset.pluginCss=RO,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_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_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`,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`,row:`ZMI-0G_row`,status:`ZMI-0G_status`,thumb:`ZMI-0G_thumb`};let zO=[];function BO(e){let t=e.filter(e=>e.type!==`image`&&e.type!==`file`).map(e=>e.type===`text`?e.text:`[${e.type}]`).join(` `).replace(/\s+/g,` `).trim(),n=Array.from(t);return n.length>200?`${n.slice(0,200).join(``)}…`:t}function VO(e){return e.every(e=>e.type===`text`)?e.map(e=>e.text).join(``):null}function HO(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 UO({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 WO({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 GO({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 KO({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`]??zO,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),[x,ee]=(0,g.useState)(null),[te,ne]=(0,g.useState)(!0),re=(0,g.useId)(),ie=l?.pausedReason??null,ae=ie===`interrupted`?s(`queue.paused.interrupted`):ie===`outcome-unknown`?s(`queue.paused.unknown`):ie===`failed`?s(`queue.paused.failed`):null;if((0,g.useEffect)(()=>{m===0&&!te&&ne(!0)},[te,m]),m===0)return null;let oe=v&&x!==null,se=!te||oe,ce=m===1||se,le=async(e,t,r)=>{if(b.current)return!1;b.current=!0,ee(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,ee(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`)}),ae!==null&&/* @__PURE__ */ (0,h.jsx)(`div`,{className:Z.paused,role:`status`,children:ae}),m>1&&/* @__PURE__ */ (0,h.jsxs)(`button`,{type:`button`,className:Z.header,"aria-controls":re,"aria-expanded":se,disabled:oe,onClick:()=>{ne(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})}),!ce&&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:se?/* @__PURE__ */ (0,h.jsx)(d.IconChevronDownOutlineRegular,{}):/* @__PURE__ */ (0,h.jsx)(d.IconChevronUpOutlineRegular,{})})]}),/* @__PURE__ */ (0,h.jsxs)(`ul`,{id:re,className:Z.list,hidden:!ce,children:[ce&&f.map(e=>{let t=HO(e.content),n=l?.editable===void 0?(()=>{let t=VO(e.content);return t===null?null:{kind:`legacyText`,text:t}})():(()=>{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=n!==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)(WO,{attachment:e.attachment,loadImage:o,label:s(`queue.image`)},`${e.attachment.attachmentId}:${t}`):/* @__PURE__ */ (0,h.jsx)(UO,{attachment:e.attachment,label:s(`queue.file`,{name:e.attachment.name})},`${e.attachment.attachmentId}:${e.attachment.name}:${t}`))}),/* @__PURE__ */ (0,h.jsx)(`span`,{className:Z.preview,children:(0,d.projectUserText)(BO(e.content),[])}),v&&/* @__PURE__ */ (0,h.jsxs)(`div`,{className:Z.actions,children:[!y&&/* @__PURE__ */ (0,h.jsx)(d.Tooltip,{portal:!0,label:s(a?`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:x!==null||!a,onClick:()=>{n!==null&&le(e.id,()=>r(e.id,n),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:x!==null,onClick:()=>{le(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:x!==null,onClick:()=>{le(e.id,{kind:`steer`},s(_?`queue.steerFailed`:`queue.resumeFailed`))},children:/* @__PURE__ */ (0,h.jsx)(d.IconSendOutlineRegular,{})})})]})]},e.id)}),ce&&p.map(e=>/* @__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)(UO,{attachment:e.value,label:s(`queue.file`,{name:e.value.name})}),e.upload&&/* @__PURE__ */ (0,h.jsx)(GO,{upload:e.upload,t:s})]},t))}),/* @__PURE__ */ (0,h.jsx)(`span`,{className:Z.preview,children:(0,d.projectUserText)(e.text,[])}),/* @__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 qO={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:qu,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`){if(await i.updateQueue(r,{kind:`remove`}),s.isDisposed)throw Error(`Queued message was removed, but the session composer was closed before restoring.`);let e=s.draftSnapshot;s.setDraft({...e,text:e.text===``?o.text:`${e.text}\n${o.text}`}),s.actions.persistDraft(),s.focus(`end`);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 IO(o.images,a):/* @__PURE__ */ new Map;if(s.isDisposed)throw Error(`queue dock: session composer closed before editing`);await LO({sessionId:n,shell:s,conversation:l,message:await c.takeForEdit(n,r,o.revision),imageBlobs:u})}finally{s.release()}},notify:(t,a)=>{e.sessions.scope(n)===r&&i.input.for(r).notify(t,a)},loadImage:a}}},KO))}},JO=`@deepseek-ai/dsh-client-ui-conversation/EnterBehaviorRow.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(JO)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-conversation`,e.dataset.pluginCss=JO,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 YO={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 XO=[{id:`queue`,label:`settings.enter.queue`},{id:`steer`,label:`settings.enter.steer`}];function ZO({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:YO.row,children:[/* @__PURE__ */ (0,h.jsxs)(`div`,{className:YO.rowText,children:[/* @__PURE__ */ (0,h.jsx)(`div`,{className:YO.title,children:n(`settings.enter.title`)}),/* @__PURE__ */ (0,h.jsx)(`div`,{className:YO.desc,children:n(`settings.enter.description`)})]}),/* @__PURE__ */ (0,h.jsx)(d.Menu,{open:i,onClose:()=>{a(!1)},items:XO.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:YO.selector,"aria-haspopup":`menu`,"aria-expanded":i,onClick:()=>{a(e=>!e)},children:[n(o),/* @__PURE__ */ (0,h.jsx)(d.IconChevronDownOutlineRegular,{className:YO.chevron})]})})]})}let QO={views:{get:()=>void 0,grouped:()=>void 0},activeTargets:/* @__PURE__ */ new Set};function $O(e,t){return t.activeTargets.size>0||!e.blank&&!e.awaitingFirstTurn||e.running?`active`:e.promptAttempted?`engaging`:`blank`}let ek=`@deepseek-ai/dsh-client-ui-conversation/ConversationRoot.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(ek)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-conversation`,e.dataset.pluginCss=ek,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{--dsh-composer-text-max-height:336px;flex-direction:column;flex:none;display:flex}.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));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: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 tk=`dsh.conversation.contentWidth`;function nk(){let e=localStorage.getItem(tk);if(e===null)return null;let t=Number(e);return Number.isFinite(t)&&t>0?t:null}function rk(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 ik(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 ak(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`]??ek}}publish(){let e=this.compose();this.state.set(e);let t=this.draftSnapshot;t!==this.lastPublishedDraft&&(this.lastPublishedDraft=t,this.scheduleDraftPersistence(t))}};function rk(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 ik=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 nk({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=>{rk(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 ak=/* @__PURE__ */ new Map;var ok=class{runtime;unregister;textStore=(0,f.createSnapshotStore)(``);activeToken=null;modified=!1;seeding=!1;text=this.textStore;constructor(){this.runtime=new ZO({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:()=>ak,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 sk=`busyEnter`,ck=[`queue`,`steer`],lk=`queue`,uk={[sk]:S.union([...ck]).default(lk)};S.object(uk);function dk(e,t,n,r){return!t||!r?`queue`:n===`enter`?e:e===`queue`?`steer`:`queue`}var fk=class{busyEnter=(0,f.createSnapshotStore)(lk);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(sk,e))}adopt(e){let t=e.getSnapshot().value;t!==void 0&&this.busyEnter.getSnapshot()!==t.busyEnter&&this.busyEnter.set(t.busyEnter)}};async function pk(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 mk(e,t,n){let{annotations:r,body:i}=bO(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 hk(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!==``&&mk(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 gk=`@deepseek-ai/dsh-client-ui-conversation/QueueDock.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(gk)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-conversation`,e.dataset.pluginCss=gk,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 _k=[];function vk(e){let t=e.replace(/\s+/g,` `).trim(),n=Array.from(t);return n.length>200?`${n.slice(0,200).join(``)}…`:t}function yk(e,t){let n=vk(t);if(e.length===0)return{annotations:e,preview:n,fallbackPreview:``,annotationTooltip:``};let r=e[0];return{annotations:e,preview:n,fallbackPreview:n===``?vk(r.annotation??r.text):``,annotationTooltip:e.map((e,t)=>`${String(t+1)}. ${vk(e.annotation??e.text)}`).join(`
167
+ `)}}function bk(e){let t=[],n=[];for(let r of e)if(r.type!==`image`&&r.type!==`file`){if(r.type===`text`){let e=bO(r.text);t.push(...e.annotations),e.body!==``&&n.push(e.body)}else n.push(`[${r.type}]`)}return yk(t,n.join(` `))}function xk(e){let t=bO(e);return yk(t.annotations,t.body)}function Sk({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 Ck(e){return e.every(e=>e.type===`text`)?e.map(e=>e.text).join(``):null}function wk(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 Tk({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 Ek({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 Dk({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 Ok({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`]??_k,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=wk(e.content),n=bk(e.content),a=e.source.kind===`user`&&`rpcId`in e.source?e.source.rpcId:void 0,c=l?.editable===void 0?(()=>{let t=Ck(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)(Ek,{attachment:e.attachment,loadImage:o,label:s(`queue.image`)},`${e.attachment.attachmentId}:${t}`):/* @__PURE__ */ (0,h.jsx)(Tk,{attachment:e.attachment,label:s(`queue.file`,{name:e.attachment.name})},`${e.attachment.attachmentId}:${e.attachment.name}:${t}`))}),/* @__PURE__ */ (0,h.jsx)(Sk,{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=xk(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)(Tk,{attachment:e.value,label:s(`queue.file`,{name:e.value.name})}),e.upload&&/* @__PURE__ */ (0,h.jsx)(Dk,{upload:e.upload,t:s})]},t))}),/* @__PURE__ */ (0,h.jsx)(Sk,{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 kk={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 hk({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 pk(o.images,a):/* @__PURE__ */ new Map;if(s.isDisposed)throw Error(`queue dock: session composer closed before editing`);await hk({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}}},Ok))}},Ak=`@deepseek-ai/dsh-client-ui-conversation/EnterBehaviorRow.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(Ak)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-conversation`,e.dataset.pluginCss=Ak,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 jk={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 Mk=[{id:`queue`,label:`settings.enter.queue`},{id:`steer`,label:`settings.enter.steer`}];function Nk({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:jk.row,children:[/* @__PURE__ */ (0,h.jsxs)(`div`,{className:jk.rowText,children:[/* @__PURE__ */ (0,h.jsx)(`div`,{className:jk.title,children:n(`settings.enter.title`)}),/* @__PURE__ */ (0,h.jsx)(`div`,{className:jk.desc,children:n(`settings.enter.description`)})]}),/* @__PURE__ */ (0,h.jsx)(d.Menu,{open:i,onClose:()=>{a(!1)},items:Mk.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:jk.selector,"aria-haspopup":`menu`,"aria-expanded":i,onClick:()=>{a(e=>!e)},children:[n(o),/* @__PURE__ */ (0,h.jsx)(d.IconChevronDownOutlineRegular,{className:jk.chevron})]})})]})}let Pk={views:{get:()=>void 0,grouped:()=>void 0},activeTargets:/* @__PURE__ */ new Set};function Fk(e,t){return t.activeTargets.size>0||!e.blank&&!e.awaitingFirstTurn||e.running?`active`:e.promptAttempted?`engaging`:`blank`}let Ik=`@deepseek-ai/dsh-client-ui-conversation/ConversationRoot.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(Ik)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-conversation`,e.dataset.pluginCss=Ik,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));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 Lk=`dsh.conversation.contentWidth`;function Rk(){let e=localStorage.getItem(Lk);if(e===null)return null;let t=Number(e);return Number.isFinite(t)&&t>0?t:null}function zk(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 Bk(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 Vk(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;
164
168
  /* v8 ignore next -- a width handle renders only inside the Conversation body. */
165
169
  if(t===null)return;let n=t.querySelector(`:scope > [data-conversation-scroll]`);
166
170
  /* v8 ignore next -- the Conversation body always contains its direct scroll element. */
167
- n!==null&&(e.ctrlKey||e.deltaY===0||n.scrollBy({top:ik(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 ok({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=nk();r===null?t.style.removeProperty(`--dsh-chat-user-width`):t.style.setProperty(`--dsh-chat-user-width`,`${rk(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:rk(e.offsetWidth,nk()),[e]),i=(0,g.useCallback)(t=>{e!==null&&(e.parentElement??e).style.setProperty(`--dsh-chat-user-width`,`${rk(e.offsetWidth,t)}px`)},[e]),a=(0,g.useCallback)(t=>{e!==null&&localStorage.setItem(tk,`${rk(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)(ak,{side:e,onStart:r,onDrag:i,onCommit:a,onEnd:o},e))}let sk={widthControls:ok};function ck(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`:$O(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:sk})]})}function lk(e){return/* @__PURE__ */ (0,h.jsx)(ck,{...e})}function uk(e,t){return e===`default-workspace`?t:e}let dk=`@deepseek-ai/dsh-client-ui-conversation/HeroShell.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(dk)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-conversation`,e.dataset.pluginCss=dk,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_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 fk={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`,root:`Dgrl1G_root`,stack:`Dgrl1G_stack`,titleGroup:`Dgrl1G_titleGroup`,workspace:`Dgrl1G_workspace`,workspaceLabel:`Dgrl1G_workspaceLabel`,workspaceRow:`Dgrl1G_workspaceRow`};function pk(e){let t=Gu(e);return t===``?e:t}function mk({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:fk.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:fk.folder,size:16}):/* @__PURE__ */ (0,h.jsx)(d.IconFolderOpenRegular,{className:fk.folder,size:16}),/* @__PURE__ */ (0,h.jsx)(`span`,{className:fk.workspaceLabel,children:t??a(`hero.chooseWorkspace`)}),/* @__PURE__ */ (0,h.jsx)(d.IconChevronDownOutlineRegular,{className:fk.chevron,size:12})]})}function hk({hovering:e}){return/* @__PURE__ */ (0,h.jsx)(`svg`,{className:fk.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 gk({t:e,renderSlot:t,children:n}){let[r,i]=(0,g.useState)(!1);return/* @__PURE__ */ (0,h.jsxs)(`div`,{className:fk.root,children:[/* @__PURE__ */ (0,h.jsxs)(`div`,{className:fk.stack,children:[/* @__PURE__ */ (0,h.jsxs)(`div`,{className:fk.headline,children:[/* @__PURE__ */ (0,h.jsx)(`span`,{className:fk.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:fk.fish},{fallback:/* @__PURE__ */ (0,h.jsx)(hk,{hovering:r})})}),/* @__PURE__ */ (0,h.jsxs)(`span`,{className:fk.titleGroup,children:[/* @__PURE__ */ (0,h.jsx)(`span`,{children:e(`hero.headline`)}),/* @__PURE__ */ (0,h.jsx)(`span`,{className:fk.previewBadge,children:e(`hero.preview`)})]})]}),/* @__PURE__ */ (0,h.jsx)(`div`,{className:fk.body})]}),n]})}let _k=`@deepseek-ai/dsh-client-ui-conversation/ThreadReferenceDropTarget.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(_k)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-conversation`,e.dataset.pluginCss=_k,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 vk={hint:`tWXKHq_hint`,invitation:`tWXKHq_invitation`,overlay:`tWXKHq_overlay`,preview:`tWXKHq_preview`,title:`tWXKHq_title`};function yk({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:XS(YS(e)),n=t===void 0?void 0:a.current[t];return n!==void 0&&JS(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:QS(t.getData(KS));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(Gp,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=QS(a.getData(KS));i()&&c(r)&&r?.threadId===n?.threadId&&r?.hostId===n?.hostId?t.dispatchCommand(Up,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:vk.overlay,"data-thread-reference-drop":!0,role:`status`,"aria-live":`polite`,children:/* @__PURE__ */ (0,h.jsxs)(`div`,{className:vk.invitation,children:[/* @__PURE__ */ (0,h.jsx)(`div`,{className:vk.hint,children:r(`reference.dropTitle`)}),/* @__PURE__ */ (0,h.jsxs)(`div`,{className:vk.preview,"data-thread-reference-preview":!0,children:[/* @__PURE__ */ (0,h.jsx)(d.ReferenceIconRegular,{kind:`session`,size:20}),/* @__PURE__ */ (0,h.jsx)(`span`,{className:vk.title,children:o.title})]})]})})}function bk({renderSlot:e}){return e(`conversation.session`,{})}function xk({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 Sk(){return null}function Ck(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),x=y(`views`,bk),ee=y(`widthControls`,Sk),[te,ne]=(0,g.useState)(null),re=o(e=>t===void 0?void 0:e.get(t)?.pendingInteraction),ie=a(e=>t===void 0?void 0:e.byId[t]?.cwd),ae=s(e=>e),oe=l(e=>e),se=u(e=>e),ce=t===void 0&&se.state!==`idle`?se.workspaceId:void 0,[le,ue]=(0,g.useState)(!1),[de,fe]=(0,g.useState)(),pe=(0,g.useRef)(null),S=(0,g.useRef)(null),C=(0,g.useCallback)(e=>{S.current?.disconnect(),S.current=null;let t=e?.parentElement??null;e!==null&&t!==null&&(S.current=new ResizeObserver(()=>{t.style.setProperty(`--dsh-composer-height`,`${e.offsetHeight}px`),t.style.setProperty(`--dsh-conversation-viewport-height`,`${t.clientHeight}px`)}),S.current.observe(e),S.current.observe(t))},[]),me=t===void 0?void 0:ae.items.find(e=>e.sessionIds.includes(t)),he=de?de.id:ce,ge=ae.items.find(e=>e.workspaceId===he),_e=(he===null?void 0:ge?.title)??(he===null||t===void 0?void 0:me?.title??(ae.phase===`ready`||ie===void 0||ie===``?void 0:pk(ie))),ve=_e===void 0?void 0:uk(_e,v(`workspace.defaultName`)),ye=/* @__PURE__ */ (0,h.jsxs)(`div`,{className:Q.heroTopBarInner,children:[d(`conversation.hero.workspace`,{open:le,anchorRef:pe,selectedId:he===null?void 0:he??me?.workspaceId,fallbackLabel:ve,onOpenChange:ue,onPick:e=>{ue(!1);let t={id:e};fe(t);let n=()=>fe(e=>e===t?void 0:e);p(e).then(n,n)},onClose:()=>{ue(!1)}},{fallback:/* @__PURE__ */ (0,h.jsx)(mk,{buttonRef:pe,label:ve??(ae.canStartProjectless?v(`hero.noWorkspace`):void 0),projectless:ae.canStartProjectless===!0&&ve===void 0,menuOpen:le,onClick:()=>{ue(e=>!e)},t:v})}),/* @__PURE__ */ (0,h.jsx)(`div`,{className:Q.heroAgentPresetSeat,children:d(`conversation.hero.agentPreset`,{})})]}),be=ae.phase===`ready`&&!ae.canStartProjectless&&ve===void 0,xe=t===void 0&&se.state!==`idle`,Se=t!==void 0&&r&&b?.openState===`loading`&&!be,Ce=r&&de!==void 0,we=Ce||(t===void 0||b?.openState!==`open`)&&!be,Te=Ce||t===void 0||b?.openState!==`open`||r&&be,Ee=!Te&&oe!==void 0,De=d(`conversation.composer.bar`,{variant:r?`hero`:`composer`,...r?{topBar:ye}:{},...xe?{sessionCreation:se,onRetrySessionCreation:m,placeholder:v(`placeholder.hero`)}:Se?{disabled:!0,preparingDraft:!0,placeholder:v(`placeholder.hero`)}:Te?{disabled:!0,placeholder:v(we?`placeholder.preparing`:`placeholder.workspace`),...we?{}:{workspacePickerOpen:le,onRequestWorkspace:()=>{ue(!0)}}}:Ee?{blocked:oe,placeholder:oe.reason}:r?{placeholder:v(`placeholder.hero`)}:{}}),Oe=/* @__PURE__ */ (0,h.jsxs)(`div`,{className:eC(Q.composerStack,r&&Q.composerHero),children:[r&&/* @__PURE__ */ (0,h.jsx)(gk,{t:v,renderSlot:d}),/* @__PURE__ */ (0,h.jsx)(xk,{session:b,useInput:c,renderSlot:d}),De]}),ke=f(`conversation.composer`,{sessionId:t,session:b,pendingInteraction:b?.openState===`open`?re:void 0},{fallback:Oe,fallbackOnly:t===void 0,overlay:!0}),Ae=/* @__PURE__ */ (0,h.jsx)(`div`,{ref:C,className:Q.composerSeat,"data-composer-seat":``,"data-conversation-region":`composer`,children:ke});return/* @__PURE__ */ (0,h.jsxs)(`div`,{ref:ne,className:eC(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)(x,{}),Ae]}),/* @__PURE__ */ (0,h.jsx)(ee,{container:te,phase:n}),/* @__PURE__ */ (0,h.jsx)(yk,{container:te,editor:_,useSessions:a,t:v},t)]})}function wk({renderSlot:e}){return e(`main.conversation`,{})}function Tk(){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 Ek({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&&$O(i,a)===`blank`;return/* @__PURE__ */ (0,h.jsxs)(`header`,{className:eC(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:Tk}),/* @__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:Tk}),trailingAction:r(`conversation.header.trailing`,{})}),r(`conversation.header.shortcuts`,{restoreNavigationFocus:Tk})]})}function Dk(e,t){return(t===null?void 0:e.find(e=>e.id===t))??e.find(e=>e.id===`chat`)}function Ok({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=Dk(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&&$O(_,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 kk(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 Ak(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 jk({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=Dk(d,o(e=>e.view)),p=i(t=>kk(t,e),Ak),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:eC(Q.crumb,e.subagent&&Q.crumbSubagent,Q.crumbCurrent),children:e.displayTitle}):/* @__PURE__ */ (0,h.jsx)(`button`,{type:`button`,className:eC(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:eC(Q.tab,e.id===f?.id&&Q.tabActive),onClick:()=>{l(e.id)},children:e.label},e.id))})]})}function Mk(e){return/* @__PURE__ */ (0,h.jsx)(Ok,{...e})}function Nk({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 Pk({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 Fk({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)(Nk,{editor:l?null:t,editable:r,preserveFocus:a,className:eC(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)(Pk,{editor:l?null:t})]})})}function Ik(){return typeof window<`u`&&typeof window.matchMedia==`function`&&window.matchMedia(`(pointer: coarse)`).matches}function Lk(e,t){return e.isComposing||e.keyCode===229||t()}function Rk(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&&Lk(n,c);return t.arbitrate(e,r)!==`pass`&&(n?.preventDefault(),!0)};return Jb(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(Fp,l(`up`),4),e.registerCommand(Ip,l(`down`),4),e.registerCommand(jp,t=>e.getEditorState().read(()=>{let e=H();if(!V(e)||!e.isCollapsed())return!1;let t=e.anchor,n=t.getNode();if(!B(n))return!0;let r=n.getTextContent().charAt(t.offset);return r===``||/\s/u.test(r)})?l(`right`)(t):!1,4),e.registerCommand(Np,t=>e.getEditorState().read(()=>{let e=H();return V(e)&&e.isCollapsed()})?l(`left`)(t):!1,4),e.registerCommand(Hp,e=>l(e.shiftKey?`tabBack`:`tab`)(e),4),e.registerCommand(Bp,e=>(t.dismissPopup(),t.arbitrate(`escape`,Lk(e,c))===`consumed`&&(e.preventDefault(),!0)),4),e.registerCommand(Rp,e=>Lk(e,c)?!1:t.space()?(e.preventDefault(),!0):!1,4),e.registerCommand(Lp,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&&Lk(e,c)?!0:t.arbitrate(`enter`,!1)===`pass`?Ik()&&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(Cp,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 zk(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 Bk(e,t){e.getRootElement()?.focus({preventScroll:!0}),e.focus(()=>{t()})}function Vk(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 Hk(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 Uk(e,t,n){return e.bindFilePicker({available:()=>t.current.canAcceptDrop&&n.current!==null,open:()=>{n.current?.click()}})}function Wk(e,t,n){return Rk(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(PO(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 Gk(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 Kk(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 qk(e,t){(0,d.shouldAutoFocusTextInput)()&&(e.preventDefault(),t?.getRootElement()?.focus({preventScroll:!0}))}function Jk(e){let t=e/1048576;return`${Number.isInteger(t)?String(t):t.toFixed(1)}MB`}function Yk(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:Jk(n.maxImageBytes)});break;case`IMAGES_TOO_LARGE`:if(n!==void 0)return e(`image.totalTooLarge`,{size:Jk(n.maxMessageImageBytes)})}return e(`image.sendFailed`,{reason:t})}function Xk(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 Zk=`@deepseek-ai/dsh-client-ui-conversation/ContextMeter.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(Zk)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-conversation`,e.dataset.pluginCss=Zk,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 Qk={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 $k=5.5,eA=2*Math.PI*$k,tA=[{key:`systemTokens`,label:`context.system`,color:Qk.colorSystem},{key:`toolsTokens`,label:`context.tools`,color:Qk.colorTools},{key:`messageTokens`,label:`context.messages`,color:Qk.colorMessages}];function nA(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 rA({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=Xk(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}]:tA.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:Qk.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:Qk.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:Qk.track,cx:`7`,cy:`7`,r:$k}),/* @__PURE__ */ (0,h.jsx)(`circle`,{className:Qk.fill,cx:`7`,cy:`7`,r:$k,strokeDasharray:`${eA*f/100} ${eA}`,transform:`rotate(-90 7 7)`})]}),/* @__PURE__ */ (0,h.jsx)(`span`,{children:p})]})}),i&&(0,_.createPortal)(/* @__PURE__ */ (0,h.jsxs)(`div`,{ref:s,className:Qk.panel,style:u??{visibility:`hidden`,left:0,top:0},role:`dialog`,"aria-label":t(`context.used`),children:[/* @__PURE__ */ (0,h.jsxs)(`div`,{className:Qk.header,children:[/* @__PURE__ */ (0,h.jsx)(`span`,{className:Qk.headline,children:m}),/* @__PURE__ */ (0,h.jsx)(`span`,{className:Qk.percent,children:p}),/* @__PURE__ */ (0,h.jsx)(`span`,{className:Qk.headline,children:v}),/* @__PURE__ */ (0,h.jsx)(`span`,{className:Qk.figures,children:`~${nA(c.usedTokens,t)} / ${nA(c.contextWindow,t)}`})]}),/* @__PURE__ */ (0,h.jsx)(`div`,{className:Qk.bar,children:b.map(e=>/* @__PURE__ */ (0,h.jsx)(`div`,{className:e.color===void 0?Qk.segment:`${Qk.segment} ${e.color}`,style:{width:`${e.width}%`}},e.key))}),r!==void 0&&/* @__PURE__ */ (0,h.jsx)(`dl`,{className:Qk.rows,children:tA.map(e=>/* @__PURE__ */ (0,h.jsxs)(`div`,{className:Qk.row,children:[/* @__PURE__ */ (0,h.jsxs)(`dt`,{children:[/* @__PURE__ */ (0,h.jsx)(`span`,{className:`${Qk.swatch} ${e.color}`,"aria-hidden":!0}),t(e.label)]}),/* @__PURE__ */ (0,h.jsx)(`dd`,{children:`~${nA(r[e.key],t)}`})]},e.key))})]}),document.body)]})}function iA(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 aA=`@deepseek-ai/dsh-client-ui-conversation/InputBar.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(aA)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-conversation`,e.dataset.pluginCss=aA,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);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{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);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;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 oA=[],sA=(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:x,useMenuLauncher:ee,useStopShortcut:te,useProjection:ne,sessionId:re,variant:ie,disabled:ae=!1,preparingDraft:oe=!1,sessionCreation:se,onRetrySessionCreation:ce,blocked:le,workspacePickerOpen:ue=!1,onRequestWorkspace:de,placeholder:fe,topBar:pe,accessory:S}){let C=t(e=>e),me=_(e=>e),he=C?.responseAnnotations??oA,ge=C?.hoveredResponseAnnotationId,_e=(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]),ve=(0,g.useMemo)(()=>he.map(e=>({id:e.id,text:e.text,...e.annotation===void 0?{}:{annotation:e.annotation},canReveal:e.anchor!==void 0})),[he]),ye=b(e=>e),be=v(e=>e),xe=te(e=>e),Se=ee(e=>e===`command`),[Ce,we]=(0,g.useState)(!1);(0,g.useEffect)(()=>{we(!1)},[re]);let Te=e(e=>e.promptError)??null,Ee=e(e=>e.running)??!1,De=e(e=>e.subagent)??null,Oe=e(e=>e.removed)??!1,ke=ne(`plan`,e=>e!==void 0&&(e.pending?!e.active:e.active)),Ae=ne(`goal`,e=>e!=null),je=re===void 0&&i!==void 0&&se!==void 0&&se.state!==`idle`,Me=je&&se.state===`creating`,Ne=je&&se.state===`error`,Pe=je?se.token:void 0,Fe=C!==void 0&&r!==void 0&&n!==void 0,Ie=je?me:C?.draft??``,Le=C?.primaryAction,w=je?i.editor:r?.editor??null,Re=(0,g.useMemo)(()=>C===void 0||s===void 0?[]:s(C.attachmentIds),[s,C?.attachmentIds]),ze=Ie.trim()===``&&Re.length===0&&he.length===0,Be=y(e=>e),Ve=Re.some(e=>Be[e.id]?.status===`error`),[He,Ue]=(0,g.useState)(null),We=(0,g.useRef)(0),Ge=(0,g.useCallback)(e=>{We.current+=1,Ue({seq:We.current,text:e})},[]),Ke=(0,g.useCallback)(()=>{Ue(null)},[]),qe=ne(`imageLimits`),Je=ne(`attachmentInput`),Ye=ne(`queueState`),Xe=Je?.enabled!==!1,Ze=Je?.imagesOnly===!0;(0,g.useEffect)(()=>{if(Te===null)return;let{error:e}=Te;e.code===`session/writer-held`?Ge(p(`error.sessionInUse`)):e.code===`remote/turn-changed`?Ge(p(`error.steerTurnChanged`)):e.code===`remote/steer-unavailable`?Ge(p(`error.remoteSteerUnavailable`)):Ge(e.code===`session/attachment-invalid`||e.code===`subagent/attachment-invalid`?Yk(p,e.details.reason,qe):`${e.message} (${e.code})`)},[Te,Ge,p,qe]),(0,g.useEffect)(()=>{ye?.level===`error`&&Ge(ye.text)},[ye,Ge]);let Qe=(0,g.useRef)(null),[$e,et]=(0,g.useState)({phone:!1,overflowActions:!1});(0,g.useLayoutEffect)(()=>{let e=Qe.current;if(e!==null)return iA(e,et)},[]);let tt=(0,g.useRef)(null),nt=(0,g.useRef)(null),rt=De?.address.mode===`continuable`,it=rt&&De.parentAvailable!==!0,at=je||Oe||ae||!Fe||le!==void 0||it,ot=at,st=je||Oe||ae||!Fe,ct=C?.phase===`adjudicating`||C?.phase===`submitting`,lt=!je&&ae&&!Oe&&de!==void 0,ut=je||Fe&&!ct&&(!ot||!je&&oe&&Fe&&!Oe&&!it&&!lt),dt=Oe||!ut&&!lt,ft=De===null||De.address.mode===`continuable`,pt=!ot&&!ct&&ze&&Ee&&ft&&Ye?.previewOnly!==!0&&C.queue.length>0,mt=(0,g.useRef)(je),ht=(0,g.useRef)(!1);if(mt.current&&!je&&re!==void 0){let e=document.activeElement;e!==null&&tt.current?.contains(e)&&(ht.current=!0)}(0,g.useLayoutEffect)(()=>{mt.current=je},[je]),(0,g.useEffect)(()=>{C!==void 0&&n!==void 0&&Re.length!==C.attachmentIds.length&&n.pruneAttachments(Re.map(e=>e.id))},[Re,C?.attachmentIds,n]);let gt=()=>{zk(nt)};(0,g.useEffect)(()=>{je?w!==null&&(0,d.shouldAutoFocusTextInput)()&&Bk(w,gt):w!==null&&ut&&(ht.current?(ht.current=!1,Bk(w,gt)):!ot&&(0,d.shouldAutoFocusTextInput)()&&Bk(w,gt))},[je,Pe,ot,ut,re,w]),(0,g.useEffect)(()=>{ot||Ie===``||gt()},[Ie!==``]),(0,g.useEffect)(()=>Hk(nt),[]);let _t=(0,g.useRef)({sessionId:re,ids:new Set(Re.map(e=>e.id)),count:Re.length}),[vt,yt]=(0,g.useState)(0),bt=(0,g.useRef)(0);(0,g.useEffect)(()=>{let e=_t.current,t=e.sessionId!==re,n=vt!==bt.current;if(bt.current=vt,t){_t.current={sessionId:re,ids:new Set(Re.map(e=>e.id)),count:Re.length};return}let r=!1;for(let t of Re)e.ids.has(t.id)||(e.ids.add(t.id),r=!0);let i=e.count!==Re.length;e.count=Re.length;let a=(r||n)&&(0,d.shouldAutoFocusTextInput)();if(!a&&!i&&!r&&!n||w===null||!ut||ot)return;a&&Bk(w,gt);let o=window.requestAnimationFrame(()=>{let e=w.getRootElement();if(e===null)return;let t=e.ownerDocument.activeElement;a&&(t===null||t===e.ownerDocument.body||t===e.ownerDocument.documentElement)&&Bk(w,gt),Vk(w),gt()});return()=>{window.cancelAnimationFrame(o)}},[re,Re,vt,w,ut,ot]);let xt=(0,g.useCallback)((e,t)=>{if(De!==null||a===void 0||e.length===0)return;if(!Xe){Ge(p(`attachment.unavailable`));return}let n=(()=>{if(Ze&&e.some(e=>!(qe?.mediaTypes)?.includes(e.type)))return p(`image.unsupportedType`);if(qe!==void 0){let t=qe.mediaTypes,n=e.filter(e=>t.includes(e.type)),r=Re.filter(e=>e.kind===`image`);if(r.length+n.length>qe.maxImagesPerMessage)return p(`image.tooMany`,{count:qe.maxImagesPerMessage});if(n.some(e=>e.size>qe.maxImageBytes))return p(`image.fileTooLarge`,{size:Jk(qe.maxImageBytes)});if(r.reduce((e,t)=>e+t.file.size,0)+n.reduce((e,t)=>e+t.size,0)>qe.maxMessageImageBytes)return p(`image.totalTooLarge`,{size:Jk(qe.maxMessageImageBytes)})}return a(e,t)})();n===null?yt(e=>e+1):Ge(n)},[De,a,Xe,Ze,Re,qe,Ge,p]),St=Xe&&De===null&&!ot&&!ct&&a!==void 0,Ct=p(Xe?Ze?`input.imagesAndCommands`:`input.commands`:`input.commandsOnly`),wt=(0,g.useRef)(null),Tt=e=>{let t=e.target.files===null?[]:[...e.target.files];e.target.value=``,t.length>0&&xt(t)},Et=(0,g.useRef)({locked:ot,canPasteText:ut,machineBusy:ct,primaryAction:Le,canSteerQueue:pt,running:Ee,steeringAvailable:ft,busyEnter:be,intakeFiles:xt,uploadsFailed:Ve,showToast:Ge,t:p,canAcceptDrop:St});Et.current={locked:ot,canPasteText:ut,machineBusy:ct,primaryAction:Le,canSteerQueue:pt,running:Ee,steeringAvailable:ft,busyEnter:be,intakeFiles:xt,uploadsFailed:Ve,showToast:Ge,t:p,canAcceptDrop:St},(0,g.useEffect)(()=>{if(r!==void 0)return Uk(r,Et,wt)},[r]),(0,g.useEffect)(()=>{if(w!==null){if(je&&i!==void 0)return Rk(w,{arbitrate:()=>`pass`,space:()=>!1,dismissPopup:()=>{},canSubmit:()=>!1,submit:()=>{},intakeFiles:()=>{Et.current.showToast(Et.current.t(`newSession.uploadUnavailable`))},pasteText:e=>{i.paste(e)}});if(r!==void 0)return Wk(w,r,Et)}},[w,r,je,i]);let Dt=e=>{qk(e,w)},Ot=e=>{!jt&&e.button===0&&Gk(e.currentTarget.ownerDocument),qk(e,w)},kt=()=>{r!==void 0&&(w!==null&&(0,d.shouldAutoFocusTextInput)()&&Bk(w,gt),u?.(r.caretSpan()))},At=e=>{lt&&(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),de())},jt=Le===void 0&&Ee&&De===null&&(ze||le!==void 0),Mt=jt?f===void 0:(Le===void 0?ze:Le.disabled)||at||ct,Nt=Ee&&rt,Pt=PO(be,Ee,`enter`,ft),Ft=!ze&&C?.phase===`plain`&&!Ie.trimStart().startsWith(`/`),It=p(jt?`input.stop`:Le===void 0&&Ee&&ft&&!at&&!Ve&&Ft?Pt===`steer`?`input.send.steer`:`input.send.queue`:`input.send`),Lt=()=>{(0,d.shouldAutoFocusTextInput)()||Kk(w)},Rt=()=>{Lt(),f?.()},zt=()=>{jt?Rt():Ve?Ge(p(`file.retryOrRemove`)):Le===void 0?r!==void 0&&!ze&&!at&&!ct&&(Lt(),r.submit(Pt,`click`)):Mt||(Lt(),Le.run())},Bt=(C?.phase===`claimed`||C?.phase===`submitting`)&&C.claim!==void 0&&Ie.startsWith(C.claim.token),Vt=Bt&&C.claim.hint!==void 0&&Ie.slice(C.claim.token.length).trim()===``?C.claim.hint:null,Ht=(()=>{if(Vt===null)return null;let e=C?.claim?.name??``,t=`hint.${e===`goal`&&Ae?`goal.active`:e}`,n=p(t);return n===t?Vt:n})(),Ut=fe??p(it?`placeholder.parentOffline`:at?`placeholder.unavailable`:pt?`placeholder.steerQueue`:ke?`placeholder.plan`:`placeholder.default`);return/* @__PURE__ */ (0,h.jsxs)(`div`,{className:eC($.root,ie===`hero`&&$.hero),"data-composer-variant":ie,children:[He!==null&&/* @__PURE__ */ (0,h.jsx)(d.Toast,{text:He.text,icon:/* @__PURE__ */ (0,h.jsx)(d.IconWarningOutlineRegular,{}),anchor:tt.current,onDone:Ke},He.seq),ye?.level===`info`&&/* @__PURE__ */ (0,h.jsx)(`div`,{className:$.notice,role:`status`,children:ye.text}),/* @__PURE__ */ (0,h.jsxs)(`div`,{className:$.cardStack,children:[pe!==void 0&&/* @__PURE__ */ (0,h.jsx)(`div`,{className:$.topRail,"data-composer-top-bar":``,onClick:e=>{e.stopPropagation()},onPointerDown:e=>{e.stopPropagation()},children:pe}),/* @__PURE__ */ (0,h.jsxs)(`div`,{ref:tt,className:eC($.card,lt&&$.cardWorkspaceTrigger),"data-composer-card":!0,onClick:lt?de:void 0,onPointerDown:lt?e=>{e.stopPropagation()}:void 0,children:[re!==void 0&&/* @__PURE__ */ (0,h.jsx)(`div`,{className:$.overlayAnchor,children:m(`conversation.input.overlay`,{})}),S!==void 0&&/* @__PURE__ */ (0,h.jsx)(`div`,{className:$.accessory,children:S}),Ne&&/* @__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:se.reason===`no-harness`?p(`newSession.createFailed.noHarness`):se.reason===`workspace-required`?p(`newSession.createFailed.workspaceRequired`):se.message??p(`newSession.createFailed.generic`)})]}),ce!==void 0&&/* @__PURE__ */ (0,h.jsx)(`button`,{type:`button`,className:$.creationRetry,onMouseDown:Dt,onClick:ce,children:p(`newSession.retry`)})]}),ve.length===0?null:/* @__PURE__ */ (0,h.jsx)(`div`,{className:$.annotations,children:/* @__PURE__ */ (0,h.jsx)(d.ResponseAnnotationTray,{annotations:ve,hoveredId:ge,disabled:ot||ct,labels:_e,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()}})}),C===void 0||re===void 0?null:/* @__PURE__ */ (0,h.jsx)(`div`,{className:$.inlineNotices,children:m(`conversation.input.notice`,{})}),m(`conversation.input.attachments`,{attachments:Re,canAcceptDrop:St,onAddFiles:xt,onRemoveAttachment:e=>{o?.(e)},uploads:Be,onRetryFile:e=>{c?.(e)},dropLimits:qe===void 0?void 0:{count:qe.maxImagesPerMessage,size:Jk(qe.maxImageBytes)}}),/* @__PURE__ */ (0,h.jsx)(Fk,{classNames:$,editor:w,scrollRef:nt,editable:ut,editorDisabled:dt,preserveFocus:ht.current,phase:je?`plain`:C?.phase??`inert`,placeholderText:Ut,ariaLabel:lt?p(`hero.chooseWorkspace`):Ut,workspaceTrigger:lt,workspacePickerOpen:ue,onWorkspaceKeyDown:At,hint:Ht,showPlaceholder:Ie===``&&Re.length===0&&!Bt}),/* @__PURE__ */ (0,h.jsx)(`div`,{ref:Qe,className:$.row,"data-composer-toolbar":!0,"data-command-menu-open":Se||void 0,"data-toolbar-activity":Ce||void 0,children:/* @__PURE__ */ (0,h.jsxs)(`div`,{className:$.controlScroll,"data-toolbar-scroll":!0,children:[/* @__PURE__ */ (0,h.jsxs)(`div`,{className:$.tools,hidden:Ce,"data-composer-tools":!0,children:[/* @__PURE__ */ (0,h.jsx)(`div`,{className:$.addSeat,"data-toolbar-fixed":`start`,children:/* @__PURE__ */ (0,h.jsx)(d.Tooltip,{portal:$e.phone,label:Ct,side:`top`,delayMs:500,children:/* @__PURE__ */ (0,h.jsx)(`button`,{type:`button`,className:$.add,"aria-label":Ct,"aria-haspopup":`listbox`,"aria-expanded":Se,disabled:ot||ct||u===void 0,onMouseDown:Dt,onClick:kt,children:/* @__PURE__ */ (0,h.jsx)(d.IconPlusOutlineMedium,{size:14})})})}),/* @__PURE__ */ (0,h.jsx)(`input`,{ref:wt,type:`file`,accept:Ze?qe?.mediaTypes.join(`,`):void 0,multiple:!0,disabled:!Xe||De!==null,hidden:!0,onChange:Tt}),/* @__PURE__ */ (0,h.jsxs)(`div`,{className:$.modes,children:[re===void 0?null:m(`conversation.input.permission`,{locked:ot}),re===void 0?null:m(`conversation.input.plan`,{locked:ot})]}),C===void 0||re===void 0?null:m(`conversation.input.left`,{})]}),/* @__PURE__ */ (0,h.jsxs)(`div`,{className:eC($.trailing,Ce&&$.trailingActive),children:[/* @__PURE__ */ (0,h.jsxs)(`div`,{className:$.standardControls,hidden:Ce,children:[C===void 0||re===void 0?null:m(`conversation.input.right`,{overflowActions:$e.overflowActions}),re===void 0?Me?/* @__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:st})]}),C===void 0||re===void 0?null:/* @__PURE__ */ (0,h.jsx)(`div`,{className:Ce?$.activityExpanded:$.activity,children:m(`conversation.input.activity`,{locked:ot,onActiveChange:we})}),/* @__PURE__ */ (0,h.jsxs)(`div`,{className:$.submitSeat,"data-toolbar-fixed":`end`,children:[Nt&&/* @__PURE__ */ (0,h.jsx)(d.Tooltip,{portal:$e.phone,label:p(`input.stop`),shortcutKeys:xe,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:Dt,onClick:Rt,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:$e.phone,label:jt?p(`input.stop`):It,shortcutKeys:jt?xe:void 0,side:`top`,delayMs:500,disabled:Mt,children:/* @__PURE__ */ (0,h.jsx)(`button`,{type:`button`,className:$.primary,"aria-label":It,disabled:Mt,onMouseDown:Ot,onClick:zt,children:jt?/* @__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,children:[ie===`composer`&&C!==void 0&&re!==void 0?m(`conversation.composer.dock`,{}):null,Ce?null:/* @__PURE__ */ (0,h.jsx)(rA,{useProjection:ne,t:p})]})]})}),cA=`@deepseek-ai/dsh-client-ui-conversation/TodoPanel.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(cA)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-conversation`,e.dataset.pluginCss=cA,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 lA={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:Bk(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 Hk({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=Rk();r===null?t.style.removeProperty(`--dsh-chat-user-width`):t.style.setProperty(`--dsh-chat-user-width`,`${zk(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:zk(e.offsetWidth,Rk()),[e]),i=(0,g.useCallback)(t=>{e!==null&&(e.parentElement??e).style.setProperty(`--dsh-chat-user-width`,`${zk(e.offsetWidth,t)}px`)},[e]),a=(0,g.useCallback)(t=>{e!==null&&localStorage.setItem(Lk,`${zk(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)(Vk,{side:e,onStart:r,onDrag:i,onCommit:a,onEnd:o},e))}let Uk={widthControls:Hk};function Wk(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`:Fk(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:Uk})]})}function Gk(e){return/* @__PURE__ */ (0,h.jsx)(Wk,{...e})}function Kk(e,t){return e===`default-workspace`?t:e}let qk=`@deepseek-ai/dsh-client-ui-conversation/HeroShell.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(qk)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-conversation`,e.dataset.pluginCss=qk,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 Jk={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 Yk(e){let t=Qu(e);return t===``?e:t}function Xk({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:Jk.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:Jk.folder,size:16}):/* @__PURE__ */ (0,h.jsx)(d.IconFolderOpenRegular,{className:Jk.folder,size:16}),/* @__PURE__ */ (0,h.jsx)(`span`,{className:Jk.workspaceLabel,children:t??a(`hero.chooseWorkspace`)}),/* @__PURE__ */ (0,h.jsx)(d.IconChevronDownOutlineRegular,{className:Jk.chevron,size:12})]})}function Zk({hovering:e}){return/* @__PURE__ */ (0,h.jsx)(`svg`,{className:Jk.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 Qk({t:e,renderSlot:t,children:n}){let[r,i]=(0,g.useState)(!1);return/* @__PURE__ */ (0,h.jsxs)(`div`,{className:Jk.root,children:[/* @__PURE__ */ (0,h.jsxs)(`div`,{className:Jk.stack,children:[/* @__PURE__ */ (0,h.jsxs)(`div`,{className:Jk.headline,children:[/* @__PURE__ */ (0,h.jsx)(`span`,{className:Jk.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:Jk.fish},{fallback:/* @__PURE__ */ (0,h.jsx)(Zk,{hovering:r})})}),/* @__PURE__ */ (0,h.jsxs)(`span`,{className:Jk.titleGroup,children:[/* @__PURE__ */ (0,h.jsx)(`span`,{children:e(`hero.headline`)}),/* @__PURE__ */ (0,h.jsxs)(`span`,{className:Jk.previewBadge,children:[/* @__PURE__ */ (0,h.jsx)(`span`,{className:Jk.previewBadgeWeb,children:e(`hero.preview`)}),/* @__PURE__ */ (0,h.jsx)(`span`,{className:Jk.previewBadgeDesktop,children:e(`hero.previewDesktop`)})]})]})]}),/* @__PURE__ */ (0,h.jsx)(`div`,{className:Jk.body})]}),n]})}let $k=`@deepseek-ai/dsh-client-ui-conversation/ThreadReferenceDropTarget.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify($k)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-conversation`,e.dataset.pluginCss=$k,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 eA={hint:`tWXKHq_hint`,invitation:`tWXKHq_invitation`,overlay:`tWXKHq_overlay`,preview:`tWXKHq_preview`,title:`tWXKHq_title`};function tA({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:eA.overlay,"data-thread-reference-drop":!0,role:`status`,"aria-live":`polite`,children:/* @__PURE__ */ (0,h.jsxs)(`div`,{className:eA.invitation,children:[/* @__PURE__ */ (0,h.jsx)(`div`,{className:eA.hint,children:r(`reference.dropTitle`)}),/* @__PURE__ */ (0,h.jsxs)(`div`,{className:eA.preview,"data-thread-reference-preview":!0,children:[/* @__PURE__ */ (0,h.jsx)(d.ReferenceIconRegular,{kind:`session`,size:20}),/* @__PURE__ */ (0,h.jsx)(`span`,{className:eA.title,children:o.title})]})]})})}let nA=`data-selection-drag`,rA=[`pointerup`,`pointercancel`,`dragstart`,`contextmenu`];function iA(e){let t=e.ownerDocument.defaultView;if(t===null)return()=>{};let n=()=>{e.removeAttribute(nA);for(let e of rA)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(nA,``);for(let e of rA)t.addEventListener(e,n,!0);t.addEventListener(`blur`,n)}};return e.addEventListener(`pointerdown`,r,!0),()=>{e.removeEventListener(`pointerdown`,r,!0),n()}}function aA({renderSlot:e}){return e(`conversation.session`,{})}function oA({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 sA(){return null}function cA(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`,aA),te=y(`widthControls`,sA),[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:iA(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:Yk(ae))),ye=ve===void 0?void 0:Kk(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)(Xk,{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)(Qk,{t:v,renderSlot:d}),/* @__PURE__ */ (0,h.jsx)(oA,{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)(tA,{container:ne,editor:_,useSessions:a,t:v},t)]})}function lA({renderSlot:e}){return e(`main.conversation`,{})}function uA(){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 dA({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&&Fk(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:uA}),/* @__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:uA}),trailingAction:r(`conversation.header.trailing`,{})}),r(`conversation.header.shortcuts`,{restoreNavigationFocus:uA})]})}function fA(e,t){return(t===null?void 0:e.find(e=>e.id===t))??e.find(e=>e.id===`chat`)}function pA({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=fA(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&&Fk(_,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 mA(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 hA(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 gA({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=fA(d,o(e=>e.view)),p=i(t=>mA(t,e),hA),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 _A(e){return/* @__PURE__ */ (0,h.jsx)(pA,{...e})}function vA({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 yA({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 bA({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)(vA,{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)(yA,{editor:l?null:t})]})})}function xA(){return typeof window<`u`&&typeof window.matchMedia==`function`&&window.matchMedia(`(pointer: coarse)`).matches}function SA(e,t){return e.isComposing||e.keyCode===229||t()}function CA(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&&SA(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`,SA(e,c))===`consumed`&&(e.preventDefault(),!0)),4),e.registerCommand(Gp,e=>SA(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&&SA(e,c)?!0:t.arbitrate(`enter`,!1)===`pass`?xA()&&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 wA(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 TA(e,t){e.getRootElement()?.focus({preventScroll:!0}),e.focus(()=>{t()})}function EA(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 DA(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 OA(e,t,n){return e.bindFilePicker({available:()=>t.current.canAcceptDrop&&n.current!==null,open:()=>{n.current?.click()}})}function kA(e,t,n){return CA(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(dk(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 AA(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 jA(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 MA(e,t){(0,d.shouldAutoFocusTextInput)()&&(e.preventDefault(),t?.getRootElement()?.focus({preventScroll:!0}))}function NA(e){let t=e/1048576;return`${Number.isInteger(t)?String(t):t.toFixed(1)}MB`}function PA(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:NA(n.maxImageBytes)});break;case`IMAGES_TOO_LARGE`:if(n!==void 0)return e(`image.totalTooLarge`,{size:NA(n.maxMessageImageBytes)})}return e(`image.sendFailed`,{reason:t})}function FA(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 IA=`@deepseek-ai/dsh-client-ui-conversation/ContextMeter.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(IA)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-conversation`,e.dataset.pluginCss=IA,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 LA={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 RA=5.5,zA=2*Math.PI*RA,BA=[{key:`systemTokens`,label:`context.system`,color:LA.colorSystem},{key:`toolsTokens`,label:`context.tools`,color:LA.colorTools},{key:`messageTokens`,label:`context.messages`,color:LA.colorMessages}];function VA(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 HA({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=FA(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}]:BA.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:LA.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:LA.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:LA.track,cx:`7`,cy:`7`,r:RA}),/* @__PURE__ */ (0,h.jsx)(`circle`,{className:LA.fill,cx:`7`,cy:`7`,r:RA,strokeDasharray:`${zA*f/100} ${zA}`,transform:`rotate(-90 7 7)`})]}),/* @__PURE__ */ (0,h.jsx)(`span`,{children:p})]})}),i&&(0,_.createPortal)(/* @__PURE__ */ (0,h.jsxs)(`div`,{ref:s,className:LA.panel,style:u??{visibility:`hidden`,left:0,top:0},role:`dialog`,"aria-label":t(`context.used`),children:[/* @__PURE__ */ (0,h.jsxs)(`div`,{className:LA.header,children:[/* @__PURE__ */ (0,h.jsx)(`span`,{className:LA.headline,children:m}),/* @__PURE__ */ (0,h.jsx)(`span`,{className:LA.percent,children:p}),/* @__PURE__ */ (0,h.jsx)(`span`,{className:LA.headline,children:v}),/* @__PURE__ */ (0,h.jsx)(`span`,{className:LA.figures,children:`~${VA(c.usedTokens,t)} / ${VA(c.contextWindow,t)}`})]}),/* @__PURE__ */ (0,h.jsx)(`div`,{className:LA.bar,children:b.map(e=>/* @__PURE__ */ (0,h.jsx)(`div`,{className:e.color===void 0?LA.segment:`${LA.segment} ${e.color}`,style:{width:`${e.width}%`}},e.key))}),r!==void 0&&/* @__PURE__ */ (0,h.jsx)(`dl`,{className:LA.rows,children:BA.map(e=>/* @__PURE__ */ (0,h.jsxs)(`div`,{className:LA.row,children:[/* @__PURE__ */ (0,h.jsxs)(`dt`,{children:[/* @__PURE__ */ (0,h.jsx)(`span`,{className:`${LA.swatch} ${e.color}`,"aria-hidden":!0}),t(e.label)]}),/* @__PURE__ */ (0,h.jsx)(`dd`,{children:`~${VA(r[e.key],t)}`})]},e.key))})]}),document.body)]})}function UA(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 WA=`@deepseek-ai/dsh-client-ui-conversation/InputBar.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(WA)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-conversation`,e.dataset.pluginCss=WA,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 GA=[],KA=(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??GA,_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(`goal`,e=>e!=null),Me=ie===void 0&&i!==void 0&&ce!==void 0&&ce.state!==`idle`,Ne=Me&&ce.state===`creating`,Pe=Me&&ce.state===`error`,Fe=Me?ce.token:void 0,Ie=S!==void 0&&r!==void 0&&n!==void 0,Le=Me?he:S?.draft??``,Re=S?.primaryAction,C=Me?i.editor:r?.editor??null,ze=(0,g.useMemo)(()=>S===void 0||s===void 0?[]:s(S.attachmentIds),[s,S?.attachmentIds]),Be=Le.trim()===``&&ze.length===0&&ge.length===0,Ve=y(e=>e),He=ze.some(e=>Ve[e.id]?.status===`error`),[Ue,We]=(0,g.useState)(null),Ge=(0,g.useRef)(0),Ke=(0,g.useCallback)(e=>{Ge.current+=1,We({seq:Ge.current,text:e})},[]),qe=(0,g.useCallback)(()=>{We(null)},[]),Je=re(`imageLimits`),Ye=re(`attachmentInput`),Xe=re(`queueState`),Ze=Ye?.enabled!==!1,Qe=Ye?.imagesOnly===!0;(0,g.useEffect)(()=>{if(Ee===null)return;let{error:e}=Ee;e.code===`session/writer-held`?Ke(p(`error.sessionInUse`)):e.code===`remote/turn-changed`?Ke(p(`error.steerTurnChanged`)):e.code===`remote/steer-unavailable`?Ke(p(`error.remoteSteerUnavailable`)):Ke(e.code===`session/attachment-invalid`||e.code===`subagent/attachment-invalid`?PA(p,e.details.reason,Je):`${e.message} (${e.code})`)},[Ee,Ke,p,Je]),(0,g.useEffect)(()=>{be?.level===`error`&&Ke(be.text)},[be,Ke]);let $e=(0,g.useRef)(null),[et,tt]=(0,g.useState)({phone:!1,overflowActions:!1});(0,g.useLayoutEffect)(()=>{let e=$e.current;if(e!==null)return UA(e,tt)},[]);let nt=(0,g.useRef)(null),rt=(0,g.useRef)(null),it=Oe?.address.mode===`continuable`,at=it&&Oe.parentAvailable!==!0,ot=Me||ke||oe||!Ie||ue!==void 0||at,st=ot,ct=Me||ke||oe||!Ie,lt=S?.phase===`adjudicating`||S?.phase===`submitting`,ut=!Me&&oe&&!ke&&fe!==void 0,dt=Me||Ie&&!lt&&(!st||!Me&&se&&Ie&&!ke&&!at&&!ut),ft=ke||!dt&&!ut,pt=Oe===null||Oe.address.mode===`continuable`,mt=!st&&!lt&&Be&&De&&pt&&Xe?.previewOnly!==!0&&S.queue.length>0,ht=(0,g.useRef)(Me),gt=(0,g.useRef)(!1);if(ht.current&&!Me&&ie!==void 0){let e=document.activeElement;e!==null&&nt.current?.contains(e)&&(gt.current=!0)}(0,g.useLayoutEffect)(()=>{ht.current=Me},[Me]),(0,g.useEffect)(()=>{S!==void 0&&n!==void 0&&ze.length!==S.attachmentIds.length&&n.pruneAttachments(ze.map(e=>e.id))},[ze,S?.attachmentIds,n]);let _t=()=>{wA(rt)};(0,g.useEffect)(()=>{Me?C!==null&&(0,d.shouldAutoFocusTextInput)()&&TA(C,_t):C!==null&&dt&&(gt.current?(gt.current=!1,TA(C,_t)):!st&&(0,d.shouldAutoFocusTextInput)()&&TA(C,_t))},[Me,Fe,st,dt,ie,C]),(0,g.useEffect)(()=>{st||Le===``||_t()},[Le!==``]),(0,g.useEffect)(()=>DA(rt),[]);let vt=(0,g.useRef)({sessionId:ie,ids:new Set(ze.map(e=>e.id)),count:ze.length}),[yt,bt]=(0,g.useState)(0),xt=(0,g.useRef)(0);(0,g.useEffect)(()=>{let e=vt.current,t=e.sessionId!==ie,n=yt!==xt.current;if(xt.current=yt,t){vt.current={sessionId:ie,ids:new Set(ze.map(e=>e.id)),count:ze.length};return}let r=!1;for(let t of ze)e.ids.has(t.id)||(e.ids.add(t.id),r=!0);let i=e.count!==ze.length;e.count=ze.length;let a=(r||n)&&(0,d.shouldAutoFocusTextInput)();if(!a&&!i&&!r&&!n||C===null||!dt||st)return;a&&TA(C,_t);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)&&TA(C,_t),EA(C),_t()});return()=>{window.cancelAnimationFrame(o)}},[ie,ze,yt,C,dt,st]);let St=(0,g.useCallback)((e,t)=>{if(Oe!==null||a===void 0||e.length===0)return;if(!Ze){Ke(p(`attachment.unavailable`));return}let n=(()=>{if(Qe&&e.some(e=>!(Je?.mediaTypes)?.includes(e.type)))return p(`image.unsupportedType`);if(Je!==void 0){let t=Je.mediaTypes,n=e.filter(e=>t.includes(e.type)),r=ze.filter(e=>e.kind===`image`);if(r.length+n.length>Je.maxImagesPerMessage)return p(`image.tooMany`,{count:Je.maxImagesPerMessage});if(n.some(e=>e.size>Je.maxImageBytes))return p(`image.fileTooLarge`,{size:NA(Je.maxImageBytes)});if(r.reduce((e,t)=>e+t.file.size,0)+n.reduce((e,t)=>e+t.size,0)>Je.maxMessageImageBytes)return p(`image.totalTooLarge`,{size:NA(Je.maxMessageImageBytes)})}return a(e,t)})();n===null?bt(e=>e+1):Ke(n)},[Oe,a,Ze,Qe,ze,Je,Ke,p]),Ct=Ze&&Oe===null&&!st&&!lt&&a!==void 0,wt=p(Ze?Qe?`input.imagesAndCommands`:`input.commands`:`input.commandsOnly`),Tt=(0,g.useRef)(null),Et=e=>{let t=e.target.files===null?[]:[...e.target.files];e.target.value=``,t.length>0&&St(t)},Dt=(0,g.useRef)({locked:st,canPasteText:dt,machineBusy:lt,primaryAction:Re,canSteerQueue:mt,running:De,steeringAvailable:pt,busyEnter:xe,intakeFiles:St,uploadsFailed:He,showToast:Ke,t:p,canAcceptDrop:Ct});Dt.current={locked:st,canPasteText:dt,machineBusy:lt,primaryAction:Re,canSteerQueue:mt,running:De,steeringAvailable:pt,busyEnter:xe,intakeFiles:St,uploadsFailed:He,showToast:Ke,t:p,canAcceptDrop:Ct},(0,g.useEffect)(()=>{if(r!==void 0)return OA(r,Dt,Tt)},[r]),(0,g.useEffect)(()=>{if(C!==null){if(Me&&i!==void 0)return CA(C,{arbitrate:()=>`pass`,space:()=>!1,dismissPopup:()=>{},canSubmit:()=>!1,submit:()=>{},intakeFiles:()=>{Dt.current.showToast(Dt.current.t(`newSession.uploadUnavailable`))},pasteText:e=>{i.paste(e)}});if(r!==void 0)return kA(C,r,Dt)}},[C,r,Me,i]);let Ot=e=>{MA(e,C)},kt=e=>{!Mt&&e.button===0&&AA(e.currentTarget.ownerDocument),MA(e,C)},At=()=>{r!==void 0&&(C!==null&&(0,d.shouldAutoFocusTextInput)()&&TA(C,_t),u?.(r.caretSpan()))},jt=e=>{ut&&(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),fe())},Mt=Re===void 0&&De&&Oe===null&&(Be||ue!==void 0),Nt=Mt?f===void 0:(Re===void 0?Be:Re.disabled)||ot||lt,Pt=De&&it,Ft=dk(xe,De,`enter`,pt),It=!Be&&S?.phase===`plain`&&!Le.trimStart().startsWith(`/`),Lt=p(Mt?`input.stop`:Re===void 0&&De&&pt&&!ot&&!He&&It?Ft===`steer`?`input.send.steer`:`input.send.queue`:`input.send`),Rt=()=>{(0,d.shouldAutoFocusTextInput)()||jA(C)},zt=()=>{Rt(),f?.()},Bt=()=>{Mt?zt():He?Ke(p(`file.retryOrRemove`)):Re===void 0?r!==void 0&&!Be&&!ot&&!lt&&(Rt(),r.submit(Ft,`click`)):Nt||(Rt(),Re.run())},Vt=(S?.phase===`claimed`||S?.phase===`submitting`)&&S.claim!==void 0&&Le.startsWith(S.claim.token),Ht=Vt&&S.claim.hint!==void 0&&Le.slice(S.claim.token.length).trim()===``?S.claim.hint:null,Ut=(()=>{if(Ht===null)return null;let e=S?.claim?.name??``,t=`hint.${e===`goal`&&je?`goal.active`:e}`,n=p(t);return n===t?Ht:n})(),Wt=pe??p(at?`placeholder.parentOffline`:ot?`placeholder.unavailable`:mt?`placeholder.steerQueue`:Ae?`placeholder.plan`:`placeholder.default`);return/* @__PURE__ */ (0,h.jsxs)(`div`,{className:sC($.root,ae===`hero`&&$.hero),"data-composer-variant":ae,children:[Ue!==null&&/* @__PURE__ */ (0,h.jsx)(d.Toast,{text:Ue.text,icon:/* @__PURE__ */ (0,h.jsx)(d.IconWarningOutlineRegular,{}),anchor:nt.current,onDone:qe},Ue.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:nt,className:sC($.card,ut&&$.cardWorkspaceTrigger),"data-composer-card":!0,onClick:ut?fe:void 0,onPointerDown:ut?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}),Pe&&/* @__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:Ot,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:st||lt,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:ze,canAcceptDrop:Ct,onAddFiles:St,onRemoveAttachment:e=>{o?.(e)},uploads:Ve,onRetryFile:e=>{c?.(e)},dropLimits:Je===void 0?void 0:{count:Je.maxImagesPerMessage,size:NA(Je.maxImageBytes)}}),/* @__PURE__ */ (0,h.jsx)(bA,{classNames:$,editor:C,scrollRef:rt,editable:dt,editorDisabled:ft,preserveFocus:gt.current,phase:Me?`plain`:S?.phase??`inert`,placeholderText:Wt,ariaLabel:ut?p(`hero.chooseWorkspace`):Wt,workspaceTrigger:ut,workspacePickerOpen:de,onWorkspaceKeyDown:jt,hint:Ut,showPlaceholder:Le===``&&ze.length===0&&!Vt}),/* @__PURE__ */ (0,h.jsx)(`div`,{ref:$e,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:et.phone,label:wt,side:`top`,delayMs:500,children:/* @__PURE__ */ (0,h.jsx)(`button`,{type:`button`,className:$.add,"aria-label":wt,"aria-haspopup":`listbox`,"aria-expanded":Ce,disabled:st||lt||u===void 0,onMouseDown:Ot,onClick:At,children:/* @__PURE__ */ (0,h.jsx)(d.IconPlusOutlineMedium,{size:14})})})}),/* @__PURE__ */ (0,h.jsx)(`input`,{ref:Tt,type:`file`,accept:Qe?Je?.mediaTypes.join(`,`):void 0,multiple:!0,disabled:!Ze||Oe!==null,hidden:!0,onChange:Et}),/* @__PURE__ */ (0,h.jsxs)(`div`,{className:$.modes,children:[ie===void 0?null:m(`conversation.input.permission`,{locked:st}),ie===void 0?null:m(`conversation.input.plan`,{locked:st})]}),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:et.overflowActions}),ie===void 0?Ne?/* @__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:ct})]}),S===void 0||ie===void 0?null:/* @__PURE__ */ (0,h.jsx)(`div`,{className:we?$.activityExpanded:$.activity,children:m(`conversation.input.activity`,{locked:st,onActiveChange:Te})}),/* @__PURE__ */ (0,h.jsxs)(`div`,{className:$.submitSeat,"data-toolbar-fixed":`end`,children:[Pt&&/* @__PURE__ */ (0,h.jsx)(d.Tooltip,{portal:et.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:Ot,onClick:zt,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:et.phone,label:Mt?p(`input.stop`):Lt,shortcutKeys:Mt?Se:void 0,side:`top`,delayMs:500,disabled:Nt,children:/* @__PURE__ */ (0,h.jsx)(`button`,{type:`button`,className:$.primary,"aria-label":Lt,disabled:Nt,onMouseDown:kt,onClick:Bt,children:Mt?/* @__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)(HA,{useProjection:re,t:p})]})]})}),qA=`@deepseek-ai/dsh-client-ui-conversation/TodoPanel.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(qA)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-conversation`,e.dataset.pluginCss=qA,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 JA={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`};
168
172
  /* v8 ignore next 3 -- closed-union backstop; only reached if status is forged */
169
- function uA(e){throw Error(`unreachable todo status: ${String(e)}`)}function dA(e){switch(e){case`completed`:return`done`;case`in_progress`:return`ongoing`;case`pending`:return`idle`;
173
+ function YA(e){throw Error(`unreachable todo status: ${String(e)}`)}function XA(e){switch(e){case`completed`:return`done`;case`in_progress`:return`ongoing`;case`pending`:return`idle`;
170
174
  /* v8 ignore next -- closed TodoItem status union */
171
- default:return uA(e)}}function fA(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 YA(e)}}function ZA(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`);
172
176
  /* v8 ignore next -- closed TodoItem status union */
173
- default:return uA(e)}}function pA(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 mA({todos:e,t}){let[n,r]=(0,g.useState)(!0);return e.length===0?null:/* @__PURE__ */ (0,h.jsx)(`section`,{className:lA.root,"data-testid":`todo-panel`,"aria-label":t(`todo.title`),children:/* @__PURE__ */ (0,h.jsxs)(`div`,{className:lA.body,children:[/* @__PURE__ */ (0,h.jsxs)(`button`,{type:`button`,className:lA.header,"aria-expanded":!n,onClick:()=>{r(e=>!e)},children:[/* @__PURE__ */ (0,h.jsx)(`span`,{className:lA.lead,"aria-hidden":!0,children:/* @__PURE__ */ (0,h.jsx)(d.IconChecklistOutlineRegular,{})}),/* @__PURE__ */ (0,h.jsx)(`span`,{className:lA.title,children:t(`todo.title`)}),/* @__PURE__ */ (0,h.jsx)(`span`,{className:lA.progress,children:pA(e,t)}),/* @__PURE__ */ (0,h.jsx)(`span`,{className:lA.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:lA.list,children:e.map(e=>/* @__PURE__ */ (0,h.jsxs)(`li`,{className:lA.item,"data-status":e.status,children:[/* @__PURE__ */ (0,h.jsx)(`span`,{className:lA.glyph,role:`img`,"aria-label":fA(e.status,t),children:/* @__PURE__ */ (0,h.jsx)(d.StateDot,{state:dA(e.status)})}),/* @__PURE__ */ (0,h.jsx)(`span`,{className:lA.content,children:e.content})]},e.content))})]})})}function hA({useProjection:e,t}){let n=e(`todos`);return/* @__PURE__ */ (0,h.jsx)(mA,{todos:n??[],t})}let gA={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:qu},hA))}};var _A=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 vA(e,t,n,r,i){let a=()=>{},o=new _A(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 yA=[`slots`,`sessions`,`fileUpload`,`uiSession`,`uiWorkspace`,`locale`,`configForms`],bA=C.object({maxConcurrentFileUploads:C.natural().min(1).default(2)}),xA={getSnapshot:()=>null,subscribe:()=>()=>{}},SA={getSnapshot:()=>void 0,subscribe:()=>()=>{}},CA=/* @__PURE__ */ new Map,wA={getSnapshot:()=>CA,subscribe:()=>()=>{}},TA={getSnapshot:()=>null,subscribe:()=>()=>{}},EA={},DA={getSnapshot:()=>EA,subscribe:()=>()=>{}},OA={state:`idle`},kA={getSnapshot:()=>OA,subscribe:()=>()=>{}},AA={getSnapshot:()=>``,subscribe:()=>()=>{}};function jA(){return globalThis.__DSH_HOST_PATHS__}function MA(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 NA(e){let t=e.get(`conversation`);if(t===void 0)throw Error(`ui-conversation: conversation service unavailable`);return t}function PA(e,t=bA({})){let n=e.sessions,r=e.slots,i=t.maxConcurrentFileUploads,a=e.get(`uiWorkspace`),o=new Mt(e,n);e.effect(()=>e.locale.register(qu,{zh:Xu,en:Zu}),`ui-conversation: dictionaries`);let s=e.locale.bind(qu),c=Vu(),l=new FO(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:qu,inject:()=>({hooks:{busyEnter:l.busyEnter},setBusyEnter:e=>{l.setBusyEnter(e)}})},ZO));let u=()=>{let t=[];for(let n of r.entries(`conversation.view`))
177
+ default:return YA(e)}}function QA(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 $A({todos:e,t}){let[n,r]=(0,g.useState)(!0);return e.length===0?null:/* @__PURE__ */ (0,h.jsx)(`section`,{className:JA.root,"data-testid":`todo-panel`,"aria-label":t(`todo.title`),children:/* @__PURE__ */ (0,h.jsxs)(`div`,{className:JA.body,children:[/* @__PURE__ */ (0,h.jsxs)(`button`,{type:`button`,className:JA.header,"aria-expanded":!n,onClick:()=>{r(e=>!e)},children:[/* @__PURE__ */ (0,h.jsx)(`span`,{className:JA.lead,"aria-hidden":!0,children:/* @__PURE__ */ (0,h.jsx)(d.IconChecklistOutlineRegular,{})}),/* @__PURE__ */ (0,h.jsx)(`span`,{className:JA.title,children:t(`todo.title`)}),/* @__PURE__ */ (0,h.jsx)(`span`,{className:JA.progress,children:QA(e,t)}),/* @__PURE__ */ (0,h.jsx)(`span`,{className:JA.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:JA.list,children:e.map(e=>/* @__PURE__ */ (0,h.jsxs)(`li`,{className:JA.item,"data-status":e.status,children:[/* @__PURE__ */ (0,h.jsx)(`span`,{className:JA.glyph,role:`img`,"aria-label":ZA(e.status,t),children:/* @__PURE__ */ (0,h.jsx)(d.StateDot,{state:XA(e.status)})}),/* @__PURE__ */ (0,h.jsx)(`span`,{className:JA.content,children:e.content})]},e.content))})]})})}function ej({useProjection:e,t}){let n=e(`todos`);return/* @__PURE__ */ (0,h.jsx)($A,{todos:n??[],t})}let tj={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},ej))}};var nj=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 rj(e,t,n,r,i){let a=()=>{},o=new nj(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 ij=[`slots`,`sessions`,`fileUpload`,`uiSession`,`uiWorkspace`,`locale`,`configForms`],aj=S.object({maxConcurrentFileUploads:S.natural().min(1).default(2)}),oj={getSnapshot:()=>null,subscribe:()=>()=>{}},sj={getSnapshot:()=>void 0,subscribe:()=>()=>{}},cj=/* @__PURE__ */ new Map,lj={getSnapshot:()=>cj,subscribe:()=>()=>{}},uj={getSnapshot:()=>null,subscribe:()=>()=>{}},dj={},fj={getSnapshot:()=>dj,subscribe:()=>()=>{}},pj={state:`idle`},mj={getSnapshot:()=>pj,subscribe:()=>()=>{}},hj={getSnapshot:()=>``,subscribe:()=>()=>{}};function gj(){return globalThis.__DSH_HOST_PATHS__}function _j(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 vj(e){let t=e.get(`conversation`);if(t===void 0)throw Error(`ui-conversation: conversation service unavailable`);return t}function yj(e,t=aj({})){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 fk(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)}})},Nk));let u=()=>{let t=[];for(let n of r.entries(`conversation.view`))
174
178
  /* v8 ignore next -- list registration validates id at load. */
175
- 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=Dk(u(),t);n!==void 0&&o.binding(e).activate(n.id)},h=e=>{m(e,Uu(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 x=e=>{MA(n,e).cancel().catch(e=>{})},ee=(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(()=>vA(t.shortcuts,n,e=>o.binding(e).openTurn,e.uiSession,x),`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 ee.set(e.keys),()=>{ee.set([]),n()}},`ui-conversation: fixed stop reference`)});let te=new kO;e.effect(()=>{let e=a.creating;e!==void 0&&te.syncCreation(e.getSnapshot());let t=e?.subscribe(()=>{te.syncCreation(e.getSnapshot())});return()=>{t?.(),te.dispose()}},`ui-conversation: pending new-session draft`);let ne=new DO(e,s,te),re=new ud;e.inject([`commandUi`],e=>{let t=e.get(`commandUi`);e.effect(()=>t.register({name:`file`,label:()=>s(`input.file`),icon:d.IconPaperclipOutlineRegular,available:e=>ne.canPickFiles(e.sessionId),ui:{kind:`action`,run:e=>{ne.pickFiles(e.sessionId)}}}),`ui-conversation: File action`)}),e.uiSession.provide({hooks:[`conversation`,`input`],props:[`inputActions`],resolve:e=>{y(e);let t=ne.shellFor(e),n=o.binding(e);return h(e.sessionId),{hooks:{conversation:n.snapshot,input:t.state},props:{inputActions:t.actions}}}});let ie=()=>r.register({name:`main.conversation`,children:{"conversation.header":{kind:`single`,scope:`session-maybe`},"conversation.header.notice":{kind:`list`,scope:`session-maybe`}}},lk),ae=()=>r.registerFactory({name:`conversation.content`,scope:`session-maybe`,locale:qu,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:ne.shell(t).editor,retrySessionCreation:()=>{a.retryCreating?.()},hooks:{composerBlock:t===void 0?SA:re.storeFor(t),sessionCreation:a.creating??kA},selectWorkspace:r=>a.openWorkspace(r,r=>{if(t!==void 0&&r!==t){let i=ne.shell(t),a=i.draftSnapshot,o=i.snapshot.attachmentIds,s=ne.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(NA(e).rebindDraftFiles(r,o),a.text!==``&&(s.setDraft(a),i.setDraft(``)),o.length>0)for(let e of o)i.removeAttachment(e)}}})})},Ck),oe=()=>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=>ne.shell(e).bindDraftPersistence(t),onRevealResponseAnnotation:t=>n.scope(e)?.on(`conversation/reveal-response-annotation`,t)??(()=>{}),openView:r}}},Mk),se=()=>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`}}},Ek),ce=()=>r.register({name:`conversation.session.header`,locale:qu,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)}})},jk),le=()=>r.register({name:`conversation.composer.bar`,locale:qu,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:te.editor,paste:e=>{te.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:te.text,stopShortcut:ee,busyEnter:l.busyEnter,fileUploads:DA,notices:xA,lexicon:wA,menuLauncher:TA}};let r=NA(e),i=ne.shell(t),a=ne.inputTriggers(t),o=jA();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&&cd(t.type)){c.push(t);continue}let r=Ku(n,u),i=Wu({path:e?`${r}/`:r,kind:`file`},!1);if(i===void 0)return s(`attachment.pathUnsupported`);let d=Gu(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:()=>{x(t)},hooks:{pendingDraftText:AA,stopShortcut:ee,busyEnter:l.busyEnter,fileUploads:r.fileUploads,notices:i.notices,lexicon:i.lexicon,menuLauncher:a?.launcher??TA}}}},sA);e.inject([`conversation`],e=>e.slots.inject(`main`,function*(){yield r.register({name:`main`,key:`conversation`,children:{"main.conversation":{kind:`single`,scope:`session-maybe`}}},wk),yield ie(),yield ae(),yield oe(),yield se(),yield ce(),yield le()})),e.plugin(sd,{input:ne,blocks:re,maxConcurrentFileUploads:i}),e.plugin(gA),e.plugin(qO,ne)}return n.Config=bA,n.ConversationController=sd,n.ConversationDefinitionRegistry=mt,n.ConversationEventRegistry=ht,n.ConversationLocationIndex=Qe,n.ConversationNodeAssembler=dt,n.ConversationViewRegistry=kt,n.EMPTY_CONVERSATION_SNAPSHOT=QO,n.UiConversation=Mt,n.apply=PA,n.conversationPhase=$O,n.inject=yA,n.inspectRequestPrompt=Ne,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=fA(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=>{_j(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(()=>rj(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 ok;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 ik(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`}}},Gk),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?sj:ie.storeFor(t),sessionCreation:a.creating??mj},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(vj(e).rebindDraftFiles(r,o),a.text!==``&&(s.setDraft(a),i.setDraft(``)),o.length>0)for(let e of o)i.removeAttachment(e)}}})})},cA),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}}},_A),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`}}},dA),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)}})},gA),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:fj,notices:oj,lexicon:lj,menuLauncher:uj}};let r=vj(e),i=re.shell(t),a=re.inputTriggers(t),o=gj();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:hj,stopShortcut:te,busyEnter:l.busyEnter,fileUploads:r.fileUploads,notices:i.notices,lexicon:i.lexicon,menuLauncher:a?.launcher??uj}}}},KA);e.inject([`conversation`],e=>e.slots.inject(`main`,function*(){yield r.register({name:`main`,key:`conversation`,children:{"main.conversation":{kind:`single`,scope:`session-maybe`}}},lA),yield ae(),yield oe(),yield se(),yield ce(),yield le(),yield ue()})),e.plugin(md,{input:re,blocks:ie,maxConcurrentFileUploads:i}),e.plugin(tj),e.plugin(kk,re)}return n.Config=aj,n.ConversationController=md,n.ConversationDefinitionRegistry=ht,n.ConversationEventRegistry=gt,n.ConversationLocationIndex=$e,n.ConversationNodeAssembler=ft,n.ConversationViewRegistry=Nt,n.EMPTY_CONVERSATION_SNAPSHOT=Pk,n.UiConversation=zt,n.apply=yj,n.conversationPhase=Fk,n.inject=ij,n.inspectRequestPrompt=Pe,t.exports}});