@codexhost/cli-darwin-x64 0.22.0 → 0.24.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.
- package/README.md +1 -1
- package/app/codexhost-distribution.json +1 -1
- package/app/console-server.mjs +3117 -274
- package/app/console-web.js +15645 -4413
- package/app/desktop-controller.mjs +14057 -969
- package/app/host-runtime.mjs +11518 -8277
- package/app/plugins/antigravity/plugin.mjs +2030 -678
- package/app/plugins/claude-code/plugin.mjs +2116 -929
- package/app/plugins/codebuddy/plugin.mjs +1247 -353
- package/app/plugins/codex-usage/plugin.mjs +786 -163
- package/app/plugins/copilot/plugin.mjs +938 -296
- package/app/plugins/cursor-cli/plugin.mjs +1021 -232
- package/app/plugins/deepseek-harness/plugin.mjs +1552 -664
- package/app/plugins/devin/plugin.mjs +826 -185
- package/app/plugins/grok/plugin.mjs +1083 -424
- package/app/plugins/hermes/plugin.mjs +961 -338
- package/app/plugins/kimi-code/plugin.mjs +854 -237
- package/app/plugins/kiro-cli/plugin.mjs +821 -184
- package/app/plugins/omp/plugin.mjs +1316 -633
- package/app/plugins/opencode/plugin.mjs +1293 -606
- package/app/plugins/pi/plugin.mjs +1540 -867
- package/app/plugins/qoder/plugin.mjs +961 -332
- package/app/plugins/qoder-cn/plugin.mjs +961 -332
- package/app/plugins/qwen-code/plugin.mjs +937 -321
- package/app/plugins/workbuddy/plugin.mjs +1311 -370
- package/app/plugins/zcode/plugin.mjs +1516 -423
- package/app/renderer-extension.js +21297 -9060
- package/app/web/assets/index-CTCFIQbU.css +1 -0
- package/app/web/assets/index-IvFk9KT-.js +203 -0
- package/app/web/codexhost-settings.js +6753 -31616
- package/app/web/index.html +2 -2
- package/app/web/plugins/deepseek-ai__dsh-api-remotes/client.js +1 -1
- package/app/web/plugins/deepseek-ai__dsh-api-session-controller/client.js +69 -69
- package/app/web/plugins/deepseek-ai__dsh-client-ui-approval/client.js +1 -1
- package/app/web/plugins/deepseek-ai__dsh-client-ui-chat/client.js +14 -14
- package/app/web/plugins/deepseek-ai__dsh-client-ui-codexhost/client.js +75 -64
- package/app/web/plugins/deepseek-ai__dsh-client-ui-conversation/client.js +94 -91
- package/app/web/plugins/deepseek-ai__dsh-client-ui-input-trigger/client.js +1 -1
- package/app/web/plugins/deepseek-ai__dsh-client-ui-layout/client.js +2 -2
- package/app/web/plugins/deepseek-ai__dsh-client-ui-model-selection/client.js +2 -2
- package/app/web/plugins/deepseek-ai__dsh-client-ui-settings-general/client.js +1 -1
- package/app/web/plugins/deepseek-ai__dsh-client-ui-sidebar/client.js +2 -2
- package/app/web/plugins/deepseek-ai__dsh-client-ui-sidebar-browser/client.js +1 -1
- package/app/web/plugins/deepseek-ai__dsh-client-ui-sidebar-documentpreview/client.js +9 -9
- package/app/web/plugins/deepseek-ai__dsh-client-ui-sidebar-right/client.js +1 -1
- package/app/web/plugins/deepseek-ai__dsh-client-ui-theme/client.js +1 -1
- package/app/web/plugins/deepseek-ai__dsh-client-ui-tool/client.js +79 -79
- package/app/web/plugins/deepseek-ai__dsh-client-ui-user-questions/client.js +3 -3
- package/app/web/plugins/deepseek-ai__dsh-client-ui-workspace/client.js +7 -7
- package/app/web/sw.js +8 -1
- package/app/web-modules/licenses/werift-NOTICES.txt +123 -0
- package/app/web-modules/licenses/werift-libwebrtc-NOTICES.txt +58 -0
- package/app/web-modules/server.mjs +40416 -11283
- package/bin/codexhost +0 -0
- package/libexec/codexhost-shim +0 -0
- package/libexec/codexhost-updater +0 -0
- package/package.json +1 -1
- package/app/web/assets/index-CN4a4sj0.js +0 -201
- package/app/web/assets/index-DJW4bmyx.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 ee(e,t){return Object.fromEntries(Object.entries(e).filter(([e,n])=>t(e,n)))}function b(e,t){return Object.fromEntries(Object.entries(e).map(([e,n])=>[e,t(n,e)]))}function x(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 S;(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})(S||={}),S.fromBase64,S.toBase64,S.fromHex,S.toHex;function ce(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(ce,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(ce,null,[i.value,t])),Reflect.defineProperty(r,n,i)}return r}function le(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 ue;(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})(ue||={});let de=Symbol.for(`schemastery`),fe=Symbol.for(`ValidationError`);globalThis.__schemastery_index__??=0,globalThis.__schemastery_refs__=void 0;var C=class extends TypeError{options;name=`ValidationError`;constructor(e,t){let n=`$`;for(let e of t.path||[])typeof e==`string`?n+=`.`+e:typeof e==`number`?n+=`[`+e+`]`:typeof e==`symbol`&&(n+=`[Symbol(${e.toString()})]`);n.startsWith(`.`)&&(n=n.slice(1)),super((n===`$`?``:`${n} `)+e),this.options=t}static is(e){return!!e?.[fe]}};Object.defineProperty(C.prototype,fe,{value:!0});let w=function(e){let t=function(e,n={}){return w.resolve(e,t,n)[0]};if(e.refs){let t=b(e.refs,e=>new w(e)),n=e=>t[e];for(let e in t){let r=t[e];r.sKey=n(r.sKey),r.inner=n(r.inner),r.list=r.list&&r.list.map(n),r.dict=r.dict&&b(r.dict,n)}return t[e.uid]}if(Object.assign(t,e),typeof t.callback==`string`)try{t.callback=Function(`return `+t.callback)()}catch{}return Object.defineProperty(t,"uid",{value:globalThis.__schemastery_index__++}),Object.setPrototypeOf(t,w.prototype),t.meta||={},t.toString=t.toString.bind(t),t};w.prototype=Object.create(Function.prototype),w.prototype[de]=!0,Object.defineProperty(w.prototype,"~standard",{get(){return{version:1,vendor:`schemastery`,validate:e=>{try{return{value:w.resolve(e,this,{})[0]}}catch(e){if(C.is(e))return{issues:[{message:e.message,path:e.options.path}]};throw e}}}}}),w.ValidationError=C,w.prototype.toJSON=function(){if(globalThis.__schemastery_refs__)return globalThis.__schemastery_refs__[this.uid]??=JSON.parse(JSON.stringify({...this})),this.uid;globalThis.__schemastery_refs__={[this.uid]:{...this}},globalThis.__schemastery_refs__[this.uid]=JSON.parse(JSON.stringify({...this}));let e={uid:this.uid,refs:globalThis.__schemastery_refs__};return globalThis.__schemastery_refs__=void 0,e},w.prototype.set=function(e,t){return this.dict[e]=t,this},w.prototype.push=function(e){return this.list.push(e),this};function pe(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 me(e){return e?.$value??e?.$inner}function he(e){return ee(e??{},e=>!e.startsWith(`$`))}w.prototype.i18n=function(e){let t=w(this),n=pe(t.meta.description,e);return Object.keys(n).length&&(t.meta.description=n),t.dict&&=b(t.dict,(t,n)=>t.i18n(b(e,e=>me(e)?.[n]??e?.[n]))),t.list&&=t.list.map((t,n)=>t.i18n(b(e,(e={})=>Array.isArray(me(e))?me(e)[n]:Array.isArray(e)?e[n]:he(e)))),t.inner&&=t.inner.i18n(b(e,e=>me(e)?me(e):he(e))),t.sKey&&=t.sKey.i18n(b(e,e=>e?.$key)),t},w.prototype.extra=function(e,t){let n=w(this);return n.meta={...n.meta,[e]:t},n};for(let e of[`required`,`disabled`,`collapse`,`hidden`,`loose`])Object.assign(w.prototype,{[e](t=!0){let n=w(this);return n.meta={...n.meta,[e]:t},n}});w.prototype.deprecated=function(){let e=w(this);return e.meta.badges||=[],e.meta.badges.push({text:`deprecated`,type:`danger`}),e},w.prototype.experimental=function(){let e=w(this);return e.meta.badges||=[],e.meta.badges.push({text:`experimental`,type:`warning`}),e},w.prototype.pattern=function(e){let t=w(this),n=x(e,[`source`,`flags`]);return t.meta={...t.meta,pattern:n},t},w.prototype.simplify=function(e){if(ie(e)&&(e=e.get()),le(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 le(t,this.meta.default,this.type===`dict`)?null:t}if(this.type===`array`||this.type===`tuple`){let t=[];return e.forEach((e,n)=>{let r=this.type===`array`?this.inner:this.list[n],i=r?r.simplify(e):e;t.push(i)}),t}if(this.type===`intersect`){let t={};for(let n of this.list)Object.assign(t,n.simplify(e));return t}if(this.type===`union`)for(let t of this.list)try{return w.resolve(e,t,{}),t.simplify(e)}catch{}return e},w.prototype.toString=function(e){return we[this.type]?.(this,e)??`Schema<${this.type}>`},w.prototype.role=function(e,t){let n=w(this);return n.meta={...n.meta,role:e,extra:t},n};for(let e of[`default`,`link`,`comment`,`description`,`max`,`min`,`step`])Object.assign(w.prototype,{[e](t){let n=w(this);return n.meta={...n.meta,[e]:t},n}});w.prototype.volatile=function(){if(this.meta.volatile)throw TypeError(`volatile schema is already wrapped`);return this.extra(`volatile`,!0)};let ge={},_e=Symbol(`checked-volatile-schema`);function ve(e,t=[],n=!1,r=/* @__PURE__ */ new Map){let i=r.get(e)??/* @__PURE__ */ new Set;if(i.has(n))return;if(i.add(n),r.set(e,i),e.meta?.volatile&&n)throw new C(`volatile fields require a fixed object path without an enclosing volatile field`,{path:t});let a=n||!!e.meta?.volatile;if(e.dict)for(let[n,i]of Object.entries(e.dict))ve(i,[...t,n],a,r);if(e.sKey&&ve(e.sKey,[...t,`<key>`],!0,r),e.inner&&(e.type!==`lazy`||e.inner[de])&&ve(e.inner,[...t,`*`],!0,r),e.list)for(let n=0;n<e.list.length;n++)ve(e.list[n],[...t,String(n)],!0,r)}w.extend=function(e,t){ge[e]=t},w.resolve=function(e,t,n={},r=!1){if(!t)return[e];if(n[_e]||(ve(t,n.path),n={...n,[_e]:!0}),t.meta?.volatile){let i=w(t);i.meta={...t.meta,volatile:!1};let[a,o]=w.resolve(e,i,n,r);try{return[re(a),o]}catch(e){throw new C(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 C(`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=ce(i)}let i=ge[t.type];if(!i)throw new C(`unsupported type "${t.type}"`,n);try{return i(e,t,n,r)}catch(e){if(!t.meta.loose)throw e;return[t.meta.default]}},w.from=function(e){if(v(e))return w.any();if([`string`,`number`,`boolean`].includes(typeof e))return w.const(e).required();if(e[de])return e;if(typeof e==`function`)switch(e){case String:return w.string().required();case Number:return w.number().required();case Boolean:return w.boolean().required();case Function:return w.function().required();default:return w.is(e).required()}else throw TypeError(`cannot infer schema from ${e}`)},w.lazy=function(e){let t=new w({type:`lazy`,builder:e,inner:{toJSON:()=>(t.inner[de]||(t.inner=t.builder(),t.inner.meta={...t.meta,...t.inner.meta}),t.inner.toJSON())}});return t},w.natural=function(){return w.number().step(1).min(0)},w.percent=function(){return w.number().step(.01).min(0).max(1).role(`slider`)},w.date=function(){return w.union([w.is(Date),w.transform(w.string().role(`datetime`),(e,t)=>{let n=new Date(e);if(isNaN(+n))throw new C(`invalid date "${e}"`,t);return n},!0)])},w.regExp=function(e=``){return w.union([w.is(RegExp),w.transform(w.string().role(`regexp`,{flag:e}),(t,n)=>{try{return new RegExp(t,e)}catch(e){throw new C(e.message,n)}},!0)])},w.arrayBuffer=function(e){return w.union([w.is(ArrayBuffer),w.is(SharedArrayBuffer),w.transform(w.any(),(e,t)=>{if(S.isSource(e))return S.fromSource(e);throw new C(`expected ArrayBufferSource but got ${e}`,t)},!0),...e?[w.transform(w.string(),(t,n)=>{try{return e===`base64`?S.fromBase64(t):S.fromHex(t)}catch(e){throw new C(e.message,n)}},!0)]:[]])},w.extend(`lazy`,(e,t,n,r)=>(t.inner[de]||(t.inner=t.builder(),t.inner.meta={...t.meta,...t.inner.meta},ve(t.inner,n.path,!0)),w.resolve(e,t.inner,n,r))),w.extend(`any`,e=>[e]),w.extend(`never`,(e,t,n)=>{throw new C(`expected nullable but got ${e}`,n)}),w.extend(`const`,(e,{value:t},n)=>{if(le(e,t))return[t];throw new C(`expected ${t} but got ${e}`,n)});function ye(e,t,n,r,i=!1){let{max:a=1/0,min:o=-1/0}=t;if(e>a)throw new C(`expected ${n} <= ${a} but got ${e}`,r);if(e<o&&!i)throw new C(`expected ${n} >= ${o} but got ${e}`,r)}w.extend(`string`,(e,{meta:t},n)=>{if(typeof e!=`string`)throw new C(`expected string but got ${e}`,n);if(t.pattern){let r=new RegExp(t.pattern.source,t.pattern.flags);if(!r.test(e))throw new C(`expect string to match regexp ${r}`,n)}return ye(e.length,t,`string length`,n),[e]});function be(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 xe(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(be(e,i)-be(t,i))%be(n,i)===0}w.extend(`number`,(e,{meta:t},n)=>{if(typeof e!=`number`)throw new C(`expected number but got ${e}`,n);ye(e,t,`number`,n);let{step:r}=t;if(r&&!xe(e,t.min??0,r))throw new C(`expected number multiple of ${r} but got ${e}`,n);return[e]}),w.extend(`boolean`,(e,t,n)=>{if(typeof e==`boolean`)return[e];throw new C(`expected boolean but got ${e}`,n)}),w.extend(`bitset`,(e,{bits:t,meta:n},r)=>{let i=0,a=[];if(typeof e==`number`){i=e;for(let n in t)e&t[n]&&a.push(n)}else if(Array.isArray(e)){a=e;for(let e of a){if(typeof e!=`string`)throw new C(`expected string but got ${e}`,r);e in t&&(i|=t[e])}}else throw new C(`expected number or array but got ${e}`,r);return i===n.default?[i]:[i,a]}),w.extend(`function`,(e,t,n)=>{if(typeof e==`function`)return[e];throw new C(`expected function but got ${e}`,n)}),w.extend(`is`,(e,{constructor:t},n)=>{if(typeof t==`function`){if(e instanceof t)return[e];throw new C(`expected ${t.name} but got ${e}`,n)}{if(v(e))throw new C(`expected ${t} but got ${e}`,n);let r=Object.getPrototypeOf(e);for(;r;){if(r.constructor?.name===t)return[e];r=Object.getPrototypeOf(r)}throw new C(`expected ${t} but got ${e}`,n)}});function Se(e,t,n,r){try{let[i,a]=w.resolve(e[t],n,{...r,path:[...r.path||[],t]});return a!==void 0&&(e[t]=a),i}catch(i){if(!r?.autofix)throw i;return delete e[t],n.meta.volatile?re(n.meta.default):n.meta.default}}w.extend(`array`,(e,{inner:t,meta:n},r)=>{if(!Array.isArray(e))throw new C(`expected array but got ${e}`,r);return ye(e.length,n,`array length`,r,!v(t.meta.default)),[e.map((n,i)=>Se(e,i,t,r))]}),w.extend(`dict`,(e,{inner:t,sKey:n},r,i)=>{if(!y(e))throw new C(`expected object but got ${e}`,r);let a={};for(let o in e){let s;try{s=w.resolve(o,n,r)[0]}catch(e){if(i)continue;throw e}a[s]=Se(e,o,t,r),e[s]=e[o],o!==s&&delete e[o]}return[a]}),w.extend(`tuple`,(e,{list:t},n,r)=>{if(!Array.isArray(e))throw new C(`expected array but got ${e}`,n);let i=t.map((t,r)=>Se(e,r,t,n));return r||i.push(...e.slice(t.length)),[i]});function Ce(e,t){for(let n in t)n in e||(e[n]=t[n])}w.extend(`object`,(e,{dict:t},n,r)=>{if(!y(e))throw new C(`expected object but got ${e}`,n);let i={};for(let r in t){let a=Se(e,r,t[r],n);(!v(a)||r in e)&&(i[r]=a)}return r||Ce(i,e),[i]}),w.extend(`union`,(e,{list:t,toString:n},r,i)=>{let a=[];for(let n of t)try{return w.resolve(e,n,r,i)}catch(e){a.push(e)}throw new C(`expected ${n()} but got ${JSON.stringify(e)}`,r)}),w.extend(`intersect`,(e,{list:t,toString:n},r,i)=>{if(!t.length)return[e];let a;for(let i of t){let t=w.resolve(e,i,r,!0)[0];if(!v(t)){if(v(a))a=t;else if(typeof a!=typeof t)throw new C(`expected ${n()} but got ${JSON.stringify(e)}`,r);else if(typeof t==`object`)Ce(a??={},t);else if(a!==t)throw new C(`expected ${n()} but got ${JSON.stringify(e)}`,r)}}return!i&&y(e)&&Ce(a,e),[a]}),w.extend(`transform`,(e,{inner:t,callback:n,preserve:r},i)=>{let[a,o=e]=w.resolve(e,t,i,!0);return r?[n(a)]:[n(a),n(o)]});let we={};function Te(e,t,n){we[e]=n,Object.assign(w,{[e](...n){let r=new w({type:e});return t.forEach((e,t)=>{switch(e){case`sKey`:r.sKey=n[t]??w.string();break;case`inner`:r.inner=w.from(n[t]);break;case`list`:r.list=n[t].map(w.from);break;case`dict`:r.dict=b(n[t],w.from);break;case`bits`:r.bits={};for(let e in n[t])typeof n[t][e]==`number`&&(r.bits[e]=n[t][e]);break;case`callback`:{let e=r.callback=n[t];e.toJSON||=()=>e.toString();break}case`constructor`:{let e=r.constructor=n[t];typeof e==`function`&&(e.toJSON||=()=>e.name);break}default:r[e]=n[t]}}),e===`object`||e===`dict`?r.meta.default={}:e===`array`||e===`tuple`?r.meta.default=[]:e===`bitset`&&(r.meta.default=0),r}})}Te(`is`,[`constructor`],({constructor:e})=>typeof e==`function`?e.name:e),Te(`any`,[],()=>`any`),Te(`never`,[],()=>`never`),Te(`const`,[`value`],({value:e})=>typeof e==`string`?JSON.stringify(e):e),Te(`string`,[],()=>`string`),Te(`number`,[],()=>`number`),Te(`boolean`,[],()=>`boolean`),Te(`bitset`,[`bits`],()=>`bitset`),Te(`function`,[],()=>`function`),Te(`array`,[`inner`],({inner:e})=>`${e.toString(!0)}[]`),Te(`dict`,[`inner`,`sKey`],({inner:e,sKey:t})=>`{ [key: ${t.toString()}]: ${e.toString()} }`),Te(`tuple`,[`list`],({list:e})=>`[${e.map(e=>e.toString()).join(`, `)}]`),Te(`object`,[`dict`],({dict:e})=>Object.keys(e).length===0?`{}`:`{ ${Object.entries(e).map(([e,t])=>`${e}${t.meta.required?``:`?`}: ${t.toString()}`).join(`, `)} }`),Te(`union`,[`list`],({list:e},t)=>{let n=e.map(({toString:e})=>e()).join(` | `);return t?`(${n})`:n}),Te(`intersect`,[`list`],({list:e})=>`${e.map(e=>e.toString(!0)).join(` & `)}`),Te(`transform`,[`inner`,`callback`,`preserve`],({inner:e},t)=>e.toString(t));let Ee={'"':`"`,"\\":`\\`,"/":`/`,b:`\b`,f:`\f`,n:`
|
|
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 ee(e,t){return Object.fromEntries(Object.entries(e).filter(([e,n])=>t(e,n)))}function b(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 x=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,[x]:e=>{t=e}})}function ie(e){return typeof e==`object`&&!!e&&x 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 S(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(S,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(S,null,[i.value,t])),Reflect.defineProperty(r,n,i)}return r}function le(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 ue;(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})(ue||={});let de=Symbol.for(`schemastery`),fe=Symbol.for(`ValidationError`);globalThis.__schemastery_index__??=0,globalThis.__schemastery_refs__=void 0;var C=class extends TypeError{options;name=`ValidationError`;constructor(e,t){let n=`$`;for(let e of t.path||[])typeof e==`string`?n+=`.`+e:typeof e==`number`?n+=`[`+e+`]`:typeof e==`symbol`&&(n+=`[Symbol(${e.toString()})]`);n.startsWith(`.`)&&(n=n.slice(1)),super((n===`$`?``:`${n} `)+e),this.options=t}static is(e){return!!e?.[fe]}};Object.defineProperty(C.prototype,fe,{value:!0});let w=function(e){let t=function(e,n={}){return w.resolve(e,t,n)[0]};if(e.refs){let t=b(e.refs,e=>new w(e)),n=e=>t[e];for(let e in t){let r=t[e];r.sKey=n(r.sKey),r.inner=n(r.inner),r.list=r.list&&r.list.map(n),r.dict=r.dict&&b(r.dict,n)}return t[e.uid]}if(Object.assign(t,e),typeof t.callback==`string`)try{t.callback=Function(`return `+t.callback)()}catch{}return Object.defineProperty(t,"uid",{value:globalThis.__schemastery_index__++}),Object.setPrototypeOf(t,w.prototype),t.meta||={},t.toString=t.toString.bind(t),t};w.prototype=Object.create(Function.prototype),w.prototype[de]=!0,Object.defineProperty(w.prototype,"~standard",{get(){return{version:1,vendor:`schemastery`,validate:e=>{try{return{value:w.resolve(e,this,{})[0]}}catch(e){if(C.is(e))return{issues:[{message:e.message,path:e.options.path}]};throw e}}}}}),w.ValidationError=C,w.prototype.toJSON=function(){if(globalThis.__schemastery_refs__)return globalThis.__schemastery_refs__[this.uid]??=JSON.parse(JSON.stringify({...this})),this.uid;globalThis.__schemastery_refs__={[this.uid]:{...this}},globalThis.__schemastery_refs__[this.uid]=JSON.parse(JSON.stringify({...this}));let e={uid:this.uid,refs:globalThis.__schemastery_refs__};return globalThis.__schemastery_refs__=void 0,e},w.prototype.set=function(e,t){return this.dict[e]=t,this},w.prototype.push=function(e){return this.list.push(e),this};function pe(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 me(e){return e?.$value??e?.$inner}function he(e){return ee(e??{},e=>!e.startsWith(`$`))}w.prototype.i18n=function(e){let t=w(this),n=pe(t.meta.description,e);return Object.keys(n).length&&(t.meta.description=n),t.dict&&=b(t.dict,(t,n)=>t.i18n(b(e,e=>me(e)?.[n]??e?.[n]))),t.list&&=t.list.map((t,n)=>t.i18n(b(e,(e={})=>Array.isArray(me(e))?me(e)[n]:Array.isArray(e)?e[n]:he(e)))),t.inner&&=t.inner.i18n(b(e,e=>me(e)?me(e):he(e))),t.sKey&&=t.sKey.i18n(b(e,e=>e?.$key)),t},w.prototype.extra=function(e,t){let n=w(this);return n.meta={...n.meta,[e]:t},n};for(let e of[`required`,`disabled`,`collapse`,`hidden`,`loose`])Object.assign(w.prototype,{[e](t=!0){let n=w(this);return n.meta={...n.meta,[e]:t},n}});w.prototype.deprecated=function(){let e=w(this);return e.meta.badges||=[],e.meta.badges.push({text:`deprecated`,type:`danger`}),e},w.prototype.experimental=function(){let e=w(this);return e.meta.badges||=[],e.meta.badges.push({text:`experimental`,type:`warning`}),e},w.prototype.pattern=function(e){let t=w(this),n=te(e,[`source`,`flags`]);return t.meta={...t.meta,pattern:n},t},w.prototype.simplify=function(e){if(ie(e)&&(e=e.get()),le(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 le(t,this.meta.default,this.type===`dict`)?null:t}if(this.type===`array`||this.type===`tuple`){let t=[];return e.forEach((e,n)=>{let r=this.type===`array`?this.inner:this.list[n],i=r?r.simplify(e):e;t.push(i)}),t}if(this.type===`intersect`){let t={};for(let n of this.list)Object.assign(t,n.simplify(e));return t}if(this.type===`union`)for(let t of this.list)try{return w.resolve(e,t,{}),t.simplify(e)}catch{}return e},w.prototype.toString=function(e){return we[this.type]?.(this,e)??`Schema<${this.type}>`},w.prototype.role=function(e,t){let n=w(this);return n.meta={...n.meta,role:e,extra:t},n};for(let e of[`default`,`link`,`comment`,`description`,`max`,`min`,`step`])Object.assign(w.prototype,{[e](t){let n=w(this);return n.meta={...n.meta,[e]:t},n}});w.prototype.volatile=function(){if(this.meta.volatile)throw TypeError(`volatile schema is already wrapped`);return this.extra(`volatile`,!0)};let ge={},_e=Symbol(`checked-volatile-schema`);function ve(e,t=[],n=!1,r=/* @__PURE__ */ new Map){let i=r.get(e)??/* @__PURE__ */ new Set;if(i.has(n))return;if(i.add(n),r.set(e,i),e.meta?.volatile&&n)throw new C(`volatile fields require a fixed object path without an enclosing volatile field`,{path:t});let a=n||!!e.meta?.volatile;if(e.dict)for(let[n,i]of Object.entries(e.dict))ve(i,[...t,n],a,r);if(e.sKey&&ve(e.sKey,[...t,`<key>`],!0,r),e.inner&&(e.type!==`lazy`||e.inner[de])&&ve(e.inner,[...t,`*`],!0,r),e.list)for(let n=0;n<e.list.length;n++)ve(e.list[n],[...t,String(n)],!0,r)}w.extend=function(e,t){ge[e]=t},w.resolve=function(e,t,n={},r=!1){if(!t)return[e];if(n[_e]||(ve(t,n.path),n={...n,[_e]:!0}),t.meta?.volatile){let i=w(t);i.meta={...t.meta,volatile:!1};let[a,o]=w.resolve(e,i,n,r);try{return[re(a),o]}catch(e){throw new C(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 C(`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=S(i)}let i=ge[t.type];if(!i)throw new C(`unsupported type "${t.type}"`,n);try{return i(e,t,n,r)}catch(e){if(!t.meta.loose)throw e;return[t.meta.default]}},w.from=function(e){if(v(e))return w.any();if([`string`,`number`,`boolean`].includes(typeof e))return w.const(e).required();if(e[de])return e;if(typeof e==`function`)switch(e){case String:return w.string().required();case Number:return w.number().required();case Boolean:return w.boolean().required();case Function:return w.function().required();default:return w.is(e).required()}else throw TypeError(`cannot infer schema from ${e}`)},w.lazy=function(e){let t=new w({type:`lazy`,builder:e,inner:{toJSON:()=>(t.inner[de]||(t.inner=t.builder(),t.inner.meta={...t.meta,...t.inner.meta}),t.inner.toJSON())}});return t},w.natural=function(){return w.number().step(1).min(0)},w.percent=function(){return w.number().step(.01).min(0).max(1).role(`slider`)},w.date=function(){return w.union([w.is(Date),w.transform(w.string().role(`datetime`),(e,t)=>{let n=new Date(e);if(isNaN(+n))throw new C(`invalid date "${e}"`,t);return n},!0)])},w.regExp=function(e=``){return w.union([w.is(RegExp),w.transform(w.string().role(`regexp`,{flag:e}),(t,n)=>{try{return new RegExp(t,e)}catch(e){throw new C(e.message,n)}},!0)])},w.arrayBuffer=function(e){return w.union([w.is(ArrayBuffer),w.is(SharedArrayBuffer),w.transform(w.any(),(e,t)=>{if(ce.isSource(e))return ce.fromSource(e);throw new C(`expected ArrayBufferSource but got ${e}`,t)},!0),...e?[w.transform(w.string(),(t,n)=>{try{return e===`base64`?ce.fromBase64(t):ce.fromHex(t)}catch(e){throw new C(e.message,n)}},!0)]:[]])},w.extend(`lazy`,(e,t,n,r)=>(t.inner[de]||(t.inner=t.builder(),t.inner.meta={...t.meta,...t.inner.meta},ve(t.inner,n.path,!0)),w.resolve(e,t.inner,n,r))),w.extend(`any`,e=>[e]),w.extend(`never`,(e,t,n)=>{throw new C(`expected nullable but got ${e}`,n)}),w.extend(`const`,(e,{value:t},n)=>{if(le(e,t))return[t];throw new C(`expected ${t} but got ${e}`,n)});function ye(e,t,n,r,i=!1){let{max:a=1/0,min:o=-1/0}=t;if(e>a)throw new C(`expected ${n} <= ${a} but got ${e}`,r);if(e<o&&!i)throw new C(`expected ${n} >= ${o} but got ${e}`,r)}w.extend(`string`,(e,{meta:t},n)=>{if(typeof e!=`string`)throw new C(`expected string but got ${e}`,n);if(t.pattern){let r=new RegExp(t.pattern.source,t.pattern.flags);if(!r.test(e))throw new C(`expect string to match regexp ${r}`,n)}return ye(e.length,t,`string length`,n),[e]});function be(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 xe(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(be(e,i)-be(t,i))%be(n,i)===0}w.extend(`number`,(e,{meta:t},n)=>{if(typeof e!=`number`)throw new C(`expected number but got ${e}`,n);ye(e,t,`number`,n);let{step:r}=t;if(r&&!xe(e,t.min??0,r))throw new C(`expected number multiple of ${r} but got ${e}`,n);return[e]}),w.extend(`boolean`,(e,t,n)=>{if(typeof e==`boolean`)return[e];throw new C(`expected boolean but got ${e}`,n)}),w.extend(`bitset`,(e,{bits:t,meta:n},r)=>{let i=0,a=[];if(typeof e==`number`){i=e;for(let n in t)e&t[n]&&a.push(n)}else if(Array.isArray(e)){a=e;for(let e of a){if(typeof e!=`string`)throw new C(`expected string but got ${e}`,r);e in t&&(i|=t[e])}}else throw new C(`expected number or array but got ${e}`,r);return i===n.default?[i]:[i,a]}),w.extend(`function`,(e,t,n)=>{if(typeof e==`function`)return[e];throw new C(`expected function but got ${e}`,n)}),w.extend(`is`,(e,{constructor:t},n)=>{if(typeof t==`function`){if(e instanceof t)return[e];throw new C(`expected ${t.name} but got ${e}`,n)}{if(v(e))throw new C(`expected ${t} but got ${e}`,n);let r=Object.getPrototypeOf(e);for(;r;){if(r.constructor?.name===t)return[e];r=Object.getPrototypeOf(r)}throw new C(`expected ${t} but got ${e}`,n)}});function Se(e,t,n,r){try{let[i,a]=w.resolve(e[t],n,{...r,path:[...r.path||[],t]});return a!==void 0&&(e[t]=a),i}catch(i){if(!r?.autofix)throw i;return delete e[t],n.meta.volatile?re(n.meta.default):n.meta.default}}w.extend(`array`,(e,{inner:t,meta:n},r)=>{if(!Array.isArray(e))throw new C(`expected array but got ${e}`,r);return ye(e.length,n,`array length`,r,!v(t.meta.default)),[e.map((n,i)=>Se(e,i,t,r))]}),w.extend(`dict`,(e,{inner:t,sKey:n},r,i)=>{if(!y(e))throw new C(`expected object but got ${e}`,r);let a={};for(let o in e){let s;try{s=w.resolve(o,n,r)[0]}catch(e){if(i)continue;throw e}a[s]=Se(e,o,t,r),e[s]=e[o],o!==s&&delete e[o]}return[a]}),w.extend(`tuple`,(e,{list:t},n,r)=>{if(!Array.isArray(e))throw new C(`expected array but got ${e}`,n);let i=t.map((t,r)=>Se(e,r,t,n));return r||i.push(...e.slice(t.length)),[i]});function Ce(e,t){for(let n in t)n in e||(e[n]=t[n])}w.extend(`object`,(e,{dict:t},n,r)=>{if(!y(e))throw new C(`expected object but got ${e}`,n);let i={};for(let r in t){let a=Se(e,r,t[r],n);(!v(a)||r in e)&&(i[r]=a)}return r||Ce(i,e),[i]}),w.extend(`union`,(e,{list:t,toString:n},r,i)=>{let a=[];for(let n of t)try{return w.resolve(e,n,r,i)}catch(e){a.push(e)}throw new C(`expected ${n()} but got ${JSON.stringify(e)}`,r)}),w.extend(`intersect`,(e,{list:t,toString:n},r,i)=>{if(!t.length)return[e];let a;for(let i of t){let t=w.resolve(e,i,r,!0)[0];if(!v(t)){if(v(a))a=t;else if(typeof a!=typeof t)throw new C(`expected ${n()} but got ${JSON.stringify(e)}`,r);else if(typeof t==`object`)Ce(a??={},t);else if(a!==t)throw new C(`expected ${n()} but got ${JSON.stringify(e)}`,r)}}return!i&&y(e)&&Ce(a,e),[a]}),w.extend(`transform`,(e,{inner:t,callback:n,preserve:r},i)=>{let[a,o=e]=w.resolve(e,t,i,!0);return r?[n(a)]:[n(a),n(o)]});let we={};function Te(e,t,n){we[e]=n,Object.assign(w,{[e](...n){let r=new w({type:e});return t.forEach((e,t)=>{switch(e){case`sKey`:r.sKey=n[t]??w.string();break;case`inner`:r.inner=w.from(n[t]);break;case`list`:r.list=n[t].map(w.from);break;case`dict`:r.dict=b(n[t],w.from);break;case`bits`:r.bits={};for(let e in n[t])typeof n[t][e]==`number`&&(r.bits[e]=n[t][e]);break;case`callback`:{let e=r.callback=n[t];e.toJSON||=()=>e.toString();break}case`constructor`:{let e=r.constructor=n[t];typeof e==`function`&&(e.toJSON||=()=>e.name);break}default:r[e]=n[t]}}),e===`object`||e===`dict`?r.meta.default={}:e===`array`||e===`tuple`?r.meta.default=[]:e===`bitset`&&(r.meta.default=0),r}})}Te(`is`,[`constructor`],({constructor:e})=>typeof e==`function`?e.name:e),Te(`any`,[],()=>`any`),Te(`never`,[],()=>`never`),Te(`const`,[`value`],({value:e})=>typeof e==`string`?JSON.stringify(e):e),Te(`string`,[],()=>`string`),Te(`number`,[],()=>`number`),Te(`boolean`,[],()=>`boolean`),Te(`bitset`,[`bits`],()=>`bitset`),Te(`function`,[],()=>`function`),Te(`array`,[`inner`],({inner:e})=>`${e.toString(!0)}[]`),Te(`dict`,[`inner`,`sKey`],({inner:e,sKey:t})=>`{ [key: ${t.toString()}]: ${e.toString()} }`),Te(`tuple`,[`list`],({list:e})=>`[${e.map(e=>e.toString()).join(`, `)}]`),Te(`object`,[`dict`],({dict:e})=>Object.keys(e).length===0?`{}`:`{ ${Object.entries(e).map(([e,t])=>`${e}${t.meta.required?``:`?`}: ${t.toString()}`).join(`, `)} }`),Te(`union`,[`list`],({list:e},t)=>{let n=e.map(({toString:e})=>e()).join(` | `);return t?`(${n})`:n}),Te(`intersect`,[`list`],({list:e})=>`${e.map(e=>e.toString(!0)).join(` & `)}`),Te(`transform`,[`inner`,`callback`,`preserve`],({inner:e},t)=>e.toString(t));let Ee={'"':`"`,"\\":`\\`,"/":`/`,b:`\b`,f:`\f`,n:`
|
|
2
2
|
`,r:`\r`,t:` `},De=/[\\\u0000-\u001f]/u;function Oe(e){return e===` `||e===`
|
|
3
3
|
`||e===`\r`||e===` `}function ke(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(De),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++)ke(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=Ee[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&&De.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(Oe(e))return;if(e===`{`){this.#r=`key-or-end`;return}this.fail();return;case`key-or-end`:if(Oe(e))return;if(e===`}`){this.#r=`closed`;return}if(e===`"`){this.beginKey(t);return}this.fail();return;case`key-only`:if(Oe(e))return;if(e===`"`){this.beginKey(t);return}this.fail();return;case`key`:this.stepKey(e,t);return;case`colon`:if(Oe(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(Oe(e))return;if(e===`,`){this.#r=`key-only`;return}if(e===`}`){this.#r=`closed`;return}this.fail();return;case`closed`:if(Oe(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:Ae(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){Oe(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===`}`||Oe(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 Ae(e,t){let n=JSON.stringify(e)??String(e);throw Error(`unreachable variant${t?` in ${t}`:``}: ${n}`)}var je=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 Me(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 Ne=/* @__PURE__ */ new Set([`system/message`,`developer/message`,`user/message`,`assistant/message`,`tool/result`]);function Pe(e){return Ne.has(e.type)?e.surfaceOp!==void 0:!1}function Fe(e,t){let n=Pe(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 Ie(e,t){return`${e.length}:${e}${t}`}function Le(e,t){return e.key===t.key&&e.groupPart===t.groupPart}function
|
|
7
|
+
default:Ae(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){Oe(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===`}`||Oe(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 Ae(e,t){let n=JSON.stringify(e)??String(e);throw Error(`unreachable variant${t?` in ${t}`:``}: ${n}`)}var je=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 Me(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 Ne=/* @__PURE__ */ new Set([`system/message`,`developer/message`,`user/message`,`assistant/message`,`tool/result`]);function Pe(e){return Ne.has(e.type)?e.surfaceOp!==void 0:!1}function Fe(e,t){let n=Pe(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 Ie(e,t){return`${e.length}:${e}${t}`}function Le(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:[]}},
|
|
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=
|
|
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;
|
|
10
10
|
/* v8 ignore next 2 -- closed update union; TypeScript rejects other operation tags. */
|
|
11
|
-
default:Ae(e.groups)}return{upserts:t,removes:n}}},Ve=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}`))}},He=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 Ve(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 Ue={kind:`session`},We={kind:`unresolved`};function Ge(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 Ke(e,t){return e.length===t.length&&e.every((e,n)=>e===t[n])}function qe(e,t){return e!==void 0&&e.start===t.start&&e.end===t.end&&e.status===t.status&&e.data===t.data}function Je(e,t){return e!==void 0&&e.start===t.start&&e.end===t.end&&e.status===t.status&&e.data===t.data&&Ke(e.steps,t.steps)}function Ye(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 Xe=class{coordinates=/* @__PURE__ */ new Map;seqsByTurn=/* @__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(Ze(i.turn,Qe(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(Ze(i.turn,Qe(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(e.seq)?.location??Ue}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=Ge(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(t.seq,{...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 qe(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,Je(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.seqsByTurn=/* @__PURE__ */ new Map;for(let{event:t}of e){let e=this.coordinates.get(t.seq);e.turn!==void 0&&this.indexTurnSeq(e.turn,t.seq),e.location=this.resolve(t.seq)}this.currentTurn=i,this.currentStep=a;let m=/* @__PURE__ */ new Set;for(let{event:n}of e)Ye(t.get(n.seq)?.location,this.coordinates.get(n.seq)?.location)||m.add(n.seq);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=Ge(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.indexTurnSeq(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=qe(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=Je(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.seqsByTurn.get(n)??[]){let t=this.coordinates.get(e),n=t.location,r=this.resolve(e);t.location=r,Ye(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=Ge(e);if(t.session===!0){this.coordinates.set(e.seq,{location:Ue});return}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,r=t.step??(n===this.currentTurn?this.currentStep:void 0),i=t.turn!==void 0&&t.step!==void 0?t:{...n===void 0?{}:{turn:n},...n===void 0||r===void 0?{}:{step:r},location:void 0};this.coordinates.set(e.seq,i),n!==void 0&&this.indexTurnSeq(n,e.seq),i.location=this.resolve(e.seq)}removeAssistantTransients(e){for(let t of e){let e=this.coordinates.get(t.seq)?.turn;if(e!==void 0){let n=this.seqsByTurn.get(e);n?.delete(t.seq),n?.size===0&&this.seqsByTurn.delete(e)}this.coordinates.delete(t.seq)}}insertAssistantSettlement(e){let t={turn:e.data.turn,step:e.data.step,location:void 0};this.coordinates.set(e.seq,t),this.indexTurnSeq(e.data.turn,e.seq),t.location=this.resolve(e.seq)}indexTurnSeq(e,t){let n=this.seqsByTurn.get(e);n===void 0&&(n=/* @__PURE__ */ new Set,this.seqsByTurn.set(e,n)),n.add(t)}turnData(e){return this.mutableTurnData(e)}stepData(e,t){return this.mutableStepData(Ze(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 He(t=>{this.dirtyDataStores.add(t),this.changedTurns.add(e)})}storeFor(e){return e.kind===`turn`?this.mutableTurnData(e.turn):this.mutableStepData(Ze(e.turn,Qe(e)))}resolve(e){let t=this.coordinates.get(e);if(t?.turn===void 0)return Ue;let n=this.timeline.turns.get(t.turn);if(n===void 0)return We;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 Ze(e,t){return`${e}:${t}`}function Qe(e){if(e.kind===`step`&&e.step!==void 0)return e.step;throw Error(`conversation Step data "${e.key}" requires a step`)}let $e={none:0,"animation-frame":1,immediate:2},et=[`step`,`turn`];function tt(){return{step:null,turn:null}}function nt(e,t){return $e[e]>=$e[t]?e:t}function rt(e){return e.startSeq}function it(e,t){let n=0,r=e.length;for(;n<r;){let i=n+Math.floor((r-n)/2),a=e[i];a!==void 0&&a.startSeq<t?n=i+1:r=i}return n}function at(e){return{key:e.key,kind:e.kind,id:e.id,matches:e.matches,start:e.start,state:e.state,current:e.current}}function ot(e,t,n){let r=[],i=0,a=0;for(;i<t.length||a<n.length;){let o=t[i],s=n[a];if(o!==void 0&&s!==void 0&&o.event.seq===s.event.seq)throw Error(`conversation Context ${e} received duplicate Match ${o.event.seq}`);s===void 0||o!==void 0&&o.event.seq<s.event.seq?(r.push(o),i++):(r.push(s),a++)}return r}function st(e,t,n){return{event:e.event,role:t,location:n}}let ct={entries:()=>[],forTarget:()=>void 0};var lt=class{eventDefinitions;viewDefinitions;groupDefinitions;contexts=/* @__PURE__ */ new Map;contextsByKind=/* @__PURE__ */ new Map;contextsBySeq=/* @__PURE__ */ new Map;contextsByTarget=/* @__PURE__ */ new Map;inputs=/* @__PURE__ */ new Map;locationIndex=new Xe;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=ct){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.contextsBySeq.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)=>e.event.seq-t.event.seq);for(let e of n)this.inputs.set(e.event.seq,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;if(this.inputs.has(t.seq))return`none`;this.revised.size>0&&this.revised.clear(),this.inputs.set(t.seq,e);let n=`none`;if(t.type!==`assistant/live-chunk`&&ut(t.type)){let e=this.locationIndex.snapshot(),r=this.locationIndex.appendBoundary(t);this.locationIndex.snapshot()!==e&&(this.timelineDirty=!0,n=`immediate`),this.replayContexts(this.refreshMatchLocations(r)),r.size>0&&(n=`immediate`)}else this.locationIndex.appendNonBoundary(t);return n=nt(n,this.matchInput(e)),this.replayRevisedDependents()&&(n=`immediate`),this.revised.size>0&&this.revised.clear(),n}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=>e.event.seq)),i=/* @__PURE__ */ new Set;for(let e of r){this.inputs.delete(e);for(let t of this.contextsBySeq.get(e)??[])i.add(t);this.contextsBySeq.delete(e)}for(let e of i)e.matches=e.matches.filter(e=>!r.has(e.event.seq));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=nt(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(e.event.seq)).sort((e,t)=>e.event.seq-t.event.seq);for(let e of i)this.inputs.set(e.event.seq,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=nt(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)=>e.event.seq-t.event.seq)}matchInput(e){return this.dispatchInput(e,this.acceptMatch)}collectInput(e,t){return this.dispatchInput(e,(e,n,r)=>{let i=Ie(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??=st(e,t,a):i??=st(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=nt(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=nt(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=nt(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,startSeq:void 0,start:void 0,matches:[],state:void 0,revision:0,current:/* @__PURE__ */ new Map,locationData:tt(),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:Ie(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&&s.event.seq>=n.event.seq)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`);a.matches.push(n),o&&(a.startSeq=n.event.seq,a.start=n,this.indexStartedContext(a));let c=this.contextsBySeq.get(n.event.seq);if(c===void 0&&(c=[],this.contextsBySeq.set(n.event.seq,c)),c.push(a),o)this.replayContext(a);else if(a.state!==void 0){let t=at(a);a.state=dt(e,`update`,e.update(t,n)),a.revision++,this.revised.add(a)}return this.markDirty(a),e.publication?.(n)??`immediate`}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`);let t=this.contextsBySeq.get(e.match.event.seq);return t===void 0&&(t=[],this.contextsBySeq.set(e.match.event.seq,t)),t.push(i),e.match}).sort((e,t)=>e.event.seq-t.event.seq);i.matches=ot(i.key,a,i.matches),t.add(i),this.markDirty(i)}}replayContexts(e){this.refreshStarts(e);let t=[...e].sort((e,t)=>(e.startSeq??1/0)-(t.startSeq??1/0));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,r.startSeq=e?.event.seq,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.seq,n);e.state=void 0,e.state=dt(e.definition,`start`,e.definition.start(at(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=at(e);e.state=dt(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=rt(r);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=it(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.startSeq;if(t===void 0)return;let n=this.contextsByKind.get(e.kind)??[],r=n.at(-1);r===void 0||r.startSeq<t?n.push(e):n.splice(it(n,t),0,e),this.contextsByKind.set(e.kind,n)}indexStartedContexts(e,t){if(t.length===0)return;let n=[...t].sort((e,t)=>e.startSeq-t.startSeq),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&&e.startSeq<t.startSeq?(i.push(e),a++):(i.push(t),o++)}this.contextsByKind.set(e,i)}replayDependencies(){let e=!1,t=[...this.contexts.values()].filter(e=>rt(e)!==void 0).sort((e,t)=>rt(e)-rt(t));for(let n of t){if(n.state===void 0||n.dependencies.size===0)continue;let t=rt(n);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.contextsBySeq.get(n)??[])t.add(e);for(let n of t){let t=n.start;n.matches=n.matches.map(n=>{if(!e.has(n.event.seq))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(at(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 Be});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(at(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 et){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 et){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 ut(e){return e===`turn/start`||e===`turn/end`||e===`step/start`||e===`step/end`}function dt(e,t,n){if(n===void 0)throw Error(`conversation Definition "${e.kind}" returned undefined from ${t}()`);return n}var ft=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`)}},pt=class extends ft{fallback;routes=/* @__PURE__ */ new Map;unrestricted=/* @__PURE__ */ new Set;tables=/* @__PURE__ */ new WeakMap;register(e){return mt(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(mt(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 mt(e){if(e.target===void 0!=(e.buildViewNode===void 0))throw Error(`conversation Definition "${e.kind}" must declare target and buildViewNode together`)}function ht(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 gt(){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 _t=class{sessions;entries=new je;scopeDisposers=new je;urls=/* @__PURE__ */ new Set;disposed=!1;constructor(e,t){this.sessions=t,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.bindScope(n),i=t.attachmentId,a=r.get(i);if(a!==void 0)return a.pending;let o={binding:n,pending:Promise.resolve(``)};return r.set(i,o),o.pending=this.loadCanonical(i,o,t),o.pending}peek(e,t){let n=this.sessions.binding(e);return n===void 0?void 0:this.entries.get(n)?.get(t.attachmentId)?.current}seed(e,t,n){if(this.disposed)return!1;let r=this.sessions.binding(e);if(r===void 0)return!1;let i=this.bindScope(r),a=t.attachmentId;if(i.has(a))return!1;let o={binding:r,current:n,pending:Promise.resolve(n)};return this.urls.add(n),i.set(a,o),o.pending=this.loadCanonical(a,o,t).catch(e=>{throw i.get(a)===o&&o.current===n&&(i.delete(a),this.releaseUrl(n)),e}),o.pending.catch(()=>{}),!0}loadCanonical(e,t,n){return t.binding.session.readAttachment(n.attachmentId).then(n=>{if(!n.ok)throw Object.assign(Error(n.error.message),n.error);this.assertLive(e,t);let r;if(typeof URL.createObjectURL!=`function`)r=`data:${n.value.attachment.mediaType};base64,${ht(n.value.data)}`;else{let e=Uint8Array.from(n.value.data);r=URL.createObjectURL(new Blob([e.buffer],{type:n.value.attachment.mediaType}))}this.assertLive(e,t),this.urls.add(r);let i=t.current;return t.current=r,i!==void 0&&i!==r&&this.releaseUrl(i),r}).catch(n=>{let r=this.entries.get(t.binding);throw r?.get(e)===t&&t.current===void 0&&r.delete(e),n})}assertLive(e,t){if(this.disposed)throw Error(`ui-conversation image cache was disposed before loading completed`);if(this.entries.get(t.binding)?.get(e)!==t)throw Error(`ui-conversation image scope was released before loading completed`)}bindScope(e){let t=this.entries.get(e);if(t!==void 0)return t;let n=/* @__PURE__ */ new Map;this.entries.set(e,n);let r=e.ctx.effect(()=>()=>{this.scopeDisposers.delete(e),this.release(e,n)},`ui-conversation historical image scope`);return this.scopeDisposers.set(e,()=>{r()}),n}release(e,t){this.entries.get(e)===t&&this.entries.delete(e);for(let e of t.values())e.current!==void 0&&this.releaseUrl(e.current);t.clear()}releaseUrl(e){this.urls.delete(e)&&vt(e)}dispose(){if(!this.disposed){this.disposed=!0;for(let e of[...this.scopeDisposers.values])e();this.scopeDisposers.clear();for(let e of this.urls)vt(e);this.urls.clear();for(let e of this.entries.values)e.clear();this.entries.clear()}}};function vt(e){e.startsWith(`blob:`)&&URL.revokeObjectURL(e)}var yt=class extends ft{register(e){return this.registerDefinition(e.target,e,`conversation view target "${e.target}" is already registered`,`uiConversation.views.register(${JSON.stringify(e.target)})`)}},bt=class extends ft{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)}},xt=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()}}},St=class extends m.Service{sessions;events;views;groups;bindings=new je;images;constructor(e,t){super(e,`uiConversation`),this.sessions=t,this.events=new pt(e),this.views=new yt(e),this.groups=new bt(e,this.views),this.images=new _t(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 xt(n.eventSource,new lt(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){return this.images.seed(e,t,n)}inspectSystemPrompt(e,t){return Fe(e,t)}inspectRequestPrompt(e,t,n){return Me(e,t,n)}drop(e,t){this.bindings.get(e.source)===e&&(this.bindings.delete(e.source),e.binding.dispose(),t&&e.disposeScope())}},Ct;let wt=/*@__PURE__*/ Object.freeze({status:`aborted`});function T(e,t,n){function r(n,r){if(n._zod||Object.defineProperty(n,"_zod",{value:{def:r,constr:o,traits:/* @__PURE__ */ new Set},enumerable:!1}),n._zod.traits.has(e))return;n._zod.traits.add(e),t(n,r);let i=o.prototype,a=Object.keys(i);for(let e=0;e<a.length;e++){let t=a[e];t in n||(n[t]=i[t].bind(n))}}let i=n?.Parent??Object;class a extends i{}Object.defineProperty(a,"name",{value:e});function o(e){var t;let i=n?.Parent?new a:this;r(i,e),(t=i._zod).deferred??(t.deferred=[]);for(let e of i._zod.deferred)e();return i}return Object.defineProperty(o,"init",{value:r}),Object.defineProperty(o,Symbol.hasInstance,{value:t=>n?.Parent&&t instanceof n.Parent?!0:t?._zod?.traits?.has(e)}),Object.defineProperty(o,"name",{value:e}),o}var Tt=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}},Et=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name=`ZodEncodeError`}};(Ct=globalThis).__zod_globalConfig??(Ct.__zod_globalConfig={});let Dt=globalThis.__zod_globalConfig;function Ot(e){return e&&Object.assign(Dt,e),Dt}function kt(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 At(e,t){return typeof t==`bigint`?t.toString():t}function jt(e){return{get value(){{let t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function Mt(e){return e==null}function Nt(e){let t=+!!e.startsWith(`^`),n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function Pt(e,t){let n=e/t,r=Math.round(n),i=2**-52*Math.max(Math.abs(n),1);return Math.abs(n-r)<i?0:n-r}let Ft=/* @__PURE__*/ Symbol(`evaluating`);function E(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==Ft)return r===void 0&&(r=Ft,r=n()),r},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function It(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function Lt(...e){let t={};for(let n of e){let e=Object.getOwnPropertyDescriptors(n);Object.assign(t,e)}return Object.defineProperties({},t)}function Rt(e){return JSON.stringify(e)}function zt(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,``).replace(/[\s_-]+/g,`-`).replace(/^-+|-+$/g,``)}let Bt=`captureStackTrace`in Error?Error.captureStackTrace:(...e)=>{};function Vt(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}let Ht=/* @__PURE__*/ jt(()=>{if(Dt.jitless||typeof navigator<`u`&&navigator?.userAgent?.includes(`Cloudflare`))return!1;try{return Function(``),!0}catch{return!1}});function Ut(e){if(Vt(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!=`function`)return!0;let n=t.prototype;return Vt(n)!==!1&&Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)!==!1}function Wt(e){return Ut(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}let Gt=/* @__PURE__*/ new Set([`string`,`number`,`symbol`]);function Kt(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function qt(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function D(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 Jt(e){return Object.keys(e).filter(t=>e[t]._zod.optin===`optional`&&e[t]._zod.optout===`optional`)}let Yt={safeint:[-(2**53-1),2**53-1],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function Xt(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.pick() cannot be used on object schemas containing refinements`);return qt(e,Lt(e._zod.def,{get shape(){let e={};for(let r in t){if(!(r in n.shape))throw Error(`Unrecognized key: "${r}"`);t[r]&&(e[r]=n.shape[r])}return It(this,`shape`,e),e},checks:[]}))}function Zt(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.omit() cannot be used on object schemas containing refinements`);return qt(e,Lt(e._zod.def,{get shape(){let r={...e._zod.def.shape};for(let e in t){if(!(e in n.shape))throw Error(`Unrecognized key: "${e}"`);t[e]&&delete r[e]}return It(this,`shape`,r),r},checks:[]}))}function Qt(e,t){if(!Ut(t))throw Error(`Invalid input to extend: expected a plain object`);let n=e._zod.def.checks;if(n&&n.length>0){let n=e._zod.def.shape;for(let e in t)if(Object.getOwnPropertyDescriptor(n,e)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return qt(e,Lt(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return It(this,`shape`,n),n}}))}function $t(e,t){if(!Ut(t))throw Error(`Invalid input to safeExtend: expected a plain object`);return qt(e,Lt(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return It(this,`shape`,n),n}}))}function en(e,t){if(e._zod.def.checks?.length)throw Error(`.merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.`);return qt(e,Lt(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t._zod.def.shape};return It(this,`shape`,n),n},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]}))}function tn(e,t,n){let r=t._zod.def.checks;if(r&&r.length>0)throw Error(`.partial() cannot be used on object schemas containing refinements`);return qt(t,Lt(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in r))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t])}else for(let t in r)i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t];return It(this,`shape`,i),i},checks:[]}))}function nn(e,t,n){return qt(t,Lt(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in i))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=new e({type:`nonoptional`,innerType:r[t]}))}else for(let t in r)i[t]=new e({type:`nonoptional`,innerType:r[t]});return It(this,`shape`,i),i}}))}function rn(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function an(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue===!1)return!0;return!1}function on(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function sn(e){return typeof e==`string`?e:e?.message}function cn(e,t,n){let r=e.message?e.message:sn(e.inst?._zod.def?.error?.(e))??sn(t?.error?.(e))??sn(n.customError?.(e))??sn(n.localeError?.(e))??`Invalid input`,{inst:i,continue:a,input:o,...s}=e;return s.path??=[],s.message=r,t?.reportInput&&(s.input=o),s}function ln(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function un(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}let dn=(e,t)=>{e.name=`$ZodError`,Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,At,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},fn=T(`$ZodError`,dn),pn=T(`$ZodError`,dn,{Parent:Error});function mn(e,t=e=>e.message){let n={},r=[];for(let i of e.issues)i.path.length>0?(n[i.path[0]]=n[i.path[0]]||[],n[i.path[0]].push(t(i))):r.push(t(i));return{formErrors:r,fieldErrors:n}}function hn(e,t=e=>e.message){let n={_errors:[]},r=(e,i=[])=>{for(let a of e.issues)if(a.code===`invalid_union`&&a.errors.length)a.errors.map(e=>r({issues:e},[...i,...a.path]));else if(a.code===`invalid_key`)r({issues:a.issues},[...i,...a.path]);else if(a.code===`invalid_element`)r({issues:a.issues},[...i,...a.path]);else{let e=[...i,...a.path];if(e.length===0)n._errors.push(t(a));else{let r=n,i=0;for(;i<e.length;){let n=e[i];i===e.length-1?(r[n]=r[n]||{_errors:[]},r[n]._errors.push(t(a))):r[n]=r[n]||{_errors:[]},r=r[n],i++}}}};return r(e),n}let gn=e=>(t,n,r,i)=>{let a=r?{...r,async:!1}:{async:!1},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise)throw new Tt;if(o.issues.length){let t=new((i?.Err)??e)(o.issues.map(e=>cn(e,a,Ot())));throw Bt(t,i?.callee),t}return o.value},_n=e=>async(t,n,r,i)=>{let a=r?{...r,async:!0}:{async:!0},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise&&(o=await o),o.issues.length){let t=new((i?.Err)??e)(o.issues.map(e=>cn(e,a,Ot())));throw Bt(t,i?.callee),t}return o.value},vn=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 Tt;return a.issues.length?{success:!1,error:new(e??fn)(a.issues.map(e=>cn(e,i,Ot())))}:{success:!0,data:a.value}},yn=/* @__PURE__*/ vn(pn),bn=e=>async(t,n,r)=>{let i=r?{...r,async:!0}:{async:!0},a=t._zod.run({value:n,issues:[]},i);return a instanceof Promise&&(a=await a),a.issues.length?{success:!1,error:new e(a.issues.map(e=>cn(e,i,Ot())))}:{success:!0,data:a.value}},xn=/* @__PURE__*/ bn(pn),Sn=e=>(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return gn(e)(t,n,i)},Cn=e=>(t,n,r)=>gn(e)(t,n,r),wn=e=>async(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return _n(e)(t,n,i)},Tn=e=>async(t,n,r)=>_n(e)(t,n,r),En=e=>(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return vn(e)(t,n,i)},Dn=e=>(t,n,r)=>vn(e)(t,n,r),On=e=>async(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return bn(e)(t,n,i)},kn=e=>async(t,n,r)=>bn(e)(t,n,r),An=/^[cC][0-9a-z]{6,}$/,jn=/^[0-9a-z]+$/,Mn=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Nn=/^[0-9a-vA-V]{20}$/,Pn=/^[A-Za-z0-9]{27}$/,Fn=/^[a-zA-Z0-9_-]{21}$/,In=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Ln=/^([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})$/,Rn=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)$/,zn=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;function Bn(){return RegExp(`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`,`u`)}let Vn=/^(?:(?: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])$/,Hn=/^(([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}|:))$/,Un=/^((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])$/,Wn=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Gn=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Kn=/^[A-Za-z0-9_-]*$/,qn=/^https?$/,Jn=/^\+[1-9]\d{6,14}$/,Yn=`(?:(?:\\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])))`,Xn=/*@__PURE__*/ RegExp(`^${Yn}$`);function Zn(e){let t=`(?:[01]\\d|2[0-3]):[0-5]\\d`;return typeof e.precision==`number`?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function Qn(e){return RegExp(`^${Zn(e)}$`)}function $n(e){let t=Zn({precision:e.precision}),n=[`Z`];e.local&&n.push(``),e.offset&&n.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);let r=`${t}(?:${n.join(`|`)})`;return RegExp(`^${Yn}T(?:${r})$`)}let er=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??``}}`:`[\\s\\S]*`;return RegExp(`^${t}$`)},tr=/^-?\d+$/,nr=/^-?\d+(?:\.\d+)?$/,rr=/^(?:true|false)$/i,ir=/^null$/i,ar=/^[^A-Z]*$/,or=/^[^a-z]*$/,sr=/*@__PURE__*/ T(`$ZodCheck`,(e,t)=>{var n;e._zod??={},e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),cr={number:`number`,bigint:`bigint`,object:`date`},lr=/*@__PURE__*/ T(`$ZodCheckLessThan`,(e,t)=>{sr.init(e,t);let n=cr[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.maximum:n.exclusiveMaximum)??1/0;t.value<r&&(t.inclusive?n.maximum=t.value:n.exclusiveMaximum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:n,code:`too_big`,maximum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),ur=/*@__PURE__*/ T(`$ZodCheckGreaterThan`,(e,t)=>{sr.init(e,t);let n=cr[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.minimum:n.exclusiveMinimum)??-1/0;t.value>r&&(t.inclusive?n.minimum=t.value:n.exclusiveMinimum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:n,code:`too_small`,minimum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),dr=/*@__PURE__*/ T(`$ZodCheckMultipleOf`,(e,t)=>{sr.init(e,t),e._zod.onattach.push(e=>{var n;(n=e._zod.bag).multipleOf??(n.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw Error(`Cannot mix number and bigint in multiple_of check.`);(typeof n.value==`bigint`?n.value%t.value===BigInt(0):Pt(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})}}),fr=/*@__PURE__*/ T(`$ZodCheckNumberFormat`,(e,t)=>{sr.init(e,t),t.format=t.format||`float64`;let n=t.format?.includes(`int`),r=n?`int`:`number`,[i,a]=Yt[t.format];e._zod.onattach.push(e=>{let r=e._zod.bag;r.format=t.format,r.minimum=i,r.maximum=a,n&&(r.pattern=tr)}),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})}}),pr=/*@__PURE__*/ T(`$ZodCheckMaxLength`,(e,t)=>{var n;sr.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!Mt(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.maximum??1/0;t.maximum<n&&(e._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{let r=n.value;if(r.length<=t.maximum)return;let i=ln(r);n.issues.push({origin:i,code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),mr=/*@__PURE__*/ T(`$ZodCheckMinLength`,(e,t)=>{var n;sr.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!Mt(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.minimum??-1/0;t.minimum>n&&(e._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{let r=n.value;if(r.length>=t.minimum)return;let i=ln(r);n.issues.push({origin:i,code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),hr=/*@__PURE__*/ T(`$ZodCheckLengthEquals`,(e,t)=>{var n;sr.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!Mt(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag;n.minimum=t.length,n.maximum=t.length,n.length=t.length}),e._zod.check=n=>{let r=n.value,i=r.length;if(i===t.length)return;let a=ln(r),o=i>t.length;n.issues.push({origin:a,...o?{code:`too_big`,maximum:t.length}:{code:`too_small`,minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),gr=/*@__PURE__*/ T(`$ZodCheckStringFormat`,(e,t)=>{var n,r;sr.init(e,t),e._zod.onattach.push(e=>{let n=e._zod.bag;n.format=t.format,t.pattern&&(n.patterns??=/* @__PURE__ */ new Set,n.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),_r=/*@__PURE__*/ T(`$ZodCheckRegex`,(e,t)=>{gr.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})}}),vr=/*@__PURE__*/ T(`$ZodCheckLowerCase`,(e,t)=>{t.pattern??=ar,gr.init(e,t)}),yr=/*@__PURE__*/ T(`$ZodCheckUpperCase`,(e,t)=>{t.pattern??=or,gr.init(e,t)}),br=/*@__PURE__*/ T(`$ZodCheckIncludes`,(e,t)=>{sr.init(e,t);let n=Kt(t.includes),r=new RegExp(typeof t.position==`number`?`^.{${t.position}}${n}`:n);t.pattern=r,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=/* @__PURE__ */ new Set,t.patterns.add(r)}),e._zod.check=n=>{n.value.includes(t.includes,t.position)||n.issues.push({origin:`string`,code:`invalid_format`,format:`includes`,includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),xr=/*@__PURE__*/ T(`$ZodCheckStartsWith`,(e,t)=>{sr.init(e,t);let n=RegExp(`^${Kt(t.prefix)}.*`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=/* @__PURE__ */ new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`starts_with`,prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),Sr=/*@__PURE__*/ T(`$ZodCheckEndsWith`,(e,t)=>{sr.init(e,t);let n=RegExp(`.*${Kt(t.suffix)}$`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=/* @__PURE__ */ new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`ends_with`,suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}),Cr=/*@__PURE__*/ T(`$ZodCheckOverwrite`,(e,t)=>{sr.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}});var wr=class{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),--this.indent}write(e){if(typeof e==`function`){e(this,{execution:`sync`}),e(this,{execution:`async`});return}let t=e.split(`
|
|
11
|
+
default:Ae(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(Le(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(Le(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=Le(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=Le(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=Le(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=Le(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(Le(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=Le(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=>Le(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(Le(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(Le(e.event))).sort((e,t)=>Re(e.event,t.event));for(let e of i)this.inputs.set(Le(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=Ie(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:Ie(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=Le(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(Le(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;entries=new je;scopeDisposers=new je;urls=/* @__PURE__ */ new Set;disposed=!1;constructor(e,t){this.sessions=t,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.bindScope(n),i=t.attachmentId,a=r.get(i);if(a!==void 0)return a.pending;let o={binding:n,pending:Promise.resolve(``)};return r.set(i,o),o.pending=this.loadCanonical(i,o,t),o.pending}peek(e,t){let n=this.sessions.binding(e);return n===void 0?void 0:this.entries.get(n)?.get(t.attachmentId)?.current}seed(e,t,n){if(this.disposed)return!1;let r=this.sessions.binding(e);if(r===void 0)return!1;let i=this.bindScope(r),a=t.attachmentId;if(i.has(a))return!1;let o={binding:r,current:n,pending:Promise.resolve(n)};return this.urls.add(n),i.set(a,o),o.pending=this.loadCanonical(a,o,t).catch(e=>{throw i.get(a)===o&&o.current===n&&(i.delete(a),this.releaseUrl(n)),e}),o.pending.catch(()=>{}),!0}loadCanonical(e,t,n){return t.binding.session.readAttachment(n.attachmentId).then(n=>{if(!n.ok)throw Object.assign(Error(n.error.message),n.error);this.assertLive(e,t);let r;if(typeof URL.createObjectURL!=`function`)r=`data:${n.value.attachment.mediaType};base64,${_t(n.value.data)}`;else{let e=Uint8Array.from(n.value.data);r=URL.createObjectURL(new Blob([e.buffer],{type:n.value.attachment.mediaType}))}this.assertLive(e,t),this.urls.add(r);let i=t.current;return t.current=r,i!==void 0&&i!==r&&this.releaseUrl(i),r}).catch(n=>{let r=this.entries.get(t.binding);throw r?.get(e)===t&&t.current===void 0&&r.delete(e),n})}assertLive(e,t){if(this.disposed)throw Error(`ui-conversation image cache was disposed before loading completed`);if(this.entries.get(t.binding)?.get(e)!==t)throw Error(`ui-conversation image scope was released before loading completed`)}bindScope(e){let t=this.entries.get(e);if(t!==void 0)return t;let n=/* @__PURE__ */ new Map;this.entries.set(e,n);let r=e.ctx.effect(()=>()=>{this.scopeDisposers.delete(e),this.release(e,n)},`ui-conversation historical image scope`);return this.scopeDisposers.set(e,()=>{r()}),n}release(e,t){this.entries.get(e)===t&&this.entries.delete(e);for(let e of t.values())e.current!==void 0&&this.releaseUrl(e.current);t.clear()}releaseUrl(e){this.urls.delete(e)&&bt(e)}dispose(){if(!this.disposed){this.disposed=!0;for(let e of[...this.scopeDisposers.values])e();this.scopeDisposers.clear();for(let e of this.urls)bt(e);this.urls.clear();for(let e of this.entries.values)e.clear();this.entries.clear()}}};function bt(e){e.startsWith(`blob:`)&&URL.revokeObjectURL(e)}var xt=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)})`)}},St=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)}},Ct=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()}}},wt=class extends m.Service{sessions;events;views;groups;bindings=new je;images;constructor(e,t){super(e,`uiConversation`),this.sessions=t,this.events=new ht(e),this.views=new xt(e),this.groups=new St(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 Ct(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){return this.images.seed(e,t,n)}inspectSystemPrompt(e,t){return Fe(e,t)}inspectRequestPrompt(e,t,n){return Me(e,t,n)}drop(e,t){this.bindings.get(e.source)===e&&(this.bindings.delete(e.source),e.binding.dispose(),t&&e.disposeScope())}},Tt;let Et=/*@__PURE__*/ Object.freeze({status:`aborted`});function T(e,t,n){function r(n,r){if(n._zod||Object.defineProperty(n,"_zod",{value:{def:r,constr:o,traits:/* @__PURE__ */ new Set},enumerable:!1}),n._zod.traits.has(e))return;n._zod.traits.add(e),t(n,r);let i=o.prototype,a=Object.keys(i);for(let e=0;e<a.length;e++){let t=a[e];t in n||(n[t]=i[t].bind(n))}}let i=n?.Parent??Object;class a extends i{}Object.defineProperty(a,"name",{value:e});function o(e){var t;let i=n?.Parent?new a:this;r(i,e),(t=i._zod).deferred??(t.deferred=[]);for(let e of i._zod.deferred)e();return i}return Object.defineProperty(o,"init",{value:r}),Object.defineProperty(o,Symbol.hasInstance,{value:t=>n?.Parent&&t instanceof n.Parent?!0:t?._zod?.traits?.has(e)}),Object.defineProperty(o,"name",{value:e}),o}var Dt=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}},Ot=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name=`ZodEncodeError`}};(Tt=globalThis).__zod_globalConfig??(Tt.__zod_globalConfig={});let kt=globalThis.__zod_globalConfig;function At(e){return e&&Object.assign(kt,e),kt}function jt(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 Mt(e,t){return typeof t==`bigint`?t.toString():t}function Nt(e){return{get value(){{let t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function Pt(e){return e==null}function Ft(e){let t=+!!e.startsWith(`^`),n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function It(e,t){let n=e/t,r=Math.round(n),i=2**-52*Math.max(Math.abs(n),1);return Math.abs(n-r)<i?0:n-r}let Lt=/* @__PURE__*/ Symbol(`evaluating`);function E(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==Lt)return r===void 0&&(r=Lt,r=n()),r},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function Rt(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function zt(...e){let t={};for(let n of e){let e=Object.getOwnPropertyDescriptors(n);Object.assign(t,e)}return Object.defineProperties({},t)}function Bt(e){return JSON.stringify(e)}function Vt(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,``).replace(/[\s_-]+/g,`-`).replace(/^-+|-+$/g,``)}let Ht=`captureStackTrace`in Error?Error.captureStackTrace:(...e)=>{};function Ut(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}let Wt=/* @__PURE__*/ Nt(()=>{if(kt.jitless||typeof navigator<`u`&&navigator?.userAgent?.includes(`Cloudflare`))return!1;try{return Function(``),!0}catch{return!1}});function Gt(e){if(Ut(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!=`function`)return!0;let n=t.prototype;return Ut(n)!==!1&&Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)!==!1}function Kt(e){return Gt(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}let qt=/* @__PURE__*/ new Set([`string`,`number`,`symbol`]);function Jt(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function Yt(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function D(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 Xt(e){return Object.keys(e).filter(t=>e[t]._zod.optin===`optional`&&e[t]._zod.optout===`optional`)}let Zt={safeint:[-(2**53-1),2**53-1],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function Qt(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.pick() cannot be used on object schemas containing refinements`);return Yt(e,zt(e._zod.def,{get shape(){let e={};for(let r in t){if(!(r in n.shape))throw Error(`Unrecognized key: "${r}"`);t[r]&&(e[r]=n.shape[r])}return Rt(this,`shape`,e),e},checks:[]}))}function $t(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.omit() cannot be used on object schemas containing refinements`);return Yt(e,zt(e._zod.def,{get shape(){let r={...e._zod.def.shape};for(let e in t){if(!(e in n.shape))throw Error(`Unrecognized key: "${e}"`);t[e]&&delete r[e]}return Rt(this,`shape`,r),r},checks:[]}))}function en(e,t){if(!Gt(t))throw Error(`Invalid input to extend: expected a plain object`);let n=e._zod.def.checks;if(n&&n.length>0){let n=e._zod.def.shape;for(let e in t)if(Object.getOwnPropertyDescriptor(n,e)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return Yt(e,zt(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return Rt(this,`shape`,n),n}}))}function tn(e,t){if(!Gt(t))throw Error(`Invalid input to safeExtend: expected a plain object`);return Yt(e,zt(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return Rt(this,`shape`,n),n}}))}function nn(e,t){if(e._zod.def.checks?.length)throw Error(`.merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.`);return Yt(e,zt(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t._zod.def.shape};return Rt(this,`shape`,n),n},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]}))}function rn(e,t,n){let r=t._zod.def.checks;if(r&&r.length>0)throw Error(`.partial() cannot be used on object schemas containing refinements`);return Yt(t,zt(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in r))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t])}else for(let t in r)i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t];return Rt(this,`shape`,i),i},checks:[]}))}function an(e,t,n){return Yt(t,zt(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in i))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=new e({type:`nonoptional`,innerType:r[t]}))}else for(let t in r)i[t]=new e({type:`nonoptional`,innerType:r[t]});return Rt(this,`shape`,i),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 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 ln(e){return typeof e==`string`?e:e?.message}function un(e,t,n){let r=e.message?e.message:ln(e.inst?._zod.def?.error?.(e))??ln(t?.error?.(e))??ln(n.customError?.(e))??ln(n.localeError?.(e))??`Invalid input`,{inst:i,continue:a,input:o,...s}=e;return s.path??=[],s.message=r,t?.reportInput&&(s.input=o),s}function dn(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function fn(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}let pn=(e,t)=>{e.name=`$ZodError`,Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,Mt,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},mn=T(`$ZodError`,pn),hn=T(`$ZodError`,pn,{Parent:Error});function gn(e,t=e=>e.message){let n={},r=[];for(let i of e.issues)i.path.length>0?(n[i.path[0]]=n[i.path[0]]||[],n[i.path[0]].push(t(i))):r.push(t(i));return{formErrors:r,fieldErrors:n}}function _n(e,t=e=>e.message){let n={_errors:[]},r=(e,i=[])=>{for(let a of e.issues)if(a.code===`invalid_union`&&a.errors.length)a.errors.map(e=>r({issues:e},[...i,...a.path]));else if(a.code===`invalid_key`)r({issues:a.issues},[...i,...a.path]);else if(a.code===`invalid_element`)r({issues:a.issues},[...i,...a.path]);else{let e=[...i,...a.path];if(e.length===0)n._errors.push(t(a));else{let r=n,i=0;for(;i<e.length;){let n=e[i];i===e.length-1?(r[n]=r[n]||{_errors:[]},r[n]._errors.push(t(a))):r[n]=r[n]||{_errors:[]},r=r[n],i++}}}};return r(e),n}let vn=e=>(t,n,r,i)=>{let a=r?{...r,async:!1}:{async:!1},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise)throw new Dt;if(o.issues.length){let t=new((i?.Err)??e)(o.issues.map(e=>un(e,a,At())));throw Ht(t,i?.callee),t}return o.value},yn=e=>async(t,n,r,i)=>{let a=r?{...r,async:!0}:{async:!0},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise&&(o=await o),o.issues.length){let t=new((i?.Err)??e)(o.issues.map(e=>un(e,a,At())));throw Ht(t,i?.callee),t}return o.value},bn=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 Dt;return a.issues.length?{success:!1,error:new(e??mn)(a.issues.map(e=>un(e,i,At())))}:{success:!0,data:a.value}},xn=/* @__PURE__*/ bn(hn),Sn=e=>async(t,n,r)=>{let i=r?{...r,async:!0}:{async:!0},a=t._zod.run({value:n,issues:[]},i);return a instanceof Promise&&(a=await a),a.issues.length?{success:!1,error:new e(a.issues.map(e=>un(e,i,At())))}:{success:!0,data:a.value}},Cn=/* @__PURE__*/ Sn(hn),wn=e=>(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return vn(e)(t,n,i)},Tn=e=>(t,n,r)=>vn(e)(t,n,r),En=e=>async(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return yn(e)(t,n,i)},Dn=e=>async(t,n,r)=>yn(e)(t,n,r),On=e=>(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return bn(e)(t,n,i)},kn=e=>(t,n,r)=>bn(e)(t,n,r),An=e=>async(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return Sn(e)(t,n,i)},jn=e=>async(t,n,r)=>Sn(e)(t,n,r),Mn=/^[cC][0-9a-z]{6,}$/,Nn=/^[0-9a-z]+$/,Pn=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Fn=/^[0-9a-vA-V]{20}$/,In=/^[A-Za-z0-9]{27}$/,Ln=/^[a-zA-Z0-9_-]{21}$/,Rn=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,zn=/^([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})$/,Bn=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)$/,Vn=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;function Hn(){return RegExp(`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`,`u`)}let Un=/^(?:(?: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])$/,Wn=/^(([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}|:))$/,Gn=/^((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])$/,Kn=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,qn=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Jn=/^[A-Za-z0-9_-]*$/,Yn=/^https?$/,Xn=/^\+[1-9]\d{6,14}$/,Zn=`(?:(?:\\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])))`,Qn=/*@__PURE__*/ RegExp(`^${Zn}$`);function $n(e){let t=`(?:[01]\\d|2[0-3]):[0-5]\\d`;return typeof e.precision==`number`?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function er(e){return RegExp(`^${$n(e)}$`)}function tr(e){let t=$n({precision:e.precision}),n=[`Z`];e.local&&n.push(``),e.offset&&n.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);let r=`${t}(?:${n.join(`|`)})`;return RegExp(`^${Zn}T(?:${r})$`)}let nr=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??``}}`:`[\\s\\S]*`;return RegExp(`^${t}$`)},rr=/^-?\d+$/,ir=/^-?\d+(?:\.\d+)?$/,ar=/^(?:true|false)$/i,or=/^null$/i,sr=/^[^A-Z]*$/,cr=/^[^a-z]*$/,lr=/*@__PURE__*/ T(`$ZodCheck`,(e,t)=>{var n;e._zod??={},e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),ur={number:`number`,bigint:`bigint`,object:`date`},dr=/*@__PURE__*/ T(`$ZodCheckLessThan`,(e,t)=>{lr.init(e,t);let n=ur[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.maximum:n.exclusiveMaximum)??1/0;t.value<r&&(t.inclusive?n.maximum=t.value:n.exclusiveMaximum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:n,code:`too_big`,maximum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),fr=/*@__PURE__*/ T(`$ZodCheckGreaterThan`,(e,t)=>{lr.init(e,t);let n=ur[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.minimum:n.exclusiveMinimum)??-1/0;t.value>r&&(t.inclusive?n.minimum=t.value:n.exclusiveMinimum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:n,code:`too_small`,minimum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),pr=/*@__PURE__*/ T(`$ZodCheckMultipleOf`,(e,t)=>{lr.init(e,t),e._zod.onattach.push(e=>{var n;(n=e._zod.bag).multipleOf??(n.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw Error(`Cannot mix number and bigint in multiple_of check.`);(typeof n.value==`bigint`?n.value%t.value===BigInt(0):It(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})}}),mr=/*@__PURE__*/ T(`$ZodCheckNumberFormat`,(e,t)=>{lr.init(e,t),t.format=t.format||`float64`;let n=t.format?.includes(`int`),r=n?`int`:`number`,[i,a]=Zt[t.format];e._zod.onattach.push(e=>{let r=e._zod.bag;r.format=t.format,r.minimum=i,r.maximum=a,n&&(r.pattern=rr)}),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})}}),hr=/*@__PURE__*/ T(`$ZodCheckMaxLength`,(e,t)=>{var n;lr.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!Pt(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.maximum??1/0;t.maximum<n&&(e._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{let r=n.value;if(r.length<=t.maximum)return;let i=dn(r);n.issues.push({origin:i,code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),gr=/*@__PURE__*/ T(`$ZodCheckMinLength`,(e,t)=>{var n;lr.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!Pt(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.minimum??-1/0;t.minimum>n&&(e._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{let r=n.value;if(r.length>=t.minimum)return;let i=dn(r);n.issues.push({origin:i,code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),_r=/*@__PURE__*/ T(`$ZodCheckLengthEquals`,(e,t)=>{var n;lr.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!Pt(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag;n.minimum=t.length,n.maximum=t.length,n.length=t.length}),e._zod.check=n=>{let r=n.value,i=r.length;if(i===t.length)return;let a=dn(r),o=i>t.length;n.issues.push({origin:a,...o?{code:`too_big`,maximum:t.length}:{code:`too_small`,minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),vr=/*@__PURE__*/ T(`$ZodCheckStringFormat`,(e,t)=>{var n,r;lr.init(e,t),e._zod.onattach.push(e=>{let n=e._zod.bag;n.format=t.format,t.pattern&&(n.patterns??=/* @__PURE__ */ new Set,n.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),yr=/*@__PURE__*/ T(`$ZodCheckRegex`,(e,t)=>{vr.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})}}),br=/*@__PURE__*/ T(`$ZodCheckLowerCase`,(e,t)=>{t.pattern??=sr,vr.init(e,t)}),xr=/*@__PURE__*/ T(`$ZodCheckUpperCase`,(e,t)=>{t.pattern??=cr,vr.init(e,t)}),Sr=/*@__PURE__*/ T(`$ZodCheckIncludes`,(e,t)=>{lr.init(e,t);let n=Jt(t.includes),r=new RegExp(typeof t.position==`number`?`^.{${t.position}}${n}`:n);t.pattern=r,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=/* @__PURE__ */ new Set,t.patterns.add(r)}),e._zod.check=n=>{n.value.includes(t.includes,t.position)||n.issues.push({origin:`string`,code:`invalid_format`,format:`includes`,includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),Cr=/*@__PURE__*/ T(`$ZodCheckStartsWith`,(e,t)=>{lr.init(e,t);let n=RegExp(`^${Jt(t.prefix)}.*`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=/* @__PURE__ */ new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`starts_with`,prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),wr=/*@__PURE__*/ T(`$ZodCheckEndsWith`,(e,t)=>{lr.init(e,t);let n=RegExp(`.*${Jt(t.suffix)}$`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=/* @__PURE__ */ new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`ends_with`,suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}),Tr=/*@__PURE__*/ T(`$ZodCheckOverwrite`,(e,t)=>{lr.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}});var Er=class{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),--this.indent}write(e){if(typeof e==`function`){e(this,{execution:`sync`}),e(this,{execution:`async`});return}let t=e.split(`
|
|
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?.args,n=[...(this?.content??[``]).map(e=>` ${e}`)];return new e(...t,n.join(`
|
|
13
|
-
`))}};let Tr={major:4,minor:4,patch:3},O=/*@__PURE__*/ T(`$ZodType`,(e,t)=>{var n;e??={},e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Tr;let r=[...e._zod.def.checks??[]];e._zod.traits.has(`$ZodCheck`)&&r.unshift(e);for(let t of r)for(let n of t._zod.onattach)n(e);if(r.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let t=(e,t,n)=>{let r=rn(e),i;for(let a of t){if(a._zod.def.when){if(an(e)||!a._zod.def.when(e))continue}else if(r)continue;let t=e.issues.length,o=a._zod.check(e);if(o instanceof Promise&&n?.async===!1)throw new Tt;if(i||o instanceof Promise)i=(i??Promise.resolve()).then(async()=>{await o,e.issues.length!==t&&(r||=rn(e,t))});else{if(e.issues.length===t)continue;r||=rn(e,t)}}return i?i.then(()=>e):e},n=(n,i,a)=>{if(rn(n))return n.aborted=!0,n;let o=t(i,r,a);if(o instanceof Promise){if(a.async===!1)throw new Tt;return o.then(t=>e._zod.parse(t,a))}return e._zod.parse(o,a)};e._zod.run=(i,a)=>{if(a.skipChecks)return e._zod.parse(i,a);if(a.direction===`backward`){let t=e._zod.parse({value:i.value,issues:[]},{...a,skipChecks:!0});return t instanceof Promise?t.then(e=>n(e,i,a)):n(t,i,a)}let o=e._zod.parse(i,a);if(o instanceof Promise){if(a.async===!1)throw new Tt;return o.then(e=>t(e,r,a))}return t(o,r,a)}}E(e,`~standard`,()=>({validate:t=>{try{let n=yn(e,t);return n.success?{value:n.data}:{issues:n.error?.issues}}catch{return xn(e,t).then(e=>e.success?{value:e.data}:{issues:e.error?.issues})}},vendor:`zod`,version:1}))}),Er=/*@__PURE__*/ T(`$ZodString`,(e,t)=>{O.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??er(e._zod.bag),e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value==`string`||n.issues.push({expected:`string`,code:`invalid_type`,input:n.value,inst:e}),n}}),Dr=/*@__PURE__*/ T(`$ZodStringFormat`,(e,t)=>{gr.init(e,t),Er.init(e,t)}),Or=/*@__PURE__*/ T(`$ZodGUID`,(e,t)=>{t.pattern??=Ln,Dr.init(e,t)}),kr=/*@__PURE__*/ T(`$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??=Rn(e)}else t.pattern??=Rn();Dr.init(e,t)}),Ar=/*@__PURE__*/ T(`$ZodEmail`,(e,t)=>{t.pattern??=zn,Dr.init(e,t)}),jr=/*@__PURE__*/ T(`$ZodURL`,(e,t)=>{Dr.init(e,t),e._zod.check=n=>{try{let r=n.value.trim();if(!t.normalize&&t.protocol?.source===qn.source&&!/^https?:\/\//i.test(r)){n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid URL format`,input:n.value,inst:e,continue:!t.abort});return}let i=new URL(r);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(i.hostname)||n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid hostname`,pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(i.protocol.endsWith(`:`)?i.protocol.slice(0,-1):i.protocol)||n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid protocol`,pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),n.value=t.normalize?i.href:r;return}catch{n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort})}}}),Mr=/*@__PURE__*/ T(`$ZodEmoji`,(e,t)=>{t.pattern??=Bn(),Dr.init(e,t)}),Nr=/*@__PURE__*/ T(`$ZodNanoID`,(e,t)=>{t.pattern??=Fn,Dr.init(e,t)}),Pr=/*@__PURE__*/ T(`$ZodCUID`,(e,t)=>{t.pattern??=An,Dr.init(e,t)}),Fr=/*@__PURE__*/ T(`$ZodCUID2`,(e,t)=>{t.pattern??=jn,Dr.init(e,t)}),Ir=/*@__PURE__*/ T(`$ZodULID`,(e,t)=>{t.pattern??=Mn,Dr.init(e,t)}),Lr=/*@__PURE__*/ T(`$ZodXID`,(e,t)=>{t.pattern??=Nn,Dr.init(e,t)}),Rr=/*@__PURE__*/ T(`$ZodKSUID`,(e,t)=>{t.pattern??=Pn,Dr.init(e,t)}),zr=/*@__PURE__*/ T(`$ZodISODateTime`,(e,t)=>{t.pattern??=$n(t),Dr.init(e,t)}),Br=/*@__PURE__*/ T(`$ZodISODate`,(e,t)=>{t.pattern??=Xn,Dr.init(e,t)}),Vr=/*@__PURE__*/ T(`$ZodISOTime`,(e,t)=>{t.pattern??=Qn(t),Dr.init(e,t)}),Hr=/*@__PURE__*/ T(`$ZodISODuration`,(e,t)=>{t.pattern??=In,Dr.init(e,t)}),Ur=/*@__PURE__*/ T(`$ZodIPv4`,(e,t)=>{t.pattern??=Vn,Dr.init(e,t),e._zod.bag.format=`ipv4`}),Wr=/*@__PURE__*/ T(`$ZodIPv6`,(e,t)=>{t.pattern??=Hn,Dr.init(e,t),e._zod.bag.format=`ipv6`,e._zod.check=n=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:`invalid_format`,format:`ipv6`,input:n.value,inst:e,continue:!t.abort})}}}),Gr=/*@__PURE__*/ T(`$ZodCIDRv4`,(e,t)=>{t.pattern??=Un,Dr.init(e,t)}),Kr=/*@__PURE__*/ T(`$ZodCIDRv6`,(e,t)=>{t.pattern??=Wn,Dr.init(e,t),e._zod.check=n=>{let r=n.value.split(`/`);try{if(r.length!==2)throw Error();let[e,t]=r;if(!t)throw Error();let n=Number(t);if(`${n}`!==t||n<0||n>128)throw Error();new URL(`http://[${e}]`)}catch{n.issues.push({code:`invalid_format`,format:`cidrv6`,input:n.value,inst:e,continue:!t.abort})}}});function qr(e){if(e===``)return!0;if(/\s/.test(e)||e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}let Jr=/*@__PURE__*/ T(`$ZodBase64`,(e,t)=>{t.pattern??=Gn,Dr.init(e,t),e._zod.bag.contentEncoding=`base64`,e._zod.check=n=>{qr(n.value)||n.issues.push({code:`invalid_format`,format:`base64`,input:n.value,inst:e,continue:!t.abort})}});function Yr(e){if(!Kn.test(e))return!1;let t=e.replace(/[-_]/g,e=>e===`-`?`+`:`/`);return qr(t.padEnd(Math.ceil(t.length/4)*4,`=`))}let Xr=/*@__PURE__*/ T(`$ZodBase64URL`,(e,t)=>{t.pattern??=Kn,Dr.init(e,t),e._zod.bag.contentEncoding=`base64url`,e._zod.check=n=>{Yr(n.value)||n.issues.push({code:`invalid_format`,format:`base64url`,input:n.value,inst:e,continue:!t.abort})}}),Zr=/*@__PURE__*/ T(`$ZodE164`,(e,t)=>{t.pattern??=Jn,Dr.init(e,t)});function Qr(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 $r=/*@__PURE__*/ T(`$ZodJWT`,(e,t)=>{Dr.init(e,t),e._zod.check=n=>{Qr(n.value,t.alg)||n.issues.push({code:`invalid_format`,format:`jwt`,input:n.value,inst:e,continue:!t.abort})}}),ei=/*@__PURE__*/ T(`$ZodNumber`,(e,t)=>{O.init(e,t),e._zod.pattern=e._zod.bag.pattern??nr,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}let i=n.value;if(typeof i==`number`&&!Number.isNaN(i)&&Number.isFinite(i))return n;let a=typeof i==`number`?Number.isNaN(i)?`NaN`:Number.isFinite(i)?void 0:`Infinity`:void 0;return n.issues.push({expected:`number`,code:`invalid_type`,input:i,inst:e,...a?{received:a}:{}}),n}}),ti=/*@__PURE__*/ T(`$ZodNumberFormat`,(e,t)=>{fr.init(e,t),ei.init(e,t)}),ni=/*@__PURE__*/ T(`$ZodBoolean`,(e,t)=>{O.init(e,t),e._zod.pattern=rr,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}}),ri=/*@__PURE__*/ T(`$ZodNull`,(e,t)=>{O.init(e,t),e._zod.pattern=ir,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}}),ii=/*@__PURE__*/ T(`$ZodUnknown`,(e,t)=>{O.init(e,t),e._zod.parse=e=>e}),ai=/*@__PURE__*/ T(`$ZodNever`,(e,t)=>{O.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:`never`,code:`invalid_type`,input:t.value,inst:e}),t)});function oi(e,t,n){e.issues.length&&t.issues.push(...on(n,e.issues)),t.value[n]=e.value}let si=/*@__PURE__*/ T(`$ZodArray`,(e,t)=>{O.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!Array.isArray(i))return n.issues.push({expected:`array`,code:`invalid_type`,input:i,inst:e}),n;n.value=Array(i.length);let a=[];for(let e=0;e<i.length;e++){let o=i[e],s=t.element._zod.run({value:o,issues:[]},r);s instanceof Promise?a.push(s.then(t=>oi(t,n,e))):oi(s,n,e)}return a.length?Promise.all(a).then(()=>n):n}});function ci(e,t,n,r,i,a){let o=n in r;if(e.issues.length){if(i&&a&&!o)return;t.issues.push(...on(n,e.issues))}!o&&!i?e.issues.length||t.issues.push({code:`invalid_type`,expected:`nonoptional`,input:void 0,path:[n]}):e.value===void 0?o&&(t.value[n]=void 0):t.value[n]=e.value}function li(e){let t=Object.keys(e.shape);for(let n of t)if(!e.shape?.[n]?._zod?.traits?.has(`$ZodType`))throw Error(`Invalid element at key "${n}": expected a Zod schema`);let n=Jt(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function ui(e,t,n,r,i,a){let o=[],s=i.keySet,c=i.catchall._zod,l=c.def.type,u=c.optin===`optional`,d=c.optout===`optional`;for(let i in t){if(i===`__proto__`||s.has(i))continue;if(l===`never`){o.push(i);continue}let a=c.run({value:t[i],issues:[]},r);a instanceof Promise?e.push(a.then(e=>ci(e,n,i,t,u,d))):ci(a,n,i,t,u,d)}return o.length&&n.issues.push({code:`unrecognized_keys`,keys:o,input:t,inst:a}),e.length?Promise.all(e).then(()=>n):n}let di=/*@__PURE__*/ T(`$ZodObject`,(e,t)=>{if(O.init(e,t),!Object.getOwnPropertyDescriptor(t,`shape`)?.get){let e=t.shape;Object.defineProperty(t,"shape",{get:()=>{let n={...e};return Object.defineProperty(t,"shape",{value:n}),n}})}let n=jt(()=>li(t));E(e._zod,`propValues`,()=>{let e=t.shape,n={};for(let t in e){let r=e[t]._zod;if(r.values){n[t]??(n[t]=/* @__PURE__ */ new Set);for(let e of r.values)n[t].add(e)}}return n});let r=Vt,i=t.catchall,a;e._zod.parse=(t,o)=>{a??=n.value;let s=t.value;if(!r(s))return t.issues.push({expected:`object`,code:`invalid_type`,input:s,inst:e}),t;t.value={};let c=[],l=a.shape;for(let e of a.keys){let n=l[e],r=n._zod.optin===`optional`,i=n._zod.optout===`optional`,a=n._zod.run({value:s[e],issues:[]},o);a instanceof Promise?c.push(a.then(n=>ci(n,t,e,s,r,i))):ci(a,t,e,s,r,i)}return i?ui(c,s,t,o,n.value,e):c.length?Promise.all(c).then(()=>t):t}}),fi=/*@__PURE__*/ T(`$ZodObjectJIT`,(e,t)=>{di.init(e,t);let n=e._zod.parse,r=jt(()=>li(t)),i=e=>{let t=new wr([`shape`,`payload`,`ctx`]),n=r.value,i=e=>{let t=Rt(e);return`shape[${t}]._zod.run({ value: input[${t}], issues: [] }, ctx)`};t.write(`const input = payload.value;`);let a=Object.create(null),o=0;for(let e of n.keys)a[e]=`key_${o++}`;t.write(`const newResult = {};`);for(let r of n.keys){let n=a[r],o=Rt(r),s=e[r],c=s?._zod?.optin===`optional`,l=s?._zod?.optout===`optional`;t.write(`const ${n} = ${i(r)};`),c&&l?t.write(`
|
|
13
|
+
`))}};let Dr={major:4,minor:4,patch:3},O=/*@__PURE__*/ T(`$ZodType`,(e,t)=>{var n;e??={},e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Dr;let r=[...e._zod.def.checks??[]];e._zod.traits.has(`$ZodCheck`)&&r.unshift(e);for(let t of r)for(let n of t._zod.onattach)n(e);if(r.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let t=(e,t,n)=>{let r=on(e),i;for(let a of t){if(a._zod.def.when){if(sn(e)||!a._zod.def.when(e))continue}else if(r)continue;let t=e.issues.length,o=a._zod.check(e);if(o instanceof Promise&&n?.async===!1)throw new Dt;if(i||o instanceof Promise)i=(i??Promise.resolve()).then(async()=>{await o,e.issues.length!==t&&(r||=on(e,t))});else{if(e.issues.length===t)continue;r||=on(e,t)}}return i?i.then(()=>e):e},n=(n,i,a)=>{if(on(n))return n.aborted=!0,n;let o=t(i,r,a);if(o instanceof Promise){if(a.async===!1)throw new Dt;return o.then(t=>e._zod.parse(t,a))}return e._zod.parse(o,a)};e._zod.run=(i,a)=>{if(a.skipChecks)return e._zod.parse(i,a);if(a.direction===`backward`){let t=e._zod.parse({value:i.value,issues:[]},{...a,skipChecks:!0});return t instanceof Promise?t.then(e=>n(e,i,a)):n(t,i,a)}let o=e._zod.parse(i,a);if(o instanceof Promise){if(a.async===!1)throw new Dt;return o.then(e=>t(e,r,a))}return t(o,r,a)}}E(e,`~standard`,()=>({validate:t=>{try{let n=xn(e,t);return n.success?{value:n.data}:{issues:n.error?.issues}}catch{return Cn(e,t).then(e=>e.success?{value:e.data}:{issues:e.error?.issues})}},vendor:`zod`,version:1}))}),Or=/*@__PURE__*/ T(`$ZodString`,(e,t)=>{O.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??nr(e._zod.bag),e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value==`string`||n.issues.push({expected:`string`,code:`invalid_type`,input:n.value,inst:e}),n}}),kr=/*@__PURE__*/ T(`$ZodStringFormat`,(e,t)=>{vr.init(e,t),Or.init(e,t)}),Ar=/*@__PURE__*/ T(`$ZodGUID`,(e,t)=>{t.pattern??=zn,kr.init(e,t)}),jr=/*@__PURE__*/ T(`$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??=Bn(e)}else t.pattern??=Bn();kr.init(e,t)}),Mr=/*@__PURE__*/ T(`$ZodEmail`,(e,t)=>{t.pattern??=Vn,kr.init(e,t)}),Nr=/*@__PURE__*/ T(`$ZodURL`,(e,t)=>{kr.init(e,t),e._zod.check=n=>{try{let r=n.value.trim();if(!t.normalize&&t.protocol?.source===Yn.source&&!/^https?:\/\//i.test(r)){n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid URL format`,input:n.value,inst:e,continue:!t.abort});return}let i=new URL(r);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(i.hostname)||n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid hostname`,pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(i.protocol.endsWith(`:`)?i.protocol.slice(0,-1):i.protocol)||n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid protocol`,pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),n.value=t.normalize?i.href:r;return}catch{n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort})}}}),Pr=/*@__PURE__*/ T(`$ZodEmoji`,(e,t)=>{t.pattern??=Hn(),kr.init(e,t)}),Fr=/*@__PURE__*/ T(`$ZodNanoID`,(e,t)=>{t.pattern??=Ln,kr.init(e,t)}),Ir=/*@__PURE__*/ T(`$ZodCUID`,(e,t)=>{t.pattern??=Mn,kr.init(e,t)}),Lr=/*@__PURE__*/ T(`$ZodCUID2`,(e,t)=>{t.pattern??=Nn,kr.init(e,t)}),Rr=/*@__PURE__*/ T(`$ZodULID`,(e,t)=>{t.pattern??=Pn,kr.init(e,t)}),zr=/*@__PURE__*/ T(`$ZodXID`,(e,t)=>{t.pattern??=Fn,kr.init(e,t)}),Br=/*@__PURE__*/ T(`$ZodKSUID`,(e,t)=>{t.pattern??=In,kr.init(e,t)}),Vr=/*@__PURE__*/ T(`$ZodISODateTime`,(e,t)=>{t.pattern??=tr(t),kr.init(e,t)}),Hr=/*@__PURE__*/ T(`$ZodISODate`,(e,t)=>{t.pattern??=Qn,kr.init(e,t)}),Ur=/*@__PURE__*/ T(`$ZodISOTime`,(e,t)=>{t.pattern??=er(t),kr.init(e,t)}),Wr=/*@__PURE__*/ T(`$ZodISODuration`,(e,t)=>{t.pattern??=Rn,kr.init(e,t)}),Gr=/*@__PURE__*/ T(`$ZodIPv4`,(e,t)=>{t.pattern??=Un,kr.init(e,t),e._zod.bag.format=`ipv4`}),Kr=/*@__PURE__*/ T(`$ZodIPv6`,(e,t)=>{t.pattern??=Wn,kr.init(e,t),e._zod.bag.format=`ipv6`,e._zod.check=n=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:`invalid_format`,format:`ipv6`,input:n.value,inst:e,continue:!t.abort})}}}),qr=/*@__PURE__*/ T(`$ZodCIDRv4`,(e,t)=>{t.pattern??=Gn,kr.init(e,t)}),Jr=/*@__PURE__*/ T(`$ZodCIDRv6`,(e,t)=>{t.pattern??=Kn,kr.init(e,t),e._zod.check=n=>{let r=n.value.split(`/`);try{if(r.length!==2)throw Error();let[e,t]=r;if(!t)throw Error();let n=Number(t);if(`${n}`!==t||n<0||n>128)throw Error();new URL(`http://[${e}]`)}catch{n.issues.push({code:`invalid_format`,format:`cidrv6`,input:n.value,inst:e,continue:!t.abort})}}});function Yr(e){if(e===``)return!0;if(/\s/.test(e)||e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}let Xr=/*@__PURE__*/ T(`$ZodBase64`,(e,t)=>{t.pattern??=qn,kr.init(e,t),e._zod.bag.contentEncoding=`base64`,e._zod.check=n=>{Yr(n.value)||n.issues.push({code:`invalid_format`,format:`base64`,input:n.value,inst:e,continue:!t.abort})}});function Zr(e){if(!Jn.test(e))return!1;let t=e.replace(/[-_]/g,e=>e===`-`?`+`:`/`);return Yr(t.padEnd(Math.ceil(t.length/4)*4,`=`))}let Qr=/*@__PURE__*/ T(`$ZodBase64URL`,(e,t)=>{t.pattern??=Jn,kr.init(e,t),e._zod.bag.contentEncoding=`base64url`,e._zod.check=n=>{Zr(n.value)||n.issues.push({code:`invalid_format`,format:`base64url`,input:n.value,inst:e,continue:!t.abort})}}),$r=/*@__PURE__*/ T(`$ZodE164`,(e,t)=>{t.pattern??=Xn,kr.init(e,t)});function ei(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 ti=/*@__PURE__*/ T(`$ZodJWT`,(e,t)=>{kr.init(e,t),e._zod.check=n=>{ei(n.value,t.alg)||n.issues.push({code:`invalid_format`,format:`jwt`,input:n.value,inst:e,continue:!t.abort})}}),ni=/*@__PURE__*/ T(`$ZodNumber`,(e,t)=>{O.init(e,t),e._zod.pattern=e._zod.bag.pattern??ir,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}let i=n.value;if(typeof i==`number`&&!Number.isNaN(i)&&Number.isFinite(i))return n;let a=typeof i==`number`?Number.isNaN(i)?`NaN`:Number.isFinite(i)?void 0:`Infinity`:void 0;return n.issues.push({expected:`number`,code:`invalid_type`,input:i,inst:e,...a?{received:a}:{}}),n}}),ri=/*@__PURE__*/ T(`$ZodNumberFormat`,(e,t)=>{mr.init(e,t),ni.init(e,t)}),ii=/*@__PURE__*/ T(`$ZodBoolean`,(e,t)=>{O.init(e,t),e._zod.pattern=ar,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}}),ai=/*@__PURE__*/ T(`$ZodNull`,(e,t)=>{O.init(e,t),e._zod.pattern=or,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}}),oi=/*@__PURE__*/ T(`$ZodUnknown`,(e,t)=>{O.init(e,t),e._zod.parse=e=>e}),si=/*@__PURE__*/ T(`$ZodNever`,(e,t)=>{O.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:`never`,code:`invalid_type`,input:t.value,inst:e}),t)});function ci(e,t,n){e.issues.length&&t.issues.push(...cn(n,e.issues)),t.value[n]=e.value}let li=/*@__PURE__*/ T(`$ZodArray`,(e,t)=>{O.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!Array.isArray(i))return n.issues.push({expected:`array`,code:`invalid_type`,input:i,inst:e}),n;n.value=Array(i.length);let a=[];for(let e=0;e<i.length;e++){let o=i[e],s=t.element._zod.run({value:o,issues:[]},r);s instanceof Promise?a.push(s.then(t=>ci(t,n,e))):ci(s,n,e)}return a.length?Promise.all(a).then(()=>n):n}});function ui(e,t,n,r,i,a){let o=n in r;if(e.issues.length){if(i&&a&&!o)return;t.issues.push(...cn(n,e.issues))}!o&&!i?e.issues.length||t.issues.push({code:`invalid_type`,expected:`nonoptional`,input:void 0,path:[n]}):e.value===void 0?o&&(t.value[n]=void 0):t.value[n]=e.value}function di(e){let t=Object.keys(e.shape);for(let n of t)if(!e.shape?.[n]?._zod?.traits?.has(`$ZodType`))throw Error(`Invalid element at key "${n}": expected a Zod schema`);let n=Xt(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function fi(e,t,n,r,i,a){let o=[],s=i.keySet,c=i.catchall._zod,l=c.def.type,u=c.optin===`optional`,d=c.optout===`optional`;for(let i in t){if(i===`__proto__`||s.has(i))continue;if(l===`never`){o.push(i);continue}let a=c.run({value:t[i],issues:[]},r);a instanceof Promise?e.push(a.then(e=>ui(e,n,i,t,u,d))):ui(a,n,i,t,u,d)}return o.length&&n.issues.push({code:`unrecognized_keys`,keys:o,input:t,inst:a}),e.length?Promise.all(e).then(()=>n):n}let pi=/*@__PURE__*/ T(`$ZodObject`,(e,t)=>{if(O.init(e,t),!Object.getOwnPropertyDescriptor(t,`shape`)?.get){let e=t.shape;Object.defineProperty(t,"shape",{get:()=>{let n={...e};return Object.defineProperty(t,"shape",{value:n}),n}})}let n=Nt(()=>di(t));E(e._zod,`propValues`,()=>{let e=t.shape,n={};for(let t in e){let r=e[t]._zod;if(r.values){n[t]??(n[t]=/* @__PURE__ */ new Set);for(let e of r.values)n[t].add(e)}}return n});let r=Ut,i=t.catchall,a;e._zod.parse=(t,o)=>{a??=n.value;let s=t.value;if(!r(s))return t.issues.push({expected:`object`,code:`invalid_type`,input:s,inst:e}),t;t.value={};let c=[],l=a.shape;for(let e of a.keys){let n=l[e],r=n._zod.optin===`optional`,i=n._zod.optout===`optional`,a=n._zod.run({value:s[e],issues:[]},o);a instanceof Promise?c.push(a.then(n=>ui(n,t,e,s,r,i))):ui(a,t,e,s,r,i)}return i?fi(c,s,t,o,n.value,e):c.length?Promise.all(c).then(()=>t):t}}),mi=/*@__PURE__*/ T(`$ZodObjectJIT`,(e,t)=>{pi.init(e,t);let n=e._zod.parse,r=Nt(()=>di(t)),i=e=>{let t=new Er([`shape`,`payload`,`ctx`]),n=r.value,i=e=>{let t=Bt(e);return`shape[${t}]._zod.run({ value: input[${t}], issues: [] }, ctx)`};t.write(`const input = payload.value;`);let a=Object.create(null),o=0;for(let e of n.keys)a[e]=`key_${o++}`;t.write(`const newResult = {};`);for(let r of n.keys){let n=a[r],o=Bt(r),s=e[r],c=s?._zod?.optin===`optional`,l=s?._zod?.optout===`optional`;t.write(`const ${n} = ${i(r)};`),c&&l?t.write(`
|
|
14
14
|
if (${n}.issues.length) {
|
|
15
15
|
if (${o} in input) {
|
|
16
16
|
payload.issues = payload.issues.concat(${n}.issues.map(iss => ({
|
|
@@ -69,113 +69,116 @@ default:Ae(e.groups)}return{upserts:t,removes:n}}},Ve=class{store;key;listeners=
|
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
-
`)}t.write(`payload.value = newResult;`),t.write(`return payload;`);let s=t.compile();return(t,n)=>s(e,t,n)},a,o=Vt,s=!Dt.jitless,c=s&&Ht.value,l=t.catchall,u;e._zod.parse=(d,f)=>{u??=r.value;let p=d.value;return o(p)?s&&c&&f?.async===!1&&f.jitless!==!0?(a||=i(t.shape),d=a(d,f),l?ui([],p,d,f,u,e):d):n(d,f):(d.issues.push({expected:`object`,code:`invalid_type`,input:p,inst:e}),d)}});function pi(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=>!rn(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=>cn(e,r,Ot())))}),t)}let mi=/*@__PURE__*/ T(`$ZodUnion`,(e,t)=>{O.init(e,t),E(e._zod,`optin`,()=>t.options.some(e=>e._zod.optin===`optional`)?`optional`:void 0),E(e._zod,`optout`,()=>t.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),E(e._zod,`values`,()=>{if(t.options.every(e=>e._zod.values))return new Set(t.options.flatMap(e=>Array.from(e._zod.values)))}),E(e._zod,`pattern`,()=>{if(t.options.every(e=>e._zod.pattern)){let e=t.options.map(e=>e._zod.pattern);return RegExp(`^(${e.map(e=>Nt(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=>pi(t,r,e,i)):pi(o,r,e,i)}}),hi=/*@__PURE__*/ T(`$ZodDiscriminatedUnion`,(e,t)=>{t.inclusive=!1,mi.init(e,t);let n=e._zod.parse;E(e._zod,`propValues`,()=>{let e={};for(let n of t.options){let r=n._zod.propValues;if(!r||Object.keys(r).length===0)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(n)}"`);for(let[t,n]of Object.entries(r)){e[t]||(e[t]=/* @__PURE__ */ new Set);for(let r of n)e[t].add(r)}}return e});let r=jt(()=>{let e=t.options,n=/* @__PURE__ */ new Map;for(let r of e){let e=r._zod.propValues?.[t.discriminator];if(!e||e.size===0)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(r)}"`);for(let t of e){if(n.has(t))throw Error(`Duplicate discriminator value "${String(t)}"`);n.set(t,r)}}return n});e._zod.parse=(i,a)=>{let o=i.value;if(!Vt(o))return i.issues.push({code:`invalid_type`,expected:`object`,input:o,inst:e}),i;let s=r.value.get(o?.[t.discriminator]);return s?s._zod.run(i,a):t.unionFallback||a.direction===`backward`?n(i,a):(i.issues.push({code:`invalid_union`,errors:[],note:`No matching discriminator`,discriminator:t.discriminator,options:Array.from(r.value.keys()),input:o,path:[t.discriminator],inst:e}),i)}}),gi=/*@__PURE__*/ T(`$ZodIntersection`,(e,t)=>{O.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])=>vi(e,t,n)):vi(e,i,a)}});function _i(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(Ut(e)&&Ut(t)){let n=Object.keys(t),r=Object.keys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};for(let n of r){let r=_i(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=_i(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 vi(e,t,n){let r=/* @__PURE__ */ new Map,i;for(let n of t.issues)if(n.code===`unrecognized_keys`){i??=n;for(let e of n.keys)r.has(e)||r.set(e,{}),r.get(e).l=!0}else e.issues.push(n);for(let t of n.issues)if(t.code===`unrecognized_keys`)for(let e of t.keys)r.has(e)||r.set(e,{}),r.get(e).r=!0;else e.issues.push(t);let a=[...r].filter(([,e])=>e.l&&e.r).map(([e])=>e);if(a.length&&i&&e.issues.push({...i,keys:a}),rn(e))return e;let o=_i(t.value,n.value);if(!o.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(o.mergeErrorPath)}`);return e.value=o.data,e}let yi=/*@__PURE__*/ T(`$ZodTuple`,(e,t)=>{O.init(e,t);let n=t.items;e._zod.parse=(r,i)=>{let a=r.value;if(!Array.isArray(a))return r.issues.push({input:a,inst:e,expected:`tuple`,code:`invalid_type`}),r;r.value=[];let o=[],s=bi(n,`optin`),c=bi(n,`optout`);if(!t.rest){if(a.length<s)return r.issues.push({code:`too_small`,minimum:s,inclusive:!0,input:a,inst:e,origin:`array`}),r;a.length>n.length&&r.issues.push({code:`too_big`,maximum:n.length,inclusive:!0,input:a,inst:e,origin:`array`})}let l=Array(n.length);for(let e=0;e<n.length;e++){let t=n[e]._zod.run({value:a[e],issues:[]},i);t instanceof Promise?o.push(t.then(t=>{l[e]=t})):l[e]=t}if(t.rest){let e=n.length-1,s=a.slice(n.length);for(let n of s){e++;let a=t.rest._zod.run({value:n,issues:[]},i);a instanceof Promise?o.push(a.then(t=>xi(t,r,e))):xi(a,r,e)}}return o.length?Promise.all(o).then(()=>Si(l,r,n,a,c)):Si(l,r,n,a,c)}});function bi(e,t){for(let n=e.length-1;n>=0;n--)if(e[n]._zod[t]!==`optional`)return n+1;return 0}function xi(e,t,n){e.issues.length&&t.issues.push(...on(n,e.issues)),t.value[n]=e.value}function Si(e,t,n,r,i){for(let a=0;a<n.length;a++){let n=e[a],o=a<r.length;if(n.issues.length){if(!o&&a>=i){t.value.length=a;break}t.issues.push(...on(a,n.issues))}t.value[a]=n.value}for(let e=t.value.length-1;e>=r.length&&n[e]._zod.optout===`optional`&&t.value[e]===void 0;e--)t.value.length=e;return t}let Ci=/*@__PURE__*/ T(`$ZodRecord`,(e,t)=>{O.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!Ut(i))return n.issues.push({expected:`record`,code:`invalid_type`,input:i,inst:e}),n;let a=[],o=t.keyType._zod.values;if(o){n.value={};let s=/* @__PURE__ */ new Set;for(let c of o)if(typeof c==`string`||typeof c==`number`||typeof c==`symbol`){s.add(typeof c==`number`?c.toString():c);let o=t.keyType._zod.run({value:c,issues:[]},r);if(o instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(o.issues.length){n.issues.push({code:`invalid_key`,origin:`record`,issues:o.issues.map(e=>cn(e,r,Ot())),input:c,path:[c],inst:e});continue}let l=o.value,u=t.valueType._zod.run({value:i[c],issues:[]},r);u instanceof Promise?a.push(u.then(e=>{e.issues.length&&n.issues.push(...on(c,e.issues)),n.value[l]=e.value})):(u.issues.length&&n.issues.push(...on(c,u.issues)),n.value[l]=u.value)}let c;for(let e in i)s.has(e)||(c??=[],c.push(e));c&&c.length>0&&n.issues.push({code:`unrecognized_keys`,input:i,inst:e,keys:c})}else{n.value={};for(let o of Reflect.ownKeys(i)){if(o===`__proto__`||!Object.prototype.propertyIsEnumerable.call(i,o))continue;let s=t.keyType._zod.run({value:o,issues:[]},r);if(s instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(typeof o==`string`&&nr.test(o)&&s.issues.length){let e=t.keyType._zod.run({value:Number(o),issues:[]},r);if(e instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);e.issues.length===0&&(s=e)}if(s.issues.length){t.mode===`loose`?n.value[o]=i[o]:n.issues.push({code:`invalid_key`,origin:`record`,issues:s.issues.map(e=>cn(e,r,Ot())),input:o,path:[o],inst:e});continue}let c=t.valueType._zod.run({value:i[o],issues:[]},r);c instanceof Promise?a.push(c.then(e=>{e.issues.length&&n.issues.push(...on(o,e.issues)),n.value[s.value]=e.value})):(c.issues.length&&n.issues.push(...on(o,c.issues)),n.value[s.value]=c.value)}}return a.length?Promise.all(a).then(()=>n):n}}),wi=/*@__PURE__*/ T(`$ZodEnum`,(e,t)=>{O.init(e,t);let n=kt(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=RegExp(`^(${n.filter(e=>Gt.has(typeof e)).map(e=>typeof e==`string`?Kt(e):e.toString()).join(`|`)})$`),e._zod.parse=(t,i)=>{let a=t.value;return r.has(a)||t.issues.push({code:`invalid_value`,values:n,input:a,inst:e}),t}}),Ti=/*@__PURE__*/ T(`$ZodLiteral`,(e,t)=>{if(O.init(e,t),t.values.length===0)throw Error(`Cannot create literal schema with no valid values`);let n=new Set(t.values);e._zod.values=n,e._zod.pattern=RegExp(`^(${t.values.map(e=>typeof e==`string`?Kt(e):e?Kt(e.toString()):String(e)).join(`|`)})$`),e._zod.parse=(r,i)=>{let a=r.value;return n.has(a)||r.issues.push({code:`invalid_value`,values:t.values,input:a,inst:e}),r}}),Ei=/*@__PURE__*/ T(`$ZodTransform`,(e,t)=>{O.init(e,t),e._zod.optin=`optional`,e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new Et(e.constructor.name);let i=t.transform(n.value,n);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(e=>(n.value=e,n.fallback=!0,n));if(i instanceof Promise)throw new Tt;return n.value=i,n.fallback=!0,n}});function Di(e,t){return t===void 0&&(e.issues.length||e.fallback)?{issues:[],value:void 0}:e}let Oi=/*@__PURE__*/ T(`$ZodOptional`,(e,t)=>{O.init(e,t),e._zod.optin=`optional`,e._zod.optout=`optional`,E(e._zod,`values`,()=>t.innerType._zod.values?/* @__PURE__ */ new Set([...t.innerType._zod.values,void 0]):void 0),E(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${Nt(e.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if(t.innerType._zod.optin===`optional`){let r=e.value,i=t.innerType._zod.run(e,n);return i instanceof Promise?i.then(e=>Di(e,r)):Di(i,r)}return e.value===void 0?e:t.innerType._zod.run(e,n)}}),ki=/*@__PURE__*/ T(`$ZodExactOptional`,(e,t)=>{Oi.init(e,t),E(e._zod,`values`,()=>t.innerType._zod.values),E(e._zod,`pattern`,()=>t.innerType._zod.pattern),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),Ai=/*@__PURE__*/ T(`$ZodNullable`,(e,t)=>{O.init(e,t),E(e._zod,`optin`,()=>t.innerType._zod.optin),E(e._zod,`optout`,()=>t.innerType._zod.optout),E(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${Nt(e.source)}|null)$`):void 0}),E(e._zod,`values`,()=>t.innerType._zod.values?/* @__PURE__ */ new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>e.value===null?e:t.innerType._zod.run(e,n)}),ji=/*@__PURE__*/ T(`$ZodDefault`,(e,t)=>{O.init(e,t),e._zod.optin=`optional`,E(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);if(e.value===void 0)return e.value=t.defaultValue,e;let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(e=>Mi(e,t)):Mi(r,t)}});function Mi(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}let Ni=/*@__PURE__*/ T(`$ZodPrefault`,(e,t)=>{O.init(e,t),e._zod.optin=`optional`,E(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>(n.direction===`backward`||e.value===void 0&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))}),Pi=/*@__PURE__*/ T(`$ZodNonOptional`,(e,t)=>{O.init(e,t),E(e._zod,`values`,()=>{let e=t.innerType._zod.values;return e?new Set([...e].filter(e=>e!==void 0)):void 0}),e._zod.parse=(n,r)=>{let i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(t=>Fi(t,e)):Fi(i,e)}});function Fi(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:`invalid_type`,expected:`nonoptional`,input:e.value,inst:t}),e}let Ii=/*@__PURE__*/ T(`$ZodCatch`,(e,t)=>{O.init(e,t),e._zod.optin=`optional`,E(e._zod,`optout`,()=>t.innerType._zod.optout),E(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(r=>(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>cn(e,n,Ot()))},input:e.value}),e.issues=[],e.fallback=!0),e)):(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>cn(e,n,Ot()))},input:e.value}),e.issues=[],e.fallback=!0),e)}}),Li=/*@__PURE__*/ T(`$ZodPipe`,(e,t)=>{O.init(e,t),E(e._zod,`values`,()=>t.in._zod.values),E(e._zod,`optin`,()=>t.in._zod.optin),E(e._zod,`optout`,()=>t.out._zod.optout),E(e._zod,`propValues`,()=>t.in._zod.propValues),e._zod.parse=(e,n)=>{if(n.direction===`backward`){let r=t.out._zod.run(e,n);return r instanceof Promise?r.then(e=>Ri(e,t.in,n)):Ri(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>Ri(e,t.out,n)):Ri(r,t.out,n)}});function Ri(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues,fallback:e.fallback},n)}let zi=/*@__PURE__*/ T(`$ZodReadonly`,(e,t)=>{O.init(e,t),E(e._zod,`propValues`,()=>t.innerType._zod.propValues),E(e._zod,`values`,()=>t.innerType._zod.values),E(e._zod,`optin`,()=>t.innerType?._zod?.optin),E(e._zod,`optout`,()=>t.innerType?._zod?.optout),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(Bi):Bi(r)}});function Bi(e){return e.value=Object.freeze(e.value),e}let Vi=/*@__PURE__*/ T(`$ZodLazy`,(e,t)=>{O.init(e,t),E(e._zod,`innerType`,()=>{let e=t;return e._cachedInner||=t.getter(),e._cachedInner}),E(e._zod,`pattern`,()=>e._zod.innerType?._zod?.pattern),E(e._zod,`propValues`,()=>e._zod.innerType?._zod?.propValues),E(e._zod,`optin`,()=>e._zod.innerType?._zod?.optin??void 0),E(e._zod,`optout`,()=>e._zod.innerType?._zod?.optout??void 0),e._zod.parse=(t,n)=>e._zod.innerType._zod.run(t,n)}),Hi=/*@__PURE__*/ T(`$ZodCustom`,(e,t)=>{sr.init(e,t),O.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=>Ui(t,n,r,e));Ui(i,n,r,e)}});function Ui(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(un(e))}}var Wi,Gi=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 Ki(){return new Gi}(Wi=globalThis).__zod_globalRegistry??(Wi.__zod_globalRegistry=Ki());let qi=globalThis.__zod_globalRegistry;// @__NO_SIDE_EFFECTS__
|
|
73
|
-
function
|
|
74
|
-
function
|
|
75
|
-
function
|
|
76
|
-
function
|
|
77
|
-
function
|
|
78
|
-
function
|
|
79
|
-
function
|
|
80
|
-
function
|
|
81
|
-
function
|
|
82
|
-
function
|
|
83
|
-
function
|
|
84
|
-
function
|
|
85
|
-
function
|
|
86
|
-
function
|
|
87
|
-
function
|
|
88
|
-
function
|
|
89
|
-
function
|
|
90
|
-
function
|
|
91
|
-
function
|
|
92
|
-
function
|
|
93
|
-
function
|
|
94
|
-
function
|
|
95
|
-
function
|
|
96
|
-
function
|
|
97
|
-
function
|
|
98
|
-
function
|
|
99
|
-
function
|
|
100
|
-
function
|
|
101
|
-
function
|
|
102
|
-
function
|
|
103
|
-
function
|
|
104
|
-
function
|
|
105
|
-
function
|
|
106
|
-
function
|
|
107
|
-
function
|
|
108
|
-
function
|
|
109
|
-
function
|
|
110
|
-
function
|
|
111
|
-
function
|
|
112
|
-
function
|
|
113
|
-
function
|
|
114
|
-
function
|
|
115
|
-
function
|
|
116
|
-
function
|
|
117
|
-
function
|
|
118
|
-
function
|
|
119
|
-
function
|
|
120
|
-
function
|
|
121
|
-
function
|
|
122
|
-
function
|
|
123
|
-
function
|
|
124
|
-
function
|
|
125
|
-
function
|
|
126
|
-
function
|
|
127
|
-
function
|
|
128
|
-
function
|
|
129
|
-
function
|
|
130
|
-
function
|
|
72
|
+
`)}t.write(`payload.value = newResult;`),t.write(`return payload;`);let s=t.compile();return(t,n)=>s(e,t,n)},a,o=Ut,s=!kt.jitless,c=s&&Wt.value,l=t.catchall,u;e._zod.parse=(d,f)=>{u??=r.value;let p=d.value;return o(p)?s&&c&&f?.async===!1&&f.jitless!==!0?(a||=i(t.shape),d=a(d,f),l?fi([],p,d,f,u,e):d):n(d,f):(d.issues.push({expected:`object`,code:`invalid_type`,input:p,inst:e}),d)}});function hi(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=>un(e,r,At())))}),t)}let gi=/*@__PURE__*/ T(`$ZodUnion`,(e,t)=>{O.init(e,t),E(e._zod,`optin`,()=>t.options.some(e=>e._zod.optin===`optional`)?`optional`:void 0),E(e._zod,`optout`,()=>t.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),E(e._zod,`values`,()=>{if(t.options.every(e=>e._zod.values))return new Set(t.options.flatMap(e=>Array.from(e._zod.values)))}),E(e._zod,`pattern`,()=>{if(t.options.every(e=>e._zod.pattern)){let e=t.options.map(e=>e._zod.pattern);return RegExp(`^(${e.map(e=>Ft(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=>hi(t,r,e,i)):hi(o,r,e,i)}}),_i=/*@__PURE__*/ T(`$ZodDiscriminatedUnion`,(e,t)=>{t.inclusive=!1,gi.init(e,t);let n=e._zod.parse;E(e._zod,`propValues`,()=>{let e={};for(let n of t.options){let r=n._zod.propValues;if(!r||Object.keys(r).length===0)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(n)}"`);for(let[t,n]of Object.entries(r)){e[t]||(e[t]=/* @__PURE__ */ new Set);for(let r of n)e[t].add(r)}}return e});let r=Nt(()=>{let e=t.options,n=/* @__PURE__ */ new Map;for(let r of e){let e=r._zod.propValues?.[t.discriminator];if(!e||e.size===0)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(r)}"`);for(let t of e){if(n.has(t))throw Error(`Duplicate discriminator value "${String(t)}"`);n.set(t,r)}}return n});e._zod.parse=(i,a)=>{let o=i.value;if(!Ut(o))return i.issues.push({code:`invalid_type`,expected:`object`,input:o,inst:e}),i;let s=r.value.get(o?.[t.discriminator]);return s?s._zod.run(i,a):t.unionFallback||a.direction===`backward`?n(i,a):(i.issues.push({code:`invalid_union`,errors:[],note:`No matching discriminator`,discriminator:t.discriminator,options:Array.from(r.value.keys()),input:o,path:[t.discriminator],inst:e}),i)}}),vi=/*@__PURE__*/ T(`$ZodIntersection`,(e,t)=>{O.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])=>bi(e,t,n)):bi(e,i,a)}});function yi(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(Gt(e)&&Gt(t)){let n=Object.keys(t),r=Object.keys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};for(let n of r){let r=yi(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=yi(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 bi(e,t,n){let r=/* @__PURE__ */ new Map,i;for(let n of t.issues)if(n.code===`unrecognized_keys`){i??=n;for(let e of n.keys)r.has(e)||r.set(e,{}),r.get(e).l=!0}else e.issues.push(n);for(let t of n.issues)if(t.code===`unrecognized_keys`)for(let e of t.keys)r.has(e)||r.set(e,{}),r.get(e).r=!0;else e.issues.push(t);let a=[...r].filter(([,e])=>e.l&&e.r).map(([e])=>e);if(a.length&&i&&e.issues.push({...i,keys:a}),on(e))return e;let o=yi(t.value,n.value);if(!o.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(o.mergeErrorPath)}`);return e.value=o.data,e}let xi=/*@__PURE__*/ T(`$ZodTuple`,(e,t)=>{O.init(e,t);let n=t.items;e._zod.parse=(r,i)=>{let a=r.value;if(!Array.isArray(a))return r.issues.push({input:a,inst:e,expected:`tuple`,code:`invalid_type`}),r;r.value=[];let o=[],s=Si(n,`optin`),c=Si(n,`optout`);if(!t.rest){if(a.length<s)return r.issues.push({code:`too_small`,minimum:s,inclusive:!0,input:a,inst:e,origin:`array`}),r;a.length>n.length&&r.issues.push({code:`too_big`,maximum:n.length,inclusive:!0,input:a,inst:e,origin:`array`})}let l=Array(n.length);for(let e=0;e<n.length;e++){let t=n[e]._zod.run({value:a[e],issues:[]},i);t instanceof Promise?o.push(t.then(t=>{l[e]=t})):l[e]=t}if(t.rest){let e=n.length-1,s=a.slice(n.length);for(let n of s){e++;let a=t.rest._zod.run({value:n,issues:[]},i);a instanceof Promise?o.push(a.then(t=>Ci(t,r,e))):Ci(a,r,e)}}return o.length?Promise.all(o).then(()=>wi(l,r,n,a,c)):wi(l,r,n,a,c)}});function Si(e,t){for(let n=e.length-1;n>=0;n--)if(e[n]._zod[t]!==`optional`)return n+1;return 0}function Ci(e,t,n){e.issues.length&&t.issues.push(...cn(n,e.issues)),t.value[n]=e.value}function wi(e,t,n,r,i){for(let a=0;a<n.length;a++){let n=e[a],o=a<r.length;if(n.issues.length){if(!o&&a>=i){t.value.length=a;break}t.issues.push(...cn(a,n.issues))}t.value[a]=n.value}for(let e=t.value.length-1;e>=r.length&&n[e]._zod.optout===`optional`&&t.value[e]===void 0;e--)t.value.length=e;return t}let Ti=/*@__PURE__*/ T(`$ZodRecord`,(e,t)=>{O.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!Gt(i))return n.issues.push({expected:`record`,code:`invalid_type`,input:i,inst:e}),n;let a=[],o=t.keyType._zod.values;if(o){n.value={};let s=/* @__PURE__ */ new Set;for(let c of o)if(typeof c==`string`||typeof c==`number`||typeof c==`symbol`){s.add(typeof c==`number`?c.toString():c);let o=t.keyType._zod.run({value:c,issues:[]},r);if(o instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(o.issues.length){n.issues.push({code:`invalid_key`,origin:`record`,issues:o.issues.map(e=>un(e,r,At())),input:c,path:[c],inst:e});continue}let l=o.value,u=t.valueType._zod.run({value:i[c],issues:[]},r);u instanceof Promise?a.push(u.then(e=>{e.issues.length&&n.issues.push(...cn(c,e.issues)),n.value[l]=e.value})):(u.issues.length&&n.issues.push(...cn(c,u.issues)),n.value[l]=u.value)}let c;for(let e in i)s.has(e)||(c??=[],c.push(e));c&&c.length>0&&n.issues.push({code:`unrecognized_keys`,input:i,inst:e,keys:c})}else{n.value={};for(let o of Reflect.ownKeys(i)){if(o===`__proto__`||!Object.prototype.propertyIsEnumerable.call(i,o))continue;let s=t.keyType._zod.run({value:o,issues:[]},r);if(s instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(typeof o==`string`&&ir.test(o)&&s.issues.length){let e=t.keyType._zod.run({value:Number(o),issues:[]},r);if(e instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);e.issues.length===0&&(s=e)}if(s.issues.length){t.mode===`loose`?n.value[o]=i[o]:n.issues.push({code:`invalid_key`,origin:`record`,issues:s.issues.map(e=>un(e,r,At())),input:o,path:[o],inst:e});continue}let c=t.valueType._zod.run({value:i[o],issues:[]},r);c instanceof Promise?a.push(c.then(e=>{e.issues.length&&n.issues.push(...cn(o,e.issues)),n.value[s.value]=e.value})):(c.issues.length&&n.issues.push(...cn(o,c.issues)),n.value[s.value]=c.value)}}return a.length?Promise.all(a).then(()=>n):n}}),Ei=/*@__PURE__*/ T(`$ZodEnum`,(e,t)=>{O.init(e,t);let n=jt(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=RegExp(`^(${n.filter(e=>qt.has(typeof e)).map(e=>typeof e==`string`?Jt(e):e.toString()).join(`|`)})$`),e._zod.parse=(t,i)=>{let a=t.value;return r.has(a)||t.issues.push({code:`invalid_value`,values:n,input:a,inst:e}),t}}),Di=/*@__PURE__*/ T(`$ZodLiteral`,(e,t)=>{if(O.init(e,t),t.values.length===0)throw Error(`Cannot create literal schema with no valid values`);let n=new Set(t.values);e._zod.values=n,e._zod.pattern=RegExp(`^(${t.values.map(e=>typeof e==`string`?Jt(e):e?Jt(e.toString()):String(e)).join(`|`)})$`),e._zod.parse=(r,i)=>{let a=r.value;return n.has(a)||r.issues.push({code:`invalid_value`,values:t.values,input:a,inst:e}),r}}),Oi=/*@__PURE__*/ T(`$ZodTransform`,(e,t)=>{O.init(e,t),e._zod.optin=`optional`,e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new Ot(e.constructor.name);let i=t.transform(n.value,n);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(e=>(n.value=e,n.fallback=!0,n));if(i instanceof Promise)throw new Dt;return n.value=i,n.fallback=!0,n}});function ki(e,t){return t===void 0&&(e.issues.length||e.fallback)?{issues:[],value:void 0}:e}let Ai=/*@__PURE__*/ T(`$ZodOptional`,(e,t)=>{O.init(e,t),e._zod.optin=`optional`,e._zod.optout=`optional`,E(e._zod,`values`,()=>t.innerType._zod.values?/* @__PURE__ */ new Set([...t.innerType._zod.values,void 0]):void 0),E(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${Ft(e.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if(t.innerType._zod.optin===`optional`){let r=e.value,i=t.innerType._zod.run(e,n);return i instanceof Promise?i.then(e=>ki(e,r)):ki(i,r)}return e.value===void 0?e:t.innerType._zod.run(e,n)}}),ji=/*@__PURE__*/ T(`$ZodExactOptional`,(e,t)=>{Ai.init(e,t),E(e._zod,`values`,()=>t.innerType._zod.values),E(e._zod,`pattern`,()=>t.innerType._zod.pattern),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),Mi=/*@__PURE__*/ T(`$ZodNullable`,(e,t)=>{O.init(e,t),E(e._zod,`optin`,()=>t.innerType._zod.optin),E(e._zod,`optout`,()=>t.innerType._zod.optout),E(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${Ft(e.source)}|null)$`):void 0}),E(e._zod,`values`,()=>t.innerType._zod.values?/* @__PURE__ */ new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>e.value===null?e:t.innerType._zod.run(e,n)}),Ni=/*@__PURE__*/ T(`$ZodDefault`,(e,t)=>{O.init(e,t),e._zod.optin=`optional`,E(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);if(e.value===void 0)return e.value=t.defaultValue,e;let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(e=>Pi(e,t)):Pi(r,t)}});function Pi(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}let Fi=/*@__PURE__*/ T(`$ZodPrefault`,(e,t)=>{O.init(e,t),e._zod.optin=`optional`,E(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>(n.direction===`backward`||e.value===void 0&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))}),Ii=/*@__PURE__*/ T(`$ZodNonOptional`,(e,t)=>{O.init(e,t),E(e._zod,`values`,()=>{let e=t.innerType._zod.values;return e?new Set([...e].filter(e=>e!==void 0)):void 0}),e._zod.parse=(n,r)=>{let i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(t=>Li(t,e)):Li(i,e)}});function Li(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:`invalid_type`,expected:`nonoptional`,input:e.value,inst:t}),e}let Ri=/*@__PURE__*/ T(`$ZodCatch`,(e,t)=>{O.init(e,t),e._zod.optin=`optional`,E(e._zod,`optout`,()=>t.innerType._zod.optout),E(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(r=>(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>un(e,n,At()))},input:e.value}),e.issues=[],e.fallback=!0),e)):(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>un(e,n,At()))},input:e.value}),e.issues=[],e.fallback=!0),e)}}),zi=/*@__PURE__*/ T(`$ZodPipe`,(e,t)=>{O.init(e,t),E(e._zod,`values`,()=>t.in._zod.values),E(e._zod,`optin`,()=>t.in._zod.optin),E(e._zod,`optout`,()=>t.out._zod.optout),E(e._zod,`propValues`,()=>t.in._zod.propValues),e._zod.parse=(e,n)=>{if(n.direction===`backward`){let r=t.out._zod.run(e,n);return r instanceof Promise?r.then(e=>Bi(e,t.in,n)):Bi(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>Bi(e,t.out,n)):Bi(r,t.out,n)}});function Bi(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues,fallback:e.fallback},n)}let Vi=/*@__PURE__*/ T(`$ZodReadonly`,(e,t)=>{O.init(e,t),E(e._zod,`propValues`,()=>t.innerType._zod.propValues),E(e._zod,`values`,()=>t.innerType._zod.values),E(e._zod,`optin`,()=>t.innerType?._zod?.optin),E(e._zod,`optout`,()=>t.innerType?._zod?.optout),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(Hi):Hi(r)}});function Hi(e){return e.value=Object.freeze(e.value),e}let Ui=/*@__PURE__*/ T(`$ZodLazy`,(e,t)=>{O.init(e,t),E(e._zod,`innerType`,()=>{let e=t;return e._cachedInner||=t.getter(),e._cachedInner}),E(e._zod,`pattern`,()=>e._zod.innerType?._zod?.pattern),E(e._zod,`propValues`,()=>e._zod.innerType?._zod?.propValues),E(e._zod,`optin`,()=>e._zod.innerType?._zod?.optin??void 0),E(e._zod,`optout`,()=>e._zod.innerType?._zod?.optout??void 0),e._zod.parse=(t,n)=>e._zod.innerType._zod.run(t,n)}),Wi=/*@__PURE__*/ T(`$ZodCustom`,(e,t)=>{lr.init(e,t),O.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=>Gi(t,n,r,e));Gi(i,n,r,e)}});function Gi(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(fn(e))}}var Ki,qi=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 Ji(){return new qi}(Ki=globalThis).__zod_globalRegistry??(Ki.__zod_globalRegistry=Ji());let Yi=globalThis.__zod_globalRegistry;// @__NO_SIDE_EFFECTS__
|
|
73
|
+
function Xi(e,t){return new e({type:`string`,...D(t)})}// @__NO_SIDE_EFFECTS__
|
|
74
|
+
function Zi(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...D(t)})}// @__NO_SIDE_EFFECTS__
|
|
75
|
+
function Qi(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...D(t)})}// @__NO_SIDE_EFFECTS__
|
|
76
|
+
function $i(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...D(t)})}// @__NO_SIDE_EFFECTS__
|
|
77
|
+
function ea(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...D(t)})}// @__NO_SIDE_EFFECTS__
|
|
78
|
+
function ta(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...D(t)})}// @__NO_SIDE_EFFECTS__
|
|
79
|
+
function na(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...D(t)})}// @__NO_SIDE_EFFECTS__
|
|
80
|
+
function ra(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...D(t)})}// @__NO_SIDE_EFFECTS__
|
|
81
|
+
function ia(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...D(t)})}// @__NO_SIDE_EFFECTS__
|
|
82
|
+
function aa(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...D(t)})}// @__NO_SIDE_EFFECTS__
|
|
83
|
+
function oa(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...D(t)})}// @__NO_SIDE_EFFECTS__
|
|
84
|
+
function sa(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...D(t)})}// @__NO_SIDE_EFFECTS__
|
|
85
|
+
function ca(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...D(t)})}// @__NO_SIDE_EFFECTS__
|
|
86
|
+
function la(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...D(t)})}// @__NO_SIDE_EFFECTS__
|
|
87
|
+
function ua(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...D(t)})}// @__NO_SIDE_EFFECTS__
|
|
88
|
+
function da(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...D(t)})}// @__NO_SIDE_EFFECTS__
|
|
89
|
+
function fa(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...D(t)})}// @__NO_SIDE_EFFECTS__
|
|
90
|
+
function pa(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...D(t)})}// @__NO_SIDE_EFFECTS__
|
|
91
|
+
function ma(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...D(t)})}// @__NO_SIDE_EFFECTS__
|
|
92
|
+
function ha(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...D(t)})}// @__NO_SIDE_EFFECTS__
|
|
93
|
+
function ga(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...D(t)})}// @__NO_SIDE_EFFECTS__
|
|
94
|
+
function _a(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...D(t)})}// @__NO_SIDE_EFFECTS__
|
|
95
|
+
function va(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...D(t)})}// @__NO_SIDE_EFFECTS__
|
|
96
|
+
function ya(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...D(t)})}// @__NO_SIDE_EFFECTS__
|
|
97
|
+
function ba(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...D(t)})}// @__NO_SIDE_EFFECTS__
|
|
98
|
+
function xa(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...D(t)})}// @__NO_SIDE_EFFECTS__
|
|
99
|
+
function Sa(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...D(t)})}// @__NO_SIDE_EFFECTS__
|
|
100
|
+
function Ca(e,t){return new e({type:`number`,checks:[],...D(t)})}// @__NO_SIDE_EFFECTS__
|
|
101
|
+
function wa(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...D(t)})}// @__NO_SIDE_EFFECTS__
|
|
102
|
+
function Ta(e,t){return new e({type:`boolean`,...D(t)})}// @__NO_SIDE_EFFECTS__
|
|
103
|
+
function Ea(e,t){return new e({type:`null`,...D(t)})}// @__NO_SIDE_EFFECTS__
|
|
104
|
+
function Da(e){return new e({type:`unknown`})}// @__NO_SIDE_EFFECTS__
|
|
105
|
+
function Oa(e,t){return new e({type:`never`,...D(t)})}// @__NO_SIDE_EFFECTS__
|
|
106
|
+
function ka(e,t){return new dr({check:`less_than`,...D(t),value:e,inclusive:!1})}// @__NO_SIDE_EFFECTS__
|
|
107
|
+
function Aa(e,t){return new dr({check:`less_than`,...D(t),value:e,inclusive:!0})}// @__NO_SIDE_EFFECTS__
|
|
108
|
+
function ja(e,t){return new fr({check:`greater_than`,...D(t),value:e,inclusive:!1})}// @__NO_SIDE_EFFECTS__
|
|
109
|
+
function Ma(e,t){return new fr({check:`greater_than`,...D(t),value:e,inclusive:!0})}// @__NO_SIDE_EFFECTS__
|
|
110
|
+
function Na(e,t){return new pr({check:`multiple_of`,...D(t),value:e})}// @__NO_SIDE_EFFECTS__
|
|
111
|
+
function Pa(e,t){return new hr({check:`max_length`,...D(t),maximum:e})}// @__NO_SIDE_EFFECTS__
|
|
112
|
+
function Fa(e,t){return new gr({check:`min_length`,...D(t),minimum:e})}// @__NO_SIDE_EFFECTS__
|
|
113
|
+
function Ia(e,t){return new _r({check:`length_equals`,...D(t),length:e})}// @__NO_SIDE_EFFECTS__
|
|
114
|
+
function La(e,t){return new yr({check:`string_format`,format:`regex`,...D(t),pattern:e})}// @__NO_SIDE_EFFECTS__
|
|
115
|
+
function Ra(e){return new br({check:`string_format`,format:`lowercase`,...D(e)})}// @__NO_SIDE_EFFECTS__
|
|
116
|
+
function za(e){return new xr({check:`string_format`,format:`uppercase`,...D(e)})}// @__NO_SIDE_EFFECTS__
|
|
117
|
+
function Ba(e,t){return new Sr({check:`string_format`,format:`includes`,...D(t),includes:e})}// @__NO_SIDE_EFFECTS__
|
|
118
|
+
function Va(e,t){return new Cr({check:`string_format`,format:`starts_with`,...D(t),prefix:e})}// @__NO_SIDE_EFFECTS__
|
|
119
|
+
function Ha(e,t){return new wr({check:`string_format`,format:`ends_with`,...D(t),suffix:e})}// @__NO_SIDE_EFFECTS__
|
|
120
|
+
function Ua(e){return new Tr({check:`overwrite`,tx:e})}// @__NO_SIDE_EFFECTS__
|
|
121
|
+
function Wa(e){return/* @__PURE__ */ Ua(t=>t.normalize(e))}// @__NO_SIDE_EFFECTS__
|
|
122
|
+
function Ga(){return/* @__PURE__ */ Ua(e=>e.trim())}// @__NO_SIDE_EFFECTS__
|
|
123
|
+
function Ka(){return/* @__PURE__ */ Ua(e=>e.toLowerCase())}// @__NO_SIDE_EFFECTS__
|
|
124
|
+
function qa(){return/* @__PURE__ */ Ua(e=>e.toUpperCase())}// @__NO_SIDE_EFFECTS__
|
|
125
|
+
function Ja(){return/* @__PURE__ */ Ua(e=>Vt(e))}// @__NO_SIDE_EFFECTS__
|
|
126
|
+
function Ya(e,t,n){return new e({type:`array`,element:t,...D(n)})}// @__NO_SIDE_EFFECTS__
|
|
127
|
+
function Xa(e,t,n){let r=D(n);return r.abort??=!0,new e({type:`custom`,check:`custom`,fn:t,...r})}// @__NO_SIDE_EFFECTS__
|
|
128
|
+
function Za(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...D(n)})}// @__NO_SIDE_EFFECTS__
|
|
129
|
+
function Qa(e,t){let n=/* @__PURE__ */ $a(t=>(t.addIssue=e=>{if(typeof e==`string`)t.issues.push(fn(e,t.value,n._zod.def));else{let r=e;r.fatal&&(r.continue=!1),r.code??=`custom`,r.input??=t.value,r.inst??=n,r.continue??=!n._zod.def.abort,t.issues.push(fn(r))}},e(t.value,t)),t);return n}// @__NO_SIDE_EFFECTS__
|
|
130
|
+
function $a(e,t){let n=new lr({check:`custom`,...D(t)});return n._zod.check=e,n}function eo(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??Yi,target:t,unrepresentable:e?.unrepresentable??`throw`,override:e?.override??(()=>{}),io:e?.io??`output`,counter:0,seen:/* @__PURE__ */ new Map,cycles:e?.cycles??`ref`,reused:e?.reused??`inline`,external:e?.external??void 0}}function to(e,t,n={path:[],schemaPath:[]}){var r;let i=e._zod.def,a=t.seen.get(e);if(a)return a.count++,n.schemaPath.includes(e)&&(a.cycle=n.path),a.schema;let o={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,o);let s=e._zod.toJSONSchema?.();if(s)o.schema=s;else{let r={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,r);else{let n=o.schema,a=t.processors[i.type];if(!a)throw Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);a(e,t,n,r)}let a=e._zod.parent;a&&(o.ref||=a,to(a,t,r),t.seen.get(a).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&Object.assign(o.schema,c),t.io===`input`&&io(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 no(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=/* @__PURE__ */ new Map;for(let t of e.seen.entries()){let n=e.metadataRegistry.get(t[0])?.id;if(n){let e=r.get(n);if(e&&e!==t[0])throw Error(`Duplicate schema id "${n}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(n,t[0])}}let i=t=>{let r=e.target===`draft-2020-12`?`$defs`:`definitions`;if(e.external){let n=e.external.registry.get(t[0])?.id,i=e.external.uri??(e=>e);if(n)return{ref:i(n)};let a=t[1].defId??t[1].schema.id??`schema${e.counter++}`;return t[1].defId=a,{defId:a,ref:`${i(`__shared`)}#/${r}/${a}`}}if(t[1]===n)return{ref:`#`};let i=`#/${r}/`,a=t[1].schema.id??`__schema${e.counter++}`;return{defId:a,ref:i+a}},a=e=>{if(e[1].schema.$ref)return;let t=e[1],{ref:n,defId:r}=i(e);t.def={...t.schema},r&&(t.defId=r);let a=t.schema;for(let e in a)delete a[e];a.$ref=n};if(e.cycles===`throw`)for(let t of e.seen.entries()){let e=t[1];if(e.cycle)throw Error(`Cycle detected: #/${e.cycle?.join(`/`)}/<root>
|
|
131
131
|
|
|
132
|
-
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let n of e.seen.entries()){let r=n[1];if(t===n[0])a(n);else{if(e.external){let r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){a(n);continue}}(e.metadataRegistry.get(n[0])?.id||r.cycle||r.count>1&&e.reused===`ref`)&&a(n)}}}function to(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=t=>{let n=e.seen.get(t);if(n.ref===null)return;let i=n.def??n.schema,a={...i},o=n.ref;if(n.ref=null,o){r(o);let n=e.seen.get(o),s=n.schema;if(s.$ref&&(e.target===`draft-07`||e.target===`draft-04`||e.target===`openapi-3.0`)?(i.allOf=i.allOf??[],i.allOf.push(s)):Object.assign(i,s),Object.assign(i,a),t._zod.parent===o)for(let e in i)e!==`$ref`&&e!==`allOf`&&(e in a||delete i[e]);if(s.$ref&&n.def)for(let e in i)e!==`$ref`&&e!==`allOf`&&e in n.def&&JSON.stringify(i[e])===JSON.stringify(n.def[e])&&delete i[e]}let s=t._zod.parent;if(s&&s!==o){r(s);let t=e.seen.get(s);if(t?.schema.$ref&&(i.$ref=t.schema.$ref,t.def))for(let e in i)e!==`$ref`&&e!==`allOf`&&e in t.def&&JSON.stringify(i[e])===JSON.stringify(t.def[e])&&delete i[e]}e.override({zodSchema:t,jsonSchema:i,path:n.path??[]})};for(let t of[...e.seen.entries()].reverse())r(t[0]);let i={};if(e.target===`draft-2020-12`?i.$schema=`https://json-schema.org/draft/2020-12/schema`:e.target===`draft-07`?i.$schema=`http://json-schema.org/draft-07/schema#`:e.target===`draft-04`?i.$schema=`http://json-schema.org/draft-04/schema#`:e.target,e.external?.uri){let n=e.external.registry.get(t)?.id;if(!n)throw Error("Schema is missing an `id` property");i.$id=e.external.uri(n)}Object.assign(i,n.def??n.schema);let a=e.metadataRegistry.get(t)?.id;a!==void 0&&i.id===a&&delete i.id;let o=e.external?.defs??{};for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(e.def.id===e.defId&&delete e.def.id,o[e.defId]=e.def)}e.external||Object.keys(o).length>0&&(e.target===`draft-2020-12`?i.$defs=o:i.definitions=o);try{let n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,"~standard",{value:{...t[`~standard`],jsonSchema:{input:io(t,`input`,e.processors),output:io(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function no(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 no(r.element,n);if(r.type===`set`)return no(r.valueType,n);if(r.type===`lazy`)return no(r.getter(),n);if(r.type===`promise`||r.type===`optional`||r.type===`nonoptional`||r.type===`nullable`||r.type===`readonly`||r.type==="default"||r.type===`prefault`)return no(r.innerType,n);if(r.type===`intersection`)return no(r.left,n)||no(r.right,n);if(r.type===`record`||r.type===`map`)return no(r.keyType,n)||no(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:no(r.in,n)||no(r.out,n);if(r.type===`object`){for(let e in r.shape)if(no(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(no(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(no(e,n))return!0;return!!(r.rest&&no(r.rest,n))}return!1}let ro=(e,t={})=>n=>{let r=Qa({...n,processors:t});return $a(e,r),eo(r,e),to(r,e)},io=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=Qa({...i??{},target:a,io:t,processors:n});return $a(e,o),eo(o,e),to(o,e)},ao={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},oo=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l}=e._zod.bag;if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=ao[s]??s,i.format===``&&delete i.format,s===`time`&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let e=[...c];e.length===1?i.pattern=e[0].source:e.length>1&&(i.allOf=[...e.map(e=>({...t.target===`draft-07`||t.target===`draft-04`||t.target===`openapi-3.0`?{type:`string`}:{},pattern:e.source}))])}},so=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,format:s,multipleOf:c,exclusiveMaximum:l,exclusiveMinimum:u}=e._zod.bag;i.type=typeof s==`string`&&s.includes(`int`)?`integer`:`number`;let d=typeof u==`number`&&u>=(a??-1/0),f=typeof l==`number`&&l<=(o??1/0),p=t.target===`draft-04`||t.target===`openapi-3.0`;d?p?(i.minimum=u,i.exclusiveMinimum=!0):i.exclusiveMinimum=u:typeof a==`number`&&(i.minimum=a),f?p?(i.maximum=l,i.exclusiveMaximum=!0):i.exclusiveMaximum=l:typeof o==`number`&&(i.maximum=o),typeof c==`number`&&(i.multipleOf=c)},co=(e,t,n,r)=>{n.type=`boolean`},lo=(e,t,n,r)=>{t.target===`openapi-3.0`?(n.type=`string`,n.nullable=!0,n.enum=[null]):n.type=`null`},uo=(e,t,n,r)=>{n.not={}},fo=(e,t,n,r)=>{let i=e._zod.def,a=kt(i.entries);a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a},po=(e,t,n,r)=>{let i=e._zod.def,a=[];for(let e of i.values)if(e===void 0){if(t.unrepresentable===`throw`)throw Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof e==`bigint`){if(t.unrepresentable===`throw`)throw Error(`BigInt literals cannot be represented in JSON Schema`);a.push(Number(e))}else a.push(e);if(a.length!==0){if(a.length===1){let e=a[0];n.type=e===null?`null`:typeof e,t.target===`draft-04`||t.target===`openapi-3.0`?n.enum=[e]:n.const=e}else a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),a.every(e=>typeof e==`boolean`)&&(n.type=`boolean`),a.every(e=>e===null)&&(n.type=`null`),n.enum=a}},mo=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Custom types cannot be represented in JSON Schema`)},ho=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Transforms cannot be represented in JSON Schema`)},go=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=e._zod.bag;typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=$a(a.element,t,{...r,path:[...r.path,`items`]})},_o=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`,i.properties={};let o=a.shape;for(let e in o)i.properties[e]=$a(o[e],t,{...r,path:[...r.path,`properties`,e]});let s=new Set(Object.keys(o)),c=new Set([...s].filter(e=>{let n=a.shape[e]._zod;return t.io===`input`?n.optin===void 0:n.optout===void 0}));c.size>0&&(i.required=Array.from(c)),a.catchall?._zod.def.type===`never`?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=$a(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},vo=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>$a(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},yo=(e,t,n,r)=>{let i=e._zod.def,a=$a(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=$a(i.right,t,{...r,path:[...r.path,`allOf`,1]}),s=e=>`allOf`in e&&Object.keys(e).length===1;n.allOf=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]]},bo=(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)=>$a(e,t,{...r,path:[...r.path,o,n]})),l=a.rest?$a(a.rest,t,{...r,path:[...r.path,s,...t.target===`openapi-3.0`?[a.items.length]:[]]}):null;t.target===`draft-2020-12`?(i.prefixItems=c,l&&(i.items=l)):t.target===`openapi-3.0`?(i.items={anyOf:c},l&&i.items.anyOf.push(l),i.minItems=c.length,l||(i.maxItems=c.length)):(i.items=c,l&&(i.additionalItems=l));let{minimum:u,maximum:d}=e._zod.bag;typeof u==`number`&&(i.minItems=u),typeof d==`number`&&(i.maxItems=d)},xo=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`;let o=a.keyType,s=o._zod.bag?.patterns;if(a.mode===`loose`&&s&&s.size>0){let e=$a(a.valueType,t,{...r,path:[...r.path,`patternProperties`,`*`]});i.patternProperties={};for(let t of s)i.patternProperties[t.source]=e}else(t.target===`draft-07`||t.target===`draft-2020-12`)&&(i.propertyNames=$a(a.keyType,t,{...r,path:[...r.path,`propertyNames`]})),i.additionalProperties=$a(a.valueType,t,{...r,path:[...r.path,`additionalProperties`]});let c=o._zod.values;if(c){let e=[...c].filter(e=>typeof e==`string`||typeof e==`number`);e.length>0&&(i.required=e)}},So=(e,t,n,r)=>{let i=e._zod.def,a=$a(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`}]},Co=(e,t,n,r)=>{let i=e._zod.def;$a(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},wo=(e,t,n,r)=>{let i=e._zod.def;$a(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.default=JSON.parse(JSON.stringify(i.defaultValue))},To=(e,t,n,r)=>{let i=e._zod.def;$a(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,t.io===`input`&&(n._prefault=JSON.parse(JSON.stringify(i.defaultValue)))},Eo=(e,t,n,r)=>{let i=e._zod.def;$a(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{throw Error(`Dynamic catch values are not supported in JSON Schema`)}n.default=o},Do=(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;$a(o,t,r);let s=t.seen.get(e);s.ref=o},Oo=(e,t,n,r)=>{let i=e._zod.def;$a(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},ko=(e,t,n,r)=>{let i=e._zod.def;$a(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Ao=(e,t,n,r)=>{let i=e._zod.innerType;$a(i,t,r);let a=t.seen.get(e);a.ref=i},jo=/*@__PURE__*/ T(`ZodISODateTime`,(e,t)=>{zr.init(e,t),rs.init(e,t)});function Mo(e){return/* @__PURE__ */ _a(jo,e)}let No=/*@__PURE__*/ T(`ZodISODate`,(e,t)=>{Br.init(e,t),rs.init(e,t)});function Po(e){return/* @__PURE__ */ va(No,e)}let Fo=/*@__PURE__*/ T(`ZodISOTime`,(e,t)=>{Vr.init(e,t),rs.init(e,t)});function Io(e){return/* @__PURE__ */ ya(Fo,e)}let Lo=/*@__PURE__*/ T(`ZodISODuration`,(e,t)=>{Hr.init(e,t),rs.init(e,t)});function Ro(e){return/* @__PURE__ */ ba(Lo,e)}let zo=/*@__PURE__*/ T(`ZodError`,(e,t)=>{fn.init(e,t),e.name=`ZodError`,Object.defineProperties(e,{format:{value:t=>hn(e,t)},flatten:{value:t=>mn(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,At,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,At,2)}},isEmpty:{get(){return e.issues.length===0}}})},{Parent:Error}),Bo=/* @__PURE__ */ gn(zo),Vo=/* @__PURE__ */ _n(zo),Ho=/* @__PURE__ */ vn(zo),Uo=/* @__PURE__ */ bn(zo),Wo=/* @__PURE__ */ Sn(zo),Go=/* @__PURE__ */ Cn(zo),Ko=/* @__PURE__ */ wn(zo),qo=/* @__PURE__ */ Tn(zo),Jo=/* @__PURE__ */ En(zo),Yo=/* @__PURE__ */ Dn(zo),Xo=/* @__PURE__ */ On(zo),Zo=/* @__PURE__ */ kn(zo),Qo=/* @__PURE__ */ new WeakMap;function $o(e,t,n){let r=Object.getPrototypeOf(e),i=Qo.get(r);if(i||(i=/* @__PURE__ */ new Set,Qo.set(r,i)),!i.has(t)){i.add(t);for(let e in n){let t=n[e];Object.defineProperty(r,e,{configurable:!0,enumerable:!1,get(){let n=t.bind(this);return Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:n}),n},set(t){Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:t})}})}}}let es=/*@__PURE__*/ T(`ZodType`,(e,t)=>(O.init(e,t),Object.assign(e[`~standard`],{jsonSchema:{input:io(e,`input`),output:io(e,`output`)}}),e.toJSONSchema=ro(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(t,n)=>Bo(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>Ho(e,t,n),e.parseAsync=async(t,n)=>Vo(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>Uo(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>Wo(e,t,n),e.decode=(t,n)=>Go(e,t,n),e.encodeAsync=async(t,n)=>Ko(e,t,n),e.decodeAsync=async(t,n)=>qo(e,t,n),e.safeEncode=(t,n)=>Jo(e,t,n),e.safeDecode=(t,n)=>Yo(e,t,n),e.safeEncodeAsync=async(t,n)=>Xo(e,t,n),e.safeDecodeAsync=async(t,n)=>Zo(e,t,n),$o(e,`ZodType`,{check(...e){let t=this.def;return this.clone(Lt(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 qt(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(vc(e,t))},superRefine(e,t){return this.check(yc(e,t))},overwrite(e){return this.check(/* @__PURE__ */ Va(e))},optional(){return Zs(this)},exactOptional(){return $s(this)},nullable(){return tc(this)},nullish(){return Zs(tc(this))},nonoptional(e){return sc(this,e)},array(){return M(this)},or(e){return Ls([this,e])},and(e){return Vs(this,e)},transform(e){return dc(this,Ys(e))},default(e){return rc(this,e)},prefault(e){return ac(this,e)},catch(e){return lc(this,e)},pipe(e){return dc(this,e)},readonly(){return pc(this)},describe(e){let t=this.clone();return qi.add(t,{description:e}),t},meta(...e){if(e.length===0)return qi.get(this);let t=this.clone();return qi.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e){return e(this)}}),Object.defineProperty(e,"description",{get(){return qi.get(e)?.description},configurable:!0}),e)),ts=/*@__PURE__*/ T(`_ZodString`,(e,t)=>{Er.init(e,t),es.init(e,t),e._zod.processJSONSchema=(t,n,r)=>oo(e,t,n,r);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,$o(e,`_ZodString`,{regex(...e){return this.check(/* @__PURE__ */ Fa(...e))},includes(...e){return this.check(/* @__PURE__ */ Ra(...e))},startsWith(...e){return this.check(/* @__PURE__ */ za(...e))},endsWith(...e){return this.check(/* @__PURE__ */ Ba(...e))},min(...e){return this.check(/* @__PURE__ */ Na(...e))},max(...e){return this.check(/* @__PURE__ */ Ma(...e))},length(...e){return this.check(/* @__PURE__ */ Pa(...e))},nonempty(...e){return this.check(/* @__PURE__ */ Na(1,...e))},lowercase(e){return this.check(/* @__PURE__ */ Ia(e))},uppercase(e){return this.check(/* @__PURE__ */ La(e))},trim(){return this.check(/* @__PURE__ */ Ua())},normalize(...e){return this.check(/* @__PURE__ */ Ha(...e))},toLowerCase(){return this.check(/* @__PURE__ */ Wa())},toUpperCase(){return this.check(/* @__PURE__ */ Ga())},slugify(){return this.check(/* @__PURE__ */ Ka())}})}),ns=/*@__PURE__*/ T(`ZodString`,(e,t)=>{Er.init(e,t),ts.init(e,t),e.email=t=>e.check(/* @__PURE__ */ Yi(is,t)),e.url=t=>e.check(/* @__PURE__ */ ta(ss,t)),e.jwt=t=>e.check(/* @__PURE__ */ ga(Cs,t)),e.emoji=t=>e.check(/* @__PURE__ */ na(ls,t)),e.guid=t=>e.check(/* @__PURE__ */ Xi(as,t)),e.uuid=t=>e.check(/* @__PURE__ */ Zi(os,t)),e.uuidv4=t=>e.check(/* @__PURE__ */ Qi(os,t)),e.uuidv6=t=>e.check(/* @__PURE__ */ $i(os,t)),e.uuidv7=t=>e.check(/* @__PURE__ */ ea(os,t)),e.nanoid=t=>e.check(/* @__PURE__ */ ra(us,t)),e.guid=t=>e.check(/* @__PURE__ */ Xi(as,t)),e.cuid=t=>e.check(/* @__PURE__ */ ia(ds,t)),e.cuid2=t=>e.check(/* @__PURE__ */ aa(fs,t)),e.ulid=t=>e.check(/* @__PURE__ */ oa(ps,t)),e.base64=t=>e.check(/* @__PURE__ */ pa(bs,t)),e.base64url=t=>e.check(/* @__PURE__ */ ma(xs,t)),e.xid=t=>e.check(/* @__PURE__ */ sa(ms,t)),e.ksuid=t=>e.check(/* @__PURE__ */ ca(hs,t)),e.ipv4=t=>e.check(/* @__PURE__ */ la(gs,t)),e.ipv6=t=>e.check(/* @__PURE__ */ ua(_s,t)),e.cidrv4=t=>e.check(/* @__PURE__ */ da(vs,t)),e.cidrv6=t=>e.check(/* @__PURE__ */ fa(ys,t)),e.e164=t=>e.check(/* @__PURE__ */ ha(Ss,t)),e.datetime=t=>e.check(Mo(t)),e.date=t=>e.check(Po(t)),e.time=t=>e.check(Io(t)),e.duration=t=>e.check(Ro(t))});function k(e){return/* @__PURE__ */ Ji(ns,e)}let rs=/*@__PURE__*/ T(`ZodStringFormat`,(e,t)=>{Dr.init(e,t),ts.init(e,t)}),is=/*@__PURE__*/ T(`ZodEmail`,(e,t)=>{Ar.init(e,t),rs.init(e,t)}),as=/*@__PURE__*/ T(`ZodGUID`,(e,t)=>{Or.init(e,t),rs.init(e,t)}),os=/*@__PURE__*/ T(`ZodUUID`,(e,t)=>{kr.init(e,t),rs.init(e,t)}),ss=/*@__PURE__*/ T(`ZodURL`,(e,t)=>{jr.init(e,t),rs.init(e,t)});function cs(e){return/* @__PURE__ */ ta(ss,e)}let ls=/*@__PURE__*/ T(`ZodEmoji`,(e,t)=>{Mr.init(e,t),rs.init(e,t)}),us=/*@__PURE__*/ T(`ZodNanoID`,(e,t)=>{Nr.init(e,t),rs.init(e,t)}),ds=/*@__PURE__*/ T(`ZodCUID`,(e,t)=>{Pr.init(e,t),rs.init(e,t)}),fs=/*@__PURE__*/ T(`ZodCUID2`,(e,t)=>{Fr.init(e,t),rs.init(e,t)}),ps=/*@__PURE__*/ T(`ZodULID`,(e,t)=>{Ir.init(e,t),rs.init(e,t)}),ms=/*@__PURE__*/ T(`ZodXID`,(e,t)=>{Lr.init(e,t),rs.init(e,t)}),hs=/*@__PURE__*/ T(`ZodKSUID`,(e,t)=>{Rr.init(e,t),rs.init(e,t)}),gs=/*@__PURE__*/ T(`ZodIPv4`,(e,t)=>{Ur.init(e,t),rs.init(e,t)}),_s=/*@__PURE__*/ T(`ZodIPv6`,(e,t)=>{Wr.init(e,t),rs.init(e,t)}),vs=/*@__PURE__*/ T(`ZodCIDRv4`,(e,t)=>{Gr.init(e,t),rs.init(e,t)}),ys=/*@__PURE__*/ T(`ZodCIDRv6`,(e,t)=>{Kr.init(e,t),rs.init(e,t)}),bs=/*@__PURE__*/ T(`ZodBase64`,(e,t)=>{Jr.init(e,t),rs.init(e,t)}),xs=/*@__PURE__*/ T(`ZodBase64URL`,(e,t)=>{Xr.init(e,t),rs.init(e,t)}),Ss=/*@__PURE__*/ T(`ZodE164`,(e,t)=>{Zr.init(e,t),rs.init(e,t)}),Cs=/*@__PURE__*/ T(`ZodJWT`,(e,t)=>{$r.init(e,t),rs.init(e,t)}),ws=/*@__PURE__*/ T(`ZodNumber`,(e,t)=>{ei.init(e,t),es.init(e,t),e._zod.processJSONSchema=(t,n,r)=>so(e,t,n,r),$o(e,`ZodNumber`,{gt(e,t){return this.check(/* @__PURE__ */ ka(e,t))},gte(e,t){return this.check(/* @__PURE__ */ Aa(e,t))},min(e,t){return this.check(/* @__PURE__ */ Aa(e,t))},lt(e,t){return this.check(/* @__PURE__ */ Da(e,t))},lte(e,t){return this.check(/* @__PURE__ */ Oa(e,t))},max(e,t){return this.check(/* @__PURE__ */ Oa(e,t))},int(e){return this.check(Es(e))},safe(e){return this.check(Es(e))},positive(e){return this.check(/* @__PURE__ */ ka(0,e))},nonnegative(e){return this.check(/* @__PURE__ */ Aa(0,e))},negative(e){return this.check(/* @__PURE__ */ Da(0,e))},nonpositive(e){return this.check(/* @__PURE__ */ Oa(0,e))},multipleOf(e,t){return this.check(/* @__PURE__ */ ja(e,t))},step(e,t){return this.check(/* @__PURE__ */ ja(e,t))},finite(){return this}});let n=e._zod.bag;e.minValue=Math.max(n.minimum??-1/0,n.exclusiveMinimum??-1/0)??null,e.maxValue=Math.min(n.maximum??1/0,n.exclusiveMaximum??1/0)??null,e.isInt=(n.format??``).includes(`int`)||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function A(e){return/* @__PURE__ */ xa(ws,e)}let Ts=/*@__PURE__*/ T(`ZodNumberFormat`,(e,t)=>{ti.init(e,t),ws.init(e,t)});function Es(e){return/* @__PURE__ */ Sa(Ts,e)}let Ds=/*@__PURE__*/ T(`ZodBoolean`,(e,t)=>{ni.init(e,t),es.init(e,t),e._zod.processJSONSchema=(t,n,r)=>co(e,t,n,r)});function j(e){return/* @__PURE__ */ Ca(Ds,e)}let Os=/*@__PURE__*/ T(`ZodNull`,(e,t)=>{ri.init(e,t),es.init(e,t),e._zod.processJSONSchema=(t,n,r)=>lo(e,t,n,r)});function ks(e){return/* @__PURE__ */ wa(Os,e)}let As=/*@__PURE__*/ T(`ZodUnknown`,(e,t)=>{ii.init(e,t),es.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function js(){return/* @__PURE__ */ Ta(As)}let Ms=/*@__PURE__*/ T(`ZodNever`,(e,t)=>{ai.init(e,t),es.init(e,t),e._zod.processJSONSchema=(t,n,r)=>uo(e,t,n,r)});function Ns(e){return/* @__PURE__ */ Ea(Ms,e)}let Ps=/*@__PURE__*/ T(`ZodArray`,(e,t)=>{si.init(e,t),es.init(e,t),e._zod.processJSONSchema=(t,n,r)=>go(e,t,n,r),e.element=t.element,$o(e,`ZodArray`,{min(e,t){return this.check(/* @__PURE__ */ Na(e,t))},nonempty(e){return this.check(/* @__PURE__ */ Na(1,e))},max(e,t){return this.check(/* @__PURE__ */ Ma(e,t))},length(e,t){return this.check(/* @__PURE__ */ Pa(e,t))},unwrap(){return this.element}})});function M(e,t){return/* @__PURE__ */ qa(Ps,e,t)}let Fs=/*@__PURE__*/ T(`ZodObject`,(e,t)=>{fi.init(e,t),es.init(e,t),e._zod.processJSONSchema=(t,n,r)=>_o(e,t,n,r),E(e,`shape`,()=>t.shape),$o(e,`ZodObject`,{keyof(){return F(Object.keys(this._zod.def.shape))},catchall(e){return this.clone({...this._zod.def,catchall:e})},passthrough(){return this.clone({...this._zod.def,catchall:js()})},loose(){return this.clone({...this._zod.def,catchall:js()})},strict(){return this.clone({...this._zod.def,catchall:Ns()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(e){return Qt(this,e)},safeExtend(e){return $t(this,e)},merge(e){return en(this,e)},pick(e){return Xt(this,e)},omit(e){return Zt(this,e)},partial(...e){return tn(Xs,this,e[0])},required(...e){return nn(oc,this,e[0])}})});function N(e,t){let n={type:`object`,shape:e??{},...D(t)};return new Fs(n)}function P(e,t){return new Fs({type:`object`,shape:e,catchall:Ns(),...D(t)})}let Is=/*@__PURE__*/ T(`ZodUnion`,(e,t)=>{mi.init(e,t),es.init(e,t),e._zod.processJSONSchema=(t,n,r)=>vo(e,t,n,r),e.options=t.options});function Ls(e,t){return new Is({type:`union`,options:e,...D(t)})}let Rs=/*@__PURE__*/ T(`ZodDiscriminatedUnion`,(e,t)=>{Is.init(e,t),hi.init(e,t)});function zs(e,t,n){return new Rs({type:`union`,options:t,discriminator:e,...D(n)})}let Bs=/*@__PURE__*/ T(`ZodIntersection`,(e,t)=>{gi.init(e,t),es.init(e,t),e._zod.processJSONSchema=(t,n,r)=>yo(e,t,n,r)});function Vs(e,t){return new Bs({type:`intersection`,left:e,right:t})}let Hs=/*@__PURE__*/ T(`ZodTuple`,(e,t)=>{yi.init(e,t),es.init(e,t),e._zod.processJSONSchema=(t,n,r)=>bo(e,t,n,r),e.rest=t=>e.clone({...e._zod.def,rest:t})});function Us(e,t,n){let r=t instanceof O;return new Hs({type:`tuple`,items:e,rest:r?t:null,...D(r?n:t)})}let Ws=/*@__PURE__*/ T(`ZodRecord`,(e,t)=>{Ci.init(e,t),es.init(e,t),e._zod.processJSONSchema=(t,n,r)=>xo(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType});function Gs(e,t,n){return!t||!t._zod?new Ws({type:`record`,keyType:k(),valueType:e,...D(t)}):new Ws({type:`record`,keyType:e,valueType:t,...D(n)})}let Ks=/*@__PURE__*/ T(`ZodEnum`,(e,t)=>{wi.init(e,t),es.init(e,t),e._zod.processJSONSchema=(t,n,r)=>fo(e,t,n,r),e.enum=t.entries,e.options=Object.values(t.entries);let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new Ks({...t,checks:[],...D(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 Ks({...t,checks:[],...D(r),entries:i})}});function F(e,t){let n=Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e;return new Ks({type:`enum`,entries:n,...D(t)})}let qs=/*@__PURE__*/ T(`ZodLiteral`,(e,t)=>{Ti.init(e,t),es.init(e,t),e._zod.processJSONSchema=(t,n,r)=>po(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 I(e,t){return new qs({type:`literal`,values:Array.isArray(e)?e:[e],...D(t)})}let Js=/*@__PURE__*/ T(`ZodTransform`,(e,t)=>{Ei.init(e,t),es.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ho(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new Et(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(un(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,t.input??=n.value,t.inst??=e,n.issues.push(un(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n.fallback=!0,n)):(n.value=i,n.fallback=!0,n)}});function Ys(e){return new Js({type:`transform`,transform:e})}let Xs=/*@__PURE__*/ T(`ZodOptional`,(e,t)=>{Oi.init(e,t),es.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ko(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Zs(e){return new Xs({type:`optional`,innerType:e})}let Qs=/*@__PURE__*/ T(`ZodExactOptional`,(e,t)=>{ki.init(e,t),es.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ko(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function $s(e){return new Qs({type:`optional`,innerType:e})}let ec=/*@__PURE__*/ T(`ZodNullable`,(e,t)=>{Ai.init(e,t),es.init(e,t),e._zod.processJSONSchema=(t,n,r)=>So(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function tc(e){return new ec({type:`nullable`,innerType:e})}let nc=/*@__PURE__*/ T(`ZodDefault`,(e,t)=>{ji.init(e,t),es.init(e,t),e._zod.processJSONSchema=(t,n,r)=>wo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function rc(e,t){return new nc({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():Wt(t)}})}let ic=/*@__PURE__*/ T(`ZodPrefault`,(e,t)=>{Ni.init(e,t),es.init(e,t),e._zod.processJSONSchema=(t,n,r)=>To(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function ac(e,t){return new ic({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():Wt(t)}})}let oc=/*@__PURE__*/ T(`ZodNonOptional`,(e,t)=>{Pi.init(e,t),es.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Co(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function sc(e,t){return new oc({type:`nonoptional`,innerType:e,...D(t)})}let cc=/*@__PURE__*/ T(`ZodCatch`,(e,t)=>{Ii.init(e,t),es.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Eo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function lc(e,t){return new cc({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:()=>t})}let uc=/*@__PURE__*/ T(`ZodPipe`,(e,t)=>{Li.init(e,t),es.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Do(e,t,n,r),e.in=t.in,e.out=t.out});function dc(e,t){return new uc({type:`pipe`,in:e,out:t})}let fc=/*@__PURE__*/ T(`ZodReadonly`,(e,t)=>{zi.init(e,t),es.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Oo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function pc(e){return new fc({type:`readonly`,innerType:e})}let mc=/*@__PURE__*/ T(`ZodLazy`,(e,t)=>{Vi.init(e,t),es.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ao(e,t,n,r),e.unwrap=()=>e._zod.def.getter()});function hc(e){return new mc({type:`lazy`,getter:e})}let gc=/*@__PURE__*/ T(`ZodCustom`,(e,t)=>{Hi.init(e,t),es.init(e,t),e._zod.processJSONSchema=(t,n,r)=>mo(e,t,n,r)});function _c(e,t){return/* @__PURE__ */ Ja(gc,e??(()=>!0),t)}function vc(e,t={}){return/* @__PURE__ */ Ya(gc,e,t)}function yc(e,t){return/* @__PURE__ */ Xa(e,t)}let bc=N({source:k(),ref:k(),offset:A().int().nonnegative(),length:A().int().positive(),label:k(),appearance:F([`session`,`file`,`folder`,`skill`]).optional(),clipboardText:k(),invalid:j().optional()}),xc=N({text:k(),references:M(bc)}).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 Sc(e){return typeof e==`string`?{text:e,references:[]}:{text:e.text,references:e.references.map(Tc)}}function Cc(e){if(typeof e==`string`)return Sc(e);let t=xc.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 wc(e,t){return{text:e,references:t.map(Tc)}}function Tc(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 Ec=`dsh.conversation`;function Dc(){return(0,f.defineStore)({init:()=>({draft:``,view:null,viewRequest:null}),persist:Ec,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 Oc(e){let t={text:``,references:[]};if(typeof localStorage>`u`)return t;try{let n=localStorage.getItem(`${Ec}.${e}`);if(n===null)return t;let r=JSON.parse(n);return typeof r!=`object`||!r||!(`draft`in r)?t:Cc(r.draft)??t}catch{return t}}function kc(e){if(typeof localStorage>`u`)return null;try{let t=localStorage.getItem(`${Ec}.${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 Ac(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 jc(e){let t=e.replace(/[/\\]+$/,``),n=Math.max(t.lastIndexOf(`/`),t.lastIndexOf(`\\`));return t.slice(n+1)}function Mc(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 Nc=`conversation`,Pc=`描述你的任务以生成计划`,Fc=`describe your task to generate plan`,Ic={"shortcut.newline":`换行`,"shortcut.complementary":`使用互补的 Queue/Steer 方式`,"shortcut.slash":`打开命令菜单`,"shortcut.mention":`打开引用菜单`,"hint.plan":Pc,"hint.goal":`输入目标,智能体将持续执行`,"hint.goal.active":`当前目标进行中。可输入 edit 修改 / pause 暂停 / resume 继续 / clear 清除`,"placeholder.plan":Pc,"placeholder.default":`发消息或创建任务, / 调用指令, @ 文件或对话`,"placeholder.unavailable":`会话不可用`,"placeholder.parentOffline":`父会话已离线,无法继续发送;仍可停止当前运行`,"placeholder.hero":`描述你想要构建的内容, / 调用指令, @ 文件或对话`,"placeholder.workspace":`选择一个工作区开始`,"placeholder.preparing":`正在准备对话…`,"placeholder.steerQueue":`Cmd/Ctrl+Enter 插话发送全部排队消息`,"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.chipLabel":`{index}.`,"annotation.title":`批注 {index}:{excerpt}`,"annotation.selectedText":`选中文字:`,"annotation.userComment":`你的批注:`,"annotation.remove":`移除批注 {index}`,"annotation.label":`批注 {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 后重试。`,"queue.editFailed":`编辑失败:这条消息可能已经开始发送。`,"queue.removeFailed":`删除失败:这条消息可能已经开始发送。`,"queue.steerFailed":`插话发送失败,请重试。`,"queue.resumeFailed":`继续队列失败,请重试。`,"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}`},Lc={"shortcut.newline":`New line`,"shortcut.complementary":`Use the complementary Queue / Steer action`,"shortcut.slash":`Open command menu`,"shortcut.mention":`Open reference menu`,"hint.plan":Fc,"hint.goal":`describe the objective for a long-running task`,"hint.goal.active":`goal active — edit / pause / resume / clear`,"placeholder.plan":Fc,"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`,"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.chipLabel":`{index}.`,"annotation.title":`Annotation {index}: {excerpt}`,"annotation.selectedText":`Selected text:`,"annotation.userComment":`Your comment:`,"annotation.remove":`Remove annotation {index}`,"annotation.label":`Annotation {index}`,"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 non-text content; editing is not supported 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.`,"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.`,"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}`},Rc=2048;async function zc(e){if(e.type!==`image/jpeg`&&e.type!==`image/webp`)return e;let t;try{t=await createImageBitmap(e,{imageOrientation:`from-image`});let n=Math.max(t.width,t.height);if(n<=Rc&&e.size<=1048576)return e;let r=Math.min(1,Rc/n),i=Math.max(1,Math.round(t.width*r)),a=Math.max(1,Math.round(t.height*r)),o;if(typeof OffscreenCanvas==`function`&&typeof OffscreenCanvas.prototype.convertToBlob==`function`){let n=new OffscreenCanvas(i,a),r=n.getContext(`2d`);if(r===null)return e;r.drawImage(t,0,0,i,a),o=await n.convertToBlob({type:`image/jpeg`,quality:.85})}else{let n=document.createElement(`canvas`);n.width=i,n.height=a;let r=n.getContext(`2d`);if(r===null)return e;r.drawImage(t,0,0,i,a),o=await new Promise(e=>n.toBlob(e,`image/jpeg`,.85))}if(o===null||o.type!==`image/jpeg`||o.size===0||o.size>=e.size)return e;let s=e.name===``?``:`${e.name.replace(/\.[^.]*$/u,``)}.jpg`;return new File([o],s,{type:`image/jpeg`,lastModified:e.lastModified})}catch{return e}finally{t?.close()}}function Bc(e){return{kind:`image`,id:gt(),previewUrl:URL.createObjectURL(e),file:e}}function Vc(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 Hc(){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 Uc=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`&&Gc(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:e.file.name,bytes:e.file.size}}})),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,onRetire:t=>{this.settleSubmittedAttachments(e.sessionId,a,t),c?.(t)}}),d;try{await Hc(),d=[...await s(),...t===``?[]:[{type:`text`,text:t}]]}catch(e){throw u.abandon(),e}return!(await e.prompt(d,r,i,u.requestId)).ok||l!==void 0&&(await l).reason!==`observed`?{kind:`error`}:{kind:`success`}}finally{a?.release()}}createDrafts(e,t){return t.map(t=>{if(Wc(t.type)){let n=Bc(t);return this.draftAttachments.set(n.id,n),Vc(n),this.beginFileUpload(e,n),n}let n={kind:`file`,id:gt(),file:t};return this.draftAttachments.set(n.id,n),this.beginFileUpload(e,n),n})}retryFileUpload(e,t){let n=this.draftAttachments.get(t);n!==void 0&&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&&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`&&(r.type===`image/jpeg`||r.type===`image/webp`)){let e=this.preparedPhotos.get(t);if(e===void 0&&(e=zc(r),this.preparedPhotos.set(t,e)),r=await e,n.signal.aborted||this.fileUploadOperations.get(t.id)?.controller!==n)return;this.fileUploads.update(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;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.fileUploadOperations.get(e);this.fileUploadOperations.delete(e),n?.controller.abort(),this.draftAttachments.delete(e),this.uploadSessions.delete(e),this.foregroundRetried.delete(e),t.kind===`image`&&Gc(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}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++];t!==void 0&&(a.kind===`file`?this.releaseDraftAttachment(a.id):(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&&r?.seedImageUrl(e,o,a.previewUrl)===!0)&&Gc(a.previewUrl)))}}assertUploadsNotFailed(e){if(e.some(e=>this.fileUploads.getSnapshot()[e]?.status===`error`))throw Error(this.ctx.locale.bind(Nc)(`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(Nc)(`file.retryOrRemove`)))):e.every(e=>r[e]?.status===`ready`)&&(i(),t())},i=this.fileUploads.subscribe(r);r()})}};function Wc(e){return e===`image/png`||e===`image/jpeg`||e===`image/webp`||e===`image/gif`}function Gc(e){e.startsWith(`blob:`)&&URL.revokeObjectURL(e)}var Kc=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 L(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 qc(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 Jc=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0,Yc=Jc&&`documentMode`in document?document.documentMode:null,Xc=Jc&&/Mac|iPod|iPhone|iPad/.test(navigator.platform),Zc=Jc&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent),Qc=!(!Jc||!(`InputEvent`in window)||Yc)&&`getTargetRanges`in new window.InputEvent(`input`),$c=Jc&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,el=Jc&&/Android/.test(navigator.userAgent),tl=Jc&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent)&&!el,nl=Jc&&/^(?=.*Chrome).*/i.test(navigator.userAgent),rl=Jc&&el&&nl,il=Jc&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&Xc&&!nl,al=tl||$c||il?`\xA0`:``,ol=Zc?`\xA0`:al,sl=`֑-߿יִ-﷽ﹰ-ﻼ`,cl=`A-Za-zÀ-ÖØ-öø-ʸ̀-ࠀ-Ⰰ-︀--`;RegExp(`^[^`+cl+`]*[`+sl+`]`),RegExp(`^[^`+sl+`]*[`+cl+`]`);let ll={bold:1,capitalize:1024,code:16,highlight:128,italic:2,lowercase:256,strikethrough:4,subscript:32,superscript:64,underline:8,uppercase:512},ul={directionless:1,unmergeable:2},dl={center:2,end:6,justify:4,left:1,right:3,start:5},fl={2:`center`,6:`end`,4:`justify`,1:`left`,3:`right`,5:`start`},pl={normal:0,segmented:2,token:1},ml={0:`normal`,2:`segmented`,1:`token`},hl=`$config`;function gl(){return Pg()._blockCursorElement}function _l(e){return e!==null&&e.nodeType===1&&e.hasAttribute(`data-lexical-slot`)}var vl=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&&L(357),this.element.insertBefore(e,t),this}removeChild(e){return e.parentElement!==this.element&&L(358),this.element.removeChild(e),this}replaceChild(e,t){return t.parentElement!==this.element&&L(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=yl(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=yl(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 yl(e,t){let n=t;for(;n!==null&&n.parentNode!==e;)n=n.parentNode;return n}var bl=class e extends vl{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(;_l(t);)e=t,t=t.nextSibling;let n=e?e.nextSibling:this.element.firstChild;return n!==null&&n===gl()?n:e}getManagedLineBreak(){return this.element.__lexicalLineBreak||null}setManagedLineBreak(e){if(this.element.__lexicalLastChildKind=e,e===null)this.removeManagedLineBreak();else{let t=e===`decorator`&&(il||$c||tl);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=_g().createElement(`br`);if(i.setAttribute(`data-lexical-managed-linebreak`,`true`),n.insertBefore(i,r),e){let e=_g().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=gl(),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=xl(t,n);i.push(r);let a=xl(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 xl(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&&L(225),n.reverse()}let Sl;try{Sl=`0.49.0+prod.esm`}catch{}let Cl=Sl??`"<unknown>+source"`;var wl=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 Tl(e,t=1e3){return e instanceof El?e.clone():e.size<t?new Map(e):new El().init(new Map(e),void 0,e.size)}var El=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 Dl(e,t,n,r,i,a){if(G(e)){let o=e.getFirstChild();for(;o!==null;){let e=o.__key;o.__parent===t&&((G(o)||s_(o)&&o.__slots!==null)&&Dl(o,e,n,r,i,a),n.has(e)||a.delete(e),i.push(e)),o=o.getNextSibling()}}for(let o of s_(e)&&e.__slots!==null?e.__slots.values():[]){let e=r.get(o);e!==void 0&&c_(e)&&e.__slotHost===t&&((G(e)||s_(e)&&e.__slots!==null)&&Dl(e,o,n,r,i,a),n.has(o)||a.delete(o),i.push(o))}}let Ol=!1,kl=0;function Al(e){kl=e.timeStamp}function jl(e,t,n){let r=e.nodeName===`BR`,i=t.__lexicalLineBreak;return i&&(e===i||r&&e.previousSibling===i)||r&&bh(e,n)!==void 0}function Ml(e,t,n){let r=ug($h(n)),i=r&&bg(r,n._rootElement),a=null,o=null;i!==null&&i.anchorNode===e&&(a=i.anchorOffset,o=i.focusOffset);let s=e.nodeValue;s!==null&&Nh(t,s,a,o,!1)}function Nl(e,t,n){if(H(e)){let t=e.anchor.getNode();if(t.is(n)&&e.format!==t.getFormat())return!1}return ch(t)&&n.isAttached()}function Pl(e,t,n){for(let r=e;r&&!Jg(r);r=qh(r)){let e=bh(r,t);if(e!==void 0){let t=_h(e,n);if(t)return K(t)||!Y(r)?void 0:[r,t]}}}function Fl(e,t,n){Ol=!0;let r=performance.now()-kl>100;try{gm(e,()=>{let i=U()||function(e){return e.read(`latest`,()=>{let e=U();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=Pl(f,e,o);if(!p)continue;let[m,h]=p;if(d===`characterData`)r&&V(h)&&ch(f)&&Nl(i,f,h)&&Ml(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=vh(r),a=r.parentNode;if(!(a==null||r===s||i!==null||jl(r,a,e)||e._slotsUsed&&Y(r)&&r.hasAttribute(`data-lexical-slot`)||Jg(r))){if(Zc){let e=(Y(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];(jl(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`||jl(n,i,e)||a.removeChild(n)}}n.takeRecords()}i!==null&&(c&&Th(i),Zc&&Gh(e)&&i.insertRawText(l))})}finally{Ol=!1}}function Il(e){let t=e._observer;t!==null&&Fl(e,t.takeRecords(),t)}function Ll(e){(function(e){kl===0&&$h(e).addEventListener(`textInput`,Al,!0)})(e),e._observer=new MutationObserver((t,n)=>{Fl(e,t,n)})}var Rl=class{key;parse;unparse;isEqual;defaultValue;resetOnCopyNode;constructor(e,t){this.key=e,this.parse=t.parse.bind(t),this.unparse=(t.unparse||Kl).bind(t),this.isEqual=(t.isEqual||Object.is).bind(t),this.defaultValue=this.parse(void 0),this.resetOnCopyNode=t.resetOnCopyNode||!1}};function zl(e,t){return new Rl(e,t)}function Bl(e){let t=/* @__PURE__ */ new Map,n=/* @__PURE__ */ new Set;for(let{ownNodeConfig:r}of t_(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 Vl=/* @__PURE__ */ new Set([`__proto__`,`constructor`,`prototype`]);var Hl=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 Gl(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(Vl.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=Gl(i)),this.size++),r.set(e,t)}updateFromUnknown(e,t){if(Vl.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 Ul(e){let t=e.getWritable(),n=t.__state?t.__state.getWritable(t):new Hl(t,Wl(t));return t.__state=n,n}function Wl(e){return e.__state?e.__state.sharedNodeState:Qm(Pg(),e.getType()).sharedNodeState}function Gl(e){if(e)for(let t in e)return e}function Kl(e){return e}function ql(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 Jl(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 Yl(e,t){let n=e.__state;return n&&n.node===e?n.getWritable(t):n}function Xl(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&&ql(n,e,t)||t&&ql(n,t,e)||e&&Jl(n,e,t)||t&&Jl(n,t,e))}(c,l))}function Zl(e,t){let n=e.mergeWithSibling(t),r=W()._normalizedNodes;return r.add(e.__key),r.add(t.__key),n}function Ql(e){let t,n,r=e;if(r.__text!==``||!r.isSimpleText()||r.isUnmergeable()){for(;(t=r.getPreviousSibling())!==null&&V(t)&&t.isSimpleText()&&!t.isUnmergeable();){if(t.__text!==``){if(Xl(t,r)){r=Zl(t,r);break}break}t.remove()}for(;(n=r.getNextSibling())!==null&&V(n)&&n.isSimpleText()&&!n.isUnmergeable();){if(n.__text!==``){if(Xl(r,n)){r=Zl(r,n);break}break}n.remove()}}else r.remove()}function $l(e){return eu(e.anchor),eu(e.focus),e}function eu(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),V(r)){e.set(r.__key,i?r.getTextContentSize():0,`text`,!0);break}if(!G(r))break;e.set(r.__key,i?r.getChildrenSize():0,`element`,!0)}}let tu=Symbol.for(`@lexical/CachedTextSize`);function nu(e,t){return gu.read(()=>{let n=0,r=e;for(let e=0;e<t&&r!==null;e++){let i=hu.get(r);if(i===void 0&&L(345,r),G(i)){let a=_u.get(r);if(a!==void 0&&G(a)&&a.__parent!==i.__parent)n+=i.getTextContentSize();else{let e=vu.get(r),t=e&&e.__lexicalTextContent;typeof t!=`string`&&L(346,i.getType()),n+=t.length}e<t-1&&!i.isInline()&&(n+=2)}else{let e=i[tu];e===void 0&&L(347,i.getType(),r),n+=e}r=i.__next}return n},{editor:R})}function ru(e){G(e)||e[tu]===void 0&&(e[tu]=V(e)?e.__text.length:e.getTextContentSize())}let iu,R,au,z=``,ou=null,su=null,cu=null;function lu(){return{firstTextKey:cu,format:ou,style:su}}function uu(e){e.firstTextKey!==null&&(ou=e.format,su=e.style,cu=e.firstTextKey)}function du(e){if(cu!==null)return;let t=e.__lexicalFirstTextKey;if(t===void 0&&L(348),t===null)return;let n=_u.get(t);V(n)&&(ou=n.getFormat(),su=n.getStyle(),cu=t)}let fu,pu,mu,hu,gu,_u,vu,yu,bu,xu,Su=!1,Cu=!1;function wu(e,t){let n=hu.get(e),r=_u.has(e);if(t!==null){let n=qu(e);n.parentNode===t&&t.removeChild(n)}if(!r){if(R._keyToDOMMap.delete(e),G(n)){let e=i_(n,hu);Tu(e,0,e.length-1,null)}if(n!==void 0){for(let e of Nu(n).values()){let t=Fu(e);wu(e,null),t!==null&&t.remove()}Hh(bu,au,fu,n,`destroyed`)}}}function Tu(e,t,n,r){for(let i=t;i<=n;++i){let t=e[i];t!==void 0&&wu(t,r)}}function Eu(e,t){e.setProperty(`text-align`,t)}function Du(e,t){let n=iu.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 Ou(e,t){let n=e.style;t===0?Eu(n,``):t===1?Eu(n,`left`):t===2?Eu(n,`center`):t===3?Eu(n,`right`):t===4?Eu(n,`justify`):t===5?Eu(n,`start`):t===6&&Eu(n,`end`)}function ku(e,t){let n=function(e){let t=e.__dir;if(t!==null)return t;if(Sm(e))return null;let n=e.getParent();return n===null||rg(n)&&n.__dir===null?`auto`:null}(t);n===null?e.removeAttribute(`dir`):e.dir=n}function Au(e){let t=_g().createElement(`div`);return t.setAttribute(`data-lexical-slot`,e),t.style.display=`none`,t}function ju(e,t,n){t||e.contentEditable===`false`?Yg(n,R):n.removeAttribute(`contenteditable`)}function Mu(e,t,n){let r=z,i=lu();z=``;let a=``,o=K(e);for(let[r,i]of n){let n=Au(r);ju(t,o,n),t.appendChild(n),z=``;let s=lu();Lu(i,Ig(e,n,R)),uu(s),Pu(e,r,t,n),a+=z}return uu(i),z=r,a}function Nu(e){return s_(e)&&e.__slots!==null?e.__slots:o_}function Pu(e,t,n,r){let i=xu.$getSlotTargetElement(e,t,n,R);i!==null&&(r.parentElement!==i&&i.appendChild(r),r.style.display=``)}function Fu(e){let t=vu.get(e);return t===void 0?null:t.parentElement}function Iu(e,t,n){let r=Nu(e),i=Nu(t);for(let[e,t]of r)if(!i.has(e)){let e=Fu(t);wu(t,null),e!==null&&e.remove()}let a=z,o=lu(),s=``,c=null,l=K(t);for(let[e,a]of i){let i=r.get(e),o=i===void 0?null:Fu(i);z=``;let u=lu();if(o===null){o=Au(e);let r=null;for(let e of n.children)if(!e.hasAttribute(`data-lexical-slot`)){r=e;break}n.insertBefore(o,r),Lu(a,Ig(t,o,R))}else i===a?Hu(a,o):(i!==void 0&&wu(i,o),Lu(a,Ig(t,o,R)));if(uu(u),ju(n,l,o),Pu(t,e,n,o),s+=z,o.parentElement===n){let e=c===null?n.firstChild:c.nextSibling;e!==o&&n.insertBefore(o,e),c=o}}return uu(o),z=a,s}function Lu(e,t){let n=_u.get(e);if(n===void 0&&L(60),t!==null){let r=hu.get(e);if(r!==void 0){let i=vu.get(e);if(i!==void 0){let a=c_(r)?r.__slotHost:null,o=c_(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),Hu(e,t.element)}}}let r=xu.$createDOM(n,R);if(function(e,t,n){let r=n._keyToDOMMap;yh(t,n,e),r.set(e,t)}(e,r,R),V(n)?r.setAttribute(`data-lexical-text`,`true`):K(n)&&(r.setAttribute(`data-lexical-decorator`,`true`),qg(r,{captureSelection:!0})),G(n)){let e=n.__indent,t=n.__size;ku(r,n),e!==0&&Du(r,e);let i=Nu(n),a=i.size>0?Mu(n,r,i):``;if(t===0)r.__lexicalTextContent=a,r.__lexicalFirstTextKey=null,z+=a,i.size>0&&(r.__lexicalSlotTextLength=a.length);else{let e=z,o=t-1;if(Ru(i_(n,_u),n,0,o,Ig(n,r,R)),a!==``){let t=r.__lexicalTextContent||``;r.__lexicalTextContent=a+t,z=e+a+t}i.size>0&&(r.__lexicalSlotTextLength=a.length)}let o=n.__format;o!==0&&Ou(r,o),n.isInline()||zu(null,n,r)}else{let t=n.getTextContent();if(K(n)){let t=n.decorate(R,iu);t!==null&&Uu(e,t),r.contentEditable=`false`;let i=Nu(n);i.size>0&&Mu(n,r,i)}z+=t}return t!==null&&t.insertChild(r),xu.$decorateDOM(n,null,r,R),ru(n),Hh(bu,au,fu,n,`created`),r}function Ru(e,t,n,r,i){let a=z,o=lu();z=``,ou=null,su=null,cu=null;let s=n;for(;s<=r;++s){let t=lu();Lu(e[s],i);let n=_u.get(e[s]);n!==null&&V(n)?ou===null&&(ou=n.getFormat(),su=n.getStyle(),cu=n.__key):G(n)&&s<r&&!n.isInline()&&(z+=`
|
|
132
|
+
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let n of e.seen.entries()){let r=n[1];if(t===n[0])a(n);else{if(e.external){let r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){a(n);continue}}(e.metadataRegistry.get(n[0])?.id||r.cycle||r.count>1&&e.reused===`ref`)&&a(n)}}}function ro(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=t=>{let n=e.seen.get(t);if(n.ref===null)return;let i=n.def??n.schema,a={...i},o=n.ref;if(n.ref=null,o){r(o);let n=e.seen.get(o),s=n.schema;if(s.$ref&&(e.target===`draft-07`||e.target===`draft-04`||e.target===`openapi-3.0`)?(i.allOf=i.allOf??[],i.allOf.push(s)):Object.assign(i,s),Object.assign(i,a),t._zod.parent===o)for(let e in i)e!==`$ref`&&e!==`allOf`&&(e in a||delete i[e]);if(s.$ref&&n.def)for(let e in i)e!==`$ref`&&e!==`allOf`&&e in n.def&&JSON.stringify(i[e])===JSON.stringify(n.def[e])&&delete i[e]}let s=t._zod.parent;if(s&&s!==o){r(s);let t=e.seen.get(s);if(t?.schema.$ref&&(i.$ref=t.schema.$ref,t.def))for(let e in i)e!==`$ref`&&e!==`allOf`&&e in t.def&&JSON.stringify(i[e])===JSON.stringify(t.def[e])&&delete i[e]}e.override({zodSchema:t,jsonSchema:i,path:n.path??[]})};for(let t of[...e.seen.entries()].reverse())r(t[0]);let i={};if(e.target===`draft-2020-12`?i.$schema=`https://json-schema.org/draft/2020-12/schema`:e.target===`draft-07`?i.$schema=`http://json-schema.org/draft-07/schema#`:e.target===`draft-04`?i.$schema=`http://json-schema.org/draft-04/schema#`:e.target,e.external?.uri){let n=e.external.registry.get(t)?.id;if(!n)throw Error("Schema is missing an `id` property");i.$id=e.external.uri(n)}Object.assign(i,n.def??n.schema);let a=e.metadataRegistry.get(t)?.id;a!==void 0&&i.id===a&&delete i.id;let o=e.external?.defs??{};for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(e.def.id===e.defId&&delete e.def.id,o[e.defId]=e.def)}e.external||Object.keys(o).length>0&&(e.target===`draft-2020-12`?i.$defs=o:i.definitions=o);try{let n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,"~standard",{value:{...t[`~standard`],jsonSchema:{input:oo(t,`input`,e.processors),output:oo(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function io(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 io(r.element,n);if(r.type===`set`)return io(r.valueType,n);if(r.type===`lazy`)return io(r.getter(),n);if(r.type===`promise`||r.type===`optional`||r.type===`nonoptional`||r.type===`nullable`||r.type===`readonly`||r.type==="default"||r.type===`prefault`)return io(r.innerType,n);if(r.type===`intersection`)return io(r.left,n)||io(r.right,n);if(r.type===`record`||r.type===`map`)return io(r.keyType,n)||io(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:io(r.in,n)||io(r.out,n);if(r.type===`object`){for(let e in r.shape)if(io(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(io(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(io(e,n))return!0;return!!(r.rest&&io(r.rest,n))}return!1}let ao=(e,t={})=>n=>{let r=eo({...n,processors:t});return to(e,r),no(r,e),ro(r,e)},oo=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=eo({...i??{},target:a,io:t,processors:n});return to(e,o),no(o,e),ro(o,e)},so={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},co=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l}=e._zod.bag;if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=so[s]??s,i.format===``&&delete i.format,s===`time`&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let e=[...c];e.length===1?i.pattern=e[0].source:e.length>1&&(i.allOf=[...e.map(e=>({...t.target===`draft-07`||t.target===`draft-04`||t.target===`openapi-3.0`?{type:`string`}:{},pattern:e.source}))])}},lo=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,format:s,multipleOf:c,exclusiveMaximum:l,exclusiveMinimum:u}=e._zod.bag;i.type=typeof s==`string`&&s.includes(`int`)?`integer`:`number`;let d=typeof u==`number`&&u>=(a??-1/0),f=typeof l==`number`&&l<=(o??1/0),p=t.target===`draft-04`||t.target===`openapi-3.0`;d?p?(i.minimum=u,i.exclusiveMinimum=!0):i.exclusiveMinimum=u:typeof a==`number`&&(i.minimum=a),f?p?(i.maximum=l,i.exclusiveMaximum=!0):i.exclusiveMaximum=l:typeof o==`number`&&(i.maximum=o),typeof c==`number`&&(i.multipleOf=c)},uo=(e,t,n,r)=>{n.type=`boolean`},fo=(e,t,n,r)=>{t.target===`openapi-3.0`?(n.type=`string`,n.nullable=!0,n.enum=[null]):n.type=`null`},po=(e,t,n,r)=>{n.not={}},mo=(e,t,n,r)=>{let i=e._zod.def,a=jt(i.entries);a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a},ho=(e,t,n,r)=>{let i=e._zod.def,a=[];for(let e of i.values)if(e===void 0){if(t.unrepresentable===`throw`)throw Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof e==`bigint`){if(t.unrepresentable===`throw`)throw Error(`BigInt literals cannot be represented in JSON Schema`);a.push(Number(e))}else a.push(e);if(a.length!==0){if(a.length===1){let e=a[0];n.type=e===null?`null`:typeof e,t.target===`draft-04`||t.target===`openapi-3.0`?n.enum=[e]:n.const=e}else a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),a.every(e=>typeof e==`boolean`)&&(n.type=`boolean`),a.every(e=>e===null)&&(n.type=`null`),n.enum=a}},go=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Custom types cannot be represented in JSON Schema`)},_o=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Transforms cannot be represented in JSON Schema`)},vo=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=e._zod.bag;typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=to(a.element,t,{...r,path:[...r.path,`items`]})},yo=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`,i.properties={};let o=a.shape;for(let e in o)i.properties[e]=to(o[e],t,{...r,path:[...r.path,`properties`,e]});let s=new Set(Object.keys(o)),c=new Set([...s].filter(e=>{let n=a.shape[e]._zod;return t.io===`input`?n.optin===void 0:n.optout===void 0}));c.size>0&&(i.required=Array.from(c)),a.catchall?._zod.def.type===`never`?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=to(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},bo=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>to(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},xo=(e,t,n,r)=>{let i=e._zod.def,a=to(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=to(i.right,t,{...r,path:[...r.path,`allOf`,1]}),s=e=>`allOf`in e&&Object.keys(e).length===1;n.allOf=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]]},So=(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)=>to(e,t,{...r,path:[...r.path,o,n]})),l=a.rest?to(a.rest,t,{...r,path:[...r.path,s,...t.target===`openapi-3.0`?[a.items.length]:[]]}):null;t.target===`draft-2020-12`?(i.prefixItems=c,l&&(i.items=l)):t.target===`openapi-3.0`?(i.items={anyOf:c},l&&i.items.anyOf.push(l),i.minItems=c.length,l||(i.maxItems=c.length)):(i.items=c,l&&(i.additionalItems=l));let{minimum:u,maximum:d}=e._zod.bag;typeof u==`number`&&(i.minItems=u),typeof d==`number`&&(i.maxItems=d)},Co=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`;let o=a.keyType,s=o._zod.bag?.patterns;if(a.mode===`loose`&&s&&s.size>0){let e=to(a.valueType,t,{...r,path:[...r.path,`patternProperties`,`*`]});i.patternProperties={};for(let t of s)i.patternProperties[t.source]=e}else(t.target===`draft-07`||t.target===`draft-2020-12`)&&(i.propertyNames=to(a.keyType,t,{...r,path:[...r.path,`propertyNames`]})),i.additionalProperties=to(a.valueType,t,{...r,path:[...r.path,`additionalProperties`]});let c=o._zod.values;if(c){let e=[...c].filter(e=>typeof e==`string`||typeof e==`number`);e.length>0&&(i.required=e)}},wo=(e,t,n,r)=>{let i=e._zod.def,a=to(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`}]},To=(e,t,n,r)=>{let i=e._zod.def;to(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Eo=(e,t,n,r)=>{let i=e._zod.def;to(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.default=JSON.parse(JSON.stringify(i.defaultValue))},Do=(e,t,n,r)=>{let i=e._zod.def;to(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,t.io===`input`&&(n._prefault=JSON.parse(JSON.stringify(i.defaultValue)))},Oo=(e,t,n,r)=>{let i=e._zod.def;to(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{throw Error(`Dynamic catch values are not supported in JSON Schema`)}n.default=o},ko=(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;to(o,t,r);let s=t.seen.get(e);s.ref=o},Ao=(e,t,n,r)=>{let i=e._zod.def;to(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},jo=(e,t,n,r)=>{let i=e._zod.def;to(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Mo=(e,t,n,r)=>{let i=e._zod.innerType;to(i,t,r);let a=t.seen.get(e);a.ref=i},No=/*@__PURE__*/ T(`ZodISODateTime`,(e,t)=>{Vr.init(e,t),as.init(e,t)});function Po(e){return/* @__PURE__ */ ya(No,e)}let Fo=/*@__PURE__*/ T(`ZodISODate`,(e,t)=>{Hr.init(e,t),as.init(e,t)});function Io(e){return/* @__PURE__ */ ba(Fo,e)}let Lo=/*@__PURE__*/ T(`ZodISOTime`,(e,t)=>{Ur.init(e,t),as.init(e,t)});function Ro(e){return/* @__PURE__ */ xa(Lo,e)}let zo=/*@__PURE__*/ T(`ZodISODuration`,(e,t)=>{Wr.init(e,t),as.init(e,t)});function Bo(e){return/* @__PURE__ */ Sa(zo,e)}let Vo=/*@__PURE__*/ T(`ZodError`,(e,t)=>{mn.init(e,t),e.name=`ZodError`,Object.defineProperties(e,{format:{value:t=>_n(e,t)},flatten:{value:t=>gn(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,Mt,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,Mt,2)}},isEmpty:{get(){return e.issues.length===0}}})},{Parent:Error}),Ho=/* @__PURE__ */ vn(Vo),Uo=/* @__PURE__ */ yn(Vo),Wo=/* @__PURE__ */ bn(Vo),Go=/* @__PURE__ */ Sn(Vo),Ko=/* @__PURE__ */ wn(Vo),qo=/* @__PURE__ */ Tn(Vo),Jo=/* @__PURE__ */ En(Vo),Yo=/* @__PURE__ */ Dn(Vo),Xo=/* @__PURE__ */ On(Vo),Zo=/* @__PURE__ */ kn(Vo),Qo=/* @__PURE__ */ An(Vo),$o=/* @__PURE__ */ jn(Vo),es=/* @__PURE__ */ new WeakMap;function ts(e,t,n){let r=Object.getPrototypeOf(e),i=es.get(r);if(i||(i=/* @__PURE__ */ new Set,es.set(r,i)),!i.has(t)){i.add(t);for(let e in n){let t=n[e];Object.defineProperty(r,e,{configurable:!0,enumerable:!1,get(){let n=t.bind(this);return Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:n}),n},set(t){Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:t})}})}}}let ns=/*@__PURE__*/ T(`ZodType`,(e,t)=>(O.init(e,t),Object.assign(e[`~standard`],{jsonSchema:{input:oo(e,`input`),output:oo(e,`output`)}}),e.toJSONSchema=ao(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(t,n)=>Ho(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>Wo(e,t,n),e.parseAsync=async(t,n)=>Uo(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>Go(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>Ko(e,t,n),e.decode=(t,n)=>qo(e,t,n),e.encodeAsync=async(t,n)=>Jo(e,t,n),e.decodeAsync=async(t,n)=>Yo(e,t,n),e.safeEncode=(t,n)=>Xo(e,t,n),e.safeDecode=(t,n)=>Zo(e,t,n),e.safeEncodeAsync=async(t,n)=>Qo(e,t,n),e.safeDecodeAsync=async(t,n)=>$o(e,t,n),ts(e,`ZodType`,{check(...e){let t=this.def;return this.clone(zt(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 Yt(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(xc(e,t))},superRefine(e,t){return this.check(Sc(e,t))},overwrite(e){return this.check(/* @__PURE__ */ Ua(e))},optional(){return ec(this)},exactOptional(){return nc(this)},nullable(){return ic(this)},nullish(){return ec(ic(this))},nonoptional(e){return uc(this,e)},array(){return M(this)},or(e){return Bs([this,e])},and(e){return Ws(this,e)},transform(e){return mc(this,Qs(e))},default(e){return oc(this,e)},prefault(e){return cc(this,e)},catch(e){return fc(this,e)},pipe(e){return mc(this,e)},readonly(){return gc(this)},describe(e){let t=this.clone();return Yi.add(t,{description:e}),t},meta(...e){if(e.length===0)return Yi.get(this);let t=this.clone();return Yi.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e){return e(this)}}),Object.defineProperty(e,"description",{get(){return Yi.get(e)?.description},configurable:!0}),e)),rs=/*@__PURE__*/ T(`_ZodString`,(e,t)=>{Or.init(e,t),ns.init(e,t),e._zod.processJSONSchema=(t,n,r)=>co(e,t,n,r);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,ts(e,`_ZodString`,{regex(...e){return this.check(/* @__PURE__ */ La(...e))},includes(...e){return this.check(/* @__PURE__ */ Ba(...e))},startsWith(...e){return this.check(/* @__PURE__ */ Va(...e))},endsWith(...e){return this.check(/* @__PURE__ */ Ha(...e))},min(...e){return this.check(/* @__PURE__ */ Fa(...e))},max(...e){return this.check(/* @__PURE__ */ Pa(...e))},length(...e){return this.check(/* @__PURE__ */ Ia(...e))},nonempty(...e){return this.check(/* @__PURE__ */ Fa(1,...e))},lowercase(e){return this.check(/* @__PURE__ */ Ra(e))},uppercase(e){return this.check(/* @__PURE__ */ za(e))},trim(){return this.check(/* @__PURE__ */ Ga())},normalize(...e){return this.check(/* @__PURE__ */ Wa(...e))},toLowerCase(){return this.check(/* @__PURE__ */ Ka())},toUpperCase(){return this.check(/* @__PURE__ */ qa())},slugify(){return this.check(/* @__PURE__ */ Ja())}})}),is=/*@__PURE__*/ T(`ZodString`,(e,t)=>{Or.init(e,t),rs.init(e,t),e.email=t=>e.check(/* @__PURE__ */ Zi(os,t)),e.url=t=>e.check(/* @__PURE__ */ ra(us,t)),e.jwt=t=>e.check(/* @__PURE__ */ va(Es,t)),e.emoji=t=>e.check(/* @__PURE__ */ ia(fs,t)),e.guid=t=>e.check(/* @__PURE__ */ Qi(ss,t)),e.uuid=t=>e.check(/* @__PURE__ */ $i(cs,t)),e.uuidv4=t=>e.check(/* @__PURE__ */ ea(cs,t)),e.uuidv6=t=>e.check(/* @__PURE__ */ ta(cs,t)),e.uuidv7=t=>e.check(/* @__PURE__ */ na(cs,t)),e.nanoid=t=>e.check(/* @__PURE__ */ aa(ps,t)),e.guid=t=>e.check(/* @__PURE__ */ Qi(ss,t)),e.cuid=t=>e.check(/* @__PURE__ */ oa(ms,t)),e.cuid2=t=>e.check(/* @__PURE__ */ sa(hs,t)),e.ulid=t=>e.check(/* @__PURE__ */ ca(gs,t)),e.base64=t=>e.check(/* @__PURE__ */ ha(Cs,t)),e.base64url=t=>e.check(/* @__PURE__ */ ga(ws,t)),e.xid=t=>e.check(/* @__PURE__ */ la(_s,t)),e.ksuid=t=>e.check(/* @__PURE__ */ ua(vs,t)),e.ipv4=t=>e.check(/* @__PURE__ */ da(ys,t)),e.ipv6=t=>e.check(/* @__PURE__ */ fa(bs,t)),e.cidrv4=t=>e.check(/* @__PURE__ */ pa(xs,t)),e.cidrv6=t=>e.check(/* @__PURE__ */ ma(Ss,t)),e.e164=t=>e.check(/* @__PURE__ */ _a(Ts,t)),e.datetime=t=>e.check(Po(t)),e.date=t=>e.check(Io(t)),e.time=t=>e.check(Ro(t)),e.duration=t=>e.check(Bo(t))});function k(e){return/* @__PURE__ */ Xi(is,e)}let as=/*@__PURE__*/ T(`ZodStringFormat`,(e,t)=>{kr.init(e,t),rs.init(e,t)}),os=/*@__PURE__*/ T(`ZodEmail`,(e,t)=>{Mr.init(e,t),as.init(e,t)}),ss=/*@__PURE__*/ T(`ZodGUID`,(e,t)=>{Ar.init(e,t),as.init(e,t)}),cs=/*@__PURE__*/ T(`ZodUUID`,(e,t)=>{jr.init(e,t),as.init(e,t)});function ls(e){return/* @__PURE__ */ $i(cs,e)}let us=/*@__PURE__*/ T(`ZodURL`,(e,t)=>{Nr.init(e,t),as.init(e,t)});function ds(e){return/* @__PURE__ */ ra(us,e)}let fs=/*@__PURE__*/ T(`ZodEmoji`,(e,t)=>{Pr.init(e,t),as.init(e,t)}),ps=/*@__PURE__*/ T(`ZodNanoID`,(e,t)=>{Fr.init(e,t),as.init(e,t)}),ms=/*@__PURE__*/ T(`ZodCUID`,(e,t)=>{Ir.init(e,t),as.init(e,t)}),hs=/*@__PURE__*/ T(`ZodCUID2`,(e,t)=>{Lr.init(e,t),as.init(e,t)}),gs=/*@__PURE__*/ T(`ZodULID`,(e,t)=>{Rr.init(e,t),as.init(e,t)}),_s=/*@__PURE__*/ T(`ZodXID`,(e,t)=>{zr.init(e,t),as.init(e,t)}),vs=/*@__PURE__*/ T(`ZodKSUID`,(e,t)=>{Br.init(e,t),as.init(e,t)}),ys=/*@__PURE__*/ T(`ZodIPv4`,(e,t)=>{Gr.init(e,t),as.init(e,t)}),bs=/*@__PURE__*/ T(`ZodIPv6`,(e,t)=>{Kr.init(e,t),as.init(e,t)}),xs=/*@__PURE__*/ T(`ZodCIDRv4`,(e,t)=>{qr.init(e,t),as.init(e,t)}),Ss=/*@__PURE__*/ T(`ZodCIDRv6`,(e,t)=>{Jr.init(e,t),as.init(e,t)}),Cs=/*@__PURE__*/ T(`ZodBase64`,(e,t)=>{Xr.init(e,t),as.init(e,t)}),ws=/*@__PURE__*/ T(`ZodBase64URL`,(e,t)=>{Qr.init(e,t),as.init(e,t)}),Ts=/*@__PURE__*/ T(`ZodE164`,(e,t)=>{$r.init(e,t),as.init(e,t)}),Es=/*@__PURE__*/ T(`ZodJWT`,(e,t)=>{ti.init(e,t),as.init(e,t)}),Ds=/*@__PURE__*/ T(`ZodNumber`,(e,t)=>{ni.init(e,t),ns.init(e,t),e._zod.processJSONSchema=(t,n,r)=>lo(e,t,n,r),ts(e,`ZodNumber`,{gt(e,t){return this.check(/* @__PURE__ */ ja(e,t))},gte(e,t){return this.check(/* @__PURE__ */ Ma(e,t))},min(e,t){return this.check(/* @__PURE__ */ Ma(e,t))},lt(e,t){return this.check(/* @__PURE__ */ ka(e,t))},lte(e,t){return this.check(/* @__PURE__ */ Aa(e,t))},max(e,t){return this.check(/* @__PURE__ */ Aa(e,t))},int(e){return this.check(ks(e))},safe(e){return this.check(ks(e))},positive(e){return this.check(/* @__PURE__ */ ja(0,e))},nonnegative(e){return this.check(/* @__PURE__ */ Ma(0,e))},negative(e){return this.check(/* @__PURE__ */ ka(0,e))},nonpositive(e){return this.check(/* @__PURE__ */ Aa(0,e))},multipleOf(e,t){return this.check(/* @__PURE__ */ Na(e,t))},step(e,t){return this.check(/* @__PURE__ */ Na(e,t))},finite(){return this}});let n=e._zod.bag;e.minValue=Math.max(n.minimum??-1/0,n.exclusiveMinimum??-1/0)??null,e.maxValue=Math.min(n.maximum??1/0,n.exclusiveMaximum??1/0)??null,e.isInt=(n.format??``).includes(`int`)||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function A(e){return/* @__PURE__ */ Ca(Ds,e)}let Os=/*@__PURE__*/ T(`ZodNumberFormat`,(e,t)=>{ri.init(e,t),Ds.init(e,t)});function ks(e){return/* @__PURE__ */ wa(Os,e)}let As=/*@__PURE__*/ T(`ZodBoolean`,(e,t)=>{ii.init(e,t),ns.init(e,t),e._zod.processJSONSchema=(t,n,r)=>uo(e,t,n,r)});function j(e){return/* @__PURE__ */ Ta(As,e)}let js=/*@__PURE__*/ T(`ZodNull`,(e,t)=>{ai.init(e,t),ns.init(e,t),e._zod.processJSONSchema=(t,n,r)=>fo(e,t,n,r)});function Ms(e){return/* @__PURE__ */ Ea(js,e)}let Ns=/*@__PURE__*/ T(`ZodUnknown`,(e,t)=>{oi.init(e,t),ns.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function Ps(){return/* @__PURE__ */ Da(Ns)}let Fs=/*@__PURE__*/ T(`ZodNever`,(e,t)=>{si.init(e,t),ns.init(e,t),e._zod.processJSONSchema=(t,n,r)=>po(e,t,n,r)});function Is(e){return/* @__PURE__ */ Oa(Fs,e)}let Ls=/*@__PURE__*/ T(`ZodArray`,(e,t)=>{li.init(e,t),ns.init(e,t),e._zod.processJSONSchema=(t,n,r)=>vo(e,t,n,r),e.element=t.element,ts(e,`ZodArray`,{min(e,t){return this.check(/* @__PURE__ */ Fa(e,t))},nonempty(e){return this.check(/* @__PURE__ */ Fa(1,e))},max(e,t){return this.check(/* @__PURE__ */ Pa(e,t))},length(e,t){return this.check(/* @__PURE__ */ Ia(e,t))},unwrap(){return this.element}})});function M(e,t){return/* @__PURE__ */ Ya(Ls,e,t)}let Rs=/*@__PURE__*/ T(`ZodObject`,(e,t)=>{mi.init(e,t),ns.init(e,t),e._zod.processJSONSchema=(t,n,r)=>yo(e,t,n,r),E(e,`shape`,()=>t.shape),ts(e,`ZodObject`,{keyof(){return F(Object.keys(this._zod.def.shape))},catchall(e){return this.clone({...this._zod.def,catchall:e})},passthrough(){return this.clone({...this._zod.def,catchall:Ps()})},loose(){return this.clone({...this._zod.def,catchall:Ps()})},strict(){return this.clone({...this._zod.def,catchall:Is()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(e){return en(this,e)},safeExtend(e){return tn(this,e)},merge(e){return nn(this,e)},pick(e){return Qt(this,e)},omit(e){return $t(this,e)},partial(...e){return rn($s,this,e[0])},required(...e){return an(lc,this,e[0])}})});function N(e,t){let n={type:`object`,shape:e??{},...D(t)};return new Rs(n)}function P(e,t){return new Rs({type:`object`,shape:e,catchall:Is(),...D(t)})}let zs=/*@__PURE__*/ T(`ZodUnion`,(e,t)=>{gi.init(e,t),ns.init(e,t),e._zod.processJSONSchema=(t,n,r)=>bo(e,t,n,r),e.options=t.options});function Bs(e,t){return new zs({type:`union`,options:e,...D(t)})}let Vs=/*@__PURE__*/ T(`ZodDiscriminatedUnion`,(e,t)=>{zs.init(e,t),_i.init(e,t)});function Hs(e,t,n){return new Vs({type:`union`,options:t,discriminator:e,...D(n)})}let Us=/*@__PURE__*/ T(`ZodIntersection`,(e,t)=>{vi.init(e,t),ns.init(e,t),e._zod.processJSONSchema=(t,n,r)=>xo(e,t,n,r)});function Ws(e,t){return new Us({type:`intersection`,left:e,right:t})}let Gs=/*@__PURE__*/ T(`ZodTuple`,(e,t)=>{xi.init(e,t),ns.init(e,t),e._zod.processJSONSchema=(t,n,r)=>So(e,t,n,r),e.rest=t=>e.clone({...e._zod.def,rest:t})});function Ks(e,t,n){let r=t instanceof O;return new Gs({type:`tuple`,items:e,rest:r?t:null,...D(r?n:t)})}let qs=/*@__PURE__*/ T(`ZodRecord`,(e,t)=>{Ti.init(e,t),ns.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Co(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType});function Js(e,t,n){return!t||!t._zod?new qs({type:`record`,keyType:k(),valueType:e,...D(t)}):new qs({type:`record`,keyType:e,valueType:t,...D(n)})}let Ys=/*@__PURE__*/ T(`ZodEnum`,(e,t)=>{Ei.init(e,t),ns.init(e,t),e._zod.processJSONSchema=(t,n,r)=>mo(e,t,n,r),e.enum=t.entries,e.options=Object.values(t.entries);let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new Ys({...t,checks:[],...D(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 Ys({...t,checks:[],...D(r),entries:i})}});function F(e,t){let n=Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e;return new Ys({type:`enum`,entries:n,...D(t)})}let Xs=/*@__PURE__*/ T(`ZodLiteral`,(e,t)=>{Di.init(e,t),ns.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ho(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 I(e,t){return new Xs({type:`literal`,values:Array.isArray(e)?e:[e],...D(t)})}let Zs=/*@__PURE__*/ T(`ZodTransform`,(e,t)=>{Oi.init(e,t),ns.init(e,t),e._zod.processJSONSchema=(t,n,r)=>_o(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new Ot(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(fn(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,t.input??=n.value,t.inst??=e,n.issues.push(fn(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n.fallback=!0,n)):(n.value=i,n.fallback=!0,n)}});function Qs(e){return new Zs({type:`transform`,transform:e})}let $s=/*@__PURE__*/ T(`ZodOptional`,(e,t)=>{Ai.init(e,t),ns.init(e,t),e._zod.processJSONSchema=(t,n,r)=>jo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function ec(e){return new $s({type:`optional`,innerType:e})}let tc=/*@__PURE__*/ T(`ZodExactOptional`,(e,t)=>{ji.init(e,t),ns.init(e,t),e._zod.processJSONSchema=(t,n,r)=>jo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function nc(e){return new tc({type:`optional`,innerType:e})}let rc=/*@__PURE__*/ T(`ZodNullable`,(e,t)=>{Mi.init(e,t),ns.init(e,t),e._zod.processJSONSchema=(t,n,r)=>wo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function ic(e){return new rc({type:`nullable`,innerType:e})}let ac=/*@__PURE__*/ T(`ZodDefault`,(e,t)=>{Ni.init(e,t),ns.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Eo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function oc(e,t){return new ac({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():Kt(t)}})}let sc=/*@__PURE__*/ T(`ZodPrefault`,(e,t)=>{Fi.init(e,t),ns.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Do(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function cc(e,t){return new sc({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():Kt(t)}})}let lc=/*@__PURE__*/ T(`ZodNonOptional`,(e,t)=>{Ii.init(e,t),ns.init(e,t),e._zod.processJSONSchema=(t,n,r)=>To(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function uc(e,t){return new lc({type:`nonoptional`,innerType:e,...D(t)})}let dc=/*@__PURE__*/ T(`ZodCatch`,(e,t)=>{Ri.init(e,t),ns.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Oo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function fc(e,t){return new dc({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:()=>t})}let pc=/*@__PURE__*/ T(`ZodPipe`,(e,t)=>{zi.init(e,t),ns.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ko(e,t,n,r),e.in=t.in,e.out=t.out});function mc(e,t){return new pc({type:`pipe`,in:e,out:t})}let hc=/*@__PURE__*/ T(`ZodReadonly`,(e,t)=>{Vi.init(e,t),ns.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ao(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function gc(e){return new hc({type:`readonly`,innerType:e})}let _c=/*@__PURE__*/ T(`ZodLazy`,(e,t)=>{Ui.init(e,t),ns.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Mo(e,t,n,r),e.unwrap=()=>e._zod.def.getter()});function vc(e){return new _c({type:`lazy`,getter:e})}let yc=/*@__PURE__*/ T(`ZodCustom`,(e,t)=>{Wi.init(e,t),ns.init(e,t),e._zod.processJSONSchema=(t,n,r)=>go(e,t,n,r)});function bc(e,t){return/* @__PURE__ */ Xa(yc,e??(()=>!0),t)}function xc(e,t={}){return/* @__PURE__ */ Za(yc,e,t)}function Sc(e,t){return/* @__PURE__ */ Qa(e,t)}let Cc=N({source:k(),ref:k(),offset:A().int().nonnegative(),length:A().int().positive(),label:k(),appearance:F([`session`,`file`,`folder`,`skill`]).optional(),clipboardText:k(),invalid:j().optional()}),wc=N({text:k(),references:M(Cc)}).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 Tc(e){return typeof e==`string`?{text:e,references:[]}:{text:e.text,references:e.references.map(Oc)}}function Ec(e){if(typeof e==`string`)return Tc(e);let t=wc.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 Dc(e,t){return{text:e,references:t.map(Oc)}}function Oc(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 kc=`dsh.conversation`;function Ac(){return(0,f.defineStore)({init:()=>({draft:``,view:null,viewRequest:null}),persist:kc,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 jc(e){let t={text:``,references:[]};if(typeof localStorage>`u`)return t;try{let n=localStorage.getItem(`${kc}.${e}`);if(n===null)return t;let r=JSON.parse(n);return typeof r!=`object`||!r||!(`draft`in r)?t:Ec(r.draft)??t}catch{return t}}function Mc(e){if(typeof localStorage>`u`)return null;try{let t=localStorage.getItem(`${kc}.${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 Nc(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 Pc(e){let t=e.replace(/[/\\]+$/,``),n=Math.max(t.lastIndexOf(`/`),t.lastIndexOf(`\\`));return t.slice(n+1)}function Fc(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 Ic=`conversation`,Lc=`描述你的任务以生成计划`,Rc=`describe your task to generate plan`,zc={"shortcut.newline":`换行`,"shortcut.complementary":`使用互补的 Queue/Steer 方式`,"shortcut.slash":`打开命令菜单`,"shortcut.mention":`打开引用菜单`,"hint.plan":Lc,"hint.goal":`输入目标,智能体将持续执行`,"hint.goal.active":`当前目标进行中。可输入 edit 修改 / pause 暂停 / resume 继续 / clear 清除`,"placeholder.plan":Lc,"placeholder.default":`发消息或创建任务, / 调用指令, @ 文件或对话`,"placeholder.unavailable":`会话不可用`,"placeholder.parentOffline":`父会话已离线,无法继续发送;仍可停止当前运行`,"placeholder.hero":`描述你想要构建的内容, / 调用指令, @ 文件或对话`,"placeholder.workspace":`选择一个工作区开始`,"placeholder.preparing":`正在准备对话…`,"placeholder.steerQueue":`Cmd/Ctrl+Enter 插话发送全部排队消息`,"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.chipLabel":`{index}.`,"annotation.title":`批注 {index}:{excerpt}`,"annotation.selectedText":`选中文字:`,"annotation.userComment":`你的批注:`,"annotation.remove":`移除批注 {index}`,"annotation.label":`批注 {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 后重试。`,"queue.editFailed":`编辑失败:这条消息可能已经开始发送。`,"queue.removeFailed":`删除失败:这条消息可能已经开始发送。`,"queue.steerFailed":`插话发送失败,请重试。`,"queue.resumeFailed":`继续队列失败,请重试。`,"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}`},Bc={"shortcut.newline":`New line`,"shortcut.complementary":`Use the complementary Queue / Steer action`,"shortcut.slash":`Open command menu`,"shortcut.mention":`Open reference menu`,"hint.plan":Rc,"hint.goal":`describe the objective for a long-running task`,"hint.goal.active":`goal active — edit / pause / resume / clear`,"placeholder.plan":Rc,"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`,"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.chipLabel":`{index}.`,"annotation.title":`Annotation {index}: {excerpt}`,"annotation.selectedText":`Selected text:`,"annotation.userComment":`Your comment:`,"annotation.remove":`Remove annotation {index}`,"annotation.label":`Annotation {index}`,"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 non-text content; editing is not supported 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.`,"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.`,"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}`},Vc=2048;async function Hc(e){if(e.type!==`image/jpeg`&&e.type!==`image/webp`)return e;let t;try{t=await createImageBitmap(e,{imageOrientation:`from-image`});let n=Math.max(t.width,t.height);if(n<=Vc&&e.size<=1048576)return e;let r=Math.min(1,Vc/n),i=Math.max(1,Math.round(t.width*r)),a=Math.max(1,Math.round(t.height*r)),o;if(typeof OffscreenCanvas==`function`&&typeof OffscreenCanvas.prototype.convertToBlob==`function`){let n=new OffscreenCanvas(i,a),r=n.getContext(`2d`);if(r===null)return e;r.drawImage(t,0,0,i,a),o=await n.convertToBlob({type:`image/jpeg`,quality:.85})}else{let n=document.createElement(`canvas`);n.width=i,n.height=a;let r=n.getContext(`2d`);if(r===null)return e;r.drawImage(t,0,0,i,a),o=await new Promise(e=>n.toBlob(e,`image/jpeg`,.85))}if(o===null||o.type!==`image/jpeg`||o.size===0||o.size>=e.size)return e;let s=e.name===``?``:`${e.name.replace(/\.[^.]*$/u,``)}.jpg`;return new File([o],s,{type:`image/jpeg`,lastModified:e.lastModified})}catch{return e}finally{t?.close()}}function Uc(e){return{kind:`image`,id:vt(),previewUrl:URL.createObjectURL(e),file:e}}function Wc(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 Gc(){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 Kc=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`&&Jc(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:e.file.name,bytes:e.file.size}}})),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,onRetire:t=>{this.settleSubmittedAttachments(e.sessionId,a,t),c?.(t)}}),d;try{await Gc(),d=[...await s(),...t===``?[]:[{type:`text`,text:t}]]}catch(e){throw u.abandon(),e}return!(await e.prompt(d,r,i,u.requestId)).ok||l!==void 0&&(await l).reason!==`observed`?{kind:`error`}:{kind:`success`}}finally{a?.release()}}createDrafts(e,t){return t.map(t=>{if(qc(t.type)){let n=Uc(t);return this.draftAttachments.set(n.id,n),Wc(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})}retryFileUpload(e,t){let n=this.draftAttachments.get(t);n!==void 0&&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&&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`&&(r.type===`image/jpeg`||r.type===`image/webp`)){let e=this.preparedPhotos.get(t);if(e===void 0&&(e=Hc(r),this.preparedPhotos.set(t,e)),r=await e,n.signal.aborted||this.fileUploadOperations.get(t.id)?.controller!==n)return;this.fileUploads.update(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;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.fileUploadOperations.get(e);this.fileUploadOperations.delete(e),n?.controller.abort(),this.draftAttachments.delete(e),this.uploadSessions.delete(e),this.foregroundRetried.delete(e),t.kind===`image`&&Jc(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}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++];t!==void 0&&(a.kind===`file`?this.releaseDraftAttachment(a.id):(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&&r?.seedImageUrl(e,o,a.previewUrl)===!0)&&Jc(a.previewUrl)))}}assertUploadsNotFailed(e){if(e.some(e=>this.fileUploads.getSnapshot()[e]?.status===`error`))throw Error(this.ctx.locale.bind(Ic)(`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(Ic)(`file.retryOrRemove`)))):e.every(e=>r[e]?.status===`ready`)&&(i(),t())},i=this.fileUploads.subscribe(r);r()})}};function qc(e){return e===`image/png`||e===`image/jpeg`||e===`image/webp`||e===`image/gif`}function Jc(e){e.startsWith(`blob:`)&&URL.revokeObjectURL(e)}var Yc=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 L(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 Xc(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 Zc=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0,Qc=Zc&&`documentMode`in document?document.documentMode:null,$c=Zc&&/Mac|iPod|iPhone|iPad/.test(navigator.platform),el=Zc&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent),tl=!(!Zc||!(`InputEvent`in window)||Qc)&&`getTargetRanges`in new window.InputEvent(`input`),nl=Zc&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,rl=Zc&&/Android/.test(navigator.userAgent),il=Zc&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent)&&!rl,al=Zc&&/^(?=.*Chrome).*/i.test(navigator.userAgent),ol=Zc&&rl&&al,sl=Zc&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&$c&&!al,cl=il||nl||sl?`\xA0`:``,ll=el?`\xA0`:cl,ul=`֑-߿יִ-﷽ﹰ-ﻼ`,dl=`A-Za-zÀ-ÖØ-öø-ʸ̀-ࠀ-Ⰰ-︀--`;RegExp(`^[^`+dl+`]*[`+ul+`]`),RegExp(`^[^`+ul+`]*[`+dl+`]`);let fl={bold:1,capitalize:1024,code:16,highlight:128,italic:2,lowercase:256,strikethrough:4,subscript:32,superscript:64,underline:8,uppercase:512},pl={directionless:1,unmergeable:2},ml={center:2,end:6,justify:4,left:1,right:3,start:5},hl={2:`center`,6:`end`,4:`justify`,1:`left`,3:`right`,5:`start`},gl={normal:0,segmented:2,token:1},_l={0:`normal`,2:`segmented`,1:`token`},vl=`$config`;function yl(){return Lg()._blockCursorElement}function bl(e){return e!==null&&e.nodeType===1&&e.hasAttribute(`data-lexical-slot`)}var xl=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&&L(357),this.element.insertBefore(e,t),this}removeChild(e){return e.parentElement!==this.element&&L(358),this.element.removeChild(e),this}replaceChild(e,t){return t.parentElement!==this.element&&L(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=Sl(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=Sl(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 Sl(e,t){let n=t;for(;n!==null&&n.parentNode!==e;)n=n.parentNode;return n}var Cl=class e extends xl{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(;bl(t);)e=t,t=t.nextSibling;let n=e?e.nextSibling:this.element.firstChild;return n!==null&&n===yl()?n:e}getManagedLineBreak(){return this.element.__lexicalLineBreak||null}setManagedLineBreak(e){if(this.element.__lexicalLastChildKind=e,e===null)this.removeManagedLineBreak();else{let t=e===`decorator`&&(sl||nl||il);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=bg().createElement(`br`);if(i.setAttribute(`data-lexical-managed-linebreak`,`true`),n.insertBefore(i,r),e){let e=bg().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=yl(),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=wl(t,n);i.push(r);let a=wl(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 wl(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&&L(225),n.reverse()}let Tl;try{Tl=`0.49.0+prod.esm`}catch{}let El=Tl??`"<unknown>+source"`;var Dl=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 Ol(e,t=1e3){return e instanceof kl?e.clone():e.size<t?new Map(e):new kl().init(new Map(e),void 0,e.size)}var kl=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 Al(e,t,n,r,i,a){if(G(e)){let o=e.getFirstChild();for(;o!==null;){let e=o.__key;o.__parent===t&&((G(o)||u_(o)&&o.__slots!==null)&&Al(o,e,n,r,i,a),n.has(e)||a.delete(e),i.push(e)),o=o.getNextSibling()}}for(let o of u_(e)&&e.__slots!==null?e.__slots.values():[]){let e=r.get(o);e!==void 0&&d_(e)&&e.__slotHost===t&&((G(e)||u_(e)&&e.__slots!==null)&&Al(e,o,n,r,i,a),n.has(o)||a.delete(o),i.push(o))}}let jl=!1,Ml=0;function Nl(e){Ml=e.timeStamp}function Pl(e,t,n){let r=e.nodeName===`BR`,i=t.__lexicalLineBreak;return i&&(e===i||r&&e.previousSibling===i)||r&&Ch(e,n)!==void 0}function Fl(e,t,n){let r=pg(ng(n)),i=r&&Cg(r,n._rootElement),a=null,o=null;i!==null&&i.anchorNode===e&&(a=i.anchorOffset,o=i.focusOffset);let s=e.nodeValue;s!==null&&Ih(t,s,a,o,!1)}function Il(e,t,n){if(H(e)){let t=e.anchor.getNode();if(t.is(n)&&e.format!==t.getFormat())return!1}return dh(t)&&n.isAttached()}function Ll(e,t,n){for(let r=e;r&&!Zg(r);r=Xh(r)){let e=Ch(r,t);if(e!==void 0){let t=bh(e,n);if(t)return K(t)||!Y(r)?void 0:[r,t]}}}function Rl(e,t,n){jl=!0;let r=performance.now()-Ml>100;try{ym(e,()=>{let i=U()||function(e){return e.read(`latest`,()=>{let e=U();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=Ll(f,e,o);if(!p)continue;let[m,h]=p;if(d===`characterData`)r&&V(h)&&dh(f)&&Il(i,f,h)&&Fl(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=xh(r),a=r.parentNode;if(!(a==null||r===s||i!==null||Pl(r,a,e)||e._slotsUsed&&Y(r)&&r.hasAttribute(`data-lexical-slot`)||Zg(r))){if(el){let e=(Y(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];(Pl(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`||Pl(n,i,e)||a.removeChild(n)}}n.takeRecords()}i!==null&&(c&&Oh(i),el&&Jh(e)&&i.insertRawText(l))})}finally{jl=!1}}function zl(e){let t=e._observer;t!==null&&Rl(e,t.takeRecords(),t)}function Bl(e){(function(e){Ml===0&&ng(e).addEventListener(`textInput`,Nl,!0)})(e),e._observer=new MutationObserver((t,n)=>{Rl(e,t,n)})}var Vl=class{key;parse;unparse;isEqual;defaultValue;resetOnCopyNode;constructor(e,t){this.key=e,this.parse=t.parse.bind(t),this.unparse=(t.unparse||Yl).bind(t),this.isEqual=(t.isEqual||Object.is).bind(t),this.defaultValue=this.parse(void 0),this.resetOnCopyNode=t.resetOnCopyNode||!1}};function Hl(e,t){return new Vl(e,t)}function Ul(e){let t=/* @__PURE__ */ new Map,n=/* @__PURE__ */ new Set;for(let{ownNodeConfig:r}of i_(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 Wl=/* @__PURE__ */ new Set([`__proto__`,`constructor`,`prototype`]);var Gl=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 Jl(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(Wl.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=Jl(i)),this.size++),r.set(e,t)}updateFromUnknown(e,t){if(Wl.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 Kl(e){let t=e.getWritable(),n=t.__state?t.__state.getWritable(t):new Gl(t,ql(t));return t.__state=n,n}function ql(e){return e.__state?e.__state.sharedNodeState:th(Lg(),e.getType()).sharedNodeState}function Jl(e){if(e)for(let t in e)return e}function Yl(e){return e}function Xl(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 Zl(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 Ql(e,t){let n=e.__state;return n&&n.node===e?n.getWritable(t):n}function $l(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&&Xl(n,e,t)||t&&Xl(n,t,e)||e&&Zl(n,e,t)||t&&Zl(n,t,e))}(c,l))}function eu(e,t){let n=e.mergeWithSibling(t),r=W()._normalizedNodes;return r.add(e.__key),r.add(t.__key),n}function tu(e){let t,n,r=e;if(r.__text!==``||!r.isSimpleText()||r.isUnmergeable()){for(;(t=r.getPreviousSibling())!==null&&V(t)&&t.isSimpleText()&&!t.isUnmergeable();){if(t.__text!==``){if($l(t,r)){r=eu(t,r);break}break}t.remove()}for(;(n=r.getNextSibling())!==null&&V(n)&&n.isSimpleText()&&!n.isUnmergeable();){if(n.__text!==``){if($l(r,n)){r=eu(r,n);break}break}n.remove()}}else r.remove()}function nu(e){return ru(e.anchor),ru(e.focus),e}function ru(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),V(r)){e.set(r.__key,i?r.getTextContentSize():0,`text`,!0);break}if(!G(r))break;e.set(r.__key,i?r.getChildrenSize():0,`element`,!0)}}let iu=Symbol.for(`@lexical/CachedTextSize`);function au(e,t){return yu.read(()=>{let n=0,r=e;for(let e=0;e<t&&r!==null;e++){let i=vu.get(r);if(i===void 0&&L(345,r),G(i)){let a=bu.get(r);if(a!==void 0&&G(a)&&a.__parent!==i.__parent)n+=i.getTextContentSize();else{let e=xu.get(r),t=e&&e.__lexicalTextContent;typeof t!=`string`&&L(346,i.getType()),n+=t.length}e<t-1&&!i.isInline()&&(n+=2)}else{let e=i[iu];e===void 0&&L(347,i.getType(),r),n+=e}r=i.__next}return n},{editor:R})}function ou(e){G(e)||e[iu]===void 0&&(e[iu]=V(e)?e.__text.length:e.getTextContentSize())}let su,R,cu,z=``,lu=null,uu=null,du=null;function fu(){return{firstTextKey:du,format:lu,style:uu}}function pu(e){e.firstTextKey!==null&&(lu=e.format,uu=e.style,du=e.firstTextKey)}function mu(e){if(du!==null)return;let t=e.__lexicalFirstTextKey;if(t===void 0&&L(348),t===null)return;let n=bu.get(t);V(n)&&(lu=n.getFormat(),uu=n.getStyle(),du=t)}let hu,gu,_u,vu,yu,bu,xu,Su,Cu,wu,Tu=!1,Eu=!1;function Du(e,t){let n=vu.get(e),r=bu.has(e);if(t!==null){let n=Xu(e);n.parentNode===t&&t.removeChild(n)}if(!r){if(R._keyToDOMMap.delete(e),G(n)){let e=s_(n,vu);Ou(e,0,e.length-1,null)}if(n!==void 0){for(let e of Iu(n).values()){let t=Ru(e);Du(e,null),t!==null&&t.remove()}Gh(Cu,cu,hu,n,`destroyed`)}}}function Ou(e,t,n,r){for(let i=t;i<=n;++i){let t=e[i];t!==void 0&&Du(t,r)}}function ku(e,t){e.setProperty(`text-align`,t)}function Au(e,t){let n=su.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 ju(e,t){let n=e.style;t===0?ku(n,``):t===1?ku(n,`left`):t===2?ku(n,`center`):t===3?ku(n,`right`):t===4?ku(n,`justify`):t===5?ku(n,`start`):t===6&&ku(n,`end`)}function Mu(e,t){let n=function(e){let t=e.__dir;if(t!==null)return t;if(Tm(e))return null;let n=e.getParent();return n===null||og(n)&&n.__dir===null?`auto`:null}(t);n===null?e.removeAttribute(`dir`):e.dir=n}function Nu(e){let t=bg().createElement(`div`);return t.setAttribute(`data-lexical-slot`,e),t.style.display=`none`,t}function Pu(e,t,n){t||e.contentEditable===`false`?Qg(n,R):n.removeAttribute(`contenteditable`)}function Fu(e,t,n){let r=z,i=fu();z=``;let a=``,o=K(e);for(let[r,i]of n){let n=Nu(r);Pu(t,o,n),t.appendChild(n),z=``;let s=fu();Bu(i,zg(e,n,R)),pu(s),Lu(e,r,t,n),a+=z}return pu(i),z=r,a}function Iu(e){return u_(e)&&e.__slots!==null?e.__slots:l_}function Lu(e,t,n,r){let i=wu.$getSlotTargetElement(e,t,n,R);i!==null&&(r.parentElement!==i&&i.appendChild(r),r.style.display=``)}function Ru(e){let t=xu.get(e);return t===void 0?null:t.parentElement}function zu(e,t,n){let r=Iu(e),i=Iu(t);for(let[e,t]of r)if(!i.has(e)){let e=Ru(t);Du(t,null),e!==null&&e.remove()}let a=z,o=fu(),s=``,c=null,l=K(t);for(let[e,a]of i){let i=r.get(e),o=i===void 0?null:Ru(i);z=``;let u=fu();if(o===null){o=Nu(e);let r=null;for(let e of n.children)if(!e.hasAttribute(`data-lexical-slot`)){r=e;break}n.insertBefore(o,r),Bu(a,zg(t,o,R))}else i===a?Gu(a,o):(i!==void 0&&Du(i,o),Bu(a,zg(t,o,R)));if(pu(u),Pu(n,l,o),Lu(t,e,n,o),s+=z,o.parentElement===n){let e=c===null?n.firstChild:c.nextSibling;e!==o&&n.insertBefore(o,e),c=o}}return pu(o),z=a,s}function Bu(e,t){let n=bu.get(e);if(n===void 0&&L(60),t!==null){let r=vu.get(e);if(r!==void 0){let i=xu.get(e);if(i!==void 0){let a=d_(r)?r.__slotHost:null,o=d_(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),Gu(e,t.element)}}}let r=wu.$createDOM(n,R);if(function(e,t,n){let r=n._keyToDOMMap;Sh(t,n,e),r.set(e,t)}(e,r,R),V(n)?r.setAttribute(`data-lexical-text`,`true`):K(n)&&(r.setAttribute(`data-lexical-decorator`,`true`),Xg(r,{captureSelection:!0})),G(n)){let e=n.__indent,t=n.__size;Mu(r,n),e!==0&&Au(r,e);let i=Iu(n),a=i.size>0?Fu(n,r,i):``;if(t===0)r.__lexicalTextContent=a,r.__lexicalFirstTextKey=null,z+=a,i.size>0&&(r.__lexicalSlotTextLength=a.length);else{let e=z,o=t-1;if(Vu(s_(n,bu),n,0,o,zg(n,r,R)),a!==``){let t=r.__lexicalTextContent||``;r.__lexicalTextContent=a+t,z=e+a+t}i.size>0&&(r.__lexicalSlotTextLength=a.length)}let o=n.__format;o!==0&&ju(r,o),n.isInline()||Hu(null,n,r)}else{let t=n.getTextContent();if(K(n)){let t=n.decorate(R,su);t!==null&&Ku(e,t),r.contentEditable=`false`;let i=Iu(n);i.size>0&&Fu(n,r,i)}z+=t}return t!==null&&t.insertChild(r),wu.$decorateDOM(n,null,r,R),ou(n),Gh(Cu,cu,hu,n,`created`),r}function Vu(e,t,n,r,i){let a=z,o=fu();z=``,lu=null,uu=null,du=null;let s=n;for(;s<=r;++s){let t=fu();Bu(e[s],i);let n=bu.get(e[s]);n!==null&&V(n)?lu===null&&(lu=n.getFormat(),uu=n.getStyle(),du=n.__key):G(n)&&s<r&&!n.isInline()&&(z+=`
|
|
133
133
|
|
|
134
|
-
`),
|
|
134
|
+
`),pu(t)}let c=R._keyToDOMMap.get(t.__key);c===void 0&&L(349,t.__key),c.__lexicalTextContent=z,c.__lexicalFirstTextKey=du,z=a+z,pu(o)}function Hu(e,t,n){let r=zg(t,n,R),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 Fm(e)?`line-break`:K(e)&&e.isInline()?`decorator`:null}return Iu(e).size>0?null:`empty`}return null}(t,bu);i!==a&&r.setManagedLineBreak(a)}function Uu(e,t,n){var r;lu=null,uu=null,du=null,function(e,t,n){let r=z,i=e.__size,a=t.__size;z=``;let o=n.element,s=R._keyToDOMMap.get(t.__key);s===void 0&&L(351,t.__key);let c=a-i;if(!Tu&&Math.abs(c)<=1&&i>=4&&e.__first===t.__first&&(c!==0||!R._cloneNotNeeded.has(e.__key))){let i=s.__lexicalTextContent,l=Su.get(e.__key);if(!Tu&&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=bu.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=au(a,u),n=a,c=0;for(;n!==null&&c<u;){let e=bu.get(n);if(e===void 0)break;let t=fu();Gu(n,o),V(e)&&lu===null&&(lu=e.getFormat(),uu=e.getStyle(),du=e.__key),pu(t),n=e.__next,c++}let d=``;for(n=a,c=0;n!==null&&c<u;){let e=bu.get(n);if(e===void 0)break;let t;if(G(e)){let r=R._keyToDOMMap.get(n),i=r&&r.__lexicalTextContent;typeof i!=`string`&&L(352,e.getType()),t=i}else t=e.getTextContent();d+=t,c<u-1&&G(e)&&!e.isInline()&&(d+=`
|
|
135
135
|
|
|
136
|
-
`),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,z=r+m,
|
|
136
|
+
`),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,z=r+m,Wu(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=vu.get(l);if(e===void 0)return!1;l=e.__prev}if(l===null)return!1;let u=bu.get(a),d=vu.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=bu.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=vu.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 ee=au(l,c);for(let e of _){let t=fu();if(e.kind===`reconcile`)Gu(e.key,n.element);else if(e.kind===`destroy`)Du(e.key,n.element);else{let t=null;for(let n=e.nextIndex+1;n<o;n++){let e=R._keyToDOMMap.get(f[n]);if(e!==void 0){t=e;break}}Bu(e.key,n.withBefore(t??n.before))}if(e.kind!==`destroy`){let t=bu.get(e.key);t&&V(t)&&lu===null&&(lu=t.getFormat(),uu=t.getStyle(),du=t.__key)}pu(t)}let b=``;for(let e=0;e<o;e++){let t=bu.get(f[e]);if(t===void 0)return!1;let n;if(G(t)){let r=R._keyToDOMMap.get(f[e]),i=r&&r.__lexicalTextContent;typeof i!=`string`&&L(350,t.getType()),n=i}else n=t.getTextContent();b+=n,e<o-1&&G(t)&&!t.isInline()&&(b+=`
|
|
137
137
|
|
|
138
|
-
`)}let
|
|
138
|
+
`)}let te=r.__lexicalSlotTextLength||0,x=te>0?i.slice(te):i;return r.__lexicalTextContent=x.slice(0,x.length-ee)+b,!0}(e,0,n,s,i,a,u,c)){let e=s.__lexicalTextContent;typeof e!=`string`&&L(353),z=r+e,Wu(t,s,l);return}}}if(c===0){let t=e.__first,n=0;for(;t!==null;){let e=bu.get(t);if(e===void 0)break;let r=Tu||_u.has(t)||gu.has(t),i=fu();if(r)Gu(t,o);else{let n,r;if(G(e)){r=xu.get(t);let i=r&&r.__lexicalTextContent;typeof i!=`string`&&L(354,e.getType()),n=i}else n=e.getTextContent();z+=n,r!==void 0&&mu(r)}V(e)?lu===null&&(lu=e.getFormat(),uu=e.getStyle(),du=e.__key):G(e)&&n<a-1&&!e.isInline()&&(z+=`
|
|
139
139
|
|
|
140
|
-
`),
|
|
140
|
+
`),pu(i),t=e.__next,n++}s.__lexicalTextContent=z,s.__lexicalFirstTextKey=du,z=r+z;return}}if(i===1&&a===1){let r=e.__first,i=t.__first;if(r===i)Gu(r,o);else{let e=Xu(r),t=Bu(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}Du(r,null)}let a=bu.get(i);V(a)&&lu===null&&(lu=a.getFormat(),uu=a.getStyle(),du=a.__key)}else{let r=s_(e,vu),s=s_(t,bu);if(r.length!==i&&L(227),s.length!==a&&L(228),i===0)a!==0&&Vu(s,t,0,a-1,n);else if(a===0){if(i!==0){let e=n.after==null&&n.before==null&&Iu(t).size===0&&n.element.__lexicalLineBreak==null;Ou(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=fu();if(e===r)u=qu(Gu(r,a.element)),d++,f++;else{if(l===void 0&&(l=Ju(n,f)),c===void 0)c=Ju(t,d);else if(!c.has(e)){d++,pu(i);continue}if(!l.has(e)){u=qu(Xu(e)),Du(e,a.element),d++,c.delete(e),pu(i);continue}if(c.has(r)){let e=Yh(R,r);e!==u&&a.withBefore(u??a.before).insertChild(e),u=qu(Gu(r,a.element)),d++,f++}else Bu(r,a.withBefore(u??a.before)),f++}let o=bu.get(r);o!==null&&V(o)?lu===null&&(lu=o.getFormat(),uu=o.getStyle(),du=o.__key):G(o)&&f<=s&&!o.isInline()&&(z+=`
|
|
141
141
|
|
|
142
|
-
`),uu(i)}let p=d>o,m=f>s;if(p&&!m){let t=n[s+1],r=t===void 0?null:R.getElementByKey(t);Ru(n,e,f,s,a.withBefore(r??a.before))}else m&&!p&&Tu(t,d,o,a.element)})(t,r,s,i,a,n)}s.__lexicalTextContent=z,s.__lexicalFirstTextKey=cu,z=r+z}(e,t,Ig(t,n,R)),rg(t)||(r=t,ou==null||ou===r.__textFormat||Cu||r.setTextFormat(ou),function(e){su==null||su===e.__textStyle||Cu||e.setTextStyle(su)}(t))}function Vu(e,t,n){let r=t.__lexicalFirstTextKey;if(r!=null){let t=e.__key,i=r;for(;i!==null;){let e=_u.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=_u.get(r);if(V(e))return ou=e.getFormat(),void(su=e.getStyle())}}t.__lexicalFirstTextKey=cu}function Hu(e,t){let n=hu.get(e),r=_u.get(e);n!==void 0&&r!==void 0||L(61);let i=Su||mu.has(e)||pu.has(e),a=Kh(R,e);if(n===r&&!i){let e;if(G(n)){let t=a.__lexicalTextContent;typeof t!=`string`&&L(355,n.getType()),e=t,du(a)}else e=n.getTextContent();return z+=e,a}if(n!==r&&i&&Hh(bu,au,fu,r,`updated`),xu.$updateDOM(r,n,a,R)){let n=Lu(e,null);return t===null&&L(62),t.replaceChild(n,a),wu(e,null),n}if(G(n)){G(r)||L(334,e);let t=r.__indent;(Su||t!==n.__indent)&&Du(a,t);let o=r.__format;(Su||o!==n.__format)&&Ou(a,o);let s=i&&(Nu(r).size>0||Nu(n).size>0)?Iu(n,r,a):``;if(i){let e=z;if(Bu(n,r,a),Sm(r)||r.isInline()||zu(0,r,a),s!==``){let t=a.__lexicalTextContent||``;a.__lexicalTextContent=s+t,z=e+s+t,a.__lexicalSlotTextLength=s.length}else(Nu(r).size>0||Nu(n).size>0)&&(a.__lexicalSlotTextLength=0)}else{let e=a.__lexicalTextContent;typeof e!=`string`&&L(356,n.getType()),z+=e,du(a)}if((Su||r.__dir!==n.__dir||r.__parent!==n.__parent)&&(ku(a,r),Sm(r)&&!Su))for(let e of r.getChildren())G(e)&&ku(Kh(R,e.getKey()),e)}else{let t=r.getTextContent();if(K(r)){let t=r.decorate(R,iu);t!==null&&Uu(e,t),i&&(Nu(r).size>0||Nu(n).size>0)&&Iu(n,r,a)}z+=t}if(!Cu&&Sm(r)){let e=r.getLatest();if(e.__cachedText!==z){let t=e.getWritable();t.__cachedText=z,r=t}}return xu.$decorateDOM(r,n,a,R),ru(r),a}function Uu(e,t){let n=R._pendingDecorators,r=R._decorators;if(n===null){if(r[e]===t)return;n=Sh(R)}n[e]=t}function Wu(e){let t=e.nextSibling;return t!==null&&t===R._blockCursorElement&&(t=t.nextSibling),t}function Gu(e,t){let n=/* @__PURE__ */ new Set;for(let r=t;r<e.length;r++)n.add(e[r]);return n}function Ku(e,t,n,r,i,a){z=``,ou=null,su=null,cu=null,Su=r===2,R=n,iu=n._config,xu=n._config.dom||Um,au=n._nodes,fu=R._listeners.mutation,pu=i,mu=a,hu=e._nodeMap,gu=e,_u=t._nodeMap,Cu=t._readOnly,vu=Tl(n._keyToDOMMap),yu=function(){let e=/* @__PURE__ */ new Map,t=t=>{for(let n of t){let t=_u.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(pu.keys()),t(mu),e}();let o=/* @__PURE__ */ new Map;return bu=o,Hu(`root`,null),R=void 0,au=void 0,pu=void 0,mu=void 0,hu=void 0,gu=void 0,_u=void 0,iu=void 0,vu=void 0,yu=void 0,bu=void 0,xu=Um,o}function qu(e){let t=vu.get(e);return t===void 0&&L(75,e),t}function B(e){return{type:e}}let Ju=/* @__PURE__ */ B(`SELECTION_CHANGE_COMMAND`),Yu=/* @__PURE__ */ B(`CLICK_COMMAND`),Xu=/* @__PURE__ */ B(`BEFORE_INPUT_COMMAND`),Zu=/* @__PURE__ */ B(`INPUT_COMMAND`),Qu=/* @__PURE__ */ B(`COMPOSITION_START_COMMAND`),$u=/* @__PURE__ */ B(`COMPOSITION_END_COMMAND`),ed=/* @__PURE__ */ B(`DELETE_CHARACTER_COMMAND`),td=/* @__PURE__ */ B(`INSERT_LINE_BREAK_COMMAND`),nd=/* @__PURE__ */ B(`INSERT_PARAGRAPH_COMMAND`),rd=/* @__PURE__ */ B(`CONTROLLED_TEXT_INSERTION_COMMAND`),id=/* @__PURE__ */ B(`PASTE_COMMAND`),ad=/* @__PURE__ */ B(`REMOVE_TEXT_COMMAND`),od=/* @__PURE__ */ B(`DELETE_WORD_COMMAND`),sd=/* @__PURE__ */ B(`DELETE_LINE_COMMAND`),cd=/* @__PURE__ */ B(`FORMAT_TEXT_COMMAND`),ld=/* @__PURE__ */ B(`UNDO_COMMAND`),ud=/* @__PURE__ */ B(`REDO_COMMAND`),dd=/* @__PURE__ */ B(`KEYDOWN_COMMAND`),fd=/* @__PURE__ */ B(`KEY_ARROW_RIGHT_COMMAND`),pd=/* @__PURE__ */ B(`MOVE_TO_END`),md=/* @__PURE__ */ B(`KEY_ARROW_LEFT_COMMAND`),hd=/* @__PURE__ */ B(`MOVE_TO_START`),gd=/* @__PURE__ */ B(`KEY_ARROW_UP_COMMAND`),_d=/* @__PURE__ */ B(`KEY_ARROW_DOWN_COMMAND`),vd=/* @__PURE__ */ B(`KEY_ENTER_COMMAND`),yd=/* @__PURE__ */ B(`KEY_SPACE_COMMAND`),bd=/* @__PURE__ */ B(`KEY_BACKSPACE_COMMAND`),xd=/* @__PURE__ */ B(`KEY_ESCAPE_COMMAND`),Sd=/* @__PURE__ */ B(`KEY_DELETE_COMMAND`),Cd=/* @__PURE__ */ B(`KEY_TAB_COMMAND`),wd=/* @__PURE__ */ B(`DROP_COMMAND`),Td=/* @__PURE__ */ B(`DRAGSTART_COMMAND`),Ed=/* @__PURE__ */ B(`DRAGOVER_COMMAND`),Dd=/* @__PURE__ */ B(`DRAGEND_COMMAND`),Od=/* @__PURE__ */ B(`COPY_COMMAND`),kd=/* @__PURE__ */ B(`CUT_COMMAND`),Ad=/* @__PURE__ */ B(`SELECT_ALL_COMMAND`),jd=/* @__PURE__ */ B(`CLEAR_EDITOR_COMMAND`),Md=/* @__PURE__ */ B(`CLEAR_HISTORY_COMMAND`),Nd=/* @__PURE__ */ B(`CAN_REDO_COMMAND`),Pd=/* @__PURE__ */ B(`CAN_UNDO_COMMAND`),Fd=/* @__PURE__ */ B(`FOCUS_COMMAND`),Id=/* @__PURE__ */ B(`BLUR_COMMAND`),Ld=/* @__PURE__ */ B(`KEY_MODIFIER_COMMAND`);function Rd(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 zd(e,t,n,r){return e.addEventListener(t,n,r),e.removeEventListener.bind(e,t,n,r)}let Bd=Object.freeze({}),Vd=[[`keydown`,function(e,t){let n=t._inputState;n.lastKeyDownTimeStamp=e.timeStamp,n.lastKeyCode=e.key,e.key!==`Backspace`&&Qd(n),!t.isComposing()&&J(t,dd,e)}],[`pointerdown`,function(e,t){let n=Eg(e),r=e.pointerType;Dg(n)&&r!==`touch`&&r!==`pen`&&e.button===0&&gm(t,()=>{Xg(n,t)||(t._inputState.isSelectionChangeFromMouseDown=!0)})}],[`compositionstart`,function(e,t){J(t,Qu,e)}],[`compositionend`,function(e,t){let n=t._inputState;Zc?n.compositionPhase=`ending-firefox`:$c||!tl&&!il?J(t,$u,e):(n.compositionPhase=`ending-safari`,n.compositionEndData=e.data)}],[`input`,function(e,t){e.stopPropagation();let n=t._inputState;Qd(n),gm(t,()=>{ef(e,t)||t.dispatchCommand(Zu,e)},{event:e}),n.unprocessedBeforeInputData=null}],[`click`,function(e,t){gm(t,()=>{let n=U(),r=ug($h(t)),i=Dp();if(r){if(H(n)){let e=n.anchor,t=e.getNode();e.type===`element`&&e.offset===0&&n.isCollapsed()&&!Sm(t)&&wh().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=bg(r,t._rootElement).anchorNode;(Y(n)||ch(n))&&Th(Ep(i,r,t,e))}}if(Zc&&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(Y(t)){let n=t.getBoundingClientRect();if(a<=(n.top+n.bottom)/2){o=e;break}}}r.setBaseAndExtent(n,o,n,o);let s=Ep(i,r,t,e);s===null?r.removeAllRanges():Th(s)}}J(t,Yu,e)})}],[`cut`,Bd],[`copy`,Bd],[`dragstart`,Bd],[`dragover`,Bd],[`dragend`,Bd],[`paste`,Bd],[`focus`,Bd],[`blur`,Bd],[`drop`,Bd]];Qc&&Vd.push([`beforeinput`,(e,t)=>function(e,t){let n=e.inputType;n===`deleteCompositionText`||Zc&&Gh(t)||n!==`insertCompositionText`&&gm(t,()=>{ef(e,t)||J(t,Xu,e)},{event:e})}(e,t)]);let Hd=/* @__PURE__ */ new WeakMap,Ud=/* @__PURE__ */ new WeakMap,Wd=Rd(e=>(e.addEventListener(`selectionchange`,df),()=>e.removeEventListener(`selectionchange`,df)));function Gd(e,t,n,r,i,a){let o=e.anchor,s=e.focus,c=o.getNode(),l=W(),u;if(a!==void 0)u=a;else{let e=ug($h(l));u=e===null?null:bg(e,l._rootElement)}let d=u===null?null:u.anchorNode,f=o.key,p=l.getElementByKey(f),m=n.length;return f!==s.key||!V(c)||(!i&&(!Qc||l._inputState.lastBeforeInputInsertTextTimeStamp<r+50)||c.isDirty()&&m<2||Oh(n))&&o.offset!==s.offset&&!c.isComposing()||sh(c)||c.isDirty()&&m>1||(i||!Qc)&&p!==null&&!c.isComposing()&&d!==Rg(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=oh(t);return n===0?!t.canInsertTextBefore()||!r.canInsertTextBefore()&&!t.isComposing()||i||function(e){let t=e.getPreviousSibling();return(V(t)||G(t)&&t.isInline())&&!t.canInsertTextAfter()}(t):n===t.getTextContentSize()&&(!t.canInsertTextAfter()||!r.canInsertTextAfter()&&!t.isComposing()||i)}(e,c)}function Kd(e,t){return ch(e)&&e.nodeValue!==null&&t!==0&&t!==e.nodeValue.length}function qd(e,t,n){let{anchorNode:r,anchorOffset:i,focusNode:a,focusOffset:o}=bg(e,t._rootElement),s=t._inputState;s.isSelectionChangeFromDOMUpdate&&(s.isSelectionChangeFromDOMUpdate=!1,Kd(r,i)&&Kd(a,o)&&!s.postDeleteSelectionToRestore)||gm(t,()=>{if(!n)return void Th(null);if(!nh(t,r,a))return;let c=U();if(s.postDeleteSelectionToRestore&&H(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(),Th(c))}if(s.postDeleteSelectionToRestore=null,H(c)){let n=c.anchor,l=n.getNode();if(c.isCollapsed()){e.type===`Range`&&r===a&&(c.dirty=!0);let i=$h(t).event,o=i?i.timeStamp:performance.now(),{format:u,style:d,offset:f,key:p,timeStamp:m}=s.collapsedSelectionFormat,h=wh(),g=!1===t.isComposing()&&h.getTextContent()===``;if(o<m+200&&n.offset===f&&n.key===p)Jd(c,u,d);else if(n.type===`text`)V(l)||L(141),Yd(c,l);else if(n.type===`element`&&!g){G(l)||L(259);let e=n.getNode();e.isEmpty()?function(e,t){Jd(e,t.getTextFormat(),t.getTextStyle())}(c,e):Jd(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(V(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}}J(t,Ju)})}function Jd(e,t,n){e.format===t&&e.style===n||(e.format=t,e.style=n,e.dirty=!0)}function Yd(e,t){Jd(e,t.getFormat(),t.getStyle())}function Xd(e){if(!e.getTargetRanges)return null;let t=e.getTargetRanges();return t.length===0?null:t[0]}function Zd(e){let{lastKeyCode:t}=W()._inputState;if(e==null||e.length<=1||t==null)return;let n=t.length===1?t:t===`Enter`?`
|
|
142
|
+
`),pu(i)}let p=d>o,m=f>s;if(p&&!m){let t=n[s+1],r=t===void 0?null:R.getElementByKey(t);Vu(n,e,f,s,a.withBefore(r??a.before))}else m&&!p&&Ou(t,d,o,a.element)})(t,r,s,i,a,n)}s.__lexicalTextContent=z,s.__lexicalFirstTextKey=du,z=r+z}(e,t,zg(t,n,R)),og(t)||(r=t,lu==null||lu===r.__textFormat||Eu||r.setTextFormat(lu),function(e){uu==null||uu===e.__textStyle||Eu||e.setTextStyle(uu)}(t))}function Wu(e,t,n){let r=t.__lexicalFirstTextKey;if(r!=null){let t=e.__key,i=r;for(;i!==null;){let e=bu.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=bu.get(r);if(V(e))return lu=e.getFormat(),void(uu=e.getStyle())}}t.__lexicalFirstTextKey=du}function Gu(e,t){let n=vu.get(e),r=bu.get(e);n!==void 0&&r!==void 0||L(61);let i=Tu||_u.has(e)||gu.has(e),a=Yh(R,e);if(n===r&&!i){let e;if(G(n)){let t=a.__lexicalTextContent;typeof t!=`string`&&L(355,n.getType()),e=t,mu(a)}else e=n.getTextContent();return z+=e,a}if(n!==r&&i&&Gh(Cu,cu,hu,r,`updated`),wu.$updateDOM(r,n,a,R)){let n=Bu(e,null);return t===null&&L(62),t.replaceChild(n,a),Du(e,null),n}if(G(n)){G(r)||L(334,e);let t=r.__indent;(Tu||t!==n.__indent)&&Au(a,t);let o=r.__format;(Tu||o!==n.__format)&&ju(a,o);let s=i&&(Iu(r).size>0||Iu(n).size>0)?zu(n,r,a):``;if(i){let e=z;if(Uu(n,r,a),Tm(r)||r.isInline()||Hu(0,r,a),s!==``){let t=a.__lexicalTextContent||``;a.__lexicalTextContent=s+t,z=e+s+t,a.__lexicalSlotTextLength=s.length}else(Iu(r).size>0||Iu(n).size>0)&&(a.__lexicalSlotTextLength=0)}else{let e=a.__lexicalTextContent;typeof e!=`string`&&L(356,n.getType()),z+=e,mu(a)}if((Tu||r.__dir!==n.__dir||r.__parent!==n.__parent)&&(Mu(a,r),Tm(r)&&!Tu))for(let e of r.getChildren())G(e)&&Mu(Yh(R,e.getKey()),e)}else{let t=r.getTextContent();if(K(r)){let t=r.decorate(R,su);t!==null&&Ku(e,t),i&&(Iu(r).size>0||Iu(n).size>0)&&zu(n,r,a)}z+=t}if(!Eu&&Tm(r)){let e=r.getLatest();if(e.__cachedText!==z){let t=e.getWritable();t.__cachedText=z,r=t}}return wu.$decorateDOM(r,n,a,R),ou(r),a}function Ku(e,t){let n=R._pendingDecorators,r=R._decorators;if(n===null){if(r[e]===t)return;n=Th(R)}n[e]=t}function qu(e){let t=e.nextSibling;return t!==null&&t===R._blockCursorElement&&(t=t.nextSibling),t}function Ju(e,t){let n=/* @__PURE__ */ new Set;for(let r=t;r<e.length;r++)n.add(e[r]);return n}function Yu(e,t,n,r,i,a){z=``,lu=null,uu=null,du=null,Tu=r===2,R=n,su=n._config,wu=n._config.dom||Km,cu=n._nodes,hu=R._listeners.mutation,gu=i,_u=a,vu=e._nodeMap,yu=e,bu=t._nodeMap,Eu=t._readOnly,xu=Ol(n._keyToDOMMap),Su=function(){let e=/* @__PURE__ */ new Map,t=t=>{for(let n of t){let t=bu.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(gu.keys()),t(_u),e}();let o=/* @__PURE__ */ new Map;return Cu=o,Gu(`root`,null),R=void 0,cu=void 0,gu=void 0,_u=void 0,vu=void 0,yu=void 0,bu=void 0,su=void 0,xu=void 0,Su=void 0,Cu=void 0,wu=Km,o}function Xu(e){let t=xu.get(e);return t===void 0&&L(75,e),t}function B(e){return{type:e}}let Zu=/* @__PURE__ */ B(`SELECTION_CHANGE_COMMAND`),Qu=/* @__PURE__ */ B(`CLICK_COMMAND`),$u=/* @__PURE__ */ B(`BEFORE_INPUT_COMMAND`),ed=/* @__PURE__ */ B(`INPUT_COMMAND`),td=/* @__PURE__ */ B(`COMPOSITION_START_COMMAND`),nd=/* @__PURE__ */ B(`COMPOSITION_END_COMMAND`),rd=/* @__PURE__ */ B(`DELETE_CHARACTER_COMMAND`),id=/* @__PURE__ */ B(`INSERT_LINE_BREAK_COMMAND`),ad=/* @__PURE__ */ B(`INSERT_PARAGRAPH_COMMAND`),od=/* @__PURE__ */ B(`CONTROLLED_TEXT_INSERTION_COMMAND`),sd=/* @__PURE__ */ B(`PASTE_COMMAND`),cd=/* @__PURE__ */ B(`REMOVE_TEXT_COMMAND`),ld=/* @__PURE__ */ B(`DELETE_WORD_COMMAND`),ud=/* @__PURE__ */ B(`DELETE_LINE_COMMAND`),dd=/* @__PURE__ */ B(`FORMAT_TEXT_COMMAND`),fd=/* @__PURE__ */ B(`UNDO_COMMAND`),pd=/* @__PURE__ */ B(`REDO_COMMAND`),md=/* @__PURE__ */ B(`KEYDOWN_COMMAND`),hd=/* @__PURE__ */ B(`KEY_ARROW_RIGHT_COMMAND`),gd=/* @__PURE__ */ B(`MOVE_TO_END`),_d=/* @__PURE__ */ B(`KEY_ARROW_LEFT_COMMAND`),vd=/* @__PURE__ */ B(`MOVE_TO_START`),yd=/* @__PURE__ */ B(`KEY_ARROW_UP_COMMAND`),bd=/* @__PURE__ */ B(`KEY_ARROW_DOWN_COMMAND`),xd=/* @__PURE__ */ B(`KEY_ENTER_COMMAND`),Sd=/* @__PURE__ */ B(`KEY_SPACE_COMMAND`),Cd=/* @__PURE__ */ B(`KEY_BACKSPACE_COMMAND`),wd=/* @__PURE__ */ B(`KEY_ESCAPE_COMMAND`),Td=/* @__PURE__ */ B(`KEY_DELETE_COMMAND`),Ed=/* @__PURE__ */ B(`KEY_TAB_COMMAND`),Dd=/* @__PURE__ */ B(`DROP_COMMAND`),Od=/* @__PURE__ */ B(`DRAGSTART_COMMAND`),kd=/* @__PURE__ */ B(`DRAGOVER_COMMAND`),Ad=/* @__PURE__ */ B(`DRAGEND_COMMAND`),jd=/* @__PURE__ */ B(`COPY_COMMAND`),Md=/* @__PURE__ */ B(`CUT_COMMAND`),Nd=/* @__PURE__ */ B(`SELECT_ALL_COMMAND`),Pd=/* @__PURE__ */ B(`CLEAR_EDITOR_COMMAND`),Fd=/* @__PURE__ */ B(`CLEAR_HISTORY_COMMAND`),Id=/* @__PURE__ */ B(`CAN_REDO_COMMAND`),Ld=/* @__PURE__ */ B(`CAN_UNDO_COMMAND`),Rd=/* @__PURE__ */ B(`FOCUS_COMMAND`),zd=/* @__PURE__ */ B(`BLUR_COMMAND`),Bd=/* @__PURE__ */ B(`KEY_MODIFIER_COMMAND`);function Vd(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 Hd(e,t,n,r){return e.addEventListener(t,n,r),e.removeEventListener.bind(e,t,n,r)}let Ud=Object.freeze({}),Wd=[[`keydown`,function(e,t){let n=t._inputState;n.lastKeyDownTimeStamp=e.timeStamp,n.lastKeyCode=e.key,e.key!==`Backspace`&&tf(n),!t.isComposing()&&J(t,md,e)}],[`pointerdown`,function(e,t){let n=kg(e),r=e.pointerType;Ag(n)&&r!==`touch`&&r!==`pen`&&e.button===0&&ym(t,()=>{$g(n,t)||(t._inputState.isSelectionChangeFromMouseDown=!0)})}],[`compositionstart`,function(e,t){J(t,td,e)}],[`compositionend`,function(e,t){let n=t._inputState;el?n.compositionPhase=`ending-firefox`:nl||!il&&!sl?J(t,nd,e):(n.compositionPhase=`ending-safari`,n.compositionEndData=e.data)}],[`input`,function(e,t){e.stopPropagation();let n=t._inputState;tf(n),ym(t,()=>{rf(e,t)||t.dispatchCommand(ed,e)},{event:e}),n.unprocessedBeforeInputData=null}],[`click`,function(e,t){ym(t,()=>{let n=U(),r=pg(ng(t)),i=Ap();if(r){if(H(n)){let e=n.anchor,t=e.getNode();e.type===`element`&&e.offset===0&&n.isCollapsed()&&!Tm(t)&&Dh().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=Cg(r,t._rootElement).anchorNode;(Y(n)||dh(n))&&Oh(kp(i,r,t,e))}}if(el&&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(Y(t)){let n=t.getBoundingClientRect();if(a<=(n.top+n.bottom)/2){o=e;break}}}r.setBaseAndExtent(n,o,n,o);let s=kp(i,r,t,e);s===null?r.removeAllRanges():Oh(s)}}J(t,Qu,e)})}],[`cut`,Ud],[`copy`,Ud],[`dragstart`,Ud],[`dragover`,Ud],[`dragend`,Ud],[`paste`,Ud],[`focus`,Ud],[`blur`,Ud],[`drop`,Ud]];tl&&Wd.push([`beforeinput`,(e,t)=>function(e,t){let n=e.inputType;n===`deleteCompositionText`||el&&Jh(t)||n!==`insertCompositionText`&&ym(t,()=>{rf(e,t)||J(t,$u,e)},{event:e})}(e,t)]);let Gd=/* @__PURE__ */ new WeakMap,Kd=/* @__PURE__ */ new WeakMap,qd=Vd(e=>(e.addEventListener(`selectionchange`,mf),()=>e.removeEventListener(`selectionchange`,mf)));function Jd(e,t,n,r,i,a){let o=e.anchor,s=e.focus,c=o.getNode(),l=W(),u;if(a!==void 0)u=a;else{let e=pg(ng(l));u=e===null?null:Cg(e,l._rootElement)}let d=u===null?null:u.anchorNode,f=o.key,p=l.getElementByKey(f),m=n.length;return f!==s.key||!V(c)||(!i&&(!tl||l._inputState.lastBeforeInputInsertTextTimeStamp<r+50)||c.isDirty()&&m<2||jh(n))&&o.offset!==s.offset&&!c.isComposing()||uh(c)||c.isDirty()&&m>1||(i||!tl)&&p!==null&&!c.isComposing()&&d!==Vg(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=lh(t);return n===0?!t.canInsertTextBefore()||!r.canInsertTextBefore()&&!t.isComposing()||i||function(e){let t=e.getPreviousSibling();return(V(t)||G(t)&&t.isInline())&&!t.canInsertTextAfter()}(t):n===t.getTextContentSize()&&(!t.canInsertTextAfter()||!r.canInsertTextAfter()&&!t.isComposing()||i)}(e,c)}function Yd(e,t){return dh(e)&&e.nodeValue!==null&&t!==0&&t!==e.nodeValue.length}function Xd(e,t,n){let{anchorNode:r,anchorOffset:i,focusNode:a,focusOffset:o}=Cg(e,t._rootElement),s=t._inputState;s.isSelectionChangeFromDOMUpdate&&(s.isSelectionChangeFromDOMUpdate=!1,Yd(r,i)&&Yd(a,o)&&!s.postDeleteSelectionToRestore)||ym(t,()=>{if(!n)return void Oh(null);if(!ah(t,r,a))return;let c=U();if(s.postDeleteSelectionToRestore&&H(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(),Oh(c))}if(s.postDeleteSelectionToRestore=null,H(c)){let n=c.anchor,l=n.getNode();if(c.isCollapsed()){e.type===`Range`&&r===a&&(c.dirty=!0);let i=ng(t).event,o=i?i.timeStamp:performance.now(),{format:u,style:d,offset:f,key:p,timeStamp:m}=s.collapsedSelectionFormat,h=Dh(),g=!1===t.isComposing()&&h.getTextContent()===``;if(o<m+200&&n.offset===f&&n.key===p)Zd(c,u,d);else if(n.type===`text`)V(l)||L(141),Qd(c,l);else if(n.type===`element`&&!g){G(l)||L(259);let e=n.getNode();e.isEmpty()?function(e,t){Zd(e,t.getTextFormat(),t.getTextStyle())}(c,e):Zd(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(V(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}}J(t,Zu)})}function Zd(e,t,n){e.format===t&&e.style===n||(e.format=t,e.style=n,e.dirty=!0)}function Qd(e,t){Zd(e,t.getFormat(),t.getStyle())}function $d(e){if(!e.getTargetRanges)return null;let t=e.getTargetRanges();return t.length===0?null:t[0]}function ef(e){let{lastKeyCode:t}=W()._inputState;if(e==null||e.length<=1||t==null)return;let n=t.length===1?t:t===`Enter`?`
|
|
143
143
|
`:t===`Tab`?` `:null;if(!n)return;let r=U();if(!H(r)||!r.isCollapsed())return;let i=r.anchor.getNode();if(!V(i))return;let{offset:a}=r.anchor;if(i.getTextContentSize()===a){let e=i.getNextSibling();if(n===`
|
|
144
|
-
`){if(
|
|
145
|
-
`)e.preventDefault(),J(r,
|
|
144
|
+
`){if(Fm(e))e.selectEnd();else if(!e){let e=o_(i,Tp),t=e&&e.getNextSibling();G(t)&&t.selectStart()}}else n===` `?Zf(e)&&e.selectEnd():V(e)&&e.getTextContent()[0]===n&&e.select(1,1)}else i.getTextContent()[a]===n&&i.select(a+1,a+1)}function tf(e){e.isInsertTextAfterHandledSelectionCommand=!1,e.handledSelectionCommandTimeoutId!==null&&(clearTimeout(e.handledSelectionCommandTimeoutId),e.handledSelectionCommandTimeoutId=null)}function nf(e){tf(e),e.isInsertTextAfterHandledSelectionCommand=!0,e.handledSelectionCommandTimeoutId=setTimeout(()=>tf(e),0)}function rf(e,t){let n=kg(e);if(Y(n)&&$g(n,t))return!0;let r=t.getRootElement();if(r===null)return!1;let i=Og(r.ownerDocument);return i!==null&&r.contains(i)&&$g(i,t)}function af(e){let t=e.inputType,n=$d(e),r=W(),i=r._inputState,a=U();if(t===`insertText`&&e.data&&i.isInsertTextAfterHandledSelectionCommand){if(tf(i),e.preventDefault(),H(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=Ap();if(!H(e))return!0;Oh(e.clone())}if(H(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(vh(null),i.lastKeyDownTimeStamp=0,setTimeout(()=>{ym(r,()=>{vh(null)})},30),H(a)){let e=a.anchor.getNode();e.markDirty(),V(e)||L(142),Qd(a,e)}}else{if(vh(null),nl&&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=ol&&t&&!l&&c;if(u&&a.isCollapsed()&&(u=!K(qh(a.anchor,!0))),!u){J(r,rd,!0);let e=U();ol&&H(e)&&e.isCollapsed()&&(i.postDeleteSelectionToRestore=e,setTimeout(()=>i.postDeleteSelectionToRestore=null))}}return!0}}if(!H(a))return!0;let o=e.data;i.unprocessedBeforeInputData!==null&&Fh(!1,r,i.unprocessedBeforeInputData),a.dirty&&i.unprocessedBeforeInputData===null||!a.isCollapsed()||Tm(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===`
|
|
145
|
+
`)e.preventDefault(),J(r,id,!1);else if(o===`
|
|
146
146
|
|
|
147
|
-
`)e.preventDefault(),J(r,
|
|
148
|
-
`){let t=U();if(H(t)||ip(t)){if(H(t)){let e=t.focus;t.anchor.set(e.key,e.offset,e.type)}return J(e,vd,null),of(n),!1}}let r=_h(n);if(r!==null&&V(r)&&sh(r)){r.markDirty();let e=U(),i=r.getTextContentSize(),a=H(e)&&e.anchor.key===n?e.anchor.offset:i;return r.select(a,a).insertText(t),!0}}return Mh(!0,e,t),of(n),!1}function cf(e){let t=W(),n=t._inputState;if(e.key==null)return!0;if(n.compositionPhase===`ending-safari`){let r=zh(e);if(r&&gm(t,()=>{sf(t,n.compositionEndData)}),n.compositionPhase=`idle`,n.compositionEndData=``,r)return!0}if(function(e){return q(e,`ArrowRight`,{shiftKey:`any`})}(e))J(t,fd,e);else if(function(e){return q(e,`ArrowRight`,{...Lh,shiftKey:`any`})}(e))J(t,pd,e);else if(function(e){return q(e,`ArrowLeft`,{shiftKey:`any`})}(e))J(t,md,e);else if(function(e){return q(e,`ArrowLeft`,{...Lh,shiftKey:`any`})}(e))J(t,hd,e);else if(function(e){return q(e,`ArrowUp`,{altKey:`any`,shiftKey:`any`})}(e))J(t,gd,e);else if(function(e){return q(e,`ArrowDown`,{altKey:`any`,shiftKey:`any`})}(e))J(t,_d,e);else if(function(e){return q(e,`Enter`,{altKey:`any`,ctrlKey:`any`,metaKey:`any`,shiftKey:!0})}(e))n.isInsertLineBreak=!0,J(t,vd,e);else if(function(e){return e.key===` `}(e))J(t,yd,e);else if(function(e){return Xc&&q(e,`o`,{ctrlKey:!0})}(e))e.preventDefault(),n.isInsertLineBreak=!0,J(t,td,!0);else if(function(e){return q(e,`Enter`,{altKey:`any`,ctrlKey:`any`,metaKey:`any`})}(e))n.isInsertLineBreak=!1,J(t,vd,e);else if(function(e){return q(e,`Backspace`,{shiftKey:`any`})||Xc&&q(e,`h`,{ctrlKey:!0})}(e))zh(e)?J(t,bd,e)&&$d(n):(e.preventDefault(),J(t,ed,!0));else if(function(e){return e.key===`Escape`}(e))J(t,xd,e);else if(function(e){return q(e,`Delete`,{})||Xc&&q(e,`d`,{ctrlKey:!0})}(e))(function(e){return e.key===`Delete`})(e)?J(t,Sd,e):(e.preventDefault(),J(t,ed,!1));else if(function(e){return q(e,`Backspace`,Rh)}(e))e.preventDefault(),J(t,od,!0);else if(function(e){return q(e,`Delete`,Rh)}(e))e.preventDefault(),J(t,od,!1);else if(function(e){return Xc&&q(e,`Backspace`,{metaKey:!0})}(e))e.preventDefault(),J(t,sd,!0);else if(function(e){return Xc&&(q(e,`Delete`,{metaKey:!0})||q(e,`k`,{ctrlKey:!0}))}(e))e.preventDefault(),J(t,sd,!1);else if(function(e){return q(e,`b`,Lh)}(e))e.preventDefault(),J(t,cd,`bold`);else if(function(e){return q(e,`u`,Lh)}(e))e.preventDefault(),J(t,cd,`underline`);else if(function(e){return q(e,`i`,Lh)}(e))e.preventDefault(),J(t,cd,`italic`);else if(function(e){return q(e,`Tab`,{shiftKey:`any`})}(e))J(t,Cd,e);else if(function(e){return q(e,`z`,Lh)}(e))e.preventDefault(),J(t,ld);else if(function(e){return Xc?q(e,`z`,{metaKey:!0,shiftKey:!0}):q(e,`y`,{ctrlKey:!0})||q(e,`z`,{ctrlKey:!0,shiftKey:!0})}(e))e.preventDefault(),J(t,ud);else{let r=t._editorState._selection;(function(e){return q(e,`a`,Lh)})(e)?(e.preventDefault(),J(t,Ad,e)&&$d(n)):r===null||H(r)||(function(e){return q(e,`c`,Lh)}(e)?(e.preventDefault(),J(t,Od,e)):function(e){return q(e,`x`,Lh)}(e)&&(e.preventDefault(),J(t,kd,e)))}return function(e){return e.ctrlKey||e.shiftKey||e.altKey||e.metaKey}(e)&&t.dispatchCommand(Ld,e),!0}function lf(e){let t=e.__lexicalEventHandles;return t===void 0&&(t=[],e.__lexicalEventHandles=t),t}let uf=/* @__PURE__ */ new Map;function df(e){let t=dg(e.target);if(t===null)return;let n=Jh(e.target),r=null,i=null,a=n===null?void 0:Ud.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&&fg(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=bg(t,e).anchorNode;if(s!==null&&ih(s)===o){if(fg(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||Y(e)&&e.shadowRoot!==null||(r=ih(e),r!==null&&(i=e))}}if(r===null){let e=Tg(n);r=e===null?null:ih(e)}}if(r===null)return;if(r._inputState.isSelectionChangeFromMouseDown){if(a!==void 0)for(let e of a.editors)e._inputState.isSelectionChangeFromMouseDown=!1;gm(r,()=>{let n=Dp(),a=i??bg(t,r._rootElement).anchorNode;(Y(a)||ch(a))&&Th(Ep(n,t,r,e))})}let o=kh(r),s=o[o.length-1],c=s._key,l=uf.get(c),u=l||s;u!==r&&qd(t,u,!1),qd(t,r,!0),r===s?l&&uf.delete(c):uf.set(c,r)}function ff(e){e._lexicalHandled=!0}function pf(e){return!0===e._lexicalHandled}function mf(e){let t=Hd.get(e);if(t===void 0)return;let n=Ud.get(t);if(n===void 0)return;Hd.delete(e);let r=ah(e);rh(r)?(function(e){if(e._parentEditor!==null){let t=kh(e),n=t[t.length-1]._key;uf.get(n)===e&&uf.delete(n)}else uf.delete(e._key)}(r),n.editors.delete(r),n.hasShadowEditor=void 0,e.__lexicalEditor=null):r&&L(198);let i=lf(e);for(let e=0;e<i.length;e++)i[e]();e.__lexicalEventHandles=[]}function hf(e,t,n){Qp();let r=e.__key,i=e.getParent();if(i===null)return void(l_(e)!==null&&L(367,r,String(l_(e))));let a=function(e){let t=U();if(!H(t)||!G(e))return t;let{anchor:n,focus:r}=t,i=n.getNode(),a=r.getNode();return Zh(i,e)&&n.set(e.__key,0,`element`),Zh(a,e)&&r.set(e.__key,0,`element`),t}(e),o=!1;if(H(a)&&t){let t=a.anchor,n=a.focus;t.key===r&&(Ap(t,e,i,e.getPreviousSibling(),e.getNextSibling()),o=!0),n.key===r&&(Ap(n,e,i,e.getPreviousSibling(),e.getNextSibling()),o=!0)}else ip(a)&&t&&e.isSelected()&&e.selectPrevious();if(H(a)&&t&&!o){let t=e.getIndexWithinParent();ph(e),Op(a,i,t,-1)}else ph(e);n||rg(i)||i.canBeEmpty()||!i.isEmpty()||hf(i,t),t&&a&&Sm(i)&&i.isEmpty()&&i.selectEnd()}let gf=Symbol.for(`ephemeral`);function _f(e){return e[gf]||!1}let vf={configurable:!0,enumerable:!1,value:void 0,writable:!0};var yf=class{__type;__key;__parent;__prev;__next;__state;[tu];static getType(){let{ownNodeType:e}=e_(this);return e===void 0&&L(64,this.name),e}static clone(e){L(65,this.name)}$config(){return{}}config(e,t){let n=t.extends||a_(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",vf),Object.defineProperty(this,tu,vf),fh(this,e)}getType(){return this.__type}isInline(){L(137,this.constructor.name)}isAttached(){let e=this.__key;for(;e!==null;){if(e===`root`)return!0;let t=_h(e);if(t===null)break;e=t.__parent===null?l_(t):t.__parent}return!1}isSelected(e){let t=e||U();if(t==null)return!1;let n=t.getNodes().some(e=>e.__key===this.__key);if(V(this))return n;if(H(t)&&t.anchor.type===`element`&&t.focus.type===`element`){if(t.isCollapsed())return!1;let e=this.getParent();if(K(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:_h(e)}getParentOrThrow(){let e=this.getParent();return e===null&&L(66,this.__key),e}getTopLevelElement(){let e=this;for(;e!==null;){let t=e.getParent();if(rg(t)||l_(e)!==null)return G(e)||e===this&&K(e)||L(194),e;e=t}return null}getTopLevelElementOrThrow(){let e=this.getTopLevelElement();return e===null&&L(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:_h(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:_h(e)}getNextSiblings(){let e=[],t=this.getNextSibling();for(;t!==null;)e.push(t),t=t.getNextSibling();return e}getCommonAncestor(e){let t=G(this)?this:this.getParent(),n=G(e)?e:e.getParent(),r=t&&n?av(t,n):null;return r?r.commonAncestor:null}is(e){return e!=null&&this.__key===e.__key}isBefore(e){let t=av(this,e);return t!==null&&(t.type===`descendant`||(t.type===`branch`?nv(t)===-1:(t.type!==`same`&&t.type!==`ancestor`&&L(279),!1)))}isParentOf(e){return Zh(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=G(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&&L(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=W()._dirtyLeaves;return e!==null&&e.has(this.__key)}getLatest(){if(_f(this))return this;let e=_h(this.__key);return e===null&&L(113),e}getWritable(){if(_f(this))return this;Qp();let e=em(),t=W(),n=e._nodeMap,r=this.__key,i=this.getLatest(),a=t._cloneNotNeeded,o=U();if(o!==null&&o.setCachedNodes(null),a.has(r))return mh(i),i;let s=Hg(i);return a.add(r),mh(s),n.set(r,s),s}getTextContent(){return S_(this)}getTextContentSize(){return this.getTextContent().length}createDOM(e,t){L(70)}updateDOM(e,t,n){L(71)}getDOMSlot(e){return new vl(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){L(18,this.name)}updateFromJSON(e){return function(e,t){let n=e.getWritable(),r=t.$,i=r;for(let e of Wl(n).flatKeys)e in t&&(i!==void 0&&i!==r||(i={...r}),i[e]=t[e]);return(n.__state||i)&&Ul(e).updateFromJSON(i),n}(this,e)}static transform(){return null}remove(e){hf(this,!0,e)}replace(e,t){Qp();let n=U();n!==null&&(n=n.clone()),og(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();ph(o),l!==null&&H(n)&&Op(n,l,u,-1);let d=r.getPreviousSibling(),f=r.getNextSibling(),p=r.__prev,m=r.__next,h=r.__parent;hf(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&&(G(this)&&G(o)||L(139),g=o.getChildrenSize(),o.splice(g,0,this.getChildren()));let _=m_(this);if(_.length>0){s_(this)&&s_(o)||L(368,this.__key,o.__key);for(let e of _){let t=h_(this,e);t!==null&&(E_(this,e),T_(o,e,t))}}if(H(n)){Th(n);let e=n.anchor,r=n.focus;e.key===i&&(t&&e.type===`element`?e.set(o.__key,g+e.offset,`element`):Qf(e,o)),r.key===i&&(t&&r.type===`element`?r.set(o.__key,g+r.offset,`element`):Qf(r,o))}return gh()===i&&hh(a),o}insertAfter(e,t=!0){Qp(),og(this,e);let n=this.getWritable(),r=e.getWritable();this.getParentOrThrow();let i=r.getParent(),a=U(),o=!1,s=!1;if(i!==null){let n=e.getIndexWithinParent();if(H(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}ph(r),t&&H(a)&&Op(a,i,n,-1)}else ph(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&&H(a)){let e=this.getIndexWithinParent();Op(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){Qp(),og(this,e);let n=this.getWritable(),r=e.getWritable();this.getParentOrThrow();let i=r.__key,a=U(),o=r.getParent(),s=o===null?-1:r.getIndexWithinParent();ph(r),o!==null&&t&&H(a)&&Op(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&&H(a)&&Op(a,this.getParentOrThrow(),d),e}isParentRequired(){return!1}createParentElementNode(){return Rm()}selectStart(){return this.selectPrevious()}selectEnd(){return this.selectNext(0,0)}selectPrevious(e,t){Qp();let n=u_(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(G(r))return r.select();if(!V(r)){let e=r.getIndexWithinParent()+1;return i.select(e,e)}return r.select(e,t)}selectNext(e,t){Qp();let n=u_(this);if(n!==null)return n.selectNext(e,t);let r=this.getNextSibling(),i=this.getParentOrThrow();if(r===null)return i.select();if(G(r))return r.select(0,0);if(!V(r)){let e=r.getIndexWithinParent();return i.select(e,e)}return r.select(e,t)}markDirty(){this.getWritable()}reconcileObservedMutation(e,t){this.markDirty()}};function bf(e){return e instanceof yf}let xf=`history-merge`,Sf=`paste`,Cf=`skip-selection-focus`,wf=`composition-end`;function Tf(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 Ef(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 Df(e,t,n=``){if(t===n)return;let r=Tf(n),i=Tf(t);for(let t in i)delete r[t],Ef(e,t,i[t]);for(let t in r)e.removeProperty(t)}function Of(e,t){return 16&t?`code`:t&128?`mark`:32&t?`sub`:64&t?`sup`:null}function kf(e,t){return 1&t?`strong`:2&t?`em`:`span`}function Af(e,t,n,r,i){let a=r.classList,o=Vh(i,`base`);o!==void 0&&a.add(...o),o=Vh(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 ll){let r=ll[e];if(o=Vh(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 jf(e,t,n){let r=n.isComposing(),i=e+(r?al:``),a=Pg(),o=Fg(a).$getDOMSlot(n,t,a),s=o.getFirstChild();if(s===null||s.nodeType!==Node.TEXT_NODE)return void o.insertChild(_g().createTextNode(i));let c=s,l=c.nodeValue;if(l!==i){if(r||Zc){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 Mf(e,t,n,r,i,a){jf(i,e,t);let o=a.theme.text;o!==void 0&&Af(0,0,r,e,o)}function Nf(e,t){let n=_g().createElement(t);return n.appendChild(e),n}function Pf(e){return e!=null&&!0===e.__isInlineFormattable}var Ff=class extends yf{__text;__format;__style;__mode;__detail;get __isInlineFormattable(){return!0}$config(){return this.config(`text`,{importDOM:{"#text":()=>({conversion:Bf,priority:0}),b:()=>({conversion:Lf,priority:0}),code:()=>({conversion:Uf,priority:0}),em:()=>({conversion:Uf,priority:0}),i:()=>({conversion:Uf,priority:0}),mark:()=>({conversion:Uf,priority:0}),s:()=>({conversion:Uf,priority:0}),span:()=>({conversion:If,priority:0}),strong:()=>({conversion:Uf,priority:0}),sub:()=>({conversion:Uf,priority:0}),sup:()=>({conversion:Uf,priority:0}),u:()=>({conversion:Uf,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 ml[e.__mode]}getStyle(){return this.getLatest().__style}isToken(){return this.getLatest().__mode===1}isComposing(){return this.__key===gh()}isSegmented(){return this.getLatest().__mode===2}isDirectionless(){return!!(1&this.getLatest().__detail)}isUnmergeable(){return!!(2&this.getLatest().__detail)}hasFormat(e){let t=ll[e];return(this.getFormat()&t)!==0}isSimpleText(){return this.__type===`text`&&this.__mode===0}getTextContent(){return this.getLatest().__text}getFormatFlags(e,t){return dh(this.getLatest().__format,e,t)}canHaveFormat(){return!0}isInline(){return!0}createDOM(e,t){let n=this.__format,r=Of(0,n),i=kf(0,n),a=r===null?i:r,o=_g().createElement(a),s=o;this.hasFormat(`code`)&&o.setAttribute(`spellcheck`,`false`),r!==null&&(s=_g().createElement(i),o.appendChild(s)),Mf(s,this,0,n,this.__text,e);let c=this.__style;return c!==``&&Df(o.style,c),o}updateDOM(e,t,n){let r=this.__text,i=e.__format,a=this.__format,o=Of(0,i),s=Of(0,a),c=kf(0,i),l=kf(0,a);if((o===null?c:o)!==(s===null?l:s))return!0;if(o===s&&c!==l){let e=t.firstChild;e??L(48);let i=_g().createElement(l);return Mf(i,this,0,a,r,n),t.replaceChild(i,e),!1}let u=t;s!==null&&o!==null&&(u=t.firstChild,u??L(49)),jf(r,u,this);let d=n.theme.text;d!==void 0&&i!==a&&Af(0,i,a,u,d);let f=e.__style,p=this.__style;return f!==p&&Df(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 Y(t)||L(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=Nf(t,`b`)),this.hasFormat(`italic`)&&(t=Nf(t,`i`)),this.hasFormat(`strikethrough`)&&(t=Nf(t,`s`)),this.hasFormat(`underline`)&&(t=Nf(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`?ll[e]:e,t}setDetail(e){let t=this.getWritable();return t.__detail=typeof e==`string`?ul[e]:e,t}setStyle(e){let t=this.getWritable();return t.__style=e,t}toggleFormat(e){let t=dh(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=pl[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){Qp();let n=e,r=t,i=U(),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(!H(i))return Cp(o,n,o,r,`text`,`text`);{let e=gh();e!==i.anchor.key&&e!==i.focus.key||hh(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=U();if(r&&H(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){Qp();let t=this.getLatest(),n=t.getTextContent();if(n===``)return[];let r=t.__key,i=gh(),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=U();if(H(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=Wf(l),d.__format=f,d.__style=p,d.__detail=m,d.__state=Yl(t,d),h=!0):d=t.setTextContent(l);let y=[d];for(let e=1;e<c;e++){let n=Wf(o[e]);n.__format=f,n.__style=p,n.__detail=m,n.__state=Yl(t,n);let a=n.__key;i===r&&hh(a),y.push(n)}let ee=g?g.offset:null,b=_?_.offset:null,x=0;for(let e of y){if(!g&&!_)break;let t=x+e.getTextContentSize();if(g!==null&&ee!==null&&ee<=t&&ee>=x&&(g.set(e.getKey(),ee-x,`text`),ee<t&&(g=null)),_!==null&&b!==null&&b<=t&&b>=x){_.set(e.getKey(),b-x,`text`);break}x=t}if(u!==null){(function(e){let t=e.getPreviousSibling(),n=e.getNextSibling();t!==null&&mh(t),n!==null&&mh(n)})(this);let e=u.getWritable(),t=this.getIndexWithinParent();h?(e.splice(t,0,y),this.remove()):e.splice(t,1,y),H(v)&&Op(v,u,t,c-1)}return y}mergeWithSibling(e){let t=e===this.getPreviousSibling();t||e===this.getNextSibling()||L(50);let n=this.__key,r=e.__key,i=this.__text,a=i.length;gh()===r&&hh(n);let o=U();if(H(o)){let i=o.anchor,s=o.focus;i!==null&&i.key===r&&jp(i,t,n,e,a),s!==null&&s.key===r&&jp(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 If(e){return{forChild:Gf(e.style),node:null}}function Lf(e){let t=e,n=t.style.fontWeight===`normal`;return{forChild:Gf(t.style,n?void 0:`bold`),node:null}}let Rf=/* @__PURE__ */ new WeakMap;function zf(e){if(!Y(e))return!1;if(e.nodeName===`PRE`)return!0;let t=e.style.whiteSpace;return typeof t==`string`&&t.startsWith(`pre`)}function Bf(e){let t=e;e.parentElement===null&&L(129);let n=t.textContent||``;if(function(e){let t,n=e.parentNode,r=[e];for(;n!==null&&(t=Rf.get(n))===void 0&&!zf(n);)r.push(n),n=n.parentNode;let i=t===void 0?n:t;for(let e=0;e<r.length;e++)Rf.set(r[e],i);return i}(t)!==null)return{node:Ip(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=Vf(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=Vf(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:Wf(n)}}function Vf(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,Y(n)){let e=n.style.display;if(e===``&&!Ag(n)||e!==``&&!e.startsWith(`inline`))return null}let r=n;for(;(r=t?n.firstChild:n.lastChild)!==null;)n=r;if(ch(n))return n;if(n.nodeName===`BR`)return null}}let Hf={code:`code`,em:`italic`,i:`italic`,mark:`highlight`,s:`strikethrough`,strong:`bold`,sub:`subscript`,sup:`superscript`,u:`underline`};function Uf(e){let t=Hf[e.nodeName.toLowerCase()];return t===void 0?{node:null}:{forChild:Gf(e.style,t),node:null}}function Wf(e=``){return ag(new Ff(e))}function V(e){return e instanceof Ff}function Gf(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=>((V(e)||Pf(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 Kf=class extends Ff{$config(){return this.config(`tab`,{extends:Ff})}constructor(e=void 0){super(` `,e),this.__detail=2}createDOM(e){let t=super.createDOM(e),n=Vh(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||L(286),this}setDetail(e){return e!==2&&L(127),this}setMode(e){return e!==`normal`&&L(128),this}canInsertTextBefore(){return!1}canInsertTextAfter(){return!1}};function qf(){return ag(new Kf)}function Jf(e){return e instanceof Kf}var Yf=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:tv(hv(ov(this,`next`)),hv(ov(e,`next`)))<0}getNode(){let e=_h(this.key);return e===null&&L(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,Zp()||(gh()===a&&hh(e),i!==null&&(i.setCachedNodes(null),H(i)&&(i._cachedIsBackward=null),i.dirty=!0)))}};function Xf(e,t,n){return new Yf(e,t,n)}function Zf(e,t){let n=t.__key,r=e.offset,i=`element`;if(V(t)){i=`text`;let e=t.getTextContentSize();r>e&&(r=e)}else if(!G(t)){let e=t.getNextSibling();if(V(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 Qf(e,t){if(G(t)){let n=t.getLastDescendant();G(n)||V(n)?Zf(e,n):Zf(e,t)}else Zf(e,t)}function $f(e,t,n,r){let i=e.getNode(),a=i.getChildAtIndex(e.offset),o=Wf();if(o.setFormat(n),o.setStyle(r),zm(a))a.splice(0,0,[o]);else if(a!==null){let e=rg(i)?Rm().append(o):o;a.insertBefore(e)}else if(rg(i)){let e=i.getLastChild();G(e)&&!e.isInline()&&e.isEmpty()?e.append(o):i.append(Rm().append(o))}else i.append(o);e.is(t)&&t.set(o.__key,0,`text`),e.set(o.__key,0,`text`)}function ep(e,t,n,r){let i=e.anchor.getNode();V(i)||L(398);let a=e.anchor.offset,o=Wf(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 tp=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(!ip(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=>l_(e)===null),n=t.length;if(n===0)return;let r=t[n-1],i;if(V(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=_h(e);t!==null&&n.push(t)}return Zp()||(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=>l_(e)===null);if((U()||Dp())===this&&e[0]){let t=H_(e[0],`next`);cv($_(t,t))}for(let t of e)t.remove();np()}};function np(){let e=wh();if(e.isEmpty()){let t=Rm();e.append(t),t.select()}}function H(e){return e instanceof rp}var rp=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!!H(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(R_(n)){let{origin:e}=n;t.length===0?i.add(e):(a.add(e),t.push(e))}else{let{origin:e}=n;G(e)&&a.has(e)||t.push(e)}if(r&&t.push(r.caret.origin),L_(e.focus)&&G(e.focus.origin)&&e.focus.getNodeAtCaret()===null)for(let n=K_(e.focus.origin,`previous`);R_(n)&&i.has(n.origin)&&!n.origin.isEmpty()&&n.origin.is(t[t.length-1]);n=J_(n))i.delete(n.origin),t.pop();for(;t.length>1;){let e=t[t.length-1];if(!G(e)||a.has(e)||e.isEmpty()||i.has(e))break;t.pop()}if(t.length===0&&e.isCollapsed()){let n=hv(e.anchor),r=hv(e.anchor.getFlipped()),i=e=>I_(e)?e.origin:e.getNodeAtCaret(),a=i(n)||i(r)||(e.anchor.getNodeAtCaret()?n.origin:r.origin);t.push(a)}return t}(vv(uv(this),`next`));return Zp()||(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]=cp(this),c=``,l=!0;for(let u=0;u<e.length;u++){let d=e[u];if(G(d)&&!d.isInline()){l||(c+=`
|
|
149
|
-
`);let e=``;for(let t of m_(d)){let n=h_(d,t);n!==null&&(e+=n.getTextContent())}e===``?l=!d.isEmpty():(c+=e,l=!1)}else if(l=!1,V(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!K(d)&&!Mm(d)||d===n&&this.isCollapsed()||(c+=d.getTextContent())}return c}applyDOMRange(e){let t=W(),n=t.getEditorState()._selection,r=xp(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),$l(this)}clone(){let t=this.anchor,n=this.focus;return new e(Xf(t.key,t.offset,t.type),Xf(n.key,n.offset,n.type),this.format,this.style)}toggleFormat(e){this.format=dh(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=ll[e];return(this.format&t)!==0}insertRawText(e){this.insertNodes(Ip(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(V(r)&&(t=r.getFormat(),n=r.getStyle()),this.removeText(),this.format=t,this.style=n,e===``)return;if(gh()===null)return this.anchor.type===`element`&&$f(this.anchor,this.focus,t,n),void ep(this,e,t,n)}this.anchor.type===`element`&&$f(this.anchor,this.focus,t,n);let r=this.anchor.getNode();V(r)||L(398);let i=this.anchor.offset,a=r.getParentOrThrow(),o=r.getTextContentSize();if(sh(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(gh()!==null)r.setMode(`normal`).setFormat(t).setStyle(n);else{let e=Wf(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(V(i)&&i.canInsertTextAfter()&&!sh(i))i.select();else{let e=Wf();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(V(i)&&i.canInsertTextBefore()&&!sh(i))i.select(0,0);else{let e=Wf();e.setFormat(t),e.setStyle(n),a.canInsertTextAfter()?r.insertAfter(e):a.insertAfter(e),e.select(0,0)}this.insertText(e);return}let s=Wf(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 ep(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=U()===this;lv(this,mv(uv(this))),e&&U()!==this&&Th(this)}formatText(e,t=null){op(this,e,t)}insertNodes(e){if(e.length===0)return;this.isCollapsed()||this.removeText();let t=this.anchor.getNode();if(this.anchor.type===`element`&&G(t)&&l_(t)!==null){let n=t.isShadowRoot()?t.getFirstChild()??t.append(Rm()).getFirstChild():t.getFirstChild();if(t.isShadowRoot()&&n!==null&&!G(n)){let e=Rm();n.insertBefore(e),n=e}if(n!==null){n.selectStart();let t=U();return H(t)||L(369),t.insertNodes(e)}}if(this.anchor.type===`element`&&rg(t)){let n=Vp(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=r_(n,Ng),i=e[e.length-1];if(G(r)&&`__language`in r){if(`__language`in e[0])this.insertText(e[0].getTextContent());else{let t=Rp(this);r.splice(t,0,e),i.selectEnd()}return}if(!e.some(e=>(G(e)||K(e))&&!e.isInline())){G(r)||L(211,n.constructor.name,n.getType());let t=Rp(this);r.splice(t,0,e),i.selectEnd();return}if(G(r)&&l_(r)!==null){let t=Rp(this),n=Lp(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=Vp(e),n=t.getLastDescendant(),r=ov(this.anchor,`next`);for(let e of t.getChildren())r=Cv(e,r);n!==null&&n.selectEnd();return}if(G(r)&&!r.isParentRequired()&&!rg(r.getParentOrThrow())){let t=Rp(this),n=Lp(e);r.splice(t,0,n);let i=n[n.length-1];i===void 0?r.select(t,t):i.selectEnd();return}let a=Vp(e),o=a.getLastDescendant(),s=a.getChildren(),c=!G(r)||!r.isEmpty()?this.insertParagraph():null;c&&!r.isAttached()&&(n=this.anchor.getNode(),r=r_(n,Ng));let l=s[s.length-1],u=s[0];var d;G(d=u)&&Ng(d)&&!d.isEmpty()&&G(r)&&(!r.isEmpty()||r.canMergeWhenEmpty())&&(G(r)||L(211,n.constructor.name,n.getType()),r.append(...u.getChildren()),u=s[1]),u&&(r===null&&L(212,n.constructor.name,n.getType()),function(e,t){let n=t.getParentOrThrow().getLastChild(),r=t,i=[t];for(;r!==n;)r.getNextSibling()||L(140),r=r.getNextSibling(),i.push(r);let a=e;for(let e of i)a=a.insertAfter(e)}(r,u));let f=r_(o,Ng);c&&G(f)&&(c.canMergeWhenEmpty()||Ng(l))&&(f.append(...c.getChildren()),c.remove()),G(r)&&r.isEmpty()&&r.remove(),o.selectEnd();let p=G(r)?r.getLastChild():null;Mm(p)&&f!==r&&p.remove()}insertParagraph(){let e=this.anchor.getNode();if(this.anchor.type===`element`&&rg(e)){let t=Rm();return e.splice(this.anchor.offset,0,[t]),t.select(),t}let t=Rp(this),n=r_(this.anchor.getNode(),Ng);if(n!==null&&l_(n)!==null)return null;G(n)||L(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=jm();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]=cp(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(V(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(V(n)&&(l===n.getTextContentSize()?e.shift():l!==0&&([,n]=n.splitText(l),e[0]=n,s.set(n.getKey(),0,`text`))),V(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(Hp(this,e,t,n))return;let r=e===`move`,i=W(),a=ug($h(i));if(!a)return;let o=i._blockCursorElement,s=i._rootElement,c=this.focus.getNode();s===null||o===null||!G(c)||c.isInline()||c.canBeEmpty()||lg(o,i,s);let l=Kh(i,this.focus.key),u=l;if(this.focus.type===`text`&&(u=V(c)?Rg(c,l,i):null),this.dirty){let e=Kh(i,this.anchor.key),t=e;if(this.anchor.type===`text`){let n=this.anchor.getNode();t=V(n)?Rg(n,e,i):null}t&&u&&Mp(a,t,this.anchor.offset,u,this.focus.offset)}if(n===`character`&&V(c)&&c.isUnmergeable()&&(t?this.focus.offset===0:this.focus.offset===c.getTextContentSize())){let e=H_(c,t?`previous`:`next`).getNodeAtCaret();if(V(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?Rg(e,n,i):null;if(r){let e=t?r.length:0;Mp(a,r,e,r,e)}}}}if(dp(a,e,t?`backward`:`forward`,n),a.rangeCount>0){let e=vg(a,i._rootElement),n=e||a.getRangeAt(0),o=this.anchor.getNode(),s=Sm(o)?o:tg(o);this.applyDOMRange(n),this.dirty=!0,!r&&(fp(this,t,s),(e?a.direction!==`backward`:a.anchorNode===n.startContainer&&a.anchorOffset===n.startOffset)||up(this))}n===`lineboundary`&&Hp(this,e,t,n,`decorators`)}forwardDeletion(e,t,n){if(!n&&(e.type===`element`&&G(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(G(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=Z_(ov(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(R_(t)){if(!t.origin.isInline()){if(t.origin.isShadowRoot()){if(e.type===`merge-block`)break;if(G(r.anchor.origin)&&r.anchor.origin.isEmpty()){let e=hv(t);lv(this,$_(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(L_(t)){if(G(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(K(t.origin)){if(!t.origin.isIsolated()){if(m_(t.origin).length>0){if(G(r.anchor.origin)&&r.anchor.origin.isEmpty()){r.anchor.origin.remove();let e=Tp();e.add(t.origin.getKey()),Th(e)}}else if(e.type===`merge-next-block`&&(t.origin.isKeyboardSelectable()||!t.origin.isInline())&&G(r.anchor.origin)&&r.anchor.origin.isEmpty()){r.anchor.origin.remove();let e=Tp();e.add(t.origin.getKey()),Th(e)}else t.origin.remove()}return}break}}if(e.type===`merge-block`){let{caret:t,block:n}=e;return m_(n).length>0?void 0:t.origin.isEmpty()&&!n.isEmpty()&&t.origin.getParent()===n.getParent()?void t.origin.remove(!0):(lv(this,$_(!t.origin.isEmpty()&&n.isEmpty()?dv(H_(n,t.direction)):r.anchor,t)),this.removeText())}for(let e=t.getNode();e!==null;){if(l_(e)!==null)return;if(G(e)&&e.isShadowRoot())break;e=e.getParent()}}let i=this.focus;if(pp(this,e,`character`),this.isCollapsed()){if(e&&t.offset===0&&lp(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 hp(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 hp(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!(Oh(e)||mp(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()&&Sm(e.getParent())&&e.getPreviousSibling()===null&&lp(this,e),np()}}deleteLine(e){let t=vp(this.anchor);if(t!==null&&K(u_(t)))return this.isCollapsed()||this.focus.set(this.anchor.key,this.anchor.offset,this.anchor.type),void this.deleteCharacter(e);this.isCollapsed()&&pp(this,e,`lineboundary`),this.isCollapsed()?this.deleteCharacter(e):r_(this.anchor.getNode(),Ng)===r_(this.focus.getNode(),Ng)?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;pp(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 Zp()||(this._cachedIsBackward=t),t}getStartEndPoints(){return[this.anchor,this.focus]}};function ip(e){return e instanceof tp}function ap(e,t){if(ip(e)){for(let n of e.getNodes())Pf(n)&&n.setFormat(t(n.getFormat()));return}if(e.isCollapsed())return e.setFormat(t(e.format)),void hh(null);let n=[];for(let r of e.getNodes())V(r)?n.push(r):G(r)?r.setTextFormat(t(r.getTextFormat())):Pf(r)&&r.setFormat(t(r.getFormat()));let r=n.length;if(r===0)return e.setFormat(t(e.format)),void hh(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(sh(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||sh(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()||sh(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 op(e,t,n=null){let r=n===null&&H(e)?dh(e.format,t,null):n;ap(e,e=>dh(e,t,r))}function sp(e){let t=e.offset;if(e.type===`text`)return t;let n=e.getNode();return t===n.getChildrenSize()?n.getTextContent().length:0}function cp(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]:[sp(n),sp(r)]}function lp(e,t){for(let n=t;n;n=n.getParent()){if(G(n)){if(n.collapseAtStart(e))return!0;if(rg(n))break}if(n.getPreviousSibling())break}return!1}function up(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 dp(e,t,n,r){e.modify(t,n,r)}function fp(e,t,n){let r=e.getNodes(),i=r.filter(e=>Zh(e,n));if(i.length===0||i.length===r.length)return!1;let a=t?i[0]:i[i.length-1],o=G(a)?a:a.getParentOrThrow();return t?o.selectStart():o.selectEnd(),!0}function pp(e,t,n){if(Hp(e,`extend`,t,n))return;let r=W(),i=ug($h(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||!G(c)||c.isInline()||c.canBeEmpty()||lg(a,r,o);let l=e=>{let t=e.getNode(),n=r.getElementByKey(e.key);return n!==null&&e.type===`text`&&V(t)?Rg(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(Mp(i,h,g,h,g),dp(i,`move`,t?`backward`:`forward`,n),i.rangeCount===0)return;let _=vg(i,o)||i.getRangeAt(0),v=_.startContainer,y=_.startOffset;if(p&&n===`character`&&s.type===`text`&&V(u)&&u.isUnmergeable()&&f===(t?0:u.getTextContentSize())){let n=H_(u,t?`previous`:`next`).getNodeAtCaret();if(V(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[ee,b,x,te]=t?[v,y,d,f]:[d,f,v,y],ne=Sm(u)?u:tg(u);e.applyDOMRange({collapsed:!1,endContainer:x,endOffset:te,startContainer:ee,startOffset:b}),e.dirty=!0,!fp(e,t,ne)&&t&&up(e),n===`lineboundary`&&Hp(e,`extend`,t,n,`decorators`)}let mp=(()=>{try{let e=RegExp(`\\p{Emoji}`,`u`),t=e.test.bind(e);if(t(`❤️`)&&t(`#️⃣`)&&t(`👍`))return t}catch{}return()=>!1})();function hp(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 gp(e,t,n,r){let i,a=t,o=!1;if(Y(e)){let s=!1,c=e.childNodes,l=c.length,u=r._blockCursorElement;a===l&&l>0&&(s=!0,a=l-1),bh(e,r)!==void 0||Xg(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=Dh(d),V(i))a=W_(i,s?`next`:`previous`);else{let c=Dh(e);if(c===null)return null;if(G(c)){let o=r.getElementByKey(c.getKey());o===null&&L(214);let l=Ig(c,o,r);[c,a]=l.resolveChildIndex(c,o,e,t),G(c)||L(215),s&&a>=c.getChildrenSize()&&(a=Math.max(0,c.getChildrenSize()-1));let u=c.getChildAtIndex(a);if(G(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=G(u)?u:u.getParentOrThrow()),a=0}V(u)?(i=u,c=null,a=W_(u,s?`next`:`previous`)):u!==c&&s&&!f&&(G(c)||L(216),a=Math.min(c.getChildrenSize(),a+1))}else{let n=u_(c),i=n===null?c:n,o=i.getIndexWithinParent(),s=r.getElementByKey(c.getKey()),l=`after`;if(s!==null&&Dh(e)===c){let n=Ig(c,s,r);n.element===s?t===0&&K(c)&&(l=`before`):l=n.resolveLeafPosition(s,e,t)}a=l===`before`?o:o+1,c=i.getParentOrThrow()}if(G(c))return[Xf(c.__key,a,`element`),o]}}else i=Dh(e);return V(i)?[Xf(i.__key,W_(i,a,`clamp`),`text`),o]:null}function _p(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&&G(a)&&a.isInline()){let t=a.getPreviousSibling();V(t)&&e.set(t.__key,t.getTextContent().length,`text`)}}else G(r)&&!n&&r.isInline()?e.set(r.__key,r.getChildrenSize(),`element`):V(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&&G(r)&&r.isInline())e.set(r.__key,0,`element`);else if((n||t)&&r===null&&G(a)&&a.isInline()&&!a.canInsertTextAfter()&&a.getTextContentSize()>1){let t=a.getNextSibling();V(t)&&e.set(t.__key,0,`text`)}}}function vp(e){let t=_h(e.key);return t===null?null:f_(t)}function yp(e,t,n){let r=vp(e),i=vp(t);if(r===i||r!==null&&i!==null&&r.is(i))return!1;let a=n(r,i);if(r!==null)return G(r)?t.set(r.getKey(),a?r.getChildrenSize():0,`element`):t.set(r.getKey(),a?r.getTextContentSize():0,`text`),!0;let o=u_(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 bp(e){let t=yp(e.anchor,e.focus,(t,n)=>function(e,t,n,r){if(n!==null&&r!==null){let e=u_(n),t=u_(r);if(e!==null&&e.is(t)){for(let t of p_(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=u_(n),r=_h(t.key);return e===null||r===null||!(!e.is(r)&&!e.isParentOf(r))||e.isBefore(r)}let i=u_(r),a=_h(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 xp(e,t,n,r,i,a){if(e===null||n===null||!nh(i,e,n))return null;let o=gp(e,t,H(a)?a.anchor:null,i);if(o===null)return null;let s=gp(n,r,H(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=Dh(e),r=Dh(n);if(K(t)&&K(r))return null}let f=i._slotsUsed&&yp(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);_p(e,n,r),_p(t,!n,r),r&&t.set(e.key,e.offset,e.type)}}(c,u),[c,u,l||d||f]}function Sp(e){return G(e)&&!e.isInline()}function Cp(e,t,n,r,i,a){let o=em(),s=new rp(Xf(e,t,i),Xf(n,r,a),0,``);return s.dirty=!0,o._selection=s,s}function wp(){return new rp(Xf(`root`,0,`element`),Xf(`root`,0,`element`),0,``)}function Tp(){return new tp(/* @__PURE__ */ new Set)}function Ep(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=!Ol&&(s||o===`beforeinput`||o===`compositionstart`||o===`compositionend`||o===`click`&&a&&a.detail===3||o===`drop`||o===void 0),l,u,d,f;if(H(e)&&!c)return e.clone();{if(t===null)return null;let r=bg(t,n._rootElement);if(l=r.anchorNode,u=r.focusNode,d=r.anchorOffset,f=r.focusOffset,(s||o===void 0)&&H(e)&&!nh(n,l,u))return e.clone()}let p=xp(l,d,u,f,n,e);if(p===null)return null;let[m,h,g]=p,_=0,v=``;if(H(e)){let t=e.anchor;if(m.key===t.key)_=e.format,v=e.style;else{let e=m.getNode();V(e)?(_=e.getFormat(),v=e.getStyle()):G(e)&&(_=e.getTextFormat(),v=e.getTextStyle())}}let y=new rp(m,h,_,v);return g&&(y.dirty=!0),y}function U(){return em()._selection}function Dp(){return W()._editorState._selection}function Op(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`),kp(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`)}}kp(e)}function kp(e){let t=e.anchor,n=t.offset,r=e.focus,i=r.offset,a=t.getNode(),o=r.getNode();if(e.isCollapsed()){if(!G(a))return;let e=a.getChildrenSize(),i=n>=e,o=i?a.getChildAtIndex(e-1):a.getChildAtIndex(n);if(V(o)){let e=0;i&&(e=o.getTextContentSize()),t.set(o.__key,e,`text`),r.set(o.__key,e,`text`)}}else{if(G(a)){let e=a.getChildrenSize(),r=n>=e,i=r?a.getChildAtIndex(e-1):a.getChildAtIndex(n);if(V(i)){let e=0;r&&(e=i.getTextContentSize()),t.set(i.__key,e,`text`)}}if(G(o)){let e=o.getChildrenSize(),t=i>=e,n=t?o.getChildAtIndex(e-1):o.getChildAtIndex(i);if(V(n)){let e=0;t&&(e=n.getTextContentSize()),r.set(n.__key,e,`text`)}}}}function Ap(e,t,n,r,i){let a=null,o=0,s=null;r===null?i!==null&&(a=i.__key,V(i)?s=`text`:G(i)&&(s=`element`)):(a=r.__key,V(r)?(o=r.getTextContentSize(),s=`text`):G(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 jp(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 Mp(e,t,n,r,i){try{e.setBaseAndExtent(t,n,r,i)}catch{}}function Np(e,t,n){let r=Kh(e,t.getKey());if(G(t)){let i=Ig(t,r,e);return[i.element,n+i.getFirstChildOffset()]}return[r,n]}function Pp(e,t,n,r,i,a){let o=a.getRootNode(),s=lh(o)||fg(o)?Tg(o):null;if(i.has(`collaboration`)&&s!==a||s!==null&&th(s,s))return;let c=bg(r,a),l;if(!H(t))return void(e!==null&&nh(n,c.anchorNode,c.focusNode)&&r.removeAllRanges());let u=t.anchor,d=t.focus,f=u.getNode(),p=d.getNode(),[m,h]=Np(n,f,u.offset),[g,_]=Np(n,p,d.offset),v=t.format,y=t.style,ee=t.isCollapsed(),b=m,x=g,te=!1;if(u.type===`text`?(b=V(f)?Rg(f,m,n):null,te=f.getFormat()!==v||f.getStyle()!==y):H(e)&&e.anchor.type===`text`&&(te=!0),d.type===`text`&&(x=V(p)?Rg(p,g,n):null),b!==null&&x!==null){if(ee&&(e===null||te||H(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`||!ee)&&c.anchorOffset===h&&c.focusOffset===_&&c.anchorNode===b&&c.focusNode===x){if(s===null||!a.contains(s)){let e=s===null?null:ih(s);e!==null&&e!==n||i.has(`skip-selection-focus`)||a.focus({preventScroll:!0})}if(u.type!==`element`)return}if(Mp(r,b,h,x,_),Zc&&t.isCollapsed()&&a!==null&&!i.has(`skip-selection-focus`)){let e=wg(a);if(e===null||!a.contains(e)){let e=Tg(a.ownerDocument),t=e===null?null:ih(e);t!==null&&t!==n||a.focus({preventScroll:!0})}}if(!i.has(`skip-scroll-into-view`)&&t.isCollapsed()&&a!==null&&a===wg(a)){let e=H(t)&&t.anchor.type===`element`?b.childNodes[h]||null:(l===void 0&&(l=yg(r,a)),l);if(e!==null){let t;if(ch(e)){let n=e.ownerDocument.createRange();n.selectNode(e),t=n.getBoundingClientRect()}else t=e.getBoundingClientRect();(function(e,t,n){let r=Jh(n),i=Qh(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=$h(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=qh(u)}})(n,t,a)}}(function(e){e._inputState.isSelectionChangeFromDOMUpdate=!0})(n)}}function Fp(e,t){for(let n of e.split(/(\r?\n|\t)/))n===`
|
|
147
|
+
`)e.preventDefault(),J(r,ad);else if(o==null&&e.dataTransfer){let t=e.dataTransfer.getData(`text/plain`);e.preventDefault(),a.insertRawText(t)}else o!=null&&Jd(a,n,o,e.timeStamp,!0)?(e.preventDefault(),J(r,od,o),ef(o)):i.unprocessedBeforeInputData=o;return i.lastBeforeInputInsertTextTimeStamp=e.timeStamp,!0}switch(e.preventDefault(),t){case`insertFromYank`:case`insertFromDrop`:case`insertReplacementText`:J(r,od,e),ef((e.dataTransfer?e.dataTransfer.getData(`text/plain`):null)??e.data);break;case`insertFromComposition`:{let t=i.hadOrphanedCompositionEvents;i.hadOrphanedCompositionEvents=!1;let n=r._compositionKey;vh(null),t||J(r,od,e),lf(n);break}case`insertLineBreak`:vh(null),J(r,id,!1);break;case`insertParagraph`:vh(null),i.isInsertLineBreak&&!nl?(i.isInsertLineBreak=!1,J(r,id,!1)):J(r,ad);break;case`insertFromPaste`:case`insertFromPasteAsQuotation`:J(r,sd,e);break;case`deleteByComposition`:(function(e,t){return e!==t||G(e)||G(t)||!lh(e)||!lh(t)})(l,u)&&J(r,cd,e);break;case`deleteByDrag`:Qh(Ef),J(r,cd,e);break;case`deleteByCut`:J(r,cd,e);break;case`deleteContent`:J(r,rd,!1);break;case`deleteWordBackward`:J(r,ld,!0);break;case`deleteWordForward`:J(r,ld,!1);break;case`deleteHardLineBackward`:case`deleteSoftLineBackward`:J(r,ud,!0);break;case`deleteContentForward`:case`deleteHardLineForward`:case`deleteSoftLineForward`:J(r,ud,!1);break;case`formatStrikeThrough`:J(r,dd,`strikethrough`);break;case`formatBold`:J(r,dd,`bold`);break;case`formatItalic`:J(r,dd,`italic`);break;case`formatUnderline`:J(r,dd,`underline`);break;case`historyUndo`:J(r,fd);break;case`historyRedo`:J(r,pd)}return!0}function of(e){let t=W(),n=t._inputState,r=U(),i=e.data,a=$d(e),o=!1;if(i!=null&&H(r)){let s=pg(ng(t)),c=s===null?null:Cg(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()&&V(u)&&uh(u);if(!l&&!d&&Jd(r,a,i,e.timeStamp,!1,c)){if(o=!0,n.compositionPhase===`ending-firefox`){let e=uf(t,i);if(n.compositionPhase=`idle`,e)return Qh(Df),kh(),!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;tl&&!r.isCollapsed()&&V(a)&&c.anchorNode!==null&&a.getTextContent().slice(0,u)+i+a.getTextContent().slice(u+d)===Ph(c.anchorNode)||J(t,od,i);let f=i.length;el&&f>1&&e.inputType===`insertCompositionText`&&!t.isComposing()&&(r.anchor.offset-=f,r._cachedNodes=null,r._cachedIsBackward=null),ol&&t.isComposing()&&(n.lastKeyDownTimeStamp=0,vh(null))}}return o||(Fh(!1,t,i===null?void 0:i),n.compositionPhase===`ending-firefox`&&(uf(t,i||void 0),Qh(`composition-end`),n.compositionPhase=`idle`)),kh(),!0}function sf(e){let t=W(),n=t._inputState,r=U();if(H(r)&&!t.isComposing()){n.compositionPhase=`composing`,n.hadOrphanedCompositionEvents=!1;let i=r.anchor,a=r.anchor.getNode();if(vh(i.key),Qh(`composition-start`),e.timeStamp<n.lastKeyDownTimeStamp+30||i.type===`element`||!r.isCollapsed()||!ol&&(a.getFormat()!==r.format||V(a)&&a.getStyle()!==r.style)||V(a)&&(uh(a)||i.offset===0&&!a.canInsertTextBefore()||i.offset===a.getTextContentSize()&&!a.canInsertTextAfter())){J(t,od,ll);let e=U();H(e)&&vh(e.anchor.key)}}return!0}function cf(e){let t=W();return t._inputState.compositionPhase=`idle`,uf(t,e.data),Qh(Df),!0}function lf(e){if(e===null)return;let t=bh(e);if(!V(t)||t.getType()===`text`||uh(t)||!t.isAttached())return;let n=U(),r=H(n)&&n.anchor.key===e?n.anchor.offset:null,i=qf(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 uf(e,t){let n=e._compositionKey;if(vh(null),n!==null&&t!=null){if(t===``){let t=bh(n),r=e.getElementByKey(n),i=r!==null&&V(t)?Vg(t,r,e):null;if(i!==null&&i.nodeValue!==null&&V(t)){let n=pg(ng(e)),r=n&&Cg(n,e._rootElement),a=null,o=null;r!==null&&r.anchorNode===i&&(a=r.anchorOffset,o=r.focusOffset),Ih(t,i.nodeValue,a,o,!0)}return lf(n),!1}if(t[t.length-1]===`
|
|
148
|
+
`){let t=U();if(H(t)||sp(t)){if(H(t)){let e=t.focus;t.anchor.set(e.key,e.offset,e.type)}return J(e,xd,null),lf(n),!1}}let r=bh(n);if(r!==null&&V(r)&&uh(r)){r.markDirty();let e=U(),i=r.getTextContentSize(),a=H(e)&&e.anchor.key===n?e.anchor.offset:i;return r.select(a,a).insertText(t),!0}}return Fh(!0,e,t),lf(n),!1}function df(e){let t=W(),n=t._inputState;if(e.key==null)return!0;if(n.compositionPhase===`ending-safari`){let r=Hh(e);if(r&&ym(t,()=>{uf(t,n.compositionEndData)}),n.compositionPhase=`idle`,n.compositionEndData=``,r)return!0}if(function(e){return q(e,`ArrowRight`,{shiftKey:`any`})}(e))J(t,hd,e);else if(function(e){return q(e,`ArrowRight`,{...Bh,shiftKey:`any`})}(e))J(t,gd,e);else if(function(e){return q(e,`ArrowLeft`,{shiftKey:`any`})}(e))J(t,_d,e);else if(function(e){return q(e,`ArrowLeft`,{...Bh,shiftKey:`any`})}(e))J(t,vd,e);else if(function(e){return q(e,`ArrowUp`,{altKey:`any`,shiftKey:`any`})}(e))J(t,yd,e);else if(function(e){return q(e,`ArrowDown`,{altKey:`any`,shiftKey:`any`})}(e))J(t,bd,e);else if(function(e){return q(e,`Enter`,{altKey:`any`,ctrlKey:`any`,metaKey:`any`,shiftKey:!0})}(e))n.isInsertLineBreak=!0,J(t,xd,e);else if(function(e){return e.key===` `}(e))J(t,Sd,e);else if(function(e){return $c&&q(e,`o`,{ctrlKey:!0})}(e))e.preventDefault(),n.isInsertLineBreak=!0,J(t,id,!0);else if(function(e){return q(e,`Enter`,{altKey:`any`,ctrlKey:`any`,metaKey:`any`})}(e))n.isInsertLineBreak=!1,J(t,xd,e);else if(function(e){return q(e,`Backspace`,{shiftKey:`any`})||$c&&q(e,`h`,{ctrlKey:!0})}(e))Hh(e)?J(t,Cd,e)&&nf(n):(e.preventDefault(),J(t,rd,!0));else if(function(e){return e.key===`Escape`}(e))J(t,wd,e);else if(function(e){return q(e,`Delete`,{})||$c&&q(e,`d`,{ctrlKey:!0})}(e))(function(e){return e.key===`Delete`})(e)?J(t,Td,e):(e.preventDefault(),J(t,rd,!1));else if(function(e){return q(e,`Backspace`,Vh)}(e))e.preventDefault(),J(t,ld,!0);else if(function(e){return q(e,`Delete`,Vh)}(e))e.preventDefault(),J(t,ld,!1);else if(function(e){return $c&&q(e,`Backspace`,{metaKey:!0})}(e))e.preventDefault(),J(t,ud,!0);else if(function(e){return $c&&(q(e,`Delete`,{metaKey:!0})||q(e,`k`,{ctrlKey:!0}))}(e))e.preventDefault(),J(t,ud,!1);else if(function(e){return q(e,`b`,Bh)}(e))e.preventDefault(),J(t,dd,`bold`);else if(function(e){return q(e,`u`,Bh)}(e))e.preventDefault(),J(t,dd,`underline`);else if(function(e){return q(e,`i`,Bh)}(e))e.preventDefault(),J(t,dd,`italic`);else if(function(e){return q(e,`Tab`,{shiftKey:`any`})}(e))J(t,Ed,e);else if(function(e){return q(e,`z`,Bh)}(e))e.preventDefault(),J(t,fd);else if(function(e){return $c?q(e,`z`,{metaKey:!0,shiftKey:!0}):q(e,`y`,{ctrlKey:!0})||q(e,`z`,{ctrlKey:!0,shiftKey:!0})}(e))e.preventDefault(),J(t,pd);else{let r=t._editorState._selection;(function(e){return q(e,`a`,Bh)})(e)?(e.preventDefault(),J(t,Nd,e)&&nf(n)):r===null||H(r)||(function(e){return q(e,`c`,Bh)}(e)?(e.preventDefault(),J(t,jd,e)):function(e){return q(e,`x`,Bh)}(e)&&(e.preventDefault(),J(t,Md,e)))}return function(e){return e.ctrlKey||e.shiftKey||e.altKey||e.metaKey}(e)&&t.dispatchCommand(Bd,e),!0}function ff(e){let t=e.__lexicalEventHandles;return t===void 0&&(t=[],e.__lexicalEventHandles=t),t}let pf=/* @__PURE__ */ new Map;function mf(e){let t=mg(e.target);if(t===null)return;let n=Zh(e.target),r=null,i=null,a=n===null?void 0:Kd.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&&hg(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=Cg(t,e).anchorNode;if(s!==null&&sh(s)===o){if(hg(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||Y(e)&&e.shadowRoot!==null||(r=sh(e),r!==null&&(i=e))}}if(r===null){let e=Og(n);r=e===null?null:sh(e)}}if(r===null)return;if(r._inputState.isSelectionChangeFromMouseDown){if(a!==void 0)for(let e of a.editors)e._inputState.isSelectionChangeFromMouseDown=!1;ym(r,()=>{let n=Ap(),a=i??Cg(t,r._rootElement).anchorNode;(Y(a)||dh(a))&&Oh(kp(n,t,r,e))})}let o=Mh(r),s=o[o.length-1],c=s._key,l=pf.get(c),u=l||s;u!==r&&Xd(t,u,!1),Xd(t,r,!0),r===s?l&&pf.delete(c):pf.set(c,r)}function hf(e){e._lexicalHandled=!0}function gf(e){return!0===e._lexicalHandled}function _f(e){let t=Gd.get(e);if(t===void 0)return;let n=Kd.get(t);if(n===void 0)return;Gd.delete(e);let r=ch(e);oh(r)?(function(e){if(e._parentEditor!==null){let t=Mh(e),n=t[t.length-1]._key;pf.get(n)===e&&pf.delete(n)}else pf.delete(e._key)}(r),n.editors.delete(r),n.hasShadowEditor=void 0,e.__lexicalEditor=null):r&&L(198);let i=ff(e);for(let e=0;e<i.length;e++)i[e]();e.__lexicalEventHandles=[]}function vf(e,t,n){tm();let r=e.__key,i=e.getParent();if(i===null)return void(f_(e)!==null&&L(367,r,String(f_(e))));let a=function(e){let t=U();if(!H(t)||!G(e))return t;let{anchor:n,focus:r}=t,i=n.getNode(),a=r.getNode();return eg(i,e)&&n.set(e.__key,0,`element`),eg(a,e)&&r.set(e.__key,0,`element`),t}(e),o=!1;if(H(a)&&t){let t=a.anchor,n=a.focus;t.key===r&&(Np(t,e,i,e.getPreviousSibling(),e.getNextSibling()),o=!0),n.key===r&&(Np(n,e,i,e.getPreviousSibling(),e.getNextSibling()),o=!0)}else sp(a)&&t&&e.isSelected()&&e.selectPrevious();if(H(a)&&t&&!o){let t=e.getIndexWithinParent();gh(e),jp(a,i,t,-1)}else gh(e);n||og(i)||i.canBeEmpty()||!i.isEmpty()||vf(i,t),t&&a&&Tm(i)&&i.isEmpty()&&i.selectEnd()}let yf=Symbol.for(`ephemeral`);function bf(e){return e[yf]||!1}let xf={configurable:!0,enumerable:!1,value:void 0,writable:!0};var Sf=class{__type;__key;__parent;__prev;__next;__state;[iu];static getType(){let{ownNodeType:e}=r_(this);return e===void 0&&L(64,this.name),e}static clone(e){L(65,this.name)}$config(){return{}}config(e,t){let n=t.extends||c_(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",xf),Object.defineProperty(this,iu,xf),hh(this,e)}getType(){return this.__type}isInline(){L(137,this.constructor.name)}isAttached(){let e=this.__key;for(;e!==null;){if(e===`root`)return!0;let t=bh(e);if(t===null)break;e=t.__parent===null?f_(t):t.__parent}return!1}isSelected(e){let t=e||U();if(t==null)return!1;let n=t.getNodes().some(e=>e.__key===this.__key);if(V(this))return n;if(H(t)&&t.anchor.type===`element`&&t.focus.type===`element`){if(t.isCollapsed())return!1;let e=this.getParent();if(K(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:bh(e)}getParentOrThrow(){let e=this.getParent();return e===null&&L(66,this.__key),e}getTopLevelElement(){let e=this;for(;e!==null;){let t=e.getParent();if(og(t)||f_(e)!==null)return G(e)||e===this&&K(e)||L(194),e;e=t}return null}getTopLevelElementOrThrow(){let e=this.getTopLevelElement();return e===null&&L(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:bh(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:bh(e)}getNextSiblings(){let e=[],t=this.getNextSibling();for(;t!==null;)e.push(t),t=t.getNextSibling();return e}getCommonAncestor(e){let t=G(this)?this:this.getParent(),n=G(e)?e:e.getParent(),r=t&&n?cv(t,n):null;return r?r.commonAncestor:null}is(e){return e!=null&&this.__key===e.__key}isBefore(e){let t=cv(this,e);return t!==null&&(t.type===`descendant`||(t.type===`branch`?av(t)===-1:(t.type!==`same`&&t.type!==`ancestor`&&L(279),!1)))}isParentOf(e){return eg(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=G(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&&L(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=W()._dirtyLeaves;return e!==null&&e.has(this.__key)}getLatest(){if(bf(this))return this;let e=bh(this.__key);return e===null&&L(113),e}getWritable(){if(bf(this))return this;tm();let e=rm(),t=W(),n=e._nodeMap,r=this.__key,i=this.getLatest(),a=t._cloneNotNeeded,o=U();if(o!==null&&o.setCachedNodes(null),a.has(r))return _h(i),i;let s=Gg(i);return a.add(r),_h(s),n.set(r,s),s}getTextContent(){return T_(this)}getTextContentSize(){return this.getTextContent().length}createDOM(e,t){L(70)}updateDOM(e,t,n){L(71)}getDOMSlot(e){return new xl(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){L(18,this.name)}updateFromJSON(e){return function(e,t){let n=e.getWritable(),r=t.$,i=r;for(let e of ql(n).flatKeys)e in t&&(i!==void 0&&i!==r||(i={...r}),i[e]=t[e]);return(n.__state||i)&&Kl(e).updateFromJSON(i),n}(this,e)}static transform(){return null}remove(e){vf(this,!0,e)}replace(e,t){tm();let n=U();n!==null&&(n=n.clone()),lg(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();gh(o),l!==null&&H(n)&&jp(n,l,u,-1);let d=r.getPreviousSibling(),f=r.getNextSibling(),p=r.__prev,m=r.__next,h=r.__parent;vf(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&&(G(this)&&G(o)||L(139),g=o.getChildrenSize(),o.splice(g,0,this.getChildren()));let _=__(this);if(_.length>0){u_(this)&&u_(o)||L(368,this.__key,o.__key);for(let e of _){let t=v_(this,e);t!==null&&(k_(this,e),O_(o,e,t))}}if(H(n)){Oh(n);let e=n.anchor,r=n.focus;e.key===i&&(t&&e.type===`element`?e.set(o.__key,g+e.offset,`element`):tp(e,o)),r.key===i&&(t&&r.type===`element`?r.set(o.__key,g+r.offset,`element`):tp(r,o))}return yh()===i&&vh(a),o}insertAfter(e,t=!0){tm(),lg(this,e);let n=this.getWritable(),r=e.getWritable();this.getParentOrThrow();let i=r.getParent(),a=U(),o=!1,s=!1;if(i!==null){let n=e.getIndexWithinParent();if(H(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}gh(r),t&&H(a)&&jp(a,i,n,-1)}else gh(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&&H(a)){let e=this.getIndexWithinParent();jp(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){tm(),lg(this,e);let n=this.getWritable(),r=e.getWritable();this.getParentOrThrow();let i=r.__key,a=U(),o=r.getParent(),s=o===null?-1:r.getIndexWithinParent();gh(r),o!==null&&t&&H(a)&&jp(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&&H(a)&&jp(a,this.getParentOrThrow(),d),e}isParentRequired(){return!1}createParentElementNode(){return Vm()}selectStart(){return this.selectPrevious()}selectEnd(){return this.selectNext(0,0)}selectPrevious(e,t){tm();let n=p_(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(G(r))return r.select();if(!V(r)){let e=r.getIndexWithinParent()+1;return i.select(e,e)}return r.select(e,t)}selectNext(e,t){tm();let n=p_(this);if(n!==null)return n.selectNext(e,t);let r=this.getNextSibling(),i=this.getParentOrThrow();if(r===null)return i.select();if(G(r))return r.select(0,0);if(!V(r)){let e=r.getIndexWithinParent();return i.select(e,e)}return r.select(e,t)}markDirty(){this.getWritable()}reconcileObservedMutation(e,t){this.markDirty()}};function Cf(e){return e instanceof Sf}let wf=`history-merge`,Tf=`paste`,Ef=`skip-selection-focus`,Df=`composition-end`;function Of(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 kf(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 Af(e,t,n=``){if(t===n)return;let r=Of(n),i=Of(t);for(let t in i)delete r[t],kf(e,t,i[t]);for(let t in r)e.removeProperty(t)}function jf(e,t){return 16&t?`code`:t&128?`mark`:32&t?`sub`:64&t?`sup`:null}function Mf(e,t){return 1&t?`strong`:2&t?`em`:`span`}function Nf(e,t,n,r,i){let a=r.classList,o=Wh(i,`base`);o!==void 0&&a.add(...o),o=Wh(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 fl){let r=fl[e];if(o=Wh(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 Pf(e,t,n){let r=n.isComposing(),i=e+(r?cl:``),a=Lg(),o=Rg(a).$getDOMSlot(n,t,a),s=o.getFirstChild();if(s===null||s.nodeType!==Node.TEXT_NODE)return void o.insertChild(bg().createTextNode(i));let c=s,l=c.nodeValue;if(l!==i){if(r||el){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 Ff(e,t,n,r,i,a){Pf(i,e,t);let o=a.theme.text;o!==void 0&&Nf(0,0,r,e,o)}function If(e,t){let n=bg().createElement(t);return n.appendChild(e),n}function Lf(e){return e!=null&&!0===e.__isInlineFormattable}var Rf=class extends Sf{__text;__format;__style;__mode;__detail;get __isInlineFormattable(){return!0}$config(){return this.config(`text`,{importDOM:{"#text":()=>({conversion:Uf,priority:0}),b:()=>({conversion:Bf,priority:0}),code:()=>({conversion:Kf,priority:0}),em:()=>({conversion:Kf,priority:0}),i:()=>({conversion:Kf,priority:0}),mark:()=>({conversion:Kf,priority:0}),s:()=>({conversion:Kf,priority:0}),span:()=>({conversion:zf,priority:0}),strong:()=>({conversion:Kf,priority:0}),sub:()=>({conversion:Kf,priority:0}),sup:()=>({conversion:Kf,priority:0}),u:()=>({conversion:Kf,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 _l[e.__mode]}getStyle(){return this.getLatest().__style}isToken(){return this.getLatest().__mode===1}isComposing(){return this.__key===yh()}isSegmented(){return this.getLatest().__mode===2}isDirectionless(){return!!(1&this.getLatest().__detail)}isUnmergeable(){return!!(2&this.getLatest().__detail)}hasFormat(e){let t=fl[e];return(this.getFormat()&t)!==0}isSimpleText(){return this.__type===`text`&&this.__mode===0}getTextContent(){return this.getLatest().__text}getFormatFlags(e,t){return mh(this.getLatest().__format,e,t)}canHaveFormat(){return!0}isInline(){return!0}createDOM(e,t){let n=this.__format,r=jf(0,n),i=Mf(0,n),a=r===null?i:r,o=bg().createElement(a),s=o;this.hasFormat(`code`)&&o.setAttribute(`spellcheck`,`false`),r!==null&&(s=bg().createElement(i),o.appendChild(s)),Ff(s,this,0,n,this.__text,e);let c=this.__style;return c!==``&&Af(o.style,c),o}updateDOM(e,t,n){let r=this.__text,i=e.__format,a=this.__format,o=jf(0,i),s=jf(0,a),c=Mf(0,i),l=Mf(0,a);if((o===null?c:o)!==(s===null?l:s))return!0;if(o===s&&c!==l){let e=t.firstChild;e??L(48);let i=bg().createElement(l);return Ff(i,this,0,a,r,n),t.replaceChild(i,e),!1}let u=t;s!==null&&o!==null&&(u=t.firstChild,u??L(49)),Pf(r,u,this);let d=n.theme.text;d!==void 0&&i!==a&&Nf(0,i,a,u,d);let f=e.__style,p=this.__style;return f!==p&&Af(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 Y(t)||L(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=If(t,`b`)),this.hasFormat(`italic`)&&(t=If(t,`i`)),this.hasFormat(`strikethrough`)&&(t=If(t,`s`)),this.hasFormat(`underline`)&&(t=If(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`?fl[e]:e,t}setDetail(e){let t=this.getWritable();return t.__detail=typeof e==`string`?pl[e]:e,t}setStyle(e){let t=this.getWritable();return t.__style=e,t}toggleFormat(e){let t=mh(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=gl[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){tm();let n=e,r=t,i=U(),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(!H(i))return Ep(o,n,o,r,`text`,`text`);{let e=yh();e!==i.anchor.key&&e!==i.focus.key||vh(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=U();if(r&&H(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){tm();let t=this.getLatest(),n=t.getTextContent();if(n===``)return[];let r=t.__key,i=yh(),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=U();if(H(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=qf(l),d.__format=f,d.__style=p,d.__detail=m,d.__state=Ql(t,d),h=!0):d=t.setTextContent(l);let y=[d];for(let e=1;e<c;e++){let n=qf(o[e]);n.__format=f,n.__style=p,n.__detail=m,n.__state=Ql(t,n);let a=n.__key;i===r&&vh(a),y.push(n)}let ee=g?g.offset:null,b=_?_.offset:null,te=0;for(let e of y){if(!g&&!_)break;let t=te+e.getTextContentSize();if(g!==null&&ee!==null&&ee<=t&&ee>=te&&(g.set(e.getKey(),ee-te,`text`),ee<t&&(g=null)),_!==null&&b!==null&&b<=t&&b>=te){_.set(e.getKey(),b-te,`text`);break}te=t}if(u!==null){(function(e){let t=e.getPreviousSibling(),n=e.getNextSibling();t!==null&&_h(t),n!==null&&_h(n)})(this);let e=u.getWritable(),t=this.getIndexWithinParent();h?(e.splice(t,0,y),this.remove()):e.splice(t,1,y),H(v)&&jp(v,u,t,c-1)}return y}mergeWithSibling(e){let t=e===this.getPreviousSibling();t||e===this.getNextSibling()||L(50);let n=this.__key,r=e.__key,i=this.__text,a=i.length;yh()===r&&vh(n);let o=U();if(H(o)){let i=o.anchor,s=o.focus;i!==null&&i.key===r&&Pp(i,t,n,e,a),s!==null&&s.key===r&&Pp(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 zf(e){return{forChild:Jf(e.style),node:null}}function Bf(e){let t=e,n=t.style.fontWeight===`normal`;return{forChild:Jf(t.style,n?void 0:`bold`),node:null}}let Vf=/* @__PURE__ */ new WeakMap;function Hf(e){if(!Y(e))return!1;if(e.nodeName===`PRE`)return!0;let t=e.style.whiteSpace;return typeof t==`string`&&t.startsWith(`pre`)}function Uf(e){let t=e;e.parentElement===null&&L(129);let n=t.textContent||``;if(function(e){let t,n=e.parentNode,r=[e];for(;n!==null&&(t=Vf.get(n))===void 0&&!Hf(n);)r.push(n),n=n.parentNode;let i=t===void 0?n:t;for(let e=0;e<r.length;e++)Vf.set(r[e],i);return i}(t)!==null)return{node:zp(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=Wf(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=Wf(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:qf(n)}}function Wf(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,Y(n)){let e=n.style.display;if(e===``&&!Ng(n)||e!==``&&!e.startsWith(`inline`))return null}let r=n;for(;(r=t?n.firstChild:n.lastChild)!==null;)n=r;if(dh(n))return n;if(n.nodeName===`BR`)return null}}let Gf={code:`code`,em:`italic`,i:`italic`,mark:`highlight`,s:`strikethrough`,strong:`bold`,sub:`subscript`,sup:`superscript`,u:`underline`};function Kf(e){let t=Gf[e.nodeName.toLowerCase()];return t===void 0?{node:null}:{forChild:Jf(e.style,t),node:null}}function qf(e=``){return cg(new Rf(e))}function V(e){return e instanceof Rf}function Jf(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=>((V(e)||Lf(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 Yf=class extends Rf{$config(){return this.config(`tab`,{extends:Rf})}constructor(e=void 0){super(` `,e),this.__detail=2}createDOM(e){let t=super.createDOM(e),n=Wh(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||L(286),this}setDetail(e){return e!==2&&L(127),this}setMode(e){return e!==`normal`&&L(128),this}canInsertTextBefore(){return!1}canInsertTextAfter(){return!1}};function Xf(){return cg(new Yf)}function Zf(e){return e instanceof Yf}var Qf=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:iv(vv(lv(this,`next`)),vv(lv(e,`next`)))<0}getNode(){let e=bh(this.key);return e===null&&L(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,em()||(yh()===a&&vh(e),i!==null&&(i.setCachedNodes(null),H(i)&&(i._cachedIsBackward=null),i.dirty=!0)))}};function $f(e,t,n){return new Qf(e,t,n)}function ep(e,t){let n=t.__key,r=e.offset,i=`element`;if(V(t)){i=`text`;let e=t.getTextContentSize();r>e&&(r=e)}else if(!G(t)){let e=t.getNextSibling();if(V(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 tp(e,t){if(G(t)){let n=t.getLastDescendant();G(n)||V(n)?ep(e,n):ep(e,t)}else ep(e,t)}function np(e,t,n,r){let i=e.getNode(),a=i.getChildAtIndex(e.offset),o=qf();if(o.setFormat(n),o.setStyle(r),Hm(a))a.splice(0,0,[o]);else if(a!==null){let e=og(i)?Vm().append(o):o;a.insertBefore(e)}else if(og(i)){let e=i.getLastChild();G(e)&&!e.isInline()&&e.isEmpty()?e.append(o):i.append(Vm().append(o))}else i.append(o);e.is(t)&&t.set(o.__key,0,`text`),e.set(o.__key,0,`text`)}function rp(e,t,n,r){let i=e.anchor.getNode();V(i)||L(398);let a=e.anchor.offset,o=qf(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 ip=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(!sp(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=>f_(e)===null),n=t.length;if(n===0)return;let r=t[n-1],i;if(V(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=bh(e);t!==null&&n.push(t)}return em()||(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=>f_(e)===null);if((U()||Ap())===this&&e[0]){let t=G_(e[0],`next`);dv(nv(t,t))}for(let t of e)t.remove();ap()}};function ap(){let e=Dh();if(e.isEmpty()){let t=Vm();e.append(t),t.select()}}function H(e){return e instanceof op}var op=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!!H(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(V_(n)){let{origin:e}=n;t.length===0?i.add(e):(a.add(e),t.push(e))}else{let{origin:e}=n;G(e)&&a.has(e)||t.push(e)}if(r&&t.push(r.caret.origin),B_(e.focus)&&G(e.focus.origin)&&e.focus.getNodeAtCaret()===null)for(let n=Y_(e.focus.origin,`previous`);V_(n)&&i.has(n.origin)&&!n.origin.isEmpty()&&n.origin.is(t[t.length-1]);n=Z_(n))i.delete(n.origin),t.pop();for(;t.length>1;){let e=t[t.length-1];if(!G(e)||a.has(e)||e.isEmpty()||i.has(e))break;t.pop()}if(t.length===0&&e.isCollapsed()){let n=vv(e.anchor),r=vv(e.anchor.getFlipped()),i=e=>z_(e)?e.origin:e.getNodeAtCaret(),a=i(n)||i(r)||(e.anchor.getNodeAtCaret()?n.origin:r.origin);t.push(a)}return t}(xv(pv(this),`next`));return em()||(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]=dp(this),c=``,l=!0;for(let u=0;u<e.length;u++){let d=e[u];if(G(d)&&!d.isInline()){l||(c+=`
|
|
149
|
+
`);let e=``;for(let t of __(d)){let n=v_(d,t);n!==null&&(e+=n.getTextContent())}e===``?l=!d.isEmpty():(c+=e,l=!1)}else if(l=!1,V(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!K(d)&&!Fm(d)||d===n&&this.isCollapsed()||(c+=d.getTextContent())}return c}applyDOMRange(e){let t=W(),n=t.getEditorState()._selection,r=wp(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),nu(this)}clone(){let t=this.anchor,n=this.focus;return new e($f(t.key,t.offset,t.type),$f(n.key,n.offset,n.type),this.format,this.style)}toggleFormat(e){this.format=mh(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=fl[e];return(this.format&t)!==0}insertRawText(e){this.insertNodes(zp(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(V(r)&&(t=r.getFormat(),n=r.getStyle()),this.removeText(),this.format=t,this.style=n,e===``)return;if(yh()===null)return this.anchor.type===`element`&&np(this.anchor,this.focus,t,n),void rp(this,e,t,n)}this.anchor.type===`element`&&np(this.anchor,this.focus,t,n);let r=this.anchor.getNode();V(r)||L(398);let i=this.anchor.offset,a=r.getParentOrThrow(),o=r.getTextContentSize();if(uh(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(yh()!==null)r.setMode(`normal`).setFormat(t).setStyle(n);else{let e=qf(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(V(i)&&i.canInsertTextAfter()&&!uh(i))i.select();else{let e=qf();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(V(i)&&i.canInsertTextBefore()&&!uh(i))i.select(0,0);else{let e=qf();e.setFormat(t),e.setStyle(n),a.canInsertTextAfter()?r.insertAfter(e):a.insertAfter(e),e.select(0,0)}this.insertText(e);return}let s=qf(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 rp(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=U()===this;fv(this,_v(pv(this))),e&&U()!==this&&Oh(this)}formatText(e,t=null){lp(this,e,t)}insertNodes(e){if(e.length===0)return;this.isCollapsed()||this.removeText();let t=this.anchor.getNode();if(this.anchor.type===`element`&&G(t)&&f_(t)!==null){let n=t.isShadowRoot()?t.getFirstChild()??t.append(Vm()).getFirstChild():t.getFirstChild();if(t.isShadowRoot()&&n!==null&&!G(n)){let e=Vm();n.insertBefore(e),n=e}if(n!==null){n.selectStart();let t=U();return H(t)||L(369),t.insertNodes(e)}}if(this.anchor.type===`element`&&og(t)){let n=Wp(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=o_(n,Ig),i=e[e.length-1];if(G(r)&&`__language`in r){if(`__language`in e[0])this.insertText(e[0].getTextContent());else{let t=Vp(this);r.splice(t,0,e),i.selectEnd()}return}if(!e.some(e=>(G(e)||K(e))&&!e.isInline())){G(r)||L(211,n.constructor.name,n.getType());let t=Vp(this);r.splice(t,0,e),i.selectEnd();return}if(G(r)&&f_(r)!==null){let t=Vp(this),n=Bp(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=Wp(e),n=t.getLastDescendant(),r=lv(this.anchor,`next`);for(let e of t.getChildren())r=Ev(e,r);n!==null&&n.selectEnd();return}if(G(r)&&!r.isParentRequired()&&!og(r.getParentOrThrow())){let t=Vp(this),n=Bp(e);r.splice(t,0,n);let i=n[n.length-1];i===void 0?r.select(t,t):i.selectEnd();return}let a=Wp(e),o=a.getLastDescendant(),s=a.getChildren(),c=!G(r)||!r.isEmpty()?this.insertParagraph():null;c&&!r.isAttached()&&(n=this.anchor.getNode(),r=o_(n,Ig));let l=s[s.length-1],u=s[0];var d;G(d=u)&&Ig(d)&&!d.isEmpty()&&G(r)&&(!r.isEmpty()||r.canMergeWhenEmpty())&&(G(r)||L(211,n.constructor.name,n.getType()),r.append(...u.getChildren()),u=s[1]),u&&(r===null&&L(212,n.constructor.name,n.getType()),function(e,t){let n=t.getParentOrThrow().getLastChild(),r=t,i=[t];for(;r!==n;)r.getNextSibling()||L(140),r=r.getNextSibling(),i.push(r);let a=e;for(let e of i)a=a.insertAfter(e)}(r,u));let f=o_(o,Ig);c&&G(f)&&(c.canMergeWhenEmpty()||Ig(l))&&(f.append(...c.getChildren()),c.remove()),G(r)&&r.isEmpty()&&r.remove(),o.selectEnd();let p=G(r)?r.getLastChild():null;Fm(p)&&f!==r&&p.remove()}insertParagraph(){let e=this.anchor.getNode();if(this.anchor.type===`element`&&og(e)){let t=Vm();return e.splice(this.anchor.offset,0,[t]),t.select(),t}let t=Vp(this),n=o_(this.anchor.getNode(),Ig);if(n!==null&&f_(n)!==null)return null;G(n)||L(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=Pm();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]=dp(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(V(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(V(n)&&(l===n.getTextContentSize()?e.shift():l!==0&&([,n]=n.splitText(l),e[0]=n,s.set(n.getKey(),0,`text`))),V(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(Gp(this,e,t,n))return;let r=e===`move`,i=W(),a=pg(ng(i));if(!a)return;let o=i._blockCursorElement,s=i._rootElement,c=this.focus.getNode();s===null||o===null||!G(c)||c.isInline()||c.canBeEmpty()||fg(o,i,s);let l=Yh(i,this.focus.key),u=l;if(this.focus.type===`text`&&(u=V(c)?Vg(c,l,i):null),this.dirty){let e=Yh(i,this.anchor.key),t=e;if(this.anchor.type===`text`){let n=this.anchor.getNode();t=V(n)?Vg(n,e,i):null}t&&u&&Fp(a,t,this.anchor.offset,u,this.focus.offset)}if(n===`character`&&V(c)&&c.isUnmergeable()&&(t?this.focus.offset===0:this.focus.offset===c.getTextContentSize())){let e=G_(c,t?`previous`:`next`).getNodeAtCaret();if(V(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?Vg(e,n,i):null;if(r){let e=t?r.length:0;Fp(a,r,e,r,e)}}}}if(mp(a,e,t?`backward`:`forward`,n),a.rangeCount>0){let e=xg(a,i._rootElement),n=e||a.getRangeAt(0),o=this.anchor.getNode(),s=Tm(o)?o:ig(o);this.applyDOMRange(n),this.dirty=!0,!r&&(hp(this,t,s),(e?a.direction!==`backward`:a.anchorNode===n.startContainer&&a.anchorOffset===n.startOffset)||pp(this))}n===`lineboundary`&&Gp(this,e,t,n,`decorators`)}forwardDeletion(e,t,n){if(!n&&(e.type===`element`&&G(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(G(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=ev(lv(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(V_(t)){if(!t.origin.isInline()){if(t.origin.isShadowRoot()){if(e.type===`merge-block`)break;if(G(r.anchor.origin)&&r.anchor.origin.isEmpty()){let e=vv(t);fv(this,nv(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(B_(t)){if(G(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(K(t.origin)){if(!t.origin.isIsolated()){if(__(t.origin).length>0){if(G(r.anchor.origin)&&r.anchor.origin.isEmpty()){r.anchor.origin.remove();let e=Op();e.add(t.origin.getKey()),Oh(e)}}else if(e.type===`merge-next-block`&&(t.origin.isKeyboardSelectable()||!t.origin.isInline())&&G(r.anchor.origin)&&r.anchor.origin.isEmpty()){r.anchor.origin.remove();let e=Op();e.add(t.origin.getKey()),Oh(e)}else t.origin.remove()}return}break}}if(e.type===`merge-block`){let{caret:t,block:n}=e;return __(n).length>0?void 0:t.origin.isEmpty()&&!n.isEmpty()&&t.origin.getParent()===n.getParent()?void t.origin.remove(!0):(fv(this,nv(!t.origin.isEmpty()&&n.isEmpty()?mv(G_(n,t.direction)):r.anchor,t)),this.removeText())}for(let e=t.getNode();e!==null;){if(f_(e)!==null)return;if(G(e)&&e.isShadowRoot())break;e=e.getParent()}}let i=this.focus;if(gp(this,e,`character`),this.isCollapsed()){if(e&&t.offset===0&&fp(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 vp(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 vp(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!(jh(e)||_p(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()&&Tm(e.getParent())&&e.getPreviousSibling()===null&&fp(this,e),ap()}}deleteLine(e){let t=xp(this.anchor);if(t!==null&&K(p_(t)))return this.isCollapsed()||this.focus.set(this.anchor.key,this.anchor.offset,this.anchor.type),void this.deleteCharacter(e);this.isCollapsed()&&gp(this,e,`lineboundary`),this.isCollapsed()?this.deleteCharacter(e):o_(this.anchor.getNode(),Ig)===o_(this.focus.getNode(),Ig)?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;gp(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 em()||(this._cachedIsBackward=t),t}getStartEndPoints(){return[this.anchor,this.focus]}};function sp(e){return e instanceof ip}function cp(e,t){if(sp(e)){for(let n of e.getNodes())Lf(n)&&n.setFormat(t(n.getFormat()));return}if(e.isCollapsed())return e.setFormat(t(e.format)),void vh(null);let n=[];for(let r of e.getNodes())V(r)?n.push(r):G(r)?r.setTextFormat(t(r.getTextFormat())):Lf(r)&&r.setFormat(t(r.getFormat()));let r=n.length;if(r===0)return e.setFormat(t(e.format)),void vh(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(uh(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||uh(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()||uh(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 lp(e,t,n=null){let r=n===null&&H(e)?mh(e.format,t,null):n;cp(e,e=>mh(e,t,r))}function up(e){let t=e.offset;if(e.type===`text`)return t;let n=e.getNode();return t===n.getChildrenSize()?n.getTextContent().length:0}function dp(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]:[up(n),up(r)]}function fp(e,t){for(let n=t;n;n=n.getParent()){if(G(n)){if(n.collapseAtStart(e))return!0;if(og(n))break}if(n.getPreviousSibling())break}return!1}function pp(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 mp(e,t,n,r){e.modify(t,n,r)}function hp(e,t,n){let r=e.getNodes(),i=r.filter(e=>eg(e,n));if(i.length===0||i.length===r.length)return!1;let a=t?i[0]:i[i.length-1],o=G(a)?a:a.getParentOrThrow();return t?o.selectStart():o.selectEnd(),!0}function gp(e,t,n){if(Gp(e,`extend`,t,n))return;let r=W(),i=pg(ng(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||!G(c)||c.isInline()||c.canBeEmpty()||fg(a,r,o);let l=e=>{let t=e.getNode(),n=r.getElementByKey(e.key);return n!==null&&e.type===`text`&&V(t)?Vg(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(Fp(i,h,g,h,g),mp(i,`move`,t?`backward`:`forward`,n),i.rangeCount===0)return;let _=xg(i,o)||i.getRangeAt(0),v=_.startContainer,y=_.startOffset;if(p&&n===`character`&&s.type===`text`&&V(u)&&u.isUnmergeable()&&f===(t?0:u.getTextContentSize())){let n=G_(u,t?`previous`:`next`).getNodeAtCaret();if(V(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[ee,b,te,x]=t?[v,y,d,f]:[d,f,v,y],ne=Tm(u)?u:ig(u);e.applyDOMRange({collapsed:!1,endContainer:te,endOffset:x,startContainer:ee,startOffset:b}),e.dirty=!0,!hp(e,t,ne)&&t&&pp(e),n===`lineboundary`&&Gp(e,`extend`,t,n,`decorators`)}let _p=(()=>{try{let e=RegExp(`\\p{Emoji}`,`u`),t=e.test.bind(e);if(t(`❤️`)&&t(`#️⃣`)&&t(`👍`))return t}catch{}return()=>!1})();function vp(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 yp(e,t,n,r){let i,a=t,o=!1;if(Y(e)){let s=!1,c=e.childNodes,l=c.length,u=r._blockCursorElement;a===l&&l>0&&(s=!0,a=l-1),Ch(e,r)!==void 0||$g(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=Ah(d),V(i))a=q_(i,s?`next`:`previous`);else{let c=Ah(e);if(c===null)return null;if(G(c)){let o=r.getElementByKey(c.getKey());o===null&&L(214);let l=zg(c,o,r);[c,a]=l.resolveChildIndex(c,o,e,t),G(c)||L(215),s&&a>=c.getChildrenSize()&&(a=Math.max(0,c.getChildrenSize()-1));let u=c.getChildAtIndex(a);if(G(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=G(u)?u:u.getParentOrThrow()),a=0}V(u)?(i=u,c=null,a=q_(u,s?`next`:`previous`)):u!==c&&s&&!f&&(G(c)||L(216),a=Math.min(c.getChildrenSize(),a+1))}else{let n=p_(c),i=n===null?c:n,o=i.getIndexWithinParent(),s=r.getElementByKey(c.getKey()),l=`after`;if(s!==null&&Ah(e)===c){let n=zg(c,s,r);n.element===s?t===0&&K(c)&&(l=`before`):l=n.resolveLeafPosition(s,e,t)}a=l===`before`?o:o+1,c=i.getParentOrThrow()}if(G(c))return[$f(c.__key,a,`element`),o]}}else i=Ah(e);return V(i)?[$f(i.__key,q_(i,a,`clamp`),`text`),o]:null}function bp(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&&G(a)&&a.isInline()){let t=a.getPreviousSibling();V(t)&&e.set(t.__key,t.getTextContent().length,`text`)}}else G(r)&&!n&&r.isInline()?e.set(r.__key,r.getChildrenSize(),`element`):V(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&&G(r)&&r.isInline())e.set(r.__key,0,`element`);else if((n||t)&&r===null&&G(a)&&a.isInline()&&!a.canInsertTextAfter()&&a.getTextContentSize()>1){let t=a.getNextSibling();V(t)&&e.set(t.__key,0,`text`)}}}function xp(e){let t=bh(e.key);return t===null?null:h_(t)}function Sp(e,t,n){let r=xp(e),i=xp(t);if(r===i||r!==null&&i!==null&&r.is(i))return!1;let a=n(r,i);if(r!==null)return G(r)?t.set(r.getKey(),a?r.getChildrenSize():0,`element`):t.set(r.getKey(),a?r.getTextContentSize():0,`text`),!0;let o=p_(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 Cp(e){let t=Sp(e.anchor,e.focus,(t,n)=>function(e,t,n,r){if(n!==null&&r!==null){let e=p_(n),t=p_(r);if(e!==null&&e.is(t)){for(let t of g_(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=p_(n),r=bh(t.key);return e===null||r===null||!(!e.is(r)&&!e.isParentOf(r))||e.isBefore(r)}let i=p_(r),a=bh(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 wp(e,t,n,r,i,a){if(e===null||n===null||!ah(i,e,n))return null;let o=yp(e,t,H(a)?a.anchor:null,i);if(o===null)return null;let s=yp(n,r,H(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=Ah(e),r=Ah(n);if(K(t)&&K(r))return null}let f=i._slotsUsed&&Sp(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);bp(e,n,r),bp(t,!n,r),r&&t.set(e.key,e.offset,e.type)}}(c,u),[c,u,l||d||f]}function Tp(e){return G(e)&&!e.isInline()}function Ep(e,t,n,r,i,a){let o=rm(),s=new op($f(e,t,i),$f(n,r,a),0,``);return s.dirty=!0,o._selection=s,s}function Dp(){return new op($f(`root`,0,`element`),$f(`root`,0,`element`),0,``)}function Op(){return new ip(/* @__PURE__ */ new Set)}function kp(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=!jl&&(s||o===`beforeinput`||o===`compositionstart`||o===`compositionend`||o===`click`&&a&&a.detail===3||o===`drop`||o===void 0),l,u,d,f;if(H(e)&&!c)return e.clone();{if(t===null)return null;let r=Cg(t,n._rootElement);if(l=r.anchorNode,u=r.focusNode,d=r.anchorOffset,f=r.focusOffset,(s||o===void 0)&&H(e)&&!ah(n,l,u))return e.clone()}let p=wp(l,d,u,f,n,e);if(p===null)return null;let[m,h,g]=p,_=0,v=``;if(H(e)){let t=e.anchor;if(m.key===t.key)_=e.format,v=e.style;else{let e=m.getNode();V(e)?(_=e.getFormat(),v=e.getStyle()):G(e)&&(_=e.getTextFormat(),v=e.getTextStyle())}}let y=new op(m,h,_,v);return g&&(y.dirty=!0),y}function U(){return rm()._selection}function Ap(){return W()._editorState._selection}function jp(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`),Mp(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`)}}Mp(e)}function Mp(e){let t=e.anchor,n=t.offset,r=e.focus,i=r.offset,a=t.getNode(),o=r.getNode();if(e.isCollapsed()){if(!G(a))return;let e=a.getChildrenSize(),i=n>=e,o=i?a.getChildAtIndex(e-1):a.getChildAtIndex(n);if(V(o)){let e=0;i&&(e=o.getTextContentSize()),t.set(o.__key,e,`text`),r.set(o.__key,e,`text`)}}else{if(G(a)){let e=a.getChildrenSize(),r=n>=e,i=r?a.getChildAtIndex(e-1):a.getChildAtIndex(n);if(V(i)){let e=0;r&&(e=i.getTextContentSize()),t.set(i.__key,e,`text`)}}if(G(o)){let e=o.getChildrenSize(),t=i>=e,n=t?o.getChildAtIndex(e-1):o.getChildAtIndex(i);if(V(n)){let e=0;t&&(e=n.getTextContentSize()),r.set(n.__key,e,`text`)}}}}function Np(e,t,n,r,i){let a=null,o=0,s=null;r===null?i!==null&&(a=i.__key,V(i)?s=`text`:G(i)&&(s=`element`)):(a=r.__key,V(r)?(o=r.getTextContentSize(),s=`text`):G(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 Pp(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 Fp(e,t,n,r,i){try{e.setBaseAndExtent(t,n,r,i)}catch{}}function Ip(e,t,n){let r=Yh(e,t.getKey());if(G(t)){let i=zg(t,r,e);return[i.element,n+i.getFirstChildOffset()]}return[r,n]}function Lp(e,t,n,r,i,a){let o=a.getRootNode(),s=fh(o)||hg(o)?Og(o):null;if(i.has(`collaboration`)&&s!==a||s!==null&&ih(s,s))return;let c=Cg(r,a),l;if(!H(t))return void(e!==null&&ah(n,c.anchorNode,c.focusNode)&&r.removeAllRanges());let u=t.anchor,d=t.focus,f=u.getNode(),p=d.getNode(),[m,h]=Ip(n,f,u.offset),[g,_]=Ip(n,p,d.offset),v=t.format,y=t.style,ee=t.isCollapsed(),b=m,te=g,x=!1;if(u.type===`text`?(b=V(f)?Vg(f,m,n):null,x=f.getFormat()!==v||f.getStyle()!==y):H(e)&&e.anchor.type===`text`&&(x=!0),d.type===`text`&&(te=V(p)?Vg(p,g,n):null),b!==null&&te!==null){if(ee&&(e===null||x||H(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`||!ee)&&c.anchorOffset===h&&c.focusOffset===_&&c.anchorNode===b&&c.focusNode===te){if(s===null||!a.contains(s)){let e=s===null?null:sh(s);e!==null&&e!==n||i.has(`skip-selection-focus`)||a.focus({preventScroll:!0})}if(u.type!==`element`)return}if(Fp(r,b,h,te,_),el&&t.isCollapsed()&&a!==null&&!i.has(`skip-selection-focus`)){let e=Dg(a);if(e===null||!a.contains(e)){let e=Og(a.ownerDocument),t=e===null?null:sh(e);t!==null&&t!==n||a.focus({preventScroll:!0})}}if(!i.has(`skip-scroll-into-view`)&&t.isCollapsed()&&a!==null&&a===Dg(a)){let e=H(t)&&t.anchor.type===`element`?b.childNodes[h]||null:(l===void 0&&(l=Sg(r,a)),l);if(e!==null){let t;if(dh(e)){let n=e.ownerDocument.createRange();n.selectNode(e),t=n.getBoundingClientRect()}else t=e.getBoundingClientRect();(function(e,t,n){let r=Zh(n),i=tg(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=ng(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=Xh(u)}})(n,t,a)}}(function(e){e._inputState.isSelectionChangeFromDOMUpdate=!0})(n)}}function Rp(e,t){for(let n of e.split(/(\r?\n|\t)/))n===`
|
|
150
150
|
`||n===`\r
|
|
151
|
-
`?t.linebreak():n===` `?t.tab():n!==``&&t.text(n)}function Ip(e){let t=[];return Fp(e,{linebreak:()=>t.push(jm()),tab:()=>t.push(qf()),text:e=>t.push(Wf(e))}),t}function Lp(e){let t=[];for(let n of e)Mm(n)||(!G(n)&&!K(n)||n.isInline()?t.push(n):G(n)&&t.push(...Lp(n.getChildren())));return t}function Rp(e){let t=e;e.isCollapsed()||t.removeText();let n=U();H(n)&&(t=n),H(t)||L(161);let r=t.anchor,i=r.getNode(),a=r.offset;for(;!Ng(i)&&l_(i)===null;){let e=i;if([i,a]=zp(i,a),e.is(i))break}return a}function zp(e,t){let n=e.getParent();if(!n){let e=Rm();return wh().append(e),e.select(),[wh(),0]}if(V(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(!G(e)||t===0)return[n,e.getIndexWithinParent()];let r=e.getChildAtIndex(t);if(r){let n=new rp(Xf(e.__key,t,`element`),Xf(e.__key,t,`element`),0,``),i=e.insertNewAfter(n);i&&i.append(r,...r.getNextSiblings())}return[n,e.getIndexWithinParent()+1]}function Bp(e){return Mm(e)||eg(e)||V(e)||e.isParentRequired()}function Vp(e){let t=Rm(),n=null;for(let r=0;r<e.length;r++){let i=e[r];if(Bp(i)){if(n===null){n=i.createParentElementNode(),t.append(n);let a=e[r+1];if(Mm(i)&&(a===void 0||!Bp(a)))continue}n.append(i)}else t.append(i),n=null}return t}function Hp(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=ov(e.focus,n?`previous`:`next`),o=r===`lineboundary`,s=t===`move`,c=a,l=i===`decorators-and-blocks`;if(!gv(c)){for(let e of c){l=!1;let{origin:t}=e;if(!K(t)||t.isIsolated()||(c=e,!o||!t.isInline()))break}if(l)for(let e of Z_(a).iterNodeCarets(t===`extend`?`shadowRoot`:`root`)){if(R_(e))e.origin.isInline()||(c=e);else{if(G(e.origin))continue;K(e.origin)&&!e.origin.isInline()&&(c=e)}break}}if(c===a)return!1;if(s&&!o&&K(c.origin)&&c.origin.isKeyboardSelectable()){let e=Tp();return e.add(c.origin.getKey()),Th(e),!0}return c=hv(c),s&&sv(e.anchor,c),sv(e.focus,c),l||!o}let Up=null,Wp=null,Gp=!1,Kp=!1,qp=!1,Jp=/* @__PURE__ */ new Set,Yp=0,Xp={characterData:!0,childList:!0,subtree:!0};function Zp(){return Gp||Up!==null&&Up._readOnly}function Qp(){Gp&&L(13)}function $p(){Yp>99&&L(14)}function em(){return Up===null&&L(195,rm()),Up}function tm(e){em()!==null&&Wp===null&&(Wp=e),Wp!==e&&qc(378)}function W(){return Wp===null&&L(337,rm()),Wp}function nm(){W()._dirtyType=2}function rm(){let e=0,t=/* @__PURE__ */ new Set,n=qm.version;if(typeof window<`u`)for(let r of hg(document)){let i=ah(r);if(rh(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 im(){return Wp}function am(e,t,n){let r=t.__type,i=Qm(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 om(e,t){return e!==void 0&&e.__key!==t&&e.isAttached()}function sm(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 cm(e,t){let n=e.type,r=t.get(n);r===void 0&&L(17,n);let i=r.klass;e.type!==i.getType()&&L(18,i.name);let a=i.importJSON(e),o=e.children;if(G(a)&&Array.isArray(o))for(let e=0;e<o.length;e++){let n=cm(o[e],t);a.append(n)}let s=e.$slots;if(s){s_(a)||L(379,i.name);for(let e in s)T_(a,e,cm(s[e],t))}return a}function lm(e,t,n){let r=Up,i=Gp,a=Wp;Up=t,Gp=!0,Wp=e;try{return n()}finally{Up=r,Gp=i,Wp=a}}function um(e,t){let n=qp;qp=!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&&pm(e,e._deferred));let a=e._editorState,o=a._selection,s=n._selection,c=e._dirtyType!==0,l=Up,u=Gp,d=Wp,f=e._updating,p=e._observer,m=null;if(e._pendingEditorState=null,e._editorState=n,!i&&c&&p!==null){Wp=e,Up=n,Gp=!1,e._updating=!0;try{let t=e._dirtyType,r=e._dirtyElements,i=e._dirtyLeaves;p.disconnect(),m=Ku(a,n,e,t,r,i)}catch(t){if(t instanceof Error&&e._onError(t),Kp)throw t;Vm(e,null,r,n),Ll(e),e._dirtyType=2,Kp=!0,um(e,a),Kp=!1;return}finally{p.observe(r,Xp),e._updating=f,Up=l,Gp=u,Wp=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=Sh(e)),delete r[a])}(e,n);let y=i?null:ug($h(e));if(e._editable&&y!==null&&(c||s===null||s.dirty||!s.is(o))&&r!==null&&!v.has(`skip-dom-selection`)){Wp=e,Up=n;try{if(p!==null&&p.disconnect(),c||s===null||s.dirty){let t=e._blockCursorElement;t!==null&&lg(t,e,r),Pp(o,s,e,y,v,r)}(function(e,t,n){let r=e._blockCursorElement;if(H(n)&&n.isCollapsed()&&n.anchor.type===`element`&&t.contains(wg(t))){let i=n.anchor,a=i.getNode(),o=i.offset,s=!1,c=null;if(o===a.getChildrenSize())cg(a.getChildAtIndex(o-1))&&(s=!0);else{let t=a.getChildAtIndex(o);if(t!==null&&cg(t)){let n=t.getPreviousSibling();(n===null||cg(n))&&(s=!0,c=e.getElementByKey(t.__key))}}if(s){let n=Ig(a,e.getElementByKey(a.__key),e).element;r===null&&(e._blockCursorElement=r=function(e){let t=e.theme,n=_g().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=Dv(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&&lg(r,e,t)})(e,r,s)}finally{p!==null&&p.observe(r,Xp),Wp=d,Up=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),H(s)||s===null||o!==null&&o.is(s)||e.dispatchCommand(Ju);let ee=e._pendingDecorators;ee!==null&&(e._decorators=ee,e._pendingDecorators=null,dm(`decorator`,e,!0,ee)),function(e,t,n){let r=Ch(t),i=Ch(n);r!==i&&dm(`textcontent`,e,!0,i)}(e,t||a,n),dm(`update`,e,!0,{dirtyElements:g,dirtyLeaves:h,editorState:n,mutatedNodes:m,normalizedNodes:_,prevEditorState:t||a,tags:v}),!f&&pm(e,e._deferred),(function(e){let t=e._updates;if(t.length===0)return void(e._cascadeCount=0);if(function(e){Jp.has(e)||(Jp.add(e),setTimeout(()=>{Jp.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;hm(e,t,r)}})(e)})(e,t)}finally{qp=n}}function dm(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 fm(e,t,n,r){let i=kh(e),a;if(!qp)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(gm(s,()=>{for(let i of t)if(i(n,r))return void(e=!0)}),e)return e}}}return a&&a.update(()=>{fm(a,t,n,r)}),!1}function pm(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 mm(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&&L(191),a._flushSync=!0),o&&e._deferred.push(o),sm(e,i.tag)),a==null?hm(e,n,i):n()}}return r}function hm(e,t,n){let r=e._updateTags,i,a=!1,o=!1;n!==void 0&&(i=n.onUpdate,sm(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=Cm(c||s),l=!0),c._flushSync=o;let u=Up,d=Gp,f=Wp,p=e._updating;Up=c,Gp=!1,e._updating=!0,Wp=e;let m=e._headless||e.getRootElement()===null;Ym(null);try{l&&(m?s._selection!==null&&(c._selection=s._selection.clone()):c._selection=function(e,t){let n=e.getEditorState()._selection,r=ug($h(e));return H(n)||n==null?Ep(n,r,e,t):n.clone()}(e,n&&n.event||null));let r=e._compositionKey;t(),a=mm(e,a),function(e,t){let n=t.getEditorState()._selection,r=e._selection;if(H(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);V(t)&&t.isAttached()&&t.isSimpleText()&&!t.isUnmergeable()&&Ql(t)}}(c,e):function(e,t){let n=t._dirtyLeaves,r=t._dirtyElements,i=e._nodeMap,a=gh(),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);V(r)&&r.isAttached()&&r.isSimpleText()&&!r.isUnmergeable()&&Ql(r),r!==void 0&&om(r,a)&&am(t,r,o),n.add(e)}if(s=t._dirtyLeaves,c=s.size,c>0){Yp++;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&&om(c,a)&&am(t,c,o)}s=t._dirtyLeaves,c=s.size,l=t._dirtyElements,u=l.size,Yp++}t._dirtyLeaves=n,t._dirtyElements=r}(c,e),mm(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()||(G(t)&&Dl(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()||(s_(t)&&t.__slots!==null&&Dl(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=W(),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(H(i)){e._slotsUsed&&bp(i);let t=c._nodeMap,n=i.anchor.key,r=i.focus.key;t.get(n)!==void 0&&t.get(r)!==void 0||L(19)}else ip(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(),um(e);return}finally{Up=u,Gp=d,Wp=f,e._updating=p,Yp=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,um(e)):l&&eh(()=>{um(e)}):(c._flushSync=!1,l&&(r.clear(),e._deferred=[],e._pendingEditorState=null))}function gm(e,t,n){Wp===e&&n===void 0?Zp()?hm(e,t,n):t():hm(e,t,n)}function _m(e){if(rg(e)){let t=null;for(let n of e.getChildren())t=n.isInline()?(t||n.replace(n.createParentElementNode())).append(n):null}}var vm=class extends yf{__first;__last;__size;__format;__style;__indent;__dir;__textFormat;__textStyle;__slotHost;__slots;$config(){return this.config(Symbol.for(`ElementNode`),{$transform:_m,extends:yf})}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&&L(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 fl[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&&m_(this).length===0}isDirty(){let e=W()._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 m_(this)){let n=h_(this,t);G(n)&&e.push(...n.getAllTextNodes())}let t=this.getFirstChild();for(;t!==null;){if(V(t)&&e.push(t),G(t)){let n=t.getAllTextNodes();e.push(...n)}t=t.getNextSibling()}return e}getFirstDescendant(){let e=this.getFirstChild();for(;G(e);){let t=e.getFirstChild();if(t===null)break;e=t}return e}getLastDescendant(){let e=this.getLastChild();for(;G(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 G(e)&&e.getLastDescendant()||e||null}let r=t[e];return G(r)&&r.getFirstDescendant()||r||null}getFirstChild(){let e=this.getLatest().__first;return e===null?null:_h(e)}getFirstChildOrThrow(){let e=this.getFirstChild();return e===null&&L(45,this.__key),e}getLastChild(){let e=this.getLatest().__last;return e===null?null:_h(e)}getLastChildOrThrow(){let e=this.getLastChild();return e===null&&L(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=S_(this),t=this.getChildren(),n=t.length;for(let r=0;r<n;r++){let i=t[r];e+=i.getTextContent(),G(i)&&r!==n-1&&!i.isInline()&&(e+=`
|
|
151
|
+
`?t.linebreak():n===` `?t.tab():n!==``&&t.text(n)}function zp(e){let t=[];return Rp(e,{linebreak:()=>t.push(Pm()),tab:()=>t.push(Xf()),text:e=>t.push(qf(e))}),t}function Bp(e){let t=[];for(let n of e)Fm(n)||(!G(n)&&!K(n)||n.isInline()?t.push(n):G(n)&&t.push(...Bp(n.getChildren())));return t}function Vp(e){let t=e;e.isCollapsed()||t.removeText();let n=U();H(n)&&(t=n),H(t)||L(161);let r=t.anchor,i=r.getNode(),a=r.offset;for(;!Ig(i)&&f_(i)===null;){let e=i;if([i,a]=Hp(i,a),e.is(i))break}return a}function Hp(e,t){let n=e.getParent();if(!n){let e=Vm();return Dh().append(e),e.select(),[Dh(),0]}if(V(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(!G(e)||t===0)return[n,e.getIndexWithinParent()];let r=e.getChildAtIndex(t);if(r){let n=new op($f(e.__key,t,`element`),$f(e.__key,t,`element`),0,``),i=e.insertNewAfter(n);i&&i.append(r,...r.getNextSiblings())}return[n,e.getIndexWithinParent()+1]}function Up(e){return Fm(e)||rg(e)||V(e)||e.isParentRequired()}function Wp(e){let t=Vm(),n=null;for(let r=0;r<e.length;r++){let i=e[r];if(Up(i)){if(n===null){n=i.createParentElementNode(),t.append(n);let a=e[r+1];if(Fm(i)&&(a===void 0||!Up(a)))continue}n.append(i)}else t.append(i),n=null}return t}function Gp(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=lv(e.focus,n?`previous`:`next`),o=r===`lineboundary`,s=t===`move`,c=a,l=i===`decorators-and-blocks`;if(!yv(c)){for(let e of c){l=!1;let{origin:t}=e;if(!K(t)||t.isIsolated()||(c=e,!o||!t.isInline()))break}if(l)for(let e of ev(a).iterNodeCarets(t===`extend`?`shadowRoot`:`root`)){if(V_(e))e.origin.isInline()||(c=e);else{if(G(e.origin))continue;K(e.origin)&&!e.origin.isInline()&&(c=e)}break}}if(c===a)return!1;if(s&&!o&&K(c.origin)&&c.origin.isKeyboardSelectable()){let e=Op();return e.add(c.origin.getKey()),Oh(e),!0}return c=vv(c),s&&uv(e.anchor,c),uv(e.focus,c),l||!o}let Kp=null,qp=null,Jp=!1,Yp=!1,Xp=!1,Zp=/* @__PURE__ */ new Set,Qp=0,$p={characterData:!0,childList:!0,subtree:!0};function em(){return Jp||Kp!==null&&Kp._readOnly}function tm(){Jp&&L(13)}function nm(){Qp>99&&L(14)}function rm(){return Kp===null&&L(195,om()),Kp}function im(e){rm()!==null&&qp===null&&(qp=e),qp!==e&&Xc(378)}function W(){return qp===null&&L(337,om()),qp}function am(){W()._dirtyType=2}function om(){let e=0,t=/* @__PURE__ */ new Set,n=Xm.version;if(typeof window<`u`)for(let r of vg(document)){let i=ch(r);if(oh(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 sm(){return qp}function cm(e,t,n){let r=t.__type,i=th(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 lm(e,t){return e!==void 0&&e.__key!==t&&e.isAttached()}function um(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 dm(e,t){let n=e.type,r=t.get(n);r===void 0&&L(17,n);let i=r.klass;e.type!==i.getType()&&L(18,i.name);let a=i.importJSON(e),o=e.children;if(G(a)&&Array.isArray(o))for(let e=0;e<o.length;e++){let n=dm(o[e],t);a.append(n)}let s=e.$slots;if(s){u_(a)||L(379,i.name);for(let e in s)O_(a,e,dm(s[e],t))}return a}function fm(e,t,n){let r=Kp,i=Jp,a=qp;Kp=t,Jp=!0,qp=e;try{return n()}finally{Kp=r,Jp=i,qp=a}}function pm(e,t){let n=Xp;Xp=!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&&gm(e,e._deferred));let a=e._editorState,o=a._selection,s=n._selection,c=e._dirtyType!==0,l=Kp,u=Jp,d=qp,f=e._updating,p=e._observer,m=null;if(e._pendingEditorState=null,e._editorState=n,!i&&c&&p!==null){qp=e,Kp=n,Jp=!1,e._updating=!0;try{let t=e._dirtyType,r=e._dirtyElements,i=e._dirtyLeaves;p.disconnect(),m=Yu(a,n,e,t,r,i)}catch(t){if(t instanceof Error&&e._onError(t),Yp)throw t;Wm(e,null,r,n),Bl(e),e._dirtyType=2,Yp=!0,pm(e,a),Yp=!1;return}finally{p.observe(r,$p),e._updating=f,Kp=l,Jp=u,qp=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=Th(e)),delete r[a])}(e,n);let y=i?null:pg(ng(e));if(e._editable&&y!==null&&(c||s===null||s.dirty||!s.is(o))&&r!==null&&!v.has(`skip-dom-selection`)){qp=e,Kp=n;try{if(p!==null&&p.disconnect(),c||s===null||s.dirty){let t=e._blockCursorElement;t!==null&&fg(t,e,r),Lp(o,s,e,y,v,r)}(function(e,t,n){let r=e._blockCursorElement;if(H(n)&&n.isCollapsed()&&n.anchor.type===`element`&&t.contains(Dg(t))){let i=n.anchor,a=i.getNode(),o=i.offset,s=!1,c=null;if(o===a.getChildrenSize())dg(a.getChildAtIndex(o-1))&&(s=!0);else{let t=a.getChildAtIndex(o);if(t!==null&&dg(t)){let n=t.getPreviousSibling();(n===null||dg(n))&&(s=!0,c=e.getElementByKey(t.__key))}}if(s){let n=zg(a,e.getElementByKey(a.__key),e).element;r===null&&(e._blockCursorElement=r=function(e){let t=e.theme,n=bg().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=Av(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&&fg(r,e,t)})(e,r,s)}finally{p!==null&&p.observe(r,$p),qp=d,Kp=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),H(s)||s===null||o!==null&&o.is(s)||e.dispatchCommand(Zu);let ee=e._pendingDecorators;ee!==null&&(e._decorators=ee,e._pendingDecorators=null,mm(`decorator`,e,!0,ee)),function(e,t,n){let r=Eh(t),i=Eh(n);r!==i&&mm(`textcontent`,e,!0,i)}(e,t||a,n),mm(`update`,e,!0,{dirtyElements:g,dirtyLeaves:h,editorState:n,mutatedNodes:m,normalizedNodes:_,prevEditorState:t||a,tags:v}),!f&&gm(e,e._deferred),(function(e){let t=e._updates;if(t.length===0)return void(e._cascadeCount=0);if(function(e){Zp.has(e)||(Zp.add(e),setTimeout(()=>{Zp.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;vm(e,t,r)}})(e)})(e,t)}finally{Xp=n}}function mm(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 hm(e,t,n,r){let i=Mh(e),a;if(!Xp)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(ym(s,()=>{for(let i of t)if(i(n,r))return void(e=!0)}),e)return e}}}return a&&a.update(()=>{hm(a,t,n,r)}),!1}function gm(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 _m(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&&L(191),a._flushSync=!0),o&&e._deferred.push(o),um(e,i.tag)),a==null?vm(e,n,i):n()}}return r}function vm(e,t,n){let r=e._updateTags,i,a=!1,o=!1;n!==void 0&&(i=n.onUpdate,um(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=Em(c||s),l=!0),c._flushSync=o;let u=Kp,d=Jp,f=qp,p=e._updating;Kp=c,Jp=!1,e._updating=!0,qp=e;let m=e._headless||e.getRootElement()===null;Qm(null);try{l&&(m?s._selection!==null&&(c._selection=s._selection.clone()):c._selection=function(e,t){let n=e.getEditorState()._selection,r=pg(ng(e));return H(n)||n==null?kp(n,r,e,t):n.clone()}(e,n&&n.event||null));let r=e._compositionKey;t(),a=_m(e,a),function(e,t){let n=t.getEditorState()._selection,r=e._selection;if(H(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);V(t)&&t.isAttached()&&t.isSimpleText()&&!t.isUnmergeable()&&tu(t)}}(c,e):function(e,t){let n=t._dirtyLeaves,r=t._dirtyElements,i=e._nodeMap,a=yh(),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);V(r)&&r.isAttached()&&r.isSimpleText()&&!r.isUnmergeable()&&tu(r),r!==void 0&&lm(r,a)&&cm(t,r,o),n.add(e)}if(s=t._dirtyLeaves,c=s.size,c>0){Qp++;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&&lm(c,a)&&cm(t,c,o)}s=t._dirtyLeaves,c=s.size,l=t._dirtyElements,u=l.size,Qp++}t._dirtyLeaves=n,t._dirtyElements=r}(c,e),_m(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()||(G(t)&&Al(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()||(u_(t)&&t.__slots!==null&&Al(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=W(),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(H(i)){e._slotsUsed&&Cp(i);let t=c._nodeMap,n=i.anchor.key,r=i.focus.key;t.get(n)!==void 0&&t.get(r)!==void 0||L(19)}else sp(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(),pm(e);return}finally{Kp=u,Jp=d,qp=f,e._updating=p,Qp=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,pm(e)):l&&rh(()=>{pm(e)}):(c._flushSync=!1,l&&(r.clear(),e._deferred=[],e._pendingEditorState=null))}function ym(e,t,n){qp===e&&n===void 0?em()?vm(e,t,n):t():vm(e,t,n)}function bm(e){if(og(e)){let t=null;for(let n of e.getChildren())t=n.isInline()?(t||n.replace(n.createParentElementNode())).append(n):null}}var xm=class extends Sf{__first;__last;__size;__format;__style;__indent;__dir;__textFormat;__textStyle;__slotHost;__slots;$config(){return this.config(Symbol.for(`ElementNode`),{$transform:bm,extends:Sf})}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&&L(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 hl[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&&__(this).length===0}isDirty(){let e=W()._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 __(this)){let n=v_(this,t);G(n)&&e.push(...n.getAllTextNodes())}let t=this.getFirstChild();for(;t!==null;){if(V(t)&&e.push(t),G(t)){let n=t.getAllTextNodes();e.push(...n)}t=t.getNextSibling()}return e}getFirstDescendant(){let e=this.getFirstChild();for(;G(e);){let t=e.getFirstChild();if(t===null)break;e=t}return e}getLastDescendant(){let e=this.getLastChild();for(;G(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 G(e)&&e.getLastDescendant()||e||null}let r=t[e];return G(r)&&r.getFirstDescendant()||r||null}getFirstChild(){let e=this.getLatest().__first;return e===null?null:bh(e)}getFirstChildOrThrow(){let e=this.getFirstChild();return e===null&&L(45,this.__key),e}getLastChild(){let e=this.getLatest().__last;return e===null?null:bh(e)}getLastChildOrThrow(){let e=this.getLastChild();return e===null&&L(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=T_(this),t=this.getChildren(),n=t.length;for(let r=0;r<n;r++){let i=t[r];e+=i.getTextContent(),G(i)&&r!==n-1&&!i.isInline()&&(e+=`
|
|
152
152
|
|
|
153
|
-
`)}return e}getTextContentSize(){let e=function(e){let t=0;for(let n of
|
|
154
|
-
`}createDOM(){return _g().createElement(`br`)}updateDOM(){return!1}isInline(){return!0}};function Am(e){return{node:jm()}}function jm(){return ag(new km)}function Mm(e){return e instanceof km}function Nm(e){let t=e.parentElement;if(t!==null&&Mg(t)){let n=t.firstChild;if(n===e||n.nextSibling===e&&Fm(n)){let n=t.lastChild;if(n===e||n.previousSibling===e&&Fm(n))return!0}}return!1}function Pm(e){let t=e.parentElement;if(t!==null&&Mg(t)){let n=t.firstChild;if(n===e||n.nextSibling===e&&Fm(n))return!1;let r=t.lastChild;if(r===e||r.previousSibling===e&&Fm(r))return!0}return!1}function Fm(e){return ch(e)&&/^( |\t|\r?\n)+$/.test(e.textContent||``)}var Im=class extends vm{$config(){return this.config(`paragraph`,{extends:vm,importDOM:{p:()=>({conversion:Lm,priority:0})}})}createDOM(e){let t=_g().createElement(`p`),n=Vh(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(Y(t)){this.isEmpty()&&t.append(_g().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(V);t?(e.textFormat=t.getFormat(),e.textStyle=t.getStyle()):(e.textFormat=this.getTextFormat(),e.textStyle=this.getTextStyle())}return e}insertNewAfter(e,t){let n=Rm();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||V(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 Lm(e){let t=Rm();if(Kg(t,e),Wg(e,t),t.getFormatType()===``){let n=e.getAttribute(`align`);n&&n&&n in dl&&t.setFormat(n)}return Gg(t,e),{node:t}}function Rm(){return ag(new Im)}function zm(e){return e instanceof Im}function Bm(e){console.warn(e)}function Vm(e,t,n,r,i){let a=e._keyToDOMMap;a.clear(),e._editorState=wm(),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),yh(n,e,`root`))}function Hm(e){let t=/* @__PURE__ */ new Set,n=/* @__PURE__ */ new Set;for(let{klass:r,ownNodeConfig:i}of t_(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 Um={$createDOM:(e,t)=>e.createDOM(t._config,t),$decorateDOM:(e,t,n,r)=>{},$exportDOM:(e,t)=>{let n=$m(t,e.getType());return n&&n.exportDOM!==void 0?n.exportDOM(t,e):e.exportDOM(t)},$extractWithChild:(e,t,n,r,i)=>G(e)&&e.extractWithChild(t,n,r),$getDOMSlot:(e,t,n)=>e.getDOMSlot(t),$getSlotTargetElement:(e,t,n,r)=>null,$shouldExclude:(e,t,n)=>G(e)&&e.excludeFromCopy(`html`),$shouldInclude:(e,t,n)=>!t||e.isSelected(t),$updateDOM:(e,t,n,r)=>e.updateDOM(t,n,r._config)};function Wm(e){let t=e||{},n=im(),r=t.theme||{},i=e===void 0?n:t.parentEditor||null,a=t.disableEvents||!1,o=wm(),s=t.namespace||(i===null?Ah():i._config.namespace),c=t.editorState,l=[xm,Ff,km,Kf,Im,Om,...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===yf||n.prototype instanceof yf)){let r=`<unknown>`;try{r=JSON.parse(Cl)}catch{}L(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))}e_(n);let a=n.getType(),o=Hm(n);m.set(a,{exportDOM:f&&f.export?f.export.get(n):void 0,klass:n,replace:r,replaceWithKlass:i,sharedNodeState:Bl(l[e]),transforms:o})}}let h=new qm(o,i,m,{disableEvents:a,dom:{...Um,...e&&e.dom},namespace:s,theme:r},u||console.error,d||Bm,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(Xu,tf,0),e.registerCommand(Zu,nf,0),e.registerCommand(Qu,rf,0),e.registerCommand($u,af,0),e.registerCommand(dd,cf,0)}(h),h}function Gm(e,t){let n=e.get(t);e.delete(t),n&&n()}function Km(e,t,n){return e.set(t,n),Gm.bind(null,e,t)}var qm=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 El,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=Ah(),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 Km(this._listeners.update,e)}registerEditableListener(e){return Km(this._listeners.editable,e)}registerDecoratorListener(e){return Km(this._listeners.decorator,e)}registerTextContentListener(e){return Km(this._listeners.textcontent,e)}registerRootListener(e){let t=this._listeners.root;return kv(Km(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&&L(35);let r=this._commands;r.has(e)||r.set(e,[new wl,new wl,new wl,new wl,new wl]);let i=r.get(e);i===void 0&&L(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&&L(37,e.name),t}resolveRegisteredNodeAfterReplacements(e){for(;e.replaceWithKlass;)e=this.getRegisteredNode(e.replaceWithKlass);return e}initializeMutationListener(e,t){let n=this._editorState,r=Vg(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=Vg(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=_h(t);e&&e.markDirty()}},e._pendingEditorState===null?{tag:xf}: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 J(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=Vh(this._config.theme,`root`),r=this._pendingEditorState||this._editorState;if(this._rootElement=e,Vm(this,t,e,r,{preserveUpdateQueue:!0}),t!==null&&(this._config.disableEvents||mf(t),n!=null&&t.classList.remove(...n)),e!==null){let t=Qh(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,Ll(this),this._updateTags.add(xf),um(this),this._config.disableEvents||function(e,t){let n=e.ownerDocument;Hd.set(e,n);let r=Ud.get(n);r===void 0&&(r={editors:/* @__PURE__ */ new Set,hasShadowEditor:void 0},Ud.set(n,r)),r.editors.add(t),r.hasShadowEditor=void 0,e.__lexicalEditor=t;let i=lf(e);i.push(Wd.register(n));for(let n=0;n<Vd.length;n++){let[r,a]=Vd[n],o=typeof a==`function`?e=>{pf(e)||(ff(e),(t.isEditable()||r===`click`)&&a(e,t))}:e=>{if(pf(e))return;ff(e);let n=t.isEditable();switch(r){case`cut`:return n&&J(t,kd,e);case`copy`:return J(t,Od,e);case`paste`:return n&&J(t,id,e);case`dragstart`:return n&&J(t,Td,e);case`dragover`:return n&&J(t,Ed,e);case`dragend`:return n&&J(t,Dd,e);case`focus`:return n&&J(t,Fd,e);case`blur`:return n&&J(t,Id,e);case`drop`:return n&&J(t,wd,e)}};i.push(zd(e,r,o))}}(e,this),n!=null&&e.classList.add(...n)}else this._window=null,this._updateTags.add(xf),um(this);dm(`root`,this,!1,e,t)}}getElementByKey(e){return this._keyToDOMMap.get(e)||null}getEditorState(){return this._editorState}setEditorState(e,t){e.isEmpty()&&L(38);let n=e;n._readOnly&&(n=Cm(e),n._selection=e._selection?e._selection.clone():null),Il(this);let r=this._pendingEditorState,i=t===void 0?null:t.tag;r===null||r.isEmpty()||(i!=null&&this._updateTags.add(i),um(this)),this._pendingEditorState=n,this._dirtyType=2,this._dirtyElements.set(`root`,!1),this._compositionKey=null,this._slotsUsed=this._slotsUsed||e._slotsUsed,gm(this,()=>{if(i&&this._updateTags.add(i),e._parsed)for(let[e,t]of n._nodeMap.entries())G(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=wm(),i=Up,a=Gp,o=Wp,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,Up=r,Gp=!1,Wp=t,Ym(null);try{let i=t._nodes;cm(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,Up=i,Gp=a,Wp=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`&&um(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]):hm(e,t,n)})(this,e,t)}focus(e,t={}){let n=this._rootElement;n!==null&&(n.setAttribute(`autocapitalize`,`off`),gm(this,()=>{let r=U(),i=wh();r===null?i.getChildrenSize()!==0&&(t.defaultSelection===`rootStart`?i.selectStart():i.selectEnd()):r.dirty||Th(r.clone()),Yh(`focus`),Xh(()=>{n.removeAttribute(`autocapitalize`),e&&e()})}),this._pendingEditorState===null&&n.removeAttribute(`autocapitalize`))}blur(){let e=this._rootElement;e!==null&&e.blur();let t=ug(this._window);t!==null&&t.removeAllRanges()}isEditable(){return this._editable}setEditable(e){this._editable!==e&&(this._editable=e,dm(`editable`,this,!0,e),this._slotsUsed&&this.update(()=>nm()))}toJSON(){return{editorState:this._editorState.toJSON()}}};qm.version=Cl;let Jm=null;function Ym(e){Jm=e}let Xm=Symbol(`INTERNAL_SKIP_AFTER_CLONE_FROM`),Zm=1;function Qm(e,t){let n=$m(e,t);return n===void 0&&L(30,t),n}function $m(e,t){return e._nodes.get(t)}let eh=typeof queueMicrotask==`function`?queueMicrotask:e=>{Promise.resolve().then(e)};function th(e,t){let n=t===void 0?(()=>{let t=e.getRootNode();return lh(t)||fg(t)?Tg(t):null})():t;if(!Y(n)||n.hasAttribute(`data-lexical-slot`))return!1;let r=xh(n),i=n.nodeName;return bf(r)&&(i===`INPUT`||i===`TEXTAREA`||n.contentEditable===`true`&&ah(n)==null)}function nh(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 ih(t)===e&&e.read(`latest`,()=>!th(t))}function rh(e){return e instanceof qm}function ih(e){let t=e;for(;t!=null;){let e=ah(t);if(rh(e))return e;t=qh(t)}return null}function ah(e){return e?e.__lexicalEditor:null}function oh(e){return Jf(e)||e.isToken()}function sh(e){return oh(e)||e.isSegmented()}function ch(e){return Dg(e)&&e.nodeType===3}function lh(e){return Dg(e)&&e.nodeType===9}function uh(e){let t=e;for(;t!=null;){if(ch(t))return t;t=t.firstChild}return null}function dh(e,t,n){let r=ll[t];if(n!==null&&(e&r)===(n&r))return e;let i=e^r;return t===`subscript`?i&=~ll.superscript:t===`superscript`?i&=~ll.subscript:t===`lowercase`?(i&=~ll.uppercase,i&=~ll.capitalize):t===`uppercase`?(i&=~ll.lowercase,i&=~ll.capitalize):t===`capitalize`&&(i&=~ll.lowercase,i&=~ll.uppercase),i}function fh(e,t){let n=function(){let e=Jm;return Jm=null,e}();if((t||=n&&n.__key)!=null)return void(e.__key=t);Qp(),$p();let r=W(),i=em(),a=``+Zm++;i._nodeMap.set(a,e),G(e)?r._dirtyElements.set(a,!0):r._dirtyLeaves.add(a),r._cloneNotNeeded.add(a),r._dirtyType===0&&(r._dirtyType=1),e.__key=a}function ph(e){l_(e)!==null&&L(380,e.__key,String(l_(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 mh(e){$p(),_f(e)&&L(323,e.__key,e.__type);let t=e.getLatest(),n=t.__parent===null?c_(t)?t.__slotHost:null:t.__parent,r=em(),i=W(),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?c_(e)?e.__slotHost:null:e.__parent}}(n,a,o);let s=t.__key;i._dirtyType===0&&(i._dirtyType=1),G(e)?o.set(s,!0):i._dirtyLeaves.add(s)}function hh(e){Qp();let t=W(),n=t._compositionKey;if(e!==n){if(t._compositionKey=e,n!==null){let e=_h(n);e!==null&&e.getWritable()}if(e!==null){let t=_h(e);t!==null&&t.getWritable()}}}function gh(){return Zp()?null:W()._compositionKey}function _h(e,t){let n=(t||em())._nodeMap.get(e);return n===void 0?null:n}function vh(e,t){let n=bh(e,W());return n===void 0?null:_h(n,t)}function yh(e,t,n){e[`__lexicalKey_${t._key}`]=n}function bh(e,t){return e[`__lexicalKey_${t._key}`]}function xh(e,t){let n=e;for(;n!=null;){let e=vh(n,t);if(e!==null)return e;n=qh(n)}return null}function Sh(e){let t=e._decorators,n=Object.assign({},t);return e._pendingDecorators=n,n}function Ch(e){return e.read(()=>wh().getTextContent())}function wh(){return em()._nodeMap.get(`root`)}function Th(e){Qp();let t=em();e!==null&&(e.dirty=!0,e.setCachedNodes(null),H(e)&&W()._slotsUsed&&bp(e)),t._selection=e}function Eh(){Qp(),Il(W())}function Dh(e){let t=function(e,t){let n=e;for(;n!=null;){let e=bh(n,t);if(e!==void 0)return e;n=qh(n)}return null}(e,W());return t===null?null:_h(t)}function Oh(e){return/[\uD800-\uDBFF][\uDC00-\uDFFF]/g.test(e)}function kh(e){let t=[];for(let n=e;n!==null;n=n._parentEditor)t.push(n);return t}function Ah(){return Math.random().toString(36).replace(/[^a-z]+/g,``).substring(0,5)}function jh(e){return ch(e)?e.nodeValue:null}function Mh(e,t,n){let r=ug($h(t));if(r===null)return;let i=bg(r,t._rootElement),a=i.anchorNode,{anchorOffset:o,focusOffset:s}=i;if(a!==null){let t=jh(a),r=xh(a);if(t!==null&&V(r)){if((t===al||t===ol)&&n){let e=n.length;t=n,o=e,s=e}t!==null&&Nh(r,t,o,s,e)}}}function Nh(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(al)&&(s=t.slice(0,-al.length)),i)){let e=ol,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=U();if(s===``){if(hh(null),tl||$c||il)a.remove();else{let e=W();Ph(a,``,t),setTimeout(()=>{e.update(()=>{a.isAttached()&&a.getTextContent()===``&&a.remove()})},20)}return}let i=a.getParent(),c=Dp(),l=a.getTextContentSize(),u=gh(),d=a.getKey();if(a.isToken()&&!o||u!==null&&d===u&&!o||H(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(!H(t)||n===null||r===null)return void Ph(a,s,t);if(t.setTextNodeRange(a,n,a,r),a.isSegmented()){let e=Wf(a.getTextContent());a.replace(e),a=e}Ph(a,s,t)}}}function Ph(e,t,n){if(e.setTextContent(t),H(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=W_(e,a.offset,`clamp`),r=!0)}r&&(n._cachedNodes=null,n._cachedIsBackward=null)}}function Fh(e,t,n){let r=t[n]||!1;return r===`any`||r===e[n]}function Ih(e,t){return Fh(e,t,`altKey`)&&Fh(e,t,`ctrlKey`)&&Fh(e,t,`shiftKey`)&&Fh(e,t,`metaKey`)}function q(e,t,n){if(!Ih(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 Lh={ctrlKey:!Xc,metaKey:Xc},Rh={altKey:Xc,ctrlKey:!Xc};function zh(e){return e.key===`Backspace`}function Bh(e){let t=wh();if(H(e)){let t=e.anchor,n=e.focus,r=t.getNode();if(Sm(r))return t.set(r.getKey(),0,`element`),n.set(r.getKey(),r.getChildrenSize(),`element`),$l(e),e;let i=r.getTopLevelElementOrThrow(),a=i.getParent();if(a===null)return G(i)&&(t.set(i.getKey(),0,`element`),n.set(i.getKey(),i.getChildrenSize(),`element`),$l(e)),e;let o=a;return t.set(o.getKey(),0,`element`),n.set(o.getKey(),o.getChildrenSize(),`element`),$l(e),e}{let e=t.select(0,t.getChildrenSize());return Th($l(e)),e}}function Vh(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=Dv(i);return n[t]=e,e}return i}function Hh(e,t,n,r,i){if(n.size===0)return;let a=r.__type,o=r.__key,s=t.get(a);s===void 0&&L(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 Uh(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 Wh(e,t){let n=e.offset;if(e.type===`element`)return Uh(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?Uh(r.getParentOrThrow(),t,r.getIndexWithinParent()+ +!t):e}}return null}function Gh(e){let t=$h(e).event,n=t&&t.inputType;return n===`insertFromPaste`||n===`insertFromPasteAsQuotation`}function J(e,t,...n){return fm(e,t,n[0],e)}function Kh(e,t){let n=e._keyToDOMMap.get(t);return n===void 0&&L(75,t),n}function qh(e){let t=e.assignedSlot||e.parentElement;if(t!==null)return t;let n=e.parentNode;return fg(n)?n.host:null}function Jh(e){return lh(e)?e:Y(e)?e.ownerDocument:null}function Yh(e){Qp(),W()._updateTags.add(e)}function Xh(e){Qp(),W()._deferred.push(e)}function Zh(e,t){let n=e.getParent();for(;n!==null;){if(n.is(t))return!0;n=n.getParent()}return!1}function Qh(e){let t=Jh(e);return t?t.defaultView:null}function $h(e){let t=e._window;return t===null&&L(78),t}function eg(e){return G(e)&&e.isInline()||K(e)&&e.isInline()}function tg(e){let t=e.getLatest();for(;t!==null;){if(l_(t)!==null&&G(t))return t;let e=t.getParentOrThrow();if(rg(e))return e;t=e}return t}function ng(e){return G(e)&&e.isShadowRoot()}function rg(e){return Sm(e)||ng(e)}function ig(e,t=!1){let n=e.constructor.clone(e,Xm);return fh(n,null),n.afterCloneFrom(e),t||n.resetOnCopyNodeFrom(e),n}function ag(e){let t=W(),n=e.getType(),r=$m(t,n);r===void 0&&L(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||L(202,r.name,r.getType(),e.constructor.name,n):t instanceof a||L(201,a.name,a.getType(),r.name,r.getType(),e.constructor.name,n),t.__key===e.__key&&L(203,e.constructor.name,n,r.name,r.getType()),t}return e}function og(e,t){!Sm(e.getParent())||G(t)||K(t)||L(99)}function sg(e){let t=_h(e);return t===null&&L(63,e),t}function cg(e){if(!e||e.isInline())return!1;if(K(e))return!0;if(G(e)){if(e.isShadowRoot()){let t=e.getParent();return!(G(t)&&t.isShadowRoot())}return!e.canBeEmpty()}return!1}function lg(e,t,n){n.style.removeProperty(`caret-color`),t._blockCursorElement=null;let r=e.parentElement;r!==null&&r.removeChild(e)}function ug(e){return Jc?(e||window).getSelection():null}function dg(e){let t=Qh(e);return t?t.getSelection():null}function fg(e){return Og(e)&&`host`in e}let pg=[];function mg(e){let t=e.getRootNode();if(t===e||!fg(t))return pg;let n=[t],r=t.host;for(;;){let e=r.getRootNode();if(e===r||!fg(e))break;n.push(e),r=e.host}return n}function*hg(e){let t=[e],n;for(;n=t.pop();){yield*n.querySelectorAll(`[data-lexical-editor="true"]`);let e=(lh(n)?n:n.ownerDocument).createTreeWalker(n,NodeFilter.SHOW_ELEMENT),r;for(;r=e.nextNode();)r.shadowRoot&&t.push(r.shadowRoot)}}function gg(e){return e===null?document:e.ownerDocument}function _g(){let e=im();return gg(e===null?null:e._rootElement)}function vg(e,t){if(t===null||typeof e.getComposedRanges!=`function`)return null;let n=mg(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 yg(e,t){let n=vg(e,t);if(n!==null){let e=xg(n);if(e!==null)return e}return e.rangeCount>0?e.getRangeAt(0):null}function bg(e,t){let n=vg(e,t);return n===null?e:Sg(n,Cg(e))}function xg(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 Sg(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 Cg(e){return e.direction}function wg(e){let t=e.getRootNode();return lh(t)||fg(t)?t.activeElement:null}function Tg(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 Eg(e){let t=e.target;if(t!==null&&Y(t)&&t.shadowRoot!==null&&typeof e.composedPath==`function`){let t=e.composedPath();if(t.length>0)return t[0]}return t}function Y(e){return Dg(e)&&e.nodeType===1}function Dg(e){return typeof e==`object`&&!!e&&`nodeType`in e&&typeof e.nodeType==`number`}function Og(e){return Dg(e)&&e.nodeType===11}let kg=/^(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 Ag(e){return!(!Y(e)||!e.style.display.startsWith(`inline`))||kg.test(e.nodeName)}let jg=/^(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 Mg(e){return(!Y(e)||!e.style.display.startsWith(`inline`))&&jg.test(e.nodeName)}function Ng(e){if(K(e)&&!e.isInline())return!0;if(!G(e)||rg(e))return!1;let t=e.getFirstChild(),n=t===null||Mm(t)||V(t)||t.isInline();return!e.isInline()&&!1!==e.canBeEmpty()&&n}function Pg(){return W()}function Fg(e=Pg()){return e._config.dom||Um}function Ig(e,t,n=Pg()){let r=Fg(n).$getDOMSlot(e,t,n);return G(e)&&(Lg(r)||L(344,e.getKey(),e.getType())),r}function Lg(e){return e instanceof bl}function Rg(e,t,n=Pg()){return uh(Ig(e,t,n).element)}let zg=/* @__PURE__ */ new WeakMap,Bg=/* @__PURE__ */ new Map;function Vg(e){if(!e._readOnly&&e.isEmpty())return Bg;e._readOnly||L(192);let t=zg.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),zg.set(e,t)),t}function Hg(e){let t=e.constructor.clone(e,Xm);return t.afterCloneFrom(e),t}function Ug(e){return(t=Hg(e))[gf]=!0,t;var t}function Wg(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 Gg(e,t){let n=t.getAttribute(`dir`);return n===`ltr`||n===`rtl`?e.setDirection(n):e}function Kg(e,t){let n=t.style.textAlign;return n&&n in dl?e.setFormat(n):e}function qg(e,t){e.__lexicalUnmanaged=!0,t&&t.captureSelection!==void 0&&(e.__lexicalCapturedSelection=t.captureSelection)}function Jg(e){return!0===e.__lexicalUnmanaged}function Yg(e,t=Pg()){let n=t.isEditable();e.contentEditable=n?`true`:`false`,n?e.__lexicalEditor=t:delete e.__lexicalEditor}function Xg(e,t){let n=e;for(;n!=null;){if(!0===n.__lexicalCapturedSelection)return!0;if(Y(n)&&n.hasAttribute(`data-lexical-slot`)||bh(n,t)!==void 0)return!1;n=qh(n)}return!1}function Zg(e,t){return function(e,t){return Object.prototype.hasOwnProperty.call(e,t)}(e,t)&&e[t]!==yf[t]}let Qg=/* @__PURE__ */ new WeakMap,$g=Symbol(`lexical.synthesizedGetType`);function e_(e){let t=Qg.get(e);if(t)return t;let n=e.prototype!=null&&hl in e.prototype?e.prototype[hl]():void 0,r=function(e){if(!(e===yf||e.prototype instanceof yf)){let t=`<unknown>`,n=`<unknown>`;try{t=e.getType()}catch{}try{qm.version&&(n=JSON.parse(qm.version))}catch{}L(290,e.name,t,n)}return e===bm||e===vm||e===yf}(e),i=!r&&Zg(e,`getType`)?e.getType:void 0,a=i&&!($g 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(!Zg(e,`getType`)){let t=e,n=function(){return this===t?s:yf.getType.call(this)};n[$g]=!0,e.getType=n}if(Zg(e,`clone`)||(e.clone=(t,n)=>{Ym(t);let r=new e;return n!==Xm&&r.afterCloneFrom(t),r}),Zg(e,`importJSON`)||(e.importJSON=o&&o.$importJSON||(t=>new e().updateFromJSON(t))),!Zg(e,`importDOM`)&&o){let{importDOM:t}=o;t&&(e.importDOM=()=>t)}}let c={klass:e,ownNodeConfig:o,ownNodeType:s};return Qg.set(e,c),c}function*t_(e){for(let t=e;t&&(t===yf||bf(t.prototype));){let e=e_(t);yield e,t=e.ownNodeConfig&&e.ownNodeConfig.extends||a_(t)}}function n_(e){let t=Pg();return Qp(),new(t.resolveRegisteredNodeAfterReplacements(t.getRegisteredNode(e))).klass}let r_=(e,t)=>{let n=e;for(;n!=null&&!Sm(n);){if(t(n))return n;n=n.getParent()}return null};function i_(e,t){let n=[],r=e.__first;for(;r!==null;){let e=t===null?_h(r):t.get(r);e??L(174),n.push(r),r=e.__next}return n}function a_(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 o_=/* @__PURE__ */ new Map;function s_(e){return G(e)||K(e)}function c_(e){return G(e)||K(e)}function l_(e){let t=e.getLatest();return c_(t)?t.__slotHost:null}function u_(e){let t=l_(e);if(t===null)return null;let n=_h(t);return G(n)||K(n)||L(370),n}function d_(e){let t=u_(e);if(t===null)return null;let n=e.getLatest().__key;for(let[e,r]of p_(t))if(r===n)return e;return null}function f_(e){let t=e.getLatest();for(;t!==null;){if(l_(t)!==null)return t;t=t.getParent()}return null}function p_(e){let t=e.getLatest();return s_(t)&&t.__slots!==null?t.__slots:o_}function m_(e){return Array.from(p_(e).keys())}function h_(e,t){let n=p_(e).get(t);return n===void 0?null:_h(n)}let g_=[`__proto__`,`constructor`,`prototype`],__=Symbol(`slotMapOwner`);function v_(e){let t=e.__slots;return t!==null&&t[__]===e||(t=new Map(t),t[__]=e,e.__slots=t),t}let y_=/* @__PURE__ */ new WeakMap,b_=[];function x_(e){for(let{ownNodeConfig:t}of t_(e)){let e=t&&t.slots;if(e)return e}return b_}function S_(e){let t=``;for(let n of m_(e)){let r=h_(e,n);r!==null&&(t+=r.getTextContent())}return t}function C_(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 w_(e){let t=e.__slots;if(t===null||t.size<2)return;let n=function(e){let t=y_.get(e);if(t===void 0){let n=x_(e),r=/* @__PURE__ */ new Map;for(let t of n)g_.includes(t)&&L(371,e.name,t),r.has(t)&&L(372,e.name,t),r.set(t,r.size);t=r,y_.set(e,t)}return t}(e.constructor),r=null,i=!0;for(let e of t.keys()){if(r!==null&&C_(r,e,n)>0){i=!1;break}r=e}if(i)return;let a=Array.from(t).sort(([e],[t])=>C_(e,t,n));t.clear();for(let[e,n]of a)t.set(e,n)}function T_(e,t,n){t!==`__proto__`&&t!==`constructor`&&t!==`prototype`||L(373,t);let r=e.getLatest();if(r.__slots!==null&&r.__slots.get(t)===n.getLatest().__key)return r;(!G(n)&&!K(n)||n.isInline())&&L(374,n.__key);let i=e.getWritable(),a=v_(i),o=a.get(t);o!==void 0&&D_(o);let s=n.getWritable(),c=u_(s);if(c!==null){let e=d_(s);e!==null&&v_(c.getWritable()).delete(e),s.__slotHost=null}return ph(s),s.__slotHost=i.__key,a.set(t,s.__key),w_(i),function(){let e=Pg();e._slotsUsed=!0,e._pendingEditorState&&(e._pendingEditorState._slotsUsed=!0)}(),i}function E_(e,t){let n=e.getWritable();if(n.__slots===null)return n;let r=n.__slots.get(t);return r!==void 0&&(D_(r),v_(n).delete(t)),n}function D_(e){let t=_h(e);if(t===null)return;let n=t.getWritable();c_(n)||L(377,e),n.__slotHost=null,n.remove()}let O_={next:`previous`,previous:`next`};var k_=class{origin;constructor(e){this.origin=e}[Symbol.iterator](){return ev({hasNext:L_,initial:this.getAdjacentCaret(),map:e=>e,step:e=>e.getAdjacentCaret()})}getAdjacentCaret(){return H_(this.getNodeAtCaret(),this.direction)}getSiblingCaret(){return H_(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&&L(263,Array.from(o).join(` `))}else i.insert(e);i=H_(e,this.direction)}for(let e of o.values())e.remove();return this}},A_=class e extends k_{type=`child`;getLatest(){let e=this.origin.getLatest();return e===this.origin?this:K_(e,this.direction)}getParentCaret(e=`root`){return H_(N_(this.getParentAtCaret(),e),this.direction)}getFlipped(){let e=M_(this.direction);return H_(this.getNodeAtCaret(),e)||K_(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 j_={root:Sm,shadowRoot:rg};function M_(e){return O_[e]}function N_(e,t=`root`){return e===null||j_[t](e)?null:l_(e)===null?e:null}var P_=class e extends k_{type=`sibling`;getLatest(){let e=this.origin.getLatest();return e===this.origin?this:H_(e,this.direction)}getSiblingCaret(){return this}getParentAtCaret(){return this.origin.getParent()}getChildCaret(){return G(this.origin)?K_(this.origin,this.direction):null}getParentCaret(e=`root`){return H_(N_(this.getParentAtCaret(),e),this.direction)}getFlipped(){let e=M_(this.direction);return H_(this.getNodeAtCaret(),e)||K_(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 F_)&&this.direction===t.direction&&this.origin.is(t.origin)}},F_=class e extends k_{type=`text`;offset;constructor(e,t){super(e),this.offset=t}getLatest(){let e=this.origin.getLatest();return e===this.origin?this:U_(e,this.direction,this.offset)}getParentAtCaret(){return this.origin.getParent()}getChildCaret(){return null}getParentCaret(e=`root`){return H_(N_(this.getParentAtCaret(),e),this.direction)}getFlipped(){return U_(this.origin,M_(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 P_||t instanceof e)&&this.direction===t.direction&&this.origin.is(t.origin)}getSiblingCaret(){return H_(this.origin,this.direction)}};function I_(e){return e instanceof F_}function L_(e){return e instanceof P_}function R_(e){return e instanceof A_}let z_={next:class extends F_{direction=`next`;getNodeAtCaret(){return this.origin.getNextSibling()}insert(e){return this.origin.insertAfter(e),this}},previous:class extends F_{direction=`previous`;getNodeAtCaret(){return this.origin.getPreviousSibling()}insert(e){return this.origin.insertBefore(e),this}}},B_={next:class extends P_{direction=`next`;getNodeAtCaret(){return this.origin.getNextSibling()}insert(e){return this.origin.insertAfter(e),this}},previous:class extends P_{direction=`previous`;getNodeAtCaret(){return this.origin.getPreviousSibling()}insert(e){return this.origin.insertBefore(e),this}}},V_={next:class extends A_{direction=`next`;getNodeAtCaret(){return this.origin.getFirstChild()}insert(e){return this.origin.splice(0,0,[e]),this}},previous:class extends A_{direction=`previous`;getNodeAtCaret(){return this.origin.getLastChild()}insert(e){return this.origin.splice(this.origin.getChildrenSize(),0,[e]),this}}};function H_(e,t){return e?new B_[t](e):null}function U_(e,t,n){return e?new z_[t](e,W_(e,n)):null}function W_(e,t,n=`error`){let r=e.getTextContentSize(),i=t===`next`?r:t===`previous`?0:t;return(i<0||i>r)&&(n!==`clamp`&&qc(284,String(t),String(r),e.getKey()),i=i<0?0:r),i}function G_(e,t){return new X_(e,t)}function K_(e,t){return G(e)?new V_[t](e):null}function q_(e){return e&&e.getChildCaret()||e}function J_(e){return e&&q_(e.getAdjacentCaret())}var Y_=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 I_(t)?function(e,t){let{direction:n,origin:r}=e;return G_(e,W_(r,t===`focus`?M_(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[G_(e,r.offset-e.offset),null]}return[t,n]}iterNodeCarets(e=`root`){let t=I_(this.anchor)?this.anchor.getSiblingCaret():this.anchor.getLatest(),n=this.focus.getLatest(),r=I_(n),i=t=>t.isSameNodeCaret(n)?null:J_(t)||t.getParentCaret(e);return ev({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`)}},X_=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 U_(e.setTextContent(i.slice(0,n)+i.slice(r)),t,n)}};function Z_(e){return $_(e,H_(wh(),e.direction))}function Q_(e){return $_(e,e)}function $_(e,t){return e.direction!==t.direction&&L(265),new Y_(e,t,e.direction)}function ev(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 tv(e,t){let n=av(e.origin,t.origin);switch(n===null&&L(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 nv(n)}}function nv(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 rv(e,t){return t.is(e)}function iv(e){return G(e)?[e.getLatest(),null]:[e.getParent(),e.getLatest()]}function av(e,t){if(e.is(t))return{commonAncestor:e,type:`same`};let n=/* @__PURE__ */ new Map;for(let[t,r]=iv(e);t;r=t,t=t.getParent())n.set(t,r);for(let[r,i]=iv(t);r;i=r,r=r.getParent()){let a=n.get(r);if(a!==void 0)return a===null?(rv(e,r)||L(276),{commonAncestor:r,type:`ancestor`}):i===null?(rv(t,r)||L(277),{commonAncestor:r,type:`descendant`}):((G(a)||rv(e,a))&&(G(i)||rv(t,i))&&r.is(a.getParent())&&r.is(i.getParent())||L(278),{a,b:i,commonAncestor:r,type:`branch`})}return null}function ov(e,t){let{type:n,key:r,offset:i}=e,a=sg(e.key);return n===`text`?(V(a)||L(266,a.getType(),r),U_(a,t,i)):(G(a)||L(267,a.getType(),r),yv(a,e.offset,t))}function sv(e,t){let{origin:n,direction:r}=t,i=r===`next`;I_(t)?e.set(n.getKey(),t.offset,`text`):L_(t)?V(n)?e.set(n.getKey(),W_(n,r),`text`):e.set(n.getParentOrThrow().getKey(),n.getIndexWithinParent()+ +!!i,`element`):(R_(t)&&G(n)||L(268),e.set(n.getKey(),i?0:n.getChildrenSize(),`element`))}function cv(e){let t=U(),n=H(t)?t:wp();return lv(n,e),Th(n),n}function lv(e,t){sv(e.anchor,t.anchor),sv(e.focus,t.focus)}function uv(e){let{anchor:t,focus:n}=e,r=ov(t,`next`),i=ov(n,`next`),a=tv(r,i)<=0?`next`:`previous`;return $_(_v(r,a),_v(i,a))}function dv(e){let{direction:t,origin:n}=e,r=H_(n,M_(t)).getNodeAtCaret();return r?H_(r,t):K_(n.getParentOrThrow(),t)}function fv(e,t=`root`){let n=[e];for(let r=R_(e)?e.getParentCaret(t):e.getSiblingCaret();r!==null;r=r.getParentCaret(t))n.push(dv(r));return n}function pv(e){return!!e&&e.origin.isAttached()}function mv(e,t=`removeEmptySlices`){if(e.isCollapsed())return e;let n=`root`,r=`next`,i=t,a=vv(e,r),o=fv(a.anchor,n),s=fv(a.focus.getFlipped(),n),c=/* @__PURE__ */ new Set,l=[];for(let e of a.iterNodeCarets(n))if(R_(e))c.add(e.origin.getKey());else if(L_(e)){let{origin:t}=e;G(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),ph(e)}for(let e of u)!e.canBeEmpty()&&!rg(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=dv(H_(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=Wf(e.getTextContent()).setStyle(e.getStyle()).setFormat(e.getFormat());a.replaceOrInsert(n),t=U_(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(pv(e)){d=hv(e);break}for(let e of s)if(pv(e)){f=hv(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(rg(i))return;!n&&t(i)&&(n=i)}return n},u=l(a,Ng),d=u&&l(o,e=>n.has(e.getKey())&&Ng(e));return d&&m_(d).length>0?null:u&&d?[u,d]:null}(d,f,c);if(p){let[e,t]=p;K_(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(R_(e)){let t=e.origin;if(Ng(t))return t}else{let t=e.getParentAtCaret();if(t&&Ng(t))return t}return null}(f),t=e&&e.getParent(),n=e&&e.getParents().findLast(ng);if(e&&t&&!Sm(t)&&e.isEmpty()&&c.has(e.getKey())&&m_(e).length===0&&(!n||c.has(n.getKey()))){e.remove(!0);let n=t;for(;n&&!Sm(n)&&n.isEmpty();){let e=n.getParent();if(e&&Sm(e)&&e.getChildrenSize()<=1)break;let t=n;n=e,t.remove(!0)}}}let m=[d,f,...o,...s].find(pv);if(m)return Q_(_v(hv(m),e.direction));L(269,JSON.stringify(o.map(e=>e.origin.__key)))}function hv(e){let t=function(e){let t=e;for(;R_(t);){let e=J_(t);if(!R_(e))break;t=e}return t}(e.getLatest()),{direction:n}=t;if(V(t.origin))return I_(t)?t:U_(t.origin,n,n);let r=t.getAdjacentCaret();return L_(r)&&V(r.origin)?U_(r.origin,n,M_(n)):t}function gv(e){return I_(e)&&e.offset!==W_(e.origin,e.direction)}function _v(e,t){return e.direction===t?e:e.getFlipped()}function vv(e,t){return e.direction===t?e:$_(_v(e.focus,t),_v(e.anchor,t))}function yv(e,t,n){let r=K_(e,`next`);for(let e=0;e<t;e++){let e=r.getAdjacentCaret();if(e===null)break;r=e}return _v(r,n)}function bv(e){let{origin:t,offset:n,direction:r}=e;if(n===W_(t,r))return e.getSiblingCaret();if(n===W_(t,M_(r)))return dv(e.getSiblingCaret());let[i]=t.splitText(n);return V(i)||L(281),_v(H_(i,`next`),r)}function xv(e,t){return!0}function Sv(e,{$copyElementNode:t=ig,$splitTextPointCaretNext:n=bv,rootMode:r=`shadowRoot`,$shouldSplit:i=xv,removeEmptyDestination:a=!1}={}){if(I_(e))return n(e);let o=e.getParentCaret(r);if(o){let{origin:n}=o;if(R_(e)){let e=dv(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 Cv(e,t,n){let r=_v(t,`next`);I_(r)&&(r.offset===0?r=H_(r.origin,`previous`).getFlipped():r.offset===r.origin.getTextContentSize()&&(r=H_(r.origin,`next`))),r.origin.is(e)&&(L_(r)||L(342,e.getKey(),e.getType()),r=dv(r)),(e.is(r.getNodeAtCaret())||e.is(r.getFlipped().getNodeAtCaret()))&&e.remove(!0);for(let e=r;e;e=Sv(e,n))r=e;return I_(r)&&L(283),r.insert(e.isInline()?Rm().append(e):e),_v(H_(e.getLatest(),`next`),t.direction)}function wv(e){return e}function Tv(e){return e}function Ev(e,t){if(!t||e===t)return e;for(let n in t)if(e[n]!==t[n])return{...e,...t};return e}function Dv(...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 Ov(e,...t){let n=Dv(...t);n.length>0&&e.classList.add(...n)}function kv(...e){return()=>{for(let t=e.length-1;t>=0;t--)e[t]();e.length=0}}function Av(e){throw Error(`unreachable input event: ${JSON.stringify(e)}`)}function jv(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 Mv(e,t){return e.startsWith(t)||e===t.trimEnd()}var Nv=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 Av(e)}}onDraftChanged(e){return this.phase===`claimed`&&this.claim!==void 0&&!Mv(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:jv(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:jv(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&&Mv(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 Pv(e){let t=Pg().getElementByKey(e.getKey());if(t===null)return null;let n=t.ownerDocument.defaultView;return n===null?null:n.getComputedStyle(t)}function Fv(e){return Pv(Sm(e)?e:e.getParentOrThrow())}function Iv(e,t,n=`self`){let r=e.getStartEndPoints();if(t.isSelected(e)&&!sh(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]=cp(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=Ug(t)),t.__text=p)}}return t}function Lv(e){let t=Rv(e);return t!==null&&t.writingMode===`vertical-rl`}function Rv(e){let t=e.anchor.getNode();return G(t)?Pv(t):Fv(t)}function zv(e,t){let n=Lv(e)?!t:t;Vv(e)&&(n=!n);let r=ov(e.focus,n?`previous`:`next`);if(gv(r))return!1;if(I_(r)&&!Jf(r.origin)&&r.origin.isUnmergeable()){let e=r.getNodeAtCaret();if(V(e)&&!Jf(e))return!0}for(let e of Z_(r)){if(R_(e))return!e.origin.isInline();if(!G(e.origin)){if(K(e.origin))return!0;break}}return!1}function Bv(e,t,n,r){e.modify(t?`extend`:`move`,n,r)}function Vv(e){let t=Rv(e);return t!==null&&t.direction===`rtl`}function Hv(e,t,n){let r=Vv(e),i;i=Lv(e)||r?!n:n,Bv(e,t,i,`character`)}function Uv(e,t){return e!==null&&Object.getPrototypeOf(e).constructor.name===t.name}let Wv=Symbol.for(`preact-signals`);function Gv(){if(Yv>1)return void Yv--;let e,t=!1;for(function(){let e=Jv;for(Jv=void 0;e!==void 0;)e.S.v===e.v&&(e.S.i=e.i),e=e.o}();Kv!==void 0;){let n=Kv;for(Kv=void 0,Xv++;n!==void 0;){let r=n.u;if(n.u=void 0,n.f&=-3,!(8&n.f)&&ey(n))try{n.c()}catch(n){t||=(e=n,!0)}n=r}}if(Xv=0,Yv--,t)throw e}let X,Kv;function qv(e){let t=X;X=void 0;try{return e()}finally{X=t}}let Jv,Yv=0,Xv=0,Zv=0;function Qv(e){if(X===void 0)return;let t=e.n;return t===void 0||t.t!==X?(t={i:0,S:e,p:X.s,n:void 0,t:X,e:void 0,x:void 0,r:t},X.s!==void 0&&(X.s.n=t),X.s=t,e.n=t,32&X.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=X.s,t.n=void 0,X.s.n=t,X.s=t),t):void 0}function $v(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 ey(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 ty(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 ny(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 ry(e,t){$v.call(this,void 0),this.x=e,this.s=void 0,this.g=Zv-1,this.f=4,this.W=t?.watched,this.Z=t?.unwatched,this.name=t?.name}function iy(e){let t=e.m;if(e.m=void 0,typeof t==`function`){Yv++;let n=X;X=void 0;try{t()}catch(t){throw e.f&=-2,e.f|=8,ay(e),t}finally{X=n,Gv()}}}function ay(e){for(let t=e.s;t!==void 0;t=t.n)t.S.U(t);e.x=void 0,e.s=void 0,iy(e)}function oy(e){if(X!==this)throw Error(`Out-of-order effect`);ny(this),X=e,this.f&=-2,8&this.f&&ay(this),Gv()}function sy(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 cy(e,t){let n=new sy(e,t);try{n.c()}catch(e){throw n.d(),e}let r=n.d.bind(n);return r[Symbol.dispose]=r,r}$v.prototype.brand=Wv,$v.prototype.h=function(){return!0},$v.prototype.S=function(e){let t=this.t;t!==e&&e.e===void 0&&(e.x=t,this.t=e,t===void 0?qv(()=>{var e;(e=this.W)==null||e.call(this)}):t.e=e)},$v.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&&qv(()=>{var e;(e=this.Z)==null||e.call(this)}))}},$v.prototype.subscribe=function(e){return cy(()=>{let t=this.value,n=X;X=void 0;try{e(t)}finally{X=n}},{name:`sub`})},$v.prototype.valueOf=function(){return this.value},$v.prototype.toString=function(){return this.value+``},$v.prototype.toJSON=function(){return this.value},$v.prototype.peek=function(){let e=X;X=void 0;try{return this.value}finally{X=e}},Object.defineProperty($v.prototype,"value",{get(){let e=Qv(this);return e!==void 0&&(e.i=this.i),this.v},set(e){if(e!==this.v){if(Xv>100)throw Error(`Cycle detected`);(function(e){Yv!==0&&Xv===0&&e.l!==0&&(e.l=0,Jv={S:e,v:e.v,i:e.i,o:Jv})})(this),this.v=e,this.i++,Zv++,Yv++;try{for(let e=this.t;e!==void 0;e=e.x)e.t.N()}finally{Gv()}}}}),ry.prototype=new $v,ry.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===Zv))return!0;if(this.g=Zv,this.f|=1,this.i>0&&!ey(this))return this.f&=-2,!0;let e=X;try{ty(this),X=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 X=e,ny(this),this.f&=-2,!0},ry.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)}$v.prototype.S.call(this,e)},ry.prototype.U=function(e){if(this.t!==void 0&&($v.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)}},ry.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(ry.prototype,"value",{get(){if(1&this.f)throw Error(`Cycle detected`);let e=Qv(this);if(this.h(),e!==void 0&&(e.i=this.i),16&this.f)throw this.v;return this.v}}),sy.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()}},sy.prototype.S=function(){if(1&this.f)throw Error(`Cycle detected`);this.f|=1,this.f&=-9,iy(this),ty(this),Yv++;let e=X;return X=this,oy.bind(this,e)},sy.prototype.N=function(){2&this.f||(this.f|=2,this.u=Kv,Kv=this)},sy.prototype.d=function(){this.f|=8,1&this.f||ay(this)},sy.prototype.dispose=function(){this.d()};function ly(e){return(typeof e.nodes==`function`?e.nodes():e.nodes)||[]}function Z(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 uy;try{uy=`0.49.0+prod.esm`}catch{}let dy=uy??`"<unknown>+source"`,fy=/* @__PURE__ */ new Set([`__proto__`,`constructor`,`prototype`]);function py(e,t){if(e&&t&&!Array.isArray(t)&&typeof e==`object`&&typeof t==`object`){let n=e,r=t;for(let e in r)!fy.has(e)&&Object.prototype.hasOwnProperty.call(r,e)&&(n[e]=py(n[e],r[e]));return e}return t}function my(e){return e.id===0}function hy(e){return e.id===2}function gy(e){return function(e){return e.id===1}(e)||Z(305,String(e.id),`1`),Object.assign(e,{id:2})}let _y=/* @__PURE__ */ new Set;var vy=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):Ev;for(let n of this.configs)e=t(e,n);return e}init(e){let t=this.state;hy(t)||Z(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&&Z(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&&Z(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&&Z(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&&Z(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&&Z(311),this._signal}getInitResult(){this.extension.init===void 0&&Z(312,this.extension.name);let e=this.state;return function(e){return e.id>=4}(e)||Z(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)||Z(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&&Z(315,this.extension.name,e.name),t.getExtensionInitDependency()}getDependency(e){let t=this.builder.getExtensionRep(e);return t===void 0&&Z(315,this.extension.name,e.name),t.getExtensionDependency()}getState(){let e=this.state;return function(e){return e.id>=7}(e)||Z(316,String(e.id),`7`),e}getDirectDependentNames(){return this.builder.incomingEdges.get(this.extension.name)||_y}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)||Z(317,this.extension.name),this._dependency={config:e.config,init:e.initResult,output:e.output}}return this._dependency}};let yy={tag:xf};function by(){let e=wh();e.isEmpty()&&e.append(Rm())}let xy=/* @__PURE__ */ wv({config:/* @__PURE__ */ Tv({setOptions:yy,updateOptions:yy}),init:({$initialEditorState:e=by})=>({$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(Em(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:[xm,Ff,km,Kf,Im]}),Sy=Symbol.for(`@lexical/extension/LexicalBuilder`);function Cy(){}function wy(e){throw e}function Ty(e){return Array.isArray(e)?e:[e]}let Ey=dy;var Dy=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=Ey,this.roots=e;for(let t of e)this.addExtension(t)}static fromExtensions(t){let n=[Ty(xy)];for(let e of t)n.push(Ty(e));return new e(n)}static maybeFromEditor(t){let n=t[Sy];return n&&(n.PACKAGE_VERSION!==Ey&&Z(292,n.PACKAGE_VERSION,Ey),n instanceof e||Z(293)),n}static fromEditor(t){let n=e.maybeFromEditor(t);return n===void 0&&Z(294),n}constructEditor(){let{$initialEditorState:e,onError:t,onWarn:n,...r}=this.buildCreateEditorArgs(),i=Object.assign(Wm({...r,...t?{onError:e=>{t(e,i)}}:{},...n?{onWarn:e=>{n(e,i)}}:{}}),{[Sy]:this});for(let e of this.sortedExtensionReps())e.build(i);return i}buildEditor(){let e=Cy;function t(){try{e()}finally{e=Cy}}let n=Object.assign(this.constructEditor(),{dispose:t,[Symbol.dispose]:t});return e=kv(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&&Z(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&&Z(296);let[t]=Ty(e);typeof t.name!=`string`&&Z(297,typeof t.name);let n=this.extensionNameMap.get(t.name);if(n!==void 0&&n.extension!==t&&Z(298,t.name),!n){n=new vy(this,t),this.extensionNameMap.set(t.name,n);let e=this.conflicts.get(t.name);typeof e==`string`&&Z(299,t.name,e);for(let e of t.conflictsWith||[])this.extensionNameMap.has(e)&&Z(299,t.name,e),this.conflicts.set(e,t.name);for(let e of t.dependencies||[]){let n=Ty(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(hy(i))return;let a=n.extension.name;var o;my(i)||Z(300,a,r||`[unknown]`),my(o=i)||Z(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=gy(i),n.state=i,e.push(n)};for(let e of this.extensionNameMap.values())my(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&&Z(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 kv(...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 ly(o)){if(typeof e!=`function`){let t=n.get(e.replace);t&&Z(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&&py(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||=wy,e}};function Oy(e,t){let n=Dy.maybeFromEditor(e);if(!n)return;let r=n.extensionNameMap.get(t);return r?r.getExtensionDependency():void 0}var ky=class extends bm{$config(){return this.config(`horizontalrule`,{importDOM:{hr:()=>({conversion:Ay,priority:0})}})}exportDOM(){return{element:_g().createElement(`hr`)}}createDOM(e){let t=_g().createElement(`hr`);return Ov(t,e.theme.hr),t}getTextContent(){return`
|
|
155
|
-
`}isInline(){return!1}updateDOM(){return!1}};function Ay(){return{node:jy()}}function jy(){return n_(ky)}Date.now;function My(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 Ny;function Py(e,t){let{key:n}=t;return e&&n in e?e[n]:t.defaultValue}function Fy(e){return Ny&&Ny.editor===e?Ny:void 0}function Iy(e,t){if(`cfg`in t){let{cfg:n,updater:r}=t;return[n,r(Py(e,n))]}return t}function Ly(e,t){let n=t;for(let r of e){let[e,i]=Iy(n,r),a=e.key;if(n===t&&Py(n,e)===i)continue;let o=n===t||n===void 0?Ry(t):n;o[a]=i,n=o}return n}function Ry(e){return Object.create(e||null)}function zy(e,t){return[e,t]}function By(e,t,n,r=Pg()){let i=Ny,a=Fy(r);try{return Ny={...a,editor:r,[e]:t},n()}finally{Ny=i}}function Vy(e,t=()=>{}){return(n,r=Pg())=>i=>{let a=Fy(r),o=a&&a[e],s=Ly(n,o||t(r));return s&&s!==o?By(e,s,i,r):i()}}function Hy(e,t,n,r){return Object.assign(zl(Symbol(t),{isEqual:r,parse:n}),{[e]:!0})}let Uy=`@lexical/html/DOM`,Wy=Symbol.for(`@lexical/html/DOMExportContext`);function Gy(e,t,n){return Hy(Wy,e,t,n)}let Ky=/* @__PURE__ */ Gy(`isExport`,Boolean);function qy(e){let t=Oy(e,Uy);return t?t.output.defaults:void 0}function Jy(e){let t=Oy(e,Uy);return t?t.output.runtime:void 0}function Yy(e=Pg()){let t=Jy(e);return t?t.getSessionConfig():Fg(e)}let Xy=Vy(Wy,qy),Zy=Symbol.for(`@lexical/html/SelectorImpl`);function Qy(e,t){let n={kind:`element`,predicate:(r=t,r.length===0?Y: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=>Qy(e,[...t,n]);return{[Zy]:n,attr:(e,t,n)=>i(tb(e,t,n)),classAll:(...e)=>i(eb(e)),classAny:(...e)=>i(function(e){let t=$y(e);return t.length===0?()=>!1:e=>{if(!Y(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=>Y(n)&&n.style.getPropertyValue(e)===t;if(t instanceof RegExp){let r=n&&n.capture,i=t;return(t,n)=>{if(!Y(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)}}My(362,JSON.stringify(e))}(e,t,n))}}function $y(e){let t=[];for(let n of e)n&&t.push(n);return t}function eb(e){let t=$y(e);return t.length===0?()=>!0:e=>{if(!Y(e))return!1;let n=e.classList;for(let e of t)if(!n.contains(e))return!1;return!0}}function tb(e,t,n){if(!0===t)return t=>Y(t)&&t.hasAttribute(e);if(typeof t==`string`)return n=>Y(n)&&n.getAttribute(e)===t;if(t instanceof RegExp){let r=n&&n.capture,i=t;return(t,n)=>{if(!Y(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)}}My(361,JSON.stringify(e))}let nb={kind:`text`,predicate:ch,tags:/* @__PURE__ */ new Set},rb={[Zy]:nb},ib={kind:`comment`,predicate:e=>e.nodeType===8,tags:/* @__PURE__ */ new Set},ab={[Zy]:ib},ob={any:()=>Qy(/* @__PURE__ */ new Set,[]),comment:()=>ab,tag(...e){e.length>0||My(363);let t=/* @__PURE__ */ new Set;for(let n of e)t.add(n.toUpperCase());return Qy(t,[])},text:()=>rb},sb=ob;sb.tag(`b`,`strong`,`em`,`i`,`code`,`mark`,`s`,`sub`,`sup`,`u`,`span`),sb.text(),sb.tag(`script`,`style`),sb.tag(`br`),sb.tag(`p`),sb.tag(`hr`),sb.any(),Object.freeze([]),Object.freeze({}),ob.any(),ob.any,ob.comment,ob.tag,ob.text;function cb(e,t=null,n=Pg()){return Xy([zy(Ky,!0)],n)(()=>{let r=wh(),i=Yy(n),a=H(t)?f_(t.anchor.getNode()):null,o=e.append.bind(e);for(let e of(G(a)?a:r).getChildren())ub(n,e,o,t,i);return e})}function lb(e,t=null){return(typeof document>`u`||typeof window>`u`&&global.window===void 0)&&My(338),tm(e),cb(_g().createElement(`div`),t,e).innerHTML}function ub(e,t,n,r=null,i=Fg(e)){let a=i.$shouldInclude(t,r,e),o=i.$shouldExclude(t,r,e),s=t;r!==null&&V(t)&&(s=Iv(r,t,`clone`));let{element:c,after:l,append:u,$getChildNodes:d}=i.$exportDOM(s,e);if(!c)return!1;let f=_g().createDocumentFragment(),p=d?d():G(s)?s.getChildren():[],m=a&&ip(r)&&G(t)?null:r,h=f.append.bind(f);for(let n of p){let o=ub(e,n,h,m,i);!a&&o&&i.$extractWithChild(t,n,r,`html`,e)&&(a=!0)}if(a&&!o){if((Y(c)||Og(c))&&(u?u(f):c.append(f)),n(c),l){let e=l.call(s,c);e&&(Og(c)?c.replaceChildren(e):c.replaceWith(e))}}else n(f);return a}function db(e,t,n=null){let r=gg(n),i=n?mg(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=qh(n)}return!1}(a.offsetNode,n))return{node:a.offsetNode,offset:a.offset}}if(a){let i=n.getRootNode();if(fg(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 fb(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 pb(e,t=U()){return t??fb(166),H(t)&&t.isCollapsed()||t.getNodes().length===0?``:lb(e,t)}function mb(e,t){let n=e.getData(`text/plain`)||e.getData(`text/uri-list`);n!=null&&t.insertRawText(n)}let hb=`application/x-lexical-drag`;function gb(e,t){let n={editorKey:t.getKey()};e.setData(hb,JSON.stringify(n))}function _b(e,t,n){let r=e.dataTransfer;if(r===null)return!1;let i=function(e){let t=e.getData(hb);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=db(e.clientX,e.clientY,t.getRootElement());if(n===null)return null;let r=xh(n.node);if(r===null)return null;if(V(r))return U_(r,`next`,n.offset);if(G(r))return yv(r,n.offset,`next`);let i=r.getParent();return i===null?null:yv(i,r.getIndexWithinParent()+1,`next`)}(e,t);if(a===null)return!1;let o=Sv(a);if(o===null)return!1;let s=i.editorKey===t.getKey(),c=U();if(s){if(!H(c)||c.isCollapsed())return!1;if(function(e,t){let{anchor:n,focus:r}=vv(uv(t),`next`);return tv(n,e)<0&&tv(e,r)<0}(a,c))return e.preventDefault(),!0;c.removeText()}if(!o.origin.isAttached())return e.preventDefault(),!0;if(n(r,cv(Q_(o)),t),!s){let e=t.getRootElement(),n=e?e.ownerDocument:null,r=n?function(e,t){for(let n of hg(t)){let t=ah(n);if(rh(t)&&t.getKey()===e&&Y(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 vb(e,t){return _b(e,t,(e,t)=>mb(e,t))}function yb(e,t){t.update(()=>{if(e!==null){let n=Uv(e,KeyboardEvent)?null:e.clipboardData,r=U();if(r!==null&&!r.isCollapsed()&&n!=null){e.preventDefault();let i=pb(t);i!==null&&n.setData(`text/html`,i),n.setData(`text/plain`,r.getTextContent())}}})}function bb(e){return kv(e.registerCommand(ed,e=>{let t=U();return!!H(t)&&(t.deleteCharacter(e),!0)},0),e.registerCommand(od,e=>{let t=U();return!!H(t)&&(t.deleteWord(e),!0)},0),e.registerCommand(sd,e=>{let t=U();return!!H(t)&&(t.deleteLine(e),!0)},0),e.registerCommand(rd,e=>{let t=U();if(!H(t))return!1;if(typeof e==`string`)t.insertText(e);else{let n=e.dataTransfer;if(n!=null)mb(n,t);else{let n=e.data;n&&t.insertText(n)}}return!0},0),e.registerCommand(ad,()=>{let e=U();return!!H(e)&&(e.removeText(),!0)},0),e.registerCommand(td,e=>{let t=U();return!!H(t)&&(t.insertLineBreak(e),!0)},0),e.registerCommand(nd,()=>{let e=U();return!!H(e)&&(e.insertLineBreak(),!0)},0),e.registerCommand(md,e=>{let t=U();if(!H(t))return!1;let n=e,r=n.shiftKey;return!!zv(t,!0)&&(n.preventDefault(),Hv(t,r,!0),!0)},0),e.registerCommand(fd,e=>{let t=U();if(!H(t))return!1;let n=e,r=n.shiftKey;return!!zv(t,!1)&&(n.preventDefault(),Hv(t,r,!1),!0)},0),e.registerCommand(bd,t=>!!H(U())&&(!$c||!Qc)&&(t.preventDefault(),e.dispatchCommand(ed,!0)),0),e.registerCommand(Sd,t=>!!H(U())&&(t.preventDefault(),e.dispatchCommand(ed,!1)),0),e.registerCommand(vd,t=>{if(!H(U()))return!1;if(t!==null){if(($c||tl||il)&&Qc)return!1;t.preventDefault()}return e.dispatchCommand(td,!1)},0),e.registerCommand(Ad,()=>{let e=U();return Bh(H(e)&&f_(e.anchor.getNode())!==null?e:null),!0},0),e.registerCommand(Od,t=>!!H(U())&&(yb(t,e),!0),0),e.registerCommand(kd,t=>!!H(U())&&(function(e,t){yb(e,t),t.update(()=>{let e=U();H(e)&&e.removeText()},{tag:`cut`})}(t,e),!0),0),e.registerCommand(id,t=>!!H(U())&&(function(e,t){e.preventDefault(),t.update(()=>{let t=U(),n=Uv(e,ClipboardEvent)?e.clipboardData:null;n!=null&&H(t)&&mb(n,t)},{tag:`paste`})}(t,e),!0),0),e.registerCommand(wd,t=>vb(t,e),0),e.registerCommand(Td,t=>{let n=U();return!!H(n)&&(n.isCollapsed()||t.dataTransfer===null||gb(t.dataTransfer,e),!0)},0))}function xb(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(!(H(a)&&H(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||Sm(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)&&V(r)&&r.__text.length===1&&a.anchor.offset===1?2:0}let c=s[0],l=e._nodeMap.get(c.__key);if(!V(l)||!V(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 Sb(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:xb(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!(H(a)&&H(o)&&a.anchor.type===`element`&&a.focus.type===`element`&&o.anchor.type===`text`&&o.focus.type===`text`||!V(r)||!V(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 Cb(e,t){e.undoStack=[],e.redoStack=[],e.current=null,t&&t(e)}function wb(e,t,n,r=Date.now,i,a=null){let o=Sb(e,n,r),s=()=>{i&&i(t)};return s(),kv(e.registerCommand(ld,()=>(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(Nd,!0)),i.length===0&&e.dispatchCommand(Pd,!1),t.current=o||null,n&&n(t),o&&o.editor.setEditorState(o.editorState,{tag:`historic`})}}(e,t,i),!0),0),e.registerCommand(ud,()=>(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(Pd,!0));let o=r.pop();r.length===0&&e.dispatchCommand(Nd,!1),t.current=o||null,n&&n(t),o&&o.editor.setEditorState(o.editorState,{tag:`historic`})}}(e,t,i),!0),0),e.registerCommand(jd,()=>(Cb(t,i),!1),0),e.registerCommand(Md,()=>(Cb(t,i),e.dispatchCommand(Nd,!1),e.dispatchCommand(Pd,!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(Nd,!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(Pd,!0)}}else if(m===2)return;t.current={editor:e,editorState:n},s()}))}function Tb(){return{current:null,redoStack:[],undoStack:[]}}Date.now;let Eb=`application/x-codexhost-thread-reference`;function Db(e){let t=e.projectionValues?.threadReference;if(!e.blank&&t?.hostId&&(t.hostId===`local`||/^remote-(?:ssh(?:-|:)|control:)/u.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 Ob(e){return`thread://${encodeURIComponent(e.threadId).replace(/[!'()*]/gu,e=>`%${e.charCodeAt(0).toString(16).toUpperCase()}`)}?hostId=${encodeURIComponent(e.hostId)}`}function kb(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(!/^remote-(?:ssh(?:-|:)|control:)/u.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 Ab(e){let t=`[@${e.title.replace(/[\\`*{}[\]()#+.!_<>|~-]/gu,e=>`\\${e}`)}](${Ob(e)})`;return{source:`codexhost-thread`,ref:t,label:e.title,appearance:`session`,clipboardText:t}}function jb(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`&&!/^remote-(?:ssh(?:-|:)|control:)/u.test(r)||typeof i!=`string`?void 0:Db({id:n,blank:!1,title:i,projectionValues:{threadReference:{hostId:r,threadId:n}}})}catch{return}}function Mb(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=Mb(e[t]))&&(r&&(r+=` `),r+=n)}else for(n in e)e[n]&&(r&&(r+=` `),r+=n)}return r}function Nb(){for(var e,t,n=0,r=``,i=arguments.length;n<i;n++)(e=arguments[n])&&(t=Mb(e))&&(r&&(r+=` `),r+=t);return r}let Pb=`@deepseek-ai/dsh-client-ui-conversation/ReferenceChip.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(Pb)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-conversation`,e.dataset.pluginCss=Pb,e.textContent=`.HsYvBG_chip{max-width:240px;color:var(--dsw-alias-state-business-primary);user-select:none;align-items:baseline;gap:3px;display:inline-flex}.HsYvBG_marker{flex:none;font-weight:500}.HsYvBG_icon{flex:none;align-self:center}.HsYvBG_label{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.HsYvBG_invalid{color:var(--dsw-alias-state-error-primary);opacity:.7;text-decoration:line-through}`,document.head.appendChild(e)}var Fb={chip:`HsYvBG_chip`,icon:`HsYvBG_icon`,invalid:`HsYvBG_invalid`,label:`HsYvBG_label`,marker:`HsYvBG_marker`};let Ib=`@deepseek-ai/dsh-client-ui-conversation/composer-editor.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(Ib)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-conversation`,e.dataset.pluginCss=Ib,e.textContent=`._06X5vW_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}._06X5vW_reference:hover{background:var(--dsw-alias-state-business-tertiary)}._06X5vW_openable{cursor:pointer}._06X5vW_textRef{max-width:100%;display:inline-block}`,document.head.appendChild(e)}var Lb={openable:`_06X5vW_openable`,reference:`_06X5vW_reference`,textRef:`_06X5vW_textRef`};function Rb({label:e,reference:t,appearance:n,invalid:r}){return/* @__PURE__ */ (0,h.jsxs)(`span`,{className:Nb(Lb.reference,Fb.chip,n===`file`&&!r&&Lb.openable,r&&Fb.invalid),title:e,children:[n===void 0?/* @__PURE__ */ (0,h.jsx)(`span`,{className:Fb.marker,"aria-hidden":!0,children:`@`}):/* @__PURE__ */ (0,h.jsx)(d.ReferenceIconRegular,{kind:n,reference:t,size:14,className:Fb.icon}),/* @__PURE__ */ (0,h.jsx)(`span`,{className:Fb.label,children:e})]})}var zb=class e extends bm{__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)(Rb,{label:this.__label,reference:this.__ref,appearance:this.__appearance,invalid:this.__invalid})}};function Bb(e){return new zb(e)}function Vb(e){return e instanceof zb}function Hb(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 Ub(e,t,n,r){let i=e=>e instanceof n,a=e=>{let t=Wf(e.getTextContent());t.setFormat(e.getFormat()),e.replace(t)};return[e.registerNodeTransform(Ff,e=>{if(!e.isSimpleText())return;let n,o=e.getPreviousSibling(),s=e.getTextContent(),c=e;if(V(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(V(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&&V(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&&Hb(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();V(o)&&o.isTextEntity()&&(a(o),a(e));let s=e.getNextSibling();V(s)&&s.isTextEntity()&&(a(s),i(e)&&a(e))})]}let Wb=/(^|\s)([/@])([\w-]+)/g,Gb=/(^|\s)(@(?:"[^"\n]*"?|[^\s"]\S*))/g,Kb=/* @__PURE__ */ new Set(`.,;:!?,。;:!?`),qb=/^@.*[/\\.]/u;function Jb(e,t,n){if(!n.startsWith(`@"`)){let e=n.length;for(;Kb.has(n.charAt(e-1));)--e;return qb.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(;Kb.has(e.charAt(i));)i+=1;return i===e.length||/\s/u.test(e.charAt(i))?t+r+1:void 0}let Yb=/^(?:\s|$)/;function Xb(e,t){if(e===``)return[];let n=[];Wb.lastIndex=0;let r;for(;(r=Wb.exec(e))!==null;){let i=r[2],a=r[3]??``;if((i!==`/`||Yb.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})}}Gb.lastIndex=0;let i;for(;(i=Gb.exec(e))!==null;){let t=i.index+(i[1]?.length??0),r=Jb(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 Zb=class e extends Ff{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=Nb(t.className,Lb.reference,Lb.textRef,this.getTextContent().startsWith(`/`)&&Lb.openable),t.setAttribute(`spellcheck`,`false`),t.setAttribute(`data-composer-text-ref`,``),t}isTextEntity(){return!0}canInsertTextBefore(){return!0}};function Qb(e,t,n){return kv(...Ub(e,e=>{let r=n();for(let n of Xb(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},Zb,e=>new Zb(e.getTextContent())))}function $b(e){e.update(()=>{for(let e of wh().getAllTextNodes())e.markDirty()},{tag:xf})}function ex(e,t){return e.registerCommand(Yu,e=>{if(e.target===null||e.button!==0||e.detail>1)return!1;let n=U();if(H(n)&&!n.isCollapsed())return!1;let r=xh(e.target);if(Vb(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 Zb&&t(void 0,{ref:r.getTextContent()})},1)}function tx(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 nx=Ls([k(),A(),j(),ks()]);function rx(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 ix=_c(rx,{message:`JSON value must not contain circular references`}),ax=hc(()=>Ls([nx,M(ax),Gs(k(),ax)])),ox=ix.pipe(ax);ix.pipe(M(ax));let sx=ix.pipe(Gs(k(),ax)),cx=P({code:k().min(1),message:k().min(1),retryable:j(),diagnostic:k().min(1).optional(),stage:k().min(1).optional(),durationMs:A().int().nonnegative().optional(),stderrTail:k().min(1).optional()}).superRefine(tx([`diagnostic`,`stage`,`durationMs`,`stderrTail`])),lx=k().max(64).regex(/^[a-z]{2,3}(?:-[A-Za-z0-9]{2,8})*$/u),ux=e=>k().min(1).max(e).refine(e=>e.trim().length>0),dx=Gs(lx,N({label:ux(256).optional(),description:ux(1024).optional()}).strict()).refine(e=>Object.keys(e).length<=16,`Too many locales`),fx=Gs(lx,ux(4096)).refine(e=>typeof e.en==`string`,`English fallback is required`).refine(e=>Object.keys(e).length<=16,`Too many locales`),px=k().refine(e=>e.trim().length>0,{message:`Identifier must not be empty or whitespace`}),mx=px.brand(),hx=px.brand(),gx=px.brand();px.brand(),px.brand();let _x=k().refine(e=>e.trim().length>0,{message:`Value must not be empty or whitespace`}),vx=_x.max(128).regex(/^[A-Za-z0-9._~:-]+$/u,`Permission Mode ID must use transport-safe characters`).brand(),yx=N({modes:M(N({id:vx,label:_x.max(256),description:_x.max(1024).optional(),dangerous:j().optional(),localizations:dx.optional()}).strict()).min(1).max(32),defaultModeId:vx}).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`]})});N({threadId:hx,permissionModeId:vx}).strict();let bx=A().int().safe().nonnegative(),xx=A().finite().nonnegative(),Sx=A().finite().min(0).max(100),Cx=N({version:Ls([I(3),I(4)]).optional(),requestId:k().min(1),turnId:k().min(1).max(1024),outputTokens:bx,startedAtMs:bx,completedAtMs:bx}).strict().refine(e=>e.completedAtMs>e.startedAtMs),wx=N({version:Ls([I(2),I(3),I(4)]).optional(),value:xx,turnId:k().min(1).max(1024),at:bx}).strict();N({outputTimings:M(Cx).transform(e=>e.filter(e=>e.version===4)).optional(),outputTokensPerSecond:wx.refine(e=>e.version===4).optional().catch(void 0),timeToFirstOutputMs:wx.extend({value:bx}).optional()}).strict();let Tx=e=>fx.refine(t=>Object.values(t).every(t=>t.length<=e)),Ex=N({composerIndicators:M(N({kind:I(`countdown`),id:k().min(1).max(64),expiresAtUnix:bx,label:Tx(256).optional(),tooltip:Tx(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:bx.optional(),cachedInputTokens:bx.optional(),cacheWriteInputTokens:bx.optional(),outputTokens:bx.optional(),outputTokensPerSecond:xx.optional(),sessionOutputTokensPerSecond:xx.optional(),apiOutputTokensPerSecond:xx.optional(),reasoningOutputTokens:bx.optional(),totalTokens:bx.optional(),totalCostUsd:xx.optional(),totalCredits:xx.optional(),contextUsagePercent:xx.optional(),cacheHitRatePercent:Sx.optional(),contextWindowTokens:bx.optional(),contextUsedTokens:bx.optional(),planFiveHourUsedPercent:Sx.optional(),planFiveHourResetsAtUnix:bx.optional(),planSevenDayUsedPercent:Sx.optional(),planSevenDayResetsAtUnix:bx.optional(),sessionCacheHitRatePercent:Sx.optional(),timeToFirstOutputMs:bx.optional(),costSource:F([`publicPrice`,`native`]).optional(),unpricedModels:M(k().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`]})}),Dx=A().finite().min(0).max(100),Ox=F([`weekly`,`monthly`,`five_hour`,`seven_day`,`unknown`]),kx=N({id:k().min(1).max(256),label:k().min(1).max(256),localizations:dx.optional()}).strict(),Ax=N({product:k().min(1),periodType:Ox.optional(),scope:kx.optional(),localizations:dx.optional(),used:A().finite().nonnegative().optional(),limit:A().finite().nonnegative().optional(),unit:k().min(1).max(32).optional(),usagePercent:Dx,resetsAt:k().min(1).optional()}).strict(),jx=N({availableCount:A().int().safe().positive(),nextExpiresAt:k().min(1).optional(),expiresAt:M(k().min(1)).min(1).max(32).optional()}).strict(),Mx=N({used:A().finite().nonnegative().optional(),limit:A().finite().nonnegative().optional(),unit:k().min(1).max(32).optional(),label:k().min(1).optional(),scope:kx.optional(),localizations:dx.optional(),usedPercent:Dx,resetsAt:k().min(1).optional(),periodType:Ox,productUsage:M(Ax).min(1).optional(),resetCredits:jx.optional()}).strict();N({threadId:hx,refresh:I(`exact`).optional()}).strict(),N({threadId:hx,usage:Ex.nullable(),accountCredits:Mx.optional(),accountCreditsSupported:j().optional()}).strict();let Nx=k().refine(e=>e.trim().length>0,{message:`Value must not be empty or whitespace`}),Px=N({id:Nx.max(512).regex(/^[A-Za-z0-9._~-]+$/u,`Model Ref must use transport-safe opaque characters`).brand()}).strict(),Fx=Nx.max(128).regex(/^[A-Za-z0-9._~-]+$/u,`Thinking option ID must use transport-safe characters`).brand(),Ix=Nx.max(256),Lx=N({id:Fx,label:Nx.max(256)}).strict(),Rx=N({ref:Px,label:Nx.max(256),resolvedModelLabel:Ix.optional(),fastModel:Px.optional(),supportedThinkingOptionIds:M(Fx).optional()}).strict(),zx=M(Lx).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)}),Bx=N({models:M(Rx),defaultModel:Px.optional(),thinkingOptions:zx,defaultThinkingOptionId:Fx.optional()}).strict().superRefine((e,t)=>{let n=/* @__PURE__ */ new Set,r=new Set(e.thinkingOptions.map(({id:e})=>e));for(let[i,a]of e.models.entries()){n.has(a.ref.id)&&t.addIssue({code:`custom`,message:`Model Catalog refs must be unique`,path:[`models`,i,`ref`,`id`]}),n.add(a.ref.id),a.fastModel&&((n.has(a.fastModel.id)||e.models.some(e=>e.ref.id===a.fastModel?.id))&&t.addIssue({code:`custom`,message:`Fast Model refs must be distinct and unique`,path:[`models`,i,`fastModel`]}),n.add(a.fastModel.id));let o=/* @__PURE__ */ new Set;for(let[e,n]of(a.supportedThinkingOptionIds??[]).entries())o.has(n)&&t.addIssue({code:`custom`,message:`Supported Thinking option IDs must be unique per Model`,path:[`models`,i,`supportedThinkingOptionIds`,e]}),o.add(n),r.has(n)||t.addIssue({code:`custom`,message:`Supported Thinking option must exist in the catalog`,path:[`models`,i,`supportedThinkingOptionIds`,e]})}e.defaultModel&&!n.has(e.defaultModel.id)&&t.addIssue({code:`custom`,message:`Default Model must exist in the Model Catalog`,path:[`defaultModel`,`id`]}),e.defaultThinkingOptionId&&!r.has(e.defaultThinkingOptionId)&&t.addIssue({code:`custom`,message:`Default Thinking option must exist in the catalog`,path:[`defaultThinkingOptionId`]})}),Vx=N({fork:j(),forkAcrossCwd:j(),rollbackLastTurn:j()}).strict().refine(e=>e.fork||!e.forkAcrossCwd,{path:[`forkAcrossCwd`],message:`Cross-cwd Fork requires exact history Fork support`}),Hx=F([`live`,`atCreate`]),Ux=N({configuration:N({selectModel:j(),selectThinkingOption:j(),selectPermissionMode:j(),permissionModeScope:Hx.default(`live`)}).strict(),history:Vx,subagents:N({observe:j(),readTranscript:j()}).strict().optional(),autonomousTurns:N({observe:j()}).strict().optional(),steer:j().optional()}).strict();N({effectiveModel:Px.optional(),resolvedModelLabel:Ix.optional(),effectiveThinkingOptionId:Fx.optional(),availableThinkingOptions:zx.optional(),effectivePermissionModeId:vx.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 Wx=N({open:I(!0)}).strict();Ls([N({status:I(`ready`),catalog:Bx,permissionModes:yx.optional(),capabilities:Ux,webUi:Wx.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`]})}),N({status:F([`notInstalled`,`unavailable`,`error`]),error:cx}).strict()]),N({harnessId:mx,cwd:Nx.max(16384).optional(),refresh:j().optional(),purpose:I(`availability`).optional()}).strict(),N({harnessId:mx}).strict(),N({}).strict(),N({threadId:hx,model:Px}).strict(),N({threadId:hx,thinkingOptionId:Fx}).strict(),N({threadId:hx,includeReferenceCapability:j().optional()}).strict(),zs(`owner`,[N({owner:I(`codex`),locked:j(),effectiveModel:Px.optional(),resolvedModelLabel:Ix.optional(),effectiveThinkingOptionId:Fx.optional(),effectivePermissionModeId:vx.optional(),history:Vx.optional(),supportsThreadReferences:I(!0).optional()}).strict(),N({owner:I(`external`),harnessId:Nx.max(256),transportModelId:Nx.max(1024),effectiveModel:Px.optional(),resolvedModelLabel:Ix.optional(),effectiveThinkingOptionId:Fx.optional(),availableThinkingOptions:zx.optional(),effectivePermissionModeId:vx.optional(),history:Vx,usage:Ex.optional(),locked:I(!0)}).strict()]),N({threadIds:M(hx).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 Gx=zs(`owner`,[N({threadId:hx,owner:I(`codex`)}).strict(),N({threadId:hx,owner:I(`external`),harnessId:k().max(256).pipe(mx)}).strict()]);N({threads:M(Gx).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)}),N({threadId:hx,text:k().optional()}).strict(),N({kind:I(`application`),value:k().transform((e,t)=>{try{return JSON.parse(e)}catch{return t.addIssue({code:`custom`,message:`Invalid steering context JSON`}),wt}}).pipe(N({expectedTurnId:gx,clientUserMessageId:k().min(1),delivery:F([`newTurn`,`activeTurn`])}).strict())}).strict().transform(e=>e.value),F([`activeTurn`,`newTurn`]),N({delivery:F([`official`,`activeTurn`,`newTurn`])}).strict(),N({threadId:hx}).strict(),N({confirmed:j()}).strict(),N({threadIds:M(k().min(1))}).strict(),N({threadId:k().min(1).max(1024),pinned:j()}).strict(),N({}).strict(),N({parents:Gs(k().min(1),k().min(1))}).strict(),N({prompt:k().max(16384).optional()}).strict(),N({projects:M(N({id:k(),name:k(),rootPaths:M(k())})),assignments:Gs(k(),k()),projectless:M(k()),pinned:M(k())});let Kx=Gs(k(),js()),qx=N({epoch:k().uuid(),sequence:A().int().nonnegative()});zs(`type`,[N({type:I(`skills-changed`),cursor:qx,cwd:k().optional()}),N({type:I(`harness-inspection-changed`),cursor:qx,harnessId:k().min(1)}),N({type:I(`display-settings-changed`),cursor:qx}),N({type:I(`preferences-changed`),cursor:qx,revision:A().int().nonnegative()}),N({type:I(`hello`),version:I(1),cursor:qx,reset:j()}),N({type:I(`changed`),cursor:qx,threadId:k().min(1),method:k().min(1)})]);let Jx=zs(`type`,[N({type:I(`text`),id:k(),prompt:k(),secret:j().optional(),optional:j().optional()}),N({type:I(`choice`),id:k(),prompt:k(),multiple:j(),allowOther:j(),optional:j().optional(),options:M(N({value:k(),label:k(),description:k().optional()}))})]),Yx=zs(`type`,[N({type:I(`approval`),title:k(),description:k().optional(),subject:js().optional(),actions:M(N({id:k(),label:k(),effect:k()}))}),N({type:I(`question`),title:k().optional(),questions:M(Jx)})]),Xx=N({requestId:Ls([k(),A().int()]),threadId:k(),kind:F([`approval`,`question`]),interaction:Yx,request:Kx}),Zx=N({id:k().min(1),clientUserMessageId:k().min(1),input:M(Kx),presentationInput:M(Kx).nullable().optional()}).passthrough();N({fields:M(N({path:M(Ls([k(),A().int().nonnegative()])),originalLength:A().int().nonnegative()}))});let Qx=N({id:k().min(1),status:k().min(1),codexhostTurnOutcome:N({status:I(`unknown`),reason:k()}).optional(),items:M(N({id:k().min(1),type:k().min(1)}).passthrough()),codexhostFileOperations:M(N({beforeItemId:k().nullable(),item:N({id:k().min(1),type:k().min(1)}).passthrough()})).optional(),error:N({message:k().optional()}).passthrough().nullable().optional(),fingerprint:k().min(1).optional(),unchanged:I(!0).optional()}).passthrough(),$x=N({id:k().min(1).max(512),fingerprint:k().min(1).max(128)});N({threadId:k().min(1),knownTurns:M($x).max(64).optional(),truncateToolOutput:j().optional()});let eS=N({harnessId:k().min(1),nativeSessionId:k().min(1)});N({cursor:qx,activeTurnId:k().min(1).nullable().optional(),command:N({name:k().min(1),turn:Qx,subsequentTurnId:k().min(1).optional()}).optional(),thread:N({id:k().min(1),cwd:k(),modelProvider:k().min(1),createdAt:A(),updatedAt:A(),status:N({type:k()}).passthrough(),name:k().nullable().optional(),preview:k().optional(),codexhostImportSource:eS.optional(),turns:M(Qx).length(0)}).passthrough(),turnsPage:N({data:M(Qx).max(5),nextCursor:k().nullable()}),configuration:N({native:N({model:k().min(1).max(1024).optional(),reasoningEffort:k().min(1).max(128).optional()}).optional(),effectiveModel:Px.optional(),effectiveThinkingOptionId:Fx.optional(),effectivePermissionModeId:vx.optional()}),queue:N({items:M(Zx),pausedReason:F([`interrupted`,`outcome-unknown`,`failed`]).nullable()}).optional(),interactions:M(Xx)}),N({version:I(1),owner:I(`service`).optional(),pid:A().int().positive(),port:A().int().min(1).max(65535),token:k().regex(/^[0-9a-f]{64}$/u),startedAt:A(),epoch:k().uuid()}),N({epoch:k().uuid(),threadId:k().min(1),requestId:Ls([k(),A().int()]),result:Kx}),N({includeArchived:j().optional(),officialCursor:N({live:k().nullable(),archived:k().nullable().optional()}).strict().optional()}).strict(),N({threads:M(sx),ownership:M(Gx),archivedThreadIds:M(hx),officialCursor:N({live:k().nullable(),archived:k().nullable().optional()}).strict().optional()}).strict();let tS=k().regex(/^audio\/[a-z0-9.+-]+(?:\s*;[^\r\n]*)?$/i);N({available:j()}).strict(),N({path:k().min(1),mimeType:tS}).strict();let nS=F([`credentials-unavailable`,`login-expired`,`rate-limited`,`service-rejected`,`host-incompatible`,`network`,`timeout`,`audio-empty`,`audio-too-large`,`audio-format`,`audio-invalid`]);zs(`ok`,[N({ok:I(!0),text:k()}).strict(),N({ok:I(!1),error:N({code:nS}).strict()}).strict()]),N({threadId:hx.optional(),cwd:k().min(1).optional()}).strict().refine(e=>!(e.threadId&&e.cwd),{message:`Specify threadId or cwd, not both`});let rS=N({name:k().min(1).regex(/^[^\s[\]]+$/u),description:k().optional(),path:k().min(1),scope:F([`project`,`global`]),source:k().min(1)}).strict();N({revision:A().int().nonnegative(),complete:j(),skills:M(rS),warnings:M(k()).optional()}).strict(),N({cwd:k().min(1).optional()}).strict();let iS=/\[\$([^\]\r\n]+)\]\((?:<([^<>\r\n]+)>|([^\s()]+))(?:[ \t]+(?:"[^"\r\n]*"|'[^'\r\n]*'))?\)/gu;function aS(e){return[...e.matchAll(iS)].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 oS=N({kind:F([`public`,`relay`,`tailscale-funnel`,`tailscale-https`,`tailscale`,`lan`,`virtual`]),url:k().min(1)}).strict(),sS=zs(`status`,[N({status:I(`not-installed`)}),N({status:I(`not-running`)}),N({status:I(`not-logged-in`)}),N({status:I(`https-disabled`)}),N({status:I(`not-serving`),command:k()}),N({status:I(`occupied`),target:k()}),N({status:I(`serving`),url:k(),funnel:j()}),N({status:I(`error`),message:k()})]);N({state:sS,error:k().optional()}).strict();let cS=zs(`status`,[N({status:I(`on`)}),N({status:I(`off`)}),N({status:I(`invalid`),reason:k()})]),lS=N({lan:j(),autostart:cS}).strict(),uS=N({expiresAt:k().optional(),issuing:j(),failure:N({detail:k().optional(),retryAt:k(),paused:j()}).optional()}),dS=zs(`status`,[N({status:I(`off`),reason:F([`invite`,`name-taken`,`banned`]).optional()}),N({status:I(`connecting`),reason:F([`full`,`unreachable`]).optional()}),N({status:I(`connected`),url:k(),certificate:uS}),N({status:I(`missing-certificate`),url:k(),certificate:uS}),N({status:I(`stopped`),reason:F([`replaced`,`rejected`,`unsupported-version`])})]);k().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()),k().regex(/^(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)?$/);let fS=F([`official`,`self-hosted`]);N({secret:k().min(1),lastUsedAt:A().nullable(),networkUrls:M(oS),directCandidates:M(oS).optional(),tailscale:sS,background:lS.optional(),relay:N({state:dS,enabled:j(),kind:fS,officialHost:k(),customHost:k().optional(),officialHostname:k().optional(),customHostname:k().optional(),quotaUntil:k().optional()}).strict().optional()}).strict();let pS=P({threadId:k().min(1).max(1024),view:F([`result`,`messages`]),from:A().int().min(1).max(2**53-1).optional(),to:A().int().min(1).max(2**53-1).optional()}),mS=N({id:k().min(1).max(256),harnessId:k().min(1),label:k().min(1).max(512),provider:F([`openai-codex`,`xai`])}).strict(),hS=k().regex(/^[a-z][a-z0-9-]{0,47}$/),gS=N({name:hS,source:mS,importedAt:k()}).strict(),_S=zs(`action`,[N({action:I(`list`)}).strict(),N({action:I(`import`),sourceId:k().min(1).max(256),name:hS,confirmed:I(!0)}).strict(),N({action:I(`reimport`),sourceId:k().min(1).max(256),name:hS,confirmed:I(!0)}).strict(),N({action:I(`remove`),name:hS,confirmed:I(!0)}).strict()]),vS=N({provider:k().min(1).max(128),type:F([`oauth`,`api_key`,`unknown`]),label:k().min(1).max(512).optional(),vendor:F([`openai-codex`,`xai`]).optional()}).strict();N({sources:M(mS),targets:M(N({harnessId:k(),providers:M(F([`openai-codex`,`xai`])),imports:M(gS),others:M(vS).default([])}).strict())}).strict(),N({targetHarnessId:k().min(1).max(128).optional(),request:_S}).strict(),N({events:j()});let yS=M(P({agent:k().min(1).max(128),section:F([`main`,`more`,`auto`])})).max(256).refine(e=>new Set(e.map(e=>e.agent)).size===e.length,`Duplicate Harness IDs`);P({entries:yS.nullable()}),P({}),P({entries:yS,initializeOnly:j().optional()});let bS=P({enabled:j(),timeoutMinutes:A().int().min(5).max(1440)});Object.freeze({enabled:!1,timeoutMinutes:10});let xS=k().regex(/^external$/u),SS=mx.transform(e=>String(e)),CS=P({model:Px.optional(),thinkingOptionId:Fx.optional(),permissionModeId:vx.optional()}).refine(e=>!!(e.model||e.thinkingOptionId||e.permissionModeId),`A default configuration must contain a preference`),wS=P({lastHarness:mx.optional(),byHarness:Gs(SS,CS)}),TS=k().min(1).max(1024),ES=P({idleRelease:bS.optional(),favorites:Gs(SS,M(TS).max(2048)).default({}),newThread:wS.optional()});P({scope:xS,revision:A().int().nonnegative(),values:ES}),P({scope:xS.default(`external`)});let DS=zs(`kind`,[P({kind:I(`idleRelease`),value:bS}),P({kind:I(`favorite`),harnessId:mx,modelId:TS,enabled:j()}),P({kind:I(`favorites`),harnessId:mx,modelIds:M(TS).max(2048)}),P({kind:I(`newThread`),lastHarness:mx.optional(),harnessId:mx.optional(),configuration:CS.optional()})]);P({scope:xS.default(`external`),operations:M(DS).min(1).max(256),initializeOnly:j().optional(),expectedRevision:A().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`})}),P({version:I(1),revision:A().int().nonnegative(),scopes:Gs(xS,ES)});let OS=A().finite().nonnegative(),kS=P({input:OS,output:OS,cacheRead:OS.optional(),cacheWrite:OS.optional(),cacheWrite1h:OS.optional()}),AS=k().max(512).refine(e=>e.trim()===e&&e.length>0,`Model ID is required`);P({path:k(),entries:M(P({key:k(),price:kS})),error:k().nullable()}),P({}),P({key:AS,price:kS.nullable(),previousKey:AS.optional()}),P({model:AS});let jS=P({official:j().optional(),canonicalModelId:k().min(1).optional(),provider:k().min(1).max(512),model:k().min(1).max(512),price:kS});P({price:kS.nullable(),suggestions:M(jS).max(6).optional()});let MS=[`today`,`7d`,`30d`,`90d`,`all`],NS=A().int().min(0).max(2**53-1),PS=k().regex(/^\d{4}-\d{2}-\d{2}$/u),FS=k().min(1).max(128),IS=k().min(1).max(512),LS=k().min(1).max(4096);P({range:F(MS),timeZone:k().min(1).max(128).refine(e=>{try{return new Intl.DateTimeFormat(`en`,{timeZone:e}),!0}catch{return!1}},`Unsupported usage statistics timezone`).optional(),harness:FS.optional(),model:IS.nullable().optional(),project:LS.nullable().optional(),date:PS.optional()});let RS=P({requests:NS,inputTokens:NS,cachedInputTokens:NS,cacheWriteInputTokens:NS,cacheKnownInputTokens:NS,cacheHitCachedInputTokens:NS,cacheHitInputTokens:NS,outputTokens:NS,reasoningOutputTokens:NS,costUsd:A().finite().min(0),unpricedRequests:NS,unmeteredRequests:NS}),zS=RS.shape,BS=P({harness:FS,sessionId:k().min(1).max(512),project:LS.nullable(),title:k().min(1).max(200).optional(),models:M(IS).max(16),firstAtMs:NS,lastAtMs:NS,...zS});P({range:F(MS),from:PS.nullable(),to:PS,filters:P({harness:FS.nullable(),model:IS.nullable(),unknownModel:j(),project:LS.nullable(),unknownProject:j(),date:PS.nullable()}),reading:P({complete:j(),sources:NS,read:NS}),failures:M(P({harness:FS,message:k().max(2048)})).max(256),options:P({harnesses:M(FS).max(256),models:M(IS.nullable()).max(4096),projects:M(LS.nullable()).max(4096)}),modelLabels:M(P({harness:FS,model:IS,label:IS})).max(4096).optional(),credits:M(P({harness:FS,model:IS.nullable(),credits:A().finite().min(0),reportedRequests:NS,requests:NS})).max(4096).optional(),totals:RS,daily:M(P({date:PS,harness:FS,...zS})).max(2e5),hourly:M(P({weekday:A().int().min(0).max(6),hour:A().int().min(0).max(23),...zS})).max(168),byHarness:M(P({harness:FS,...zS})).max(256),byModel:M(P({model:IS.nullable(),...zS,harnessPricedRequests:NS})).max(4096),byProject:M(P({project:LS.nullable(),...zS})).max(4096),sessions:M(BS).max(100),recentSessions:M(BS).max(100).optional()}),N({threadId:hx}),N({discarded:j()});let VS=zs(`type`,[N({id:k().min(1),type:I(`choice`),prompt:k(),options:M(N({value:k().min(1),label:k(),description:k().optional()})).min(1),multiple:j(),allowOther:j(),optional:j()}),N({id:k().min(1),type:I(`text`),prompt:k(),multiline:j(),secret:I(!1),optional:j(),placeholder:k().optional(),prefill:k().optional()})]),HS=N({interactionId:k().min(1),turnId:k().min(1),title:k().optional(),questions:M(VS).min(1)}).refine(({questions:e})=>e.some(e=>e.type===`choice`&&e.multiple),{message:`Shared cards require at least one multi-select question`});P({threadId:k().min(1)}),N({questions:M(HS)}),P({threadId:k().min(1),turnId:k().min(1),interactionId:k().min(1),answers:Gs(k(),M(k())),cancelled:j().default(!1)}),N({accepted:I(!0)});let US=N({path:k(),oldText:k().nullable(),newText:k()});N({sessionId:k().min(1),turn:A().int().nonnegative(),path:k().min(1).optional()}),N({diffs:M(US)}),P({}),P({}),N({reference:N({sessionId:k().min(1),epoch:k().min(1),turn:A().int().nonnegative(),seq:A().int().nonnegative(),callId:k().min(1),part:A().int().nonnegative(),version:k().min(1)}),length:A().int().nonnegative(),bytes:A().int().nonnegative()}),P({title:k().trim().min(1).max(200),type:F([`info`,`warning`,`danger`]),body:k().trim().min(1).max(16384)}),P({}),P({url:k().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 WS=F([`idle`,`running`,`busy`,`closing`,`failed`,`blocked`]),GS=F([`none`,`disabled`,`timeout`,`operation`,`background`,`identity`,`persistence`,`closeFailed`]);P({threadId:k(),title:k(),harnessId:k(),state:WS,reason:GS,inactiveMs:A().nonnegative()}),P({threadId:hx,turnId:gx});let KS=N({amount:A().finite().nonnegative(),currency:k().trim().min(1).max(8),label:k().trim().min(1).max(128).optional()}).strict(),qS=N({email:k().trim().min(1).max(320).optional(),label:k().trim().min(1).max(256).optional(),plan:k().trim().min(1).max(128).optional(),credits:Mx.optional(),balance:KS.optional()}).strict();function JS(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 YS=JS(qS),XS={harnessId:mx,harnessName:k().trim().min(1).max(128)},ZS=N(XS).strict();N({}).strict(),N({sources:M(ZS).max(128)}).strict(),N({harnessId:mx,refresh:j().optional()}).strict(),N({...XS,account:YS.nullable(),accounts:M(YS).max(8).optional()}).strict(),N({refresh:j().optional()}).strict(),N({accounts:M(JS(qS.extend(XS))).max(128)}).strict();let QS=k().min(1).max(128).regex(/^[a-z][a-z0-9]*(?:[._-][a-z0-9]+)*$/u).pipe(mx),$S=QS.refine(e=>e!==`codex`,`The official Codex identity is reserved`),eC=k().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`),tC=cs().refine(e=>/^https:\/\/[^/?#@]+(?:[/?#]|$)/iu.test(e),`Plugin documentation links must be credential-free HTTPS URLs`),nC=N({en:k().max(4096),"zh-CN":k().max(4096).optional()}).strict(),rC=N({commands:M(N({terminal:k().max(256),command:k().max(4096)}).strict()).max(8),before:nC.optional(),after:nC.optional(),downloads:M(N({label:k().max(128),url:tC}).strict()).max(8).optional()}).strict(),iC={id:QS,name:k().trim().min(1).max(128),version:k().min(1).max(128),kind:I(`usage`).optional(),iconStyle:N({vector:N({viewBox:k().max(128).regex(/^-?\d+(?:\.\d+)?(?: +-?\d+(?:\.\d+)?){3}$/u),color:k().regex(/^(?:currentColor|#[a-f0-9]{6})$/iu),paths:M(N({d:k().min(1).max(32768).regex(/^[MmLlHhVvCcSsQqTtAaZz\d.,+eE\s-]+$/u),fillRule:F([`evenodd`,`nonzero`]).optional(),fill:k().regex(/^(?:currentColor|#[a-f0-9]{6})$/iu).optional()}).strict()).min(1).max(32)}).strict().optional(),background:k().regex(/^#[a-f0-9]{6}$/iu).optional(),borderRadius:A().min(0).max(50).optional(),paddingRatio:A().min(0).max(.25).optional()}).strict().optional(),installation:rC.optional(),notice:nC.optional(),launchCommand:I(!0).optional(),links:N({website:tC.optional(),documentation:tC.optional(),installation:tC.optional()}).strict().optional()};N({manifestVersion:I(1),...iC,adapterApiVersion:A().int().positive(),entry:eC,icon:eC.optional()}).strict();let aC=k().max(174828).regex(/^data:image\/(?:png|jpeg|webp|svg\+xml);base64,[A-Za-z0-9+/]+={0,2}$/u),oC=N({...iC,icon:aC.optional()}).strict();N({}).strict(),N({plugins:M(oC.extend({id:$S})).max(128)}).strict(),N({version:I(1),enabled:M(QS).max(128)}).strict().refine(e=>new Set(e.enabled).size===e.enabled.length,{message:`Enabled plugin IDs must be unique`,path:[`enabled`]}),N({harnessId:$S,model:Px.optional(),thinkingOptionId:Fx.optional(),permissionModeId:vx.optional(),prewarm:I(!0).optional()}).strict();let sC=k().trim().min(1).max(4096).refine(e=>!/[\u0000\r\n]/u.test(e),`Invalid entrypoint path`);N({harnessId:$S}).strict().extend({path:sC.nullable()}),N({path:sC.nullable(),restartRequired:j()}).strict(),N({harnessId:mx,action:F([`check`,`update`,`install`])}).strict();let cC=N({currentVersion:k().min(1).max(128),latestVersion:k().min(1).max(128),updateAvailable:j(),canUpdate:j(),versionKind:F([`cli`,`application`]).optional(),manualUpdateUrl:cs().max(2048).refine(e=>/^https:\/\/[^/?#@]+(?:[/?#]|$)/iu.test(e),`Manual updates require a credential-free HTTPS URL`).optional(),message:k().max(2048).optional(),messageCode:k().min(1).max(128).optional(),notice:fx.optional(),latestVersionKind:F([`unknown`,`tracking-branch`]).optional()}).strict();N({taskId:k().uuid()}).strict(),zs(`status`,[N({taskId:k().uuid(),status:I(`running`)}).strict(),N({taskId:k().uuid(),status:I(`succeeded`),result:cC}).strict(),N({taskId:k().uuid(),status:I(`failed`),error:N({code:A().int(),message:k().min(1).max(2048)}).strict()}).strict()]);let lC=k().min(1).max(256).regex(/^[A-Za-z0-9._~-]+$/u),uC=k().trim().min(1),dC=F([`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`]),fC=N({accountId:lC,label:uC.max(256),email:k().email().max(320).optional(),planType:dC.optional()}).strict(),pC=F([`ready`,`unavailable`]);N({version:I(2),currentAccountId:lC.nullable(),phase:pC,revision:A().int().nonnegative(),instanceId:uC.max(1024).optional(),accounts:M(fC).max(1)}).strict(),N({accountId:lC,refresh:j().optional()}).strict(),N({accountId:lC,usage:Ex.nullable(),accountCredits:Mx.optional(),freshness:F([`live`,`cached`]),observedAt:k().datetime().nullable()}).strict();let mC=1e3,hC=k().refine(e=>e.trim().length>0,`Value must not be empty or whitespace`).refine(e=>!e.includes(`\0`),`Value must not contain NUL`),gC=hC.max(1024),_C=N({nativeSessionId:gC,title:hC.max(4096).nullable(),updatedAt:A().int().nonnegative().max(864e13),cwd:hC.max(16384),running:j().nullable()}).strict();N({}).strict(),N({harnesses:M(N({harnessId:$S,name:hC.max(128)}).strict()).max(128)}).strict(),N({harnessId:$S,query:k().trim().max(4096).refine(e=>!e.includes(`\0`)).optional(),offset:A().int().nonnegative().safe().optional(),limit:A().int().min(1).max(mC).optional()}).strict(),N({candidates:M(_C).max(mC),total:A().int().nonnegative().safe()}).strict(),N({harnessId:$S,nativeSessionId:gC}).strict(),N({threadId:hC.max(1024).pipe(hx)}).strict();let vC=k().refine(e=>e.trim().length>0,`Value must not be empty or whitespace`).refine(e=>!e.includes(`\0`),`Value must not contain NUL`),yC=gC,bC=_C;N({}).strict(),N({candidates:M(bC).max(1e3)}).strict(),N({nativeSessionId:yC}).strict(),N({threadId:vC.max(1024).pipe(hx)}).strict(),N({threadId:hx,lastTurnId:gx}).strict(),N({threadId:hx}).strict();let xC=k().trim().min(1).max(128).regex(/^[A-Za-z0-9._:-]+$/u).brand();N({commands:M(N({id:xC,invocation:k().min(1).max(128),label:k().trim().min(1).max(128),description:k().trim().min(1).max(512).optional(),localizations:dx.optional(),argumentMode:F([`none`,`text`]),kind:F([`command`,`skill`]).optional()}).strict()),warnings:M(k().min(1)).optional(),source:F([`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)}),N({harnessId:mx,cwd:k().min(1).optional()}).strict(),N({threadId:hx}).strict(),N({threadId:hx,commandId:xC,turnId:gx.optional(),arguments:sx.optional()}).strict(),N({accepted:I(!0),turnId:gx.optional()}).strict();let SC=I(`2.0`).optional(),CC=Ns().optional(),wC=k().min(1),TC=Ls([k(),A().int()]),EC=N({code:A().int(),message:k(),data:ox.optional()}).catchall(ox).superRefine(tx([`data`]));Ls([N({jsonrpc:SC,id:TC,method:wC,params:ox.optional(),result:CC,error:CC}).catchall(ox).superRefine(tx([`jsonrpc`,`params`,`result`,`error`])),N({jsonrpc:SC,id:CC,method:wC,params:ox.optional(),result:CC,error:CC}).catchall(ox).superRefine(tx([`jsonrpc`,`id`,`params`,`result`,`error`])),N({jsonrpc:SC,id:TC,method:CC,params:CC,result:ox,error:CC}).catchall(ox).superRefine(tx([`jsonrpc`,`method`,`params`,`error`])),N({jsonrpc:SC,id:TC,method:CC,params:CC,result:CC,error:EC}).catchall(ox).superRefine(tx([`jsonrpc`,`method`,`params`,`result`]))]);let DC=k().refine(e=>e.trim().length>0,{message:`Native identifier must not be empty or whitespace`});P({harnessId:mx,nativeSessionId:DC,locator:ox.optional(),formatVersion:I(1)}).superRefine(tx([`locator`])),P({harnessId:mx,nativeSessionId:DC,nativeTurnKey:DC,formatVersion:I(1)}),P({harnessId:mx,nativeSessionId:DC,checkpointId:DC,locator:ox.optional(),formatVersion:I(1)}).superRefine(tx([`locator`]));let OC=k().regex(/^\d+\.\d+\.\d+(?:-[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?(?:\+[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/u),kC=F([`npm`,`windows-installer`,`macos-dmg`]),AC=P({version:OC,installation:kC,phase:F([`prepared`,`downloading`,`waiting-for-exit`,`installing`,`restarting`,`succeeded`,`failed`]),updatedAt:A().int().nonnegative(),downloadedBytes:A().int().nonnegative().optional(),totalBytes:A().int().positive().optional(),error:k().min(1).max(500).nullable(),serviceStopOutput:k().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`})});P({});let jC=k().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`);P({currentVersion:OC,installation:kC.nullable(),latestVersion:OC.nullable(),updateAvailable:j(),installationAvailable:j(),releaseNotes:k().min(1).max(2e4).nullable(),releaseNotesUrl:jC.nullable(),status:AC.nullable(),error:k().min(1).max(500).nullable()}),P({status:AC}),P({status:AC.nullable()}),RegExp(String.raw`^- \[([^\]\n]+)\]\(thread://([^\s()<>"?#/]+)\): `+`(${[`completed`,`failed`,`interrupted`,`needsInput`,`timedOut`,`unreadable`,`notFound`].join(`|`)})(?:\. (.+))?$`,`u`);function MC(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 NC(e,t){let n=MC(e);return n===``?t:`${n}\n## My request:\n${t}\n`}let PC=F([`idle`,`installing`,`restarting`,`succeeded`,`failed`]);N({runningVersion:k().nullable(),installedVersion:k().nullable(),restartRequired:j(),remote:j(),updateSupported:j(),update:N({phase:PC,targetVersion:k().nullable(),error:k().nullable()})});let FC=N({version:k().regex(/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/u)}).strict();N({hostname:k().min(1).max(1024).refine(e=>!e.startsWith(`-`)&&!/\s/u.test(e)),port:A().int().min(1).max(65535).nullable(),identity:k().max(4096).nullable(),action:F([`inspect`,`install`,`update`,`repair`,`uninstall`]),uninstallPackage:j().optional(),version:k().regex(/^\d+\.\d+\.\d+$/u).nullable()}).strict(),N({state:F([`installed`,`not-installed`])}).strict();let IC=k().min(1).max(1024),LC={hostId:IC.regex(/^remote-(?:ssh(?:-|:)|control:)/u)},RC={...LC,threadId:IC},zC=zs(`kind`,[P({kind:I(`hosts`)}),P({kind:I(`status`),...RC}),P({kind:I(`list`),...LC,cursor:k().nullable(),archived:j()}),P({kind:I(`read`),...RC,page:P({cursor:k().min(1).max(8192).nullable(),epoch:IC.optional(),sortDirection:F([`asc`,`desc`]).optional(),limit:A().int().min(1).max(20).optional()}).refine(e=>e.cursor===null||e.epoch!==void 0,{message:`A history continuation requires its connection epoch`}).optional()}),P({kind:I(`usage`),...RC,epoch:IC}),P({kind:I(`configure`),...RC,epoch:IC,modelId:IC.optional(),thinkingOptionId:IC.optional(),permissionModeId:IC.optional()}).refine(e=>[e.modelId,e.thinkingOptionId,e.permissionModeId].filter(e=>e!==void 0).length===1,`Select exactly one remote setting`),P({kind:I(`prompt`),...RC,epoch:IC,text:k().min(1).max(8e3),requestId:IC.optional()}),P({kind:I(`interrupt`),...RC,epoch:IC,turnId:IC}),P({kind:I(`rename`),...RC,epoch:IC,name:k().min(1).max(512)}),P({kind:I(`archive`),...RC,epoch:IC,archived:j()}),P({kind:I(`respond`),...RC,epoch:IC,requestId:Ls([IC,A().int()]),result:Gs(k(),js())})]),BC=k().min(1).max(1024),VC=N({hostId:BC,displayName:k().min(1).max(1024),source:F([`codex-managed`,`discovered`]),sshAlias:k().max(1024).nullable(),sshHost:k().min(1).max(1024),sshPort:A().int().min(1).max(65535).nullable(),identity:k().max(4096).nullable(),autoConnect:j(),connectionAnalyticsId:k().max(1024).optional()}),HC=P({displayName:k().min(1).max(1024),hostname:k().min(1).max(1024),sshPort:A().int().min(1).max(65535).nullable(),identity:k().max(4096).nullable()});zs(`action`,[P({action:I(`session`),operation:zC}),P({action:I(`list`)}),P({action:I(`catalog`)}),P({action:I(`read-thread`),hostId:BC.refine(e=>e!==`local`),input:pS}),P({action:I(`save`),draft:HC,previous:VC.nullable()}),P({action:I(`remove`),previous:VC}),P({action:I(`connect`),hostId:BC,enabled:j()}),P({action:I(`state`),hostId:BC}),P({action:I(`runtime`),hostId:BC}),P({action:I(`update`),hostId:BC.refine(e=>e!==`local`),version:FC.shape.version})]),Ls([P({result:ox}),P({error:P({code:A().int(),message:k()})})]),P({prompt:k().trim().min(1).max(2e3),cwd:k().max(4096).nullable()}),k().trim().min(1).max(60).nullable();let UC=k().max(214).regex(/^(?:@[a-z0-9][a-z0-9._-]*\/)?[a-z0-9][a-z0-9._-]*$/u),WC=Ls([k(),N({en:k()}).catchall(k())]),GC=N({title:WC.optional(),description:WC.optional(),icon:k().max(349592).regex(/^data:image\/(?:svg\+xml|png|jpeg|webp);base64,[A-Za-z0-9+/]*={0,2}$/u).optional(),error:k().optional()});N({extensions:M(N({id:UC,name:k().min(1).max(214),version:k().min(1).max(128),format:I(`dsh`),supportedTargets:Us([I(`web`)]),enabledTargets:M(I(`web`)).max(1),source:k().min(1).max(4096),projectUrl:k().max(4096).url({protocol:/^https?$/u}).optional(),installedAt:k(),meta:GC.optional(),loadError:k().optional()})),loadedIds:M(UC),safeMode:j(),storeError:k().optional()});let KC=k().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}/`);N({spec:k().trim().min(1).max(4096),registry:KC.optional()}).strict(),N({id:UC,enabled:j()}).strict(),N({id:UC}).strict(),I(1);function qC(e){return e.registerNodeTransform(Ff,e=>{let t=aS(e.getTextContent())[0];t&&e.splitText(t.start,t.end)[t.start===0?0:1]?.replace(new zb({source:`codexhost-skill`,ref:t.text,label:t.name,appearance:`skill`,clipboardText:t.text}))})}let JC=`color: var(--dsw-alias-state-business-primary)`;function YC(){let e=wh().getFirstChild();if(!G(e))return null;let t=e.getFirstChild();return V(t)?t:null}function XC(e,t){return e.registerNodeTransform(Ff,e=>{let n=YC();if(n===null||e.getKey()!==n.getKey()){e.getStyle()===JC&&e.setStyle(``);return}let r=e.getTextContent(),i=t(),a=r===i?.trimEnd()?r:i;if(a===null||!r.startsWith(a))e.getStyle()===JC&&e.setStyle(``);else if(r.length>a.length){let[t,n]=e.splitText(a.length);t!==void 0&&t.getStyle()!==JC&&t.setStyle(JC),n?.setStyle(``)}else e.getStyle()!==JC&&e.setStyle(JC)})}function ZC(e){e.update(()=>{YC()?.markDirty()})}function QC(){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(Vb(e))o(`chip`,e,``,e.getTextContent());else if(V(e)){let t=e.getTextContent();o(`text`,e,t,t)}else Mm(e)?o(`linebreak`,e,`
|
|
153
|
+
`)}return e}getTextContentSize(){let e=function(e){let t=0;for(let n of __(e)){let r=v_(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(),G(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=ml[e];return(this.getFormat()&t)!==0}return!1}hasTextFormat(e){let t=fl[e];return(this.getTextFormat()&t)!==0}getFormatFlags(e,t){return mh(this.getLatest().__textFormat,e,t)}getTextStyle(){return this.getLatest().__textStyle}select(e,t){tm();let n=U(),r=e,i=t,a=this.getChildrenSize();if(!this.canBeEmpty()){if(e===0&&t===0){let e=this.getFirstChild();if(V(e)||G(e))return e.select(0,0)}else if(!(e!==void 0&&e!==a||t!==void 0&&t!==a)){let e=this.getLastChild();if(V(e)||G(e))return e.select()}}r===void 0&&(r=a),i===void 0&&(i=a);let o=this.__key;return H(n)?(n.anchor.set(o,r,`element`),n.focus.set(o,i,`element`),n.dirty=!0,n):Ep(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!==``&&ml[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){bf(this)&&L(324,this.__key,this.__type);let r=this.getChildrenSize(),i=this.getWritable();e+t<=r||L(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&&L(100);let t=e.getNextSibling(),n=e.__key;gh(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--,gh(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&&L(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=U();if(H(e)){let t=new Set(s),n=new Set(o),{anchor:r,focus:i}=e;Sm(r,t,n)&&Np(r,r.getNode(),this,l,c),Sm(i,t,n)&&Np(i,i.getNode(),this,l,c),u!==0||this.canBeEmpty()||og(this)||this.remove()}}return i}getDOMSlot(e){return new Cl(e)}exportDOM(e){let{element:t}=super.exportDOM(e);if(Y(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===``||og(this)||this.getChildren().some(V)||(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=zg(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 G(e){return e instanceof xm}function Sm(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 Cm=class extends Sf{__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&&L(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 K(e){return e instanceof Cm}var wm=class extends xm{__cachedText;$config(){return this.config(`root`,{extends:xm})}constructor(){super(`root`),this.__cachedText=null}getTopLevelElementOrThrow(){L(51)}getTextContent(){let e=this.__cachedText;return e===null||!em()&&W()._dirtyType!==0?super.getTextContent():e}remove(){L(52)}replace(e){L(53)}insertBefore(e){L(54)}insertAfter(e){L(55)}updateDOM(e,t){return!1}splice(e,t,n){for(let e of n)G(e)||K(e)||L(282);return super.splice(e,t,n)}static importJSON(e){return Dh().updateFromJSON(e)}collapseAtStart(){return!0}};function Tm(e){return e instanceof wm}function Em(e){return new Am(Ol(e._nodeMap),null,e._slotsUsed)}function Dm(){return new Am(/* @__PURE__ */ new Map([[`root`,new wm]]),null,!1)}function Om(e){let t=e.exportJSON(),n=e.constructor;if(t.type!==n.getType()&&L(130,n.name),G(e)){let r=t.children;Array.isArray(r)||L(59,n.name);let i=e.getChildren();for(let e=0;e<i.length;e++){let t=Om(i[e]);r.push(t)}}let r=__(e);if(r.length>0){let i={};for(let t of r){let r=v_(e,t);r===null&&L(366,n.name,t),i[t]=Om(r)}t.$slots=i}return t}function km(e){return e instanceof Am}var Am=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 fm(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 fm(null,this,()=>({root:Om(Dh())}))}},jm=class extends xm{$config(){return this.config(`artificial`,{extends:xm})}createDOM(e){return bg().createElement(`div`)}},Mm=class extends Sf{$config(){return this.config(`linebreak`,{importDOM:{br:e=>Im(e)||Lm(e)?null:{conversion:Nm,priority:0}}})}getTextContent(){return`
|
|
154
|
+
`}createDOM(){return bg().createElement(`br`)}updateDOM(){return!1}isInline(){return!0}};function Nm(e){return{node:Pm()}}function Pm(){return cg(new Mm)}function Fm(e){return e instanceof Mm}function Im(e){let t=e.parentElement;if(t!==null&&Fg(t)){let n=t.firstChild;if(n===e||n.nextSibling===e&&Rm(n)){let n=t.lastChild;if(n===e||n.previousSibling===e&&Rm(n))return!0}}return!1}function Lm(e){let t=e.parentElement;if(t!==null&&Fg(t)){let n=t.firstChild;if(n===e||n.nextSibling===e&&Rm(n))return!1;let r=t.lastChild;if(r===e||r.previousSibling===e&&Rm(r))return!0}return!1}function Rm(e){return dh(e)&&/^( |\t|\r?\n)+$/.test(e.textContent||``)}var zm=class extends xm{$config(){return this.config(`paragraph`,{extends:xm,importDOM:{p:()=>({conversion:Bm,priority:0})}})}createDOM(e){let t=bg().createElement(`p`),n=Wh(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(Y(t)){this.isEmpty()&&t.append(bg().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(V);t?(e.textFormat=t.getFormat(),e.textStyle=t.getStyle()):(e.textFormat=this.getTextFormat(),e.textStyle=this.getTextStyle())}return e}insertNewAfter(e,t){let n=Vm();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||V(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 Bm(e){let t=Vm();if(Yg(t,e),qg(e,t),t.getFormatType()===``){let n=e.getAttribute(`align`);n&&n&&n in ml&&t.setFormat(n)}return Jg(t,e),{node:t}}function Vm(){return cg(new zm)}function Hm(e){return e instanceof zm}function Um(e){console.warn(e)}function Wm(e,t,n,r,i){let a=e._keyToDOMMap;a.clear(),e._editorState=Dm(),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),Sh(n,e,`root`))}function Gm(e){let t=/* @__PURE__ */ new Set,n=/* @__PURE__ */ new Set;for(let{klass:r,ownNodeConfig:i}of i_(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 Km={$createDOM:(e,t)=>e.createDOM(t._config,t),$decorateDOM:(e,t,n,r)=>{},$exportDOM:(e,t)=>{let n=nh(t,e.getType());return n&&n.exportDOM!==void 0?n.exportDOM(t,e):e.exportDOM(t)},$extractWithChild:(e,t,n,r,i)=>G(e)&&e.extractWithChild(t,n,r),$getDOMSlot:(e,t,n)=>e.getDOMSlot(t),$getSlotTargetElement:(e,t,n,r)=>null,$shouldExclude:(e,t,n)=>G(e)&&e.excludeFromCopy(`html`),$shouldInclude:(e,t,n)=>!t||e.isSelected(t),$updateDOM:(e,t,n,r)=>e.updateDOM(t,n,r._config)};function qm(e){let t=e||{},n=sm(),r=t.theme||{},i=e===void 0?n:t.parentEditor||null,a=t.disableEvents||!1,o=Dm(),s=t.namespace||(i===null?Nh():i._config.namespace),c=t.editorState,l=[wm,Rf,Mm,Yf,zm,jm,...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===Sf||n.prototype instanceof Sf)){let r=`<unknown>`;try{r=JSON.parse(El)}catch{}L(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))}r_(n);let a=n.getType(),o=Gm(n);m.set(a,{exportDOM:f&&f.export?f.export.get(n):void 0,klass:n,replace:r,replaceWithKlass:i,sharedNodeState:Ul(l[e]),transforms:o})}}let h=new Xm(o,i,m,{disableEvents:a,dom:{...Km,...e&&e.dom},namespace:s,theme:r},u||console.error,d||Um,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($u,af,0),e.registerCommand(ed,of,0),e.registerCommand(td,sf,0),e.registerCommand(nd,cf,0),e.registerCommand(md,df,0)}(h),h}function Jm(e,t){let n=e.get(t);e.delete(t),n&&n()}function Ym(e,t,n){return e.set(t,n),Jm.bind(null,e,t)}var Xm=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 kl,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=Nh(),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 Ym(this._listeners.update,e)}registerEditableListener(e){return Ym(this._listeners.editable,e)}registerDecoratorListener(e){return Ym(this._listeners.decorator,e)}registerTextContentListener(e){return Ym(this._listeners.textcontent,e)}registerRootListener(e){let t=this._listeners.root;return Mv(Ym(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&&L(35);let r=this._commands;r.has(e)||r.set(e,[new Dl,new Dl,new Dl,new Dl,new Dl]);let i=r.get(e);i===void 0&&L(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&&L(37,e.name),t}resolveRegisteredNodeAfterReplacements(e){for(;e.replaceWithKlass;)e=this.getRegisteredNode(e.replaceWithKlass);return e}initializeMutationListener(e,t){let n=this._editorState,r=Wg(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=Wg(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=bh(t);e&&e.markDirty()}},e._pendingEditorState===null?{tag:wf}: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 J(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=Wh(this._config.theme,`root`),r=this._pendingEditorState||this._editorState;if(this._rootElement=e,Wm(this,t,e,r,{preserveUpdateQueue:!0}),t!==null&&(this._config.disableEvents||_f(t),n!=null&&t.classList.remove(...n)),e!==null){let t=tg(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,Bl(this),this._updateTags.add(wf),pm(this),this._config.disableEvents||function(e,t){let n=e.ownerDocument;Gd.set(e,n);let r=Kd.get(n);r===void 0&&(r={editors:/* @__PURE__ */ new Set,hasShadowEditor:void 0},Kd.set(n,r)),r.editors.add(t),r.hasShadowEditor=void 0,e.__lexicalEditor=t;let i=ff(e);i.push(qd.register(n));for(let n=0;n<Wd.length;n++){let[r,a]=Wd[n],o=typeof a==`function`?e=>{gf(e)||(hf(e),(t.isEditable()||r===`click`)&&a(e,t))}:e=>{if(gf(e))return;hf(e);let n=t.isEditable();switch(r){case`cut`:return n&&J(t,Md,e);case`copy`:return J(t,jd,e);case`paste`:return n&&J(t,sd,e);case`dragstart`:return n&&J(t,Od,e);case`dragover`:return n&&J(t,kd,e);case`dragend`:return n&&J(t,Ad,e);case`focus`:return n&&J(t,Rd,e);case`blur`:return n&&J(t,zd,e);case`drop`:return n&&J(t,Dd,e)}};i.push(Hd(e,r,o))}}(e,this),n!=null&&e.classList.add(...n)}else this._window=null,this._updateTags.add(wf),pm(this);mm(`root`,this,!1,e,t)}}getElementByKey(e){return this._keyToDOMMap.get(e)||null}getEditorState(){return this._editorState}setEditorState(e,t){e.isEmpty()&&L(38);let n=e;n._readOnly&&(n=Em(e),n._selection=e._selection?e._selection.clone():null),zl(this);let r=this._pendingEditorState,i=t===void 0?null:t.tag;r===null||r.isEmpty()||(i!=null&&this._updateTags.add(i),pm(this)),this._pendingEditorState=n,this._dirtyType=2,this._dirtyElements.set(`root`,!1),this._compositionKey=null,this._slotsUsed=this._slotsUsed||e._slotsUsed,ym(this,()=>{if(i&&this._updateTags.add(i),e._parsed)for(let[e,t]of n._nodeMap.entries())G(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=Dm(),i=Kp,a=Jp,o=qp,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,Kp=r,Jp=!1,qp=t,Qm(null);try{let i=t._nodes;dm(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,Kp=i,Jp=a,qp=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`&&pm(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]):vm(e,t,n)})(this,e,t)}focus(e,t={}){let n=this._rootElement;n!==null&&(n.setAttribute(`autocapitalize`,`off`),ym(this,()=>{let r=U(),i=Dh();r===null?i.getChildrenSize()!==0&&(t.defaultSelection===`rootStart`?i.selectStart():i.selectEnd()):r.dirty||Oh(r.clone()),Qh(`focus`),$h(()=>{n.removeAttribute(`autocapitalize`),e&&e()})}),this._pendingEditorState===null&&n.removeAttribute(`autocapitalize`))}blur(){let e=this._rootElement;e!==null&&e.blur();let t=pg(this._window);t!==null&&t.removeAllRanges()}isEditable(){return this._editable}setEditable(e){this._editable!==e&&(this._editable=e,mm(`editable`,this,!0,e),this._slotsUsed&&this.update(()=>am()))}toJSON(){return{editorState:this._editorState.toJSON()}}};Xm.version=El;let Zm=null;function Qm(e){Zm=e}let $m=Symbol(`INTERNAL_SKIP_AFTER_CLONE_FROM`),eh=1;function th(e,t){let n=nh(e,t);return n===void 0&&L(30,t),n}function nh(e,t){return e._nodes.get(t)}let rh=typeof queueMicrotask==`function`?queueMicrotask:e=>{Promise.resolve().then(e)};function ih(e,t){let n=t===void 0?(()=>{let t=e.getRootNode();return fh(t)||hg(t)?Og(t):null})():t;if(!Y(n)||n.hasAttribute(`data-lexical-slot`))return!1;let r=wh(n),i=n.nodeName;return Cf(r)&&(i===`INPUT`||i===`TEXTAREA`||n.contentEditable===`true`&&ch(n)==null)}function ah(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 sh(t)===e&&e.read(`latest`,()=>!ih(t))}function oh(e){return e instanceof Xm}function sh(e){let t=e;for(;t!=null;){let e=ch(t);if(oh(e))return e;t=Xh(t)}return null}function ch(e){return e?e.__lexicalEditor:null}function lh(e){return Zf(e)||e.isToken()}function uh(e){return lh(e)||e.isSegmented()}function dh(e){return Ag(e)&&e.nodeType===3}function fh(e){return Ag(e)&&e.nodeType===9}function ph(e){let t=e;for(;t!=null;){if(dh(t))return t;t=t.firstChild}return null}function mh(e,t,n){let r=fl[t];if(n!==null&&(e&r)===(n&r))return e;let i=e^r;return t===`subscript`?i&=~fl.superscript:t===`superscript`?i&=~fl.subscript:t===`lowercase`?(i&=~fl.uppercase,i&=~fl.capitalize):t===`uppercase`?(i&=~fl.lowercase,i&=~fl.capitalize):t===`capitalize`&&(i&=~fl.lowercase,i&=~fl.uppercase),i}function hh(e,t){let n=function(){let e=Zm;return Zm=null,e}();if((t||=n&&n.__key)!=null)return void(e.__key=t);tm(),nm();let r=W(),i=rm(),a=``+eh++;i._nodeMap.set(a,e),G(e)?r._dirtyElements.set(a,!0):r._dirtyLeaves.add(a),r._cloneNotNeeded.add(a),r._dirtyType===0&&(r._dirtyType=1),e.__key=a}function gh(e){f_(e)!==null&&L(380,e.__key,String(f_(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 _h(e){nm(),bf(e)&&L(323,e.__key,e.__type);let t=e.getLatest(),n=t.__parent===null?d_(t)?t.__slotHost:null:t.__parent,r=rm(),i=W(),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?d_(e)?e.__slotHost:null:e.__parent}}(n,a,o);let s=t.__key;i._dirtyType===0&&(i._dirtyType=1),G(e)?o.set(s,!0):i._dirtyLeaves.add(s)}function vh(e){tm();let t=W(),n=t._compositionKey;if(e!==n){if(t._compositionKey=e,n!==null){let e=bh(n);e!==null&&e.getWritable()}if(e!==null){let t=bh(e);t!==null&&t.getWritable()}}}function yh(){return em()?null:W()._compositionKey}function bh(e,t){let n=(t||rm())._nodeMap.get(e);return n===void 0?null:n}function xh(e,t){let n=Ch(e,W());return n===void 0?null:bh(n,t)}function Sh(e,t,n){e[`__lexicalKey_${t._key}`]=n}function Ch(e,t){return e[`__lexicalKey_${t._key}`]}function wh(e,t){let n=e;for(;n!=null;){let e=xh(n,t);if(e!==null)return e;n=Xh(n)}return null}function Th(e){let t=e._decorators,n=Object.assign({},t);return e._pendingDecorators=n,n}function Eh(e){return e.read(()=>Dh().getTextContent())}function Dh(){return rm()._nodeMap.get(`root`)}function Oh(e){tm();let t=rm();e!==null&&(e.dirty=!0,e.setCachedNodes(null),H(e)&&W()._slotsUsed&&Cp(e)),t._selection=e}function kh(){tm(),zl(W())}function Ah(e){let t=function(e,t){let n=e;for(;n!=null;){let e=Ch(n,t);if(e!==void 0)return e;n=Xh(n)}return null}(e,W());return t===null?null:bh(t)}function jh(e){return/[\uD800-\uDBFF][\uDC00-\uDFFF]/g.test(e)}function Mh(e){let t=[];for(let n=e;n!==null;n=n._parentEditor)t.push(n);return t}function Nh(){return Math.random().toString(36).replace(/[^a-z]+/g,``).substring(0,5)}function Ph(e){return dh(e)?e.nodeValue:null}function Fh(e,t,n){let r=pg(ng(t));if(r===null)return;let i=Cg(r,t._rootElement),a=i.anchorNode,{anchorOffset:o,focusOffset:s}=i;if(a!==null){let t=Ph(a),r=wh(a);if(t!==null&&V(r)){if((t===cl||t===ll)&&n){let e=n.length;t=n,o=e,s=e}t!==null&&Ih(r,t,o,s,e)}}}function Ih(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(cl)&&(s=t.slice(0,-cl.length)),i)){let e=ll,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=U();if(s===``){if(vh(null),il||nl||sl)a.remove();else{let e=W();Lh(a,``,t),setTimeout(()=>{e.update(()=>{a.isAttached()&&a.getTextContent()===``&&a.remove()})},20)}return}let i=a.getParent(),c=Ap(),l=a.getTextContentSize(),u=yh(),d=a.getKey();if(a.isToken()&&!o||u!==null&&d===u&&!o||H(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(!H(t)||n===null||r===null)return void Lh(a,s,t);if(t.setTextNodeRange(a,n,a,r),a.isSegmented()){let e=qf(a.getTextContent());a.replace(e),a=e}Lh(a,s,t)}}}function Lh(e,t,n){if(e.setTextContent(t),H(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=q_(e,a.offset,`clamp`),r=!0)}r&&(n._cachedNodes=null,n._cachedIsBackward=null)}}function Rh(e,t,n){let r=t[n]||!1;return r===`any`||r===e[n]}function zh(e,t){return Rh(e,t,`altKey`)&&Rh(e,t,`ctrlKey`)&&Rh(e,t,`shiftKey`)&&Rh(e,t,`metaKey`)}function q(e,t,n){if(!zh(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 Bh={ctrlKey:!$c,metaKey:$c},Vh={altKey:$c,ctrlKey:!$c};function Hh(e){return e.key===`Backspace`}function Uh(e){let t=Dh();if(H(e)){let t=e.anchor,n=e.focus,r=t.getNode();if(Tm(r))return t.set(r.getKey(),0,`element`),n.set(r.getKey(),r.getChildrenSize(),`element`),nu(e),e;let i=r.getTopLevelElementOrThrow(),a=i.getParent();if(a===null)return G(i)&&(t.set(i.getKey(),0,`element`),n.set(i.getKey(),i.getChildrenSize(),`element`),nu(e)),e;let o=a;return t.set(o.getKey(),0,`element`),n.set(o.getKey(),o.getChildrenSize(),`element`),nu(e),e}{let e=t.select(0,t.getChildrenSize());return Oh(nu(e)),e}}function Wh(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=Av(i);return n[t]=e,e}return i}function Gh(e,t,n,r,i){if(n.size===0)return;let a=r.__type,o=r.__key,s=t.get(a);s===void 0&&L(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 Kh(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 qh(e,t){let n=e.offset;if(e.type===`element`)return Kh(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?Kh(r.getParentOrThrow(),t,r.getIndexWithinParent()+ +!t):e}}return null}function Jh(e){let t=ng(e).event,n=t&&t.inputType;return n===`insertFromPaste`||n===`insertFromPasteAsQuotation`}function J(e,t,...n){return hm(e,t,n[0],e)}function Yh(e,t){let n=e._keyToDOMMap.get(t);return n===void 0&&L(75,t),n}function Xh(e){let t=e.assignedSlot||e.parentElement;if(t!==null)return t;let n=e.parentNode;return hg(n)?n.host:null}function Zh(e){return fh(e)?e:Y(e)?e.ownerDocument:null}function Qh(e){tm(),W()._updateTags.add(e)}function $h(e){tm(),W()._deferred.push(e)}function eg(e,t){let n=e.getParent();for(;n!==null;){if(n.is(t))return!0;n=n.getParent()}return!1}function tg(e){let t=Zh(e);return t?t.defaultView:null}function ng(e){let t=e._window;return t===null&&L(78),t}function rg(e){return G(e)&&e.isInline()||K(e)&&e.isInline()}function ig(e){let t=e.getLatest();for(;t!==null;){if(f_(t)!==null&&G(t))return t;let e=t.getParentOrThrow();if(og(e))return e;t=e}return t}function ag(e){return G(e)&&e.isShadowRoot()}function og(e){return Tm(e)||ag(e)}function sg(e,t=!1){let n=e.constructor.clone(e,$m);return hh(n,null),n.afterCloneFrom(e),t||n.resetOnCopyNodeFrom(e),n}function cg(e){let t=W(),n=e.getType(),r=nh(t,n);r===void 0&&L(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||L(202,r.name,r.getType(),e.constructor.name,n):t instanceof a||L(201,a.name,a.getType(),r.name,r.getType(),e.constructor.name,n),t.__key===e.__key&&L(203,e.constructor.name,n,r.name,r.getType()),t}return e}function lg(e,t){!Tm(e.getParent())||G(t)||K(t)||L(99)}function ug(e){let t=bh(e);return t===null&&L(63,e),t}function dg(e){if(!e||e.isInline())return!1;if(K(e))return!0;if(G(e)){if(e.isShadowRoot()){let t=e.getParent();return!(G(t)&&t.isShadowRoot())}return!e.canBeEmpty()}return!1}function fg(e,t,n){n.style.removeProperty(`caret-color`),t._blockCursorElement=null;let r=e.parentElement;r!==null&&r.removeChild(e)}function pg(e){return Zc?(e||window).getSelection():null}function mg(e){let t=tg(e);return t?t.getSelection():null}function hg(e){return jg(e)&&`host`in e}let gg=[];function _g(e){let t=e.getRootNode();if(t===e||!hg(t))return gg;let n=[t],r=t.host;for(;;){let e=r.getRootNode();if(e===r||!hg(e))break;n.push(e),r=e.host}return n}function*vg(e){let t=[e],n;for(;n=t.pop();){yield*n.querySelectorAll(`[data-lexical-editor="true"]`);let e=(fh(n)?n:n.ownerDocument).createTreeWalker(n,NodeFilter.SHOW_ELEMENT),r;for(;r=e.nextNode();)r.shadowRoot&&t.push(r.shadowRoot)}}function yg(e){return e===null?document:e.ownerDocument}function bg(){let e=sm();return yg(e===null?null:e._rootElement)}function xg(e,t){if(t===null||typeof e.getComposedRanges!=`function`)return null;let n=_g(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 Sg(e,t){let n=xg(e,t);if(n!==null){let e=wg(n);if(e!==null)return e}return e.rangeCount>0?e.getRangeAt(0):null}function Cg(e,t){let n=xg(e,t);return n===null?e:Tg(n,Eg(e))}function wg(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 Tg(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 Eg(e){return e.direction}function Dg(e){let t=e.getRootNode();return fh(t)||hg(t)?t.activeElement:null}function Og(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 kg(e){let t=e.target;if(t!==null&&Y(t)&&t.shadowRoot!==null&&typeof e.composedPath==`function`){let t=e.composedPath();if(t.length>0)return t[0]}return t}function Y(e){return Ag(e)&&e.nodeType===1}function Ag(e){return typeof e==`object`&&!!e&&`nodeType`in e&&typeof e.nodeType==`number`}function jg(e){return Ag(e)&&e.nodeType===11}let Mg=/^(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 Ng(e){return!(!Y(e)||!e.style.display.startsWith(`inline`))||Mg.test(e.nodeName)}let Pg=/^(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 Fg(e){return(!Y(e)||!e.style.display.startsWith(`inline`))&&Pg.test(e.nodeName)}function Ig(e){if(K(e)&&!e.isInline())return!0;if(!G(e)||og(e))return!1;let t=e.getFirstChild(),n=t===null||Fm(t)||V(t)||t.isInline();return!e.isInline()&&!1!==e.canBeEmpty()&&n}function Lg(){return W()}function Rg(e=Lg()){return e._config.dom||Km}function zg(e,t,n=Lg()){let r=Rg(n).$getDOMSlot(e,t,n);return G(e)&&(Bg(r)||L(344,e.getKey(),e.getType())),r}function Bg(e){return e instanceof Cl}function Vg(e,t,n=Lg()){return ph(zg(e,t,n).element)}let Hg=/* @__PURE__ */ new WeakMap,Ug=/* @__PURE__ */ new Map;function Wg(e){if(!e._readOnly&&e.isEmpty())return Ug;e._readOnly||L(192);let t=Hg.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),Hg.set(e,t)),t}function Gg(e){let t=e.constructor.clone(e,$m);return t.afterCloneFrom(e),t}function Kg(e){return(t=Gg(e))[yf]=!0,t;var t}function qg(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 Jg(e,t){let n=t.getAttribute(`dir`);return n===`ltr`||n===`rtl`?e.setDirection(n):e}function Yg(e,t){let n=t.style.textAlign;return n&&n in ml?e.setFormat(n):e}function Xg(e,t){e.__lexicalUnmanaged=!0,t&&t.captureSelection!==void 0&&(e.__lexicalCapturedSelection=t.captureSelection)}function Zg(e){return!0===e.__lexicalUnmanaged}function Qg(e,t=Lg()){let n=t.isEditable();e.contentEditable=n?`true`:`false`,n?e.__lexicalEditor=t:delete e.__lexicalEditor}function $g(e,t){let n=e;for(;n!=null;){if(!0===n.__lexicalCapturedSelection)return!0;if(Y(n)&&n.hasAttribute(`data-lexical-slot`)||Ch(n,t)!==void 0)return!1;n=Xh(n)}return!1}function e_(e,t){return function(e,t){return Object.prototype.hasOwnProperty.call(e,t)}(e,t)&&e[t]!==Sf[t]}let t_=/* @__PURE__ */ new WeakMap,n_=Symbol(`lexical.synthesizedGetType`);function r_(e){let t=t_.get(e);if(t)return t;let n=e.prototype!=null&&vl in e.prototype?e.prototype[vl]():void 0,r=function(e){if(!(e===Sf||e.prototype instanceof Sf)){let t=`<unknown>`,n=`<unknown>`;try{t=e.getType()}catch{}try{Xm.version&&(n=JSON.parse(Xm.version))}catch{}L(290,e.name,t,n)}return e===Cm||e===xm||e===Sf}(e),i=!r&&e_(e,`getType`)?e.getType:void 0,a=i&&!(n_ 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(!e_(e,`getType`)){let t=e,n=function(){return this===t?s:Sf.getType.call(this)};n[n_]=!0,e.getType=n}if(e_(e,`clone`)||(e.clone=(t,n)=>{Qm(t);let r=new e;return n!==$m&&r.afterCloneFrom(t),r}),e_(e,`importJSON`)||(e.importJSON=o&&o.$importJSON||(t=>new e().updateFromJSON(t))),!e_(e,`importDOM`)&&o){let{importDOM:t}=o;t&&(e.importDOM=()=>t)}}let c={klass:e,ownNodeConfig:o,ownNodeType:s};return t_.set(e,c),c}function*i_(e){for(let t=e;t&&(t===Sf||Cf(t.prototype));){let e=r_(t);yield e,t=e.ownNodeConfig&&e.ownNodeConfig.extends||c_(t)}}function a_(e){let t=Lg();return tm(),new(t.resolveRegisteredNodeAfterReplacements(t.getRegisteredNode(e))).klass}let o_=(e,t)=>{let n=e;for(;n!=null&&!Tm(n);){if(t(n))return n;n=n.getParent()}return null};function s_(e,t){let n=[],r=e.__first;for(;r!==null;){let e=t===null?bh(r):t.get(r);e??L(174),n.push(r),r=e.__next}return n}function c_(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 l_=/* @__PURE__ */ new Map;function u_(e){return G(e)||K(e)}function d_(e){return G(e)||K(e)}function f_(e){let t=e.getLatest();return d_(t)?t.__slotHost:null}function p_(e){let t=f_(e);if(t===null)return null;let n=bh(t);return G(n)||K(n)||L(370),n}function m_(e){let t=p_(e);if(t===null)return null;let n=e.getLatest().__key;for(let[e,r]of g_(t))if(r===n)return e;return null}function h_(e){let t=e.getLatest();for(;t!==null;){if(f_(t)!==null)return t;t=t.getParent()}return null}function g_(e){let t=e.getLatest();return u_(t)&&t.__slots!==null?t.__slots:l_}function __(e){return Array.from(g_(e).keys())}function v_(e,t){let n=g_(e).get(t);return n===void 0?null:bh(n)}let y_=[`__proto__`,`constructor`,`prototype`],b_=Symbol(`slotMapOwner`);function x_(e){let t=e.__slots;return t!==null&&t[b_]===e||(t=new Map(t),t[b_]=e,e.__slots=t),t}let S_=/* @__PURE__ */ new WeakMap,C_=[];function w_(e){for(let{ownNodeConfig:t}of i_(e)){let e=t&&t.slots;if(e)return e}return C_}function T_(e){let t=``;for(let n of __(e)){let r=v_(e,n);r!==null&&(t+=r.getTextContent())}return t}function E_(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 D_(e){let t=e.__slots;if(t===null||t.size<2)return;let n=function(e){let t=S_.get(e);if(t===void 0){let n=w_(e),r=/* @__PURE__ */ new Map;for(let t of n)y_.includes(t)&&L(371,e.name,t),r.has(t)&&L(372,e.name,t),r.set(t,r.size);t=r,S_.set(e,t)}return t}(e.constructor),r=null,i=!0;for(let e of t.keys()){if(r!==null&&E_(r,e,n)>0){i=!1;break}r=e}if(i)return;let a=Array.from(t).sort(([e],[t])=>E_(e,t,n));t.clear();for(let[e,n]of a)t.set(e,n)}function O_(e,t,n){t!==`__proto__`&&t!==`constructor`&&t!==`prototype`||L(373,t);let r=e.getLatest();if(r.__slots!==null&&r.__slots.get(t)===n.getLatest().__key)return r;(!G(n)&&!K(n)||n.isInline())&&L(374,n.__key);let i=e.getWritable(),a=x_(i),o=a.get(t);o!==void 0&&A_(o);let s=n.getWritable(),c=p_(s);if(c!==null){let e=m_(s);e!==null&&x_(c.getWritable()).delete(e),s.__slotHost=null}return gh(s),s.__slotHost=i.__key,a.set(t,s.__key),D_(i),function(){let e=Lg();e._slotsUsed=!0,e._pendingEditorState&&(e._pendingEditorState._slotsUsed=!0)}(),i}function k_(e,t){let n=e.getWritable();if(n.__slots===null)return n;let r=n.__slots.get(t);return r!==void 0&&(A_(r),x_(n).delete(t)),n}function A_(e){let t=bh(e);if(t===null)return;let n=t.getWritable();d_(n)||L(377,e),n.__slotHost=null,n.remove()}let j_={next:`previous`,previous:`next`};var M_=class{origin;constructor(e){this.origin=e}[Symbol.iterator](){return rv({hasNext:B_,initial:this.getAdjacentCaret(),map:e=>e,step:e=>e.getAdjacentCaret()})}getAdjacentCaret(){return G_(this.getNodeAtCaret(),this.direction)}getSiblingCaret(){return G_(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&&L(263,Array.from(o).join(` `))}else i.insert(e);i=G_(e,this.direction)}for(let e of o.values())e.remove();return this}},N_=class e extends M_{type=`child`;getLatest(){let e=this.origin.getLatest();return e===this.origin?this:Y_(e,this.direction)}getParentCaret(e=`root`){return G_(I_(this.getParentAtCaret(),e),this.direction)}getFlipped(){let e=F_(this.direction);return G_(this.getNodeAtCaret(),e)||Y_(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 P_={root:Tm,shadowRoot:og};function F_(e){return j_[e]}function I_(e,t=`root`){return e===null||P_[t](e)?null:f_(e)===null?e:null}var L_=class e extends M_{type=`sibling`;getLatest(){let e=this.origin.getLatest();return e===this.origin?this:G_(e,this.direction)}getSiblingCaret(){return this}getParentAtCaret(){return this.origin.getParent()}getChildCaret(){return G(this.origin)?Y_(this.origin,this.direction):null}getParentCaret(e=`root`){return G_(I_(this.getParentAtCaret(),e),this.direction)}getFlipped(){let e=F_(this.direction);return G_(this.getNodeAtCaret(),e)||Y_(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 R_)&&this.direction===t.direction&&this.origin.is(t.origin)}},R_=class e extends M_{type=`text`;offset;constructor(e,t){super(e),this.offset=t}getLatest(){let e=this.origin.getLatest();return e===this.origin?this:K_(e,this.direction,this.offset)}getParentAtCaret(){return this.origin.getParent()}getChildCaret(){return null}getParentCaret(e=`root`){return G_(I_(this.getParentAtCaret(),e),this.direction)}getFlipped(){return K_(this.origin,F_(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 L_||t instanceof e)&&this.direction===t.direction&&this.origin.is(t.origin)}getSiblingCaret(){return G_(this.origin,this.direction)}};function z_(e){return e instanceof R_}function B_(e){return e instanceof L_}function V_(e){return e instanceof N_}let H_={next:class extends R_{direction=`next`;getNodeAtCaret(){return this.origin.getNextSibling()}insert(e){return this.origin.insertAfter(e),this}},previous:class extends R_{direction=`previous`;getNodeAtCaret(){return this.origin.getPreviousSibling()}insert(e){return this.origin.insertBefore(e),this}}},U_={next:class extends L_{direction=`next`;getNodeAtCaret(){return this.origin.getNextSibling()}insert(e){return this.origin.insertAfter(e),this}},previous:class extends L_{direction=`previous`;getNodeAtCaret(){return this.origin.getPreviousSibling()}insert(e){return this.origin.insertBefore(e),this}}},W_={next:class extends N_{direction=`next`;getNodeAtCaret(){return this.origin.getFirstChild()}insert(e){return this.origin.splice(0,0,[e]),this}},previous:class extends N_{direction=`previous`;getNodeAtCaret(){return this.origin.getLastChild()}insert(e){return this.origin.splice(this.origin.getChildrenSize(),0,[e]),this}}};function G_(e,t){return e?new U_[t](e):null}function K_(e,t,n){return e?new H_[t](e,q_(e,n)):null}function q_(e,t,n=`error`){let r=e.getTextContentSize(),i=t===`next`?r:t===`previous`?0:t;return(i<0||i>r)&&(n!==`clamp`&&Xc(284,String(t),String(r),e.getKey()),i=i<0?0:r),i}function J_(e,t){return new $_(e,t)}function Y_(e,t){return G(e)?new W_[t](e):null}function X_(e){return e&&e.getChildCaret()||e}function Z_(e){return e&&X_(e.getAdjacentCaret())}var Q_=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 z_(t)?function(e,t){let{direction:n,origin:r}=e;return J_(e,q_(r,t===`focus`?F_(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[J_(e,r.offset-e.offset),null]}return[t,n]}iterNodeCarets(e=`root`){let t=z_(this.anchor)?this.anchor.getSiblingCaret():this.anchor.getLatest(),n=this.focus.getLatest(),r=z_(n),i=t=>t.isSameNodeCaret(n)?null:Z_(t)||t.getParentCaret(e);return rv({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`)}},$_=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 K_(e.setTextContent(i.slice(0,n)+i.slice(r)),t,n)}};function ev(e){return nv(e,G_(Dh(),e.direction))}function tv(e){return nv(e,e)}function nv(e,t){return e.direction!==t.direction&&L(265),new Q_(e,t,e.direction)}function rv(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 iv(e,t){let n=cv(e.origin,t.origin);switch(n===null&&L(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 av(n)}}function av(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 ov(e,t){return t.is(e)}function sv(e){return G(e)?[e.getLatest(),null]:[e.getParent(),e.getLatest()]}function cv(e,t){if(e.is(t))return{commonAncestor:e,type:`same`};let n=/* @__PURE__ */ new Map;for(let[t,r]=sv(e);t;r=t,t=t.getParent())n.set(t,r);for(let[r,i]=sv(t);r;i=r,r=r.getParent()){let a=n.get(r);if(a!==void 0)return a===null?(ov(e,r)||L(276),{commonAncestor:r,type:`ancestor`}):i===null?(ov(t,r)||L(277),{commonAncestor:r,type:`descendant`}):((G(a)||ov(e,a))&&(G(i)||ov(t,i))&&r.is(a.getParent())&&r.is(i.getParent())||L(278),{a,b:i,commonAncestor:r,type:`branch`})}return null}function lv(e,t){let{type:n,key:r,offset:i}=e,a=ug(e.key);return n===`text`?(V(a)||L(266,a.getType(),r),K_(a,t,i)):(G(a)||L(267,a.getType(),r),Sv(a,e.offset,t))}function uv(e,t){let{origin:n,direction:r}=t,i=r===`next`;z_(t)?e.set(n.getKey(),t.offset,`text`):B_(t)?V(n)?e.set(n.getKey(),q_(n,r),`text`):e.set(n.getParentOrThrow().getKey(),n.getIndexWithinParent()+ +!!i,`element`):(V_(t)&&G(n)||L(268),e.set(n.getKey(),i?0:n.getChildrenSize(),`element`))}function dv(e){let t=U(),n=H(t)?t:Dp();return fv(n,e),Oh(n),n}function fv(e,t){uv(e.anchor,t.anchor),uv(e.focus,t.focus)}function pv(e){let{anchor:t,focus:n}=e,r=lv(t,`next`),i=lv(n,`next`),a=iv(r,i)<=0?`next`:`previous`;return nv(bv(r,a),bv(i,a))}function mv(e){let{direction:t,origin:n}=e,r=G_(n,F_(t)).getNodeAtCaret();return r?G_(r,t):Y_(n.getParentOrThrow(),t)}function hv(e,t=`root`){let n=[e];for(let r=V_(e)?e.getParentCaret(t):e.getSiblingCaret();r!==null;r=r.getParentCaret(t))n.push(mv(r));return n}function gv(e){return!!e&&e.origin.isAttached()}function _v(e,t=`removeEmptySlices`){if(e.isCollapsed())return e;let n=`root`,r=`next`,i=t,a=xv(e,r),o=hv(a.anchor,n),s=hv(a.focus.getFlipped(),n),c=/* @__PURE__ */ new Set,l=[];for(let e of a.iterNodeCarets(n))if(V_(e))c.add(e.origin.getKey());else if(B_(e)){let{origin:t}=e;G(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),gh(e)}for(let e of u)!e.canBeEmpty()&&!og(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=mv(G_(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=qf(e.getTextContent()).setStyle(e.getStyle()).setFormat(e.getFormat());a.replaceOrInsert(n),t=K_(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(gv(e)){d=vv(e);break}for(let e of s)if(gv(e)){f=vv(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(og(i))return;!n&&t(i)&&(n=i)}return n},u=l(a,Ig),d=u&&l(o,e=>n.has(e.getKey())&&Ig(e));return d&&__(d).length>0?null:u&&d?[u,d]:null}(d,f,c);if(p){let[e,t]=p;Y_(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(V_(e)){let t=e.origin;if(Ig(t))return t}else{let t=e.getParentAtCaret();if(t&&Ig(t))return t}return null}(f),t=e&&e.getParent(),n=e&&e.getParents().findLast(ag);if(e&&t&&!Tm(t)&&e.isEmpty()&&c.has(e.getKey())&&__(e).length===0&&(!n||c.has(n.getKey()))){e.remove(!0);let n=t;for(;n&&!Tm(n)&&n.isEmpty();){let e=n.getParent();if(e&&Tm(e)&&e.getChildrenSize()<=1)break;let t=n;n=e,t.remove(!0)}}}let m=[d,f,...o,...s].find(gv);if(m)return tv(bv(vv(m),e.direction));L(269,JSON.stringify(o.map(e=>e.origin.__key)))}function vv(e){let t=function(e){let t=e;for(;V_(t);){let e=Z_(t);if(!V_(e))break;t=e}return t}(e.getLatest()),{direction:n}=t;if(V(t.origin))return z_(t)?t:K_(t.origin,n,n);let r=t.getAdjacentCaret();return B_(r)&&V(r.origin)?K_(r.origin,n,F_(n)):t}function yv(e){return z_(e)&&e.offset!==q_(e.origin,e.direction)}function bv(e,t){return e.direction===t?e:e.getFlipped()}function xv(e,t){return e.direction===t?e:nv(bv(e.focus,t),bv(e.anchor,t))}function Sv(e,t,n){let r=Y_(e,`next`);for(let e=0;e<t;e++){let e=r.getAdjacentCaret();if(e===null)break;r=e}return bv(r,n)}function Cv(e){let{origin:t,offset:n,direction:r}=e;if(n===q_(t,r))return e.getSiblingCaret();if(n===q_(t,F_(r)))return mv(e.getSiblingCaret());let[i]=t.splitText(n);return V(i)||L(281),bv(G_(i,`next`),r)}function wv(e,t){return!0}function Tv(e,{$copyElementNode:t=sg,$splitTextPointCaretNext:n=Cv,rootMode:r=`shadowRoot`,$shouldSplit:i=wv,removeEmptyDestination:a=!1}={}){if(z_(e))return n(e);let o=e.getParentCaret(r);if(o){let{origin:n}=o;if(V_(e)){let e=mv(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 Ev(e,t,n){let r=bv(t,`next`);z_(r)&&(r.offset===0?r=G_(r.origin,`previous`).getFlipped():r.offset===r.origin.getTextContentSize()&&(r=G_(r.origin,`next`))),r.origin.is(e)&&(B_(r)||L(342,e.getKey(),e.getType()),r=mv(r)),(e.is(r.getNodeAtCaret())||e.is(r.getFlipped().getNodeAtCaret()))&&e.remove(!0);for(let e=r;e;e=Tv(e,n))r=e;return z_(r)&&L(283),r.insert(e.isInline()?Vm().append(e):e),bv(G_(e.getLatest(),`next`),t.direction)}function Dv(e){return e}function Ov(e){return e}function kv(e,t){if(!t||e===t)return e;for(let n in t)if(e[n]!==t[n])return{...e,...t};return e}function Av(...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 jv(e,...t){let n=Av(...t);n.length>0&&e.classList.add(...n)}function Mv(...e){return()=>{for(let t=e.length-1;t>=0;t--)e[t]();e.length=0}}function Nv(e){throw Error(`unreachable input event: ${JSON.stringify(e)}`)}function Pv(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 Fv(e,t){return e.startsWith(t)||e===t.trimEnd()}var Iv=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 Nv(e)}}onDraftChanged(e){return this.phase===`claimed`&&this.claim!==void 0&&!Fv(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:Pv(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:Pv(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&&Fv(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 Lv(e){let t=Lg().getElementByKey(e.getKey());if(t===null)return null;let n=t.ownerDocument.defaultView;return n===null?null:n.getComputedStyle(t)}function Rv(e){return Lv(Tm(e)?e:e.getParentOrThrow())}function zv(e,t,n=`self`){let r=e.getStartEndPoints();if(t.isSelected(e)&&!uh(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]=dp(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=Kg(t)),t.__text=p)}}return t}function Bv(e){let t=Vv(e);return t!==null&&t.writingMode===`vertical-rl`}function Vv(e){let t=e.anchor.getNode();return G(t)?Lv(t):Rv(t)}function Hv(e,t){let n=Bv(e)?!t:t;Wv(e)&&(n=!n);let r=lv(e.focus,n?`previous`:`next`);if(yv(r))return!1;if(z_(r)&&!Zf(r.origin)&&r.origin.isUnmergeable()){let e=r.getNodeAtCaret();if(V(e)&&!Zf(e))return!0}for(let e of ev(r)){if(V_(e))return!e.origin.isInline();if(!G(e.origin)){if(K(e.origin))return!0;break}}return!1}function Uv(e,t,n,r){e.modify(t?`extend`:`move`,n,r)}function Wv(e){let t=Vv(e);return t!==null&&t.direction===`rtl`}function Gv(e,t,n){let r=Wv(e),i;i=Bv(e)||r?!n:n,Uv(e,t,i,`character`)}function Kv(e,t){return e!==null&&Object.getPrototypeOf(e).constructor.name===t.name}let qv=Symbol.for(`preact-signals`);function Jv(){if(Qv>1)return void Qv--;let e,t=!1;for(function(){let e=Zv;for(Zv=void 0;e!==void 0;)e.S.v===e.v&&(e.S.i=e.i),e=e.o}();Yv!==void 0;){let n=Yv;for(Yv=void 0,$v++;n!==void 0;){let r=n.u;if(n.u=void 0,n.f&=-3,!(8&n.f)&&ry(n))try{n.c()}catch(n){t||=(e=n,!0)}n=r}}if($v=0,Qv--,t)throw e}let X,Yv;function Xv(e){let t=X;X=void 0;try{return e()}finally{X=t}}let Zv,Qv=0,$v=0,ey=0;function ty(e){if(X===void 0)return;let t=e.n;return t===void 0||t.t!==X?(t={i:0,S:e,p:X.s,n:void 0,t:X,e:void 0,x:void 0,r:t},X.s!==void 0&&(X.s.n=t),X.s=t,e.n=t,32&X.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=X.s,t.n=void 0,X.s.n=t,X.s=t),t):void 0}function ny(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 ry(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 iy(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 ay(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 oy(e,t){ny.call(this,void 0),this.x=e,this.s=void 0,this.g=ey-1,this.f=4,this.W=t?.watched,this.Z=t?.unwatched,this.name=t?.name}function sy(e){let t=e.m;if(e.m=void 0,typeof t==`function`){Qv++;let n=X;X=void 0;try{t()}catch(t){throw e.f&=-2,e.f|=8,cy(e),t}finally{X=n,Jv()}}}function cy(e){for(let t=e.s;t!==void 0;t=t.n)t.S.U(t);e.x=void 0,e.s=void 0,sy(e)}function ly(e){if(X!==this)throw Error(`Out-of-order effect`);ay(this),X=e,this.f&=-2,8&this.f&&cy(this),Jv()}function uy(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 dy(e,t){let n=new uy(e,t);try{n.c()}catch(e){throw n.d(),e}let r=n.d.bind(n);return r[Symbol.dispose]=r,r}ny.prototype.brand=qv,ny.prototype.h=function(){return!0},ny.prototype.S=function(e){let t=this.t;t!==e&&e.e===void 0&&(e.x=t,this.t=e,t===void 0?Xv(()=>{var e;(e=this.W)==null||e.call(this)}):t.e=e)},ny.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&&Xv(()=>{var e;(e=this.Z)==null||e.call(this)}))}},ny.prototype.subscribe=function(e){return dy(()=>{let t=this.value,n=X;X=void 0;try{e(t)}finally{X=n}},{name:`sub`})},ny.prototype.valueOf=function(){return this.value},ny.prototype.toString=function(){return this.value+``},ny.prototype.toJSON=function(){return this.value},ny.prototype.peek=function(){let e=X;X=void 0;try{return this.value}finally{X=e}},Object.defineProperty(ny.prototype,"value",{get(){let e=ty(this);return e!==void 0&&(e.i=this.i),this.v},set(e){if(e!==this.v){if($v>100)throw Error(`Cycle detected`);(function(e){Qv!==0&&$v===0&&e.l!==0&&(e.l=0,Zv={S:e,v:e.v,i:e.i,o:Zv})})(this),this.v=e,this.i++,ey++,Qv++;try{for(let e=this.t;e!==void 0;e=e.x)e.t.N()}finally{Jv()}}}}),oy.prototype=new ny,oy.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===ey))return!0;if(this.g=ey,this.f|=1,this.i>0&&!ry(this))return this.f&=-2,!0;let e=X;try{iy(this),X=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 X=e,ay(this),this.f&=-2,!0},oy.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)}ny.prototype.S.call(this,e)},oy.prototype.U=function(e){if(this.t!==void 0&&(ny.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)}},oy.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(oy.prototype,"value",{get(){if(1&this.f)throw Error(`Cycle detected`);let e=ty(this);if(this.h(),e!==void 0&&(e.i=this.i),16&this.f)throw this.v;return this.v}}),uy.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()}},uy.prototype.S=function(){if(1&this.f)throw Error(`Cycle detected`);this.f|=1,this.f&=-9,sy(this),iy(this),Qv++;let e=X;return X=this,ly.bind(this,e)},uy.prototype.N=function(){2&this.f||(this.f|=2,this.u=Yv,Yv=this)},uy.prototype.d=function(){this.f|=8,1&this.f||cy(this)},uy.prototype.dispose=function(){this.d()};function fy(e){return(typeof e.nodes==`function`?e.nodes():e.nodes)||[]}function Z(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 py;try{py=`0.49.0+prod.esm`}catch{}let my=py??`"<unknown>+source"`,hy=/* @__PURE__ */ new Set([`__proto__`,`constructor`,`prototype`]);function gy(e,t){if(e&&t&&!Array.isArray(t)&&typeof e==`object`&&typeof t==`object`){let n=e,r=t;for(let e in r)!hy.has(e)&&Object.prototype.hasOwnProperty.call(r,e)&&(n[e]=gy(n[e],r[e]));return e}return t}function _y(e){return e.id===0}function vy(e){return e.id===2}function yy(e){return function(e){return e.id===1}(e)||Z(305,String(e.id),`1`),Object.assign(e,{id:2})}let by=/* @__PURE__ */ new Set;var xy=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):kv;for(let n of this.configs)e=t(e,n);return e}init(e){let t=this.state;vy(t)||Z(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&&Z(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&&Z(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&&Z(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&&Z(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&&Z(311),this._signal}getInitResult(){this.extension.init===void 0&&Z(312,this.extension.name);let e=this.state;return function(e){return e.id>=4}(e)||Z(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)||Z(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&&Z(315,this.extension.name,e.name),t.getExtensionInitDependency()}getDependency(e){let t=this.builder.getExtensionRep(e);return t===void 0&&Z(315,this.extension.name,e.name),t.getExtensionDependency()}getState(){let e=this.state;return function(e){return e.id>=7}(e)||Z(316,String(e.id),`7`),e}getDirectDependentNames(){return this.builder.incomingEdges.get(this.extension.name)||by}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)||Z(317,this.extension.name),this._dependency={config:e.config,init:e.initResult,output:e.output}}return this._dependency}};let Sy={tag:wf};function Cy(){let e=Dh();e.isEmpty()&&e.append(Vm())}let wy=/* @__PURE__ */ Dv({config:/* @__PURE__ */ Ov({setOptions:Sy,updateOptions:Sy}),init:({$initialEditorState:e=Cy})=>({$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(km(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:[wm,Rf,Mm,Yf,zm]}),Ty=Symbol.for(`@lexical/extension/LexicalBuilder`);function Ey(){}function Dy(e){throw e}function Oy(e){return Array.isArray(e)?e:[e]}let ky=my;var Ay=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=ky,this.roots=e;for(let t of e)this.addExtension(t)}static fromExtensions(t){let n=[Oy(wy)];for(let e of t)n.push(Oy(e));return new e(n)}static maybeFromEditor(t){let n=t[Ty];return n&&(n.PACKAGE_VERSION!==ky&&Z(292,n.PACKAGE_VERSION,ky),n instanceof e||Z(293)),n}static fromEditor(t){let n=e.maybeFromEditor(t);return n===void 0&&Z(294),n}constructEditor(){let{$initialEditorState:e,onError:t,onWarn:n,...r}=this.buildCreateEditorArgs(),i=Object.assign(qm({...r,...t?{onError:e=>{t(e,i)}}:{},...n?{onWarn:e=>{n(e,i)}}:{}}),{[Ty]:this});for(let e of this.sortedExtensionReps())e.build(i);return i}buildEditor(){let e=Ey;function t(){try{e()}finally{e=Ey}}let n=Object.assign(this.constructEditor(),{dispose:t,[Symbol.dispose]:t});return e=Mv(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&&Z(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&&Z(296);let[t]=Oy(e);typeof t.name!=`string`&&Z(297,typeof t.name);let n=this.extensionNameMap.get(t.name);if(n!==void 0&&n.extension!==t&&Z(298,t.name),!n){n=new xy(this,t),this.extensionNameMap.set(t.name,n);let e=this.conflicts.get(t.name);typeof e==`string`&&Z(299,t.name,e);for(let e of t.conflictsWith||[])this.extensionNameMap.has(e)&&Z(299,t.name,e),this.conflicts.set(e,t.name);for(let e of t.dependencies||[]){let n=Oy(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(vy(i))return;let a=n.extension.name;var o;_y(i)||Z(300,a,r||`[unknown]`),_y(o=i)||Z(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=yy(i),n.state=i,e.push(n)};for(let e of this.extensionNameMap.values())_y(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&&Z(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 Mv(...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 fy(o)){if(typeof e!=`function`){let t=n.get(e.replace);t&&Z(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&&gy(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||=Dy,e}};function jy(e,t){let n=Ay.maybeFromEditor(e);if(!n)return;let r=n.extensionNameMap.get(t);return r?r.getExtensionDependency():void 0}var My=class extends Cm{$config(){return this.config(`horizontalrule`,{importDOM:{hr:()=>({conversion:Ny,priority:0})}})}exportDOM(){return{element:bg().createElement(`hr`)}}createDOM(e){let t=bg().createElement(`hr`);return jv(t,e.theme.hr),t}getTextContent(){return`
|
|
155
|
+
`}isInline(){return!1}updateDOM(){return!1}};function Ny(){return{node:Py()}}function Py(){return a_(My)}Date.now;function Fy(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 Iy;function Ly(e,t){let{key:n}=t;return e&&n in e?e[n]:t.defaultValue}function Ry(e){return Iy&&Iy.editor===e?Iy:void 0}function zy(e,t){if(`cfg`in t){let{cfg:n,updater:r}=t;return[n,r(Ly(e,n))]}return t}function By(e,t){let n=t;for(let r of e){let[e,i]=zy(n,r),a=e.key;if(n===t&&Ly(n,e)===i)continue;let o=n===t||n===void 0?Vy(t):n;o[a]=i,n=o}return n}function Vy(e){return Object.create(e||null)}function Hy(e,t){return[e,t]}function Uy(e,t,n,r=Lg()){let i=Iy,a=Ry(r);try{return Iy={...a,editor:r,[e]:t},n()}finally{Iy=i}}function Wy(e,t=()=>{}){return(n,r=Lg())=>i=>{let a=Ry(r),o=a&&a[e],s=By(n,o||t(r));return s&&s!==o?Uy(e,s,i,r):i()}}function Gy(e,t,n,r){return Object.assign(Hl(Symbol(t),{isEqual:r,parse:n}),{[e]:!0})}let Ky=`@lexical/html/DOM`,qy=Symbol.for(`@lexical/html/DOMExportContext`);function Jy(e,t,n){return Gy(qy,e,t,n)}let Yy=/* @__PURE__ */ Jy(`isExport`,Boolean);function Xy(e){let t=jy(e,Ky);return t?t.output.defaults:void 0}function Zy(e){let t=jy(e,Ky);return t?t.output.runtime:void 0}function Qy(e=Lg()){let t=Zy(e);return t?t.getSessionConfig():Rg(e)}let $y=Wy(qy,Xy),eb=Symbol.for(`@lexical/html/SelectorImpl`);function tb(e,t){let n={kind:`element`,predicate:(r=t,r.length===0?Y: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=>tb(e,[...t,n]);return{[eb]:n,attr:(e,t,n)=>i(ib(e,t,n)),classAll:(...e)=>i(rb(e)),classAny:(...e)=>i(function(e){let t=nb(e);return t.length===0?()=>!1:e=>{if(!Y(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=>Y(n)&&n.style.getPropertyValue(e)===t;if(t instanceof RegExp){let r=n&&n.capture,i=t;return(t,n)=>{if(!Y(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)}}Fy(362,JSON.stringify(e))}(e,t,n))}}function nb(e){let t=[];for(let n of e)n&&t.push(n);return t}function rb(e){let t=nb(e);return t.length===0?()=>!0:e=>{if(!Y(e))return!1;let n=e.classList;for(let e of t)if(!n.contains(e))return!1;return!0}}function ib(e,t,n){if(!0===t)return t=>Y(t)&&t.hasAttribute(e);if(typeof t==`string`)return n=>Y(n)&&n.getAttribute(e)===t;if(t instanceof RegExp){let r=n&&n.capture,i=t;return(t,n)=>{if(!Y(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)}}Fy(361,JSON.stringify(e))}let ab={kind:`text`,predicate:dh,tags:/* @__PURE__ */ new Set},ob={[eb]:ab},sb={kind:`comment`,predicate:e=>e.nodeType===8,tags:/* @__PURE__ */ new Set},cb={[eb]:sb},lb={any:()=>tb(/* @__PURE__ */ new Set,[]),comment:()=>cb,tag(...e){e.length>0||Fy(363);let t=/* @__PURE__ */ new Set;for(let n of e)t.add(n.toUpperCase());return tb(t,[])},text:()=>ob},ub=lb;ub.tag(`b`,`strong`,`em`,`i`,`code`,`mark`,`s`,`sub`,`sup`,`u`,`span`),ub.text(),ub.tag(`script`,`style`),ub.tag(`br`),ub.tag(`p`),ub.tag(`hr`),ub.any(),Object.freeze([]),Object.freeze({}),lb.any(),lb.any,lb.comment,lb.tag,lb.text;function db(e,t=null,n=Lg()){return $y([Hy(Yy,!0)],n)(()=>{let r=Dh(),i=Qy(n),a=H(t)?h_(t.anchor.getNode()):null,o=e.append.bind(e);for(let e of(G(a)?a:r).getChildren())pb(n,e,o,t,i);return e})}function fb(e,t=null){return(typeof document>`u`||typeof window>`u`&&global.window===void 0)&&Fy(338),im(e),db(bg().createElement(`div`),t,e).innerHTML}function pb(e,t,n,r=null,i=Rg(e)){let a=i.$shouldInclude(t,r,e),o=i.$shouldExclude(t,r,e),s=t;r!==null&&V(t)&&(s=zv(r,t,`clone`));let{element:c,after:l,append:u,$getChildNodes:d}=i.$exportDOM(s,e);if(!c)return!1;let f=bg().createDocumentFragment(),p=d?d():G(s)?s.getChildren():[],m=a&&sp(r)&&G(t)?null:r,h=f.append.bind(f);for(let n of p){let o=pb(e,n,h,m,i);!a&&o&&i.$extractWithChild(t,n,r,`html`,e)&&(a=!0)}if(a&&!o){if((Y(c)||jg(c))&&(u?u(f):c.append(f)),n(c),l){let e=l.call(s,c);e&&(jg(c)?c.replaceChildren(e):c.replaceWith(e))}}else n(f);return a}function mb(e,t,n=null){let r=yg(n),i=n?_g(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=Xh(n)}return!1}(a.offsetNode,n))return{node:a.offsetNode,offset:a.offset}}if(a){let i=n.getRootNode();if(hg(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 hb(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 gb(e,t=U()){return t??hb(166),H(t)&&t.isCollapsed()||t.getNodes().length===0?``:fb(e,t)}function _b(e,t){let n=e.getData(`text/plain`)||e.getData(`text/uri-list`);n!=null&&t.insertRawText(n)}let vb=`application/x-lexical-drag`;function yb(e,t){let n={editorKey:t.getKey()};e.setData(vb,JSON.stringify(n))}function bb(e,t,n){let r=e.dataTransfer;if(r===null)return!1;let i=function(e){let t=e.getData(vb);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=mb(e.clientX,e.clientY,t.getRootElement());if(n===null)return null;let r=wh(n.node);if(r===null)return null;if(V(r))return K_(r,`next`,n.offset);if(G(r))return Sv(r,n.offset,`next`);let i=r.getParent();return i===null?null:Sv(i,r.getIndexWithinParent()+1,`next`)}(e,t);if(a===null)return!1;let o=Tv(a);if(o===null)return!1;let s=i.editorKey===t.getKey(),c=U();if(s){if(!H(c)||c.isCollapsed())return!1;if(function(e,t){let{anchor:n,focus:r}=xv(pv(t),`next`);return iv(n,e)<0&&iv(e,r)<0}(a,c))return e.preventDefault(),!0;c.removeText()}if(!o.origin.isAttached())return e.preventDefault(),!0;if(n(r,dv(tv(o)),t),!s){let e=t.getRootElement(),n=e?e.ownerDocument:null,r=n?function(e,t){for(let n of vg(t)){let t=ch(n);if(oh(t)&&t.getKey()===e&&Y(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 xb(e,t){return bb(e,t,(e,t)=>_b(e,t))}function Sb(e,t){t.update(()=>{if(e!==null){let n=Kv(e,KeyboardEvent)?null:e.clipboardData,r=U();if(r!==null&&!r.isCollapsed()&&n!=null){e.preventDefault();let i=gb(t);i!==null&&n.setData(`text/html`,i),n.setData(`text/plain`,r.getTextContent())}}})}function Cb(e){return Mv(e.registerCommand(rd,e=>{let t=U();return!!H(t)&&(t.deleteCharacter(e),!0)},0),e.registerCommand(ld,e=>{let t=U();return!!H(t)&&(t.deleteWord(e),!0)},0),e.registerCommand(ud,e=>{let t=U();return!!H(t)&&(t.deleteLine(e),!0)},0),e.registerCommand(od,e=>{let t=U();if(!H(t))return!1;if(typeof e==`string`)t.insertText(e);else{let n=e.dataTransfer;if(n!=null)_b(n,t);else{let n=e.data;n&&t.insertText(n)}}return!0},0),e.registerCommand(cd,()=>{let e=U();return!!H(e)&&(e.removeText(),!0)},0),e.registerCommand(id,e=>{let t=U();return!!H(t)&&(t.insertLineBreak(e),!0)},0),e.registerCommand(ad,()=>{let e=U();return!!H(e)&&(e.insertLineBreak(),!0)},0),e.registerCommand(_d,e=>{let t=U();if(!H(t))return!1;let n=e,r=n.shiftKey;return!!Hv(t,!0)&&(n.preventDefault(),Gv(t,r,!0),!0)},0),e.registerCommand(hd,e=>{let t=U();if(!H(t))return!1;let n=e,r=n.shiftKey;return!!Hv(t,!1)&&(n.preventDefault(),Gv(t,r,!1),!0)},0),e.registerCommand(Cd,t=>!!H(U())&&(!nl||!tl)&&(t.preventDefault(),e.dispatchCommand(rd,!0)),0),e.registerCommand(Td,t=>!!H(U())&&(t.preventDefault(),e.dispatchCommand(rd,!1)),0),e.registerCommand(xd,t=>{if(!H(U()))return!1;if(t!==null){if((nl||il||sl)&&tl)return!1;t.preventDefault()}return e.dispatchCommand(id,!1)},0),e.registerCommand(Nd,()=>{let e=U();return Uh(H(e)&&h_(e.anchor.getNode())!==null?e:null),!0},0),e.registerCommand(jd,t=>!!H(U())&&(Sb(t,e),!0),0),e.registerCommand(Md,t=>!!H(U())&&(function(e,t){Sb(e,t),t.update(()=>{let e=U();H(e)&&e.removeText()},{tag:`cut`})}(t,e),!0),0),e.registerCommand(sd,t=>!!H(U())&&(function(e,t){e.preventDefault(),t.update(()=>{let t=U(),n=Kv(e,ClipboardEvent)?e.clipboardData:null;n!=null&&H(t)&&_b(n,t)},{tag:`paste`})}(t,e),!0),0),e.registerCommand(Dd,t=>xb(t,e),0),e.registerCommand(Od,t=>{let n=U();return!!H(n)&&(n.isCollapsed()||t.dataTransfer===null||yb(t.dataTransfer,e),!0)},0))}function wb(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(!(H(a)&&H(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||Tm(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)&&V(r)&&r.__text.length===1&&a.anchor.offset===1?2:0}let c=s[0],l=e._nodeMap.get(c.__key);if(!V(l)||!V(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 Tb(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:wb(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!(H(a)&&H(o)&&a.anchor.type===`element`&&a.focus.type===`element`&&o.anchor.type===`text`&&o.focus.type===`text`||!V(r)||!V(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 Eb(e,t){e.undoStack=[],e.redoStack=[],e.current=null,t&&t(e)}function Db(e,t,n,r=Date.now,i,a=null){let o=Tb(e,n,r),s=()=>{i&&i(t)};return s(),Mv(e.registerCommand(fd,()=>(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(Id,!0)),i.length===0&&e.dispatchCommand(Ld,!1),t.current=o||null,n&&n(t),o&&o.editor.setEditorState(o.editorState,{tag:`historic`})}}(e,t,i),!0),0),e.registerCommand(pd,()=>(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(Ld,!0));let o=r.pop();r.length===0&&e.dispatchCommand(Id,!1),t.current=o||null,n&&n(t),o&&o.editor.setEditorState(o.editorState,{tag:`historic`})}}(e,t,i),!0),0),e.registerCommand(Pd,()=>(Eb(t,i),!1),0),e.registerCommand(Fd,()=>(Eb(t,i),e.dispatchCommand(Id,!1),e.dispatchCommand(Ld,!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(Id,!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(Ld,!0)}}else if(m===2)return;t.current={editor:e,editorState:n},s()}))}function Ob(){return{current:null,redoStack:[],undoStack:[]}}Date.now;let kb=`application/x-codexhost-thread-reference`;function Ab(e){let t=e.projectionValues?.threadReference;if(!e.blank&&t?.hostId&&(t.hostId===`local`||/^remote-(?:ssh(?:-|:)|control:)/u.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 jb(e){return`thread://${encodeURIComponent(e.threadId).replace(/[!'()*]/gu,e=>`%${e.charCodeAt(0).toString(16).toUpperCase()}`)}?hostId=${encodeURIComponent(e.hostId)}`}function Mb(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(!/^remote-(?:ssh(?:-|:)|control:)/u.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 Nb(e){let t=`[@${e.title.replace(/[\\`*{}[\]()#+.!_<>|~-]/gu,e=>`\\${e}`)}](${jb(e)})`;return{source:`codexhost-thread`,ref:t,label:e.title,appearance:`session`,clipboardText:t}}function Pb(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`&&!/^remote-(?:ssh(?:-|:)|control:)/u.test(r)||typeof i!=`string`?void 0:Ab({id:n,blank:!1,title:i,projectionValues:{threadReference:{hostId:r,threadId:n}}})}catch{return}}function Fb(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=Fb(e[t]))&&(r&&(r+=` `),r+=n)}else for(n in e)e[n]&&(r&&(r+=` `),r+=n)}return r}function Ib(){for(var e,t,n=0,r=``,i=arguments.length;n<i;n++)(e=arguments[n])&&(t=Fb(e))&&(r&&(r+=` `),r+=t);return r}let Lb=`@deepseek-ai/dsh-client-ui-conversation/ReferenceChip.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(Lb)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-conversation`,e.dataset.pluginCss=Lb,e.textContent=`.HsYvBG_chip{max-width:240px;color:var(--dsw-alias-state-business-primary);user-select:none;align-items:baseline;gap:3px;display:inline-flex}.HsYvBG_marker{flex:none;font-weight:500}.HsYvBG_icon{flex:none;align-self:center}.HsYvBG_label{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.HsYvBG_invalid{color:var(--dsw-alias-state-error-primary);opacity:.7;text-decoration:line-through}`,document.head.appendChild(e)}var Rb={chip:`HsYvBG_chip`,icon:`HsYvBG_icon`,invalid:`HsYvBG_invalid`,label:`HsYvBG_label`,marker:`HsYvBG_marker`};let zb=`@deepseek-ai/dsh-client-ui-conversation/composer-editor.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(zb)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-conversation`,e.dataset.pluginCss=zb,e.textContent=`._06X5vW_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}._06X5vW_reference:hover{background:var(--dsw-alias-state-business-tertiary)}._06X5vW_openable{cursor:pointer}._06X5vW_textRef{max-width:100%;display:inline-block}`,document.head.appendChild(e)}var Bb={openable:`_06X5vW_openable`,reference:`_06X5vW_reference`,textRef:`_06X5vW_textRef`};function Vb({label:e,reference:t,appearance:n,invalid:r}){return/* @__PURE__ */ (0,h.jsxs)(`span`,{className:Ib(Bb.reference,Rb.chip,n===`file`&&!r&&Bb.openable,r&&Rb.invalid),title:e,children:[n===void 0?/* @__PURE__ */ (0,h.jsx)(`span`,{className:Rb.marker,"aria-hidden":!0,children:`@`}):/* @__PURE__ */ (0,h.jsx)(d.ReferenceIconRegular,{kind:n,reference:t,size:14,className:Rb.icon}),/* @__PURE__ */ (0,h.jsx)(`span`,{className:Rb.label,children:e})]})}var Hb=class e extends Cm{__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)(Vb,{label:this.__label,reference:this.__ref,appearance:this.__appearance,invalid:this.__invalid})}};function Ub(e){return new Hb(e)}function Wb(e){return e instanceof Hb}function Gb(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 Kb(e,t,n,r){let i=e=>e instanceof n,a=e=>{let t=qf(e.getTextContent());t.setFormat(e.getFormat()),e.replace(t)};return[e.registerNodeTransform(Rf,e=>{if(!e.isSimpleText())return;let n,o=e.getPreviousSibling(),s=e.getTextContent(),c=e;if(V(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(V(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&&V(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&&Gb(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();V(o)&&o.isTextEntity()&&(a(o),a(e));let s=e.getNextSibling();V(s)&&s.isTextEntity()&&(a(s),i(e)&&a(e))})]}let qb=/(^|\s)([/@])([\w-]+)/g,Jb=/(^|\s)(@(?:"[^"\n]*"?|[^\s"]\S*))/g,Yb=/* @__PURE__ */ new Set(`.,;:!?,。;:!?`),Xb=/^@.*[/\\.]/u;function Zb(e,t,n){if(!n.startsWith(`@"`)){let e=n.length;for(;Yb.has(n.charAt(e-1));)--e;return Xb.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(;Yb.has(e.charAt(i));)i+=1;return i===e.length||/\s/u.test(e.charAt(i))?t+r+1:void 0}let Qb=/^(?:\s|$)/;function $b(e,t){if(e===``)return[];let n=[];qb.lastIndex=0;let r;for(;(r=qb.exec(e))!==null;){let i=r[2],a=r[3]??``;if((i!==`/`||Qb.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})}}Jb.lastIndex=0;let i;for(;(i=Jb.exec(e))!==null;){let t=i.index+(i[1]?.length??0),r=Zb(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 ex=class e extends Rf{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=Ib(t.className,Bb.reference,Bb.textRef,this.getTextContent().startsWith(`/`)&&Bb.openable),t.setAttribute(`spellcheck`,`false`),t.setAttribute(`data-composer-text-ref`,``),t}isTextEntity(){return!0}canInsertTextBefore(){return!0}};function tx(e,t,n){return Mv(...Kb(e,e=>{let r=n();for(let n of $b(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},ex,e=>new ex(e.getTextContent())))}function nx(e){e.update(()=>{for(let e of Dh().getAllTextNodes())(e instanceof ex||e.getPreviousSibling()instanceof ex||/[/@]/u.test(e.getTextContent()))&&e.markDirty()},{tag:wf})}function rx(e,t){return e.registerCommand(Qu,e=>{if(e.target===null||e.button!==0||e.detail>1)return!1;let n=U();if(H(n)&&!n.isCollapsed())return!1;let r=wh(e.target);if(Wb(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 ex&&t(void 0,{ref:r.getTextContent()})},1)}function ix(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 ax=Bs([k(),A(),j(),Ms()]);function ox(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 sx=bc(ox,{message:`JSON value must not contain circular references`}),cx=vc(()=>Bs([ax,M(cx),Js(k(),cx)])),lx=sx.pipe(cx);sx.pipe(M(cx));let ux=sx.pipe(Js(k(),cx)),dx=P({code:k().min(1),message:k().min(1),retryable:j(),diagnostic:k().min(1).optional(),stage:k().min(1).optional(),durationMs:A().int().nonnegative().optional(),stderrTail:k().min(1).optional()}).superRefine(ix([`diagnostic`,`stage`,`durationMs`,`stderrTail`])),fx=k().max(64).regex(/^[a-z]{2,3}(?:-[A-Za-z0-9]{2,8})*$/u),px=e=>k().min(1).max(e).refine(e=>e.trim().length>0),mx=Js(fx,N({label:px(256).optional(),description:px(1024).optional()}).strict()).refine(e=>Object.keys(e).length<=16,`Too many locales`),hx=Js(fx,px(4096)).refine(e=>typeof e.en==`string`,`English fallback is required`).refine(e=>Object.keys(e).length<=16,`Too many locales`),gx=k().refine(e=>e.trim().length>0,{message:`Identifier must not be empty or whitespace`}),_x=gx.brand(),vx=gx.brand(),yx=gx.brand();gx.brand(),gx.brand();let bx=k().refine(e=>e.trim().length>0,{message:`Value must not be empty or whitespace`}),xx=bx.max(128).regex(/^[A-Za-z0-9._~:-]+$/u,`Permission Mode ID must use transport-safe characters`).brand(),Sx=N({modes:M(N({id:xx,label:bx.max(256),description:bx.max(1024).optional(),dangerous:j().optional(),localizations:mx.optional()}).strict()).min(1).max(32),defaultModeId:xx}).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`]})});N({threadId:vx,permissionModeId:xx}).strict();let Cx=A().int().safe().nonnegative(),wx=A().finite().nonnegative(),Tx=A().finite().min(0).max(100),Ex=N({version:Bs([I(3),I(4)]).optional(),requestId:k().min(1),turnId:k().min(1).max(1024),outputTokens:Cx,startedAtMs:Cx,completedAtMs:Cx}).strict().refine(e=>e.completedAtMs>e.startedAtMs),Dx=N({version:Bs([I(2),I(3),I(4)]).optional(),value:wx,turnId:k().min(1).max(1024),at:Cx}).strict();N({outputTimings:M(Ex).transform(e=>e.filter(e=>e.version===4)).optional(),outputTokensPerSecond:Dx.refine(e=>e.version===4).optional().catch(void 0),timeToFirstOutputMs:Dx.extend({value:Cx}).optional()}).strict();let Ox=e=>hx.refine(t=>Object.values(t).every(t=>t.length<=e)),kx=N({composerIndicators:M(N({kind:I(`countdown`),id:k().min(1).max(64),expiresAtUnix:Cx,label:Ox(256).optional(),tooltip:Ox(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:Cx.optional(),cachedInputTokens:Cx.optional(),cacheWriteInputTokens:Cx.optional(),outputTokens:Cx.optional(),outputTokensPerSecond:wx.optional(),sessionOutputTokensPerSecond:wx.optional(),apiOutputTokensPerSecond:wx.optional(),reasoningOutputTokens:Cx.optional(),totalTokens:Cx.optional(),totalCostUsd:wx.optional(),totalCredits:wx.optional(),contextUsagePercent:wx.optional(),cacheHitRatePercent:Tx.optional(),contextWindowTokens:Cx.optional(),contextUsedTokens:Cx.optional(),planFiveHourUsedPercent:Tx.optional(),planFiveHourResetsAtUnix:Cx.optional(),planSevenDayUsedPercent:Tx.optional(),planSevenDayResetsAtUnix:Cx.optional(),sessionCacheHitRatePercent:Tx.optional(),timeToFirstOutputMs:Cx.optional(),latestRequestTimeToFirstOutputMs:Cx.optional(),costSource:F([`publicPrice`,`native`]).optional(),unpricedModels:M(k().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`]})}),Ax=A().finite().min(0).max(100),jx=F([`weekly`,`monthly`,`five_hour`,`seven_day`,`unknown`]),Mx=N({id:k().min(1).max(256),label:k().min(1).max(256),localizations:mx.optional()}).strict(),Nx=N({product:k().min(1),periodType:jx.optional(),scope:Mx.optional(),localizations:mx.optional(),used:A().finite().nonnegative().optional(),limit:A().finite().nonnegative().optional(),unit:k().min(1).max(32).optional(),usagePercent:Ax,resetsAt:k().min(1).optional()}).strict(),Px=N({availableCount:A().int().safe().positive(),nextExpiresAt:k().min(1).optional(),expiresAt:M(k().min(1)).min(1).max(32).optional()}).strict(),Fx=N({used:A().finite().nonnegative().optional(),limit:A().finite().nonnegative().optional(),unit:k().min(1).max(32).optional(),label:k().min(1).optional(),scope:Mx.optional(),localizations:mx.optional(),usedPercent:Ax,resetsAt:k().min(1).optional(),periodType:jx,productUsage:M(Nx).min(1).optional(),resetCredits:Px.optional()}).strict(),Ix=N({amount:A().finite().nonnegative(),currency:k().trim().min(1).max(8),label:k().trim().min(1).max(128).optional()}).strict();N({threadId:vx,refresh:I(`exact`).optional()}).strict(),N({threadId:vx,usage:kx.nullable(),accountCredits:Fx.optional(),accountBalance:Ix.optional(),accountCreditsSupported:j().optional()}).strict();let Lx=k().refine(e=>e.trim().length>0,{message:`Value must not be empty or whitespace`}),Rx=k().min(1).max(512).refine(e=>!/\p{Cc}/u.test(e),`Model Ref must not contain control characters`).brand(),zx=F([`priority`,`ultrafast`]),Bx=N({id:Rx,serviceTier:zx.optional()}).strict();function Vx(e,t){return e?.id===t?.id&&e?.serviceTier===t?.serviceTier}let Hx=Lx.max(128).regex(/^[A-Za-z0-9._~-]+$/u,`Thinking option ID must use transport-safe characters`).brand(),Ux=Lx.max(256),Wx=N({id:Hx,label:Lx.max(256)}).strict(),Gx=N({ref:Bx,label:Lx.max(256),resolvedModelLabel:Ux.optional(),fastModel:Bx.optional(),supportedThinkingOptionIds:M(Hx).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 Kx(e,t){if(t)return e?.models.find(e=>Vx(e.ref,t)||Vx(e.fastModel,t))}let qx=M(Wx).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)}),Jx=N({models:M(Gx),defaultModel:Bx.optional(),thinkingOptions:qx,defaultThinkingOptionId:Hx.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=>Vx(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=>Vx(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&&!Kx(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`]})}),Yx=N({fork:j(),forkAcrossCwd:j(),rollbackLastTurn:j()}).strict().refine(e=>e.fork||!e.forkAcrossCwd,{path:[`forkAcrossCwd`],message:`Cross-cwd Fork requires exact history Fork support`}),Xx=F([`live`,`atCreate`]),Zx=N({configuration:N({selectModel:j(),selectThinkingOption:j(),selectPermissionMode:j(),permissionModeScope:Xx.default(`live`)}).strict(),history:Yx,subagents:N({observe:j(),readTranscript:j()}).strict().optional(),autonomousTurns:N({observe:j()}).strict().optional(),steer:j().optional(),persistentPlan:j().optional()}).strict();N({effectiveModel:Bx.optional(),resolvedModelLabel:Ux.optional(),effectiveThinkingOptionId:Hx.optional(),availableThinkingOptions:qx.optional(),effectivePermissionModeId:xx.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 Qx=N({open:I(!0)}).strict();Bs([N({status:I(`ready`),catalog:Jx,permissionModes:Sx.optional(),capabilities:Zx,webUi:Qx.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`]})}),N({status:F([`notInstalled`,`unavailable`,`error`]),error:dx}).strict()]),N({harnessId:_x,cwd:Lx.max(16384).optional(),refresh:j().optional(),purpose:I(`availability`).optional(),credentialAccess:F([`allow`,`retry`]).optional()}).strict(),N({harnessId:_x}).strict(),N({}).strict(),N({threadId:vx,model:Bx}).strict(),N({threadId:vx,thinkingOptionId:Hx}).strict(),N({threadId:vx,includeReferenceCapability:j().optional()}).strict(),Hs(`owner`,[N({owner:I(`codex`),locked:j(),effectiveModel:Bx.optional(),resolvedModelLabel:Ux.optional(),effectiveThinkingOptionId:Hx.optional(),effectivePermissionModeId:xx.optional(),history:Yx.optional(),supportsThreadReferences:I(!0).optional()}).strict(),N({owner:I(`external`),harnessId:Lx.max(256),transportModelId:Lx.max(8192),effectiveModel:Bx.optional(),resolvedModelLabel:Ux.optional(),effectiveThinkingOptionId:Hx.optional(),availableThinkingOptions:qx.optional(),effectivePermissionModeId:xx.optional(),history:Yx,usage:kx.optional(),locked:I(!0)}).strict()]),N({threadIds:M(vx).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 $x=Hs(`owner`,[N({threadId:vx,owner:I(`codex`)}).strict(),N({threadId:vx,owner:I(`external`),harnessId:k().max(256).pipe(_x)}).strict()]);N({threads:M($x).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)}),N({threadId:vx,text:k().optional()}).strict(),N({kind:I(`application`),value:k().transform((e,t)=>{try{return JSON.parse(e)}catch{return t.addIssue({code:`custom`,message:`Invalid steering context JSON`}),Et}}).pipe(N({expectedTurnId:yx,clientUserMessageId:k().min(1),delivery:F([`newTurn`,`activeTurn`])}).strict())}).strict().transform(e=>e.value),F([`activeTurn`,`newTurn`]),N({delivery:F([`official`,`activeTurn`,`newTurn`])}).strict();let eS=k().min(1).max(128).regex(/^[a-z][a-z0-9]*(?:[._-][a-z0-9]+)*$/u),tS=eS.pipe(_x),nS=tS.refine(e=>e!==`codex`,`The official Codex identity is reserved`),rS=k().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`),iS=ds().refine(e=>/^https:\/\/[^/?#@]+(?:[/?#]|$)/iu.test(e),`Plugin documentation links must be credential-free HTTPS URLs`),aS=N({en:k().max(4096),"zh-CN":k().max(4096).optional()}).strict(),oS=N({commands:M(N({terminal:k().max(256),command:k().max(4096)}).strict()).max(8),before:aS.optional(),after:aS.optional(),downloads:M(N({label:k().max(128),url:iS}).strict()).max(8).optional()}).strict(),sS={id:tS,name:k().trim().min(1).max(128),version:k().min(1).max(128),kind:I(`usage`).optional(),iconStyle:N({vector:N({viewBox:k().max(128).regex(/^-?\d+(?:\.\d+)?(?: +-?\d+(?:\.\d+)?){3}$/u),color:k().regex(/^(?:currentColor|#[a-f0-9]{6})$/iu),paths:M(N({d:k().min(1).max(32768).regex(/^[MmLlHhVvCcSsQqTtAaZz\d.,+eE\s-]+$/u),fillRule:F([`evenodd`,`nonzero`]).optional(),fill:k().regex(/^(?:currentColor|#[a-f0-9]{6})$/iu).optional()}).strict()).min(1).max(32)}).strict().optional(),background:k().regex(/^#[a-f0-9]{6}$/iu).optional(),borderRadius:A().min(0).max(50).optional(),paddingRatio:A().min(0).max(.25).optional()}).strict().optional(),installation:oS.optional(),notice:aS.optional(),launchCommand:I(!0).optional(),links:N({website:iS.optional(),documentation:iS.optional(),installation:iS.optional()}).strict().optional()};N({manifestVersion:I(1),...sS,adapterApiVersion:A().int().positive(),entry:rS,icon:rS.optional()}).strict();let cS=k().max(174828).regex(/^data:image\/(?:png|jpeg|webp|svg\+xml);base64,[A-Za-z0-9+/]+={0,2}$/u),lS=N({...sS,icon:cS.optional()}).strict();N({}).strict(),N({plugins:M(lS.extend({id:nS})).max(128)}).strict(),N({version:I(1),enabled:M(tS).max(128)}).strict().refine(e=>new Set(e.enabled).size===e.enabled.length,{message:`Enabled plugin IDs must be unique`,path:[`enabled`]});let uS=eS,dS=F([`sidebar.thread-layout`,`sidebar.thread-badge`,`appearance.theme`]),fS=F([`appearance`,`interface`,`workflow`,`analytics`,`integrations`,`tools`]),pS=k().trim().min(1).max(128);function mS(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 hS=e=>e.split(`/`).every(e=>!/[. ]$/u.test(e)),gS=rS.refine(e=>mS(e)!==void 0&&hS(e),`Images must be relative .png, .jpg, .jpeg, or .webp paths with no segments ending in a dot or space`),_S=k().trim().max(2048).regex(/^https?:\/\/[^/?#\\\s]+/iu,`Expected an HTTP(S) URL`).pipe(ds({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 vS(e){return P({en:e,"zh-CN":e})}let yS=vS(k().trim().min(1)),bS=M(fS).max(fS.options.length).refine(e=>new Set(e).size===e.length,`Duplicate categories`),xS=M(dS).max(dS.options.length).refine(e=>new Set(e).size===e.length,`Duplicate slots`),SS={key:k().regex(/^[A-Za-z_][A-Za-z0-9_]*$/u),label:yS,description:yS.optional()},CS={...SS,step:A().positive().optional(),default:A().optional()},wS=P({value:k(),label:yS}),TS=Hs(`type`,[P({...SS,type:I(`boolean`),default:j().optional()}),P({...SS,type:I(`string`),placeholder:yS.optional(),default:k().optional()}),P({...CS,type:I(`number`),min:A().optional(),max:A().optional()}),P({...CS,type:I(`range`),min:A(),max:A()}),P({...SS,type:I(`select`),options:M(wS).min(1),default:k().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`)}}),ES=N({manifestVersion:ks().positive(),id:uS,name:Bs([pS,vS(pS)]),version:k().min(1).max(128),desktopApi:ks().positive()}).passthrough().extend({manifestVersion:I(1),desktopApi:I(1),description:P({en:k().max(4096),"zh-CN":k().max(4096).optional()}).optional(),author:k().trim().min(1).max(128).optional(),repository:_S.optional(),details:P({en:k().max(16384),"zh-CN":k().max(16384).optional()}).optional(),icon:gS.optional(),screenshots:M(gS).max(4).refine(e=>new Set(e).size===e.length,`Duplicate screenshots`).optional(),desktop:P({script:rS,style:rS.optional()}).optional(),backend:P({script:rS.refine(hS)}).optional(),slots:xS.default(()=>[]),settingsSchema:M(TS).max(32).refine(e=>new Set(e.map(({key:e})=>e)).size===e.length,`Duplicate setting keys`).optional(),categories:bS.optional()}).strict().refine(e=>e.desktop!==void 0||e.backend!==void 0,`Expected at least one desktop or backend entry`),DS=k().regex(/^[a-f0-9]{64}$/u),OS=P({state:F([`running`,`disabled`,`invalid`,`incompatible`,`conflict`,`failed`,`waiting`]),hash:DS.optional(),error:k().optional(),conflictWith:uS.optional()});P({controllerPid:ks().positive(),targetId:k().nullable(),updatedAt:Po(),handledReloadToken:ls().optional(),extensions:Js(k(),OS),surfaces:Js(k(),OS).optional()});let kS=F([`official`,`community`]);function AS(e){return e.origin===`https://api.github.com`&&/^\/repos\/[\w-]+\/[\w.-]+\/zipball(?:\/[^/]+)?\/?$/u.test(e.pathname)}let jS=_S.refine(e=>{let t=new URL(e);return/\.zip$/iu.test(t.pathname)||AS(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`),MS=P({id:uS,version:k().trim().min(1).max(128),name:yS.extend({en:pS,"zh-CN":pS}),description:vS(k().trim().min(1).max(4096)),details:vS(k().trim().min(1).max(16384)).optional(),author:k().trim().min(1).max(128),repository:_S,stars:A().int().min(0).optional(),downloads:A().int().min(0).optional(),categories:bS.optional(),trustTier:kS.default(`community`),icon:_S.optional(),screenshots:M(_S).max(4).optional(),downloadUrl:jS,sha256:DS,slots:xS.optional(),publishedAt:k().optional(),updatedAt:k().optional(),minCodexHostVersion:k().optional()});P({schemaVersion:I(1),generatedAt:k(),extensions:M(MS).refine(e=>new Set(e.map(({id:e})=>e)).size===e.length,`Duplicate extension IDs`)});let NS=k().trim().min(1).max(128),PS=/^(?:con|prn|aux|nul|com[1-9¹²³]|lpt[1-9¹²³]) *(?:\.|$)/iu,FS=uS.refine(e=>!PS.test(e),`Reserved extension ID`),IS=F([`desktop`,`web`]),LS=DS,RS=ls(),zS=rS.refine(e=>!/[\x00-\x1f\x7f<>"|*]/u.test(e)&&e.split(`/`).every(e=>!/[. ]$/u.test(e)&&!PS.test(e)),`Expected a portable relative resource path`).refine(e=>e.split(`/`).length<=32,`Extension resources may be at most 32 segments deep`),BS=ES.shape,VS=(e,t=0)=>P({en:k().trim().min(t).max(e),"zh-CN":k().trim().min(t).max(e)}),HS=e=>zS.refine(t=>t.endsWith(e),`Expected a ${e} file`),US=HS(`.mjs`),WS=HS(`.css`).optional(),GS=e=>e.normalize(`NFC`).toLowerCase(),KS=P({manifestVersion:I(2),id:FS,name:VS(128,1),version:k().trim().min(1).max(128),description:VS(4096),details:VS(16384).optional(),author:BS.author,repository:BS.repository,icon:BS.icon.refine(e=>e===void 0||zS.safeParse(e).success),screenshots:BS.screenshots.refine(e=>e===void 0||e.every(e=>zS.safeParse(e).success)),categories:BS.categories,settingsSchema:BS.settingsSchema,slots:BS.slots.removeDefault().optional(),page:P({apiVersion:I(1),entry:US,style:WS,title:VS(128,1).optional()}).optional(),widget:P({apiVersion:I(1),entry:US,style:WS}).optional(),desktop:P({apiVersion:I(1),script:HS(`.js`),style:WS}).optional(),web:P({apiVersion:I(1),entry:US.optional(),style:WS}).refine(({entry:e,style:t})=>e!==void 0||t!==void 0,`Expected a Web entry or style`).optional(),backend:P({apiVersion:I(1),entry:US}).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||GS(e)!==GS(r.entry)),{path:[`backend`,`entry`],message:`A backend entry cannot also be a frontend entry`});function qS({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 JS=NS,YS=ks().nonnegative(),XS=P({revision:YS,enabled:M(FS).max(64).refine(e=>new Set(e).size===e.length,`Duplicate extension IDs`)}),{downloadUrl:ZS,...QS}=MS.shape,$S=N({...QS,id:FS,format:I(`codexhost`),targets:M(IS).min(1).max(2).refine(e=>new Set(e).size===e.length,`Duplicate targets`),apis:P({page:ks().positive().optional(),widget:ks().positive().optional(),desktop:ks().positive().optional(),web:ks().positive().optional(),backend:ks().positive().optional()}),downloadUrl:ZS.refine(e=>e.startsWith(`https://`),`Expected HTTPS`)}).refine(({targets:e,apis:t})=>{let n=qS({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`);N({schemaVersion:I(2),generatedAt:k().min(1),extensions:M($S).max(1e4).refine(e=>new Set(e.map(({id:e})=>e)).size===e.length,`Duplicate extension IDs`)}).extend({catalogUrl:_S,fetchedAt:Po(),cached:j()});let eC={id:FS},tC={...eC,activationId:RS,digest:LS},nC={...eC,activationId:tC.activationId.optional()},rC=k().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`),iC=k().min(1).max(256).refine(e=>e.split(`/`).every(e=>e&&/^[a-z0-9_.-]+$/iu.test(e)&&e!==`.`&&e!==`..`),`Invalid GitHub ref`);function aC(e){return k().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 oC=P({type:I(`github`),repository:k().max(150).regex(/^[a-z0-9-]+\/[a-z0-9_-][a-z0-9_.-]*$/iu),ref:iC.optional(),tag:iC.optional(),asset:k().max(255).regex(/^[a-z0-9_.-]+\.zip$/iu).optional(),subpath:zS.optional()}).refine(({ref:e,tag:t,asset:n})=>!e||!t&&!n,`Use either a zipball ref or a release tag/asset`),sC=Bs([P({type:I(`catalog`),...eC}),oC,P({type:I(`zip`),base64:aC(67108864).min(4)}),P({type:I(`zip`),localZipPath:rC}),P({type:I(`localDir`),localDir:rC})]),cC=Hs(`type`,[P({type:I(`catalog`),...eC}),oC,P({type:I(`zip`)}),P({type:I(`localDir`)})]),lC=P({...tC,manifest:KS,installedAt:Po(),source:cC.optional()}),uC=e=>k().max(23+4*Math.ceil(e/3)).regex(/^data:image\/(?:png|jpeg|webp);base64,[A-Za-z0-9+/]+={0,2}$/u),dC={desktopConflictWith:FS.optional()},fC=F([`none`,`inactive`,`starting`,`running`,`failed`]),pC=Hs(`state`,[lC.extend({state:I(`valid`),enabled:j(),...dC,iconDataUrl:uC(131072).optional(),screenshotDataUrls:M(uC(524288)).max(4).optional(),backendState:fC.optional(),backendError:k().optional()}),P({state:F([`invalid`,`incompatible`]),id:k().min(1),enabled:j(),error:k()})]);P({revision:YS,configuration:XS,diagnostics:M(k()),extensions:M(pC)}),P({revision:YS,extensions:M(lC.extend({...dC,settingsRevision:YS})).max(64)});let mC={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`},hC=Object.freeze(Object.values(mC));new Set(hC),P({});let gC={expectedRevision:YS};P({...eC,...gC}),lC.extend({replaced:j()}),Hs(`state`,[P({state:I(`saved`),configuration:XS}),P({state:I(`revision-conflict`),revision:YS})]),P({...nC,digest:tC.digest.optional(),path:zS}),P({mimeType:k().min(1),base64:aC(16777216),digest:tC.digest}),P({settingsRevision:YS,values:ux}),mC.list,mC.snapshot,mC.catalog,P({forceRefresh:j().optional()}),mC.install,P({source:sC}),mC.update,P({...eC,expectedDigest:tC.digest,expectedActivationId:tC.activationId.optional(),source:sC.optional()}),mC.enable,mC.disable,mC.uninstall,P({...eC,removeData:j().optional(),expectedDigest:tC.digest.optional()}),P({...eC,removed:j()}),mC.recover,P({expectedRevision:gC.expectedRevision.optional()}),mC.asset,mC.settingsGet,P(nC),mC.settingsSet,P({...nC,expectedSettingsRevision:YS,values:ux}),mC.backendInvoke,P({...nC,method:JS,params:lx.optional()}),P({result:lx}),N({threadId:vx}).strict(),N({confirmed:j()}).strict(),[...hC],N({threadIds:M(k().min(1))}).strict(),N({threadId:k().min(1).max(1024),pinned:j()}).strict(),N({}).strict(),N({parents:Js(k().min(1),k().min(1))}).strict(),N({prompt:k().max(16384).optional()}).strict(),N({projects:M(N({id:k(),name:k(),rootPaths:M(k())})),assignments:Js(k(),k()),projectless:M(k()),pinned:M(k())});let _C=Js(k(),Ps()),vC=N({epoch:k().uuid(),sequence:A().int().nonnegative()});Hs(`type`,[N({type:I(`skills-changed`),cursor:vC,cwd:k().optional()}),N({type:I(`harness-inspection-changed`),cursor:vC,harnessId:k().min(1)}),N({type:I(`display-settings-changed`),cursor:vC}),N({type:I(`preferences-changed`),cursor:vC,revision:A().int().nonnegative()}),N({type:I(`extensions-changed`),cursor:vC,revision:YS}),N({type:I(`hello`),version:I(1),cursor:vC,reset:j()}),N({type:I(`changed`),cursor:vC,threadId:k().min(1),method:k().min(1)})]);let yC=Hs(`type`,[N({type:I(`text`),id:k(),prompt:k(),secret:j().optional(),optional:j().optional()}),N({type:I(`choice`),id:k(),prompt:k(),multiple:j(),allowOther:j(),optional:j().optional(),options:M(N({value:k(),label:k(),description:k().optional()}))})]),bC=Hs(`type`,[N({type:I(`approval`),title:k(),description:k().optional(),subject:Ps().optional(),actions:M(N({id:k(),label:k(),effect:k()}))}),N({type:I(`question`),title:k().optional(),questions:M(yC)})]),xC=N({requestId:Bs([k(),A().int()]),threadId:k(),kind:F([`approval`,`question`]),interaction:bC,request:_C}),SC=N({id:k().min(1),clientUserMessageId:k().min(1),input:M(_C),presentationInput:M(_C).nullable().optional()}).passthrough();N({fields:M(N({path:M(Bs([k(),A().int().nonnegative()])),originalLength:A().int().nonnegative()}))});let CC=N({id:k().min(1),status:k().min(1),codexhostTurnOutcome:N({status:I(`unknown`),reason:k()}).optional(),items:M(N({id:k().min(1),type:k().min(1)}).passthrough()),codexhostFileOperations:M(N({beforeItemId:k().nullable(),item:N({id:k().min(1),type:k().min(1)}).passthrough()})).optional(),error:N({message:k().optional()}).passthrough().nullable().optional(),fingerprint:k().min(1).optional(),unchanged:I(!0).optional()}).passthrough(),wC=N({id:k().min(1).max(512),fingerprint:k().min(1).max(128)});N({threadId:k().min(1),knownTurns:M(wC).max(64).optional(),truncateToolOutput:j().optional()});let TC=N({harnessId:k().min(1),nativeSessionId:k().min(1)});N({cursor:vC,activeTurnId:k().min(1).nullable().optional(),command:N({name:k().min(1),turn:CC,subsequentTurnId:k().min(1).optional()}).optional(),thread:N({id:k().min(1),cwd:k(),modelProvider:k().min(1),createdAt:A(),updatedAt:A(),status:N({type:k()}).passthrough(),name:k().nullable().optional(),preview:k().optional(),codexhostImportSource:TC.optional(),turns:M(CC).length(0)}).passthrough(),turnsPage:N({data:M(CC).max(5),nextCursor:k().nullable()}),configuration:N({native:N({model:k().min(1).max(1024).optional(),reasoningEffort:k().min(1).max(128).optional()}).optional(),effectiveModel:Bx.optional(),effectiveThinkingOptionId:Hx.optional(),effectivePermissionModeId:xx.optional()}),queue:N({items:M(SC),pausedReason:F([`interrupted`,`outcome-unknown`,`failed`]).nullable()}).optional(),interactions:M(xC)}),N({version:I(1),owner:I(`service`).optional(),pid:A().int().positive(),port:A().int().min(1).max(65535),token:k().regex(/^[0-9a-f]{64}$/u),startedAt:A(),epoch:k().uuid()}),N({epoch:k().uuid(),threadId:k().min(1),requestId:Bs([k(),A().int()]),result:_C}),N({includeArchived:j().optional(),officialCursor:N({live:k().nullable(),archived:k().nullable().optional()}).strict().optional()}).strict(),N({threads:M(ux),ownership:M($x),archivedThreadIds:M(vx),officialCursor:N({live:k().nullable(),archived:k().nullable().optional()}).strict().optional()}).strict();let EC=F([`running`,`waiting`,`idle`,`unknown`]),DC=P({harnessId:_x,title:k().optional(),status:EC,archived:j()}),OC=P({revision:ks().nonnegative(),parents:Js(vx,vx),nodes:Js(vx,DC),truncated:j()}).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`),kC=k().min(1).max(128);P({});let AC=P({subscriptionId:kC});P({}),AC.extend({snapshot:OC});let jC=k().regex(/^audio\/[a-z0-9.+-]+(?:\s*;[^\r\n]*)?$/i);N({available:j()}).strict(),N({path:k().min(1),mimeType:jC}).strict();let MC=F([`credentials-unavailable`,`login-expired`,`rate-limited`,`service-rejected`,`host-incompatible`,`network`,`timeout`,`audio-empty`,`audio-too-large`,`audio-format`,`audio-invalid`]);Hs(`ok`,[N({ok:I(!0),text:k()}).strict(),N({ok:I(!1),error:N({code:MC}).strict()}).strict()]),N({threadId:vx.optional(),cwd:k().min(1).optional()}).strict().refine(e=>!(e.threadId&&e.cwd),{message:`Specify threadId or cwd, not both`});let NC=N({name:k().min(1).regex(/^[^\s[\]]+$/u),description:k().optional(),path:k().min(1),scope:F([`project`,`global`]),source:k().min(1)}).strict();N({revision:A().int().nonnegative(),complete:j(),skills:M(NC),warnings:M(k()).optional()}).strict(),N({cwd:k().min(1).optional()}).strict();let PC=/\[\$([^\]\r\n]+)\]\((?:<([^<>\r\n]+)>|([^\s()]+))(?:[ \t]+(?:"[^"\r\n]*"|'[^'\r\n]*'))?\)/gu;function FC(e){return[...e.matchAll(PC)].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 IC=N({kind:F([`public`,`relay`,`tailscale-funnel`,`tailscale-https`,`tailscale`,`lan`,`virtual`]),url:k().min(1)}).strict(),LC=Hs(`status`,[N({status:I(`not-installed`)}),N({status:I(`not-running`)}),N({status:I(`not-logged-in`)}),N({status:I(`https-disabled`)}),N({status:I(`not-serving`),command:k()}),N({status:I(`occupied`),target:k()}),N({status:I(`serving`),url:k(),funnel:j()}),N({status:I(`error`),message:k()})]);N({state:LC,error:k().optional()}).strict();let RC=Hs(`status`,[N({status:I(`on`)}),N({status:I(`off`)}),N({status:I(`invalid`),reason:k()})]),zC=N({lan:j(),autostart:RC}).strict(),BC=N({expiresAt:k().optional(),issuing:j(),failure:N({detail:k().optional(),retryAt:k(),paused:j()}).optional()}),VC=Hs(`status`,[N({status:I(`off`),reason:F([`invite`,`name-taken`,`banned`]).optional()}),N({status:I(`connecting`),reason:F([`full`,`unreachable`]).optional()}),N({status:I(`connected`),url:k(),certificate:BC}),N({status:I(`missing-certificate`),url:k(),certificate:BC}),N({status:I(`stopped`),reason:F([`replaced`,`rejected`,`unsupported-version`])})]);k().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()),k().regex(/^(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)?$/);let HC=F([`official`,`self-hosted`]);N({secret:k().min(1),lastUsedAt:A().nullable(),networkUrls:M(IC),directCandidates:M(IC).optional(),tailscale:LC,background:zC.optional(),relay:N({state:VC,enabled:j(),kind:HC,officialHost:k(),customHost:k().optional(),officialHostname:k().optional(),customHostname:k().optional(),quotaUntil:k().optional()}).strict().optional()}).strict();let UC=P({threadId:k().min(1).max(1024),view:F([`result`,`messages`]),from:A().int().min(1).max(2**53-1).optional(),to:A().int().min(1).max(2**53-1).optional()}),WC=N({id:k().min(1).max(256),harnessId:k().min(1),label:k().min(1).max(512),provider:F([`openai-codex`,`xai`])}).strict(),GC=k().regex(/^[a-z][a-z0-9-]{0,47}$/),KC=N({name:GC,source:WC,importedAt:k()}).strict(),qC=Hs(`action`,[N({action:I(`list`)}).strict(),N({action:I(`import`),sourceId:k().min(1).max(256),name:GC,confirmed:I(!0)}).strict(),N({action:I(`reimport`),sourceId:k().min(1).max(256),name:GC,confirmed:I(!0)}).strict(),N({action:I(`remove`),name:GC,confirmed:I(!0)}).strict()]),JC=N({provider:k().min(1).max(128),type:F([`oauth`,`api_key`,`unknown`]),label:k().min(1).max(512).optional(),vendor:F([`openai-codex`,`xai`]).optional()}).strict();N({sources:M(WC),targets:M(N({harnessId:k(),providers:M(F([`openai-codex`,`xai`])),imports:M(KC),others:M(JC).default([])}).strict())}).strict(),N({targetHarnessId:k().min(1).max(128).optional(),request:qC}).strict(),N({events:j()});let YC=M(P({agent:k().min(1).max(128),section:F([`main`,`more`,`auto`])})).max(256).refine(e=>new Set(e.map(e=>e.agent)).size===e.length,`Duplicate Harness IDs`);P({entries:YC.nullable()}),P({}),P({entries:YC,initializeOnly:j().optional()});let XC=P({enabled:j(),timeoutMinutes:A().int().min(5).max(1440)});Object.freeze({enabled:!1,timeoutMinutes:10});let ZC=k().regex(/^external$/u),QC=_x.transform(e=>String(e)),$C=P({model:Bx.optional(),thinkingOptionId:Hx.optional(),permissionModeId:xx.optional()}).refine(e=>!!(e.model||e.thinkingOptionId||e.permissionModeId),`A default configuration must contain a preference`),ew=P({lastHarness:_x.optional(),byHarness:Js(QC,$C)}),tw=P({model:Bx.optional(),thinkingOptionId:Hx.optional()}).refine(e=>!!(e.model||e.thinkingOptionId),`A delegation default must contain a Model or Thinking option`),nw=P({byHarness:Js(QC,tw)}),rw=k().min(1).max(1024),iw=P({idleRelease:XC.optional(),favorites:Js(QC,M(rw).max(2048)).default({}),newThread:ew.optional(),delegation:nw.optional()});P({scope:ZC,revision:A().int().nonnegative(),values:iw}),P({scope:ZC.default(`external`)});let aw=Hs(`kind`,[P({kind:I(`idleRelease`),value:XC}),P({kind:I(`favorite`),harnessId:_x,modelId:rw,enabled:j()}),P({kind:I(`favorites`),harnessId:_x,modelIds:M(rw).max(2048)}),P({kind:I(`newThread`),lastHarness:_x.optional(),harnessId:_x.optional(),configuration:$C.optional()}),P({kind:I(`delegation`),harnessId:_x,configuration:tw.nullable()})]);P({scope:ZC.default(`external`),operations:M(aw).min(1).max(256),initializeOnly:j().optional(),expectedRevision:A().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`})}),P({version:I(1),revision:A().int().nonnegative(),scopes:Js(ZC,iw)});let ow=A().finite().nonnegative(),sw=P({input:ow,output:ow,cacheRead:ow.optional(),cacheWrite:ow.optional(),cacheWrite1h:ow.optional()}),cw=k().max(512).refine(e=>e.trim()===e&&e.length>0,`Model ID is required`);P({path:k(),entries:M(P({key:k(),price:sw})),error:k().nullable()}),P({}),P({key:cw,price:sw.nullable(),previousKey:cw.optional()}),P({model:cw});let lw=P({official:j().optional(),canonicalModelId:k().min(1).optional(),provider:k().min(1).max(512),model:k().min(1).max(512),price:sw});P({price:sw.nullable(),suggestions:M(lw).max(6).optional()});let uw=[`today`,`7d`,`30d`,`90d`,`all`],dw=A().int().min(0).max(2**53-1),fw=k().regex(/^\d{4}-\d{2}-\d{2}$/u),pw=k().min(1).max(128),mw=k().min(1).max(512),hw=k().min(1).max(4096);P({range:F(uw),timeZone:k().min(1).max(128).refine(e=>{try{return new Intl.DateTimeFormat(`en`,{timeZone:e}),!0}catch{return!1}},`Unsupported usage statistics timezone`).optional(),harness:pw.optional(),model:mw.nullable().optional(),project:hw.nullable().optional(),date:fw.optional()});let gw=P({requests:dw,inputTokens:dw,cachedInputTokens:dw,cacheWriteInputTokens:dw,cacheKnownInputTokens:dw,cacheHitCachedInputTokens:dw,cacheHitInputTokens:dw,outputTokens:dw,reasoningOutputTokens:dw,costUsd:A().finite().min(0),unpricedRequests:dw,unmeteredRequests:dw}),_w=gw.shape,vw=P({harness:pw,sessionId:k().min(1).max(512),project:hw.nullable(),title:k().min(1).max(200).optional(),models:M(mw).max(16),firstAtMs:dw,lastAtMs:dw,..._w});P({range:F(uw),from:fw.nullable(),to:fw,filters:P({harness:pw.nullable(),model:mw.nullable(),unknownModel:j(),project:hw.nullable(),unknownProject:j(),date:fw.nullable()}),reading:P({complete:j(),sources:dw,read:dw}),failures:M(P({harness:pw,message:k().max(2048)})).max(256),options:P({harnesses:M(pw).max(256),models:M(mw.nullable()).max(4096),projects:M(hw.nullable()).max(4096)}),modelLabels:M(P({harness:pw,model:mw,label:mw})).max(4096).optional(),credits:M(P({harness:pw,model:mw.nullable(),credits:A().finite().min(0),reportedRequests:dw,requests:dw})).max(4096).optional(),totals:gw,daily:M(P({date:fw,harness:pw,..._w})).max(2e5),hourly:M(P({weekday:A().int().min(0).max(6),hour:A().int().min(0).max(23),..._w})).max(168),byHarness:M(P({harness:pw,..._w})).max(256),byModel:M(P({model:mw.nullable(),..._w,harnessPricedRequests:dw})).max(4096),byProject:M(P({project:hw.nullable(),..._w})).max(4096),sessions:M(vw).max(100),recentSessions:M(vw).max(100).optional()}),N({threadId:vx}),N({discarded:j()});let yw=Hs(`type`,[N({id:k().min(1),type:I(`choice`),prompt:k(),options:M(N({value:k().min(1),label:k(),description:k().optional()})).min(1),multiple:j(),allowOther:j(),optional:j()}),N({id:k().min(1),type:I(`text`),prompt:k(),multiline:j(),secret:I(!1),optional:j(),placeholder:k().optional(),prefill:k().optional()})]),bw=N({interactionId:k().min(1),turnId:k().min(1),title:k().optional(),questions:M(yw).min(1)}).refine(({questions:e})=>e.some(e=>e.type===`choice`&&e.multiple),{message:`Shared cards require at least one multi-select question`});P({threadId:k().min(1)}),N({questions:M(bw)}),P({threadId:k().min(1),turnId:k().min(1),interactionId:k().min(1),answers:Js(k(),M(k())),cancelled:j().default(!1)}),N({accepted:I(!0)});let xw=N({path:k(),oldText:k().nullable(),newText:k()});N({sessionId:k().min(1),turn:A().int().nonnegative(),path:k().min(1).optional()}),N({diffs:M(xw)}),P({}),P({}),N({reference:N({sessionId:k().min(1),epoch:k().min(1),turn:A().int().nonnegative(),seq:A().int().nonnegative(),callId:k().min(1),part:A().int().nonnegative(),version:k().min(1)}),length:A().int().nonnegative(),bytes:A().int().nonnegative()}),P({title:k().trim().min(1).max(200),type:F([`info`,`warning`,`danger`]),body:k().trim().min(1).max(16384)}),P({}),P({url:k().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 Sw=F([`idle`,`running`,`busy`,`closing`,`failed`,`blocked`]),Cw=F([`none`,`disabled`,`timeout`,`operation`,`background`,`identity`,`persistence`,`closeFailed`]);P({threadId:k(),title:k(),harnessId:k(),state:Sw,reason:Cw,inactiveMs:A().nonnegative()}),P({threadId:vx,turnId:yx});let ww=N({email:k().trim().min(1).max(320).optional(),label:k().trim().min(1).max(256).optional(),plan:k().trim().min(1).max(128).optional(),credits:Fx.optional(),balance:Ix.optional()}).strict();function Tw(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 Ew=Tw(ww),Dw={harnessId:_x,harnessName:k().trim().min(1).max(128)},Ow=N(Dw).strict();N({}).strict(),N({sources:M(Ow).max(128)}).strict(),N({harnessId:_x,refresh:j().optional()}).strict(),N({...Dw,account:Ew.nullable(),accounts:M(Ew).max(8).optional()}).strict(),N({refresh:j().optional()}).strict(),N({accounts:M(Tw(ww.extend(Dw))).max(128)}).strict(),N({harnessId:nS,model:Bx.optional(),thinkingOptionId:Hx.optional(),permissionModeId:xx.optional(),prewarm:I(!0).optional()}).strict();let kw=k().trim().min(1).max(4096).refine(e=>!/[\u0000\r\n]/u.test(e),`Invalid entrypoint path`);N({harnessId:nS}).strict().extend({path:kw.nullable()}),N({path:kw.nullable(),restartRequired:j()}).strict(),N({harnessId:_x,action:F([`check`,`update`,`install`])}).strict();let Aw=N({currentVersion:k().min(1).max(128),latestVersion:k().min(1).max(128),updateAvailable:j(),canUpdate:j(),versionKind:F([`cli`,`application`]).optional(),manualUpdateUrl:ds().max(2048).refine(e=>/^https:\/\/[^/?#@]+(?:[/?#]|$)/iu.test(e),`Manual updates require a credential-free HTTPS URL`).optional(),message:k().max(2048).optional(),messageCode:k().min(1).max(128).optional(),notice:hx.optional(),latestVersionKind:F([`unknown`,`tracking-branch`]).optional()}).strict();N({taskId:k().uuid()}).strict(),Hs(`status`,[N({taskId:k().uuid(),status:I(`running`)}).strict(),N({taskId:k().uuid(),status:I(`succeeded`),result:Aw}).strict(),N({taskId:k().uuid(),status:I(`failed`),error:N({code:A().int(),message:k().min(1).max(2048)}).strict()}).strict()]);let jw=k().min(1).max(256).regex(/^[A-Za-z0-9._~-]+$/u),Mw=k().trim().min(1),Nw=F([`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`]),Pw=N({accountId:jw,label:Mw.max(256),email:k().email().max(320).optional(),planType:Nw.optional()}).strict(),Fw=F([`ready`,`unavailable`]);N({version:I(2),currentAccountId:jw.nullable(),phase:Fw,revision:A().int().nonnegative(),instanceId:Mw.max(1024).optional(),accounts:M(Pw).max(1)}).strict(),N({accountId:jw,refresh:j().optional()}).strict(),N({accountId:jw,usage:kx.nullable(),accountCredits:Fx.optional(),freshness:F([`live`,`cached`]),observedAt:k().datetime().nullable()}).strict();let Iw=1e3,Lw=k().refine(e=>e.trim().length>0,`Value must not be empty or whitespace`).refine(e=>!e.includes(`\0`),`Value must not contain NUL`),Rw=Lw.max(1024),zw=N({nativeSessionId:Rw,title:Lw.max(4096).nullable(),updatedAt:A().int().nonnegative().max(864e13),cwd:Lw.max(16384),running:j().nullable()}).strict();N({}).strict(),N({harnesses:M(N({harnessId:nS,name:Lw.max(128)}).strict()).max(128)}).strict(),N({harnessId:nS,query:k().trim().max(4096).refine(e=>!e.includes(`\0`)).optional(),offset:A().int().nonnegative().safe().optional(),limit:A().int().min(1).max(Iw).optional()}).strict(),N({candidates:M(zw).max(Iw),total:A().int().nonnegative().safe()}).strict(),N({harnessId:nS,nativeSessionId:Rw}).strict(),N({threadId:Lw.max(1024).pipe(vx)}).strict();let Bw=k().refine(e=>e.trim().length>0,`Value must not be empty or whitespace`).refine(e=>!e.includes(`\0`),`Value must not contain NUL`),Vw=Rw,Hw=zw;N({}).strict(),N({candidates:M(Hw).max(1e3)}).strict(),N({nativeSessionId:Vw}).strict(),N({threadId:Bw.max(1024).pipe(vx)}).strict(),N({threadId:vx,lastTurnId:yx}).strict(),N({threadId:vx}).strict();let Uw=k().trim().min(1).max(128).regex(/^[A-Za-z0-9._:-]+$/u).brand();N({commands:M(N({id:Uw,invocation:k().min(1).max(128),label:k().trim().min(1).max(128),description:k().trim().min(1).max(512).optional(),localizations:mx.optional(),argumentMode:F([`none`,`text`]),kind:F([`command`,`skill`]).optional()}).strict()),warnings:M(k().min(1)).optional(),source:F([`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)}),N({harnessId:_x,cwd:k().min(1).optional()}).strict(),N({threadId:vx}).strict(),N({threadId:vx,commandId:Uw,turnId:yx.optional(),arguments:ux.optional()}).strict(),N({accepted:I(!0),turnId:yx.optional()}).strict();let Ww=I(`2.0`).optional(),Gw=Is().optional(),Kw=k().min(1),qw=Bs([k(),A().int()]),Jw=N({code:A().int(),message:k(),data:lx.optional()}).catchall(lx).superRefine(ix([`data`]));Bs([N({jsonrpc:Ww,id:qw,method:Kw,params:lx.optional(),result:Gw,error:Gw}).catchall(lx).superRefine(ix([`jsonrpc`,`params`,`result`,`error`])),N({jsonrpc:Ww,id:Gw,method:Kw,params:lx.optional(),result:Gw,error:Gw}).catchall(lx).superRefine(ix([`jsonrpc`,`id`,`params`,`result`,`error`])),N({jsonrpc:Ww,id:qw,method:Gw,params:Gw,result:lx,error:Gw}).catchall(lx).superRefine(ix([`jsonrpc`,`method`,`params`,`error`])),N({jsonrpc:Ww,id:qw,method:Gw,params:Gw,result:Gw,error:Jw}).catchall(lx).superRefine(ix([`jsonrpc`,`method`,`params`,`result`]))]);let Yw=k().refine(e=>e.trim().length>0,{message:`Native identifier must not be empty or whitespace`});P({harnessId:_x,nativeSessionId:Yw,locator:lx.optional(),formatVersion:I(1)}).superRefine(ix([`locator`])),P({harnessId:_x,nativeSessionId:Yw,nativeTurnKey:Yw,formatVersion:I(1)}),P({harnessId:_x,nativeSessionId:Yw,checkpointId:Yw,locator:lx.optional(),formatVersion:I(1)}).superRefine(ix([`locator`]));let Xw=k().regex(/^\d+\.\d+\.\d+(?:-[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?(?:\+[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/u),Zw=F([`npm`,`windows-installer`,`macos-dmg`]),Qw=P({version:Xw,installation:Zw,phase:F([`prepared`,`downloading`,`waiting-for-exit`,`installing`,`restarting`,`succeeded`,`failed`]),updatedAt:A().int().nonnegative(),downloadedBytes:A().int().nonnegative().optional(),totalBytes:A().int().positive().optional(),error:k().min(1).max(500).nullable(),serviceStopOutput:k().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`})});P({});let $w=k().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`);P({currentVersion:Xw,installation:Zw.nullable(),latestVersion:Xw.nullable(),updateAvailable:j(),installationAvailable:j(),releaseNotes:k().min(1).max(2e4).nullable(),releaseNotesUrl:$w.nullable(),status:Qw.nullable(),error:k().min(1).max(500).nullable()}),P({status:Qw}),P({status:Qw.nullable()}),RegExp(String.raw`^- \[([^\]\n]+)\]\(thread://([^\s()<>"?#/]+)\): `+`(${[`completed`,`failed`,`interrupted`,`needsInput`,`timedOut`,`unreadable`,`notFound`].join(`|`)})(?:\. (.+))?$`,`u`);function eT(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 tT(e,t){let n=eT(e);return n===``?t:`${n}\n## My request:\n${t}\n`}let nT=F([`idle`,`installing`,`restarting`,`succeeded`,`failed`]);N({runningVersion:k().nullable(),installedVersion:k().nullable(),restartRequired:j(),remote:j(),updateSupported:j(),update:N({phase:nT,targetVersion:k().nullable(),error:k().nullable()})});let rT=N({version:k().regex(/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/u)}).strict();N({hostname:k().min(1).max(1024).refine(e=>!e.startsWith(`-`)&&!/\s/u.test(e)),port:A().int().min(1).max(65535).nullable(),identity:k().max(4096).nullable(),action:F([`inspect`,`install`,`update`,`repair`,`uninstall`]),uninstallPackage:j().optional(),version:k().regex(/^\d+\.\d+\.\d+$/u).nullable()}).strict(),N({state:F([`installed`,`not-installed`])}).strict();let iT=k().min(1).max(1024),aT={hostId:iT.regex(/^remote-(?:ssh(?:-|:)|control:)/u)},oT={...aT,threadId:iT},sT=Hs(`kind`,[P({kind:I(`hosts`)}),P({kind:I(`status`),...oT}),P({kind:I(`list`),...aT,cursor:k().nullable(),archived:j()}),P({kind:I(`read`),...oT,page:P({cursor:k().min(1).max(8192).nullable(),epoch:iT.optional(),sortDirection:F([`asc`,`desc`]).optional(),limit:A().int().min(1).max(20).optional()}).refine(e=>e.cursor===null||e.epoch!==void 0,{message:`A history continuation requires its connection epoch`}).optional()}),P({kind:I(`usage`),...oT,epoch:iT}),P({kind:I(`configure`),...oT,epoch:iT,modelId:iT.optional(),serviceTier:zx.optional(),thinkingOptionId:iT.optional(),permissionModeId:iT.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`}),P({kind:I(`prompt`),...oT,epoch:iT,text:k().min(1).max(8e3),requestId:iT.optional()}),P({kind:I(`interrupt`),...oT,epoch:iT,turnId:iT}),P({kind:I(`rename`),...oT,epoch:iT,name:k().min(1).max(512)}),P({kind:I(`archive`),...oT,epoch:iT,archived:j()}),P({kind:I(`respond`),...oT,epoch:iT,requestId:Bs([iT,A().int()]),result:Js(k(),Ps())})]),cT=k().min(1).max(1024),lT=N({hostId:cT,displayName:k().min(1).max(1024),source:F([`codex-managed`,`discovered`]),sshAlias:k().max(1024).nullable(),sshHost:k().min(1).max(1024),sshPort:A().int().min(1).max(65535).nullable(),identity:k().max(4096).nullable(),autoConnect:j(),connectionAnalyticsId:k().max(1024).optional()}),uT=P({displayName:k().min(1).max(1024),hostname:k().min(1).max(1024),sshPort:A().int().min(1).max(65535).nullable(),identity:k().max(4096).nullable()});Hs(`action`,[P({action:I(`session`),operation:sT}),P({action:I(`list`)}),P({action:I(`catalog`)}),P({action:I(`read-thread`),hostId:cT.refine(e=>e!==`local`),input:UC}),P({action:I(`save`),draft:uT,previous:lT.nullable()}),P({action:I(`remove`),previous:lT}),P({action:I(`connect`),hostId:cT,enabled:j()}),P({action:I(`state`),hostId:cT}),P({action:I(`runtime`),hostId:cT}),P({action:I(`update`),hostId:cT.refine(e=>e!==`local`),version:rT.shape.version})]),Bs([P({result:lx}),P({error:P({code:A().int(),message:k()})})]),P({prompt:k().trim().min(1).max(2e3),cwd:k().max(4096).nullable()}),k().trim().min(1).max(60).nullable();let dT=k().max(214).regex(/^(?:@[a-z0-9][a-z0-9._-]*\/)?[a-z0-9][a-z0-9._-]*$/u),fT=Bs([k(),N({en:k()}).catchall(k())]),pT=N({title:fT.optional(),description:fT.optional(),icon:k().max(349592).regex(/^data:image\/(?:svg\+xml|png|jpeg|webp);base64,[A-Za-z0-9+/]*={0,2}$/u).optional(),error:k().optional()});N({extensions:M(N({id:dT,name:k().min(1).max(214),version:k().min(1).max(128),format:I(`dsh`),supportedTargets:Ks([I(`web`)]),enabledTargets:M(I(`web`)).max(1),source:k().min(1).max(4096),projectUrl:k().max(4096).url({protocol:/^https?$/u}).optional(),installedAt:k(),meta:pT.optional(),loadError:k().optional()})),loadedIds:M(dT),safeMode:j(),storeError:k().optional()});let mT=k().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}/`);N({spec:k().trim().min(1).max(4096),registry:mT.optional()}).strict(),N({id:dT,enabled:j()}).strict(),N({id:dT}).strict(),I(1);function hT(e){return e.registerNodeTransform(Rf,e=>{let t=FC(e.getTextContent())[0];t&&e.splitText(t.start,t.end)[t.start===0?0:1]?.replace(new Hb({source:`codexhost-skill`,ref:t.text,label:t.name,appearance:`skill`,clipboardText:t.text}))})}let gT=`color: var(--dsw-alias-state-business-primary)`;function _T(){let e=Dh().getFirstChild();if(!G(e))return null;let t=e.getFirstChild();return V(t)?t:null}function vT(e,t){return e.registerNodeTransform(Rf,e=>{let n=_T();if(n===null||e.getKey()!==n.getKey()){e.getStyle()===gT&&e.setStyle(``);return}let r=e.getTextContent(),i=t(),a=r===i?.trimEnd()?r:i;if(a===null||!r.startsWith(a))e.getStyle()===gT&&e.setStyle(``);else if(r.length>a.length){let[t,n]=e.splitText(a.length);t!==void 0&&t.getStyle()!==gT&&t.setStyle(gT),n?.setStyle(``)}else e.getStyle()!==gT&&e.setStyle(gT)})}function yT(e){e.update(()=>{_T()?.markDirty()})}function bT(){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(Wb(e))o(`chip`,e,``,e.getTextContent());else if(V(e)){let t=e.getTextContent();o(`text`,e,t,t)}else Fm(e)?o(`linebreak`,e,`
|
|
156
156
|
`,`
|
|
157
157
|
`):G(e)&&
|
|
158
158
|
/* v8 ignore next 4 -- plain-text composition nests no block elements today; the walk stays total for imported states. */
|
|
159
|
-
s(e);r.set(e.getKey(),{start:t,end:i.length})},c=
|
|
159
|
+
s(e);r.set(e.getKey(),{start:t,end:i.length})},c=Dh(),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+=`
|
|
160
160
|
`,a+=`
|
|
161
|
-
`),G(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
|
|
161
|
+
`),G(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 xT(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 ST(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 CT(e){let t=bT(),n=[];for(let r of t.segments){if(r.kind!==`chip`||!Wb(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=U(),i=null;if(H(r)){let e=ST(t,r.anchor),n=ST(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 wT(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`}}
|
|
162
162
|
/* v8 ignore next -- non-gap segments always carry their node. */
|
|
163
|
-
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=
|
|
163
|
+
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=Dh().getChildren(),r=n[n.length-1];return r===void 0?{key:Dh().getKey(),offset:0,type:`element`}:{key:r.getKey(),offset:e.children.get(r.getKey())?.length??0,type:`element`}}function TT(e,t){if(t.start<0||t.start>t.end||t.end>e.detectLength)return null;let n=wT(e,t.start),r=wT(e,t.end);
|
|
164
164
|
/* v8 ignore next -- bounds were checked above; resolvePoint only fails out of bounds. */
|
|
165
|
-
if(n===null||r===null)return null;let i=
|
|
166
|
-
`)
|
|
167
|
-
`);for(let e=0;e<t.length;e+=1){let i=t[e];i!==``&&r.append(Wf(i)),e<t.length-1&&(r=Rm(),n.append(r))}},a=0;for(let n of t)i(e.slice(a,n.offset)),r.append(new zb({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:xf})}clearHistory(){this.editor.dispatchCommand(Md,void 0)}};function cw(e){switch(e){case`plain`:return`plain`;case`claimed`:return`claimed`;default:return`frozen`}}function lw(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 uw=[],dw=/* @__PURE__ */ new Map;var fw=class{deps;state;notices=(0,f.createSnapshotStore)(null);get editor(){return this.draftEditor.editor}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.editor.update(()=>{wh().selectEnd()},{discrete:!0}),this.focus()),n},removeResponseAnnotation:e=>{this.removeResponseAnnotation(e)},submit:()=>{this.submit(`queue`)}};primaryAction;core=new Nv;draftEditor;get projection(){return this.draftEditor.projection}rev=0;unregister;noticeSeq=0;lastPublishedDraft;draftSnapshotCache;attachmentIds=[];responseAnnotations=[];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 sw({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(){lw(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:cw(this.core.state.phase)},this.rev)}setDraft(e){let t=Sc(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=wc(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.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}}],this.publish(),t}removeResponseAnnotation(e){if(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.forgetFailedAnnotation(e),this.publish(),!0)}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()??dw,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(){this.editor.getRootElement()?.focus({preventScroll:!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.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=[];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(NC(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+=`
|
|
165
|
+
if(n===null||r===null)return null;let i=Dp();return i.anchor.set(n.key,n.offset,n.type),i.focus.set(r.key,r.offset,r.type),Oh(i),i}function ET(e,t){let n=TT(bT(),e);if(n===null)return!1;if(t===``)n.isCollapsed()||n.removeText();else{let e=t.replace(/\r\n?/gu,`
|
|
166
|
+
`);e.includes(`
|
|
167
|
+
`)?n.insertRawText(e):n.insertText(e)}return!0}function DT(e,t){let n=TT(bT(),e);return n!==null&&(n.insertNodes([...t]),!0)}let OT=/[\uE100-\uE11D\uFFFC]/gu;var kT=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=qm({namespace:`dsh-composer`,nodes:[Hb,ex],onError:e=>{throw e}})}register(){let e=()=>{let e=this.editor.getRootElement();return e!==null&&!e.contains(e.ownerDocument.activeElement)&&Qh(`skip-dom-selection`),!1},t=Mv(Cb(this.editor),this.editor.registerCommand(kd,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(Dd,e=>{if(!this.editor.isEditable()||!e.dataTransfer||e.dataTransfer.types.includes(`Files`))return!1;let t=Pb(e.dataTransfer.getData(kb));return t!==void 0&&(e.preventDefault(),e.stopPropagation(),e.dataTransfer.dropEffect=`copy`,this.insertFileReferences([Nb(t)]))},4),this.editor.registerCommand(zd,()=>(this.editor.update(e,{discrete:!0}),!1),4),this.editor.registerCommand(Zu,e,4),this.editor.registerNodeTransform(wm,e),rx(this.editor,(e,t)=>this.deps.openReference(e,t)),Db(this.editor,Ob(),1e3),this.editor.registerUpdateListener(()=>{this.deps.onUpdate()}),hT(this.editor),vT(this.editor,()=>this.deps.activeClaimToken()),tx(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&&Qh(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(()=>{nx(this.editor)}),nx(this.editor))}refreshProjection(){let e=this.projected;return this.projected=this.editor.getEditorState().read(()=>CT(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(OT,``);(t!==this.projection.clipboardText||this.projection.occurrences.length!==0)&&this.editor.update(()=>{let e=Dh();e.clear();for(let n of t.split(`
|
|
168
|
+
`)){let t=Vm();n!==``&&t.append(qf(n)),e.append(t)}e.selectEnd()},{discrete:!0,tag:wf})}paste(e){let t=e.replace(OT,``).replace(/\r\n?/gu,`
|
|
169
|
+
`);t!==``&&this.applyEdit(()=>{let e=U();if(H(e)){e.insertRawText(t);return}let n=Dh();n.getChildrenSize()===0&&n.append(Vm()),n.selectEnd().insertRawText(t)},Tf)}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=ET(e,t)}),n}insertAsyncText(e,t){let n=!1,r=t.replace(OT,``);return this.applyEdit(()=>{n=ET(e,r)},Tf),n}insertReference(e,t,n){let r=!1;return this.applyEdit(()=>{r=DT(e,n===` `?[Ub(t)]:[Ub(t),qf(` `)])}),r}insertFileReferences(e,t){if(e.length===0)return!0;let n=!1;return this.applyEdit(()=>{let r=CT(e=>this.occurrenceIdOf(e)),i=t?.end??r.selection?.end??r.detectText.length,a=r.detectText.slice(0,i),o=e.flatMap(e=>[Ub(e),qf(` `)]);a!==``&&!/\s$/u.test(a)&&o.unshift(qf(` `)),n=DT({start:i,end:i},o)},Tf),n}refreshClaimDecoration(){yT(this.editor)}clearCommittedDraft(e){this.editor.update(()=>{let t=bT(),n=e(t.clipboardText);if(n!==null){ET({start:0,end:xT(t,n)},``);return}let r=Dh();r.clear(),r.selectEnd()},{discrete:!0,tag:wf})}restoreDraft(e,t){this.editor.update(()=>{let n=Dh();n.clear();let r=Vm();n.append(r);let i=e=>{let t=e.replace(OT,``).split(`
|
|
170
|
+
`);for(let e=0;e<t.length;e+=1){let i=t[e];i!==``&&r.append(qf(i)),e<t.length-1&&(r=Vm(),n.append(r))}},a=0;for(let n of t)i(e.slice(a,n.offset)),r.append(new Hb({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:wf})}clearHistory(){this.editor.dispatchCommand(Fd,void 0)}};function AT(e){switch(e){case`plain`:return`plain`;case`claimed`:return`claimed`;default:return`frozen`}}function jT(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 MT=[],NT=/* @__PURE__ */ new Map;var PT=class{deps;state;notices=(0,f.createSnapshotStore)(null);get editor(){return this.draftEditor.editor}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},removeResponseAnnotation:e=>{this.removeResponseAnnotation(e)},submit:()=>{this.submit(`queue`)}};primaryAction;core=new Iv;draftEditor;get projection(){return this.draftEditor.projection}rev=0;unregister;noticeSeq=0;lastPublishedDraft;draftSnapshotCache;attachmentIds=[];responseAnnotations=[];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 kT({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(){jT(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:AT(this.core.state.phase)},this.rev)}setDraft(e){let t=Tc(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=Dc(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.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}removeResponseAnnotation(e){if(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.forgetFailedAnnotation(e),this.publish(),!0)}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()??NT,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(()=>{Dh().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.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=[];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(tT(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+=`
|
|
168
171
|
|
|
169
|
-
`),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,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`]??uw}}publish(){let e=this.compose();this.state.set(e);let t=this.draftSnapshot;t!==this.lastPublishedDraft&&(this.lastPublishedDraft=t,this.persistDraft?.(t))}};function pw(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 mw=class{rootCtx;t;shells=/* @__PURE__ */ new WeakMap;constructor(e,t){this.rootCtx=e,this.t=t}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)}shellFor(e){let t=this.shells.get(e);if(t!==void 0)return t;let{session:n,ctx:r}=e,i=new fw({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=>{pw(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(Oc(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 hw=`busyEnter`,gw=[`queue`,`steer`],_w=`queue`,vw={[hw]:w.union([...gw]).default(_w)};w.object(vw);function yw(e,t,n,r){return!t||!r?`queue`:n===`enter`?e:e===`queue`?`steer`:`queue`}var bw=class{busyEnter=(0,f.createSnapshotStore)(_w);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(hw,e))}adopt(e){let t=e.getSnapshot().value;t!==void 0&&this.busyEnter.getSnapshot()!==t.busyEnter&&this.busyEnter.set(t.busyEnter)}};let xw=`@deepseek-ai/dsh-client-ui-conversation/QueueDock.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(xw)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-conversation`,e.dataset.pluginCss=xw,e.textContent=`._45elva_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}._45elva_pendingAttachment{flex-direction:column;gap:2px;display:inline-flex}._45elva_panel{isolation:isolate;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}._45elva_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}._45elva_panel:after{border:.5px solid var(--dsw-alias-border-l1);border-radius:inherit;content:"";pointer-events:none;border-bottom:none;position:absolute;inset:0}._45elva_paused{color:var(--dsw-alias-label-tertiary);font:var(--dsw-font-xs-13);padding:6px 12px 2px}._45elva_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}._45elva_header:focus-visible{outline:var(--dsw-focus-ring-width) solid var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary));outline-offset:-2px}._45elva_header:disabled{cursor:default}._45elva_lead{color:var(--dsw-alias-label-tertiary);flex:none;place-items:center;display:grid}._45elva_count{min-width:0;font-family:Inter, var(--dsw-font-family);flex:auto;font-size:13px;font-weight:500;line-height:24px}._45elva_chevron{width:14px;height:14px;color:var(--dsw-alias-label-tertiary);flex:none;place-items:center;display:grid}._45elva_list{max-height:180px;margin:0;padding:0;list-style:none;overflow-y:auto}._45elva_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}._45elva_row+._45elva_row{box-shadow:inset 0 1px 0 var(--dsw-alias-border-l1)}._45elva_attachments{flex:none;gap:4px;min-width:0;max-width:55%;display:flex;overflow:hidden}._45elva_pendingRow ._45elva_attachments{flex-shrink:1}._45elva_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}._45elva_fileIcon{flex:none;width:16px;height:16px;display:inline-flex}._45elva_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}._45elva_fileSize{color:var(--dsw-alias-label-tertiary);white-space:nowrap;flex:none;font-size:10px}._45elva_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}._45elva_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}._45elva_actions{flex:none;align-items:center;gap:10px;display:flex}._45elva_status{color:var(--dsw-alias-label-tertiary);font:var(--dsw-font-xs-13);white-space:nowrap;flex:none}._45elva_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}._45elva_action:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-hover)}._45elva_action:focus-visible{outline:var(--dsw-focus-ring-width) solid var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary));outline-offset:-2px}._45elva_action:disabled{cursor:default;opacity:.45}`,document.head.appendChild(e)}var Q={action:`_45elva_action`,actions:`_45elva_actions`,attachments:`_45elva_attachments`,chevron:`_45elva_chevron`,count:`_45elva_count`,dock:`_45elva_dock`,file:`_45elva_file`,fileIcon:`_45elva_fileIcon`,fileName:`_45elva_fileName`,fileSize:`_45elva_fileSize`,header:`_45elva_header`,lead:`_45elva_lead`,list:`_45elva_list`,panel:`_45elva_panel`,paused:`_45elva_paused`,pendingAttachment:`_45elva_pendingAttachment`,pendingRow:`_45elva_pendingRow`,preview:`_45elva_preview`,row:`_45elva_row`,status:`_45elva_status`,thumb:`_45elva_thumb`};let Sw=[];function Cw(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 ww(e){return e.every(e=>e.type===`text`)?e.map(e=>e.text).join(``):null}function Tw(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 Ew({attachment:e,label:t}){return/* @__PURE__ */ (0,h.jsxs)(`span`,{className:Q.file,"aria-label":t,title:e.name,children:[/* @__PURE__ */ (0,h.jsx)(`span`,{className:Q.fileIcon,"aria-hidden":!0,children:/* @__PURE__ */ (0,h.jsx)(d.FileTypeIcon,{path:e.name,size:16})}),/* @__PURE__ */ (0,h.jsx)(`span`,{className:Q.fileName,children:e.name}),/* @__PURE__ */ (0,h.jsx)(`span`,{className:Q.fileSize,children:(0,d.fileSizeText)(e.bytes)})]})}function Dw({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:Q.thumb,"aria-hidden":!0}):/* @__PURE__ */ (0,h.jsx)(`img`,{className:Q.thumb,src:r,alt:n})}function Ow({upload:e,t}){let n=(0,g.useSyncExternalStore)(e.subscribe,e.getSnapshot);return n?.status===`uploading`?/* @__PURE__ */ (0,h.jsx)(`span`,{className:Q.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 kw({useSession:e,useProjection:t,updateQueue:n,editQueue:r,notify:i,loadImage:a,t:o}){let s=t(`inbox`),c=t(`queueState`),l=e(e=>e.pendingSubmissions),u=(0,g.useMemo)(()=>{let e=s?.[`next-turn`]??Sw,t=new Set(l.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))},[s,l]),f=(0,g.useMemo)(()=>{let e=new Set(u.flatMap(({source:e})=>e.kind===`user`&&`rpcId`in e?[e.rpcId]:[]));return l.filter(t=>t.placement===`queued`&&!e.has(t.requestId))},[l,u]),p=u.length+f.length,m=e(e=>e.running),_=e(e=>e.subagent===null||e.subagent.address.mode===`continuable`),v=(0,g.useRef)(!1),[y,ee]=(0,g.useState)(null),[b,x]=(0,g.useState)(!0),te=(0,g.useId)(),ne=c?.pausedReason??null,re=ne===`interrupted`?o(`queue.paused.interrupted`):ne===`outcome-unknown`?o(`queue.paused.unknown`):ne===`failed`?o(`queue.paused.failed`):null;if((0,g.useEffect)(()=>{p===0&&!b&&x(!0)},[b,p]),p===0)return null;let ie=_&&y!==null,ae=!b||ie,oe=p===1||ae,se=async(e,t,r)=>{if(v.current)return!1;v.current=!0,ee(e);try{return typeof t==`function`?await t():await n(e,t),!0}catch{return i(`error`,r),!1}finally{v.current=!1,ee(t=>t===e?null:t)}};return/* @__PURE__ */ (0,h.jsx)(`div`,{className:Q.dock,"data-queue-dock":``,children:/* @__PURE__ */ (0,h.jsxs)(`div`,{className:Q.panel,children:[re!==null&&/* @__PURE__ */ (0,h.jsx)(`div`,{className:Q.paused,role:`status`,children:re}),p>1&&/* @__PURE__ */ (0,h.jsxs)(`button`,{type:`button`,className:Q.header,"aria-controls":te,"aria-expanded":ae,disabled:ie,onClick:()=>{x(e=>!e)},children:[/* @__PURE__ */ (0,h.jsx)(`span`,{className:Q.lead,"aria-hidden":!0,children:/* @__PURE__ */ (0,h.jsx)(d.IconQueueOutlineRegular,{})}),/* @__PURE__ */ (0,h.jsx)(`span`,{className:Q.count,children:o(`queue.count`,{n:p})}),!oe&&f.length>0&&/* @__PURE__ */ (0,h.jsx)(`span`,{className:Q.status,role:`status`,children:o(`queue.sending`)}),/* @__PURE__ */ (0,h.jsx)(`span`,{className:Q.chevron,"aria-hidden":!0,children:ae?/* @__PURE__ */ (0,h.jsx)(d.IconChevronDownOutlineRegular,{}):/* @__PURE__ */ (0,h.jsx)(d.IconChevronUpOutlineRegular,{})})]}),/* @__PURE__ */ (0,h.jsxs)(`ul`,{id:te,className:Q.list,hidden:!oe,children:[oe&&u.map(e=>{let t=Tw(e.content),n=ww(e.content);return/* @__PURE__ */ (0,h.jsxs)(`li`,{className:Q.row,children:[p===1&&/* @__PURE__ */ (0,h.jsx)(`span`,{className:Q.lead,"aria-hidden":!0,children:/* @__PURE__ */ (0,h.jsx)(d.IconQueueOutlineRegular,{})}),t.length>0&&/* @__PURE__ */ (0,h.jsx)(`span`,{className:Q.attachments,children:t.map((e,t)=>e.type===`image`?/* @__PURE__ */ (0,h.jsx)(Dw,{attachment:e.attachment,loadImage:a,label:o(`queue.image`)},`${e.attachment.attachmentId}:${t}`):/* @__PURE__ */ (0,h.jsx)(Ew,{attachment:e.attachment,label:o(`queue.file`,{name:e.attachment.name})},`${e.attachment.attachmentId}:${e.attachment.name}:${t}`))}),/* @__PURE__ */ (0,h.jsx)(`span`,{className:Q.preview,children:(0,d.projectUserText)(Cw(e.content),[])}),_&&/* @__PURE__ */ (0,h.jsxs)(`div`,{className:Q.actions,children:[/* @__PURE__ */ (0,h.jsx)(d.Tooltip,{portal:!0,label:o(`queue.edit`),side:`bottom`,delayMs:500,disabled:n===null,children:/* @__PURE__ */ (0,h.jsx)(`button`,{type:`button`,className:Q.action,"aria-label":o(`queue.edit`),title:n===null?o(`queue.edit.unsupported`):void 0,disabled:y!==null||n===null,onClick:()=>{n!==null&&se(e.id,()=>r(e.id,n),o(`queue.editFailed`))},children:/* @__PURE__ */ (0,h.jsx)(d.IconEditOutlineRegular,{size:14})})}),/* @__PURE__ */ (0,h.jsx)(d.Tooltip,{portal:!0,label:o(`queue.remove`),side:`bottom`,delayMs:500,children:/* @__PURE__ */ (0,h.jsx)(`button`,{type:`button`,className:Q.action,"aria-label":o(`queue.remove`),disabled:y!==null,onClick:()=>{se(e.id,{kind:`remove`},o(`queue.removeFailed`))},children:/* @__PURE__ */ (0,h.jsx)(d.IconTrashOutlineRegular,{size:14})})}),/* @__PURE__ */ (0,h.jsx)(d.Tooltip,{portal:!0,label:o(m?`queue.steer`:`queue.resume`),side:`bottom`,delayMs:500,children:/* @__PURE__ */ (0,h.jsx)(`button`,{type:`button`,className:Q.action,"aria-label":o(m?`queue.steer`:`queue.resume`),disabled:y!==null,onClick:()=>{se(e.id,{kind:`steer`},o(m?`queue.steerFailed`:`queue.resumeFailed`))},children:/* @__PURE__ */ (0,h.jsx)(d.IconSendOutlineRegular,{})})})]})]},e.id)}),oe&&f.map(e=>/* @__PURE__ */ (0,h.jsxs)(`li`,{className:`${Q.row} ${Q.pendingRow}`,"data-submission-echo":``,children:[p===1&&/* @__PURE__ */ (0,h.jsx)(`span`,{className:Q.lead,"aria-hidden":!0,children:/* @__PURE__ */ (0,h.jsx)(d.IconQueueOutlineRegular,{})}),e.attachments.length>0&&/* @__PURE__ */ (0,h.jsx)(`span`,{className:Q.attachments,children:e.attachments.map((e,t)=>/* @__PURE__ */ (0,h.jsxs)(`span`,{className:Q.pendingAttachment,children:[e.type===`image`?/* @__PURE__ */ (0,h.jsx)(`img`,{className:Q.thumb,src:e.value.previewUrl,alt:o(`queue.image`)}):/* @__PURE__ */ (0,h.jsx)(Ew,{attachment:e.value,label:o(`queue.file`,{name:e.value.name})}),e.upload&&/* @__PURE__ */ (0,h.jsx)(Ow,{upload:e.upload,t:o})]},t))}),/* @__PURE__ */ (0,h.jsx)(`span`,{className:Q.preview,children:(0,d.projectUserText)(e.text,[])}),/* @__PURE__ */ (0,h.jsx)(`span`,{className:Q.status,role:`status`,children:o(`queue.sending`)}),_&&/* @__PURE__ */ (0,h.jsxs)(`div`,{className:Q.actions,children:[/* @__PURE__ */ (0,h.jsx)(`button`,{type:`button`,className:Q.action,"aria-label":o(`queue.edit`),title:o(`queue.sending`),disabled:!0,children:/* @__PURE__ */ (0,h.jsx)(d.IconEditOutlineRegular,{size:14})}),/* @__PURE__ */ (0,h.jsx)(`button`,{type:`button`,className:Q.action,"aria-label":o(`queue.remove`),title:o(`queue.sending`),disabled:!0,children:/* @__PURE__ */ (0,h.jsx)(d.IconTrashOutlineRegular,{size:14})}),/* @__PURE__ */ (0,h.jsx)(`button`,{type:`button`,className:Q.action,"aria-label":o(`queue.steer`),title:o(`queue.sending`),disabled:!0,children:/* @__PURE__ */ (0,h.jsx)(d.IconSendOutlineRegular,{})})]})]},e.requestId))]})]})})}let Aw={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:Nc,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`);return{updateQueue:(e,t)=>i.updateQueue(e,t),editQueue:async(e,r)=>{let a=t.shell(n);await i.updateQueue(e,{kind:`remove`});let o=a.draftSnapshot;a.setDraft({...o,text:o.text===``?r:`${o.text}\n${r}`}),a.actions.persistDraft(),a.focus()},notify:(e,t)=>{i.input.for(r).notify(e,t)},loadImage:t=>e.uiConversation.imageUrl(n,t)}}},kw))}},jw=`@deepseek-ai/dsh-client-ui-conversation/EnterBehaviorRow.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(jw)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-conversation`,e.dataset.pluginCss=jw,e.textContent=`.KaT34W_row{border-bottom:.5px solid var(--dsw-alias-border-l2);align-items:center;gap:8px;padding:16px 0;display:flex}.KaT34W_rowText{flex-direction:column;flex:1;gap:4px;min-width:0;padding-right:48px;display:flex}.KaT34W_title{color:var(--dsw-alias-label-primary);font-size:14px;font-weight:400;line-height:22px}.KaT34W_desc{color:var(--dsw-alias-label-tertiary);font-size:12px;font-weight:400;line-height:18px}.KaT34W_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}.KaT34W_selector:hover{background:var(--dsw-alias-interactive-bg-hover)}.KaT34W_chevron{flex:none}`,document.head.appendChild(e)}var Mw={chevron:`KaT34W_chevron`,desc:`KaT34W_desc`,row:`KaT34W_row`,rowText:`KaT34W_rowText`,selector:`KaT34W_selector`,title:`KaT34W_title`};let Nw=[{id:`queue`,label:`settings.enter.queue`},{id:`steer`,label:`settings.enter.steer`}];function Pw({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:Mw.row,children:[/* @__PURE__ */ (0,h.jsxs)(`div`,{className:Mw.rowText,children:[/* @__PURE__ */ (0,h.jsx)(`div`,{className:Mw.title,children:n(`settings.enter.title`)}),/* @__PURE__ */ (0,h.jsx)(`div`,{className:Mw.desc,children:n(`settings.enter.description`)})]}),/* @__PURE__ */ (0,h.jsx)(d.Menu,{open:i,onClose:()=>{a(!1)},items:Nw.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:Mw.selector,"aria-haspopup":`menu`,"aria-expanded":i,onClick:()=>{a(e=>!e)},children:[n(o),/* @__PURE__ */ (0,h.jsx)(d.IconChevronDownOutlineRegular,{className:Mw.chevron})]})})]})}let Fw={views:{get:()=>void 0,grouped:()=>void 0},activeTargets:/* @__PURE__ */ new Set};function Iw(e,t){return t.activeTargets.size>0||!e.blank&&!e.awaitingFirstTurn||e.running?`active`:e.promptAttempted?`engaging`:`blank`}let Lw=`@deepseek-ai/dsh-client-ui-conversation/ConversationRoot.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(Lw)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-conversation`,e.dataset.pluginCss=Lw,e.textContent=`.ofIY9G_root{background:var(--dsw-alias-bg-base);flex-direction:column;min-width:0;height:100%;display:flex;position:relative}body[data-codexhost-wallpaper] .ofIY9G_root{background:0 0}.ofIY9G_header{box-sizing:border-box;border-bottom:.5px solid var(--dsw-alias-border-l3);flex:none;grid-template-columns:auto minmax(0,1fr);min-height:76px;padding:10px 28px 0 20px;display:grid}.ofIY9G_header:where(:not(:has(.ofIY9G_tabs))){min-height:0;padding-bottom:10px}.ofIY9G_headerBlank{border-bottom:none;min-height:0;padding-bottom:0}.ofIY9G_headerBlank .ofIY9G_headerCorner{margin-left:auto}html:not([data-platform=darwin]) .ofIY9G_headerSessionless{padding-top:0}html:not([data-platform=darwin]) .ofIY9G_headerSessionless .ofIY9G_titleRow{min-height:0}[data-platform=darwin] .ofIY9G_headerLeading,[data-platform=darwin] .ofIY9G_headerActions,[data-platform=darwin] .ofIY9G_headerUtilities,[data-platform=darwin] .ofIY9G_headerCorner{-webkit-app-region:no-drag}.ofIY9G_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}[data-phone] .ofIY9G_header:has([data-slot="conversation.header.navigation"] button){padding-top:env(safe-area-inset-top)}[data-phone] .ofIY9G_header:has([data-slot="conversation.header.navigation"] button) .ofIY9G_titleRow{min-height:44px}.ofIY9G_titleCluster{flex:1;align-items:center;gap:10px;min-width:0;display:flex}.ofIY9G_headerLeading{flex:none;grid-area:1/1;align-items:center;gap:8px;display:flex}.ofIY9G_crumbs{white-space:nowrap;align-items:center;gap:4px;min-width:0;display:flex;overflow:hidden}.ofIY9G_crumbSeg{align-items:center;gap:4px;min-width:0;display:inline-flex}.ofIY9G_crumbSep{color:var(--dsw-alias-label-caption);font-size:14px;line-height:20px}.ofIY9G_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}.ofIY9G_crumbSubagent{font-size:12px;line-height:18px}button.ofIY9G_crumb:hover{background:var(--dsw-alias-interactive-bg-hover)}.ofIY9G_crumbCurrent{color:var(--dsw-alias-label-primary);cursor:default;font-weight:500}.ofIY9G_headerActions{flex:none;align-items:center;gap:8px;display:flex}.ofIY9G_headerUtilities{flex:none;align-items:center;gap:8px;margin-left:20px;display:flex}.ofIY9G_headerUtilities:empty{display:none}.ofIY9G_headerCorner{flex:none;align-items:center;margin-left:8px;margin-right:-16px;display:flex}.ofIY9G_headerCorner:empty{display:none}.ofIY9G_tabs{z-index:1;grid-column:1/-1;gap:36px;margin-top:10px;padding-left:8px;display:flex;position:relative}.ofIY9G_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}.ofIY9G_tab:after{content:"";background:0 0;border-radius:2px;height:2px;position:absolute;bottom:-1px;left:0;right:0}.ofIY9G_tabActive{color:var(--dsw-alias-state-business-primary)}.ofIY9G_tabActive:after{background:var(--dsw-alias-state-business-primary)}.ofIY9G_viewArea{flex-direction:column;flex:1;min-height:0;display:flex}.ofIY9G_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}.ofIY9G_widthHandle[data-side=left]{right:calc(50% + var(--dsh-chat-content-width) / 2 + 24px)}.ofIY9G_widthHandle[data-side=right]{left:calc(50% + var(--dsh-chat-content-width) / 2 + 24px)}.ofIY9G_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}.ofIY9G_widthHandle[data-side=left]:after{right:4px}.ofIY9G_widthHandle[data-side=right]:after{left:4px}.ofIY9G_widthHandle:hover:after,.ofIY9G_widthHandle[data-dragging]:after{opacity:1}.ofIY9G_widthHandle[data-dragging]{z-index:8}.ofIY9G_root:has([data-conversation-composer-overlay]) .ofIY9G_widthHandle{display:none}.ofIY9G_composerStack{--dsh-composer-stack-gap:6px;gap:var(--dsh-composer-stack-gap);flex-direction:column;display:flex}.ofIY9G_composerSeat{--dsh-composer-text-max-height:336px;flex-direction:column;flex:none;display:flex}.ofIY9G_root[data-phase=active]{overflow:hidden}.ofIY9G_root[data-phase=active] .ofIY9G_header{flex:none}.ofIY9G_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}.ofIY9G_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}.ofIY9G_scrollBody{scrollbar-gutter:stable;flex-direction:column;flex:1;min-height:0;margin-right:2px;display:flex;overflow-y:auto}.ofIY9G_scrollBody::-webkit-scrollbar-track{margin:2px}.ofIY9G_root[data-phase=active] .ofIY9G_viewArea,.ofIY9G_embeddedBody[data-content-phase=active] .ofIY9G_viewArea{flex:1 0 auto;min-height:auto}.ofIY9G_root[data-phase=active] .ofIY9G_composerSeat,.ofIY9G_embeddedBody[data-content-phase=active] .ofIY9G_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] .ofIY9G_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] .ofIY9G_composerSeat{--dsh-phone-composer-mask:initial}}body[data-codexhost-wallpaper] .ofIY9G_root[data-phase=active] .ofIY9G_composerSeat,body[data-codexhost-wallpaper] .ofIY9G_embeddedBody[data-content-phase=active] .ofIY9G_composerSeat{background:0 0}.ofIY9G_root[data-phase=active] .ofIY9G_composerSeat:has([data-trigger-menu]){z-index:9}.ofIY9G_scrollBody:has([data-conversation-composer-overlay]){scrollbar-gutter:auto;position:relative;overflow:hidden auto}.ofIY9G_scrollBody:has([data-conversation-composer-overlay])>[data-slot=conversation\\.session]>.ofIY9G_viewArea{flex:1 1 0;min-height:0;overflow:hidden}.ofIY9G_scrollBody:has([data-conversation-composer-overlay])>.ofIY9G_composerSeat{right:var(--dsh-scrollbar-width);position:absolute;bottom:0;left:0}.ofIY9G_composerHero{width:min(calc(var(--dsh-composer-card-max-width) + 2 * var(--dsh-composer-side-clearance)), 100%);z-index:1;align-self:center;gap:8px;padding-bottom:32px}.ofIY9G_heroWorkspaceRow{align-items:center;gap:2px;min-width:0;margin-top:4px;padding:0 16px 0 20px;display:flex}.ofIY9G_root[data-phase=hero] .ofIY9G_scrollBody,.ofIY9G_embeddedBody[data-content-phase=hero] .ofIY9G_scrollBody{justify-content:center;overflow-y:auto}.ofIY9G_root[data-phase=settling] .ofIY9G_composerSeat,.ofIY9G_embeddedBody[data-content-phase=settling] .ofIY9G_composerSeat{visibility:hidden}`,document.head.appendChild(e)}var $={body:`ofIY9G_body`,composerHero:`ofIY9G_composerHero`,composerSeat:`ofIY9G_composerSeat`,composerStack:`ofIY9G_composerStack`,crumb:`ofIY9G_crumb`,crumbCurrent:`ofIY9G_crumbCurrent`,crumbSeg:`ofIY9G_crumbSeg`,crumbSep:`ofIY9G_crumbSep`,crumbSubagent:`ofIY9G_crumbSubagent`,crumbs:`ofIY9G_crumbs`,embeddedBody:`ofIY9G_embeddedBody`,header:`ofIY9G_header`,headerActions:`ofIY9G_headerActions`,headerBlank:`ofIY9G_headerBlank`,headerCorner:`ofIY9G_headerCorner`,headerLeading:`ofIY9G_headerLeading`,headerSessionless:`ofIY9G_headerSessionless`,headerUtilities:`ofIY9G_headerUtilities`,heroWorkspaceRow:`ofIY9G_heroWorkspaceRow`,root:`ofIY9G_root`,scrollBody:`ofIY9G_scrollBody`,tab:`ofIY9G_tab`,tabActive:`ofIY9G_tabActive`,tabs:`ofIY9G_tabs`,titleCluster:`ofIY9G_titleCluster`,titleRow:`ofIY9G_titleRow`,viewArea:`ofIY9G_viewArea`,widthHandle:`ofIY9G_widthHandle`};let Rw=`dsh.conversation.contentWidth`;function zw(){let e=localStorage.getItem(Rw);if(e===null)return null;let t=Number(e);return Number.isFinite(t)&&t>0?t:null}function Bw(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 Vw(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 Hw(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;
|
|
172
|
+
`),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,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`]??MT}}publish(){let e=this.compose();this.state.set(e);let t=this.draftSnapshot;t!==this.lastPublishedDraft&&(this.lastPublishedDraft=t,this.persistDraft?.(t))}};function FT(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 IT=class{rootCtx;t;shells=/* @__PURE__ */ new WeakMap;constructor(e,t){this.rootCtx=e,this.t=t}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)}shellFor(e){let t=this.shells.get(e);if(t!==void 0)return t;let{session:n,ctx:r}=e,i=new PT({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=>{FT(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(jc(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 LT=`busyEnter`,RT=[`queue`,`steer`],zT=`queue`,BT={[LT]:w.union([...RT]).default(zT)};w.object(BT);function VT(e,t,n,r){return!t||!r?`queue`:n===`enter`?e:e===`queue`?`steer`:`queue`}var HT=class{busyEnter=(0,f.createSnapshotStore)(zT);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(LT,e))}adopt(e){let t=e.getSnapshot().value;t!==void 0&&this.busyEnter.getSnapshot()!==t.busyEnter&&this.busyEnter.set(t.busyEnter)}};let UT=`@deepseek-ai/dsh-client-ui-conversation/QueueDock.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(UT)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-conversation`,e.dataset.pluginCss=UT,e.textContent=`._45elva_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}._45elva_pendingAttachment{flex-direction:column;gap:2px;display:inline-flex}._45elva_panel{isolation:isolate;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}._45elva_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}._45elva_panel:after{border:.5px solid var(--dsw-alias-border-l1);border-radius:inherit;content:"";pointer-events:none;border-bottom:none;position:absolute;inset:0}._45elva_paused{color:var(--dsw-alias-label-tertiary);font:var(--dsw-font-xs-13);padding:6px 12px 2px}._45elva_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}._45elva_header:focus-visible{outline:var(--dsw-focus-ring-width) solid var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary));outline-offset:-2px}._45elva_header:disabled{cursor:default}._45elva_lead{color:var(--dsw-alias-label-tertiary);flex:none;place-items:center;display:grid}._45elva_count{min-width:0;font-family:Inter, var(--dsw-font-family);flex:auto;font-size:13px;font-weight:500;line-height:24px}._45elva_chevron{width:14px;height:14px;color:var(--dsw-alias-label-tertiary);flex:none;place-items:center;display:grid}._45elva_list{max-height:180px;margin:0;padding:0;list-style:none;overflow-y:auto}._45elva_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}._45elva_row+._45elva_row{box-shadow:inset 0 1px 0 var(--dsw-alias-border-l1)}._45elva_attachments{flex:none;gap:4px;min-width:0;max-width:55%;display:flex;overflow:hidden}._45elva_pendingRow ._45elva_attachments{flex-shrink:1}._45elva_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}._45elva_fileIcon{flex:none;width:16px;height:16px;display:inline-flex}._45elva_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}._45elva_fileSize{color:var(--dsw-alias-label-tertiary);white-space:nowrap;flex:none;font-size:10px}._45elva_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}._45elva_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}._45elva_actions{flex:none;align-items:center;gap:10px;display:flex}._45elva_status{color:var(--dsw-alias-label-tertiary);font:var(--dsw-font-xs-13);white-space:nowrap;flex:none}._45elva_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}._45elva_action:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-hover)}._45elva_action:focus-visible{outline:var(--dsw-focus-ring-width) solid var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary));outline-offset:-2px}._45elva_action:disabled{cursor:default;opacity:.45}`,document.head.appendChild(e)}var Q={action:`_45elva_action`,actions:`_45elva_actions`,attachments:`_45elva_attachments`,chevron:`_45elva_chevron`,count:`_45elva_count`,dock:`_45elva_dock`,file:`_45elva_file`,fileIcon:`_45elva_fileIcon`,fileName:`_45elva_fileName`,fileSize:`_45elva_fileSize`,header:`_45elva_header`,lead:`_45elva_lead`,list:`_45elva_list`,panel:`_45elva_panel`,paused:`_45elva_paused`,pendingAttachment:`_45elva_pendingAttachment`,pendingRow:`_45elva_pendingRow`,preview:`_45elva_preview`,row:`_45elva_row`,status:`_45elva_status`,thumb:`_45elva_thumb`};let WT=[];function GT(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 KT(e){return e.every(e=>e.type===`text`)?e.map(e=>e.text).join(``):null}function qT(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 JT({attachment:e,label:t}){return/* @__PURE__ */ (0,h.jsxs)(`span`,{className:Q.file,"aria-label":t,title:e.name,children:[/* @__PURE__ */ (0,h.jsx)(`span`,{className:Q.fileIcon,"aria-hidden":!0,children:/* @__PURE__ */ (0,h.jsx)(d.FileTypeIcon,{path:e.name,size:16})}),/* @__PURE__ */ (0,h.jsx)(`span`,{className:Q.fileName,children:e.name}),/* @__PURE__ */ (0,h.jsx)(`span`,{className:Q.fileSize,children:(0,d.fileSizeText)(e.bytes)})]})}function YT({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:Q.thumb,"aria-hidden":!0}):/* @__PURE__ */ (0,h.jsx)(`img`,{className:Q.thumb,src:r,alt:n})}function XT({upload:e,t}){let n=(0,g.useSyncExternalStore)(e.subscribe,e.getSnapshot);return n?.status===`uploading`?/* @__PURE__ */ (0,h.jsx)(`span`,{className:Q.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 ZT({useSession:e,useProjection:t,updateQueue:n,editQueue:r,notify:i,loadImage:a,t:o}){let s=t(`inbox`),c=t(`queueState`),l=e(e=>e.pendingSubmissions),u=(0,g.useMemo)(()=>{let e=s?.[`next-turn`]??WT,t=new Set(l.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))},[s,l]),f=(0,g.useMemo)(()=>{let e=new Set(u.flatMap(({source:e})=>e.kind===`user`&&`rpcId`in e?[e.rpcId]:[]));return l.filter(t=>t.placement===`queued`&&!e.has(t.requestId))},[l,u]),p=u.length+f.length,m=e(e=>e.running),_=e(e=>e.subagent===null||e.subagent.address.mode===`continuable`),v=(0,g.useRef)(!1),[y,ee]=(0,g.useState)(null),[b,te]=(0,g.useState)(!0),x=(0,g.useId)(),ne=c?.pausedReason??null,re=ne===`interrupted`?o(`queue.paused.interrupted`):ne===`outcome-unknown`?o(`queue.paused.unknown`):ne===`failed`?o(`queue.paused.failed`):null;if((0,g.useEffect)(()=>{p===0&&!b&&te(!0)},[b,p]),p===0)return null;let ie=_&&y!==null,ae=!b||ie,oe=p===1||ae,se=async(e,t,r)=>{if(v.current)return!1;v.current=!0,ee(e);try{return typeof t==`function`?await t():await n(e,t),!0}catch{return i(`error`,r),!1}finally{v.current=!1,ee(t=>t===e?null:t)}};return/* @__PURE__ */ (0,h.jsx)(`div`,{className:Q.dock,"data-queue-dock":``,children:/* @__PURE__ */ (0,h.jsxs)(`div`,{className:Q.panel,children:[re!==null&&/* @__PURE__ */ (0,h.jsx)(`div`,{className:Q.paused,role:`status`,children:re}),p>1&&/* @__PURE__ */ (0,h.jsxs)(`button`,{type:`button`,className:Q.header,"aria-controls":x,"aria-expanded":ae,disabled:ie,onClick:()=>{te(e=>!e)},children:[/* @__PURE__ */ (0,h.jsx)(`span`,{className:Q.lead,"aria-hidden":!0,children:/* @__PURE__ */ (0,h.jsx)(d.IconQueueOutlineRegular,{})}),/* @__PURE__ */ (0,h.jsx)(`span`,{className:Q.count,children:o(`queue.count`,{n:p})}),!oe&&f.length>0&&/* @__PURE__ */ (0,h.jsx)(`span`,{className:Q.status,role:`status`,children:o(`queue.sending`)}),/* @__PURE__ */ (0,h.jsx)(`span`,{className:Q.chevron,"aria-hidden":!0,children:ae?/* @__PURE__ */ (0,h.jsx)(d.IconChevronDownOutlineRegular,{}):/* @__PURE__ */ (0,h.jsx)(d.IconChevronUpOutlineRegular,{})})]}),/* @__PURE__ */ (0,h.jsxs)(`ul`,{id:x,className:Q.list,hidden:!oe,children:[oe&&u.map(e=>{let t=qT(e.content),n=KT(e.content);return/* @__PURE__ */ (0,h.jsxs)(`li`,{className:Q.row,children:[p===1&&/* @__PURE__ */ (0,h.jsx)(`span`,{className:Q.lead,"aria-hidden":!0,children:/* @__PURE__ */ (0,h.jsx)(d.IconQueueOutlineRegular,{})}),t.length>0&&/* @__PURE__ */ (0,h.jsx)(`span`,{className:Q.attachments,children:t.map((e,t)=>e.type===`image`?/* @__PURE__ */ (0,h.jsx)(YT,{attachment:e.attachment,loadImage:a,label:o(`queue.image`)},`${e.attachment.attachmentId}:${t}`):/* @__PURE__ */ (0,h.jsx)(JT,{attachment:e.attachment,label:o(`queue.file`,{name:e.attachment.name})},`${e.attachment.attachmentId}:${e.attachment.name}:${t}`))}),/* @__PURE__ */ (0,h.jsx)(`span`,{className:Q.preview,children:(0,d.projectUserText)(GT(e.content),[])}),_&&/* @__PURE__ */ (0,h.jsxs)(`div`,{className:Q.actions,children:[/* @__PURE__ */ (0,h.jsx)(d.Tooltip,{portal:!0,label:o(`queue.edit`),side:`bottom`,delayMs:500,disabled:n===null,children:/* @__PURE__ */ (0,h.jsx)(`button`,{type:`button`,className:Q.action,"aria-label":o(`queue.edit`),title:n===null?o(`queue.edit.unsupported`):void 0,disabled:y!==null||n===null,onClick:()=>{n!==null&&se(e.id,()=>r(e.id,n),o(`queue.editFailed`))},children:/* @__PURE__ */ (0,h.jsx)(d.IconEditOutlineRegular,{size:14})})}),/* @__PURE__ */ (0,h.jsx)(d.Tooltip,{portal:!0,label:o(`queue.remove`),side:`bottom`,delayMs:500,children:/* @__PURE__ */ (0,h.jsx)(`button`,{type:`button`,className:Q.action,"aria-label":o(`queue.remove`),disabled:y!==null,onClick:()=>{se(e.id,{kind:`remove`},o(`queue.removeFailed`))},children:/* @__PURE__ */ (0,h.jsx)(d.IconTrashOutlineRegular,{size:14})})}),/* @__PURE__ */ (0,h.jsx)(d.Tooltip,{portal:!0,label:o(m?`queue.steer`:`queue.resume`),side:`bottom`,delayMs:500,children:/* @__PURE__ */ (0,h.jsx)(`button`,{type:`button`,className:Q.action,"aria-label":o(m?`queue.steer`:`queue.resume`),disabled:y!==null,onClick:()=>{se(e.id,{kind:`steer`},o(m?`queue.steerFailed`:`queue.resumeFailed`))},children:/* @__PURE__ */ (0,h.jsx)(d.IconSendOutlineRegular,{})})})]})]},e.id)}),oe&&f.map(e=>/* @__PURE__ */ (0,h.jsxs)(`li`,{className:`${Q.row} ${Q.pendingRow}`,"data-submission-echo":``,children:[p===1&&/* @__PURE__ */ (0,h.jsx)(`span`,{className:Q.lead,"aria-hidden":!0,children:/* @__PURE__ */ (0,h.jsx)(d.IconQueueOutlineRegular,{})}),e.attachments.length>0&&/* @__PURE__ */ (0,h.jsx)(`span`,{className:Q.attachments,children:e.attachments.map((e,t)=>/* @__PURE__ */ (0,h.jsxs)(`span`,{className:Q.pendingAttachment,children:[e.type===`image`?/* @__PURE__ */ (0,h.jsx)(`img`,{className:Q.thumb,src:e.value.previewUrl,alt:o(`queue.image`)}):/* @__PURE__ */ (0,h.jsx)(JT,{attachment:e.value,label:o(`queue.file`,{name:e.value.name})}),e.upload&&/* @__PURE__ */ (0,h.jsx)(XT,{upload:e.upload,t:o})]},t))}),/* @__PURE__ */ (0,h.jsx)(`span`,{className:Q.preview,children:(0,d.projectUserText)(e.text,[])}),/* @__PURE__ */ (0,h.jsx)(`span`,{className:Q.status,role:`status`,children:o(`queue.sending`)}),_&&/* @__PURE__ */ (0,h.jsxs)(`div`,{className:Q.actions,children:[/* @__PURE__ */ (0,h.jsx)(`button`,{type:`button`,className:Q.action,"aria-label":o(`queue.edit`),title:o(`queue.sending`),disabled:!0,children:/* @__PURE__ */ (0,h.jsx)(d.IconEditOutlineRegular,{size:14})}),/* @__PURE__ */ (0,h.jsx)(`button`,{type:`button`,className:Q.action,"aria-label":o(`queue.remove`),title:o(`queue.sending`),disabled:!0,children:/* @__PURE__ */ (0,h.jsx)(d.IconTrashOutlineRegular,{size:14})}),/* @__PURE__ */ (0,h.jsx)(`button`,{type:`button`,className:Q.action,"aria-label":o(`queue.steer`),title:o(`queue.sending`),disabled:!0,children:/* @__PURE__ */ (0,h.jsx)(d.IconSendOutlineRegular,{})})]})]},e.requestId))]})]})})}let QT={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:Ic,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`);return{updateQueue:(e,t)=>i.updateQueue(e,t),editQueue:async(e,r)=>{let a=t.shell(n);await i.updateQueue(e,{kind:`remove`});let o=a.draftSnapshot;a.setDraft({...o,text:o.text===``?r:`${o.text}\n${r}`}),a.actions.persistDraft(),a.focus(`end`)},notify:(e,t)=>{i.input.for(r).notify(e,t)},loadImage:t=>e.uiConversation.imageUrl(n,t)}}},ZT))}},$T=`@deepseek-ai/dsh-client-ui-conversation/EnterBehaviorRow.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify($T)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-conversation`,e.dataset.pluginCss=$T,e.textContent=`.KaT34W_row{border-bottom:.5px solid var(--dsw-alias-border-l2);align-items:center;gap:8px;padding:16px 0;display:flex}.KaT34W_rowText{flex-direction:column;flex:1;gap:4px;min-width:0;padding-right:48px;display:flex}.KaT34W_title{color:var(--dsw-alias-label-primary);font-size:14px;font-weight:400;line-height:22px}.KaT34W_desc{color:var(--dsw-alias-label-tertiary);font-size:12px;font-weight:400;line-height:18px}.KaT34W_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}.KaT34W_selector:hover{background:var(--dsw-alias-interactive-bg-hover)}.KaT34W_chevron{flex:none}`,document.head.appendChild(e)}var eE={chevron:`KaT34W_chevron`,desc:`KaT34W_desc`,row:`KaT34W_row`,rowText:`KaT34W_rowText`,selector:`KaT34W_selector`,title:`KaT34W_title`};let tE=[{id:`queue`,label:`settings.enter.queue`},{id:`steer`,label:`settings.enter.steer`}];function nE({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:eE.row,children:[/* @__PURE__ */ (0,h.jsxs)(`div`,{className:eE.rowText,children:[/* @__PURE__ */ (0,h.jsx)(`div`,{className:eE.title,children:n(`settings.enter.title`)}),/* @__PURE__ */ (0,h.jsx)(`div`,{className:eE.desc,children:n(`settings.enter.description`)})]}),/* @__PURE__ */ (0,h.jsx)(d.Menu,{open:i,onClose:()=>{a(!1)},items:tE.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:eE.selector,"aria-haspopup":`menu`,"aria-expanded":i,onClick:()=>{a(e=>!e)},children:[n(o),/* @__PURE__ */ (0,h.jsx)(d.IconChevronDownOutlineRegular,{className:eE.chevron})]})})]})}let rE={views:{get:()=>void 0,grouped:()=>void 0},activeTargets:/* @__PURE__ */ new Set};function iE(e,t){return t.activeTargets.size>0||!e.blank&&!e.awaitingFirstTurn||e.running?`active`:e.promptAttempted?`engaging`:`blank`}let aE=`@deepseek-ai/dsh-client-ui-conversation/ConversationRoot.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(aE)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-conversation`,e.dataset.pluginCss=aE,e.textContent=`.ofIY9G_root{background:var(--dsw-alias-bg-base);flex-direction:column;min-width:0;height:100%;display:flex;position:relative}body[data-codexhost-wallpaper] .ofIY9G_root{background:0 0}.ofIY9G_header{box-sizing:border-box;border-bottom:.5px solid var(--dsw-alias-border-l3);flex:none;grid-template-columns:auto minmax(0,1fr);min-height:76px;padding:10px 28px 0 20px;display:grid}.ofIY9G_header:where(:not(:has(.ofIY9G_tabs))){min-height:0;padding-bottom:10px}.ofIY9G_headerBlank{border-bottom:none;min-height:0;padding-bottom:0}.ofIY9G_headerBlank .ofIY9G_headerCorner{margin-left:auto}html:not([data-platform=darwin]) .ofIY9G_headerSessionless{padding-top:0}html:not([data-platform=darwin]) .ofIY9G_headerSessionless .ofIY9G_titleRow{min-height:0}[data-platform=darwin] .ofIY9G_headerLeading,[data-platform=darwin] .ofIY9G_headerActions,[data-platform=darwin] .ofIY9G_headerUtilities,[data-platform=darwin] .ofIY9G_headerCorner{-webkit-app-region:no-drag}.ofIY9G_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}.ofIY9G_titleCenter{display:contents}.ofIY9G_phoneTrailingAction{display:none}.ofIY9G_titleCluster{flex:1;align-items:center;gap:10px;min-width:0;display:flex}.ofIY9G_headerLeading{flex:none;grid-area:1/1;align-items:center;gap:8px;display:flex}.ofIY9G_crumbs{white-space:nowrap;align-items:center;gap:4px;min-width:0;display:flex;overflow:hidden}.ofIY9G_crumbSeg{align-items:center;gap:4px;min-width:0;display:inline-flex}.ofIY9G_crumbSep{color:var(--dsw-alias-label-caption);font-size:14px;line-height:20px}.ofIY9G_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}.ofIY9G_crumbSubagent{font-size:12px;line-height:18px}button.ofIY9G_crumb:hover{background:var(--dsw-alias-interactive-bg-hover)}.ofIY9G_crumbCurrent{color:var(--dsw-alias-label-primary);cursor:default;font-weight:500}.ofIY9G_headerActions{flex:none;align-items:center;gap:8px;display:flex}.ofIY9G_headerUtilities{flex:none;align-items:center;gap:8px;margin-left:20px;display:flex}.ofIY9G_headerUtilities:empty{display:none}.ofIY9G_headerCorner{flex:none;align-items:center;margin-left:8px;margin-right:-16px;display:flex}.ofIY9G_headerCorner:empty,.ofIY9G_headerCorner:not(:has([data-slot="conversation.session.header.corner"]>*)){display:none}[data-phone] .ofIY9G_root[data-phase=active]{--dsh-phone-header-height:calc(env(safe-area-inset-top) + 44px)}[data-phone] .ofIY9G_root[data-phase=active]:has([data-slot="conversation.header.shortcuts"] nav){--dsh-phone-header-height:calc(env(safe-area-inset-top) + 88px)}[data-phone] .ofIY9G_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] .ofIY9G_root[data-phase=active] .ofIY9G_header{pointer-events:none;position:absolute;top:0;left:0;right:0}[data-phone] .ofIY9G_root[data-phase=active] .ofIY9G_header [data-slot="conversation.header.shortcuts"]{pointer-events:auto}[data-phone] .ofIY9G_root[data-phase=active]:not(:has([data-slot="conversation.header.notice"]>*)) .ofIY9G_scrollBody{padding-top:var(--dsh-phone-header-height)}[data-phone] .ofIY9G_root[data-phase=active]>[data-slot="conversation.header.notice"]:not(:empty){margin-top:var(--dsh-phone-header-height);z-index:5;position:relative}[data-phone] .ofIY9G_root[data-phase=active] .ofIY9G_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] .ofIY9G_root[data-phase=active] .ofIY9G_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] .ofIY9G_root[data-phase=active] .ofIY9G_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] .ofIY9G_headerLeading{display:none}[data-phone] .ofIY9G_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] .ofIY9G_titleCluster{grid-column:2;justify-content:center;align-items:center;gap:4px;min-width:0;max-width:100%;display:flex}[data-phone] .ofIY9G_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] .ofIY9G_root[data-phase=active] .ofIY9G_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] .ofIY9G_root[data-phase=active] .ofIY9G_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] .ofIY9G_titleCenter{text-shadow:0 1px 10px #0000006b}[data-phone] .ofIY9G_titleCenter:has([data-navigation-focus-return]){cursor:pointer;-webkit-tap-highlight-color:transparent}[data-phone] .ofIY9G_titleRow>.ofIY9G_titleCenter,[data-phone] .ofIY9G_titleRow>[data-slot="conversation.header.navigation"]{pointer-events:auto;grid-column:2;justify-self:center}[data-phone] .ofIY9G_titleCenter>[data-slot="conversation.header.navigation"]{display:contents}[data-phone] .ofIY9G_titleCenter:has([data-navigation-focus-return]):active{opacity:.52}[data-phone] .ofIY9G_titleCenter:has([data-navigation-focus-return]:focus-visible){outline:none}@media (hover:hover) and (pointer:fine){[data-phone] .ofIY9G_titleCenter:has([data-navigation-focus-return]:focus-visible){outline:2px solid var(--dsw-alias-label-primary);outline-offset:2px}}[data-phone] .ofIY9G_crumbs{justify-content:center;gap:3px}[data-phone] .ofIY9G_crumb{letter-spacing:-.015em;max-width:none;padding:0;font-size:15px;font-weight:600;line-height:20px}[data-phone] button.ofIY9G_crumb{z-index:1;position:relative}[data-phone] .ofIY9G_headerActions:not(:has(button)),[data-phone] .ofIY9G_headerUtilities{display:none}[data-phone] .ofIY9G_phoneTrailingAction,[data-phone] .ofIY9G_headerCorner>[data-slot="conversation.session.header.corner"],[data-phone] .ofIY9G_phoneTrailingAction>[data-slot="conversation.header.trailing"]{display:contents}[data-phone] .ofIY9G_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] .ofIY9G_headerCorner:has(button):not(:has([data-phone-new-session]):has([data-sidebar-right-expand])){width:36px;padding:0}[data-ds-dark-theme] [data-phone] .ofIY9G_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] .ofIY9G_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] .ofIY9G_headerCorner:has(button){backdrop-filter:blur(10px)saturate(180%);background:linear-gradient(#ffffff1f 0%,#ffffff0d 100%)}}@media (prefers-reduced-motion:reduce){[data-phone] .ofIY9G_titleCenter{transition:none}}@media (prefers-reduced-transparency:reduce),(prefers-contrast:more){[data-phone] .ofIY9G_root[data-phase=active] .ofIY9G_header{pointer-events:auto;background:var(--dsw-alias-bg-base);border-bottom:.5px solid var(--dsw-alias-border-l3);position:relative}[data-phone] .ofIY9G_root[data-phase=active] .ofIY9G_header:before{display:none}[data-phone] .ofIY9G_root[data-phase=active]:not(:has([data-slot="conversation.header.notice"]>*)) .ofIY9G_scrollBody{padding-top:0}[data-phone] .ofIY9G_root[data-phase=active]>[data-slot="conversation.header.notice"]:not(:empty){margin-top:0}[data-phone] .ofIY9G_headerCorner:has(button),[data-ds-dark-theme] [data-phone] .ofIY9G_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] .ofIY9G_headerCorner:has(button),[data-ds-dark-theme] [data-phone] .ofIY9G_headerCorner:has(button){border-color:var(--dsw-alias-label-secondary);box-shadow:none}}@media (forced-colors:active){[data-phone] .ofIY9G_root[data-phase=active] .ofIY9G_header{pointer-events:auto;background:canvas;border-bottom:1px solid canvastext;position:relative}[data-phone] .ofIY9G_root[data-phase=active] .ofIY9G_header:before{display:none}[data-phone] .ofIY9G_root[data-phase=active]:not(:has([data-slot="conversation.header.notice"]>*)) .ofIY9G_scrollBody{padding-top:0}[data-phone] .ofIY9G_root[data-phase=active]>[data-slot="conversation.header.notice"]:not(:empty){margin-top:0}[data-phone] .ofIY9G_headerCorner:has(button),[data-ds-dark-theme] [data-phone] .ofIY9G_headerCorner:has(button){backdrop-filter:none;box-shadow:none;background:buttonface;border:1px solid buttontext}}.ofIY9G_tabs{z-index:1;grid-column:1/-1;gap:36px;margin-top:10px;padding-left:8px;display:flex;position:relative}.ofIY9G_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}.ofIY9G_tab:after{content:"";background:0 0;border-radius:2px;height:2px;position:absolute;bottom:-1px;left:0;right:0}.ofIY9G_tabActive{color:var(--dsw-alias-state-business-primary)}.ofIY9G_tabActive:after{background:var(--dsw-alias-state-business-primary)}.ofIY9G_viewArea{flex-direction:column;flex:1;min-height:0;display:flex}.ofIY9G_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}.ofIY9G_widthHandle[data-side=left]{right:calc(50% + var(--dsh-chat-content-width) / 2 + 24px)}.ofIY9G_widthHandle[data-side=right]{left:calc(50% + var(--dsh-chat-content-width) / 2 + 24px)}.ofIY9G_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}.ofIY9G_widthHandle[data-side=left]:after{right:4px}.ofIY9G_widthHandle[data-side=right]:after{left:4px}.ofIY9G_widthHandle:hover:after,.ofIY9G_widthHandle[data-dragging]:after{opacity:1}.ofIY9G_widthHandle[data-dragging]{z-index:8}.ofIY9G_root:has([data-conversation-composer-overlay]) .ofIY9G_widthHandle{display:none}.ofIY9G_composerStack{--dsh-composer-stack-gap:6px;gap:var(--dsh-composer-stack-gap);flex-direction:column;display:flex}.ofIY9G_composerSeat{--dsh-composer-text-max-height:336px;flex-direction:column;flex:none;display:flex}.ofIY9G_root[data-phase=active]{overflow:hidden}.ofIY9G_root[data-phase=active] .ofIY9G_header{flex:none}.ofIY9G_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}.ofIY9G_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}.ofIY9G_scrollBody{scrollbar-gutter:stable;flex-direction:column;flex:1;min-height:0;margin-right:2px;display:flex;overflow:hidden auto}.ofIY9G_scrollBody::-webkit-scrollbar-track{margin:2px}.ofIY9G_root[data-phase=active] .ofIY9G_viewArea,.ofIY9G_embeddedBody[data-content-phase=active] .ofIY9G_viewArea{flex:1 0 auto;min-height:auto}.ofIY9G_root[data-phase=active] .ofIY9G_composerSeat,.ofIY9G_embeddedBody[data-content-phase=active] .ofIY9G_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] .ofIY9G_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] .ofIY9G_composerSeat{--dsh-phone-composer-mask:initial}}body[data-codexhost-wallpaper] .ofIY9G_root[data-phase=active] .ofIY9G_composerSeat,body[data-codexhost-wallpaper] .ofIY9G_embeddedBody[data-content-phase=active] .ofIY9G_composerSeat{background:0 0}.ofIY9G_root[data-phase=active] .ofIY9G_composerSeat:has([data-trigger-menu]){z-index:9}.ofIY9G_scrollBody:has([data-conversation-composer-overlay]){scrollbar-gutter:auto;position:relative;overflow:hidden auto}.ofIY9G_scrollBody:has([data-conversation-composer-overlay])>[data-slot=conversation\\.session]>.ofIY9G_viewArea{flex:1 1 0;min-height:0;overflow:hidden}.ofIY9G_scrollBody:has([data-conversation-composer-overlay])>.ofIY9G_composerSeat{right:var(--dsh-scrollbar-width);position:absolute;bottom:0;left:0}.ofIY9G_composerHero{width:min(calc(var(--dsh-composer-card-max-width) + 2 * var(--dsh-composer-side-clearance)), 100%);z-index:1;align-self:center;gap:8px;padding-bottom:32px}.ofIY9G_heroWorkspaceRow{align-items:center;gap:2px;min-width:0;margin-top:4px;padding:0 16px 0 20px;display:flex}.ofIY9G_root[data-phase=hero] .ofIY9G_scrollBody,.ofIY9G_embeddedBody[data-content-phase=hero] .ofIY9G_scrollBody{justify-content:center;overflow-y:auto}.ofIY9G_root[data-phase=settling] .ofIY9G_composerSeat,.ofIY9G_embeddedBody[data-content-phase=settling] .ofIY9G_composerSeat{visibility:hidden}`,document.head.appendChild(e)}var $={body:`ofIY9G_body`,composerHero:`ofIY9G_composerHero`,composerSeat:`ofIY9G_composerSeat`,composerStack:`ofIY9G_composerStack`,crumb:`ofIY9G_crumb`,crumbCurrent:`ofIY9G_crumbCurrent`,crumbSeg:`ofIY9G_crumbSeg`,crumbSep:`ofIY9G_crumbSep`,crumbSubagent:`ofIY9G_crumbSubagent`,crumbs:`ofIY9G_crumbs`,embeddedBody:`ofIY9G_embeddedBody`,header:`ofIY9G_header`,headerActions:`ofIY9G_headerActions`,headerBlank:`ofIY9G_headerBlank`,headerCorner:`ofIY9G_headerCorner`,headerLeading:`ofIY9G_headerLeading`,headerSessionless:`ofIY9G_headerSessionless`,headerUtilities:`ofIY9G_headerUtilities`,heroWorkspaceRow:`ofIY9G_heroWorkspaceRow`,phoneTrailingAction:`ofIY9G_phoneTrailingAction`,root:`ofIY9G_root`,scrollBody:`ofIY9G_scrollBody`,tab:`ofIY9G_tab`,tabActive:`ofIY9G_tabActive`,tabs:`ofIY9G_tabs`,titleCenter:`ofIY9G_titleCenter`,titleCluster:`ofIY9G_titleCluster`,titleRow:`ofIY9G_titleRow`,viewArea:`ofIY9G_viewArea`,widthHandle:`ofIY9G_widthHandle`};let oE=`dsh.conversation.contentWidth`;function sE(){let e=localStorage.getItem(oE);if(e===null)return null;let t=Number(e);return Number.isFinite(t)&&t>0?t:null}function cE(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 lE(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 uE(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;
|
|
170
173
|
/* v8 ignore next -- a width handle renders only inside the Conversation body. */
|
|
171
174
|
if(t===null)return;let n=t.querySelector(`:scope > [data-conversation-scroll]`);
|
|
172
175
|
/* v8 ignore next -- the Conversation body always contains its direct scroll element. */
|
|
173
|
-
n!==null&&(e.ctrlKey||e.deltaY===0||n.scrollBy({top:Vw(e,n)}))},[]);return/* @__PURE__ */ (0,h.jsx)(`div`,{className:$.widthHandle,"data-side":e.side,"data-width-handle":e.side,onPointerDown:l,onPointerMove:u,onPointerUp:d,onPointerCancel:f,onLostPointerCapture:f,onWheel:p})}function Uw({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=zw();r===null?t.style.removeProperty(`--dsh-chat-user-width`):t.style.setProperty(`--dsh-chat-user-width`,`${Bw(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:Bw(e.offsetWidth,zw()),[e]),i=(0,g.useCallback)(t=>{e!==null&&(e.parentElement??e).style.setProperty(`--dsh-chat-user-width`,`${Bw(e.offsetWidth,t)}px`)},[e]),a=(0,g.useCallback)(t=>{e!==null&&localStorage.setItem(Rw,`${Bw(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)(Hw,{side:e,onStart:r,onDrag:i,onCommit:a,onEnd:o},e))}let Ww={widthControls:Uw};function Gw(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`:Iw(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:$.root,"data-phase":g,children:[a(`conversation.header`,{}),a(`conversation.header.notice`,{}),o(`conversation.content`,{variant:`main`,phase:g,hero:m},{slots:Ww})]})}function Kw(e){return/* @__PURE__ */ (0,h.jsx)(Gw,{...e})}function qw(e,t){return e===`default-workspace`?t:e}let Jw=`@deepseek-ai/dsh-client-ui-conversation/HeroShell.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(Jw)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-conversation`,e.dataset.pluginCss=Jw,e.textContent=`._93RU4a_root{justify-content:center;align-items:center;min-width:0;height:100%;padding:0 24px;display:flex}._93RU4a_stack{width:100%;max-width:var(--dsh-composer-card-max-width);flex-direction:column;align-items:stretch;gap:12px;display:flex;overflow:visible}._93RU4a_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}._93RU4a_titleGroup{flex-wrap:wrap;justify-content:center;align-items:center;gap:4px 7px;min-width:0;display:flex}._93RU4a_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}._93RU4a_fishHitbox{flex:none;justify-content:center;align-items:center;display:inline-flex}._93RU4a_fish{transform-origin:50% 60%;color:var(--dsw-alias-label-primary);display:block;overflow:visible}@keyframes _93RU4a_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){._93RU4a_fishHitbox:hover ._93RU4a_fish{animation:1.6s ease-in-out infinite _93RU4a_hero-fish-swim}}._93RU4a_body{flex-direction:column;gap:12px;min-width:0;display:flex;position:relative;overflow:visible}._93RU4a_body>*{z-index:1;position:relative}._93RU4a_body>._93RU4a_workspaceRow{z-index:10;align-items:center;min-width:0;padding-left:8px;display:flex}._93RU4a_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}._93RU4a_workspace:not(:disabled):hover,._93RU4a_workspace[aria-expanded=true]{background:var(--dsw-alias-interactive-bg-hover)}._93RU4a_workspace:disabled{cursor:default}._93RU4a_folder{color:var(--dsw-alias-label-primary);flex:none}._93RU4a_workspaceLabel{text-overflow:ellipsis;white-space:nowrap;min-width:0;overflow:hidden}._93RU4a_chevron{color:var(--dsw-alias-label-caption);flex:none}._93RU4a_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}._93RU4a_modalInput::placeholder{color:var(--dsw-alias-label-caption)}._93RU4a_modalInput:disabled{color:var(--dsw-alias-label-dimmed)}._93RU4a_modalAction{min-width:72px}._93RU4a_modalError{color:var(--dsw-alias-state-error-primary);margin-top:8px;font-size:12px;line-height:18px}`,document.head.appendChild(e)}var Yw={body:`_93RU4a_body`,chevron:`_93RU4a_chevron`,fish:`_93RU4a_fish`,fishHitbox:`_93RU4a_fishHitbox`,folder:`_93RU4a_folder`,headline:`_93RU4a_headline`,"hero-fish-swim":`_93RU4a_hero-fish-swim`,modalAction:`_93RU4a_modalAction`,modalError:`_93RU4a_modalError`,modalInput:`_93RU4a_modalInput`,previewBadge:`_93RU4a_previewBadge`,root:`_93RU4a_root`,stack:`_93RU4a_stack`,titleGroup:`_93RU4a_titleGroup`,workspace:`_93RU4a_workspace`,workspaceLabel:`_93RU4a_workspaceLabel`,workspaceRow:`_93RU4a_workspaceRow`};function Xw(e){let t=jc(e);return t===``?e:t}function Zw({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:Yw.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:Yw.folder,size:16}):/* @__PURE__ */ (0,h.jsx)(d.IconFolderOpenRegular,{className:Yw.folder,size:16}),/* @__PURE__ */ (0,h.jsx)(`span`,{className:Yw.workspaceLabel,children:t??a(`hero.chooseWorkspace`)}),/* @__PURE__ */ (0,h.jsx)(d.IconChevronDownOutlineRegular,{className:Yw.chevron,size:12})]})}function Qw({hovering:e}){return/* @__PURE__ */ (0,h.jsx)(`svg`,{className:Yw.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 $w({t:e,renderSlot:t,children:n}){let[r,i]=(0,g.useState)(!1);return/* @__PURE__ */ (0,h.jsxs)(`div`,{className:Yw.root,children:[/* @__PURE__ */ (0,h.jsxs)(`div`,{className:Yw.stack,children:[/* @__PURE__ */ (0,h.jsxs)(`div`,{className:Yw.headline,children:[/* @__PURE__ */ (0,h.jsx)(`span`,{className:Yw.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:Yw.fish},{fallback:/* @__PURE__ */ (0,h.jsx)(Qw,{hovering:r})})}),/* @__PURE__ */ (0,h.jsxs)(`span`,{className:Yw.titleGroup,children:[/* @__PURE__ */ (0,h.jsx)(`span`,{children:e(`hero.headline`)}),/* @__PURE__ */ (0,h.jsx)(`span`,{className:Yw.previewBadge,children:e(`hero.preview`)})]})]}),/* @__PURE__ */ (0,h.jsx)(`div`,{className:Yw.body})]}),n]})}let eT=`@deepseek-ai/dsh-client-ui-conversation/ThreadReferenceDropTarget.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(eT)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-conversation`,e.dataset.pluginCss=eT,e.textContent=`.DZV3nW_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}.DZV3nW_invitation{flex-direction:column;align-items:center;gap:8px;max-width:calc(100% - 40px);display:flex}.DZV3nW_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}.DZV3nW_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}.DZV3nW_preview svg{flex:none}.DZV3nW_title{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}`,document.head.appendChild(e)}var tT={hint:`DZV3nW_hint`,invitation:`DZV3nW_invitation`,overlay:`DZV3nW_overlay`,preview:`DZV3nW_preview`,title:`DZV3nW_title`};function nT({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:kb(Ob(e)),n=t===void 0?void 0:a.current[t];return n!==void 0&&Db(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:jb(t.getData(Eb));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(Ed,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=jb(a.getData(Eb));i()&&c(r)&&r?.threadId===n?.threadId&&r?.hostId===n?.hostId?t.dispatchCommand(wd,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:tT.overlay,"data-thread-reference-drop":!0,role:`status`,"aria-live":`polite`,children:/* @__PURE__ */ (0,h.jsxs)(`div`,{className:tT.invitation,children:[/* @__PURE__ */ (0,h.jsx)(`div`,{className:tT.hint,children:r(`reference.dropTitle`)}),/* @__PURE__ */ (0,h.jsxs)(`div`,{className:tT.preview,"data-thread-reference-preview":!0,children:[/* @__PURE__ */ (0,h.jsx)(d.ReferenceIconRegular,{kind:`session`,size:20}),/* @__PURE__ */ (0,h.jsx)(`span`,{className:tT.title,children:o.title})]})]})})}function rT({renderSlot:e}){return e(`conversation.session`,{})}function iT(){return null}function aT(e){let{sessionId:t,phase:n,hero:r,useSession:i,useSessions:a,useSessionStatus:o,useWorkspaces:s,useInput:c,useComposerBlock:l,renderSlot:u,renderSlotChain:d,selectWorkspace:f,referenceEditor:p,t:m,useFactorySlot:_}=e,v=i(e=>e),y=_(`views`,rT),ee=_(`widthControls`,iT),[b,x]=(0,g.useState)(null),te=o(e=>t===void 0?void 0:e.get(t)?.pendingInteraction),ne=c(e=>e),re=a(e=>t===void 0?void 0:e.byId[t]?.cwd),ie=s(e=>e),ae=l(e=>e),[oe,se]=(0,g.useState)(!1),[S,ce]=(0,g.useState)(),le=(0,g.useRef)(null),ue=(0,g.useRef)(null),de=(0,g.useCallback)(e=>{ue.current?.disconnect(),ue.current=null;let t=e?.parentElement??null;e!==null&&t!==null&&(ue.current=new ResizeObserver(()=>{t.style.setProperty(`--dsh-composer-height`,`${e.offsetHeight}px`),t.style.setProperty(`--dsh-conversation-viewport-height`,`${t.clientHeight}px`)}),ue.current.observe(e),ue.current.observe(t))},[]),fe=t===void 0?void 0:ie.items.find(e=>e.sessionIds.includes(t)),C=ie.items.find(e=>e.workspaceId===S);(0,g.useEffect)(()=>{S!==void 0&&((S===null?fe===void 0:fe?.workspaceId===S)||S!==null&&ie.phase===`ready`&&C===void 0)&&ce(void 0)},[S,fe?.workspaceId,ie.phase,C]);let w=v===void 0||ne===void 0?void 0:{session:v,input:ne},pe=(S===null?void 0:C?.title)??(S===null||t===void 0?void 0:fe?.title??(ie.phase===`ready`||re===void 0||re===``?void 0:Xw(re))),me=pe===void 0?void 0:qw(pe,m(`workspace.defaultName`)),he=/* @__PURE__ */ (0,h.jsxs)(`div`,{className:$.heroWorkspaceRow,children:[/* @__PURE__ */ (0,h.jsx)(Zw,{buttonRef:le,label:me??(ie.canStartProjectless?m(`hero.noWorkspace`):void 0),projectless:ie.canStartProjectless===!0&&me===void 0,menuOpen:oe,onClick:()=>{se(e=>!e)},t:m}),u(`conversation.hero.workspace`,{open:oe,anchorRef:le,selectedId:S===null?void 0:S??fe?.workspaceId,onPick:e=>{se(!1),ce(e),f(e).catch(()=>{ce(t=>t===e?void 0:t)})},onClose:()=>{se(!1)}}),u(`conversation.hero.agentPreset`,{})]}),ge=ie.phase===`ready`&&!ie.canStartProjectless&&me===void 0,_e=(t===void 0||v?.openState!==`open`)&&!ge,ve=t===void 0||v?.openState!==`open`||r&&ge,ye=u(`conversation.composer.bar`,{variant:r?`hero`:`composer`,...ve?{disabled:!0,placeholder:m(_e?`placeholder.preparing`:`placeholder.workspace`),..._e?{}:{workspacePickerOpen:oe,onRequestWorkspace:()=>{se(!0)}}}:!ve&&ae!==void 0?{blocked:ae,placeholder:ae.reason}:r?{placeholder:m(`placeholder.hero`)}:{}}),be=/* @__PURE__ */ (0,h.jsxs)(`div`,{className:Nb($.composerStack,r&&$.composerHero),children:[r&&/* @__PURE__ */ (0,h.jsx)($w,{t:m,renderSlot:u}),r&&he,w!==void 0&&u(`conversation.input.dock`,w),ye]}),xe=d(`conversation.composer`,{sessionId:t,session:v,pendingInteraction:v?.openState===`open`?te:void 0},{fallback:be,fallbackOnly:t===void 0,overlay:!0}),Se=/* @__PURE__ */ (0,h.jsx)(`div`,{ref:de,className:$.composerSeat,"data-composer-seat":``,"data-conversation-region":`composer`,children:xe});return/* @__PURE__ */ (0,h.jsxs)(`div`,{ref:x,className:Nb($.body,e.variant===`embedded`&&$.embeddedBody),"data-conversation-content":``,"data-conversation-session":t,"data-conversation-region":`chat`,"data-content-phase":n,children:[/* @__PURE__ */ (0,h.jsxs)(`div`,{className:$.scrollBody,"data-conversation-scroll":``,children:[t===void 0?null:/* @__PURE__ */ (0,h.jsx)(y,{}),Se]}),/* @__PURE__ */ (0,h.jsx)(ee,{container:b,phase:n}),/* @__PURE__ */ (0,h.jsx)(nT,{container:b,editor:p,useSessions:a,t:m},t)]})}function oT({renderSlot:e}){return e(`main.conversation`,{})}function sT(){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 cT({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&&Iw(i,a)===`blank`;return/* @__PURE__ */ (0,h.jsxs)(`header`,{className:Nb($.header,o&&$.headerBlank,e===void 0&&$.headerSessionless),"data-window-drag":!0,"data-conversation-navigation-focus":!0,tabIndex:-1,children:[/* @__PURE__ */ (0,h.jsx)(`div`,{className:$.headerLeading,"data-conversation-header-leading":``,children:r(`conversation.header.leading`,{})}),e===void 0?/* @__PURE__ */ (0,h.jsx)(`div`,{className:$.titleRow,children:r(`conversation.header.navigation`,{restoreNavigationFocus:sT})}):r(`conversation.session.header`,{hideChrome:o,titleNavigation:r(`conversation.header.navigation`,{restoreNavigationFocus:sT})}),r(`conversation.header.shortcuts`,{restoreNavigationFocus:sT})]})}function lT(e,t){return(t===null?void 0:e.find(e=>e.id===t))??e.find(e=>e.id===`chat`)}function uT({view:e,useSession:t,useConversation:n,useConversationViews:r,inputActions:i,useStore:a,actions:o,renderSlot:s,bindDraftPersistence:c,openView:l,useInspectCall:u}){let d=r(e=>e),f=u(e=>e),p=lT(d,a(e=>e.view)),m=t(e=>e),_=n(e=>e),v=a(e=>e.viewRequest??null);if((0,g.useEffect)(()=>{let e=c(o.setDraft);return i.persistDraft(),()=>{e()}},[i]),m.blank&&Iw(m,_)===`blank`)return null;let y=e??p?.id;return/* @__PURE__ */ (0,h.jsx)(`div`,{className:$.viewArea,children:y!==void 0&&s(`conversation.view`,{inspectCall:f,viewRequest:v,openView:l,completeViewRequest:o.completeViewRequest},{only:y})})}function dT(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 fT(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 pT({sessionId:e,hideChrome:t,titleNavigation:n,useSessions:r,useConversationViews:i,useStore:a,renderSlot:o,open:s,selectView:c,t:l}){let u=i(e=>e),d=lT(u,a(e=>e.view)),f=r(t=>dT(t,e),fT),p=!t&&u.length>1;return/* @__PURE__ */ (0,h.jsxs)(h.Fragment,{children:[/* @__PURE__ */ (0,h.jsxs)(`div`,{className:$.titleRow,children:[!t&&/* @__PURE__ */ (0,h.jsxs)(h.Fragment,{children:[/* @__PURE__ */ (0,h.jsxs)(`div`,{className:$.titleCluster,children:[/* @__PURE__ */ (0,h.jsxs)(`nav`,{className:$.crumbs,"aria-label":l(`session.hierarchy`),children:[f.map((e,t)=>{let n=t===f.length-1,r=n?/* @__PURE__ */ (0,h.jsx)(`span`,{className:Nb($.crumb,e.subagent&&$.crumbSubagent,$.crumbCurrent),children:e.displayTitle}):/* @__PURE__ */ (0,h.jsx)(`button`,{type:`button`,className:Nb($.crumb,e.subagent&&$.crumbSubagent),onClick:()=>{s(e.id)},children:e.displayTitle}),i=n||e.subagent,a={lineageSessionId:e.id,displayTitle:e.displayTitle,...n?{}:{openTitle:()=>{s(e.id)}}};return/* @__PURE__ */ (0,h.jsxs)(`span`,{className:$.crumbSeg,children:[t>0&&/* @__PURE__ */ (0,h.jsx)(`span`,{className:$.crumbSep,children:`/`}),i?e.subagent?o(`conversation.session.header.lineage`,a,{fallback:r}):/* @__PURE__ */ (0,h.jsxs)(h.Fragment,{children:[r,o(`conversation.session.header.lineage`,a,{fallback:null})]}):r]},e.id)}),f.length===0&&/* @__PURE__ */ (0,h.jsx)(`span`,{className:$.crumbCurrent,children:e})]}),n,/* @__PURE__ */ (0,h.jsx)(`div`,{className:$.headerActions,children:o(`conversation.session.header.actions`,{})})]}),/* @__PURE__ */ (0,h.jsx)(`div`,{className:$.headerUtilities,children:o(`conversation.session.header.utilities`,{})})]}),t&&n,/* @__PURE__ */ (0,h.jsx)(`div`,{className:$.headerCorner,"data-conversation-header-corner":``,children:o(`conversation.session.header.corner`,{})})]}),p&&/* @__PURE__ */ (0,h.jsx)(`div`,{className:$.tabs,role:`tablist`,"data-conversation-tabs":``,children:u.map(e=>/* @__PURE__ */ (0,h.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":e.id===d?.id,className:Nb($.tab,e.id===d?.id&&$.tabActive),onClick:()=>{c(e.id)},children:e.label},e.id))})]})}function mT(e){return/* @__PURE__ */ (0,h.jsx)(uT,{...e})}function hT({editor:e,editable:t,...n}){let r=(0,g.useRef)(null);return(0,g.useLayoutEffect)(()=>{let t=r.current;if(t!==null&&((0,d.shouldAutoFocusTextInput)()||(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:r,contentEditable:e!==null&&t,suppressContentEditableWarning:!0,role:`textbox`,"aria-multiline":`true`,"data-composer-input":!0,...n})}function gT({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 _T({classNames:e,editor:t,scrollRef:n,editable:r,editorDisabled:i,phase:a,placeholderText:o,ariaLabel:s,workspaceTrigger:c,workspacePickerOpen:l,onWorkspaceKeyDown:u,hint:d,showPlaceholder:f}){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)(hT,{editor:c?null:t,editable:r,className:Nb(e.input,i&&e.inputDisabled),"data-phase":a,"aria-disabled":i||void 0,"data-placeholder":o,"aria-label":s,"aria-haspopup":c?`menu`:void 0,"aria-expanded":c?l:void 0,tabIndex:c?0:void 0,onKeyDown:c?u:void 0,style:d===null?void 0:{"--dsh-composer-hint":JSON.stringify(d)}}),f&&/* @__PURE__ */ (0,h.jsx)(`div`,{"aria-hidden":!0,className:e.placeholder,"data-composer-placeholder":!0,children:o}),/* @__PURE__ */ (0,h.jsx)(gT,{editor:c?null:t})]})})}function vT(e,t){return e.isComposing||e.keyCode===229||t()}function yT(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&&vT(n,c);return t.arbitrate(e,r)!==`pass`&&(n?.preventDefault(),!0)};return kv(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(gd,l(`up`),4),e.registerCommand(_d,l(`down`),4),e.registerCommand(Cd,e=>l(e.shiftKey?`tabBack`:`tab`)(e),4),e.registerCommand(xd,e=>(t.dismissPopup(),t.arbitrate(`escape`,vT(e,c))===`consumed`&&(e.preventDefault(),!0)),4),e.registerCommand(yd,e=>vT(e,c)?!1:t.space()?(e.preventDefault(),!0):!1,4),e.registerCommand(vd,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&&vT(e,c)?!0:t.arbitrate(`enter`,!1)===`pass`?(e?.preventDefault(),e?.repeat===!0||!t.canSubmit()||t.submit(e?.ctrlKey===!0||e?.metaKey===!0),!0):(e?.preventDefault(),!0),4),e.registerCommand(id,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 bT(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 xT(e,t){e.getRootElement()?.focus({preventScroll:!0}),e.focus(()=>{t()})}function ST(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 CT(e,t,n){return e.bindFilePicker({available:()=>t.current.canAcceptDrop&&n.current!==null,open:()=>{n.current?.click()}})}function wT(e,t,n){return yT(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(yw(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.locked||t.paste(e)}})}function TT(e,t){e.preventDefault(),!(0,d.isMobileDevice)()&&t?.getRootElement()?.focus({preventScroll:!0})}function ET(e){let t=e/1048576;return`${Number.isInteger(t)?String(t):t.toFixed(1)}MB`}function DT(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:ET(n.maxImageBytes)});break;case`IMAGES_TOO_LARGE`:if(n!==void 0)return e(`image.totalTooLarge`,{size:ET(n.maxMessageImageBytes)})}return e(`image.sendFailed`,{reason:t})}function OT(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 kT=`@deepseek-ai/dsh-client-ui-conversation/ContextMeter.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(kT)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-conversation`,e.dataset.pluginCss=kT,e.textContent=`.LDRuKa_root{flex:none;display:inline-flex}.LDRuKa_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}.LDRuKa_trigger:hover,.LDRuKa_trigger[aria-expanded=true]{background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-label-secondary)}.LDRuKa_track{fill:none;stroke:var(--dsw-alias-border-l3);stroke-width:2px}.LDRuKa_fill{fill:none;stroke:var(--dsw-alias-label-tertiary);stroke-width:2px;stroke-linecap:round}.LDRuKa_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}.LDRuKa_header{align-items:center;gap:6px;display:flex}.LDRuKa_figures{font-variant-numeric:tabular-nums;color:var(--dsw-alias-label-primary);margin-left:auto;font-weight:500}.LDRuKa_percent{color:var(--dsw-alias-label-primary);font-weight:500}.LDRuKa_headline{color:var(--dsw-alias-label-tertiary)}.LDRuKa_headline:empty{display:none}.LDRuKa_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}.LDRuKa_segment{background:var(--meter-tint,var(--dsw-alias-label-tertiary));border-radius:1px;flex:none;min-width:2px;height:100%}.LDRuKa_swatch{background:var(--meter-tint);vertical-align:baseline;border-radius:2px;width:8px;height:8px;margin-right:6px;display:inline-block}.LDRuKa_colorSystem{--meter-tint:var(--dsw-static-neutral-bluish-400)}.LDRuKa_colorTools{--meter-tint:#a78bfa}.LDRuKa_colorMessages{--meter-tint:var(--dsw-static-blue-450)}.LDRuKa_rows{margin:6px 0 0}.LDRuKa_row{justify-content:space-between;align-items:center;gap:12px;padding:2px 0;display:flex}.LDRuKa_row dt{color:var(--dsw-alias-label-secondary)}.LDRuKa_row dd{font-variant-numeric:tabular-nums;color:var(--dsw-alias-label-primary);margin:0}`,document.head.appendChild(e)}var AT={bar:`LDRuKa_bar`,colorMessages:`LDRuKa_colorMessages`,colorSystem:`LDRuKa_colorSystem`,colorTools:`LDRuKa_colorTools`,figures:`LDRuKa_figures`,fill:`LDRuKa_fill`,header:`LDRuKa_header`,headline:`LDRuKa_headline`,panel:`LDRuKa_panel`,percent:`LDRuKa_percent`,root:`LDRuKa_root`,row:`LDRuKa_row`,rows:`LDRuKa_rows`,segment:`LDRuKa_segment`,swatch:`LDRuKa_swatch`,track:`LDRuKa_track`,trigger:`LDRuKa_trigger`};let jT=5.5,MT=2*Math.PI*jT,NT=[{key:`systemTokens`,label:`context.system`,color:AT.colorSystem},{key:`toolsTokens`,label:`context.tools`,color:AT.colorTools},{key:`messageTokens`,label:`context.messages`,color:AT.colorMessages}];function PT(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 FT({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=OT(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,ee=(r===void 0||y===0?[{key:`total`,color:void 0,width:f}]:NT.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:AT.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:AT.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:AT.track,cx:`7`,cy:`7`,r:jT}),/* @__PURE__ */ (0,h.jsx)(`circle`,{className:AT.fill,cx:`7`,cy:`7`,r:jT,strokeDasharray:`${MT*f/100} ${MT}`,transform:`rotate(-90 7 7)`})]}),/* @__PURE__ */ (0,h.jsx)(`span`,{children:p})]})}),i&&(0,_.createPortal)(/* @__PURE__ */ (0,h.jsxs)(`div`,{ref:s,className:AT.panel,style:u??{visibility:`hidden`,left:0,top:0},role:`dialog`,"aria-label":t(`context.used`),children:[/* @__PURE__ */ (0,h.jsxs)(`div`,{className:AT.header,children:[/* @__PURE__ */ (0,h.jsx)(`span`,{className:AT.headline,children:m}),/* @__PURE__ */ (0,h.jsx)(`span`,{className:AT.percent,children:p}),/* @__PURE__ */ (0,h.jsx)(`span`,{className:AT.headline,children:v}),/* @__PURE__ */ (0,h.jsx)(`span`,{className:AT.figures,children:`~${PT(c.usedTokens,t)} / ${PT(c.contextWindow,t)}`})]}),/* @__PURE__ */ (0,h.jsx)(`div`,{className:AT.bar,children:ee.map(e=>/* @__PURE__ */ (0,h.jsx)(`div`,{className:e.color===void 0?AT.segment:`${AT.segment} ${e.color}`,style:{width:`${e.width}%`}},e.key))}),r!==void 0&&/* @__PURE__ */ (0,h.jsx)(`dl`,{className:AT.rows,children:NT.map(e=>/* @__PURE__ */ (0,h.jsxs)(`div`,{className:AT.row,children:[/* @__PURE__ */ (0,h.jsxs)(`dt`,{children:[/* @__PURE__ */ (0,h.jsx)(`span`,{className:`${AT.swatch} ${e.color}`,"aria-hidden":!0}),t(e.label)]}),/* @__PURE__ */ (0,h.jsx)(`dd`,{children:`~${PT(r[e.key],t)}`})]},e.key))})]}),document.body)]})}function IT(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 LT=`@deepseek-ai/dsh-client-ui-conversation/InputBar.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(LT)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-conversation`,e.dataset.pluginCss=LT,e.textContent=`.b5Vi8W_root{padding:0 var(--dsh-composer-side-clearance) 4px;flex-direction:column;align-items:center;display:flex}[data-phone] .b5Vi8W_root{padding-bottom:max(4px, calc(env(safe-area-inset-bottom) - 23px))}.b5Vi8W_dock{justify-content:center;align-items:center;gap:12px;max-width:100%;padding-top:4px;display:flex}.b5Vi8W_hero .b5Vi8W_dock:empty{display:none}.b5Vi8W_hero{padding:0 var(--dsh-composer-side-clearance)}.b5Vi8W_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}.b5Vi8W_card{box-sizing:border-box;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] .b5Vi8W_card,[data-phone] .b5Vi8W_card{box-shadow:none;background:0 0}body[data-codexhost-wallpaper] .b5Vi8W_card:before,[data-phone] .b5Vi8W_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] .b5Vi8W_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] .b5Vi8W_card,[data-phone] .b5Vi8W_card{background:var(--dsw-specific-input-major);box-shadow:var(--dsw-elevation-soft)}body[data-codexhost-wallpaper] .b5Vi8W_card:before,[data-phone] .b5Vi8W_card:before{display:none}}@media (prefers-contrast:more),(forced-colors:active){[data-phone] .b5Vi8W_card:not(.b5Vi8W_cardWorkspaceTrigger){outline:1px solid var(--dsw-alias-label-primary);outline-offset:-1px}}.b5Vi8W_cardWorkspaceTrigger{--dsw-elevation-stroke-color:transparent;cursor:pointer}.b5Vi8W_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}.b5Vi8W_cardWorkspaceTrigger :disabled{pointer-events:none}.b5Vi8W_cardWorkspaceTrigger:hover:after{color:var(--dsw-alias-state-business-primary)}.b5Vi8W_inlineNotices{flex-direction:column;gap:8px;display:flex}.b5Vi8W_inlineNotices>[data-slot]>*{margin:10px 10px 0}.b5Vi8W_accessory{align-items:center;gap:8px;padding:10px 12px 0;display:flex}.b5Vi8W_overlayAnchor{height:0;position:absolute;inset:0 0 auto}.b5Vi8W_scroll{max-height:var(--dsh-composer-text-max-height);margin-right:4px;overflow-y:auto}.b5Vi8W_scroll::-webkit-scrollbar-track{margin-top:8px}.b5Vi8W_grow{position:relative}.b5Vi8W_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 b5Vi8W_input-pending}@keyframes b5Vi8W_input-pending{0%{opacity:.35}to{opacity:1}}.b5Vi8W_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}.b5Vi8W_input p{margin:0}.b5Vi8W_input p:last-child:after{content:var(--dsh-composer-hint);color:var(--dsw-alias-label-caption)}.b5Vi8W_input[data-composer-composing] p:last-child:after{content:none}.b5Vi8W_input[data-composer-composing]+.b5Vi8W_placeholder{visibility:hidden}.b5Vi8W_placeholder{color:var(--dsw-alias-label-caption);white-space:nowrap;text-overflow:ellipsis;pointer-events:none;user-select:none;position:absolute;inset:4px 8px auto 14px;overflow:hidden}.b5Vi8W_inputDisabled{color:var(--dsw-alias-label-tertiary);cursor:not-allowed}.b5Vi8W_input[aria-haspopup=menu]{cursor:pointer}.b5Vi8W_hero .b5Vi8W_input{min-height:52px}.b5Vi8W_hero .b5Vi8W_placeholder{white-space:normal;-webkit-line-clamp:2;line-clamp:2;-webkit-box-orient:vertical;display:-webkit-box}@media (width<=600px){.b5Vi8W_hero .b5Vi8W_input{min-height:36px}.b5Vi8W_hero .b5Vi8W_placeholder{white-space:nowrap;display:block}}.b5Vi8W_row{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}.b5Vi8W_row[data-model-compact]{--dsh-composer-model-text-display:none;--dsh-composer-model-icon-display:block}.b5Vi8W_tools,.b5Vi8W_modes,.b5Vi8W_trailing{align-items:center;min-width:0;display:flex}.b5Vi8W_tools,.b5Vi8W_modes{gap:12px}.b5Vi8W_trailing{flex:none;gap:12px;margin-left:auto}@container (width<=560px){.b5Vi8W_tools,.b5Vi8W_modes,.b5Vi8W_trailing{gap:8px}}.b5Vi8W_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}.b5Vi8W_add:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-hover-solid)}.b5Vi8W_add:disabled{opacity:.5;cursor:default}.b5Vi8W_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}.b5Vi8W_select:hover:not(:disabled){background-color:var(--dsw-alias-interactive-bg-hover)}.b5Vi8W_select:disabled{opacity:.5;cursor:default}.b5Vi8W_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)}.b5Vi8W_primary:hover:not(:disabled){background:var(--dsw-alias-button-info-hover)}.b5Vi8W_primary:disabled{opacity:.4;cursor:default}.b5Vi8W_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}.b5Vi8W_addSeat,.b5Vi8W_submitSeat,.b5Vi8W_controlScroll{display:contents}.b5Vi8W_row[data-phone-toolbar]{flex-wrap:nowrap;gap:4px;position:relative}.b5Vi8W_row[data-phone-toolbar] .b5Vi8W_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}.b5Vi8W_row[data-phone-toolbar] .b5Vi8W_controlScroll::-webkit-scrollbar{display:none}.b5Vi8W_row[data-phone-toolbar] .b5Vi8W_tools:not([hidden]),.b5Vi8W_row[data-phone-toolbar] .b5Vi8W_trailing:not(.b5Vi8W_trailingActive){display:contents}.b5Vi8W_row[data-phone-toolbar] .b5Vi8W_tools>*,.b5Vi8W_row[data-phone-toolbar] [data-slot="conversation.input.left"]>*{flex-shrink:0}.b5Vi8W_row[data-phone-toolbar] button:focus-visible{outline-offset:-2px}.b5Vi8W_row[data-phone-toolbar] .b5Vi8W_modes,.b5Vi8W_row[data-phone-toolbar] .b5Vi8W_standardControls{flex:none;gap:4px;width:max-content}.b5Vi8W_row[data-phone-toolbar] .b5Vi8W_standardControls{margin-left:0}.b5Vi8W_row[data-phone-toolbar] .b5Vi8W_addSeat,.b5Vi8W_row[data-phone-toolbar] .b5Vi8W_submitSeat{z-index:1;flex:none;align-items:center;gap:4px;display:flex;position:absolute;inset-block:2px 6px}.b5Vi8W_row[data-phone-toolbar] .b5Vi8W_addSeat{left:8px}.b5Vi8W_row[data-phone-toolbar] .b5Vi8W_submitSeat{margin-left:0;right:8px}.b5Vi8W_row[data-phone-toolbar] .b5Vi8W_add,.b5Vi8W_row[data-phone-toolbar] .b5Vi8W_primary{box-sizing:border-box;background-clip:padding-box;width:44px;height:44px}.b5Vi8W_row[data-phone-toolbar] .b5Vi8W_add{border:8px solid #0000}.b5Vi8W_row[data-phone-toolbar] .b5Vi8W_primary{border:7px solid #0000}.b5Vi8W_row[data-phone-toolbar][data-toolbar-activity] .b5Vi8W_controlScroll{display:contents}.b5Vi8W_row[data-phone-toolbar][data-toolbar-activity] .b5Vi8W_submitSeat{position:static}.b5Vi8W_row[data-actions-overflow] [data-composer-overflow-action]{display:none}.b5Vi8W_standardControls{align-items:center;gap:12px;min-width:0;display:flex}.b5Vi8W_tools[hidden],.b5Vi8W_standardControls[hidden]{display:none}.b5Vi8W_trailingActive{flex:1;margin-left:0}.b5Vi8W_activity{flex:none;align-items:center;display:flex}.b5Vi8W_activity:empty{display:none}.b5Vi8W_activityExpanded{flex:1;min-width:0}.b5Vi8W_annotations{scrollbar-width:none;align-items:center;gap:6px;padding:8px 12px 0;display:flex;overflow-x:auto}.b5Vi8W_annotations::-webkit-scrollbar{display:none}.b5Vi8W_annotations>*{flex:none}`,document.head.appendChild(e)}var RT={accessory:`b5Vi8W_accessory`,activity:`b5Vi8W_activity`,activityExpanded:`b5Vi8W_activityExpanded`,add:`b5Vi8W_add`,addSeat:`b5Vi8W_addSeat`,annotations:`b5Vi8W_annotations`,card:`b5Vi8W_card`,cardWorkspaceTrigger:`b5Vi8W_cardWorkspaceTrigger`,controlScroll:`b5Vi8W_controlScroll`,dock:`b5Vi8W_dock`,grow:`b5Vi8W_grow`,hero:`b5Vi8W_hero`,inlineNotices:`b5Vi8W_inlineNotices`,input:`b5Vi8W_input`,"input-pending":`b5Vi8W_input-pending`,inputDisabled:`b5Vi8W_inputDisabled`,modes:`b5Vi8W_modes`,notice:`b5Vi8W_notice`,overlayAnchor:`b5Vi8W_overlayAnchor`,pending:`b5Vi8W_pending`,placeholder:`b5Vi8W_placeholder`,primary:`b5Vi8W_primary`,retry:`b5Vi8W_retry`,root:`b5Vi8W_root`,row:`b5Vi8W_row`,scroll:`b5Vi8W_scroll`,select:`b5Vi8W_select`,standardControls:`b5Vi8W_standardControls`,submitSeat:`b5Vi8W_submitSeat`,tools:`b5Vi8W_tools`,trailing:`b5Vi8W_trailing`,trailingActive:`b5Vi8W_trailingActive`};let zT=[],BT=(0,g.memo)(function({useSession:e,useInput:t,inputActions:n,keyboard:r,addFiles:i,removeAttachment:a,resolveDraftAttachments:o,retryFileUpload:s,toggleCommandMenu:c,stop:l,t:u,renderSlot:f,useBusyEnter:p,useFileUploads:m,useNotices:_,useLexicon:v,useMenuLauncher:y,useStopShortcut:ee,useProjection:b,sessionId:x,variant:te,disabled:ne=!1,blocked:re,workspacePickerOpen:ie=!1,onRequestWorkspace:ae,placeholder:oe,accessory:se}){let S=t(e=>e),ce=S?.responseAnnotations??zT,le=(0,g.useMemo)(()=>({label:e=>u(`annotation.label`,{index:e}),railLabel:e=>u(`annotation.chipLabel`,{index:e}),railTitle:(e,t)=>u(`annotation.title`,{index:e,excerpt:t}),remove:e=>u(`annotation.remove`,{index:e}),selectedText:u(`annotation.selectedText`),userComment:u(`annotation.userComment`)}),[u]),ue=_(e=>e),de=p(e=>e),fe=ee(e=>e),C=y(e=>e===`command`),[w,pe]=(0,g.useState)(!1);(0,g.useEffect)(()=>{pe(!1)},[x]);let me=e(e=>e.promptError)??null,he=e(e=>e.running)??!1,ge=e(e=>e.subagent)??null,_e=e(e=>e.removed)??!1,ve=b(`plan`,e=>e!==void 0&&(e.pending?!e.active:e.active)),ye=b(`goal`,e=>e!=null),be=S!==void 0&&r!==void 0&&n!==void 0,xe=S?.draft??``,Se=S?.primaryAction,Ce=r?.editor??null,we=(0,g.useMemo)(()=>S===void 0||o===void 0?[]:o(S.attachmentIds),[o,S?.attachmentIds]),Te=xe.trim()===``&&we.length===0&&ce.length===0,Ee=m(e=>e),De=we.some(e=>Ee[e.id]?.status===`error`),[Oe,ke]=(0,g.useState)(null),Ae=(0,g.useRef)(0),je=(0,g.useCallback)(e=>{Ae.current+=1,ke({seq:Ae.current,text:e})},[]),Me=(0,g.useCallback)(()=>{ke(null)},[]),Ne=b(`imageLimits`),Pe=b(`attachmentInput`),Fe=Pe?.enabled!==!1,Ie=Pe?.imagesOnly===!0;(0,g.useEffect)(()=>{if(me===null)return;let{error:e}=me;e.code===`session/writer-held`?je(u(`error.sessionInUse`)):je(e.code===`session/attachment-invalid`||e.code===`subagent/attachment-invalid`?DT(u,e.details.reason,Ne):`${e.message} (${e.code})`)},[me,je,u,Ne]),(0,g.useEffect)(()=>{ue?.level===`error`&&je(ue.text)},[ue,je]);let Le=(0,g.useRef)(null),[Re,ze]=(0,g.useState)({phone:!1,overflowActions:!1});(0,g.useLayoutEffect)(()=>{let e=Le.current;if(e!==null)return IT(e,ze)},[]);let Be=(0,g.useRef)(null),Ve=(0,g.useRef)(null),He=ge?.address.mode===`continuable`,Ue=He&&ge.parentAvailable!==!0,We=_e||ne||!be||re!==void 0||Ue,Ge=We,Ke=_e||ne||!be,qe=S?.phase===`adjudicating`||S?.phase===`submitting`,Je=ne&&!_e&&ae!==void 0,Ye=_e||Ge&&!Je,Xe=be&&!Ge&&!qe,Ze=ge===null||ge.address.mode===`continuable`,Qe=!Ge&&!qe&&Te&&he&&Ze&&S.queue.length>0;(0,g.useEffect)(()=>{S!==void 0&&n!==void 0&&we.length!==S.attachmentIds.length&&n.pruneAttachments(we.map(e=>e.id))},[we,S?.attachmentIds,n]);let $e=()=>{bT(Ve)};(0,g.useEffect)(()=>{Ge||Ce===null||(0,d.shouldAutoFocusTextInput)()&&xT(Ce,$e)},[Ge,x,Ce]),(0,g.useEffect)(()=>{Ge||xe===``||$e()},[xe!==``]),(0,g.useEffect)(()=>ST(Ve),[]);let et=(0,g.useCallback)((e,t)=>{if(ge!==null||i===void 0||e.length===0)return;if(!Fe){je(u(`attachment.unavailable`));return}let n=(()=>{if(Ie&&e.some(e=>!(Ne?.mediaTypes)?.includes(e.type)))return u(`image.unsupportedType`);if(Ne!==void 0){let t=Ne.mediaTypes,n=e.filter(e=>t.includes(e.type)),r=we.filter(e=>e.kind===`image`);if(r.length+n.length>Ne.maxImagesPerMessage)return u(`image.tooMany`,{count:Ne.maxImagesPerMessage});if(n.some(e=>e.size>Ne.maxImageBytes))return u(`image.fileTooLarge`,{size:ET(Ne.maxImageBytes)});if(r.reduce((e,t)=>e+t.file.size,0)+n.reduce((e,t)=>e+t.size,0)>Ne.maxMessageImageBytes)return u(`image.totalTooLarge`,{size:ET(Ne.maxMessageImageBytes)})}return i(e,t)})();n!==null&&je(n)},[ge,i,Fe,Ie,we,Ne,je,u]),tt=Fe&&ge===null&&!Ge&&!qe&&i!==void 0,nt=u(Fe?Ie?`input.imagesAndCommands`:`input.commands`:`input.commandsOnly`),rt=(0,g.useRef)(null),it=e=>{let t=e.target.files===null?[]:[...e.target.files];e.target.value=``,t.length>0&&et(t)},at=(0,g.useRef)({locked:Ge,machineBusy:qe,primaryAction:Se,canSteerQueue:Qe,running:he,steeringAvailable:Ze,busyEnter:de,intakeFiles:et,uploadsFailed:De,showToast:je,t:u,canAcceptDrop:tt});at.current={locked:Ge,machineBusy:qe,primaryAction:Se,canSteerQueue:Qe,running:he,steeringAvailable:Ze,busyEnter:de,intakeFiles:et,uploadsFailed:De,showToast:je,t:u,canAcceptDrop:tt},(0,g.useEffect)(()=>{if(r!==void 0)return CT(r,at,rt)},[r]),(0,g.useEffect)(()=>{if(Ce!==null&&r!==void 0)return wT(Ce,r,at)},[Ce,r]);let ot=e=>{TT(e,Ce)},st=()=>{r!==void 0&&(Ce!==null&&(0,d.shouldAutoFocusTextInput)()&&xT(Ce,$e),c?.(r.caretSpan()))},ct=e=>{Je&&(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),ae())},lt=Se===void 0&&he&&ge===null&&(Te||re!==void 0),ut=lt?l===void 0:(Se===void 0?Te:Se.disabled)||We||qe,dt=he&&He,ft=yw(de,he,`enter`,Ze),pt=!Te&&S?.phase===`plain`&&!xe.trimStart().startsWith(`/`),mt=u(lt?`input.stop`:Se===void 0&&he&&Ze&&!We&&!De&&pt?ft===`steer`?`input.send.steer`:`input.send.queue`:`input.send`),ht=()=>{lt?l?.():De?je(u(`file.retryOrRemove`)):Se===void 0?r!==void 0&&!Te&&!We&&!qe&&r.submit(ft,`click`):ut||Se.run()},gt=(S?.phase===`claimed`||S?.phase===`submitting`)&&S.claim!==void 0&&xe.startsWith(S.claim.token),_t=gt&&S.claim.hint!==void 0&&xe.slice(S.claim.token.length).trim()===``?S.claim.hint:null,vt=(()=>{if(_t===null)return null;let e=S?.claim?.name??``,t=`hint.${e===`goal`&&ye?`goal.active`:e}`,n=u(t);return n===t?_t:n})(),yt=oe??u(Ue?`placeholder.parentOffline`:We?`placeholder.unavailable`:Qe?`placeholder.steerQueue`:ve?`placeholder.plan`:`placeholder.default`);return/* @__PURE__ */ (0,h.jsxs)(`div`,{className:Nb(RT.root,te===`hero`&&RT.hero),children:[Oe!==null&&/* @__PURE__ */ (0,h.jsx)(d.Toast,{text:Oe.text,icon:/* @__PURE__ */ (0,h.jsx)(d.IconWarningOutlineRegular,{}),anchor:Be.current,onDone:Me},Oe.seq),ue?.level===`info`&&/* @__PURE__ */ (0,h.jsx)(`div`,{className:RT.notice,role:`status`,children:ue.text}),/* @__PURE__ */ (0,h.jsxs)(`div`,{ref:Be,className:Nb(RT.card,Je&&RT.cardWorkspaceTrigger),"data-composer-card":!0,onClick:Je?ae:void 0,onPointerDown:Je?e=>{e.stopPropagation()}:void 0,children:[x!==void 0&&/* @__PURE__ */ (0,h.jsx)(`div`,{className:RT.overlayAnchor,children:f(`conversation.input.overlay`,{})}),se!==void 0&&/* @__PURE__ */ (0,h.jsx)(`div`,{className:RT.accessory,children:se}),ce.length===0?null:/* @__PURE__ */ (0,h.jsx)(`div`,{className:RT.annotations,"data-composer-annotations":!0,children:ce.map((e,t)=>/* @__PURE__ */ (0,h.jsx)(d.ResponseAnnotationChip,{index:t+1,annotation:e,labels:le,onRemove:()=>{n?.removeResponseAnnotation(e.id)}},e.id))}),S===void 0||x===void 0?null:/* @__PURE__ */ (0,h.jsx)(`div`,{className:RT.inlineNotices,children:f(`conversation.input.notice`,{})}),f(`conversation.input.attachments`,{attachments:we,canAcceptDrop:tt,onAddFiles:et,onRemoveAttachment:e=>{a?.(e)},uploads:Ee,onRetryFile:e=>{s?.(e)},dropLimits:Ne===void 0?void 0:{count:Ne.maxImagesPerMessage,size:ET(Ne.maxImageBytes)}}),/* @__PURE__ */ (0,h.jsx)(_T,{classNames:RT,editor:Ce,scrollRef:Ve,editable:Xe,editorDisabled:Ye,phase:S?.phase??`inert`,placeholderText:yt,ariaLabel:Je?u(`hero.chooseWorkspace`):yt,workspaceTrigger:Je,workspacePickerOpen:ie,onWorkspaceKeyDown:ct,hint:vt,showPlaceholder:xe===``&&we.length===0&&!gt}),/* @__PURE__ */ (0,h.jsx)(`div`,{ref:Le,className:RT.row,"data-composer-toolbar":!0,"data-command-menu-open":C||void 0,"data-toolbar-activity":w||void 0,children:/* @__PURE__ */ (0,h.jsxs)(`div`,{className:RT.controlScroll,"data-toolbar-scroll":!0,children:[/* @__PURE__ */ (0,h.jsxs)(`div`,{className:RT.tools,hidden:w,"data-composer-tools":!0,children:[/* @__PURE__ */ (0,h.jsx)(`div`,{className:RT.addSeat,"data-toolbar-fixed":`start`,children:/* @__PURE__ */ (0,h.jsx)(d.Tooltip,{portal:Re.phone,label:nt,side:`top`,delayMs:500,children:/* @__PURE__ */ (0,h.jsx)(`button`,{type:`button`,className:RT.add,"aria-label":nt,"aria-haspopup":`listbox`,"aria-expanded":C,disabled:Ge||qe||c===void 0,onMouseDown:ot,onClick:st,children:/* @__PURE__ */ (0,h.jsx)(d.IconPlusOutlineMedium,{size:14})})})}),/* @__PURE__ */ (0,h.jsx)(`input`,{ref:rt,type:`file`,accept:Ie?Ne?.mediaTypes.join(`,`):void 0,multiple:!0,disabled:!Fe||ge!==null,hidden:!0,onChange:it}),/* @__PURE__ */ (0,h.jsxs)(`div`,{className:RT.modes,children:[x===void 0?null:f(`conversation.input.permission`,{locked:Ge}),x===void 0?null:f(`conversation.input.plan`,{locked:Ge})]}),S===void 0||x===void 0?null:f(`conversation.input.left`,{})]}),/* @__PURE__ */ (0,h.jsxs)(`div`,{className:Nb(RT.trailing,w&&RT.trailingActive),children:[/* @__PURE__ */ (0,h.jsxs)(`div`,{className:RT.standardControls,hidden:w,children:[S===void 0||x===void 0?null:f(`conversation.input.right`,{overflowActions:Re.overflowActions}),x===void 0?null:f(`conversation.input.model`,{locked:Ke})]}),S===void 0||x===void 0?null:/* @__PURE__ */ (0,h.jsx)(`div`,{className:w?RT.activityExpanded:RT.activity,children:f(`conversation.input.activity`,{locked:Ge,onActiveChange:pe})}),/* @__PURE__ */ (0,h.jsxs)(`div`,{className:RT.submitSeat,"data-toolbar-fixed":`end`,children:[dt&&/* @__PURE__ */ (0,h.jsx)(d.Tooltip,{portal:Re.phone,label:u(`input.stop`),shortcutKeys:fe,side:`top`,delayMs:500,disabled:l===void 0,children:/* @__PURE__ */ (0,h.jsx)(`button`,{type:`button`,className:RT.primary,"aria-label":u(`input.stop`),disabled:l===void 0,onMouseDown:ot,onClick:l,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:Re.phone,label:lt?u(`input.stop`):mt,shortcutKeys:lt?fe:void 0,side:`top`,delayMs:500,disabled:ut,children:/* @__PURE__ */ (0,h.jsx)(`button`,{type:`button`,className:RT.primary,"aria-label":mt,disabled:ut,onMouseDown:ot,onClick:ht,children:lt?/* @__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:RT.dock,"data-composer-dock":!0,children:[te===`composer`&&S!==void 0&&x!==void 0?f(`conversation.composer.dock`,{}):null,w?null:/* @__PURE__ */ (0,h.jsx)(FT,{useProjection:b,t:u})]})]})}),VT=`@deepseek-ai/dsh-client-ui-conversation/TodoPanel.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(VT)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-conversation`,e.dataset.pluginCss=VT,e.textContent=`.Sdgm8W_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}.Sdgm8W_body{flex-direction:column;gap:8px;padding:6px 12px;display:flex}.Sdgm8W_header{text-align:left;cursor:pointer;background:0 0;border:none;align-items:center;gap:10px;width:100%;padding:0;display:flex}.Sdgm8W_lead{color:var(--dsw-alias-label-tertiary);flex:none;place-items:center;display:grid}.Sdgm8W_title{color:var(--dsw-alias-label-primary);flex:none;font-size:13px;font-weight:500;line-height:24px}.Sdgm8W_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}.Sdgm8W_chevron{color:var(--dsw-alias-label-tertiary);flex:none;place-items:center;display:grid}.Sdgm8W_list{flex-direction:column;gap:8px;max-height:180px;margin:0;padding:0;list-style:none;display:flex;overflow-y:auto}.Sdgm8W_item{min-width:0;color:var(--dsw-alias-label-secondary);align-items:center;gap:10px;font-size:13px;line-height:20px;display:flex}.Sdgm8W_glyph{flex:none;place-items:center;width:16px;height:16px;display:grid}.Sdgm8W_content{text-overflow:ellipsis;white-space:nowrap;min-width:0;overflow:hidden}`,document.head.appendChild(e)}var HT={body:`Sdgm8W_body`,chevron:`Sdgm8W_chevron`,content:`Sdgm8W_content`,glyph:`Sdgm8W_glyph`,header:`Sdgm8W_header`,item:`Sdgm8W_item`,lead:`Sdgm8W_lead`,list:`Sdgm8W_list`,progress:`Sdgm8W_progress`,root:`Sdgm8W_root`,title:`Sdgm8W_title`};
|
|
176
|
+
n!==null&&(e.ctrlKey||e.deltaY===0||n.scrollBy({top:lE(e,n)}))},[]);return/* @__PURE__ */ (0,h.jsx)(`div`,{className:$.widthHandle,"data-side":e.side,"data-width-handle":e.side,onPointerDown:l,onPointerMove:u,onPointerUp:d,onPointerCancel:f,onLostPointerCapture:f,onWheel:p})}function dE({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=sE();r===null?t.style.removeProperty(`--dsh-chat-user-width`):t.style.setProperty(`--dsh-chat-user-width`,`${cE(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:cE(e.offsetWidth,sE()),[e]),i=(0,g.useCallback)(t=>{e!==null&&(e.parentElement??e).style.setProperty(`--dsh-chat-user-width`,`${cE(e.offsetWidth,t)}px`)},[e]),a=(0,g.useCallback)(t=>{e!==null&&localStorage.setItem(oE,`${cE(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)(uE,{side:e,onStart:r,onDrag:i,onCommit:a,onEnd:o},e))}let fE={widthControls:dE};function pE(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`:iE(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:$.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:fE})]})}function mE(e){return/* @__PURE__ */ (0,h.jsx)(pE,{...e})}function hE(e,t){return e===`default-workspace`?t:e}let gE=`@deepseek-ai/dsh-client-ui-conversation/HeroShell.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(gE)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-conversation`,e.dataset.pluginCss=gE,e.textContent=`._93RU4a_root{justify-content:center;align-items:center;min-width:0;height:100%;padding:0 24px;display:flex}._93RU4a_stack{width:100%;max-width:var(--dsh-composer-card-max-width);flex-direction:column;align-items:stretch;gap:12px;display:flex;overflow:visible}._93RU4a_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}._93RU4a_titleGroup{flex-wrap:wrap;justify-content:center;align-items:center;gap:4px 7px;min-width:0;display:flex}._93RU4a_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}._93RU4a_fishHitbox{flex:none;justify-content:center;align-items:center;display:inline-flex}._93RU4a_fish{transform-origin:50% 60%;color:var(--dsw-alias-label-primary);display:block;overflow:visible}@keyframes _93RU4a_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){._93RU4a_fishHitbox:hover ._93RU4a_fish{animation:1.6s ease-in-out infinite _93RU4a_hero-fish-swim}}._93RU4a_body{flex-direction:column;gap:12px;min-width:0;display:flex;position:relative;overflow:visible}._93RU4a_body>*{z-index:1;position:relative}._93RU4a_body>._93RU4a_workspaceRow{z-index:10;align-items:center;min-width:0;padding-left:8px;display:flex}._93RU4a_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}._93RU4a_workspace:not(:disabled):hover,._93RU4a_workspace[aria-expanded=true]{background:var(--dsw-alias-interactive-bg-hover)}._93RU4a_workspace:disabled{cursor:default}._93RU4a_folder{color:var(--dsw-alias-label-primary);flex:none}._93RU4a_workspaceLabel{text-overflow:ellipsis;white-space:nowrap;min-width:0;overflow:hidden}._93RU4a_chevron{color:var(--dsw-alias-label-caption);flex:none}._93RU4a_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}._93RU4a_modalInput::placeholder{color:var(--dsw-alias-label-caption)}._93RU4a_modalInput:disabled{color:var(--dsw-alias-label-dimmed)}._93RU4a_modalAction{min-width:72px}._93RU4a_modalError{color:var(--dsw-alias-state-error-primary);margin-top:8px;font-size:12px;line-height:18px}`,document.head.appendChild(e)}var _E={body:`_93RU4a_body`,chevron:`_93RU4a_chevron`,fish:`_93RU4a_fish`,fishHitbox:`_93RU4a_fishHitbox`,folder:`_93RU4a_folder`,headline:`_93RU4a_headline`,"hero-fish-swim":`_93RU4a_hero-fish-swim`,modalAction:`_93RU4a_modalAction`,modalError:`_93RU4a_modalError`,modalInput:`_93RU4a_modalInput`,previewBadge:`_93RU4a_previewBadge`,root:`_93RU4a_root`,stack:`_93RU4a_stack`,titleGroup:`_93RU4a_titleGroup`,workspace:`_93RU4a_workspace`,workspaceLabel:`_93RU4a_workspaceLabel`,workspaceRow:`_93RU4a_workspaceRow`};function vE(e){let t=Pc(e);return t===``?e:t}function yE({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:_E.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:_E.folder,size:16}):/* @__PURE__ */ (0,h.jsx)(d.IconFolderOpenRegular,{className:_E.folder,size:16}),/* @__PURE__ */ (0,h.jsx)(`span`,{className:_E.workspaceLabel,children:t??a(`hero.chooseWorkspace`)}),/* @__PURE__ */ (0,h.jsx)(d.IconChevronDownOutlineRegular,{className:_E.chevron,size:12})]})}function bE({hovering:e}){return/* @__PURE__ */ (0,h.jsx)(`svg`,{className:_E.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 xE({t:e,renderSlot:t,children:n}){let[r,i]=(0,g.useState)(!1);return/* @__PURE__ */ (0,h.jsxs)(`div`,{className:_E.root,children:[/* @__PURE__ */ (0,h.jsxs)(`div`,{className:_E.stack,children:[/* @__PURE__ */ (0,h.jsxs)(`div`,{className:_E.headline,children:[/* @__PURE__ */ (0,h.jsx)(`span`,{className:_E.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:_E.fish},{fallback:/* @__PURE__ */ (0,h.jsx)(bE,{hovering:r})})}),/* @__PURE__ */ (0,h.jsxs)(`span`,{className:_E.titleGroup,children:[/* @__PURE__ */ (0,h.jsx)(`span`,{children:e(`hero.headline`)}),/* @__PURE__ */ (0,h.jsx)(`span`,{className:_E.previewBadge,children:e(`hero.preview`)})]})]}),/* @__PURE__ */ (0,h.jsx)(`div`,{className:_E.body})]}),n]})}let SE=`@deepseek-ai/dsh-client-ui-conversation/ThreadReferenceDropTarget.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(SE)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-conversation`,e.dataset.pluginCss=SE,e.textContent=`.DZV3nW_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}.DZV3nW_invitation{flex-direction:column;align-items:center;gap:8px;max-width:calc(100% - 40px);display:flex}.DZV3nW_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}.DZV3nW_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}.DZV3nW_preview svg{flex:none}.DZV3nW_title{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}`,document.head.appendChild(e)}var CE={hint:`DZV3nW_hint`,invitation:`DZV3nW_invitation`,overlay:`DZV3nW_overlay`,preview:`DZV3nW_preview`,title:`DZV3nW_title`};function wE({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:Mb(jb(e)),n=t===void 0?void 0:a.current[t];return n!==void 0&&Ab(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:Pb(t.getData(kb));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(kd,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=Pb(a.getData(kb));i()&&c(r)&&r?.threadId===n?.threadId&&r?.hostId===n?.hostId?t.dispatchCommand(Dd,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:CE.overlay,"data-thread-reference-drop":!0,role:`status`,"aria-live":`polite`,children:/* @__PURE__ */ (0,h.jsxs)(`div`,{className:CE.invitation,children:[/* @__PURE__ */ (0,h.jsx)(`div`,{className:CE.hint,children:r(`reference.dropTitle`)}),/* @__PURE__ */ (0,h.jsxs)(`div`,{className:CE.preview,"data-thread-reference-preview":!0,children:[/* @__PURE__ */ (0,h.jsx)(d.ReferenceIconRegular,{kind:`session`,size:20}),/* @__PURE__ */ (0,h.jsx)(`span`,{className:CE.title,children:o.title})]})]})})}function TE({renderSlot:e}){return e(`conversation.session`,{})}function EE(){return null}function DE(e){let{sessionId:t,phase:n,hero:r,useSession:i,useSessions:a,useSessionStatus:o,useWorkspaces:s,useInput:c,useComposerBlock:l,renderSlot:u,renderSlotChain:d,selectWorkspace:f,referenceEditor:p,t:m,useFactorySlot:_}=e,v=i(e=>e),y=_(`views`,TE),ee=_(`widthControls`,EE),[b,te]=(0,g.useState)(null),x=o(e=>t===void 0?void 0:e.get(t)?.pendingInteraction),ne=c(e=>e),re=a(e=>t===void 0?void 0:e.byId[t]?.cwd),ie=s(e=>e),ae=l(e=>e),[oe,se]=(0,g.useState)(!1),[ce,S]=(0,g.useState)(),le=(0,g.useRef)(null),ue=(0,g.useRef)(null),de=(0,g.useCallback)(e=>{ue.current?.disconnect(),ue.current=null;let t=e?.parentElement??null;e!==null&&t!==null&&(ue.current=new ResizeObserver(()=>{t.style.setProperty(`--dsh-composer-height`,`${e.offsetHeight}px`),t.style.setProperty(`--dsh-conversation-viewport-height`,`${t.clientHeight}px`)}),ue.current.observe(e),ue.current.observe(t))},[]),fe=t===void 0?void 0:ie.items.find(e=>e.sessionIds.includes(t)),C=ie.items.find(e=>e.workspaceId===ce);(0,g.useEffect)(()=>{ce!==void 0&&((ce===null?fe===void 0:fe?.workspaceId===ce)||ce!==null&&ie.phase===`ready`&&C===void 0)&&S(void 0)},[ce,fe?.workspaceId,ie.phase,C]);let w=v===void 0||ne===void 0?void 0:{session:v,input:ne},pe=(ce===null?void 0:C?.title)??(ce===null||t===void 0?void 0:fe?.title??(ie.phase===`ready`||re===void 0||re===``?void 0:vE(re))),me=pe===void 0?void 0:hE(pe,m(`workspace.defaultName`)),he=/* @__PURE__ */ (0,h.jsxs)(`div`,{className:$.heroWorkspaceRow,children:[/* @__PURE__ */ (0,h.jsx)(yE,{buttonRef:le,label:me??(ie.canStartProjectless?m(`hero.noWorkspace`):void 0),projectless:ie.canStartProjectless===!0&&me===void 0,menuOpen:oe,onClick:()=>{se(e=>!e)},t:m}),u(`conversation.hero.workspace`,{open:oe,anchorRef:le,selectedId:ce===null?void 0:ce??fe?.workspaceId,onPick:e=>{se(!1),S(e),f(e).catch(()=>{S(t=>t===e?void 0:t)})},onClose:()=>{se(!1)}}),u(`conversation.hero.agentPreset`,{})]}),ge=ie.phase===`ready`&&!ie.canStartProjectless&&me===void 0,_e=(t===void 0||v?.openState!==`open`)&&!ge,ve=t===void 0||v?.openState!==`open`||r&&ge,ye=u(`conversation.composer.bar`,{variant:r?`hero`:`composer`,...ve?{disabled:!0,placeholder:m(_e?`placeholder.preparing`:`placeholder.workspace`),..._e?{}:{workspacePickerOpen:oe,onRequestWorkspace:()=>{se(!0)}}}:!ve&&ae!==void 0?{blocked:ae,placeholder:ae.reason}:r?{placeholder:m(`placeholder.hero`)}:{}}),be=/* @__PURE__ */ (0,h.jsxs)(`div`,{className:Ib($.composerStack,r&&$.composerHero),children:[r&&/* @__PURE__ */ (0,h.jsx)(xE,{t:m,renderSlot:u}),r&&he,w!==void 0&&u(`conversation.input.dock`,w),ye]}),xe=d(`conversation.composer`,{sessionId:t,session:v,pendingInteraction:v?.openState===`open`?x:void 0},{fallback:be,fallbackOnly:t===void 0,overlay:!0}),Se=/* @__PURE__ */ (0,h.jsx)(`div`,{ref:de,className:$.composerSeat,"data-composer-seat":``,"data-conversation-region":`composer`,children:xe});return/* @__PURE__ */ (0,h.jsxs)(`div`,{ref:te,className:Ib($.body,e.variant===`embedded`&&$.embeddedBody),"data-conversation-content":``,"data-conversation-session":t,"data-conversation-region":`chat`,"data-content-phase":n,children:[/* @__PURE__ */ (0,h.jsxs)(`div`,{className:$.scrollBody,"data-conversation-scroll":``,children:[t===void 0?null:/* @__PURE__ */ (0,h.jsx)(y,{}),Se]}),/* @__PURE__ */ (0,h.jsx)(ee,{container:b,phase:n}),/* @__PURE__ */ (0,h.jsx)(wE,{container:b,editor:p,useSessions:a,t:m},t)]})}function OE({renderSlot:e}){return e(`main.conversation`,{})}function kE(){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 AE({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&&iE(i,a)===`blank`;return/* @__PURE__ */ (0,h.jsxs)(`header`,{className:Ib($.header,o&&$.headerBlank,e===void 0&&$.headerSessionless),"data-window-drag":!0,"data-conversation-navigation-focus":!0,"data-cx-region":`topbar`,tabIndex:-1,children:[/* @__PURE__ */ (0,h.jsx)(`div`,{className:$.headerLeading,"data-conversation-header-leading":``,children:r(`conversation.header.leading`,{})}),e===void 0?/* @__PURE__ */ (0,h.jsxs)(`div`,{className:$.titleRow,children:[r(`conversation.header.navigation`,{restoreNavigationFocus:kE}),/* @__PURE__ */ (0,h.jsx)(`div`,{className:$.headerCorner,"data-conversation-header-corner":``,children:/* @__PURE__ */ (0,h.jsx)(`span`,{className:$.phoneTrailingAction,children:r(`conversation.header.trailing`,{})})})]}):r(`conversation.session.header`,{hideChrome:o,titleNavigation:r(`conversation.header.navigation`,{restoreNavigationFocus:kE}),trailingAction:r(`conversation.header.trailing`,{})}),r(`conversation.header.shortcuts`,{restoreNavigationFocus:kE})]})}function jE(e,t){return(t===null?void 0:e.find(e=>e.id===t))??e.find(e=>e.id===`chat`)}function ME({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=jE(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&&iE(_,v)===`blank`)return null;let ee=e??m?.id;return/* @__PURE__ */ (0,h.jsx)(`div`,{className:$.viewArea,children:ee!==void 0&&s(`conversation.view`,{inspectCall:p,viewRequest:y,openView:u,completeViewRequest:o.completeViewRequest},{only:ee})})}function NE(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 PE(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 FE({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=jE(d,o(e=>e.view)),p=i(t=>NE(t,e),PE),m=!t&&d.length>1;return/* @__PURE__ */ (0,h.jsxs)(h.Fragment,{children:[/* @__PURE__ */ (0,h.jsxs)(`div`,{className:$.titleRow,children:[!t&&/* @__PURE__ */ (0,h.jsxs)(h.Fragment,{children:[/* @__PURE__ */ (0,h.jsxs)(`div`,{className:$.titleCluster,children:[/* @__PURE__ */ (0,h.jsxs)(`div`,{className:$.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:$.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:Ib($.crumb,e.subagent&&$.crumbSubagent,$.crumbCurrent),children:e.displayTitle}):/* @__PURE__ */ (0,h.jsx)(`button`,{type:`button`,className:Ib($.crumb,e.subagent&&$.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:$.crumbSeg,children:[t>0&&/* @__PURE__ */ (0,h.jsx)(`span`,{className:$.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:$.crumbCurrent,children:e})]}),n]}),/* @__PURE__ */ (0,h.jsx)(`div`,{className:$.headerActions,children:s(`conversation.session.header.actions`,{})})]}),/* @__PURE__ */ (0,h.jsx)(`div`,{className:$.headerUtilities,children:s(`conversation.session.header.utilities`,{})})]}),t&&/* @__PURE__ */ (0,h.jsx)(`div`,{className:$.titleCenter,children:n}),/* @__PURE__ */ (0,h.jsxs)(`div`,{className:$.headerCorner,"data-conversation-header-corner":``,children:[/* @__PURE__ */ (0,h.jsx)(`span`,{className:$.phoneTrailingAction,children:r}),s(`conversation.session.header.corner`,{})]})]}),m&&/* @__PURE__ */ (0,h.jsx)(`div`,{className:$.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:Ib($.tab,e.id===f?.id&&$.tabActive),onClick:()=>{l(e.id)},children:e.label},e.id))})]})}function IE(e){return/* @__PURE__ */ (0,h.jsx)(ME,{...e})}function LE({editor:e,editable:t,...n}){let r=(0,g.useRef)(null);return(0,g.useLayoutEffect)(()=>{let t=r.current;if(t!==null&&((0,d.shouldAutoFocusTextInput)()||(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:r,contentEditable:e!==null&&t,suppressContentEditableWarning:!0,role:`textbox`,"aria-multiline":`true`,"data-composer-input":!0,...n})}function RE({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 zE({classNames:e,editor:t,scrollRef:n,editable:r,editorDisabled:i,phase:a,placeholderText:o,ariaLabel:s,workspaceTrigger:c,workspacePickerOpen:l,onWorkspaceKeyDown:u,hint:d,showPlaceholder:f}){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)(LE,{editor:c?null:t,editable:r,className:Ib(e.input,i&&e.inputDisabled),"data-phase":a,"aria-disabled":i||void 0,"data-placeholder":o,"aria-label":s,"aria-haspopup":c?`menu`:void 0,"aria-expanded":c?l:void 0,tabIndex:c?0:void 0,onKeyDown:c?u:void 0,style:d===null?void 0:{"--dsh-composer-hint":JSON.stringify(d)}}),f&&/* @__PURE__ */ (0,h.jsx)(`div`,{"aria-hidden":!0,className:e.placeholder,"data-composer-placeholder":!0,children:o}),/* @__PURE__ */ (0,h.jsx)(RE,{editor:c?null:t})]})})}function BE(e,t){return e.isComposing||e.keyCode===229||t()}function VE(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&&BE(n,c);return t.arbitrate(e,r)!==`pass`&&(n?.preventDefault(),!0)};return Mv(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(yd,l(`up`),4),e.registerCommand(bd,l(`down`),4),e.registerCommand(Ed,e=>l(e.shiftKey?`tabBack`:`tab`)(e),4),e.registerCommand(wd,e=>(t.dismissPopup(),t.arbitrate(`escape`,BE(e,c))===`consumed`&&(e.preventDefault(),!0)),4),e.registerCommand(Sd,e=>BE(e,c)?!1:t.space()?(e.preventDefault(),!0):!1,4),e.registerCommand(xd,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&&BE(e,c)?!0:t.arbitrate(`enter`,!1)===`pass`?(e?.preventDefault(),e?.repeat===!0||!t.canSubmit()||t.submit(e?.ctrlKey===!0||e?.metaKey===!0),!0):(e?.preventDefault(),!0),4),e.registerCommand(sd,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 HE(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 UE(e,t){e.getRootElement()?.focus({preventScroll:!0}),e.focus(()=>{t()})}function WE(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 GE(e,t,n){return e.bindFilePicker({available:()=>t.current.canAcceptDrop&&n.current!==null,open:()=>{n.current?.click()}})}function KE(e,t,n){return VE(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(VT(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.locked||t.paste(e)}})}function qE(e,t){e.preventDefault(),!(0,d.isMobileDevice)()&&t?.getRootElement()?.focus({preventScroll:!0})}function JE(e){let t=e/1048576;return`${Number.isInteger(t)?String(t):t.toFixed(1)}MB`}function YE(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:JE(n.maxImageBytes)});break;case`IMAGES_TOO_LARGE`:if(n!==void 0)return e(`image.totalTooLarge`,{size:JE(n.maxMessageImageBytes)})}return e(`image.sendFailed`,{reason:t})}function XE(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 ZE=`@deepseek-ai/dsh-client-ui-conversation/ContextMeter.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(ZE)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-conversation`,e.dataset.pluginCss=ZE,e.textContent=`.LDRuKa_root{flex:none;display:inline-flex}.LDRuKa_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}.LDRuKa_trigger:hover,.LDRuKa_trigger[aria-expanded=true]{background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-label-secondary)}.LDRuKa_track{fill:none;stroke:var(--dsw-alias-border-l3);stroke-width:2px}.LDRuKa_fill{fill:none;stroke:var(--dsw-alias-label-tertiary);stroke-width:2px;stroke-linecap:round}.LDRuKa_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}.LDRuKa_header{align-items:center;gap:6px;display:flex}.LDRuKa_figures{font-variant-numeric:tabular-nums;color:var(--dsw-alias-label-primary);margin-left:auto;font-weight:500}.LDRuKa_percent{color:var(--dsw-alias-label-primary);font-weight:500}.LDRuKa_headline{color:var(--dsw-alias-label-tertiary)}.LDRuKa_headline:empty{display:none}.LDRuKa_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}.LDRuKa_segment{background:var(--meter-tint,var(--dsw-alias-label-tertiary));border-radius:1px;flex:none;min-width:2px;height:100%}.LDRuKa_swatch{background:var(--meter-tint);vertical-align:baseline;border-radius:2px;width:8px;height:8px;margin-right:6px;display:inline-block}.LDRuKa_colorSystem{--meter-tint:var(--dsw-static-neutral-bluish-400)}.LDRuKa_colorTools{--meter-tint:#a78bfa}.LDRuKa_colorMessages{--meter-tint:var(--dsw-static-blue-450)}.LDRuKa_rows{margin:6px 0 0}.LDRuKa_row{justify-content:space-between;align-items:center;gap:12px;padding:2px 0;display:flex}.LDRuKa_row dt{color:var(--dsw-alias-label-secondary)}.LDRuKa_row dd{font-variant-numeric:tabular-nums;color:var(--dsw-alias-label-primary);margin:0}`,document.head.appendChild(e)}var QE={bar:`LDRuKa_bar`,colorMessages:`LDRuKa_colorMessages`,colorSystem:`LDRuKa_colorSystem`,colorTools:`LDRuKa_colorTools`,figures:`LDRuKa_figures`,fill:`LDRuKa_fill`,header:`LDRuKa_header`,headline:`LDRuKa_headline`,panel:`LDRuKa_panel`,percent:`LDRuKa_percent`,root:`LDRuKa_root`,row:`LDRuKa_row`,rows:`LDRuKa_rows`,segment:`LDRuKa_segment`,swatch:`LDRuKa_swatch`,track:`LDRuKa_track`,trigger:`LDRuKa_trigger`};let $E=5.5,eD=2*Math.PI*$E,tD=[{key:`systemTokens`,label:`context.system`,color:QE.colorSystem},{key:`toolsTokens`,label:`context.tools`,color:QE.colorTools},{key:`messageTokens`,label:`context.messages`,color:QE.colorMessages}];function nD(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 rD({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=XE(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,ee=(r===void 0||y===0?[{key:`total`,color:void 0,width:f}]:tD.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:QE.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:QE.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:QE.track,cx:`7`,cy:`7`,r:$E}),/* @__PURE__ */ (0,h.jsx)(`circle`,{className:QE.fill,cx:`7`,cy:`7`,r:$E,strokeDasharray:`${eD*f/100} ${eD}`,transform:`rotate(-90 7 7)`})]}),/* @__PURE__ */ (0,h.jsx)(`span`,{children:p})]})}),i&&(0,_.createPortal)(/* @__PURE__ */ (0,h.jsxs)(`div`,{ref:s,className:QE.panel,style:u??{visibility:`hidden`,left:0,top:0},role:`dialog`,"aria-label":t(`context.used`),children:[/* @__PURE__ */ (0,h.jsxs)(`div`,{className:QE.header,children:[/* @__PURE__ */ (0,h.jsx)(`span`,{className:QE.headline,children:m}),/* @__PURE__ */ (0,h.jsx)(`span`,{className:QE.percent,children:p}),/* @__PURE__ */ (0,h.jsx)(`span`,{className:QE.headline,children:v}),/* @__PURE__ */ (0,h.jsx)(`span`,{className:QE.figures,children:`~${nD(c.usedTokens,t)} / ${nD(c.contextWindow,t)}`})]}),/* @__PURE__ */ (0,h.jsx)(`div`,{className:QE.bar,children:ee.map(e=>/* @__PURE__ */ (0,h.jsx)(`div`,{className:e.color===void 0?QE.segment:`${QE.segment} ${e.color}`,style:{width:`${e.width}%`}},e.key))}),r!==void 0&&/* @__PURE__ */ (0,h.jsx)(`dl`,{className:QE.rows,children:tD.map(e=>/* @__PURE__ */ (0,h.jsxs)(`div`,{className:QE.row,children:[/* @__PURE__ */ (0,h.jsxs)(`dt`,{children:[/* @__PURE__ */ (0,h.jsx)(`span`,{className:`${QE.swatch} ${e.color}`,"aria-hidden":!0}),t(e.label)]}),/* @__PURE__ */ (0,h.jsx)(`dd`,{children:`~${nD(r[e.key],t)}`})]},e.key))})]}),document.body)]})}function iD(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 aD=`@deepseek-ai/dsh-client-ui-conversation/InputBar.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(aD)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-conversation`,e.dataset.pluginCss=aD,e.textContent=`.b5Vi8W_root{padding:0 var(--dsh-composer-side-clearance) 4px;flex-direction:column;align-items:center;display:flex}[data-phone] .b5Vi8W_root{padding-bottom:max(4px, calc(env(safe-area-inset-bottom) - 23px))}.b5Vi8W_dock{justify-content:center;align-items:center;gap:12px;max-width:100%;padding-top:4px;display:flex}.b5Vi8W_hero .b5Vi8W_dock:empty{display:none}.b5Vi8W_hero{padding:0 var(--dsh-composer-side-clearance)}.b5Vi8W_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}.b5Vi8W_card{box-sizing:border-box;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] .b5Vi8W_card,[data-phone] .b5Vi8W_card{box-shadow:none;background:0 0}body[data-codexhost-wallpaper] .b5Vi8W_card:before,[data-phone] .b5Vi8W_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] .b5Vi8W_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] .b5Vi8W_card,[data-phone] .b5Vi8W_card{background:var(--dsw-specific-input-major);box-shadow:var(--dsw-elevation-soft)}body[data-codexhost-wallpaper] .b5Vi8W_card:before,[data-phone] .b5Vi8W_card:before{display:none}}@media (prefers-contrast:more),(forced-colors:active){[data-phone] .b5Vi8W_card:not(.b5Vi8W_cardWorkspaceTrigger){outline:1px solid var(--dsw-alias-label-primary);outline-offset:-1px}}.b5Vi8W_cardWorkspaceTrigger{--dsw-elevation-stroke-color:transparent;cursor:pointer}.b5Vi8W_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}.b5Vi8W_cardWorkspaceTrigger :disabled{pointer-events:none}.b5Vi8W_cardWorkspaceTrigger:hover:after{color:var(--dsw-alias-state-business-primary)}.b5Vi8W_inlineNotices{flex-direction:column;gap:8px;display:flex}.b5Vi8W_inlineNotices>[data-slot]>*{margin:10px 10px 0}.b5Vi8W_accessory{align-items:center;gap:8px;padding:10px 12px 0;display:flex}.b5Vi8W_overlayAnchor{height:0;position:absolute;inset:0 0 auto}.b5Vi8W_scroll{max-height:var(--dsh-composer-text-max-height);margin-right:4px;overflow-y:auto}.b5Vi8W_scroll::-webkit-scrollbar-track{margin-top:8px}.b5Vi8W_grow{position:relative}.b5Vi8W_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 b5Vi8W_input-pending}@keyframes b5Vi8W_input-pending{0%{opacity:.35}to{opacity:1}}.b5Vi8W_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}.b5Vi8W_input p{margin:0}.b5Vi8W_input p:last-child:after{content:var(--dsh-composer-hint);color:var(--dsw-alias-label-caption)}.b5Vi8W_input[data-composer-composing] p:last-child:after{content:none}.b5Vi8W_input[data-composer-composing]+.b5Vi8W_placeholder{visibility:hidden}.b5Vi8W_placeholder{color:var(--dsw-alias-label-caption);white-space:nowrap;text-overflow:ellipsis;pointer-events:none;user-select:none;position:absolute;inset:4px 8px auto 14px;overflow:hidden}.b5Vi8W_inputDisabled{color:var(--dsw-alias-label-tertiary);cursor:not-allowed}.b5Vi8W_input[aria-haspopup=menu]{cursor:pointer}.b5Vi8W_hero .b5Vi8W_input{min-height:52px}.b5Vi8W_hero .b5Vi8W_placeholder{white-space:normal;-webkit-line-clamp:2;line-clamp:2;-webkit-box-orient:vertical;display:-webkit-box}@media (width<=600px){.b5Vi8W_hero .b5Vi8W_input{min-height:36px}.b5Vi8W_hero .b5Vi8W_placeholder{white-space:nowrap;display:block}}.b5Vi8W_row{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}.b5Vi8W_row[data-model-compact]{--dsh-composer-model-text-display:none;--dsh-composer-model-icon-display:block}.b5Vi8W_tools,.b5Vi8W_modes,.b5Vi8W_trailing{align-items:center;min-width:0;display:flex}.b5Vi8W_tools,.b5Vi8W_modes{gap:12px}.b5Vi8W_trailing{flex:none;gap:12px;margin-left:auto}@container (width<=560px){.b5Vi8W_tools,.b5Vi8W_modes,.b5Vi8W_trailing{gap:8px}}.b5Vi8W_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}.b5Vi8W_add:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-hover-solid)}.b5Vi8W_add:disabled{opacity:.5;cursor:default}.b5Vi8W_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}.b5Vi8W_select:hover:not(:disabled){background-color:var(--dsw-alias-interactive-bg-hover)}.b5Vi8W_select:disabled{opacity:.5;cursor:default}.b5Vi8W_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)}.b5Vi8W_primary:hover:not(:disabled){background:var(--dsw-alias-button-info-hover)}.b5Vi8W_primary:disabled{opacity:.4;cursor:default}.b5Vi8W_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}.b5Vi8W_addSeat,.b5Vi8W_submitSeat,.b5Vi8W_controlScroll{display:contents}.b5Vi8W_row[data-phone-toolbar]{flex-wrap:nowrap;gap:4px;position:relative}.b5Vi8W_row[data-phone-toolbar] .b5Vi8W_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}.b5Vi8W_row[data-phone-toolbar] .b5Vi8W_controlScroll::-webkit-scrollbar{display:none}.b5Vi8W_row[data-phone-toolbar] .b5Vi8W_tools:not([hidden]),.b5Vi8W_row[data-phone-toolbar] .b5Vi8W_trailing:not(.b5Vi8W_trailingActive){display:contents}.b5Vi8W_row[data-phone-toolbar] .b5Vi8W_tools>*,.b5Vi8W_row[data-phone-toolbar] [data-slot="conversation.input.left"]>*{flex-shrink:0}.b5Vi8W_row[data-phone-toolbar] button:focus-visible{outline-offset:-2px}.b5Vi8W_row[data-phone-toolbar] .b5Vi8W_modes,.b5Vi8W_row[data-phone-toolbar] .b5Vi8W_standardControls{flex:none;gap:4px;width:max-content}.b5Vi8W_row[data-phone-toolbar] .b5Vi8W_standardControls{margin-left:0}.b5Vi8W_row[data-phone-toolbar] .b5Vi8W_addSeat,.b5Vi8W_row[data-phone-toolbar] .b5Vi8W_submitSeat{z-index:1;flex:none;align-items:center;gap:4px;display:flex;position:absolute;inset-block:2px 6px}.b5Vi8W_row[data-phone-toolbar] .b5Vi8W_addSeat{left:8px}.b5Vi8W_row[data-phone-toolbar] .b5Vi8W_submitSeat{margin-left:0;right:8px}.b5Vi8W_row[data-phone-toolbar] .b5Vi8W_add,.b5Vi8W_row[data-phone-toolbar] .b5Vi8W_primary{box-sizing:border-box;background-clip:padding-box;width:44px;height:44px}.b5Vi8W_row[data-phone-toolbar] .b5Vi8W_add{border:8px solid #0000}.b5Vi8W_row[data-phone-toolbar] .b5Vi8W_primary{border:7px solid #0000}.b5Vi8W_row[data-phone-toolbar][data-toolbar-activity] .b5Vi8W_controlScroll{display:contents}.b5Vi8W_row[data-phone-toolbar][data-toolbar-activity] .b5Vi8W_submitSeat{position:static}.b5Vi8W_row[data-actions-overflow] [data-composer-overflow-action]{display:none}.b5Vi8W_standardControls{align-items:center;gap:12px;min-width:0;display:flex}.b5Vi8W_tools[hidden],.b5Vi8W_standardControls[hidden]{display:none}.b5Vi8W_trailingActive{flex:1;margin-left:0}.b5Vi8W_activity{flex:none;align-items:center;display:flex}.b5Vi8W_activity:empty{display:none}.b5Vi8W_activityExpanded{flex:1;min-width:0}.b5Vi8W_annotations{scrollbar-width:none;align-items:center;gap:6px;padding:8px 12px 0;display:flex;overflow-x:auto}.b5Vi8W_annotations::-webkit-scrollbar{display:none}.b5Vi8W_annotations>*{flex:none}`,document.head.appendChild(e)}var oD={accessory:`b5Vi8W_accessory`,activity:`b5Vi8W_activity`,activityExpanded:`b5Vi8W_activityExpanded`,add:`b5Vi8W_add`,addSeat:`b5Vi8W_addSeat`,annotations:`b5Vi8W_annotations`,card:`b5Vi8W_card`,cardWorkspaceTrigger:`b5Vi8W_cardWorkspaceTrigger`,controlScroll:`b5Vi8W_controlScroll`,dock:`b5Vi8W_dock`,grow:`b5Vi8W_grow`,hero:`b5Vi8W_hero`,inlineNotices:`b5Vi8W_inlineNotices`,input:`b5Vi8W_input`,"input-pending":`b5Vi8W_input-pending`,inputDisabled:`b5Vi8W_inputDisabled`,modes:`b5Vi8W_modes`,notice:`b5Vi8W_notice`,overlayAnchor:`b5Vi8W_overlayAnchor`,pending:`b5Vi8W_pending`,placeholder:`b5Vi8W_placeholder`,primary:`b5Vi8W_primary`,retry:`b5Vi8W_retry`,root:`b5Vi8W_root`,row:`b5Vi8W_row`,scroll:`b5Vi8W_scroll`,select:`b5Vi8W_select`,standardControls:`b5Vi8W_standardControls`,submitSeat:`b5Vi8W_submitSeat`,tools:`b5Vi8W_tools`,trailing:`b5Vi8W_trailing`,trailingActive:`b5Vi8W_trailingActive`};let sD=[],cD=(0,g.memo)(function({useSession:e,useInput:t,inputActions:n,keyboard:r,addFiles:i,removeAttachment:a,resolveDraftAttachments:o,retryFileUpload:s,revealResponseAnnotation:c,toggleCommandMenu:l,stop:u,t:f,renderSlot:p,useBusyEnter:m,useFileUploads:_,useNotices:v,useLexicon:y,useMenuLauncher:ee,useStopShortcut:b,useProjection:te,sessionId:x,variant:ne,disabled:re=!1,blocked:ie,workspacePickerOpen:ae=!1,onRequestWorkspace:oe,placeholder:se,accessory:ce}){let S=t(e=>e),le=S?.responseAnnotations??sD,ue=(0,g.useMemo)(()=>({label:e=>f(`annotation.label`,{index:e}),railLabel:e=>f(`annotation.chipLabel`,{index:e}),railTitle:(e,t)=>f(`annotation.title`,{index:e,excerpt:t}),remove:e=>f(`annotation.remove`,{index:e}),selectedText:f(`annotation.selectedText`),userComment:f(`annotation.userComment`)}),[f]),de=v(e=>e),fe=m(e=>e),C=b(e=>e),w=ee(e=>e===`command`),[pe,me]=(0,g.useState)(!1);(0,g.useEffect)(()=>{me(!1)},[x]);let he=e(e=>e.promptError)??null,ge=e(e=>e.running)??!1,_e=e(e=>e.subagent)??null,ve=e(e=>e.removed)??!1,ye=te(`plan`,e=>e!==void 0&&(e.pending?!e.active:e.active)),be=te(`goal`,e=>e!=null),xe=S!==void 0&&r!==void 0&&n!==void 0,Se=S?.draft??``,Ce=S?.primaryAction,we=r?.editor??null,Te=(0,g.useMemo)(()=>S===void 0||o===void 0?[]:o(S.attachmentIds),[o,S?.attachmentIds]),Ee=Se.trim()===``&&Te.length===0&&le.length===0,De=_(e=>e),Oe=Te.some(e=>De[e.id]?.status===`error`),[ke,Ae]=(0,g.useState)(null),je=(0,g.useRef)(0),Me=(0,g.useCallback)(e=>{je.current+=1,Ae({seq:je.current,text:e})},[]),Ne=(0,g.useCallback)(()=>{Ae(null)},[]),Pe=te(`imageLimits`),Fe=te(`attachmentInput`),Ie=Fe?.enabled!==!1,Le=Fe?.imagesOnly===!0;(0,g.useEffect)(()=>{if(he===null)return;let{error:e}=he;e.code===`session/writer-held`?Me(f(`error.sessionInUse`)):Me(e.code===`session/attachment-invalid`||e.code===`subagent/attachment-invalid`?YE(f,e.details.reason,Pe):`${e.message} (${e.code})`)},[he,Me,f,Pe]),(0,g.useEffect)(()=>{de?.level===`error`&&Me(de.text)},[de,Me]);let Re=(0,g.useRef)(null),[ze,Be]=(0,g.useState)({phone:!1,overflowActions:!1});(0,g.useLayoutEffect)(()=>{let e=Re.current;if(e!==null)return iD(e,Be)},[]);let Ve=(0,g.useRef)(null),He=(0,g.useRef)(null),Ue=_e?.address.mode===`continuable`,We=Ue&&_e.parentAvailable!==!0,Ge=ve||re||!xe||ie!==void 0||We,Ke=Ge,qe=ve||re||!xe,Je=S?.phase===`adjudicating`||S?.phase===`submitting`,Ye=re&&!ve&&oe!==void 0,Xe=ve||Ke&&!Ye,Ze=xe&&!Ke&&!Je,Qe=_e===null||_e.address.mode===`continuable`,$e=!Ke&&!Je&&Ee&&ge&&Qe&&S.queue.length>0;(0,g.useEffect)(()=>{S!==void 0&&n!==void 0&&Te.length!==S.attachmentIds.length&&n.pruneAttachments(Te.map(e=>e.id))},[Te,S?.attachmentIds,n]);let et=()=>{HE(He)};(0,g.useEffect)(()=>{Ke||we===null||(0,d.shouldAutoFocusTextInput)()&&UE(we,et)},[Ke,x,we]),(0,g.useEffect)(()=>{Ke||Se===``||et()},[Se!==``]),(0,g.useEffect)(()=>WE(He),[]);let tt=(0,g.useCallback)((e,t)=>{if(_e!==null||i===void 0||e.length===0)return;if(!Ie){Me(f(`attachment.unavailable`));return}let n=(()=>{if(Le&&e.some(e=>!(Pe?.mediaTypes)?.includes(e.type)))return f(`image.unsupportedType`);if(Pe!==void 0){let t=Pe.mediaTypes,n=e.filter(e=>t.includes(e.type)),r=Te.filter(e=>e.kind===`image`);if(r.length+n.length>Pe.maxImagesPerMessage)return f(`image.tooMany`,{count:Pe.maxImagesPerMessage});if(n.some(e=>e.size>Pe.maxImageBytes))return f(`image.fileTooLarge`,{size:JE(Pe.maxImageBytes)});if(r.reduce((e,t)=>e+t.file.size,0)+n.reduce((e,t)=>e+t.size,0)>Pe.maxMessageImageBytes)return f(`image.totalTooLarge`,{size:JE(Pe.maxMessageImageBytes)})}return i(e,t)})();n!==null&&Me(n)},[_e,i,Ie,Le,Te,Pe,Me,f]),nt=Ie&&_e===null&&!Ke&&!Je&&i!==void 0,rt=f(Ie?Le?`input.imagesAndCommands`:`input.commands`:`input.commandsOnly`),it=(0,g.useRef)(null),at=e=>{let t=e.target.files===null?[]:[...e.target.files];e.target.value=``,t.length>0&&tt(t)},ot=(0,g.useRef)({locked:Ke,machineBusy:Je,primaryAction:Ce,canSteerQueue:$e,running:ge,steeringAvailable:Qe,busyEnter:fe,intakeFiles:tt,uploadsFailed:Oe,showToast:Me,t:f,canAcceptDrop:nt});ot.current={locked:Ke,machineBusy:Je,primaryAction:Ce,canSteerQueue:$e,running:ge,steeringAvailable:Qe,busyEnter:fe,intakeFiles:tt,uploadsFailed:Oe,showToast:Me,t:f,canAcceptDrop:nt},(0,g.useEffect)(()=>{if(r!==void 0)return GE(r,ot,it)},[r]),(0,g.useEffect)(()=>{if(we!==null&&r!==void 0)return KE(we,r,ot)},[we,r]);let st=e=>{qE(e,we)},ct=()=>{r!==void 0&&(we!==null&&(0,d.shouldAutoFocusTextInput)()&&UE(we,et),l?.(r.caretSpan()))},lt=e=>{Ye&&(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),oe())},ut=Ce===void 0&&ge&&_e===null&&(Ee||ie!==void 0),dt=ut?u===void 0:(Ce===void 0?Ee:Ce.disabled)||Ge||Je,ft=ge&&Ue,pt=VT(fe,ge,`enter`,Qe),mt=!Ee&&S?.phase===`plain`&&!Se.trimStart().startsWith(`/`),ht=f(ut?`input.stop`:Ce===void 0&&ge&&Qe&&!Ge&&!Oe&&mt?pt===`steer`?`input.send.steer`:`input.send.queue`:`input.send`),gt=()=>{ut?u?.():Oe?Me(f(`file.retryOrRemove`)):Ce===void 0?r!==void 0&&!Ee&&!Ge&&!Je&&r.submit(pt,`click`):dt||Ce.run()},_t=(S?.phase===`claimed`||S?.phase===`submitting`)&&S.claim!==void 0&&Se.startsWith(S.claim.token),vt=_t&&S.claim.hint!==void 0&&Se.slice(S.claim.token.length).trim()===``?S.claim.hint:null,yt=(()=>{if(vt===null)return null;let e=S?.claim?.name??``,t=`hint.${e===`goal`&&be?`goal.active`:e}`,n=f(t);return n===t?vt:n})(),bt=se??f(We?`placeholder.parentOffline`:Ge?`placeholder.unavailable`:$e?`placeholder.steerQueue`:ye?`placeholder.plan`:`placeholder.default`);return/* @__PURE__ */ (0,h.jsxs)(`div`,{className:Ib(oD.root,ne===`hero`&&oD.hero),children:[ke!==null&&/* @__PURE__ */ (0,h.jsx)(d.Toast,{text:ke.text,icon:/* @__PURE__ */ (0,h.jsx)(d.IconWarningOutlineRegular,{}),anchor:Ve.current,onDone:Ne},ke.seq),de?.level===`info`&&/* @__PURE__ */ (0,h.jsx)(`div`,{className:oD.notice,role:`status`,children:de.text}),/* @__PURE__ */ (0,h.jsxs)(`div`,{ref:Ve,className:Ib(oD.card,Ye&&oD.cardWorkspaceTrigger),"data-composer-card":!0,onClick:Ye?oe:void 0,onPointerDown:Ye?e=>{e.stopPropagation()}:void 0,children:[x!==void 0&&/* @__PURE__ */ (0,h.jsx)(`div`,{className:oD.overlayAnchor,children:p(`conversation.input.overlay`,{})}),ce!==void 0&&/* @__PURE__ */ (0,h.jsx)(`div`,{className:oD.accessory,children:ce}),le.length===0?null:/* @__PURE__ */ (0,h.jsx)(`div`,{className:oD.annotations,"data-composer-annotations":!0,children:le.map((e,t)=>/* @__PURE__ */ (0,h.jsx)(d.ResponseAnnotationChip,{index:t+1,annotation:e,labels:ue,onActivate:e.anchor===void 0?void 0:()=>c?.(e.id),onRemove:()=>{n?.removeResponseAnnotation(e.id)}},e.id))}),S===void 0||x===void 0?null:/* @__PURE__ */ (0,h.jsx)(`div`,{className:oD.inlineNotices,children:p(`conversation.input.notice`,{})}),p(`conversation.input.attachments`,{attachments:Te,canAcceptDrop:nt,onAddFiles:tt,onRemoveAttachment:e=>{a?.(e)},uploads:De,onRetryFile:e=>{s?.(e)},dropLimits:Pe===void 0?void 0:{count:Pe.maxImagesPerMessage,size:JE(Pe.maxImageBytes)}}),/* @__PURE__ */ (0,h.jsx)(zE,{classNames:oD,editor:we,scrollRef:He,editable:Ze,editorDisabled:Xe,phase:S?.phase??`inert`,placeholderText:bt,ariaLabel:Ye?f(`hero.chooseWorkspace`):bt,workspaceTrigger:Ye,workspacePickerOpen:ae,onWorkspaceKeyDown:lt,hint:yt,showPlaceholder:Se===``&&Te.length===0&&!_t}),/* @__PURE__ */ (0,h.jsx)(`div`,{ref:Re,className:oD.row,"data-composer-toolbar":!0,"data-command-menu-open":w||void 0,"data-toolbar-activity":pe||void 0,children:/* @__PURE__ */ (0,h.jsxs)(`div`,{className:oD.controlScroll,"data-toolbar-scroll":!0,children:[/* @__PURE__ */ (0,h.jsxs)(`div`,{className:oD.tools,hidden:pe,"data-composer-tools":!0,children:[/* @__PURE__ */ (0,h.jsx)(`div`,{className:oD.addSeat,"data-toolbar-fixed":`start`,children:/* @__PURE__ */ (0,h.jsx)(d.Tooltip,{portal:ze.phone,label:rt,side:`top`,delayMs:500,children:/* @__PURE__ */ (0,h.jsx)(`button`,{type:`button`,className:oD.add,"aria-label":rt,"aria-haspopup":`listbox`,"aria-expanded":w,disabled:Ke||Je||l===void 0,onMouseDown:st,onClick:ct,children:/* @__PURE__ */ (0,h.jsx)(d.IconPlusOutlineMedium,{size:14})})})}),/* @__PURE__ */ (0,h.jsx)(`input`,{ref:it,type:`file`,accept:Le?Pe?.mediaTypes.join(`,`):void 0,multiple:!0,disabled:!Ie||_e!==null,hidden:!0,onChange:at}),/* @__PURE__ */ (0,h.jsxs)(`div`,{className:oD.modes,children:[x===void 0?null:p(`conversation.input.permission`,{locked:Ke}),x===void 0?null:p(`conversation.input.plan`,{locked:Ke})]}),S===void 0||x===void 0?null:p(`conversation.input.left`,{})]}),/* @__PURE__ */ (0,h.jsxs)(`div`,{className:Ib(oD.trailing,pe&&oD.trailingActive),children:[/* @__PURE__ */ (0,h.jsxs)(`div`,{className:oD.standardControls,hidden:pe,children:[S===void 0||x===void 0?null:p(`conversation.input.right`,{overflowActions:ze.overflowActions}),x===void 0?null:p(`conversation.input.model`,{locked:qe})]}),S===void 0||x===void 0?null:/* @__PURE__ */ (0,h.jsx)(`div`,{className:pe?oD.activityExpanded:oD.activity,children:p(`conversation.input.activity`,{locked:Ke,onActiveChange:me})}),/* @__PURE__ */ (0,h.jsxs)(`div`,{className:oD.submitSeat,"data-toolbar-fixed":`end`,children:[ft&&/* @__PURE__ */ (0,h.jsx)(d.Tooltip,{portal:ze.phone,label:f(`input.stop`),shortcutKeys:C,side:`top`,delayMs:500,disabled:u===void 0,children:/* @__PURE__ */ (0,h.jsx)(`button`,{type:`button`,className:oD.primary,"aria-label":f(`input.stop`),disabled:u===void 0,onMouseDown:st,onClick:u,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:ze.phone,label:ut?f(`input.stop`):ht,shortcutKeys:ut?C:void 0,side:`top`,delayMs:500,disabled:dt,children:/* @__PURE__ */ (0,h.jsx)(`button`,{type:`button`,className:oD.primary,"aria-label":ht,disabled:dt,onMouseDown:st,onClick:gt,children:ut?/* @__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:oD.dock,"data-composer-dock":!0,children:[ne===`composer`&&S!==void 0&&x!==void 0?p(`conversation.composer.dock`,{}):null,pe?null:/* @__PURE__ */ (0,h.jsx)(rD,{useProjection:te,t:f})]})]})}),lD=`@deepseek-ai/dsh-client-ui-conversation/TodoPanel.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(lD)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-conversation`,e.dataset.pluginCss=lD,e.textContent=`.Sdgm8W_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}.Sdgm8W_body{flex-direction:column;gap:8px;padding:6px 12px;display:flex}.Sdgm8W_header{text-align:left;cursor:pointer;background:0 0;border:none;align-items:center;gap:10px;width:100%;padding:0;display:flex}.Sdgm8W_lead{color:var(--dsw-alias-label-tertiary);flex:none;place-items:center;display:grid}.Sdgm8W_title{color:var(--dsw-alias-label-primary);flex:none;font-size:13px;font-weight:500;line-height:24px}.Sdgm8W_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}.Sdgm8W_chevron{color:var(--dsw-alias-label-tertiary);flex:none;place-items:center;display:grid}.Sdgm8W_list{flex-direction:column;gap:8px;max-height:180px;margin:0;padding:0;list-style:none;display:flex;overflow-y:auto}.Sdgm8W_item{min-width:0;color:var(--dsw-alias-label-secondary);align-items:center;gap:10px;font-size:13px;line-height:20px;display:flex}.Sdgm8W_glyph{flex:none;place-items:center;width:16px;height:16px;display:grid}.Sdgm8W_content{text-overflow:ellipsis;white-space:nowrap;min-width:0;overflow:hidden}`,document.head.appendChild(e)}var uD={body:`Sdgm8W_body`,chevron:`Sdgm8W_chevron`,content:`Sdgm8W_content`,glyph:`Sdgm8W_glyph`,header:`Sdgm8W_header`,item:`Sdgm8W_item`,lead:`Sdgm8W_lead`,list:`Sdgm8W_list`,progress:`Sdgm8W_progress`,root:`Sdgm8W_root`,title:`Sdgm8W_title`};
|
|
174
177
|
/* v8 ignore next 3 -- closed-union backstop; only reached if status is forged */
|
|
175
|
-
function
|
|
178
|
+
function dD(e){throw Error(`unreachable todo status: ${String(e)}`)}function fD(e){switch(e){case`completed`:return`done`;case`in_progress`:return`ongoing`;case`pending`:return`idle`;
|
|
176
179
|
/* v8 ignore next -- closed TodoItem status union */
|
|
177
|
-
default:return
|
|
180
|
+
default:return dD(e)}}function pD(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`);
|
|
178
181
|
/* v8 ignore next -- closed TodoItem status union */
|
|
179
|
-
default:return
|
|
182
|
+
default:return dD(e)}}function mD(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 hD({todos:e,t}){let[n,r]=(0,g.useState)(!0);return e.length===0?null:/* @__PURE__ */ (0,h.jsx)(`section`,{className:uD.root,"data-testid":`todo-panel`,"aria-label":t(`todo.title`),children:/* @__PURE__ */ (0,h.jsxs)(`div`,{className:uD.body,children:[/* @__PURE__ */ (0,h.jsxs)(`button`,{type:`button`,className:uD.header,"aria-expanded":!n,onClick:()=>{r(e=>!e)},children:[/* @__PURE__ */ (0,h.jsx)(`span`,{className:uD.lead,"aria-hidden":!0,children:/* @__PURE__ */ (0,h.jsx)(d.IconChecklistOutlineRegular,{})}),/* @__PURE__ */ (0,h.jsx)(`span`,{className:uD.title,children:t(`todo.title`)}),/* @__PURE__ */ (0,h.jsx)(`span`,{className:uD.progress,children:mD(e,t)}),/* @__PURE__ */ (0,h.jsx)(`span`,{className:uD.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:uD.list,children:e.map(e=>/* @__PURE__ */ (0,h.jsxs)(`li`,{className:uD.item,"data-status":e.status,children:[/* @__PURE__ */ (0,h.jsx)(`span`,{className:uD.glyph,role:`img`,"aria-label":pD(e.status,t),children:/* @__PURE__ */ (0,h.jsx)(d.StateDot,{state:fD(e.status)})}),/* @__PURE__ */ (0,h.jsx)(`span`,{className:uD.content,children:e.content})]},e.content))})]})})}function gD({useProjection:e,t}){let n=e(`todos`);return/* @__PURE__ */ (0,h.jsx)(hD,{todos:n??[],t})}let _D={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:Ic},gD))}};var vD=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 yD(e,t,n,r,i){let a=()=>{},o=new vD(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 bD=[`slots`,`sessions`,`fileUpload`,`uiSession`,`uiWorkspace`,`locale`,`configForms`],xD=w.object({maxConcurrentFileUploads:w.natural().min(1).default(2)}),SD={getSnapshot:()=>null,subscribe:()=>()=>{}},CD={getSnapshot:()=>void 0,subscribe:()=>()=>{}},wD=/* @__PURE__ */ new Map,TD={getSnapshot:()=>wD,subscribe:()=>()=>{}},ED={getSnapshot:()=>null,subscribe:()=>()=>{}},DD={},OD={getSnapshot:()=>DD,subscribe:()=>()=>{}};function kD(){return globalThis.__DSH_HOST_PATHS__}function AD(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 jD(e){let t=e.get(`conversation`);if(t===void 0)throw Error(`ui-conversation: conversation service unavailable`);return t}function MD(e,t=xD({})){let n=e.sessions,r=e.slots,i=t.maxConcurrentFileUploads,a=e.get(`uiWorkspace`),o=new wt(e,n);e.effect(()=>e.locale.register(Ic,{zh:zc,en:Bc}),`ui-conversation: dictionaries`);let s=e.locale.bind(Ic),c=Ac(),l=new HT(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:Ic,inject:()=>({hooks:{busyEnter:l.busyEnter},setBusyEnter:e=>{l.setBusyEnter(e)}})},nE));let u=()=>{let t=[];for(let n of r.entries(`conversation.view`))
|
|
180
183
|
/* v8 ignore next -- list registration validates id at load. */
|
|
181
|
-
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=
|
|
184
|
+
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=jE(u(),t);n!==void 0&&o.binding(e).activate(n.id)},h=e=>{m(e,Mc(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`))},ee=()=>{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`,ee),n=e.locale.subscribe(ee),i=e.configForms.developerTools.enabled.subscribe(ee);return()=>{i(),n(),t()}},`ui-conversation: View selection`);let b=e=>{AD(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(()=>yD(t.shortcuts,n,e=>o.binding(e).openTurn,e.uiSession,b),`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 x=new IT(e,s),ne=new Yc;e.inject([`commandUi`],e=>{let t=e.get(`commandUi`);e.effect(()=>t.register({name:`file`,label:()=>s(`input.file`),icon:d.IconPaperclipOutlineRegular,available:e=>x.canPickFiles(e.sessionId),ui:{kind:`action`,run:e=>{x.pickFiles(e.sessionId)}}}),`ui-conversation: File action`)}),e.uiSession.provide({hooks:[`conversation`,`input`],props:[`inputActions`],resolve:e=>{y(e);let t=x.shellFor(e),n=o.binding(e);return h(e.sessionId),{hooks:{conversation:n.snapshot,input:t.state},props:{inputActions:t.actions}}}});let re=()=>r.register({name:`main.conversation`,children:{"conversation.header":{kind:`single`,scope:`session-maybe`},"conversation.header.notice":{kind:`list`,scope:`session-maybe`}}},mE),ie=()=>r.registerFactory({name:`conversation.content`,scope:`session-maybe`,locale:Ic,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:x.shell(t).editor,hooks:{composerBlock:t===void 0?CD:ne.storeFor(t)},selectWorkspace:r=>a.openWorkspace(r,r=>{if(t!==void 0&&r!==t){let i=x.shell(t),a=i.draftSnapshot,o=i.snapshot.attachmentIds,s=x.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(jD(e).rebindDraftFiles(r,o),a.text!==``&&(s.setDraft(a),i.setDraft(``)),o.length>0)for(let e of o)i.removeAttachment(e)}}})})},DE),ae=()=>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=>x.shell(e).bindDraftPersistence(t),onRevealResponseAnnotation:t=>n.scope(e)?.on(`conversation/reveal-response-annotation`,t)??(()=>{}),openView:r}}},IE),oe=()=>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`}}},AE),se=()=>r.register({name:`conversation.session.header`,locale:Ic,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)}})},FE),ce=()=>r.register({name:`conversation.composer.bar`,locale:Ic,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,addFiles:void 0,removeAttachment:void 0,resolveDraftAttachments:void 0,retryFileUpload:void 0,revealResponseAnnotation:void 0,toggleCommandMenu:void 0,stop:void 0,hooks:{stopShortcut:te,busyEnter:l.busyEnter,fileUploads:OD,notices:SD,lexicon:TD,menuLauncher:ED}};let r=jD(e),i=x.shell(t),a=x.inputTriggers(t),o=kD();return{keyboard:i,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&&qc(t.type)){c.push(t);continue}let r=Fc(n,u),i=Nc({path:e?`${r}/`:r,kind:`file`},!1);if(i===void 0)return s(`attachment.pathUnsupported`);let d=Pc(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:()=>{b(t)},hooks:{stopShortcut:te,busyEnter:l.busyEnter,fileUploads:r.fileUploads,notices:i.notices,lexicon:i.lexicon,menuLauncher:a?.launcher??ED}}}},cD);e.inject([`conversation`],e=>e.slots.inject(`main`,function*(){yield r.register({name:`main`,key:`conversation`,children:{"main.conversation":{kind:`single`,scope:`session-maybe`}}},OE),yield re(),yield ie(),yield ae(),yield oe(),yield se(),yield ce()})),e.plugin(Kc,{input:x,blocks:ne,maxConcurrentFileUploads:i}),e.plugin(_D),e.plugin(QT,x)}return n.Config=xD,n.ConversationController=Kc,n.ConversationDefinitionRegistry=mt,n.ConversationEventRegistry=ht,n.ConversationLocationIndex=Qe,n.ConversationNodeAssembler=dt,n.ConversationViewRegistry=xt,n.EMPTY_CONVERSATION_SNAPSHOT=rE,n.UiConversation=wt,n.apply=MD,n.conversationPhase=iE,n.inject=bD,n.inspectRequestPrompt=Me,t.exports}});
|