flavor-code 1.3.9 → 1.3.11

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.
@@ -69,7 +69,7 @@ ${e}</tr>
69
69
  `}tablecell(e){let t=this.parser.parseInline(e.tokens),n=e.header?`th`:`td`;return(e.align?`<${n} align="${e.align}">`:`<${n}>`)+t+`</${n}>
70
70
  `}strong({tokens:e}){return`<strong>${this.parser.parseInline(e)}</strong>`}em({tokens:e}){return`<em>${this.parser.parseInline(e)}</em>`}codespan({text:e}){return`<code>${P(e,!0)}</code>`}br(e){return`<br>`}del({tokens:e}){return`<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:t,tokens:n}){let r=this.parser.parseInline(n),i=Mt(e);if(i===null)return r;e=i;let a=`<a href="`+e+`"`;return t&&(a+=` title="`+P(t)+`"`),a+=`>`+r+`</a>`,a}image({href:e,title:t,text:n,tokens:r}){r&&(n=this.parser.parseInline(r,this.parser.textRenderer));let i=Mt(e);if(i===null)return P(n);e=i;let a=`<img src="${e}" alt="${n}"`;return t&&(a+=` title="${P(t)}"`),a+=`>`,a}text(e){return`tokens`in e&&e.tokens?this.parser.parseInline(e.tokens):`escaped`in e&&e.escaped?e.text:P(e.text)}},Vt=class{strong({text:e}){return e}em({text:e}){return e}codespan({text:e}){return e}del({text:e}){return e}html({text:e}){return e}text({text:e}){return e}link({text:e}){return``+e}image({text:e}){return``+e}br(){return``}},Ht=class e{options;renderer;textRenderer;constructor(e){this.options=e||Ee,this.options.renderer=this.options.renderer||new Bt,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new Vt}static parse(t,n){return new e(n).parse(t)}static parseInline(t,n){return new e(n).parseInline(t)}parse(e,t=!0){let n=``;for(let r=0;r<e.length;r++){let i=e[r];if(this.options.extensions?.renderers?.[i.type]){let e=i,t=this.options.extensions.renderers[e.type].call({parser:this},e);if(t!==!1||![`space`,`hr`,`heading`,`code`,`table`,`blockquote`,`list`,`html`,`def`,`paragraph`,`text`].includes(e.type)){n+=t||``;continue}}let a=i;switch(a.type){case`space`:n+=this.renderer.space(a);continue;case`hr`:n+=this.renderer.hr(a);continue;case`heading`:n+=this.renderer.heading(a);continue;case`code`:n+=this.renderer.code(a);continue;case`table`:n+=this.renderer.table(a);continue;case`blockquote`:n+=this.renderer.blockquote(a);continue;case`list`:n+=this.renderer.list(a);continue;case`html`:n+=this.renderer.html(a);continue;case`def`:n+=this.renderer.def(a);continue;case`paragraph`:n+=this.renderer.paragraph(a);continue;case`text`:{let i=a,o=this.renderer.text(i);for(;r+1<e.length&&e[r+1].type===`text`;)i=e[++r],o+=`
71
71
  `+this.renderer.text(i);t?n+=this.renderer.paragraph({type:`paragraph`,raw:o,text:o,tokens:[{type:`text`,raw:o,text:o,escaped:!0}]}):n+=o;continue}default:{let e=`Token with "`+a.type+`" type was not found.`;if(this.options.silent)return console.error(e),``;throw Error(e)}}}return n}parseInline(e,t=this.renderer){let n=``;for(let r=0;r<e.length;r++){let i=e[r];if(this.options.extensions?.renderers?.[i.type]){let e=this.options.extensions.renderers[i.type].call({parser:this},i);if(e!==!1||![`escape`,`html`,`link`,`image`,`strong`,`em`,`codespan`,`br`,`del`,`text`].includes(i.type)){n+=e||``;continue}}let a=i;switch(a.type){case`escape`:n+=t.text(a);break;case`html`:n+=t.html(a);break;case`link`:n+=t.link(a);break;case`image`:n+=t.image(a);break;case`strong`:n+=t.strong(a);break;case`em`:n+=t.em(a);break;case`codespan`:n+=t.codespan(a);break;case`br`:n+=t.br(a);break;case`del`:n+=t.del(a);break;case`text`:n+=t.text(a);break;default:{let e=`Token with "`+a.type+`" type was not found.`;if(this.options.silent)return console.error(e),``;throw Error(e)}}}return n}},Ut=class{options;block;constructor(e){this.options=e||Ee}static passThroughHooks=new Set([`preprocess`,`postprocess`,`processAllTokens`,`emStrongMask`]);static passThroughHooksRespectAsync=new Set([`preprocess`,`postprocess`,`processAllTokens`]);preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}emStrongMask(e){return e}provideLexer(){return this.block?zt.lex:zt.lexInline}provideParser(){return this.block?Ht.parse:Ht.parseInline}},Wt=new class{defaults=Te();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=Ht;Renderer=Bt;TextRenderer=Vt;Lexer=zt;Tokenizer=Rt;Hooks=Ut;constructor(...e){this.use(...e)}walkTokens(e,t){let n=[];for(let r of e)switch(n=n.concat(t.call(this,r)),r.type){case`table`:{let e=r;for(let r of e.header)n=n.concat(this.walkTokens(r.tokens,t));for(let r of e.rows)for(let e of r)n=n.concat(this.walkTokens(e.tokens,t));break}case`list`:{let e=r;n=n.concat(this.walkTokens(e.items,t));break}default:{let e=r;this.defaults.extensions?.childTokens?.[e.type]?this.defaults.extensions.childTokens[e.type].forEach(r=>{let i=e[r].flat(1/0);n=n.concat(this.walkTokens(i,t))}):e.tokens&&(n=n.concat(this.walkTokens(e.tokens,t)))}}return n}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(e=>{let n={...e};if(n.async=this.defaults.async||n.async||!1,e.extensions&&(e.extensions.forEach(e=>{if(!e.name)throw Error(`extension name required`);if(`renderer`in e){let n=t.renderers[e.name];n?t.renderers[e.name]=function(...t){let r=e.renderer.apply(this,t);return r===!1&&(r=n.apply(this,t)),r}:t.renderers[e.name]=e.renderer}if(`tokenizer`in e){if(!e.level||e.level!==`block`&&e.level!==`inline`)throw Error(`extension level must be 'block' or 'inline'`);let n=t[e.level];n?n.unshift(e.tokenizer):t[e.level]=[e.tokenizer],e.start&&(e.level===`block`?t.startBlock?t.startBlock.push(e.start):t.startBlock=[e.start]:e.level===`inline`&&(t.startInline?t.startInline.push(e.start):t.startInline=[e.start]))}`childTokens`in e&&e.childTokens&&(t.childTokens[e.name]=e.childTokens)}),n.extensions=t),e.renderer){let t=this.defaults.renderer||new Bt(this.defaults);for(let n in e.renderer){if(!(n in t))throw Error(`renderer '${n}' does not exist`);if([`options`,`parser`].includes(n))continue;let r=n,i=e.renderer[r],a=t[r];t[r]=(...e)=>{let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n||``}}n.renderer=t}if(e.tokenizer){let t=this.defaults.tokenizer||new Rt(this.defaults);for(let n in e.tokenizer){if(!(n in t))throw Error(`tokenizer '${n}' does not exist`);if([`options`,`rules`,`lexer`].includes(n))continue;let r=n,i=e.tokenizer[r],a=t[r];t[r]=(...e)=>{let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n}}n.tokenizer=t}if(e.hooks){let t=this.defaults.hooks||new Ut;for(let n in e.hooks){if(!(n in t))throw Error(`hook '${n}' does not exist`);if([`options`,`block`].includes(n))continue;let r=n,i=e.hooks[r],a=t[r];Ut.passThroughHooks.has(n)?t[r]=e=>{if(this.defaults.async&&Ut.passThroughHooksRespectAsync.has(n))return(async()=>{let n=await i.call(t,e);return a.call(t,n)})();let r=i.call(t,e);return a.call(t,r)}:t[r]=(...e)=>{if(this.defaults.async)return(async()=>{let n=await i.apply(t,e);return n===!1&&(n=await a.apply(t,e)),n})();let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n}}n.hooks=t}if(e.walkTokens){let t=this.defaults.walkTokens,r=e.walkTokens;n.walkTokens=function(e){let n=[];return n.push(r.call(this,e)),t&&(n=n.concat(t.call(this,e))),n}}this.defaults={...this.defaults,...n}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return zt.lex(e,t??this.defaults)}parser(e,t){return Ht.parse(e,t??this.defaults)}parseMarkdown(e){return(t,n)=>{let r={...n},i={...this.defaults,...r},a=this.onError(!!i.silent,!!i.async);if(this.defaults.async===!0&&r.async===!1)return a(Error(`marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise.`));if(typeof t>`u`||t===null)return a(Error(`marked(): input parameter is undefined or null`));if(typeof t!=`string`)return a(Error(`marked(): input parameter is of type `+Object.prototype.toString.call(t)+`, string expected`));if(i.hooks&&(i.hooks.options=i,i.hooks.block=e),i.async)return(async()=>{let n=i.hooks?await i.hooks.preprocess(t):t,r=await(i.hooks?await i.hooks.provideLexer():e?zt.lex:zt.lexInline)(n,i),a=i.hooks?await i.hooks.processAllTokens(r):r;i.walkTokens&&await Promise.all(this.walkTokens(a,i.walkTokens));let o=await(i.hooks?await i.hooks.provideParser():e?Ht.parse:Ht.parseInline)(a,i);return i.hooks?await i.hooks.postprocess(o):o})().catch(a);try{i.hooks&&(t=i.hooks.preprocess(t));let n=(i.hooks?i.hooks.provideLexer():e?zt.lex:zt.lexInline)(t,i);i.hooks&&(n=i.hooks.processAllTokens(n)),i.walkTokens&&this.walkTokens(n,i.walkTokens);let r=(i.hooks?i.hooks.provideParser():e?Ht.parse:Ht.parseInline)(n,i);return i.hooks&&(r=i.hooks.postprocess(r)),r}catch(e){return a(e)}}}onError(e,t){return n=>{if(n.message+=`
72
- Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error occurred:</p><pre>`+P(n.message+``,!0)+`</pre>`;return t?Promise.resolve(e):e}if(t)return Promise.reject(n);throw n}}};function F(e,t){return Wt.parse(e,t)}F.options=F.setOptions=function(e){return Wt.setOptions(e),F.defaults=Wt.defaults,De(F.defaults),F},F.getDefaults=Te,F.defaults=Ee,F.use=function(...e){return Wt.use(...e),F.defaults=Wt.defaults,De(F.defaults),F},F.walkTokens=function(e,t){return Wt.walkTokens(e,t)},F.parseInline=Wt.parseInline,F.Parser=Ht,F.parser=Ht.parse,F.Renderer=Bt,F.TextRenderer=Vt,F.Lexer=zt,F.lexer=zt.lex,F.Tokenizer=Rt,F.Hooks=Ut,F.parse=F,F.options,F.setOptions,F.use,F.walkTokens,F.parseInline,Ht.parse,zt.lex;var Gt=o((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.fragment`);function r(e,n,r){var i=null;if(r!==void 0&&(i=``+r),n.key!==void 0&&(i=``+n.key),`key`in n)for(var a in r={},n)a!==`key`&&(r[a]=n[a]);else r=n;return n=r.ref,{$$typeof:t,type:e,key:i,ref:n===void 0?null:n,props:r}}e.Fragment=n,e.jsx=r,e.jsxs=r})),Kt=o(((e,t)=>{t.exports=Gt()})),I=Kt();function qt(e){try{return F.lexer(e,{gfm:!0,async:!1}).filter(e=>e.type!==`html`)}catch{return[{type:`text`,raw:e,text:e}]}}function Jt({text:e}){return(0,I.jsx)(`div`,{className:`markdown-content`,children:(0,_.useMemo)(()=>qt(e),[e]).map((e,t)=>(0,I.jsx)(Yt,{token:e},`${e.type}-${t}`))})}function Yt({token:e}){if(e.type===`space`)return null;if(e.type===`heading`){let t=e;return(0,I.jsx)(`h${Math.min(6,t.depth)}`,{children:(0,I.jsx)(Xt,{tokens:t.tokens})})}if(e.type===`paragraph`)return(0,I.jsx)(`p`,{children:(0,I.jsx)(Xt,{tokens:e.tokens??[]})});if(e.type===`code`){let t=e;return(0,I.jsxs)(`div`,{className:`markdown-code`,children:[(0,I.jsx)(`span`,{children:t.lang?.trim()||`code`}),(0,I.jsx)(`pre`,{children:(0,I.jsx)(`code`,{children:t.text})})]})}if(e.type===`blockquote`)return(0,I.jsx)(`blockquote`,{children:e.tokens.map((e,t)=>(0,I.jsx)(Yt,{token:e},t))});if(e.type===`list`){let t=e;return(0,I.jsx)(t.ordered?`ol`:`ul`,{start:t.ordered&&typeof t.start==`number`?t.start:void 0,children:t.items.map((e,t)=>(0,I.jsx)(`li`,{children:e.tokens.map((e,t)=>(0,I.jsx)(Yt,{token:e},t))},t))})}if(e.type===`hr`)return(0,I.jsx)(`hr`,{});if(e.type===`table`){let t=e;return(0,I.jsx)(`div`,{className:`markdown-table-wrap`,children:(0,I.jsxs)(`table`,{children:[(0,I.jsx)(`thead`,{children:(0,I.jsx)(`tr`,{children:t.header.map((e,t)=>(0,I.jsx)(`th`,{style:{textAlign:e.align??void 0},children:(0,I.jsx)(Xt,{tokens:e.tokens})},t))})}),(0,I.jsx)(`tbody`,{children:t.rows.map((e,n)=>(0,I.jsx)(`tr`,{children:e.map((e,n)=>(0,I.jsx)(`td`,{style:{textAlign:t.align[n]??void 0},children:(0,I.jsx)(Xt,{tokens:e.tokens})},n))},n))})]})})}return`tokens`in e&&Array.isArray(e.tokens)?(0,I.jsx)(`p`,{children:(0,I.jsx)(Xt,{tokens:e.tokens})}):`text`in e&&typeof e.text==`string`?(0,I.jsx)(`p`,{children:e.text}):null}function Xt({tokens:e}){return(0,I.jsx)(I.Fragment,{children:e.map((e,t)=>(0,I.jsx)(Zt,{token:e},t))})}function Zt({token:e}){if(e.type===`text`){let t=e;return t.tokens?.length?(0,I.jsx)(Xt,{tokens:t.tokens}):t.text}if(e.type===`strong`)return(0,I.jsx)(`strong`,{children:(0,I.jsx)(Xt,{tokens:e.tokens})});if(e.type===`em`)return(0,I.jsx)(`em`,{children:(0,I.jsx)(Xt,{tokens:e.tokens})});if(e.type===`del`)return(0,I.jsx)(`del`,{children:(0,I.jsx)(Xt,{tokens:e.tokens})});if(e.type===`codespan`)return(0,I.jsx)(`code`,{children:e.text});if(e.type===`br`)return(0,I.jsx)(`br`,{});if(e.type===`escape`)return e.text;if(e.type===`link`){let t=e;return(0,I.jsx)(`a`,{href:t.href,target:`_blank`,rel:`noreferrer`,children:(0,I.jsx)(Xt,{tokens:t.tokens})})}return e.type===`image`?(0,I.jsxs)(`span`,{className:`markdown-image-label`,children:[`[图片:`,e.text,`]`]}):e.type===`html`?null:`text`in e&&typeof e.text==`string`?e.text:null}function Qt(e,t,n){let r=new Map;for(let t of e)r.set(t.name,{name:t.name,kind:`command`,description:t.description});for(let e of t)r.has(e.name)||r.set(e.name,e.description===void 0?{name:e.name,kind:`plugin`}:{name:e.name,kind:`plugin`,description:e.description});for(let e of n)r.has(e.name)||r.set(e.name,{name:e.name,kind:`skill`,description:e.description,source:e.source});return[...r.values()]}function $t(e,t,n){if(n)return 0;let r=[...e];if(r[0]!==`/`)return 0;let i=r.findIndex(e=>/\s/u.test(e)),a=i<0?r.length:i,o=r.slice(1,a).join(``);return t.some(e=>e.name===o)?a:0}function en(e,t,n,r,i=6){let a=[...e],o=Math.max(0,Math.min(a.length,t));if(a[0]!==`/`)return null;let s=a.findIndex(e=>/\s/u.test(e)),c=s<0?a.length:s;if(o<1||o>c)return null;let l=a.slice(1,c).join(``),u=l.toLowerCase(),d=n.filter(({name:e})=>e.toLowerCase().includes(u)).sort((e,t)=>{let n=e.name.toLowerCase().startsWith(u);return n===t.name.toLowerCase().startsWith(u)?e.name.localeCompare(t.name):n?-1:1});if(d.length===0)return null;let f=Math.max(0,Math.min(d.length-1,r)),p=Math.max(1,i);return{query:l,items:d,selectedIndex:f,windowStart:Math.max(0,Math.min(f,d.length-p))}}function tn(e,t,n){return n<=0?0:(e+t+n)%n}function nn(e,t,n){let r=[...e],i=Math.max(0,Math.min(r.length,t)),a=r.slice(i).findIndex(e=>/\s/u.test(e)),o=a<0?r.length:i+a,s=r.slice(o).join(``).replace(/^\s*/u,``),c=`/${n} `;return{text:c+s,cursor:[...c].length}}function rn(e,t,n){if(t<=0)return null;let r=[...e],i=Math.min(r.length,t),a=Math.max(i,Math.min(r.length,n)),o=r.slice(i,a).join(``);return/^\s*$/u.test(o)?{text:r.slice(a).join(``),cursor:0}:null}function an(e,t){if(t.length===0)return[];let n=e.toLowerCase(),r=t.toLowerCase(),i=[],a=0;for(;a<n.length;){let e=n.indexOf(r,a);if(e<0)break;i.push([e,e+r.length]),a=e+r.length}return i}var on={command:`命令`,plugin:`插件`,skill:`技能`},sn={command:`slash-kind-command`,plugin:`slash-kind-plugin`,skill:`slash-kind-skill`};function cn({completion:e,onSelect:t,onDismiss:n}){let r=e.items.slice(e.windowStart,e.windowStart+6);return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`div`,{className:`slash-dropdown-backdrop`,onClick:n}),(0,I.jsxs)(`div`,{className:`slash-dropdown`,role:`listbox`,"aria-label":`命令补全`,children:[(0,I.jsxs)(`div`,{className:`slash-dropdown-header`,children:[(0,I.jsx)(`span`,{children:`可用命令`}),(0,I.jsx)(`kbd`,{children:`↑↓ 选择`}),(0,I.jsx)(`kbd`,{children:`Tab 确认`}),(0,I.jsx)(`kbd`,{children:`Esc 关闭`})]}),(0,I.jsx)(`div`,{className:`slash-dropdown-list`,children:r.map(n=>{let r=e.items.indexOf(n)===e.selectedIndex,i=an(n.name,e.query);return(0,I.jsxs)(`button`,{className:`slash-item${r?` slash-item-selected`:``}`,role:`option`,"aria-selected":r,onMouseDown:e=>{e.preventDefault(),t(n.name)},children:[(0,I.jsx)(`span`,{className:`slash-item-marker`,children:r?`›`:` `}),(0,I.jsx)(`span`,{className:sn[n.kind],children:on[n.kind]}),(0,I.jsx)(`span`,{className:`slash-item-name`,children:ln(n.name,i)}),n.description&&(0,I.jsx)(`span`,{className:`slash-item-desc`,children:n.description})]},n.name)})}),(0,I.jsx)(`div`,{className:`slash-dropdown-footer`,children:e.items.length>6&&(0,I.jsxs)(`span`,{className:`slash-count`,children:[e.selectedIndex+1,` / `,e.items.length]})})]})]})}function ln(e,t){if(t.length===0)return(0,I.jsx)(I.Fragment,{children:e});let n=[],r=0;for(let[i,a]of t)i>r&&n.push((0,I.jsx)(`span`,{children:e.slice(r,i)},`text-${r}`)),n.push((0,I.jsx)(`mark`,{children:e.slice(i,a)},`mark-${i}`)),r=a;return r<e.length&&n.push((0,I.jsx)(`span`,{children:e.slice(r)},`text-${r}`)),(0,I.jsx)(I.Fragment,{children:n})}function un(e,t){if(t.length===0)return(0,I.jsx)(I.Fragment,{children:e});let n=e.toLowerCase(),r=t.toLowerCase(),i=[],a=0;for(;a<n.length;){let e=n.indexOf(r,a);if(e<0)break;i.push([e,e+r.length]),a=e+r.length}if(i.length===0)return(0,I.jsx)(I.Fragment,{children:e});let o=[],s=0;for(let[t,n]of i)t>s&&o.push((0,I.jsx)(`span`,{children:e.slice(s,t)},`text-${s}`)),o.push((0,I.jsx)(`mark`,{children:e.slice(t,n)},`mark-${t}`)),s=n;return s<e.length&&o.push((0,I.jsx)(`span`,{children:e.slice(s)},`text-${s}`)),(0,I.jsx)(I.Fragment,{children:o})}function dn({completion:e,onSelect:t,onDismiss:n}){let r=e.items.slice(e.windowStart,e.windowStart+6);return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`div`,{className:`mention-dropdown-backdrop`,onClick:n}),(0,I.jsxs)(`div`,{className:`mention-dropdown`,role:`listbox`,"aria-label":`文件补全`,children:[(0,I.jsxs)(`div`,{className:`mention-dropdown-header`,children:[(0,I.jsx)(`span`,{children:`项目文件`}),(0,I.jsx)(`kbd`,{children:`↑↓ 选择`}),(0,I.jsx)(`kbd`,{children:`Tab 确认`}),(0,I.jsx)(`kbd`,{children:`Esc 关闭`})]}),(0,I.jsx)(`div`,{className:`mention-dropdown-list`,children:r.map(n=>{let r=e.items.indexOf(n)===e.selectedIndex;return(0,I.jsxs)(`button`,{className:`mention-item${r?` mention-item-selected`:``}`,role:`option`,"aria-selected":r,onMouseDown:e=>{e.preventDefault(),t(n)},children:[(0,I.jsx)(`span`,{className:`mention-item-marker`,children:r?`›`:` `}),(0,I.jsx)(`span`,{className:`mention-item-icon`,children:`📄`}),(0,I.jsx)(`span`,{className:`mention-item-path`,children:un(n,e.query)})]},n)})}),(0,I.jsx)(`div`,{className:`mention-dropdown-footer`,children:e.items.length>6&&(0,I.jsxs)(`span`,{className:`mention-count`,children:[e.selectedIndex+1,` / `,e.items.length]})})]})]})}function fn(e){let t=e.replaceAll(`\\`,`/`),n=t.lastIndexOf(`/`);return n<0?e:t.slice(n+1)}function pn(e){return[...new Set(e.map(e=>e.replaceAll(`\\`,`/`)))].sort(xn)}function mn(e,t,n,r,i=6){let a=_n(e,t);if(a===null)return null;let o=a.query.toLowerCase(),s=n.filter(e=>e.toLowerCase().includes(o)).sort((e,t)=>bn(e,o)-bn(t,o)||xn(e,t));if(s.length===0)return null;let c=Math.max(0,Math.min(s.length-1,r)),l=Math.max(1,i),u=Math.max(0,Math.min(c,s.length-l));return{query:a.query,items:s,selectedIndex:c,windowStart:u}}function hn(e,t,n){return n<=0?0:(e+t+n)%n}function gn(e,t,n){let r=[...e],i=_n(e,t),a=Math.max(0,Math.min(r.length,t));if(i===null)return{text:e,cursor:a};let o=`@${n.replaceAll(`\\`,`/`).replaceAll(` `,`\\ `)} `,s=r.slice(0,i.start).join(``),c=r.slice(i.end).join(``).replace(/^\s*/u,``);return{text:s+o+c,cursor:[...s+o].length,span:{start:[...s].length,end:[...s+o].length}}}function _n(e,t){let n=[...e],r=Math.max(0,Math.min(n.length,t)),i=r;for(;i>0&&!vn(n,i-1);)--i;if(n[i]!==`@`||r<=i)return null;let a=r;for(;a<n.length&&!vn(n,a);)a+=1;return{start:i,end:a,query:yn(n.slice(i+1,a).join(``))}}function vn(e,t){if(!/\s/u.test(e[t]??``))return!1;let n=0;for(let r=t-1;r>=0&&e[r]===`\\`;--r)n+=1;return n%2==0}function yn(e){return e.replace(/\\(\s)/gu,`$1`)}function bn(e,t){let n=e.toLowerCase();return fn(n).startsWith(t)?0:n.startsWith(t)?1:2}function xn(e,t){return e.localeCompare(t,`en`)}var Sn;function L(e,t,n){function r(n,r){if(n._zod||Object.defineProperty(n,"_zod",{value:{def:r,constr:o,traits: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 Cn=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}},wn=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name=`ZodEncodeError`}};(Sn=globalThis).__zod_globalConfig??(Sn.__zod_globalConfig={});var Tn=globalThis.__zod_globalConfig;function En(e){return e&&Object.assign(Tn,e),Tn}function Dn(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 On(e,t){return typeof t==`bigint`?t.toString():t}function kn(e){return{get value(){{let t=e();return Object.defineProperty(this,"value",{value:t}),t}throw Error(`cached value already set`)}}}function An(e){return e==null}function jn(e){let t=+!!e.startsWith(`^`),n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function Mn(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}var Nn=Symbol(`evaluating`);function R(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==Nn)return r===void 0&&(r=Nn,r=n()),r},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function Pn(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function Fn(...e){let t={};for(let n of e){let e=Object.getOwnPropertyDescriptors(n);Object.assign(t,e)}return Object.defineProperties({},t)}function In(e){return JSON.stringify(e)}function Ln(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,``).replace(/[\s_-]+/g,`-`).replace(/^-+|-+$/g,``)}var Rn=`captureStackTrace`in Error?Error.captureStackTrace:(...e)=>{};function zn(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var Bn=kn(()=>{if(Tn.jitless||typeof navigator<`u`&&navigator?.userAgent?.includes(`Cloudflare`))return!1;try{return Function(``),!0}catch{return!1}});function Vn(e){if(zn(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!=`function`)return!0;let n=t.prototype;return!(zn(n)===!1||Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)===!1)}function Hn(e){return Vn(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}var Un=new Set([`string`,`number`,`symbol`]);function Wn(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function Gn(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function z(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 Kn(e){return Object.keys(e).filter(t=>e[t]._zod.optin===`optional`&&e[t]._zod.optout===`optional`)}var qn={safeint:[-(2**53-1),2**53-1],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function Jn(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 Gn(e,Fn(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 Pn(this,`shape`,e),e},checks:[]}))}function Yn(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 Gn(e,Fn(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 Pn(this,`shape`,r),r},checks:[]}))}function Xn(e,t){if(!Vn(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 Gn(e,Fn(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return Pn(this,`shape`,n),n}}))}function Zn(e,t){if(!Vn(t))throw Error(`Invalid input to safeExtend: expected a plain object`);return Gn(e,Fn(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return Pn(this,`shape`,n),n}}))}function Qn(e,t){if(e._zod.def.checks?.length)throw Error(`.merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.`);return Gn(e,Fn(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t._zod.def.shape};return Pn(this,`shape`,n),n},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]}))}function $n(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 Gn(t,Fn(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 Pn(this,`shape`,i),i},checks:[]}))}function er(e,t,n){return Gn(t,Fn(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 Pn(this,`shape`,i),i}}))}function tr(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 nr(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 rr(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function ir(e){return typeof e==`string`?e:e?.message}function ar(e,t,n){let r=e.message?e.message:ir(e.inst?._zod.def?.error?.(e))??ir(t?.error?.(e))??ir(n.customError?.(e))??ir(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 or(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function sr(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}var cr=(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,On,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},lr=L(`$ZodError`,cr),ur=L(`$ZodError`,cr,{Parent:Error});function dr(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 fr(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}var pr=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 Cn;if(o.issues.length){let t=new((i?.Err)??e)(o.issues.map(e=>ar(e,a,En())));throw Rn(t,i?.callee),t}return o.value},mr=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=>ar(e,a,En())));throw Rn(t,i?.callee),t}return o.value},hr=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 Cn;return a.issues.length?{success:!1,error:new(e??lr)(a.issues.map(e=>ar(e,i,En())))}:{success:!0,data:a.value}},gr=hr(ur),_r=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=>ar(e,i,En())))}:{success:!0,data:a.value}},vr=_r(ur),yr=e=>(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return pr(e)(t,n,i)},br=e=>(t,n,r)=>pr(e)(t,n,r),xr=e=>async(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return mr(e)(t,n,i)},Sr=e=>async(t,n,r)=>mr(e)(t,n,r),Cr=e=>(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return hr(e)(t,n,i)},wr=e=>(t,n,r)=>hr(e)(t,n,r),Tr=e=>async(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return _r(e)(t,n,i)},Er=e=>async(t,n,r)=>_r(e)(t,n,r),Dr=/^[cC][0-9a-z]{6,}$/,Or=/^[0-9a-z]+$/,kr=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Ar=/^[0-9a-vA-V]{20}$/,jr=/^[A-Za-z0-9]{27}$/,Mr=/^[a-zA-Z0-9_-]{21}$/,Nr=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Pr=/^([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})$/,Fr=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)$/,Ir=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,Lr=`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;function Rr(){return new RegExp(Lr,`u`)}var zr=/^(?:(?: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])$/,Br=/^(([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}|:))$/,Vr=/^((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])$/,Hr=/^(([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])$/,Ur=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Wr=/^[A-Za-z0-9_-]*$/,Gr=/^https?$/,Kr=/^\+[1-9]\d{6,14}$/,qr=`(?:(?:\\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])))`,Jr=RegExp(`^${qr}$`);function Yr(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 Xr(e){return RegExp(`^${Yr(e)}$`)}function Zr(e){let t=Yr({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(`^${qr}T(?:${r})$`)}var Qr=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??``}}`:`[\\s\\S]*`;return RegExp(`^${t}$`)},$r=/^-?\d+$/,ei=/^-?\d+(?:\.\d+)?$/,ti=/^(?:true|false)$/i,ni=/^[^A-Z]*$/,ri=/^[^a-z]*$/,ii=L(`$ZodCheck`,(e,t)=>{var n;e._zod??={},e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),ai={number:`number`,bigint:`bigint`,object:`date`},oi=L(`$ZodCheckLessThan`,(e,t)=>{ii.init(e,t);let n=ai[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})}}),si=L(`$ZodCheckGreaterThan`,(e,t)=>{ii.init(e,t);let n=ai[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})}}),ci=L(`$ZodCheckMultipleOf`,(e,t)=>{ii.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):Mn(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})}}),li=L(`$ZodCheckNumberFormat`,(e,t)=>{ii.init(e,t),t.format=t.format||`float64`;let n=t.format?.includes(`int`),r=n?`int`:`number`,[i,a]=qn[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=$r)}),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})}}),ui=L(`$ZodCheckMaxLength`,(e,t)=>{var n;ii.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!An(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=or(r);n.issues.push({origin:i,code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),di=L(`$ZodCheckMinLength`,(e,t)=>{var n;ii.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!An(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=or(r);n.issues.push({origin:i,code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),fi=L(`$ZodCheckLengthEquals`,(e,t)=>{var n;ii.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!An(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=or(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})}}),pi=L(`$ZodCheckStringFormat`,(e,t)=>{var n,r;ii.init(e,t),e._zod.onattach.push(e=>{let n=e._zod.bag;n.format=t.format,t.pattern&&(n.patterns??=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=()=>{})}),mi=L(`$ZodCheckRegex`,(e,t)=>{pi.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})}}),hi=L(`$ZodCheckLowerCase`,(e,t)=>{t.pattern??=ni,pi.init(e,t)}),gi=L(`$ZodCheckUpperCase`,(e,t)=>{t.pattern??=ri,pi.init(e,t)}),_i=L(`$ZodCheckIncludes`,(e,t)=>{ii.init(e,t);let n=Wn(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??=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})}}),vi=L(`$ZodCheckStartsWith`,(e,t)=>{ii.init(e,t);let n=RegExp(`^${Wn(t.prefix)}.*`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=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})}}),yi=L(`$ZodCheckEndsWith`,(e,t)=>{ii.init(e,t);let n=RegExp(`.*${Wn(t.suffix)}$`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=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})}}),bi=L(`$ZodCheckOverwrite`,(e,t)=>{ii.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}}),xi=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(`
72
+ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error occurred:</p><pre>`+P(n.message+``,!0)+`</pre>`;return t?Promise.resolve(e):e}if(t)return Promise.reject(n);throw n}}};function F(e,t){return Wt.parse(e,t)}F.options=F.setOptions=function(e){return Wt.setOptions(e),F.defaults=Wt.defaults,De(F.defaults),F},F.getDefaults=Te,F.defaults=Ee,F.use=function(...e){return Wt.use(...e),F.defaults=Wt.defaults,De(F.defaults),F},F.walkTokens=function(e,t){return Wt.walkTokens(e,t)},F.parseInline=Wt.parseInline,F.Parser=Ht,F.parser=Ht.parse,F.Renderer=Bt,F.TextRenderer=Vt,F.Lexer=zt,F.lexer=zt.lex,F.Tokenizer=Rt,F.Hooks=Ut,F.parse=F,F.options,F.setOptions,F.use,F.walkTokens,F.parseInline,Ht.parse,zt.lex;var Gt=o((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.fragment`);function r(e,n,r){var i=null;if(r!==void 0&&(i=``+r),n.key!==void 0&&(i=``+n.key),`key`in n)for(var a in r={},n)a!==`key`&&(r[a]=n[a]);else r=n;return n=r.ref,{$$typeof:t,type:e,key:i,ref:n===void 0?null:n,props:r}}e.Fragment=n,e.jsx=r,e.jsxs=r})),Kt=o(((e,t)=>{t.exports=Gt()})),I=Kt();function qt(e){try{return F.lexer(e,{gfm:!0,async:!1}).filter(e=>e.type!==`html`)}catch{return[{type:`text`,raw:e,text:e}]}}function Jt({text:e}){return(0,I.jsx)(`div`,{className:`markdown-content`,children:(0,_.useMemo)(()=>qt(e),[e]).map((e,t)=>(0,I.jsx)(Yt,{token:e},`${e.type}-${t}`))})}function Yt({token:e}){if(e.type===`space`)return null;if(e.type===`heading`){let t=e;return(0,I.jsx)(`h${Math.min(6,t.depth)}`,{children:(0,I.jsx)(Xt,{tokens:t.tokens})})}if(e.type===`paragraph`)return(0,I.jsx)(`p`,{children:(0,I.jsx)(Xt,{tokens:e.tokens??[]})});if(e.type===`code`){let t=e;return(0,I.jsxs)(`div`,{className:`markdown-code`,children:[(0,I.jsx)(`span`,{children:t.lang?.trim()||`code`}),(0,I.jsx)(`pre`,{children:(0,I.jsx)(`code`,{children:t.text})})]})}if(e.type===`blockquote`)return(0,I.jsx)(`blockquote`,{children:e.tokens.map((e,t)=>(0,I.jsx)(Yt,{token:e},t))});if(e.type===`list`){let t=e;return(0,I.jsx)(t.ordered?`ol`:`ul`,{start:t.ordered&&typeof t.start==`number`?t.start:void 0,children:t.items.map((e,t)=>(0,I.jsx)(`li`,{children:e.tokens.map((e,t)=>(0,I.jsx)(Yt,{token:e},t))},t))})}if(e.type===`hr`)return(0,I.jsx)(`hr`,{});if(e.type===`table`){let t=e;return(0,I.jsx)(`div`,{className:`markdown-table-wrap`,children:(0,I.jsxs)(`table`,{children:[(0,I.jsx)(`thead`,{children:(0,I.jsx)(`tr`,{children:t.header.map((e,t)=>(0,I.jsx)(`th`,{style:{textAlign:e.align??void 0},children:(0,I.jsx)(Xt,{tokens:e.tokens})},t))})}),(0,I.jsx)(`tbody`,{children:t.rows.map((e,n)=>(0,I.jsx)(`tr`,{children:e.map((e,n)=>(0,I.jsx)(`td`,{style:{textAlign:t.align[n]??void 0},children:(0,I.jsx)(Xt,{tokens:e.tokens})},n))},n))})]})})}return`tokens`in e&&Array.isArray(e.tokens)?(0,I.jsx)(`p`,{children:(0,I.jsx)(Xt,{tokens:e.tokens})}):`text`in e&&typeof e.text==`string`?(0,I.jsx)(`p`,{children:e.text}):null}function Xt({tokens:e}){return(0,I.jsx)(I.Fragment,{children:e.map((e,t)=>(0,I.jsx)(Zt,{token:e},t))})}function Zt({token:e}){if(e.type===`text`){let t=e;return t.tokens?.length?(0,I.jsx)(Xt,{tokens:t.tokens}):t.text}if(e.type===`strong`)return(0,I.jsx)(`strong`,{children:(0,I.jsx)(Xt,{tokens:e.tokens})});if(e.type===`em`)return(0,I.jsx)(`em`,{children:(0,I.jsx)(Xt,{tokens:e.tokens})});if(e.type===`del`)return(0,I.jsx)(`del`,{children:(0,I.jsx)(Xt,{tokens:e.tokens})});if(e.type===`codespan`)return(0,I.jsx)(`code`,{children:e.text});if(e.type===`br`)return(0,I.jsx)(`br`,{});if(e.type===`escape`)return e.text;if(e.type===`link`){let t=e;return(0,I.jsx)(`a`,{href:t.href,target:`_blank`,rel:`noreferrer`,children:(0,I.jsx)(Xt,{tokens:t.tokens})})}return e.type===`image`?(0,I.jsxs)(`span`,{className:`markdown-image-label`,children:[`[图片:`,e.text,`]`]}):e.type===`html`?null:`text`in e&&typeof e.text==`string`?e.text:null}function Qt(e,t,n,r=[]){let i=new Map;for(let t of e)i.set(t.name,{name:t.name,kind:`command`,description:t.description});for(let e of t)i.has(e.name)||i.set(e.name,e.description===void 0?{name:e.name,kind:`plugin`}:{name:e.name,kind:`plugin`,description:e.description});for(let e of r)i.has(e.name)||i.set(e.name,e.description===void 0?{name:e.name,kind:`tool`}:{name:e.name,kind:`tool`,description:e.description});for(let e of n)i.has(e.name)||i.set(e.name,{name:e.name,kind:`skill`,description:e.description,source:e.source});return[...i.values()]}function $t(e,t,n){if(n)return 0;let r=[...e];if(r[0]!==`/`)return 0;let i=r.findIndex(e=>/\s/u.test(e)),a=i<0?r.length:i,o=r.slice(1,a).join(``);return t.some(e=>e.name===o)?a:0}function en(e,t,n,r,i=6){let a=[...e],o=Math.max(0,Math.min(a.length,t));if(a[0]!==`/`)return null;let s=a.findIndex(e=>/\s/u.test(e)),c=s<0?a.length:s;if(o<1||o>c)return null;let l=a.slice(1,c).join(``),u=l.toLowerCase(),d=n.filter(({name:e})=>e.toLowerCase().includes(u)).sort((e,t)=>{let n=e.name.toLowerCase().startsWith(u);return n===t.name.toLowerCase().startsWith(u)?e.name.localeCompare(t.name):n?-1:1});if(d.length===0)return null;let f=Math.max(0,Math.min(d.length-1,r)),p=Math.max(1,i);return{query:l,items:d,selectedIndex:f,windowStart:Math.max(0,Math.min(f,d.length-p))}}function tn(e,t,n){return n<=0?0:(e+t+n)%n}function nn(e,t,n){let r=[...e],i=Math.max(0,Math.min(r.length,t)),a=r.slice(i).findIndex(e=>/\s/u.test(e)),o=a<0?r.length:i+a,s=r.slice(o).join(``).replace(/^\s*/u,``),c=`/${n} `;return{text:c+s,cursor:[...c].length}}function rn(e,t,n){if(t<=0)return null;let r=[...e],i=Math.min(r.length,t),a=Math.max(i,Math.min(r.length,n)),o=r.slice(i,a).join(``);return/^\s*$/u.test(o)?{text:r.slice(a).join(``),cursor:0}:null}function an(e,t){if(t.length===0)return[];let n=e.toLowerCase(),r=t.toLowerCase(),i=[],a=0;for(;a<n.length;){let e=n.indexOf(r,a);if(e<0)break;i.push([e,e+r.length]),a=e+r.length}return i}var on={command:`命令`,plugin:`插件`,tool:`工具`,skill:`技能`},sn={command:`slash-kind-command`,plugin:`slash-kind-plugin`,tool:`slash-kind-tool`,skill:`slash-kind-skill`};function cn({completion:e,onSelect:t,onDismiss:n}){let r=e.items.slice(e.windowStart,e.windowStart+6);return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`div`,{className:`slash-dropdown-backdrop`,onClick:n}),(0,I.jsxs)(`div`,{className:`slash-dropdown`,role:`listbox`,"aria-label":`命令补全`,children:[(0,I.jsxs)(`div`,{className:`slash-dropdown-header`,children:[(0,I.jsx)(`span`,{children:`可用命令`}),(0,I.jsx)(`kbd`,{children:`↑↓ 选择`}),(0,I.jsx)(`kbd`,{children:`Tab 确认`}),(0,I.jsx)(`kbd`,{children:`Esc 关闭`})]}),(0,I.jsx)(`div`,{className:`slash-dropdown-list`,children:r.map(n=>{let r=e.items.indexOf(n)===e.selectedIndex,i=an(n.name,e.query);return(0,I.jsxs)(`button`,{className:`slash-item${r?` slash-item-selected`:``}`,role:`option`,"aria-selected":r,onMouseDown:e=>{e.preventDefault(),t(n.name)},children:[(0,I.jsx)(`span`,{className:`slash-item-marker`,children:r?`›`:` `}),(0,I.jsx)(`span`,{className:sn[n.kind],children:on[n.kind]}),(0,I.jsx)(`span`,{className:`slash-item-name`,children:ln(n.name,i)}),n.description&&(0,I.jsx)(`span`,{className:`slash-item-desc`,children:n.description})]},n.name)})}),(0,I.jsx)(`div`,{className:`slash-dropdown-footer`,children:e.items.length>6&&(0,I.jsxs)(`span`,{className:`slash-count`,children:[e.selectedIndex+1,` / `,e.items.length]})})]})]})}function ln(e,t){if(t.length===0)return(0,I.jsx)(I.Fragment,{children:e});let n=[],r=0;for(let[i,a]of t)i>r&&n.push((0,I.jsx)(`span`,{children:e.slice(r,i)},`text-${r}`)),n.push((0,I.jsx)(`mark`,{children:e.slice(i,a)},`mark-${i}`)),r=a;return r<e.length&&n.push((0,I.jsx)(`span`,{children:e.slice(r)},`text-${r}`)),(0,I.jsx)(I.Fragment,{children:n})}function un(e,t){if(t.length===0)return(0,I.jsx)(I.Fragment,{children:e});let n=e.toLowerCase(),r=t.toLowerCase(),i=[],a=0;for(;a<n.length;){let e=n.indexOf(r,a);if(e<0)break;i.push([e,e+r.length]),a=e+r.length}if(i.length===0)return(0,I.jsx)(I.Fragment,{children:e});let o=[],s=0;for(let[t,n]of i)t>s&&o.push((0,I.jsx)(`span`,{children:e.slice(s,t)},`text-${s}`)),o.push((0,I.jsx)(`mark`,{children:e.slice(t,n)},`mark-${t}`)),s=n;return s<e.length&&o.push((0,I.jsx)(`span`,{children:e.slice(s)},`text-${s}`)),(0,I.jsx)(I.Fragment,{children:o})}function dn({completion:e,onSelect:t,onDismiss:n}){let r=e.items.slice(e.windowStart,e.windowStart+6);return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`div`,{className:`mention-dropdown-backdrop`,onClick:n}),(0,I.jsxs)(`div`,{className:`mention-dropdown`,role:`listbox`,"aria-label":`文件补全`,children:[(0,I.jsxs)(`div`,{className:`mention-dropdown-header`,children:[(0,I.jsx)(`span`,{children:`项目文件`}),(0,I.jsx)(`kbd`,{children:`↑↓ 选择`}),(0,I.jsx)(`kbd`,{children:`Tab 确认`}),(0,I.jsx)(`kbd`,{children:`Esc 关闭`})]}),(0,I.jsx)(`div`,{className:`mention-dropdown-list`,children:r.map(n=>{let r=e.items.indexOf(n)===e.selectedIndex;return(0,I.jsxs)(`button`,{className:`mention-item${r?` mention-item-selected`:``}`,role:`option`,"aria-selected":r,onMouseDown:e=>{e.preventDefault(),t(n)},children:[(0,I.jsx)(`span`,{className:`mention-item-marker`,children:r?`›`:` `}),(0,I.jsx)(`span`,{className:`mention-item-icon`,children:`📄`}),(0,I.jsx)(`span`,{className:`mention-item-path`,children:un(n,e.query)})]},n)})}),(0,I.jsx)(`div`,{className:`mention-dropdown-footer`,children:e.items.length>6&&(0,I.jsxs)(`span`,{className:`mention-count`,children:[e.selectedIndex+1,` / `,e.items.length]})})]})]})}function fn(e){let t=e.replaceAll(`\\`,`/`),n=t.lastIndexOf(`/`);return n<0?e:t.slice(n+1)}function pn(e){return[...new Set(e.map(e=>e.replaceAll(`\\`,`/`)))].sort(xn)}function mn(e,t,n,r,i=6){let a=_n(e,t);if(a===null)return null;let o=a.query.toLowerCase(),s=n.filter(e=>e.toLowerCase().includes(o)).sort((e,t)=>bn(e,o)-bn(t,o)||xn(e,t));if(s.length===0)return null;let c=Math.max(0,Math.min(s.length-1,r)),l=Math.max(1,i),u=Math.max(0,Math.min(c,s.length-l));return{query:a.query,items:s,selectedIndex:c,windowStart:u}}function hn(e,t,n){return n<=0?0:(e+t+n)%n}function gn(e,t,n){let r=[...e],i=_n(e,t),a=Math.max(0,Math.min(r.length,t));if(i===null)return{text:e,cursor:a};let o=`@${n.replaceAll(`\\`,`/`).replaceAll(` `,`\\ `)} `,s=r.slice(0,i.start).join(``),c=r.slice(i.end).join(``).replace(/^\s*/u,``);return{text:s+o+c,cursor:[...s+o].length,span:{start:[...s].length,end:[...s+o].length}}}function _n(e,t){let n=[...e],r=Math.max(0,Math.min(n.length,t)),i=r;for(;i>0&&!vn(n,i-1);)--i;if(n[i]!==`@`||r<=i)return null;let a=r;for(;a<n.length&&!vn(n,a);)a+=1;return{start:i,end:a,query:yn(n.slice(i+1,a).join(``))}}function vn(e,t){if(!/\s/u.test(e[t]??``))return!1;let n=0;for(let r=t-1;r>=0&&e[r]===`\\`;--r)n+=1;return n%2==0}function yn(e){return e.replace(/\\(\s)/gu,`$1`)}function bn(e,t){let n=e.toLowerCase();return fn(n).startsWith(t)?0:n.startsWith(t)?1:2}function xn(e,t){return e.localeCompare(t,`en`)}var Sn;function L(e,t,n){function r(n,r){if(n._zod||Object.defineProperty(n,"_zod",{value:{def:r,constr:o,traits: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 Cn=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}},wn=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name=`ZodEncodeError`}};(Sn=globalThis).__zod_globalConfig??(Sn.__zod_globalConfig={});var Tn=globalThis.__zod_globalConfig;function En(e){return e&&Object.assign(Tn,e),Tn}function Dn(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 On(e,t){return typeof t==`bigint`?t.toString():t}function kn(e){return{get value(){{let t=e();return Object.defineProperty(this,"value",{value:t}),t}throw Error(`cached value already set`)}}}function An(e){return e==null}function jn(e){let t=+!!e.startsWith(`^`),n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function Mn(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}var Nn=Symbol(`evaluating`);function R(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==Nn)return r===void 0&&(r=Nn,r=n()),r},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function Pn(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function Fn(...e){let t={};for(let n of e){let e=Object.getOwnPropertyDescriptors(n);Object.assign(t,e)}return Object.defineProperties({},t)}function In(e){return JSON.stringify(e)}function Ln(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,``).replace(/[\s_-]+/g,`-`).replace(/^-+|-+$/g,``)}var Rn=`captureStackTrace`in Error?Error.captureStackTrace:(...e)=>{};function zn(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var Bn=kn(()=>{if(Tn.jitless||typeof navigator<`u`&&navigator?.userAgent?.includes(`Cloudflare`))return!1;try{return Function(``),!0}catch{return!1}});function Vn(e){if(zn(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!=`function`)return!0;let n=t.prototype;return!(zn(n)===!1||Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)===!1)}function Hn(e){return Vn(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}var Un=new Set([`string`,`number`,`symbol`]);function Wn(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function Gn(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function z(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 Kn(e){return Object.keys(e).filter(t=>e[t]._zod.optin===`optional`&&e[t]._zod.optout===`optional`)}var qn={safeint:[-(2**53-1),2**53-1],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function Jn(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 Gn(e,Fn(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 Pn(this,`shape`,e),e},checks:[]}))}function Yn(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 Gn(e,Fn(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 Pn(this,`shape`,r),r},checks:[]}))}function Xn(e,t){if(!Vn(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 Gn(e,Fn(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return Pn(this,`shape`,n),n}}))}function Zn(e,t){if(!Vn(t))throw Error(`Invalid input to safeExtend: expected a plain object`);return Gn(e,Fn(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return Pn(this,`shape`,n),n}}))}function Qn(e,t){if(e._zod.def.checks?.length)throw Error(`.merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.`);return Gn(e,Fn(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t._zod.def.shape};return Pn(this,`shape`,n),n},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]}))}function $n(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 Gn(t,Fn(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 Pn(this,`shape`,i),i},checks:[]}))}function er(e,t,n){return Gn(t,Fn(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 Pn(this,`shape`,i),i}}))}function tr(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 nr(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 rr(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function ir(e){return typeof e==`string`?e:e?.message}function ar(e,t,n){let r=e.message?e.message:ir(e.inst?._zod.def?.error?.(e))??ir(t?.error?.(e))??ir(n.customError?.(e))??ir(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 or(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function sr(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}var cr=(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,On,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},lr=L(`$ZodError`,cr),ur=L(`$ZodError`,cr,{Parent:Error});function dr(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 fr(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}var pr=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 Cn;if(o.issues.length){let t=new((i?.Err)??e)(o.issues.map(e=>ar(e,a,En())));throw Rn(t,i?.callee),t}return o.value},mr=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=>ar(e,a,En())));throw Rn(t,i?.callee),t}return o.value},hr=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 Cn;return a.issues.length?{success:!1,error:new(e??lr)(a.issues.map(e=>ar(e,i,En())))}:{success:!0,data:a.value}},gr=hr(ur),_r=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=>ar(e,i,En())))}:{success:!0,data:a.value}},vr=_r(ur),yr=e=>(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return pr(e)(t,n,i)},br=e=>(t,n,r)=>pr(e)(t,n,r),xr=e=>async(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return mr(e)(t,n,i)},Sr=e=>async(t,n,r)=>mr(e)(t,n,r),Cr=e=>(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return hr(e)(t,n,i)},wr=e=>(t,n,r)=>hr(e)(t,n,r),Tr=e=>async(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return _r(e)(t,n,i)},Er=e=>async(t,n,r)=>_r(e)(t,n,r),Dr=/^[cC][0-9a-z]{6,}$/,Or=/^[0-9a-z]+$/,kr=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Ar=/^[0-9a-vA-V]{20}$/,jr=/^[A-Za-z0-9]{27}$/,Mr=/^[a-zA-Z0-9_-]{21}$/,Nr=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Pr=/^([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})$/,Fr=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)$/,Ir=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,Lr=`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;function Rr(){return new RegExp(Lr,`u`)}var zr=/^(?:(?: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])$/,Br=/^(([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}|:))$/,Vr=/^((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])$/,Hr=/^(([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])$/,Ur=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Wr=/^[A-Za-z0-9_-]*$/,Gr=/^https?$/,Kr=/^\+[1-9]\d{6,14}$/,qr=`(?:(?:\\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])))`,Jr=RegExp(`^${qr}$`);function Yr(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 Xr(e){return RegExp(`^${Yr(e)}$`)}function Zr(e){let t=Yr({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(`^${qr}T(?:${r})$`)}var Qr=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??``}}`:`[\\s\\S]*`;return RegExp(`^${t}$`)},$r=/^-?\d+$/,ei=/^-?\d+(?:\.\d+)?$/,ti=/^(?:true|false)$/i,ni=/^[^A-Z]*$/,ri=/^[^a-z]*$/,ii=L(`$ZodCheck`,(e,t)=>{var n;e._zod??={},e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),ai={number:`number`,bigint:`bigint`,object:`date`},oi=L(`$ZodCheckLessThan`,(e,t)=>{ii.init(e,t);let n=ai[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})}}),si=L(`$ZodCheckGreaterThan`,(e,t)=>{ii.init(e,t);let n=ai[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})}}),ci=L(`$ZodCheckMultipleOf`,(e,t)=>{ii.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):Mn(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})}}),li=L(`$ZodCheckNumberFormat`,(e,t)=>{ii.init(e,t),t.format=t.format||`float64`;let n=t.format?.includes(`int`),r=n?`int`:`number`,[i,a]=qn[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=$r)}),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})}}),ui=L(`$ZodCheckMaxLength`,(e,t)=>{var n;ii.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!An(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=or(r);n.issues.push({origin:i,code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),di=L(`$ZodCheckMinLength`,(e,t)=>{var n;ii.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!An(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=or(r);n.issues.push({origin:i,code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),fi=L(`$ZodCheckLengthEquals`,(e,t)=>{var n;ii.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!An(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=or(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})}}),pi=L(`$ZodCheckStringFormat`,(e,t)=>{var n,r;ii.init(e,t),e._zod.onattach.push(e=>{let n=e._zod.bag;n.format=t.format,t.pattern&&(n.patterns??=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=()=>{})}),mi=L(`$ZodCheckRegex`,(e,t)=>{pi.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})}}),hi=L(`$ZodCheckLowerCase`,(e,t)=>{t.pattern??=ni,pi.init(e,t)}),gi=L(`$ZodCheckUpperCase`,(e,t)=>{t.pattern??=ri,pi.init(e,t)}),_i=L(`$ZodCheckIncludes`,(e,t)=>{ii.init(e,t);let n=Wn(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??=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})}}),vi=L(`$ZodCheckStartsWith`,(e,t)=>{ii.init(e,t);let n=RegExp(`^${Wn(t.prefix)}.*`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=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})}}),yi=L(`$ZodCheckEndsWith`,(e,t)=>{ii.init(e,t);let n=RegExp(`.*${Wn(t.suffix)}$`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=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})}}),bi=L(`$ZodCheckOverwrite`,(e,t)=>{ii.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}}),xi=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(`
73
73
  `).filter(e=>e),n=Math.min(...t.map(e=>e.length-e.trimStart().length)),r=t.map(e=>e.slice(n)).map(e=>` `.repeat(this.indent*2)+e);for(let e of r)this.content.push(e)}compile(){let e=Function,t=this?.args,n=[...(this?.content??[``]).map(e=>` ${e}`)];return new e(...t,n.join(`
74
74
  `))}},Si={major:4,minor:4,patch:3},B=L(`$ZodType`,(e,t)=>{var n;e??={},e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Si;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=tr(e),i;for(let a of t){if(a._zod.def.when){if(nr(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 Cn;if(i||o instanceof Promise)i=(i??Promise.resolve()).then(async()=>{await o,e.issues.length!==t&&(r||=tr(e,t))});else{if(e.issues.length===t)continue;r||=tr(e,t)}}return i?i.then(()=>e):e},n=(n,i,a)=>{if(tr(n))return n.aborted=!0,n;let o=t(i,r,a);if(o instanceof Promise){if(a.async===!1)throw new Cn;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 Cn;return o.then(e=>t(e,r,a))}return t(o,r,a)}}R(e,`~standard`,()=>({validate:t=>{try{let n=gr(e,t);return n.success?{value:n.data}:{issues:n.error?.issues}}catch{return vr(e,t).then(e=>e.success?{value:e.data}:{issues:e.error?.issues})}},vendor:`zod`,version:1}))}),Ci=L(`$ZodString`,(e,t)=>{B.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??Qr(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}}),V=L(`$ZodStringFormat`,(e,t)=>{pi.init(e,t),Ci.init(e,t)}),wi=L(`$ZodGUID`,(e,t)=>{t.pattern??=Pr,V.init(e,t)}),Ti=L(`$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??=Fr(e)}else t.pattern??=Fr();V.init(e,t)}),Ei=L(`$ZodEmail`,(e,t)=>{t.pattern??=Ir,V.init(e,t)}),Di=L(`$ZodURL`,(e,t)=>{V.init(e,t),e._zod.check=n=>{try{let r=n.value.trim();if(!t.normalize&&t.protocol?.source===Gr.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})),t.normalize?n.value=i.href:n.value=r;return}catch{n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort})}}}),Oi=L(`$ZodEmoji`,(e,t)=>{t.pattern??=Rr(),V.init(e,t)}),ki=L(`$ZodNanoID`,(e,t)=>{t.pattern??=Mr,V.init(e,t)}),Ai=L(`$ZodCUID`,(e,t)=>{t.pattern??=Dr,V.init(e,t)}),ji=L(`$ZodCUID2`,(e,t)=>{t.pattern??=Or,V.init(e,t)}),H=L(`$ZodULID`,(e,t)=>{t.pattern??=kr,V.init(e,t)}),Mi=L(`$ZodXID`,(e,t)=>{t.pattern??=Ar,V.init(e,t)}),Ni=L(`$ZodKSUID`,(e,t)=>{t.pattern??=jr,V.init(e,t)}),Pi=L(`$ZodISODateTime`,(e,t)=>{t.pattern??=Zr(t),V.init(e,t)}),Fi=L(`$ZodISODate`,(e,t)=>{t.pattern??=Jr,V.init(e,t)}),Ii=L(`$ZodISOTime`,(e,t)=>{t.pattern??=Xr(t),V.init(e,t)}),Li=L(`$ZodISODuration`,(e,t)=>{t.pattern??=Nr,V.init(e,t)}),Ri=L(`$ZodIPv4`,(e,t)=>{t.pattern??=zr,V.init(e,t),e._zod.bag.format=`ipv4`}),zi=L(`$ZodIPv6`,(e,t)=>{t.pattern??=Br,V.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})}}}),Bi=L(`$ZodCIDRv4`,(e,t)=>{t.pattern??=Vr,V.init(e,t)}),Vi=L(`$ZodCIDRv6`,(e,t)=>{t.pattern??=Hr,V.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 Hi(e){if(e===``)return!0;if(/\s/.test(e)||e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}var Ui=L(`$ZodBase64`,(e,t)=>{t.pattern??=Ur,V.init(e,t),e._zod.bag.contentEncoding=`base64`,e._zod.check=n=>{Hi(n.value)||n.issues.push({code:`invalid_format`,format:`base64`,input:n.value,inst:e,continue:!t.abort})}});function Wi(e){if(!Wr.test(e))return!1;let t=e.replace(/[-_]/g,e=>e===`-`?`+`:`/`);return Hi(t.padEnd(Math.ceil(t.length/4)*4,`=`))}var Gi=L(`$ZodBase64URL`,(e,t)=>{t.pattern??=Wr,V.init(e,t),e._zod.bag.contentEncoding=`base64url`,e._zod.check=n=>{Wi(n.value)||n.issues.push({code:`invalid_format`,format:`base64url`,input:n.value,inst:e,continue:!t.abort})}}),Ki=L(`$ZodE164`,(e,t)=>{t.pattern??=Kr,V.init(e,t)});function qi(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}}var Ji=L(`$ZodJWT`,(e,t)=>{V.init(e,t),e._zod.check=n=>{qi(n.value,t.alg)||n.issues.push({code:`invalid_format`,format:`jwt`,input:n.value,inst:e,continue:!t.abort})}}),Yi=L(`$ZodNumber`,(e,t)=>{B.init(e,t),e._zod.pattern=e._zod.bag.pattern??ei,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}}),Xi=L(`$ZodNumberFormat`,(e,t)=>{li.init(e,t),Yi.init(e,t)}),Zi=L(`$ZodBoolean`,(e,t)=>{B.init(e,t),e._zod.pattern=ti,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}}),Qi=L(`$ZodUnknown`,(e,t)=>{B.init(e,t),e._zod.parse=e=>e}),$i=L(`$ZodNever`,(e,t)=>{B.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:`never`,code:`invalid_type`,input:t.value,inst:e}),t)});function ea(e,t,n){e.issues.length&&t.issues.push(...rr(n,e.issues)),t.value[n]=e.value}var ta=L(`$ZodArray`,(e,t)=>{B.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=>ea(t,n,e))):ea(s,n,e)}return a.length?Promise.all(a).then(()=>n):n}});function na(e,t,n,r,i,a){let o=n in r;if(e.issues.length){if(i&&a&&!o)return;t.issues.push(...rr(n,e.issues))}if(!o&&!i){e.issues.length||t.issues.push({code:`invalid_type`,expected:`nonoptional`,input:void 0,path:[n]});return}e.value===void 0?o&&(t.value[n]=void 0):t.value[n]=e.value}function ra(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=Kn(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function ia(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=>na(e,n,i,t,u,d))):na(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}var aa=L(`$ZodObject`,(e,t)=>{if(B.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=kn(()=>ra(t));R(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]=new Set);for(let e of r.values)n[t].add(e)}}return n});let r=zn,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=>na(n,t,e,s,r,i))):na(a,t,e,s,r,i)}return i?ia(c,s,t,o,n.value,e):c.length?Promise.all(c).then(()=>t):t}}),oa=L(`$ZodObjectJIT`,(e,t)=>{aa.init(e,t);let n=e._zod.parse,r=kn(()=>ra(t)),i=e=>{let t=new xi([`shape`,`payload`,`ctx`]),n=r.value,i=e=>{let t=In(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=In(r),s=e[r],c=s?._zod?.optin===`optional`,l=s?._zod?.optout===`optional`;t.write(`const ${n} = ${i(r)};`),c&&l?t.write(`
75
75
  if (${n}.issues.length) {
@@ -132,7 +132,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
132
132
 
133
133
  `)}t.write(`payload.value = newResult;`),t.write(`return payload;`);let s=t.compile();return(t,n)=>s(e,t,n)},a,o=zn,s=!Tn.jitless,c=s&&Bn.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?ia([],p,d,f,u,e):d):n(d,f):(d.issues.push({expected:`object`,code:`invalid_type`,input:p,inst:e}),d)}});function sa(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=>!tr(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=>ar(e,r,En())))}),t)}var ca=L(`$ZodUnion`,(e,t)=>{B.init(e,t),R(e._zod,`optin`,()=>t.options.some(e=>e._zod.optin===`optional`)?`optional`:void 0),R(e._zod,`optout`,()=>t.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),R(e._zod,`values`,()=>{if(t.options.every(e=>e._zod.values))return new Set(t.options.flatMap(e=>Array.from(e._zod.values)))}),R(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=>jn(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=>sa(t,r,e,i)):sa(o,r,e,i)}}),la=L(`$ZodDiscriminatedUnion`,(e,t)=>{t.inclusive=!1,ca.init(e,t);let n=e._zod.parse;R(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]=new Set);for(let r of n)e[t].add(r)}}return e});let r=kn(()=>{let e=t.options,n=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(!zn(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)}}),ua=L(`$ZodIntersection`,(e,t)=>{B.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])=>fa(e,t,n)):fa(e,i,a)}});function da(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(Vn(e)&&Vn(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=da(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=da(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 fa(e,t,n){let r=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}),tr(e))return e;let o=da(t.value,n.value);if(!o.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(o.mergeErrorPath)}`);return e.value=o.data,e}var pa=L(`$ZodRecord`,(e,t)=>{B.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!Vn(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=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=>ar(e,r,En())),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(...rr(c,e.issues)),n.value[l]=e.value})):(u.issues.length&&n.issues.push(...rr(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`&&ei.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=>ar(e,r,En())),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(...rr(o,e.issues)),n.value[s.value]=e.value})):(c.issues.length&&n.issues.push(...rr(o,c.issues)),n.value[s.value]=c.value)}}return a.length?Promise.all(a).then(()=>n):n}}),ma=L(`$ZodEnum`,(e,t)=>{B.init(e,t);let n=Dn(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=RegExp(`^(${n.filter(e=>Un.has(typeof e)).map(e=>typeof e==`string`?Wn(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}}),ha=L(`$ZodLiteral`,(e,t)=>{if(B.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`?Wn(e):e?Wn(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}}),ga=L(`$ZodTransform`,(e,t)=>{B.init(e,t),e._zod.optin=`optional`,e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new wn(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 Cn;return n.value=i,n.fallback=!0,n}});function _a(e,t){return t===void 0&&(e.issues.length||e.fallback)?{issues:[],value:void 0}:e}var va=L(`$ZodOptional`,(e,t)=>{B.init(e,t),e._zod.optin=`optional`,e._zod.optout=`optional`,R(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),R(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${jn(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=>_a(e,r)):_a(i,r)}return e.value===void 0?e:t.innerType._zod.run(e,n)}}),ya=L(`$ZodExactOptional`,(e,t)=>{va.init(e,t),R(e._zod,`values`,()=>t.innerType._zod.values),R(e._zod,`pattern`,()=>t.innerType._zod.pattern),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),ba=L(`$ZodNullable`,(e,t)=>{B.init(e,t),R(e._zod,`optin`,()=>t.innerType._zod.optin),R(e._zod,`optout`,()=>t.innerType._zod.optout),R(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${jn(e.source)}|null)$`):void 0}),R(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>e.value===null?e:t.innerType._zod.run(e,n)}),xa=L(`$ZodDefault`,(e,t)=>{B.init(e,t),e._zod.optin=`optional`,R(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=>Sa(e,t)):Sa(r,t)}});function Sa(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var Ca=L(`$ZodPrefault`,(e,t)=>{B.init(e,t),e._zod.optin=`optional`,R(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))}),wa=L(`$ZodNonOptional`,(e,t)=>{B.init(e,t),R(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=>Ta(t,e)):Ta(i,e)}});function Ta(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:`invalid_type`,expected:`nonoptional`,input:e.value,inst:t}),e}var Ea=L(`$ZodCatch`,(e,t)=>{B.init(e,t),e._zod.optin=`optional`,R(e._zod,`optout`,()=>t.innerType._zod.optout),R(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=>ar(e,n,En()))},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=>ar(e,n,En()))},input:e.value}),e.issues=[],e.fallback=!0),e)}}),Da=L(`$ZodPipe`,(e,t)=>{B.init(e,t),R(e._zod,`values`,()=>t.in._zod.values),R(e._zod,`optin`,()=>t.in._zod.optin),R(e._zod,`optout`,()=>t.out._zod.optout),R(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=>Oa(e,t.in,n)):Oa(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>Oa(e,t.out,n)):Oa(r,t.out,n)}});function Oa(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues,fallback:e.fallback},n)}var ka=L(`$ZodPreprocess`,(e,t)=>{Da.init(e,t)}),Aa=L(`$ZodReadonly`,(e,t)=>{B.init(e,t),R(e._zod,`propValues`,()=>t.innerType._zod.propValues),R(e._zod,`values`,()=>t.innerType._zod.values),R(e._zod,`optin`,()=>t.innerType?._zod?.optin),R(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(ja):ja(r)}});function ja(e){return e.value=Object.freeze(e.value),e}var Ma=L(`$ZodCustom`,(e,t)=>{ii.init(e,t),B.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=>Na(t,n,r,e));Na(i,n,r,e)}});function Na(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(sr(e))}}var Pa,Fa=class{constructor(){this._map=new WeakMap,this._idmap=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=new WeakMap,this._idmap=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 Ia(){return new Fa}(Pa=globalThis).__zod_globalRegistry??(Pa.__zod_globalRegistry=Ia());var La=globalThis.__zod_globalRegistry;function Ra(e,t){return new e({type:`string`,...z(t)})}function za(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...z(t)})}function Ba(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...z(t)})}function Va(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...z(t)})}function Ha(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...z(t)})}function Ua(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...z(t)})}function Wa(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...z(t)})}function Ga(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...z(t)})}function Ka(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...z(t)})}function qa(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...z(t)})}function Ja(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...z(t)})}function Ya(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...z(t)})}function Xa(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...z(t)})}function Za(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...z(t)})}function Qa(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...z(t)})}function $a(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...z(t)})}function eo(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...z(t)})}function to(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...z(t)})}function no(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...z(t)})}function ro(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...z(t)})}function io(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...z(t)})}function ao(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...z(t)})}function oo(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...z(t)})}function so(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...z(t)})}function co(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...z(t)})}function lo(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...z(t)})}function U(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...z(t)})}function uo(e,t){return new e({type:`number`,checks:[],...z(t)})}function fo(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...z(t)})}function po(e,t){return new e({type:`boolean`,...z(t)})}function mo(e){return new e({type:`unknown`})}function ho(e,t){return new e({type:`never`,...z(t)})}function go(e,t){return new oi({check:`less_than`,...z(t),value:e,inclusive:!1})}function _o(e,t){return new oi({check:`less_than`,...z(t),value:e,inclusive:!0})}function vo(e,t){return new si({check:`greater_than`,...z(t),value:e,inclusive:!1})}function yo(e,t){return new si({check:`greater_than`,...z(t),value:e,inclusive:!0})}function bo(e,t){return new ci({check:`multiple_of`,...z(t),value:e})}function xo(e,t){return new ui({check:`max_length`,...z(t),maximum:e})}function So(e,t){return new di({check:`min_length`,...z(t),minimum:e})}function Co(e,t){return new fi({check:`length_equals`,...z(t),length:e})}function wo(e,t){return new mi({check:`string_format`,format:`regex`,...z(t),pattern:e})}function To(e){return new hi({check:`string_format`,format:`lowercase`,...z(e)})}function Eo(e){return new gi({check:`string_format`,format:`uppercase`,...z(e)})}function Do(e,t){return new _i({check:`string_format`,format:`includes`,...z(t),includes:e})}function Oo(e,t){return new vi({check:`string_format`,format:`starts_with`,...z(t),prefix:e})}function ko(e,t){return new yi({check:`string_format`,format:`ends_with`,...z(t),suffix:e})}function Ao(e){return new bi({check:`overwrite`,tx:e})}function jo(e){return Ao(t=>t.normalize(e))}function Mo(){return Ao(e=>e.trim())}function No(){return Ao(e=>e.toLowerCase())}function Po(){return Ao(e=>e.toUpperCase())}function Fo(){return Ao(e=>Ln(e))}function Io(e,t,n){return new e({type:`array`,element:t,...z(n)})}function Lo(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...z(n)})}function Ro(e,t){let n=zo(t=>(t.addIssue=e=>{if(typeof e==`string`)t.issues.push(sr(e,t.value,n._zod.def));else{let r=e;r.fatal&&(r.continue=!1),r.code??=`custom`,r.input??=t.value,r.inst??=n,r.continue??=!n._zod.def.abort,t.issues.push(sr(r))}},e(t.value,t)),t);return n}function zo(e,t){let n=new ii({check:`custom`,...z(t)});return n._zod.check=e,n}function Bo(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??La,target:t,unrepresentable:e?.unrepresentable??`throw`,override:e?.override??(()=>{}),io:e?.io??`output`,counter:0,seen:new Map,cycles:e?.cycles??`ref`,reused:e?.reused??`inline`,external:e?.external??void 0}}function Vo(e,t,n={path:[],schemaPath:[]}){var r;let i=e._zod.def,a=t.seen.get(e);if(a)return a.count++,n.schemaPath.includes(e)&&(a.cycle=n.path),a.schema;let o={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,o);let s=e._zod.toJSONSchema?.();if(s)o.schema=s;else{let r={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,r);else{let n=o.schema,a=t.processors[i.type];if(!a)throw Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);a(e,t,n,r)}let a=e._zod.parent;a&&(o.ref||=a,Vo(a,t,r),t.seen.get(a).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&Object.assign(o.schema,c),t.io===`input`&&Wo(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 Ho(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=new Map;for(let t of e.seen.entries()){let n=e.metadataRegistry.get(t[0])?.id;if(n){let e=r.get(n);if(e&&e!==t[0])throw Error(`Duplicate schema id "${n}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(n,t[0])}}let i=t=>{let r=e.target===`draft-2020-12`?`$defs`:`definitions`;if(e.external){let n=e.external.registry.get(t[0])?.id,i=e.external.uri??(e=>e);if(n)return{ref:i(n)};let a=t[1].defId??t[1].schema.id??`schema${e.counter++}`;return t[1].defId=a,{defId:a,ref:`${i(`__shared`)}#/${r}/${a}`}}if(t[1]===n)return{ref:`#`};let i=`#/${r}/`,a=t[1].schema.id??`__schema${e.counter++}`;return{defId:a,ref:i+a}},a=e=>{if(e[1].schema.$ref)return;let t=e[1],{ref:n,defId:r}=i(e);t.def={...t.schema},r&&(t.defId=r);let a=t.schema;for(let e in a)delete a[e];a.$ref=n};if(e.cycles===`throw`)for(let t of e.seen.entries()){let e=t[1];if(e.cycle)throw Error(`Cycle detected: #/${e.cycle?.join(`/`)}/<root>
134
134
 
135
- 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);continue}if(e.external){let r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){a(n);continue}}if(e.metadataRegistry.get(n[0])?.id){a(n);continue}if(r.cycle){a(n);continue}if(r.count>1&&e.reused===`ref`){a(n);continue}}}function Uo(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:Ko(t,`input`,e.processors),output:Ko(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function Wo(e,t){let n=t??{seen: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 Wo(r.element,n);if(r.type===`set`)return Wo(r.valueType,n);if(r.type===`lazy`)return Wo(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 Wo(r.innerType,n);if(r.type===`intersection`)return Wo(r.left,n)||Wo(r.right,n);if(r.type===`record`||r.type===`map`)return Wo(r.keyType,n)||Wo(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:Wo(r.in,n)||Wo(r.out,n);if(r.type===`object`){for(let e in r.shape)if(Wo(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(Wo(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(Wo(e,n))return!0;return!!(r.rest&&Wo(r.rest,n))}return!1}var Go=(e,t={})=>n=>{let r=Bo({...n,processors:t});return Vo(e,r),Ho(r,e),Uo(r,e)},Ko=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=Bo({...i??{},target:a,io:t,processors:n});return Vo(e,o),Ho(o,e),Uo(o,e)},qo={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},Jo=(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=qo[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}))])}},Yo=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,format:s,multipleOf:c,exclusiveMaximum:l,exclusiveMinimum:u}=e._zod.bag;typeof s==`string`&&s.includes(`int`)?i.type=`integer`:i.type=`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)},Xo=(e,t,n,r)=>{n.type=`boolean`},Zo=(e,t,n,r)=>{n.not={}},Qo=(e,t,n,r)=>{let i=e._zod.def,a=Dn(i.entries);a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a},$o=(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},es=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Custom types cannot be represented in JSON Schema`)},ts=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Transforms cannot be represented in JSON Schema`)},ns=(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=Vo(a.element,t,{...r,path:[...r.path,`items`]})},rs=(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]=Vo(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=Vo(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},is=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>Vo(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},as=(e,t,n,r)=>{let i=e._zod.def,a=Vo(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=Vo(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]]},os=(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=Vo(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=Vo(a.keyType,t,{...r,path:[...r.path,`propertyNames`]})),i.additionalProperties=Vo(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)}},ss=(e,t,n,r)=>{let i=e._zod.def,a=Vo(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`}]},cs=(e,t,n,r)=>{let i=e._zod.def;Vo(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},ls=(e,t,n,r)=>{let i=e._zod.def;Vo(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.default=JSON.parse(JSON.stringify(i.defaultValue))},us=(e,t,n,r)=>{let i=e._zod.def;Vo(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)))},ds=(e,t,n,r)=>{let i=e._zod.def;Vo(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},fs=(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;Vo(o,t,r);let s=t.seen.get(e);s.ref=o},ps=(e,t,n,r)=>{let i=e._zod.def;Vo(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},ms=(e,t,n,r)=>{let i=e._zod.def;Vo(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},hs=L(`ZodISODateTime`,(e,t)=>{Pi.init(e,t),Vs.init(e,t)});function gs(e){return so(hs,e)}var _s=L(`ZodISODate`,(e,t)=>{Fi.init(e,t),Vs.init(e,t)});function vs(e){return co(_s,e)}var ys=L(`ZodISOTime`,(e,t)=>{Ii.init(e,t),Vs.init(e,t)});function bs(e){return lo(ys,e)}var xs=L(`ZodISODuration`,(e,t)=>{Li.init(e,t),Vs.init(e,t)});function Ss(e){return U(xs,e)}var Cs=L(`ZodError`,(e,t)=>{lr.init(e,t),e.name=`ZodError`,Object.defineProperties(e,{format:{value:t=>fr(e,t)},flatten:{value:t=>dr(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,On,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,On,2)}},isEmpty:{get(){return e.issues.length===0}}})},{Parent:Error}),ws=pr(Cs),Ts=mr(Cs),Es=hr(Cs),Ds=_r(Cs),Os=yr(Cs),ks=br(Cs),As=xr(Cs),js=Sr(Cs),Ms=Cr(Cs),Ns=wr(Cs),Ps=Tr(Cs),Fs=Er(Cs),Is=new WeakMap;function Ls(e,t,n){let r=Object.getPrototypeOf(e),i=Is.get(r);if(i||(i=new Set,Is.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})}})}}}var Rs=L(`ZodType`,(e,t)=>(B.init(e,t),Object.assign(e[`~standard`],{jsonSchema:{input:Ko(e,`input`),output:Ko(e,`output`)}}),e.toJSONSchema=Go(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(t,n)=>ws(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>Es(e,t,n),e.parseAsync=async(t,n)=>Ts(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>Ds(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>Os(e,t,n),e.decode=(t,n)=>ks(e,t,n),e.encodeAsync=async(t,n)=>As(e,t,n),e.decodeAsync=async(t,n)=>js(e,t,n),e.safeEncode=(t,n)=>Ms(e,t,n),e.safeDecode=(t,n)=>Ns(e,t,n),e.safeEncodeAsync=async(t,n)=>Ps(e,t,n),e.safeDecodeAsync=async(t,n)=>Fs(e,t,n),Ls(e,`ZodType`,{check(...e){let t=this.def;return this.clone(Fn(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 Gn(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(el(e,t))},superRefine(e,t){return this.check(tl(e,t))},overwrite(e){return this.check(Ao(e))},optional(){return Fc(this)},exactOptional(){return Lc(this)},nullable(){return zc(this)},nullish(){return Fc(zc(this))},nonoptional(e){return Gc(this,e)},array(){return vc(this)},or(e){return xc([this,e])},and(e){return Tc(this,e)},transform(e){return Yc(this,Nc(e))},default(e){return Vc(this,e)},prefault(e){return Uc(this,e)},catch(e){return qc(this,e)},pipe(e){return Yc(this,e)},readonly(){return Qc(this)},describe(e){let t=this.clone();return La.add(t,{description:e}),t},meta(...e){if(e.length===0)return La.get(this);let t=this.clone();return La.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 La.get(e)?.description},configurable:!0}),e)),zs=L(`_ZodString`,(e,t)=>{Ci.init(e,t),Rs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Jo(e,t,n,r);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,Ls(e,`_ZodString`,{regex(...e){return this.check(wo(...e))},includes(...e){return this.check(Do(...e))},startsWith(...e){return this.check(Oo(...e))},endsWith(...e){return this.check(ko(...e))},min(...e){return this.check(So(...e))},max(...e){return this.check(xo(...e))},length(...e){return this.check(Co(...e))},nonempty(...e){return this.check(So(1,...e))},lowercase(e){return this.check(To(e))},uppercase(e){return this.check(Eo(e))},trim(){return this.check(Mo())},normalize(...e){return this.check(jo(...e))},toLowerCase(){return this.check(No())},toUpperCase(){return this.check(Po())},slugify(){return this.check(Fo())}})}),Bs=L(`ZodString`,(e,t)=>{Ci.init(e,t),zs.init(e,t),e.email=t=>e.check(za(Hs,t)),e.url=t=>e.check(Ga(Ks,t)),e.jwt=t=>e.check(oo(sc,t)),e.emoji=t=>e.check(Ka(qs,t)),e.guid=t=>e.check(Ba(Us,t)),e.uuid=t=>e.check(Va(Ws,t)),e.uuidv4=t=>e.check(Ha(Ws,t)),e.uuidv6=t=>e.check(Ua(Ws,t)),e.uuidv7=t=>e.check(Wa(Ws,t)),e.nanoid=t=>e.check(qa(Js,t)),e.guid=t=>e.check(Ba(Us,t)),e.cuid=t=>e.check(Ja(Ys,t)),e.cuid2=t=>e.check(Ya(Xs,t)),e.ulid=t=>e.check(Xa(Zs,t)),e.base64=t=>e.check(ro(ic,t)),e.base64url=t=>e.check(io(ac,t)),e.xid=t=>e.check(Za(Qs,t)),e.ksuid=t=>e.check(Qa($s,t)),e.ipv4=t=>e.check($a(ec,t)),e.ipv6=t=>e.check(eo(tc,t)),e.cidrv4=t=>e.check(to(nc,t)),e.cidrv6=t=>e.check(no(rc,t)),e.e164=t=>e.check(ao(oc,t)),e.datetime=t=>e.check(gs(t)),e.date=t=>e.check(vs(t)),e.time=t=>e.check(bs(t)),e.duration=t=>e.check(Ss(t))});function W(e){return Ra(Bs,e)}var Vs=L(`ZodStringFormat`,(e,t)=>{V.init(e,t),zs.init(e,t)}),Hs=L(`ZodEmail`,(e,t)=>{Ei.init(e,t),Vs.init(e,t)}),Us=L(`ZodGUID`,(e,t)=>{wi.init(e,t),Vs.init(e,t)}),Ws=L(`ZodUUID`,(e,t)=>{Ti.init(e,t),Vs.init(e,t)});function Gs(e){return Va(Ws,e)}var Ks=L(`ZodURL`,(e,t)=>{Di.init(e,t),Vs.init(e,t)}),qs=L(`ZodEmoji`,(e,t)=>{Oi.init(e,t),Vs.init(e,t)}),Js=L(`ZodNanoID`,(e,t)=>{ki.init(e,t),Vs.init(e,t)}),Ys=L(`ZodCUID`,(e,t)=>{Ai.init(e,t),Vs.init(e,t)}),Xs=L(`ZodCUID2`,(e,t)=>{ji.init(e,t),Vs.init(e,t)}),Zs=L(`ZodULID`,(e,t)=>{H.init(e,t),Vs.init(e,t)}),Qs=L(`ZodXID`,(e,t)=>{Mi.init(e,t),Vs.init(e,t)}),$s=L(`ZodKSUID`,(e,t)=>{Ni.init(e,t),Vs.init(e,t)}),ec=L(`ZodIPv4`,(e,t)=>{Ri.init(e,t),Vs.init(e,t)}),tc=L(`ZodIPv6`,(e,t)=>{zi.init(e,t),Vs.init(e,t)}),nc=L(`ZodCIDRv4`,(e,t)=>{Bi.init(e,t),Vs.init(e,t)}),rc=L(`ZodCIDRv6`,(e,t)=>{Vi.init(e,t),Vs.init(e,t)}),ic=L(`ZodBase64`,(e,t)=>{Ui.init(e,t),Vs.init(e,t)}),ac=L(`ZodBase64URL`,(e,t)=>{Gi.init(e,t),Vs.init(e,t)}),oc=L(`ZodE164`,(e,t)=>{Ki.init(e,t),Vs.init(e,t)}),sc=L(`ZodJWT`,(e,t)=>{Ji.init(e,t),Vs.init(e,t)}),cc=L(`ZodNumber`,(e,t)=>{Yi.init(e,t),Rs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Yo(e,t,n,r),Ls(e,`ZodNumber`,{gt(e,t){return this.check(vo(e,t))},gte(e,t){return this.check(yo(e,t))},min(e,t){return this.check(yo(e,t))},lt(e,t){return this.check(go(e,t))},lte(e,t){return this.check(_o(e,t))},max(e,t){return this.check(_o(e,t))},int(e){return this.check(uc(e))},safe(e){return this.check(uc(e))},positive(e){return this.check(vo(0,e))},nonnegative(e){return this.check(yo(0,e))},negative(e){return this.check(go(0,e))},nonpositive(e){return this.check(_o(0,e))},multipleOf(e,t){return this.check(bo(e,t))},step(e,t){return this.check(bo(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 G(e){return uo(cc,e)}var lc=L(`ZodNumberFormat`,(e,t)=>{Xi.init(e,t),cc.init(e,t)});function uc(e){return fo(lc,e)}var dc=L(`ZodBoolean`,(e,t)=>{Zi.init(e,t),Rs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Xo(e,t,n,r)});function fc(e){return po(dc,e)}var pc=L(`ZodUnknown`,(e,t)=>{Qi.init(e,t),Rs.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function mc(){return mo(pc)}var hc=L(`ZodNever`,(e,t)=>{$i.init(e,t),Rs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Zo(e,t,n,r)});function gc(e){return ho(hc,e)}var _c=L(`ZodArray`,(e,t)=>{ta.init(e,t),Rs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ns(e,t,n,r),e.element=t.element,Ls(e,`ZodArray`,{min(e,t){return this.check(So(e,t))},nonempty(e){return this.check(So(1,e))},max(e,t){return this.check(xo(e,t))},length(e,t){return this.check(Co(e,t))},unwrap(){return this.element}})});function vc(e,t){return Io(_c,e,t)}var yc=L(`ZodObject`,(e,t)=>{oa.init(e,t),Rs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>rs(e,t,n,r),R(e,`shape`,()=>t.shape),Ls(e,`ZodObject`,{keyof(){return kc(Object.keys(this._zod.def.shape))},catchall(e){return this.clone({...this._zod.def,catchall:e})},passthrough(){return this.clone({...this._zod.def,catchall:mc()})},loose(){return this.clone({...this._zod.def,catchall:mc()})},strict(){return this.clone({...this._zod.def,catchall:gc()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(e){return Xn(this,e)},safeExtend(e){return Zn(this,e)},merge(e){return Qn(this,e)},pick(e){return Jn(this,e)},omit(e){return Yn(this,e)},partial(...e){return $n(Pc,this,e[0])},required(...e){return er(Wc,this,e[0])}})});function K(e,t){return new yc({type:`object`,shape:e??{},...z(t)})}var bc=L(`ZodUnion`,(e,t)=>{ca.init(e,t),Rs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>is(e,t,n,r),e.options=t.options});function xc(e,t){return new bc({type:`union`,options:e,...z(t)})}var Sc=L(`ZodDiscriminatedUnion`,(e,t)=>{bc.init(e,t),la.init(e,t)});function Cc(e,t,n){return new Sc({type:`union`,options:t,discriminator:e,...z(n)})}var wc=L(`ZodIntersection`,(e,t)=>{ua.init(e,t),Rs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>as(e,t,n,r)});function Tc(e,t){return new wc({type:`intersection`,left:e,right:t})}var Ec=L(`ZodRecord`,(e,t)=>{pa.init(e,t),Rs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>os(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType});function Dc(e,t,n){return!t||!t._zod?new Ec({type:`record`,keyType:W(),valueType:e,...z(t)}):new Ec({type:`record`,keyType:e,valueType:t,...z(n)})}var Oc=L(`ZodEnum`,(e,t)=>{ma.init(e,t),Rs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Qo(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 Oc({...t,checks:[],...z(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 Oc({...t,checks:[],...z(r),entries:i})}});function kc(e,t){return new Oc({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...z(t)})}var Ac=L(`ZodLiteral`,(e,t)=>{ha.init(e,t),Rs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>$o(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 jc(e,t){return new Ac({type:`literal`,values:Array.isArray(e)?e:[e],...z(t)})}var Mc=L(`ZodTransform`,(e,t)=>{ga.init(e,t),Rs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ts(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new wn(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(sr(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(sr(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 Nc(e){return new Mc({type:`transform`,transform:e})}var Pc=L(`ZodOptional`,(e,t)=>{va.init(e,t),Rs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ms(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Fc(e){return new Pc({type:`optional`,innerType:e})}var Ic=L(`ZodExactOptional`,(e,t)=>{ya.init(e,t),Rs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ms(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Lc(e){return new Ic({type:`optional`,innerType:e})}var Rc=L(`ZodNullable`,(e,t)=>{ba.init(e,t),Rs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ss(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function zc(e){return new Rc({type:`nullable`,innerType:e})}var Bc=L(`ZodDefault`,(e,t)=>{xa.init(e,t),Rs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ls(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Vc(e,t){return new Bc({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():Hn(t)}})}var Hc=L(`ZodPrefault`,(e,t)=>{Ca.init(e,t),Rs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>us(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Uc(e,t){return new Hc({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():Hn(t)}})}var Wc=L(`ZodNonOptional`,(e,t)=>{wa.init(e,t),Rs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>cs(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Gc(e,t){return new Wc({type:`nonoptional`,innerType:e,...z(t)})}var Kc=L(`ZodCatch`,(e,t)=>{Ea.init(e,t),Rs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ds(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function qc(e,t){return new Kc({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:()=>t})}var Jc=L(`ZodPipe`,(e,t)=>{Da.init(e,t),Rs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>fs(e,t,n,r),e.in=t.in,e.out=t.out});function Yc(e,t){return new Jc({type:`pipe`,in:e,out:t})}var Xc=L(`ZodPreprocess`,(e,t)=>{Jc.init(e,t),ka.init(e,t)}),Zc=L(`ZodReadonly`,(e,t)=>{Aa.init(e,t),Rs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ps(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Qc(e){return new Zc({type:`readonly`,innerType:e})}var $c=L(`ZodCustom`,(e,t)=>{Ma.init(e,t),Rs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>es(e,t,n,r)});function el(e,t={}){return Lo($c,e,t)}function tl(e,t){return Ro(e,t)}function nl(e,t){return new Xc({type:`pipe`,in:Nc(e),out:t})}var rl=[`default`,`acceptEdits`,`plan`,`bypassPermissions`,`auto`,`bubble`];function il(e){return e===`safe`||e===`workspace`?`default`:e===`full`?`bypassPermissions`:e}var al=nl(il,kc(rl).default(`default`)),ol=K({type:W(),baseURL:W().url().optional(),apiKey:W().optional(),defaultModel:W().min(1).optional(),cheapModel:W().min(1).optional(),models:vc(W().min(1)).max(100).optional(),maxOutputTokens:G().int().positive().optional(),claudeClient:fc().optional(),apiType:kc([`openai`,`anthropic`]).optional(),authorizationUrl:W().url().optional(),tokenUrl:W().url().optional(),clientId:W().min(1).optional(),scope:W().optional()}),sl={disabled:fc().default(!1),timeoutMs:G().int().min(100).max(30*6e4).default(6e4)},cl=xc([K({command:W().min(1),args:vc(W()).default([]),env:Dc(W(),W()).default({}),cwd:W().min(1).optional(),...sl}).strict(),K({url:W().url().refine(e=>{let t=new URL(e).protocol;return t===`http:`||t===`https:`},`MCP HTTP URLs must use http or https`),headers:Dc(W(),W()).default({}),...sl}).strict()]),ll=W().min(1).max(32).regex(/^[A-Za-z0-9_-]+$/,`MCP server names may contain only letters, digits, underscores, and hyphens`),ul=W().min(1).max(64).regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/,`Skill names must use lowercase letters, digits, and single hyphens`);K({sleep:fc().default(!1),providers:Dc(W(),ol).default({}),mcpServers:Dc(ll,cl).default({}),skills:K({disabled:vc(ul).max(1e3).default([])}).prefault({}),agents:K({main:K({model:W()}).optional(),subagent:K({model:W()}).optional()}).optional(),maxSubagents:G().int().min(1).max(16).default(3),maxSessions:G().int().min(1).max(1e3).default(50),memory:K({enabled:fc().default(!0),autoExtract:fc().default(!0),autoExtractMinChars:G().int().min(200).max(1e5).default(200),scoreThreshold:G().int().min(0).max(12).default(9),autoStoreThreshold:G().int().min(0).max(12).default(11),ignoreStreakLimit:G().int().min(2).max(100).default(5),reviewAutoDismissSeconds:G().int().min(0).max(300).default(5),maxCandidatesPerTask:G().int().min(1).max(10).default(1),retrievalTopK:G().int().min(1).max(20).default(5),maxEntries:G().int().min(1).max(1e4).default(200),maxEntryChars:G().int().min(32).max(2e4).default(1e3),maxPromptChars:G().int().min(256).max(2e5).default(12e3)}).prefault({}),permissionMode:al,execution:K({mode:kc([`local`,`docker`]).default(`local`),image:W().trim().min(1).default(`node:24-bookworm-slim`),network:fc().default(!1),memory:W().regex(/^[1-9][0-9]*(?:[kKmMgG])?$/).default(`2g`),cpus:G().positive().max(64).default(2)}).prefault({}),language:W().regex(/^[a-z]{2}(-[A-Z]{2})?$/,`language must be a BCP47 tag like zh-CN or en-US`).optional(),hallucination:K({showWarnings:fc().default(!1),evaluationTimeoutMs:G().int().min(100).max(3e4).default(2e3)}).prefault({}),maxIterations:K({main:G().int().min(10).max(500).default(80),subagent:G().int().min(10).max(200).default(40),softLimitFactor:G().min(.5).max(1).default(.8),extendBy:G().int().min(5).max(100).default(20)}).prefault({}),loop:K({maxCycles:G().int().positive().max(1e4).default(20),maxTokens:G().int().positive().max(2**53-1).default(5e5),isolation:jc(`auto`).default(`auto`)}).prefault({}),context:K({windowTokens:G().int().positive().default(2e5),reservedOutputTokens:G().int().nonnegative().default(2e4),autoCompactBufferTokens:G().int().nonnegative().default(13e3),warningBufferTokens:G().int().nonnegative().default(2e4),blockingBufferTokens:G().int().nonnegative().default(3e3),microcompactKeepRecentToolResults:G().int().nonnegative().default(5),recentTokens:G().int().nonnegative().default(1e4),recentTextMessages:G().int().nonnegative().default(5),maxRecentTokens:G().int().nonnegative().default(4e4),compactAtChars:G().int().positive().optional(),toolOutputChars:G().int().positive().default(3e4)}).superRefine((e,t)=>{e.reservedOutputTokens>=e.windowTokens&&t.addIssue({code:`custom`,path:[`reservedOutputTokens`],message:`reservedOutputTokens must be below windowTokens`}),e.maxRecentTokens<e.recentTokens&&t.addIssue({code:`custom`,path:[`maxRecentTokens`],message:`maxRecentTokens must be at least recentTokens`})}).prefault({}),incidents:K({enabled:fc().default(!1),webhookUrl:W().url().optional()}).prefault({}),evolve:K({promptTop:G().int().min(1).max(10).default(3),minRepeats:G().int().min(2).max(100).default(2),testCommand:W().trim().min(1).default(`npm test`),testTimeoutMs:G().int().min(1e3).max(6e5).default(12e4)}).prefault({})});var dl=[`user`,`feedback`,`project`,`reference`],fl=32*1024,pl=64*1024,ml=1024,hl=24*1024,gl=56*1024,_l=4*1024,vl=12*1024,yl=jc(1),q=Gs(),bl=W().trim().min(1).max(64).refine(e=>!/[\p{Cc}\uD800-\uDFFF]/u.test(e),`Identity must contain only printable non-control Unicode`),xl=bl,Sl=bl,Cl=W().refine(e=>Buffer.byteLength(e,`utf8`)<=fl,`Text must not exceed ${fl} UTF-8 bytes`),wl=Cl.refine(e=>e.length>0,`Text must not be empty`),Tl=W().trim().min(1).refine(e=>Buffer.byteLength(e,`utf8`)<=_l,`Completion evidence must not exceed ${_l} UTF-8 bytes`),El=K({version:yl,id:q,alias:xl,projectPath:W().min(1).refine(e=>Buffer.byteLength(e,`utf8`)<=ml,`Project path must not exceed ${ml} UTF-8 bytes`),connectedAt:gs(),lastSeenAt:gs()}).strict();vc(El).max(16),K({version:yl,type:jc(`task`),messageId:q,target:Sl,goal:wl}).strict();var Dl=K({version:yl,type:jc(`task-event`),messageId:q,taskId:q,senderId:q,recipientId:q,status:kc([`accepted`,`started`,`progress`,`completed`,`failed`,`cancelled`]),detail:Cl.optional()}).strict(),Ol=K({version:yl,type:jc(`delivery-receipt`),messageId:q,status:kc([`delivered`,`duplicate`,`rejected`]),recipientIds:vc(q).max(16),error:Cl.optional()}).strict(),kl=K({palId:q,required:fc()}).strict(),Al=vc(kl).min(2).max(16).superRefine((e,t)=>{let n=new Set;for(let[r,i]of e.entries()){let e=i.palId.toLowerCase();n.has(e)&&t.addIssue({code:`custom`,path:[r,`palId`],message:`Duplicate participant`}),n.add(e)}}),jl=K({id:W().min(1).max(128),assigneeId:q,description:wl,dependsOn:vc(W().min(1).max(128)).max(32)}).strict(),Ml=K({version:yl,coWorkId:q,epoch:G().int().positive(),goal:wl,participants:vc(kl).min(1).max(16),tasks:vc(jl).min(1).max(32)}).strict().superRefine((e,t)=>{Buffer.byteLength(JSON.stringify(e),`utf8`)>24576&&t.addIssue({code:`custom`,message:`Encoded plan must not exceed ${hl} UTF-8 bytes`});let n=new Set;for(let[r,i]of e.participants.entries())n.has(i.palId)&&t.addIssue({code:`custom`,path:[`participants`,r,`palId`],message:`Duplicate participant`}),n.add(i.palId);let r=new Set;for(let[i,a]of e.tasks.entries())r.has(a.id)&&t.addIssue({code:`custom`,path:[`tasks`,i,`id`],message:`Duplicate task id`}),r.add(a.id),n.has(a.assigneeId)||t.addIssue({code:`custom`,path:[`tasks`,i,`assigneeId`],message:`Assignee is not a participant`});for(let[n,i]of e.tasks.entries())for(let e of i.dependsOn)(!r.has(e)||e===i.id)&&t.addIssue({code:`custom`,path:[`tasks`,n,`dependsOn`],message:`Invalid task dependency`});let i=new Map(e.tasks.map(e=>[e.id,e.dependsOn])),a=new Set,o=new Set,s=e=>{if(a.has(e))return!0;if(o.has(e))return!1;a.add(e);for(let t of i.get(e)??[])if(i.has(t)&&s(t))return!0;return a.delete(e),o.add(e),!1};for(let[n,r]of e.tasks.entries())if(s(r.id)){t.addIssue({code:`custom`,path:[`tasks`,n,`dependsOn`],message:`Task dependencies must be acyclic`});break}}),Nl=kc([`proposed`,`planning`,`prepared`,`running`,`verifying`,`completed`,`failed`,`cancelled`]),Pl=K({passed:fc(),evidence:Tl}).strict(),Fl=K({participantId:q,passed:fc(),detail:Tl.optional()}).strict(),Il=K({version:yl,coWorkId:q,epoch:G().int().positive(),phase:Nl,goal:wl,participants:vc(kl).min(1).max(16),integrationOwnerId:q,acceptedParticipantIds:vc(q).max(16),planHash:W().regex(/^[a-f0-9]{64}$/).nullable(),plan:Ml.nullable(),planAcceptedParticipantIds:vc(q).max(16),readyParticipantIds:vc(q).max(16),completedParticipantIds:vc(q).max(16),completionAssertions:vc(Fl).max(16),integration:Pl.nullable()}).strict().superRefine((e,t)=>{Buffer.byteLength(JSON.stringify(e),`utf8`)>57344&&t.addIssue({code:`custom`,message:`Encoded snapshot must not exceed ${gl} UTF-8 bytes`});let n=new Set(e.participants.map(({palId:e})=>e));new Set(e.participants.filter(({required:e})=>e).map(({palId:e})=>e)).has(e.integrationOwnerId)||t.addIssue({code:`custom`,path:[`integrationOwnerId`],message:`Integration owner must be a required participant`});let r=new Set,i=0;for(let[a,o]of e.completionAssertions.entries())n.has(o.participantId)||t.addIssue({code:`custom`,path:[`completionAssertions`,a,`participantId`],message:`Assertion owner must be a participant`}),r.has(o.participantId)&&t.addIssue({code:`custom`,path:[`completionAssertions`,a,`participantId`],message:`Duplicate completion assertion`}),r.add(o.participantId),i+=Buffer.byteLength(o.detail??``,`utf8`);i>12288&&t.addIssue({code:`custom`,path:[`completionAssertions`],message:`Completion assertions must not exceed ${vl} UTF-8 bytes in aggregate`})}),J={version:yl,requestId:q};Cc(`type`,[K({...J,type:jc(`register`),authToken:W().regex(/^[a-f0-9]{64}$/).optional(),presence:El}).strict(),K({...J,type:jc(`heartbeat`)}).strict(),K({...J,type:jc(`list`)}).strict(),K({...J,type:jc(`disconnect`)}).strict(),K({...J,type:jc(`chat`),messageId:q,target:Sl,message:wl}).strict(),K({...J,type:jc(`task`),messageId:q,target:Sl,goal:wl}).strict(),K({...J,type:jc(`cowork-propose`),coWorkId:q,goal:wl,participants:Al}).strict(),K({...J,type:jc(`cowork-accept`),coWorkId:q,epoch:G().int().positive()}).strict(),K({...J,type:jc(`cowork-plan`),plan:Ml}).strict(),K({...J,type:jc(`cowork-plan-accept`),coWorkId:q,epoch:G().int().positive(),planHash:W().regex(/^[a-f0-9]{64}$/)}).strict(),K({...J,type:jc(`cowork-ready`),coWorkId:q,epoch:G().int().positive(),planHash:W().regex(/^[a-f0-9]{64}$/)}).strict(),K({...J,type:jc(`cowork-complete`),coWorkId:q,epoch:G().int().positive(),planHash:W().regex(/^[a-f0-9]{64}$/),passed:fc(),detail:Tl.optional()}).strict(),K({...J,type:jc(`cowork-integration`),coWorkId:q,epoch:G().int().positive(),planHash:W().regex(/^[a-f0-9]{64}$/),passed:fc(),evidence:Tl}).strict(),K({...J,type:jc(`cowork-get`),coWorkId:q}).strict(),K({...J,type:jc(`cowork-cancel`),coWorkId:q,reason:wl}).strict()]);var Ll=K({version:yl,type:jc(`ok`),requestId:q,data:mc()}).strict(),Y=K({version:yl,type:jc(`error`),requestId:q,code:kc([`invalid-request`,`authentication-failed`,`not-found`,`ambiguous-target`,`alias-conflict`,`invalid-transition`,`stale-epoch`,`duplicate`]),message:Cl}).strict(),X=xc([K({version:yl,type:jc(`chat-event`),messageId:q,senderId:q,recipientId:q,message:wl}).strict(),Dl,Ol,K({version:yl,type:jc(`cowork-event`),action:kc([`PROPOSE`,`PLAN`,`START`,`END`,`FAIL`,`CANCEL`]),actorId:q,coWorkId:q,epoch:G().int().positive(),planHash:W().regex(/^[a-f0-9]{64}$/).nullable(),snapshot:Il}).strict()]);Cc(`type`,[Ll,Y,K({version:yl,type:jc(`event`),event:X}).strict()]),W().refine(e=>Buffer.byteLength(e,`utf8`)<=pl,`Control frame must not exceed ${pl} UTF-8 bytes`);var Z=`model.init.config.login.logout.permissions.skills.plugins.hooks.tasks.finish.compact.clear.help.exit.audit.usage.loop.goal.evolve.mcp.commit.review.ide.memory.remember.forget.forget-cold.checkpoint.tree.rewind.unrevert.fork.pals.chat.co-work`.split(`.`),Rl={model:`Switch the active model`,init:`Initialize Flavor project files`,config:`Show the resolved configuration`,login:`Authenticate via OAuth PKCE`,logout:`Clear stored OAuth credentials and restore configured models`,permissions:`Change the tool permission mode`,skills:`List discovered skills`,plugins:`List loaded plugins`,hooks:`Show plugin hook status`,tasks:`Show task planning status`,finish:`Complete this task and evaluate long-term memory`,compact:`Compact the conversation context`,clear:`Clear the transcript`,help:`Show available commands`,exit:`Exit Flavor`,audit:`Query tool failure audit log`,usage:`Show cache hit statistics for this session`,loop:`Run a verified autonomous loop toward a goal`,goal:`Run a goal pipeline with adversarial verification`,evolve:`Self-improvement loop: capture failures, suggest fixes, verify with tests`,commit:`Generate a commit message for staged changes and commit after confirmation`,review:`Review uncommitted changes for bugs and risks before committing`,mcp:`Manage MCP servers`,ide:`Show the connected IDE and editor context`,memory:`Show long-term project memory`,remember:`Add a long-term memory`,forget:`Remove matching long-term memories`,"forget-cold":`Remove all cold long-term memories and their files`,checkpoint:`Create a workspace and context checkpoint`,tree:`Show the session history tree`,rewind:`Restore a prior session node`,unrevert:`Undo the most recent rewind`,fork:`Continue context from a prior session node`,pals:`List, rename, or inspect active Flavor pals`,chat:`Send a task to another Flavor pal`,"co-work":`Coordinate a shared goal with another Flavor pal`},zl={name:``,description:``,body:`# Instructions
135
+ 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);continue}if(e.external){let r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){a(n);continue}}if(e.metadataRegistry.get(n[0])?.id){a(n);continue}if(r.cycle){a(n);continue}if(r.count>1&&e.reused===`ref`){a(n);continue}}}function Uo(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:Ko(t,`input`,e.processors),output:Ko(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function Wo(e,t){let n=t??{seen: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 Wo(r.element,n);if(r.type===`set`)return Wo(r.valueType,n);if(r.type===`lazy`)return Wo(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 Wo(r.innerType,n);if(r.type===`intersection`)return Wo(r.left,n)||Wo(r.right,n);if(r.type===`record`||r.type===`map`)return Wo(r.keyType,n)||Wo(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:Wo(r.in,n)||Wo(r.out,n);if(r.type===`object`){for(let e in r.shape)if(Wo(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(Wo(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(Wo(e,n))return!0;return!!(r.rest&&Wo(r.rest,n))}return!1}var Go=(e,t={})=>n=>{let r=Bo({...n,processors:t});return Vo(e,r),Ho(r,e),Uo(r,e)},Ko=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=Bo({...i??{},target:a,io:t,processors:n});return Vo(e,o),Ho(o,e),Uo(o,e)},qo={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},Jo=(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=qo[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}))])}},Yo=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,format:s,multipleOf:c,exclusiveMaximum:l,exclusiveMinimum:u}=e._zod.bag;typeof s==`string`&&s.includes(`int`)?i.type=`integer`:i.type=`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)},Xo=(e,t,n,r)=>{n.type=`boolean`},Zo=(e,t,n,r)=>{n.not={}},Qo=(e,t,n,r)=>{let i=e._zod.def,a=Dn(i.entries);a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a},$o=(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},es=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Custom types cannot be represented in JSON Schema`)},ts=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Transforms cannot be represented in JSON Schema`)},ns=(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=Vo(a.element,t,{...r,path:[...r.path,`items`]})},rs=(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]=Vo(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=Vo(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},is=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>Vo(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},as=(e,t,n,r)=>{let i=e._zod.def,a=Vo(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=Vo(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]]},os=(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=Vo(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=Vo(a.keyType,t,{...r,path:[...r.path,`propertyNames`]})),i.additionalProperties=Vo(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)}},ss=(e,t,n,r)=>{let i=e._zod.def,a=Vo(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`}]},cs=(e,t,n,r)=>{let i=e._zod.def;Vo(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},ls=(e,t,n,r)=>{let i=e._zod.def;Vo(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.default=JSON.parse(JSON.stringify(i.defaultValue))},us=(e,t,n,r)=>{let i=e._zod.def;Vo(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)))},ds=(e,t,n,r)=>{let i=e._zod.def;Vo(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},fs=(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;Vo(o,t,r);let s=t.seen.get(e);s.ref=o},ps=(e,t,n,r)=>{let i=e._zod.def;Vo(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},ms=(e,t,n,r)=>{let i=e._zod.def;Vo(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},hs=L(`ZodISODateTime`,(e,t)=>{Pi.init(e,t),Vs.init(e,t)});function gs(e){return so(hs,e)}var _s=L(`ZodISODate`,(e,t)=>{Fi.init(e,t),Vs.init(e,t)});function vs(e){return co(_s,e)}var ys=L(`ZodISOTime`,(e,t)=>{Ii.init(e,t),Vs.init(e,t)});function bs(e){return lo(ys,e)}var xs=L(`ZodISODuration`,(e,t)=>{Li.init(e,t),Vs.init(e,t)});function Ss(e){return U(xs,e)}var Cs=L(`ZodError`,(e,t)=>{lr.init(e,t),e.name=`ZodError`,Object.defineProperties(e,{format:{value:t=>fr(e,t)},flatten:{value:t=>dr(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,On,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,On,2)}},isEmpty:{get(){return e.issues.length===0}}})},{Parent:Error}),ws=pr(Cs),Ts=mr(Cs),Es=hr(Cs),Ds=_r(Cs),Os=yr(Cs),ks=br(Cs),As=xr(Cs),js=Sr(Cs),Ms=Cr(Cs),Ns=wr(Cs),Ps=Tr(Cs),Fs=Er(Cs),Is=new WeakMap;function Ls(e,t,n){let r=Object.getPrototypeOf(e),i=Is.get(r);if(i||(i=new Set,Is.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})}})}}}var Rs=L(`ZodType`,(e,t)=>(B.init(e,t),Object.assign(e[`~standard`],{jsonSchema:{input:Ko(e,`input`),output:Ko(e,`output`)}}),e.toJSONSchema=Go(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(t,n)=>ws(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>Es(e,t,n),e.parseAsync=async(t,n)=>Ts(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>Ds(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>Os(e,t,n),e.decode=(t,n)=>ks(e,t,n),e.encodeAsync=async(t,n)=>As(e,t,n),e.decodeAsync=async(t,n)=>js(e,t,n),e.safeEncode=(t,n)=>Ms(e,t,n),e.safeDecode=(t,n)=>Ns(e,t,n),e.safeEncodeAsync=async(t,n)=>Ps(e,t,n),e.safeDecodeAsync=async(t,n)=>Fs(e,t,n),Ls(e,`ZodType`,{check(...e){let t=this.def;return this.clone(Fn(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 Gn(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(el(e,t))},superRefine(e,t){return this.check(tl(e,t))},overwrite(e){return this.check(Ao(e))},optional(){return Fc(this)},exactOptional(){return Lc(this)},nullable(){return zc(this)},nullish(){return Fc(zc(this))},nonoptional(e){return Gc(this,e)},array(){return vc(this)},or(e){return xc([this,e])},and(e){return Tc(this,e)},transform(e){return Yc(this,Nc(e))},default(e){return Vc(this,e)},prefault(e){return Uc(this,e)},catch(e){return qc(this,e)},pipe(e){return Yc(this,e)},readonly(){return Qc(this)},describe(e){let t=this.clone();return La.add(t,{description:e}),t},meta(...e){if(e.length===0)return La.get(this);let t=this.clone();return La.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 La.get(e)?.description},configurable:!0}),e)),zs=L(`_ZodString`,(e,t)=>{Ci.init(e,t),Rs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Jo(e,t,n,r);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,Ls(e,`_ZodString`,{regex(...e){return this.check(wo(...e))},includes(...e){return this.check(Do(...e))},startsWith(...e){return this.check(Oo(...e))},endsWith(...e){return this.check(ko(...e))},min(...e){return this.check(So(...e))},max(...e){return this.check(xo(...e))},length(...e){return this.check(Co(...e))},nonempty(...e){return this.check(So(1,...e))},lowercase(e){return this.check(To(e))},uppercase(e){return this.check(Eo(e))},trim(){return this.check(Mo())},normalize(...e){return this.check(jo(...e))},toLowerCase(){return this.check(No())},toUpperCase(){return this.check(Po())},slugify(){return this.check(Fo())}})}),Bs=L(`ZodString`,(e,t)=>{Ci.init(e,t),zs.init(e,t),e.email=t=>e.check(za(Hs,t)),e.url=t=>e.check(Ga(Ks,t)),e.jwt=t=>e.check(oo(sc,t)),e.emoji=t=>e.check(Ka(qs,t)),e.guid=t=>e.check(Ba(Us,t)),e.uuid=t=>e.check(Va(Ws,t)),e.uuidv4=t=>e.check(Ha(Ws,t)),e.uuidv6=t=>e.check(Ua(Ws,t)),e.uuidv7=t=>e.check(Wa(Ws,t)),e.nanoid=t=>e.check(qa(Js,t)),e.guid=t=>e.check(Ba(Us,t)),e.cuid=t=>e.check(Ja(Ys,t)),e.cuid2=t=>e.check(Ya(Xs,t)),e.ulid=t=>e.check(Xa(Zs,t)),e.base64=t=>e.check(ro(ic,t)),e.base64url=t=>e.check(io(ac,t)),e.xid=t=>e.check(Za(Qs,t)),e.ksuid=t=>e.check(Qa($s,t)),e.ipv4=t=>e.check($a(ec,t)),e.ipv6=t=>e.check(eo(tc,t)),e.cidrv4=t=>e.check(to(nc,t)),e.cidrv6=t=>e.check(no(rc,t)),e.e164=t=>e.check(ao(oc,t)),e.datetime=t=>e.check(gs(t)),e.date=t=>e.check(vs(t)),e.time=t=>e.check(bs(t)),e.duration=t=>e.check(Ss(t))});function W(e){return Ra(Bs,e)}var Vs=L(`ZodStringFormat`,(e,t)=>{V.init(e,t),zs.init(e,t)}),Hs=L(`ZodEmail`,(e,t)=>{Ei.init(e,t),Vs.init(e,t)}),Us=L(`ZodGUID`,(e,t)=>{wi.init(e,t),Vs.init(e,t)}),Ws=L(`ZodUUID`,(e,t)=>{Ti.init(e,t),Vs.init(e,t)});function Gs(e){return Va(Ws,e)}var Ks=L(`ZodURL`,(e,t)=>{Di.init(e,t),Vs.init(e,t)}),qs=L(`ZodEmoji`,(e,t)=>{Oi.init(e,t),Vs.init(e,t)}),Js=L(`ZodNanoID`,(e,t)=>{ki.init(e,t),Vs.init(e,t)}),Ys=L(`ZodCUID`,(e,t)=>{Ai.init(e,t),Vs.init(e,t)}),Xs=L(`ZodCUID2`,(e,t)=>{ji.init(e,t),Vs.init(e,t)}),Zs=L(`ZodULID`,(e,t)=>{H.init(e,t),Vs.init(e,t)}),Qs=L(`ZodXID`,(e,t)=>{Mi.init(e,t),Vs.init(e,t)}),$s=L(`ZodKSUID`,(e,t)=>{Ni.init(e,t),Vs.init(e,t)}),ec=L(`ZodIPv4`,(e,t)=>{Ri.init(e,t),Vs.init(e,t)}),tc=L(`ZodIPv6`,(e,t)=>{zi.init(e,t),Vs.init(e,t)}),nc=L(`ZodCIDRv4`,(e,t)=>{Bi.init(e,t),Vs.init(e,t)}),rc=L(`ZodCIDRv6`,(e,t)=>{Vi.init(e,t),Vs.init(e,t)}),ic=L(`ZodBase64`,(e,t)=>{Ui.init(e,t),Vs.init(e,t)}),ac=L(`ZodBase64URL`,(e,t)=>{Gi.init(e,t),Vs.init(e,t)}),oc=L(`ZodE164`,(e,t)=>{Ki.init(e,t),Vs.init(e,t)}),sc=L(`ZodJWT`,(e,t)=>{Ji.init(e,t),Vs.init(e,t)}),cc=L(`ZodNumber`,(e,t)=>{Yi.init(e,t),Rs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Yo(e,t,n,r),Ls(e,`ZodNumber`,{gt(e,t){return this.check(vo(e,t))},gte(e,t){return this.check(yo(e,t))},min(e,t){return this.check(yo(e,t))},lt(e,t){return this.check(go(e,t))},lte(e,t){return this.check(_o(e,t))},max(e,t){return this.check(_o(e,t))},int(e){return this.check(uc(e))},safe(e){return this.check(uc(e))},positive(e){return this.check(vo(0,e))},nonnegative(e){return this.check(yo(0,e))},negative(e){return this.check(go(0,e))},nonpositive(e){return this.check(_o(0,e))},multipleOf(e,t){return this.check(bo(e,t))},step(e,t){return this.check(bo(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 G(e){return uo(cc,e)}var lc=L(`ZodNumberFormat`,(e,t)=>{Xi.init(e,t),cc.init(e,t)});function uc(e){return fo(lc,e)}var dc=L(`ZodBoolean`,(e,t)=>{Zi.init(e,t),Rs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Xo(e,t,n,r)});function fc(e){return po(dc,e)}var pc=L(`ZodUnknown`,(e,t)=>{Qi.init(e,t),Rs.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function mc(){return mo(pc)}var hc=L(`ZodNever`,(e,t)=>{$i.init(e,t),Rs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Zo(e,t,n,r)});function gc(e){return ho(hc,e)}var _c=L(`ZodArray`,(e,t)=>{ta.init(e,t),Rs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ns(e,t,n,r),e.element=t.element,Ls(e,`ZodArray`,{min(e,t){return this.check(So(e,t))},nonempty(e){return this.check(So(1,e))},max(e,t){return this.check(xo(e,t))},length(e,t){return this.check(Co(e,t))},unwrap(){return this.element}})});function vc(e,t){return Io(_c,e,t)}var yc=L(`ZodObject`,(e,t)=>{oa.init(e,t),Rs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>rs(e,t,n,r),R(e,`shape`,()=>t.shape),Ls(e,`ZodObject`,{keyof(){return kc(Object.keys(this._zod.def.shape))},catchall(e){return this.clone({...this._zod.def,catchall:e})},passthrough(){return this.clone({...this._zod.def,catchall:mc()})},loose(){return this.clone({...this._zod.def,catchall:mc()})},strict(){return this.clone({...this._zod.def,catchall:gc()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(e){return Xn(this,e)},safeExtend(e){return Zn(this,e)},merge(e){return Qn(this,e)},pick(e){return Jn(this,e)},omit(e){return Yn(this,e)},partial(...e){return $n(Pc,this,e[0])},required(...e){return er(Wc,this,e[0])}})});function K(e,t){return new yc({type:`object`,shape:e??{},...z(t)})}var bc=L(`ZodUnion`,(e,t)=>{ca.init(e,t),Rs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>is(e,t,n,r),e.options=t.options});function xc(e,t){return new bc({type:`union`,options:e,...z(t)})}var Sc=L(`ZodDiscriminatedUnion`,(e,t)=>{bc.init(e,t),la.init(e,t)});function Cc(e,t,n){return new Sc({type:`union`,options:t,discriminator:e,...z(n)})}var wc=L(`ZodIntersection`,(e,t)=>{ua.init(e,t),Rs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>as(e,t,n,r)});function Tc(e,t){return new wc({type:`intersection`,left:e,right:t})}var Ec=L(`ZodRecord`,(e,t)=>{pa.init(e,t),Rs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>os(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType});function Dc(e,t,n){return!t||!t._zod?new Ec({type:`record`,keyType:W(),valueType:e,...z(t)}):new Ec({type:`record`,keyType:e,valueType:t,...z(n)})}var Oc=L(`ZodEnum`,(e,t)=>{ma.init(e,t),Rs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Qo(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 Oc({...t,checks:[],...z(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 Oc({...t,checks:[],...z(r),entries:i})}});function kc(e,t){return new Oc({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...z(t)})}var Ac=L(`ZodLiteral`,(e,t)=>{ha.init(e,t),Rs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>$o(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 jc(e,t){return new Ac({type:`literal`,values:Array.isArray(e)?e:[e],...z(t)})}var Mc=L(`ZodTransform`,(e,t)=>{ga.init(e,t),Rs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ts(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new wn(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(sr(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(sr(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 Nc(e){return new Mc({type:`transform`,transform:e})}var Pc=L(`ZodOptional`,(e,t)=>{va.init(e,t),Rs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ms(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Fc(e){return new Pc({type:`optional`,innerType:e})}var Ic=L(`ZodExactOptional`,(e,t)=>{ya.init(e,t),Rs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ms(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Lc(e){return new Ic({type:`optional`,innerType:e})}var Rc=L(`ZodNullable`,(e,t)=>{ba.init(e,t),Rs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ss(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function zc(e){return new Rc({type:`nullable`,innerType:e})}var Bc=L(`ZodDefault`,(e,t)=>{xa.init(e,t),Rs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ls(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Vc(e,t){return new Bc({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():Hn(t)}})}var Hc=L(`ZodPrefault`,(e,t)=>{Ca.init(e,t),Rs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>us(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Uc(e,t){return new Hc({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():Hn(t)}})}var Wc=L(`ZodNonOptional`,(e,t)=>{wa.init(e,t),Rs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>cs(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Gc(e,t){return new Wc({type:`nonoptional`,innerType:e,...z(t)})}var Kc=L(`ZodCatch`,(e,t)=>{Ea.init(e,t),Rs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ds(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function qc(e,t){return new Kc({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:()=>t})}var Jc=L(`ZodPipe`,(e,t)=>{Da.init(e,t),Rs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>fs(e,t,n,r),e.in=t.in,e.out=t.out});function Yc(e,t){return new Jc({type:`pipe`,in:e,out:t})}var Xc=L(`ZodPreprocess`,(e,t)=>{Jc.init(e,t),ka.init(e,t)}),Zc=L(`ZodReadonly`,(e,t)=>{Aa.init(e,t),Rs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ps(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Qc(e){return new Zc({type:`readonly`,innerType:e})}var $c=L(`ZodCustom`,(e,t)=>{Ma.init(e,t),Rs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>es(e,t,n,r)});function el(e,t={}){return Lo($c,e,t)}function tl(e,t){return Ro(e,t)}function nl(e,t){return new Xc({type:`pipe`,in:Nc(e),out:t})}var rl=[`default`,`acceptEdits`,`plan`,`bypassPermissions`,`auto`,`bubble`];function il(e){return e===`safe`||e===`workspace`?`default`:e===`full`?`bypassPermissions`:e}var al=nl(il,kc(rl).default(`default`)),ol=K({type:W(),baseURL:W().url().optional(),apiKey:W().optional(),defaultModel:W().min(1).optional(),cheapModel:W().min(1).optional(),models:vc(W().min(1)).max(100).optional(),maxOutputTokens:G().int().positive().optional(),claudeClient:fc().optional(),apiType:kc([`openai`,`anthropic`]).optional(),authorizationUrl:W().url().optional(),tokenUrl:W().url().optional(),clientId:W().min(1).optional(),scope:W().optional()}),sl={disabled:fc().default(!1),timeoutMs:G().int().min(100).max(30*6e4).default(6e4)},cl=xc([K({command:W().min(1),args:vc(W()).default([]),env:Dc(W(),W()).default({}),cwd:W().min(1).optional(),...sl}).strict(),K({url:W().url().refine(e=>{let t=new URL(e).protocol;return t===`http:`||t===`https:`},`MCP HTTP URLs must use http or https`),headers:Dc(W(),W()).default({}),...sl}).strict()]),ll=W().min(1).max(32).regex(/^[A-Za-z0-9_-]+$/,`MCP server names may contain only letters, digits, underscores, and hyphens`),ul=W().min(1).max(64).regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/,`Skill names must use lowercase letters, digits, and single hyphens`);K({sleep:fc().default(!1),providers:Dc(W(),ol).default({}),mcpServers:Dc(ll,cl).default({}),skills:K({disabled:vc(ul).max(1e3).default([])}).prefault({}),agents:K({main:K({model:W()}).optional(),subagent:K({model:W()}).optional()}).optional(),maxSubagents:G().int().min(1).max(16).default(3),maxSessions:G().int().min(1).max(1e3).default(50),memory:K({enabled:fc().default(!0),autoExtract:fc().default(!0),autoExtractMinChars:G().int().min(200).max(1e5).default(200),scoreThreshold:G().int().min(0).max(12).default(9),autoStoreThreshold:G().int().min(0).max(12).default(11),ignoreStreakLimit:G().int().min(2).max(100).default(5),reviewAutoDismissSeconds:G().int().min(0).max(300).default(5),maxCandidatesPerTask:G().int().min(1).max(10).default(1),retrievalTopK:G().int().min(1).max(20).default(5),maxEntries:G().int().min(1).max(1e4).default(200),maxEntryChars:G().int().min(32).max(2e4).default(1e3),maxPromptChars:G().int().min(256).max(2e5).default(12e3)}).prefault({}),permissionMode:al,execution:K({mode:kc([`local`,`docker`]).default(`local`),image:W().trim().min(1).default(`node:24-bookworm-slim`),network:fc().default(!1),memory:W().regex(/^[1-9][0-9]*(?:[kKmMgG])?$/).default(`2g`),cpus:G().positive().max(64).default(2)}).prefault({}),language:W().regex(/^[a-z]{2}(-[A-Z]{2})?$/,`language must be a BCP47 tag like zh-CN or en-US`).optional(),hallucination:K({showWarnings:fc().default(!1),evaluationTimeoutMs:G().int().min(100).max(3e4).default(2e3)}).prefault({}),maxIterations:K({main:G().int().min(10).max(500).default(80),subagent:G().int().min(10).max(200).default(40),softLimitFactor:G().min(.5).max(1).default(.8),extendBy:G().int().min(5).max(100).default(20)}).prefault({}),loop:K({maxCycles:G().int().positive().max(1e4).default(20),maxTokens:G().int().positive().max(2**53-1).default(5e5),isolation:jc(`auto`).default(`auto`)}).prefault({}),context:K({windowTokens:G().int().positive().default(2e5),reservedOutputTokens:G().int().nonnegative().default(2e4),autoCompactBufferTokens:G().int().nonnegative().default(13e3),warningBufferTokens:G().int().nonnegative().default(2e4),blockingBufferTokens:G().int().nonnegative().default(3e3),microcompactKeepRecentToolResults:G().int().nonnegative().default(5),recentTokens:G().int().nonnegative().default(1e4),recentTextMessages:G().int().nonnegative().default(5),maxRecentTokens:G().int().nonnegative().default(4e4),compactAtChars:G().int().positive().optional(),toolOutputChars:G().int().positive().default(3e4)}).superRefine((e,t)=>{e.reservedOutputTokens>=e.windowTokens&&t.addIssue({code:`custom`,path:[`reservedOutputTokens`],message:`reservedOutputTokens must be below windowTokens`}),e.maxRecentTokens<e.recentTokens&&t.addIssue({code:`custom`,path:[`maxRecentTokens`],message:`maxRecentTokens must be at least recentTokens`})}).prefault({}),incidents:K({enabled:fc().default(!1),webhookUrl:W().url().optional()}).prefault({}),evolve:K({promptTop:G().int().min(1).max(10).default(3),minRepeats:G().int().min(2).max(100).default(2),testCommand:W().trim().min(1).default(`npm test`),testTimeoutMs:G().int().min(1e3).max(6e5).default(12e4)}).prefault({})});var dl=[`user`,`feedback`,`project`,`reference`],fl=32*1024,pl=64*1024,ml=1024,hl=24*1024,gl=56*1024,_l=4*1024,vl=12*1024,yl=jc(1),q=Gs(),bl=W().trim().min(1).max(64).refine(e=>!/[\p{Cc}\uD800-\uDFFF]/u.test(e),`Identity must contain only printable non-control Unicode`),xl=bl,Sl=bl,Cl=W().refine(e=>Buffer.byteLength(e,`utf8`)<=fl,`Text must not exceed ${fl} UTF-8 bytes`),wl=Cl.refine(e=>e.length>0,`Text must not be empty`),Tl=W().trim().min(1).refine(e=>Buffer.byteLength(e,`utf8`)<=_l,`Completion evidence must not exceed ${_l} UTF-8 bytes`),El=K({version:yl,id:q,alias:xl,projectPath:W().min(1).refine(e=>Buffer.byteLength(e,`utf8`)<=ml,`Project path must not exceed ${ml} UTF-8 bytes`),connectedAt:gs(),lastSeenAt:gs()}).strict();vc(El).max(16),K({version:yl,type:jc(`task`),messageId:q,target:Sl,goal:wl}).strict();var Dl=K({version:yl,type:jc(`task-event`),messageId:q,taskId:q,senderId:q,recipientId:q,status:kc([`accepted`,`started`,`progress`,`completed`,`failed`,`cancelled`]),detail:Cl.optional()}).strict(),Ol=K({version:yl,type:jc(`delivery-receipt`),messageId:q,status:kc([`delivered`,`duplicate`,`rejected`]),recipientIds:vc(q).max(16),error:Cl.optional()}).strict(),kl=K({palId:q,required:fc()}).strict(),Al=vc(kl).min(2).max(16).superRefine((e,t)=>{let n=new Set;for(let[r,i]of e.entries()){let e=i.palId.toLowerCase();n.has(e)&&t.addIssue({code:`custom`,path:[r,`palId`],message:`Duplicate participant`}),n.add(e)}}),jl=K({id:W().min(1).max(128),assigneeId:q,description:wl,dependsOn:vc(W().min(1).max(128)).max(32)}).strict(),Ml=K({version:yl,coWorkId:q,epoch:G().int().positive(),goal:wl,participants:vc(kl).min(1).max(16),tasks:vc(jl).min(1).max(32)}).strict().superRefine((e,t)=>{Buffer.byteLength(JSON.stringify(e),`utf8`)>24576&&t.addIssue({code:`custom`,message:`Encoded plan must not exceed ${hl} UTF-8 bytes`});let n=new Set;for(let[r,i]of e.participants.entries())n.has(i.palId)&&t.addIssue({code:`custom`,path:[`participants`,r,`palId`],message:`Duplicate participant`}),n.add(i.palId);let r=new Set;for(let[i,a]of e.tasks.entries())r.has(a.id)&&t.addIssue({code:`custom`,path:[`tasks`,i,`id`],message:`Duplicate task id`}),r.add(a.id),n.has(a.assigneeId)||t.addIssue({code:`custom`,path:[`tasks`,i,`assigneeId`],message:`Assignee is not a participant`});for(let[n,i]of e.tasks.entries())for(let e of i.dependsOn)(!r.has(e)||e===i.id)&&t.addIssue({code:`custom`,path:[`tasks`,n,`dependsOn`],message:`Invalid task dependency`});let i=new Map(e.tasks.map(e=>[e.id,e.dependsOn])),a=new Set,o=new Set,s=e=>{if(a.has(e))return!0;if(o.has(e))return!1;a.add(e);for(let t of i.get(e)??[])if(i.has(t)&&s(t))return!0;return a.delete(e),o.add(e),!1};for(let[n,r]of e.tasks.entries())if(s(r.id)){t.addIssue({code:`custom`,path:[`tasks`,n,`dependsOn`],message:`Task dependencies must be acyclic`});break}}),Nl=kc([`proposed`,`planning`,`prepared`,`running`,`verifying`,`completed`,`failed`,`cancelled`]),Pl=K({passed:fc(),evidence:Tl}).strict(),Fl=K({participantId:q,passed:fc(),detail:Tl.optional()}).strict(),Il=K({version:yl,coWorkId:q,epoch:G().int().positive(),phase:Nl,goal:wl,participants:vc(kl).min(1).max(16),integrationOwnerId:q,acceptedParticipantIds:vc(q).max(16),planHash:W().regex(/^[a-f0-9]{64}$/).nullable(),plan:Ml.nullable(),planAcceptedParticipantIds:vc(q).max(16),readyParticipantIds:vc(q).max(16),completedParticipantIds:vc(q).max(16),completionAssertions:vc(Fl).max(16),integration:Pl.nullable()}).strict().superRefine((e,t)=>{Buffer.byteLength(JSON.stringify(e),`utf8`)>57344&&t.addIssue({code:`custom`,message:`Encoded snapshot must not exceed ${gl} UTF-8 bytes`});let n=new Set(e.participants.map(({palId:e})=>e));new Set(e.participants.filter(({required:e})=>e).map(({palId:e})=>e)).has(e.integrationOwnerId)||t.addIssue({code:`custom`,path:[`integrationOwnerId`],message:`Integration owner must be a required participant`});let r=new Set,i=0;for(let[a,o]of e.completionAssertions.entries())n.has(o.participantId)||t.addIssue({code:`custom`,path:[`completionAssertions`,a,`participantId`],message:`Assertion owner must be a participant`}),r.has(o.participantId)&&t.addIssue({code:`custom`,path:[`completionAssertions`,a,`participantId`],message:`Duplicate completion assertion`}),r.add(o.participantId),i+=Buffer.byteLength(o.detail??``,`utf8`);i>12288&&t.addIssue({code:`custom`,path:[`completionAssertions`],message:`Completion assertions must not exceed ${vl} UTF-8 bytes in aggregate`})}),J={version:yl,requestId:q};Cc(`type`,[K({...J,type:jc(`register`),authToken:W().regex(/^[a-f0-9]{64}$/).optional(),presence:El}).strict(),K({...J,type:jc(`heartbeat`)}).strict(),K({...J,type:jc(`list`)}).strict(),K({...J,type:jc(`disconnect`)}).strict(),K({...J,type:jc(`chat`),messageId:q,target:Sl,message:wl}).strict(),K({...J,type:jc(`task`),messageId:q,target:Sl,goal:wl}).strict(),K({...J,type:jc(`cowork-propose`),coWorkId:q,goal:wl,participants:Al}).strict(),K({...J,type:jc(`cowork-accept`),coWorkId:q,epoch:G().int().positive()}).strict(),K({...J,type:jc(`cowork-plan`),plan:Ml}).strict(),K({...J,type:jc(`cowork-plan-accept`),coWorkId:q,epoch:G().int().positive(),planHash:W().regex(/^[a-f0-9]{64}$/)}).strict(),K({...J,type:jc(`cowork-ready`),coWorkId:q,epoch:G().int().positive(),planHash:W().regex(/^[a-f0-9]{64}$/)}).strict(),K({...J,type:jc(`cowork-complete`),coWorkId:q,epoch:G().int().positive(),planHash:W().regex(/^[a-f0-9]{64}$/),passed:fc(),detail:Tl.optional()}).strict(),K({...J,type:jc(`cowork-integration`),coWorkId:q,epoch:G().int().positive(),planHash:W().regex(/^[a-f0-9]{64}$/),passed:fc(),evidence:Tl}).strict(),K({...J,type:jc(`cowork-get`),coWorkId:q}).strict(),K({...J,type:jc(`cowork-cancel`),coWorkId:q,reason:wl}).strict()]);var Ll=K({version:yl,type:jc(`ok`),requestId:q,data:mc()}).strict(),Y=K({version:yl,type:jc(`error`),requestId:q,code:kc([`invalid-request`,`authentication-failed`,`not-found`,`ambiguous-target`,`alias-conflict`,`invalid-transition`,`stale-epoch`,`duplicate`]),message:Cl}).strict(),X=xc([K({version:yl,type:jc(`chat-event`),messageId:q,senderId:q,recipientId:q,message:wl}).strict(),Dl,Ol,K({version:yl,type:jc(`cowork-event`),action:kc([`PROPOSE`,`PLAN`,`START`,`END`,`FAIL`,`CANCEL`]),actorId:q,coWorkId:q,epoch:G().int().positive(),planHash:W().regex(/^[a-f0-9]{64}$/).nullable(),snapshot:Il}).strict()]);Cc(`type`,[Ll,Y,K({version:yl,type:jc(`event`),event:X}).strict()]),W().refine(e=>Buffer.byteLength(e,`utf8`)<=pl,`Control frame must not exceed ${pl} UTF-8 bytes`);var Z=`model.init.config.login.logout.permissions.skills.plugins.hooks.tasks.finish.compact.clear.help.exit.audit.usage.loop.goal.evolve.mcp.commit.review.ide.memory.remember.forget.forget-cold.checkpoint.tree.rewind.unrevert.fork.pals.chat.co-work.tool`.split(`.`),Rl={model:`Switch the active model`,init:`Initialize Flavor project files`,config:`Show the resolved configuration`,login:`Authenticate via OAuth PKCE`,logout:`Clear stored OAuth credentials and restore configured models`,permissions:`Change the tool permission mode`,skills:`List discovered skills`,plugins:`List loaded plugins`,hooks:`Show plugin hook status`,tasks:`Show task planning status`,finish:`Complete this task and evaluate long-term memory`,compact:`Compact the conversation context`,clear:`Clear the transcript`,help:`Show available commands`,exit:`Exit Flavor`,audit:`Query tool failure audit log`,usage:`Show cache hit statistics for this session`,loop:`Run a verified autonomous loop toward a goal`,goal:`Run a goal pipeline with adversarial verification`,evolve:`Self-improvement loop: capture failures, suggest fixes, verify with tests`,commit:`Generate a commit message for staged changes and commit after confirmation`,review:`Review uncommitted changes for bugs and risks before committing`,mcp:`Manage MCP servers`,ide:`Show the connected IDE and editor context`,memory:`Show long-term project memory`,remember:`Add a long-term memory`,forget:`Remove matching long-term memories`,"forget-cold":`Remove all cold long-term memories and their files`,checkpoint:`Create a workspace and context checkpoint`,tree:`Show the session history tree`,rewind:`Restore a prior session node`,unrevert:`Undo the most recent rewind`,fork:`Continue context from a prior session node`,pals:`List, rename, or inspect active Flavor pals`,chat:`Send a task to another Flavor pal`,"co-work":`Coordinate a shared goal with another Flavor pal`,tool:`Run a registered managed tool with a JSON object`},zl={name:``,description:``,body:`# Instructions
136
136
 
137
137
  Describe when and how the agent should use this skill.`,disableModelInvocation:!1};function Bl({onClose:e,onError:t}){let[n,r]=(0,_.useState)([]),[i,a]=(0,_.useState)(),[o,s]=(0,_.useState)(zl),[c,l]=(0,_.useState)(!1),[u,d]=(0,_.useState)(!0),[f,p]=(0,_.useState)(!1),[m,h]=(0,_.useState)(``),[g,v]=(0,_.useState)(!1),y=(0,_.useMemo)(()=>{let e=m.trim().toLowerCase();return e.length===0?n:n.filter(t=>t.name.includes(e)||t.description.toLowerCase().includes(e))},[m,n]),b=n.filter(e=>e.enabled).length,x=c?o.name.trim().length>0||o.description.trim().length>0||o.body!==zl.body:i!==void 0&&(o.description!==i.description||o.body!==i.body||!!o.disableModelInvocation!==i.disableModelInvocation),S=e=>t(e instanceof Error?e.message:String(e)),C=async e=>{let t=await window.flavorDesktop.listSkills();r(t);let n=e??i?.name??t[0]?.name;n!==void 0&&t.some(e=>e.name===n)?await w(n):c||(a(void 0),s(zl))},w=async e=>{try{let t=await window.flavorDesktop.getSkill(e);a(t),s({name:t.name,description:t.description,body:t.body,disableModelInvocation:t.disableModelInvocation}),l(!1),v(!1)}catch(e){S(e)}};(0,_.useEffect)(()=>{let e=!0;return window.flavorDesktop.listSkills().then(async t=>{e&&(r(t),t[0]!==void 0&&await w(t[0].name))}).catch(S).finally(()=>{e&&d(!1)}),()=>{e=!1}},[]);let ee=()=>{l(!0),a(void 0),s(zl),v(!1)},te=async()=>{if(!f){p(!0);try{let e=c?await window.flavorDesktop.createSkill(o):await window.flavorDesktop.updateSkill(i.name,o);l(!1),a(e),s({name:e.name,description:e.description,body:e.body,disableModelInvocation:e.disableModelInvocation}),await C(e.name)}catch(e){S(e)}finally{p(!1)}}},ne=async(e,t)=>{r(n=>n.map(n=>n.name===e.name?{...n,enabled:t}:n)),i?.name===e.name&&a({...i,enabled:t});try{await window.flavorDesktop.setSkillEnabled(e.name,t)}catch(n){r(n=>n.map(n=>n.name===e.name?{...n,enabled:!t}:n)),i?.name===e.name&&a({...i,enabled:!t}),S(n)}},re=async()=>{if(!(i===void 0||f)){p(!0);try{await window.flavorDesktop.deleteSkill(i.name),v(!1),a(void 0),s(zl);let e=await window.flavorDesktop.listSkills();r(e),e[0]!==void 0&&await w(e[0].name)}catch(e){S(e)}finally{p(!1)}}};return(0,I.jsxs)(`section`,{className:`skill-workbench`,"aria-label":`技能管理`,children:[(0,I.jsxs)(`header`,{className:`skill-workbench-header`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`button`,{className:`skill-back`,onClick:e,"aria-label":`返回对话`,children:`‹`}),(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`p`,{children:`项目能力`}),(0,I.jsx)(`h1`,{children:`技能管理`})]})]}),(0,I.jsxs)(`div`,{className:`skill-health`,children:[(0,I.jsx)(`i`,{}),(0,I.jsxs)(`span`,{children:[(0,I.jsx)(`strong`,{children:b}),` / `,n.length,` 已开启`]})]})]}),(0,I.jsxs)(`div`,{className:`skill-workbench-body`,children:[(0,I.jsxs)(`aside`,{className:`skill-catalog`,children:[(0,I.jsxs)(`div`,{className:`skill-catalog-tools`,children:[(0,I.jsxs)(`label`,{children:[(0,I.jsx)(`span`,{children:`⌕`}),(0,I.jsx)(`input`,{value:m,onChange:e=>h(e.target.value),placeholder:`搜索技能`})]}),(0,I.jsxs)(`button`,{className:`skill-create`,onClick:ee,children:[(0,I.jsx)(`span`,{children:`+`}),` 新建技能`]})]}),(0,I.jsxs)(`div`,{className:`skill-list`,"aria-busy":u,children:[u&&(0,I.jsx)(`p`,{className:`skill-list-empty`,children:`正在读取技能…`}),!u&&y.length===0&&(0,I.jsxs)(`div`,{className:`skill-list-empty`,children:[(0,I.jsx)(`strong`,{children:`没有匹配的技能`}),(0,I.jsx)(`span`,{children:`创建一个项目技能,或调整搜索词。`})]}),y.map(e=>(0,I.jsxs)(`article`,{className:`skill-list-item`,"data-selected":!c&&i?.name===e.name,"data-enabled":e.enabled,children:[(0,I.jsxs)(`button`,{className:`skill-select`,onClick:()=>void w(e.name),children:[(0,I.jsx)(`span`,{className:`skill-glyph`,children:e.name.slice(0,1).toUpperCase()}),(0,I.jsxs)(`span`,{children:[(0,I.jsx)(`strong`,{children:e.name}),(0,I.jsx)(`small`,{children:e.description})]})]}),(0,I.jsxs)(`label`,{className:`skill-toggle`,title:e.enabled?`关闭后 Agent 无法读取`:`开启后 Agent 可以读取`,children:[(0,I.jsx)(`input`,{type:`checkbox`,checked:e.enabled,onChange:t=>void ne(e,t.target.checked)}),(0,I.jsx)(`span`,{})]})]},e.name))]}),(0,I.jsxs)(`p`,{className:`skill-catalog-note`,children:[`启停状态保存在 `,(0,I.jsx)(`code`,{children:`.flavor/flavor.json`})]})]}),(0,I.jsx)(`main`,{className:`skill-editor`,children:i===void 0&&!c?(0,I.jsxs)(`div`,{className:`skill-editor-empty`,children:[(0,I.jsx)(`span`,{children:`◇`}),(0,I.jsx)(`h2`,{children:`选择或创建一个技能`}),(0,I.jsx)(`p`,{children:`技能会在任务匹配时为 Agent 注入专门的工作说明。`})]}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`div`,{className:`skill-editor-heading`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`p`,{children:c?`新建项目技能`:i?.editable?`项目技能`:i?.source===`global`?`全局技能`:`插件技能`}),(0,I.jsx)(`h2`,{children:c?`定义一项新能力`:i?.name})]}),!c&&i!==void 0&&(0,I.jsxs)(`span`,{className:`skill-status`,"data-enabled":i.enabled,children:[(0,I.jsx)(`i`,{}),i.enabled?`Agent 可读取`:`已隔离`]})]}),!c&&i?.editable===!1&&(0,I.jsx)(`div`,{className:`skill-readonly-note`,children:`此技能由全局目录或插件提供,在此项目中只读。你仍可以为当前项目开启或关闭它。`}),(0,I.jsxs)(`div`,{className:`skill-form`,children:[(0,I.jsxs)(`label`,{children:[(0,I.jsxs)(`span`,{children:[`名称 `,(0,I.jsx)(`small`,{children:`小写字母、数字和连字符`})]}),(0,I.jsx)(`input`,{value:o.name,disabled:!c,onChange:e=>s({...o,name:e.target.value}),placeholder:`code-review`})]}),(0,I.jsxs)(`label`,{children:[(0,I.jsxs)(`span`,{children:[`描述 `,(0,I.jsx)(`small`,{children:`帮助 Agent 判断何时使用`})]}),(0,I.jsx)(`textarea`,{rows:3,value:o.description,disabled:!c&&!i?.editable,onChange:e=>s({...o,description:e.target.value}),placeholder:`在提交代码前检查正确性、安全性与可维护性`})]}),(0,I.jsxs)(`label`,{className:`skill-instructions`,children:[(0,I.jsxs)(`span`,{children:[`SKILL.md 指令 `,(0,I.jsx)(`small`,{children:`支持 Markdown`})]}),(0,I.jsx)(`textarea`,{value:o.body,disabled:!c&&!i?.editable,onChange:e=>s({...o,body:e.target.value}),spellCheck:!1})]}),(0,I.jsxs)(`label`,{className:`manual-invocation`,children:[(0,I.jsx)(`input`,{type:`checkbox`,checked:!!o.disableModelInvocation,disabled:!c&&!i?.editable,onChange:e=>s({...o,disableModelInvocation:e.target.checked})}),(0,I.jsxs)(`span`,{children:[(0,I.jsx)(`strong`,{children:`仅允许手动调用`}),(0,I.jsxs)(`small`,{children:[`开启技能,但不让 Agent 自动匹配;仍可通过 /`,o.name||`skill-name`,` 调用。`]})]})]})]}),(0,I.jsxs)(`footer`,{className:`skill-editor-actions`,children:[!c&&i?.editable&&(0,I.jsx)(`button`,{className:`skill-delete`,onClick:()=>v(!0),children:`删除技能`}),c&&(0,I.jsx)(`button`,{onClick:()=>{l(!1),C()},children:`取消`}),(c||i?.editable)&&(0,I.jsx)(`button`,{className:`skill-save`,disabled:!x||f||!o.name.trim()||!o.description.trim()||!o.body.trim(),onClick:()=>void te(),children:f?`正在保存…`:c?`创建技能`:`保存更改`})]})]})})]}),g&&i!==void 0&&(0,I.jsx)(`div`,{className:`skill-delete-layer`,children:(0,I.jsxs)(`div`,{className:`skill-delete-dialog`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`skill-delete-title`,children:[(0,I.jsx)(`span`,{children:`!`}),(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`p`,{children:`删除项目技能`}),(0,I.jsxs)(`h2`,{id:`skill-delete-title`,children:[`删除“`,i.name,`”?`]}),(0,I.jsx)(`small`,{children:`技能目录及其中的资源会被永久删除,此操作无法撤销。`}),(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`button`,{onClick:()=>v(!1),children:`取消`}),(0,I.jsx)(`button`,{className:`danger`,disabled:f,onClick:()=>void re(),children:f?`正在删除…`:`删除技能`})]})]})]})})]})}var Vl={user:{label:`用户偏好`,hint:`长期稳定的角色、表达和工作偏好`},feedback:{label:`行为反馈`,hint:`希望 Agent 以后持续遵守的纠正`},project:{label:`项目约定`,hint:`不能只靠代码推导出的规则和决策`},reference:{label:`外部引用`,hint:`以后仍会用到的文档或系统入口`}},Hl={enabled:!0,path:``,entries:[]},Ul={type:`project`,content:``};function Wl({heat:e=`normal`,recallTotal:t=0}){return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`span`,{className:`memory-heat-badge`,"data-heat":e,children:e}),(0,I.jsxs)(`span`,{className:`memory-recall-count`,children:[`↻ `,t]})]})}function Gl({onClose:e,onError:t}){let[n,r]=(0,_.useState)(Hl),[i,a]=(0,_.useState)(),[o,s]=(0,_.useState)(Ul),[c,l]=(0,_.useState)(!1),[u,d]=(0,_.useState)(!0),[f,p]=(0,_.useState)(!1),[m,h]=(0,_.useState)(``),[g,v]=(0,_.useState)(`all`),[y,b]=(0,_.useState)(`all`),[x,S]=(0,_.useState)(!1),C=e=>t(e instanceof Error?e.message:String(e)),w=(0,_.useMemo)(()=>{let e=m.trim().toLocaleLowerCase();return n.entries.filter(t=>(g===`all`||t.type===g)&&(y===`all`||t.heat===y)&&(e.length===0||t.content.toLocaleLowerCase().includes(e)||t.id.includes(e)))},[g,y,m,n.entries]),ee=c?o.content.trim().length>0:i!==void 0&&(o.type!==i.type||o.content!==i.content),te=(e,t)=>{let n=e.entries.find(e=>e.id===t)??e.entries.find(e=>e.id===i?.id)??e.entries[0];a(n),s(n===void 0?Ul:{type:n.type,content:n.content})},ne=async e=>{let t=await window.flavorDesktop.listMemory();return r(t),te(t,e),t};(0,_.useEffect)(()=>{let e=!0;return window.flavorDesktop.listMemory().then(t=>{e&&(r(t),te(t))}).catch(C).finally(()=>{e&&d(!1)}),()=>{e=!1}},[]);let re=()=>{l(!0),a(void 0),s(Ul),S(!1)},ie=e=>{l(!1),a(e),s({type:e.type,content:e.content}),S(!1)},ae=async()=>{if(!(f||o.content.trim().length===0)){p(!0);try{let e=c?await window.flavorDesktop.createMemory(o):await window.flavorDesktop.updateMemory(i.id,o);l(!1),await ne(e.id)}catch(e){C(e)}finally{p(!1)}}},oe=async()=>{if(!(i===void 0||f)){p(!0);try{if(!await window.flavorDesktop.deleteMemory(i.id))throw Error(`这条记忆已不存在,请重新载入后再试。`);S(!1),a(void 0),s(Ul),await ne()}catch(e){C(e)}finally{p(!1)}}},se=async()=>{let e=n.entries.filter(e=>e.heat===`cold`).length;if(!(e===0||!window.confirm(`删除全部 ${e} 条 cold 记忆?此操作不可撤销。`))){p(!0);try{await window.flavorDesktop.deleteColdMemory(),a(void 0),await ne()}catch(e){C(e)}finally{p(!1)}}};return(0,I.jsxs)(`section`,{className:`memory-workbench`,"aria-label":`长期记忆管理`,children:[(0,I.jsxs)(`header`,{className:`memory-workbench-header`,children:[(0,I.jsxs)(`div`,{className:`memory-heading`,children:[(0,I.jsx)(`button`,{className:`memory-back`,onClick:e,"aria-label":`返回对话`,children:`‹`}),(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`p`,{children:`项目上下文`}),(0,I.jsx)(`h1`,{children:`长期记忆`})]})]}),(0,I.jsxs)(`div`,{className:`memory-header-actions`,children:[(0,I.jsxs)(`div`,{className:`memory-ledger-status`,"data-enabled":n.enabled,children:[(0,I.jsx)(`i`,{}),(0,I.jsxs)(`span`,{children:[(0,I.jsx)(`strong`,{children:n.entries.length}),` 条记忆`]})]}),(0,I.jsx)(`button`,{className:`memory-purge-cold`,disabled:f||!n.entries.some(e=>e.heat===`cold`),onClick:()=>void se(),children:`清理 cold`})]})]}),(0,I.jsxs)(`div`,{className:`memory-workbench-body`,children:[(0,I.jsxs)(`aside`,{className:`memory-catalog`,children:[(0,I.jsxs)(`div`,{className:`memory-catalog-tools`,children:[(0,I.jsxs)(`label`,{children:[(0,I.jsx)(`span`,{children:`⌕`}),(0,I.jsx)(`input`,{"aria-label":`搜索记忆`,value:m,onChange:e=>h(e.target.value),placeholder:`搜索记忆`})]}),(0,I.jsxs)(`button`,{className:`memory-create`,onClick:re,disabled:!n.enabled,children:[(0,I.jsx)(`span`,{children:`+`}),` 新建记忆`]})]}),(0,I.jsxs)(`div`,{className:`memory-index`,"aria-label":`按类型筛选`,children:[(0,I.jsxs)(`button`,{"data-active":g===`all`,onClick:()=>v(`all`),children:[(0,I.jsx)(`span`,{children:`全部`}),(0,I.jsx)(`b`,{children:n.entries.length})]}),dl.map(e=>(0,I.jsxs)(`button`,{"data-type":e,"data-active":g===e,onClick:()=>v(e),children:[(0,I.jsx)(`span`,{children:Vl[e].label}),(0,I.jsx)(`b`,{children:n.entries.filter(t=>t.type===e).length})]},e))]}),(0,I.jsx)(`div`,{className:`memory-heat-index`,"aria-label":`按热度筛选`,children:[`all`,`hot`,`normal`,`cold`].map(e=>(0,I.jsxs)(`button`,{"data-active":y===e,"data-heat":e,onClick:()=>b(e),children:[e===`all`?`全部热度`:e,(0,I.jsx)(`b`,{children:e===`all`?n.entries.length:n.entries.filter(t=>t.heat===e).length})]},e))}),(0,I.jsxs)(`div`,{className:`memory-list`,"aria-busy":u,children:[u&&(0,I.jsx)(`p`,{className:`memory-list-empty`,children:`正在读取记忆…`}),!u&&!n.enabled&&(0,I.jsxs)(`div`,{className:`memory-list-empty`,children:[(0,I.jsx)(`strong`,{children:`长期记忆已关闭`}),(0,I.jsx)(`span`,{children:`在项目配置中将 memory.enabled 设为 true 后可维护。`})]}),!u&&n.enabled&&w.length===0&&(0,I.jsxs)(`div`,{className:`memory-list-empty`,children:[(0,I.jsx)(`strong`,{children:n.entries.length===0?`还没有长期记忆`:`没有匹配项`}),(0,I.jsx)(`span`,{children:n.entries.length===0?`新建一条明确、稳定、以后仍有用的信息。`:`尝试其他关键词或类型。`})]}),w.map(e=>(0,I.jsxs)(`button`,{className:`memory-card`,"data-selected":!c&&i?.id===e.id,"data-type":e.type,onClick:()=>ie(e),children:[(0,I.jsxs)(`span`,{className:`memory-card-meta`,children:[(0,I.jsx)(`span`,{className:`memory-card-tab`,children:Vl[e.type].label}),(0,I.jsx)(Wl,{heat:e.heat,recallTotal:e.recallTotal})]}),(0,I.jsx)(`strong`,{children:e.content}),(0,I.jsx)(`code`,{children:e.id})]},e.id))]}),(0,I.jsxs)(`p`,{className:`memory-catalog-note`,children:[`存储于 `,(0,I.jsx)(`code`,{children:n.path||`.flavor/memory/MEMORY.md`})]})]}),(0,I.jsx)(`main`,{className:`memory-editor`,children:n.enabled?i===void 0&&!c?(0,I.jsxs)(`div`,{className:`memory-editor-empty`,children:[(0,I.jsx)(`span`,{children:`⌁`}),(0,I.jsx)(`h2`,{children:`建立项目的共同记忆`}),(0,I.jsx)(`p`,{children:`保存少量稳定事实。当前指令和仓库内容始终优先。`}),(0,I.jsx)(`button`,{onClick:re,children:`新建第一条记忆`})]}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`div`,{className:`memory-editor-heading`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`p`,{children:c?`新记忆`:`记忆 ${i?.id}`}),(0,I.jsx)(`h2`,{children:c?`记录一件以后仍有用的事`:Vl[o.type].label})]}),(0,I.jsx)(`span`,{className:`memory-type-seal`,"data-type":o.type,children:o.type})]}),(0,I.jsxs)(`div`,{className:`memory-priority-note`,children:[(0,I.jsx)(`span`,{children:`i`}),(0,I.jsx)(`p`,{children:`记忆是历史背景,不是强制指令。新建或修改后,从下一次模型请求开始生效。`})]}),(0,I.jsxs)(`div`,{className:`memory-form`,children:[(0,I.jsxs)(`fieldset`,{children:[(0,I.jsx)(`legend`,{children:`记忆类型`}),(0,I.jsx)(`div`,{className:`memory-type-options`,children:dl.map(e=>(0,I.jsxs)(`label`,{"data-type":e,"data-selected":o.type===e,children:[(0,I.jsx)(`input`,{type:`radio`,name:`memory-type`,value:e,checked:o.type===e,onChange:()=>s({...o,type:e})}),(0,I.jsxs)(`span`,{children:[(0,I.jsx)(`strong`,{children:Vl[e].label}),(0,I.jsx)(`small`,{children:Vl[e].hint})]})]},e))})]}),(0,I.jsxs)(`label`,{className:`memory-content-field`,children:[(0,I.jsxs)(`span`,{children:[`内容 `,(0,I.jsx)(`small`,{children:`只写一件事,避免密码、Token 和临时任务状态`})]}),(0,I.jsx)(`textarea`,{autoFocus:!0,value:o.content,maxLength:2e4,onChange:e=>s({...o,content:e.target.value}),placeholder:`例如:不要在未明确要求时创建 Git 提交。`}),(0,I.jsxs)(`em`,{children:[o.content.length,` 字符`]})]})]}),(0,I.jsxs)(`footer`,{className:`memory-editor-actions`,children:[!c&&(0,I.jsx)(`button`,{className:`memory-delete`,onClick:()=>S(!0),children:`删除记忆`}),c&&(0,I.jsx)(`button`,{onClick:()=>{l(!1),ne()},children:`取消`}),(0,I.jsx)(`button`,{className:`memory-save`,disabled:!ee||f||o.content.trim().length===0,onClick:()=>void ae(),children:f?`正在保存…`:c?`保存记忆`:`保存更改`})]})]}):(0,I.jsxs)(`div`,{className:`memory-editor-empty`,children:[(0,I.jsx)(`span`,{children:`⊘`}),(0,I.jsx)(`h2`,{children:`长期记忆没有启用`}),(0,I.jsx)(`p`,{children:`启用后才能读取和修改项目记忆。`})]})})]}),x&&i!==void 0&&(0,I.jsx)(`div`,{className:`memory-delete-layer`,children:(0,I.jsxs)(`div`,{className:`memory-delete-dialog`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`memory-delete-title`,children:[(0,I.jsx)(`span`,{children:`!`}),(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`p`,{children:`删除长期记忆`}),(0,I.jsxs)(`h2`,{id:`memory-delete-title`,children:[`删除这条`,Vl[i.type].label,`?`]}),(0,I.jsx)(`small`,{children:i.content}),(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`button`,{onClick:()=>S(!1),children:`取消`}),(0,I.jsx)(`button`,{className:`danger`,disabled:f,onClick:()=>void oe(),children:f?`正在删除…`:`删除记忆`})]})]})]})})]})}var Kl={name:``,transport:`stdio`,enabled:!0,command:``,args:``,env:``,cwd:``,url:``,headers:``,timeoutMs:`60000`};function ql({onClose:e,onError:t}){let[n,r]=(0,_.useState)([]),[i,a]=(0,_.useState)(),[o,s]=(0,_.useState)(Kl),[c,l]=(0,_.useState)(!1),[u,d]=(0,_.useState)(!0),[f,p]=(0,_.useState)(!1),[m,h]=(0,_.useState)(``),[g,v]=(0,_.useState)(),y=(0,_.useMemo)(()=>{let e=m.trim().toLowerCase();return e===``?n:n.filter(t=>t.name.toLowerCase().includes(e)||t.transport.includes(e))},[m,n]),b=async e=>{let t=await window.flavorDesktop.listMcpServers();r(t);let n=t.find(t=>t.name===e)??t.find(e=>e.name===i)??t[0];n===void 0?t.length===0&&a(void 0):(a(n.name),s(Jl(n)))};(0,_.useEffect)(()=>{let e=!1;return window.flavorDesktop.listMcpServers().then(t=>{if(e)return;r(t);let n=t[0];n!==void 0&&(a(n.name),s(Jl(n)))}).catch(n=>{e||t(tu(n))}).finally(()=>{e||d(!1)}),()=>{e=!0}},[]);let x=e=>{l(!1),a(e.name),s(Jl(e))},S=()=>{l(!0),a(void 0),s(Kl)},C=async()=>{p(!0);try{let e=await window.flavorDesktop.saveMcpServer(c?void 0:i,Yl(o));l(!1),a(e.name),await b(e.name)}catch(e){t(tu(e))}finally{p(!1)}},w=async(e,n)=>{try{let t=await window.flavorDesktop.setMcpServerEnabled(e.name,n);r(e=>e.map(e=>e.name===t.name?t:e)),i===t.name&&s(Jl(t))}catch(e){t(tu(e))}},ee=async()=>{let e=g;if(e!==void 0){p(!0);try{await window.flavorDesktop.deleteMcpServer(e.name),v(void 0),l(!1),a(void 0),s(Kl),await b()}catch(e){t(tu(e))}finally{p(!1)}}},te=n.find(e=>e.name===i);return(0,I.jsxs)(`section`,{className:`mcp-workbench`,"aria-label":`MCP 服务管理`,children:[(0,I.jsxs)(`header`,{className:`mcp-workbench-header`,children:[(0,I.jsxs)(`div`,{className:`mcp-heading`,children:[(0,I.jsx)(`button`,{className:`mcp-back`,onClick:e,"aria-label":`返回对话`,children:`‹`}),(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`p`,{children:`PROJECT CONNECTIONS`}),(0,I.jsx)(`h1`,{children:`MCP 服务`})]})]}),(0,I.jsxs)(`div`,{className:`mcp-health`,children:[(0,I.jsx)(`i`,{}),`项目配置 `,(0,I.jsx)(`strong`,{children:n.filter(e=>e.enabled).length}),` 已开启`]})]}),(0,I.jsxs)(`div`,{className:`mcp-workbench-body`,children:[(0,I.jsxs)(`aside`,{className:`mcp-catalog`,children:[(0,I.jsxs)(`div`,{className:`mcp-catalog-tools`,children:[(0,I.jsxs)(`label`,{children:[(0,I.jsx)(`span`,{children:`⌕`}),(0,I.jsx)(`input`,{value:m,onChange:e=>h(e.target.value),placeholder:`搜索服务`,"aria-label":`搜索服务`})]}),(0,I.jsxs)(`button`,{className:`mcp-create`,onClick:S,children:[(0,I.jsx)(`span`,{children:`+`}),`添加服务`]})]}),(0,I.jsx)(`div`,{className:`mcp-list`,children:u?(0,I.jsxs)(`div`,{className:`mcp-list-empty`,children:[(0,I.jsx)(`strong`,{children:`正在读取项目配置`}),(0,I.jsx)(`span`,{children:`.flavor/flavor.json`})]}):y.length===0?(0,I.jsxs)(`div`,{className:`mcp-list-empty`,children:[(0,I.jsx)(`strong`,{children:m?`没有匹配的服务`:`还没有项目 MCP 服务`}),(0,I.jsx)(`span`,{children:m?`尝试其他名称或传输类型`:`添加 stdio 或 Streamable HTTP 服务`})]}):y.map(e=>(0,I.jsxs)(`div`,{className:`mcp-list-item`,"data-selected":!c&&i===e.name,"data-transport":e.transport,"data-enabled":e.enabled,children:[(0,I.jsxs)(`button`,{className:`mcp-select`,onClick:()=>x(e),children:[(0,I.jsx)(`span`,{className:`mcp-transport-glyph`,children:e.transport===`stdio`?`>_`:`↗`}),(0,I.jsxs)(`span`,{children:[(0,I.jsx)(`strong`,{children:e.name}),(0,I.jsx)(`small`,{children:e.transport===`stdio`?$l(e.config):eu(e.config)})]})]}),(0,I.jsxs)(`label`,{className:`mcp-toggle`,title:e.enabled?`关闭服务`:`开启服务`,children:[(0,I.jsx)(`input`,{type:`checkbox`,checked:e.enabled,onChange:t=>void w(e,t.target.checked),"aria-label":`${e.enabled?`关闭`:`开启`} ${e.name}`}),(0,I.jsx)(`span`,{})]})]},e.name))}),(0,I.jsxs)(`p`,{className:`mcp-catalog-note`,children:[`仅管理项目配置 `,(0,I.jsx)(`code`,{children:`.flavor/flavor.json`})]})]}),(0,I.jsx)(`article`,{className:`mcp-editor`,children:c||te!==void 0?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`div`,{className:`mcp-editor-heading`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`p`,{children:c?`NEW CONNECTION`:`SERVICE CONFIGURATION`}),(0,I.jsx)(`h2`,{children:c?`添加 MCP 服务`:i})]}),(0,I.jsx)(`span`,{className:`mcp-transport-seal`,"data-transport":o.transport,children:o.transport})]}),(0,I.jsxs)(`div`,{className:`mcp-lifecycle-note`,children:[(0,I.jsx)(`span`,{children:`↻`}),(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`strong`,{children:`从下一个任务开始生效`}),(0,I.jsx)(`small`,{children:`现有对话不会因配置更改而中断。`})]})]}),(0,I.jsxs)(`form`,{className:`mcp-form`,onSubmit:e=>{e.preventDefault(),C()},children:[(0,I.jsxs)(`div`,{className:`mcp-form-grid`,children:[(0,I.jsxs)(`label`,{children:[(0,I.jsxs)(`span`,{children:[`服务名称 `,(0,I.jsx)(`small`,{children:`字母、数字、_ 或 -`})]}),(0,I.jsx)(`input`,{value:o.name,onChange:e=>s({...o,name:e.target.value}),required:!0,pattern:`[A-Za-z0-9_-]+`})]}),(0,I.jsxs)(`label`,{children:[(0,I.jsx)(`span`,{children:`传输方式`}),(0,I.jsxs)(`select`,{value:o.transport,onChange:e=>s({...o,transport:e.target.value}),children:[(0,I.jsx)(`option`,{value:`stdio`,children:`stdio · 本地进程`}),(0,I.jsx)(`option`,{value:`http`,children:`HTTP · 远程服务`})]})]})]}),o.transport===`stdio`?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`label`,{children:[(0,I.jsx)(`span`,{children:`启动命令`}),(0,I.jsx)(`input`,{value:o.command,onChange:e=>s({...o,command:e.target.value}),placeholder:`npx`,required:!0})]}),(0,I.jsxs)(`label`,{children:[(0,I.jsxs)(`span`,{children:[`参数 `,(0,I.jsx)(`small`,{children:`每行一个参数`})]}),(0,I.jsx)(`textarea`,{rows:4,value:o.args,onChange:e=>s({...o,args:e.target.value}),placeholder:`-y
138
138
  @modelcontextprotocol/server-filesystem
@@ -147,8 +147,8 @@ Describe when and how the agent should use this skill.`,disableModelInvocation:!
147
147
  `).length+3)),value:we,onChange:e=>Te(e.target.value),onDoubleClick:e=>e.stopPropagation(),spellCheck:!1})]}):(0,I.jsx)(Jt,{text:yu(e)})},e.id)})??(D.prdMarkdown!==void 0&&(0,I.jsx)(Jt,{text:D.prdMarkdown}))}),(0,I.jsxs)(`section`,{className:`d2c-prd-regenerate`,children:[(0,I.jsx)(`header`,{children:(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`strong`,{children:`需要整体调整?`}),(0,I.jsx)(`span`,{children:`描述期望变化,AI 会基于当前 PRD 生成一份新草案。`})]})}),(0,I.jsx)(`textarea`,{rows:3,value:be,"aria-label":`PRD 重新生成要求`,placeholder:`例如:保留现有范围,补充退款失败后的恢复流程`,onChange:e=>xe(e.target.value)}),(0,I.jsxs)(`footer`,{children:[(0,I.jsx)(`span`,{children:`当前版本不会在生成过程中被覆盖`}),(0,I.jsxs)(`button`,{type:`button`,className:`d2c-prd-regenerate-button`,disabled:Ee||s||be.trim().length===0,onClick:()=>void on(),children:[(0,I.jsx)(`i`,{"aria-hidden":`true`,children:`↻`}),`重新生成 PRD`]})]})]}),(0,I.jsxs)(`label`,{children:[(0,I.jsx)(`span`,{children:`退回意见`}),(0,I.jsx)(`textarea`,{rows:3,value:ve,placeholder:`例如:补充退款失败后的恢复路径`,onChange:e=>ye(e.target.value)})]}),(0,I.jsxs)(`div`,{className:`d2c-artifact-actions`,children:[(0,I.jsx)(`button`,{type:`button`,disabled:Ee||s||ve.trim().length===0,onClick:()=>void an(`prd`,!1),children:`退回修改`}),(0,I.jsx)(`button`,{type:`button`,className:`primary`,disabled:Ee||s,onClick:()=>void an(`prd`,!0),children:`确认 PRD,生成交互稿`})]})]}),D?.plan.phase===`design-generating`&&(0,I.jsxs)(`div`,{className:`d2c-artifact-wait`,"data-invalid":D.validationError?.stage===`design`,"aria-live":`polite`,children:[(0,I.jsx)(`i`,{}),(0,I.jsx)(`div`,{children:D.validationError?.stage===`design`?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`strong`,{children:`交互契约未通过预检`}),(0,I.jsx)(`span`,{children:D.validationError.message})]}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`strong`,{children:`正在生成可交互体验基线`}),(0,I.jsx)(`span`,{children:`视觉、关键状态和行为契约会一起落盘。`})]})}),D.validationError?.stage===`design`?(0,I.jsx)(`button`,{type:`button`,disabled:Ee||s,onClick:()=>void At(),children:`自动修复清单`}):(0,I.jsx)(`button`,{type:`button`,onClick:()=>void nn(D.plan.task),children:`刷新`})]}),D?.plan.phase===`design-review`&&(0,I.jsxs)(`div`,{className:`d2c-artifact-review d2c-design-review`,children:[(0,I.jsxs)(`header`,{children:[(0,I.jsx)(`span`,{children:`INTERACTIVE PROTOTYPE`}),(0,I.jsx)(`h3`,{children:`直接体验,再决定是否开发`}),(0,I.jsx)(`p`,{children:`点击、输入并检查主流程和异常状态;确认后它会成为 E2E 中 D2C 视觉还原的设计基线。`})]}),(0,I.jsx)(Vu,{url:ge.url,onStart:()=>void en(D.plan.task)}),(0,I.jsxs)(`div`,{className:`d2c-prototype-tools`,children:[(0,I.jsx)(`span`,{children:ge.running?`● LOOPBACK PREVIEW`:`PREVIEW STOPPED`}),ge.running&&(0,I.jsx)(`button`,{type:`button`,onClick:()=>void window.flavorDesktop.openD2cProductPreview(D.plan.task),children:`浏览器打开`})]}),(0,I.jsxs)(`label`,{children:[(0,I.jsx)(`span`,{children:`退回意见`}),(0,I.jsx)(`textarea`,{rows:3,value:ve,placeholder:`例如:筛选结果缺少空状态,趋势图悬停信息不够明确`,onChange:e=>ye(e.target.value)})]}),(0,I.jsxs)(`div`,{className:`d2c-artifact-actions`,children:[(0,I.jsx)(`button`,{type:`button`,disabled:Ee||s||ve.trim().length===0,onClick:()=>void an(`design`,!1),children:`退回修改`}),(0,I.jsx)(`button`,{type:`button`,className:`primary`,disabled:Ee||s,onClick:()=>void an(`design`,!0),children:`确认设计,进入 D2C 视觉还原`})]})]}),D?.plan.phase===`ready-for-d2c`&&(0,I.jsxs)(`div`,{className:`d2c-artifact-wait`,"data-ready":`true`,children:[(0,I.jsx)(`i`,{}),(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`strong`,{children:`设计基线已确认`}),(0,I.jsx)(`span`,{children:`如果生成任务未启动或应用曾关闭,可从这里安全地继续 D2C 视觉还原。`})]}),(0,I.jsx)(`button`,{type:`button`,disabled:Ee||s,onClick:()=>void an(`design`,!0),children:`继续视觉还原 →`})]}),s&&(0,I.jsx)(`p`,{className:`d2c-start-warning`,children:`当前会话正在执行其他任务,完成或中断后可开始 E2E。`})]})]}):xn===`pending`&&a!==void 0?(0,I.jsx)(Ju,{pending:a,onOpenLog:e,onInterrupt:t}):(ke===`integration`||ke===`acceptance`)&&A.running&&A.url!==void 0?(0,I.jsxs)(`main`,{className:`d2c-live-preview`,"aria-label":`Interactive integration preview`,children:[(0,I.jsxs)(`header`,{className:`d2c-live-toolbar`,children:[(0,I.jsxs)(`span`,{className:`d2c-live-state`,children:[(0,I.jsx)(`i`,{}),` LIVE`]}),(0,I.jsx)(`code`,{title:A.url,children:A.url}),(0,I.jsx)(`button`,{type:`button`,onClick:()=>ut(e=>e+1),children:`Refresh`}),(0,I.jsx)(`button`,{type:`button`,onClick:()=>void window.flavorDesktop.openD2cPreview(u.report.task),children:`Open in browser`})]}),(0,I.jsx)(Hu,{url:A.url,reloadKey:lt,task:u.report.task})]}):(0,I.jsxs)(`main`,{className:`d2c-canvas-area`,"data-pages":_n.length>1?`multiple`:`single`,children:[u!==void 0&&Tt!==void 0&&fn!==void 0&&pn!==void 0&&(0,I.jsxs)(I.Fragment,{children:[_n.length>1&&(0,I.jsxs)(`nav`,{className:`d2c-page-rail`,"aria-label":`页面评测结果`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`strong`,{children:`页面`}),(0,I.jsx)(`span`,{children:u.report.page===void 0?``:`${u.report.page.index+1} / ${u.report.page.count}`})]}),(0,I.jsx)(`div`,{children:_n.map(e=>(0,I.jsxs)(`button`,{type:`button`,"aria-pressed":e.reportId===u.report.reportId,"data-selected":e.reportId===u.report.reportId,"data-status":e.evaluationStatus,onClick:()=>void Ot(e),children:[(0,I.jsx)(`span`,{children:e.page?.label??e.reportId}),(0,I.jsx)(`small`,{children:e.evaluationStatus===`invalid`?`待重测`:`${e.total.toFixed(1)} · ${e.issueCount} 项`})]},e.reportId))})]}),(0,I.jsxs)(`div`,{className:`d2c-trust-bar`,"data-status":pn.status,children:[(0,I.jsx)(`strong`,{children:Nu[pn.verdict]}),(0,I.jsx)(`span`,{children:pn.summary}),(0,I.jsx)(`div`,{children:pn.checks.map(e=>(0,I.jsxs)(`span`,{"data-status":e.status,title:e.message,children:[e.status===`pass`?`✓`:e.status===`warn`?`!`:`×`,` `,e.label]},e.key))})]}),(0,I.jsxs)(`div`,{className:`d2c-canvas-toolbar`,children:[(0,I.jsx)(`div`,{className:`d2c-mode-switch`,role:`tablist`,"aria-label":`画布显示模式`,children:mn.map(e=>(0,I.jsx)(`button`,{role:`tab`,"aria-selected":g===e,"data-active":g===e,onClick:()=>v(e),children:Mu[e]},e))}),g===`overlay`&&(0,I.jsxs)(`label`,{className:`d2c-opacity d2c-opacity-overlay`,children:[(0,I.jsxs)(`span`,{children:[`实现 `,Math.round(y*100),`%`]}),(0,I.jsx)(`input`,{type:`range`,min:0,max:100,value:Math.round(y*100),onChange:e=>b(Number(e.target.value)/100)})]}),g===`wipe`&&(0,I.jsxs)(`label`,{className:`d2c-opacity d2c-opacity-wipe`,children:[(0,I.jsxs)(`span`,{children:[`分界 `,x,`%`]}),(0,I.jsx)(`input`,{type:`range`,min:0,max:100,value:x,onChange:e=>S(Number(e.target.value))})]}),(0,I.jsxs)(`div`,{className:`d2c-zoom-tools`,"aria-label":`缩放控制`,children:[(0,I.jsx)(`button`,{onClick:()=>Lt(1/1.2),"aria-label":`缩小`,children:`−`}),(0,I.jsx)(`button`,{onClick:zt,children:`100%`}),(0,I.jsx)(`button`,{onClick:Dt,children:`适应`}),(0,I.jsx)(`button`,{onClick:()=>Lt(1.2),"aria-label":`放大`,children:`+`}),(0,I.jsxs)(`output`,{children:[Math.round(pt.scale*100),`%`]})]})]}),(0,I.jsxs)(`div`,{className:`d2c-canvas-viewport`,ref:ht,tabIndex:0,"aria-label":`差异画布。滚轮缩放,拖动平移,F 适应,0 显示 100%。`,onWheel:e=>{e.preventDefault();let t=e.currentTarget.getBoundingClientRect();Lt(Math.exp(-e.deltaY*.0015),{x:e.clientX-t.left,y:e.clientY-t.top},!1),xt.current!==void 0&&clearTimeout(xt.current),xt.current=setTimeout(()=>{mt({...yt.current}),xt.current=void 0},120)},onPointerDown:e=>{e.button===0&&(e.currentTarget.setPointerCapture(e.pointerId),St.current={pointerId:e.pointerId,x:e.clientX,y:e.clientY,originX:yt.current.x,originY:yt.current.y},e.currentTarget.dataset.dragging=`true`)},onPointerMove:e=>{let t=St.current;t===void 0||t.pointerId!==e.pointerId||Et({...yt.current,x:t.originX+e.clientX-t.x,y:t.originY+e.clientY-t.y},!1)},onPointerUp:e=>{St.current?.pointerId===e.pointerId&&(St.current=void 0,e.currentTarget.dataset.dragging=`false`,mt({...yt.current}))},onKeyDown:e=>{if(e.key===`+`||e.key===`=`)Lt(1.2);else if(e.key===`-`)Lt(1/1.2);else if(e.key===`0`)zt();else if(e.key.toLowerCase()===`f`)Dt();else if(e.key.toLowerCase()===`b`&&Ct.current===void 0)Ct.current=g,v(`blink`);else if(/^[1-6]$/.test(e.key)){let t=mn[Number(e.key)-1];t!==void 0&&v(t)}},onKeyUp:e=>{e.key.toLowerCase()===`b`&&Ct.current!==void 0&&(v(Ct.current),Ct.current=void 0)},children:[(0,I.jsxs)(`div`,{className:`d2c-canvas-stage d2c-mode-${g}`,ref:vt,style:{width:Tt.width,height:Tt.height,"--d2c-scale":pt.scale,"--d2c-x":`${pt.x}px`,"--d2c-y":`${pt.y}px`,"--d2c-impl-opacity":y,"--d2c-wipe":`${x}%`},children:[(0,I.jsx)(`img`,{className:`d2c-layer d2c-layer-design`,src:u.designPng,alt:`设计稿截图`,draggable:!1}),(0,I.jsx)(`img`,{className:`d2c-layer d2c-layer-impl`,src:u.implementationPng,alt:`实现截图`,draggable:!1}),(0,I.jsx)(`img`,{className:`d2c-layer d2c-layer-heatmap`,src:u.heatmapPng,alt:`像素差异热力图`,draggable:!1}),pn.status===`invalid`&&(0,I.jsx)(`div`,{className:`d2c-invalid-capture-badge`,children:`错误现场 · 不参与评分`}),g===`wipe`&&(0,I.jsx)(`button`,{className:`d2c-wipe-handle`,"aria-label":`拖动拉帘分界,当前 ${Math.round(x)}%`,onPointerDown:e=>{e.stopPropagation(),e.currentTarget.setPointerCapture(e.pointerId)},onPointerMove:e=>{e.currentTarget.hasPointerCapture(e.pointerId)&&Rt(e.clientX,!1)},onPointerUp:e=>{Rt(e.clientX,!0),e.currentTarget.releasePointerCapture(e.pointerId)},children:(0,I.jsx)(`span`,{})}),(0,I.jsx)(`div`,{className:`d2c-annotations`,"aria-hidden":`true`,children:Ft.map(e=>{let t=e.designRect??e.implementationRect;return t===void 0?null:(0,I.jsx)(`div`,{className:`d2c-annotation`,"data-kind":e.kind,"data-severity":e.severity,"data-selected":e.fingerprint===C,style:Uu(t)},e.fingerprint)})}),Pt?.designRect!==void 0&&(0,I.jsx)(`div`,{className:`d2c-focus-box d2c-focus-design`,style:Uu(Pt.designRect),children:(0,I.jsx)(`span`,{children:`设计`})}),Pt?.implementationRect!==void 0&&(0,I.jsx)(`div`,{className:`d2c-focus-box d2c-focus-implementation`,style:Uu(Pt.implementationRect),children:(0,I.jsx)(`span`,{children:`实现`})}),Pt?.designRect!==void 0&&Pt.implementationRect!==void 0&&(0,I.jsx)(Q,{design:Pt.designRect,implementation:Pt.implementationRect,canvas:Tt,scale:pt.scale})]}),(0,I.jsx)(`aside`,{className:`d2c-difference-ruler`,"aria-label":`垂直差异分布`,children:P.slice(0,500).map(e=>{let t=e.designRect??e.implementationRect;return t===void 0?null:(0,I.jsx)(`button`,{style:{top:`${(t.y+t.height/2)/Tt.height*100}%`},"data-severity":e.severity,"aria-label":`定位 ${e.label}`,title:e.label,onClick:()=>It(e)},e.fingerprint)})}),(0,I.jsx)(`div`,{className:`d2c-canvas-hint`,children:`滚轮缩放 · 拖动平移 · F 适应 · 0 原始尺寸 · 按住 B 闪烁`})]})]}),m&&(0,I.jsx)(`div`,{className:`d2c-loading`,"aria-busy":`true`,children:`正在加载报告…`})]}),xn===`report`&&(0,I.jsx)(`aside`,{className:`d2c-inspector`,"aria-label":`差异检查器`,children:u!==void 0&&Tt!==void 0&&fn!==void 0?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`section`,{className:`d2c-inspector-verdict`,"data-verdict":u.report.evaluation.verdict,children:[(0,I.jsx)(`span`,{className:`d2c-verdict-mark`,"aria-hidden":`true`,children:u.report.evaluation.verdict===`pass`?`✓`:u.report.evaluation.verdict===`conditional`?`!`:`×`}),(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`p`,{children:u.report.evaluation.status===`invalid`?`EVALUATION INTERRUPTED`:`PAGE VERDICT`}),(0,I.jsx)(`h2`,{children:u.report.evaluation.verdict===`pass`?P.length===0?`本页已通过验收`:`已通过,仍可继续优化`:u.report.evaluation.verdict===`conditional`?`有差异需要确认`:u.report.evaluation.verdict===`invalid`?`评测需要重新运行`:`本页尚未通过验收`}),(0,I.jsx)(`span`,{children:u.report.evaluation.summary})]})]}),(0,I.jsxs)(`nav`,{className:`d2c-stage-tabs`,"aria-label":`E2E 交付阶段`,children:[(0,I.jsxs)(`button`,{type:`button`,"data-active":ke===`review`,"aria-pressed":ke===`review`,onClick:()=>Ae(`review`),children:[(0,I.jsx)(`span`,{children:`04`}),`D2C 视觉还原`]}),(0,I.jsxs)(`button`,{type:`button`,"data-active":ke===`integration`,"aria-pressed":ke===`integration`,disabled:yn===void 0||!yn.complete||u.report.evaluation.status===`invalid`,title:yn?.complete?`进入接口联调`:`全部差异通过后解锁`,onClick:Ut,children:[(0,I.jsx)(`span`,{children:`05`}),`接口联调`]}),(0,I.jsxs)(`button`,{type:`button`,"data-active":ke===`acceptance`,"aria-pressed":ke===`acceptance`,disabled:u.workflow.integrationFiles===void 0,title:u.workflow.integrationFiles===void 0?`生成联调代码后解锁`:`进入验收与交付`,onClick:Wt,children:[(0,I.jsx)(`span`,{children:`06—07`}),`验收与交付`]})]}),ke===`review`?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`section`,{className:`d2c-score-card`,"aria-label":`分项得分`,"data-status":u.report.evaluation.status,children:[(0,I.jsxs)(`header`,{children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`p`,{children:`QUALITY PROFILE`}),(0,I.jsx)(`h2`,{children:`五项质量`})]}),u.report.evaluation.status!==`invalid`&&(0,I.jsxs)(`span`,{children:[ku.filter(({key:e})=>(fn[e]??0)>=.9).length,` / 5 达标`]})]}),u.report.evaluation.status===`invalid`&&(0,I.jsx)(`p`,{className:`d2c-score-invalid`,children:`实现页面渲染失败,当前截图仅用于诊断,不生成正式分数。`}),u.report.evaluation.status!==`invalid`&&(0,I.jsx)(`div`,{className:`d2c-score-list`,children:ku.map(({key:e,label:t})=>fn[e]===void 0?null:(0,I.jsxs)(`div`,{"data-level":zu(fn[e]),children:[(0,I.jsx)(`span`,{children:t}),(0,I.jsx)(`i`,{children:(0,I.jsx)(`b`,{style:{"--score":fn[e]}})}),(0,I.jsx)(`strong`,{children:Math.round(fn[e]*100)})]},e))})]}),u.report.evaluation.status!==`invalid`&&yn!==void 0&&(0,I.jsxs)(`section`,{className:`d2c-review-console`,"data-complete":yn.complete,children:[(0,I.jsxs)(`header`,{children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`p`,{children:`REVIEW QUEUE`}),(0,I.jsx)(`h2`,{children:yn.complete?`视觉审阅已完成`:`等待你的验收`})]}),(0,I.jsxs)(`strong`,{children:[yn.accepted,(0,I.jsxs)(`span`,{children:[` / `,yn.total]})]})]}),(0,I.jsxs)(`div`,{className:`d2c-review-meter`,"aria-label":`已通过 ${yn.accepted},待审 ${yn.pending},退回 ${yn.needsFix}`,children:[(0,I.jsx)(`i`,{style:{"--accepted":yn.total===0?1:yn.accepted/yn.total}}),(0,I.jsxs)(`span`,{children:[`待审 `,(0,I.jsx)(`b`,{children:yn.pending})]}),(0,I.jsxs)(`span`,{children:[`通过 `,(0,I.jsx)(`b`,{children:yn.accepted})]}),(0,I.jsxs)(`span`,{children:[`退回 `,(0,I.jsx)(`b`,{children:yn.needsFix})]})]}),(0,I.jsxs)(`div`,{className:`d2c-review-bulk`,children:[!yn.complete&&(0,I.jsx)(`button`,{type:`button`,disabled:je||s||P.length===0,onClick:()=>void Vt(P.map(e=>e.fingerprint),`accepted`),children:`全部跳过(不扣分)`}),!yn.complete&&(0,I.jsx)(`button`,{type:`button`,className:`d2c-review-reject`,disabled:je||s||P.length===0,onClick:()=>void Vt(P.map(e=>e.fingerprint),`needs-fix`,`集中修复所有退回差异,仍需严格限制在各自模块文件内。`),children:`全部退回并修复`}),yn.complete&&(0,I.jsxs)(`button`,{type:`button`,className:`d2c-review-next`,onClick:Ut,children:[`进入接口联调 `,(0,I.jsx)(`span`,{children:`→`})]})]})]}),(0,I.jsxs)(`div`,{className:`d2c-issue-heading`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`h2`,{children:u.report.evaluation.status===`invalid`?`错误诊断`:`差异问题`}),u.report.evaluation.status!==`invalid`&&(0,I.jsxs)(`span`,{children:[Nt.length,` / `,P.length]})]}),u.report.evaluation.status!==`invalid`&&(0,I.jsx)(`div`,{className:`d2c-issue-filters`,children:[`all`,`blocking`,`content`,`geometry`].map(e=>(0,I.jsxs)(`button`,{type:`button`,"aria-pressed":ee===e,"data-active":ee===e,onClick:()=>{te(e),re(_u)},children:[(0,I.jsx)(`span`,{children:Au[e]}),(0,I.jsx)(`small`,{children:Mt[e]})]},e))})]}),Nt.length===0?(0,I.jsxs)(`div`,{className:`d2c-issue-empty`,"data-kind":u.report.evaluation.status===`invalid`?`invalid`:P.length===0?`clear`:`filtered`,children:[(0,I.jsx)(`span`,{className:`d2c-empty-mark`,"aria-hidden":`true`,children:u.report.evaluation.status===`invalid`?`!`:P.length===0?`✓`:`⌁`}),(0,I.jsx)(`strong`,{children:u.report.evaluation.status===`invalid`?`等待有效评测`:P.length===0?`未发现可定位的差异`:`这个筛选下没有问题`}),(0,I.jsx)(`p`,{children:u.report.evaluation.status===`invalid`?`修复项目并重新运行 E2E 中的 D2C 视觉还原后,这里会生成可定位的差异清单。`:P.length===0?`布局、色彩、字体、内容与像素结果均已通过检查。`:`切换分类或显示全部问题,继续检查其他差异。`}),u.report.evaluation.status!==`invalid`&&(0,I.jsxs)(`div`,{className:`d2c-empty-stats`,children:[(0,I.jsxs)(`span`,{children:[`阻断 `,(0,I.jsx)(`b`,{children:Mt.blocking})]}),(0,I.jsxs)(`span`,{children:[`内容 `,(0,I.jsx)(`b`,{children:Mt.content})]}),(0,I.jsxs)(`span`,{children:[`几何 `,(0,I.jsx)(`b`,{children:Mt.geometry})]})]}),u.report.evaluation.status!==`invalid`&&(P.length===0?(0,I.jsx)(`button`,{type:`button`,onClick:()=>{v(`overlay`),Dt()},children:`查看叠加结果`}):(0,I.jsx)(`button`,{type:`button`,onClick:()=>{te(`all`),re(_u)},children:`显示全部问题`}))]}):(0,I.jsx)(`ol`,{className:`d2c-issue-list`,children:Nt.slice(0,ne).map(e=>{let t=bn(e.fingerprint);return(0,I.jsxs)(`li`,{"data-severity":e.severity,"data-selected":C===e.fingerprint,"data-review":t?.decision??`pending`,children:[(0,I.jsxs)(`button`,{className:`d2c-issue-main`,onClick:()=>It(e),"aria-pressed":C===e.fingerprint,children:[(0,I.jsx)(`span`,{className:`d2c-impact`,children:t?.decision===`accepted`?`✓`:t?.decision===`needs-fix`?`↻`:e.impact.toFixed(1)}),(0,I.jsxs)(`span`,{children:[(0,I.jsx)(`strong`,{children:e.label}),Lu(e).map(e=>(0,I.jsx)(`small`,{children:e},e))]})]}),C===e.fingerprint&&(0,I.jsxs)(`div`,{className:`d2c-evidence`,children:[(0,I.jsxs)(`div`,{className:`d2c-evidence-pair`,children:[e.designRect!==void 0&&(0,I.jsx)(Bu,{src:u.designPng,rect:e.designRect,canvas:Tt,label:`设计`}),e.implementationRect!==void 0&&(0,I.jsx)(Bu,{src:u.implementationPng,rect:e.implementationRect,canvas:Tt,label:`实现`})]}),(0,I.jsxs)(`div`,{className:`d2c-copy-actions`,children:[e.selector!==void 0&&(0,I.jsx)(`button`,{onClick:()=>Bt(e.selector),children:`复制选择器`}),(0,I.jsx)(`button`,{onClick:()=>Bt(`${e.label}\n${Lu(e).join(`
148
148
  `)}\n位置:${JSON.stringify(vn)}`),children:`复制修复线索`})]}),(0,I.jsxs)(`label`,{className:`d2c-review-instruction`,children:[(0,I.jsx)(`span`,{children:`补充修改要求`}),(0,I.jsx)(`textarea`,{rows:2,value:Ne,placeholder:`例如:保持卡片高度,只调整内部间距`,onChange:e=>Pe(e.target.value)})]}),(0,I.jsxs)(`div`,{className:`d2c-review-actions`,children:[(0,I.jsx)(`button`,{type:`button`,className:`d2c-accept`,disabled:je||s||t?.decision===`accepted`,onClick:()=>void Vt([e.fingerprint],`accepted`),children:`跳过(本项不扣分)`}),(0,I.jsx)(`button`,{type:`button`,className:`d2c-fix`,disabled:je||s,onClick:()=>void Vt([e.fingerprint],`needs-fix`,Ne||void 0),children:`修复并自动视觉复验`})]})]})]},e.fingerprint)})}),Nt.length>ne&&(0,I.jsxs)(`button`,{className:`d2c-show-more`,onClick:()=>re(e=>e+_u),children:[`再显示 `,Math.min(_u,Nt.length-ne),` 条`]})]}):(0,I.jsxs)(`section`,{className:`d2c-integration-panel`,"data-stage":ke,"aria-label":ke===`acceptance`?`验收与交付`:`接口联调`,children:[(0,I.jsxs)(`header`,{children:[(0,I.jsx)(`p`,{children:ke===`acceptance`?`ACCEPTANCE & DELIVERY`:`API INTEGRATION`}),(0,I.jsx)(`h2`,{children:ke===`acceptance`?`验收与交付`:Fe===void 0?u.deliveryOrigin===`requirement`?`自动准备接口契约`:`导入接口描述`:Fe.document.title}),(0,I.jsx)(`span`,{children:ke===`acceptance`?`通过自动回放、人工操作与多模态质量门,完成最终交付验收。`:Fe===void 0?u.deliveryOrigin===`requirement`?`根据已确认 PRD 与实现模块生成 OpenAPI,无需手动上传。`:`上传 Swagger / OpenAPI JSON,自动匹配页面模块和接口出入参。`:`${Fe.document.version}${Fe.document.baseUrl?` · ${Fe.document.baseUrl}`:``}`})]}),Fe===void 0?(0,I.jsxs)(`div`,{className:`d2c-api-import`,"data-origin":u.deliveryOrigin,children:[(0,I.jsx)(`span`,{"aria-hidden":`true`,children:`{}`}),(0,I.jsx)(`strong`,{children:u.deliveryOrigin===`requirement`?`正在根据 PRD 与模块准备 OpenAPI 契约`:`Swagger JSON`}),(0,I.jsx)(`p`,{children:u.deliveryOrigin===`requirement`?`契约会自动生成并映射到当前实现;也可接入已有后端契约覆盖默认结果。`:`支持 Swagger 2.0、OpenAPI 3.0/3.1 和文档内引用。`}),(0,I.jsx)(`button`,{type:`button`,disabled:Le,onClick:()=>void F(),children:Le?u.deliveryOrigin===`requirement`?`自动准备中…`:`正在解析…`:u.deliveryOrigin===`requirement`?`接入已有 Swagger / OpenAPI`:`选择 swagger.json`})]}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`div`,{className:`d2c-api-summary`,children:[(0,I.jsxs)(`span`,{children:[`模块 `,(0,I.jsx)(`b`,{children:Fe.mappings.length})]}),(0,I.jsxs)(`span`,{children:[`自动匹配 `,(0,I.jsx)(`b`,{children:Fe.mappings.filter(e=>e.status===`auto`).length})]}),(0,I.jsxs)(`span`,{children:[`待确认 `,(0,I.jsx)(`b`,{children:Fe.mappings.filter(e=>e.status===`needs-confirmation`).length})]})]}),(0,I.jsx)(`ol`,{className:`d2c-mapping-list`,children:Fe.mappings.map(e=>(0,I.jsxs)(`li`,{"data-status":e.status,children:[(0,I.jsxs)(`header`,{children:[(0,I.jsx)(`span`,{children:e.moduleLabel}),(0,I.jsx)(`small`,{children:e.status===`auto`?`自动匹配`:e.status===`confirmed`?`已确认`:`需要确认`})]}),(0,I.jsx)(`select`,{"aria-label":`${e.moduleLabel} 接口`,value:e.operationKey,disabled:Le,onChange:t=>void Gt(e,t.target.value),children:Fe.document.operations.map(e=>(0,I.jsxs)(`option`,{value:e.id,children:[e.operationId,` · `,e.id]},e.id))}),e.status===`needs-confirmation`&&(0,I.jsx)(`button`,{type:`button`,className:`d2c-confirm-mapping`,disabled:Le,onClick:()=>void Gt(e,e.operationKey),children:`确认此映射`}),(0,I.jsxs)(`div`,{children:[(0,I.jsxs)(`span`,{children:[`请求 `,e.parameters.length+e.requestFields.length,` 字段`]}),(0,I.jsxs)(`span`,{children:[`响应 `,e.responseFields.length,` 字段`]}),(0,I.jsxs)(`b`,{children:[Math.round(e.confidence*100),`%`]})]})]},e.moduleId))}),(0,I.jsxs)(`div`,{className:`d2c-integration-launch`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`span`,{children:`接口映射已就绪`}),(0,I.jsx)(`small`,{children:Fe.mappings.some(e=>e.status===`needs-confirmation`)?`仍有接口需要人工确认`:`${Fe.mappings.length} 个模块将接入真实请求链路`})]}),(0,I.jsxs)(`button`,{type:`button`,className:`d2c-generate-integration`,disabled:Le||Fe.mappings.some(e=>e.status===`needs-confirmation`),onClick:()=>void Kt(),children:[Le?`正在准备联调…`:u.workflow.integrationFiles===void 0?`生成并开始联调`:`重新生成联调代码`,(0,I.jsx)(`span`,{children:`→`})]})]}),Fe.mappings.some(e=>e.status===`needs-confirmation`)&&(0,I.jsx)(`p`,{className:`d2c-api-hint`,children:`确认所有标记为“需要确认”的接口后即可生成。`}),(0,I.jsxs)(`section`,{className:`d2c-mock-control`,"data-running":ze.running,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`i`,{}),(0,I.jsxs)(`span`,{children:[(0,I.jsx)(`strong`,{children:u.deliveryOrigin===`requirement`?ze.running?`真实后端服务运行中`:`真实后端服务未启动`:ze.running?`本地契约服务运行中`:`本地契约服务未启动`}),(0,I.jsx)(`small`,{children:ze.url??`生成联调代码后可启动`})]})]}),u.workflow.integrationFiles!==void 0&&(0,I.jsx)(`button`,{type:`button`,disabled:Le||A.running,title:A.running?`请先停止交互页面`:void 0,onClick:()=>void qt(),children:ze.running?`停止`:`启动`})]}),u.workflow.integrationFiles!==void 0&&(0,I.jsxs)(`section`,{className:`d2c-integration-ready`,"data-running":A.running,children:[(0,I.jsx)(`span`,{"aria-hidden":`true`,children:`✓`}),(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`strong`,{children:`联调环境已生成`}),(0,I.jsx)(`small`,{children:A.running?`前端页面与后端服务已连接,可进入最终验收。`:`启动联调页面后即可进入自动与人工验收。`})]}),(0,I.jsx)(`button`,{type:`button`,onClick:Wt,children:`进入验收与交付 →`})]}),(0,I.jsxs)(`section`,{className:`d2c-preview-control`,"data-running":A.running,children:[(0,I.jsxs)(`header`,{children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`p`,{children:`INTERACTIVE ACCEPTANCE`}),(0,I.jsx)(`h3`,{children:A.running?`可交互页面运行中`:`等待启动可交互页面`})]}),(0,I.jsx)(`i`,{})]}),(0,I.jsx)(`code`,{children:A.url??`Vite preview not started`}),(0,I.jsxs)(`div`,{className:`d2c-preview-actions`,children:[(0,I.jsx)(`button`,{type:`button`,disabled:Ge||u.workflow.integrationFiles===void 0,onClick:()=>void(A.running?Xt():Yt()),children:A.running?`停止页面`:`启动页面`}),(0,I.jsx)(`button`,{type:`button`,disabled:Ge||!A.running,onClick:()=>void Zt(),children:qe?`可视回放中…`:Ge?`处理中…`:`运行自动验收`}),A.running&&(0,I.jsx)(`button`,{type:`button`,onClick:()=>void window.flavorDesktop.openD2cPreview(u.report.task),children:`浏览器打开`})]}),qe&&(0,I.jsxs)(`div`,{className:`d2c-playback-notice`,role:`status`,"aria-live":`polite`,children:[(0,I.jsx)(`i`,{"aria-hidden":`true`}),(0,I.jsxs)(`span`,{children:[(0,I.jsx)(`strong`,{children:`正在可视化回放`}),(0,I.jsx)(`small`,{children:$e.configured?`多模态模型正在观察并规划用户旅程;随后青色指针会完成点击、输入、导航和检查。`:`请观察左侧页面:青色指针会依次完成设计契约中的定位、点击、输入和检查。配置多模态模型后可启用自主审阅。`})]})]}),j!==void 0&&(0,I.jsxs)(`div`,{className:`d2c-review-plan`,"data-mode":j.mode,children:[(0,I.jsx)(`strong`,{children:j.mode===`autonomous`?`自主审阅已执行`:j.mode===`contract-fallback`?`自主规划失败,已执行设计契约`:`设计契约已执行`}),(0,I.jsxs)(`span`,{children:[j.plannedScenarios,` 条用户旅程`,j.model?` · ${j.model}`:``]}),j.summary&&(0,I.jsx)(`p`,{children:j.summary}),j.warning&&(0,I.jsx)(`p`,{role:`alert`,children:j.warning})]}),He!==void 0&&(0,I.jsxs)(`div`,{className:`d2c-test-results`,"data-passed":He.passed,children:[(0,I.jsxs)(`header`,{children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`strong`,{children:He.passed?`自动验收通过`:`${He.failures} 条自动验收失败`}),(0,I.jsxs)(`span`,{children:[He.total,` scenarios · `,He.apiRequestCount,` API requests`]})]}),!He.passed&&(0,I.jsx)(`button`,{type:`button`,disabled:Ye!==void 0||s,onClick:()=>void $t(He.scenarios.filter(e=>!e.passed)),children:Ye===`all`?`正在发起修复…`:Ze.trim()?`按要求修复全部`:`修复全部失败`})]}),!He.passed&&(0,I.jsxs)(`label`,{className:`d2c-interaction-repair-guide`,children:[(0,I.jsxs)(`span`,{children:[`补充修复要求 `,(0,I.jsx)(`small`,{children:`可选`})]}),(0,I.jsx)(`textarea`,{rows:3,value:Ze,placeholder:`例如:不要修改接口契约;优先检查登录响应的 data 包装层与会话持久化`,onChange:e=>Qe(e.target.value)}),(0,I.jsx)(`small`,{children:`留空则按失败证据自动修复;填写后会连同请求日志一起交给修复任务。`})]}),(0,I.jsx)(`ol`,{children:He.scenarios.map(e=>(0,I.jsxs)(`li`,{"data-passed":e.passed,children:[(0,I.jsxs)(`span`,{children:[e.passed?`✓`:`×`,` `,e.id]}),(0,I.jsxs)(`small`,{children:[e.apiRequestCount,` API · `,e.durationMs,`ms`]}),e.failure!==void 0&&(0,I.jsx)(`p`,{children:e.failure}),!e.passed&&(0,I.jsx)(`button`,{type:`button`,className:`d2c-fix-scenario`,disabled:Ye!==void 0||s,"aria-label":`修复失败场景 ${e.id}`,onClick:()=>void $t([e]),children:Ye===e.id?`正在发起修复…`:Ze.trim()?`按要求修复此项`:`修复此项`})]},e.id))})]}),(0,I.jsxs)(`div`,{className:`d2c-manual-acceptance`,children:[(0,I.jsxs)(`span`,{children:[(0,I.jsx)(`strong`,{children:`人工验收`}),(0,I.jsx)(`small`,{children:`请直接在左侧页面完成点击、输入和提交流程`})]}),(0,I.jsx)(`button`,{type:`button`,disabled:Ge||!A.running,"data-accepted":u.workflow.interaction?.manualDecision===`accepted`,onClick:()=>void Qt(u.workflow.interaction?.manualDecision!==`accepted`),children:u.workflow.interaction?.manualDecision===`accepted`?`已通过(撤回)`:`确认人工验收通过`})]}),(0,I.jsxs)(`section`,{className:`d2c-quality-gate`,"data-verdict":u.workflow.quality?.verdict??`pending`,children:[(0,I.jsxs)(`header`,{children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`p`,{children:`LLM-AS-A-JUDGE`}),(0,I.jsx)(`h3`,{children:`最终质量门`})]}),u.workflow.quality!==void 0&&(0,I.jsx)(`strong`,{children:u.workflow.quality.overallScore.toFixed(1)})]}),!$e.configured||at?(0,I.jsxs)(`form`,{className:`d2c-judge-config`,onSubmit:e=>void ln(e),children:[(0,I.jsxs)(`label`,{children:[(0,I.jsx)(`span`,{children:`协议`}),(0,I.jsxs)(`select`,{value:st.protocol,onChange:e=>ct(t=>({...t,protocol:e.target.value})),children:[(0,I.jsx)(`option`,{value:`openai-compatible`,children:`OpenAI 兼容`}),(0,I.jsx)(`option`,{value:`anthropic`,children:`Anthropic`})]})]}),(0,I.jsxs)(`label`,{children:[(0,I.jsx)(`span`,{children:`Base URL`}),(0,I.jsx)(`input`,{required:!0,type:`url`,placeholder:`https://api.example.com/v1`,value:st.baseURL,onChange:e=>ct(t=>({...t,baseURL:e.target.value}))})]}),(0,I.jsxs)(`label`,{children:[(0,I.jsx)(`span`,{children:`模型`}),(0,I.jsx)(`input`,{required:!0,placeholder:`支持视觉的模型名称`,value:st.model,onChange:e=>ct(t=>({...t,model:e.target.value}))})]}),(0,I.jsxs)(`label`,{children:[(0,I.jsx)(`span`,{children:`API Key`}),(0,I.jsx)(`input`,{required:!0,type:`password`,autoComplete:`off`,value:st.apiKey,onChange:e=>ct(t=>({...t,apiKey:e.target.value}))})]}),(0,I.jsxs)(`label`,{children:[(0,I.jsx)(`span`,{children:`通过阈值`}),(0,I.jsx)(`input`,{required:!0,type:`number`,min:0,max:100,value:st.passThreshold,onChange:e=>ct(t=>({...t,passThreshold:Number(e.target.value)}))})]}),(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`button`,{type:`submit`,disabled:tt,children:tt?`保存中…`:`保存多模态模型`}),$e.configured&&(0,I.jsx)(`button`,{type:`button`,onClick:()=>ot(!1),children:`取消`})]})]}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`div`,{className:`d2c-judge-model`,children:[(0,I.jsx)(`span`,{children:$e.model}),(0,I.jsxs)(`small`,{children:[$e.baseURL,` · 阈值 `,$e.passThreshold]}),(0,I.jsx)(`button`,{type:`button`,onClick:()=>ot(!0),children:`修改配置`})]}),u.workflow.quality===void 0?(0,I.jsx)(`p`,{children:`可随时评测当前版本;自动与人工验收未通过时,评分只用于诊断,不会放行最终交付。`}):(0,I.jsxs)(`div`,{className:`d2c-quality-result`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsxs)(`span`,{children:[`视觉质量 `,(0,I.jsx)(`b`,{children:u.workflow.quality.visualScore})]}),(0,I.jsxs)(`span`,{children:[`交互质量 `,(0,I.jsx)(`b`,{children:u.workflow.quality.interactionScore})]}),(0,I.jsxs)(`span`,{children:[`综合得分 `,(0,I.jsx)(`b`,{children:u.workflow.quality.overallScore})]})]}),(0,I.jsx)(`strong`,{children:u.workflow.quality.verdict===`pass`?`质量门通过`:`质量门未通过`}),(0,I.jsx)(`p`,{children:u.workflow.quality.summary}),u.workflow.quality.issues.length>0&&(0,I.jsx)(`ol`,{children:u.workflow.quality.issues.map(e=>(0,I.jsxs)(`li`,{"data-severity":e.severity,"data-decision":e.decision,children:[(0,I.jsx)(`span`,{children:e.description}),(0,I.jsx)(`small`,{children:e.recommendation}),(0,I.jsxs)(`em`,{children:[e.category,` · 影响 `,e.scoreImpact,` 分 · `,e.decision===`skipped`?`已跳过,不扣分`:e.decision===`fixing`?`修复中,完成后自动复验`:`待处理`]}),(0,I.jsxs)(`div`,{className:`d2c-quality-issue-actions`,children:[(0,I.jsx)(`button`,{type:`button`,disabled:rt!==void 0||e.decision===`skipped`,onClick:()=>void dn(e,`skipped`),children:`跳过(不扣分)`}),(0,I.jsx)(`button`,{type:`button`,disabled:rt!==void 0||e.decision===`fixing`,onClick:()=>void dn(e,`fixing`),children:`修复并自动复验`})]})]},e.id))})]}),(0,I.jsx)(`button`,{type:`button`,className:`d2c-run-judge`,disabled:tt||!A.running||u.workflow.interaction?.automated===void 0,title:u.workflow.interaction?.automated===void 0?`至少运行一次自动验收后可评分;验收失败也可以评分诊断`:void 0,onClick:()=>void un(),children:tt?`AI 评审中…`:u.workflow.quality===void 0?`运行 AI 质量评审`:`重新运行 AI 质量评审`})]})]}),u.workflow.stage===`completed`&&(0,I.jsx)(`p`,{className:`d2c-acceptance-complete`,children:`✓ 自动、人工与多模态质量验收均已完成`})]})]})]})]}):(0,I.jsxs)(`div`,{className:`d2c-inspector-empty`,children:[(0,I.jsx)(`strong`,{children:`问题检查器`}),(0,I.jsx)(`span`,{children:`选择报告后,可按影响度逐项定位和取证。`})]})})]})]})}var Xu={repository:!1,branch:``,head:``,files:[]};function Zu(e,t=!1){let n=e.replace(/\r\n/g,`
149
149
  `).split(`
150
- `);if(n.at(-1)===``&&n.pop(),t&&!n.some(e=>e.startsWith(`@@`)))return n.map((e,t)=>({kind:`addition`,marker:`+`,text:e,newNumber:t+1}));let r=0,i=0,a=!1;return n.map(e=>{let t=/^@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@(.*)$/.exec(e);if(t!==null)return r=Number(t[1]),i=Number(t[2]),a=!0,{kind:`hunk`,marker:`@@`,text:t[3]?.trim()??``};if(!a||e.startsWith(`diff --git`)||e.startsWith(`index `)||e.startsWith(`--- `)||e.startsWith(`+++ `))return{kind:`meta`,marker:``,text:e};if(e.startsWith(`+`)&&!e.startsWith(`+++`))return{kind:`addition`,marker:`+`,text:e.slice(1),newNumber:i++};if(e.startsWith(`-`)&&!e.startsWith(`---`))return{kind:`deletion`,marker:`−`,text:e.slice(1),oldNumber:r++};if(e.startsWith(`\\ No newline`))return{kind:`meta`,marker:``,text:e};let n={kind:`context`,marker:``,text:e.startsWith(` `)?e.slice(1):e,oldNumber:r,newNumber:i};return r+=1,i+=1,n})}function Qu({onClose:e,onReview:t,onError:n}){let[r,i]=(0,_.useState)(Xu),[a,o]=(0,_.useState)(),[s,c]=(0,_.useState)(``),[l,u]=(0,_.useState)(`working`),[d,f]=(0,_.useState)(!0),[p,m]=(0,_.useState)(!1),[h,g]=(0,_.useState)(``),v=(0,_.useMemo)(()=>Zu(s,a?.untracked),[s,a?.untracked]),y=v.filter(e=>e.kind===`addition`).length,b=v.filter(e=>e.kind===`deletion`).length,x=r.files.filter(e=>e.staged).length,S=async()=>{try{i(await window.flavorDesktop.gitStatus())}catch(e){n(ed(e))}finally{f(!1)}};(0,_.useEffect)(()=>{S()},[]);let C=async(e,t)=>{m(!0),c(``),u(t);try{c(await window.flavorDesktop.gitDiff(e.path,t===`staged`))}catch(e){let t=ed(e);c(t),n(t)}finally{m(!1)}},w=async e=>{o(e),await C(e,e.unstaged||e.untracked?`working`:`staged`)},ee=async(e,t)=>{if(!(e===`discard`&&!window.confirm(`确定还原 ${t.path}?此操作无法撤销。`)))try{let n=e===`stage`?await window.flavorDesktop.gitStage(t.path):e===`unstage`?await window.flavorDesktop.gitUnstage(t.path):await window.flavorDesktop.gitDiscard(t.path);i(n);let r=n.files.find(e=>e.path===t.path);r===void 0?(o(void 0),c(``)):(o(r),await C(r,r.unstaged||r.untracked?`working`:`staged`))}catch(e){n(ed(e))}},te=async()=>{if(h.trim())try{let e=await window.flavorDesktop.gitCommit(h.trim());i(e.status),g(``),o(void 0),c(``),n(`已提交 ${e.result}`)}catch(e){n(ed(e))}};return(0,I.jsxs)(`section`,{className:`manager-view git-view`,children:[(0,I.jsxs)(`header`,{className:`manager-header git-header`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`button`,{className:`git-back`,onClick:e,"aria-label":`返回`,children:`←`}),(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`h2`,{children:`Git 变更`}),(0,I.jsx)(`span`,{children:`审阅并整理本次工作区修改`})]})]}),r.repository&&(0,I.jsxs)(`span`,{className:`git-branch`,children:[(0,I.jsx)(`i`,{}),r.branch,(0,I.jsx)(`b`,{children:r.head})]})]}),d?(0,I.jsx)(`p`,{className:`manager-empty`,children:`正在读取工作区…`}):r.repository?(0,I.jsxs)(`div`,{className:`git-layout`,children:[(0,I.jsxs)(`aside`,{className:`git-files`,children:[(0,I.jsxs)(`div`,{className:`git-toolbar`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`strong`,{children:`变更`}),(0,I.jsx)(`span`,{children:r.files.length})]}),(0,I.jsx)(`button`,{onClick:()=>void S(),title:`重新读取变更`,children:`↻`})]}),r.files.length===0?(0,I.jsxs)(`div`,{className:`git-clean`,children:[(0,I.jsx)(`i`,{children:`✓`}),(0,I.jsx)(`strong`,{children:`工作区干净`}),(0,I.jsx)(`span`,{children:`没有需要审阅的修改`})]}):r.files.map(e=>{let t=$u(e.path),n=e.untracked?`U`:e.index===`A`?`A`:e.index===`D`||e.worktree===`D`?`D`:`M`;return(0,I.jsxs)(`div`,{className:`git-file-row`,"data-active":a?.path===e.path,children:[(0,I.jsxs)(`button`,{className:`git-file-name`,onClick:()=>void w(e),title:e.path,children:[(0,I.jsx)(`code`,{"data-state":n,children:n}),(0,I.jsxs)(`span`,{children:[(0,I.jsx)(`b`,{children:t.name}),t.directory&&(0,I.jsx)(`small`,{children:t.directory})]})]}),(0,I.jsxs)(`div`,{className:`git-file-actions`,children:[e.staged?(0,I.jsx)(`button`,{onClick:()=>void ee(`unstage`,e),children:`取消暂存`}):(0,I.jsx)(`button`,{className:`stage-action`,onClick:()=>void ee(`stage`,e),children:`暂存`}),(e.unstaged||e.untracked)&&(0,I.jsx)(`button`,{className:`danger-text`,onClick:()=>void ee(`discard`,e),children:`还原`})]})]},e.path)})]}),(0,I.jsx)(`article`,{className:`git-diff`,children:a===void 0?(0,I.jsxs)(`div`,{className:`git-diff-empty`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`span`,{children:`−`}),(0,I.jsx)(`span`,{children:`+`})]}),(0,I.jsx)(`strong`,{children:`选择文件查看差异`}),(0,I.jsx)(`p`,{children:`逐行审阅修改,然后决定暂存或还原。`})]}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`header`,{className:`git-diff-header`,children:[(0,I.jsxs)(`div`,{className:`git-diff-title`,children:[(0,I.jsx)(`span`,{children:$u(a.path).directory||`项目根目录`}),(0,I.jsx)(`strong`,{children:$u(a.path).name})]}),(0,I.jsxs)(`div`,{className:`git-diff-controls`,children:[a.staged&&a.unstaged&&(0,I.jsxs)(`div`,{className:`git-layer-switch`,children:[(0,I.jsx)(`button`,{"data-active":l===`working`,onClick:()=>void C(a,`working`),children:`工作区`}),(0,I.jsx)(`button`,{"data-active":l===`staged`,onClick:()=>void C(a,`staged`),children:`已暂存`})]}),!p&&(0,I.jsxs)(`div`,{className:`git-diff-stats`,children:[(0,I.jsxs)(`span`,{className:`add`,children:[`+`,y]}),(0,I.jsxs)(`span`,{className:`del`,children:[`−`,b]})]})]})]}),(0,I.jsx)(`div`,{className:`git-code`,"aria-label":`${a.path} 差异`,children:p?(0,I.jsxs)(`div`,{className:`git-diff-loading`,children:[(0,I.jsx)(`i`,{}),`正在生成差异…`]}):v.map((e,t)=>(0,I.jsxs)(`div`,{className:`git-code-line`,"data-kind":e.kind,children:[(0,I.jsx)(`span`,{className:`old-line`,children:e.oldNumber??``}),(0,I.jsx)(`span`,{className:`new-line`,children:e.newNumber??``}),(0,I.jsx)(`span`,{className:`change-marker`,children:e.marker}),(0,I.jsx)(`code`,{children:e.text||` `})]},`${t}-${e.oldNumber??``}-${e.newNumber??``}`))})]})})]}):(0,I.jsx)(`p`,{className:`manager-empty`,children:`当前项目不是 Git 仓库`}),r.repository&&(0,I.jsxs)(`footer`,{className:`git-footer`,children:[(0,I.jsx)(`button`,{className:`review-action`,onClick:t,children:`交给 /review`}),(0,I.jsxs)(`div`,{className:`commit-field`,children:[(0,I.jsx)(`input`,{value:h,onChange:e=>g(e.target.value),placeholder:x>0?`描述这次提交…`:`暂存文件后即可提交`}),(0,I.jsxs)(`span`,{children:[x,` 个文件已暂存`]})]}),(0,I.jsx)(`button`,{className:`commit-action`,disabled:!h.trim()||x===0,onClick:()=>void te(),children:`提交`})]})]})}function $u(e){let t=e.replace(/\\/g,`/`),n=t.lastIndexOf(`/`);return n<0?{name:t,directory:``}:{name:t.slice(n+1),directory:t.slice(0,n)}}function ed(e){return e instanceof Error?e.message:String(e)}function td(e){let t=[],n,r=()=>{if(n===void 0)return;let e=n.lines.length,r=n.hunks.map((t,r)=>({...t,end:n.hunks[r+1]?.start??e}));t.push({...n,hunks:r})};for(let t of e.split(/\r?\n/)){let e=/^diff --(?:git|flavor) a\/(.+?) b\/(.+)$/.exec(t);if(e!==null){r(),n={path:e[2],lines:[t],hunks:[],additions:0,deletions:0};continue}if(n===void 0)continue;let i=n.lines.length;n.lines.push(t),t.startsWith(`@@`)?n.hunks.push({id:`${n.path}:${n.hunks.length+1}`,header:t,start:i,end:i+1}):t.startsWith(`+`)&&!t.startsWith(`+++`)?n.additions+=1:t.startsWith(`-`)&&!t.startsWith(`---`)&&(n.deletions+=1)}return r(),t}function nd(e){return Math.min(2.4,Math.max(.55,e))}function rd(e,t,n){let r=nd(n),i=r/e.scale;return{x:t.x-(t.x-e.x)*i,y:t.y-(t.y-e.y)*i,scale:r}}function id(e,t,n){return{x:Math.round(t.x+e.x*n.width*t.scale/100),y:Math.round(t.y+e.y*n.height*t.scale/100)}}function ad(e,t){let n=new Map,r=[];n.set(e.id,{...e,role:`origin`,x:50,y:50});let i=(t,i,a)=>{t.slice(0,8).forEach((t,o,s)=>{n.set(t.id,{...t,role:i,x:a,y:(o+1)*100/(s.length+1)}),r.push(i===`caller`?{from:t.id,to:e.id,kind:i}:{from:e.id,to:t.id,kind:i})})};i(t.callers,`caller`,14),i(t.callees,`callee`,86);let a=t.impact.filter(e=>!n.has(e.id)).slice(0,12),o=Math.ceil(a.length/2);return a.forEach((t,i)=>{let s=i<o,c=s?i:i-o,l=s?o:a.length-o,u=Math.floor(c/3),d=c%3,f=Math.min(3,l-u*3),p=(d+1)*100/(f+1),m=s?13+u*11:87-u*11;n.set(t.id,{...t,role:`impact`,x:p,y:m,hop:t.hop}),r.push({from:e.id,to:t.id,kind:`impact`,hop:t.hop})}),{nodes:[...n.values()],edges:r}}function od(e){let t=new Map(e.map(e=>[e.id,e]));return e.map(e=>{let n=0,r=e.parentId,i=new Set([e.id]);for(;r!==null&&n<12&&!i.has(r);){i.add(r);let e=t.get(r);if(e===void 0)break;n+=1,r=e.parentId}return{node:e,depth:n}})}function sd(e){return e.replaceAll(`\\`,`/`).split(`/`).filter(Boolean).at(-1)??e}function cd(e,t){let n=t.filter(e=>e.state!==`closed`);return e!==void 0&&n.some(t=>t.id===e)?e:n.find(e=>e.state===`running`)?.id??n[0]?.id}var ld=`modulepreload`,ud=function(e,t){return new URL(e,t).href},dd={},fd=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?import.meta.resolve(e):new URL(e,import.meta.url).href}r=o(t.map(t=>{if(t=ud(t,n),t=s(t),t in dd)return;dd[t]=!0;let r=t.endsWith(`.css`);for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}let i=document.createElement(`link`);if(i.rel=r?`stylesheet`:ld,r||(i.as=`script`),i.crossOrigin=``,i.href=t,a&&i.setAttribute(`nonce`,a),document.head.appendChild(i),r)return new Promise((e,n)=>{i.addEventListener(`load`,e),i.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},pd=[{id:`cockpit`,label:`执行`},{id:`timeline`,label:`时间机`},{id:`terminal`,label:`终端`},{id:`review`,label:`审查`},{id:`preview`,label:`预览`},{id:`context`,label:`上下文`},{id:`ast`,label:`代码图`},{id:`pals`,label:`Pals`},{id:`worktrees`,label:`工作树`}],md=_.lazy(()=>fd(()=>import(`./interactive-terminal-BwS6MvIe.js`),[],import.meta.url));function hd({snapshot:e,onClose:t,onError:n,onCompose:r}){let[i,a]=(0,_.useState)(`cockpit`),[o,s]=(0,_.useState)(()=>Od(e.jobs.map(e=>e.label).join(`
150
+ `);if(n.at(-1)===``&&n.pop(),t&&!n.some(e=>e.startsWith(`@@`)))return n.map((e,t)=>({kind:`addition`,marker:`+`,text:e,newNumber:t+1}));let r=0,i=0,a=!1;return n.map(e=>{let t=/^@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@(.*)$/.exec(e);if(t!==null)return r=Number(t[1]),i=Number(t[2]),a=!0,{kind:`hunk`,marker:`@@`,text:t[3]?.trim()??``};if(!a||e.startsWith(`diff --git`)||e.startsWith(`index `)||e.startsWith(`--- `)||e.startsWith(`+++ `))return{kind:`meta`,marker:``,text:e};if(e.startsWith(`+`)&&!e.startsWith(`+++`))return{kind:`addition`,marker:`+`,text:e.slice(1),newNumber:i++};if(e.startsWith(`-`)&&!e.startsWith(`---`))return{kind:`deletion`,marker:`−`,text:e.slice(1),oldNumber:r++};if(e.startsWith(`\\ No newline`))return{kind:`meta`,marker:``,text:e};let n={kind:`context`,marker:``,text:e.startsWith(` `)?e.slice(1):e,oldNumber:r,newNumber:i};return r+=1,i+=1,n})}function Qu({onClose:e,onReview:t,onError:n}){let[r,i]=(0,_.useState)(Xu),[a,o]=(0,_.useState)(),[s,c]=(0,_.useState)(``),[l,u]=(0,_.useState)(`working`),[d,f]=(0,_.useState)(!0),[p,m]=(0,_.useState)(!1),[h,g]=(0,_.useState)(``),v=(0,_.useMemo)(()=>Zu(s,a?.untracked),[s,a?.untracked]),y=v.filter(e=>e.kind===`addition`).length,b=v.filter(e=>e.kind===`deletion`).length,x=r.files.filter(e=>e.staged).length,S=async()=>{try{i(await window.flavorDesktop.gitStatus())}catch(e){n(ed(e))}finally{f(!1)}};(0,_.useEffect)(()=>{S()},[]);let C=async(e,t)=>{m(!0),c(``),u(t);try{c(await window.flavorDesktop.gitDiff(e.path,t===`staged`))}catch(e){let t=ed(e);c(t),n(t)}finally{m(!1)}},w=async e=>{o(e),await C(e,e.unstaged||e.untracked?`working`:`staged`)},ee=async(e,t)=>{if(!(e===`discard`&&!window.confirm(`确定还原 ${t.path}?此操作无法撤销。`)))try{let n=e===`stage`?await window.flavorDesktop.gitStage(t.path):e===`unstage`?await window.flavorDesktop.gitUnstage(t.path):await window.flavorDesktop.gitDiscard(t.path);i(n);let r=n.files.find(e=>e.path===t.path);r===void 0?(o(void 0),c(``)):(o(r),await C(r,r.unstaged||r.untracked?`working`:`staged`))}catch(e){n(ed(e))}},te=async()=>{if(h.trim())try{let e=await window.flavorDesktop.gitCommit(h.trim());i(e.status),g(``),o(void 0),c(``),n(`已提交 ${e.result}`)}catch(e){n(ed(e))}};return(0,I.jsxs)(`section`,{className:`manager-view git-view`,children:[(0,I.jsxs)(`header`,{className:`manager-header git-header`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`button`,{className:`git-back`,onClick:e,"aria-label":`返回`,children:`←`}),(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`h2`,{children:`Git 变更`}),(0,I.jsx)(`span`,{children:`审阅并整理本次工作区修改`})]})]}),r.repository&&(0,I.jsxs)(`span`,{className:`git-branch`,children:[(0,I.jsx)(`i`,{}),r.branch,(0,I.jsx)(`b`,{children:r.head})]})]}),d?(0,I.jsx)(`p`,{className:`manager-empty`,children:`正在读取工作区…`}):r.repository?(0,I.jsxs)(`div`,{className:`git-layout`,children:[(0,I.jsxs)(`aside`,{className:`git-files`,children:[(0,I.jsxs)(`div`,{className:`git-toolbar`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`strong`,{children:`变更`}),(0,I.jsx)(`span`,{children:r.files.length})]}),(0,I.jsx)(`button`,{onClick:()=>void S(),title:`重新读取变更`,children:`↻`})]}),r.files.length===0?(0,I.jsxs)(`div`,{className:`git-clean`,children:[(0,I.jsx)(`i`,{children:`✓`}),(0,I.jsx)(`strong`,{children:`工作区干净`}),(0,I.jsx)(`span`,{children:`没有需要审阅的修改`})]}):r.files.map(e=>{let t=$u(e.path),n=e.untracked?`U`:e.index===`A`?`A`:e.index===`D`||e.worktree===`D`?`D`:`M`;return(0,I.jsxs)(`div`,{className:`git-file-row`,"data-active":a?.path===e.path,children:[(0,I.jsxs)(`button`,{className:`git-file-name`,onClick:()=>void w(e),title:e.path,children:[(0,I.jsx)(`code`,{"data-state":n,children:n}),(0,I.jsxs)(`span`,{children:[(0,I.jsx)(`b`,{children:t.name}),t.directory&&(0,I.jsx)(`small`,{children:t.directory})]})]}),(0,I.jsxs)(`div`,{className:`git-file-actions`,children:[e.staged?(0,I.jsx)(`button`,{onClick:()=>void ee(`unstage`,e),children:`取消暂存`}):(0,I.jsx)(`button`,{className:`stage-action`,onClick:()=>void ee(`stage`,e),children:`暂存`}),(e.unstaged||e.untracked)&&(0,I.jsx)(`button`,{className:`danger-text`,onClick:()=>void ee(`discard`,e),children:`还原`})]})]},e.path)})]}),(0,I.jsx)(`article`,{className:`git-diff`,children:a===void 0?(0,I.jsxs)(`div`,{className:`git-diff-empty`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`span`,{children:`−`}),(0,I.jsx)(`span`,{children:`+`})]}),(0,I.jsx)(`strong`,{children:`选择文件查看差异`}),(0,I.jsx)(`p`,{children:`逐行审阅修改,然后决定暂存或还原。`})]}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`header`,{className:`git-diff-header`,children:[(0,I.jsxs)(`div`,{className:`git-diff-title`,children:[(0,I.jsx)(`span`,{children:$u(a.path).directory||`项目根目录`}),(0,I.jsx)(`strong`,{children:$u(a.path).name})]}),(0,I.jsxs)(`div`,{className:`git-diff-controls`,children:[a.staged&&a.unstaged&&(0,I.jsxs)(`div`,{className:`git-layer-switch`,children:[(0,I.jsx)(`button`,{"data-active":l===`working`,onClick:()=>void C(a,`working`),children:`工作区`}),(0,I.jsx)(`button`,{"data-active":l===`staged`,onClick:()=>void C(a,`staged`),children:`已暂存`})]}),!p&&(0,I.jsxs)(`div`,{className:`git-diff-stats`,children:[(0,I.jsxs)(`span`,{className:`add`,children:[`+`,y]}),(0,I.jsxs)(`span`,{className:`del`,children:[`−`,b]})]})]})]}),(0,I.jsx)(`div`,{className:`git-code`,"aria-label":`${a.path} 差异`,children:p?(0,I.jsxs)(`div`,{className:`git-diff-loading`,children:[(0,I.jsx)(`i`,{}),`正在生成差异…`]}):v.map((e,t)=>(0,I.jsxs)(`div`,{className:`git-code-line`,"data-kind":e.kind,children:[(0,I.jsx)(`span`,{className:`old-line`,children:e.oldNumber??``}),(0,I.jsx)(`span`,{className:`new-line`,children:e.newNumber??``}),(0,I.jsx)(`span`,{className:`change-marker`,children:e.marker}),(0,I.jsx)(`code`,{children:e.text||` `})]},`${t}-${e.oldNumber??``}-${e.newNumber??``}`))})]})})]}):(0,I.jsx)(`p`,{className:`manager-empty`,children:`当前项目不是 Git 仓库`}),r.repository&&(0,I.jsxs)(`footer`,{className:`git-footer`,children:[(0,I.jsx)(`button`,{className:`review-action`,onClick:t,children:`交给 /review`}),(0,I.jsxs)(`div`,{className:`commit-field`,children:[(0,I.jsx)(`input`,{value:h,onChange:e=>g(e.target.value),placeholder:x>0?`描述这次提交…`:`暂存文件后即可提交`}),(0,I.jsxs)(`span`,{children:[x,` 个文件已暂存`]})]}),(0,I.jsx)(`button`,{className:`commit-action`,disabled:!h.trim()||x===0,onClick:()=>void te(),children:`提交`})]})]})}function $u(e){let t=e.replace(/\\/g,`/`),n=t.lastIndexOf(`/`);return n<0?{name:t,directory:``}:{name:t.slice(n+1),directory:t.slice(0,n)}}function ed(e){return e instanceof Error?e.message:String(e)}function td(e){let t=[],n,r=()=>{if(n===void 0)return;let e=n.lines.length,r=n.hunks.map((t,r)=>({...t,end:n.hunks[r+1]?.start??e}));t.push({...n,hunks:r})};for(let t of e.split(/\r?\n/)){let e=/^diff --(?:git|flavor) a\/(.+?) b\/(.+)$/.exec(t);if(e!==null){r(),n={path:e[2],lines:[t],hunks:[],additions:0,deletions:0};continue}if(n===void 0)continue;let i=n.lines.length;n.lines.push(t),t.startsWith(`@@`)?n.hunks.push({id:`${n.path}:${n.hunks.length+1}`,header:t,start:i,end:i+1}):t.startsWith(`+`)&&!t.startsWith(`+++`)?n.additions+=1:t.startsWith(`-`)&&!t.startsWith(`---`)&&(n.deletions+=1)}return r(),t}function nd(e){return Math.min(2.4,Math.max(.55,e))}function rd(e,t,n){let r=nd(n),i=r/e.scale;return{x:t.x-(t.x-e.x)*i,y:t.y-(t.y-e.y)*i,scale:r}}function id(e,t,n){return{x:Math.round(t.x+e.x*n.width*t.scale/100),y:Math.round(t.y+e.y*n.height*t.scale/100)}}function ad(e,t){let n=new Map,r=[];n.set(e.id,{...e,role:`origin`,x:50,y:50});let i=(t,i,a)=>{t.slice(0,8).forEach((t,o,s)=>{n.set(t.id,{...t,role:i,x:a,y:(o+1)*100/(s.length+1)}),r.push(i===`caller`?{from:t.id,to:e.id,kind:i}:{from:e.id,to:t.id,kind:i})})};i(t.callers,`caller`,14),i(t.callees,`callee`,86);let a=t.impact.filter(e=>!n.has(e.id)).slice(0,12),o=Math.ceil(a.length/2);return a.forEach((t,i)=>{let s=i<o,c=s?i:i-o,l=s?o:a.length-o,u=Math.floor(c/3),d=c%3,f=Math.min(3,l-u*3),p=(d+1)*100/(f+1),m=s?13+u*11:87-u*11;n.set(t.id,{...t,role:`impact`,x:p,y:m,hop:t.hop}),r.push({from:e.id,to:t.id,kind:`impact`,hop:t.hop})}),{nodes:[...n.values()],edges:r}}function od(e){let t=new Map(e.map(e=>[e.id,e]));return e.map(e=>{let n=0,r=e.parentId,i=new Set([e.id]);for(;r!==null&&n<12&&!i.has(r);){i.add(r);let e=t.get(r);if(e===void 0)break;n+=1,r=e.parentId}return{node:e,depth:n}})}function sd(e){return e.replaceAll(`\\`,`/`).split(`/`).filter(Boolean).at(-1)??e}function cd(e,t){let n=t.filter(e=>e.state!==`closed`);return e!==void 0&&n.some(t=>t.id===e)?e:n.find(e=>e.state===`running`)?.id??n[0]?.id}var ld=`modulepreload`,ud=function(e,t){return new URL(e,t).href},dd={},fd=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?import.meta.resolve(e):new URL(e,import.meta.url).href}r=o(t.map(t=>{if(t=ud(t,n),t=s(t),t in dd)return;dd[t]=!0;let r=t.endsWith(`.css`);for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}let i=document.createElement(`link`);if(i.rel=r?`stylesheet`:ld,r||(i.as=`script`),i.crossOrigin=``,i.href=t,a&&i.setAttribute(`nonce`,a),document.head.appendChild(i),r)return new Promise((e,n)=>{i.addEventListener(`load`,e),i.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},pd=[{id:`cockpit`,label:`执行`},{id:`timeline`,label:`时间机`},{id:`terminal`,label:`终端`},{id:`review`,label:`审查`},{id:`preview`,label:`预览`},{id:`context`,label:`上下文`},{id:`ast`,label:`代码图`},{id:`pals`,label:`Pals`},{id:`worktrees`,label:`工作树`}],md=_.lazy(()=>fd(()=>import(`./interactive-terminal-CNgUWG7b.js`),[],import.meta.url));function hd({snapshot:e,onClose:t,onError:n,onCompose:r}){let[i,a]=(0,_.useState)(`cockpit`),[o,s]=(0,_.useState)(()=>Od(e.jobs.map(e=>e.label).join(`
151
151
  `))),c=(0,_.useRef)(new Map),l=e=>s(t=>[...new Set([...t,...Od(e)])].slice(-20));return(0,_.useEffect)(()=>{let t=!1;return Promise.all(e.jobs.map(async e=>{let n=await window.flavorDesktop.readJob(e.id,c.current.get(e.id)??0).catch(()=>void 0);n===void 0||t||(c.current.set(e.id,n.cursor),l(n.output))})),()=>{t=!0}},[e.jobs]),(0,I.jsxs)(`section`,{className:`agent-workbench manager-view`,children:[(0,I.jsxs)(`header`,{className:`manager-header workbench-header`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`button`,{onClick:t,children:`‹`}),(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`small`,{children:`FLAVOR DESKTOP 1.3.4`}),(0,I.jsx)(`h2`,{children:`Agent 工作台`})]})]}),(0,I.jsx)(`span`,{children:e.activeSession?.environment===`worktree`?`隔离工作树`:`本地检出`})]}),(0,I.jsx)(`nav`,{className:`workbench-tabs`,"aria-label":`工作台功能`,children:pd.map(e=>(0,I.jsx)(`button`,{"data-active":i===e.id,onClick:()=>a(e.id),children:e.label},e.id))}),(0,I.jsxs)(`div`,{className:`workbench-stage`,children:[i===`cockpit`&&(0,I.jsx)(gd,{snapshot:e,onCompose:r}),i===`timeline`&&(0,I.jsx)(_d,{onError:n}),i===`terminal`&&(0,I.jsx)(vd,{onError:n,onDiscover:l}),i===`review`&&(0,I.jsx)($,{onError:n,onCompose:r}),i===`preview`&&(0,I.jsx)(bd,{onError:n,suggestions:o}),i===`context`&&(0,I.jsx)(xd,{snapshot:e,onError:n}),i===`ast`&&(0,I.jsx)(Sd,{onError:n,onCompose:r}),i===`pals`&&(0,I.jsx)(Td,{onError:n}),i===`worktrees`&&(0,I.jsx)(Ed,{snapshot:e,onError:n})]})]})}function gd({snapshot:e,onCompose:t}){let[n,r]=(0,_.useState)(),[i,a]=(0,_.useState)(``);(0,_.useEffect)(()=>{window.flavorDesktop.inspectWorkbench().then(r).catch(()=>void 0)},[e.activeSession?.sessionId]);let o=n?.goals[0];(0,_.useEffect)(()=>{o!==void 0&&a(o.objective)},[o?.id]);let s=e.tasks?.plan?.tasks??[],c=Object.entries(e.tasks?.subagents.states??{});return(0,I.jsxs)(`div`,{className:`cockpit-grid`,children:[(0,I.jsxs)(`section`,{className:`cockpit-trace`,children:[(0,I.jsxs)(`header`,{children:[(0,I.jsx)(`small`,{children:`EXECUTION TRACE`}),(0,I.jsx)(`h3`,{children:o?.objective??`当前会话尚未启动持久目标`})]}),(0,I.jsx)(`ol`,{children:s.length===0?(0,I.jsxs)(`li`,{"data-state":`pending`,children:[(0,I.jsx)(`i`,{}),(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`strong`,{children:`等待执行计划`}),(0,I.jsx)(`small`,{children:`TaskPlan 出现后会自动同步`})]})]}):s.map(e=>(0,I.jsxs)(`li`,{"data-state":e.status,children:[(0,I.jsx)(`i`,{}),(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`strong`,{children:e.subject}),(0,I.jsxs)(`small`,{children:[e.status,e.result?` · ${e.result}`:``]})]})]},e.id))})]}),(0,I.jsxs)(`aside`,{className:`cockpit-evidence`,children:[(0,I.jsxs)(`section`,{children:[(0,I.jsx)(`small`,{children:`目标状态`}),(0,I.jsx)(`b`,{"data-phase":o?.phase,children:o?.phase??`idle`}),(0,I.jsx)(`p`,{children:o?`${o.status} · worker ${o.workerRounds} · verify ${o.verifyRounds}`:`使用 /goal 启动带验证的长期任务`}),o&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`textarea`,{className:`cockpit-goal-editor`,value:i,onChange:e=>a(e.target.value),"aria-label":`继续目标`}),(0,I.jsxs)(`div`,{className:`cockpit-goal-actions`,children:[e.activeSession?.busy&&(0,I.jsx)(`button`,{onClick:()=>void window.flavorDesktop.interrupt(),children:`安全暂停`}),(0,I.jsx)(`button`,{disabled:!i.trim(),onClick:()=>t(`/goal ${i.trim()}`),children:`以编辑目标继续`})]})]})]}),(0,I.jsxs)(`section`,{children:[(0,I.jsx)(`small`,{children:`协作 Agent`}),c.length===0?(0,I.jsx)(`p`,{children:`没有活跃子 Agent`}):c.map(([e,t])=>(0,I.jsxs)(`div`,{className:`cockpit-row`,children:[(0,I.jsx)(`code`,{children:e}),(0,I.jsx)(`span`,{"data-state":t,children:t})]},e))]}),(0,I.jsxs)(`section`,{children:[(0,I.jsx)(`small`,{children:`后台作业`}),e.jobs.length===0?(0,I.jsx)(`p`,{children:`没有后台作业`}):e.jobs.map(e=>(0,I.jsxs)(`div`,{className:`cockpit-row`,children:[(0,I.jsx)(`code`,{children:e.label}),(0,I.jsx)(`span`,{"data-state":e.state,children:e.state})]},e.id))]}),o&&o.evidenceRounds.length>0&&(0,I.jsxs)(`section`,{children:[(0,I.jsx)(`small`,{children:`验证证据`}),o.evidenceRounds.slice(-3).reverse().map(e=>(0,I.jsxs)(`div`,{className:`cockpit-evidence-round`,children:[(0,I.jsxs)(`b`,{children:[`ROUND `,e.round]}),(0,I.jsx)(`p`,{children:e.hostVerification?.summary??`workspace ${e.workspaceDiffHash.slice(0,10)}`}),(0,I.jsx)(`span`,{"data-passed":e.hostVerification?.passed,children:e.hostVerification===void 0?`workspace evidence`:e.hostVerification.passed?`passed`:`failed`})]},e.round))]}),o&&o.lastGaps.length>0&&(0,I.jsxs)(`section`,{children:[(0,I.jsx)(`small`,{children:`验证缺口`}),o.lastGaps.map((e,t)=>(0,I.jsx)(`p`,{className:`cockpit-gap`,children:e.description},t))]})]})]})}function _d({onError:e}){let[t,n]=(0,_.useState)({leafId:null,nodes:[]}),[r,i]=(0,_.useState)(``),[a,o]=(0,_.useState)(!1),s=()=>window.flavorDesktop.historySnapshot().then(n).catch(t=>e(Dd(t)));(0,_.useEffect)(()=>{s()},[]);let c=async t=>{o(!0);try{await t(),await s()}catch(t){e(Dd(t))}finally{o(!1)}},l=od(t.nodes);return(0,I.jsxs)(`div`,{className:`timeline-layout`,children:[(0,I.jsxs)(`section`,{className:`timeline-canvas`,children:[(0,I.jsxs)(`header`,{children:[(0,I.jsx)(`small`,{children:`SESSION TREE`}),(0,I.jsxs)(`h3`,{children:[t.nodes.length,` 个可恢复节点`]})]}),(0,I.jsx)(`ol`,{children:l.map(({node:e,depth:n})=>(0,I.jsxs)(`li`,{className:`timeline-node`,style:{paddingLeft:n*26},"data-depth":n,"data-current":e.id===t.leafId,children:[(0,I.jsx)(`i`,{}),(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`strong`,{children:e.prompt||e.id}),(0,I.jsxs)(`small`,{children:[new Date(e.createdAt).toLocaleString(),` · `,e.checkpointId]})]}),(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`button`,{disabled:a,onClick:()=>void c(()=>window.flavorDesktop.rewindHistory(e.id)),children:`回到这里`}),(0,I.jsx)(`button`,{disabled:a,onClick:()=>{window.confirm(`从这个节点建立新分支?当前上下文将切换。`)&&c(()=>window.flavorDesktop.forkHistory(e.id))},children:`Fork`})]})]},e.id))})]}),(0,I.jsxs)(`aside`,{className:`timeline-actions`,children:[(0,I.jsx)(`h3`,{children:`建立安全点`}),(0,I.jsx)(`input`,{value:r,onChange:e=>i(e.target.value),placeholder:`例如:重构前`}),(0,I.jsx)(`button`,{disabled:a,onClick:()=>void c(()=>window.flavorDesktop.createCheckpoint(r||void 0)),children:`创建 checkpoint`}),(0,I.jsx)(`button`,{disabled:a,onClick:()=>void c(()=>window.flavorDesktop.unrevertHistory()),children:`撤销上次回退`})]})]})}function vd({onError:e,onDiscover:t}){let[n,r]=(0,_.useState)([]),[i,a]=(0,_.useState)(),o=n.find(e=>e.id===i),s=(e,t)=>{let n=e.filter(e=>e.state!==`closed`);r(n),a(e=>cd(t??e,n))},c=async e=>s(await window.flavorDesktop.listTerminals(),e);(0,_.useEffect)(()=>{c().catch(t=>e(Dd(t)))},[]);let l=async()=>{try{let e=await window.flavorDesktop.openTerminal();await c(e.id)}catch(t){e(Dd(t))}},u=async()=>{if(i!==void 0)try{await window.flavorDesktop.closeTerminal(i),await c()}catch(t){e(Dd(t))}};return(0,I.jsxs)(`div`,{className:`terminal-layout`,children:[(0,I.jsxs)(`aside`,{children:[(0,I.jsx)(`button`,{className:`primary`,onClick:()=>void l(),children:`+ 新终端`}),n.map(e=>(0,I.jsxs)(`button`,{"data-active":e.id===i,onClick:()=>a(e.id),title:e.shell,children:[(0,I.jsx)(`strong`,{children:sd(e.shell)}),(0,I.jsxs)(`small`,{children:[e.state,` · `,e.id]})]},e.id))]}),(0,I.jsxs)(`main`,{children:[(0,I.jsxs)(`header`,{children:[(0,I.jsx)(`span`,{title:o?.cwd,children:o?.cwd??`尚未打开终端`}),o&&(0,I.jsx)(`button`,{onClick:()=>void u(),children:`关闭终端`})]}),o===void 0?(0,I.jsxs)(`div`,{className:`terminal-empty`,children:[(0,I.jsx)(`b`,{children:`没有打开终端`}),(0,I.jsx)(`span`,{children:`新建终端后,直接在终端区域输入和操作。`})]}):(0,I.jsx)(_.Suspense,{fallback:(0,I.jsxs)(`div`,{className:`terminal-empty`,children:[(0,I.jsx)(`b`,{children:`正在连接终端`}),(0,I.jsx)(`span`,{children:`正在加载交互渲染器…`})]}),children:(0,I.jsx)(md,{terminal:o,onError:e,onDiscover:t},o.id)})]})]})}function $({onError:e,onCompose:t}){let[n,r]=(0,_.useState)(`working`),[i,a]=(0,_.useState)(``),[o,s]=(0,_.useState)(``),[c,l]=(0,_.useState)(!1),[u,d]=(0,_.useState)(),[f,p]=(0,_.useState)(),m=(0,_.useMemo)(()=>td(o),[o]),h=m.find(e=>e.path===u)??m[0],g=async()=>{l(!0);try{let e=await window.flavorDesktop.gitReview(n,i||void 0);s(e);let t=td(e);d(t[0]?.path),p(t[0]?.hunks[0]?.id)}catch(t){e(Dd(t))}finally{l(!1)}};return(0,_.useEffect)(()=>{if(n===`commit`||n===`base`){s(``),d(void 0),p(void 0);return}g()},[n]),(0,I.jsxs)(`div`,{className:`review-layout`,children:[(0,I.jsxs)(`aside`,{className:`review-scope`,children:[(0,I.jsx)(`small`,{children:`DIFF SCOPE`}),[`working`,`staged`,`last-turn`,`commit`,`base`].map(e=>(0,I.jsx)(`button`,{"data-active":n===e,onClick:()=>r(e),children:e},e)),(n===`commit`||n===`base`)&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`input`,{value:i,onChange:e=>a(e.target.value),placeholder:n===`base`?`main / origin/main`:`commit SHA`}),(0,I.jsx)(`button`,{onClick:()=>void g(),children:`载入范围`})]})]}),(0,I.jsxs)(`section`,{className:`review-files`,"aria-label":`变更文件`,children:[(0,I.jsxs)(`header`,{children:[(0,I.jsx)(`strong`,{children:`文件`}),(0,I.jsx)(`span`,{children:m.length})]}),m.map(e=>(0,I.jsxs)(`button`,{"data-active":e.path===h?.path,onClick:()=>{d(e.path),p(e.hunks[0]?.id)},children:[(0,I.jsx)(`strong`,{children:e.path.split(`/`).at(-1)}),(0,I.jsx)(`small`,{children:e.path}),(0,I.jsxs)(`span`,{children:[(0,I.jsxs)(`b`,{children:[`+`,e.additions]}),(0,I.jsxs)(`em`,{children:[`-`,e.deletions]})]})]},e.path))]}),(0,I.jsxs)(`main`,{children:[(0,I.jsxs)(`header`,{children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`strong`,{children:h?.path??n}),(0,I.jsxs)(`span`,{children:[h?.hunks.length??0,` hunks`]})]}),(0,I.jsx)(`button`,{onClick:()=>t(`/review 请审查 ${n}${i?` ${i}`:``}${h?` 中的 ${h.path}`:``},按 P0/P1/P2 分级输出发现,必须给出文件行号和触发场景。`),children:`交给 Agent 审查`})]}),h&&h.hunks.length>0&&(0,I.jsx)(`nav`,{className:`review-hunks`,"aria-label":`Hunk 导航`,children:h.hunks.map((e,t)=>(0,I.jsxs)(`button`,{"data-active":f===e.id,onClick:()=>p(e.id),children:[`H`,t+1,(0,I.jsx)(`span`,{children:e.header})]},e.id))}),(0,I.jsx)(yd,{file:h,activeHunk:f,loading:c,empty:o}),(0,I.jsxs)(`footer`,{className:`review-priority-legend`,children:[(0,I.jsx)(`span`,{"data-priority":`0`,children:`P0 阻断`}),(0,I.jsx)(`span`,{"data-priority":`1`,children:`P1 高风险`}),(0,I.jsx)(`span`,{"data-priority":`2`,children:`P2 一般`}),(0,I.jsx)(`small`,{children:`审查结果将在对话中返回,并携带文件行号。`})]})]})]})}function yd({file:e,activeHunk:t,loading:n,empty:r}){return n?(0,I.jsx)(`div`,{className:`review-empty`,children:`正在生成 diff…`}):e===void 0?(0,I.jsx)(`div`,{className:`review-empty`,children:r||`此范围没有差异`}):(0,I.jsx)(`div`,{className:`review-code`,role:`region`,"aria-label":`${e.path} 差异`,children:(0,I.jsx)(`pre`,{children:e.lines.map((n,r)=>{let i=e.hunks.find(e=>r>=e.start&&r<e.end);return(0,I.jsx)(`code`,{"data-kind":n.startsWith(`+++`)||n.startsWith(`---`)?`meta`:n.startsWith(`+`)?`addition`:n.startsWith(`-`)?`deletion`:n.startsWith(`@@`)?`hunk`:`context`,"data-active":i?.id===t,children:n||` `},r)})})})}function bd({onError:e,suggestions:t}){let[n,r]=(0,_.useState)(`http://localhost:3000`),[i,a]=(0,_.useState)(),[o,s]=(0,_.useState)(0),c=async()=>{try{a(await window.flavorDesktop.validatePreviewUrl(n))}catch(t){e(Dd(t))}};return(0,I.jsxs)(`div`,{className:`preview-layout`,children:[(0,I.jsxs)(`header`,{children:[(0,I.jsx)(`input`,{value:n,onChange:e=>r(e.target.value),onKeyDown:e=>{e.key===`Enter`&&c()}}),(0,I.jsx)(`button`,{onClick:()=>void c(),children:`打开`}),(0,I.jsx)(`button`,{disabled:!i,onClick:()=>s(e=>e+1),children:`刷新`}),(0,I.jsx)(`button`,{disabled:!i,onClick:()=>{i&&window.flavorDesktop.openPreviewUrl(i)},children:`外部打开`}),(0,I.jsx)(`button`,{disabled:!i,onClick:()=>{i&&navigator.clipboard.writeText(i)},children:`复制`})]}),t.length>0&&(0,I.jsxs)(`div`,{className:`preview-suggestions`,children:[`检测到:`,t.map(t=>(0,I.jsx)(`button`,{onClick:()=>{r(t),window.flavorDesktop.validatePreviewUrl(t).then(a).catch(t=>e(Dd(t)))},children:t},t))]}),i?(0,I.jsx)(`iframe`,{src:i,title:`本地应用预览`,sandbox:`allow-forms allow-modals allow-popups allow-scripts allow-same-origin`},o):(0,I.jsxs)(`div`,{className:`preview-empty`,children:[(0,I.jsx)(`strong`,{children:`安全的本地预览`}),(0,I.jsx)(`p`,{children:`仅允许 localhost、127.0.0.1 和 ::1 的 HTTP(S) 地址。`})]})]})}function xd({snapshot:e,onError:t}){let[n,r]=(0,_.useState)();return(0,_.useEffect)(()=>{window.flavorDesktop.inspectWorkbench().then(r).catch(e=>t(Dd(e)))},[]),(0,I.jsxs)(`div`,{className:`context-grid`,children:[(0,I.jsxs)(`section`,{children:[(0,I.jsxs)(`header`,{children:[(0,I.jsx)(`small`,{children:`RUNTIME`}),(0,I.jsx)(`h3`,{children:`上下文 Epoch`})]}),(0,I.jsxs)(`dl`,{children:[(0,I.jsx)(`dt`,{children:`Permission`}),(0,I.jsx)(`dd`,{children:e.activeSession?.permissionMode??`—`}),(0,I.jsx)(`dt`,{children:`Model`}),(0,I.jsx)(`dd`,{children:e.activeSession?.mainModel??`—`}),(0,I.jsx)(`dt`,{children:`Checkout`}),(0,I.jsx)(`dd`,{children:e.activeSession?.workingDirectory??e.workspace??`—`})]}),n?.context?.epoch!==void 0&&(0,I.jsx)(`pre`,{className:`context-record`,children:JSON.stringify(n.context.epoch,null,2)}),n?.context?.visibility.map((e,t)=>(0,I.jsx)(`pre`,{className:`context-record`,children:JSON.stringify(e,null,2)},t)),n?.context?.usage.map((e,t)=>(0,I.jsx)(`pre`,{className:`context-record`,children:JSON.stringify(e,null,2)},`usage-${t}`)),e.diagnostics.map((e,t)=>(0,I.jsx)(`p`,{className:`context-record`,children:e},`diag-${t}`))]}),(0,I.jsxs)(`section`,{children:[(0,I.jsxs)(`header`,{children:[(0,I.jsx)(`small`,{children:`INSTRUCTIONS`}),(0,I.jsx)(`h3`,{children:`生效的项目指令`})]}),n?.instructions.map(e=>(0,I.jsxs)(`details`,{children:[(0,I.jsx)(`summary`,{children:e.name}),(0,I.jsx)(`pre`,{children:e.content})]},e.path))]}),(0,I.jsxs)(`section`,{children:[(0,I.jsxs)(`header`,{children:[(0,I.jsx)(`small`,{children:`SAFETY`}),(0,I.jsx)(`h3`,{children:`权限规则与审计`})]}),n?.permissionFiles.map(e=>(0,I.jsxs)(`details`,{children:[(0,I.jsxs)(`summary`,{children:[e.tier,` · `,e.path]}),(0,I.jsx)(`pre`,{children:e.content})]},e.path)),n?.audit.slice(0,30).map((e,t)=>(0,I.jsx)(`pre`,{className:`context-record`,children:JSON.stringify(e,null,2)},t))]})]})}function Sd({onError:e,onCompose:t}){let[n,r]=(0,_.useState)(),[i,a]=(0,_.useState)(``),[o,s]=(0,_.useState)([]),[c,l]=(0,_.useState)(),[u,d]=(0,_.useState)(),[f,p]=(0,_.useState)(2),[m,h]=(0,_.useState)(!1);(0,_.useEffect)(()=>{window.flavorDesktop.astStatus().then(r).catch(t=>e(Dd(t)))},[]);let g=async()=>{try{s(await window.flavorDesktop.astSearch(i))}catch(t){e(Dd(t))}},v=async(t,n=f)=>{l(t),h(!0);try{d(await window.flavorDesktop.astRelations(t.id,n))}catch(t){e(Dd(t))}finally{h(!1)}},y=c===void 0||u===void 0?void 0:ad(c,u);return(0,I.jsxs)(`div`,{className:`ast-layout`,children:[(0,I.jsxs)(`aside`,{className:`ast-symbols`,children:[(0,I.jsxs)(`header`,{children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`small`,{children:`SYMBOL INDEX`}),(0,I.jsx)(`strong`,{children:`代码索引`})]}),(0,I.jsx)(`span`,{"data-ready":n?.available,children:n?.available?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`b`,{children:n.nodes}),` symbols`,(0,I.jsx)(`br`,{}),(0,I.jsx)(`b`,{children:n.edges}),` edges`]}):`尚未建立索引`})]}),(0,I.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),g()},children:[(0,I.jsx)(`span`,{"aria-hidden":`true`,children:`⌕`}),(0,I.jsx)(`input`,{"aria-label":`搜索代码符号`,value:i,onChange:e=>a(e.target.value),placeholder:`函数、类型或模块`}),(0,I.jsx)(`button`,{children:`搜索`})]}),(0,I.jsx)(`div`,{className:`ast-symbol-list`,children:o.length===0?(0,I.jsx)(`p`,{children:n?.available===!1?`项目尚未建立代码索引`:`输入名称,定位代码中的关键符号`}):o.map(e=>(0,I.jsxs)(`button`,{"data-active":e.id===c?.id,onClick:()=>void v(e),children:[(0,I.jsxs)(`span`,{children:[(0,I.jsx)(`strong`,{children:e.name}),(0,I.jsx)(`em`,{children:e.kind})]}),(0,I.jsxs)(`small`,{children:[e.filePath,`:`,e.startLine]})]},e.id))})]}),(0,I.jsxs)(`main`,{className:`ast-graph-stage`,children:[(0,I.jsxs)(`header`,{children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`small`,{children:`RELATION MAP`}),(0,I.jsx)(`h3`,{children:c?.qualifiedName??`代码关系浏览器`}),(0,I.jsx)(`code`,{children:c?`${c.filePath}:${c.startLine}-${c.endLine}`:`搜索并选择一个符号作为图中心`})]}),(0,I.jsxs)(`div`,{className:`ast-depth`,"aria-label":`影响深度`,children:[(0,I.jsx)(`span`,{children:`影响深度`}),[1,2,3,4].map(e=>(0,I.jsx)(`button`,{"aria-label":`${e} 层影响深度`,"data-active":f===e,onClick:()=>{p(e),c&&v(c,e)},children:e},e))]})]}),m?(0,I.jsx)(`div`,{className:`ast-graph-empty`,children:`正在展开关系图…`}):y?(0,I.jsx)(Cd,{graph:y,selected:c,onSelect:e=>void v(e)}):(0,I.jsxs)(`div`,{className:`ast-graph-empty`,children:[(0,I.jsx)(`strong`,{children:`从一个符号开始`}),(0,I.jsx)(`p`,{children:`搜索函数、类或模块,在同一张图上查看调用者、被调用项和多跳影响范围。`})]})]}),(0,I.jsxs)(`aside`,{className:`ast-inspector`,children:[(0,I.jsxs)(`header`,{children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`small`,{children:`SYMBOL INSPECTOR`}),(0,I.jsx)(`h3`,{children:c?.name??`未选择符号`})]}),c&&(0,I.jsx)(`span`,{children:c.kind})]}),c?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`dl`,{children:[(0,I.jsx)(`dt`,{children:`语言`}),(0,I.jsx)(`dd`,{children:c.language}),(0,I.jsx)(`dt`,{children:`位置`}),(0,I.jsxs)(`dd`,{children:[c.filePath,`:`,c.startLine]}),c.signature&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`dt`,{children:`签名`}),(0,I.jsx)(`dd`,{children:c.signature})]})]}),(0,I.jsxs)(`button`,{className:`ast-compose`,onClick:()=>t(`请查看 @${c.filePath}#L${c.startLine}-L${c.endLine} 中的 ${c.qualifiedName}`),children:[(0,I.jsx)(`span`,{children:`加入输入框`}),(0,I.jsx)(`b`,{"aria-hidden":`true`,children:`↗`})]}),(0,I.jsx)(wd,{title:`Callers`,nodes:u?.callers??[],onSelect:e=>void v(e)}),(0,I.jsx)(wd,{title:`Callees`,nodes:u?.callees??[],onSelect:e=>void v(e)}),(0,I.jsx)(wd,{title:`Impact`,nodes:u?.impact??[],onSelect:e=>void v(e)})]}):(0,I.jsx)(`p`,{className:`ast-inspector-empty`,children:`选择一个符号后,这里会显示源码位置和完整关系。`})]})]})}function Cd({graph:e,selected:t,onSelect:n}){let r={x:0,y:0,scale:1},[i,a]=(0,_.useState)(r),[o,s]=(0,_.useState)({width:0,height:0}),[c,l]=(0,_.useState)(!1),u=(0,_.useRef)(null),d=(0,_.useRef)(void 0),f=new Map(e.nodes.map(e=>[e.id,e]));(0,_.useEffect)(()=>{a(r)},[t.id]),(0,_.useEffect)(()=>{let e=u.current;if(e===null)return;let t=()=>{let t=e.getBoundingClientRect();s({width:t.width,height:t.height})};t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[]);let p=(e,t)=>{let n=u.current?.getBoundingClientRect(),r=t??{x:(n?.width??0)/2,y:(n?.height??0)/2};a(t=>rd(t,r,e))},m=e=>{d.current?.pointerId===e.pointerId&&(d.current=void 0,l(!1),e.currentTarget.hasPointerCapture(e.pointerId)&&e.currentTarget.releasePointerCapture(e.pointerId))};return(0,I.jsxs)(`div`,{ref:u,className:`ast-graph`,"data-dragging":c,role:`region`,"aria-label":`${t.name} 代码关系图,可拖动和滚轮缩放`,onWheel:e=>{e.preventDefault();let t=e.currentTarget.getBoundingClientRect();p(i.scale*Math.exp(-e.deltaY*.0014),{x:e.clientX-t.left,y:e.clientY-t.top})},onPointerDown:e=>{e.button!==0||e.target.closest(`button`)||(e.currentTarget.setPointerCapture(e.pointerId),d.current={pointerId:e.pointerId,x:e.clientX,y:e.clientY},l(!0))},onPointerMove:e=>{let t=d.current;if(t?.pointerId!==e.pointerId)return;let n=e.clientX-t.x,r=e.clientY-t.y;d.current={...t,x:e.clientX,y:e.clientY},a(e=>({...e,x:e.x+n,y:e.y+r}))},onPointerUp:m,onPointerCancel:m,children:[(0,I.jsx)(`div`,{className:`ast-graph-viewport`,style:{transform:`translate(${i.x}px, ${i.y}px) scale(${i.scale})`},children:(0,I.jsx)(`svg`,{viewBox:`0 0 100 100`,preserveAspectRatio:`none`,"aria-hidden":`true`,children:e.edges.map((e,t)=>{let n=f.get(e.from),r=f.get(e.to);if(!n||!r)return null;let i=(n.x+r.x)/2;return(0,I.jsx)(`path`,{"data-kind":e.kind,d:`M ${n.x} ${n.y} C ${i} ${n.y}, ${i} ${r.y}, ${r.x} ${r.y}`},`${e.from}-${e.to}-${t}`)})})}),e.nodes.map(e=>{let t=id(e,i,o);return(0,I.jsxs)(`button`,{className:`ast-graph-node`,"data-role":e.role,style:{left:t.x,top:t.y,visibility:o.width>0?`visible`:`hidden`},onClick:()=>n(e),title:`${e.qualifiedName}\n${e.filePath}:${e.startLine}`,children:[(0,I.jsx)(`i`,{}),(0,I.jsxs)(`span`,{children:[(0,I.jsx)(`strong`,{children:e.name}),(0,I.jsx)(`small`,{children:e.role===`impact`?`hop ${e.hop}`:e.kind})]})]},e.id)}),(0,I.jsxs)(`div`,{className:`ast-graph-hint`,children:[(0,I.jsx)(`span`,{"aria-hidden":`true`,children:`↔`}),` 拖动平移 `,(0,I.jsx)(`i`,{}),` 滚轮缩放`]}),(0,I.jsxs)(`div`,{className:`ast-graph-controls`,"aria-label":`画布缩放`,children:[(0,I.jsx)(`button`,{"aria-label":`放大`,onClick:()=>p(i.scale*1.2),children:`+`}),(0,I.jsxs)(`span`,{children:[Math.round(i.scale*100),`%`]}),(0,I.jsx)(`button`,{"aria-label":`缩小`,onClick:()=>p(i.scale/1.2),children:`−`}),(0,I.jsx)(`button`,{className:`ast-graph-reset`,"aria-label":`复位画布`,onClick:()=>a(r),children:`复位`})]}),(0,I.jsxs)(`div`,{className:`ast-graph-legend`,children:[(0,I.jsx)(`span`,{"data-kind":`caller`,children:`调用者`}),(0,I.jsx)(`span`,{"data-kind":`origin`,children:`中心符号`}),(0,I.jsx)(`span`,{"data-kind":`callee`,children:`被调用`}),(0,I.jsx)(`span`,{"data-kind":`impact`,children:`影响范围`})]})]})}function wd({title:e,nodes:t,onSelect:n}){return(0,I.jsxs)(`section`,{className:`ast-relation`,children:[(0,I.jsxs)(`h4`,{children:[e,(0,I.jsx)(`span`,{children:t.length})]}),t.length===0?(0,I.jsx)(`p`,{children:`没有关系记录`}):t.slice(0,20).map(e=>(0,I.jsxs)(`button`,{onClick:()=>n(e),children:[(0,I.jsx)(`strong`,{children:e.name}),(0,I.jsxs)(`code`,{children:[e.filePath,`:`,e.startLine]})]},e.id))]})}function Td({onError:e}){let[t,n]=(0,_.useState)([]),[r,i]=(0,_.useState)(),[a,o]=(0,_.useState)(``),[s,c]=(0,_.useState)(``),[l,u]=(0,_.useState)(),[d,f]=(0,_.useState)(),[p,m]=(0,_.useState)(),[h,g]=(0,_.useState)(),v=()=>window.flavorDesktop.listPals().then(e=>{f(void 0),n(e),i(t=>e.some(e=>e.alias===t)?t:e[0]?.alias)}).catch(e=>{n([]),f(Dd(e))});(0,_.useEffect)(()=>{v();let e=window.setInterval(v,4e3);return()=>window.clearInterval(e)},[]);let y=async(t,n,r)=>{m(t),g(void 0);try{r(await n())}catch(t){e(Dd(t))}finally{m(void 0)}},b=t.find(e=>e.alias===r),x=b?.alias,S=typeof l==`object`&&l?l:void 0,C=typeof S?.coWorkId==`string`?S.coWorkId:void 0,w=typeof S?.status==`string`?S.status:`created`,ee=e=>{x===void 0||!a.trim()||y(e,()=>window.flavorDesktop.sendPalMessage(x,a.trim(),e),()=>{o(``),g(e===`chat`?`消息已发送给 ${x}`:`任务已委托给 ${x}`)})};return(0,I.jsxs)(`div`,{className:`pals-layout`,children:[(0,I.jsxs)(`aside`,{children:[(0,I.jsxs)(`header`,{children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`small`,{children:`LOCAL BROKER`}),(0,I.jsx)(`h3`,{children:`在线 Pals`})]}),(0,I.jsx)(`span`,{children:t.length})]}),d===void 0?t.length===0&&(0,I.jsxs)(`div`,{className:`pals-list-empty`,children:[(0,I.jsx)(`b`,{children:`等待其他实例`}),(0,I.jsx)(`p`,{children:`同一台设备上的 Flavor 实例上线后会出现在这里。`})]}):(0,I.jsxs)(`div`,{className:`pals-unavailable`,children:[(0,I.jsx)(`strong`,{children:`正在恢复本地协作`}),(0,I.jsx)(`p`,{children:`broker 暂时不可用,工作台会自动重试。`}),(0,I.jsx)(`button`,{onClick:()=>void v(),children:`立即重试`})]}),(0,I.jsx)(`div`,{className:`pals-list`,children:t.map(e=>(0,I.jsxs)(`button`,{"data-active":r===e.alias,onClick:()=>{i(e.alias),g(void 0)},children:[(0,I.jsx)(`span`,{className:`pal-presence`,children:(0,I.jsx)(`i`,{})}),(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`strong`,{children:e.alias}),(0,I.jsx)(`small`,{title:e.projectPath??e.id,children:e.projectPath??e.id})]}),(0,I.jsx)(`em`,{children:`在线`})]},e.id))})]}),(0,I.jsxs)(`main`,{children:[(0,I.jsxs)(`header`,{className:`pals-channel-header`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`small`,{children:`CO-WORK CHANNEL`}),(0,I.jsx)(`h3`,{children:x??`没有选中 Pal`}),(0,I.jsx)(`p`,{title:b?.projectPath,children:b?.projectPath??`从左侧选择一个在线实例后即可发送消息、委托任务或共同执行目标。`})]}),(0,I.jsxs)(`span`,{"data-online":b!==void 0,children:[(0,I.jsx)(`i`,{}),b===void 0?`等待选择`:`连接正常`]})]}),(0,I.jsxs)(`div`,{className:`pals-compose-grid`,children:[(0,I.jsxs)(`section`,{className:`pal-compose-card`,"data-kind":`message`,children:[(0,I.jsxs)(`header`,{children:[(0,I.jsx)(`span`,{children:`MESSAGE`}),(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`h4`,{children:`发消息或委托任务`}),(0,I.jsx)(`p`,{children:`同一段内容,可以即时沟通,也可以交给对方独立执行。`})]})]}),(0,I.jsxs)(`label`,{children:[(0,I.jsx)(`span`,{children:`内容`}),(0,I.jsx)(`textarea`,{"aria-label":`消息或任务内容`,value:a,onChange:e=>o(e.target.value),placeholder:`写下背景、期望结果和必要约束…`})]}),(0,I.jsxs)(`footer`,{children:[(0,I.jsx)(`small`,{children:a.length===0?`建议说明交付结果`:`${a.length} 字符`}),(0,I.jsxs)(`div`,{children:[(0,I.jsxs)(`button`,{disabled:p!==void 0||x===void 0||!a.trim(),onClick:()=>ee(`chat`),children:[(0,I.jsx)(`b`,{children:p===`chat`?`发送中…`:`发送 Chat`}),(0,I.jsx)(`span`,{children:`直接沟通`})]}),(0,I.jsxs)(`button`,{disabled:p!==void 0||x===void 0||!a.trim(),onClick:()=>ee(`task`),children:[(0,I.jsx)(`b`,{children:p===`task`?`委托中…`:`委托 Task`}),(0,I.jsx)(`span`,{children:`异步执行`})]})]})]})]}),(0,I.jsxs)(`section`,{className:`pal-compose-card`,"data-kind":`cowork`,children:[(0,I.jsxs)(`header`,{children:[(0,I.jsx)(`span`,{children:`CO-WORK`}),(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`h4`,{children:`共同完成一个目标`}),(0,I.jsx)(`p`,{children:`双方先共同规划,再持续同步执行状态与结果。`})]})]}),(0,I.jsxs)(`label`,{children:[(0,I.jsx)(`span`,{children:`共同目标`}),(0,I.jsx)(`textarea`,{"aria-label":`共同目标`,value:s,onChange:e=>c(e.target.value),placeholder:`描述目标、完成标准和双方需要协作的部分…`})]}),(0,I.jsxs)(`footer`,{children:[(0,I.jsx)(`small`,{children:s.length===0?`适合跨实例并行工作`:`${s.length} 字符`}),(0,I.jsxs)(`button`,{className:`primary`,disabled:p!==void 0||x===void 0||!s.trim(),onClick:()=>{x===void 0||!s.trim()||y(`cowork`,()=>window.flavorDesktop.startCoWork(x,s.trim()),e=>{u(e),c(``),g(`已与 ${x} 建立共同目标`)})},children:[(0,I.jsx)(`b`,{children:p===`cowork`?`建立中…`:`开始 Co-work`}),(0,I.jsx)(`span`,{children:`共同规划并执行`})]})]})]})]}),h!==void 0&&(0,I.jsxs)(`div`,{className:`pals-notice`,children:[(0,I.jsx)(`i`,{}),` `,h]}),l!==void 0&&(0,I.jsxs)(`section`,{className:`cowork-state`,children:[(0,I.jsxs)(`header`,{children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`small`,{children:`LIVE CO-WORK`}),(0,I.jsx)(`strong`,{children:`最新协作状态`})]}),(0,I.jsx)(`span`,{"data-status":w,children:w}),(0,I.jsxs)(`nav`,{children:[(0,I.jsx)(`button`,{disabled:p!==void 0,onClick:()=>void y(`refresh`,()=>window.flavorDesktop.coWorkStatus(C),u),children:`刷新状态`}),C&&(0,I.jsx)(`button`,{className:`danger`,disabled:p!==void 0,onClick:()=>{window.confirm(`取消这个 Co-work?`)&&y(`cancel`,()=>window.flavorDesktop.cancelCoWork(C,`cancelled from desktop workbench`),e=>{u(e),g(`协作已取消`)})},children:`取消协作`})]})]}),(0,I.jsxs)(`details`,{children:[(0,I.jsx)(`summary`,{children:`查看原始协作数据`}),(0,I.jsx)(`pre`,{children:JSON.stringify(l,null,2)})]})]})]})]})}function Ed({snapshot:e,onError:t}){let[n,r]=(0,_.useState)([]),i=()=>window.flavorDesktop.listWorktrees().then(r).catch(e=>t(Dd(e)));return(0,_.useEffect)(()=>{i()},[]),(0,I.jsxs)(`div`,{className:`worktree-pane`,children:[(0,I.jsxs)(`header`,{children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`small`,{children:`TASK ISOLATION`}),(0,I.jsx)(`h3`,{children:`工作树`}),(0,I.jsx)(`p`,{children:`新任务可在独立分支中运行,不改动当前检出。`})]}),(0,I.jsxs)(`span`,{children:[n.length,` active`]})]}),n.length===0?(0,I.jsx)(`div`,{className:`manager-empty`,children:`还没有隔离工作树。新建任务时选择“隔离工作树”。`}):(0,I.jsx)(`div`,{className:`worktree-list`,children:n.map(n=>(0,I.jsxs)(`article`,{"data-current":e.activeSession?.worktreeId===n.id,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`i`,{}),(0,I.jsx)(`strong`,{children:n.branch}),(0,I.jsx)(`small`,{children:n.path})]}),(0,I.jsx)(`span`,{"data-dirty":n.dirty,children:n.merged?`merged`:n.dirty?`dirty`:`clean`}),(0,I.jsxs)(`div`,{className:`worktree-actions`,children:[(0,I.jsx)(`button`,{disabled:n.dirty||n.merged,onClick:()=>{window.confirm(`将 ${n.branch} 合并回当前项目分支?`)&&window.flavorDesktop.mergeWorktree(n.id).then(i).catch(e=>t(Dd(e)))},children:`合并交付`}),(0,I.jsx)(`button`,{onClick:()=>{window.confirm(`移除工作树 ${n.branch}?${n.dirty?`存在未提交变更,将强制移除。`:`分支会保留。`}`)&&window.flavorDesktop.removeWorktree(n.id,n.dirty).then(i).catch(e=>t(Dd(e)))},children:`移除并保留分支`})]})]},n.id))})]})}function Dd(e){return e instanceof Error?e.message:String(e)}function Od(e){return e.match(/https?:\/\/(?:localhost|127\.0\.0\.1|\[?::1\]?)(?::\d{1,5})?(?:\/[^\s"'<>]*)?/gi)??[]}function kd(e,t,n=Date.now()){return{task:e,framework:t,startedAt:n,updatedAt:n,phase:`analyzing`,comparisonCycle:0,activity:[{id:`import`,label:`HTML 设计稿已导入`,state:`completed`,startedAt:n,completedAt:n}]}}function Ad(e,t,n=Date.now()){if(t.type===`model-start`){let r=e.phase===`analyzing`?`分析设计并规划实现`:e.phase===`building`?`检查实现并规划下一步`:`分析评测结果`;return Pd(e,{id:`model:${t.id}`,label:r,state:`running`,startedAt:n},n)}if(t.type===`model-end`)return Fd(e,`model:${t.id}`,`completed`,n);if(t.type===`tool-start`){let r=Md(t.name,e.phase),i=Nd(t.name,t.label,t.hint);return Pd({...e,phase:r},{id:`tool:${t.id}`,label:i,state:`running`,startedAt:n,...t.hint===void 0||t.hint===t.label?{}:{detail:Id(t.hint,72)}},n)}if(t.type===`tool-end`){let r=t.result.ok?`completed`:`failed`,i=e.activity.find(e=>e.id===`tool:${t.id}`);return i===void 0?Pd(e,{id:`tool:${t.id}`,label:Nd(t.name,t.label,t.hint),state:r,startedAt:n,completedAt:n},n):Fd(e,i.id,r,n)}return t.type===`model-retry`?Pd(e,{id:`retry:${t.attempt}`,label:`模型请求重试 ${t.attempt}/${t.maxAttempts}`,detail:`${Math.ceil(t.delayMs/1e3)} 秒后继续`,state:`info`,startedAt:n,completedAt:n},n):t.type===`warning`?Pd(e,{id:`warning:${n}`,label:Id(t.message,96),state:`info`,startedAt:n,completedAt:n},n):t.type===`error`?Pd(e,{id:`error:${n}`,label:Id(t.error.message,96),state:`failed`,startedAt:n,completedAt:n},n):e}function jd(e,t,n=Date.now()){if(t.task!==e.task)return e;let r=`engine:${t.cycle}:${t.stage}`,i=e.activity.find(e=>e.id===r);return Pd({...e,phase:`evaluating`,comparisonCycle:t.cycle},{id:r,label:t.message,state:t.state,startedAt:i?.startedAt??n,...t.state===`running`?{}:{completedAt:n},...t.cached===!0?{detail:`已复用缓存`}:{}},n)}function Md(e,t){return e===`D2cCompare`?`evaluating`:[`Write`,`Edit`,`ApplyPatch`,`Mkdir`,`Copy`,`Move`,`Shell`,`Bash`,`Command`,`Exec`].includes(e)?`building`:t}function Nd(e,t,n){let r=Id(t??n??``,60),i=r===``?``:` ${r}`;return[`Read`,`Glob`,`Grep`,`Search`,`List`].includes(e)?`读取${i||`设计与项目文件`}`:e===`Write`?`创建${i||`前端文件`}`:e===`Edit`||e===`ApplyPatch`?`调整${i||`前端实现`}`:e===`Mkdir`?`创建${i||`项目目录`}`:[`Shell`,`Bash`,`Command`,`Exec`].includes(e)?`运行${i||`项目命令`}`:e===`D2cCompare`?`启动视觉评测`:`${e}${i}`}function Pd(e,t,n){let r=e.activity.findIndex(e=>e.id===t.id),i=[...e.activity];return r<0?i.push(t):i[r]=t,{...e,updatedAt:n,activity:i.slice(-12)}}function Fd(e,t,n,r){let i=e.activity.find(e=>e.id===t);return i===void 0?e:Pd(e,{...i,state:n,completedAt:r},r)}function Id(e,t){let n=e.replaceAll(/\s+/g,` `).trim();return n.length<=t?n:`${n.slice(0,t-1)}…`}var Ld={sessions:[],diagnostics:[],models:[],jobs:[]},Rd=[`default`,`acceptEdits`,`plan`,`bypassPermissions`,`auto`,`bubble`],zd=Z.map(e=>({name:e,description:Rl[e]})),Bd=5,Vd=5*1024*1024,Hd=20*1024*1024,Ud=new Set([`image/png`,`image/jpeg`,`image/webp`]);function Wd(e,t){return[e.trim(),...t.map((e,t)=>`[Image #${t+1}]`)].filter(Boolean).join(`
152
- `)}function Gd({attachments:e,onRemove:t}){return(0,I.jsx)(`div`,{className:`image-attachment-strip`,"aria-label":`待发送图片`,children:e.map((e,n)=>(0,I.jsxs)(`figure`,{className:`image-attachment-chip`,children:[(0,I.jsx)(`img`,{src:e.previewUrl,alt:e.name}),(0,I.jsxs)(`figcaption`,{children:[(0,I.jsxs)(`strong`,{children:[`[Image #`,n+1,`]`]}),(0,I.jsx)(`span`,{children:e.name})]}),(0,I.jsx)(`button`,{type:`button`,onClick:()=>t(e.id),"aria-label":`移除 ${e.name}`,title:`移除图片`,children:`×`})]},e.id))})}function Kd(){let[e,t]=(0,_.useState)(Ld),[n,r]=(0,_.useState)(x),[i,a]=(0,_.useState)(``),[o,s]=(0,_.useState)([]),[c,l]=(0,_.useState)(!0),[u,d]=(0,_.useState)(),[f,p]=(0,_.useState)(!1),[m,h]=(0,_.useState)(!1),[g,v]=(0,_.useState)(),[y,b]=(0,_.useState)(),[C,w]=(0,_.useState)(!1),[ee,te]=(0,_.useState)(0),[ne,re]=(0,_.useState)(),[ie,ae]=(0,_.useState)([]),[oe,se]=(0,_.useState)([]),[ce,le]=(0,_.useState)(0),[ue,T]=(0,_.useState)(),[E,de]=(0,_.useState)(),[fe,pe]=(0,_.useState)(0),[D,O]=(0,_.useState)(`conversation`),[me,he]=(0,_.useState)(!1),[ge,_e]=(0,_.useState)(``),[ve,ye]=(0,_.useState)(`active`),[Ce,Te]=(0,_.useState)(),[Ee,De]=(0,_.useState)(),[Oe,k]=(0,_.useState)(``),[ke,Ae]=(0,_.useState)([]),[je,Me]=(0,_.useState)(-1),[Ne,Pe]=(0,_.useState)(0),[Fe,Ie]=(0,_.useState)(),[Le,Re]=(0,_.useState)(()=>new Map),ze=(0,_.useRef)(null),Be=(0,_.useRef)(null),A=(0,_.useRef)(void 0),Ve=(0,_.useRef)(void 0),He=(0,_.useRef)(n),Ue=(0,_.useRef)(new Map),j=(0,_.useRef)(new Map),We=(0,_.useRef)(new Map),Ge=(0,_.useRef)(new Set),Ke=(0,_.useRef)(!1),qe=(0,_.useCallback)(e=>{a(e),re(void 0),T(void 0)},[]);(0,_.useEffect)(()=>{He.current=n},[n]);let Je=(0,_.useCallback)(()=>{let e=Ve.current;e!==void 0&&(Ue.current.set(e,{sessionId:A.current,transcript:He.current}),A.current!==void 0&&j.current.set(`${e}\u0000${A.current}`,He.current))},[]),Ye=(0,_.useCallback)(e=>{e!==void 0&&Re(t=>{if(!t.has(e))return t;let n=new Map(t);return n.delete(e),n})},[]),Xe=(0,_.useCallback)(e=>{let n=e.workspace;Ve.current=n,A.current=e.activeSession?.sessionId,t(e);let i=n===void 0?void 0:Ue.current.get(n);r(i!==void 0&&i.sessionId===e.activeSession?.sessionId?i.transcript:x()),Ye(n),O(`conversation`),p(!1)},[Ye]);(0,_.useEffect)(()=>()=>{for(let e of Ge.current)URL.revokeObjectURL(e);Ge.current.clear()},[]);let Ze=(0,_.useCallback)(e=>{s(t=>{let n=t.find(t=>t.id===e);return n!==void 0&&(URL.revokeObjectURL(n.previewUrl),Ge.current.delete(n.previewUrl)),t.filter(t=>t.id!==e)})},[]),Qe=(0,_.useCallback)(()=>{s(e=>{for(let t of e)URL.revokeObjectURL(t.previewUrl),Ge.current.delete(t.previewUrl);return[]})},[]),$e=(0,_.useCallback)(async e=>{if(e.length===0)return;let t=Bd-o.length;if(t<=0||e.length>t){d(`每条消息最多添加 ${Bd} 张图片。`);return}if(o.reduce((e,t)=>e+Math.floor(t.dataBase64.length*3/4),0)+e.reduce((e,t)=>e+t.size,0)>Hd){d(`单条消息的图片总大小不能超过 20 MiB。`);return}try{let t=await Promise.all(e.map(sf));for(let e of t)Ge.current.add(e.previewUrl);s(e=>[...e,...t].slice(0,Bd)),d(void 0)}catch(e){d(Cf(e))}},[o]);(0,_.useEffect)(()=>{let e=ze.current;if(!e)return;let t=e=>{e.deltaY<0?Ke.current=!0:requestAnimationFrame(()=>{let e=ze.current;e&&e.scrollHeight-e.scrollTop-e.clientHeight<8&&(Ke.current=!1)})};return e.addEventListener(`wheel`,t,{passive:!0}),()=>e.removeEventListener(`wheel`,t)},[]),(0,_.useEffect)(()=>{let e=window.flavorDesktop.onEvent(e=>{if(e.type===`snapshot`&&e.workspace!==void 0&&e.snapshot.workspace===e.workspace){let t=Ve.current;if(t!==void 0&&t!==e.workspace){Ue.current.set(t,{sessionId:A.current,transcript:He.current});let n=Ue.current.get(e.workspace);r(n!==void 0&&n.sessionId===e.snapshot.activeSession?.sessionId?n.transcript:x()),O(`conversation`),Ye(e.workspace)}Ve.current=e.workspace}else if(e.workspace!==void 0&&(e.workspace!==Ve.current||e.type===`session-output`&&e.sessionId!==A.current||e.type===`session-started`&&e.payload.sessionId!==A.current)){let t=Ue.current.get(e.workspace)??{sessionId:void 0,transcript:x()};if(e.type===`session-started`){let t=S(x(),{type:`restore`,state:e.payload.restoredTranscript});j.current.set(`${e.workspace}\u0000${e.payload.sessionId}`,t),Ue.current.set(e.workspace,{sessionId:e.payload.sessionId,transcript:t})}else if(e.type===`session-output`){let n=`${e.workspace}\u0000${e.sessionId}`,r=we(j.current.get(n)??x(),e.sessionId,e);j.current.set(n,r),t.sessionId===e.sessionId&&Ue.current.set(e.workspace,{...t,transcript:r})}return}if(e.type===`d2c-report`){Pe(e=>e+1),Ie(t=>t!==void 0&&t.task===e.payload.task?void 0:t),O(`e2e`);return}if(e.type===`d2c-progress`){Ie(t=>t===void 0?t:jd(t,e.payload));return}e.type===`session-output`&&e.sessionId===A.current&&Ie(t=>t===void 0?t:Ad(t,e.event)),(e.type===`session-output`&&e.sessionId===A.current&&[`done`,`error`,`exit`].includes(e.event.type)||e.type===`runtime-error`&&(e.sessionId===void 0||e.sessionId===A.current))&&Ie(void 0),Zd(e,A,t,r,d)});return window.flavorDesktop.bootstrap().then(e=>{Ve.current=e.workspace,A.current=e.activeSession?.sessionId,t(e)}).catch(e=>d(Cf(e))).finally(()=>l(!1)),e},[]),(0,_.useEffect)(()=>{Ke.current||ze.current?.scrollTo({top:ze.current.scrollHeight,behavior:`smooth`})},[n]),(0,_.useEffect)(()=>{let e=!1;return window.flavorDesktop.listFiles().then(t=>{e||se(pn(t))}).catch(()=>{}),()=>{e=!0}},[e.workspace]),(0,_.useEffect)(()=>{let t=!1;return e.workspace===void 0?(ae([]),()=>{t=!0}):(window.flavorDesktop.listSkills().then(e=>{t||ae(e)}).catch(()=>{t||ae([])}),()=>{t=!0})},[e.workspace,D]);let et=e.activeSession?.busy??!1,tt=(0,_.useMemo)(()=>e.projects??(e.workspace===void 0?[]:[{workspace:e.workspace,sessions:e.sessions,...e.activeSession===void 0?{}:{activeSession:{sessionId:e.activeSession.sessionId,busy:e.activeSession.busy}},running:et||e.jobs.some(e=>e.state===`running`)}]),[e.projects,e.workspace,e.sessions,e.activeSession,e.jobs,et]);(0,_.useEffect)(()=>{Re(e=>{let t=Se(tt,We.current,e);return We.current=t.activity,t.notices})},[tt]);let nt=(0,_.useMemo)(()=>Qt(zd,[],ie.filter(e=>e.enabled)),[ie]),rt=(0,_.useMemo)(()=>et||e.approval!==void 0||e.questions!==void 0||ne===i?null:en(i,fe,nt,ee),[i,fe,ee,ne,et,e.approval,e.questions,nt]),it=(0,_.useMemo)(()=>et||e.approval!==void 0||e.questions!==void 0||ue===i||rt!==null?null:mn(i,fe,oe,ce),[i,fe,ce,ue,et,e.approval,e.questions,oe,rt]),at=rt===null?$t(i,nt,!1):0,ot=(0,_.useCallback)(e=>{let t=nn(i,fe,e);a(t.text),re(t.text),te(0),pe(t.cursor),setTimeout(()=>{let e=Be.current;e!==null&&(e.focus(),e.setSelectionRange(e.value.length,e.value.length))},0)},[i,fe]),st=(0,_.useCallback)(()=>{re(i)},[i]),ct=(0,_.useCallback)(e=>{te(t=>tn(t,e,rt?.items.length??0))},[rt]),lt=(0,_.useCallback)(e=>{let t=gn(i,fe,e);a(t.text),T(t.text),le(0),de(t.span),pe(t.cursor),setTimeout(()=>{let e=Be.current;e!==null&&(e.focus(),e.setSelectionRange(e.value.length,e.value.length))},0)},[i,fe]),ut=(0,_.useCallback)(()=>{T(i)},[i]),dt=(0,_.useCallback)(e=>{le(t=>hn(t,e,it?.items.length??0))},[it]),ft=async()=>{d(void 0);try{Je();let e=await window.flavorDesktop.chooseWorkspace();e!==void 0&&(Qe(),Xe(e))}catch(e){d(Cf(e))}},pt=async n=>{if(n===e.workspace)return Ye(n),window.flavorDesktop.acknowledgeSession().then(t).catch(()=>void 0),O(`conversation`),p(!1),e;d(void 0),Je();try{let e=await window.flavorDesktop.openWorkspace(n);return Qe(),Xe(e),window.flavorDesktop.acknowledgeSession().then(t).catch(()=>void 0),e}catch(e){d(Cf(e));return}},mt=async(e,t)=>{let n=await pt(e);if(n!==void 0){if(n.activeSession?.sessionId===t.sessionId){O(`conversation`),p(!1);return}await ht(t)}},ht=async e=>{d(void 0);try{Je();let n=await window.flavorDesktop.selectSession(e.sessionId),i=n.snapshot.workspace===void 0?void 0:j.current.get(`${n.snapshot.workspace}\u0000${n.sessionId}`);t(n.snapshot),Ve.current=n.snapshot.workspace,A.current=n.sessionId,r(i??S(x(),{type:`restore`,state:n.restoredTranscript})),O(`conversation`),p(!1)}catch(e){d(Cf(e))}},gt=async(e,n)=>{d(void 0);try{let i=await window.flavorDesktop.startSession(e?.sessionId,n);Qe(),t(i.snapshot),Ve.current=i.snapshot.workspace,A.current=i.sessionId,r(S(x(),{type:`restore`,state:i.restoredTranscript})),i.snapshot.workspace!==void 0&&j.current.set(`${i.snapshot.workspace}\u0000${i.sessionId}`,S(x(),{type:`restore`,state:i.restoredTranscript})),p(!1),O(`conversation`),setTimeout(()=>Be.current?.focus(),0)}catch(e){d(Cf(e))}},_t=async(n,s,c)=>{let l=(n??i).trim(),u=n===void 0?o:[];if(!l&&u.length===0)return!1;d(void 0);try{let i=e;if(i.activeSession===void 0){let e=await window.flavorDesktop.startSession();i=e.snapshot,t(i),r(S(x(),{type:`restore`,state:e.restoredTranscript}))}let o=s??(et?`steer`:`prompt`);if(u.length>0&&o!==`prompt`)throw Error(`图片只能随新消息发送,不能作为运行中的引导或后续消息。`);return o===`prompt`&&r(e=>S(e,{type:`submit`,prompt:Wd(l,u)})),n===void 0&&a(``),await window.flavorDesktop.submit(l,o,u.map(({name:e,mediaType:t,dataBase64:n})=>({name:e,mediaType:t,dataBase64:n})),c),u.length>0&&Qe(),!0}catch(e){let t=Cf(e);return d(t),r(e=>S(e,{type:`submit-error`,message:t})),!1}},vt=e=>void _t(`/permissions ${e}`),yt=async e=>{d(void 0);try{t(await window.flavorDesktop.switchModel(e))}catch(e){d(Cf(e))}},bt=async()=>{if(!(et||e.activeSession===void 0)){d(void 0);try{await window.flavorDesktop.finishTask()}catch(e){d(Cf(e))}}},xt=async e=>{d(void 0);try{let n=await window.flavorDesktop.addModel(e);t(n.snapshot)}catch(e){throw d(Cf(e)),e}},St=(e,t)=>{let n=t.currentTarget.getBoundingClientRect();window.flavorDesktop.showAppMenu(e,Math.round(n.left),Math.round(n.bottom))},Ct=async()=>{if(!(y===void 0||C)){w(!0),d(void 0);try{let n=y.sessionId===e.activeSession?.sessionId,i=await window.flavorDesktop.deleteSession(y.sessionId);t(i),n&&r(x()),b(void 0),v(void 0)}catch(e){d(Cf(e))}finally{w(!1)}}},wt=async(e,n)=>{try{t(await window.flavorDesktop.updateSession(e.sessionId,n)),v(void 0)}catch(e){d(Cf(e))}},M=e=>{let t=window.prompt(`任务名称`,e.title??be(e));t!==null&&wt(e,{title:t.trim()})},N=async(e,n)=>{try{t(await window.flavorDesktop.updateProject(e,n)),Te(void 0)}catch(e){d(Cf(e))}},Tt=(e,t)=>{let n=window.prompt(`项目显示名称`,t??xe(e));n!==null&&N(e,{label:n.trim()})},Et=async(e,t)=>{if(!(t&&!window.confirm(`项目中有任务正在运行。停止任务并关闭项目?`)))try{Xe(await window.flavorDesktop.closeProject(e,t)),Te(void 0)}catch(e){d(Cf(e))}},Dt=async(e,t)=>{let n=await pt(e);if(n!==void 0&&t!==void 0){let e=n.sessions.find(e=>e.sessionId===t);e!==void 0&&await ht(e)}};(0,_.useEffect)(()=>{let t={...e.workspace===void 0?{}:{workspace:e.workspace},...e.activeSession===void 0?{}:{sessionId:e.activeSession.sessionId},view:D};Ae(e=>{let n=e[je];if(n?.workspace===t.workspace&&n?.sessionId===t.sessionId&&n?.view===t.view)return e;let r=[...e.slice(0,je+1),t].slice(-50);return Me(r.length-1),r})},[e.workspace,e.activeSession?.sessionId,D]);let Ot=async e=>{let n=je+e,i=ke[n];if(i!==void 0){if(Me(n),i.workspace!==void 0){let e=await window.flavorDesktop.openWorkspace(i.workspace);if(Xe(e),i.sessionId!==void 0){let e=await window.flavorDesktop.selectSession(i.sessionId);t(e.snapshot),A.current=e.sessionId,r(j.current.get(`${i.workspace}\u0000${i.sessionId}`)??S(x(),{type:`restore`,state:e.restoredTranscript}))}}O(i.view)}};return(0,_.useEffect)(()=>{let e=e=>{if(!(e.ctrlKey||e.metaKey))return;let t=e.key.toLowerCase();t===`n`&&(e.preventDefault(),he(!0)),t===`p`&&(e.preventDefault(),De(`projects`),k(``)),t===`k`&&(e.preventDefault(),De(`commands`),k(``)),t===`[`&&(e.preventDefault(),Ot(-1)),t===`]`&&(e.preventDefault(),Ot(1))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[e.workspace,ke,je]),(0,I.jsxs)(`div`,{className:`app-frame`,children:[(0,I.jsx)(Xd,{railCollapsed:m,onToggleRail:()=>h(e=>!e),onMenu:St,canBack:je>0,canForward:je<ke.length-1,onBack:()=>void Ot(-1),onForward:()=>void Ot(1)}),(0,I.jsxs)(`div`,{className:`desktop-shell`,"data-rail-collapsed":m,children:[(0,I.jsx)(`button`,{className:`rail-scrim`,"data-open":f,onClick:()=>p(!1),"aria-label":`关闭项目栏`}),(0,I.jsxs)(`aside`,{className:`project-rail`,"data-open":f,children:[(0,I.jsxs)(`div`,{className:`brand-row`,children:[(0,I.jsx)(Sf,{}),(0,I.jsx)(`strong`,{children:`Flavor Code`})]}),(0,I.jsxs)(`nav`,{className:`primary-actions`,"aria-label":`主要操作`,children:[(0,I.jsxs)(`button`,{className:`rail-action rail-action-primary`,disabled:e.workspace===void 0,onClick:()=>he(!0),children:[(0,I.jsx)(`span`,{className:`action-icon`,children:(0,I.jsx)(xf,{name:`plus`})}),(0,I.jsx)(`span`,{children:`新建任务`}),(0,I.jsx)(`kbd`,{children:`Ctrl N`})]}),(0,I.jsxs)(`button`,{className:`rail-action`,onClick:()=>void ft(),children:[(0,I.jsx)(`span`,{className:`action-icon`,children:(0,I.jsx)(xf,{name:`folder`})}),(0,I.jsx)(`span`,{children:`打开项目`})]}),(0,I.jsxs)(`button`,{className:`rail-action`,"data-active":D===`skills`,onClick:()=>{O(`skills`),p(!1)},disabled:e.workspace===void 0,children:[(0,I.jsx)(`span`,{className:`action-icon`,children:(0,I.jsx)(xf,{name:`sparkles`})}),(0,I.jsx)(`span`,{children:`技能`})]}),(0,I.jsxs)(`button`,{className:`rail-action`,"data-active":D===`memory`,onClick:()=>{O(`memory`),p(!1)},disabled:e.workspace===void 0,children:[(0,I.jsx)(`span`,{className:`action-icon`,children:(0,I.jsx)(xf,{name:`database`})}),(0,I.jsx)(`span`,{children:`长期记忆`})]}),(0,I.jsxs)(`button`,{className:`rail-action`,"data-active":D===`mcp`,onClick:()=>{O(`mcp`),p(!1)},disabled:e.workspace===void 0,children:[(0,I.jsx)(`span`,{className:`action-icon`,children:(0,I.jsx)(xf,{name:`server`})}),(0,I.jsx)(`span`,{children:`MCP 服务`})]}),(0,I.jsxs)(`button`,{className:`rail-action`,"data-active":D===`e2e`,onClick:()=>{O(`e2e`),p(!1)},disabled:e.workspace===void 0,children:[(0,I.jsx)(`span`,{className:`action-icon`,children:(0,I.jsx)(xf,{name:`checklist`})}),(0,I.jsx)(`span`,{children:`E2E`})]}),(0,I.jsxs)(`button`,{className:`rail-action`,"data-active":D===`activity`,onClick:()=>{O(`activity`),p(!1)},children:[(0,I.jsx)(`span`,{className:`action-icon`,children:(0,I.jsx)(xf,{name:`bell`})}),(0,I.jsx)(`span`,{children:`活动`}),(e.activities?.filter(e=>e.unread).length??0)>0&&(0,I.jsx)(`em`,{className:`rail-badge`,children:e.activities.filter(e=>e.unread).length})]}),(0,I.jsxs)(`button`,{className:`rail-action`,"data-active":D===`git`,onClick:()=>{O(`git`),p(!1)},disabled:e.workspace===void 0,children:[(0,I.jsx)(`span`,{className:`action-icon`,children:(0,I.jsx)(xf,{name:`git`})}),(0,I.jsx)(`span`,{children:`Git 变更`})]}),(0,I.jsxs)(`button`,{className:`rail-action`,"data-active":D===`workbench`,onClick:()=>{O(`workbench`),p(!1)},disabled:e.workspace===void 0||e.activeSession===void 0,children:[(0,I.jsx)(`span`,{className:`action-icon`,children:(0,I.jsx)(xf,{name:`checklist`})}),(0,I.jsx)(`span`,{children:`Agent 工作台`})]})]}),(0,I.jsxs)(`div`,{className:`sessions-scroll`,children:[(0,I.jsxs)(`div`,{className:`rail-section-heading`,children:[(0,I.jsx)(`span`,{children:`项目`}),(0,I.jsx)(`button`,{onClick:()=>void ft(),"aria-label":`打开新项目`,title:`打开新项目`,children:(0,I.jsx)(xf,{name:`plus`})})]}),tt.length>0&&(0,I.jsxs)(`div`,{className:`session-filter`,children:[(0,I.jsxs)(`div`,{className:`session-search`,children:[(0,I.jsx)(xf,{name:`search`}),(0,I.jsx)(`input`,{value:ge,onChange:e=>_e(e.target.value),placeholder:`搜索任务`,"aria-label":`搜索任务`}),ge.length>0&&(0,I.jsx)(`button`,{type:`button`,onClick:()=>_e(``),"aria-label":`清除搜索`,title:`清除搜索`,children:`×`})]}),(0,I.jsxs)(`div`,{className:`session-group-filter`,children:[(0,I.jsxs)(`select`,{value:ve,onChange:e=>ye(e.target.value),"aria-label":`按状态筛选`,children:[(0,I.jsx)(`option`,{value:`active`,children:`任务`}),(0,I.jsx)(`option`,{value:`running`,children:`运行`}),(0,I.jsx)(`option`,{value:`unread`,children:`未读`}),(0,I.jsx)(`option`,{value:`archived`,children:`归档`})]}),(0,I.jsx)(`span`,{"aria-hidden":`true`})]})]}),tt.length===0?(0,I.jsx)(`button`,{className:`empty-project`,onClick:()=>void ft(),children:`选择一个本地文件夹开始`}):tt.map(t=>{let n=t.workspace===e.workspace,r=Le.has(t.workspace);Le.get(t.workspace);let i=n||t.running||r;return(0,I.jsxs)(`section`,{className:`project-entry`,"data-active":n,children:[(0,I.jsxs)(`div`,{className:`project-heading-shell`,children:[(0,I.jsxs)(`button`,{className:`project-heading`,onClick:()=>void pt(t.workspace),title:t.workspace,children:[(0,I.jsx)(`span`,{className:`folder-icon`,"aria-hidden":`true`,children:(0,I.jsx)(xf,{name:`folder`})}),(0,I.jsx)(`span`,{children:t.label||xe(t.workspace)}),t.running?(0,I.jsx)(`span`,{className:`project-running-dot`,title:`项目中有任务正在执行`}):(t.unreadCount??0)>0&&(0,I.jsx)(`span`,{className:`project-complete-dot`,role:`status`,"aria-label":`项目有未读活动`})]}),(0,I.jsx)(`button`,{className:`project-more`,onClick:()=>Te(e=>e===t.workspace?void 0:t.workspace),"aria-label":`管理项目`,children:`•••`}),Ce===t.workspace&&(0,I.jsxs)(`div`,{className:`project-menu`,role:`menu`,children:[(0,I.jsx)(`button`,{onClick:()=>Tt(t.workspace,t.label),children:`修改显示名称`}),(0,I.jsx)(`button`,{onClick:()=>void N(t.workspace,{pinned:!t.pinned}),children:t.pinned?`取消置顶`:`置顶项目`}),(0,I.jsx)(`button`,{onClick:()=>void window.flavorDesktop.revealProject(t.workspace),children:`在资源管理器中打开`}),(0,I.jsx)(`button`,{onClick:()=>void window.flavorDesktop.copyProjectPath(t.workspace),children:`复制路径`}),(0,I.jsx)(`button`,{className:`danger-item`,onClick:()=>void Et(t.workspace,t.running),children:`关闭项目`})]})]}),i&&t.sessions.length===0&&(0,I.jsx)(`p`,{className:`no-sessions`,children:`还没有任务`}),i&&t.sessions.filter(e=>(ve===`archived`?e.archived:!e.archived)&&(ve!==`running`||t.runningSessions?.includes(e.sessionId))&&(ve!==`unread`||e.unread)&&(!ge.trim()||be(e).toLowerCase().includes(ge.trim().toLowerCase()))).map(r=>{let i=n&&r.sessionId===e.activeSession?.sessionId,a=t.runningSessions?.includes(r.sessionId)??(t.running&&r.sessionId===t.activeSession?.sessionId),o=r.unread&&r.activity===`completed`;return(0,I.jsxs)(`div`,{className:`session-item-shell`,onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||v(void 0)},children:[(0,I.jsxs)(`button`,{className:`session-item`,"data-active":i,"data-running":a,disabled:n&&et&&!i,onClick:()=>void mt(t.workspace,r),children:[(0,I.jsxs)(`span`,{children:[r.pinned&&(0,I.jsx)(`i`,{className:`pin-mark`,children:`◆`}),be(r)]}),a?(0,I.jsx)(`span`,{className:`session-spinner`,role:`status`,"aria-label":`任务正在执行`}):o?(0,I.jsx)(`span`,{className:`session-complete-dot`,role:`status`,"aria-label":`任务已完成,点击查看`}):(0,I.jsx)(`time`,{children:Df(r.updatedAt)})]}),n&&(0,I.jsx)(`button`,{className:`session-more`,"aria-label":`管理会话:${be(r)}`,"aria-expanded":g===r.sessionId,onClick:()=>v(e=>e===r.sessionId?void 0:r.sessionId),children:`•••`}),n&&g===r.sessionId&&(0,I.jsxs)(`div`,{className:`session-menu`,role:`menu`,children:[(0,I.jsx)(`button`,{role:`menuitem`,onClick:()=>M(r),children:`重命名`}),(0,I.jsx)(`button`,{role:`menuitem`,onClick:()=>void wt(r,{pinned:!r.pinned}),children:r.pinned?`取消置顶`:`置顶`}),(0,I.jsx)(`button`,{role:`menuitem`,onClick:()=>void wt(r,{archived:!r.archived}),children:r.archived?`取消归档`:`归档`}),(0,I.jsx)(`button`,{role:`menuitem`,className:`danger-item`,disabled:et&&r.sessionId===e.activeSession?.sessionId,onClick:()=>{b(r),v(void 0)},children:`删除会话`})]})]},r.sessionId)})]},t.workspace)})]}),(0,I.jsxs)(`div`,{className:`rail-footer`,children:[(0,I.jsx)(`span`,{className:`avatar`,children:`F`}),(0,I.jsx)(`span`,{children:`本地工作区`}),(0,I.jsx)(`button`,{title:`帮助`,children:`?`})]})]}),(0,I.jsxs)(`main`,{className:`workspace-panel`,children:[D===`workbench`&&e.workspace!==void 0&&e.activeSession!==void 0?(0,I.jsx)(hd,{snapshot:e,onClose:()=>O(`conversation`),onError:d,onCompose:e=>{qe(e),O(`conversation`),setTimeout(()=>Be.current?.focus(),0)}}):D===`skills`&&e.workspace!==void 0?(0,I.jsx)(Bl,{onClose:()=>O(`conversation`),onError:d}):D===`memory`&&e.workspace!==void 0?(0,I.jsx)(Gl,{onClose:()=>O(`conversation`),onError:d}):D===`mcp`&&e.workspace!==void 0?(0,I.jsx)(ql,{onClose:()=>O(`conversation`),onError:d}):D===`activity`?(0,I.jsx)(qd,{activities:e.activities??[],onClose:()=>O(`conversation`),onOpen:(e,t)=>void Dt(e,t),onClear:()=>void window.flavorDesktop.acknowledgeSession().then(t)}):D===`git`&&e.workspace!==void 0?(0,I.jsx)(Qu,{onClose:()=>O(`conversation`),onError:d,onReview:()=>{O(`conversation`),_t(`/review`,`prompt`)}}):D===`e2e`&&e.workspace!==void 0?(0,I.jsx)(Yu,{onClose:()=>O(`conversation`),onInterrupt:()=>void window.flavorDesktop.interrupt(),onError:d,refreshKey:Ne,pending:Fe,disabled:et,onLaunch:(e,t)=>Ie(kd(e,t)),onStartTask:e=>_t(e,`prompt`,`d2c`)}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`header`,{className:`workspace-header`,children:[(0,I.jsx)(`button`,{className:`mobile-rail-toggle`,onClick:()=>p(!0),"aria-label":`打开项目栏`,children:`☰`}),(0,I.jsx)(`div`,{className:`workspace-breadcrumb`,children:(0,I.jsx)(`span`,{children:xe(e.workspace)})}),(0,I.jsxs)(`div`,{className:`header-actions`,children:[e.jobs.some(e=>e.state===`running`)&&(0,I.jsxs)(`div`,{className:`job-strip`,title:`后台任务`,children:[(0,I.jsx)(`span`,{className:`job-pulse`}),e.jobs.filter(e=>e.state===`running`).length,` 个后台任务`]}),(0,I.jsx)(`button`,{className:`finish-task-button`,onClick:()=>void bt(),disabled:et||e.activeSession===void 0,title:`评估并完成当前任务`,children:`完成任务`}),(0,I.jsx)(`button`,{title:`更多选项`,children:`•••`})]})]}),(e.recoveryItems?.filter(t=>t.workspace===e.workspace).length??0)>0&&(0,I.jsxs)(`div`,{className:`recovery-banner`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`strong`,{children:`检测到上次未完成的任务`}),(0,I.jsx)(`span`,{children:`应用异常退出时,这些任务仍在运行。`})]}),e.recoveryItems.filter(t=>t.workspace===e.workspace).map(n=>(0,I.jsxs)(`div`,{className:`recovery-action`,children:[(0,I.jsx)(`code`,{children:wf(n.sessionId)}),(0,I.jsx)(`button`,{onClick:()=>{let t=e.sessions.find(e=>e.sessionId===n.sessionId);t!==void 0&&ht(t)},children:`恢复 / 查看`}),(0,I.jsx)(`button`,{onClick:()=>void window.flavorDesktop.dismissRecovery(n.sessionId).then(t),children:`忽略`})]},n.sessionId))]}),(0,I.jsx)(`div`,{className:`conversation-scroll`,ref:ze,children:c?(0,I.jsx)(_f,{}):e.workspace===void 0?(0,I.jsx)(gf,{onOpen:ft}):n.completed.length===0&&n.active===void 0?(0,I.jsx)(hf,{project:xe(e.workspace),onStart:e=>void _t(e)}):(0,I.jsxs)(`div`,{className:`conversation-column`,children:[n.completed.map(e=>(0,I.jsx)(Qd,{turn:e},e.id)),n.active!==void 0&&(0,I.jsx)(Qd,{turn:n.active,active:!0})]})}),e.diagnostics.length>0&&(0,I.jsxs)(`details`,{className:`diagnostics`,children:[(0,I.jsxs)(`summary`,{children:[e.diagnostics.length,` 条启动提示`]}),(0,I.jsx)(`pre`,{children:e.diagnostics.join(`
152
+ `)}function Gd({attachments:e,onRemove:t}){return(0,I.jsx)(`div`,{className:`image-attachment-strip`,"aria-label":`待发送图片`,children:e.map((e,n)=>(0,I.jsxs)(`figure`,{className:`image-attachment-chip`,children:[(0,I.jsx)(`img`,{src:e.previewUrl,alt:e.name}),(0,I.jsxs)(`figcaption`,{children:[(0,I.jsxs)(`strong`,{children:[`[Image #`,n+1,`]`]}),(0,I.jsx)(`span`,{children:e.name})]}),(0,I.jsx)(`button`,{type:`button`,onClick:()=>t(e.id),"aria-label":`移除 ${e.name}`,title:`移除图片`,children:`×`})]},e.id))})}function Kd(){let[e,t]=(0,_.useState)(Ld),[n,r]=(0,_.useState)(x),[i,a]=(0,_.useState)(``),[o,s]=(0,_.useState)([]),[c,l]=(0,_.useState)(!0),[u,d]=(0,_.useState)(),[f,p]=(0,_.useState)(!1),[m,h]=(0,_.useState)(!1),[g,v]=(0,_.useState)(),[y,b]=(0,_.useState)(),[C,w]=(0,_.useState)(!1),[ee,te]=(0,_.useState)(0),[ne,re]=(0,_.useState)(),[ie,ae]=(0,_.useState)([]),[oe,se]=(0,_.useState)([]),[ce,le]=(0,_.useState)(0),[ue,T]=(0,_.useState)(),[E,de]=(0,_.useState)(),[fe,pe]=(0,_.useState)(0),[D,O]=(0,_.useState)(`conversation`),[me,he]=(0,_.useState)(!1),[ge,_e]=(0,_.useState)(``),[ve,ye]=(0,_.useState)(`active`),[Ce,Te]=(0,_.useState)(),[Ee,De]=(0,_.useState)(),[Oe,k]=(0,_.useState)(``),[ke,Ae]=(0,_.useState)([]),[je,Me]=(0,_.useState)(-1),[Ne,Pe]=(0,_.useState)(0),[Fe,Ie]=(0,_.useState)(),[Le,Re]=(0,_.useState)(()=>new Map),ze=(0,_.useRef)(null),Be=(0,_.useRef)(null),A=(0,_.useRef)(void 0),Ve=(0,_.useRef)(void 0),He=(0,_.useRef)(n),Ue=(0,_.useRef)(new Map),j=(0,_.useRef)(new Map),We=(0,_.useRef)(new Map),Ge=(0,_.useRef)(new Set),Ke=(0,_.useRef)(!1),qe=(0,_.useCallback)(e=>{a(e),re(void 0),T(void 0)},[]);(0,_.useEffect)(()=>{He.current=n},[n]);let Je=(0,_.useCallback)(()=>{let e=Ve.current;e!==void 0&&(Ue.current.set(e,{sessionId:A.current,transcript:He.current}),A.current!==void 0&&j.current.set(`${e}\u0000${A.current}`,He.current))},[]),Ye=(0,_.useCallback)(e=>{e!==void 0&&Re(t=>{if(!t.has(e))return t;let n=new Map(t);return n.delete(e),n})},[]),Xe=(0,_.useCallback)(e=>{let n=e.workspace;Ve.current=n,A.current=e.activeSession?.sessionId,t(e);let i=n===void 0?void 0:Ue.current.get(n);r(i!==void 0&&i.sessionId===e.activeSession?.sessionId?i.transcript:x()),Ye(n),O(`conversation`),p(!1)},[Ye]);(0,_.useEffect)(()=>()=>{for(let e of Ge.current)URL.revokeObjectURL(e);Ge.current.clear()},[]);let Ze=(0,_.useCallback)(e=>{s(t=>{let n=t.find(t=>t.id===e);return n!==void 0&&(URL.revokeObjectURL(n.previewUrl),Ge.current.delete(n.previewUrl)),t.filter(t=>t.id!==e)})},[]),Qe=(0,_.useCallback)(()=>{s(e=>{for(let t of e)URL.revokeObjectURL(t.previewUrl),Ge.current.delete(t.previewUrl);return[]})},[]),$e=(0,_.useCallback)(async e=>{if(e.length===0)return;let t=Bd-o.length;if(t<=0||e.length>t){d(`每条消息最多添加 ${Bd} 张图片。`);return}if(o.reduce((e,t)=>e+Math.floor(t.dataBase64.length*3/4),0)+e.reduce((e,t)=>e+t.size,0)>Hd){d(`单条消息的图片总大小不能超过 20 MiB。`);return}try{let t=await Promise.all(e.map(sf));for(let e of t)Ge.current.add(e.previewUrl);s(e=>[...e,...t].slice(0,Bd)),d(void 0)}catch(e){d(Cf(e))}},[o]);(0,_.useEffect)(()=>{let e=ze.current;if(!e)return;let t=e=>{e.deltaY<0?Ke.current=!0:requestAnimationFrame(()=>{let e=ze.current;e&&e.scrollHeight-e.scrollTop-e.clientHeight<8&&(Ke.current=!1)})};return e.addEventListener(`wheel`,t,{passive:!0}),()=>e.removeEventListener(`wheel`,t)},[]),(0,_.useEffect)(()=>{let e=window.flavorDesktop.onEvent(e=>{if(e.type===`snapshot`&&e.workspace!==void 0&&e.snapshot.workspace===e.workspace){let t=Ve.current;if(t!==void 0&&t!==e.workspace){Ue.current.set(t,{sessionId:A.current,transcript:He.current});let n=Ue.current.get(e.workspace);r(n!==void 0&&n.sessionId===e.snapshot.activeSession?.sessionId?n.transcript:x()),O(`conversation`),Ye(e.workspace)}Ve.current=e.workspace}else if(e.workspace!==void 0&&(e.workspace!==Ve.current||e.type===`session-output`&&e.sessionId!==A.current||e.type===`session-started`&&e.payload.sessionId!==A.current)){let t=Ue.current.get(e.workspace)??{sessionId:void 0,transcript:x()};if(e.type===`session-started`){let t=S(x(),{type:`restore`,state:e.payload.restoredTranscript});j.current.set(`${e.workspace}\u0000${e.payload.sessionId}`,t),Ue.current.set(e.workspace,{sessionId:e.payload.sessionId,transcript:t})}else if(e.type===`session-output`){let n=`${e.workspace}\u0000${e.sessionId}`,r=we(j.current.get(n)??x(),e.sessionId,e);j.current.set(n,r),t.sessionId===e.sessionId&&Ue.current.set(e.workspace,{...t,transcript:r})}return}if(e.type===`d2c-report`){Pe(e=>e+1),Ie(t=>t!==void 0&&t.task===e.payload.task?void 0:t),O(`e2e`);return}if(e.type===`d2c-progress`){Ie(t=>t===void 0?t:jd(t,e.payload));return}e.type===`session-output`&&e.sessionId===A.current&&Ie(t=>t===void 0?t:Ad(t,e.event)),(e.type===`session-output`&&e.sessionId===A.current&&[`done`,`error`,`exit`].includes(e.event.type)||e.type===`runtime-error`&&(e.sessionId===void 0||e.sessionId===A.current))&&Ie(void 0),Zd(e,A,t,r,d)});return window.flavorDesktop.bootstrap().then(e=>{Ve.current=e.workspace,A.current=e.activeSession?.sessionId,t(e)}).catch(e=>d(Cf(e))).finally(()=>l(!1)),e},[]),(0,_.useEffect)(()=>{Ke.current||ze.current?.scrollTo({top:ze.current.scrollHeight,behavior:`smooth`})},[n]),(0,_.useEffect)(()=>{let e=!1;return window.flavorDesktop.listFiles().then(t=>{e||se(pn(t))}).catch(()=>{}),()=>{e=!0}},[e.workspace]),(0,_.useEffect)(()=>{let t=!1;return e.workspace===void 0?(ae([]),()=>{t=!0}):(window.flavorDesktop.listSkills().then(e=>{t||ae(e)}).catch(()=>{t||ae([])}),()=>{t=!0})},[e.workspace,D]);let et=e.activeSession?.busy??!1,tt=(0,_.useMemo)(()=>e.projects??(e.workspace===void 0?[]:[{workspace:e.workspace,sessions:e.sessions,...e.activeSession===void 0?{}:{activeSession:{sessionId:e.activeSession.sessionId,busy:e.activeSession.busy}},running:et||e.jobs.some(e=>e.state===`running`)}]),[e.projects,e.workspace,e.sessions,e.activeSession,e.jobs,et]);(0,_.useEffect)(()=>{Re(e=>{let t=Se(tt,We.current,e);return We.current=t.activity,t.notices})},[tt]);let nt=(0,_.useMemo)(()=>Qt(zd,[],ie.filter(e=>e.enabled),e.managedTools??[]),[ie,e.managedTools]),rt=(0,_.useMemo)(()=>et||e.approval!==void 0||e.questions!==void 0||ne===i?null:en(i,fe,nt,ee),[i,fe,ee,ne,et,e.approval,e.questions,nt]),it=(0,_.useMemo)(()=>et||e.approval!==void 0||e.questions!==void 0||ue===i||rt!==null?null:mn(i,fe,oe,ce),[i,fe,ce,ue,et,e.approval,e.questions,oe,rt]),at=rt===null?$t(i,nt,!1):0,ot=(0,_.useCallback)(e=>{let t=nn(i,fe,e);a(t.text),re(t.text),te(0),pe(t.cursor),setTimeout(()=>{let e=Be.current;e!==null&&(e.focus(),e.setSelectionRange(e.value.length,e.value.length))},0)},[i,fe]),st=(0,_.useCallback)(()=>{re(i)},[i]),ct=(0,_.useCallback)(e=>{te(t=>tn(t,e,rt?.items.length??0))},[rt]),lt=(0,_.useCallback)(e=>{let t=gn(i,fe,e);a(t.text),T(t.text),le(0),de(t.span),pe(t.cursor),setTimeout(()=>{let e=Be.current;e!==null&&(e.focus(),e.setSelectionRange(e.value.length,e.value.length))},0)},[i,fe]),ut=(0,_.useCallback)(()=>{T(i)},[i]),dt=(0,_.useCallback)(e=>{le(t=>hn(t,e,it?.items.length??0))},[it]),ft=async()=>{d(void 0);try{Je();let e=await window.flavorDesktop.chooseWorkspace();e!==void 0&&(Qe(),Xe(e))}catch(e){d(Cf(e))}},pt=async n=>{if(n===e.workspace)return Ye(n),window.flavorDesktop.acknowledgeSession().then(t).catch(()=>void 0),O(`conversation`),p(!1),e;d(void 0),Je();try{let e=await window.flavorDesktop.openWorkspace(n);return Qe(),Xe(e),window.flavorDesktop.acknowledgeSession().then(t).catch(()=>void 0),e}catch(e){d(Cf(e));return}},mt=async(e,t)=>{let n=await pt(e);if(n!==void 0){if(n.activeSession?.sessionId===t.sessionId){O(`conversation`),p(!1);return}await ht(t)}},ht=async e=>{d(void 0);try{Je();let n=await window.flavorDesktop.selectSession(e.sessionId),i=n.snapshot.workspace===void 0?void 0:j.current.get(`${n.snapshot.workspace}\u0000${n.sessionId}`);t(n.snapshot),Ve.current=n.snapshot.workspace,A.current=n.sessionId,r(i??S(x(),{type:`restore`,state:n.restoredTranscript})),O(`conversation`),p(!1)}catch(e){d(Cf(e))}},gt=async(e,n)=>{d(void 0);try{let i=await window.flavorDesktop.startSession(e?.sessionId,n);Qe(),t(i.snapshot),Ve.current=i.snapshot.workspace,A.current=i.sessionId,r(S(x(),{type:`restore`,state:i.restoredTranscript})),i.snapshot.workspace!==void 0&&j.current.set(`${i.snapshot.workspace}\u0000${i.sessionId}`,S(x(),{type:`restore`,state:i.restoredTranscript})),p(!1),O(`conversation`),setTimeout(()=>Be.current?.focus(),0)}catch(e){d(Cf(e))}},_t=async(n,s,c)=>{let l=(n??i).trim(),u=n===void 0?o:[];if(!l&&u.length===0)return!1;d(void 0);try{let i=e;if(i.activeSession===void 0){let e=await window.flavorDesktop.startSession();i=e.snapshot,t(i),r(S(x(),{type:`restore`,state:e.restoredTranscript}))}let o=s??(et?`steer`:`prompt`);if(u.length>0&&o!==`prompt`)throw Error(`图片只能随新消息发送,不能作为运行中的引导或后续消息。`);return o===`prompt`&&r(e=>S(e,{type:`submit`,prompt:Wd(l,u)})),n===void 0&&a(``),await window.flavorDesktop.submit(l,o,u.map(({name:e,mediaType:t,dataBase64:n})=>({name:e,mediaType:t,dataBase64:n})),c),u.length>0&&Qe(),!0}catch(e){let t=Cf(e);return d(t),r(e=>S(e,{type:`submit-error`,message:t})),!1}},vt=e=>void _t(`/permissions ${e}`),yt=async e=>{d(void 0);try{t(await window.flavorDesktop.switchModel(e))}catch(e){d(Cf(e))}},bt=async()=>{if(!(et||e.activeSession===void 0)){d(void 0);try{await window.flavorDesktop.finishTask()}catch(e){d(Cf(e))}}},xt=async e=>{d(void 0);try{let n=await window.flavorDesktop.addModel(e);t(n.snapshot)}catch(e){throw d(Cf(e)),e}},St=(e,t)=>{let n=t.currentTarget.getBoundingClientRect();window.flavorDesktop.showAppMenu(e,Math.round(n.left),Math.round(n.bottom))},Ct=async()=>{if(!(y===void 0||C)){w(!0),d(void 0);try{let n=y.sessionId===e.activeSession?.sessionId,i=await window.flavorDesktop.deleteSession(y.sessionId);t(i),n&&r(x()),b(void 0),v(void 0)}catch(e){d(Cf(e))}finally{w(!1)}}},wt=async(e,n)=>{try{t(await window.flavorDesktop.updateSession(e.sessionId,n)),v(void 0)}catch(e){d(Cf(e))}},M=e=>{let t=window.prompt(`任务名称`,e.title??be(e));t!==null&&wt(e,{title:t.trim()})},N=async(e,n)=>{try{t(await window.flavorDesktop.updateProject(e,n)),Te(void 0)}catch(e){d(Cf(e))}},Tt=(e,t)=>{let n=window.prompt(`项目显示名称`,t??xe(e));n!==null&&N(e,{label:n.trim()})},Et=async(e,t)=>{if(!(t&&!window.confirm(`项目中有任务正在运行。停止任务并关闭项目?`)))try{Xe(await window.flavorDesktop.closeProject(e,t)),Te(void 0)}catch(e){d(Cf(e))}},Dt=async(e,t)=>{let n=await pt(e);if(n!==void 0&&t!==void 0){let e=n.sessions.find(e=>e.sessionId===t);e!==void 0&&await ht(e)}};(0,_.useEffect)(()=>{let t={...e.workspace===void 0?{}:{workspace:e.workspace},...e.activeSession===void 0?{}:{sessionId:e.activeSession.sessionId},view:D};Ae(e=>{let n=e[je];if(n?.workspace===t.workspace&&n?.sessionId===t.sessionId&&n?.view===t.view)return e;let r=[...e.slice(0,je+1),t].slice(-50);return Me(r.length-1),r})},[e.workspace,e.activeSession?.sessionId,D]);let Ot=async e=>{let n=je+e,i=ke[n];if(i!==void 0){if(Me(n),i.workspace!==void 0){let e=await window.flavorDesktop.openWorkspace(i.workspace);if(Xe(e),i.sessionId!==void 0){let e=await window.flavorDesktop.selectSession(i.sessionId);t(e.snapshot),A.current=e.sessionId,r(j.current.get(`${i.workspace}\u0000${i.sessionId}`)??S(x(),{type:`restore`,state:e.restoredTranscript}))}}O(i.view)}};return(0,_.useEffect)(()=>{let e=e=>{if(!(e.ctrlKey||e.metaKey))return;let t=e.key.toLowerCase();t===`n`&&(e.preventDefault(),he(!0)),t===`p`&&(e.preventDefault(),De(`projects`),k(``)),t===`k`&&(e.preventDefault(),De(`commands`),k(``)),t===`[`&&(e.preventDefault(),Ot(-1)),t===`]`&&(e.preventDefault(),Ot(1))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[e.workspace,ke,je]),(0,I.jsxs)(`div`,{className:`app-frame`,children:[(0,I.jsx)(Xd,{railCollapsed:m,onToggleRail:()=>h(e=>!e),onMenu:St,canBack:je>0,canForward:je<ke.length-1,onBack:()=>void Ot(-1),onForward:()=>void Ot(1)}),(0,I.jsxs)(`div`,{className:`desktop-shell`,"data-rail-collapsed":m,children:[(0,I.jsx)(`button`,{className:`rail-scrim`,"data-open":f,onClick:()=>p(!1),"aria-label":`关闭项目栏`}),(0,I.jsxs)(`aside`,{className:`project-rail`,"data-open":f,children:[(0,I.jsxs)(`div`,{className:`brand-row`,children:[(0,I.jsx)(Sf,{}),(0,I.jsx)(`strong`,{children:`Flavor Code`})]}),(0,I.jsxs)(`nav`,{className:`primary-actions`,"aria-label":`主要操作`,children:[(0,I.jsxs)(`button`,{className:`rail-action rail-action-primary`,disabled:e.workspace===void 0,onClick:()=>he(!0),children:[(0,I.jsx)(`span`,{className:`action-icon`,children:(0,I.jsx)(xf,{name:`plus`})}),(0,I.jsx)(`span`,{children:`新建任务`}),(0,I.jsx)(`kbd`,{children:`Ctrl N`})]}),(0,I.jsxs)(`button`,{className:`rail-action`,onClick:()=>void ft(),children:[(0,I.jsx)(`span`,{className:`action-icon`,children:(0,I.jsx)(xf,{name:`folder`})}),(0,I.jsx)(`span`,{children:`打开项目`})]}),(0,I.jsxs)(`button`,{className:`rail-action`,"data-active":D===`skills`,onClick:()=>{O(`skills`),p(!1)},disabled:e.workspace===void 0,children:[(0,I.jsx)(`span`,{className:`action-icon`,children:(0,I.jsx)(xf,{name:`sparkles`})}),(0,I.jsx)(`span`,{children:`技能`})]}),(0,I.jsxs)(`button`,{className:`rail-action`,"data-active":D===`memory`,onClick:()=>{O(`memory`),p(!1)},disabled:e.workspace===void 0,children:[(0,I.jsx)(`span`,{className:`action-icon`,children:(0,I.jsx)(xf,{name:`database`})}),(0,I.jsx)(`span`,{children:`长期记忆`})]}),(0,I.jsxs)(`button`,{className:`rail-action`,"data-active":D===`mcp`,onClick:()=>{O(`mcp`),p(!1)},disabled:e.workspace===void 0,children:[(0,I.jsx)(`span`,{className:`action-icon`,children:(0,I.jsx)(xf,{name:`server`})}),(0,I.jsx)(`span`,{children:`MCP 服务`})]}),(0,I.jsxs)(`button`,{className:`rail-action`,"data-active":D===`e2e`,onClick:()=>{O(`e2e`),p(!1)},disabled:e.workspace===void 0,children:[(0,I.jsx)(`span`,{className:`action-icon`,children:(0,I.jsx)(xf,{name:`checklist`})}),(0,I.jsx)(`span`,{children:`E2E`})]}),(0,I.jsxs)(`button`,{className:`rail-action`,"data-active":D===`activity`,onClick:()=>{O(`activity`),p(!1)},children:[(0,I.jsx)(`span`,{className:`action-icon`,children:(0,I.jsx)(xf,{name:`bell`})}),(0,I.jsx)(`span`,{children:`活动`}),(e.activities?.filter(e=>e.unread).length??0)>0&&(0,I.jsx)(`em`,{className:`rail-badge`,children:e.activities.filter(e=>e.unread).length})]}),(0,I.jsxs)(`button`,{className:`rail-action`,"data-active":D===`git`,onClick:()=>{O(`git`),p(!1)},disabled:e.workspace===void 0,children:[(0,I.jsx)(`span`,{className:`action-icon`,children:(0,I.jsx)(xf,{name:`git`})}),(0,I.jsx)(`span`,{children:`Git 变更`})]}),(0,I.jsxs)(`button`,{className:`rail-action`,"data-active":D===`workbench`,onClick:()=>{O(`workbench`),p(!1)},disabled:e.workspace===void 0||e.activeSession===void 0,children:[(0,I.jsx)(`span`,{className:`action-icon`,children:(0,I.jsx)(xf,{name:`checklist`})}),(0,I.jsx)(`span`,{children:`Agent 工作台`})]})]}),(0,I.jsxs)(`div`,{className:`sessions-scroll`,children:[(0,I.jsxs)(`div`,{className:`rail-section-heading`,children:[(0,I.jsx)(`span`,{children:`项目`}),(0,I.jsx)(`button`,{onClick:()=>void ft(),"aria-label":`打开新项目`,title:`打开新项目`,children:(0,I.jsx)(xf,{name:`plus`})})]}),tt.length>0&&(0,I.jsxs)(`div`,{className:`session-filter`,children:[(0,I.jsxs)(`div`,{className:`session-search`,children:[(0,I.jsx)(xf,{name:`search`}),(0,I.jsx)(`input`,{value:ge,onChange:e=>_e(e.target.value),placeholder:`搜索任务`,"aria-label":`搜索任务`}),ge.length>0&&(0,I.jsx)(`button`,{type:`button`,onClick:()=>_e(``),"aria-label":`清除搜索`,title:`清除搜索`,children:`×`})]}),(0,I.jsxs)(`div`,{className:`session-group-filter`,children:[(0,I.jsxs)(`select`,{value:ve,onChange:e=>ye(e.target.value),"aria-label":`按状态筛选`,children:[(0,I.jsx)(`option`,{value:`active`,children:`任务`}),(0,I.jsx)(`option`,{value:`running`,children:`运行`}),(0,I.jsx)(`option`,{value:`unread`,children:`未读`}),(0,I.jsx)(`option`,{value:`archived`,children:`归档`})]}),(0,I.jsx)(`span`,{"aria-hidden":`true`})]})]}),tt.length===0?(0,I.jsx)(`button`,{className:`empty-project`,onClick:()=>void ft(),children:`选择一个本地文件夹开始`}):tt.map(t=>{let n=t.workspace===e.workspace,r=Le.has(t.workspace);Le.get(t.workspace);let i=n||t.running||r;return(0,I.jsxs)(`section`,{className:`project-entry`,"data-active":n,children:[(0,I.jsxs)(`div`,{className:`project-heading-shell`,children:[(0,I.jsxs)(`button`,{className:`project-heading`,onClick:()=>void pt(t.workspace),title:t.workspace,children:[(0,I.jsx)(`span`,{className:`folder-icon`,"aria-hidden":`true`,children:(0,I.jsx)(xf,{name:`folder`})}),(0,I.jsx)(`span`,{children:t.label||xe(t.workspace)}),t.running?(0,I.jsx)(`span`,{className:`project-running-dot`,title:`项目中有任务正在执行`}):(t.unreadCount??0)>0&&(0,I.jsx)(`span`,{className:`project-complete-dot`,role:`status`,"aria-label":`项目有未读活动`})]}),(0,I.jsx)(`button`,{className:`project-more`,onClick:()=>Te(e=>e===t.workspace?void 0:t.workspace),"aria-label":`管理项目`,children:`•••`}),Ce===t.workspace&&(0,I.jsxs)(`div`,{className:`project-menu`,role:`menu`,children:[(0,I.jsx)(`button`,{onClick:()=>Tt(t.workspace,t.label),children:`修改显示名称`}),(0,I.jsx)(`button`,{onClick:()=>void N(t.workspace,{pinned:!t.pinned}),children:t.pinned?`取消置顶`:`置顶项目`}),(0,I.jsx)(`button`,{onClick:()=>void window.flavorDesktop.revealProject(t.workspace),children:`在资源管理器中打开`}),(0,I.jsx)(`button`,{onClick:()=>void window.flavorDesktop.copyProjectPath(t.workspace),children:`复制路径`}),(0,I.jsx)(`button`,{className:`danger-item`,onClick:()=>void Et(t.workspace,t.running),children:`关闭项目`})]})]}),i&&t.sessions.length===0&&(0,I.jsx)(`p`,{className:`no-sessions`,children:`还没有任务`}),i&&t.sessions.filter(e=>(ve===`archived`?e.archived:!e.archived)&&(ve!==`running`||t.runningSessions?.includes(e.sessionId))&&(ve!==`unread`||e.unread)&&(!ge.trim()||be(e).toLowerCase().includes(ge.trim().toLowerCase()))).map(r=>{let i=n&&r.sessionId===e.activeSession?.sessionId,a=t.runningSessions?.includes(r.sessionId)??(t.running&&r.sessionId===t.activeSession?.sessionId),o=r.unread&&r.activity===`completed`;return(0,I.jsxs)(`div`,{className:`session-item-shell`,onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||v(void 0)},children:[(0,I.jsxs)(`button`,{className:`session-item`,"data-active":i,"data-running":a,disabled:n&&et&&!i,onClick:()=>void mt(t.workspace,r),children:[(0,I.jsxs)(`span`,{children:[r.pinned&&(0,I.jsx)(`i`,{className:`pin-mark`,children:`◆`}),be(r)]}),a?(0,I.jsx)(`span`,{className:`session-spinner`,role:`status`,"aria-label":`任务正在执行`}):o?(0,I.jsx)(`span`,{className:`session-complete-dot`,role:`status`,"aria-label":`任务已完成,点击查看`}):(0,I.jsx)(`time`,{children:Df(r.updatedAt)})]}),n&&(0,I.jsx)(`button`,{className:`session-more`,"aria-label":`管理会话:${be(r)}`,"aria-expanded":g===r.sessionId,onClick:()=>v(e=>e===r.sessionId?void 0:r.sessionId),children:`•••`}),n&&g===r.sessionId&&(0,I.jsxs)(`div`,{className:`session-menu`,role:`menu`,children:[(0,I.jsx)(`button`,{role:`menuitem`,onClick:()=>M(r),children:`重命名`}),(0,I.jsx)(`button`,{role:`menuitem`,onClick:()=>void wt(r,{pinned:!r.pinned}),children:r.pinned?`取消置顶`:`置顶`}),(0,I.jsx)(`button`,{role:`menuitem`,onClick:()=>void wt(r,{archived:!r.archived}),children:r.archived?`取消归档`:`归档`}),(0,I.jsx)(`button`,{role:`menuitem`,className:`danger-item`,disabled:et&&r.sessionId===e.activeSession?.sessionId,onClick:()=>{b(r),v(void 0)},children:`删除会话`})]})]},r.sessionId)})]},t.workspace)})]}),(0,I.jsxs)(`div`,{className:`rail-footer`,children:[(0,I.jsx)(`span`,{className:`avatar`,children:`F`}),(0,I.jsx)(`span`,{children:`本地工作区`}),(0,I.jsx)(`button`,{title:`帮助`,children:`?`})]})]}),(0,I.jsxs)(`main`,{className:`workspace-panel`,children:[D===`workbench`&&e.workspace!==void 0&&e.activeSession!==void 0?(0,I.jsx)(hd,{snapshot:e,onClose:()=>O(`conversation`),onError:d,onCompose:e=>{qe(e),O(`conversation`),setTimeout(()=>Be.current?.focus(),0)}}):D===`skills`&&e.workspace!==void 0?(0,I.jsx)(Bl,{onClose:()=>O(`conversation`),onError:d}):D===`memory`&&e.workspace!==void 0?(0,I.jsx)(Gl,{onClose:()=>O(`conversation`),onError:d}):D===`mcp`&&e.workspace!==void 0?(0,I.jsx)(ql,{onClose:()=>O(`conversation`),onError:d}):D===`activity`?(0,I.jsx)(qd,{activities:e.activities??[],onClose:()=>O(`conversation`),onOpen:(e,t)=>void Dt(e,t),onClear:()=>void window.flavorDesktop.acknowledgeSession().then(t)}):D===`git`&&e.workspace!==void 0?(0,I.jsx)(Qu,{onClose:()=>O(`conversation`),onError:d,onReview:()=>{O(`conversation`),_t(`/review`,`prompt`)}}):D===`e2e`&&e.workspace!==void 0?(0,I.jsx)(Yu,{onClose:()=>O(`conversation`),onInterrupt:()=>void window.flavorDesktop.interrupt(),onError:d,refreshKey:Ne,pending:Fe,disabled:et,onLaunch:(e,t)=>Ie(kd(e,t)),onStartTask:e=>_t(e,`prompt`,`d2c`)}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`header`,{className:`workspace-header`,children:[(0,I.jsx)(`button`,{className:`mobile-rail-toggle`,onClick:()=>p(!0),"aria-label":`打开项目栏`,children:`☰`}),(0,I.jsx)(`div`,{className:`workspace-breadcrumb`,children:(0,I.jsx)(`span`,{children:xe(e.workspace)})}),(0,I.jsxs)(`div`,{className:`header-actions`,children:[e.jobs.some(e=>e.state===`running`)&&(0,I.jsxs)(`div`,{className:`job-strip`,title:`后台任务`,children:[(0,I.jsx)(`span`,{className:`job-pulse`}),e.jobs.filter(e=>e.state===`running`).length,` 个后台任务`]}),(0,I.jsx)(`button`,{className:`finish-task-button`,onClick:()=>void bt(),disabled:et||e.activeSession===void 0,title:`评估并完成当前任务`,children:`完成任务`}),(0,I.jsx)(`button`,{title:`更多选项`,children:`•••`})]})]}),(e.recoveryItems?.filter(t=>t.workspace===e.workspace).length??0)>0&&(0,I.jsxs)(`div`,{className:`recovery-banner`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`strong`,{children:`检测到上次未完成的任务`}),(0,I.jsx)(`span`,{children:`应用异常退出时,这些任务仍在运行。`})]}),e.recoveryItems.filter(t=>t.workspace===e.workspace).map(n=>(0,I.jsxs)(`div`,{className:`recovery-action`,children:[(0,I.jsx)(`code`,{children:wf(n.sessionId)}),(0,I.jsx)(`button`,{onClick:()=>{let t=e.sessions.find(e=>e.sessionId===n.sessionId);t!==void 0&&ht(t)},children:`恢复 / 查看`}),(0,I.jsx)(`button`,{onClick:()=>void window.flavorDesktop.dismissRecovery(n.sessionId).then(t),children:`忽略`})]},n.sessionId))]}),(0,I.jsx)(`div`,{className:`conversation-scroll`,ref:ze,children:c?(0,I.jsx)(_f,{}):e.workspace===void 0?(0,I.jsx)(gf,{onOpen:ft}):n.completed.length===0&&n.active===void 0?(0,I.jsx)(hf,{project:xe(e.workspace),onStart:e=>void _t(e)}):(0,I.jsxs)(`div`,{className:`conversation-column`,children:[n.completed.map(e=>(0,I.jsx)(Qd,{turn:e},e.id)),n.active!==void 0&&(0,I.jsx)(Qd,{turn:n.active,active:!0})]})}),e.diagnostics.length>0&&(0,I.jsxs)(`details`,{className:`diagnostics`,children:[(0,I.jsxs)(`summary`,{children:[e.diagnostics.length,` 条启动提示`]}),(0,I.jsx)(`pre`,{children:e.diagnostics.join(`
153
153
  `)})]}),(0,I.jsx)(rf,{input:i,setInput:qe,onSend:e=>void _t(void 0,e),busy:et,onInterrupt:()=>{Ie(void 0),window.flavorDesktop.interrupt()},inputRef:Be,snapshot:e,attachments:o,onAddImages:e=>void $e(e),onRemoveImage:Ze,setModel:yt,addModel:xt,setPermission:vt,slashCompletion:rt,onSlashSelect:ot,onSlashDismiss:st,onSlashMove:ct,mentionCompletion:it,onMentionSelect:lt,onMentionDismiss:ut,onMentionMove:dt,mentionSpan:E,setMentionSpan:de,completedTokenLen:at,cursorPos:fe,setCursorPos:pe})]}),u!==void 0&&(0,I.jsxs)(`div`,{className:`error-toast`,role:`alert`,children:[(0,I.jsx)(`span`,{children:`!`}),(0,I.jsx)(`p`,{children:u}),(0,I.jsx)(`button`,{onClick:()=>d(void 0),children:`×`})]})]})]}),e.approval!==void 0&&(0,I.jsx)(df,{approval:e.approval,onResolve:e=>void window.flavorDesktop.resolveApproval(e)}),e.questions!==void 0&&(0,I.jsx)(ff,{questions:e.questions,onAnswer:e=>void window.flavorDesktop.answerQuestions(e)}),e.memoryReviews!==void 0&&e.memoryReviews.length>0&&(0,I.jsx)(pf,{reviews:e.memoryReviews,autoDismissSeconds:e.memoryAutoDismissSeconds??0,onResolve:(e,t)=>{window.flavorDesktop.resolveMemoryReview(e,t).catch(e=>d(Cf(e)))}}),y!==void 0&&(0,I.jsx)(lf,{session:y,deleting:C,onCancel:()=>b(void 0),onDelete:()=>void Ct()}),me&&(0,I.jsx)(Jd,{onCancel:()=>he(!1),onChoose:e=>{he(!1),gt(void 0,e)}}),Ee!==void 0&&(0,I.jsx)(Yd,{mode:Ee,query:Oe,setQuery:k,projects:tt,onClose:()=>De(void 0),onProject:e=>{De(void 0),pt(e)},onCommand:e=>{De(void 0),e===`new`?he(!0):e===`open`?ft():e===`activity`?O(`activity`):e===`git`?O(`git`):e===`skills`&&O(`skills`)}})]})}function qd({activities:e,onClose:t,onOpen:n,onClear:r}){return(0,I.jsxs)(`section`,{className:`manager-view activity-center`,children:[(0,I.jsxs)(`header`,{className:`manager-header`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`button`,{onClick:t,children:`←`}),(0,I.jsx)(`h2`,{children:`活动`})]}),(0,I.jsx)(`button`,{onClick:r,children:`全部标为已读`})]}),(0,I.jsx)(`div`,{className:`activity-list`,children:e.length===0?(0,I.jsx)(`p`,{className:`manager-empty`,children:`还没有任务活动`}):e.map(e=>(0,I.jsxs)(`button`,{className:`activity-row`,"data-kind":e.kind,"data-unread":e.unread,onClick:()=>n(e.workspace,e.sessionId),children:[(0,I.jsx)(`i`,{}),(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`strong`,{children:e.title}),(0,I.jsxs)(`span`,{children:[xe(e.workspace),e.detail?` · ${e.detail}`:``]})]}),(0,I.jsx)(`time`,{children:Df(e.createdAt)})]},e.id))})]})}function Jd({onCancel:e,onChoose:t}){return(0,I.jsx)(`div`,{className:`modal-layer`,onMouseDown:t=>{t.target===t.currentTarget&&e()},children:(0,I.jsxs)(`section`,{className:`new-task-sheet`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`new-task-title`,children:[(0,I.jsxs)(`header`,{children:[(0,I.jsx)(`p`,{children:`NEW TASK`}),(0,I.jsx)(`h2`,{id:`new-task-title`,children:`选择任务运行环境`}),(0,I.jsx)(`span`,{children:`隔离只影响 Electron 任务,不改变 CLI 默认行为。`})]}),(0,I.jsxs)(`div`,{children:[(0,I.jsxs)(`button`,{onClick:()=>t(`worktree`),children:[(0,I.jsx)(`i`,{children:`◇`}),(0,I.jsx)(`strong`,{children:`隔离工作树`}),(0,I.jsx)(`span`,{children:`新建 flavor/desktop-* 分支,在应用目录中独立运行。`}),(0,I.jsx)(`em`,{children:`推荐`})]}),(0,I.jsxs)(`button`,{onClick:()=>t(`local`),children:[(0,I.jsx)(`i`,{children:`⌂`}),(0,I.jsx)(`strong`,{children:`当前检出`}),(0,I.jsx)(`span`,{children:`直接使用项目当前目录,适合快速查看和轻量操作。`})]})]}),(0,I.jsx)(`footer`,{children:(0,I.jsx)(`button`,{onClick:e,children:`取消`})})]})})}function Yd({mode:e,query:t,setQuery:n,projects:r,onClose:i,onProject:a,onCommand:o}){let s=[{id:`new`,label:`新建任务`,hint:`Ctrl N`},{id:`open`,label:`打开项目`,hint:`Ctrl O`},{id:`activity`,label:`查看活动`,hint:``},{id:`git`,label:`打开 Git 变更`,hint:``},{id:`skills`,label:`管理技能`,hint:``}].filter(e=>e.label.toLowerCase().includes(t.toLowerCase())),c=r.filter(e=>`${e.label??``} ${xe(e.workspace)} ${e.workspace}`.toLowerCase().includes(t.toLowerCase()));return(0,I.jsx)(`div`,{className:`palette-layer`,onMouseDown:e=>{e.target===e.currentTarget&&i()},children:(0,I.jsxs)(`section`,{className:`command-palette`,role:`dialog`,"aria-modal":`true`,children:[(0,I.jsx)(`input`,{autoFocus:!0,value:t,onChange:e=>n(e.target.value),onKeyDown:e=>{e.key===`Escape`&&i()},placeholder:e===`projects`?`切换到项目…`:`键入命令…`}),(0,I.jsx)(`div`,{children:e===`projects`?c.map(e=>(0,I.jsxs)(`button`,{onClick:()=>a(e.workspace),children:[(0,I.jsx)(xf,{name:`folder`}),(0,I.jsx)(`span`,{children:e.label||xe(e.workspace)}),(0,I.jsx)(`small`,{children:e.workspace})]},e.workspace)):s.map(e=>(0,I.jsxs)(`button`,{onClick:()=>o(e.id),children:[(0,I.jsx)(`span`,{children:e.label}),(0,I.jsx)(`kbd`,{children:e.hint})]},e.id))})]})})}function Xd({railCollapsed:e,onToggleRail:t,onMenu:n,canBack:r,canForward:i,onBack:a,onForward:o}){return(0,I.jsxs)(`header`,{className:`window-titlebar`,children:[(0,I.jsx)(`button`,{className:`titlebar-icon sidebar-toggle`,"data-collapsed":e,onClick:t,"aria-label":e?`显示项目栏`:`隐藏项目栏`,title:e?`显示项目栏`:`隐藏项目栏`,children:(0,I.jsxs)(`svg`,{viewBox:`0 0 16 16`,"aria-hidden":`true`,children:[(0,I.jsx)(`rect`,{x:`2.5`,y:`2.5`,width:`11`,height:`11`,rx:`2`}),(0,I.jsx)(`path`,{d:`M6 3v10`})]})}),(0,I.jsx)(`button`,{className:`titlebar-icon nav-button`,disabled:!r,onClick:a,"aria-label":`后退`,title:`后退 (Ctrl+[)`,children:(0,I.jsx)(`span`,{children:`‹`})}),(0,I.jsx)(`button`,{className:`titlebar-icon nav-button`,disabled:!i,onClick:o,"aria-label":`前进`,title:`前进 (Ctrl+])`,children:(0,I.jsx)(`span`,{children:`›`})}),(0,I.jsxs)(`nav`,{className:`titlebar-menus`,"aria-label":`应用菜单`,children:[(0,I.jsx)(`button`,{onClick:e=>n(`file`,e),children:`文件`}),(0,I.jsx)(`button`,{onClick:e=>n(`edit`,e),children:`编辑`}),(0,I.jsx)(`button`,{onClick:e=>n(`view`,e),children:`视图`}),(0,I.jsx)(`button`,{onClick:e=>n(`help`,e),children:`帮助`})]})]})}function Zd(e,t,n,r,i){e.type===`snapshot`?(t.current=e.snapshot.activeSession?.sessionId,n(e.snapshot)):e.type===`session-started`?(t.current=e.payload.sessionId,n(e.payload.snapshot),r(S(x(),{type:`restore`,state:e.payload.restoredTranscript}))):e.type===`session-output`?r(n=>we(n,t.current,e)):e.type===`runtime-error`&&(e.sessionId===void 0||e.sessionId===t.current)&&i(e.message)}function Qd({turn:e,active:t=!1}){let n=t?e.blocks:e.blocks.filter(e=>e.kind!==`status`||e.task===void 0);return(0,I.jsxs)(`article`,{className:`turn`,"data-active":t,"data-kind":e.kind??`conversation`,children:[(0,I.jsx)(`div`,{className:`user-message`,children:(0,I.jsx)(`span`,{children:e.prompt})}),(0,I.jsxs)(`div`,{className:`assistant-message`,children:[(0,I.jsx)(`div`,{className:`assistant-avatar`,children:(0,I.jsx)(Sf,{})}),(0,I.jsxs)(`div`,{className:`turn-content`,children:[n.map((e,t)=>(0,I.jsx)($d,{block:e},e.kind===`status`?e.id:`text-${t}`)),t&&n.length===0&&(0,I.jsxs)(`div`,{className:`thinking-line`,children:[(0,I.jsx)(`i`,{}),(0,I.jsx)(`span`,{children:`正在理解任务…`})]})]})]})]})}function $d({block:e}){if(e.kind===`text`)return(0,I.jsx)(`div`,{className:`assistant-copy`,children:(0,I.jsx)(Jt,{text:e.text})});let t=e.state===`completed`?`✓`:e.state===`failed`?`×`:e.state===`cancelled`?`–`:e.state===`running`?``:`·`;return(0,I.jsxs)(`div`,{className:`activity-card`,"data-state":e.state,"data-tone":e.tone,children:[(0,I.jsx)(`span`,{className:`activity-node`,children:t}),(0,I.jsxs)(`div`,{className:`activity-body`,children:[(0,I.jsxs)(`div`,{className:`activity-title`,children:[(0,I.jsx)(`span`,{children:e.text.replace(/^[·✓×]\s*/,``)}),e.hint&&(0,I.jsx)(`code`,{children:e.hint})]}),e.progress!==void 0&&(0,I.jsx)(`div`,{className:`progress-track`,children:(0,I.jsx)(`i`,{style:{width:`${e.progress}%`}})}),e.presentation?.kind===`file-change`&&(0,I.jsx)(tf,{presentation:e.presentation}),e.presentation?.kind===`generic`&&(0,I.jsxs)(`div`,{className:`tool-presentation`,children:[(0,I.jsx)(`strong`,{children:e.presentation.title}),e.presentation.summary&&(0,I.jsx)(`span`,{children:e.presentation.summary})]}),e.presentation?.kind===`terminal`&&(0,I.jsxs)(`div`,{className:`tool-presentation`,children:[(0,I.jsx)(`strong`,{children:e.presentation.title}),e.presentation.stdout&&(0,I.jsx)(`pre`,{children:e.presentation.stdout})]}),e.presentation?.kind===`web`&&(0,I.jsxs)(`div`,{className:`tool-presentation`,children:[(0,I.jsx)(`strong`,{children:e.presentation.title}),e.presentation.summary&&(0,I.jsx)(`span`,{children:e.presentation.summary})]}),e.tool&&(0,I.jsxs)(`details`,{className:`tool-details`,children:[(0,I.jsx)(`summary`,{children:`调用详情`}),(0,I.jsx)(`label`,{children:`Input`}),(0,I.jsx)(`pre`,{children:ef(e.tool.input)}),e.tool.result===void 0?null:(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`label`,{children:`Result`}),(0,I.jsx)(`pre`,{children:ef(e.tool.result)})]})]}),e.details&&(0,I.jsxs)(`details`,{className:`timeline-details`,children:[(0,I.jsx)(`summary`,{children:`压缩摘要`}),(0,I.jsx)(Jt,{text:e.details})]})]})]})}function ef(e,t=1e4){let n;try{n=JSON.stringify(e,null,2)??`undefined`}catch{n=String(e)}return n.length<=t?n:`${n.slice(0,t)}…`}function tf({presentation:e}){let t=e.operation===`delete`,n=e.operation===`create`?`新建`:e.operation===`delete`?`删除`:`修改`,r=e.path.replace(/^.*[/\\]/,``),i=t?1:Math.max(1,...e.lines.map(e=>Math.max(e.oldLine??0,e.newLine??0))).toString().length;return(0,I.jsxs)(`details`,{className:`diff-preview`,children:[(0,I.jsxs)(`summary`,{children:[(0,I.jsx)(`span`,{className:`diff-marker ${t?`diff-delete`:`diff-add`}`,children:`●`}),(0,I.jsx)(`span`,{className:`diff-label`,children:n}),(0,I.jsx)(`span`,{className:`diff-path`,children:r}),(0,I.jsxs)(`span`,{className:`diff-counts`,children:[!t&&(0,I.jsxs)(`span`,{className:`diff-added-count`,children:[`+`,e.added]}),!t&&e.removed>0&&(0,I.jsxs)(`span`,{className:`diff-removed-count`,children:[` −`,e.removed]}),t&&(0,I.jsxs)(`span`,{className:`diff-removed-count`,children:[`−`,e.removed]})]})]}),t?null:(0,I.jsx)(`div`,{className:`diff-body`,children:e.lines.map((e,t)=>(0,I.jsx)(nf,{line:e,lineWidth:i},t))})]})}function nf({line:e,lineWidth:t}){let n=e.kind===`removed`||e.kind===`context`?e.oldLine:e.newLine,r=e.kind===`removed`?`-`:e.kind===`added`?`+`:e.kind===`omitted`?`…`:` `;return(0,I.jsxs)(`div`,{className:`diff-row ${e.kind===`added`?`diff-row-added`:e.kind===`removed`?`diff-row-removed`:e.kind===`omitted`?`diff-row-omitted`:`diff-row-context`}`,children:[(0,I.jsx)(`span`,{className:`diff-line-number`,children:String(n??``).padStart(t)}),(0,I.jsx)(`span`,{className:`diff-line-marker`,children:r}),(0,I.jsx)(`span`,{className:`diff-line-text`,children:e.text})]})}function rf(e){let t=e.snapshot.workspace===void 0,[n,r]=(0,_.useState)(!1),i=(0,_.useRef)(null),a=e.slashCompletion!==null,o=e.mentionCompletion!==null,s=a||o,c=e.completedTokenLen>0,l=c?e.input.slice(0,e.completedTokenLen):void 0,u=l?.startsWith(`/`)?l.slice(1).trim():l?.trim(),d=c?void 0:e.mentionSpan,f=d!==void 0&&d.start>=0&&d.end>d.start&&d.start<e.input.length&&d.end<=e.input.length&&e.input.slice(d.start,d.end)===e.input.slice(d.start,d.end),p=f?e.input.slice(0,d.start):``,m=f?e.input.slice(d.start,d.end):``,h=f?e.input.slice(d.end):``,g=m.startsWith(`@`)?m.slice(1).trim():m,v=c?e.input.slice(e.completedTokenLen):f?h:e.input,y=c?l.length:f?d.start+m.length:0,b=e=>y+e,x=t=>{if(a){if(t.key===`ArrowDown`){t.preventDefault(),e.onSlashMove(1);return}if(t.key===`ArrowUp`){t.preventDefault(),e.onSlashMove(-1);return}if(t.key===`Tab`||t.key===`Enter`){t.preventDefault();let n=e.slashCompletion?.items[e.slashCompletion?.selectedIndex??0];n!==void 0&&e.onSlashSelect(n.name);return}if(t.key===`Escape`){t.preventDefault(),e.onSlashDismiss();return}}if(o){if(t.key===`ArrowDown`){t.preventDefault(),e.onMentionMove(1);return}if(t.key===`ArrowUp`){t.preventDefault(),e.onMentionMove(-1);return}if(t.key===`Tab`||t.key===`Enter`){t.preventDefault();let n=e.mentionCompletion?.items[e.mentionCompletion?.selectedIndex??0];n!==void 0&&e.onMentionSelect(n);return}if(t.key===`Escape`){t.preventDefault(),e.onMentionDismiss();return}}let n=t.target,r=n.selectionStart,i=n.selectionEnd;if(t.key===`Backspace`&&r===i&&!s){if(c){let n=rn(e.input,e.completedTokenLen,b(r));if(n!==null){t.preventDefault(),e.setInput(n.text),e.setCursorPos(n.cursor);return}}if(f&&r===0){t.preventDefault();let n=p+h;e.setInput(n),e.setMentionSpan(void 0),e.setCursorPos(p.length);return}}t.key===`Enter`&&!t.shiftKey&&(t.preventDefault(),e.onSend(t.altKey?`followUp`:e.busy?`steer`:void 0))},S=(t,n)=>{let r;if(r=c?l+t:f?p+m+t:t,f){let t=p+m;r.startsWith(t)||e.setMentionSpan(void 0)}e.setInput(r),e.setCursorPos(b(n))},C=t=>{e.setCursorPos(b(t))},w=(0,I.jsx)(`textarea`,{ref:e.inputRef,className:`composer-textarea`,value:v,onChange:e=>S(e.target.value,e.target.selectionStart),onSelect:e=>C(e.target.selectionStart),onKeyDown:x,onPaste:t=>{let n=af(t.clipboardData.files);n.length!==0&&(t.preventDefault(),e.onAddImages(n))},onClick:e=>C(e.target.selectionStart),placeholder:t?`先打开一个项目`:c||f?``:`给 Flavor 一个任务,或输入 / 查看命令`,disabled:t,rows:1}),ee=c?(0,I.jsxs)(`div`,{className:`composer-input-row`,children:[(0,I.jsx)(`span`,{className:`slash-tag`,children:u}),w]}):f?(0,I.jsxs)(`div`,{className:`composer-input-row`,children:[p.length>0&&(0,I.jsx)(`span`,{className:`composer-plain-text`,children:p}),(0,I.jsx)(`span`,{className:`mention-tag`,children:g}),w]}):w;return(0,I.jsxs)(`div`,{className:`composer-wrap`,onDragEnter:e=>{of(e.dataTransfer)&&(e.preventDefault(),r(!0))},onDragOver:e=>{of(e.dataTransfer)&&e.preventDefault()},onDragLeave:e=>{e.currentTarget.contains(e.relatedTarget)||r(!1)},onDrop:t=>{let n=af(t.dataTransfer.files);n.length!==0&&(t.preventDefault(),r(!1),e.onAddImages(n))},children:[a&&(0,I.jsx)(cn,{completion:e.slashCompletion,onSelect:e.onSlashSelect,onDismiss:e.onSlashDismiss}),o&&(0,I.jsx)(dn,{completion:e.mentionCompletion,onSelect:e.onMentionSelect,onDismiss:e.onMentionDismiss}),(0,I.jsxs)(`div`,{className:`composer${c||f?` has-tag`:``}`,"data-busy":e.busy,"data-image-drag":n,children:[e.attachments.length>0&&(0,I.jsx)(Gd,{attachments:e.attachments,onRemove:e.onRemoveImage}),ee,(0,I.jsxs)(`div`,{className:`composer-tools`,children:[(0,I.jsx)(`input`,{ref:i,className:`image-file-input`,type:`file`,accept:`image/png,image/jpeg,image/webp`,multiple:!0,onChange:t=>{e.onAddImages(af(t.target.files)),t.target.value=``}}),(0,I.jsxs)(`button`,{type:`button`,className:`attach-button attach-button-labeled image-attach-button`,title:`添加图片(也可粘贴或拖入)`,"aria-label":`添加图片`,onClick:()=>i.current?.click(),disabled:t||e.busy||e.attachments.length>=Bd,children:[(0,I.jsx)(xf,{name:`image`}),(0,I.jsx)(`span`,{children:`图片`})]}),(0,I.jsxs)(`button`,{className:`attach-button attach-button-labeled`,title:`在提示中输入 @ 引用项目文件`,onClick:()=>{e.setInput(`${e.input}${e.input?` `:``}@`),setTimeout(()=>{let t=e.inputRef.current;t!==null&&(t.focus(),t.setSelectionRange(t.value.length,t.value.length))},0)},disabled:t,children:[(0,I.jsx)(xf,{name:`at`}),(0,I.jsx)(`span`,{children:`文件`})]}),(0,I.jsxs)(`div`,{className:`composer-context`,children:[(0,I.jsxs)(`span`,{className:`context-item`,title:e.snapshot.workspace,children:[(0,I.jsx)(xf,{name:`folder`}),(0,I.jsx)(`span`,{children:xe(e.snapshot.workspace)})]}),(0,I.jsxs)(`span`,{className:`context-item`,children:[(0,I.jsx)(xf,{name:`monitor`}),(0,I.jsx)(`span`,{children:`本地`})]})]}),(0,I.jsxs)(`div`,{className:`composer-controls`,children:[(0,I.jsx)(Ef,{models:e.snapshot.models,activeModel:e.snapshot.activeSession?.mainModel,busy:e.busy,onSelect:e.setModel,onAdd:e.addModel}),(0,I.jsx)(`select`,{"aria-label":`权限模式`,value:e.snapshot.activeSession?.permissionMode??`default`,disabled:e.busy||e.snapshot.activeSession===void 0,onChange:t=>e.setPermission(t.target.value),children:Rd.map(e=>(0,I.jsx)(`option`,{value:e,children:ye(e)},e))}),e.busy&&(0,I.jsxs)(`span`,{className:`queue-count`,title:`引导 + 后续消息`,children:[e.snapshot.activeSession?.queue.steering.length??0,`+`,e.snapshot.activeSession?.queue.followUp.length??0]}),(0,I.jsx)(`button`,{className:`send-button`,onClick:()=>e.onSend(e.busy?`steer`:void 0),disabled:t||!e.input.trim()&&e.attachments.length===0,title:e.busy?`发送引导消息`:`发送`,children:(0,I.jsx)(`span`,{children:`↑`})}),e.busy&&(0,I.jsx)(`button`,{className:`send-button stop-button`,onClick:e.onInterrupt,title:`停止任务`,children:(0,I.jsx)(`span`,{})})]})]})]}),(0,I.jsx)(`p`,{className:`composer-hint`,children:`Enter 发送 · Shift Enter 换行 · 粘贴/拖入图片 · @ 引用文件 · / 调用命令`})]})}function af(e){return e===null?[]:Array.from(e).filter(e=>e.type.startsWith(`image/`))}function of(e){return Array.from(e.items).some(e=>e.kind===`file`&&e.type.startsWith(`image/`))}async function sf(e){if(!Ud.has(e.type))throw Error(`不支持 ${e.type||`未知格式`};请选择 PNG、JPEG 或 WebP 图片。`);if(e.size<=0)throw Error(`${e.name} 是空文件。`);if(e.size>Vd)throw Error(`${e.name} 超过单图 5 MiB 限制。`);let t=cf(new Uint8Array(await e.arrayBuffer())),n=URL.createObjectURL(e);return{id:globalThis.crypto?.randomUUID?.()??`${Date.now()}-${Math.random()}`,name:e.name,mediaType:e.type,dataBase64:t,previewUrl:n}}function cf(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 lf({session:e,deleting:t,onCancel:n,onDelete:r}){return(0,I.jsx)(`div`,{className:`modal-layer`,children:(0,I.jsxs)(`section`,{className:`decision-sheet delete-session-sheet`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`delete-session-title`,children:[(0,I.jsx)(`div`,{className:`sheet-icon danger`,children:`×`}),(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`p`,{className:`sheet-kicker`,children:`删除历史会话`}),(0,I.jsxs)(`h2`,{id:`delete-session-title`,children:[`删除“`,be(e),`”?`]}),(0,I.jsx)(`p`,{children:`此会话的消息和任务记录将从当前项目中永久删除,此操作无法撤销。`}),(0,I.jsxs)(`div`,{className:`sheet-actions`,children:[(0,I.jsx)(`button`,{disabled:t,onClick:n,children:`取消`}),(0,I.jsx)(`button`,{className:`danger`,disabled:t,onClick:r,children:t?`正在删除…`:`删除会话`})]})]})]})})}var uf=new Set([`Delete`,`Move`,`RemoveTool`]);function df({approval:e,onResolve:t}){let n=uf.has(e.tool)||e.allowAlways===!1;return(0,I.jsx)(`div`,{className:`modal-layer`,children:(0,I.jsxs)(`section`,{className:`decision-sheet`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`approval-title`,children:[(0,I.jsx)(`div`,{className:`sheet-icon warning`,children:`!`}),(0,I.jsxs)(`div`,{children:[(0,I.jsxs)(`p`,{className:`sheet-kicker`,children:[`权限确认 · `,e.agent===`main`?`主 Agent`:`子 Agent`]}),(0,I.jsxs)(`h2`,{id:`approval-title`,children:[`允许执行 `,e.tool,`?`]}),(0,I.jsx)(`p`,{children:e.reason??`这项操作需要你的确认。`}),(e.command||e.paths?.length)&&(0,I.jsxs)(`pre`,{children:[e.command??e.paths?.join(`
154
154
  `),e.args?.length?` ${e.args.join(` `)}`:``]}),(0,I.jsxs)(`div`,{className:`sheet-actions`,children:[(0,I.jsx)(`button`,{onClick:()=>t(`deny`),children:`拒绝`}),!n&&(0,I.jsx)(`button`,{onClick:()=>t(`always`),children:`始终允许同类操作`}),(0,I.jsx)(`button`,{className:`primary`,onClick:()=>t(`allow`),children:`允许一次`})]})]})]})})}function ff({questions:e,onAnswer:t}){let[n,r]=(0,_.useState)({}),[i,a]=(0,_.useState)({}),o=e.every((e,t)=>!!n[t]?.trim());return(0,I.jsx)(`div`,{className:`modal-layer`,children:(0,I.jsxs)(`section`,{className:`question-sheet`,role:`dialog`,"aria-modal":`true`,children:[(0,I.jsx)(`p`,{className:`sheet-kicker`,children:`Flavor 需要确认`}),e.map((e,t)=>(0,I.jsxs)(`fieldset`,{children:[(0,I.jsx)(`legend`,{children:e.header}),(0,I.jsx)(`p`,{children:e.question}),(0,I.jsxs)(`div`,{className:`question-options`,children:[e.options.map(e=>(0,I.jsxs)(`button`,{"data-selected":!i[t]&&n[t]===e.label,onClick:()=>{a(e=>({...e,[t]:!1})),r(n=>({...n,[t]:e.label}))},children:[(0,I.jsx)(`strong`,{children:e.label}),(0,I.jsx)(`span`,{children:e.description})]},e.label)),(0,I.jsxs)(`button`,{"data-selected":i[t]===!0,onClick:()=>{a(e=>({...e,[t]:!0})),r(e=>({...e,[t]:``}))},children:[(0,I.jsx)(`strong`,{children:`其他(自定义输入)`}),(0,I.jsx)(`span`,{children:`键入你自己的回答`})]}),i[t]===!0&&(0,I.jsx)(`input`,{className:`question-custom-input`,autoFocus:!0,value:n[t]??``,onChange:e=>r(n=>({...n,[t]:e.target.value})),placeholder:`请输入回答`,"aria-label":`${e.header} 自定义回答`})]})]},`${e.header}-${t}`)),(0,I.jsx)(`div`,{className:`sheet-actions`,children:(0,I.jsx)(`button`,{className:`primary`,disabled:!o,onClick:()=>t(n),children:`继续`})})]})})}function pf({reviews:e,autoDismissSeconds:t,onResolve:n}){return(0,I.jsxs)(`aside`,{className:`memory-review-rail`,"aria-label":`长期记忆写入确认`,children:[(0,I.jsxs)(`header`,{children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`p`,{children:`待确认`}),(0,I.jsx)(`h2`,{children:`长期记忆候选`})]}),(0,I.jsx)(`span`,{children:e.length})]}),(0,I.jsx)(`p`,{className:`memory-review-warning`,children:`以下内容由模型生成,确认前不会写入长期记忆,也不会影响后续会话。`}),(0,I.jsx)(`div`,{className:`memory-review-list`,children:e.map(e=>(0,I.jsxs)(`article`,{children:[(0,I.jsx)(`small`,{children:e.type}),(0,I.jsx)(`p`,{children:e.content}),(0,I.jsx)(mf,{seconds:t}),(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`button`,{onClick:()=>n(e.id,`dismiss`),children:`忽略`}),(0,I.jsx)(`button`,{className:`primary`,onClick:()=>n(e.id,`accept`),children:`保存`})]})]},e.id))})]})}function mf({seconds:e}){let[t,n]=(0,_.useState)(e);return(0,_.useEffect)(()=>{if(e<=0)return;n(e);let t=setInterval(()=>n(e=>Math.max(0,e-1)),1e3);return()=>clearInterval(t)},[e]),e<=0?null:(0,I.jsxs)(`small`,{className:`memory-review-countdown`,children:[`未操作将在 `,t,`s 后自动忽略`]})}function hf({project:e,onStart:t}){return(0,I.jsxs)(`section`,{className:`welcome-state`,children:[(0,I.jsx)(`div`,{className:`welcome-mark`,children:(0,I.jsx)(Sf,{})}),(0,I.jsx)(`p`,{children:`已连接本地项目`}),(0,I.jsxs)(`h1`,{children:[`我们应该在 `,(0,I.jsx)(`u`,{children:e}),` 中构建什么?`]}),(0,I.jsx)(`div`,{className:`starter-grid`,children:_e.map(e=>(0,I.jsx)(`button`,{onClick:()=>t(e),children:e},e))})]})}function gf({onOpen:e}){return(0,I.jsxs)(`section`,{className:`open-state`,children:[(0,I.jsx)(`div`,{className:`welcome-mark`,children:(0,I.jsx)(Sf,{})}),(0,I.jsx)(`h1`,{children:`从一个本地项目开始`}),(0,I.jsx)(`p`,{children:`Flavor 会在你选择的文件夹范围内阅读、修改和运行代码。`}),(0,I.jsx)(`button`,{onClick:e,children:`打开项目`})]})}function _f(){return(0,I.jsxs)(`div`,{className:`loading-state`,children:[(0,I.jsx)(Sf,{}),(0,I.jsx)(`span`,{children:`正在准备桌面工作区…`})]})}var vf;function yf(){return vf??=window.flavorDesktop.appIcon().catch(()=>void 0),vf}function bf(){let[e,t]=(0,_.useState)(void 0);return(0,_.useEffect)(()=>{let e=!1;return yf().then(n=>{e||t(n)}),()=>{e=!0}},[]),e}function xf({name:e}){let t;switch(e){case`plus`:t=(0,I.jsx)(`path`,{d:`M10 4v12M4 10h12`});break;case`folder`:t=(0,I.jsx)(`path`,{d:`M2.75 6.25h5l1.5 1.75h8v7.25a1.5 1.5 0 0 1-1.5 1.5h-12a1.5 1.5 0 0 1-1.5-1.5v-7.5a1.5 1.5 0 0 1 1.5-1.5Z`});break;case`sparkles`:t=(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`path`,{d:`M8.25 3.25c.4 2.4 1.6 3.6 4 4-2.4.4-3.6 1.6-4 4-.4-2.4-1.6-3.6-4-4 2.4-.4 3.6-1.6 4-4Z`}),(0,I.jsx)(`path`,{d:`M14.5 11.5c.25 1.45 1.05 2.25 2.5 2.5-1.45.25-2.25 1.05-2.5 2.5-.25-1.45-1.05-2.25-2.5-2.5 1.45-.25 2.25-1.05 2.5-2.5Z`})]});break;case`database`:t=(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`ellipse`,{cx:`10`,cy:`5`,rx:`6.25`,ry:`2.5`}),(0,I.jsx)(`path`,{d:`M3.75 5v5c0 1.38 2.8 2.5 6.25 2.5s6.25-1.12 6.25-2.5V5M3.75 10v5c0 1.38 2.8 2.5 6.25 2.5s6.25-1.12 6.25-2.5v-5`})]});break;case`server`:t=(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`rect`,{x:`3`,y:`3.5`,width:`14`,height:`5`,rx:`1.5`}),(0,I.jsx)(`rect`,{x:`3`,y:`11.5`,width:`14`,height:`5`,rx:`1.5`}),(0,I.jsx)(`path`,{d:`M6 6h.01M6 14h.01M9 6h5M9 14h5`})]});break;case`checklist`:t=(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`rect`,{x:`3.25`,y:`2.75`,width:`13.5`,height:`14.5`,rx:`2`}),(0,I.jsx)(`path`,{d:`m6.25 7 1.25 1.25L10 5.75M11.75 7h2M6.25 12h1.5M10 12h4`})]});break;case`image`:t=(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`rect`,{x:`2.75`,y:`3.25`,width:`14.5`,height:`13.5`,rx:`2`}),(0,I.jsx)(`circle`,{cx:`7`,cy:`7.25`,r:`1.25`}),(0,I.jsx)(`path`,{d:`m4.75 14 3.5-3.5 2.25 2.25 2.25-2.5 2.5 3.75`})]});break;case`at`:t=(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`circle`,{cx:`9.5`,cy:`10`,r:`3`}),(0,I.jsx)(`path`,{d:`M12.5 10v1.25c0 1.15.8 1.75 1.75 1.75 1.4 0 2.25-1.2 2.25-3a6.5 6.5 0 1 0-2.1 4.78`})]});break;case`monitor`:t=(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`rect`,{x:`2.75`,y:`3.5`,width:`14.5`,height:`10.5`,rx:`2`}),(0,I.jsx)(`path`,{d:`M7 17h6M10 14v3`})]});break;case`bell`:t=(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`path`,{d:`M5.25 8.5a4.75 4.75 0 0 1 9.5 0c0 5 2 5.5 2 5.5H3.25s2-.5 2-5.5Z`}),(0,I.jsx)(`path`,{d:`M8 16a2.25 2.25 0 0 0 4 0`})]});break;case`git`:t=(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`circle`,{cx:`5`,cy:`4`,r:`1.75`}),(0,I.jsx)(`circle`,{cx:`15`,cy:`6.5`,r:`1.75`}),(0,I.jsx)(`circle`,{cx:`5`,cy:`16`,r:`1.75`}),(0,I.jsx)(`path`,{d:`M5 5.75v8.5M6.75 7.5C11 7.5 10.5 6.5 13.25 6.5`})]});break;case`search`:t=(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`circle`,{cx:`8.75`,cy:`8.75`,r:`5.25`}),(0,I.jsx)(`path`,{d:`m12.5 12.5 4 4`})]});break}return(0,I.jsx)(`svg`,{className:`ui-icon`,viewBox:`0 0 20 20`,"aria-hidden":`true`,focusable:`false`,children:t})}function Sf(){let e=bf();return e===void 0?(0,I.jsxs)(`svg`,{className:`flavor-mark`,viewBox:`0 0 36 36`,"aria-hidden":`true`,children:[(0,I.jsx)(`path`,{d:`M8 17.5C8 11.7 12.5 7 18 7s10 4.7 10 10.5c0 2.7-1 5.1-2.7 7l1 3.8-4-1.2A9.5 9.5 0 0 1 18 28c-5.5 0-10-4.7-10-10.5Z`}),(0,I.jsx)(`path`,{d:`M16 15l-2 2l2 2`,fill:`none`,stroke:`#1979c9`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,I.jsx)(`path`,{d:`M20 15l2 2l-2 2`,fill:`none`,stroke:`#1979c9`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,I.jsx)(`path`,{className:`mark-smile`,d:`M14 23c2.5 1.5 5.5 1.5 8 0`}),(0,I.jsx)(`ellipse`,{cx:`22`,cy:`24`,rx:`1.2`,ry:`0.9`,fill:`#f472b6`,stroke:`#ec4899`,strokeWidth:`0.3`,transform:`rotate(15 22 24)`})]}):(0,I.jsx)(`img`,{className:`flavor-mark`,src:e,alt:``,"aria-hidden":`true`})}function Cf(e){return e instanceof Error?e.message:String(e)}function wf(e){return e.replace(/^session-/,``).slice(0,17)}function Tf(e){return e?e.split(`:`).at(-1)??e:`选择模型`}function Ef({models:e,activeModel:t,busy:n,onSelect:r,onAdd:i}){let[a,o]=(0,_.useState)(!1),[s,c]=(0,_.useState)(!1),[l,u]=(0,_.useState)(),[d,f]=(0,_.useState)({provider:``,model:``,baseURL:``,apiKey:``,protocol:`openai-compatible`}),p=t??e[0]?.id,m=e.find(e=>e.id===p),h=m?.label??Tf(p),g=(e,t)=>{f(n=>({...n,[e]:t})),u(void 0)},v=async e=>{if(e.preventDefault(),s)return;let t=e.currentTarget;c(!0),u(void 0);try{await i(d),o(!1),f({provider:``,model:``,baseURL:``,apiKey:``,protocol:`openai-compatible`}),t.closest(`details`)?.removeAttribute(`open`)}catch(e){u(Cf(e))}finally{c(!1)}};return(0,I.jsxs)(`details`,{className:`model-menu`,children:[(0,I.jsxs)(`summary`,{"aria-label":`主模型:${h}`,title:`切换主模型`,children:[(0,I.jsx)(`span`,{className:`model-status-dot`,"data-configured":m!==void 0}),(0,I.jsx)(`span`,{className:`model-summary-label`,children:h}),(0,I.jsx)(`span`,{className:`model-summary-chevron`,"aria-hidden":`true`})]}),(0,I.jsxs)(`div`,{className:`popover model-popover`,children:[(0,I.jsxs)(`div`,{className:`model-popover-heading`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`strong`,{children:a?`添加厂商模型`:`切换主模型`}),(0,I.jsx)(`span`,{children:a?`连接 OpenAI 兼容或 Anthropic 服务`:`DeepSeek 默认可用,也可接入其他厂商`})]}),!a&&(0,I.jsx)(`button`,{type:`button`,onClick:()=>o(!0),disabled:n,children:`+ 新增`})]}),a?(0,I.jsxs)(`form`,{className:`model-provider-form`,onSubmit:e=>void v(e),children:[(0,I.jsxs)(`div`,{className:`model-form-grid`,children:[(0,I.jsxs)(`label`,{children:[(0,I.jsx)(`span`,{children:`厂商名称 / ID`}),(0,I.jsx)(`input`,{required:!0,maxLength:64,placeholder:`例如 siliconflow`,value:d.provider,onChange:e=>g(`provider`,e.target.value),pattern:`[A-Za-z0-9][A-Za-z0-9_-]*`})]}),(0,I.jsxs)(`label`,{children:[(0,I.jsx)(`span`,{children:`模型名称`}),(0,I.jsx)(`input`,{required:!0,maxLength:256,placeholder:`例如 qwen3-coder`,value:d.model,onChange:e=>g(`model`,e.target.value)})]})]}),(0,I.jsxs)(`label`,{children:[(0,I.jsx)(`span`,{children:`接口协议`}),(0,I.jsxs)(`select`,{value:d.protocol,onChange:e=>g(`protocol`,e.target.value),children:[(0,I.jsx)(`option`,{value:`openai-compatible`,children:`OpenAI 兼容 API`}),(0,I.jsx)(`option`,{value:`anthropic`,children:`Anthropic API`})]})]}),(0,I.jsxs)(`label`,{children:[(0,I.jsx)(`span`,{children:`Base URL`}),(0,I.jsx)(`input`,{required:!0,type:`url`,maxLength:2048,placeholder:`https://api.example.com/v1`,value:d.baseURL,onChange:e=>g(`baseURL`,e.target.value)})]}),(0,I.jsxs)(`label`,{children:[(0,I.jsx)(`span`,{children:`API Key`}),(0,I.jsx)(`input`,{required:!0,type:`password`,autoComplete:`off`,maxLength:16384,placeholder:`输入服务密钥`,value:d.apiKey,onChange:e=>g(`apiKey`,e.target.value)})]}),(0,I.jsxs)(`p`,{className:`model-security-note`,children:[(0,I.jsx)(`span`,{children:`◆`}),` 配置同步到当前项目,密钥只加密保存在本机。保存后会新建会话。`]}),l!==void 0&&(0,I.jsx)(`p`,{className:`model-form-error`,role:`alert`,children:l}),(0,I.jsxs)(`div`,{className:`model-form-actions`,children:[(0,I.jsx)(`button`,{type:`button`,onClick:()=>{o(!1),u(void 0)},disabled:s,children:`取消`}),(0,I.jsx)(`button`,{type:`submit`,className:`primary`,disabled:s||n,children:s?`正在连接…`:`保存并切换`})]})]}):(0,I.jsx)(`div`,{className:`model-options`,role:`listbox`,"aria-label":`主模型`,children:e.map(e=>{let t=p===e.id;return(0,I.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":t,className:`model-option`,disabled:n||t,onClick:t=>{r(e.id),t.currentTarget.closest(`details`)?.removeAttribute(`open`)},children:[(0,I.jsxs)(`span`,{className:`model-option-copy`,children:[(0,I.jsx)(`strong`,{children:e.label}),(0,I.jsx)(`small`,{children:e.description})]}),e.source===`custom`&&(0,I.jsx)(`span`,{className:`model-option-badge`,children:`自定义`}),(0,I.jsx)(`span`,{className:`model-option-state`,"aria-hidden":`true`,children:t?`✓`:`→`})]},e.id)})})]})]})}function Df(e){let t=new Date(e);return Number.isNaN(t.getTime())?``:t.toLocaleTimeString(`zh-CN`,{hour:`2-digit`,minute:`2-digit`})}var Of=document.getElementById(`root`);if(Of===null)throw Error(`Desktop root element was not found`);(0,v.createRoot)(Of).render((0,I.jsx)(_.StrictMode,{children:(0,I.jsx)(Kd,{})}));export{c as i,Kt as n,u as r,sd as t};