@codexhost/cli-win32-arm64 0.26.0 → 0.26.1
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/THIRD_PARTY_NOTICES.txt +1 -1
- package/app/codexhost-distribution.json +1 -1
- package/app/console-server.mjs +7669 -2363
- package/app/console-web.js +7604 -2343
- package/app/desktop-controller.mjs +7259 -2056
- package/app/host-runtime.mjs +11012 -5608
- package/app/plugins/antigravity/plugin.mjs +7620 -2371
- package/app/plugins/claude-code/plugin.mjs +7431 -2217
- package/app/plugins/codebuddy/plugin.mjs +7697 -2494
- package/app/plugins/codex-usage/plugin.mjs +7242 -2039
- package/app/plugins/copilot/plugin.mjs +7404 -2201
- package/app/plugins/cursor-cli/plugin.mjs +7583 -2380
- package/app/plugins/deepseek-harness/plugin.mjs +7825 -2598
- package/app/plugins/devin/plugin.mjs +7407 -2204
- package/app/plugins/grok/plugin.mjs +7672 -2469
- package/app/plugins/hermes/plugin.mjs +7594 -2247
- package/app/plugins/kimi-code/plugin.mjs +7494 -2291
- package/app/plugins/kiro-cli/plugin.mjs +7509 -2306
- package/app/plugins/omp/plugin.mjs +7540 -2337
- package/app/plugins/opencode/plugin.mjs +7954 -2751
- package/app/plugins/pi/plugin.mjs +7558 -2355
- package/app/plugins/qoder/plugin.mjs +7843 -2601
- package/app/plugins/qoder-cn/plugin.mjs +7843 -2601
- package/app/plugins/qwen-code/plugin.mjs +7527 -2324
- package/app/plugins/workbuddy/plugin.mjs +7705 -2502
- package/app/plugins/zcode/plugin.mjs +7371 -2168
- package/app/renderer-extension.js +7938 -2663
- package/app/web/assets/index-CR4Y8Ndj.css +1 -0
- package/app/web/assets/index-Dw-yHAxN.js +196 -0
- package/app/web/codexhost-settings.js +97 -88
- package/app/web/index.html +2 -2
- package/app/web/plugins/deepseek-ai__dsh-api-remotes/client.js +98 -106
- package/app/web/plugins/deepseek-ai__dsh-api-session-controller/client.js +102 -111
- package/app/web/plugins/deepseek-ai__dsh-client-ui-attachment/client.js +1 -1
- package/app/web/plugins/deepseek-ai__dsh-client-ui-chat/client.js +107 -116
- package/app/web/plugins/deepseek-ai__dsh-client-ui-codexhost/client.js +106 -115
- package/app/web/plugins/deepseek-ai__dsh-client-ui-conversation/client.js +128 -137
- package/app/web/plugins/deepseek-ai__dsh-client-ui-sidebar-right/client.js +94 -103
- package/app/web/plugins/deepseek-ai__dsh-client-ui-tool/client.js +112 -121
- package/app/web/plugins/deepseek-ai__dsh-client-ui-workspace/client.js +102 -111
- package/app/web/plugins/deepseek-ai__dsh-typert-registry/client.js +8 -8
- package/app/web-modules/node_modules/@deepseek-ai/dsh-client-modules/index.js +2 -2
- package/app/web-modules/server.mjs +9130 -4614
- package/bin/codexhost.exe +0 -0
- package/libexec/codexhost-node-repl.exe +0 -0
- package/libexec/codexhost-shell.exe +0 -0
- package/libexec/codexhost-shim.exe +0 -0
- package/libexec/codexhost-updater.exe +0 -0
- package/package.json +1 -1
- package/app/web/assets/index-BDWdtbFT.js +0 -203
- package/app/web/assets/index-jLAmV7OU.css +0 -1
|
@@ -1,184 +1,175 @@
|
|
|
1
|
-
window.__ModuleLoader__.load({id:`@deepseek-ai/dsh-client-ui-conversation`,factory:e=>{var t={exports:{}},n=t.exports;Object.defineProperty(n,Symbol.toStringTag,{value:`Module`});var r=Object.create,i=Object.defineProperty,a=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyNames,s=Object.getPrototypeOf,c=Object.prototype.hasOwnProperty,l=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var s=o(t),l=0,u=s.length,d;l<u;l++)d=s[l],!c.call(e,d)&&d!==n&&i(e,d,{get:(e=>t[e]).bind(null,d),enumerable:!(r=a(t,d))||r.enumerable});return e},u=(e,t,n)=>(n=e==null?{}:r(s(e)),l(t||!e||!e.__esModule||!c.call(e,`default`)?i(n,`default`,{value:e,enumerable:!0}):n,e));let d=e("@deepseek-ai/dsh-client-ui-primitives"),f=e("@deepseek-ai/dsh-client-store"),p=e("@deepseek-ai/dsh-client-ui-slots"),m=e("@deepseek-ai/cordis"),h=e("react/jsx-runtime"),g=e("react");g=u(g,1);let _=e("react-dom");function v(e){return e==null}function y(e){return e&&typeof e==`object`&&!Array.isArray(e)}function b(e,t){return Object.fromEntries(Object.entries(e).filter(([e,n])=>t(e,n)))}function ee(e,t){return Object.fromEntries(Object.entries(e).map(([e,n])=>[e,t(n,e)]))}function te(e,t,n){if(!t)return{...e};let r={};for(let i of t)(n||e[i]!==void 0)&&(r[i]=e[i]);return r}let ne=Symbol.for(`cosmokit.volatile.write`);function re(e,t=/* @__PURE__ */ new Set){if(typeof e==`function`)throw TypeError(`volatile config cannot contain functions`);if(typeof e!=`object`||!e)return e;if(t.has(e))throw TypeError(`volatile config cannot contain cycles`);t.add(e);try{if(Array.isArray(e))return Object.freeze(e.map(e=>re(e,t)));if(Object.getPrototypeOf(e)!==Object.prototype&&Object.getPrototypeOf(e)!==null)throw TypeError(`volatile config objects must be plain objects or arrays`);return Object.freeze(Object.fromEntries(Object.entries(e).map(([e,n])=>[e,re(n,t)])))}finally{t.delete(e)}}function ie(e){let t=re(e);return Object.freeze({get:()=>t,[ne]:e=>{t=e}})}function ae(e){return typeof e==`object`&&!!e&&ne in e}function oe(e,t){return arguments.length===1?t=>oe(e,t):e in globalThis&&t instanceof globalThis[e]||Object.prototype.toString.call(t).slice(8,-1)===e}function se(e){return oe(`ArrayBuffer`,e)||oe(`SharedArrayBuffer`,e)}function ce(e){return se(e)||ArrayBuffer.isView(e)}let le;(function(e){e.is=se,e.isSource=ce;function t(e){return ArrayBuffer.isView(e)?e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength):e}e.fromSource=t;function n(e){if(e=t(e),typeof Buffer<`u`)return Buffer.from(e).toString(`base64`);let n=``,r=new Uint8Array(e);for(let e=0;e<r.byteLength;e++)n+=String.fromCharCode(r[e]);return btoa(n)}e.toBase64=n;function r(e){return typeof Buffer<`u`?t(Buffer.from(e,`base64`)):Uint8Array.from(atob(e),e=>e.charCodeAt(0))}e.fromBase64=r;function i(e){return e=t(e),typeof Buffer<`u`?Buffer.from(e).toString(`hex`):Array.from(new Uint8Array(e),e=>e.toString(16).padStart(2,`0`)).join(``)}e.toHex=i;function a(e){if(typeof Buffer<`u`)return t(Buffer.from(e,`hex`));let n=e.length%2==0?e:e.slice(0,e.length-1),r=[];for(let e=0;e<n.length;e+=2)r.push(parseInt(`${n[e]}${n[e+1]}`,16));return Uint8Array.from(r).buffer}e.fromHex=a})(le||={}),le.fromBase64,le.toBase64,le.fromHex,le.toHex;function ue(e,t=/* @__PURE__ */ new Map){if(!e||typeof e!=`object`)return e;if(oe(`Date`,e))return new Date(e.valueOf());if(oe(`RegExp`,e))return new RegExp(e.source,e.flags);if(se(e))return e.slice(0);if(ArrayBuffer.isView(e))return e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength);let n=t.get(e);if(n)return n;if(Array.isArray(e)){let n=[];return t.set(e,n),e.forEach((e,r)=>{n[r]=Reflect.apply(ue,null,[e,t])}),n}let r=Object.create(Object.getPrototypeOf(e));t.set(e,r);for(let n of Reflect.ownKeys(e)){let i={...Reflect.getOwnPropertyDescriptor(e,n)};`value`in i&&(i.value=Reflect.apply(ue,null,[i.value,t])),Reflect.defineProperty(r,n,i)}return r}function de(e,t,n){let r=/* @__PURE__ */ new Set;function i(e,t){if(e===t)return!0;if(ae(e)||ae(t))return ae(e)&&ae(t);if(!n&&v(e)&&v(t))return!0;if(typeof e!=typeof t||typeof e!=`object`||!e||!t||r.has(e))return!1;function a(n,r){return n(e)?n(t)?r(e,t):!1:!n(t)&&void 0}r.add(e);try{return a(Array.isArray,(e,t)=>{if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!i(e[n],t[n]))return!1;return!0})??a(oe(`Date`),(e,t)=>e.valueOf()===t.valueOf())??a(oe(`URL`),(e,t)=>e.href===t.href)??a(oe(`RegExp`),(e,t)=>e.source===t.source&&e.flags===t.flags)??a(se,(e,t)=>{if(e.byteLength!==t.byteLength)return!1;let n=new Uint8Array(e),r=new Uint8Array(t);for(let e=0;e<n.length;e++)if(n[e]!==r[e])return!1;return!0})??((!n||[e,t].every(e=>Object.getPrototypeOf(e)===Object.prototype||Object.getPrototypeOf(e)===null))&&Object.keys({...e,...t}).every(n=>i(e[n],t[n])))}finally{r.delete(e)}}return i(e,t)}let fe;(function(e){e.millisecond=1;let t=e.second=1e3,n=e.minute=t*60,r=e.hour=n*60,i=e.day=r*24,a=e.week=i*7,o=(/* @__PURE__ */ new Date()).getTimezoneOffset();function s(e){o=e}e.setTimezoneOffset=s;function c(){return o}e.getTimezoneOffset=c;function l(e=/* @__PURE__ */ new Date,t){return typeof e==`number`&&(e=new Date(e)),t===void 0&&(t=o),Math.floor((e.valueOf()/n-t)/1440)}e.getDateNumber=l;function u(e,t){let r=new Date(e*i);return t===void 0&&(t=o),new Date(+r+t*n)}e.fromDateNumber=u;let d=RegExp(`^${[`w(?:eek(?:s)?)?`,`d(?:ay(?:s)?)?`,`h(?:our(?:s)?)?`,`m(?:in(?:ute)?(?:s)?)?`,`s(?:ec(?:ond)?(?:s)?)?`].map(e=>`(\\d+(?:\\.\\d+)?${e})?`).join(``)}$`);function f(e){let o=d.exec(e);return o?(parseFloat(o[1])*a||0)+(parseFloat(o[2])*i||0)+(parseFloat(o[3])*r||0)+(parseFloat(o[4])*n||0)+(parseFloat(o[5])*t||0):0}e.parseTime=f;function p(e){let t=f(e);return t?e=Date.now()+t:/^\d{1,2}(:\d{1,2}){1,2}$/.test(e)?e=`${(/* @__PURE__ */ new Date()).toLocaleDateString()}-${e}`:/^\d{1,2}-\d{1,2}-\d{1,2}(:\d{1,2}){1,2}$/.test(e)&&(e=`${(/* @__PURE__ */ new Date()).getFullYear()}-${e}`),e?new Date(e):/* @__PURE__ */ new Date}e.parseDate=p;function m(e){let a=Math.abs(e);return a>=i-r/2?Math.round(e/i)+`d`:a>=r-n/2?Math.round(e/r)+`h`:a>=n-t/2?Math.round(e/n)+`m`:a>=t?Math.round(e/t)+`s`:e+`ms`}e.format=m;function h(e,t=2){return e.toString().padStart(t,`0`)}e.toDigits=h;function g(e,t=/* @__PURE__ */ new Date){return e.replace(`yyyy`,t.getFullYear().toString()).replace(`yy`,t.getFullYear().toString().slice(2)).replace(`MM`,h(t.getMonth()+1)).replace(`dd`,h(t.getDate())).replace(`hh`,h(t.getHours())).replace(`mm`,h(t.getMinutes())).replace(`ss`,h(t.getSeconds())).replace(`SSS`,h(t.getMilliseconds(),3))}e.template=g})(fe||={});let pe=Symbol.for(`schemastery`),me=Symbol.for(`ValidationError`);globalThis.__schemastery_index__??=0,globalThis.__schemastery_refs__=void 0;var x=class extends TypeError{options;name=`ValidationError`;constructor(e,t){let n=`$`;for(let e of t.path||[])typeof e==`string`?n+=`.`+e:typeof e==`number`?n+=`[`+e+`]`:typeof e==`symbol`&&(n+=`[Symbol(${e.toString()})]`);n.startsWith(`.`)&&(n=n.slice(1)),super((n===`$`?``:`${n} `)+e),this.options=t}static is(e){return!!e?.[me]}};Object.defineProperty(x.prototype,me,{value:!0});let S=function(e){let t=function(e,n={}){return S.resolve(e,t,n)[0]};if(e.refs){let t=ee(e.refs,e=>new S(e)),n=e=>t[e];for(let e in t){let r=t[e];r.sKey=n(r.sKey),r.inner=n(r.inner),r.list=r.list&&r.list.map(n),r.dict=r.dict&&ee(r.dict,n)}return t[e.uid]}if(Object.assign(t,e),typeof t.callback==`string`)try{t.callback=Function(`return `+t.callback)()}catch{}return Object.defineProperty(t,"uid",{value:globalThis.__schemastery_index__++}),Object.setPrototypeOf(t,S.prototype),t.meta||={},t.toString=t.toString.bind(t),t};S.prototype=Object.create(Function.prototype),S.prototype[pe]=!0,Object.defineProperty(S.prototype,"~standard",{get(){return{version:1,vendor:`schemastery`,validate:e=>{try{return{value:S.resolve(e,this,{})[0]}}catch(e){if(x.is(e))return{issues:[{message:e.message,path:e.options.path}]};throw e}}}}}),S.ValidationError=x,S.prototype.toJSON=function(){if(globalThis.__schemastery_refs__)return globalThis.__schemastery_refs__[this.uid]??=JSON.parse(JSON.stringify({...this})),this.uid;globalThis.__schemastery_refs__={[this.uid]:{...this}},globalThis.__schemastery_refs__[this.uid]=JSON.parse(JSON.stringify({...this}));let e={uid:this.uid,refs:globalThis.__schemastery_refs__};return globalThis.__schemastery_refs__=void 0,e},S.prototype.set=function(e,t){return this.dict[e]=t,this},S.prototype.push=function(e){return this.list.push(e),this};function he(e,t){let n=typeof e==`string`?{"":e}:{...e};for(let e in t){let r=t[e];r?.$description||r?.$desc?n[e]=r.$description||r.$desc:typeof r==`string`&&(n[e]=r)}return n}function ge(e){return e?.$value??e?.$inner}function _e(e){return b(e??{},e=>!e.startsWith(`$`))}S.prototype.i18n=function(e){let t=S(this),n=he(t.meta.description,e);return Object.keys(n).length&&(t.meta.description=n),t.dict&&=ee(t.dict,(t,n)=>t.i18n(ee(e,e=>ge(e)?.[n]??e?.[n]))),t.list&&=t.list.map((t,n)=>t.i18n(ee(e,(e={})=>Array.isArray(ge(e))?ge(e)[n]:Array.isArray(e)?e[n]:_e(e)))),t.inner&&=t.inner.i18n(ee(e,e=>ge(e)?ge(e):_e(e))),t.sKey&&=t.sKey.i18n(ee(e,e=>e?.$key)),t},S.prototype.extra=function(e,t){let n=S(this);return n.meta={...n.meta,[e]:t},n};for(let e of[`required`,`disabled`,`collapse`,`hidden`,`loose`])Object.assign(S.prototype,{[e](t=!0){let n=S(this);return n.meta={...n.meta,[e]:t},n}});S.prototype.deprecated=function(){let e=S(this);return e.meta.badges||=[],e.meta.badges.push({text:`deprecated`,type:`danger`}),e},S.prototype.experimental=function(){let e=S(this);return e.meta.badges||=[],e.meta.badges.push({text:`experimental`,type:`warning`}),e},S.prototype.pattern=function(e){let t=S(this),n=te(e,[`source`,`flags`]);return t.meta={...t.meta,pattern:n},t},S.prototype.simplify=function(e){if(ae(e)&&(e=e.get()),de(e,this.meta.default,this.type===`dict`))return null;if(v(e))return e;if(this.type===`object`||this.type===`dict`){let t={};for(let n in e){let r=(this.type===`object`?this.dict[n]:this.inner)?.simplify(e[n]);(this.type===`dict`||!v(r))&&(t[n]=r)}return de(t,this.meta.default,this.type===`dict`)?null:t}if(this.type===`array`||this.type===`tuple`){let t=[];return e.forEach((e,n)=>{let r=this.type===`array`?this.inner:this.list[n],i=r?r.simplify(e):e;t.push(i)}),t}if(this.type===`intersect`){let t={};for(let n of this.list)Object.assign(t,n.simplify(e));return t}if(this.type===`union`)for(let t of this.list)try{return S.resolve(e,t,{}),t.simplify(e)}catch{}return e},S.prototype.toString=function(e){return Ee[this.type]?.(this,e)??`Schema<${this.type}>`},S.prototype.role=function(e,t){let n=S(this);return n.meta={...n.meta,role:e,extra:t},n};for(let e of[`default`,`link`,`comment`,`description`,`max`,`min`,`step`])Object.assign(S.prototype,{[e](t){let n=S(this);return n.meta={...n.meta,[e]:t},n}});S.prototype.volatile=function(){if(this.meta.volatile)throw TypeError(`volatile schema is already wrapped`);return this.extra(`volatile`,!0)};let ve={},ye=Symbol(`checked-volatile-schema`);function be(e,t=[],n=!1,r=/* @__PURE__ */ new Map){let i=r.get(e)??/* @__PURE__ */ new Set;if(i.has(n))return;if(i.add(n),r.set(e,i),e.meta?.volatile&&n)throw new x(`volatile fields require a fixed object path without an enclosing volatile field`,{path:t});let a=n||!!e.meta?.volatile;if(e.dict)for(let[n,i]of Object.entries(e.dict))be(i,[...t,n],a,r);if(e.sKey&&be(e.sKey,[...t,`<key>`],!0,r),e.inner&&(e.type!==`lazy`||e.inner[pe])&&be(e.inner,[...t,`*`],!0,r),e.list)for(let n=0;n<e.list.length;n++)be(e.list[n],[...t,String(n)],!0,r)}S.extend=function(e,t){ve[e]=t},S.resolve=function(e,t,n={},r=!1){if(!t)return[e];if(n[ye]||(be(t,n.path),n={...n,[ye]:!0}),t.meta?.volatile){let i=S(t);i.meta={...t.meta,volatile:!1};let[a,o]=S.resolve(e,i,n,r);try{return[ie(a),o]}catch(e){throw new x(e instanceof Error?e.message:String(e),n)}}if(n.ignore?.(e,t))return[e];if(v(e)&&t.type!==`lazy`){if(t.meta.required)throw new x(`missing required value`,n);let r=t,i=t.meta.default;for(;r?.type===`intersect`&&v(i);)r=r.list[0],i=r?.meta.default;if(v(i))return[e];e=ue(i)}let i=ve[t.type];if(!i)throw new x(`unsupported type "${t.type}"`,n);try{return i(e,t,n,r)}catch(e){if(!t.meta.loose)throw e;return[t.meta.default]}},S.from=function(e){if(v(e))return S.any();if([`string`,`number`,`boolean`].includes(typeof e))return S.const(e).required();if(e[pe])return e;if(typeof e==`function`)switch(e){case String:return S.string().required();case Number:return S.number().required();case Boolean:return S.boolean().required();case Function:return S.function().required();default:return S.is(e).required()}else throw TypeError(`cannot infer schema from ${e}`)},S.lazy=function(e){let t=new S({type:`lazy`,builder:e,inner:{toJSON:()=>(t.inner[pe]||(t.inner=t.builder(),t.inner.meta={...t.meta,...t.inner.meta}),t.inner.toJSON())}});return t},S.natural=function(){return S.number().step(1).min(0)},S.percent=function(){return S.number().step(.01).min(0).max(1).role(`slider`)},S.date=function(){return S.union([S.is(Date),S.transform(S.string().role(`datetime`),(e,t)=>{let n=new Date(e);if(isNaN(+n))throw new x(`invalid date "${e}"`,t);return n},!0)])},S.regExp=function(e=``){return S.union([S.is(RegExp),S.transform(S.string().role(`regexp`,{flag:e}),(t,n)=>{try{return new RegExp(t,e)}catch(e){throw new x(e.message,n)}},!0)])},S.arrayBuffer=function(e){return S.union([S.is(ArrayBuffer),S.is(SharedArrayBuffer),S.transform(S.any(),(e,t)=>{if(le.isSource(e))return le.fromSource(e);throw new x(`expected ArrayBufferSource but got ${e}`,t)},!0),...e?[S.transform(S.string(),(t,n)=>{try{return e===`base64`?le.fromBase64(t):le.fromHex(t)}catch(e){throw new x(e.message,n)}},!0)]:[]])},S.extend(`lazy`,(e,t,n,r)=>(t.inner[pe]||(t.inner=t.builder(),t.inner.meta={...t.meta,...t.inner.meta},be(t.inner,n.path,!0)),S.resolve(e,t.inner,n,r))),S.extend(`any`,e=>[e]),S.extend(`never`,(e,t,n)=>{throw new x(`expected nullable but got ${e}`,n)}),S.extend(`const`,(e,{value:t},n)=>{if(de(e,t))return[t];throw new x(`expected ${t} but got ${e}`,n)});function xe(e,t,n,r,i=!1){let{max:a=1/0,min:o=-1/0}=t;if(e>a)throw new x(`expected ${n} <= ${a} but got ${e}`,r);if(e<o&&!i)throw new x(`expected ${n} >= ${o} but got ${e}`,r)}S.extend(`string`,(e,{meta:t},n)=>{if(typeof e!=`string`)throw new x(`expected string but got ${e}`,n);if(t.pattern){let r=new RegExp(t.pattern.source,t.pattern.flags);if(!r.test(e))throw new x(`expect string to match regexp ${r}`,n)}return xe(e.length,t,`string length`,n),[e]});function Se(e,t){let n=e.toString();if(n.includes(`e`))return e*10**t;let r=n.indexOf(`.`);if(r===-1)return e*10**t;let i=n.slice(r+1),a=n.slice(0,r);return i.length<=t?+(a+i.padEnd(t,`0`)):+(a+i.slice(0,t)+`.`+i.slice(t))}function Ce(e,t,n){if(n=Math.abs(n),!/^\d+\.\d+$/.test(n.toString()))return(e-t)%n===0;let r=n.toString().indexOf(`.`),i=n.toString().slice(r+1).length;return Math.abs(Se(e,i)-Se(t,i))%Se(n,i)===0}S.extend(`number`,(e,{meta:t},n)=>{if(typeof e!=`number`)throw new x(`expected number but got ${e}`,n);xe(e,t,`number`,n);let{step:r}=t;if(r&&!Ce(e,t.min??0,r))throw new x(`expected number multiple of ${r} but got ${e}`,n);return[e]}),S.extend(`boolean`,(e,t,n)=>{if(typeof e==`boolean`)return[e];throw new x(`expected boolean but got ${e}`,n)}),S.extend(`bitset`,(e,{bits:t,meta:n},r)=>{let i=0,a=[];if(typeof e==`number`){i=e;for(let n in t)e&t[n]&&a.push(n)}else if(Array.isArray(e)){a=e;for(let e of a){if(typeof e!=`string`)throw new x(`expected string but got ${e}`,r);e in t&&(i|=t[e])}}else throw new x(`expected number or array but got ${e}`,r);return i===n.default?[i]:[i,a]}),S.extend(`function`,(e,t,n)=>{if(typeof e==`function`)return[e];throw new x(`expected function but got ${e}`,n)}),S.extend(`is`,(e,{constructor:t},n)=>{if(typeof t==`function`){if(e instanceof t)return[e];throw new x(`expected ${t.name} but got ${e}`,n)}{if(v(e))throw new x(`expected ${t} but got ${e}`,n);let r=Object.getPrototypeOf(e);for(;r;){if(r.constructor?.name===t)return[e];r=Object.getPrototypeOf(r)}throw new x(`expected ${t} but got ${e}`,n)}});function we(e,t,n,r){try{let[i,a]=S.resolve(e[t],n,{...r,path:[...r.path||[],t]});return a!==void 0&&(e[t]=a),i}catch(i){if(!r?.autofix)throw i;return delete e[t],n.meta.volatile?ie(n.meta.default):n.meta.default}}S.extend(`array`,(e,{inner:t,meta:n},r)=>{if(!Array.isArray(e))throw new x(`expected array but got ${e}`,r);return xe(e.length,n,`array length`,r,!v(t.meta.default)),[e.map((n,i)=>we(e,i,t,r))]}),S.extend(`dict`,(e,{inner:t,sKey:n},r,i)=>{if(!y(e))throw new x(`expected object but got ${e}`,r);let a={};for(let o in e){let s;try{s=S.resolve(o,n,r)[0]}catch(e){if(i)continue;throw e}a[s]=we(e,o,t,r),e[s]=e[o],o!==s&&delete e[o]}return[a]}),S.extend(`tuple`,(e,{list:t},n,r)=>{if(!Array.isArray(e))throw new x(`expected array but got ${e}`,n);let i=t.map((t,r)=>we(e,r,t,n));return r||i.push(...e.slice(t.length)),[i]});function Te(e,t){for(let n in t)n in e||(e[n]=t[n])}S.extend(`object`,(e,{dict:t},n,r)=>{if(!y(e))throw new x(`expected object but got ${e}`,n);let i={};for(let r in t){let a=we(e,r,t[r],n);(!v(a)||r in e)&&(i[r]=a)}return r||Te(i,e),[i]}),S.extend(`union`,(e,{list:t,toString:n},r,i)=>{let a=[];for(let n of t)try{return S.resolve(e,n,r,i)}catch(e){a.push(e)}throw new x(`expected ${n()} but got ${JSON.stringify(e)}`,r)}),S.extend(`intersect`,(e,{list:t,toString:n},r,i)=>{if(!t.length)return[e];let a;for(let i of t){let t=S.resolve(e,i,r,!0)[0];if(!v(t)){if(v(a))a=t;else if(typeof a!=typeof t)throw new x(`expected ${n()} but got ${JSON.stringify(e)}`,r);else if(typeof t==`object`)Te(a??={},t);else if(a!==t)throw new x(`expected ${n()} but got ${JSON.stringify(e)}`,r)}}return!i&&y(e)&&Te(a,e),[a]}),S.extend(`transform`,(e,{inner:t,callback:n,preserve:r},i)=>{let[a,o=e]=S.resolve(e,t,i,!0);return r?[n(a)]:[n(a),n(o)]});let Ee={};function De(e,t,n){Ee[e]=n,Object.assign(S,{[e](...n){let r=new S({type:e});return t.forEach((e,t)=>{switch(e){case`sKey`:r.sKey=n[t]??S.string();break;case`inner`:r.inner=S.from(n[t]);break;case`list`:r.list=n[t].map(S.from);break;case`dict`:r.dict=ee(n[t],S.from);break;case`bits`:r.bits={};for(let e in n[t])typeof n[t][e]==`number`&&(r.bits[e]=n[t][e]);break;case`callback`:{let e=r.callback=n[t];e.toJSON||=()=>e.toString();break}case`constructor`:{let e=r.constructor=n[t];typeof e==`function`&&(e.toJSON||=()=>e.name);break}default:r[e]=n[t]}}),e===`object`||e===`dict`?r.meta.default={}:e===`array`||e===`tuple`?r.meta.default=[]:e===`bitset`&&(r.meta.default=0),r}})}De(`is`,[`constructor`],({constructor:e})=>typeof e==`function`?e.name:e),De(`any`,[],()=>`any`),De(`never`,[],()=>`never`),De(`const`,[`value`],({value:e})=>typeof e==`string`?JSON.stringify(e):e),De(`string`,[],()=>`string`),De(`number`,[],()=>`number`),De(`boolean`,[],()=>`boolean`),De(`bitset`,[`bits`],()=>`bitset`),De(`function`,[],()=>`function`),De(`array`,[`inner`],({inner:e})=>`${e.toString(!0)}[]`),De(`dict`,[`inner`,`sKey`],({inner:e,sKey:t})=>`{ [key: ${t.toString()}]: ${e.toString()} }`),De(`tuple`,[`list`],({list:e})=>`[${e.map(e=>e.toString()).join(`, `)}]`),De(`object`,[`dict`],({dict:e})=>Object.keys(e).length===0?`{}`:`{ ${Object.entries(e).map(([e,t])=>`${e}${t.meta.required?``:`?`}: ${t.toString()}`).join(`, `)} }`),De(`union`,[`list`],({list:e},t)=>{let n=e.map(({toString:e})=>e()).join(` | `);return t?`(${n})`:n}),De(`intersect`,[`list`],({list:e})=>`${e.map(e=>e.toString(!0)).join(` & `)}`),De(`transform`,[`inner`,`callback`,`preserve`],({inner:e},t)=>e.toString(t));let Oe={'"':`"`,"\\":`\\`,"/":`/`,b:`\b`,f:`\f`,n:`
|
|
2
|
-
`,r:`\r`,t:` `},
|
|
3
|
-
`||e===`\r`||e===` `}function
|
|
1
|
+
window.__ModuleLoader__.load({id:`@deepseek-ai/dsh-client-ui-conversation`,factory:e=>{var t={exports:{}},n=t.exports;Object.defineProperty(n,Symbol.toStringTag,{value:`Module`});var r=Object.create,i=Object.defineProperty,a=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyNames,s=Object.getPrototypeOf,c=Object.prototype.hasOwnProperty,l=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var s=o(t),l=0,u=s.length,d;l<u;l++)d=s[l],!c.call(e,d)&&d!==n&&i(e,d,{get:(e=>t[e]).bind(null,d),enumerable:!(r=a(t,d))||r.enumerable});return e},u=(e,t,n)=>(n=e==null?{}:r(s(e)),l(t||!e||!e.__esModule||!c.call(e,`default`)?i(n,`default`,{value:e,enumerable:!0}):n,e));let d=e("@deepseek-ai/dsh-client-ui-primitives"),f=e("@deepseek-ai/dsh-client-store"),p=e("@deepseek-ai/dsh-client-ui-slots"),m=e("@deepseek-ai/cordis"),h=e("react/jsx-runtime"),g=e("react");g=u(g,1);let _=e("react-dom");function v(e){return e==null}function y(e){return e&&typeof e==`object`&&!Array.isArray(e)}function b(e,t){return Object.fromEntries(Object.entries(e).filter(([e,n])=>t(e,n)))}function x(e,t){return Object.fromEntries(Object.entries(e).map(([e,n])=>[e,t(n,e)]))}function ee(e,t,n){if(!t)return{...e};let r={};for(let i of t)(n||e[i]!==void 0)&&(r[i]=e[i]);return r}let te=Symbol.for(`cosmokit.volatile.write`);function ne(e,t=/* @__PURE__ */ new Set){if(typeof e==`function`)throw TypeError(`volatile config cannot contain functions`);if(typeof e!=`object`||!e)return e;if(t.has(e))throw TypeError(`volatile config cannot contain cycles`);t.add(e);try{if(Array.isArray(e))return Object.freeze(e.map(e=>ne(e,t)));if(Object.getPrototypeOf(e)!==Object.prototype&&Object.getPrototypeOf(e)!==null)throw TypeError(`volatile config objects must be plain objects or arrays`);return Object.freeze(Object.fromEntries(Object.entries(e).map(([e,n])=>[e,ne(n,t)])))}finally{t.delete(e)}}function re(e){let t=ne(e);return Object.freeze({get:()=>t,[te]:e=>{t=e}})}function ie(e){return typeof e==`object`&&!!e&&te in e}function ae(e,t){return arguments.length===1?t=>ae(e,t):e in globalThis&&t instanceof globalThis[e]||Object.prototype.toString.call(t).slice(8,-1)===e}function oe(e){return ae(`ArrayBuffer`,e)||ae(`SharedArrayBuffer`,e)}function se(e){return oe(e)||ArrayBuffer.isView(e)}let ce;(function(e){e.is=oe,e.isSource=se;function t(e){return ArrayBuffer.isView(e)?e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength):e}e.fromSource=t;function n(e){if(e=t(e),typeof Buffer<`u`)return Buffer.from(e).toString(`base64`);let n=``,r=new Uint8Array(e);for(let e=0;e<r.byteLength;e++)n+=String.fromCharCode(r[e]);return btoa(n)}e.toBase64=n;function r(e){return typeof Buffer<`u`?t(Buffer.from(e,`base64`)):Uint8Array.from(atob(e),e=>e.charCodeAt(0))}e.fromBase64=r;function i(e){return e=t(e),typeof Buffer<`u`?Buffer.from(e).toString(`hex`):Array.from(new Uint8Array(e),e=>e.toString(16).padStart(2,`0`)).join(``)}e.toHex=i;function a(e){if(typeof Buffer<`u`)return t(Buffer.from(e,`hex`));let n=e.length%2==0?e:e.slice(0,e.length-1),r=[];for(let e=0;e<n.length;e+=2)r.push(parseInt(`${n[e]}${n[e+1]}`,16));return Uint8Array.from(r).buffer}e.fromHex=a})(ce||={}),ce.fromBase64,ce.toBase64,ce.fromHex,ce.toHex;function le(e,t=/* @__PURE__ */ new Map){if(!e||typeof e!=`object`)return e;if(ae(`Date`,e))return new Date(e.valueOf());if(ae(`RegExp`,e))return new RegExp(e.source,e.flags);if(oe(e))return e.slice(0);if(ArrayBuffer.isView(e))return e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength);let n=t.get(e);if(n)return n;if(Array.isArray(e)){let n=[];return t.set(e,n),e.forEach((e,r)=>{n[r]=Reflect.apply(le,null,[e,t])}),n}let r=Object.create(Object.getPrototypeOf(e));t.set(e,r);for(let n of Reflect.ownKeys(e)){let i={...Reflect.getOwnPropertyDescriptor(e,n)};`value`in i&&(i.value=Reflect.apply(le,null,[i.value,t])),Reflect.defineProperty(r,n,i)}return r}function ue(e,t,n){let r=/* @__PURE__ */ new Set;function i(e,t){if(e===t)return!0;if(ie(e)||ie(t))return ie(e)&&ie(t);if(!n&&v(e)&&v(t))return!0;if(typeof e!=typeof t||typeof e!=`object`||!e||!t||r.has(e))return!1;function a(n,r){return n(e)?n(t)?r(e,t):!1:!n(t)&&void 0}r.add(e);try{return a(Array.isArray,(e,t)=>{if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!i(e[n],t[n]))return!1;return!0})??a(ae(`Date`),(e,t)=>e.valueOf()===t.valueOf())??a(ae(`URL`),(e,t)=>e.href===t.href)??a(ae(`RegExp`),(e,t)=>e.source===t.source&&e.flags===t.flags)??a(oe,(e,t)=>{if(e.byteLength!==t.byteLength)return!1;let n=new Uint8Array(e),r=new Uint8Array(t);for(let e=0;e<n.length;e++)if(n[e]!==r[e])return!1;return!0})??((!n||[e,t].every(e=>Object.getPrototypeOf(e)===Object.prototype||Object.getPrototypeOf(e)===null))&&Object.keys({...e,...t}).every(n=>i(e[n],t[n])))}finally{r.delete(e)}}return i(e,t)}let de;(function(e){e.millisecond=1;let t=e.second=1e3,n=e.minute=t*60,r=e.hour=n*60,i=e.day=r*24,a=e.week=i*7,o=(/* @__PURE__ */ new Date()).getTimezoneOffset();function s(e){o=e}e.setTimezoneOffset=s;function c(){return o}e.getTimezoneOffset=c;function l(e=/* @__PURE__ */ new Date,t){return typeof e==`number`&&(e=new Date(e)),t===void 0&&(t=o),Math.floor((e.valueOf()/n-t)/1440)}e.getDateNumber=l;function u(e,t){let r=new Date(e*i);return t===void 0&&(t=o),new Date(+r+t*n)}e.fromDateNumber=u;let d=RegExp(`^${[`w(?:eek(?:s)?)?`,`d(?:ay(?:s)?)?`,`h(?:our(?:s)?)?`,`m(?:in(?:ute)?(?:s)?)?`,`s(?:ec(?:ond)?(?:s)?)?`].map(e=>`(\\d+(?:\\.\\d+)?${e})?`).join(``)}$`);function f(e){let o=d.exec(e);return o?(parseFloat(o[1])*a||0)+(parseFloat(o[2])*i||0)+(parseFloat(o[3])*r||0)+(parseFloat(o[4])*n||0)+(parseFloat(o[5])*t||0):0}e.parseTime=f;function p(e){let t=f(e);return t?e=Date.now()+t:/^\d{1,2}(:\d{1,2}){1,2}$/.test(e)?e=`${(/* @__PURE__ */ new Date()).toLocaleDateString()}-${e}`:/^\d{1,2}-\d{1,2}-\d{1,2}(:\d{1,2}){1,2}$/.test(e)&&(e=`${(/* @__PURE__ */ new Date()).getFullYear()}-${e}`),e?new Date(e):/* @__PURE__ */ new Date}e.parseDate=p;function m(e){let a=Math.abs(e);return a>=i-r/2?Math.round(e/i)+`d`:a>=r-n/2?Math.round(e/r)+`h`:a>=n-t/2?Math.round(e/n)+`m`:a>=t?Math.round(e/t)+`s`:e+`ms`}e.format=m;function h(e,t=2){return e.toString().padStart(t,`0`)}e.toDigits=h;function g(e,t=/* @__PURE__ */ new Date){return e.replace(`yyyy`,t.getFullYear().toString()).replace(`yy`,t.getFullYear().toString().slice(2)).replace(`MM`,h(t.getMonth()+1)).replace(`dd`,h(t.getDate())).replace(`hh`,h(t.getHours())).replace(`mm`,h(t.getMinutes())).replace(`ss`,h(t.getSeconds())).replace(`SSS`,h(t.getMilliseconds(),3))}e.template=g})(de||={});let fe=Symbol.for(`schemastery`),pe=Symbol.for(`ValidationError`);globalThis.__schemastery_index__??=0,globalThis.__schemastery_refs__=void 0;var S=class extends TypeError{options;name=`ValidationError`;constructor(e,t){let n=`$`;for(let e of t.path||[])typeof e==`string`?n+=`.`+e:typeof e==`number`?n+=`[`+e+`]`:typeof e==`symbol`&&(n+=`[Symbol(${e.toString()})]`);n.startsWith(`.`)&&(n=n.slice(1)),super((n===`$`?``:`${n} `)+e),this.options=t}static is(e){return!!e?.[pe]}};Object.defineProperty(S.prototype,pe,{value:!0});let C=function(e){let t=function(e,n={}){return C.resolve(e,t,n)[0]};if(e.refs){let t=x(e.refs,e=>new C(e)),n=e=>t[e];for(let e in t){let r=t[e];r.sKey=n(r.sKey),r.inner=n(r.inner),r.list=r.list&&r.list.map(n),r.dict=r.dict&&x(r.dict,n)}return t[e.uid]}if(Object.assign(t,e),typeof t.callback==`string`)try{t.callback=Function(`return `+t.callback)()}catch{}return Object.defineProperty(t,"uid",{value:globalThis.__schemastery_index__++}),Object.setPrototypeOf(t,C.prototype),t.meta||={},t.toString=t.toString.bind(t),t};C.prototype=Object.create(Function.prototype),C.prototype[fe]=!0,Object.defineProperty(C.prototype,"~standard",{get(){return{version:1,vendor:`schemastery`,validate:e=>{try{return{value:C.resolve(e,this,{})[0]}}catch(e){if(S.is(e))return{issues:[{message:e.message,path:e.options.path}]};throw e}}}}}),C.ValidationError=S,C.prototype.toJSON=function(){if(globalThis.__schemastery_refs__)return globalThis.__schemastery_refs__[this.uid]??=JSON.parse(JSON.stringify({...this})),this.uid;globalThis.__schemastery_refs__={[this.uid]:{...this}},globalThis.__schemastery_refs__[this.uid]=JSON.parse(JSON.stringify({...this}));let e={uid:this.uid,refs:globalThis.__schemastery_refs__};return globalThis.__schemastery_refs__=void 0,e},C.prototype.set=function(e,t){return this.dict[e]=t,this},C.prototype.push=function(e){return this.list.push(e),this};function me(e,t){let n=typeof e==`string`?{"":e}:{...e};for(let e in t){let r=t[e];r?.$description||r?.$desc?n[e]=r.$description||r.$desc:typeof r==`string`&&(n[e]=r)}return n}function he(e){return e?.$value??e?.$inner}function ge(e){return b(e??{},e=>!e.startsWith(`$`))}C.prototype.i18n=function(e){let t=C(this),n=me(t.meta.description,e);return Object.keys(n).length&&(t.meta.description=n),t.dict&&=x(t.dict,(t,n)=>t.i18n(x(e,e=>he(e)?.[n]??e?.[n]))),t.list&&=t.list.map((t,n)=>t.i18n(x(e,(e={})=>Array.isArray(he(e))?he(e)[n]:Array.isArray(e)?e[n]:ge(e)))),t.inner&&=t.inner.i18n(x(e,e=>he(e)?he(e):ge(e))),t.sKey&&=t.sKey.i18n(x(e,e=>e?.$key)),t},C.prototype.extra=function(e,t){let n=C(this);return n.meta={...n.meta,[e]:t},n};for(let e of[`required`,`disabled`,`collapse`,`hidden`,`loose`])Object.assign(C.prototype,{[e](t=!0){let n=C(this);return n.meta={...n.meta,[e]:t},n}});C.prototype.deprecated=function(){let e=C(this);return e.meta.badges||=[],e.meta.badges.push({text:`deprecated`,type:`danger`}),e},C.prototype.experimental=function(){let e=C(this);return e.meta.badges||=[],e.meta.badges.push({text:`experimental`,type:`warning`}),e},C.prototype.pattern=function(e){let t=C(this),n=ee(e,[`source`,`flags`]);return t.meta={...t.meta,pattern:n},t},C.prototype.simplify=function(e){if(ie(e)&&(e=e.get()),ue(e,this.meta.default,this.type===`dict`))return null;if(v(e))return e;if(this.type===`object`||this.type===`dict`){let t={};for(let n in e){let r=(this.type===`object`?this.dict[n]:this.inner)?.simplify(e[n]);(this.type===`dict`||!v(r))&&(t[n]=r)}return ue(t,this.meta.default,this.type===`dict`)?null:t}if(this.type===`array`||this.type===`tuple`){let t=[];return e.forEach((e,n)=>{let r=this.type===`array`?this.inner:this.list[n],i=r?r.simplify(e):e;t.push(i)}),t}if(this.type===`intersect`){let t={};for(let n of this.list)Object.assign(t,n.simplify(e));return t}if(this.type===`union`)for(let t of this.list)try{return C.resolve(e,t,{}),t.simplify(e)}catch{}return e},C.prototype.toString=function(e){return Te[this.type]?.(this,e)??`Schema<${this.type}>`},C.prototype.role=function(e,t){let n=C(this);return n.meta={...n.meta,role:e,extra:t},n};for(let e of[`default`,`link`,`comment`,`description`,`max`,`min`,`step`])Object.assign(C.prototype,{[e](t){let n=C(this);return n.meta={...n.meta,[e]:t},n}});C.prototype.volatile=function(){if(this.meta.volatile)throw TypeError(`volatile schema is already wrapped`);return this.extra(`volatile`,!0)};let _e={},ve=Symbol(`checked-volatile-schema`);function ye(e,t=[],n=!1,r=/* @__PURE__ */ new Map){let i=r.get(e)??/* @__PURE__ */ new Set;if(i.has(n))return;if(i.add(n),r.set(e,i),e.meta?.volatile&&n)throw new S(`volatile fields require a fixed object path without an enclosing volatile field`,{path:t});let a=n||!!e.meta?.volatile;if(e.dict)for(let[n,i]of Object.entries(e.dict))ye(i,[...t,n],a,r);if(e.sKey&&ye(e.sKey,[...t,`<key>`],!0,r),e.inner&&(e.type!==`lazy`||e.inner[fe])&&ye(e.inner,[...t,`*`],!0,r),e.list)for(let n=0;n<e.list.length;n++)ye(e.list[n],[...t,String(n)],!0,r)}C.extend=function(e,t){_e[e]=t},C.resolve=function(e,t,n={},r=!1){if(!t)return[e];if(n[ve]||(ye(t,n.path),n={...n,[ve]:!0}),t.meta?.volatile){let i=C(t);i.meta={...t.meta,volatile:!1};let[a,o]=C.resolve(e,i,n,r);try{return[re(a),o]}catch(e){throw new S(e instanceof Error?e.message:String(e),n)}}if(n.ignore?.(e,t))return[e];if(v(e)&&t.type!==`lazy`){if(t.meta.required)throw new S(`missing required value`,n);let r=t,i=t.meta.default;for(;r?.type===`intersect`&&v(i);)r=r.list[0],i=r?.meta.default;if(v(i))return[e];e=le(i)}let i=_e[t.type];if(!i)throw new S(`unsupported type "${t.type}"`,n);try{return i(e,t,n,r)}catch(e){if(!t.meta.loose)throw e;return[t.meta.default]}},C.from=function(e){if(v(e))return C.any();if([`string`,`number`,`boolean`].includes(typeof e))return C.const(e).required();if(e[fe])return e;if(typeof e==`function`)switch(e){case String:return C.string().required();case Number:return C.number().required();case Boolean:return C.boolean().required();case Function:return C.function().required();default:return C.is(e).required()}else throw TypeError(`cannot infer schema from ${e}`)},C.lazy=function(e){let t=new C({type:`lazy`,builder:e,inner:{toJSON:()=>(t.inner[fe]||(t.inner=t.builder(),t.inner.meta={...t.meta,...t.inner.meta}),t.inner.toJSON())}});return t},C.natural=function(){return C.number().step(1).min(0)},C.percent=function(){return C.number().step(.01).min(0).max(1).role(`slider`)},C.date=function(){return C.union([C.is(Date),C.transform(C.string().role(`datetime`),(e,t)=>{let n=new Date(e);if(isNaN(+n))throw new S(`invalid date "${e}"`,t);return n},!0)])},C.regExp=function(e=``){return C.union([C.is(RegExp),C.transform(C.string().role(`regexp`,{flag:e}),(t,n)=>{try{return new RegExp(t,e)}catch(e){throw new S(e.message,n)}},!0)])},C.arrayBuffer=function(e){return C.union([C.is(ArrayBuffer),C.is(SharedArrayBuffer),C.transform(C.any(),(e,t)=>{if(ce.isSource(e))return ce.fromSource(e);throw new S(`expected ArrayBufferSource but got ${e}`,t)},!0),...e?[C.transform(C.string(),(t,n)=>{try{return e===`base64`?ce.fromBase64(t):ce.fromHex(t)}catch(e){throw new S(e.message,n)}},!0)]:[]])},C.extend(`lazy`,(e,t,n,r)=>(t.inner[fe]||(t.inner=t.builder(),t.inner.meta={...t.meta,...t.inner.meta},ye(t.inner,n.path,!0)),C.resolve(e,t.inner,n,r))),C.extend(`any`,e=>[e]),C.extend(`never`,(e,t,n)=>{throw new S(`expected nullable but got ${e}`,n)}),C.extend(`const`,(e,{value:t},n)=>{if(ue(e,t))return[t];throw new S(`expected ${t} but got ${e}`,n)});function be(e,t,n,r,i=!1){let{max:a=1/0,min:o=-1/0}=t;if(e>a)throw new S(`expected ${n} <= ${a} but got ${e}`,r);if(e<o&&!i)throw new S(`expected ${n} >= ${o} but got ${e}`,r)}C.extend(`string`,(e,{meta:t},n)=>{if(typeof e!=`string`)throw new S(`expected string but got ${e}`,n);if(t.pattern){let r=new RegExp(t.pattern.source,t.pattern.flags);if(!r.test(e))throw new S(`expect string to match regexp ${r}`,n)}return be(e.length,t,`string length`,n),[e]});function xe(e,t){let n=e.toString();if(n.includes(`e`))return e*10**t;let r=n.indexOf(`.`);if(r===-1)return e*10**t;let i=n.slice(r+1),a=n.slice(0,r);return i.length<=t?+(a+i.padEnd(t,`0`)):+(a+i.slice(0,t)+`.`+i.slice(t))}function Se(e,t,n){if(n=Math.abs(n),!/^\d+\.\d+$/.test(n.toString()))return(e-t)%n===0;let r=n.toString().indexOf(`.`),i=n.toString().slice(r+1).length;return Math.abs(xe(e,i)-xe(t,i))%xe(n,i)===0}C.extend(`number`,(e,{meta:t},n)=>{if(typeof e!=`number`)throw new S(`expected number but got ${e}`,n);be(e,t,`number`,n);let{step:r}=t;if(r&&!Se(e,t.min??0,r))throw new S(`expected number multiple of ${r} but got ${e}`,n);return[e]}),C.extend(`boolean`,(e,t,n)=>{if(typeof e==`boolean`)return[e];throw new S(`expected boolean but got ${e}`,n)}),C.extend(`bitset`,(e,{bits:t,meta:n},r)=>{let i=0,a=[];if(typeof e==`number`){i=e;for(let n in t)e&t[n]&&a.push(n)}else if(Array.isArray(e)){a=e;for(let e of a){if(typeof e!=`string`)throw new S(`expected string but got ${e}`,r);e in t&&(i|=t[e])}}else throw new S(`expected number or array but got ${e}`,r);return i===n.default?[i]:[i,a]}),C.extend(`function`,(e,t,n)=>{if(typeof e==`function`)return[e];throw new S(`expected function but got ${e}`,n)}),C.extend(`is`,(e,{constructor:t},n)=>{if(typeof t==`function`){if(e instanceof t)return[e];throw new S(`expected ${t.name} but got ${e}`,n)}{if(v(e))throw new S(`expected ${t} but got ${e}`,n);let r=Object.getPrototypeOf(e);for(;r;){if(r.constructor?.name===t)return[e];r=Object.getPrototypeOf(r)}throw new S(`expected ${t} but got ${e}`,n)}});function Ce(e,t,n,r){try{let[i,a]=C.resolve(e[t],n,{...r,path:[...r.path||[],t]});return a!==void 0&&(e[t]=a),i}catch(i){if(!r?.autofix)throw i;return delete e[t],n.meta.volatile?re(n.meta.default):n.meta.default}}C.extend(`array`,(e,{inner:t,meta:n},r)=>{if(!Array.isArray(e))throw new S(`expected array but got ${e}`,r);return be(e.length,n,`array length`,r,!v(t.meta.default)),[e.map((n,i)=>Ce(e,i,t,r))]}),C.extend(`dict`,(e,{inner:t,sKey:n},r,i)=>{if(!y(e))throw new S(`expected object but got ${e}`,r);let a={};for(let o in e){let s;try{s=C.resolve(o,n,r)[0]}catch(e){if(i)continue;throw e}a[s]=Ce(e,o,t,r),e[s]=e[o],o!==s&&delete e[o]}return[a]}),C.extend(`tuple`,(e,{list:t},n,r)=>{if(!Array.isArray(e))throw new S(`expected array but got ${e}`,n);let i=t.map((t,r)=>Ce(e,r,t,n));return r||i.push(...e.slice(t.length)),[i]});function we(e,t){for(let n in t)n in e||(e[n]=t[n])}C.extend(`object`,(e,{dict:t},n,r)=>{if(!y(e))throw new S(`expected object but got ${e}`,n);let i={};for(let r in t){let a=Ce(e,r,t[r],n);(!v(a)||r in e)&&(i[r]=a)}return r||we(i,e),[i]}),C.extend(`union`,(e,{list:t,toString:n},r,i)=>{let a=[];for(let n of t)try{return C.resolve(e,n,r,i)}catch(e){a.push(e)}throw new S(`expected ${n()} but got ${JSON.stringify(e)}`,r)}),C.extend(`intersect`,(e,{list:t,toString:n},r,i)=>{if(!t.length)return[e];let a;for(let i of t){let t=C.resolve(e,i,r,!0)[0];if(!v(t)){if(v(a))a=t;else if(typeof a!=typeof t)throw new S(`expected ${n()} but got ${JSON.stringify(e)}`,r);else if(typeof t==`object`)we(a??={},t);else if(a!==t)throw new S(`expected ${n()} but got ${JSON.stringify(e)}`,r)}}return!i&&y(e)&&we(a,e),[a]}),C.extend(`transform`,(e,{inner:t,callback:n,preserve:r},i)=>{let[a,o=e]=C.resolve(e,t,i,!0);return r?[n(a)]:[n(a),n(o)]});let Te={};function Ee(e,t,n){Te[e]=n,Object.assign(C,{[e](...n){let r=new C({type:e});return t.forEach((e,t)=>{switch(e){case`sKey`:r.sKey=n[t]??C.string();break;case`inner`:r.inner=C.from(n[t]);break;case`list`:r.list=n[t].map(C.from);break;case`dict`:r.dict=x(n[t],C.from);break;case`bits`:r.bits={};for(let e in n[t])typeof n[t][e]==`number`&&(r.bits[e]=n[t][e]);break;case`callback`:{let e=r.callback=n[t];e.toJSON||=()=>e.toString();break}case`constructor`:{let e=r.constructor=n[t];typeof e==`function`&&(e.toJSON||=()=>e.name);break}default:r[e]=n[t]}}),e===`object`||e===`dict`?r.meta.default={}:e===`array`||e===`tuple`?r.meta.default=[]:e===`bitset`&&(r.meta.default=0),r}})}Ee(`is`,[`constructor`],({constructor:e})=>typeof e==`function`?e.name:e),Ee(`any`,[],()=>`any`),Ee(`never`,[],()=>`never`),Ee(`const`,[`value`],({value:e})=>typeof e==`string`?JSON.stringify(e):e),Ee(`string`,[],()=>`string`),Ee(`number`,[],()=>`number`),Ee(`boolean`,[],()=>`boolean`),Ee(`bitset`,[`bits`],()=>`bitset`),Ee(`function`,[],()=>`function`),Ee(`array`,[`inner`],({inner:e})=>`${e.toString(!0)}[]`),Ee(`dict`,[`inner`,`sKey`],({inner:e,sKey:t})=>`{ [key: ${t.toString()}]: ${e.toString()} }`),Ee(`tuple`,[`list`],({list:e})=>`[${e.map(e=>e.toString()).join(`, `)}]`),Ee(`object`,[`dict`],({dict:e})=>Object.keys(e).length===0?`{}`:`{ ${Object.entries(e).map(([e,t])=>`${e}${t.meta.required?``:`?`}: ${t.toString()}`).join(`, `)} }`),Ee(`union`,[`list`],({list:e},t)=>{let n=e.map(({toString:e})=>e()).join(` | `);return t?`(${n})`:n}),Ee(`intersect`,[`list`],({list:e})=>`${e.map(e=>e.toString(!0)).join(` & `)}`),Ee(`transform`,[`inner`,`callback`,`preserve`],({inner:e},t)=>e.toString(t));let De={'"':`"`,"\\":`\\`,"/":`/`,b:`\b`,f:`\f`,n:`
|
|
2
|
+
`,r:`\r`,t:` `},Oe=/[\\\u0000-\u001f]/u;function w(e){return e===` `||e===`
|
|
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(Oe),u=Math.min(l<0?c.length:l,n-t.length);if(u>0){r&&(t.text+=c.slice(0,u)),t.at+=u,t.length+=u,t.at===o+s.length&&a++;continue}let d=c.length>1?c[1]:t.at+1<i?this.chunks[a+1][0]:void 0,f,p=2;if(c[0]===`\\`&&d===void 0&&e.end<0)return;if(c[0]===`\\`&&d===`u`){let n=this.slice(t.at+2,Math.min(i,t.at+6)),r=!0;for(let e=0;e<n.length;e++)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=De[d]);if(f===void 0){e.invalidAt=t.at,this.#f=!0;return}for(r&&(t.text+=f),t.length++,t.at+=p;a<this.chunks.length&&t.at>=this.#e[a];)a++}}scan(){if(this.object===void 0&&this.#n!==this.#t)for(let e=this.chunkAt(this.#n);e<this.chunks.length&&this.#d===void 0;e++){let t=this.chunks[e],n=e===0?0:this.#e[e-1];for(let e=this.#n-n;e<t.length&&this.#r!==`invalid`;e++){if(this.#r===`string`||this.#r===`nested`&&this.#u){let n=this.stringBoundary(t,e);if(this.#n+=n-e,e=n,e===t.length)break}this.step(t[e],this.#n),this.#n++}}}stringBoundary(e,t){let n=t;for(;;){let t=e.indexOf(`"`,n),r=t<0?e.length:t;if(this.#r===`string`){let t=this.#c;!t.needsDecoding&&Oe.test(e.slice(n,r))&&(t.needsDecoding=!0)}let i=r;for(;i>n&&e[i-1]===`\\`;)i--;let a=(r-i)%2==1!==(i===n&&this.#i);if(this.#i=t<0&&a,t<0||!a)return r;n=t+1}}step(e,t){switch(this.#r){case`root`:if(w(e))return;if(e===`{`){this.#r=`key-or-end`;return}this.fail();return;case`key-or-end`:if(w(e))return;if(e===`}`){this.#r=`closed`;return}if(e===`"`){this.beginKey(t);return}this.fail();return;case`key-only`:if(w(e))return;if(e===`"`){this.beginKey(t);return}this.fail();return;case`key`:this.stepKey(e,t);return;case`colon`:if(w(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(w(e))return;if(e===`,`){this.#r=`key-only`;return}if(e===`}`){this.#r=`closed`;return}this.fail();return;case`closed`:if(w(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:
|
|
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){w(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===`}`||w(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:je(e.groups)}return{upserts:t,removes:n}}},We=class{store;key;listeners=/* @__PURE__ */ new Set;published;constructor(e,t){this.store=e,this.key=t,this.published=e.get(t)}getSnapshot=()=>this.store.get(this.key);subscribe=e=>(this.listeners.add(e),()=>{this.listeners.delete(e)});publish(){let e=this.getSnapshot();this.published!==e&&(this.published=e,(0,f.notifySubscribers)(this.listeners,`[ui-conversation] Location data ${this.key}`))}},Ge=class{markDirty;entries=/* @__PURE__ */ new Map;sources=/* @__PURE__ */ new Map;dirtyKeys=/* @__PURE__ */ new Set;constructor(e){this.markDirty=e}get(e){return this.entries.get(e)?.value}source(e){let t=this.sources.get(e);return t===void 0&&(t=new We(this,e),this.sources.set(e,t)),t}remove(e,t){return this.entries.get(t)?.owner===e&&(this.entries.delete(t),this.changed(t),!0)}set(e,t,n){let r=this.entries.get(t);if(r!==void 0&&r.owner!==e)throw Error(`conversation Location data "${t}" is already owned by ${r.owner}`);return r?.value!==n&&(this.entries.set(t,{owner:e,value:n}),this.changed(t),!0)}replace(e){let t=[];for(let n of/* @__PURE__ */ new Set([...this.entries.keys(),...e.keys()])){let r=this.entries.get(n),i=e.get(n);(r?.owner!==i?.owner||r?.value!==i?.value)&&t.push(n)}if(t.length===0)return!1;this.entries=new Map(e);for(let e of t)this.changed(e);return!0}publish(){let e=[...this.dirtyKeys];this.dirtyKeys.clear();for(let t of e)this.sources.get(t)?.publish()}changed(e){this.dirtyKeys.add(e),this.markDirty(this)}};let Ke={kind:`session`},qe={kind:`unresolved`};function Je(e){let t=e.data;if(t.turn===null)return{session:!0,location:void 0};let n=Number.isSafeInteger(t.turn)&&t.turn>=0?t.turn:void 0,r=Number.isSafeInteger(t.step)&&t.step>=0?t.step:void 0;return n===void 0?r===void 0?{location:void 0}:{step:r,location:void 0}:r===void 0?{turn:n,location:void 0}:{turn:n,step:r,location:void 0}}function Ye(e,t){return e.length===t.length&&e.every((e,n)=>e===t[n])}function Xe(e,t){return e!==void 0&&e.start===t.start&&e.end===t.end&&e.status===t.status&&e.data===t.data}function Ze(e,t){return e!==void 0&&e.start===t.start&&e.end===t.end&&e.status===t.status&&e.data===t.data&&Ye(e.steps,t.steps)}function Qe(e,t){return e===void 0||t===void 0||e.kind!==t.kind?e===t:e.kind===`session`||e.kind===`unresolved`?!0:t.kind===`session`||t.kind===`unresolved`?!1:e.kind===`turn`||t.kind===`turn`?e.kind===`turn`&&t.kind===`turn`&&e.turn===t.turn:e.turn===t.turn&&e.step===t.step}var $e=class{coordinates=/* @__PURE__ */ new Map;eventKeysByTurn=/* @__PURE__ */ new Map;stepsByTurn=/* @__PURE__ */ new Map;timeline={turnOrder:[],turns:/* @__PURE__ */ new Map};turnDataStores=/* @__PURE__ */ new Map;stepDataStores=/* @__PURE__ */ new Map;dirtyDataStores=/* @__PURE__ */ new Set;changedTurns=/* @__PURE__ */ new Set;currentTurn;currentStep;snapshot(){return this.timeline}takeChangedTurns(){let e=[...this.changedTurns];return this.changedTurns.clear(),e}replaceData(e){let t=/* @__PURE__ */ new Map,n=/* @__PURE__ */ new Map;for(let{owner:r,data:i}of e){let e=i.kind===`turn`?t.get(i.turn)??/* @__PURE__ */ new Map:n.get(et(i.turn,tt(i)))??/* @__PURE__ */ new Map,a=e.get(i.key);if(a!==void 0&&a.owner!==r)throw Error(`conversation Location data "${i.key}" is already owned by ${a.owner}`);e.set(i.key,{owner:r,value:i.value}),i.kind===`turn`?t.set(i.turn,e):n.set(et(i.turn,tt(i)),e)}let r=!1;for(let e of/* @__PURE__ */ new Set([...this.turnDataStores.keys(),...t.keys()]))r=this.mutableTurnData(e).replace(t.get(e)??/* @__PURE__ */ new Map)||r;for(let e of/* @__PURE__ */ new Set([...this.stepDataStores.keys(),...n.keys()]))r=this.mutableStepData(e).replace(n.get(e)??/* @__PURE__ */ new Map)||r;return r}applyData(e){let t=!1;for(let n of e){let e=n.previous;e!==null&&(t=this.storeFor(e).remove(n.owner,e.key)||t)}for(let n of e){let e=n.next;e!==null&&(t=this.storeFor(e).set(n.owner,e.key,e.value)||t)}return t}publishData(){let e=[...this.dirtyDataStores];this.dirtyDataStores.clear();for(let t of e)t.publish()}locationOf(e){return this.coordinates.get(Re(e))?.location??Ke}rebuild(e){let t=this.coordinates,n=/* @__PURE__ */ new Map,r=/* @__PURE__ */ new Map,i,a,o=(e,t)=>{let r=n.get(e);return r===void 0?(r={turn:e,firstSeq:t,steps:/* @__PURE__ */ new Map},n.set(e,r)):r.firstSeq=Math.min(r.firstSeq,t),r},s=(e,t,n)=>{let r=o(e,n),i=r.steps.get(t);return i===void 0?(i={turn:e,step:t,firstSeq:n},r.steps.set(t,i)):i.firstSeq=Math.min(i.firstSeq,n),i};for(let{event:t}of e){let e=Je(t);t.type===`turn/start`&&(i=t.data.turn,a=void 0),t.type===`step/start`&&(i=t.data.turn,a=t.data.step),e.session!==!0&&e.turn!==void 0&&(i!==e.turn&&(a=void 0),i=e.turn,e.step!==void 0&&(a=e.step));let n=e.session===!0?void 0:e.turn??i,c=e.session===!0||t.type===`turn/start`||t.type===`turn/end`?void 0:e.step??(n===i?a:void 0);r.set(Re(t),{...n===void 0?{}:{turn:n},...n===void 0||c===void 0?{}:{step:c},location:void 0}),n!==void 0&&o(n,t.seq),n!==void 0&&c!==void 0&&s(n,c,t.seq),t.type===`turn/start`?o(t.data.turn,t.seq).start=t:t.type===`turn/end`?o(t.data.turn,t.seq).end=t:t.type===`step/start`?s(t.data.turn,t.data.step,t.seq).start=t:t.type===`step/end`&&(s(t.data.turn,t.data.step,t.seq).end=t),t.type===`step/end`&&i===t.data.turn&&a===t.data.step&&(a=void 0),t.type===`turn/end`&&i===t.data.turn&&(i=void 0,a=void 0)}let c=this.timeline.turns,l=/* @__PURE__ */ new Map,u=[...n.values()].sort((e,t)=>e.firstSeq-t.firstSeq);for(let e of u){let t=c.get(e.turn),n=new Map(t?.steps.map(e=>[e.step,e])??[]),r=[...e.steps.values()].sort((e,t)=>e.firstSeq-t.firstSeq).map(e=>{let t={turn:e.turn,step:e.step,start:e.start,end:e.end,status:e.end===void 0?e.start===void 0?`unknown`:`open`:`closed`,data:this.stepData(e.turn,e.step)},r=n.get(e.step);return Xe(r,t)?r:t}),i={turn:e.turn,start:e.start,end:e.end,status:e.end===void 0?e.start===void 0?`unknown`:`open`:`closed`,steps:r,data:this.turnData(e.turn)};l.set(e.turn,Ze(t,i)?t:i)}let d=u.map(e=>e.turn),f=this.timeline.turnOrder.length===d.length&&this.timeline.turnOrder.every((e,t)=>e===d[t])?this.timeline.turnOrder:d,p=c.size===l.size;if(p){for(let[e,t]of l)if(c.get(e)!==t){p=!1;break}}for(let e of/* @__PURE__ */ new Set([...c.keys(),...l.keys()]))c.get(e)!==l.get(e)&&this.changedTurns.add(e);this.timeline=p&&f===this.timeline.turnOrder?this.timeline:{turnOrder:f,turns:l},this.stepsByTurn.clear();for(let[e,t]of this.timeline.turns)this.stepsByTurn.set(e,new Map(t.steps.map(e=>[e.step,e])));this.coordinates=r,this.eventKeysByTurn=/* @__PURE__ */ new Map;for(let{event:t}of e){let e=Re(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=Re(n);Qe(t.get(e)?.location,this.coordinates.get(e)?.location)||m.add(e)}return m}appendBoundary(e){if(e.type!==`turn/start`&&e.type!==`turn/end`&&e.type!==`step/start`&&e.type!==`step/end`)throw Error(`conversation Location boundary expected, received ${e.type}`);let t=Je(e);e.type===`turn/start`?(this.currentTurn=e.data.turn,this.currentStep=void 0):e.type===`step/start`&&(this.currentTurn=e.data.turn,this.currentStep=e.data.step),t.turn!==void 0&&(this.currentTurn!==t.turn&&(this.currentStep=void 0),this.currentTurn=t.turn,t.step!==void 0&&(this.currentStep=t.step));let n=t.turn??this.currentTurn;if(n===void 0)throw Error(`conversation boundary ${e.type} has no turn`);let r=e.type===`turn/start`||e.type===`turn/end`?void 0:t.step??(n===this.currentTurn?this.currentStep:void 0);this.coordinates.set(e.seq,{turn:n,...r===void 0?{}:{step:r},location:this.coordinates.get(e.seq)?.location}),this.indexTurnEvent(n,e.seq);let i=this.timeline.turns.get(n),a=i?.steps??[];if(e.type===`step/start`||e.type===`step/end`){let t=e.data.step,r=this.stepsByTurn.get(n)??/* @__PURE__ */ new Map,i=r.get(t),o={turn:n,step:t,start:e.type===`step/start`?e:i?.start,end:e.type===`step/end`?e:i?.end,status:e.type===`step/end`||i?.end!==void 0?`closed`:`open`,data:this.stepData(n,t)},s=Xe(i,o)?i:o;r.set(t,s),this.stepsByTurn.set(n,r);let c=a.findIndex(e=>e.step===t);a=c<0?[...a,s]:a.map((e,t)=>t===c?s:e)}let o={turn:n,start:e.type===`turn/start`?e:i?.start,end:e.type===`turn/end`?e:i?.end,status:e.type===`turn/end`||i?.end!==void 0?`closed`:e.type===`turn/start`||i?.start!==void 0?`open`:`unknown`,steps:a,data:this.turnData(n)},s=Ze(i,o)?i:o,c=new Map(this.timeline.turns);c.set(n,s);let l=i===void 0?[...this.timeline.turnOrder,n]:this.timeline.turnOrder;this.timeline={turnOrder:l,turns:c},s!==i&&this.changedTurns.add(n);let u=/* @__PURE__ */ new Set;for(let e of this.eventKeysByTurn.get(n)??[]){let t=this.coordinates.get(e),n=t.location,r=this.resolve(e);t.location=r,Qe(n,r)||u.add(e)}return e.type===`step/end`&&this.currentTurn===e.data.turn&&this.currentStep===e.data.step&&(this.currentStep=void 0),e.type===`turn/end`&&this.currentTurn===e.data.turn&&(this.currentTurn=void 0,this.currentStep=void 0),u}appendNonBoundary(e){let t=Re(e),n=Je(e);if(n.session===!0){this.coordinates.set(t,{location:Ke});return}n.turn!==void 0&&(this.currentTurn!==n.turn&&(this.currentStep=void 0),this.currentTurn=n.turn,n.step!==void 0&&(this.currentStep=n.step));let r=n.turn??this.currentTurn,i=n.step??(r===this.currentTurn?this.currentStep:void 0),a=n.turn!==void 0&&n.step!==void 0?n:{...r===void 0?{}:{turn:r},...r===void 0||i===void 0?{}:{step:i},location:void 0};this.coordinates.set(t,a),r!==void 0&&this.indexTurnEvent(r,t),a.location=this.resolve(t)}removeAssistantTransients(e){for(let t of e){let e=Re(t),n=this.coordinates.get(e)?.turn;if(n!==void 0){let t=this.eventKeysByTurn.get(n);t?.delete(e),t?.size===0&&this.eventKeysByTurn.delete(n)}this.coordinates.delete(e)}}insertAssistantSettlement(e){let t={turn:e.data.turn,step:e.data.step,location:void 0};this.coordinates.set(e.seq,t),this.indexTurnEvent(e.data.turn,e.seq),t.location=this.resolve(e.seq)}indexTurnEvent(e,t){let n=this.eventKeysByTurn.get(e);n===void 0&&(n=/* @__PURE__ */ new Set,this.eventKeysByTurn.set(e,n)),n.add(t)}turnData(e){return this.mutableTurnData(e)}stepData(e,t){return this.mutableStepData(et(e,t))}mutableTurnData(e){let t=this.turnDataStores.get(e)??this.createDataStore(e);return this.turnDataStores.set(e,t),t}mutableStepData(e){let t=this.stepDataStores.get(e)??this.createDataStore(Number(e.slice(0,e.indexOf(`:`))));return this.stepDataStores.set(e,t),t}createDataStore(e){return new Ge(t=>{this.dirtyDataStores.add(t),this.changedTurns.add(e)})}storeFor(e){return e.kind===`turn`?this.mutableTurnData(e.turn):this.mutableStepData(et(e.turn,tt(e)))}resolve(e){let t=this.coordinates.get(e);if(t?.turn===void 0)return Ke;let n=this.timeline.turns.get(t.turn);if(n===void 0)return qe;if(t.step===void 0)return{kind:`turn`,turn:n};let r=this.stepsByTurn.get(t.turn)?.get(t.step);return r===void 0?{kind:`turn`,turn:n}:{kind:`step`,turn:n,step:r}}};function et(e,t){return`${e}:${t}`}function tt(e){if(e.kind===`step`&&e.step!==void 0)return e.step;throw Error(`conversation Step data "${e.key}" requires a step`)}let nt={none:0,"animation-frame":1,immediate:2},rt=[`step`,`turn`];function it(){return{step:null,turn:null}}function at(e,t){return nt[e]>=nt[t]?e:t}function ot(e,t){return e.start===void 0?t.start===void 0?0:1:t.start===void 0?-1:ze(e.start.event,t.start.event)}function st(e,t){let n=0,r=e.length;for(;n<r;){let i=n+Math.floor((r-n)/2),a=e[i]?.start;a!==void 0&&ze(a.event,t)<0?n=i+1:r=i}return n}function ct(e){return{key:e.key,kind:e.kind,id:e.id,matches:e.matches,start:e.start,state:e.state,current:e.current}}function lt(e,t,n){let r=[],i=0,a=0;for(;i<t.length||a<n.length;){let o=t[i],s=n[a],c=o===void 0?1:s===void 0?-1:ze(o.event,s.event);if(c===0)throw Error(`conversation Context ${e} received duplicate Match ${o?.event.seq}`);c<0?(r.push(o),i++):(r.push(s),a++)}return r}function ut(e,t,n){return{event:e.event,role:t,location:n}}let dt={entries:()=>[],forTarget:()=>void 0};var ft=class{eventDefinitions;viewDefinitions;groupDefinitions;contexts=/* @__PURE__ */ new Map;contextsByKind=/* @__PURE__ */ new Map;contextsByEventKey=/* @__PURE__ */ new Map;contextsByTarget=/* @__PURE__ */ new Map;inputs=/* @__PURE__ */ new Map;locationIndex=new $e;dirty=/* @__PURE__ */ new Set;dirtyByTarget=/* @__PURE__ */ new Map;revised=/* @__PURE__ */ new Set;dependents=/* @__PURE__ */ new Map;views=/* @__PURE__ */ new Map;groups=/* @__PURE__ */ new Map;pendingGroupStores=/* @__PURE__ */ new Set;activeTargets=/* @__PURE__ */ new Set;hasMore=!1;replacePending=!0;timelineDirty=!0;constructor(e,t,n=dt){this.eventDefinitions=e,this.viewDefinitions=t,this.groupDefinitions=n,this.resetViewBuilders()}openTurn(){let e=this.locationIndex.snapshot(),t=e.turnOrder.at(-1),n=t===void 0?void 0:e.turns.get(t);return n?.status===`open`&&n.start!==void 0?n.turn:void 0}replaceWindow(e,t){this.contexts.clear(),this.contextsByKind.clear(),this.contextsByEventKey.clear(),this.contextsByTarget.clear(),this.inputs.clear(),this.dirty.clear(),this.dirtyByTarget.clear(),this.revised.clear(),this.dependents.clear(),this.hasMore=t;let n=[...e].sort((e,t)=>ze(e.event,t.event));for(let e of n)this.inputs.set(Re(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=Re(t);if(this.inputs.has(n))return`none`;this.revised.size>0&&this.revised.clear(),this.inputs.set(n,e);let r=`none`;if(t.type!==`assistant/live-chunk`&&pt(t.type)){let e=this.locationIndex.snapshot(),n=this.locationIndex.appendBoundary(t);this.locationIndex.snapshot()!==e&&(this.timelineDirty=!0,r=`immediate`),this.replayContexts(this.refreshMatchLocations(n)),n.size>0&&(r=`immediate`)}else this.locationIndex.appendNonBoundary(t);return r=at(r,this.matchInput(e)),this.replayRevisedDependents()&&(r=`immediate`),this.revised.size>0&&this.revised.clear(),r}settleAssistant(e,t){this.revised.clear();let n=[...this.inputs.values()].filter(t=>t.type===`transient`&&t.event.data.attemptId===e),r=new Set(n.map(e=>Re(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(Re(e.event)));this.locationIndex.removeAssistantTransients(n.map(e=>e.event));let a=n.length===0?`none`:`immediate`;if(t!==void 0&&!this.inputs.has(t.event.seq)){this.inputs.set(t.event.seq,t),this.locationIndex.insertAssistantSettlement(t.event);let e=/* @__PURE__ */ new Map;a=at(a,this.collectInput(t,e)),this.applyPendingMatches(e,i)}return this.replayContexts(i),this.replayRevisedDependents()&&(a=`immediate`),this.revised.clear(),a}prepend(e,t){this.revised.clear();let n=`none`,r=this.hasMore,i=e.filter(e=>!this.inputs.has(Re(e.event))).sort((e,t)=>ze(e.event,t.event));for(let e of i)this.inputs.set(Re(e.event),e);this.hasMore=t;let a=this.locationIndex.snapshot(),o=this.locationIndex.rebuild(this.sortedInputs());this.locationIndex.snapshot()!==a&&(this.timelineDirty=!0);let s=this.refreshMatchLocations(o),c=/* @__PURE__ */ new Map;for(let e of i)n=at(n,this.collectInput(e,c));return this.applyPendingMatches(c,s),this.replayContexts(s),(this.revised.size>0||r!==t)&&this.replayDependencies()&&(n=`immediate`),o.size>0&&(n=`immediate`),this.revised.clear(),n}rebuildRegistry(){return this.resetViewBuilders(),this.replaceWindow(this.sortedInputs(),this.hasMore)}flush(){if(!this.replacePending&&this.dirty.size===0&&!this.timelineDirty)return!1;if(this.replacePending){this.replaceLocationData();let e=[],t=this.locationIndex.takeChangedTurns();for(let n of this.activeTargets){let r=this.views.get(n);r!==void 0&&(this.updateView(r,!0,this.buildTargetNodes(n,this.contextsByTarget.get(n)),t),e.push(r))}return this.replacePending=!1,this.dirty.clear(),this.dirtyByTarget.clear(),this.timelineDirty=!1,this.publishViews(e)}let e=[];this.applyDirtyLocationData()&&(this.timelineDirty=!0);let t=this.locationIndex.takeChangedTurns(),n=this.timelineDirty;for(let r of this.activeTargets){let i=this.views.get(r);if(i===void 0||i.builder===void 0)continue;let a=this.buildTargetUpserts(r,this.dirtyByTarget.get(r));(a.length!==0||n)&&(this.updateView(i,!1,a,t),e.push(i))}return this.dirty.clear(),this.dirtyByTarget.clear(),this.timelineDirty=!1,this.publishViews(e)}activateTarget(e){let t=this.views.get(e);if(this.activeTargets.has(e))return!1;let n=this.flush();return this.activeTargets.add(e),t===void 0?n:(this.replaceView(t),this.publishViews([t]),!0)}snapshot(e){return this.views.get(e)?.snapshot}get(e){return this.snapshot(e)}grouped(e){return this.groups.get(e)?.store}activityTargets(){let e=/* @__PURE__ */ new Set;for(let t of this.activeTargets){let n=this.views.get(t);n!==void 0&&n.isActive?.(n.snapshot)===!0&&e.add(n.target)}return e}sortedInputs(){return[...this.inputs.values()].sort((e,t)=>ze(e.event,t.event))}matchInput(e){return this.dispatchInput(e,this.acceptMatch)}collectInput(e,t){return this.dispatchInput(e,(e,n,r)=>{let i=Le(e.kind,n),a=t.get(i)??[];return a.push({definition:e,id:n,match:r}),t.set(i,a),e.publication?.(r)??`immediate`})}dispatchInput(e,t){let n=e.event,r,i,a,o=t=>(a??=this.locationIndex.locationOf(n),t===`start`?r??=ut(e,t,a):i??=ut(e,t,a)),s,c,l,u=`none`,d=this.eventDefinitions.forEvent?.(n.type);if(d===void 0)for(let e of this.eventDefinitions.entries()){let r=e.match(n);r!==null&&(e.target!==void 0&&e.target!==s&&e.target!==c&&(s===void 0?s=e.target:c===void 0?c=e.target:(l??=/* @__PURE__ */ new Set).add(e.target)),u=at(u,t.call(this,e,r.id,o(r.role))))}else for(let{definition:e,match:r}of d){let i=r(n);i!==null&&(e.target!==void 0&&e.target!==s&&e.target!==c&&(s===void 0?s=e.target:c===void 0?c=e.target:(l??=/* @__PURE__ */ new Set).add(e.target)),u=at(u,t.call(this,e,i.id,o(i.role))))}let f=this.eventDefinitions.fallbackEntry(),p=f?.target;if(f!==void 0&&p!==void 0&&p!==s&&p!==c&&l?.has(p)!==!0){let e=f.match(n);e!==null&&(u=at(u,t.call(this,f,e.id,o(e.role))))}return u}createContext(e,t,n){let r={key:n,kind:e.kind,id:t,definition:e,start:void 0,matches:[],state:void 0,revision:0,current:/* @__PURE__ */ new Map,locationData:it(),dependencies:/* @__PURE__ */ new Map};return this.contexts.set(n,r),this.indexTargetContext(r),r}acceptMatch(e,t,n){let r=this.contextsByKind.get(e.kind)?.at(-1),i=r?.id===t?r.key:Le(e.kind,t),a=this.contexts.get(i);a??=this.createContext(e,t,i);let o=n.role===`start`&&a.start===void 0,s=a.matches.at(-1);if(s!==void 0&&ze(s.event,n.event)>=0)throw Error(`conversation Context ${i} received non-appended Match ${n.event.seq}`);if(o&&a.matches.length>0)throw Error(`conversation Context ${i} received an update before its start Match`);if(a.matches.push(n),o&&(a.start=n,this.indexStartedContext(a)),this.indexMatch(a,n),o)this.replayContext(a);else if(a.state!==void 0){let t=ct(a);a.state=mt(e,`update`,e.update(t,n)),a.revision++,this.revised.add(a)}return this.markDirty(a),e.publication?.(n)??`immediate`}indexMatch(e,t){let n=Re(t.event),r=this.contextsByEventKey.get(n);r===void 0&&(r=[],this.contextsByEventKey.set(n,r)),r.push(e)}applyPendingMatches(e,t){for(let[n,r]of e){let e=r[0];if(e===void 0)continue;let i=this.contexts.get(n);i??=this.createContext(e.definition,e.id,n);let a=r.map(e=>{if(e.definition!==i.definition||e.id!==i.id)throw Error(`conversation Context ${n} received inconsistent Definition identity`);return this.indexMatch(i,e.match),e.match}).sort((e,t)=>ze(e.event,t.event));i.matches=lt(i.key,a,i.matches),t.add(i),this.markDirty(i)}}replayContexts(e){this.refreshStarts(e);let t=[...e].sort(ot);for(let e of t)e.start===void 0?(e.state=void 0,this.replaceDependencies(e,/* @__PURE__ */ new Map),e.revision++,this.revised.add(e),this.markDirty(e)):this.replayContext(e)}refreshStarts(e){let t=/* @__PURE__ */ new Set,n=/* @__PURE__ */ new Map;for(let r of e){let e=r.matches.find(e=>e.role===`start`);if(e===r.start)continue;r.start=e,t.add(r);let i=n.get(r.kind)??[];e!==void 0&&i.push(r),n.set(r.kind,i)}for(let[e,r]of n){let n=this.contextsByKind.get(e)??[];this.contextsByKind.set(e,n.filter(e=>!t.has(e))),this.indexStartedContexts(e,r)}}replayContext(e){let t=e.start;if(t===void 0){e.state=void 0;return}if(e.matches[0]!==t)throw Error(`conversation Context ${e.key} received an update before its start Match`);let n=/* @__PURE__ */ new Map,r=this.readerFor(t.event,n);e.state=void 0,e.state=mt(e.definition,`start`,e.definition.start(ct(e),t,r)),this.replaceDependencies(e,n);for(let t=1;t<e.matches.length;t++){let n=e.matches[t];if(n===void 0)continue;let r=ct(e);e.state=mt(e.definition,`update`,e.definition.update(r,n))}e.revision++,this.revised.add(e),this.markDirty(e)}indexTargetContext(e){let t=e.definition.target;if(t===void 0)return;let n=this.contextsByTarget.get(t)??/* @__PURE__ */ new Set;n.add(e),this.contextsByTarget.set(t,n)}markDirty(e){if(this.dirty.has(e))return;this.dirty.add(e);let t=e.definition.target;if(t===void 0||!this.activeTargets.has(t))return;let n=this.dirtyByTarget.get(t);n===void 0&&(n=/* @__PURE__ */ new Set,this.dirtyByTarget.set(t,n)),n.add(e)}replaceDependencies(e,t){for(let t of e.dependencies.values()){if(t.key===void 0)continue;let n=this.dependents.get(t.key);n?.delete(e),n?.size===0&&this.dependents.delete(t.key)}e.dependencies=t;for(let n of t.values()){if(n.key===void 0)continue;let t=this.dependents.get(n.key)??/* @__PURE__ */ new Set;t.add(e),this.dependents.set(n.key,t)}}replayRevisedDependents(){if(this.dependents.size===0)return!1;let e=[...this.revised],t=/* @__PURE__ */ new Set;for(let n=0;n<e.length;n++){let r=e[n];if(r!==void 0)for(let n of this.dependents.get(r.key)??[])t.has(n)||(t.add(n),e.push(n))}return t.size>0&&this.replayContexts(t),t.size>0}readerFor(e,t){return{previous:n=>{let r=this.previousContext(n,e);if(t.set(n,{kind:n,key:r?.key,revision:r?.revision,windowGap:r===void 0&&this.hasMore}),r?.state===void 0)return;let i=r.start?.event.seq;if(i!==void 0)return{key:r.key,kind:r.kind,id:r.id,startSeq:i,state:r.state,matches:r.matches}}}}previousContext(e,t){let n=this.contextsByKind.get(e)??[],r=st(n,t);for(let e=r-1;e>=0;e--){let t=n[e];if(t?.state!==void 0)return t}}indexStartedContext(e){let t=e.start;if(t===void 0)return;let n=this.contextsByKind.get(e.kind)??[],r=n.at(-1);r===void 0||ot(r,e)<0?n.push(e):n.splice(st(n,t.event),0,e),this.contextsByKind.set(e.kind,n)}indexStartedContexts(e,t){if(t.length===0)return;let n=[...t].sort(ot),r=this.contextsByKind.get(e)??[],i=[],a=0,o=0;for(;a<r.length||o<n.length;){let e=r[a],t=n[o];t===void 0||e!==void 0&&ot(e,t)<0?(i.push(e),a++):(i.push(t),o++)}this.contextsByKind.set(e,i)}replayDependencies(){let e=!1,t=[...this.contexts.values()].filter(e=>e.start!==void 0).sort(ot);for(let n of t){if(n.state===void 0||n.dependencies.size===0)continue;let t=n.start?.event;if(t===void 0)continue;let r=!1;for(let e of n.dependencies.values()){let n=this.previousContext(e.kind,t),i=n===void 0&&this.hasMore;if(n?.key!==e.key||n?.revision!==e.revision||i!==e.windowGap){r=!0;break}}r&&(this.replayContext(n),e=!0)}return e}refreshMatchLocations(e){let t=/* @__PURE__ */ new Set;if(e.size===0)return t;for(let n of e)for(let e of this.contextsByEventKey.get(n)??[])t.add(e);for(let n of t){let t=n.start;n.matches=n.matches.map(n=>{if(!e.has(Re(n.event)))return n;if(n.role===`start`){let e={...n,location:this.locationIndex.locationOf(n.event)};return n===t&&(t=e),e}return{...n,location:this.locationIndex.locationOf(n.event)}}),n.start=t}return t}buildNode(e,t){if(e.definition.target!==t||e.definition.buildViewNode===void 0)return null;let n=e.definition.buildViewNode(ct(e));if(n===null)return null;if(n.key!==e.key)throw Error(`conversation Definition "${e.kind}" returned unstable key "${n.key}"; expected "${e.key}"`);if(n.target!==t)throw Error(`conversation Definition "${e.kind}" returned target "${n.target}" while building "${t}"`);return n}replaceView(e){this.updateView(e,!0,this.buildTargetNodes(e.target,this.contextsByTarget.get(e.target)),[])}updateView(e,t,n,r){let i=e.builder??e.definition.create(),a=e.groupDefinition;if(a!==void 0&&i.groupInput===void 0)throw Error(`conversation group target "${e.target}" requires builder.groupInput()`);e.builder=i;let o=this.locationIndex.snapshot(),s=t?i.replace({nodes:n,timeline:o,changedTurns:r}):i.apply({upserts:n,timeline:o,changedTurns:r});if(a!==void 0&&i.groupInput!==void 0){let t=this.groups.get(e.target),n=t===void 0;t===void 0&&(t={definition:a,state:a.create(),store:new Ue});let r=i.groupInput();t.state=a.update(t,r);let o=a.buildGroups(t);if((n||r.kind===`replace`)&&(o===null||o.entries===void 0||o.groups.kind!==`replace`))throw Error(`conversation group target "${e.target}" requires complete grouping for replacement input`);o!==null&&(t.store.prepareAndInstall(o,r.readNode),this.pendingGroupStores.add(t.store)),this.groups.set(e.target,t)}e.snapshot=s}publishViews(e){let t=e.length>0||this.pendingGroupStores.size>0,n=[...this.pendingGroupStores];this.pendingGroupStores.clear();for(let t of e)t.builder?.publish?.();for(let e of n)e.publish();return this.locationIndex.publishData(),t}buildTargetNodes(e,t){let n=[];for(let r of t??[]){let t=this.buildNode(r,e);r.current.set(e,t),t!==null&&n.push(t)}return n}buildTargetUpserts(e,t){let n=[];for(let r of t??[]){let t=r.current.get(e)??null,i=this.buildNode(r,e);if(i===null&&t!==null)throw Error(`conversation Definition "${r.kind}" withdrew materialized target "${e}"; return the same key with hidden visibility instead`);r.current.set(e,i),i!==null&&n.push(i)}return n}buildLocationData(e,t,n){if(e.definition.buildLocationData===void 0)return null;let r=e.definition.buildLocationData(ct(e),t,n);if(r===null)return null;if(r.kind!==t)throw Error(`conversation Definition "${e.kind}" published ${r.kind} data through its ${t} scope`);if(r.key!==e.kind)throw Error(`conversation Definition "${e.kind}" published Location data key "${r.key}"; expected its owned kind`);if(!Number.isSafeInteger(r.turn)||r.turn<0)throw Error(`conversation Definition "${e.kind}" published invalid turn ${r.turn}`);if(r.kind===`step`&&(!Number.isSafeInteger(r.step)||r.step<0))throw Error(`conversation Definition "${e.kind}" published invalid step ${String(r.step)}`);return r}replaceLocationData(){let e=[];for(let t of rt){for(let n of this.contexts.values()){let r=this.buildLocationData(n,t,n.locationData[t]);n.locationData[t]=r,r!==null&&e.push({owner:n.key,data:r})}this.locationIndex.replaceData(e)}}applyDirtyLocationData(){let e=!1;for(let t of rt){let n=[];for(let e of this.dirty){let r=e.locationData[t],i=this.buildLocationData(e,t,r);r!==i&&(e.locationData[t]=i,n.push({owner:e.key,previous:r,next:i}))}e=this.locationIndex.applyData(n)||e}return e}resetViewBuilders(){let e=this.viewDefinitions.entries(),t=new Set(e.map(e=>e.target));for(let[e,n]of this.groups)(!t.has(e)||this.groupDefinitions.forTarget(e)!==n.definition)&&(n.store.clear(),this.pendingGroupStores.add(n.store),this.groups.delete(e));this.views.clear();for(let t of e){let e={target:t.target,definition:t,groupDefinition:this.groupDefinitions.forTarget(t.target),isActive:t.isActive===void 0?void 0:e=>t.isActive?.(e)===!0,builder:void 0,snapshot:void 0};this.views.set(t.target,e)}this.replacePending=!0}};function pt(e){return e===`turn/start`||e===`turn/end`||e===`step/start`||e===`step/end`}function mt(e,t,n){if(n===void 0)throw Error(`conversation Definition "${e.kind}" returned undefined from ${t}()`);return n}var ht=class{ctx;definitions=/* @__PURE__ */ new Map;listeners=/* @__PURE__ */ new Set;cached=[];constructor(e){this.ctx=e,Object.defineProperty(this,m.Service.tracker,{value:{property:`ctx`}})}entries(){return this.cached}subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}registerDefinition(e,t,n,r){if(this.definitions.has(e))throw Error(n);let i=this.ctx.effect(()=>(this.definitions.set(e,t),this.refresh(),()=>{this.definitions.get(e)===t&&(this.definitions.delete(e),this.refresh())}),r);return()=>{i()}}refresh(){this.cached=[...this.definitions.values()],(0,f.notifySubscribers)(this.listeners,`[ui-conversation] definition registry`)}},gt=class extends ht{fallback;routes=/* @__PURE__ */ new Map;unrestricted=/* @__PURE__ */ new Set;tables=/* @__PURE__ */ new WeakMap;register(e){return _t(e),this.registerDefinition(e.kind,this.resolve(e),`conversation Definition "${e.kind}" is already registered`,`uiConversation.events.register(${JSON.stringify(e.kind)})`)}registerFallback(e){if(_t(e),e.target===void 0)throw Error(`conversation fallback Definition must declare a target`);if(this.fallback!==void 0)throw Error(`conversation fallback Definition is already registered`);let t=this.resolve(e),n=this.ctx.effect(()=>(this.fallback=t,this.refresh(),()=>{this.fallback===t&&(this.fallback=void 0,this.refresh())}),`uiConversation.events.registerFallback(${JSON.stringify(t.kind)})`);return()=>{n()}}fallbackEntry(){return this.fallback}forEvent(e){return this.routes.get(e)??this.unrestricted}resolve(e){if(typeof e.match==`function`)return e;let t=new Map(Object.entries(e.match)),n={...e,match:e=>t.get(e.type)?.call(n,e)??null};return this.tables.set(n,t),n}refresh(){let e=/* @__PURE__ */ new Map,t=/* @__PURE__ */ new Set;for(let n of this.definitions.values()){let r=this.tables.get(n);if(r===void 0){let r={definition:n,match:n.match.bind(n)};t.add(r);for(let t of e.values())t.add(r)}else for(let[i,a]of r){let r=e.get(i);r===void 0&&(r=new Set(t),e.set(i,r)),r.add({definition:n,match:a.bind(n)})}}this.routes=e,this.unrestricted=t,super.refresh()}};function _t(e){if(e.target===void 0!=(e.buildViewNode===void 0))throw Error(`conversation Definition "${e.kind}" must declare target and buildViewNode together`)}function vt(e){let t=``,n=32768;for(let r=0;r<e.length;r+=n)t+=String.fromCharCode(...e.subarray(r,r+n));return btoa(t)}function yt(){let e=globalThis.crypto.getRandomValues(/* @__PURE__ */ new Uint8Array(16)),t=Array.from(e,(e,t)=>(t===6?e&15|64:t===8?e&63|128:e).toString(16).padStart(2,`0`)).join(``);return`${t.slice(0,8)}-${t.slice(8,12)}-${t.slice(12,16)}-${t.slice(16,20)}-${t.slice(20)}`}var bt=class{sessions;entries=new Me;scopeDisposers=new Me;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,${vt(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)&&xt(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)xt(e);this.urls.clear();for(let e of this.entries.values)e.clear();this.entries.clear()}}};function xt(e){e.startsWith(`blob:`)&&URL.revokeObjectURL(e)}var St=class extends ht{register(e){return this.registerDefinition(e.target,e,`conversation view target "${e.target}" is already registered`,`uiConversation.views.register(${JSON.stringify(e.target)})`)}},Ct=class extends ht{views;constructor(e,t){super(e),this.views=t}register(e){if(!this.views.entries().some(t=>t.target===e.target))throw Error(`conversation group target "${e.target}" is not registered`);return this.registerDefinition(e.target,e,`conversation group target "${e.target}" is already registered`,`uiConversation.groups.register(${JSON.stringify(e.target)})`)}forTarget(e){return this.definitions.get(e)}},wt=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()}}},Tt=class extends m.Service{sessions;events;views;groups;bindings=new Me;images;constructor(e,t){super(e,`uiConversation`),this.sessions=t,this.events=new gt(e),this.views=new St(e),this.groups=new Ct(e,this.views),this.images=new bt(e,t);let n=()=>{for(let e of this.bindings.values)e.binding.rebuild()},r=!1,i=()=>{r||(r=!0,queueMicrotask(()=>{r=!1,n()}))};e.effect(()=>{let e=this.events.subscribe(i),t=this.views.subscribe(i),n=this.groups.subscribe(i);return()=>{n(),t(),e();for(let e of[...this.bindings.values])this.drop(e,!0)}},`ui-conversation assembly`)}binding(e){let t=typeof e==`string`?e:e.sessionId,n=typeof e==`string`?this.sessions.binding(e):e;if(n===void 0)throw Error(`uiConversation.binding: unknown session "${t}"`);if(this.sessions.binding(t)!==n)throw Error(`uiConversation.binding: inactive session "${t}"`);let r=this.bindings.get(n);if(r!==void 0)return r.binding;let i=new wt(n.eventSource,new ft(this.events,this.views,this.groups)),a={source:n,binding:i,disposeScope:()=>{}};this.bindings.set(n,a);let o=n.ctx.effect(()=>()=>{this.drop(a,!1)},`ui-conversation binding`);return a.disposeScope=()=>{o()},i}imageUrl(e,t){return this.images.resolve(e,t)}peekImageUrl(e,t){return this.images.peek(e,t)}seedImageUrl(e,t,n){return this.images.seed(e,t,n)}inspectSystemPrompt(e,t){return Ie(e,t)}inspectRequestPrompt(e,t,n){return Ne(e,t,n)}drop(e,t){this.bindings.get(e.source)===e&&(this.bindings.delete(e.source),e.binding.dispose(),t&&e.disposeScope())}},Et;let Dt=/*@__PURE__*/ Object.freeze({status:`aborted`});function w(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 Ot=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}},kt=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name=`ZodEncodeError`}};(Et=globalThis).__zod_globalConfig??(Et.__zod_globalConfig={});let At=globalThis.__zod_globalConfig;function jt(e){return e&&Object.assign(At,e),At}function Mt(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 Nt(e,t){return typeof t==`bigint`?t.toString():t}function Pt(e){return{get value(){{let t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function Ft(e){return e==null}function It(e){let t=+!!e.startsWith(`^`),n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function Lt(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 Rt=/* @__PURE__*/ Symbol(`evaluating`);function T(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==Rt)return r===void 0&&(r=Rt,r=n()),r},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function zt(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function Bt(...e){let t={};for(let n of e){let e=Object.getOwnPropertyDescriptors(n);Object.assign(t,e)}return Object.defineProperties({},t)}function Vt(e){return JSON.stringify(e)}function Ht(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,``).replace(/[\s_-]+/g,`-`).replace(/^-+|-+$/g,``)}let Ut=`captureStackTrace`in Error?Error.captureStackTrace:(...e)=>{};function Wt(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}let Gt=/* @__PURE__*/ Pt(()=>{if(At.jitless||typeof navigator<`u`&&navigator?.userAgent?.includes(`Cloudflare`))return!1;try{return Function(``),!0}catch{return!1}});function Kt(e){if(Wt(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!=`function`)return!0;let n=t.prototype;return Wt(n)!==!1&&Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)!==!1}function qt(e){return Kt(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}let Jt=/* @__PURE__*/ new Set([`string`,`number`,`symbol`]);function Yt(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function Xt(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function E(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 Zt(e){return Object.keys(e).filter(t=>e[t]._zod.optin===`optional`&&e[t]._zod.optout===`optional`)}let Qt={safeint:[-(2**53-1),2**53-1],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function $t(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 Xt(e,Bt(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 zt(this,`shape`,e),e},checks:[]}))}function en(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 Xt(e,Bt(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 zt(this,`shape`,r),r},checks:[]}))}function tn(e,t){if(!Kt(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 Xt(e,Bt(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return zt(this,`shape`,n),n}}))}function nn(e,t){if(!Kt(t))throw Error(`Invalid input to safeExtend: expected a plain object`);return Xt(e,Bt(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return zt(this,`shape`,n),n}}))}function rn(e,t){if(e._zod.def.checks?.length)throw Error(`.merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.`);return Xt(e,Bt(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t._zod.def.shape};return zt(this,`shape`,n),n},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]}))}function an(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 Xt(t,Bt(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 zt(this,`shape`,i),i},checks:[]}))}function on(e,t,n){return Xt(t,Bt(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 zt(this,`shape`,i),i}}))}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!==!0)return!0;return!1}function cn(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 ln(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function un(e){return typeof e==`string`?e:e?.message}function dn(e,t,n){let r=e.message?e.message:un(e.inst?._zod.def?.error?.(e))??un(t?.error?.(e))??un(n.customError?.(e))??un(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 fn(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function pn(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}let mn=(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,Nt,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},hn=w(`$ZodError`,mn),gn=w(`$ZodError`,mn,{Parent:Error});function _n(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 vn(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 yn=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 Ot;if(o.issues.length){let t=new((i?.Err)??e)(o.issues.map(e=>dn(e,a,jt())));throw Ut(t,i?.callee),t}return o.value},bn=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=>dn(e,a,jt())));throw Ut(t,i?.callee),t}return o.value},xn=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 Ot;return a.issues.length?{success:!1,error:new(e??hn)(a.issues.map(e=>dn(e,i,jt())))}:{success:!0,data:a.value}},Sn=/* @__PURE__*/ xn(gn),Cn=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=>dn(e,i,jt())))}:{success:!0,data:a.value}},wn=/* @__PURE__*/ Cn(gn),Tn=e=>(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return yn(e)(t,n,i)},En=e=>(t,n,r)=>yn(e)(t,n,r),Dn=e=>async(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return bn(e)(t,n,i)},On=e=>async(t,n,r)=>bn(e)(t,n,r),kn=e=>(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return xn(e)(t,n,i)},An=e=>(t,n,r)=>xn(e)(t,n,r),jn=e=>async(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return Cn(e)(t,n,i)},Mn=e=>async(t,n,r)=>Cn(e)(t,n,r),Nn=/^[cC][0-9a-z]{6,}$/,Pn=/^[0-9a-z]+$/,Fn=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,In=/^[0-9a-vA-V]{20}$/,Ln=/^[A-Za-z0-9]{27}$/,Rn=/^[a-zA-Z0-9_-]{21}$/,zn=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Bn=/^([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})$/,Vn=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)$/,Hn=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;function Un(){return RegExp(`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`,`u`)}let Wn=/^(?:(?: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])$/,Gn=/^(([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}|:))$/,Kn=/^((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])$/,qn=/^(([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])$/,Jn=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Yn=/^[A-Za-z0-9_-]*$/,Xn=/^https?$/,Zn=/^\+[1-9]\d{6,14}$/,Qn=`(?:(?:\\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])))`,$n=/*@__PURE__*/ RegExp(`^${Qn}$`);function er(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 tr(e){return RegExp(`^${er(e)}$`)}function nr(e){let t=er({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(`^${Qn}T(?:${r})$`)}let rr=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??``}}`:`[\\s\\S]*`;return RegExp(`^${t}$`)},ir=/^-?\d+$/,ar=/^-?\d+(?:\.\d+)?$/,or=/^(?:true|false)$/i,sr=/^null$/i,cr=/^[^A-Z]*$/,lr=/^[^a-z]*$/,ur=/*@__PURE__*/ w(`$ZodCheck`,(e,t)=>{var n;e._zod??={},e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),dr={number:`number`,bigint:`bigint`,object:`date`},fr=/*@__PURE__*/ w(`$ZodCheckLessThan`,(e,t)=>{ur.init(e,t);let n=dr[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})}}),pr=/*@__PURE__*/ w(`$ZodCheckGreaterThan`,(e,t)=>{ur.init(e,t);let n=dr[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})}}),mr=/*@__PURE__*/ w(`$ZodCheckMultipleOf`,(e,t)=>{ur.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):Lt(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})}}),hr=/*@__PURE__*/ w(`$ZodCheckNumberFormat`,(e,t)=>{ur.init(e,t),t.format=t.format||`float64`;let n=t.format?.includes(`int`),r=n?`int`:`number`,[i,a]=Qt[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=ir)}),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})}}),gr=/*@__PURE__*/ w(`$ZodCheckMaxLength`,(e,t)=>{var n;ur.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!Ft(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=fn(r);n.issues.push({origin:i,code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),_r=/*@__PURE__*/ w(`$ZodCheckMinLength`,(e,t)=>{var n;ur.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!Ft(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=fn(r);n.issues.push({origin:i,code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),vr=/*@__PURE__*/ w(`$ZodCheckLengthEquals`,(e,t)=>{var n;ur.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!Ft(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=fn(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})}}),yr=/*@__PURE__*/ w(`$ZodCheckStringFormat`,(e,t)=>{var n,r;ur.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=()=>{})}),br=/*@__PURE__*/ w(`$ZodCheckRegex`,(e,t)=>{yr.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})}}),xr=/*@__PURE__*/ w(`$ZodCheckLowerCase`,(e,t)=>{t.pattern??=cr,yr.init(e,t)}),Sr=/*@__PURE__*/ w(`$ZodCheckUpperCase`,(e,t)=>{t.pattern??=lr,yr.init(e,t)}),Cr=/*@__PURE__*/ w(`$ZodCheckIncludes`,(e,t)=>{ur.init(e,t);let n=Yt(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})}}),wr=/*@__PURE__*/ w(`$ZodCheckStartsWith`,(e,t)=>{ur.init(e,t);let n=RegExp(`^${Yt(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})}}),Tr=/*@__PURE__*/ w(`$ZodCheckEndsWith`,(e,t)=>{ur.init(e,t);let n=RegExp(`.*${Yt(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})}}),Er=/*@__PURE__*/ w(`$ZodCheckOverwrite`,(e,t)=>{ur.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}});var Dr=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
|
-
`).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?.
|
|
13
|
-
`))}};let Or={major:4,minor:4,patch:3},D=/*@__PURE__*/ w(`$ZodType`,(e,t)=>{var n;e??={},e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Or;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=sn(e),i;for(let a of t){if(a._zod.def.when){if(cn(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 Ot;if(i||o instanceof Promise)i=(i??Promise.resolve()).then(async()=>{await o,e.issues.length!==t&&(r||=sn(e,t))});else{if(e.issues.length===t)continue;r||=sn(e,t)}}return i?i.then(()=>e):e},n=(n,i,a)=>{if(sn(n))return n.aborted=!0,n;let o=t(i,r,a);if(o instanceof Promise){if(a.async===!1)throw new Ot;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 Ot;return o.then(e=>t(e,r,a))}return t(o,r,a)}}T(e,`~standard`,()=>({validate:t=>{try{let n=Sn(e,t);return n.success?{value:n.data}:{issues:n.error?.issues}}catch{return wn(e,t).then(e=>e.success?{value:e.data}:{issues:e.error?.issues})}},vendor:`zod`,version:1}))}),kr=/*@__PURE__*/ w(`$ZodString`,(e,t)=>{D.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??rr(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}}),Ar=/*@__PURE__*/ w(`$ZodStringFormat`,(e,t)=>{yr.init(e,t),kr.init(e,t)}),jr=/*@__PURE__*/ w(`$ZodGUID`,(e,t)=>{t.pattern??=Bn,Ar.init(e,t)}),Mr=/*@__PURE__*/ w(`$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??=Vn(e)}else t.pattern??=Vn();Ar.init(e,t)}),Nr=/*@__PURE__*/ w(`$ZodEmail`,(e,t)=>{t.pattern??=Hn,Ar.init(e,t)}),Pr=/*@__PURE__*/ w(`$ZodURL`,(e,t)=>{Ar.init(e,t),e._zod.check=n=>{try{let r=n.value.trim();if(!t.normalize&&t.protocol?.source===Xn.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})}}}),Fr=/*@__PURE__*/ w(`$ZodEmoji`,(e,t)=>{t.pattern??=Un(),Ar.init(e,t)}),Ir=/*@__PURE__*/ w(`$ZodNanoID`,(e,t)=>{t.pattern??=Rn,Ar.init(e,t)}),Lr=/*@__PURE__*/ w(`$ZodCUID`,(e,t)=>{t.pattern??=Nn,Ar.init(e,t)}),Rr=/*@__PURE__*/ w(`$ZodCUID2`,(e,t)=>{t.pattern??=Pn,Ar.init(e,t)}),zr=/*@__PURE__*/ w(`$ZodULID`,(e,t)=>{t.pattern??=Fn,Ar.init(e,t)}),Br=/*@__PURE__*/ w(`$ZodXID`,(e,t)=>{t.pattern??=In,Ar.init(e,t)}),Vr=/*@__PURE__*/ w(`$ZodKSUID`,(e,t)=>{t.pattern??=Ln,Ar.init(e,t)}),Hr=/*@__PURE__*/ w(`$ZodISODateTime`,(e,t)=>{t.pattern??=nr(t),Ar.init(e,t)}),Ur=/*@__PURE__*/ w(`$ZodISODate`,(e,t)=>{t.pattern??=$n,Ar.init(e,t)}),Wr=/*@__PURE__*/ w(`$ZodISOTime`,(e,t)=>{t.pattern??=tr(t),Ar.init(e,t)}),Gr=/*@__PURE__*/ w(`$ZodISODuration`,(e,t)=>{t.pattern??=zn,Ar.init(e,t)}),Kr=/*@__PURE__*/ w(`$ZodIPv4`,(e,t)=>{t.pattern??=Wn,Ar.init(e,t),e._zod.bag.format=`ipv4`}),qr=/*@__PURE__*/ w(`$ZodIPv6`,(e,t)=>{t.pattern??=Gn,Ar.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})}}}),Jr=/*@__PURE__*/ w(`$ZodCIDRv4`,(e,t)=>{t.pattern??=Kn,Ar.init(e,t)}),Yr=/*@__PURE__*/ w(`$ZodCIDRv6`,(e,t)=>{t.pattern??=qn,Ar.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 Xr(e){if(e===``)return!0;if(/\s/.test(e)||e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}let Zr=/*@__PURE__*/ w(`$ZodBase64`,(e,t)=>{t.pattern??=Jn,Ar.init(e,t),e._zod.bag.contentEncoding=`base64`,e._zod.check=n=>{Xr(n.value)||n.issues.push({code:`invalid_format`,format:`base64`,input:n.value,inst:e,continue:!t.abort})}});function Qr(e){if(!Yn.test(e))return!1;let t=e.replace(/[-_]/g,e=>e===`-`?`+`:`/`);return Xr(t.padEnd(Math.ceil(t.length/4)*4,`=`))}let $r=/*@__PURE__*/ w(`$ZodBase64URL`,(e,t)=>{t.pattern??=Yn,Ar.init(e,t),e._zod.bag.contentEncoding=`base64url`,e._zod.check=n=>{Qr(n.value)||n.issues.push({code:`invalid_format`,format:`base64url`,input:n.value,inst:e,continue:!t.abort})}}),ei=/*@__PURE__*/ w(`$ZodE164`,(e,t)=>{t.pattern??=Zn,Ar.init(e,t)});function ti(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 ni=/*@__PURE__*/ w(`$ZodJWT`,(e,t)=>{Ar.init(e,t),e._zod.check=n=>{ti(n.value,t.alg)||n.issues.push({code:`invalid_format`,format:`jwt`,input:n.value,inst:e,continue:!t.abort})}}),ri=/*@__PURE__*/ w(`$ZodNumber`,(e,t)=>{D.init(e,t),e._zod.pattern=e._zod.bag.pattern??ar,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}}),ii=/*@__PURE__*/ w(`$ZodNumberFormat`,(e,t)=>{hr.init(e,t),ri.init(e,t)}),ai=/*@__PURE__*/ w(`$ZodBoolean`,(e,t)=>{D.init(e,t),e._zod.pattern=or,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}}),oi=/*@__PURE__*/ w(`$ZodNull`,(e,t)=>{D.init(e,t),e._zod.pattern=sr,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}}),si=/*@__PURE__*/ w(`$ZodUnknown`,(e,t)=>{D.init(e,t),e._zod.parse=e=>e}),ci=/*@__PURE__*/ w(`$ZodNever`,(e,t)=>{D.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:`never`,code:`invalid_type`,input:t.value,inst:e}),t)});function li(e,t,n){e.issues.length&&t.issues.push(...ln(n,e.issues)),t.value[n]=e.value}let ui=/*@__PURE__*/ w(`$ZodArray`,(e,t)=>{D.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=>li(t,n,e))):li(s,n,e)}return a.length?Promise.all(a).then(()=>n):n}});function di(e,t,n,r,i,a){let o=n in r;if(e.issues.length){if(i&&a&&!o)return;t.issues.push(...ln(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 fi(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=Zt(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function pi(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=>di(e,n,i,t,u,d))):di(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 mi=/*@__PURE__*/ w(`$ZodObject`,(e,t)=>{if(D.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=Pt(()=>fi(t));T(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=Wt,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=>di(n,t,e,s,r,i))):di(a,t,e,s,r,i)}return i?pi(c,s,t,o,n.value,e):c.length?Promise.all(c).then(()=>t):t}}),hi=/*@__PURE__*/ w(`$ZodObjectJIT`,(e,t)=>{mi.init(e,t);let n=e._zod.parse,r=Pt(()=>fi(t)),i=e=>{let t=new Dr([`shape`,`payload`,`ctx`]),n=r.value,i=e=>{let t=Vt(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=Vt(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
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
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())}};function Tt(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 Et(e,t=`|`){return e.map(e=>$t(e)).join(t)}function Dt(e,t){return typeof t==`bigint`?t.toString():t}var Ot=class{constructor(e){this._getter=e,this._value=void 0}get value(){let e=this._getter;return e!==void 0&&(this._value=e(),this._getter=void 0),this._value}};function kt(e){return new Ot(e)}function At(e){return e==null}function jt(e){let t=+!!e.startsWith(`^`),n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function Mt(e,t){let n=e/t,r=Math.round(n),i=4*2**-52*Math.max(Math.abs(n),1);return Math.abs(n-r)<i?0:n-r}let Nt=/* @__PURE__*/ Symbol(`evaluating`);function Pt(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==Nt)return r===void 0&&(r=Nt,r=n()),r},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function Ft(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function It(e){let t=Object.getOwnPropertyDescriptor(e,`shape`);return t?.get?t.get.raw:t?.value}function Lt(e){return It(e._zod.def)??e._zod.def.shape}function Rt(e,t,n){Object.defineProperty(e,t,{get(){let e=n();return Ft(this,t,e),e},enumerable:!0,configurable:!0})}function zt(e,t,n){t in e?Ft(e,t,n):e[t]=n}function Bt(e,t,n,r){let i=Lt(t);for(let a of n){let n=Object.getOwnPropertyDescriptor(i,a);n.enumerable&&(n.get?Rt(e,a,()=>{let e=t._zod.def.shape[a];return r?r(e,a):e}):zt(e,a,r?r(n.value,a):n.value))}}function Vt(e,t){for(let n of Reflect.ownKeys(t)){let r=Object.getOwnPropertyDescriptor(t,n);r.enumerable&&(r.get?Rt(e,n,()=>t[n]):zt(e,n,r.value))}}function Ht(...e){let t={};for(let n of e){let e=Object.getOwnPropertyDescriptors(n);Object.assign(t,e)}return Object.defineProperties({},t)}function Ut(e){return JSON.stringify(e)}function Wt(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,``).replace(/[\s_-]+/g,`-`).replace(/^-+|-+$/g,``)}let Gt=`captureStackTrace`in Error?Error.captureStackTrace:(...e)=>{};function Kt(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}let qt=/* @__PURE__*/ kt(()=>{if(Un.jitless||typeof navigator<`u`&&navigator?.userAgent?.includes(`Cloudflare`))return!1;try{return Function(``),!0}catch{return!1}});function Jt(e){if(Kt(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!=`function`)return!0;let n=t.prototype;return Kt(n)!==!1&&Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)!==!1}function Yt(e){return Jt(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}let Xt=/* @__PURE__*/ new Set([`string`,`number`,`symbol`]);function Zt(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 T(e){let t=e;if(!t)return{};if(typeof t==`string`)return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error==`string`?{...t,error:()=>t.error}:t}function $t(e){return typeof e==`bigint`?e.toString()+`n`:typeof e==`string`?`"${e}"`:`${e}`}function en(e){return Object.keys(e).filter(t=>e[t]._zod.optin!==void 0&&e[t]._zod.optout===`optional`)}let tn={safeint:[-(2**53-1),2**53-1],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},nn={int64:[/* @__PURE__*/ BigInt(`-9223372036854775808`),/* @__PURE__*/ BigInt(`9223372036854775807`)],uint64:[/* @__PURE__*/ BigInt(0),/* @__PURE__*/ BigInt(`18446744073709551615`)]};function rn(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.pick() cannot be used on object schemas containing refinements`);let i={};return Bt(i,e,an(e,t)),Qt(e,Ht(n,{shape:i,checks:[]}))}function an(e,t){let n=Lt(e),r=[];for(let e of Reflect.ownKeys(t)){if(!Object.getOwnPropertyDescriptor(n,e)?.enumerable)throw Error(`Unrecognized key: "${String(e)}"`);t[e]&&r.push(e)}return r}function on(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.omit() cannot be used on object schemas containing refinements`);let i=new Set(an(e,t)),a={};return Bt(a,e,Reflect.ownKeys(Lt(e)).filter(e=>!i.has(e))),Qt(e,Ht(n,{shape:a,checks:[]}))}function sn(e,t){if(!Jt(t))throw Error(`Invalid input to extend: expected a plain object`);let n=e._zod.def.checks;if(n&&n.length>0){let n=Lt(e);for(let e of Reflect.ownKeys(t))if(Object.getOwnPropertyDescriptor(n,e)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return Qt(e,Ht(e._zod.def,{shape:cn(e,t)}))}function cn(e,t){let n={};return Bt(n,e,Reflect.ownKeys(Lt(e))),Vt(n,t),n}function ln(e,t){if(!Jt(t))throw Error(`Invalid input to safeExtend: expected a plain object`);return Qt(e,Ht(e._zod.def,{shape:cn(e,t)}))}function un(e,t){if(!t?._zod?.def)throw Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");if(e._zod.def.checks?.length)throw Error(`.merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.`);let n={};return Bt(n,e,Reflect.ownKeys(Lt(e))),Bt(n,t,Reflect.ownKeys(Lt(t))),Qt(e,Ht(e._zod.def,{shape:n,get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]}))}function dn(e,t,n,r=`partial`){let i=t._zod.def.checks;if(i&&i.length>0)throw Error(`.${r}() cannot be used on object schemas containing refinements`);let a=n?new Set(an(t,n)):void 0,o={};return Bt(o,t,Reflect.ownKeys(Lt(t)),e&&((t,n)=>a&&!a.has(n)?t:new e({type:`optional`,innerType:t}))),Qt(t,Ht(t._zod.def,{shape:o,checks:[]}))}function fn(e,t,n){let r=n?new Set(an(t,n)):void 0,i={};return Bt(i,t,Reflect.ownKeys(Lt(t)),(t,n)=>r&&!r.has(n)?t:new e({type:`nonoptional`,innerType:t})),Qt(t,Ht(t._zod.def,{shape:i}))}function pn(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 mn(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 hn(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function gn(e){return typeof e==`string`?e:e?.message}function _n(e){let t=[];for(let n of e??[]){let e=n._zod.def;if(!/_(length|size)$|_equals$/.test(e.check))break;let r=e.maximum??e.length??e.size;r>=0&&t.push([r,n])}return t}function vn(e,t,n){var r;for(let i=t;i<e.length;i++)(r=e[i]).schema??(r.schema=n)}function yn(e,t,n){var r;let i=e.inst?._zod?.traits;i?.has(`$ZodType`)&&(i.has(`$ZodCheck`)?(r=e).schema??(r.schema=e.inst):e.schema=e.inst);let a=e.schema===e.inst?void 0:e.schema?._zod.def?.error,o=e.message?e.message:gn(e.inst?._zod.def?.error?.(e))??gn(a?.(e))??gn(t?.error?.(e))??gn(n.customError?.(e))??gn(n.localeError?.(e))??`Invalid input`,s={};for(let t of Object.keys(e))t!==`inst`&&t!==`schema`&&t!==`continue`&&t!==`input`&&t!==`__proto__`&&(s[t]=e[t]);return s.path??=[],s.message=o,t?.reportInput&&(s.input=e.input),s}let bn=/[\uD800-\uDBFF]/;function xn(e){let t=e.length;if(!bn.test(e))return t;let n=t;for(let r=0;r<t-1;r++)(e.charCodeAt(r)&64512)==55296&&(e.charCodeAt(r+1)&64512)==56320&&(n--,r++);return n}function Sn(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function Cn(e){let t=typeof e;switch(t){case`number`:return Number.isNaN(e)?`nan`:`number`;case`object`:{if(e===null)return`null`;if(Array.isArray(e))return`array`;let t=e;if(t&&Object.getPrototypeOf(t)!==Object.prototype&&`constructor`in t&&t.constructor)return t.constructor.name}}return t}function wn(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}function Tn(e,t){for(let n in t){let r=Object.getOwnPropertyDescriptor(t,n);r.get?Object.defineProperty(e,n,{...r,enumerable:!1}):kn(e,n,r.value)}}function En(e,t,n,r=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:r,value:n}),n}function Dn(e,t,n){return En(e,t,n,!1)}function On(e,t){for(let n in e){let r=e[n];Object.defineProperty(t,n,{configurable:!0,enumerable:!0,get(){return En(this,n,r(this))},set(e){En(this,n,e)}})}return t}function kn(e,t,n){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?n:En(this,t,n.bind(this))},set(e){En(this,t,e)}})}function An(e,t){let n=Object.getPrototypeOf(e);return t in n?void 0:n}let jn,Mn=!1,Nn={configurable:!0,get(){Mn=!0}};function E(e,t,n){let r=Object.getPrototypeOf(e._zod);t in r&&jn!==e._zod?jn=void 0:(jn=e._zod,Object.defineProperty(r,t,{configurable:!0,get(){Object.defineProperty(this,t,Nn);let e=Mn;Mn=!1;try{let r=n(this);return Mn?delete this[t]:Object.defineProperty(this,t,{configurable:!0,writable:!0,value:r}),Mn||=e,r}catch(n){throw delete this[t],Mn||=e,n}},set(e){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:e})}}))}function Pn(e,t,n,r){let i=An(e,t);i&&Object.defineProperty(i,t,{configurable:!0,get(){let e={configurable:!0,writable:!0,enumerable:r,value:void 0};return Object.defineProperty(this,t,e),e.value=n(this),Object.defineProperty(this,t,e),e.value},set(e){Object.defineProperty(this,t,{configurable:!0,writable:!0,enumerable:r,value:e})}})}function Fn(e){let t=()=>e;return t[`~constantCatch`]=!0,t}var In;let Ln=/*@__PURE__*/ Object.freeze({status:`aborted`}),Rn={value:void 0,enumerable:!1},zn=`captureStackTrace`in Error?Error:null;function Bn(e){let t=zn;if(t){let n=t.stackTraceLimit;if(typeof n==`number`){try{t.stackTraceLimit=0}catch{return zn=null,new e}try{return new e}finally{t.stackTraceLimit=n}}}return new e}function D(e,t,n,r){let i={};function a(e){this.def=e,this.constr=d,this.traits=/* @__PURE__ */ new Set}a.prototype=i;let o=n,s=o&&/* @__PURE__ */ new WeakSet;function c(n,r){if(!n._zod){Rn.value=new a(r);try{Object.defineProperty(n,"_zod",Rn)}finally{Rn.value=void 0}}else if(n._zod.traits.has(e))return;if(n._zod.traits.add(e),t(n,r),s){let e=Object.getPrototypeOf(n),t=n._zod.constr.prototype,r=e;for(;r&&r!==t;)r=Object.getPrototypeOf(r);let i=r??e;s.has(i)||(s.add(i),Tn(i,o))}let i=d.prototype;for(let e in i)Object.prototype.hasOwnProperty.call(i,e)&&(e in n||(n[e]=i[e].bind(n)))}let l=r?.Parent??Object;class u extends l{}Object.defineProperty(u,"name",{value:e});function d(e){let t=r?.Parent?Bn(u):this;c(t,e);let n=t._zod.deferred;if(n){for(let e of n)e();t._zod.deferred=void 0}let i=globalThis.__zod_globalConfig?.postProcessor;return i&&i(t),t}return Object.defineProperty(d,"init",{value:c}),Object.defineProperty(d,Symbol.hasInstance,{value:t=>r?.Parent&&t instanceof r.Parent?!0:t?._zod?.traits?.has(e)}),Object.defineProperty(d,"name",{value:e}),d}var Vn=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}},Hn=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name=`ZodEncodeError`}};(In=globalThis).__zod_globalConfig??(In.__zod_globalConfig={});let Un=globalThis.__zod_globalConfig;function Wn(e){return e&&Object.assign(Un,e),Un}function Gn(){let e=this._zod;return e.message??=JSON.stringify(e.def,Dt,2),e.message}function Kn(e){this._zod.message=e}let qn={get:Gn,set:Kn,enumerable:!0,configurable:!0},Jn={value:void 0,enumerable:!1},Yn=/* @__PURE__ */ new WeakSet([Object.prototype,Error.prototype]),Xn=(e,t)=>{e.name=`$ZodError`,Jn.value=t,Object.defineProperty(e,"issues",Jn),Jn.value=void 0,Object.defineProperty(e,"message",qn);let n=Object.getPrototypeOf(e);Yn.has(n)||(Yn.add(n),Object.defineProperty(n,"toString",{configurable:!0,enumerable:!1,get(){let e=()=>this.message;return Object.defineProperty(this,"toString",{value:e,configurable:!0,writable:!0}),e},set(e){Object.defineProperty(this,"toString",{value:e,configurable:!0,writable:!0})}}))},Zn=D(`$ZodError`,Xn);D(`$ZodError`,Xn,void 0,{Parent:Error});function Qn(e,t,n){return Object.prototype.hasOwnProperty.call(e,t)||(t===`__proto__`?Object.defineProperty(e,t,{value:n(),writable:!0,enumerable:!0,configurable:!0}):e[t]=n()),e[t]}function $n(e,t=e=>e.message){let n={},r=[];for(let i of e.issues)i.path.length>0?Qn(n,i.path[0],()=>[]).push(t(i)):r.push(t(i));return{formErrors:r,fieldErrors:n}}function er(e,t=e=>e.message){let n={_errors:[]},r=(e,i=[])=>{for(let a of e.issues)if(a.code===`invalid_union`&&a.errors.length)a.errors.map(e=>r({issues:e},[...i,...a.path]));else if(a.code===`invalid_key`)r({issues:a.issues},[...i,...a.path]);else if(a.code===`invalid_element`)r({issues:a.issues},[...i,...a.path]);else{let e=[...i,...a.path];if(e.length===0)n._errors.push(t(a));else{let r=n,i=0;for(;i<e.length;){let n=e[i],o=i===e.length-1;if(n===`_errors`){o&&r._errors.push(t(a)),i++;continue}Object.prototype.hasOwnProperty.call(r,n)||Object.defineProperty(r,n,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});let s=r[n];o&&s._errors.push(t(a)),r=s,i++}}}};return r(e),n}function tr(e,t){return{callee:t?.callee??e,Err:t?.Err}}let nr=e=>{let t=(n,r,i,a)=>{let o=i?{...i,async:!1}:{async:!1},s=n._zod.run({value:r,issues:[]},o);if(s instanceof Promise)throw new Vn;if(s.issues.length){let n=new((a?.Err)??e)(s.issues.map(e=>yn(e,o,Wn())));throw Gt(n,a?.callee??t),n}return s.value};return t},rr=e=>{let t=async(n,r,i,a)=>{let o=i?{...i,async:!0}:{async:!0},s=n._zod.run({value:r,issues:[]},o);if(s instanceof Promise&&(s=await s),s.issues.length){let n=new((a?.Err)??e)(s.issues.map(e=>yn(e,o,Wn())));throw Gt(n,a?.callee??t),n}return s.value};return t},ir=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 Vn;return a.issues.length?ar(e,a.issues,i):{success:!0,data:a.value}};function ar(e,t,n){let r;return{success:!1,get error(){return r||(r=new e(t.map(e=>yn(e,n,Wn()))),t=void 0,n=void 0),r},set error(e){r=e,t=void 0,n=void 0}}}let or=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?ar(e,a.issues,i):{success:!0,data:a.value}},sr=/* @__PURE__ */ Symbol.for(`zod.compile.invalid`),cr=/* @__PURE__ */ Symbol.for(`zod.compile.fallback`),lr=((e,t,n)=>{let r=e._zod.bag.validator;if(r!==void 0){if(r(t)!==sr)return!0;if(r.definite===!0&&n===void 0)return!1}return ur(e,t,n)});function ur(e,t,n){let r=n?{...n,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},i=e._zod.bag.fallbackRun,a;if(i?(r[cr]=!0,a=i({value:t,issues:[]},r)):a=e._zod.run({value:t,issues:[]},r),a instanceof Promise)throw new Vn;return a.issues.length===0}let dr=async(e,t,n)=>{let r=n?{...n,async:!0,abortEarly:!0}:{async:!0,abortEarly:!0},i=e._zod.run({value:t,issues:[]},r);return i instanceof Promise&&(i=await i),i.issues.length===0},fr=e=>{let t=nr(e),n=(e,r,i,a)=>{let o=i?{...i,direction:`backward`}:{direction:`backward`};return t(e,r,o,tr(n,a))};return n},pr=e=>{let t=nr(e),n=(e,r,i,a)=>t(e,r,i,tr(n,a));return n},mr=e=>{let t=rr(e),n=async(e,r,i,a)=>{let o=i?{...i,direction:`backward`}:{direction:`backward`};return await t(e,r,o,tr(n,a))};return n},hr=e=>{let t=rr(e),n=async(e,r,i,a)=>await t(e,r,i,tr(n,a));return n},gr=e=>(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return ir(e)(t,n,i)},_r=e=>(t,n,r)=>ir(e)(t,n,r),vr=e=>async(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return or(e)(t,n,i)},yr=e=>async(t,n,r)=>or(e)(t,n,r),br=/^[cC][0-9a-z]{6,}$/,xr=/^[0-9a-z]+$/,Sr=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,Cr=/^[0-9a-vA-V]{20}$/,wr=/^[A-Za-z0-9]{27}$/,Tr=/^[a-zA-Z0-9_-]{21}$/;function Er(e){return RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}let Dr=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Or=/^([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})$/,kr=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)$/,Ar=/^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;function jr(){return RegExp(`^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$`,`u`)}let Mr=/^(?:(?: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])$/,Nr=/^(([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}|:))$/,Pr=/^((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])$/,Fr=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Ir=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Lr=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/,Rr=/^https?$/,zr=/^\+[1-9]\d{6,14}$/,Br=`(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))`;function Vr(e){return RegExp(`^${e}$`)}let Hr=/*@__PURE__*/ Vr(Br);function Ur(e){let t=`(?:[01]\\d|2[0-3]):[0-5]\\d`;return typeof e.precision==`number`?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:e.seconds?`${t}:[0-5]\\d(?:\\.\\d+)?`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function Wr(e){return RegExp(`^${Ur(e)}$`)}function Gr(e){let t=[`Z`];e.offset&&t.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);let n=`${Ur({precision:e.precision,seconds:!0})}(?:${t.join(`|`)})`,r=e.local?`${n}|${Ur({precision:e.precision})}`:n;return RegExp(`^${Br}T(?:${r})$`)}let Kr=/^[\s\S]{0,}$/,qr=/^-?\d+$/,Jr=/^-?\d+(?:\.\d+)?$/,Yr=/^(?:true|false)$/i,Xr=/^null$/i,Zr=/^[^A-Z]*$/,Qr=/^[^a-z]*$/,$r=/*@__PURE__*/ D(`$ZodCheck`,(e,t)=>{var n;e._zod??={},e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),ei=e=>{let t=e.value;return!At(t)&&t.length!==void 0},ti={number:`number`,bigint:`bigint`,object:`date`},ni=/*@__PURE__*/ D(`$ZodCheckLessThan`,(e,t)=>{$r.init(e,t);let n=ti[typeof t.value];e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:ti[typeof r.value]??n,code:`too_big`,maximum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),ri=/*@__PURE__*/ D(`$ZodCheckGreaterThan`,(e,t)=>{$r.init(e,t);let n=ti[typeof t.value];e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:ti[typeof r.value]??n,code:`too_small`,minimum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),ii=/*@__PURE__*/ D(`$ZodCheckMultipleOf`,(e,t)=>{$r.init(e,t),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw Error(`Cannot mix number and bigint in multiple_of check.`);(typeof n.value==`bigint`?t.value!==BigInt(0)&&n.value%t.value===BigInt(0):Mt(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})}}),ai=/*@__PURE__*/ D(`$ZodCheckNumberFormat`,(e,t)=>{$r.init(e,t),t.format=t.format||`float64`;let n=t.format?.includes(`int`),r=n?`int`:`number`,[i,a]=tn[t.format];e._zod.check=o=>{let s=o.value;if(n){if(!Number.isInteger(s)){o.issues.push({expected:r,format:t.format,code:`invalid_type`,continue:!1,input:s,inst:e});return}if(!Number.isSafeInteger(s)){s>0?o.issues.push({input:s,code:`too_big`,maximum:2**53-1,note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort}):o.issues.push({input:s,code:`too_small`,minimum:-(2**53-1),note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort});return}}s<i&&o.issues.push({origin:`number`,input:s,code:`too_small`,minimum:i,inclusive:!0,inst:e,continue:!t.abort}),s>a&&o.issues.push({origin:`number`,input:s,code:`too_big`,maximum:a,inclusive:!0,inst:e,continue:!t.abort})}}),oi=/*@__PURE__*/ D(`$ZodCheckMaxLength`,(e,t)=>{var n;$r.init(e,t),(n=e._zod.def).when??(n.when=ei),e._zod.check=n=>{let r=n.value,i=r.length;if((typeof r==`string`&&i>t.maximum?xn(r):i)<=t.maximum)return;let a=Sn(r);n.issues.push({origin:a,code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),si=/*@__PURE__*/ D(`$ZodCheckMinLength`,(e,t)=>{var n;$r.init(e,t),(n=e._zod.def).when??(n.when=ei),e._zod.check=n=>{let r=n.value,i=r.length;if((typeof r==`string`&&i>=t.minimum&&i<t.minimum*2?xn(r):i)>=t.minimum)return;let a=Sn(r);n.issues.push({origin:a,code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),ci=/*@__PURE__*/ D(`$ZodCheckLengthEquals`,(e,t)=>{var n;$r.init(e,t),(n=e._zod.def).when??(n.when=ei),e._zod.check=n=>{let r=n.value,i=r.length,a=typeof r==`string`&&i>=t.length&&i<=t.length*2?xn(r):i;if(a===t.length)return;let o=Sn(r),s=a>t.length;n.issues.push({origin:o,...s?{code:`too_big`,maximum:t.length}:{code:`too_small`,minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),li=/*@__PURE__*/ D(`$ZodCheckStringFormat`,(e,t)=>{var n,r;$r.init(e,t),t.pattern?(n=e._zod).check??(n.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),ui=/*@__PURE__*/ D(`$ZodCheckRegex`,(e,t)=>{li.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})}}),di=/*@__PURE__*/ D(`$ZodCheckLowerCase`,(e,t)=>{t.pattern??=Zr,li.init(e,t)}),fi=/*@__PURE__*/ D(`$ZodCheckUpperCase`,(e,t)=>{t.pattern??=Qr,li.init(e,t)}),pi=/*@__PURE__*/ D(`$ZodCheckIncludes`,(e,t)=>{$r.init(e,t);let n=Zt(t.includes);t.pattern=new RegExp(typeof t.position==`number`?`^.{${t.position},}${n}`:n),e._zod.check=n=>{n.value.includes(t.includes,t.position)||n.issues.push({origin:`string`,code:`invalid_format`,format:`includes`,includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),mi=/*@__PURE__*/ D(`$ZodCheckStartsWith`,(e,t)=>{$r.init(e,t);let n=RegExp(`^${Zt(t.prefix)}.*`);t.pattern??=n,e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`starts_with`,prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),hi=/*@__PURE__*/ D(`$ZodCheckEndsWith`,(e,t)=>{$r.init(e,t);let n=RegExp(`.*${Zt(t.suffix)}$`);t.pattern??=n,e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`ends_with`,suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}),gi=/*@__PURE__*/ D(`$ZodCheckOverwrite`,(e,t)=>{$r.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}});var _i=class{constructor(e=[],t={}){this.content=[],this.indent=0,this.args=e,this.closed=t}indented(e){this.indent+=1;try{e(this)}finally{--this.indent}}write(e){if(typeof e==`function`){e(this,{execution:`sync`}),e(this,{execution:`async`});return}let t=e.split(`
|
|
12
|
+
`).filter(e=>e),n=Math.min(...t.map(e=>e.length-e.trimStart().length)),r=t.map(e=>e.slice(n)).map(e=>` `.repeat(this.indent*2)+e);for(let e of r)this.content.push(e)}compile(){let e=Function,t=this?.content??[``];return new e(...Object.keys(this.closed),`return function (${this.args.join(`, `)}) {\n${t.join(`
|
|
13
|
+
`)}\n};`)(...Object.values(this.closed))}};let vi={major:4,minor:6,patch:7},yi=/*@__PURE__*/ D(`$ZodType`,(e,t)=>{var n;e??={},e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=vi;let r=e._zod.def.checks,i=e._zod.traits.has(`$ZodCheck`)?[e,...r??[]]:r?.length?[...r]:[];for(let t of i)for(let n of t._zod.onattach)n(e);if(i.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let t=(t,n,r)=>{if(t.memo)return t;let i=pn(t),a;for(let o of n){if(o._zod.def.when){if(mn(t)||!o._zod.def.when(t))continue}else if(i)continue;let n=t.issues.length,s=o._zod.check(t);if(s instanceof Promise&&r?.async===!1)throw new Vn;if(a||s instanceof Promise)a=(a??Promise.resolve()).then(async()=>{await s,t.issues.length!==n&&(vn(t.issues,n,e),i||=pn(t,n))});else{if(t.issues.length===n)continue;vn(t.issues,n,e),i||=pn(t,n)}}return a?a.then(()=>t):t},n=(n,r,a)=>{if(pn(n))return n.aborted=!0,n;let o=t(r,i,a);if(o instanceof Promise){if(a.async===!1)throw new Vn;return o.then(t=>e._zod.parse(t,a))}return e._zod.parse(o,a)};e._zod.run=(r,a)=>{if(a.skipChecks)return e._zod.parse(r,a);if(a.direction===`backward`){let t=e._zod.parse({value:r.value,issues:[]},{...a,skipChecks:!0});return t instanceof Promise?t.then(e=>n(e,r,a)):n(t,r,a)}let o=e._zod.parse(r,a);if(o instanceof Promise){if(a.async===!1)throw new Vn;return o.then(e=>t(e,i,a))}return t(o,i,a)}}},{get"~standard"(){return Dn(this,`~standard`,Si(this))},set"~standard"(e){En(this,`~standard`,e)}}),bi=(e,t)=>e.issues.length?{issues:e.issues.map(e=>yn(e,t,Wn()))}:{value:e.value};async function xi(e,t){let n={async:!0};return bi(await e._zod.run({value:t,issues:[]},n),n)}function Si(e){return{validate:t=>{let n={async:!1};try{let r=e._zod.run({value:t,issues:[]},n);if(!(r instanceof Promise))return bi(r,n)}catch{}return xi(e,t)},vendor:`zod`,version:1}}let Ci=/*@__PURE__*/ D(`$ZodString`,(e,t)=>{yi.init(e,t),e._zod.pattern=t.pattern??Kr,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}}),wi=/*@__PURE__*/ D(`$ZodStringFormat`,(e,t)=>{li.init(e,t),Ci.init(e,t)}),Ti=/*@__PURE__*/ D(`$ZodGUID`,(e,t)=>{t.pattern??=Or,wi.init(e,t)}),Ei=/*@__PURE__*/ D(`$ZodUUID`,(e,t)=>{if(t.version){let e={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(e===void 0)throw Error(`Invalid UUID version: "${t.version}"`);t.pattern??=kr(e)}else t.pattern??=kr();wi.init(e,t)}),Di=/*@__PURE__*/ D(`$ZodEmail`,(e,t)=>{t.pattern??=Ar,wi.init(e,t)});function Oi(e){try{return typeof URL<`u`&&typeof URL.canParse==`function`?URL.canParse(e):(new URL(e),!0)}catch{return!1}}function ki(e,t){return!(`normalize`in t)&&!(`hostname`in t)&&!(`protocol`in t)?Oi(e)||2:Ai(e,t)}function Ai(e,t){if(!t.normalize&&t.protocol?.source===Rr.source&&!/^https?:\/\//i.test(e))return 1;try{if(typeof URL<`u`){let t=URL;if(typeof t.parse==`function`)return t.parse(e)??2}return new URL(e)}catch{return 2}}let ji=/[\t\n\r]/g;function Mi(e){return e.replace(ji,``)}function Ni(e,t){return t.lastIndex=0,t.test(e.hostname)}function Pi(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(`:`)?e.protocol.slice(0,-1):e.protocol)}let Fi=/*@__PURE__*/ D(`$ZodURL`,(e,t)=>{wi.init(e,t),e._zod.check=n=>{try{let r=n.value.trim(),i=ki(r,t);if(i===1){n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid URL format`,input:n.value,inst:e,continue:!t.abort});return}if(i===2){n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort});return}if(i===!0){n.value=Mi(r);return}t.hostname&&!Ni(i,t.hostname)&&n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid hostname`,pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort}),t.protocol&&!Pi(i,t.protocol)&&n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid protocol`,pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort}),n.value=t.normalize?i.href:Mi(r);return}catch{n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort})}}}),Ii=/*@__PURE__*/ D(`$ZodEmoji`,(e,t)=>{t.pattern??=jr(),wi.init(e,t)}),Li=/*@__PURE__*/ D(`$ZodNanoID`,(e,t)=>{if(t.length!==void 0&&(!Number.isInteger(t.length)||t.length<1))throw Error(`Invalid nanoid length: ${t.length}`);t.pattern??=t.length===void 0?Tr:Er(t.length),wi.init(e,t)}),Ri=/*@__PURE__*/ D(`$ZodCUID`,(e,t)=>{t.pattern??=br,wi.init(e,t)}),zi=/*@__PURE__*/ D(`$ZodCUID2`,(e,t)=>{t.pattern??=xr,wi.init(e,t)}),Bi=/*@__PURE__*/ D(`$ZodULID`,(e,t)=>{t.pattern??=Sr,wi.init(e,t)}),Vi=/*@__PURE__*/ D(`$ZodXID`,(e,t)=>{t.pattern??=Cr,wi.init(e,t)}),Hi=/*@__PURE__*/ D(`$ZodKSUID`,(e,t)=>{t.pattern??=wr,wi.init(e,t)}),Ui=/*@__PURE__*/ D(`$ZodISODateTime`,(e,t)=>{t.pattern??=Gr(t),wi.init(e,t)}),Wi=/*@__PURE__*/ D(`$ZodISODate`,(e,t)=>{t.pattern??=Hr,wi.init(e,t)}),Gi=/*@__PURE__*/ D(`$ZodISOTime`,(e,t)=>{t.pattern??=Wr(t),wi.init(e,t)}),Ki=/*@__PURE__*/ D(`$ZodISODuration`,(e,t)=>{t.pattern??=Dr,wi.init(e,t)}),qi=/*@__PURE__*/ D(`$ZodIPv4`,(e,t)=>{t.pattern??=Mr,wi.init(e,t)}),Ji=/^[0-9a-fA-F:.]+$/;function Yi(e){return Ji.test(e)?Oi(`http://[${e}]`):!1}let Xi=/*@__PURE__*/ D(`$ZodIPv6`,(e,t)=>{t.pattern??=Nr,wi.init(e,t),e._zod.check=n=>{Yi(n.value)||n.issues.push({code:`invalid_format`,format:`ipv6`,input:n.value,inst:e,continue:!t.abort})}}),Zi=/*@__PURE__*/ D(`$ZodCIDRv4`,(e,t)=>{t.pattern??=Pr,wi.init(e,t)});function Qi(e){let t=e.split(`/`);if(t.length!==2)return!1;let[n,r]=t;if(!r)return!1;let i=Number(r);return`${i}`!==r||i<0||i>128?!1:Yi(n)}let $i=/*@__PURE__*/ D(`$ZodCIDRv6`,(e,t)=>{t.pattern??=Fr,wi.init(e,t),e._zod.check=n=>{Qi(n.value)||n.issues.push({code:`invalid_format`,format:`cidrv6`,input:n.value,inst:e,continue:!t.abort})}});function ea(e){if(e===``)return!0;if(/\s/.test(e)||e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}let ta=/^[0-9a-zA-Z+/]*={0,2}$/,na=/*@__PURE__*/ D(`$ZodBase64`,(e,t)=>{t.pattern??=ta,wi.init(e,t),e._zod.check=n=>{ea(n.value)||n.issues.push({code:`invalid_format`,format:`base64`,input:n.value,inst:e,continue:!t.abort})}}),ra=/^[A-Za-z0-9_-]*$/;function ia(e){if(!ra.test(e))return!1;let t=e.replace(/[-_]/g,e=>e===`-`?`+`:`/`);return ea(t.padEnd(Math.ceil(t.length/4)*4,`=`))}let aa=/*@__PURE__*/ D(`$ZodBase64URL`,(e,t)=>{t.pattern??=ra,wi.init(e,t),e._zod.check=n=>{ia(n.value)||n.issues.push({code:`invalid_format`,format:`base64url`,input:n.value,inst:e,continue:!t.abort})}}),oa=/*@__PURE__*/ D(`$ZodE164`,(e,t)=>{t.pattern??=zr,wi.init(e,t)});function sa(e,t=null){try{let n=e.split(`.`);if(n.length!==3)return!1;let[r]=n;if(!r)return!1;let i=JSON.parse(atob(r));return!(`typ`in i&&i?.typ!==`JWT`||!i.alg||t&&(!(`alg`in i)||i.alg!==t))}catch{return!1}}let ca=/*@__PURE__*/ D(`$ZodJWT`,(e,t)=>{wi.init(e,t),e._zod.check=n=>{sa(n.value,t.alg)||n.issues.push({code:`invalid_format`,format:`jwt`,input:n.value,inst:e,continue:!t.abort})}}),la=/*@__PURE__*/ D(`$ZodNumber`,(e,t)=>{yi.init(e,t),e._zod.pattern=Jr,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}let i=n.value;if(typeof i==`number`&&!Number.isNaN(i)&&Number.isFinite(i))return n;let a=typeof i==`number`?Number.isNaN(i)?`NaN`:Number.isFinite(i)?void 0:String(i):void 0;return n.issues.push({expected:`number`,code:`invalid_type`,input:i,inst:e,...a?{received:a}:{}}),n}}),ua=/*@__PURE__*/ D(`$ZodNumberFormat`,(e,t)=>{ai.init(e,t),la.init(e,t)}),da=/*@__PURE__*/ D(`$ZodBoolean`,(e,t)=>{yi.init(e,t),e._zod.pattern=Yr,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}}),fa=/*@__PURE__*/ D(`$ZodNull`,(e,t)=>{yi.init(e,t),e._zod.pattern=Xr,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}}),pa=/*@__PURE__*/ D(`$ZodUnknown`,(e,t)=>{yi.init(e,t),e._zod.parse=e=>e}),ma=/*@__PURE__*/ D(`$ZodNever`,(e,t)=>{yi.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:`never`,code:`invalid_type`,input:t.value,inst:e}),t)});function ha(e,t){let n=_n(e._zod.def.checks);if(!n.length)return;let r=Math.min(...n.map(e=>e[0])),i=e._zod.parse;e._zod.parse=(n,a)=>{let o=t(n.value);if(o>r&&!a?.skipChecks&&a?.direction!==`backward`){for(let[t,r]of _n(e._zod.def.checks))if(o>t&&r._zod.def.when(n)){let t=n.issues.length;return r._zod.check(n),n.issues[t].continue=!1,vn(n.issues,t,e),n}}return i(n,a)}}let ga=e=>Array.isArray(e)?e.length:-1;function _a(e,t,n){e.issues.length&&t.issues.push(...hn(n,e.issues)),t.value[n]=e.value}let va=/*@__PURE__*/ D(`$ZodArray`,(e,t)=>{yi.init(e,t);let n=Un.memoizer;n?.attach(e),e._zod.parse=(r,i)=>{let a=r.value;if(!Array.isArray(a))return r.issues.push({expected:`array`,code:`invalid_type`,input:a,inst:e}),r;r.value=n?n.alloc(e,r,Array(a.length),i):Array(a.length);let o=[],s=i?.abortEarly;for(let e=0;e<a.length;e++){let n=a[e],c=t.element._zod.run({value:n,issues:[]},i);if(c instanceof Promise)o.push(c.then(t=>_a(t,r,e)));else if(_a(c,r,e),s&&c.issues.length!==0&&pn(c))break}return o.length?Promise.all(o).then(()=>r):r},ha(e,ga)});function ya(e,t,n,r,i,a){let o=n in r,s=a===`optional`;if(o||!s||i!==`optional`){if(e.issues.length){if(i!==void 0&&s&&!o)return;t.issues.push(...hn(n,e.issues))}!o&&i===void 0?e.issues.length||t.issues.push({code:`invalid_type`,expected:`nonoptional`,input:void 0,path:[n]}):e.value===void 0?(o||i===`defaulted`&&!s)&&(t.value[n]=void 0):t.value[n]=e.value}}let ba=[];function xa(e){let t=Object.keys(e.shape),n=Object.getOwnPropertySymbols(e.shape),r=n.length?n:ba,i=r.length?[...t,...r]:t;for(let t of i)if(!e.shape?.[t]?._zod?.traits?.has(`$ZodType`))throw Error(`Invalid element at key "${String(t)}": expected a Zod schema`);let a=en(e.shape);return{...e,allKeys:i,symbolKeys:r,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(a)}}function Sa(e,t,n,r,i,a,o){let s=[],c=i.keySet,l=i.catchall._zod,u=l.def.type,d=l.optin,f=l.optout,p=0;for(let i in t){if(o&&n.issues.length!==p){if(pn(n,p))break;p=n.issues.length}if(c.has(i))continue;if(i===`__proto__`){u===`never`&&s.push(i);continue}if(u===`never`){s.push(i);continue}let a=l.run({value:t[i],issues:[]},r);a instanceof Promise?e.push(a.then(e=>ya(e,n,i,t,d,f))):ya(a,n,i,t,d,f)}return s.length&&n.issues.push({code:`unrecognized_keys`,keys:s,input:t,inst:a,continue:!0}),e.length?Promise.all(e).then(()=>n):n}let Ca=/*@__PURE__*/ D(`$ZodObject`,(e,t)=>{yi.init(e,t);let n=Object.getOwnPropertyDescriptor(t,`shape`),r=n?.get?n.get.raw:t.shape??{};if(r){let e=()=>{let n={...r};return Object.defineProperty(t,"shape",{value:n}),e.raw=n,n};e.raw=r,Object.defineProperty(t,"shape",{get:e})}let i=kt(()=>xa(t));E(e,`propValues`,e=>{let t=e.def.shape,n={};for(let e in t){let r=t[e]._zod;if(r.values){Object.prototype.hasOwnProperty.call(n,e)||Ft(n,e,/* @__PURE__ */ new Set);for(let t of r.values)n[e].add(t);r.optin!==void 0&&n[e].add(void 0)}}return n});let a=Kt,o=t.catchall,s,c=Un.memoizer;c?.attach(e),e._zod.parse=(t,n)=>{s??=i.value;let r=t.value;if(!a(r))return t.issues.push({expected:`object`,code:`invalid_type`,input:r,inst:e}),t;t.value=c?c.alloc(e,t,{},n):{};let l=[],u=s.shape,d=n?.abortEarly,f=t.issues.length;for(let e of s.allKeys){if(d&&t.issues.length!==f){if(pn(t,f))break;f=t.issues.length}if(e===`__proto__`)continue;let i=u[e],a=i._zod.optin,o=i._zod.optout,s=i._zod.run({value:r[e],issues:[]},n);s instanceof Promise?l.push(s.then(n=>ya(n,t,e,r,a,o))):ya(s,t,e,r,a,o)}return o?Sa(l,r,t,n,i.value,e,d===!0):l.length?Promise.all(l).then(()=>t):t}}),wa=/*@__PURE__*/ D(`$ZodObjectJIT`,(e,t)=>{Ca.init(e,t);let n=e._zod.parse,r=kt(()=>xa(t)),i=Un.memoizer,a=t=>{let n=r.value,a=n.symbolKeys,o=new _i([`payload`,`ctx`],{shape:t,inst:e,memo:i,syms:a}),s=e=>`shape[${e}]._zod.run({ value: input[${e}], issues: [] }, ctx)`,c=(e,t)=>`
|
|
14
|
+
let ${e}_ab = false;
|
|
15
|
+
for (let i = 0; i < ${e}.issues.length; i++) {
|
|
16
|
+
const iss = ${e}.issues[i];
|
|
17
|
+
iss.path = iss.path ? [${t}, ...iss.path] : [${t}];
|
|
18
|
+
payload.issues.push(iss);
|
|
19
|
+
if (iss.continue !== true) ${e}_ab = true;
|
|
20
20
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
21
|
+
if (${e}_ab && ctx && ctx.abortEarly) {
|
|
22
|
+
payload.value = newResult;
|
|
23
|
+
return payload;
|
|
24
|
+
}`;o.write(`const input = payload.value;`);let l=Object.create(null),u=0;for(let e of n.allKeys)l[e]=`key_${u++}`;o.write(i?`const newResult = memo.alloc(inst, payload, {}, ctx);`:`const newResult = {};`);for(let e of n.allKeys){if(e===`__proto__`)continue;let n=l[e],r=typeof e==`symbol`?`syms[${a.indexOf(e)}]`:Ut(e),i=`${r} in input`,u=t[e],d=u?._zod?.optin,f=d!==void 0,p=u?._zod?.optout===`optional`;if(o.write(`const ${n} = ${s(r)};`),f&&p){let e=d===`optional`?`${n}_present`:`${n}.value !== undefined || ${n}_present`;o.write(`
|
|
25
|
+
const ${n}_present = ${i};
|
|
26
|
+
if (!${n}.issues.length || ${n}_present) {
|
|
27
|
+
if (${n}.issues.length) {${c(n,r)}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
if (${e}) {
|
|
31
|
+
newResult[${r}] = ${n}.value;
|
|
26
32
|
}
|
|
27
|
-
} else {
|
|
28
|
-
newResult[${o}] = ${n}.value;
|
|
29
33
|
}
|
|
30
|
-
|
|
31
|
-
`)
|
|
32
|
-
if (${n}.issues.length) {
|
|
33
|
-
payload.issues = payload.issues.concat(${n}.issues.map(iss => ({
|
|
34
|
-
...iss,
|
|
35
|
-
path: iss.path ? [${o}, ...iss.path] : [${o}]
|
|
36
|
-
})));
|
|
34
|
+
|
|
35
|
+
`)}else f?(o.write(`
|
|
36
|
+
if (${n}.issues.length) {${c(n,r)}
|
|
37
37
|
}
|
|
38
|
-
|
|
39
|
-
if (${n}.value
|
|
40
|
-
|
|
41
|
-
newResult[${o}] = undefined;
|
|
42
|
-
}
|
|
43
|
-
} else {
|
|
44
|
-
newResult[${o}] = ${n}.value;
|
|
38
|
+
`),d===`defaulted`?o.write(`newResult[${r}] = ${n}.value;`):o.write(`
|
|
39
|
+
if (${n}.value !== undefined || ${i}) {
|
|
40
|
+
newResult[${r}] = ${n}.value;
|
|
45
41
|
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
if (${n}.issues.length) {
|
|
50
|
-
payload.issues = payload.issues.concat(${n}.issues.map(iss => ({
|
|
51
|
-
...iss,
|
|
52
|
-
path: iss.path ? [${o}, ...iss.path] : [${o}]
|
|
53
|
-
})));
|
|
42
|
+
`)):o.write(`
|
|
43
|
+
const ${n}_present = ${i};
|
|
44
|
+
if (${n}.issues.length) {${c(n,r)}
|
|
54
45
|
}
|
|
55
46
|
if (!${n}_present && !${n}.issues.length) {
|
|
56
47
|
payload.issues.push({
|
|
57
48
|
code: "invalid_type",
|
|
58
49
|
expected: "nonoptional",
|
|
59
50
|
input: undefined,
|
|
60
|
-
path: [${
|
|
51
|
+
path: [${r}]
|
|
61
52
|
});
|
|
53
|
+
if (ctx && ctx.abortEarly) {
|
|
54
|
+
payload.value = newResult;
|
|
55
|
+
return payload;
|
|
56
|
+
}
|
|
62
57
|
}
|
|
63
58
|
|
|
64
59
|
if (${n}_present) {
|
|
65
|
-
|
|
66
|
-
newResult[${o}] = undefined;
|
|
67
|
-
} else {
|
|
68
|
-
newResult[${o}] = ${n}.value;
|
|
69
|
-
}
|
|
60
|
+
newResult[${r}] = ${n}.value;
|
|
70
61
|
}
|
|
71
62
|
|
|
72
|
-
`)}t.write(`payload.value = newResult;`),t.write(`return payload;`);let s=t.compile();return(t,n)=>s(e,t,n)},a,o=Wt,s=!At.jitless,c=s&&Gt.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?pi([],p,d,f,u,e):d):n(d,f):(d.issues.push({expected:`object`,code:`invalid_type`,input:p,inst:e}),d)}});function gi(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=>!sn(e));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:`invalid_union`,input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>dn(e,r,jt())))}),t)}let _i=/*@__PURE__*/ w(`$ZodUnion`,(e,t)=>{D.init(e,t),T(e._zod,`optin`,()=>t.options.some(e=>e._zod.optin===`optional`)?`optional`:void 0),T(e._zod,`optout`,()=>t.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),T(e._zod,`values`,()=>{if(t.options.every(e=>e._zod.values))return new Set(t.options.flatMap(e=>Array.from(e._zod.values)))}),T(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=>It(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=>gi(t,r,e,i)):gi(o,r,e,i)}}),vi=/*@__PURE__*/ w(`$ZodDiscriminatedUnion`,(e,t)=>{t.inclusive=!1,_i.init(e,t);let n=e._zod.parse;T(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=Pt(()=>{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(!Wt(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)}}),yi=/*@__PURE__*/ w(`$ZodIntersection`,(e,t)=>{D.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])=>xi(e,t,n)):xi(e,i,a)}});function bi(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(Kt(e)&&Kt(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=bi(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=bi(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 xi(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}),sn(e))return e;let o=bi(t.value,n.value);if(!o.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(o.mergeErrorPath)}`);return e.value=o.data,e}let Si=/*@__PURE__*/ w(`$ZodTuple`,(e,t)=>{D.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=Ci(n,`optin`),c=Ci(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=>wi(t,r,e))):wi(a,r,e)}}return o.length?Promise.all(o).then(()=>Ti(l,r,n,a,c)):Ti(l,r,n,a,c)}});function Ci(e,t){for(let n=e.length-1;n>=0;n--)if(e[n]._zod[t]!==`optional`)return n+1;return 0}function wi(e,t,n){e.issues.length&&t.issues.push(...ln(n,e.issues)),t.value[n]=e.value}function Ti(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(...ln(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 Ei=/*@__PURE__*/ w(`$ZodRecord`,(e,t)=>{D.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!Kt(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=>dn(e,r,jt())),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(...ln(c,e.issues)),n.value[l]=e.value})):(u.issues.length&&n.issues.push(...ln(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`&&ar.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=>dn(e,r,jt())),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(...ln(o,e.issues)),n.value[s.value]=e.value})):(c.issues.length&&n.issues.push(...ln(o,c.issues)),n.value[s.value]=c.value)}}return a.length?Promise.all(a).then(()=>n):n}}),Di=/*@__PURE__*/ w(`$ZodEnum`,(e,t)=>{D.init(e,t);let n=Mt(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=RegExp(`^(${n.filter(e=>Jt.has(typeof e)).map(e=>typeof e==`string`?Yt(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}}),Oi=/*@__PURE__*/ w(`$ZodLiteral`,(e,t)=>{if(D.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`?Yt(e):e?Yt(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}}),ki=/*@__PURE__*/ w(`$ZodTransform`,(e,t)=>{D.init(e,t),e._zod.optin=`optional`,e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new kt(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 Ot;return n.value=i,n.fallback=!0,n}});function Ai(e,t){return t===void 0&&(e.issues.length||e.fallback)?{issues:[],value:void 0}:e}let ji=/*@__PURE__*/ w(`$ZodOptional`,(e,t)=>{D.init(e,t),e._zod.optin=`optional`,e._zod.optout=`optional`,T(e._zod,`values`,()=>t.innerType._zod.values?/* @__PURE__ */ new Set([...t.innerType._zod.values,void 0]):void 0),T(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${It(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=>Ai(e,r)):Ai(i,r)}return e.value===void 0?e:t.innerType._zod.run(e,n)}}),Mi=/*@__PURE__*/ w(`$ZodExactOptional`,(e,t)=>{ji.init(e,t),T(e._zod,`values`,()=>t.innerType._zod.values),T(e._zod,`pattern`,()=>t.innerType._zod.pattern),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),Ni=/*@__PURE__*/ w(`$ZodNullable`,(e,t)=>{D.init(e,t),T(e._zod,`optin`,()=>t.innerType._zod.optin),T(e._zod,`optout`,()=>t.innerType._zod.optout),T(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${It(e.source)}|null)$`):void 0}),T(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)}),Pi=/*@__PURE__*/ w(`$ZodDefault`,(e,t)=>{D.init(e,t),e._zod.optin=`optional`,T(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=>Fi(e,t)):Fi(r,t)}});function Fi(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}let Ii=/*@__PURE__*/ w(`$ZodPrefault`,(e,t)=>{D.init(e,t),e._zod.optin=`optional`,T(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))}),Li=/*@__PURE__*/ w(`$ZodNonOptional`,(e,t)=>{D.init(e,t),T(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=>Ri(t,e)):Ri(i,e)}});function Ri(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 zi=/*@__PURE__*/ w(`$ZodCatch`,(e,t)=>{D.init(e,t),e._zod.optin=`optional`,T(e._zod,`optout`,()=>t.innerType._zod.optout),T(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=>dn(e,n,jt()))},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=>dn(e,n,jt()))},input:e.value}),e.issues=[],e.fallback=!0),e)}}),Bi=/*@__PURE__*/ w(`$ZodPipe`,(e,t)=>{D.init(e,t),T(e._zod,`values`,()=>t.in._zod.values),T(e._zod,`optin`,()=>t.in._zod.optin),T(e._zod,`optout`,()=>t.out._zod.optout),T(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=>Vi(e,t.in,n)):Vi(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>Vi(e,t.out,n)):Vi(r,t.out,n)}});function Vi(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 Hi=/*@__PURE__*/ w(`$ZodReadonly`,(e,t)=>{D.init(e,t),T(e._zod,`propValues`,()=>t.innerType._zod.propValues),T(e._zod,`values`,()=>t.innerType._zod.values),T(e._zod,`optin`,()=>t.innerType?._zod?.optin),T(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(Ui):Ui(r)}});function Ui(e){return e.value=Object.freeze(e.value),e}let Wi=/*@__PURE__*/ w(`$ZodLazy`,(e,t)=>{D.init(e,t),T(e._zod,`innerType`,()=>{let e=t;return e._cachedInner||=t.getter(),e._cachedInner}),T(e._zod,`pattern`,()=>e._zod.innerType?._zod?.pattern),T(e._zod,`propValues`,()=>e._zod.innerType?._zod?.propValues),T(e._zod,`optin`,()=>e._zod.innerType?._zod?.optin??void 0),T(e._zod,`optout`,()=>e._zod.innerType?._zod?.optout??void 0),e._zod.parse=(t,n)=>e._zod.innerType._zod.run(t,n)}),Gi=/*@__PURE__*/ w(`$ZodCustom`,(e,t)=>{ur.init(e,t),D.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=>Ki(t,n,r,e));Ki(i,n,r,e)}});function Ki(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(pn(e))}}var qi,Ji=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 Yi(){return new Ji}(qi=globalThis).__zod_globalRegistry??(qi.__zod_globalRegistry=Yi());let Xi=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
|
|
63
|
+
`)}return o.write(`payload.value = newResult;`),o.write(`return payload;`),o.compile()},o,s=Kt,c=!Un.jitless,l=c&&qt.value,u=t.catchall,d;e._zod.parse=(i,f)=>{d??=r.value;let p=i.value;return s(p)?c&&l&&f?.async===!1&&f.jitless!==!0?(o||=a(t.shape),i=o(i,f),u?Sa([],p,i,f,d,e,f?.abortEarly===!0):i):n(i,f):(i.issues.push({expected:`object`,code:`invalid_type`,input:p,inst:e}),i)}});function Ta(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=>!pn(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=>yn(e,r,Wn())))}),t)}let Ea=/*@__PURE__*/ D(`$ZodUnion`,(e,t)=>{yi.init(e,t),E(e,`optin`,e=>e.def.options.some(e=>e._zod.optin===`defaulted`)?`defaulted`:e.def.options.some(e=>e._zod.optin!==void 0)?`optional`:void 0),E(e,`optout`,e=>e.def.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),E(e,`values`,e=>{if(e.def.options.every(e=>e._zod.values))return new Set(e.def.options.flatMap(e=>Array.from(e._zod.values)))}),E(e,`pattern`,e=>{if(e.def.options.every(e=>e._zod.pattern)){let t=e.def.options.map(e=>e._zod.pattern);return RegExp(`^(${t.map(e=>jt(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=>Ta(t,r,e,i)):Ta(o,r,e,i)}});function Da(e){let t=/* @__PURE__ */ new Map;for(let n of e.options){let r=n._zod.propValues?.[e.discriminator];if(!r||r.size===0)throw Error(`Invalid discriminated union option at index "${e.options.indexOf(n)}"`);for(let e of r)if(t.has(e)){if(e!==void 0)throw Error(`Duplicate discriminator value "${String(e)}"`);t.set(e,null)}else t.set(e,n)}return t}let Oa=/*@__PURE__*/ D(`$ZodDiscriminatedUnion`,(e,t)=>{t.inclusive=!1,Ea.init(e,t);let n=e._zod.parse;E(e,`propValues`,e=>{let t={},n=0;for(let r of e.def.options){let i=r._zod.propValues;if(!i||Object.keys(i).length===0)throw Error(`Invalid discriminated union option at index "${e.def.options.indexOf(r)}"`);i[e.def.discriminator]?.has(void 0)&&n++;for(let[e,n]of Object.entries(i)){Object.prototype.hasOwnProperty.call(t,e)||Ft(t,e,/* @__PURE__ */ new Set);for(let r of n)t[e].add(r)}}return!e.def.unionFallback&&n>1&&t[e.def.discriminator]?.delete(void 0),t}),t.options.forEach((e,n)=>{let r=It(e._zod.def);if(r&&!Object.prototype.hasOwnProperty.call(r,t.discriminator))throw Error(`Invalid discriminated union option at index "${n}"`)});let r=kt(()=>Da(t));e._zod.parse=(i,a)=>{let o=i.value;if(!Kt(o))return i.issues.push({code:`invalid_type`,expected:`object`,input:o,inst:e}),i;let s=o?.[t.discriminator],c=r.value.get(s);return c&&(s!==void 0||a.direction!==`backward`)?c._zod.run(i,a):t.unionFallback||a.direction===`backward`?n(i,a):(i.issues.push({code:`invalid_union`,errors:[],note:`No matching discriminator`,discriminator:t.discriminator,options:Array.from(r.value.keys()).filter(e=>r.value.get(e)!==null),input:o,path:[t.discriminator],inst:e}),i)}}),ka=/*@__PURE__*/ D(`$ZodIntersection`,(e,t)=>{yi.init(e,t),e._zod.parse=(e,n)=>{let r=e.value,i=t.left._zod.run({value:r,issues:[]},n),a=t.right._zod.run({value:r,issues:[]},n);return i instanceof Promise||a instanceof Promise?Promise.all([i,a]).then(([t,n])=>ja(e,t,n)):ja(e,i,a)}});function Aa(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(Jt(e)&&Jt(t)){let n=Object.keys(t),r=Object.keys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};Object.prototype.hasOwnProperty.call(i,`__proto__`)&&delete i.__proto__;for(let n of r){if(n===`__proto__`)continue;let r=Aa(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=Aa(i,a);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function ja(e,t,n){let r=/* @__PURE__ */ new Map,i,a=/* @__PURE__ */ new Map,o=(e,t)=>{let n;if(e.code===`unrecognized_keys`&&!e.path?.length)i??=e,n=e.keys;else if(e.code===`invalid_key`&&e.origin===`record`&&e.path?.length===1){let t=String(e.path[0]);a.has(t)||a.set(t,e),n=[t]}else return!1;for(let e of n)r.has(e)||r.set(e,{}),r.get(e)[t]=!0;return!0};for(let n of t.issues)o(n,`l`)||e.issues.push(n);for(let t of n.issues)o(t,`r`)||e.issues.push(t);let s=[...r].filter(([,e])=>e.l&&e.r).map(([e])=>e);if(s.length){let t=i?s.filter(e=>i.keys.includes(e)):[];t.length&&e.issues.push({...i,keys:t});for(let n of s)!t.includes(n)&&a.has(n)&&e.issues.push(a.get(n))}let c=Aa(t.value,n.value);if(!c.valid){if(pn(e))return e;throw Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`)}return e.value=c.data,e}let Ma=/*@__PURE__*/ D(`$ZodTuple`,(e,t)=>{yi.init(e,t);let n=t.items,r=Un.memoizer;r?.attach(e),e._zod.parse=(i,a)=>{let o=i.value;if(!Array.isArray(o))return i.issues.push({input:o,inst:e,expected:`tuple`,code:`invalid_type`}),i;i.value=r?r.alloc(e,i,[],a):[];let s=[],c=Na(n,`optin`),l=Na(n,`optout`);if(!t.rest){if(o.length<c)return i.issues.push({code:`too_small`,minimum:c,inclusive:!0,input:o,inst:e,origin:`array`}),i;o.length>n.length&&i.issues.push({code:`too_big`,maximum:n.length,inclusive:!0,input:o,inst:e,origin:`array`})}let u=Array(n.length),d=t.rest?a?.abortEarly:void 0,f=!1;for(let e=0;e<n.length;e++){let t=n[e]._zod.run({value:o[e],issues:[]},a);t instanceof Promise?s.push(t.then(t=>{u[e]=t})):(u[e]=t,d&&!f&&t.issues.length&&(f=pn(t)))}if(t.rest&&!f){let e=n.length-1,r=o.slice(n.length),c=i.issues.length;for(let n of r){if(d&&i.issues.length!==c){if(pn(i,c))break;c=i.issues.length}e++;let r=t.rest._zod.run({value:n,issues:[]},a);r instanceof Promise?s.push(r.then(t=>Pa(t,i,e))):Pa(r,i,e)}}return s.length?Promise.all(s).then(()=>Fa(u,i,n,o,l)):Fa(u,i,n,o,l)}});function Na(e,t){for(let n=e.length-1;n>=0;n--)if(!(t===`optin`?e[n]._zod.optin!==void 0:e[n]._zod.optout===`optional`))return n+1;return 0}function Pa(e,t,n){e.issues.length&&t.issues.push(...hn(n,e.issues)),t.value[n]=e.value}function Fa(e,t,n,r,i){for(let a=0;a<n.length;a++){let o=e[a],s=a<r.length;if(!s&&a>=i&&n[a]._zod.optin===`optional`){t.value.length=a;break}if(o.issues.length){if(!s&&a>=i){t.value.length=a;break}t.issues.push(...hn(a,o.issues))}t.value[a]=o.value}for(let e=t.value.length-1;e>=r.length&&n[e]._zod.optout===`optional`&&t.value[e]===void 0;e--)t.value.length=e;return t}let Ia=/*@__PURE__*/ D(`$ZodRecord`,(e,t)=>{yi.init(e,t);let n=Un.memoizer;n?.attach(e),e._zod.parse=(r,i)=>{let a=r.value;if(!Jt(a))return r.issues.push({expected:`record`,code:`invalid_type`,input:a,inst:e}),r;let o=[],s=t.keyType._zod.values;if(s&&!t.partial){r.value=n?n.alloc(e,r,{},i):{};let c=/* @__PURE__ */ new Set;for(let n of s)if(typeof n==`string`||typeof n==`number`||typeof n==`symbol`){if(c.add(typeof n==`number`?n.toString():n),n===`__proto__`)continue;let s=t.keyType._zod.run({value:n,issues:[]},i);if(s instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(s.issues.length){r.issues.push({code:`invalid_key`,origin:`record`,issues:s.issues.map(e=>yn(e,i,Wn())),input:n,path:[n],inst:e});continue}let l=s.value;if(l===`__proto__`)continue;let u=t.valueType._zod.run({value:a[n],issues:[]},i);u instanceof Promise?o.push(u.then(e=>{e.issues.length&&r.issues.push(...hn(n,e.issues)),r.value[l]=e.value})):(u.issues.length&&r.issues.push(...hn(n,u.issues)),r.value[l]=u.value)}let l;for(let e in a)if(!c.has(e)){if(t.mode===`loose`){if(e===`__proto__`)continue;r.value[e]=a[e]}else l??=[],l.push(e)}l&&l.length>0&&r.issues.push({code:`unrecognized_keys`,input:a,inst:e,keys:l,continue:!0})}else{r.value=n?n.alloc(e,r,{},i):{};let c;for(let n of Reflect.ownKeys(a)){if(n===`__proto__`||!Object.prototype.propertyIsEnumerable.call(a,n))continue;let l=t.keyType._zod.run({value:n,issues:[]},i);if(l instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(typeof n==`string`&&Jr.test(n)&&l.issues.length){let e=t.keyType._zod.run({value:Number(n),issues:[]},i);if(e instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);e.issues.length===0&&(l=e)}if(l.issues.length){t.mode===`loose`?r.value[n]=a[n]:s?(c??=[],c.push(n)):r.issues.push({code:`invalid_key`,origin:`record`,issues:l.issues.map(e=>yn(e,i,Wn())),input:n,path:[n],inst:e});continue}let u=l.value;if(u===`__proto__`)continue;let d=t.valueType._zod.run({value:a[n],issues:[]},i);d instanceof Promise?o.push(d.then(e=>{e.issues.length&&r.issues.push(...hn(n,e.issues)),r.value[u]=e.value})):(d.issues.length&&r.issues.push(...hn(n,d.issues)),r.value[u]=d.value)}c&&c.length>0&&r.issues.push({code:`unrecognized_keys`,input:a,inst:e,keys:c,continue:!0})}return o.length?Promise.all(o).then(()=>r):r}}),La=/*@__PURE__*/ D(`$ZodEnum`,(e,t)=>{yi.init(e,t);let n=Tt(t.entries),r=new Set(n);e._zod.values=r,E(e,`pattern`,e=>{let t=Tt(e.def.entries).filter(e=>Xt.has(typeof e));return RegExp(t.length?`^(${t.map(e=>Zt(e.toString())).join(`|`)})$`:`^[^\\s\\S]$`)}),e._zod.parse=(t,i)=>{let a=t.value;return r.has(a)||t.issues.push({code:`invalid_value`,values:n,input:a,inst:e}),t}}),Ra=/*@__PURE__*/ D(`$ZodLiteral`,(e,t)=>{yi.init(e,t);let n=new Set(t.values);e._zod.values=n,E(e,`pattern`,e=>{let t=e.def.values;return RegExp(t.length?`^(${t.map(e=>typeof e==`string`?Zt(e):e?Zt(e.toString()):String(e)).join(`|`)})$`:`^[^\\s\\S]$`)}),e._zod.parse=(r,i)=>{let a=r.value;return n.has(a)||r.issues.push({code:`invalid_value`,values:t.values,input:a,inst:e}),r}}),za=/*@__PURE__*/ D(`$ZodTransform`,(e,t)=>{yi.init(e,t),e._zod.optin=`optional`,Un.memoizer?.guard(e),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new Hn(e.constructor.name);let i=t.transform(n.value,n);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(e=>(n.value=e,n));if(i instanceof Promise)throw new Vn;return n.value=i,n}});function Ba(e,t){return e.value=t.issues.length?void 0:t.value,e}let Va=/*@__PURE__*/ D(`$ZodOptional`,(e,t)=>{yi.init(e,t),E(e,`optin`,e=>e.def.innerType._zod.optin===`defaulted`?`defaulted`:`optional`),e._zod.optout=`optional`,E(e,`values`,e=>{let t=e.def.innerType._zod.values;return t?/* @__PURE__ */ new Set([...t,void 0]):void 0}),E(e,`pattern`,e=>{let t=e.def.innerType._zod.pattern;return t?RegExp(`^(${jt(t.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if(e.value===void 0){if(t.innerType._zod.optin!==`defaulted`)return e;let r=t.innerType._zod.run({value:e.value,issues:[]},n);return r instanceof Promise?r.then(t=>Ba(e,t)):Ba(e,r)}return t.innerType._zod.run(e,n)}}),Ha=/*@__PURE__*/ D(`$ZodExactOptional`,(e,t)=>{Va.init(e,t),E(e,`values`,e=>e.def.innerType._zod.values),E(e,`pattern`,e=>e.def.innerType._zod.pattern),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),Ua=/*@__PURE__*/ D(`$ZodNullable`,(e,t)=>{yi.init(e,t),E(e,`optin`,e=>e.def.innerType._zod.optin),E(e,`optout`,e=>e.def.innerType._zod.optout),E(e,`pattern`,e=>{let t=e.def.innerType._zod.pattern;return t?RegExp(`^(${jt(t.source)}|null)$`):void 0}),E(e,`values`,e=>e.def.innerType._zod.values?/* @__PURE__ */ new Set([...e.def.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>e.value===null?e:t.innerType._zod.run(e,n)}),Wa=/*@__PURE__*/ D(`$ZodDefault`,(e,t)=>{yi.init(e,t),e._zod.optin=`defaulted`,E(e,`values`,e=>e.def.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);if(e.value===void 0)return e.value=t.defaultValue,e;let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(e=>Ga(e,t)):Ga(r,t)}});function Ga(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}let Ka=/*@__PURE__*/ D(`$ZodPrefault`,(e,t)=>{yi.init(e,t),e._zod.optin=`defaulted`,E(e,`values`,e=>e.def.innerType._zod.values),e._zod.parse=(e,n)=>(n.direction===`backward`||e.value===void 0&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))}),qa=/*@__PURE__*/ D(`$ZodNonOptional`,(e,t)=>{yi.init(e,t),E(e,`values`,e=>{let t=e.def.innerType._zod.values;return t?new Set([...t].filter(e=>e!==void 0)):void 0}),e._zod.parse=(n,r)=>{let i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(t=>Ja(t,e)):Ja(i,e)}});function Ja(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:`invalid_type`,expected:`nonoptional`,input:e.value,inst:t}),e}function Ya(e,t,n,r){return t.issues.length?(e.value=n.catchValue({...t,value:e.value,error:{issues:t.issues.map(e=>yn(e,r,Wn()))},input:e.value}),e):(e.value=t.value,t.memo&&(e.memo=!0),e)}let Xa=/*@__PURE__*/ D(`$ZodCatch`,(e,t)=>{yi.init(e,t),E(e,`optin`,e=>e.def.innerType._zod.optin===`defaulted`?`defaulted`:`optional`),E(e,`optout`,e=>e.def.innerType._zod.optout),E(e,`values`,e=>e.def.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run({value:e.value,issues:[]},n);return r instanceof Promise?r.then(r=>Ya(e,r,t,n)):Ya(e,r,t,n)}}),Za=/*@__PURE__*/ D(`$ZodPipe`,(e,t)=>{yi.init(e,t),E(e,`values`,e=>e.def.in._zod.values),E(e,`optin`,e=>e.def.in._zod.optin),E(e,`optout`,e=>e.def.out._zod.optout),E(e,`propValues`,e=>e.def.in._zod.propValues),e._zod.parse=(e,n)=>{if(n.direction===`backward`){let r=t.out._zod.run(e,n);return r instanceof Promise?r.then(e=>Qa(e,t.in,n)):Qa(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>Qa(e,t.out,n)):Qa(r,t.out,n)}});function Qa(e,t,n){return e.issues.some(e=>e.code!==`unrecognized_keys`)?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}let $a=/*@__PURE__*/ D(`$ZodReadonly`,(e,t)=>{yi.init(e,t),E(e,`propValues`,e=>e.def.innerType._zod.propValues),E(e,`values`,e=>e.def.innerType._zod.values),E(e,`optin`,e=>e.def.innerType?._zod?.optin),E(e,`optout`,e=>e.def.innerType?._zod?.optout),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(eo):eo(r)}});function eo(e){return e.memo||(e.value=Object.freeze(e.value)),e}let to=/*@__PURE__*/ D(`$ZodLazy`,(e,t)=>{yi.init(e,t),Pt(e._zod,`innerType`,()=>{let e=t;return e._cachedInner||=t.getter(),e._cachedInner}),E(e,`pattern`,e=>e.innerType?._zod?.pattern),E(e,`propValues`,e=>e.innerType?._zod?.propValues),E(e,`optin`,e=>e.innerType?._zod?.optin??void 0),E(e,`optout`,e=>e.innerType?._zod?.optout??void 0),e._zod.parse=(t,n)=>e._zod.innerType._zod.run(t,n)}),no=/*@__PURE__*/ D(`$ZodCustom`,(e,t)=>{$r.init(e,t),yi.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=>ro(t,n,r,e));ro(i,n,r,e)}});function ro(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(wn(e))}}var io=class extends Error{constructor(){super(`Cannot parse a reference cycle that closes through a transform`),this.name=`ZodCyclicError`}};let ao=`~memo`,oo=[];function so(e){return typeof e==`object`&&!!e}function co(e){return e.map(e=>e.path?{...e,path:e.path.slice()}:{...e})}let lo=/*@__PURE__*/ new WeakMap;function uo(e,t,n){let r=lo.get(e);if(r!==void 0)return r?2:0;if(t.has(e))return 2;t.add(e);let i=0,a=e=>{if(i!==2&&e?._zod){let r=uo(e,t,n);r>i&&(i=r)}},o=(e,r)=>{let i=0;for(let a of Reflect.ownKeys(e)){let o=Object.getOwnPropertyDescriptor(e,a);if(r&&!o.enumerable)continue;let s=o.get?1:o.value?._zod?uo(o.value,t,n):0;s>i&&(i=s)}return i},s=e=>{e>i&&(i=e)},c=e._zod.def;switch(c.type){case`object`:{let e=It(c);s(e?o(e,!0):1),a(c.catchall);break}case`array`:a(c.element);break;case`tuple`:for(let e of c.items)a(e);a(c.rest);break;case`record`:case`map`:a(c.keyType),a(c.valueType);break;case`set`:a(c.valueType);break;case`union`:for(let e of c.options)a(e);break;case`intersection`:a(c.left),a(c.right);break;case`optional`:case`nullable`:case`default`:case`prefault`:case`catch`:case`readonly`:case`nonoptional`:case`promise`:case`success`:a(c.innerType);break;case`pipe`:a(c.in),a(c.out);break;case`function`:a(c.input),a(c.output);break;case`lazy`:{let r=c._cachedInner??(n?e._zod.innerType:void 0);s(r?uo(r,t,!1):1);break}case`template_literal`:case`string`:case`number`:case`int`:case`boolean`:case`bigint`:case`symbol`:case`undefined`:case`null`:case`void`:case`never`:case`any`:case`unknown`:case`date`:case`nan`:case`enum`:case`literal`:case`file`:case`transform`:case`custom`:break;default:for(let e in c){let t=Object.getOwnPropertyDescriptor(c,e);if(!t||t.get)continue;let n=t.value;if(n&&typeof n==`object`){if(n._zod)a(n);else if(Array.isArray(n))for(let e of n)a(e)}}}return t.delete(e),fo(e,i)}function fo(e,t){return t!==1&&lo.set(e,t===2),t}function po(e,t){let n=e.buckets.get(t);return n||(n=/* @__PURE__ */ new WeakMap,e.buckets.set(t,n)),n}let mo,ho=[],go={alloc(e,t,n){let r=mo;if(!r)return n;mo=void 0;let i={value:n,issues:null};return r.set(t.value,i),ho.push(i),n},guard(e){var t;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let t=e._zod.parse,n=(e,n)=>{if(n.direction!==`backward`&&vo(n,e.value))throw new io;return t(e,n)};e._zod.parse=n,e._zod.run===t&&(e._zod.run=n)})},attach(e){var t;let n,r=!1,i,a;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let t=e._zod.parse,o=(s,c)=>{if(n===void 0){let i=uo(e,/* @__PURE__ */ new Set,!1);if(i===0)return e._zod.parse=t,e._zod.run===o&&(e._zod.run=t),t(s,c);i===2||r?n=!0:r=!0}let l=s.value;if(!so(l))return t(s,c);let u=c[ao];u||(u={buckets:/* @__PURE__ */ new WeakMap,backEdges:void 0},c[ao]=u);let d;i===c?d=a:(d=po(u,e),i=c,a=d);let f=d.get(l);if(f)return s.value=f.value,f.issues?f.issues.length&&s.issues.push(...co(f.issues)):(s.memo=!0,u.backEdges??(u.backEdges=/* @__PURE__ */ new WeakSet),u.backEdges.add(f.value)),s;mo=d;let p=ho.length,m=t(s,c);mo=void 0;let h=ho.length>p?ho.pop():void 0;return m instanceof Promise?m.then(e=>(h&&(h.issues=e.issues.length?co(e.issues):oo),e)):(h&&(h.issues=m.issues.length?co(m.issues):oo),m)};e._zod.parse=o,e._zod.run===t&&(e._zod.run=o)})}};function _o(){return go}function vo(e,t){let n=e[ao]?.backEdges;return n!==void 0&&so(t)&&n.has(t)}let yo=()=>{let e={string:{unit:`characters`,verb:`to have`},file:{unit:`bytes`,verb:`to have`},array:{unit:`items`,verb:`to have`},set:{unit:`items`,verb:`to have`},map:{unit:`entries`,verb:`to have`}};function t(t){return e[t]??null}let n={regex:`input`,email:`email address`,url:`URL`,emoji:`emoji`,uuid:`UUID`,uuidv4:`UUIDv4`,uuidv6:`UUIDv6`,nanoid:`nanoid`,guid:`GUID`,cuid:`cuid`,cuid2:`cuid2`,ulid:`ULID`,xid:`XID`,ksuid:`KSUID`,datetime:`ISO datetime`,date:`ISO date`,time:`ISO time`,duration:`ISO duration`,ipv4:`IPv4 address`,ipv6:`IPv6 address`,mac:`MAC address`,cidrv4:`IPv4 range`,cidrv6:`IPv6 range`,base64:`base64-encoded string`,base64url:`base64url-encoded string`,json_string:`JSON string`,e164:`E.164 number`,currency_code:`currency code`,credit_card:`credit card number`,iban:`IBAN`,jwt:`JWT`,template_literal:`input`},r={nan:`NaN`};function i(e,t){return e===`number`&&typeof t==`number`&&!Number.isFinite(t)?String(t):r[e]??e}return e=>{switch(e.code){case`invalid_type`:return`Invalid input: expected ${i(e.expected)}, received ${i(Cn(e.input),e.input)}`;case`invalid_value`:return e.values.length===1?`Invalid input: expected ${$t(e.values[0])}`:`Invalid option: expected one of ${Et(e.values,`|`)}`;case`too_big`:{let n=e.exact?`exactly `:e.inclusive?`<=`:`<`,r=t(e.origin);return r?`Too big: expected ${e.origin??`value`} to have ${n}${e.maximum.toString()} ${r.unit??`elements`}`:`Too big: expected ${e.origin??`value`} to be ${n}${e.maximum.toString()}`}case`too_small`:{let n=e.exact?`exactly `:e.inclusive?`>=`:`>`,r=t(e.origin);return r?`Too small: expected ${e.origin} to have ${n}${e.minimum.toString()} ${r.unit}`:`Too small: expected ${e.origin} to be ${n}${e.minimum.toString()}`}case`invalid_format`:{let t=e;return t.format===`starts_with`?`Invalid string: must start with "${t.prefix}"`:t.format===`ends_with`?`Invalid string: must end with "${t.suffix}"`:t.format===`includes`?`Invalid string: must include "${t.includes}"`:t.format===`regex`?`Invalid string: must match pattern ${t.pattern}`:`Invalid ${n[t.format]??e.format}`}case`not_multiple_of`:return`Invalid number: must be a multiple of ${e.divisor}`;case`unrecognized_keys`:return`Unrecognized key${e.keys.length>1?`s`:``}: ${Et(e.keys,`, `)}`;case`invalid_key`:return`Invalid key in ${e.origin}`;case`invalid_union`:return e.options&&Array.isArray(e.options)&&e.options.length>0?`Invalid discriminator value. Expected ${e.options.map(e=>`'${e}'`).join(` | `)}`:e.inclusive===!1?`Invalid input: more than one option matched`:`Invalid input`;case`invalid_element`:return`Invalid value in ${e.origin}`;default:return`Invalid input`}}};function bo(){return{localeError:yo()}}var xo,So=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 Co(){return new So}(xo=globalThis).__zod_globalRegistry??(xo.__zod_globalRegistry=Co());let wo=globalThis.__zod_globalRegistry;function To(e){return e.checks&&=[...e.checks],e}// @__NO_SIDE_EFFECTS__
|
|
64
|
+
function Eo(e,t){return new e(To({type:`string`,...T(t)}))}// @__NO_SIDE_EFFECTS__
|
|
65
|
+
function Do(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...T(t)})}// @__NO_SIDE_EFFECTS__
|
|
66
|
+
function Oo(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...T(t)})}// @__NO_SIDE_EFFECTS__
|
|
67
|
+
function ko(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...T(t)})}// @__NO_SIDE_EFFECTS__
|
|
68
|
+
function Ao(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...T(t)})}// @__NO_SIDE_EFFECTS__
|
|
69
|
+
function jo(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...T(t)})}// @__NO_SIDE_EFFECTS__
|
|
70
|
+
function Mo(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...T(t)})}// @__NO_SIDE_EFFECTS__
|
|
71
|
+
function No(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...T(t)})}// @__NO_SIDE_EFFECTS__
|
|
72
|
+
function Po(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...T(t)})}// @__NO_SIDE_EFFECTS__
|
|
73
|
+
function Fo(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...T(t)})}// @__NO_SIDE_EFFECTS__
|
|
74
|
+
function Io(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...T(t)})}// @__NO_SIDE_EFFECTS__
|
|
75
|
+
function Lo(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...T(t)})}// @__NO_SIDE_EFFECTS__
|
|
76
|
+
function Ro(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...T(t)})}// @__NO_SIDE_EFFECTS__
|
|
77
|
+
function zo(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...T(t)})}// @__NO_SIDE_EFFECTS__
|
|
78
|
+
function Bo(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...T(t)})}// @__NO_SIDE_EFFECTS__
|
|
79
|
+
function Vo(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...T(t)})}// @__NO_SIDE_EFFECTS__
|
|
80
|
+
function Ho(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...T(t)})}// @__NO_SIDE_EFFECTS__
|
|
81
|
+
function Uo(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...T(t)})}// @__NO_SIDE_EFFECTS__
|
|
82
|
+
function Wo(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...T(t)})}// @__NO_SIDE_EFFECTS__
|
|
83
|
+
function Go(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...T(t)})}// @__NO_SIDE_EFFECTS__
|
|
84
|
+
function Ko(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...T(t)})}// @__NO_SIDE_EFFECTS__
|
|
85
|
+
function qo(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...T(t)})}// @__NO_SIDE_EFFECTS__
|
|
86
|
+
function Jo(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...T(t)})}// @__NO_SIDE_EFFECTS__
|
|
87
|
+
function Yo(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...T(t)})}// @__NO_SIDE_EFFECTS__
|
|
88
|
+
function Xo(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...T(t)})}// @__NO_SIDE_EFFECTS__
|
|
89
|
+
function Zo(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...T(t)})}// @__NO_SIDE_EFFECTS__
|
|
90
|
+
function Qo(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...T(t)})}// @__NO_SIDE_EFFECTS__
|
|
91
|
+
function $o(e,t){return new e(To({type:`number`,checks:[],...T(t)}))}// @__NO_SIDE_EFFECTS__
|
|
92
|
+
function es(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...T(t)})}// @__NO_SIDE_EFFECTS__
|
|
93
|
+
function ts(e,t){return new e({type:`boolean`,...T(t)})}// @__NO_SIDE_EFFECTS__
|
|
94
|
+
function ns(e,t){return new e({type:`null`,...T(t)})}// @__NO_SIDE_EFFECTS__
|
|
95
|
+
function rs(e){return new e({type:`unknown`})}// @__NO_SIDE_EFFECTS__
|
|
96
|
+
function is(e,t){return new e({type:`never`,...T(t)})}// @__NO_SIDE_EFFECTS__
|
|
97
|
+
function as(e,t){return new ni({check:`less_than`,...T(t),value:e,inclusive:!1})}// @__NO_SIDE_EFFECTS__
|
|
98
|
+
function os(e,t){return new ni({check:`less_than`,...T(t),value:e,inclusive:!0})}// @__NO_SIDE_EFFECTS__
|
|
99
|
+
function ss(e,t){return new ri({check:`greater_than`,...T(t),value:e,inclusive:!1})}// @__NO_SIDE_EFFECTS__
|
|
100
|
+
function cs(e,t){return new ri({check:`greater_than`,...T(t),value:e,inclusive:!0})}// @__NO_SIDE_EFFECTS__
|
|
101
|
+
function ls(e,t){return new ii({check:`multiple_of`,...T(t),value:e})}// @__NO_SIDE_EFFECTS__
|
|
102
|
+
function us(e,t){return new oi({check:`max_length`,...T(t),maximum:e})}// @__NO_SIDE_EFFECTS__
|
|
103
|
+
function ds(e,t){return new si({check:`min_length`,...T(t),minimum:e})}// @__NO_SIDE_EFFECTS__
|
|
104
|
+
function fs(e,t){return new ci({check:`length_equals`,...T(t),length:e})}// @__NO_SIDE_EFFECTS__
|
|
105
|
+
function ps(e,t){return new ui({check:`string_format`,format:`regex`,...T(t),pattern:e})}// @__NO_SIDE_EFFECTS__
|
|
106
|
+
function ms(e){return new di({check:`string_format`,format:`lowercase`,...T(e)})}// @__NO_SIDE_EFFECTS__
|
|
107
|
+
function hs(e){return new fi({check:`string_format`,format:`uppercase`,...T(e)})}// @__NO_SIDE_EFFECTS__
|
|
108
|
+
function gs(e,t){return new pi({check:`string_format`,format:`includes`,...T(t),includes:e})}// @__NO_SIDE_EFFECTS__
|
|
109
|
+
function _s(e,t){return new mi({check:`string_format`,format:`starts_with`,...T(t),prefix:e})}// @__NO_SIDE_EFFECTS__
|
|
110
|
+
function vs(e,t){return new hi({check:`string_format`,format:`ends_with`,...T(t),suffix:e})}// @__NO_SIDE_EFFECTS__
|
|
111
|
+
function ys(e){return new gi({check:`overwrite`,tx:e})}// @__NO_SIDE_EFFECTS__
|
|
112
|
+
function bs(e){return/* @__PURE__ */ ys(t=>t.normalize(e))}// @__NO_SIDE_EFFECTS__
|
|
113
|
+
function xs(){return/* @__PURE__ */ ys(e=>e.trim())}// @__NO_SIDE_EFFECTS__
|
|
114
|
+
function Ss(){return/* @__PURE__ */ ys(e=>e.toLowerCase())}// @__NO_SIDE_EFFECTS__
|
|
115
|
+
function Cs(){return/* @__PURE__ */ ys(e=>e.toUpperCase())}// @__NO_SIDE_EFFECTS__
|
|
116
|
+
function ws(){return/* @__PURE__ */ ys(e=>Wt(e))}// @__NO_SIDE_EFFECTS__
|
|
117
|
+
function Ts(e,t,n){return new e({type:`array`,element:t,...T(n)})}// @__NO_SIDE_EFFECTS__
|
|
118
|
+
function Es(e,t,n){let r=T(n);return r.abort??=!0,new e({type:`custom`,check:`custom`,fn:t,...r})}// @__NO_SIDE_EFFECTS__
|
|
119
|
+
function Ds(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...T(n)})}// @__NO_SIDE_EFFECTS__
|
|
120
|
+
function Os(e,t){let n=/* @__PURE__ */ ks(t=>(t.addIssue=e=>{if(typeof e==`string`)t.issues.push(wn(e,t.value,n._zod.def));else{let r=e;r.fatal&&(r.continue=!1),r.code??=`custom`,`input`in r||(r.input=t.value),r.inst??=n,r.continue??=!n._zod.def.abort,t.issues.push(wn(r))}},e(t.value,t)),t);return n}// @__NO_SIDE_EFFECTS__
|
|
121
|
+
function ks(e,t){let n=new $r({check:`custom`,...T(t)});return n._zod.check=e,n}function As(e,...t){for(let n of t)for(let t of Reflect.ownKeys(n))Object.prototype.propertyIsEnumerable.call(n,t)&&Ft(e,t,n[t]);return e}function js(e){let t=e?.target??`draft-2020-12`;return t===`draft-4`&&(t=`draft-04`),t===`draft-7`&&(t=`draft-07`),{processors:e.processors??{},metadataRegistry:e?.metadata??wo,target:t,unrepresentable:e?.unrepresentable??`throw`,override:e?.override??(()=>{}),io:e?.io??`output`,counter:0,seen:/* @__PURE__ */ new Map,sharedDefsExtractedFor:void 0,sharedEmitDoneFor:void 0,cycles:e?.cycles??`ref`,reused:e?.reused??`inline`,intersections:[],deferred:[],external:e?.external??void 0}}function Ms(e,t,n,r,i){let a=typeof t.unrepresentable==`function`?t.unrepresentable({zodSchema:e,path:r.path,message:i}):t.unrepresentable;if(a===`any`)return!1;if(a===void 0||a===`throw`)throw Error(i);return Object.assign(n,a),!0}function Ns(e,t,n={path:[],schemaPath:[]}){var r;let i=e._zod.def,a=t.seen.get(e);if(a)return a.count++,n.schemaPath.includes(e)&&(a.cycle=n.path),a.schema;let o={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,o),t.sharedDefsExtractedFor=void 0,t.sharedEmitDoneFor=void 0;let s=e._zod.toJSONSchema?.();if(s)o.schema=s;else{let r={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,r);else{let n=o.schema,a=t.processors[i.type];if(!a)throw Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);a(e,t,n,r)}let a=e._zod.parent;a&&(o.ref||=a,Ns(a,t,r),t.seen.get(a).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&As(o.schema,c),t.io===`input`&&Us(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 Ps(e){return e.replace(/~/g,`~0`).replace(/\//g,`~1`)}function Fs(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);if(e.external&&e.sharedDefsExtractedFor===e.external)return;let r=/* @__PURE__ */ new Map;for(let t of e.seen.entries()){let n=e.metadataRegistry.get(t[0])?.id;if(n){let e=r.get(n);if(e&&e!==t[0])throw Error(`Duplicate schema id "${n}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(n,t[0])}}let i=t=>{let r=e.target===`draft-2020-12`?`$defs`:`definitions`;if(e.external){let n=e.external.registry.get(t[0])?.id,i=e.external.uri??(e=>e);if(n)return{ref:i(n)};let a=t[1].defId??t[1].schema.id??`schema${e.counter++}`;return t[1].defId=a,{defId:a,ref:`${i(`__shared`)}#/${r}/${Ps(a)}`}}let i=`#/${r}/`;if(t[1]===n&&!t[1].schema.id)return{ref:`#`};let a=t[1].schema.id??`__schema${e.counter++}`;return{defId:a,ref:i+Ps(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
122
|
|
|
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 io(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:so(t,`input`,e.processors),output:so(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function ao(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 ao(r.element,n);if(r.type===`set`)return ao(r.valueType,n);if(r.type===`lazy`)return ao(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 ao(r.innerType,n);if(r.type===`intersection`)return ao(r.left,n)||ao(r.right,n);if(r.type===`record`||r.type===`map`)return ao(r.keyType,n)||ao(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:ao(r.in,n)||ao(r.out,n);if(r.type===`object`){for(let e in r.shape)if(ao(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(ao(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(ao(e,n))return!0;return!!(r.rest&&ao(r.rest,n))}return!1}let oo=(e,t={})=>n=>{let r=to({...n,processors:t});return no(e,r),ro(r,e),io(r,e)},so=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=to({...i??{},target:a,io:t,processors:n});return no(e,o),ro(o,e),io(o,e)},co={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},lo=(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=co[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}))])}},uo=(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)},fo=(e,t,n,r)=>{n.type=`boolean`},po=(e,t,n,r)=>{t.target===`openapi-3.0`?(n.type=`string`,n.nullable=!0,n.enum=[null]):n.type=`null`},mo=(e,t,n,r)=>{n.not={}},ho=(e,t,n,r)=>{let i=e._zod.def,a=Mt(i.entries);a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a},go=(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}},_o=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Custom types cannot be represented in JSON Schema`)},vo=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Transforms cannot be represented in JSON Schema`)},yo=(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=no(a.element,t,{...r,path:[...r.path,`items`]})},bo=(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]=no(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=no(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},xo=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>no(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},So=(e,t,n,r)=>{let i=e._zod.def,a=no(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=no(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]]},Co=(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)=>no(e,t,{...r,path:[...r.path,o,n]})),l=a.rest?no(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)},wo=(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=no(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=no(a.keyType,t,{...r,path:[...r.path,`propertyNames`]})),i.additionalProperties=no(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)}},To=(e,t,n,r)=>{let i=e._zod.def,a=no(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`}]},Eo=(e,t,n,r)=>{let i=e._zod.def;no(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Do=(e,t,n,r)=>{let i=e._zod.def;no(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.default=JSON.parse(JSON.stringify(i.defaultValue))},Oo=(e,t,n,r)=>{let i=e._zod.def;no(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)))},ko=(e,t,n,r)=>{let i=e._zod.def;no(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},Ao=(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;no(o,t,r);let s=t.seen.get(e);s.ref=o},jo=(e,t,n,r)=>{let i=e._zod.def;no(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},Mo=(e,t,n,r)=>{let i=e._zod.def;no(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},No=(e,t,n,r)=>{let i=e._zod.innerType;no(i,t,r);let a=t.seen.get(e);a.ref=i},Po=/*@__PURE__*/ w(`ZodISODateTime`,(e,t)=>{Hr.init(e,t),os.init(e,t)});function Fo(e){return/* @__PURE__ */ ba(Po,e)}let Io=/*@__PURE__*/ w(`ZodISODate`,(e,t)=>{Ur.init(e,t),os.init(e,t)});function Lo(e){return/* @__PURE__ */ xa(Io,e)}let Ro=/*@__PURE__*/ w(`ZodISOTime`,(e,t)=>{Wr.init(e,t),os.init(e,t)});function zo(e){return/* @__PURE__ */ Sa(Ro,e)}let Bo=/*@__PURE__*/ w(`ZodISODuration`,(e,t)=>{Gr.init(e,t),os.init(e,t)});function Vo(e){return/* @__PURE__ */ Ca(Bo,e)}let Ho=/*@__PURE__*/ w(`ZodError`,(e,t)=>{hn.init(e,t),e.name=`ZodError`,Object.defineProperties(e,{format:{value:t=>vn(e,t)},flatten:{value:t=>_n(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,Nt,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,Nt,2)}},isEmpty:{get(){return e.issues.length===0}}})},{Parent:Error}),Uo=/* @__PURE__ */ yn(Ho),Wo=/* @__PURE__ */ bn(Ho),Go=/* @__PURE__ */ xn(Ho),Ko=/* @__PURE__ */ Cn(Ho),qo=/* @__PURE__ */ Tn(Ho),Jo=/* @__PURE__ */ En(Ho),Yo=/* @__PURE__ */ Dn(Ho),Xo=/* @__PURE__ */ On(Ho),Zo=/* @__PURE__ */ kn(Ho),Qo=/* @__PURE__ */ An(Ho),$o=/* @__PURE__ */ jn(Ho),es=/* @__PURE__ */ Mn(Ho),ts=/* @__PURE__ */ new WeakMap;function ns(e,t,n){let r=Object.getPrototypeOf(e),i=ts.get(r);if(i||(i=/* @__PURE__ */ new Set,ts.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 rs=/*@__PURE__*/ w(`ZodType`,(e,t)=>(D.init(e,t),Object.assign(e[`~standard`],{jsonSchema:{input:so(e,`input`),output:so(e,`output`)}}),e.toJSONSchema=oo(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(t,n)=>Uo(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>Go(e,t,n),e.parseAsync=async(t,n)=>Wo(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>Ko(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>qo(e,t,n),e.decode=(t,n)=>Jo(e,t,n),e.encodeAsync=async(t,n)=>Yo(e,t,n),e.decodeAsync=async(t,n)=>Xo(e,t,n),e.safeEncode=(t,n)=>Zo(e,t,n),e.safeDecode=(t,n)=>Qo(e,t,n),e.safeEncodeAsync=async(t,n)=>$o(e,t,n),e.safeDecodeAsync=async(t,n)=>es(e,t,n),ns(e,`ZodType`,{check(...e){let t=this.def;return this.clone(Bt(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 Xt(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(Sc(e,t))},superRefine(e,t){return this.check(Cc(e,t))},overwrite(e){return this.check(/* @__PURE__ */ Wa(e))},optional(){return tc(this)},exactOptional(){return rc(this)},nullable(){return ac(this)},nullish(){return tc(ac(this))},nonoptional(e){return dc(this,e)},array(){return j(this)},or(e){return Vs([this,e])},and(e){return Gs(this,e)},transform(e){return hc(this,$s(e))},default(e){return sc(this,e)},prefault(e){return lc(this,e)},catch(e){return pc(this,e)},pipe(e){return hc(this,e)},readonly(){return _c(this)},describe(e){let t=this.clone();return Xi.add(t,{description:e}),t},meta(...e){if(e.length===0)return Xi.get(this);let t=this.clone();return Xi.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 Xi.get(e)?.description},configurable:!0}),e)),is=/*@__PURE__*/ w(`_ZodString`,(e,t)=>{kr.init(e,t),rs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>lo(e,t,n,r);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,ns(e,`_ZodString`,{regex(...e){return this.check(/* @__PURE__ */ Ra(...e))},includes(...e){return this.check(/* @__PURE__ */ Va(...e))},startsWith(...e){return this.check(/* @__PURE__ */ Ha(...e))},endsWith(...e){return this.check(/* @__PURE__ */ Ua(...e))},min(...e){return this.check(/* @__PURE__ */ Ia(...e))},max(...e){return this.check(/* @__PURE__ */ Fa(...e))},length(...e){return this.check(/* @__PURE__ */ La(...e))},nonempty(...e){return this.check(/* @__PURE__ */ Ia(1,...e))},lowercase(e){return this.check(/* @__PURE__ */ za(e))},uppercase(e){return this.check(/* @__PURE__ */ Ba(e))},trim(){return this.check(/* @__PURE__ */ Ka())},normalize(...e){return this.check(/* @__PURE__ */ Ga(...e))},toLowerCase(){return this.check(/* @__PURE__ */ qa())},toUpperCase(){return this.check(/* @__PURE__ */ Ja())},slugify(){return this.check(/* @__PURE__ */ Ya())}})}),as=/*@__PURE__*/ w(`ZodString`,(e,t)=>{kr.init(e,t),is.init(e,t),e.email=t=>e.check(/* @__PURE__ */ Qi(ss,t)),e.url=t=>e.check(/* @__PURE__ */ ia(ds,t)),e.jwt=t=>e.check(/* @__PURE__ */ ya(Ds,t)),e.emoji=t=>e.check(/* @__PURE__ */ aa(ps,t)),e.guid=t=>e.check(/* @__PURE__ */ $i(cs,t)),e.uuid=t=>e.check(/* @__PURE__ */ ea(ls,t)),e.uuidv4=t=>e.check(/* @__PURE__ */ ta(ls,t)),e.uuidv6=t=>e.check(/* @__PURE__ */ na(ls,t)),e.uuidv7=t=>e.check(/* @__PURE__ */ ra(ls,t)),e.nanoid=t=>e.check(/* @__PURE__ */ oa(ms,t)),e.guid=t=>e.check(/* @__PURE__ */ $i(cs,t)),e.cuid=t=>e.check(/* @__PURE__ */ sa(hs,t)),e.cuid2=t=>e.check(/* @__PURE__ */ ca(gs,t)),e.ulid=t=>e.check(/* @__PURE__ */ la(_s,t)),e.base64=t=>e.check(/* @__PURE__ */ ga(ws,t)),e.base64url=t=>e.check(/* @__PURE__ */ _a(Ts,t)),e.xid=t=>e.check(/* @__PURE__ */ ua(vs,t)),e.ksuid=t=>e.check(/* @__PURE__ */ da(ys,t)),e.ipv4=t=>e.check(/* @__PURE__ */ fa(bs,t)),e.ipv6=t=>e.check(/* @__PURE__ */ pa(xs,t)),e.cidrv4=t=>e.check(/* @__PURE__ */ ma(Ss,t)),e.cidrv6=t=>e.check(/* @__PURE__ */ ha(Cs,t)),e.e164=t=>e.check(/* @__PURE__ */ va(Es,t)),e.datetime=t=>e.check(Fo(t)),e.date=t=>e.check(Lo(t)),e.time=t=>e.check(zo(t)),e.duration=t=>e.check(Vo(t))});function O(e){return/* @__PURE__ */ Zi(as,e)}let os=/*@__PURE__*/ w(`ZodStringFormat`,(e,t)=>{Ar.init(e,t),is.init(e,t)}),ss=/*@__PURE__*/ w(`ZodEmail`,(e,t)=>{Nr.init(e,t),os.init(e,t)}),cs=/*@__PURE__*/ w(`ZodGUID`,(e,t)=>{jr.init(e,t),os.init(e,t)}),ls=/*@__PURE__*/ w(`ZodUUID`,(e,t)=>{Mr.init(e,t),os.init(e,t)});function us(e){return/* @__PURE__ */ ea(ls,e)}let ds=/*@__PURE__*/ w(`ZodURL`,(e,t)=>{Pr.init(e,t),os.init(e,t)});function fs(e){return/* @__PURE__ */ ia(ds,e)}let ps=/*@__PURE__*/ w(`ZodEmoji`,(e,t)=>{Fr.init(e,t),os.init(e,t)}),ms=/*@__PURE__*/ w(`ZodNanoID`,(e,t)=>{Ir.init(e,t),os.init(e,t)}),hs=/*@__PURE__*/ w(`ZodCUID`,(e,t)=>{Lr.init(e,t),os.init(e,t)}),gs=/*@__PURE__*/ w(`ZodCUID2`,(e,t)=>{Rr.init(e,t),os.init(e,t)}),_s=/*@__PURE__*/ w(`ZodULID`,(e,t)=>{zr.init(e,t),os.init(e,t)}),vs=/*@__PURE__*/ w(`ZodXID`,(e,t)=>{Br.init(e,t),os.init(e,t)}),ys=/*@__PURE__*/ w(`ZodKSUID`,(e,t)=>{Vr.init(e,t),os.init(e,t)}),bs=/*@__PURE__*/ w(`ZodIPv4`,(e,t)=>{Kr.init(e,t),os.init(e,t)}),xs=/*@__PURE__*/ w(`ZodIPv6`,(e,t)=>{qr.init(e,t),os.init(e,t)}),Ss=/*@__PURE__*/ w(`ZodCIDRv4`,(e,t)=>{Jr.init(e,t),os.init(e,t)}),Cs=/*@__PURE__*/ w(`ZodCIDRv6`,(e,t)=>{Yr.init(e,t),os.init(e,t)}),ws=/*@__PURE__*/ w(`ZodBase64`,(e,t)=>{Zr.init(e,t),os.init(e,t)}),Ts=/*@__PURE__*/ w(`ZodBase64URL`,(e,t)=>{$r.init(e,t),os.init(e,t)}),Es=/*@__PURE__*/ w(`ZodE164`,(e,t)=>{ei.init(e,t),os.init(e,t)}),Ds=/*@__PURE__*/ w(`ZodJWT`,(e,t)=>{ni.init(e,t),os.init(e,t)}),Os=/*@__PURE__*/ w(`ZodNumber`,(e,t)=>{ri.init(e,t),rs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>uo(e,t,n,r),ns(e,`ZodNumber`,{gt(e,t){return this.check(/* @__PURE__ */ Ma(e,t))},gte(e,t){return this.check(/* @__PURE__ */ Na(e,t))},min(e,t){return this.check(/* @__PURE__ */ Na(e,t))},lt(e,t){return this.check(/* @__PURE__ */ Aa(e,t))},lte(e,t){return this.check(/* @__PURE__ */ ja(e,t))},max(e,t){return this.check(/* @__PURE__ */ ja(e,t))},int(e){return this.check(As(e))},safe(e){return this.check(As(e))},positive(e){return this.check(/* @__PURE__ */ Ma(0,e))},nonnegative(e){return this.check(/* @__PURE__ */ Na(0,e))},negative(e){return this.check(/* @__PURE__ */ Aa(0,e))},nonpositive(e){return this.check(/* @__PURE__ */ ja(0,e))},multipleOf(e,t){return this.check(/* @__PURE__ */ Pa(e,t))},step(e,t){return this.check(/* @__PURE__ */ Pa(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 k(e){return/* @__PURE__ */ wa(Os,e)}let ks=/*@__PURE__*/ w(`ZodNumberFormat`,(e,t)=>{ii.init(e,t),Os.init(e,t)});function As(e){return/* @__PURE__ */ Ta(ks,e)}let js=/*@__PURE__*/ w(`ZodBoolean`,(e,t)=>{ai.init(e,t),rs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>fo(e,t,n,r)});function A(e){return/* @__PURE__ */ Ea(js,e)}let Ms=/*@__PURE__*/ w(`ZodNull`,(e,t)=>{oi.init(e,t),rs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>po(e,t,n,r)});function Ns(e){return/* @__PURE__ */ Da(Ms,e)}let Ps=/*@__PURE__*/ w(`ZodUnknown`,(e,t)=>{si.init(e,t),rs.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function Fs(){return/* @__PURE__ */ Oa(Ps)}let Is=/*@__PURE__*/ w(`ZodNever`,(e,t)=>{ci.init(e,t),rs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>mo(e,t,n,r)});function Ls(e){return/* @__PURE__ */ ka(Is,e)}let Rs=/*@__PURE__*/ w(`ZodArray`,(e,t)=>{ui.init(e,t),rs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>yo(e,t,n,r),e.element=t.element,ns(e,`ZodArray`,{min(e,t){return this.check(/* @__PURE__ */ Ia(e,t))},nonempty(e){return this.check(/* @__PURE__ */ Ia(1,e))},max(e,t){return this.check(/* @__PURE__ */ Fa(e,t))},length(e,t){return this.check(/* @__PURE__ */ La(e,t))},unwrap(){return this.element}})});function j(e,t){return/* @__PURE__ */ Xa(Rs,e,t)}let zs=/*@__PURE__*/ w(`ZodObject`,(e,t)=>{hi.init(e,t),rs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>bo(e,t,n,r),T(e,`shape`,()=>t.shape),ns(e,`ZodObject`,{keyof(){return P(Object.keys(this._zod.def.shape))},catchall(e){return this.clone({...this._zod.def,catchall:e})},passthrough(){return this.clone({...this._zod.def,catchall:Fs()})},loose(){return this.clone({...this._zod.def,catchall:Fs()})},strict(){return this.clone({...this._zod.def,catchall:Ls()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(e){return tn(this,e)},safeExtend(e){return nn(this,e)},merge(e){return rn(this,e)},pick(e){return $t(this,e)},omit(e){return en(this,e)},partial(...e){return an(ec,this,e[0])},required(...e){return on(uc,this,e[0])}})});function M(e,t){let n={type:`object`,shape:e??{},...E(t)};return new zs(n)}function N(e,t){return new zs({type:`object`,shape:e,catchall:Ls(),...E(t)})}let Bs=/*@__PURE__*/ w(`ZodUnion`,(e,t)=>{_i.init(e,t),rs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>xo(e,t,n,r),e.options=t.options});function Vs(e,t){return new Bs({type:`union`,options:e,...E(t)})}let Hs=/*@__PURE__*/ w(`ZodDiscriminatedUnion`,(e,t)=>{Bs.init(e,t),vi.init(e,t)});function Us(e,t,n){return new Hs({type:`union`,options:t,discriminator:e,...E(n)})}let Ws=/*@__PURE__*/ w(`ZodIntersection`,(e,t)=>{yi.init(e,t),rs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>So(e,t,n,r)});function Gs(e,t){return new Ws({type:`intersection`,left:e,right:t})}let Ks=/*@__PURE__*/ w(`ZodTuple`,(e,t)=>{Si.init(e,t),rs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Co(e,t,n,r),e.rest=t=>e.clone({...e._zod.def,rest:t})});function qs(e,t,n){let r=t instanceof D;return new Ks({type:`tuple`,items:e,rest:r?t:null,...E(r?n:t)})}let Js=/*@__PURE__*/ w(`ZodRecord`,(e,t)=>{Ei.init(e,t),rs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>wo(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType});function Ys(e,t,n){return!t||!t._zod?new Js({type:`record`,keyType:O(),valueType:e,...E(t)}):new Js({type:`record`,keyType:e,valueType:t,...E(n)})}let Xs=/*@__PURE__*/ w(`ZodEnum`,(e,t)=>{Di.init(e,t),rs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ho(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 Xs({...t,checks:[],...E(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 Xs({...t,checks:[],...E(r),entries:i})}});function P(e,t){let n=Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e;return new Xs({type:`enum`,entries:n,...E(t)})}let Zs=/*@__PURE__*/ w(`ZodLiteral`,(e,t)=>{Oi.init(e,t),rs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>go(e,t,n,r),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function F(e,t){return new Zs({type:`literal`,values:Array.isArray(e)?e:[e],...E(t)})}let Qs=/*@__PURE__*/ w(`ZodTransform`,(e,t)=>{ki.init(e,t),rs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>vo(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new kt(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(pn(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(pn(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 $s(e){return new Qs({type:`transform`,transform:e})}let ec=/*@__PURE__*/ w(`ZodOptional`,(e,t)=>{ji.init(e,t),rs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Mo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function tc(e){return new ec({type:`optional`,innerType:e})}let nc=/*@__PURE__*/ w(`ZodExactOptional`,(e,t)=>{Mi.init(e,t),rs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Mo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function rc(e){return new nc({type:`optional`,innerType:e})}let ic=/*@__PURE__*/ w(`ZodNullable`,(e,t)=>{Ni.init(e,t),rs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>To(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function ac(e){return new ic({type:`nullable`,innerType:e})}let oc=/*@__PURE__*/ w(`ZodDefault`,(e,t)=>{Pi.init(e,t),rs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Do(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function sc(e,t){return new oc({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():qt(t)}})}let cc=/*@__PURE__*/ w(`ZodPrefault`,(e,t)=>{Ii.init(e,t),rs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Oo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function lc(e,t){return new cc({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():qt(t)}})}let uc=/*@__PURE__*/ w(`ZodNonOptional`,(e,t)=>{Li.init(e,t),rs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Eo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function dc(e,t){return new uc({type:`nonoptional`,innerType:e,...E(t)})}let fc=/*@__PURE__*/ w(`ZodCatch`,(e,t)=>{zi.init(e,t),rs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ko(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function pc(e,t){return new fc({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:()=>t})}let mc=/*@__PURE__*/ w(`ZodPipe`,(e,t)=>{Bi.init(e,t),rs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ao(e,t,n,r),e.in=t.in,e.out=t.out});function hc(e,t){return new mc({type:`pipe`,in:e,out:t})}let gc=/*@__PURE__*/ w(`ZodReadonly`,(e,t)=>{Hi.init(e,t),rs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>jo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function _c(e){return new gc({type:`readonly`,innerType:e})}let vc=/*@__PURE__*/ w(`ZodLazy`,(e,t)=>{Wi.init(e,t),rs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>No(e,t,n,r),e.unwrap=()=>e._zod.def.getter()});function yc(e){return new vc({type:`lazy`,getter:e})}let bc=/*@__PURE__*/ w(`ZodCustom`,(e,t)=>{Gi.init(e,t),rs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>_o(e,t,n,r)});function xc(e,t){return/* @__PURE__ */ Za(bc,e??(()=>!0),t)}function Sc(e,t={}){return/* @__PURE__ */ Qa(bc,e,t)}function Cc(e,t){return/* @__PURE__ */ $a(e,t)}let wc=M({source:O(),ref:O(),offset:k().int().nonnegative(),length:k().int().positive(),label:O(),appearance:P([`session`,`file`,`folder`,`skill`]).optional(),clipboardText:O(),invalid:A().optional()}),Tc=M({text:O(),references:j(wc)}).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 Ec(e){return typeof e==`string`?{text:e,references:[]}:{text:e.text,references:e.references.map(kc)}}function Dc(e){if(typeof e==`string`)return Ec(e);let t=Tc.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 Oc(e,t){return{text:e,references:t.map(kc)}}function kc(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 Ac=`dsh.conversation`;function jc(){return(0,f.defineStore)({init:()=>({draft:``,view:null,viewRequest:null}),persist:Ac,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 Mc(e){let t={text:``,references:[]};if(typeof localStorage>`u`)return t;try{let n=localStorage.getItem(`${Ac}.${e}`);if(n===null)return t;let r=JSON.parse(n);return typeof r!=`object`||!r||!(`draft`in r)?t:Dc(r.draft)??t}catch{return t}}function Nc(e){if(typeof localStorage>`u`)return null;try{let t=localStorage.getItem(`${Ac}.${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 Pc(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 Fc(e){let t=e.replace(/[/\\]+$/,``),n=Math.max(t.lastIndexOf(`/`),t.lastIndexOf(`\\`));return t.slice(n+1)}function Ic(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 Lc=`conversation`,Rc=`描述你的任务以生成计划`,zc=`describe your task to generate plan`,Bc={"shortcut.newline":`换行`,"shortcut.complementary":`使用互补的 Queue/Steer 方式`,"shortcut.slash":`打开命令菜单`,"shortcut.mention":`打开引用菜单`,"hint.plan":Rc,"hint.goal":`输入目标,智能体将持续执行`,"hint.goal.active":`当前目标进行中。可输入 edit 修改 / pause 暂停 / resume 继续 / clear 清除`,"placeholder.plan":Rc,"placeholder.default":`发消息或创建任务, / 调用指令, @ 文件或对话`,"placeholder.unavailable":`会话不可用`,"placeholder.parentOffline":`父会话已离线,无法继续发送;仍可停止当前运行`,"placeholder.hero":`描述你想要构建的内容, / 调用指令, @ 文件或对话`,"placeholder.workspace":`选择一个工作区开始`,"placeholder.preparing":`正在准备对话…`,"placeholder.steerQueue":`Cmd/Ctrl+Enter 插话发送全部排队消息`,"newSession.loadingModel":`模型加载中…`,"newSession.loadingHarness":`正在加载 Harness…`,"newSession.createFailedTitle":`无法创建新会话`,"newSession.createFailed.noHarness":`没有可用的 Harness,请检查设置后重试。`,"newSession.createFailed.workspaceRequired":`请先选择一个工作区再开始新会话。`,"newSession.createFailed.generic":`暂时无法创建新会话,请稍后重试。`,"newSession.retry":`重试`,"newSession.uploadUnavailable":`新会话准备完成后才能添加文件`,"input.commands":`添加文件或调用指令`,"input.commandsOnly":`调用指令`,"input.imagesAndCommands":`添加图片或调用指令`,"attachment.unavailable":`当前 Web 连接不支持附件上传。`,"input.file":`文件`,"input.stop":`停止生成`,"input.send":`发送消息`,"input.send.queue":`排队发送`,"input.send.steer":`插话发送`,"attachment.pending":`待发送附件`,"annotation.rail":`已附加的选中文字`,"annotation.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 后重试。`,"error.steerTurnChanged":`你要插话的这一轮已经结束或切换,草稿已保留。`,"error.remoteSteerUnavailable":`当前连接无法确认插话的目标轮次,草稿已保留。`,"queue.editFailed":`编辑失败:这条消息可能已经开始发送。`,"queue.removeFailed":`删除失败:这条消息可能已经开始发送。`,"queue.steerFailed":`插话发送失败,请重试。`,"queue.resumeFailed":`继续队列失败,请重试。`,"queue.remoteActionFailed":`远程队列操作未确认,请先查看队列和会话状态。`,"queue.remoteStartUnconfirmed":`消息已入队,启动尚未确认。请查看队列和会话,勿重发。`,"queue.remoteStale":`暂时无法刷新远程队列。`,"terminal.signal":`信号 {signal}`,"terminal.exitCode":`退出码 {code}`,"terminal.noExitCode":`未正常退出`,"terminal.running":`运行中`,"terminal.failed":`失败`,"terminal.done":`已完成`,"terminal.noOutput":`无输出`,"terminal.collapseAria":`收起输出`,"terminal.expandAria":`展开其余 {n} 行输出`,"terminal.expandRest":`… 其余 {n} 行`,"terminal.sendInput":`(发送输入)`,"terminal.session":`终端 {sessionId}`},Vc={"shortcut.newline":`New line`,"shortcut.complementary":`Use the complementary Queue / Steer action`,"shortcut.slash":`Open command menu`,"shortcut.mention":`Open reference menu`,"hint.plan":zc,"hint.goal":`describe the objective for a long-running task`,"hint.goal.active":`goal active — edit / pause / resume / clear`,"placeholder.plan":zc,"placeholder.default":`Message or run a task, / commands, @ files or sessions`,"placeholder.unavailable":`Session unavailable`,"placeholder.parentOffline":`Parent session offline; sending is unavailable but you can still stop the run`,"placeholder.hero":`Describe what you want to build, / commands, @ files or sessions`,"placeholder.workspace":`Choose a workspace to start`,"placeholder.preparing":`Preparing conversation…`,"placeholder.steerQueue":`Cmd/Ctrl+Enter steers all queued messages`,"newSession.loadingModel":`Loading models…`,"newSession.loadingHarness":`Loading Harness…`,"newSession.createFailedTitle":`Couldn’t start a new session`,"newSession.createFailed.noHarness":`No Harness is available. Check your settings and try again.`,"newSession.createFailed.workspaceRequired":`Choose a workspace before starting a new session.`,"newSession.createFailed.generic":`Unable to start a new session right now. Please try again.`,"newSession.retry":`Retry`,"newSession.uploadUnavailable":`Wait for the new session to finish loading before adding files`,"input.commands":`Add files or run commands`,"input.commandsOnly":`Run commands`,"input.imagesAndCommands":`Add images or run commands`,"attachment.unavailable":`Attachment uploads are unavailable on this Web connection.`,"input.file":`File`,"input.stop":`Stop generating`,"input.send":`Send message`,"input.send.queue":`Queue message`,"input.send.steer":`Steer message`,"attachment.pending":`Pending attachments`,"annotation.rail":`Selected text attached to this message`,"annotation.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.`,"error.steerTurnChanged":`The turn you tried to steer ended or changed. Your draft was kept.`,"error.remoteSteerUnavailable":`This connection cannot confirm the target turn for steering. Your draft was kept.`,"queue.editFailed":`Edit failed: this message may have already started sending.`,"queue.removeFailed":`Removal failed: this message may have already started sending.`,"queue.steerFailed":`Steering failed. Try again.`,"queue.resumeFailed":`Could not resume the queue. Try again.`,"queue.remoteActionFailed":`Remote queue action was not confirmed. Check the queue and chat.`,"queue.remoteStartUnconfirmed":`Message queued. Its start is unconfirmed. Check the queue and chat. Do not resend.`,"queue.remoteStale":`The remote queue could not be refreshed.`,"terminal.signal":`signal {signal}`,"terminal.exitCode":`exit code {code}`,"terminal.noExitCode":`no exit code`,"terminal.running":`Running`,"terminal.failed":`Failed`,"terminal.done":`Done`,"terminal.noOutput":`No output`,"terminal.collapseAria":`Collapse output`,"terminal.expandAria":`Expand the remaining {n} output lines`,"terminal.expandRest":`… {n} more lines`,"terminal.sendInput":`(send input)`,"terminal.session":`Terminal {sessionId}`},Hc=2048;async function Uc(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<=Hc&&e.size<=1048576)return e;let r=Math.min(1,Hc/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 Wc(e){return{kind:`image`,id:yt(),previewUrl:URL.createObjectURL(e),file:e}}function Gc(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 Kc(){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 qc=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`&&Yc(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 Kc(),d=[...await s(),...t===``?[]:[{type:`text`,text:t}]]}catch(e){throw u.abandon(),e}let f=await e.prompt(d,r,i,u.requestId);return!f.ok||l!==void 0&&(await l).reason!==`observed`?{kind:`error`}:f.value.queueStartUnconfirmed?{kind:`success`,text:this.ctx.locale.bind(Lc)(`queue.remoteStartUnconfirmed`)}:{kind:`success`}}finally{a?.release()}}createDrafts(e,t){return t.map(t=>{if(Jc(t.type)){let n=Wc(t);return this.draftAttachments.set(n.id,n),Gc(n),this.beginFileUpload(e,n),n}let n={kind:`file`,id:yt(),file:t};return this.draftAttachments.set(n.id,n),this.beginFileUpload(e,n),n})}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=Uc(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`&&Yc(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)&&Yc(a.previewUrl)))}}assertUploadsNotFailed(e){if(e.some(e=>this.fileUploads.getSnapshot()[e]?.status===`error`))throw Error(this.ctx.locale.bind(Lc)(`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(Lc)(`file.retryOrRemove`)))):e.every(e=>r[e]?.status===`ready`)&&(i(),t())},i=this.fileUploads.subscribe(r);r()})}};function Jc(e){return e===`image/png`||e===`image/jpeg`||e===`image/webp`||e===`image/gif`}function Yc(e){e.startsWith(`blob:`)&&URL.revokeObjectURL(e)}var Xc=class{stores=/* @__PURE__ */ new Map;set(e,t){let n=this.storeFor(e);n.getSnapshot()?.reason!==t?.reason&&n.set(t)}storeFor(e){let t=this.stores.get(e);if(t!==void 0)return t;let n=(0,f.createSnapshotStore)(void 0);return this.stores.set(e,n),n}forget(e){this.stores.delete(e)}};function I(e,...t){let n=new URL(`https://lexical.dev/docs/error`),r=new URLSearchParams;r.append(`code`,e);for(let e of t)r.append(`v`,e);throw n.search=r.toString(),Error(`Minified Lexical error #${e}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}function Zc(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 Qc=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0,$c=Qc&&`documentMode`in document?document.documentMode:null,el=Qc&&/Mac|iPod|iPhone|iPad/.test(navigator.platform),tl=Qc&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent),nl=!(!Qc||!(`InputEvent`in window)||$c)&&`getTargetRanges`in new window.InputEvent(`input`),rl=Qc&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,il=Qc&&/Android/.test(navigator.userAgent),al=Qc&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent)&&!il,ol=Qc&&/^(?=.*Chrome).*/i.test(navigator.userAgent),sl=Qc&&il&&ol,cl=Qc&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&el&&!ol,ll=al||rl||cl?`\xA0`:``,ul=tl?`\xA0`:ll,dl=`֑-߿יִ-﷽ﹰ-ﻼ`,fl=`A-Za-zÀ-ÖØ-öø-ʸ̀-ࠀ-Ⰰ-︀--`;RegExp(`^[^`+fl+`]*[`+dl+`]`),RegExp(`^[^`+dl+`]*[`+fl+`]`);let pl={bold:1,capitalize:1024,code:16,highlight:128,italic:2,lowercase:256,strikethrough:4,subscript:32,superscript:64,underline:8,uppercase:512},ml={directionless:1,unmergeable:2},hl={center:2,end:6,justify:4,left:1,right:3,start:5},gl={2:`center`,6:`end`,4:`justify`,1:`left`,3:`right`,5:`start`},_l={normal:0,segmented:2,token:1},vl={0:`normal`,2:`segmented`,1:`token`},yl=`$config`;function bl(){return Rg()._blockCursorElement}function xl(e){return e!==null&&e.nodeType===1&&e.hasAttribute(`data-lexical-slot`)}var Sl=class e{element;before;after;constructor(e,t,n){this.element=e,this.before=t||null,this.after=n||null}withBefore(t){return new e(this.element,t,this.after)}withAfter(t){return new e(this.element,this.before,t)}withElement(t){return this.element===t?this:new e(t,this.before,this.after)}insertChild(e){let t=this.getInsertionAnchor();return t!==null&&t.parentElement!==this.element&&I(357),this.element.insertBefore(e,t),this}removeChild(e){return e.parentElement!==this.element&&I(358),this.element.removeChild(e),this}replaceChild(e,t){return t.parentElement!==this.element&&I(359),this.element.replaceChild(e,t),this}getFirstChild(){let e=this.getFirstChildAnchor(),t=e?e.nextSibling:this.element.firstChild;return t===this.getInsertionAnchor()?null:t}getFirstChildAnchor(){return this.after}resolveLeafPosition(e,t,n){if(this.element===e)return t===e&&n===0?`before`:`after`;let r=Cl(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=Cl(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 Cl(e,t){let n=t;for(;n!==null&&n.parentNode!==e;)n=n.parentNode;return n}var wl=class e extends Sl{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(;xl(t);)e=t,t=t.nextSibling;let n=e?e.nextSibling:this.element.firstChild;return n!==null&&n===bl()?n:e}getManagedLineBreak(){return this.element.__lexicalLineBreak||null}setManagedLineBreak(e){if(this.element.__lexicalLastChildKind=e,e===null)this.removeManagedLineBreak();else{let t=e===`decorator`&&(cl||rl||al);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=xg().createElement(`br`);if(i.setAttribute(`data-lexical-managed-linebreak`,`true`),n.insertBefore(i,r),e){let e=xg().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=bl(),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=Tl(t,n);i.push(r);let a=Tl(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 Tl(e,t){let n=[],r=t;for(;r!==e&&r!==null;r=r.parentNode){let e=0;for(let t=r.previousSibling;t!==null;t=t.previousSibling)e++;n.push(e)}return r!==e&&I(225),n.reverse()}let El;try{El=`0.49.0+prod.esm`}catch{}let Dl=El??`"<unknown>+source"`;var Ol=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 kl(e,t=1e3){return e instanceof Al?e.clone():e.size<t?new Map(e):new Al().init(new Map(e),void 0,e.size)}var Al=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 jl(e,t,n,r,i,a){if(W(e)){let o=e.getFirstChild();for(;o!==null;){let e=o.__key;o.__parent===t&&((W(o)||d_(o)&&o.__slots!==null)&&jl(o,e,n,r,i,a),n.has(e)||a.delete(e),i.push(e)),o=o.getNextSibling()}}for(let o of d_(e)&&e.__slots!==null?e.__slots.values():[]){let e=r.get(o);e!==void 0&&f_(e)&&e.__slotHost===t&&((W(e)||d_(e)&&e.__slots!==null)&&jl(e,o,n,r,i,a),n.has(o)||a.delete(o),i.push(o))}}let Ml=!1,Nl=0;function Pl(e){Nl=e.timeStamp}function Fl(e,t,n){let r=e.nodeName===`BR`,i=t.__lexicalLineBreak;return i&&(e===i||r&&e.previousSibling===i)||r&&wh(e,n)!==void 0}function Il(e,t,n){let r=mg(rg(n)),i=r&&wg(r,n._rootElement),a=null,o=null;i!==null&&i.anchorNode===e&&(a=i.anchorOffset,o=i.focusOffset);let s=e.nodeValue;s!==null&&Lh(t,s,a,o,!1)}function Ll(e,t,n){if(V(e)){let t=e.anchor.getNode();if(t.is(n)&&e.format!==t.getFormat())return!1}return fh(t)&&n.isAttached()}function Rl(e,t,n){for(let r=e;r&&!Qg(r);r=Zh(r)){let e=wh(r,t);if(e!==void 0){let t=xh(e,n);if(t)return G(t)||!J(r)?void 0:[r,t]}}}function zl(e,t,n){Ml=!0;let r=performance.now()-Nl>100;try{bm(e,()=>{let i=H()||function(e){return e.read(`latest`,()=>{let e=H();return e===null?null:e.clone()})}(e),a=/* @__PURE__ */ new Map,o=e._editorState,s=e._blockCursorElement,c=!1,l=``;for(let n=0;n<t.length;n++){let u=t[n],d=u.type,f=u.target,p=Rl(f,e,o);if(!p)continue;let[m,h]=p;if(d===`characterData`)r&&B(h)&&fh(f)&&Ll(i,f,h)&&Il(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=Sh(r),a=r.parentNode;if(!(a==null||r===s||i!==null||Fl(r,a,e)||e._slotsUsed&&J(r)&&r.hasAttribute(`data-lexical-slot`)||Qg(r))){if(tl){let e=(J(r)?r.innerText:null)||r.nodeValue;e&&(l+=e)}a.removeChild(r)}}let n=u.removedNodes,r=n.length;if(r>0){let t=0;for(let i=0;i<r;i++){let r=n[i];(Fl(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`||Fl(n,i,e)||a.removeChild(n)}}n.takeRecords()}i!==null&&(c&&kh(i),tl&&Yh(e)&&i.insertRawText(l))})}finally{Ml=!1}}function Bl(e){let t=e._observer;t!==null&&zl(e,t.takeRecords(),t)}function Vl(e){(function(e){Nl===0&&rg(e).addEventListener(`textInput`,Pl,!0)})(e),e._observer=new MutationObserver((t,n)=>{zl(e,t,n)})}var Hl=class{key;parse;unparse;isEqual;defaultValue;resetOnCopyNode;constructor(e,t){this.key=e,this.parse=t.parse.bind(t),this.unparse=(t.unparse||Xl).bind(t),this.isEqual=(t.isEqual||Object.is).bind(t),this.defaultValue=this.parse(void 0),this.resetOnCopyNode=t.resetOnCopyNode||!1}};function Ul(e,t){return new Hl(e,t)}function Wl(e){let t=/* @__PURE__ */ new Map,n=/* @__PURE__ */ new Set;for(let{ownNodeConfig:r}of a_(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 Gl=/* @__PURE__ */ new Set([`__proto__`,`constructor`,`prototype`]);var Kl=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 Yl(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(Gl.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=Yl(i)),this.size++),r.set(e,t)}updateFromUnknown(e,t){if(Gl.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 ql(e){let t=e.getWritable(),n=t.__state?t.__state.getWritable(t):new Kl(t,Jl(t));return t.__state=n,n}function Jl(e){return e.__state?e.__state.sharedNodeState:nh(Rg(),e.getType()).sharedNodeState}function Yl(e){if(e)for(let t in e)return e}function Xl(e){return e}function Zl(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 Ql(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 $l(e,t){let n=e.__state;return n&&n.node===e?n.getWritable(t):n}function eu(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&&Zl(n,e,t)||t&&Zl(n,t,e)||e&&Ql(n,e,t)||t&&Ql(n,t,e))}(c,l))}function tu(e,t){let n=e.mergeWithSibling(t),r=U()._normalizedNodes;return r.add(e.__key),r.add(t.__key),n}function nu(e){let t,n,r=e;if(r.__text!==``||!r.isSimpleText()||r.isUnmergeable()){for(;(t=r.getPreviousSibling())!==null&&B(t)&&t.isSimpleText()&&!t.isUnmergeable();){if(t.__text!==``){if(eu(t,r)){r=tu(t,r);break}break}t.remove()}for(;(n=r.getNextSibling())!==null&&B(n)&&n.isSimpleText()&&!n.isUnmergeable();){if(n.__text!==``){if(eu(r,n)){r=tu(r,n);break}break}n.remove()}}else r.remove()}function ru(e){return iu(e.anchor),iu(e.focus),e}function iu(e){for(;e.type===`element`;){let t=e.getNode(),n=e.offset,r,i;if(n===t.getChildrenSize()?(r=t.getChildAtIndex(n-1),i=!0):(r=t.getChildAtIndex(n),i=!1),B(r)){e.set(r.__key,i?r.getTextContentSize():0,`text`,!0);break}if(!W(r))break;e.set(r.__key,i?r.getChildrenSize():0,`element`,!0)}}let au=Symbol.for(`@lexical/CachedTextSize`);function ou(e,t){return bu.read(()=>{let n=0,r=e;for(let e=0;e<t&&r!==null;e++){let i=yu.get(r);if(i===void 0&&I(345,r),W(i)){let a=xu.get(r);if(a!==void 0&&W(a)&&a.__parent!==i.__parent)n+=i.getTextContentSize();else{let e=Su.get(r),t=e&&e.__lexicalTextContent;typeof t!=`string`&&I(346,i.getType()),n+=t.length}e<t-1&&!i.isInline()&&(n+=2)}else{let e=i[au];e===void 0&&I(347,i.getType(),r),n+=e}r=i.__next}return n},{editor:L})}function su(e){W(e)||e[au]===void 0&&(e[au]=B(e)?e.__text.length:e.getTextContentSize())}let cu,L,lu,R=``,uu=null,du=null,fu=null;function pu(){return{firstTextKey:fu,format:uu,style:du}}function mu(e){e.firstTextKey!==null&&(uu=e.format,du=e.style,fu=e.firstTextKey)}function hu(e){if(fu!==null)return;let t=e.__lexicalFirstTextKey;if(t===void 0&&I(348),t===null)return;let n=xu.get(t);B(n)&&(uu=n.getFormat(),du=n.getStyle(),fu=t)}let gu,_u,vu,yu,bu,xu,Su,Cu,wu,Tu,Eu=!1,Du=!1;function Ou(e,t){let n=yu.get(e),r=xu.has(e);if(t!==null){let n=Zu(e);n.parentNode===t&&t.removeChild(n)}if(!r){if(L._keyToDOMMap.delete(e),W(n)){let e=c_(n,yu);ku(e,0,e.length-1,null)}if(n!==void 0){for(let e of Lu(n).values()){let t=zu(e);Ou(e,null),t!==null&&t.remove()}Kh(wu,lu,gu,n,`destroyed`)}}}function ku(e,t,n,r){for(let i=t;i<=n;++i){let t=e[i];t!==void 0&&Ou(t,r)}}function Au(e,t){e.setProperty(`text-align`,t)}function ju(e,t){let n=cu.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 Mu(e,t){let n=e.style;t===0?Au(n,``):t===1?Au(n,`left`):t===2?Au(n,`center`):t===3?Au(n,`right`):t===4?Au(n,`justify`):t===5?Au(n,`start`):t===6&&Au(n,`end`)}function Nu(e,t){let n=function(e){let t=e.__dir;if(t!==null)return t;if(Em(e))return null;let n=e.getParent();return n===null||sg(n)&&n.__dir===null?`auto`:null}(t);n===null?e.removeAttribute(`dir`):e.dir=n}function Pu(e){let t=xg().createElement(`div`);return t.setAttribute(`data-lexical-slot`,e),t.style.display=`none`,t}function Fu(e,t,n){t||e.contentEditable===`false`?$g(n,L):n.removeAttribute(`contenteditable`)}function Iu(e,t,n){let r=R,i=pu();R=``;let a=``,o=G(e);for(let[r,i]of n){let n=Pu(r);Fu(t,o,n),t.appendChild(n),R=``;let s=pu();Vu(i,Bg(e,n,L)),mu(s),Ru(e,r,t,n),a+=R}return mu(i),R=r,a}function Lu(e){return d_(e)&&e.__slots!==null?e.__slots:u_}function Ru(e,t,n,r){let i=Tu.$getSlotTargetElement(e,t,n,L);i!==null&&(r.parentElement!==i&&i.appendChild(r),r.style.display=``)}function zu(e){let t=Su.get(e);return t===void 0?null:t.parentElement}function Bu(e,t,n){let r=Lu(e),i=Lu(t);for(let[e,t]of r)if(!i.has(e)){let e=zu(t);Ou(t,null),e!==null&&e.remove()}let a=R,o=pu(),s=``,c=null,l=G(t);for(let[e,a]of i){let i=r.get(e),o=i===void 0?null:zu(i);R=``;let u=pu();if(o===null){o=Pu(e);let r=null;for(let e of n.children)if(!e.hasAttribute(`data-lexical-slot`)){r=e;break}n.insertBefore(o,r),Vu(a,Bg(t,o,L))}else i===a?Ku(a,o):(i!==void 0&&Ou(i,o),Vu(a,Bg(t,o,L)));if(mu(u),Fu(n,l,o),Ru(t,e,n,o),s+=R,o.parentElement===n){let e=c===null?n.firstChild:c.nextSibling;e!==o&&n.insertBefore(o,e),c=o}}return mu(o),R=a,s}function Vu(e,t){let n=xu.get(e);if(n===void 0&&I(60),t!==null){let r=yu.get(e);if(r!==void 0){let i=Su.get(e);if(i!==void 0){let a=f_(r)?r.__slotHost:null,o=f_(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),Ku(e,t.element)}}}let r=Tu.$createDOM(n,L);if(function(e,t,n){let r=n._keyToDOMMap;Ch(t,n,e),r.set(e,t)}(e,r,L),B(n)?r.setAttribute(`data-lexical-text`,`true`):G(n)&&(r.setAttribute(`data-lexical-decorator`,`true`),Zg(r,{captureSelection:!0})),W(n)){let e=n.__indent,t=n.__size;Nu(r,n),e!==0&&ju(r,e);let i=Lu(n),a=i.size>0?Iu(n,r,i):``;if(t===0)r.__lexicalTextContent=a,r.__lexicalFirstTextKey=null,R+=a,i.size>0&&(r.__lexicalSlotTextLength=a.length);else{let e=R,o=t-1;if(Hu(c_(n,xu),n,0,o,Bg(n,r,L)),a!==``){let t=r.__lexicalTextContent||``;r.__lexicalTextContent=a+t,R=e+a+t}i.size>0&&(r.__lexicalSlotTextLength=a.length)}let o=n.__format;o!==0&&Mu(r,o),n.isInline()||Uu(null,n,r)}else{let t=n.getTextContent();if(G(n)){let t=n.decorate(L,cu);t!==null&&qu(e,t),r.contentEditable=`false`;let i=Lu(n);i.size>0&&Iu(n,r,i)}R+=t}return t!==null&&t.insertChild(r),Tu.$decorateDOM(n,null,r,L),su(n),Kh(wu,lu,gu,n,`created`),r}function Hu(e,t,n,r,i){let a=R,o=pu();R=``,uu=null,du=null,fu=null;let s=n;for(;s<=r;++s){let t=pu();Vu(e[s],i);let n=xu.get(e[s]);n!==null&&B(n)?uu===null&&(uu=n.getFormat(),du=n.getStyle(),fu=n.__key):W(n)&&s<r&&!n.isInline()&&(R+=`
|
|
123
|
+
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let n of e.seen.entries()){let r=n[1];if(t===n[0])a(n);else{if(e.external){let r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){a(n);continue}}(e.metadataRegistry.get(n[0])?.id||r.cycle||r.count>1&&e.reused===`ref`)&&a(n)}}e.external&&(e.sharedDefsExtractedFor=e.external)}function Is(e){let t=e.anyOf;if(!Array.isArray(t)||t.length===0||e.type!==void 0)return;let n=[];for(let e of t){if(!e||typeof e!=`object`)return;Is(e);let t=Object.keys(e);if(t.length!==1||t[0]!==`type`)return;let r=e.type;for(let e of Array.isArray(r)?r:[r]){if(typeof e!=`string`)return;n.includes(e)||n.push(e)}}delete e.anyOf,e.type=n.length===1?n[0]:n}let Ls=/* @__PURE__ */ new Set([`type`,`properties`,`required`,`additionalProperties`]),Rs=[`oneOf`,`anyOf`];function zs(e){let t=e.additionalProperties;return t===void 0||t===!1||typeof t!=`object`||!t?null:Object.keys(t).length?t:null}function Bs(e){let t=[];for(let n of e){if(typeof n!=`object`||n.type!==`object`)return null;for(let e in n)if(!Ls.has(e))return null;t.push(n)}let n={},r=/* @__PURE__ */ new Set;for(let e of t){for(let r in e.properties){if(Object.prototype.hasOwnProperty.call(n,r))continue;let e=[];for(let n of t){let t=n.properties?.[r]??zs(n);t!=null&&(e.some(e=>JSON.stringify(e)===JSON.stringify(t))||e.push(t))}Ft(n,r,e.length===1?e[0]:Bs(e)??{allOf:e})}for(let t of e.required??[])r.add(t)}let i={type:`object`,properties:n};if(r.size&&(i.required=[...r]),t.every(e=>e.additionalProperties===!1))i.additionalProperties=!1;else{let e=[];for(let n of t){let t=zs(n);t&&!e.some(e=>JSON.stringify(e)===JSON.stringify(t))&&e.push(t)}e.length===1?i.additionalProperties=e[0]:e.length>1&&(i.additionalProperties={allOf:e})}return i}function Vs(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let t of Ls)if(t in e)return;let n=t.filter(e=>Rs.some(t=>Array.isArray(e[t]))),r=null;if(!n.length)r=Bs(t);else{let e=n[0],i=Rs.find(t=>Array.isArray(e[t]));if(Object.keys(e).length!==1)return;let a=t.filter(t=>t!==e),o=e[i].map(e=>Bs([...a,e]));if(o.some(e=>!e))return;r={[i]:o}}r&&(delete e.allOf,As(e,r))}function Hs(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)):As(i,s),As(i,a),t._zod.parent===o)for(let e in i)e!==`$ref`&&e!==`allOf`&&(e in a||delete i[e]);if(s.$ref&&n.def)for(let e in i)e!==`$ref`&&e!==`allOf`&&e in n.def&&JSON.stringify(i[e])===JSON.stringify(n.def[e])&&delete i[e]}let s=t._zod.parent;if(s&&s!==o){r(s);let t=e.seen.get(s);if(t?.schema.$ref&&(i.$ref=t.schema.$ref,t.def))for(let e in i)e!==`$ref`&&e!==`allOf`&&e in t.def&&JSON.stringify(i[e])===JSON.stringify(t.def[e])&&delete i[e]}e.override({zodSchema:t,jsonSchema:i,path:n.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(let t of[...e.seen.entries()].reverse())r(t[0]);if(e.target!==`openapi-3.0`)for(let t of e.seen.entries())Is(t[1].def??t[1].schema);for(let t of e.deferred)t();if(e.intersections.length){let t=/* @__PURE__ */ new Map;for(let n of e.seen.values())for(let e of[n.schema,n.def]){let n=e?.allOf;if(!Array.isArray(n))continue;let r=t.get(n);r?r.push(e):t.set(n,[e])}for(let n of e.intersections)for(let e of t.get(n)??[])Vs(e)}}let i={};if(e.target===`draft-2020-12`?i.$schema=`https://json-schema.org/draft/2020-12/schema`:e.target===`draft-07`?i.$schema=`http://json-schema.org/draft-07/schema#`:e.target===`draft-04`?i.$schema=`http://json-schema.org/draft-04/schema#`:e.target,e.external?.uri){let n=e.external.registry.get(t)?.id;if(!n)throw Error("Schema is missing an `id` property");i.$id=e.external.uri(n)}As(i,n.defId?n.schema:n.def??n.schema);let a=e.metadataRegistry.get(t)?.id;a!==void 0&&i.id===a&&delete i.id;let o=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(e.def.id===e.defId&&delete e.def.id,Ft(o,e.defId,e.def))}e.external&&(e.sharedEmitDoneFor=e.external),e.external||Object.keys(o).length>0&&(e.target===`draft-2020-12`?i.$defs=o:i.definitions=o);try{let n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,"~standard",{value:{...t[`~standard`],jsonSchema:{input:Gs(t,`input`,e.processors),output:Gs(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function Us(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 Us(r.element,n);if(r.type===`set`)return Us(r.valueType,n);if(r.type===`lazy`)return Us(r.getter(),n);if(r.type===`promise`||r.type===`optional`||r.type===`nonoptional`||r.type===`nullable`||r.type===`readonly`||r.type==="default"||r.type===`prefault`||r.type===`catch`)return Us(r.innerType,n);if(r.type===`intersection`)return Us(r.left,n)||Us(r.right,n);if(r.type===`record`||r.type===`map`)return Us(r.keyType,n)||Us(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:Us(r.in,n)||Us(r.out,n);if(r.type===`object`){for(let e in r.shape)if(Us(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(Us(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(Us(e,n))return!0;return!!(r.rest&&Us(r.rest,n))}return!1}let Ws=(e,t={})=>n=>{let r=js({...n,processors:t});return Ns(e,r),Fs(r,e),Hs(r,e)},Gs=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=js({...i??{},target:a,io:t,processors:n});return Ns(e,o),Fs(o,e),Hs(o,e)},Ks=(e,t,n)=>{(e[t]===void 0||n>e[t])&&(e[t]=n)},qs=(e,t,n)=>{(e[t]===void 0||n<e[t])&&(e[t]=n)},Js=(e,t)=>{Ks(e,`minimum`,t),qs(e,`maximum`,t)},Ys=(e,t)=>{e.multipleOf??=[],e.multipleOf.includes(t)||e.multipleOf.push(t)},Xs=(e,t)=>{e.patterns??=/* @__PURE__ */ new Set,e.patterns.add(t)},Zs=(e,t)=>{e.mime=e.mime?e.mime.filter(e=>t.includes(e)):[...t]},Qs=(e,t)=>{e.format=t,t.includes(`int`)&&(e.isInt=!0)},$s=(e,t)=>Ks(e,`minimum`,t.minimum),ec=(e,t)=>qs(e,`maximum`,t.maximum),tc=e=>(t,n)=>{Qs(t,n.format);let[r,i]=e[n.format];Ks(t,`minimum`,r),qs(t,`maximum`,i)},nc={greater_than:(e,t)=>Ks(e,t.inclusive?`minimum`:`exclusiveMinimum`,t.value),less_than:(e,t)=>qs(e,t.inclusive?`maximum`:`exclusiveMaximum`,t.value),multiple_of:(e,t)=>Ys(e,t.value),number_format:tc(tn),bigint_format:tc(nn),min_length:$s,max_length:ec,length_equals:(e,t)=>Js(e,t.length),min_size:$s,max_size:ec,size_equals:(e,t)=>Js(e,t.size),string_format:(e,t)=>{Qs(e,t.format),t.pattern&&Xs(e,t.pattern),(t.format===`base64`||t.format===`base64url`)&&(e.contentEncoding=t.format),(t.local||t.precision===-1)&&(e.laxFormat=!0)},mime_type:(e,t)=>Zs(e,t.mime)};function rc(e){let t={},n=e._zod.def,r=e._zod.traits.has(`$ZodCheck`)?[e,...n.checks??[]]:n.checks??[];for(let e of r)nc[e._zod.def.check]?.(t,e._zod.def);let i=e._zod.bag;i.minimum!==void 0&&Ks(t,`minimum`,i.minimum),i.exclusiveMinimum!==void 0&&Ks(t,`exclusiveMinimum`,i.exclusiveMinimum),i.maximum!==void 0&&qs(t,`maximum`,i.maximum),i.exclusiveMaximum!==void 0&&qs(t,`exclusiveMaximum`,i.exclusiveMaximum),i.multipleOf!==void 0&&Ys(t,i.multipleOf),i.format!==void 0&&(t.format??=i.format,i.format.includes(`int`)&&(t.isInt=!0)),i.mime&&Zs(t,i.mime);for(let e of i.patterns??[])Xs(t,e);return t}let ic={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},ac=/* @__PURE__ */ new Map([[ta,Ir],[ra,Lr]]),oc=e=>ac.get(e)??e,sc=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l,laxFormat:u}=rc(e);if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=ic[s]??s,i.format===``&&delete i.format,(s===`time`||u)&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let e=[...c].map(oc);e.length===1?i.pattern=e[0].source:e.length>1&&(i.allOf=[...e.map(e=>({...t.target===`draft-07`||t.target===`draft-04`||t.target===`openapi-3.0`?{type:`string`}:{},pattern:e.source}))])}},cc=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,multipleOf:s,exclusiveMaximum:c,exclusiveMinimum:l,isInt:u}=rc(e);i.type=u?`integer`:`number`;let d=typeof l==`number`&&l>=(a??-1/0),f=typeof c==`number`&&c<=(o??1/0),p=t.target===`draft-04`||t.target===`openapi-3.0`;if(d?p?(i.minimum=l,i.exclusiveMinimum=!0):i.exclusiveMinimum=l:typeof a==`number`&&(i.minimum=a),f?p?(i.maximum=c,i.exclusiveMaximum=!0):i.exclusiveMaximum=c:typeof o==`number`&&(i.maximum=o),s){let n=/* @__PURE__ */ new Set;for(let a of s)Number.isFinite(a)&&a!==0?n.add(Math.abs(a)):Ms(e,t,i,r,`A multipleOf divisor of ${a} cannot be represented in JSON Schema`);let[a,...o]=n;a!==void 0&&(i.multipleOf=a),o.length&&(i.allOf=[...i.allOf??[],...o.map(e=>({multipleOf:e}))])}},lc=(e,t,n,r)=>{n.type=`boolean`},uc=(e,t,n,r)=>{t.target===`openapi-3.0`?(n.type=`string`,n.nullable=!0,n.enum=[null]):n.type=`null`},dc=(e,t,n,r)=>{n.not={}},fc=(e,t,n,r)=>{let i=e._zod.def,a=Tt(i.entries);a.length===0?n.not={}:(a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a)},pc=(e,t,n,r)=>{let i=e._zod.def;if(i.values.length===0){n.not={};return}let a=[];for(let o of i.values)if(o===void 0){if(Ms(e,t,n,r,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof o==`bigint`){if(Ms(e,t,n,r,`BigInt literals cannot be represented in JSON Schema`))return;a.push(Number(o))}else a.push(o);if(a.length!==0){if(a.length===1){let e=a[0];n.type=e===null?`null`:typeof e,t.target===`draft-04`||t.target===`openapi-3.0`?n.enum=[e]:n.const=e}else a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),a.every(e=>typeof e==`boolean`)&&(n.type=`boolean`),a.every(e=>e===null)&&(n.type=`null`),n.enum=a}},mc=(e,t,n,r)=>{Ms(e,t,n,r,`Custom types cannot be represented in JSON Schema`)},hc=(e,t,n,r)=>{Ms(e,t,n,r,`Transforms cannot be represented in JSON Schema`)},gc=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=rc(e);typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=Ns(a.element,t,{...r,path:[...r.path,`items`]})};function _c(e){let t=e._zod.def;return t.type===`pipe`&&t.in._zod.traits.has(`$ZodTransform`)?_c(t.out):t.type===`catch`?_c(t.innerType):e._zod.optin}let vc=(e,t,n,r)=>{let i=n,a=e._zod.def,o=a.shape;if(Object.getOwnPropertySymbols(o).length&&Ms(e,t,i,r,`Symbol keys cannot be represented in JSON Schema`))return;i.type=`object`,i.properties={};for(let e in o)Ft(i.properties,e,Ns(o[e],t,{...r,path:[...r.path,`properties`,e]}));let s=[];for(let e of Object.keys(o)){let n=a.shape[e];(t.io===`input`?_c(n)===void 0:n._zod.optout===void 0)&&s.push(e)}s.length>0&&(i.required=s),a.catchall?._zod.def.type===`never`?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=Ns(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},yc=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>Ns(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},bc=(e,t,n,r)=>{let i=e._zod.def,a=Ns(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=Ns(i.right,t,{...r,path:[...r.path,`allOf`,1]}),s=e=>`allOf`in e&&Object.keys(e).length===1,c=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]];n.allOf=c,t.intersections.push(c)},xc=(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)=>Ns(e,t,{...r,path:[...r.path,o,n]})),l=a.rest?Ns(a.rest,t,{...r,path:[...r.path,s,...t.target===`openapi-3.0`?[a.items.length]:[]]}):null,u=a.items.length;for(;u>0;){let e=a.items[u-1];if(!(t.io===`input`?_c(e)!==void 0:e._zod.optout===`optional`))break;u--}let d=a.items.length,f=!a.rest;t.target===`draft-2020-12`?(i.prefixItems=c,f?i.items=!1:l&&(i.items=l),u>0&&(i.minItems=u),f&&(i.maxItems=d)):t.target===`openapi-3.0`?(i.items={anyOf:c},l&&i.items.anyOf.push(l),u>0&&(i.minItems=u),f&&(i.maxItems=d)):(i.items=c,f?i.additionalItems=!1:l&&(i.additionalItems=l),u>0&&(i.minItems=u),f&&(i.maxItems=d));let{minimum:p,maximum:m}=rc(e);typeof p==`number`&&(i.minItems=p),typeof m==`number`&&(i.maxItems=m)};function Sc(e,t,n){if(t.$ref){if(n.has(t))return t;n.add(t);let r=e.get(t)?.def;if(!r)return t;let i=Sc(e,r,n);return i===r?t:i}for(let r of[`anyOf`,`oneOf`]){let i=t[r];if(!Array.isArray(i))continue;let a=i.map(t=>Sc(e,t,n));a.some((e,t)=>e!==i[t])&&(t={...t,[r]:a})}let r=Array.isArray(t.type)?t.type:[t.type],i=!r.includes(`string`)&&r.some(e=>e===`number`||e===`integer`),a=t.enum??(t.const===void 0?void 0:[t.const]);if(!i&&!a?.some(e=>typeof e==`number`))return t;let{minimum:o,maximum:s,exclusiveMinimum:c,exclusiveMaximum:l,multipleOf:u,format:d,id:f,...p}=t;return p.enum?p.enum=p.enum.map(e=>typeof e==`number`?String(e):e):typeof p.const==`number`&&(p.const=String(p.const)),i&&(p.type=`string`,a||(p.pattern=(r.includes(`number`)?Jr:qr).source)),p}let Cc=/* @__PURE__ */ new WeakMap;function wc(e){let t=/* @__PURE__ */ new Map;for(let n of e.seen.values())n.def&&!t.has(n.schema)&&t.set(n.schema,n);let n=/* @__PURE__ */ new Map;for(let r of Cc.get(e)??[]){let i=e.seen.get(r),a=(i?.def??i?.schema)?.propertyNames;if(!a||a===!0||n.has(a))continue;let o=Sc(t,a,/* @__PURE__ */ new Set);o!==a&&n.set(a,o)}if(n.size)for(let t of e.seen.values())for(let e of[t.schema,t.def]){let t=e&&n.get(e.propertyNames);t&&(e.propertyNames=t)}}let Tc=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`;let o=a.keyType,s=rc(o).patterns;if(a.mode===`loose`&&s&&s.size>0){let e=Ns(a.valueType,t,{...r,path:[...r.path,`patternProperties`,`*`]});i.patternProperties={};for(let t of s)Ft(i.patternProperties,oc(t).source,e)}else{if(t.target===`draft-07`||t.target===`draft-2020-12`){i.propertyNames=Ns(a.keyType,t,{...r,path:[...r.path,`propertyNames`]});let n=Cc.get(t);n||(n=[],Cc.set(t,n),t.deferred.push(()=>wc(t))),n.push(e)}i.additionalProperties=Ns(a.valueType,t,{...r,path:[...r.path,`additionalProperties`]})}let c=o._zod.values,l=t.io===`input`&&_c(a.valueType)!==void 0;if(c&&!a.partial&&!l){let e=[...c].filter(e=>typeof e==`string`||typeof e==`number`);e.length>0&&(i.required=e.map(String))}},Ec=(e,t,n,r)=>{let i=e._zod.def,a=Ns(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`}]},Dc=(e,t,n,r)=>{let i=e._zod.def;Ns(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Oc=Symbol();function kc(e,t,n,r,i){let a=!1,o=JSON.stringify(e,(e,t)=>typeof t==`bigint`?(a=!0,null):t);return a?(Ms(t,n,r,i,`BigInt defaults cannot be represented in JSON Schema`),Oc):JSON.parse(o)}let Ac=(e,t,n,r)=>{let i=e._zod.def;Ns(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o=kc(i.defaultValue,e,t,n,r);o!==Oc&&(n.default=o)},jc=(e,t,n,r)=>{let i=e._zod.def;Ns(i.innerType,t,r);let a=t.seen.get(e);if(a.ref=i.innerType,t.io!==`input`)return;let o=kc(i.defaultValue,e,t,n,r);o!==Oc&&(n._prefault=o)},Mc=(e,t,n,r)=>{let i=e._zod.def;Ns(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{Ms(e,t,n,r,`Dynamic catch values are not supported in JSON Schema`);return}n.default=o},Nc=(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;Ns(o,t,r);let s=t.seen.get(e);s.ref=o},Pc=(e,t,n,r)=>{let i=e._zod.def;Ns(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},Fc=(e,t,n,r)=>{let i=e._zod.def;Ns(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Ic=(e,t,n,r)=>{let i=e._zod.innerType;Ns(i,t,r);let a=t.seen.get(e);a.ref=i},Lc=/* @__PURE__ */ new WeakSet([Object.prototype,Error.prototype]);function Rc(e,t,n){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){let e=n(this);return Object.defineProperty(this,t,{value:e,configurable:!0,writable:!0}),e},set(e){Object.defineProperty(this,t,{value:e,configurable:!0,writable:!0})}})}let zc=/*@__PURE__*/ D(`ZodError`,(e,t)=>{Zn.init(e,t),e.name=`ZodError`;let n=Object.getPrototypeOf(e);Lc.has(n)||(Lc.add(n),Rc(n,`format`,e=>t=>er(e,t)),Rc(n,`flatten`,e=>t=>$n(e,t)),Rc(n,`addIssue`,e=>t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,Dt,2)}),Rc(n,`addIssues`,e=>t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,Dt,2)}),Object.defineProperty(n,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))},void 0,{Parent:Error}),Bc=/* @__PURE__ */ nr(zc),Vc=/* @__PURE__ */ rr(zc),Hc=/* @__PURE__ */ ir(zc),Uc=/* @__PURE__ */ or(zc),Wc=/* @__PURE__ */ fr(zc),Gc=/* @__PURE__ */ pr(zc),Kc=/* @__PURE__ */ mr(zc),qc=/* @__PURE__ */ hr(zc),Jc=/* @__PURE__ */ gr(zc),Yc=/* @__PURE__ */ _r(zc),Xc=/* @__PURE__ */ vr(zc),Zc=/* @__PURE__ */ yr(zc);function Qc(){Un.localeError||Wn(bo())}function $c(){Un.memoizer||Wn({memoizer:_o()})}let el=/*@__PURE__*/ D(`ZodType`,(e,t)=>(Qc(),yi.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(Ht(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(Cu(e,t))},superRefine(e,t){return this.check(wu(e,t))},overwrite(e){return this.check(/* @__PURE__ */ ys(e))},optional(){return nu(this)},exactOptional(){return iu(this)},nullable(){return ou(this)},nullish(){return nu(ou(this))},nonoptional(e){return fu(this,e)},array(){return j(this)},or(e){return Hl([this,e])},and(e){return Kl(this,e)},transform(e){return gu(this,eu(e))},default(e){return cu(this,e)},prefault(e){return uu(this,e)},catch(e){return mu(this,e)},pipe(e){return gu(this,e)},readonly(){return vu(this)},describe(e){let t=this.clone();return wo.add(t,{description:e}),t},meta(...e){if(e.length===0)return wo.get(this);let t=this.clone();return wo.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...t){return t.length===0?e(this):e(this,...t)},get"~standard"(){return Dn(this,`~standard`,{...Si(this),jsonSchema:{input:Gs(this,`input`),output:Gs(this,`output`)}})},set"~standard"(e){En(this,`~standard`,e)},parse:function e(t,n){return Bc(this,t,n,{callee:e})},parseAsync:async function e(t,n){return await Vc(this,t,n,{callee:e})},safeParse(e,t){return Hc(this,e,t)},async safeParseAsync(e,t){return Uc(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){En(this,`spa`,e)},validate(e,t){return lr(this,e,t)},validateAsync(e,t){return dr(this,e,t)},encode:function e(t,n){return Wc(this,t,n,{callee:e})},decode:function e(t,n){return Gc(this,t,n,{callee:e})},encodeAsync:async function e(t,n){return await Kc(this,t,n,{callee:e})},decodeAsync:async function e(t,n){return await qc(this,t,n,{callee:e})},safeEncode(e,t){return Jc(this,e,t)},safeDecode(e,t){return Yc(this,e,t)},async safeEncodeAsync(e,t){return Xc(this,e,t)},async safeDecodeAsync(e,t){return Zc(this,e,t)},toJSONSchema(e){return Ws(this,{})(e)},get description(){return wo.get(this)?.description},get _def(){return this._zod.def}}),tl=/*@__PURE__*/ D(`_ZodString`,(e,t)=>{Ci.init(e,t),el.init(e,t),e._zod.processJSONSchema=(t,n,r)=>sc(e,t,n,r)},/*@__PURE__*/ On({format:e=>rc(e).format??null,minLength:e=>rc(e).minimum??null,maxLength:e=>rc(e).maximum??null},{regex(...e){return this.check(/* @__PURE__ */ ps(...e))},includes(...e){return this.check(/* @__PURE__ */ gs(...e))},startsWith(...e){return this.check(/* @__PURE__ */ _s(...e))},endsWith(...e){return this.check(/* @__PURE__ */ vs(...e))},min(...e){return this.check(/* @__PURE__ */ ds(...e))},max(...e){return this.check(/* @__PURE__ */ us(...e))},length(...e){return this.check(/* @__PURE__ */ fs(...e))},nonempty(...e){return this.check(/* @__PURE__ */ ds(1,...e))},lowercase(e){return this.check(/* @__PURE__ */ ms(e))},uppercase(e){return this.check(/* @__PURE__ */ hs(e))},trim(){return this.check(/* @__PURE__ */ xs())},normalize(...e){return this.check(/* @__PURE__ */ bs(...e))},toLowerCase(){return this.check(/* @__PURE__ */ Ss())},toUpperCase(){return this.check(/* @__PURE__ */ Cs())},slugify(){return this.check(/* @__PURE__ */ ws())}})),nl=/*@__PURE__*/ D(`ZodString`,(e,t)=>{Ci.init(e,t),tl.init(e,t)},{email(e){return this.check(/* @__PURE__ */ Do(cl,e))},url(e){return this.check(/* @__PURE__ */ No(fl,e))},jwt(e){return this.check(/* @__PURE__ */ Jo(Ol,e))},emoji(e){return this.check(/* @__PURE__ */ Po(ml,e))},guid(e){return this.check(/* @__PURE__ */ Oo(ll,e))},uuid(e){return this.check(/* @__PURE__ */ ko(ul,e))},uuidv4(e){return this.check(/* @__PURE__ */ Ao(ul,e))},uuidv6(e){return this.check(/* @__PURE__ */ jo(ul,e))},uuidv7(e){return this.check(/* @__PURE__ */ Mo(ul,e))},nanoid(e){return this.check(/* @__PURE__ */ Fo(hl,e))},cuid(e){return this.check(/* @__PURE__ */ Io(gl,e))},cuid2(e){return this.check(/* @__PURE__ */ Lo(_l,e))},ulid(e){return this.check(/* @__PURE__ */ Ro(vl,e))},base64(e){return this.check(/* @__PURE__ */ Go(Tl,e))},base64url(e){return this.check(/* @__PURE__ */ Ko(El,e))},xid(e){return this.check(/* @__PURE__ */ zo(yl,e))},ksuid(e){return this.check(/* @__PURE__ */ Bo(bl,e))},ipv4(e){return this.check(/* @__PURE__ */ Vo(xl,e))},ipv6(e){return this.check(/* @__PURE__ */ Ho(Sl,e))},cidrv4(e){return this.check(/* @__PURE__ */ Uo(Cl,e))},cidrv6(e){return this.check(/* @__PURE__ */ Wo(wl,e))},e164(e){return this.check(/* @__PURE__ */ qo(Dl,e))},datetime(e){return this.check(/* @__PURE__ */ Yo(il,e))},date(e){return this.check(/* @__PURE__ */ Xo(al,e))},time(e){return this.check(/* @__PURE__ */ Zo(ol,e))},duration(e){return this.check(/* @__PURE__ */ Qo(sl,e))}});function O(e){return/* @__PURE__ */ Eo(nl,e)}let rl=/*@__PURE__*/ D(`ZodStringFormat`,(e,t)=>{wi.init(e,t),tl.init(e,t)}),il=/*@__PURE__*/ D(`ZodISODateTime`,(e,t)=>{Ui.init(e,t),rl.init(e,t)}),al=/*@__PURE__*/ D(`ZodISODate`,(e,t)=>{Wi.init(e,t),rl.init(e,t)}),ol=/*@__PURE__*/ D(`ZodISOTime`,(e,t)=>{Gi.init(e,t),rl.init(e,t)}),sl=/*@__PURE__*/ D(`ZodISODuration`,(e,t)=>{Ki.init(e,t),rl.init(e,t)}),cl=/*@__PURE__*/ D(`ZodEmail`,(e,t)=>{Di.init(e,t),rl.init(e,t)}),ll=/*@__PURE__*/ D(`ZodGUID`,(e,t)=>{Ti.init(e,t),rl.init(e,t)}),ul=/*@__PURE__*/ D(`ZodUUID`,(e,t)=>{Ei.init(e,t),rl.init(e,t)});function dl(e){return/* @__PURE__ */ ko(ul,e)}let fl=/*@__PURE__*/ D(`ZodURL`,(e,t)=>{Fi.init(e,t),rl.init(e,t)});function pl(e){return/* @__PURE__ */ No(fl,e)}let ml=/*@__PURE__*/ D(`ZodEmoji`,(e,t)=>{Ii.init(e,t),rl.init(e,t)}),hl=/*@__PURE__*/ D(`ZodNanoID`,(e,t)=>{Li.init(e,t),rl.init(e,t)}),gl=/*@__PURE__*/ D(`ZodCUID`,(e,t)=>{Ri.init(e,t),rl.init(e,t)}),_l=/*@__PURE__*/ D(`ZodCUID2`,(e,t)=>{zi.init(e,t),rl.init(e,t)}),vl=/*@__PURE__*/ D(`ZodULID`,(e,t)=>{Bi.init(e,t),rl.init(e,t)}),yl=/*@__PURE__*/ D(`ZodXID`,(e,t)=>{Vi.init(e,t),rl.init(e,t)}),bl=/*@__PURE__*/ D(`ZodKSUID`,(e,t)=>{Hi.init(e,t),rl.init(e,t)}),xl=/*@__PURE__*/ D(`ZodIPv4`,(e,t)=>{qi.init(e,t),rl.init(e,t)}),Sl=/*@__PURE__*/ D(`ZodIPv6`,(e,t)=>{Xi.init(e,t),rl.init(e,t)}),Cl=/*@__PURE__*/ D(`ZodCIDRv4`,(e,t)=>{Zi.init(e,t),rl.init(e,t)}),wl=/*@__PURE__*/ D(`ZodCIDRv6`,(e,t)=>{$i.init(e,t),rl.init(e,t)}),Tl=/*@__PURE__*/ D(`ZodBase64`,(e,t)=>{na.init(e,t),rl.init(e,t)}),El=/*@__PURE__*/ D(`ZodBase64URL`,(e,t)=>{aa.init(e,t),rl.init(e,t)}),Dl=/*@__PURE__*/ D(`ZodE164`,(e,t)=>{oa.init(e,t),rl.init(e,t)}),Ol=/*@__PURE__*/ D(`ZodJWT`,(e,t)=>{ca.init(e,t),rl.init(e,t)}),kl=/*@__PURE__*/ D(`ZodNumber`,(e,t)=>{la.init(e,t),el.init(e,t),e._zod.processJSONSchema=(t,n,r)=>cc(e,t,n,r),e.isFinite=!0},/*@__PURE__*/ On({minValue:e=>{let{minimum:t,exclusiveMinimum:n}=rc(e);return Math.max(t??-1/0,n??-1/0)},maxValue:e=>{let{maximum:t,exclusiveMaximum:n}=rc(e);return Math.min(t??1/0,n??1/0)},isInt:e=>{let{isInt:t,multipleOf:n}=rc(e);return!!t||!!n?.some(Number.isSafeInteger)},format:e=>rc(e).format??null},{gt(e,t){return this.check(/* @__PURE__ */ ss(e,t))},gte(e,t){return this.check(/* @__PURE__ */ cs(e,t))},min(e,t){return this.check(/* @__PURE__ */ cs(e,t))},lt(e,t){return this.check(/* @__PURE__ */ as(e,t))},lte(e,t){return this.check(/* @__PURE__ */ os(e,t))},max(e,t){return this.check(/* @__PURE__ */ os(e,t))},int(e){return this.check(jl(e))},safe(e){return this.check(jl(e))},positive(e){return this.check(/* @__PURE__ */ ss(0,e))},nonnegative(e){return this.check(/* @__PURE__ */ cs(0,e))},negative(e){return this.check(/* @__PURE__ */ as(0,e))},nonpositive(e){return this.check(/* @__PURE__ */ os(0,e))},multipleOf(e,t){return this.check(/* @__PURE__ */ ls(e,t))},step(e,t){return this.check(/* @__PURE__ */ ls(e,t))},finite(){return this}}));function k(e){return/* @__PURE__ */ $o(kl,e)}let Al=/*@__PURE__*/ D(`ZodNumberFormat`,(e,t)=>{ua.init(e,t),kl.init(e,t)});function jl(e){return/* @__PURE__ */ es(Al,e)}let Ml=/*@__PURE__*/ D(`ZodBoolean`,(e,t)=>{da.init(e,t),el.init(e,t),e._zod.processJSONSchema=(t,n,r)=>lc(e,t,n,r)});function A(e){return/* @__PURE__ */ ts(Ml,e)}let Nl=/*@__PURE__*/ D(`ZodNull`,(e,t)=>{fa.init(e,t),el.init(e,t),e._zod.processJSONSchema=(t,n,r)=>uc(e,t,n,r)});function Pl(e){return/* @__PURE__ */ ns(Nl,e)}let Fl=/*@__PURE__*/ D(`ZodUnknown`,(e,t)=>{pa.init(e,t),el.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function Il(){return/* @__PURE__ */ rs(Fl)}let Ll=/*@__PURE__*/ D(`ZodNever`,(e,t)=>{ma.init(e,t),el.init(e,t),e._zod.processJSONSchema=(t,n,r)=>dc(e,t,n,r)});function Rl(e){return/* @__PURE__ */ is(Ll,e)}let zl=/*@__PURE__*/ D(`ZodArray`,(e,t)=>{$c(),va.init(e,t),el.init(e,t),e._zod.processJSONSchema=(t,n,r)=>gc(e,t,n,r),e.element=t.element},{min(e,t){return this.check(/* @__PURE__ */ ds(e,t))},nonempty(e){return this.check(/* @__PURE__ */ ds(1,e))},max(e,t){return this.check(/* @__PURE__ */ us(e,t))},length(e,t){return this.check(/* @__PURE__ */ fs(e,t))},unwrap(){return this.element}});function j(e,t){return/* @__PURE__ */ Ts(zl,e,t)}let Bl=/*@__PURE__*/ D(`ZodObject`,(e,t)=>{$c(),wa.init(e,t),el.init(e,t),e._zod.processJSONSchema=(t,n,r)=>vc(e,t,n,r),Pn(e,`shape`,e=>e._zod.def.shape,!1)},{keyof(){return P(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(Ht(this._zod.def,{catchall:e}))},passthrough(){return this.clone(Ht(this._zod.def,{catchall:Il()}))},loose(){return this.clone(Ht(this._zod.def,{catchall:Il()}))},strict(){return this.clone(Ht(this._zod.def,{catchall:Rl()}))},strip(){return this.clone(Ht(this._zod.def,{catchall:void 0}))},extend(e){return sn(this,e)},safeExtend(e){return ln(this,e)},merge(e){return un(this,e)},pick(e){return rn(this,e)},omit(e){return on(this,e)},partial(...e){return dn(tu,this,e[0])},exactPartial(...e){return dn(ru,this,e[0],`exactPartial`)},required(...e){return fn(du,this,e[0])}});function M(e,t){let n={type:`object`,shape:e??{},...T(t)};return new Bl(n)}function N(e,t){return new Bl({type:`object`,shape:e,catchall:Rl(),...T(t)})}let Vl=/*@__PURE__*/ D(`ZodUnion`,(e,t)=>{Ea.init(e,t),el.init(e,t),e._zod.processJSONSchema=(t,n,r)=>yc(e,t,n,r),e.options=t.options});function Hl(e,t){return new Vl({type:`union`,options:e,...T(t)})}let Ul=/*@__PURE__*/ D(`ZodDiscriminatedUnion`,(e,t)=>{Vl.init(e,t),Oa.init(e,t)});function Wl(e,t,n){return new Ul({type:`union`,options:t,discriminator:e,...T(n)})}let Gl=/*@__PURE__*/ D(`ZodIntersection`,(e,t)=>{ka.init(e,t),el.init(e,t),e._zod.processJSONSchema=(t,n,r)=>bc(e,t,n,r)});function Kl(e,t){return new Gl({type:`intersection`,left:e,right:t})}let ql=/*@__PURE__*/ D(`ZodTuple`,(e,t)=>{$c(),Ma.init(e,t),el.init(e,t),e._zod.processJSONSchema=(t,n,r)=>xc(e,t,n,r)},{rest(e){return this.clone({...this._zod.def,rest:e})},partial(){let e=this._zod.def;if(e.checks?.length)throw Error(`.partial() cannot be used on tuple schemas containing refinements`);return this.clone({...e,items:e.items.map(e=>new tu({type:`optional`,innerType:e}))})}});function Jl(e,t,n){let r=t instanceof yi;return new ql({type:`tuple`,items:e,rest:r?t:null,...T(r?n:t)})}let Yl=/*@__PURE__*/ D(`ZodRecord`,(e,t)=>{$c(),Ia.init(e,t),el.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Tc(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType});function Xl(e,t,n){return!t||!t._zod?new Yl({type:`record`,keyType:O(),valueType:e,...T(t)}):new Yl({type:`record`,keyType:e,valueType:t,...T(n)})}let Zl=/*@__PURE__*/ D(`ZodEnum`,(e,t)=>{La.init(e,t),el.init(e,t),e._zod.processJSONSchema=(t,n,r)=>fc(e,t,n,r),e.enum=t.entries,e.options=[...e._zod.values];let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new Zl({...t,checks:[],...T(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new Zl({...t,checks:[],...T(r),entries:i})}});function P(e,t){let n=Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e;return new Zl({type:`enum`,entries:n,...T(t)})}let Ql=/*@__PURE__*/ D(`ZodLiteral`,(e,t)=>{Ra.init(e,t),el.init(e,t),e._zod.processJSONSchema=(t,n,r)=>pc(e,t,n,r),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function F(e,t){return new Ql({type:`literal`,values:Array.isArray(e)?e:[e],...T(t)})}let $l=/*@__PURE__*/ D(`ZodTransform`,(e,t)=>{$c(),za.init(e,t),el.init(e,t),e._zod.processJSONSchema=(t,n,r)=>hc(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new Hn(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(wn(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,`input`in t||(t.input=n.value),t.inst??=e,n.issues.push(wn(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n)):(n.value=i,n)}});function eu(e){return new $l({type:`transform`,transform:e})}let tu=/*@__PURE__*/ D(`ZodOptional`,(e,t)=>{Va.init(e,t),el.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Fc(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function nu(e){return new tu({type:`optional`,innerType:e})}let ru=/*@__PURE__*/ D(`ZodExactOptional`,(e,t)=>{Ha.init(e,t),el.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Fc(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function iu(e){return new ru({type:`optional`,innerType:e})}let au=/*@__PURE__*/ D(`ZodNullable`,(e,t)=>{Ua.init(e,t),el.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ec(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function ou(e){return new au({type:`nullable`,innerType:e})}let su=/*@__PURE__*/ D(`ZodDefault`,(e,t)=>{Wa.init(e,t),el.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ac(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function cu(e,t){return new su({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():Yt(t)}})}let lu=/*@__PURE__*/ D(`ZodPrefault`,(e,t)=>{Ka.init(e,t),el.init(e,t),e._zod.processJSONSchema=(t,n,r)=>jc(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function uu(e,t){return new lu({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():Yt(t)}})}let du=/*@__PURE__*/ D(`ZodNonOptional`,(e,t)=>{qa.init(e,t),el.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Dc(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function fu(e,t){return new du({type:`nonoptional`,innerType:e,...T(t)})}let pu=/*@__PURE__*/ D(`ZodCatch`,(e,t)=>{Xa.init(e,t),el.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Mc(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function mu(e,t){return new pu({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:Fn(t)})}let hu=/*@__PURE__*/ D(`ZodPipe`,(e,t)=>{Za.init(e,t),el.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Nc(e,t,n,r),e.in=t.in,e.out=t.out});function gu(e,t){return new hu({type:`pipe`,in:e,out:t})}let _u=/*@__PURE__*/ D(`ZodReadonly`,(e,t)=>{$a.init(e,t),el.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Pc(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function vu(e){return new _u({type:`readonly`,innerType:e})}let yu=/*@__PURE__*/ D(`ZodLazy`,(e,t)=>{to.init(e,t),el.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ic(e,t,n,r),e.unwrap=()=>e._zod.def.getter()});function bu(e){return new yu({type:`lazy`,getter:e})}let xu=/*@__PURE__*/ D(`ZodCustom`,(e,t)=>{no.init(e,t),el.init(e,t),e._zod.processJSONSchema=(t,n,r)=>mc(e,t,n,r)});function Su(e,t){return/* @__PURE__ */ Es(xu,e??(()=>!0),t)}function Cu(e,t={}){return/* @__PURE__ */ Ds(xu,e,t)}function wu(e,t){return/* @__PURE__ */ Os(e,t)}function Tu(e){return/* @__PURE__ */ Yo(il,e)}let Eu=M({source:O(),ref:O(),offset:k().int().nonnegative(),length:k().int().positive(),label:O(),appearance:P([`session`,`file`,`folder`,`skill`]).optional(),clipboardText:O(),invalid:A().optional()}),Du=M({text:O(),references:j(Eu)}).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 Ou(e){return typeof e==`string`?{text:e,references:[]}:{text:e.text,references:e.references.map(ju)}}function ku(e){if(typeof e==`string`)return Ou(e);let t=Du.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 Au(e,t){return{text:e,references:t.map(ju)}}function ju(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 Mu=`dsh.conversation`;function Nu(){return(0,f.defineStore)({init:()=>({draft:``,view:null,viewRequest:null}),persist:Mu,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 Pu(e){let t={text:``,references:[]};if(typeof localStorage>`u`)return t;try{let n=localStorage.getItem(`${Mu}.${e}`);if(n===null)return t;let r=JSON.parse(n);return typeof r!=`object`||!r||!(`draft`in r)?t:ku(r.draft)??t}catch{return t}}function Fu(e){if(typeof localStorage>`u`)return null;try{let t=localStorage.getItem(`${Mu}.${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 Iu(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 Lu(e){let t=e.replace(/[/\\]+$/,``),n=Math.max(t.lastIndexOf(`/`),t.lastIndexOf(`\\`));return t.slice(n+1)}function Ru(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 zu=`conversation`,Bu=`描述你的任务以生成计划`,Vu=`describe your task to generate plan`,Hu={"shortcut.newline":`换行`,"shortcut.complementary":`使用互补的 Queue/Steer 方式`,"shortcut.slash":`打开命令菜单`,"shortcut.mention":`打开引用菜单`,"hint.plan":Bu,"hint.goal":`输入目标,智能体将持续执行`,"hint.goal.active":`当前目标进行中。可输入 edit 修改 / pause 暂停 / resume 继续 / clear 清除`,"placeholder.plan":Bu,"placeholder.default":`发消息或创建任务, / 调用指令, @ 文件或对话`,"placeholder.unavailable":`会话不可用`,"placeholder.parentOffline":`父会话已离线,无法继续发送;仍可停止当前运行`,"placeholder.hero":`描述你想要构建的内容, / 调用指令, @ 文件或对话`,"placeholder.workspace":`选择一个工作区开始`,"placeholder.preparing":`正在准备对话…`,"placeholder.steerQueue":`Cmd/Ctrl+Enter 插话发送全部排队消息`,"newSession.loadingModel":`模型加载中…`,"newSession.loadingHarness":`正在加载 Harness…`,"newSession.createFailedTitle":`无法创建新会话`,"newSession.createFailed.noHarness":`没有可用的 Harness,请检查设置后重试。`,"newSession.createFailed.workspaceRequired":`请先选择一个工作区再开始新会话。`,"newSession.createFailed.generic":`暂时无法创建新会话,请稍后重试。`,"newSession.retry":`重试`,"newSession.uploadUnavailable":`新会话准备完成后才能添加文件`,"input.commands":`添加文件或调用指令`,"input.commandsOnly":`调用指令`,"input.imagesAndCommands":`添加图片或调用指令`,"attachment.unavailable":`当前 Web 连接不支持附件上传。`,"input.file":`文件`,"input.stop":`停止生成`,"input.send":`发送消息`,"input.send.queue":`排队发送`,"input.send.steer":`插话发送`,"attachment.pending":`待发送附件`,"annotation.rail":`已附加的选中文字`,"annotation.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 后重试。`,"error.steerTurnChanged":`你要插话的这一轮已经结束或切换,草稿已保留。`,"error.remoteSteerUnavailable":`当前连接无法确认插话的目标轮次,草稿已保留。`,"queue.editFailed":`编辑失败:这条消息可能已经开始发送。`,"queue.removeFailed":`删除失败:这条消息可能已经开始发送。`,"queue.steerFailed":`插话发送失败,请重试。`,"queue.resumeFailed":`继续队列失败,请重试。`,"queue.remoteActionFailed":`远程队列操作未确认,请先查看队列和会话状态。`,"queue.remoteStartUnconfirmed":`消息已入队,启动尚未确认。请查看队列和会话,勿重发。`,"queue.remoteStale":`暂时无法刷新远程队列。`,"terminal.signal":`信号 {signal}`,"terminal.exitCode":`退出码 {code}`,"terminal.noExitCode":`未正常退出`,"terminal.running":`运行中`,"terminal.failed":`失败`,"terminal.done":`已完成`,"terminal.noOutput":`无输出`,"terminal.collapseAria":`收起输出`,"terminal.expandAria":`展开其余 {n} 行输出`,"terminal.expandRest":`… 其余 {n} 行`,"terminal.sendInput":`(发送输入)`,"terminal.session":`终端 {sessionId}`},Uu={"shortcut.newline":`New line`,"shortcut.complementary":`Use the complementary Queue / Steer action`,"shortcut.slash":`Open command menu`,"shortcut.mention":`Open reference menu`,"hint.plan":Vu,"hint.goal":`describe the objective for a long-running task`,"hint.goal.active":`goal active — edit / pause / resume / clear`,"placeholder.plan":Vu,"placeholder.default":`Message or run a task, / commands, @ files or sessions`,"placeholder.unavailable":`Session unavailable`,"placeholder.parentOffline":`Parent session offline; sending is unavailable but you can still stop the run`,"placeholder.hero":`Describe what you want to build, / commands, @ files or sessions`,"placeholder.workspace":`Choose a workspace to start`,"placeholder.preparing":`Preparing conversation…`,"placeholder.steerQueue":`Cmd/Ctrl+Enter steers all queued messages`,"newSession.loadingModel":`Loading models…`,"newSession.loadingHarness":`Loading Harness…`,"newSession.createFailedTitle":`Couldn’t start a new session`,"newSession.createFailed.noHarness":`No Harness is available. Check your settings and try again.`,"newSession.createFailed.workspaceRequired":`Choose a workspace before starting a new session.`,"newSession.createFailed.generic":`Unable to start a new session right now. Please try again.`,"newSession.retry":`Retry`,"newSession.uploadUnavailable":`Wait for the new session to finish loading before adding files`,"input.commands":`Add files or run commands`,"input.commandsOnly":`Run commands`,"input.imagesAndCommands":`Add images or run commands`,"attachment.unavailable":`Attachment uploads are unavailable on this Web connection.`,"input.file":`File`,"input.stop":`Stop generating`,"input.send":`Send message`,"input.send.queue":`Queue message`,"input.send.steer":`Steer message`,"attachment.pending":`Pending attachments`,"annotation.rail":`Selected text attached to this message`,"annotation.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 content that cannot be edited yet`,"queue.save":`Save queued message`,"queue.cancelEdit":`Cancel editing`,"queue.remove":`Remove queued message`,"queue.steer":`Steer queued message`,"queue.steer.unavailable":`Steering is available only while the agent is running`,"queue.resume":`Resume queue`,"queue.paused.interrupted":`Queue paused because you interrupted. Choose a message to resume.`,"queue.paused.unknown":`Outcome unknown. The queue is paused and will not retry automatically.`,"queue.paused.failed":`The previous turn did not finish normally. The queue is paused.`,"error.sessionInUse":`This session is already in use, possibly by another running DSH instance (such as dsh web or the desktop app). Quit other running DSH instances and try again.`,"error.steerTurnChanged":`The turn you tried to steer ended or changed. Your draft was kept.`,"error.remoteSteerUnavailable":`This connection cannot confirm the target turn for steering. Your draft was kept.`,"queue.editFailed":`Edit failed: this message may have already started sending.`,"queue.removeFailed":`Removal failed: this message may have already started sending.`,"queue.steerFailed":`Steering failed. Try again.`,"queue.resumeFailed":`Could not resume the queue. Try again.`,"queue.remoteActionFailed":`Remote queue action was not confirmed. Check the queue and chat.`,"queue.remoteStartUnconfirmed":`Message queued. Its start is unconfirmed. Check the queue and chat. Do not resend.`,"queue.remoteStale":`The remote queue could not be refreshed.`,"terminal.signal":`signal {signal}`,"terminal.exitCode":`exit code {code}`,"terminal.noExitCode":`no exit code`,"terminal.running":`Running`,"terminal.failed":`Failed`,"terminal.done":`Done`,"terminal.noOutput":`No output`,"terminal.collapseAria":`Collapse output`,"terminal.expandAria":`Expand the remaining {n} output lines`,"terminal.expandRest":`… {n} more lines`,"terminal.sendInput":`(send input)`,"terminal.session":`Terminal {sessionId}`},Wu=2048;async function Gu(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<=Wu&&e.size<=1048576)return e;let r=Math.min(1,Wu/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 Ku(e){return{kind:`image`,id:vt(),previewUrl:URL.createObjectURL(e),file:e}}function qu(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 Ju(){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 Yu=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`&&Zu(e.previewUrl);this.draftAttachments.clear(),this.uploadSessions.clear(),this.foregroundRetried.clear(),this.fileUploads.set({})},`conversation draft attachments`)}async send(e){let t=await this.scopedSession(`send`).prompt([{type:`text`,text:e}],`queue`);if(!t.ok)throw Error(`conversation.send failed: ${t.error.code}: ${t.error.message}`)}async sendSession(e,t,n,r,i){let a=n.length===0?void 0:this.requireSessions().retain(e.sessionId,{source:`controllerOperation`});try{let a=this.resolveDraftAttachments(n);if(a.length!==n.length)throw Error(`conversation.sendSession: one or more draft attachments are no longer available`);this.assertUploadsNotFailed(n);let o=a.map(e=>({upload:{subscribe:this.fileUploads.subscribe,getSnapshot:()=>this.fileUploads.getSnapshot()[e.id]},...e.kind===`image`?{type:`image`,value:{previewUrl:e.previewUrl,...e.file.name===``?{}:{name:e.file.name},...e.width===void 0?{}:{width:e.width},...e.height===void 0?{}:{height:e.height}}}:{type:`file`,value:{attachmentId:e.id,name:`file`in e?e.file.name:e.stored.name,bytes:`file`in e?e.file.size:e.stored.bytes}}})),s=async()=>(await this.serializeDraftAttachments(n)).attachments;if(e.getSnapshot().subagent!==null){let n=[...await s(),...t===``?[]:[{type:`text`,text:t}]];return(await e.prompt(n,r,i)).ok?{kind:`success`}:{kind:`error`}}let c,l=a.length===0?void 0:new Promise(e=>{c=e}),u=e.beginSubmission({mode:r,text:t,attachments:o,onRetire:t=>{this.settleSubmittedAttachments(e.sessionId,a,t),c?.(t)}}),d;try{await Ju(),d=[...await s(),...t===``?[]:[{type:`text`,text:t}]]}catch(e){throw u.abandon(),e}let f=await e.prompt(d,r,i,u.requestId);return!f.ok||l!==void 0&&(await l).reason!==`observed`?{kind:`error`}:f.value.queueStartUnconfirmed?{kind:`success`,text:this.ctx.locale.bind(zu)(`queue.remoteStartUnconfirmed`)}:{kind:`success`}}finally{a?.release()}}createDrafts(e,t){return t.map(t=>{if(Xu(t.type)){let n=Ku(t);return this.draftAttachments.set(n.id,n),qu(n),this.beginFileUpload(e,n),n}let n={kind:`file`,id:vt(),file:t};return this.draftAttachments.set(n.id,n),this.beginFileUpload(e,n),n})}restoreStagedDrafts(e,t){let n=[],r=[];for(let i of t){let t;if(i.kind===`image`&&i.imageFile!==void 0){let e=Ku(i.imageFile);qu(e),t=e}else t={kind:`file`,id:vt(),stored:i.file};this.draftAttachments.set(t.id,t),this.uploadSessions.set(t.id,e),n.push([t.id,{status:`ready`,receiptId:i.receiptId,file:i.file}]),r.push(t)}return n.length>0&&this.fileUploads.update(e=>{for(let[t,r]of n)e[t]=r}),r}retryFileUpload(e,t){let n=this.draftAttachments.get(t);n!==void 0&&(n.kind!==`file`||`file`in n)&&this.fileUploads.getSnapshot()[t]?.status===`error`&&this.beginFileUpload(e,n)}rebindDraftFiles(e,t){for(let n of t){let t=this.draftAttachments.get(n);t!==void 0&&(t.kind===`file`&&!(`file`in t)?(this.uploadSessions.delete(n),this.fileUploads.update(e=>{e[n]={status:`error`,message:this.ctx.locale.bind(zu)(`file.unavailable`),transport:!1}})):this.beginFileUpload(e,t))}}beginFileUpload(e,t){this.uploadSessions.set(t.id,e),this.fileUploadOperations.get(t.id)?.controller.abort();let n=new AbortController;this.fileUploads.update(e=>{e[t.id]={status:`uploading`,loaded:0,total:t.file.size}});let r,i=new Promise(e=>{r=e});this.fileUploadOperations.set(t.id,{controller:n,done:i}),this.pendingFileUploads.add(i),i.then(()=>{this.pendingFileUploads.delete(i)}),this.fileUploadQueue.push({run:async()=>{try{if(n.signal.aborted||this.fileUploadOperations.get(t.id)?.controller!==n)return;let r=t.file;if(t.kind===`image`&&(r.type===`image/jpeg`||r.type===`image/webp`)){let e=this.preparedPhotos.get(t);if(e===void 0&&(e=Gu(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`&&Zu(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)&&Zu(a.previewUrl)))}}assertUploadsNotFailed(e){if(e.some(e=>this.fileUploads.getSnapshot()[e]?.status===`error`))throw Error(this.ctx.locale.bind(zu)(`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(zu)(`file.retryOrRemove`)))):e.every(e=>r[e]?.status===`ready`)&&(i(),t())},i=this.fileUploads.subscribe(r);r()})}};function Xu(e){return e===`image/png`||e===`image/jpeg`||e===`image/webp`||e===`image/gif`}function Zu(e){e.startsWith(`blob:`)&&URL.revokeObjectURL(e)}var Qu=class{stores=/* @__PURE__ */ new Map;set(e,t){let n=this.storeFor(e);n.getSnapshot()?.reason!==t?.reason&&n.set(t)}storeFor(e){let t=this.stores.get(e);if(t!==void 0)return t;let n=(0,f.createSnapshotStore)(void 0);return this.stores.set(e,n),n}forget(e){this.stores.delete(e)}};function I(e,...t){let n=new URL(`https://lexical.dev/docs/error`),r=new URLSearchParams;r.append(`code`,e);for(let e of t)r.append(`v`,e);throw n.search=r.toString(),Error(`Minified Lexical error #${e}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}function $u(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 ed=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0,td=ed&&`documentMode`in document?document.documentMode:null,nd=ed&&/Mac|iPod|iPhone|iPad/.test(navigator.platform),rd=ed&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent),id=!(!ed||!(`InputEvent`in window)||td)&&`getTargetRanges`in new window.InputEvent(`input`),ad=ed&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,od=ed&&/Android/.test(navigator.userAgent),sd=ed&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent)&&!od,cd=ed&&/^(?=.*Chrome).*/i.test(navigator.userAgent),ld=ed&&od&&cd,ud=ed&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&nd&&!cd,dd=sd||ad||ud?`\xA0`:``,fd=rd?`\xA0`:dd,pd=`֑-߿יִ-﷽ﹰ-ﻼ`,md=`A-Za-zÀ-ÖØ-öø-ʸ̀-ࠀ-Ⰰ-︀--`;RegExp(`^[^`+md+`]*[`+pd+`]`),RegExp(`^[^`+pd+`]*[`+md+`]`);let hd={bold:1,capitalize:1024,code:16,highlight:128,italic:2,lowercase:256,strikethrough:4,subscript:32,superscript:64,underline:8,uppercase:512},gd={directionless:1,unmergeable:2},_d={center:2,end:6,justify:4,left:1,right:3,start:5},vd={2:`center`,6:`end`,4:`justify`,1:`left`,3:`right`,5:`start`},yd={normal:0,segmented:2,token:1},bd={0:`normal`,2:`segmented`,1:`token`},xd=`$config`;function Sd(){return Vv()._blockCursorElement}function Cd(e){return e!==null&&e.nodeType===1&&e.hasAttribute(`data-lexical-slot`)}var wd=class e{element;before;after;constructor(e,t,n){this.element=e,this.before=t||null,this.after=n||null}withBefore(t){return new e(this.element,t,this.after)}withAfter(t){return new e(this.element,this.before,t)}withElement(t){return this.element===t?this:new e(t,this.before,this.after)}insertChild(e){let t=this.getInsertionAnchor();return t!==null&&t.parentElement!==this.element&&I(357),this.element.insertBefore(e,t),this}removeChild(e){return e.parentElement!==this.element&&I(358),this.element.removeChild(e),this}replaceChild(e,t){return t.parentElement!==this.element&&I(359),this.element.replaceChild(e,t),this}getFirstChild(){let e=this.getFirstChildAnchor(),t=e?e.nextSibling:this.element.firstChild;return t===this.getInsertionAnchor()?null:t}getFirstChildAnchor(){return this.after}resolveLeafPosition(e,t,n){if(this.element===e)return t===e&&n===0?`before`:`after`;let r=Td(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=Td(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 Td(e,t){let n=t;for(;n!==null&&n.parentNode!==e;)n=n.parentNode;return n}var Ed=class e extends wd{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(;Cd(t);)e=t,t=t.nextSibling;let n=e?e.nextSibling:this.element.firstChild;return n!==null&&n===Sd()?n:e}getManagedLineBreak(){return this.element.__lexicalLineBreak||null}setManagedLineBreak(e){if(this.element.__lexicalLastChildKind=e,e===null)this.removeManagedLineBreak();else{let t=e===`decorator`&&(ud||ad||sd);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=wv().createElement(`br`);if(i.setAttribute(`data-lexical-managed-linebreak`,`true`),n.insertBefore(i,r),e){let e=wv().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=Sd(),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=Dd(t,n);i.push(r);let a=Dd(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 Dd(e,t){let n=[],r=t;for(;r!==e&&r!==null;r=r.parentNode){let e=0;for(let t=r.previousSibling;t!==null;t=t.previousSibling)e++;n.push(e)}return r!==e&&I(225),n.reverse()}let Od;try{Od=`0.49.0+prod.esm`}catch{}let kd=Od??`"<unknown>+source"`;var Ad=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 jd(e,t=1e3){return e instanceof Md?e.clone():e.size<t?new Map(e):new Md().init(new Map(e),void 0,e.size)}var Md=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 Nd(e,t,n,r,i,a){if(W(e)){let o=e.getFirstChild();for(;o!==null;){let e=o.__key;o.__parent===t&&((W(o)||my(o)&&o.__slots!==null)&&Nd(o,e,n,r,i,a),n.has(e)||a.delete(e),i.push(e)),o=o.getNextSibling()}}for(let o of my(e)&&e.__slots!==null?e.__slots.values():[]){let e=r.get(o);e!==void 0&&hy(e)&&e.__slotHost===t&&((W(e)||my(e)&&e.__slots!==null)&&Nd(e,o,n,r,i,a),n.has(o)||a.delete(o),i.push(o))}}let Pd=!1,Fd=0;function Id(e){Fd=e.timeStamp}function Ld(e,t,n){let r=e.nodeName===`BR`,i=t.__lexicalLineBreak;return i&&(e===i||r&&e.previousSibling===i)||r&&D_(e,n)!==void 0}function Rd(e,t,n){let r=_v(ov(n)),i=r&&Dv(r,n._rootElement),a=null,o=null;i!==null&&i.anchorNode===e&&(a=i.anchorOffset,o=i.focusOffset);let s=e.nodeValue;s!==null&&B_(t,s,a,o,!1)}function zd(e,t,n){if(V(e)){let t=e.anchor.getNode();if(t.is(n)&&e.format!==t.getFormat())return!1}return h_(t)&&n.isAttached()}function Bd(e,t,n){for(let r=e;r&&!ty(r);r=ev(r)){let e=D_(r,t);if(e!==void 0){let t=w_(e,n);if(t)return G(t)||!J(r)?void 0:[r,t]}}}function Vd(e,t,n){Pd=!0;let r=performance.now()-Fd>100;try{Cg(e,()=>{let i=H()||function(e){return e.read(`latest`,()=>{let e=H();return e===null?null:e.clone()})}(e),a=/* @__PURE__ */ new Map,o=e._editorState,s=e._blockCursorElement,c=!1,l=``;for(let n=0;n<t.length;n++){let u=t[n],d=u.type,f=u.target,p=Bd(f,e,o);if(!p)continue;let[m,h]=p;if(d===`characterData`)r&&B(h)&&h_(f)&&zd(i,f,h)&&Rd(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=T_(r),a=r.parentNode;if(!(a==null||r===s||i!==null||Ld(r,a,e)||e._slotsUsed&&J(r)&&r.hasAttribute(`data-lexical-slot`)||ty(r))){if(rd){let e=(J(r)?r.innerText:null)||r.nodeValue;e&&(l+=e)}a.removeChild(r)}}let n=u.removedNodes,r=n.length;if(r>0){let t=0;for(let i=0;i<r;i++){let r=n[i];(Ld(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`||Ld(n,i,e)||a.removeChild(n)}}n.takeRecords()}i!==null&&(c&&M_(i),rd&&Q_(e)&&i.insertRawText(l))})}finally{Pd=!1}}function Hd(e){let t=e._observer;t!==null&&Vd(e,t.takeRecords(),t)}function Ud(e){(function(e){Fd===0&&ov(e).addEventListener(`textInput`,Id,!0)})(e),e._observer=new MutationObserver((t,n)=>{Vd(e,t,n)})}var Wd=class{key;parse;unparse;isEqual;defaultValue;resetOnCopyNode;constructor(e,t){this.key=e,this.parse=t.parse.bind(t),this.unparse=(t.unparse||Qd).bind(t),this.isEqual=(t.isEqual||Object.is).bind(t),this.defaultValue=this.parse(void 0),this.resetOnCopyNode=t.resetOnCopyNode||!1}};function Gd(e,t){return new Wd(e,t)}function Kd(e){let t=/* @__PURE__ */ new Map,n=/* @__PURE__ */ new Set;for(let{ownNodeConfig:r}of cy(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 qd=/* @__PURE__ */ new Set([`__proto__`,`constructor`,`prototype`]);var Jd=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 Zd(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(qd.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=Zd(i)),this.size++),r.set(e,t)}updateFromUnknown(e,t){if(qd.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 Yd(e){let t=e.getWritable(),n=t.__state?t.__state.getWritable(t):new Jd(t,Xd(t));return t.__state=n,n}function Xd(e){return e.__state?e.__state.sharedNodeState:a_(Vv(),e.getType()).sharedNodeState}function Zd(e){if(e)for(let t in e)return e}function Qd(e){return e}function $d(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 ef(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 tf(e,t){let n=e.__state;return n&&n.node===e?n.getWritable(t):n}function nf(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&&$d(n,e,t)||t&&$d(n,t,e)||e&&ef(n,e,t)||t&&ef(n,t,e))}(c,l))}function rf(e,t){let n=e.mergeWithSibling(t),r=U()._normalizedNodes;return r.add(e.__key),r.add(t.__key),n}function af(e){let t,n,r=e;if(r.__text!==``||!r.isSimpleText()||r.isUnmergeable()){for(;(t=r.getPreviousSibling())!==null&&B(t)&&t.isSimpleText()&&!t.isUnmergeable();){if(t.__text!==``){if(nf(t,r)){r=rf(t,r);break}break}t.remove()}for(;(n=r.getNextSibling())!==null&&B(n)&&n.isSimpleText()&&!n.isUnmergeable();){if(n.__text!==``){if(nf(r,n)){r=rf(r,n);break}break}n.remove()}}else r.remove()}function of(e){return sf(e.anchor),sf(e.focus),e}function sf(e){for(;e.type===`element`;){let t=e.getNode(),n=e.offset,r,i;if(n===t.getChildrenSize()?(r=t.getChildAtIndex(n-1),i=!0):(r=t.getChildAtIndex(n),i=!1),B(r)){e.set(r.__key,i?r.getTextContentSize():0,`text`,!0);break}if(!W(r))break;e.set(r.__key,i?r.getChildrenSize():0,`element`,!0)}}let cf=Symbol.for(`@lexical/CachedTextSize`);function lf(e,t){return Cf.read(()=>{let n=0,r=e;for(let e=0;e<t&&r!==null;e++){let i=Sf.get(r);if(i===void 0&&I(345,r),W(i)){let a=wf.get(r);if(a!==void 0&&W(a)&&a.__parent!==i.__parent)n+=i.getTextContentSize();else{let e=Tf.get(r),t=e&&e.__lexicalTextContent;typeof t!=`string`&&I(346,i.getType()),n+=t.length}e<t-1&&!i.isInline()&&(n+=2)}else{let e=i[cf];e===void 0&&I(347,i.getType(),r),n+=e}r=i.__next}return n},{editor:L})}function uf(e){W(e)||e[cf]===void 0&&(e[cf]=B(e)?e.__text.length:e.getTextContentSize())}let df,L,ff,R=``,pf=null,mf=null,hf=null;function gf(){return{firstTextKey:hf,format:pf,style:mf}}function _f(e){e.firstTextKey!==null&&(pf=e.format,mf=e.style,hf=e.firstTextKey)}function vf(e){if(hf!==null)return;let t=e.__lexicalFirstTextKey;if(t===void 0&&I(348),t===null)return;let n=wf.get(t);B(n)&&(pf=n.getFormat(),mf=n.getStyle(),hf=t)}let yf,bf,xf,Sf,Cf,wf,Tf,Ef,Df,Of,kf=!1,Af=!1;function jf(e,t){let n=Sf.get(e),r=wf.has(e);if(t!==null){let n=ep(e);n.parentNode===t&&t.removeChild(n)}if(!r){if(L._keyToDOMMap.delete(e),W(n)){let e=dy(n,Sf);Mf(e,0,e.length-1,null)}if(n!==void 0){for(let e of Bf(n).values()){let t=Hf(e);jf(e,null),t!==null&&t.remove()}Y_(Df,ff,yf,n,`destroyed`)}}}function Mf(e,t,n,r){for(let i=t;i<=n;++i){let t=e[i];t!==void 0&&jf(t,r)}}function Nf(e,t){e.setProperty(`text-align`,t)}function Pf(e,t){let n=df.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 Ff(e,t){let n=e.style;t===0?Nf(n,``):t===1?Nf(n,`left`):t===2?Nf(n,`center`):t===3?Nf(n,`right`):t===4?Nf(n,`justify`):t===5?Nf(n,`start`):t===6&&Nf(n,`end`)}function If(e,t){let n=function(e){let t=e.__dir;if(t!==null)return t;if(kg(e))return null;let n=e.getParent();return n===null||uv(n)&&n.__dir===null?`auto`:null}(t);n===null?e.removeAttribute(`dir`):e.dir=n}function Lf(e){let t=wv().createElement(`div`);return t.setAttribute(`data-lexical-slot`,e),t.style.display=`none`,t}function Rf(e,t,n){t||e.contentEditable===`false`?ny(n,L):n.removeAttribute(`contenteditable`)}function zf(e,t,n){let r=R,i=gf();R=``;let a=``,o=G(e);for(let[r,i]of n){let n=Lf(r);Rf(t,o,n),t.appendChild(n),R=``;let s=gf();Wf(i,Uv(e,n,L)),_f(s),Vf(e,r,t,n),a+=R}return _f(i),R=r,a}function Bf(e){return my(e)&&e.__slots!==null?e.__slots:py}function Vf(e,t,n,r){let i=Of.$getSlotTargetElement(e,t,n,L);i!==null&&(r.parentElement!==i&&i.appendChild(r),r.style.display=``)}function Hf(e){let t=Tf.get(e);return t===void 0?null:t.parentElement}function Uf(e,t,n){let r=Bf(e),i=Bf(t);for(let[e,t]of r)if(!i.has(e)){let e=Hf(t);jf(t,null),e!==null&&e.remove()}let a=R,o=gf(),s=``,c=null,l=G(t);for(let[e,a]of i){let i=r.get(e),o=i===void 0?null:Hf(i);R=``;let u=gf();if(o===null){o=Lf(e);let r=null;for(let e of n.children)if(!e.hasAttribute(`data-lexical-slot`)){r=e;break}n.insertBefore(o,r),Wf(a,Uv(t,o,L))}else i===a?Yf(a,o):(i!==void 0&&jf(i,o),Wf(a,Uv(t,o,L)));if(_f(u),Rf(n,l,o),Vf(t,e,n,o),s+=R,o.parentElement===n){let e=c===null?n.firstChild:c.nextSibling;e!==o&&n.insertBefore(o,e),c=o}}return _f(o),R=a,s}function Wf(e,t){let n=wf.get(e);if(n===void 0&&I(60),t!==null){let r=Sf.get(e);if(r!==void 0){let i=Tf.get(e);if(i!==void 0){let a=hy(r)?r.__slotHost:null,o=hy(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),Yf(e,t.element)}}}let r=Of.$createDOM(n,L);if(function(e,t,n){let r=n._keyToDOMMap;E_(t,n,e),r.set(e,t)}(e,r,L),B(n)?r.setAttribute(`data-lexical-text`,`true`):G(n)&&(r.setAttribute(`data-lexical-decorator`,`true`),ey(r,{captureSelection:!0})),W(n)){let e=n.__indent,t=n.__size;If(r,n),e!==0&&Pf(r,e);let i=Bf(n),a=i.size>0?zf(n,r,i):``;if(t===0)r.__lexicalTextContent=a,r.__lexicalFirstTextKey=null,R+=a,i.size>0&&(r.__lexicalSlotTextLength=a.length);else{let e=R,o=t-1;if(Gf(dy(n,wf),n,0,o,Uv(n,r,L)),a!==``){let t=r.__lexicalTextContent||``;r.__lexicalTextContent=a+t,R=e+a+t}i.size>0&&(r.__lexicalSlotTextLength=a.length)}let o=n.__format;o!==0&&Ff(r,o),n.isInline()||Kf(null,n,r)}else{let t=n.getTextContent();if(G(n)){let t=n.decorate(L,df);t!==null&&Xf(e,t),r.contentEditable=`false`;let i=Bf(n);i.size>0&&zf(n,r,i)}R+=t}return t!==null&&t.insertChild(r),Of.$decorateDOM(n,null,r,L),uf(n),Y_(Df,ff,yf,n,`created`),r}function Gf(e,t,n,r,i){let a=R,o=gf();R=``,pf=null,mf=null,hf=null;let s=n;for(;s<=r;++s){let t=gf();Wf(e[s],i);let n=wf.get(e[s]);n!==null&&B(n)?pf===null&&(pf=n.getFormat(),mf=n.getStyle(),hf=n.__key):W(n)&&s<r&&!n.isInline()&&(R+=`
|
|
133
124
|
|
|
134
|
-
`),
|
|
125
|
+
`),_f(t)}let c=L._keyToDOMMap.get(t.__key);c===void 0&&I(349,t.__key),c.__lexicalTextContent=R,c.__lexicalFirstTextKey=hf,R=a+R,_f(o)}function Kf(e,t,n){let r=Uv(t,n,L),i=r.element.__lexicalLastChildKind??null,a=function(e,t){if(e){let n=e.__last;if(n){let e=t.get(n);if(e)return zg(e)?`line-break`:G(e)&&e.isInline()?`decorator`:null}return Bf(e).size>0?null:`empty`}return null}(t,wf);i!==a&&r.setManagedLineBreak(a)}function qf(e,t,n){var r;pf=null,mf=null,hf=null,function(e,t,n){let r=R,i=e.__size,a=t.__size;R=``;let o=n.element,s=L._keyToDOMMap.get(t.__key);s===void 0&&I(351,t.__key);let c=a-i;if(!kf&&Math.abs(c)<=1&&i>=4&&e.__first===t.__first&&(c!==0||!L._cloneNotNeeded.has(e.__key))){let i=s.__lexicalTextContent,l=Ef.get(e.__key);if(!kf&&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=wf.get(r);if(e===void 0)return null;r=e.__prev,a++}return a!==n||r!==null&&t.has(r)?null:i}(t,l);if(a!==null){let u=l.size;if(c===0){let e=lf(a,u),n=a,c=0;for(;n!==null&&c<u;){let e=wf.get(n);if(e===void 0)break;let t=gf();Yf(n,o),B(e)&&pf===null&&(pf=e.getFormat(),mf=e.getStyle(),hf=e.__key),_f(t),n=e.__next,c++}let d=``;for(n=a,c=0;n!==null&&c<u;){let e=wf.get(n);if(e===void 0)break;let t;if(W(e)){let r=L._keyToDOMMap.get(n),i=r&&r.__lexicalTextContent;typeof i!=`string`&&I(352,e.getType()),t=i}else t=e.getTextContent();d+=t,c<u-1&&W(e)&&!e.isInline()&&(d+=`
|
|
135
126
|
|
|
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,R=r+m,
|
|
127
|
+
`),n=e.__next,c++}let f=s.__lexicalSlotTextLength||0,p=f>0?i.slice(f):i,m=p.slice(0,p.length-e)+d;s.__lexicalTextContent=m,R=r+m,Jf(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=Sf.get(l);if(e===void 0)return!1;l=e.__prev}if(l===null)return!1;let u=wf.get(a),d=Sf.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=wf.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=Sf.get(p);p=e?e.__next:null}let h=new Set(m),g=new Set(f),_=[],v=0,y=0;for(;v<c&&y<o;)if(f[y]===m[v])_.push({key:f[y],kind:`reconcile`}),v++,y++;else if(g.has(m[v])){if(h.has(f[y]))return!1;_.push({key:f[y],kind:`create`,nextIndex:y}),y++}else _.push({key:m[v],kind:`destroy`}),v++;for(;v<c;)_.push({key:m[v++],kind:`destroy`});for(;y<o;)_.push({key:f[y],kind:`create`,nextIndex:y}),y++;let b=lf(l,c);for(let e of _){let t=gf();if(e.kind===`reconcile`)Yf(e.key,n.element);else if(e.kind===`destroy`)jf(e.key,n.element);else{let t=null;for(let n=e.nextIndex+1;n<o;n++){let e=L._keyToDOMMap.get(f[n]);if(e!==void 0){t=e;break}}Wf(e.key,n.withBefore(t??n.before))}if(e.kind!==`destroy`){let t=wf.get(e.key);t&&B(t)&&pf===null&&(pf=t.getFormat(),mf=t.getStyle(),hf=t.__key)}_f(t)}let x=``;for(let e=0;e<o;e++){let t=wf.get(f[e]);if(t===void 0)return!1;let n;if(W(t)){let r=L._keyToDOMMap.get(f[e]),i=r&&r.__lexicalTextContent;typeof i!=`string`&&I(350,t.getType()),n=i}else n=t.getTextContent();x+=n,e<o-1&&W(t)&&!t.isInline()&&(x+=`
|
|
137
128
|
|
|
138
|
-
`)}let
|
|
129
|
+
`)}let ee=r.__lexicalSlotTextLength||0,te=ee>0?i.slice(ee):i;return r.__lexicalTextContent=te.slice(0,te.length-b)+x,!0}(e,0,n,s,i,a,u,c)){let e=s.__lexicalTextContent;typeof e!=`string`&&I(353),R=r+e,Jf(t,s,l);return}}}if(c===0){let t=e.__first,n=0;for(;t!==null;){let e=wf.get(t);if(e===void 0)break;let r=kf||xf.has(t)||bf.has(t),i=gf();if(r)Yf(t,o);else{let n,r;if(W(e)){r=Tf.get(t);let i=r&&r.__lexicalTextContent;typeof i!=`string`&&I(354,e.getType()),n=i}else n=e.getTextContent();R+=n,r!==void 0&&vf(r)}B(e)?pf===null&&(pf=e.getFormat(),mf=e.getStyle(),hf=e.__key):W(e)&&n<a-1&&!e.isInline()&&(R+=`
|
|
139
130
|
|
|
140
|
-
`),
|
|
131
|
+
`),_f(i),t=e.__next,n++}s.__lexicalTextContent=R,s.__lexicalFirstTextKey=hf,R=r+R;return}}if(i===1&&a===1){let r=e.__first,i=t.__first;if(r===i)Yf(r,o);else{let e=ep(r),t=Wf(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}jf(r,null)}let a=wf.get(i);B(a)&&pf===null&&(pf=a.getFormat(),mf=a.getStyle(),hf=a.__key)}else{let r=dy(e,Sf),s=dy(t,wf);if(r.length!==i&&I(227),s.length!==a&&I(228),i===0)a!==0&&Gf(s,t,0,a-1,n);else if(a===0){if(i!==0){let e=n.after==null&&n.before==null&&Bf(t).size===0&&n.element.__lexicalLineBreak==null;Mf(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=gf();if(e===r)u=Zf(Yf(r,a.element)),d++,f++;else{if(l===void 0&&(l=Qf(n,f)),c===void 0)c=Qf(t,d);else if(!c.has(e)){d++,_f(i);continue}if(!l.has(e)){u=Zf(ep(e)),jf(e,a.element),d++,c.delete(e),_f(i);continue}if(c.has(r)){let e=$_(L,r);e!==u&&a.withBefore(u??a.before).insertChild(e),u=Zf(Yf(r,a.element)),d++,f++}else Wf(r,a.withBefore(u??a.before)),f++}let o=wf.get(r);o!==null&&B(o)?pf===null&&(pf=o.getFormat(),mf=o.getStyle(),hf=o.__key):W(o)&&f<=s&&!o.isInline()&&(R+=`
|
|
141
132
|
|
|
142
|
-
`),mu(i)}let p=d>o,m=f>s;if(p&&!m){let t=n[s+1],r=t===void 0?null:L.getElementByKey(t);Hu(n,e,f,s,a.withBefore(r??a.before))}else m&&!p&&ku(t,d,o,a.element)})(t,r,s,i,a,n)}s.__lexicalTextContent=R,s.__lexicalFirstTextKey=fu,R=r+R}(e,t,Bg(t,n,L)),sg(t)||(r=t,uu==null||uu===r.__textFormat||Du||r.setTextFormat(uu),function(e){du==null||du===e.__textStyle||Du||e.setTextStyle(du)}(t))}function Gu(e,t,n){let r=t.__lexicalFirstTextKey;if(r!=null){let t=e.__key,i=r;for(;i!==null;){let e=xu.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=xu.get(r);if(B(e))return uu=e.getFormat(),void(du=e.getStyle())}}t.__lexicalFirstTextKey=fu}function Ku(e,t){let n=yu.get(e),r=xu.get(e);n!==void 0&&r!==void 0||I(61);let i=Eu||vu.has(e)||_u.has(e),a=Xh(L,e);if(n===r&&!i){let e;if(W(n)){let t=a.__lexicalTextContent;typeof t!=`string`&&I(355,n.getType()),e=t,hu(a)}else e=n.getTextContent();return R+=e,a}if(n!==r&&i&&Kh(wu,lu,gu,r,`updated`),Tu.$updateDOM(r,n,a,L)){let n=Vu(e,null);return t===null&&I(62),t.replaceChild(n,a),Ou(e,null),n}if(W(n)){W(r)||I(334,e);let t=r.__indent;(Eu||t!==n.__indent)&&ju(a,t);let o=r.__format;(Eu||o!==n.__format)&&Mu(a,o);let s=i&&(Lu(r).size>0||Lu(n).size>0)?Bu(n,r,a):``;if(i){let e=R;if(Wu(n,r,a),Em(r)||r.isInline()||Uu(0,r,a),s!==``){let t=a.__lexicalTextContent||``;a.__lexicalTextContent=s+t,R=e+s+t,a.__lexicalSlotTextLength=s.length}else(Lu(r).size>0||Lu(n).size>0)&&(a.__lexicalSlotTextLength=0)}else{let e=a.__lexicalTextContent;typeof e!=`string`&&I(356,n.getType()),R+=e,hu(a)}if((Eu||r.__dir!==n.__dir||r.__parent!==n.__parent)&&(Nu(a,r),Em(r)&&!Eu))for(let e of r.getChildren())W(e)&&Nu(Xh(L,e.getKey()),e)}else{let t=r.getTextContent();if(G(r)){let t=r.decorate(L,cu);t!==null&&qu(e,t),i&&(Lu(r).size>0||Lu(n).size>0)&&Bu(n,r,a)}R+=t}if(!Du&&Em(r)){let e=r.getLatest();if(e.__cachedText!==R){let t=e.getWritable();t.__cachedText=R,r=t}}return Tu.$decorateDOM(r,n,a,L),su(r),a}function qu(e,t){let n=L._pendingDecorators,r=L._decorators;if(n===null){if(r[e]===t)return;n=Eh(L)}n[e]=t}function Ju(e){let t=e.nextSibling;return t!==null&&t===L._blockCursorElement&&(t=t.nextSibling),t}function Yu(e,t){let n=/* @__PURE__ */ new Set;for(let r=t;r<e.length;r++)n.add(e[r]);return n}function Xu(e,t,n,r,i,a){R=``,uu=null,du=null,fu=null,Eu=r===2,L=n,cu=n._config,Tu=n._config.dom||qm,lu=n._nodes,gu=L._listeners.mutation,_u=i,vu=a,yu=e._nodeMap,bu=e,xu=t._nodeMap,Du=t._readOnly,Su=kl(n._keyToDOMMap),Cu=function(){let e=/* @__PURE__ */ new Map,t=t=>{for(let n of t){let t=xu.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(_u.keys()),t(vu),e}();let o=/* @__PURE__ */ new Map;return wu=o,Ku(`root`,null),L=void 0,lu=void 0,_u=void 0,vu=void 0,yu=void 0,bu=void 0,xu=void 0,cu=void 0,Su=void 0,Cu=void 0,wu=void 0,Tu=qm,o}function Zu(e){let t=Su.get(e);return t===void 0&&I(75,e),t}function z(e){return{type:e}}let Qu=/* @__PURE__ */ z(`SELECTION_CHANGE_COMMAND`),$u=/* @__PURE__ */ z(`CLICK_COMMAND`),ed=/* @__PURE__ */ z(`BEFORE_INPUT_COMMAND`),td=/* @__PURE__ */ z(`INPUT_COMMAND`),nd=/* @__PURE__ */ z(`COMPOSITION_START_COMMAND`),rd=/* @__PURE__ */ z(`COMPOSITION_END_COMMAND`),id=/* @__PURE__ */ z(`DELETE_CHARACTER_COMMAND`),ad=/* @__PURE__ */ z(`INSERT_LINE_BREAK_COMMAND`),od=/* @__PURE__ */ z(`INSERT_PARAGRAPH_COMMAND`),sd=/* @__PURE__ */ z(`CONTROLLED_TEXT_INSERTION_COMMAND`),cd=/* @__PURE__ */ z(`PASTE_COMMAND`),ld=/* @__PURE__ */ z(`REMOVE_TEXT_COMMAND`),ud=/* @__PURE__ */ z(`DELETE_WORD_COMMAND`),dd=/* @__PURE__ */ z(`DELETE_LINE_COMMAND`),fd=/* @__PURE__ */ z(`FORMAT_TEXT_COMMAND`),pd=/* @__PURE__ */ z(`UNDO_COMMAND`),md=/* @__PURE__ */ z(`REDO_COMMAND`),hd=/* @__PURE__ */ z(`KEYDOWN_COMMAND`),gd=/* @__PURE__ */ z(`KEY_ARROW_RIGHT_COMMAND`),_d=/* @__PURE__ */ z(`MOVE_TO_END`),vd=/* @__PURE__ */ z(`KEY_ARROW_LEFT_COMMAND`),yd=/* @__PURE__ */ z(`MOVE_TO_START`),bd=/* @__PURE__ */ z(`KEY_ARROW_UP_COMMAND`),xd=/* @__PURE__ */ z(`KEY_ARROW_DOWN_COMMAND`),Sd=/* @__PURE__ */ z(`KEY_ENTER_COMMAND`),Cd=/* @__PURE__ */ z(`KEY_SPACE_COMMAND`),wd=/* @__PURE__ */ z(`KEY_BACKSPACE_COMMAND`),Td=/* @__PURE__ */ z(`KEY_ESCAPE_COMMAND`),Ed=/* @__PURE__ */ z(`KEY_DELETE_COMMAND`),Dd=/* @__PURE__ */ z(`KEY_TAB_COMMAND`),Od=/* @__PURE__ */ z(`DROP_COMMAND`),kd=/* @__PURE__ */ z(`DRAGSTART_COMMAND`),Ad=/* @__PURE__ */ z(`DRAGOVER_COMMAND`),jd=/* @__PURE__ */ z(`DRAGEND_COMMAND`),Md=/* @__PURE__ */ z(`COPY_COMMAND`),Nd=/* @__PURE__ */ z(`CUT_COMMAND`),Pd=/* @__PURE__ */ z(`SELECT_ALL_COMMAND`),Fd=/* @__PURE__ */ z(`CLEAR_EDITOR_COMMAND`),Id=/* @__PURE__ */ z(`CLEAR_HISTORY_COMMAND`),Ld=/* @__PURE__ */ z(`CAN_REDO_COMMAND`),Rd=/* @__PURE__ */ z(`CAN_UNDO_COMMAND`),zd=/* @__PURE__ */ z(`FOCUS_COMMAND`),Bd=/* @__PURE__ */ z(`BLUR_COMMAND`),Vd=/* @__PURE__ */ z(`KEY_MODIFIER_COMMAND`);function Hd(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 Ud(e,t,n,r){return e.addEventListener(t,n,r),e.removeEventListener.bind(e,t,n,r)}let Wd=Object.freeze({}),Gd=[[`keydown`,function(e,t){let n=t._inputState;n.lastKeyDownTimeStamp=e.timeStamp,n.lastKeyCode=e.key,e.key!==`Backspace`&&nf(n),!t.isComposing()&&q(t,hd,e)}],[`pointerdown`,function(e,t){let n=Ag(e),r=e.pointerType;jg(n)&&r!==`touch`&&r!==`pen`&&e.button===0&&bm(t,()=>{e_(n,t)||(t._inputState.isSelectionChangeFromMouseDown=!0)})}],[`compositionstart`,function(e,t){q(t,nd,e)}],[`compositionend`,function(e,t){let n=t._inputState;tl?n.compositionPhase=`ending-firefox`:rl||!al&&!cl?q(t,rd,e):(n.compositionPhase=`ending-safari`,n.compositionEndData=e.data)}],[`input`,function(e,t){e.stopPropagation();let n=t._inputState;nf(n),bm(t,()=>{af(e,t)||t.dispatchCommand(td,e)},{event:e}),n.unprocessedBeforeInputData=null}],[`click`,function(e,t){bm(t,()=>{let n=H(),r=mg(rg(t)),i=jp();if(r){if(V(n)){let e=n.anchor,t=e.getNode();e.type===`element`&&e.offset===0&&n.isCollapsed()&&!Em(t)&&Oh().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=wg(r,t._rootElement).anchorNode;(J(n)||fh(n))&&kh(Ap(i,r,t,e))}}if(tl&&r!==null&&r.rangeCount===0){let n=t._rootElement;if(n!==null&&e.target===n){let a=e.clientY,o=n.childNodes.length;for(let e=0;e<n.childNodes.length;e++){let t=n.childNodes[e];if(J(t)){let n=t.getBoundingClientRect();if(a<=(n.top+n.bottom)/2){o=e;break}}}r.setBaseAndExtent(n,o,n,o);let s=Ap(i,r,t,e);s===null?r.removeAllRanges():kh(s)}}q(t,$u,e)})}],[`cut`,Wd],[`copy`,Wd],[`dragstart`,Wd],[`dragover`,Wd],[`dragend`,Wd],[`paste`,Wd],[`focus`,Wd],[`blur`,Wd],[`drop`,Wd]];nl&&Gd.push([`beforeinput`,(e,t)=>function(e,t){let n=e.inputType;n===`deleteCompositionText`||tl&&Yh(t)||n!==`insertCompositionText`&&bm(t,()=>{af(e,t)||q(t,ed,e)},{event:e})}(e,t)]);let Kd=/* @__PURE__ */ new WeakMap,qd=/* @__PURE__ */ new WeakMap,Jd=Hd(e=>(e.addEventListener(`selectionchange`,hf),()=>e.removeEventListener(`selectionchange`,hf)));function Yd(e,t,n,r,i,a){let o=e.anchor,s=e.focus,c=o.getNode(),l=U(),u;if(a!==void 0)u=a;else{let e=mg(rg(l));u=e===null?null:wg(e,l._rootElement)}let d=u===null?null:u.anchorNode,f=o.key,p=l.getElementByKey(f),m=n.length;return f!==s.key||!B(c)||(!i&&(!nl||l._inputState.lastBeforeInputInsertTextTimeStamp<r+50)||c.isDirty()&&m<2||Mh(n))&&o.offset!==s.offset&&!c.isComposing()||dh(c)||c.isDirty()&&m>1||(i||!nl)&&p!==null&&!c.isComposing()&&d!==Hg(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=uh(t);return n===0?!t.canInsertTextBefore()||!r.canInsertTextBefore()&&!t.isComposing()||i||function(e){let t=e.getPreviousSibling();return(B(t)||W(t)&&t.isInline())&&!t.canInsertTextAfter()}(t):n===t.getTextContentSize()&&(!t.canInsertTextAfter()||!r.canInsertTextAfter()&&!t.isComposing()||i)}(e,c)}function Xd(e,t){return fh(e)&&e.nodeValue!==null&&t!==0&&t!==e.nodeValue.length}function Zd(e,t,n){let{anchorNode:r,anchorOffset:i,focusNode:a,focusOffset:o}=wg(e,t._rootElement),s=t._inputState;s.isSelectionChangeFromDOMUpdate&&(s.isSelectionChangeFromDOMUpdate=!1,Xd(r,i)&&Xd(a,o)&&!s.postDeleteSelectionToRestore)||bm(t,()=>{if(!n)return void kh(null);if(!oh(t,r,a))return;let c=H();if(s.postDeleteSelectionToRestore&&V(c)&&c.isCollapsed()){let e=c.anchor,t=s.postDeleteSelectionToRestore.anchor;(e.key===t.key&&e.offset===t.offset+1||e.offset===1&&t.getNode().is(e.getNode().getPreviousSibling()))&&(c=s.postDeleteSelectionToRestore.clone(),kh(c))}if(s.postDeleteSelectionToRestore=null,V(c)){let n=c.anchor,l=n.getNode();if(c.isCollapsed()){e.type===`Range`&&r===a&&(c.dirty=!0);let i=rg(t).event,o=i?i.timeStamp:performance.now(),{format:u,style:d,offset:f,key:p,timeStamp:m}=s.collapsedSelectionFormat,h=Oh(),g=!1===t.isComposing()&&h.getTextContent()===``;if(o<m+200&&n.offset===f&&n.key===p)Qd(c,u,d);else if(n.type===`text`)B(l)||I(141),$d(c,l);else if(n.type===`element`&&!g){W(l)||I(259);let e=n.getNode();e.isEmpty()?function(e,t){Qd(e,t.getTextFormat(),t.getTextStyle())}(c,e):Qd(c,c.format,``)}}else{let e=n.key,t=c.focus.key,r=c.getNodes(),a=r.length,s=c.isBackward(),l=s?o:i,u=s?i:o,d=s?t:e,f=s?e:t,p=2047,m=!1;for(let e=0;e<a;e++){let t=r[e],n=t.getTextContentSize();if(B(t)&&n!==0&&!(e===0&&t.__key===d&&l===n||e===a-1&&t.__key===f&&u===0)&&(m=!0,p&=t.getFormat(),p===0))break}c.format=m?p:0}}q(t,Qu)})}function Qd(e,t,n){e.format===t&&e.style===n||(e.format=t,e.style=n,e.dirty=!0)}function $d(e,t){Qd(e,t.getFormat(),t.getStyle())}function ef(e){if(!e.getTargetRanges)return null;let t=e.getTargetRanges();return t.length===0?null:t[0]}function tf(e){let{lastKeyCode:t}=U()._inputState;if(e==null||e.length<=1||t==null)return;let n=t.length===1?t:t===`Enter`?`
|
|
133
|
+
`),_f(i)}let p=d>o,m=f>s;if(p&&!m){let t=n[s+1],r=t===void 0?null:L.getElementByKey(t);Gf(n,e,f,s,a.withBefore(r??a.before))}else m&&!p&&Mf(t,d,o,a.element)})(t,r,s,i,a,n)}s.__lexicalTextContent=R,s.__lexicalFirstTextKey=hf,R=r+R}(e,t,Uv(t,n,L)),uv(t)||(r=t,pf==null||pf===r.__textFormat||Af||r.setTextFormat(pf),function(e){mf==null||mf===e.__textStyle||Af||e.setTextStyle(mf)}(t))}function Jf(e,t,n){let r=t.__lexicalFirstTextKey;if(r!=null){let t=e.__key,i=r;for(;i!==null;){let e=wf.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=wf.get(r);if(B(e))return pf=e.getFormat(),void(mf=e.getStyle())}}t.__lexicalFirstTextKey=hf}function Yf(e,t){let n=Sf.get(e),r=wf.get(e);n!==void 0&&r!==void 0||I(61);let i=kf||xf.has(e)||bf.has(e),a=$_(L,e);if(n===r&&!i){let e;if(W(n)){let t=a.__lexicalTextContent;typeof t!=`string`&&I(355,n.getType()),e=t,vf(a)}else e=n.getTextContent();return R+=e,a}if(n!==r&&i&&Y_(Df,ff,yf,r,`updated`),Of.$updateDOM(r,n,a,L)){let n=Wf(e,null);return t===null&&I(62),t.replaceChild(n,a),jf(e,null),n}if(W(n)){W(r)||I(334,e);let t=r.__indent;(kf||t!==n.__indent)&&Pf(a,t);let o=r.__format;(kf||o!==n.__format)&&Ff(a,o);let s=i&&(Bf(r).size>0||Bf(n).size>0)?Uf(n,r,a):``;if(i){let e=R;if(qf(n,r,a),kg(r)||r.isInline()||Kf(0,r,a),s!==``){let t=a.__lexicalTextContent||``;a.__lexicalTextContent=s+t,R=e+s+t,a.__lexicalSlotTextLength=s.length}else(Bf(r).size>0||Bf(n).size>0)&&(a.__lexicalSlotTextLength=0)}else{let e=a.__lexicalTextContent;typeof e!=`string`&&I(356,n.getType()),R+=e,vf(a)}if((kf||r.__dir!==n.__dir||r.__parent!==n.__parent)&&(If(a,r),kg(r)&&!kf))for(let e of r.getChildren())W(e)&&If($_(L,e.getKey()),e)}else{let t=r.getTextContent();if(G(r)){let t=r.decorate(L,df);t!==null&&Xf(e,t),i&&(Bf(r).size>0||Bf(n).size>0)&&Uf(n,r,a)}R+=t}if(!Af&&kg(r)){let e=r.getLatest();if(e.__cachedText!==R){let t=e.getWritable();t.__cachedText=R,r=t}}return Of.$decorateDOM(r,n,a,L),uf(r),a}function Xf(e,t){let n=L._pendingDecorators,r=L._decorators;if(n===null){if(r[e]===t)return;n=k_(L)}n[e]=t}function Zf(e){let t=e.nextSibling;return t!==null&&t===L._blockCursorElement&&(t=t.nextSibling),t}function Qf(e,t){let n=/* @__PURE__ */ new Set;for(let r=t;r<e.length;r++)n.add(e[r]);return n}function $f(e,t,n,r,i,a){R=``,pf=null,mf=null,hf=null,kf=r===2,L=n,df=n._config,Of=n._config.dom||Xg,ff=n._nodes,yf=L._listeners.mutation,bf=i,xf=a,Sf=e._nodeMap,Cf=e,wf=t._nodeMap,Af=t._readOnly,Tf=jd(n._keyToDOMMap),Ef=function(){let e=/* @__PURE__ */ new Map,t=t=>{for(let n of t){let t=wf.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(bf.keys()),t(xf),e}();let o=/* @__PURE__ */ new Map;return Df=o,Yf(`root`,null),L=void 0,ff=void 0,bf=void 0,xf=void 0,Sf=void 0,Cf=void 0,wf=void 0,df=void 0,Tf=void 0,Ef=void 0,Df=void 0,Of=Xg,o}function ep(e){let t=Tf.get(e);return t===void 0&&I(75,e),t}function z(e){return{type:e}}let tp=/* @__PURE__ */ z(`SELECTION_CHANGE_COMMAND`),np=/* @__PURE__ */ z(`CLICK_COMMAND`),rp=/* @__PURE__ */ z(`BEFORE_INPUT_COMMAND`),ip=/* @__PURE__ */ z(`INPUT_COMMAND`),ap=/* @__PURE__ */ z(`COMPOSITION_START_COMMAND`),op=/* @__PURE__ */ z(`COMPOSITION_END_COMMAND`),sp=/* @__PURE__ */ z(`DELETE_CHARACTER_COMMAND`),cp=/* @__PURE__ */ z(`INSERT_LINE_BREAK_COMMAND`),lp=/* @__PURE__ */ z(`INSERT_PARAGRAPH_COMMAND`),up=/* @__PURE__ */ z(`CONTROLLED_TEXT_INSERTION_COMMAND`),dp=/* @__PURE__ */ z(`PASTE_COMMAND`),fp=/* @__PURE__ */ z(`REMOVE_TEXT_COMMAND`),pp=/* @__PURE__ */ z(`DELETE_WORD_COMMAND`),mp=/* @__PURE__ */ z(`DELETE_LINE_COMMAND`),hp=/* @__PURE__ */ z(`FORMAT_TEXT_COMMAND`),gp=/* @__PURE__ */ z(`UNDO_COMMAND`),_p=/* @__PURE__ */ z(`REDO_COMMAND`),vp=/* @__PURE__ */ z(`KEYDOWN_COMMAND`),yp=/* @__PURE__ */ z(`KEY_ARROW_RIGHT_COMMAND`),bp=/* @__PURE__ */ z(`MOVE_TO_END`),xp=/* @__PURE__ */ z(`KEY_ARROW_LEFT_COMMAND`),Sp=/* @__PURE__ */ z(`MOVE_TO_START`),Cp=/* @__PURE__ */ z(`KEY_ARROW_UP_COMMAND`),wp=/* @__PURE__ */ z(`KEY_ARROW_DOWN_COMMAND`),Tp=/* @__PURE__ */ z(`KEY_ENTER_COMMAND`),Ep=/* @__PURE__ */ z(`KEY_SPACE_COMMAND`),Dp=/* @__PURE__ */ z(`KEY_BACKSPACE_COMMAND`),Op=/* @__PURE__ */ z(`KEY_ESCAPE_COMMAND`),kp=/* @__PURE__ */ z(`KEY_DELETE_COMMAND`),Ap=/* @__PURE__ */ z(`KEY_TAB_COMMAND`),jp=/* @__PURE__ */ z(`DROP_COMMAND`),Mp=/* @__PURE__ */ z(`DRAGSTART_COMMAND`),Np=/* @__PURE__ */ z(`DRAGOVER_COMMAND`),Pp=/* @__PURE__ */ z(`DRAGEND_COMMAND`),Fp=/* @__PURE__ */ z(`COPY_COMMAND`),Ip=/* @__PURE__ */ z(`CUT_COMMAND`),Lp=/* @__PURE__ */ z(`SELECT_ALL_COMMAND`),Rp=/* @__PURE__ */ z(`CLEAR_EDITOR_COMMAND`),zp=/* @__PURE__ */ z(`CLEAR_HISTORY_COMMAND`),Bp=/* @__PURE__ */ z(`CAN_REDO_COMMAND`),Vp=/* @__PURE__ */ z(`CAN_UNDO_COMMAND`),Hp=/* @__PURE__ */ z(`FOCUS_COMMAND`),Up=/* @__PURE__ */ z(`BLUR_COMMAND`),Wp=/* @__PURE__ */ z(`KEY_MODIFIER_COMMAND`);function Gp(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 Kp(e,t,n,r){return e.addEventListener(t,n,r),e.removeEventListener.bind(e,t,n,r)}let qp=Object.freeze({}),Jp=[[`keydown`,function(e,t){let n=t._inputState;n.lastKeyDownTimeStamp=e.timeStamp,n.lastKeyCode=e.key,e.key!==`Backspace`&&am(n),!t.isComposing()&&q(t,vp,e)}],[`pointerdown`,function(e,t){let n=Nv(e),r=e.pointerType;Pv(n)&&r!==`touch`&&r!==`pen`&&e.button===0&&Cg(t,()=>{ry(n,t)||(t._inputState.isSelectionChangeFromMouseDown=!0)})}],[`compositionstart`,function(e,t){q(t,ap,e)}],[`compositionend`,function(e,t){let n=t._inputState;rd?n.compositionPhase=`ending-firefox`:ad||!sd&&!ud?q(t,op,e):(n.compositionPhase=`ending-safari`,n.compositionEndData=e.data)}],[`input`,function(e,t){e.stopPropagation();let n=t._inputState;am(n),Cg(t,()=>{sm(e,t)||t.dispatchCommand(ip,e)},{event:e}),n.unprocessedBeforeInputData=null}],[`click`,function(e,t){Cg(t,()=>{let n=H(),r=_v(ov(t)),i=Ph();if(r){if(V(n)){let e=n.anchor,t=e.getNode();e.type===`element`&&e.offset===0&&n.isCollapsed()&&!kg(t)&&j_().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=Dv(r,t._rootElement).anchorNode;(J(n)||h_(n))&&M_(Nh(i,r,t,e))}}if(rd&&r!==null&&r.rangeCount===0){let n=t._rootElement;if(n!==null&&e.target===n){let a=e.clientY,o=n.childNodes.length;for(let e=0;e<n.childNodes.length;e++){let t=n.childNodes[e];if(J(t)){let n=t.getBoundingClientRect();if(a<=(n.top+n.bottom)/2){o=e;break}}}r.setBaseAndExtent(n,o,n,o);let s=Nh(i,r,t,e);s===null?r.removeAllRanges():M_(s)}}q(t,np,e)})}],[`cut`,qp],[`copy`,qp],[`dragstart`,qp],[`dragover`,qp],[`dragend`,qp],[`paste`,qp],[`focus`,qp],[`blur`,qp],[`drop`,qp]];id&&Jp.push([`beforeinput`,(e,t)=>function(e,t){let n=e.inputType;n===`deleteCompositionText`||rd&&Q_(t)||n!==`insertCompositionText`&&Cg(t,()=>{sm(e,t)||q(t,rp,e)},{event:e})}(e,t)]);let Yp=/* @__PURE__ */ new WeakMap,Xp=/* @__PURE__ */ new WeakMap,Zp=Gp(e=>(e.addEventListener(`selectionchange`,_m),()=>e.removeEventListener(`selectionchange`,_m)));function Qp(e,t,n,r,i,a){let o=e.anchor,s=e.focus,c=o.getNode(),l=U(),u;if(a!==void 0)u=a;else{let e=_v(ov(l));u=e===null?null:Dv(e,l._rootElement)}let d=u===null?null:u.anchorNode,f=o.key,p=l.getElementByKey(f),m=n.length;return f!==s.key||!B(c)||(!i&&(!id||l._inputState.lastBeforeInputInsertTextTimeStamp<r+50)||c.isDirty()&&m<2||F_(n))&&o.offset!==s.offset&&!c.isComposing()||m_(c)||c.isDirty()&&m>1||(i||!id)&&p!==null&&!c.isComposing()&&d!==Gv(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=p_(t);return n===0?!t.canInsertTextBefore()||!r.canInsertTextBefore()&&!t.isComposing()||i||function(e){let t=e.getPreviousSibling();return(B(t)||W(t)&&t.isInline())&&!t.canInsertTextAfter()}(t):n===t.getTextContentSize()&&(!t.canInsertTextAfter()||!r.canInsertTextAfter()&&!t.isComposing()||i)}(e,c)}function $p(e,t){return h_(e)&&e.nodeValue!==null&&t!==0&&t!==e.nodeValue.length}function em(e,t,n){let{anchorNode:r,anchorOffset:i,focusNode:a,focusOffset:o}=Dv(e,t._rootElement),s=t._inputState;s.isSelectionChangeFromDOMUpdate&&(s.isSelectionChangeFromDOMUpdate=!1,$p(r,i)&&$p(a,o)&&!s.postDeleteSelectionToRestore)||Cg(t,()=>{if(!n)return void M_(null);if(!l_(t,r,a))return;let c=H();if(s.postDeleteSelectionToRestore&&V(c)&&c.isCollapsed()){let e=c.anchor,t=s.postDeleteSelectionToRestore.anchor;(e.key===t.key&&e.offset===t.offset+1||e.offset===1&&t.getNode().is(e.getNode().getPreviousSibling()))&&(c=s.postDeleteSelectionToRestore.clone(),M_(c))}if(s.postDeleteSelectionToRestore=null,V(c)){let n=c.anchor,l=n.getNode();if(c.isCollapsed()){e.type===`Range`&&r===a&&(c.dirty=!0);let i=ov(t).event,o=i?i.timeStamp:performance.now(),{format:u,style:d,offset:f,key:p,timeStamp:m}=s.collapsedSelectionFormat,h=j_(),g=!1===t.isComposing()&&h.getTextContent()===``;if(o<m+200&&n.offset===f&&n.key===p)tm(c,u,d);else if(n.type===`text`)B(l)||I(141),nm(c,l);else if(n.type===`element`&&!g){W(l)||I(259);let e=n.getNode();e.isEmpty()?function(e,t){tm(e,t.getTextFormat(),t.getTextStyle())}(c,e):tm(c,c.format,``)}}else{let e=n.key,t=c.focus.key,r=c.getNodes(),a=r.length,s=c.isBackward(),l=s?o:i,u=s?i:o,d=s?t:e,f=s?e:t,p=2047,m=!1;for(let e=0;e<a;e++){let t=r[e],n=t.getTextContentSize();if(B(t)&&n!==0&&!(e===0&&t.__key===d&&l===n||e===a-1&&t.__key===f&&u===0)&&(m=!0,p&=t.getFormat(),p===0))break}c.format=m?p:0}}q(t,tp)})}function tm(e,t,n){e.format===t&&e.style===n||(e.format=t,e.style=n,e.dirty=!0)}function nm(e,t){tm(e,t.getFormat(),t.getStyle())}function rm(e){if(!e.getTargetRanges)return null;let t=e.getTargetRanges();return t.length===0?null:t[0]}function im(e){let{lastKeyCode:t}=U()._inputState;if(e==null||e.length<=1||t==null)return;let n=t.length===1?t:t===`Enter`?`
|
|
143
134
|
`:t===`Tab`?` `:null;if(!n)return;let r=H();if(!V(r)||!r.isCollapsed())return;let i=r.anchor.getNode();if(!B(i))return;let{offset:a}=r.anchor;if(i.getTextContentSize()===a){let e=i.getNextSibling();if(n===`
|
|
144
|
-
`){if(
|
|
145
|
-
`)e.preventDefault(),q(r,
|
|
135
|
+
`){if(zg(e))e.selectEnd();else if(!e){let e=uy(i,kh),t=e&&e.getNextSibling();W(t)&&t.selectStart()}}else n===` `?th(e)&&e.selectEnd():B(e)&&e.getTextContent()[0]===n&&e.select(1,1)}else i.getTextContent()[a]===n&&i.select(a+1,a+1)}function am(e){e.isInsertTextAfterHandledSelectionCommand=!1,e.handledSelectionCommandTimeoutId!==null&&(clearTimeout(e.handledSelectionCommandTimeoutId),e.handledSelectionCommandTimeoutId=null)}function om(e){am(e),e.isInsertTextAfterHandledSelectionCommand=!0,e.handledSelectionCommandTimeoutId=setTimeout(()=>am(e),0)}function sm(e,t){let n=Nv(e);if(J(n)&&ry(n,t))return!0;let r=t.getRootElement();if(r===null)return!1;let i=Mv(r.ownerDocument);return i!==null&&r.contains(i)&&ry(i,t)}function cm(e){let t=e.inputType,n=rm(e),r=U(),i=r._inputState,a=H();if(t===`insertText`&&e.data&&i.isInsertTextAfterHandledSelectionCommand){if(am(i),e.preventDefault(),V(a)&&!a.isCollapsed()){let e=a.isBackward()?a.anchor:a.focus;a.anchor.set(e.key,e.offset,e.type),a.focus.set(e.key,e.offset,e.type)}return!0}if(t===`deleteContentBackward`){if(a===null){let e=Ph();if(!V(e))return!0;M_(e.clone())}if(V(a)){let t=a.anchor.key===a.focus.key;if(function(e,t){return e.lastKeyCode===`MediaLast`&&t<e.lastKeyDownTimeStamp+30}(i,e.timeStamp)&&r.isComposing()&&t){if(S_(null),i.lastKeyDownTimeStamp=0,setTimeout(()=>{Cg(r,()=>{S_(null)})},30),V(a)){let e=a.anchor.getNode();e.markDirty(),B(e)||I(142),nm(a,e)}}else{if(S_(null),ad&&n!==null&&!n.collapsed&&(a.applyDOMRange(n),!a.isCollapsed()))return e.preventDefault(),a.removeText(),!0;e.preventDefault();let o=a.anchor.getNode(),s=o.getTextContent(),c=o.canInsertTextAfter(),l=a.anchor.offset===0&&a.focus.offset===s.length,u=ld&&t&&!l&&c;if(u&&a.isCollapsed()&&(u=!G(Z_(a.anchor,!0))),!u){q(r,sp,!0);let e=H();ld&&V(e)&&e.isCollapsed()&&(i.postDeleteSelectionToRestore=e,setTimeout(()=>i.postDeleteSelectionToRestore=null))}}return!0}}if(!V(a))return!0;let o=e.data;i.unprocessedBeforeInputData!==null&&z_(!1,r,i.unprocessedBeforeInputData),a.dirty&&i.unprocessedBeforeInputData===null||!a.isCollapsed()||kg(a.anchor.getNode())||n===null||a.applyDOMRange(n),i.unprocessedBeforeInputData=null;let s=a.anchor,c=a.focus,l=s.getNode(),u=c.getNode();if(t===`insertText`||t===`insertTranspose`){if(o===`
|
|
136
|
+
`)e.preventDefault(),q(r,cp,!1);else if(o===`
|
|
146
137
|
|
|
147
|
-
`)e.preventDefault(),q(r,
|
|
148
|
-
`){let t=H();if(V(t)||cp(t)){if(V(t)){let e=t.focus;t.anchor.set(e.key,e.offset,e.type)}return q(e,Sd,null),uf(n),!1}}let r=xh(n);if(r!==null&&B(r)&&dh(r)){r.markDirty();let e=H(),i=r.getTextContentSize(),a=V(e)&&e.anchor.key===n?e.anchor.offset:i;return r.select(a,a).insertText(t),!0}}return Ih(!0,e,t),uf(n),!1}function ff(e){let t=U(),n=t._inputState;if(e.key==null)return!0;if(n.compositionPhase===`ending-safari`){let r=Uh(e);if(r&&bm(t,()=>{df(t,n.compositionEndData)}),n.compositionPhase=`idle`,n.compositionEndData=``,r)return!0}if(function(e){return K(e,`ArrowRight`,{shiftKey:`any`})}(e))q(t,gd,e);else if(function(e){return K(e,`ArrowRight`,{...Vh,shiftKey:`any`})}(e))q(t,_d,e);else if(function(e){return K(e,`ArrowLeft`,{shiftKey:`any`})}(e))q(t,vd,e);else if(function(e){return K(e,`ArrowLeft`,{...Vh,shiftKey:`any`})}(e))q(t,yd,e);else if(function(e){return K(e,`ArrowUp`,{altKey:`any`,shiftKey:`any`})}(e))q(t,bd,e);else if(function(e){return K(e,`ArrowDown`,{altKey:`any`,shiftKey:`any`})}(e))q(t,xd,e);else if(function(e){return K(e,`Enter`,{altKey:`any`,ctrlKey:`any`,metaKey:`any`,shiftKey:!0})}(e))n.isInsertLineBreak=!0,q(t,Sd,e);else if(function(e){return e.key===` `}(e))q(t,Cd,e);else if(function(e){return el&&K(e,`o`,{ctrlKey:!0})}(e))e.preventDefault(),n.isInsertLineBreak=!0,q(t,ad,!0);else if(function(e){return K(e,`Enter`,{altKey:`any`,ctrlKey:`any`,metaKey:`any`})}(e))n.isInsertLineBreak=!1,q(t,Sd,e);else if(function(e){return K(e,`Backspace`,{shiftKey:`any`})||el&&K(e,`h`,{ctrlKey:!0})}(e))Uh(e)?q(t,wd,e)&&rf(n):(e.preventDefault(),q(t,id,!0));else if(function(e){return e.key===`Escape`}(e))q(t,Td,e);else if(function(e){return K(e,`Delete`,{})||el&&K(e,`d`,{ctrlKey:!0})}(e))(function(e){return e.key===`Delete`})(e)?q(t,Ed,e):(e.preventDefault(),q(t,id,!1));else if(function(e){return K(e,`Backspace`,Hh)}(e))e.preventDefault(),q(t,ud,!0);else if(function(e){return K(e,`Delete`,Hh)}(e))e.preventDefault(),q(t,ud,!1);else if(function(e){return el&&K(e,`Backspace`,{metaKey:!0})}(e))e.preventDefault(),q(t,dd,!0);else if(function(e){return el&&(K(e,`Delete`,{metaKey:!0})||K(e,`k`,{ctrlKey:!0}))}(e))e.preventDefault(),q(t,dd,!1);else if(function(e){return K(e,`b`,Vh)}(e))e.preventDefault(),q(t,fd,`bold`);else if(function(e){return K(e,`u`,Vh)}(e))e.preventDefault(),q(t,fd,`underline`);else if(function(e){return K(e,`i`,Vh)}(e))e.preventDefault(),q(t,fd,`italic`);else if(function(e){return K(e,`Tab`,{shiftKey:`any`})}(e))q(t,Dd,e);else if(function(e){return K(e,`z`,Vh)}(e))e.preventDefault(),q(t,pd);else if(function(e){return el?K(e,`z`,{metaKey:!0,shiftKey:!0}):K(e,`y`,{ctrlKey:!0})||K(e,`z`,{ctrlKey:!0,shiftKey:!0})}(e))e.preventDefault(),q(t,md);else{let r=t._editorState._selection;(function(e){return K(e,`a`,Vh)})(e)?(e.preventDefault(),q(t,Pd,e)&&rf(n)):r===null||V(r)||(function(e){return K(e,`c`,Vh)}(e)?(e.preventDefault(),q(t,Md,e)):function(e){return K(e,`x`,Vh)}(e)&&(e.preventDefault(),q(t,Nd,e)))}return function(e){return e.ctrlKey||e.shiftKey||e.altKey||e.metaKey}(e)&&t.dispatchCommand(Vd,e),!0}function pf(e){let t=e.__lexicalEventHandles;return t===void 0&&(t=[],e.__lexicalEventHandles=t),t}let mf=/* @__PURE__ */ new Map;function hf(e){let t=hg(e.target);if(t===null)return;let n=Qh(e.target),r=null,i=null,a=n===null?void 0:qd.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&&gg(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=wg(t,e).anchorNode;if(s!==null&&ch(s)===o){if(gg(e.getRootNode())){r=o,i=s;break}n===null&&(n=o,a=s)}}r===null&&n!==null&&(r=n,i=a)}else{let e=t.anchorNode;e===null||J(e)&&e.shadowRoot!==null||(r=ch(e),r!==null&&(i=e))}}if(r===null){let e=kg(n);r=e===null?null:ch(e)}}if(r===null)return;if(r._inputState.isSelectionChangeFromMouseDown){if(a!==void 0)for(let e of a.editors)e._inputState.isSelectionChangeFromMouseDown=!1;bm(r,()=>{let n=jp(),a=i??wg(t,r._rootElement).anchorNode;(J(a)||fh(a))&&kh(Ap(n,t,r,e))})}let o=Nh(r),s=o[o.length-1],c=s._key,l=mf.get(c),u=l||s;u!==r&&Zd(t,u,!1),Zd(t,r,!0),r===s?l&&mf.delete(c):mf.set(c,r)}function gf(e){e._lexicalHandled=!0}function _f(e){return!0===e._lexicalHandled}function vf(e){let t=Kd.get(e);if(t===void 0)return;let n=qd.get(t);if(n===void 0)return;Kd.delete(e);let r=lh(e);sh(r)?(function(e){if(e._parentEditor!==null){let t=Nh(e),n=t[t.length-1]._key;mf.get(n)===e&&mf.delete(n)}else mf.delete(e._key)}(r),n.editors.delete(r),n.hasShadowEditor=void 0,e.__lexicalEditor=null):r&&I(198);let i=pf(e);for(let e=0;e<i.length;e++)i[e]();e.__lexicalEventHandles=[]}function yf(e,t,n){nm();let r=e.__key,i=e.getParent();if(i===null)return void(p_(e)!==null&&I(367,r,String(p_(e))));let a=function(e){let t=H();if(!V(t)||!W(e))return t;let{anchor:n,focus:r}=t,i=n.getNode(),a=r.getNode();return tg(i,e)&&n.set(e.__key,0,`element`),tg(a,e)&&r.set(e.__key,0,`element`),t}(e),o=!1;if(V(a)&&t){let t=a.anchor,n=a.focus;t.key===r&&(Pp(t,e,i,e.getPreviousSibling(),e.getNextSibling()),o=!0),n.key===r&&(Pp(n,e,i,e.getPreviousSibling(),e.getNextSibling()),o=!0)}else cp(a)&&t&&e.isSelected()&&e.selectPrevious();if(V(a)&&t&&!o){let t=e.getIndexWithinParent();_h(e),Mp(a,i,t,-1)}else _h(e);n||sg(i)||i.canBeEmpty()||!i.isEmpty()||yf(i,t),t&&a&&Em(i)&&i.isEmpty()&&i.selectEnd()}let bf=Symbol.for(`ephemeral`);function xf(e){return e[bf]||!1}let Sf={configurable:!0,enumerable:!1,value:void 0,writable:!0};var Cf=class{__type;__key;__parent;__prev;__next;__state;[au];static getType(){let{ownNodeType:e}=i_(this);return e===void 0&&I(64,this.name),e}static clone(e){I(65,this.name)}$config(){return{}}config(e,t){let n=t.extends||l_(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",Sf),Object.defineProperty(this,au,Sf),gh(this,e)}getType(){return this.__type}isInline(){I(137,this.constructor.name)}isAttached(){let e=this.__key;for(;e!==null;){if(e===`root`)return!0;let t=xh(e);if(t===null)break;e=t.__parent===null?p_(t):t.__parent}return!1}isSelected(e){let t=e||H();if(t==null)return!1;let n=t.getNodes().some(e=>e.__key===this.__key);if(B(this))return n;if(V(t)&&t.anchor.type===`element`&&t.focus.type===`element`){if(t.isCollapsed())return!1;let e=this.getParent();if(G(this)&&this.isInline()&&e){let n=t.isBackward()?t.focus:t.anchor;if(e.is(n.getNode())&&n.offset===e.getChildrenSize()&&this.is(e.getLastChild()))return!1}}return n}getKey(){return this.__key}getIndexWithinParent(){let e=this.getParent();if(e===null)return-1;let t=e.getFirstChild(),n=0;for(;t!==null;){if(this.is(t))return n;n++,t=t.getNextSibling()}return-1}getParent(){let e=this.getLatest().__parent;return e===null?null:xh(e)}getParentOrThrow(){let e=this.getParent();return e===null&&I(66,this.__key),e}getTopLevelElement(){let e=this;for(;e!==null;){let t=e.getParent();if(sg(t)||p_(e)!==null)return W(e)||e===this&&G(e)||I(194),e;e=t}return null}getTopLevelElementOrThrow(){let e=this.getTopLevelElement();return e===null&&I(67,this.__key),e}getParents(){let e=[],t=this.getParent();for(;t!==null;)e.push(t),t=t.getParent();return e}getParentKeys(){let e=[],t=this.getParent();for(;t!==null;)e.push(t.__key),t=t.getParent();return e}getPreviousSibling(){let e=this.getLatest().__prev;return e===null?null:xh(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:xh(e)}getNextSiblings(){let e=[],t=this.getNextSibling();for(;t!==null;)e.push(t),t=t.getNextSibling();return e}getCommonAncestor(e){let t=W(this)?this:this.getParent(),n=W(e)?e:e.getParent(),r=t&&n?lv(t,n):null;return r?r.commonAncestor:null}is(e){return e!=null&&this.__key===e.__key}isBefore(e){let t=lv(this,e);return t!==null&&(t.type===`descendant`||(t.type===`branch`?ov(t)===-1:(t.type!==`same`&&t.type!==`ancestor`&&I(279),!1)))}isParentOf(e){return tg(e,this)}getNodesBetween(e){let t=this.isBefore(e),n=[],r=/* @__PURE__ */ new Set,i=this;for(;i!==null;){let a=i.__key;if(r.has(a)||(r.add(a),n.push(i)),i===e)break;let o=W(i)?t?i.getFirstChild():i.getLastChild():null;if(o!==null){i=o;continue}let s=t?i.getNextSibling():i.getPreviousSibling();if(s!==null){i=s;continue}let c=i.getParentOrThrow();if(r.has(c.__key)||n.push(c),c===e)break;let l=null,u=c;do{if(u===null&&I(68),l=t?u.getNextSibling():u.getPreviousSibling(),u=u.getParent(),u===null)break;l!==null||r.has(u.__key)||n.push(u)}while(l===null);i=l}return t||n.reverse(),n}isDirty(){let e=U()._dirtyLeaves;return e!==null&&e.has(this.__key)}getLatest(){if(xf(this))return this;let e=xh(this.__key);return e===null&&I(113),e}getWritable(){if(xf(this))return this;nm();let e=im(),t=U(),n=e._nodeMap,r=this.__key,i=this.getLatest(),a=t._cloneNotNeeded,o=H();if(o!==null&&o.setCachedNodes(null),a.has(r))return vh(i),i;let s=Kg(i);return a.add(r),vh(s),n.set(r,s),s}getTextContent(){return E_(this)}getTextContentSize(){return this.getTextContent().length}createDOM(e,t){I(70)}updateDOM(e,t,n){I(71)}getDOMSlot(e){return new Sl(e)}exportDOM(e){return{element:this.createDOM(e._config,e)}}exportJSON(){let e=this.__state?this.__state.toJSON():void 0;return{type:this.__type,version:1,...e}}static importJSON(e){I(18,this.name)}updateFromJSON(e){return function(e,t){let n=e.getWritable(),r=t.$,i=r;for(let e of Jl(n).flatKeys)e in t&&(i!==void 0&&i!==r||(i={...r}),i[e]=t[e]);return(n.__state||i)&&ql(e).updateFromJSON(i),n}(this,e)}static transform(){return null}remove(e){yf(this,!0,e)}replace(e,t){nm();let n=H();n!==null&&(n=n.clone()),ug(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();_h(o),l!==null&&V(n)&&Mp(n,l,u,-1);let d=r.getPreviousSibling(),f=r.getNextSibling(),p=r.__prev,m=r.__next,h=r.__parent;yf(r,!1,!0),d===null?s.__first=a:d.getWritable().__next=a,o.__prev=p,f===null?s.__last=a:f.getWritable().__prev=a,o.__next=m,o.__parent=h,s.__size=c;let g=0;t&&(W(this)&&W(o)||I(139),g=o.getChildrenSize(),o.splice(g,0,this.getChildren()));let _=v_(this);if(_.length>0){d_(this)&&d_(o)||I(368,this.__key,o.__key);for(let e of _){let t=y_(this,e);t!==null&&(A_(this,e),k_(o,e,t))}}if(V(n)){kh(n);let e=n.anchor,r=n.focus;e.key===i&&(t&&e.type===`element`?e.set(o.__key,g+e.offset,`element`):np(e,o)),r.key===i&&(t&&r.type===`element`?r.set(o.__key,g+r.offset,`element`):np(r,o))}return bh()===i&&yh(a),o}insertAfter(e,t=!0){nm(),ug(this,e);let n=this.getWritable(),r=e.getWritable();this.getParentOrThrow();let i=r.getParent(),a=H(),o=!1,s=!1;if(i!==null){let n=e.getIndexWithinParent();if(V(a)){let e=i.__key,t=a.anchor,r=a.focus;o=t.type===`element`&&t.key===e&&t.offset===n+1,s=r.type===`element`&&r.key===e&&r.offset===n+1}_h(r),t&&V(a)&&Mp(a,i,n,-1)}else _h(r);let c=this.getNextSibling(),l=this.getParentOrThrow().getWritable(),u=r.__key,d=n.__next;if(c===null?l.__last=u:c.getWritable().__prev=u,l.__size++,n.__next=u,r.__next=d,r.__prev=n.__key,r.__parent=n.__parent,t&&V(a)){let e=this.getIndexWithinParent();Mp(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){nm(),ug(this,e);let n=this.getWritable(),r=e.getWritable();this.getParentOrThrow();let i=r.__key,a=H(),o=r.getParent(),s=o===null?-1:r.getIndexWithinParent();_h(r),o!==null&&t&&V(a)&&Mp(a,o,s,-1);let c=this.getPreviousSibling(),l=this.getParentOrThrow().getWritable(),u=n.__prev,d=this.getIndexWithinParent();return c===null?l.__first=i:c.getWritable().__next=i,l.__size++,n.__prev=i,r.__prev=u,r.__next=n.__key,r.__parent=n.__parent,t&&V(a)&&Mp(a,this.getParentOrThrow(),d),e}isParentRequired(){return!1}createParentElementNode(){return Hm()}selectStart(){return this.selectPrevious()}selectEnd(){return this.selectNext(0,0)}selectPrevious(e,t){nm();let n=m_(this);if(n!==null)return n.selectPrevious(e,t);let r=this.getPreviousSibling(),i=this.getParentOrThrow();if(r===null)return i.select(0,0);if(W(r))return r.select();if(!B(r)){let e=r.getIndexWithinParent()+1;return i.select(e,e)}return r.select(e,t)}selectNext(e,t){nm();let n=m_(this);if(n!==null)return n.selectNext(e,t);let r=this.getNextSibling(),i=this.getParentOrThrow();if(r===null)return i.select();if(W(r))return r.select(0,0);if(!B(r)){let e=r.getIndexWithinParent();return i.select(e,e)}return r.select(e,t)}markDirty(){this.getWritable()}reconcileObservedMutation(e,t){this.markDirty()}};function wf(e){return e instanceof Cf}let Tf=`history-merge`,Ef=`paste`,Df=`skip-selection-focus`,Of=`composition-end`;function kf(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 Af(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 jf(e,t,n=``){if(t===n)return;let r=kf(n),i=kf(t);for(let t in i)delete r[t],Af(e,t,i[t]);for(let t in r)e.removeProperty(t)}function Mf(e,t){return 16&t?`code`:t&128?`mark`:32&t?`sub`:64&t?`sup`:null}function Nf(e,t){return 1&t?`strong`:2&t?`em`:`span`}function Pf(e,t,n,r,i){let a=r.classList,o=Gh(i,`base`);o!==void 0&&a.add(...o),o=Gh(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 pl){let r=pl[e];if(o=Gh(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 Ff(e,t,n){let r=n.isComposing(),i=e+(r?ll:``),a=Rg(),o=zg(a).$getDOMSlot(n,t,a),s=o.getFirstChild();if(s===null||s.nodeType!==Node.TEXT_NODE)return void o.insertChild(xg().createTextNode(i));let c=s,l=c.nodeValue;if(l!==i){if(r||tl){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 If(e,t,n,r,i,a){Ff(i,e,t);let o=a.theme.text;o!==void 0&&Pf(0,0,r,e,o)}function Lf(e,t){let n=xg().createElement(t);return n.appendChild(e),n}function Rf(e){return e!=null&&!0===e.__isInlineFormattable}var zf=class extends Cf{__text;__format;__style;__mode;__detail;get __isInlineFormattable(){return!0}$config(){return this.config(`text`,{importDOM:{"#text":()=>({conversion:Wf,priority:0}),b:()=>({conversion:Vf,priority:0}),code:()=>({conversion:qf,priority:0}),em:()=>({conversion:qf,priority:0}),i:()=>({conversion:qf,priority:0}),mark:()=>({conversion:qf,priority:0}),s:()=>({conversion:qf,priority:0}),span:()=>({conversion:Bf,priority:0}),strong:()=>({conversion:qf,priority:0}),sub:()=>({conversion:qf,priority:0}),sup:()=>({conversion:qf,priority:0}),u:()=>({conversion:qf,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 vl[e.__mode]}getStyle(){return this.getLatest().__style}isToken(){return this.getLatest().__mode===1}isComposing(){return this.__key===bh()}isSegmented(){return this.getLatest().__mode===2}isDirectionless(){return!!(1&this.getLatest().__detail)}isUnmergeable(){return!!(2&this.getLatest().__detail)}hasFormat(e){let t=pl[e];return(this.getFormat()&t)!==0}isSimpleText(){return this.__type===`text`&&this.__mode===0}getTextContent(){return this.getLatest().__text}getFormatFlags(e,t){return hh(this.getLatest().__format,e,t)}canHaveFormat(){return!0}isInline(){return!0}createDOM(e,t){let n=this.__format,r=Mf(0,n),i=Nf(0,n),a=r===null?i:r,o=xg().createElement(a),s=o;this.hasFormat(`code`)&&o.setAttribute(`spellcheck`,`false`),r!==null&&(s=xg().createElement(i),o.appendChild(s)),If(s,this,0,n,this.__text,e);let c=this.__style;return c!==``&&jf(o.style,c),o}updateDOM(e,t,n){let r=this.__text,i=e.__format,a=this.__format,o=Mf(0,i),s=Mf(0,a),c=Nf(0,i),l=Nf(0,a);if((o===null?c:o)!==(s===null?l:s))return!0;if(o===s&&c!==l){let e=t.firstChild;e??I(48);let i=xg().createElement(l);return If(i,this,0,a,r,n),t.replaceChild(i,e),!1}let u=t;s!==null&&o!==null&&(u=t.firstChild,u??I(49)),Ff(r,u,this);let d=n.theme.text;d!==void 0&&i!==a&&Pf(0,i,a,u,d);let f=e.__style,p=this.__style;return f!==p&&jf(t.style,p,f),!1}updateFromJSON(e){return super.updateFromJSON(e).setTextContent(e.text).setFormat(e.format).setDetail(e.detail).setMode(e.mode).setStyle(e.style)}exportDOM(e){let{element:t}=super.exportDOM(e);return J(t)||I(132),t.style.whiteSpace=`pre-wrap`,this.hasFormat(`lowercase`)?t.style.textTransform=`lowercase`:this.hasFormat(`uppercase`)?t.style.textTransform=`uppercase`:this.hasFormat(`capitalize`)&&(t.style.textTransform=`capitalize`),this.hasFormat(`bold`)&&(t=Lf(t,`b`)),this.hasFormat(`italic`)&&(t=Lf(t,`i`)),this.hasFormat(`strikethrough`)&&(t=Lf(t,`s`)),this.hasFormat(`underline`)&&(t=Lf(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`?pl[e]:e,t}setDetail(e){let t=this.getWritable();return t.__detail=typeof e==`string`?ml[e]:e,t}setStyle(e){let t=this.getWritable();return t.__style=e,t}toggleFormat(e){let t=hh(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=_l[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){nm();let n=e,r=t,i=H(),a=this.getTextContent(),o=this.__key;if(typeof a==`string`){let e=a.length;n===void 0&&(n=e),r===void 0&&(r=e)}else n=0,r=0;if(!V(i))return Dp(o,n,o,r,`text`,`text`);{let e=bh();e!==i.anchor.key&&e!==i.focus.key||yh(o),i.setTextNodeRange(this,n,this,r)}return i}selectStart(){return this.select(0,0)}selectEnd(){let e=this.getTextContentSize();return this.select(e,e)}spliceText(e,t,n,r){let i=this.getWritable(),a=i.__text,o=n.length,s=e;s<0&&(s=o+s,s<0&&(s=0));let c=H();if(r&&V(c)){let t=e+o;c.setTextNodeRange(i,t,i,t)}return i.__text=a.slice(0,s)+n+a.slice(s+t),i}canInsertTextBefore(){return!0}canInsertTextAfter(){return!0}splitText(...e){nm();let t=this.getLatest(),n=t.getTextContent();if(n===``)return[];let r=t.__key,i=bh(),a=n.length;e.sort((e,t)=>e-t),e.push(a);let o=[],s=e.length;for(let t=0,r=0;t<a&&r<=s;r++){let i=e[r];i>t&&(o.push(n.slice(t,i)),t=i)}let c=o.length;if(c===1)return[t];let l=o[0],u=t.getParent(),d,f=t.getFormat(),p=t.getStyle(),m=t.__detail,h=!1,g=null,_=null,v=H();if(V(v)){let[e,t]=v.isBackward()?[v.focus,v.anchor]:[v.anchor,v.focus];e.type===`text`&&e.key===r&&(g=e),t.type===`text`&&t.key===r&&(_=t)}t.isSegmented()?(d=Jf(l),d.__format=f,d.__style=p,d.__detail=m,d.__state=$l(t,d),h=!0):d=t.setTextContent(l);let y=[d];for(let e=1;e<c;e++){let n=Jf(o[e]);n.__format=f,n.__style=p,n.__detail=m,n.__state=$l(t,n);let a=n.__key;i===r&&yh(a),y.push(n)}let b=g?g.offset:null,ee=_?_.offset:null,te=0;for(let e of y){if(!g&&!_)break;let t=te+e.getTextContentSize();if(g!==null&&b!==null&&b<=t&&b>=te&&(g.set(e.getKey(),b-te,`text`),b<t&&(g=null)),_!==null&&ee!==null&&ee<=t&&ee>=te){_.set(e.getKey(),ee-te,`text`);break}te=t}if(u!==null){(function(e){let t=e.getPreviousSibling(),n=e.getNextSibling();t!==null&&vh(t),n!==null&&vh(n)})(this);let e=u.getWritable(),t=this.getIndexWithinParent();h?(e.splice(t,0,y),this.remove()):e.splice(t,1,y),V(v)&&Mp(v,u,t,c-1)}return y}mergeWithSibling(e){let t=e===this.getPreviousSibling();t||e===this.getNextSibling()||I(50);let n=this.__key,r=e.__key,i=this.__text,a=i.length;bh()===r&&yh(n);let o=H();if(V(o)){let i=o.anchor,s=o.focus;i!==null&&i.key===r&&Fp(i,t,n,e,a),s!==null&&s.key===r&&Fp(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 Bf(e){return{forChild:Yf(e.style),node:null}}function Vf(e){let t=e,n=t.style.fontWeight===`normal`;return{forChild:Yf(t.style,n?void 0:`bold`),node:null}}let Hf=/* @__PURE__ */ new WeakMap;function Uf(e){if(!J(e))return!1;if(e.nodeName===`PRE`)return!0;let t=e.style.whiteSpace;return typeof t==`string`&&t.startsWith(`pre`)}function Wf(e){let t=e;e.parentElement===null&&I(129);let n=t.textContent||``;if(function(e){let t,n=e.parentNode,r=[e];for(;n!==null&&(t=Hf.get(n))===void 0&&!Uf(n);)r.push(n),n=n.parentNode;let i=t===void 0?n:t;for(let e=0;e<r.length;e++)Hf.set(r[e],i);return i}(t)!==null)return{node:Bp(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=Gf(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=Gf(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:Jf(n)}}function Gf(e,t){let n=e;for(;;){let e;for(;(e=t?n.nextSibling:n.previousSibling)===null;){let e=n.parentElement;if(e===null)return null;n=e}if(n=e,J(n)){let e=n.style.display;if(e===``&&!Pg(n)||e!==``&&!e.startsWith(`inline`))return null}let r=n;for(;(r=t?n.firstChild:n.lastChild)!==null;)n=r;if(fh(n))return n;if(n.nodeName===`BR`)return null}}let Kf={code:`code`,em:`italic`,i:`italic`,mark:`highlight`,s:`strikethrough`,strong:`bold`,sub:`subscript`,sup:`superscript`,u:`underline`};function qf(e){let t=Kf[e.nodeName.toLowerCase()];return t===void 0?{node:null}:{forChild:Yf(e.style,t),node:null}}function Jf(e=``){return lg(new zf(e))}function B(e){return e instanceof zf}function Yf(e,t){let n=e.fontWeight,r=e.textDecoration.split(` `),i=n===`700`||n===`bold`,a=r.includes(`line-through`),o=e.fontStyle===`italic`,s=r.includes(`underline`),c=e.verticalAlign;return e=>((B(e)||Rf(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 Xf=class extends zf{$config(){return this.config(`tab`,{extends:zf})}constructor(e=void 0){super(` `,e),this.__detail=2}createDOM(e){let t=super.createDOM(e),n=Gh(e.theme,`tab`);return n!==void 0&&t.classList.add(...n),t}setTextContent(e){return super.setTextContent(` `)}spliceText(e,t,n,r){return n===``&&t===0||n===` `&&t===1||I(286),this}setDetail(e){return e!==2&&I(127),this}setMode(e){return e!==`normal`&&I(128),this}canInsertTextBefore(){return!1}canInsertTextAfter(){return!1}};function Zf(){return lg(new Xf)}function Qf(e){return e instanceof Xf}var $f=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:av(yv(uv(this,`next`)),yv(uv(e,`next`)))<0}getNode(){let e=xh(this.key);return e===null&&I(20),e}set(e,t,n,r){let i=this._selection,a=this.key;r&&this.key===e&&this.offset===t&&this.type===n||(this.key=e,this.offset=t,this.type=n,tm()||(bh()===a&&yh(e),i!==null&&(i.setCachedNodes(null),V(i)&&(i._cachedIsBackward=null),i.dirty=!0)))}};function ep(e,t,n){return new $f(e,t,n)}function tp(e,t){let n=t.__key,r=e.offset,i=`element`;if(B(t)){i=`text`;let e=t.getTextContentSize();r>e&&(r=e)}else if(!W(t)){let e=t.getNextSibling();if(B(e))n=e.__key,r=0,i=`text`;else{let e=t.getParent();e&&(n=e.__key,r=t.getIndexWithinParent()+1)}}e.set(n,r,i)}function np(e,t){if(W(t)){let n=t.getLastDescendant();W(n)||B(n)?tp(e,n):tp(e,t)}else tp(e,t)}function rp(e,t,n,r){let i=e.getNode(),a=i.getChildAtIndex(e.offset),o=Jf();if(o.setFormat(n),o.setStyle(r),Um(a))a.splice(0,0,[o]);else if(a!==null){let e=sg(i)?Hm().append(o):o;a.insertBefore(e)}else if(sg(i)){let e=i.getLastChild();W(e)&&!e.isInline()&&e.isEmpty()?e.append(o):i.append(Hm().append(o))}else i.append(o);e.is(t)&&t.set(o.__key,0,`text`),e.set(o.__key,0,`text`)}function ip(e,t,n,r){let i=e.anchor.getNode();B(i)||I(398);let a=e.anchor.offset,o=Jf(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 ap=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(!cp(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=>p_(e)===null),n=t.length;if(n===0)return;let r=t[n-1],i;if(B(r))i=r.select();else{let e=r.getIndexWithinParent()+1;i=r.getParentOrThrow().select(e,e)}i.insertNodes(e);for(let e=0;e<n;e++)t[e].remove()}getNodes(){let e=this._cachedNodes;if(e!==null)return e;let t=this._nodes,n=[];for(let e of t){let t=xh(e);t!==null&&n.push(t)}return tm()||(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=>p_(e)===null);if((H()||jp())===this&&e[0]){let t=K_(e[0],`next`);fv(rv(t,t))}for(let t of e)t.remove();op()}};function op(){let e=Oh();if(e.isEmpty()){let t=Hm();e.append(t),t.select()}}function V(e){return e instanceof sp}var sp=class e{format;style;anchor;focus;_cachedNodes;_cachedIsBackward;dirty;constructor(e,t,n,r){this.anchor=e,this.focus=t,e._selection=this,t._selection=this,this._cachedNodes=null,this._cachedIsBackward=null,this.format=n,this.style=r,this.dirty=!1}getCachedNodes(){return this._cachedNodes}setCachedNodes(e){this._cachedNodes=e}is(e){return!!V(e)&&this.anchor.is(e.anchor)&&this.focus.is(e.focus)&&this.format===e.format&&this.style===e.style}isCollapsed(){return this.anchor.is(this.focus)}getNodes(){let e=this._cachedNodes;if(e!==null)return e;let t=function(e){let t=[],[n,r]=e.getTextSlices();n&&t.push(n.caret.origin);let i=/* @__PURE__ */ new Set,a=/* @__PURE__ */ new Set;for(let n of e)if(H_(n)){let{origin:e}=n;t.length===0?i.add(e):(a.add(e),t.push(e))}else{let{origin:e}=n;W(e)&&a.has(e)||t.push(e)}if(r&&t.push(r.caret.origin),V_(e.focus)&&W(e.focus.origin)&&e.focus.getNodeAtCaret()===null)for(let n=X_(e.focus.origin,`previous`);H_(n)&&i.has(n.origin)&&!n.origin.isEmpty()&&n.origin.is(t[t.length-1]);n=Q_(n))i.delete(n.origin),t.pop();for(;t.length>1;){let e=t[t.length-1];if(!W(e)||a.has(e)||e.isEmpty()||i.has(e))break;t.pop()}if(t.length===0&&e.isCollapsed()){let n=yv(e.anchor),r=yv(e.anchor.getFlipped()),i=e=>B_(e)?e.origin:e.getNodeAtCaret(),a=i(n)||i(r)||(e.anchor.getNodeAtCaret()?n.origin:r.origin);t.push(a)}return t}(Sv(mv(this),`next`));return tm()||(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]=fp(this),c=``,l=!0;for(let u=0;u<e.length;u++){let d=e[u];if(W(d)&&!d.isInline()){l||(c+=`
|
|
149
|
-
`);let e=``;for(let t of v_(d)){let n=y_(d,t);n!==null&&(e+=n.getTextContent())}e===``?l=!d.isEmpty():(c+=e,l=!1)}else if(l=!1,B(d)){let e=d.getTextContent();d===t?d===n?r.type===`element`&&i.type===`element`&&i.offset!==r.offset||(e=o<s?e.slice(o,s):e.slice(s,o)):e=a?e.slice(o):e.slice(s):d===n&&(e=a?e.slice(0,s):e.slice(0,o)),c+=e}else!G(d)&&!Im(d)||d===n&&this.isCollapsed()||(c+=d.getTextContent())}return c}applyDOMRange(e){let t=U(),n=t.getEditorState()._selection,r=Tp(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),ru(this)}clone(){let t=this.anchor,n=this.focus;return new e(ep(t.key,t.offset,t.type),ep(n.key,n.offset,n.type),this.format,this.style)}toggleFormat(e){this.format=hh(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=pl[e];return(this.format&t)!==0}insertRawText(e){this.insertNodes(Bp(e))}insertText(e){let t=this.format,n=this.style;if(!this.isCollapsed()){let r=(this.focus.isBefore(this.anchor)?this.focus:this.anchor).getNode();if(B(r)&&(t=r.getFormat(),n=r.getStyle()),this.removeText(),this.format=t,this.style=n,e===``)return;if(bh()===null)return this.anchor.type===`element`&&rp(this.anchor,this.focus,t,n),void ip(this,e,t,n)}this.anchor.type===`element`&&rp(this.anchor,this.focus,t,n);let r=this.anchor.getNode();B(r)||I(398);let i=this.anchor.offset,a=r.getParentOrThrow(),o=r.getTextContentSize();if(dh(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(bh()!==null)r.setMode(`normal`).setFormat(t).setStyle(n);else{let e=Jf(r.getTextContent());e.setFormat(t),e.setStyle(n),r.replace(e),e.select(i,i)}e!==``&&this.insertText(e);return}if(e===``)return;if(i===0){let i=r.getPreviousSibling();if(B(i)&&i.canInsertTextAfter()&&!dh(i))i.select();else{let e=Jf();e.setFormat(t),e.setStyle(n),a.canInsertTextBefore()?r.insertBefore(e):a.insertBefore(e),e.select()}this.insertText(e);return}if(i===o){let i=r.getNextSibling();if(B(i)&&i.canInsertTextBefore()&&!dh(i))i.select(0,0);else{let e=Jf();e.setFormat(t),e.setStyle(n),a.canInsertTextAfter()?r.insertAfter(e):a.insertAfter(e),e.select(0,0)}this.insertText(e);return}let s=Jf(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 ip(this,e,t,n);r.setFormat(t),r.setStyle(n)}r.spliceText(i,0,e,!0),r.isComposing()&&this.anchor.type===`text`&&this.anchor.set(this.anchor.key,this.anchor.offset-e.length,this.anchor.type)}removeText(){let e=H()===this;pv(this,vv(mv(this))),e&&H()!==this&&kh(this)}formatText(e,t=null){up(this,e,t)}insertNodes(e){if(e.length===0)return;this.isCollapsed()||this.removeText();let t=this.anchor.getNode();if(this.anchor.type===`element`&&W(t)&&p_(t)!==null){let n=t.isShadowRoot()?t.getFirstChild()??t.append(Hm()).getFirstChild():t.getFirstChild();if(t.isShadowRoot()&&n!==null&&!W(n)){let e=Hm();n.insertBefore(e),n=e}if(n!==null){n.selectStart();let t=H();return V(t)||I(369),t.insertNodes(e)}}if(this.anchor.type===`element`&&sg(t)){let n=Gp(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=s_(n,Lg),i=e[e.length-1];if(W(r)&&`__language`in r){if(`__language`in e[0])this.insertText(e[0].getTextContent());else{let t=Hp(this);r.splice(t,0,e),i.selectEnd()}return}if(!e.some(e=>(W(e)||G(e))&&!e.isInline())){W(r)||I(211,n.constructor.name,n.getType());let t=Hp(this);r.splice(t,0,e),i.selectEnd();return}if(W(r)&&p_(r)!==null){let t=Hp(this),n=Vp(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=Gp(e),n=t.getLastDescendant(),r=uv(this.anchor,`next`);for(let e of t.getChildren())r=Dv(e,r);n!==null&&n.selectEnd();return}if(W(r)&&!r.isParentRequired()&&!sg(r.getParentOrThrow())){let t=Hp(this),n=Vp(e);r.splice(t,0,n);let i=n[n.length-1];i===void 0?r.select(t,t):i.selectEnd();return}let a=Gp(e),o=a.getLastDescendant(),s=a.getChildren(),c=!W(r)||!r.isEmpty()?this.insertParagraph():null;c&&!r.isAttached()&&(n=this.anchor.getNode(),r=s_(n,Lg));let l=s[s.length-1],u=s[0];var d;W(d=u)&&Lg(d)&&!d.isEmpty()&&W(r)&&(!r.isEmpty()||r.canMergeWhenEmpty())&&(W(r)||I(211,n.constructor.name,n.getType()),r.append(...u.getChildren()),u=s[1]),u&&(r===null&&I(212,n.constructor.name,n.getType()),function(e,t){let n=t.getParentOrThrow().getLastChild(),r=t,i=[t];for(;r!==n;)r.getNextSibling()||I(140),r=r.getNextSibling(),i.push(r);let a=e;for(let e of i)a=a.insertAfter(e)}(r,u));let f=s_(o,Lg);c&&W(f)&&(c.canMergeWhenEmpty()||Lg(l))&&(f.append(...c.getChildren()),c.remove()),W(r)&&r.isEmpty()&&r.remove(),o.selectEnd();let p=W(r)?r.getLastChild():null;Im(p)&&f!==r&&p.remove()}insertParagraph(){let e=this.anchor.getNode();if(this.anchor.type===`element`&&sg(e)){let t=Hm();return e.splice(this.anchor.offset,0,[t]),t.select(),t}let t=Hp(this),n=s_(this.anchor.getNode(),Lg);if(n!==null&&p_(n)!==null)return null;W(n)||I(213);let r=n.getChildAtIndex(t),i=r?[r,...r.getNextSiblings()]:[],a=n.insertNewAfter(this,!1);return a?(a.append(...i),a.selectStart(),a):null}insertLineBreak(e){let t=Fm();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]=fp(this),o=this.isBackward(),[s,c]=o?[this.focus,this.anchor]:[this.anchor,this.focus],[l,u]=o?[a,i]:[i,a];if(t===0)return[];if(t===1){if(B(n)&&!this.isCollapsed()){let e=n.splitText(l,u),t=l===0?e[0]:e[1];return t?(s.set(t.getKey(),0,`text`),c.set(t.getKey(),t.getTextContentSize(),`text`),[t]):[]}return[n]}if(B(n)&&(l===n.getTextContentSize()?e.shift():l!==0&&([,n]=n.splitText(l),e[0]=n,s.set(n.getKey(),0,`text`))),B(r)){let t=r.getTextContent().length;u===0?e.pop():u!==t&&([r]=r.splitText(u),e[e.length-1]=r,c.set(r.getKey(),r.getTextContentSize(),`text`))}return e}modify(e,t,n){if(Kp(this,e,t,n))return;let r=e===`move`,i=U(),a=mg(rg(i));if(!a)return;let o=i._blockCursorElement,s=i._rootElement,c=this.focus.getNode();s===null||o===null||!W(c)||c.isInline()||c.canBeEmpty()||pg(o,i,s);let l=Xh(i,this.focus.key),u=l;if(this.focus.type===`text`&&(u=B(c)?Hg(c,l,i):null),this.dirty){let e=Xh(i,this.anchor.key),t=e;if(this.anchor.type===`text`){let n=this.anchor.getNode();t=B(n)?Hg(n,e,i):null}t&&u&&Ip(a,t,this.anchor.offset,u,this.focus.offset)}if(n===`character`&&B(c)&&c.isUnmergeable()&&(t?this.focus.offset===0:this.focus.offset===c.getTextContentSize())){let e=K_(c,t?`previous`:`next`).getNodeAtCaret();if(B(e)){if(!r){let n=e.getTextContentSize();t?this.focus.set(e.__key,n-1,`text`):this.focus.set(e.__key,1,`text`),this.dirty=!0;return}{let n=i.getElementByKey(e.getKey()),r=n?Hg(e,n,i):null;if(r){let e=t?r.length:0;Ip(a,r,e,r,e)}}}}if(hp(a,e,t?`backward`:`forward`,n),a.rangeCount>0){let e=Sg(a,i._rootElement),n=e||a.getRangeAt(0),o=this.anchor.getNode(),s=Em(o)?o:ag(o);this.applyDOMRange(n),this.dirty=!0,!r&&(gp(this,t,s),(e?a.direction!==`backward`:a.anchorNode===n.startContainer&&a.anchorOffset===n.startOffset)||mp(this))}n===`lineboundary`&&Kp(this,e,t,n,`decorators`)}forwardDeletion(e,t,n){if(!n&&(e.type===`element`&&W(t)&&e.offset===t.getChildrenSize()||e.type===`text`&&e.offset===t.getTextContentSize())){let e=t.getParent(),n=t.getNextSibling()||(e===null?null:e.getNextSibling());if(W(n)&&n.isShadowRoot())return!0}return!1}deleteCharacter(e){let t=this.isCollapsed();if(this.isCollapsed()){let t=this.anchor,n=t.getNode();if(this.forwardDeletion(t,n,e))return;let r=tv(uv(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(H_(t)){if(!t.origin.isInline()){if(t.origin.isShadowRoot()){if(e.type===`merge-block`)break;if(W(r.anchor.origin)&&r.anchor.origin.isEmpty()){let e=yv(t);pv(this,rv(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(V_(t)){if(W(t.origin)){if(t.origin.isInline()){if(!t.origin.isParentOf(r.anchor.origin))break}else e={block:t.origin,type:`merge-next-block`};continue}if(G(t.origin)){if(!t.origin.isIsolated()){if(v_(t.origin).length>0){if(W(r.anchor.origin)&&r.anchor.origin.isEmpty()){r.anchor.origin.remove();let e=kp();e.add(t.origin.getKey()),kh(e)}}else if(e.type===`merge-next-block`&&(t.origin.isKeyboardSelectable()||!t.origin.isInline())&&W(r.anchor.origin)&&r.anchor.origin.isEmpty()){r.anchor.origin.remove();let e=kp();e.add(t.origin.getKey()),kh(e)}else t.origin.remove()}return}break}}if(e.type===`merge-block`){let{caret:t,block:n}=e;return v_(n).length>0?void 0:t.origin.isEmpty()&&!n.isEmpty()&&t.origin.getParent()===n.getParent()?void t.origin.remove(!0):(pv(this,rv(!t.origin.isEmpty()&&n.isEmpty()?hv(K_(n,t.direction)):r.anchor,t)),this.removeText())}for(let e=t.getNode();e!==null;){if(p_(e)!==null)return;if(W(e)&&e.isShadowRoot())break;e=e.getParent()}}let i=this.focus;if(_p(this,e,`character`),this.isCollapsed()){if(e&&t.offset===0&&pp(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 yp(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 yp(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!(Mh(e)||vp(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()&&Em(e.getParent())&&e.getPreviousSibling()===null&&pp(this,e),op()}}deleteLine(e){let t=Sp(this.anchor);if(t!==null&&G(m_(t)))return this.isCollapsed()||this.focus.set(this.anchor.key,this.anchor.offset,this.anchor.type),void this.deleteCharacter(e);this.isCollapsed()&&_p(this,e,`lineboundary`),this.isCollapsed()?this.deleteCharacter(e):s_(this.anchor.getNode(),Lg)===s_(this.focus.getNode(),Lg)?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;_p(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 tm()||(this._cachedIsBackward=t),t}getStartEndPoints(){return[this.anchor,this.focus]}};function cp(e){return e instanceof ap}function lp(e,t){if(cp(e)){for(let n of e.getNodes())Rf(n)&&n.setFormat(t(n.getFormat()));return}if(e.isCollapsed())return e.setFormat(t(e.format)),void yh(null);let n=[];for(let r of e.getNodes())B(r)?n.push(r):W(r)?r.setTextFormat(t(r.getTextFormat())):Rf(r)&&r.setFormat(t(r.getFormat()));let r=n.length;if(r===0)return e.setFormat(t(e.format)),void yh(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(dh(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||dh(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()||dh(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 up(e,t,n=null){let r=n===null&&V(e)?hh(e.format,t,null):n;lp(e,e=>hh(e,t,r))}function dp(e){let t=e.offset;if(e.type===`text`)return t;let n=e.getNode();return t===n.getChildrenSize()?n.getTextContent().length:0}function fp(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]:[dp(n),dp(r)]}function pp(e,t){for(let n=t;n;n=n.getParent()){if(W(n)){if(n.collapseAtStart(e))return!0;if(sg(n))break}if(n.getPreviousSibling())break}return!1}function mp(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 hp(e,t,n,r){e.modify(t,n,r)}function gp(e,t,n){let r=e.getNodes(),i=r.filter(e=>tg(e,n));if(i.length===0||i.length===r.length)return!1;let a=t?i[0]:i[i.length-1],o=W(a)?a:a.getParentOrThrow();return t?o.selectStart():o.selectEnd(),!0}function _p(e,t,n){if(Kp(e,`extend`,t,n))return;let r=U(),i=mg(rg(r));if(!i||typeof i.modify!=`function`)return;let a=r._blockCursorElement,o=r._rootElement,s=e.anchor,c=e.focus.getNode();o===null||a===null||!W(c)||c.isInline()||c.canBeEmpty()||pg(a,r,o);let l=e=>{let t=e.getNode(),n=r.getElementByKey(e.key);return n!==null&&e.type===`text`&&B(t)?Hg(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(Ip(i,h,g,h,g),hp(i,`move`,t?`backward`:`forward`,n),i.rangeCount===0)return;let _=Sg(i,o)||i.getRangeAt(0),v=_.startContainer,y=_.startOffset;if(p&&n===`character`&&s.type===`text`&&B(u)&&u.isUnmergeable()&&f===(t?0:u.getTextContentSize())){let n=K_(u,t?`previous`:`next`).getNodeAtCaret();if(B(n)){let r=t?n.getTextContentSize()-1:1;e.focus.set(n.__key,r,`text`),e.dirty=!0;return}}if(p&&n===`character`&&s.type===`text`){let n=t?0:u.getTextContentSize(),r=v===d?y:f===n?-1:n;if(r>=0)return void(r!==f&&(e.focus.set(s.key,r,`text`),e.dirty=!0))}let[b,ee,te,ne]=t?[v,y,d,f]:[d,f,v,y],re=Em(u)?u:ag(u);e.applyDOMRange({collapsed:!1,endContainer:te,endOffset:ne,startContainer:b,startOffset:ee}),e.dirty=!0,!gp(e,t,re)&&t&&mp(e),n===`lineboundary`&&Kp(e,`extend`,t,n,`decorators`)}let vp=(()=>{try{let e=RegExp(`\\p{Emoji}`,`u`),t=e.test.bind(e);if(t(`❤️`)&&t(`#️⃣`)&&t(`👍`))return t}catch{}return()=>!1})();function yp(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 bp(e,t,n,r){let i,a=t,o=!1;if(J(e)){let s=!1,c=e.childNodes,l=c.length,u=r._blockCursorElement;a===l&&l>0&&(s=!0,a=l-1),wh(e,r)!==void 0||e_(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=jh(d),B(i))a=J_(i,s?`next`:`previous`);else{let c=jh(e);if(c===null)return null;if(W(c)){let o=r.getElementByKey(c.getKey());o===null&&I(214);let l=Bg(c,o,r);[c,a]=l.resolveChildIndex(c,o,e,t),W(c)||I(215),s&&a>=c.getChildrenSize()&&(a=Math.max(0,c.getChildrenSize()-1));let u=c.getChildAtIndex(a);if(W(u)&&function(e,t,n){let r=e.getParent();return n===null||r===null||!r.canBeEmpty()||r!==n.getNode()}(u,0,n)){let e=s?u.getLastDescendant():u.getFirstDescendant();e===null?c=u:(u=e,c=W(u)?u:u.getParentOrThrow()),a=0}B(u)?(i=u,c=null,a=J_(u,s?`next`:`previous`)):u!==c&&s&&!f&&(W(c)||I(216),a=Math.min(c.getChildrenSize(),a+1))}else{let n=m_(c),i=n===null?c:n,o=i.getIndexWithinParent(),s=r.getElementByKey(c.getKey()),l=`after`;if(s!==null&&jh(e)===c){let n=Bg(c,s,r);n.element===s?t===0&&G(c)&&(l=`before`):l=n.resolveLeafPosition(s,e,t)}a=l===`before`?o:o+1,c=i.getParentOrThrow()}if(W(c))return[ep(c.__key,a,`element`),o]}}else i=jh(e);return B(i)?[ep(i.__key,J_(i,a,`clamp`),`text`),o]:null}function xp(e,t,n){let r=e.offset,i=e.getNode();if(r===0){let r=i.getPreviousSibling(),a=i.getParent();if(t){if((n||!t)&&r===null&&W(a)&&a.isInline()){let t=a.getPreviousSibling();B(t)&&e.set(t.__key,t.getTextContent().length,`text`)}}else W(r)&&!n&&r.isInline()?e.set(r.__key,r.getChildrenSize(),`element`):B(r)&&!i.isUnmergeable()&&e.set(r.__key,r.getTextContent().length,`text`)}else if(r===i.getTextContent().length){let r=i.getNextSibling(),a=i.getParent();if(t&&W(r)&&r.isInline())e.set(r.__key,0,`element`);else if((n||t)&&r===null&&W(a)&&a.isInline()&&!a.canInsertTextAfter()&&a.getTextContentSize()>1){let t=a.getNextSibling();B(t)&&e.set(t.__key,0,`text`)}}}function Sp(e){let t=xh(e.key);return t===null?null:g_(t)}function Cp(e,t,n){let r=Sp(e),i=Sp(t);if(r===i||r!==null&&i!==null&&r.is(i))return!1;let a=n(r,i);if(r!==null)return W(r)?t.set(r.getKey(),a?r.getChildrenSize():0,`element`):t.set(r.getKey(),a?r.getTextContentSize():0,`text`),!0;let o=m_(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 wp(e){let t=Cp(e.anchor,e.focus,(t,n)=>function(e,t,n,r){if(n!==null&&r!==null){let e=m_(n),t=m_(r);if(e!==null&&e.is(t)){for(let t of __(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=m_(n),r=xh(t.key);return e===null||r===null||!(!e.is(r)&&!e.isParentOf(r))||e.isBefore(r)}let i=m_(r),a=xh(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 Tp(e,t,n,r,i,a){if(e===null||n===null||!oh(i,e,n))return null;let o=bp(e,t,V(a)?a.anchor:null,i);if(o===null)return null;let s=bp(n,r,V(a)?a.focus:null,i);if(s===null)return null;let[c,l]=o,[u,d]=s;if(c.type===`element`&&u.type===`element`){let t=jh(e),r=jh(n);if(G(t)&&G(r))return null}let f=i._slotsUsed&&Cp(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);xp(e,n,r),xp(t,!n,r),r&&t.set(e.key,e.offset,e.type)}}(c,u),[c,u,l||d||f]}function Ep(e){return W(e)&&!e.isInline()}function Dp(e,t,n,r,i,a){let o=im(),s=new sp(ep(e,t,i),ep(n,r,a),0,``);return s.dirty=!0,o._selection=s,s}function Op(){return new sp(ep(`root`,0,`element`),ep(`root`,0,`element`),0,``)}function kp(){return new ap(/* @__PURE__ */ new Set)}function Ap(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=!Ml&&(s||o===`beforeinput`||o===`compositionstart`||o===`compositionend`||o===`click`&&a&&a.detail===3||o===`drop`||o===void 0),l,u,d,f;if(V(e)&&!c)return e.clone();{if(t===null)return null;let r=wg(t,n._rootElement);if(l=r.anchorNode,u=r.focusNode,d=r.anchorOffset,f=r.focusOffset,(s||o===void 0)&&V(e)&&!oh(n,l,u))return e.clone()}let p=Tp(l,d,u,f,n,e);if(p===null)return null;let[m,h,g]=p,_=0,v=``;if(V(e)){let t=e.anchor;if(m.key===t.key)_=e.format,v=e.style;else{let e=m.getNode();B(e)?(_=e.getFormat(),v=e.getStyle()):W(e)&&(_=e.getTextFormat(),v=e.getTextStyle())}}let y=new sp(m,h,_,v);return g&&(y.dirty=!0),y}function H(){return im()._selection}function jp(){return U()._editorState._selection}function Mp(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`),Np(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`)}}Np(e)}function Np(e){let t=e.anchor,n=t.offset,r=e.focus,i=r.offset,a=t.getNode(),o=r.getNode();if(e.isCollapsed()){if(!W(a))return;let e=a.getChildrenSize(),i=n>=e,o=i?a.getChildAtIndex(e-1):a.getChildAtIndex(n);if(B(o)){let e=0;i&&(e=o.getTextContentSize()),t.set(o.__key,e,`text`),r.set(o.__key,e,`text`)}}else{if(W(a)){let e=a.getChildrenSize(),r=n>=e,i=r?a.getChildAtIndex(e-1):a.getChildAtIndex(n);if(B(i)){let e=0;r&&(e=i.getTextContentSize()),t.set(i.__key,e,`text`)}}if(W(o)){let e=o.getChildrenSize(),t=i>=e,n=t?o.getChildAtIndex(e-1):o.getChildAtIndex(i);if(B(n)){let e=0;t&&(e=n.getTextContentSize()),r.set(n.__key,e,`text`)}}}}function Pp(e,t,n,r,i){let a=null,o=0,s=null;r===null?i!==null&&(a=i.__key,B(i)?s=`text`:W(i)&&(s=`element`)):(a=r.__key,B(r)?(o=r.getTextContentSize(),s=`text`):W(r)&&(o=r.getChildrenSize(),s=`element`)),a!==null&&s!==null?e.set(a,o,s):(o=t.getIndexWithinParent(),o===-1&&(o=n.getChildrenSize()),e.set(n.__key,o,`element`))}function Fp(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 Ip(e,t,n,r,i){try{e.setBaseAndExtent(t,n,r,i)}catch{}}function Lp(e,t,n){let r=Xh(e,t.getKey());if(W(t)){let i=Bg(t,r,e);return[i.element,n+i.getFirstChildOffset()]}return[r,n]}function Rp(e,t,n,r,i,a){let o=a.getRootNode(),s=ph(o)||gg(o)?kg(o):null;if(i.has(`collaboration`)&&s!==a||s!==null&&ah(s,s))return;let c=wg(r,a),l;if(!V(t))return void(e!==null&&oh(n,c.anchorNode,c.focusNode)&&r.removeAllRanges());let u=t.anchor,d=t.focus,f=u.getNode(),p=d.getNode(),[m,h]=Lp(n,f,u.offset),[g,_]=Lp(n,p,d.offset),v=t.format,y=t.style,b=t.isCollapsed(),ee=m,te=g,ne=!1;if(u.type===`text`?(ee=B(f)?Hg(f,m,n):null,ne=f.getFormat()!==v||f.getStyle()!==y):V(e)&&e.anchor.type===`text`&&(ne=!0),d.type===`text`&&(te=B(p)?Hg(p,g,n):null),ee!==null&&te!==null){if(b&&(e===null||ne||V(e)&&(e.format!==v||e.style!==y))&&function(e,t,n,r,i,a){e._inputState.collapsedSelectionFormat={format:t,key:i,offset:r,style:n,timeStamp:a}}(n,v,y,h,u.key,performance.now()),(r.type!==`Range`||!b)&&c.anchorOffset===h&&c.focusOffset===_&&c.anchorNode===ee&&c.focusNode===te){if(s===null||!a.contains(s)){let e=s===null?null:ch(s);e!==null&&e!==n||i.has(`skip-selection-focus`)||a.focus({preventScroll:!0})}if(u.type!==`element`)return}if(Ip(r,ee,h,te,_),tl&&t.isCollapsed()&&a!==null&&!i.has(`skip-selection-focus`)){let e=Og(a);if(e===null||!a.contains(e)){let e=kg(a.ownerDocument),t=e===null?null:ch(e);t!==null&&t!==n||a.focus({preventScroll:!0})}}if(!i.has(`skip-scroll-into-view`)&&t.isCollapsed()&&a!==null&&a===Og(a)){let e=V(t)&&t.anchor.type===`element`?ee.childNodes[h]||null:(l===void 0&&(l=Cg(r,a)),l);if(e!==null){let t;if(fh(e)){let n=e.ownerDocument.createRange();n.selectNode(e),t=n.getBoundingClientRect()}else t=e.getBoundingClientRect();(function(e,t,n){let r=Qh(n),i=ng(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=rg(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=Zh(u)}})(n,t,a)}}(function(e){e._inputState.isSelectionChangeFromDOMUpdate=!0})(n)}}function zp(e,t){for(let n of e.split(/(\r?\n|\t)/))n===`
|
|
138
|
+
`)e.preventDefault(),q(r,lp);else if(o==null&&e.dataTransfer){let t=e.dataTransfer.getData(`text/plain`);e.preventDefault(),a.insertRawText(t)}else o!=null&&Qp(a,n,o,e.timeStamp,!0)?(e.preventDefault(),q(r,up,o),im(o)):i.unprocessedBeforeInputData=o;return i.lastBeforeInputInsertTextTimeStamp=e.timeStamp,!0}switch(e.preventDefault(),t){case`insertFromYank`:case`insertFromDrop`:case`insertReplacementText`:q(r,up,e),im((e.dataTransfer?e.dataTransfer.getData(`text/plain`):null)??e.data);break;case`insertFromComposition`:{let t=i.hadOrphanedCompositionEvents;i.hadOrphanedCompositionEvents=!1;let n=r._compositionKey;S_(null),t||q(r,up,e),fm(n);break}case`insertLineBreak`:S_(null),q(r,cp,!1);break;case`insertParagraph`:S_(null),i.isInsertLineBreak&&!ad?(i.isInsertLineBreak=!1,q(r,cp,!1)):q(r,lp);break;case`insertFromPaste`:case`insertFromPasteAsQuotation`:q(r,dp,e);break;case`deleteByComposition`:(function(e,t){return e!==t||W(e)||W(t)||!p_(e)||!p_(t)})(l,u)&&q(r,fp,e);break;case`deleteByDrag`:nv(Am),q(r,fp,e);break;case`deleteByCut`:q(r,fp,e);break;case`deleteContent`:q(r,sp,!1);break;case`deleteWordBackward`:q(r,pp,!0);break;case`deleteWordForward`:q(r,pp,!1);break;case`deleteHardLineBackward`:case`deleteSoftLineBackward`:q(r,mp,!0);break;case`deleteContentForward`:case`deleteHardLineForward`:case`deleteSoftLineForward`:q(r,mp,!1);break;case`formatStrikeThrough`:q(r,hp,`strikethrough`);break;case`formatBold`:q(r,hp,`bold`);break;case`formatItalic`:q(r,hp,`italic`);break;case`formatUnderline`:q(r,hp,`underline`);break;case`historyUndo`:q(r,gp);break;case`historyRedo`:q(r,_p)}return!0}function lm(e){let t=U(),n=t._inputState,r=H(),i=e.data,a=rm(e),o=!1;if(i!=null&&V(r)){let s=_v(ov(t)),c=s===null?null:Dv(s,t._rootElement),l=e.inputType===`insertCompositionText`&&n.compositionPhase!==`ending-firefox`&&!t.isComposing();l&&(n.hadOrphanedCompositionEvents=!0);let u=r.anchor.getNode(),d=e.inputType===`insertCompositionText`&&n.compositionPhase!==`ending-firefox`&&t.isComposing()&&B(u)&&m_(u);if(!l&&!d&&Qp(r,a,i,e.timeStamp,!1,c)){if(o=!0,n.compositionPhase===`ending-firefox`){let e=pm(t,i);if(n.compositionPhase=`idle`,e)return nv(jm),N_(),!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;id&&!r.isCollapsed()&&B(a)&&c.anchorNode!==null&&a.getTextContent().slice(0,u)+i+a.getTextContent().slice(u+d)===R_(c.anchorNode)||q(t,up,i);let f=i.length;rd&&f>1&&e.inputType===`insertCompositionText`&&!t.isComposing()&&(r.anchor.offset-=f,r._cachedNodes=null,r._cachedIsBackward=null),ld&&t.isComposing()&&(n.lastKeyDownTimeStamp=0,S_(null))}}return o||(z_(!1,t,i===null?void 0:i),n.compositionPhase===`ending-firefox`&&(pm(t,i||void 0),nv(`composition-end`),n.compositionPhase=`idle`)),N_(),!0}function um(e){let t=U(),n=t._inputState,r=H();if(V(r)&&!t.isComposing()){n.compositionPhase=`composing`,n.hadOrphanedCompositionEvents=!1;let i=r.anchor,a=r.anchor.getNode();if(S_(i.key),nv(`composition-start`),e.timeStamp<n.lastKeyDownTimeStamp+30||i.type===`element`||!r.isCollapsed()||!ld&&(a.getFormat()!==r.format||B(a)&&a.getStyle()!==r.style)||B(a)&&(m_(a)||i.offset===0&&!a.canInsertTextBefore()||i.offset===a.getTextContentSize()&&!a.canInsertTextAfter())){q(t,up,fd);let e=H();V(e)&&S_(e.anchor.key)}}return!0}function dm(e){let t=U();return t._inputState.compositionPhase=`idle`,pm(t,e.data),nv(jm),!0}function fm(e){if(e===null)return;let t=w_(e);if(!B(t)||t.getType()===`text`||m_(t)||!t.isAttached())return;let n=H(),r=V(n)&&n.anchor.key===e?n.anchor.offset:null,i=Zm(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 pm(e,t){let n=e._compositionKey;if(S_(null),n!==null&&t!=null){if(t===``){let t=w_(n),r=e.getElementByKey(n),i=r!==null&&B(t)?Gv(t,r,e):null;if(i!==null&&i.nodeValue!==null&&B(t)){let n=_v(ov(e)),r=n&&Dv(n,e._rootElement),a=null,o=null;r!==null&&r.anchorNode===i&&(a=r.anchorOffset,o=r.focusOffset),B_(t,i.nodeValue,a,o,!0)}return fm(n),!1}if(t[t.length-1]===`
|
|
139
|
+
`){let t=H();if(V(t)||dh(t)){if(V(t)){let e=t.focus;t.anchor.set(e.key,e.offset,e.type)}return q(e,Tp,null),fm(n),!1}}let r=w_(n);if(r!==null&&B(r)&&m_(r)){r.markDirty();let e=H(),i=r.getTextContentSize(),a=V(e)&&e.anchor.key===n?e.anchor.offset:i;return r.select(a,a).insertText(t),!0}}return z_(!0,e,t),fm(n),!1}function mm(e){let t=U(),n=t._inputState;if(e.key==null)return!0;if(n.compositionPhase===`ending-safari`){let r=K_(e);if(r&&Cg(t,()=>{pm(t,n.compositionEndData)}),n.compositionPhase=`idle`,n.compositionEndData=``,r)return!0}if(function(e){return K(e,`ArrowRight`,{shiftKey:`any`})}(e))q(t,yp,e);else if(function(e){return K(e,`ArrowRight`,{...W_,shiftKey:`any`})}(e))q(t,bp,e);else if(function(e){return K(e,`ArrowLeft`,{shiftKey:`any`})}(e))q(t,xp,e);else if(function(e){return K(e,`ArrowLeft`,{...W_,shiftKey:`any`})}(e))q(t,Sp,e);else if(function(e){return K(e,`ArrowUp`,{altKey:`any`,shiftKey:`any`})}(e))q(t,Cp,e);else if(function(e){return K(e,`ArrowDown`,{altKey:`any`,shiftKey:`any`})}(e))q(t,wp,e);else if(function(e){return K(e,`Enter`,{altKey:`any`,ctrlKey:`any`,metaKey:`any`,shiftKey:!0})}(e))n.isInsertLineBreak=!0,q(t,Tp,e);else if(function(e){return e.key===` `}(e))q(t,Ep,e);else if(function(e){return nd&&K(e,`o`,{ctrlKey:!0})}(e))e.preventDefault(),n.isInsertLineBreak=!0,q(t,cp,!0);else if(function(e){return K(e,`Enter`,{altKey:`any`,ctrlKey:`any`,metaKey:`any`})}(e))n.isInsertLineBreak=!1,q(t,Tp,e);else if(function(e){return K(e,`Backspace`,{shiftKey:`any`})||nd&&K(e,`h`,{ctrlKey:!0})}(e))K_(e)?q(t,Dp,e)&&om(n):(e.preventDefault(),q(t,sp,!0));else if(function(e){return e.key===`Escape`}(e))q(t,Op,e);else if(function(e){return K(e,`Delete`,{})||nd&&K(e,`d`,{ctrlKey:!0})}(e))(function(e){return e.key===`Delete`})(e)?q(t,kp,e):(e.preventDefault(),q(t,sp,!1));else if(function(e){return K(e,`Backspace`,G_)}(e))e.preventDefault(),q(t,pp,!0);else if(function(e){return K(e,`Delete`,G_)}(e))e.preventDefault(),q(t,pp,!1);else if(function(e){return nd&&K(e,`Backspace`,{metaKey:!0})}(e))e.preventDefault(),q(t,mp,!0);else if(function(e){return nd&&(K(e,`Delete`,{metaKey:!0})||K(e,`k`,{ctrlKey:!0}))}(e))e.preventDefault(),q(t,mp,!1);else if(function(e){return K(e,`b`,W_)}(e))e.preventDefault(),q(t,hp,`bold`);else if(function(e){return K(e,`u`,W_)}(e))e.preventDefault(),q(t,hp,`underline`);else if(function(e){return K(e,`i`,W_)}(e))e.preventDefault(),q(t,hp,`italic`);else if(function(e){return K(e,`Tab`,{shiftKey:`any`})}(e))q(t,Ap,e);else if(function(e){return K(e,`z`,W_)}(e))e.preventDefault(),q(t,gp);else if(function(e){return nd?K(e,`z`,{metaKey:!0,shiftKey:!0}):K(e,`y`,{ctrlKey:!0})||K(e,`z`,{ctrlKey:!0,shiftKey:!0})}(e))e.preventDefault(),q(t,_p);else{let r=t._editorState._selection;(function(e){return K(e,`a`,W_)})(e)?(e.preventDefault(),q(t,Lp,e)&&om(n)):r===null||V(r)||(function(e){return K(e,`c`,W_)}(e)?(e.preventDefault(),q(t,Fp,e)):function(e){return K(e,`x`,W_)}(e)&&(e.preventDefault(),q(t,Ip,e)))}return function(e){return e.ctrlKey||e.shiftKey||e.altKey||e.metaKey}(e)&&t.dispatchCommand(Wp,e),!0}function hm(e){let t=e.__lexicalEventHandles;return t===void 0&&(t=[],e.__lexicalEventHandles=t),t}let gm=/* @__PURE__ */ new Map;function _m(e){let t=vv(e.target);if(t===null)return;let n=tv(e.target),r=null,i=null,a=n===null?void 0:Xp.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&&yv(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=Dv(t,e).anchorNode;if(s!==null&&d_(s)===o){if(yv(e.getRootNode())){r=o,i=s;break}n===null&&(n=o,a=s)}}r===null&&n!==null&&(r=n,i=a)}else{let e=t.anchorNode;e===null||J(e)&&e.shadowRoot!==null||(r=d_(e),r!==null&&(i=e))}}if(r===null){let e=Mv(n);r=e===null?null:d_(e)}}if(r===null)return;if(r._inputState.isSelectionChangeFromMouseDown){if(a!==void 0)for(let e of a.editors)e._inputState.isSelectionChangeFromMouseDown=!1;Cg(r,()=>{let n=Ph(),a=i??Dv(t,r._rootElement).anchorNode;(J(a)||h_(a))&&M_(Nh(n,t,r,e))})}let o=I_(r),s=o[o.length-1],c=s._key,l=gm.get(c),u=l||s;u!==r&&em(t,u,!1),em(t,r,!0),r===s?l&&gm.delete(c):gm.set(c,r)}function vm(e){e._lexicalHandled=!0}function ym(e){return!0===e._lexicalHandled}function bm(e){let t=Yp.get(e);if(t===void 0)return;let n=Xp.get(t);if(n===void 0)return;Yp.delete(e);let r=f_(e);u_(r)?(function(e){if(e._parentEditor!==null){let t=I_(e),n=t[t.length-1]._key;gm.get(n)===e&&gm.delete(n)}else gm.delete(e._key)}(r),n.editors.delete(r),n.hasShadowEditor=void 0,e.__lexicalEditor=null):r&&I(198);let i=hm(e);for(let e=0;e<i.length;e++)i[e]();e.__lexicalEventHandles=[]}function xm(e,t,n){ag();let r=e.__key,i=e.getParent();if(i===null)return void(gy(e)!==null&&I(367,r,String(gy(e))));let a=function(e){let t=H();if(!V(t)||!W(e))return t;let{anchor:n,focus:r}=t,i=n.getNode(),a=r.getNode();return iv(i,e)&&n.set(e.__key,0,`element`),iv(a,e)&&r.set(e.__key,0,`element`),t}(e),o=!1;if(V(a)&&t){let t=a.anchor,n=a.focus;t.key===r&&(Lh(t,e,i,e.getPreviousSibling(),e.getNextSibling()),o=!0),n.key===r&&(Lh(n,e,i,e.getPreviousSibling(),e.getNextSibling()),o=!0)}else dh(a)&&t&&e.isSelected()&&e.selectPrevious();if(V(a)&&t&&!o){let t=e.getIndexWithinParent();b_(e),Fh(a,i,t,-1)}else b_(e);n||uv(i)||i.canBeEmpty()||!i.isEmpty()||xm(i,t),t&&a&&kg(i)&&i.isEmpty()&&i.selectEnd()}let Sm=Symbol.for(`ephemeral`);function Cm(e){return e[Sm]||!1}let wm={configurable:!0,enumerable:!1,value:void 0,writable:!0};var Tm=class{__type;__key;__parent;__prev;__next;__state;[cf];static getType(){let{ownNodeType:e}=sy(this);return e===void 0&&I(64,this.name),e}static clone(e){I(65,this.name)}$config(){return{}}config(e,t){let n=t.extends||fy(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",wm),Object.defineProperty(this,cf,wm),y_(this,e)}getType(){return this.__type}isInline(){I(137,this.constructor.name)}isAttached(){let e=this.__key;for(;e!==null;){if(e===`root`)return!0;let t=w_(e);if(t===null)break;e=t.__parent===null?gy(t):t.__parent}return!1}isSelected(e){let t=e||H();if(t==null)return!1;let n=t.getNodes().some(e=>e.__key===this.__key);if(B(this))return n;if(V(t)&&t.anchor.type===`element`&&t.focus.type===`element`){if(t.isCollapsed())return!1;let e=this.getParent();if(G(this)&&this.isInline()&&e){let n=t.isBackward()?t.focus:t.anchor;if(e.is(n.getNode())&&n.offset===e.getChildrenSize()&&this.is(e.getLastChild()))return!1}}return n}getKey(){return this.__key}getIndexWithinParent(){let e=this.getParent();if(e===null)return-1;let t=e.getFirstChild(),n=0;for(;t!==null;){if(this.is(t))return n;n++,t=t.getNextSibling()}return-1}getParent(){let e=this.getLatest().__parent;return e===null?null:w_(e)}getParentOrThrow(){let e=this.getParent();return e===null&&I(66,this.__key),e}getTopLevelElement(){let e=this;for(;e!==null;){let t=e.getParent();if(uv(t)||gy(e)!==null)return W(e)||e===this&&G(e)||I(194),e;e=t}return null}getTopLevelElementOrThrow(){let e=this.getTopLevelElement();return e===null&&I(67,this.__key),e}getParents(){let e=[],t=this.getParent();for(;t!==null;)e.push(t),t=t.getParent();return e}getParentKeys(){let e=[],t=this.getParent();for(;t!==null;)e.push(t.__key),t=t.getParent();return e}getPreviousSibling(){let e=this.getLatest().__prev;return e===null?null:w_(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:w_(e)}getNextSiblings(){let e=[],t=this.getNextSibling();for(;t!==null;)e.push(t),t=t.getNextSibling();return e}getCommonAncestor(e){let t=W(this)?this:this.getParent(),n=W(e)?e:e.getParent(),r=t&&n?fb(t,n):null;return r?r.commonAncestor:null}is(e){return e!=null&&this.__key===e.__key}isBefore(e){let t=fb(this,e);return t!==null&&(t.type===`descendant`||(t.type===`branch`?lb(t)===-1:(t.type!==`same`&&t.type!==`ancestor`&&I(279),!1)))}isParentOf(e){return iv(e,this)}getNodesBetween(e){let t=this.isBefore(e),n=[],r=/* @__PURE__ */ new Set,i=this;for(;i!==null;){let a=i.__key;if(r.has(a)||(r.add(a),n.push(i)),i===e)break;let o=W(i)?t?i.getFirstChild():i.getLastChild():null;if(o!==null){i=o;continue}let s=t?i.getNextSibling():i.getPreviousSibling();if(s!==null){i=s;continue}let c=i.getParentOrThrow();if(r.has(c.__key)||n.push(c),c===e)break;let l=null,u=c;do{if(u===null&&I(68),l=t?u.getNextSibling():u.getPreviousSibling(),u=u.getParent(),u===null)break;l!==null||r.has(u.__key)||n.push(u)}while(l===null);i=l}return t||n.reverse(),n}isDirty(){let e=U()._dirtyLeaves;return e!==null&&e.has(this.__key)}getLatest(){if(Cm(this))return this;let e=w_(this.__key);return e===null&&I(113),e}getWritable(){if(Cm(this))return this;ag();let e=sg(),t=U(),n=e._nodeMap,r=this.__key,i=this.getLatest(),a=t._cloneNotNeeded,o=H();if(o!==null&&o.setCachedNodes(null),a.has(r))return x_(i),i;let s=Yv(i);return a.add(r),x_(s),n.set(r,s),s}getTextContent(){return ky(this)}getTextContentSize(){return this.getTextContent().length}createDOM(e,t){I(70)}updateDOM(e,t,n){I(71)}getDOMSlot(e){return new wd(e)}exportDOM(e){return{element:this.createDOM(e._config,e)}}exportJSON(){let e=this.__state?this.__state.toJSON():void 0;return{type:this.__type,version:1,...e}}static importJSON(e){I(18,this.name)}updateFromJSON(e){return function(e,t){let n=e.getWritable(),r=t.$,i=r;for(let e of Xd(n).flatKeys)e in t&&(i!==void 0&&i!==r||(i={...r}),i[e]=t[e]);return(n.__state||i)&&Yd(e).updateFromJSON(i),n}(this,e)}static transform(){return null}remove(e){xm(this,!0,e)}replace(e,t){ag();let n=H();n!==null&&(n=n.clone()),pv(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();b_(o),l!==null&&V(n)&&Fh(n,l,u,-1);let d=r.getPreviousSibling(),f=r.getNextSibling(),p=r.__prev,m=r.__next,h=r.__parent;xm(r,!1,!0),d===null?s.__first=a:d.getWritable().__next=a,o.__prev=p,f===null?s.__last=a:f.getWritable().__prev=a,o.__next=m,o.__parent=h,s.__size=c;let g=0;t&&(W(this)&&W(o)||I(139),g=o.getChildrenSize(),o.splice(g,0,this.getChildren()));let _=xy(this);if(_.length>0){my(this)&&my(o)||I(368,this.__key,o.__key);for(let e of _){let t=Sy(this,e);t!==null&&(Ny(this,e),My(o,e,t))}}if(V(n)){M_(n);let e=n.anchor,r=n.focus;e.key===i&&(t&&e.type===`element`?e.set(o.__key,g+e.offset,`element`):ah(e,o)),r.key===i&&(t&&r.type===`element`?r.set(o.__key,g+r.offset,`element`):ah(r,o))}return C_()===i&&S_(a),o}insertAfter(e,t=!0){ag(),pv(this,e);let n=this.getWritable(),r=e.getWritable();this.getParentOrThrow();let i=r.getParent(),a=H(),o=!1,s=!1;if(i!==null){let n=e.getIndexWithinParent();if(V(a)){let e=i.__key,t=a.anchor,r=a.focus;o=t.type===`element`&&t.key===e&&t.offset===n+1,s=r.type===`element`&&r.key===e&&r.offset===n+1}b_(r),t&&V(a)&&Fh(a,i,n,-1)}else b_(r);let c=this.getNextSibling(),l=this.getParentOrThrow().getWritable(),u=r.__key,d=n.__next;if(c===null?l.__last=u:c.getWritable().__prev=u,l.__size++,n.__next=u,r.__next=d,r.__prev=n.__key,r.__parent=n.__parent,t&&V(a)){let e=this.getIndexWithinParent();Fh(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){ag(),pv(this,e);let n=this.getWritable(),r=e.getWritable();this.getParentOrThrow();let i=r.__key,a=H(),o=r.getParent(),s=o===null?-1:r.getIndexWithinParent();b_(r),o!==null&&t&&V(a)&&Fh(a,o,s,-1);let c=this.getPreviousSibling(),l=this.getParentOrThrow().getWritable(),u=n.__prev,d=this.getIndexWithinParent();return c===null?l.__first=i:c.getWritable().__next=i,l.__size++,n.__prev=i,r.__prev=u,r.__next=n.__key,r.__parent=n.__parent,t&&V(a)&&Fh(a,this.getParentOrThrow(),d),e}isParentRequired(){return!1}createParentElementNode(){return Gg()}selectStart(){return this.selectPrevious()}selectEnd(){return this.selectNext(0,0)}selectPrevious(e,t){ag();let n=_y(this);if(n!==null)return n.selectPrevious(e,t);let r=this.getPreviousSibling(),i=this.getParentOrThrow();if(r===null)return i.select(0,0);if(W(r))return r.select();if(!B(r)){let e=r.getIndexWithinParent()+1;return i.select(e,e)}return r.select(e,t)}selectNext(e,t){ag();let n=_y(this);if(n!==null)return n.selectNext(e,t);let r=this.getNextSibling(),i=this.getParentOrThrow();if(r===null)return i.select();if(W(r))return r.select(0,0);if(!B(r)){let e=r.getIndexWithinParent();return i.select(e,e)}return r.select(e,t)}markDirty(){this.getWritable()}reconcileObservedMutation(e,t){this.markDirty()}};function Em(e){return e instanceof Tm}let Dm=`history-merge`,Om=`paste`,km=`skip-dom-selection`,Am=`skip-selection-focus`,jm=`composition-end`;function Mm(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 Nm(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 Pm(e,t,n=``){if(t===n)return;let r=Mm(n),i=Mm(t);for(let t in i)delete r[t],Nm(e,t,i[t]);for(let t in r)e.removeProperty(t)}function Fm(e,t){return 16&t?`code`:t&128?`mark`:32&t?`sub`:64&t?`sup`:null}function Im(e,t){return 1&t?`strong`:2&t?`em`:`span`}function Lm(e,t,n,r,i){let a=r.classList,o=J_(i,`base`);o!==void 0&&a.add(...o),o=J_(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 hd){let r=hd[e];if(o=J_(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 Rm(e,t,n){let r=n.isComposing(),i=e+(r?dd:``),a=Vv(),o=Hv(a).$getDOMSlot(n,t,a),s=o.getFirstChild();if(s===null||s.nodeType!==Node.TEXT_NODE)return void o.insertChild(wv().createTextNode(i));let c=s,l=c.nodeValue;if(l!==i){if(r||rd){let[e,t,n]=function(e,t){let n=e.length,r=t.length,i=0,a=0;for(;i<n&&i<r&&e[i]===t[i];)i++;for(;a+i<n&&a+i<r&&e[n-a-1]===t[r-a-1];)a++;return[i,n-i-a,t.slice(i,r-a)]}(l,i);t!==0&&c.deleteData(e,t),c.insertData(e,n)}else c.nodeValue=i}}function zm(e,t,n,r,i,a){Rm(i,e,t);let o=a.theme.text;o!==void 0&&Lm(0,0,r,e,o)}function Bm(e,t){let n=wv().createElement(t);return n.appendChild(e),n}function Vm(e){return e!=null&&!0===e.__isInlineFormattable}var Hm=class extends Tm{__text;__format;__style;__mode;__detail;get __isInlineFormattable(){return!0}$config(){return this.config(`text`,{importDOM:{"#text":()=>({conversion:qm,priority:0}),b:()=>({conversion:Wm,priority:0}),code:()=>({conversion:Xm,priority:0}),em:()=>({conversion:Xm,priority:0}),i:()=>({conversion:Xm,priority:0}),mark:()=>({conversion:Xm,priority:0}),s:()=>({conversion:Xm,priority:0}),span:()=>({conversion:Um,priority:0}),strong:()=>({conversion:Xm,priority:0}),sub:()=>({conversion:Xm,priority:0}),sup:()=>({conversion:Xm,priority:0}),u:()=>({conversion:Xm,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 bd[e.__mode]}getStyle(){return this.getLatest().__style}isToken(){return this.getLatest().__mode===1}isComposing(){return this.__key===C_()}isSegmented(){return this.getLatest().__mode===2}isDirectionless(){return!!(1&this.getLatest().__detail)}isUnmergeable(){return!!(2&this.getLatest().__detail)}hasFormat(e){let t=hd[e];return(this.getFormat()&t)!==0}isSimpleText(){return this.__type===`text`&&this.__mode===0}getTextContent(){return this.getLatest().__text}getFormatFlags(e,t){return v_(this.getLatest().__format,e,t)}canHaveFormat(){return!0}isInline(){return!0}createDOM(e,t){let n=this.__format,r=Fm(0,n),i=Im(0,n),a=r===null?i:r,o=wv().createElement(a),s=o;this.hasFormat(`code`)&&o.setAttribute(`spellcheck`,`false`),r!==null&&(s=wv().createElement(i),o.appendChild(s)),zm(s,this,0,n,this.__text,e);let c=this.__style;return c!==``&&Pm(o.style,c),o}updateDOM(e,t,n){let r=this.__text,i=e.__format,a=this.__format,o=Fm(0,i),s=Fm(0,a),c=Im(0,i),l=Im(0,a);if((o===null?c:o)!==(s===null?l:s))return!0;if(o===s&&c!==l){let e=t.firstChild;e??I(48);let i=wv().createElement(l);return zm(i,this,0,a,r,n),t.replaceChild(i,e),!1}let u=t;s!==null&&o!==null&&(u=t.firstChild,u??I(49)),Rm(r,u,this);let d=n.theme.text;d!==void 0&&i!==a&&Lm(0,i,a,u,d);let f=e.__style,p=this.__style;return f!==p&&Pm(t.style,p,f),!1}updateFromJSON(e){return super.updateFromJSON(e).setTextContent(e.text).setFormat(e.format).setDetail(e.detail).setMode(e.mode).setStyle(e.style)}exportDOM(e){let{element:t}=super.exportDOM(e);return J(t)||I(132),t.style.whiteSpace=`pre-wrap`,this.hasFormat(`lowercase`)?t.style.textTransform=`lowercase`:this.hasFormat(`uppercase`)?t.style.textTransform=`uppercase`:this.hasFormat(`capitalize`)&&(t.style.textTransform=`capitalize`),this.hasFormat(`bold`)&&(t=Bm(t,`b`)),this.hasFormat(`italic`)&&(t=Bm(t,`i`)),this.hasFormat(`strikethrough`)&&(t=Bm(t,`s`)),this.hasFormat(`underline`)&&(t=Bm(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`?hd[e]:e,t}setDetail(e){let t=this.getWritable();return t.__detail=typeof e==`string`?gd[e]:e,t}setStyle(e){let t=this.getWritable();return t.__style=e,t}toggleFormat(e){let t=v_(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=yd[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){ag();let n=e,r=t,i=H(),a=this.getTextContent(),o=this.__key;if(typeof a==`string`){let e=a.length;n===void 0&&(n=e),r===void 0&&(r=e)}else n=0,r=0;if(!V(i))return Ah(o,n,o,r,`text`,`text`);{let e=C_();e!==i.anchor.key&&e!==i.focus.key||S_(o),i.setTextNodeRange(this,n,this,r)}return i}selectStart(){return this.select(0,0)}selectEnd(){let e=this.getTextContentSize();return this.select(e,e)}spliceText(e,t,n,r){let i=this.getWritable(),a=i.__text,o=n.length,s=e;s<0&&(s=o+s,s<0&&(s=0));let c=H();if(r&&V(c)){let t=e+o;c.setTextNodeRange(i,t,i,t)}return i.__text=a.slice(0,s)+n+a.slice(s+t),i}canInsertTextBefore(){return!0}canInsertTextAfter(){return!0}splitText(...e){ag();let t=this.getLatest(),n=t.getTextContent();if(n===``)return[];let r=t.__key,i=C_(),a=n.length;e.sort((e,t)=>e-t),e.push(a);let o=[],s=e.length;for(let t=0,r=0;t<a&&r<=s;r++){let i=e[r];i>t&&(o.push(n.slice(t,i)),t=i)}let c=o.length;if(c===1)return[t];let l=o[0],u=t.getParent(),d,f=t.getFormat(),p=t.getStyle(),m=t.__detail,h=!1,g=null,_=null,v=H();if(V(v)){let[e,t]=v.isBackward()?[v.focus,v.anchor]:[v.anchor,v.focus];e.type===`text`&&e.key===r&&(g=e),t.type===`text`&&t.key===r&&(_=t)}t.isSegmented()?(d=Zm(l),d.__format=f,d.__style=p,d.__detail=m,d.__state=tf(t,d),h=!0):d=t.setTextContent(l);let y=[d];for(let e=1;e<c;e++){let n=Zm(o[e]);n.__format=f,n.__style=p,n.__detail=m,n.__state=tf(t,n);let a=n.__key;i===r&&S_(a),y.push(n)}let b=g?g.offset:null,x=_?_.offset:null,ee=0;for(let e of y){if(!g&&!_)break;let t=ee+e.getTextContentSize();if(g!==null&&b!==null&&b<=t&&b>=ee&&(g.set(e.getKey(),b-ee,`text`),b<t&&(g=null)),_!==null&&x!==null&&x<=t&&x>=ee){_.set(e.getKey(),x-ee,`text`);break}ee=t}if(u!==null){(function(e){let t=e.getPreviousSibling(),n=e.getNextSibling();t!==null&&x_(t),n!==null&&x_(n)})(this);let e=u.getWritable(),t=this.getIndexWithinParent();h?(e.splice(t,0,y),this.remove()):e.splice(t,1,y),V(v)&&Fh(v,u,t,c-1)}return y}mergeWithSibling(e){let t=e===this.getPreviousSibling();t||e===this.getNextSibling()||I(50);let n=this.__key,r=e.__key,i=this.__text,a=i.length;C_()===r&&S_(n);let o=H();if(V(o)){let i=o.anchor,s=o.focus;i!==null&&i.key===r&&Rh(i,t,n,e,a),s!==null&&s.key===r&&Rh(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 Um(e){return{forChild:Qm(e.style),node:null}}function Wm(e){let t=e,n=t.style.fontWeight===`normal`;return{forChild:Qm(t.style,n?void 0:`bold`),node:null}}let Gm=/* @__PURE__ */ new WeakMap;function Km(e){if(!J(e))return!1;if(e.nodeName===`PRE`)return!0;let t=e.style.whiteSpace;return typeof t==`string`&&t.startsWith(`pre`)}function qm(e){let t=e;e.parentElement===null&&I(129);let n=t.textContent||``;if(function(e){let t,n=e.parentNode,r=[e];for(;n!==null&&(t=Gm.get(n))===void 0&&!Km(n);)r.push(n),n=n.parentNode;let i=t===void 0?n:t;for(let e=0;e<r.length;e++)Gm.set(r[e],i);return i}(t)!==null)return{node:Uh(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=Jm(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=Jm(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:Zm(n)}}function Jm(e,t){let n=e;for(;;){let e;for(;(e=t?n.nextSibling:n.previousSibling)===null;){let e=n.parentElement;if(e===null)return null;n=e}if(n=e,J(n)){let e=n.style.display;if(e===``&&!Lv(n)||e!==``&&!e.startsWith(`inline`))return null}let r=n;for(;(r=t?n.firstChild:n.lastChild)!==null;)n=r;if(h_(n))return n;if(n.nodeName===`BR`)return null}}let Ym={code:`code`,em:`italic`,i:`italic`,mark:`highlight`,s:`strikethrough`,strong:`bold`,sub:`subscript`,sup:`superscript`,u:`underline`};function Xm(e){let t=Ym[e.nodeName.toLowerCase()];return t===void 0?{node:null}:{forChild:Qm(e.style,t),node:null}}function Zm(e=``){return fv(new Hm(e))}function B(e){return e instanceof Hm}function Qm(e,t){let n=e.fontWeight,r=e.textDecoration.split(` `),i=n===`700`||n===`bold`,a=r.includes(`line-through`),o=e.fontStyle===`italic`,s=r.includes(`underline`),c=e.verticalAlign;return e=>((B(e)||Vm(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 $m=class extends Hm{$config(){return this.config(`tab`,{extends:Hm})}constructor(e=void 0){super(` `,e),this.__detail=2}createDOM(e){let t=super.createDOM(e),n=J_(e.theme,`tab`);return n!==void 0&&t.classList.add(...n),t}setTextContent(e){return super.setTextContent(` `)}spliceText(e,t,n,r){return n===``&&t===0||n===` `&&t===1||I(286),this}setDetail(e){return e!==2&&I(127),this}setMode(e){return e!==`normal`&&I(128),this}canInsertTextBefore(){return!1}canInsertTextAfter(){return!1}};function eh(){return fv(new $m)}function th(e){return e instanceof $m}var nh=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:cb(Sb(pb(this,`next`)),Sb(pb(e,`next`)))<0}getNode(){let e=w_(this.key);return e===null&&I(20),e}set(e,t,n,r){let i=this._selection,a=this.key;r&&this.key===e&&this.offset===t&&this.type===n||(this.key=e,this.offset=t,this.type=n,ig()||(C_()===a&&S_(e),i!==null&&(i.setCachedNodes(null),V(i)&&(i._cachedIsBackward=null),i.dirty=!0)))}};function rh(e,t,n){return new nh(e,t,n)}function ih(e,t){let n=t.__key,r=e.offset,i=`element`;if(B(t)){i=`text`;let e=t.getTextContentSize();r>e&&(r=e)}else if(!W(t)){let e=t.getNextSibling();if(B(e))n=e.__key,r=0,i=`text`;else{let e=t.getParent();e&&(n=e.__key,r=t.getIndexWithinParent()+1)}}e.set(n,r,i)}function ah(e,t){if(W(t)){let n=t.getLastDescendant();W(n)||B(n)?ih(e,n):ih(e,t)}else ih(e,t)}function oh(e,t,n,r){let i=e.getNode(),a=i.getChildAtIndex(e.offset),o=Zm();if(o.setFormat(n),o.setStyle(r),Kg(a))a.splice(0,0,[o]);else if(a!==null){let e=uv(i)?Gg().append(o):o;a.insertBefore(e)}else if(uv(i)){let e=i.getLastChild();W(e)&&!e.isInline()&&e.isEmpty()?e.append(o):i.append(Gg().append(o))}else i.append(o);e.is(t)&&t.set(o.__key,0,`text`),e.set(o.__key,0,`text`)}function sh(e,t,n,r){let i=e.anchor.getNode();B(i)||I(398);let a=e.anchor.offset,o=Zm(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 ch=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(!dh(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=>gy(e)===null),n=t.length;if(n===0)return;let r=t[n-1],i;if(B(r))i=r.select();else{let e=r.getIndexWithinParent()+1;i=r.getParentOrThrow().select(e,e)}i.insertNodes(e);for(let e=0;e<n;e++)t[e].remove()}getNodes(){let e=this._cachedNodes;if(e!==null)return e;let t=this._nodes,n=[];for(let e of t){let t=w_(e);t!==null&&n.push(t)}return ig()||(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=>gy(e)===null);if((H()||Ph())===this&&e[0]){let t=Yy(e[0],`next`);hb(ob(t,t))}for(let t of e)t.remove();lh()}};function lh(){let e=j_();if(e.isEmpty()){let t=Gg();e.append(t),t.select()}}function V(e){return e instanceof uh}var uh=class e{format;style;anchor;focus;_cachedNodes;_cachedIsBackward;dirty;constructor(e,t,n,r){this.anchor=e,this.focus=t,e._selection=this,t._selection=this,this._cachedNodes=null,this._cachedIsBackward=null,this.format=n,this.style=r,this.dirty=!1}getCachedNodes(){return this._cachedNodes}setCachedNodes(e){this._cachedNodes=e}is(e){return!!V(e)&&this.anchor.is(e.anchor)&&this.focus.is(e.focus)&&this.format===e.format&&this.style===e.style}isCollapsed(){return this.anchor.is(this.focus)}getNodes(){let e=this._cachedNodes;if(e!==null)return e;let t=function(e){let t=[],[n,r]=e.getTextSlices();n&&t.push(n.caret.origin);let i=/* @__PURE__ */ new Set,a=/* @__PURE__ */ new Set;for(let n of e)if(Gy(n)){let{origin:e}=n;t.length===0?i.add(e):(a.add(e),t.push(e))}else{let{origin:e}=n;W(e)&&a.has(e)||t.push(e)}if(r&&t.push(r.caret.origin),Wy(e.focus)&&W(e.focus.origin)&&e.focus.getNodeAtCaret()===null)for(let n=$y(e.focus.origin,`previous`);Gy(n)&&i.has(n.origin)&&!n.origin.isEmpty()&&n.origin.is(t[t.length-1]);n=tb(n))i.delete(n.origin),t.pop();for(;t.length>1;){let e=t[t.length-1];if(!W(e)||a.has(e)||e.isEmpty()||i.has(e))break;t.pop()}if(t.length===0&&e.isCollapsed()){let n=Sb(e.anchor),r=Sb(e.anchor.getFlipped()),i=e=>Uy(e)?e.origin:e.getNodeAtCaret(),a=i(n)||i(r)||(e.anchor.getNodeAtCaret()?n.origin:r.origin);t.push(a)}return t}(Tb(_b(this),`next`));return ig()||(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]=hh(this),c=``,l=!0;for(let u=0;u<e.length;u++){let d=e[u];if(W(d)&&!d.isInline()){l||(c+=`
|
|
140
|
+
`);let e=``;for(let t of xy(d)){let n=Sy(d,t);n!==null&&(e+=n.getTextContent())}e===``?l=!d.isEmpty():(c+=e,l=!1)}else if(l=!1,B(d)){let e=d.getTextContent();d===t?d===n?r.type===`element`&&i.type===`element`&&i.offset!==r.offset||(e=o<s?e.slice(o,s):e.slice(s,o)):e=a?e.slice(o):e.slice(s):d===n&&(e=a?e.slice(0,s):e.slice(0,o)),c+=e}else!G(d)&&!zg(d)||d===n&&this.isCollapsed()||(c+=d.getTextContent())}return c}applyDOMRange(e){let t=U(),n=t.getEditorState()._selection,r=Oh(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),of(this)}clone(){let t=this.anchor,n=this.focus;return new e(rh(t.key,t.offset,t.type),rh(n.key,n.offset,n.type),this.format,this.style)}toggleFormat(e){this.format=v_(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=hd[e];return(this.format&t)!==0}insertRawText(e){this.insertNodes(Uh(e))}insertText(e){let t=this.format,n=this.style;if(!this.isCollapsed()){let r=(this.focus.isBefore(this.anchor)?this.focus:this.anchor).getNode();if(B(r)&&(t=r.getFormat(),n=r.getStyle()),this.removeText(),this.format=t,this.style=n,e===``)return;if(C_()===null)return this.anchor.type===`element`&&oh(this.anchor,this.focus,t,n),void sh(this,e,t,n)}this.anchor.type===`element`&&oh(this.anchor,this.focus,t,n);let r=this.anchor.getNode();B(r)||I(398);let i=this.anchor.offset,a=r.getParentOrThrow(),o=r.getTextContentSize();if(m_(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(C_()!==null)r.setMode(`normal`).setFormat(t).setStyle(n);else{let e=Zm(r.getTextContent());e.setFormat(t),e.setStyle(n),r.replace(e),e.select(i,i)}e!==``&&this.insertText(e);return}if(e===``)return;if(i===0){let i=r.getPreviousSibling();if(B(i)&&i.canInsertTextAfter()&&!m_(i))i.select();else{let e=Zm();e.setFormat(t),e.setStyle(n),a.canInsertTextBefore()?r.insertBefore(e):a.insertBefore(e),e.select()}this.insertText(e);return}if(i===o){let i=r.getNextSibling();if(B(i)&&i.canInsertTextBefore()&&!m_(i))i.select(0,0);else{let e=Zm();e.setFormat(t),e.setStyle(n),a.canInsertTextAfter()?r.insertAfter(e):a.insertAfter(e),e.select(0,0)}this.insertText(e);return}let s=Zm(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 sh(this,e,t,n);r.setFormat(t),r.setStyle(n)}r.spliceText(i,0,e,!0),r.isComposing()&&this.anchor.type===`text`&&this.anchor.set(this.anchor.key,this.anchor.offset-e.length,this.anchor.type)}removeText(){let e=H()===this;gb(this,xb(_b(this))),e&&H()!==this&&M_(this)}formatText(e,t=null){ph(this,e,t)}insertNodes(e){if(e.length===0)return;this.isCollapsed()||this.removeText();let t=this.anchor.getNode();if(this.anchor.type===`element`&&W(t)&&gy(t)!==null){let n=t.isShadowRoot()?t.getFirstChild()??t.append(Gg()).getFirstChild():t.getFirstChild();if(t.isShadowRoot()&&n!==null&&!W(n)){let e=Gg();n.insertBefore(e),n=e}if(n!==null){n.selectStart();let t=H();return V(t)||I(369),t.insertNodes(e)}}if(this.anchor.type===`element`&&uv(t)){let n=Jh(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=uy(n,Bv),i=e[e.length-1];if(W(r)&&`__language`in r){if(`__language`in e[0])this.insertText(e[0].getTextContent());else{let t=Gh(this);r.splice(t,0,e),i.selectEnd()}return}if(!e.some(e=>(W(e)||G(e))&&!e.isInline())){W(r)||I(211,n.constructor.name,n.getType());let t=Gh(this);r.splice(t,0,e),i.selectEnd();return}if(W(r)&&gy(r)!==null){let t=Gh(this),n=Wh(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=Jh(e),n=t.getLastDescendant(),r=pb(this.anchor,`next`);for(let e of t.getChildren())r=Ab(e,r);n!==null&&n.selectEnd();return}if(W(r)&&!r.isParentRequired()&&!uv(r.getParentOrThrow())){let t=Gh(this),n=Wh(e);r.splice(t,0,n);let i=n[n.length-1];i===void 0?r.select(t,t):i.selectEnd();return}let a=Jh(e),o=a.getLastDescendant(),s=a.getChildren(),c=!W(r)||!r.isEmpty()?this.insertParagraph():null;c&&!r.isAttached()&&(n=this.anchor.getNode(),r=uy(n,Bv));let l=s[s.length-1],u=s[0];var d;W(d=u)&&Bv(d)&&!d.isEmpty()&&W(r)&&(!r.isEmpty()||r.canMergeWhenEmpty())&&(W(r)||I(211,n.constructor.name,n.getType()),r.append(...u.getChildren()),u=s[1]),u&&(r===null&&I(212,n.constructor.name,n.getType()),function(e,t){let n=t.getParentOrThrow().getLastChild(),r=t,i=[t];for(;r!==n;)r.getNextSibling()||I(140),r=r.getNextSibling(),i.push(r);let a=e;for(let e of i)a=a.insertAfter(e)}(r,u));let f=uy(o,Bv);c&&W(f)&&(c.canMergeWhenEmpty()||Bv(l))&&(f.append(...c.getChildren()),c.remove()),W(r)&&r.isEmpty()&&r.remove(),o.selectEnd();let p=W(r)?r.getLastChild():null;zg(p)&&f!==r&&p.remove()}insertParagraph(){let e=this.anchor.getNode();if(this.anchor.type===`element`&&uv(e)){let t=Gg();return e.splice(this.anchor.offset,0,[t]),t.select(),t}let t=Gh(this),n=uy(this.anchor.getNode(),Bv);if(n!==null&&gy(n)!==null)return null;W(n)||I(213);let r=n.getChildAtIndex(t),i=r?[r,...r.getNextSiblings()]:[],a=n.insertNewAfter(this,!1);return a?(a.append(...i),a.selectStart(),a):null}insertLineBreak(e){let t=Rg();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]=hh(this),o=this.isBackward(),[s,c]=o?[this.focus,this.anchor]:[this.anchor,this.focus],[l,u]=o?[a,i]:[i,a];if(t===0)return[];if(t===1){if(B(n)&&!this.isCollapsed()){let e=n.splitText(l,u),t=l===0?e[0]:e[1];return t?(s.set(t.getKey(),0,`text`),c.set(t.getKey(),t.getTextContentSize(),`text`),[t]):[]}return[n]}if(B(n)&&(l===n.getTextContentSize()?e.shift():l!==0&&([,n]=n.splitText(l),e[0]=n,s.set(n.getKey(),0,`text`))),B(r)){let t=r.getTextContent().length;u===0?e.pop():u!==t&&([r]=r.splitText(u),e[e.length-1]=r,c.set(r.getKey(),r.getTextContentSize(),`text`))}return e}modify(e,t,n){if(Yh(this,e,t,n))return;let r=e===`move`,i=U(),a=_v(ov(i));if(!a)return;let o=i._blockCursorElement,s=i._rootElement,c=this.focus.getNode();s===null||o===null||!W(c)||c.isInline()||c.canBeEmpty()||gv(o,i,s);let l=$_(i,this.focus.key),u=l;if(this.focus.type===`text`&&(u=B(c)?Gv(c,l,i):null),this.dirty){let e=$_(i,this.anchor.key),t=e;if(this.anchor.type===`text`){let n=this.anchor.getNode();t=B(n)?Gv(n,e,i):null}t&&u&&zh(a,t,this.anchor.offset,u,this.focus.offset)}if(n===`character`&&B(c)&&c.isUnmergeable()&&(t?this.focus.offset===0:this.focus.offset===c.getTextContentSize())){let e=Yy(c,t?`previous`:`next`).getNodeAtCaret();if(B(e)){if(!r){let n=e.getTextContentSize();t?this.focus.set(e.__key,n-1,`text`):this.focus.set(e.__key,1,`text`),this.dirty=!0;return}{let n=i.getElementByKey(e.getKey()),r=n?Gv(e,n,i):null;if(r){let e=t?r.length:0;zh(a,r,e,r,e)}}}}if(vh(a,e,t?`backward`:`forward`,n),a.rangeCount>0){let e=Tv(a,i._rootElement),n=e||a.getRangeAt(0),o=this.anchor.getNode(),s=kg(o)?o:cv(o);this.applyDOMRange(n),this.dirty=!0,!r&&(yh(this,t,s),(e?a.direction!==`backward`:a.anchorNode===n.startContainer&&a.anchorOffset===n.startOffset)||_h(this))}n===`lineboundary`&&Yh(this,e,t,n,`decorators`)}forwardDeletion(e,t,n){if(!n&&(e.type===`element`&&W(t)&&e.offset===t.getChildrenSize()||e.type===`text`&&e.offset===t.getTextContentSize())){let e=t.getParent(),n=t.getNextSibling()||(e===null?null:e.getNextSibling());if(W(n)&&n.isShadowRoot())return!0}return!1}deleteCharacter(e){let t=this.isCollapsed();if(this.isCollapsed()){let t=this.anchor,n=t.getNode();if(this.forwardDeletion(t,n,e))return;let r=ib(pb(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(Gy(t)){if(!t.origin.isInline()){if(t.origin.isShadowRoot()){if(e.type===`merge-block`)break;if(W(r.anchor.origin)&&r.anchor.origin.isEmpty()){let e=Sb(t);gb(this,ob(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(Wy(t)){if(W(t.origin)){if(t.origin.isInline()){if(!t.origin.isParentOf(r.anchor.origin))break}else e={block:t.origin,type:`merge-next-block`};continue}if(G(t.origin)){if(!t.origin.isIsolated()){if(xy(t.origin).length>0){if(W(r.anchor.origin)&&r.anchor.origin.isEmpty()){r.anchor.origin.remove();let e=Mh();e.add(t.origin.getKey()),M_(e)}}else if(e.type===`merge-next-block`&&(t.origin.isKeyboardSelectable()||!t.origin.isInline())&&W(r.anchor.origin)&&r.anchor.origin.isEmpty()){r.anchor.origin.remove();let e=Mh();e.add(t.origin.getKey()),M_(e)}else t.origin.remove()}return}break}}if(e.type===`merge-block`){let{caret:t,block:n}=e;return xy(n).length>0?void 0:t.origin.isEmpty()&&!n.isEmpty()&&t.origin.getParent()===n.getParent()?void t.origin.remove(!0):(gb(this,ob(!t.origin.isEmpty()&&n.isEmpty()?vb(Yy(n,t.direction)):r.anchor,t)),this.removeText())}for(let e=t.getNode();e!==null;){if(gy(e)!==null)return;if(W(e)&&e.isShadowRoot())break;e=e.getParent()}}let i=this.focus;if(bh(this,e,`character`),this.isCollapsed()){if(e&&t.offset===0&&gh(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 Sh(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 Sh(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!(F_(e)||xh(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()&&kg(e.getParent())&&e.getPreviousSibling()===null&&gh(this,e),lh()}}deleteLine(e){let t=Th(this.anchor);if(t!==null&&G(_y(t)))return this.isCollapsed()||this.focus.set(this.anchor.key,this.anchor.offset,this.anchor.type),void this.deleteCharacter(e);this.isCollapsed()&&bh(this,e,`lineboundary`),this.isCollapsed()?this.deleteCharacter(e):uy(this.anchor.getNode(),Bv)===uy(this.focus.getNode(),Bv)?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;bh(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 ig()||(this._cachedIsBackward=t),t}getStartEndPoints(){return[this.anchor,this.focus]}};function dh(e){return e instanceof ch}function fh(e,t){if(dh(e)){for(let n of e.getNodes())Vm(n)&&n.setFormat(t(n.getFormat()));return}if(e.isCollapsed())return e.setFormat(t(e.format)),void S_(null);let n=[];for(let r of e.getNodes())B(r)?n.push(r):W(r)?r.setTextFormat(t(r.getTextFormat())):Vm(r)&&r.setFormat(t(r.getFormat()));let r=n.length;if(r===0)return e.setFormat(t(e.format)),void S_(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(m_(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||m_(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()||m_(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 ph(e,t,n=null){let r=n===null&&V(e)?v_(e.format,t,null):n;fh(e,e=>v_(e,t,r))}function mh(e){let t=e.offset;if(e.type===`text`)return t;let n=e.getNode();return t===n.getChildrenSize()?n.getTextContent().length:0}function hh(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]:[mh(n),mh(r)]}function gh(e,t){for(let n=t;n;n=n.getParent()){if(W(n)){if(n.collapseAtStart(e))return!0;if(uv(n))break}if(n.getPreviousSibling())break}return!1}function _h(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 vh(e,t,n,r){e.modify(t,n,r)}function yh(e,t,n){let r=e.getNodes(),i=r.filter(e=>iv(e,n));if(i.length===0||i.length===r.length)return!1;let a=t?i[0]:i[i.length-1],o=W(a)?a:a.getParentOrThrow();return t?o.selectStart():o.selectEnd(),!0}function bh(e,t,n){if(Yh(e,`extend`,t,n))return;let r=U(),i=_v(ov(r));if(!i||typeof i.modify!=`function`)return;let a=r._blockCursorElement,o=r._rootElement,s=e.anchor,c=e.focus.getNode();o===null||a===null||!W(c)||c.isInline()||c.canBeEmpty()||gv(a,r,o);let l=e=>{let t=e.getNode(),n=r.getElementByKey(e.key);return n!==null&&e.type===`text`&&B(t)?Gv(t,n,r):n},u=s.getNode(),d=l(s);if(d===null)return;let f=s.offset,p=e.isCollapsed(),m=e.focus,h=p?d:l(m);if(h===null)return;let g=m.offset;if(zh(i,h,g,h,g),vh(i,`move`,t?`backward`:`forward`,n),i.rangeCount===0)return;let _=Tv(i,o)||i.getRangeAt(0),v=_.startContainer,y=_.startOffset;if(p&&n===`character`&&s.type===`text`&&B(u)&&u.isUnmergeable()&&f===(t?0:u.getTextContentSize())){let n=Yy(u,t?`previous`:`next`).getNodeAtCaret();if(B(n)){let r=t?n.getTextContentSize()-1:1;e.focus.set(n.__key,r,`text`),e.dirty=!0;return}}if(p&&n===`character`&&s.type===`text`){let n=t?0:u.getTextContentSize(),r=v===d?y:f===n?-1:n;if(r>=0)return void(r!==f&&(e.focus.set(s.key,r,`text`),e.dirty=!0))}let[b,x,ee,te]=t?[v,y,d,f]:[d,f,v,y],ne=kg(u)?u:cv(u);e.applyDOMRange({collapsed:!1,endContainer:ee,endOffset:te,startContainer:b,startOffset:x}),e.dirty=!0,!yh(e,t,ne)&&t&&_h(e),n===`lineboundary`&&Yh(e,`extend`,t,n,`decorators`)}let xh=(()=>{try{let e=RegExp(`\\p{Emoji}`,`u`),t=e.test.bind(e);if(t(`❤️`)&&t(`#️⃣`)&&t(`👍`))return t}catch{}return()=>!1})();function Sh(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 Ch(e,t,n,r){let i,a=t,o=!1;if(J(e)){let s=!1,c=e.childNodes,l=c.length,u=r._blockCursorElement;a===l&&l>0&&(s=!0,a=l-1),D_(e,r)!==void 0||ry(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=P_(d),B(i))a=Zy(i,s?`next`:`previous`);else{let c=P_(e);if(c===null)return null;if(W(c)){let o=r.getElementByKey(c.getKey());o===null&&I(214);let l=Uv(c,o,r);[c,a]=l.resolveChildIndex(c,o,e,t),W(c)||I(215),s&&a>=c.getChildrenSize()&&(a=Math.max(0,c.getChildrenSize()-1));let u=c.getChildAtIndex(a);if(W(u)&&function(e,t,n){let r=e.getParent();return n===null||r===null||!r.canBeEmpty()||r!==n.getNode()}(u,0,n)){let e=s?u.getLastDescendant():u.getFirstDescendant();e===null?c=u:(u=e,c=W(u)?u:u.getParentOrThrow()),a=0}B(u)?(i=u,c=null,a=Zy(u,s?`next`:`previous`)):u!==c&&s&&!f&&(W(c)||I(216),a=Math.min(c.getChildrenSize(),a+1))}else{let n=_y(c),i=n===null?c:n,o=i.getIndexWithinParent(),s=r.getElementByKey(c.getKey()),l=`after`;if(s!==null&&P_(e)===c){let n=Uv(c,s,r);n.element===s?t===0&&G(c)&&(l=`before`):l=n.resolveLeafPosition(s,e,t)}a=l===`before`?o:o+1,c=i.getParentOrThrow()}if(W(c))return[rh(c.__key,a,`element`),o]}}else i=P_(e);return B(i)?[rh(i.__key,Zy(i,a,`clamp`),`text`),o]:null}function wh(e,t,n){let r=e.offset,i=e.getNode();if(r===0){let r=i.getPreviousSibling(),a=i.getParent();if(t){if((n||!t)&&r===null&&W(a)&&a.isInline()){let t=a.getPreviousSibling();B(t)&&e.set(t.__key,t.getTextContent().length,`text`)}}else W(r)&&!n&&r.isInline()?e.set(r.__key,r.getChildrenSize(),`element`):B(r)&&!i.isUnmergeable()&&e.set(r.__key,r.getTextContent().length,`text`)}else if(r===i.getTextContent().length){let r=i.getNextSibling(),a=i.getParent();if(t&&W(r)&&r.isInline())e.set(r.__key,0,`element`);else if((n||t)&&r===null&&W(a)&&a.isInline()&&!a.canInsertTextAfter()&&a.getTextContentSize()>1){let t=a.getNextSibling();B(t)&&e.set(t.__key,0,`text`)}}}function Th(e){let t=w_(e.key);return t===null?null:yy(t)}function Eh(e,t,n){let r=Th(e),i=Th(t);if(r===i||r!==null&&i!==null&&r.is(i))return!1;let a=n(r,i);if(r!==null)return W(r)?t.set(r.getKey(),a?r.getChildrenSize():0,`element`):t.set(r.getKey(),a?r.getTextContentSize():0,`text`),!0;let o=_y(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 Dh(e){let t=Eh(e.anchor,e.focus,(t,n)=>function(e,t,n,r){if(n!==null&&r!==null){let e=_y(n),t=_y(r);if(e!==null&&e.is(t)){for(let t of by(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=_y(n),r=w_(t.key);return e===null||r===null||!(!e.is(r)&&!e.isParentOf(r))||e.isBefore(r)}let i=_y(r),a=w_(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 Oh(e,t,n,r,i,a){if(e===null||n===null||!l_(i,e,n))return null;let o=Ch(e,t,V(a)?a.anchor:null,i);if(o===null)return null;let s=Ch(n,r,V(a)?a.focus:null,i);if(s===null)return null;let[c,l]=o,[u,d]=s;if(c.type===`element`&&u.type===`element`){let t=P_(e),r=P_(n);if(G(t)&&G(r))return null}let f=i._slotsUsed&&Eh(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);wh(e,n,r),wh(t,!n,r),r&&t.set(e.key,e.offset,e.type)}}(c,u),[c,u,l||d||f]}function kh(e){return W(e)&&!e.isInline()}function Ah(e,t,n,r,i,a){let o=sg(),s=new uh(rh(e,t,i),rh(n,r,a),0,``);return s.dirty=!0,o._selection=s,s}function jh(){return new uh(rh(`root`,0,`element`),rh(`root`,0,`element`),0,``)}function Mh(){return new ch(/* @__PURE__ */ new Set)}function Nh(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=!Pd&&(s||o===`beforeinput`||o===`compositionstart`||o===`compositionend`||o===`click`&&a&&a.detail===3||o===`drop`||o===void 0),l,u,d,f;if(V(e)&&!c)return e.clone();{if(t===null)return null;let r=Dv(t,n._rootElement);if(l=r.anchorNode,u=r.focusNode,d=r.anchorOffset,f=r.focusOffset,(s||o===void 0)&&V(e)&&!l_(n,l,u))return e.clone()}let p=Oh(l,d,u,f,n,e);if(p===null)return null;let[m,h,g]=p,_=0,v=``;if(V(e)){let t=e.anchor;if(m.key===t.key)_=e.format,v=e.style;else{let e=m.getNode();B(e)?(_=e.getFormat(),v=e.getStyle()):W(e)&&(_=e.getTextFormat(),v=e.getTextStyle())}}let y=new uh(m,h,_,v);return g&&(y.dirty=!0),y}function H(){return sg()._selection}function Ph(){return U()._editorState._selection}function Fh(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`),Ih(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`)}}Ih(e)}function Ih(e){let t=e.anchor,n=t.offset,r=e.focus,i=r.offset,a=t.getNode(),o=r.getNode();if(e.isCollapsed()){if(!W(a))return;let e=a.getChildrenSize(),i=n>=e,o=i?a.getChildAtIndex(e-1):a.getChildAtIndex(n);if(B(o)){let e=0;i&&(e=o.getTextContentSize()),t.set(o.__key,e,`text`),r.set(o.__key,e,`text`)}}else{if(W(a)){let e=a.getChildrenSize(),r=n>=e,i=r?a.getChildAtIndex(e-1):a.getChildAtIndex(n);if(B(i)){let e=0;r&&(e=i.getTextContentSize()),t.set(i.__key,e,`text`)}}if(W(o)){let e=o.getChildrenSize(),t=i>=e,n=t?o.getChildAtIndex(e-1):o.getChildAtIndex(i);if(B(n)){let e=0;t&&(e=n.getTextContentSize()),r.set(n.__key,e,`text`)}}}}function Lh(e,t,n,r,i){let a=null,o=0,s=null;r===null?i!==null&&(a=i.__key,B(i)?s=`text`:W(i)&&(s=`element`)):(a=r.__key,B(r)?(o=r.getTextContentSize(),s=`text`):W(r)&&(o=r.getChildrenSize(),s=`element`)),a!==null&&s!==null?e.set(a,o,s):(o=t.getIndexWithinParent(),o===-1&&(o=n.getChildrenSize()),e.set(n.__key,o,`element`))}function Rh(e,t,n,r,i){e.type===`text`?e.set(n,e.offset+(t?0:i),`text`):e.offset>r.getIndexWithinParent()&&e.set(e.key,e.offset-1,`element`)}function zh(e,t,n,r,i){try{e.setBaseAndExtent(t,n,r,i)}catch{}}function Bh(e,t,n){let r=$_(e,t.getKey());if(W(t)){let i=Uv(t,r,e);return[i.element,n+i.getFirstChildOffset()]}return[r,n]}function Vh(e,t,n,r,i,a){let o=a.getRootNode(),s=g_(o)||yv(o)?Mv(o):null;if(i.has(`collaboration`)&&s!==a||s!==null&&c_(s,s))return;let c=Dv(r,a),l;if(!V(t))return void(e!==null&&l_(n,c.anchorNode,c.focusNode)&&r.removeAllRanges());let u=t.anchor,d=t.focus,f=u.getNode(),p=d.getNode(),[m,h]=Bh(n,f,u.offset),[g,_]=Bh(n,p,d.offset),v=t.format,y=t.style,b=t.isCollapsed(),x=m,ee=g,te=!1;if(u.type===`text`?(x=B(f)?Gv(f,m,n):null,te=f.getFormat()!==v||f.getStyle()!==y):V(e)&&e.anchor.type===`text`&&(te=!0),d.type===`text`&&(ee=B(p)?Gv(p,g,n):null),x!==null&&ee!==null){if(b&&(e===null||te||V(e)&&(e.format!==v||e.style!==y))&&function(e,t,n,r,i,a){e._inputState.collapsedSelectionFormat={format:t,key:i,offset:r,style:n,timeStamp:a}}(n,v,y,h,u.key,performance.now()),(r.type!==`Range`||!b)&&c.anchorOffset===h&&c.focusOffset===_&&c.anchorNode===x&&c.focusNode===ee){if(s===null||!a.contains(s)){let e=s===null?null:d_(s);e!==null&&e!==n||i.has(`skip-selection-focus`)||a.focus({preventScroll:!0})}if(u.type!==`element`)return}if(zh(r,x,h,ee,_),rd&&t.isCollapsed()&&a!==null&&!i.has(`skip-selection-focus`)){let e=jv(a);if(e===null||!a.contains(e)){let e=Mv(a.ownerDocument),t=e===null?null:d_(e);t!==null&&t!==n||a.focus({preventScroll:!0})}}if(!i.has(`skip-scroll-into-view`)&&t.isCollapsed()&&a!==null&&a===jv(a)){let e=V(t)&&t.anchor.type===`element`?x.childNodes[h]||null:(l===void 0&&(l=Ev(r,a)),l);if(e!==null){let t;if(h_(e)){let n=e.ownerDocument.createRange();n.selectNode(e),t=n.getBoundingClientRect()}else t=e.getBoundingClientRect();(function(e,t,n){let r=tv(n),i=av(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=ov(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=ev(u)}})(n,t,a)}}(function(e){e._inputState.isSelectionChangeFromDOMUpdate=!0})(n)}}function Hh(e,t){for(let n of e.split(/(\r?\n|\t)/))n===`
|
|
150
141
|
`||n===`\r
|
|
151
|
-
`?t.linebreak():n===` `?t.tab():n!==``&&t.text(n)}function Bp(e){let t=[];return zp(e,{linebreak:()=>t.push(Fm()),tab:()=>t.push(Zf()),text:e=>t.push(Jf(e))}),t}function Vp(e){let t=[];for(let n of e)Im(n)||(!W(n)&&!G(n)||n.isInline()?t.push(n):W(n)&&t.push(...Vp(n.getChildren())));return t}function Hp(e){let t=e;e.isCollapsed()||t.removeText();let n=H();V(n)&&(t=n),V(t)||I(161);let r=t.anchor,i=r.getNode(),a=r.offset;for(;!Lg(i)&&p_(i)===null;){let e=i;if([i,a]=Up(i,a),e.is(i))break}return a}function Up(e,t){let n=e.getParent();if(!n){let e=Hm();return Oh().append(e),e.select(),[Oh(),0]}if(B(e)){let r=e.splitText(t);if(r.length===0)return[n,e.getIndexWithinParent()];let i=t===0?0:1;return[n,r[0].getIndexWithinParent()+i]}if(!W(e)||t===0)return[n,e.getIndexWithinParent()];let r=e.getChildAtIndex(t);if(r){let n=new sp(ep(e.__key,t,`element`),ep(e.__key,t,`element`),0,``),i=e.insertNewAfter(n);i&&i.append(r,...r.getNextSiblings())}return[n,e.getIndexWithinParent()+1]}function Wp(e){return Im(e)||ig(e)||B(e)||e.isParentRequired()}function Gp(e){let t=Hm(),n=null;for(let r=0;r<e.length;r++){let i=e[r];if(Wp(i)){if(n===null){n=i.createParentElementNode(),t.append(n);let a=e[r+1];if(Im(i)&&(a===void 0||!Wp(a)))continue}n.append(i)}else t.append(i),n=null}return t}function Kp(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=uv(e.focus,n?`previous`:`next`),o=r===`lineboundary`,s=t===`move`,c=a,l=i===`decorators-and-blocks`;if(!bv(c)){for(let e of c){l=!1;let{origin:t}=e;if(!G(t)||t.isIsolated()||(c=e,!o||!t.isInline()))break}if(l)for(let e of tv(a).iterNodeCarets(t===`extend`?`shadowRoot`:`root`)){if(H_(e))e.origin.isInline()||(c=e);else{if(W(e.origin))continue;G(e.origin)&&!e.origin.isInline()&&(c=e)}break}}if(c===a)return!1;if(s&&!o&&G(c.origin)&&c.origin.isKeyboardSelectable()){let e=kp();return e.add(c.origin.getKey()),kh(e),!0}return c=yv(c),s&&dv(e.anchor,c),dv(e.focus,c),l||!o}let qp=null,Jp=null,Yp=!1,Xp=!1,Zp=!1,Qp=/* @__PURE__ */ new Set,$p=0,em={characterData:!0,childList:!0,subtree:!0};function tm(){return Yp||qp!==null&&qp._readOnly}function nm(){Yp&&I(13)}function rm(){$p>99&&I(14)}function im(){return qp===null&&I(195,sm()),qp}function am(e){im()!==null&&Jp===null&&(Jp=e),Jp!==e&&Zc(378)}function U(){return Jp===null&&I(337,sm()),Jp}function om(){U()._dirtyType=2}function sm(){let e=0,t=/* @__PURE__ */ new Set,n=Zm.version;if(typeof window<`u`)for(let r of yg(document)){let i=lh(r);if(sh(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 cm(){return Jp}function lm(e,t,n){let r=t.__type,i=nh(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 um(e,t){return e!==void 0&&e.__key!==t&&e.isAttached()}function dm(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 fm(e,t){let n=e.type,r=t.get(n);r===void 0&&I(17,n);let i=r.klass;e.type!==i.getType()&&I(18,i.name);let a=i.importJSON(e),o=e.children;if(W(a)&&Array.isArray(o))for(let e=0;e<o.length;e++){let n=fm(o[e],t);a.append(n)}let s=e.$slots;if(s){d_(a)||I(379,i.name);for(let e in s)k_(a,e,fm(s[e],t))}return a}function pm(e,t,n){let r=qp,i=Yp,a=Jp;qp=t,Yp=!0,Jp=e;try{return n()}finally{qp=r,Yp=i,Jp=a}}function mm(e,t){let n=Zp;Zp=!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&&_m(e,e._deferred));let a=e._editorState,o=a._selection,s=n._selection,c=e._dirtyType!==0,l=qp,u=Yp,d=Jp,f=e._updating,p=e._observer,m=null;if(e._pendingEditorState=null,e._editorState=n,!i&&c&&p!==null){Jp=e,qp=n,Yp=!1,e._updating=!0;try{let t=e._dirtyType,r=e._dirtyElements,i=e._dirtyLeaves;p.disconnect(),m=Xu(a,n,e,t,r,i)}catch(t){if(t instanceof Error&&e._onError(t),Xp)throw t;Gm(e,null,r,n),Vl(e),e._dirtyType=2,Xp=!0,mm(e,a),Xp=!1;return}finally{p.observe(r,em),e._updating=f,qp=l,Yp=u,Jp=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=Eh(e)),delete r[a])}(e,n);let y=i?null:mg(rg(e));if(e._editable&&y!==null&&(c||s===null||s.dirty||!s.is(o))&&r!==null&&!v.has(`skip-dom-selection`)){Jp=e,qp=n;try{if(p!==null&&p.disconnect(),c||s===null||s.dirty){let t=e._blockCursorElement;t!==null&&pg(t,e,r),Rp(o,s,e,y,v,r)}(function(e,t,n){let r=e._blockCursorElement;if(V(n)&&n.isCollapsed()&&n.anchor.type===`element`&&t.contains(Og(t))){let i=n.anchor,a=i.getNode(),o=i.offset,s=!1,c=null;if(o===a.getChildrenSize())fg(a.getChildAtIndex(o-1))&&(s=!0);else{let t=a.getChildAtIndex(o);if(t!==null&&fg(t)){let n=t.getPreviousSibling();(n===null||fg(n))&&(s=!0,c=e.getElementByKey(t.__key))}}if(s){let n=Bg(a,e.getElementByKey(a.__key),e).element;r===null&&(e._blockCursorElement=r=function(e){let t=e.theme,n=xg().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=jv(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&&pg(r,e,t)})(e,r,s)}finally{p!==null&&p.observe(r,em),Jp=d,qp=l}}m!==null&&function(e,t,n,r,i){let a=Array.from(e._listeners.mutation),o=a.length;for(let e=0;e<o;e++){let[o,s]=a[e];for(let e of s){let a=t.get(e);a!==void 0&&o(a,{dirtyLeaves:r,prevEditorState:i,updateTags:n})}}}(e,m,v,h,a),V(s)||s===null||o!==null&&o.is(s)||e.dispatchCommand(Qu);let b=e._pendingDecorators;b!==null&&(e._decorators=b,e._pendingDecorators=null,hm(`decorator`,e,!0,b)),function(e,t,n){let r=Dh(t),i=Dh(n);r!==i&&hm(`textcontent`,e,!0,i)}(e,t||a,n),hm(`update`,e,!0,{dirtyElements:g,dirtyLeaves:h,editorState:n,mutatedNodes:m,normalizedNodes:_,prevEditorState:t||a,tags:v}),!f&&_m(e,e._deferred),(function(e){let t=e._updates;if(t.length===0)return void(e._cascadeCount=0);if(function(e){Qp.has(e)||(Qp.add(e),setTimeout(()=>{Qp.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;ym(e,t,r)}})(e)})(e,t)}finally{Zp=n}}function hm(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 gm(e,t,n,r){let i=Nh(e),a;if(!Zp)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(bm(s,()=>{for(let i of t)if(i(n,r))return void(e=!0)}),e)return e}}}return a&&a.update(()=>{gm(a,t,n,r)}),!1}function _m(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 vm(e,t){let n=e._updates,r=t||!1;for(;n.length!==0;){let t=n.shift();if(t){let[n,i]=t,a=e._pendingEditorState,o;i!==void 0&&(o=i.onUpdate,i.skipTransforms&&(r=!0),i.discrete&&(a===null&&I(191),a._flushSync=!0),o&&e._deferred.push(o),dm(e,i.tag)),a==null?ym(e,n,i):n()}}return r}function ym(e,t,n){let r=e._updateTags,i,a=!1,o=!1;n!==void 0&&(i=n.onUpdate,dm(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=Dm(c||s),l=!0),c._flushSync=o;let u=qp,d=Yp,f=Jp,p=e._updating;qp=c,Yp=!1,e._updating=!0,Jp=e;let m=e._headless||e.getRootElement()===null;$m(null);try{l&&(m?s._selection!==null&&(c._selection=s._selection.clone()):c._selection=function(e,t){let n=e.getEditorState()._selection,r=mg(rg(e));return V(n)||n==null?Ap(n,r,e,t):n.clone()}(e,n&&n.event||null));let r=e._compositionKey;t(),a=vm(e,a),function(e,t){let n=t.getEditorState()._selection,r=e._selection;if(V(r)){let e=r.anchor,t=r.focus,i;if(e.type===`text`&&(i=e.getNode(),i.selectionTransform(n,r)),t.type===`text`){let e=t.getNode();i!==e&&e.selectionTransform(n,r)}}}(c,e),e._dirtyType!==0&&(a?function(e,t){let n=t._dirtyLeaves,r=e._nodeMap;for(let e of n){let t=r.get(e);B(t)&&t.isAttached()&&t.isSimpleText()&&!t.isUnmergeable()&&nu(t)}}(c,e):function(e,t){let n=t._dirtyLeaves,r=t._dirtyElements,i=e._nodeMap,a=bh(),o=/* @__PURE__ */ new Map,s=n,c=s.size,l=r,u=l.size;for(;c>0||u>0;){if(c>0){t._dirtyLeaves=/* @__PURE__ */ new Set;for(let e of s){let r=i.get(e);B(r)&&r.isAttached()&&r.isSimpleText()&&!r.isUnmergeable()&&nu(r),r!==void 0&&um(r,a)&&lm(t,r,o),n.add(e)}if(s=t._dirtyLeaves,c=s.size,c>0){$p++;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&&um(c,a)&&lm(t,c,o)}s=t._dirtyLeaves,c=s.size,l=t._dirtyElements,u=l.size,$p++}t._dirtyLeaves=n,t._dirtyElements=r}(c,e),vm(e),function(e,t,n,r){let i=e._nodeMap,a=t._nodeMap,o=[];for(let[e]of r){let t=a.get(e);t!==void 0&&(t.isAttached()||(W(t)&&jl(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()||(d_(t)&&t.__slots!==null&&jl(t,e,i,a,o,n),i.has(e)||n.delete(e),o.push(e))}for(let e of o)a.delete(e);let s=U(),c=s._compositionKey;c===null||a.has(c)||(s._compositionKey=null)}(s,c,e._dirtyLeaves,e._dirtyElements)),r!==e._compositionKey&&(c._flushSync=!0);let i=c._selection;if(V(i)){e._slotsUsed&&wp(i);let t=c._nodeMap,n=i.anchor.key,r=i.focus.key;t.get(n)!==void 0&&t.get(r)!==void 0||I(19)}else cp(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(),mm(e);return}finally{qp=u,Yp=d,Jp=f,e._updating=p,$p=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,mm(e)):l&&ih(()=>{mm(e)}):(c._flushSync=!1,l&&(r.clear(),e._deferred=[],e._pendingEditorState=null))}function bm(e,t,n){Jp===e&&n===void 0?tm()?ym(e,t,n):t():ym(e,t,n)}function xm(e){if(sg(e)){let t=null;for(let n of e.getChildren())t=n.isInline()?(t||n.replace(n.createParentElementNode())).append(n):null}}var Sm=class extends Cf{__first;__last;__size;__format;__style;__indent;__dir;__textFormat;__textStyle;__slotHost;__slots;$config(){return this.config(Symbol.for(`ElementNode`),{$transform:xm,extends:Cf})}constructor(e){super(e),this.__first=null,this.__last=null,this.__size=0,this.__format=0,this.__style=``,this.__indent=0,this.__dir=null,this.__textFormat=0,this.__textStyle=``,this.__slotHost=null,this.__slots=null}afterCloneFrom(e){super.afterCloneFrom(e),this.__key===e.__key&&(this.__first=e.__first,this.__last=e.__last,this.__size=e.__size,this.__slotHost=e.__slotHost,this.__slotHost!==null&&this.__parent!==null&&I(384,this.__key,String(this.__slotHost),String(this.__parent)),this.__slots=e.__slots),this.__indent=e.__indent,this.__format=e.__format,this.__style=e.__style,this.__dir=e.__dir,this.__textFormat=e.__textFormat,this.__textStyle=e.__textStyle}getFormat(){return this.getLatest().__format}getFormatType(){let e=this.getFormat();return gl[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&&v_(this).length===0}isDirty(){let e=U()._dirtyElements;return e!==null&&e.has(this.__key)}isLastChild(){let e=this.getLatest(),t=this.getParentOrThrow().getLastChild();return t!==null&&t.is(e)}getAllTextNodes(){let e=[];for(let t of v_(this)){let n=y_(this,t);W(n)&&e.push(...n.getAllTextNodes())}let t=this.getFirstChild();for(;t!==null;){if(B(t)&&e.push(t),W(t)){let n=t.getAllTextNodes();e.push(...n)}t=t.getNextSibling()}return e}getFirstDescendant(){let e=this.getFirstChild();for(;W(e);){let t=e.getFirstChild();if(t===null)break;e=t}return e}getLastDescendant(){let e=this.getLastChild();for(;W(e);){let t=e.getLastChild();if(t===null)break;e=t}return e}getDescendantByIndex(e){let t=this.getChildren(),n=t.length;if(e>=n){let e=t[n-1];return W(e)&&e.getLastDescendant()||e||null}let r=t[e];return W(r)&&r.getFirstDescendant()||r||null}getFirstChild(){let e=this.getLatest().__first;return e===null?null:xh(e)}getFirstChildOrThrow(){let e=this.getFirstChild();return e===null&&I(45,this.__key),e}getLastChild(){let e=this.getLatest().__last;return e===null?null:xh(e)}getLastChildOrThrow(){let e=this.getLastChild();return e===null&&I(96,this.__key),e}getChildAtIndex(e){let t=this.getChildrenSize(),n,r;if(e<t/2){for(n=this.getFirstChild(),r=0;n!==null&&r<=e;){if(r===e)return n;n=n.getNextSibling(),r++}return null}for(n=this.getLastChild(),r=t-1;n!==null&&r>=e;){if(r===e)return n;n=n.getPreviousSibling(),r--}return null}getTextContent(){let e=E_(this),t=this.getChildren(),n=t.length;for(let r=0;r<n;r++){let i=t[r];e+=i.getTextContent(),W(i)&&r!==n-1&&!i.isInline()&&(e+=`
|
|
142
|
+
`?t.linebreak():n===` `?t.tab():n!==``&&t.text(n)}function Uh(e){let t=[];return Hh(e,{linebreak:()=>t.push(Rg()),tab:()=>t.push(eh()),text:e=>t.push(Zm(e))}),t}function Wh(e){let t=[];for(let n of e)zg(n)||(!W(n)&&!G(n)||n.isInline()?t.push(n):W(n)&&t.push(...Wh(n.getChildren())));return t}function Gh(e){let t=e;e.isCollapsed()||t.removeText();let n=H();V(n)&&(t=n),V(t)||I(161);let r=t.anchor,i=r.getNode(),a=r.offset;for(;!Bv(i)&&gy(i)===null;){let e=i;if([i,a]=Kh(i,a),e.is(i))break}return a}function Kh(e,t){let n=e.getParent();if(!n){let e=Gg();return j_().append(e),e.select(),[j_(),0]}if(B(e)){let r=e.splitText(t);if(r.length===0)return[n,e.getIndexWithinParent()];let i=t===0?0:1;return[n,r[0].getIndexWithinParent()+i]}if(!W(e)||t===0)return[n,e.getIndexWithinParent()];let r=e.getChildAtIndex(t);if(r){let n=new uh(rh(e.__key,t,`element`),rh(e.__key,t,`element`),0,``),i=e.insertNewAfter(n);i&&i.append(r,...r.getNextSiblings())}return[n,e.getIndexWithinParent()+1]}function qh(e){return zg(e)||sv(e)||B(e)||e.isParentRequired()}function Jh(e){let t=Gg(),n=null;for(let r=0;r<e.length;r++){let i=e[r];if(qh(i)){if(n===null){n=i.createParentElementNode(),t.append(n);let a=e[r+1];if(zg(i)&&(a===void 0||!qh(a)))continue}n.append(i)}else t.append(i),n=null}return t}function Yh(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=pb(e.focus,n?`previous`:`next`),o=r===`lineboundary`,s=t===`move`,c=a,l=i===`decorators-and-blocks`;if(!Cb(c)){for(let e of c){l=!1;let{origin:t}=e;if(!G(t)||t.isIsolated()||(c=e,!o||!t.isInline()))break}if(l)for(let e of ib(a).iterNodeCarets(t===`extend`?`shadowRoot`:`root`)){if(Gy(e))e.origin.isInline()||(c=e);else{if(W(e.origin))continue;G(e.origin)&&!e.origin.isInline()&&(c=e)}break}}if(c===a)return!1;if(s&&!o&&G(c.origin)&&c.origin.isKeyboardSelectable()){let e=Mh();return e.add(c.origin.getKey()),M_(e),!0}return c=Sb(c),s&&mb(e.anchor,c),mb(e.focus,c),l||!o}let Xh=null,Zh=null,Qh=!1,$h=!1,eg=!1,tg=/* @__PURE__ */ new Set,ng=0,rg={characterData:!0,childList:!0,subtree:!0};function ig(){return Qh||Xh!==null&&Xh._readOnly}function ag(){Qh&&I(13)}function og(){ng>99&&I(14)}function sg(){return Xh===null&&I(195,ug()),Xh}function cg(e){sg()!==null&&Zh===null&&(Zh=e),Zh!==e&&$u(378)}function U(){return Zh===null&&I(337,ug()),Zh}function lg(){U()._dirtyType=2}function ug(){let e=0,t=/* @__PURE__ */ new Set,n=e_.version;if(typeof window<`u`)for(let r of Sv(document)){let i=f_(r);if(u_(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 dg(){return Zh}function fg(e,t,n){let r=t.__type,i=a_(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 pg(e,t){return e!==void 0&&e.__key!==t&&e.isAttached()}function mg(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 hg(e,t){let n=e.type,r=t.get(n);r===void 0&&I(17,n);let i=r.klass;e.type!==i.getType()&&I(18,i.name);let a=i.importJSON(e),o=e.children;if(W(a)&&Array.isArray(o))for(let e=0;e<o.length;e++){let n=hg(o[e],t);a.append(n)}let s=e.$slots;if(s){my(a)||I(379,i.name);for(let e in s)My(a,e,hg(s[e],t))}return a}function gg(e,t,n){let r=Xh,i=Qh,a=Zh;Xh=t,Qh=!0,Zh=e;try{return n()}finally{Xh=r,Qh=i,Zh=a}}function _g(e,t){let n=eg;eg=!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&&bg(e,e._deferred));let a=e._editorState,o=a._selection,s=n._selection,c=e._dirtyType!==0,l=Xh,u=Qh,d=Zh,f=e._updating,p=e._observer,m=null;if(e._pendingEditorState=null,e._editorState=n,!i&&c&&p!==null){Zh=e,Xh=n,Qh=!1,e._updating=!0;try{let t=e._dirtyType,r=e._dirtyElements,i=e._dirtyLeaves;p.disconnect(),m=$f(a,n,e,t,r,i)}catch(t){if(t instanceof Error&&e._onError(t),$h)throw t;Jg(e,null,r,n),Ud(e),e._dirtyType=2,$h=!0,_g(e,a),$h=!1;return}finally{p.observe(r,rg),e._updating=f,Xh=l,Qh=u,Zh=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=k_(e)),delete r[a])}(e,n);let y=i?null:_v(ov(e));if(e._editable&&y!==null&&(c||s===null||s.dirty||!s.is(o))&&r!==null&&!v.has(`skip-dom-selection`)){Zh=e,Xh=n;try{if(p!==null&&p.disconnect(),c||s===null||s.dirty){let t=e._blockCursorElement;t!==null&&gv(t,e,r),Vh(o,s,e,y,v,r)}(function(e,t,n){let r=e._blockCursorElement;if(V(n)&&n.isCollapsed()&&n.anchor.type===`element`&&t.contains(jv(t))){let i=n.anchor,a=i.getNode(),o=i.offset,s=!1,c=null;if(o===a.getChildrenSize())hv(a.getChildAtIndex(o-1))&&(s=!0);else{let t=a.getChildAtIndex(o);if(t!==null&&hv(t)){let n=t.getPreviousSibling();(n===null||hv(n))&&(s=!0,c=e.getElementByKey(t.__key))}}if(s){let n=Uv(a,e.getElementByKey(a.__key),e).element;r===null&&(e._blockCursorElement=r=function(e){let t=e.theme,n=wv().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=Pb(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&&gv(r,e,t)})(e,r,s)}finally{p!==null&&p.observe(r,rg),Zh=d,Xh=l}}m!==null&&function(e,t,n,r,i){let a=Array.from(e._listeners.mutation),o=a.length;for(let e=0;e<o;e++){let[o,s]=a[e];for(let e of s){let a=t.get(e);a!==void 0&&o(a,{dirtyLeaves:r,prevEditorState:i,updateTags:n})}}}(e,m,v,h,a),V(s)||s===null||o!==null&&o.is(s)||e.dispatchCommand(tp);let b=e._pendingDecorators;b!==null&&(e._decorators=b,e._pendingDecorators=null,vg(`decorator`,e,!0,b)),function(e,t,n){let r=A_(t),i=A_(n);r!==i&&vg(`textcontent`,e,!0,i)}(e,t||a,n),vg(`update`,e,!0,{dirtyElements:g,dirtyLeaves:h,editorState:n,mutatedNodes:m,normalizedNodes:_,prevEditorState:t||a,tags:v}),!f&&bg(e,e._deferred),(function(e){let t=e._updates;if(t.length===0)return void(e._cascadeCount=0);if(function(e){tg.has(e)||(tg.add(e),setTimeout(()=>{tg.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;Sg(e,t,r)}})(e)})(e,t)}finally{eg=n}}function vg(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 yg(e,t,n,r){let i=I_(e),a;if(!eg)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(Cg(s,()=>{for(let i of t)if(i(n,r))return void(e=!0)}),e)return e}}}return a&&a.update(()=>{yg(a,t,n,r)}),!1}function bg(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 xg(e,t){let n=e._updates,r=t||!1;for(;n.length!==0;){let t=n.shift();if(t){let[n,i]=t,a=e._pendingEditorState,o;i!==void 0&&(o=i.onUpdate,i.skipTransforms&&(r=!0),i.discrete&&(a===null&&I(191),a._flushSync=!0),o&&e._deferred.push(o),mg(e,i.tag)),a==null?Sg(e,n,i):n()}}return r}function Sg(e,t,n){let r=e._updateTags,i,a=!1,o=!1;n!==void 0&&(i=n.onUpdate,mg(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=Ag(c||s),l=!0),c._flushSync=o;let u=Xh,d=Qh,f=Zh,p=e._updating;Xh=c,Qh=!1,e._updating=!0,Zh=e;let m=e._headless||e.getRootElement()===null;n_(null);try{l&&(m?s._selection!==null&&(c._selection=s._selection.clone()):c._selection=function(e,t){let n=e.getEditorState()._selection,r=_v(ov(e));return V(n)||n==null?Nh(n,r,e,t):n.clone()}(e,n&&n.event||null));let r=e._compositionKey;t(),a=xg(e,a),function(e,t){let n=t.getEditorState()._selection,r=e._selection;if(V(r)){let e=r.anchor,t=r.focus,i;if(e.type===`text`&&(i=e.getNode(),i.selectionTransform(n,r)),t.type===`text`){let e=t.getNode();i!==e&&e.selectionTransform(n,r)}}}(c,e),e._dirtyType!==0&&(a?function(e,t){let n=t._dirtyLeaves,r=e._nodeMap;for(let e of n){let t=r.get(e);B(t)&&t.isAttached()&&t.isSimpleText()&&!t.isUnmergeable()&&af(t)}}(c,e):function(e,t){let n=t._dirtyLeaves,r=t._dirtyElements,i=e._nodeMap,a=C_(),o=/* @__PURE__ */ new Map,s=n,c=s.size,l=r,u=l.size;for(;c>0||u>0;){if(c>0){t._dirtyLeaves=/* @__PURE__ */ new Set;for(let e of s){let r=i.get(e);B(r)&&r.isAttached()&&r.isSimpleText()&&!r.isUnmergeable()&&af(r),r!==void 0&&pg(r,a)&&fg(t,r,o),n.add(e)}if(s=t._dirtyLeaves,c=s.size,c>0){ng++;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&&pg(c,a)&&fg(t,c,o)}s=t._dirtyLeaves,c=s.size,l=t._dirtyElements,u=l.size,ng++}t._dirtyLeaves=n,t._dirtyElements=r}(c,e),xg(e),function(e,t,n,r){let i=e._nodeMap,a=t._nodeMap,o=[];for(let[e]of r){let t=a.get(e);t!==void 0&&(t.isAttached()||(W(t)&&Nd(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()||(my(t)&&t.__slots!==null&&Nd(t,e,i,a,o,n),i.has(e)||n.delete(e),o.push(e))}for(let e of o)a.delete(e);let s=U(),c=s._compositionKey;c===null||a.has(c)||(s._compositionKey=null)}(s,c,e._dirtyLeaves,e._dirtyElements)),r!==e._compositionKey&&(c._flushSync=!0);let i=c._selection;if(V(i)){e._slotsUsed&&Dh(i);let t=c._nodeMap,n=i.anchor.key,r=i.focus.key;t.get(n)!==void 0&&t.get(r)!==void 0||I(19)}else dh(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(),_g(e);return}finally{Xh=u,Qh=d,Zh=f,e._updating=p,ng=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,_g(e)):l&&s_(()=>{_g(e)}):(c._flushSync=!1,l&&(r.clear(),e._deferred=[],e._pendingEditorState=null))}function Cg(e,t,n){Zh===e&&n===void 0?ig()?Sg(e,t,n):t():Sg(e,t,n)}function wg(e){if(uv(e)){let t=null;for(let n of e.getChildren())t=n.isInline()?(t||n.replace(n.createParentElementNode())).append(n):null}}var Tg=class extends Tm{__first;__last;__size;__format;__style;__indent;__dir;__textFormat;__textStyle;__slotHost;__slots;$config(){return this.config(Symbol.for(`ElementNode`),{$transform:wg,extends:Tm})}constructor(e){super(e),this.__first=null,this.__last=null,this.__size=0,this.__format=0,this.__style=``,this.__indent=0,this.__dir=null,this.__textFormat=0,this.__textStyle=``,this.__slotHost=null,this.__slots=null}afterCloneFrom(e){super.afterCloneFrom(e),this.__key===e.__key&&(this.__first=e.__first,this.__last=e.__last,this.__size=e.__size,this.__slotHost=e.__slotHost,this.__slotHost!==null&&this.__parent!==null&&I(384,this.__key,String(this.__slotHost),String(this.__parent)),this.__slots=e.__slots),this.__indent=e.__indent,this.__format=e.__format,this.__style=e.__style,this.__dir=e.__dir,this.__textFormat=e.__textFormat,this.__textStyle=e.__textStyle}getFormat(){return this.getLatest().__format}getFormatType(){let e=this.getFormat();return vd[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&&xy(this).length===0}isDirty(){let e=U()._dirtyElements;return e!==null&&e.has(this.__key)}isLastChild(){let e=this.getLatest(),t=this.getParentOrThrow().getLastChild();return t!==null&&t.is(e)}getAllTextNodes(){let e=[];for(let t of xy(this)){let n=Sy(this,t);W(n)&&e.push(...n.getAllTextNodes())}let t=this.getFirstChild();for(;t!==null;){if(B(t)&&e.push(t),W(t)){let n=t.getAllTextNodes();e.push(...n)}t=t.getNextSibling()}return e}getFirstDescendant(){let e=this.getFirstChild();for(;W(e);){let t=e.getFirstChild();if(t===null)break;e=t}return e}getLastDescendant(){let e=this.getLastChild();for(;W(e);){let t=e.getLastChild();if(t===null)break;e=t}return e}getDescendantByIndex(e){let t=this.getChildren(),n=t.length;if(e>=n){let e=t[n-1];return W(e)&&e.getLastDescendant()||e||null}let r=t[e];return W(r)&&r.getFirstDescendant()||r||null}getFirstChild(){let e=this.getLatest().__first;return e===null?null:w_(e)}getFirstChildOrThrow(){let e=this.getFirstChild();return e===null&&I(45,this.__key),e}getLastChild(){let e=this.getLatest().__last;return e===null?null:w_(e)}getLastChildOrThrow(){let e=this.getLastChild();return e===null&&I(96,this.__key),e}getChildAtIndex(e){let t=this.getChildrenSize(),n,r;if(e<t/2){for(n=this.getFirstChild(),r=0;n!==null&&r<=e;){if(r===e)return n;n=n.getNextSibling(),r++}return null}for(n=this.getLastChild(),r=t-1;n!==null&&r>=e;){if(r===e)return n;n=n.getPreviousSibling(),r--}return null}getTextContent(){let e=ky(this),t=this.getChildren(),n=t.length;for(let r=0;r<n;r++){let i=t[r];e+=i.getTextContent(),W(i)&&r!==n-1&&!i.isInline()&&(e+=`
|
|
152
143
|
|
|
153
|
-
`)}return e}getTextContentSize(){let e=function(e){let t=0;for(let n of
|
|
154
|
-
`}createDOM(){return xg().createElement(`br`)}updateDOM(){return!1}isInline(){return!0}};function Pm(e){return{node:Fm()}}function Fm(){return lg(new Nm)}function Im(e){return e instanceof Nm}function Lm(e){let t=e.parentElement;if(t!==null&&Ig(t)){let n=t.firstChild;if(n===e||n.nextSibling===e&&zm(n)){let n=t.lastChild;if(n===e||n.previousSibling===e&&zm(n))return!0}}return!1}function Rm(e){let t=e.parentElement;if(t!==null&&Ig(t)){let n=t.firstChild;if(n===e||n.nextSibling===e&&zm(n))return!1;let r=t.lastChild;if(r===e||r.previousSibling===e&&zm(r))return!0}return!1}function zm(e){return fh(e)&&/^( |\t|\r?\n)+$/.test(e.textContent||``)}var Bm=class extends Sm{$config(){return this.config(`paragraph`,{extends:Sm,importDOM:{p:()=>({conversion:Vm,priority:0})}})}createDOM(e){let t=xg().createElement(`p`),n=Gh(e.theme,`paragraph`);return n!==void 0&&t.classList.add(...n),t}updateDOM(e,t,n){return!1}exportDOM(e){let{element:t}=super.exportDOM(e);if(J(t)){this.isEmpty()&&t.append(xg().createElement(`br`));let e=this.getFormatType();e&&(t.style.textAlign=e)}return{element:t}}exportJSON(){let e=super.exportJSON();if(e.textFormat===void 0||e.textStyle===void 0){let t=this.getChildren().find(B);t?(e.textFormat=t.getFormat(),e.textStyle=t.getStyle()):(e.textFormat=this.getTextFormat(),e.textStyle=this.getTextStyle())}return e}insertNewAfter(e,t){let n=Hm();n.setTextFormat(e.format),n.setTextStyle(e.style);let r=this.getDirection();return n.setDirection(r),n.setFormat(this.getFormatType()),n.setStyle(this.getStyle()),this.insertAfter(n,t),n}collapseAtStart(){let e=this.getChildren();if(e.length===0||B(e[0])&&e[0].getTextContent().trim()===``){if(this.getNextSibling()!==null)return this.selectNext(),this.remove(),!0;if(this.getPreviousSibling()!==null)return this.selectPrevious(),this.remove(),!0}return!1}};function Vm(e){let t=Hm();if(Xg(t,e),Jg(e,t),t.getFormatType()===``){let n=e.getAttribute(`align`);n&&n&&n in hl&&t.setFormat(n)}return Yg(t,e),{node:t}}function Hm(){return lg(new Bm)}function Um(e){return e instanceof Bm}function Wm(e){console.warn(e)}function Gm(e,t,n,r,i){let a=e._keyToDOMMap;a.clear(),e._editorState=Om(),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),Ch(n,e,`root`))}function Km(e){let t=/* @__PURE__ */ new Set,n=/* @__PURE__ */ new Set;for(let{klass:r,ownNodeConfig:i}of a_(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 qm={$createDOM:(e,t)=>e.createDOM(t._config,t),$decorateDOM:(e,t,n,r)=>{},$exportDOM:(e,t)=>{let n=rh(t,e.getType());return n&&n.exportDOM!==void 0?n.exportDOM(t,e):e.exportDOM(t)},$extractWithChild:(e,t,n,r,i)=>W(e)&&e.extractWithChild(t,n,r),$getDOMSlot:(e,t,n)=>e.getDOMSlot(t),$getSlotTargetElement:(e,t,n,r)=>null,$shouldExclude:(e,t,n)=>W(e)&&e.excludeFromCopy(`html`),$shouldInclude:(e,t,n)=>!t||e.isSelected(t),$updateDOM:(e,t,n,r)=>e.updateDOM(t,n,r._config)};function Jm(e){let t=e||{},n=cm(),r=t.theme||{},i=e===void 0?n:t.parentEditor||null,a=t.disableEvents||!1,o=Om(),s=t.namespace||(i===null?Ph():i._config.namespace),c=t.editorState,l=[Tm,zf,Nm,Xf,Bm,Mm,...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===Cf||n.prototype instanceof Cf)){let r=`<unknown>`;try{r=JSON.parse(Dl)}catch{}I(365,String(e-l.length+(t.nodes?t.nodes.length:0)),typeof n==`function`?`${n.name}${typeof n.getType==`function`?` (type ${String(n.getType())})`:``}`:String(n),String(r))}i_(n);let a=n.getType(),o=Km(n);m.set(a,{exportDOM:f&&f.export?f.export.get(n):void 0,klass:n,replace:r,replaceWithKlass:i,sharedNodeState:Wl(l[e]),transforms:o})}}let h=new Zm(o,i,m,{disableEvents:a,dom:{...qm,...e&&e.dom},namespace:s,theme:r},u||console.error,d||Wm,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(ed,of,0),e.registerCommand(td,sf,0),e.registerCommand(nd,cf,0),e.registerCommand(rd,lf,0),e.registerCommand(hd,ff,0)}(h),h}function Ym(e,t){let n=e.get(t);e.delete(t),n&&n()}function Xm(e,t,n){return e.set(t,n),Ym.bind(null,e,t)}var Zm=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 Al,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=Ph(),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 Xm(this._listeners.update,e)}registerEditableListener(e){return Xm(this._listeners.editable,e)}registerDecoratorListener(e){return Xm(this._listeners.decorator,e)}registerTextContentListener(e){return Xm(this._listeners.textcontent,e)}registerRootListener(e){let t=this._listeners.root;return Nv(Xm(t,e,e(this._rootElement,null)||void 0),()=>function(e,t,n){let r=e.get(t);r&&r(),e.set(t,t(...n)||void 0)}(t,e,[null,this._rootElement]))}registerCommand(e,t,n){n===void 0&&I(35);let r=this._commands;r.has(e)||r.set(e,[new Ol,new Ol,new Ol,new Ol,new Ol]);let i=r.get(e);i===void 0&&I(36,String(e));let a=function(e){return 7&e}(n),o=i[a];return a===n?o.addBack(t):o.addFront(t),()=>{o.delete(t),i.every(e=>e.size===0)&&r.delete(e)}}registerMutationListener(e,t,n){let r=this.resolveRegisteredNodeAfterReplacements(this.getRegisteredNode(e)).klass,i=this._listeners.mutation,a=i.get(t);a===void 0&&(a=/* @__PURE__ */ new Set,i.set(t,a)),a.add(r);let o=n&&n.skipInitialization;return o!==void 0&&o||this.initializeMutationListener(t,r),()=>{a.delete(r),a.size===0&&i.delete(t)}}getRegisteredNode(e){let t=this._nodes.get(e.getType());return t===void 0&&I(37,e.name),t}resolveRegisteredNodeAfterReplacements(e){for(;e.replaceWithKlass;)e=this.getRegisteredNode(e.replaceWithKlass);return e}initializeMutationListener(e,t){let n=this._editorState,r=Gg(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=Gg(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=xh(t);e&&e.markDirty()}},e._pendingEditorState===null?{tag:Tf}:void 0)}(this,r.map(e=>e.klass.getType())),()=>{r.forEach(e=>e.transforms.delete(t))}}hasNode(e){return this._nodes.has(e.getType())}hasNodes(e){return e.every(this.hasNode.bind(this))}dispatchCommand(e,...t){return q(this,e,...t)}getDecorators(){return this._decorators}getRootElement(){return this._rootElement}getKey(){return this._key}setRootElement(e){let t=this._rootElement;if(e!==t){let n=Gh(this._config.theme,`root`),r=this._pendingEditorState||this._editorState;if(this._rootElement=e,Gm(this,t,e,r,{preserveUpdateQueue:!0}),t!==null&&(this._config.disableEvents||vf(t),n!=null&&t.classList.remove(...n)),e!==null){let t=ng(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,Vl(this),this._updateTags.add(Tf),mm(this),this._config.disableEvents||function(e,t){let n=e.ownerDocument;Kd.set(e,n);let r=qd.get(n);r===void 0&&(r={editors:/* @__PURE__ */ new Set,hasShadowEditor:void 0},qd.set(n,r)),r.editors.add(t),r.hasShadowEditor=void 0,e.__lexicalEditor=t;let i=pf(e);i.push(Jd.register(n));for(let n=0;n<Gd.length;n++){let[r,a]=Gd[n],o=typeof a==`function`?e=>{_f(e)||(gf(e),(t.isEditable()||r===`click`)&&a(e,t))}:e=>{if(_f(e))return;gf(e);let n=t.isEditable();switch(r){case`cut`:return n&&q(t,Nd,e);case`copy`:return q(t,Md,e);case`paste`:return n&&q(t,cd,e);case`dragstart`:return n&&q(t,kd,e);case`dragover`:return n&&q(t,Ad,e);case`dragend`:return n&&q(t,jd,e);case`focus`:return n&&q(t,zd,e);case`blur`:return n&&q(t,Bd,e);case`drop`:return n&&q(t,Od,e)}};i.push(Ud(e,r,o))}}(e,this),n!=null&&e.classList.add(...n)}else this._window=null,this._updateTags.add(Tf),mm(this);hm(`root`,this,!1,e,t)}}getElementByKey(e){return this._keyToDOMMap.get(e)||null}getEditorState(){return this._editorState}setEditorState(e,t){e.isEmpty()&&I(38);let n=e;n._readOnly&&(n=Dm(e),n._selection=e._selection?e._selection.clone():null),Bl(this);let r=this._pendingEditorState,i=t===void 0?null:t.tag;r===null||r.isEmpty()||(i!=null&&this._updateTags.add(i),mm(this)),this._pendingEditorState=n,this._dirtyType=2,this._dirtyElements.set(`root`,!1),this._compositionKey=null,this._slotsUsed=this._slotsUsed||e._slotsUsed,bm(this,()=>{if(i&&this._updateTags.add(i),e._parsed)for(let[e,t]of n._nodeMap.entries())W(t)?this._dirtyElements.set(e,!0):this._dirtyLeaves.add(e)},{discrete:!this._updating||void 0})}parseEditorState(e,t){return function(e,t,n){let r=Om(),i=qp,a=Yp,o=Jp,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,qp=r,Yp=!1,Jp=t,$m(null);try{let i=t._nodes;fm(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,qp=i,Yp=a,Jp=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`&&mm(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]):ym(e,t,n)})(this,e,t)}focus(e,t={}){let n=this._rootElement;n!==null&&(n.setAttribute(`autocapitalize`,`off`),bm(this,()=>{let r=H(),i=Oh();r===null?i.getChildrenSize()!==0&&(t.defaultSelection===`rootStart`?i.selectStart():i.selectEnd()):r.dirty||kh(r.clone()),$h(`focus`),eg(()=>{n.removeAttribute(`autocapitalize`),e&&e()})}),this._pendingEditorState===null&&n.removeAttribute(`autocapitalize`))}blur(){let e=this._rootElement;e!==null&&e.blur();let t=mg(this._window);t!==null&&t.removeAllRanges()}isEditable(){return this._editable}setEditable(e){this._editable!==e&&(this._editable=e,hm(`editable`,this,!0,e),this._slotsUsed&&this.update(()=>om()))}toJSON(){return{editorState:this._editorState.toJSON()}}};Zm.version=Dl;let Qm=null;function $m(e){Qm=e}let eh=Symbol(`INTERNAL_SKIP_AFTER_CLONE_FROM`),th=1;function nh(e,t){let n=rh(e,t);return n===void 0&&I(30,t),n}function rh(e,t){return e._nodes.get(t)}let ih=typeof queueMicrotask==`function`?queueMicrotask:e=>{Promise.resolve().then(e)};function ah(e,t){let n=t===void 0?(()=>{let t=e.getRootNode();return ph(t)||gg(t)?kg(t):null})():t;if(!J(n)||n.hasAttribute(`data-lexical-slot`))return!1;let r=Th(n),i=n.nodeName;return wf(r)&&(i===`INPUT`||i===`TEXTAREA`||n.contentEditable===`true`&&lh(n)==null)}function oh(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 ch(t)===e&&e.read(`latest`,()=>!ah(t))}function sh(e){return e instanceof Zm}function ch(e){let t=e;for(;t!=null;){let e=lh(t);if(sh(e))return e;t=Zh(t)}return null}function lh(e){return e?e.__lexicalEditor:null}function uh(e){return Qf(e)||e.isToken()}function dh(e){return uh(e)||e.isSegmented()}function fh(e){return jg(e)&&e.nodeType===3}function ph(e){return jg(e)&&e.nodeType===9}function mh(e){let t=e;for(;t!=null;){if(fh(t))return t;t=t.firstChild}return null}function hh(e,t,n){let r=pl[t];if(n!==null&&(e&r)===(n&r))return e;let i=e^r;return t===`subscript`?i&=~pl.superscript:t===`superscript`?i&=~pl.subscript:t===`lowercase`?(i&=~pl.uppercase,i&=~pl.capitalize):t===`uppercase`?(i&=~pl.lowercase,i&=~pl.capitalize):t===`capitalize`&&(i&=~pl.lowercase,i&=~pl.uppercase),i}function gh(e,t){let n=function(){let e=Qm;return Qm=null,e}();if((t||=n&&n.__key)!=null)return void(e.__key=t);nm(),rm();let r=U(),i=im(),a=``+th++;i._nodeMap.set(a,e),W(e)?r._dirtyElements.set(a,!0):r._dirtyLeaves.add(a),r._cloneNotNeeded.add(a),r._dirtyType===0&&(r._dirtyType=1),e.__key=a}function _h(e){p_(e)!==null&&I(380,e.__key,String(p_(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 vh(e){rm(),xf(e)&&I(323,e.__key,e.__type);let t=e.getLatest(),n=t.__parent===null?f_(t)?t.__slotHost:null:t.__parent,r=im(),i=U(),a=r._nodeMap,o=i._dirtyElements;n!==null&&function(e,t,n){let r=e;for(;r!==null;){if(n.has(r))return;let e=t.get(r);if(e===void 0)break;n.set(r,!1),r=e.__parent===null?f_(e)?e.__slotHost:null:e.__parent}}(n,a,o);let s=t.__key;i._dirtyType===0&&(i._dirtyType=1),W(e)?o.set(s,!0):i._dirtyLeaves.add(s)}function yh(e){nm();let t=U(),n=t._compositionKey;if(e!==n){if(t._compositionKey=e,n!==null){let e=xh(n);e!==null&&e.getWritable()}if(e!==null){let t=xh(e);t!==null&&t.getWritable()}}}function bh(){return tm()?null:U()._compositionKey}function xh(e,t){let n=(t||im())._nodeMap.get(e);return n===void 0?null:n}function Sh(e,t){let n=wh(e,U());return n===void 0?null:xh(n,t)}function Ch(e,t,n){e[`__lexicalKey_${t._key}`]=n}function wh(e,t){return e[`__lexicalKey_${t._key}`]}function Th(e,t){let n=e;for(;n!=null;){let e=Sh(n,t);if(e!==null)return e;n=Zh(n)}return null}function Eh(e){let t=e._decorators,n=Object.assign({},t);return e._pendingDecorators=n,n}function Dh(e){return e.read(()=>Oh().getTextContent())}function Oh(){return im()._nodeMap.get(`root`)}function kh(e){nm();let t=im();e!==null&&(e.dirty=!0,e.setCachedNodes(null),V(e)&&U()._slotsUsed&&wp(e)),t._selection=e}function Ah(){nm(),Bl(U())}function jh(e){let t=function(e,t){let n=e;for(;n!=null;){let e=wh(n,t);if(e!==void 0)return e;n=Zh(n)}return null}(e,U());return t===null?null:xh(t)}function Mh(e){return/[\uD800-\uDBFF][\uDC00-\uDFFF]/g.test(e)}function Nh(e){let t=[];for(let n=e;n!==null;n=n._parentEditor)t.push(n);return t}function Ph(){return Math.random().toString(36).replace(/[^a-z]+/g,``).substring(0,5)}function Fh(e){return fh(e)?e.nodeValue:null}function Ih(e,t,n){let r=mg(rg(t));if(r===null)return;let i=wg(r,t._rootElement),a=i.anchorNode,{anchorOffset:o,focusOffset:s}=i;if(a!==null){let t=Fh(a),r=Th(a);if(t!==null&&B(r)){if((t===ll||t===ul)&&n){let e=n.length;t=n,o=e,s=e}t!==null&&Lh(r,t,o,s,e)}}}function Lh(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(ll)&&(s=t.slice(0,-ll.length)),i)){let e=ul,t;for(;(t=s.indexOf(e))!==-1;)s=s.slice(0,t)+s.slice(t+e.length),n!==null&&n>t&&(n=Math.max(t,n-e.length)),r!==null&&r>t&&(r=Math.max(t,r-e.length))}let c=a.getTextContent();if(i||s!==c){let t=H();if(s===``){if(yh(null),al||rl||cl)a.remove();else{let e=U();Rh(a,``,t),setTimeout(()=>{e.update(()=>{a.isAttached()&&a.getTextContent()===``&&a.remove()})},20)}return}let i=a.getParent(),c=jp(),l=a.getTextContentSize(),u=bh(),d=a.getKey();if(a.isToken()&&!o||u!==null&&d===u&&!o||V(c)&&(i!==null&&!i.canInsertTextBefore()&&c.anchor.offset===0||c.anchor.key===e.__key&&c.anchor.offset===0&&!a.canInsertTextBefore()&&!o||c.focus.key===e.__key&&c.focus.offset===l&&!a.canInsertTextAfter()&&!o))return void a.markDirty();if(!V(t)||n===null||r===null)return void Rh(a,s,t);if(t.setTextNodeRange(a,n,a,r),a.isSegmented()){let e=Jf(a.getTextContent());a.replace(e),a=e}Rh(a,s,t)}}}function Rh(e,t,n){if(e.setTextContent(t),V(n)){let t=e.getKey(),r=!1;for(let i of[`anchor`,`focus`]){let a=n[i];a.type===`text`&&a.key===t&&(a.offset=J_(e,a.offset,`clamp`),r=!0)}r&&(n._cachedNodes=null,n._cachedIsBackward=null)}}function zh(e,t,n){let r=t[n]||!1;return r===`any`||r===e[n]}function Bh(e,t){return zh(e,t,`altKey`)&&zh(e,t,`ctrlKey`)&&zh(e,t,`shiftKey`)&&zh(e,t,`metaKey`)}function K(e,t,n){if(!Bh(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 Vh={ctrlKey:!el,metaKey:el},Hh={altKey:el,ctrlKey:!el};function Uh(e){return e.key===`Backspace`}function Wh(e){let t=Oh();if(V(e)){let t=e.anchor,n=e.focus,r=t.getNode();if(Em(r))return t.set(r.getKey(),0,`element`),n.set(r.getKey(),r.getChildrenSize(),`element`),ru(e),e;let i=r.getTopLevelElementOrThrow(),a=i.getParent();if(a===null)return W(i)&&(t.set(i.getKey(),0,`element`),n.set(i.getKey(),i.getChildrenSize(),`element`),ru(e)),e;let o=a;return t.set(o.getKey(),0,`element`),n.set(o.getKey(),o.getChildrenSize(),`element`),ru(e),e}{let e=t.select(0,t.getChildrenSize());return kh(ru(e)),e}}function Gh(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=jv(i);return n[t]=e,e}return i}function Kh(e,t,n,r,i){if(n.size===0)return;let a=r.__type,o=r.__key,s=t.get(a);s===void 0&&I(33,a);let c=s.klass,l=e.get(c);l===void 0&&(l=/* @__PURE__ */ new Map,e.set(c,l));let u=l.get(o),d=u===`destroyed`&&i===`created`;(u===void 0||d)&&l.set(o,d?`updated`:i)}function qh(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 Jh(e,t){let n=e.offset;if(e.type===`element`)return qh(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?qh(r.getParentOrThrow(),t,r.getIndexWithinParent()+ +!t):e}}return null}function Yh(e){let t=rg(e).event,n=t&&t.inputType;return n===`insertFromPaste`||n===`insertFromPasteAsQuotation`}function q(e,t,...n){return gm(e,t,n[0],e)}function Xh(e,t){let n=e._keyToDOMMap.get(t);return n===void 0&&I(75,t),n}function Zh(e){let t=e.assignedSlot||e.parentElement;if(t!==null)return t;let n=e.parentNode;return gg(n)?n.host:null}function Qh(e){return ph(e)?e:J(e)?e.ownerDocument:null}function $h(e){nm(),U()._updateTags.add(e)}function eg(e){nm(),U()._deferred.push(e)}function tg(e,t){let n=e.getParent();for(;n!==null;){if(n.is(t))return!0;n=n.getParent()}return!1}function ng(e){let t=Qh(e);return t?t.defaultView:null}function rg(e){let t=e._window;return t===null&&I(78),t}function ig(e){return W(e)&&e.isInline()||G(e)&&e.isInline()}function ag(e){let t=e.getLatest();for(;t!==null;){if(p_(t)!==null&&W(t))return t;let e=t.getParentOrThrow();if(sg(e))return e;t=e}return t}function og(e){return W(e)&&e.isShadowRoot()}function sg(e){return Em(e)||og(e)}function cg(e,t=!1){let n=e.constructor.clone(e,eh);return gh(n,null),n.afterCloneFrom(e),t||n.resetOnCopyNodeFrom(e),n}function lg(e){let t=U(),n=e.getType(),r=rh(t,n);r===void 0&&I(200,e.constructor.name,n);let{replace:i,replaceWithKlass:a}=r;if(i!==null){let t=i(e),r=t.constructor;return a===null?t instanceof e.constructor&&r!==e.constructor||I(202,r.name,r.getType(),e.constructor.name,n):t instanceof a||I(201,a.name,a.getType(),r.name,r.getType(),e.constructor.name,n),t.__key===e.__key&&I(203,e.constructor.name,n,r.name,r.getType()),t}return e}function ug(e,t){!Em(e.getParent())||W(t)||G(t)||I(99)}function dg(e){let t=xh(e);return t===null&&I(63,e),t}function fg(e){if(!e||e.isInline())return!1;if(G(e))return!0;if(W(e)){if(e.isShadowRoot()){let t=e.getParent();return!(W(t)&&t.isShadowRoot())}return!e.canBeEmpty()}return!1}function pg(e,t,n){n.style.removeProperty(`caret-color`),t._blockCursorElement=null;let r=e.parentElement;r!==null&&r.removeChild(e)}function mg(e){return Qc?(e||window).getSelection():null}function hg(e){let t=ng(e);return t?t.getSelection():null}function gg(e){return Mg(e)&&`host`in e}let _g=[];function vg(e){let t=e.getRootNode();if(t===e||!gg(t))return _g;let n=[t],r=t.host;for(;;){let e=r.getRootNode();if(e===r||!gg(e))break;n.push(e),r=e.host}return n}function*yg(e){let t=[e],n;for(;n=t.pop();){yield*n.querySelectorAll(`[data-lexical-editor="true"]`);let e=(ph(n)?n:n.ownerDocument).createTreeWalker(n,NodeFilter.SHOW_ELEMENT),r;for(;r=e.nextNode();)r.shadowRoot&&t.push(r.shadowRoot)}}function bg(e){return e===null?document:e.ownerDocument}function xg(){let e=cm();return bg(e===null?null:e._rootElement)}function Sg(e,t){if(t===null||typeof e.getComposedRanges!=`function`)return null;let n=vg(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 Cg(e,t){let n=Sg(e,t);if(n!==null){let e=Tg(n);if(e!==null)return e}return e.rangeCount>0?e.getRangeAt(0):null}function wg(e,t){let n=Sg(e,t);return n===null?e:Eg(n,Dg(e))}function Tg(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 Eg(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 Dg(e){return e.direction}function Og(e){let t=e.getRootNode();return ph(t)||gg(t)?t.activeElement:null}function kg(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 Ag(e){let t=e.target;if(t!==null&&J(t)&&t.shadowRoot!==null&&typeof e.composedPath==`function`){let t=e.composedPath();if(t.length>0)return t[0]}return t}function J(e){return jg(e)&&e.nodeType===1}function jg(e){return typeof e==`object`&&!!e&&`nodeType`in e&&typeof e.nodeType==`number`}function Mg(e){return jg(e)&&e.nodeType===11}let Ng=/^(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 Pg(e){return!(!J(e)||!e.style.display.startsWith(`inline`))||Ng.test(e.nodeName)}let Fg=/^(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 Ig(e){return(!J(e)||!e.style.display.startsWith(`inline`))&&Fg.test(e.nodeName)}function Lg(e){if(G(e)&&!e.isInline())return!0;if(!W(e)||sg(e))return!1;let t=e.getFirstChild(),n=t===null||Im(t)||B(t)||t.isInline();return!e.isInline()&&!1!==e.canBeEmpty()&&n}function Rg(){return U()}function zg(e=Rg()){return e._config.dom||qm}function Bg(e,t,n=Rg()){let r=zg(n).$getDOMSlot(e,t,n);return W(e)&&(Vg(r)||I(344,e.getKey(),e.getType())),r}function Vg(e){return e instanceof wl}function Hg(e,t,n=Rg()){return mh(Bg(e,t,n).element)}let Ug=/* @__PURE__ */ new WeakMap,Wg=/* @__PURE__ */ new Map;function Gg(e){if(!e._readOnly&&e.isEmpty())return Wg;e._readOnly||I(192);let t=Ug.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),Ug.set(e,t)),t}function Kg(e){let t=e.constructor.clone(e,eh);return t.afterCloneFrom(e),t}function qg(e){return(t=Kg(e))[bf]=!0,t;var t}function Jg(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 Yg(e,t){let n=t.getAttribute(`dir`);return n===`ltr`||n===`rtl`?e.setDirection(n):e}function Xg(e,t){let n=t.style.textAlign;return n&&n in hl?e.setFormat(n):e}function Zg(e,t){e.__lexicalUnmanaged=!0,t&&t.captureSelection!==void 0&&(e.__lexicalCapturedSelection=t.captureSelection)}function Qg(e){return!0===e.__lexicalUnmanaged}function $g(e,t=Rg()){let n=t.isEditable();e.contentEditable=n?`true`:`false`,n?e.__lexicalEditor=t:delete e.__lexicalEditor}function e_(e,t){let n=e;for(;n!=null;){if(!0===n.__lexicalCapturedSelection)return!0;if(J(n)&&n.hasAttribute(`data-lexical-slot`)||wh(n,t)!==void 0)return!1;n=Zh(n)}return!1}function t_(e,t){return function(e,t){return Object.prototype.hasOwnProperty.call(e,t)}(e,t)&&e[t]!==Cf[t]}let n_=/* @__PURE__ */ new WeakMap,r_=Symbol(`lexical.synthesizedGetType`);function i_(e){let t=n_.get(e);if(t)return t;let n=e.prototype!=null&&yl in e.prototype?e.prototype[yl]():void 0,r=function(e){if(!(e===Cf||e.prototype instanceof Cf)){let t=`<unknown>`,n=`<unknown>`;try{t=e.getType()}catch{}try{Zm.version&&(n=JSON.parse(Zm.version))}catch{}I(290,e.name,t,n)}return e===wm||e===Sm||e===Cf}(e),i=!r&&t_(e,`getType`)?e.getType:void 0,a=i&&!(r_ 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(!t_(e,`getType`)){let t=e,n=function(){return this===t?s:Cf.getType.call(this)};n[r_]=!0,e.getType=n}if(t_(e,`clone`)||(e.clone=(t,n)=>{$m(t);let r=new e;return n!==eh&&r.afterCloneFrom(t),r}),t_(e,`importJSON`)||(e.importJSON=o&&o.$importJSON||(t=>new e().updateFromJSON(t))),!t_(e,`importDOM`)&&o){let{importDOM:t}=o;t&&(e.importDOM=()=>t)}}let c={klass:e,ownNodeConfig:o,ownNodeType:s};return n_.set(e,c),c}function*a_(e){for(let t=e;t&&(t===Cf||wf(t.prototype));){let e=i_(t);yield e,t=e.ownNodeConfig&&e.ownNodeConfig.extends||l_(t)}}function o_(e){let t=Rg();return nm(),new(t.resolveRegisteredNodeAfterReplacements(t.getRegisteredNode(e))).klass}let s_=(e,t)=>{let n=e;for(;n!=null&&!Em(n);){if(t(n))return n;n=n.getParent()}return null};function c_(e,t){let n=[],r=e.__first;for(;r!==null;){let e=t===null?xh(r):t.get(r);e??I(174),n.push(r),r=e.__next}return n}function l_(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 u_=/* @__PURE__ */ new Map;function d_(e){return W(e)||G(e)}function f_(e){return W(e)||G(e)}function p_(e){let t=e.getLatest();return f_(t)?t.__slotHost:null}function m_(e){let t=p_(e);if(t===null)return null;let n=xh(t);return W(n)||G(n)||I(370),n}function h_(e){let t=m_(e);if(t===null)return null;let n=e.getLatest().__key;for(let[e,r]of __(t))if(r===n)return e;return null}function g_(e){let t=e.getLatest();for(;t!==null;){if(p_(t)!==null)return t;t=t.getParent()}return null}function __(e){let t=e.getLatest();return d_(t)&&t.__slots!==null?t.__slots:u_}function v_(e){return Array.from(__(e).keys())}function y_(e,t){let n=__(e).get(t);return n===void 0?null:xh(n)}let b_=[`__proto__`,`constructor`,`prototype`],x_=Symbol(`slotMapOwner`);function S_(e){let t=e.__slots;return t!==null&&t[x_]===e||(t=new Map(t),t[x_]=e,e.__slots=t),t}let C_=/* @__PURE__ */ new WeakMap,w_=[];function T_(e){for(let{ownNodeConfig:t}of a_(e)){let e=t&&t.slots;if(e)return e}return w_}function E_(e){let t=``;for(let n of v_(e)){let r=y_(e,n);r!==null&&(t+=r.getTextContent())}return t}function D_(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 O_(e){let t=e.__slots;if(t===null||t.size<2)return;let n=function(e){let t=C_.get(e);if(t===void 0){let n=T_(e),r=/* @__PURE__ */ new Map;for(let t of n)b_.includes(t)&&I(371,e.name,t),r.has(t)&&I(372,e.name,t),r.set(t,r.size);t=r,C_.set(e,t)}return t}(e.constructor),r=null,i=!0;for(let e of t.keys()){if(r!==null&&D_(r,e,n)>0){i=!1;break}r=e}if(i)return;let a=Array.from(t).sort(([e],[t])=>D_(e,t,n));t.clear();for(let[e,n]of a)t.set(e,n)}function k_(e,t,n){t!==`__proto__`&&t!==`constructor`&&t!==`prototype`||I(373,t);let r=e.getLatest();if(r.__slots!==null&&r.__slots.get(t)===n.getLatest().__key)return r;(!W(n)&&!G(n)||n.isInline())&&I(374,n.__key);let i=e.getWritable(),a=S_(i),o=a.get(t);o!==void 0&&j_(o);let s=n.getWritable(),c=m_(s);if(c!==null){let e=h_(s);e!==null&&S_(c.getWritable()).delete(e),s.__slotHost=null}return _h(s),s.__slotHost=i.__key,a.set(t,s.__key),O_(i),function(){let e=Rg();e._slotsUsed=!0,e._pendingEditorState&&(e._pendingEditorState._slotsUsed=!0)}(),i}function A_(e,t){let n=e.getWritable();if(n.__slots===null)return n;let r=n.__slots.get(t);return r!==void 0&&(j_(r),S_(n).delete(t)),n}function j_(e){let t=xh(e);if(t===null)return;let n=t.getWritable();f_(n)||I(377,e),n.__slotHost=null,n.remove()}let M_={next:`previous`,previous:`next`};var N_=class{origin;constructor(e){this.origin=e}[Symbol.iterator](){return iv({hasNext:V_,initial:this.getAdjacentCaret(),map:e=>e,step:e=>e.getAdjacentCaret()})}getAdjacentCaret(){return K_(this.getNodeAtCaret(),this.direction)}getSiblingCaret(){return K_(this.origin,this.direction)}remove(){let e=this.getNodeAtCaret();return e&&e.remove(),this}replaceOrInsert(e,t){let n=this.getNodeAtCaret();return e.is(this.origin)||e.is(n)||(n===null?this.insert(e):n.replace(e,t)),this}splice(e,t,n=`next`){let r=n===this.direction?t:Array.from(t).reverse(),i=this,a=this.getParentAtCaret(),o=/* @__PURE__ */ new Map;for(let t=i.getAdjacentCaret();t!==null&&o.size<e;t=t.getAdjacentCaret()){let e=t.origin.getWritable();o.set(e.getKey(),e)}for(let e of r){if(o.size>0){let t=i.getNodeAtCaret();if(t){if(o.delete(t.getKey()),o.delete(e.getKey()),!(t.is(e)||i.origin.is(e))){let n=e.getParent();n&&n.is(a)&&e.remove(),t.replace(e)}}else t===null&&I(263,Array.from(o).join(` `))}else i.insert(e);i=K_(e,this.direction)}for(let e of o.values())e.remove();return this}},P_=class e extends N_{type=`child`;getLatest(){let e=this.origin.getLatest();return e===this.origin?this:X_(e,this.direction)}getParentCaret(e=`root`){return K_(L_(this.getParentAtCaret(),e),this.direction)}getFlipped(){let e=I_(this.direction);return K_(this.getNodeAtCaret(),e)||X_(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 F_={root:Em,shadowRoot:sg};function I_(e){return M_[e]}function L_(e,t=`root`){return e===null||F_[t](e)?null:p_(e)===null?e:null}var R_=class e extends N_{type=`sibling`;getLatest(){let e=this.origin.getLatest();return e===this.origin?this:K_(e,this.direction)}getSiblingCaret(){return this}getParentAtCaret(){return this.origin.getParent()}getChildCaret(){return W(this.origin)?X_(this.origin,this.direction):null}getParentCaret(e=`root`){return K_(L_(this.getParentAtCaret(),e),this.direction)}getFlipped(){let e=I_(this.direction);return K_(this.getNodeAtCaret(),e)||X_(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 z_)&&this.direction===t.direction&&this.origin.is(t.origin)}},z_=class e extends N_{type=`text`;offset;constructor(e,t){super(e),this.offset=t}getLatest(){let e=this.origin.getLatest();return e===this.origin?this:q_(e,this.direction,this.offset)}getParentAtCaret(){return this.origin.getParent()}getChildCaret(){return null}getParentCaret(e=`root`){return K_(L_(this.getParentAtCaret(),e),this.direction)}getFlipped(){return q_(this.origin,I_(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 R_||t instanceof e)&&this.direction===t.direction&&this.origin.is(t.origin)}getSiblingCaret(){return K_(this.origin,this.direction)}};function B_(e){return e instanceof z_}function V_(e){return e instanceof R_}function H_(e){return e instanceof P_}let U_={next:class extends z_{direction=`next`;getNodeAtCaret(){return this.origin.getNextSibling()}insert(e){return this.origin.insertAfter(e),this}},previous:class extends z_{direction=`previous`;getNodeAtCaret(){return this.origin.getPreviousSibling()}insert(e){return this.origin.insertBefore(e),this}}},W_={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}}},G_={next:class extends P_{direction=`next`;getNodeAtCaret(){return this.origin.getFirstChild()}insert(e){return this.origin.splice(0,0,[e]),this}},previous:class extends P_{direction=`previous`;getNodeAtCaret(){return this.origin.getLastChild()}insert(e){return this.origin.splice(this.origin.getChildrenSize(),0,[e]),this}}};function K_(e,t){return e?new W_[t](e):null}function q_(e,t,n){return e?new U_[t](e,J_(e,n)):null}function J_(e,t,n=`error`){let r=e.getTextContentSize(),i=t===`next`?r:t===`previous`?0:t;return(i<0||i>r)&&(n!==`clamp`&&Zc(284,String(t),String(r),e.getKey()),i=i<0?0:r),i}function Y_(e,t){return new ev(e,t)}function X_(e,t){return W(e)?new G_[t](e):null}function Z_(e){return e&&e.getChildCaret()||e}function Q_(e){return e&&Z_(e.getAdjacentCaret())}var $_=class e{type=`node-caret-range`;direction;anchor;focus;constructor(e,t,n){this.anchor=e,this.focus=t,this.direction=n}getLatest(){let t=this.anchor.getLatest(),n=this.focus.getLatest();return t===this.anchor&&n===this.focus?this:new e(t,n,this.direction)}isCollapsed(){return this.anchor.isSamePointCaret(this.focus)}getTextSlices(){let e=e=>{let t=this[e].getLatest();return B_(t)?function(e,t){let{direction:n,origin:r}=e;return Y_(e,J_(r,t===`focus`?I_(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[Y_(e,r.offset-e.offset),null]}return[t,n]}iterNodeCarets(e=`root`){let t=B_(this.anchor)?this.anchor.getSiblingCaret():this.anchor.getLatest(),n=this.focus.getLatest(),r=B_(n),i=t=>t.isSameNodeCaret(n)?null:Q_(t)||t.getParentCaret(e);return iv({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`)}},ev=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 q_(e.setTextContent(i.slice(0,n)+i.slice(r)),t,n)}};function tv(e){return rv(e,K_(Oh(),e.direction))}function nv(e){return rv(e,e)}function rv(e,t){return e.direction!==t.direction&&I(265),new $_(e,t,e.direction)}function iv(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 av(e,t){let n=lv(e.origin,t.origin);switch(n===null&&I(275,e.origin.getKey(),t.origin.getKey()),n.type){case`same`:{let n=e.type===`text`,r=t.type===`text`;return n&&r?function(e,t){return Math.sign(e-t)}(e.offset,t.offset):e.type===t.type?0:n?-1:r?1:e.type===`child`?-1:1}case`ancestor`:return e.type===`child`?-1:1;case`descendant`:return t.type===`child`?1:-1;case`branch`:return ov(n)}}function ov(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 sv(e,t){return t.is(e)}function cv(e){return W(e)?[e.getLatest(),null]:[e.getParent(),e.getLatest()]}function lv(e,t){if(e.is(t))return{commonAncestor:e,type:`same`};let n=/* @__PURE__ */ new Map;for(let[t,r]=cv(e);t;r=t,t=t.getParent())n.set(t,r);for(let[r,i]=cv(t);r;i=r,r=r.getParent()){let a=n.get(r);if(a!==void 0)return a===null?(sv(e,r)||I(276),{commonAncestor:r,type:`ancestor`}):i===null?(sv(t,r)||I(277),{commonAncestor:r,type:`descendant`}):((W(a)||sv(e,a))&&(W(i)||sv(t,i))&&r.is(a.getParent())&&r.is(i.getParent())||I(278),{a,b:i,commonAncestor:r,type:`branch`})}return null}function uv(e,t){let{type:n,key:r,offset:i}=e,a=dg(e.key);return n===`text`?(B(a)||I(266,a.getType(),r),q_(a,t,i)):(W(a)||I(267,a.getType(),r),Cv(a,e.offset,t))}function dv(e,t){let{origin:n,direction:r}=t,i=r===`next`;B_(t)?e.set(n.getKey(),t.offset,`text`):V_(t)?B(n)?e.set(n.getKey(),J_(n,r),`text`):e.set(n.getParentOrThrow().getKey(),n.getIndexWithinParent()+ +!!i,`element`):(H_(t)&&W(n)||I(268),e.set(n.getKey(),i?0:n.getChildrenSize(),`element`))}function fv(e){let t=H(),n=V(t)?t:Op();return pv(n,e),kh(n),n}function pv(e,t){dv(e.anchor,t.anchor),dv(e.focus,t.focus)}function mv(e){let{anchor:t,focus:n}=e,r=uv(t,`next`),i=uv(n,`next`),a=av(r,i)<=0?`next`:`previous`;return rv(xv(r,a),xv(i,a))}function hv(e){let{direction:t,origin:n}=e,r=K_(n,I_(t)).getNodeAtCaret();return r?K_(r,t):X_(n.getParentOrThrow(),t)}function gv(e,t=`root`){let n=[e];for(let r=H_(e)?e.getParentCaret(t):e.getSiblingCaret();r!==null;r=r.getParentCaret(t))n.push(hv(r));return n}function _v(e){return!!e&&e.origin.isAttached()}function vv(e,t=`removeEmptySlices`){if(e.isCollapsed())return e;let n=`root`,r=`next`,i=t,a=Sv(e,r),o=gv(a.anchor,n),s=gv(a.focus.getFlipped(),n),c=/* @__PURE__ */ new Set,l=[];for(let e of a.iterNodeCarets(n))if(H_(e))c.add(e.origin.getKey());else if(V_(e)){let{origin:t}=e;W(t)&&!c.has(t.getKey())||l.push(t)}let u=/* @__PURE__ */ new Set;for(let e of l){let t=e.getParent();t===null||c.has(t.getKey())||u.add(t),_h(e)}for(let e of u)!e.canBeEmpty()&&!sg(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=hv(K_(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=Jf(e.getTextContent()).setStyle(e.getStyle()).setFormat(e.getFormat());a.replaceOrInsert(n),t=q_(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(_v(e)){d=yv(e);break}for(let e of s)if(_v(e)){f=yv(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(sg(i))return;!n&&t(i)&&(n=i)}return n},u=l(a,Lg),d=u&&l(o,e=>n.has(e.getKey())&&Lg(e));return d&&v_(d).length>0?null:u&&d?[u,d]:null}(d,f,c);if(p){let[e,t]=p;X_(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(H_(e)){let t=e.origin;if(Lg(t))return t}else{let t=e.getParentAtCaret();if(t&&Lg(t))return t}return null}(f),t=e&&e.getParent(),n=e&&e.getParents().findLast(og);if(e&&t&&!Em(t)&&e.isEmpty()&&c.has(e.getKey())&&v_(e).length===0&&(!n||c.has(n.getKey()))){e.remove(!0);let n=t;for(;n&&!Em(n)&&n.isEmpty();){let e=n.getParent();if(e&&Em(e)&&e.getChildrenSize()<=1)break;let t=n;n=e,t.remove(!0)}}}let m=[d,f,...o,...s].find(_v);if(m)return nv(xv(yv(m),e.direction));I(269,JSON.stringify(o.map(e=>e.origin.__key)))}function yv(e){let t=function(e){let t=e;for(;H_(t);){let e=Q_(t);if(!H_(e))break;t=e}return t}(e.getLatest()),{direction:n}=t;if(B(t.origin))return B_(t)?t:q_(t.origin,n,n);let r=t.getAdjacentCaret();return V_(r)&&B(r.origin)?q_(r.origin,n,I_(n)):t}function bv(e){return B_(e)&&e.offset!==J_(e.origin,e.direction)}function xv(e,t){return e.direction===t?e:e.getFlipped()}function Sv(e,t){return e.direction===t?e:rv(xv(e.focus,t),xv(e.anchor,t))}function Cv(e,t,n){let r=X_(e,`next`);for(let e=0;e<t;e++){let e=r.getAdjacentCaret();if(e===null)break;r=e}return xv(r,n)}function wv(e){let{origin:t,offset:n,direction:r}=e;if(n===J_(t,r))return e.getSiblingCaret();if(n===J_(t,I_(r)))return hv(e.getSiblingCaret());let[i]=t.splitText(n);return B(i)||I(281),xv(K_(i,`next`),r)}function Tv(e,t){return!0}function Ev(e,{$copyElementNode:t=cg,$splitTextPointCaretNext:n=wv,rootMode:r=`shadowRoot`,$shouldSplit:i=Tv,removeEmptyDestination:a=!1}={}){if(B_(e))return n(e);let o=e.getParentCaret(r);if(o){let{origin:n}=o;if(H_(e)){let e=hv(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 Dv(e,t,n){let r=xv(t,`next`);B_(r)&&(r.offset===0?r=K_(r.origin,`previous`).getFlipped():r.offset===r.origin.getTextContentSize()&&(r=K_(r.origin,`next`))),r.origin.is(e)&&(V_(r)||I(342,e.getKey(),e.getType()),r=hv(r)),(e.is(r.getNodeAtCaret())||e.is(r.getFlipped().getNodeAtCaret()))&&e.remove(!0);for(let e=r;e;e=Ev(e,n))r=e;return B_(r)&&I(283),r.insert(e.isInline()?Hm().append(e):e),xv(K_(e.getLatest(),`next`),t.direction)}function Ov(e){return e}function kv(e){return e}function Av(e,t){if(!t||e===t)return e;for(let n in t)if(e[n]!==t[n])return{...e,...t};return e}function jv(...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 Mv(e,...t){let n=jv(...t);n.length>0&&e.classList.add(...n)}function Nv(...e){return()=>{for(let t=e.length-1;t>=0;t--)e[t]();e.length=0}}function Pv(e){throw Error(`unreachable input event: ${JSON.stringify(e)}`)}function Fv(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 Iv(e,t){return e.startsWith(t)||e===t.trimEnd()}var Lv=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 Pv(e)}}onDraftChanged(e){return this.phase===`claimed`&&this.claim!==void 0&&!Iv(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:Fv(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:Fv(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&&Iv(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 Rv(e){let t=Rg().getElementByKey(e.getKey());if(t===null)return null;let n=t.ownerDocument.defaultView;return n===null?null:n.getComputedStyle(t)}function zv(e){return Rv(Em(e)?e:e.getParentOrThrow())}function Bv(e,t,n=`self`){let r=e.getStartEndPoints();if(t.isSelected(e)&&!dh(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]=fp(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=qg(t)),t.__text=p)}}return t}function Vv(e){let t=Hv(e);return t!==null&&t.writingMode===`vertical-rl`}function Hv(e){let t=e.anchor.getNode();return W(t)?Rv(t):zv(t)}function Uv(e,t){let n=Vv(e)?!t:t;Gv(e)&&(n=!n);let r=uv(e.focus,n?`previous`:`next`);if(bv(r))return!1;if(B_(r)&&!Qf(r.origin)&&r.origin.isUnmergeable()){let e=r.getNodeAtCaret();if(B(e)&&!Qf(e))return!0}for(let e of tv(r)){if(H_(e))return!e.origin.isInline();if(!W(e.origin)){if(G(e.origin))return!0;break}}return!1}function Wv(e,t,n,r){e.modify(t?`extend`:`move`,n,r)}function Gv(e){let t=Hv(e);return t!==null&&t.direction===`rtl`}function Kv(e,t,n){let r=Gv(e),i;i=Vv(e)||r?!n:n,Wv(e,t,i,`character`)}function qv(e,t){return e!==null&&Object.getPrototypeOf(e).constructor.name===t.name}let Jv=Symbol.for(`preact-signals`);function Yv(){if($v>1)return void $v--;let e,t=!1;for(function(){let e=Qv;for(Qv=void 0;e!==void 0;)e.S.v===e.v&&(e.S.i=e.i),e=e.o}();Xv!==void 0;){let n=Xv;for(Xv=void 0,ey++;n!==void 0;){let r=n.u;if(n.u=void 0,n.f&=-3,!(8&n.f)&&iy(n))try{n.c()}catch(n){t||=(e=n,!0)}n=r}}if(ey=0,$v--,t)throw e}let Y,Xv;function Zv(e){let t=Y;Y=void 0;try{return e()}finally{Y=t}}let Qv,$v=0,ey=0,ty=0;function ny(e){if(Y===void 0)return;let t=e.n;return t===void 0||t.t!==Y?(t={i:0,S:e,p:Y.s,n:void 0,t:Y,e:void 0,x:void 0,r:t},Y.s!==void 0&&(Y.s.n=t),Y.s=t,e.n=t,32&Y.f&&e.S(t),t):t.i===-1?(t.i=0,t.n!==void 0&&(t.n.p=t.p,t.p!==void 0&&(t.p.n=t.n),t.p=Y.s,t.n=void 0,Y.s.n=t,Y.s=t),t):void 0}function ry(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 iy(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 ay(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 oy(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 sy(e,t){ry.call(this,void 0),this.x=e,this.s=void 0,this.g=ty-1,this.f=4,this.W=t?.watched,this.Z=t?.unwatched,this.name=t?.name}function cy(e){let t=e.m;if(e.m=void 0,typeof t==`function`){$v++;let n=Y;Y=void 0;try{t()}catch(t){throw e.f&=-2,e.f|=8,ly(e),t}finally{Y=n,Yv()}}}function ly(e){for(let t=e.s;t!==void 0;t=t.n)t.S.U(t);e.x=void 0,e.s=void 0,cy(e)}function uy(e){if(Y!==this)throw Error(`Out-of-order effect`);oy(this),Y=e,this.f&=-2,8&this.f&&ly(this),Yv()}function dy(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 fy(e,t){let n=new dy(e,t);try{n.c()}catch(e){throw n.d(),e}let r=n.d.bind(n);return r[Symbol.dispose]=r,r}ry.prototype.brand=Jv,ry.prototype.h=function(){return!0},ry.prototype.S=function(e){let t=this.t;t!==e&&e.e===void 0&&(e.x=t,this.t=e,t===void 0?Zv(()=>{var e;(e=this.W)==null||e.call(this)}):t.e=e)},ry.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&&Zv(()=>{var e;(e=this.Z)==null||e.call(this)}))}},ry.prototype.subscribe=function(e){return fy(()=>{let t=this.value,n=Y;Y=void 0;try{e(t)}finally{Y=n}},{name:`sub`})},ry.prototype.valueOf=function(){return this.value},ry.prototype.toString=function(){return this.value+``},ry.prototype.toJSON=function(){return this.value},ry.prototype.peek=function(){let e=Y;Y=void 0;try{return this.value}finally{Y=e}},Object.defineProperty(ry.prototype,"value",{get(){let e=ny(this);return e!==void 0&&(e.i=this.i),this.v},set(e){if(e!==this.v){if(ey>100)throw Error(`Cycle detected`);(function(e){$v!==0&&ey===0&&e.l!==0&&(e.l=0,Qv={S:e,v:e.v,i:e.i,o:Qv})})(this),this.v=e,this.i++,ty++,$v++;try{for(let e=this.t;e!==void 0;e=e.x)e.t.N()}finally{Yv()}}}}),sy.prototype=new ry,sy.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===ty))return!0;if(this.g=ty,this.f|=1,this.i>0&&!iy(this))return this.f&=-2,!0;let e=Y;try{ay(this),Y=this;let e=this.x();(16&this.f||this.v!==e||this.i===0)&&(this.v=e,this.f&=-17,this.i++)}catch(e){this.v=e,this.f|=16,this.i++}return Y=e,oy(this),this.f&=-2,!0},sy.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)}ry.prototype.S.call(this,e)},sy.prototype.U=function(e){if(this.t!==void 0&&(ry.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)}},sy.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(sy.prototype,"value",{get(){if(1&this.f)throw Error(`Cycle detected`);let e=ny(this);if(this.h(),e!==void 0&&(e.i=this.i),16&this.f)throw this.v;return this.v}}),dy.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()}},dy.prototype.S=function(){if(1&this.f)throw Error(`Cycle detected`);this.f|=1,this.f&=-9,cy(this),ay(this),$v++;let e=Y;return Y=this,uy.bind(this,e)},dy.prototype.N=function(){2&this.f||(this.f|=2,this.u=Xv,Xv=this)},dy.prototype.d=function(){this.f|=8,1&this.f||ly(this)},dy.prototype.dispose=function(){this.d()};function py(e){return(typeof e.nodes==`function`?e.nodes():e.nodes)||[]}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 hy;try{hy=`0.49.0+prod.esm`}catch{}let gy=hy??`"<unknown>+source"`,_y=/* @__PURE__ */ new Set([`__proto__`,`constructor`,`prototype`]);function vy(e,t){if(e&&t&&!Array.isArray(t)&&typeof e==`object`&&typeof t==`object`){let n=e,r=t;for(let e in r)!_y.has(e)&&Object.prototype.hasOwnProperty.call(r,e)&&(n[e]=vy(n[e],r[e]));return e}return t}function yy(e){return e.id===0}function by(e){return e.id===2}function xy(e){return function(e){return e.id===1}(e)||my(305,String(e.id),`1`),Object.assign(e,{id:2})}let Sy=/* @__PURE__ */ new Set;var Cy=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):Av;for(let n of this.configs)e=t(e,n);return e}init(e){let t=this.state;by(t)||my(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&&my(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&&my(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&&my(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&&my(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&&my(311),this._signal}getInitResult(){this.extension.init===void 0&&my(312,this.extension.name);let e=this.state;return function(e){return e.id>=4}(e)||my(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)||my(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&&my(315,this.extension.name,e.name),t.getExtensionInitDependency()}getDependency(e){let t=this.builder.getExtensionRep(e);return t===void 0&&my(315,this.extension.name,e.name),t.getExtensionDependency()}getState(){let e=this.state;return function(e){return e.id>=7}(e)||my(316,String(e.id),`7`),e}getDirectDependentNames(){return this.builder.incomingEdges.get(this.extension.name)||Sy}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)||my(317,this.extension.name),this._dependency={config:e.config,init:e.initResult,output:e.output}}return this._dependency}};let wy={tag:Tf};function Ty(){let e=Oh();e.isEmpty()&&e.append(Hm())}let Ey=/* @__PURE__ */ Ov({config:/* @__PURE__ */ kv({setOptions:wy,updateOptions:wy}),init:({$initialEditorState:e=Ty})=>({$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(Am(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:[Tm,zf,Nm,Xf,Bm]}),Dy=Symbol.for(`@lexical/extension/LexicalBuilder`);function Oy(){}function ky(e){throw e}function Ay(e){return Array.isArray(e)?e:[e]}let jy=gy;var My=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=jy,this.roots=e;for(let t of e)this.addExtension(t)}static fromExtensions(t){let n=[Ay(Ey)];for(let e of t)n.push(Ay(e));return new e(n)}static maybeFromEditor(t){let n=t[Dy];return n&&(n.PACKAGE_VERSION!==jy&&my(292,n.PACKAGE_VERSION,jy),n instanceof e||my(293)),n}static fromEditor(t){let n=e.maybeFromEditor(t);return n===void 0&&my(294),n}constructEditor(){let{$initialEditorState:e,onError:t,onWarn:n,...r}=this.buildCreateEditorArgs(),i=Object.assign(Jm({...r,...t?{onError:e=>{t(e,i)}}:{},...n?{onWarn:e=>{n(e,i)}}:{}}),{[Dy]:this});for(let e of this.sortedExtensionReps())e.build(i);return i}buildEditor(){let e=Oy;function t(){try{e()}finally{e=Oy}}let n=Object.assign(this.constructEditor(),{dispose:t,[Symbol.dispose]:t});return e=Nv(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&&my(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&&my(296);let[t]=Ay(e);typeof t.name!=`string`&&my(297,typeof t.name);let n=this.extensionNameMap.get(t.name);if(n!==void 0&&n.extension!==t&&my(298,t.name),!n){n=new Cy(this,t),this.extensionNameMap.set(t.name,n);let e=this.conflicts.get(t.name);typeof e==`string`&&my(299,t.name,e);for(let e of t.conflictsWith||[])this.extensionNameMap.has(e)&&my(299,t.name,e),this.conflicts.set(e,t.name);for(let e of t.dependencies||[]){let n=Ay(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(by(i))return;let a=n.extension.name;var o;yy(i)||my(300,a,r||`[unknown]`),yy(o=i)||my(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=xy(i),n.state=i,e.push(n)};for(let e of this.extensionNameMap.values())yy(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&&my(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 Nv(...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 py(o)){if(typeof e!=`function`){let t=n.get(e.replace);t&&my(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&&vy(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||=ky,e}};function Ny(e,t){let n=My.maybeFromEditor(e);if(!n)return;let r=n.extensionNameMap.get(t);return r?r.getExtensionDependency():void 0}var Py=class extends wm{$config(){return this.config(`horizontalrule`,{importDOM:{hr:()=>({conversion:Fy,priority:0})}})}exportDOM(){return{element:xg().createElement(`hr`)}}createDOM(e){let t=xg().createElement(`hr`);return Mv(t,e.theme.hr),t}getTextContent(){return`
|
|
155
|
-
`}isInline(){return!1}updateDOM(){return!1}};function Fy(){return{node:Iy()}}function Iy(){return o_(Py)}Date.now;function Ly(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 Ry;function zy(e,t){let{key:n}=t;return e&&n in e?e[n]:t.defaultValue}function By(e){return Ry&&Ry.editor===e?Ry:void 0}function Vy(e,t){if(`cfg`in t){let{cfg:n,updater:r}=t;return[n,r(zy(e,n))]}return t}function Hy(e,t){let n=t;for(let r of e){let[e,i]=Vy(n,r),a=e.key;if(n===t&&zy(n,e)===i)continue;let o=n===t||n===void 0?Uy(t):n;o[a]=i,n=o}return n}function Uy(e){return Object.create(e||null)}function Wy(e,t){return[e,t]}function Gy(e,t,n,r=Rg()){let i=Ry,a=By(r);try{return Ry={...a,editor:r,[e]:t},n()}finally{Ry=i}}function Ky(e,t=()=>{}){return(n,r=Rg())=>i=>{let a=By(r),o=a&&a[e],s=Hy(n,o||t(r));return s&&s!==o?Gy(e,s,i,r):i()}}function qy(e,t,n,r){return Object.assign(Ul(Symbol(t),{isEqual:r,parse:n}),{[e]:!0})}let Jy=`@lexical/html/DOM`,Yy=Symbol.for(`@lexical/html/DOMExportContext`);function Xy(e,t,n){return qy(Yy,e,t,n)}let Zy=/* @__PURE__ */ Xy(`isExport`,Boolean);function Qy(e){let t=Ny(e,Jy);return t?t.output.defaults:void 0}function $y(e){let t=Ny(e,Jy);return t?t.output.runtime:void 0}function eb(e=Rg()){let t=$y(e);return t?t.getSessionConfig():zg(e)}let tb=Ky(Yy,Qy),nb=Symbol.for(`@lexical/html/SelectorImpl`);function rb(e,t){let n={kind:`element`,predicate:(r=t,r.length===0?J:r.length===1?r[0]:(e,t)=>{for(let n of r)if(!n(e,t))return!1;return!0}),tags:e};var r;let i=n=>rb(e,[...t,n]);return{[nb]:n,attr:(e,t,n)=>i(ob(e,t,n)),classAll:(...e)=>i(ab(e)),classAny:(...e)=>i(function(e){let t=ib(e);return t.length===0?()=>!1:e=>{if(!J(e))return!1;let n=e.classList;for(let e of t)if(n.contains(e))return!0;return!1}}(e)),styleAny:(e,t,n)=>i(function(e,t,n){if(typeof t==`string`)return n=>J(n)&&n.style.getPropertyValue(e)===t;if(t instanceof RegExp){let r=n&&n.capture,i=t;return(t,n)=>{if(!J(t))return!1;let a=t.style.getPropertyValue(e);if(!a)return!1;let o=a.match(i);return o!==null&&(r!==void 0&&(n[r]=o),!0)}}Ly(362,JSON.stringify(e))}(e,t,n))}}function ib(e){let t=[];for(let n of e)n&&t.push(n);return t}function ab(e){let t=ib(e);return t.length===0?()=>!0:e=>{if(!J(e))return!1;let n=e.classList;for(let e of t)if(!n.contains(e))return!1;return!0}}function ob(e,t,n){if(!0===t)return t=>J(t)&&t.hasAttribute(e);if(typeof t==`string`)return n=>J(n)&&n.getAttribute(e)===t;if(t instanceof RegExp){let r=n&&n.capture,i=t;return(t,n)=>{if(!J(t))return!1;let a=t.getAttribute(e);if(a==null)return!1;let o=a.match(i);return o!==null&&(r!==void 0&&(n[r]=o),!0)}}Ly(361,JSON.stringify(e))}let sb={kind:`text`,predicate:fh,tags:/* @__PURE__ */ new Set},cb={[nb]:sb},lb={kind:`comment`,predicate:e=>e.nodeType===8,tags:/* @__PURE__ */ new Set},ub={[nb]:lb},db={any:()=>rb(/* @__PURE__ */ new Set,[]),comment:()=>ub,tag(...e){e.length>0||Ly(363);let t=/* @__PURE__ */ new Set;for(let n of e)t.add(n.toUpperCase());return rb(t,[])},text:()=>cb},fb=db;fb.tag(`b`,`strong`,`em`,`i`,`code`,`mark`,`s`,`sub`,`sup`,`u`,`span`),fb.text(),fb.tag(`script`,`style`),fb.tag(`br`),fb.tag(`p`),fb.tag(`hr`),fb.any(),Object.freeze([]),Object.freeze({}),db.any(),db.any,db.comment,db.tag,db.text;function pb(e,t=null,n=Rg()){return tb([Wy(Zy,!0)],n)(()=>{let r=Oh(),i=eb(n),a=V(t)?g_(t.anchor.getNode()):null,o=e.append.bind(e);for(let e of(W(a)?a:r).getChildren())hb(n,e,o,t,i);return e})}function mb(e,t=null){return(typeof document>`u`||typeof window>`u`&&global.window===void 0)&&Ly(338),am(e),pb(xg().createElement(`div`),t,e).innerHTML}function hb(e,t,n,r=null,i=zg(e)){let a=i.$shouldInclude(t,r,e),o=i.$shouldExclude(t,r,e),s=t;r!==null&&B(t)&&(s=Bv(r,t,`clone`));let{element:c,after:l,append:u,$getChildNodes:d}=i.$exportDOM(s,e);if(!c)return!1;let f=xg().createDocumentFragment(),p=d?d():W(s)?s.getChildren():[],m=a&&cp(r)&&W(t)?null:r,h=f.append.bind(f);for(let n of p){let o=hb(e,n,h,m,i);!a&&o&&i.$extractWithChild(t,n,r,`html`,e)&&(a=!0)}if(a&&!o){if((J(c)||Mg(c))&&(u?u(f):c.append(f)),n(c),l){let e=l.call(s,c);e&&(Mg(c)?c.replaceChildren(e):c.replaceWith(e))}}else n(f);return a}function gb(e,t,n=null){let r=bg(n),i=n?vg(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=Zh(n)}return!1}(a.offsetNode,n))return{node:a.offsetNode,offset:a.offset}}if(a){let i=n.getRootNode();if(gg(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 _b(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 vb(e,t=H()){return t??_b(166),V(t)&&t.isCollapsed()||t.getNodes().length===0?``:mb(e,t)}function yb(e,t){let n=e.getData(`text/plain`)||e.getData(`text/uri-list`);n!=null&&t.insertRawText(n)}let bb=`application/x-lexical-drag`;function xb(e,t){let n={editorKey:t.getKey()};e.setData(bb,JSON.stringify(n))}function Sb(e,t,n){let r=e.dataTransfer;if(r===null)return!1;let i=function(e){let t=e.getData(bb);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=gb(e.clientX,e.clientY,t.getRootElement());if(n===null)return null;let r=Th(n.node);if(r===null)return null;if(B(r))return q_(r,`next`,n.offset);if(W(r))return Cv(r,n.offset,`next`);let i=r.getParent();return i===null?null:Cv(i,r.getIndexWithinParent()+1,`next`)}(e,t);if(a===null)return!1;let o=Ev(a);if(o===null)return!1;let s=i.editorKey===t.getKey(),c=H();if(s){if(!V(c)||c.isCollapsed())return!1;if(function(e,t){let{anchor:n,focus:r}=Sv(mv(t),`next`);return av(n,e)<0&&av(e,r)<0}(a,c))return e.preventDefault(),!0;c.removeText()}if(!o.origin.isAttached())return e.preventDefault(),!0;if(n(r,fv(nv(o)),t),!s){let e=t.getRootElement(),n=e?e.ownerDocument:null,r=n?function(e,t){for(let n of yg(t)){let t=lh(n);if(sh(t)&&t.getKey()===e&&J(n))return n}return null}(i.editorKey,n):null;r!==null&&r.dispatchEvent(new InputEvent(`beforeinput`,{bubbles:!0,cancelable:!0,inputType:`deleteByDrag`}))}return e.preventDefault(),!0}function Cb(e,t){return Sb(e,t,(e,t)=>yb(e,t))}function wb(e,t){t.update(()=>{if(e!==null){let n=qv(e,KeyboardEvent)?null:e.clipboardData,r=H();if(r!==null&&!r.isCollapsed()&&n!=null){e.preventDefault();let i=vb(t);i!==null&&n.setData(`text/html`,i),n.setData(`text/plain`,r.getTextContent())}}})}function Tb(e){return Nv(e.registerCommand(id,e=>{let t=H();return!!V(t)&&(t.deleteCharacter(e),!0)},0),e.registerCommand(ud,e=>{let t=H();return!!V(t)&&(t.deleteWord(e),!0)},0),e.registerCommand(dd,e=>{let t=H();return!!V(t)&&(t.deleteLine(e),!0)},0),e.registerCommand(sd,e=>{let t=H();if(!V(t))return!1;if(typeof e==`string`)t.insertText(e);else{let n=e.dataTransfer;if(n!=null)yb(n,t);else{let n=e.data;n&&t.insertText(n)}}return!0},0),e.registerCommand(ld,()=>{let e=H();return!!V(e)&&(e.removeText(),!0)},0),e.registerCommand(ad,e=>{let t=H();return!!V(t)&&(t.insertLineBreak(e),!0)},0),e.registerCommand(od,()=>{let e=H();return!!V(e)&&(e.insertLineBreak(),!0)},0),e.registerCommand(vd,e=>{let t=H();if(!V(t))return!1;let n=e,r=n.shiftKey;return!!Uv(t,!0)&&(n.preventDefault(),Kv(t,r,!0),!0)},0),e.registerCommand(gd,e=>{let t=H();if(!V(t))return!1;let n=e,r=n.shiftKey;return!!Uv(t,!1)&&(n.preventDefault(),Kv(t,r,!1),!0)},0),e.registerCommand(wd,t=>!!V(H())&&(!rl||!nl)&&(t.preventDefault(),e.dispatchCommand(id,!0)),0),e.registerCommand(Ed,t=>!!V(H())&&(t.preventDefault(),e.dispatchCommand(id,!1)),0),e.registerCommand(Sd,t=>{if(!V(H()))return!1;if(t!==null){if((rl||al||cl)&&nl)return!1;t.preventDefault()}return e.dispatchCommand(ad,!1)},0),e.registerCommand(Pd,()=>{let e=H();return Wh(V(e)&&g_(e.anchor.getNode())!==null?e:null),!0},0),e.registerCommand(Md,t=>!!V(H())&&(wb(t,e),!0),0),e.registerCommand(Nd,t=>!!V(H())&&(function(e,t){wb(e,t),t.update(()=>{let e=H();V(e)&&e.removeText()},{tag:`cut`})}(t,e),!0),0),e.registerCommand(cd,t=>!!V(H())&&(function(e,t){e.preventDefault(),t.update(()=>{let t=H(),n=qv(e,ClipboardEvent)?e.clipboardData:null;n!=null&&V(t)&&yb(n,t)},{tag:`paste`})}(t,e),!0),0),e.registerCommand(Od,t=>Cb(t,e),0),e.registerCommand(kd,t=>{let n=H();return!!V(n)&&(n.isCollapsed()||t.dataTransfer===null||xb(t.dataTransfer,e),!0)},0))}function Eb(e,t,n,r,i){if(e===null||n.size===0&&r.size===0&&!i)return 0;let a=t._selection,o=e._selection;if(i)return 1;if(!(V(a)&&V(o)&&o.isCollapsed()&&a.isCollapsed()))return 0;let s=function(e,t,n){let r=e._nodeMap,i=[];for(let e of t){let t=r.get(e);t!==void 0&&i.push(t)}for(let[e,t]of n){if(!t)continue;let n=r.get(e);n===void 0||Em(n)||i.push(n)}return i}(t,n,r);if(s.length===0)return 0;if(s.length>1){let n=t._nodeMap,r=n.get(a.anchor.key),i=n.get(o.anchor.key);return r&&i&&!e._nodeMap.has(r.__key)&&B(r)&&r.__text.length===1&&a.anchor.offset===1?2:0}let c=s[0],l=e._nodeMap.get(c.__key);if(!B(l)||!B(c)||l.__mode!==c.__mode)return 0;let u=l.__text,d=c.__text;if(u===d)return 0;let f=a.anchor,p=o.anchor;if(f.key!==p.key||f.type!==`text`)return 0;let m=f.offset,h=p.offset,g=d.length-u.length;return g===1&&h===m-1?2:g===-1&&h===m+1?3:g===-1&&h===m?4:0}function Db(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:Eb(c,l,d,f,e.isComposing()),g=(()=>{let n=u===null||u.editor===e,a=p.has(`history-push`);if(!a&&n&&p.has(`history-merge`))return 0;if(h===1)return 2;if(c===null)return 1;let o=l._selection;if(!(d.size>0||f.size>0))return o===null?2:0;let s=typeof t==`number`?t:t.peek();return!1===a&&h!==0&&h===i&&m<r+s&&n||d.size===1&&function(e,t,n){let r=t._nodeMap.get(e),i=n._nodeMap.get(e),a=t._selection,o=n._selection;return!(V(a)&&V(o)&&a.anchor.type===`element`&&a.focus.type===`element`&&o.anchor.type===`text`&&o.focus.type===`text`||!B(r)||!B(i)||r.__parent!==i.__parent)&&JSON.stringify(t.read(()=>r.exportJSON()))===JSON.stringify(n.read(()=>i.exportJSON()))}(Array.from(d)[0],c,l)?0:1})();return r=m,i=h,g}}function Ob(e,t){e.undoStack=[],e.redoStack=[],e.current=null,t&&t(e)}function kb(e,t,n,r=Date.now,i,a=null){let o=Db(e,n,r),s=()=>{i&&i(t)};return s(),Nv(e.registerCommand(pd,()=>(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(Ld,!0)),i.length===0&&e.dispatchCommand(Rd,!1),t.current=o||null,n&&n(t),o&&o.editor.setEditorState(o.editorState,{tag:`historic`})}}(e,t,i),!0),0),e.registerCommand(md,()=>(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(Rd,!0));let o=r.pop();r.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(Fd,()=>(Ob(t,i),!1),0),e.registerCommand(Id,()=>(Ob(t,i),e.dispatchCommand(Ld,!1),e.dispatchCommand(Rd,!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(Ld,!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(Rd,!0)}}else if(m===2)return;t.current={editor:e,editorState:n},s()}))}function Ab(){return{current:null,redoStack:[],undoStack:[]}}Date.now;let jb=`application/x-codexhost-thread-reference`;function Mb(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 Nb(e){return`thread://${encodeURIComponent(e.threadId).replace(/[!'()*]/gu,e=>`%${e.charCodeAt(0).toString(16).toUpperCase()}`)}?hostId=${encodeURIComponent(e.hostId)}`}function Pb(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 Fb(e){let t=`[@${e.title.replace(/[\\`*{}[\]()#+.!_<>|~-]/gu,e=>`\\${e}`)}](${Nb(e)})`;return{source:`codexhost-thread`,ref:t,label:e.title,appearance:`session`,clipboardText:t}}function Ib(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:Mb({id:n,blank:!1,title:i,projectionValues:{threadReference:{hostId:r,threadId:n}}})}catch{return}}function Lb(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=Lb(e[t]))&&(r&&(r+=` `),r+=n)}else for(n in e)e[n]&&(r&&(r+=` `),r+=n)}return r}function Rb(){for(var e,t,n=0,r=``,i=arguments.length;n<i;n++)(e=arguments[n])&&(t=Lb(e))&&(r&&(r+=` `),r+=t);return r}let zb=`@deepseek-ai/dsh-client-ui-conversation/ReferenceChip.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=`.s8J5YG_chip{max-width:240px;color:var(--dsw-alias-state-business-primary);user-select:none;align-items:baseline;gap:3px;display:inline-flex}.s8J5YG_marker{flex:none;font-weight:500}.s8J5YG_icon{flex:none;align-self:center}.s8J5YG_label{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.s8J5YG_invalid{color:var(--dsw-alias-state-error-primary);opacity:.7;text-decoration:line-through}`,document.head.appendChild(e)}var Bb={chip:`s8J5YG_chip`,icon:`s8J5YG_icon`,invalid:`s8J5YG_invalid`,label:`s8J5YG_label`,marker:`s8J5YG_marker`};let Vb=`@deepseek-ai/dsh-client-ui-conversation/composer-editor.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(Vb)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-conversation`,e.dataset.pluginCss=Vb,e.textContent=`._VTzna_reference{border-radius:var(--dsw-radius-sm);line-height:inherit;vertical-align:baseline;color:var(--dsw-alias-state-business-primary);-webkit-box-decoration-break:clone;box-decoration-break:clone;background:0 0;padding:0 4px}._VTzna_reference:hover{background:var(--dsw-alias-state-business-tertiary)}._VTzna_openable{cursor:pointer}._VTzna_textRef{max-width:100%;display:inline-block}`,document.head.appendChild(e)}var Hb={openable:`_VTzna_openable`,reference:`_VTzna_reference`,textRef:`_VTzna_textRef`};function Ub({label:e,reference:t,appearance:n,invalid:r}){return/* @__PURE__ */ (0,h.jsxs)(`span`,{className:Rb(Hb.reference,Bb.chip,n===`file`&&!r&&Hb.openable,r&&Bb.invalid),title:e,children:[n===void 0?/* @__PURE__ */ (0,h.jsx)(`span`,{className:Bb.marker,"aria-hidden":!0,children:`@`}):/* @__PURE__ */ (0,h.jsx)(d.ReferenceIconRegular,{kind:n,reference:t,size:14,className:Bb.icon}),/* @__PURE__ */ (0,h.jsx)(`span`,{className:Bb.label,children:e})]})}var Wb=class e extends wm{__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)(Ub,{label:this.__label,reference:this.__ref,appearance:this.__appearance,invalid:this.__invalid})}};function Gb(e){return new Wb(e)}function Kb(e){return e instanceof Wb}function qb(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 Jb(e,t,n,r){let i=e=>e instanceof n,a=e=>{let t=Jf(e.getTextContent());t.setFormat(e.getFormat()),e.replace(t)};return[e.registerNodeTransform(zf,e=>{if(!e.isSimpleText())return;let n,o=e.getPreviousSibling(),s=e.getTextContent(),c=e;if(B(o)){let n=o.getTextContent(),r=t(n+s);if(i(o)){if(r===null||(e=>e.getLatest().__mode)(o)!==0)return void a(o);{let t=r.end-n.length;if(t>0){let r=n+s.slice(0,t);if(o.select(),o.setTextContent(r),t===s.length)e.remove();else{let n=s.slice(t);e.setTextContent(n)}return}}}else if(r===null||r.start<n.length)return}let l=0;for(;;){n=t(s);let e,u=n===null?``:s.slice(n.end);if(s=u,u===``){let e=c.getNextSibling();if(B(e)){u=c.getTextContent()+e.getTextContent();let n=t(u);if(n===null)return void(i(e)?a(e):e.markDirty());if(n.start!==0)return}}if(n===null)return;if(n.start===0&&B(o)&&o.isTextEntity()){l+=n.end;continue}n.start===0?[e,c]=c.splitText(n.end):[,e,c]=c.splitText(n.start+l,n.end+l),e===void 0&&qb(165,`nodeToReplace`);let d=r(e);if(d.setFormat(e.getFormat()),e.replace(d),c==null)return;l=0,o=d}}),e.registerNodeTransform(n,e=>{let n=e.getTextContent(),r=t(n);if(r===null||r.start!==0)return void a(e);if(n.length>r.end)return void e.splitText(r.end);let o=e.getPreviousSibling();B(o)&&o.isTextEntity()&&(a(o),a(e));let s=e.getNextSibling();B(s)&&s.isTextEntity()&&(a(s),i(e)&&a(e))})]}let Yb=/(^|\s)([/@])([\w-]+)/g,Xb=/(^|\s)(@(?:"[^"\n]*"?|[^\s"]\S*))/g,Zb=/* @__PURE__ */ new Set(`.,;:!?,。;:!?`),Qb=/^@.*[/\\.]/u;function $b(e,t,n){if(!n.startsWith(`@"`)){let e=n.length;for(;Zb.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(;Zb.has(e.charAt(i));)i+=1;return i===e.length||/\s/u.test(e.charAt(i))?t+r+1:void 0}let ex=/^(?:\s|$)/;function tx(e,t){if(e===``)return[];let n=[];Yb.lastIndex=0;let r;for(;(r=Yb.exec(e))!==null;){let i=r[2],a=r[3]??``;if((i!==`/`||ex.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})}}Xb.lastIndex=0;let i;for(;(i=Xb.exec(e))!==null;){let t=i.index+(i[1]?.length??0),r=$b(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 nx=class e extends zf{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=Rb(t.className,Hb.reference,Hb.textRef,this.getTextContent().startsWith(`/`)&&Hb.openable),t.setAttribute(`spellcheck`,`false`),t.setAttribute(`data-composer-text-ref`,``),t}isTextEntity(){return!0}canInsertTextBefore(){return!0}};function rx(e,t,n){return Nv(...Jb(e,e=>{let r=n();for(let n of tx(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},nx,e=>new nx(e.getTextContent())))}function ix(e){e.update(()=>{for(let e of Oh().getAllTextNodes())(e instanceof nx||e.getPreviousSibling()instanceof nx||/[/@]/u.test(e.getTextContent()))&&e.markDirty()},{tag:Tf})}function ax(e,t){return e.registerCommand($u,e=>{if(e.target===null||e.button!==0||e.detail>1)return!1;let n=H();if(V(n)&&!n.isCollapsed())return!1;let r=Th(e.target);if(Kb(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 nx&&t(void 0,{ref:r.getTextContent()})},1)}function ox(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 sx=Vs([O(),k(),A(),Ns()]);function cx(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 lx=xc(cx,{message:`JSON value must not contain circular references`}),ux=yc(()=>Vs([sx,j(ux),Ys(O(),ux)])),dx=lx.pipe(ux);lx.pipe(j(ux));let fx=lx.pipe(Ys(O(),ux)),px=N({code:O().min(1),message:O().min(1),retryable:A(),diagnostic:O().min(1).optional(),stage:O().min(1).optional(),durationMs:k().int().nonnegative().optional(),stderrTail:O().min(1).optional()}).superRefine(ox([`diagnostic`,`stage`,`durationMs`,`stderrTail`])),mx=O().max(64).regex(/^[a-z]{2,3}(?:-[A-Za-z0-9]{2,8})*$/u),hx=e=>O().min(1).max(e).refine(e=>e.trim().length>0),gx=Ys(mx,M({label:hx(256).optional(),description:hx(1024).optional()}).strict()).refine(e=>Object.keys(e).length<=16,`Too many locales`),_x=Ys(mx,hx(4096)).refine(e=>typeof e.en==`string`,`English fallback is required`).refine(e=>Object.keys(e).length<=16,`Too many locales`),vx=O().refine(e=>e.trim().length>0,{message:`Identifier must not be empty or whitespace`}),yx=vx.brand(),bx=vx.brand(),xx=vx.brand();vx.brand(),vx.brand();let Sx=O().refine(e=>e.trim().length>0,{message:`Value must not be empty or whitespace`}),Cx=Sx.max(128).regex(/^[A-Za-z0-9._~:-]+$/u,`Permission Mode ID must use transport-safe characters`).brand(),wx=M({modes:j(M({id:Cx,label:Sx.max(256),description:Sx.max(1024).optional(),dangerous:A().optional(),localizations:gx.optional()}).strict()).min(1).max(32),defaultModeId:Cx}).strict().superRefine((e,t)=>{let n=/* @__PURE__ */ new Set;for(let[r,i]of e.modes.entries())n.has(i.id)&&t.addIssue({code:`custom`,message:`Permission Mode IDs must be unique`,path:[`modes`,r,`id`]}),n.add(i.id);n.has(e.defaultModeId)||t.addIssue({code:`custom`,message:`Default Permission Mode must exist in the catalog`,path:[`defaultModeId`]})});M({threadId:bx,permissionModeId:Cx}).strict();let Tx=k().int().safe().nonnegative(),Ex=k().finite().nonnegative(),Dx=k().finite().min(0).max(100),Ox=M({version:Vs([F(3),F(4)]).optional(),requestId:O().min(1),turnId:O().min(1).max(1024),outputTokens:Tx,startedAtMs:Tx,completedAtMs:Tx}).strict().refine(e=>e.completedAtMs>e.startedAtMs),kx=M({version:Vs([F(2),F(3),F(4)]).optional(),value:Ex,turnId:O().min(1).max(1024),at:Tx}).strict();M({outputTimings:j(Ox).transform(e=>e.filter(e=>e.version===4)).optional(),outputTokensPerSecond:kx.refine(e=>e.version===4).optional().catch(void 0),timeToFirstOutputMs:kx.extend({value:Tx}).optional()}).strict();let Ax=e=>_x.refine(t=>Object.values(t).every(t=>t.length<=e)),jx=M({composerIndicators:j(M({kind:F(`countdown`),id:O().min(1).max(64),expiresAtUnix:Tx,label:Ax(256).optional(),tooltip:Ax(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:Tx.optional(),cachedInputTokens:Tx.optional(),cacheWriteInputTokens:Tx.optional(),outputTokens:Tx.optional(),outputTokensPerSecond:Ex.optional(),sessionOutputTokensPerSecond:Ex.optional(),apiOutputTokensPerSecond:Ex.optional(),reasoningOutputTokens:Tx.optional(),totalTokens:Tx.optional(),totalCostUsd:Ex.optional(),totalCredits:Ex.optional(),contextUsagePercent:Ex.optional(),cacheHitRatePercent:Dx.optional(),contextWindowTokens:Tx.optional(),contextUsedTokens:Tx.optional(),planFiveHourUsedPercent:Dx.optional(),planFiveHourResetsAtUnix:Tx.optional(),planSevenDayUsedPercent:Dx.optional(),planSevenDayResetsAtUnix:Tx.optional(),sessionCacheHitRatePercent:Dx.optional(),timeToFirstOutputMs:Tx.optional(),latestRequestTimeToFirstOutputMs:Tx.optional(),costSource:P([`publicPrice`,`native`]).optional(),unpricedModels:j(O().min(1)).min(1).optional()}).strict().superRefine((e,t)=>{Object.keys(e).length===0&&t.addIssue({code:`custom`,message:`Thread Usage must contain a reliable field`});let n=e.contextUsedTokens!==void 0;n!==(e.contextWindowTokens!==void 0)&&t.addIssue({code:`custom`,message:`Thread Usage context fields must be provided together`,path:[n?`contextWindowTokens`:`contextUsedTokens`]}),e.contextWindowTokens===0&&t.addIssue({code:`custom`,message:`Thread Usage contextWindowTokens must be greater than zero`,path:[`contextWindowTokens`]}),e.costSource!==void 0&&e.totalCostUsd===void 0&&t.addIssue({code:`custom`,message:`Thread Usage costSource must be provided with totalCostUsd`,path:[`costSource`]}),e.unpricedModels!==void 0&&e.costSource!==`publicPrice`&&t.addIssue({code:`custom`,message:`Thread Usage unpricedModels must be provided with a publicPrice cost`,path:[`unpricedModels`]}),e.planFiveHourResetsAtUnix!==void 0&&e.planFiveHourUsedPercent===void 0&&t.addIssue({code:`custom`,message:`Thread Usage planFiveHourResetsAtUnix must be provided with planFiveHourUsedPercent`,path:[`planFiveHourResetsAtUnix`]}),e.planSevenDayResetsAtUnix!==void 0&&e.planSevenDayUsedPercent===void 0&&t.addIssue({code:`custom`,message:`Thread Usage planSevenDayResetsAtUnix must be provided with planSevenDayUsedPercent`,path:[`planSevenDayResetsAtUnix`]})}),Mx=k().finite().min(0).max(100),Nx=P([`weekly`,`monthly`,`five_hour`,`seven_day`,`unknown`]),Px=M({id:O().min(1).max(256),label:O().min(1).max(256),localizations:gx.optional()}).strict(),Fx=M({product:O().min(1),periodType:Nx.optional(),scope:Px.optional(),localizations:gx.optional(),used:k().finite().nonnegative().optional(),limit:k().finite().nonnegative().optional(),unit:O().min(1).max(32).optional(),usagePercent:Mx,resetsAt:O().min(1).optional()}).strict(),Ix=M({availableCount:k().int().safe().positive(),nextExpiresAt:O().min(1).optional(),expiresAt:j(O().min(1)).min(1).max(32).optional()}).strict(),Lx=M({used:k().finite().nonnegative().optional(),limit:k().finite().nonnegative().optional(),unit:O().min(1).max(32).optional(),label:O().min(1).optional(),scope:Px.optional(),localizations:gx.optional(),usedPercent:Mx,resetsAt:O().min(1).optional(),periodType:Nx,productUsage:j(Fx).min(1).optional(),resetCredits:Ix.optional()}).strict(),Rx=M({amount:k().finite().nonnegative(),currency:O().trim().min(1).max(8),label:O().trim().min(1).max(128).optional()}).strict();M({threadId:bx,refresh:F(`exact`).optional()}).strict(),M({threadId:bx,usage:jx.nullable(),accountCredits:Lx.optional(),accountBalance:Rx.optional(),accountCreditsSupported:A().optional()}).strict();let zx=O().refine(e=>e.trim().length>0,{message:`Value must not be empty or whitespace`}),Bx=O().min(1).max(512).refine(e=>!/\p{Cc}/u.test(e),`Model Ref must not contain control characters`).brand(),Vx=P([`priority`,`ultrafast`]),Hx=M({id:Bx,serviceTier:Vx.optional()}).strict();function Ux(e,t){return e?.id===t?.id&&e?.serviceTier===t?.serviceTier}let Wx=zx.max(128).regex(/^[A-Za-z0-9._~-]+$/u,`Thinking option ID must use transport-safe characters`).brand(),Gx=zx.max(256),Kx=M({id:Wx,label:zx.max(256)}).strict(),qx=M({ref:Hx,label:zx.max(256),resolvedModelLabel:Gx.optional(),fastModel:Hx.optional(),supportedThinkingOptionIds:j(Wx).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 Jx(e,t){if(t)return e?.models.find(e=>Ux(e.ref,t)||Ux(e.fastModel,t))}let Yx=j(Kx).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)}),Xx=M({models:j(qx),defaultModel:Hx.optional(),thinkingOptions:Yx,defaultThinkingOptionId:Wx.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=>Ux(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=>Ux(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&&!Jx(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`]})}),Zx=M({fork:A(),forkAcrossCwd:A(),rollbackLastTurn:A()}).strict().refine(e=>e.fork||!e.forkAcrossCwd,{path:[`forkAcrossCwd`],message:`Cross-cwd Fork requires exact history Fork support`}),Qx=P([`live`,`atCreate`]),$x=M({configuration:M({selectModel:A(),selectThinkingOption:A(),selectPermissionMode:A(),permissionModeScope:Qx.default(`live`)}).strict(),history:Zx,subagents:M({observe:A(),readTranscript:A()}).strict().optional(),autonomousTurns:M({observe:A()}).strict().optional(),steer:A().optional(),persistentPlan:A().optional()}).strict();M({effectiveModel:Hx.optional(),resolvedModelLabel:Gx.optional(),effectiveThinkingOptionId:Wx.optional(),availableThinkingOptions:Yx.optional(),effectivePermissionModeId:Cx.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 eS=M({open:F(!0)}).strict();Vs([M({status:F(`ready`),catalog:Xx,permissionModes:wx.optional(),capabilities:$x,webUi:eS.optional()}).strict().superRefine((e,t)=>{let n=e.capabilities.configuration.selectPermissionMode;n!==!!e.permissionModes&&t.addIssue({code:`custom`,message:`Permission Mode catalog and capability must agree`,path:n?[`permissionModes`]:[`capabilities`,`configuration`,`selectPermissionMode`]})}),M({status:P([`notInstalled`,`unavailable`,`error`]),error:px}).strict()]),M({harnessId:yx,cwd:zx.max(16384).optional(),refresh:A().optional(),purpose:F(`availability`).optional(),credentialAccess:P([`allow`,`retry`]).optional()}).strict(),M({harnessId:yx}).strict(),M({}).strict(),M({threadId:bx,model:Hx}).strict(),M({threadId:bx,thinkingOptionId:Wx}).strict(),M({threadId:bx,includeReferenceCapability:A().optional()}).strict(),Us(`owner`,[M({owner:F(`codex`),locked:A(),effectiveModel:Hx.optional(),resolvedModelLabel:Gx.optional(),effectiveThinkingOptionId:Wx.optional(),effectivePermissionModeId:Cx.optional(),history:Zx.optional(),supportsThreadReferences:F(!0).optional()}).strict(),M({owner:F(`external`),harnessId:zx.max(256),transportModelId:zx.max(8192),effectiveModel:Hx.optional(),resolvedModelLabel:Gx.optional(),effectiveThinkingOptionId:Wx.optional(),availableThinkingOptions:Yx.optional(),effectivePermissionModeId:Cx.optional(),catalog:Xx.optional(),history:Zx,usage:jx.optional(),locked:F(!0)}).strict()]),M({threadIds:j(bx).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 tS=Us(`owner`,[M({threadId:bx,owner:F(`codex`)}).strict(),M({threadId:bx,owner:F(`external`),harnessId:O().max(256).pipe(yx)}).strict()]);M({threads:j(tS).min(1).max(100)}).strict().superRefine(({threads:e},t)=>{let n=/* @__PURE__ */ new Set;for(let[r,i]of e.entries())n.has(i.threadId)&&t.addIssue({code:`custom`,message:`Thread ownership-list results must be unique`,path:[`threads`,r,`threadId`]}),n.add(i.threadId)}),M({threadId:bx,text:O().optional()}).strict(),M({kind:F(`application`),value:O().transform((e,t)=>{try{return JSON.parse(e)}catch{return t.addIssue({code:`custom`,message:`Invalid steering context JSON`}),Dt}}).pipe(M({expectedTurnId:xx,clientUserMessageId:O().min(1),delivery:P([`newTurn`,`activeTurn`])}).strict())}).strict().transform(e=>e.value),P([`activeTurn`,`newTurn`]),M({delivery:P([`official`,`activeTurn`,`newTurn`])}).strict();let nS=O().min(1).max(128).regex(/^[a-z][a-z0-9]*(?:[._-][a-z0-9]+)*$/u),rS=nS.pipe(yx),iS=rS.refine(e=>e!==`codex`,`The official Codex identity is reserved`),aS=O().min(1).max(512).refine(e=>!/[\\\u0000:#?]/u.test(e)&&!e.startsWith(`/`)&&!e.split(`/`).some(e=>e===`..`||e===``),`Plugin resources must be relative paths inside the plugin`),oS=fs().refine(e=>/^https:\/\/[^/?#@]+(?:[/?#]|$)/iu.test(e),`Plugin documentation links must be credential-free HTTPS URLs`),sS=M({en:O().max(4096),"zh-CN":O().max(4096).optional()}).strict(),cS=M({commands:j(M({terminal:O().max(256),command:O().max(4096)}).strict()).max(8),before:sS.optional(),after:sS.optional(),downloads:j(M({label:O().max(128),url:oS}).strict()).max(8).optional()}).strict(),lS={id:rS,name:O().trim().min(1).max(128),version:O().min(1).max(128),kind:F(`usage`).optional(),iconStyle:M({vector:M({viewBox:O().max(128).regex(/^-?\d+(?:\.\d+)?(?: +-?\d+(?:\.\d+)?){3}$/u),color:O().regex(/^(?:currentColor|#[a-f0-9]{6})$/iu),paths:j(M({d:O().min(1).max(32768).regex(/^[MmLlHhVvCcSsQqTtAaZz\d.,+eE\s-]+$/u),fillRule:P([`evenodd`,`nonzero`]).optional(),fill:O().regex(/^(?:currentColor|#[a-f0-9]{6})$/iu).optional()}).strict()).min(1).max(32)}).strict().optional(),background:O().regex(/^#[a-f0-9]{6}$/iu).optional(),borderRadius:k().min(0).max(50).optional(),paddingRatio:k().min(0).max(.25).optional()}).strict().optional(),installation:cS.optional(),notice:sS.optional(),launchCommand:F(!0).optional(),links:M({website:oS.optional(),documentation:oS.optional(),installation:oS.optional()}).strict().optional()};M({manifestVersion:F(1),...lS,adapterApiVersion:k().int().positive(),entry:aS,icon:aS.optional()}).strict();let uS=O().max(174828).regex(/^data:image\/(?:png|jpeg|webp|svg\+xml);base64,[A-Za-z0-9+/]+={0,2}$/u),dS=M({...lS,icon:uS.optional()}).strict();M({}).strict(),M({plugins:j(dS.extend({id:iS})).max(128)}).strict(),M({version:F(1),enabled:j(rS).max(128)}).strict().refine(e=>new Set(e.enabled).size===e.enabled.length,{message:`Enabled plugin IDs must be unique`,path:[`enabled`]});let fS=nS,pS=P([`sidebar.thread-layout`,`sidebar.thread-badge`,`appearance.theme`]),mS=P([`appearance`,`interface`,`workflow`,`analytics`,`integrations`,`tools`]),hS=O().trim().min(1).max(128);function gS(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 _S=e=>e.split(`/`).every(e=>!/[. ]$/u.test(e)),vS=aS.refine(e=>gS(e)!==void 0&&_S(e),`Images must be relative .png, .jpg, .jpeg, or .webp paths with no segments ending in a dot or space`),yS=O().trim().max(2048).regex(/^https?:\/\/[^/?#\\\s]+/iu,`Expected an HTTP(S) URL`).pipe(fs({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 bS(e){return N({en:e,"zh-CN":e})}let xS=bS(O().trim().min(1)),SS=j(mS).max(mS.options.length).refine(e=>new Set(e).size===e.length,`Duplicate categories`),CS=j(pS).max(pS.options.length).refine(e=>new Set(e).size===e.length,`Duplicate slots`),wS={key:O().regex(/^[A-Za-z_][A-Za-z0-9_]*$/u),label:xS,description:xS.optional()},TS={...wS,step:k().positive().optional(),default:k().optional()},ES=N({value:O(),label:xS}),DS=Us(`type`,[N({...wS,type:F(`boolean`),default:A().optional()}),N({...wS,type:F(`string`),placeholder:xS.optional(),default:O().optional()}),N({...TS,type:F(`number`),min:k().optional(),max:k().optional()}),N({...TS,type:F(`range`),min:k(),max:k()}),N({...wS,type:F(`select`),options:j(ES).min(1),default:O().optional()})]).superRefine((e,t)=>{let n=(e,n)=>t.addIssue({code:`custom`,path:[e],message:n});if(e.type===`number`||e.type===`range`){let{min:t=-1/0,max:r=1/0,default:i}=e;t>r&&n(`max`,`Must be at least min`),i!==void 0&&(i<t||i>r)&&n(`default`,`Must be within min and max`)}else if(e.type===`select`){let t=new Set(e.options.map(({value:e})=>e));t.size!==e.options.length&&n(`options`,`Duplicate option values`),e.default!==void 0&&!t.has(e.default)&&n(`default`,`Must match an option value`)}}),OS=M({manifestVersion:As().positive(),id:fS,name:Vs([hS,bS(hS)]),version:O().min(1).max(128),desktopApi:As().positive()}).passthrough().extend({manifestVersion:F(1),desktopApi:F(1),description:N({en:O().max(4096),"zh-CN":O().max(4096).optional()}).optional(),author:O().trim().min(1).max(128).optional(),repository:yS.optional(),details:N({en:O().max(16384),"zh-CN":O().max(16384).optional()}).optional(),icon:vS.optional(),screenshots:j(vS).max(4).refine(e=>new Set(e).size===e.length,`Duplicate screenshots`).optional(),desktop:N({script:aS,style:aS.optional()}).optional(),backend:N({script:aS.refine(_S)}).optional(),slots:CS.default(()=>[]),settingsSchema:j(DS).max(32).refine(e=>new Set(e.map(({key:e})=>e)).size===e.length,`Duplicate setting keys`).optional(),categories:SS.optional()}).strict().refine(e=>e.desktop!==void 0||e.backend!==void 0,`Expected at least one desktop or backend entry`),kS=O().regex(/^[a-f0-9]{64}$/u),AS=N({state:P([`running`,`disabled`,`invalid`,`incompatible`,`conflict`,`failed`,`waiting`]),hash:kS.optional(),error:O().optional(),conflictWith:fS.optional()});N({controllerPid:As().positive(),targetId:O().nullable(),updatedAt:Fo(),handledReloadToken:us().optional(),extensions:Ys(O(),AS),surfaces:Ys(O(),AS).optional()});let jS=P([`official`,`community`]);function MS(e){return e.origin===`https://api.github.com`&&/^\/repos\/[\w-]+\/[\w.-]+\/zipball(?:\/[^/]+)?\/?$/u.test(e.pathname)}let NS=yS.refine(e=>{let t=new URL(e);return/\.zip$/iu.test(t.pathname)||MS(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`),PS=N({id:fS,version:O().trim().min(1).max(128),name:xS.extend({en:hS,"zh-CN":hS}),description:bS(O().trim().min(1).max(4096)),details:bS(O().trim().min(1).max(16384)).optional(),author:O().trim().min(1).max(128),repository:yS,stars:k().int().min(0).optional(),downloads:k().int().min(0).optional(),categories:SS.optional(),trustTier:jS.default(`community`),icon:yS.optional(),screenshots:j(yS).max(4).optional(),downloadUrl:NS,sha256:kS,slots:CS.optional(),publishedAt:O().optional(),updatedAt:O().optional(),minCodexHostVersion:O().optional()});N({schemaVersion:F(1),generatedAt:O(),extensions:j(PS).refine(e=>new Set(e.map(({id:e})=>e)).size===e.length,`Duplicate extension IDs`)});let FS=O().trim().min(1).max(128),IS=/^(?:con|prn|aux|nul|com[1-9¹²³]|lpt[1-9¹²³]) *(?:\.|$)/iu,LS=fS.refine(e=>!IS.test(e),`Reserved extension ID`),RS=P([`desktop`,`web`]),zS=kS,BS=us(),VS=aS.refine(e=>!/[\x00-\x1f\x7f<>"|*]/u.test(e)&&e.split(`/`).every(e=>!/[. ]$/u.test(e)&&!IS.test(e)),`Expected a portable relative resource path`).refine(e=>e.split(`/`).length<=32,`Extension resources may be at most 32 segments deep`),HS=OS.shape,US=(e,t=0)=>N({en:O().trim().min(t).max(e),"zh-CN":O().trim().min(t).max(e)}),WS=e=>VS.refine(t=>t.endsWith(e),`Expected a ${e} file`),GS=WS(`.mjs`),KS=WS(`.css`).optional(),qS=e=>e.normalize(`NFC`).toLowerCase(),JS=N({manifestVersion:F(2),id:LS,name:US(128,1),version:O().trim().min(1).max(128),description:US(4096),details:US(16384).optional(),author:HS.author,repository:HS.repository,icon:HS.icon.refine(e=>e===void 0||VS.safeParse(e).success),screenshots:HS.screenshots.refine(e=>e===void 0||e.every(e=>VS.safeParse(e).success)),categories:HS.categories,settingsSchema:HS.settingsSchema,slots:HS.slots.removeDefault().optional(),page:N({apiVersion:F(1),entry:GS,style:KS,title:US(128,1).optional()}).optional(),widget:N({apiVersion:F(1),entry:GS,style:KS}).optional(),desktop:N({apiVersion:F(1),script:WS(`.js`),style:KS}).optional(),web:N({apiVersion:F(1),entry:GS.optional(),style:KS}).refine(({entry:e,style:t})=>e!==void 0||t!==void 0,`Expected a Web entry or style`).optional(),backend:N({apiVersion:F(1),entry:GS}).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||qS(e)!==qS(r.entry)),{path:[`backend`,`entry`],message:`A backend entry cannot also be a frontend entry`});function YS({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 XS=FS,ZS=As().nonnegative(),QS=N({revision:ZS,enabled:j(LS).max(64).refine(e=>new Set(e).size===e.length,`Duplicate extension IDs`)}),{downloadUrl:$S,...eC}=PS.shape,tC=M({...eC,id:LS,format:F(`codexhost`),targets:j(RS).min(1).max(2).refine(e=>new Set(e).size===e.length,`Duplicate targets`),apis:N({page:As().positive().optional(),widget:As().positive().optional(),desktop:As().positive().optional(),web:As().positive().optional(),backend:As().positive().optional()}),downloadUrl:$S.refine(e=>e.startsWith(`https://`),`Expected HTTPS`)}).refine(({targets:e,apis:t})=>{let n=YS({hasPage:!!t.page,hasWidget:!!t.widget,hasDesktop:!!t.desktop,hasWeb:!!t.web,hasBackend:!!t.backend});return e.length===n.length&&n.every(t=>e.includes(t))},`Catalog targets must match the declared APIs`);M({schemaVersion:F(2),generatedAt:O().min(1),extensions:j(tC).max(1e4).refine(e=>new Set(e.map(({id:e})=>e)).size===e.length,`Duplicate extension IDs`)}).extend({catalogUrl:yS,fetchedAt:Fo(),cached:A()});let nC={id:LS},rC={...nC,activationId:BS,digest:zS},iC={...nC,activationId:rC.activationId.optional()},aC=O().min(1).max(4096).refine(e=>/^(?:\/|[a-z]:[/\\])/iu.test(e)&&!e.includes(`\0`)&&!e.split(/[/\\]/u).some(e=>e===`.`||e===`..`),`Expected an absolute local path without dot segments`),oC=O().min(1).max(256).refine(e=>e.split(`/`).every(e=>e&&/^[a-z0-9_.-]+$/iu.test(e)&&e!==`.`&&e!==`..`),`Invalid GitHub ref`);function sC(e){return O().max(4*Math.ceil(e/3)).refine(t=>{let n=t.endsWith(`==`)?2:+!!t.endsWith(`=`);return t.length%4==0&&t.length*3/4-n<=e&&/^[A-Za-z0-9+/]*={0,2}$/u.test(t)},`Expected bounded standard padded base64`)}let cC=N({type:F(`github`),repository:O().max(150).regex(/^[a-z0-9-]+\/[a-z0-9_-][a-z0-9_.-]*$/iu),ref:oC.optional(),tag:oC.optional(),asset:O().max(255).regex(/^[a-z0-9_.-]+\.zip$/iu).optional(),subpath:VS.optional()}).refine(({ref:e,tag:t,asset:n})=>!e||!t&&!n,`Use either a zipball ref or a release tag/asset`),lC=Vs([N({type:F(`catalog`),...nC}),cC,N({type:F(`zip`),base64:sC(67108864).min(4)}),N({type:F(`zip`),localZipPath:aC}),N({type:F(`localDir`),localDir:aC})]),uC=Us(`type`,[N({type:F(`catalog`),...nC}),cC,N({type:F(`zip`)}),N({type:F(`localDir`)})]),dC=N({...rC,manifest:JS,installedAt:Fo(),source:uC.optional()}),fC=e=>O().max(23+4*Math.ceil(e/3)).regex(/^data:image\/(?:png|jpeg|webp);base64,[A-Za-z0-9+/]+={0,2}$/u),pC={desktopConflictWith:LS.optional()},mC=P([`none`,`inactive`,`starting`,`running`,`failed`]),hC=Us(`state`,[dC.extend({state:F(`valid`),enabled:A(),...pC,iconDataUrl:fC(131072).optional(),screenshotDataUrls:j(fC(524288)).max(4).optional(),backendState:mC.optional(),backendError:O().optional()}),N({state:P([`invalid`,`incompatible`]),id:O().min(1),enabled:A(),error:O()})]);N({revision:ZS,configuration:QS,diagnostics:j(O()),extensions:j(hC)}),N({revision:ZS,extensions:j(dC.extend({...pC,settingsRevision:ZS})).max(64)});let gC={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`},_C=Object.freeze(Object.values(gC));new Set(_C),N({});let vC={expectedRevision:ZS};N({...nC,...vC}),dC.extend({replaced:A()}),Us(`state`,[N({state:F(`saved`),configuration:QS}),N({state:F(`revision-conflict`),revision:ZS})]),N({...iC,digest:rC.digest.optional(),path:VS}),N({mimeType:O().min(1),base64:sC(16777216),digest:rC.digest}),N({settingsRevision:ZS,values:fx}),gC.list,gC.snapshot,gC.catalog,N({forceRefresh:A().optional()}),gC.install,N({source:lC}),gC.update,N({...nC,expectedDigest:rC.digest,expectedActivationId:rC.activationId.optional(),source:lC.optional()}),gC.enable,gC.disable,gC.uninstall,N({...nC,removeData:A().optional(),expectedDigest:rC.digest.optional()}),N({...nC,removed:A()}),gC.recover,N({expectedRevision:vC.expectedRevision.optional()}),gC.asset,gC.settingsGet,N(iC),gC.settingsSet,N({...iC,expectedSettingsRevision:ZS,values:fx}),gC.backendInvoke,N({...iC,method:XS,params:dx.optional()}),N({result:dx}),M({threadId:bx}).strict(),M({confirmed:A()}).strict(),[..._C],M({sections:j(M({id:O().min(1),name:O().min(1),threads:j(fx)}).strict())}).strict(),M({threadId:O().min(1).max(1024),sectionId:O().min(1).max(1024).nullable()}).strict(),M({threadIds:j(O().min(1))}).strict(),M({threadId:O().min(1).max(1024),pinned:A()}).strict(),M({}).strict(),M({parents:Ys(O().min(1),O().min(1))}).strict(),M({prompt:O().max(16384).optional()}).strict(),M({projects:j(M({id:O(),name:O(),rootPaths:j(O())})),assignments:Ys(O(),O()),projectless:j(O()),pinned:j(O()),sectionProjects:Ys(O(),j(O())).optional()});let yC=Ys(O(),Fs()),bC=M({epoch:O().uuid(),sequence:k().int().nonnegative()});Us(`type`,[M({type:F(`skills-changed`),cursor:bC,cwd:O().optional()}),M({type:F(`harness-inspection-changed`),cursor:bC,harnessId:O().min(1)}),M({type:F(`display-settings-changed`),cursor:bC}),M({type:F(`preferences-changed`),cursor:bC,revision:k().int().nonnegative()}),M({type:F(`extensions-changed`),cursor:bC,revision:ZS}),M({type:F(`hello`),version:F(1),cursor:bC,reset:A()}),M({type:F(`changed`),cursor:bC,threadId:O().min(1),method:O().min(1)})]);let xC=Us(`type`,[M({type:F(`text`),id:O(),prompt:O(),secret:A().optional(),optional:A().optional()}),M({type:F(`choice`),id:O(),prompt:O(),multiple:A(),allowOther:A(),optional:A().optional(),options:j(M({value:O(),label:O(),description:O().optional()}))})]),SC=Us(`type`,[M({type:F(`approval`),title:O(),description:O().optional(),subject:Fs().optional(),actions:j(M({id:O(),label:O(),effect:O()}))}),M({type:F(`question`),title:O().optional(),questions:j(xC)})]),CC=M({requestId:Vs([O(),k().int()]),threadId:O(),kind:P([`approval`,`question`]),interaction:SC,request:yC}),wC=M({id:O().min(1),clientUserMessageId:O().min(1),input:j(yC),presentationInput:j(yC).nullable().optional()}).passthrough();M({fields:j(M({path:j(Vs([O(),k().int().nonnegative()])),originalLength:k().int().nonnegative()}))});let TC=M({id:O().min(1),status:O().min(1),codexhostTurnOutcome:M({status:F(`unknown`),reason:O()}).optional(),items:j(M({id:O().min(1),type:O().min(1)}).passthrough()),codexhostFileOperations:j(M({beforeItemId:O().nullable(),item:M({id:O().min(1),type:O().min(1)}).passthrough()})).optional(),error:M({message:O().optional()}).passthrough().nullable().optional(),fingerprint:O().min(1).optional(),unchanged:F(!0).optional()}).passthrough(),EC=M({id:O().min(1).max(512),fingerprint:O().min(1).max(128)});M({threadId:O().min(1),knownTurns:j(EC).max(64).optional(),truncateToolOutput:A().optional()});let DC=M({harnessId:O().min(1),nativeSessionId:O().min(1)});M({cursor:bC,activeTurnId:O().min(1).nullable().optional(),command:M({name:O().min(1),turn:TC,subsequentTurnId:O().min(1).optional()}).optional(),thread:M({id:O().min(1),cwd:O(),modelProvider:O().min(1),createdAt:k(),updatedAt:k(),status:M({type:O()}).passthrough(),name:O().nullable().optional(),preview:O().optional(),codexhostImportSource:DC.optional(),turns:j(TC).length(0)}).passthrough(),turnsPage:M({data:j(TC).max(5),nextCursor:O().nullable()}),configuration:M({native:M({model:O().min(1).max(1024).optional(),reasoningEffort:O().min(1).max(128).optional()}).optional(),effectiveModel:Hx.optional(),effectiveThinkingOptionId:Wx.optional(),effectivePermissionModeId:Cx.optional()}),queue:M({items:j(wC),pausedReason:P([`interrupted`,`outcome-unknown`,`failed`]).nullable()}).optional(),interactions:j(CC)}),M({version:F(1),owner:F(`service`).optional(),pid:k().int().positive(),port:k().int().min(1).max(65535),token:O().regex(/^[0-9a-f]{64}$/u),startedAt:k(),epoch:O().uuid()}),M({epoch:O().uuid(),threadId:O().min(1),requestId:Vs([O(),k().int()]),result:yC}),M({includeArchived:A().optional(),officialCursor:M({live:O().nullable(),archived:O().nullable().optional()}).strict().optional(),scope:M({cwd:O().min(1).max(4096),excludeCwds:j(O().min(1).max(4096)).max(1024)}).strict().optional()}).strict(),M({threads:j(fx),ownership:j(tS),archivedThreadIds:j(bx),officialCursor:M({live:O().nullable(),archived:O().nullable().optional()}).strict().optional()}).strict();let OC=P([`running`,`waiting`,`idle`,`unknown`]),kC=N({harnessId:yx,title:O().optional(),status:OC,archived:A()}),AC=N({revision:As().nonnegative(),parents:Ys(bx,bx),nodes:Ys(bx,kC),truncated:A()}).refine(e=>Object.keys(e.nodes).length<=5e3,`Too many Thread tree nodes`).refine(({parents:e,nodes:t})=>Object.entries(e).every(([e,n])=>Object.hasOwn(t,e)&&Object.hasOwn(t,n)),`Missing Thread tree node`),jC=O().min(1).max(128);N({});let MC=N({subscriptionId:jC});N({}),MC.extend({snapshot:AC});let NC=O().regex(/^audio\/[a-z0-9.+-]+(?:\s*;[^\r\n]*)?$/i);M({available:A()}).strict(),M({path:O().min(1),mimeType:NC}).strict();let PC=P([`credentials-unavailable`,`login-expired`,`rate-limited`,`service-rejected`,`host-incompatible`,`network`,`timeout`,`audio-empty`,`audio-too-large`,`audio-format`,`audio-invalid`]);Us(`ok`,[M({ok:F(!0),text:O()}).strict(),M({ok:F(!1),error:M({code:PC}).strict()}).strict()]),M({threadId:bx.optional(),cwd:O().min(1).optional()}).strict().refine(e=>!(e.threadId&&e.cwd),{message:`Specify threadId or cwd, not both`});let FC=M({name:O().min(1).regex(/^[^\s[\]]+$/u),description:O().optional(),path:O().min(1),scope:P([`project`,`global`]),source:O().min(1)}).strict();M({revision:k().int().nonnegative(),complete:A(),skills:j(FC),warnings:j(O()).optional()}).strict(),M({cwd:O().min(1).optional()}).strict();let IC=/\[\$([^\]\r\n]+)\]\((?:<([^<>\r\n]+)>|([^\s()]+))(?:[ \t]+(?:"[^"\r\n]*"|'[^'\r\n]*'))?\)/gu;function LC(e){return[...e.matchAll(IC)].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 RC=M({kind:P([`public`,`relay`,`tailscale-funnel`,`tailscale-https`,`tailscale`,`lan`,`virtual`]),url:O().min(1)}).strict(),zC=Us(`status`,[M({status:F(`not-installed`)}),M({status:F(`not-running`)}),M({status:F(`not-logged-in`)}),M({status:F(`https-disabled`)}),M({status:F(`not-serving`),command:O()}),M({status:F(`occupied`),target:O()}),M({status:F(`serving`),url:O(),funnel:A()}),M({status:F(`error`),message:O()})]);M({state:zC,error:O().optional()}).strict();let BC=Us(`status`,[M({status:F(`on`)}),M({status:F(`off`)}),M({status:F(`invalid`),reason:O()})]),VC=M({lan:A(),autostart:BC}).strict(),HC=M({expiresAt:O().optional(),issuing:A(),failure:M({detail:O().optional(),retryAt:O(),paused:A()}).optional()}),UC=Us(`status`,[M({status:F(`off`),reason:P([`invite`,`name-taken`,`banned`]).optional()}),M({status:F(`connecting`),reason:P([`full`,`unreachable`]).optional()}),M({status:F(`connected`),url:O(),certificate:HC}),M({status:F(`missing-certificate`),url:O(),certificate:HC}),M({status:F(`stopped`),reason:P([`replaced`,`rejected`,`unsupported-version`])})]);O().max(253).regex(/^(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z](?:[a-z0-9-]{0,61}[a-z0-9])?$/i).transform(e=>e.toLowerCase()),O().regex(/^(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)?$/);let WC=P([`official`,`self-hosted`]);M({secret:O().min(1),lastUsedAt:k().nullable(),networkUrls:j(RC),directCandidates:j(RC).optional(),tailscale:zC,background:VC.optional(),relay:M({state:UC,enabled:A(),kind:WC,officialHost:O(),customHost:O().optional(),officialHostname:O().optional(),customHostname:O().optional(),quotaUntil:O().optional()}).strict().optional()}).strict();let GC=N({threadId:O().min(1).max(1024),view:P([`result`,`messages`]),from:k().int().min(1).max(2**53-1).optional(),to:k().int().min(1).max(2**53-1).optional()}),KC=M({id:O().min(1).max(256),harnessId:O().min(1),label:O().min(1).max(512),provider:P([`openai-codex`,`xai`])}).strict(),qC=O().regex(/^[a-z][a-z0-9-]{0,47}$/),JC=M({name:qC,source:KC,importedAt:O()}).strict(),YC=Us(`action`,[M({action:F(`list`)}).strict(),M({action:F(`import`),sourceId:O().min(1).max(256),name:qC,confirmed:F(!0)}).strict(),M({action:F(`reimport`),sourceId:O().min(1).max(256),name:qC,confirmed:F(!0)}).strict(),M({action:F(`remove`),name:qC,confirmed:F(!0)}).strict()]),XC=M({provider:O().min(1).max(128),type:P([`oauth`,`api_key`,`unknown`]),label:O().min(1).max(512).optional(),vendor:P([`openai-codex`,`xai`]).optional()}).strict();M({sources:j(KC),targets:j(M({harnessId:O(),providers:j(P([`openai-codex`,`xai`])),imports:j(JC),others:j(XC).default([])}).strict())}).strict(),M({targetHarnessId:O().min(1).max(128).optional(),request:YC}).strict(),M({events:A()});let ZC=j(N({agent:O().min(1).max(128),section:P([`main`,`more`,`auto`])})).max(256).refine(e=>new Set(e.map(e=>e.agent)).size===e.length,`Duplicate Harness IDs`);N({entries:ZC.nullable()}),N({}),N({entries:ZC,initializeOnly:A().optional()});let QC=N({enabled:A(),timeoutMinutes:k().int().min(5).max(1440)});Object.freeze({enabled:!0,timeoutMinutes:10});let $C=O().regex(/^external$/u),ew=yx.transform(e=>String(e)),tw=N({model:Hx.optional(),thinkingOptionId:Wx.optional(),permissionModeId:Cx.optional()}).refine(e=>!!(e.model||e.thinkingOptionId||e.permissionModeId),`A default configuration must contain a preference`),nw=N({lastHarness:yx.optional(),byHarness:Ys(ew,tw)}),rw=N({model:Hx.optional(),thinkingOptionId:Wx.optional()}).refine(e=>!!(e.model||e.thinkingOptionId),`A delegation default must contain a Model or Thinking option`),iw=N({byHarness:Ys(ew,rw)}),aw=O().min(1).max(1024),ow=N({idleRelease:QC.optional(),favorites:Ys(ew,j(aw).max(2048)).default({}),newThread:nw.optional(),delegation:iw.optional()});N({scope:$C,revision:k().int().nonnegative(),values:ow}),N({scope:$C.default(`external`)});let sw=Us(`kind`,[N({kind:F(`idleRelease`),value:QC}),N({kind:F(`favorite`),harnessId:yx,modelId:aw,enabled:A()}),N({kind:F(`favorites`),harnessId:yx,modelIds:j(aw).max(2048)}),N({kind:F(`newThread`),lastHarness:yx.optional(),harnessId:yx.optional(),configuration:tw.optional()}),N({kind:F(`delegation`),harnessId:yx,configuration:rw.nullable()})]);N({scope:$C.default(`external`),operations:j(sw).min(1).max(256),initializeOnly:A().optional(),expectedRevision:k().int().nonnegative().optional()}).superRefine((e,t)=>{for(let n of e.operations)n.kind===`newThread`&&(!n.lastHarness&&!n.configuration||!!n.harnessId!=!!n.configuration)&&t.addIssue({code:`custom`,message:`A default Harness or complete configuration is required`})}),N({version:F(1),revision:k().int().nonnegative(),scopes:Ys($C,ow)});let cw=k().finite().nonnegative(),lw=N({input:cw,output:cw,cacheRead:cw.optional(),cacheWrite:cw.optional(),cacheWrite1h:cw.optional()}),uw=O().max(512).refine(e=>e.trim()===e&&e.length>0,`Model ID is required`);N({path:O(),entries:j(N({key:O(),price:lw})),error:O().nullable()}),N({}),N({key:uw,price:lw.nullable(),previousKey:uw.optional()}),N({model:uw});let dw=N({official:A().optional(),canonicalModelId:O().min(1).optional(),provider:O().min(1).max(512),model:O().min(1).max(512),price:lw});N({price:lw.nullable(),suggestions:j(dw).max(6).optional()});let fw=[`today`,`7d`,`30d`,`90d`,`all`],pw=k().int().min(0).max(2**53-1),mw=O().regex(/^\d{4}-\d{2}-\d{2}$/u),hw=O().min(1).max(128),gw=O().min(1).max(512),_w=O().min(1).max(4096);N({range:P(fw),timeZone:O().min(1).max(128).refine(e=>{try{return new Intl.DateTimeFormat(`en`,{timeZone:e}),!0}catch{return!1}},`Unsupported usage statistics timezone`).optional(),harness:hw.optional(),model:gw.nullable().optional(),project:_w.nullable().optional(),date:mw.optional()});let vw=N({requests:pw,inputTokens:pw,cachedInputTokens:pw,cacheWriteInputTokens:pw,cacheKnownInputTokens:pw,cacheHitCachedInputTokens:pw,cacheHitInputTokens:pw,outputTokens:pw,reasoningOutputTokens:pw,costUsd:k().finite().min(0),unpricedRequests:pw,unmeteredRequests:pw}),yw=vw.shape,bw=N({harness:hw,sessionId:O().min(1).max(512),project:_w.nullable(),title:O().min(1).max(200).optional(),models:j(gw).max(16),firstAtMs:pw,lastAtMs:pw,...yw});N({range:P(fw),from:mw.nullable(),to:mw,filters:N({harness:hw.nullable(),model:gw.nullable(),unknownModel:A(),project:_w.nullable(),unknownProject:A(),date:mw.nullable()}),reading:N({complete:A(),sources:pw,read:pw}),failures:j(N({harness:hw,message:O().max(2048)})).max(256),options:N({harnesses:j(hw).max(256),models:j(gw.nullable()).max(4096),projects:j(_w.nullable()).max(4096)}),modelLabels:j(N({harness:hw,model:gw,label:gw})).max(4096).optional(),credits:j(N({harness:hw,model:gw.nullable(),credits:k().finite().min(0),reportedRequests:pw,requests:pw})).max(4096).optional(),totals:vw,daily:j(N({date:mw,harness:hw,...yw})).max(2e5),hourly:j(N({weekday:k().int().min(0).max(6),hour:k().int().min(0).max(23),...yw})).max(168),byHarness:j(N({harness:hw,...yw})).max(256),byModel:j(N({model:gw.nullable(),...yw,harnessPricedRequests:pw})).max(4096),byProject:j(N({project:_w.nullable(),...yw})).max(4096),sessions:j(bw).max(100),recentSessions:j(bw).max(100).optional()}),M({threadId:bx}),M({discarded:A()});let xw=Us(`type`,[M({id:O().min(1),type:F(`choice`),prompt:O(),options:j(M({value:O().min(1),label:O(),description:O().optional()})).min(1),multiple:A(),allowOther:A(),optional:A()}),M({id:O().min(1),type:F(`text`),prompt:O(),multiline:A(),secret:F(!1),optional:A(),placeholder:O().optional(),prefill:O().optional()})]),Sw=M({interactionId:O().min(1),turnId:O().min(1),title:O().optional(),questions:j(xw).min(1)}).refine(({questions:e})=>e.some(e=>e.type===`choice`&&e.multiple),{message:`Shared cards require at least one multi-select question`});N({threadId:O().min(1)}),M({questions:j(Sw)}),N({threadId:O().min(1),turnId:O().min(1),interactionId:O().min(1),answers:Ys(O(),j(O())),cancelled:A().default(!1)}),M({accepted:F(!0)});let Cw=M({path:O(),oldText:O().nullable(),newText:O()});M({sessionId:O().min(1),turn:k().int().nonnegative(),path:O().min(1).optional()}),M({diffs:j(Cw)}),N({}),N({}),M({reference:M({sessionId:O().min(1),epoch:O().min(1),turn:k().int().nonnegative(),seq:k().int().nonnegative(),callId:O().min(1),part:k().int().nonnegative(),version:O().min(1)}),length:k().int().nonnegative(),bytes:k().int().nonnegative()}),N({title:O().trim().min(1).max(200),type:P([`info`,`warning`,`danger`]),body:O().trim().min(1).max(16384)}),N({}),N({url:O().max(2048).regex(/^http:\/\/(?:127\.0\.0\.1|localhost):\d{1,5}\/(?:\?.*)?$/u)}),Object.freeze(/* @__PURE__ */ `codexhost/console/remote-connections.codexhost/runtime/status.codexhost/remote/ssh-setup.codexhost/harness/plugins/list.codexhost/harness/display-settings/capabilities.codexhost/harness/display-settings/get.codexhost/harness/display-settings/set.codexhost/harness/inspect.codexhost/harness/installation.codexhost/harness/installation/start.codexhost/harness/installation/status.codexhost/harness/launch-settings/get.codexhost/harness/launch-settings/set.codexhost/harness/web-ui/open.codexhost/harness/accounts/sources.codexhost/harness/accounts/list.codexhost/harness/accounts/inspect.codexhost/harness/credential-imports.codexhost/harness/session-import/sources.codexhost/harness/session-import/list.codexhost/harness/session-import/import.codexhost/account/list.codexhost/account/refresh.codexhost/account/usage/inspect.codexhost/usage/model-prices/get.codexhost/usage/model-prices/set.codexhost/usage/model-prices/default.codexhost/usage/statistics/get.codexhost/update/check.codexhost/update/start.codexhost/update/status`.split(`.`));let ww=P([`idle`,`running`,`busy`,`closing`,`failed`,`blocked`]),Tw=P([`none`,`disabled`,`timeout`,`operation`,`background`,`identity`,`persistence`,`closeFailed`]);N({threadId:O(),title:O(),harnessId:O(),state:ww,reason:Tw,inactiveMs:k().nonnegative()}),N({threadId:bx,turnId:xx});let Ew=M({email:O().trim().min(1).max(320).optional(),label:O().trim().min(1).max(256).optional(),plan:O().trim().min(1).max(128).optional(),credits:Lx.optional(),balance:Rx.optional()}).strict();function Dw(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 Ow=Dw(Ew),kw={harnessId:yx,harnessName:O().trim().min(1).max(128)},Aw=M(kw).strict();M({}).strict(),M({sources:j(Aw).max(128)}).strict(),M({harnessId:yx,refresh:A().optional()}).strict(),M({...kw,account:Ow.nullable(),accounts:j(Ow).max(8).optional()}).strict(),M({refresh:A().optional()}).strict(),M({accounts:j(Dw(Ew.extend(kw))).max(128)}).strict(),M({harnessId:iS,model:Hx.optional(),thinkingOptionId:Wx.optional(),permissionModeId:Cx.optional(),prewarm:F(!0).optional()}).strict();let jw=O().trim().min(1).max(4096).refine(e=>!/[\u0000\r\n]/u.test(e),`Invalid entrypoint path`);M({harnessId:iS}).strict().extend({path:jw.nullable()}),M({path:jw.nullable(),restartRequired:A()}).strict(),M({harnessId:yx,action:P([`check`,`update`,`install`]),confirmedVersion:O().min(1).max(128).optional()}).strict().refine(({action:e,confirmedVersion:t})=>e===`update`||t===void 0);let Mw=M({currentVersion:O().min(1).max(128),latestVersion:O().min(1).max(128),updateAvailable:A(),canUpdate:A(),latestVerifiedVersion:O().min(1).max(128).optional(),confirmationRequired:F(!0).optional(),versionKind:P([`cli`,`application`]).optional(),manualUpdateUrl:fs().max(2048).refine(e=>/^https:\/\/[^/?#@]+(?:[/?#]|$)/iu.test(e),`Manual updates require a credential-free HTTPS URL`).optional(),message:O().max(2048).optional(),messageCode:O().min(1).max(128).optional(),notice:_x.optional(),latestVersionKind:P([`unknown`,`tracking-branch`]).optional()}).strict();M({taskId:O().uuid()}).strict(),Us(`status`,[M({taskId:O().uuid(),status:F(`running`)}).strict(),M({taskId:O().uuid(),status:F(`succeeded`),result:Mw}).strict(),M({taskId:O().uuid(),status:F(`failed`),error:M({code:k().int(),message:O().min(1).max(2048)}).strict()}).strict()]);let Nw=O().min(1).max(256).regex(/^[A-Za-z0-9._~-]+$/u),Pw=O().trim().min(1),Fw=P([`free`,`go`,`plus`,`pro`,`prolite`,`team`,`self_serve_business_prolite`,`self_serve_business_usage_based`,`business`,`ent26`,`enterprise_cbp_automation`,`enterprise_cbp_usage_based`,`enterprise`,`edu`,`edu_plus`,`edu_pro`,`unknown`]),Iw=M({accountId:Nw,label:Pw.max(256),email:O().email().max(320).optional(),planType:Fw.optional()}).strict(),Lw=P([`ready`,`unavailable`]);M({version:F(2),currentAccountId:Nw.nullable(),phase:Lw,revision:k().int().nonnegative(),instanceId:Pw.max(1024).optional(),accounts:j(Iw).max(1)}).strict(),M({accountId:Nw,refresh:A().optional()}).strict(),M({accountId:Nw,usage:jx.nullable(),accountCredits:Lx.optional(),freshness:P([`live`,`cached`]),observedAt:O().datetime().nullable()}).strict();let Rw=1e3,zw=O().refine(e=>e.trim().length>0,`Value must not be empty or whitespace`).refine(e=>!e.includes(`\0`),`Value must not contain NUL`),Bw=zw.max(1024),Vw=M({nativeSessionId:Bw,title:zw.max(4096).nullable(),updatedAt:k().int().nonnegative().max(864e13),cwd:zw.max(16384),running:A().nullable()}).strict();M({}).strict(),M({harnesses:j(M({harnessId:iS,name:zw.max(128)}).strict()).max(128)}).strict(),M({harnessId:iS,query:O().trim().max(4096).refine(e=>!e.includes(`\0`)).optional(),offset:k().int().nonnegative().safe().optional(),limit:k().int().min(1).max(Rw).optional()}).strict(),M({candidates:j(Vw).max(Rw),total:k().int().nonnegative().safe()}).strict(),M({harnessId:iS,nativeSessionId:Bw}).strict(),M({threadId:zw.max(1024).pipe(bx)}).strict();let Hw=O().refine(e=>e.trim().length>0,`Value must not be empty or whitespace`).refine(e=>!e.includes(`\0`),`Value must not contain NUL`),Uw=Bw,Ww=Vw;M({}).strict(),M({candidates:j(Ww).max(1e3)}).strict(),M({nativeSessionId:Uw}).strict(),M({threadId:Hw.max(1024).pipe(bx)}).strict(),M({threadId:bx,lastTurnId:xx}).strict(),M({threadId:bx}).strict();let Gw=O().trim().min(1).max(128).regex(/^[A-Za-z0-9._:-]+$/u).brand();M({commands:j(M({id:Gw,invocation:O().min(1).max(128),label:O().trim().min(1).max(128),description:O().trim().min(1).max(512).optional(),localizations:gx.optional(),argumentMode:P([`none`,`text`]),kind:P([`command`,`skill`]).optional()}).strict()),warnings:j(O().min(1)).optional(),source:P([`live`,`static`]).optional()}).strict().superRefine((e,t)=>{let n=/* @__PURE__ */ new Set;for(let[r,i]of e.commands.entries())n.has(i.id)&&t.addIssue({code:`custom`,message:`Harness command IDs must be unique`,path:[`commands`,r,`id`]}),n.add(i.id)}),M({harnessId:yx,cwd:O().min(1).optional()}).strict(),M({threadId:bx}).strict(),M({threadId:bx,commandId:Gw,turnId:xx.optional(),arguments:fx.optional()}).strict(),M({accepted:F(!0),turnId:xx.optional()}).strict();let Kw=F(`2.0`).optional(),qw=Ls().optional(),Jw=O().min(1),Yw=Vs([O(),k().int()]),Xw=M({code:k().int(),message:O(),data:dx.optional()}).catchall(dx).superRefine(ox([`data`]));Vs([M({jsonrpc:Kw,id:Yw,method:Jw,params:dx.optional(),result:qw,error:qw}).catchall(dx).superRefine(ox([`jsonrpc`,`params`,`result`,`error`])),M({jsonrpc:Kw,id:qw,method:Jw,params:dx.optional(),result:qw,error:qw}).catchall(dx).superRefine(ox([`jsonrpc`,`id`,`params`,`result`,`error`])),M({jsonrpc:Kw,id:Yw,method:qw,params:qw,result:dx,error:qw}).catchall(dx).superRefine(ox([`jsonrpc`,`method`,`params`,`error`])),M({jsonrpc:Kw,id:Yw,method:qw,params:qw,result:qw,error:Xw}).catchall(dx).superRefine(ox([`jsonrpc`,`method`,`params`,`result`]))]);let Zw=O().refine(e=>e.trim().length>0,{message:`Native identifier must not be empty or whitespace`});N({harnessId:yx,nativeSessionId:Zw,locator:dx.optional(),formatVersion:F(1)}).superRefine(ox([`locator`])),N({harnessId:yx,nativeSessionId:Zw,nativeTurnKey:Zw,formatVersion:F(1)}),N({harnessId:yx,nativeSessionId:Zw,checkpointId:Zw,locator:dx.optional(),formatVersion:F(1)}).superRefine(ox([`locator`]));let Qw=O().regex(/^\d+\.\d+\.\d+(?:-[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?(?:\+[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/u),$w=P([`npm`,`windows-installer`,`macos-dmg`,`linux-archive`]),eT=N({version:Qw,installation:$w,phase:P([`prepared`,`downloading`,`waiting-for-exit`,`installing`,`restarting`,`succeeded`,`failed`]),updatedAt:k().int().nonnegative(),downloadedBytes:k().int().nonnegative().optional(),totalBytes:k().int().positive().optional(),error:O().min(1).max(500).nullable(),serviceStopOutput:O().optional()}).superRefine((e,t)=>{e.downloadedBytes!==void 0&&e.totalBytes!==void 0&&e.downloadedBytes>e.totalBytes&&t.addIssue({code:`custom`,path:[`downloadedBytes`],message:`downloadedBytes must not exceed totalBytes`})});N({});let tT=O().max(300).regex(/^https:\/\/github\.com\/BytePioneer-AI\/codex-host\/releases\/tag\/v[0-9A-Za-z.+-]+$/u,`release notes URL must identify a codexhost GitHub Release`);N({currentVersion:Qw,installation:$w.nullable(),latestVersion:Qw.nullable(),updateAvailable:A(),installationAvailable:A(),releaseNotes:O().min(1).max(2e4).nullable(),releaseNotesUrl:tT.nullable(),status:eT.nullable(),error:O().min(1).max(500).nullable()}),N({status:eT}),N({status:eT.nullable()});let nT=N({icon:O().min(1).max(16).optional(),title:O().min(1).max(120),body:O().min(1).max(1200),contributors:j(O().min(1).max(39)).max(30)}),rT=N({summary:O().min(1).max(600).optional(),themes:j(nT).min(1).max(12)}),iT=N({version:Qw,publishedAt:Fo(),url:O().max(300).regex(/^https:\/\/github\.com\/BytePioneer-AI\/codex-host\/releases\/tag\/v[0-9A-Za-z.+-]+$/u),zh:rT.nullable(),en:rT.nullable()}).refine(e=>e.zh!==null||e.en!==null,{message:`an announcement needs at least one language`});N({manual:A().optional()}),N({announcement:iT.nullable(),unread:A()}),N({version:Qw}),RegExp(String.raw`^- \[([^\]\n]+)\]\(thread://([^\s()<>"?#/]+)\): `+`(${[`completed`,`failed`,`interrupted`,`needsInput`,`timedOut`,`unreadable`,`notFound`].join(`|`)})(?:\. (.+))?$`,`u`);function aT(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 oT(e,t){let n=aT(e);return n===``?t:`${n}\n## My request:\n${t}\n`}let sT=P([`idle`,`installing`,`restarting`,`succeeded`,`failed`]);M({runningVersion:O().nullable(),installedVersion:O().nullable(),restartRequired:A(),remote:A(),updateSupported:A(),update:M({phase:sT,targetVersion:O().nullable(),error:O().nullable()})});let cT=M({version:O().regex(/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/u)}).strict();M({hostname:O().min(1).max(1024).refine(e=>!e.startsWith(`-`)&&!/\s/u.test(e)),port:k().int().min(1).max(65535).nullable(),identity:O().max(4096).nullable(),action:P([`inspect`,`install`,`update`,`repair`,`uninstall`]),uninstallPackage:A().optional(),version:O().regex(/^\d+\.\d+\.\d+$/u).nullable()}).strict(),M({state:P([`installed`,`not-installed`])}).strict();let X=O().min(1).max(1024),lT={hostId:X.regex(/^(?:remote-(?:ssh(?:-|:)|control:)|remote-peer:[a-zA-Z0-9_-]{1,64}$)/u)},uT={...lT,threadId:X},dT=O().min(1).max(8e3),fT={text:dT,requestId:X};Us(`accepted`,[M({accepted:F(!0),startQueuedItemId:X.optional()}),M({accepted:F(!1),code:P([`remote/queue-unavailable`,`remote/steer-unavailable`,`remote/turn-changed`,`remote/send-rejected`,`session/queue-item-not-found`,`session/queue-item-starting`]),message:O()})]),Us(`available`,[M({available:F(!1)}),M({available:F(!0),items:j(M({id:X,clientUserMessageId:X,preview:O().max(801)})).max(100)})]);let pT=Us(`kind`,[N({kind:F(`hosts`)}),N({kind:F(`create`),...lT,cwd:O().min(1).max(8192),epoch:X}),N({kind:F(`projectHarnesses`),...lT,epoch:X}),N({kind:F(`inspectHarness`),...lT,epoch:X,cwd:O().min(1).max(8192),harnessId:X}),N({kind:F(`startSelected`),...lT,epoch:X,cwd:O().min(1).max(8192),harnessId:X,model:O().min(1).max(4096),serviceTier:P([`priority`,`ultrafast`]).optional(),reasoningEffort:X.optional()}),N({kind:F(`status`),...uT}),N({kind:F(`list`),...lT,cursor:O().nullable(),archived:A(),includeLoaded:F(!0).optional()}),N({kind:F(`read`),...uT,page:N({cursor:O().min(1).max(8192).nullable(),epoch:X.optional(),sortDirection:P([`asc`,`desc`]).optional(),limit:k().int().min(1).max(20).optional()}).refine(e=>e.cursor===null||e.epoch!==void 0,{message:`A history continuation requires its connection epoch`}).optional()}),N({kind:F(`usage`),...uT,epoch:X}),N({kind:F(`configure`),...uT,epoch:X,modelId:X.optional(),serviceTier:Vx.optional(),thinkingOptionId:X.optional(),permissionModeId:X.optional()}).refine(e=>[e.modelId,e.thinkingOptionId,e.permissionModeId].filter(e=>e!==void 0).length===1,`Select exactly one remote setting`).refine(e=>e.serviceTier===void 0||e.modelId!==void 0,{message:`A service tier requires a Model ID`}),N({kind:F(`prompt`),...uT,epoch:X,text:dT,requestId:X.optional()}),N({kind:F(`queue`),...uT,epoch:X}),N({kind:F(`delivery`),...uT,epoch:X,action:Us(`kind`,[N({kind:F(`enqueue`),...fT}),N({kind:F(`steer`),...fT,turnId:X}),N({kind:F(`remove`),itemId:X}),N({kind:F(`start`),itemId:X,onlyIfHead:F(!0).optional()})])}),N({kind:F(`interrupt`),...uT,epoch:X,turnId:X}),N({kind:F(`rename`),...uT,epoch:X,name:O().min(1).max(512)}),N({kind:F(`archive`),...uT,epoch:X,archived:A()}),N({kind:F(`respond`),...uT,epoch:X,requestId:Vs([X,k().int()]),result:Ys(O(),Fs())})]),mT=O().min(1).max(1024),hT=M({hostId:mT,displayName:O().min(1).max(1024),source:P([`codex-managed`,`discovered`]),sshAlias:O().max(1024).nullable(),sshHost:O().min(1).max(1024),sshPort:k().int().min(1).max(65535).nullable(),identity:O().max(4096).nullable(),autoConnect:A(),connectionAnalyticsId:O().max(1024).optional()}),gT=N({displayName:O().min(1).max(1024),hostname:O().min(1).max(1024),sshPort:k().int().min(1).max(65535).nullable(),identity:O().max(4096).nullable()});Us(`action`,[N({action:F(`session`),operation:pT}),N({action:F(`list`)}),N({action:F(`catalog`)}),N({action:F(`read-thread`),hostId:mT.refine(e=>e!==`local`),input:GC}),N({action:F(`save`),draft:gT,previous:hT.nullable()}),N({action:F(`remove`),previous:hT}),N({action:F(`connect`),hostId:mT,enabled:A()}),N({action:F(`state`),hostId:mT}),N({action:F(`runtime`),hostId:mT}),N({action:F(`update`),hostId:mT.refine(e=>e!==`local`),version:cT.shape.version})]),Vs([N({result:dx}),N({error:N({code:k().int(),message:O()})})]),N({prompt:O().trim().min(1).max(2e3),cwd:O().max(4096).nullable()}),O().trim().min(1).max(60).nullable();let _T=O().max(214).regex(/^(?:@[a-z0-9][a-z0-9._-]*\/)?[a-z0-9][a-z0-9._-]*$/u),vT=Vs([O(),M({en:O()}).catchall(O())]),yT=M({title:vT.optional(),description:vT.optional(),icon:O().max(349592).regex(/^data:image\/(?:svg\+xml|png|jpeg|webp);base64,[A-Za-z0-9+/]*={0,2}$/u).optional(),error:O().optional()});M({extensions:j(M({id:_T,name:O().min(1).max(214),version:O().min(1).max(128),format:F(`dsh`),supportedTargets:qs([F(`web`)]),enabledTargets:j(F(`web`)).max(1),source:O().min(1).max(4096),projectUrl:O().max(4096).url({protocol:/^https?$/u}).optional(),installedAt:O(),meta:yT.optional(),loadError:O().optional()})),loadedIds:j(_T),safeMode:A(),storeError:O().optional()});let bT=O().trim().max(2048).url({protocol:/^https?$/u,normalize:!0}).refine(e=>!/[\s\\?#]/u.test(e)&&!e.split(`/`)[2]?.includes(`@`),`Use an HTTP(S) registry URL without credentials, a query, or a fragment.`).transform(e=>e.endsWith(`/`)?e:`${e}/`);M({spec:O().trim().min(1).max(4096),registry:bT.optional()}).strict(),M({id:_T,enabled:A()}).strict(),M({id:_T}).strict();let xT=O().regex(/^[a-zA-Z0-9_-]{1,64}$/u),ST=O().regex(/^remote-peer:[a-zA-Z0-9_-]{1,64}$/u),CT=P([`relay`,`tailscale`,`lan`,`custom`]),wT=[`blue`,`purple`,`cyan`,`green`,`amber`,`rose`,`slate`],TT=P(wT);new Set(wT);let ET=P([`connected`,`connecting`,`auth-error`,`offline`,`disabled`]);M({peers:j(M({peerId:xT,hostId:ST,name:O().min(1).max(120),color:TT.optional(),origin:O().min(1).max(2048),transportKind:CT,encrypted:A(),enabled:A(),state:ET,latencyMs:k().int().nonnegative().optional(),version:O().max(128).optional(),platform:O().max(64).optional(),hostname:O().max(255).optional(),homeDir:O().max(4096).optional(),lastError:O().max(1e3).optional(),projectCount:k().int().nonnegative(),createdAt:O(),updatedAt:O()}))}),M({connectionUrl:O().min(1).max(4096).optional(),origin:O().min(1).max(2048).optional(),token:O().min(1).max(2048).optional(),name:O().trim().min(1).max(120).optional(),color:TT.optional()}).refine(e=>!!e.connectionUrl||!!e.origin&&!!e.token,`Provide either connectionUrl or both origin and token`),M({peerId:xT,name:O().trim().min(1).max(120).optional(),color:TT.nullable().optional(),connectionUrl:O().min(1).max(4096).optional(),origin:O().min(1).max(2048).optional(),token:O().min(1).max(2048).optional(),enabled:A().optional()}),M({peerId:xT}),M({removed:A()}),M({peerId:xT.optional(),connectionUrl:O().min(1).max(4096).optional(),origin:O().min(1).max(2048).optional(),token:O().min(1).max(2048).optional()}).refine(e=>!!e.peerId||!!e.connectionUrl||!!e.origin&&!!e.token,`Provide peerId, connectionUrl, or both origin and token`);let DT=M({id:O().min(1).max(1024),name:O().min(1).max(512),path:O().min(1).max(8192)});M({ok:A(),latencyMs:k().int().nonnegative().optional(),origin:O().max(2048).optional(),transportKind:CT.optional(),encrypted:A().optional(),version:O().max(128).optional(),platform:O().max(64).optional(),hostname:O().max(255).optional(),homeDir:O().max(4096).optional(),projectCount:k().int().nonnegative().optional(),projects:j(DT).optional(),error:O().max(1e3).optional()});let OT=M({id:O().min(1).max(1024),name:O().min(1).max(512),path:O().min(1).max(8192),threadIds:j(O().min(1).max(1024))}),kT=M({attachments:F(1).optional(),workspaceFiles:F(1).optional(),officePreview:F(1).optional()}),AT=M({version:O().max(128),platform:O().max(64),hostname:O().max(255),homeDir:O().max(4096).optional(),epoch:O().min(1).max(256),projects:j(OT),capabilities:kT.optional()});N({threadId:O().min(1).max(1024),scope:O().regex(/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/u).optional(),requestId:O().min(1).max(256).optional(),mode:P([`queue`,`steer`]).optional(),expectedTurnId:O().min(1).max(1024).nullable().optional(),content:j(Us(`type`,[N({type:F(`text`),text:O()}),N({type:F(`file`),receiptId:O().min(1).max(128)})])).min(1).max(64)});let jT=M({ok:F(!1),error:M({code:O(),message:O(),details:Ys(O(),Fs()).optional()})});Vs([M({ok:F(!0),value:M({receiptId:O().min(1),file:M({attachmentId:O(),name:O(),bytes:k().int().nonnegative()})})}),jT]),Vs([M({ok:F(!0),value:M({accepted:F(!0)})}),jT]);let MT=M({name:O().min(1).max(512),path:O().min(1).max(8192),kind:F(`directory`)});M({peerId:xT,path:O().min(1).max(8192).optional()}),M({path:O().min(1).max(8192),parentPath:O().min(1).max(8192).nullable(),homeDir:O().min(1).max(8192).optional(),entries:j(MT)}),M({peerId:xT,parentPath:O().min(1).max(8192),name:O().min(1).max(255).refine(e=>e.trim().length>0,`Directory name cannot be blank`)}),M({path:O().min(1).max(8192),name:O().min(1).max(255)}),M({peerId:xT,path:O().min(1).max(8192),title:O().trim().min(1).max(255).optional()}),M({peerId:xT,workspaceId:O().min(1).max(1024),title:O().trim().min(1).max(255)}),M({peerId:xT,workspaceId:O().min(1).max(1024)}),M({workspaceId:O().min(1).max(1024).optional(),manifest:AT}),F(1);function NT(e){return e.registerNodeTransform(zf,e=>{let t=LC(e.getTextContent())[0];t&&e.splitText(t.start,t.end)[t.start===0?0:1]?.replace(new Wb({source:`codexhost-skill`,ref:t.text,label:t.name,appearance:`skill`,clipboardText:t.text}))})}let PT=`color: var(--dsw-alias-state-business-primary)`;function FT(){let e=Oh().getFirstChild();if(!W(e))return null;let t=e.getFirstChild();return B(t)?t:null}function IT(e,t){return e.registerNodeTransform(zf,e=>{let n=FT();if(n===null||e.getKey()!==n.getKey()){e.getStyle()===PT&&e.setStyle(``);return}let r=e.getTextContent(),i=t(),a=r===i?.trimEnd()?r:i;if(a===null||!r.startsWith(a))e.getStyle()===PT&&e.setStyle(``);else if(r.length>a.length){let[t,n]=e.splitText(a.length);t!==void 0&&t.getStyle()!==PT&&t.setStyle(PT),n?.setStyle(``)}else e.getStyle()!==PT&&e.setStyle(PT)})}function LT(e){e.update(()=>{FT()?.markDirty()})}function RT(){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(Kb(e))o(`chip`,e,``,e.getTextContent());else if(B(e)){let t=e.getTextContent();o(`text`,e,t,t)}else Im(e)?o(`linebreak`,e,`
|
|
144
|
+
`)}return e}getTextContentSize(){let e=function(e){let t=0;for(let n of xy(e)){let r=Sy(e,n);r!==null&&(t+=r.getTextContentSize())}return t}(this),t=this.getChildren(),n=t.length;for(let r=0;r<n;r++){let i=t[r];e+=i.getTextContentSize(),W(i)&&r!==n-1&&!i.isInline()&&(e+=2)}return e}getDirection(){return this.getLatest().__dir}getTextFormat(){return this.getLatest().__textFormat}hasFormat(e){if(e!==``){let t=_d[e];return(this.getFormat()&t)!==0}return!1}hasTextFormat(e){let t=hd[e];return(this.getTextFormat()&t)!==0}getFormatFlags(e,t){return v_(this.getLatest().__textFormat,e,t)}getTextStyle(){return this.getLatest().__textStyle}select(e,t){ag();let n=H(),r=e,i=t,a=this.getChildrenSize();if(!this.canBeEmpty()){if(e===0&&t===0){let e=this.getFirstChild();if(B(e)||W(e))return e.select(0,0)}else if(!(e!==void 0&&e!==a||t!==void 0&&t!==a)){let e=this.getLastChild();if(B(e)||W(e))return e.select()}}r===void 0&&(r=a),i===void 0&&(i=a);let o=this.__key;return V(n)?(n.anchor.set(o,r,`element`),n.focus.set(o,i,`element`),n.dirty=!0,n):Ah(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!==``&&_d[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){Cm(this)&&I(324,this.__key,this.__type);let r=this.getChildrenSize(),i=this.getWritable();e+t<=r||I(226,String(e),String(t),String(r));for(let e of n);let a=i.__key,o=[],s=[],c=this.getChildAtIndex(e+t),l=null,u=r-t+n.length;if(e!==0){if(e===r)l=this.getLastChild();else{let t=this.getChildAtIndex(e);t!==null&&(l=t.getPreviousSibling())}}if(t>0){let e=l===null?this.getFirstChild():l.getNextSibling();for(let n=0;n<t;n++){e===null&&I(100);let t=e.getNextSibling(),n=e.__key;b_(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--,b_(t);let n=e.__key;if(d===null)i.__first=n,t.__prev=null;else{let e=d.getWritable();e.__next=n,t.__prev=e.__key}e.__key===a&&I(76),t.__parent=a,o.push(n),d=e}if(e+t===r)d!==null&&(d.getWritable().__next=null,i.__last=d.__key);else if(c!==null){let e=c.getWritable();if(d!==null){let t=d.getWritable();e.__prev=d.__key,t.__next=c.__key}else e.__prev=null}if(i.__size=u,s.length){let e=H();if(V(e)){let t=new Set(s),n=new Set(o),{anchor:r,focus:i}=e;Eg(r,t,n)&&Lh(r,r.getNode(),this,l,c),Eg(i,t,n)&&Lh(i,i.getNode(),this,l,c),u!==0||this.canBeEmpty()||uv(this)||this.remove()}}return i}getDOMSlot(e){return new Ed(e)}exportDOM(e){let{element:t}=super.exportDOM(e);if(J(t)){let e=this.getIndent();e>0&&(t.style.paddingInlineStart=40*e+`px`,t.setAttribute(`data-lexical-indent`,String(e)));let n=this.getDirection();n&&(t.dir=n)}return{element:t}}exportJSON(){let e={children:[],direction:this.getDirection(),format:this.getFormatType(),indent:this.getIndent(),...super.exportJSON()},t=this.getTextFormat(),n=this.getTextStyle();return t===0&&n===``||uv(this)||this.getChildren().some(B)||(t!==0&&(e.textFormat=t),n!==``&&(e.textStyle=n)),e}updateFromJSON(e){return super.updateFromJSON(e).setFormat(e.format).setIndent(e.indent).setDirection(e.direction).setTextFormat(e.textFormat||0).setTextStyle(e.textStyle||``)}insertNewAfter(e,t){return null}canIndent(){return!0}collapseAtStart(e){return!1}excludeFromCopy(e){return!1}canReplaceWith(e){return!0}canInsertAfter(e){return!0}canBeEmpty(){return!0}canInsertTextBefore(){return!0}canInsertTextAfter(){return!0}isInline(){return!1}isShadowRoot(){return!1}canMergeWith(e){return!1}extractWithChild(e,t,n){return!1}canMergeWhenEmpty(){return!1}reconcileObservedMutation(e,t){let n=Uv(this,e,t),r=n.getFirstChild();for(let e=this.getFirstChild();e;e=e.getNextSibling()){let i=t.getElementByKey(e.getKey());i!==null&&(r==null?(n.insertChild(i),r=i):r!==i&&n.replaceChild(i,r),r=r.nextSibling)}}};function W(e){return e instanceof Tg}function Eg(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 Dg=class extends Tm{__slotHost;__slots;constructor(e){super(e),this.__slotHost=null,this.__slots=null}afterCloneFrom(e){super.afterCloneFrom(e),this.__key===e.__key&&(this.__slotHost=e.__slotHost,this.__slotHost!==null&&this.__parent!==null&&I(383,this.__key,String(this.__slotHost),String(this.__parent)),this.__slots=e.__slots)}decorate(e,t){return null}isIsolated(){return!1}isInline(){return!0}isKeyboardSelectable(){return!0}};function G(e){return e instanceof Dg}var Og=class extends Tg{__cachedText;$config(){return this.config(`root`,{extends:Tg})}constructor(){super(`root`),this.__cachedText=null}getTopLevelElementOrThrow(){I(51)}getTextContent(){let e=this.__cachedText;return e===null||!ig()&&U()._dirtyType!==0?super.getTextContent():e}remove(){I(52)}replace(e){I(53)}insertBefore(e){I(54)}insertAfter(e){I(55)}updateDOM(e,t){return!1}splice(e,t,n){for(let e of n)W(e)||G(e)||I(282);return super.splice(e,t,n)}static importJSON(e){return j_().updateFromJSON(e)}collapseAtStart(){return!0}};function kg(e){return e instanceof Og}function Ag(e){return new Pg(jd(e._nodeMap),null,e._slotsUsed)}function jg(){return new Pg(/* @__PURE__ */ new Map([[`root`,new Og]]),null,!1)}function Mg(e){let t=e.exportJSON(),n=e.constructor;if(t.type!==n.getType()&&I(130,n.name),W(e)){let r=t.children;Array.isArray(r)||I(59,n.name);let i=e.getChildren();for(let e=0;e<i.length;e++){let t=Mg(i[e]);r.push(t)}}let r=xy(e);if(r.length>0){let i={};for(let t of r){let r=Sy(e,t);r===null&&I(366,n.name,t),i[t]=Mg(r)}t.$slots=i}return t}function Ng(e){return e instanceof Pg}var Pg=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 gg(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 gg(null,this,()=>({root:Mg(j_())}))}},Fg=class extends Tg{$config(){return this.config(`artificial`,{extends:Tg})}createDOM(e){return wv().createElement(`div`)}},Ig=class extends Tm{$config(){return this.config(`linebreak`,{importDOM:{br:e=>Bg(e)||Vg(e)?null:{conversion:Lg,priority:0}}})}getTextContent(){return`
|
|
145
|
+
`}createDOM(){return wv().createElement(`br`)}updateDOM(){return!1}isInline(){return!0}};function Lg(e){return{node:Rg()}}function Rg(){return fv(new Ig)}function zg(e){return e instanceof Ig}function Bg(e){let t=e.parentElement;if(t!==null&&zv(t)){let n=t.firstChild;if(n===e||n.nextSibling===e&&Hg(n)){let n=t.lastChild;if(n===e||n.previousSibling===e&&Hg(n))return!0}}return!1}function Vg(e){let t=e.parentElement;if(t!==null&&zv(t)){let n=t.firstChild;if(n===e||n.nextSibling===e&&Hg(n))return!1;let r=t.lastChild;if(r===e||r.previousSibling===e&&Hg(r))return!0}return!1}function Hg(e){return h_(e)&&/^( |\t|\r?\n)+$/.test(e.textContent||``)}var Ug=class extends Tg{$config(){return this.config(`paragraph`,{extends:Tg,importDOM:{p:()=>({conversion:Wg,priority:0})}})}createDOM(e){let t=wv().createElement(`p`),n=J_(e.theme,`paragraph`);return n!==void 0&&t.classList.add(...n),t}updateDOM(e,t,n){return!1}exportDOM(e){let{element:t}=super.exportDOM(e);if(J(t)){this.isEmpty()&&t.append(wv().createElement(`br`));let e=this.getFormatType();e&&(t.style.textAlign=e)}return{element:t}}exportJSON(){let e=super.exportJSON();if(e.textFormat===void 0||e.textStyle===void 0){let t=this.getChildren().find(B);t?(e.textFormat=t.getFormat(),e.textStyle=t.getStyle()):(e.textFormat=this.getTextFormat(),e.textStyle=this.getTextStyle())}return e}insertNewAfter(e,t){let n=Gg();n.setTextFormat(e.format),n.setTextStyle(e.style);let r=this.getDirection();return n.setDirection(r),n.setFormat(this.getFormatType()),n.setStyle(this.getStyle()),this.insertAfter(n,t),n}collapseAtStart(){let e=this.getChildren();if(e.length===0||B(e[0])&&e[0].getTextContent().trim()===``){if(this.getNextSibling()!==null)return this.selectNext(),this.remove(),!0;if(this.getPreviousSibling()!==null)return this.selectPrevious(),this.remove(),!0}return!1}};function Wg(e){let t=Gg();if($v(t,e),Zv(e,t),t.getFormatType()===``){let n=e.getAttribute(`align`);n&&n&&n in _d&&t.setFormat(n)}return Qv(t,e),{node:t}}function Gg(){return fv(new Ug)}function Kg(e){return e instanceof Ug}function qg(e){console.warn(e)}function Jg(e,t,n,r,i){let a=e._keyToDOMMap;a.clear(),e._editorState=jg(),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),E_(n,e,`root`))}function Yg(e){let t=/* @__PURE__ */ new Set,n=/* @__PURE__ */ new Set;for(let{klass:r,ownNodeConfig:i}of cy(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 Xg={$createDOM:(e,t)=>e.createDOM(t._config,t),$decorateDOM:(e,t,n,r)=>{},$exportDOM:(e,t)=>{let n=o_(t,e.getType());return n&&n.exportDOM!==void 0?n.exportDOM(t,e):e.exportDOM(t)},$extractWithChild:(e,t,n,r,i)=>W(e)&&e.extractWithChild(t,n,r),$getDOMSlot:(e,t,n)=>e.getDOMSlot(t),$getSlotTargetElement:(e,t,n,r)=>null,$shouldExclude:(e,t,n)=>W(e)&&e.excludeFromCopy(`html`),$shouldInclude:(e,t,n)=>!t||e.isSelected(t),$updateDOM:(e,t,n,r)=>e.updateDOM(t,n,r._config)};function Zg(e){let t=e||{},n=dg(),r=t.theme||{},i=e===void 0?n:t.parentEditor||null,a=t.disableEvents||!1,o=jg(),s=t.namespace||(i===null?L_():i._config.namespace),c=t.editorState,l=[Og,Hm,Ig,$m,Ug,Fg,...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===Tm||n.prototype instanceof Tm)){let r=`<unknown>`;try{r=JSON.parse(kd)}catch{}I(365,String(e-l.length+(t.nodes?t.nodes.length:0)),typeof n==`function`?`${n.name}${typeof n.getType==`function`?` (type ${String(n.getType())})`:``}`:String(n),String(r))}sy(n);let a=n.getType(),o=Yg(n);m.set(a,{exportDOM:f&&f.export?f.export.get(n):void 0,klass:n,replace:r,replaceWithKlass:i,sharedNodeState:Kd(l[e]),transforms:o})}}let h=new e_(o,i,m,{disableEvents:a,dom:{...Xg,...e&&e.dom},namespace:s,theme:r},u||console.error,d||qg,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(rp,cm,0),e.registerCommand(ip,lm,0),e.registerCommand(ap,um,0),e.registerCommand(op,dm,0),e.registerCommand(vp,mm,0)}(h),h}function Qg(e,t){let n=e.get(t);e.delete(t),n&&n()}function $g(e,t,n){return e.set(t,n),Qg.bind(null,e,t)}var e_=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 Md,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=L_(),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 $g(this._listeners.update,e)}registerEditableListener(e){return $g(this._listeners.editable,e)}registerDecoratorListener(e){return $g(this._listeners.decorator,e)}registerTextContentListener(e){return $g(this._listeners.textcontent,e)}registerRootListener(e){let t=this._listeners.root;return Ib($g(t,e,e(this._rootElement,null)||void 0),()=>function(e,t,n){let r=e.get(t);r&&r(),e.set(t,t(...n)||void 0)}(t,e,[null,this._rootElement]))}registerCommand(e,t,n){n===void 0&&I(35);let r=this._commands;r.has(e)||r.set(e,[new Ad,new Ad,new Ad,new Ad,new Ad]);let i=r.get(e);i===void 0&&I(36,String(e));let a=function(e){return 7&e}(n),o=i[a];return a===n?o.addBack(t):o.addFront(t),()=>{o.delete(t),i.every(e=>e.size===0)&&r.delete(e)}}registerMutationListener(e,t,n){let r=this.resolveRegisteredNodeAfterReplacements(this.getRegisteredNode(e)).klass,i=this._listeners.mutation,a=i.get(t);a===void 0&&(a=/* @__PURE__ */ new Set,i.set(t,a)),a.add(r);let o=n&&n.skipInitialization;return o!==void 0&&o||this.initializeMutationListener(t,r),()=>{a.delete(r),a.size===0&&i.delete(t)}}getRegisteredNode(e){let t=this._nodes.get(e.getType());return t===void 0&&I(37,e.name),t}resolveRegisteredNodeAfterReplacements(e){for(;e.replaceWithKlass;)e=this.getRegisteredNode(e.replaceWithKlass);return e}initializeMutationListener(e,t){let n=this._editorState,r=Jv(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=Jv(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=w_(t);e&&e.markDirty()}},e._pendingEditorState===null?{tag:Dm}:void 0)}(this,r.map(e=>e.klass.getType())),()=>{r.forEach(e=>e.transforms.delete(t))}}hasNode(e){return this._nodes.has(e.getType())}hasNodes(e){return e.every(this.hasNode.bind(this))}dispatchCommand(e,...t){return q(this,e,...t)}getDecorators(){return this._decorators}getRootElement(){return this._rootElement}getKey(){return this._key}setRootElement(e){let t=this._rootElement;if(e!==t){let n=J_(this._config.theme,`root`),r=this._pendingEditorState||this._editorState;if(this._rootElement=e,Jg(this,t,e,r,{preserveUpdateQueue:!0}),t!==null&&(this._config.disableEvents||bm(t),n!=null&&t.classList.remove(...n)),e!==null){let t=av(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,Ud(this),this._updateTags.add(Dm),_g(this),this._config.disableEvents||function(e,t){let n=e.ownerDocument;Yp.set(e,n);let r=Xp.get(n);r===void 0&&(r={editors:/* @__PURE__ */ new Set,hasShadowEditor:void 0},Xp.set(n,r)),r.editors.add(t),r.hasShadowEditor=void 0,e.__lexicalEditor=t;let i=hm(e);i.push(Zp.register(n));for(let n=0;n<Jp.length;n++){let[r,a]=Jp[n],o=typeof a==`function`?e=>{ym(e)||(vm(e),(t.isEditable()||r===`click`)&&a(e,t))}:e=>{if(ym(e))return;vm(e);let n=t.isEditable();switch(r){case`cut`:return n&&q(t,Ip,e);case`copy`:return q(t,Fp,e);case`paste`:return n&&q(t,dp,e);case`dragstart`:return n&&q(t,Mp,e);case`dragover`:return n&&q(t,Np,e);case`dragend`:return n&&q(t,Pp,e);case`focus`:return n&&q(t,Hp,e);case`blur`:return n&&q(t,Up,e);case`drop`:return n&&q(t,jp,e)}};i.push(Kp(e,r,o))}}(e,this),n!=null&&e.classList.add(...n)}else this._window=null,this._updateTags.add(Dm),_g(this);vg(`root`,this,!1,e,t)}}getElementByKey(e){return this._keyToDOMMap.get(e)||null}getEditorState(){return this._editorState}setEditorState(e,t){e.isEmpty()&&I(38);let n=e;n._readOnly&&(n=Ag(e),n._selection=e._selection?e._selection.clone():null),Hd(this);let r=this._pendingEditorState,i=t===void 0?null:t.tag;r===null||r.isEmpty()||(i!=null&&this._updateTags.add(i),_g(this)),this._pendingEditorState=n,this._dirtyType=2,this._dirtyElements.set(`root`,!1),this._compositionKey=null,this._slotsUsed=this._slotsUsed||e._slotsUsed,Cg(this,()=>{if(i&&this._updateTags.add(i),e._parsed)for(let[e,t]of n._nodeMap.entries())W(t)?this._dirtyElements.set(e,!0):this._dirtyLeaves.add(e)},{discrete:!this._updating||void 0})}parseEditorState(e,t){return function(e,t,n){let r=jg(),i=Xh,a=Qh,o=Zh,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,Xh=r,Qh=!1,Zh=t,n_(null);try{let i=t._nodes;hg(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,Xh=i,Qh=a,Zh=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`&&_g(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]):Sg(e,t,n)})(this,e,t)}focus(e,t={}){let n=this._rootElement;n!==null&&(n.setAttribute(`autocapitalize`,`off`),Cg(this,()=>{let r=H(),i=j_();r===null?i.getChildrenSize()!==0&&(t.defaultSelection===`rootStart`?i.selectStart():i.selectEnd()):r.dirty||M_(r.clone()),nv(`focus`),rv(()=>{n.removeAttribute(`autocapitalize`),e&&e()})}),this._pendingEditorState===null&&n.removeAttribute(`autocapitalize`))}blur(){let e=this._rootElement;e!==null&&e.blur();let t=_v(this._window);t!==null&&t.removeAllRanges()}isEditable(){return this._editable}setEditable(e){this._editable!==e&&(this._editable=e,vg(`editable`,this,!0,e),this._slotsUsed&&this.update(()=>lg()))}toJSON(){return{editorState:this._editorState.toJSON()}}};e_.version=kd;let t_=null;function n_(e){t_=e}let r_=Symbol(`INTERNAL_SKIP_AFTER_CLONE_FROM`),i_=1;function a_(e,t){let n=o_(e,t);return n===void 0&&I(30,t),n}function o_(e,t){return e._nodes.get(t)}let s_=typeof queueMicrotask==`function`?queueMicrotask:e=>{Promise.resolve().then(e)};function c_(e,t){let n=t===void 0?(()=>{let t=e.getRootNode();return g_(t)||yv(t)?Mv(t):null})():t;if(!J(n)||n.hasAttribute(`data-lexical-slot`))return!1;let r=O_(n),i=n.nodeName;return Em(r)&&(i===`INPUT`||i===`TEXTAREA`||n.contentEditable===`true`&&f_(n)==null)}function l_(e,t,n){let r=e.getRootElement();if(!r)return!1;try{if(!t||!r.contains(t)||!r.contains(n))return!1}catch{return!1}return d_(t)===e&&e.read(`latest`,()=>!c_(t))}function u_(e){return e instanceof e_}function d_(e){let t=e;for(;t!=null;){let e=f_(t);if(u_(e))return e;t=ev(t)}return null}function f_(e){return e?e.__lexicalEditor:null}function p_(e){return th(e)||e.isToken()}function m_(e){return p_(e)||e.isSegmented()}function h_(e){return Pv(e)&&e.nodeType===3}function g_(e){return Pv(e)&&e.nodeType===9}function __(e){let t=e;for(;t!=null;){if(h_(t))return t;t=t.firstChild}return null}function v_(e,t,n){let r=hd[t];if(n!==null&&(e&r)===(n&r))return e;let i=e^r;return t===`subscript`?i&=~hd.superscript:t===`superscript`?i&=~hd.subscript:t===`lowercase`?(i&=~hd.uppercase,i&=~hd.capitalize):t===`uppercase`?(i&=~hd.lowercase,i&=~hd.capitalize):t===`capitalize`&&(i&=~hd.lowercase,i&=~hd.uppercase),i}function y_(e,t){let n=function(){let e=t_;return t_=null,e}();if((t||=n&&n.__key)!=null)return void(e.__key=t);ag(),og();let r=U(),i=sg(),a=``+i_++;i._nodeMap.set(a,e),W(e)?r._dirtyElements.set(a,!0):r._dirtyLeaves.add(a),r._cloneNotNeeded.add(a),r._dirtyType===0&&(r._dirtyType=1),e.__key=a}function b_(e){gy(e)!==null&&I(380,e.__key,String(gy(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 x_(e){og(),Cm(e)&&I(323,e.__key,e.__type);let t=e.getLatest(),n=t.__parent===null?hy(t)?t.__slotHost:null:t.__parent,r=sg(),i=U(),a=r._nodeMap,o=i._dirtyElements;n!==null&&function(e,t,n){let r=e;for(;r!==null;){if(n.has(r))return;let e=t.get(r);if(e===void 0)break;n.set(r,!1),r=e.__parent===null?hy(e)?e.__slotHost:null:e.__parent}}(n,a,o);let s=t.__key;i._dirtyType===0&&(i._dirtyType=1),W(e)?o.set(s,!0):i._dirtyLeaves.add(s)}function S_(e){ag();let t=U(),n=t._compositionKey;if(e!==n){if(t._compositionKey=e,n!==null){let e=w_(n);e!==null&&e.getWritable()}if(e!==null){let t=w_(e);t!==null&&t.getWritable()}}}function C_(){return ig()?null:U()._compositionKey}function w_(e,t){let n=(t||sg())._nodeMap.get(e);return n===void 0?null:n}function T_(e,t){let n=D_(e,U());return n===void 0?null:w_(n,t)}function E_(e,t,n){e[`__lexicalKey_${t._key}`]=n}function D_(e,t){return e[`__lexicalKey_${t._key}`]}function O_(e,t){let n=e;for(;n!=null;){let e=T_(n,t);if(e!==null)return e;n=ev(n)}return null}function k_(e){let t=e._decorators,n=Object.assign({},t);return e._pendingDecorators=n,n}function A_(e){return e.read(()=>j_().getTextContent())}function j_(){return sg()._nodeMap.get(`root`)}function M_(e){ag();let t=sg();e!==null&&(e.dirty=!0,e.setCachedNodes(null),V(e)&&U()._slotsUsed&&Dh(e)),t._selection=e}function N_(){ag(),Hd(U())}function P_(e){let t=function(e,t){let n=e;for(;n!=null;){let e=D_(n,t);if(e!==void 0)return e;n=ev(n)}return null}(e,U());return t===null?null:w_(t)}function F_(e){return/[\uD800-\uDBFF][\uDC00-\uDFFF]/g.test(e)}function I_(e){let t=[];for(let n=e;n!==null;n=n._parentEditor)t.push(n);return t}function L_(){return Math.random().toString(36).replace(/[^a-z]+/g,``).substring(0,5)}function R_(e){return h_(e)?e.nodeValue:null}function z_(e,t,n){let r=_v(ov(t));if(r===null)return;let i=Dv(r,t._rootElement),a=i.anchorNode,{anchorOffset:o,focusOffset:s}=i;if(a!==null){let t=R_(a),r=O_(a);if(t!==null&&B(r)){if((t===dd||t===fd)&&n){let e=n.length;t=n,o=e,s=e}t!==null&&B_(r,t,o,s,e)}}}function B_(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(dd)&&(s=t.slice(0,-dd.length)),i)){let e=fd,t;for(;(t=s.indexOf(e))!==-1;)s=s.slice(0,t)+s.slice(t+e.length),n!==null&&n>t&&(n=Math.max(t,n-e.length)),r!==null&&r>t&&(r=Math.max(t,r-e.length))}let c=a.getTextContent();if(i||s!==c){let t=H();if(s===``){if(S_(null),sd||ad||ud)a.remove();else{let e=U();V_(a,``,t),setTimeout(()=>{e.update(()=>{a.isAttached()&&a.getTextContent()===``&&a.remove()})},20)}return}let i=a.getParent(),c=Ph(),l=a.getTextContentSize(),u=C_(),d=a.getKey();if(a.isToken()&&!o||u!==null&&d===u&&!o||V(c)&&(i!==null&&!i.canInsertTextBefore()&&c.anchor.offset===0||c.anchor.key===e.__key&&c.anchor.offset===0&&!a.canInsertTextBefore()&&!o||c.focus.key===e.__key&&c.focus.offset===l&&!a.canInsertTextAfter()&&!o))return void a.markDirty();if(!V(t)||n===null||r===null)return void V_(a,s,t);if(t.setTextNodeRange(a,n,a,r),a.isSegmented()){let e=Zm(a.getTextContent());a.replace(e),a=e}V_(a,s,t)}}}function V_(e,t,n){if(e.setTextContent(t),V(n)){let t=e.getKey(),r=!1;for(let i of[`anchor`,`focus`]){let a=n[i];a.type===`text`&&a.key===t&&(a.offset=Zy(e,a.offset,`clamp`),r=!0)}r&&(n._cachedNodes=null,n._cachedIsBackward=null)}}function H_(e,t,n){let r=t[n]||!1;return r===`any`||r===e[n]}function U_(e,t){return H_(e,t,`altKey`)&&H_(e,t,`ctrlKey`)&&H_(e,t,`shiftKey`)&&H_(e,t,`metaKey`)}function K(e,t,n){if(!U_(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 W_={ctrlKey:!nd,metaKey:nd},G_={altKey:nd,ctrlKey:!nd};function K_(e){return e.key===`Backspace`}function q_(e){let t=j_();if(V(e)){let t=e.anchor,n=e.focus,r=t.getNode();if(kg(r))return t.set(r.getKey(),0,`element`),n.set(r.getKey(),r.getChildrenSize(),`element`),of(e),e;let i=r.getTopLevelElementOrThrow(),a=i.getParent();if(a===null)return W(i)&&(t.set(i.getKey(),0,`element`),n.set(i.getKey(),i.getChildrenSize(),`element`),of(e)),e;let o=a;return t.set(o.getKey(),0,`element`),n.set(o.getKey(),o.getChildrenSize(),`element`),of(e),e}{let e=t.select(0,t.getChildrenSize());return M_(of(e)),e}}function J_(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=Pb(i);return n[t]=e,e}return i}function Y_(e,t,n,r,i){if(n.size===0)return;let a=r.__type,o=r.__key,s=t.get(a);s===void 0&&I(33,a);let c=s.klass,l=e.get(c);l===void 0&&(l=/* @__PURE__ */ new Map,e.set(c,l));let u=l.get(o),d=u===`destroyed`&&i===`created`;(u===void 0||d)&&l.set(o,d?`updated`:i)}function X_(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 Z_(e,t){let n=e.offset;if(e.type===`element`)return X_(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?X_(r.getParentOrThrow(),t,r.getIndexWithinParent()+ +!t):e}}return null}function Q_(e){let t=ov(e).event,n=t&&t.inputType;return n===`insertFromPaste`||n===`insertFromPasteAsQuotation`}function q(e,t,...n){return yg(e,t,n[0],e)}function $_(e,t){let n=e._keyToDOMMap.get(t);return n===void 0&&I(75,t),n}function ev(e){let t=e.assignedSlot||e.parentElement;if(t!==null)return t;let n=e.parentNode;return yv(n)?n.host:null}function tv(e){return g_(e)?e:J(e)?e.ownerDocument:null}function nv(e){ag(),U()._updateTags.add(e)}function rv(e){ag(),U()._deferred.push(e)}function iv(e,t){let n=e.getParent();for(;n!==null;){if(n.is(t))return!0;n=n.getParent()}return!1}function av(e){let t=tv(e);return t?t.defaultView:null}function ov(e){let t=e._window;return t===null&&I(78),t}function sv(e){return W(e)&&e.isInline()||G(e)&&e.isInline()}function cv(e){let t=e.getLatest();for(;t!==null;){if(gy(t)!==null&&W(t))return t;let e=t.getParentOrThrow();if(uv(e))return e;t=e}return t}function lv(e){return W(e)&&e.isShadowRoot()}function uv(e){return kg(e)||lv(e)}function dv(e,t=!1){let n=e.constructor.clone(e,r_);return y_(n,null),n.afterCloneFrom(e),t||n.resetOnCopyNodeFrom(e),n}function fv(e){let t=U(),n=e.getType(),r=o_(t,n);r===void 0&&I(200,e.constructor.name,n);let{replace:i,replaceWithKlass:a}=r;if(i!==null){let t=i(e),r=t.constructor;return a===null?t instanceof e.constructor&&r!==e.constructor||I(202,r.name,r.getType(),e.constructor.name,n):t instanceof a||I(201,a.name,a.getType(),r.name,r.getType(),e.constructor.name,n),t.__key===e.__key&&I(203,e.constructor.name,n,r.name,r.getType()),t}return e}function pv(e,t){!kg(e.getParent())||W(t)||G(t)||I(99)}function mv(e){let t=w_(e);return t===null&&I(63,e),t}function hv(e){if(!e||e.isInline())return!1;if(G(e))return!0;if(W(e)){if(e.isShadowRoot()){let t=e.getParent();return!(W(t)&&t.isShadowRoot())}return!e.canBeEmpty()}return!1}function gv(e,t,n){n.style.removeProperty(`caret-color`),t._blockCursorElement=null;let r=e.parentElement;r!==null&&r.removeChild(e)}function _v(e){return ed?(e||window).getSelection():null}function vv(e){let t=av(e);return t?t.getSelection():null}function yv(e){return Fv(e)&&`host`in e}let bv=[];function xv(e){let t=e.getRootNode();if(t===e||!yv(t))return bv;let n=[t],r=t.host;for(;;){let e=r.getRootNode();if(e===r||!yv(e))break;n.push(e),r=e.host}return n}function*Sv(e){let t=[e],n;for(;n=t.pop();){yield*n.querySelectorAll(`[data-lexical-editor="true"]`);let e=(g_(n)?n:n.ownerDocument).createTreeWalker(n,NodeFilter.SHOW_ELEMENT),r;for(;r=e.nextNode();)r.shadowRoot&&t.push(r.shadowRoot)}}function Cv(e){return e===null?document:e.ownerDocument}function wv(){let e=dg();return Cv(e===null?null:e._rootElement)}function Tv(e,t){if(t===null||typeof e.getComposedRanges!=`function`)return null;let n=xv(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 Ev(e,t){let n=Tv(e,t);if(n!==null){let e=Ov(n);if(e!==null)return e}return e.rangeCount>0?e.getRangeAt(0):null}function Dv(e,t){let n=Tv(e,t);return n===null?e:kv(n,Av(e))}function Ov(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 kv(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 Av(e){return e.direction}function jv(e){let t=e.getRootNode();return g_(t)||yv(t)?t.activeElement:null}function Mv(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 Nv(e){let t=e.target;if(t!==null&&J(t)&&t.shadowRoot!==null&&typeof e.composedPath==`function`){let t=e.composedPath();if(t.length>0)return t[0]}return t}function J(e){return Pv(e)&&e.nodeType===1}function Pv(e){return typeof e==`object`&&!!e&&`nodeType`in e&&typeof e.nodeType==`number`}function Fv(e){return Pv(e)&&e.nodeType===11}let Iv=/^(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 Lv(e){return!(!J(e)||!e.style.display.startsWith(`inline`))||Iv.test(e.nodeName)}let Rv=/^(address|article|aside|blockquote|canvas|dd|div|dl|dt|fieldset|figcaption|figure|footer|form|h1|h2|h3|h4|h5|h6|header|hr|li|main|nav|noscript|ol|p|pre|section|table|td|tfoot|ul|video)$/i;function zv(e){return(!J(e)||!e.style.display.startsWith(`inline`))&&Rv.test(e.nodeName)}function Bv(e){if(G(e)&&!e.isInline())return!0;if(!W(e)||uv(e))return!1;let t=e.getFirstChild(),n=t===null||zg(t)||B(t)||t.isInline();return!e.isInline()&&!1!==e.canBeEmpty()&&n}function Vv(){return U()}function Hv(e=Vv()){return e._config.dom||Xg}function Uv(e,t,n=Vv()){let r=Hv(n).$getDOMSlot(e,t,n);return W(e)&&(Wv(r)||I(344,e.getKey(),e.getType())),r}function Wv(e){return e instanceof Ed}function Gv(e,t,n=Vv()){return __(Uv(e,t,n).element)}let Kv=/* @__PURE__ */ new WeakMap,qv=/* @__PURE__ */ new Map;function Jv(e){if(!e._readOnly&&e.isEmpty())return qv;e._readOnly||I(192);let t=Kv.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),Kv.set(e,t)),t}function Yv(e){let t=e.constructor.clone(e,r_);return t.afterCloneFrom(e),t}function Xv(e){return(t=Yv(e))[Sm]=!0,t;var t}function Zv(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 Qv(e,t){let n=t.getAttribute(`dir`);return n===`ltr`||n===`rtl`?e.setDirection(n):e}function $v(e,t){let n=t.style.textAlign;return n&&n in _d?e.setFormat(n):e}function ey(e,t){e.__lexicalUnmanaged=!0,t&&t.captureSelection!==void 0&&(e.__lexicalCapturedSelection=t.captureSelection)}function ty(e){return!0===e.__lexicalUnmanaged}function ny(e,t=Vv()){let n=t.isEditable();e.contentEditable=n?`true`:`false`,n?e.__lexicalEditor=t:delete e.__lexicalEditor}function ry(e,t){let n=e;for(;n!=null;){if(!0===n.__lexicalCapturedSelection)return!0;if(J(n)&&n.hasAttribute(`data-lexical-slot`)||D_(n,t)!==void 0)return!1;n=ev(n)}return!1}function iy(e,t){return function(e,t){return Object.prototype.hasOwnProperty.call(e,t)}(e,t)&&e[t]!==Tm[t]}let ay=/* @__PURE__ */ new WeakMap,oy=Symbol(`lexical.synthesizedGetType`);function sy(e){let t=ay.get(e);if(t)return t;let n=e.prototype!=null&&xd in e.prototype?e.prototype[xd]():void 0,r=function(e){if(!(e===Tm||e.prototype instanceof Tm)){let t=`<unknown>`,n=`<unknown>`;try{t=e.getType()}catch{}try{e_.version&&(n=JSON.parse(e_.version))}catch{}I(290,e.name,t,n)}return e===Dg||e===Tg||e===Tm}(e),i=!r&&iy(e,`getType`)?e.getType:void 0,a=i&&!(oy 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(!iy(e,`getType`)){let t=e,n=function(){return this===t?s:Tm.getType.call(this)};n[oy]=!0,e.getType=n}if(iy(e,`clone`)||(e.clone=(t,n)=>{n_(t);let r=new e;return n!==r_&&r.afterCloneFrom(t),r}),iy(e,`importJSON`)||(e.importJSON=o&&o.$importJSON||(t=>new e().updateFromJSON(t))),!iy(e,`importDOM`)&&o){let{importDOM:t}=o;t&&(e.importDOM=()=>t)}}let c={klass:e,ownNodeConfig:o,ownNodeType:s};return ay.set(e,c),c}function*cy(e){for(let t=e;t&&(t===Tm||Em(t.prototype));){let e=sy(t);yield e,t=e.ownNodeConfig&&e.ownNodeConfig.extends||fy(t)}}function ly(e){let t=Vv();return ag(),new(t.resolveRegisteredNodeAfterReplacements(t.getRegisteredNode(e))).klass}let uy=(e,t)=>{let n=e;for(;n!=null&&!kg(n);){if(t(n))return n;n=n.getParent()}return null};function dy(e,t){let n=[],r=e.__first;for(;r!==null;){let e=t===null?w_(r):t.get(r);e??I(174),n.push(r),r=e.__next}return n}function fy(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 py=/* @__PURE__ */ new Map;function my(e){return W(e)||G(e)}function hy(e){return W(e)||G(e)}function gy(e){let t=e.getLatest();return hy(t)?t.__slotHost:null}function _y(e){let t=gy(e);if(t===null)return null;let n=w_(t);return W(n)||G(n)||I(370),n}function vy(e){let t=_y(e);if(t===null)return null;let n=e.getLatest().__key;for(let[e,r]of by(t))if(r===n)return e;return null}function yy(e){let t=e.getLatest();for(;t!==null;){if(gy(t)!==null)return t;t=t.getParent()}return null}function by(e){let t=e.getLatest();return my(t)&&t.__slots!==null?t.__slots:py}function xy(e){return Array.from(by(e).keys())}function Sy(e,t){let n=by(e).get(t);return n===void 0?null:w_(n)}let Cy=[`__proto__`,`constructor`,`prototype`],wy=Symbol(`slotMapOwner`);function Ty(e){let t=e.__slots;return t!==null&&t[wy]===e||(t=new Map(t),t[wy]=e,e.__slots=t),t}let Ey=/* @__PURE__ */ new WeakMap,Dy=[];function Oy(e){for(let{ownNodeConfig:t}of cy(e)){let e=t&&t.slots;if(e)return e}return Dy}function ky(e){let t=``;for(let n of xy(e)){let r=Sy(e,n);r!==null&&(t+=r.getTextContent())}return t}function Ay(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 jy(e){let t=e.__slots;if(t===null||t.size<2)return;let n=function(e){let t=Ey.get(e);if(t===void 0){let n=Oy(e),r=/* @__PURE__ */ new Map;for(let t of n)Cy.includes(t)&&I(371,e.name,t),r.has(t)&&I(372,e.name,t),r.set(t,r.size);t=r,Ey.set(e,t)}return t}(e.constructor),r=null,i=!0;for(let e of t.keys()){if(r!==null&&Ay(r,e,n)>0){i=!1;break}r=e}if(i)return;let a=Array.from(t).sort(([e],[t])=>Ay(e,t,n));t.clear();for(let[e,n]of a)t.set(e,n)}function My(e,t,n){t!==`__proto__`&&t!==`constructor`&&t!==`prototype`||I(373,t);let r=e.getLatest();if(r.__slots!==null&&r.__slots.get(t)===n.getLatest().__key)return r;(!W(n)&&!G(n)||n.isInline())&&I(374,n.__key);let i=e.getWritable(),a=Ty(i),o=a.get(t);o!==void 0&&Py(o);let s=n.getWritable(),c=_y(s);if(c!==null){let e=vy(s);e!==null&&Ty(c.getWritable()).delete(e),s.__slotHost=null}return b_(s),s.__slotHost=i.__key,a.set(t,s.__key),jy(i),function(){let e=Vv();e._slotsUsed=!0,e._pendingEditorState&&(e._pendingEditorState._slotsUsed=!0)}(),i}function Ny(e,t){let n=e.getWritable();if(n.__slots===null)return n;let r=n.__slots.get(t);return r!==void 0&&(Py(r),Ty(n).delete(t)),n}function Py(e){let t=w_(e);if(t===null)return;let n=t.getWritable();hy(n)||I(377,e),n.__slotHost=null,n.remove()}let Fy={next:`previous`,previous:`next`};var Iy=class{origin;constructor(e){this.origin=e}[Symbol.iterator](){return sb({hasNext:Wy,initial:this.getAdjacentCaret(),map:e=>e,step:e=>e.getAdjacentCaret()})}getAdjacentCaret(){return Yy(this.getNodeAtCaret(),this.direction)}getSiblingCaret(){return Yy(this.origin,this.direction)}remove(){let e=this.getNodeAtCaret();return e&&e.remove(),this}replaceOrInsert(e,t){let n=this.getNodeAtCaret();return e.is(this.origin)||e.is(n)||(n===null?this.insert(e):n.replace(e,t)),this}splice(e,t,n=`next`){let r=n===this.direction?t:Array.from(t).reverse(),i=this,a=this.getParentAtCaret(),o=/* @__PURE__ */ new Map;for(let t=i.getAdjacentCaret();t!==null&&o.size<e;t=t.getAdjacentCaret()){let e=t.origin.getWritable();o.set(e.getKey(),e)}for(let e of r){if(o.size>0){let t=i.getNodeAtCaret();if(t){if(o.delete(t.getKey()),o.delete(e.getKey()),!(t.is(e)||i.origin.is(e))){let n=e.getParent();n&&n.is(a)&&e.remove(),t.replace(e)}}else t===null&&I(263,Array.from(o).join(` `))}else i.insert(e);i=Yy(e,this.direction)}for(let e of o.values())e.remove();return this}},Ly=class e extends Iy{type=`child`;getLatest(){let e=this.origin.getLatest();return e===this.origin?this:$y(e,this.direction)}getParentCaret(e=`root`){return Yy(By(this.getParentAtCaret(),e),this.direction)}getFlipped(){let e=zy(this.direction);return Yy(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 Ry={root:kg,shadowRoot:uv};function zy(e){return Fy[e]}function By(e,t=`root`){return e===null||Ry[t](e)?null:gy(e)===null?e:null}var Vy=class e extends Iy{type=`sibling`;getLatest(){let e=this.origin.getLatest();return e===this.origin?this:Yy(e,this.direction)}getSiblingCaret(){return this}getParentAtCaret(){return this.origin.getParent()}getChildCaret(){return W(this.origin)?$y(this.origin,this.direction):null}getParentCaret(e=`root`){return Yy(By(this.getParentAtCaret(),e),this.direction)}getFlipped(){let e=zy(this.direction);return Yy(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 Hy)&&this.direction===t.direction&&this.origin.is(t.origin)}},Hy=class e extends Iy{type=`text`;offset;constructor(e,t){super(e),this.offset=t}getLatest(){let e=this.origin.getLatest();return e===this.origin?this:Xy(e,this.direction,this.offset)}getParentAtCaret(){return this.origin.getParent()}getChildCaret(){return null}getParentCaret(e=`root`){return Yy(By(this.getParentAtCaret(),e),this.direction)}getFlipped(){return Xy(this.origin,zy(this.direction),this.offset)}isSamePointCaret(t){return t instanceof e&&this.direction===t.direction&&this.origin.is(t.origin)&&this.offset===t.offset}isSameNodeCaret(t){return(t instanceof Vy||t instanceof e)&&this.direction===t.direction&&this.origin.is(t.origin)}getSiblingCaret(){return Yy(this.origin,this.direction)}};function Uy(e){return e instanceof Hy}function Wy(e){return e instanceof Vy}function Gy(e){return e instanceof Ly}let Ky={next:class extends Hy{direction=`next`;getNodeAtCaret(){return this.origin.getNextSibling()}insert(e){return this.origin.insertAfter(e),this}},previous:class extends Hy{direction=`previous`;getNodeAtCaret(){return this.origin.getPreviousSibling()}insert(e){return this.origin.insertBefore(e),this}}},qy={next:class extends Vy{direction=`next`;getNodeAtCaret(){return this.origin.getNextSibling()}insert(e){return this.origin.insertAfter(e),this}},previous:class extends Vy{direction=`previous`;getNodeAtCaret(){return this.origin.getPreviousSibling()}insert(e){return this.origin.insertBefore(e),this}}},Jy={next:class extends Ly{direction=`next`;getNodeAtCaret(){return this.origin.getFirstChild()}insert(e){return this.origin.splice(0,0,[e]),this}},previous:class extends Ly{direction=`previous`;getNodeAtCaret(){return this.origin.getLastChild()}insert(e){return this.origin.splice(this.origin.getChildrenSize(),0,[e]),this}}};function Yy(e,t){return e?new qy[t](e):null}function Xy(e,t,n){return e?new Ky[t](e,Zy(e,n)):null}function Zy(e,t,n=`error`){let r=e.getTextContentSize(),i=t===`next`?r:t===`previous`?0:t;return(i<0||i>r)&&(n!==`clamp`&&$u(284,String(t),String(r),e.getKey()),i=i<0?0:r),i}function Qy(e,t){return new rb(e,t)}function $y(e,t){return W(e)?new Jy[t](e):null}function eb(e){return e&&e.getChildCaret()||e}function tb(e){return e&&eb(e.getAdjacentCaret())}var nb=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 Uy(t)?function(e,t){let{direction:n,origin:r}=e;return Qy(e,Zy(r,t===`focus`?zy(n):n)-e.offset)}(t,e):null},t=e(`anchor`),n=e(`focus`);if(t&&n){let{caret:e}=t,{caret:r}=n;if(e.isSameNodeCaret(r))return[Qy(e,r.offset-e.offset),null]}return[t,n]}iterNodeCarets(e=`root`){let t=Uy(this.anchor)?this.anchor.getSiblingCaret():this.anchor.getLatest(),n=this.focus.getLatest(),r=Uy(n),i=t=>t.isSameNodeCaret(n)?null:tb(t)||t.getParentCaret(e);return sb({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`)}},rb=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 Xy(e.setTextContent(i.slice(0,n)+i.slice(r)),t,n)}};function ib(e){return ob(e,Yy(j_(),e.direction))}function ab(e){return ob(e,e)}function ob(e,t){return e.direction!==t.direction&&I(265),new nb(e,t,e.direction)}function sb(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 cb(e,t){let n=fb(e.origin,t.origin);switch(n===null&&I(275,e.origin.getKey(),t.origin.getKey()),n.type){case`same`:{let n=e.type===`text`,r=t.type===`text`;return n&&r?function(e,t){return Math.sign(e-t)}(e.offset,t.offset):e.type===t.type?0:n?-1:r?1:e.type===`child`?-1:1}case`ancestor`:return e.type===`child`?-1:1;case`descendant`:return t.type===`child`?1:-1;case`branch`:return lb(n)}}function lb(e){let{a:t,b:n}=e,r=t.__key,i=n.__key,a=t,o=n;for(;a&&o;a=a.getNextSibling(),o=o.getNextSibling()){if(a.__key===i)return-1;if(o.__key===r)return 1}return a===null?1:-1}function ub(e,t){return t.is(e)}function db(e){return W(e)?[e.getLatest(),null]:[e.getParent(),e.getLatest()]}function fb(e,t){if(e.is(t))return{commonAncestor:e,type:`same`};let n=/* @__PURE__ */ new Map;for(let[t,r]=db(e);t;r=t,t=t.getParent())n.set(t,r);for(let[r,i]=db(t);r;i=r,r=r.getParent()){let a=n.get(r);if(a!==void 0)return a===null?(ub(e,r)||I(276),{commonAncestor:r,type:`ancestor`}):i===null?(ub(t,r)||I(277),{commonAncestor:r,type:`descendant`}):((W(a)||ub(e,a))&&(W(i)||ub(t,i))&&r.is(a.getParent())&&r.is(i.getParent())||I(278),{a,b:i,commonAncestor:r,type:`branch`})}return null}function pb(e,t){let{type:n,key:r,offset:i}=e,a=mv(e.key);return n===`text`?(B(a)||I(266,a.getType(),r),Xy(a,t,i)):(W(a)||I(267,a.getType(),r),Eb(a,e.offset,t))}function mb(e,t){let{origin:n,direction:r}=t,i=r===`next`;Uy(t)?e.set(n.getKey(),t.offset,`text`):Wy(t)?B(n)?e.set(n.getKey(),Zy(n,r),`text`):e.set(n.getParentOrThrow().getKey(),n.getIndexWithinParent()+ +!!i,`element`):(Gy(t)&&W(n)||I(268),e.set(n.getKey(),i?0:n.getChildrenSize(),`element`))}function hb(e){let t=H(),n=V(t)?t:jh();return gb(n,e),M_(n),n}function gb(e,t){mb(e.anchor,t.anchor),mb(e.focus,t.focus)}function _b(e){let{anchor:t,focus:n}=e,r=pb(t,`next`),i=pb(n,`next`),a=cb(r,i)<=0?`next`:`previous`;return ob(wb(r,a),wb(i,a))}function vb(e){let{direction:t,origin:n}=e,r=Yy(n,zy(t)).getNodeAtCaret();return r?Yy(r,t):$y(n.getParentOrThrow(),t)}function yb(e,t=`root`){let n=[e];for(let r=Gy(e)?e.getParentCaret(t):e.getSiblingCaret();r!==null;r=r.getParentCaret(t))n.push(vb(r));return n}function bb(e){return!!e&&e.origin.isAttached()}function xb(e,t=`removeEmptySlices`){if(e.isCollapsed())return e;let n=`root`,r=`next`,i=t,a=Tb(e,r),o=yb(a.anchor,n),s=yb(a.focus.getFlipped(),n),c=/* @__PURE__ */ new Set,l=[];for(let e of a.iterNodeCarets(n))if(Gy(e))c.add(e.origin.getKey());else if(Wy(e)){let{origin:t}=e;W(t)&&!c.has(t.getKey())||l.push(t)}let u=/* @__PURE__ */ new Set;for(let e of l){let t=e.getParent();t===null||c.has(t.getKey())||u.add(t),b_(e)}for(let e of u)!e.canBeEmpty()&&!uv(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=vb(Yy(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=Zm(e.getTextContent()).setStyle(e.getStyle()).setFormat(e.getFormat());a.replaceOrInsert(n),t=Xy(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(bb(e)){d=Sb(e);break}for(let e of s)if(bb(e)){f=Sb(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(uv(i))return;!n&&t(i)&&(n=i)}return n},u=l(a,Bv),d=u&&l(o,e=>n.has(e.getKey())&&Bv(e));return d&&xy(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(Gy(e)){let t=e.origin;if(Bv(t))return t}else{let t=e.getParentAtCaret();if(t&&Bv(t))return t}return null}(f),t=e&&e.getParent(),n=e&&e.getParents().findLast(lv);if(e&&t&&!kg(t)&&e.isEmpty()&&c.has(e.getKey())&&xy(e).length===0&&(!n||c.has(n.getKey()))){e.remove(!0);let n=t;for(;n&&!kg(n)&&n.isEmpty();){let e=n.getParent();if(e&&kg(e)&&e.getChildrenSize()<=1)break;let t=n;n=e,t.remove(!0)}}}let m=[d,f,...o,...s].find(bb);if(m)return ab(wb(Sb(m),e.direction));I(269,JSON.stringify(o.map(e=>e.origin.__key)))}function Sb(e){let t=function(e){let t=e;for(;Gy(t);){let e=tb(t);if(!Gy(e))break;t=e}return t}(e.getLatest()),{direction:n}=t;if(B(t.origin))return Uy(t)?t:Xy(t.origin,n,n);let r=t.getAdjacentCaret();return Wy(r)&&B(r.origin)?Xy(r.origin,n,zy(n)):t}function Cb(e){return Uy(e)&&e.offset!==Zy(e.origin,e.direction)}function wb(e,t){return e.direction===t?e:e.getFlipped()}function Tb(e,t){return e.direction===t?e:ob(wb(e.focus,t),wb(e.anchor,t))}function Eb(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 wb(r,n)}function Db(e){let{origin:t,offset:n,direction:r}=e;if(n===Zy(t,r))return e.getSiblingCaret();if(n===Zy(t,zy(r)))return vb(e.getSiblingCaret());let[i]=t.splitText(n);return B(i)||I(281),wb(Yy(i,`next`),r)}function Ob(e,t){return!0}function kb(e,{$copyElementNode:t=dv,$splitTextPointCaretNext:n=Db,rootMode:r=`shadowRoot`,$shouldSplit:i=Ob,removeEmptyDestination:a=!1}={}){if(Uy(e))return n(e);let o=e.getParentCaret(r);if(o){let{origin:n}=o;if(Gy(e)){let e=vb(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 Ab(e,t,n){let r=wb(t,`next`);Uy(r)&&(r.offset===0?r=Yy(r.origin,`previous`).getFlipped():r.offset===r.origin.getTextContentSize()&&(r=Yy(r.origin,`next`))),r.origin.is(e)&&(Wy(r)||I(342,e.getKey(),e.getType()),r=vb(r)),(e.is(r.getNodeAtCaret())||e.is(r.getFlipped().getNodeAtCaret()))&&e.remove(!0);for(let e=r;e;e=kb(e,n))r=e;return Uy(r)&&I(283),r.insert(e.isInline()?Gg().append(e):e),wb(Yy(e.getLatest(),`next`),t.direction)}function jb(e){return e}function Mb(e){return e}function Nb(e,t){if(!t||e===t)return e;for(let n in t)if(e[n]!==t[n])return{...e,...t};return e}function Pb(...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 Fb(e,...t){let n=Pb(...t);n.length>0&&e.classList.add(...n)}function Ib(...e){return()=>{for(let t=e.length-1;t>=0;t--)e[t]();e.length=0}}function Lb(e){throw Error(`unreachable input event: ${JSON.stringify(e)}`)}function Rb(e,t){let n=e.trimStart();if(n.startsWith(t))return n.slice(t.length);let r=t.trimEnd();if(n.startsWith(r)){let e=n.slice(r.length);return/^\s/.test(e)?e.slice(1):e}return``}function zb(e,t){return e.startsWith(t)||e===t.trimEnd()}var Bb=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 Lb(e)}}onDraftChanged(e){return this.phase===`claimed`&&this.claim!==void 0&&!zb(e,this.claim.token)&&(this.phase=`plain`,this.claim=void 0),[]}onClaim(e){return this.phase!==`plain`&&this.phase!==`claimed`||(this.claim=e,this.phase=`claimed`),[]}mintAttempt(e,t,n){let r=new AbortController;return this.seq+=1,{attempt:{seq:this.seq,signal:r.signal,draftSnapshot:t,mode:e,...n===void 0?{}:{submission:n}},controller:r}}beginAttempt(e,t,n){let r=this.mintAttempt(e,t,n);return this.inflight=r,r.attempt}beginDetached(e,t,n){let r=this.mintAttempt(e,t,n);return this.detached.set(r.attempt.seq,r.controller),this.claim=void 0,this.phase=`plain`,r.attempt}detachedEffects(e){return[{type:`default-sink`,attempt:e,draft:e.draftSnapshot,mode:e.mode},{type:`commit-draft`,retainSuffixOf:e.draftSnapshot}]}onEnter(e,t,n,r){if(this.phase===`adjudicating`||this.phase===`submitting`)return[];if(this.phase===`claimed`&&this.claim!==void 0){let n=this.beginAttempt(e,t,r);return this.phase=`submitting`,[{type:`begin-submit`,attempt:n,claim:this.claim,args:Rb(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:Rb(e.draftSnapshot,t.claim.token)}]):(this.inflight=void 0,this.phase=`plain`,t===void 0?(this.detached.set(e.seq,n.controller),this.detachedEffects(e)):[])}onAdjudicationFailed(e,t){return this.phase!==`adjudicating`||this.inflight?.attempt.seq!==e.seq?[]:(this.inflight=void 0,this.phase=`plain`,[{type:`notice`,level:`error`,text:t}])}onSubmitSettled(e){let t=this.inflight;if(this.phase!==`submitting`||t===void 0||t.attempt.seq!==e.attempt.seq)return[];if(this.inflight=void 0,e.ok){this.phase=`plain`,this.claim=void 0;let n=[{type:`commit-draft`,retainSuffixOf:t.attempt.draftSnapshot}];return e.outcome?.text!==void 0&&n.push({type:`notice`,level:e.outcome.kind===`error`?`error`:`info`,text:e.outcome.text}),n}let n=e.message??e.outcome?.text;return e.draft===t.attempt.draftSnapshot&&this.claim!==void 0&&zb(e.draft,this.claim.token)?(this.phase=`claimed`,n===void 0?[]:[{type:`notice`,level:`error`,text:n}]):(this.phase=`plain`,this.claim=void 0,n===void 0?[]:[{type:`notice`,level:`error`,text:n}])}onSinkSettled(e){if(!this.detached.delete(e.attempt.seq))return[];let t=e.message??e.outcome?.text;return t===void 0?[]:[{type:`notice`,level:e.ok&&e.outcome?.kind!==`error`?`info`:`error`,text:t}]}onSendCommitted(){return this.phase===`plain`?(this.claim=void 0,[{type:`commit-draft`,retainSuffixOf:null}]):[]}onRelease(){this.inflight!==void 0&&(this.inflight.controller.abort(),this.inflight=void 0);for(let e of this.detached.values())e.abort();return this.detached.clear(),this.phase=`plain`,this.claim=void 0,[]}};function Vb(e){let t=Vv().getElementByKey(e.getKey());if(t===null)return null;let n=t.ownerDocument.defaultView;return n===null?null:n.getComputedStyle(t)}function Hb(e){return Vb(kg(e)?e:e.getParentOrThrow())}function Ub(e,t,n=`self`){let r=e.getStartEndPoints();if(t.isSelected(e)&&!m_(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]=hh(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=Xv(t)),t.__text=p)}}return t}function Wb(e){let t=Gb(e);return t!==null&&t.writingMode===`vertical-rl`}function Gb(e){let t=e.anchor.getNode();return W(t)?Vb(t):Hb(t)}function Kb(e,t){let n=Wb(e)?!t:t;Jb(e)&&(n=!n);let r=pb(e.focus,n?`previous`:`next`);if(Cb(r))return!1;if(Uy(r)&&!th(r.origin)&&r.origin.isUnmergeable()){let e=r.getNodeAtCaret();if(B(e)&&!th(e))return!0}for(let e of ib(r)){if(Gy(e))return!e.origin.isInline();if(!W(e.origin)){if(G(e.origin))return!0;break}}return!1}function qb(e,t,n,r){e.modify(t?`extend`:`move`,n,r)}function Jb(e){let t=Gb(e);return t!==null&&t.direction===`rtl`}function Yb(e,t,n){let r=Jb(e),i;i=Wb(e)||r?!n:n,qb(e,t,i,`character`)}function Xb(e,t){return e!==null&&Object.getPrototypeOf(e).constructor.name===t.name}let Zb=Symbol.for(`preact-signals`);function Qb(){if(nx>1)return void nx--;let e,t=!1;for(function(){let e=tx;for(tx=void 0;e!==void 0;)e.S.v===e.v&&(e.S.i=e.i),e=e.o}();$b!==void 0;){let n=$b;for($b=void 0,rx++;n!==void 0;){let r=n.u;if(n.u=void 0,n.f&=-3,!(8&n.f)&&sx(n))try{n.c()}catch(n){t||=(e=n,!0)}n=r}}if(rx=0,nx--,t)throw e}let Y,$b;function ex(e){let t=Y;Y=void 0;try{return e()}finally{Y=t}}let tx,nx=0,rx=0,ix=0;function ax(e){if(Y===void 0)return;let t=e.n;return t===void 0||t.t!==Y?(t={i:0,S:e,p:Y.s,n:void 0,t:Y,e:void 0,x:void 0,r:t},Y.s!==void 0&&(Y.s.n=t),Y.s=t,e.n=t,32&Y.f&&e.S(t),t):t.i===-1?(t.i=0,t.n!==void 0&&(t.n.p=t.p,t.p!==void 0&&(t.p.n=t.n),t.p=Y.s,t.n=void 0,Y.s.n=t,Y.s=t),t):void 0}function ox(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 sx(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 cx(e){for(let t=e.s;t!==void 0;t=t.n){let n=t.S.n;if(n!==void 0&&(t.r=n),t.S.n=t,t.i=-1,t.n===void 0){e.s=t;break}}}function lx(e){let t,n=e.s;for(;n!==void 0;){let e=n.p;n.i===-1?(n.S.U(n),e!==void 0&&(e.n=n.n),n.n!==void 0&&(n.n.p=e)):t=n,n.S.n=n.r,n.r!==void 0&&(n.r=void 0),n=e}e.s=t}function ux(e,t){ox.call(this,void 0),this.x=e,this.s=void 0,this.g=ix-1,this.f=4,this.W=t?.watched,this.Z=t?.unwatched,this.name=t?.name}function dx(e){let t=e.m;if(e.m=void 0,typeof t==`function`){nx++;let n=Y;Y=void 0;try{t()}catch(t){throw e.f&=-2,e.f|=8,fx(e),t}finally{Y=n,Qb()}}}function fx(e){for(let t=e.s;t!==void 0;t=t.n)t.S.U(t);e.x=void 0,e.s=void 0,dx(e)}function px(e){if(Y!==this)throw Error(`Out-of-order effect`);lx(this),Y=e,this.f&=-2,8&this.f&&fx(this),Qb()}function mx(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 hx(e,t){let n=new mx(e,t);try{n.c()}catch(e){throw n.d(),e}let r=n.d.bind(n);return r[Symbol.dispose]=r,r}ox.prototype.brand=Zb,ox.prototype.h=function(){return!0},ox.prototype.S=function(e){let t=this.t;t!==e&&e.e===void 0&&(e.x=t,this.t=e,t===void 0?ex(()=>{var e;(e=this.W)==null||e.call(this)}):t.e=e)},ox.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&&ex(()=>{var e;(e=this.Z)==null||e.call(this)}))}},ox.prototype.subscribe=function(e){return hx(()=>{let t=this.value,n=Y;Y=void 0;try{e(t)}finally{Y=n}},{name:`sub`})},ox.prototype.valueOf=function(){return this.value},ox.prototype.toString=function(){return this.value+``},ox.prototype.toJSON=function(){return this.value},ox.prototype.peek=function(){let e=Y;Y=void 0;try{return this.value}finally{Y=e}},Object.defineProperty(ox.prototype,"value",{get(){let e=ax(this);return e!==void 0&&(e.i=this.i),this.v},set(e){if(e!==this.v){if(rx>100)throw Error(`Cycle detected`);(function(e){nx!==0&&rx===0&&e.l!==0&&(e.l=0,tx={S:e,v:e.v,i:e.i,o:tx})})(this),this.v=e,this.i++,ix++,nx++;try{for(let e=this.t;e!==void 0;e=e.x)e.t.N()}finally{Qb()}}}}),ux.prototype=new ox,ux.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===ix))return!0;if(this.g=ix,this.f|=1,this.i>0&&!sx(this))return this.f&=-2,!0;let e=Y;try{cx(this),Y=this;let e=this.x();(16&this.f||this.v!==e||this.i===0)&&(this.v=e,this.f&=-17,this.i++)}catch(e){this.v=e,this.f|=16,this.i++}return Y=e,lx(this),this.f&=-2,!0},ux.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)}ox.prototype.S.call(this,e)},ux.prototype.U=function(e){if(this.t!==void 0&&(ox.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)}},ux.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(ux.prototype,"value",{get(){if(1&this.f)throw Error(`Cycle detected`);let e=ax(this);if(this.h(),e!==void 0&&(e.i=this.i),16&this.f)throw this.v;return this.v}}),mx.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()}},mx.prototype.S=function(){if(1&this.f)throw Error(`Cycle detected`);this.f|=1,this.f&=-9,dx(this),cx(this),nx++;let e=Y;return Y=this,px.bind(this,e)},mx.prototype.N=function(){2&this.f||(this.f|=2,this.u=$b,$b=this)},mx.prototype.d=function(){this.f|=8,1&this.f||fx(this)},mx.prototype.dispose=function(){this.d()};function gx(e){return(typeof e.nodes==`function`?e.nodes():e.nodes)||[]}function _x(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 vx;try{vx=`0.49.0+prod.esm`}catch{}let yx=vx??`"<unknown>+source"`,bx=/* @__PURE__ */ new Set([`__proto__`,`constructor`,`prototype`]);function xx(e,t){if(e&&t&&!Array.isArray(t)&&typeof e==`object`&&typeof t==`object`){let n=e,r=t;for(let e in r)!bx.has(e)&&Object.prototype.hasOwnProperty.call(r,e)&&(n[e]=xx(n[e],r[e]));return e}return t}function Sx(e){return e.id===0}function Cx(e){return e.id===2}function wx(e){return function(e){return e.id===1}(e)||_x(305,String(e.id),`1`),Object.assign(e,{id:2})}let Tx=/* @__PURE__ */ new Set;var Ex=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):Nb;for(let n of this.configs)e=t(e,n);return e}init(e){let t=this.state;Cx(t)||_x(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&&_x(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&&_x(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&&_x(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&&_x(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&&_x(311),this._signal}getInitResult(){this.extension.init===void 0&&_x(312,this.extension.name);let e=this.state;return function(e){return e.id>=4}(e)||_x(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)||_x(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&&_x(315,this.extension.name,e.name),t.getExtensionInitDependency()}getDependency(e){let t=this.builder.getExtensionRep(e);return t===void 0&&_x(315,this.extension.name,e.name),t.getExtensionDependency()}getState(){let e=this.state;return function(e){return e.id>=7}(e)||_x(316,String(e.id),`7`),e}getDirectDependentNames(){return this.builder.incomingEdges.get(this.extension.name)||Tx}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)||_x(317,this.extension.name),this._dependency={config:e.config,init:e.initResult,output:e.output}}return this._dependency}};let Dx={tag:Dm};function Ox(){let e=j_();e.isEmpty()&&e.append(Gg())}let kx=/* @__PURE__ */ jb({config:/* @__PURE__ */ Mb({setOptions:Dx,updateOptions:Dx}),init:({$initialEditorState:e=Ox})=>({$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(Ng(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:[Og,Hm,Ig,$m,Ug]}),Ax=Symbol.for(`@lexical/extension/LexicalBuilder`);function jx(){}function Mx(e){throw e}function Nx(e){return Array.isArray(e)?e:[e]}let Px=yx;var Fx=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=Px,this.roots=e;for(let t of e)this.addExtension(t)}static fromExtensions(t){let n=[Nx(kx)];for(let e of t)n.push(Nx(e));return new e(n)}static maybeFromEditor(t){let n=t[Ax];return n&&(n.PACKAGE_VERSION!==Px&&_x(292,n.PACKAGE_VERSION,Px),n instanceof e||_x(293)),n}static fromEditor(t){let n=e.maybeFromEditor(t);return n===void 0&&_x(294),n}constructEditor(){let{$initialEditorState:e,onError:t,onWarn:n,...r}=this.buildCreateEditorArgs(),i=Object.assign(Zg({...r,...t?{onError:e=>{t(e,i)}}:{},...n?{onWarn:e=>{n(e,i)}}:{}}),{[Ax]:this});for(let e of this.sortedExtensionReps())e.build(i);return i}buildEditor(){let e=jx;function t(){try{e()}finally{e=jx}}let n=Object.assign(this.constructEditor(),{dispose:t,[Symbol.dispose]:t});return e=Ib(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&&_x(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&&_x(296);let[t]=Nx(e);typeof t.name!=`string`&&_x(297,typeof t.name);let n=this.extensionNameMap.get(t.name);if(n!==void 0&&n.extension!==t&&_x(298,t.name),!n){n=new Ex(this,t),this.extensionNameMap.set(t.name,n);let e=this.conflicts.get(t.name);typeof e==`string`&&_x(299,t.name,e);for(let e of t.conflictsWith||[])this.extensionNameMap.has(e)&&_x(299,t.name,e),this.conflicts.set(e,t.name);for(let e of t.dependencies||[]){let n=Nx(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(Cx(i))return;let a=n.extension.name;var o;Sx(i)||_x(300,a,r||`[unknown]`),Sx(o=i)||_x(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=wx(i),n.state=i,e.push(n)};for(let e of this.extensionNameMap.values())Sx(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&&_x(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 Ib(...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 gx(o)){if(typeof e!=`function`){let t=n.get(e.replace);t&&_x(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&&xx(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||=Mx,e}};function Ix(e,t){let n=Fx.maybeFromEditor(e);if(!n)return;let r=n.extensionNameMap.get(t);return r?r.getExtensionDependency():void 0}var Lx=class extends Dg{$config(){return this.config(`horizontalrule`,{importDOM:{hr:()=>({conversion:Rx,priority:0})}})}exportDOM(){return{element:wv().createElement(`hr`)}}createDOM(e){let t=wv().createElement(`hr`);return Fb(t,e.theme.hr),t}getTextContent(){return`
|
|
146
|
+
`}isInline(){return!1}updateDOM(){return!1}};function Rx(){return{node:zx()}}function zx(){return ly(Lx)}Date.now;function Bx(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 Vx;function Hx(e,t){let{key:n}=t;return e&&n in e?e[n]:t.defaultValue}function Ux(e){return Vx&&Vx.editor===e?Vx:void 0}function Wx(e,t){if(`cfg`in t){let{cfg:n,updater:r}=t;return[n,r(Hx(e,n))]}return t}function Gx(e,t){let n=t;for(let r of e){let[e,i]=Wx(n,r),a=e.key;if(n===t&&Hx(n,e)===i)continue;let o=n===t||n===void 0?Kx(t):n;o[a]=i,n=o}return n}function Kx(e){return Object.create(e||null)}function qx(e,t){return[e,t]}function Jx(e,t,n,r=Vv()){let i=Vx,a=Ux(r);try{return Vx={...a,editor:r,[e]:t},n()}finally{Vx=i}}function Yx(e,t=()=>{}){return(n,r=Vv())=>i=>{let a=Ux(r),o=a&&a[e],s=Gx(n,o||t(r));return s&&s!==o?Jx(e,s,i,r):i()}}function Xx(e,t,n,r){return Object.assign(Gd(Symbol(t),{isEqual:r,parse:n}),{[e]:!0})}let Zx=`@lexical/html/DOM`,Qx=Symbol.for(`@lexical/html/DOMExportContext`);function $x(e,t,n){return Xx(Qx,e,t,n)}let eS=/* @__PURE__ */ $x(`isExport`,Boolean);function tS(e){let t=Ix(e,Zx);return t?t.output.defaults:void 0}function nS(e){let t=Ix(e,Zx);return t?t.output.runtime:void 0}function rS(e=Vv()){let t=nS(e);return t?t.getSessionConfig():Hv(e)}let iS=Yx(Qx,tS),aS=Symbol.for(`@lexical/html/SelectorImpl`);function oS(e,t){let n={kind:`element`,predicate:(r=t,r.length===0?J:r.length===1?r[0]:(e,t)=>{for(let n of r)if(!n(e,t))return!1;return!0}),tags:e};var r;let i=n=>oS(e,[...t,n]);return{[aS]:n,attr:(e,t,n)=>i(lS(e,t,n)),classAll:(...e)=>i(cS(e)),classAny:(...e)=>i(function(e){let t=sS(e);return t.length===0?()=>!1:e=>{if(!J(e))return!1;let n=e.classList;for(let e of t)if(n.contains(e))return!0;return!1}}(e)),styleAny:(e,t,n)=>i(function(e,t,n){if(typeof t==`string`)return n=>J(n)&&n.style.getPropertyValue(e)===t;if(t instanceof RegExp){let r=n&&n.capture,i=t;return(t,n)=>{if(!J(t))return!1;let a=t.style.getPropertyValue(e);if(!a)return!1;let o=a.match(i);return o!==null&&(r!==void 0&&(n[r]=o),!0)}}Bx(362,JSON.stringify(e))}(e,t,n))}}function sS(e){let t=[];for(let n of e)n&&t.push(n);return t}function cS(e){let t=sS(e);return t.length===0?()=>!0:e=>{if(!J(e))return!1;let n=e.classList;for(let e of t)if(!n.contains(e))return!1;return!0}}function lS(e,t,n){if(!0===t)return t=>J(t)&&t.hasAttribute(e);if(typeof t==`string`)return n=>J(n)&&n.getAttribute(e)===t;if(t instanceof RegExp){let r=n&&n.capture,i=t;return(t,n)=>{if(!J(t))return!1;let a=t.getAttribute(e);if(a==null)return!1;let o=a.match(i);return o!==null&&(r!==void 0&&(n[r]=o),!0)}}Bx(361,JSON.stringify(e))}let uS={kind:`text`,predicate:h_,tags:/* @__PURE__ */ new Set},dS={[aS]:uS},fS={kind:`comment`,predicate:e=>e.nodeType===8,tags:/* @__PURE__ */ new Set},pS={[aS]:fS},mS={any:()=>oS(/* @__PURE__ */ new Set,[]),comment:()=>pS,tag(...e){e.length>0||Bx(363);let t=/* @__PURE__ */ new Set;for(let n of e)t.add(n.toUpperCase());return oS(t,[])},text:()=>dS},hS=mS;hS.tag(`b`,`strong`,`em`,`i`,`code`,`mark`,`s`,`sub`,`sup`,`u`,`span`),hS.text(),hS.tag(`script`,`style`),hS.tag(`br`),hS.tag(`p`),hS.tag(`hr`),hS.any(),Object.freeze([]),Object.freeze({}),mS.any(),mS.any,mS.comment,mS.tag,mS.text;function gS(e,t=null,n=Vv()){return iS([qx(eS,!0)],n)(()=>{let r=j_(),i=rS(n),a=V(t)?yy(t.anchor.getNode()):null,o=e.append.bind(e);for(let e of(W(a)?a:r).getChildren())vS(n,e,o,t,i);return e})}function _S(e,t=null){return(typeof document>`u`||typeof window>`u`&&global.window===void 0)&&Bx(338),cg(e),gS(wv().createElement(`div`),t,e).innerHTML}function vS(e,t,n,r=null,i=Hv(e)){let a=i.$shouldInclude(t,r,e),o=i.$shouldExclude(t,r,e),s=t;r!==null&&B(t)&&(s=Ub(r,t,`clone`));let{element:c,after:l,append:u,$getChildNodes:d}=i.$exportDOM(s,e);if(!c)return!1;let f=wv().createDocumentFragment(),p=d?d():W(s)?s.getChildren():[],m=a&&dh(r)&&W(t)?null:r,h=f.append.bind(f);for(let n of p){let o=vS(e,n,h,m,i);!a&&o&&i.$extractWithChild(t,n,r,`html`,e)&&(a=!0)}if(a&&!o){if((J(c)||Fv(c))&&(u?u(f):c.append(f)),n(c),l){let e=l.call(s,c);e&&(Fv(c)?c.replaceChildren(e):c.replaceWith(e))}}else n(f);return a}function yS(e,t,n=null){let r=Cv(n),i=n?xv(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=ev(n)}return!1}(a.offsetNode,n))return{node:a.offsetNode,offset:a.offset}}if(a){let i=n.getRootNode();if(yv(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 bS(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 xS(e,t=H()){return t??bS(166),V(t)&&t.isCollapsed()||t.getNodes().length===0?``:_S(e,t)}function SS(e,t){let n=e.getData(`text/plain`)||e.getData(`text/uri-list`);n!=null&&t.insertRawText(n)}let CS=`application/x-lexical-drag`;function wS(e,t){let n={editorKey:t.getKey()};e.setData(CS,JSON.stringify(n))}function TS(e,t,n){let r=e.dataTransfer;if(r===null)return!1;let i=function(e){let t=e.getData(CS);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=yS(e.clientX,e.clientY,t.getRootElement());if(n===null)return null;let r=O_(n.node);if(r===null)return null;if(B(r))return Xy(r,`next`,n.offset);if(W(r))return Eb(r,n.offset,`next`);let i=r.getParent();return i===null?null:Eb(i,r.getIndexWithinParent()+1,`next`)}(e,t);if(a===null)return!1;let o=kb(a);if(o===null)return!1;let s=i.editorKey===t.getKey(),c=H();if(s){if(!V(c)||c.isCollapsed())return!1;if(function(e,t){let{anchor:n,focus:r}=Tb(_b(t),`next`);return cb(n,e)<0&&cb(e,r)<0}(a,c))return e.preventDefault(),!0;c.removeText()}if(!o.origin.isAttached())return e.preventDefault(),!0;if(n(r,hb(ab(o)),t),!s){let e=t.getRootElement(),n=e?e.ownerDocument:null,r=n?function(e,t){for(let n of Sv(t)){let t=f_(n);if(u_(t)&&t.getKey()===e&&J(n))return n}return null}(i.editorKey,n):null;r!==null&&r.dispatchEvent(new InputEvent(`beforeinput`,{bubbles:!0,cancelable:!0,inputType:`deleteByDrag`}))}return e.preventDefault(),!0}function ES(e,t){return TS(e,t,(e,t)=>SS(e,t))}function DS(e,t){t.update(()=>{if(e!==null){let n=Xb(e,KeyboardEvent)?null:e.clipboardData,r=H();if(r!==null&&!r.isCollapsed()&&n!=null){e.preventDefault();let i=xS(t);i!==null&&n.setData(`text/html`,i),n.setData(`text/plain`,r.getTextContent())}}})}function OS(e){return Ib(e.registerCommand(sp,e=>{let t=H();return!!V(t)&&(t.deleteCharacter(e),!0)},0),e.registerCommand(pp,e=>{let t=H();return!!V(t)&&(t.deleteWord(e),!0)},0),e.registerCommand(mp,e=>{let t=H();return!!V(t)&&(t.deleteLine(e),!0)},0),e.registerCommand(up,e=>{let t=H();if(!V(t))return!1;if(typeof e==`string`)t.insertText(e);else{let n=e.dataTransfer;if(n!=null)SS(n,t);else{let n=e.data;n&&t.insertText(n)}}return!0},0),e.registerCommand(fp,()=>{let e=H();return!!V(e)&&(e.removeText(),!0)},0),e.registerCommand(cp,e=>{let t=H();return!!V(t)&&(t.insertLineBreak(e),!0)},0),e.registerCommand(lp,()=>{let e=H();return!!V(e)&&(e.insertLineBreak(),!0)},0),e.registerCommand(xp,e=>{let t=H();if(!V(t))return!1;let n=e,r=n.shiftKey;return!!Kb(t,!0)&&(n.preventDefault(),Yb(t,r,!0),!0)},0),e.registerCommand(yp,e=>{let t=H();if(!V(t))return!1;let n=e,r=n.shiftKey;return!!Kb(t,!1)&&(n.preventDefault(),Yb(t,r,!1),!0)},0),e.registerCommand(Dp,t=>!!V(H())&&(!ad||!id)&&(t.preventDefault(),e.dispatchCommand(sp,!0)),0),e.registerCommand(kp,t=>!!V(H())&&(t.preventDefault(),e.dispatchCommand(sp,!1)),0),e.registerCommand(Tp,t=>{if(!V(H()))return!1;if(t!==null){if((ad||sd||ud)&&id)return!1;t.preventDefault()}return e.dispatchCommand(cp,!1)},0),e.registerCommand(Lp,()=>{let e=H();return q_(V(e)&&yy(e.anchor.getNode())!==null?e:null),!0},0),e.registerCommand(Fp,t=>!!V(H())&&(DS(t,e),!0),0),e.registerCommand(Ip,t=>!!V(H())&&(function(e,t){DS(e,t),t.update(()=>{let e=H();V(e)&&e.removeText()},{tag:`cut`})}(t,e),!0),0),e.registerCommand(dp,t=>!!V(H())&&(function(e,t){e.preventDefault(),t.update(()=>{let t=H(),n=Xb(e,ClipboardEvent)?e.clipboardData:null;n!=null&&V(t)&&SS(n,t)},{tag:`paste`})}(t,e),!0),0),e.registerCommand(jp,t=>ES(t,e),0),e.registerCommand(Mp,t=>{let n=H();return!!V(n)&&(n.isCollapsed()||t.dataTransfer===null||wS(t.dataTransfer,e),!0)},0))}function kS(e,t,n,r,i){if(e===null||n.size===0&&r.size===0&&!i)return 0;let a=t._selection,o=e._selection;if(i)return 1;if(!(V(a)&&V(o)&&o.isCollapsed()&&a.isCollapsed()))return 0;let s=function(e,t,n){let r=e._nodeMap,i=[];for(let e of t){let t=r.get(e);t!==void 0&&i.push(t)}for(let[e,t]of n){if(!t)continue;let n=r.get(e);n===void 0||kg(n)||i.push(n)}return i}(t,n,r);if(s.length===0)return 0;if(s.length>1){let n=t._nodeMap,r=n.get(a.anchor.key),i=n.get(o.anchor.key);return r&&i&&!e._nodeMap.has(r.__key)&&B(r)&&r.__text.length===1&&a.anchor.offset===1?2:0}let c=s[0],l=e._nodeMap.get(c.__key);if(!B(l)||!B(c)||l.__mode!==c.__mode)return 0;let u=l.__text,d=c.__text;if(u===d)return 0;let f=a.anchor,p=o.anchor;if(f.key!==p.key||f.type!==`text`)return 0;let m=f.offset,h=p.offset,g=d.length-u.length;return g===1&&h===m-1?2:g===-1&&h===m+1?3:g===-1&&h===m?4:0}function AS(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:kS(c,l,d,f,e.isComposing()),g=(()=>{let n=u===null||u.editor===e,a=p.has(`history-push`);if(!a&&n&&p.has(`history-merge`))return 0;if(h===1)return 2;if(c===null)return 1;let o=l._selection;if(!(d.size>0||f.size>0))return o===null?2:0;let s=typeof t==`number`?t:t.peek();return!1===a&&h!==0&&h===i&&m<r+s&&n||d.size===1&&function(e,t,n){let r=t._nodeMap.get(e),i=n._nodeMap.get(e),a=t._selection,o=n._selection;return!(V(a)&&V(o)&&a.anchor.type===`element`&&a.focus.type===`element`&&o.anchor.type===`text`&&o.focus.type===`text`||!B(r)||!B(i)||r.__parent!==i.__parent)&&JSON.stringify(t.read(()=>r.exportJSON()))===JSON.stringify(n.read(()=>i.exportJSON()))}(Array.from(d)[0],c,l)?0:1})();return r=m,i=h,g}}function jS(e,t){e.undoStack=[],e.redoStack=[],e.current=null,t&&t(e)}function MS(e,t,n,r=Date.now,i,a=null){let o=AS(e,n,r),s=()=>{i&&i(t)};return s(),Ib(e.registerCommand(gp,()=>(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(Bp,!0)),i.length===0&&e.dispatchCommand(Vp,!1),t.current=o||null,n&&n(t),o&&o.editor.setEditorState(o.editorState,{tag:`historic`})}}(e,t,i),!0),0),e.registerCommand(_p,()=>(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(Vp,!0));let o=r.pop();r.length===0&&e.dispatchCommand(Bp,!1),t.current=o||null,n&&n(t),o&&o.editor.setEditorState(o.editorState,{tag:`historic`})}}(e,t,i),!0),0),e.registerCommand(Rp,()=>(jS(t,i),!1),0),e.registerCommand(zp,()=>(jS(t,i),e.dispatchCommand(Bp,!1),e.dispatchCommand(Vp,!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(Bp,!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(Vp,!0)}}else if(m===2)return;t.current={editor:e,editorState:n},s()}))}function NS(){return{current:null,redoStack:[],undoStack:[]}}Date.now;let PS=`application/x-codexhost-thread-reference`;function FS(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 IS(e){return`thread://${encodeURIComponent(e.threadId).replace(/[!'()*]/gu,e=>`%${e.charCodeAt(0).toString(16).toUpperCase()}`)}?hostId=${encodeURIComponent(e.hostId)}`}function LS(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 RS(e){let t=`[@${e.title.replace(/[\\`*{}[\]()#+.!_<>|~-]/gu,e=>`\\${e}`)}](${IS(e)})`;return{source:`codexhost-thread`,ref:t,label:e.title,appearance:`session`,clipboardText:t}}function zS(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:FS({id:n,blank:!1,title:i,projectionValues:{threadReference:{hostId:r,threadId:n}}})}catch{return}}function BS(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=BS(e[t]))&&(r&&(r+=` `),r+=n)}else for(n in e)e[n]&&(r&&(r+=` `),r+=n)}return r}function VS(){for(var e,t,n=0,r=``,i=arguments.length;n<i;n++)(e=arguments[n])&&(t=BS(e))&&(r&&(r+=` `),r+=t);return r}let HS=`@deepseek-ai/dsh-client-ui-conversation/ReferenceChip.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(HS)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-conversation`,e.dataset.pluginCss=HS,e.textContent=`.s8J5YG_chip{max-width:240px;color:var(--dsw-alias-state-business-primary);user-select:none;align-items:baseline;gap:3px;display:inline-flex}.s8J5YG_marker{flex:none;font-weight:500}.s8J5YG_icon{flex:none;align-self:center}.s8J5YG_label{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.s8J5YG_invalid{color:var(--dsw-alias-state-error-primary);opacity:.7;text-decoration:line-through}`,document.head.appendChild(e)}var US={chip:`s8J5YG_chip`,icon:`s8J5YG_icon`,invalid:`s8J5YG_invalid`,label:`s8J5YG_label`,marker:`s8J5YG_marker`};let WS=`@deepseek-ai/dsh-client-ui-conversation/composer-editor.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(WS)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-conversation`,e.dataset.pluginCss=WS,e.textContent=`._VTzna_reference{border-radius:var(--dsw-radius-sm);line-height:inherit;vertical-align:baseline;color:var(--dsw-alias-state-business-primary);-webkit-box-decoration-break:clone;box-decoration-break:clone;background:0 0;padding:0 4px}._VTzna_reference:hover{background:var(--dsw-alias-state-business-tertiary)}._VTzna_openable{cursor:pointer}._VTzna_textRef{max-width:100%;display:inline-block}`,document.head.appendChild(e)}var GS={openable:`_VTzna_openable`,reference:`_VTzna_reference`,textRef:`_VTzna_textRef`};function KS({label:e,reference:t,appearance:n,invalid:r}){return/* @__PURE__ */ (0,h.jsxs)(`span`,{className:VS(GS.reference,US.chip,n===`file`&&!r&&GS.openable,r&&US.invalid),title:e,children:[n===void 0?/* @__PURE__ */ (0,h.jsx)(`span`,{className:US.marker,"aria-hidden":!0,children:`@`}):/* @__PURE__ */ (0,h.jsx)(d.ReferenceIconRegular,{kind:n,reference:t,size:14,className:US.icon}),/* @__PURE__ */ (0,h.jsx)(`span`,{className:US.label,children:e})]})}var qS=class e extends Dg{__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)(KS,{label:this.__label,reference:this.__ref,appearance:this.__appearance,invalid:this.__invalid})}};function JS(e){return new qS(e)}function YS(e){return e instanceof qS}function XS(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 ZS(e,t,n,r){let i=e=>e instanceof n,a=e=>{let t=Zm(e.getTextContent());t.setFormat(e.getFormat()),e.replace(t)};return[e.registerNodeTransform(Hm,e=>{if(!e.isSimpleText())return;let n,o=e.getPreviousSibling(),s=e.getTextContent(),c=e;if(B(o)){let n=o.getTextContent(),r=t(n+s);if(i(o)){if(r===null||(e=>e.getLatest().__mode)(o)!==0)return void a(o);{let t=r.end-n.length;if(t>0){let r=n+s.slice(0,t);if(o.select(),o.setTextContent(r),t===s.length)e.remove();else{let n=s.slice(t);e.setTextContent(n)}return}}}else if(r===null||r.start<n.length)return}let l=0;for(;;){n=t(s);let e,u=n===null?``:s.slice(n.end);if(s=u,u===``){let e=c.getNextSibling();if(B(e)){u=c.getTextContent()+e.getTextContent();let n=t(u);if(n===null)return void(i(e)?a(e):e.markDirty());if(n.start!==0)return}}if(n===null)return;if(n.start===0&&B(o)&&o.isTextEntity()){l+=n.end;continue}n.start===0?[e,c]=c.splitText(n.end):[,e,c]=c.splitText(n.start+l,n.end+l),e===void 0&&XS(165,`nodeToReplace`);let d=r(e);if(d.setFormat(e.getFormat()),e.replace(d),c==null)return;l=0,o=d}}),e.registerNodeTransform(n,e=>{let n=e.getTextContent(),r=t(n);if(r===null||r.start!==0)return void a(e);if(n.length>r.end)return void e.splitText(r.end);let o=e.getPreviousSibling();B(o)&&o.isTextEntity()&&(a(o),a(e));let s=e.getNextSibling();B(s)&&s.isTextEntity()&&(a(s),i(e)&&a(e))})]}let QS=/(^|\s)([/@])([\w-]+)/g,$S=/(^|\s)(@(?:"[^"\n]*"?|[^\s"]\S*))/g,eC=/* @__PURE__ */ new Set(`.,;:!?,。;:!?`),tC=/^@.*[/\\.]/u;function nC(e,t,n){if(!n.startsWith(`@"`)){let e=n.length;for(;eC.has(n.charAt(e-1));)--e;return tC.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(;eC.has(e.charAt(i));)i+=1;return i===e.length||/\s/u.test(e.charAt(i))?t+r+1:void 0}let rC=/^(?:\s|$)/;function iC(e,t){if(e===``)return[];let n=[];QS.lastIndex=0;let r;for(;(r=QS.exec(e))!==null;){let i=r[2],a=r[3]??``;if((i!==`/`||rC.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})}}$S.lastIndex=0;let i;for(;(i=$S.exec(e))!==null;){let t=i.index+(i[1]?.length??0),r=nC(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 aC=class e extends Hm{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=VS(t.className,GS.reference,GS.textRef,this.getTextContent().startsWith(`/`)&&GS.openable),t.setAttribute(`spellcheck`,`false`),t.setAttribute(`data-composer-text-ref`,``),t}isTextEntity(){return!0}canInsertTextBefore(){return!0}};function oC(e,t,n){return Ib(...ZS(e,e=>{let r=n();for(let n of iC(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},aC,e=>new aC(e.getTextContent())))}function sC(e){e.update(()=>{for(let e of j_().getAllTextNodes())(e instanceof aC||e.getPreviousSibling()instanceof aC||/[/@]/u.test(e.getTextContent()))&&e.markDirty()},{tag:Dm})}function cC(e,t){return e.registerCommand(np,e=>{if(e.target===null||e.button!==0||e.detail>1)return!1;let n=H();if(V(n)&&!n.isCollapsed())return!1;let r=O_(e.target);if(YS(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 aC&&t(void 0,{ref:r.getTextContent()})},1)}function lC(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 uC=Hl([O(),k(),A(),Pl()]);function dC(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 fC=Su(dC,{message:`JSON value must not contain circular references`}),pC=bu(()=>Hl([uC,j(pC),Xl(O(),pC)])),mC=fC.pipe(pC);fC.pipe(j(pC));let hC=fC.pipe(Xl(O(),pC)),gC=N({code:O().min(1),message:O().min(1),retryable:A(),diagnostic:O().min(1).optional(),stage:O().min(1).optional(),durationMs:k().int().nonnegative().optional(),stderrTail:O().min(1).optional()}).superRefine(lC([`diagnostic`,`stage`,`durationMs`,`stderrTail`])),_C=O().max(64).regex(/^[a-z]{2,3}(?:-[A-Za-z0-9]{2,8})*$/u),vC=e=>O().min(1).max(e).refine(e=>e.trim().length>0),yC=Xl(_C,M({label:vC(256).optional(),description:vC(1024).optional()}).strict()).refine(e=>Object.keys(e).length<=16,`Too many locales`),bC=Xl(_C,vC(4096)).refine(e=>typeof e.en==`string`,`English fallback is required`).refine(e=>Object.keys(e).length<=16,`Too many locales`),xC=O().refine(e=>e.trim().length>0,{message:`Identifier must not be empty or whitespace`}),SC=xC.brand(),CC=xC.brand(),wC=xC.brand();xC.brand(),xC.brand();let TC=O().refine(e=>e.trim().length>0,{message:`Value must not be empty or whitespace`}),EC=TC.max(128).regex(/^[A-Za-z0-9._~:-]+$/u,`Permission Mode ID must use transport-safe characters`).brand(),DC=M({modes:j(M({id:EC,label:TC.max(256),description:TC.max(1024).optional(),dangerous:A().optional(),localizations:yC.optional()}).strict()).min(1).max(32),defaultModeId:EC}).strict().superRefine((e,t)=>{let n=/* @__PURE__ */ new Set;for(let[r,i]of e.modes.entries())n.has(i.id)&&t.addIssue({code:`custom`,message:`Permission Mode IDs must be unique`,path:[`modes`,r,`id`]}),n.add(i.id);n.has(e.defaultModeId)||t.addIssue({code:`custom`,message:`Default Permission Mode must exist in the catalog`,path:[`defaultModeId`]})});M({threadId:CC,permissionModeId:EC}).strict();let OC=k().int().safe().nonnegative(),kC=k().finite().nonnegative(),AC=k().finite().min(0).max(100),jC=M({version:Hl([F(3),F(4)]).optional(),requestId:O().min(1),turnId:O().min(1).max(1024),outputTokens:OC,startedAtMs:OC,completedAtMs:OC}).strict().refine(e=>e.completedAtMs>e.startedAtMs),MC=M({version:Hl([F(2),F(3),F(4)]).optional(),value:kC,turnId:O().min(1).max(1024),at:OC}).strict();M({outputTimings:j(jC).transform(e=>e.filter(e=>e.version===4)).optional(),outputTokensPerSecond:MC.refine(e=>e.version===4).optional().catch(void 0),timeToFirstOutputMs:MC.extend({value:OC}).optional()}).strict();let NC=e=>bC.refine(t=>Object.values(t).every(t=>t.length<=e)),PC=M({composerIndicators:j(M({kind:F(`countdown`),id:O().min(1).max(64),expiresAtUnix:OC,label:NC(256).optional(),tooltip:NC(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:OC.optional(),cachedInputTokens:OC.optional(),cacheWriteInputTokens:OC.optional(),outputTokens:OC.optional(),outputTokensPerSecond:kC.optional(),sessionOutputTokensPerSecond:kC.optional(),apiOutputTokensPerSecond:kC.optional(),reasoningOutputTokens:OC.optional(),totalTokens:OC.optional(),totalCostUsd:kC.optional(),totalCredits:kC.optional(),contextUsagePercent:kC.optional(),cacheHitRatePercent:AC.optional(),contextWindowTokens:OC.optional(),contextUsedTokens:OC.optional(),planFiveHourUsedPercent:AC.optional(),planFiveHourResetsAtUnix:OC.optional(),planSevenDayUsedPercent:AC.optional(),planSevenDayResetsAtUnix:OC.optional(),sessionCacheHitRatePercent:AC.optional(),timeToFirstOutputMs:OC.optional(),latestRequestTimeToFirstOutputMs:OC.optional(),costSource:P([`publicPrice`,`native`]).optional(),unpricedModels:j(O().min(1)).min(1).optional()}).strict().superRefine((e,t)=>{Object.keys(e).length===0&&t.addIssue({code:`custom`,message:`Thread Usage must contain a reliable field`});let n=e.contextUsedTokens!==void 0;n!==(e.contextWindowTokens!==void 0)&&t.addIssue({code:`custom`,message:`Thread Usage context fields must be provided together`,path:[n?`contextWindowTokens`:`contextUsedTokens`]}),e.contextWindowTokens===0&&t.addIssue({code:`custom`,message:`Thread Usage contextWindowTokens must be greater than zero`,path:[`contextWindowTokens`]}),e.costSource!==void 0&&e.totalCostUsd===void 0&&t.addIssue({code:`custom`,message:`Thread Usage costSource must be provided with totalCostUsd`,path:[`costSource`]}),e.unpricedModels!==void 0&&e.costSource!==`publicPrice`&&t.addIssue({code:`custom`,message:`Thread Usage unpricedModels must be provided with a publicPrice cost`,path:[`unpricedModels`]}),e.planFiveHourResetsAtUnix!==void 0&&e.planFiveHourUsedPercent===void 0&&t.addIssue({code:`custom`,message:`Thread Usage planFiveHourResetsAtUnix must be provided with planFiveHourUsedPercent`,path:[`planFiveHourResetsAtUnix`]}),e.planSevenDayResetsAtUnix!==void 0&&e.planSevenDayUsedPercent===void 0&&t.addIssue({code:`custom`,message:`Thread Usage planSevenDayResetsAtUnix must be provided with planSevenDayUsedPercent`,path:[`planSevenDayResetsAtUnix`]})}),FC=k().finite().min(0).max(100),IC=P([`weekly`,`monthly`,`five_hour`,`seven_day`,`unknown`]),LC=M({id:O().min(1).max(256),label:O().min(1).max(256),localizations:yC.optional()}).strict(),RC=M({product:O().min(1),periodType:IC.optional(),scope:LC.optional(),localizations:yC.optional(),used:k().finite().nonnegative().optional(),limit:k().finite().nonnegative().optional(),unit:O().min(1).max(32).optional(),usagePercent:FC,resetsAt:O().min(1).optional()}).strict(),zC=M({availableCount:k().int().safe().positive(),nextExpiresAt:O().min(1).optional(),expiresAt:j(O().min(1)).min(1).max(32).optional()}).strict(),BC=M({used:k().finite().nonnegative().optional(),limit:k().finite().nonnegative().optional(),unit:O().min(1).max(32).optional(),label:O().min(1).optional(),scope:LC.optional(),localizations:yC.optional(),usedPercent:FC,resetsAt:O().min(1).optional(),periodType:IC,productUsage:j(RC).min(1).optional(),resetCredits:zC.optional()}).strict(),VC=M({amount:k().finite().nonnegative(),currency:O().trim().min(1).max(8),label:O().trim().min(1).max(128).optional()}).strict();M({threadId:CC,refresh:F(`exact`).optional()}).strict(),M({threadId:CC,usage:PC.nullable(),accountCredits:BC.optional(),accountBalance:VC.optional(),accountCreditsSupported:A().optional()}).strict();let HC=O().refine(e=>e.trim().length>0,{message:`Value must not be empty or whitespace`}),UC=O().min(1).max(512).refine(e=>!/\p{Cc}/u.test(e),`Model Ref must not contain control characters`).brand(),WC=P([`priority`,`ultrafast`]),GC=M({id:UC,serviceTier:WC.optional()}).strict();function KC(e,t){return e?.id===t?.id&&e?.serviceTier===t?.serviceTier}let qC=HC.max(128).regex(/^[A-Za-z0-9._~-]+$/u,`Thinking option ID must use transport-safe characters`).brand(),JC=HC.max(256),YC=M({id:qC,label:HC.max(256)}).strict(),XC=M({ref:GC,label:HC.max(256),resolvedModelLabel:JC.optional(),fastModel:GC.optional(),supportedThinkingOptionIds:j(qC).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 ZC(e,t){if(t)return e?.models.find(e=>KC(e.ref,t)||KC(e.fastModel,t))}let QC=j(YC).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)}),$C=M({models:j(XC),defaultModel:GC.optional(),thinkingOptions:QC,defaultThinkingOptionId:qC.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=>KC(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=>KC(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&&!ZC(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`]})}),ew=M({fork:A(),forkAcrossCwd:A(),rollbackLastTurn:A()}).strict().refine(e=>e.fork||!e.forkAcrossCwd,{path:[`forkAcrossCwd`],message:`Cross-cwd Fork requires exact history Fork support`}),tw=P([`live`,`atCreate`]),nw=M({configuration:M({selectModel:A(),selectThinkingOption:A(),selectPermissionMode:A(),permissionModeScope:tw.default(`live`)}).strict(),history:ew,subagents:M({observe:A(),readTranscript:A()}).strict().optional(),autonomousTurns:M({observe:A()}).strict().optional(),steer:A().optional(),persistentPlan:A().optional()}).strict();M({effectiveModel:GC.optional(),resolvedModelLabel:JC.optional(),effectiveThinkingOptionId:qC.optional(),availableThinkingOptions:QC.optional(),effectivePermissionModeId:EC.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 rw=M({open:F(!0)}).strict();Hl([M({status:F(`ready`),catalog:$C,permissionModes:DC.optional(),capabilities:nw,webUi:rw.optional()}).strict().superRefine((e,t)=>{let n=e.capabilities.configuration.selectPermissionMode;n!==!!e.permissionModes&&t.addIssue({code:`custom`,message:`Permission Mode catalog and capability must agree`,path:n?[`permissionModes`]:[`capabilities`,`configuration`,`selectPermissionMode`]})}),M({status:P([`notInstalled`,`unavailable`,`error`]),error:gC}).strict()]),M({harnessId:SC,cwd:HC.max(16384).optional(),refresh:A().optional(),purpose:F(`availability`).optional(),credentialAccess:P([`allow`,`retry`]).optional()}).strict(),M({harnessId:SC}).strict(),M({}).strict(),M({threadId:CC,model:GC}).strict(),M({threadId:CC,thinkingOptionId:qC}).strict(),M({threadId:CC,includeReferenceCapability:A().optional()}).strict(),Wl(`owner`,[M({owner:F(`codex`),locked:A(),effectiveModel:GC.optional(),resolvedModelLabel:JC.optional(),effectiveThinkingOptionId:qC.optional(),effectivePermissionModeId:EC.optional(),history:ew.optional(),supportsThreadReferences:F(!0).optional()}).strict(),M({owner:F(`external`),harnessId:HC.max(256),transportModelId:HC.max(8192),effectiveModel:GC.optional(),resolvedModelLabel:JC.optional(),effectiveThinkingOptionId:qC.optional(),availableThinkingOptions:QC.optional(),effectivePermissionModeId:EC.optional(),catalog:$C.optional(),history:ew,usage:PC.optional(),locked:F(!0)}).strict()]),M({threadIds:j(CC).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 iw=Wl(`owner`,[M({threadId:CC,owner:F(`codex`)}).strict(),M({threadId:CC,owner:F(`external`),harnessId:O().max(256).pipe(SC)}).strict()]);M({threads:j(iw).min(1).max(100)}).strict().superRefine(({threads:e},t)=>{let n=/* @__PURE__ */ new Set;for(let[r,i]of e.entries())n.has(i.threadId)&&t.addIssue({code:`custom`,message:`Thread ownership-list results must be unique`,path:[`threads`,r,`threadId`]}),n.add(i.threadId)}),M({threadId:CC,text:O().optional()}).strict(),M({kind:F(`application`),value:O().transform((e,t)=>{try{return JSON.parse(e)}catch{return t.addIssue({code:`custom`,message:`Invalid steering context JSON`}),Ln}}).pipe(M({expectedTurnId:wC,clientUserMessageId:O().min(1),delivery:P([`newTurn`,`activeTurn`])}).strict())}).strict().transform(e=>e.value),P([`activeTurn`,`newTurn`]),M({delivery:P([`official`,`activeTurn`,`newTurn`])}).strict();let aw=O().min(1).max(128).regex(/^[a-z][a-z0-9]*(?:[._-][a-z0-9]+)*$/u),ow=aw.pipe(SC),sw=ow.refine(e=>e!==`codex`,`The official Codex identity is reserved`),cw=O().min(1).max(512).refine(e=>!/[\\\u0000:#?]/u.test(e)&&!e.startsWith(`/`)&&!e.split(`/`).some(e=>e===`..`||e===``),`Plugin resources must be relative paths inside the plugin`),lw=pl().refine(e=>/^https:\/\/[^/?#@]+(?:[/?#]|$)/iu.test(e),`Plugin documentation links must be credential-free HTTPS URLs`),uw=M({en:O().max(4096),"zh-CN":O().max(4096).optional()}).strict(),dw=M({commands:j(M({terminal:O().max(256),command:O().max(4096)}).strict()).max(8),before:uw.optional(),after:uw.optional(),downloads:j(M({label:O().max(128),url:lw}).strict()).max(8).optional()}).strict(),fw={id:ow,name:O().trim().min(1).max(128),version:O().min(1).max(128),kind:F(`usage`).optional(),iconStyle:M({vector:M({viewBox:O().max(128).regex(/^-?\d+(?:\.\d+)?(?: +-?\d+(?:\.\d+)?){3}$/u),color:O().regex(/^(?:currentColor|#[a-f0-9]{6})$/iu),paths:j(M({d:O().min(1).max(32768).regex(/^[MmLlHhVvCcSsQqTtAaZz\d.,+eE\s-]+$/u),fillRule:P([`evenodd`,`nonzero`]).optional(),fill:O().regex(/^(?:currentColor|#[a-f0-9]{6})$/iu).optional()}).strict()).min(1).max(32)}).strict().optional(),background:O().regex(/^#[a-f0-9]{6}$/iu).optional(),borderRadius:k().min(0).max(50).optional(),paddingRatio:k().min(0).max(.25).optional()}).strict().optional(),installation:dw.optional(),notice:uw.optional(),launchCommand:F(!0).optional(),links:M({website:lw.optional(),documentation:lw.optional(),installation:lw.optional()}).strict().optional()};M({manifestVersion:F(1),...fw,adapterApiVersion:k().int().positive(),entry:cw,icon:cw.optional()}).strict();let pw=O().max(174828).regex(/^data:image\/(?:png|jpeg|webp|svg\+xml);base64,[A-Za-z0-9+/]+={0,2}$/u),mw=M({...fw,icon:pw.optional()}).strict();M({}).strict(),M({plugins:j(mw.extend({id:sw})).max(128)}).strict(),M({version:F(1),enabled:j(ow).max(128)}).strict().refine(e=>new Set(e.enabled).size===e.enabled.length,{message:`Enabled plugin IDs must be unique`,path:[`enabled`]});let hw=aw,gw=P([`sidebar.thread-layout`,`sidebar.thread-badge`,`appearance.theme`]),_w=P([`appearance`,`interface`,`workflow`,`analytics`,`integrations`,`tools`]),vw=O().trim().min(1).max(128);function yw(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 bw=e=>e.split(`/`).every(e=>!/[. ]$/u.test(e)),xw=cw.refine(e=>yw(e)!==void 0&&bw(e),`Images must be relative .png, .jpg, .jpeg, or .webp paths with no segments ending in a dot or space`),Sw=O().trim().max(2048).regex(/^https?:\/\/[^/?#\\\s]+/iu,`Expected an HTTP(S) URL`).pipe(pl({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 Cw(e){return N({en:e,"zh-CN":e})}let ww=Cw(O().trim().min(1)),Tw=j(_w).max(_w.options.length).refine(e=>new Set(e).size===e.length,`Duplicate categories`),Ew=j(gw).max(gw.options.length).refine(e=>new Set(e).size===e.length,`Duplicate slots`),Dw={key:O().regex(/^[A-Za-z_][A-Za-z0-9_]*$/u),label:ww,description:ww.optional()},Ow={...Dw,step:k().positive().optional(),default:k().optional()},kw=N({value:O(),label:ww}),Aw=Wl(`type`,[N({...Dw,type:F(`boolean`),default:A().optional()}),N({...Dw,type:F(`string`),placeholder:ww.optional(),default:O().optional()}),N({...Ow,type:F(`number`),min:k().optional(),max:k().optional()}),N({...Ow,type:F(`range`),min:k(),max:k()}),N({...Dw,type:F(`select`),options:j(kw).min(1),default:O().optional()})]).superRefine((e,t)=>{let n=(e,n)=>t.addIssue({code:`custom`,path:[e],message:n});if(e.type===`number`||e.type===`range`){let{min:t=-1/0,max:r=1/0,default:i}=e;t>r&&n(`max`,`Must be at least min`),i!==void 0&&(i<t||i>r)&&n(`default`,`Must be within min and max`)}else if(e.type===`select`){let t=new Set(e.options.map(({value:e})=>e));t.size!==e.options.length&&n(`options`,`Duplicate option values`),e.default!==void 0&&!t.has(e.default)&&n(`default`,`Must match an option value`)}}),jw=M({manifestVersion:jl().positive(),id:hw,name:Hl([vw,Cw(vw)]),version:O().min(1).max(128),desktopApi:jl().positive()}).passthrough().extend({manifestVersion:F(1),desktopApi:F(1),description:N({en:O().max(4096),"zh-CN":O().max(4096).optional()}).optional(),author:O().trim().min(1).max(128).optional(),repository:Sw.optional(),details:N({en:O().max(16384),"zh-CN":O().max(16384).optional()}).optional(),icon:xw.optional(),screenshots:j(xw).max(4).refine(e=>new Set(e).size===e.length,`Duplicate screenshots`).optional(),desktop:N({script:cw,style:cw.optional()}).optional(),backend:N({script:cw.refine(bw)}).optional(),slots:Ew.default(()=>[]),settingsSchema:j(Aw).max(32).refine(e=>new Set(e.map(({key:e})=>e)).size===e.length,`Duplicate setting keys`).optional(),categories:Tw.optional()}).strict().refine(e=>e.desktop!==void 0||e.backend!==void 0,`Expected at least one desktop or backend entry`),Mw=O().regex(/^[a-f0-9]{64}$/u),Nw=N({state:P([`running`,`disabled`,`invalid`,`incompatible`,`conflict`,`failed`,`waiting`]),hash:Mw.optional(),error:O().optional(),conflictWith:hw.optional()});N({controllerPid:jl().positive(),targetId:O().nullable(),updatedAt:Tu(),handledReloadToken:dl().optional(),extensions:Xl(O(),Nw),surfaces:Xl(O(),Nw).optional()});let Pw=P([`official`,`community`]);function Fw(e){return e.origin===`https://api.github.com`&&/^\/repos\/[\w-]+\/[\w.-]+\/zipball(?:\/[^/]+)?\/?$/u.test(e.pathname)}let Iw=Sw.refine(e=>{let t=new URL(e);return/\.zip$/iu.test(t.pathname)||Fw(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`),Lw=N({id:hw,version:O().trim().min(1).max(128),name:ww.extend({en:vw,"zh-CN":vw}),description:Cw(O().trim().min(1).max(4096)),details:Cw(O().trim().min(1).max(16384)).optional(),author:O().trim().min(1).max(128),repository:Sw,stars:k().int().min(0).optional(),downloads:k().int().min(0).optional(),categories:Tw.optional(),trustTier:Pw.default(`community`),icon:Sw.optional(),screenshots:j(Sw).max(4).optional(),downloadUrl:Iw,sha256:Mw,slots:Ew.optional(),publishedAt:O().optional(),updatedAt:O().optional(),minCodexHostVersion:O().optional()});N({schemaVersion:F(1),generatedAt:O(),extensions:j(Lw).refine(e=>new Set(e.map(({id:e})=>e)).size===e.length,`Duplicate extension IDs`)});let Rw=O().trim().min(1).max(128),zw=/^(?:con|prn|aux|nul|com[1-9¹²³]|lpt[1-9¹²³]) *(?:\.|$)/iu,Bw=hw.refine(e=>!zw.test(e),`Reserved extension ID`),Vw=P([`desktop`,`web`]),Hw=Mw,Uw=dl(),Ww=cw.refine(e=>!/[\x00-\x1f\x7f<>"|*]/u.test(e)&&e.split(`/`).every(e=>!/[. ]$/u.test(e)&&!zw.test(e)),`Expected a portable relative resource path`).refine(e=>e.split(`/`).length<=32,`Extension resources may be at most 32 segments deep`),Gw=jw.shape,Kw=(e,t=0)=>N({en:O().trim().min(t).max(e),"zh-CN":O().trim().min(t).max(e)}),qw=e=>Ww.refine(t=>t.endsWith(e),`Expected a ${e} file`),Jw=qw(`.mjs`),Yw=qw(`.css`).optional(),Xw=e=>e.normalize(`NFC`).toLowerCase(),Zw=N({manifestVersion:F(2),id:Bw,name:Kw(128,1),version:O().trim().min(1).max(128),description:Kw(4096),details:Kw(16384).optional(),author:Gw.author,repository:Gw.repository,icon:Gw.icon.refine(e=>e===void 0||Ww.safeParse(e).success),screenshots:Gw.screenshots.refine(e=>e===void 0||e.every(e=>Ww.safeParse(e).success)),categories:Gw.categories,settingsSchema:Gw.settingsSchema,slots:Gw.slots.removeDefault().optional(),page:N({apiVersion:F(1),entry:Jw,style:Yw,title:Kw(128,1).optional()}).optional(),widget:N({apiVersion:F(1),entry:Jw,style:Yw}).optional(),desktop:N({apiVersion:F(1),script:qw(`.js`),style:Yw}).optional(),web:N({apiVersion:F(1),entry:Jw.optional(),style:Yw}).refine(({entry:e,style:t})=>e!==void 0||t!==void 0,`Expected a Web entry or style`).optional(),backend:N({apiVersion:F(1),entry:Jw}).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||Xw(e)!==Xw(r.entry)),{path:[`backend`,`entry`],message:`A backend entry cannot also be a frontend entry`});function Qw({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 $w=Rw,eT=jl().nonnegative(),tT=N({revision:eT,enabled:j(Bw).max(64).refine(e=>new Set(e).size===e.length,`Duplicate extension IDs`)}),{downloadUrl:nT,...rT}=Lw.shape,iT=M({...rT,id:Bw,format:F(`codexhost`),targets:j(Vw).min(1).max(2).refine(e=>new Set(e).size===e.length,`Duplicate targets`),apis:N({page:jl().positive().optional(),widget:jl().positive().optional(),desktop:jl().positive().optional(),web:jl().positive().optional(),backend:jl().positive().optional()}),downloadUrl:nT.refine(e=>e.startsWith(`https://`),`Expected HTTPS`)}).refine(({targets:e,apis:t})=>{let n=Qw({hasPage:!!t.page,hasWidget:!!t.widget,hasDesktop:!!t.desktop,hasWeb:!!t.web,hasBackend:!!t.backend});return e.length===n.length&&n.every(t=>e.includes(t))},`Catalog targets must match the declared APIs`);M({schemaVersion:F(2),generatedAt:O().min(1),extensions:j(iT).max(1e4).refine(e=>new Set(e.map(({id:e})=>e)).size===e.length,`Duplicate extension IDs`)}).extend({catalogUrl:Sw,fetchedAt:Tu(),cached:A()});let aT={id:Bw},oT={...aT,activationId:Uw,digest:Hw},sT={...aT,activationId:oT.activationId.optional()},cT=O().min(1).max(4096).refine(e=>/^(?:\/|[a-z]:[/\\])/iu.test(e)&&!e.includes(`\0`)&&!e.split(/[/\\]/u).some(e=>e===`.`||e===`..`),`Expected an absolute local path without dot segments`),lT=O().min(1).max(256).refine(e=>e.split(`/`).every(e=>e&&/^[a-z0-9_.-]+$/iu.test(e)&&e!==`.`&&e!==`..`),`Invalid GitHub ref`);function uT(e){return O().max(4*Math.ceil(e/3)).refine(t=>{let n=t.endsWith(`==`)?2:+!!t.endsWith(`=`);return t.length%4==0&&t.length*3/4-n<=e&&/^[A-Za-z0-9+/]*={0,2}$/u.test(t)},`Expected bounded standard padded base64`)}let dT=N({type:F(`github`),repository:O().max(150).regex(/^[a-z0-9-]+\/[a-z0-9_-][a-z0-9_.-]*$/iu),ref:lT.optional(),tag:lT.optional(),asset:O().max(255).regex(/^[a-z0-9_.-]+\.zip$/iu).optional(),subpath:Ww.optional()}).refine(({ref:e,tag:t,asset:n})=>!e||!t&&!n,`Use either a zipball ref or a release tag/asset`),fT=Hl([N({type:F(`catalog`),...aT}),dT,N({type:F(`zip`),base64:uT(67108864).min(4)}),N({type:F(`zip`),localZipPath:cT}),N({type:F(`localDir`),localDir:cT})]),pT=Wl(`type`,[N({type:F(`catalog`),...aT}),dT,N({type:F(`zip`)}),N({type:F(`localDir`)})]),mT=N({...oT,manifest:Zw,installedAt:Tu(),source:pT.optional()}),hT=e=>O().max(23+4*Math.ceil(e/3)).regex(/^data:image\/(?:png|jpeg|webp);base64,[A-Za-z0-9+/]+={0,2}$/u),gT={desktopConflictWith:Bw.optional()},_T=P([`none`,`inactive`,`starting`,`running`,`failed`]),vT=Wl(`state`,[mT.extend({state:F(`valid`),enabled:A(),...gT,iconDataUrl:hT(131072).optional(),screenshotDataUrls:j(hT(524288)).max(4).optional(),backendState:_T.optional(),backendError:O().optional()}),N({state:P([`invalid`,`incompatible`]),id:O().min(1),enabled:A(),error:O()})]);N({revision:eT,configuration:tT,diagnostics:j(O()),extensions:j(vT)}),N({revision:eT,extensions:j(mT.extend({...gT,settingsRevision:eT})).max(64)});let yT={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`},bT=Object.freeze(Object.values(yT));new Set(bT),N({});let xT={expectedRevision:eT};N({...aT,...xT}),mT.extend({replaced:A()}),Wl(`state`,[N({state:F(`saved`),configuration:tT}),N({state:F(`revision-conflict`),revision:eT})]),N({...sT,digest:oT.digest.optional(),path:Ww}),N({mimeType:O().min(1),base64:uT(16777216),digest:oT.digest}),N({settingsRevision:eT,values:hC}),yT.list,yT.snapshot,yT.catalog,N({forceRefresh:A().optional()}),yT.install,N({source:fT}),yT.update,N({...aT,expectedDigest:oT.digest,expectedActivationId:oT.activationId.optional(),source:fT.optional()}),yT.enable,yT.disable,yT.uninstall,N({...aT,removeData:A().optional(),expectedDigest:oT.digest.optional()}),N({...aT,removed:A()}),yT.recover,N({expectedRevision:xT.expectedRevision.optional()}),yT.asset,yT.settingsGet,N(sT),yT.settingsSet,N({...sT,expectedSettingsRevision:eT,values:hC}),yT.backendInvoke,N({...sT,method:$w,params:mC.optional()}),N({result:mC}),M({threadId:CC}).strict(),M({confirmed:A()}).strict(),[...bT],M({sections:j(M({id:O().min(1),name:O().min(1),threads:j(hC)}).strict())}).strict(),M({threadId:O().min(1).max(1024),sectionId:O().min(1).max(1024).nullable()}).strict(),M({threadIds:j(O().min(1))}).strict(),M({threadId:O().min(1).max(1024),pinned:A()}).strict(),M({}).strict(),M({parents:Xl(O().min(1),O().min(1))}).strict(),M({prompt:O().max(16384).optional()}).strict(),M({projects:j(M({id:O(),name:O(),rootPaths:j(O())})),assignments:Xl(O(),O()),projectless:j(O()),pinned:j(O()),sectionProjects:Xl(O(),j(O())).optional()});let ST=Xl(O(),Il()),CT=M({epoch:O().uuid(),sequence:k().int().nonnegative()});Wl(`type`,[M({type:F(`skills-changed`),cursor:CT,cwd:O().optional()}),M({type:F(`harness-inspection-changed`),cursor:CT,harnessId:O().min(1)}),M({type:F(`display-settings-changed`),cursor:CT}),M({type:F(`preferences-changed`),cursor:CT,revision:k().int().nonnegative()}),M({type:F(`extensions-changed`),cursor:CT,revision:eT}),M({type:F(`hello`),version:F(1),cursor:CT,reset:A()}),M({type:F(`changed`),cursor:CT,threadId:O().min(1),method:O().min(1)})]);let wT=Wl(`type`,[M({type:F(`text`),id:O(),prompt:O(),secret:A().optional(),optional:A().optional()}),M({type:F(`choice`),id:O(),prompt:O(),multiple:A(),allowOther:A(),optional:A().optional(),options:j(M({value:O(),label:O(),description:O().optional()}))})]),TT=Wl(`type`,[M({type:F(`approval`),title:O(),description:O().optional(),subject:Il().optional(),actions:j(M({id:O(),label:O(),effect:O()}))}),M({type:F(`question`),title:O().optional(),questions:j(wT)})]),ET=M({requestId:Hl([O(),k().int()]),threadId:O(),kind:P([`approval`,`question`]),interaction:TT,request:ST}),DT=M({id:O().min(1),clientUserMessageId:O().min(1),input:j(ST),presentationInput:j(ST).nullable().optional()}).passthrough();M({fields:j(M({path:j(Hl([O(),k().int().nonnegative()])),originalLength:k().int().nonnegative()}))});let OT=M({id:O().min(1),status:O().min(1),codexhostTurnOutcome:M({status:F(`unknown`),reason:O()}).optional(),items:j(M({id:O().min(1),type:O().min(1)}).passthrough()),codexhostFileOperations:j(M({beforeItemId:O().nullable(),item:M({id:O().min(1),type:O().min(1)}).passthrough()})).optional(),error:M({message:O().optional()}).passthrough().nullable().optional(),fingerprint:O().min(1).optional(),unchanged:F(!0).optional()}).passthrough(),kT=M({id:O().min(1).max(512),fingerprint:O().min(1).max(128)});M({threadId:O().min(1),knownTurns:j(kT).max(64).optional(),truncateToolOutput:A().optional()});let AT=M({harnessId:O().min(1),nativeSessionId:O().min(1)});M({cursor:CT,activeTurnId:O().min(1).nullable().optional(),command:M({name:O().min(1),turn:OT,subsequentTurnId:O().min(1).optional()}).optional(),thread:M({id:O().min(1),cwd:O(),modelProvider:O().min(1),createdAt:k(),updatedAt:k(),status:M({type:O()}).passthrough(),name:O().nullable().optional(),preview:O().optional(),codexhostImportSource:AT.optional(),turns:j(OT).length(0)}).passthrough(),turnsPage:M({data:j(OT).max(5),nextCursor:O().nullable()}),configuration:M({native:M({model:O().min(1).max(1024).optional(),reasoningEffort:O().min(1).max(128).optional()}).optional(),effectiveModel:GC.optional(),effectiveThinkingOptionId:qC.optional(),effectivePermissionModeId:EC.optional()}),queue:M({items:j(DT),pausedReason:P([`interrupted`,`outcome-unknown`,`failed`]).nullable()}).optional(),interactions:j(ET)}),M({version:F(1),owner:F(`service`).optional(),pid:k().int().positive(),port:k().int().min(1).max(65535),token:O().regex(/^[0-9a-f]{64}$/u),startedAt:k(),epoch:O().uuid()}),M({epoch:O().uuid(),threadId:O().min(1),requestId:Hl([O(),k().int()]),result:ST}),M({includeArchived:A().optional(),officialCursor:M({live:O().nullable(),archived:O().nullable().optional()}).strict().optional(),scope:M({cwd:O().min(1).max(4096),excludeCwds:j(O().min(1).max(4096)).max(1024)}).strict().optional()}).strict(),M({threads:j(hC),ownership:j(iw),archivedThreadIds:j(CC),officialCursor:M({live:O().nullable(),archived:O().nullable().optional()}).strict().optional()}).strict();let jT=P([`running`,`waiting`,`idle`,`unknown`]),MT=N({harnessId:SC,title:O().optional(),status:jT,archived:A()}),NT=N({revision:jl().nonnegative(),parents:Xl(CC,CC),nodes:Xl(CC,MT),truncated:A()}).refine(e=>Object.keys(e.nodes).length<=5e3,`Too many Thread tree nodes`).refine(({parents:e,nodes:t})=>Object.entries(e).every(([e,n])=>Object.hasOwn(t,e)&&Object.hasOwn(t,n)),`Missing Thread tree node`),PT=O().min(1).max(128);N({});let FT=N({subscriptionId:PT});N({}),FT.extend({snapshot:NT});let IT=O().regex(/^audio\/[a-z0-9.+-]+(?:\s*;[^\r\n]*)?$/i);M({available:A()}).strict(),M({path:O().min(1),mimeType:IT}).strict();let LT=P([`credentials-unavailable`,`login-expired`,`rate-limited`,`service-rejected`,`host-incompatible`,`network`,`timeout`,`audio-empty`,`audio-too-large`,`audio-format`,`audio-invalid`]);Wl(`ok`,[M({ok:F(!0),text:O()}).strict(),M({ok:F(!1),error:M({code:LT}).strict()}).strict()]),M({threadId:CC.optional(),cwd:O().min(1).optional()}).strict().refine(e=>!(e.threadId&&e.cwd),{message:`Specify threadId or cwd, not both`});let RT=M({name:O().min(1).regex(/^[^\s[\]]+$/u),description:O().optional(),path:O().min(1),scope:P([`project`,`global`]),source:O().min(1)}).strict();M({revision:k().int().nonnegative(),complete:A(),skills:j(RT),warnings:j(O()).optional()}).strict(),M({cwd:O().min(1).optional()}).strict();let zT=/\[\$([^\]\r\n]+)\]\((?:<([^<>\r\n]+)>|([^\s()]+))(?:[ \t]+(?:"[^"\r\n]*"|'[^'\r\n]*'))?\)/gu;function BT(e){return[...e.matchAll(zT)].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 VT=M({kind:P([`public`,`relay`,`tailscale-funnel`,`tailscale-https`,`tailscale`,`lan`,`virtual`]),url:O().min(1)}).strict(),HT=Wl(`status`,[M({status:F(`not-installed`)}),M({status:F(`not-running`)}),M({status:F(`not-logged-in`)}),M({status:F(`https-disabled`)}),M({status:F(`not-serving`),command:O()}),M({status:F(`occupied`),target:O()}),M({status:F(`serving`),url:O(),funnel:A()}),M({status:F(`error`),message:O()})]);M({state:HT,error:O().optional()}).strict();let UT=Wl(`status`,[M({status:F(`on`)}),M({status:F(`off`)}),M({status:F(`invalid`),reason:O()})]),WT=M({lan:A(),autostart:UT}).strict(),GT=M({expiresAt:O().optional(),issuing:A(),failure:M({detail:O().optional(),retryAt:O(),paused:A()}).optional()}),KT=Wl(`status`,[M({status:F(`off`),reason:P([`invite`,`name-taken`,`banned`]).optional()}),M({status:F(`connecting`),reason:P([`full`,`unreachable`]).optional()}),M({status:F(`connected`),url:O(),certificate:GT}),M({status:F(`missing-certificate`),url:O(),certificate:GT}),M({status:F(`stopped`),reason:P([`replaced`,`rejected`,`unsupported-version`])})]);O().max(253).regex(/^(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z](?:[a-z0-9-]{0,61}[a-z0-9])?$/i).transform(e=>e.toLowerCase()),O().regex(/^(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)?$/);let qT=P([`official`,`self-hosted`]);M({secret:O().min(1),lastUsedAt:k().nullable(),networkUrls:j(VT),directCandidates:j(VT).optional(),tailscale:HT,background:WT.optional(),relay:M({state:KT,enabled:A(),kind:qT,officialHost:O(),customHost:O().optional(),officialHostname:O().optional(),customHostname:O().optional(),quotaUntil:O().optional()}).strict().optional()}).strict();let JT=N({threadId:O().min(1).max(1024),view:P([`result`,`messages`]),from:k().int().min(1).max(2**53-1).optional(),to:k().int().min(1).max(2**53-1).optional()}),YT=M({id:O().min(1).max(256),harnessId:O().min(1),label:O().min(1).max(512),provider:P([`openai-codex`,`xai`])}).strict(),XT=O().regex(/^[a-z][a-z0-9-]{0,47}$/),ZT=M({name:XT,source:YT,importedAt:O()}).strict(),QT=Wl(`action`,[M({action:F(`list`)}).strict(),M({action:F(`import`),sourceId:O().min(1).max(256),name:XT,confirmed:F(!0)}).strict(),M({action:F(`reimport`),sourceId:O().min(1).max(256),name:XT,confirmed:F(!0)}).strict(),M({action:F(`remove`),name:XT,confirmed:F(!0)}).strict()]),$T=M({provider:O().min(1).max(128),type:P([`oauth`,`api_key`,`unknown`]),label:O().min(1).max(512).optional(),vendor:P([`openai-codex`,`xai`]).optional()}).strict();M({sources:j(YT),targets:j(M({harnessId:O(),providers:j(P([`openai-codex`,`xai`])),imports:j(ZT),others:j($T).default([])}).strict())}).strict(),M({targetHarnessId:O().min(1).max(128).optional(),request:QT}).strict(),M({events:A()});let eE=j(N({agent:O().min(1).max(128),section:P([`main`,`more`,`auto`])})).max(256).refine(e=>new Set(e.map(e=>e.agent)).size===e.length,`Duplicate Harness IDs`);N({entries:eE.nullable()}),N({}),N({entries:eE,initializeOnly:A().optional()});let tE=N({enabled:A(),timeoutMinutes:k().int().min(5).max(1440)});Object.freeze({enabled:!0,timeoutMinutes:10});let nE=O().regex(/^external$/u),rE=SC.transform(e=>String(e)),iE=N({model:GC.optional(),thinkingOptionId:qC.optional(),permissionModeId:EC.optional()}).refine(e=>!!(e.model||e.thinkingOptionId||e.permissionModeId),`A default configuration must contain a preference`),aE=N({lastHarness:SC.optional(),byHarness:Xl(rE,iE)}),oE=N({model:GC.optional(),thinkingOptionId:qC.optional()}).refine(e=>!!(e.model||e.thinkingOptionId),`A delegation default must contain a Model or Thinking option`),sE=N({byHarness:Xl(rE,oE)}),cE=O().min(1).max(1024),lE=N({idleRelease:tE.optional(),favorites:Xl(rE,j(cE).max(2048)).default({}),newThread:aE.optional(),delegation:sE.optional()});N({scope:nE,revision:k().int().nonnegative(),values:lE}),N({scope:nE.default(`external`)});let uE=Wl(`kind`,[N({kind:F(`idleRelease`),value:tE}),N({kind:F(`favorite`),harnessId:SC,modelId:cE,enabled:A()}),N({kind:F(`favorites`),harnessId:SC,modelIds:j(cE).max(2048)}),N({kind:F(`newThread`),lastHarness:SC.optional(),harnessId:SC.optional(),configuration:iE.optional()}),N({kind:F(`delegation`),harnessId:SC,configuration:oE.nullable()})]);N({scope:nE.default(`external`),operations:j(uE).min(1).max(256),initializeOnly:A().optional(),expectedRevision:k().int().nonnegative().optional()}).superRefine((e,t)=>{for(let n of e.operations)n.kind===`newThread`&&(!n.lastHarness&&!n.configuration||!!n.harnessId!=!!n.configuration)&&t.addIssue({code:`custom`,message:`A default Harness or complete configuration is required`})}),N({version:F(1),revision:k().int().nonnegative(),scopes:Xl(nE,lE)});let dE=k().finite().nonnegative(),fE=N({input:dE,output:dE,cacheRead:dE.optional(),cacheWrite:dE.optional(),cacheWrite1h:dE.optional()}),pE=O().max(512).refine(e=>e.trim()===e&&e.length>0,`Model ID is required`);N({path:O(),entries:j(N({key:O(),price:fE})),error:O().nullable()}),N({}),N({key:pE,price:fE.nullable(),previousKey:pE.optional()}),N({model:pE});let mE=N({official:A().optional(),canonicalModelId:O().min(1).optional(),provider:O().min(1).max(512),model:O().min(1).max(512),price:fE});N({price:fE.nullable(),suggestions:j(mE).max(6).optional()});let hE=[`today`,`7d`,`30d`,`90d`,`all`],gE=k().int().min(0).max(2**53-1),_E=O().regex(/^\d{4}-\d{2}-\d{2}$/u),vE=O().min(1).max(128),yE=O().min(1).max(512),bE=O().min(1).max(4096);N({range:P(hE),timeZone:O().min(1).max(128).refine(e=>{try{return new Intl.DateTimeFormat(`en`,{timeZone:e}),!0}catch{return!1}},`Unsupported usage statistics timezone`).optional(),harness:vE.optional(),model:yE.nullable().optional(),project:bE.nullable().optional(),date:_E.optional()});let xE=N({requests:gE,inputTokens:gE,cachedInputTokens:gE,cacheWriteInputTokens:gE,cacheKnownInputTokens:gE,cacheHitCachedInputTokens:gE,cacheHitInputTokens:gE,outputTokens:gE,reasoningOutputTokens:gE,costUsd:k().finite().min(0),unpricedRequests:gE,unmeteredRequests:gE}),SE=xE.shape,CE=N({harness:vE,sessionId:O().min(1).max(512),project:bE.nullable(),title:O().min(1).max(200).optional(),models:j(yE).max(16),firstAtMs:gE,lastAtMs:gE,...SE});N({range:P(hE),from:_E.nullable(),to:_E,filters:N({harness:vE.nullable(),model:yE.nullable(),unknownModel:A(),project:bE.nullable(),unknownProject:A(),date:_E.nullable()}),reading:N({complete:A(),sources:gE,read:gE}),failures:j(N({harness:vE,message:O().max(2048)})).max(256),options:N({harnesses:j(vE).max(256),models:j(yE.nullable()).max(4096),projects:j(bE.nullable()).max(4096)}),modelLabels:j(N({harness:vE,model:yE,label:yE})).max(4096).optional(),credits:j(N({harness:vE,model:yE.nullable(),credits:k().finite().min(0),reportedRequests:gE,requests:gE})).max(4096).optional(),totals:xE,daily:j(N({date:_E,harness:vE,...SE})).max(2e5),hourly:j(N({weekday:k().int().min(0).max(6),hour:k().int().min(0).max(23),...SE})).max(168),byHarness:j(N({harness:vE,...SE})).max(256),byModel:j(N({model:yE.nullable(),...SE,harnessPricedRequests:gE})).max(4096),byProject:j(N({project:bE.nullable(),...SE})).max(4096),sessions:j(CE).max(100),recentSessions:j(CE).max(100).optional()}),M({threadId:CC}),M({discarded:A()});let wE=Wl(`type`,[M({id:O().min(1),type:F(`choice`),prompt:O(),options:j(M({value:O().min(1),label:O(),description:O().optional()})).min(1),multiple:A(),allowOther:A(),optional:A()}),M({id:O().min(1),type:F(`text`),prompt:O(),multiline:A(),secret:F(!1),optional:A(),placeholder:O().optional(),prefill:O().optional()})]),TE=M({interactionId:O().min(1),turnId:O().min(1),title:O().optional(),questions:j(wE).min(1)}).refine(({questions:e})=>e.some(e=>e.type===`choice`&&e.multiple),{message:`Shared cards require at least one multi-select question`});N({threadId:O().min(1)}),M({questions:j(TE)}),N({threadId:O().min(1),turnId:O().min(1),interactionId:O().min(1),answers:Xl(O(),j(O())),cancelled:A().default(!1)}),M({accepted:F(!0)});let EE=M({path:O(),oldText:O().nullable(),newText:O()});M({sessionId:O().min(1),turn:k().int().nonnegative(),path:O().min(1).optional()}),M({diffs:j(EE)}),N({}),N({}),M({reference:M({sessionId:O().min(1),epoch:O().min(1),turn:k().int().nonnegative(),seq:k().int().nonnegative(),callId:O().min(1),part:k().int().nonnegative(),version:O().min(1)}),length:k().int().nonnegative(),bytes:k().int().nonnegative()}),N({title:O().trim().min(1).max(200),type:P([`info`,`warning`,`danger`]),body:O().trim().min(1).max(16384)}),N({}),N({url:O().max(2048).regex(/^http:\/\/(?:127\.0\.0\.1|localhost):\d{1,5}\/(?:\?.*)?$/u)}),Object.freeze(/* @__PURE__ */ `codexhost/console/remote-connections.codexhost/runtime/status.codexhost/remote/ssh-setup.codexhost/harness/plugins/list.codexhost/harness/display-settings/capabilities.codexhost/harness/display-settings/get.codexhost/harness/display-settings/set.codexhost/harness/inspect.codexhost/harness/installation.codexhost/harness/installation/start.codexhost/harness/installation/status.codexhost/harness/launch-settings/get.codexhost/harness/launch-settings/set.codexhost/harness/web-ui/open.codexhost/harness/accounts/sources.codexhost/harness/accounts/list.codexhost/harness/accounts/inspect.codexhost/harness/credential-imports.codexhost/harness/session-import/sources.codexhost/harness/session-import/list.codexhost/harness/session-import/import.codexhost/account/list.codexhost/account/refresh.codexhost/account/usage/inspect.codexhost/usage/model-prices/get.codexhost/usage/model-prices/set.codexhost/usage/model-prices/default.codexhost/usage/statistics/get.codexhost/update/check.codexhost/update/start.codexhost/update/status`.split(`.`));let DE=P([`idle`,`running`,`busy`,`closing`,`failed`,`blocked`]),OE=P([`none`,`disabled`,`timeout`,`operation`,`background`,`identity`,`persistence`,`closeFailed`]);N({threadId:O(),title:O(),harnessId:O(),state:DE,reason:OE,inactiveMs:k().nonnegative()}),N({threadId:CC,turnId:wC});let kE=M({email:O().trim().min(1).max(320).optional(),label:O().trim().min(1).max(256).optional(),plan:O().trim().min(1).max(128).optional(),credits:BC.optional(),balance:VC.optional()}).strict();function AE(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 jE=AE(kE),ME={harnessId:SC,harnessName:O().trim().min(1).max(128)},NE=M(ME).strict();M({}).strict(),M({sources:j(NE).max(128)}).strict(),M({harnessId:SC,refresh:A().optional()}).strict(),M({...ME,account:jE.nullable(),accounts:j(jE).max(8).optional()}).strict(),M({refresh:A().optional()}).strict(),M({accounts:j(AE(kE.extend(ME))).max(128)}).strict(),M({harnessId:sw,model:GC.optional(),thinkingOptionId:qC.optional(),permissionModeId:EC.optional(),prewarm:F(!0).optional()}).strict();let PE=O().trim().min(1).max(4096).refine(e=>!/[\u0000\r\n]/u.test(e),`Invalid entrypoint path`);M({harnessId:sw}).strict().extend({path:PE.nullable()}),M({path:PE.nullable(),restartRequired:A()}).strict(),M({harnessId:SC,action:P([`check`,`update`,`install`]),confirmedVersion:O().min(1).max(128).optional()}).strict().refine(({action:e,confirmedVersion:t})=>e===`update`||t===void 0);let FE=M({currentVersion:O().min(1).max(128),latestVersion:O().min(1).max(128),updateAvailable:A(),canUpdate:A(),latestVerifiedVersion:O().min(1).max(128).optional(),confirmationRequired:F(!0).optional(),versionKind:P([`cli`,`application`]).optional(),manualUpdateUrl:pl().max(2048).refine(e=>/^https:\/\/[^/?#@]+(?:[/?#]|$)/iu.test(e),`Manual updates require a credential-free HTTPS URL`).optional(),message:O().max(2048).optional(),messageCode:O().min(1).max(128).optional(),notice:bC.optional(),latestVersionKind:P([`unknown`,`tracking-branch`]).optional()}).strict();M({taskId:O().uuid()}).strict(),Wl(`status`,[M({taskId:O().uuid(),status:F(`running`)}).strict(),M({taskId:O().uuid(),status:F(`succeeded`),result:FE}).strict(),M({taskId:O().uuid(),status:F(`failed`),error:M({code:k().int(),message:O().min(1).max(2048)}).strict()}).strict()]);let IE=O().min(1).max(256).regex(/^[A-Za-z0-9._~-]+$/u),LE=O().trim().min(1),RE=P([`free`,`go`,`plus`,`pro`,`prolite`,`team`,`self_serve_business_prolite`,`self_serve_business_usage_based`,`business`,`ent26`,`enterprise_cbp_automation`,`enterprise_cbp_usage_based`,`enterprise`,`edu`,`edu_plus`,`edu_pro`,`unknown`]),zE=M({accountId:IE,label:LE.max(256),email:O().email().max(320).optional(),planType:RE.optional()}).strict(),BE=P([`ready`,`unavailable`]);M({version:F(2),currentAccountId:IE.nullable(),phase:BE,revision:k().int().nonnegative(),instanceId:LE.max(1024).optional(),accounts:j(zE).max(1)}).strict(),M({accountId:IE,refresh:A().optional()}).strict(),M({accountId:IE,usage:PC.nullable(),accountCredits:BC.optional(),freshness:P([`live`,`cached`]),observedAt:O().datetime().nullable()}).strict();let VE=1e3,HE=O().refine(e=>e.trim().length>0,`Value must not be empty or whitespace`).refine(e=>!e.includes(`\0`),`Value must not contain NUL`),UE=HE.max(1024),WE=M({nativeSessionId:UE,title:HE.max(4096).nullable(),updatedAt:k().int().nonnegative().max(864e13),cwd:HE.max(16384),running:A().nullable()}).strict();M({}).strict(),M({harnesses:j(M({harnessId:sw,name:HE.max(128)}).strict()).max(128)}).strict(),M({harnessId:sw,query:O().trim().max(4096).refine(e=>!e.includes(`\0`)).optional(),offset:k().int().nonnegative().safe().optional(),limit:k().int().min(1).max(VE).optional()}).strict(),M({candidates:j(WE).max(VE),total:k().int().nonnegative().safe()}).strict(),M({harnessId:sw,nativeSessionId:UE}).strict(),M({threadId:HE.max(1024).pipe(CC)}).strict();let GE=O().refine(e=>e.trim().length>0,`Value must not be empty or whitespace`).refine(e=>!e.includes(`\0`),`Value must not contain NUL`),KE=UE,qE=WE;M({}).strict(),M({candidates:j(qE).max(1e3)}).strict(),M({nativeSessionId:KE}).strict(),M({threadId:GE.max(1024).pipe(CC)}).strict(),M({threadId:CC,lastTurnId:wC}).strict(),M({threadId:CC}).strict();let JE=O().trim().min(1).max(128).regex(/^[A-Za-z0-9._:-]+$/u).brand();M({commands:j(M({id:JE,invocation:O().min(1).max(128),label:O().trim().min(1).max(128),description:O().trim().min(1).max(512).optional(),localizations:yC.optional(),argumentMode:P([`none`,`text`]),kind:P([`command`,`skill`]).optional()}).strict()),warnings:j(O().min(1)).optional(),source:P([`live`,`static`]).optional()}).strict().superRefine((e,t)=>{let n=/* @__PURE__ */ new Set;for(let[r,i]of e.commands.entries())n.has(i.id)&&t.addIssue({code:`custom`,message:`Harness command IDs must be unique`,path:[`commands`,r,`id`]}),n.add(i.id)}),M({harnessId:SC,cwd:O().min(1).optional()}).strict(),M({threadId:CC}).strict(),M({threadId:CC,commandId:JE,turnId:wC.optional(),arguments:hC.optional()}).strict(),M({accepted:F(!0),turnId:wC.optional()}).strict();let YE=F(`2.0`).optional(),XE=Rl().optional(),ZE=O().min(1),QE=Hl([O(),k().int()]),$E=M({code:k().int(),message:O(),data:mC.optional()}).catchall(mC).superRefine(lC([`data`]));Hl([M({jsonrpc:YE,id:QE,method:ZE,params:mC.optional(),result:XE,error:XE}).catchall(mC).superRefine(lC([`jsonrpc`,`params`,`result`,`error`])),M({jsonrpc:YE,id:XE,method:ZE,params:mC.optional(),result:XE,error:XE}).catchall(mC).superRefine(lC([`jsonrpc`,`id`,`params`,`result`,`error`])),M({jsonrpc:YE,id:QE,method:XE,params:XE,result:mC,error:XE}).catchall(mC).superRefine(lC([`jsonrpc`,`method`,`params`,`error`])),M({jsonrpc:YE,id:QE,method:XE,params:XE,result:XE,error:$E}).catchall(mC).superRefine(lC([`jsonrpc`,`method`,`params`,`result`]))]);let eD=O().refine(e=>e.trim().length>0,{message:`Native identifier must not be empty or whitespace`});N({harnessId:SC,nativeSessionId:eD,locator:mC.optional(),formatVersion:F(1)}).superRefine(lC([`locator`])),N({harnessId:SC,nativeSessionId:eD,nativeTurnKey:eD,formatVersion:F(1)}),N({harnessId:SC,nativeSessionId:eD,checkpointId:eD,locator:mC.optional(),formatVersion:F(1)}).superRefine(lC([`locator`]));let tD=O().regex(/^\d+\.\d+\.\d+(?:-[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?(?:\+[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/u),nD=P([`npm`,`windows-installer`,`macos-dmg`,`linux-archive`]),rD=N({version:tD,installation:nD,phase:P([`prepared`,`downloading`,`waiting-for-exit`,`installing`,`restarting`,`succeeded`,`failed`]),updatedAt:k().int().nonnegative(),downloadedBytes:k().int().nonnegative().optional(),totalBytes:k().int().positive().optional(),error:O().min(1).max(500).nullable(),serviceStopOutput:O().optional()}).superRefine((e,t)=>{e.downloadedBytes!==void 0&&e.totalBytes!==void 0&&e.downloadedBytes>e.totalBytes&&t.addIssue({code:`custom`,path:[`downloadedBytes`],message:`downloadedBytes must not exceed totalBytes`})});N({});let iD=O().max(300).regex(/^https:\/\/github\.com\/BytePioneer-AI\/codex-host\/releases\/tag\/v[0-9A-Za-z.+-]+$/u,`release notes URL must identify a codexhost GitHub Release`);N({currentVersion:tD,installation:nD.nullable(),latestVersion:tD.nullable(),updateAvailable:A(),installationAvailable:A(),releaseNotes:O().min(1).max(2e4).nullable(),releaseNotesUrl:iD.nullable(),status:rD.nullable(),error:O().min(1).max(500).nullable()}),N({status:rD}),N({status:rD.nullable()});let aD=N({icon:O().min(1).max(16).optional(),title:O().min(1).max(120),body:O().min(1).max(1200),contributors:j(O().min(1).max(39)).max(30)}),oD=N({summary:O().min(1).max(600).optional(),themes:j(aD).min(1).max(12)}),sD=N({version:tD,publishedAt:Tu(),url:O().max(300).regex(/^https:\/\/github\.com\/BytePioneer-AI\/codex-host\/releases\/tag\/v[0-9A-Za-z.+-]+$/u),zh:oD.nullable(),en:oD.nullable()}).refine(e=>e.zh!==null||e.en!==null,{message:`an announcement needs at least one language`});N({manual:A().optional()}),N({announcement:sD.nullable(),unread:A()}),N({version:tD}),RegExp(String.raw`^- \[([^\]\n]+)\]\(thread://([^\s()<>"?#/]+)\): `+`(${[`completed`,`failed`,`interrupted`,`needsInput`,`timedOut`,`unreadable`,`notFound`].join(`|`)})(?:\. (.+))?$`,`u`);function cD(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 lD(e,t){let n=cD(e);return n===``?t:`${n}\n## My request:\n${t}\n`}let uD=P([`idle`,`installing`,`restarting`,`succeeded`,`failed`]);M({runningVersion:O().nullable(),installedVersion:O().nullable(),restartRequired:A(),remote:A(),updateSupported:A(),update:M({phase:uD,targetVersion:O().nullable(),error:O().nullable()})});let dD=M({version:O().regex(/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/u)}).strict();M({hostname:O().min(1).max(1024).refine(e=>!e.startsWith(`-`)&&!/\s/u.test(e)),port:k().int().min(1).max(65535).nullable(),identity:O().max(4096).nullable(),action:P([`inspect`,`install`,`update`,`repair`,`uninstall`]),uninstallPackage:A().optional(),version:O().regex(/^\d+\.\d+\.\d+$/u).nullable()}).strict(),M({state:P([`installed`,`not-installed`])}).strict();let X=O().min(1).max(1024),fD={hostId:X.regex(/^(?:remote-(?:ssh(?:-|:)|control:)|remote-peer:[a-zA-Z0-9_-]{1,64}$)/u)},pD={...fD,threadId:X},mD=O().min(1).max(8e3),hD={text:mD,requestId:X};Wl(`accepted`,[M({accepted:F(!0),startQueuedItemId:X.optional()}),M({accepted:F(!1),code:P([`remote/queue-unavailable`,`remote/steer-unavailable`,`remote/turn-changed`,`remote/send-rejected`,`session/queue-item-not-found`,`session/queue-item-starting`]),message:O()})]),Wl(`available`,[M({available:F(!1)}),M({available:F(!0),items:j(M({id:X,clientUserMessageId:X,preview:O().max(801)})).max(100)})]);let gD=Wl(`kind`,[N({kind:F(`hosts`)}),N({kind:F(`create`),...fD,cwd:O().min(1).max(8192),epoch:X}),N({kind:F(`projectHarnesses`),...fD,epoch:X}),N({kind:F(`inspectHarness`),...fD,epoch:X,cwd:O().min(1).max(8192),harnessId:X}),N({kind:F(`startSelected`),...fD,epoch:X,cwd:O().min(1).max(8192),harnessId:X,model:O().min(1).max(4096),serviceTier:P([`priority`,`ultrafast`]).optional(),reasoningEffort:X.optional()}),N({kind:F(`status`),...pD}),N({kind:F(`list`),...fD,cursor:O().nullable(),archived:A(),includeLoaded:F(!0).optional()}),N({kind:F(`read`),...pD,page:N({cursor:O().min(1).max(8192).nullable(),epoch:X.optional(),sortDirection:P([`asc`,`desc`]).optional(),limit:k().int().min(1).max(20).optional()}).refine(e=>e.cursor===null||e.epoch!==void 0,{message:`A history continuation requires its connection epoch`}).optional()}),N({kind:F(`usage`),...pD,epoch:X}),N({kind:F(`configure`),...pD,epoch:X,modelId:X.optional(),serviceTier:WC.optional(),thinkingOptionId:X.optional(),permissionModeId:X.optional()}).refine(e=>[e.modelId,e.thinkingOptionId,e.permissionModeId].filter(e=>e!==void 0).length===1,`Select exactly one remote setting`).refine(e=>e.serviceTier===void 0||e.modelId!==void 0,{message:`A service tier requires a Model ID`}),N({kind:F(`prompt`),...pD,epoch:X,text:mD,requestId:X.optional()}),N({kind:F(`queue`),...pD,epoch:X}),N({kind:F(`delivery`),...pD,epoch:X,action:Wl(`kind`,[N({kind:F(`enqueue`),...hD}),N({kind:F(`steer`),...hD,turnId:X}),N({kind:F(`remove`),itemId:X}),N({kind:F(`start`),itemId:X,onlyIfHead:F(!0).optional()})])}),N({kind:F(`interrupt`),...pD,epoch:X,turnId:X}),N({kind:F(`rename`),...pD,epoch:X,name:O().min(1).max(512)}),N({kind:F(`archive`),...pD,epoch:X,archived:A()}),N({kind:F(`respond`),...pD,epoch:X,requestId:Hl([X,k().int()]),result:Xl(O(),Il())})]),_D=O().min(1).max(1024),vD=M({hostId:_D,displayName:O().min(1).max(1024),source:P([`codex-managed`,`discovered`]),sshAlias:O().max(1024).nullable(),sshHost:O().min(1).max(1024),sshPort:k().int().min(1).max(65535).nullable(),identity:O().max(4096).nullable(),autoConnect:A(),connectionAnalyticsId:O().max(1024).optional()}),yD=N({displayName:O().min(1).max(1024),hostname:O().min(1).max(1024),sshPort:k().int().min(1).max(65535).nullable(),identity:O().max(4096).nullable()});Wl(`action`,[N({action:F(`session`),operation:gD}),N({action:F(`list`)}),N({action:F(`catalog`)}),N({action:F(`read-thread`),hostId:_D.refine(e=>e!==`local`),input:JT}),N({action:F(`save`),draft:yD,previous:vD.nullable()}),N({action:F(`remove`),previous:vD}),N({action:F(`connect`),hostId:_D,enabled:A()}),N({action:F(`state`),hostId:_D}),N({action:F(`runtime`),hostId:_D}),N({action:F(`update`),hostId:_D.refine(e=>e!==`local`),version:dD.shape.version})]),Hl([N({result:mC}),N({error:N({code:k().int(),message:O()})})]),N({prompt:O().trim().min(1).max(2e3),cwd:O().max(4096).nullable()}),O().trim().min(1).max(60).nullable();let bD=O().max(214).regex(/^(?:@[a-z0-9][a-z0-9._-]*\/)?[a-z0-9][a-z0-9._-]*$/u),xD=Hl([O(),M({en:O()}).catchall(O())]),SD=M({title:xD.optional(),description:xD.optional(),icon:O().max(349592).regex(/^data:image\/(?:svg\+xml|png|jpeg|webp);base64,[A-Za-z0-9+/]*={0,2}$/u).optional(),error:O().optional()});M({extensions:j(M({id:bD,name:O().min(1).max(214),version:O().min(1).max(128),format:F(`dsh`),supportedTargets:Jl([F(`web`)]),enabledTargets:j(F(`web`)).max(1),source:O().min(1).max(4096),projectUrl:O().max(4096).url({protocol:/^https?$/u}).optional(),installedAt:O(),meta:SD.optional(),loadError:O().optional()})),loadedIds:j(bD),safeMode:A(),storeError:O().optional()});let CD=O().trim().max(2048).url({protocol:/^https?$/u,normalize:!0}).refine(e=>!/[\s\\?#]/u.test(e)&&!e.split(`/`)[2]?.includes(`@`),`Use an HTTP(S) registry URL without credentials, a query, or a fragment.`).transform(e=>e.endsWith(`/`)?e:`${e}/`);M({spec:O().trim().min(1).max(4096),registry:CD.optional()}).strict(),M({id:bD,enabled:A()}).strict(),M({id:bD}).strict();let wD=O().regex(/^[a-zA-Z0-9_-]{1,64}$/u),TD=O().regex(/^remote-peer:[a-zA-Z0-9_-]{1,64}$/u),ED=P([`relay`,`tailscale`,`lan`,`custom`]),DD=[`blue`,`purple`,`cyan`,`green`,`amber`,`rose`,`slate`],OD=P(DD);new Set(DD);let kD=P([`connected`,`connecting`,`auth-error`,`offline`,`disabled`]);M({peers:j(M({peerId:wD,hostId:TD,name:O().min(1).max(120),color:OD.optional(),origin:O().min(1).max(2048),transportKind:ED,encrypted:A(),enabled:A(),state:kD,latencyMs:k().int().nonnegative().optional(),version:O().max(128).optional(),platform:O().max(64).optional(),hostname:O().max(255).optional(),homeDir:O().max(4096).optional(),lastError:O().max(1e3).optional(),projectCount:k().int().nonnegative(),createdAt:O(),updatedAt:O()}))}),M({connectionUrl:O().min(1).max(4096).optional(),origin:O().min(1).max(2048).optional(),token:O().min(1).max(2048).optional(),name:O().trim().min(1).max(120).optional(),color:OD.optional()}).refine(e=>!!e.connectionUrl||!!e.origin&&!!e.token,`Provide either connectionUrl or both origin and token`),M({peerId:wD,name:O().trim().min(1).max(120).optional(),color:OD.nullable().optional(),connectionUrl:O().min(1).max(4096).optional(),origin:O().min(1).max(2048).optional(),token:O().min(1).max(2048).optional(),enabled:A().optional()}),M({peerId:wD}),M({removed:A()}),M({peerId:wD.optional(),connectionUrl:O().min(1).max(4096).optional(),origin:O().min(1).max(2048).optional(),token:O().min(1).max(2048).optional()}).refine(e=>!!e.peerId||!!e.connectionUrl||!!e.origin&&!!e.token,`Provide peerId, connectionUrl, or both origin and token`);let AD=M({id:O().min(1).max(1024),name:O().min(1).max(512),path:O().min(1).max(8192)});M({ok:A(),latencyMs:k().int().nonnegative().optional(),origin:O().max(2048).optional(),transportKind:ED.optional(),encrypted:A().optional(),version:O().max(128).optional(),platform:O().max(64).optional(),hostname:O().max(255).optional(),homeDir:O().max(4096).optional(),projectCount:k().int().nonnegative().optional(),projects:j(AD).optional(),error:O().max(1e3).optional()});let jD=M({id:O().min(1).max(1024),name:O().min(1).max(512),path:O().min(1).max(8192),threadIds:j(O().min(1).max(1024))}),MD=M({attachments:F(1).optional(),workspaceFiles:F(1).optional(),officePreview:F(1).optional()}),ND=M({version:O().max(128),platform:O().max(64),hostname:O().max(255),homeDir:O().max(4096).optional(),epoch:O().min(1).max(256),projects:j(jD),capabilities:MD.optional()});N({threadId:O().min(1).max(1024),scope:O().regex(/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/u).optional(),requestId:O().min(1).max(256).optional(),mode:P([`queue`,`steer`]).optional(),expectedTurnId:O().min(1).max(1024).nullable().optional(),content:j(Wl(`type`,[N({type:F(`text`),text:O()}),N({type:F(`file`),receiptId:O().min(1).max(128)})])).min(1).max(64)});let PD=M({ok:F(!1),error:M({code:O(),message:O(),details:Xl(O(),Il()).optional()})});Hl([M({ok:F(!0),value:M({receiptId:O().min(1),file:M({attachmentId:O(),name:O(),bytes:k().int().nonnegative()})})}),PD]),Hl([M({ok:F(!0),value:M({accepted:F(!0)})}),PD]);let FD=M({name:O().min(1).max(512),path:O().min(1).max(8192),kind:F(`directory`)});M({peerId:wD,path:O().min(1).max(8192).optional()}),M({path:O().min(1).max(8192),parentPath:O().min(1).max(8192).nullable(),homeDir:O().min(1).max(8192).optional(),entries:j(FD)}),M({peerId:wD,parentPath:O().min(1).max(8192),name:O().min(1).max(255).refine(e=>e.trim().length>0,`Directory name cannot be blank`)}),M({path:O().min(1).max(8192),name:O().min(1).max(255)}),M({peerId:wD,path:O().min(1).max(8192),title:O().trim().min(1).max(255).optional()}),M({peerId:wD,workspaceId:O().min(1).max(1024),title:O().trim().min(1).max(255)}),M({peerId:wD,workspaceId:O().min(1).max(1024)}),M({workspaceId:O().min(1).max(1024).optional(),manifest:ND}),F(1);function ID(e){return e.registerNodeTransform(Hm,e=>{let t=BT(e.getTextContent())[0];t&&e.splitText(t.start,t.end)[t.start===0?0:1]?.replace(new qS({source:`codexhost-skill`,ref:t.text,label:t.name,appearance:`skill`,clipboardText:t.text}))})}let LD=`color: var(--dsw-alias-state-business-primary)`;function RD(){let e=j_().getFirstChild();if(!W(e))return null;let t=e.getFirstChild();return B(t)?t:null}function zD(e,t){return e.registerNodeTransform(Hm,e=>{let n=RD();if(n===null||e.getKey()!==n.getKey()){e.getStyle()===LD&&e.setStyle(``);return}let r=e.getTextContent(),i=t(),a=r===i?.trimEnd()?r:i;if(a===null||!r.startsWith(a))e.getStyle()===LD&&e.setStyle(``);else if(r.length>a.length){let[t,n]=e.splitText(a.length);t!==void 0&&t.getStyle()!==LD&&t.setStyle(LD),n?.setStyle(``)}else e.getStyle()!==LD&&e.setStyle(LD)})}function BD(e){e.update(()=>{RD()?.markDirty()})}function VD(){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(YS(e))o(`chip`,e,``,e.getTextContent());else if(B(e)){let t=e.getTextContent();o(`text`,e,t,t)}else zg(e)?o(`linebreak`,e,`
|
|
156
147
|
`,`
|
|
157
148
|
`):W(e)&&
|
|
158
149
|
/* 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=
|
|
150
|
+
s(e);r.set(e.getKey(),{start:t,end:i.length})},c=j_(),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
151
|
`,a+=`
|
|
161
|
-
`),W(t)&&s(t)}),r.set(c.getKey(),{start:u,end:i.length}),{segments:e,detectLength:i.length,detectText:i,clipboardText:a,byKey:t,children:n,bounds:r}}function
|
|
152
|
+
`),W(t)&&s(t)}),r.set(c.getKey(),{start:u,end:i.length}),{segments:e,detectLength:i.length,detectText:i,clipboardText:a,byKey:t,children:n,bounds:r}}function HD(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 UD(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 WD(e){let t=VD(),n=[];for(let r of t.segments){if(r.kind!==`chip`||!YS(r.node))continue;let t=r.node;n.push({occurrenceId:e(t.getKey()),source:t.getSource(),ref:t.getReference(),offset:r.clipboardStart,length:r.clipboardLength,label:t.getLabel(),...t.getAppearance()===void 0?{}:{appearance:t.getAppearance()},clipboardText:t.getTextContent(),...t.isInvalid()?{invalid:!0}:{}})}let r=H(),i=null;if(V(r)){let e=UD(t,r.anchor),n=UD(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 GD(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
153
|
/* 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=
|
|
154
|
+
if(n.node===null)return null;let r=n.node.getParent();return r===null?null:{key:r.getKey(),offset:n.node.getIndexWithinParent(),type:`element`}}let n=j_().getChildren(),r=n[n.length-1];return r===void 0?{key:j_().getKey(),offset:0,type:`element`}:{key:r.getKey(),offset:e.children.get(r.getKey())?.length??0,type:`element`}}function KD(e,t){if(t.start<0||t.start>t.end||t.end>e.detectLength)return null;let n=GD(e,t.start),r=GD(e,t.end);
|
|
164
155
|
/* v8 ignore next -- bounds were checked above; resolvePoint only fails out of bounds. */
|
|
165
|
-
if(n===null||r===null)return null;let i=
|
|
156
|
+
if(n===null||r===null)return null;let i=jh();return i.anchor.set(n.key,n.offset,n.type),i.focus.set(r.key,r.offset,r.type),M_(i),i}function qD(e,t){let n=KD(VD(),e);if(n===null)return!1;if(t===``)n.isCollapsed()||n.removeText();else{let e=t.replace(/\r\n?/gu,`
|
|
166
157
|
`);e.includes(`
|
|
167
|
-
`)?n.insertRawText(e):n.insertText(e)}return!0}function
|
|
168
|
-
`)){let t=
|
|
169
|
-
`);t!==``&&this.applyEdit(()=>{let e=H();if(V(e)){e.insertRawText(t);return}let n=
|
|
170
|
-
`);for(let e=0;e<t.length;e+=1){let i=t[e];i!==``&&r.append(Jf(i)),e<t.length-1&&(r=Hm(),n.append(r))}},a=0;for(let n of t)i(e.slice(a,n.offset)),r.append(new Wb({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:Tf})}clearHistory(){this.editor.dispatchCommand(Id,void 0)}};function JT(e){switch(e){case`plain`:return`plain`;case`claimed`:return`claimed`;default:return`frozen`}}function YT(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 XT=[],ZT=/* @__PURE__ */ new Map;var QT=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 Lv;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 qT({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(){YT(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:JT(this.core.state.phase)},this.rev)}setDraft(e){let t=Ec(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=Oc(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()??ZT,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(()=>{Oh().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(oT(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+=`
|
|
158
|
+
`)?n.insertRawText(e):n.insertText(e)}return!0}function JD(e,t){let n=KD(VD(),e);return n!==null&&(n.insertNodes([...t]),!0)}let YD=/[\uE100-\uE11D\uFFFC]/gu;var XD=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=Zg({namespace:`dsh-composer`,nodes:[qS,aC],onError:e=>{throw e}}),this.editor.update(()=>{let e=j_();e.getChildrenSize()===0&&e.append(Gg())},{discrete:!0,tag:km})}register(){let e=()=>{let e=this.editor.getRootElement();return e!==null&&!e.contains(e.ownerDocument.activeElement)&&nv(km),!1},t=Ib(OS(this.editor),this.editor.registerCommand(Np,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(jp,e=>{if(!this.editor.isEditable()||!e.dataTransfer||e.dataTransfer.types.includes(`Files`))return!1;let t=zS(e.dataTransfer.getData(PS));return t!==void 0&&(e.preventDefault(),e.stopPropagation(),e.dataTransfer.dropEffect=`copy`,this.insertFileReferences([RS(t)]))},4),this.editor.registerCommand(Up,()=>(this.editor.update(e,{discrete:!0}),!1),4),this.editor.registerCommand(tp,e,4),this.editor.registerNodeTransform(Og,e),cC(this.editor,(e,t)=>this.deps.openReference(e,t)),MS(this.editor,NS(),1e3),this.editor.registerUpdateListener(()=>{this.deps.onUpdate()}),ID(this.editor),zD(this.editor,()=>this.deps.activeClaimToken()),oC(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&&nv(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(()=>{sC(this.editor)}),sC(this.editor))}refreshProjection(){let e=this.projected;return this.projected=this.editor.getEditorState().read(()=>WD(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(YD,``);(t!==this.projection.clipboardText||this.projection.occurrences.length!==0)&&this.editor.update(()=>{let e=j_();e.clear();for(let n of t.split(`
|
|
159
|
+
`)){let t=Gg();n!==``&&t.append(Zm(n)),e.append(t)}e.selectEnd()},{discrete:!0,tag:Dm})}paste(e){let t=e.replace(YD,``).replace(/\r\n?/gu,`
|
|
160
|
+
`);t!==``&&this.applyEdit(()=>{let e=H();if(V(e)){e.insertRawText(t);return}let n=j_();n.getChildrenSize()===0&&n.append(Gg()),n.selectEnd().insertRawText(t)},Om)}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=qD(e,t)}),n}insertAsyncText(e,t){let n=!1,r=t.replace(YD,``);return this.applyEdit(()=>{n=qD(e,r)},Om),n}insertReference(e,t,n){let r=!1;return this.applyEdit(()=>{r=JD(e,n===` `?[JS(t)]:[JS(t),Zm(` `)])}),r}insertFileReferences(e,t){if(e.length===0)return!0;let n=!1;return this.applyEdit(()=>{let r=WD(e=>this.occurrenceIdOf(e)),i=t?.end??r.selection?.end??r.detectText.length,a=r.detectText.slice(0,i),o=e.flatMap(e=>[JS(e),Zm(` `)]);a!==``&&!/\s$/u.test(a)&&o.unshift(Zm(` `)),n=JD({start:i,end:i},o)},Om),n}refreshClaimDecoration(){BD(this.editor)}clearCommittedDraft(e){this.editor.update(()=>{let t=VD(),n=e(t.clipboardText);if(n!==null){qD({start:0,end:HD(t,n)},``);return}let r=j_();r.clear(),r.append(Gg()),r.selectEnd()},{discrete:!0,tag:Dm})}restoreDraft(e,t){this.editor.update(()=>{let n=j_();n.clear();let r=Gg();n.append(r);let i=e=>{let t=e.replace(YD,``).split(`
|
|
161
|
+
`);for(let e=0;e<t.length;e+=1){let i=t[e];i!==``&&r.append(Zm(i)),e<t.length-1&&(r=Gg(),n.append(r))}},a=0;for(let n of t)i(e.slice(a,n.offset)),r.append(new qS({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:Dm})}clearHistory(){this.editor.dispatchCommand(zp,void 0)}};function ZD(e){switch(e){case`plain`:return`plain`;case`claimed`:return`claimed`;default:return`frozen`}}function QD(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 $D=[],eO=/* @__PURE__ */ new Map;var tO=class{deps;state;notices=(0,f.createSnapshotStore)(null);get editor(){return this.draftEditor.editor}get isDisposed(){return this.disposed}actions={captureInsertion:e=>{let t=this.projection.detectText.length;return{...e===`end`?{start:t,end:t}:this.caretSpan(),draftRev:this.rev}},bindPrimaryAction:e=>(this.primaryAction=e,this.publish(),()=>{this.primaryAction===e&&(this.primaryAction=void 0,this.publish())}),insertText:(e,t)=>this.snapshot.phase===`adjudicating`||this.snapshot.phase===`submitting`||this.disposed||t.draftRev!==this.rev?!1:this.draftEditor.insertAsyncText(t,e),setDraft:e=>{this.setDraft(e)},persistDraft:()=>{this.persistCurrentDraft()},addAttachments:e=>this.addAttachments(e),removeAttachment:e=>{this.removeAttachment(e)},pruneAttachments:e=>{this.pruneAttachments(e)},addResponseAnnotation:(e,t)=>{if(t?.focus===`end`&&!this.canInsertReferences())return;let n=this.addResponseAnnotation(e);return n!==void 0&&t?.focus===`end`&&this.canInsertReferences()&&this.focus(`end`),n},removeResponseAnnotation:e=>{this.removeResponseAnnotation(e)},submit:()=>{this.submit(`queue`)}};primaryAction;core=new Bb;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 XD({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(){QD(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:ZD(this.core.state.phase)},this.rev)}setDraft(e){let t=Ou(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=Au(this.projection.clipboardText,this.projection.occurrences);return this.draftSnapshotCache={revision:this.rev,value:e},e}persistCurrentDraft(){this.persistDraft?.(this.draftSnapshot)}requestDraftInitialization(e){return this.draftInitializationBlocked()?`blocked`:e.prompt===void 0&&e.clearPreviousDraft!==!0||e.clearPreviousDraft!==!0&&(this.snapshot.draft!==``||this.attachmentIds.length>0)?`preserved`:(this.setDraft(e.prompt??``),`applied`)}draftInitializationBlocked(){let{phase:e}=this.core.state;return this.disposed||e===`adjudicating`||e===`submitting`||this.detachedDrafts.size>0||this.attachmentFlights.size>0}canInsertReferences(){let e=this.editor.getRootElement();return!this.disposed&&this.editor.isEditable()&&e!==null&&e.isConnected&&e.getClientRects().length>0&&(this.snapshot.phase===`plain`||this.snapshot.phase===`claimed`)}insertReferences(e,t){return!this.canInsertReferences()||t.draftRev!==this.rev?!1:this.draftEditor.insertFileReferences(e,t)}addAttachments(e){return this.disposed||this.snapshot.phase===`adjudicating`||this.snapshot.phase===`submitting`?!1:(e.length===0||(this.attachmentIds=[...this.attachmentIds,...e],this.publish()),!0)}addFiles(e,t){return this.snapshot.phase===`adjudicating`||this.snapshot.phase===`submitting`||!this.draftEditor.insertFileReferences(e)?!1:(this.attachmentIds=[...this.attachmentIds,...t],this.publish(),!0)}removeAttachment(e){if(this.snapshot.phase===`adjudicating`||this.snapshot.phase===`submitting`)return!1;let t=this.attachmentIds.filter(t=>t!==e);return t.length!==this.attachmentIds.length&&(this.attachmentIds=t,this.publish(),!0)}pruneAttachments(e){let t=new Set(e),n=this.attachmentIds.filter(e=>t.has(e));n.length!==this.attachmentIds.length&&(this.attachmentIds=n,this.publish())}addResponseAnnotation(e){if(this.snapshot.phase===`adjudicating`||this.snapshot.phase===`submitting`)return;this.annotationSeq+=1;let t=`response-annotation-${String(this.annotationSeq)}`;return this.responseAnnotations=[...this.responseAnnotations,{id:t,text:e.text.trim(),...e.annotation===void 0?{}:{annotation:e.annotation},...e.anchor===void 0?{}:{anchor:e.anchor}}],this.publish(),t}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()??eO,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(()=>{j_().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(lD(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+=`
|
|
171
162
|
|
|
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`]??XT}}publish(){let e=this.compose();this.state.set(e);let t=this.draftSnapshot;t!==this.lastPublishedDraft&&(this.lastPublishedDraft=t,this.persistDraft?.(t))}};function $T(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 eE=class{rootCtx;t;pendingDraft;shells=/* @__PURE__ */ new WeakMap;constructor(e,t,n){this.rootCtx=e,this.t=t,this.pendingDraft=n}for(e){let t=this.sessions(),n=t.sessionOf(e),r=n===void 0?void 0:t.binding(n.sessionId);if(r===void 0||r.session!==n)throw Error(`conversation.input.for requires a retained Session scope`);return this.shellFor(r)}captureReferenceInsertion(e){let t=this.sessions(),n=this.shells.get(e);if(t.binding(e.sessionId)!==e||n===void 0)return;let r=this.rootCtx.get(`conversation`);if(r===void 0)return;let i=n.actions.captureInsertion(),a=r.blocks.storeFor(e.sessionId),o=this.rootCtx.uiSession.sessionStatus,s=!1,c=()=>{let r=e.session.getSnapshot();return!s&&t.binding(e.sessionId)===e&&r.openState===`open`&&!r.removed&&a.getSnapshot()===void 0&&o.getSnapshot().get(e.sessionId)?.pendingInteraction===void 0&&n.snapshot.draftRev===i.draftRev&&n.canInsertReferences()};return{getSnapshot:c,subscribe:r=>{let i=[t.list.subscribe(r),e.session.subscribe(r),n.state.subscribe(r),a.subscribe(r),o.subscribe(r),n.editor.registerEditableListener(r),n.editor.registerRootListener(r)];return()=>i.forEach(e=>e())},insert:e=>{let t=c();return s=!0,t&&n.insertReferences([e],i)}}}requestDraftInitialization(e,t){if(this.sessions().binding(e.sessionId)!==e)throw Error(`conversation.input.requestDraftInitialization requires a retained Session binding`);return this.shellFor(e).requestDraftInitialization(t)}adoptPendingDraft(e,t){if(this.sessions().binding(e.sessionId)!==e)throw Error(`conversation.input.adoptPendingDraft requires a retained Session binding`);let n=this.pendingDraft?.take(),r=this.shellFor(e);return t===void 0?n!==void 0&&n.text!==``?(r.setDraft(n.text),`applied`):`preserved`:n?.modified?r.requestDraftInitialization({prompt:n.text,clearPreviousDraft:!0}):r.requestDraftInitialization(t)}shellFor(e){let t=this.shells.get(e);if(t!==void 0)return t;let{session:n,ctx:r}=e,i=new QT({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=>{$T(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(Mc(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 tE=/* @__PURE__ */ new Map;var nE=class{runtime;unregister;textStore=(0,f.createSnapshotStore)(``);activeToken=null;modified=!1;seeding=!1;text=this.textStore;constructor(){this.runtime=new qT({onUpdate:()=>{let e=this.runtime.refreshProjection(),t=this.runtime.projection.clipboardText;e.clipboardText!==t&&(this.seeding||(this.modified=!0),this.textStore.set(t))},openReference:()=>!1,activeClaimToken:()=>null,lexicon:()=>tE,resolveLexicon:()=>void 0}),this.unregister=this.runtime.register()}get editor(){return this.runtime.editor}syncCreation(e){if(e.state===`idle`){(this.activeToken!==null||this.textStore.getSnapshot()!==``)&&(this.activeToken=null,this.clearEditor());return}let t=e.token??null;t!==this.activeToken&&(this.activeToken=t,this.seed(e.initialPrompt??``))}paste(e){this.runtime.paste(e)}take(){if(this.activeToken===null)return;let e={text:this.runtime.projection.clipboardText,modified:this.modified};return this.activeToken=null,this.clearEditor(),e}dispose(){this.activeToken=null,this.unregister()}seed(e){this.seeding=!0;try{this.modified=!1,this.runtime.setDraft(e),this.runtime.clearHistory(),this.textStore.set(this.runtime.projection.clipboardText)}finally{this.seeding=!1}}clearEditor(){this.seed(``)}};let rE=`busyEnter`,iE=[`queue`,`steer`],aE=`queue`,oE={[rE]:S.union([...iE]).default(aE)};S.object(oE);function sE(e,t,n,r){return!t||!r?`queue`:n===`enter`?e:e===`queue`?`steer`:`queue`}var cE=class{busyEnter=(0,f.createSnapshotStore)(aE);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(rE,e))}adopt(e){let t=e.getSnapshot().value;t!==void 0&&this.busyEnter.getSnapshot()!==t.busyEnter&&this.busyEnter.set(t.busyEnter)}};let lE=`@deepseek-ai/dsh-client-ui-conversation/QueueDock.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(lE)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-conversation`,e.dataset.pluginCss=lE,e.textContent=`.ZMI-0G_dock{box-sizing:border-box;width:calc(100% - var(--dsh-composer-side-clearance) - var(--dsh-composer-side-clearance) - var(--dsh-composer-dock-inset) - var(--dsh-composer-dock-inset));max-width:calc(var(--dsh-composer-card-max-width) - var(--dsh-composer-dock-inset) - var(--dsh-composer-dock-inset));margin:0 auto calc(0px - var(--dsh-composer-stack-gap) - 3px);padding:0 var(--dsh-composer-dock-inset);flex:none}.ZMI-0G_pendingAttachment{flex-direction:column;gap:2px;display:inline-flex}.ZMI-0G_panel{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}.ZMI-0G_panel:before{z-index:-1;border-radius:inherit;background:var(--dsw-specific-menu);backdrop-filter:var(--dsw-menu-backdrop-filter);content:"";pointer-events:none;position:absolute;inset:0}.ZMI-0G_panel:after{border:.5px solid var(--dsw-alias-border-l1);border-radius:inherit;content:"";pointer-events:none;border-bottom:none;position:absolute;inset:0}.ZMI-0G_paused{color:var(--dsw-alias-label-tertiary);font:var(--dsw-font-xs-13);padding:6px 12px 2px}.ZMI-0G_header{box-sizing:border-box;border-radius:var(--dsw-radius-md);width:100%;height:36px;color:var(--dsw-alias-label-primary);text-align:left;cursor:pointer;background:0 0;border:none;align-items:center;gap:10px;padding:4px 12px;display:flex}.ZMI-0G_header:focus-visible{outline:var(--dsw-focus-ring-width) solid var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary));outline-offset:-2px}.ZMI-0G_header:disabled{cursor:default}.ZMI-0G_lead{color:var(--dsw-alias-label-tertiary);flex:none;place-items:center;display:grid}.ZMI-0G_count{min-width:0;font-family:Inter, var(--dsw-font-family);flex:auto;font-size:13px;font-weight:500;line-height:24px}.ZMI-0G_chevron{width:14px;height:14px;color:var(--dsw-alias-label-tertiary);flex:none;place-items:center;display:grid}.ZMI-0G_list{max-height:180px;margin:0;padding:0;list-style:none;overflow-y:auto}.ZMI-0G_row{box-sizing:border-box;border-radius:var(--dsw-radius-md);align-items:center;gap:10px;width:100%;min-height:36px;padding:4px 5px 4px 12px;display:flex}.ZMI-0G_row+.ZMI-0G_row{box-shadow:inset 0 1px 0 var(--dsw-alias-border-l1)}.ZMI-0G_attachments{flex:none;gap:4px;min-width:0;max-width:55%;display:flex;overflow:hidden}.ZMI-0G_pendingRow .ZMI-0G_attachments{flex-shrink:1}.ZMI-0G_file{border:.5px solid var(--dsw-alias-border-l1);border-radius:var(--dsw-radius-sm);background:var(--dsw-alias-bg-base);box-sizing:border-box;flex:0 180px;align-items:center;gap:4px;min-width:74px;height:24px;padding:0 6px;display:inline-flex;overflow:hidden}.ZMI-0G_fileIcon{flex:none;width:16px;height:16px;display:inline-flex}.ZMI-0G_fileName{min-width:0;color:var(--dsw-alias-label-primary-dimmed);font:var(--dsw-font-xs-13);text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.ZMI-0G_fileSize{color:var(--dsw-alias-label-tertiary);white-space:nowrap;flex:none;font-size:10px}.ZMI-0G_thumb{border:.5px solid var(--dsw-alias-border-l1);border-radius:var(--dsw-radius-xs);background:var(--dsw-alias-bg-base);object-fit:cover;width:24px;height:24px}.ZMI-0G_preview{min-width:0;font:var(--dsw-font-xs-13);font-family:Inter, var(--dsw-font-family);color:var(--dsw-alias-label-primary-dimmed);text-overflow:ellipsis;white-space:nowrap;word-break:break-word;flex:auto;overflow:hidden}.ZMI-0G_actions{flex:none;align-items:center;gap:10px;display:flex}.ZMI-0G_status{color:var(--dsw-alias-label-tertiary);font:var(--dsw-font-xs-13);white-space:nowrap;flex:none}.ZMI-0G_action{corner-shape:round;width:28px;height:28px;color:var(--dsw-alias-label-tertiary);cursor:pointer;background:0 0;border:none;border-radius:999px;flex:none;place-items:center;padding:0;display:grid}.ZMI-0G_action:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-hover)}.ZMI-0G_action:focus-visible{outline:var(--dsw-focus-ring-width) solid var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary));outline-offset:-2px}.ZMI-0G_action:disabled{cursor:default;opacity:.45}`,document.head.appendChild(e)}var Z={action:`ZMI-0G_action`,actions:`ZMI-0G_actions`,attachments:`ZMI-0G_attachments`,chevron:`ZMI-0G_chevron`,count:`ZMI-0G_count`,dock:`ZMI-0G_dock`,file:`ZMI-0G_file`,fileIcon:`ZMI-0G_fileIcon`,fileName:`ZMI-0G_fileName`,fileSize:`ZMI-0G_fileSize`,header:`ZMI-0G_header`,lead:`ZMI-0G_lead`,list:`ZMI-0G_list`,panel:`ZMI-0G_panel`,paused:`ZMI-0G_paused`,pendingAttachment:`ZMI-0G_pendingAttachment`,pendingRow:`ZMI-0G_pendingRow`,preview:`ZMI-0G_preview`,row:`ZMI-0G_row`,status:`ZMI-0G_status`,thumb:`ZMI-0G_thumb`};let uE=[];function dE(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 fE(e){return e.every(e=>e.type===`text`)?e.map(e=>e.text).join(``):null}function pE(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 mE({attachment:e,label:t}){return/* @__PURE__ */ (0,h.jsxs)(`span`,{className:Z.file,"aria-label":t,title:e.name,children:[/* @__PURE__ */ (0,h.jsx)(`span`,{className:Z.fileIcon,"aria-hidden":!0,children:/* @__PURE__ */ (0,h.jsx)(d.FileTypeIcon,{path:e.name,size:16})}),/* @__PURE__ */ (0,h.jsx)(`span`,{className:Z.fileName,children:e.name}),/* @__PURE__ */ (0,h.jsx)(`span`,{className:Z.fileSize,children:(0,d.fileSizeText)(e.bytes)})]})}function hE({attachment:e,loadImage:t,label:n}){let[r,i]=(0,g.useState)(null);return(0,g.useEffect)(()=>{let n=!0;return t(e).then(e=>{n&&i(e)},()=>{}),()=>{n=!1}},[e,t]),r===null?/* @__PURE__ */ (0,h.jsx)(`span`,{className:Z.thumb,"aria-hidden":!0}):/* @__PURE__ */ (0,h.jsx)(`img`,{className:Z.thumb,src:r,alt:n})}function gE({upload:e,t}){let n=(0,g.useSyncExternalStore)(e.subscribe,e.getSnapshot);return n?.status===`uploading`?/* @__PURE__ */ (0,h.jsx)(`span`,{className:Z.status,role:`status`,"data-upload-progress":!0,children:n.total===void 0||n.total===0?t(`file.uploading`):t(`file.uploadingPercent`,{percent:Math.round(Math.min(1,(n.loaded??0)/n.total)*100)})}):null}function _E({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`]??uE,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`)&&c?.stale!==!0,v=c?.previewOnly===!0,y=(0,g.useRef)(!1),[b,ee]=(0,g.useState)(null),[te,ne]=(0,g.useState)(!0),re=(0,g.useId)(),ie=c?.pausedReason??null,ae=ie===`interrupted`?o(`queue.paused.interrupted`):ie===`outcome-unknown`?o(`queue.paused.unknown`):ie===`failed`?o(`queue.paused.failed`):null;if((0,g.useEffect)(()=>{p===0&&!te&&ne(!0)},[te,p]),p===0)return null;let oe=_&&b!==null,se=!te||oe,ce=p===1||se,le=async(e,t,r)=>{if(y.current)return!1;y.current=!0,ee(e);try{return typeof t==`function`?await t():await n(e,t),!0}catch{return i(`error`,v?o(`queue.remoteActionFailed`):r),!1}finally{y.current=!1,ee(t=>t===e?null:t)}};return/* @__PURE__ */ (0,h.jsx)(`div`,{className:Z.dock,"data-queue-dock":``,children:/* @__PURE__ */ (0,h.jsxs)(`div`,{className:Z.panel,children:[c?.stale&&/* @__PURE__ */ (0,h.jsx)(`div`,{className:Z.paused,role:`status`,children:o(`queue.remoteStale`)}),ae!==null&&/* @__PURE__ */ (0,h.jsx)(`div`,{className:Z.paused,role:`status`,children:ae}),p>1&&/* @__PURE__ */ (0,h.jsxs)(`button`,{type:`button`,className:Z.header,"aria-controls":re,"aria-expanded":se,disabled:oe,onClick:()=>{ne(e=>!e)},children:[/* @__PURE__ */ (0,h.jsx)(`span`,{className:Z.lead,"aria-hidden":!0,children:/* @__PURE__ */ (0,h.jsx)(d.IconQueueOutlineRegular,{})}),/* @__PURE__ */ (0,h.jsx)(`span`,{className:Z.count,children:o(`queue.count`,{n:p})}),!ce&&f.length>0&&/* @__PURE__ */ (0,h.jsx)(`span`,{className:Z.status,role:`status`,children:o(`queue.sending`)}),/* @__PURE__ */ (0,h.jsx)(`span`,{className:Z.chevron,"aria-hidden":!0,children:se?/* @__PURE__ */ (0,h.jsx)(d.IconChevronDownOutlineRegular,{}):/* @__PURE__ */ (0,h.jsx)(d.IconChevronUpOutlineRegular,{})})]}),/* @__PURE__ */ (0,h.jsxs)(`ul`,{id:re,className:Z.list,hidden:!ce,children:[ce&&u.map(e=>{let t=pE(e.content),n=fE(e.content);return/* @__PURE__ */ (0,h.jsxs)(`li`,{className:Z.row,children:[p===1&&/* @__PURE__ */ (0,h.jsx)(`span`,{className:Z.lead,"aria-hidden":!0,children:/* @__PURE__ */ (0,h.jsx)(d.IconQueueOutlineRegular,{})}),t.length>0&&/* @__PURE__ */ (0,h.jsx)(`span`,{className:Z.attachments,children:t.map((e,t)=>e.type===`image`?/* @__PURE__ */ (0,h.jsx)(hE,{attachment:e.attachment,loadImage:a,label:o(`queue.image`)},`${e.attachment.attachmentId}:${t}`):/* @__PURE__ */ (0,h.jsx)(mE,{attachment:e.attachment,label:o(`queue.file`,{name:e.attachment.name})},`${e.attachment.attachmentId}:${e.attachment.name}:${t}`))}),/* @__PURE__ */ (0,h.jsx)(`span`,{className:Z.preview,children:(0,d.projectUserText)(dE(e.content),[])}),_&&/* @__PURE__ */ (0,h.jsxs)(`div`,{className:Z.actions,children:[!v&&/* @__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:Z.action,"aria-label":o(`queue.edit`),title:n===null?o(`queue.edit.unsupported`):void 0,disabled:b!==null||n===null,onClick:()=>{n!==null&&le(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:Z.action,"aria-label":o(`queue.remove`),disabled:b!==null,onClick:()=>{le(e.id,{kind:`remove`},o(`queue.removeFailed`))},children:/* @__PURE__ */ (0,h.jsx)(d.IconTrashOutlineRegular,{size:14})})}),(!v||!m)&&/* @__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:Z.action,"aria-label":o(m?`queue.steer`:`queue.resume`),disabled:b!==null,onClick:()=>{le(e.id,{kind:`steer`},o(m?`queue.steerFailed`:`queue.resumeFailed`))},children:/* @__PURE__ */ (0,h.jsx)(d.IconSendOutlineRegular,{})})})]})]},e.id)}),ce&&f.map(e=>/* @__PURE__ */ (0,h.jsxs)(`li`,{className:`${Z.row} ${Z.pendingRow}`,"data-submission-echo":``,children:[p===1&&/* @__PURE__ */ (0,h.jsx)(`span`,{className:Z.lead,"aria-hidden":!0,children:/* @__PURE__ */ (0,h.jsx)(d.IconQueueOutlineRegular,{})}),e.attachments.length>0&&/* @__PURE__ */ (0,h.jsx)(`span`,{className:Z.attachments,children:e.attachments.map((e,t)=>/* @__PURE__ */ (0,h.jsxs)(`span`,{className:Z.pendingAttachment,children:[e.type===`image`?/* @__PURE__ */ (0,h.jsx)(`img`,{className:Z.thumb,src:e.value.previewUrl,alt:o(`queue.image`)}):/* @__PURE__ */ (0,h.jsx)(mE,{attachment:e.value,label:o(`queue.file`,{name:e.value.name})}),e.upload&&/* @__PURE__ */ (0,h.jsx)(gE,{upload:e.upload,t:o})]},t))}),/* @__PURE__ */ (0,h.jsx)(`span`,{className:Z.preview,children:(0,d.projectUserText)(e.text,[])}),/* @__PURE__ */ (0,h.jsx)(`span`,{className:Z.status,role:`status`,children:o(`queue.sending`)}),_&&!v&&/* @__PURE__ */ (0,h.jsxs)(`div`,{className:Z.actions,children:[/* @__PURE__ */ (0,h.jsx)(`button`,{type:`button`,className:Z.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:Z.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:Z.action,"aria-label":o(`queue.steer`),title:o(`queue.sending`),disabled:!0,children:/* @__PURE__ */ (0,h.jsx)(d.IconSendOutlineRegular,{})})]})]},e.requestId))]})]})})}let vE={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:Lc,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)}}},_E))}},yE=`@deepseek-ai/dsh-client-ui-conversation/EnterBehaviorRow.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(yE)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-conversation`,e.dataset.pluginCss=yE,e.textContent=`.v-9l-a_row{border-bottom:.5px solid var(--dsw-alias-border-l2);align-items:center;gap:8px;padding:16px 0;display:flex}.v-9l-a_rowText{flex-direction:column;flex:1;gap:4px;min-width:0;padding-right:48px;display:flex}.v-9l-a_title{color:var(--dsw-alias-label-primary);font-size:14px;font-weight:400;line-height:22px}.v-9l-a_desc{color:var(--dsw-alias-label-tertiary);font-size:12px;font-weight:400;line-height:18px}.v-9l-a_selector{border-radius:var(--dsw-radius-md);background:var(--dsw-alias-bg-module-platform);height:36px;font:inherit;color:var(--dsw-alias-label-primary);cursor:pointer;border:none;align-items:center;gap:12px;padding:0 14px;font-size:14px;line-height:22px;display:inline-flex}.v-9l-a_selector:hover{background:var(--dsw-alias-interactive-bg-hover)}.v-9l-a_chevron{flex:none}`,document.head.appendChild(e)}var bE={chevron:`v-9l-a_chevron`,desc:`v-9l-a_desc`,row:`v-9l-a_row`,rowText:`v-9l-a_rowText`,selector:`v-9l-a_selector`,title:`v-9l-a_title`};let xE=[{id:`queue`,label:`settings.enter.queue`},{id:`steer`,label:`settings.enter.steer`}];function SE({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:bE.row,children:[/* @__PURE__ */ (0,h.jsxs)(`div`,{className:bE.rowText,children:[/* @__PURE__ */ (0,h.jsx)(`div`,{className:bE.title,children:n(`settings.enter.title`)}),/* @__PURE__ */ (0,h.jsx)(`div`,{className:bE.desc,children:n(`settings.enter.description`)})]}),/* @__PURE__ */ (0,h.jsx)(d.Menu,{open:i,onClose:()=>{a(!1)},items:xE.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:bE.selector,"aria-haspopup":`menu`,"aria-expanded":i,onClick:()=>{a(e=>!e)},children:[n(o),/* @__PURE__ */ (0,h.jsx)(d.IconChevronDownOutlineRegular,{className:bE.chevron})]})})]})}let CE={views:{get:()=>void 0,grouped:()=>void 0},activeTargets:/* @__PURE__ */ new Set};function wE(e,t){return t.activeTargets.size>0||!e.blank&&!e.awaitingFirstTurn||e.running?`active`:e.promptAttempted?`engaging`:`blank`}let TE=`@deepseek-ai/dsh-client-ui-conversation/ConversationRoot.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(TE)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-conversation`,e.dataset.pluginCss=TE,e.textContent=`.vbpo1q_root{background:var(--dsw-alias-bg-base);flex-direction:column;min-width:0;height:100%;display:flex;position:relative}body[data-codexhost-wallpaper] .vbpo1q_root{background:0 0}.vbpo1q_header{box-sizing:border-box;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}.vbpo1q_header:where(:not(:has(.vbpo1q_tabs))){border-bottom:none;min-height:0;padding:10px 24px 6px 20px}[data-windows-titlebar] .vbpo1q_header:where(:not(:has(.vbpo1q_tabs))){padding-top:8px;padding-bottom:4px}.vbpo1q_headerBlank{border-bottom:none;min-height:0;padding-bottom:0}.vbpo1q_headerBlank .vbpo1q_headerCorner{margin-left:auto}html:not([data-platform=darwin]) .vbpo1q_headerSessionless{padding-top:0}html:not([data-platform=darwin]) .vbpo1q_headerSessionless .vbpo1q_titleRow{min-height:0}[data-platform=darwin] .vbpo1q_headerLeading,[data-platform=darwin] .vbpo1q_headerActions,[data-platform=darwin] .vbpo1q_headerUtilities,[data-platform=darwin] .vbpo1q_headerCorner{-webkit-app-region:no-drag}.vbpo1q_titleRow{min-height:30px;grid-column:2;align-items:center;gap:0;padding-inline-start:max(0px, calc(var(--dsh-frame-leading-clearance,0px) - 20px));display:flex;container-type:inline-size}.vbpo1q_titleCenter{display:contents}.vbpo1q_phoneTrailingAction{display:none}.vbpo1q_titleCluster{flex:1;align-items:center;gap:10px;min-width:0;display:flex}.vbpo1q_headerLeading{flex:none;grid-area:1/1;align-items:center;gap:8px;display:flex}.vbpo1q_crumbs{white-space:nowrap;align-items:center;gap:4px;min-width:0;display:flex;overflow:hidden}.vbpo1q_crumbSeg{align-items:center;gap:4px;min-width:0;display:inline-flex}.vbpo1q_crumbSep{color:var(--dsw-alias-label-caption);font-size:14px;line-height:20px}.vbpo1q_crumb{border-radius:var(--dsw-radius-md);max-width:220px;color:var(--dsw-alias-label-tertiary);text-overflow:ellipsis;white-space:nowrap;cursor:pointer;background:0 0;border:none;padding:4px 8px;font-size:14px;line-height:20px;display:inline-block;overflow:hidden}.vbpo1q_crumbSubagent{font-size:12px;line-height:18px}button.vbpo1q_crumb:hover{background:var(--dsw-alias-interactive-bg-hover)}.vbpo1q_crumbCurrent{color:var(--dsw-alias-label-primary);cursor:default;font-weight:500}.vbpo1q_headerActions{flex:none;align-items:center;gap:8px;display:flex}.vbpo1q_headerUtilities{flex:none;align-items:center;gap:8px;margin-left:20px;display:flex}.vbpo1q_headerUtilities:empty{display:none}.vbpo1q_headerCorner{flex:none;align-items:center;margin-left:8px;margin-right:-16px;display:flex}.vbpo1q_headerCorner:empty,.vbpo1q_headerCorner:not(:has([data-slot="conversation.session.header.corner"]>*)){display:none}[data-phone] .vbpo1q_root[data-phase=active]{--dsh-phone-header-height:calc(env(safe-area-inset-top) + 44px)}[data-phone] .vbpo1q_root[data-phase=active]:has([data-slot="conversation.header.shortcuts"] nav){--dsh-phone-header-height:calc(env(safe-area-inset-top) + 88px)}[data-phone] .vbpo1q_header{z-index:8;padding-top:env(safe-area-inset-top);background:0 0;border-bottom:none;row-gap:0;padding-bottom:0;position:relative}[data-phone] .vbpo1q_root[data-phase=active] .vbpo1q_header{pointer-events:none;position:absolute;top:0;left:0;right:0}[data-phone] .vbpo1q_root[data-phase=active] .vbpo1q_header [data-slot="conversation.header.shortcuts"]{pointer-events:auto}[data-phone] .vbpo1q_root[data-phase=active]:not(:has([data-slot="conversation.header.notice"]>*)) .vbpo1q_scrollBody{padding-top:var(--dsh-phone-header-height)}[data-phone] .vbpo1q_root[data-phase=active]>[data-slot="conversation.header.notice"]:not(:empty){margin-top:var(--dsh-phone-header-height);z-index:5;position:relative}[data-phone] .vbpo1q_root[data-phase=active] .vbpo1q_header:before{content:"";height:calc(var(--dsh-phone-header-height) + 32px);z-index:-1;background:linear-gradient(180deg, color-mix(in srgb, var(--dsw-alias-bg-base) 78%, transparent) 0%, color-mix(in srgb, var(--dsw-alias-bg-base) 58%, transparent) 44%, color-mix(in srgb, var(--dsw-alias-bg-base) 24%, transparent) 74%, transparent 100%);pointer-events:none;position:absolute;top:0;left:0;right:0}@supports (backdrop-filter:blur(16px)){[data-phone] .vbpo1q_root[data-phase=active] .vbpo1q_header:before{backdrop-filter:blur(16px)saturate(140%);-webkit-mask-image:linear-gradient(#000 0%,#000000eb 42%,#0000008f 62%,#00000038 78%,#0000000d 91%,#0000 100%);mask-image:linear-gradient(#000 0%,#000000eb 42%,#0000008f 62%,#00000038 78%,#0000000d 91%,#0000 100%)}}body[data-codexhost-wallpaper] [data-phone] .vbpo1q_root[data-phase=active] .vbpo1q_header:before{background:linear-gradient(180deg, color-mix(in srgb, var(--dsw-alias-bg-base) 64%, transparent) 0%, color-mix(in srgb, var(--dsw-alias-bg-base) 42%, transparent) 44%, color-mix(in srgb, var(--dsw-alias-bg-base) 16%, transparent) 74%, transparent 100%)}[data-phone] .vbpo1q_headerLeading{display:none}[data-phone] .vbpo1q_titleRow{grid-area:1/1/auto/-1;grid-template-columns:minmax(80px,1fr) minmax(0,auto) minmax(80px,1fr);align-items:center;gap:6px;min-height:44px;margin-inline:-8px -16px;padding-inline-start:0;display:grid}[data-phone] .vbpo1q_titleCluster{grid-column:2;justify-content:center;align-items:center;gap:4px;min-width:0;max-width:100%;display:flex}[data-phone] .vbpo1q_titleCenter{pointer-events:auto;border-radius:8px;justify-content:center;align-items:center;gap:4px;min-width:0;max-width:100%;min-height:36px;padding:0 2px;transition:opacity .12s;display:inline-flex;position:relative}[data-phone] .vbpo1q_root[data-phase=active] .vbpo1q_titleCenter:before{content:"";z-index:-1;background:radial-gradient(closest-side, color-mix(in srgb, var(--dsw-alias-bg-base) 88%, transparent) 38%, color-mix(in srgb, var(--dsw-alias-bg-base) 42%, transparent) 72%, transparent 100%);pointer-events:none;position:absolute;inset:-4px -22px}body[data-codexhost-wallpaper] [data-phone] .vbpo1q_root[data-phase=active] .vbpo1q_titleCenter:before{background:radial-gradient(closest-side, color-mix(in srgb, var(--dsw-alias-bg-base) 68%, transparent) 38%, color-mix(in srgb, var(--dsw-alias-bg-base) 28%, transparent) 72%, transparent 100%)}body[data-codexhost-wallpaper][data-ds-dark-theme] [data-phone] .vbpo1q_titleCenter{text-shadow:0 1px 10px #0000006b}[data-phone] .vbpo1q_titleCenter:has([data-navigation-focus-return]){cursor:pointer;-webkit-tap-highlight-color:transparent}[data-phone] .vbpo1q_titleRow>.vbpo1q_titleCenter,[data-phone] .vbpo1q_titleRow>[data-slot="conversation.header.navigation"]{pointer-events:auto;grid-column:2;justify-self:center}[data-phone] .vbpo1q_titleCenter>[data-slot="conversation.header.navigation"]{display:contents}[data-phone] .vbpo1q_titleCenter:has([data-navigation-focus-return]):active{opacity:.52}[data-phone] .vbpo1q_titleCenter:has([data-navigation-focus-return]:focus-visible){outline:none}@media (hover:hover) and (pointer:fine){[data-phone] .vbpo1q_titleCenter:has([data-navigation-focus-return]:focus-visible){outline:2px solid var(--dsw-alias-label-primary);outline-offset:2px}}[data-phone] .vbpo1q_crumbs{justify-content:center;gap:3px}[data-phone] .vbpo1q_crumb{letter-spacing:-.015em;max-width:none;padding:0;font-size:15px;font-weight:600;line-height:20px}[data-phone] button.vbpo1q_crumb{z-index:1;position:relative}[data-phone] .vbpo1q_headerActions:not(:has(button)),[data-phone] .vbpo1q_headerUtilities{display:none}[data-phone] .vbpo1q_phoneTrailingAction,[data-phone] .vbpo1q_headerCorner>[data-slot="conversation.session.header.corner"],[data-phone] .vbpo1q_phoneTrailingAction>[data-slot="conversation.header.trailing"]{display:contents}[data-phone] .vbpo1q_headerCorner:has(button){box-sizing:border-box;corner-shape:round;pointer-events:auto;background:#ffffffd6;border:.5px solid #0f11151a;border-radius:9999px;grid-column:3;justify-content:center;justify-self:end;align-items:center;gap:2px;height:36px;margin:0;padding:0 3px;display:inline-flex;box-shadow:inset 0 1px #ffffffb8,inset 0 -.5px #ffffff47,inset 0 0 0 .5px #ffffff38,0 1px 2px #0f11150d,0 6px 18px -4px #0f11151c}[data-phone] .vbpo1q_headerCorner:has(button):not(:has([data-phone-new-session]):has([data-sidebar-right-expand])){width:36px;padding:0}[data-ds-dark-theme] [data-phone] .vbpo1q_headerCorner:has(button){background:#24262cc7;border-color:#ffffff24;box-shadow:inset 0 1px #ffffff47,inset 0 -.5px #ffffff14,0 2px 8px #00000042,0 8px 22px -6px #0000006b}@supports (backdrop-filter:blur(8px)){[data-phone] .vbpo1q_headerCorner:has(button){backdrop-filter:blur(8px)saturate(180%);background:linear-gradient(#ffffff38 0%,#ffffff17 100%);box-shadow:inset 0 1px .5px #ffffffd9,inset 0 -.5px #0f11150f,0 1px 2px #0f11150f,0 6px 16px -4px #0f11151f}[data-ds-dark-theme] [data-phone] .vbpo1q_headerCorner:has(button){backdrop-filter:blur(10px)saturate(180%);background:linear-gradient(#ffffff1f 0%,#ffffff0d 100%)}}@media (prefers-reduced-motion:reduce){[data-phone] .vbpo1q_titleCenter{transition:none}}@media (prefers-reduced-transparency:reduce),(prefers-contrast:more){[data-phone] .vbpo1q_root[data-phase=active] .vbpo1q_header{pointer-events:auto;background:var(--dsw-alias-bg-base);border-bottom:.5px solid var(--dsw-alias-border-l3);position:relative}[data-phone] .vbpo1q_root[data-phase=active] .vbpo1q_header:before{display:none}[data-phone] .vbpo1q_root[data-phase=active]:not(:has([data-slot="conversation.header.notice"]>*)) .vbpo1q_scrollBody{padding-top:0}[data-phone] .vbpo1q_root[data-phase=active]>[data-slot="conversation.header.notice"]:not(:empty){margin-top:0}[data-phone] .vbpo1q_headerCorner:has(button),[data-ds-dark-theme] [data-phone] .vbpo1q_headerCorner:has(button){border:1px solid var(--dsw-alias-border-l3);background:var(--dsw-alias-bg-layer-1);backdrop-filter:none;box-shadow:0 1px 2px #00000014}}@media (prefers-contrast:more){[data-phone] .vbpo1q_headerCorner:has(button),[data-ds-dark-theme] [data-phone] .vbpo1q_headerCorner:has(button){border-color:var(--dsw-alias-label-secondary);box-shadow:none}}@media (forced-colors:active){[data-phone] .vbpo1q_root[data-phase=active] .vbpo1q_header{pointer-events:auto;background:canvas;border-bottom:1px solid canvastext;position:relative}[data-phone] .vbpo1q_root[data-phase=active] .vbpo1q_header:before{display:none}[data-phone] .vbpo1q_root[data-phase=active]:not(:has([data-slot="conversation.header.notice"]>*)) .vbpo1q_scrollBody{padding-top:0}[data-phone] .vbpo1q_root[data-phase=active]>[data-slot="conversation.header.notice"]:not(:empty){margin-top:0}[data-phone] .vbpo1q_headerCorner:has(button),[data-ds-dark-theme] [data-phone] .vbpo1q_headerCorner:has(button){backdrop-filter:none;box-shadow:none;background:buttonface;border:1px solid buttontext}}.vbpo1q_tabs{z-index:1;grid-column:1/-1;gap:36px;margin-top:10px;padding-left:8px;display:flex;position:relative}.vbpo1q_tab{color:var(--dsw-alias-label-tertiary);cursor:pointer;background:0 0;border:none;padding:0 0 9px;font-size:13px;font-weight:500;line-height:16px;position:relative}.vbpo1q_tab:after{content:"";background:0 0;border-radius:2px;height:2px;position:absolute;bottom:-1px;left:0;right:0}.vbpo1q_tabActive{color:var(--dsw-alias-state-business-primary)}.vbpo1q_tabActive:after{background:var(--dsw-alias-state-business-primary)}.vbpo1q_viewArea{flex-direction:column;flex:1;min-height:0;display:flex}.vbpo1q_widthHandle{z-index:0;width:min(10px, calc((100% - var(--dsh-chat-content-width)) / 2 - 24px - 24px));cursor:col-resize;position:absolute;top:0;bottom:0}.vbpo1q_widthHandle[data-side=left]{right:calc(50% + var(--dsh-chat-content-width) / 2 + 24px)}.vbpo1q_widthHandle[data-side=right]{left:calc(50% + var(--dsh-chat-content-width) / 2 + 24px)}.vbpo1q_widthHandle:after{content:"";background:linear-gradient(to bottom, transparent calc(var(--dsh-width-handle-pointer-y,50%) - 36px), var(--dsw-alias-scrollbar-bg-l1) calc(var(--dsh-width-handle-pointer-y,50%) - 8px), var(--dsw-alias-scrollbar-bg-l1) calc(var(--dsh-width-handle-pointer-y,50%) + 8px), transparent calc(var(--dsh-width-handle-pointer-y,50%) + 36px));opacity:0;pointer-events:none;border-radius:2px;width:2px;position:absolute;top:0;bottom:0}.vbpo1q_widthHandle[data-side=left]:after{right:4px}.vbpo1q_widthHandle[data-side=right]:after{left:4px}.vbpo1q_widthHandle:hover:after,.vbpo1q_widthHandle[data-dragging]:after{opacity:1}.vbpo1q_widthHandle[data-dragging]{z-index:8}.vbpo1q_root:has([data-conversation-composer-overlay]) .vbpo1q_widthHandle{display:none}.vbpo1q_composerStack{--dsh-composer-stack-gap:6px;gap:var(--dsh-composer-stack-gap);flex-direction:column;display:flex}.vbpo1q_composerSeat{--dsh-composer-text-max-height:336px;flex-direction:column;flex:none;display:flex}.vbpo1q_root[data-phase=active]{overflow:hidden}.vbpo1q_root[data-phase=active] .vbpo1q_header{flex:none}.vbpo1q_body{--dsh-chat-content-width:var(--dsh-chat-user-width,clamp(680px, calc(var(--dsh-conversation-column-width,0px) * .64), 920px));--dsh-composer-card-max-width:calc(var(--dsh-chat-content-width) + 32px);--dsh-composer-side-clearance:16px;--dsh-composer-dock-inset:8px;flex-direction:column;flex:1;min-height:0;display:flex;position:relative}.vbpo1q_embeddedBody{--dsh-chat-content-width:min(calc(100% - 32px), 920px);--dsh-composer-card-max-width:min(calc(100% - 16px), 952px);--dsh-composer-side-clearance:8px;--dsh-composer-dock-inset:8px;overflow:hidden}.vbpo1q_scrollBody{scrollbar-gutter:stable;flex-direction:column;flex:1;min-height:0;margin-right:2px;display:flex;overflow:hidden auto}.vbpo1q_scrollBody::-webkit-scrollbar-track{margin:2px}.vbpo1q_root[data-phase=active] .vbpo1q_viewArea,.vbpo1q_embeddedBody[data-content-phase=active] .vbpo1q_viewArea{flex:1 0 auto;min-height:auto}.vbpo1q_root[data-phase=active] .vbpo1q_composerSeat,.vbpo1q_embeddedBody[data-content-phase=active] .vbpo1q_composerSeat{z-index:7;background:var(--dsh-phone-composer-mask,linear-gradient(180deg, color-mix(in srgb, var(--dsw-alias-bg-base) 0%, transparent) 0px, var(--dsw-alias-bg-base) 36px));position:sticky;bottom:0}@supports (backdrop-filter:blur(14px)){[data-phone] .vbpo1q_composerSeat:where(:has([data-chain-overlay-fallback=conversation\\.composer]:only-child [data-composer-card])){--dsh-phone-composer-mask:linear-gradient(180deg, transparent 0px, color-mix(in srgb, var(--dsw-alias-bg-base) 60%, transparent) 36px, color-mix(in srgb, var(--dsw-alias-bg-base) 60%, transparent) calc(100% - 28px), var(--dsw-alias-bg-base) 100%)}}@media (prefers-reduced-transparency:reduce),(prefers-contrast:more),(forced-colors:active){[data-phone] .vbpo1q_composerSeat{--dsh-phone-composer-mask:initial}}body[data-codexhost-wallpaper] .vbpo1q_root[data-phase=active] .vbpo1q_composerSeat,body[data-codexhost-wallpaper] .vbpo1q_embeddedBody[data-content-phase=active] .vbpo1q_composerSeat{background:0 0}.vbpo1q_root[data-phase=active] .vbpo1q_composerSeat:has([data-trigger-menu]){z-index:9}.vbpo1q_scrollBody:has([data-conversation-composer-overlay]){scrollbar-gutter:auto;position:relative;overflow:hidden auto}.vbpo1q_scrollBody:has([data-conversation-composer-overlay])>[data-slot=conversation\\.session]>.vbpo1q_viewArea{flex:1 1 0;min-height:0;overflow:hidden}.vbpo1q_scrollBody:has([data-conversation-composer-overlay])>.vbpo1q_composerSeat{right:var(--dsh-scrollbar-width);position:absolute;bottom:0;left:0}.vbpo1q_composerHero{width:min(calc(var(--dsh-composer-card-max-width) + 2 * var(--dsh-composer-side-clearance)), 100%);z-index:1;align-self:center;gap:16px;padding-bottom:32px}.vbpo1q_heroTopBarInner{align-items:center;gap:4px;width:100%;min-width:0;display:flex}.vbpo1q_heroAgentPresetSeat{flex:none;align-items:center;margin-left:auto;display:flex}.vbpo1q_heroAgentPresetSeat:empty{display:none}.vbpo1q_root[data-phase=hero] .vbpo1q_scrollBody,.vbpo1q_embeddedBody[data-content-phase=hero] .vbpo1q_scrollBody{justify-content:center;overflow-y:auto}.vbpo1q_root[data-phase=settling] .vbpo1q_composerSeat,.vbpo1q_embeddedBody[data-content-phase=settling] .vbpo1q_composerSeat{visibility:hidden}`,document.head.appendChild(e)}var Q={body:`vbpo1q_body`,composerHero:`vbpo1q_composerHero`,composerSeat:`vbpo1q_composerSeat`,composerStack:`vbpo1q_composerStack`,crumb:`vbpo1q_crumb`,crumbCurrent:`vbpo1q_crumbCurrent`,crumbSeg:`vbpo1q_crumbSeg`,crumbSep:`vbpo1q_crumbSep`,crumbSubagent:`vbpo1q_crumbSubagent`,crumbs:`vbpo1q_crumbs`,embeddedBody:`vbpo1q_embeddedBody`,header:`vbpo1q_header`,headerActions:`vbpo1q_headerActions`,headerBlank:`vbpo1q_headerBlank`,headerCorner:`vbpo1q_headerCorner`,headerLeading:`vbpo1q_headerLeading`,headerSessionless:`vbpo1q_headerSessionless`,headerUtilities:`vbpo1q_headerUtilities`,heroAgentPresetSeat:`vbpo1q_heroAgentPresetSeat`,heroTopBarInner:`vbpo1q_heroTopBarInner`,phoneTrailingAction:`vbpo1q_phoneTrailingAction`,root:`vbpo1q_root`,scrollBody:`vbpo1q_scrollBody`,tab:`vbpo1q_tab`,tabActive:`vbpo1q_tabActive`,tabs:`vbpo1q_tabs`,titleCenter:`vbpo1q_titleCenter`,titleCluster:`vbpo1q_titleCluster`,titleRow:`vbpo1q_titleRow`,viewArea:`vbpo1q_viewArea`,widthHandle:`vbpo1q_widthHandle`};let EE=`dsh.conversation.contentWidth`;function DE(){let e=localStorage.getItem(EE);if(e===null)return null;let t=Number(e);return Number.isFinite(t)&&t>0?t:null}function OE(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 kE(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 AE(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;
|
|
163
|
+
`),t+=i.draft;for(let t of i.occurrences)n.push({...t,offset:e+t.offset})}let i=new Set(r.map(e=>e.id));this.responseAnnotations=[...r,...this.responseAnnotations.filter(e=>!i.has(e.id))],this.restoringFailures=!0;try{this.draftEditor.restoreDraft(t,n),this.draftEditor.clearHistory(),this.failedRestoreRev=this.rev}finally{this.restoringFailures=!1}this.publish()}restoreAttachments(e){if(e.length===0)return;let t=new Set(this.attachmentIds),n=e.filter(e=>!t.has(e));n.length!==0&&(this.attachmentIds=[...n,...this.attachmentIds],this.publish())}adjudicate(e,t){let n=this.deps.inputTriggers?.();n===void 0?this.dispatchRun({type:`adjudicated`,attempt:e,outcome:void 0}):(this.adjudication=n.adjudicate(t.trim(),e.signal,{attachments:this.attachmentIds.length}),this.adjudication.then(t=>{this.adjudication=void 0,!this.dead(e)&&this.dispatchRun({type:`adjudicated`,attempt:e,outcome:t})},t=>{if(this.adjudication=void 0,this.dead(e))return;let n=t instanceof Error?t.message:String(t);this.dispatchRun({type:`adjudication-failed`,attempt:e,message:n})}))}beginSubmit(e,t,n){let r=t.attachments===!0?[...this.attachmentIds]:[];Promise.resolve().then(async()=>{let i=r.length>0?await this.deps.commandAttachments.serialize(r):[];if(!this.dead(e))return t.submit(n,this.deps.actx,i)}).then(t=>{if(!(t===void 0||this.dead(e))){if(t.kind===`success`&&r.length>0){let e=new Set(r);this.attachmentIds=this.attachmentIds.filter(t=>!e.has(t)),this.deps.commandAttachments.release(r)}this.dispatchRun({type:`submit-settled`,attempt:e,ok:t.kind===`success`,draft:this.projection.clipboardText,outcome:t,...t.kind===`error`&&t.text===void 0?{message:`command failed`}:{}})}},t=>{if(this.dead(e))return;let n=t instanceof Error?t.message:String(t);this.dispatchRun({type:`submit-settled`,attempt:e,ok:!1,draft:this.projection.clipboardText,message:n})})}dead(e){return this.disposed||e.signal.aborted}compose(){let e=this.core.state;return{draft:this.projection.clipboardText,attachmentIds:this.attachmentIds,responseAnnotations:this.responseAnnotations,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`]??$D}}publish(){let e=this.compose();this.state.set(e);let t=this.draftSnapshot;t!==this.lastPublishedDraft&&(this.lastPublishedDraft=t,this.persistDraft?.(t))}};function nO(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 rO=class{rootCtx;t;pendingDraft;shells=/* @__PURE__ */ new WeakMap;constructor(e,t,n){this.rootCtx=e,this.t=t,this.pendingDraft=n}for(e){let t=this.sessions(),n=t.sessionOf(e),r=n===void 0?void 0:t.binding(n.sessionId);if(r===void 0||r.session!==n)throw Error(`conversation.input.for requires a retained Session scope`);return this.shellFor(r)}captureReferenceInsertion(e){let t=this.sessions(),n=this.shells.get(e);if(t.binding(e.sessionId)!==e||n===void 0)return;let r=this.rootCtx.get(`conversation`);if(r===void 0)return;let i=n.actions.captureInsertion(),a=r.blocks.storeFor(e.sessionId),o=this.rootCtx.uiSession.sessionStatus,s=!1,c=()=>{let r=e.session.getSnapshot();return!s&&t.binding(e.sessionId)===e&&r.openState===`open`&&!r.removed&&a.getSnapshot()===void 0&&o.getSnapshot().get(e.sessionId)?.pendingInteraction===void 0&&n.snapshot.draftRev===i.draftRev&&n.canInsertReferences()};return{getSnapshot:c,subscribe:r=>{let i=[t.list.subscribe(r),e.session.subscribe(r),n.state.subscribe(r),a.subscribe(r),o.subscribe(r),n.editor.registerEditableListener(r),n.editor.registerRootListener(r)];return()=>i.forEach(e=>e())},insert:e=>{let t=c();return s=!0,t&&n.insertReferences([e],i)}}}requestDraftInitialization(e,t){if(this.sessions().binding(e.sessionId)!==e)throw Error(`conversation.input.requestDraftInitialization requires a retained Session binding`);return this.shellFor(e).requestDraftInitialization(t)}adoptPendingDraft(e,t){if(this.sessions().binding(e.sessionId)!==e)throw Error(`conversation.input.adoptPendingDraft requires a retained Session binding`);let n=this.pendingDraft?.take(),r=this.shellFor(e);return t===void 0?n!==void 0&&n.text!==``?(r.setDraft(n.text),`applied`):`preserved`:n?.modified?r.requestDraftInitialization({prompt:n.text,clearPreviousDraft:!0}):r.requestDraftInitialization(t)}shellFor(e){let t=this.shells.get(e);if(t!==void 0)return t;let{session:n,ctx:r}=e,i=new tO({actx:r,submissionState:()=>{let e=n.getSnapshot(),t=n.projections.faceOf(`modelSelection`).getSnapshot(),r=n.projections.faceOf(`plan`).getSnapshot(),i=n.projections.faceOf(`goal`).getSnapshot(),a=t?.next??t?.lastUsed;return Object.freeze({...e.blank?{}:{sessionId:e.sessionId},...a==null?{}:{model:Object.freeze({provider:a.provider,name:a.model,...a.reasoningEffort===void 0?{}:{effort:a.reasoningEffort}})},runMode:r?.active?`plan`:i?.goal.phase===`active`?`goal`:`default`,running:e.running})},messageSubmitted:e=>{nO(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(Pu(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 iO=/* @__PURE__ */ new Map;var aO=class{runtime;unregister;textStore=(0,f.createSnapshotStore)(``);activeToken=null;modified=!1;seeding=!1;text=this.textStore;constructor(){this.runtime=new XD({onUpdate:()=>{let e=this.runtime.refreshProjection(),t=this.runtime.projection.clipboardText;e.clipboardText!==t&&(this.seeding||(this.modified=!0),this.textStore.set(t))},openReference:()=>!1,activeClaimToken:()=>null,lexicon:()=>iO,resolveLexicon:()=>void 0}),this.unregister=this.runtime.register()}get editor(){return this.runtime.editor}syncCreation(e){if(e.state===`idle`){(this.activeToken!==null||this.textStore.getSnapshot()!==``)&&(this.activeToken=null,this.clearEditor());return}let t=e.token??null;t!==this.activeToken&&(this.activeToken=t,this.seed(e.initialPrompt??``))}paste(e){this.runtime.paste(e)}take(){if(this.activeToken===null)return;let e={text:this.runtime.projection.clipboardText,modified:this.modified};return this.activeToken=null,this.clearEditor(),e}dispose(){this.activeToken=null,this.unregister()}seed(e){this.seeding=!0;try{this.modified=!1,this.runtime.setDraft(e),this.runtime.clearHistory(),this.textStore.set(this.runtime.projection.clipboardText)}finally{this.seeding=!1}}clearEditor(){this.seed(``)}};let oO=`busyEnter`,sO=[`queue`,`steer`],cO=`queue`,lO={[oO]:C.union([...sO]).default(cO)};C.object(lO);function uO(e,t,n,r){return!t||!r?`queue`:n===`enter`?e:e===`queue`?`steer`:`queue`}var dO=class{busyEnter=(0,f.createSnapshotStore)(cO);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(oO,e))}adopt(e){let t=e.getSnapshot().value;t!==void 0&&this.busyEnter.getSnapshot()!==t.busyEnter&&this.busyEnter.set(t.busyEnter)}};async function fO(e,t){let n=/* @__PURE__ */ new Map;for(let t of e)n.has(t.attachmentId)||n.set(t.attachmentId,t);let r=/* @__PURE__ */ new Map;return await Promise.all([...n.entries()].map(async([e,n])=>{let i=await t(n),a=await fetch(i);if(!a.ok)throw Error(`Queued image preview fetch failed (${a.status})`);r.set(e,{blob:await a.blob(),mediaType:n.mediaType})})),r}function pO(e){let{sessionId:t,shell:n,conversation:r,message:i,imageBlobs:a}=e,o=()=>{if(n.isDisposed)throw Error(`Queued message was removed, but the session composer was closed before restoring.`);let{phase:e}=n.snapshot;if(e!==`plain`&&e!==`claimed`)return!1;if(i.attachments.length>0){let e=i.attachments.map(e=>{if(e.kind!==`image`)return e;let t=a.get(e.file.attachmentId);if(t===void 0)return e;let n=new File([t.blob],e.file.name,{type:t.blob.type||t.mediaType||`image/png`});return{...e,imageFile:n}}),o=r.restoreStagedDrafts(t,e);if(!n.addAttachments(o.map(e=>e.id))){if(r.releaseDraftAttachments(o),n.isDisposed)throw Error(`Queued message was removed, but the session composer was closed before restoring.`);return!1}}if(i.text!==``){let e=n.draftSnapshot;n.setDraft({...e,text:e.text===``?i.text:`${e.text}\n${i.text}`})}return n.actions.persistDraft(),n.focus(`end`),!0};try{if(o())return Promise.resolve()}catch(e){return Promise.reject(e)}return new Promise((e,t)=>{let r=!1,i=!1,a,s=()=>{if(!(r||i)){i=!0;try{if(!o())return;r=!0,a?.(),e()}catch(e){r=!0,a?.(),t(e)}finally{i=!1}}};a=n.state.subscribe(s),s()})}let mO=`@deepseek-ai/dsh-client-ui-conversation/QueueDock.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(mO)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-conversation`,e.dataset.pluginCss=mO,e.textContent=`.ZMI-0G_dock{box-sizing:border-box;width:calc(100% - var(--dsh-composer-side-clearance) - var(--dsh-composer-side-clearance) - var(--dsh-composer-dock-inset) - var(--dsh-composer-dock-inset));max-width:calc(var(--dsh-composer-card-max-width) - var(--dsh-composer-dock-inset) - var(--dsh-composer-dock-inset));margin:0 auto calc(0px - var(--dsh-composer-stack-gap) - 3px);padding:0 var(--dsh-composer-dock-inset);flex:none}.ZMI-0G_pendingAttachment{flex-direction:column;gap:2px;display:inline-flex}.ZMI-0G_panel{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}.ZMI-0G_panel:before{z-index:-1;border-radius:inherit;background:var(--dsw-specific-menu);backdrop-filter:var(--dsw-menu-backdrop-filter);content:"";pointer-events:none;position:absolute;inset:0}.ZMI-0G_panel:after{border:.5px solid var(--dsw-alias-border-l1);border-radius:inherit;content:"";pointer-events:none;border-bottom:none;position:absolute;inset:0}.ZMI-0G_paused{color:var(--dsw-alias-label-tertiary);font:var(--dsw-font-xs-13);padding:6px 12px 2px}.ZMI-0G_header{box-sizing:border-box;border-radius:var(--dsw-radius-md);width:100%;height:36px;color:var(--dsw-alias-label-primary);text-align:left;cursor:pointer;background:0 0;border:none;align-items:center;gap:10px;padding:4px 12px;display:flex}.ZMI-0G_header:focus-visible{outline:var(--dsw-focus-ring-width) solid var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary));outline-offset:-2px}.ZMI-0G_header:disabled{cursor:default}.ZMI-0G_lead{color:var(--dsw-alias-label-tertiary);flex:none;place-items:center;display:grid}.ZMI-0G_count{min-width:0;font-family:Inter, var(--dsw-font-family);flex:auto;font-size:13px;font-weight:500;line-height:24px}.ZMI-0G_chevron{width:14px;height:14px;color:var(--dsw-alias-label-tertiary);flex:none;place-items:center;display:grid}.ZMI-0G_list{max-height:180px;margin:0;padding:0;list-style:none;overflow-y:auto}.ZMI-0G_row{box-sizing:border-box;border-radius:var(--dsw-radius-md);align-items:center;gap:10px;width:100%;min-height:36px;padding:4px 5px 4px 12px;display:flex}.ZMI-0G_row+.ZMI-0G_row{box-shadow:inset 0 1px 0 var(--dsw-alias-border-l1)}.ZMI-0G_attachments{flex:none;gap:4px;min-width:0;max-width:55%;display:flex;overflow:hidden}.ZMI-0G_pendingRow .ZMI-0G_attachments{flex-shrink:1}.ZMI-0G_file{border:.5px solid var(--dsw-alias-border-l1);border-radius:var(--dsw-radius-sm);background:var(--dsw-alias-bg-base);box-sizing:border-box;flex:0 180px;align-items:center;gap:4px;min-width:74px;height:24px;padding:0 6px;display:inline-flex;overflow:hidden}.ZMI-0G_fileIcon{flex:none;width:16px;height:16px;display:inline-flex}.ZMI-0G_fileName{min-width:0;color:var(--dsw-alias-label-primary-dimmed);font:var(--dsw-font-xs-13);text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.ZMI-0G_fileSize{color:var(--dsw-alias-label-tertiary);white-space:nowrap;flex:none;font-size:10px}.ZMI-0G_thumb{border:.5px solid var(--dsw-alias-border-l1);border-radius:var(--dsw-radius-xs);background:var(--dsw-alias-bg-base);object-fit:cover;width:24px;height:24px}.ZMI-0G_preview{min-width:0;font:var(--dsw-font-xs-13);font-family:Inter, var(--dsw-font-family);color:var(--dsw-alias-label-primary-dimmed);text-overflow:ellipsis;white-space:nowrap;word-break:break-word;flex:auto;overflow:hidden}.ZMI-0G_actions{flex:none;align-items:center;gap:10px;display:flex}.ZMI-0G_actionWrap{flex:none;display:inline-flex}.ZMI-0G_actionWrap>.ZMI-0G_action:disabled{pointer-events:none}.ZMI-0G_status{color:var(--dsw-alias-label-tertiary);font:var(--dsw-font-xs-13);white-space:nowrap;flex:none}.ZMI-0G_action{corner-shape:round;width:28px;height:28px;color:var(--dsw-alias-label-tertiary);cursor:pointer;background:0 0;border:none;border-radius:999px;flex:none;place-items:center;padding:0;display:grid}.ZMI-0G_action:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-hover)}.ZMI-0G_action:focus-visible{outline:var(--dsw-focus-ring-width) solid var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary));outline-offset:-2px}.ZMI-0G_action:disabled{cursor:default;opacity:.45}`,document.head.appendChild(e)}var Z={action:`ZMI-0G_action`,actionWrap:`ZMI-0G_actionWrap`,actions:`ZMI-0G_actions`,attachments:`ZMI-0G_attachments`,chevron:`ZMI-0G_chevron`,count:`ZMI-0G_count`,dock:`ZMI-0G_dock`,file:`ZMI-0G_file`,fileIcon:`ZMI-0G_fileIcon`,fileName:`ZMI-0G_fileName`,fileSize:`ZMI-0G_fileSize`,header:`ZMI-0G_header`,lead:`ZMI-0G_lead`,list:`ZMI-0G_list`,panel:`ZMI-0G_panel`,paused:`ZMI-0G_paused`,pendingAttachment:`ZMI-0G_pendingAttachment`,pendingRow:`ZMI-0G_pendingRow`,preview:`ZMI-0G_preview`,row:`ZMI-0G_row`,status:`ZMI-0G_status`,thumb:`ZMI-0G_thumb`};let hO=[];function gO(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 _O(e){return e.every(e=>e.type===`text`)?e.map(e=>e.text).join(``):null}function vO(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 yO({attachment:e,label:t}){return/* @__PURE__ */ (0,h.jsxs)(`span`,{className:Z.file,"aria-label":t,title:e.name,children:[/* @__PURE__ */ (0,h.jsx)(`span`,{className:Z.fileIcon,"aria-hidden":!0,children:/* @__PURE__ */ (0,h.jsx)(d.FileTypeIcon,{path:e.name,size:16})}),/* @__PURE__ */ (0,h.jsx)(`span`,{className:Z.fileName,children:e.name}),/* @__PURE__ */ (0,h.jsx)(`span`,{className:Z.fileSize,children:(0,d.fileSizeText)(e.bytes)})]})}function bO({attachment:e,loadImage:t,label:n}){let[r,i]=(0,g.useState)(null);return(0,g.useEffect)(()=>{let n=!0;return t(e).then(e=>{n&&i(e)},()=>{}),()=>{n=!1}},[e,t]),r===null?/* @__PURE__ */ (0,h.jsx)(`span`,{className:Z.thumb,"aria-hidden":!0}):/* @__PURE__ */ (0,h.jsx)(`img`,{className:Z.thumb,src:r,alt:n})}function xO({upload:e,t}){let n=(0,g.useSyncExternalStore)(e.subscribe,e.getSnapshot);return n?.status===`uploading`?/* @__PURE__ */ (0,h.jsx)(`span`,{className:Z.status,role:`status`,"data-upload-progress":!0,children:n.total===void 0||n.total===0?t(`file.uploading`):t(`file.uploadingPercent`,{percent:Math.round(Math.min(1,(n.loaded??0)/n.total)*100)})}):null}function SO({useSession:e,useProjection:t,updateQueue:n,editQueue:r,hasStructuredQueueEdit:i,notify:a,loadImage:o,t:s}){let c=t(`inbox`),l=t(`queueState`),u=e(e=>e.pendingSubmissions),f=(0,g.useMemo)(()=>{let e=c?.[`next-turn`]??hO,t=new Set(u.filter(e=>e.placement===`transcript`).map(e=>e.requestId));return t.size===0?e:e.filter(({source:e})=>e.kind!==`user`||!(`rpcId`in e)||!t.has(e.rpcId))},[c,u]),p=(0,g.useMemo)(()=>{let e=new Set(f.flatMap(({source:e})=>e.kind===`user`&&`rpcId`in e?[e.rpcId]:[]));return u.filter(t=>t.placement===`queued`&&!e.has(t.requestId))},[u,f]),m=f.length+p.length,_=e(e=>e.running),v=e(e=>e.subagent===null||e.subagent.address.mode===`continuable`)&&l?.stale!==!0,y=l?.previewOnly===!0,b=(0,g.useRef)(!1),[x,ee]=(0,g.useState)(null),[te,ne]=(0,g.useState)(!0),re=(0,g.useId)(),ie=l?.pausedReason??null,ae=ie===`interrupted`?s(`queue.paused.interrupted`):ie===`outcome-unknown`?s(`queue.paused.unknown`):ie===`failed`?s(`queue.paused.failed`):null;if((0,g.useEffect)(()=>{m===0&&!te&&ne(!0)},[te,m]),m===0)return null;let oe=v&&x!==null,se=!te||oe,ce=m===1||se,le=async(e,t,r)=>{if(b.current)return!1;b.current=!0,ee(e);try{return typeof t==`function`?await t():await n(e,t),!0}catch{return a(`error`,y?s(`queue.remoteActionFailed`):r),!1}finally{b.current=!1,ee(t=>t===e?null:t)}};return/* @__PURE__ */ (0,h.jsx)(`div`,{className:Z.dock,"data-queue-dock":``,children:/* @__PURE__ */ (0,h.jsxs)(`div`,{className:Z.panel,children:[l?.stale&&/* @__PURE__ */ (0,h.jsx)(`div`,{className:Z.paused,role:`status`,children:s(`queue.remoteStale`)}),ae!==null&&/* @__PURE__ */ (0,h.jsx)(`div`,{className:Z.paused,role:`status`,children:ae}),m>1&&/* @__PURE__ */ (0,h.jsxs)(`button`,{type:`button`,className:Z.header,"aria-controls":re,"aria-expanded":se,disabled:oe,onClick:()=>{ne(e=>!e)},children:[/* @__PURE__ */ (0,h.jsx)(`span`,{className:Z.lead,"aria-hidden":!0,children:/* @__PURE__ */ (0,h.jsx)(d.IconQueueOutlineRegular,{})}),/* @__PURE__ */ (0,h.jsx)(`span`,{className:Z.count,children:s(`queue.count`,{n:m})}),!ce&&p.length>0&&/* @__PURE__ */ (0,h.jsx)(`span`,{className:Z.status,role:`status`,children:s(`queue.sending`)}),/* @__PURE__ */ (0,h.jsx)(`span`,{className:Z.chevron,"aria-hidden":!0,children:se?/* @__PURE__ */ (0,h.jsx)(d.IconChevronDownOutlineRegular,{}):/* @__PURE__ */ (0,h.jsx)(d.IconChevronUpOutlineRegular,{})})]}),/* @__PURE__ */ (0,h.jsxs)(`ul`,{id:re,className:Z.list,hidden:!ce,children:[ce&&f.map(e=>{let t=vO(e.content),n=l?.editable===void 0?(()=>{let t=_O(e.content);return t===null?null:{kind:`legacyText`,text:t}})():(()=>{let n=l.editable?.[e.id];return n===void 0||!i()?null:{kind:`structured`,revision:n,images:t.flatMap(e=>e.type===`image`?[e.attachment]:[])}})(),a=n!==null;return/* @__PURE__ */ (0,h.jsxs)(`li`,{className:Z.row,children:[m===1&&/* @__PURE__ */ (0,h.jsx)(`span`,{className:Z.lead,"aria-hidden":!0,children:/* @__PURE__ */ (0,h.jsx)(d.IconQueueOutlineRegular,{})}),t.length>0&&/* @__PURE__ */ (0,h.jsx)(`span`,{className:Z.attachments,children:t.map((e,t)=>e.type===`image`?/* @__PURE__ */ (0,h.jsx)(bO,{attachment:e.attachment,loadImage:o,label:s(`queue.image`)},`${e.attachment.attachmentId}:${t}`):/* @__PURE__ */ (0,h.jsx)(yO,{attachment:e.attachment,label:s(`queue.file`,{name:e.attachment.name})},`${e.attachment.attachmentId}:${e.attachment.name}:${t}`))}),/* @__PURE__ */ (0,h.jsx)(`span`,{className:Z.preview,children:(0,d.projectUserText)(gO(e.content),[])}),v&&/* @__PURE__ */ (0,h.jsxs)(`div`,{className:Z.actions,children:[!y&&/* @__PURE__ */ (0,h.jsx)(d.Tooltip,{portal:!0,label:s(a?`queue.edit`:`queue.edit.unsupported`),side:`bottom`,delayMs:500,children:/* @__PURE__ */ (0,h.jsx)(`span`,{className:Z.actionWrap,children:/* @__PURE__ */ (0,h.jsx)(`button`,{type:`button`,className:Z.action,"aria-label":s(`queue.edit`),disabled:x!==null||!a,onClick:()=>{n!==null&&le(e.id,()=>r(e.id,n),s(`queue.editFailed`))},children:/* @__PURE__ */ (0,h.jsx)(d.IconEditOutlineRegular,{size:14})})})}),/* @__PURE__ */ (0,h.jsx)(d.Tooltip,{portal:!0,label:s(`queue.remove`),side:`bottom`,delayMs:500,children:/* @__PURE__ */ (0,h.jsx)(`button`,{type:`button`,className:Z.action,"aria-label":s(`queue.remove`),disabled:x!==null,onClick:()=>{le(e.id,{kind:`remove`},s(`queue.removeFailed`))},children:/* @__PURE__ */ (0,h.jsx)(d.IconTrashOutlineRegular,{size:14})})}),(!y||!_)&&/* @__PURE__ */ (0,h.jsx)(d.Tooltip,{portal:!0,label:s(_?`queue.steer`:`queue.resume`),side:`bottom`,delayMs:500,children:/* @__PURE__ */ (0,h.jsx)(`button`,{type:`button`,className:Z.action,"aria-label":s(_?`queue.steer`:`queue.resume`),disabled:x!==null,onClick:()=>{le(e.id,{kind:`steer`},s(_?`queue.steerFailed`:`queue.resumeFailed`))},children:/* @__PURE__ */ (0,h.jsx)(d.IconSendOutlineRegular,{})})})]})]},e.id)}),ce&&p.map(e=>/* @__PURE__ */ (0,h.jsxs)(`li`,{className:`${Z.row} ${Z.pendingRow}`,"data-submission-echo":``,children:[m===1&&/* @__PURE__ */ (0,h.jsx)(`span`,{className:Z.lead,"aria-hidden":!0,children:/* @__PURE__ */ (0,h.jsx)(d.IconQueueOutlineRegular,{})}),e.attachments.length>0&&/* @__PURE__ */ (0,h.jsx)(`span`,{className:Z.attachments,children:e.attachments.map((e,t)=>/* @__PURE__ */ (0,h.jsxs)(`span`,{className:Z.pendingAttachment,children:[e.type===`image`?/* @__PURE__ */ (0,h.jsx)(`img`,{className:Z.thumb,src:e.value.previewUrl,alt:s(`queue.image`)}):/* @__PURE__ */ (0,h.jsx)(yO,{attachment:e.value,label:s(`queue.file`,{name:e.value.name})}),e.upload&&/* @__PURE__ */ (0,h.jsx)(xO,{upload:e.upload,t:s})]},t))}),/* @__PURE__ */ (0,h.jsx)(`span`,{className:Z.preview,children:(0,d.projectUserText)(e.text,[])}),/* @__PURE__ */ (0,h.jsx)(`span`,{className:Z.status,role:`status`,children:s(`queue.sending`)}),v&&!y&&/* @__PURE__ */ (0,h.jsxs)(`div`,{className:Z.actions,children:[/* @__PURE__ */ (0,h.jsx)(`button`,{type:`button`,className:Z.action,"aria-label":s(`queue.edit`),title:s(`queue.sending`),disabled:!0,children:/* @__PURE__ */ (0,h.jsx)(d.IconEditOutlineRegular,{size:14})}),/* @__PURE__ */ (0,h.jsx)(`button`,{type:`button`,className:Z.action,"aria-label":s(`queue.remove`),title:s(`queue.sending`),disabled:!0,children:/* @__PURE__ */ (0,h.jsx)(d.IconTrashOutlineRegular,{size:14})}),/* @__PURE__ */ (0,h.jsx)(`button`,{type:`button`,className:Z.action,"aria-label":s(`queue.steer`),title:s(`queue.sending`),disabled:!0,children:/* @__PURE__ */ (0,h.jsx)(d.IconSendOutlineRegular,{})})]})]},e.requestId))]})]})})}let CO={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:zu,inject:n=>{let r=e.sessions.scope(n);if(r===void 0)throw Error(`queue dock: session "${n}" resolved no scope`);let i=r.get(`conversation`);if(i===void 0)throw Error(`queue dock: conversation service unavailable`);let a=t=>e.uiConversation.imageUrl(n,t);return{updateQueue:(e,t)=>i.updateQueue(e,t),hasStructuredQueueEdit:()=>{let t=e.get(`conversation`);return e.get(`queueMessageEditing`)!==void 0&&typeof t?.restoreStagedDrafts==`function`},editQueue:async(r,o)=>{let s=e.sessions.retain(n,{source:`controllerOperation`});try{let s=t.shell(n);if(o.kind===`legacyText`){if(await i.updateQueue(r,{kind:`remove`}),s.isDisposed)throw Error(`Queued message was removed, but the session composer was closed before restoring.`);let e=s.draftSnapshot;s.setDraft({...e,text:e.text===``?o.text:`${e.text}\n${o.text}`}),s.actions.persistDraft(),s.focus(`end`);return}let c=e.get(`queueMessageEditing`),l=e.get(`conversation`);if(c===void 0||typeof l?.restoreStagedDrafts!=`function`)throw Error(`queue dock: structured queue editing unavailable`);let u=o.images.length>0?await fO(o.images,a):/* @__PURE__ */ new Map;if(s.isDisposed)throw Error(`queue dock: session composer closed before editing`);await pO({sessionId:n,shell:s,conversation:l,message:await c.takeForEdit(n,r,o.revision),imageBlobs:u})}finally{s.release()}},notify:(t,a)=>{e.sessions.scope(n)===r&&i.input.for(r).notify(t,a)},loadImage:a}}},SO))}},wO=`@deepseek-ai/dsh-client-ui-conversation/EnterBehaviorRow.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(wO)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-conversation`,e.dataset.pluginCss=wO,e.textContent=`.v-9l-a_row{border-bottom:.5px solid var(--dsw-alias-border-l2);align-items:center;gap:8px;padding:16px 0;display:flex}.v-9l-a_rowText{flex-direction:column;flex:1;gap:4px;min-width:0;padding-right:48px;display:flex}.v-9l-a_title{color:var(--dsw-alias-label-primary);font-size:14px;font-weight:400;line-height:22px}.v-9l-a_desc{color:var(--dsw-alias-label-tertiary);font-size:12px;font-weight:400;line-height:18px}.v-9l-a_selector{border-radius:var(--dsw-radius-md);background:var(--dsw-alias-bg-module-platform);height:36px;font:inherit;color:var(--dsw-alias-label-primary);cursor:pointer;border:none;align-items:center;gap:12px;padding:0 14px;font-size:14px;line-height:22px;display:inline-flex}.v-9l-a_selector:hover{background:var(--dsw-alias-interactive-bg-hover)}.v-9l-a_chevron{flex:none}`,document.head.appendChild(e)}var TO={chevron:`v-9l-a_chevron`,desc:`v-9l-a_desc`,row:`v-9l-a_row`,rowText:`v-9l-a_rowText`,selector:`v-9l-a_selector`,title:`v-9l-a_title`};let EO=[{id:`queue`,label:`settings.enter.queue`},{id:`steer`,label:`settings.enter.steer`}];function DO({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:TO.row,children:[/* @__PURE__ */ (0,h.jsxs)(`div`,{className:TO.rowText,children:[/* @__PURE__ */ (0,h.jsx)(`div`,{className:TO.title,children:n(`settings.enter.title`)}),/* @__PURE__ */ (0,h.jsx)(`div`,{className:TO.desc,children:n(`settings.enter.description`)})]}),/* @__PURE__ */ (0,h.jsx)(d.Menu,{open:i,onClose:()=>{a(!1)},items:EO.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:TO.selector,"aria-haspopup":`menu`,"aria-expanded":i,onClick:()=>{a(e=>!e)},children:[n(o),/* @__PURE__ */ (0,h.jsx)(d.IconChevronDownOutlineRegular,{className:TO.chevron})]})})]})}let OO={views:{get:()=>void 0,grouped:()=>void 0},activeTargets:/* @__PURE__ */ new Set};function kO(e,t){return t.activeTargets.size>0||!e.blank&&!e.awaitingFirstTurn||e.running?`active`:e.promptAttempted?`engaging`:`blank`}let AO=`@deepseek-ai/dsh-client-ui-conversation/ConversationRoot.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(AO)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-conversation`,e.dataset.pluginCss=AO,e.textContent=`.vbpo1q_root{background:var(--dsw-alias-bg-base);flex-direction:column;min-width:0;height:100%;display:flex;position:relative}body[data-codexhost-wallpaper] .vbpo1q_root{background:0 0}.vbpo1q_header{box-sizing:border-box;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}.vbpo1q_header:where(:not(:has(.vbpo1q_tabs))){border-bottom:none;min-height:0;padding:10px 24px 6px 20px}[data-windows-titlebar] .vbpo1q_header:where(:not(:has(.vbpo1q_tabs))){padding-top:8px;padding-bottom:4px}.vbpo1q_headerBlank{border-bottom:none;min-height:0;padding-bottom:0}.vbpo1q_headerBlank .vbpo1q_headerCorner{margin-left:auto}html:not([data-platform=darwin]) .vbpo1q_headerSessionless{padding-top:0}html:not([data-platform=darwin]) .vbpo1q_headerSessionless .vbpo1q_titleRow{min-height:0}[data-platform=darwin] .vbpo1q_headerLeading,[data-platform=darwin] .vbpo1q_headerActions,[data-platform=darwin] .vbpo1q_headerUtilities,[data-platform=darwin] .vbpo1q_headerCorner{-webkit-app-region:no-drag}.vbpo1q_titleRow{min-height:30px;grid-column:2;align-items:center;gap:0;padding-inline-start:max(0px, calc(var(--dsh-frame-leading-clearance,0px) - 20px));display:flex;container-type:inline-size}.vbpo1q_titleCenter{display:contents}.vbpo1q_phoneTrailingAction{display:none}.vbpo1q_titleCluster{flex:1;align-items:center;gap:10px;min-width:0;display:flex}.vbpo1q_headerLeading{flex:none;grid-area:1/1;align-items:center;gap:8px;display:flex}.vbpo1q_crumbs{white-space:nowrap;align-items:center;gap:4px;min-width:0;display:flex;overflow:hidden}.vbpo1q_crumbSeg{align-items:center;gap:4px;min-width:0;display:inline-flex}.vbpo1q_crumbSep{color:var(--dsw-alias-label-caption);font-size:14px;line-height:20px}.vbpo1q_crumb{border-radius:var(--dsw-radius-md);max-width:220px;color:var(--dsw-alias-label-tertiary);text-overflow:ellipsis;white-space:nowrap;cursor:pointer;background:0 0;border:none;padding:4px 8px;font-size:14px;line-height:20px;display:inline-block;overflow:hidden}.vbpo1q_crumbSubagent{font-size:12px;line-height:18px}button.vbpo1q_crumb:hover{background:var(--dsw-alias-interactive-bg-hover)}.vbpo1q_crumbCurrent{color:var(--dsw-alias-label-primary);cursor:default;font-weight:500}.vbpo1q_headerActions{flex:none;align-items:center;gap:8px;display:flex}.vbpo1q_headerUtilities{flex:none;align-items:center;gap:8px;margin-left:20px;display:flex}.vbpo1q_headerUtilities:empty{display:none}.vbpo1q_headerCorner{flex:none;align-items:center;margin-left:8px;margin-right:-16px;display:flex}.vbpo1q_headerCorner:empty,.vbpo1q_headerCorner:not(:has([data-slot="conversation.session.header.corner"]>*)){display:none}[data-phone] .vbpo1q_root[data-phase=active]{--dsh-phone-header-height:calc(env(safe-area-inset-top) + 44px)}[data-phone] .vbpo1q_root[data-phase=active]:has([data-slot="conversation.header.shortcuts"] nav){--dsh-phone-header-height:calc(env(safe-area-inset-top) + 88px)}[data-phone] .vbpo1q_header{z-index:8;padding-top:env(safe-area-inset-top);background:0 0;border-bottom:none;row-gap:0;padding-bottom:0;position:relative}[data-phone] .vbpo1q_root[data-phase=active] .vbpo1q_header{pointer-events:none;position:absolute;top:0;left:0;right:0}[data-phone] .vbpo1q_root[data-phase=active] .vbpo1q_header [data-slot="conversation.header.shortcuts"]{pointer-events:auto}[data-phone] .vbpo1q_root[data-phase=active]:not(:has([data-slot="conversation.header.notice"]>*)) .vbpo1q_scrollBody{padding-top:var(--dsh-phone-header-height)}[data-phone] .vbpo1q_root[data-phase=active]>[data-slot="conversation.header.notice"]:not(:empty){margin-top:var(--dsh-phone-header-height);z-index:5;position:relative}[data-phone] .vbpo1q_root[data-phase=active] .vbpo1q_header:before{content:"";height:calc(var(--dsh-phone-header-height) + 32px);z-index:-1;background:linear-gradient(180deg, color-mix(in srgb, var(--dsw-alias-bg-base) 78%, transparent) 0%, color-mix(in srgb, var(--dsw-alias-bg-base) 58%, transparent) 44%, color-mix(in srgb, var(--dsw-alias-bg-base) 24%, transparent) 74%, transparent 100%);pointer-events:none;position:absolute;top:0;left:0;right:0}@supports (backdrop-filter:blur(16px)){[data-phone] .vbpo1q_root[data-phase=active] .vbpo1q_header:before{backdrop-filter:blur(16px)saturate(140%);-webkit-mask-image:linear-gradient(#000 0%,#000000eb 42%,#0000008f 62%,#00000038 78%,#0000000d 91%,#0000 100%);mask-image:linear-gradient(#000 0%,#000000eb 42%,#0000008f 62%,#00000038 78%,#0000000d 91%,#0000 100%)}}body[data-codexhost-wallpaper] [data-phone] .vbpo1q_root[data-phase=active] .vbpo1q_header:before{background:linear-gradient(180deg, color-mix(in srgb, var(--dsw-alias-bg-base) 64%, transparent) 0%, color-mix(in srgb, var(--dsw-alias-bg-base) 42%, transparent) 44%, color-mix(in srgb, var(--dsw-alias-bg-base) 16%, transparent) 74%, transparent 100%)}[data-phone] .vbpo1q_headerLeading{display:none}[data-phone] .vbpo1q_titleRow{grid-area:1/1/auto/-1;grid-template-columns:minmax(80px,1fr) minmax(0,auto) minmax(80px,1fr);align-items:center;gap:6px;min-height:44px;margin-inline:-8px -16px;padding-inline-start:0;display:grid}[data-phone] .vbpo1q_titleCluster{grid-column:2;justify-content:center;align-items:center;gap:4px;min-width:0;max-width:100%;display:flex}[data-phone] .vbpo1q_titleCenter{pointer-events:auto;border-radius:8px;justify-content:center;align-items:center;gap:4px;min-width:0;max-width:100%;min-height:36px;padding:0 2px;transition:opacity .12s;display:inline-flex;position:relative}[data-phone] .vbpo1q_root[data-phase=active] .vbpo1q_titleCenter:before{content:"";z-index:-1;background:radial-gradient(closest-side, color-mix(in srgb, var(--dsw-alias-bg-base) 88%, transparent) 38%, color-mix(in srgb, var(--dsw-alias-bg-base) 42%, transparent) 72%, transparent 100%);pointer-events:none;position:absolute;inset:-4px -22px}body[data-codexhost-wallpaper] [data-phone] .vbpo1q_root[data-phase=active] .vbpo1q_titleCenter:before{background:radial-gradient(closest-side, color-mix(in srgb, var(--dsw-alias-bg-base) 68%, transparent) 38%, color-mix(in srgb, var(--dsw-alias-bg-base) 28%, transparent) 72%, transparent 100%)}body[data-codexhost-wallpaper][data-ds-dark-theme] [data-phone] .vbpo1q_titleCenter{text-shadow:0 1px 10px #0000006b}[data-phone] .vbpo1q_titleCenter:has([data-navigation-focus-return]){cursor:pointer;-webkit-tap-highlight-color:transparent}[data-phone] .vbpo1q_titleRow>.vbpo1q_titleCenter,[data-phone] .vbpo1q_titleRow>[data-slot="conversation.header.navigation"]{pointer-events:auto;grid-column:2;justify-self:center}[data-phone] .vbpo1q_titleCenter>[data-slot="conversation.header.navigation"]{display:contents}[data-phone] .vbpo1q_titleCenter:has([data-navigation-focus-return]):active{opacity:.52}[data-phone] .vbpo1q_titleCenter:has([data-navigation-focus-return]:focus-visible){outline:none}@media (hover:hover) and (pointer:fine){[data-phone] .vbpo1q_titleCenter:has([data-navigation-focus-return]:focus-visible){outline:2px solid var(--dsw-alias-label-primary);outline-offset:2px}}[data-phone] .vbpo1q_crumbs{justify-content:center;gap:3px}[data-phone] .vbpo1q_crumb{letter-spacing:-.015em;max-width:none;padding:0;font-size:15px;font-weight:600;line-height:20px}[data-phone] button.vbpo1q_crumb{z-index:1;position:relative}[data-phone] .vbpo1q_headerActions:not(:has(button)),[data-phone] .vbpo1q_headerUtilities{display:none}[data-phone] .vbpo1q_phoneTrailingAction,[data-phone] .vbpo1q_headerCorner>[data-slot="conversation.session.header.corner"],[data-phone] .vbpo1q_phoneTrailingAction>[data-slot="conversation.header.trailing"]{display:contents}[data-phone] .vbpo1q_headerCorner:has(button){box-sizing:border-box;corner-shape:round;pointer-events:auto;background:#ffffffd6;border:.5px solid #0f11151a;border-radius:9999px;grid-column:3;justify-content:center;justify-self:end;align-items:center;gap:2px;height:36px;margin:0;padding:0 3px;display:inline-flex;box-shadow:inset 0 1px #ffffffb8,inset 0 -.5px #ffffff47,inset 0 0 0 .5px #ffffff38,0 1px 2px #0f11150d,0 6px 18px -4px #0f11151c}[data-phone] .vbpo1q_headerCorner:has(button):not(:has([data-phone-new-session]):has([data-sidebar-right-expand])){width:36px;padding:0}[data-ds-dark-theme] [data-phone] .vbpo1q_headerCorner:has(button){background:#24262cc7;border-color:#ffffff24;box-shadow:inset 0 1px #ffffff47,inset 0 -.5px #ffffff14,0 2px 8px #00000042,0 8px 22px -6px #0000006b}@supports (backdrop-filter:blur(8px)){[data-phone] .vbpo1q_headerCorner:has(button){backdrop-filter:blur(8px)saturate(180%);background:linear-gradient(#ffffff38 0%,#ffffff17 100%);box-shadow:inset 0 1px .5px #ffffffd9,inset 0 -.5px #0f11150f,0 1px 2px #0f11150f,0 6px 16px -4px #0f11151f}[data-ds-dark-theme] [data-phone] .vbpo1q_headerCorner:has(button){backdrop-filter:blur(10px)saturate(180%);background:linear-gradient(#ffffff1f 0%,#ffffff0d 100%)}}@media (prefers-reduced-motion:reduce){[data-phone] .vbpo1q_titleCenter{transition:none}}@media (prefers-reduced-transparency:reduce),(prefers-contrast:more){[data-phone] .vbpo1q_root[data-phase=active] .vbpo1q_header{pointer-events:auto;background:var(--dsw-alias-bg-base);border-bottom:.5px solid var(--dsw-alias-border-l3);position:relative}[data-phone] .vbpo1q_root[data-phase=active] .vbpo1q_header:before{display:none}[data-phone] .vbpo1q_root[data-phase=active]:not(:has([data-slot="conversation.header.notice"]>*)) .vbpo1q_scrollBody{padding-top:0}[data-phone] .vbpo1q_root[data-phase=active]>[data-slot="conversation.header.notice"]:not(:empty){margin-top:0}[data-phone] .vbpo1q_headerCorner:has(button),[data-ds-dark-theme] [data-phone] .vbpo1q_headerCorner:has(button){border:1px solid var(--dsw-alias-border-l3);background:var(--dsw-alias-bg-layer-1);backdrop-filter:none;box-shadow:0 1px 2px #00000014}}@media (prefers-contrast:more){[data-phone] .vbpo1q_headerCorner:has(button),[data-ds-dark-theme] [data-phone] .vbpo1q_headerCorner:has(button){border-color:var(--dsw-alias-label-secondary);box-shadow:none}}@media (forced-colors:active){[data-phone] .vbpo1q_root[data-phase=active] .vbpo1q_header{pointer-events:auto;background:canvas;border-bottom:1px solid canvastext;position:relative}[data-phone] .vbpo1q_root[data-phase=active] .vbpo1q_header:before{display:none}[data-phone] .vbpo1q_root[data-phase=active]:not(:has([data-slot="conversation.header.notice"]>*)) .vbpo1q_scrollBody{padding-top:0}[data-phone] .vbpo1q_root[data-phase=active]>[data-slot="conversation.header.notice"]:not(:empty){margin-top:0}[data-phone] .vbpo1q_headerCorner:has(button),[data-ds-dark-theme] [data-phone] .vbpo1q_headerCorner:has(button){backdrop-filter:none;box-shadow:none;background:buttonface;border:1px solid buttontext}}.vbpo1q_tabs{z-index:1;grid-column:1/-1;gap:36px;margin-top:10px;padding-left:8px;display:flex;position:relative}.vbpo1q_tab{color:var(--dsw-alias-label-tertiary);cursor:pointer;background:0 0;border:none;padding:0 0 9px;font-size:13px;font-weight:500;line-height:16px;position:relative}.vbpo1q_tab:after{content:"";background:0 0;border-radius:2px;height:2px;position:absolute;bottom:-1px;left:0;right:0}.vbpo1q_tabActive{color:var(--dsw-alias-state-business-primary)}.vbpo1q_tabActive:after{background:var(--dsw-alias-state-business-primary)}.vbpo1q_viewArea{flex-direction:column;flex:1;min-height:0;display:flex}.vbpo1q_widthHandle{z-index:0;width:min(10px, calc((100% - var(--dsh-chat-content-width)) / 2 - 24px - 24px));cursor:col-resize;position:absolute;top:0;bottom:0}.vbpo1q_widthHandle[data-side=left]{right:calc(50% + var(--dsh-chat-content-width) / 2 + 24px)}.vbpo1q_widthHandle[data-side=right]{left:calc(50% + var(--dsh-chat-content-width) / 2 + 24px)}.vbpo1q_widthHandle:after{content:"";background:linear-gradient(to bottom, transparent calc(var(--dsh-width-handle-pointer-y,50%) - 36px), var(--dsw-alias-scrollbar-bg-l1) calc(var(--dsh-width-handle-pointer-y,50%) - 8px), var(--dsw-alias-scrollbar-bg-l1) calc(var(--dsh-width-handle-pointer-y,50%) + 8px), transparent calc(var(--dsh-width-handle-pointer-y,50%) + 36px));opacity:0;pointer-events:none;border-radius:2px;width:2px;position:absolute;top:0;bottom:0}.vbpo1q_widthHandle[data-side=left]:after{right:4px}.vbpo1q_widthHandle[data-side=right]:after{left:4px}.vbpo1q_widthHandle:hover:after,.vbpo1q_widthHandle[data-dragging]:after{opacity:1}.vbpo1q_widthHandle[data-dragging]{z-index:8}.vbpo1q_root:has([data-conversation-composer-overlay]) .vbpo1q_widthHandle{display:none}.vbpo1q_composerStack{--dsh-composer-stack-gap:6px;gap:var(--dsh-composer-stack-gap);flex-direction:column;display:flex}.vbpo1q_composerSeat{--dsh-composer-text-max-height:336px;flex-direction:column;flex:none;display:flex}.vbpo1q_root[data-phase=active]{overflow:hidden}.vbpo1q_root[data-phase=active] .vbpo1q_header{flex:none}.vbpo1q_body{--dsh-chat-content-width:var(--dsh-chat-user-width,clamp(680px, calc(var(--dsh-conversation-column-width,0px) * .64), 920px));--dsh-composer-card-max-width:calc(var(--dsh-chat-content-width) + 32px);--dsh-composer-side-clearance:16px;--dsh-composer-dock-inset:8px;flex-direction:column;flex:1;min-height:0;display:flex;position:relative}.vbpo1q_embeddedBody{--dsh-chat-content-width:min(calc(100% - 32px), 920px);--dsh-composer-card-max-width:min(calc(100% - 16px), 952px);--dsh-composer-side-clearance:8px;--dsh-composer-dock-inset:8px;overflow:hidden}.vbpo1q_scrollBody{scrollbar-gutter:stable;flex-direction:column;flex:1;min-height:0;margin-right:2px;display:flex;overflow:hidden auto}.vbpo1q_scrollBody::-webkit-scrollbar-track{margin:2px}.vbpo1q_root[data-phase=active] .vbpo1q_viewArea,.vbpo1q_embeddedBody[data-content-phase=active] .vbpo1q_viewArea{flex:1 0 auto;min-height:auto}.vbpo1q_root[data-phase=active] .vbpo1q_composerSeat,.vbpo1q_embeddedBody[data-content-phase=active] .vbpo1q_composerSeat{z-index:7;background:var(--dsh-phone-composer-mask,linear-gradient(180deg, color-mix(in srgb, var(--dsw-alias-bg-base) 0%, transparent) 0px, var(--dsw-alias-bg-base) 36px));position:sticky;bottom:0}@supports (backdrop-filter:blur(14px)){[data-phone] .vbpo1q_composerSeat:where(:has([data-chain-overlay-fallback=conversation\\.composer]:only-child [data-composer-card])){--dsh-phone-composer-mask:linear-gradient(180deg, transparent 0px, color-mix(in srgb, var(--dsw-alias-bg-base) 60%, transparent) 36px, color-mix(in srgb, var(--dsw-alias-bg-base) 60%, transparent) calc(100% - 28px), var(--dsw-alias-bg-base) 100%)}}@media (prefers-reduced-transparency:reduce),(prefers-contrast:more),(forced-colors:active){[data-phone] .vbpo1q_composerSeat{--dsh-phone-composer-mask:initial}}body[data-codexhost-wallpaper] .vbpo1q_root[data-phase=active] .vbpo1q_composerSeat,body[data-codexhost-wallpaper] .vbpo1q_embeddedBody[data-content-phase=active] .vbpo1q_composerSeat{background:0 0}.vbpo1q_root[data-phase=active] .vbpo1q_composerSeat:has([data-trigger-menu]){z-index:9}.vbpo1q_scrollBody:has([data-conversation-composer-overlay]){scrollbar-gutter:auto;position:relative;overflow:hidden auto}.vbpo1q_scrollBody:has([data-conversation-composer-overlay])>[data-slot=conversation\\.session]>.vbpo1q_viewArea{flex:1 1 0;min-height:0;overflow:hidden}.vbpo1q_scrollBody:has([data-conversation-composer-overlay])>.vbpo1q_composerSeat{right:var(--dsh-scrollbar-width);position:absolute;bottom:0;left:0}.vbpo1q_composerHero{width:min(calc(var(--dsh-composer-card-max-width) + 2 * var(--dsh-composer-side-clearance)), 100%);z-index:1;align-self:center;gap:16px;padding-bottom:32px}.vbpo1q_heroTopBarInner{align-items:center;gap:4px;width:100%;min-width:0;display:flex}.vbpo1q_heroAgentPresetSeat{flex:none;align-items:center;margin-left:auto;display:flex}.vbpo1q_heroAgentPresetSeat:empty{display:none}.vbpo1q_root[data-phase=hero] .vbpo1q_scrollBody,.vbpo1q_embeddedBody[data-content-phase=hero] .vbpo1q_scrollBody{justify-content:center;overflow-y:auto}.vbpo1q_root[data-phase=settling] .vbpo1q_composerSeat,.vbpo1q_embeddedBody[data-content-phase=settling] .vbpo1q_composerSeat{visibility:hidden}`,document.head.appendChild(e)}var Q={body:`vbpo1q_body`,composerHero:`vbpo1q_composerHero`,composerSeat:`vbpo1q_composerSeat`,composerStack:`vbpo1q_composerStack`,crumb:`vbpo1q_crumb`,crumbCurrent:`vbpo1q_crumbCurrent`,crumbSeg:`vbpo1q_crumbSeg`,crumbSep:`vbpo1q_crumbSep`,crumbSubagent:`vbpo1q_crumbSubagent`,crumbs:`vbpo1q_crumbs`,embeddedBody:`vbpo1q_embeddedBody`,header:`vbpo1q_header`,headerActions:`vbpo1q_headerActions`,headerBlank:`vbpo1q_headerBlank`,headerCorner:`vbpo1q_headerCorner`,headerLeading:`vbpo1q_headerLeading`,headerSessionless:`vbpo1q_headerSessionless`,headerUtilities:`vbpo1q_headerUtilities`,heroAgentPresetSeat:`vbpo1q_heroAgentPresetSeat`,heroTopBarInner:`vbpo1q_heroTopBarInner`,phoneTrailingAction:`vbpo1q_phoneTrailingAction`,root:`vbpo1q_root`,scrollBody:`vbpo1q_scrollBody`,tab:`vbpo1q_tab`,tabActive:`vbpo1q_tabActive`,tabs:`vbpo1q_tabs`,titleCenter:`vbpo1q_titleCenter`,titleCluster:`vbpo1q_titleCluster`,titleRow:`vbpo1q_titleRow`,viewArea:`vbpo1q_viewArea`,widthHandle:`vbpo1q_widthHandle`};let jO=`dsh.conversation.contentWidth`;function MO(){let e=localStorage.getItem(jO);if(e===null)return null;let t=Number(e);return Number.isFinite(t)&&t>0?t:null}function NO(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 PO(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 FO(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;
|
|
173
164
|
/* v8 ignore next -- a width handle renders only inside the Conversation body. */
|
|
174
165
|
if(t===null)return;let n=t.querySelector(`:scope > [data-conversation-scroll]`);
|
|
175
166
|
/* v8 ignore next -- the Conversation body always contains its direct scroll element. */
|
|
176
|
-
n!==null&&(e.ctrlKey||e.deltaY===0||n.scrollBy({top:kE(e,n)}))},[]);return/* @__PURE__ */ (0,h.jsx)(`div`,{className:Q.widthHandle,"data-side":e.side,"data-width-handle":e.side,onPointerDown:l,onPointerMove:u,onPointerUp:d,onPointerCancel:f,onLostPointerCapture:f,onWheel:p})}function jE({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=DE();r===null?t.style.removeProperty(`--dsh-chat-user-width`):t.style.setProperty(`--dsh-chat-user-width`,`${OE(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:OE(e.offsetWidth,DE()),[e]),i=(0,g.useCallback)(t=>{e!==null&&(e.parentElement??e).style.setProperty(`--dsh-chat-user-width`,`${OE(e.offsetWidth,t)}px`)},[e]),a=(0,g.useCallback)(t=>{e!==null&&localStorage.setItem(EE,`${OE(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)(AE,{side:e,onStart:r,onDrag:i,onCommit:a,onEnd:o},e))}let ME={widthControls:jE};function NE(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`:wE(s,c),u=s?.openState,d=r(e=>t===void 0?void 0:e.byId[t]?.blank),f=s?.subagent?.address.mode===`continuable`&&s.subagent.parentAvailable===void 0,p=t!==void 0&&(l===`blank`&&u===`loading`&&d!==!0||f),m=t===void 0||l===`blank`&&(u===`open`||d===!0),g=p?`settling`:m?`hero`:`active`;return/* @__PURE__ */ (0,h.jsxs)(`div`,{className:Q.root,"data-phase":g,"data-cx-region":`conversation`,children:[a(`conversation.header`,{}),a(`conversation.header.notice`,{}),o(`conversation.content`,{variant:`main`,phase:g,hero:m},{slots:ME})]})}function PE(e){return/* @__PURE__ */ (0,h.jsx)(NE,{...e})}function FE(e,t){return e===`default-workspace`?t:e}let IE=`@deepseek-ai/dsh-client-ui-conversation/HeroShell.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(IE)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-conversation`,e.dataset.pluginCss=IE,e.textContent=`.Dgrl1G_root{justify-content:center;align-items:center;min-width:0;height:100%;padding:0 24px;display:flex}.Dgrl1G_stack{width:100%;max-width:var(--dsh-composer-card-max-width);flex-direction:column;align-items:stretch;gap:12px;display:flex;overflow:visible}.Dgrl1G_headline{color:var(--dsw-alias-label-primary);flex-wrap:wrap;justify-content:center;align-items:center;gap:12px 10px;font-size:26px;font-weight:500;line-height:32px;display:flex}.Dgrl1G_titleGroup{flex-wrap:wrap;justify-content:center;align-items:center;gap:4px 7px;min-width:0;display:flex}.Dgrl1G_previewBadge{border:.5px solid var(--dsw-alias-interactive-bg-hover);corner-shape:round;background:var(--dsw-alias-state-business-tertiary);color:var(--dsw-alias-label-primary-bluish);font-family:var(--ds-font-family-code);white-space:nowrap;border-radius:999px;align-self:flex-start;margin-top:2px;padding:1px 7px 0;font-size:12px;font-weight:500;line-height:18px}.Dgrl1G_fishHitbox{flex:none;justify-content:center;align-items:center;display:inline-flex}.Dgrl1G_fish{transform-origin:50% 60%;color:var(--dsw-alias-label-primary);display:block;overflow:visible}@keyframes Dgrl1G_hero-fish-swim{0%,to{transform:none}35%{transform:rotate(-4deg)translate(-.4px,-.9px)}70%{transform:rotate(1.6deg)translate(.3px,.2px)}}@media (hover:hover) and (prefers-reduced-motion:no-preference){.Dgrl1G_fishHitbox:hover .Dgrl1G_fish{animation:1.6s ease-in-out infinite Dgrl1G_hero-fish-swim}}.Dgrl1G_body{flex-direction:column;gap:12px;min-width:0;display:flex;position:relative;overflow:visible}.Dgrl1G_body>*{z-index:1;position:relative}.Dgrl1G_body>.Dgrl1G_workspaceRow{z-index:10;align-items:center;min-width:0;padding-left:8px;display:flex}.Dgrl1G_workspace{border-radius:var(--dsw-radius-sm);max-width:min(100%,360px);min-height:28px;color:var(--dsw-alias-label-primary);cursor:pointer;background:0 0;border:none;align-items:center;gap:4px;padding:0 8px;font-size:13px;font-weight:500;line-height:20px;display:inline-flex}.Dgrl1G_workspace:not(:disabled):hover,.Dgrl1G_workspace[aria-expanded=true]{background:var(--dsw-alias-interactive-bg-hover)}.Dgrl1G_workspace:disabled{cursor:default}.Dgrl1G_folder{color:var(--dsw-alias-label-primary);flex:none}.Dgrl1G_workspaceLabel{text-overflow:ellipsis;white-space:nowrap;min-width:0;overflow:hidden}.Dgrl1G_chevron{color:var(--dsw-alias-label-caption);flex:none}.Dgrl1G_modalInput{box-sizing:border-box;border:.5px solid var(--dsw-alias-border-l4);border-radius:var(--dsw-radius-lg);width:100%;height:44px;color:var(--dsw-alias-label-primary);background:0 0;outline:none;padding:7px 14px;font-size:14px;font-weight:400;line-height:22px}.Dgrl1G_modalInput::placeholder{color:var(--dsw-alias-label-caption)}.Dgrl1G_modalInput:disabled{color:var(--dsw-alias-label-dimmed)}.Dgrl1G_modalAction{min-width:72px}.Dgrl1G_modalError{color:var(--dsw-alias-state-error-primary);margin-top:8px;font-size:12px;line-height:18px}`,document.head.appendChild(e)}var LE={body:`Dgrl1G_body`,chevron:`Dgrl1G_chevron`,fish:`Dgrl1G_fish`,fishHitbox:`Dgrl1G_fishHitbox`,folder:`Dgrl1G_folder`,headline:`Dgrl1G_headline`,"hero-fish-swim":`Dgrl1G_hero-fish-swim`,modalAction:`Dgrl1G_modalAction`,modalError:`Dgrl1G_modalError`,modalInput:`Dgrl1G_modalInput`,previewBadge:`Dgrl1G_previewBadge`,root:`Dgrl1G_root`,stack:`Dgrl1G_stack`,titleGroup:`Dgrl1G_titleGroup`,workspace:`Dgrl1G_workspace`,workspaceLabel:`Dgrl1G_workspaceLabel`,workspaceRow:`Dgrl1G_workspaceRow`};function RE(e){let t=Fc(e);return t===``?e:t}function zE({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:LE.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:LE.folder,size:16}):/* @__PURE__ */ (0,h.jsx)(d.IconFolderOpenRegular,{className:LE.folder,size:16}),/* @__PURE__ */ (0,h.jsx)(`span`,{className:LE.workspaceLabel,children:t??a(`hero.chooseWorkspace`)}),/* @__PURE__ */ (0,h.jsx)(d.IconChevronDownOutlineRegular,{className:LE.chevron,size:12})]})}function BE({hovering:e}){return/* @__PURE__ */ (0,h.jsx)(`svg`,{className:LE.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 VE({t:e,renderSlot:t,children:n}){let[r,i]=(0,g.useState)(!1);return/* @__PURE__ */ (0,h.jsxs)(`div`,{className:LE.root,children:[/* @__PURE__ */ (0,h.jsxs)(`div`,{className:LE.stack,children:[/* @__PURE__ */ (0,h.jsxs)(`div`,{className:LE.headline,children:[/* @__PURE__ */ (0,h.jsx)(`span`,{className:LE.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:LE.fish},{fallback:/* @__PURE__ */ (0,h.jsx)(BE,{hovering:r})})}),/* @__PURE__ */ (0,h.jsxs)(`span`,{className:LE.titleGroup,children:[/* @__PURE__ */ (0,h.jsx)(`span`,{children:e(`hero.headline`)}),/* @__PURE__ */ (0,h.jsx)(`span`,{className:LE.previewBadge,children:e(`hero.preview`)})]})]}),/* @__PURE__ */ (0,h.jsx)(`div`,{className:LE.body})]}),n]})}let HE=`@deepseek-ai/dsh-client-ui-conversation/ThreadReferenceDropTarget.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(HE)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-conversation`,e.dataset.pluginCss=HE,e.textContent=`.tWXKHq_overlay{z-index:30;pointer-events:none;background:color-mix(in srgb, var(--dsw-alias-state-business-tertiary) 88%, transparent);place-items:center;display:grid;position:absolute;inset:0}.tWXKHq_invitation{flex-direction:column;align-items:center;gap:8px;max-width:calc(100% - 40px);display:flex}.tWXKHq_hint{border:1px solid color-mix(in srgb, var(--dsw-alias-state-business-primary) 15%, transparent);background:var(--dsw-alias-state-business-tertiary);color:var(--dsw-alias-label-primary);border-radius:10px;padding:8px 16px;font-size:16px;line-height:24px;box-shadow:0 1px 4px #00000014}.tWXKHq_preview{box-sizing:border-box;border:1px solid var(--dsw-alias-border-l3);background:var(--dsw-alias-bg-base);max-width:min(440px,100%);color:var(--dsw-alias-label-primary);border-radius:12px;align-items:center;gap:10px;padding:10px 14px;font-size:14px;line-height:20px;display:flex;box-shadow:0 4px 14px #00000014}.tWXKHq_preview svg{flex:none}.tWXKHq_title{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}`,document.head.appendChild(e)}var UE={hint:`tWXKHq_hint`,invitation:`tWXKHq_invitation`,overlay:`tWXKHq_overlay`,preview:`tWXKHq_preview`,title:`tWXKHq_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:Pb(Nb(e)),n=t===void 0?void 0:a.current[t];return n!==void 0&&Mb(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:Ib(t.getData(jb));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(Ad,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=Ib(a.getData(jb));i()&&c(r)&&r?.threadId===n?.threadId&&r?.hostId===n?.hostId?t.dispatchCommand(Od,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:UE.overlay,"data-thread-reference-drop":!0,role:`status`,"aria-live":`polite`,children:/* @__PURE__ */ (0,h.jsxs)(`div`,{className:UE.invitation,children:[/* @__PURE__ */ (0,h.jsx)(`div`,{className:UE.hint,children:r(`reference.dropTitle`)}),/* @__PURE__ */ (0,h.jsxs)(`div`,{className:UE.preview,"data-thread-reference-preview":!0,children:[/* @__PURE__ */ (0,h.jsx)(d.ReferenceIconRegular,{kind:`session`,size:20}),/* @__PURE__ */ (0,h.jsx)(`span`,{className:UE.title,children:o.title})]})]})})}function GE({renderSlot:e}){return e(`conversation.session`,{})}function KE(){return null}function qE(e){let{sessionId:t,phase:n,hero:r,useSession:i,useSessions:a,useSessionStatus:o,useWorkspaces:s,useInput:c,useComposerBlock:l,useSessionCreation:u,renderSlot:d,renderSlotChain:f,selectWorkspace:p,retrySessionCreation:m,referenceEditor:_,t:v,useFactorySlot:y}=e,b=i(e=>e),ee=y(`views`,GE),te=y(`widthControls`,KE),[ne,re]=(0,g.useState)(null),ie=o(e=>t===void 0?void 0:e.get(t)?.pendingInteraction),ae=c(e=>e),oe=a(e=>t===void 0?void 0:e.byId[t]?.cwd),se=s(e=>e),ce=l(e=>e),le=u(e=>e),ue=t===void 0&&le.state!==`idle`?le.workspaceId:void 0,[de,fe]=(0,g.useState)(!1),[pe,me]=(0,g.useState)(),x=(0,g.useRef)(null),S=(0,g.useRef)(null),he=(0,g.useCallback)(e=>{S.current?.disconnect(),S.current=null;let t=e?.parentElement??null;e!==null&&t!==null&&(S.current=new ResizeObserver(()=>{t.style.setProperty(`--dsh-composer-height`,`${e.offsetHeight}px`),t.style.setProperty(`--dsh-conversation-viewport-height`,`${t.clientHeight}px`)}),S.current.observe(e),S.current.observe(t))},[]),ge=t===void 0?void 0:se.items.find(e=>e.sessionIds.includes(t)),_e=pe===void 0?ue:pe,ve=se.items.find(e=>e.workspaceId===_e);(0,g.useEffect)(()=>{pe!==void 0&&((pe===null?ge===void 0&&t!==void 0:ge?.workspaceId===pe)||pe!==null&&se.phase===`ready`&&ve===void 0)&&me(void 0)},[pe,t,ge?.workspaceId,se.phase,ve]);let ye=b===void 0||ae===void 0?void 0:{session:b,input:ae},be=(_e===null?void 0:ve?.title)??(_e===null||t===void 0?void 0:ge?.title??(se.phase===`ready`||oe===void 0||oe===``?void 0:RE(oe))),xe=be===void 0?void 0:FE(be,v(`workspace.defaultName`)),Se=/* @__PURE__ */ (0,h.jsxs)(`div`,{className:Q.heroTopBarInner,children:[d(`conversation.hero.workspace`,{open:de,anchorRef:x,selectedId:_e===null?void 0:_e??ge?.workspaceId,fallbackLabel:xe,onOpenChange:fe,onPick:e=>{fe(!1),me(e),p(e).catch(()=>{me(t=>t===e?void 0:t)})},onClose:()=>{fe(!1)}},{fallback:/* @__PURE__ */ (0,h.jsx)(zE,{buttonRef:x,label:xe??(se.canStartProjectless?v(`hero.noWorkspace`):void 0),projectless:se.canStartProjectless===!0&&xe===void 0,menuOpen:de,onClick:()=>{fe(e=>!e)},t:v})}),/* @__PURE__ */ (0,h.jsx)(`div`,{className:Q.heroAgentPresetSeat,children:d(`conversation.hero.agentPreset`,{})})]}),Ce=se.phase===`ready`&&!se.canStartProjectless&&xe===void 0,we=t===void 0&&le.state!==`idle`,Te=t!==void 0&&r&&b?.openState===`loading`&&!Ce,Ee=(t===void 0||b?.openState!==`open`)&&!Ce,De=t===void 0||b?.openState!==`open`||r&&Ce,Oe=!De&&ce!==void 0,ke=d(`conversation.composer.bar`,{variant:r?`hero`:`composer`,...r?{topBar:Se}:{},...we?{sessionCreation:le,onRetrySessionCreation:m,placeholder:v(`placeholder.hero`)}:Te?{disabled:!0,preparingDraft:!0,placeholder:v(`placeholder.hero`)}:De?{disabled:!0,placeholder:v(Ee?`placeholder.preparing`:`placeholder.workspace`),...Ee?{}:{workspacePickerOpen:de,onRequestWorkspace:()=>{fe(!0)}}}:Oe?{blocked:ce,placeholder:ce.reason}:r?{placeholder:v(`placeholder.hero`)}:{}}),C=/* @__PURE__ */ (0,h.jsxs)(`div`,{className:Rb(Q.composerStack,r&&Q.composerHero),children:[r&&/* @__PURE__ */ (0,h.jsx)(VE,{t:v,renderSlot:d}),ye!==void 0&&d(`conversation.input.dock`,ye),ke]}),Ae=f(`conversation.composer`,{sessionId:t,session:b,pendingInteraction:b?.openState===`open`?ie:void 0},{fallback:C,fallbackOnly:t===void 0,overlay:!0}),je=/* @__PURE__ */ (0,h.jsx)(`div`,{ref:he,className:Q.composerSeat,"data-composer-seat":``,"data-conversation-region":`composer`,children:Ae});return/* @__PURE__ */ (0,h.jsxs)(`div`,{ref:re,className:Rb(Q.body,e.variant===`embedded`&&Q.embeddedBody),"data-conversation-content":``,"data-conversation-session":t,"data-conversation-region":`chat`,"data-content-phase":n,children:[/* @__PURE__ */ (0,h.jsxs)(`div`,{className:Q.scrollBody,"data-conversation-scroll":``,children:[t===void 0?null:/* @__PURE__ */ (0,h.jsx)(ee,{}),je]}),/* @__PURE__ */ (0,h.jsx)(te,{container:ne,phase:n}),/* @__PURE__ */ (0,h.jsx)(WE,{container:ne,editor:_,useSessions:a,t:v},t)]})}function JE({renderSlot:e}){return e(`main.conversation`,{})}function YE(){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 XE({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&&wE(i,a)===`blank`;return/* @__PURE__ */ (0,h.jsxs)(`header`,{className:Rb(Q.header,o&&Q.headerBlank,e===void 0&&Q.headerSessionless),"data-window-drag":!0,"data-conversation-navigation-focus":!0,"data-cx-region":`topbar`,tabIndex:-1,children:[/* @__PURE__ */ (0,h.jsx)(`div`,{className:Q.headerLeading,"data-conversation-header-leading":``,children:r(`conversation.header.leading`,{})}),e===void 0?/* @__PURE__ */ (0,h.jsxs)(`div`,{className:Q.titleRow,children:[r(`conversation.header.navigation`,{restoreNavigationFocus:YE}),/* @__PURE__ */ (0,h.jsx)(`div`,{className:Q.headerCorner,"data-conversation-header-corner":``,children:/* @__PURE__ */ (0,h.jsx)(`span`,{className:Q.phoneTrailingAction,children:r(`conversation.header.trailing`,{})})})]}):r(`conversation.session.header`,{hideChrome:o,titleNavigation:r(`conversation.header.navigation`,{restoreNavigationFocus:YE}),trailingAction:r(`conversation.header.trailing`,{})}),r(`conversation.header.shortcuts`,{restoreNavigationFocus:YE})]})}function ZE(e,t){return(t===null?void 0:e.find(e=>e.id===t))??e.find(e=>e.id===`chat`)}function QE({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=ZE(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&&wE(_,v)===`blank`)return null;let b=e??m?.id;return/* @__PURE__ */ (0,h.jsx)(`div`,{className:Q.viewArea,children:b!==void 0&&s(`conversation.view`,{inspectCall:p,viewRequest:y,openView:u,completeViewRequest:o.completeViewRequest},{only:b})})}function $E(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 eD(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 tD({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=ZE(d,o(e=>e.view)),p=i(t=>$E(t,e),eD),m=!t&&d.length>1;return/* @__PURE__ */ (0,h.jsxs)(h.Fragment,{children:[/* @__PURE__ */ (0,h.jsxs)(`div`,{className:Q.titleRow,children:[!t&&/* @__PURE__ */ (0,h.jsxs)(h.Fragment,{children:[/* @__PURE__ */ (0,h.jsxs)(`div`,{className:Q.titleCluster,children:[/* @__PURE__ */ (0,h.jsxs)(`div`,{className:Q.titleCenter,onClick:e=>{if(e.target?.closest(`button, a, input, [role='button']`))return;let t=e.currentTarget.querySelector(`[data-navigation-focus-return]`);t!==null&&t.getClientRects().length>0&&t.click()},children:[/* @__PURE__ */ (0,h.jsxs)(`nav`,{className:Q.crumbs,"aria-label":u(`session.hierarchy`),children:[p.map((e,t)=>{let n=t===p.length-1,r=n?/* @__PURE__ */ (0,h.jsx)(`span`,{className:Rb(Q.crumb,e.subagent&&Q.crumbSubagent,Q.crumbCurrent),children:e.displayTitle}):/* @__PURE__ */ (0,h.jsx)(`button`,{type:`button`,className:Rb(Q.crumb,e.subagent&&Q.crumbSubagent),onClick:()=>{c(e.id)},children:e.displayTitle}),i=n||e.subagent,a={lineageSessionId:e.id,displayTitle:e.displayTitle,...n?{}:{openTitle:()=>{c(e.id)}}};return/* @__PURE__ */ (0,h.jsxs)(`span`,{className:Q.crumbSeg,children:[t>0&&/* @__PURE__ */ (0,h.jsx)(`span`,{className:Q.crumbSep,children:`/`}),i?e.subagent?s(`conversation.session.header.lineage`,a,{fallback:r}):/* @__PURE__ */ (0,h.jsxs)(h.Fragment,{children:[r,s(`conversation.session.header.lineage`,a,{fallback:null})]}):r]},e.id)}),p.length===0&&/* @__PURE__ */ (0,h.jsx)(`span`,{className:Q.crumbCurrent,children:e})]}),n]}),/* @__PURE__ */ (0,h.jsx)(`div`,{className:Q.headerActions,children:s(`conversation.session.header.actions`,{})})]}),/* @__PURE__ */ (0,h.jsx)(`div`,{className:Q.headerUtilities,children:s(`conversation.session.header.utilities`,{})})]}),t&&/* @__PURE__ */ (0,h.jsx)(`div`,{className:Q.titleCenter,children:n}),/* @__PURE__ */ (0,h.jsxs)(`div`,{className:Q.headerCorner,"data-conversation-header-corner":``,children:[/* @__PURE__ */ (0,h.jsx)(`span`,{className:Q.phoneTrailingAction,children:r}),s(`conversation.session.header.corner`,{})]})]}),m&&/* @__PURE__ */ (0,h.jsx)(`div`,{className:Q.tabs,role:`tablist`,"data-conversation-tabs":``,children:d.map(e=>/* @__PURE__ */ (0,h.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":e.id===f?.id,className:Rb(Q.tab,e.id===f?.id&&Q.tabActive),onClick:()=>{l(e.id)},children:e.label},e.id))})]})}function nD(e){return/* @__PURE__ */ (0,h.jsx)(QE,{...e})}function rD({editor:e,editable:t,preserveFocus:n=!1,...r}){let i=(0,g.useRef)(null),a=(0,g.useRef)(n);return a.current=n,(0,g.useLayoutEffect)(()=>{let t=i.current;if(t!==null&&(!(0,d.shouldAutoFocusTextInput)()&&!a.current&&(t.ownerDocument.activeElement===t&&t.blur(),e?.setEditable(!1)),e!==null))return e.setRootElement(t),()=>{e.setRootElement(null)}},[e]),(0,g.useLayoutEffect)(()=>{e!==null&&e.setEditable(t)},[e,t]),/* @__PURE__ */ (0,h.jsx)(`div`,{ref:i,contentEditable:e!==null&&t,suppressContentEditableWarning:!0,role:`textbox`,"aria-multiline":`true`,"data-composer-input":!0,...r})}function iD({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 aD({classNames:e,editor:t,scrollRef:n,editable:r,editorDisabled:i,preserveFocus:a=!1,phase:o,placeholderText:s,ariaLabel:c,workspaceTrigger:l,workspacePickerOpen:u,onWorkspaceKeyDown:d,hint:f,showPlaceholder:p}){return/* @__PURE__ */ (0,h.jsx)(`div`,{ref:n,className:e.scroll,"data-input-scroll":!0,children:/* @__PURE__ */ (0,h.jsxs)(`div`,{className:e.grow,children:[/* @__PURE__ */ (0,h.jsx)(rD,{editor:l?null:t,editable:r,preserveFocus:a,className:Rb(e.input,i&&e.inputDisabled),"data-phase":o,"aria-disabled":i||void 0,"data-placeholder":s,"aria-label":c,"aria-haspopup":l?`menu`:void 0,"aria-expanded":l?u:void 0,tabIndex:l?0:void 0,onKeyDown:l?d:void 0,style:f===null?void 0:{"--dsh-composer-hint":JSON.stringify(f)}}),p&&/* @__PURE__ */ (0,h.jsx)(`div`,{"aria-hidden":!0,className:e.placeholder,"data-composer-placeholder":!0,children:s}),/* @__PURE__ */ (0,h.jsx)(iD,{editor:l?null:t})]})})}function oD(e,t){return e.isComposing||e.keyCode===229||t()}function sD(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&&oD(n,c);return t.arbitrate(e,r)!==`pass`&&(n?.preventDefault(),!0)};return Nv(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(bd,l(`up`),4),e.registerCommand(xd,l(`down`),4),e.registerCommand(Dd,e=>l(e.shiftKey?`tabBack`:`tab`)(e),4),e.registerCommand(Td,e=>(t.dismissPopup(),t.arbitrate(`escape`,oD(e,c))===`consumed`&&(e.preventDefault(),!0)),4),e.registerCommand(Cd,e=>oD(e,c)?!1:t.space()?(e.preventDefault(),!0):!1,4),e.registerCommand(Sd,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&&oD(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(cd,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 cD(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 lD(e,t){e.getRootElement()?.focus({preventScroll:!0}),e.focus(()=>{t()})}function uD(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 dD(e,t,n){return e.bindFilePicker({available:()=>t.current.canAcceptDrop&&n.current!==null,open:()=>{n.current?.click()}})}function fD(e,t,n){return sD(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(sE(r.busyEnter,r.running,e?`accelerated`:`enter`,r.steeringAvailable),`enter`):r.primaryAction.run()},intakeFiles:(e,t)=>{n.current.intakeFiles(e,t)},pasteText:e=>{!n.current.machineBusy&&n.current.canPasteText&&t.paste(e)}})}function pD(e,t){e.preventDefault(),!(0,d.isMobileDevice)()&&t?.getRootElement()?.focus({preventScroll:!0})}function mD(e){let t=e/1048576;return`${Number.isInteger(t)?String(t):t.toFixed(1)}MB`}function hD(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:mD(n.maxImageBytes)});break;case`IMAGES_TOO_LARGE`:if(n!==void 0)return e(`image.totalTooLarge`,{size:mD(n.maxMessageImageBytes)})}return e(`image.sendFailed`,{reason:t})}function gD(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 _D=`@deepseek-ai/dsh-client-ui-conversation/ContextMeter.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(_D)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-conversation`,e.dataset.pluginCss=_D,e.textContent=`.h1Hkra_root{flex:none;display:inline-flex}.h1Hkra_trigger{border-radius:var(--dsw-radius-sm);color:var(--dsw-alias-label-tertiary);font-family:inherit;font-size:var(--dsh-content-font-size-secondary,13px);font-variant-numeric:tabular-nums;line-height:calc(20px + var(--dsh-content-font-delta-secondary,0px));white-space:nowrap;cursor:pointer;background:0 0;border:none;flex:none;align-items:center;gap:6px;padding:1px 8px;display:inline-flex}.h1Hkra_trigger:hover,.h1Hkra_trigger[aria-expanded=true]{background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-label-secondary)}.h1Hkra_track{fill:none;stroke:var(--dsw-alias-border-l3);stroke-width:2px}.h1Hkra_fill{fill:none;stroke:var(--dsw-alias-label-tertiary);stroke-width:2px;stroke-linecap:round}.h1Hkra_panel{z-index:1100;box-sizing:border-box;border-radius:var(--dsw-radius-lg);background:var(--dsw-specific-menu);width:min(264px,100vw - 24px);backdrop-filter:var(--dsw-menu-backdrop-filter);--dsw-elevation-stroke-color:var(--dsw-alias-border-l1);box-shadow:var(--dsw-elevation-prominent);color:var(--dsw-alias-label-secondary);cursor:default;border:0;padding:12px;font-size:12px;line-height:20px;position:fixed}.h1Hkra_header{align-items:center;gap:6px;display:flex}.h1Hkra_figures{font-variant-numeric:tabular-nums;color:var(--dsw-alias-label-primary);margin-left:auto;font-weight:500}.h1Hkra_percent{color:var(--dsw-alias-label-primary);font-weight:500}.h1Hkra_headline{color:var(--dsw-alias-label-tertiary)}.h1Hkra_headline:empty{display:none}.h1Hkra_bar{corner-shape:round;background:var(--dsw-alias-interactive-bg-hover);border-radius:999px;gap:1px;height:4px;margin:10px 0 12px;display:flex;overflow:hidden}.h1Hkra_segment{background:var(--meter-tint,var(--dsw-alias-label-tertiary));border-radius:1px;flex:none;min-width:2px;height:100%}.h1Hkra_swatch{background:var(--meter-tint);vertical-align:baseline;border-radius:2px;width:8px;height:8px;margin-right:6px;display:inline-block}.h1Hkra_colorSystem{--meter-tint:var(--dsw-static-neutral-bluish-400)}.h1Hkra_colorTools{--meter-tint:#a78bfa}.h1Hkra_colorMessages{--meter-tint:var(--dsw-static-blue-450)}.h1Hkra_rows{margin:6px 0 0}.h1Hkra_row{justify-content:space-between;align-items:center;gap:12px;padding:2px 0;display:flex}.h1Hkra_row dt{color:var(--dsw-alias-label-secondary)}.h1Hkra_row dd{font-variant-numeric:tabular-nums;color:var(--dsw-alias-label-primary);margin:0}`,document.head.appendChild(e)}var vD={bar:`h1Hkra_bar`,colorMessages:`h1Hkra_colorMessages`,colorSystem:`h1Hkra_colorSystem`,colorTools:`h1Hkra_colorTools`,figures:`h1Hkra_figures`,fill:`h1Hkra_fill`,header:`h1Hkra_header`,headline:`h1Hkra_headline`,panel:`h1Hkra_panel`,percent:`h1Hkra_percent`,root:`h1Hkra_root`,row:`h1Hkra_row`,rows:`h1Hkra_rows`,segment:`h1Hkra_segment`,swatch:`h1Hkra_swatch`,track:`h1Hkra_track`,trigger:`h1Hkra_trigger`};let yD=5.5,bD=2*Math.PI*yD,xD=[{key:`systemTokens`,label:`context.system`,color:vD.colorSystem},{key:`toolsTokens`,label:`context.tools`,color:vD.colorTools},{key:`messageTokens`,label:`context.messages`,color:vD.colorMessages}];function SD(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 CD({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=gD(n),l=c!==null,u=(0,d.useAnchoredPosition)({open:i&&l,anchorRef:o,panelRef:s,side:`top`,gap:8,margin:12});if((0,d.useDismissOnOutsidePointer)(o,i&&l,a,s),(0,g.useEffect)(()=>{!l&&i&&a(!1)},[l,i]),(0,g.useEffect)(()=>{if(!i||!l)return;let e=e=>{e.key===`Escape`&&a(!1)};return document.addEventListener(`keydown`,e),()=>{document.removeEventListener(`keydown`,e)}},[l,i]),c===null)return null;let f=c.percent,p=`${f}%`,[m=``,v=``]=t(`context.aria`,{percent:`\0`}).split(`\0`).map(e=>e.trim()),y=r===void 0?0:r.systemTokens+r.toolsTokens+r.messageTokens,b=(r===void 0||y===0?[{key:`total`,color:void 0,width:f}]:xD.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:vD.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:vD.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:vD.track,cx:`7`,cy:`7`,r:yD}),/* @__PURE__ */ (0,h.jsx)(`circle`,{className:vD.fill,cx:`7`,cy:`7`,r:yD,strokeDasharray:`${bD*f/100} ${bD}`,transform:`rotate(-90 7 7)`})]}),/* @__PURE__ */ (0,h.jsx)(`span`,{children:p})]})}),i&&(0,_.createPortal)(/* @__PURE__ */ (0,h.jsxs)(`div`,{ref:s,className:vD.panel,style:u??{visibility:`hidden`,left:0,top:0},role:`dialog`,"aria-label":t(`context.used`),children:[/* @__PURE__ */ (0,h.jsxs)(`div`,{className:vD.header,children:[/* @__PURE__ */ (0,h.jsx)(`span`,{className:vD.headline,children:m}),/* @__PURE__ */ (0,h.jsx)(`span`,{className:vD.percent,children:p}),/* @__PURE__ */ (0,h.jsx)(`span`,{className:vD.headline,children:v}),/* @__PURE__ */ (0,h.jsx)(`span`,{className:vD.figures,children:`~${SD(c.usedTokens,t)} / ${SD(c.contextWindow,t)}`})]}),/* @__PURE__ */ (0,h.jsx)(`div`,{className:vD.bar,children:b.map(e=>/* @__PURE__ */ (0,h.jsx)(`div`,{className:e.color===void 0?vD.segment:`${vD.segment} ${e.color}`,style:{width:`${e.width}%`}},e.key))}),r!==void 0&&/* @__PURE__ */ (0,h.jsx)(`dl`,{className:vD.rows,children:xD.map(e=>/* @__PURE__ */ (0,h.jsxs)(`div`,{className:vD.row,children:[/* @__PURE__ */ (0,h.jsxs)(`dt`,{children:[/* @__PURE__ */ (0,h.jsx)(`span`,{className:`${vD.swatch} ${e.color}`,"aria-hidden":!0}),t(e.label)]}),/* @__PURE__ */ (0,h.jsx)(`dd`,{children:`~${SD(r[e.key],t)}`})]},e.key))})]}),document.body)]})}function wD(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 TD=`@deepseek-ai/dsh-client-ui-conversation/InputBar.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(TD)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-conversation`,e.dataset.pluginCss=TD,e.textContent=`.SFO4UW_root{padding:0 var(--dsh-composer-side-clearance) 4px;flex-direction:column;align-items:center;display:flex}[data-phone] .SFO4UW_root{padding-bottom:max(4px, calc(env(safe-area-inset-bottom) - 23px))}.SFO4UW_dock{-webkit-user-select:none;user-select:none;justify-content:center;align-items:center;gap:12px;max-width:100%;padding-top:4px;display:flex}.SFO4UW_hero .SFO4UW_dock:empty{display:none}.SFO4UW_hero{padding:0 var(--dsh-composer-side-clearance)}.SFO4UW_notice{width:100%;max-width:var(--dsh-composer-card-max-width);border-radius:var(--dsw-radius-md);background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-label-secondary);margin-bottom:6px;padding:4px 8px;font-size:12px;line-height:18px}.SFO4UW_cardStack{width:100%;max-width:var(--dsh-composer-card-max-width);flex-direction:column;display:flex;position:relative}.SFO4UW_topRail{z-index:0;box-sizing:border-box;margin-inline:16px;background:color-mix(in srgb, var(--dsw-alias-label-primary) 5%, var(--dsw-alias-bg-base));-webkit-user-select:none;user-select:none;border:0;border-radius:16px 16px 0 0;align-items:center;margin-bottom:-16px;padding:5px 10px 21px;display:flex;position:relative}.SFO4UW_card{box-sizing:border-box;z-index:1;width:100%;max-width:var(--dsh-composer-card-max-width);--dsw-elevation-stroke-color:var(--dsw-alias-border-l2);border-radius:var(--dsw-radius-panel);background:var(--dsw-specific-input-major);box-shadow:var(--dsw-elevation-soft);font-size:var(--dsh-content-font-size,14px);line-height:calc(24px + var(--dsh-content-font-delta,0px));--dsh-scrollbar-thumb:var(--dsw-alias-scrollbar-bg-l2);--dsh-scrollbar-thumb-hover:var(--dsw-alias-scrollbar-hover-l2);border:0;flex-direction:column;gap:12px;padding-top:8px;display:flex;position:relative}@supports (backdrop-filter:blur(14px)){body[data-codexhost-wallpaper] .SFO4UW_card,[data-phone] .SFO4UW_card{box-shadow:none;background:0 0}body[data-codexhost-wallpaper] .SFO4UW_card:before,[data-phone] .SFO4UW_card:before{content:"";z-index:-1;border-radius:inherit;background:color-mix(in srgb, var(--dsw-specific-input-major) 60%, transparent);backdrop-filter:blur(16px);box-shadow:inset 0 1px 0 color-mix(in srgb, var(--dsw-alias-bg-layer-3) 65%, transparent), var(--dsw-elevation-soft), 0 8px 24px -12px var(--dsw-alias-bg-mask-2);pointer-events:none;position:absolute;inset:0}body:not([data-codexhost-wallpaper]) [data-phone] .SFO4UW_card:before{background:color-mix(in srgb, var(--dsw-specific-input-major) 24%, transparent);backdrop-filter:blur(14px)}}@media (prefers-reduced-transparency:reduce),(prefers-contrast:more),(forced-colors:active){body[data-codexhost-wallpaper] .SFO4UW_card,[data-phone] .SFO4UW_card{background:var(--dsw-specific-input-major);box-shadow:var(--dsw-elevation-soft)}body[data-codexhost-wallpaper] .SFO4UW_card:before,[data-phone] .SFO4UW_card:before{display:none}}@media (prefers-contrast:more),(forced-colors:active){[data-phone] .SFO4UW_card:not(.SFO4UW_cardWorkspaceTrigger){outline:1px solid var(--dsw-alias-label-primary);outline-offset:-1px}}.SFO4UW_cardWorkspaceTrigger{--dsw-elevation-stroke-color:transparent;cursor:pointer}.SFO4UW_cardWorkspaceTrigger:after{content:"";box-sizing:border-box;border-radius:var(--dsw-radius-panel);color:var(--dsw-alias-border-l4);pointer-events:none;border:1px dashed;transition:color .1s;position:absolute;inset:0}.SFO4UW_cardWorkspaceTrigger :disabled{pointer-events:none}.SFO4UW_cardWorkspaceTrigger:hover:after{color:var(--dsw-alias-state-business-primary)}.SFO4UW_inlineNotices{flex-direction:column;gap:8px;display:flex}.SFO4UW_inlineNotices>[data-slot]>*{margin:10px 10px 0}.SFO4UW_accessory{align-items:center;gap:8px;padding:10px 12px 0;display:flex}.SFO4UW_overlayAnchor{height:0;position:absolute;inset:0 0 auto}.SFO4UW_scroll{max-height:var(--dsh-composer-text-max-height);margin-right:4px;overflow-y:auto}.SFO4UW_scroll::-webkit-scrollbar-track{margin-top:8px}.SFO4UW_grow{position:relative}.SFO4UW_pending{corner-shape:round;background:var(--dsw-alias-state-business-primary);border-radius:50%;width:8px;height:8px;animation:1s ease-in-out infinite alternate SFO4UW_input-pending}@keyframes SFO4UW_input-pending{0%{opacity:.35}to{opacity:1}}.SFO4UW_input{box-sizing:border-box;min-height:36px;font-family:var(--dsw-font-family);font-size:inherit;line-height:inherit;white-space:pre-wrap;word-break:break-word;overflow-wrap:anywhere;color:var(--dsw-alias-label-primary);caret-color:var(--dsw-alias-state-business-primary);outline:none;padding:4px 8px 0 14px}.SFO4UW_input p{margin:0}.SFO4UW_input p:last-child:after{content:var(--dsh-composer-hint);color:var(--dsw-alias-label-caption)}.SFO4UW_input[data-composer-composing] p:last-child:after{content:none}.SFO4UW_input[data-composer-composing]+.SFO4UW_placeholder{visibility:hidden}.SFO4UW_placeholder{color:var(--dsw-alias-label-caption);white-space:nowrap;text-overflow:ellipsis;pointer-events:none;-webkit-user-select:none;user-select:none;position:absolute;inset:4px 8px auto 14px;overflow:hidden}.SFO4UW_inputDisabled{color:var(--dsw-alias-label-tertiary);cursor:not-allowed}.SFO4UW_input[aria-haspopup=menu]{cursor:pointer}.SFO4UW_hero .SFO4UW_input{min-height:52px}.SFO4UW_hero .SFO4UW_placeholder{white-space:normal;-webkit-line-clamp:2;line-clamp:2;-webkit-box-orient:vertical;display:-webkit-box}@media (width<=600px){.SFO4UW_hero .SFO4UW_input{min-height:36px}.SFO4UW_hero .SFO4UW_placeholder{white-space:nowrap;display:block}}.SFO4UW_row{-webkit-user-select:none;user-select:none;flex-wrap:wrap;justify-content:space-between;align-items:center;gap:12px;min-width:0;padding:2px 8px 6px;display:flex;container-type:inline-size}.SFO4UW_row[data-model-compact]{--dsh-composer-model-text-display:none;--dsh-composer-model-icon-display:block}.SFO4UW_tools,.SFO4UW_modes,.SFO4UW_trailing{align-items:center;min-width:0;display:flex}.SFO4UW_tools,.SFO4UW_modes{gap:12px}.SFO4UW_trailing{flex:none;gap:12px;margin-left:auto}@container (width<=560px){.SFO4UW_tools,.SFO4UW_modes,.SFO4UW_trailing{gap:8px}}.SFO4UW_add{corner-shape:round;background:var(--dsw-specific-selector);width:28px;height:28px;color:var(--dsw-alias-label-primary);cursor:pointer;border:none;border-radius:999px;flex:none;place-items:center;display:grid}.SFO4UW_add:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-hover-solid)}.SFO4UW_add:disabled{opacity:.5;cursor:default}.SFO4UW_select{border-radius:var(--dsw-radius-sm);max-width:220px;height:28px;color:var(--dsw-alias-label-secondary);white-space:nowrap;cursor:pointer;appearance:none;background-color:#0000;background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12' fill='none'%3E%3Cpath d='M3 4.5L6 7.5L9 4.5' stroke='%2381858C' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");background-position:right 4px center;background-repeat:no-repeat;background-size:12px 12px;border:none;outline:none;padding:0 20px 0 8px;font-size:13px;font-weight:500;line-height:20px}.SFO4UW_select:hover:not(:disabled){background-color:var(--dsw-alias-interactive-bg-hover)}.SFO4UW_select:disabled{opacity:.5;cursor:default}.SFO4UW_primary{corner-shape:round;background:var(--dsw-alias-button-info-fill);color:#fff;cursor:pointer;border:none;border-radius:999px;flex:none;place-items:center;width:30px;height:30px;transition:background-color .1s;display:grid;transform:translateY(-2px)}.SFO4UW_primary:hover:not(:disabled){background:var(--dsw-alias-button-info-hover)}.SFO4UW_primary:disabled{opacity:.4;cursor:default}.SFO4UW_retry{border-radius:var(--dsw-radius-sm);color:inherit;cursor:pointer;background:0 0;border:1px solid;margin-left:8px;padding:1px 8px;font-size:12px}.SFO4UW_addSeat,.SFO4UW_submitSeat,.SFO4UW_controlScroll{display:contents}.SFO4UW_row[data-phone-toolbar]{flex-wrap:nowrap;gap:4px;position:relative}.SFO4UW_row[data-phone-toolbar] .SFO4UW_controlScroll{--dsh-composer-edge-gap:4px;align-items:center;gap:inherit;min-width:0;min-height:44px;margin-left:calc(var(--dsh-composer-start-width,44px) + var(--dsh-composer-edge-gap));margin-right:calc(var(--dsh-composer-end-width,44px) + var(--dsh-composer-edge-gap));overscroll-behavior-x:contain;scrollbar-width:none;flex:1;display:flex;overflow-x:auto}.SFO4UW_row[data-phone-toolbar] .SFO4UW_controlScroll::-webkit-scrollbar{display:none}.SFO4UW_row[data-phone-toolbar] .SFO4UW_tools:not([hidden]),.SFO4UW_row[data-phone-toolbar] .SFO4UW_trailing:not(.SFO4UW_trailingActive){display:contents}.SFO4UW_row[data-phone-toolbar] .SFO4UW_tools>*,.SFO4UW_row[data-phone-toolbar] [data-slot="conversation.input.left"]>*{flex-shrink:0}.SFO4UW_row[data-phone-toolbar] button:focus-visible{outline-offset:-2px}.SFO4UW_row[data-phone-toolbar] .SFO4UW_modes,.SFO4UW_row[data-phone-toolbar] .SFO4UW_standardControls{flex:none;gap:4px;width:max-content}.SFO4UW_row[data-phone-toolbar] .SFO4UW_standardControls{margin-left:0}.SFO4UW_row[data-phone-toolbar] .SFO4UW_addSeat,.SFO4UW_row[data-phone-toolbar] .SFO4UW_submitSeat{z-index:1;flex:none;align-items:center;gap:4px;display:flex;position:absolute;inset-block:2px 6px}.SFO4UW_row[data-phone-toolbar] .SFO4UW_addSeat{left:8px}.SFO4UW_row[data-phone-toolbar] .SFO4UW_submitSeat{margin-left:0;right:8px}.SFO4UW_row[data-phone-toolbar] .SFO4UW_add,.SFO4UW_row[data-phone-toolbar] .SFO4UW_primary{box-sizing:border-box;background-clip:padding-box;width:44px;height:44px}.SFO4UW_row[data-phone-toolbar] .SFO4UW_add{border:8px solid #0000}.SFO4UW_row[data-phone-toolbar] .SFO4UW_primary{border:7px solid #0000}.SFO4UW_row[data-phone-toolbar][data-toolbar-activity] .SFO4UW_controlScroll{display:contents}.SFO4UW_row[data-phone-toolbar][data-toolbar-activity] .SFO4UW_submitSeat{position:static}.SFO4UW_row[data-actions-overflow] [data-composer-overflow-action]{display:none}.SFO4UW_standardControls{align-items:center;gap:12px;min-width:0;display:flex}.SFO4UW_tools[hidden],.SFO4UW_standardControls[hidden]{display:none}.SFO4UW_trailingActive{flex:1;margin-left:0}.SFO4UW_activity{flex:none;align-items:center;display:flex}.SFO4UW_activity:empty{display:none}.SFO4UW_activityExpanded{flex:1;min-width:0}.SFO4UW_annotations{scrollbar-width:none;align-items:center;gap:6px;padding:8px 12px 0;display:flex;overflow-x:auto}.SFO4UW_annotations::-webkit-scrollbar{display:none}.SFO4UW_annotations>*{flex:none}.SFO4UW_creationError{border-radius:var(--dsw-radius-md);background:var(--dsw-alias-interactive-bg-hover-danger);color:var(--dsw-alias-state-error-primary);align-items:center;gap:8px;margin:2px 10px 0;padding:8px 10px;font-size:13px;line-height:18px;display:flex}.SFO4UW_creationErrorIcon{flex:none}.SFO4UW_creationErrorCopy{overflow-wrap:anywhere;flex-direction:column;flex:1;gap:2px;min-width:0;display:flex}.SFO4UW_creationErrorTitle{font-weight:500}.SFO4UW_creationErrorDetail{color:var(--dsw-alias-label-secondary);font-size:12px;line-height:17px}.SFO4UW_creationRetry{border-radius:var(--dsw-radius-sm);min-height:28px;color:var(--dsw-alias-state-error-primary);font:inherit;cursor:pointer;touch-action:manipulation;background:0 0;border:1px solid;flex:none;padding:4px 10px;font-size:12px;font-weight:500;line-height:16px}.SFO4UW_creationRetry:hover{background:color-mix(in srgb, currentColor 10%, transparent)}.SFO4UW_creationRetry:focus-visible{outline-offset:2px;outline:2px solid}.SFO4UW_pendingControls{align-items:center;gap:6px;min-width:0;display:inline-flex}.SFO4UW_pendingModel{border-radius:var(--dsw-radius-sm);max-width:min(220px,45cqw);height:28px;color:var(--dsw-alias-label-tertiary);white-space:nowrap;user-select:none;align-items:center;gap:6px;padding:0 8px;font-size:13px;line-height:20px;display:inline-flex}.SFO4UW_pendingModelLabel{text-overflow:ellipsis;min-width:0;overflow:hidden}.SFO4UW_pendingHarness{width:30px;height:28px;color:var(--dsw-alias-label-tertiary);opacity:.7;user-select:none;border-radius:6px;flex-shrink:0;justify-content:center;align-items:center;display:inline-flex}[data-phone] .SFO4UW_creationRetry{min-height:36px;padding:6px 12px}[data-phone] .SFO4UW_pendingModel{max-width:none}[data-phone] .SFO4UW_pendingModelLabel{max-width:120px}[data-phone] .SFO4UW_pendingHarness{width:36px;height:36px}`,document.head.appendChild(e)}var $={accessory:`SFO4UW_accessory`,activity:`SFO4UW_activity`,activityExpanded:`SFO4UW_activityExpanded`,add:`SFO4UW_add`,addSeat:`SFO4UW_addSeat`,annotations:`SFO4UW_annotations`,card:`SFO4UW_card`,cardStack:`SFO4UW_cardStack`,cardWorkspaceTrigger:`SFO4UW_cardWorkspaceTrigger`,controlScroll:`SFO4UW_controlScroll`,creationError:`SFO4UW_creationError`,creationErrorCopy:`SFO4UW_creationErrorCopy`,creationErrorDetail:`SFO4UW_creationErrorDetail`,creationErrorIcon:`SFO4UW_creationErrorIcon`,creationErrorTitle:`SFO4UW_creationErrorTitle`,creationRetry:`SFO4UW_creationRetry`,dock:`SFO4UW_dock`,grow:`SFO4UW_grow`,hero:`SFO4UW_hero`,inlineNotices:`SFO4UW_inlineNotices`,input:`SFO4UW_input`,"input-pending":`SFO4UW_input-pending`,inputDisabled:`SFO4UW_inputDisabled`,modes:`SFO4UW_modes`,notice:`SFO4UW_notice`,overlayAnchor:`SFO4UW_overlayAnchor`,pending:`SFO4UW_pending`,pendingControls:`SFO4UW_pendingControls`,pendingHarness:`SFO4UW_pendingHarness`,pendingModel:`SFO4UW_pendingModel`,pendingModelLabel:`SFO4UW_pendingModelLabel`,placeholder:`SFO4UW_placeholder`,primary:`SFO4UW_primary`,retry:`SFO4UW_retry`,root:`SFO4UW_root`,row:`SFO4UW_row`,scroll:`SFO4UW_scroll`,select:`SFO4UW_select`,standardControls:`SFO4UW_standardControls`,submitSeat:`SFO4UW_submitSeat`,tools:`SFO4UW_tools`,topRail:`SFO4UW_topRail`,trailing:`SFO4UW_trailing`,trailingActive:`SFO4UW_trailingActive`};let ED=[],DD=(0,g.memo)(function({useSession:e,useInput:t,inputActions:n,keyboard:r,pendingDraft:i,addFiles:a,removeAttachment:o,resolveDraftAttachments:s,retryFileUpload:c,revealResponseAnnotation:l,toggleCommandMenu:u,stop:f,t:p,renderSlot:m,usePendingDraftText:_,useBusyEnter:v,useFileUploads:y,useNotices:b,useLexicon:ee,useMenuLauncher:te,useStopShortcut:ne,useProjection:re,sessionId:ie,variant:ae,disabled:oe=!1,preparingDraft:se=!1,sessionCreation:ce,onRetrySessionCreation:le,blocked:ue,workspacePickerOpen:de=!1,onRequestWorkspace:fe,placeholder:pe,topBar:me,accessory:x}){let S=t(e=>e),he=_(e=>e),ge=S?.responseAnnotations??ED,_e=(0,g.useMemo)(()=>({label:e=>p(`annotation.label`,{index:e}),railLabel:e=>p(`annotation.chipLabel`,{index:e}),railTitle:(e,t)=>p(`annotation.title`,{index:e,excerpt:t}),remove:e=>p(`annotation.remove`,{index:e}),selectedText:p(`annotation.selectedText`),userComment:p(`annotation.userComment`)}),[p]),ve=b(e=>e),ye=v(e=>e),be=ne(e=>e),xe=te(e=>e===`command`),[Se,Ce]=(0,g.useState)(!1);(0,g.useEffect)(()=>{Ce(!1)},[ie]);let we=e(e=>e.promptError)??null,Te=e(e=>e.running)??!1,Ee=e(e=>e.subagent)??null,De=e(e=>e.removed)??!1,Oe=re(`plan`,e=>e!==void 0&&(e.pending?!e.active:e.active)),ke=re(`goal`,e=>e!=null),C=ie===void 0&&i!==void 0&&ce!==void 0&&ce.state!==`idle`,Ae=C&&ce.state===`creating`,je=C&&ce.state===`error`,Me=C?ce.token:void 0,Ne=S!==void 0&&r!==void 0&&n!==void 0,Pe=C?he:S?.draft??``,Fe=S?.primaryAction,Ie=C?i.editor:r?.editor??null,Le=(0,g.useMemo)(()=>S===void 0||s===void 0?[]:s(S.attachmentIds),[s,S?.attachmentIds]),Re=Pe.trim()===``&&Le.length===0&&ge.length===0,ze=y(e=>e),Be=Le.some(e=>ze[e.id]?.status===`error`),[Ve,He]=(0,g.useState)(null),Ue=(0,g.useRef)(0),We=(0,g.useCallback)(e=>{Ue.current+=1,He({seq:Ue.current,text:e})},[]),Ge=(0,g.useCallback)(()=>{He(null)},[]),Ke=re(`imageLimits`),qe=re(`attachmentInput`),Je=re(`queueState`),Ye=qe?.enabled!==!1,Xe=qe?.imagesOnly===!0;(0,g.useEffect)(()=>{if(we===null)return;let{error:e}=we;e.code===`session/writer-held`?We(p(`error.sessionInUse`)):e.code===`remote/turn-changed`?We(p(`error.steerTurnChanged`)):e.code===`remote/steer-unavailable`?We(p(`error.remoteSteerUnavailable`)):We(e.code===`session/attachment-invalid`||e.code===`subagent/attachment-invalid`?hD(p,e.details.reason,Ke):`${e.message} (${e.code})`)},[we,We,p,Ke]),(0,g.useEffect)(()=>{ve?.level===`error`&&We(ve.text)},[ve,We]);let Ze=(0,g.useRef)(null),[Qe,$e]=(0,g.useState)({phone:!1,overflowActions:!1});(0,g.useLayoutEffect)(()=>{let e=Ze.current;if(e!==null)return wD(e,$e)},[]);let et=(0,g.useRef)(null),tt=(0,g.useRef)(null),nt=Ee?.address.mode===`continuable`,rt=nt&&Ee.parentAvailable!==!0,it=C||De||oe||!Ne||ue!==void 0||rt,at=it,ot=C||De||oe||!Ne,st=S?.phase===`adjudicating`||S?.phase===`submitting`,ct=!C&&oe&&!De&&fe!==void 0,lt=C||Ne&&!st&&(!at||!C&&se&&Ne&&!De&&!rt&&!ct),ut=De||!lt&&!ct,dt=Ee===null||Ee.address.mode===`continuable`,ft=!at&&!st&&Re&&Te&&dt&&Je?.previewOnly!==!0&&S.queue.length>0,pt=(0,g.useRef)(C),mt=(0,g.useRef)(!1);if(pt.current&&!C&&ie!==void 0){let e=document.activeElement;e!==null&&et.current?.contains(e)&&(mt.current=!0)}(0,g.useLayoutEffect)(()=>{pt.current=C},[C]),(0,g.useEffect)(()=>{S!==void 0&&n!==void 0&&Le.length!==S.attachmentIds.length&&n.pruneAttachments(Le.map(e=>e.id))},[Le,S?.attachmentIds,n]);let ht=()=>{cD(tt)};(0,g.useEffect)(()=>{C?Ie!==null&&(0,d.shouldAutoFocusTextInput)()&&lD(Ie,ht):Ie!==null&<&&(mt.current?(mt.current=!1,lD(Ie,ht)):!at&&(0,d.shouldAutoFocusTextInput)()&&lD(Ie,ht))},[C,Me,at,lt,ie,Ie]),(0,g.useEffect)(()=>{at||Pe===``||ht()},[Pe!==``]),(0,g.useEffect)(()=>uD(tt),[]);let gt=(0,g.useCallback)((e,t)=>{if(Ee!==null||a===void 0||e.length===0)return;if(!Ye){We(p(`attachment.unavailable`));return}let n=(()=>{if(Xe&&e.some(e=>!(Ke?.mediaTypes)?.includes(e.type)))return p(`image.unsupportedType`);if(Ke!==void 0){let t=Ke.mediaTypes,n=e.filter(e=>t.includes(e.type)),r=Le.filter(e=>e.kind===`image`);if(r.length+n.length>Ke.maxImagesPerMessage)return p(`image.tooMany`,{count:Ke.maxImagesPerMessage});if(n.some(e=>e.size>Ke.maxImageBytes))return p(`image.fileTooLarge`,{size:mD(Ke.maxImageBytes)});if(r.reduce((e,t)=>e+t.file.size,0)+n.reduce((e,t)=>e+t.size,0)>Ke.maxMessageImageBytes)return p(`image.totalTooLarge`,{size:mD(Ke.maxMessageImageBytes)})}return a(e,t)})();n!==null&&We(n)},[Ee,a,Ye,Xe,Le,Ke,We,p]),_t=Ye&&Ee===null&&!at&&!st&&a!==void 0,vt=p(Ye?Xe?`input.imagesAndCommands`:`input.commands`:`input.commandsOnly`),yt=(0,g.useRef)(null),bt=e=>{let t=e.target.files===null?[]:[...e.target.files];e.target.value=``,t.length>0&>(t)},xt=(0,g.useRef)({locked:at,canPasteText:lt,machineBusy:st,primaryAction:Fe,canSteerQueue:ft,running:Te,steeringAvailable:dt,busyEnter:ye,intakeFiles:gt,uploadsFailed:Be,showToast:We,t:p,canAcceptDrop:_t});xt.current={locked:at,canPasteText:lt,machineBusy:st,primaryAction:Fe,canSteerQueue:ft,running:Te,steeringAvailable:dt,busyEnter:ye,intakeFiles:gt,uploadsFailed:Be,showToast:We,t:p,canAcceptDrop:_t},(0,g.useEffect)(()=>{if(r!==void 0)return dD(r,xt,yt)},[r]),(0,g.useEffect)(()=>{if(Ie!==null){if(C&&i!==void 0)return sD(Ie,{arbitrate:()=>`pass`,space:()=>!1,dismissPopup:()=>{},canSubmit:()=>!1,submit:()=>{},intakeFiles:()=>{xt.current.showToast(xt.current.t(`newSession.uploadUnavailable`))},pasteText:e=>{i.paste(e)}});if(r!==void 0)return fD(Ie,r,xt)}},[Ie,r,C,i]);let St=e=>{pD(e,Ie)},Ct=()=>{r!==void 0&&(Ie!==null&&(0,d.shouldAutoFocusTextInput)()&&lD(Ie,ht),u?.(r.caretSpan()))},wt=e=>{ct&&(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),fe())},Tt=Fe===void 0&&Te&&Ee===null&&(Re||ue!==void 0),Et=Tt?f===void 0:(Fe===void 0?Re:Fe.disabled)||it||st,Dt=Te&&nt,w=sE(ye,Te,`enter`,dt),Ot=!Re&&S?.phase===`plain`&&!Pe.trimStart().startsWith(`/`),kt=p(Tt?`input.stop`:Fe===void 0&&Te&&dt&&!it&&!Be&&Ot?w===`steer`?`input.send.steer`:`input.send.queue`:`input.send`),At=()=>{Tt?f?.():Be?We(p(`file.retryOrRemove`)):Fe===void 0?r!==void 0&&!Re&&!it&&!st&&r.submit(w,`click`):Et||Fe.run()},jt=(S?.phase===`claimed`||S?.phase===`submitting`)&&S.claim!==void 0&&Pe.startsWith(S.claim.token),Mt=jt&&S.claim.hint!==void 0&&Pe.slice(S.claim.token.length).trim()===``?S.claim.hint:null,Nt=(()=>{if(Mt===null)return null;let e=S?.claim?.name??``,t=`hint.${e===`goal`&&ke?`goal.active`:e}`,n=p(t);return n===t?Mt:n})(),Pt=pe??p(rt?`placeholder.parentOffline`:it?`placeholder.unavailable`:ft?`placeholder.steerQueue`:Oe?`placeholder.plan`:`placeholder.default`);return/* @__PURE__ */ (0,h.jsxs)(`div`,{className:Rb($.root,ae===`hero`&&$.hero),"data-composer-variant":ae,children:[Ve!==null&&/* @__PURE__ */ (0,h.jsx)(d.Toast,{text:Ve.text,icon:/* @__PURE__ */ (0,h.jsx)(d.IconWarningOutlineRegular,{}),anchor:et.current,onDone:Ge},Ve.seq),ve?.level===`info`&&/* @__PURE__ */ (0,h.jsx)(`div`,{className:$.notice,role:`status`,children:ve.text}),/* @__PURE__ */ (0,h.jsxs)(`div`,{className:$.cardStack,children:[me!==void 0&&/* @__PURE__ */ (0,h.jsx)(`div`,{className:$.topRail,"data-composer-top-bar":``,onClick:e=>{e.stopPropagation()},onPointerDown:e=>{e.stopPropagation()},children:me}),/* @__PURE__ */ (0,h.jsxs)(`div`,{ref:et,className:Rb($.card,ct&&$.cardWorkspaceTrigger),"data-composer-card":!0,onClick:ct?fe:void 0,onPointerDown:ct?e=>{e.stopPropagation()}:void 0,children:[ie!==void 0&&/* @__PURE__ */ (0,h.jsx)(`div`,{className:$.overlayAnchor,children:m(`conversation.input.overlay`,{})}),x!==void 0&&/* @__PURE__ */ (0,h.jsx)(`div`,{className:$.accessory,children:x}),je&&/* @__PURE__ */ (0,h.jsxs)(`div`,{className:$.creationError,role:`alert`,"data-new-session-error":``,children:[/* @__PURE__ */ (0,h.jsx)(d.IconWarningOutlineRegular,{className:$.creationErrorIcon,size:16}),/* @__PURE__ */ (0,h.jsxs)(`div`,{className:$.creationErrorCopy,children:[/* @__PURE__ */ (0,h.jsx)(`span`,{className:$.creationErrorTitle,children:p(`newSession.createFailedTitle`)}),/* @__PURE__ */ (0,h.jsx)(`span`,{className:$.creationErrorDetail,children:ce.reason===`no-harness`?p(`newSession.createFailed.noHarness`):ce.reason===`workspace-required`?p(`newSession.createFailed.workspaceRequired`):ce.message??p(`newSession.createFailed.generic`)})]}),le!==void 0&&/* @__PURE__ */ (0,h.jsx)(`button`,{type:`button`,className:$.creationRetry,onMouseDown:St,onClick:le,children:p(`newSession.retry`)})]}),ge.length===0?null:/* @__PURE__ */ (0,h.jsx)(`div`,{className:$.annotations,"data-composer-annotations":!0,children:ge.map((e,t)=>/* @__PURE__ */ (0,h.jsx)(d.ResponseAnnotationChip,{index:t+1,annotation:e,labels:_e,onActivate:e.anchor===void 0?void 0:()=>l?.(e.id),onRemove:()=>{n?.removeResponseAnnotation(e.id)}},e.id))}),S===void 0||ie===void 0?null:/* @__PURE__ */ (0,h.jsx)(`div`,{className:$.inlineNotices,children:m(`conversation.input.notice`,{})}),m(`conversation.input.attachments`,{attachments:Le,canAcceptDrop:_t,onAddFiles:gt,onRemoveAttachment:e=>{o?.(e)},uploads:ze,onRetryFile:e=>{c?.(e)},dropLimits:Ke===void 0?void 0:{count:Ke.maxImagesPerMessage,size:mD(Ke.maxImageBytes)}}),/* @__PURE__ */ (0,h.jsx)(aD,{classNames:$,editor:Ie,scrollRef:tt,editable:lt,editorDisabled:ut,preserveFocus:mt.current,phase:C?`plain`:S?.phase??`inert`,placeholderText:Pt,ariaLabel:ct?p(`hero.chooseWorkspace`):Pt,workspaceTrigger:ct,workspacePickerOpen:de,onWorkspaceKeyDown:wt,hint:Nt,showPlaceholder:Pe===``&&Le.length===0&&!jt}),/* @__PURE__ */ (0,h.jsx)(`div`,{ref:Ze,className:$.row,"data-composer-toolbar":!0,"data-command-menu-open":xe||void 0,"data-toolbar-activity":Se||void 0,children:/* @__PURE__ */ (0,h.jsxs)(`div`,{className:$.controlScroll,"data-toolbar-scroll":!0,children:[/* @__PURE__ */ (0,h.jsxs)(`div`,{className:$.tools,hidden:Se,"data-composer-tools":!0,children:[/* @__PURE__ */ (0,h.jsx)(`div`,{className:$.addSeat,"data-toolbar-fixed":`start`,children:/* @__PURE__ */ (0,h.jsx)(d.Tooltip,{portal:Qe.phone,label:vt,side:`top`,delayMs:500,children:/* @__PURE__ */ (0,h.jsx)(`button`,{type:`button`,className:$.add,"aria-label":vt,"aria-haspopup":`listbox`,"aria-expanded":xe,disabled:at||st||u===void 0,onMouseDown:St,onClick:Ct,children:/* @__PURE__ */ (0,h.jsx)(d.IconPlusOutlineMedium,{size:14})})})}),/* @__PURE__ */ (0,h.jsx)(`input`,{ref:yt,type:`file`,accept:Xe?Ke?.mediaTypes.join(`,`):void 0,multiple:!0,disabled:!Ye||Ee!==null,hidden:!0,onChange:bt}),/* @__PURE__ */ (0,h.jsxs)(`div`,{className:$.modes,children:[ie===void 0?null:m(`conversation.input.permission`,{locked:at}),ie===void 0?null:m(`conversation.input.plan`,{locked:at})]}),S===void 0||ie===void 0?null:m(`conversation.input.left`,{})]}),/* @__PURE__ */ (0,h.jsxs)(`div`,{className:Rb($.trailing,Se&&$.trailingActive),children:[/* @__PURE__ */ (0,h.jsxs)(`div`,{className:$.standardControls,hidden:Se,children:[S===void 0||ie===void 0?null:m(`conversation.input.right`,{overflowActions:Qe.overflowActions}),ie===void 0?Ae?/* @__PURE__ */ (0,h.jsxs)(`div`,{className:$.pendingControls,role:`status`,"aria-live":`polite`,"data-new-session-loading":``,children:[/* @__PURE__ */ (0,h.jsxs)(`span`,{className:$.pendingModel,children:[/* @__PURE__ */ (0,h.jsx)(d.StateDot,{state:`ongoing`}),/* @__PURE__ */ (0,h.jsx)(`span`,{className:$.pendingModelLabel,children:p(`newSession.loadingModel`)})]}),/* @__PURE__ */ (0,h.jsx)(`span`,{className:$.pendingHarness,role:`img`,"aria-label":p(`newSession.loadingHarness`),"aria-busy":`true`,title:p(`newSession.loadingHarness`),children:/* @__PURE__ */ (0,h.jsx)(d.StateDot,{state:`ongoing`})})]}):null:m(`conversation.input.model`,{locked:ot})]}),S===void 0||ie===void 0?null:/* @__PURE__ */ (0,h.jsx)(`div`,{className:Se?$.activityExpanded:$.activity,children:m(`conversation.input.activity`,{locked:at,onActiveChange:Ce})}),/* @__PURE__ */ (0,h.jsxs)(`div`,{className:$.submitSeat,"data-toolbar-fixed":`end`,children:[Dt&&/* @__PURE__ */ (0,h.jsx)(d.Tooltip,{portal:Qe.phone,label:p(`input.stop`),shortcutKeys:be,side:`top`,delayMs:500,disabled:f===void 0,children:/* @__PURE__ */ (0,h.jsx)(`button`,{type:`button`,className:$.primary,"aria-label":p(`input.stop`),disabled:f===void 0,onMouseDown:St,onClick:f,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:Qe.phone,label:Tt?p(`input.stop`):kt,shortcutKeys:Tt?be:void 0,side:`top`,delayMs:500,disabled:Et,children:/* @__PURE__ */ (0,h.jsx)(`button`,{type:`button`,className:$.primary,"aria-label":kt,disabled:Et,onMouseDown:St,onClick:At,children:Tt?/* @__PURE__ */ (0,h.jsx)(`svg`,{viewBox:`0 0 16 16`,width:`14`,height:`14`,"aria-hidden":!0,children:/* @__PURE__ */ (0,h.jsx)(`rect`,{x:`3`,y:`3`,width:`10`,height:`10`,rx:`3`,fill:`currentColor`})}):/* @__PURE__ */ (0,h.jsx)(`svg`,{viewBox:`0 0 16 16`,width:`14`,height:`14`,"aria-hidden":!0,children:/* @__PURE__ */ (0,h.jsx)(`path`,{d:`M8.3125 0.980183C8.66767 1.0531 8.97902 1.20418 9.2627 1.43233C9.48724 1.61297 9.73029 1.85793 9.97949 2.10714L14.707 6.83468L13.293 8.24874L9 3.95577V15.0417H7V3.95577L2.70703 8.24874L1.29297 6.83468L6.02051 2.10714C6.26971 1.85793 6.51277 1.61297 6.7373 1.43233C6.97662 1.23986 7.28445 1.04402 7.6875 0.980183C7.8973 0.947006 8.1031 0.95516 8.3125 0.980183Z`,fill:`currentColor`})})})})]})]})]})})]})]}),/* @__PURE__ */ (0,h.jsxs)(`div`,{className:$.dock,"data-composer-dock":!0,children:[ae===`composer`&&S!==void 0&&ie!==void 0?m(`conversation.composer.dock`,{}):null,Se?null:/* @__PURE__ */ (0,h.jsx)(CD,{useProjection:re,t:p})]})]})}),OD=`@deepseek-ai/dsh-client-ui-conversation/TodoPanel.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(OD)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-conversation`,e.dataset.pluginCss=OD,e.textContent=`.OKyn-W_root{box-sizing:border-box;width:calc(100% - var(--dsh-composer-side-clearance) - var(--dsh-composer-side-clearance) - var(--dsh-composer-dock-inset) - var(--dsh-composer-dock-inset) - var(--dsh-composer-dock-inset) - var(--dsh-composer-dock-inset));max-width:calc(var(--dsh-composer-card-max-width) - var(--dsh-composer-dock-inset) - var(--dsh-composer-dock-inset) - var(--dsh-composer-dock-inset) - var(--dsh-composer-dock-inset));--dsw-elevation-stroke-color:var(--dsw-alias-border-l1);border-radius:var(--dsw-radius-lg);background:var(--dsw-specific-menu);backdrop-filter:var(--dsw-menu-backdrop-filter);box-shadow:var(--dsw-elevation-panel);--dsh-scrollbar-thumb:var(--dsw-alias-scrollbar-bg-l2);--dsh-scrollbar-thumb-hover:var(--dsw-alias-scrollbar-hover-l2);border:0;flex:none;margin:0 auto;overflow:hidden}.OKyn-W_body{flex-direction:column;gap:8px;padding:6px 12px;display:flex}.OKyn-W_header{text-align:left;cursor:pointer;background:0 0;border:none;align-items:center;gap:10px;width:100%;padding:0;display:flex}.OKyn-W_lead{color:var(--dsw-alias-label-tertiary);flex:none;place-items:center;display:grid}.OKyn-W_title{color:var(--dsw-alias-label-primary);flex:none;font-size:13px;font-weight:500;line-height:24px}.OKyn-W_progress{min-width:0;color:var(--dsw-alias-label-tertiary);text-overflow:ellipsis;white-space:nowrap;flex:auto;font-size:13px;font-weight:400;line-height:20px;overflow:hidden}.OKyn-W_chevron{color:var(--dsw-alias-label-tertiary);flex:none;place-items:center;display:grid}.OKyn-W_list{flex-direction:column;gap:8px;max-height:180px;margin:0;padding:0;list-style:none;display:flex;overflow-y:auto}.OKyn-W_item{min-width:0;color:var(--dsw-alias-label-secondary);align-items:center;gap:10px;font-size:13px;line-height:20px;display:flex}.OKyn-W_glyph{flex:none;place-items:center;width:16px;height:16px;display:grid}.OKyn-W_content{text-overflow:ellipsis;white-space:nowrap;min-width:0;overflow:hidden}`,document.head.appendChild(e)}var kD={body:`OKyn-W_body`,chevron:`OKyn-W_chevron`,content:`OKyn-W_content`,glyph:`OKyn-W_glyph`,header:`OKyn-W_header`,item:`OKyn-W_item`,lead:`OKyn-W_lead`,list:`OKyn-W_list`,progress:`OKyn-W_progress`,root:`OKyn-W_root`,title:`OKyn-W_title`};
|
|
167
|
+
n!==null&&(e.ctrlKey||e.deltaY===0||n.scrollBy({top:PO(e,n)}))},[]);return/* @__PURE__ */ (0,h.jsx)(`div`,{className:Q.widthHandle,"data-side":e.side,"data-width-handle":e.side,onPointerDown:l,onPointerMove:u,onPointerUp:d,onPointerCancel:f,onLostPointerCapture:f,onWheel:p})}function IO({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=MO();r===null?t.style.removeProperty(`--dsh-chat-user-width`):t.style.setProperty(`--dsh-chat-user-width`,`${NO(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:NO(e.offsetWidth,MO()),[e]),i=(0,g.useCallback)(t=>{e!==null&&(e.parentElement??e).style.setProperty(`--dsh-chat-user-width`,`${NO(e.offsetWidth,t)}px`)},[e]),a=(0,g.useCallback)(t=>{e!==null&&localStorage.setItem(jO,`${NO(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)(FO,{side:e,onStart:r,onDrag:i,onCommit:a,onEnd:o},e))}let LO={widthControls:IO};function RO(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`:kO(s,c),u=s?.openState,d=r(e=>t===void 0?void 0:e.byId[t]?.blank),f=s?.subagent?.address.mode===`continuable`&&s.subagent.parentAvailable===void 0,p=t!==void 0&&(l===`blank`&&u===`loading`&&d!==!0||f),m=t===void 0||l===`blank`&&(u===`open`||d===!0),g=p?`settling`:m?`hero`:`active`;return/* @__PURE__ */ (0,h.jsxs)(`div`,{className:Q.root,"data-phase":g,"data-cx-region":`conversation`,children:[a(`conversation.header`,{}),a(`conversation.header.notice`,{}),o(`conversation.content`,{variant:`main`,phase:g,hero:m},{slots:LO})]})}function zO(e){return/* @__PURE__ */ (0,h.jsx)(RO,{...e})}function BO(e,t){return e===`default-workspace`?t:e}let VO=`@deepseek-ai/dsh-client-ui-conversation/HeroShell.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(VO)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-conversation`,e.dataset.pluginCss=VO,e.textContent=`.Dgrl1G_root{justify-content:center;align-items:center;min-width:0;height:100%;padding:0 24px;display:flex}.Dgrl1G_stack{width:100%;max-width:var(--dsh-composer-card-max-width);flex-direction:column;align-items:stretch;gap:12px;display:flex;overflow:visible}.Dgrl1G_headline{color:var(--dsw-alias-label-primary);flex-wrap:wrap;justify-content:center;align-items:center;gap:12px 10px;font-size:26px;font-weight:500;line-height:32px;display:flex}.Dgrl1G_titleGroup{flex-wrap:wrap;justify-content:center;align-items:center;gap:4px 7px;min-width:0;display:flex}.Dgrl1G_previewBadge{border:.5px solid var(--dsw-alias-interactive-bg-hover);corner-shape:round;background:var(--dsw-alias-state-business-tertiary);color:var(--dsw-alias-label-primary-bluish);font-family:var(--ds-font-family-code);white-space:nowrap;border-radius:999px;align-self:flex-start;margin-top:2px;padding:1px 7px 0;font-size:12px;font-weight:500;line-height:18px}.Dgrl1G_fishHitbox{flex:none;justify-content:center;align-items:center;display:inline-flex}.Dgrl1G_fish{transform-origin:50% 60%;color:var(--dsw-alias-label-primary);display:block;overflow:visible}@keyframes Dgrl1G_hero-fish-swim{0%,to{transform:none}35%{transform:rotate(-4deg)translate(-.4px,-.9px)}70%{transform:rotate(1.6deg)translate(.3px,.2px)}}@media (hover:hover) and (prefers-reduced-motion:no-preference){.Dgrl1G_fishHitbox:hover .Dgrl1G_fish{animation:1.6s ease-in-out infinite Dgrl1G_hero-fish-swim}}.Dgrl1G_body{flex-direction:column;gap:12px;min-width:0;display:flex;position:relative;overflow:visible}.Dgrl1G_body>*{z-index:1;position:relative}.Dgrl1G_body>.Dgrl1G_workspaceRow{z-index:10;align-items:center;min-width:0;padding-left:8px;display:flex}.Dgrl1G_workspace{border-radius:var(--dsw-radius-sm);max-width:min(100%,360px);min-height:28px;color:var(--dsw-alias-label-primary);cursor:pointer;background:0 0;border:none;align-items:center;gap:4px;padding:0 8px;font-size:13px;font-weight:500;line-height:20px;display:inline-flex}.Dgrl1G_workspace:not(:disabled):hover,.Dgrl1G_workspace[aria-expanded=true]{background:var(--dsw-alias-interactive-bg-hover)}.Dgrl1G_workspace:disabled{cursor:default}.Dgrl1G_folder{color:var(--dsw-alias-label-primary);flex:none}.Dgrl1G_workspaceLabel{text-overflow:ellipsis;white-space:nowrap;min-width:0;overflow:hidden}.Dgrl1G_chevron{color:var(--dsw-alias-label-caption);flex:none}.Dgrl1G_modalInput{box-sizing:border-box;border:.5px solid var(--dsw-alias-border-l4);border-radius:var(--dsw-radius-lg);width:100%;height:44px;color:var(--dsw-alias-label-primary);background:0 0;outline:none;padding:7px 14px;font-size:14px;font-weight:400;line-height:22px}.Dgrl1G_modalInput::placeholder{color:var(--dsw-alias-label-caption)}.Dgrl1G_modalInput:disabled{color:var(--dsw-alias-label-dimmed)}.Dgrl1G_modalAction{min-width:72px}.Dgrl1G_modalError{color:var(--dsw-alias-state-error-primary);margin-top:8px;font-size:12px;line-height:18px}`,document.head.appendChild(e)}var HO={body:`Dgrl1G_body`,chevron:`Dgrl1G_chevron`,fish:`Dgrl1G_fish`,fishHitbox:`Dgrl1G_fishHitbox`,folder:`Dgrl1G_folder`,headline:`Dgrl1G_headline`,"hero-fish-swim":`Dgrl1G_hero-fish-swim`,modalAction:`Dgrl1G_modalAction`,modalError:`Dgrl1G_modalError`,modalInput:`Dgrl1G_modalInput`,previewBadge:`Dgrl1G_previewBadge`,root:`Dgrl1G_root`,stack:`Dgrl1G_stack`,titleGroup:`Dgrl1G_titleGroup`,workspace:`Dgrl1G_workspace`,workspaceLabel:`Dgrl1G_workspaceLabel`,workspaceRow:`Dgrl1G_workspaceRow`};function UO(e){let t=Lu(e);return t===``?e:t}function WO({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:HO.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:HO.folder,size:16}):/* @__PURE__ */ (0,h.jsx)(d.IconFolderOpenRegular,{className:HO.folder,size:16}),/* @__PURE__ */ (0,h.jsx)(`span`,{className:HO.workspaceLabel,children:t??a(`hero.chooseWorkspace`)}),/* @__PURE__ */ (0,h.jsx)(d.IconChevronDownOutlineRegular,{className:HO.chevron,size:12})]})}function GO({hovering:e}){return/* @__PURE__ */ (0,h.jsx)(`svg`,{className:HO.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 KO({t:e,renderSlot:t,children:n}){let[r,i]=(0,g.useState)(!1);return/* @__PURE__ */ (0,h.jsxs)(`div`,{className:HO.root,children:[/* @__PURE__ */ (0,h.jsxs)(`div`,{className:HO.stack,children:[/* @__PURE__ */ (0,h.jsxs)(`div`,{className:HO.headline,children:[/* @__PURE__ */ (0,h.jsx)(`span`,{className:HO.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:HO.fish},{fallback:/* @__PURE__ */ (0,h.jsx)(GO,{hovering:r})})}),/* @__PURE__ */ (0,h.jsxs)(`span`,{className:HO.titleGroup,children:[/* @__PURE__ */ (0,h.jsx)(`span`,{children:e(`hero.headline`)}),/* @__PURE__ */ (0,h.jsx)(`span`,{className:HO.previewBadge,children:e(`hero.preview`)})]})]}),/* @__PURE__ */ (0,h.jsx)(`div`,{className:HO.body})]}),n]})}let qO=`@deepseek-ai/dsh-client-ui-conversation/ThreadReferenceDropTarget.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(qO)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-conversation`,e.dataset.pluginCss=qO,e.textContent=`.tWXKHq_overlay{z-index:30;pointer-events:none;background:color-mix(in srgb, var(--dsw-alias-state-business-tertiary) 88%, transparent);place-items:center;display:grid;position:absolute;inset:0}.tWXKHq_invitation{flex-direction:column;align-items:center;gap:8px;max-width:calc(100% - 40px);display:flex}.tWXKHq_hint{border:1px solid color-mix(in srgb, var(--dsw-alias-state-business-primary) 15%, transparent);background:var(--dsw-alias-state-business-tertiary);color:var(--dsw-alias-label-primary);border-radius:10px;padding:8px 16px;font-size:16px;line-height:24px;box-shadow:0 1px 4px #00000014}.tWXKHq_preview{box-sizing:border-box;border:1px solid var(--dsw-alias-border-l3);background:var(--dsw-alias-bg-base);max-width:min(440px,100%);color:var(--dsw-alias-label-primary);border-radius:12px;align-items:center;gap:10px;padding:10px 14px;font-size:14px;line-height:20px;display:flex;box-shadow:0 4px 14px #00000014}.tWXKHq_preview svg{flex:none}.tWXKHq_title{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}`,document.head.appendChild(e)}var JO={hint:`tWXKHq_hint`,invitation:`tWXKHq_invitation`,overlay:`tWXKHq_overlay`,preview:`tWXKHq_preview`,title:`tWXKHq_title`};function YO({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:LS(IS(e)),n=t===void 0?void 0:a.current[t];return n!==void 0&&FS(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:zS(t.getData(PS));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(Np,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=zS(a.getData(PS));i()&&c(r)&&r?.threadId===n?.threadId&&r?.hostId===n?.hostId?t.dispatchCommand(jp,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:JO.overlay,"data-thread-reference-drop":!0,role:`status`,"aria-live":`polite`,children:/* @__PURE__ */ (0,h.jsxs)(`div`,{className:JO.invitation,children:[/* @__PURE__ */ (0,h.jsx)(`div`,{className:JO.hint,children:r(`reference.dropTitle`)}),/* @__PURE__ */ (0,h.jsxs)(`div`,{className:JO.preview,"data-thread-reference-preview":!0,children:[/* @__PURE__ */ (0,h.jsx)(d.ReferenceIconRegular,{kind:`session`,size:20}),/* @__PURE__ */ (0,h.jsx)(`span`,{className:JO.title,children:o.title})]})]})})}function XO({renderSlot:e}){return e(`conversation.session`,{})}function ZO({session:e,useInput:t,renderSlot:n}){let r=t(e=>e);return e===void 0||r===void 0?null:n(`conversation.input.dock`,{session:e,input:r})}function QO(){return null}function $O(e){let{sessionId:t,phase:n,hero:r,useSession:i,useSessions:a,useSessionStatus:o,useWorkspaces:s,useInput:c,useComposerBlock:l,useSessionCreation:u,renderSlot:d,renderSlotChain:f,selectWorkspace:p,retrySessionCreation:m,referenceEditor:_,t:v,useFactorySlot:y}=e,b=i(e=>e),x=y(`views`,XO),ee=y(`widthControls`,QO),[te,ne]=(0,g.useState)(null),re=o(e=>t===void 0?void 0:e.get(t)?.pendingInteraction),ie=a(e=>t===void 0?void 0:e.byId[t]?.cwd),ae=s(e=>e),oe=l(e=>e),se=u(e=>e),ce=t===void 0&&se.state!==`idle`?se.workspaceId:void 0,[le,ue]=(0,g.useState)(!1),[de,fe]=(0,g.useState)(),pe=(0,g.useRef)(null),S=(0,g.useRef)(null),C=(0,g.useCallback)(e=>{S.current?.disconnect(),S.current=null;let t=e?.parentElement??null;e!==null&&t!==null&&(S.current=new ResizeObserver(()=>{t.style.setProperty(`--dsh-composer-height`,`${e.offsetHeight}px`),t.style.setProperty(`--dsh-conversation-viewport-height`,`${t.clientHeight}px`)}),S.current.observe(e),S.current.observe(t))},[]),me=t===void 0?void 0:ae.items.find(e=>e.sessionIds.includes(t)),he=de===void 0?ce:de,ge=ae.items.find(e=>e.workspaceId===he);(0,g.useEffect)(()=>{de!==void 0&&((de===null?me===void 0&&t!==void 0:me?.workspaceId===de)||de!==null&&ae.phase===`ready`&&ge===void 0)&&fe(void 0)},[de,t,me?.workspaceId,ae.phase,ge]);let _e=(he===null?void 0:ge?.title)??(he===null||t===void 0?void 0:me?.title??(ae.phase===`ready`||ie===void 0||ie===``?void 0:UO(ie))),ve=_e===void 0?void 0:BO(_e,v(`workspace.defaultName`)),ye=/* @__PURE__ */ (0,h.jsxs)(`div`,{className:Q.heroTopBarInner,children:[d(`conversation.hero.workspace`,{open:le,anchorRef:pe,selectedId:he===null?void 0:he??me?.workspaceId,fallbackLabel:ve,onOpenChange:ue,onPick:e=>{ue(!1),fe(e),p(e).catch(()=>{fe(t=>t===e?void 0:t)})},onClose:()=>{ue(!1)}},{fallback:/* @__PURE__ */ (0,h.jsx)(WO,{buttonRef:pe,label:ve??(ae.canStartProjectless?v(`hero.noWorkspace`):void 0),projectless:ae.canStartProjectless===!0&&ve===void 0,menuOpen:le,onClick:()=>{ue(e=>!e)},t:v})}),/* @__PURE__ */ (0,h.jsx)(`div`,{className:Q.heroAgentPresetSeat,children:d(`conversation.hero.agentPreset`,{})})]}),be=ae.phase===`ready`&&!ae.canStartProjectless&&ve===void 0,xe=t===void 0&&se.state!==`idle`,Se=t!==void 0&&r&&b?.openState===`loading`&&!be,Ce=(t===void 0||b?.openState!==`open`)&&!be,we=t===void 0||b?.openState!==`open`||r&&be,Te=!we&&oe!==void 0,Ee=d(`conversation.composer.bar`,{variant:r?`hero`:`composer`,...r?{topBar:ye}:{},...xe?{sessionCreation:se,onRetrySessionCreation:m,placeholder:v(`placeholder.hero`)}:Se?{disabled:!0,preparingDraft:!0,placeholder:v(`placeholder.hero`)}:we?{disabled:!0,placeholder:v(Ce?`placeholder.preparing`:`placeholder.workspace`),...Ce?{}:{workspacePickerOpen:le,onRequestWorkspace:()=>{ue(!0)}}}:Te?{blocked:oe,placeholder:oe.reason}:r?{placeholder:v(`placeholder.hero`)}:{}}),De=/* @__PURE__ */ (0,h.jsxs)(`div`,{className:VS(Q.composerStack,r&&Q.composerHero),children:[r&&/* @__PURE__ */ (0,h.jsx)(KO,{t:v,renderSlot:d}),/* @__PURE__ */ (0,h.jsx)(ZO,{session:b,useInput:c,renderSlot:d}),Ee]}),Oe=f(`conversation.composer`,{sessionId:t,session:b,pendingInteraction:b?.openState===`open`?re:void 0},{fallback:De,fallbackOnly:t===void 0,overlay:!0}),w=/* @__PURE__ */ (0,h.jsx)(`div`,{ref:C,className:Q.composerSeat,"data-composer-seat":``,"data-conversation-region":`composer`,children:Oe});return/* @__PURE__ */ (0,h.jsxs)(`div`,{ref:ne,className:VS(Q.body,e.variant===`embedded`&&Q.embeddedBody),"data-conversation-content":``,"data-conversation-session":t,"data-conversation-region":`chat`,"data-content-phase":n,children:[/* @__PURE__ */ (0,h.jsxs)(`div`,{className:Q.scrollBody,"data-conversation-scroll":``,children:[t===void 0?null:/* @__PURE__ */ (0,h.jsx)(x,{}),w]}),/* @__PURE__ */ (0,h.jsx)(ee,{container:te,phase:n}),/* @__PURE__ */ (0,h.jsx)(YO,{container:te,editor:_,useSessions:a,t:v},t)]})}function ek({renderSlot:e}){return e(`main.conversation`,{})}function tk(){let e=()=>{let e=document.querySelector(`[data-conversation-navigation-focus]`),t=e?.querySelector(`[data-navigation-focus-return]`);(t!=null&&t.getClientRects().length>0?t:e)?.focus({preventScroll:!0})};e(),requestAnimationFrame(()=>{document.activeElement===document.body&&e()})}function nk({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&&kO(i,a)===`blank`;return/* @__PURE__ */ (0,h.jsxs)(`header`,{className:VS(Q.header,o&&Q.headerBlank,e===void 0&&Q.headerSessionless),"data-window-drag":!0,"data-conversation-navigation-focus":!0,"data-cx-region":`topbar`,tabIndex:-1,children:[/* @__PURE__ */ (0,h.jsx)(`div`,{className:Q.headerLeading,"data-conversation-header-leading":``,children:r(`conversation.header.leading`,{})}),e===void 0?/* @__PURE__ */ (0,h.jsxs)(`div`,{className:Q.titleRow,children:[r(`conversation.header.navigation`,{restoreNavigationFocus:tk}),/* @__PURE__ */ (0,h.jsx)(`div`,{className:Q.headerCorner,"data-conversation-header-corner":``,children:/* @__PURE__ */ (0,h.jsx)(`span`,{className:Q.phoneTrailingAction,children:r(`conversation.header.trailing`,{})})})]}):r(`conversation.session.header`,{hideChrome:o,titleNavigation:r(`conversation.header.navigation`,{restoreNavigationFocus:tk}),trailingAction:r(`conversation.header.trailing`,{})}),r(`conversation.header.shortcuts`,{restoreNavigationFocus:tk})]})}function rk(e,t){return(t===null?void 0:e.find(e=>e.id===t))??e.find(e=>e.id===`chat`)}function ik({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=rk(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&&kO(_,v)===`blank`)return null;let b=e??m?.id;return/* @__PURE__ */ (0,h.jsx)(`div`,{className:Q.viewArea,children:b!==void 0&&s(`conversation.view`,{inspectCall:p,viewRequest:y,openView:u,completeViewRequest:o.completeViewRequest},{only:b})})}function ak(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 ok(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 sk({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=rk(d,o(e=>e.view)),p=i(t=>ak(t,e),ok),m=!t&&d.length>1;return/* @__PURE__ */ (0,h.jsxs)(h.Fragment,{children:[/* @__PURE__ */ (0,h.jsxs)(`div`,{className:Q.titleRow,children:[!t&&/* @__PURE__ */ (0,h.jsxs)(h.Fragment,{children:[/* @__PURE__ */ (0,h.jsxs)(`div`,{className:Q.titleCluster,children:[/* @__PURE__ */ (0,h.jsxs)(`div`,{className:Q.titleCenter,onClick:e=>{if(e.target?.closest(`button, a, input, [role='button']`))return;let t=e.currentTarget.querySelector(`[data-navigation-focus-return]`);t!==null&&t.getClientRects().length>0&&t.click()},children:[/* @__PURE__ */ (0,h.jsxs)(`nav`,{className:Q.crumbs,"aria-label":u(`session.hierarchy`),children:[p.map((e,t)=>{let n=t===p.length-1,r=n?/* @__PURE__ */ (0,h.jsx)(`span`,{className:VS(Q.crumb,e.subagent&&Q.crumbSubagent,Q.crumbCurrent),children:e.displayTitle}):/* @__PURE__ */ (0,h.jsx)(`button`,{type:`button`,className:VS(Q.crumb,e.subagent&&Q.crumbSubagent),onClick:()=>{c(e.id)},children:e.displayTitle}),i=n||e.subagent,a={lineageSessionId:e.id,displayTitle:e.displayTitle,...n?{}:{openTitle:()=>{c(e.id)}}};return/* @__PURE__ */ (0,h.jsxs)(`span`,{className:Q.crumbSeg,children:[t>0&&/* @__PURE__ */ (0,h.jsx)(`span`,{className:Q.crumbSep,children:`/`}),i?e.subagent?s(`conversation.session.header.lineage`,a,{fallback:r}):/* @__PURE__ */ (0,h.jsxs)(h.Fragment,{children:[r,s(`conversation.session.header.lineage`,a,{fallback:null})]}):r]},e.id)}),p.length===0&&/* @__PURE__ */ (0,h.jsx)(`span`,{className:Q.crumbCurrent,children:e})]}),n]}),/* @__PURE__ */ (0,h.jsx)(`div`,{className:Q.headerActions,children:s(`conversation.session.header.actions`,{})})]}),/* @__PURE__ */ (0,h.jsx)(`div`,{className:Q.headerUtilities,children:s(`conversation.session.header.utilities`,{})})]}),t&&/* @__PURE__ */ (0,h.jsx)(`div`,{className:Q.titleCenter,children:n}),/* @__PURE__ */ (0,h.jsxs)(`div`,{className:Q.headerCorner,"data-conversation-header-corner":``,children:[/* @__PURE__ */ (0,h.jsx)(`span`,{className:Q.phoneTrailingAction,children:r}),s(`conversation.session.header.corner`,{})]})]}),m&&/* @__PURE__ */ (0,h.jsx)(`div`,{className:Q.tabs,role:`tablist`,"data-conversation-tabs":``,children:d.map(e=>/* @__PURE__ */ (0,h.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":e.id===f?.id,className:VS(Q.tab,e.id===f?.id&&Q.tabActive),onClick:()=>{l(e.id)},children:e.label},e.id))})]})}function ck(e){return/* @__PURE__ */ (0,h.jsx)(ik,{...e})}function lk({editor:e,editable:t,preserveFocus:n=!1,...r}){let i=(0,g.useRef)(null),a=(0,g.useRef)(n);return a.current=n,(0,g.useLayoutEffect)(()=>{let t=i.current;if(t!==null&&(!(0,d.shouldAutoFocusTextInput)()&&!a.current&&(t.ownerDocument.activeElement===t&&t.blur(),e?.setEditable(!1)),e!==null))return e.setRootElement(t),()=>{e.setRootElement(null)}},[e]),(0,g.useLayoutEffect)(()=>{e!==null&&e.setEditable(t)},[e,t]),/* @__PURE__ */ (0,h.jsx)(`div`,{ref:i,contentEditable:e!==null&&t,suppressContentEditableWarning:!0,role:`textbox`,"aria-multiline":`true`,"data-composer-input":!0,...r})}function uk({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 dk({classNames:e,editor:t,scrollRef:n,editable:r,editorDisabled:i,preserveFocus:a=!1,phase:o,placeholderText:s,ariaLabel:c,workspaceTrigger:l,workspacePickerOpen:u,onWorkspaceKeyDown:d,hint:f,showPlaceholder:p}){return/* @__PURE__ */ (0,h.jsx)(`div`,{ref:n,className:e.scroll,"data-input-scroll":!0,children:/* @__PURE__ */ (0,h.jsxs)(`div`,{className:e.grow,children:[/* @__PURE__ */ (0,h.jsx)(lk,{editor:l?null:t,editable:r,preserveFocus:a,className:VS(e.input,i&&e.inputDisabled),"data-phase":o,"aria-disabled":i||void 0,"data-placeholder":s,"aria-label":c,"aria-haspopup":l?`menu`:void 0,"aria-expanded":l?u:void 0,tabIndex:l?0:void 0,onKeyDown:l?d:void 0,style:f===null?void 0:{"--dsh-composer-hint":JSON.stringify(f)}}),p&&/* @__PURE__ */ (0,h.jsx)(`div`,{"aria-hidden":!0,className:e.placeholder,"data-composer-placeholder":!0,children:s}),/* @__PURE__ */ (0,h.jsx)(uk,{editor:l?null:t})]})})}function fk(e,t){return e.isComposing||e.keyCode===229||t()}function pk(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&&fk(n,c);return t.arbitrate(e,r)!==`pass`&&(n?.preventDefault(),!0)};return Ib(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(Cp,l(`up`),4),e.registerCommand(wp,l(`down`),4),e.registerCommand(Ap,e=>l(e.shiftKey?`tabBack`:`tab`)(e),4),e.registerCommand(Op,e=>(t.dismissPopup(),t.arbitrate(`escape`,fk(e,c))===`consumed`&&(e.preventDefault(),!0)),4),e.registerCommand(Ep,e=>fk(e,c)?!1:t.space()?(e.preventDefault(),!0):!1,4),e.registerCommand(Tp,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&&fk(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(dp,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 mk(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 hk(e,t){e.getRootElement()?.focus({preventScroll:!0}),e.focus(()=>{t()})}function gk(e){let t=e.getRootElement();if(t===null||e.isComposing())return;let n=t.ownerDocument;if(n.activeElement!==t&&!t.contains(n.activeElement))return;let r=n.defaultView?.getSelection();if(r==null)return;if(r.rangeCount>0){if(!r.isCollapsed)return;let e=r.getRangeAt(0).cloneRange();if(t.contains(e.startContainer)&&t.contains(e.endContainer)){r.removeAllRanges(),r.addRange(e);return}}let i=t.firstChild??t,a=n.createRange();a.setStart(i,0),a.collapse(!0),r.removeAllRanges(),r.addRange(a)}function _k(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 vk(e,t,n){return e.bindFilePicker({available:()=>t.current.canAcceptDrop&&n.current!==null,open:()=>{n.current?.click()}})}function yk(e,t,n){return pk(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(uO(r.busyEnter,r.running,e?`accelerated`:`enter`,r.steeringAvailable),`enter`):r.primaryAction.run()},intakeFiles:(e,t)=>{n.current.intakeFiles(e,t)},pasteText:e=>{!n.current.machineBusy&&n.current.canPasteText&&t.paste(e)}})}function bk(e,t){e.preventDefault(),!(0,d.isMobileDevice)()&&t?.getRootElement()?.focus({preventScroll:!0})}function xk(e){let t=e/1048576;return`${Number.isInteger(t)?String(t):t.toFixed(1)}MB`}function Sk(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:xk(n.maxImageBytes)});break;case`IMAGES_TOO_LARGE`:if(n!==void 0)return e(`image.totalTooLarge`,{size:xk(n.maxMessageImageBytes)})}return e(`image.sendFailed`,{reason:t})}function Ck(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 wk=`@deepseek-ai/dsh-client-ui-conversation/ContextMeter.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(wk)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-conversation`,e.dataset.pluginCss=wk,e.textContent=`.h1Hkra_root{flex:none;display:inline-flex}.h1Hkra_trigger{border-radius:var(--dsw-radius-sm);color:var(--dsw-alias-label-tertiary);font-family:inherit;font-size:var(--dsh-content-font-size-secondary,13px);font-variant-numeric:tabular-nums;line-height:calc(20px + var(--dsh-content-font-delta-secondary,0px));white-space:nowrap;cursor:pointer;background:0 0;border:none;flex:none;align-items:center;gap:6px;padding:1px 8px;display:inline-flex}.h1Hkra_trigger:hover,.h1Hkra_trigger[aria-expanded=true]{background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-label-secondary)}.h1Hkra_track{fill:none;stroke:var(--dsw-alias-border-l3);stroke-width:2px}.h1Hkra_fill{fill:none;stroke:var(--dsw-alias-label-tertiary);stroke-width:2px;stroke-linecap:round}.h1Hkra_panel{z-index:1100;box-sizing:border-box;border-radius:var(--dsw-radius-lg);background:var(--dsw-specific-menu);width:min(264px,100vw - 24px);backdrop-filter:var(--dsw-menu-backdrop-filter);--dsw-elevation-stroke-color:var(--dsw-alias-border-l1);box-shadow:var(--dsw-elevation-prominent);color:var(--dsw-alias-label-secondary);cursor:default;border:0;padding:12px;font-size:12px;line-height:20px;position:fixed}.h1Hkra_header{align-items:center;gap:6px;display:flex}.h1Hkra_figures{font-variant-numeric:tabular-nums;color:var(--dsw-alias-label-primary);margin-left:auto;font-weight:500}.h1Hkra_percent{color:var(--dsw-alias-label-primary);font-weight:500}.h1Hkra_headline{color:var(--dsw-alias-label-tertiary)}.h1Hkra_headline:empty{display:none}.h1Hkra_bar{corner-shape:round;background:var(--dsw-alias-interactive-bg-hover);border-radius:999px;gap:1px;height:4px;margin:10px 0 12px;display:flex;overflow:hidden}.h1Hkra_segment{background:var(--meter-tint,var(--dsw-alias-label-tertiary));border-radius:1px;flex:none;min-width:2px;height:100%}.h1Hkra_swatch{background:var(--meter-tint);vertical-align:baseline;border-radius:2px;width:8px;height:8px;margin-right:6px;display:inline-block}.h1Hkra_colorSystem{--meter-tint:var(--dsw-static-neutral-bluish-400)}.h1Hkra_colorTools{--meter-tint:#a78bfa}.h1Hkra_colorMessages{--meter-tint:var(--dsw-static-blue-450)}.h1Hkra_rows{margin:6px 0 0}.h1Hkra_row{justify-content:space-between;align-items:center;gap:12px;padding:2px 0;display:flex}.h1Hkra_row dt{color:var(--dsw-alias-label-secondary)}.h1Hkra_row dd{font-variant-numeric:tabular-nums;color:var(--dsw-alias-label-primary);margin:0}`,document.head.appendChild(e)}var Tk={bar:`h1Hkra_bar`,colorMessages:`h1Hkra_colorMessages`,colorSystem:`h1Hkra_colorSystem`,colorTools:`h1Hkra_colorTools`,figures:`h1Hkra_figures`,fill:`h1Hkra_fill`,header:`h1Hkra_header`,headline:`h1Hkra_headline`,panel:`h1Hkra_panel`,percent:`h1Hkra_percent`,root:`h1Hkra_root`,row:`h1Hkra_row`,rows:`h1Hkra_rows`,segment:`h1Hkra_segment`,swatch:`h1Hkra_swatch`,track:`h1Hkra_track`,trigger:`h1Hkra_trigger`};let Ek=5.5,Dk=2*Math.PI*Ek,Ok=[{key:`systemTokens`,label:`context.system`,color:Tk.colorSystem},{key:`toolsTokens`,label:`context.tools`,color:Tk.colorTools},{key:`messageTokens`,label:`context.messages`,color:Tk.colorMessages}];function kk(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 Ak({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=Ck(n),l=c!==null,u=(0,d.useAnchoredPosition)({open:i&&l,anchorRef:o,panelRef:s,side:`top`,gap:8,margin:12});if((0,d.useDismissOnOutsidePointer)(o,i&&l,a,s),(0,g.useEffect)(()=>{!l&&i&&a(!1)},[l,i]),(0,g.useEffect)(()=>{if(!i||!l)return;let e=e=>{e.key===`Escape`&&a(!1)};return document.addEventListener(`keydown`,e),()=>{document.removeEventListener(`keydown`,e)}},[l,i]),c===null)return null;let f=c.percent,p=`${f}%`,[m=``,v=``]=t(`context.aria`,{percent:`\0`}).split(`\0`).map(e=>e.trim()),y=r===void 0?0:r.systemTokens+r.toolsTokens+r.messageTokens,b=(r===void 0||y===0?[{key:`total`,color:void 0,width:f}]:Ok.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:Tk.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:Tk.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:Tk.track,cx:`7`,cy:`7`,r:Ek}),/* @__PURE__ */ (0,h.jsx)(`circle`,{className:Tk.fill,cx:`7`,cy:`7`,r:Ek,strokeDasharray:`${Dk*f/100} ${Dk}`,transform:`rotate(-90 7 7)`})]}),/* @__PURE__ */ (0,h.jsx)(`span`,{children:p})]})}),i&&(0,_.createPortal)(/* @__PURE__ */ (0,h.jsxs)(`div`,{ref:s,className:Tk.panel,style:u??{visibility:`hidden`,left:0,top:0},role:`dialog`,"aria-label":t(`context.used`),children:[/* @__PURE__ */ (0,h.jsxs)(`div`,{className:Tk.header,children:[/* @__PURE__ */ (0,h.jsx)(`span`,{className:Tk.headline,children:m}),/* @__PURE__ */ (0,h.jsx)(`span`,{className:Tk.percent,children:p}),/* @__PURE__ */ (0,h.jsx)(`span`,{className:Tk.headline,children:v}),/* @__PURE__ */ (0,h.jsx)(`span`,{className:Tk.figures,children:`~${kk(c.usedTokens,t)} / ${kk(c.contextWindow,t)}`})]}),/* @__PURE__ */ (0,h.jsx)(`div`,{className:Tk.bar,children:b.map(e=>/* @__PURE__ */ (0,h.jsx)(`div`,{className:e.color===void 0?Tk.segment:`${Tk.segment} ${e.color}`,style:{width:`${e.width}%`}},e.key))}),r!==void 0&&/* @__PURE__ */ (0,h.jsx)(`dl`,{className:Tk.rows,children:Ok.map(e=>/* @__PURE__ */ (0,h.jsxs)(`div`,{className:Tk.row,children:[/* @__PURE__ */ (0,h.jsxs)(`dt`,{children:[/* @__PURE__ */ (0,h.jsx)(`span`,{className:`${Tk.swatch} ${e.color}`,"aria-hidden":!0}),t(e.label)]}),/* @__PURE__ */ (0,h.jsx)(`dd`,{children:`~${kk(r[e.key],t)}`})]},e.key))})]}),document.body)]})}function jk(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 Mk=`@deepseek-ai/dsh-client-ui-conversation/InputBar.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(Mk)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-conversation`,e.dataset.pluginCss=Mk,e.textContent=`.SFO4UW_root{padding:0 var(--dsh-composer-side-clearance) 4px;flex-direction:column;align-items:center;display:flex}[data-phone] .SFO4UW_root{padding-bottom:max(4px, calc(env(safe-area-inset-bottom) - 23px))}.SFO4UW_dock{-webkit-user-select:none;user-select:none;justify-content:center;align-items:center;gap:12px;max-width:100%;padding-top:4px;display:flex}.SFO4UW_hero .SFO4UW_dock:empty{display:none}.SFO4UW_hero{padding:0 var(--dsh-composer-side-clearance)}.SFO4UW_notice{width:100%;max-width:var(--dsh-composer-card-max-width);border-radius:var(--dsw-radius-md);background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-label-secondary);margin-bottom:6px;padding:4px 8px;font-size:12px;line-height:18px}.SFO4UW_cardStack{width:100%;max-width:var(--dsh-composer-card-max-width);flex-direction:column;display:flex;position:relative}.SFO4UW_topRail{z-index:0;box-sizing:border-box;margin-inline:16px;background:color-mix(in srgb, var(--dsw-alias-label-primary) 5%, var(--dsw-alias-bg-base));-webkit-user-select:none;user-select:none;border:0;border-radius:16px 16px 0 0;align-items:center;margin-bottom:-16px;padding:5px 10px 21px;display:flex;position:relative}.SFO4UW_card{box-sizing:border-box;z-index:1;width:100%;max-width:var(--dsh-composer-card-max-width);--dsw-elevation-stroke-color:var(--dsw-alias-border-l2);border-radius:var(--dsw-radius-panel);background:var(--dsw-specific-input-major);box-shadow:var(--dsw-elevation-soft);font-size:var(--dsh-content-font-size,14px);line-height:calc(24px + var(--dsh-content-font-delta,0px));--dsh-scrollbar-thumb:var(--dsw-alias-scrollbar-bg-l2);--dsh-scrollbar-thumb-hover:var(--dsw-alias-scrollbar-hover-l2);border:0;flex-direction:column;gap:12px;padding-top:8px;display:flex;position:relative}@supports (backdrop-filter:blur(14px)){body[data-codexhost-wallpaper] .SFO4UW_card,[data-phone] .SFO4UW_card{box-shadow:none;background:0 0}body[data-codexhost-wallpaper] .SFO4UW_card:before,[data-phone] .SFO4UW_card:before{content:"";z-index:-1;border-radius:inherit;background:color-mix(in srgb, var(--dsw-specific-input-major) 60%, transparent);backdrop-filter:blur(16px);box-shadow:inset 0 1px 0 color-mix(in srgb, var(--dsw-alias-bg-layer-3) 65%, transparent), var(--dsw-elevation-soft), 0 8px 24px -12px var(--dsw-alias-bg-mask-2);pointer-events:none;position:absolute;inset:0}body:not([data-codexhost-wallpaper]) [data-phone] .SFO4UW_card:before{background:color-mix(in srgb, var(--dsw-specific-input-major) 24%, transparent);backdrop-filter:blur(14px)}}@media (prefers-reduced-transparency:reduce),(prefers-contrast:more),(forced-colors:active){body[data-codexhost-wallpaper] .SFO4UW_card,[data-phone] .SFO4UW_card{background:var(--dsw-specific-input-major);box-shadow:var(--dsw-elevation-soft)}body[data-codexhost-wallpaper] .SFO4UW_card:before,[data-phone] .SFO4UW_card:before{display:none}}@media (prefers-contrast:more),(forced-colors:active){[data-phone] .SFO4UW_card:not(.SFO4UW_cardWorkspaceTrigger){outline:1px solid var(--dsw-alias-label-primary);outline-offset:-1px}}.SFO4UW_cardWorkspaceTrigger{--dsw-elevation-stroke-color:transparent;cursor:pointer}.SFO4UW_cardWorkspaceTrigger:after{content:"";box-sizing:border-box;border-radius:var(--dsw-radius-panel);color:var(--dsw-alias-border-l4);pointer-events:none;border:1px dashed;transition:color .1s;position:absolute;inset:0}.SFO4UW_cardWorkspaceTrigger :disabled{pointer-events:none}.SFO4UW_cardWorkspaceTrigger:hover:after{color:var(--dsw-alias-state-business-primary)}.SFO4UW_inlineNotices{flex-direction:column;gap:8px;display:flex}.SFO4UW_inlineNotices>[data-slot]>*{margin:10px 10px 0}.SFO4UW_accessory{align-items:center;gap:8px;padding:10px 12px 0;display:flex}.SFO4UW_overlayAnchor{height:0;position:absolute;inset:0 0 auto}.SFO4UW_scroll{max-height:var(--dsh-composer-text-max-height);margin-right:4px;overflow-y:auto}.SFO4UW_scroll::-webkit-scrollbar-track{margin-top:8px}.SFO4UW_grow{position:relative}.SFO4UW_pending{corner-shape:round;background:var(--dsw-alias-state-business-primary);border-radius:50%;width:8px;height:8px;animation:1s ease-in-out infinite alternate SFO4UW_input-pending}@keyframes SFO4UW_input-pending{0%{opacity:.35}to{opacity:1}}.SFO4UW_input{box-sizing:border-box;min-height:36px;font-family:var(--dsw-font-family);font-size:inherit;line-height:inherit;white-space:pre-wrap;word-break:break-word;overflow-wrap:anywhere;color:var(--dsw-alias-label-primary);caret-color:var(--dsw-alias-state-business-primary);outline:none;padding:4px 8px 0 14px}.SFO4UW_input p{margin:0}.SFO4UW_input p:last-child:after{content:var(--dsh-composer-hint);color:var(--dsw-alias-label-caption)}.SFO4UW_input[data-composer-composing] p:last-child:after{content:none}.SFO4UW_input[data-composer-composing]+.SFO4UW_placeholder{visibility:hidden}.SFO4UW_placeholder{color:var(--dsw-alias-label-caption);white-space:nowrap;text-overflow:ellipsis;pointer-events:none;-webkit-user-select:none;user-select:none;position:absolute;inset:4px 8px auto 14px;overflow:hidden}.SFO4UW_inputDisabled{color:var(--dsw-alias-label-tertiary);cursor:not-allowed}.SFO4UW_input[aria-haspopup=menu]{cursor:pointer}.SFO4UW_hero .SFO4UW_input{min-height:52px}.SFO4UW_hero .SFO4UW_placeholder{white-space:normal;-webkit-line-clamp:2;line-clamp:2;-webkit-box-orient:vertical;display:-webkit-box}@media (width<=600px){.SFO4UW_hero .SFO4UW_input{min-height:36px}.SFO4UW_hero .SFO4UW_placeholder{white-space:nowrap;display:block}}.SFO4UW_row{-webkit-user-select:none;user-select:none;flex-wrap:wrap;justify-content:space-between;align-items:center;gap:12px;min-width:0;padding:2px 8px 6px;display:flex;container-type:inline-size}.SFO4UW_row[data-model-compact]{--dsh-composer-model-text-display:none;--dsh-composer-model-icon-display:block}.SFO4UW_tools,.SFO4UW_modes,.SFO4UW_trailing{align-items:center;min-width:0;display:flex}.SFO4UW_tools,.SFO4UW_modes{gap:12px}.SFO4UW_trailing{flex:none;gap:12px;margin-left:auto}@container (width<=560px){.SFO4UW_tools,.SFO4UW_modes,.SFO4UW_trailing{gap:8px}}.SFO4UW_add{corner-shape:round;background:var(--dsw-specific-selector);width:28px;height:28px;color:var(--dsw-alias-label-primary);cursor:pointer;border:none;border-radius:999px;flex:none;place-items:center;display:grid}.SFO4UW_add:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-hover-solid)}.SFO4UW_add:disabled{opacity:.5;cursor:default}.SFO4UW_select{border-radius:var(--dsw-radius-sm);max-width:220px;height:28px;color:var(--dsw-alias-label-secondary);white-space:nowrap;cursor:pointer;appearance:none;background-color:#0000;background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12' fill='none'%3E%3Cpath d='M3 4.5L6 7.5L9 4.5' stroke='%2381858C' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");background-position:right 4px center;background-repeat:no-repeat;background-size:12px 12px;border:none;outline:none;padding:0 20px 0 8px;font-size:13px;font-weight:500;line-height:20px}.SFO4UW_select:hover:not(:disabled){background-color:var(--dsw-alias-interactive-bg-hover)}.SFO4UW_select:disabled{opacity:.5;cursor:default}.SFO4UW_primary{corner-shape:round;background:var(--dsw-alias-button-info-fill);color:#fff;cursor:pointer;border:none;border-radius:999px;flex:none;place-items:center;width:30px;height:30px;transition:background-color .1s;display:grid;transform:translateY(-2px)}.SFO4UW_primary:hover:not(:disabled){background:var(--dsw-alias-button-info-hover)}.SFO4UW_primary:disabled{opacity:.4;cursor:default}.SFO4UW_retry{border-radius:var(--dsw-radius-sm);color:inherit;cursor:pointer;background:0 0;border:1px solid;margin-left:8px;padding:1px 8px;font-size:12px}.SFO4UW_addSeat,.SFO4UW_submitSeat,.SFO4UW_controlScroll{display:contents}.SFO4UW_row[data-phone-toolbar]{flex-wrap:nowrap;gap:4px;position:relative}.SFO4UW_row[data-phone-toolbar] .SFO4UW_controlScroll{--dsh-composer-edge-gap:4px;align-items:center;gap:inherit;min-width:0;min-height:44px;margin-left:calc(var(--dsh-composer-start-width,44px) + var(--dsh-composer-edge-gap));margin-right:calc(var(--dsh-composer-end-width,44px) + var(--dsh-composer-edge-gap));overscroll-behavior-x:contain;scrollbar-width:none;flex:1;display:flex;overflow-x:auto}.SFO4UW_row[data-phone-toolbar] .SFO4UW_controlScroll::-webkit-scrollbar{display:none}.SFO4UW_row[data-phone-toolbar] .SFO4UW_tools:not([hidden]),.SFO4UW_row[data-phone-toolbar] .SFO4UW_trailing:not(.SFO4UW_trailingActive){display:contents}.SFO4UW_row[data-phone-toolbar] .SFO4UW_tools>*,.SFO4UW_row[data-phone-toolbar] [data-slot="conversation.input.left"]>*{flex-shrink:0}.SFO4UW_row[data-phone-toolbar] button:focus-visible{outline-offset:-2px}.SFO4UW_row[data-phone-toolbar] .SFO4UW_modes,.SFO4UW_row[data-phone-toolbar] .SFO4UW_standardControls{flex:none;gap:4px;width:max-content}.SFO4UW_row[data-phone-toolbar] .SFO4UW_standardControls{margin-left:0}.SFO4UW_row[data-phone-toolbar] .SFO4UW_addSeat,.SFO4UW_row[data-phone-toolbar] .SFO4UW_submitSeat{z-index:1;flex:none;align-items:center;gap:4px;display:flex;position:absolute;inset-block:2px 6px}.SFO4UW_row[data-phone-toolbar] .SFO4UW_addSeat{left:8px}.SFO4UW_row[data-phone-toolbar] .SFO4UW_submitSeat{margin-left:0;right:8px}.SFO4UW_row[data-phone-toolbar] .SFO4UW_add,.SFO4UW_row[data-phone-toolbar] .SFO4UW_primary{box-sizing:border-box;background-clip:padding-box;width:44px;height:44px}.SFO4UW_row[data-phone-toolbar] .SFO4UW_add{border:8px solid #0000}.SFO4UW_row[data-phone-toolbar] .SFO4UW_primary{border:7px solid #0000}.SFO4UW_row[data-phone-toolbar][data-toolbar-activity] .SFO4UW_controlScroll{display:contents}.SFO4UW_row[data-phone-toolbar][data-toolbar-activity] .SFO4UW_submitSeat{position:static}.SFO4UW_row[data-actions-overflow] [data-composer-overflow-action]{display:none}.SFO4UW_standardControls{align-items:center;gap:12px;min-width:0;display:flex}.SFO4UW_tools[hidden],.SFO4UW_standardControls[hidden]{display:none}.SFO4UW_trailingActive{flex:1;margin-left:0}.SFO4UW_activity{flex:none;align-items:center;display:flex}.SFO4UW_activity:empty{display:none}.SFO4UW_activityExpanded{flex:1;min-width:0}.SFO4UW_annotations{scrollbar-width:none;align-items:center;gap:6px;padding:8px 12px 0;display:flex;overflow-x:auto}.SFO4UW_annotations::-webkit-scrollbar{display:none}.SFO4UW_annotations>*{flex:none}.SFO4UW_creationError{border-radius:var(--dsw-radius-md);background:var(--dsw-alias-interactive-bg-hover-danger);color:var(--dsw-alias-state-error-primary);align-items:center;gap:8px;margin:2px 10px 0;padding:8px 10px;font-size:13px;line-height:18px;display:flex}.SFO4UW_creationErrorIcon{flex:none}.SFO4UW_creationErrorCopy{overflow-wrap:anywhere;flex-direction:column;flex:1;gap:2px;min-width:0;display:flex}.SFO4UW_creationErrorTitle{font-weight:500}.SFO4UW_creationErrorDetail{color:var(--dsw-alias-label-secondary);font-size:12px;line-height:17px}.SFO4UW_creationRetry{border-radius:var(--dsw-radius-sm);min-height:28px;color:var(--dsw-alias-state-error-primary);font:inherit;cursor:pointer;touch-action:manipulation;background:0 0;border:1px solid;flex:none;padding:4px 10px;font-size:12px;font-weight:500;line-height:16px}.SFO4UW_creationRetry:hover{background:color-mix(in srgb, currentColor 10%, transparent)}.SFO4UW_creationRetry:focus-visible{outline-offset:2px;outline:2px solid}.SFO4UW_pendingControls{align-items:center;gap:6px;min-width:0;display:inline-flex}.SFO4UW_pendingModel{border-radius:var(--dsw-radius-sm);max-width:min(220px,45cqw);height:28px;color:var(--dsw-alias-label-tertiary);white-space:nowrap;user-select:none;align-items:center;gap:6px;padding:0 8px;font-size:13px;line-height:20px;display:inline-flex}.SFO4UW_pendingModelLabel{text-overflow:ellipsis;min-width:0;overflow:hidden}.SFO4UW_pendingHarness{width:30px;height:28px;color:var(--dsw-alias-label-tertiary);opacity:.7;user-select:none;border-radius:6px;flex-shrink:0;justify-content:center;align-items:center;display:inline-flex}[data-phone] .SFO4UW_creationRetry{min-height:36px;padding:6px 12px}[data-phone] .SFO4UW_pendingModel{max-width:none}[data-phone] .SFO4UW_pendingModelLabel{max-width:120px}[data-phone] .SFO4UW_pendingHarness{width:36px;height:36px}`,document.head.appendChild(e)}var $={accessory:`SFO4UW_accessory`,activity:`SFO4UW_activity`,activityExpanded:`SFO4UW_activityExpanded`,add:`SFO4UW_add`,addSeat:`SFO4UW_addSeat`,annotations:`SFO4UW_annotations`,card:`SFO4UW_card`,cardStack:`SFO4UW_cardStack`,cardWorkspaceTrigger:`SFO4UW_cardWorkspaceTrigger`,controlScroll:`SFO4UW_controlScroll`,creationError:`SFO4UW_creationError`,creationErrorCopy:`SFO4UW_creationErrorCopy`,creationErrorDetail:`SFO4UW_creationErrorDetail`,creationErrorIcon:`SFO4UW_creationErrorIcon`,creationErrorTitle:`SFO4UW_creationErrorTitle`,creationRetry:`SFO4UW_creationRetry`,dock:`SFO4UW_dock`,grow:`SFO4UW_grow`,hero:`SFO4UW_hero`,inlineNotices:`SFO4UW_inlineNotices`,input:`SFO4UW_input`,"input-pending":`SFO4UW_input-pending`,inputDisabled:`SFO4UW_inputDisabled`,modes:`SFO4UW_modes`,notice:`SFO4UW_notice`,overlayAnchor:`SFO4UW_overlayAnchor`,pending:`SFO4UW_pending`,pendingControls:`SFO4UW_pendingControls`,pendingHarness:`SFO4UW_pendingHarness`,pendingModel:`SFO4UW_pendingModel`,pendingModelLabel:`SFO4UW_pendingModelLabel`,placeholder:`SFO4UW_placeholder`,primary:`SFO4UW_primary`,retry:`SFO4UW_retry`,root:`SFO4UW_root`,row:`SFO4UW_row`,scroll:`SFO4UW_scroll`,select:`SFO4UW_select`,standardControls:`SFO4UW_standardControls`,submitSeat:`SFO4UW_submitSeat`,tools:`SFO4UW_tools`,topRail:`SFO4UW_topRail`,trailing:`SFO4UW_trailing`,trailingActive:`SFO4UW_trailingActive`};let Nk=[],Pk=(0,g.memo)(function({useSession:e,useInput:t,inputActions:n,keyboard:r,pendingDraft:i,addFiles:a,removeAttachment:o,resolveDraftAttachments:s,retryFileUpload:c,revealResponseAnnotation:l,toggleCommandMenu:u,stop:f,t:p,renderSlot:m,usePendingDraftText:_,useBusyEnter:v,useFileUploads:y,useNotices:b,useLexicon:x,useMenuLauncher:ee,useStopShortcut:te,useProjection:ne,sessionId:re,variant:ie,disabled:ae=!1,preparingDraft:oe=!1,sessionCreation:se,onRetrySessionCreation:ce,blocked:le,workspacePickerOpen:ue=!1,onRequestWorkspace:de,placeholder:fe,topBar:pe,accessory:S}){let C=t(e=>e),me=_(e=>e),he=C?.responseAnnotations??Nk,ge=(0,g.useMemo)(()=>({label:e=>p(`annotation.label`,{index:e}),railLabel:e=>p(`annotation.chipLabel`,{index:e}),railTitle:(e,t)=>p(`annotation.title`,{index:e,excerpt:t}),remove:e=>p(`annotation.remove`,{index:e}),selectedText:p(`annotation.selectedText`),userComment:p(`annotation.userComment`)}),[p]),_e=b(e=>e),ve=v(e=>e),ye=te(e=>e),be=ee(e=>e===`command`),[xe,Se]=(0,g.useState)(!1);(0,g.useEffect)(()=>{Se(!1)},[re]);let Ce=e(e=>e.promptError)??null,we=e(e=>e.running)??!1,Te=e(e=>e.subagent)??null,Ee=e(e=>e.removed)??!1,De=ne(`plan`,e=>e!==void 0&&(e.pending?!e.active:e.active)),Oe=ne(`goal`,e=>e!=null),w=re===void 0&&i!==void 0&&se!==void 0&&se.state!==`idle`,ke=w&&se.state===`creating`,Ae=w&&se.state===`error`,je=w?se.token:void 0,Me=C!==void 0&&r!==void 0&&n!==void 0,Ne=w?me:C?.draft??``,Pe=C?.primaryAction,Fe=w?i.editor:r?.editor??null,Ie=(0,g.useMemo)(()=>C===void 0||s===void 0?[]:s(C.attachmentIds),[s,C?.attachmentIds]),Le=Ne.trim()===``&&Ie.length===0&&he.length===0,Re=y(e=>e),ze=Ie.some(e=>Re[e.id]?.status===`error`),[Be,Ve]=(0,g.useState)(null),He=(0,g.useRef)(0),Ue=(0,g.useCallback)(e=>{He.current+=1,Ve({seq:He.current,text:e})},[]),We=(0,g.useCallback)(()=>{Ve(null)},[]),Ge=ne(`imageLimits`),Ke=ne(`attachmentInput`),qe=ne(`queueState`),Je=Ke?.enabled!==!1,Ye=Ke?.imagesOnly===!0;(0,g.useEffect)(()=>{if(Ce===null)return;let{error:e}=Ce;e.code===`session/writer-held`?Ue(p(`error.sessionInUse`)):e.code===`remote/turn-changed`?Ue(p(`error.steerTurnChanged`)):e.code===`remote/steer-unavailable`?Ue(p(`error.remoteSteerUnavailable`)):Ue(e.code===`session/attachment-invalid`||e.code===`subagent/attachment-invalid`?Sk(p,e.details.reason,Ge):`${e.message} (${e.code})`)},[Ce,Ue,p,Ge]),(0,g.useEffect)(()=>{_e?.level===`error`&&Ue(_e.text)},[_e,Ue]);let Xe=(0,g.useRef)(null),[Ze,Qe]=(0,g.useState)({phone:!1,overflowActions:!1});(0,g.useLayoutEffect)(()=>{let e=Xe.current;if(e!==null)return jk(e,Qe)},[]);let $e=(0,g.useRef)(null),et=(0,g.useRef)(null),tt=Te?.address.mode===`continuable`,nt=tt&&Te.parentAvailable!==!0,rt=w||Ee||ae||!Me||le!==void 0||nt,it=rt,at=w||Ee||ae||!Me,ot=C?.phase===`adjudicating`||C?.phase===`submitting`,st=!w&&ae&&!Ee&&de!==void 0,ct=w||Me&&!ot&&(!it||!w&&oe&&Me&&!Ee&&!nt&&!st),lt=Ee||!ct&&!st,ut=Te===null||Te.address.mode===`continuable`,dt=!it&&!ot&&Le&&we&&ut&&qe?.previewOnly!==!0&&C.queue.length>0,ft=(0,g.useRef)(w),pt=(0,g.useRef)(!1);if(ft.current&&!w&&re!==void 0){let e=document.activeElement;e!==null&&$e.current?.contains(e)&&(pt.current=!0)}(0,g.useLayoutEffect)(()=>{ft.current=w},[w]),(0,g.useEffect)(()=>{C!==void 0&&n!==void 0&&Ie.length!==C.attachmentIds.length&&n.pruneAttachments(Ie.map(e=>e.id))},[Ie,C?.attachmentIds,n]);let mt=()=>{mk(et)};(0,g.useEffect)(()=>{w?Fe!==null&&(0,d.shouldAutoFocusTextInput)()&&hk(Fe,mt):Fe!==null&&ct&&(pt.current?(pt.current=!1,hk(Fe,mt)):!it&&(0,d.shouldAutoFocusTextInput)()&&hk(Fe,mt))},[w,je,it,ct,re,Fe]),(0,g.useEffect)(()=>{it||Ne===``||mt()},[Ne!==``]),(0,g.useEffect)(()=>_k(et),[]);let ht=(0,g.useRef)({sessionId:re,ids:new Set(Ie.map(e=>e.id)),count:Ie.length}),[gt,_t]=(0,g.useState)(0),vt=(0,g.useRef)(0);(0,g.useEffect)(()=>{let e=ht.current,t=e.sessionId!==re,n=gt!==vt.current;if(vt.current=gt,t){ht.current={sessionId:re,ids:new Set(Ie.map(e=>e.id)),count:Ie.length};return}let r=!1;for(let t of Ie)e.ids.has(t.id)||(e.ids.add(t.id),r=!0);let i=e.count!==Ie.length;e.count=Ie.length;let a=(r||n)&&(0,d.shouldAutoFocusTextInput)();if(!a&&!i&&!r&&!n||Fe===null||!ct||it)return;a&&hk(Fe,mt);let o=window.requestAnimationFrame(()=>{let e=Fe.getRootElement();if(e===null)return;let t=e.ownerDocument.activeElement;a&&(t===null||t===e.ownerDocument.body||t===e.ownerDocument.documentElement)&&hk(Fe,mt),gk(Fe),mt()});return()=>{window.cancelAnimationFrame(o)}},[re,Ie,gt,Fe,ct,it]);let yt=(0,g.useCallback)((e,t)=>{if(Te!==null||a===void 0||e.length===0)return;if(!Je){Ue(p(`attachment.unavailable`));return}let n=(()=>{if(Ye&&e.some(e=>!(Ge?.mediaTypes)?.includes(e.type)))return p(`image.unsupportedType`);if(Ge!==void 0){let t=Ge.mediaTypes,n=e.filter(e=>t.includes(e.type)),r=Ie.filter(e=>e.kind===`image`);if(r.length+n.length>Ge.maxImagesPerMessage)return p(`image.tooMany`,{count:Ge.maxImagesPerMessage});if(n.some(e=>e.size>Ge.maxImageBytes))return p(`image.fileTooLarge`,{size:xk(Ge.maxImageBytes)});if(r.reduce((e,t)=>e+t.file.size,0)+n.reduce((e,t)=>e+t.size,0)>Ge.maxMessageImageBytes)return p(`image.totalTooLarge`,{size:xk(Ge.maxMessageImageBytes)})}return a(e,t)})();n===null?_t(e=>e+1):Ue(n)},[Te,a,Je,Ye,Ie,Ge,Ue,p]),bt=Je&&Te===null&&!it&&!ot&&a!==void 0,xt=p(Je?Ye?`input.imagesAndCommands`:`input.commands`:`input.commandsOnly`),St=(0,g.useRef)(null),Ct=e=>{let t=e.target.files===null?[]:[...e.target.files];e.target.value=``,t.length>0&&yt(t)},wt=(0,g.useRef)({locked:it,canPasteText:ct,machineBusy:ot,primaryAction:Pe,canSteerQueue:dt,running:we,steeringAvailable:ut,busyEnter:ve,intakeFiles:yt,uploadsFailed:ze,showToast:Ue,t:p,canAcceptDrop:bt});wt.current={locked:it,canPasteText:ct,machineBusy:ot,primaryAction:Pe,canSteerQueue:dt,running:we,steeringAvailable:ut,busyEnter:ve,intakeFiles:yt,uploadsFailed:ze,showToast:Ue,t:p,canAcceptDrop:bt},(0,g.useEffect)(()=>{if(r!==void 0)return vk(r,wt,St)},[r]),(0,g.useEffect)(()=>{if(Fe!==null){if(w&&i!==void 0)return pk(Fe,{arbitrate:()=>`pass`,space:()=>!1,dismissPopup:()=>{},canSubmit:()=>!1,submit:()=>{},intakeFiles:()=>{wt.current.showToast(wt.current.t(`newSession.uploadUnavailable`))},pasteText:e=>{i.paste(e)}});if(r!==void 0)return yk(Fe,r,wt)}},[Fe,r,w,i]);let Tt=e=>{bk(e,Fe)},Et=()=>{r!==void 0&&(Fe!==null&&(0,d.shouldAutoFocusTextInput)()&&hk(Fe,mt),u?.(r.caretSpan()))},Dt=e=>{st&&(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),de())},Ot=Pe===void 0&&we&&Te===null&&(Le||le!==void 0),kt=Ot?f===void 0:(Pe===void 0?Le:Pe.disabled)||rt||ot,At=we&&tt,jt=uO(ve,we,`enter`,ut),Mt=!Le&&C?.phase===`plain`&&!Ne.trimStart().startsWith(`/`),Nt=p(Ot?`input.stop`:Pe===void 0&&we&&ut&&!rt&&!ze&&Mt?jt===`steer`?`input.send.steer`:`input.send.queue`:`input.send`),Pt=()=>{Ot?f?.():ze?Ue(p(`file.retryOrRemove`)):Pe===void 0?r!==void 0&&!Le&&!rt&&!ot&&r.submit(jt,`click`):kt||Pe.run()},Ft=(C?.phase===`claimed`||C?.phase===`submitting`)&&C.claim!==void 0&&Ne.startsWith(C.claim.token),It=Ft&&C.claim.hint!==void 0&&Ne.slice(C.claim.token.length).trim()===``?C.claim.hint:null,Lt=(()=>{if(It===null)return null;let e=C?.claim?.name??``,t=`hint.${e===`goal`&&Oe?`goal.active`:e}`,n=p(t);return n===t?It:n})(),Rt=fe??p(nt?`placeholder.parentOffline`:rt?`placeholder.unavailable`:dt?`placeholder.steerQueue`:De?`placeholder.plan`:`placeholder.default`);return/* @__PURE__ */ (0,h.jsxs)(`div`,{className:VS($.root,ie===`hero`&&$.hero),"data-composer-variant":ie,children:[Be!==null&&/* @__PURE__ */ (0,h.jsx)(d.Toast,{text:Be.text,icon:/* @__PURE__ */ (0,h.jsx)(d.IconWarningOutlineRegular,{}),anchor:$e.current,onDone:We},Be.seq),_e?.level===`info`&&/* @__PURE__ */ (0,h.jsx)(`div`,{className:$.notice,role:`status`,children:_e.text}),/* @__PURE__ */ (0,h.jsxs)(`div`,{className:$.cardStack,children:[pe!==void 0&&/* @__PURE__ */ (0,h.jsx)(`div`,{className:$.topRail,"data-composer-top-bar":``,onClick:e=>{e.stopPropagation()},onPointerDown:e=>{e.stopPropagation()},children:pe}),/* @__PURE__ */ (0,h.jsxs)(`div`,{ref:$e,className:VS($.card,st&&$.cardWorkspaceTrigger),"data-composer-card":!0,onClick:st?de:void 0,onPointerDown:st?e=>{e.stopPropagation()}:void 0,children:[re!==void 0&&/* @__PURE__ */ (0,h.jsx)(`div`,{className:$.overlayAnchor,children:m(`conversation.input.overlay`,{})}),S!==void 0&&/* @__PURE__ */ (0,h.jsx)(`div`,{className:$.accessory,children:S}),Ae&&/* @__PURE__ */ (0,h.jsxs)(`div`,{className:$.creationError,role:`alert`,"data-new-session-error":``,children:[/* @__PURE__ */ (0,h.jsx)(d.IconWarningOutlineRegular,{className:$.creationErrorIcon,size:16}),/* @__PURE__ */ (0,h.jsxs)(`div`,{className:$.creationErrorCopy,children:[/* @__PURE__ */ (0,h.jsx)(`span`,{className:$.creationErrorTitle,children:p(`newSession.createFailedTitle`)}),/* @__PURE__ */ (0,h.jsx)(`span`,{className:$.creationErrorDetail,children:se.reason===`no-harness`?p(`newSession.createFailed.noHarness`):se.reason===`workspace-required`?p(`newSession.createFailed.workspaceRequired`):se.message??p(`newSession.createFailed.generic`)})]}),ce!==void 0&&/* @__PURE__ */ (0,h.jsx)(`button`,{type:`button`,className:$.creationRetry,onMouseDown:Tt,onClick:ce,children:p(`newSession.retry`)})]}),he.length===0?null:/* @__PURE__ */ (0,h.jsx)(`div`,{className:$.annotations,"data-composer-annotations":!0,children:he.map((e,t)=>/* @__PURE__ */ (0,h.jsx)(d.ResponseAnnotationChip,{index:t+1,annotation:e,labels:ge,onActivate:e.anchor===void 0?void 0:()=>l?.(e.id),onRemove:()=>{n?.removeResponseAnnotation(e.id)}},e.id))}),C===void 0||re===void 0?null:/* @__PURE__ */ (0,h.jsx)(`div`,{className:$.inlineNotices,children:m(`conversation.input.notice`,{})}),m(`conversation.input.attachments`,{attachments:Ie,canAcceptDrop:bt,onAddFiles:yt,onRemoveAttachment:e=>{o?.(e)},uploads:Re,onRetryFile:e=>{c?.(e)},dropLimits:Ge===void 0?void 0:{count:Ge.maxImagesPerMessage,size:xk(Ge.maxImageBytes)}}),/* @__PURE__ */ (0,h.jsx)(dk,{classNames:$,editor:Fe,scrollRef:et,editable:ct,editorDisabled:lt,preserveFocus:pt.current,phase:w?`plain`:C?.phase??`inert`,placeholderText:Rt,ariaLabel:st?p(`hero.chooseWorkspace`):Rt,workspaceTrigger:st,workspacePickerOpen:ue,onWorkspaceKeyDown:Dt,hint:Lt,showPlaceholder:Ne===``&&Ie.length===0&&!Ft}),/* @__PURE__ */ (0,h.jsx)(`div`,{ref:Xe,className:$.row,"data-composer-toolbar":!0,"data-command-menu-open":be||void 0,"data-toolbar-activity":xe||void 0,children:/* @__PURE__ */ (0,h.jsxs)(`div`,{className:$.controlScroll,"data-toolbar-scroll":!0,children:[/* @__PURE__ */ (0,h.jsxs)(`div`,{className:$.tools,hidden:xe,"data-composer-tools":!0,children:[/* @__PURE__ */ (0,h.jsx)(`div`,{className:$.addSeat,"data-toolbar-fixed":`start`,children:/* @__PURE__ */ (0,h.jsx)(d.Tooltip,{portal:Ze.phone,label:xt,side:`top`,delayMs:500,children:/* @__PURE__ */ (0,h.jsx)(`button`,{type:`button`,className:$.add,"aria-label":xt,"aria-haspopup":`listbox`,"aria-expanded":be,disabled:it||ot||u===void 0,onMouseDown:Tt,onClick:Et,children:/* @__PURE__ */ (0,h.jsx)(d.IconPlusOutlineMedium,{size:14})})})}),/* @__PURE__ */ (0,h.jsx)(`input`,{ref:St,type:`file`,accept:Ye?Ge?.mediaTypes.join(`,`):void 0,multiple:!0,disabled:!Je||Te!==null,hidden:!0,onChange:Ct}),/* @__PURE__ */ (0,h.jsxs)(`div`,{className:$.modes,children:[re===void 0?null:m(`conversation.input.permission`,{locked:it}),re===void 0?null:m(`conversation.input.plan`,{locked:it})]}),C===void 0||re===void 0?null:m(`conversation.input.left`,{})]}),/* @__PURE__ */ (0,h.jsxs)(`div`,{className:VS($.trailing,xe&&$.trailingActive),children:[/* @__PURE__ */ (0,h.jsxs)(`div`,{className:$.standardControls,hidden:xe,children:[C===void 0||re===void 0?null:m(`conversation.input.right`,{overflowActions:Ze.overflowActions}),re===void 0?ke?/* @__PURE__ */ (0,h.jsxs)(`div`,{className:$.pendingControls,role:`status`,"aria-live":`polite`,"data-new-session-loading":``,children:[/* @__PURE__ */ (0,h.jsxs)(`span`,{className:$.pendingModel,children:[/* @__PURE__ */ (0,h.jsx)(d.StateDot,{state:`ongoing`}),/* @__PURE__ */ (0,h.jsx)(`span`,{className:$.pendingModelLabel,children:p(`newSession.loadingModel`)})]}),/* @__PURE__ */ (0,h.jsx)(`span`,{className:$.pendingHarness,role:`img`,"aria-label":p(`newSession.loadingHarness`),"aria-busy":`true`,title:p(`newSession.loadingHarness`),children:/* @__PURE__ */ (0,h.jsx)(d.StateDot,{state:`ongoing`})})]}):null:m(`conversation.input.model`,{locked:at})]}),C===void 0||re===void 0?null:/* @__PURE__ */ (0,h.jsx)(`div`,{className:xe?$.activityExpanded:$.activity,children:m(`conversation.input.activity`,{locked:it,onActiveChange:Se})}),/* @__PURE__ */ (0,h.jsxs)(`div`,{className:$.submitSeat,"data-toolbar-fixed":`end`,children:[At&&/* @__PURE__ */ (0,h.jsx)(d.Tooltip,{portal:Ze.phone,label:p(`input.stop`),shortcutKeys:ye,side:`top`,delayMs:500,disabled:f===void 0,children:/* @__PURE__ */ (0,h.jsx)(`button`,{type:`button`,className:$.primary,"aria-label":p(`input.stop`),disabled:f===void 0,onMouseDown:Tt,onClick:f,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:Ot?p(`input.stop`):Nt,shortcutKeys:Ot?ye:void 0,side:`top`,delayMs:500,disabled:kt,children:/* @__PURE__ */ (0,h.jsx)(`button`,{type:`button`,className:$.primary,"aria-label":Nt,disabled:kt,onMouseDown:Tt,onClick:Pt,children:Ot?/* @__PURE__ */ (0,h.jsx)(`svg`,{viewBox:`0 0 16 16`,width:`14`,height:`14`,"aria-hidden":!0,children:/* @__PURE__ */ (0,h.jsx)(`rect`,{x:`3`,y:`3`,width:`10`,height:`10`,rx:`3`,fill:`currentColor`})}):/* @__PURE__ */ (0,h.jsx)(`svg`,{viewBox:`0 0 16 16`,width:`14`,height:`14`,"aria-hidden":!0,children:/* @__PURE__ */ (0,h.jsx)(`path`,{d:`M8.3125 0.980183C8.66767 1.0531 8.97902 1.20418 9.2627 1.43233C9.48724 1.61297 9.73029 1.85793 9.97949 2.10714L14.707 6.83468L13.293 8.24874L9 3.95577V15.0417H7V3.95577L2.70703 8.24874L1.29297 6.83468L6.02051 2.10714C6.26971 1.85793 6.51277 1.61297 6.7373 1.43233C6.97662 1.23986 7.28445 1.04402 7.6875 0.980183C7.8973 0.947006 8.1031 0.95516 8.3125 0.980183Z`,fill:`currentColor`})})})})]})]})]})})]})]}),/* @__PURE__ */ (0,h.jsxs)(`div`,{className:$.dock,"data-composer-dock":!0,children:[ie===`composer`&&C!==void 0&&re!==void 0?m(`conversation.composer.dock`,{}):null,xe?null:/* @__PURE__ */ (0,h.jsx)(Ak,{useProjection:ne,t:p})]})]})}),Fk=`@deepseek-ai/dsh-client-ui-conversation/TodoPanel.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(Fk)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-conversation`,e.dataset.pluginCss=Fk,e.textContent=`.OKyn-W_root{box-sizing:border-box;width:calc(100% - var(--dsh-composer-side-clearance) - var(--dsh-composer-side-clearance) - var(--dsh-composer-dock-inset) - var(--dsh-composer-dock-inset) - var(--dsh-composer-dock-inset) - var(--dsh-composer-dock-inset));max-width:calc(var(--dsh-composer-card-max-width) - var(--dsh-composer-dock-inset) - var(--dsh-composer-dock-inset) - var(--dsh-composer-dock-inset) - var(--dsh-composer-dock-inset));--dsw-elevation-stroke-color:var(--dsw-alias-border-l1);border-radius:var(--dsw-radius-lg);background:var(--dsw-specific-menu);backdrop-filter:var(--dsw-menu-backdrop-filter);box-shadow:var(--dsw-elevation-panel);--dsh-scrollbar-thumb:var(--dsw-alias-scrollbar-bg-l2);--dsh-scrollbar-thumb-hover:var(--dsw-alias-scrollbar-hover-l2);border:0;flex:none;margin:0 auto;overflow:hidden}.OKyn-W_body{flex-direction:column;gap:8px;padding:6px 12px;display:flex}.OKyn-W_header{text-align:left;cursor:pointer;background:0 0;border:none;align-items:center;gap:10px;width:100%;padding:0;display:flex}.OKyn-W_lead{color:var(--dsw-alias-label-tertiary);flex:none;place-items:center;display:grid}.OKyn-W_title{color:var(--dsw-alias-label-primary);flex:none;font-size:13px;font-weight:500;line-height:24px}.OKyn-W_progress{min-width:0;color:var(--dsw-alias-label-tertiary);text-overflow:ellipsis;white-space:nowrap;flex:auto;font-size:13px;font-weight:400;line-height:20px;overflow:hidden}.OKyn-W_chevron{color:var(--dsw-alias-label-tertiary);flex:none;place-items:center;display:grid}.OKyn-W_list{flex-direction:column;gap:8px;max-height:180px;margin:0;padding:0;list-style:none;display:flex;overflow-y:auto}.OKyn-W_item{min-width:0;color:var(--dsw-alias-label-secondary);align-items:center;gap:10px;font-size:13px;line-height:20px;display:flex}.OKyn-W_glyph{flex:none;place-items:center;width:16px;height:16px;display:grid}.OKyn-W_content{text-overflow:ellipsis;white-space:nowrap;min-width:0;overflow:hidden}`,document.head.appendChild(e)}var Ik={body:`OKyn-W_body`,chevron:`OKyn-W_chevron`,content:`OKyn-W_content`,glyph:`OKyn-W_glyph`,header:`OKyn-W_header`,item:`OKyn-W_item`,lead:`OKyn-W_lead`,list:`OKyn-W_list`,progress:`OKyn-W_progress`,root:`OKyn-W_root`,title:`OKyn-W_title`};
|
|
177
168
|
/* v8 ignore next 3 -- closed-union backstop; only reached if status is forged */
|
|
178
|
-
function
|
|
169
|
+
function Lk(e){throw Error(`unreachable todo status: ${String(e)}`)}function Rk(e){switch(e){case`completed`:return`done`;case`in_progress`:return`ongoing`;case`pending`:return`idle`;
|
|
179
170
|
/* v8 ignore next -- closed TodoItem status union */
|
|
180
|
-
default:return
|
|
171
|
+
default:return Lk(e)}}function zk(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`);
|
|
181
172
|
/* v8 ignore next -- closed TodoItem status union */
|
|
182
|
-
default:return
|
|
173
|
+
default:return Lk(e)}}function Bk(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 Vk({todos:e,t}){let[n,r]=(0,g.useState)(!0);return e.length===0?null:/* @__PURE__ */ (0,h.jsx)(`section`,{className:Ik.root,"data-testid":`todo-panel`,"aria-label":t(`todo.title`),children:/* @__PURE__ */ (0,h.jsxs)(`div`,{className:Ik.body,children:[/* @__PURE__ */ (0,h.jsxs)(`button`,{type:`button`,className:Ik.header,"aria-expanded":!n,onClick:()=>{r(e=>!e)},children:[/* @__PURE__ */ (0,h.jsx)(`span`,{className:Ik.lead,"aria-hidden":!0,children:/* @__PURE__ */ (0,h.jsx)(d.IconChecklistOutlineRegular,{})}),/* @__PURE__ */ (0,h.jsx)(`span`,{className:Ik.title,children:t(`todo.title`)}),/* @__PURE__ */ (0,h.jsx)(`span`,{className:Ik.progress,children:Bk(e,t)}),/* @__PURE__ */ (0,h.jsx)(`span`,{className:Ik.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:Ik.list,children:e.map(e=>/* @__PURE__ */ (0,h.jsxs)(`li`,{className:Ik.item,"data-status":e.status,children:[/* @__PURE__ */ (0,h.jsx)(`span`,{className:Ik.glyph,role:`img`,"aria-label":zk(e.status,t),children:/* @__PURE__ */ (0,h.jsx)(d.StateDot,{state:Rk(e.status)})}),/* @__PURE__ */ (0,h.jsx)(`span`,{className:Ik.content,children:e.content})]},e.content))})]})})}function Hk({useProjection:e,t}){let n=e(`todos`);return/* @__PURE__ */ (0,h.jsx)(Vk,{todos:n??[],t})}let Uk={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:zu},Hk))}};var Wk=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 Gk(e,t,n,r,i){let a=()=>{},o=new Wk(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 Kk=[`slots`,`sessions`,`fileUpload`,`uiSession`,`uiWorkspace`,`locale`,`configForms`],qk=C.object({maxConcurrentFileUploads:C.natural().min(1).default(2)}),Jk={getSnapshot:()=>null,subscribe:()=>()=>{}},Yk={getSnapshot:()=>void 0,subscribe:()=>()=>{}},Xk=/* @__PURE__ */ new Map,Zk={getSnapshot:()=>Xk,subscribe:()=>()=>{}},Qk={getSnapshot:()=>null,subscribe:()=>()=>{}},$k={},eA={getSnapshot:()=>$k,subscribe:()=>()=>{}},tA={state:`idle`},nA={getSnapshot:()=>tA,subscribe:()=>()=>{}},rA={getSnapshot:()=>``,subscribe:()=>()=>{}};function iA(){return globalThis.__DSH_HOST_PATHS__}function aA(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 oA(e){let t=e.get(`conversation`);if(t===void 0)throw Error(`ui-conversation: conversation service unavailable`);return t}function sA(e,t=qk({})){let n=e.sessions,r=e.slots,i=t.maxConcurrentFileUploads,a=e.get(`uiWorkspace`),o=new wt(e,n);e.effect(()=>e.locale.register(zu,{zh:Hu,en:Uu}),`ui-conversation: dictionaries`);let s=e.locale.bind(zu),c=Nu(),l=new dO(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:zu,inject:()=>({hooks:{busyEnter:l.busyEnter},setBusyEnter:e=>{l.setBusyEnter(e)}})},DO));let u=()=>{let t=[];for(let n of r.entries(`conversation.view`))
|
|
183
174
|
/* v8 ignore next -- list registration validates id at load. */
|
|
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=
|
|
175
|
+
n.options.id!==void 0&&(e.configForms.developerTools.enabled.getSnapshot()||n.options.id!==`trajectory`)&&t.push({id:n.options.id,label:(0,p.resolveSlotLabel)(n.options.label)??n.options.id});return t},m=(e,t)=>{let n=rk(u(),t);n!==void 0&&o.binding(e).activate(n.id)},h=e=>{m(e,Fu(e))},g=(0,f.createSnapshotStore)(u()),_=/* @__PURE__ */ new Set,v=/* @__PURE__ */ new WeakSet,y=e=>{v.has(e)||(v.add(e),_.add(e),e.ctx.effect(()=>()=>{_.delete(e)},`ui-conversation: active Provider binding`))},b=()=>{let e=g.getSnapshot(),t=u();e.length===t.length&&e.every((e,n)=>{let r=t.at(n);return r!==void 0&&e.id===r.id&&e.label===r.label})||g.set(t);for(let e of _)n.binding(e.sessionId)===e&&h(e.sessionId)};e.effect(()=>{let t=r.subscribe(`conversation.view`,b),n=e.locale.subscribe(b),i=e.configForms.developerTools.enabled.subscribe(b);return()=>{i(),n(),t()}},`ui-conversation: View selection`);let x=e=>{aA(n,e).cancel().catch(e=>{})},ee=(0,f.createSnapshotStore)([]);e.inject([`shortcuts`],t=>{let r=[{id:`fixed.send`,label:()=>s(`input.send`),keys:[`Enter`],bindings:[{code:`Enter`,modifiers:[]}],group:`input`},{id:`fixed.newline`,label:()=>s(`shortcut.newline`),keys:t.shortcuts.describeBinding({code:`Enter`,modifiers:[`shift`]}).keys,bindings:[{code:`Enter`,modifiers:[`shift`]}],group:`input`},{id:`fixed.complementary`,label:()=>s(`shortcut.complementary`),keys:t.shortcuts.describeBinding({code:`Enter`,modifiers:[`primary`]}).keys,bindings:[{code:`Enter`,modifiers:[`control`]},{code:`Enter`,modifiers:[`meta`]}],group:`input`},{id:`fixed.slash`,label:()=>s(`shortcut.slash`),keys:[`/`],bindings:[{code:`Slash`,modifiers:[]}],group:`input`},{id:`fixed.mention`,label:()=>s(`shortcut.mention`),keys:[`@`],bindings:[{code:`Digit2`,modifiers:[`shift`]}],group:`input`}];for(let e of r)t.effect(()=>t.shortcuts.registerFixed(e),`ui-conversation: ${e.id}`);t.effect(()=>Gk(t.shortcuts,n,e=>o.binding(e).openTurn,e.uiSession,x),`ui-conversation: fixed stop input`),t.effect(()=>{let e={id:`response.stop`,label:()=>s(`input.stop`),keys:[`Esc`,`Esc`],bindings:[{code:`Escape`,modifiers:[]}],group:`input`},n=t.shortcuts.registerFixed(e);return ee.set(e.keys),()=>{ee.set([]),n()}},`ui-conversation: fixed stop reference`)});let te=new aO;e.effect(()=>{let e=a.creating;e!==void 0&&te.syncCreation(e.getSnapshot());let t=e?.subscribe(()=>{te.syncCreation(e.getSnapshot())});return()=>{t?.(),te.dispose()}},`ui-conversation: pending new-session draft`);let ne=new rO(e,s,te),re=new Qu;e.inject([`commandUi`],e=>{let t=e.get(`commandUi`);e.effect(()=>t.register({name:`file`,label:()=>s(`input.file`),icon:d.IconPaperclipOutlineRegular,available:e=>ne.canPickFiles(e.sessionId),ui:{kind:`action`,run:e=>{ne.pickFiles(e.sessionId)}}}),`ui-conversation: File action`)}),e.uiSession.provide({hooks:[`conversation`,`input`],props:[`inputActions`],resolve:e=>{y(e);let t=ne.shellFor(e),n=o.binding(e);return h(e.sessionId),{hooks:{conversation:n.snapshot,input:t.state},props:{inputActions:t.actions}}}});let ie=()=>r.register({name:`main.conversation`,children:{"conversation.header":{kind:`single`,scope:`session-maybe`},"conversation.header.notice":{kind:`list`,scope:`session-maybe`}}},zO),ae=()=>r.registerFactory({name:`conversation.content`,scope:`session-maybe`,locale:zu,children:{"conversation.session":{kind:`single`,scope:`session`},"conversation.composer":{kind:`chain`,scope:`session`},"conversation.composer.bar":{kind:`single`,scope:`session-maybe`},"conversation.input.dock":{kind:`list`,scope:`session`},"conversation.hero.brand.mark":{kind:`single`,scope:`root`},"conversation.hero.workspace":{kind:`single`,scope:`root`},"conversation.hero.agentPreset":{kind:`single`,scope:`session-maybe`}},slots:{views:{scope:`session`},widthControls:{scope:`root`}},inject:t=>({referenceEditor:t===void 0?void 0:ne.shell(t).editor,retrySessionCreation:()=>{a.retryCreating?.()},hooks:{composerBlock:t===void 0?Yk:re.storeFor(t),sessionCreation:a.creating??nA},selectWorkspace:r=>a.openWorkspace(r,r=>{if(t!==void 0&&r!==t){let i=ne.shell(t),a=i.draftSnapshot,o=i.snapshot.attachmentIds,s=ne.shell(r);if(o.length===0||s.addAttachments(o)){if(n.binding(r)===void 0)throw Error(`ui-conversation: session "${r}" resolved no binding`);if(oA(e).rebindDraftFiles(r,o),a.text!==``&&(s.setDraft(a),i.setDraft(``)),o.length>0)for(let e of o)i.removeAttachment(e)}}})})},$O),oe=()=>r.register({name:`conversation.session`,children:{"conversation.view":{kind:`list`,scope:`session`}},store:c,inject:(e,t)=>{let r=(n,r)=>{u().some(e=>e.id===n)&&(m(e,n),t.openView(n,r))},i=()=>o.views.entries().find(e=>e.toolCallFocus!==void 0&&g.getSnapshot().some(t=>t.id===e.target)),a=e=>{let t=i();t?.toolCallFocus!==void 0&&r(t.target,t.toolCallFocus(e))};return{hooks:{conversationViews:g,inspectCall:{getSnapshot:()=>i()===void 0?void 0:a,subscribe:e=>{let t=g.subscribe(e),n=o.views.subscribe(e);return()=>{t(),n()}}}},bindDraftPersistence:t=>ne.shell(e).bindDraftPersistence(t),onRevealResponseAnnotation:t=>n.scope(e)?.on(`conversation/reveal-response-annotation`,t)??(()=>{}),openView:r}}},ck),se=()=>r.register({name:`conversation.header`,children:{"conversation.header.leading":{kind:`single`,scope:`root`},"conversation.header.navigation":{kind:`single`,scope:`session-maybe`},"conversation.header.shortcuts":{kind:`single`,scope:`session-maybe`},"conversation.header.trailing":{kind:`single`,scope:`root`},"conversation.session.header":{kind:`single`,scope:`session`}}},nk),ce=()=>r.register({name:`conversation.session.header`,locale:zu,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)}})},sk),le=()=>r.register({name:`conversation.composer.bar`,locale:zu,children:{"conversation.input.attachments":{kind:`single`,scope:`session-maybe`},"conversation.input.overlay":{kind:`list`,scope:`session`},"conversation.input.notice":{kind:`list`,scope:`session`},"conversation.input.permission":{kind:`single`,scope:`session`},"conversation.input.left":{kind:`list`,scope:`session`},"conversation.input.plan":{kind:`single`,scope:`session`},"conversation.input.right":{kind:`list`,scope:`session`},"conversation.input.model":{kind:`single`,scope:`session`},"conversation.input.activity":{kind:`single`,scope:`session`},"conversation.composer.dock":{kind:`list`,scope:`session`}},inject:t=>{if(t===void 0)return{keyboard:void 0,pendingDraft:{editor:te.editor,paste:e=>{te.paste(e)}},addFiles:void 0,removeAttachment:void 0,resolveDraftAttachments:void 0,retryFileUpload:void 0,revealResponseAnnotation:void 0,toggleCommandMenu:void 0,stop:void 0,hooks:{pendingDraftText:te.text,stopShortcut:ee,busyEnter:l.busyEnter,fileUploads:eA,notices:Jk,lexicon:Zk,menuLauncher:Qk}};let r=oA(e),i=ne.shell(t),a=ne.inputTriggers(t),o=iA();return{keyboard:i,pendingDraft:void 0,addFiles:(e,a=/* @__PURE__ */ new Set)=>{if(n.binding(t)===void 0)return s(`file.sessionUnavailable`);if(i.snapshot.phase===`adjudicating`||i.snapshot.phase===`submitting`)return s(`attachment.dropBlocked`);let c=[],l=[],u=n.list.getSnapshot().byId[t]?.cwd;for(let t of e){let e=a.has(t);if(o===void 0&&e)return s(`attachment.directoryDesktopOnly`);let n=o?.pathFor(t)??``;if(e&&n===``)return s(`attachment.pathUnavailable`);if(n===``||!e&&Xu(t.type)){c.push(t);continue}let r=Ru(n,u),i=Iu({path:e?`${r}/`:r,kind:`file`},!1);if(i===void 0)return s(`attachment.pathUnsupported`);let d=Lu(n)||t.name;l.push({source:`reference`,ref:i,label:e?`${d}/`:d,appearance:e?`folder`:`file`,clipboardText:i})}try{let e=r.createDrafts(t,c);return i.addFiles(l,e.map(e=>e.id))?null:(r.releaseDraftAttachments(e),s(`attachment.dropBlocked`))}catch(e){return e instanceof Error?e.message:String(e)}},removeAttachment:e=>{i.removeAttachment(e)&&r.releaseDraftAttachment(e)},resolveDraftAttachments:e=>r.resolveDraftAttachments(e),retryFileUpload:e=>{n.binding(t)!==void 0&&r.retryFileUpload(t,e)},revealResponseAnnotation:e=>{let r=n.scope(t);r?.emit(r,`conversation/reveal-response-annotation`,e)},toggleCommandMenu:a===void 0?void 0:e=>{i.dismissPopup();let t=i.snapshot;a.toggleSource(`command`,{trigger:`/`,query:``,quoted:!1,position:t.draft.slice(0,e.start).trim()===``?`leading`:`inline`,span:{...e,draftRev:t.draftRev}})},stop:()=>{x(t)},hooks:{pendingDraftText:rA,stopShortcut:ee,busyEnter:l.busyEnter,fileUploads:r.fileUploads,notices:i.notices,lexicon:i.lexicon,menuLauncher:a?.launcher??Qk}}}},Pk);e.inject([`conversation`],e=>e.slots.inject(`main`,function*(){yield r.register({name:`main`,key:`conversation`,children:{"main.conversation":{kind:`single`,scope:`session-maybe`}}},ek),yield ie(),yield ae(),yield oe(),yield se(),yield ce(),yield le()})),e.plugin(Yu,{input:ne,blocks:re,maxConcurrentFileUploads:i}),e.plugin(Uk),e.plugin(CO,ne)}return n.Config=qk,n.ConversationController=Yu,n.ConversationDefinitionRegistry=mt,n.ConversationEventRegistry=ht,n.ConversationLocationIndex=Qe,n.ConversationNodeAssembler=dt,n.ConversationViewRegistry=xt,n.EMPTY_CONVERSATION_SNAPSHOT=OO,n.UiConversation=wt,n.apply=sA,n.conversationPhase=kO,n.inject=Kk,n.inspectRequestPrompt=Me,t.exports}});
|