@vibe-forge/client 0.6.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{arc-CMAHd5G3.js → arc-DidNmF3v.js} +1 -1
- package/dist/assets/{blockDiagram-c4efeb88-DKww-VCP.js → blockDiagram-c4efeb88-CDnN61xv.js} +1 -1
- package/dist/assets/{c4Diagram-c83219d4-DKrjVHyY.js → c4Diagram-c83219d4-B3k8deko.js} +1 -1
- package/dist/assets/channel-Cde3vJGp.js +1 -0
- package/dist/assets/{classDiagram-beda092f-BXx5rdo3.js → classDiagram-beda092f-BdANZ7yV.js} +1 -1
- package/dist/assets/{classDiagram-v2-2358418a-CnR3WLsr.js → classDiagram-v2-2358418a-ow-iRMSq.js} +1 -1
- package/dist/assets/clone-LUH_zyxR.js +1 -0
- package/dist/assets/{createText-1719965b-CmOsl1W7.js → createText-1719965b-Wz6GZTHU.js} +1 -1
- package/dist/assets/{edges-96097737-CQeQgpjD.js → edges-96097737-D0RiugNT.js} +1 -1
- package/dist/assets/{erDiagram-0228fc6a-ZUNB-ucF.js → erDiagram-0228fc6a-CthowAHZ.js} +1 -1
- package/dist/assets/{flowDb-c6c81e3f-DuuKeSLX.js → flowDb-c6c81e3f-C-joVb9m.js} +1 -1
- package/dist/assets/{flowDiagram-50d868cf-Bc6n85yR.js → flowDiagram-50d868cf-Bx-hAyRl.js} +1 -1
- package/dist/assets/flowDiagram-v2-4f6560a1-CVxV-0Ew.js +1 -0
- package/dist/assets/{flowchart-elk-definition-6af322e1-cAG5afW9.js → flowchart-elk-definition-6af322e1-CpGiH0RQ.js} +1 -1
- package/dist/assets/{ganttDiagram-a2739b55-Dp6xhY5I.js → ganttDiagram-a2739b55-B2rBCB_P.js} +1 -1
- package/dist/assets/{gitGraphDiagram-82fe8481-MlIIRBdG.js → gitGraphDiagram-82fe8481-BH6XyEeG.js} +1 -1
- package/dist/assets/{graph-D7Es8jZ-.js → graph-De4BWXYq.js} +1 -1
- package/dist/assets/{index-5325376f-DC18ottv.js → index-5325376f-DciqDx2s.js} +1 -1
- package/dist/assets/{index-D37AbgPQ.js → index-IW7UIMcY.js} +2 -2
- package/dist/assets/{infoDiagram-8eee0895-CXk21kFp.js → infoDiagram-8eee0895-CiV1aI2C.js} +1 -1
- package/dist/assets/{journeyDiagram-c64418c1-899BKBHL.js → journeyDiagram-c64418c1-DeClao2V.js} +1 -1
- package/dist/assets/{layout-DLaxdy48.js → layout-B5GMBoJz.js} +1 -1
- package/dist/assets/{line-_lw5YbRM.js → line-CgBpZ2AR.js} +1 -1
- package/dist/assets/{linear-D5iu84ui.js → linear-Cd0IpBll.js} +1 -1
- package/dist/assets/{mermaid.core-C6sW3GFM.js → mermaid.core-CZnO8AvM.js} +4 -4
- package/dist/assets/{mindmap-definition-8da855dc-BS9Xy9KN.js → mindmap-definition-8da855dc-0XmBTp3E.js} +1 -1
- package/dist/assets/{pieDiagram-a8764435-DZt9cEgs.js → pieDiagram-a8764435-BNAROg0P.js} +1 -1
- package/dist/assets/{quadrantDiagram-1e28029f-BTIeHOgn.js → quadrantDiagram-1e28029f-Df_gmUZ3.js} +1 -1
- package/dist/assets/{requirementDiagram-08caed73-BHJAKD2g.js → requirementDiagram-08caed73-CJucWU8H.js} +1 -1
- package/dist/assets/{sankeyDiagram-a04cb91d-DnAkVOK8.js → sankeyDiagram-a04cb91d-CHiMn2x-.js} +1 -1
- package/dist/assets/{sequenceDiagram-c5b8d532-92tE3oFv.js → sequenceDiagram-c5b8d532-C9TpmcH3.js} +1 -1
- package/dist/assets/{stateDiagram-1ecb1508-DG0ObiMg.js → stateDiagram-1ecb1508-Cvptb-Zj.js} +1 -1
- package/dist/assets/{stateDiagram-v2-c2b004d7-BKoJx2ci.js → stateDiagram-v2-c2b004d7-nRJ7hzpx.js} +1 -1
- package/dist/assets/{styles-b4e223ce-Ba6G4ri9.js → styles-b4e223ce-iTClb1YD.js} +1 -1
- package/dist/assets/{styles-ca3715f6-Bn6RIIVW.js → styles-ca3715f6-BstDoS6h.js} +1 -1
- package/dist/assets/{styles-d45a18b0-_dELBUI6.js → styles-d45a18b0-Ci8lW61F.js} +1 -1
- package/dist/assets/{svgDrawCommon-b86b1483-CRK-ZoIs.js → svgDrawCommon-b86b1483-DxM1HDTD.js} +1 -1
- package/dist/assets/{timeline-definition-faaaa080-DvQ_RA_i.js → timeline-definition-faaaa080-bmNqY66u.js} +1 -1
- package/dist/assets/{xychartDiagram-f5964ef8-CJxeDLfg.js → xychartDiagram-f5964ef8-0OjuuJfh.js} +1 -1
- package/dist/index.html +1 -1
- package/package.json +7 -7
- package/src/hooks/chat/use-chat-session-actions.ts +6 -1
- package/dist/assets/channel-Bi4g8rj9.js +0 -1
- package/dist/assets/clone-DPrpP2ky.js +0 -1
- package/dist/assets/flowDiagram-v2-4f6560a1-BZqaeqoh.js +0 -1
|
@@ -497,7 +497,7 @@ Please change the parent <Route path="${S}"> to <Route path="${S==="/"?"*":`${S}
|
|
|
497
497
|
${e.frontmatter.setupCommand}
|
|
498
498
|
\`\`\``})]}),b.jsxs("div",{className:"benchmark-view__info-row benchmark-view__info-row--block",children:[b.jsxs("label",{children:[b.jsx("span",{className:"material-symbols-rounded",children:"science"}),a("benchmark.testCommand")]}),b.jsx(Xi,{content:`\`\`\`bash
|
|
499
499
|
${e.frontmatter.testCommand}
|
|
500
|
-
\`\`\``})]})]})]}),b.jsxs("div",{className:"benchmark-view__section benchmark-view__task-goal",children:[b.jsx(ug,{icon:"assignment",title:a("benchmark.taskGoal")}),b.jsx("div",{className:"benchmark-view__goal-body",children:b.jsx(Xi,{content:e.rfcBody})})]})]}),b.jsx(nO,{className:"benchmark-view__sep"}),b.jsxs("div",{className:"benchmark-view__twin-grid benchmark-view__section--last",children:[b.jsx(QSe,{activeRunId:r,activeRun:n,progressPercent:o,t:a}),b.jsx(ZSe,{latestResult:t,t:a})]})]})}function QSe({activeRunId:e,activeRun:t,progressPercent:n,t:r}){return b.jsxs("div",{className:"benchmark-view__section",children:[b.jsx(ug,{icon:"pulse_alert",title:r("benchmark.runState"),extra:t?b.jsx(Lo,{children:t.status}):null}),e===""?b.jsx(ao.Text,{type:"secondary",className:"benchmark-view__hint",children:r("benchmark.noActiveRun")}):b.jsxs("div",{className:"benchmark-view__run-block",children:[b.jsxs("div",{className:"benchmark-view__run-metric",children:[b.jsx("label",{children:r("benchmark.progress")}),b.jsx("strong",{children:`${(t==null?void 0:t.completedCount)??0}/${(t==null?void 0:t.totalCount)??"-"}`})]}),b.jsx(Loe,{percent:n,showInfo:!1}),b.jsxs("div",{className:"benchmark-view__info-grid",children:[b.jsxs("div",{className:"benchmark-view__info-row",children:[b.jsx("label",{children:r("benchmark.runStatus")}),b.jsx("span",{children:(t==null?void 0:t.status)??"-"})]}),b.jsxs("div",{className:"benchmark-view__info-row",children:[b.jsx("label",{children:r("benchmark.lastMessage")}),b.jsx(ao.Text,{children:(t==null?void 0:t.lastMessage)??"-"})]})]})]})]})}function ZSe({latestResult:e,t}){return b.jsxs("div",{className:"benchmark-view__section",children:[b.jsx(ug,{icon:"insights",title:t("benchmark.resultTitle"),extra:e?b.jsx(XSe,{result:e}):null}),e==null?b.jsx(ao.Text,{type:"secondary",className:"benchmark-view__hint",children:t("benchmark.noResult")}):b.jsxs("div",{className:"benchmark-view__result",children:[b.jsxs("div",{className:"benchmark-view__score-strip",children:[b.jsxs("div",{className:"benchmark-view__score-item",children:[b.jsx("label",{children:t("benchmark.finalScore")}),b.jsx("strong",{children:e.finalScore})]}),b.jsxs("div",{className:"benchmark-view__score-item",children:[b.jsx("label",{children:t("benchmark.testScore")}),b.jsx("strong",{children:e.scores.testScore})]}),b.jsxs("div",{className:"benchmark-view__score-item",children:[b.jsx("label",{children:t("benchmark.goalScore")}),b.jsx("strong",{children:e.scores.goalScore})]}),b.jsxs("div",{className:"benchmark-view__score-item",children:[b.jsx("label",{children:t("benchmark.referenceScore")}),b.jsx("strong",{children:e.scores.referenceScore})]})]}),b.jsxs("div",{className:"benchmark-view__info-grid",children:[b.jsxs("div",{className:"benchmark-view__info-row",children:[b.jsxs("label",{children:[b.jsx("span",{className:"material-symbols-rounded",children:"schedule"}),t("benchmark.durationMs")]}),b.jsx("span",{children:e.durationMs})]}),b.jsxs("div",{className:"benchmark-view__info-row",children:[b.jsxs("label",{children:[b.jsx("span",{className:"material-symbols-rounded",children:"monitoring"}),t("benchmark.testExitCode")]}),b.jsx("span",{children:e.testExitCode})]})]}),b.jsx(ao.Paragraph,{className:"benchmark-view__judge-summary",children:e.judgeSummary}),b.jsxs("div",{className:"benchmark-view__subgrid",children:[b.jsxs("div",{className:"benchmark-view__subpanel",children:[b.jsxs("div",{className:"benchmark-view__subpanel-title",children:[b.jsx("span",{className:"material-symbols-rounded",children:"plagiarism"}),b.jsx("span",{children:t("benchmark.changedFiles")})]}),e.changedFiles!=null&&e.changedFiles.length>0?b.jsx("div",{className:"benchmark-view__file-list",children:e.changedFiles.map(n=>b.jsx("span",{className:"benchmark-view__file-tag",children:n},n))}):b.jsx(ao.Text,{type:"secondary",children:t("benchmark.noChangedFiles")})]}),b.jsxs("div",{className:"benchmark-view__subpanel",children:[b.jsxs("div",{className:"benchmark-view__subpanel-title",children:[b.jsx("span",{className:"material-symbols-rounded",children:"report"}),b.jsx("span",{children:t("benchmark.issues")})]}),e.issues.length===0?b.jsx(ao.Text,{type:"secondary",children:t("benchmark.noIssues")}):b.jsx("ul",{className:"benchmark-view__issues-list",children:e.issues.map(n=>b.jsx("li",{children:n},n))})]})]})]})]})}function JSe({result:e}){const t=AF(e);return b.jsx("span",{className:`material-symbols-rounded benchmark-view__status-icon benchmark-view__status-icon--${t.statusKey}`,children:t.icon})}function eCe(e){const{categories:t,cases:n,query:r,t:o,onRunCase:i,onRunCategory:a}=e,s=r.trim().toLowerCase();return(t.length>0?t:Array.from(new Set(n.map(c=>c.category))).map(c=>({category:c,caseCount:n.filter(d=>d.category===c).length,lastStatuses:{pass:0,partial:0,fail:0}}))).map(c=>{const d=n.filter(p=>p.category===c.category),m=s===""||c.category.toLowerCase().includes(s)?d:d.filter(p=>{const h=p.frontmatter.title??"";return p.title.toLowerCase().includes(s)||h.toLowerCase().includes(s)});return m.length===0?null:{key:`category:${c.category}`,selectable:!0,title:b.jsxs("div",{className:"benchmark-view__tree-category",children:[b.jsx("span",{className:"material-symbols-rounded benchmark-view__tree-icon benchmark-view__tree-icon--category",children:"folder_open"}),b.jsx(ao.Text,{strong:!0,className:"benchmark-view__tree-title",children:c.category}),b.jsx(ht,{title:o("benchmark.runCategory"),children:b.jsx(lt,{type:"text",size:"small",className:"benchmark-view__tree-run-btn benchmark-view__tree-run-btn--category",icon:b.jsx("span",{className:"material-symbols-rounded",children:"play_circle"}),onClick:p=>{p.stopPropagation(),a(c.category)}})})]}),children:m.map(p=>{const h={...p,key:`case:${p.category}/${p.title}`},y=p.frontmatter.title??p.title;return{key:h.key,isLeaf:!0,title:b.jsxs("div",{className:"benchmark-view__tree-case",children:[b.jsx(JSe,{result:h.latestResult}),b.jsx("span",{className:"material-symbols-rounded benchmark-view__tree-icon",children:"draft"}),b.jsx(ao.Text,{className:"benchmark-view__tree-title",children:y}),b.jsx(ht,{title:o("benchmark.runCase"),children:b.jsx(lt,{type:"text",size:"small",className:"benchmark-view__tree-run-btn",icon:b.jsx("span",{className:"material-symbols-rounded",children:"play_circle"}),onClick:x=>{x.stopPropagation(),i(p)}})})]}),caseData:h}})}}).filter(Boolean)}function tCe({cases:e,categories:t,selectedCase:n,query:r,expandedKeys:o,checkedKeys:i,checkedCaseCount:a,onQueryChange:s,onExpandedKeysChange:l,onCheckedKeysChange:c,onSelectCase:d,onRunCase:f,onRunCategory:m,onBatchRun:p}){const{t:h}=Ot(),y=u.useMemo(()=>eCe({categories:t,cases:e,query:r,t:h,onRunCase:f,onRunCategory:m}),[e,t,r,h]),x=v=>{const S=Array.isArray(v)?v:v.checked;c(S.map(String))},g=(v,S)=>{const C=S.node.caseData;if(C!=null){d(C.category,C.title);return}const _=String(S.node.key);if(!_.startsWith("category:"))return;const w=_.replace("category:",""),N=e.find(k=>k.category===w);d(w,(N==null?void 0:N.title)??"")};return b.jsxs("div",{className:"benchmark-view__sidebar",children:[b.jsx("div",{className:"benchmark-view__sidebar-header",children:b.jsx(ao.Title,{level:4,className:"benchmark-view__sidebar-title",children:h("benchmark.title")})}),b.jsxs("div",{className:"benchmark-view__search-row",children:[b.jsx(Ft,{value:r,placeholder:h("benchmark.searchPlaceholder"),prefix:b.jsx("span",{className:"material-symbols-rounded benchmark-view__search-icon",children:"search"}),allowClear:!0,onChange:v=>s(v.target.value),className:"benchmark-view__search"}),b.jsx(ht,{title:h("benchmark.expandAll"),children:b.jsx(lt,{type:"text",size:"small",icon:b.jsx("span",{className:"material-symbols-rounded",children:"unfold_more"}),onClick:()=>l(t.map(v=>`category:${v.category}`))})}),b.jsx(ht,{title:h("benchmark.collapseAll"),children:b.jsx(lt,{type:"text",size:"small",icon:b.jsx("span",{className:"material-symbols-rounded",children:"unfold_less"}),onClick:()=>l([])})}),b.jsx(ht,{title:a>0?h("benchmark.runSelected",{count:a}):h("benchmark.runAll"),children:b.jsx(C_,{count:a,size:"small",children:b.jsx(lt,{type:"text",size:"small",icon:b.jsx("span",{className:"material-symbols-rounded",children:"play_circle"}),onClick:p})})})]}),b.jsx("div",{className:"benchmark-view__tree-shell",children:y.length===0?b.jsx("div",{className:"benchmark-view__tree-empty",children:b.jsx(yn,{description:h("benchmark.emptyCases"),image:yn.PRESENTED_IMAGE_SIMPLE})}):b.jsx(Dv,{blockNode:!0,checkable:!0,showIcon:!1,switcherIcon:b.jsx("span",{className:"material-symbols-rounded benchmark-view__switcher",children:"chevron_right"}),selectedKeys:n?[`case:${n.category}/${n.title}`]:[],expandedKeys:o,checkedKeys:i,treeData:y,onExpand:v=>l(v.map(String)),onSelect:g,onCheck:x})})]})}function nCe(){const{t:e}=Ot(),{message:t}=_o.useApp(),[n,r]=u.useState(""),[o,i]=u.useState(""),[a,s]=u.useState([]),[l,c]=u.useState([]),{values:d,update:f}=Ru({keys:["category","title"],defaults:{category:"",title:""},omit:{category:I=>I==="",title:I=>I===""}}),{data:m,mutate:p}=zn("/api/benchmark/categories",yfe),h=(m==null?void 0:m.categories)??[],{data:y,mutate:x}=zn("/api/benchmark/cases",()=>bfe()),g=(y==null?void 0:y.cases)??[],v=u.useMemo(()=>{if(g.length===0)return null;const I=g.find(M=>M.category===d.category&&M.title===d.title);return I||((d.category?g.find(M=>M.category===d.category)??null:null)??g[0]??null)},[g,d.category,d.title]),{data:S,mutate:C}=zn(v?`/api/benchmark/results/${v.category}/${v.title}`:null,()=>xfe((v==null?void 0:v.category)??"",(v==null?void 0:v.title)??"")),_=(S==null?void 0:S.result)??(v==null?void 0:v.latestResult)??null,{data:w,mutate:N}=zn(n?`/api/benchmark/runs/${n}`:null,()=>Sfe(n),{refreshInterval:n?2e3:0}),k=w==null?void 0:w.run,E=u.useMemo(()=>{const I=(k==null?void 0:k.totalCount)??0;if(I<=0)return 0;const T=(k==null?void 0:k.completedCount)??0;return Math.min(100,Math.round(T/I*100))},[k==null?void 0:k.completedCount,k==null?void 0:k.totalCount]),$=u.useCallback(async I=>{try{const T=await ep({category:I.category,title:I.title});r(T.run.runId),t.success(e("benchmark.runStarted"))}catch(T){t.error(jr(T,e("benchmark.runFailed")))}},[t,e]),O=u.useCallback(async I=>{try{const T=await ep({category:I});r(T.run.runId),t.success(e("benchmark.categoryRunStarted"))}catch(T){t.error(jr(T,e("benchmark.runFailed")))}},[t,e]),R=u.useCallback(async()=>{const I=l.filter(L=>L.startsWith("case:")),T=g.filter(L=>I.includes(`case:${L.category}/${L.title}`));if(T.length===0){for(const L of g)try{await ep({category:L.category,title:L.title})}catch{}t.success(e("benchmark.runStarted"));return}let M=0;for(const L of T)try{await ep({category:L.category,title:L.title}),M++}catch{}M>0&&(c([]),x(),p(),t.success(e("benchmark.runStarted")))},[l,g,x,p,t,e]);u.useEffect(()=>{const I=h.map(T=>`category:${T.category}`);s(T=>T.length>0&&o.trim()===""?T:I)},[h,o]),u.useEffect(()=>{v!=null&&(d.category!==v.category||d.title!==v.title)&&f({category:v.category,title:v.title})},[v,f,d.category,d.title]),u.useEffect(()=>{if(!GSe(k))return;x(),p(),C(),n!==""&&N();const I=(k==null?void 0:k.status)==="completed"?e("benchmark.runCompleted"):e("benchmark.runFailed");t.info(I),r("")},[k,n,t,x,p,C,N,e]);const P=l.filter(I=>I.startsWith("case:")).length;return b.jsxs("div",{className:"benchmark-view",children:[b.jsx("div",{className:"benchmark-view__left",children:b.jsx(tCe,{cases:g,categories:h,selectedCase:v,query:o,expandedKeys:a,checkedKeys:l,checkedCaseCount:P,onQueryChange:i,onExpandedKeysChange:s,onCheckedKeysChange:c,onSelectCase:(I,T)=>f({category:I,title:T}),onRunCase:I=>void $(I),onRunCategory:I=>void O(I),onBatchRun:()=>void R()})}),b.jsx("div",{className:"benchmark-view__divider"}),b.jsx("div",{className:"benchmark-view__right",children:b.jsx(YSe,{selectedCase:v,latestResult:_,activeRun:k,activeRunId:n,progressPercent:E,onRunCase:()=>void(v&&$(v))})})]})}function rCe(){return b.jsx(nCe,{})}const oCe=({value:e})=>{const{t}=Ot(),n=e!=null&&typeof e=="object"?e:void 0,r=n==null?void 0:n.urls,o=n==null?void 0:n.version,i=n==null?void 0:n.lastReleaseAt;return b.jsxs("div",{className:"config-about",children:[b.jsxs("div",{className:"config-about__card",children:[b.jsxs("div",{className:"config-about__app",children:[b.jsx("div",{className:"config-about__app-icon",children:b.jsx("span",{className:"material-symbols-rounded",children:"auto_awesome"})}),b.jsxs("div",{className:"config-about__app-info",children:[b.jsx("div",{className:"config-about__app-title",children:t("config.about.software")}),b.jsxs("div",{className:"config-about__app-meta",children:[b.jsxs("span",{className:"config-about__app-version",children:[t("config.about.version"),": ",o??t("config.about.unknown")]}),b.jsx("span",{className:"config-about__app-date",children:i??t("config.about.unknown")})]})]})]}),b.jsx("a",{className:"config-about__primary",href:(r==null?void 0:r.releases)??(r==null?void 0:r.repo),target:"_blank",rel:"noreferrer",children:t("config.about.checkUpdate")})]}),b.jsxs("div",{className:"config-about__list",children:[b.jsxs("a",{className:"config-about__item-row",href:(r==null?void 0:r.docs)??(r==null?void 0:r.repo),target:"_blank",rel:"noreferrer",children:[b.jsxs("span",{className:"config-about__item-left",children:[b.jsx("span",{className:"material-symbols-rounded config-about__item-icon",children:"menu_book"}),b.jsx("span",{children:t("config.about.docs")})]}),b.jsx("span",{className:"material-symbols-rounded config-about__arrow",children:"open_in_new"})]}),b.jsxs("a",{className:"config-about__item-row",href:(r==null?void 0:r.contact)??(r==null?void 0:r.repo),target:"_blank",rel:"noreferrer",children:[b.jsxs("span",{className:"config-about__item-left",children:[b.jsx("span",{className:"material-symbols-rounded config-about__item-icon",children:"mail"}),b.jsx("span",{children:t("config.about.contact")})]}),b.jsx("span",{className:"material-symbols-rounded config-about__arrow",children:"open_in_new"})]}),b.jsxs("a",{className:"config-about__item-row",href:(r==null?void 0:r.issues)??(r==null?void 0:r.repo),target:"_blank",rel:"noreferrer",children:[b.jsxs("span",{className:"config-about__item-left",children:[b.jsx("span",{className:"material-symbols-rounded config-about__item-icon",children:"bug_report"}),b.jsx("span",{children:t("config.about.feedback")})]}),b.jsx("span",{className:"material-symbols-rounded config-about__arrow",children:"open_in_new"})]})]})]})},Pn=({title:e,description:t,icon:n,layout:r="inline",children:o})=>b.jsxs("div",{className:`config-view__field-row${r==="stacked"?" config-view__field-row--stacked":""}`,children:[b.jsxs("div",{className:"config-view__field-meta",children:[n!=null&&b.jsx("span",{className:"material-symbols-rounded config-view__field-icon",children:n}),b.jsxs("div",{className:"config-view__field-text",children:[b.jsx("div",{className:"config-view__field-title",children:e}),t!=null&&t!==""&&b.jsx("div",{className:"config-view__field-desc",children:t})]})]}),b.jsx("div",{className:"config-view__field-control",children:o})]}),dg=e=>e==null?!0:Array.isArray(e)?e.length===0:typeof e=="object"?Object.keys(e).length===0:!1,cp=e=>e==null?e:JSON.parse(JSON.stringify(e)),LF=e=>Array.isArray(e)?"array":e!=null&&typeof e=="object"?"object":typeof e=="number"?"number":typeof e=="boolean"?"boolean":"string",An=e=>e==="string"?"text_fields":e==="number"?"numbers":e==="boolean"?"toggle_on":e==="array"?"view_list":"account_tree",DF=(e,t,n,r)=>{if(n.length===0)return r;const o=`config.fields.${t}.${n.join(".")}.label`;return e(o,{defaultValue:r})},zF=(e,t,n)=>{if(n.length===0)return"";const r=`config.fields.${t}.${n.join(".")}.desc`;return e(r,{defaultValue:""})},BF=e=>/key|token|secret|password/i.test(e),Kp=(e,t)=>{if(t.length===0)return e;let n=e;for(const r of t){if(n==null||typeof n!="object")return;n=n[r]}return n},UR=(e,t,n)=>{if(t.length===0)return n;const r=e!=null&&typeof e=="object"&&!Array.isArray(e)?{...e}:{};let o=r;for(let i=0;i<t.length-1;i+=1){const a=t[i],s=o[a],l=s!=null&&typeof s=="object"&&!Array.isArray(s)?{...s}:{};o[a]=l,o=l}return o[t[t.length-1]]=n,r},FF=({value:e,sectionKey:t,path:n=[],t:r})=>dg(e)?b.jsx(yn,{description:r("common.noData"),image:null}):Array.isArray(e)?e.some(i=>i!=null&&typeof i=="object")?b.jsx("span",{className:"config-view__pill",children:r("config.editor.complexValue")}):b.jsx("div",{className:"config-view__display-pill",children:e.map((i,a)=>b.jsx("span",{className:"config-view__pill",children:String(i)},`${a}-${String(i)}`))}):e!=null&&typeof e=="object"?b.jsx("div",{className:"config-view__field-list",children:Object.entries(e).map(([o,i])=>{const a=DF(r,t,[...n,o],o),s=zF(r,t,[...n,o]);return b.jsx(Pn,{title:a,description:s,icon:An(LF(i)),children:b.jsx(FF,{value:i,sectionKey:t,path:[...n,o],t:r})},o)})}):b.jsx("span",{className:"config-view__pill",children:String(e)}),eu=({value:e,onChange:t})=>{const{message:n}=_o.useApp(),{t:r}=Ot(),[o,i]=u.useState(()=>JSON.stringify(e??{},null,2));return u.useEffect(()=>{i(JSON.stringify(e??{},null,2))},[e]),b.jsx(Ft.TextArea,{className:"config-view__complex-editor",value:o,onChange:a=>{i(a.target.value)},onBlur:()=>{try{const a=JSON.parse(o);t==null||t(a),i(JSON.stringify(a??{},null,2))}catch{n.error(r("config.invalidJson")),i(JSON.stringify(e??{},null,2))}},placeholder:r("config.editor.complexPlaceholder"),autoSize:{minRows:6}})},cy=({value:e,onChange:t,t:n})=>b.jsxs("div",{className:"config-view__array-list",children:[e.map((r,o)=>b.jsxs("div",{className:"config-view__array-item",children:[b.jsx(Ft,{value:r,placeholder:n("config.editor.itemPlaceholder"),onChange:i=>{const a=e.slice();a[o]=i.target.value,t(a)}}),b.jsx(ht,{title:n("config.editor.remove"),children:b.jsx(lt,{size:"small",type:"text",danger:!0,className:"config-view__icon-button config-view__icon-button--compact","aria-label":n("config.editor.remove"),icon:b.jsx("span",{className:"material-symbols-rounded",children:"delete"}),onClick:()=>{const i=e.slice();i.splice(o,1),t(i)}})})]},`${o}-${r}`)),b.jsx(ht,{title:n("config.editor.addItem"),children:b.jsx(lt,{size:"small",type:"primary",className:"config-view__icon-button config-view__icon-button--full","aria-label":n("config.editor.addItem"),icon:b.jsx("span",{className:"material-symbols-rounded",children:"add"}),onClick:()=>{t([...e,""])}})})]}),iCe=({value:e,onChange:t,placeholder:n,isMac:r,t:o})=>{const i=e.trim()===""?"":Uz(e,r);return b.jsxs("div",{className:"config-shortcut-input",children:[b.jsx(Ft,{value:i,placeholder:n,readOnly:!0,onKeyDown:a=>{if(a.key==="Backspace"||a.key==="Delete"){a.preventDefault(),t("");return}const s=kfe(a);s!=null&&(a.preventDefault(),t(s))}}),b.jsx(ht,{title:o("config.editor.clearShortcut"),children:b.jsx(lt,{size:"small",type:"text",className:"config-view__icon-button config-view__icon-button--compact","aria-label":o("config.editor.clearShortcut"),icon:b.jsx("span",{className:"material-symbols-rounded",children:"close"}),onClick:()=>t("")})})]})},aCe={general:{items:{labelKey:"config.fields.general.notifications.label"}}},sCe={general:[{path:["baseDir"],type:"string",defaultValue:".ai",icon:"folder",group:"base"},{path:["defaultAdapter"],type:"select",defaultValue:"",icon:"settings_input_component",group:"base"},{path:["defaultModelService"],type:"select",defaultValue:"",icon:"hub",group:"base"},{path:["defaultModel"],type:"select",defaultValue:"",icon:"model_training",group:"base"},{path:["recommendedModels"],type:"json",defaultValue:[],icon:"stars",group:"base"},{path:["interfaceLanguage"],type:"select",defaultValue:"",icon:"language",group:"base",options:[{value:"zh",label:"config.options.language.zh"},{value:"en",label:"config.options.language.en"}]},{path:["modelLanguage"],type:"select",defaultValue:"",icon:"translate",group:"base",options:[{value:"zh",label:"config.options.language.zh"},{value:"en",label:"config.options.language.en"}]},{path:["announcements"],type:"string[]",defaultValue:[],icon:"campaign",group:"base"},{path:["permissions","allow"],type:"string[]",defaultValue:[],icon:"check_circle",group:"permissions"},{path:["permissions","deny"],type:"string[]",defaultValue:[],icon:"block",group:"permissions"},{path:["permissions","ask"],type:"string[]",defaultValue:[],icon:"help",group:"permissions"},{path:["env"],type:"record",recordKind:"keyValue",defaultValue:{},icon:"terminal",group:"env"},{path:["notifications","disabled"],type:"boolean",defaultValue:!1,icon:"notifications",group:"items"},{path:["notifications","volume"],type:"number",defaultValue:100,icon:"volume_down",group:"items"},{path:["notifications","events","completed","title"],type:"string",defaultValue:"",icon:"title",group:"items",collapse:{key:"notifications.events.completed",labelKey:"config.fields.general.notifications.events.completed.label",descKey:"config.fields.general.notifications.events.completed.desc",togglePath:["notifications","events","completed","disabled"]}},{path:["notifications","events","completed","description"],type:"multiline",defaultValue:"",icon:"notes",group:"items",collapse:{key:"notifications.events.completed",labelKey:"config.fields.general.notifications.events.completed.label",descKey:"config.fields.general.notifications.events.completed.desc",togglePath:["notifications","events","completed","disabled"]}},{path:["notifications","events","completed","sound"],type:"string",defaultValue:"",icon:"volume_up",group:"items",collapse:{key:"notifications.events.completed",labelKey:"config.fields.general.notifications.events.completed.label",descKey:"config.fields.general.notifications.events.completed.desc",togglePath:["notifications","events","completed","disabled"]}},{path:["notifications","events","failed","title"],type:"string",defaultValue:"",icon:"title",group:"items",collapse:{key:"notifications.events.failed",labelKey:"config.fields.general.notifications.events.failed.label",descKey:"config.fields.general.notifications.events.failed.desc",togglePath:["notifications","events","failed","disabled"]}},{path:["notifications","events","failed","description"],type:"multiline",defaultValue:"",icon:"notes",group:"items",collapse:{key:"notifications.events.failed",labelKey:"config.fields.general.notifications.events.failed.label",descKey:"config.fields.general.notifications.events.failed.desc",togglePath:["notifications","events","failed","disabled"]}},{path:["notifications","events","failed","sound"],type:"string",defaultValue:"",icon:"volume_up",group:"items",collapse:{key:"notifications.events.failed",labelKey:"config.fields.general.notifications.events.failed.label",descKey:"config.fields.general.notifications.events.failed.desc",togglePath:["notifications","events","failed","disabled"]}},{path:["notifications","events","terminated","title"],type:"string",defaultValue:"",icon:"title",group:"items",collapse:{key:"notifications.events.terminated",labelKey:"config.fields.general.notifications.events.terminated.label",descKey:"config.fields.general.notifications.events.terminated.desc",togglePath:["notifications","events","terminated","disabled"]}},{path:["notifications","events","terminated","description"],type:"multiline",defaultValue:"",icon:"notes",group:"items",collapse:{key:"notifications.events.terminated",labelKey:"config.fields.general.notifications.events.terminated.label",descKey:"config.fields.general.notifications.events.terminated.desc",togglePath:["notifications","events","terminated","disabled"]}},{path:["notifications","events","terminated","sound"],type:"string",defaultValue:"",icon:"volume_up",group:"items",collapse:{key:"notifications.events.terminated",labelKey:"config.fields.general.notifications.events.terminated.label",descKey:"config.fields.general.notifications.events.terminated.desc",togglePath:["notifications","events","terminated","disabled"]}},{path:["notifications","events","waiting_input","title"],type:"string",defaultValue:"",icon:"title",group:"items",collapse:{key:"notifications.events.waiting_input",labelKey:"config.fields.general.notifications.events.waiting_input.label",descKey:"config.fields.general.notifications.events.waiting_input.desc",togglePath:["notifications","events","waiting_input","disabled"]}},{path:["notifications","events","waiting_input","description"],type:"multiline",defaultValue:"",icon:"notes",group:"items",collapse:{key:"notifications.events.waiting_input",labelKey:"config.fields.general.notifications.events.waiting_input.label",descKey:"config.fields.general.notifications.events.waiting_input.desc",togglePath:["notifications","events","waiting_input","disabled"]}},{path:["notifications","events","waiting_input","sound"],type:"string",defaultValue:"",icon:"volume_up",group:"items",collapse:{key:"notifications.events.waiting_input",labelKey:"config.fields.general.notifications.events.waiting_input.label",descKey:"config.fields.general.notifications.events.waiting_input.desc",togglePath:["notifications","events","waiting_input","disabled"]}}],conversation:[{path:["style"],type:"select",defaultValue:"friendly",icon:"forum",options:[{value:"friendly",label:"config.options.conversation.friendly"},{value:"programmatic",label:"config.options.conversation.programmatic"}]},{path:["customInstructions"],type:"multiline",defaultValue:"",icon:"description"}],modelServices:[{path:[],type:"record",recordKind:"modelServices",defaultValue:{},icon:"hub"}],channels:[{path:[],type:"record",recordKind:"channels",defaultValue:{},icon:"campaign"}],adapters:[{path:[],type:"record",recordKind:"json",defaultValue:{},icon:"settings_input_component"}],plugins:[{path:["plugins"],type:"record",recordKind:"json",defaultValue:{},icon:"extension"},{path:["enabledPlugins"],type:"record",recordKind:"boolean",defaultValue:{},group:"base",icon:"toggle_on",labelKey:"config.fields.plugins.enabled.label",descriptionKey:"config.fields.plugins.enabled.desc"},{path:["extraKnownMarketplaces"],type:"record",recordKind:"json",defaultValue:{},group:"base",icon:"storefront",labelKey:"config.fields.plugins.marketplaces.label",descriptionKey:"config.fields.plugins.marketplaces.desc"}],mcp:[{path:["defaultIncludeMcpServers"],type:"string[]",defaultValue:[],group:"base",icon:"playlist_add"},{path:["defaultExcludeMcpServers"],type:"string[]",defaultValue:[],group:"base",icon:"playlist_remove"},{path:["noDefaultVibeForgeMcpServer"],type:"boolean",defaultValue:!1,group:"base",icon:"block"},{path:["mcpServers"],type:"record",recordKind:"mcpServers",defaultValue:{},icon:"account_tree"}],shortcuts:[{path:["newSession"],type:"shortcut",defaultValue:"",icon:"add_comment"},{path:["openConfig"],type:"shortcut",defaultValue:"",icon:"settings"},{path:["sendMessage"],type:"shortcut",defaultValue:"",icon:"send"},{path:["clearInput"],type:"shortcut",defaultValue:"",icon:"clear"}]};var pn;(function(e){e.assertEqual=o=>{};function t(o){}e.assertIs=t;function n(o){throw new Error}e.assertNever=n,e.arrayToEnum=o=>{const i={};for(const a of o)i[a]=a;return i},e.getValidEnumValues=o=>{const i=e.objectKeys(o).filter(s=>typeof o[o[s]]!="number"),a={};for(const s of i)a[s]=o[s];return e.objectValues(a)},e.objectValues=o=>e.objectKeys(o).map(function(i){return o[i]}),e.objectKeys=typeof Object.keys=="function"?o=>Object.keys(o):o=>{const i=[];for(const a in o)Object.prototype.hasOwnProperty.call(o,a)&&i.push(a);return i},e.find=(o,i)=>{for(const a of o)if(i(a))return a},e.isInteger=typeof Number.isInteger=="function"?o=>Number.isInteger(o):o=>typeof o=="number"&&Number.isFinite(o)&&Math.floor(o)===o;function r(o,i=" | "){return o.map(a=>typeof a=="string"?`'${a}'`:a).join(i)}e.joinValues=r,e.jsonStringifyReplacer=(o,i)=>typeof i=="bigint"?i.toString():i})(pn||(pn={}));var GR;(function(e){e.mergeShapes=(t,n)=>({...t,...n})})(GR||(GR={}));const Et=pn.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),es=e=>{switch(typeof e){case"undefined":return Et.undefined;case"string":return Et.string;case"number":return Number.isNaN(e)?Et.nan:Et.number;case"boolean":return Et.boolean;case"function":return Et.function;case"bigint":return Et.bigint;case"symbol":return Et.symbol;case"object":return Array.isArray(e)?Et.array:e===null?Et.null:e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?Et.promise:typeof Map<"u"&&e instanceof Map?Et.map:typeof Set<"u"&&e instanceof Set?Et.set:typeof Date<"u"&&e instanceof Date?Et.date:Et.object;default:return Et.unknown}},tt=pn.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);class ja extends Error{get errors(){return this.issues}constructor(t){super(),this.issues=[],this.addIssue=r=>{this.issues=[...this.issues,r]},this.addIssues=(r=[])=>{this.issues=[...this.issues,...r]};const n=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,n):this.__proto__=n,this.name="ZodError",this.issues=t}format(t){const n=t||function(i){return i.message},r={_errors:[]},o=i=>{for(const a of i.issues)if(a.code==="invalid_union")a.unionErrors.map(o);else if(a.code==="invalid_return_type")o(a.returnTypeError);else if(a.code==="invalid_arguments")o(a.argumentsError);else if(a.path.length===0)r._errors.push(n(a));else{let s=r,l=0;for(;l<a.path.length;){const c=a.path[l];l===a.path.length-1?(s[c]=s[c]||{_errors:[]},s[c]._errors.push(n(a))):s[c]=s[c]||{_errors:[]},s=s[c],l++}}};return o(this),r}static assert(t){if(!(t instanceof ja))throw new Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,pn.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(t=n=>n.message){const n={},r=[];for(const o of this.issues)if(o.path.length>0){const i=o.path[0];n[i]=n[i]||[],n[i].push(t(o))}else r.push(t(o));return{formErrors:r,fieldErrors:n}}get formErrors(){return this.flatten()}}ja.create=e=>new ja(e);const $C=(e,t)=>{let n;switch(e.code){case tt.invalid_type:e.received===Et.undefined?n="Required":n=`Expected ${e.expected}, received ${e.received}`;break;case tt.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(e.expected,pn.jsonStringifyReplacer)}`;break;case tt.unrecognized_keys:n=`Unrecognized key(s) in object: ${pn.joinValues(e.keys,", ")}`;break;case tt.invalid_union:n="Invalid input";break;case tt.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${pn.joinValues(e.options)}`;break;case tt.invalid_enum_value:n=`Invalid enum value. Expected ${pn.joinValues(e.options)}, received '${e.received}'`;break;case tt.invalid_arguments:n="Invalid function arguments";break;case tt.invalid_return_type:n="Invalid function return type";break;case tt.invalid_date:n="Invalid date";break;case tt.invalid_string:typeof e.validation=="object"?"includes"in e.validation?(n=`Invalid input: must include "${e.validation.includes}"`,typeof e.validation.position=="number"&&(n=`${n} at one or more positions greater than or equal to ${e.validation.position}`)):"startsWith"in e.validation?n=`Invalid input: must start with "${e.validation.startsWith}"`:"endsWith"in e.validation?n=`Invalid input: must end with "${e.validation.endsWith}"`:pn.assertNever(e.validation):e.validation!=="regex"?n=`Invalid ${e.validation}`:n="Invalid";break;case tt.too_small:e.type==="array"?n=`Array must contain ${e.exact?"exactly":e.inclusive?"at least":"more than"} ${e.minimum} element(s)`:e.type==="string"?n=`String must contain ${e.exact?"exactly":e.inclusive?"at least":"over"} ${e.minimum} character(s)`:e.type==="number"?n=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:e.type==="bigint"?n=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:e.type==="date"?n=`Date must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(e.minimum))}`:n="Invalid input";break;case tt.too_big:e.type==="array"?n=`Array must contain ${e.exact?"exactly":e.inclusive?"at most":"less than"} ${e.maximum} element(s)`:e.type==="string"?n=`String must contain ${e.exact?"exactly":e.inclusive?"at most":"under"} ${e.maximum} character(s)`:e.type==="number"?n=`Number must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="bigint"?n=`BigInt must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="date"?n=`Date must be ${e.exact?"exactly":e.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(e.maximum))}`:n="Invalid input";break;case tt.custom:n="Invalid input";break;case tt.invalid_intersection_types:n="Intersection results could not be merged";break;case tt.not_multiple_of:n=`Number must be a multiple of ${e.multipleOf}`;break;case tt.not_finite:n="Number must be finite";break;default:n=t.defaultError,pn.assertNever(e)}return{message:n}};let lCe=$C;function cCe(){return lCe}const uCe=e=>{const{data:t,path:n,errorMaps:r,issueData:o}=e,i=[...n,...o.path||[]],a={...o,path:i};if(o.message!==void 0)return{...o,path:i,message:o.message};let s="";const l=r.filter(c=>!!c).slice().reverse();for(const c of l)s=c(a,{data:t,defaultError:s}).message;return{...o,path:i,message:s}};function xt(e,t){const n=cCe(),r=uCe({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,n,n===$C?void 0:$C].filter(o=>!!o)});e.common.issues.push(r)}class co{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(t,n){const r=[];for(const o of n){if(o.status==="aborted")return Wt;o.status==="dirty"&&t.dirty(),r.push(o.value)}return{status:t.value,value:r}}static async mergeObjectAsync(t,n){const r=[];for(const o of n){const i=await o.key,a=await o.value;r.push({key:i,value:a})}return co.mergeObjectSync(t,r)}static mergeObjectSync(t,n){const r={};for(const o of n){const{key:i,value:a}=o;if(i.status==="aborted"||a.status==="aborted")return Wt;i.status==="dirty"&&t.dirty(),a.status==="dirty"&&t.dirty(),i.value!=="__proto__"&&(typeof a.value<"u"||o.alwaysSet)&&(r[i.value]=a.value)}return{status:t.value,value:r}}}const Wt=Object.freeze({status:"aborted"}),fd=e=>({status:"dirty",value:e}),fi=e=>({status:"valid",value:e}),qR=e=>e.status==="aborted",XR=e=>e.status==="dirty",tu=e=>e.status==="valid",fg=e=>typeof Promise<"u"&&e instanceof Promise;var kt;(function(e){e.errToObj=t=>typeof t=="string"?{message:t}:t||{},e.toString=t=>typeof t=="string"?t:t==null?void 0:t.message})(kt||(kt={}));class na{constructor(t,n,r,o){this._cachedPath=[],this.parent=t,this.data=n,this._path=r,this._key=o}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const YR=(e,t)=>{if(tu(t))return{success:!0,data:t.value};if(!e.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const n=new ja(e.common.issues);return this._error=n,this._error}}};function Zt(e){if(!e)return{};const{errorMap:t,invalid_type_error:n,required_error:r,description:o}=e;if(t&&(n||r))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return t?{errorMap:t,description:o}:{errorMap:(a,s)=>{const{message:l}=e;return a.code==="invalid_enum_value"?{message:l??s.defaultError}:typeof s.data>"u"?{message:l??r??s.defaultError}:a.code!=="invalid_type"?{message:s.defaultError}:{message:l??n??s.defaultError}},description:o}}class ln{get description(){return this._def.description}_getType(t){return es(t.data)}_getOrReturnCtx(t,n){return n||{common:t.parent.common,data:t.data,parsedType:es(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}_processInputParams(t){return{status:new co,ctx:{common:t.parent.common,data:t.data,parsedType:es(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}}_parseSync(t){const n=this._parse(t);if(fg(n))throw new Error("Synchronous parse encountered promise.");return n}_parseAsync(t){const n=this._parse(t);return Promise.resolve(n)}parse(t,n){const r=this.safeParse(t,n);if(r.success)return r.data;throw r.error}safeParse(t,n){const r={common:{issues:[],async:(n==null?void 0:n.async)??!1,contextualErrorMap:n==null?void 0:n.errorMap},path:(n==null?void 0:n.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:es(t)},o=this._parseSync({data:t,path:r.path,parent:r});return YR(r,o)}"~validate"(t){var r,o;const n={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:es(t)};if(!this["~standard"].async)try{const i=this._parseSync({data:t,path:[],parent:n});return tu(i)?{value:i.value}:{issues:n.common.issues}}catch(i){(o=(r=i==null?void 0:i.message)==null?void 0:r.toLowerCase())!=null&&o.includes("encountered")&&(this["~standard"].async=!0),n.common={issues:[],async:!0}}return this._parseAsync({data:t,path:[],parent:n}).then(i=>tu(i)?{value:i.value}:{issues:n.common.issues})}async parseAsync(t,n){const r=await this.safeParseAsync(t,n);if(r.success)return r.data;throw r.error}async safeParseAsync(t,n){const r={common:{issues:[],contextualErrorMap:n==null?void 0:n.errorMap,async:!0},path:(n==null?void 0:n.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:es(t)},o=this._parse({data:t,path:r.path,parent:r}),i=await(fg(o)?o:Promise.resolve(o));return YR(r,i)}refine(t,n){const r=o=>typeof n=="string"||typeof n>"u"?{message:n}:typeof n=="function"?n(o):n;return this._refinement((o,i)=>{const a=t(o),s=()=>i.addIssue({code:tt.custom,...r(o)});return typeof Promise<"u"&&a instanceof Promise?a.then(l=>l?!0:(s(),!1)):a?!0:(s(),!1)})}refinement(t,n){return this._refinement((r,o)=>t(r)?!0:(o.addIssue(typeof n=="function"?n(r,o):n),!1))}_refinement(t){return new Aa({schema:this,typeName:Ht.ZodEffects,effect:{type:"refinement",refinement:t}})}superRefine(t){return this._refinement(t)}constructor(t){this.spa=this.safeParseAsync,this._def=t,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:n=>this["~validate"](n)}}optional(){return ki.create(this,this._def)}nullable(){return La.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return ri.create(this)}promise(){return bg.create(this,this._def)}or(t){return pg.create([this,t],this._def)}and(t){return hg.create(this,t,this._def)}transform(t){return new Aa({...Zt(this._def),schema:this,typeName:Ht.ZodEffects,effect:{type:"transform",transform:t}})}default(t){const n=typeof t=="function"?t:()=>t;return new nu({...Zt(this._def),innerType:this,defaultValue:n,typeName:Ht.ZodDefault})}brand(){return new TCe({typeName:Ht.ZodBranded,type:this,...Zt(this._def)})}catch(t){const n=typeof t=="function"?t:()=>t;return new NC({...Zt(this._def),innerType:this,catchValue:n,typeName:Ht.ZodCatch})}describe(t){const n=this.constructor;return new n({...this._def,description:t})}pipe(t){return V1.create(this,t)}readonly(){return OC.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const dCe=/^c[^\s-]{8,}$/i,fCe=/^[0-9a-z]+$/,mCe=/^[0-9A-HJKMNP-TV-Z]{26}$/i,pCe=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,hCe=/^[a-z0-9_-]{21}$/i,gCe=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,vCe=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,yCe=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,bCe="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let C0;const xCe=/^(?:(?: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])$/,SCe=/^(?:(?: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])\/(3[0-2]|[12]?[0-9])$/,CCe=/^(([0-9a-fA-F]{1,4}:){7,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}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,wCe=/^(([0-9a-fA-F]{1,4}:){7,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}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,_Ce=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,ECe=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,HF="((\\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])))",$Ce=new RegExp(`^${HF}$`);function VF(e){let t="[0-5]\\d";e.precision?t=`${t}\\.\\d{${e.precision}}`:e.precision==null&&(t=`${t}(\\.\\d+)?`);const n=e.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${n}`}function kCe(e){return new RegExp(`^${VF(e)}$`)}function NCe(e){let t=`${HF}T${VF(e)}`;const n=[];return n.push(e.local?"Z?":"Z"),e.offset&&n.push("([+-]\\d{2}:?\\d{2})"),t=`${t}(${n.join("|")})`,new RegExp(`^${t}$`)}function OCe(e,t){return!!((t==="v4"||!t)&&xCe.test(e)||(t==="v6"||!t)&&CCe.test(e))}function ICe(e,t){if(!gCe.test(e))return!1;try{const[n]=e.split(".");if(!n)return!1;const r=n.replace(/-/g,"+").replace(/_/g,"/").padEnd(n.length+(4-n.length%4)%4,"="),o=JSON.parse(atob(r));return!(typeof o!="object"||o===null||"typ"in o&&(o==null?void 0:o.typ)!=="JWT"||!o.alg||t&&o.alg!==t)}catch{return!1}}function RCe(e,t){return!!((t==="v4"||!t)&&SCe.test(e)||(t==="v6"||!t)&&wCe.test(e))}class ti extends ln{_parse(t){if(this._def.coerce&&(t.data=String(t.data)),this._getType(t)!==Et.string){const i=this._getOrReturnCtx(t);return xt(i,{code:tt.invalid_type,expected:Et.string,received:i.parsedType}),Wt}const r=new co;let o;for(const i of this._def.checks)if(i.kind==="min")t.data.length<i.value&&(o=this._getOrReturnCtx(t,o),xt(o,{code:tt.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),r.dirty());else if(i.kind==="max")t.data.length>i.value&&(o=this._getOrReturnCtx(t,o),xt(o,{code:tt.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),r.dirty());else if(i.kind==="length"){const a=t.data.length>i.value,s=t.data.length<i.value;(a||s)&&(o=this._getOrReturnCtx(t,o),a?xt(o,{code:tt.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}):s&&xt(o,{code:tt.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}),r.dirty())}else if(i.kind==="email")yCe.test(t.data)||(o=this._getOrReturnCtx(t,o),xt(o,{validation:"email",code:tt.invalid_string,message:i.message}),r.dirty());else if(i.kind==="emoji")C0||(C0=new RegExp(bCe,"u")),C0.test(t.data)||(o=this._getOrReturnCtx(t,o),xt(o,{validation:"emoji",code:tt.invalid_string,message:i.message}),r.dirty());else if(i.kind==="uuid")pCe.test(t.data)||(o=this._getOrReturnCtx(t,o),xt(o,{validation:"uuid",code:tt.invalid_string,message:i.message}),r.dirty());else if(i.kind==="nanoid")hCe.test(t.data)||(o=this._getOrReturnCtx(t,o),xt(o,{validation:"nanoid",code:tt.invalid_string,message:i.message}),r.dirty());else if(i.kind==="cuid")dCe.test(t.data)||(o=this._getOrReturnCtx(t,o),xt(o,{validation:"cuid",code:tt.invalid_string,message:i.message}),r.dirty());else if(i.kind==="cuid2")fCe.test(t.data)||(o=this._getOrReturnCtx(t,o),xt(o,{validation:"cuid2",code:tt.invalid_string,message:i.message}),r.dirty());else if(i.kind==="ulid")mCe.test(t.data)||(o=this._getOrReturnCtx(t,o),xt(o,{validation:"ulid",code:tt.invalid_string,message:i.message}),r.dirty());else if(i.kind==="url")try{new URL(t.data)}catch{o=this._getOrReturnCtx(t,o),xt(o,{validation:"url",code:tt.invalid_string,message:i.message}),r.dirty()}else i.kind==="regex"?(i.regex.lastIndex=0,i.regex.test(t.data)||(o=this._getOrReturnCtx(t,o),xt(o,{validation:"regex",code:tt.invalid_string,message:i.message}),r.dirty())):i.kind==="trim"?t.data=t.data.trim():i.kind==="includes"?t.data.includes(i.value,i.position)||(o=this._getOrReturnCtx(t,o),xt(o,{code:tt.invalid_string,validation:{includes:i.value,position:i.position},message:i.message}),r.dirty()):i.kind==="toLowerCase"?t.data=t.data.toLowerCase():i.kind==="toUpperCase"?t.data=t.data.toUpperCase():i.kind==="startsWith"?t.data.startsWith(i.value)||(o=this._getOrReturnCtx(t,o),xt(o,{code:tt.invalid_string,validation:{startsWith:i.value},message:i.message}),r.dirty()):i.kind==="endsWith"?t.data.endsWith(i.value)||(o=this._getOrReturnCtx(t,o),xt(o,{code:tt.invalid_string,validation:{endsWith:i.value},message:i.message}),r.dirty()):i.kind==="datetime"?NCe(i).test(t.data)||(o=this._getOrReturnCtx(t,o),xt(o,{code:tt.invalid_string,validation:"datetime",message:i.message}),r.dirty()):i.kind==="date"?$Ce.test(t.data)||(o=this._getOrReturnCtx(t,o),xt(o,{code:tt.invalid_string,validation:"date",message:i.message}),r.dirty()):i.kind==="time"?kCe(i).test(t.data)||(o=this._getOrReturnCtx(t,o),xt(o,{code:tt.invalid_string,validation:"time",message:i.message}),r.dirty()):i.kind==="duration"?vCe.test(t.data)||(o=this._getOrReturnCtx(t,o),xt(o,{validation:"duration",code:tt.invalid_string,message:i.message}),r.dirty()):i.kind==="ip"?OCe(t.data,i.version)||(o=this._getOrReturnCtx(t,o),xt(o,{validation:"ip",code:tt.invalid_string,message:i.message}),r.dirty()):i.kind==="jwt"?ICe(t.data,i.alg)||(o=this._getOrReturnCtx(t,o),xt(o,{validation:"jwt",code:tt.invalid_string,message:i.message}),r.dirty()):i.kind==="cidr"?RCe(t.data,i.version)||(o=this._getOrReturnCtx(t,o),xt(o,{validation:"cidr",code:tt.invalid_string,message:i.message}),r.dirty()):i.kind==="base64"?_Ce.test(t.data)||(o=this._getOrReturnCtx(t,o),xt(o,{validation:"base64",code:tt.invalid_string,message:i.message}),r.dirty()):i.kind==="base64url"?ECe.test(t.data)||(o=this._getOrReturnCtx(t,o),xt(o,{validation:"base64url",code:tt.invalid_string,message:i.message}),r.dirty()):pn.assertNever(i);return{status:r.value,value:t.data}}_regex(t,n,r){return this.refinement(o=>t.test(o),{validation:n,code:tt.invalid_string,...kt.errToObj(r)})}_addCheck(t){return new ti({...this._def,checks:[...this._def.checks,t]})}email(t){return this._addCheck({kind:"email",...kt.errToObj(t)})}url(t){return this._addCheck({kind:"url",...kt.errToObj(t)})}emoji(t){return this._addCheck({kind:"emoji",...kt.errToObj(t)})}uuid(t){return this._addCheck({kind:"uuid",...kt.errToObj(t)})}nanoid(t){return this._addCheck({kind:"nanoid",...kt.errToObj(t)})}cuid(t){return this._addCheck({kind:"cuid",...kt.errToObj(t)})}cuid2(t){return this._addCheck({kind:"cuid2",...kt.errToObj(t)})}ulid(t){return this._addCheck({kind:"ulid",...kt.errToObj(t)})}base64(t){return this._addCheck({kind:"base64",...kt.errToObj(t)})}base64url(t){return this._addCheck({kind:"base64url",...kt.errToObj(t)})}jwt(t){return this._addCheck({kind:"jwt",...kt.errToObj(t)})}ip(t){return this._addCheck({kind:"ip",...kt.errToObj(t)})}cidr(t){return this._addCheck({kind:"cidr",...kt.errToObj(t)})}datetime(t){return typeof t=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:t}):this._addCheck({kind:"datetime",precision:typeof(t==null?void 0:t.precision)>"u"?null:t==null?void 0:t.precision,offset:(t==null?void 0:t.offset)??!1,local:(t==null?void 0:t.local)??!1,...kt.errToObj(t==null?void 0:t.message)})}date(t){return this._addCheck({kind:"date",message:t})}time(t){return typeof t=="string"?this._addCheck({kind:"time",precision:null,message:t}):this._addCheck({kind:"time",precision:typeof(t==null?void 0:t.precision)>"u"?null:t==null?void 0:t.precision,...kt.errToObj(t==null?void 0:t.message)})}duration(t){return this._addCheck({kind:"duration",...kt.errToObj(t)})}regex(t,n){return this._addCheck({kind:"regex",regex:t,...kt.errToObj(n)})}includes(t,n){return this._addCheck({kind:"includes",value:t,position:n==null?void 0:n.position,...kt.errToObj(n==null?void 0:n.message)})}startsWith(t,n){return this._addCheck({kind:"startsWith",value:t,...kt.errToObj(n)})}endsWith(t,n){return this._addCheck({kind:"endsWith",value:t,...kt.errToObj(n)})}min(t,n){return this._addCheck({kind:"min",value:t,...kt.errToObj(n)})}max(t,n){return this._addCheck({kind:"max",value:t,...kt.errToObj(n)})}length(t,n){return this._addCheck({kind:"length",value:t,...kt.errToObj(n)})}nonempty(t){return this.min(1,kt.errToObj(t))}trim(){return new ti({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new ti({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new ti({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(t=>t.kind==="datetime")}get isDate(){return!!this._def.checks.find(t=>t.kind==="date")}get isTime(){return!!this._def.checks.find(t=>t.kind==="time")}get isDuration(){return!!this._def.checks.find(t=>t.kind==="duration")}get isEmail(){return!!this._def.checks.find(t=>t.kind==="email")}get isURL(){return!!this._def.checks.find(t=>t.kind==="url")}get isEmoji(){return!!this._def.checks.find(t=>t.kind==="emoji")}get isUUID(){return!!this._def.checks.find(t=>t.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(t=>t.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(t=>t.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(t=>t.kind==="cuid2")}get isULID(){return!!this._def.checks.find(t=>t.kind==="ulid")}get isIP(){return!!this._def.checks.find(t=>t.kind==="ip")}get isCIDR(){return!!this._def.checks.find(t=>t.kind==="cidr")}get isBase64(){return!!this._def.checks.find(t=>t.kind==="base64")}get isBase64url(){return!!this._def.checks.find(t=>t.kind==="base64url")}get minLength(){let t=null;for(const n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t}get maxLength(){let t=null;for(const n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t}}ti.create=e=>new ti({checks:[],typeName:Ht.ZodString,coerce:(e==null?void 0:e.coerce)??!1,...Zt(e)});function PCe(e,t){const n=(e.toString().split(".")[1]||"").length,r=(t.toString().split(".")[1]||"").length,o=n>r?n:r,i=Number.parseInt(e.toFixed(o).replace(".","")),a=Number.parseInt(t.toFixed(o).replace(".",""));return i%a/10**o}class bl extends ln{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(t){if(this._def.coerce&&(t.data=Number(t.data)),this._getType(t)!==Et.number){const i=this._getOrReturnCtx(t);return xt(i,{code:tt.invalid_type,expected:Et.number,received:i.parsedType}),Wt}let r;const o=new co;for(const i of this._def.checks)i.kind==="int"?pn.isInteger(t.data)||(r=this._getOrReturnCtx(t,r),xt(r,{code:tt.invalid_type,expected:"integer",received:"float",message:i.message}),o.dirty()):i.kind==="min"?(i.inclusive?t.data<i.value:t.data<=i.value)&&(r=this._getOrReturnCtx(t,r),xt(r,{code:tt.too_small,minimum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),o.dirty()):i.kind==="max"?(i.inclusive?t.data>i.value:t.data>=i.value)&&(r=this._getOrReturnCtx(t,r),xt(r,{code:tt.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),o.dirty()):i.kind==="multipleOf"?PCe(t.data,i.value)!==0&&(r=this._getOrReturnCtx(t,r),xt(r,{code:tt.not_multiple_of,multipleOf:i.value,message:i.message}),o.dirty()):i.kind==="finite"?Number.isFinite(t.data)||(r=this._getOrReturnCtx(t,r),xt(r,{code:tt.not_finite,message:i.message}),o.dirty()):pn.assertNever(i);return{status:o.value,value:t.data}}gte(t,n){return this.setLimit("min",t,!0,kt.toString(n))}gt(t,n){return this.setLimit("min",t,!1,kt.toString(n))}lte(t,n){return this.setLimit("max",t,!0,kt.toString(n))}lt(t,n){return this.setLimit("max",t,!1,kt.toString(n))}setLimit(t,n,r,o){return new bl({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:kt.toString(o)}]})}_addCheck(t){return new bl({...this._def,checks:[...this._def.checks,t]})}int(t){return this._addCheck({kind:"int",message:kt.toString(t)})}positive(t){return this._addCheck({kind:"min",value:0,inclusive:!1,message:kt.toString(t)})}negative(t){return this._addCheck({kind:"max",value:0,inclusive:!1,message:kt.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:0,inclusive:!0,message:kt.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:0,inclusive:!0,message:kt.toString(t)})}multipleOf(t,n){return this._addCheck({kind:"multipleOf",value:t,message:kt.toString(n)})}finite(t){return this._addCheck({kind:"finite",message:kt.toString(t)})}safe(t){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:kt.toString(t)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:kt.toString(t)})}get minValue(){let t=null;for(const n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t}get maxValue(){let t=null;for(const n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t}get isInt(){return!!this._def.checks.find(t=>t.kind==="int"||t.kind==="multipleOf"&&pn.isInteger(t.value))}get isFinite(){let t=null,n=null;for(const r of this._def.checks){if(r.kind==="finite"||r.kind==="int"||r.kind==="multipleOf")return!0;r.kind==="min"?(n===null||r.value>n)&&(n=r.value):r.kind==="max"&&(t===null||r.value<t)&&(t=r.value)}return Number.isFinite(n)&&Number.isFinite(t)}}bl.create=e=>new bl({checks:[],typeName:Ht.ZodNumber,coerce:(e==null?void 0:e.coerce)||!1,...Zt(e)});class kf extends ln{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(t){if(this._def.coerce)try{t.data=BigInt(t.data)}catch{return this._getInvalidInput(t)}if(this._getType(t)!==Et.bigint)return this._getInvalidInput(t);let r;const o=new co;for(const i of this._def.checks)i.kind==="min"?(i.inclusive?t.data<i.value:t.data<=i.value)&&(r=this._getOrReturnCtx(t,r),xt(r,{code:tt.too_small,type:"bigint",minimum:i.value,inclusive:i.inclusive,message:i.message}),o.dirty()):i.kind==="max"?(i.inclusive?t.data>i.value:t.data>=i.value)&&(r=this._getOrReturnCtx(t,r),xt(r,{code:tt.too_big,type:"bigint",maximum:i.value,inclusive:i.inclusive,message:i.message}),o.dirty()):i.kind==="multipleOf"?t.data%i.value!==BigInt(0)&&(r=this._getOrReturnCtx(t,r),xt(r,{code:tt.not_multiple_of,multipleOf:i.value,message:i.message}),o.dirty()):pn.assertNever(i);return{status:o.value,value:t.data}}_getInvalidInput(t){const n=this._getOrReturnCtx(t);return xt(n,{code:tt.invalid_type,expected:Et.bigint,received:n.parsedType}),Wt}gte(t,n){return this.setLimit("min",t,!0,kt.toString(n))}gt(t,n){return this.setLimit("min",t,!1,kt.toString(n))}lte(t,n){return this.setLimit("max",t,!0,kt.toString(n))}lt(t,n){return this.setLimit("max",t,!1,kt.toString(n))}setLimit(t,n,r,o){return new kf({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:kt.toString(o)}]})}_addCheck(t){return new kf({...this._def,checks:[...this._def.checks,t]})}positive(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:kt.toString(t)})}negative(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:kt.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:kt.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:kt.toString(t)})}multipleOf(t,n){return this._addCheck({kind:"multipleOf",value:t,message:kt.toString(n)})}get minValue(){let t=null;for(const n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t}get maxValue(){let t=null;for(const n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t}}kf.create=e=>new kf({checks:[],typeName:Ht.ZodBigInt,coerce:(e==null?void 0:e.coerce)??!1,...Zt(e)});class Nf extends ln{_parse(t){if(this._def.coerce&&(t.data=!!t.data),this._getType(t)!==Et.boolean){const r=this._getOrReturnCtx(t);return xt(r,{code:tt.invalid_type,expected:Et.boolean,received:r.parsedType}),Wt}return fi(t.data)}}Nf.create=e=>new Nf({typeName:Ht.ZodBoolean,coerce:(e==null?void 0:e.coerce)||!1,...Zt(e)});class mg extends ln{_parse(t){if(this._def.coerce&&(t.data=new Date(t.data)),this._getType(t)!==Et.date){const i=this._getOrReturnCtx(t);return xt(i,{code:tt.invalid_type,expected:Et.date,received:i.parsedType}),Wt}if(Number.isNaN(t.data.getTime())){const i=this._getOrReturnCtx(t);return xt(i,{code:tt.invalid_date}),Wt}const r=new co;let o;for(const i of this._def.checks)i.kind==="min"?t.data.getTime()<i.value&&(o=this._getOrReturnCtx(t,o),xt(o,{code:tt.too_small,message:i.message,inclusive:!0,exact:!1,minimum:i.value,type:"date"}),r.dirty()):i.kind==="max"?t.data.getTime()>i.value&&(o=this._getOrReturnCtx(t,o),xt(o,{code:tt.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),r.dirty()):pn.assertNever(i);return{status:r.value,value:new Date(t.data.getTime())}}_addCheck(t){return new mg({...this._def,checks:[...this._def.checks,t]})}min(t,n){return this._addCheck({kind:"min",value:t.getTime(),message:kt.toString(n)})}max(t,n){return this._addCheck({kind:"max",value:t.getTime(),message:kt.toString(n)})}get minDate(){let t=null;for(const n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t!=null?new Date(t):null}get maxDate(){let t=null;for(const n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t!=null?new Date(t):null}}mg.create=e=>new mg({checks:[],coerce:(e==null?void 0:e.coerce)||!1,typeName:Ht.ZodDate,...Zt(e)});class QR extends ln{_parse(t){if(this._getType(t)!==Et.symbol){const r=this._getOrReturnCtx(t);return xt(r,{code:tt.invalid_type,expected:Et.symbol,received:r.parsedType}),Wt}return fi(t.data)}}QR.create=e=>new QR({typeName:Ht.ZodSymbol,...Zt(e)});class ZR extends ln{_parse(t){if(this._getType(t)!==Et.undefined){const r=this._getOrReturnCtx(t);return xt(r,{code:tt.invalid_type,expected:Et.undefined,received:r.parsedType}),Wt}return fi(t.data)}}ZR.create=e=>new ZR({typeName:Ht.ZodUndefined,...Zt(e)});class JR extends ln{_parse(t){if(this._getType(t)!==Et.null){const r=this._getOrReturnCtx(t);return xt(r,{code:tt.invalid_type,expected:Et.null,received:r.parsedType}),Wt}return fi(t.data)}}JR.create=e=>new JR({typeName:Ht.ZodNull,...Zt(e)});class eP extends ln{constructor(){super(...arguments),this._any=!0}_parse(t){return fi(t.data)}}eP.create=e=>new eP({typeName:Ht.ZodAny,...Zt(e)});class tP extends ln{constructor(){super(...arguments),this._unknown=!0}_parse(t){return fi(t.data)}}tP.create=e=>new tP({typeName:Ht.ZodUnknown,...Zt(e)});class $s extends ln{_parse(t){const n=this._getOrReturnCtx(t);return xt(n,{code:tt.invalid_type,expected:Et.never,received:n.parsedType}),Wt}}$s.create=e=>new $s({typeName:Ht.ZodNever,...Zt(e)});class nP extends ln{_parse(t){if(this._getType(t)!==Et.undefined){const r=this._getOrReturnCtx(t);return xt(r,{code:tt.invalid_type,expected:Et.void,received:r.parsedType}),Wt}return fi(t.data)}}nP.create=e=>new nP({typeName:Ht.ZodVoid,...Zt(e)});class ri extends ln{_parse(t){const{ctx:n,status:r}=this._processInputParams(t),o=this._def;if(n.parsedType!==Et.array)return xt(n,{code:tt.invalid_type,expected:Et.array,received:n.parsedType}),Wt;if(o.exactLength!==null){const a=n.data.length>o.exactLength.value,s=n.data.length<o.exactLength.value;(a||s)&&(xt(n,{code:a?tt.too_big:tt.too_small,minimum:s?o.exactLength.value:void 0,maximum:a?o.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:o.exactLength.message}),r.dirty())}if(o.minLength!==null&&n.data.length<o.minLength.value&&(xt(n,{code:tt.too_small,minimum:o.minLength.value,type:"array",inclusive:!0,exact:!1,message:o.minLength.message}),r.dirty()),o.maxLength!==null&&n.data.length>o.maxLength.value&&(xt(n,{code:tt.too_big,maximum:o.maxLength.value,type:"array",inclusive:!0,exact:!1,message:o.maxLength.message}),r.dirty()),n.common.async)return Promise.all([...n.data].map((a,s)=>o.type._parseAsync(new na(n,a,n.path,s)))).then(a=>co.mergeArray(r,a));const i=[...n.data].map((a,s)=>o.type._parseSync(new na(n,a,n.path,s)));return co.mergeArray(r,i)}get element(){return this._def.type}min(t,n){return new ri({...this._def,minLength:{value:t,message:kt.toString(n)}})}max(t,n){return new ri({...this._def,maxLength:{value:t,message:kt.toString(n)}})}length(t,n){return new ri({...this._def,exactLength:{value:t,message:kt.toString(n)}})}nonempty(t){return this.min(1,t)}}ri.create=(e,t)=>new ri({type:e,minLength:null,maxLength:null,exactLength:null,typeName:Ht.ZodArray,...Zt(t)});function Xl(e){if(e instanceof qn){const t={};for(const n in e.shape){const r=e.shape[n];t[n]=ki.create(Xl(r))}return new qn({...e._def,shape:()=>t})}else return e instanceof ri?new ri({...e._def,type:Xl(e.element)}):e instanceof ki?ki.create(Xl(e.unwrap())):e instanceof La?La.create(Xl(e.unwrap())):e instanceof xl?xl.create(e.items.map(t=>Xl(t))):e}class qn extends ln{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const t=this._def.shape(),n=pn.objectKeys(t);return this._cached={shape:t,keys:n},this._cached}_parse(t){if(this._getType(t)!==Et.object){const c=this._getOrReturnCtx(t);return xt(c,{code:tt.invalid_type,expected:Et.object,received:c.parsedType}),Wt}const{status:r,ctx:o}=this._processInputParams(t),{shape:i,keys:a}=this._getCached(),s=[];if(!(this._def.catchall instanceof $s&&this._def.unknownKeys==="strip"))for(const c in o.data)a.includes(c)||s.push(c);const l=[];for(const c of a){const d=i[c],f=o.data[c];l.push({key:{status:"valid",value:c},value:d._parse(new na(o,f,o.path,c)),alwaysSet:c in o.data})}if(this._def.catchall instanceof $s){const c=this._def.unknownKeys;if(c==="passthrough")for(const d of s)l.push({key:{status:"valid",value:d},value:{status:"valid",value:o.data[d]}});else if(c==="strict")s.length>0&&(xt(o,{code:tt.unrecognized_keys,keys:s}),r.dirty());else if(c!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const c=this._def.catchall;for(const d of s){const f=o.data[d];l.push({key:{status:"valid",value:d},value:c._parse(new na(o,f,o.path,d)),alwaysSet:d in o.data})}}return o.common.async?Promise.resolve().then(async()=>{const c=[];for(const d of l){const f=await d.key,m=await d.value;c.push({key:f,value:m,alwaysSet:d.alwaysSet})}return c}).then(c=>co.mergeObjectSync(r,c)):co.mergeObjectSync(r,l)}get shape(){return this._def.shape()}strict(t){return kt.errToObj,new qn({...this._def,unknownKeys:"strict",...t!==void 0?{errorMap:(n,r)=>{var i,a;const o=((a=(i=this._def).errorMap)==null?void 0:a.call(i,n,r).message)??r.defaultError;return n.code==="unrecognized_keys"?{message:kt.errToObj(t).message??o}:{message:o}}}:{}})}strip(){return new qn({...this._def,unknownKeys:"strip"})}passthrough(){return new qn({...this._def,unknownKeys:"passthrough"})}extend(t){return new qn({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){return new qn({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>({...this._def.shape(),...t._def.shape()}),typeName:Ht.ZodObject})}setKey(t,n){return this.augment({[t]:n})}catchall(t){return new qn({...this._def,catchall:t})}pick(t){const n={};for(const r of pn.objectKeys(t))t[r]&&this.shape[r]&&(n[r]=this.shape[r]);return new qn({...this._def,shape:()=>n})}omit(t){const n={};for(const r of pn.objectKeys(this.shape))t[r]||(n[r]=this.shape[r]);return new qn({...this._def,shape:()=>n})}deepPartial(){return Xl(this)}partial(t){const n={};for(const r of pn.objectKeys(this.shape)){const o=this.shape[r];t&&!t[r]?n[r]=o:n[r]=o.optional()}return new qn({...this._def,shape:()=>n})}required(t){const n={};for(const r of pn.objectKeys(this.shape))if(t&&!t[r])n[r]=this.shape[r];else{let i=this.shape[r];for(;i instanceof ki;)i=i._def.innerType;n[r]=i}return new qn({...this._def,shape:()=>n})}keyof(){return WF(pn.objectKeys(this.shape))}}qn.create=(e,t)=>new qn({shape:()=>e,unknownKeys:"strip",catchall:$s.create(),typeName:Ht.ZodObject,...Zt(t)});qn.strictCreate=(e,t)=>new qn({shape:()=>e,unknownKeys:"strict",catchall:$s.create(),typeName:Ht.ZodObject,...Zt(t)});qn.lazycreate=(e,t)=>new qn({shape:e,unknownKeys:"strip",catchall:$s.create(),typeName:Ht.ZodObject,...Zt(t)});class pg extends ln{_parse(t){const{ctx:n}=this._processInputParams(t),r=this._def.options;function o(i){for(const s of i)if(s.result.status==="valid")return s.result;for(const s of i)if(s.result.status==="dirty")return n.common.issues.push(...s.ctx.common.issues),s.result;const a=i.map(s=>new ja(s.ctx.common.issues));return xt(n,{code:tt.invalid_union,unionErrors:a}),Wt}if(n.common.async)return Promise.all(r.map(async i=>{const a={...n,common:{...n.common,issues:[]},parent:null};return{result:await i._parseAsync({data:n.data,path:n.path,parent:a}),ctx:a}})).then(o);{let i;const a=[];for(const l of r){const c={...n,common:{...n.common,issues:[]},parent:null},d=l._parseSync({data:n.data,path:n.path,parent:c});if(d.status==="valid")return d;d.status==="dirty"&&!i&&(i={result:d,ctx:c}),c.common.issues.length&&a.push(c.common.issues)}if(i)return n.common.issues.push(...i.ctx.common.issues),i.result;const s=a.map(l=>new ja(l));return xt(n,{code:tt.invalid_union,unionErrors:s}),Wt}}get options(){return this._def.options}}pg.create=(e,t)=>new pg({options:e,typeName:Ht.ZodUnion,...Zt(t)});function kC(e,t){const n=es(e),r=es(t);if(e===t)return{valid:!0,data:e};if(n===Et.object&&r===Et.object){const o=pn.objectKeys(t),i=pn.objectKeys(e).filter(s=>o.indexOf(s)!==-1),a={...e,...t};for(const s of i){const l=kC(e[s],t[s]);if(!l.valid)return{valid:!1};a[s]=l.data}return{valid:!0,data:a}}else if(n===Et.array&&r===Et.array){if(e.length!==t.length)return{valid:!1};const o=[];for(let i=0;i<e.length;i++){const a=e[i],s=t[i],l=kC(a,s);if(!l.valid)return{valid:!1};o.push(l.data)}return{valid:!0,data:o}}else return n===Et.date&&r===Et.date&&+e==+t?{valid:!0,data:e}:{valid:!1}}class hg extends ln{_parse(t){const{status:n,ctx:r}=this._processInputParams(t),o=(i,a)=>{if(qR(i)||qR(a))return Wt;const s=kC(i.value,a.value);return s.valid?((XR(i)||XR(a))&&n.dirty(),{status:n.value,value:s.data}):(xt(r,{code:tt.invalid_intersection_types}),Wt)};return r.common.async?Promise.all([this._def.left._parseAsync({data:r.data,path:r.path,parent:r}),this._def.right._parseAsync({data:r.data,path:r.path,parent:r})]).then(([i,a])=>o(i,a)):o(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}}hg.create=(e,t,n)=>new hg({left:e,right:t,typeName:Ht.ZodIntersection,...Zt(n)});class xl extends ln{_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.parsedType!==Et.array)return xt(r,{code:tt.invalid_type,expected:Et.array,received:r.parsedType}),Wt;if(r.data.length<this._def.items.length)return xt(r,{code:tt.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),Wt;!this._def.rest&&r.data.length>this._def.items.length&&(xt(r,{code:tt.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),n.dirty());const i=[...r.data].map((a,s)=>{const l=this._def.items[s]||this._def.rest;return l?l._parse(new na(r,a,r.path,s)):null}).filter(a=>!!a);return r.common.async?Promise.all(i).then(a=>co.mergeArray(n,a)):co.mergeArray(n,i)}get items(){return this._def.items}rest(t){return new xl({...this._def,rest:t})}}xl.create=(e,t)=>{if(!Array.isArray(e))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new xl({items:e,typeName:Ht.ZodTuple,rest:null,...Zt(t)})};class gg extends ln{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.parsedType!==Et.object)return xt(r,{code:tt.invalid_type,expected:Et.object,received:r.parsedType}),Wt;const o=[],i=this._def.keyType,a=this._def.valueType;for(const s in r.data)o.push({key:i._parse(new na(r,s,r.path,s)),value:a._parse(new na(r,r.data[s],r.path,s)),alwaysSet:s in r.data});return r.common.async?co.mergeObjectAsync(n,o):co.mergeObjectSync(n,o)}get element(){return this._def.valueType}static create(t,n,r){return n instanceof ln?new gg({keyType:t,valueType:n,typeName:Ht.ZodRecord,...Zt(r)}):new gg({keyType:ti.create(),valueType:t,typeName:Ht.ZodRecord,...Zt(n)})}}class rP extends ln{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.parsedType!==Et.map)return xt(r,{code:tt.invalid_type,expected:Et.map,received:r.parsedType}),Wt;const o=this._def.keyType,i=this._def.valueType,a=[...r.data.entries()].map(([s,l],c)=>({key:o._parse(new na(r,s,r.path,[c,"key"])),value:i._parse(new na(r,l,r.path,[c,"value"]))}));if(r.common.async){const s=new Map;return Promise.resolve().then(async()=>{for(const l of a){const c=await l.key,d=await l.value;if(c.status==="aborted"||d.status==="aborted")return Wt;(c.status==="dirty"||d.status==="dirty")&&n.dirty(),s.set(c.value,d.value)}return{status:n.value,value:s}})}else{const s=new Map;for(const l of a){const c=l.key,d=l.value;if(c.status==="aborted"||d.status==="aborted")return Wt;(c.status==="dirty"||d.status==="dirty")&&n.dirty(),s.set(c.value,d.value)}return{status:n.value,value:s}}}}rP.create=(e,t,n)=>new rP({valueType:t,keyType:e,typeName:Ht.ZodMap,...Zt(n)});class Of extends ln{_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.parsedType!==Et.set)return xt(r,{code:tt.invalid_type,expected:Et.set,received:r.parsedType}),Wt;const o=this._def;o.minSize!==null&&r.data.size<o.minSize.value&&(xt(r,{code:tt.too_small,minimum:o.minSize.value,type:"set",inclusive:!0,exact:!1,message:o.minSize.message}),n.dirty()),o.maxSize!==null&&r.data.size>o.maxSize.value&&(xt(r,{code:tt.too_big,maximum:o.maxSize.value,type:"set",inclusive:!0,exact:!1,message:o.maxSize.message}),n.dirty());const i=this._def.valueType;function a(l){const c=new Set;for(const d of l){if(d.status==="aborted")return Wt;d.status==="dirty"&&n.dirty(),c.add(d.value)}return{status:n.value,value:c}}const s=[...r.data.values()].map((l,c)=>i._parse(new na(r,l,r.path,c)));return r.common.async?Promise.all(s).then(l=>a(l)):a(s)}min(t,n){return new Of({...this._def,minSize:{value:t,message:kt.toString(n)}})}max(t,n){return new Of({...this._def,maxSize:{value:t,message:kt.toString(n)}})}size(t,n){return this.min(t,n).max(t,n)}nonempty(t){return this.min(1,t)}}Of.create=(e,t)=>new Of({valueType:e,minSize:null,maxSize:null,typeName:Ht.ZodSet,...Zt(t)});class oP extends ln{get schema(){return this._def.getter()}_parse(t){const{ctx:n}=this._processInputParams(t);return this._def.getter()._parse({data:n.data,path:n.path,parent:n})}}oP.create=(e,t)=>new oP({getter:e,typeName:Ht.ZodLazy,...Zt(t)});class vg extends ln{_parse(t){if(t.data!==this._def.value){const n=this._getOrReturnCtx(t);return xt(n,{received:n.data,code:tt.invalid_literal,expected:this._def.value}),Wt}return{status:"valid",value:t.data}}get value(){return this._def.value}}vg.create=(e,t)=>new vg({value:e,typeName:Ht.ZodLiteral,...Zt(t)});function WF(e,t){return new Ma({values:e,typeName:Ht.ZodEnum,...Zt(t)})}class Ma extends ln{_parse(t){if(typeof t.data!="string"){const n=this._getOrReturnCtx(t),r=this._def.values;return xt(n,{expected:pn.joinValues(r),received:n.parsedType,code:tt.invalid_type}),Wt}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(t.data)){const n=this._getOrReturnCtx(t),r=this._def.values;return xt(n,{received:n.data,code:tt.invalid_enum_value,options:r}),Wt}return fi(t.data)}get options(){return this._def.values}get enum(){const t={};for(const n of this._def.values)t[n]=n;return t}get Values(){const t={};for(const n of this._def.values)t[n]=n;return t}get Enum(){const t={};for(const n of this._def.values)t[n]=n;return t}extract(t,n=this._def){return Ma.create(t,{...this._def,...n})}exclude(t,n=this._def){return Ma.create(this.options.filter(r=>!t.includes(r)),{...this._def,...n})}}Ma.create=WF;class yg extends ln{_parse(t){const n=pn.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(t);if(r.parsedType!==Et.string&&r.parsedType!==Et.number){const o=pn.objectValues(n);return xt(r,{expected:pn.joinValues(o),received:r.parsedType,code:tt.invalid_type}),Wt}if(this._cache||(this._cache=new Set(pn.getValidEnumValues(this._def.values))),!this._cache.has(t.data)){const o=pn.objectValues(n);return xt(r,{received:r.data,code:tt.invalid_enum_value,options:o}),Wt}return fi(t.data)}get enum(){return this._def.values}}yg.create=(e,t)=>new yg({values:e,typeName:Ht.ZodNativeEnum,...Zt(t)});class bg extends ln{unwrap(){return this._def.type}_parse(t){const{ctx:n}=this._processInputParams(t);if(n.parsedType!==Et.promise&&n.common.async===!1)return xt(n,{code:tt.invalid_type,expected:Et.promise,received:n.parsedType}),Wt;const r=n.parsedType===Et.promise?n.data:Promise.resolve(n.data);return fi(r.then(o=>this._def.type.parseAsync(o,{path:n.path,errorMap:n.common.contextualErrorMap})))}}bg.create=(e,t)=>new bg({type:e,typeName:Ht.ZodPromise,...Zt(t)});class Aa extends ln{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===Ht.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(t){const{status:n,ctx:r}=this._processInputParams(t),o=this._def.effect||null,i={addIssue:a=>{xt(r,a),a.fatal?n.abort():n.dirty()},get path(){return r.path}};if(i.addIssue=i.addIssue.bind(i),o.type==="preprocess"){const a=o.transform(r.data,i);if(r.common.async)return Promise.resolve(a).then(async s=>{if(n.value==="aborted")return Wt;const l=await this._def.schema._parseAsync({data:s,path:r.path,parent:r});return l.status==="aborted"?Wt:l.status==="dirty"||n.value==="dirty"?fd(l.value):l});{if(n.value==="aborted")return Wt;const s=this._def.schema._parseSync({data:a,path:r.path,parent:r});return s.status==="aborted"?Wt:s.status==="dirty"||n.value==="dirty"?fd(s.value):s}}if(o.type==="refinement"){const a=s=>{const l=o.refinement(s,i);if(r.common.async)return Promise.resolve(l);if(l instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return s};if(r.common.async===!1){const s=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return s.status==="aborted"?Wt:(s.status==="dirty"&&n.dirty(),a(s.value),{status:n.value,value:s.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(s=>s.status==="aborted"?Wt:(s.status==="dirty"&&n.dirty(),a(s.value).then(()=>({status:n.value,value:s.value}))))}if(o.type==="transform")if(r.common.async===!1){const a=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!tu(a))return Wt;const s=o.transform(a.value,i);if(s instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:n.value,value:s}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(a=>tu(a)?Promise.resolve(o.transform(a.value,i)).then(s=>({status:n.value,value:s})):Wt);pn.assertNever(o)}}Aa.create=(e,t,n)=>new Aa({schema:e,typeName:Ht.ZodEffects,effect:t,...Zt(n)});Aa.createWithPreprocess=(e,t,n)=>new Aa({schema:t,effect:{type:"preprocess",transform:e},typeName:Ht.ZodEffects,...Zt(n)});class ki extends ln{_parse(t){return this._getType(t)===Et.undefined?fi(void 0):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}}ki.create=(e,t)=>new ki({innerType:e,typeName:Ht.ZodOptional,...Zt(t)});class La extends ln{_parse(t){return this._getType(t)===Et.null?fi(null):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}}La.create=(e,t)=>new La({innerType:e,typeName:Ht.ZodNullable,...Zt(t)});class nu extends ln{_parse(t){const{ctx:n}=this._processInputParams(t);let r=n.data;return n.parsedType===Et.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:n.path,parent:n})}removeDefault(){return this._def.innerType}}nu.create=(e,t)=>new nu({innerType:e,typeName:Ht.ZodDefault,defaultValue:typeof t.default=="function"?t.default:()=>t.default,...Zt(t)});class NC extends ln{_parse(t){const{ctx:n}=this._processInputParams(t),r={...n,common:{...n.common,issues:[]}},o=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return fg(o)?o.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new ja(r.common.issues)},input:r.data})})):{status:"valid",value:o.status==="valid"?o.value:this._def.catchValue({get error(){return new ja(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}}NC.create=(e,t)=>new NC({innerType:e,typeName:Ht.ZodCatch,catchValue:typeof t.catch=="function"?t.catch:()=>t.catch,...Zt(t)});class iP extends ln{_parse(t){if(this._getType(t)!==Et.nan){const r=this._getOrReturnCtx(t);return xt(r,{code:tt.invalid_type,expected:Et.nan,received:r.parsedType}),Wt}return{status:"valid",value:t.data}}}iP.create=e=>new iP({typeName:Ht.ZodNaN,...Zt(e)});class TCe extends ln{_parse(t){const{ctx:n}=this._processInputParams(t),r=n.data;return this._def.type._parse({data:r,path:n.path,parent:n})}unwrap(){return this._def.type}}class V1 extends ln{_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.common.async)return(async()=>{const i=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return i.status==="aborted"?Wt:i.status==="dirty"?(n.dirty(),fd(i.value)):this._def.out._parseAsync({data:i.value,path:r.path,parent:r})})();{const o=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return o.status==="aborted"?Wt:o.status==="dirty"?(n.dirty(),{status:"dirty",value:o.value}):this._def.out._parseSync({data:o.value,path:r.path,parent:r})}}static create(t,n){return new V1({in:t,out:n,typeName:Ht.ZodPipeline})}}class OC extends ln{_parse(t){const n=this._def.innerType._parse(t),r=o=>(tu(o)&&(o.value=Object.freeze(o.value)),o);return fg(n)?n.then(o=>r(o)):r(n)}unwrap(){return this._def.innerType}}OC.create=(e,t)=>new OC({innerType:e,typeName:Ht.ZodReadonly,...Zt(t)});var Ht;(function(e){e.ZodString="ZodString",e.ZodNumber="ZodNumber",e.ZodNaN="ZodNaN",e.ZodBigInt="ZodBigInt",e.ZodBoolean="ZodBoolean",e.ZodDate="ZodDate",e.ZodSymbol="ZodSymbol",e.ZodUndefined="ZodUndefined",e.ZodNull="ZodNull",e.ZodAny="ZodAny",e.ZodUnknown="ZodUnknown",e.ZodNever="ZodNever",e.ZodVoid="ZodVoid",e.ZodArray="ZodArray",e.ZodObject="ZodObject",e.ZodUnion="ZodUnion",e.ZodDiscriminatedUnion="ZodDiscriminatedUnion",e.ZodIntersection="ZodIntersection",e.ZodTuple="ZodTuple",e.ZodRecord="ZodRecord",e.ZodMap="ZodMap",e.ZodSet="ZodSet",e.ZodFunction="ZodFunction",e.ZodLazy="ZodLazy",e.ZodLiteral="ZodLiteral",e.ZodEnum="ZodEnum",e.ZodEffects="ZodEffects",e.ZodNativeEnum="ZodNativeEnum",e.ZodOptional="ZodOptional",e.ZodNullable="ZodNullable",e.ZodDefault="ZodDefault",e.ZodCatch="ZodCatch",e.ZodPromise="ZodPromise",e.ZodBranded="ZodBranded",e.ZodPipeline="ZodPipeline",e.ZodReadonly="ZodReadonly"})(Ht||(Ht={}));const vo=ti.create,IC=Nf.create;$s.create;const td=ri.create,W1=qn.create;pg.create;hg.create;xl.create;const jCe=vg.create,K1=Ma.create;bg.create;ki.create;La.create;const MCe=W1({admins:td(vo()).optional().describe("频道管理员账号(sender ID),管理员拥有管理操作权限且不受以下访问控制限制"),allowPrivateChat:IC().optional().describe("是否允许私聊消息,默认 true"),allowGroupChat:IC().optional().describe("是否允许群聊消息,默认 true"),allowedGroups:td(vo()).optional().describe("群组白名单(channel ID),设置后仅在指定群中响应"),blockedGroups:td(vo()).optional().describe("群组黑名单(channel ID),在指定群中不响应"),allowedSenders:td(vo()).optional().describe("发送者白名单(sender ID),设置后仅白名单内的用户可交互"),blockedSenders:td(vo()).optional().describe("发送者黑名单(sender ID),黑名单内的用户消息将被忽略")}),KF=W1({type:vo().min(1).describe("频道类型"),title:vo().optional().describe("频道标题"),description:vo().optional().describe("频道说明"),enabled:IC().optional().describe("是否启用"),systemPrompt:vo().optional().describe("在此频道启动会话时注入的系统提示词"),commandPrefix:vo().optional().describe("频道指令前缀,默认 /"),language:K1(["zh","en"]).optional().describe("频道提示语言,默认 zh"),access:MCe.optional().describe("频道访问权限配置")}),ACe=e=>e,LCe=KF.extend({type:jCe("lark").describe("频道类型"),appId:vo().min(1).describe("飞书 App ID"),appSecret:vo().min(1).describe("飞书 App Secret"),domain:K1(["Feishu","Lark"]).optional().describe("飞书 Domain")}),DCe=W1({receiveId:vo().min(1).describe("接收方 ID"),receiveIdType:K1(["open_id","user_id","chat_id","email"]).describe("接收方类型"),text:vo().min(1).describe("消息文本")}),zCe=ACe({type:"lark",label:"飞书",description:"飞书消息通道",configSchema:LCe,messageSchema:DCe}),RC=[zCe],cs=e=>e instanceof qn?e.shape:e instanceof Aa?cs(e.innerType()):e instanceof ki?cs(e.unwrap()):e instanceof nu?cs(e.removeDefault()):e instanceof La?cs(e.unwrap()):{},pc=e=>e instanceof Aa?pc(e.innerType()):e instanceof ki?pc(e.unwrap()):e instanceof nu?pc(e.removeDefault()):e instanceof La?pc(e.unwrap()):e,xg=e=>{if(e instanceof nu)return e._def.defaultValue();if(!(e instanceof ki)){if(e instanceof La)return null;if(e instanceof vg)return e.value;if(e instanceof Ma)return e.options[0];if(e instanceof yg){const t=Object.values(e.enum);return t.length>0?t[0]:void 0}if(e instanceof ti)return"";if(e instanceof bl)return 0;if(e instanceof Nf)return!1;if(e instanceof ri)return[];if(e instanceof qn){const t=cs(e);return Object.fromEntries(Object.entries(t).map(([n,r])=>[n,xg(r)]))}if(e instanceof gg)return{};if(e instanceof Aa)return xg(e.innerType())}},BCe=e=>e.replace(/_/g," ").replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/\b\w/g,t=>t.toUpperCase()),aP=e=>{const t=cs(e.configSchema);return Object.entries(t).reduce((r,[o,i])=>(r[o]=xg(i),r),{})},w0=e=>RC.find(t=>t.type===e),FCe=({value:e,onChange:t,t:n,keyPlaceholder:r})=>{var y;const[o,i]=u.useState(""),[a,s]=u.useState(((y=RC[0])==null?void 0:y.type)??""),l=u.useMemo(()=>Object.entries(e),[e]),[c,d]=u.useState(()=>Object.fromEntries(l.map(([x])=>[x,!0]))),f=u.useMemo(()=>new Set(Object.keys(cs(KF))),[]),m=u.useMemo(()=>RC.map(x=>({value:x.type,label:x.label})),[]);u.useEffect(()=>{d(x=>{const g={};for(const[v]of l)g[v]=x[v]??!0;return g})},[l]);const p=(x,g)=>{t({...e,[x]:g})},h=(x,g,v,S)=>{const C=pc(S),_=C.description??"",w=BCe(v),N=g[v],k=N!==void 0?N:xg(S);if(C instanceof ti){const E=BF(v);return b.jsx(Pn,{title:w,description:_,icon:An("string"),children:E?b.jsx(Ft.Password,{value:typeof k=="string"?k:"",onChange:$=>{p(x,{...g,[v]:$.target.value})},placeholder:n("config.editor.secretPlaceholder")}):b.jsx(Ft,{value:typeof k=="string"?k:"",onChange:$=>{p(x,{...g,[v]:$.target.value})}})},v)}if(C instanceof bl)return b.jsx(Pn,{title:w,description:_,icon:An("number"),children:b.jsx(Pv,{value:typeof k=="number"?k:0,onChange:E=>{p(x,{...g,[v]:E??0})}})},v);if(C instanceof Nf)return b.jsx(Pn,{title:w,description:_,icon:An("boolean"),children:b.jsx(ta,{checked:!!k,onChange:E=>{p(x,{...g,[v]:E})}})},v);if(C instanceof Ma||C instanceof yg){const E=(C instanceof Ma?C.options:Object.values(C.enum)).map($=>String($));return b.jsx(Pn,{title:w,description:_,icon:An("string"),children:b.jsx(er,{value:typeof k=="string"?k:void 0,options:E.map($=>({value:$,label:$})),onChange:$=>{p(x,{...g,[v]:$})}})},v)}if(C instanceof ri){if(pc(C.element)instanceof ti){const $=Array.isArray(k)?k.filter(O=>typeof O=="string"):[];return b.jsx(Pn,{title:w,description:_,icon:An("array"),layout:"stacked",children:b.jsx(cy,{value:$,onChange:O=>{p(x,{...g,[v]:O})},t:n})},v)}return b.jsx(Pn,{title:w,description:_,icon:An("array"),layout:"stacked",children:b.jsx(eu,{value:Array.isArray(k)?k:[],onChange:$=>{p(x,{...g,[v]:$})}})},v)}return b.jsx(Pn,{title:w,description:_,icon:An("object"),layout:"stacked",children:b.jsx(eu,{value:k??{},onChange:E=>{p(x,{...g,[v]:E})}})},v)};return b.jsxs("div",{className:"config-view__record-list",children:[b.jsx("div",{className:"config-view__record-add",children:b.jsxs("div",{className:"config-view__record-add-inputs",children:[b.jsx(Ft,{value:o,placeholder:r,onChange:x=>i(x.target.value)}),b.jsx(er,{value:a,options:m,onChange:x=>s(x)}),b.jsx(ht,{title:n("common.confirm"),children:b.jsx(lt,{size:"small",type:"primary",className:"config-view__icon-button","aria-label":n("common.confirm"),icon:b.jsx("span",{className:"material-symbols-rounded",children:"check"}),disabled:o.trim()===""||Object.hasOwn(e,o)||a==="",onClick:()=>{const x=w0(a);x&&(t({...e,[o]:aP(x)}),i(""))}})})]})}),l.map(([x,g])=>{const v=g!=null&&typeof g=="object"?g:{},S=typeof v.type=="string"?v.type:void 0,C=w0(S),_=typeof v.title=="string"?v.title:"",w=typeof v.description=="string"?v.description:"",N=_.trim()!==""?_:x,k=(C==null?void 0:C.label)??S??n("config.editor.unknownChannelType"),E=c[x]===!0,$=C?cs(C.configSchema):{},O=Object.entries($).filter(([R])=>R!=="type").sort(([R],[P])=>{const I=["title","description","enabled","admins"],T=I.indexOf(R),M=I.indexOf(P);return T===-1&&M===-1?R.localeCompare(P):T===-1?1:M===-1?-1:T-M});return b.jsxs("div",{className:`config-view__record-card${E?" config-view__record-card--collapsed":""}`,children:[b.jsxs("div",{className:"config-view__record-title",children:[b.jsxs("div",{className:"config-view__record-title-left",children:[b.jsx(ht,{title:n(E?"config.editor.expand":"config.editor.collapse"),children:b.jsx(lt,{size:"small",type:"text",className:"config-view__icon-button config-view__icon-button--compact","aria-label":n(E?"config.editor.expand":"config.editor.collapse"),icon:b.jsx("span",{className:"material-symbols-rounded",children:E?"chevron_right":"expand_more"}),onClick:()=>{d(R=>({...R,[x]:!E}))}})}),b.jsxs("div",{className:"config-view__record-heading",children:[b.jsx("div",{children:N}),b.jsxs("div",{className:"config-view__record-subtitle",children:[x," · ",k]}),w!==""&&b.jsx("div",{className:"config-view__record-desc",children:w})]})]}),b.jsx("div",{className:"config-view__record-actions",children:b.jsx(ht,{title:n("config.editor.remove"),children:b.jsx(lt,{size:"small",type:"text",danger:!0,className:"config-view__icon-button config-view__icon-button--compact","aria-label":n("config.editor.remove"),icon:b.jsx("span",{className:"material-symbols-rounded",children:"delete"}),onClick:()=>{const R={...e};delete R[x],t(R)}})})})]}),b.jsx("div",{className:"config-view__record-body",children:b.jsxs("div",{className:"config-view__record-fields",children:[b.jsx(Pn,{title:n("config.editor.channelType"),description:(C==null?void 0:C.description)??"",icon:An("string"),children:b.jsx(er,{value:S,options:m,onChange:R=>{const P=w0(R);if(!P)return;const I=aP(P),T=Object.fromEntries(Object.entries(v).filter(([M])=>f.has(M)));p(x,{...I,...T,type:R})}})}),O.map(([R,P])=>h(x,v,R,P))]})})]},x)})]})},HCe=({value:e,onChange:t,t:n,keyPlaceholder:r})=>{const[o,i]=u.useState(""),a=Object.entries(e);return b.jsxs("div",{className:"config-view__record-list",children:[a.map(([s,l])=>b.jsxs("div",{className:"config-view__record-row",children:[b.jsx("div",{className:"config-view__record-key",children:s}),b.jsx(ta,{checked:!!l,onChange:c=>{t({...e,[s]:c})}}),b.jsx(ht,{title:n("config.editor.remove"),children:b.jsx(lt,{size:"small",type:"text",danger:!0,className:"config-view__icon-button config-view__icon-button--compact","aria-label":n("config.editor.remove"),icon:b.jsx("span",{className:"material-symbols-rounded",children:"delete"}),onClick:()=>{const c={...e};delete c[s],t(c)}})})]},s)),b.jsx("div",{className:"config-view__record-add",children:b.jsxs("div",{className:"config-view__record-add-inputs",children:[b.jsx(Ft,{value:o,placeholder:r,onChange:s=>i(s.target.value)}),b.jsx(ht,{title:n("common.confirm"),children:b.jsx(lt,{size:"small",type:"primary",className:"config-view__icon-button","aria-label":n("common.confirm"),icon:b.jsx("span",{className:"material-symbols-rounded",children:"check"}),disabled:o.trim()===""||Object.hasOwn(e,o),onClick:()=>{t({...e,[o]:!0}),i("")}})})]})})]})},PC=({value:e,onChange:t,t:n,keyPlaceholder:r})=>{const[o,i]=u.useState(""),[a,s]=u.useState(""),l=Object.entries(e);return b.jsxs("div",{className:"config-view__array-list",children:[l.map(([c,d])=>b.jsxs("div",{className:"config-view__array-item",children:[b.jsx("div",{className:"config-view__record-key",children:c}),BF(c)?b.jsx(Ft.Password,{value:d,onChange:f=>{t({...e,[c]:f.target.value})},placeholder:n("config.editor.fieldValue")}):b.jsx(Ft,{value:d,onChange:f=>{t({...e,[c]:f.target.value})},placeholder:n("config.editor.fieldValue")}),b.jsx(ht,{title:n("config.editor.remove"),children:b.jsx(lt,{size:"small",type:"text",danger:!0,className:"config-view__icon-button config-view__icon-button--compact","aria-label":n("config.editor.remove"),icon:b.jsx("span",{className:"material-symbols-rounded",children:"delete"}),onClick:()=>{const f={...e};delete f[c],t(f)}})})]},c)),b.jsx("div",{className:"config-view__array-add",children:b.jsxs("div",{className:"config-view__array-add-inputs",children:[b.jsx(Ft,{value:o,placeholder:r,onChange:c=>i(c.target.value)}),b.jsx(Ft,{value:a,placeholder:n("config.editor.fieldValue"),onChange:c=>s(c.target.value)}),b.jsx(ht,{title:n("common.confirm"),children:b.jsx(lt,{size:"small",type:"primary",className:"config-view__icon-button","aria-label":n("common.confirm"),icon:b.jsx("span",{className:"material-symbols-rounded",children:"check"}),disabled:o.trim()===""||Object.hasOwn(e,o),onClick:()=>{const c={...e,[o]:a};t(c),i(""),s("")}})})]})})]})},VCe=({value:e,onChange:t,t:n,keyPlaceholder:r})=>{const[o,i]=u.useState(""),a=u.useMemo(()=>Object.entries(e),[e]),[s,l]=u.useState(()=>Object.fromEntries(a.map(([c])=>[c,!0])));return u.useEffect(()=>{l(c=>{const d={};for(const[f]of a)d[f]=c[f]??!0;return d})},[a]),b.jsxs("div",{className:"config-view__record-list",children:[a.map(([c,d])=>{const f=d!=null&&typeof d=="object"?d:{},m=typeof f.type=="string"?f.type:"command",p=f.env!=null&&typeof f.env=="object"?f.env:{},h=f.headers!=null&&typeof f.headers=="object"?f.headers:{},y=Array.isArray(f.args)?f.args.filter(v=>typeof v=="string"):[],x=v=>{t({...e,[c]:v})},g=s[c]===!0;return b.jsxs("div",{className:`config-view__record-card${g?" config-view__record-card--collapsed":""}`,children:[b.jsxs("div",{className:"config-view__record-title",children:[b.jsxs("div",{className:"config-view__record-title-left",children:[b.jsx(ht,{title:n(g?"config.editor.expand":"config.editor.collapse"),children:b.jsx(lt,{size:"small",type:"text",className:"config-view__icon-button config-view__icon-button--compact","aria-label":n(g?"config.editor.expand":"config.editor.collapse"),icon:b.jsx("span",{className:"material-symbols-rounded",children:g?"chevron_right":"expand_more"}),onClick:()=>{l(v=>({...v,[c]:!g}))}})}),b.jsx("span",{children:c})]}),b.jsx(ht,{title:n("config.editor.remove"),children:b.jsx(lt,{size:"small",type:"text",danger:!0,className:"config-view__icon-button config-view__icon-button--compact","aria-label":n("config.editor.remove"),icon:b.jsx("span",{className:"material-symbols-rounded",children:"delete"}),onClick:()=>{const v={...e};delete v[c],t(v)}})})]}),b.jsx("div",{className:"config-view__record-body",children:b.jsxs("div",{className:"config-view__record-fields",children:[b.jsx(Pn,{title:n("config.fields.mcpServer.enabled.label"),description:n("config.fields.mcpServer.enabled.desc"),icon:An("boolean"),children:b.jsx(ta,{checked:!!f.enabled,onChange:v=>{x({...f,enabled:v})}})}),b.jsx(Pn,{title:n("config.fields.mcpServer.type.label"),description:n("config.fields.mcpServer.type.desc"),icon:An("string"),children:b.jsx(er,{value:m,options:[{value:"command",label:n("config.options.mcp.command")},{value:"sse",label:n("config.options.mcp.sse")},{value:"http",label:n("config.options.mcp.http")}],onChange:v=>{const S={...f};v==="command"?(delete S.type,S.command==null&&(S.command=""),S.args==null&&(S.args=[]),delete S.url,delete S.headers):(S.type=v,S.url==null&&(S.url=""),S.headers==null&&(S.headers={}),delete S.command,delete S.args),x(S)}})}),m==="command"&&b.jsxs(b.Fragment,{children:[b.jsx(Pn,{title:n("config.fields.mcpServer.command.label"),description:n("config.fields.mcpServer.command.desc"),icon:An("string"),children:b.jsx(Ft,{value:typeof f.command=="string"?f.command:"",onChange:v=>{x({...f,command:v.target.value})},placeholder:n("config.editor.commandPlaceholder")})}),b.jsx(Pn,{title:n("config.fields.mcpServer.args.label"),description:n("config.fields.mcpServer.args.desc"),icon:An("array"),layout:"stacked",children:b.jsx(cy,{value:y,onChange:v=>{x({...f,args:v})},t:n})})]}),m!=="command"&&b.jsxs(b.Fragment,{children:[b.jsx(Pn,{title:n("config.fields.mcpServer.url.label"),description:n("config.fields.mcpServer.url.desc"),icon:An("string"),children:b.jsx(Ft,{value:typeof f.url=="string"?f.url:"",onChange:v=>{x({...f,url:v.target.value})},placeholder:n("config.editor.urlPlaceholder")})}),b.jsx(Pn,{title:n("config.fields.mcpServer.headers.label"),description:n("config.fields.mcpServer.headers.desc"),icon:An("object"),layout:"stacked",children:b.jsx(PC,{value:h,onChange:v=>{x({...f,headers:v})},t:n,keyPlaceholder:n("config.editor.newHeaderName")})})]}),b.jsx(Pn,{title:n("config.fields.mcpServer.env.label"),description:n("config.fields.mcpServer.env.desc"),icon:An("object"),layout:"stacked",children:b.jsx(PC,{value:p,onChange:v=>{x({...f,env:v})},t:n,keyPlaceholder:n("config.editor.newEnvVarName")})})]})})]},c)}),b.jsx("div",{className:"config-view__record-add",children:b.jsxs("div",{className:"config-view__record-add-inputs",children:[b.jsx(Ft,{value:o,placeholder:r,onChange:c=>i(c.target.value)}),b.jsx(ht,{title:n("common.confirm"),children:b.jsx(lt,{size:"small",type:"primary",className:"config-view__icon-button","aria-label":n("common.confirm"),icon:b.jsx("span",{className:"material-symbols-rounded",children:"check"}),disabled:o.trim()===""||Object.hasOwn(e,o),onClick:()=>{t({...e,[o]:{enabled:!0,command:"",args:[]}}),i("")}})})]})})]})},WCe=({value:e,onChange:t,t:n,keyPlaceholder:r})=>{const[o,i]=u.useState(""),a=u.useMemo(()=>Object.entries(e),[e]),[s,l]=u.useState(()=>Object.fromEntries(a.map(([c])=>[c,!0])));return u.useEffect(()=>{l(c=>{const d={};for(const[f]of a)d[f]=c[f]??!0;return d})},[a]),b.jsxs("div",{className:"config-view__record-list",children:[a.map(([c,d])=>{const f=d!=null&&typeof d=="object"?d:{},m=typeof f.title=="string"?f.title:"",p=typeof f.description=="string"?f.description:"",h=m.trim()!==""?m:c,y=Array.isArray(f.models)?f.models.filter(g=>typeof g=="string"):[],x=s[c]===!0;return b.jsxs("div",{className:`config-view__record-card${x?" config-view__record-card--collapsed":""}`,children:[b.jsxs("div",{className:"config-view__record-title",children:[b.jsxs("div",{className:"config-view__record-title-left",children:[b.jsx(ht,{title:n(x?"config.editor.expand":"config.editor.collapse"),children:b.jsx(lt,{size:"small",type:"text",className:"config-view__icon-button config-view__icon-button--compact","aria-label":n(x?"config.editor.expand":"config.editor.collapse"),icon:b.jsx("span",{className:"material-symbols-rounded",children:x?"chevron_right":"expand_more"}),onClick:()=>{l(g=>({...g,[c]:!x}))}})}),b.jsxs("div",{className:"config-view__record-heading",children:[b.jsx("div",{children:h}),h!==c&&b.jsx("div",{className:"config-view__record-subtitle",children:c}),p!==""&&b.jsx("div",{className:"config-view__record-desc",children:p})]})]}),b.jsx(ht,{title:n("config.editor.remove"),children:b.jsx(lt,{size:"small",type:"text",danger:!0,className:"config-view__icon-button config-view__icon-button--compact","aria-label":n("config.editor.remove"),icon:b.jsx("span",{className:"material-symbols-rounded",children:"delete"}),onClick:()=>{const g={...e};delete g[c],t(g)}})})]}),b.jsx("div",{className:"config-view__record-body",children:b.jsxs("div",{className:"config-view__record-fields",children:[b.jsx(Pn,{title:n("config.fields.modelServices.item.title.label"),description:n("config.fields.modelServices.item.title.desc"),icon:An("string"),children:b.jsx(Ft,{value:m,onChange:g=>{t({...e,[c]:{...f,title:g.target.value}})},placeholder:n("config.editor.titlePlaceholder")})}),b.jsx(Pn,{title:n("config.fields.modelServices.item.description.label"),description:n("config.fields.modelServices.item.description.desc"),icon:An("string"),layout:"stacked",children:b.jsx(Ft.TextArea,{value:p,onChange:g=>{t({...e,[c]:{...f,description:g.target.value}})},autoSize:{minRows:2},placeholder:n("config.editor.descriptionPlaceholder")})}),b.jsx(Pn,{title:n("config.fields.modelServices.item.apiBaseUrl.label"),description:n("config.fields.modelServices.item.apiBaseUrl.desc"),icon:An("string"),children:b.jsx(Ft,{value:typeof f.apiBaseUrl=="string"?f.apiBaseUrl:"",onChange:g=>{t({...e,[c]:{...f,apiBaseUrl:g.target.value}})}})}),b.jsx(Pn,{title:n("config.fields.modelServices.item.apiKey.label"),description:n("config.fields.modelServices.item.apiKey.desc"),icon:An("string"),children:b.jsx(Ft.Password,{value:typeof f.apiKey=="string"?f.apiKey:"",onChange:g=>{t({...e,[c]:{...f,apiKey:g.target.value}})},placeholder:n("config.editor.secretPlaceholder")})}),b.jsx(Pn,{title:n("config.fields.modelServices.item.models.label"),description:n("config.fields.modelServices.item.models.desc"),icon:An("array"),layout:"stacked",children:b.jsx(cy,{value:y,onChange:g=>{t({...e,[c]:{...f,models:g}})},t:n})}),b.jsx(Pn,{title:n("config.fields.modelServices.item.modelsAlias.label"),description:n("config.fields.modelServices.item.modelsAlias.desc"),icon:An("object"),layout:"stacked",children:b.jsx(eu,{value:f.modelsAlias??{},onChange:g=>{t({...e,[c]:{...f,modelsAlias:g}})}})}),b.jsx(Pn,{title:n("config.fields.modelServices.item.extra.label"),description:n("config.fields.modelServices.item.extra.desc"),icon:An("object"),layout:"stacked",children:b.jsx(eu,{value:f.extra??{},onChange:g=>{t({...e,[c]:{...f,extra:g}})}})})]})})]},c)}),b.jsx("div",{className:"config-view__record-add",children:b.jsxs("div",{className:"config-view__record-add-inputs",children:[b.jsx(Ft,{value:o,placeholder:r,onChange:c=>i(c.target.value)}),b.jsx(ht,{title:n("common.confirm"),children:b.jsx(lt,{size:"small",type:"primary",className:"config-view__icon-button","aria-label":n("common.confirm"),icon:b.jsx("span",{className:"material-symbols-rounded",children:"check"}),disabled:o.trim()===""||Object.hasOwn(e,o),onClick:()=>{t({...e,[o]:{title:"",description:"",apiBaseUrl:"",apiKey:"",models:[],modelsAlias:{},extra:{}}}),i("")}})})]})})]})},KCe=({value:e,onChange:t,t:n,keyPlaceholder:r})=>{const[o,i]=u.useState(""),a=u.useMemo(()=>Object.entries(e),[e]),[s,l]=u.useState(()=>Object.fromEntries(a.map(([c])=>[c,!0])));return u.useEffect(()=>{l(c=>{const d={};for(const[f]of a)d[f]=c[f]??!0;return d})},[a]),b.jsxs("div",{className:"config-view__record-list",children:[a.map(([c,d])=>{const f=s[c]===!0;return b.jsxs("div",{className:`config-view__record-card${f?" config-view__record-card--collapsed":""}`,children:[b.jsxs("div",{className:"config-view__record-title",children:[b.jsxs("div",{className:"config-view__record-title-left",children:[b.jsx(ht,{title:n(f?"config.editor.expand":"config.editor.collapse"),children:b.jsx(lt,{size:"small",type:"text",className:"config-view__icon-button config-view__icon-button--compact","aria-label":n(f?"config.editor.expand":"config.editor.collapse"),icon:b.jsx("span",{className:"material-symbols-rounded",children:f?"chevron_right":"expand_more"}),onClick:()=>{l(m=>({...m,[c]:!f}))}})}),b.jsx("span",{children:c})]}),b.jsx(ht,{title:n("config.editor.remove"),children:b.jsx(lt,{size:"small",type:"text",danger:!0,className:"config-view__icon-button config-view__icon-button--compact","aria-label":n("config.editor.remove"),icon:b.jsx("span",{className:"material-symbols-rounded",children:"delete"}),onClick:()=>{const m={...e};delete m[c],t(m)}})})]}),b.jsx("div",{className:"config-view__record-body",children:b.jsx(eu,{value:d,onChange:m=>{t({...e,[c]:m})}})})]},c)}),b.jsx("div",{className:"config-view__record-add",children:b.jsxs("div",{className:"config-view__record-add-inputs",children:[b.jsx(Ft,{value:o,placeholder:r,onChange:c=>i(c.target.value)}),b.jsx(ht,{title:n("common.confirm"),children:b.jsx(lt,{size:"small",type:"primary",className:"config-view__icon-button","aria-label":n("common.confirm"),icon:b.jsx("span",{className:"material-symbols-rounded",children:"check"}),disabled:o.trim()===""||Object.hasOwn(e,o),onClick:()=>{t({...e,[o]:{}}),i("")}})})]})})]})},UCe=({sectionKey:e,fields:t,value:n,onChange:r,mergedModelServices:o,mergedAdapters:i,selectedModelService:a,t:s})=>{const l=t??sCe[e]??[];if(l.length===0)return b.jsx(yn,{description:s("common.noData"),image:null});const c=new Set(["modelServices","channels","adapters","plugins","mcp"]),f=Object.entries(o).map(([C,_])=>{const w=_!=null&&typeof _=="object"?_:{},N=typeof w.title=="string"&&w.title.trim()!==""?w.title:C,k=typeof w.description=="string"?w.description:"";return{value:C,label:b.jsxs("div",{className:"config-view__option",children:[b.jsx("div",{className:"config-view__option-title",children:N}),k!==""&&b.jsx("div",{className:"config-view__option-desc",children:k})]})}}),m=a?o[a]:void 0,p=m!=null&&typeof m=="object"?m.models:void 0,h=Array.isArray(p)?p.filter(C=>typeof C=="string").map(C=>({value:C,label:b.jsx("span",{children:C})})):[],y=Object.keys(i).map(C=>({value:C,label:b.jsx("span",{children:C})})),x=l.reduce((C,_)=>{const w=_.group??"default";return C[w]||(C[w]=[]),C[w].push(_),C},{}),g=["base","permissions","env","items","default"].filter(C=>{var _;return(_=x[C])==null?void 0:_.length}),v=C=>e==="modelServices"?s("config.editor.newModelServiceName"):e==="channels"?s("config.editor.newChannelName"):e==="adapters"?s("config.editor.newAdapterName"):e==="plugins"?C.path.join(".")==="extraKnownMarketplaces"?s("config.editor.newMarketplaceName"):s("config.editor.newPluginName"):e==="mcp"?s("config.editor.newMcpServerName"):e==="general"&&C.path.join(".")==="env"?s("config.editor.newEnvVarName"):s("config.editor.fieldKey"),S=C=>{const _=Kp(n,C.path),w=_!==void 0?_:C.defaultValue,N=C.labelKey?s(C.labelKey):DF(s,e,C.path,C.path[C.path.length-1]??""),k=C.descriptionKey?s(C.descriptionKey):zF(s,e,C.path),E=C.icon??An(LF(w)),$=P=>{const I=UR(n,C.path,P);r(I)};let O=null;const R=["multiline","json","record","string[]"].includes(C.type);if(C.type==="string"){const P=C.placeholderKey?s(C.placeholderKey):void 0;C.sensitive===!0?O=b.jsx(Ft.Password,{value:typeof w=="string"?w:"",onChange:I=>$(I.target.value),placeholder:s("config.editor.secretPlaceholder")}):O=b.jsx(Ft,{value:typeof w=="string"?w:"",onChange:I=>$(I.target.value),placeholder:P})}else if(C.type==="multiline"){const P=typeof w=="string"?w:"",I=C.placeholderKey?s(C.placeholderKey):s("config.editor.multilinePlaceholder");O=b.jsx("div",{className:"config-view__multiline",children:b.jsx(Ft.TextArea,{className:"config-view__multiline-input",value:P,onChange:T=>$(T.target.value),autoSize:{minRows:3},placeholder:I})})}else if(C.type==="number")if(C.path.join(".")==="notifications.volume"){const I=typeof w=="number"?w:0;O=b.jsx(Dte,{className:"config-view__slider",min:0,max:100,step:1,value:I,onChange:T=>$(typeof T=="number"?T:0)})}else O=b.jsx(Pv,{value:typeof w=="number"?w:0,onChange:I=>$(typeof I=="number"?I:0)});else if(C.type==="boolean")O=b.jsx(ta,{checked:!!w,onChange:P=>$(P)});else if(C.type==="string[]"){const P=Array.isArray(w)?w.filter(I=>typeof I=="string"):[];O=b.jsx(cy,{value:P,onChange:I=>$(I),t:s})}else if(C.type==="select"){const P=e==="general"&&C.path.join(".")==="defaultAdapter",I=e==="general"&&C.path.join(".")==="defaultModelService",T=e==="general"&&C.path.join(".")==="defaultModel",M=I?f:T?h:P?y:(C.options??[]).map(L=>({value:L.value,label:b.jsx("span",{children:s(L.label)})}));O=b.jsx(er,{value:typeof w=="string"&&w!==""?w:void 0,options:M,onChange:L=>$(L),allowClear:!0,disabled:T&&h.length===0,placeholder:s(P?"config.editor.defaultAdapterPlaceholder":I?"config.editor.defaultModelServicePlaceholder":"config.editor.defaultModelPlaceholder")})}else if(C.type==="json")O=b.jsx(eu,{value:w,onChange:$});else if(C.type==="record"){const P=w!=null&&typeof w=="object"?w:{};C.recordKind==="modelServices"?O=b.jsx(WCe,{value:P,onChange:$,t:s,keyPlaceholder:v(C)}):C.recordKind==="channels"?O=b.jsx(FCe,{value:P,onChange:$,t:s,keyPlaceholder:v(C)}):C.recordKind==="mcpServers"?O=b.jsx(VCe,{value:P,onChange:$,t:s,keyPlaceholder:v(C)}):C.recordKind==="keyValue"?O=b.jsx(PC,{value:P,onChange:$,t:s,keyPlaceholder:v(C)}):C.recordKind==="boolean"?O=b.jsx(HCe,{value:P,onChange:$,t:s,keyPlaceholder:v(C)}):O=b.jsx(KCe,{value:P,onChange:$,t:s,keyPlaceholder:v(C)})}else if(C.type==="shortcut"){const P=navigator.platform.includes("Mac");O=b.jsx(iCe,{value:typeof w=="string"?w:"",onChange:I=>$(I),placeholder:s("config.editor.shortcutPlaceholder"),isMac:P,t:s})}return c.has(e)&&C.type==="record"?b.jsx("div",{children:O},`${C.path.join(".")}-${C.type}-${C.recordKind??""}`):b.jsx(Pn,{title:N,description:k,icon:E,layout:R?"stacked":"inline",children:O},`${C.path.join(".")}-${C.type}-${C.labelKey??""}-${C.recordKind??""}`)};return b.jsx("div",{className:"config-view__field-stack",children:g.map(C=>{const _=x[C]??[];if(new Set(["base","permissions"]).has(C)&&!_.some(I=>{const T=Kp(n,I.path);return typeof T=="boolean"?T:!dg(T)}))return null;if(C==="default")return c.has(e)?b.jsx("div",{children:_.map(S)},C):b.jsx("div",{className:"config-view__field-list",children:_.map(S)},C);const N=(()=>{var I,T;const P=(T=(I=aCe[e])==null?void 0:I[C])==null?void 0:T.labelKey;return s(P||(C==="base"?"config.sectionGroups.base":C==="permissions"?"config.sectionGroups.permissions":C==="env"?"config.sectionGroups.env":e==="plugins"?"config.sectionGroups.plugins":"config.sectionGroups.items"))})(),k=_.filter(P=>P.hidden!==!0),E=k.filter(P=>P.collapse!=null),$=k.filter(P=>P.collapse==null),O=E.reduce((P,I)=>{const T=I.collapse;if(!T)return P;const M=P.get(T.key);return M?M.fields.push(I):P.set(T.key,{meta:T,fields:[I]}),P},new Map),R=Array.from(O.values()).map(P=>({key:P.meta.key,collapsible:"header",label:b.jsxs("div",{className:"config-view__collapse-header",children:[b.jsxs("div",{className:"config-view__collapse-header-main",children:[b.jsx("div",{className:"config-view__collapse-title",children:s(P.meta.labelKey)}),P.meta.descKey&&b.jsx("div",{className:"config-view__collapse-desc",children:s(P.meta.descKey)})]}),P.meta.togglePath&&b.jsx(ta,{checked:!Kp(n,P.meta.togglePath),onChange:I=>{const T=UR(n,P.meta.togglePath,!I);r(T)},onClick:(I,T)=>{T.stopPropagation()}})]}),children:b.jsx("div",{className:"config-view__field-list",children:P.fields.map(S)})}));return b.jsxs("div",{className:"config-view__subsection",children:[b.jsx("div",{className:"config-view__subsection-title",children:N}),b.jsxs("div",{className:"config-view__subsection-body",children:[$.map(S),R.length>0&&b.jsx(r7,{className:"config-view__collapse-group config-view__field-row",ghost:!0,items:R})]})]},C)})})};function UF({sectionKey:e,title:t,icon:n,fields:r,value:o,onChange:i,mergedModelServices:a,mergedAdapters:s,selectedModelService:l,headerExtra:c,t:d,className:f}){const m=["config-view__editor-wrap",f].filter(Boolean).join(" "),p=t!=null||n!=null||c!=null;return b.jsxs("div",{className:m,children:[p&&b.jsxs("div",{className:"config-view__section-header",children:[b.jsxs("div",{className:"config-view__section-title",children:[n!=null&&b.jsx("span",{className:"material-symbols-rounded config-view__section-icon",children:n}),b.jsx("span",{children:t})]}),c]}),b.jsx("div",{className:"config-view__card",children:b.jsx(UCe,{sectionKey:e,fields:r,value:o,onChange:i,mergedModelServices:a,mergedAdapters:s,selectedModelService:l,t:d})})]})}function GCe({value:e,onChange:t,options:n}){return b.jsx(Nl.Group,{value:e,optionType:"button",buttonStyle:"solid",size:"small",onChange:r=>{t(r.target.value)},options:n.map(r=>({value:r.value,label:b.jsxs("span",{className:"config-view__source-option",children:[b.jsx("span",{className:"material-symbols-rounded",children:r.icon}),b.jsx("span",{children:r.label})]})}))})}function qCe({sessionInfo:e,sessionId:t,sessionTitle:n,isStarred:r,isArchived:o,tags:i,lastMessage:a,lastUserMessage:s,activeView:l,onViewChange:c}){const{t:d}=Ot(),{message:f}=_o.useApp(),m=vl(p1),p=vl(Vz),[h,y]=u.useState(""),x=(e==null?void 0:e.type)==="summary"?e.summary:null,g=((e==null?void 0:e.type)==="init"?e.title:null)??n;(e==null?void 0:e.type)==="init"&&e.cwd;const v=g!=null&&g!==""?g:x!=null&&x!==""?x:s!=null&&s!==""?s:a!=null&&a!==""?a:d("common.newChat");u.useEffect(()=>{g!=null&&g!==""&&y(g)},[g]);const S=async()=>{if(!(t==null||t===""))try{await Sa(t,{isStarred:!r}),f.success(d(r?"common.unstarred":"common.starred"))}catch(w){f.error(jr(w,d("common.operationFailed")))}},C=async()=>{if(!(t==null||t===""))try{await Sa(t,{isArchived:!o}),f.success(d(o?"common.restored":"common.archived"))}catch(w){f.error(jr(w,d("common.operationFailed")))}},_=[{key:"star",label:d(r?"common.unstar":"common.star"),icon:b.jsx("span",{className:`material-symbols-rounded ${r?"is-filled":""}`,style:{fontSize:"18px"},children:r?"star":"star_border"}),onClick:()=>{S()}},{key:"archive",label:d(o?"common.restore":"common.archive"),icon:b.jsx("span",{className:"material-symbols-rounded",style:{fontSize:"18px"},children:o?"unarchive":"archive"}),onClick:()=>{C()}}];return b.jsxs("div",{className:`chat-header ${m?"is-collapsed":""} ${p?"is-resizing":""}`,children:[b.jsx("div",{style:{display:"flex",alignItems:"center",gap:"12px",flex:1,minWidth:0},children:b.jsxs("div",{className:"chat-header-info",children:[b.jsx("div",{className:"chat-header-title",children:v}),b.jsx("div",{className:"chat-header-subtitle",onDoubleClick:()=>{console.log("Session Full Info:",{sessionId:t,sessionTitle:n,isStarred:r,isArchived:o,tags:i,lastMessage:a,lastUserMessage:s,sessionInfo:e})},style:{cursor:"pointer",userSelect:"all"},children:t??d("chat.selectModel")})]})}),b.jsxs("div",{className:"chat-header-actions",children:[b.jsx(Nl.Group,{className:"chat-header-view-group",value:l,optionType:"button",buttonStyle:"solid",size:"small",onChange:w=>{c(w.target.value)},options:[{label:b.jsx("span",{className:"chat-header-view-option material-symbols-rounded",children:"forum"}),value:"history"},{label:b.jsx("span",{className:"chat-header-view-option material-symbols-rounded",children:"timeline"}),value:"timeline"},{label:b.jsx("span",{className:"chat-header-view-option material-symbols-rounded",children:"tune"}),value:"settings"}]}),b.jsx("div",{className:"chat-header-divider"}),b.jsx(Qc,{menu:{items:_},placement:"bottomRight",trigger:["click"],children:b.jsx(lt,{type:"text",icon:b.jsx("span",{className:"material-symbols-rounded",children:"more_vert"})})})]})]})}function XCe({sessionId:e,initialTitle:t,initialTags:n=[],onClose:r}){const{t:o}=Ot(),{message:i,modal:a}=_o.useApp(),s=u.useMemo(()=>[{path:["title"],type:"string",defaultValue:"",icon:"edit_note",labelKey:"chat.title",placeholderKey:"chat.enterTitle"},{path:["tags"],type:"string[]",defaultValue:[],icon:"sell",labelKey:"chat.tags"}],[]),l=u.useMemo(()=>({title:t??"",tags:n}),[n,t]),[c,d]=u.useState(l),f=u.useRef(l),m=u.useRef(null),p=u.useRef(!1),h=u.useRef(null);u.useEffect(()=>{d(l)},[l]),u.useEffect(()=>{f.current=c},[c]),u.useEffect(()=>()=>{m.current&&clearTimeout(m.current)},[]);const y=v=>{const S=JSON.stringify(v??{});h.current!==S&&(m.current&&clearTimeout(m.current),m.current=setTimeout(async()=>{if(p.current)return;const C=f.current,_=JSON.stringify(C??{});if(h.current!==_){p.current=!0;try{await Sa(e,{title:typeof C.title=="string"?C.title:"",tags:Array.isArray(C.tags)?C.tags:[]}),h.current=_}catch(w){i.error(jr(w,o("common.operationFailed")))}finally{p.current=!1}}},500))},x=v=>{const S=v!=null&&typeof v=="object"?v:{},C={title:typeof S.title=="string"?S.title:"",tags:Array.isArray(S.tags)?S.tags.filter(_=>typeof _=="string"):[]};d(C),y(C)},g=()=>{a.confirm({title:o("common.deleteSession"),content:o("common.deleteSessionConfirm"),okText:o("common.delete"),okType:"danger",cancelText:o("common.cancel"),onOk:async()=>{try{await qh(e),i.success(o("common.deleteSuccess")),r()}catch(v){i.error(jr(v,o("common.deleteFailed")))}}})};return b.jsxs("div",{className:"session-settings-drawer",children:[b.jsx(UF,{sectionKey:"session",title:null,icon:void 0,fields:s,value:c,onChange:x,mergedModelServices:{},mergedAdapters:{},selectedModelService:void 0,t:o,className:"session-settings-drawer__form"}),b.jsx("div",{className:"settings-footer",children:b.jsx("div",{className:"danger-zone",children:b.jsxs("div",{className:"delete-session-row",children:[b.jsxs("div",{className:"delete-session-meta",children:[b.jsx("div",{className:"delete-session-title",children:o("chat.deleteSessionTitle")}),b.jsx("div",{className:"delete-session-desc",children:o("chat.deleteSessionDesc")})]}),b.jsx(lt,{danger:!0,type:"primary",size:"middle",icon:b.jsx("span",{className:"material-symbols-rounded",children:"delete_forever"}),onClick:g,className:"delete-session-btn",children:o("common.delete")})]})})})]})}const YCe=80;function QCe({messagesLength:e}){const t=u.useRef(null),n=u.useRef(null),r=u.useRef(null),[o,i]=u.useState(!1),a=u.useCallback(()=>{const l=n.current;if(!l)return;const c=l.scrollHeight-(l.scrollTop+l.clientHeight);i(c>YCe)},[]),s=u.useCallback((l="smooth")=>{setTimeout(()=>{n.current&&n.current.scrollTo({top:n.current.scrollHeight,behavior:l})},50)},[]);return u.useEffect(()=>{const l=n.current;if(!l)return;a();const c=()=>a();return l.addEventListener("scroll",c,{passive:!0}),()=>{l.removeEventListener("scroll",c)}},[a]),u.useEffect(()=>{a()},[a,e]),{messagesEndRef:t,messagesContainerRef:n,messagesContentRef:r,showScrollBottom:o,scrollToBottom:s}}class ZCe{constructor(){je(this,"sockets",new Map);je(this,"subscribers",new Map);je(this,"disconnectTimers",new Map);je(this,"connectionParams",new Map);je(this,"DISCONNECT_DELAY",6e4)}connect(t,n,r){var l;this.disconnectTimers.has(t)&&(clearTimeout(this.disconnectTimers.get(t)),this.disconnectTimers.delete(t)),this.subscribers.has(t)||this.subscribers.set(t,new Set),this.subscribers.get(t).add(n);const o=this.normalizeParams({sessionId:t,...r??{}}),i=this.buildParamsKey(o),a=this.connectionParams.get(t);let s=this.sockets.get(t);return a!=null&&a!==i&&s&&(s.close(),this.sockets.delete(t),s=void 0),!s||s.readyState===WebSocket.CLOSED||s.readyState===WebSocket.CLOSING?this.createConnection(t,o):s.readyState===WebSocket.OPEN&&((l=n.onOpen)==null||l.call(n)),this.connectionParams.set(t,i),()=>this.disconnect(t,n)}createConnection(t,n){const r=qz({onOpen:()=>{this.broadcast(t,"onOpen")},onMessage:o=>{this.broadcast(t,"onMessage",o)},onError:o=>{this.broadcast(t,"onError",o)},onClose:()=>{this.broadcast(t,"onClose"),this.sockets.get(t)===r&&this.sockets.delete(t)}},n);this.sockets.set(t,r)}disconnect(t,n){const r=this.subscribers.get(t);r&&(r.delete(n),r.size===0&&this.disconnectTimers.set(t,setTimeout(()=>{const o=this.sockets.get(t);o&&(o.close(),this.sockets.delete(t)),this.disconnectTimers.delete(t),this.subscribers.delete(t),this.connectionParams.delete(t)},this.DISCONNECT_DELAY)))}broadcast(t,n,r){const o=this.subscribers.get(t);o&&Array.from(o).forEach(a=>{if(a[n])try{a[n](r)}catch(s){console.error(`Error in ${n} handler for session ${t}:`,s)}})}close(t){const n=this.sockets.get(t);n&&(n.close(),this.sockets.delete(t)),this.disconnectTimers.has(t)&&(clearTimeout(this.disconnectTimers.get(t)),this.disconnectTimers.delete(t)),this.subscribers.delete(t),this.connectionParams.delete(t)}send(t,n){const r=this.sockets.get(t);r&&r.readyState===WebSocket.OPEN?r.send(typeof n=="string"?n:JSON.stringify(n)):console.warn(`Cannot send message: Session ${t} not connected or ready`)}normalizeParams(t){return Object.entries(t).reduce((n,[r,o])=>{if(o==null)return n;const i=String(o).trim();return i===""||(n[r]=i),n},{})}buildParamsKey(t){return Object.entries(t).sort(([n],[r])=>n.localeCompare(r)).map(([n,r])=>`${n}=${r}`).join("&")}}const Ca=new ZCe;function JCe({session:e,modelForQuery:t,hasAvailableModels:n,permissionMode:r,adapter:o,onClearMessages:i}){const{message:a}=_o.useApp(),{t:s}=Ot(),l=Ts(),{mutate:c}=Xv(),[d,f]=u.useState(!1),m=d||(e==null?void 0:e.status)==="running",p=u.useCallback(async g=>{if(g.trim()===""||m)return!1;if(!n)return a.warning(s("chat.modelConfigRequired")),!1;if(!(e!=null&&e.id)){f(!0);try{const{session:v}=await II(void 0,g.trim(),void 0,t,{permissionMode:r,adapter:o});return await c("/api/sessions",S=>S!=null&&S.sessions?{...S,sessions:[v,...S.sessions]}:{sessions:[v]},!1),l(`/session/${v.id}`),!0}catch(v){return console.error(v),f(!1),a.error(jr(v,"Failed to create session")),!1}}return Ca.send(e.id,{type:"user_message",text:g.trim()}),!0},[o,n,m,a,c,l,r,t,e==null?void 0:e.id,s]),h=u.useCallback(async g=>{if(g.length===0||m)return!1;if(!n)return a.warning(s("chat.modelConfigRequired")),!1;if(!(e!=null&&e.id)){f(!0);try{const{session:v}=await II(void 0,void 0,g,t,{permissionMode:r,adapter:o});return await c("/api/sessions",S=>S!=null&&S.sessions?{...S,sessions:[v,...S.sessions]}:{sessions:[v]},!1),l(`/session/${v.id}`),!0}catch(v){return console.error(v),f(!1),a.error(jr(v,"Failed to create session")),!1}}return Ca.send(e.id,{type:"user_message",content:g}),!0},[o,n,m,a,c,l,r,t,e==null?void 0:e.id,s]),y=u.useCallback(()=>{!(e!=null&&e.id)||m===!1||Ca.send(e.id,{type:"interrupt"})},[m,e==null?void 0:e.id]),x=u.useCallback(()=>{i(),a.success("Messages cleared")},[a,i]);return{isCreating:d,isThinking:m,send:p,sendContent:h,interrupt:y,clearMessages:x}}function ewe({messages:e}){const{t}=Ot(),[n,r]=u.useState(!1);let o=[];for(let s=e.length-1;s>=0;s--){const l=e[s];if(l.role==="assistant"&&Array.isArray(l.content)){const c=l.content.find(d=>d!=null&&d.type==="tool_use"&&(d.name==="TodoWrite"||d.name==="todo_write"||d.name==="adapter:claude-code:TodoWrite"||d.name==="adapter:claude-code:todo_write"));if(c!=null&&c.type==="tool_use"&&c.input!=null&&typeof c.input=="object"){const d=c.input;if(Array.isArray(d.todos)){o=d.todos;break}}}}if(o.length===0)return null;const i=o.filter(s=>s.status==="completed").length,a=o.length;return a===0?b.jsx("div",{className:"current-todo-container empty",children:b.jsx("div",{className:"todo-progress-bar empty",children:b.jsxs("div",{className:"progress-info",children:[b.jsx("span",{className:"material-symbols-rounded",children:"assignment_late"}),b.jsx("span",{className:"text",children:t("chat.todo.noTasks")})]})})}):b.jsxs("div",{className:`current-todo-container ${n?"expanded":""}`,children:[b.jsxs("div",{className:"todo-progress-bar",onClick:()=>r(!n),children:[b.jsxs("div",{className:"progress-info",children:[b.jsx("span",{className:"material-symbols-rounded",children:"assignment"}),b.jsx("span",{className:"text",children:t("chat.todo.progress",{completed:i,total:a})})]}),b.jsx("div",{className:"progress-track",children:b.jsx("div",{className:"progress-fill",style:{width:`${i/a*100}%`}})}),b.jsx("button",{className:"expand-btn",children:b.jsx("span",{className:"material-symbols-rounded",children:n?"expand_more":"expand_less"})})]}),n&&b.jsx("div",{className:"todo-items-overlay",children:b.jsx("div",{className:"todo-items-scroll-container",children:o.map((s,l)=>b.jsxs("div",{className:`todo-item-vertical status-${s.status}`,children:[b.jsx("span",{className:"material-symbols-rounded icon",children:s.status==="completed"?"check_circle":s.status==="in_progress"?"clock_loader_40":"radio_button_unchecked"}),b.jsxs("div",{className:"todo-content-wrapper",children:[b.jsx("span",{className:"text",children:s.content}),s.priority!=null&&s.priority!==""&&b.jsx("span",{className:`priority-tag ${s.priority}`,children:s.priority})]})]},s.id||l))})})]})}function TC({msg:e,isUser:t}){const{message:n}=_o.useApp();return b.jsxs("div",{className:"msg-footer",children:[t&&e.model!=null&&b.jsx("span",{className:"msg-model",children:e.model.split(",").pop()}),t&&e.usage!=null&&b.jsxs("span",{className:"msg-usage",children:["Tokens: ",e.usage.input_tokens+e.usage.output_tokens]}),b.jsx("span",{className:"timestamp",onDoubleClick:()=>{console.log("Debug Message:",e),navigator.clipboard.writeText(new Date(e.createdAt).toISOString()),n.success("ISO 时间已复制到剪贴板")},title:"双击复制 ISO 时间 (控制台打印消息结构)",children:new Date(e.createdAt).toLocaleString("zh-CN",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1})})]})}function wo({header:e,content:t,isError:n=!1,type:r="call",defaultExpanded:o=!1,collapsible:i=!0,onDoubleClick:a}){const[s,l]=u.useState(o||!i),c=!i||s;return b.jsxs("div",{className:`tool-call-box ${r==="result"?"result":""} ${c?"expanded":"collapsed"}`,onDoubleClick:d=>{a&&(d.stopPropagation(),a(d))},children:[b.jsxs("div",{className:`tool-call-header ${r==="result"&&n?"error":""}`,onClick:()=>i&&l(!s),children:[b.jsx("div",{className:"tool-call-header-main",children:e}),i&&b.jsx("span",{className:"material-symbols-rounded expand-icon",children:c?"expand_less":"expand_more"})]}),c&&b.jsx("div",{className:"tool-call-body",children:t})]})}function ts(e,t=new WeakSet){if(e==null)return e;const n=typeof e;if(n==="bigint"||n==="symbol")return e.toString();if(n==="function")return"[Function]";if(n!=="object")return e;if(e instanceof Date)return e.toISOString();if(e instanceof Error)return{name:e.name,message:e.message,stack:e.stack};if(e instanceof Map)return Array.from(e.entries()).map(([i,a])=>[ts(i,t),ts(a,t)]);if(e instanceof Set)return Array.from(e.values()).map(i=>ts(i,t));if(ArrayBuffer.isView(e))return Array.from(e);if(e instanceof ArrayBuffer)return Array.from(new Uint8Array(e));if(Array.isArray(e))return e.map(i=>ts(i,t));const r=e;if(t.has(r))return"[Circular]";if(t.add(r),typeof r.toJSON=="function")try{return ts(r.toJSON(),t)}catch{return String(r)}const o={};for(const[i,a]of Object.entries(r))o[i]=ts(a,t);return o}function ra(e,t=2){try{const n=ts(e);return JSON.stringify(n,null,t)??"null"}catch{return JSON.stringify(String(e))??"null"}}function twe(e){if(typeof e!="string")return e;const t=e.trim();if(t.startsWith("{")&&t.endsWith("}")||t.startsWith("[")&&t.endsWith("]"))try{return JSON.parse(t)}catch{return e}return e}function nwe(e){const t=typeof e.url=="string"?e.url:typeof e.src=="string"?e.src:typeof e.image_url=="string"?e.image_url:typeof e.imageUrl=="string"?e.imageUrl:typeof e.dataUrl=="string"?e.dataUrl:null;if(t)return t;const n=e.source!=null&&typeof e.source=="object"?e.source:null,r=typeof e.data=="string"?e.data:typeof e.base64=="string"?e.base64:n!=null&&typeof n.data=="string"?n.data:null;return r?`data:${typeof e.mimeType=="string"?e.mimeType:typeof e.mime_type=="string"?e.mime_type:n!=null&&typeof n.media_type=="string"?n.media_type:n!=null&&typeof n.mimeType=="string"?n.mimeType:n!=null&&typeof n.mime_type=="string"?n.mime_type:"image/png"};base64,${r}`:null}function _0(e){if(e==null||typeof e!="object")return null;const t=e,n=typeof t.type=="string"?t.type.toLowerCase():"";if(n==="text"||n==="markdown"||n==="md"){const r=typeof t.text=="string"?t.text:typeof t.content=="string"?t.content:null;if(r==null)return null;const o=typeof t.format=="string"?t.format.toLowerCase():"markdown";return{type:"text",text:r,format:n==="text"&&(o==="text"||o==="plain")?"text":"markdown"}}if(n==="image"){const r=nwe(t);if(!r)return null;const o=typeof t.alt=="string"?t.alt:void 0,i=typeof t.title=="string"?t.title:void 0,a=typeof t.width=="number"?t.width:void 0,s=typeof t.height=="number"?t.height:void 0;return{type:"image",src:r,alt:o,title:i,width:a,height:s}}return null}function rwe(e){const t=ts(e),n=twe(t);if(Array.isArray(n)){const o=n.map(_0);return o.every(Boolean)?o:null}if(n!=null&&typeof n=="object"){const o=n,i=o.content??o.items??o.blocks;if(Array.isArray(i)){const a=i.map(_0);return a.every(Boolean)?a:null}}const r=_0(n);return r?[r]:null}function owe({blocks:e}){return b.jsx("div",{className:"tool-result-structured",children:e.map((t,n)=>t.type==="text"?b.jsx("div",{className:"tool-result-text",children:t.format==="markdown"?b.jsx(Xi,{content:t.text}):b.jsx("div",{className:"tool-result-text-content",children:t.text})},`text-${n}`):b.jsxs("div",{className:"tool-result-image-wrapper",children:[b.jsx("img",{className:"tool-result-image",src:t.src,alt:t.alt??"",width:t.width,height:t.height}),t.title!=null&&t.title.length>0&&b.jsx("div",{className:"tool-result-image-caption",children:t.title})]},`image-${n}`))})}function iwe({item:e,resultItem:t}){const{t:n}=Ot(),r=t!=null?rwe(t.content):null;return b.jsxs("div",{className:"tool-group",children:[b.jsx(wo,{header:b.jsxs("div",{className:"tool-header-content",children:[b.jsx("span",{className:"material-symbols-rounded tool-header-icon",children:"build"}),b.jsx("span",{className:"tool-header-title",children:e.name}),b.jsx("span",{className:"tool-header-hint",children:n("chat.tools.call")})]}),content:b.jsx("div",{className:"tool-content",children:b.jsx(Co,{code:ra(e.input!=null?e.input:{},2),lang:"json"})})}),t!=null&&b.jsx(wo,{type:"result",isError:t.is_error,header:b.jsxs("div",{className:"tool-header-content",children:[b.jsx("span",{className:"material-symbols-rounded tool-header-icon",children:t.is_error===!0?"error":"check_circle"}),b.jsx("span",{className:"tool-header-title",children:n("chat.result")})]}),content:b.jsx("div",{className:"tool-content",children:r!=null?b.jsx(owe,{blocks:r}):typeof t.content=="string"?t.content.startsWith("```")?b.jsx(Xi,{content:t.content}):b.jsx(Co,{code:t.content,lang:"text"}):b.jsx(Co,{code:ra(t.content,2),lang:"json"})})})]})}function U1(e,t){const n=t==null?void 0:t.namespace,r=Object.entries(e).flatMap(([o,i])=>{const a=[[o,i]];return n&&a.push([`${n}${o}`,i]),a});return Object.fromEntries(r)}const GF=({item:e,resultItem:t})=>{const{t:n}=Ot(),r=e.input!=null?e.input:{},o=r.command??"",i=r.description!=null&&r.description!==""?r.description:r.reason!=null&&r.reason!==""?r.reason:r.thought!=null&&r.thought!==""?r.thought:"",a=r.timeout,s=r.run_in_background,l=r.dangerouslyDisableSandbox,c=i.replaceAll(`
|
|
500
|
+
\`\`\``})]})]})]}),b.jsxs("div",{className:"benchmark-view__section benchmark-view__task-goal",children:[b.jsx(ug,{icon:"assignment",title:a("benchmark.taskGoal")}),b.jsx("div",{className:"benchmark-view__goal-body",children:b.jsx(Xi,{content:e.rfcBody})})]})]}),b.jsx(nO,{className:"benchmark-view__sep"}),b.jsxs("div",{className:"benchmark-view__twin-grid benchmark-view__section--last",children:[b.jsx(QSe,{activeRunId:r,activeRun:n,progressPercent:o,t:a}),b.jsx(ZSe,{latestResult:t,t:a})]})]})}function QSe({activeRunId:e,activeRun:t,progressPercent:n,t:r}){return b.jsxs("div",{className:"benchmark-view__section",children:[b.jsx(ug,{icon:"pulse_alert",title:r("benchmark.runState"),extra:t?b.jsx(Lo,{children:t.status}):null}),e===""?b.jsx(ao.Text,{type:"secondary",className:"benchmark-view__hint",children:r("benchmark.noActiveRun")}):b.jsxs("div",{className:"benchmark-view__run-block",children:[b.jsxs("div",{className:"benchmark-view__run-metric",children:[b.jsx("label",{children:r("benchmark.progress")}),b.jsx("strong",{children:`${(t==null?void 0:t.completedCount)??0}/${(t==null?void 0:t.totalCount)??"-"}`})]}),b.jsx(Loe,{percent:n,showInfo:!1}),b.jsxs("div",{className:"benchmark-view__info-grid",children:[b.jsxs("div",{className:"benchmark-view__info-row",children:[b.jsx("label",{children:r("benchmark.runStatus")}),b.jsx("span",{children:(t==null?void 0:t.status)??"-"})]}),b.jsxs("div",{className:"benchmark-view__info-row",children:[b.jsx("label",{children:r("benchmark.lastMessage")}),b.jsx(ao.Text,{children:(t==null?void 0:t.lastMessage)??"-"})]})]})]})]})}function ZSe({latestResult:e,t}){return b.jsxs("div",{className:"benchmark-view__section",children:[b.jsx(ug,{icon:"insights",title:t("benchmark.resultTitle"),extra:e?b.jsx(XSe,{result:e}):null}),e==null?b.jsx(ao.Text,{type:"secondary",className:"benchmark-view__hint",children:t("benchmark.noResult")}):b.jsxs("div",{className:"benchmark-view__result",children:[b.jsxs("div",{className:"benchmark-view__score-strip",children:[b.jsxs("div",{className:"benchmark-view__score-item",children:[b.jsx("label",{children:t("benchmark.finalScore")}),b.jsx("strong",{children:e.finalScore})]}),b.jsxs("div",{className:"benchmark-view__score-item",children:[b.jsx("label",{children:t("benchmark.testScore")}),b.jsx("strong",{children:e.scores.testScore})]}),b.jsxs("div",{className:"benchmark-view__score-item",children:[b.jsx("label",{children:t("benchmark.goalScore")}),b.jsx("strong",{children:e.scores.goalScore})]}),b.jsxs("div",{className:"benchmark-view__score-item",children:[b.jsx("label",{children:t("benchmark.referenceScore")}),b.jsx("strong",{children:e.scores.referenceScore})]})]}),b.jsxs("div",{className:"benchmark-view__info-grid",children:[b.jsxs("div",{className:"benchmark-view__info-row",children:[b.jsxs("label",{children:[b.jsx("span",{className:"material-symbols-rounded",children:"schedule"}),t("benchmark.durationMs")]}),b.jsx("span",{children:e.durationMs})]}),b.jsxs("div",{className:"benchmark-view__info-row",children:[b.jsxs("label",{children:[b.jsx("span",{className:"material-symbols-rounded",children:"monitoring"}),t("benchmark.testExitCode")]}),b.jsx("span",{children:e.testExitCode})]})]}),b.jsx(ao.Paragraph,{className:"benchmark-view__judge-summary",children:e.judgeSummary}),b.jsxs("div",{className:"benchmark-view__subgrid",children:[b.jsxs("div",{className:"benchmark-view__subpanel",children:[b.jsxs("div",{className:"benchmark-view__subpanel-title",children:[b.jsx("span",{className:"material-symbols-rounded",children:"plagiarism"}),b.jsx("span",{children:t("benchmark.changedFiles")})]}),e.changedFiles!=null&&e.changedFiles.length>0?b.jsx("div",{className:"benchmark-view__file-list",children:e.changedFiles.map(n=>b.jsx("span",{className:"benchmark-view__file-tag",children:n},n))}):b.jsx(ao.Text,{type:"secondary",children:t("benchmark.noChangedFiles")})]}),b.jsxs("div",{className:"benchmark-view__subpanel",children:[b.jsxs("div",{className:"benchmark-view__subpanel-title",children:[b.jsx("span",{className:"material-symbols-rounded",children:"report"}),b.jsx("span",{children:t("benchmark.issues")})]}),e.issues.length===0?b.jsx(ao.Text,{type:"secondary",children:t("benchmark.noIssues")}):b.jsx("ul",{className:"benchmark-view__issues-list",children:e.issues.map(n=>b.jsx("li",{children:n},n))})]})]})]})]})}function JSe({result:e}){const t=AF(e);return b.jsx("span",{className:`material-symbols-rounded benchmark-view__status-icon benchmark-view__status-icon--${t.statusKey}`,children:t.icon})}function eCe(e){const{categories:t,cases:n,query:r,t:o,onRunCase:i,onRunCategory:a}=e,s=r.trim().toLowerCase();return(t.length>0?t:Array.from(new Set(n.map(c=>c.category))).map(c=>({category:c,caseCount:n.filter(d=>d.category===c).length,lastStatuses:{pass:0,partial:0,fail:0}}))).map(c=>{const d=n.filter(p=>p.category===c.category),m=s===""||c.category.toLowerCase().includes(s)?d:d.filter(p=>{const h=p.frontmatter.title??"";return p.title.toLowerCase().includes(s)||h.toLowerCase().includes(s)});return m.length===0?null:{key:`category:${c.category}`,selectable:!0,title:b.jsxs("div",{className:"benchmark-view__tree-category",children:[b.jsx("span",{className:"material-symbols-rounded benchmark-view__tree-icon benchmark-view__tree-icon--category",children:"folder_open"}),b.jsx(ao.Text,{strong:!0,className:"benchmark-view__tree-title",children:c.category}),b.jsx(ht,{title:o("benchmark.runCategory"),children:b.jsx(lt,{type:"text",size:"small",className:"benchmark-view__tree-run-btn benchmark-view__tree-run-btn--category",icon:b.jsx("span",{className:"material-symbols-rounded",children:"play_circle"}),onClick:p=>{p.stopPropagation(),a(c.category)}})})]}),children:m.map(p=>{const h={...p,key:`case:${p.category}/${p.title}`},y=p.frontmatter.title??p.title;return{key:h.key,isLeaf:!0,title:b.jsxs("div",{className:"benchmark-view__tree-case",children:[b.jsx(JSe,{result:h.latestResult}),b.jsx("span",{className:"material-symbols-rounded benchmark-view__tree-icon",children:"draft"}),b.jsx(ao.Text,{className:"benchmark-view__tree-title",children:y}),b.jsx(ht,{title:o("benchmark.runCase"),children:b.jsx(lt,{type:"text",size:"small",className:"benchmark-view__tree-run-btn",icon:b.jsx("span",{className:"material-symbols-rounded",children:"play_circle"}),onClick:x=>{x.stopPropagation(),i(p)}})})]}),caseData:h}})}}).filter(Boolean)}function tCe({cases:e,categories:t,selectedCase:n,query:r,expandedKeys:o,checkedKeys:i,checkedCaseCount:a,onQueryChange:s,onExpandedKeysChange:l,onCheckedKeysChange:c,onSelectCase:d,onRunCase:f,onRunCategory:m,onBatchRun:p}){const{t:h}=Ot(),y=u.useMemo(()=>eCe({categories:t,cases:e,query:r,t:h,onRunCase:f,onRunCategory:m}),[e,t,r,h]),x=v=>{const S=Array.isArray(v)?v:v.checked;c(S.map(String))},g=(v,S)=>{const C=S.node.caseData;if(C!=null){d(C.category,C.title);return}const _=String(S.node.key);if(!_.startsWith("category:"))return;const w=_.replace("category:",""),N=e.find(k=>k.category===w);d(w,(N==null?void 0:N.title)??"")};return b.jsxs("div",{className:"benchmark-view__sidebar",children:[b.jsx("div",{className:"benchmark-view__sidebar-header",children:b.jsx(ao.Title,{level:4,className:"benchmark-view__sidebar-title",children:h("benchmark.title")})}),b.jsxs("div",{className:"benchmark-view__search-row",children:[b.jsx(Ft,{value:r,placeholder:h("benchmark.searchPlaceholder"),prefix:b.jsx("span",{className:"material-symbols-rounded benchmark-view__search-icon",children:"search"}),allowClear:!0,onChange:v=>s(v.target.value),className:"benchmark-view__search"}),b.jsx(ht,{title:h("benchmark.expandAll"),children:b.jsx(lt,{type:"text",size:"small",icon:b.jsx("span",{className:"material-symbols-rounded",children:"unfold_more"}),onClick:()=>l(t.map(v=>`category:${v.category}`))})}),b.jsx(ht,{title:h("benchmark.collapseAll"),children:b.jsx(lt,{type:"text",size:"small",icon:b.jsx("span",{className:"material-symbols-rounded",children:"unfold_less"}),onClick:()=>l([])})}),b.jsx(ht,{title:a>0?h("benchmark.runSelected",{count:a}):h("benchmark.runAll"),children:b.jsx(C_,{count:a,size:"small",children:b.jsx(lt,{type:"text",size:"small",icon:b.jsx("span",{className:"material-symbols-rounded",children:"play_circle"}),onClick:p})})})]}),b.jsx("div",{className:"benchmark-view__tree-shell",children:y.length===0?b.jsx("div",{className:"benchmark-view__tree-empty",children:b.jsx(yn,{description:h("benchmark.emptyCases"),image:yn.PRESENTED_IMAGE_SIMPLE})}):b.jsx(Dv,{blockNode:!0,checkable:!0,showIcon:!1,switcherIcon:b.jsx("span",{className:"material-symbols-rounded benchmark-view__switcher",children:"chevron_right"}),selectedKeys:n?[`case:${n.category}/${n.title}`]:[],expandedKeys:o,checkedKeys:i,treeData:y,onExpand:v=>l(v.map(String)),onSelect:g,onCheck:x})})]})}function nCe(){const{t:e}=Ot(),{message:t}=_o.useApp(),[n,r]=u.useState(""),[o,i]=u.useState(""),[a,s]=u.useState([]),[l,c]=u.useState([]),{values:d,update:f}=Ru({keys:["category","title"],defaults:{category:"",title:""},omit:{category:I=>I==="",title:I=>I===""}}),{data:m,mutate:p}=zn("/api/benchmark/categories",yfe),h=(m==null?void 0:m.categories)??[],{data:y,mutate:x}=zn("/api/benchmark/cases",()=>bfe()),g=(y==null?void 0:y.cases)??[],v=u.useMemo(()=>{if(g.length===0)return null;const I=g.find(M=>M.category===d.category&&M.title===d.title);return I||((d.category?g.find(M=>M.category===d.category)??null:null)??g[0]??null)},[g,d.category,d.title]),{data:S,mutate:C}=zn(v?`/api/benchmark/results/${v.category}/${v.title}`:null,()=>xfe((v==null?void 0:v.category)??"",(v==null?void 0:v.title)??"")),_=(S==null?void 0:S.result)??(v==null?void 0:v.latestResult)??null,{data:w,mutate:N}=zn(n?`/api/benchmark/runs/${n}`:null,()=>Sfe(n),{refreshInterval:n?2e3:0}),k=w==null?void 0:w.run,E=u.useMemo(()=>{const I=(k==null?void 0:k.totalCount)??0;if(I<=0)return 0;const T=(k==null?void 0:k.completedCount)??0;return Math.min(100,Math.round(T/I*100))},[k==null?void 0:k.completedCount,k==null?void 0:k.totalCount]),$=u.useCallback(async I=>{try{const T=await ep({category:I.category,title:I.title});r(T.run.runId),t.success(e("benchmark.runStarted"))}catch(T){t.error(jr(T,e("benchmark.runFailed")))}},[t,e]),O=u.useCallback(async I=>{try{const T=await ep({category:I});r(T.run.runId),t.success(e("benchmark.categoryRunStarted"))}catch(T){t.error(jr(T,e("benchmark.runFailed")))}},[t,e]),R=u.useCallback(async()=>{const I=l.filter(L=>L.startsWith("case:")),T=g.filter(L=>I.includes(`case:${L.category}/${L.title}`));if(T.length===0){for(const L of g)try{await ep({category:L.category,title:L.title})}catch{}t.success(e("benchmark.runStarted"));return}let M=0;for(const L of T)try{await ep({category:L.category,title:L.title}),M++}catch{}M>0&&(c([]),x(),p(),t.success(e("benchmark.runStarted")))},[l,g,x,p,t,e]);u.useEffect(()=>{const I=h.map(T=>`category:${T.category}`);s(T=>T.length>0&&o.trim()===""?T:I)},[h,o]),u.useEffect(()=>{v!=null&&(d.category!==v.category||d.title!==v.title)&&f({category:v.category,title:v.title})},[v,f,d.category,d.title]),u.useEffect(()=>{if(!GSe(k))return;x(),p(),C(),n!==""&&N();const I=(k==null?void 0:k.status)==="completed"?e("benchmark.runCompleted"):e("benchmark.runFailed");t.info(I),r("")},[k,n,t,x,p,C,N,e]);const P=l.filter(I=>I.startsWith("case:")).length;return b.jsxs("div",{className:"benchmark-view",children:[b.jsx("div",{className:"benchmark-view__left",children:b.jsx(tCe,{cases:g,categories:h,selectedCase:v,query:o,expandedKeys:a,checkedKeys:l,checkedCaseCount:P,onQueryChange:i,onExpandedKeysChange:s,onCheckedKeysChange:c,onSelectCase:(I,T)=>f({category:I,title:T}),onRunCase:I=>void $(I),onRunCategory:I=>void O(I),onBatchRun:()=>void R()})}),b.jsx("div",{className:"benchmark-view__divider"}),b.jsx("div",{className:"benchmark-view__right",children:b.jsx(YSe,{selectedCase:v,latestResult:_,activeRun:k,activeRunId:n,progressPercent:E,onRunCase:()=>void(v&&$(v))})})]})}function rCe(){return b.jsx(nCe,{})}const oCe=({value:e})=>{const{t}=Ot(),n=e!=null&&typeof e=="object"?e:void 0,r=n==null?void 0:n.urls,o=n==null?void 0:n.version,i=n==null?void 0:n.lastReleaseAt;return b.jsxs("div",{className:"config-about",children:[b.jsxs("div",{className:"config-about__card",children:[b.jsxs("div",{className:"config-about__app",children:[b.jsx("div",{className:"config-about__app-icon",children:b.jsx("span",{className:"material-symbols-rounded",children:"auto_awesome"})}),b.jsxs("div",{className:"config-about__app-info",children:[b.jsx("div",{className:"config-about__app-title",children:t("config.about.software")}),b.jsxs("div",{className:"config-about__app-meta",children:[b.jsxs("span",{className:"config-about__app-version",children:[t("config.about.version"),": ",o??t("config.about.unknown")]}),b.jsx("span",{className:"config-about__app-date",children:i??t("config.about.unknown")})]})]})]}),b.jsx("a",{className:"config-about__primary",href:(r==null?void 0:r.releases)??(r==null?void 0:r.repo),target:"_blank",rel:"noreferrer",children:t("config.about.checkUpdate")})]}),b.jsxs("div",{className:"config-about__list",children:[b.jsxs("a",{className:"config-about__item-row",href:(r==null?void 0:r.docs)??(r==null?void 0:r.repo),target:"_blank",rel:"noreferrer",children:[b.jsxs("span",{className:"config-about__item-left",children:[b.jsx("span",{className:"material-symbols-rounded config-about__item-icon",children:"menu_book"}),b.jsx("span",{children:t("config.about.docs")})]}),b.jsx("span",{className:"material-symbols-rounded config-about__arrow",children:"open_in_new"})]}),b.jsxs("a",{className:"config-about__item-row",href:(r==null?void 0:r.contact)??(r==null?void 0:r.repo),target:"_blank",rel:"noreferrer",children:[b.jsxs("span",{className:"config-about__item-left",children:[b.jsx("span",{className:"material-symbols-rounded config-about__item-icon",children:"mail"}),b.jsx("span",{children:t("config.about.contact")})]}),b.jsx("span",{className:"material-symbols-rounded config-about__arrow",children:"open_in_new"})]}),b.jsxs("a",{className:"config-about__item-row",href:(r==null?void 0:r.issues)??(r==null?void 0:r.repo),target:"_blank",rel:"noreferrer",children:[b.jsxs("span",{className:"config-about__item-left",children:[b.jsx("span",{className:"material-symbols-rounded config-about__item-icon",children:"bug_report"}),b.jsx("span",{children:t("config.about.feedback")})]}),b.jsx("span",{className:"material-symbols-rounded config-about__arrow",children:"open_in_new"})]})]})]})},Pn=({title:e,description:t,icon:n,layout:r="inline",children:o})=>b.jsxs("div",{className:`config-view__field-row${r==="stacked"?" config-view__field-row--stacked":""}`,children:[b.jsxs("div",{className:"config-view__field-meta",children:[n!=null&&b.jsx("span",{className:"material-symbols-rounded config-view__field-icon",children:n}),b.jsxs("div",{className:"config-view__field-text",children:[b.jsx("div",{className:"config-view__field-title",children:e}),t!=null&&t!==""&&b.jsx("div",{className:"config-view__field-desc",children:t})]})]}),b.jsx("div",{className:"config-view__field-control",children:o})]}),dg=e=>e==null?!0:Array.isArray(e)?e.length===0:typeof e=="object"?Object.keys(e).length===0:!1,cp=e=>e==null?e:JSON.parse(JSON.stringify(e)),LF=e=>Array.isArray(e)?"array":e!=null&&typeof e=="object"?"object":typeof e=="number"?"number":typeof e=="boolean"?"boolean":"string",An=e=>e==="string"?"text_fields":e==="number"?"numbers":e==="boolean"?"toggle_on":e==="array"?"view_list":"account_tree",DF=(e,t,n,r)=>{if(n.length===0)return r;const o=`config.fields.${t}.${n.join(".")}.label`;return e(o,{defaultValue:r})},zF=(e,t,n)=>{if(n.length===0)return"";const r=`config.fields.${t}.${n.join(".")}.desc`;return e(r,{defaultValue:""})},BF=e=>/key|token|secret|password/i.test(e),Kp=(e,t)=>{if(t.length===0)return e;let n=e;for(const r of t){if(n==null||typeof n!="object")return;n=n[r]}return n},UR=(e,t,n)=>{if(t.length===0)return n;const r=e!=null&&typeof e=="object"&&!Array.isArray(e)?{...e}:{};let o=r;for(let i=0;i<t.length-1;i+=1){const a=t[i],s=o[a],l=s!=null&&typeof s=="object"&&!Array.isArray(s)?{...s}:{};o[a]=l,o=l}return o[t[t.length-1]]=n,r},FF=({value:e,sectionKey:t,path:n=[],t:r})=>dg(e)?b.jsx(yn,{description:r("common.noData"),image:null}):Array.isArray(e)?e.some(i=>i!=null&&typeof i=="object")?b.jsx("span",{className:"config-view__pill",children:r("config.editor.complexValue")}):b.jsx("div",{className:"config-view__display-pill",children:e.map((i,a)=>b.jsx("span",{className:"config-view__pill",children:String(i)},`${a}-${String(i)}`))}):e!=null&&typeof e=="object"?b.jsx("div",{className:"config-view__field-list",children:Object.entries(e).map(([o,i])=>{const a=DF(r,t,[...n,o],o),s=zF(r,t,[...n,o]);return b.jsx(Pn,{title:a,description:s,icon:An(LF(i)),children:b.jsx(FF,{value:i,sectionKey:t,path:[...n,o],t:r})},o)})}):b.jsx("span",{className:"config-view__pill",children:String(e)}),eu=({value:e,onChange:t})=>{const{message:n}=_o.useApp(),{t:r}=Ot(),[o,i]=u.useState(()=>JSON.stringify(e??{},null,2));return u.useEffect(()=>{i(JSON.stringify(e??{},null,2))},[e]),b.jsx(Ft.TextArea,{className:"config-view__complex-editor",value:o,onChange:a=>{i(a.target.value)},onBlur:()=>{try{const a=JSON.parse(o);t==null||t(a),i(JSON.stringify(a??{},null,2))}catch{n.error(r("config.invalidJson")),i(JSON.stringify(e??{},null,2))}},placeholder:r("config.editor.complexPlaceholder"),autoSize:{minRows:6}})},cy=({value:e,onChange:t,t:n})=>b.jsxs("div",{className:"config-view__array-list",children:[e.map((r,o)=>b.jsxs("div",{className:"config-view__array-item",children:[b.jsx(Ft,{value:r,placeholder:n("config.editor.itemPlaceholder"),onChange:i=>{const a=e.slice();a[o]=i.target.value,t(a)}}),b.jsx(ht,{title:n("config.editor.remove"),children:b.jsx(lt,{size:"small",type:"text",danger:!0,className:"config-view__icon-button config-view__icon-button--compact","aria-label":n("config.editor.remove"),icon:b.jsx("span",{className:"material-symbols-rounded",children:"delete"}),onClick:()=>{const i=e.slice();i.splice(o,1),t(i)}})})]},`${o}-${r}`)),b.jsx(ht,{title:n("config.editor.addItem"),children:b.jsx(lt,{size:"small",type:"primary",className:"config-view__icon-button config-view__icon-button--full","aria-label":n("config.editor.addItem"),icon:b.jsx("span",{className:"material-symbols-rounded",children:"add"}),onClick:()=>{t([...e,""])}})})]}),iCe=({value:e,onChange:t,placeholder:n,isMac:r,t:o})=>{const i=e.trim()===""?"":Uz(e,r);return b.jsxs("div",{className:"config-shortcut-input",children:[b.jsx(Ft,{value:i,placeholder:n,readOnly:!0,onKeyDown:a=>{if(a.key==="Backspace"||a.key==="Delete"){a.preventDefault(),t("");return}const s=kfe(a);s!=null&&(a.preventDefault(),t(s))}}),b.jsx(ht,{title:o("config.editor.clearShortcut"),children:b.jsx(lt,{size:"small",type:"text",className:"config-view__icon-button config-view__icon-button--compact","aria-label":o("config.editor.clearShortcut"),icon:b.jsx("span",{className:"material-symbols-rounded",children:"close"}),onClick:()=>t("")})})]})},aCe={general:{items:{labelKey:"config.fields.general.notifications.label"}}},sCe={general:[{path:["baseDir"],type:"string",defaultValue:".ai",icon:"folder",group:"base"},{path:["defaultAdapter"],type:"select",defaultValue:"",icon:"settings_input_component",group:"base"},{path:["defaultModelService"],type:"select",defaultValue:"",icon:"hub",group:"base"},{path:["defaultModel"],type:"select",defaultValue:"",icon:"model_training",group:"base"},{path:["recommendedModels"],type:"json",defaultValue:[],icon:"stars",group:"base"},{path:["interfaceLanguage"],type:"select",defaultValue:"",icon:"language",group:"base",options:[{value:"zh",label:"config.options.language.zh"},{value:"en",label:"config.options.language.en"}]},{path:["modelLanguage"],type:"select",defaultValue:"",icon:"translate",group:"base",options:[{value:"zh",label:"config.options.language.zh"},{value:"en",label:"config.options.language.en"}]},{path:["announcements"],type:"string[]",defaultValue:[],icon:"campaign",group:"base"},{path:["permissions","allow"],type:"string[]",defaultValue:[],icon:"check_circle",group:"permissions"},{path:["permissions","deny"],type:"string[]",defaultValue:[],icon:"block",group:"permissions"},{path:["permissions","ask"],type:"string[]",defaultValue:[],icon:"help",group:"permissions"},{path:["env"],type:"record",recordKind:"keyValue",defaultValue:{},icon:"terminal",group:"env"},{path:["notifications","disabled"],type:"boolean",defaultValue:!1,icon:"notifications",group:"items"},{path:["notifications","volume"],type:"number",defaultValue:100,icon:"volume_down",group:"items"},{path:["notifications","events","completed","title"],type:"string",defaultValue:"",icon:"title",group:"items",collapse:{key:"notifications.events.completed",labelKey:"config.fields.general.notifications.events.completed.label",descKey:"config.fields.general.notifications.events.completed.desc",togglePath:["notifications","events","completed","disabled"]}},{path:["notifications","events","completed","description"],type:"multiline",defaultValue:"",icon:"notes",group:"items",collapse:{key:"notifications.events.completed",labelKey:"config.fields.general.notifications.events.completed.label",descKey:"config.fields.general.notifications.events.completed.desc",togglePath:["notifications","events","completed","disabled"]}},{path:["notifications","events","completed","sound"],type:"string",defaultValue:"",icon:"volume_up",group:"items",collapse:{key:"notifications.events.completed",labelKey:"config.fields.general.notifications.events.completed.label",descKey:"config.fields.general.notifications.events.completed.desc",togglePath:["notifications","events","completed","disabled"]}},{path:["notifications","events","failed","title"],type:"string",defaultValue:"",icon:"title",group:"items",collapse:{key:"notifications.events.failed",labelKey:"config.fields.general.notifications.events.failed.label",descKey:"config.fields.general.notifications.events.failed.desc",togglePath:["notifications","events","failed","disabled"]}},{path:["notifications","events","failed","description"],type:"multiline",defaultValue:"",icon:"notes",group:"items",collapse:{key:"notifications.events.failed",labelKey:"config.fields.general.notifications.events.failed.label",descKey:"config.fields.general.notifications.events.failed.desc",togglePath:["notifications","events","failed","disabled"]}},{path:["notifications","events","failed","sound"],type:"string",defaultValue:"",icon:"volume_up",group:"items",collapse:{key:"notifications.events.failed",labelKey:"config.fields.general.notifications.events.failed.label",descKey:"config.fields.general.notifications.events.failed.desc",togglePath:["notifications","events","failed","disabled"]}},{path:["notifications","events","terminated","title"],type:"string",defaultValue:"",icon:"title",group:"items",collapse:{key:"notifications.events.terminated",labelKey:"config.fields.general.notifications.events.terminated.label",descKey:"config.fields.general.notifications.events.terminated.desc",togglePath:["notifications","events","terminated","disabled"]}},{path:["notifications","events","terminated","description"],type:"multiline",defaultValue:"",icon:"notes",group:"items",collapse:{key:"notifications.events.terminated",labelKey:"config.fields.general.notifications.events.terminated.label",descKey:"config.fields.general.notifications.events.terminated.desc",togglePath:["notifications","events","terminated","disabled"]}},{path:["notifications","events","terminated","sound"],type:"string",defaultValue:"",icon:"volume_up",group:"items",collapse:{key:"notifications.events.terminated",labelKey:"config.fields.general.notifications.events.terminated.label",descKey:"config.fields.general.notifications.events.terminated.desc",togglePath:["notifications","events","terminated","disabled"]}},{path:["notifications","events","waiting_input","title"],type:"string",defaultValue:"",icon:"title",group:"items",collapse:{key:"notifications.events.waiting_input",labelKey:"config.fields.general.notifications.events.waiting_input.label",descKey:"config.fields.general.notifications.events.waiting_input.desc",togglePath:["notifications","events","waiting_input","disabled"]}},{path:["notifications","events","waiting_input","description"],type:"multiline",defaultValue:"",icon:"notes",group:"items",collapse:{key:"notifications.events.waiting_input",labelKey:"config.fields.general.notifications.events.waiting_input.label",descKey:"config.fields.general.notifications.events.waiting_input.desc",togglePath:["notifications","events","waiting_input","disabled"]}},{path:["notifications","events","waiting_input","sound"],type:"string",defaultValue:"",icon:"volume_up",group:"items",collapse:{key:"notifications.events.waiting_input",labelKey:"config.fields.general.notifications.events.waiting_input.label",descKey:"config.fields.general.notifications.events.waiting_input.desc",togglePath:["notifications","events","waiting_input","disabled"]}}],conversation:[{path:["style"],type:"select",defaultValue:"friendly",icon:"forum",options:[{value:"friendly",label:"config.options.conversation.friendly"},{value:"programmatic",label:"config.options.conversation.programmatic"}]},{path:["customInstructions"],type:"multiline",defaultValue:"",icon:"description"}],modelServices:[{path:[],type:"record",recordKind:"modelServices",defaultValue:{},icon:"hub"}],channels:[{path:[],type:"record",recordKind:"channels",defaultValue:{},icon:"campaign"}],adapters:[{path:[],type:"record",recordKind:"json",defaultValue:{},icon:"settings_input_component"}],plugins:[{path:["plugins"],type:"record",recordKind:"json",defaultValue:{},icon:"extension"},{path:["enabledPlugins"],type:"record",recordKind:"boolean",defaultValue:{},group:"base",icon:"toggle_on",labelKey:"config.fields.plugins.enabled.label",descriptionKey:"config.fields.plugins.enabled.desc"},{path:["extraKnownMarketplaces"],type:"record",recordKind:"json",defaultValue:{},group:"base",icon:"storefront",labelKey:"config.fields.plugins.marketplaces.label",descriptionKey:"config.fields.plugins.marketplaces.desc"}],mcp:[{path:["defaultIncludeMcpServers"],type:"string[]",defaultValue:[],group:"base",icon:"playlist_add"},{path:["defaultExcludeMcpServers"],type:"string[]",defaultValue:[],group:"base",icon:"playlist_remove"},{path:["noDefaultVibeForgeMcpServer"],type:"boolean",defaultValue:!1,group:"base",icon:"block"},{path:["mcpServers"],type:"record",recordKind:"mcpServers",defaultValue:{},icon:"account_tree"}],shortcuts:[{path:["newSession"],type:"shortcut",defaultValue:"",icon:"add_comment"},{path:["openConfig"],type:"shortcut",defaultValue:"",icon:"settings"},{path:["sendMessage"],type:"shortcut",defaultValue:"",icon:"send"},{path:["clearInput"],type:"shortcut",defaultValue:"",icon:"clear"}]};var pn;(function(e){e.assertEqual=o=>{};function t(o){}e.assertIs=t;function n(o){throw new Error}e.assertNever=n,e.arrayToEnum=o=>{const i={};for(const a of o)i[a]=a;return i},e.getValidEnumValues=o=>{const i=e.objectKeys(o).filter(s=>typeof o[o[s]]!="number"),a={};for(const s of i)a[s]=o[s];return e.objectValues(a)},e.objectValues=o=>e.objectKeys(o).map(function(i){return o[i]}),e.objectKeys=typeof Object.keys=="function"?o=>Object.keys(o):o=>{const i=[];for(const a in o)Object.prototype.hasOwnProperty.call(o,a)&&i.push(a);return i},e.find=(o,i)=>{for(const a of o)if(i(a))return a},e.isInteger=typeof Number.isInteger=="function"?o=>Number.isInteger(o):o=>typeof o=="number"&&Number.isFinite(o)&&Math.floor(o)===o;function r(o,i=" | "){return o.map(a=>typeof a=="string"?`'${a}'`:a).join(i)}e.joinValues=r,e.jsonStringifyReplacer=(o,i)=>typeof i=="bigint"?i.toString():i})(pn||(pn={}));var GR;(function(e){e.mergeShapes=(t,n)=>({...t,...n})})(GR||(GR={}));const Et=pn.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),es=e=>{switch(typeof e){case"undefined":return Et.undefined;case"string":return Et.string;case"number":return Number.isNaN(e)?Et.nan:Et.number;case"boolean":return Et.boolean;case"function":return Et.function;case"bigint":return Et.bigint;case"symbol":return Et.symbol;case"object":return Array.isArray(e)?Et.array:e===null?Et.null:e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?Et.promise:typeof Map<"u"&&e instanceof Map?Et.map:typeof Set<"u"&&e instanceof Set?Et.set:typeof Date<"u"&&e instanceof Date?Et.date:Et.object;default:return Et.unknown}},tt=pn.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);class ja extends Error{get errors(){return this.issues}constructor(t){super(),this.issues=[],this.addIssue=r=>{this.issues=[...this.issues,r]},this.addIssues=(r=[])=>{this.issues=[...this.issues,...r]};const n=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,n):this.__proto__=n,this.name="ZodError",this.issues=t}format(t){const n=t||function(i){return i.message},r={_errors:[]},o=i=>{for(const a of i.issues)if(a.code==="invalid_union")a.unionErrors.map(o);else if(a.code==="invalid_return_type")o(a.returnTypeError);else if(a.code==="invalid_arguments")o(a.argumentsError);else if(a.path.length===0)r._errors.push(n(a));else{let s=r,l=0;for(;l<a.path.length;){const c=a.path[l];l===a.path.length-1?(s[c]=s[c]||{_errors:[]},s[c]._errors.push(n(a))):s[c]=s[c]||{_errors:[]},s=s[c],l++}}};return o(this),r}static assert(t){if(!(t instanceof ja))throw new Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,pn.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(t=n=>n.message){const n={},r=[];for(const o of this.issues)if(o.path.length>0){const i=o.path[0];n[i]=n[i]||[],n[i].push(t(o))}else r.push(t(o));return{formErrors:r,fieldErrors:n}}get formErrors(){return this.flatten()}}ja.create=e=>new ja(e);const $C=(e,t)=>{let n;switch(e.code){case tt.invalid_type:e.received===Et.undefined?n="Required":n=`Expected ${e.expected}, received ${e.received}`;break;case tt.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(e.expected,pn.jsonStringifyReplacer)}`;break;case tt.unrecognized_keys:n=`Unrecognized key(s) in object: ${pn.joinValues(e.keys,", ")}`;break;case tt.invalid_union:n="Invalid input";break;case tt.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${pn.joinValues(e.options)}`;break;case tt.invalid_enum_value:n=`Invalid enum value. Expected ${pn.joinValues(e.options)}, received '${e.received}'`;break;case tt.invalid_arguments:n="Invalid function arguments";break;case tt.invalid_return_type:n="Invalid function return type";break;case tt.invalid_date:n="Invalid date";break;case tt.invalid_string:typeof e.validation=="object"?"includes"in e.validation?(n=`Invalid input: must include "${e.validation.includes}"`,typeof e.validation.position=="number"&&(n=`${n} at one or more positions greater than or equal to ${e.validation.position}`)):"startsWith"in e.validation?n=`Invalid input: must start with "${e.validation.startsWith}"`:"endsWith"in e.validation?n=`Invalid input: must end with "${e.validation.endsWith}"`:pn.assertNever(e.validation):e.validation!=="regex"?n=`Invalid ${e.validation}`:n="Invalid";break;case tt.too_small:e.type==="array"?n=`Array must contain ${e.exact?"exactly":e.inclusive?"at least":"more than"} ${e.minimum} element(s)`:e.type==="string"?n=`String must contain ${e.exact?"exactly":e.inclusive?"at least":"over"} ${e.minimum} character(s)`:e.type==="number"?n=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:e.type==="bigint"?n=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:e.type==="date"?n=`Date must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(e.minimum))}`:n="Invalid input";break;case tt.too_big:e.type==="array"?n=`Array must contain ${e.exact?"exactly":e.inclusive?"at most":"less than"} ${e.maximum} element(s)`:e.type==="string"?n=`String must contain ${e.exact?"exactly":e.inclusive?"at most":"under"} ${e.maximum} character(s)`:e.type==="number"?n=`Number must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="bigint"?n=`BigInt must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="date"?n=`Date must be ${e.exact?"exactly":e.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(e.maximum))}`:n="Invalid input";break;case tt.custom:n="Invalid input";break;case tt.invalid_intersection_types:n="Intersection results could not be merged";break;case tt.not_multiple_of:n=`Number must be a multiple of ${e.multipleOf}`;break;case tt.not_finite:n="Number must be finite";break;default:n=t.defaultError,pn.assertNever(e)}return{message:n}};let lCe=$C;function cCe(){return lCe}const uCe=e=>{const{data:t,path:n,errorMaps:r,issueData:o}=e,i=[...n,...o.path||[]],a={...o,path:i};if(o.message!==void 0)return{...o,path:i,message:o.message};let s="";const l=r.filter(c=>!!c).slice().reverse();for(const c of l)s=c(a,{data:t,defaultError:s}).message;return{...o,path:i,message:s}};function xt(e,t){const n=cCe(),r=uCe({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,n,n===$C?void 0:$C].filter(o=>!!o)});e.common.issues.push(r)}class co{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(t,n){const r=[];for(const o of n){if(o.status==="aborted")return Wt;o.status==="dirty"&&t.dirty(),r.push(o.value)}return{status:t.value,value:r}}static async mergeObjectAsync(t,n){const r=[];for(const o of n){const i=await o.key,a=await o.value;r.push({key:i,value:a})}return co.mergeObjectSync(t,r)}static mergeObjectSync(t,n){const r={};for(const o of n){const{key:i,value:a}=o;if(i.status==="aborted"||a.status==="aborted")return Wt;i.status==="dirty"&&t.dirty(),a.status==="dirty"&&t.dirty(),i.value!=="__proto__"&&(typeof a.value<"u"||o.alwaysSet)&&(r[i.value]=a.value)}return{status:t.value,value:r}}}const Wt=Object.freeze({status:"aborted"}),fd=e=>({status:"dirty",value:e}),fi=e=>({status:"valid",value:e}),qR=e=>e.status==="aborted",XR=e=>e.status==="dirty",tu=e=>e.status==="valid",fg=e=>typeof Promise<"u"&&e instanceof Promise;var kt;(function(e){e.errToObj=t=>typeof t=="string"?{message:t}:t||{},e.toString=t=>typeof t=="string"?t:t==null?void 0:t.message})(kt||(kt={}));class na{constructor(t,n,r,o){this._cachedPath=[],this.parent=t,this.data=n,this._path=r,this._key=o}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const YR=(e,t)=>{if(tu(t))return{success:!0,data:t.value};if(!e.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const n=new ja(e.common.issues);return this._error=n,this._error}}};function Zt(e){if(!e)return{};const{errorMap:t,invalid_type_error:n,required_error:r,description:o}=e;if(t&&(n||r))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return t?{errorMap:t,description:o}:{errorMap:(a,s)=>{const{message:l}=e;return a.code==="invalid_enum_value"?{message:l??s.defaultError}:typeof s.data>"u"?{message:l??r??s.defaultError}:a.code!=="invalid_type"?{message:s.defaultError}:{message:l??n??s.defaultError}},description:o}}class ln{get description(){return this._def.description}_getType(t){return es(t.data)}_getOrReturnCtx(t,n){return n||{common:t.parent.common,data:t.data,parsedType:es(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}_processInputParams(t){return{status:new co,ctx:{common:t.parent.common,data:t.data,parsedType:es(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}}_parseSync(t){const n=this._parse(t);if(fg(n))throw new Error("Synchronous parse encountered promise.");return n}_parseAsync(t){const n=this._parse(t);return Promise.resolve(n)}parse(t,n){const r=this.safeParse(t,n);if(r.success)return r.data;throw r.error}safeParse(t,n){const r={common:{issues:[],async:(n==null?void 0:n.async)??!1,contextualErrorMap:n==null?void 0:n.errorMap},path:(n==null?void 0:n.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:es(t)},o=this._parseSync({data:t,path:r.path,parent:r});return YR(r,o)}"~validate"(t){var r,o;const n={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:es(t)};if(!this["~standard"].async)try{const i=this._parseSync({data:t,path:[],parent:n});return tu(i)?{value:i.value}:{issues:n.common.issues}}catch(i){(o=(r=i==null?void 0:i.message)==null?void 0:r.toLowerCase())!=null&&o.includes("encountered")&&(this["~standard"].async=!0),n.common={issues:[],async:!0}}return this._parseAsync({data:t,path:[],parent:n}).then(i=>tu(i)?{value:i.value}:{issues:n.common.issues})}async parseAsync(t,n){const r=await this.safeParseAsync(t,n);if(r.success)return r.data;throw r.error}async safeParseAsync(t,n){const r={common:{issues:[],contextualErrorMap:n==null?void 0:n.errorMap,async:!0},path:(n==null?void 0:n.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:es(t)},o=this._parse({data:t,path:r.path,parent:r}),i=await(fg(o)?o:Promise.resolve(o));return YR(r,i)}refine(t,n){const r=o=>typeof n=="string"||typeof n>"u"?{message:n}:typeof n=="function"?n(o):n;return this._refinement((o,i)=>{const a=t(o),s=()=>i.addIssue({code:tt.custom,...r(o)});return typeof Promise<"u"&&a instanceof Promise?a.then(l=>l?!0:(s(),!1)):a?!0:(s(),!1)})}refinement(t,n){return this._refinement((r,o)=>t(r)?!0:(o.addIssue(typeof n=="function"?n(r,o):n),!1))}_refinement(t){return new Aa({schema:this,typeName:Ht.ZodEffects,effect:{type:"refinement",refinement:t}})}superRefine(t){return this._refinement(t)}constructor(t){this.spa=this.safeParseAsync,this._def=t,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:n=>this["~validate"](n)}}optional(){return ki.create(this,this._def)}nullable(){return La.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return ri.create(this)}promise(){return bg.create(this,this._def)}or(t){return pg.create([this,t],this._def)}and(t){return hg.create(this,t,this._def)}transform(t){return new Aa({...Zt(this._def),schema:this,typeName:Ht.ZodEffects,effect:{type:"transform",transform:t}})}default(t){const n=typeof t=="function"?t:()=>t;return new nu({...Zt(this._def),innerType:this,defaultValue:n,typeName:Ht.ZodDefault})}brand(){return new TCe({typeName:Ht.ZodBranded,type:this,...Zt(this._def)})}catch(t){const n=typeof t=="function"?t:()=>t;return new NC({...Zt(this._def),innerType:this,catchValue:n,typeName:Ht.ZodCatch})}describe(t){const n=this.constructor;return new n({...this._def,description:t})}pipe(t){return V1.create(this,t)}readonly(){return OC.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const dCe=/^c[^\s-]{8,}$/i,fCe=/^[0-9a-z]+$/,mCe=/^[0-9A-HJKMNP-TV-Z]{26}$/i,pCe=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,hCe=/^[a-z0-9_-]{21}$/i,gCe=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,vCe=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,yCe=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,bCe="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let C0;const xCe=/^(?:(?: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])$/,SCe=/^(?:(?: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])\/(3[0-2]|[12]?[0-9])$/,CCe=/^(([0-9a-fA-F]{1,4}:){7,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}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,wCe=/^(([0-9a-fA-F]{1,4}:){7,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}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,_Ce=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,ECe=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,HF="((\\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])))",$Ce=new RegExp(`^${HF}$`);function VF(e){let t="[0-5]\\d";e.precision?t=`${t}\\.\\d{${e.precision}}`:e.precision==null&&(t=`${t}(\\.\\d+)?`);const n=e.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${n}`}function kCe(e){return new RegExp(`^${VF(e)}$`)}function NCe(e){let t=`${HF}T${VF(e)}`;const n=[];return n.push(e.local?"Z?":"Z"),e.offset&&n.push("([+-]\\d{2}:?\\d{2})"),t=`${t}(${n.join("|")})`,new RegExp(`^${t}$`)}function OCe(e,t){return!!((t==="v4"||!t)&&xCe.test(e)||(t==="v6"||!t)&&CCe.test(e))}function ICe(e,t){if(!gCe.test(e))return!1;try{const[n]=e.split(".");if(!n)return!1;const r=n.replace(/-/g,"+").replace(/_/g,"/").padEnd(n.length+(4-n.length%4)%4,"="),o=JSON.parse(atob(r));return!(typeof o!="object"||o===null||"typ"in o&&(o==null?void 0:o.typ)!=="JWT"||!o.alg||t&&o.alg!==t)}catch{return!1}}function RCe(e,t){return!!((t==="v4"||!t)&&SCe.test(e)||(t==="v6"||!t)&&wCe.test(e))}class ti extends ln{_parse(t){if(this._def.coerce&&(t.data=String(t.data)),this._getType(t)!==Et.string){const i=this._getOrReturnCtx(t);return xt(i,{code:tt.invalid_type,expected:Et.string,received:i.parsedType}),Wt}const r=new co;let o;for(const i of this._def.checks)if(i.kind==="min")t.data.length<i.value&&(o=this._getOrReturnCtx(t,o),xt(o,{code:tt.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),r.dirty());else if(i.kind==="max")t.data.length>i.value&&(o=this._getOrReturnCtx(t,o),xt(o,{code:tt.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),r.dirty());else if(i.kind==="length"){const a=t.data.length>i.value,s=t.data.length<i.value;(a||s)&&(o=this._getOrReturnCtx(t,o),a?xt(o,{code:tt.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}):s&&xt(o,{code:tt.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}),r.dirty())}else if(i.kind==="email")yCe.test(t.data)||(o=this._getOrReturnCtx(t,o),xt(o,{validation:"email",code:tt.invalid_string,message:i.message}),r.dirty());else if(i.kind==="emoji")C0||(C0=new RegExp(bCe,"u")),C0.test(t.data)||(o=this._getOrReturnCtx(t,o),xt(o,{validation:"emoji",code:tt.invalid_string,message:i.message}),r.dirty());else if(i.kind==="uuid")pCe.test(t.data)||(o=this._getOrReturnCtx(t,o),xt(o,{validation:"uuid",code:tt.invalid_string,message:i.message}),r.dirty());else if(i.kind==="nanoid")hCe.test(t.data)||(o=this._getOrReturnCtx(t,o),xt(o,{validation:"nanoid",code:tt.invalid_string,message:i.message}),r.dirty());else if(i.kind==="cuid")dCe.test(t.data)||(o=this._getOrReturnCtx(t,o),xt(o,{validation:"cuid",code:tt.invalid_string,message:i.message}),r.dirty());else if(i.kind==="cuid2")fCe.test(t.data)||(o=this._getOrReturnCtx(t,o),xt(o,{validation:"cuid2",code:tt.invalid_string,message:i.message}),r.dirty());else if(i.kind==="ulid")mCe.test(t.data)||(o=this._getOrReturnCtx(t,o),xt(o,{validation:"ulid",code:tt.invalid_string,message:i.message}),r.dirty());else if(i.kind==="url")try{new URL(t.data)}catch{o=this._getOrReturnCtx(t,o),xt(o,{validation:"url",code:tt.invalid_string,message:i.message}),r.dirty()}else i.kind==="regex"?(i.regex.lastIndex=0,i.regex.test(t.data)||(o=this._getOrReturnCtx(t,o),xt(o,{validation:"regex",code:tt.invalid_string,message:i.message}),r.dirty())):i.kind==="trim"?t.data=t.data.trim():i.kind==="includes"?t.data.includes(i.value,i.position)||(o=this._getOrReturnCtx(t,o),xt(o,{code:tt.invalid_string,validation:{includes:i.value,position:i.position},message:i.message}),r.dirty()):i.kind==="toLowerCase"?t.data=t.data.toLowerCase():i.kind==="toUpperCase"?t.data=t.data.toUpperCase():i.kind==="startsWith"?t.data.startsWith(i.value)||(o=this._getOrReturnCtx(t,o),xt(o,{code:tt.invalid_string,validation:{startsWith:i.value},message:i.message}),r.dirty()):i.kind==="endsWith"?t.data.endsWith(i.value)||(o=this._getOrReturnCtx(t,o),xt(o,{code:tt.invalid_string,validation:{endsWith:i.value},message:i.message}),r.dirty()):i.kind==="datetime"?NCe(i).test(t.data)||(o=this._getOrReturnCtx(t,o),xt(o,{code:tt.invalid_string,validation:"datetime",message:i.message}),r.dirty()):i.kind==="date"?$Ce.test(t.data)||(o=this._getOrReturnCtx(t,o),xt(o,{code:tt.invalid_string,validation:"date",message:i.message}),r.dirty()):i.kind==="time"?kCe(i).test(t.data)||(o=this._getOrReturnCtx(t,o),xt(o,{code:tt.invalid_string,validation:"time",message:i.message}),r.dirty()):i.kind==="duration"?vCe.test(t.data)||(o=this._getOrReturnCtx(t,o),xt(o,{validation:"duration",code:tt.invalid_string,message:i.message}),r.dirty()):i.kind==="ip"?OCe(t.data,i.version)||(o=this._getOrReturnCtx(t,o),xt(o,{validation:"ip",code:tt.invalid_string,message:i.message}),r.dirty()):i.kind==="jwt"?ICe(t.data,i.alg)||(o=this._getOrReturnCtx(t,o),xt(o,{validation:"jwt",code:tt.invalid_string,message:i.message}),r.dirty()):i.kind==="cidr"?RCe(t.data,i.version)||(o=this._getOrReturnCtx(t,o),xt(o,{validation:"cidr",code:tt.invalid_string,message:i.message}),r.dirty()):i.kind==="base64"?_Ce.test(t.data)||(o=this._getOrReturnCtx(t,o),xt(o,{validation:"base64",code:tt.invalid_string,message:i.message}),r.dirty()):i.kind==="base64url"?ECe.test(t.data)||(o=this._getOrReturnCtx(t,o),xt(o,{validation:"base64url",code:tt.invalid_string,message:i.message}),r.dirty()):pn.assertNever(i);return{status:r.value,value:t.data}}_regex(t,n,r){return this.refinement(o=>t.test(o),{validation:n,code:tt.invalid_string,...kt.errToObj(r)})}_addCheck(t){return new ti({...this._def,checks:[...this._def.checks,t]})}email(t){return this._addCheck({kind:"email",...kt.errToObj(t)})}url(t){return this._addCheck({kind:"url",...kt.errToObj(t)})}emoji(t){return this._addCheck({kind:"emoji",...kt.errToObj(t)})}uuid(t){return this._addCheck({kind:"uuid",...kt.errToObj(t)})}nanoid(t){return this._addCheck({kind:"nanoid",...kt.errToObj(t)})}cuid(t){return this._addCheck({kind:"cuid",...kt.errToObj(t)})}cuid2(t){return this._addCheck({kind:"cuid2",...kt.errToObj(t)})}ulid(t){return this._addCheck({kind:"ulid",...kt.errToObj(t)})}base64(t){return this._addCheck({kind:"base64",...kt.errToObj(t)})}base64url(t){return this._addCheck({kind:"base64url",...kt.errToObj(t)})}jwt(t){return this._addCheck({kind:"jwt",...kt.errToObj(t)})}ip(t){return this._addCheck({kind:"ip",...kt.errToObj(t)})}cidr(t){return this._addCheck({kind:"cidr",...kt.errToObj(t)})}datetime(t){return typeof t=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:t}):this._addCheck({kind:"datetime",precision:typeof(t==null?void 0:t.precision)>"u"?null:t==null?void 0:t.precision,offset:(t==null?void 0:t.offset)??!1,local:(t==null?void 0:t.local)??!1,...kt.errToObj(t==null?void 0:t.message)})}date(t){return this._addCheck({kind:"date",message:t})}time(t){return typeof t=="string"?this._addCheck({kind:"time",precision:null,message:t}):this._addCheck({kind:"time",precision:typeof(t==null?void 0:t.precision)>"u"?null:t==null?void 0:t.precision,...kt.errToObj(t==null?void 0:t.message)})}duration(t){return this._addCheck({kind:"duration",...kt.errToObj(t)})}regex(t,n){return this._addCheck({kind:"regex",regex:t,...kt.errToObj(n)})}includes(t,n){return this._addCheck({kind:"includes",value:t,position:n==null?void 0:n.position,...kt.errToObj(n==null?void 0:n.message)})}startsWith(t,n){return this._addCheck({kind:"startsWith",value:t,...kt.errToObj(n)})}endsWith(t,n){return this._addCheck({kind:"endsWith",value:t,...kt.errToObj(n)})}min(t,n){return this._addCheck({kind:"min",value:t,...kt.errToObj(n)})}max(t,n){return this._addCheck({kind:"max",value:t,...kt.errToObj(n)})}length(t,n){return this._addCheck({kind:"length",value:t,...kt.errToObj(n)})}nonempty(t){return this.min(1,kt.errToObj(t))}trim(){return new ti({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new ti({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new ti({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(t=>t.kind==="datetime")}get isDate(){return!!this._def.checks.find(t=>t.kind==="date")}get isTime(){return!!this._def.checks.find(t=>t.kind==="time")}get isDuration(){return!!this._def.checks.find(t=>t.kind==="duration")}get isEmail(){return!!this._def.checks.find(t=>t.kind==="email")}get isURL(){return!!this._def.checks.find(t=>t.kind==="url")}get isEmoji(){return!!this._def.checks.find(t=>t.kind==="emoji")}get isUUID(){return!!this._def.checks.find(t=>t.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(t=>t.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(t=>t.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(t=>t.kind==="cuid2")}get isULID(){return!!this._def.checks.find(t=>t.kind==="ulid")}get isIP(){return!!this._def.checks.find(t=>t.kind==="ip")}get isCIDR(){return!!this._def.checks.find(t=>t.kind==="cidr")}get isBase64(){return!!this._def.checks.find(t=>t.kind==="base64")}get isBase64url(){return!!this._def.checks.find(t=>t.kind==="base64url")}get minLength(){let t=null;for(const n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t}get maxLength(){let t=null;for(const n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t}}ti.create=e=>new ti({checks:[],typeName:Ht.ZodString,coerce:(e==null?void 0:e.coerce)??!1,...Zt(e)});function PCe(e,t){const n=(e.toString().split(".")[1]||"").length,r=(t.toString().split(".")[1]||"").length,o=n>r?n:r,i=Number.parseInt(e.toFixed(o).replace(".","")),a=Number.parseInt(t.toFixed(o).replace(".",""));return i%a/10**o}class bl extends ln{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(t){if(this._def.coerce&&(t.data=Number(t.data)),this._getType(t)!==Et.number){const i=this._getOrReturnCtx(t);return xt(i,{code:tt.invalid_type,expected:Et.number,received:i.parsedType}),Wt}let r;const o=new co;for(const i of this._def.checks)i.kind==="int"?pn.isInteger(t.data)||(r=this._getOrReturnCtx(t,r),xt(r,{code:tt.invalid_type,expected:"integer",received:"float",message:i.message}),o.dirty()):i.kind==="min"?(i.inclusive?t.data<i.value:t.data<=i.value)&&(r=this._getOrReturnCtx(t,r),xt(r,{code:tt.too_small,minimum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),o.dirty()):i.kind==="max"?(i.inclusive?t.data>i.value:t.data>=i.value)&&(r=this._getOrReturnCtx(t,r),xt(r,{code:tt.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),o.dirty()):i.kind==="multipleOf"?PCe(t.data,i.value)!==0&&(r=this._getOrReturnCtx(t,r),xt(r,{code:tt.not_multiple_of,multipleOf:i.value,message:i.message}),o.dirty()):i.kind==="finite"?Number.isFinite(t.data)||(r=this._getOrReturnCtx(t,r),xt(r,{code:tt.not_finite,message:i.message}),o.dirty()):pn.assertNever(i);return{status:o.value,value:t.data}}gte(t,n){return this.setLimit("min",t,!0,kt.toString(n))}gt(t,n){return this.setLimit("min",t,!1,kt.toString(n))}lte(t,n){return this.setLimit("max",t,!0,kt.toString(n))}lt(t,n){return this.setLimit("max",t,!1,kt.toString(n))}setLimit(t,n,r,o){return new bl({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:kt.toString(o)}]})}_addCheck(t){return new bl({...this._def,checks:[...this._def.checks,t]})}int(t){return this._addCheck({kind:"int",message:kt.toString(t)})}positive(t){return this._addCheck({kind:"min",value:0,inclusive:!1,message:kt.toString(t)})}negative(t){return this._addCheck({kind:"max",value:0,inclusive:!1,message:kt.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:0,inclusive:!0,message:kt.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:0,inclusive:!0,message:kt.toString(t)})}multipleOf(t,n){return this._addCheck({kind:"multipleOf",value:t,message:kt.toString(n)})}finite(t){return this._addCheck({kind:"finite",message:kt.toString(t)})}safe(t){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:kt.toString(t)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:kt.toString(t)})}get minValue(){let t=null;for(const n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t}get maxValue(){let t=null;for(const n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t}get isInt(){return!!this._def.checks.find(t=>t.kind==="int"||t.kind==="multipleOf"&&pn.isInteger(t.value))}get isFinite(){let t=null,n=null;for(const r of this._def.checks){if(r.kind==="finite"||r.kind==="int"||r.kind==="multipleOf")return!0;r.kind==="min"?(n===null||r.value>n)&&(n=r.value):r.kind==="max"&&(t===null||r.value<t)&&(t=r.value)}return Number.isFinite(n)&&Number.isFinite(t)}}bl.create=e=>new bl({checks:[],typeName:Ht.ZodNumber,coerce:(e==null?void 0:e.coerce)||!1,...Zt(e)});class kf extends ln{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(t){if(this._def.coerce)try{t.data=BigInt(t.data)}catch{return this._getInvalidInput(t)}if(this._getType(t)!==Et.bigint)return this._getInvalidInput(t);let r;const o=new co;for(const i of this._def.checks)i.kind==="min"?(i.inclusive?t.data<i.value:t.data<=i.value)&&(r=this._getOrReturnCtx(t,r),xt(r,{code:tt.too_small,type:"bigint",minimum:i.value,inclusive:i.inclusive,message:i.message}),o.dirty()):i.kind==="max"?(i.inclusive?t.data>i.value:t.data>=i.value)&&(r=this._getOrReturnCtx(t,r),xt(r,{code:tt.too_big,type:"bigint",maximum:i.value,inclusive:i.inclusive,message:i.message}),o.dirty()):i.kind==="multipleOf"?t.data%i.value!==BigInt(0)&&(r=this._getOrReturnCtx(t,r),xt(r,{code:tt.not_multiple_of,multipleOf:i.value,message:i.message}),o.dirty()):pn.assertNever(i);return{status:o.value,value:t.data}}_getInvalidInput(t){const n=this._getOrReturnCtx(t);return xt(n,{code:tt.invalid_type,expected:Et.bigint,received:n.parsedType}),Wt}gte(t,n){return this.setLimit("min",t,!0,kt.toString(n))}gt(t,n){return this.setLimit("min",t,!1,kt.toString(n))}lte(t,n){return this.setLimit("max",t,!0,kt.toString(n))}lt(t,n){return this.setLimit("max",t,!1,kt.toString(n))}setLimit(t,n,r,o){return new kf({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:kt.toString(o)}]})}_addCheck(t){return new kf({...this._def,checks:[...this._def.checks,t]})}positive(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:kt.toString(t)})}negative(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:kt.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:kt.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:kt.toString(t)})}multipleOf(t,n){return this._addCheck({kind:"multipleOf",value:t,message:kt.toString(n)})}get minValue(){let t=null;for(const n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t}get maxValue(){let t=null;for(const n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t}}kf.create=e=>new kf({checks:[],typeName:Ht.ZodBigInt,coerce:(e==null?void 0:e.coerce)??!1,...Zt(e)});class Nf extends ln{_parse(t){if(this._def.coerce&&(t.data=!!t.data),this._getType(t)!==Et.boolean){const r=this._getOrReturnCtx(t);return xt(r,{code:tt.invalid_type,expected:Et.boolean,received:r.parsedType}),Wt}return fi(t.data)}}Nf.create=e=>new Nf({typeName:Ht.ZodBoolean,coerce:(e==null?void 0:e.coerce)||!1,...Zt(e)});class mg extends ln{_parse(t){if(this._def.coerce&&(t.data=new Date(t.data)),this._getType(t)!==Et.date){const i=this._getOrReturnCtx(t);return xt(i,{code:tt.invalid_type,expected:Et.date,received:i.parsedType}),Wt}if(Number.isNaN(t.data.getTime())){const i=this._getOrReturnCtx(t);return xt(i,{code:tt.invalid_date}),Wt}const r=new co;let o;for(const i of this._def.checks)i.kind==="min"?t.data.getTime()<i.value&&(o=this._getOrReturnCtx(t,o),xt(o,{code:tt.too_small,message:i.message,inclusive:!0,exact:!1,minimum:i.value,type:"date"}),r.dirty()):i.kind==="max"?t.data.getTime()>i.value&&(o=this._getOrReturnCtx(t,o),xt(o,{code:tt.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),r.dirty()):pn.assertNever(i);return{status:r.value,value:new Date(t.data.getTime())}}_addCheck(t){return new mg({...this._def,checks:[...this._def.checks,t]})}min(t,n){return this._addCheck({kind:"min",value:t.getTime(),message:kt.toString(n)})}max(t,n){return this._addCheck({kind:"max",value:t.getTime(),message:kt.toString(n)})}get minDate(){let t=null;for(const n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t!=null?new Date(t):null}get maxDate(){let t=null;for(const n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t!=null?new Date(t):null}}mg.create=e=>new mg({checks:[],coerce:(e==null?void 0:e.coerce)||!1,typeName:Ht.ZodDate,...Zt(e)});class QR extends ln{_parse(t){if(this._getType(t)!==Et.symbol){const r=this._getOrReturnCtx(t);return xt(r,{code:tt.invalid_type,expected:Et.symbol,received:r.parsedType}),Wt}return fi(t.data)}}QR.create=e=>new QR({typeName:Ht.ZodSymbol,...Zt(e)});class ZR extends ln{_parse(t){if(this._getType(t)!==Et.undefined){const r=this._getOrReturnCtx(t);return xt(r,{code:tt.invalid_type,expected:Et.undefined,received:r.parsedType}),Wt}return fi(t.data)}}ZR.create=e=>new ZR({typeName:Ht.ZodUndefined,...Zt(e)});class JR extends ln{_parse(t){if(this._getType(t)!==Et.null){const r=this._getOrReturnCtx(t);return xt(r,{code:tt.invalid_type,expected:Et.null,received:r.parsedType}),Wt}return fi(t.data)}}JR.create=e=>new JR({typeName:Ht.ZodNull,...Zt(e)});class eP extends ln{constructor(){super(...arguments),this._any=!0}_parse(t){return fi(t.data)}}eP.create=e=>new eP({typeName:Ht.ZodAny,...Zt(e)});class tP extends ln{constructor(){super(...arguments),this._unknown=!0}_parse(t){return fi(t.data)}}tP.create=e=>new tP({typeName:Ht.ZodUnknown,...Zt(e)});class $s extends ln{_parse(t){const n=this._getOrReturnCtx(t);return xt(n,{code:tt.invalid_type,expected:Et.never,received:n.parsedType}),Wt}}$s.create=e=>new $s({typeName:Ht.ZodNever,...Zt(e)});class nP extends ln{_parse(t){if(this._getType(t)!==Et.undefined){const r=this._getOrReturnCtx(t);return xt(r,{code:tt.invalid_type,expected:Et.void,received:r.parsedType}),Wt}return fi(t.data)}}nP.create=e=>new nP({typeName:Ht.ZodVoid,...Zt(e)});class ri extends ln{_parse(t){const{ctx:n,status:r}=this._processInputParams(t),o=this._def;if(n.parsedType!==Et.array)return xt(n,{code:tt.invalid_type,expected:Et.array,received:n.parsedType}),Wt;if(o.exactLength!==null){const a=n.data.length>o.exactLength.value,s=n.data.length<o.exactLength.value;(a||s)&&(xt(n,{code:a?tt.too_big:tt.too_small,minimum:s?o.exactLength.value:void 0,maximum:a?o.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:o.exactLength.message}),r.dirty())}if(o.minLength!==null&&n.data.length<o.minLength.value&&(xt(n,{code:tt.too_small,minimum:o.minLength.value,type:"array",inclusive:!0,exact:!1,message:o.minLength.message}),r.dirty()),o.maxLength!==null&&n.data.length>o.maxLength.value&&(xt(n,{code:tt.too_big,maximum:o.maxLength.value,type:"array",inclusive:!0,exact:!1,message:o.maxLength.message}),r.dirty()),n.common.async)return Promise.all([...n.data].map((a,s)=>o.type._parseAsync(new na(n,a,n.path,s)))).then(a=>co.mergeArray(r,a));const i=[...n.data].map((a,s)=>o.type._parseSync(new na(n,a,n.path,s)));return co.mergeArray(r,i)}get element(){return this._def.type}min(t,n){return new ri({...this._def,minLength:{value:t,message:kt.toString(n)}})}max(t,n){return new ri({...this._def,maxLength:{value:t,message:kt.toString(n)}})}length(t,n){return new ri({...this._def,exactLength:{value:t,message:kt.toString(n)}})}nonempty(t){return this.min(1,t)}}ri.create=(e,t)=>new ri({type:e,minLength:null,maxLength:null,exactLength:null,typeName:Ht.ZodArray,...Zt(t)});function Xl(e){if(e instanceof qn){const t={};for(const n in e.shape){const r=e.shape[n];t[n]=ki.create(Xl(r))}return new qn({...e._def,shape:()=>t})}else return e instanceof ri?new ri({...e._def,type:Xl(e.element)}):e instanceof ki?ki.create(Xl(e.unwrap())):e instanceof La?La.create(Xl(e.unwrap())):e instanceof xl?xl.create(e.items.map(t=>Xl(t))):e}class qn extends ln{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const t=this._def.shape(),n=pn.objectKeys(t);return this._cached={shape:t,keys:n},this._cached}_parse(t){if(this._getType(t)!==Et.object){const c=this._getOrReturnCtx(t);return xt(c,{code:tt.invalid_type,expected:Et.object,received:c.parsedType}),Wt}const{status:r,ctx:o}=this._processInputParams(t),{shape:i,keys:a}=this._getCached(),s=[];if(!(this._def.catchall instanceof $s&&this._def.unknownKeys==="strip"))for(const c in o.data)a.includes(c)||s.push(c);const l=[];for(const c of a){const d=i[c],f=o.data[c];l.push({key:{status:"valid",value:c},value:d._parse(new na(o,f,o.path,c)),alwaysSet:c in o.data})}if(this._def.catchall instanceof $s){const c=this._def.unknownKeys;if(c==="passthrough")for(const d of s)l.push({key:{status:"valid",value:d},value:{status:"valid",value:o.data[d]}});else if(c==="strict")s.length>0&&(xt(o,{code:tt.unrecognized_keys,keys:s}),r.dirty());else if(c!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const c=this._def.catchall;for(const d of s){const f=o.data[d];l.push({key:{status:"valid",value:d},value:c._parse(new na(o,f,o.path,d)),alwaysSet:d in o.data})}}return o.common.async?Promise.resolve().then(async()=>{const c=[];for(const d of l){const f=await d.key,m=await d.value;c.push({key:f,value:m,alwaysSet:d.alwaysSet})}return c}).then(c=>co.mergeObjectSync(r,c)):co.mergeObjectSync(r,l)}get shape(){return this._def.shape()}strict(t){return kt.errToObj,new qn({...this._def,unknownKeys:"strict",...t!==void 0?{errorMap:(n,r)=>{var i,a;const o=((a=(i=this._def).errorMap)==null?void 0:a.call(i,n,r).message)??r.defaultError;return n.code==="unrecognized_keys"?{message:kt.errToObj(t).message??o}:{message:o}}}:{}})}strip(){return new qn({...this._def,unknownKeys:"strip"})}passthrough(){return new qn({...this._def,unknownKeys:"passthrough"})}extend(t){return new qn({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){return new qn({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>({...this._def.shape(),...t._def.shape()}),typeName:Ht.ZodObject})}setKey(t,n){return this.augment({[t]:n})}catchall(t){return new qn({...this._def,catchall:t})}pick(t){const n={};for(const r of pn.objectKeys(t))t[r]&&this.shape[r]&&(n[r]=this.shape[r]);return new qn({...this._def,shape:()=>n})}omit(t){const n={};for(const r of pn.objectKeys(this.shape))t[r]||(n[r]=this.shape[r]);return new qn({...this._def,shape:()=>n})}deepPartial(){return Xl(this)}partial(t){const n={};for(const r of pn.objectKeys(this.shape)){const o=this.shape[r];t&&!t[r]?n[r]=o:n[r]=o.optional()}return new qn({...this._def,shape:()=>n})}required(t){const n={};for(const r of pn.objectKeys(this.shape))if(t&&!t[r])n[r]=this.shape[r];else{let i=this.shape[r];for(;i instanceof ki;)i=i._def.innerType;n[r]=i}return new qn({...this._def,shape:()=>n})}keyof(){return WF(pn.objectKeys(this.shape))}}qn.create=(e,t)=>new qn({shape:()=>e,unknownKeys:"strip",catchall:$s.create(),typeName:Ht.ZodObject,...Zt(t)});qn.strictCreate=(e,t)=>new qn({shape:()=>e,unknownKeys:"strict",catchall:$s.create(),typeName:Ht.ZodObject,...Zt(t)});qn.lazycreate=(e,t)=>new qn({shape:e,unknownKeys:"strip",catchall:$s.create(),typeName:Ht.ZodObject,...Zt(t)});class pg extends ln{_parse(t){const{ctx:n}=this._processInputParams(t),r=this._def.options;function o(i){for(const s of i)if(s.result.status==="valid")return s.result;for(const s of i)if(s.result.status==="dirty")return n.common.issues.push(...s.ctx.common.issues),s.result;const a=i.map(s=>new ja(s.ctx.common.issues));return xt(n,{code:tt.invalid_union,unionErrors:a}),Wt}if(n.common.async)return Promise.all(r.map(async i=>{const a={...n,common:{...n.common,issues:[]},parent:null};return{result:await i._parseAsync({data:n.data,path:n.path,parent:a}),ctx:a}})).then(o);{let i;const a=[];for(const l of r){const c={...n,common:{...n.common,issues:[]},parent:null},d=l._parseSync({data:n.data,path:n.path,parent:c});if(d.status==="valid")return d;d.status==="dirty"&&!i&&(i={result:d,ctx:c}),c.common.issues.length&&a.push(c.common.issues)}if(i)return n.common.issues.push(...i.ctx.common.issues),i.result;const s=a.map(l=>new ja(l));return xt(n,{code:tt.invalid_union,unionErrors:s}),Wt}}get options(){return this._def.options}}pg.create=(e,t)=>new pg({options:e,typeName:Ht.ZodUnion,...Zt(t)});function kC(e,t){const n=es(e),r=es(t);if(e===t)return{valid:!0,data:e};if(n===Et.object&&r===Et.object){const o=pn.objectKeys(t),i=pn.objectKeys(e).filter(s=>o.indexOf(s)!==-1),a={...e,...t};for(const s of i){const l=kC(e[s],t[s]);if(!l.valid)return{valid:!1};a[s]=l.data}return{valid:!0,data:a}}else if(n===Et.array&&r===Et.array){if(e.length!==t.length)return{valid:!1};const o=[];for(let i=0;i<e.length;i++){const a=e[i],s=t[i],l=kC(a,s);if(!l.valid)return{valid:!1};o.push(l.data)}return{valid:!0,data:o}}else return n===Et.date&&r===Et.date&&+e==+t?{valid:!0,data:e}:{valid:!1}}class hg extends ln{_parse(t){const{status:n,ctx:r}=this._processInputParams(t),o=(i,a)=>{if(qR(i)||qR(a))return Wt;const s=kC(i.value,a.value);return s.valid?((XR(i)||XR(a))&&n.dirty(),{status:n.value,value:s.data}):(xt(r,{code:tt.invalid_intersection_types}),Wt)};return r.common.async?Promise.all([this._def.left._parseAsync({data:r.data,path:r.path,parent:r}),this._def.right._parseAsync({data:r.data,path:r.path,parent:r})]).then(([i,a])=>o(i,a)):o(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}}hg.create=(e,t,n)=>new hg({left:e,right:t,typeName:Ht.ZodIntersection,...Zt(n)});class xl extends ln{_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.parsedType!==Et.array)return xt(r,{code:tt.invalid_type,expected:Et.array,received:r.parsedType}),Wt;if(r.data.length<this._def.items.length)return xt(r,{code:tt.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),Wt;!this._def.rest&&r.data.length>this._def.items.length&&(xt(r,{code:tt.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),n.dirty());const i=[...r.data].map((a,s)=>{const l=this._def.items[s]||this._def.rest;return l?l._parse(new na(r,a,r.path,s)):null}).filter(a=>!!a);return r.common.async?Promise.all(i).then(a=>co.mergeArray(n,a)):co.mergeArray(n,i)}get items(){return this._def.items}rest(t){return new xl({...this._def,rest:t})}}xl.create=(e,t)=>{if(!Array.isArray(e))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new xl({items:e,typeName:Ht.ZodTuple,rest:null,...Zt(t)})};class gg extends ln{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.parsedType!==Et.object)return xt(r,{code:tt.invalid_type,expected:Et.object,received:r.parsedType}),Wt;const o=[],i=this._def.keyType,a=this._def.valueType;for(const s in r.data)o.push({key:i._parse(new na(r,s,r.path,s)),value:a._parse(new na(r,r.data[s],r.path,s)),alwaysSet:s in r.data});return r.common.async?co.mergeObjectAsync(n,o):co.mergeObjectSync(n,o)}get element(){return this._def.valueType}static create(t,n,r){return n instanceof ln?new gg({keyType:t,valueType:n,typeName:Ht.ZodRecord,...Zt(r)}):new gg({keyType:ti.create(),valueType:t,typeName:Ht.ZodRecord,...Zt(n)})}}class rP extends ln{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.parsedType!==Et.map)return xt(r,{code:tt.invalid_type,expected:Et.map,received:r.parsedType}),Wt;const o=this._def.keyType,i=this._def.valueType,a=[...r.data.entries()].map(([s,l],c)=>({key:o._parse(new na(r,s,r.path,[c,"key"])),value:i._parse(new na(r,l,r.path,[c,"value"]))}));if(r.common.async){const s=new Map;return Promise.resolve().then(async()=>{for(const l of a){const c=await l.key,d=await l.value;if(c.status==="aborted"||d.status==="aborted")return Wt;(c.status==="dirty"||d.status==="dirty")&&n.dirty(),s.set(c.value,d.value)}return{status:n.value,value:s}})}else{const s=new Map;for(const l of a){const c=l.key,d=l.value;if(c.status==="aborted"||d.status==="aborted")return Wt;(c.status==="dirty"||d.status==="dirty")&&n.dirty(),s.set(c.value,d.value)}return{status:n.value,value:s}}}}rP.create=(e,t,n)=>new rP({valueType:t,keyType:e,typeName:Ht.ZodMap,...Zt(n)});class Of extends ln{_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.parsedType!==Et.set)return xt(r,{code:tt.invalid_type,expected:Et.set,received:r.parsedType}),Wt;const o=this._def;o.minSize!==null&&r.data.size<o.minSize.value&&(xt(r,{code:tt.too_small,minimum:o.minSize.value,type:"set",inclusive:!0,exact:!1,message:o.minSize.message}),n.dirty()),o.maxSize!==null&&r.data.size>o.maxSize.value&&(xt(r,{code:tt.too_big,maximum:o.maxSize.value,type:"set",inclusive:!0,exact:!1,message:o.maxSize.message}),n.dirty());const i=this._def.valueType;function a(l){const c=new Set;for(const d of l){if(d.status==="aborted")return Wt;d.status==="dirty"&&n.dirty(),c.add(d.value)}return{status:n.value,value:c}}const s=[...r.data.values()].map((l,c)=>i._parse(new na(r,l,r.path,c)));return r.common.async?Promise.all(s).then(l=>a(l)):a(s)}min(t,n){return new Of({...this._def,minSize:{value:t,message:kt.toString(n)}})}max(t,n){return new Of({...this._def,maxSize:{value:t,message:kt.toString(n)}})}size(t,n){return this.min(t,n).max(t,n)}nonempty(t){return this.min(1,t)}}Of.create=(e,t)=>new Of({valueType:e,minSize:null,maxSize:null,typeName:Ht.ZodSet,...Zt(t)});class oP extends ln{get schema(){return this._def.getter()}_parse(t){const{ctx:n}=this._processInputParams(t);return this._def.getter()._parse({data:n.data,path:n.path,parent:n})}}oP.create=(e,t)=>new oP({getter:e,typeName:Ht.ZodLazy,...Zt(t)});class vg extends ln{_parse(t){if(t.data!==this._def.value){const n=this._getOrReturnCtx(t);return xt(n,{received:n.data,code:tt.invalid_literal,expected:this._def.value}),Wt}return{status:"valid",value:t.data}}get value(){return this._def.value}}vg.create=(e,t)=>new vg({value:e,typeName:Ht.ZodLiteral,...Zt(t)});function WF(e,t){return new Ma({values:e,typeName:Ht.ZodEnum,...Zt(t)})}class Ma extends ln{_parse(t){if(typeof t.data!="string"){const n=this._getOrReturnCtx(t),r=this._def.values;return xt(n,{expected:pn.joinValues(r),received:n.parsedType,code:tt.invalid_type}),Wt}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(t.data)){const n=this._getOrReturnCtx(t),r=this._def.values;return xt(n,{received:n.data,code:tt.invalid_enum_value,options:r}),Wt}return fi(t.data)}get options(){return this._def.values}get enum(){const t={};for(const n of this._def.values)t[n]=n;return t}get Values(){const t={};for(const n of this._def.values)t[n]=n;return t}get Enum(){const t={};for(const n of this._def.values)t[n]=n;return t}extract(t,n=this._def){return Ma.create(t,{...this._def,...n})}exclude(t,n=this._def){return Ma.create(this.options.filter(r=>!t.includes(r)),{...this._def,...n})}}Ma.create=WF;class yg extends ln{_parse(t){const n=pn.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(t);if(r.parsedType!==Et.string&&r.parsedType!==Et.number){const o=pn.objectValues(n);return xt(r,{expected:pn.joinValues(o),received:r.parsedType,code:tt.invalid_type}),Wt}if(this._cache||(this._cache=new Set(pn.getValidEnumValues(this._def.values))),!this._cache.has(t.data)){const o=pn.objectValues(n);return xt(r,{received:r.data,code:tt.invalid_enum_value,options:o}),Wt}return fi(t.data)}get enum(){return this._def.values}}yg.create=(e,t)=>new yg({values:e,typeName:Ht.ZodNativeEnum,...Zt(t)});class bg extends ln{unwrap(){return this._def.type}_parse(t){const{ctx:n}=this._processInputParams(t);if(n.parsedType!==Et.promise&&n.common.async===!1)return xt(n,{code:tt.invalid_type,expected:Et.promise,received:n.parsedType}),Wt;const r=n.parsedType===Et.promise?n.data:Promise.resolve(n.data);return fi(r.then(o=>this._def.type.parseAsync(o,{path:n.path,errorMap:n.common.contextualErrorMap})))}}bg.create=(e,t)=>new bg({type:e,typeName:Ht.ZodPromise,...Zt(t)});class Aa extends ln{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===Ht.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(t){const{status:n,ctx:r}=this._processInputParams(t),o=this._def.effect||null,i={addIssue:a=>{xt(r,a),a.fatal?n.abort():n.dirty()},get path(){return r.path}};if(i.addIssue=i.addIssue.bind(i),o.type==="preprocess"){const a=o.transform(r.data,i);if(r.common.async)return Promise.resolve(a).then(async s=>{if(n.value==="aborted")return Wt;const l=await this._def.schema._parseAsync({data:s,path:r.path,parent:r});return l.status==="aborted"?Wt:l.status==="dirty"||n.value==="dirty"?fd(l.value):l});{if(n.value==="aborted")return Wt;const s=this._def.schema._parseSync({data:a,path:r.path,parent:r});return s.status==="aborted"?Wt:s.status==="dirty"||n.value==="dirty"?fd(s.value):s}}if(o.type==="refinement"){const a=s=>{const l=o.refinement(s,i);if(r.common.async)return Promise.resolve(l);if(l instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return s};if(r.common.async===!1){const s=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return s.status==="aborted"?Wt:(s.status==="dirty"&&n.dirty(),a(s.value),{status:n.value,value:s.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(s=>s.status==="aborted"?Wt:(s.status==="dirty"&&n.dirty(),a(s.value).then(()=>({status:n.value,value:s.value}))))}if(o.type==="transform")if(r.common.async===!1){const a=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!tu(a))return Wt;const s=o.transform(a.value,i);if(s instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:n.value,value:s}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(a=>tu(a)?Promise.resolve(o.transform(a.value,i)).then(s=>({status:n.value,value:s})):Wt);pn.assertNever(o)}}Aa.create=(e,t,n)=>new Aa({schema:e,typeName:Ht.ZodEffects,effect:t,...Zt(n)});Aa.createWithPreprocess=(e,t,n)=>new Aa({schema:t,effect:{type:"preprocess",transform:e},typeName:Ht.ZodEffects,...Zt(n)});class ki extends ln{_parse(t){return this._getType(t)===Et.undefined?fi(void 0):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}}ki.create=(e,t)=>new ki({innerType:e,typeName:Ht.ZodOptional,...Zt(t)});class La extends ln{_parse(t){return this._getType(t)===Et.null?fi(null):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}}La.create=(e,t)=>new La({innerType:e,typeName:Ht.ZodNullable,...Zt(t)});class nu extends ln{_parse(t){const{ctx:n}=this._processInputParams(t);let r=n.data;return n.parsedType===Et.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:n.path,parent:n})}removeDefault(){return this._def.innerType}}nu.create=(e,t)=>new nu({innerType:e,typeName:Ht.ZodDefault,defaultValue:typeof t.default=="function"?t.default:()=>t.default,...Zt(t)});class NC extends ln{_parse(t){const{ctx:n}=this._processInputParams(t),r={...n,common:{...n.common,issues:[]}},o=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return fg(o)?o.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new ja(r.common.issues)},input:r.data})})):{status:"valid",value:o.status==="valid"?o.value:this._def.catchValue({get error(){return new ja(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}}NC.create=(e,t)=>new NC({innerType:e,typeName:Ht.ZodCatch,catchValue:typeof t.catch=="function"?t.catch:()=>t.catch,...Zt(t)});class iP extends ln{_parse(t){if(this._getType(t)!==Et.nan){const r=this._getOrReturnCtx(t);return xt(r,{code:tt.invalid_type,expected:Et.nan,received:r.parsedType}),Wt}return{status:"valid",value:t.data}}}iP.create=e=>new iP({typeName:Ht.ZodNaN,...Zt(e)});class TCe extends ln{_parse(t){const{ctx:n}=this._processInputParams(t),r=n.data;return this._def.type._parse({data:r,path:n.path,parent:n})}unwrap(){return this._def.type}}class V1 extends ln{_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.common.async)return(async()=>{const i=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return i.status==="aborted"?Wt:i.status==="dirty"?(n.dirty(),fd(i.value)):this._def.out._parseAsync({data:i.value,path:r.path,parent:r})})();{const o=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return o.status==="aborted"?Wt:o.status==="dirty"?(n.dirty(),{status:"dirty",value:o.value}):this._def.out._parseSync({data:o.value,path:r.path,parent:r})}}static create(t,n){return new V1({in:t,out:n,typeName:Ht.ZodPipeline})}}class OC extends ln{_parse(t){const n=this._def.innerType._parse(t),r=o=>(tu(o)&&(o.value=Object.freeze(o.value)),o);return fg(n)?n.then(o=>r(o)):r(n)}unwrap(){return this._def.innerType}}OC.create=(e,t)=>new OC({innerType:e,typeName:Ht.ZodReadonly,...Zt(t)});var Ht;(function(e){e.ZodString="ZodString",e.ZodNumber="ZodNumber",e.ZodNaN="ZodNaN",e.ZodBigInt="ZodBigInt",e.ZodBoolean="ZodBoolean",e.ZodDate="ZodDate",e.ZodSymbol="ZodSymbol",e.ZodUndefined="ZodUndefined",e.ZodNull="ZodNull",e.ZodAny="ZodAny",e.ZodUnknown="ZodUnknown",e.ZodNever="ZodNever",e.ZodVoid="ZodVoid",e.ZodArray="ZodArray",e.ZodObject="ZodObject",e.ZodUnion="ZodUnion",e.ZodDiscriminatedUnion="ZodDiscriminatedUnion",e.ZodIntersection="ZodIntersection",e.ZodTuple="ZodTuple",e.ZodRecord="ZodRecord",e.ZodMap="ZodMap",e.ZodSet="ZodSet",e.ZodFunction="ZodFunction",e.ZodLazy="ZodLazy",e.ZodLiteral="ZodLiteral",e.ZodEnum="ZodEnum",e.ZodEffects="ZodEffects",e.ZodNativeEnum="ZodNativeEnum",e.ZodOptional="ZodOptional",e.ZodNullable="ZodNullable",e.ZodDefault="ZodDefault",e.ZodCatch="ZodCatch",e.ZodPromise="ZodPromise",e.ZodBranded="ZodBranded",e.ZodPipeline="ZodPipeline",e.ZodReadonly="ZodReadonly"})(Ht||(Ht={}));const vo=ti.create,IC=Nf.create;$s.create;const td=ri.create,W1=qn.create;pg.create;hg.create;xl.create;const jCe=vg.create,K1=Ma.create;bg.create;ki.create;La.create;const MCe=W1({admins:td(vo()).optional().describe("频道管理员账号(sender ID),管理员拥有管理操作权限且不受以下访问控制限制"),allowPrivateChat:IC().optional().describe("是否允许私聊消息,默认 true"),allowGroupChat:IC().optional().describe("是否允许群聊消息,默认 true"),allowedGroups:td(vo()).optional().describe("群组白名单(channel ID),设置后仅在指定群中响应"),blockedGroups:td(vo()).optional().describe("群组黑名单(channel ID),在指定群中不响应"),allowedSenders:td(vo()).optional().describe("发送者白名单(sender ID),设置后仅白名单内的用户可交互"),blockedSenders:td(vo()).optional().describe("发送者黑名单(sender ID),黑名单内的用户消息将被忽略")}),KF=W1({type:vo().min(1).describe("频道类型"),title:vo().optional().describe("频道标题"),description:vo().optional().describe("频道说明"),enabled:IC().optional().describe("是否启用"),systemPrompt:vo().optional().describe("在此频道启动会话时注入的系统提示词"),commandPrefix:vo().optional().describe("频道指令前缀,默认 /"),language:K1(["zh","en"]).optional().describe("频道提示语言,默认 zh"),access:MCe.optional().describe("频道访问权限配置")}),ACe=e=>e,LCe=KF.extend({type:jCe("lark").describe("频道类型"),appId:vo().min(1).describe("飞书 App ID"),appSecret:vo().min(1).describe("飞书 App Secret"),domain:K1(["Feishu","Lark"]).optional().describe("飞书 Domain")}),DCe=W1({receiveId:vo().min(1).describe("接收方 ID"),receiveIdType:K1(["open_id","user_id","chat_id","email"]).describe("接收方类型"),text:vo().min(1).describe("消息文本")}),zCe=ACe({type:"lark",label:"飞书",description:"飞书消息通道",configSchema:LCe,messageSchema:DCe}),RC=[zCe],cs=e=>e instanceof qn?e.shape:e instanceof Aa?cs(e.innerType()):e instanceof ki?cs(e.unwrap()):e instanceof nu?cs(e.removeDefault()):e instanceof La?cs(e.unwrap()):{},pc=e=>e instanceof Aa?pc(e.innerType()):e instanceof ki?pc(e.unwrap()):e instanceof nu?pc(e.removeDefault()):e instanceof La?pc(e.unwrap()):e,xg=e=>{if(e instanceof nu)return e._def.defaultValue();if(!(e instanceof ki)){if(e instanceof La)return null;if(e instanceof vg)return e.value;if(e instanceof Ma)return e.options[0];if(e instanceof yg){const t=Object.values(e.enum);return t.length>0?t[0]:void 0}if(e instanceof ti)return"";if(e instanceof bl)return 0;if(e instanceof Nf)return!1;if(e instanceof ri)return[];if(e instanceof qn){const t=cs(e);return Object.fromEntries(Object.entries(t).map(([n,r])=>[n,xg(r)]))}if(e instanceof gg)return{};if(e instanceof Aa)return xg(e.innerType())}},BCe=e=>e.replace(/_/g," ").replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/\b\w/g,t=>t.toUpperCase()),aP=e=>{const t=cs(e.configSchema);return Object.entries(t).reduce((r,[o,i])=>(r[o]=xg(i),r),{})},w0=e=>RC.find(t=>t.type===e),FCe=({value:e,onChange:t,t:n,keyPlaceholder:r})=>{var y;const[o,i]=u.useState(""),[a,s]=u.useState(((y=RC[0])==null?void 0:y.type)??""),l=u.useMemo(()=>Object.entries(e),[e]),[c,d]=u.useState(()=>Object.fromEntries(l.map(([x])=>[x,!0]))),f=u.useMemo(()=>new Set(Object.keys(cs(KF))),[]),m=u.useMemo(()=>RC.map(x=>({value:x.type,label:x.label})),[]);u.useEffect(()=>{d(x=>{const g={};for(const[v]of l)g[v]=x[v]??!0;return g})},[l]);const p=(x,g)=>{t({...e,[x]:g})},h=(x,g,v,S)=>{const C=pc(S),_=C.description??"",w=BCe(v),N=g[v],k=N!==void 0?N:xg(S);if(C instanceof ti){const E=BF(v);return b.jsx(Pn,{title:w,description:_,icon:An("string"),children:E?b.jsx(Ft.Password,{value:typeof k=="string"?k:"",onChange:$=>{p(x,{...g,[v]:$.target.value})},placeholder:n("config.editor.secretPlaceholder")}):b.jsx(Ft,{value:typeof k=="string"?k:"",onChange:$=>{p(x,{...g,[v]:$.target.value})}})},v)}if(C instanceof bl)return b.jsx(Pn,{title:w,description:_,icon:An("number"),children:b.jsx(Pv,{value:typeof k=="number"?k:0,onChange:E=>{p(x,{...g,[v]:E??0})}})},v);if(C instanceof Nf)return b.jsx(Pn,{title:w,description:_,icon:An("boolean"),children:b.jsx(ta,{checked:!!k,onChange:E=>{p(x,{...g,[v]:E})}})},v);if(C instanceof Ma||C instanceof yg){const E=(C instanceof Ma?C.options:Object.values(C.enum)).map($=>String($));return b.jsx(Pn,{title:w,description:_,icon:An("string"),children:b.jsx(er,{value:typeof k=="string"?k:void 0,options:E.map($=>({value:$,label:$})),onChange:$=>{p(x,{...g,[v]:$})}})},v)}if(C instanceof ri){if(pc(C.element)instanceof ti){const $=Array.isArray(k)?k.filter(O=>typeof O=="string"):[];return b.jsx(Pn,{title:w,description:_,icon:An("array"),layout:"stacked",children:b.jsx(cy,{value:$,onChange:O=>{p(x,{...g,[v]:O})},t:n})},v)}return b.jsx(Pn,{title:w,description:_,icon:An("array"),layout:"stacked",children:b.jsx(eu,{value:Array.isArray(k)?k:[],onChange:$=>{p(x,{...g,[v]:$})}})},v)}return b.jsx(Pn,{title:w,description:_,icon:An("object"),layout:"stacked",children:b.jsx(eu,{value:k??{},onChange:E=>{p(x,{...g,[v]:E})}})},v)};return b.jsxs("div",{className:"config-view__record-list",children:[b.jsx("div",{className:"config-view__record-add",children:b.jsxs("div",{className:"config-view__record-add-inputs",children:[b.jsx(Ft,{value:o,placeholder:r,onChange:x=>i(x.target.value)}),b.jsx(er,{value:a,options:m,onChange:x=>s(x)}),b.jsx(ht,{title:n("common.confirm"),children:b.jsx(lt,{size:"small",type:"primary",className:"config-view__icon-button","aria-label":n("common.confirm"),icon:b.jsx("span",{className:"material-symbols-rounded",children:"check"}),disabled:o.trim()===""||Object.hasOwn(e,o)||a==="",onClick:()=>{const x=w0(a);x&&(t({...e,[o]:aP(x)}),i(""))}})})]})}),l.map(([x,g])=>{const v=g!=null&&typeof g=="object"?g:{},S=typeof v.type=="string"?v.type:void 0,C=w0(S),_=typeof v.title=="string"?v.title:"",w=typeof v.description=="string"?v.description:"",N=_.trim()!==""?_:x,k=(C==null?void 0:C.label)??S??n("config.editor.unknownChannelType"),E=c[x]===!0,$=C?cs(C.configSchema):{},O=Object.entries($).filter(([R])=>R!=="type").sort(([R],[P])=>{const I=["title","description","enabled","admins"],T=I.indexOf(R),M=I.indexOf(P);return T===-1&&M===-1?R.localeCompare(P):T===-1?1:M===-1?-1:T-M});return b.jsxs("div",{className:`config-view__record-card${E?" config-view__record-card--collapsed":""}`,children:[b.jsxs("div",{className:"config-view__record-title",children:[b.jsxs("div",{className:"config-view__record-title-left",children:[b.jsx(ht,{title:n(E?"config.editor.expand":"config.editor.collapse"),children:b.jsx(lt,{size:"small",type:"text",className:"config-view__icon-button config-view__icon-button--compact","aria-label":n(E?"config.editor.expand":"config.editor.collapse"),icon:b.jsx("span",{className:"material-symbols-rounded",children:E?"chevron_right":"expand_more"}),onClick:()=>{d(R=>({...R,[x]:!E}))}})}),b.jsxs("div",{className:"config-view__record-heading",children:[b.jsx("div",{children:N}),b.jsxs("div",{className:"config-view__record-subtitle",children:[x," · ",k]}),w!==""&&b.jsx("div",{className:"config-view__record-desc",children:w})]})]}),b.jsx("div",{className:"config-view__record-actions",children:b.jsx(ht,{title:n("config.editor.remove"),children:b.jsx(lt,{size:"small",type:"text",danger:!0,className:"config-view__icon-button config-view__icon-button--compact","aria-label":n("config.editor.remove"),icon:b.jsx("span",{className:"material-symbols-rounded",children:"delete"}),onClick:()=>{const R={...e};delete R[x],t(R)}})})})]}),b.jsx("div",{className:"config-view__record-body",children:b.jsxs("div",{className:"config-view__record-fields",children:[b.jsx(Pn,{title:n("config.editor.channelType"),description:(C==null?void 0:C.description)??"",icon:An("string"),children:b.jsx(er,{value:S,options:m,onChange:R=>{const P=w0(R);if(!P)return;const I=aP(P),T=Object.fromEntries(Object.entries(v).filter(([M])=>f.has(M)));p(x,{...I,...T,type:R})}})}),O.map(([R,P])=>h(x,v,R,P))]})})]},x)})]})},HCe=({value:e,onChange:t,t:n,keyPlaceholder:r})=>{const[o,i]=u.useState(""),a=Object.entries(e);return b.jsxs("div",{className:"config-view__record-list",children:[a.map(([s,l])=>b.jsxs("div",{className:"config-view__record-row",children:[b.jsx("div",{className:"config-view__record-key",children:s}),b.jsx(ta,{checked:!!l,onChange:c=>{t({...e,[s]:c})}}),b.jsx(ht,{title:n("config.editor.remove"),children:b.jsx(lt,{size:"small",type:"text",danger:!0,className:"config-view__icon-button config-view__icon-button--compact","aria-label":n("config.editor.remove"),icon:b.jsx("span",{className:"material-symbols-rounded",children:"delete"}),onClick:()=>{const c={...e};delete c[s],t(c)}})})]},s)),b.jsx("div",{className:"config-view__record-add",children:b.jsxs("div",{className:"config-view__record-add-inputs",children:[b.jsx(Ft,{value:o,placeholder:r,onChange:s=>i(s.target.value)}),b.jsx(ht,{title:n("common.confirm"),children:b.jsx(lt,{size:"small",type:"primary",className:"config-view__icon-button","aria-label":n("common.confirm"),icon:b.jsx("span",{className:"material-symbols-rounded",children:"check"}),disabled:o.trim()===""||Object.hasOwn(e,o),onClick:()=>{t({...e,[o]:!0}),i("")}})})]})})]})},PC=({value:e,onChange:t,t:n,keyPlaceholder:r})=>{const[o,i]=u.useState(""),[a,s]=u.useState(""),l=Object.entries(e);return b.jsxs("div",{className:"config-view__array-list",children:[l.map(([c,d])=>b.jsxs("div",{className:"config-view__array-item",children:[b.jsx("div",{className:"config-view__record-key",children:c}),BF(c)?b.jsx(Ft.Password,{value:d,onChange:f=>{t({...e,[c]:f.target.value})},placeholder:n("config.editor.fieldValue")}):b.jsx(Ft,{value:d,onChange:f=>{t({...e,[c]:f.target.value})},placeholder:n("config.editor.fieldValue")}),b.jsx(ht,{title:n("config.editor.remove"),children:b.jsx(lt,{size:"small",type:"text",danger:!0,className:"config-view__icon-button config-view__icon-button--compact","aria-label":n("config.editor.remove"),icon:b.jsx("span",{className:"material-symbols-rounded",children:"delete"}),onClick:()=>{const f={...e};delete f[c],t(f)}})})]},c)),b.jsx("div",{className:"config-view__array-add",children:b.jsxs("div",{className:"config-view__array-add-inputs",children:[b.jsx(Ft,{value:o,placeholder:r,onChange:c=>i(c.target.value)}),b.jsx(Ft,{value:a,placeholder:n("config.editor.fieldValue"),onChange:c=>s(c.target.value)}),b.jsx(ht,{title:n("common.confirm"),children:b.jsx(lt,{size:"small",type:"primary",className:"config-view__icon-button","aria-label":n("common.confirm"),icon:b.jsx("span",{className:"material-symbols-rounded",children:"check"}),disabled:o.trim()===""||Object.hasOwn(e,o),onClick:()=>{const c={...e,[o]:a};t(c),i(""),s("")}})})]})})]})},VCe=({value:e,onChange:t,t:n,keyPlaceholder:r})=>{const[o,i]=u.useState(""),a=u.useMemo(()=>Object.entries(e),[e]),[s,l]=u.useState(()=>Object.fromEntries(a.map(([c])=>[c,!0])));return u.useEffect(()=>{l(c=>{const d={};for(const[f]of a)d[f]=c[f]??!0;return d})},[a]),b.jsxs("div",{className:"config-view__record-list",children:[a.map(([c,d])=>{const f=d!=null&&typeof d=="object"?d:{},m=typeof f.type=="string"?f.type:"command",p=f.env!=null&&typeof f.env=="object"?f.env:{},h=f.headers!=null&&typeof f.headers=="object"?f.headers:{},y=Array.isArray(f.args)?f.args.filter(v=>typeof v=="string"):[],x=v=>{t({...e,[c]:v})},g=s[c]===!0;return b.jsxs("div",{className:`config-view__record-card${g?" config-view__record-card--collapsed":""}`,children:[b.jsxs("div",{className:"config-view__record-title",children:[b.jsxs("div",{className:"config-view__record-title-left",children:[b.jsx(ht,{title:n(g?"config.editor.expand":"config.editor.collapse"),children:b.jsx(lt,{size:"small",type:"text",className:"config-view__icon-button config-view__icon-button--compact","aria-label":n(g?"config.editor.expand":"config.editor.collapse"),icon:b.jsx("span",{className:"material-symbols-rounded",children:g?"chevron_right":"expand_more"}),onClick:()=>{l(v=>({...v,[c]:!g}))}})}),b.jsx("span",{children:c})]}),b.jsx(ht,{title:n("config.editor.remove"),children:b.jsx(lt,{size:"small",type:"text",danger:!0,className:"config-view__icon-button config-view__icon-button--compact","aria-label":n("config.editor.remove"),icon:b.jsx("span",{className:"material-symbols-rounded",children:"delete"}),onClick:()=>{const v={...e};delete v[c],t(v)}})})]}),b.jsx("div",{className:"config-view__record-body",children:b.jsxs("div",{className:"config-view__record-fields",children:[b.jsx(Pn,{title:n("config.fields.mcpServer.enabled.label"),description:n("config.fields.mcpServer.enabled.desc"),icon:An("boolean"),children:b.jsx(ta,{checked:!!f.enabled,onChange:v=>{x({...f,enabled:v})}})}),b.jsx(Pn,{title:n("config.fields.mcpServer.type.label"),description:n("config.fields.mcpServer.type.desc"),icon:An("string"),children:b.jsx(er,{value:m,options:[{value:"command",label:n("config.options.mcp.command")},{value:"sse",label:n("config.options.mcp.sse")},{value:"http",label:n("config.options.mcp.http")}],onChange:v=>{const S={...f};v==="command"?(delete S.type,S.command==null&&(S.command=""),S.args==null&&(S.args=[]),delete S.url,delete S.headers):(S.type=v,S.url==null&&(S.url=""),S.headers==null&&(S.headers={}),delete S.command,delete S.args),x(S)}})}),m==="command"&&b.jsxs(b.Fragment,{children:[b.jsx(Pn,{title:n("config.fields.mcpServer.command.label"),description:n("config.fields.mcpServer.command.desc"),icon:An("string"),children:b.jsx(Ft,{value:typeof f.command=="string"?f.command:"",onChange:v=>{x({...f,command:v.target.value})},placeholder:n("config.editor.commandPlaceholder")})}),b.jsx(Pn,{title:n("config.fields.mcpServer.args.label"),description:n("config.fields.mcpServer.args.desc"),icon:An("array"),layout:"stacked",children:b.jsx(cy,{value:y,onChange:v=>{x({...f,args:v})},t:n})})]}),m!=="command"&&b.jsxs(b.Fragment,{children:[b.jsx(Pn,{title:n("config.fields.mcpServer.url.label"),description:n("config.fields.mcpServer.url.desc"),icon:An("string"),children:b.jsx(Ft,{value:typeof f.url=="string"?f.url:"",onChange:v=>{x({...f,url:v.target.value})},placeholder:n("config.editor.urlPlaceholder")})}),b.jsx(Pn,{title:n("config.fields.mcpServer.headers.label"),description:n("config.fields.mcpServer.headers.desc"),icon:An("object"),layout:"stacked",children:b.jsx(PC,{value:h,onChange:v=>{x({...f,headers:v})},t:n,keyPlaceholder:n("config.editor.newHeaderName")})})]}),b.jsx(Pn,{title:n("config.fields.mcpServer.env.label"),description:n("config.fields.mcpServer.env.desc"),icon:An("object"),layout:"stacked",children:b.jsx(PC,{value:p,onChange:v=>{x({...f,env:v})},t:n,keyPlaceholder:n("config.editor.newEnvVarName")})})]})})]},c)}),b.jsx("div",{className:"config-view__record-add",children:b.jsxs("div",{className:"config-view__record-add-inputs",children:[b.jsx(Ft,{value:o,placeholder:r,onChange:c=>i(c.target.value)}),b.jsx(ht,{title:n("common.confirm"),children:b.jsx(lt,{size:"small",type:"primary",className:"config-view__icon-button","aria-label":n("common.confirm"),icon:b.jsx("span",{className:"material-symbols-rounded",children:"check"}),disabled:o.trim()===""||Object.hasOwn(e,o),onClick:()=>{t({...e,[o]:{enabled:!0,command:"",args:[]}}),i("")}})})]})})]})},WCe=({value:e,onChange:t,t:n,keyPlaceholder:r})=>{const[o,i]=u.useState(""),a=u.useMemo(()=>Object.entries(e),[e]),[s,l]=u.useState(()=>Object.fromEntries(a.map(([c])=>[c,!0])));return u.useEffect(()=>{l(c=>{const d={};for(const[f]of a)d[f]=c[f]??!0;return d})},[a]),b.jsxs("div",{className:"config-view__record-list",children:[a.map(([c,d])=>{const f=d!=null&&typeof d=="object"?d:{},m=typeof f.title=="string"?f.title:"",p=typeof f.description=="string"?f.description:"",h=m.trim()!==""?m:c,y=Array.isArray(f.models)?f.models.filter(g=>typeof g=="string"):[],x=s[c]===!0;return b.jsxs("div",{className:`config-view__record-card${x?" config-view__record-card--collapsed":""}`,children:[b.jsxs("div",{className:"config-view__record-title",children:[b.jsxs("div",{className:"config-view__record-title-left",children:[b.jsx(ht,{title:n(x?"config.editor.expand":"config.editor.collapse"),children:b.jsx(lt,{size:"small",type:"text",className:"config-view__icon-button config-view__icon-button--compact","aria-label":n(x?"config.editor.expand":"config.editor.collapse"),icon:b.jsx("span",{className:"material-symbols-rounded",children:x?"chevron_right":"expand_more"}),onClick:()=>{l(g=>({...g,[c]:!x}))}})}),b.jsxs("div",{className:"config-view__record-heading",children:[b.jsx("div",{children:h}),h!==c&&b.jsx("div",{className:"config-view__record-subtitle",children:c}),p!==""&&b.jsx("div",{className:"config-view__record-desc",children:p})]})]}),b.jsx(ht,{title:n("config.editor.remove"),children:b.jsx(lt,{size:"small",type:"text",danger:!0,className:"config-view__icon-button config-view__icon-button--compact","aria-label":n("config.editor.remove"),icon:b.jsx("span",{className:"material-symbols-rounded",children:"delete"}),onClick:()=>{const g={...e};delete g[c],t(g)}})})]}),b.jsx("div",{className:"config-view__record-body",children:b.jsxs("div",{className:"config-view__record-fields",children:[b.jsx(Pn,{title:n("config.fields.modelServices.item.title.label"),description:n("config.fields.modelServices.item.title.desc"),icon:An("string"),children:b.jsx(Ft,{value:m,onChange:g=>{t({...e,[c]:{...f,title:g.target.value}})},placeholder:n("config.editor.titlePlaceholder")})}),b.jsx(Pn,{title:n("config.fields.modelServices.item.description.label"),description:n("config.fields.modelServices.item.description.desc"),icon:An("string"),layout:"stacked",children:b.jsx(Ft.TextArea,{value:p,onChange:g=>{t({...e,[c]:{...f,description:g.target.value}})},autoSize:{minRows:2},placeholder:n("config.editor.descriptionPlaceholder")})}),b.jsx(Pn,{title:n("config.fields.modelServices.item.apiBaseUrl.label"),description:n("config.fields.modelServices.item.apiBaseUrl.desc"),icon:An("string"),children:b.jsx(Ft,{value:typeof f.apiBaseUrl=="string"?f.apiBaseUrl:"",onChange:g=>{t({...e,[c]:{...f,apiBaseUrl:g.target.value}})}})}),b.jsx(Pn,{title:n("config.fields.modelServices.item.apiKey.label"),description:n("config.fields.modelServices.item.apiKey.desc"),icon:An("string"),children:b.jsx(Ft.Password,{value:typeof f.apiKey=="string"?f.apiKey:"",onChange:g=>{t({...e,[c]:{...f,apiKey:g.target.value}})},placeholder:n("config.editor.secretPlaceholder")})}),b.jsx(Pn,{title:n("config.fields.modelServices.item.models.label"),description:n("config.fields.modelServices.item.models.desc"),icon:An("array"),layout:"stacked",children:b.jsx(cy,{value:y,onChange:g=>{t({...e,[c]:{...f,models:g}})},t:n})}),b.jsx(Pn,{title:n("config.fields.modelServices.item.modelsAlias.label"),description:n("config.fields.modelServices.item.modelsAlias.desc"),icon:An("object"),layout:"stacked",children:b.jsx(eu,{value:f.modelsAlias??{},onChange:g=>{t({...e,[c]:{...f,modelsAlias:g}})}})}),b.jsx(Pn,{title:n("config.fields.modelServices.item.extra.label"),description:n("config.fields.modelServices.item.extra.desc"),icon:An("object"),layout:"stacked",children:b.jsx(eu,{value:f.extra??{},onChange:g=>{t({...e,[c]:{...f,extra:g}})}})})]})})]},c)}),b.jsx("div",{className:"config-view__record-add",children:b.jsxs("div",{className:"config-view__record-add-inputs",children:[b.jsx(Ft,{value:o,placeholder:r,onChange:c=>i(c.target.value)}),b.jsx(ht,{title:n("common.confirm"),children:b.jsx(lt,{size:"small",type:"primary",className:"config-view__icon-button","aria-label":n("common.confirm"),icon:b.jsx("span",{className:"material-symbols-rounded",children:"check"}),disabled:o.trim()===""||Object.hasOwn(e,o),onClick:()=>{t({...e,[o]:{title:"",description:"",apiBaseUrl:"",apiKey:"",models:[],modelsAlias:{},extra:{}}}),i("")}})})]})})]})},KCe=({value:e,onChange:t,t:n,keyPlaceholder:r})=>{const[o,i]=u.useState(""),a=u.useMemo(()=>Object.entries(e),[e]),[s,l]=u.useState(()=>Object.fromEntries(a.map(([c])=>[c,!0])));return u.useEffect(()=>{l(c=>{const d={};for(const[f]of a)d[f]=c[f]??!0;return d})},[a]),b.jsxs("div",{className:"config-view__record-list",children:[a.map(([c,d])=>{const f=s[c]===!0;return b.jsxs("div",{className:`config-view__record-card${f?" config-view__record-card--collapsed":""}`,children:[b.jsxs("div",{className:"config-view__record-title",children:[b.jsxs("div",{className:"config-view__record-title-left",children:[b.jsx(ht,{title:n(f?"config.editor.expand":"config.editor.collapse"),children:b.jsx(lt,{size:"small",type:"text",className:"config-view__icon-button config-view__icon-button--compact","aria-label":n(f?"config.editor.expand":"config.editor.collapse"),icon:b.jsx("span",{className:"material-symbols-rounded",children:f?"chevron_right":"expand_more"}),onClick:()=>{l(m=>({...m,[c]:!f}))}})}),b.jsx("span",{children:c})]}),b.jsx(ht,{title:n("config.editor.remove"),children:b.jsx(lt,{size:"small",type:"text",danger:!0,className:"config-view__icon-button config-view__icon-button--compact","aria-label":n("config.editor.remove"),icon:b.jsx("span",{className:"material-symbols-rounded",children:"delete"}),onClick:()=>{const m={...e};delete m[c],t(m)}})})]}),b.jsx("div",{className:"config-view__record-body",children:b.jsx(eu,{value:d,onChange:m=>{t({...e,[c]:m})}})})]},c)}),b.jsx("div",{className:"config-view__record-add",children:b.jsxs("div",{className:"config-view__record-add-inputs",children:[b.jsx(Ft,{value:o,placeholder:r,onChange:c=>i(c.target.value)}),b.jsx(ht,{title:n("common.confirm"),children:b.jsx(lt,{size:"small",type:"primary",className:"config-view__icon-button","aria-label":n("common.confirm"),icon:b.jsx("span",{className:"material-symbols-rounded",children:"check"}),disabled:o.trim()===""||Object.hasOwn(e,o),onClick:()=>{t({...e,[o]:{}}),i("")}})})]})})]})},UCe=({sectionKey:e,fields:t,value:n,onChange:r,mergedModelServices:o,mergedAdapters:i,selectedModelService:a,t:s})=>{const l=t??sCe[e]??[];if(l.length===0)return b.jsx(yn,{description:s("common.noData"),image:null});const c=new Set(["modelServices","channels","adapters","plugins","mcp"]),f=Object.entries(o).map(([C,_])=>{const w=_!=null&&typeof _=="object"?_:{},N=typeof w.title=="string"&&w.title.trim()!==""?w.title:C,k=typeof w.description=="string"?w.description:"";return{value:C,label:b.jsxs("div",{className:"config-view__option",children:[b.jsx("div",{className:"config-view__option-title",children:N}),k!==""&&b.jsx("div",{className:"config-view__option-desc",children:k})]})}}),m=a?o[a]:void 0,p=m!=null&&typeof m=="object"?m.models:void 0,h=Array.isArray(p)?p.filter(C=>typeof C=="string").map(C=>({value:C,label:b.jsx("span",{children:C})})):[],y=Object.keys(i).map(C=>({value:C,label:b.jsx("span",{children:C})})),x=l.reduce((C,_)=>{const w=_.group??"default";return C[w]||(C[w]=[]),C[w].push(_),C},{}),g=["base","permissions","env","items","default"].filter(C=>{var _;return(_=x[C])==null?void 0:_.length}),v=C=>e==="modelServices"?s("config.editor.newModelServiceName"):e==="channels"?s("config.editor.newChannelName"):e==="adapters"?s("config.editor.newAdapterName"):e==="plugins"?C.path.join(".")==="extraKnownMarketplaces"?s("config.editor.newMarketplaceName"):s("config.editor.newPluginName"):e==="mcp"?s("config.editor.newMcpServerName"):e==="general"&&C.path.join(".")==="env"?s("config.editor.newEnvVarName"):s("config.editor.fieldKey"),S=C=>{const _=Kp(n,C.path),w=_!==void 0?_:C.defaultValue,N=C.labelKey?s(C.labelKey):DF(s,e,C.path,C.path[C.path.length-1]??""),k=C.descriptionKey?s(C.descriptionKey):zF(s,e,C.path),E=C.icon??An(LF(w)),$=P=>{const I=UR(n,C.path,P);r(I)};let O=null;const R=["multiline","json","record","string[]"].includes(C.type);if(C.type==="string"){const P=C.placeholderKey?s(C.placeholderKey):void 0;C.sensitive===!0?O=b.jsx(Ft.Password,{value:typeof w=="string"?w:"",onChange:I=>$(I.target.value),placeholder:s("config.editor.secretPlaceholder")}):O=b.jsx(Ft,{value:typeof w=="string"?w:"",onChange:I=>$(I.target.value),placeholder:P})}else if(C.type==="multiline"){const P=typeof w=="string"?w:"",I=C.placeholderKey?s(C.placeholderKey):s("config.editor.multilinePlaceholder");O=b.jsx("div",{className:"config-view__multiline",children:b.jsx(Ft.TextArea,{className:"config-view__multiline-input",value:P,onChange:T=>$(T.target.value),autoSize:{minRows:3},placeholder:I})})}else if(C.type==="number")if(C.path.join(".")==="notifications.volume"){const I=typeof w=="number"?w:0;O=b.jsx(Dte,{className:"config-view__slider",min:0,max:100,step:1,value:I,onChange:T=>$(typeof T=="number"?T:0)})}else O=b.jsx(Pv,{value:typeof w=="number"?w:0,onChange:I=>$(typeof I=="number"?I:0)});else if(C.type==="boolean")O=b.jsx(ta,{checked:!!w,onChange:P=>$(P)});else if(C.type==="string[]"){const P=Array.isArray(w)?w.filter(I=>typeof I=="string"):[];O=b.jsx(cy,{value:P,onChange:I=>$(I),t:s})}else if(C.type==="select"){const P=e==="general"&&C.path.join(".")==="defaultAdapter",I=e==="general"&&C.path.join(".")==="defaultModelService",T=e==="general"&&C.path.join(".")==="defaultModel",M=I?f:T?h:P?y:(C.options??[]).map(L=>({value:L.value,label:b.jsx("span",{children:s(L.label)})}));O=b.jsx(er,{value:typeof w=="string"&&w!==""?w:void 0,options:M,onChange:L=>$(L),allowClear:!0,disabled:T&&h.length===0,placeholder:s(P?"config.editor.defaultAdapterPlaceholder":I?"config.editor.defaultModelServicePlaceholder":"config.editor.defaultModelPlaceholder")})}else if(C.type==="json")O=b.jsx(eu,{value:w,onChange:$});else if(C.type==="record"){const P=w!=null&&typeof w=="object"?w:{};C.recordKind==="modelServices"?O=b.jsx(WCe,{value:P,onChange:$,t:s,keyPlaceholder:v(C)}):C.recordKind==="channels"?O=b.jsx(FCe,{value:P,onChange:$,t:s,keyPlaceholder:v(C)}):C.recordKind==="mcpServers"?O=b.jsx(VCe,{value:P,onChange:$,t:s,keyPlaceholder:v(C)}):C.recordKind==="keyValue"?O=b.jsx(PC,{value:P,onChange:$,t:s,keyPlaceholder:v(C)}):C.recordKind==="boolean"?O=b.jsx(HCe,{value:P,onChange:$,t:s,keyPlaceholder:v(C)}):O=b.jsx(KCe,{value:P,onChange:$,t:s,keyPlaceholder:v(C)})}else if(C.type==="shortcut"){const P=navigator.platform.includes("Mac");O=b.jsx(iCe,{value:typeof w=="string"?w:"",onChange:I=>$(I),placeholder:s("config.editor.shortcutPlaceholder"),isMac:P,t:s})}return c.has(e)&&C.type==="record"?b.jsx("div",{children:O},`${C.path.join(".")}-${C.type}-${C.recordKind??""}`):b.jsx(Pn,{title:N,description:k,icon:E,layout:R?"stacked":"inline",children:O},`${C.path.join(".")}-${C.type}-${C.labelKey??""}-${C.recordKind??""}`)};return b.jsx("div",{className:"config-view__field-stack",children:g.map(C=>{const _=x[C]??[];if(new Set(["base","permissions"]).has(C)&&!_.some(I=>{const T=Kp(n,I.path);return typeof T=="boolean"?T:!dg(T)}))return null;if(C==="default")return c.has(e)?b.jsx("div",{children:_.map(S)},C):b.jsx("div",{className:"config-view__field-list",children:_.map(S)},C);const N=(()=>{var I,T;const P=(T=(I=aCe[e])==null?void 0:I[C])==null?void 0:T.labelKey;return s(P||(C==="base"?"config.sectionGroups.base":C==="permissions"?"config.sectionGroups.permissions":C==="env"?"config.sectionGroups.env":e==="plugins"?"config.sectionGroups.plugins":"config.sectionGroups.items"))})(),k=_.filter(P=>P.hidden!==!0),E=k.filter(P=>P.collapse!=null),$=k.filter(P=>P.collapse==null),O=E.reduce((P,I)=>{const T=I.collapse;if(!T)return P;const M=P.get(T.key);return M?M.fields.push(I):P.set(T.key,{meta:T,fields:[I]}),P},new Map),R=Array.from(O.values()).map(P=>({key:P.meta.key,collapsible:"header",label:b.jsxs("div",{className:"config-view__collapse-header",children:[b.jsxs("div",{className:"config-view__collapse-header-main",children:[b.jsx("div",{className:"config-view__collapse-title",children:s(P.meta.labelKey)}),P.meta.descKey&&b.jsx("div",{className:"config-view__collapse-desc",children:s(P.meta.descKey)})]}),P.meta.togglePath&&b.jsx(ta,{checked:!Kp(n,P.meta.togglePath),onChange:I=>{const T=UR(n,P.meta.togglePath,!I);r(T)},onClick:(I,T)=>{T.stopPropagation()}})]}),children:b.jsx("div",{className:"config-view__field-list",children:P.fields.map(S)})}));return b.jsxs("div",{className:"config-view__subsection",children:[b.jsx("div",{className:"config-view__subsection-title",children:N}),b.jsxs("div",{className:"config-view__subsection-body",children:[$.map(S),R.length>0&&b.jsx(r7,{className:"config-view__collapse-group config-view__field-row",ghost:!0,items:R})]})]},C)})})};function UF({sectionKey:e,title:t,icon:n,fields:r,value:o,onChange:i,mergedModelServices:a,mergedAdapters:s,selectedModelService:l,headerExtra:c,t:d,className:f}){const m=["config-view__editor-wrap",f].filter(Boolean).join(" "),p=t!=null||n!=null||c!=null;return b.jsxs("div",{className:m,children:[p&&b.jsxs("div",{className:"config-view__section-header",children:[b.jsxs("div",{className:"config-view__section-title",children:[n!=null&&b.jsx("span",{className:"material-symbols-rounded config-view__section-icon",children:n}),b.jsx("span",{children:t})]}),c]}),b.jsx("div",{className:"config-view__card",children:b.jsx(UCe,{sectionKey:e,fields:r,value:o,onChange:i,mergedModelServices:a,mergedAdapters:s,selectedModelService:l,t:d})})]})}function GCe({value:e,onChange:t,options:n}){return b.jsx(Nl.Group,{value:e,optionType:"button",buttonStyle:"solid",size:"small",onChange:r=>{t(r.target.value)},options:n.map(r=>({value:r.value,label:b.jsxs("span",{className:"config-view__source-option",children:[b.jsx("span",{className:"material-symbols-rounded",children:r.icon}),b.jsx("span",{children:r.label})]})}))})}function qCe({sessionInfo:e,sessionId:t,sessionTitle:n,isStarred:r,isArchived:o,tags:i,lastMessage:a,lastUserMessage:s,activeView:l,onViewChange:c}){const{t:d}=Ot(),{message:f}=_o.useApp(),m=vl(p1),p=vl(Vz),[h,y]=u.useState(""),x=(e==null?void 0:e.type)==="summary"?e.summary:null,g=((e==null?void 0:e.type)==="init"?e.title:null)??n;(e==null?void 0:e.type)==="init"&&e.cwd;const v=g!=null&&g!==""?g:x!=null&&x!==""?x:s!=null&&s!==""?s:a!=null&&a!==""?a:d("common.newChat");u.useEffect(()=>{g!=null&&g!==""&&y(g)},[g]);const S=async()=>{if(!(t==null||t===""))try{await Sa(t,{isStarred:!r}),f.success(d(r?"common.unstarred":"common.starred"))}catch(w){f.error(jr(w,d("common.operationFailed")))}},C=async()=>{if(!(t==null||t===""))try{await Sa(t,{isArchived:!o}),f.success(d(o?"common.restored":"common.archived"))}catch(w){f.error(jr(w,d("common.operationFailed")))}},_=[{key:"star",label:d(r?"common.unstar":"common.star"),icon:b.jsx("span",{className:`material-symbols-rounded ${r?"is-filled":""}`,style:{fontSize:"18px"},children:r?"star":"star_border"}),onClick:()=>{S()}},{key:"archive",label:d(o?"common.restore":"common.archive"),icon:b.jsx("span",{className:"material-symbols-rounded",style:{fontSize:"18px"},children:o?"unarchive":"archive"}),onClick:()=>{C()}}];return b.jsxs("div",{className:`chat-header ${m?"is-collapsed":""} ${p?"is-resizing":""}`,children:[b.jsx("div",{style:{display:"flex",alignItems:"center",gap:"12px",flex:1,minWidth:0},children:b.jsxs("div",{className:"chat-header-info",children:[b.jsx("div",{className:"chat-header-title",children:v}),b.jsx("div",{className:"chat-header-subtitle",onDoubleClick:()=>{console.log("Session Full Info:",{sessionId:t,sessionTitle:n,isStarred:r,isArchived:o,tags:i,lastMessage:a,lastUserMessage:s,sessionInfo:e})},style:{cursor:"pointer",userSelect:"all"},children:t??d("chat.selectModel")})]})}),b.jsxs("div",{className:"chat-header-actions",children:[b.jsx(Nl.Group,{className:"chat-header-view-group",value:l,optionType:"button",buttonStyle:"solid",size:"small",onChange:w=>{c(w.target.value)},options:[{label:b.jsx("span",{className:"chat-header-view-option material-symbols-rounded",children:"forum"}),value:"history"},{label:b.jsx("span",{className:"chat-header-view-option material-symbols-rounded",children:"timeline"}),value:"timeline"},{label:b.jsx("span",{className:"chat-header-view-option material-symbols-rounded",children:"tune"}),value:"settings"}]}),b.jsx("div",{className:"chat-header-divider"}),b.jsx(Qc,{menu:{items:_},placement:"bottomRight",trigger:["click"],children:b.jsx(lt,{type:"text",icon:b.jsx("span",{className:"material-symbols-rounded",children:"more_vert"})})})]})]})}function XCe({sessionId:e,initialTitle:t,initialTags:n=[],onClose:r}){const{t:o}=Ot(),{message:i,modal:a}=_o.useApp(),s=u.useMemo(()=>[{path:["title"],type:"string",defaultValue:"",icon:"edit_note",labelKey:"chat.title",placeholderKey:"chat.enterTitle"},{path:["tags"],type:"string[]",defaultValue:[],icon:"sell",labelKey:"chat.tags"}],[]),l=u.useMemo(()=>({title:t??"",tags:n}),[n,t]),[c,d]=u.useState(l),f=u.useRef(l),m=u.useRef(null),p=u.useRef(!1),h=u.useRef(null);u.useEffect(()=>{d(l)},[l]),u.useEffect(()=>{f.current=c},[c]),u.useEffect(()=>()=>{m.current&&clearTimeout(m.current)},[]);const y=v=>{const S=JSON.stringify(v??{});h.current!==S&&(m.current&&clearTimeout(m.current),m.current=setTimeout(async()=>{if(p.current)return;const C=f.current,_=JSON.stringify(C??{});if(h.current!==_){p.current=!0;try{await Sa(e,{title:typeof C.title=="string"?C.title:"",tags:Array.isArray(C.tags)?C.tags:[]}),h.current=_}catch(w){i.error(jr(w,o("common.operationFailed")))}finally{p.current=!1}}},500))},x=v=>{const S=v!=null&&typeof v=="object"?v:{},C={title:typeof S.title=="string"?S.title:"",tags:Array.isArray(S.tags)?S.tags.filter(_=>typeof _=="string"):[]};d(C),y(C)},g=()=>{a.confirm({title:o("common.deleteSession"),content:o("common.deleteSessionConfirm"),okText:o("common.delete"),okType:"danger",cancelText:o("common.cancel"),onOk:async()=>{try{await qh(e),i.success(o("common.deleteSuccess")),r()}catch(v){i.error(jr(v,o("common.deleteFailed")))}}})};return b.jsxs("div",{className:"session-settings-drawer",children:[b.jsx(UF,{sectionKey:"session",title:null,icon:void 0,fields:s,value:c,onChange:x,mergedModelServices:{},mergedAdapters:{},selectedModelService:void 0,t:o,className:"session-settings-drawer__form"}),b.jsx("div",{className:"settings-footer",children:b.jsx("div",{className:"danger-zone",children:b.jsxs("div",{className:"delete-session-row",children:[b.jsxs("div",{className:"delete-session-meta",children:[b.jsx("div",{className:"delete-session-title",children:o("chat.deleteSessionTitle")}),b.jsx("div",{className:"delete-session-desc",children:o("chat.deleteSessionDesc")})]}),b.jsx(lt,{danger:!0,type:"primary",size:"middle",icon:b.jsx("span",{className:"material-symbols-rounded",children:"delete_forever"}),onClick:g,className:"delete-session-btn",children:o("common.delete")})]})})})]})}const YCe=80;function QCe({messagesLength:e}){const t=u.useRef(null),n=u.useRef(null),r=u.useRef(null),[o,i]=u.useState(!1),a=u.useCallback(()=>{const l=n.current;if(!l)return;const c=l.scrollHeight-(l.scrollTop+l.clientHeight);i(c>YCe)},[]),s=u.useCallback((l="smooth")=>{setTimeout(()=>{n.current&&n.current.scrollTo({top:n.current.scrollHeight,behavior:l})},50)},[]);return u.useEffect(()=>{const l=n.current;if(!l)return;a();const c=()=>a();return l.addEventListener("scroll",c,{passive:!0}),()=>{l.removeEventListener("scroll",c)}},[a]),u.useEffect(()=>{a()},[a,e]),{messagesEndRef:t,messagesContainerRef:n,messagesContentRef:r,showScrollBottom:o,scrollToBottom:s}}class ZCe{constructor(){je(this,"sockets",new Map);je(this,"subscribers",new Map);je(this,"disconnectTimers",new Map);je(this,"connectionParams",new Map);je(this,"DISCONNECT_DELAY",6e4)}connect(t,n,r){var l;this.disconnectTimers.has(t)&&(clearTimeout(this.disconnectTimers.get(t)),this.disconnectTimers.delete(t)),this.subscribers.has(t)||this.subscribers.set(t,new Set),this.subscribers.get(t).add(n);const o=this.normalizeParams({sessionId:t,...r??{}}),i=this.buildParamsKey(o),a=this.connectionParams.get(t);let s=this.sockets.get(t);return a!=null&&a!==i&&s&&(s.close(),this.sockets.delete(t),s=void 0),!s||s.readyState===WebSocket.CLOSED||s.readyState===WebSocket.CLOSING?this.createConnection(t,o):s.readyState===WebSocket.OPEN&&((l=n.onOpen)==null||l.call(n)),this.connectionParams.set(t,i),()=>this.disconnect(t,n)}createConnection(t,n){const r=qz({onOpen:()=>{this.broadcast(t,"onOpen")},onMessage:o=>{this.broadcast(t,"onMessage",o)},onError:o=>{this.broadcast(t,"onError",o)},onClose:()=>{this.broadcast(t,"onClose"),this.sockets.get(t)===r&&this.sockets.delete(t)}},n);this.sockets.set(t,r)}disconnect(t,n){const r=this.subscribers.get(t);r&&(r.delete(n),r.size===0&&this.disconnectTimers.set(t,setTimeout(()=>{const o=this.sockets.get(t);o&&(o.close(),this.sockets.delete(t)),this.disconnectTimers.delete(t),this.subscribers.delete(t),this.connectionParams.delete(t)},this.DISCONNECT_DELAY)))}broadcast(t,n,r){const o=this.subscribers.get(t);o&&Array.from(o).forEach(a=>{if(a[n])try{a[n](r)}catch(s){console.error(`Error in ${n} handler for session ${t}:`,s)}})}close(t){const n=this.sockets.get(t);n&&(n.close(),this.sockets.delete(t)),this.disconnectTimers.has(t)&&(clearTimeout(this.disconnectTimers.get(t)),this.disconnectTimers.delete(t)),this.subscribers.delete(t),this.connectionParams.delete(t)}send(t,n){const r=this.sockets.get(t);r&&r.readyState===WebSocket.OPEN?r.send(typeof n=="string"?n:JSON.stringify(n)):console.warn(`Cannot send message: Session ${t} not connected or ready`)}normalizeParams(t){return Object.entries(t).reduce((n,[r,o])=>{if(o==null)return n;const i=String(o).trim();return i===""||(n[r]=i),n},{})}buildParamsKey(t){return Object.entries(t).sort(([n],[r])=>n.localeCompare(r)).map(([n,r])=>`${n}=${r}`).join("&")}}const Ca=new ZCe;function JCe({session:e,modelForQuery:t,hasAvailableModels:n,permissionMode:r,adapter:o,onClearMessages:i}){const{message:a}=_o.useApp(),{t:s}=Ot(),l=Ts(),{mutate:c}=Xv(),[d,f]=u.useState(!1),m=d||(e==null?void 0:e.status)==="running";u.useEffect(()=>{!d||(e==null?void 0:e.id)==null||e.id===""||f(!1)},[d,e==null?void 0:e.id]);const p=u.useCallback(async g=>{if(g.trim()===""||m)return!1;if(!n)return a.warning(s("chat.modelConfigRequired")),!1;if(!(e!=null&&e.id)){f(!0);try{const{session:v}=await II(void 0,g.trim(),void 0,t,{permissionMode:r,adapter:o});return await c("/api/sessions",S=>S!=null&&S.sessions?{...S,sessions:[v,...S.sessions]}:{sessions:[v]},!1),l(`/session/${v.id}`),!0}catch(v){return console.error(v),f(!1),a.error(jr(v,"Failed to create session")),!1}}return Ca.send(e.id,{type:"user_message",text:g.trim()}),!0},[o,n,m,a,c,l,r,t,e==null?void 0:e.id,s]),h=u.useCallback(async g=>{if(g.length===0||m)return!1;if(!n)return a.warning(s("chat.modelConfigRequired")),!1;if(!(e!=null&&e.id)){f(!0);try{const{session:v}=await II(void 0,void 0,g,t,{permissionMode:r,adapter:o});return await c("/api/sessions",S=>S!=null&&S.sessions?{...S,sessions:[v,...S.sessions]}:{sessions:[v]},!1),l(`/session/${v.id}`),!0}catch(v){return console.error(v),f(!1),a.error(jr(v,"Failed to create session")),!1}}return Ca.send(e.id,{type:"user_message",content:g}),!0},[o,n,m,a,c,l,r,t,e==null?void 0:e.id,s]),y=u.useCallback(()=>{!(e!=null&&e.id)||m===!1||Ca.send(e.id,{type:"interrupt"})},[m,e==null?void 0:e.id]),x=u.useCallback(()=>{i(),a.success("Messages cleared")},[a,i]);return{isCreating:d,isThinking:m,send:p,sendContent:h,interrupt:y,clearMessages:x}}function ewe({messages:e}){const{t}=Ot(),[n,r]=u.useState(!1);let o=[];for(let s=e.length-1;s>=0;s--){const l=e[s];if(l.role==="assistant"&&Array.isArray(l.content)){const c=l.content.find(d=>d!=null&&d.type==="tool_use"&&(d.name==="TodoWrite"||d.name==="todo_write"||d.name==="adapter:claude-code:TodoWrite"||d.name==="adapter:claude-code:todo_write"));if(c!=null&&c.type==="tool_use"&&c.input!=null&&typeof c.input=="object"){const d=c.input;if(Array.isArray(d.todos)){o=d.todos;break}}}}if(o.length===0)return null;const i=o.filter(s=>s.status==="completed").length,a=o.length;return a===0?b.jsx("div",{className:"current-todo-container empty",children:b.jsx("div",{className:"todo-progress-bar empty",children:b.jsxs("div",{className:"progress-info",children:[b.jsx("span",{className:"material-symbols-rounded",children:"assignment_late"}),b.jsx("span",{className:"text",children:t("chat.todo.noTasks")})]})})}):b.jsxs("div",{className:`current-todo-container ${n?"expanded":""}`,children:[b.jsxs("div",{className:"todo-progress-bar",onClick:()=>r(!n),children:[b.jsxs("div",{className:"progress-info",children:[b.jsx("span",{className:"material-symbols-rounded",children:"assignment"}),b.jsx("span",{className:"text",children:t("chat.todo.progress",{completed:i,total:a})})]}),b.jsx("div",{className:"progress-track",children:b.jsx("div",{className:"progress-fill",style:{width:`${i/a*100}%`}})}),b.jsx("button",{className:"expand-btn",children:b.jsx("span",{className:"material-symbols-rounded",children:n?"expand_more":"expand_less"})})]}),n&&b.jsx("div",{className:"todo-items-overlay",children:b.jsx("div",{className:"todo-items-scroll-container",children:o.map((s,l)=>b.jsxs("div",{className:`todo-item-vertical status-${s.status}`,children:[b.jsx("span",{className:"material-symbols-rounded icon",children:s.status==="completed"?"check_circle":s.status==="in_progress"?"clock_loader_40":"radio_button_unchecked"}),b.jsxs("div",{className:"todo-content-wrapper",children:[b.jsx("span",{className:"text",children:s.content}),s.priority!=null&&s.priority!==""&&b.jsx("span",{className:`priority-tag ${s.priority}`,children:s.priority})]})]},s.id||l))})})]})}function TC({msg:e,isUser:t}){const{message:n}=_o.useApp();return b.jsxs("div",{className:"msg-footer",children:[t&&e.model!=null&&b.jsx("span",{className:"msg-model",children:e.model.split(",").pop()}),t&&e.usage!=null&&b.jsxs("span",{className:"msg-usage",children:["Tokens: ",e.usage.input_tokens+e.usage.output_tokens]}),b.jsx("span",{className:"timestamp",onDoubleClick:()=>{console.log("Debug Message:",e),navigator.clipboard.writeText(new Date(e.createdAt).toISOString()),n.success("ISO 时间已复制到剪贴板")},title:"双击复制 ISO 时间 (控制台打印消息结构)",children:new Date(e.createdAt).toLocaleString("zh-CN",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1})})]})}function wo({header:e,content:t,isError:n=!1,type:r="call",defaultExpanded:o=!1,collapsible:i=!0,onDoubleClick:a}){const[s,l]=u.useState(o||!i),c=!i||s;return b.jsxs("div",{className:`tool-call-box ${r==="result"?"result":""} ${c?"expanded":"collapsed"}`,onDoubleClick:d=>{a&&(d.stopPropagation(),a(d))},children:[b.jsxs("div",{className:`tool-call-header ${r==="result"&&n?"error":""}`,onClick:()=>i&&l(!s),children:[b.jsx("div",{className:"tool-call-header-main",children:e}),i&&b.jsx("span",{className:"material-symbols-rounded expand-icon",children:c?"expand_less":"expand_more"})]}),c&&b.jsx("div",{className:"tool-call-body",children:t})]})}function ts(e,t=new WeakSet){if(e==null)return e;const n=typeof e;if(n==="bigint"||n==="symbol")return e.toString();if(n==="function")return"[Function]";if(n!=="object")return e;if(e instanceof Date)return e.toISOString();if(e instanceof Error)return{name:e.name,message:e.message,stack:e.stack};if(e instanceof Map)return Array.from(e.entries()).map(([i,a])=>[ts(i,t),ts(a,t)]);if(e instanceof Set)return Array.from(e.values()).map(i=>ts(i,t));if(ArrayBuffer.isView(e))return Array.from(e);if(e instanceof ArrayBuffer)return Array.from(new Uint8Array(e));if(Array.isArray(e))return e.map(i=>ts(i,t));const r=e;if(t.has(r))return"[Circular]";if(t.add(r),typeof r.toJSON=="function")try{return ts(r.toJSON(),t)}catch{return String(r)}const o={};for(const[i,a]of Object.entries(r))o[i]=ts(a,t);return o}function ra(e,t=2){try{const n=ts(e);return JSON.stringify(n,null,t)??"null"}catch{return JSON.stringify(String(e))??"null"}}function twe(e){if(typeof e!="string")return e;const t=e.trim();if(t.startsWith("{")&&t.endsWith("}")||t.startsWith("[")&&t.endsWith("]"))try{return JSON.parse(t)}catch{return e}return e}function nwe(e){const t=typeof e.url=="string"?e.url:typeof e.src=="string"?e.src:typeof e.image_url=="string"?e.image_url:typeof e.imageUrl=="string"?e.imageUrl:typeof e.dataUrl=="string"?e.dataUrl:null;if(t)return t;const n=e.source!=null&&typeof e.source=="object"?e.source:null,r=typeof e.data=="string"?e.data:typeof e.base64=="string"?e.base64:n!=null&&typeof n.data=="string"?n.data:null;return r?`data:${typeof e.mimeType=="string"?e.mimeType:typeof e.mime_type=="string"?e.mime_type:n!=null&&typeof n.media_type=="string"?n.media_type:n!=null&&typeof n.mimeType=="string"?n.mimeType:n!=null&&typeof n.mime_type=="string"?n.mime_type:"image/png"};base64,${r}`:null}function _0(e){if(e==null||typeof e!="object")return null;const t=e,n=typeof t.type=="string"?t.type.toLowerCase():"";if(n==="text"||n==="markdown"||n==="md"){const r=typeof t.text=="string"?t.text:typeof t.content=="string"?t.content:null;if(r==null)return null;const o=typeof t.format=="string"?t.format.toLowerCase():"markdown";return{type:"text",text:r,format:n==="text"&&(o==="text"||o==="plain")?"text":"markdown"}}if(n==="image"){const r=nwe(t);if(!r)return null;const o=typeof t.alt=="string"?t.alt:void 0,i=typeof t.title=="string"?t.title:void 0,a=typeof t.width=="number"?t.width:void 0,s=typeof t.height=="number"?t.height:void 0;return{type:"image",src:r,alt:o,title:i,width:a,height:s}}return null}function rwe(e){const t=ts(e),n=twe(t);if(Array.isArray(n)){const o=n.map(_0);return o.every(Boolean)?o:null}if(n!=null&&typeof n=="object"){const o=n,i=o.content??o.items??o.blocks;if(Array.isArray(i)){const a=i.map(_0);return a.every(Boolean)?a:null}}const r=_0(n);return r?[r]:null}function owe({blocks:e}){return b.jsx("div",{className:"tool-result-structured",children:e.map((t,n)=>t.type==="text"?b.jsx("div",{className:"tool-result-text",children:t.format==="markdown"?b.jsx(Xi,{content:t.text}):b.jsx("div",{className:"tool-result-text-content",children:t.text})},`text-${n}`):b.jsxs("div",{className:"tool-result-image-wrapper",children:[b.jsx("img",{className:"tool-result-image",src:t.src,alt:t.alt??"",width:t.width,height:t.height}),t.title!=null&&t.title.length>0&&b.jsx("div",{className:"tool-result-image-caption",children:t.title})]},`image-${n}`))})}function iwe({item:e,resultItem:t}){const{t:n}=Ot(),r=t!=null?rwe(t.content):null;return b.jsxs("div",{className:"tool-group",children:[b.jsx(wo,{header:b.jsxs("div",{className:"tool-header-content",children:[b.jsx("span",{className:"material-symbols-rounded tool-header-icon",children:"build"}),b.jsx("span",{className:"tool-header-title",children:e.name}),b.jsx("span",{className:"tool-header-hint",children:n("chat.tools.call")})]}),content:b.jsx("div",{className:"tool-content",children:b.jsx(Co,{code:ra(e.input!=null?e.input:{},2),lang:"json"})})}),t!=null&&b.jsx(wo,{type:"result",isError:t.is_error,header:b.jsxs("div",{className:"tool-header-content",children:[b.jsx("span",{className:"material-symbols-rounded tool-header-icon",children:t.is_error===!0?"error":"check_circle"}),b.jsx("span",{className:"tool-header-title",children:n("chat.result")})]}),content:b.jsx("div",{className:"tool-content",children:r!=null?b.jsx(owe,{blocks:r}):typeof t.content=="string"?t.content.startsWith("```")?b.jsx(Xi,{content:t.content}):b.jsx(Co,{code:t.content,lang:"text"}):b.jsx(Co,{code:ra(t.content,2),lang:"json"})})})]})}function U1(e,t){const n=t==null?void 0:t.namespace,r=Object.entries(e).flatMap(([o,i])=>{const a=[[o,i]];return n&&a.push([`${n}${o}`,i]),a});return Object.fromEntries(r)}const GF=({item:e,resultItem:t})=>{const{t:n}=Ot(),r=e.input!=null?e.input:{},o=r.command??"",i=r.description!=null&&r.description!==""?r.description:r.reason!=null&&r.reason!==""?r.reason:r.thought!=null&&r.thought!==""?r.thought:"",a=r.timeout,s=r.run_in_background,l=r.dangerouslyDisableSandbox,c=i.replaceAll(`
|
|
501
501
|
`," ").replace(/\s+/g," ").trim(),d=o.split(`
|
|
502
502
|
`)[0]??"",f=o.trim()!==d.trim(),m=f||d.length>80,[p,h]=u.useState(!1);return b.jsx("div",{className:"tool-group bash-tool",children:b.jsx(wo,{defaultExpanded:!0,type:t!=null?"result":"call",isError:(t==null?void 0:t.is_error)??!1,header:b.jsxs("div",{className:"bash-tool__header",children:[b.jsx("span",{className:"material-symbols-rounded bash-tool__icon",children:"terminal"}),b.jsxs("div",{className:"bash-tool__header-main",children:[b.jsx("div",{className:"bash-tool__reason-row",children:b.jsx("span",{className:"bash-tool__reason-text tool-header-hint",children:c!==""?c:d})}),c!==""&&b.jsx("div",{className:"bash-tool__command-row",children:b.jsxs("span",{className:`bash-tool__command-text tool-header-mono${m?" bash-tool__command-text--clickable":""}`,title:m?n("chat.tools.viewCommand"):void 0,onClick:y=>{m&&(y.stopPropagation(),h(x=>!x))},children:[d,f?" …":""]})})]}),b.jsxs("div",{className:"bash-tool__header-tags",children:[typeof a=="number"&&Number.isFinite(a)&&b.jsxs("span",{className:"tool-icon-tag",title:`${n("chat.tools.timeout")}: ${a}ms`,children:[b.jsx("span",{className:"material-symbols-rounded tool-icon-tag__icon",children:"timer"}),b.jsx("span",{className:"tool-icon-tag__text",children:a%1e3===0?`${a/1e3}s`:`${a}ms`})]}),s===!0&&b.jsx("span",{className:"tool-icon-tag",title:n("chat.tools.runInBackground"),children:b.jsx("span",{className:"material-symbols-rounded tool-icon-tag__icon",children:"schedule"})}),l===!0&&b.jsx("span",{className:"tool-icon-tag",title:n("chat.tools.dangerouslyDisableSandbox"),children:b.jsx("span",{className:"material-symbols-rounded tool-icon-tag__icon",children:"shield_lock"})})]})]}),content:b.jsxs("div",{className:"tool-content",children:[p&&b.jsx("div",{className:"bash-tool__command-detail",children:b.jsx("div",{className:"tool-code-wrapper",children:b.jsx(Co,{code:o,lang:"shell",hideHeader:!0})})}),b.jsx("div",{className:"tool-scroll",children:b.jsx("div",{className:"tool-code-wrapper",children:t?typeof t.content=="string"?b.jsx(Co,{code:t.content,lang:"text",hideHeader:!0}):b.jsx(Co,{code:ra(t.content,2),lang:"json",hideHeader:!0}):b.jsx("div",{className:"tool-placeholder",children:n("chat.result")})})})]})})})};function G1({content:e,removeRoot:t=!1,defaultCollapsed:n=!1}){const r=u.useMemo(()=>{let d=[];if(Array.isArray(e))d=e;else if(typeof e=="string")if(e.trim().startsWith("[")&&e.trim().endsWith("]"))try{const m=JSON.parse(e);Array.isArray(m)?d=m.map(String):d=e.split(`
|
|
503
503
|
`)}catch{d=e.split(`
|
|
@@ -514,7 +514,7 @@ ${e.frontmatter.testCommand}
|
|
|
514
514
|
`)){const Ge=localStorage.getItem("vf_chat_history"),ut=Ge!=null?JSON.parse(Ge):[],Ie=te===-1?null:ut[te];if(k.trim()===""||k===Ie){se.preventDefault(),pe("up");return}}}if(se.key==="ArrowDown"){const we=se.target,Oe=we.selectionEnd;if(!we.value.substring(Oe).includes(`
|
|
515
515
|
`)){const Ge=localStorage.getItem("vf_chat_history"),ut=Ge!=null?JSON.parse(Ge):[],Ie=te===-1?null:ut[te];if(te!==-1||k===Ie){se.preventDefault(),pe("down");return}}}if(se.key==="Escape"){k!==""&&(se.preventDefault(),me());return}if(se.key==="l"&&(se.metaKey||se.ctrlKey)){se.preventDefault(),E(""),ie(-1),i!=null?i():N.info("Clear screen is not supported in this context");return}se.key==="Enter"&&(se.metaKey||se.ctrlKey)&&(se.preventDefault(),de())},Se=se=>{const we=se.target.value;E(we);const Oe=se.target.selectionStart,Ae=we[Oe-1];if(["/","@","#"].includes(Ae)){L(Ae);let Ge=[];if((a==null?void 0:a.type)==="init"){const ut=a;Ae==="/"?Ge=(ut.slashCommands!=null?ut.slashCommands:[]).map(Ie=>({label:`/${Ie}`,value:Ie,icon:"terminal"})):Ae==="@"?Ge=(ut.agents!=null?ut.agents:[]).map(Ie=>({label:`@${Ie}`,value:Ie,icon:"smart_toy"})):Ae==="#"&&(Ge=(ut.tools!=null?ut.tools:[]).map(Ie=>({label:`#${Ie}`,value:Ie,icon:"check_box"})))}Ge.length>0?(P(Ge),T(0),O(!0)):O(!1)}else $&&(we.includes(M??"")||O(!1))};return b.jsxs("div",{className:"chat-input-wrapper",children:[J&&b.jsx(Pwe,{}),c!=null&&b.jsxs("div",{className:"interaction-panel",style:{display:"flex",flexDirection:"column",maxHeight:"200px",overflowY:"auto",marginBottom:"10px",gap:"8px",padding:"8px",border:"1px solid var(--border-color)",borderRadius:"8px",backgroundColor:"var(--bg-color)"},children:[b.jsx("div",{className:"interaction-question",style:{fontWeight:"bold"},children:c.payload.question}),(Me=c.payload.options)==null?void 0:Me.map(se=>b.jsxs(lt,{block:!0,style:{height:"auto",textAlign:"left",display:"block",padding:"8px 12px"},onClick:()=>d==null?void 0:d(c.id,se.label),children:[b.jsx("div",{style:{fontWeight:500},children:se.label}),se.description&&b.jsx("div",{style:{fontSize:"12px",color:"var(--sub-text-color)",marginTop:"4px"},children:se.description})]},se.label))]}),b.jsxs("div",{className:"chat-input-container",children:[s&&s.trim()!==""&&b.jsxs("div",{className:"connection-error-banner",children:[b.jsxs("div",{className:"connection-error-content",children:[b.jsx("span",{className:"material-symbols-rounded",children:"error"}),b.jsxs("div",{className:"connection-error-copy",children:[b.jsx("div",{className:"connection-error-title",children:w("chat.connectionErrorTitle")}),b.jsx("div",{className:"connection-error-message",children:s})]})]}),b.jsx(lt,{size:"small",onClick:l,children:w("chat.retryConnection")})]}),_&&b.jsx("div",{className:"model-unavailable",children:w("chat.modelConfigRequired")}),A.length>0&&b.jsx("div",{className:"pending-images",children:A.map(se=>b.jsxs("div",{className:"pending-image",children:[b.jsx("img",{src:se.url,alt:se.name??"image"}),b.jsx("div",{className:"pending-image-remove",onClick:()=>fe(se.id),children:b.jsx("span",{className:"material-symbols-rounded",children:"close"})})]},se.id))}),$&&b.jsx(Rwe,{items:R,selectedIndex:I,onSelect:Ee,onClose:()=>O(!1)}),b.jsx(Twe,{ref:j,className:"chat-input-textarea",placeholder:f??(c==null?void 0:c.payload.question)??w("chat.inputPlaceholder"),value:k,onChange:Se,onKeyDown:ve,onPaste:he,autoSize:{minRows:1,maxRows:10},variant:"borderless",disabled:_}),b.jsxs("div",{className:"chat-input-toolbar",children:[b.jsx("input",{ref:V,type:"file",accept:"image/*",multiple:!0,onChange:xe,className:"file-input-hidden"}),b.jsxs("div",{className:"toolbar-left",children:[b.jsx(ht,{title:"快捷指令",children:b.jsx("span",{children:b.jsx("div",{className:"toolbar-btn",onClick:()=>ue("/"),children:b.jsx("span",{className:"material-symbols-rounded",children:"terminal"})})})}),b.jsx(ht,{title:"提及代理",children:b.jsx("span",{children:b.jsx("div",{className:"toolbar-btn",onClick:()=>ue("@"),children:b.jsx("span",{className:"material-symbols-rounded",children:"smart_toy"})})})}),b.jsx(ht,{title:"注入上下文",children:b.jsx("span",{children:b.jsx("div",{className:"toolbar-btn",onClick:()=>ue("#"),children:b.jsx("span",{className:"material-symbols-rounded",children:"description"})})})}),b.jsx(ht,{title:"上传图片",children:b.jsx("span",{children:b.jsx("div",{className:"toolbar-btn",onClick:ge,children:b.jsx("span",{className:"material-symbols-rounded",children:"image"})})})}),a!=null&&a.type==="init"&&b.jsx("div",{className:"session-info-toolbar",children:b.jsx(Cu,{open:D,options:oe,expandTrigger:"hover",placement:"topLeft",allowClear:!1,popupClassName:"sender-tools-cascader-popup",onOpenChange:z,onChange:()=>z(!1),children:b.jsxs("div",{className:`info-item ${D?"active":""}`,children:[b.jsx("span",{className:"info-item-leading",children:b.jsx("span",{className:"material-symbols-rounded",children:"build"})}),b.jsx("span",{className:"info-text",children:w("chat.toolsCount",{count:a.tools.length})}),b.jsx("span",{className:"material-symbols-rounded arrow-icon",children:"keyboard_arrow_up"})]})})})]}),b.jsxs("div",{className:"toolbar-right",children:[S&&S.length>1&&b.jsx(er,{className:"adapter-select",classNames:{popup:{root:"adapter-select-popup"}},value:v,options:S,showSearch:!1,allowClear:!1,disabled:n||_||J,onChange:se=>C==null?void 0:C(se),placeholder:w("chat.adapterSelectPlaceholder",{defaultValue:"Adapter"}),optionLabelProp:"label",popupMatchSelectWidth:!1}),b.jsx(er,{className:"model-select",classNames:{popup:{root:"model-select-popup"}},value:p,options:m??[],showSearch:!0,allowClear:!1,disabled:_||J,onChange:se=>h==null?void 0:h(se),placeholder:w(_?"chat.modelUnavailable":"chat.modelSelectPlaceholder"),optionLabelProp:"displayLabel",filterOption:(se,we)=>String((we==null?void 0:we.searchText)??"").toLowerCase().includes(se.toLowerCase()),popupMatchSelectWidth:!1}),b.jsx(er,{className:"permission-mode-select",classNames:{popup:{root:"permission-mode-select-popup"}},value:y,options:x,showSearch:!1,allowClear:!1,disabled:_||J,onChange:se=>g(se),placeholder:"权限模式",optionLabelProp:"label",popupMatchSelectWidth:!1}),b.jsx("div",{className:`chat-send-btn ${k.trim()!==""&&!_?"active":""} ${J?"thinking":""} ${_?"disabled":""}`,onClick:_?void 0:J?o:de,children:b.jsx("span",{className:"material-symbols-rounded",children:J?"stop_circle":"send"})})]})]})]}),b.jsx("div",{className:"chat-input-hint",children:w("chat.hint")})]})}function Lwe({items:e,footer:t}){const{t:n}=Ot(),[r,o]=u.useState(!1);if(e.length===0)return null;if(e.length===1)return b.jsxs("div",{className:"tool-group-container",children:[b.jsx("div",{className:"tool-group-wrapper single-item",children:b.jsx(Pc,{item:e[0].item,resultItem:e[0].resultItem})}),t&&b.jsx("div",{className:"tool-group-footer-wrapper",children:b.jsx(TC,{msg:t.originalMessage,isUser:!1})})]});const i=e[e.length-1],a=e.slice(0,-1);return b.jsxs("div",{className:"tool-group-container",children:[b.jsxs("div",{className:"tool-group-wrapper card-style",children:[b.jsxs("div",{className:"tool-group-header",onClick:()=>o(!r),children:[b.jsxs("div",{className:"header-left",children:[b.jsx("span",{className:"material-symbols-rounded",children:"dataset"}),b.jsx("span",{children:n("chat.usedTools",{count:e.length})})]}),b.jsx("span",{className:"material-symbols-rounded expand-icon",children:r?"expand_less":"expand_more"})]}),r&&b.jsx("div",{className:"tool-group-list",children:a.map((s,l)=>b.jsx(Pc,{item:s.item,resultItem:s.resultItem},s.item.id||l))}),b.jsx("div",{className:"tool-group-last-item",children:b.jsx(Pc,{item:i.item,resultItem:i.resultItem})})]}),t&&b.jsx("div",{className:"tool-group-footer-wrapper",children:b.jsx(TC,{msg:t.originalMessage,isUser:!1})})]})}const Dwe=(e,t)=>{if(e.items.length!==t.items.length)return!1;for(let n=0;n<e.items.length;n++)if(e.items[n].item!==t.items[n].item||e.items[n].resultItem!==t.items[n].resultItem)return!1;return e.footer==null&&t.footer==null?!0:e.footer==null||t.footer==null?!1:e.footer.originalMessage===t.footer.originalMessage&&e.footer.createdAt===t.footer.createdAt&&e.footer.model===t.footer.model&&e.footer.usage===t.footer.usage},zwe=ee.memo(Lwe,Dwe);function Bwe({isReady:e,messages:t,session:n,sessionInfo:r,connectionError:o,onRetryConnection:i,interactionRequest:a,onInteractionResponse:s,setMessages:l,onClearMessages:c,placeholder:d,modelOptions:f,selectedModel:m,modelForQuery:p,onModelChange:h,permissionMode:y,permissionModeOptions:x,onPermissionModeChange:g,selectedAdapter:v,adapterOptions:S,onAdapterChange:C,modelUnavailable:_,hasAvailableModels:w}){const{t:N}=Ot(),{messagesEndRef:k,messagesContainerRef:E,messagesContentRef:$,showScrollBottom:O,scrollToBottom:R}=QCe({messagesLength:t.length}),{isCreating:P,send:I,sendContent:T,interrupt:M,clearMessages:L}=JCe({session:n,modelForQuery:p,hasAvailableModels:w,permissionMode:y,adapter:v,onClearMessages:c}),D=u.useRef(!1),z=A=>{var H;return{id:(H=globalThis.crypto)!=null&&H.randomUUID?globalThis.crypto.randomUUID():`local-${Date.now()}-${Math.random().toString(16).slice(2)}`,role:"user",content:A,createdAt:Date.now()}},j=async A=>{if(!(n!=null&&n.id)){const H=z(A);l(U=>[...U,H]),await I(A)||l(U=>U.filter(G=>G.id!==H.id));return}await I(A)&&l(H=>[...H,z(A)])},V=async A=>{if(!(n!=null&&n.id)){const H=z(A);l(U=>[...U,H]),await T(A)||l(U=>U.filter(G=>G.id!==H.id));return}await T(A)&&l(H=>[...H,z(A)])};u.useEffect(()=>{D.current=!1},[n==null?void 0:n.id]),u.useEffect(()=>{!D.current&&e&&(R("auto"),D.current=!0)},[e,t.length,R]),u.useEffect(()=>{O||R("auto")},[t.length,R,O]);const B=u.useMemo(()=>Owe(t),[t]);return b.jsxs(b.Fragment,{children:[b.jsxs("div",{className:`chat-messages ${e?"ready":""}`,ref:E,children:[b.jsxs("div",{className:"chat-messages-content",ref:$,children:[!(n!=null&&n.id)&&P&&b.jsxs("div",{className:"chat-pending-session-banner",children:[b.jsx("span",{className:"material-symbols-rounded",children:"hourglass_top"}),b.jsx("span",{children:N("common.creatingChat")})]}),B.map((A,F)=>A.type==="message"?b.jsx(Nwe,{msg:A.message,isFirstInGroup:A.isFirstInGroup},A.message.id||F):A.type==="tool-group"?b.jsx(zwe,{items:A.items,footer:A.footer},A.id||`group-${F}`):null),b.jsx("div",{ref:k})]}),O&&b.jsx("div",{className:"scroll-bottom-btn",onClick:()=>R(),children:b.jsx("span",{className:"material-symbols-rounded",children:"arrow_downward"})})]}),!(n!=null&&n.id)&&t.length===0&&b.jsx("div",{className:"new-session-guide-wrapper",children:b.jsx(Iwe,{})}),b.jsx(ewe,{messages:t}),b.jsx("div",{className:"sender-container",children:b.jsx(Awe,{onSend:j,onSendContent:V,adapterLocked:(n==null?void 0:n.id)!=null,sessionStatus:P?"running":n==null?void 0:n.status,onInterrupt:M,onClear:L,sessionInfo:r,connectionError:o,onRetryConnection:i,interactionRequest:a,onInteractionResponse:s,placeholder:d,modelOptions:f,selectedModel:m,onModelChange:h,permissionMode:y,permissionModeOptions:x,onPermissionModeChange:g,selectedAdapter:v,adapterOptions:S,onAdapterChange:C,modelUnavailable:_})})]})}function Fwe({session:e,onClose:t}){return b.jsx("div",{className:"chat-settings-panel",children:b.jsx(XCe,{sessionId:e.id,initialTitle:e.title,initialTags:e.tags,onClose:t})})}function Hwe(e){return e.replace(/\W/g,"_")}function Zo(e){const[t,n,r]=e.split(":").map(Number);return(t||0)*3600+(n||0)*60+(r||0)}function hc(e){const[t,n,r]=e.split(":"),o=i=>{const a=Number.parseInt(i??"0",10);return Number.isFinite(a)?`${a}`.padStart(2,"0"):"00"};return`${o(t)}:${o(n)}:${o(r)}`}function sP(){let e=0;return t=>`${t}_${e++}`}function Vwe(e,t){const n=sP(),r=sP(),o=[],i=[],a="";let s=0;const l=()=>(s+=1,a.repeat(s)),c=h=>{o.push(h)},d=h=>{const y=[{start:h.startTime,end:h.endTime}],x=h.events??[],g=x.findIndex(_=>_.type==="tool__AskUserQuestion");if(g<0)return y;const v=x[g],S=Zo(v.startTime)<=Zo(v.endTime)?v.startTime:v.endTime,C=Zo(v.startTime)<=Zo(v.endTime)?v.endTime:v.startTime;return Zo(C)<=Zo(S)||(y[y.length-1]={start:y[y.length-1].start,end:S},y.push({start:C,end:h.endTime})),y},f=h=>{for(let y=0;y<h.length;y+=1){const x=h[y],{type:g,startTime:v,endTime:S}=x;switch(g){case"tool__StartTasks":{const{tasks:C={}}=x,_=r("section"),w=l();for(const[N,k]of Object.entries(C)){const E=d(k);E.forEach((O,R)=>{const P=n("task"),I=E.length>1?`${N} - ${R}`:N,T={id:P,label:N,payload:{kind:"task",name:N,task:k}};i.push({id:P,label:I,start:hc(O.start),end:hc(O.end),sectionId:_,sectionLabel:w,type:"task",interaction:T}),c(T)});const{events:$=[]}=k;$.length>0&&f($)}break}}}},m=n("main"),p=r("section");return i.push({id:m,label:t.ganttMainSection,start:hc(e.startTime),end:hc(e.endTime),sectionId:p,sectionLabel:t.ganttMainSection,type:"task"}),f(e.events??[]),{items:i,interactions:o}}function Wwe(e){var r;const t=["gantt","dateFormat HH:mm:ss","axisFormat %H:%M:%S"],n=new Map;for(const o of e)n.has(o.sectionId)||n.set(o.sectionId,{label:o.sectionLabel,items:[]}),(r=n.get(o.sectionId))==null||r.items.push(o);for(const o of n.values()){t.push(o.label?`section ${o.label}`:"section");for(const i of o.items)i.end&&t.push(`${i.label} :${i.id}, ${i.start}, ${i.end}`)}return t.join(`
|
|
516
516
|
`)}function Kwe(e,t){const{items:n,interactions:r}=Vwe(e,t);return{code:Wwe(n),interactions:r}}function Uwe(e){if(e)return e.replace(/"/g,"'")}function Gwe(e){return{normalizeCommitId:r=>r.replace(/\s+/g,"_"),allocateCommitId:r=>{let o=r,i=1;for(;e.has(o);)o=`${r}_${i}`,i+=1;return e.add(o),o}}}function up(e,t){switch(t){case"tool__StartTasks":return e.startTasks;case"tool__AskUserQuestion":return e.askUserQuestion;case"tool__Edit":return e.edit;case"tool__ResumeTask":return e.resumeTask;case"user__Prompt":return e.userPrompt;default:return t}}function lP(e){switch(e.kind){case"merge":return e.target;case"branch":return e.name;default:return e.branch}}function qwe(e){return[...e].sort((t,n)=>{const r=Zo(t.time)-Zo(n.time);if(r!==0)return r;if(t.priority!==n.priority)return t.priority-n.priority;const o=lP(t),i=lP(n);return o!==i?o.localeCompare(i):t.seq-n.seq})}function Xwe(e){const t=["gitGraph TB:"],n=new Set,r=new Set,{normalizeCommitId:o,allocateCommitId:i}=Gwe(r),a=new Map,s=new Map,l=new Map,c=new Map;let d,f,m=0;const p=[],h=[],y=(O,R)=>{const P=Uwe(R);return P?t.push(`commit id:"${O}" tag:"${P}"`):t.push(`commit id:"${O}"`),O},x=(O,R,P,I)=>{if(!d){d={id:O,branch:R,time:P,seq:I};return}const T=Zo(P)-Zo(d.time);(T>0||T===0&&I>d.seq)&&(d={id:O,branch:R,time:P,seq:I})},g=O=>{let R=O;for(;R;){const P=s.get(R);if(P)return{id:P,branch:l.get(P)??R};const I=c.get(R);if(!I||I===R)break;R=I}},v=O=>{if(O)return g(O);if(d)return{id:d.id,branch:d.branch}},S=(O,R,P,I)=>{const T=o(O),M=i(T);return P!=null&&P.branchName&&typeof P.priority=="number"?(p.push({kind:"commit",time:O,branch:P.branchName,commitId:M,action:R,priority:P.priority,seq:m++}),s.set(P.branchName,M),l.set(M,P.branchName),x(M,P.branchName,O,m-1),I&&h.push({id:M,label:R??M,payload:I}),M):(I&&h.push({id:M,label:R??M,payload:I}),y(M,R))},C=O=>{n.has(O)||(n.add(O),f=O,t.push(`branch ${O}`))},_=O=>{f=O,t.push(`checkout ${O}`)},w=(O,R,P,I)=>{const T=[];R&&T.push(`id:"${R}"`),P&&T.push(`tag:"${P}"`),t.push(`merge ${O} ${T.join(" ")}`),R&&(I!=null&&I.branchName)&&I.time&&typeof I.seq=="number"&&(s.set(I.branchName,R),l.set(R,I.branchName),x(R,I.branchName,I.time,I.seq))},N=(O,R,P,I)=>{p.push({kind:"branch",time:O,baseBranch:R,name:P,priority:I,seq:m++})},k=(O,R,P,I,T,M)=>{const L=o(O),D=i(L);return p.push({kind:"merge",time:O,target:R,source:P,action:I,mergeId:D,priority:T,seq:m++}),M&&h.push({id:D,label:I,payload:M}),D},E="main";return{get curBranch(){return f},labels:e,lines:t,ops:p,interactions:h,commit:y,branch:C,checkout:_,merge:w,addCommit:S,addBranch:N,addMerge:k,ensureBranch:O=>{O!==E&&C(O)},normalizeCommitId:o,allocateCommitId:i,findLatestCommitId:v,resumeCommitIds:a,parentByBranch:c}}function QF(e,t,n,r){const{labels:o,addCommit:i,addBranch:a,addMerge:s,parentByBranch:l,resumeCommitIds:c}=r;for(const d of e){const{type:f,startTime:m,endTime:p}=d;switch(f){case"tool__StartTasks":{i(m,o.taskStart,{branchName:t,priority:10},{kind:"event",event:d});const{tasks:h={}}=d;for(const[y,x]of Object.entries(h)){const g=Hwe(y);l.set(g,t),a(m,t,g,15),i(x.startTime,o.taskStart,{branchName:g,priority:16},{kind:"task",name:y,task:x});const{events:v=[]}=x;v.length>0&&QF(v,g,t,r),i(x.endTime,o.taskEnd,{branchName:g,priority:60})}i(p,o.allTasksDone,{branchName:t,priority:70});break}case"tool__AskUserQuestion":i(m,o.askUserQuestion,{branchName:t,priority:20},{kind:"event",event:d}),s(p,n,t,o.userAnswer,80,{kind:"event",event:d});break;case"tool__Edit":i(m,up(o,f),{branchName:t,priority:30},{kind:"event",event:d});break;case"tool__ResumeTask":{const h=i(m,up(o,f),{branchName:t,priority:40},{kind:"event",event:d});c.set(t,h);break}case"user__Prompt":s(m,t,"<prev_branch>",up(o,f),50,{kind:"event",event:d});break;default:i(p,up(o,f),{branchName:t,priority:55},{kind:"event",event:d});break}}}function Ywe(e){const t=qwe(e.ops);for(const n of t)switch(n.kind){case"commit":e.ensureBranch(n.branch),e.checkout(n.branch),e.commit(n.commitId,n.action);break;case"branch":e.checkout(n.baseBranch),e.ensureBranch(n.name);break;case"merge":{n.source==="<prev_branch>"&&(n.source=e.curBranch),e.ensureBranch(n.target),e.ensureBranch(n.source),e.checkout(n.target),e.merge(n.source,n.mergeId,n.action,{branchName:n.target,time:n.time,seq:n.seq});break}}}function Qwe(e,t){const n=Xwe(t),r="main";return n.checkout(r),n.addCommit(e.startTime,t.mainStart),QF(e.events??[],r,r,n),Ywe(n),n.checkout(r),n.addCommit(e.endTime,t.mainEnd),{code:n.lines.join(`
|
|
517
|
-
`),interactions:n.interactions}}function cP(e){const{task:t,viewMode:n,className:r,style:o}=e,i=ee.useRef(null),{t:a}=Ot(),s=ee.useMemo(()=>({mainStart:a("chat.timeline.mainStart"),mainEnd:a("chat.timeline.mainEnd"),startTasks:a("chat.timeline.startTasks"),allTasksDone:a("chat.timeline.allTasksDone"),askUserQuestion:a("chat.timeline.askUserQuestion"),edit:a("chat.timeline.edit"),resumeTask:a("chat.timeline.resumeTask"),userPrompt:a("chat.timeline.userPrompt"),userAnswer:a("chat.timeline.userAnswer"),receiveReply:a("chat.timeline.receiveReply"),taskStart:a("chat.timeline.taskStart"),taskEnd:a("chat.timeline.taskEnd"),ganttTitle:a("chat.timeline.ganttTitle"),ganttMainSection:a("chat.timeline.ganttMainSection"),ganttTasksSection:a("chat.timeline.ganttTasksSection")}),[a]),l=ee.useMemo(()=>n==="gantt"?Kwe(t,s):Qwe(t,s),[s,t,n]),c=ee.useId(),d=ee.useMemo(()=>c.replace(/\W/g,"_"),[c]),f=ee.useRef(new Map),m=ee.useMemo(()=>l.code,[l.code]);return ee.useEffect(()=>{let p=!1;return(async()=>{const x=(await re(()=>import("./mermaid.core-
|
|
517
|
+
`),interactions:n.interactions}}function cP(e){const{task:t,viewMode:n,className:r,style:o}=e,i=ee.useRef(null),{t:a}=Ot(),s=ee.useMemo(()=>({mainStart:a("chat.timeline.mainStart"),mainEnd:a("chat.timeline.mainEnd"),startTasks:a("chat.timeline.startTasks"),allTasksDone:a("chat.timeline.allTasksDone"),askUserQuestion:a("chat.timeline.askUserQuestion"),edit:a("chat.timeline.edit"),resumeTask:a("chat.timeline.resumeTask"),userPrompt:a("chat.timeline.userPrompt"),userAnswer:a("chat.timeline.userAnswer"),receiveReply:a("chat.timeline.receiveReply"),taskStart:a("chat.timeline.taskStart"),taskEnd:a("chat.timeline.taskEnd"),ganttTitle:a("chat.timeline.ganttTitle"),ganttMainSection:a("chat.timeline.ganttMainSection"),ganttTasksSection:a("chat.timeline.ganttTasksSection")}),[a]),l=ee.useMemo(()=>n==="gantt"?Kwe(t,s):Qwe(t,s),[s,t,n]),c=ee.useId(),d=ee.useMemo(()=>c.replace(/\W/g,"_"),[c]),f=ee.useRef(new Map),m=ee.useMemo(()=>l.code,[l.code]);return ee.useEffect(()=>{let p=!1;return(async()=>{const x=(await re(()=>import("./mermaid.core-CZnO8AvM.js").then(w=>w.b5),[])).default,g=getComputedStyle(document.body).fontFamily;if(x.initialize({startOnLoad:!1,securityLevel:"loose",themeVariables:{fontFamily:g},gitGraph:{},gantt:{topAxis:!0,displayMode:"compact",gridLineStartPadding:0,leftPadding:16,rightPadding:16}}),p)return;const v=i.current;if(!v)return;const{svg:S,bindFunctions:C}=await x.render(d,m);if(p)return;v.innerHTML=S;const _=v.querySelector("svg");if(_){_.classList.add("session-timeline-mermaid__svg");for(const w of l.interactions){const N=_.querySelector(`#${CSS.escape(w.id)}`);N&&(N.classList.add("session-timeline-mermaid__interactive"),N.addEventListener("click",()=>{const k=f.current.get(w.id);k&&console.warn(k.payload)}))}}typeof C=="function"&&C(v)})(),()=>{p=!0}},[l.interactions,m,d]),ee.useEffect(()=>{f.current=new Map(l.interactions.map(p=>[p.id,{label:p.label,payload:p.payload}]))},[l.interactions]),b.jsx("div",{ref:i,className:`session-timeline-panel session-timeline-panel--${n}${r?` ${r}`:""}`,style:o})}const Zwe=(e,t)=>{const n=[];let r=0;const o=(a,s,l,c,d)=>{n.push({id:`${a}-${s}-${l}-${r}`,label:a,startTime:s,endTime:l,depth:c,payload:d}),r+=1},i=(a,s)=>{for(const l of a)l.type==="tool__StartTasks"?o(t.startTasks,l.startTime,l.endTime,s,l):l.type==="tool__AskUserQuestion"?o(t.askUserQuestion,l.startTime,l.endTime,s,l):l.type==="tool__Edit"?o(t.edit,l.startTime,l.endTime,s,l):l.type==="tool__ResumeTask"?o(t.resumeTask,l.startTime,l.endTime,s,l):l.type==="user__Prompt"&&o(t.userPrompt,l.startTime,l.endTime,s,l)};return o(t.mainStart,e.startTime,e.startTime,0),i(e.events??[],0),o(t.mainEnd,e.endTime,e.endTime,0),n.map((a,s)=>({...a,index:s})).sort((a,s)=>{const l=Zo(a.startTime)-Zo(s.startTime);return l!==0?l:a.index-s.index}).map(({index:a,...s})=>s)};function Jwe({task:e}){const{t}=Ot(),[n,r]=ee.useState(""),o=ee.useRef(null),[i,a]=ee.useState(240),s=ee.useMemo(()=>({mainStart:t("chat.timeline.mainStart"),mainEnd:t("chat.timeline.mainEnd"),startTasks:t("chat.timeline.startTasks"),askUserQuestion:t("chat.timeline.askUserQuestion"),edit:t("chat.timeline.edit"),resumeTask:t("chat.timeline.resumeTask"),userPrompt:t("chat.timeline.userPrompt")}),[t]),l=ee.useMemo(()=>Zwe(e,s),[s,e]),c=ee.useMemo(()=>{const m=n.trim().toLowerCase();return m?l.filter(p=>`${p.label} ${p.startTime} ${p.endTime}`.toLowerCase().includes(m)):l},[l,n]),d=t("chat.timelineEmptyValue"),f=ee.useMemo(()=>[{title:t("chat.timelineEventName"),key:"label",width:180,render:(m,p)=>b.jsx("span",{className:"session-timeline-event-table__label",style:{paddingLeft:`${p.depth*16}px`},children:p.label})},{title:t("chat.timelineInput"),key:"input",width:180,render:(m,p)=>b.jsx("span",{className:"session-timeline-event-table__value",children:p.input??d})},{title:t("chat.timelineOutput"),key:"output",width:180,render:(m,p)=>b.jsx("span",{className:"session-timeline-event-table__value",children:p.output??d})},{title:t("chat.timelineTiming"),key:"time",width:160,render:(m,p)=>{const h=hc(p.startTime),y=hc(p.endTime);return b.jsx("span",{className:"session-timeline-event-table__time",children:h===y?h:`${h} → ${y}`})}}],[d,t]);return ee.useEffect(()=>{const m=o.current;if(!m)return;const p=()=>{const y=m.querySelector(".session-timeline-event-table__header"),x=m.querySelector(".ant-table-pagination"),g=(y==null?void 0:y.offsetHeight)??0,v=(x==null?void 0:x.offsetHeight)??0,S=Math.max(160,m.clientHeight-g-v-16);a(C=>C===S?C:S)};p();const h=new ResizeObserver(p);return h.observe(m),()=>{h.disconnect()}},[]),b.jsxs("div",{ref:o,className:"session-timeline-event-table",children:[b.jsxs("div",{className:"session-timeline-event-table__header",children:[b.jsx("span",{className:"session-timeline-event-table__title",children:t("chat.timeline.eventListTitle")}),b.jsx(Ft,{className:"session-timeline-event-table__search",allowClear:!0,value:n,onChange:m=>r(m.target.value),placeholder:t("chat.timeline.eventListSearch")})]}),b.jsx(la,{className:"session-timeline-event-table__table",size:"small",columns:f,dataSource:c,rowKey:"id",onRow:m=>({onClick:()=>{m.payload&&console.warn(m.payload)}}),pagination:{pageSize:20,showSizeChanger:!0,pageSizeOptions:["10","20","50"]},scroll:{y:i},locale:{emptyText:t("chat.timelineEmpty")}})]})}const E0={startTime:"09:40:00",endTime:"11:30:48",events:[{type:"tool__StartTasks",startTime:"09:41:02",endTime:"10:10:25",tasks:{taskA:{startTime:"09:41:10",endTime:"09:55:02",description:"Task A"},taskB:{startTime:"09:41:10",endTime:"09:50:40",description:"Task B"},taskC:{startTime:"09:41:10",endTime:"10:10:20",description:"Task C",events:[{type:"tool__StartTasks",startTime:"09:48:00",endTime:"10:05:30",tasks:{taskC0:{startTime:"09:49:10",endTime:"10:05:25",events:[{type:"tool__AskUserQuestion",startTime:"09:57:00",endTime:"09:59:23"},{type:"user__Prompt",startTime:"09:58:10",endTime:"09:58:20"}]}}},{type:"tool__Edit",startTime:"09:57:10",endTime:"09:59:20"},{type:"tool__ResumeTask",startTime:"09:59:22",endTime:"10:05:30"}]}}},{type:"tool__StartTasks",startTime:"10:41:02",endTime:"11:10:25",tasks:{taskA1:{startTime:"10:41:10",endTime:"10:55:02",description:"Task A1"},taskB1:{startTime:"10:41:10",endTime:"10:50:40",description:"Task B1"},taskC1:{startTime:"10:41:10",endTime:"11:10:20",description:"Task C1",events:[{type:"tool__StartTasks",startTime:"10:48:00",endTime:"11:05:30",tasks:{taskC10:{startTime:"10:49:10",endTime:"11:05:25",events:[{type:"tool__AskUserQuestion",startTime:"10:57:00",endTime:"10:59:23"},{type:"user__Prompt",startTime:"10:58:10",endTime:"10:58:20"}]}}},{type:"tool__Edit",startTime:"10:57:10",endTime:"10:59:20"},{type:"tool__ResumeTask",startTime:"10:59:22",endTime:"11:05:30"}]}}}]};function e_e({messages:e}){return b.jsxs("div",{className:"chat-timeline-view",children:[b.jsx("section",{className:"session-timeline-section session-timeline-section--fixed",children:b.jsx(cP,{task:E0,viewMode:"gantt"})}),b.jsxs("section",{className:"session-timeline-section session-timeline-section--flex session-timeline-section--row",children:[b.jsx("div",{className:"session-timeline-column session-timeline-column--graph",children:b.jsx(cP,{task:E0,viewMode:"git"})}),b.jsx("div",{className:"session-timeline-column session-timeline-column--events",children:b.jsx(Jwe,{task:E0})})]})]})}const t_e=`
|
|
518
518
|
<svg width="64" height="64" viewBox="0 0 64 64" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
519
519
|
<g fill="#D97957">
|
|
520
520
|
<rect x="29" y="2" width="6" height="20" rx="3"/>
|