@markus-global/cli 0.11.2-rc.0 → 0.11.2
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/markus.mjs +6 -4
- package/dist/web-ui/assets/{CommentInput-Cqi5Hldw.js → CommentInput-Cgu8208h.js} +1 -1
- package/dist/web-ui/assets/{ContentRenderer-BAB3il9e.js → ContentRenderer-rzRUDj8T.js} +2 -2
- package/dist/web-ui/assets/{DeliverableShareModal-DJXkM66x.js → DeliverableShareModal-BvfmqTNG.js} +1 -1
- package/dist/web-ui/assets/{Deliverables-zKPxgZAN.js → Deliverables-DKTLnaF8.js} +1 -1
- package/dist/web-ui/assets/{Notifications-HAycgg2x.js → Notifications-CWaO9onn.js} +1 -1
- package/dist/web-ui/assets/{Search-SZuDcxy0.js → Search-D_C5Eyed.js} +1 -1
- package/dist/web-ui/assets/{Settings-CZgNsYSC.js → Settings-B5Ib6SFf.js} +1 -1
- package/dist/web-ui/assets/{Store-BS7VNrsr.js → Store-D__pfqoc.js} +1 -1
- package/dist/web-ui/assets/{Team-B6vw2Oj5.js → Team-FFbGLcXj.js} +36 -36
- package/dist/web-ui/assets/{Work-BN-LsW3k.js → Work-BJ7kXixx.js} +1 -1
- package/dist/web-ui/assets/{arc-CsnWE2QW.js → arc-BN0GMYN6.js} +1 -1
- package/dist/web-ui/assets/{architectureDiagram-3BPJPVTR-CLek8I2z.js → architectureDiagram-3BPJPVTR-BP5Nnl2Y.js} +1 -1
- package/dist/web-ui/assets/{blockDiagram-GPEHLZMM-jSgWEHN7.js → blockDiagram-GPEHLZMM-nKHUCU_z.js} +1 -1
- package/dist/web-ui/assets/{c4Diagram-AAUBKEIU-BaC188UT.js → c4Diagram-AAUBKEIU-DoS0wcHh.js} +1 -1
- package/dist/web-ui/assets/channel-C_kHFvaW.js +1 -0
- package/dist/web-ui/assets/{chunk-2J33WTMH-CdtP4-T4.js → chunk-2J33WTMH-CP54_XNl.js} +1 -1
- package/dist/web-ui/assets/{chunk-4BX2VUAB-BSgBKyC9.js → chunk-4BX2VUAB-DMvJaJb7.js} +1 -1
- package/dist/web-ui/assets/{chunk-55IACEB6-XB_ZMqfw.js → chunk-55IACEB6-DQnZgoOO.js} +1 -1
- package/dist/web-ui/assets/{chunk-727SXJPM-YFPBFW4M.js → chunk-727SXJPM-B5_3LI53.js} +1 -1
- package/dist/web-ui/assets/{chunk-AQP2D5EJ-CDbFN1Un.js → chunk-AQP2D5EJ-B5Mh5bI_.js} +1 -1
- package/dist/web-ui/assets/{chunk-FMBD7UC4-BGKt8xP8.js → chunk-FMBD7UC4-mjYTpuBm.js} +1 -1
- package/dist/web-ui/assets/{chunk-ND2GUHAM-DKicpX2b.js → chunk-ND2GUHAM-BxTrseJg.js} +1 -1
- package/dist/web-ui/assets/{chunk-QZHKN3VN-BD4tv8RZ.js → chunk-QZHKN3VN-C1do5brE.js} +1 -1
- package/dist/web-ui/assets/classDiagram-4FO5ZUOK-UF2PuXCi.js +1 -0
- package/dist/web-ui/assets/classDiagram-v2-Q7XG4LA2-UF2PuXCi.js +1 -0
- package/dist/web-ui/assets/{cose-bilkent-S5V4N54A-BjOoIarG.js → cose-bilkent-S5V4N54A-DMn7aSDK.js} +1 -1
- package/dist/web-ui/assets/{dagre-BM42HDAG-BWal5GOH.js → dagre-BM42HDAG-CE-tTagY.js} +1 -1
- package/dist/web-ui/assets/{diagram-2AECGRRQ-CJj-CzRg.js → diagram-2AECGRRQ-BwyvxbJa.js} +1 -1
- package/dist/web-ui/assets/{diagram-5GNKFQAL-4IMjuEPm.js → diagram-5GNKFQAL-Nopndxl0.js} +1 -1
- package/dist/web-ui/assets/{diagram-KO2AKTUF-DQiRAfss.js → diagram-KO2AKTUF-CGTjHHnD.js} +1 -1
- package/dist/web-ui/assets/{diagram-LMA3HP47-BMPvbEbY.js → diagram-LMA3HP47-DhC3AqLA.js} +1 -1
- package/dist/web-ui/assets/{diagram-OG6HWLK6-D5_vmdXl.js → diagram-OG6HWLK6-BIuzyWJO.js} +1 -1
- package/dist/web-ui/assets/{docx-preview-Cdouj_6e.js → docx-preview-ClO_djcO.js} +1 -1
- package/dist/web-ui/assets/{erDiagram-TEJ5UH35-DOnDuvXd.js → erDiagram-TEJ5UH35-Nmfi9Wv0.js} +1 -1
- package/dist/web-ui/assets/{flowDiagram-I6XJVG4X-DL6G76eC.js → flowDiagram-I6XJVG4X-BVAM5QzO.js} +1 -1
- package/dist/web-ui/assets/{ganttDiagram-6RSMTGT7-CwHnuRR8.js → ganttDiagram-6RSMTGT7-BGdTbY0A.js} +1 -1
- package/dist/web-ui/assets/{gitGraphDiagram-PVQCEYII-BFUnsmW_.js → gitGraphDiagram-PVQCEYII-BMfug5mp.js} +1 -1
- package/dist/web-ui/assets/{index-BSktaJwx.js → index-1X1Ykov8.js} +36 -36
- package/dist/web-ui/assets/{infoDiagram-5YYISTIA-DhU1bQNw.js → infoDiagram-5YYISTIA-DAqSLNMU.js} +1 -1
- package/dist/web-ui/assets/{ishikawaDiagram-YF4QCWOH-o6ujfUJF.js → ishikawaDiagram-YF4QCWOH-Bro4RrlG.js} +1 -1
- package/dist/web-ui/assets/{journeyDiagram-JHISSGLW-Dx_SZ8zv.js → journeyDiagram-JHISSGLW-CdRHOaID.js} +1 -1
- package/dist/web-ui/assets/{kanban-definition-UN3LZRKU-D4BWXcIn.js → kanban-definition-UN3LZRKU-9iLNl-rB.js} +1 -1
- package/dist/web-ui/assets/{mermaid.core-BHDulYyB.js → mermaid.core-BRHCbDDt.js} +5 -5
- package/dist/web-ui/assets/{mindmap-definition-RKZ34NQL-BVy6py_h.js → mindmap-definition-RKZ34NQL-BLm-XQ6W.js} +1 -1
- package/dist/web-ui/assets/{pieDiagram-4H26LBE5-CUr5__J1.js → pieDiagram-4H26LBE5-ith90T5A.js} +1 -1
- package/dist/web-ui/assets/{quadrantDiagram-W4KKPZXB-C5Owt_r4.js → quadrantDiagram-W4KKPZXB-Cb08oHG7.js} +1 -1
- package/dist/web-ui/assets/{requirementDiagram-4Y6WPE33-Bb933lBb.js → requirementDiagram-4Y6WPE33-DzMKi4w8.js} +1 -1
- package/dist/web-ui/assets/{sankeyDiagram-5OEKKPKP-CJq-boMJ.js → sankeyDiagram-5OEKKPKP-C0Wv4A7m.js} +1 -1
- package/dist/web-ui/assets/{sequenceDiagram-3UESZ5HK-BP8L47v3.js → sequenceDiagram-3UESZ5HK-C_HL9WB0.js} +1 -1
- package/dist/web-ui/assets/{stateDiagram-AJRCARHV-Byk9-Yrm.js → stateDiagram-AJRCARHV-BFfTVEYQ.js} +1 -1
- package/dist/web-ui/assets/stateDiagram-v2-BHNVJYJU-DuO1A2q2.js +1 -0
- package/dist/web-ui/assets/{timeline-definition-PNZ67QCA-2z8RR-l_.js → timeline-definition-PNZ67QCA-cyPnAADn.js} +1 -1
- package/dist/web-ui/assets/{vennDiagram-CIIHVFJN-CSwDDhHv.js → vennDiagram-CIIHVFJN-Cb82-9OZ.js} +1 -1
- package/dist/web-ui/assets/{wardley-L42UT6IY-DW30MdHd.js → wardley-L42UT6IY-BTW1NXXR.js} +1 -1
- package/dist/web-ui/assets/{wardleyDiagram-YWT4CUSO-DUb2r21l.js → wardleyDiagram-YWT4CUSO-C_F_dT6n.js} +1 -1
- package/dist/web-ui/assets/{xychartDiagram-2RQKCTM6-4DTcVUL8.js → xychartDiagram-2RQKCTM6-clcfplhG.js} +1 -1
- package/dist/web-ui/index.html +1 -1
- package/package.json +1 -1
- package/dist/web-ui/assets/channel-CqbBz9iL.js +0 -1
- package/dist/web-ui/assets/classDiagram-4FO5ZUOK-DDQJP38f.js +0 -1
- package/dist/web-ui/assets/classDiagram-v2-Q7XG4LA2-DDQJP38f.js +0 -1
- package/dist/web-ui/assets/stateDiagram-v2-BHNVJYJU-CWa-Q2Gf.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{u as I,r as i,l as c,j as e,n as d,P as x,A as O}from"./index-BSktaJwx.js";function D(){const{t:l}=I(["common","home","work"]),[u,y]=i.useState(""),[r,o]=i.useState("all"),[t,m]=i.useState({agents:[],tasks:[],requirements:[],projects:[],deliverables:[],workflows:[]}),[h,b]=i.useState(!1),[w,p]=i.useState(!1),v=i.useRef(null),j=i.useRef(void 0);i.useEffect(()=>{setTimeout(()=>v.current?.focus(),100)},[]);const W=i.useCallback(async s=>{if(!s.trim()){m({agents:[],tasks:[],requirements:[],projects:[],deliverables:[],workflows:[]}),p(!1);return}b(!0),p(!0);const n=s.toLowerCase();try{const[N,C,V,R,L,A]=await Promise.allSettled([c.agents.list(),c.tasks.list({search:s,pageSize:20}),c.requirements.list(),c.projects.list(),c.deliverables.search({q:s,limit:20}),c.teams.list()]),E=N.status==="fulfilled"?N.value.agents.filter(a=>a.name?.toLowerCase().includes(n)||a.role?.toLowerCase().includes(n)):[],M=C.status==="fulfilled"?C.value.tasks:[],H=V.status==="fulfilled"?V.value.requirements.filter(a=>a.title?.toLowerCase().includes(n)||a.description?.toLowerCase().includes(n)):[],T=R.status==="fulfilled"?R.value.projects.filter(a=>a.name?.toLowerCase().includes(n)||a.description?.toLowerCase().includes(n)):[],z=L.status==="fulfilled"?L.value.results:[],S=[];if(A.status==="fulfilled"){const a=await Promise.allSettled(A.value.teams.map(f=>c.workflows.list(f.id)));for(const f of a)if(f.status==="fulfilled")for(const g of f.value.workflows)(g.name.toLowerCase().includes(n)||(g.displayName||"").toLowerCase().includes(n)||g.description?.toLowerCase().includes(n))&&S.push(g)}m({agents:E,tasks:M,requirements:H,projects:T,deliverables:z,workflows:S})}catch{m({agents:[],tasks:[],requirements:[],projects:[],deliverables:[],workflows:[]})}finally{b(!1)}},[]),B=s=>{y(s),j.current&&clearTimeout(j.current),j.current=setTimeout(()=>W(s),400)},q=[{id:"all",label:l("common:all",{defaultValue:"全部"})},{id:"agents",label:l("common:agents",{defaultValue:"智能体"})},{id:"tasks",label:l("common:tasks",{defaultValue:"任务"})},{id:"requirements",label:l("common:requirements",{defaultValue:"需求"})},{id:"projects",label:l("common:projects",{defaultValue:"项目"})},{id:"deliverables",label:l("common:deliverables",{defaultValue:"交付物"})},{id:"workflows",label:l("common:workflows",{defaultValue:"工作流"})}],k=t.agents.length>0||t.tasks.length>0||t.requirements.length>0||t.projects.length>0||t.deliverables.length>0||t.workflows.length>0;return e.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[e.jsxs("div",{className:"shrink-0 px-4 pt-4 pb-2 space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>d.navigate(x.HOME),className:"p-1.5 rounded-lg hover:bg-surface-overlay transition-colors shrink-0",children:e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M19 12H5"}),e.jsx("polyline",{points:"12 19 5 12 12 5"})]})}),e.jsxs("div",{className:"flex-1 relative",children:[e.jsxs("svg",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-fg-tertiary",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"11",cy:"11",r:"8"}),e.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]}),e.jsx("input",{ref:v,value:u,onChange:s=>B(s.target.value),placeholder:l("common:search"),className:"w-full bg-surface-elevated border border-border-default rounded-xl pl-9 pr-3 py-2.5 text-sm text-fg-primary placeholder:text-fg-tertiary focus:border-brand-500 focus:outline-none transition-colors"}),u&&e.jsx("button",{onClick:()=>{y(""),m({agents:[],tasks:[],requirements:[],projects:[],deliverables:[],workflows:[]}),p(!1),v.current?.focus()},className:"absolute right-3 top-1/2 -translate-y-1/2 text-fg-tertiary hover:text-fg-secondary",children:e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),e.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]})]}),e.jsx("div",{className:"flex gap-1 overflow-x-auto scrollbar-hide",children:q.map(s=>e.jsx("button",{onClick:()=>o(s.id),className:`px-3 py-1.5 text-xs rounded-lg whitespace-nowrap transition-colors ${r===s.id?"bg-brand-600 text-white":"bg-surface-elevated text-fg-secondary hover:text-fg-primary"}`,children:s.label},s.id))})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto px-4 pb-4",children:[h&&e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx("div",{className:"text-fg-tertiary text-sm animate-pulse",children:l("common:loading")})}),!h&&w&&!k&&e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsxs("svg",{width:"40",height:"40",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",className:"text-fg-tertiary mb-3",children:[e.jsx("circle",{cx:"11",cy:"11",r:"8"}),e.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]}),e.jsx("p",{className:"text-sm text-fg-tertiary",children:l("common:noResults",{defaultValue:"没有找到相关结果"})})]}),!h&&k&&e.jsxs("div",{className:"space-y-4",children:[(r==="all"||r==="agents")&&t.agents.length>0&&e.jsxs("section",{children:[e.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:l("common:agents",{defaultValue:"智能体"})}),e.jsx("div",{className:"space-y-1",children:(r==="all"?t.agents.slice(0,8):t.agents).map(s=>e.jsxs("button",{onClick:()=>d.navigate(x.TEAM,{agentId:s.id}),className:"w-full flex items-center gap-3 px-3 py-2.5 rounded-xl hover:bg-surface-overlay transition-colors text-left",children:[e.jsx(O,{name:s.name||"Agent",avatarUrl:s.avatarUrl,size:32}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-sm font-medium text-fg-primary truncate",children:s.name}),e.jsx("div",{className:"text-xs text-fg-tertiary truncate",children:s.role||s.status})]}),e.jsx(P,{status:s.status})]},s.id))}),r==="all"&&t.agents.length>8&&e.jsxs("button",{onClick:()=>o("agents"),className:"mt-1 w-full text-xs text-brand-500 hover:text-brand-400 py-1.5 rounded-lg hover:bg-surface-overlay transition-colors",children:[l("common:showAll",{defaultValue:"查看全部"})," (",t.agents.length,")"]})]}),(r==="all"||r==="tasks")&&t.tasks.length>0&&e.jsxs("section",{children:[e.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:l("common:tasks",{defaultValue:"任务"})}),e.jsx("div",{className:"space-y-1",children:(r==="all"?t.tasks.slice(0,8):t.tasks).map(s=>e.jsxs("button",{onClick:()=>d.navigate(x.WORK,{openTask:s.id}),className:"w-full flex items-center gap-3 px-3 py-2.5 rounded-xl hover:bg-surface-overlay transition-colors text-left",children:[e.jsx(K,{status:s.status}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-sm text-fg-primary truncate",children:s.title}),e.jsxs("div",{className:"text-xs text-fg-tertiary truncate",children:[s.status," · ",s.priority||""]})]})]},s.id))}),r==="all"&&t.tasks.length>8&&e.jsxs("button",{onClick:()=>o("tasks"),className:"mt-1 w-full text-xs text-brand-500 hover:text-brand-400 py-1.5 rounded-lg hover:bg-surface-overlay transition-colors",children:[l("common:showAll",{defaultValue:"查看全部"})," (",t.tasks.length,")"]})]}),(r==="all"||r==="requirements")&&t.requirements.length>0&&e.jsxs("section",{children:[e.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:l("common:requirements",{defaultValue:"需求"})}),e.jsx("div",{className:"space-y-1",children:(r==="all"?t.requirements.slice(0,8):t.requirements).map(s=>e.jsxs("button",{onClick:()=>d.navigate(x.WORK,{openRequirement:s.id}),className:"w-full flex items-center gap-3 px-3 py-2.5 rounded-xl hover:bg-surface-overlay transition-colors text-left",children:[e.jsx("div",{className:`w-8 h-8 rounded-lg flex items-center justify-center shrink-0 ${s.status==="approved"?"text-green-500 bg-green-500/15":s.status==="pending"?"text-amber-500 bg-amber-500/15":s.status==="rejected"?"text-red-500 bg-red-500/15":"text-fg-tertiary bg-surface-elevated"}`,children:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),e.jsx("polyline",{points:"14 2 14 8 20 8"}),e.jsx("line",{x1:"16",y1:"13",x2:"8",y2:"13"}),e.jsx("line",{x1:"16",y1:"17",x2:"8",y2:"17"})]})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-sm text-fg-primary truncate",children:s.title}),e.jsxs("div",{className:"text-xs text-fg-tertiary truncate",children:[s.status," · ",s.priority||""]})]})]},s.id))}),r==="all"&&t.requirements.length>8&&e.jsxs("button",{onClick:()=>o("requirements"),className:"mt-1 w-full text-xs text-brand-500 hover:text-brand-400 py-1.5 rounded-lg hover:bg-surface-overlay transition-colors",children:[l("common:showAll",{defaultValue:"查看全部"})," (",t.requirements.length,")"]})]}),(r==="all"||r==="projects")&&t.projects.length>0&&e.jsxs("section",{children:[e.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:l("common:projects",{defaultValue:"项目"})}),e.jsx("div",{className:"space-y-1",children:(r==="all"?t.projects.slice(0,8):t.projects).map(s=>e.jsxs("button",{onClick:()=>d.navigate(x.WORK,{projectId:s.id}),className:"w-full flex items-center gap-3 px-3 py-2.5 rounded-xl hover:bg-surface-overlay transition-colors text-left",children:[e.jsx("div",{className:"w-8 h-8 rounded-lg bg-brand-500/15 flex items-center justify-center shrink-0",children:e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"text-brand-500",children:e.jsx("path",{d:"M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z"})})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-sm text-fg-primary truncate",children:s.name}),s.description&&e.jsx("div",{className:"text-xs text-fg-tertiary truncate",children:s.description})]})]},s.id))}),r==="all"&&t.projects.length>8&&e.jsxs("button",{onClick:()=>o("projects"),className:"mt-1 w-full text-xs text-brand-500 hover:text-brand-400 py-1.5 rounded-lg hover:bg-surface-overlay transition-colors",children:[l("common:showAll",{defaultValue:"查看全部"})," (",t.projects.length,")"]})]}),(r==="all"||r==="deliverables")&&t.deliverables.length>0&&e.jsxs("section",{children:[e.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:l("common:deliverables",{defaultValue:"交付物"})}),e.jsx("div",{className:"space-y-1",children:(r==="all"?t.deliverables.slice(0,8):t.deliverables).map(s=>e.jsxs("button",{onClick:()=>d.navigate(x.DELIVERABLES,{openDeliverable:s.id}),className:"w-full flex items-center gap-3 px-3 py-2.5 rounded-xl hover:bg-surface-overlay transition-colors text-left",children:[e.jsx("div",{className:"w-8 h-8 rounded-lg bg-purple-500/15 flex items-center justify-center shrink-0",children:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"text-purple-500",children:[e.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),e.jsx("polyline",{points:"14 2 14 8 20 8"})]})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-sm text-fg-primary truncate",children:s.title}),e.jsxs("div",{className:"text-xs text-fg-tertiary truncate",children:[s.type," · ",s.status]})]})]},s.id))}),r==="all"&&t.deliverables.length>8&&e.jsxs("button",{onClick:()=>o("deliverables"),className:"mt-1 w-full text-xs text-brand-500 hover:text-brand-400 py-1.5 rounded-lg hover:bg-surface-overlay transition-colors",children:[l("common:showAll",{defaultValue:"查看全部"})," (",t.deliverables.length,")"]})]}),(r==="all"||r==="workflows")&&t.workflows.length>0&&e.jsxs("section",{children:[e.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:l("common:workflows",{defaultValue:"工作流"})}),e.jsx("div",{className:"space-y-1",children:(r==="all"?t.workflows.slice(0,8):t.workflows).map(s=>e.jsxs("button",{onClick:()=>d.navigate(x.WORK,{boardType:"workflows"}),className:"w-full flex items-center gap-3 px-3 py-2.5 rounded-xl hover:bg-surface-overlay transition-colors text-left",children:[e.jsx("div",{className:"w-8 h-8 rounded-lg bg-teal-500/15 flex items-center justify-center shrink-0",children:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"text-teal-500",children:[e.jsx("circle",{cx:"12",cy:"12",r:"3"}),e.jsx("path",{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-2 2 2 2 0 0 1-2-2v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06A1.65 1.65 0 0 0 4.68 15a1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1-2-2 2 2 0 0 1 2-2h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06A1.65 1.65 0 0 0 9 4.68a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 2-2 2 2 0 0 1 2 2v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06A1.65 1.65 0 0 0 19.4 9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 2 2 2 2 0 0 1-2 2h-.09a1.65 1.65 0 0 0-1.51 1z"})]})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-sm text-fg-primary truncate",children:s.displayName||s.name}),e.jsxs("div",{className:"text-xs text-fg-tertiary truncate",children:[s.stepCount," steps · v",s.version]})]})]},s.name))}),r==="all"&&t.workflows.length>8&&e.jsxs("button",{onClick:()=>o("workflows"),className:"mt-1 w-full text-xs text-brand-500 hover:text-brand-400 py-1.5 rounded-lg hover:bg-surface-overlay transition-colors",children:[l("common:showAll",{defaultValue:"查看全部"})," (",t.workflows.length,")"]})]})]}),!h&&!w&&e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsxs("svg",{width:"40",height:"40",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",className:"text-fg-tertiary mb-3",children:[e.jsx("circle",{cx:"11",cy:"11",r:"8"}),e.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]}),e.jsx("p",{className:"text-sm text-fg-tertiary",children:l("common:search")})]})]})]})}function P({status:l}){const u=l==="active"||l==="idle"?"bg-green-500":l==="working"||l==="busy"?"bg-blue-500":"bg-gray-400";return e.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${u}`})}function K({status:l}){const u=l==="completed"?"text-green-500 bg-green-500/15":l==="in_progress"?"text-blue-500 bg-blue-500/15":l==="pending"?"text-amber-500 bg-amber-500/15":"text-fg-tertiary bg-surface-elevated";return e.jsx("div",{className:`w-8 h-8 rounded-lg flex items-center justify-center shrink-0 ${u}`,children:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("path",{d:"M9 11l3 3L22 4"}),e.jsx("path",{d:"M21 12v7a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11"})]})})}export{D as SearchPage};
|
|
1
|
+
import{u as I,r as i,l as c,j as e,n as d,P as x,A as O}from"./index-1X1Ykov8.js";function D(){const{t:l}=I(["common","home","work"]),[u,y]=i.useState(""),[r,o]=i.useState("all"),[t,m]=i.useState({agents:[],tasks:[],requirements:[],projects:[],deliverables:[],workflows:[]}),[h,b]=i.useState(!1),[w,p]=i.useState(!1),v=i.useRef(null),j=i.useRef(void 0);i.useEffect(()=>{setTimeout(()=>v.current?.focus(),100)},[]);const W=i.useCallback(async s=>{if(!s.trim()){m({agents:[],tasks:[],requirements:[],projects:[],deliverables:[],workflows:[]}),p(!1);return}b(!0),p(!0);const n=s.toLowerCase();try{const[N,C,V,R,L,A]=await Promise.allSettled([c.agents.list(),c.tasks.list({search:s,pageSize:20}),c.requirements.list(),c.projects.list(),c.deliverables.search({q:s,limit:20}),c.teams.list()]),E=N.status==="fulfilled"?N.value.agents.filter(a=>a.name?.toLowerCase().includes(n)||a.role?.toLowerCase().includes(n)):[],M=C.status==="fulfilled"?C.value.tasks:[],H=V.status==="fulfilled"?V.value.requirements.filter(a=>a.title?.toLowerCase().includes(n)||a.description?.toLowerCase().includes(n)):[],T=R.status==="fulfilled"?R.value.projects.filter(a=>a.name?.toLowerCase().includes(n)||a.description?.toLowerCase().includes(n)):[],z=L.status==="fulfilled"?L.value.results:[],S=[];if(A.status==="fulfilled"){const a=await Promise.allSettled(A.value.teams.map(f=>c.workflows.list(f.id)));for(const f of a)if(f.status==="fulfilled")for(const g of f.value.workflows)(g.name.toLowerCase().includes(n)||(g.displayName||"").toLowerCase().includes(n)||g.description?.toLowerCase().includes(n))&&S.push(g)}m({agents:E,tasks:M,requirements:H,projects:T,deliverables:z,workflows:S})}catch{m({agents:[],tasks:[],requirements:[],projects:[],deliverables:[],workflows:[]})}finally{b(!1)}},[]),B=s=>{y(s),j.current&&clearTimeout(j.current),j.current=setTimeout(()=>W(s),400)},q=[{id:"all",label:l("common:all",{defaultValue:"全部"})},{id:"agents",label:l("common:agents",{defaultValue:"智能体"})},{id:"tasks",label:l("common:tasks",{defaultValue:"任务"})},{id:"requirements",label:l("common:requirements",{defaultValue:"需求"})},{id:"projects",label:l("common:projects",{defaultValue:"项目"})},{id:"deliverables",label:l("common:deliverables",{defaultValue:"交付物"})},{id:"workflows",label:l("common:workflows",{defaultValue:"工作流"})}],k=t.agents.length>0||t.tasks.length>0||t.requirements.length>0||t.projects.length>0||t.deliverables.length>0||t.workflows.length>0;return e.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[e.jsxs("div",{className:"shrink-0 px-4 pt-4 pb-2 space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>d.navigate(x.HOME),className:"p-1.5 rounded-lg hover:bg-surface-overlay transition-colors shrink-0",children:e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M19 12H5"}),e.jsx("polyline",{points:"12 19 5 12 12 5"})]})}),e.jsxs("div",{className:"flex-1 relative",children:[e.jsxs("svg",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-fg-tertiary",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"11",cy:"11",r:"8"}),e.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]}),e.jsx("input",{ref:v,value:u,onChange:s=>B(s.target.value),placeholder:l("common:search"),className:"w-full bg-surface-elevated border border-border-default rounded-xl pl-9 pr-3 py-2.5 text-sm text-fg-primary placeholder:text-fg-tertiary focus:border-brand-500 focus:outline-none transition-colors"}),u&&e.jsx("button",{onClick:()=>{y(""),m({agents:[],tasks:[],requirements:[],projects:[],deliverables:[],workflows:[]}),p(!1),v.current?.focus()},className:"absolute right-3 top-1/2 -translate-y-1/2 text-fg-tertiary hover:text-fg-secondary",children:e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),e.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]})]}),e.jsx("div",{className:"flex gap-1 overflow-x-auto scrollbar-hide",children:q.map(s=>e.jsx("button",{onClick:()=>o(s.id),className:`px-3 py-1.5 text-xs rounded-lg whitespace-nowrap transition-colors ${r===s.id?"bg-brand-600 text-white":"bg-surface-elevated text-fg-secondary hover:text-fg-primary"}`,children:s.label},s.id))})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto px-4 pb-4",children:[h&&e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx("div",{className:"text-fg-tertiary text-sm animate-pulse",children:l("common:loading")})}),!h&&w&&!k&&e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsxs("svg",{width:"40",height:"40",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",className:"text-fg-tertiary mb-3",children:[e.jsx("circle",{cx:"11",cy:"11",r:"8"}),e.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]}),e.jsx("p",{className:"text-sm text-fg-tertiary",children:l("common:noResults",{defaultValue:"没有找到相关结果"})})]}),!h&&k&&e.jsxs("div",{className:"space-y-4",children:[(r==="all"||r==="agents")&&t.agents.length>0&&e.jsxs("section",{children:[e.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:l("common:agents",{defaultValue:"智能体"})}),e.jsx("div",{className:"space-y-1",children:(r==="all"?t.agents.slice(0,8):t.agents).map(s=>e.jsxs("button",{onClick:()=>d.navigate(x.TEAM,{agentId:s.id}),className:"w-full flex items-center gap-3 px-3 py-2.5 rounded-xl hover:bg-surface-overlay transition-colors text-left",children:[e.jsx(O,{name:s.name||"Agent",avatarUrl:s.avatarUrl,size:32}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-sm font-medium text-fg-primary truncate",children:s.name}),e.jsx("div",{className:"text-xs text-fg-tertiary truncate",children:s.role||s.status})]}),e.jsx(P,{status:s.status})]},s.id))}),r==="all"&&t.agents.length>8&&e.jsxs("button",{onClick:()=>o("agents"),className:"mt-1 w-full text-xs text-brand-500 hover:text-brand-400 py-1.5 rounded-lg hover:bg-surface-overlay transition-colors",children:[l("common:showAll",{defaultValue:"查看全部"})," (",t.agents.length,")"]})]}),(r==="all"||r==="tasks")&&t.tasks.length>0&&e.jsxs("section",{children:[e.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:l("common:tasks",{defaultValue:"任务"})}),e.jsx("div",{className:"space-y-1",children:(r==="all"?t.tasks.slice(0,8):t.tasks).map(s=>e.jsxs("button",{onClick:()=>d.navigate(x.WORK,{openTask:s.id}),className:"w-full flex items-center gap-3 px-3 py-2.5 rounded-xl hover:bg-surface-overlay transition-colors text-left",children:[e.jsx(K,{status:s.status}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-sm text-fg-primary truncate",children:s.title}),e.jsxs("div",{className:"text-xs text-fg-tertiary truncate",children:[s.status," · ",s.priority||""]})]})]},s.id))}),r==="all"&&t.tasks.length>8&&e.jsxs("button",{onClick:()=>o("tasks"),className:"mt-1 w-full text-xs text-brand-500 hover:text-brand-400 py-1.5 rounded-lg hover:bg-surface-overlay transition-colors",children:[l("common:showAll",{defaultValue:"查看全部"})," (",t.tasks.length,")"]})]}),(r==="all"||r==="requirements")&&t.requirements.length>0&&e.jsxs("section",{children:[e.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:l("common:requirements",{defaultValue:"需求"})}),e.jsx("div",{className:"space-y-1",children:(r==="all"?t.requirements.slice(0,8):t.requirements).map(s=>e.jsxs("button",{onClick:()=>d.navigate(x.WORK,{openRequirement:s.id}),className:"w-full flex items-center gap-3 px-3 py-2.5 rounded-xl hover:bg-surface-overlay transition-colors text-left",children:[e.jsx("div",{className:`w-8 h-8 rounded-lg flex items-center justify-center shrink-0 ${s.status==="approved"?"text-green-500 bg-green-500/15":s.status==="pending"?"text-amber-500 bg-amber-500/15":s.status==="rejected"?"text-red-500 bg-red-500/15":"text-fg-tertiary bg-surface-elevated"}`,children:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),e.jsx("polyline",{points:"14 2 14 8 20 8"}),e.jsx("line",{x1:"16",y1:"13",x2:"8",y2:"13"}),e.jsx("line",{x1:"16",y1:"17",x2:"8",y2:"17"})]})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-sm text-fg-primary truncate",children:s.title}),e.jsxs("div",{className:"text-xs text-fg-tertiary truncate",children:[s.status," · ",s.priority||""]})]})]},s.id))}),r==="all"&&t.requirements.length>8&&e.jsxs("button",{onClick:()=>o("requirements"),className:"mt-1 w-full text-xs text-brand-500 hover:text-brand-400 py-1.5 rounded-lg hover:bg-surface-overlay transition-colors",children:[l("common:showAll",{defaultValue:"查看全部"})," (",t.requirements.length,")"]})]}),(r==="all"||r==="projects")&&t.projects.length>0&&e.jsxs("section",{children:[e.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:l("common:projects",{defaultValue:"项目"})}),e.jsx("div",{className:"space-y-1",children:(r==="all"?t.projects.slice(0,8):t.projects).map(s=>e.jsxs("button",{onClick:()=>d.navigate(x.WORK,{projectId:s.id}),className:"w-full flex items-center gap-3 px-3 py-2.5 rounded-xl hover:bg-surface-overlay transition-colors text-left",children:[e.jsx("div",{className:"w-8 h-8 rounded-lg bg-brand-500/15 flex items-center justify-center shrink-0",children:e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"text-brand-500",children:e.jsx("path",{d:"M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z"})})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-sm text-fg-primary truncate",children:s.name}),s.description&&e.jsx("div",{className:"text-xs text-fg-tertiary truncate",children:s.description})]})]},s.id))}),r==="all"&&t.projects.length>8&&e.jsxs("button",{onClick:()=>o("projects"),className:"mt-1 w-full text-xs text-brand-500 hover:text-brand-400 py-1.5 rounded-lg hover:bg-surface-overlay transition-colors",children:[l("common:showAll",{defaultValue:"查看全部"})," (",t.projects.length,")"]})]}),(r==="all"||r==="deliverables")&&t.deliverables.length>0&&e.jsxs("section",{children:[e.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:l("common:deliverables",{defaultValue:"交付物"})}),e.jsx("div",{className:"space-y-1",children:(r==="all"?t.deliverables.slice(0,8):t.deliverables).map(s=>e.jsxs("button",{onClick:()=>d.navigate(x.DELIVERABLES,{openDeliverable:s.id}),className:"w-full flex items-center gap-3 px-3 py-2.5 rounded-xl hover:bg-surface-overlay transition-colors text-left",children:[e.jsx("div",{className:"w-8 h-8 rounded-lg bg-purple-500/15 flex items-center justify-center shrink-0",children:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"text-purple-500",children:[e.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),e.jsx("polyline",{points:"14 2 14 8 20 8"})]})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-sm text-fg-primary truncate",children:s.title}),e.jsxs("div",{className:"text-xs text-fg-tertiary truncate",children:[s.type," · ",s.status]})]})]},s.id))}),r==="all"&&t.deliverables.length>8&&e.jsxs("button",{onClick:()=>o("deliverables"),className:"mt-1 w-full text-xs text-brand-500 hover:text-brand-400 py-1.5 rounded-lg hover:bg-surface-overlay transition-colors",children:[l("common:showAll",{defaultValue:"查看全部"})," (",t.deliverables.length,")"]})]}),(r==="all"||r==="workflows")&&t.workflows.length>0&&e.jsxs("section",{children:[e.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:l("common:workflows",{defaultValue:"工作流"})}),e.jsx("div",{className:"space-y-1",children:(r==="all"?t.workflows.slice(0,8):t.workflows).map(s=>e.jsxs("button",{onClick:()=>d.navigate(x.WORK,{boardType:"workflows"}),className:"w-full flex items-center gap-3 px-3 py-2.5 rounded-xl hover:bg-surface-overlay transition-colors text-left",children:[e.jsx("div",{className:"w-8 h-8 rounded-lg bg-teal-500/15 flex items-center justify-center shrink-0",children:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"text-teal-500",children:[e.jsx("circle",{cx:"12",cy:"12",r:"3"}),e.jsx("path",{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-2 2 2 2 0 0 1-2-2v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06A1.65 1.65 0 0 0 4.68 15a1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1-2-2 2 2 0 0 1 2-2h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06A1.65 1.65 0 0 0 9 4.68a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 2-2 2 2 0 0 1 2 2v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06A1.65 1.65 0 0 0 19.4 9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 2 2 2 2 0 0 1-2 2h-.09a1.65 1.65 0 0 0-1.51 1z"})]})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-sm text-fg-primary truncate",children:s.displayName||s.name}),e.jsxs("div",{className:"text-xs text-fg-tertiary truncate",children:[s.stepCount," steps · v",s.version]})]})]},s.name))}),r==="all"&&t.workflows.length>8&&e.jsxs("button",{onClick:()=>o("workflows"),className:"mt-1 w-full text-xs text-brand-500 hover:text-brand-400 py-1.5 rounded-lg hover:bg-surface-overlay transition-colors",children:[l("common:showAll",{defaultValue:"查看全部"})," (",t.workflows.length,")"]})]})]}),!h&&!w&&e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsxs("svg",{width:"40",height:"40",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",className:"text-fg-tertiary mb-3",children:[e.jsx("circle",{cx:"11",cy:"11",r:"8"}),e.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]}),e.jsx("p",{className:"text-sm text-fg-tertiary",children:l("common:search")})]})]})]})}function P({status:l}){const u=l==="active"||l==="idle"?"bg-green-500":l==="working"||l==="busy"?"bg-blue-500":"bg-gray-400";return e.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${u}`})}function K({status:l}){const u=l==="completed"?"text-green-500 bg-green-500/15":l==="in_progress"?"text-blue-500 bg-blue-500/15":l==="pending"?"text-amber-500 bg-amber-500/15":"text-fg-tertiary bg-surface-elevated";return e.jsx("div",{className:`w-8 h-8 rounded-lg flex items-center justify-center shrink-0 ${u}`,children:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("path",{d:"M9 11l3 3L22 4"}),e.jsx("path",{d:"M21 12v7a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11"})]})})}export{D as SearchPage};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{u as ye,r as i,j as e,F as Fr,l as V,x as pa,k as ha,a as ba,b as ya,c as va,Z as Fs,n as lr,$ as ja,a0 as _s,P as Us,h as Ve,i as wa,a1 as Ln,w as Na,o as dr,t as _r,_ as ka}from"./index-BSktaJwx.js";import{i as Ca}from"./modelCapabilities-DDtCBZ6o.js";function Sa(r,s){for(var l=0;l<s.length;l++){const o=s[l];if(typeof o!="string"&&!Array.isArray(o)){for(const a in o)if(a!=="default"&&!(a in r)){const t=Object.getOwnPropertyDescriptor(o,a);t&&Object.defineProperty(r,a,t.get?t:{enumerable:!0,get:()=>o[a]})}}}return Object.freeze(Object.defineProperty(r,Symbol.toStringTag,{value:"Module"}))}function Pa(r){return r>=1e6?`${(r/1e6).toFixed(r%1e6===0?0:1)}M`:r>=1e3?`${(r/1e3).toFixed((r%1e3===0,0))}K`:String(r)}function Ma(r){return r.maxInputTokens>0||r.inputCostPer1MTokens>0||r.outputCostPer1MTokens>0}function cr(r){if(r.tier)return r.tier;const s=r.id.toLowerCase(),l=/opus|5\.4|o3-(?!mini)|o1-(?!mini)|gemini.*ultra|sonnet-4-20/,o=/haiku|flash|nano|lite|small|fast|free|8b|7b|1b|3b/;return/o4-mini|o3-mini|o1-mini|gpt-4o-mini/.test(s)?"pro":l.test(s)?"max":o.test(s)?"base":"pro"}const $s={max:"bg-purple-500/20 text-purple-400 border-purple-500/30",pro:"bg-blue-500/20 text-blue-400 border-blue-500/30",base:"bg-gray-500/20 text-gray-400 border-gray-500/30"};function In({models:r,selectedModel:s,onSelect:l,loading:o,compact:a,maxVisible:t,showTiers:c}){const{t:u}=ye("settings"),[x,h]=i.useState(""),[y,A]=i.useState(!1),[g,C]=i.useState(""),N=i.useMemo(()=>{let m=r;if(x){const w=x.toLowerCase();m=m.filter(R=>R.id.toLowerCase().includes(w))}return g&&(m=m.filter(w=>cr(w)===g)),m},[r,x,g]),b=i.useMemo(()=>{const m={max:0,pro:0,base:0};for(const w of r)m[cr(w)]++;return m},[r]),S=t??(a?5:10),f=y?N:N.slice(0,S),v=N.length>S;return o?e.jsxs("div",{className:"flex items-center gap-2 py-4 text-sm text-fg-tertiary",children:[e.jsx("div",{className:"w-4 h-4 border-2 border-brand-500 border-t-transparent rounded-full animate-spin"}),u("modelPicker.loading")]}):r.length===0?e.jsx("div",{className:"py-3 text-sm text-fg-tertiary",children:u("modelPicker.empty")}):e.jsxs("div",{className:"space-y-2",children:[c&&r.length>3&&e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("button",{onClick:()=>C(""),className:`px-2 py-0.5 rounded text-[10px] transition-colors ${g?"bg-surface-overlay text-fg-tertiary hover:text-fg-secondary":"bg-brand-500/20 text-brand-500"}`,children:u("modelPicker.allCount",{count:r.length})}),["max","pro","base"].filter(m=>b[m]>0).map(m=>e.jsx("button",{onClick:()=>C(g===m?"":m),className:`px-2 py-0.5 rounded text-[10px] font-medium uppercase transition-colors border ${g===m?$s[m]:"border-transparent bg-surface-overlay text-fg-tertiary hover:text-fg-secondary"}`,children:u("modelPicker.tierCount",{tier:u(`modelRouting.tier.${m}`),count:b[m]})},m))]}),r.length>5&&e.jsx("input",{type:"text",value:x,onChange:m=>{h(m.target.value),A(!1)},placeholder:u("modelPicker.filterPlaceholder"),className:"w-full px-3 py-1.5 bg-surface-overlay border border-border-default rounded-lg text-xs text-fg-primary placeholder:text-fg-tertiary focus:outline-none focus:border-brand-500"}),e.jsx("div",{className:`space-y-1 ${a?"max-h-[280px] overflow-y-auto":""}`,children:f.map(m=>{const w=m.id===s,R=cr(m);return e.jsxs("button",{type:"button",onClick:()=>l(m.id),className:`w-full text-left px-3 py-2 rounded-lg transition-colors ${w?"bg-brand-500/10 border border-brand-500/30":"hover:bg-surface-overlay border border-transparent"}`,children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:`w-3 h-3 rounded-full border-2 flex items-center justify-center ${w?"border-brand-500":"border-border-default"}`,children:w&&e.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-brand-500"})}),e.jsx("span",{className:`text-xs font-medium ${w?"text-brand-500":"text-fg-primary"}`,children:m.id}),c&&e.jsx("span",{className:`px-1.5 py-0.5 rounded text-[9px] font-semibold uppercase border ${$s[R]}`,children:u(`modelRouting.tier.${R}`)})]}),e.jsx("div",{className:"flex items-center gap-2",children:w&&e.jsx("span",{className:"text-[10px] text-brand-500 font-medium",children:u("modelPicker.active")})})]}),Ma(m)&&m.maxInputTokens>0&&e.jsx("div",{className:"ml-5 mt-0.5 flex items-center gap-2 text-[10px] text-fg-tertiary flex-wrap",children:e.jsxs("span",{children:[Pa(m.maxInputTokens)," ",u("modelPicker.ctx")]})}),!a&&e.jsxs("div",{className:"ml-5 mt-1 flex items-center gap-1.5 flex-wrap",children:[m.capabilities.functionCalling&&e.jsx(lt,{label:u("modelPicker.capabilities.tools")}),m.capabilities.vision&&e.jsx(lt,{label:u("modelPicker.capabilities.vision")}),m.capabilities.reasoning&&e.jsx(lt,{label:u("modelPicker.capabilities.reasoning")}),m.capabilities.promptCaching&&e.jsx(lt,{label:u("modelPicker.capabilities.caching")}),m.capabilities.webSearch&&e.jsx(lt,{label:u("modelPicker.capabilities.search")})]})]},m.id)})}),v&&!y&&e.jsx("button",{type:"button",onClick:()=>A(!0),className:"text-xs text-brand-500 hover:text-brand-400 px-3",children:u("modelPicker.showAll",{count:N.length})}),y&&v&&e.jsx("button",{type:"button",onClick:()=>A(!1),className:"text-xs text-fg-tertiary hover:text-fg-secondary px-3",children:u("modelPicker.showLess")})]})}function lt({label:r}){return e.jsx("span",{className:"px-1.5 py-0.5 rounded text-[9px] bg-surface-overlay text-fg-tertiary border border-border-default",children:r})}function xt({value:r,options:s,placeholder:l,onChange:o}){const{t:a}=ye("settings"),[t,c]=i.useState(!1),[u,x]=i.useState(""),h=i.useRef(null),y=i.useRef(null),A=i.useRef(null),[g,C]=i.useState(-1);i.useEffect(()=>{function m(w){h.current&&!h.current.contains(w.target)&&c(!1)}return document.addEventListener("mousedown",m),()=>document.removeEventListener("mousedown",m)},[]),i.useEffect(()=>{t&&y.current&&y.current.focus()},[t]);const N=i.useMemo(()=>{if(!u.trim())return s;const m=u.toLowerCase();return s.filter(w=>w.modelId.toLowerCase().includes(m)||w.modelName.toLowerCase().includes(m)||w.provider.toLowerCase().includes(m)||w.providerLabel.toLowerCase().includes(m)||w.tier&&w.tier.toLowerCase().includes(m))},[s,u]),b=i.useMemo(()=>{const m=new Map;for(const R of N){const I=R.providerLabel;m.has(I)||m.set(I,[]),m.get(I).push(R)}const w={max:0,pro:1,base:2};for(const R of m.values())R.sort((I,F)=>(w[I.tier??"base"]??9)-(w[F.tier??"base"]??9));return m},[N]),S=i.useMemo(()=>{const m=[];for(const w of b.values())m.push(...w);return m},[b]),f=i.useMemo(()=>{if(!r)return l??a("modelRouting.auto");const m=s.find(w=>`${w.provider}/${w.modelId}`===r);return m?`${m.providerLabel}/${m.modelName}`:r},[r,s,l,a]);function v(m){if(!t){(m.key==="Enter"||m.key===" ")&&(m.preventDefault(),c(!0));return}switch(m.key){case"ArrowDown":m.preventDefault(),C(w=>Math.min(w+1,S.length-1));break;case"ArrowUp":m.preventDefault(),C(w=>Math.max(w-1,-1));break;case"Enter":m.preventDefault(),g===-1?o(""):S[g]&&o(`${S[g].provider}/${S[g].modelId}`),c(!1),x("");break;case"Escape":c(!1),x("");break}}return i.useEffect(()=>{A.current&&g>=0&&A.current.querySelector(`[data-focus-index="${g}"]`)?.scrollIntoView({block:"nearest"})},[g]),e.jsxs("div",{ref:h,className:"relative",onKeyDown:v,children:[e.jsx("button",{type:"button",onClick:()=>{c(!t),x(""),C(-1)},className:"w-full px-2 py-1 bg-surface-overlay border border-border-default rounded text-xs text-fg-primary text-left truncate focus:outline-none focus:border-brand-500",children:f}),t&&e.jsxs("div",{className:"absolute z-50 mt-1 w-full min-w-[240px] max-h-[280px] bg-surface-elevated border border-border-default rounded-lg shadow-xl overflow-hidden flex flex-col",children:[e.jsx("div",{className:"p-1.5 border-b border-border-default",children:e.jsx("input",{ref:y,type:"text",value:u,onChange:m=>{x(m.target.value),C(-1)},placeholder:a("modelPicker.searchPlaceholder")||"Search models...",className:"w-full px-2 py-1 bg-surface-overlay border border-border-default rounded text-xs text-fg-primary focus:outline-none focus:border-brand-500"})}),e.jsxs("div",{ref:A,className:"overflow-y-auto flex-1",children:[e.jsx("div",{className:`px-3 py-1.5 text-xs cursor-pointer ${g===-1?"bg-brand-500/20 text-brand-500":"text-fg-secondary hover:bg-surface-overlay"}`,onClick:()=>{o(""),c(!1),x("")},children:l??a("modelRouting.auto")}),[...b.entries()].map(([m,w])=>e.jsxs("div",{children:[e.jsx("div",{className:"px-3 py-1 text-[10px] font-semibold text-fg-tertiary uppercase tracking-wider bg-surface-overlay/50 sticky top-0",children:m}),w.map(R=>{const I=S.indexOf(R),F=`${R.provider}/${R.modelId}`===r;return e.jsxs("div",{"data-focus-index":I,className:`px-3 py-1.5 text-xs cursor-pointer flex items-center gap-2 ${I===g?"bg-brand-500/20":F?"bg-surface-overlay":"hover:bg-surface-overlay/50"}`,onClick:()=>{o(`${R.provider}/${R.modelId}`),c(!1),x("")},children:[e.jsx("span",{className:"flex-1 truncate text-fg-primary",children:R.modelName}),R.tier&&e.jsx(Aa,{tier:R.tier}),R.costTier&&e.jsx("span",{className:"text-[9px] text-fg-tertiary",children:R.costTier})]},`${R.provider}/${R.modelId}`)})]},m)),S.length===0&&e.jsx("div",{className:"px-3 py-3 text-xs text-fg-tertiary text-center",children:a("modelPicker.empty")})]})]})]})}function Aa({tier:r}){const s={max:"bg-purple-500/20 text-purple-400",pro:"bg-blue-500/20 text-blue-400",base:"bg-gray-500/20 text-gray-400"};return e.jsx("span",{className:`px-1 py-0.5 rounded text-[8px] font-bold uppercase ${s[r]??s.base}`,children:r})}const Ea=500,Vs=[{groupKey:"image",capabilities:["image_recognition","image_generation"]},{groupKey:"audio",capabilities:["audio_tts","audio_stt"]},{groupKey:"video",capabilities:["video_generation"]}];function Ta({onSave:r,configuredProviders:s}){const{t:l}=ye(["settings","common"]),[o,a]=i.useState({}),[t,c]=i.useState(null),[u,x]=i.useState(!1),[h,y]=i.useState(null),[A,g]=i.useState(!0),[C,N]=i.useState("idle"),[b,S]=i.useState(null),[f,v]=i.useState({}),[m,w]=i.useState(!1),[R,I]=i.useState("idle"),[F,$]=i.useState(null),[P,O]=i.useState(!1),L=i.useRef(null),U=i.useRef(null),_=i.useMemo(()=>s.map(d=>d.name).sort().join(","),[s]);i.useEffect(()=>{fetch("/api/settings/llm/routing",{credentials:"include"}).then(d=>{if(!d.ok)throw new Error(`HTTP ${d.status}`);return d.json()}).then(d=>{a(d.capabilityRouting?.assignments??{}),c(d.routingDefaultModel??null),x(!0)}).catch(d=>{y(String(d)),x(!0)})},[_]),i.useEffect(()=>{let d=!1;return g(!0),fetch("/api/models/routing-candidates",{credentials:"include"}).then(k=>{if(!k.ok)throw new Error(`HTTP ${k.status}`);return k.json()}).then(k=>{if(d)return;const D=[];for(const z of k.providers)for(const J of z.models)D.push({provider:z.provider,providerLabel:z.displayName,modelId:J.id,modelName:J.name,mode:J.mode,tier:J.tier,costTier:J.costTier,capabilities:J.capabilities});S(D)}).catch(()=>{d||S(null)}).finally(()=>{d||g(!1)}),()=>{d=!0}},[_]),i.useEffect(()=>{fetch("/api/models/suggested-assignments",{credentials:"include"}).then(d=>{if(!d.ok)throw new Error(`HTTP ${d.status}`);return d.json()}).then(d=>{v(d.suggestions),w(!0)}).catch(()=>w(!0))},[_]);const K=i.useCallback(d=>{N("saving"),r(d).then(()=>{N("saved"),setTimeout(()=>N(k=>k==="saved"?"idle":k),2e3)}).catch(()=>{N("error"),setTimeout(()=>N(k=>k==="error"?"idle":k),3e3)})},[r]),q=i.useCallback((d,k)=>{U.current={capabilityRouting:d!==void 0?{assignments:d}:U.current?.capabilityRouting,routingDefaultModel:k!==void 0?k:U.current?.routingDefaultModel},L.current&&clearTimeout(L.current),L.current=setTimeout(()=>{const D=U.current;U.current=null,D&&K(D)},Ea)},[K]),T=i.useMemo(()=>s.flatMap(d=>(d.models??[{id:d.model,name:d.model}]).map(k=>({provider:d.name,providerLabel:d.displayName??d.name,modelId:k.id,modelName:k.name}))),[s]),B=b??T,ee=i.useMemo(()=>Object.entries(o).map(([d,k])=>`${d}:${k?.provider??""}/${k?.model??""}`).sort().join("|"),[o]);i.useEffect(()=>{!u||!b||b.length===0||b.some(d=>!!d.modelId)&&(a(d=>{let k=!1;const D={...d};for(const z of Vs)for(const J of z.capabilities){const re=D[J];if(!re?.model)continue;const Z=Rn(b,J);if(Z.length===0)continue;Z.some(Ne=>Ne.provider===re.provider&&Ne.modelId===re.model)||(delete D[J],k=!0)}return k?(q(D),D):d}),c(d=>{if(!d?.model||b.some(J=>J.provider===d.provider&&J.modelId===d.model))return d;const D=b.find(J=>J.provider==="markus"),z=D?{provider:D.provider,model:D.modelId}:{provider:b[0].provider,model:b[0].modelId};return r({routingDefaultModel:z}),z}))},[u,b,_,q,ee]);const ie=i.useCallback(()=>{fetch("/api/settings/llm/routing",{credentials:"include"}).then(d=>{if(!d.ok)throw new Error(`HTTP ${d.status}`);return d.json()}).then(d=>{a(d.capabilityRouting?.assignments??{}),c(d.routingDefaultModel??null)}).catch(()=>{}),g(!0),fetch("/api/models/routing-candidates",{credentials:"include"}).then(d=>{if(!d.ok)throw new Error(`HTTP ${d.status}`);return d.json()}).then(d=>{const k=[];for(const D of d.providers)for(const z of D.models)k.push({provider:D.provider,providerLabel:D.displayName,modelId:z.id,modelName:z.name,mode:z.mode,tier:z.tier,costTier:z.costTier,capabilities:z.capabilities});S(k)}).catch(()=>{}).finally(()=>g(!1))},[]),de=i.useCallback(async()=>{if(R!=="working"){I("working"),$(null);try{const d=await fetch("/api/settings/llm/restore-recommended",{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"}}),k=await d.json().catch(()=>({}));if(!d.ok||!k.ok)throw new Error(k.error??`HTTP ${d.status}`);k.capabilityRouting&&a(k.capabilityRouting.assignments??{}),k.routingDefaultModel!==void 0&&c(k.routingDefaultModel),ie(),I("idle"),N("saved"),setTimeout(()=>N(D=>D==="saved"?"idle":D),2e3)}catch(d){I("error"),$(d instanceof Error?d.message:String(d)),setTimeout(()=>I("idle"),4e3)}}},[R,ie]),se=B.length>0;return u?h?e.jsx("div",{className:"bg-red-500/10 border border-red-500/30 rounded-xl p-4 text-xs text-red-400",children:l("modelRouting.loadError",{error:h})}):A&&!se?e.jsx("div",{className:"space-y-4",children:e.jsx("div",{className:"bg-surface-elevated rounded-xl p-5",children:e.jsxs("div",{className:"flex items-center gap-2 text-xs text-fg-secondary",children:[e.jsxs("svg",{className:"w-4 h-4 animate-spin text-brand-500",fill:"none",viewBox:"0 0 24 24",children:[e.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),e.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8v4a4 4 0 00-4 4H4z"})]}),e.jsx("span",{children:l("modelRouting.loadingModels")})]})})}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx(Ra,{status:C,t:l}),e.jsxs("div",{className:"flex flex-col items-end gap-1",children:[e.jsx("button",{type:"button",onClick:()=>O(!0),disabled:R==="working",className:"text-xs px-3 py-1.5 rounded-lg border border-border-default text-fg-secondary hover:text-fg-primary hover:border-brand-500/40 disabled:opacity-50 transition-colors",children:l(R==="working"?"modelRouting.restoreWorking":"modelRouting.restoreRecommended")}),F&&e.jsx("span",{className:"text-[10px] text-red-400 max-w-xs text-right",children:F})]})]}),e.jsxs("div",{className:"bg-surface-elevated rounded-xl p-5 space-y-3",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-semibold text-fg-primary",children:l("modelRouting.defaultModelTitle")}),e.jsx("p",{className:"text-xs text-fg-tertiary mt-1",children:l("modelRouting.defaultModelDesc")})]}),e.jsx("div",{className:"max-w-md",children:e.jsx(xt,{value:t?`${t.provider}/${t.model}`:"",options:B,placeholder:l("modelRouting.defaultModelPlaceholder"),onChange:d=>{if(!d)c(null),q(void 0,null);else{const[k,...D]=d.split("/"),z={provider:k,model:D.join("/")};if(c(z),o.text){const J={...o};delete J.text,a(J),q(J,z)}else q(void 0,z)}}})})]}),e.jsxs("div",{className:"bg-surface-elevated rounded-xl p-5 space-y-4",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-semibold text-fg-primary",children:l("modelRouting.capabilityAssignTitle")}),e.jsx("p",{className:"text-xs text-fg-tertiary mt-1",children:l("modelRouting.capabilityAssignDesc")})]}),s.length===0&&e.jsx("div",{className:"p-3 bg-yellow-500/10 border border-yellow-500/30 rounded-lg text-xs text-yellow-400",children:l("modelRouting.noProvidersHint")}),s.length>0&&e.jsx("div",{className:"space-y-4",children:Vs.map(d=>e.jsx(La,{groupKey:d.groupKey,capabilities:d.capabilities,assignments:o,suggestions:f,allModels:B,configuredProviderNames:new Set(s.map(k=>k.name)),t:l,onAssign:(k,D)=>{const z={...o};D?z[k]=D:delete z[k],a(z),q(z)}},d.groupKey))})]}),P&&e.jsx(Fr,{variant:"primary",title:l("modelRouting.restoreRecommended"),message:l("modelRouting.restoreConfirm"),confirmLabel:l("common:confirm"),onConfirm:()=>{O(!1),de()},onCancel:()=>O(!1)})]}):e.jsx("div",{className:"space-y-4",children:e.jsxs("div",{className:"bg-surface-elevated rounded-xl p-5 animate-pulse",children:[e.jsx("div",{className:"h-4 bg-surface-overlay rounded w-1/3 mb-3"}),e.jsx("div",{className:"h-3 bg-surface-overlay rounded w-2/3 mb-4"}),e.jsx("div",{className:"space-y-2",children:[1,2,3,4,5].map(d=>e.jsx("div",{className:"h-10 bg-surface-overlay rounded-lg"},d))})]})})}function La({groupKey:r,capabilities:s,assignments:l,suggestions:o,allModels:a,configuredProviderNames:t,t:c,onAssign:u}){return e.jsxs("div",{children:[e.jsx("div",{className:"text-[10px] font-semibold text-fg-tertiary uppercase tracking-wider mb-2 px-1",children:c(`modelRouting.capabilityGroups.${r}`)}),e.jsx("div",{className:"space-y-1",children:s.map(x=>{const h=l[x],y=o[x],A=h?`${h.provider}/${h.model}`:"",g=Rn(a,x),C=y?g.find(v=>v.provider===y.provider&&v.modelId===y.model)?.modelName??y.model:void 0,N=g.length>0,b=h?Ia(a,h.provider,h.model):void 0,S=h&&!t.has(h.provider),f=!!(h&&N&&x!=="text"&&!g.some(v=>v.provider===h.provider&&v.modelId===h.model));return e.jsxs("div",{className:`flex items-center gap-3 px-3 py-2 rounded-lg ${f?"bg-red-500/10 border border-red-500/30":S?"bg-yellow-500/10 border border-yellow-500/30":!N&&!h?"bg-amber-500/5 border border-amber-500/20":"bg-surface-overlay/40"}`,children:[e.jsx("div",{className:"w-28 shrink-0",children:e.jsx("span",{className:"text-xs text-fg-primary",children:c(`modelRouting.capabilities.${x}`)})}),e.jsx("div",{className:"flex-1 min-w-0",children:f?e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsxs("span",{className:"text-xs text-red-400",children:["⚠ ",h.model]}),e.jsx("span",{className:"text-[10px] text-red-400/70",children:c("modelRouting.mismatchHint")})]}),e.jsx(xt,{value:"",options:g,placeholder:c("modelRouting.selectModel"),onChange:v=>{if(!v)u(x,null);else{const[m,...w]=v.split("/");u(x,{provider:m,model:w.join("/")})}}})]}):N?e.jsx(xt,{value:A,options:g,placeholder:C?`${C} (${c("modelRouting.suggested")})`:c("modelRouting.selectModel"),onChange:v=>{if(!v)u(x,null);else{const[m,...w]=v.split("/");u(x,{provider:m,model:w.join("/")})}}}):e.jsxs("span",{className:"text-xs text-amber-400",children:[c("modelRouting.noModelAvailable"),e.jsxs("span",{className:"text-fg-tertiary ml-1",children:["— ",c("modelRouting.addProviderHint")]})]})}),e.jsxs("div",{className:"w-14 shrink-0 flex justify-end",children:[f&&e.jsx("span",{className:"text-[10px] text-red-400 font-medium",title:c("modelRouting.mismatchHint"),children:"⚠"}),!f&&S&&e.jsx("span",{className:"text-[10px] text-yellow-400 font-medium",title:c("modelRouting.staleProvider"),children:"⚠"}),!f&&!S&&b&&e.jsx(Ks,{tier:b}),!f&&!S&&!b&&h&&e.jsx(Ks,{tier:"unknown"})]}),e.jsx("div",{className:"w-8 shrink-0 flex justify-end",children:h&&e.jsx("button",{onClick:()=>u(x,null),className:"text-fg-tertiary hover:text-red-400 transition-colors",title:c("modelRouting.clear"),children:e.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})})]},x)})})]})}function Ia(r,s,l){return r.find(a=>a.provider===s&&a.modelId===l)?.tier}function Ra({status:r,t:s}){if(r==="idle")return null;const l={idle:"",saving:"text-fg-tertiary",saved:"text-green-400",error:"text-red-400"},o={idle:"",saving:s("modelRouting.saving"),saved:s("modelRouting.saved"),error:s("modelRouting.saveError")};return e.jsx("div",{className:`text-xs font-medium transition-opacity ${l[r]}`,children:o[r]})}function Ks({tier:r}){const s={max:"bg-purple-500/20 text-purple-400 border-purple-500/30",pro:"bg-blue-500/20 text-blue-400 border-blue-500/30",base:"bg-gray-500/20 text-gray-400 border-gray-500/30",unknown:"bg-gray-500/10 text-fg-tertiary border-border-default"};return e.jsx("span",{className:`px-1.5 py-0.5 text-[9px] rounded font-semibold uppercase border ${s[r]??s.unknown}`,children:r==="unknown"?"—":r})}function Rn(r,s){if(s==="text")return r.filter(c=>Ca(c));const l={image_generation:["image_generation"],audio_tts:["audio_speech"],audio_stt:["audio_transcription"],video_generation:["video_generation"]},o={image_recognition:["vision"],image_generation:["imageGeneration"],audio_tts:["tts"],audio_stt:["stt"],video_generation:["videoGeneration"]},a=l[s],t=o[s];return r.filter(c=>!!(c.capabilities&&c.capabilities.length>0&&t&&t.some(u=>c.capabilities.includes(u))||a&&c.mode&&a.includes(c.mode)))}function Ba({configuredProviders:r}){const{t:s}=ye("settings"),[l,o]=i.useState(null),[a,t]=i.useState([]),[c,u]=i.useState(null),[x,h]=i.useState(null),y=i.useMemo(()=>r.map(b=>`${b.name}:${b.models?.length??0}`).sort().join(","),[r]),A=i.useCallback(async()=>{u(null);try{const[{agents:b},S]=await Promise.all([V.agents.list(),V.teams.list()]),f=S.teams.map(m=>({id:m.id,name:m.name}));t(f);const v=await Promise.all(b.map(async m=>{try{const R=(await V.agents.get(m.id)).config?.llmConfig;return{id:m.id,name:m.name||m.id,teamId:m.teamId,override:R?.modelMode==="custom"&&R.primary&&R.defaultModel?`${R.primary}/${R.defaultModel}`:null,llmConfig:{modelMode:R?.modelMode,primary:R?.primary??"",defaultModel:R?.defaultModel}}}catch{return{id:m.id,name:m.name||m.id,teamId:m.teamId,override:null,llmConfig:{modelMode:"default",primary:"",defaultModel:void 0}}}}));o(b.length?v:null)}catch(b){u(String(b))}},[y]);i.useEffect(()=>{A()},[A,y]);const g=i.useMemo(()=>{const b=[];for(const S of r)for(const f of S.models??[])b.push({provider:S.name,providerLabel:S.displayName??S.name,modelId:f.id,modelName:f.name??f.id});return b},[r]),C=async(b,S)=>{h(b),u(null);try{if(S){const[f,v]=[S.slice(0,S.lastIndexOf("/")),S.slice(S.lastIndexOf("/")+1)];await V.agents.updateConfig(b,{llmConfig:{modelMode:"custom",primary:f,defaultModel:v}})}else await V.agents.updateConfig(b,{llmConfig:{modelMode:"default",primary:"",defaultModel:void 0}});o(f=>f?.map(v=>v.id===b?{...v,override:S}:v)??f)}catch(f){u(String(f))}finally{h(null)}},N=i.useMemo(()=>{if(!l)return[];const b=new Map,S=[];for(const v of l)if(v.teamId){const m=b.get(v.teamId)??[];m.push(v),b.set(v.teamId,m)}else S.push(v);const f=[];S.length&&f.push({key:"ungrouped",label:s("perAgentModel.ungrouped",{defaultValue:"Ungrouped"}),rows:S});for(const v of a){const m=b.get(v.id);m?.length&&f.push({key:`team:${v.id}`,label:v.name,rows:m})}for(const[v,m]of b)a.some(w=>w.id===v)||f.push({key:`team:${v}`,label:v,rows:m});return f},[l,a,s]);return l===null&&!c?e.jsx("div",{className:"bg-surface-elevated rounded-xl p-5 text-sm text-fg-tertiary",children:s("common:loading",{defaultValue:"Loading…"})}):e.jsxs("div",{className:"bg-surface-elevated rounded-xl p-5 space-y-4",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium",children:s("perAgentModel.title",{defaultValue:"Per-agent default model"})}),e.jsx("div",{className:"text-xs text-fg-tertiary mt-0.5",children:s("perAgentModel.desc",{defaultValue:'Bind a specific provider+model to an agent, or leave it following the global default. This is what the composer "Apply to current agent" writes.'})})]})}),c&&e.jsx("div",{className:"text-xs text-red-500",children:c}),(!l||l.length===0)&&!c&&e.jsx("div",{className:"text-xs text-fg-tertiary",children:s("perAgentModel.noAgents",{defaultValue:"No agents available."})}),l&&l.length>0&&e.jsx("div",{className:"space-y-5",children:N.map(b=>e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wider text-fg-tertiary truncate",children:b.label}),e.jsx("span",{className:"text-[10px] text-fg-tertiary/70 tabular-nums shrink-0",children:b.rows.length})]}),e.jsx("div",{className:"space-y-2",children:b.rows.map(S=>e.jsxs("div",{className:"flex items-center justify-between gap-3 text-sm",children:[e.jsxs("div",{className:"flex-1 truncate",children:[e.jsx("span",{className:"font-medium",children:S.name}),e.jsx("span",{className:"text-xs text-fg-tertiary ml-2 truncate",children:S.id})]}),e.jsxs("div",{className:"flex items-center gap-2 w-[320px]",children:[S.override?e.jsxs(e.Fragment,{children:[e.jsx(xt,{value:S.override,options:g,placeholder:s("perAgentModel.followGlobal",{defaultValue:"Follow global"}),onChange:f=>{C(S.id,f||null)}}),e.jsx("button",{type:"button",disabled:x===S.id,onClick:()=>{C(S.id,null)},className:"shrink-0 px-2.5 py-1.5 text-xs border border-border-default rounded-lg hover:bg-surface-base disabled:opacity-40 transition-colors",children:s("perAgentModel.reset",{defaultValue:"Reset"})})]}):e.jsx(xt,{value:"",options:g,placeholder:s("perAgentModel.followGlobal",{defaultValue:"Follow global"}),onChange:f=>{C(S.id,f||null)}}),x===S.id&&e.jsx("span",{className:"shrink-0 text-[10px] text-fg-tertiary",children:s("common:loading",{defaultValue:"…"})})]})]},S.id))})]},b.key))})]})}let Tt=[],Mt=null;async function Oa(){return Mt||(Mt=(async()=>{try{Tt=(await V.modelCatalog.providerCatalog()).providers??[]}catch{Tt=[]}return Tt})(),Mt)}function Da(){const[r,s]=i.useState(Tt);return i.useEffect(()=>{let l=!0;return Oa().then(o=>{l&&s(o)}),()=>{l=!1}},[]),r}var Ze={},ur,zs;function Fa(){return zs||(zs=1,ur=function(){return typeof Promise=="function"&&Promise.prototype&&Promise.prototype.then}),ur}var xr={},Fe={},Hs;function Ke(){if(Hs)return Fe;Hs=1;let r;const s=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];return Fe.getSymbolSize=function(o){if(!o)throw new Error('"version" cannot be null or undefined');if(o<1||o>40)throw new Error('"version" should be in range from 1 to 40');return o*4+17},Fe.getSymbolTotalCodewords=function(o){return s[o]},Fe.getBCHDigit=function(l){let o=0;for(;l!==0;)o++,l>>>=1;return o},Fe.setToSJISFunction=function(o){if(typeof o!="function")throw new Error('"toSJISFunc" is not a valid function.');r=o},Fe.isKanjiModeEnabled=function(){return typeof r<"u"},Fe.toSJIS=function(o){return r(o)},Fe}var mr={},qs;function Ur(){return qs||(qs=1,(function(r){r.L={bit:1},r.M={bit:0},r.Q={bit:3},r.H={bit:2};function s(l){if(typeof l!="string")throw new Error("Param is not a string");switch(l.toLowerCase()){case"l":case"low":return r.L;case"m":case"medium":return r.M;case"q":case"quartile":return r.Q;case"h":case"high":return r.H;default:throw new Error("Unknown EC Level: "+l)}}r.isValid=function(o){return o&&typeof o.bit<"u"&&o.bit>=0&&o.bit<4},r.from=function(o,a){if(r.isValid(o))return o;try{return s(o)}catch{return a}}})(mr)),mr}var fr,Ws;function _a(){if(Ws)return fr;Ws=1;function r(){this.buffer=[],this.length=0}return r.prototype={get:function(s){const l=Math.floor(s/8);return(this.buffer[l]>>>7-s%8&1)===1},put:function(s,l){for(let o=0;o<l;o++)this.putBit((s>>>l-o-1&1)===1)},getLengthInBits:function(){return this.length},putBit:function(s){const l=Math.floor(this.length/8);this.buffer.length<=l&&this.buffer.push(0),s&&(this.buffer[l]|=128>>>this.length%8),this.length++}},fr=r,fr}var gr,Js;function Ua(){if(Js)return gr;Js=1;function r(s){if(!s||s<1)throw new Error("BitMatrix size must be defined and greater than 0");this.size=s,this.data=new Uint8Array(s*s),this.reservedBit=new Uint8Array(s*s)}return r.prototype.set=function(s,l,o,a){const t=s*this.size+l;this.data[t]=o,a&&(this.reservedBit[t]=!0)},r.prototype.get=function(s,l){return this.data[s*this.size+l]},r.prototype.xor=function(s,l,o){this.data[s*this.size+l]^=o},r.prototype.isReserved=function(s,l){return this.reservedBit[s*this.size+l]},gr=r,gr}var pr={},Gs;function $a(){return Gs||(Gs=1,(function(r){const s=Ke().getSymbolSize;r.getRowColCoords=function(o){if(o===1)return[];const a=Math.floor(o/7)+2,t=s(o),c=t===145?26:Math.ceil((t-13)/(2*a-2))*2,u=[t-7];for(let x=1;x<a-1;x++)u[x]=u[x-1]-c;return u.push(6),u.reverse()},r.getPositions=function(o){const a=[],t=r.getRowColCoords(o),c=t.length;for(let u=0;u<c;u++)for(let x=0;x<c;x++)u===0&&x===0||u===0&&x===c-1||u===c-1&&x===0||a.push([t[u],t[x]]);return a}})(pr)),pr}var hr={},Qs;function Va(){if(Qs)return hr;Qs=1;const r=Ke().getSymbolSize,s=7;return hr.getPositions=function(o){const a=r(o);return[[0,0],[a-s,0],[0,a-s]]},hr}var br={},Ys;function Ka(){return Ys||(Ys=1,(function(r){r.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};const s={N1:3,N2:3,N3:40,N4:10};r.isValid=function(a){return a!=null&&a!==""&&!isNaN(a)&&a>=0&&a<=7},r.from=function(a){return r.isValid(a)?parseInt(a,10):void 0},r.getPenaltyN1=function(a){const t=a.size;let c=0,u=0,x=0,h=null,y=null;for(let A=0;A<t;A++){u=x=0,h=y=null;for(let g=0;g<t;g++){let C=a.get(A,g);C===h?u++:(u>=5&&(c+=s.N1+(u-5)),h=C,u=1),C=a.get(g,A),C===y?x++:(x>=5&&(c+=s.N1+(x-5)),y=C,x=1)}u>=5&&(c+=s.N1+(u-5)),x>=5&&(c+=s.N1+(x-5))}return c},r.getPenaltyN2=function(a){const t=a.size;let c=0;for(let u=0;u<t-1;u++)for(let x=0;x<t-1;x++){const h=a.get(u,x)+a.get(u,x+1)+a.get(u+1,x)+a.get(u+1,x+1);(h===4||h===0)&&c++}return c*s.N2},r.getPenaltyN3=function(a){const t=a.size;let c=0,u=0,x=0;for(let h=0;h<t;h++){u=x=0;for(let y=0;y<t;y++)u=u<<1&2047|a.get(h,y),y>=10&&(u===1488||u===93)&&c++,x=x<<1&2047|a.get(y,h),y>=10&&(x===1488||x===93)&&c++}return c*s.N3},r.getPenaltyN4=function(a){let t=0;const c=a.data.length;for(let x=0;x<c;x++)t+=a.data[x];return Math.abs(Math.ceil(t*100/c/5)-10)*s.N4};function l(o,a,t){switch(o){case r.Patterns.PATTERN000:return(a+t)%2===0;case r.Patterns.PATTERN001:return a%2===0;case r.Patterns.PATTERN010:return t%3===0;case r.Patterns.PATTERN011:return(a+t)%3===0;case r.Patterns.PATTERN100:return(Math.floor(a/2)+Math.floor(t/3))%2===0;case r.Patterns.PATTERN101:return a*t%2+a*t%3===0;case r.Patterns.PATTERN110:return(a*t%2+a*t%3)%2===0;case r.Patterns.PATTERN111:return(a*t%3+(a+t)%2)%2===0;default:throw new Error("bad maskPattern:"+o)}}r.applyMask=function(a,t){const c=t.size;for(let u=0;u<c;u++)for(let x=0;x<c;x++)t.isReserved(x,u)||t.xor(x,u,l(a,x,u))},r.getBestMask=function(a,t){const c=Object.keys(r.Patterns).length;let u=0,x=1/0;for(let h=0;h<c;h++){t(h),r.applyMask(h,a);const y=r.getPenaltyN1(a)+r.getPenaltyN2(a)+r.getPenaltyN3(a)+r.getPenaltyN4(a);r.applyMask(h,a),y<x&&(x=y,u=h)}return u}})(br)),br}var At={},Zs;function Bn(){if(Zs)return At;Zs=1;const r=Ur(),s=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],l=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];return At.getBlocksCount=function(a,t){switch(t){case r.L:return s[(a-1)*4+0];case r.M:return s[(a-1)*4+1];case r.Q:return s[(a-1)*4+2];case r.H:return s[(a-1)*4+3];default:return}},At.getTotalCodewordsCount=function(a,t){switch(t){case r.L:return l[(a-1)*4+0];case r.M:return l[(a-1)*4+1];case r.Q:return l[(a-1)*4+2];case r.H:return l[(a-1)*4+3];default:return}},At}var yr={},dt={},Xs;function za(){if(Xs)return dt;Xs=1;const r=new Uint8Array(512),s=new Uint8Array(256);return(function(){let o=1;for(let a=0;a<255;a++)r[a]=o,s[o]=a,o<<=1,o&256&&(o^=285);for(let a=255;a<512;a++)r[a]=r[a-255]})(),dt.log=function(o){if(o<1)throw new Error("log("+o+")");return s[o]},dt.exp=function(o){return r[o]},dt.mul=function(o,a){return o===0||a===0?0:r[s[o]+s[a]]},dt}var en;function Ha(){return en||(en=1,(function(r){const s=za();r.mul=function(o,a){const t=new Uint8Array(o.length+a.length-1);for(let c=0;c<o.length;c++)for(let u=0;u<a.length;u++)t[c+u]^=s.mul(o[c],a[u]);return t},r.mod=function(o,a){let t=new Uint8Array(o);for(;t.length-a.length>=0;){const c=t[0];for(let x=0;x<a.length;x++)t[x]^=s.mul(a[x],c);let u=0;for(;u<t.length&&t[u]===0;)u++;t=t.slice(u)}return t},r.generateECPolynomial=function(o){let a=new Uint8Array([1]);for(let t=0;t<o;t++)a=r.mul(a,new Uint8Array([1,s.exp(t)]));return a}})(yr)),yr}var vr,tn;function qa(){if(tn)return vr;tn=1;const r=Ha();function s(l){this.genPoly=void 0,this.degree=l,this.degree&&this.initialize(this.degree)}return s.prototype.initialize=function(o){this.degree=o,this.genPoly=r.generateECPolynomial(this.degree)},s.prototype.encode=function(o){if(!this.genPoly)throw new Error("Encoder not initialized");const a=new Uint8Array(o.length+this.degree);a.set(o);const t=r.mod(a,this.genPoly),c=this.degree-t.length;if(c>0){const u=new Uint8Array(this.degree);return u.set(t,c),u}return t},vr=s,vr}var jr={},wr={},Nr={},rn;function On(){return rn||(rn=1,Nr.isValid=function(s){return!isNaN(s)&&s>=1&&s<=40}),Nr}var Me={},sn;function Dn(){if(sn)return Me;sn=1;const r="[0-9]+",s="[A-Z $%*+\\-./:]+";let l="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";l=l.replace(/u/g,"\\u");const o="(?:(?![A-Z0-9 $%*+\\-./:]|"+l+`)(?:.|[\r
|
|
1
|
+
import{u as ye,r as i,j as e,F as Fr,l as V,x as pa,k as ha,a as ba,b as ya,c as va,Z as Fs,n as lr,$ as ja,a0 as _s,P as Us,h as Ve,i as wa,a1 as Ln,w as Na,o as dr,t as _r,_ as ka}from"./index-1X1Ykov8.js";import{i as Ca}from"./modelCapabilities-DDtCBZ6o.js";function Sa(r,s){for(var l=0;l<s.length;l++){const o=s[l];if(typeof o!="string"&&!Array.isArray(o)){for(const a in o)if(a!=="default"&&!(a in r)){const t=Object.getOwnPropertyDescriptor(o,a);t&&Object.defineProperty(r,a,t.get?t:{enumerable:!0,get:()=>o[a]})}}}return Object.freeze(Object.defineProperty(r,Symbol.toStringTag,{value:"Module"}))}function Pa(r){return r>=1e6?`${(r/1e6).toFixed(r%1e6===0?0:1)}M`:r>=1e3?`${(r/1e3).toFixed((r%1e3===0,0))}K`:String(r)}function Ma(r){return r.maxInputTokens>0||r.inputCostPer1MTokens>0||r.outputCostPer1MTokens>0}function cr(r){if(r.tier)return r.tier;const s=r.id.toLowerCase(),l=/opus|5\.4|o3-(?!mini)|o1-(?!mini)|gemini.*ultra|sonnet-4-20/,o=/haiku|flash|nano|lite|small|fast|free|8b|7b|1b|3b/;return/o4-mini|o3-mini|o1-mini|gpt-4o-mini/.test(s)?"pro":l.test(s)?"max":o.test(s)?"base":"pro"}const $s={max:"bg-purple-500/20 text-purple-400 border-purple-500/30",pro:"bg-blue-500/20 text-blue-400 border-blue-500/30",base:"bg-gray-500/20 text-gray-400 border-gray-500/30"};function In({models:r,selectedModel:s,onSelect:l,loading:o,compact:a,maxVisible:t,showTiers:c}){const{t:u}=ye("settings"),[x,h]=i.useState(""),[y,A]=i.useState(!1),[g,C]=i.useState(""),N=i.useMemo(()=>{let m=r;if(x){const w=x.toLowerCase();m=m.filter(R=>R.id.toLowerCase().includes(w))}return g&&(m=m.filter(w=>cr(w)===g)),m},[r,x,g]),b=i.useMemo(()=>{const m={max:0,pro:0,base:0};for(const w of r)m[cr(w)]++;return m},[r]),S=t??(a?5:10),f=y?N:N.slice(0,S),v=N.length>S;return o?e.jsxs("div",{className:"flex items-center gap-2 py-4 text-sm text-fg-tertiary",children:[e.jsx("div",{className:"w-4 h-4 border-2 border-brand-500 border-t-transparent rounded-full animate-spin"}),u("modelPicker.loading")]}):r.length===0?e.jsx("div",{className:"py-3 text-sm text-fg-tertiary",children:u("modelPicker.empty")}):e.jsxs("div",{className:"space-y-2",children:[c&&r.length>3&&e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("button",{onClick:()=>C(""),className:`px-2 py-0.5 rounded text-[10px] transition-colors ${g?"bg-surface-overlay text-fg-tertiary hover:text-fg-secondary":"bg-brand-500/20 text-brand-500"}`,children:u("modelPicker.allCount",{count:r.length})}),["max","pro","base"].filter(m=>b[m]>0).map(m=>e.jsx("button",{onClick:()=>C(g===m?"":m),className:`px-2 py-0.5 rounded text-[10px] font-medium uppercase transition-colors border ${g===m?$s[m]:"border-transparent bg-surface-overlay text-fg-tertiary hover:text-fg-secondary"}`,children:u("modelPicker.tierCount",{tier:u(`modelRouting.tier.${m}`),count:b[m]})},m))]}),r.length>5&&e.jsx("input",{type:"text",value:x,onChange:m=>{h(m.target.value),A(!1)},placeholder:u("modelPicker.filterPlaceholder"),className:"w-full px-3 py-1.5 bg-surface-overlay border border-border-default rounded-lg text-xs text-fg-primary placeholder:text-fg-tertiary focus:outline-none focus:border-brand-500"}),e.jsx("div",{className:`space-y-1 ${a?"max-h-[280px] overflow-y-auto":""}`,children:f.map(m=>{const w=m.id===s,R=cr(m);return e.jsxs("button",{type:"button",onClick:()=>l(m.id),className:`w-full text-left px-3 py-2 rounded-lg transition-colors ${w?"bg-brand-500/10 border border-brand-500/30":"hover:bg-surface-overlay border border-transparent"}`,children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:`w-3 h-3 rounded-full border-2 flex items-center justify-center ${w?"border-brand-500":"border-border-default"}`,children:w&&e.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-brand-500"})}),e.jsx("span",{className:`text-xs font-medium ${w?"text-brand-500":"text-fg-primary"}`,children:m.id}),c&&e.jsx("span",{className:`px-1.5 py-0.5 rounded text-[9px] font-semibold uppercase border ${$s[R]}`,children:u(`modelRouting.tier.${R}`)})]}),e.jsx("div",{className:"flex items-center gap-2",children:w&&e.jsx("span",{className:"text-[10px] text-brand-500 font-medium",children:u("modelPicker.active")})})]}),Ma(m)&&m.maxInputTokens>0&&e.jsx("div",{className:"ml-5 mt-0.5 flex items-center gap-2 text-[10px] text-fg-tertiary flex-wrap",children:e.jsxs("span",{children:[Pa(m.maxInputTokens)," ",u("modelPicker.ctx")]})}),!a&&e.jsxs("div",{className:"ml-5 mt-1 flex items-center gap-1.5 flex-wrap",children:[m.capabilities.functionCalling&&e.jsx(lt,{label:u("modelPicker.capabilities.tools")}),m.capabilities.vision&&e.jsx(lt,{label:u("modelPicker.capabilities.vision")}),m.capabilities.reasoning&&e.jsx(lt,{label:u("modelPicker.capabilities.reasoning")}),m.capabilities.promptCaching&&e.jsx(lt,{label:u("modelPicker.capabilities.caching")}),m.capabilities.webSearch&&e.jsx(lt,{label:u("modelPicker.capabilities.search")})]})]},m.id)})}),v&&!y&&e.jsx("button",{type:"button",onClick:()=>A(!0),className:"text-xs text-brand-500 hover:text-brand-400 px-3",children:u("modelPicker.showAll",{count:N.length})}),y&&v&&e.jsx("button",{type:"button",onClick:()=>A(!1),className:"text-xs text-fg-tertiary hover:text-fg-secondary px-3",children:u("modelPicker.showLess")})]})}function lt({label:r}){return e.jsx("span",{className:"px-1.5 py-0.5 rounded text-[9px] bg-surface-overlay text-fg-tertiary border border-border-default",children:r})}function xt({value:r,options:s,placeholder:l,onChange:o}){const{t:a}=ye("settings"),[t,c]=i.useState(!1),[u,x]=i.useState(""),h=i.useRef(null),y=i.useRef(null),A=i.useRef(null),[g,C]=i.useState(-1);i.useEffect(()=>{function m(w){h.current&&!h.current.contains(w.target)&&c(!1)}return document.addEventListener("mousedown",m),()=>document.removeEventListener("mousedown",m)},[]),i.useEffect(()=>{t&&y.current&&y.current.focus()},[t]);const N=i.useMemo(()=>{if(!u.trim())return s;const m=u.toLowerCase();return s.filter(w=>w.modelId.toLowerCase().includes(m)||w.modelName.toLowerCase().includes(m)||w.provider.toLowerCase().includes(m)||w.providerLabel.toLowerCase().includes(m)||w.tier&&w.tier.toLowerCase().includes(m))},[s,u]),b=i.useMemo(()=>{const m=new Map;for(const R of N){const I=R.providerLabel;m.has(I)||m.set(I,[]),m.get(I).push(R)}const w={max:0,pro:1,base:2};for(const R of m.values())R.sort((I,F)=>(w[I.tier??"base"]??9)-(w[F.tier??"base"]??9));return m},[N]),S=i.useMemo(()=>{const m=[];for(const w of b.values())m.push(...w);return m},[b]),f=i.useMemo(()=>{if(!r)return l??a("modelRouting.auto");const m=s.find(w=>`${w.provider}/${w.modelId}`===r);return m?`${m.providerLabel}/${m.modelName}`:r},[r,s,l,a]);function v(m){if(!t){(m.key==="Enter"||m.key===" ")&&(m.preventDefault(),c(!0));return}switch(m.key){case"ArrowDown":m.preventDefault(),C(w=>Math.min(w+1,S.length-1));break;case"ArrowUp":m.preventDefault(),C(w=>Math.max(w-1,-1));break;case"Enter":m.preventDefault(),g===-1?o(""):S[g]&&o(`${S[g].provider}/${S[g].modelId}`),c(!1),x("");break;case"Escape":c(!1),x("");break}}return i.useEffect(()=>{A.current&&g>=0&&A.current.querySelector(`[data-focus-index="${g}"]`)?.scrollIntoView({block:"nearest"})},[g]),e.jsxs("div",{ref:h,className:"relative",onKeyDown:v,children:[e.jsx("button",{type:"button",onClick:()=>{c(!t),x(""),C(-1)},className:"w-full px-2 py-1 bg-surface-overlay border border-border-default rounded text-xs text-fg-primary text-left truncate focus:outline-none focus:border-brand-500",children:f}),t&&e.jsxs("div",{className:"absolute z-50 mt-1 w-full min-w-[240px] max-h-[280px] bg-surface-elevated border border-border-default rounded-lg shadow-xl overflow-hidden flex flex-col",children:[e.jsx("div",{className:"p-1.5 border-b border-border-default",children:e.jsx("input",{ref:y,type:"text",value:u,onChange:m=>{x(m.target.value),C(-1)},placeholder:a("modelPicker.searchPlaceholder")||"Search models...",className:"w-full px-2 py-1 bg-surface-overlay border border-border-default rounded text-xs text-fg-primary focus:outline-none focus:border-brand-500"})}),e.jsxs("div",{ref:A,className:"overflow-y-auto flex-1",children:[e.jsx("div",{className:`px-3 py-1.5 text-xs cursor-pointer ${g===-1?"bg-brand-500/20 text-brand-500":"text-fg-secondary hover:bg-surface-overlay"}`,onClick:()=>{o(""),c(!1),x("")},children:l??a("modelRouting.auto")}),[...b.entries()].map(([m,w])=>e.jsxs("div",{children:[e.jsx("div",{className:"px-3 py-1 text-[10px] font-semibold text-fg-tertiary uppercase tracking-wider bg-surface-overlay/50 sticky top-0",children:m}),w.map(R=>{const I=S.indexOf(R),F=`${R.provider}/${R.modelId}`===r;return e.jsxs("div",{"data-focus-index":I,className:`px-3 py-1.5 text-xs cursor-pointer flex items-center gap-2 ${I===g?"bg-brand-500/20":F?"bg-surface-overlay":"hover:bg-surface-overlay/50"}`,onClick:()=>{o(`${R.provider}/${R.modelId}`),c(!1),x("")},children:[e.jsx("span",{className:"flex-1 truncate text-fg-primary",children:R.modelName}),R.tier&&e.jsx(Aa,{tier:R.tier}),R.costTier&&e.jsx("span",{className:"text-[9px] text-fg-tertiary",children:R.costTier})]},`${R.provider}/${R.modelId}`)})]},m)),S.length===0&&e.jsx("div",{className:"px-3 py-3 text-xs text-fg-tertiary text-center",children:a("modelPicker.empty")})]})]})]})}function Aa({tier:r}){const s={max:"bg-purple-500/20 text-purple-400",pro:"bg-blue-500/20 text-blue-400",base:"bg-gray-500/20 text-gray-400"};return e.jsx("span",{className:`px-1 py-0.5 rounded text-[8px] font-bold uppercase ${s[r]??s.base}`,children:r})}const Ea=500,Vs=[{groupKey:"image",capabilities:["image_recognition","image_generation"]},{groupKey:"audio",capabilities:["audio_tts","audio_stt"]},{groupKey:"video",capabilities:["video_generation"]}];function Ta({onSave:r,configuredProviders:s}){const{t:l}=ye(["settings","common"]),[o,a]=i.useState({}),[t,c]=i.useState(null),[u,x]=i.useState(!1),[h,y]=i.useState(null),[A,g]=i.useState(!0),[C,N]=i.useState("idle"),[b,S]=i.useState(null),[f,v]=i.useState({}),[m,w]=i.useState(!1),[R,I]=i.useState("idle"),[F,$]=i.useState(null),[P,O]=i.useState(!1),L=i.useRef(null),U=i.useRef(null),_=i.useMemo(()=>s.map(d=>d.name).sort().join(","),[s]);i.useEffect(()=>{fetch("/api/settings/llm/routing",{credentials:"include"}).then(d=>{if(!d.ok)throw new Error(`HTTP ${d.status}`);return d.json()}).then(d=>{a(d.capabilityRouting?.assignments??{}),c(d.routingDefaultModel??null),x(!0)}).catch(d=>{y(String(d)),x(!0)})},[_]),i.useEffect(()=>{let d=!1;return g(!0),fetch("/api/models/routing-candidates",{credentials:"include"}).then(k=>{if(!k.ok)throw new Error(`HTTP ${k.status}`);return k.json()}).then(k=>{if(d)return;const D=[];for(const z of k.providers)for(const J of z.models)D.push({provider:z.provider,providerLabel:z.displayName,modelId:J.id,modelName:J.name,mode:J.mode,tier:J.tier,costTier:J.costTier,capabilities:J.capabilities});S(D)}).catch(()=>{d||S(null)}).finally(()=>{d||g(!1)}),()=>{d=!0}},[_]),i.useEffect(()=>{fetch("/api/models/suggested-assignments",{credentials:"include"}).then(d=>{if(!d.ok)throw new Error(`HTTP ${d.status}`);return d.json()}).then(d=>{v(d.suggestions),w(!0)}).catch(()=>w(!0))},[_]);const K=i.useCallback(d=>{N("saving"),r(d).then(()=>{N("saved"),setTimeout(()=>N(k=>k==="saved"?"idle":k),2e3)}).catch(()=>{N("error"),setTimeout(()=>N(k=>k==="error"?"idle":k),3e3)})},[r]),q=i.useCallback((d,k)=>{U.current={capabilityRouting:d!==void 0?{assignments:d}:U.current?.capabilityRouting,routingDefaultModel:k!==void 0?k:U.current?.routingDefaultModel},L.current&&clearTimeout(L.current),L.current=setTimeout(()=>{const D=U.current;U.current=null,D&&K(D)},Ea)},[K]),T=i.useMemo(()=>s.flatMap(d=>(d.models??[{id:d.model,name:d.model}]).map(k=>({provider:d.name,providerLabel:d.displayName??d.name,modelId:k.id,modelName:k.name}))),[s]),B=b??T,ee=i.useMemo(()=>Object.entries(o).map(([d,k])=>`${d}:${k?.provider??""}/${k?.model??""}`).sort().join("|"),[o]);i.useEffect(()=>{!u||!b||b.length===0||b.some(d=>!!d.modelId)&&(a(d=>{let k=!1;const D={...d};for(const z of Vs)for(const J of z.capabilities){const re=D[J];if(!re?.model)continue;const Z=Rn(b,J);if(Z.length===0)continue;Z.some(Ne=>Ne.provider===re.provider&&Ne.modelId===re.model)||(delete D[J],k=!0)}return k?(q(D),D):d}),c(d=>{if(!d?.model||b.some(J=>J.provider===d.provider&&J.modelId===d.model))return d;const D=b.find(J=>J.provider==="markus"),z=D?{provider:D.provider,model:D.modelId}:{provider:b[0].provider,model:b[0].modelId};return r({routingDefaultModel:z}),z}))},[u,b,_,q,ee]);const ie=i.useCallback(()=>{fetch("/api/settings/llm/routing",{credentials:"include"}).then(d=>{if(!d.ok)throw new Error(`HTTP ${d.status}`);return d.json()}).then(d=>{a(d.capabilityRouting?.assignments??{}),c(d.routingDefaultModel??null)}).catch(()=>{}),g(!0),fetch("/api/models/routing-candidates",{credentials:"include"}).then(d=>{if(!d.ok)throw new Error(`HTTP ${d.status}`);return d.json()}).then(d=>{const k=[];for(const D of d.providers)for(const z of D.models)k.push({provider:D.provider,providerLabel:D.displayName,modelId:z.id,modelName:z.name,mode:z.mode,tier:z.tier,costTier:z.costTier,capabilities:z.capabilities});S(k)}).catch(()=>{}).finally(()=>g(!1))},[]),de=i.useCallback(async()=>{if(R!=="working"){I("working"),$(null);try{const d=await fetch("/api/settings/llm/restore-recommended",{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"}}),k=await d.json().catch(()=>({}));if(!d.ok||!k.ok)throw new Error(k.error??`HTTP ${d.status}`);k.capabilityRouting&&a(k.capabilityRouting.assignments??{}),k.routingDefaultModel!==void 0&&c(k.routingDefaultModel),ie(),I("idle"),N("saved"),setTimeout(()=>N(D=>D==="saved"?"idle":D),2e3)}catch(d){I("error"),$(d instanceof Error?d.message:String(d)),setTimeout(()=>I("idle"),4e3)}}},[R,ie]),se=B.length>0;return u?h?e.jsx("div",{className:"bg-red-500/10 border border-red-500/30 rounded-xl p-4 text-xs text-red-400",children:l("modelRouting.loadError",{error:h})}):A&&!se?e.jsx("div",{className:"space-y-4",children:e.jsx("div",{className:"bg-surface-elevated rounded-xl p-5",children:e.jsxs("div",{className:"flex items-center gap-2 text-xs text-fg-secondary",children:[e.jsxs("svg",{className:"w-4 h-4 animate-spin text-brand-500",fill:"none",viewBox:"0 0 24 24",children:[e.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),e.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8v4a4 4 0 00-4 4H4z"})]}),e.jsx("span",{children:l("modelRouting.loadingModels")})]})})}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx(Ra,{status:C,t:l}),e.jsxs("div",{className:"flex flex-col items-end gap-1",children:[e.jsx("button",{type:"button",onClick:()=>O(!0),disabled:R==="working",className:"text-xs px-3 py-1.5 rounded-lg border border-border-default text-fg-secondary hover:text-fg-primary hover:border-brand-500/40 disabled:opacity-50 transition-colors",children:l(R==="working"?"modelRouting.restoreWorking":"modelRouting.restoreRecommended")}),F&&e.jsx("span",{className:"text-[10px] text-red-400 max-w-xs text-right",children:F})]})]}),e.jsxs("div",{className:"bg-surface-elevated rounded-xl p-5 space-y-3",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-semibold text-fg-primary",children:l("modelRouting.defaultModelTitle")}),e.jsx("p",{className:"text-xs text-fg-tertiary mt-1",children:l("modelRouting.defaultModelDesc")})]}),e.jsx("div",{className:"max-w-md",children:e.jsx(xt,{value:t?`${t.provider}/${t.model}`:"",options:B,placeholder:l("modelRouting.defaultModelPlaceholder"),onChange:d=>{if(!d)c(null),q(void 0,null);else{const[k,...D]=d.split("/"),z={provider:k,model:D.join("/")};if(c(z),o.text){const J={...o};delete J.text,a(J),q(J,z)}else q(void 0,z)}}})})]}),e.jsxs("div",{className:"bg-surface-elevated rounded-xl p-5 space-y-4",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-semibold text-fg-primary",children:l("modelRouting.capabilityAssignTitle")}),e.jsx("p",{className:"text-xs text-fg-tertiary mt-1",children:l("modelRouting.capabilityAssignDesc")})]}),s.length===0&&e.jsx("div",{className:"p-3 bg-yellow-500/10 border border-yellow-500/30 rounded-lg text-xs text-yellow-400",children:l("modelRouting.noProvidersHint")}),s.length>0&&e.jsx("div",{className:"space-y-4",children:Vs.map(d=>e.jsx(La,{groupKey:d.groupKey,capabilities:d.capabilities,assignments:o,suggestions:f,allModels:B,configuredProviderNames:new Set(s.map(k=>k.name)),t:l,onAssign:(k,D)=>{const z={...o};D?z[k]=D:delete z[k],a(z),q(z)}},d.groupKey))})]}),P&&e.jsx(Fr,{variant:"primary",title:l("modelRouting.restoreRecommended"),message:l("modelRouting.restoreConfirm"),confirmLabel:l("common:confirm"),onConfirm:()=>{O(!1),de()},onCancel:()=>O(!1)})]}):e.jsx("div",{className:"space-y-4",children:e.jsxs("div",{className:"bg-surface-elevated rounded-xl p-5 animate-pulse",children:[e.jsx("div",{className:"h-4 bg-surface-overlay rounded w-1/3 mb-3"}),e.jsx("div",{className:"h-3 bg-surface-overlay rounded w-2/3 mb-4"}),e.jsx("div",{className:"space-y-2",children:[1,2,3,4,5].map(d=>e.jsx("div",{className:"h-10 bg-surface-overlay rounded-lg"},d))})]})})}function La({groupKey:r,capabilities:s,assignments:l,suggestions:o,allModels:a,configuredProviderNames:t,t:c,onAssign:u}){return e.jsxs("div",{children:[e.jsx("div",{className:"text-[10px] font-semibold text-fg-tertiary uppercase tracking-wider mb-2 px-1",children:c(`modelRouting.capabilityGroups.${r}`)}),e.jsx("div",{className:"space-y-1",children:s.map(x=>{const h=l[x],y=o[x],A=h?`${h.provider}/${h.model}`:"",g=Rn(a,x),C=y?g.find(v=>v.provider===y.provider&&v.modelId===y.model)?.modelName??y.model:void 0,N=g.length>0,b=h?Ia(a,h.provider,h.model):void 0,S=h&&!t.has(h.provider),f=!!(h&&N&&x!=="text"&&!g.some(v=>v.provider===h.provider&&v.modelId===h.model));return e.jsxs("div",{className:`flex items-center gap-3 px-3 py-2 rounded-lg ${f?"bg-red-500/10 border border-red-500/30":S?"bg-yellow-500/10 border border-yellow-500/30":!N&&!h?"bg-amber-500/5 border border-amber-500/20":"bg-surface-overlay/40"}`,children:[e.jsx("div",{className:"w-28 shrink-0",children:e.jsx("span",{className:"text-xs text-fg-primary",children:c(`modelRouting.capabilities.${x}`)})}),e.jsx("div",{className:"flex-1 min-w-0",children:f?e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsxs("span",{className:"text-xs text-red-400",children:["⚠ ",h.model]}),e.jsx("span",{className:"text-[10px] text-red-400/70",children:c("modelRouting.mismatchHint")})]}),e.jsx(xt,{value:"",options:g,placeholder:c("modelRouting.selectModel"),onChange:v=>{if(!v)u(x,null);else{const[m,...w]=v.split("/");u(x,{provider:m,model:w.join("/")})}}})]}):N?e.jsx(xt,{value:A,options:g,placeholder:C?`${C} (${c("modelRouting.suggested")})`:c("modelRouting.selectModel"),onChange:v=>{if(!v)u(x,null);else{const[m,...w]=v.split("/");u(x,{provider:m,model:w.join("/")})}}}):e.jsxs("span",{className:"text-xs text-amber-400",children:[c("modelRouting.noModelAvailable"),e.jsxs("span",{className:"text-fg-tertiary ml-1",children:["— ",c("modelRouting.addProviderHint")]})]})}),e.jsxs("div",{className:"w-14 shrink-0 flex justify-end",children:[f&&e.jsx("span",{className:"text-[10px] text-red-400 font-medium",title:c("modelRouting.mismatchHint"),children:"⚠"}),!f&&S&&e.jsx("span",{className:"text-[10px] text-yellow-400 font-medium",title:c("modelRouting.staleProvider"),children:"⚠"}),!f&&!S&&b&&e.jsx(Ks,{tier:b}),!f&&!S&&!b&&h&&e.jsx(Ks,{tier:"unknown"})]}),e.jsx("div",{className:"w-8 shrink-0 flex justify-end",children:h&&e.jsx("button",{onClick:()=>u(x,null),className:"text-fg-tertiary hover:text-red-400 transition-colors",title:c("modelRouting.clear"),children:e.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})})]},x)})})]})}function Ia(r,s,l){return r.find(a=>a.provider===s&&a.modelId===l)?.tier}function Ra({status:r,t:s}){if(r==="idle")return null;const l={idle:"",saving:"text-fg-tertiary",saved:"text-green-400",error:"text-red-400"},o={idle:"",saving:s("modelRouting.saving"),saved:s("modelRouting.saved"),error:s("modelRouting.saveError")};return e.jsx("div",{className:`text-xs font-medium transition-opacity ${l[r]}`,children:o[r]})}function Ks({tier:r}){const s={max:"bg-purple-500/20 text-purple-400 border-purple-500/30",pro:"bg-blue-500/20 text-blue-400 border-blue-500/30",base:"bg-gray-500/20 text-gray-400 border-gray-500/30",unknown:"bg-gray-500/10 text-fg-tertiary border-border-default"};return e.jsx("span",{className:`px-1.5 py-0.5 text-[9px] rounded font-semibold uppercase border ${s[r]??s.unknown}`,children:r==="unknown"?"—":r})}function Rn(r,s){if(s==="text")return r.filter(c=>Ca(c));const l={image_generation:["image_generation"],audio_tts:["audio_speech"],audio_stt:["audio_transcription"],video_generation:["video_generation"]},o={image_recognition:["vision"],image_generation:["imageGeneration"],audio_tts:["tts"],audio_stt:["stt"],video_generation:["videoGeneration"]},a=l[s],t=o[s];return r.filter(c=>!!(c.capabilities&&c.capabilities.length>0&&t&&t.some(u=>c.capabilities.includes(u))||a&&c.mode&&a.includes(c.mode)))}function Ba({configuredProviders:r}){const{t:s}=ye("settings"),[l,o]=i.useState(null),[a,t]=i.useState([]),[c,u]=i.useState(null),[x,h]=i.useState(null),y=i.useMemo(()=>r.map(b=>`${b.name}:${b.models?.length??0}`).sort().join(","),[r]),A=i.useCallback(async()=>{u(null);try{const[{agents:b},S]=await Promise.all([V.agents.list(),V.teams.list()]),f=S.teams.map(m=>({id:m.id,name:m.name}));t(f);const v=await Promise.all(b.map(async m=>{try{const R=(await V.agents.get(m.id)).config?.llmConfig;return{id:m.id,name:m.name||m.id,teamId:m.teamId,override:R?.modelMode==="custom"&&R.primary&&R.defaultModel?`${R.primary}/${R.defaultModel}`:null,llmConfig:{modelMode:R?.modelMode,primary:R?.primary??"",defaultModel:R?.defaultModel}}}catch{return{id:m.id,name:m.name||m.id,teamId:m.teamId,override:null,llmConfig:{modelMode:"default",primary:"",defaultModel:void 0}}}}));o(b.length?v:null)}catch(b){u(String(b))}},[y]);i.useEffect(()=>{A()},[A,y]);const g=i.useMemo(()=>{const b=[];for(const S of r)for(const f of S.models??[])b.push({provider:S.name,providerLabel:S.displayName??S.name,modelId:f.id,modelName:f.name??f.id});return b},[r]),C=async(b,S)=>{h(b),u(null);try{if(S){const[f,v]=[S.slice(0,S.lastIndexOf("/")),S.slice(S.lastIndexOf("/")+1)];await V.agents.updateConfig(b,{llmConfig:{modelMode:"custom",primary:f,defaultModel:v}})}else await V.agents.updateConfig(b,{llmConfig:{modelMode:"default",primary:"",defaultModel:void 0}});o(f=>f?.map(v=>v.id===b?{...v,override:S}:v)??f)}catch(f){u(String(f))}finally{h(null)}},N=i.useMemo(()=>{if(!l)return[];const b=new Map,S=[];for(const v of l)if(v.teamId){const m=b.get(v.teamId)??[];m.push(v),b.set(v.teamId,m)}else S.push(v);const f=[];S.length&&f.push({key:"ungrouped",label:s("perAgentModel.ungrouped",{defaultValue:"Ungrouped"}),rows:S});for(const v of a){const m=b.get(v.id);m?.length&&f.push({key:`team:${v.id}`,label:v.name,rows:m})}for(const[v,m]of b)a.some(w=>w.id===v)||f.push({key:`team:${v}`,label:v,rows:m});return f},[l,a,s]);return l===null&&!c?e.jsx("div",{className:"bg-surface-elevated rounded-xl p-5 text-sm text-fg-tertiary",children:s("common:loading",{defaultValue:"Loading…"})}):e.jsxs("div",{className:"bg-surface-elevated rounded-xl p-5 space-y-4",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium",children:s("perAgentModel.title",{defaultValue:"Per-agent default model"})}),e.jsx("div",{className:"text-xs text-fg-tertiary mt-0.5",children:s("perAgentModel.desc",{defaultValue:'Bind a specific provider+model to an agent, or leave it following the global default. This is what the composer "Apply to current agent" writes.'})})]})}),c&&e.jsx("div",{className:"text-xs text-red-500",children:c}),(!l||l.length===0)&&!c&&e.jsx("div",{className:"text-xs text-fg-tertiary",children:s("perAgentModel.noAgents",{defaultValue:"No agents available."})}),l&&l.length>0&&e.jsx("div",{className:"space-y-5",children:N.map(b=>e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wider text-fg-tertiary truncate",children:b.label}),e.jsx("span",{className:"text-[10px] text-fg-tertiary/70 tabular-nums shrink-0",children:b.rows.length})]}),e.jsx("div",{className:"space-y-2",children:b.rows.map(S=>e.jsxs("div",{className:"flex items-center justify-between gap-3 text-sm",children:[e.jsxs("div",{className:"flex-1 truncate",children:[e.jsx("span",{className:"font-medium",children:S.name}),e.jsx("span",{className:"text-xs text-fg-tertiary ml-2 truncate",children:S.id})]}),e.jsxs("div",{className:"flex items-center gap-2 w-[320px]",children:[S.override?e.jsxs(e.Fragment,{children:[e.jsx(xt,{value:S.override,options:g,placeholder:s("perAgentModel.followGlobal",{defaultValue:"Follow global"}),onChange:f=>{C(S.id,f||null)}}),e.jsx("button",{type:"button",disabled:x===S.id,onClick:()=>{C(S.id,null)},className:"shrink-0 px-2.5 py-1.5 text-xs border border-border-default rounded-lg hover:bg-surface-base disabled:opacity-40 transition-colors",children:s("perAgentModel.reset",{defaultValue:"Reset"})})]}):e.jsx(xt,{value:"",options:g,placeholder:s("perAgentModel.followGlobal",{defaultValue:"Follow global"}),onChange:f=>{C(S.id,f||null)}}),x===S.id&&e.jsx("span",{className:"shrink-0 text-[10px] text-fg-tertiary",children:s("common:loading",{defaultValue:"…"})})]})]},S.id))})]},b.key))})]})}let Tt=[],Mt=null;async function Oa(){return Mt||(Mt=(async()=>{try{Tt=(await V.modelCatalog.providerCatalog()).providers??[]}catch{Tt=[]}return Tt})(),Mt)}function Da(){const[r,s]=i.useState(Tt);return i.useEffect(()=>{let l=!0;return Oa().then(o=>{l&&s(o)}),()=>{l=!1}},[]),r}var Ze={},ur,zs;function Fa(){return zs||(zs=1,ur=function(){return typeof Promise=="function"&&Promise.prototype&&Promise.prototype.then}),ur}var xr={},Fe={},Hs;function Ke(){if(Hs)return Fe;Hs=1;let r;const s=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];return Fe.getSymbolSize=function(o){if(!o)throw new Error('"version" cannot be null or undefined');if(o<1||o>40)throw new Error('"version" should be in range from 1 to 40');return o*4+17},Fe.getSymbolTotalCodewords=function(o){return s[o]},Fe.getBCHDigit=function(l){let o=0;for(;l!==0;)o++,l>>>=1;return o},Fe.setToSJISFunction=function(o){if(typeof o!="function")throw new Error('"toSJISFunc" is not a valid function.');r=o},Fe.isKanjiModeEnabled=function(){return typeof r<"u"},Fe.toSJIS=function(o){return r(o)},Fe}var mr={},qs;function Ur(){return qs||(qs=1,(function(r){r.L={bit:1},r.M={bit:0},r.Q={bit:3},r.H={bit:2};function s(l){if(typeof l!="string")throw new Error("Param is not a string");switch(l.toLowerCase()){case"l":case"low":return r.L;case"m":case"medium":return r.M;case"q":case"quartile":return r.Q;case"h":case"high":return r.H;default:throw new Error("Unknown EC Level: "+l)}}r.isValid=function(o){return o&&typeof o.bit<"u"&&o.bit>=0&&o.bit<4},r.from=function(o,a){if(r.isValid(o))return o;try{return s(o)}catch{return a}}})(mr)),mr}var fr,Ws;function _a(){if(Ws)return fr;Ws=1;function r(){this.buffer=[],this.length=0}return r.prototype={get:function(s){const l=Math.floor(s/8);return(this.buffer[l]>>>7-s%8&1)===1},put:function(s,l){for(let o=0;o<l;o++)this.putBit((s>>>l-o-1&1)===1)},getLengthInBits:function(){return this.length},putBit:function(s){const l=Math.floor(this.length/8);this.buffer.length<=l&&this.buffer.push(0),s&&(this.buffer[l]|=128>>>this.length%8),this.length++}},fr=r,fr}var gr,Js;function Ua(){if(Js)return gr;Js=1;function r(s){if(!s||s<1)throw new Error("BitMatrix size must be defined and greater than 0");this.size=s,this.data=new Uint8Array(s*s),this.reservedBit=new Uint8Array(s*s)}return r.prototype.set=function(s,l,o,a){const t=s*this.size+l;this.data[t]=o,a&&(this.reservedBit[t]=!0)},r.prototype.get=function(s,l){return this.data[s*this.size+l]},r.prototype.xor=function(s,l,o){this.data[s*this.size+l]^=o},r.prototype.isReserved=function(s,l){return this.reservedBit[s*this.size+l]},gr=r,gr}var pr={},Gs;function $a(){return Gs||(Gs=1,(function(r){const s=Ke().getSymbolSize;r.getRowColCoords=function(o){if(o===1)return[];const a=Math.floor(o/7)+2,t=s(o),c=t===145?26:Math.ceil((t-13)/(2*a-2))*2,u=[t-7];for(let x=1;x<a-1;x++)u[x]=u[x-1]-c;return u.push(6),u.reverse()},r.getPositions=function(o){const a=[],t=r.getRowColCoords(o),c=t.length;for(let u=0;u<c;u++)for(let x=0;x<c;x++)u===0&&x===0||u===0&&x===c-1||u===c-1&&x===0||a.push([t[u],t[x]]);return a}})(pr)),pr}var hr={},Qs;function Va(){if(Qs)return hr;Qs=1;const r=Ke().getSymbolSize,s=7;return hr.getPositions=function(o){const a=r(o);return[[0,0],[a-s,0],[0,a-s]]},hr}var br={},Ys;function Ka(){return Ys||(Ys=1,(function(r){r.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};const s={N1:3,N2:3,N3:40,N4:10};r.isValid=function(a){return a!=null&&a!==""&&!isNaN(a)&&a>=0&&a<=7},r.from=function(a){return r.isValid(a)?parseInt(a,10):void 0},r.getPenaltyN1=function(a){const t=a.size;let c=0,u=0,x=0,h=null,y=null;for(let A=0;A<t;A++){u=x=0,h=y=null;for(let g=0;g<t;g++){let C=a.get(A,g);C===h?u++:(u>=5&&(c+=s.N1+(u-5)),h=C,u=1),C=a.get(g,A),C===y?x++:(x>=5&&(c+=s.N1+(x-5)),y=C,x=1)}u>=5&&(c+=s.N1+(u-5)),x>=5&&(c+=s.N1+(x-5))}return c},r.getPenaltyN2=function(a){const t=a.size;let c=0;for(let u=0;u<t-1;u++)for(let x=0;x<t-1;x++){const h=a.get(u,x)+a.get(u,x+1)+a.get(u+1,x)+a.get(u+1,x+1);(h===4||h===0)&&c++}return c*s.N2},r.getPenaltyN3=function(a){const t=a.size;let c=0,u=0,x=0;for(let h=0;h<t;h++){u=x=0;for(let y=0;y<t;y++)u=u<<1&2047|a.get(h,y),y>=10&&(u===1488||u===93)&&c++,x=x<<1&2047|a.get(y,h),y>=10&&(x===1488||x===93)&&c++}return c*s.N3},r.getPenaltyN4=function(a){let t=0;const c=a.data.length;for(let x=0;x<c;x++)t+=a.data[x];return Math.abs(Math.ceil(t*100/c/5)-10)*s.N4};function l(o,a,t){switch(o){case r.Patterns.PATTERN000:return(a+t)%2===0;case r.Patterns.PATTERN001:return a%2===0;case r.Patterns.PATTERN010:return t%3===0;case r.Patterns.PATTERN011:return(a+t)%3===0;case r.Patterns.PATTERN100:return(Math.floor(a/2)+Math.floor(t/3))%2===0;case r.Patterns.PATTERN101:return a*t%2+a*t%3===0;case r.Patterns.PATTERN110:return(a*t%2+a*t%3)%2===0;case r.Patterns.PATTERN111:return(a*t%3+(a+t)%2)%2===0;default:throw new Error("bad maskPattern:"+o)}}r.applyMask=function(a,t){const c=t.size;for(let u=0;u<c;u++)for(let x=0;x<c;x++)t.isReserved(x,u)||t.xor(x,u,l(a,x,u))},r.getBestMask=function(a,t){const c=Object.keys(r.Patterns).length;let u=0,x=1/0;for(let h=0;h<c;h++){t(h),r.applyMask(h,a);const y=r.getPenaltyN1(a)+r.getPenaltyN2(a)+r.getPenaltyN3(a)+r.getPenaltyN4(a);r.applyMask(h,a),y<x&&(x=y,u=h)}return u}})(br)),br}var At={},Zs;function Bn(){if(Zs)return At;Zs=1;const r=Ur(),s=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],l=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];return At.getBlocksCount=function(a,t){switch(t){case r.L:return s[(a-1)*4+0];case r.M:return s[(a-1)*4+1];case r.Q:return s[(a-1)*4+2];case r.H:return s[(a-1)*4+3];default:return}},At.getTotalCodewordsCount=function(a,t){switch(t){case r.L:return l[(a-1)*4+0];case r.M:return l[(a-1)*4+1];case r.Q:return l[(a-1)*4+2];case r.H:return l[(a-1)*4+3];default:return}},At}var yr={},dt={},Xs;function za(){if(Xs)return dt;Xs=1;const r=new Uint8Array(512),s=new Uint8Array(256);return(function(){let o=1;for(let a=0;a<255;a++)r[a]=o,s[o]=a,o<<=1,o&256&&(o^=285);for(let a=255;a<512;a++)r[a]=r[a-255]})(),dt.log=function(o){if(o<1)throw new Error("log("+o+")");return s[o]},dt.exp=function(o){return r[o]},dt.mul=function(o,a){return o===0||a===0?0:r[s[o]+s[a]]},dt}var en;function Ha(){return en||(en=1,(function(r){const s=za();r.mul=function(o,a){const t=new Uint8Array(o.length+a.length-1);for(let c=0;c<o.length;c++)for(let u=0;u<a.length;u++)t[c+u]^=s.mul(o[c],a[u]);return t},r.mod=function(o,a){let t=new Uint8Array(o);for(;t.length-a.length>=0;){const c=t[0];for(let x=0;x<a.length;x++)t[x]^=s.mul(a[x],c);let u=0;for(;u<t.length&&t[u]===0;)u++;t=t.slice(u)}return t},r.generateECPolynomial=function(o){let a=new Uint8Array([1]);for(let t=0;t<o;t++)a=r.mul(a,new Uint8Array([1,s.exp(t)]));return a}})(yr)),yr}var vr,tn;function qa(){if(tn)return vr;tn=1;const r=Ha();function s(l){this.genPoly=void 0,this.degree=l,this.degree&&this.initialize(this.degree)}return s.prototype.initialize=function(o){this.degree=o,this.genPoly=r.generateECPolynomial(this.degree)},s.prototype.encode=function(o){if(!this.genPoly)throw new Error("Encoder not initialized");const a=new Uint8Array(o.length+this.degree);a.set(o);const t=r.mod(a,this.genPoly),c=this.degree-t.length;if(c>0){const u=new Uint8Array(this.degree);return u.set(t,c),u}return t},vr=s,vr}var jr={},wr={},Nr={},rn;function On(){return rn||(rn=1,Nr.isValid=function(s){return!isNaN(s)&&s>=1&&s<=40}),Nr}var Me={},sn;function Dn(){if(sn)return Me;sn=1;const r="[0-9]+",s="[A-Z $%*+\\-./:]+";let l="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";l=l.replace(/u/g,"\\u");const o="(?:(?![A-Z0-9 $%*+\\-./:]|"+l+`)(?:.|[\r
|
|
2
2
|
]))+`;Me.KANJI=new RegExp(l,"g"),Me.BYTE_KANJI=new RegExp("[^A-Z0-9 $%*+\\-./:]+","g"),Me.BYTE=new RegExp(o,"g"),Me.NUMERIC=new RegExp(r,"g"),Me.ALPHANUMERIC=new RegExp(s,"g");const a=new RegExp("^"+l+"$"),t=new RegExp("^"+r+"$"),c=new RegExp("^[A-Z0-9 $%*+\\-./:]+$");return Me.testKanji=function(x){return a.test(x)},Me.testNumeric=function(x){return t.test(x)},Me.testAlphanumeric=function(x){return c.test(x)},Me}var nn;function ze(){return nn||(nn=1,(function(r){const s=On(),l=Dn();r.NUMERIC={id:"Numeric",bit:1,ccBits:[10,12,14]},r.ALPHANUMERIC={id:"Alphanumeric",bit:2,ccBits:[9,11,13]},r.BYTE={id:"Byte",bit:4,ccBits:[8,16,16]},r.KANJI={id:"Kanji",bit:8,ccBits:[8,10,12]},r.MIXED={bit:-1},r.getCharCountIndicator=function(t,c){if(!t.ccBits)throw new Error("Invalid mode: "+t);if(!s.isValid(c))throw new Error("Invalid version: "+c);return c>=1&&c<10?t.ccBits[0]:c<27?t.ccBits[1]:t.ccBits[2]},r.getBestModeForData=function(t){return l.testNumeric(t)?r.NUMERIC:l.testAlphanumeric(t)?r.ALPHANUMERIC:l.testKanji(t)?r.KANJI:r.BYTE},r.toString=function(t){if(t&&t.id)return t.id;throw new Error("Invalid mode")},r.isValid=function(t){return t&&t.bit&&t.ccBits};function o(a){if(typeof a!="string")throw new Error("Param is not a string");switch(a.toLowerCase()){case"numeric":return r.NUMERIC;case"alphanumeric":return r.ALPHANUMERIC;case"kanji":return r.KANJI;case"byte":return r.BYTE;default:throw new Error("Unknown mode: "+a)}}r.from=function(t,c){if(r.isValid(t))return t;try{return o(t)}catch{return c}}})(wr)),wr}var an;function Wa(){return an||(an=1,(function(r){const s=Ke(),l=Bn(),o=Ur(),a=ze(),t=On(),c=7973,u=s.getBCHDigit(c);function x(g,C,N){for(let b=1;b<=40;b++)if(C<=r.getCapacity(b,N,g))return b}function h(g,C){return a.getCharCountIndicator(g,C)+4}function y(g,C){let N=0;return g.forEach(function(b){const S=h(b.mode,C);N+=S+b.getBitsLength()}),N}function A(g,C){for(let N=1;N<=40;N++)if(y(g,N)<=r.getCapacity(N,C,a.MIXED))return N}r.from=function(C,N){return t.isValid(C)?parseInt(C,10):N},r.getCapacity=function(C,N,b){if(!t.isValid(C))throw new Error("Invalid QR Code version");typeof b>"u"&&(b=a.BYTE);const S=s.getSymbolTotalCodewords(C),f=l.getTotalCodewordsCount(C,N),v=(S-f)*8;if(b===a.MIXED)return v;const m=v-h(b,C);switch(b){case a.NUMERIC:return Math.floor(m/10*3);case a.ALPHANUMERIC:return Math.floor(m/11*2);case a.KANJI:return Math.floor(m/13);case a.BYTE:default:return Math.floor(m/8)}},r.getBestVersionForData=function(C,N){let b;const S=o.from(N,o.M);if(Array.isArray(C)){if(C.length>1)return A(C,S);if(C.length===0)return 1;b=C[0]}else b=C;return x(b.mode,b.getLength(),S)},r.getEncodedBits=function(C){if(!t.isValid(C)||C<7)throw new Error("Invalid QR Code version");let N=C<<12;for(;s.getBCHDigit(N)-u>=0;)N^=c<<s.getBCHDigit(N)-u;return C<<12|N}})(jr)),jr}var kr={},on;function Ja(){if(on)return kr;on=1;const r=Ke(),s=1335,l=21522,o=r.getBCHDigit(s);return kr.getEncodedBits=function(t,c){const u=t.bit<<3|c;let x=u<<10;for(;r.getBCHDigit(x)-o>=0;)x^=s<<r.getBCHDigit(x)-o;return(u<<10|x)^l},kr}var Cr={},Sr,ln;function Ga(){if(ln)return Sr;ln=1;const r=ze();function s(l){this.mode=r.NUMERIC,this.data=l.toString()}return s.getBitsLength=function(o){return 10*Math.floor(o/3)+(o%3?o%3*3+1:0)},s.prototype.getLength=function(){return this.data.length},s.prototype.getBitsLength=function(){return s.getBitsLength(this.data.length)},s.prototype.write=function(o){let a,t,c;for(a=0;a+3<=this.data.length;a+=3)t=this.data.substr(a,3),c=parseInt(t,10),o.put(c,10);const u=this.data.length-a;u>0&&(t=this.data.substr(a),c=parseInt(t,10),o.put(c,u*3+1))},Sr=s,Sr}var Pr,dn;function Qa(){if(dn)return Pr;dn=1;const r=ze(),s=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"," ","$","%","*","+","-",".","/",":"];function l(o){this.mode=r.ALPHANUMERIC,this.data=o}return l.getBitsLength=function(a){return 11*Math.floor(a/2)+6*(a%2)},l.prototype.getLength=function(){return this.data.length},l.prototype.getBitsLength=function(){return l.getBitsLength(this.data.length)},l.prototype.write=function(a){let t;for(t=0;t+2<=this.data.length;t+=2){let c=s.indexOf(this.data[t])*45;c+=s.indexOf(this.data[t+1]),a.put(c,11)}this.data.length%2&&a.put(s.indexOf(this.data[t]),6)},Pr=l,Pr}var Mr,cn;function Ya(){if(cn)return Mr;cn=1;const r=ze();function s(l){this.mode=r.BYTE,typeof l=="string"?this.data=new TextEncoder().encode(l):this.data=new Uint8Array(l)}return s.getBitsLength=function(o){return o*8},s.prototype.getLength=function(){return this.data.length},s.prototype.getBitsLength=function(){return s.getBitsLength(this.data.length)},s.prototype.write=function(l){for(let o=0,a=this.data.length;o<a;o++)l.put(this.data[o],8)},Mr=s,Mr}var Ar,un;function Za(){if(un)return Ar;un=1;const r=ze(),s=Ke();function l(o){this.mode=r.KANJI,this.data=o}return l.getBitsLength=function(a){return a*13},l.prototype.getLength=function(){return this.data.length},l.prototype.getBitsLength=function(){return l.getBitsLength(this.data.length)},l.prototype.write=function(o){let a;for(a=0;a<this.data.length;a++){let t=s.toSJIS(this.data[a]);if(t>=33088&&t<=40956)t-=33088;else if(t>=57408&&t<=60351)t-=49472;else throw new Error("Invalid SJIS character: "+this.data[a]+`
|
|
3
3
|
Make sure your charset is UTF-8`);t=(t>>>8&255)*192+(t&255),o.put(t,13)}},Ar=l,Ar}var Er={exports:{}},xn;function Xa(){return xn||(xn=1,(function(r){var s={single_source_shortest_paths:function(l,o,a){var t={},c={};c[o]=0;var u=s.PriorityQueue.make();u.push(o,0);for(var x,h,y,A,g,C,N,b,S;!u.empty();){x=u.pop(),h=x.value,A=x.cost,g=l[h]||{};for(y in g)g.hasOwnProperty(y)&&(C=g[y],N=A+C,b=c[y],S=typeof c[y]>"u",(S||b>N)&&(c[y]=N,u.push(y,N),t[y]=h))}if(typeof a<"u"&&typeof c[a]>"u"){var f=["Could not find a path from ",o," to ",a,"."].join("");throw new Error(f)}return t},extract_shortest_path_from_predecessor_list:function(l,o){for(var a=[],t=o;t;)a.push(t),l[t],t=l[t];return a.reverse(),a},find_path:function(l,o,a){var t=s.single_source_shortest_paths(l,o,a);return s.extract_shortest_path_from_predecessor_list(t,a)},PriorityQueue:{make:function(l){var o=s.PriorityQueue,a={},t;l=l||{};for(t in o)o.hasOwnProperty(t)&&(a[t]=o[t]);return a.queue=[],a.sorter=l.sorter||o.default_sorter,a},default_sorter:function(l,o){return l.cost-o.cost},push:function(l,o){var a={value:l,cost:o};this.queue.push(a),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return this.queue.length===0}}};r.exports=s})(Er)),Er.exports}var mn;function eo(){return mn||(mn=1,(function(r){const s=ze(),l=Ga(),o=Qa(),a=Ya(),t=Za(),c=Dn(),u=Ke(),x=Xa();function h(f){return unescape(encodeURIComponent(f)).length}function y(f,v,m){const w=[];let R;for(;(R=f.exec(m))!==null;)w.push({data:R[0],index:R.index,mode:v,length:R[0].length});return w}function A(f){const v=y(c.NUMERIC,s.NUMERIC,f),m=y(c.ALPHANUMERIC,s.ALPHANUMERIC,f);let w,R;return u.isKanjiModeEnabled()?(w=y(c.BYTE,s.BYTE,f),R=y(c.KANJI,s.KANJI,f)):(w=y(c.BYTE_KANJI,s.BYTE,f),R=[]),v.concat(m,w,R).sort(function(F,$){return F.index-$.index}).map(function(F){return{data:F.data,mode:F.mode,length:F.length}})}function g(f,v){switch(v){case s.NUMERIC:return l.getBitsLength(f);case s.ALPHANUMERIC:return o.getBitsLength(f);case s.KANJI:return t.getBitsLength(f);case s.BYTE:return a.getBitsLength(f)}}function C(f){return f.reduce(function(v,m){const w=v.length-1>=0?v[v.length-1]:null;return w&&w.mode===m.mode?(v[v.length-1].data+=m.data,v):(v.push(m),v)},[])}function N(f){const v=[];for(let m=0;m<f.length;m++){const w=f[m];switch(w.mode){case s.NUMERIC:v.push([w,{data:w.data,mode:s.ALPHANUMERIC,length:w.length},{data:w.data,mode:s.BYTE,length:w.length}]);break;case s.ALPHANUMERIC:v.push([w,{data:w.data,mode:s.BYTE,length:w.length}]);break;case s.KANJI:v.push([w,{data:w.data,mode:s.BYTE,length:h(w.data)}]);break;case s.BYTE:v.push([{data:w.data,mode:s.BYTE,length:h(w.data)}])}}return v}function b(f,v){const m={},w={start:{}};let R=["start"];for(let I=0;I<f.length;I++){const F=f[I],$=[];for(let P=0;P<F.length;P++){const O=F[P],L=""+I+P;$.push(L),m[L]={node:O,lastCount:0},w[L]={};for(let U=0;U<R.length;U++){const _=R[U];m[_]&&m[_].node.mode===O.mode?(w[_][L]=g(m[_].lastCount+O.length,O.mode)-g(m[_].lastCount,O.mode),m[_].lastCount+=O.length):(m[_]&&(m[_].lastCount=O.length),w[_][L]=g(O.length,O.mode)+4+s.getCharCountIndicator(O.mode,v))}}R=$}for(let I=0;I<R.length;I++)w[R[I]].end=0;return{map:w,table:m}}function S(f,v){let m;const w=s.getBestModeForData(f);if(m=s.from(v,w),m!==s.BYTE&&m.bit<w.bit)throw new Error('"'+f+'" cannot be encoded with mode '+s.toString(m)+`.
|
|
4
4
|
Suggested mode is: `+s.toString(w));switch(m===s.KANJI&&!u.isKanjiModeEnabled()&&(m=s.BYTE),m){case s.NUMERIC:return new l(f);case s.ALPHANUMERIC:return new o(f);case s.KANJI:return new t(f);case s.BYTE:return new a(f)}}r.fromArray=function(v){return v.reduce(function(m,w){return typeof w=="string"?m.push(S(w,null)):w.data&&m.push(S(w.data,w.mode)),m},[])},r.fromString=function(v,m){const w=A(v,u.isKanjiModeEnabled()),R=N(w),I=b(R,m),F=x.find_path(I.map,"start","end"),$=[];for(let P=1;P<F.length-1;P++)$.push(I.table[F[P]].node);return r.fromArray(C($))},r.rawSplit=function(v){return r.fromArray(A(v,u.isKanjiModeEnabled()))}})(Cr)),Cr}var fn;function to(){if(fn)return xr;fn=1;const r=Ke(),s=Ur(),l=_a(),o=Ua(),a=$a(),t=Va(),c=Ka(),u=Bn(),x=qa(),h=Wa(),y=Ja(),A=ze(),g=eo();function C(I,F){const $=I.size,P=t.getPositions(F);for(let O=0;O<P.length;O++){const L=P[O][0],U=P[O][1];for(let _=-1;_<=7;_++)if(!(L+_<=-1||$<=L+_))for(let K=-1;K<=7;K++)U+K<=-1||$<=U+K||(_>=0&&_<=6&&(K===0||K===6)||K>=0&&K<=6&&(_===0||_===6)||_>=2&&_<=4&&K>=2&&K<=4?I.set(L+_,U+K,!0,!0):I.set(L+_,U+K,!1,!0))}}function N(I){const F=I.size;for(let $=8;$<F-8;$++){const P=$%2===0;I.set($,6,P,!0),I.set(6,$,P,!0)}}function b(I,F){const $=a.getPositions(F);for(let P=0;P<$.length;P++){const O=$[P][0],L=$[P][1];for(let U=-2;U<=2;U++)for(let _=-2;_<=2;_++)U===-2||U===2||_===-2||_===2||U===0&&_===0?I.set(O+U,L+_,!0,!0):I.set(O+U,L+_,!1,!0)}}function S(I,F){const $=I.size,P=h.getEncodedBits(F);let O,L,U;for(let _=0;_<18;_++)O=Math.floor(_/3),L=_%3+$-8-3,U=(P>>_&1)===1,I.set(O,L,U,!0),I.set(L,O,U,!0)}function f(I,F,$){const P=I.size,O=y.getEncodedBits(F,$);let L,U;for(L=0;L<15;L++)U=(O>>L&1)===1,L<6?I.set(L,8,U,!0):L<8?I.set(L+1,8,U,!0):I.set(P-15+L,8,U,!0),L<8?I.set(8,P-L-1,U,!0):L<9?I.set(8,15-L-1+1,U,!0):I.set(8,15-L-1,U,!0);I.set(P-8,8,1,!0)}function v(I,F){const $=I.size;let P=-1,O=$-1,L=7,U=0;for(let _=$-1;_>0;_-=2)for(_===6&&_--;;){for(let K=0;K<2;K++)if(!I.isReserved(O,_-K)){let q=!1;U<F.length&&(q=(F[U]>>>L&1)===1),I.set(O,_-K,q),L--,L===-1&&(U++,L=7)}if(O+=P,O<0||$<=O){O-=P,P=-P;break}}}function m(I,F,$){const P=new l;$.forEach(function(K){P.put(K.mode.bit,4),P.put(K.getLength(),A.getCharCountIndicator(K.mode,I)),K.write(P)});const O=r.getSymbolTotalCodewords(I),L=u.getTotalCodewordsCount(I,F),U=(O-L)*8;for(P.getLengthInBits()+4<=U&&P.put(0,4);P.getLengthInBits()%8!==0;)P.putBit(0);const _=(U-P.getLengthInBits())/8;for(let K=0;K<_;K++)P.put(K%2?17:236,8);return w(P,I,F)}function w(I,F,$){const P=r.getSymbolTotalCodewords(F),O=u.getTotalCodewordsCount(F,$),L=P-O,U=u.getBlocksCount(F,$),_=P%U,K=U-_,q=Math.floor(P/U),T=Math.floor(L/U),B=T+1,ee=q-T,ie=new x(ee);let de=0;const se=new Array(U),d=new Array(U);let k=0;const D=new Uint8Array(I.buffer);for(let ce=0;ce<U;ce++){const Ne=ce<K?T:B;se[ce]=D.slice(de,de+Ne),d[ce]=ie.encode(se[ce]),de+=Ne,k=Math.max(k,Ne)}const z=new Uint8Array(P);let J=0,re,Z;for(re=0;re<k;re++)for(Z=0;Z<U;Z++)re<se[Z].length&&(z[J++]=se[Z][re]);for(re=0;re<ee;re++)for(Z=0;Z<U;Z++)z[J++]=d[Z][re];return z}function R(I,F,$,P){let O;if(Array.isArray(I))O=g.fromArray(I);else if(typeof I=="string"){let q=F;if(!q){const T=g.rawSplit(I);q=h.getBestVersionForData(T,$)}O=g.fromString(I,q||40)}else throw new Error("Invalid data");const L=h.getBestVersionForData(O,$);if(!L)throw new Error("The amount of data is too big to be stored in a QR Code");if(!F)F=L;else if(F<L)throw new Error(`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{u as E,r as d,a as M,b as A,c as D,d as C,j as e,P as L,i as R,S as z,T as H,e as K,f as $,I as O,h as q,g as B}from"./index-
|
|
1
|
+
import{u as E,r as d,a as M,b as A,c as D,d as C,j as e,P as L,i as R,S as z,T as H,e as K,f as $,I as O,h as q,g as B}from"./index-1X1Ykov8.js";const v=[{id:"discover"},{id:"agents"},{id:"teams"},{id:"skills"},{id:"installed"}],P={agent:"agents",team:"teams",skill:"skills",connector:"skills"},F={discover:"M12 2l2.4 6.9L21 9l-5.4 4 2 7-5.6-4.1L6.4 20l2-7L3 9l6.6-.1z",agents:"M12 2a5 5 0 015 5v1a5 5 0 01-10 0V7a5 5 0 015-5zM4 21a8 8 0 0116 0z",teams:"M16 11a4 4 0 10-4-4 4 4 0 004 4zM8 13a3 3 0 10-3-3 3 3 0 003 3zm0 2c-2.7 0-5 1.3-5 3v2h7v-2c0-.7.2-1.3.6-1.9A7.6 7.6 0 008 15zm8 0c-3 0-6 1.5-6 3.5V21h12v-2.5c0-2-3-3.5-6-3.5z",skills:"M13 2L3 14h7l-1 8 10-12h-7z",installed:"M12 3v12m0 0l-4-4m4 4l4-4M5 21h14"};function I(n){return n==="discover"||n==="agents"||n==="teams"||n==="skills"||n==="installed"}function T(){const n=localStorage.getItem("markus_nav_installItem"),o=localStorage.getItem("markus_nav_storeTab");if(n)return{tab:I(o)?o:"agents",installId:n};const f=new URLSearchParams(window.location.search),s=f.get("install");if(s){const a=f.get("type");return{tab:a&&P[a]||"agents",installId:s}}return{tab:I(o)?o:"discover",installId:null}}function N(){localStorage.removeItem("markus_nav_installItem"),localStorage.removeItem("markus_nav_storeTab");const n=new URLSearchParams(window.location.search);if(n.has("install")||n.has("type")){n.delete("install"),n.delete("type");const o=n.toString();window.history.replaceState(null,"",window.location.pathname+(o?`?${o}`:"")+window.location.hash)}}function V({itemId:n,onDismiss:o,onInstalled:f}){const{t:s}=E(["store","common"]),[a,p]=d.useState(null),[g,l]=d.useState("loading"),[b,k]=d.useState(!1),[u,m]=d.useState("");d.useEffect(()=>{let x=!1;return l("loading"),p(null),m(""),q.getItem(n).then(({item:c})=>{x||(c?(p(c),l("ready")):l("missing"))}).catch(()=>{x||l("missing")}),()=>{x=!0}},[n]);const w=async()=>{if(!(!a||b)){k(!0),m("");try{await B(a),m(s("deepLink.installed")),f()}catch(x){const c=x instanceof Error?x.message:"";m(c.includes("402")||c.includes("Purchase")?s("deepLink.purchaseRequired"):s("deepLink.failed"))}finally{k(!1)}}};return e.jsxs("div",{className:"shrink-0 mx-3 mt-3 mb-1 rounded-xl border border-brand-500/30 bg-brand-600/10 px-4 py-3 flex flex-col sm:flex-row sm:items-center gap-3",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-wider text-brand-400/90 mb-0.5",children:s("deepLink.fromHub")}),g==="loading"&&e.jsx("p",{className:"text-sm text-fg-secondary",children:s("deepLink.loading")}),g==="missing"&&e.jsx("p",{className:"text-sm text-rose-300",children:s("deepLink.missing")}),g==="ready"&&a&&e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-sm font-semibold text-fg-primary truncate",children:a.name}),a.description&&e.jsx("p",{className:"text-xs text-fg-tertiary line-clamp-2 mt-0.5",children:a.description}),u&&e.jsx("p",{className:"text-xs mt-1 text-brand-300",children:u})]})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[g==="ready"&&a&&e.jsx("button",{type:"button",disabled:b,onClick:()=>{w()},className:"px-3.5 py-2 rounded-lg text-xs font-semibold bg-brand-600 hover:bg-brand-500 text-white disabled:opacity-60",children:s(b?"deepLink.installing":"deepLink.install")}),e.jsx("button",{type:"button",onClick:o,className:"px-2.5 py-2 rounded-lg text-xs text-fg-tertiary hover:text-fg-secondary hover:bg-surface-elevated/60",children:s("deepLink.dismiss")})]})]})}function G({authUser:n}){const{t:o}=E(["store","common"]),[f]=d.useState(T),[s,a]=d.useState(f.tab),p=M(),g=A(L.STORE),l=D(),b=l?.keyboardPane??"content",k=C(v,s,a),[u,m]=d.useState(f.installId),w=d.useRef(s);w.current=s,d.useEffect(()=>{if(p||!g)return;const t=r=>{if(l?.keyboardPane==="l0"||r.metaKey||r.ctrlKey||r.altKey||R(r.target))return;const i=r.key.length===1?r.key.toLowerCase():r.key;if(i==="h"||i==="ArrowLeft"){r.preventDefault(),l?.setL0FocusPageId(L.STORE),l?.setLeftCollapsed(!1),l?.setKeyboardPane("l0");return}if(i==="l"||i==="ArrowRight"){r.preventDefault(),l?.keyboardPane!=="l1"&&l?.setKeyboardPane("l1");return}const h=i==="j"||i==="ArrowDown"?1:i==="k"||i==="ArrowUp"?-1:0;if(!h)return;r.preventDefault(),l?.setKeyboardPane("l1");const y=v.findIndex(_=>_.id===w.current),S=v[Math.max(0,Math.min(v.length-1,y+h))];a(S.id),requestAnimationFrame(()=>{document.querySelector(`[data-store-tab-id="${S.id}"]`)?.scrollIntoView({block:"nearest"})})};return document.addEventListener("keydown",t,!0),()=>document.removeEventListener("keydown",t,!0)},[p,g,l]),d.useEffect(()=>{const t=T();t.installId&&(m(t.installId),I(t.tab)&&a(t.tab),N())},[]),d.useEffect(()=>{const t=r=>{const i=r.detail;if(i.page==="store"||i.page==="explore"){const h=i.params?.storeTab??localStorage.getItem("markus_nav_storeTab"),y=i.params?.installItem??localStorage.getItem("markus_nav_installItem");h&&I(h)&&a(h),y&&m(y),(h||y)&&N()}};return window.addEventListener("markus:navigate",t),()=>window.removeEventListener("markus:navigate",t)},[]);const x=(t,r)=>{const i=P[t]??"agents";r&&m(r),a(i)},c=()=>m(null),j=()=>e.jsxs(e.Fragment,{children:[u&&e.jsx(V,{itemId:u,onDismiss:c,onInstalled:c}),s==="discover"&&e.jsx(z,{onOpenType:x}),s==="agents"&&e.jsx(H,{authUser:n,highlightItemId:u,onHighlightDone:c}),s==="teams"&&e.jsx(K,{highlightItemId:u,onHighlightDone:c}),s==="skills"&&e.jsx($,{highlightItemId:u,onHighlightDone:c}),s==="installed"&&e.jsx(O,{})]});return p?e.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",onTouchStart:k.onTouchStart,onTouchEnd:k.onTouchEnd,children:[e.jsx("div",{className:"flex shrink-0 overflow-x-auto scrollbar-hide",children:v.map(t=>e.jsx("button",{onClick:()=>a(t.id),className:`flex-1 min-w-fit px-4 py-3 text-sm font-medium text-center whitespace-nowrap transition-colors border-b-2 ${s===t.id?"border-brand-500 text-brand-500":"border-transparent text-fg-tertiary hover:text-fg-secondary"}`,children:o(`tabs.${t.id}`)},t.id))}),e.jsx("div",{className:"flex-1 overflow-hidden flex flex-col",children:j()})]}):e.jsxs("div",{className:"flex-1 overflow-hidden flex flex-row",children:[e.jsxs("nav",{"data-keyboard-pane":"l1",className:`w-36 shrink-0 bg-surface-secondary rounded-xl m-1 mr-0 flex flex-col py-4 px-2 gap-1 ${b==="l1"?"ring-1 ring-inset ring-brand-500/30":""}`,children:[e.jsx("div",{className:"px-3 pb-3 mb-1",children:e.jsx("h2",{className:"text-xs font-semibold text-fg-tertiary uppercase tracking-wider",children:o("title")})}),v.map(t=>e.jsxs("button",{"data-store-tab-id":t.id,onClick:()=>a(t.id),className:`flex items-center gap-2.5 px-3 py-2.5 rounded-lg text-sm font-medium transition-all ${s===t.id?b==="l1"?"bg-brand-500/25 text-brand-400 ring-1 ring-inset ring-brand-500/40":"bg-brand-600/15 text-brand-400 shadow-sm shadow-brand-500/10":"text-fg-tertiary hover:text-fg-secondary hover:bg-surface-elevated/50"}`,children:[e.jsx("svg",{className:"w-4 h-4 shrink-0",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:e.jsx("path",{d:F[t.id]})}),o(`tabs.${t.id}`)]},t.id))]}),e.jsx("div",{className:"flex-1 overflow-hidden flex flex-col",children:j()})]})}export{G as StorePage};
|