@markus-global/cli 0.9.0 → 0.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. package/dist/commands/start.js +25 -0
  2. package/dist/commands/start.js.map +1 -1
  3. package/dist/markus.mjs +123 -14
  4. package/dist/web-ui/assets/{CommentInput-Ccv0KCzc.js → CommentInput-ZW-2JyIg.js} +1 -1
  5. package/dist/web-ui/assets/{ContentRenderer-BbN7QT3E.js → ContentRenderer-Ccoj5KhH.js} +2 -2
  6. package/dist/web-ui/assets/{Deliverables-Dzfujlqv.js → Deliverables-Cfdx-Yeu.js} +1 -1
  7. package/dist/web-ui/assets/Notifications-CKTZO9fn.js +1 -0
  8. package/dist/web-ui/assets/{Search-Va12fH-V.js → Search-_yYhKio7.js} +1 -1
  9. package/dist/web-ui/assets/{Settings-D_0MEUGb.js → Settings-BzI3q_dx.js} +1 -1
  10. package/dist/web-ui/assets/{Store-dRlOlppM.js → Store-DweBtEGf.js} +1 -1
  11. package/dist/web-ui/assets/Team-CpIDXpOi.js +40 -0
  12. package/dist/web-ui/assets/{Work-C6pfFbRU.js → Work-CMguHPuO.js} +5 -5
  13. package/dist/web-ui/assets/{arc-w52qYN0j.js → arc-BCQf-2jC.js} +1 -1
  14. package/dist/web-ui/assets/{architectureDiagram-3BPJPVTR-Dq5t04Vy.js → architectureDiagram-3BPJPVTR-CPfkQ9P6.js} +1 -1
  15. package/dist/web-ui/assets/{blockDiagram-GPEHLZMM-dMSQ7RYP.js → blockDiagram-GPEHLZMM-w0CZJHe6.js} +1 -1
  16. package/dist/web-ui/assets/{c4Diagram-AAUBKEIU-yG4K-xPW.js → c4Diagram-AAUBKEIU-BTiNccgB.js} +1 -1
  17. package/dist/web-ui/assets/channel-DIphKEQ6.js +1 -0
  18. package/dist/web-ui/assets/{chunk-2J33WTMH-BMCCyFP7.js → chunk-2J33WTMH-BGdXq7Ci.js} +1 -1
  19. package/dist/web-ui/assets/{chunk-4BX2VUAB-DrZE__0f.js → chunk-4BX2VUAB-CDNqL2YA.js} +1 -1
  20. package/dist/web-ui/assets/{chunk-55IACEB6-BHAPJ9Eo.js → chunk-55IACEB6-B0gL5ae4.js} +1 -1
  21. package/dist/web-ui/assets/{chunk-727SXJPM-Ctfjl9vK.js → chunk-727SXJPM-C377nPB7.js} +1 -1
  22. package/dist/web-ui/assets/{chunk-AQP2D5EJ-SVZPGzSA.js → chunk-AQP2D5EJ-DmrWdQ_x.js} +1 -1
  23. package/dist/web-ui/assets/{chunk-FMBD7UC4-DeTpOrnv.js → chunk-FMBD7UC4-CasLcPiP.js} +1 -1
  24. package/dist/web-ui/assets/{chunk-ND2GUHAM-CudW1r3G.js → chunk-ND2GUHAM-Bl_5b1IO.js} +1 -1
  25. package/dist/web-ui/assets/{chunk-QZHKN3VN-CJSQIoVy.js → chunk-QZHKN3VN-CAFFoh9g.js} +1 -1
  26. package/dist/web-ui/assets/classDiagram-4FO5ZUOK-CIRviJO4.js +1 -0
  27. package/dist/web-ui/assets/classDiagram-v2-Q7XG4LA2-CIRviJO4.js +1 -0
  28. package/dist/web-ui/assets/{cose-bilkent-S5V4N54A-CcCOSPt7.js → cose-bilkent-S5V4N54A-CNLxRUfr.js} +1 -1
  29. package/dist/web-ui/assets/{dagre-BM42HDAG-F3l9565T.js → dagre-BM42HDAG-CkqVIRox.js} +1 -1
  30. package/dist/web-ui/assets/{diagram-2AECGRRQ-B5Ep5hBX.js → diagram-2AECGRRQ-CBxL1Jqg.js} +1 -1
  31. package/dist/web-ui/assets/{diagram-5GNKFQAL-Ba-Xi40Z.js → diagram-5GNKFQAL-CpSDzWYR.js} +1 -1
  32. package/dist/web-ui/assets/{diagram-KO2AKTUF-nq3nvV52.js → diagram-KO2AKTUF-DG-3NyJR.js} +1 -1
  33. package/dist/web-ui/assets/{diagram-LMA3HP47-BLQG5suI.js → diagram-LMA3HP47-DOq08i33.js} +1 -1
  34. package/dist/web-ui/assets/{diagram-OG6HWLK6-BZwEfL_A.js → diagram-OG6HWLK6-B6_uG9hH.js} +1 -1
  35. package/dist/web-ui/assets/{erDiagram-TEJ5UH35-x0d6Urzc.js → erDiagram-TEJ5UH35-DOyEVlMM.js} +1 -1
  36. package/dist/web-ui/assets/{flowDiagram-I6XJVG4X-Bps4iInm.js → flowDiagram-I6XJVG4X-BiWeEgX3.js} +1 -1
  37. package/dist/web-ui/assets/{ganttDiagram-6RSMTGT7-BQhqabZG.js → ganttDiagram-6RSMTGT7-D-j-5cEg.js} +1 -1
  38. package/dist/web-ui/assets/{gitGraphDiagram-PVQCEYII-CZsFUtiG.js → gitGraphDiagram-PVQCEYII-C6lcURfO.js} +1 -1
  39. package/dist/web-ui/assets/index-CPULIfuW.css +1 -0
  40. package/dist/web-ui/assets/{index-BVZKeNvh.js → index-lNtr_En-.js} +55 -55
  41. package/dist/web-ui/assets/{infoDiagram-5YYISTIA-bUkRpixn.js → infoDiagram-5YYISTIA-DU_r7Q4O.js} +1 -1
  42. package/dist/web-ui/assets/{ishikawaDiagram-YF4QCWOH-C71uSHjN.js → ishikawaDiagram-YF4QCWOH-C7M7fHbe.js} +1 -1
  43. package/dist/web-ui/assets/{journeyDiagram-JHISSGLW-CH4cq7H3.js → journeyDiagram-JHISSGLW-DQJbMKSV.js} +1 -1
  44. package/dist/web-ui/assets/{kanban-definition-UN3LZRKU-B1plHCmn.js → kanban-definition-UN3LZRKU-D8nO46ug.js} +1 -1
  45. package/dist/web-ui/assets/{mermaid.core-BtKFJxef.js → mermaid.core-D9X_B1hr.js} +5 -5
  46. package/dist/web-ui/assets/{mindmap-definition-RKZ34NQL-BRinAMnx.js → mindmap-definition-RKZ34NQL-BoWfA0x3.js} +1 -1
  47. package/dist/web-ui/assets/{pieDiagram-4H26LBE5-B8r7cm8D.js → pieDiagram-4H26LBE5-GeMxJnY4.js} +1 -1
  48. package/dist/web-ui/assets/{quadrantDiagram-W4KKPZXB-BlYE_3Bv.js → quadrantDiagram-W4KKPZXB-B5xQl44f.js} +1 -1
  49. package/dist/web-ui/assets/{requirementDiagram-4Y6WPE33-XHqns5Oh.js → requirementDiagram-4Y6WPE33-DAecntg7.js} +1 -1
  50. package/dist/web-ui/assets/{sankeyDiagram-5OEKKPKP--WceN9u7.js → sankeyDiagram-5OEKKPKP-DOLj0rKK.js} +1 -1
  51. package/dist/web-ui/assets/{sequenceDiagram-3UESZ5HK-NXQDJA2d.js → sequenceDiagram-3UESZ5HK-BvS7cOXA.js} +1 -1
  52. package/dist/web-ui/assets/{stateDiagram-AJRCARHV-Cs8Vl8wX.js → stateDiagram-AJRCARHV-CqHRpjfn.js} +1 -1
  53. package/dist/web-ui/assets/stateDiagram-v2-BHNVJYJU-Df743oiT.js +1 -0
  54. package/dist/web-ui/assets/{timeline-definition-PNZ67QCA-V9TBhcGA.js → timeline-definition-PNZ67QCA-Bsk6HQIz.js} +1 -1
  55. package/dist/web-ui/assets/{vennDiagram-CIIHVFJN-BkrjAkwE.js → vennDiagram-CIIHVFJN-CekJLx4L.js} +1 -1
  56. package/dist/web-ui/assets/{wardley-L42UT6IY-DnYl7xFk.js → wardley-L42UT6IY-CBUmu8Xa.js} +1 -1
  57. package/dist/web-ui/assets/{wardleyDiagram-YWT4CUSO-Bgjk8gUy.js → wardleyDiagram-YWT4CUSO-BgoDq86Z.js} +1 -1
  58. package/dist/web-ui/assets/{xychartDiagram-2RQKCTM6-DVv-I1Er.js → xychartDiagram-2RQKCTM6-zDxkTG1v.js} +1 -1
  59. package/dist/web-ui/index.html +2 -2
  60. package/package.json +1 -1
  61. package/dist/web-ui/assets/Notifications-DMI9cmK5.js +0 -1
  62. package/dist/web-ui/assets/Team-D8m98W3b.js +0 -40
  63. package/dist/web-ui/assets/channel-0x_SxlyN.js +0 -1
  64. package/dist/web-ui/assets/classDiagram-4FO5ZUOK-D4o-x8Tr.js +0 -1
  65. package/dist/web-ui/assets/classDiagram-v2-Q7XG4LA2-D4o-x8Tr.js +0 -1
  66. package/dist/web-ui/assets/index-BDWvYwl1.css +0 -1
  67. package/dist/web-ui/assets/stateDiagram-v2-BHNVJYJU-Cmof_fUq.js +0 -1
@@ -1 +1 @@
1
- import{j as t,u as T,r as a,e as ee}from"./index-BVZKeNvh.js";const te=1920,ne=10*1024*1024,W=5,re=.8;function se(l,u,i){return new Promise((g,f)=>{const y=new Image;y.onload=()=>{let{width:s,height:r}=y;if(s<=u&&r<=u){g(l);return}s>r?(r=Math.round(r*(u/s)),s=u):(s=Math.round(s*(u/r)),r=u);const x=document.createElement("canvas");x.width=s,x.height=r;const b=x.getContext("2d");if(!b){f(new Error("Failed to get canvas context"));return}b.drawImage(y,0,0,s,r),g(x.toDataURL("image/jpeg",i))},y.onerror=()=>f(new Error("Failed to load image")),y.src=l})}function ae({candidates:l,filter:u,anchorRef:i,onSelect:g,selectedIndex:f,onIndexChange:y}){const{t:s}=T("common"),[r,x]=a.useState(null),b=a.useRef(null),w=l.filter(d=>d.name.toLowerCase().includes(u));return a.useEffect(()=>{const d=i.current;if(!d)return;const h=d.getBoundingClientRect();x({top:h.top+window.scrollY-4,left:h.left+window.scrollX+8})},[i,u]),a.useEffect(()=>{if(!b.current||!r)return;if(b.current.getBoundingClientRect().top<8){const h=i.current;if(!h)return;const c=h.getBoundingClientRect();x({top:c.bottom+window.scrollY+4,left:r.left})}},[r,i]),a.useEffect(()=>{f>=w.length&&y(Math.max(0,w.length-1))},[w.length,f,y]),a.useEffect(()=>{if(!b.current)return;b.current.querySelector('[data-selected="true"]')?.scrollIntoView({block:"nearest"})},[f]),!r||w.length===0?null:ee.createPortal(t.jsxs("div",{ref:b,style:{position:"absolute",top:r.top,left:r.left,transform:"translateY(-100%)"},className:"w-60 bg-surface-overlay border border-border-default rounded-lg shadow-xl z-[9999] max-h-48 overflow-y-auto",children:[t.jsx("div",{className:"px-2.5 py-1.5 text-[10px] text-fg-tertiary font-medium uppercase tracking-wider border-b border-border-default",children:s("commentInput.mentionHeading")}),w.map((d,h)=>t.jsxs("button",{"data-selected":h===f,onMouseDown:c=>{c.preventDefault(),g(d)},onMouseEnter:()=>y(h),className:`w-full text-left px-3 py-2 text-xs flex items-center gap-2 transition-colors ${h===f?"bg-brand-500/15 text-brand-500":"hover:bg-surface-elevated"}`,children:[t.jsx("span",{className:`w-6 h-6 rounded-full flex items-center justify-center text-[10px] font-bold shrink-0 ${d.type==="human"?"bg-green-500/20 text-green-500":"bg-brand-500/20 text-brand-500"}`,children:d.name.slice(0,2).toUpperCase()}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("span",{className:"text-fg-primary font-medium",children:d.name}),t.jsx("span",{className:"text-fg-tertiary text-[10px] ml-1.5",children:d.subtitle??d.type})]}),d.type==="agent"&&t.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${d.online?"bg-green-400":"bg-gray-500"}`})]},d.id))]}),document.body)}function oe(l){return/^\w+$/.test(l)?`@${l}`:`@[${l}]`}const K=/@\[([^\]]+)\]|@([\w\p{L}\p{N}]+)/gu;function ie(l){const u=[];let i;for(K.lastIndex=0;(i=K.exec(l))!==null;)u.push(i[1]??i[2]);return u}function ce(l,u,i){const g=[];let f=0;const y=u.map(r=>r.name).sort((r,x)=>x.length-r.length);let s=0;for(;s<l.length;){const r=l.indexOf("@",s);if(r<0){g.push(t.jsx("span",{children:l.slice(s)},f++));break}if(r>s&&g.push(t.jsx("span",{children:l.slice(s,r)},f++)),l[r+1]==="["){const c=l.indexOf("]",r+2);if(c>r+2){const m=l.slice(r+2,c),j=u.find(k=>k.name.toLowerCase()===m.toLowerCase());g.push(t.jsxs("span",{className:`text-brand-500 font-medium ${i&&j?"cursor-pointer hover:underline":""}`,onClick:i&&j?k=>i(j,k):void 0,title:j?`${j.name} (${j.role})`:void 0,children:["@",m]},f++)),s=c+1;continue}}const x=l.slice(r+1),b=x.toLowerCase(),w=y.find(c=>b.startsWith(c.toLowerCase()));if(w){const c=u.find(m=>m.name.toLowerCase()===w.toLowerCase());g.push(t.jsxs("span",{className:`text-brand-500 font-medium ${i&&c?"cursor-pointer hover:underline":""}`,onClick:i&&c?m=>i(c,m):void 0,title:c?`${c.name} (${c.role})`:void 0,children:["@",w]},f++)),s=r+1+w.length;continue}const d=/^([\w\p{L}\p{N}]+)/u,h=x.match(d);if(h){const c=h[1],m=u.find(j=>j.name.toLowerCase()===c.toLowerCase());g.push(t.jsxs("span",{className:`text-brand-500 font-medium ${i&&m?"cursor-pointer hover:underline":""}`,onClick:i&&m?j=>i(m,j):void 0,title:m?`${m.name} (${m.role})`:void 0,children:["@",c]},f++)),s=r+1+c.length;continue}g.push(t.jsx("span",{children:"@"},f++)),s=r+1}return g.length>0?g:[t.jsx("span",{children:l},0)]}function de({agents:l,humans:u,onSubmit:i,placeholder:g,replyTo:f,onCancelReply:y}){const{t:s}=T("common"),[r,x]=a.useState(""),[b,w]=a.useState(!1),[d,h]=a.useState(null),[c,m]=a.useState(!1),[j,k]=a.useState(""),[C,S]=a.useState([]),[B,I]=a.useState(0),[N,M]=a.useState([]),[z,A]=a.useState(!1),F=a.useRef(null),U=a.useRef(null),L=a.useRef(null),$=a.useMemo(()=>{const e=(u??[]).map(n=>({id:n.id,name:n.name,type:"human",subtitle:n.role}));for(const n of l)e.push({id:n.id,name:n.name,type:"agent",subtitle:n.role,online:n.status==="idle"||n.status==="working"});return e},[l,u]),D=$.filter(e=>e.name.toLowerCase().includes(j)),E=a.useCallback(e=>{const n=Array.from(e).filter(o=>o.type.startsWith("image/"));if(n.length!==0)for(const o of n){if(o.size>ne)continue;const p=new FileReader;p.onload=()=>{const R=p.result;se(R,te,re).then(v=>{M(_=>_.length>=W?_:[..._,{id:`img_${Date.now()}_${Math.random().toString(36).slice(2,6)}`,dataUrl:v,name:o.name}])})},p.readAsDataURL(o)}},[]),X=a.useCallback(e=>{M(n=>n.filter(o=>o.id!==e))},[]),Y=a.useCallback(e=>{const n=e.clipboardData?.files;if(n&&n.length>0){const o=Array.from(n).filter(p=>p.type.startsWith("image/"));o.length>0&&(e.preventDefault(),E(o))}},[E]),q=a.useCallback(e=>{e.preventDefault(),A(!1);const n=e.dataTransfer?.files;n&&n.length>0&&E(Array.from(n).filter(o=>o.type.startsWith("image/")))},[E]),G=a.useCallback(e=>{e.preventDefault(),A(!0)},[]),H=a.useCallback(()=>{A(!1)},[]),O=async()=>{if(!(!r.trim()&&N.length===0)){w(!0),h(null),L.current={content:r,mentions:[...C],images:[...N]};try{await i(r,C,[...N],f?.id),x(""),S([]),M([]),L.current=null,y?.()}catch(e){h(String(e instanceof Error?e.message:e)||s("commentInput.sendFailed"))}w(!1)}},Q=async()=>{if(!L.current)return;const{content:e,mentions:n,images:o}=L.current;w(!0),h(null);try{await i(e,n,o),x(""),S([]),M([]),L.current=null}catch(p){h(String(p instanceof Error?p.message:p)||s("commentInput.sendFailed"))}w(!1)},P=a.useCallback(e=>{x(n=>{const o=n.lastIndexOf("@"),p=oe(e.name);return o>=0?n.slice(0,o)+p+" ":n+p+" "}),C.includes(e.id)||S(n=>[...n,e.id]),m(!1),k(""),I(0),F.current?.focus()},[C]),V=e=>{x(e),h(null);const n=e.lastIndexOf("@");if(n>=0&&(n===0||e[n-1]===" ")){const p=e.slice(n+1).toLowerCase();if($.some(v=>v.name.toLowerCase().includes(p))){k(p),m(!0),I(0);return}}m(!1)},Z=e=>{if(c&&D.length>0){const n=e.key==="ArrowUp"||e.ctrlKey&&e.key==="p",o=e.key==="ArrowDown"||e.ctrlKey&&e.key==="n",p=e.key==="Enter"||e.key==="Tab",R=e.key==="Escape";if(n){e.preventDefault(),I(v=>(v-1+D.length)%D.length);return}if(o){e.preventDefault(),I(v=>(v+1)%D.length);return}if(p){e.preventDefault();const v=D[B];v&&P(v);return}if(R){e.preventDefault(),m(!1);return}}e.key==="Enter"&&!e.shiftKey&&(e.preventDefault(),O())},J=a.useCallback(()=>{setTimeout(()=>m(!1),200)},[]);return t.jsxs("div",{className:"relative",onDragOver:G,onDragLeave:H,onDrop:q,children:[z&&t.jsx("div",{className:"absolute inset-0 z-50 flex items-center justify-center bg-brand-500/10 rounded-lg border-2 border-dashed border-brand-500",children:t.jsx("span",{className:"text-sm text-brand-500 font-medium",children:s("commentInput.dragDropHint")})}),c&&t.jsx(ae,{candidates:$,filter:j,anchorRef:F,onSelect:P,selectedIndex:B,onIndexChange:I}),t.jsxs("div",{className:"border border-border-default rounded-lg bg-surface-elevated",children:[f&&t.jsxs("div",{className:"flex items-center gap-2 px-2.5 pt-2 pb-1 border-b border-border-default/50",children:[t.jsxs("div",{className:"flex-1 min-w-0 pl-2 border-l-2 border-brand-500/50",children:[t.jsx("span",{className:"text-[10px] font-medium text-brand-500",children:f.authorName}),t.jsx("p",{className:"text-[10px] text-fg-tertiary truncate",children:f.content})]}),t.jsx("button",{onClick:y,className:"text-fg-tertiary hover:text-fg-secondary shrink-0 p-0.5",children:t.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),t.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),C.length>0&&t.jsx("div",{className:"flex gap-1 px-2.5 pt-2 flex-wrap",children:C.map(e=>{const n=$.find(o=>o.id===e);return t.jsxs("span",{className:`inline-flex items-center gap-1 px-1.5 py-0.5 text-[10px] rounded-full ${n?.type==="human"?"bg-green-500/15 text-green-500":"bg-brand-500/15 text-brand-500"}`,children:["@",n?.name??e,t.jsx("button",{onClick:()=>S(o=>o.filter(p=>p!==e)),className:"hover:text-red-400",children:"×"})]},e)})}),t.jsx("textarea",{ref:F,value:r,onChange:e=>V(e.target.value),onKeyDown:Z,onBlur:J,onPaste:Y,placeholder:g??s("commentInput.placeholder"),rows:2,className:"w-full px-2.5 py-2 text-xs bg-transparent text-fg-primary placeholder-fg-tertiary outline-none resize-none"}),N.length>0&&t.jsx("div",{className:"flex items-center gap-1.5 px-2.5 pb-1.5 overflow-x-auto",children:N.map(e=>t.jsxs("div",{className:"relative group/img shrink-0",children:[t.jsx("img",{src:e.dataUrl,alt:e.name,className:"w-12 h-12 rounded-lg object-cover border border-border-default"}),t.jsx("button",{onClick:()=>X(e.id),className:"absolute -top-1.5 -right-1.5 w-4 h-4 bg-surface-secondary border border-gray-600 rounded-full flex items-center justify-center text-fg-secondary hover:text-red-500 hover:border-red-500 text-[10px] opacity-0 group-hover/img:opacity-100 transition-opacity",title:s("commentInput.removeImage"),children:"×"})]},e.id))}),d&&t.jsxs("div",{className:"flex items-center gap-2 px-2.5 pb-1.5",children:[t.jsx("span",{className:"text-[11px] text-red-400 flex-1 truncate",children:d}),t.jsxs("button",{onClick:Q,disabled:b,className:"text-[11px] text-amber-500 hover:text-amber-400 font-medium transition-colors flex items-center gap-1",children:[t.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[t.jsx("polyline",{points:"23 4 23 10 17 10"}),t.jsx("path",{d:"M20.49 15a9 9 0 11-2.12-9.36L23 10"})]}),s("commentInput.retry")]})]}),t.jsxs("div",{className:"flex items-center justify-between px-2.5 pb-2",children:[t.jsx("button",{type:"button",onClick:()=>U.current?.click(),disabled:b||N.length>=W,className:"p-1 text-fg-tertiary hover:text-brand-500 disabled:opacity-30 disabled:cursor-not-allowed transition-colors",title:s("commentInput.attachImage"),children:t.jsxs("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"}),t.jsx("circle",{cx:"8.5",cy:"8.5",r:"1.5"}),t.jsx("polyline",{points:"21 15 16 10 5 21"})]})}),t.jsx("input",{ref:U,type:"file",accept:"image/*",multiple:!0,className:"hidden",onChange:e=>{e.target.files&&E(e.target.files),e.target.value=""}}),t.jsx("button",{onClick:O,disabled:!r.trim()&&N.length===0||b,className:"px-3 py-1 text-[11px] font-medium bg-brand-500 text-white rounded-md hover:bg-brand-600 disabled:opacity-40 disabled:cursor-not-allowed transition-colors",children:s(b?"commentInput.sending":"commentInput.submit")})]})]}),t.jsx("p",{className:"mt-1 text-center text-[10px] text-fg-tertiary/80 select-none",children:s("aiDisclaimer")})]})}export{de as C,ie as p,ce as r};
1
+ import{j as t,u as T,r as a,e as ee}from"./index-lNtr_En-.js";const te=1920,ne=10*1024*1024,W=5,re=.8;function se(l,u,i){return new Promise((g,f)=>{const y=new Image;y.onload=()=>{let{width:s,height:r}=y;if(s<=u&&r<=u){g(l);return}s>r?(r=Math.round(r*(u/s)),s=u):(s=Math.round(s*(u/r)),r=u);const x=document.createElement("canvas");x.width=s,x.height=r;const b=x.getContext("2d");if(!b){f(new Error("Failed to get canvas context"));return}b.drawImage(y,0,0,s,r),g(x.toDataURL("image/jpeg",i))},y.onerror=()=>f(new Error("Failed to load image")),y.src=l})}function ae({candidates:l,filter:u,anchorRef:i,onSelect:g,selectedIndex:f,onIndexChange:y}){const{t:s}=T("common"),[r,x]=a.useState(null),b=a.useRef(null),w=l.filter(d=>d.name.toLowerCase().includes(u));return a.useEffect(()=>{const d=i.current;if(!d)return;const h=d.getBoundingClientRect();x({top:h.top+window.scrollY-4,left:h.left+window.scrollX+8})},[i,u]),a.useEffect(()=>{if(!b.current||!r)return;if(b.current.getBoundingClientRect().top<8){const h=i.current;if(!h)return;const c=h.getBoundingClientRect();x({top:c.bottom+window.scrollY+4,left:r.left})}},[r,i]),a.useEffect(()=>{f>=w.length&&y(Math.max(0,w.length-1))},[w.length,f,y]),a.useEffect(()=>{if(!b.current)return;b.current.querySelector('[data-selected="true"]')?.scrollIntoView({block:"nearest"})},[f]),!r||w.length===0?null:ee.createPortal(t.jsxs("div",{ref:b,style:{position:"absolute",top:r.top,left:r.left,transform:"translateY(-100%)"},className:"w-60 bg-surface-overlay border border-border-default rounded-lg shadow-xl z-[9999] max-h-48 overflow-y-auto",children:[t.jsx("div",{className:"px-2.5 py-1.5 text-[10px] text-fg-tertiary font-medium uppercase tracking-wider border-b border-border-default",children:s("commentInput.mentionHeading")}),w.map((d,h)=>t.jsxs("button",{"data-selected":h===f,onMouseDown:c=>{c.preventDefault(),g(d)},onMouseEnter:()=>y(h),className:`w-full text-left px-3 py-2 text-xs flex items-center gap-2 transition-colors ${h===f?"bg-brand-500/15 text-brand-500":"hover:bg-surface-elevated"}`,children:[t.jsx("span",{className:`w-6 h-6 rounded-full flex items-center justify-center text-[10px] font-bold shrink-0 ${d.type==="human"?"bg-green-500/20 text-green-500":"bg-brand-500/20 text-brand-500"}`,children:d.name.slice(0,2).toUpperCase()}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("span",{className:"text-fg-primary font-medium",children:d.name}),t.jsx("span",{className:"text-fg-tertiary text-[10px] ml-1.5",children:d.subtitle??d.type})]}),d.type==="agent"&&t.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${d.online?"bg-green-400":"bg-gray-500"}`})]},d.id))]}),document.body)}function oe(l){return/^\w+$/.test(l)?`@${l}`:`@[${l}]`}const K=/@\[([^\]]+)\]|@([\w\p{L}\p{N}]+)/gu;function ie(l){const u=[];let i;for(K.lastIndex=0;(i=K.exec(l))!==null;)u.push(i[1]??i[2]);return u}function ce(l,u,i){const g=[];let f=0;const y=u.map(r=>r.name).sort((r,x)=>x.length-r.length);let s=0;for(;s<l.length;){const r=l.indexOf("@",s);if(r<0){g.push(t.jsx("span",{children:l.slice(s)},f++));break}if(r>s&&g.push(t.jsx("span",{children:l.slice(s,r)},f++)),l[r+1]==="["){const c=l.indexOf("]",r+2);if(c>r+2){const m=l.slice(r+2,c),j=u.find(k=>k.name.toLowerCase()===m.toLowerCase());g.push(t.jsxs("span",{className:`text-brand-500 font-medium ${i&&j?"cursor-pointer hover:underline":""}`,onClick:i&&j?k=>i(j,k):void 0,title:j?`${j.name} (${j.role})`:void 0,children:["@",m]},f++)),s=c+1;continue}}const x=l.slice(r+1),b=x.toLowerCase(),w=y.find(c=>b.startsWith(c.toLowerCase()));if(w){const c=u.find(m=>m.name.toLowerCase()===w.toLowerCase());g.push(t.jsxs("span",{className:`text-brand-500 font-medium ${i&&c?"cursor-pointer hover:underline":""}`,onClick:i&&c?m=>i(c,m):void 0,title:c?`${c.name} (${c.role})`:void 0,children:["@",w]},f++)),s=r+1+w.length;continue}const d=/^([\w\p{L}\p{N}]+)/u,h=x.match(d);if(h){const c=h[1],m=u.find(j=>j.name.toLowerCase()===c.toLowerCase());g.push(t.jsxs("span",{className:`text-brand-500 font-medium ${i&&m?"cursor-pointer hover:underline":""}`,onClick:i&&m?j=>i(m,j):void 0,title:m?`${m.name} (${m.role})`:void 0,children:["@",c]},f++)),s=r+1+c.length;continue}g.push(t.jsx("span",{children:"@"},f++)),s=r+1}return g.length>0?g:[t.jsx("span",{children:l},0)]}function de({agents:l,humans:u,onSubmit:i,placeholder:g,replyTo:f,onCancelReply:y}){const{t:s}=T("common"),[r,x]=a.useState(""),[b,w]=a.useState(!1),[d,h]=a.useState(null),[c,m]=a.useState(!1),[j,k]=a.useState(""),[C,S]=a.useState([]),[B,I]=a.useState(0),[N,M]=a.useState([]),[z,A]=a.useState(!1),F=a.useRef(null),U=a.useRef(null),L=a.useRef(null),$=a.useMemo(()=>{const e=(u??[]).map(n=>({id:n.id,name:n.name,type:"human",subtitle:n.role}));for(const n of l)e.push({id:n.id,name:n.name,type:"agent",subtitle:n.role,online:n.status==="idle"||n.status==="working"});return e},[l,u]),D=$.filter(e=>e.name.toLowerCase().includes(j)),E=a.useCallback(e=>{const n=Array.from(e).filter(o=>o.type.startsWith("image/"));if(n.length!==0)for(const o of n){if(o.size>ne)continue;const p=new FileReader;p.onload=()=>{const R=p.result;se(R,te,re).then(v=>{M(_=>_.length>=W?_:[..._,{id:`img_${Date.now()}_${Math.random().toString(36).slice(2,6)}`,dataUrl:v,name:o.name}])})},p.readAsDataURL(o)}},[]),X=a.useCallback(e=>{M(n=>n.filter(o=>o.id!==e))},[]),Y=a.useCallback(e=>{const n=e.clipboardData?.files;if(n&&n.length>0){const o=Array.from(n).filter(p=>p.type.startsWith("image/"));o.length>0&&(e.preventDefault(),E(o))}},[E]),q=a.useCallback(e=>{e.preventDefault(),A(!1);const n=e.dataTransfer?.files;n&&n.length>0&&E(Array.from(n).filter(o=>o.type.startsWith("image/")))},[E]),G=a.useCallback(e=>{e.preventDefault(),A(!0)},[]),H=a.useCallback(()=>{A(!1)},[]),O=async()=>{if(!(!r.trim()&&N.length===0)){w(!0),h(null),L.current={content:r,mentions:[...C],images:[...N]};try{await i(r,C,[...N],f?.id),x(""),S([]),M([]),L.current=null,y?.()}catch(e){h(String(e instanceof Error?e.message:e)||s("commentInput.sendFailed"))}w(!1)}},Q=async()=>{if(!L.current)return;const{content:e,mentions:n,images:o}=L.current;w(!0),h(null);try{await i(e,n,o),x(""),S([]),M([]),L.current=null}catch(p){h(String(p instanceof Error?p.message:p)||s("commentInput.sendFailed"))}w(!1)},P=a.useCallback(e=>{x(n=>{const o=n.lastIndexOf("@"),p=oe(e.name);return o>=0?n.slice(0,o)+p+" ":n+p+" "}),C.includes(e.id)||S(n=>[...n,e.id]),m(!1),k(""),I(0),F.current?.focus()},[C]),V=e=>{x(e),h(null);const n=e.lastIndexOf("@");if(n>=0&&(n===0||e[n-1]===" ")){const p=e.slice(n+1).toLowerCase();if($.some(v=>v.name.toLowerCase().includes(p))){k(p),m(!0),I(0);return}}m(!1)},Z=e=>{if(c&&D.length>0){const n=e.key==="ArrowUp"||e.ctrlKey&&e.key==="p",o=e.key==="ArrowDown"||e.ctrlKey&&e.key==="n",p=e.key==="Enter"||e.key==="Tab",R=e.key==="Escape";if(n){e.preventDefault(),I(v=>(v-1+D.length)%D.length);return}if(o){e.preventDefault(),I(v=>(v+1)%D.length);return}if(p){e.preventDefault();const v=D[B];v&&P(v);return}if(R){e.preventDefault(),m(!1);return}}e.key==="Enter"&&!e.shiftKey&&(e.preventDefault(),O())},J=a.useCallback(()=>{setTimeout(()=>m(!1),200)},[]);return t.jsxs("div",{className:"relative",onDragOver:G,onDragLeave:H,onDrop:q,children:[z&&t.jsx("div",{className:"absolute inset-0 z-50 flex items-center justify-center bg-brand-500/10 rounded-lg border-2 border-dashed border-brand-500",children:t.jsx("span",{className:"text-sm text-brand-500 font-medium",children:s("commentInput.dragDropHint")})}),c&&t.jsx(ae,{candidates:$,filter:j,anchorRef:F,onSelect:P,selectedIndex:B,onIndexChange:I}),t.jsxs("div",{className:"border border-border-default rounded-lg bg-surface-elevated",children:[f&&t.jsxs("div",{className:"flex items-center gap-2 px-2.5 pt-2 pb-1 border-b border-border-default/50",children:[t.jsxs("div",{className:"flex-1 min-w-0 pl-2 border-l-2 border-brand-500/50",children:[t.jsx("span",{className:"text-[10px] font-medium text-brand-500",children:f.authorName}),t.jsx("p",{className:"text-[10px] text-fg-tertiary truncate",children:f.content})]}),t.jsx("button",{onClick:y,className:"text-fg-tertiary hover:text-fg-secondary shrink-0 p-0.5",children:t.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),t.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),C.length>0&&t.jsx("div",{className:"flex gap-1 px-2.5 pt-2 flex-wrap",children:C.map(e=>{const n=$.find(o=>o.id===e);return t.jsxs("span",{className:`inline-flex items-center gap-1 px-1.5 py-0.5 text-[10px] rounded-full ${n?.type==="human"?"bg-green-500/15 text-green-500":"bg-brand-500/15 text-brand-500"}`,children:["@",n?.name??e,t.jsx("button",{onClick:()=>S(o=>o.filter(p=>p!==e)),className:"hover:text-red-400",children:"×"})]},e)})}),t.jsx("textarea",{ref:F,value:r,onChange:e=>V(e.target.value),onKeyDown:Z,onBlur:J,onPaste:Y,placeholder:g??s("commentInput.placeholder"),rows:2,className:"w-full px-2.5 py-2 text-xs bg-transparent text-fg-primary placeholder-fg-tertiary outline-none resize-none"}),N.length>0&&t.jsx("div",{className:"flex items-center gap-1.5 px-2.5 pb-1.5 overflow-x-auto",children:N.map(e=>t.jsxs("div",{className:"relative group/img shrink-0",children:[t.jsx("img",{src:e.dataUrl,alt:e.name,className:"w-12 h-12 rounded-lg object-cover border border-border-default"}),t.jsx("button",{onClick:()=>X(e.id),className:"absolute -top-1.5 -right-1.5 w-4 h-4 bg-surface-secondary border border-gray-600 rounded-full flex items-center justify-center text-fg-secondary hover:text-red-500 hover:border-red-500 text-[10px] opacity-0 group-hover/img:opacity-100 transition-opacity",title:s("commentInput.removeImage"),children:"×"})]},e.id))}),d&&t.jsxs("div",{className:"flex items-center gap-2 px-2.5 pb-1.5",children:[t.jsx("span",{className:"text-[11px] text-red-400 flex-1 truncate",children:d}),t.jsxs("button",{onClick:Q,disabled:b,className:"text-[11px] text-amber-500 hover:text-amber-400 font-medium transition-colors flex items-center gap-1",children:[t.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[t.jsx("polyline",{points:"23 4 23 10 17 10"}),t.jsx("path",{d:"M20.49 15a9 9 0 11-2.12-9.36L23 10"})]}),s("commentInput.retry")]})]}),t.jsxs("div",{className:"flex items-center justify-between px-2.5 pb-2",children:[t.jsx("button",{type:"button",onClick:()=>U.current?.click(),disabled:b||N.length>=W,className:"p-1 text-fg-tertiary hover:text-brand-500 disabled:opacity-30 disabled:cursor-not-allowed transition-colors",title:s("commentInput.attachImage"),children:t.jsxs("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"}),t.jsx("circle",{cx:"8.5",cy:"8.5",r:"1.5"}),t.jsx("polyline",{points:"21 15 16 10 5 21"})]})}),t.jsx("input",{ref:U,type:"file",accept:"image/*",multiple:!0,className:"hidden",onChange:e=>{e.target.files&&E(e.target.files),e.target.value=""}}),t.jsx("button",{onClick:O,disabled:!r.trim()&&N.length===0||b,className:"px-3 py-1 text-[11px] font-medium bg-brand-500 text-white rounded-md hover:bg-brand-600 disabled:opacity-40 disabled:cursor-not-allowed transition-colors",children:s(b?"commentInput.sending":"commentInput.submit")})]})]}),t.jsx("p",{className:"mt-1 text-center text-[10px] text-fg-tertiary/80 select-none",children:s("aiDisclaimer")})]})}export{de as C,ie as p,ce as r};
@@ -1,5 +1,5 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-BVZKeNvh.js","assets/index-BDWvYwl1.css"])))=>i.map(i=>d[i]);
2
- import{j as i,r as s,_ as f}from"./index-BVZKeNvh.js";const b=s.lazy(()=>f(()=>import("./index-BVZKeNvh.js").then(e=>e.az),__vite__mapDeps([0,1])).then(e=>({default:e.MarkdownMessage})));function x(e){switch(e.split(".").pop()?.toLowerCase()){case"md":case"markdown":return"markdown";case"html":case"htm":return"html";case"json":return"json";case"csv":case"tsv":return"csv";default:return}}function w(e){const t=e.trimStart();if(/^<!doctype\s+html/i.test(t)||/^<html[\s>]/i.test(t))return"html";if(t.startsWith("{")||t.startsWith("["))try{return JSON.parse(e),"json"}catch{}}function E(e){if(e.format)return e.format;if(e.reference){const t=x(e.reference);if(t)return t}if(e.content){const t=w(e.content);if(t)return t}return"markdown"}function v({content:e,className:t,onSelection:r}){const c=s.useRef(null),[l,g]=s.useState(null);s.useEffect(()=>{const o=d=>{d.data?.type==="__htmlpreview_height"&&typeof d.data.height=="number"&&g(d.data.height),d.data?.type==="__htmlpreview_selection"&&r&&r(d.data)};return window.addEventListener("message",o),()=>window.removeEventListener("message",o)},[r]);const h=`<script>
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-lNtr_En-.js","assets/index-CPULIfuW.css"])))=>i.map(i=>d[i]);
2
+ import{j as i,r as s,_ as f}from"./index-lNtr_En-.js";const b=s.lazy(()=>f(()=>import("./index-lNtr_En-.js").then(e=>e.aA),__vite__mapDeps([0,1])).then(e=>({default:e.MarkdownMessage})));function x(e){switch(e.split(".").pop()?.toLowerCase()){case"md":case"markdown":return"markdown";case"html":case"htm":return"html";case"json":return"json";case"csv":case"tsv":return"csv";default:return}}function w(e){const t=e.trimStart();if(/^<!doctype\s+html/i.test(t)||/^<html[\s>]/i.test(t))return"html";if(t.startsWith("{")||t.startsWith("["))try{return JSON.parse(e),"json"}catch{}}function E(e){if(e.format)return e.format;if(e.reference){const t=x(e.reference);if(t)return t}if(e.content){const t=w(e.content);if(t)return t}return"markdown"}function v({content:e,className:t,onSelection:r}){const c=s.useRef(null),[l,g]=s.useState(null);s.useEffect(()=>{const o=d=>{d.data?.type==="__htmlpreview_height"&&typeof d.data.height=="number"&&g(d.data.height),d.data?.type==="__htmlpreview_selection"&&r&&r(d.data)};return window.addEventListener("message",o),()=>window.removeEventListener("message",o)},[r]);const h=`<script>
3
3
  (function(){
4
4
  function getXPath(el){
5
5
  if(!el||el.nodeType!==1)return'';
@@ -1,4 +1,4 @@
1
- import{u as st,j as e,r as s,e as rs,A as xt,w as ft,s as as,g as Ot,f as L,k as os,l as ls,m as zt,o as is,p as cs,q as ds,t as tt,v as us,R as xs,x as fs,y as ms,z as ps,a as hs,B as gs,C as bs,b as ys,D as vs,P as Te,M as js,n as Ge,E as ws}from"./index-BVZKeNvh.js";import{resolveFormat as ks,ContentRenderer as Ns}from"./ContentRenderer-BbN7QT3E.js";function Ne(c){return Array.isArray(c)?c.map(h=>String(h).trim()).filter(Boolean):typeof c=="string"&&c?c.split(",").map(h=>h.trim()).filter(Boolean):[]}function Ss(c){return c.files&&typeof c.files=="object"&&!Array.isArray(c.files)?c.files:null}function Ue({label:c,value:h}){return h?e.jsxs("div",{children:[e.jsx("span",{className:"text-[10px] text-fg-tertiary uppercase tracking-wider",children:c}),e.jsx("div",{className:"text-xs text-fg-secondary mt-0.5",children:h})]}):null}function Ye({label:c,value:h,color:f}){if(!h)return null;const r={purple:"bg-brand-500/15 text-brand-500",cyan:"bg-blue-500/15 text-blue-600",indigo:"bg-brand-500/15 text-brand-500",gray:"bg-gray-500/15 text-fg-secondary",emerald:"bg-green-500/15 text-green-600"};return e.jsxs("div",{children:[e.jsx("span",{className:"text-[10px] text-fg-tertiary uppercase tracking-wider",children:c}),e.jsx("div",{className:`mt-0.5 px-2 py-0.5 rounded-full text-[10px] font-medium ${r[f]??r.gray} capitalize inline-block`,children:h})]})}function Nt({files:c}){const{t:h}=st(["builder","common"]),[f,r]=s.useState(Object.keys(c)[0]??""),v=Object.keys(c);return v.length===0?null:e.jsxs("div",{children:[e.jsx("span",{className:"text-[10px] text-fg-tertiary uppercase tracking-wider",children:h("builder:artifact.files",{count:v.length})}),e.jsxs("div",{className:"mt-1 bg-surface-elevated/50 rounded-lg border border-border-default/30 overflow-hidden",children:[e.jsx("div",{className:"flex gap-0.5 px-1.5 py-1 border-b border-border-default/30 overflow-x-auto",children:v.map(_=>e.jsx("button",{onClick:()=>r(_),className:`px-2 py-0.5 text-[10px] rounded whitespace-nowrap transition-colors ${f===_?"bg-brand-600/30 text-brand-500":"text-fg-tertiary hover:text-fg-secondary"}`,children:_},_))}),f&&c[f]!=null&&e.jsx("pre",{className:"p-2 text-[10px] text-fg-secondary max-h-[120px] overflow-auto whitespace-pre-wrap font-mono",children:c[f]})]})]})}function Cs({artifact:c,mode:h}){const{t:f}=st(["builder","common"]),r=Ss(c),v=c.agent,_=c.team,K=c.dependencies,z=c.displayName??c.name;if(h==="agent"){const U=v?.roleName,F=v?.agentRole,M=v?.llmProvider,q=v?.llmModel,E=Ne(K?.env),P=Ne(K?.skills);return e.jsxs("div",{className:"space-y-3 text-sm",children:[e.jsx(Ue,{label:f("builder:artifact.name"),value:z}),e.jsx(Ue,{label:f("builder:artifact.description"),value:c.description}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[U&&e.jsx(Ye,{label:f("builder:artifact.baseTemplate"),value:U,color:"indigo"}),e.jsx(Ye,{label:f("builder:artifact.agentRole"),value:F,color:F==="manager"?"purple":"cyan"})]}),Ne(c.tags).length>0&&e.jsx("div",{className:"flex flex-wrap gap-1",children:Ne(c.tags).map(k=>e.jsx("span",{className:"px-1.5 py-0.5 text-[10px] bg-surface-elevated text-fg-tertiary rounded",children:k},k))}),(M||q)&&e.jsxs("div",{className:"flex gap-2",children:[M&&e.jsx(Ye,{label:f("builder:artifact.llmProvider"),value:M,color:"gray"}),q&&e.jsx(Ye,{label:f("builder:artifact.llmModel"),value:q,color:"gray"})]}),E.length>0&&e.jsxs("div",{children:[e.jsx("span",{className:"text-[10px] text-fg-tertiary uppercase tracking-wider",children:f("builder:artifact.requiredEnv")}),e.jsx("div",{className:"flex flex-wrap gap-1 mt-1",children:E.map(k=>e.jsx("span",{className:"px-1.5 py-0.5 text-[10px] bg-amber-500/10 text-amber-600 rounded font-mono",children:k},k))})]}),P.length>0&&e.jsx(Ue,{label:f("builder:artifact.skills"),value:P.join(", ")}),r&&e.jsx(Nt,{files:r})]})}if(h==="team"){const F=_?.members??[];return e.jsxs("div",{className:"space-y-3 text-sm",children:[e.jsx(Ue,{label:f("builder:artifact.name"),value:z}),e.jsx(Ue,{label:f("builder:artifact.description"),value:c.description}),e.jsx("div",{className:"flex flex-wrap gap-2",children:e.jsx(Ye,{label:f("builder:artifact.category"),value:c.category,color:"indigo"})}),Ne(c.tags).length>0&&e.jsx("div",{className:"flex flex-wrap gap-1",children:Ne(c.tags).map(M=>e.jsx("span",{className:"px-1.5 py-0.5 text-[10px] bg-surface-elevated text-fg-tertiary rounded",children:M},M))}),r&&e.jsx(Nt,{files:r}),e.jsxs("div",{children:[e.jsx("span",{className:"text-[10px] text-fg-tertiary uppercase tracking-wider",children:f("builder:artifact.members",{count:F.length})}),e.jsx("div",{className:"mt-1.5 space-y-1.5",children:F.map((M,q)=>e.jsxs("div",{className:"bg-surface-elevated/30 rounded-lg px-2 py-1.5 border border-border-default/20",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`w-5 h-5 rounded flex items-center justify-center text-[10px] font-bold ${M.role==="manager"?"bg-brand-500/20 text-brand-500":"bg-blue-500/20 text-blue-600"}`,children:M.role==="manager"?"★":q+1}),e.jsx("span",{className:"text-xs text-fg-secondary flex-1 truncate",children:M.name}),typeof M.roleName=="string"&&M.roleName&&e.jsx("span",{className:"text-[10px] text-brand-500/70 font-mono",children:M.roleName}),e.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:["x",String(M.count??1)]})]}),Ne(M.skills).length>0&&e.jsx("div",{className:"mt-1 ml-7 flex flex-wrap gap-1",children:Ne(M.skills).map(E=>e.jsx("span",{className:"px-1 py-0.5 text-[9px] bg-green-500/10 text-green-600 rounded font-mono",children:E},E))})]},q))})]})]})}return e.jsxs("div",{className:"space-y-3 text-sm",children:[e.jsx(Ue,{label:f("builder:artifact.name"),value:z}),e.jsx(Ue,{label:f("builder:artifact.description"),value:c.description}),e.jsx("div",{className:"flex gap-2",children:e.jsx(Ye,{label:f("builder:artifact.category"),value:c.category,color:"indigo"})}),r&&e.jsx(Nt,{files:r}),Ne(c.tags).length>0&&e.jsx("div",{className:"flex flex-wrap gap-1",children:Ne(c.tags).map(U=>e.jsx("span",{className:"px-1.5 py-0.5 text-[10px] bg-surface-elevated text-fg-tertiary rounded",children:U},U))})]})}const Ut={agent:"🤖",project:"📁",requirement:"📋",task:"✅",deliverable:"📦",workflow:"⚙️"},Is=["project","requirement","task","deliverable","workflow","agent"];function Vt(c){return c.dataUrl.startsWith("data:image/")}function Ls(c,h){if(Vt({dataUrl:h}))return null;const f=c.split(".").pop()?.toLowerCase()??"";return{pdf:"📄",docx:"📝",doc:"📝",xlsx:"📊",xls:"📊",pptx:"📎",csv:"📊",json:"🔧",xml:"🔧",html:"🌐",epub:"📚"}[f]??"📁"}function Ms({value:c,onChange:h,onSend:f,disabled:r=!1,placeholder:v="",sending:_=!1,onStop:K,contextChips:z,mentionItems:U,pendingFiles:F,onAttach:M,onPaste:q,onDrop:E,onDragOver:P,onRemoveFile:k,replyTo:Z,onClearReply:ne,fileInputRef:ge,visionWarning:We,maxFiles:Fe=5,className:Se="",compact:oe=!1,onMentionChipsChange:fe}){const{t:be}=st(["team","common"]),G=s.useRef(null),le=s.useRef(null);s.useRef(null);const[ie,ce]=s.useState(!1),[ye,me]=s.useState(""),[Y,J]=s.useState(0),[ee,ve]=s.useState(null),[W,Ce]=s.useState([]),n=(U??[]).filter(o=>o.name.toLowerCase().includes(ye)),de=(()=>{if(n.length===0)return[];const o=new Map;for(const O of n){const A=O.type??"agent";o.has(A)||o.set(A,[]),o.get(A).push(O)}const D=[];for(const O of Is){const A=o.get(O);A?.length&&D.push({type:O,items:A})}return D})();s.useEffect(()=>{if(!ie||!G.current){ve(null);return}const o=G.current.getBoundingClientRect();ve({left:o.left+16,bottom:window.innerHeight-o.top+4})},[ie]);const Ee=s.useCallback(()=>{const o=le.current;o&&(o.style.height="auto",o.style.height=`${Math.min(o.scrollHeight,oe?80:120)}px`)},[oe]);s.useEffect(()=>{Ee()},[c,Ee]);const He=s.useCallback(o=>{if(h(o),!U?.length){ce(!1);return}const D=le.current?.selectionStart??o.length,O=o.slice(0,D),A=O.lastIndexOf("@");if(A>=0){const V=A===0?"":O[A-1];if(A===0||/[\s\n,,。!?!?;;::、()()\[\]【】]/.test(V)){const re=O.slice(A+1);if(!re.includes(" ")&&!re.includes(`
1
+ import{u as st,j as e,r as s,e as rs,A as xt,w as ft,s as as,g as Ot,f as L,k as os,l as ls,m as zt,o as is,p as cs,q as ds,t as tt,v as us,R as xs,x as fs,y as ms,z as ps,a as hs,B as gs,C as bs,b as ys,D as vs,P as Te,M as js,n as Ge,E as ws}from"./index-lNtr_En-.js";import{resolveFormat as ks,ContentRenderer as Ns}from"./ContentRenderer-Ccoj5KhH.js";function Ne(c){return Array.isArray(c)?c.map(h=>String(h).trim()).filter(Boolean):typeof c=="string"&&c?c.split(",").map(h=>h.trim()).filter(Boolean):[]}function Ss(c){return c.files&&typeof c.files=="object"&&!Array.isArray(c.files)?c.files:null}function Ue({label:c,value:h}){return h?e.jsxs("div",{children:[e.jsx("span",{className:"text-[10px] text-fg-tertiary uppercase tracking-wider",children:c}),e.jsx("div",{className:"text-xs text-fg-secondary mt-0.5",children:h})]}):null}function Ye({label:c,value:h,color:f}){if(!h)return null;const r={purple:"bg-brand-500/15 text-brand-500",cyan:"bg-blue-500/15 text-blue-600",indigo:"bg-brand-500/15 text-brand-500",gray:"bg-gray-500/15 text-fg-secondary",emerald:"bg-green-500/15 text-green-600"};return e.jsxs("div",{children:[e.jsx("span",{className:"text-[10px] text-fg-tertiary uppercase tracking-wider",children:c}),e.jsx("div",{className:`mt-0.5 px-2 py-0.5 rounded-full text-[10px] font-medium ${r[f]??r.gray} capitalize inline-block`,children:h})]})}function Nt({files:c}){const{t:h}=st(["builder","common"]),[f,r]=s.useState(Object.keys(c)[0]??""),v=Object.keys(c);return v.length===0?null:e.jsxs("div",{children:[e.jsx("span",{className:"text-[10px] text-fg-tertiary uppercase tracking-wider",children:h("builder:artifact.files",{count:v.length})}),e.jsxs("div",{className:"mt-1 bg-surface-elevated/50 rounded-lg border border-border-default/30 overflow-hidden",children:[e.jsx("div",{className:"flex gap-0.5 px-1.5 py-1 border-b border-border-default/30 overflow-x-auto",children:v.map(_=>e.jsx("button",{onClick:()=>r(_),className:`px-2 py-0.5 text-[10px] rounded whitespace-nowrap transition-colors ${f===_?"bg-brand-600/30 text-brand-500":"text-fg-tertiary hover:text-fg-secondary"}`,children:_},_))}),f&&c[f]!=null&&e.jsx("pre",{className:"p-2 text-[10px] text-fg-secondary max-h-[120px] overflow-auto whitespace-pre-wrap font-mono",children:c[f]})]})]})}function Cs({artifact:c,mode:h}){const{t:f}=st(["builder","common"]),r=Ss(c),v=c.agent,_=c.team,K=c.dependencies,z=c.displayName??c.name;if(h==="agent"){const U=v?.roleName,F=v?.agentRole,M=v?.llmProvider,q=v?.llmModel,E=Ne(K?.env),P=Ne(K?.skills);return e.jsxs("div",{className:"space-y-3 text-sm",children:[e.jsx(Ue,{label:f("builder:artifact.name"),value:z}),e.jsx(Ue,{label:f("builder:artifact.description"),value:c.description}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[U&&e.jsx(Ye,{label:f("builder:artifact.baseTemplate"),value:U,color:"indigo"}),e.jsx(Ye,{label:f("builder:artifact.agentRole"),value:F,color:F==="manager"?"purple":"cyan"})]}),Ne(c.tags).length>0&&e.jsx("div",{className:"flex flex-wrap gap-1",children:Ne(c.tags).map(k=>e.jsx("span",{className:"px-1.5 py-0.5 text-[10px] bg-surface-elevated text-fg-tertiary rounded",children:k},k))}),(M||q)&&e.jsxs("div",{className:"flex gap-2",children:[M&&e.jsx(Ye,{label:f("builder:artifact.llmProvider"),value:M,color:"gray"}),q&&e.jsx(Ye,{label:f("builder:artifact.llmModel"),value:q,color:"gray"})]}),E.length>0&&e.jsxs("div",{children:[e.jsx("span",{className:"text-[10px] text-fg-tertiary uppercase tracking-wider",children:f("builder:artifact.requiredEnv")}),e.jsx("div",{className:"flex flex-wrap gap-1 mt-1",children:E.map(k=>e.jsx("span",{className:"px-1.5 py-0.5 text-[10px] bg-amber-500/10 text-amber-600 rounded font-mono",children:k},k))})]}),P.length>0&&e.jsx(Ue,{label:f("builder:artifact.skills"),value:P.join(", ")}),r&&e.jsx(Nt,{files:r})]})}if(h==="team"){const F=_?.members??[];return e.jsxs("div",{className:"space-y-3 text-sm",children:[e.jsx(Ue,{label:f("builder:artifact.name"),value:z}),e.jsx(Ue,{label:f("builder:artifact.description"),value:c.description}),e.jsx("div",{className:"flex flex-wrap gap-2",children:e.jsx(Ye,{label:f("builder:artifact.category"),value:c.category,color:"indigo"})}),Ne(c.tags).length>0&&e.jsx("div",{className:"flex flex-wrap gap-1",children:Ne(c.tags).map(M=>e.jsx("span",{className:"px-1.5 py-0.5 text-[10px] bg-surface-elevated text-fg-tertiary rounded",children:M},M))}),r&&e.jsx(Nt,{files:r}),e.jsxs("div",{children:[e.jsx("span",{className:"text-[10px] text-fg-tertiary uppercase tracking-wider",children:f("builder:artifact.members",{count:F.length})}),e.jsx("div",{className:"mt-1.5 space-y-1.5",children:F.map((M,q)=>e.jsxs("div",{className:"bg-surface-elevated/30 rounded-lg px-2 py-1.5 border border-border-default/20",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`w-5 h-5 rounded flex items-center justify-center text-[10px] font-bold ${M.role==="manager"?"bg-brand-500/20 text-brand-500":"bg-blue-500/20 text-blue-600"}`,children:M.role==="manager"?"★":q+1}),e.jsx("span",{className:"text-xs text-fg-secondary flex-1 truncate",children:M.name}),typeof M.roleName=="string"&&M.roleName&&e.jsx("span",{className:"text-[10px] text-brand-500/70 font-mono",children:M.roleName}),e.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:["x",String(M.count??1)]})]}),Ne(M.skills).length>0&&e.jsx("div",{className:"mt-1 ml-7 flex flex-wrap gap-1",children:Ne(M.skills).map(E=>e.jsx("span",{className:"px-1 py-0.5 text-[9px] bg-green-500/10 text-green-600 rounded font-mono",children:E},E))})]},q))})]})]})}return e.jsxs("div",{className:"space-y-3 text-sm",children:[e.jsx(Ue,{label:f("builder:artifact.name"),value:z}),e.jsx(Ue,{label:f("builder:artifact.description"),value:c.description}),e.jsx("div",{className:"flex gap-2",children:e.jsx(Ye,{label:f("builder:artifact.category"),value:c.category,color:"indigo"})}),r&&e.jsx(Nt,{files:r}),Ne(c.tags).length>0&&e.jsx("div",{className:"flex flex-wrap gap-1",children:Ne(c.tags).map(U=>e.jsx("span",{className:"px-1.5 py-0.5 text-[10px] bg-surface-elevated text-fg-tertiary rounded",children:U},U))})]})}const Ut={agent:"🤖",project:"📁",requirement:"📋",task:"✅",deliverable:"📦",workflow:"⚙️"},Is=["project","requirement","task","deliverable","workflow","agent"];function Vt(c){return c.dataUrl.startsWith("data:image/")}function Ls(c,h){if(Vt({dataUrl:h}))return null;const f=c.split(".").pop()?.toLowerCase()??"";return{pdf:"📄",docx:"📝",doc:"📝",xlsx:"📊",xls:"📊",pptx:"📎",csv:"📊",json:"🔧",xml:"🔧",html:"🌐",epub:"📚"}[f]??"📁"}function Ms({value:c,onChange:h,onSend:f,disabled:r=!1,placeholder:v="",sending:_=!1,onStop:K,contextChips:z,mentionItems:U,pendingFiles:F,onAttach:M,onPaste:q,onDrop:E,onDragOver:P,onRemoveFile:k,replyTo:Z,onClearReply:ne,fileInputRef:ge,visionWarning:We,maxFiles:Fe=5,className:Se="",compact:oe=!1,onMentionChipsChange:fe}){const{t:be}=st(["team","common"]),G=s.useRef(null),le=s.useRef(null);s.useRef(null);const[ie,ce]=s.useState(!1),[ye,me]=s.useState(""),[Y,J]=s.useState(0),[ee,ve]=s.useState(null),[W,Ce]=s.useState([]),n=(U??[]).filter(o=>o.name.toLowerCase().includes(ye)),de=(()=>{if(n.length===0)return[];const o=new Map;for(const O of n){const A=O.type??"agent";o.has(A)||o.set(A,[]),o.get(A).push(O)}const D=[];for(const O of Is){const A=o.get(O);A?.length&&D.push({type:O,items:A})}return D})();s.useEffect(()=>{if(!ie||!G.current){ve(null);return}const o=G.current.getBoundingClientRect();ve({left:o.left+16,bottom:window.innerHeight-o.top+4})},[ie]);const Ee=s.useCallback(()=>{const o=le.current;o&&(o.style.height="auto",o.style.height=`${Math.min(o.scrollHeight,oe?80:120)}px`)},[oe]);s.useEffect(()=>{Ee()},[c,Ee]);const He=s.useCallback(o=>{if(h(o),!U?.length){ce(!1);return}const D=le.current?.selectionStart??o.length,O=o.slice(0,D),A=O.lastIndexOf("@");if(A>=0){const V=A===0?"":O[A-1];if(A===0||/[\s\n,,。!?!?;;::、()()\[\]【】]/.test(V)){const re=O.slice(A+1);if(!re.includes(" ")&&!re.includes(`
2
2
  `)){ce(!0),me(re.toLowerCase()),J(0);return}}}ce(!1)},[h,U]),Ae=s.useCallback(o=>{const D=le.current?.selectionStart??c.length,A=c.slice(0,D).lastIndexOf("@"),V=c.slice(D),Q=c.slice(0,A)+V.replace(/^\s/,"");h(Q);const re={id:`mention_${Date.now()}_${o.id}`,entityId:o.id,name:o.name,entityType:o.type},Be=[...W,re];Ce(Be),fe?.(Be),ce(!1),J(0),requestAnimationFrame(()=>{const ue=A;le.current?.setSelectionRange(ue,ue),le.current?.focus()})},[c,h,W,fe]),Ie=s.useCallback(()=>{f(),Ce([]),fe?.([])},[f,fe]),X=s.useCallback(o=>{if(ie&&n.length>0){const D=o.key==="ArrowUp"||o.ctrlKey&&o.key==="p",O=o.key==="ArrowDown"||o.ctrlKey&&o.key==="n",A=o.key==="Enter"||o.key==="Tab",V=o.key==="Escape";if(D){o.preventDefault(),J(Q=>(Q-1+n.length)%n.length);return}if(O){o.preventDefault(),J(Q=>(Q+1)%n.length);return}if(A){o.preventDefault();const Q=n[Y];Q&&Ae(Q);return}if(V){o.preventDefault(),ce(!1);return}}o.key==="Enter"&&!o.shiftKey&&(o.preventDefault(),Ie())},[ie,n,Y,Ae,Ie]),je=F??[],Re=ie&&n.length>0&&ee&&rs.createPortal(e.jsx("div",{className:"fixed bg-surface-elevated border border-border-default rounded-lg shadow-xl overflow-hidden max-h-64 overflow-y-auto min-w-[220px]",style:{left:ee.left,bottom:ee.bottom,zIndex:9999},children:(()=>{let o=0;return de.map(D=>{const O=Ut[D.type],A=be(`page.mentionType.${D.type}`);return e.jsxs("div",{children:[e.jsxs("div",{className:"px-3 py-1 text-[10px] text-fg-tertiary font-medium uppercase tracking-wider border-b border-border-default bg-surface-secondary/50 flex items-center gap-1.5 sticky top-0",children:[e.jsx("span",{children:O}),e.jsx("span",{children:A})]}),D.items.map(V=>{const Q=o++;return e.jsxs("button",{ref:re=>{Q===Y&&re&&re.scrollIntoView({block:"nearest"})},onMouseDown:re=>{re.preventDefault(),Ae(V)},onMouseEnter:()=>J(Q),className:`w-full text-left px-4 py-2 text-sm flex items-center gap-2 transition-colors ${Q===Y?"bg-brand-500/15 text-brand-500":"text-fg-secondary hover:bg-surface-overlay"}`,children:[V.type==="agent"?e.jsx(xt,{name:V.name,avatarUrl:V.avatarUrl,size:20,bgClass:"bg-brand-500/20 text-brand-500"}):e.jsx("span",{className:"text-xs w-5 h-5 flex items-center justify-center shrink-0",children:O}),e.jsx("span",{className:"flex-1 min-w-0 truncate",children:V.name}),V.role&&e.jsx("span",{className:"text-[10px] text-fg-tertiary ml-auto shrink-0",children:V.role})]},V.id)})]},D.type)})})()}),document.body);return e.jsxs("div",{ref:G,className:`relative bg-surface-primary border border-border-default shadow-lg shadow-black/10 rounded-2xl p-3 ${Se}`,onDrop:E,onDragOver:P,children:[Re,(z&&z.length>0||W.length>0)&&e.jsxs("div",{className:"flex flex-wrap gap-1.5 mb-2",children:[W.map(o=>e.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-full bg-brand-500/10 border border-brand-500/30 text-xs text-brand-400 max-w-[200px]",children:[e.jsx("span",{className:"shrink-0 text-[10px]",children:Ut[o.entityType]}),e.jsx("span",{className:"truncate font-medium",children:o.name}),e.jsx("button",{onClick:()=>{const D=W.filter(O=>O.id!==o.id);Ce(D),fe?.(D)},className:"shrink-0 text-brand-400/60 hover:text-red-400 transition-colors",children:e.jsxs("svg",{width:"12",height:"12",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"})]})})]},o.id)),z?.map(o=>e.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-md bg-surface-elevated border border-border-default text-xs text-fg-secondary max-w-[200px]",children:[e.jsx("span",{className:"truncate",children:o.label}),o.onRemove&&e.jsx("button",{onClick:o.onRemove,className:"shrink-0 text-fg-tertiary hover:text-red-500 transition-colors",children:e.jsxs("svg",{width:"12",height:"12",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"})]})})]},o.id))]}),je.length>0&&e.jsxs("div",{className:"flex items-center gap-2 mb-2 overflow-x-auto pb-1",children:[je.map(o=>e.jsxs("div",{className:"relative group/img shrink-0",children:[Vt(o)?e.jsx("img",{src:o.dataUrl,alt:o.name,className:"w-16 h-16 rounded-lg object-cover border border-border-default"}):e.jsxs("div",{className:"w-16 h-16 rounded-lg border border-border-default bg-surface-elevated flex flex-col items-center justify-center gap-0.5",title:o.name,children:[e.jsx("span",{className:"text-xl leading-none",children:Ls(o.name,o.dataUrl)}),e.jsx("span",{className:"text-[9px] text-fg-tertiary truncate max-w-[56px] px-0.5",children:o.name.split(".").pop()?.toUpperCase()})]}),k&&e.jsx("button",{onClick:()=>k(o.id),className:"absolute -top-1.5 -right-1.5 w-5 h-5 bg-surface-secondary border border-gray-600 rounded-full flex items-center justify-center text-fg-secondary hover:text-red-500 hover:border-red-500 text-xs opacity-0 group-hover/img:opacity-100 transition-opacity",children:"×"})]},o.id)),je.length<Fe&&M&&e.jsx("button",{onClick:M,className:"w-16 h-16 rounded-lg border border-dashed border-gray-600 flex items-center justify-center text-fg-tertiary hover:text-fg-secondary hover:border-gray-400 transition-colors shrink-0",title:be("page.addMoreFiles"),children:e.jsx("svg",{className:"w-5 h-5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:e.jsx("path",{d:"M12 5v14M5 12h14"})})})]}),We&&e.jsxs("div",{className:"text-[10px] text-amber-500/80 mb-1.5 flex items-center gap-1",children:[e.jsx("svg",{className:"w-3 h-3 shrink-0",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:e.jsx("path",{d:"M12 9v4m0 4h.01M12 2L2 22h20L12 2z",strokeLinecap:"round",strokeLinejoin:"round"})}),be("page.visionWarning")]}),Z&&e.jsxs("div",{className:"flex items-center gap-2 mb-2 px-3 py-1.5 bg-surface-elevated rounded-lg border border-border-default/50",children:[e.jsxs("div",{className:"flex-1 min-w-0 pl-2 border-l-2 border-brand-500/50",children:[e.jsx("span",{className:"text-[11px] font-medium text-brand-500",children:Z.sender}),e.jsx("p",{className:"text-[11px] text-fg-tertiary truncate",children:Z.text})]}),ne&&e.jsx("button",{onClick:ne,className:"text-fg-tertiary hover:text-fg-secondary shrink-0 p-0.5",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.jsxs("div",{className:"flex gap-2 items-end",children:[M&&e.jsx("button",{onClick:M,disabled:r,className:"px-2.5 py-2.5 text-fg-tertiary hover:text-fg-secondary disabled:opacity-40 transition-colors rounded-xl hover:bg-surface-elevated",title:be("page.attachFilesTitle"),children:e.jsx("svg",{className:"w-5 h-5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:e.jsx("path",{d:"M21.44 11.05l-9.19 9.19a6 6 0 01-8.49-8.49l9.19-9.19a4 4 0 015.66 5.66l-9.2 9.19a2 2 0 01-2.83-2.83l8.49-8.48",strokeLinecap:"round",strokeLinejoin:"round"})})}),e.jsx("textarea",{ref:le,value:c,onChange:o=>He(o.target.value),onKeyDown:X,onPaste:q,placeholder:v,disabled:r,rows:oe?1:2,className:"flex-1 px-4 py-3 bg-transparent rounded-xl text-sm outline-none disabled:opacity-40 transition-colors resize-none overflow-hidden leading-relaxed placeholder:text-fg-secondary",style:{minHeight:oe?"36px":"52px",maxHeight:oe?"80px":"120px"}}),_&&K&&e.jsx("button",{onClick:K,className:"px-3 py-2.5 bg-red-600 hover:bg-red-500 text-white text-sm rounded-xl transition-colors flex items-center gap-1.5",title:be("page.stopAgent"),children:e.jsx("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 24 24",fill:"currentColor",children:e.jsx("rect",{x:"4",y:"4",width:"16",height:"16",rx:"2"})})}),e.jsx("button",{onClick:Ie,disabled:r||!c.trim()&&je.length===0&&W.length===0,className:"px-5 py-2.5 bg-brand-600 hover:bg-brand-500 disabled:opacity-40 text-white text-sm rounded-xl transition-colors",children:be("common:send")})]})]})}function Ts({agentId:c,sessionId:h,agents:f,authUser:r,onClose:v,contextChips:_,extraMentionItems:K,width:z,className:U=""}){const{t:F}=st(["team","common"]),M=f.find(d=>d.id===c),q=M?.name??F("page.fallbackAgent"),E=r?.name??F("page.fallbackYou"),[P,k]=s.useState([]),[Z,ne]=s.useState(h??null),[ge,We]=s.useState(!0),[Fe,Se]=s.useState(!1),[oe,fe]=s.useState(""),[be,G]=s.useState([]),[le,ie]=s.useState([]),ce=s.useRef(null),ye=s.useRef(null),me=s.useRef(null),Y=s.useRef(!0),J=s.useRef(Z);J.current=Z;const ee=s.useMemo(()=>({today:F("page.dateToday"),yesterday:F("page.dateYesterday")}),[F]),ve=s.useMemo(()=>{const d=F("page.chatGreetings",{returnObjects:!0});return Array.isArray(d)&&d.length>0?d[Math.floor(Math.random()*d.length)]:""},[F]),W=s.useCallback((d="auto")=>{ye.current?.scrollIntoView({behavior:d})},[]);s.useEffect(()=>{let d=!1;return We(!0),k([]),(async()=>{try{let C=h??null;if(!C){const{sessions:H}=await L.sessions.listByAgent(c,10);C=H.find(R=>R.isMain)?.id??H[0]?.id??null}if(d)return;if(ne(C),C){const H=await L.sessions.getMessages(C,50);if(d)return;const T=H.messages.map(fs).filter(R=>R.sender!=="agent"||R.text||R.segments&&R.segments.length>0);k(T)}}catch{}d||We(!1)})(),()=>{d=!0}},[c,h]);const Ce=s.useRef(!0);s.useEffect(()=>{Ce.current&&!ge&&P.length>0&&requestAnimationFrame(()=>{requestAnimationFrame(()=>W())}),Ce.current=ge},[ge,P.length,W]),s.useEffect(()=>{!ge&&Y.current&&requestAnimationFrame(()=>W())},[P,W,ge]),s.useEffect(()=>ft.on("chat:proactive_message",N=>{const C=N.payload,H=C.agentId??"";if(H!==c)return;const T=C.targetUserId;if(T&&T!==r?.id)return;const R=C.message??"",pe=C.sessionId??"",te=C.messageId??"";if(!R||R==="[cancelled]"||R==="[Stream cancelled]"||pe&&J.current&&pe!==J.current)return;const S=C.metadata??{},he=S.role==="user",{cleaned:se,priority:Le}=as(R),l=!he&&(!!S.notifyUser||se!==R),g=typeof S.userText=="string"?S.userText:"",i=typeof S.userMessageId=="string"?S.userMessageId:"",x=typeof S.createdAt=="string"&&S.createdAt||(typeof N.timestamp=="string"?N.timestamp:void 0)||new Date().toISOString(),p=(()=>{try{return new Date(x).toLocaleTimeString()}catch{return new Date().toLocaleTimeString()}})(),b={id:te||`proactive_${Date.now()}`,sender:he?"user":"agent",text:se,time:p,rawCreatedAt:x,...he?{}:{agentName:C.agentName??q,agentId:H,...l?{isNotification:!0,notifyPriority:S.priority??Le}:{}}};k(j=>{if(j.some(y=>y.id===b.id))return j;let I=j;return!he&&g&&(I.some(w=>i&&w.id===i||w.sender==="user"&&w.text===g)||(I=Ot(I,{id:i||`feishu_user_${b.id}`,sender:"user",text:g,time:p,rawCreatedAt:x}))),Ot(I,b)})}),[c,q,r?.id]);const[n,de]=s.useState(!1),Ee=s.useCallback(()=>{const d=ce.current;if(!d)return;const N=d.scrollHeight-d.scrollTop-d.clientHeight<60;Y.current=N,de(!N)},[]),He=s.useCallback(()=>{me.current?.abort(),me.current=null,Se(!1),G([]),L.agents.cancelProcessing(c).catch(()=>{})},[c]),[Ae,Ie]=s.useState(null),[X,je]=s.useState(null),[Re,o]=s.useState(!1),D=s.useCallback(async(d,N)=>{let C=d?.trim()??"";if(!C){const l=[];if(le.length>0&&l.push(le.map(g=>`@[${g.name}](${g.entityType}:${g.entityId})`).join(" ")),_?.length)for(const g of _)l.push(`[${g.type}: ${g.label}]
3
3
  ${g.content}`);oe.trim()&&l.push(oe.trim()),C=l.join(`
4
4
 
@@ -0,0 +1 @@
1
+ import{u as o,a as l,j as e,M as t,N as n}from"./index-lNtr_En-.js";function r({authUser:s}){const{t:a}=o("nav"),i=l();return e.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[e.jsxs("div",{"data-electron-drag":!0,className:"flex items-center gap-2 px-4 h-14",children:[i&&e.jsx(t,{}),e.jsx("h2",{className:"text-base font-bold",children:a("notifications")})]}),e.jsx("div",{className:"flex-1 overflow-hidden",children:e.jsx(n,{collapsed:!1,userId:s?.id,embeddedMode:!0})})]})}export{r as NotificationsPage};
@@ -1 +1 @@
1
- import{u as I,r as i,f as c,j as e,n as d,P as x,A as O}from"./index-BVZKeNvh.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,f as c,j as e,n as d,P as x,A as O}from"./index-lNtr_En-.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 me,r as l,j as e,J as bn,F as ta,f as F,a as sa,as as kr,n as ss,P as rs,at as ra,au as Cr,h as Fe,av as yn,w as na,aw as ns,ax as Rs,_ as aa}from"./index-BVZKeNvh.js";function oa(s,r){for(var o=0;o<r.length;o++){const n=r[o];if(typeof n!="string"&&!Array.isArray(n)){for(const a in n)if(a!=="default"&&!(a in s)){const t=Object.getOwnPropertyDescriptor(n,a);t&&Object.defineProperty(s,a,t.get?t:{enumerable:!0,get:()=>n[a]})}}}return Object.freeze(Object.defineProperty(s,Symbol.toStringTag,{value:"Module"}))}function ia(s){return s>=1e6?`${(s/1e6).toFixed(s%1e6===0?0:1)}M`:s>=1e3?`${(s/1e3).toFixed((s%1e3===0,0))}K`:String(s)}function la(s){return s.maxInputTokens>0||s.inputCostPer1MTokens>0||s.outputCostPer1MTokens>0}function as(s){if(s.tier)return s.tier;const r=s.id.toLowerCase(),o=/opus|5\.4|o3-(?!mini)|o1-(?!mini)|gemini.*ultra|sonnet-4-20/,n=/haiku|flash|nano|lite|small|fast|free|8b|7b|1b|3b/;return/o4-mini|o3-mini|o1-mini|gpt-4o-mini/.test(r)?"pro":o.test(r)?"max":n.test(r)?"base":"pro"}const Sr={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 vn({models:s,selectedModel:r,onSelect:o,loading:n,compact:a,maxVisible:t,showTiers:d}){const{t:c}=me("settings"),[u,p]=l.useState(""),[y,T]=l.useState(!1),[x,v]=l.useState(""),w=l.useMemo(()=>{let g=s;if(u){const h=u.toLowerCase();g=g.filter(N=>N.id.toLowerCase().includes(h))}return x&&(g=g.filter(h=>as(h)===x)),g},[s,u,x]),A=l.useMemo(()=>{const g={max:0,pro:0,base:0};for(const h of s)g[as(h)]++;return g},[s]),K=t??(a?5:10),j=y?w:w.slice(0,K),S=w.length>K;return n?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"}),c("modelPicker.loading")]}):s.length===0?e.jsx("div",{className:"py-3 text-sm text-fg-tertiary",children:c("modelPicker.empty")}):e.jsxs("div",{className:"space-y-2",children:[d&&s.length>3&&e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("button",{onClick:()=>v(""),className:`px-2 py-0.5 rounded text-[10px] transition-colors ${x?"bg-surface-overlay text-fg-tertiary hover:text-fg-secondary":"bg-brand-500/20 text-brand-500"}`,children:c("modelPicker.allCount",{count:s.length})}),["max","pro","base"].filter(g=>A[g]>0).map(g=>e.jsx("button",{onClick:()=>v(x===g?"":g),className:`px-2 py-0.5 rounded text-[10px] font-medium uppercase transition-colors border ${x===g?Sr[g]:"border-transparent bg-surface-overlay text-fg-tertiary hover:text-fg-secondary"}`,children:c("modelPicker.tierCount",{tier:c(`modelRouting.tier.${g}`),count:A[g]})},g))]}),s.length>5&&e.jsx("input",{type:"text",value:u,onChange:g=>{p(g.target.value),T(!1)},placeholder:c("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:j.map(g=>{const h=g.id===r,N=as(g);return e.jsxs("button",{type:"button",onClick:()=>o(g.id),className:`w-full text-left px-3 py-2 rounded-lg transition-colors ${h?"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 ${h?"border-brand-500":"border-border-default"}`,children:h&&e.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-brand-500"})}),e.jsx("span",{className:`text-xs font-medium ${h?"text-brand-500":"text-fg-primary"}`,children:g.id}),d&&e.jsx("span",{className:`px-1.5 py-0.5 rounded text-[9px] font-semibold uppercase border ${Sr[N]}`,children:c(`modelRouting.tier.${N}`)})]}),e.jsx("div",{className:"flex items-center gap-2",children:h&&e.jsx("span",{className:"text-[10px] text-brand-500 font-medium",children:c("modelPicker.active")})})]}),la(g)&&g.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:[ia(g.maxInputTokens)," ",c("modelPicker.ctx")]})}),!a&&e.jsxs("div",{className:"ml-5 mt-1 flex items-center gap-1.5 flex-wrap",children:[g.capabilities.functionCalling&&e.jsx(nt,{label:c("modelPicker.capabilities.tools")}),g.capabilities.vision&&e.jsx(nt,{label:c("modelPicker.capabilities.vision")}),g.capabilities.reasoning&&e.jsx(nt,{label:c("modelPicker.capabilities.reasoning")}),g.capabilities.promptCaching&&e.jsx(nt,{label:c("modelPicker.capabilities.caching")}),g.capabilities.webSearch&&e.jsx(nt,{label:c("modelPicker.capabilities.search")})]})]},g.id)})}),S&&!y&&e.jsx("button",{type:"button",onClick:()=>T(!0),className:"text-xs text-brand-500 hover:text-brand-400 px-3",children:c("modelPicker.showAll",{count:w.length})}),y&&S&&e.jsx("button",{type:"button",onClick:()=>T(!1),className:"text-xs text-fg-tertiary hover:text-fg-secondary px-3",children:c("modelPicker.showLess")})]})}function nt({label:s}){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:s})}function Os({value:s,options:r,placeholder:o,onChange:n}){const{t:a}=me("settings"),[t,d]=l.useState(!1),[c,u]=l.useState(""),p=l.useRef(null),y=l.useRef(null),T=l.useRef(null),[x,v]=l.useState(-1);l.useEffect(()=>{function g(h){p.current&&!p.current.contains(h.target)&&d(!1)}return document.addEventListener("mousedown",g),()=>document.removeEventListener("mousedown",g)},[]),l.useEffect(()=>{t&&y.current&&y.current.focus()},[t]);const w=l.useMemo(()=>{if(!c.trim())return r;const g=c.toLowerCase();return r.filter(h=>h.modelId.toLowerCase().includes(g)||h.modelName.toLowerCase().includes(g)||h.provider.toLowerCase().includes(g)||h.providerLabel.toLowerCase().includes(g)||h.tier&&h.tier.toLowerCase().includes(g))},[r,c]),A=l.useMemo(()=>{const g=new Map;for(const N of w){const E=N.providerLabel;g.has(E)||g.set(E,[]),g.get(E).push(N)}const h={max:0,pro:1,base:2};for(const N of g.values())N.sort((E,O)=>(h[E.tier??"base"]??9)-(h[O.tier??"base"]??9));return g},[w]),K=l.useMemo(()=>{const g=[];for(const h of A.values())g.push(...h);return g},[A]),j=l.useMemo(()=>{if(!s)return o??a("modelRouting.auto");const g=r.find(h=>`${h.provider}/${h.modelId}`===s);return g?`${g.providerLabel}/${g.modelName}`:s},[s,r,o,a]);function S(g){if(!t){(g.key==="Enter"||g.key===" ")&&(g.preventDefault(),d(!0));return}switch(g.key){case"ArrowDown":g.preventDefault(),v(h=>Math.min(h+1,K.length-1));break;case"ArrowUp":g.preventDefault(),v(h=>Math.max(h-1,-1));break;case"Enter":g.preventDefault(),x===-1?n(""):K[x]&&n(`${K[x].provider}/${K[x].modelId}`),d(!1),u("");break;case"Escape":d(!1),u("");break}}return l.useEffect(()=>{T.current&&x>=0&&T.current.querySelector(`[data-focus-index="${x}"]`)?.scrollIntoView({block:"nearest"})},[x]),e.jsxs("div",{ref:p,className:"relative",onKeyDown:S,children:[e.jsx("button",{type:"button",onClick:()=>{d(!t),u(""),v(-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:j}),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:c,onChange:g=>{u(g.target.value),v(-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:T,className:"overflow-y-auto flex-1",children:[e.jsx("div",{className:`px-3 py-1.5 text-xs cursor-pointer ${x===-1?"bg-brand-500/20 text-brand-500":"text-fg-secondary hover:bg-surface-overlay"}`,onClick:()=>{n(""),d(!1),u("")},children:o??a("modelRouting.auto")}),[...A.entries()].map(([g,h])=>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:g}),h.map(N=>{const E=K.indexOf(N),O=`${N.provider}/${N.modelId}`===s;return e.jsxs("div",{"data-focus-index":E,className:`px-3 py-1.5 text-xs cursor-pointer flex items-center gap-2 ${E===x?"bg-brand-500/20":O?"bg-surface-overlay":"hover:bg-surface-overlay/50"}`,onClick:()=>{n(`${N.provider}/${N.modelId}`),d(!1),u("")},children:[e.jsx("span",{className:"flex-1 truncate text-fg-primary",children:N.modelName}),N.tier&&e.jsx(da,{tier:N.tier}),N.costTier&&e.jsx("span",{className:"text-[9px] text-fg-tertiary",children:N.costTier})]},`${N.provider}/${N.modelId}`)})]},g)),K.length===0&&e.jsx("div",{className:"px-3 py-3 text-xs text-fg-tertiary text-center",children:a("modelPicker.empty")})]})]})]})}function da({tier:s}){const r={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 ${r[s]??r.base}`,children:s})}const ca=500,Pr=[{groupKey:"image",capabilities:["image_recognition","image_generation"]},{groupKey:"audio",capabilities:["audio_tts","audio_stt"]},{groupKey:"video",capabilities:["video_generation"]}];function ua({onSave:s,configuredProviders:r}){const{t:o}=me(["settings","common"]),[n,a]=l.useState({}),[t,d]=l.useState(null),[c,u]=l.useState(!1),[p,y]=l.useState(null),[T,x]=l.useState("idle"),[v,w]=l.useState(null),[A,K]=l.useState({}),[j,S]=l.useState(!1),[g,h]=l.useState("idle"),[N,E]=l.useState(null),[O,U]=l.useState(!1),_=l.useRef(null),D=l.useRef(null),R=l.useMemo(()=>r.map(I=>I.name).sort().join(","),[r]);l.useEffect(()=>{fetch("/api/settings/llm/routing",{credentials:"include"}).then(I=>{if(!I.ok)throw new Error(`HTTP ${I.status}`);return I.json()}).then(I=>{a(I.capabilityRouting?.assignments??{}),d(I.routingDefaultModel??null),u(!0)}).catch(I=>{y(String(I)),u(!0)})},[R]),l.useEffect(()=>{fetch("/api/models/routing-candidates",{credentials:"include"}).then(I=>{if(!I.ok)throw new Error(`HTTP ${I.status}`);return I.json()}).then(I=>{const H=[];for(const q of I.providers)for(const m of q.models)H.push({provider:q.provider,providerLabel:q.displayName,modelId:m.id,modelName:m.name,mode:m.mode,tier:m.tier,costTier:m.costTier,capabilities:m.capabilities});w(H)}).catch(()=>w(null))},[R]),l.useEffect(()=>{fetch("/api/models/suggested-assignments",{credentials:"include"}).then(I=>{if(!I.ok)throw new Error(`HTTP ${I.status}`);return I.json()}).then(I=>{K(I.suggestions),S(!0)}).catch(()=>S(!0))},[R]);const P=l.useCallback(I=>{x("saving"),s(I).then(()=>{x("saved"),setTimeout(()=>x(H=>H==="saved"?"idle":H),2e3)}).catch(()=>{x("error"),setTimeout(()=>x(H=>H==="error"?"idle":H),3e3)})},[s]),f=l.useCallback((I,H)=>{D.current={capabilityRouting:I!==void 0?{assignments:I}:D.current?.capabilityRouting,routingDefaultModel:H!==void 0?H:D.current?.routingDefaultModel},_.current&&clearTimeout(_.current),_.current=setTimeout(()=>{const q=D.current;D.current=null,q&&P(q)},ca)},[P]),k=l.useMemo(()=>r.flatMap(I=>(I.models??[{id:I.model,name:I.model}]).map(H=>({provider:I.name,providerLabel:I.displayName??I.name,modelId:H.id,modelName:H.name}))),[r]),$=v??k,J=l.useMemo(()=>Object.entries(n).map(([I,H])=>`${I}:${H?.provider??""}/${H?.model??""}`).sort().join("|"),[n]);l.useEffect(()=>{!c||!v||v.length===0||v.some(I=>!!I.modelId)&&a(I=>{let H=!1;const q={...I};for(const m of Pr)for(const L of m.capabilities){const V=q[L];if(!V?.model)continue;const X=jn(v,L);if(X.length===0)continue;X.some(Q=>Q.provider===V.provider&&Q.modelId===V.model)||(delete q[L],H=!0)}return H?(f(q),q):I})},[c,v,R,f,J]);const Z=l.useCallback(()=>{fetch("/api/settings/llm/routing",{credentials:"include"}).then(I=>{if(!I.ok)throw new Error(`HTTP ${I.status}`);return I.json()}).then(I=>{a(I.capabilityRouting?.assignments??{}),d(I.routingDefaultModel??null)}).catch(()=>{}),fetch("/api/models/routing-candidates",{credentials:"include"}).then(I=>{if(!I.ok)throw new Error(`HTTP ${I.status}`);return I.json()}).then(I=>{const H=[];for(const q of I.providers)for(const m of q.models)H.push({provider:q.provider,providerLabel:q.displayName,modelId:m.id,modelName:m.name,mode:m.mode,tier:m.tier,costTier:m.costTier,capabilities:m.capabilities});w(H)}).catch(()=>{})},[]),ne=l.useCallback(async()=>{if(g!=="working"){h("working"),E(null);try{const I=await fetch("/api/settings/llm/restore-recommended",{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"}}),H=await I.json().catch(()=>({}));if(!I.ok||!H.ok)throw new Error(H.error??`HTTP ${I.status}`);H.capabilityRouting&&a(H.capabilityRouting.assignments??{}),H.routingDefaultModel!==void 0&&d(H.routingDefaultModel),Z(),h("idle"),x("saved"),setTimeout(()=>x(q=>q==="saved"?"idle":q),2e3)}catch(I){h("error"),E(I instanceof Error?I.message:String(I)),setTimeout(()=>h("idle"),4e3)}}},[g,Z]);return c?p?e.jsx("div",{className:"bg-red-500/10 border border-red-500/30 rounded-xl p-4 text-xs text-red-400",children:o("modelRouting.loadError",{error:p})}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx(ga,{status:T,t:o}),e.jsxs("div",{className:"flex flex-col items-end gap-1",children:[e.jsx("button",{type:"button",onClick:()=>U(!0),disabled:g==="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:o(g==="working"?"modelRouting.restoreWorking":"modelRouting.restoreRecommended")}),N&&e.jsx("span",{className:"text-[10px] text-red-400 max-w-xs text-right",children:N})]})]}),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:o("modelRouting.defaultModelTitle")}),e.jsx("p",{className:"text-xs text-fg-tertiary mt-1",children:o("modelRouting.defaultModelDesc")})]}),e.jsx("div",{className:"max-w-md",children:e.jsx(Os,{value:t?`${t.provider}/${t.model}`:"",options:$,placeholder:o("modelRouting.defaultModelPlaceholder"),onChange:I=>{if(!I)d(null),f(void 0,null);else{const[H,...q]=I.split("/"),m={provider:H,model:q.join("/")};if(d(m),n.text){const L={...n};delete L.text,a(L),f(L,m)}else f(void 0,m)}}})})]}),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:o("modelRouting.capabilityAssignTitle")}),e.jsx("p",{className:"text-xs text-fg-tertiary mt-1",children:o("modelRouting.capabilityAssignDesc")})]}),r.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:o("modelRouting.noProvidersHint")}),r.length>0&&e.jsx("div",{className:"space-y-4",children:Pr.map(I=>e.jsx(xa,{groupKey:I.groupKey,capabilities:I.capabilities,assignments:n,suggestions:A,allModels:$,configuredProviderNames:new Set(r.map(H=>H.name)),t:o,onAssign:(H,q)=>{const m={...n};q?m[H]=q:delete m[H],a(m),f(m)}},I.groupKey))})]}),O&&e.jsx(bn,{variant:"primary",title:o("modelRouting.restoreRecommended"),message:o("modelRouting.restoreConfirm"),confirmLabel:o("common:confirm"),onConfirm:()=>{U(!1),ne()},onCancel:()=>U(!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(I=>e.jsx("div",{className:"h-10 bg-surface-overlay rounded-lg"},I))})]})})}function xa({groupKey:s,capabilities:r,assignments:o,suggestions:n,allModels:a,configuredProviderNames:t,t:d,onAssign:c}){return e.jsxs("div",{children:[e.jsx("div",{className:"text-[10px] font-semibold text-fg-tertiary uppercase tracking-wider mb-2 px-1",children:d(`modelRouting.capabilityGroups.${s}`)}),e.jsx("div",{className:"space-y-1",children:r.map(u=>{const p=o[u],y=n[u],T=p?`${p.provider}/${p.model}`:"",x=jn(a,u),v=y?x.find(S=>S.provider===y.provider&&S.modelId===y.model)?.modelName??y.model:void 0,w=x.length>0,A=p?ma(a,p.provider,p.model):void 0,K=p&&!t.has(p.provider),j=!!(p&&w&&u!=="text"&&!x.some(S=>S.provider===p.provider&&S.modelId===p.model));return e.jsxs("div",{className:`flex items-center gap-3 px-3 py-2 rounded-lg ${j?"bg-red-500/10 border border-red-500/30":K?"bg-yellow-500/10 border border-yellow-500/30":!w&&!p?"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:d(`modelRouting.capabilities.${u}`)})}),e.jsx("div",{className:"flex-1 min-w-0",children:j?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:["⚠ ",p.model]}),e.jsx("span",{className:"text-[10px] text-red-400/70",children:d("modelRouting.mismatchHint")})]}),e.jsx(Os,{value:"",options:x,placeholder:d("modelRouting.selectModel"),onChange:S=>{if(!S)c(u,null);else{const[g,...h]=S.split("/");c(u,{provider:g,model:h.join("/")})}}})]}):w?e.jsx(Os,{value:T,options:x,placeholder:v?`${v} (${d("modelRouting.suggested")})`:d("modelRouting.selectModel"),onChange:S=>{if(!S)c(u,null);else{const[g,...h]=S.split("/");c(u,{provider:g,model:h.join("/")})}}}):e.jsxs("span",{className:"text-xs text-amber-400",children:[d("modelRouting.noModelAvailable"),e.jsxs("span",{className:"text-fg-tertiary ml-1",children:["— ",d("modelRouting.addProviderHint")]})]})}),e.jsxs("div",{className:"w-14 shrink-0 flex justify-end",children:[j&&e.jsx("span",{className:"text-[10px] text-red-400 font-medium",title:d("modelRouting.mismatchHint"),children:"⚠"}),!j&&K&&e.jsx("span",{className:"text-[10px] text-yellow-400 font-medium",title:d("modelRouting.staleProvider"),children:"⚠"}),!j&&!K&&A&&e.jsx(Ar,{tier:A}),!j&&!K&&!A&&p&&e.jsx(Ar,{tier:"unknown"})]}),e.jsx("div",{className:"w-8 shrink-0 flex justify-end",children:p&&e.jsx("button",{onClick:()=>c(u,null),className:"text-fg-tertiary hover:text-red-400 transition-colors",title:d("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"})})})})]},u)})})]})}function ma(s,r,o){return s.find(a=>a.provider===r&&a.modelId===o)?.tier}function ga({status:s,t:r}){if(s==="idle")return null;const o={idle:"",saving:"text-fg-tertiary",saved:"text-green-400",error:"text-red-400"},n={idle:"",saving:r("modelRouting.saving"),saved:r("modelRouting.saved"),error:r("modelRouting.saveError")};return e.jsx("div",{className:`text-xs font-medium transition-opacity ${o[s]}`,children:n[s]})}function Ar({tier:s}){const r={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 ${r[s]??r.unknown}`,children:s==="unknown"?"—":s})}const fa=new Set(["imageGeneration","tts","stt","videoGeneration","audioOutput","audioInput"]);function jn(s,r){if(r==="text")return s.filter(d=>!(d.capabilities&&d.capabilities.some(c=>fa.has(c))||d.mode&&d.mode!=="chat"));const o={image_generation:["image_generation"],audio_tts:["audio_speech"],audio_stt:["audio_transcription"],video_generation:["video_generation"]},n={image_recognition:["vision"],image_generation:["imageGeneration"],audio_tts:["tts"],audio_stt:["stt"],video_generation:["videoGeneration"]},a=o[r],t=n[r];return s.filter(d=>!!(d.capabilities&&d.capabilities.length>0&&t&&t.some(c=>d.capabilities.includes(c))||a&&d.mode&&a.includes(d.mode)))}const Ct=[{id:"markus",label:"Markus Cloud AI",envKey:"MARKUS_SUBSCRIPTION_KEY",defaultModel:""},{id:"anthropic",label:"Anthropic",envKey:"ANTHROPIC_API_KEY",defaultModel:"claude-opus-4-6"},{id:"openai",label:"OpenAI",envKey:"OPENAI_API_KEY",defaultModel:"gpt-5.4"},{id:"google",label:"Google Gemini",envKey:"GOOGLE_API_KEY",defaultModel:"gemini-3-1-pro"},{id:"deepseek",label:"DeepSeek",envKey:"DEEPSEEK_API_KEY",baseUrl:"https://api.deepseek.com",defaultModel:"deepseek-v4-flash"},{id:"siliconflow",label:"SiliconFlow (中国)",envKey:"SILICONFLOW_API_KEY",baseUrl:"https://api.siliconflow.cn/v1",defaultModel:"Qwen/Qwen3.5-35B-A3B"},{id:"siliconflow-intl",label:"SiliconFlow (Global)",envKey:"SILICONFLOW_INTL_API_KEY",baseUrl:"https://api-st.siliconflow.cn/v1",defaultModel:"Qwen/Qwen3.5-35B-A3B"},{id:"minimax",label:"MiniMax (Global)",envKey:"MINIMAX_API_KEY",baseUrl:"https://api.minimax.io/v1",defaultModel:"MiniMax-M3"},{id:"minimax-cn",label:"MiniMax (中国)",envKey:"MINIMAX_CN_API_KEY",baseUrl:"https://api.minimaxi.com/v1",defaultModel:"MiniMax-M3"},{id:"openrouter",label:"OpenRouter",envKey:"OPENROUTER_API_KEY",baseUrl:"https://openrouter.ai/api/v1",defaultModel:"xiaomi/mimo-v2-pro:free"},{id:"zai",label:"ZAI (GLM)",envKey:"ZAI_API_KEY",baseUrl:"https://api.z.ai/api/paas/v4",defaultModel:"glm-5.1"},{id:"xai",label:"xAI (Grok)",envKey:"XAI_API_KEY",baseUrl:"https://api.x.ai/v1",defaultModel:"grok-3"},{id:"mistral",label:"Mistral AI",envKey:"MISTRAL_API_KEY",baseUrl:"https://api.mistral.ai/v1",defaultModel:"mistral-large-latest"},{id:"groq",label:"Groq",envKey:"GROQ_API_KEY",baseUrl:"https://api.groq.com/openai/v1",defaultModel:"llama-3.3-70b-versatile"},{id:"perplexity",label:"Perplexity",envKey:"PERPLEXITY_API_KEY",baseUrl:"https://api.perplexity.ai",defaultModel:"sonar-pro"},{id:"cohere",label:"Cohere",envKey:"COHERE_API_KEY",baseUrl:"https://api.cohere.ai/compatibility/v1",defaultModel:"command-r-plus"},{id:"together_ai",label:"Together AI",envKey:"TOGETHER_API_KEY",baseUrl:"https://api.together.xyz/v1",defaultModel:"meta-llama/Llama-3.3-70B-Instruct-Turbo"},{id:"fireworks_ai",label:"Fireworks AI",envKey:"FIREWORKS_API_KEY",baseUrl:"https://api.fireworks.ai/inference/v1",defaultModel:"accounts/fireworks/models/llama-v3p3-70b-instruct"},{id:"moonshot",label:"Moonshot (Kimi)",envKey:"MOONSHOT_API_KEY",baseUrl:"https://api.moonshot.cn/v1",defaultModel:"moonshot-v1-auto"},{id:"volcengine",label:"Volcengine (Doubao)",envKey:"VOLCENGINE_API_KEY",baseUrl:"https://ark.cn-beijing.volces.com/api/v3",defaultModel:"doubao-1.5-pro-32k"},{id:"dashscope",label:"DashScope (Qwen)",envKey:"DASHSCOPE_API_KEY",baseUrl:"https://dashscope.aliyuncs.com/compatible-mode/v1",defaultModel:"qwen-max"},{id:"ollama",label:"Ollama (Local)",envKey:"OLLAMA_BASE_URL",baseUrl:"http://localhost:11434/v1",defaultModel:"llama3"},{id:"atlascloud",label:"Atlas Cloud (Full-Modal)",envKey:"ATLASCLOUD_API_KEY",baseUrl:"https://api.atlascloud.ai/v1",defaultModel:"claude-sonnet-4-6"},{id:"strongly",label:"Strongly.AI (Full-Modal)",envKey:"STRONGLY_API_KEY",baseUrl:"https://api.strongly.ai/v1",defaultModel:"claude-sonnet-4-6"}];var Ye={},os,Mr;function pa(){return Mr||(Mr=1,os=function(){return typeof Promise=="function"&&Promise.prototype&&Promise.prototype.then}),os}var is={},De={},Tr;function $e(){if(Tr)return De;Tr=1;let s;const r=[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 De.getSymbolSize=function(n){if(!n)throw new Error('"version" cannot be null or undefined');if(n<1||n>40)throw new Error('"version" should be in range from 1 to 40');return n*4+17},De.getSymbolTotalCodewords=function(n){return r[n]},De.getBCHDigit=function(o){let n=0;for(;o!==0;)n++,o>>>=1;return n},De.setToSJISFunction=function(n){if(typeof n!="function")throw new Error('"toSJISFunc" is not a valid function.');s=n},De.isKanjiModeEnabled=function(){return typeof s<"u"},De.toSJIS=function(n){return s(n)},De}var ls={},Er;function _s(){return Er||(Er=1,(function(s){s.L={bit:1},s.M={bit:0},s.Q={bit:3},s.H={bit:2};function r(o){if(typeof o!="string")throw new Error("Param is not a string");switch(o.toLowerCase()){case"l":case"low":return s.L;case"m":case"medium":return s.M;case"q":case"quartile":return s.Q;case"h":case"high":return s.H;default:throw new Error("Unknown EC Level: "+o)}}s.isValid=function(n){return n&&typeof n.bit<"u"&&n.bit>=0&&n.bit<4},s.from=function(n,a){if(s.isValid(n))return n;try{return r(n)}catch{return a}}})(ls)),ls}var ds,Ir;function ha(){if(Ir)return ds;Ir=1;function s(){this.buffer=[],this.length=0}return s.prototype={get:function(r){const o=Math.floor(r/8);return(this.buffer[o]>>>7-r%8&1)===1},put:function(r,o){for(let n=0;n<o;n++)this.putBit((r>>>o-n-1&1)===1)},getLengthInBits:function(){return this.length},putBit:function(r){const o=Math.floor(this.length/8);this.buffer.length<=o&&this.buffer.push(0),r&&(this.buffer[o]|=128>>>this.length%8),this.length++}},ds=s,ds}var cs,Lr;function ba(){if(Lr)return cs;Lr=1;function s(r){if(!r||r<1)throw new Error("BitMatrix size must be defined and greater than 0");this.size=r,this.data=new Uint8Array(r*r),this.reservedBit=new Uint8Array(r*r)}return s.prototype.set=function(r,o,n,a){const t=r*this.size+o;this.data[t]=n,a&&(this.reservedBit[t]=!0)},s.prototype.get=function(r,o){return this.data[r*this.size+o]},s.prototype.xor=function(r,o,n){this.data[r*this.size+o]^=n},s.prototype.isReserved=function(r,o){return this.reservedBit[r*this.size+o]},cs=s,cs}var us={},Rr;function ya(){return Rr||(Rr=1,(function(s){const r=$e().getSymbolSize;s.getRowColCoords=function(n){if(n===1)return[];const a=Math.floor(n/7)+2,t=r(n),d=t===145?26:Math.ceil((t-13)/(2*a-2))*2,c=[t-7];for(let u=1;u<a-1;u++)c[u]=c[u-1]-d;return c.push(6),c.reverse()},s.getPositions=function(n){const a=[],t=s.getRowColCoords(n),d=t.length;for(let c=0;c<d;c++)for(let u=0;u<d;u++)c===0&&u===0||c===0&&u===d-1||c===d-1&&u===0||a.push([t[c],t[u]]);return a}})(us)),us}var xs={},Or;function va(){if(Or)return xs;Or=1;const s=$e().getSymbolSize,r=7;return xs.getPositions=function(n){const a=s(n);return[[0,0],[a-r,0],[0,a-r]]},xs}var ms={},Br;function ja(){return Br||(Br=1,(function(s){s.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};const r={N1:3,N2:3,N3:40,N4:10};s.isValid=function(a){return a!=null&&a!==""&&!isNaN(a)&&a>=0&&a<=7},s.from=function(a){return s.isValid(a)?parseInt(a,10):void 0},s.getPenaltyN1=function(a){const t=a.size;let d=0,c=0,u=0,p=null,y=null;for(let T=0;T<t;T++){c=u=0,p=y=null;for(let x=0;x<t;x++){let v=a.get(T,x);v===p?c++:(c>=5&&(d+=r.N1+(c-5)),p=v,c=1),v=a.get(x,T),v===y?u++:(u>=5&&(d+=r.N1+(u-5)),y=v,u=1)}c>=5&&(d+=r.N1+(c-5)),u>=5&&(d+=r.N1+(u-5))}return d},s.getPenaltyN2=function(a){const t=a.size;let d=0;for(let c=0;c<t-1;c++)for(let u=0;u<t-1;u++){const p=a.get(c,u)+a.get(c,u+1)+a.get(c+1,u)+a.get(c+1,u+1);(p===4||p===0)&&d++}return d*r.N2},s.getPenaltyN3=function(a){const t=a.size;let d=0,c=0,u=0;for(let p=0;p<t;p++){c=u=0;for(let y=0;y<t;y++)c=c<<1&2047|a.get(p,y),y>=10&&(c===1488||c===93)&&d++,u=u<<1&2047|a.get(y,p),y>=10&&(u===1488||u===93)&&d++}return d*r.N3},s.getPenaltyN4=function(a){let t=0;const d=a.data.length;for(let u=0;u<d;u++)t+=a.data[u];return Math.abs(Math.ceil(t*100/d/5)-10)*r.N4};function o(n,a,t){switch(n){case s.Patterns.PATTERN000:return(a+t)%2===0;case s.Patterns.PATTERN001:return a%2===0;case s.Patterns.PATTERN010:return t%3===0;case s.Patterns.PATTERN011:return(a+t)%3===0;case s.Patterns.PATTERN100:return(Math.floor(a/2)+Math.floor(t/3))%2===0;case s.Patterns.PATTERN101:return a*t%2+a*t%3===0;case s.Patterns.PATTERN110:return(a*t%2+a*t%3)%2===0;case s.Patterns.PATTERN111:return(a*t%3+(a+t)%2)%2===0;default:throw new Error("bad maskPattern:"+n)}}s.applyMask=function(a,t){const d=t.size;for(let c=0;c<d;c++)for(let u=0;u<d;u++)t.isReserved(u,c)||t.xor(u,c,o(a,u,c))},s.getBestMask=function(a,t){const d=Object.keys(s.Patterns).length;let c=0,u=1/0;for(let p=0;p<d;p++){t(p),s.applyMask(p,a);const y=s.getPenaltyN1(a)+s.getPenaltyN2(a)+s.getPenaltyN3(a)+s.getPenaltyN4(a);s.applyMask(p,a),y<u&&(u=y,c=p)}return c}})(ms)),ms}var St={},_r;function Nn(){if(_r)return St;_r=1;const s=_s(),r=[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],o=[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 St.getBlocksCount=function(a,t){switch(t){case s.L:return r[(a-1)*4+0];case s.M:return r[(a-1)*4+1];case s.Q:return r[(a-1)*4+2];case s.H:return r[(a-1)*4+3];default:return}},St.getTotalCodewordsCount=function(a,t){switch(t){case s.L:return o[(a-1)*4+0];case s.M:return o[(a-1)*4+1];case s.Q:return o[(a-1)*4+2];case s.H:return o[(a-1)*4+3];default:return}},St}var gs={},at={},Dr;function Na(){if(Dr)return at;Dr=1;const s=new Uint8Array(512),r=new Uint8Array(256);return(function(){let n=1;for(let a=0;a<255;a++)s[a]=n,r[n]=a,n<<=1,n&256&&(n^=285);for(let a=255;a<512;a++)s[a]=s[a-255]})(),at.log=function(n){if(n<1)throw new Error("log("+n+")");return r[n]},at.exp=function(n){return s[n]},at.mul=function(n,a){return n===0||a===0?0:s[r[n]+r[a]]},at}var Kr;function wa(){return Kr||(Kr=1,(function(s){const r=Na();s.mul=function(n,a){const t=new Uint8Array(n.length+a.length-1);for(let d=0;d<n.length;d++)for(let c=0;c<a.length;c++)t[d+c]^=r.mul(n[d],a[c]);return t},s.mod=function(n,a){let t=new Uint8Array(n);for(;t.length-a.length>=0;){const d=t[0];for(let u=0;u<a.length;u++)t[u]^=r.mul(a[u],d);let c=0;for(;c<t.length&&t[c]===0;)c++;t=t.slice(c)}return t},s.generateECPolynomial=function(n){let a=new Uint8Array([1]);for(let t=0;t<n;t++)a=s.mul(a,new Uint8Array([1,r.exp(t)]));return a}})(gs)),gs}var fs,Ur;function ka(){if(Ur)return fs;Ur=1;const s=wa();function r(o){this.genPoly=void 0,this.degree=o,this.degree&&this.initialize(this.degree)}return r.prototype.initialize=function(n){this.degree=n,this.genPoly=s.generateECPolynomial(this.degree)},r.prototype.encode=function(n){if(!this.genPoly)throw new Error("Encoder not initialized");const a=new Uint8Array(n.length+this.degree);a.set(n);const t=s.mod(a,this.genPoly),d=this.degree-t.length;if(d>0){const c=new Uint8Array(this.degree);return c.set(t,d),c}return t},fs=r,fs}var ps={},hs={},bs={},Fr;function wn(){return Fr||(Fr=1,bs.isValid=function(r){return!isNaN(r)&&r>=1&&r<=40}),bs}var Pe={},$r;function kn(){if($r)return Pe;$r=1;const s="[0-9]+",r="[A-Z $%*+\\-./:]+";let o="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";o=o.replace(/u/g,"\\u");const n="(?:(?![A-Z0-9 $%*+\\-./:]|"+o+`)(?:.|[\r
1
+ import{u as me,r as l,j as e,J as bn,F as ta,f as F,a as sa,at as kr,n as ss,P as rs,au as ra,av as Cr,h as Fe,aw as yn,w as na,ax as ns,ay as Rs,_ as aa}from"./index-lNtr_En-.js";function oa(s,r){for(var o=0;o<r.length;o++){const n=r[o];if(typeof n!="string"&&!Array.isArray(n)){for(const a in n)if(a!=="default"&&!(a in s)){const t=Object.getOwnPropertyDescriptor(n,a);t&&Object.defineProperty(s,a,t.get?t:{enumerable:!0,get:()=>n[a]})}}}return Object.freeze(Object.defineProperty(s,Symbol.toStringTag,{value:"Module"}))}function ia(s){return s>=1e6?`${(s/1e6).toFixed(s%1e6===0?0:1)}M`:s>=1e3?`${(s/1e3).toFixed((s%1e3===0,0))}K`:String(s)}function la(s){return s.maxInputTokens>0||s.inputCostPer1MTokens>0||s.outputCostPer1MTokens>0}function as(s){if(s.tier)return s.tier;const r=s.id.toLowerCase(),o=/opus|5\.4|o3-(?!mini)|o1-(?!mini)|gemini.*ultra|sonnet-4-20/,n=/haiku|flash|nano|lite|small|fast|free|8b|7b|1b|3b/;return/o4-mini|o3-mini|o1-mini|gpt-4o-mini/.test(r)?"pro":o.test(r)?"max":n.test(r)?"base":"pro"}const Sr={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 vn({models:s,selectedModel:r,onSelect:o,loading:n,compact:a,maxVisible:t,showTiers:d}){const{t:c}=me("settings"),[u,p]=l.useState(""),[y,T]=l.useState(!1),[x,v]=l.useState(""),w=l.useMemo(()=>{let g=s;if(u){const h=u.toLowerCase();g=g.filter(N=>N.id.toLowerCase().includes(h))}return x&&(g=g.filter(h=>as(h)===x)),g},[s,u,x]),A=l.useMemo(()=>{const g={max:0,pro:0,base:0};for(const h of s)g[as(h)]++;return g},[s]),K=t??(a?5:10),j=y?w:w.slice(0,K),S=w.length>K;return n?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"}),c("modelPicker.loading")]}):s.length===0?e.jsx("div",{className:"py-3 text-sm text-fg-tertiary",children:c("modelPicker.empty")}):e.jsxs("div",{className:"space-y-2",children:[d&&s.length>3&&e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("button",{onClick:()=>v(""),className:`px-2 py-0.5 rounded text-[10px] transition-colors ${x?"bg-surface-overlay text-fg-tertiary hover:text-fg-secondary":"bg-brand-500/20 text-brand-500"}`,children:c("modelPicker.allCount",{count:s.length})}),["max","pro","base"].filter(g=>A[g]>0).map(g=>e.jsx("button",{onClick:()=>v(x===g?"":g),className:`px-2 py-0.5 rounded text-[10px] font-medium uppercase transition-colors border ${x===g?Sr[g]:"border-transparent bg-surface-overlay text-fg-tertiary hover:text-fg-secondary"}`,children:c("modelPicker.tierCount",{tier:c(`modelRouting.tier.${g}`),count:A[g]})},g))]}),s.length>5&&e.jsx("input",{type:"text",value:u,onChange:g=>{p(g.target.value),T(!1)},placeholder:c("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:j.map(g=>{const h=g.id===r,N=as(g);return e.jsxs("button",{type:"button",onClick:()=>o(g.id),className:`w-full text-left px-3 py-2 rounded-lg transition-colors ${h?"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 ${h?"border-brand-500":"border-border-default"}`,children:h&&e.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-brand-500"})}),e.jsx("span",{className:`text-xs font-medium ${h?"text-brand-500":"text-fg-primary"}`,children:g.id}),d&&e.jsx("span",{className:`px-1.5 py-0.5 rounded text-[9px] font-semibold uppercase border ${Sr[N]}`,children:c(`modelRouting.tier.${N}`)})]}),e.jsx("div",{className:"flex items-center gap-2",children:h&&e.jsx("span",{className:"text-[10px] text-brand-500 font-medium",children:c("modelPicker.active")})})]}),la(g)&&g.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:[ia(g.maxInputTokens)," ",c("modelPicker.ctx")]})}),!a&&e.jsxs("div",{className:"ml-5 mt-1 flex items-center gap-1.5 flex-wrap",children:[g.capabilities.functionCalling&&e.jsx(nt,{label:c("modelPicker.capabilities.tools")}),g.capabilities.vision&&e.jsx(nt,{label:c("modelPicker.capabilities.vision")}),g.capabilities.reasoning&&e.jsx(nt,{label:c("modelPicker.capabilities.reasoning")}),g.capabilities.promptCaching&&e.jsx(nt,{label:c("modelPicker.capabilities.caching")}),g.capabilities.webSearch&&e.jsx(nt,{label:c("modelPicker.capabilities.search")})]})]},g.id)})}),S&&!y&&e.jsx("button",{type:"button",onClick:()=>T(!0),className:"text-xs text-brand-500 hover:text-brand-400 px-3",children:c("modelPicker.showAll",{count:w.length})}),y&&S&&e.jsx("button",{type:"button",onClick:()=>T(!1),className:"text-xs text-fg-tertiary hover:text-fg-secondary px-3",children:c("modelPicker.showLess")})]})}function nt({label:s}){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:s})}function Os({value:s,options:r,placeholder:o,onChange:n}){const{t:a}=me("settings"),[t,d]=l.useState(!1),[c,u]=l.useState(""),p=l.useRef(null),y=l.useRef(null),T=l.useRef(null),[x,v]=l.useState(-1);l.useEffect(()=>{function g(h){p.current&&!p.current.contains(h.target)&&d(!1)}return document.addEventListener("mousedown",g),()=>document.removeEventListener("mousedown",g)},[]),l.useEffect(()=>{t&&y.current&&y.current.focus()},[t]);const w=l.useMemo(()=>{if(!c.trim())return r;const g=c.toLowerCase();return r.filter(h=>h.modelId.toLowerCase().includes(g)||h.modelName.toLowerCase().includes(g)||h.provider.toLowerCase().includes(g)||h.providerLabel.toLowerCase().includes(g)||h.tier&&h.tier.toLowerCase().includes(g))},[r,c]),A=l.useMemo(()=>{const g=new Map;for(const N of w){const E=N.providerLabel;g.has(E)||g.set(E,[]),g.get(E).push(N)}const h={max:0,pro:1,base:2};for(const N of g.values())N.sort((E,O)=>(h[E.tier??"base"]??9)-(h[O.tier??"base"]??9));return g},[w]),K=l.useMemo(()=>{const g=[];for(const h of A.values())g.push(...h);return g},[A]),j=l.useMemo(()=>{if(!s)return o??a("modelRouting.auto");const g=r.find(h=>`${h.provider}/${h.modelId}`===s);return g?`${g.providerLabel}/${g.modelName}`:s},[s,r,o,a]);function S(g){if(!t){(g.key==="Enter"||g.key===" ")&&(g.preventDefault(),d(!0));return}switch(g.key){case"ArrowDown":g.preventDefault(),v(h=>Math.min(h+1,K.length-1));break;case"ArrowUp":g.preventDefault(),v(h=>Math.max(h-1,-1));break;case"Enter":g.preventDefault(),x===-1?n(""):K[x]&&n(`${K[x].provider}/${K[x].modelId}`),d(!1),u("");break;case"Escape":d(!1),u("");break}}return l.useEffect(()=>{T.current&&x>=0&&T.current.querySelector(`[data-focus-index="${x}"]`)?.scrollIntoView({block:"nearest"})},[x]),e.jsxs("div",{ref:p,className:"relative",onKeyDown:S,children:[e.jsx("button",{type:"button",onClick:()=>{d(!t),u(""),v(-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:j}),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:c,onChange:g=>{u(g.target.value),v(-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:T,className:"overflow-y-auto flex-1",children:[e.jsx("div",{className:`px-3 py-1.5 text-xs cursor-pointer ${x===-1?"bg-brand-500/20 text-brand-500":"text-fg-secondary hover:bg-surface-overlay"}`,onClick:()=>{n(""),d(!1),u("")},children:o??a("modelRouting.auto")}),[...A.entries()].map(([g,h])=>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:g}),h.map(N=>{const E=K.indexOf(N),O=`${N.provider}/${N.modelId}`===s;return e.jsxs("div",{"data-focus-index":E,className:`px-3 py-1.5 text-xs cursor-pointer flex items-center gap-2 ${E===x?"bg-brand-500/20":O?"bg-surface-overlay":"hover:bg-surface-overlay/50"}`,onClick:()=>{n(`${N.provider}/${N.modelId}`),d(!1),u("")},children:[e.jsx("span",{className:"flex-1 truncate text-fg-primary",children:N.modelName}),N.tier&&e.jsx(da,{tier:N.tier}),N.costTier&&e.jsx("span",{className:"text-[9px] text-fg-tertiary",children:N.costTier})]},`${N.provider}/${N.modelId}`)})]},g)),K.length===0&&e.jsx("div",{className:"px-3 py-3 text-xs text-fg-tertiary text-center",children:a("modelPicker.empty")})]})]})]})}function da({tier:s}){const r={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 ${r[s]??r.base}`,children:s})}const ca=500,Pr=[{groupKey:"image",capabilities:["image_recognition","image_generation"]},{groupKey:"audio",capabilities:["audio_tts","audio_stt"]},{groupKey:"video",capabilities:["video_generation"]}];function ua({onSave:s,configuredProviders:r}){const{t:o}=me(["settings","common"]),[n,a]=l.useState({}),[t,d]=l.useState(null),[c,u]=l.useState(!1),[p,y]=l.useState(null),[T,x]=l.useState("idle"),[v,w]=l.useState(null),[A,K]=l.useState({}),[j,S]=l.useState(!1),[g,h]=l.useState("idle"),[N,E]=l.useState(null),[O,U]=l.useState(!1),_=l.useRef(null),D=l.useRef(null),R=l.useMemo(()=>r.map(I=>I.name).sort().join(","),[r]);l.useEffect(()=>{fetch("/api/settings/llm/routing",{credentials:"include"}).then(I=>{if(!I.ok)throw new Error(`HTTP ${I.status}`);return I.json()}).then(I=>{a(I.capabilityRouting?.assignments??{}),d(I.routingDefaultModel??null),u(!0)}).catch(I=>{y(String(I)),u(!0)})},[R]),l.useEffect(()=>{fetch("/api/models/routing-candidates",{credentials:"include"}).then(I=>{if(!I.ok)throw new Error(`HTTP ${I.status}`);return I.json()}).then(I=>{const H=[];for(const q of I.providers)for(const m of q.models)H.push({provider:q.provider,providerLabel:q.displayName,modelId:m.id,modelName:m.name,mode:m.mode,tier:m.tier,costTier:m.costTier,capabilities:m.capabilities});w(H)}).catch(()=>w(null))},[R]),l.useEffect(()=>{fetch("/api/models/suggested-assignments",{credentials:"include"}).then(I=>{if(!I.ok)throw new Error(`HTTP ${I.status}`);return I.json()}).then(I=>{K(I.suggestions),S(!0)}).catch(()=>S(!0))},[R]);const P=l.useCallback(I=>{x("saving"),s(I).then(()=>{x("saved"),setTimeout(()=>x(H=>H==="saved"?"idle":H),2e3)}).catch(()=>{x("error"),setTimeout(()=>x(H=>H==="error"?"idle":H),3e3)})},[s]),f=l.useCallback((I,H)=>{D.current={capabilityRouting:I!==void 0?{assignments:I}:D.current?.capabilityRouting,routingDefaultModel:H!==void 0?H:D.current?.routingDefaultModel},_.current&&clearTimeout(_.current),_.current=setTimeout(()=>{const q=D.current;D.current=null,q&&P(q)},ca)},[P]),k=l.useMemo(()=>r.flatMap(I=>(I.models??[{id:I.model,name:I.model}]).map(H=>({provider:I.name,providerLabel:I.displayName??I.name,modelId:H.id,modelName:H.name}))),[r]),$=v??k,J=l.useMemo(()=>Object.entries(n).map(([I,H])=>`${I}:${H?.provider??""}/${H?.model??""}`).sort().join("|"),[n]);l.useEffect(()=>{!c||!v||v.length===0||v.some(I=>!!I.modelId)&&a(I=>{let H=!1;const q={...I};for(const m of Pr)for(const L of m.capabilities){const V=q[L];if(!V?.model)continue;const X=jn(v,L);if(X.length===0)continue;X.some(Q=>Q.provider===V.provider&&Q.modelId===V.model)||(delete q[L],H=!0)}return H?(f(q),q):I})},[c,v,R,f,J]);const Z=l.useCallback(()=>{fetch("/api/settings/llm/routing",{credentials:"include"}).then(I=>{if(!I.ok)throw new Error(`HTTP ${I.status}`);return I.json()}).then(I=>{a(I.capabilityRouting?.assignments??{}),d(I.routingDefaultModel??null)}).catch(()=>{}),fetch("/api/models/routing-candidates",{credentials:"include"}).then(I=>{if(!I.ok)throw new Error(`HTTP ${I.status}`);return I.json()}).then(I=>{const H=[];for(const q of I.providers)for(const m of q.models)H.push({provider:q.provider,providerLabel:q.displayName,modelId:m.id,modelName:m.name,mode:m.mode,tier:m.tier,costTier:m.costTier,capabilities:m.capabilities});w(H)}).catch(()=>{})},[]),ne=l.useCallback(async()=>{if(g!=="working"){h("working"),E(null);try{const I=await fetch("/api/settings/llm/restore-recommended",{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"}}),H=await I.json().catch(()=>({}));if(!I.ok||!H.ok)throw new Error(H.error??`HTTP ${I.status}`);H.capabilityRouting&&a(H.capabilityRouting.assignments??{}),H.routingDefaultModel!==void 0&&d(H.routingDefaultModel),Z(),h("idle"),x("saved"),setTimeout(()=>x(q=>q==="saved"?"idle":q),2e3)}catch(I){h("error"),E(I instanceof Error?I.message:String(I)),setTimeout(()=>h("idle"),4e3)}}},[g,Z]);return c?p?e.jsx("div",{className:"bg-red-500/10 border border-red-500/30 rounded-xl p-4 text-xs text-red-400",children:o("modelRouting.loadError",{error:p})}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx(ga,{status:T,t:o}),e.jsxs("div",{className:"flex flex-col items-end gap-1",children:[e.jsx("button",{type:"button",onClick:()=>U(!0),disabled:g==="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:o(g==="working"?"modelRouting.restoreWorking":"modelRouting.restoreRecommended")}),N&&e.jsx("span",{className:"text-[10px] text-red-400 max-w-xs text-right",children:N})]})]}),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:o("modelRouting.defaultModelTitle")}),e.jsx("p",{className:"text-xs text-fg-tertiary mt-1",children:o("modelRouting.defaultModelDesc")})]}),e.jsx("div",{className:"max-w-md",children:e.jsx(Os,{value:t?`${t.provider}/${t.model}`:"",options:$,placeholder:o("modelRouting.defaultModelPlaceholder"),onChange:I=>{if(!I)d(null),f(void 0,null);else{const[H,...q]=I.split("/"),m={provider:H,model:q.join("/")};if(d(m),n.text){const L={...n};delete L.text,a(L),f(L,m)}else f(void 0,m)}}})})]}),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:o("modelRouting.capabilityAssignTitle")}),e.jsx("p",{className:"text-xs text-fg-tertiary mt-1",children:o("modelRouting.capabilityAssignDesc")})]}),r.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:o("modelRouting.noProvidersHint")}),r.length>0&&e.jsx("div",{className:"space-y-4",children:Pr.map(I=>e.jsx(xa,{groupKey:I.groupKey,capabilities:I.capabilities,assignments:n,suggestions:A,allModels:$,configuredProviderNames:new Set(r.map(H=>H.name)),t:o,onAssign:(H,q)=>{const m={...n};q?m[H]=q:delete m[H],a(m),f(m)}},I.groupKey))})]}),O&&e.jsx(bn,{variant:"primary",title:o("modelRouting.restoreRecommended"),message:o("modelRouting.restoreConfirm"),confirmLabel:o("common:confirm"),onConfirm:()=>{U(!1),ne()},onCancel:()=>U(!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(I=>e.jsx("div",{className:"h-10 bg-surface-overlay rounded-lg"},I))})]})})}function xa({groupKey:s,capabilities:r,assignments:o,suggestions:n,allModels:a,configuredProviderNames:t,t:d,onAssign:c}){return e.jsxs("div",{children:[e.jsx("div",{className:"text-[10px] font-semibold text-fg-tertiary uppercase tracking-wider mb-2 px-1",children:d(`modelRouting.capabilityGroups.${s}`)}),e.jsx("div",{className:"space-y-1",children:r.map(u=>{const p=o[u],y=n[u],T=p?`${p.provider}/${p.model}`:"",x=jn(a,u),v=y?x.find(S=>S.provider===y.provider&&S.modelId===y.model)?.modelName??y.model:void 0,w=x.length>0,A=p?ma(a,p.provider,p.model):void 0,K=p&&!t.has(p.provider),j=!!(p&&w&&u!=="text"&&!x.some(S=>S.provider===p.provider&&S.modelId===p.model));return e.jsxs("div",{className:`flex items-center gap-3 px-3 py-2 rounded-lg ${j?"bg-red-500/10 border border-red-500/30":K?"bg-yellow-500/10 border border-yellow-500/30":!w&&!p?"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:d(`modelRouting.capabilities.${u}`)})}),e.jsx("div",{className:"flex-1 min-w-0",children:j?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:["⚠ ",p.model]}),e.jsx("span",{className:"text-[10px] text-red-400/70",children:d("modelRouting.mismatchHint")})]}),e.jsx(Os,{value:"",options:x,placeholder:d("modelRouting.selectModel"),onChange:S=>{if(!S)c(u,null);else{const[g,...h]=S.split("/");c(u,{provider:g,model:h.join("/")})}}})]}):w?e.jsx(Os,{value:T,options:x,placeholder:v?`${v} (${d("modelRouting.suggested")})`:d("modelRouting.selectModel"),onChange:S=>{if(!S)c(u,null);else{const[g,...h]=S.split("/");c(u,{provider:g,model:h.join("/")})}}}):e.jsxs("span",{className:"text-xs text-amber-400",children:[d("modelRouting.noModelAvailable"),e.jsxs("span",{className:"text-fg-tertiary ml-1",children:["— ",d("modelRouting.addProviderHint")]})]})}),e.jsxs("div",{className:"w-14 shrink-0 flex justify-end",children:[j&&e.jsx("span",{className:"text-[10px] text-red-400 font-medium",title:d("modelRouting.mismatchHint"),children:"⚠"}),!j&&K&&e.jsx("span",{className:"text-[10px] text-yellow-400 font-medium",title:d("modelRouting.staleProvider"),children:"⚠"}),!j&&!K&&A&&e.jsx(Ar,{tier:A}),!j&&!K&&!A&&p&&e.jsx(Ar,{tier:"unknown"})]}),e.jsx("div",{className:"w-8 shrink-0 flex justify-end",children:p&&e.jsx("button",{onClick:()=>c(u,null),className:"text-fg-tertiary hover:text-red-400 transition-colors",title:d("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"})})})})]},u)})})]})}function ma(s,r,o){return s.find(a=>a.provider===r&&a.modelId===o)?.tier}function ga({status:s,t:r}){if(s==="idle")return null;const o={idle:"",saving:"text-fg-tertiary",saved:"text-green-400",error:"text-red-400"},n={idle:"",saving:r("modelRouting.saving"),saved:r("modelRouting.saved"),error:r("modelRouting.saveError")};return e.jsx("div",{className:`text-xs font-medium transition-opacity ${o[s]}`,children:n[s]})}function Ar({tier:s}){const r={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 ${r[s]??r.unknown}`,children:s==="unknown"?"—":s})}const fa=new Set(["imageGeneration","tts","stt","videoGeneration","audioOutput","audioInput"]);function jn(s,r){if(r==="text")return s.filter(d=>!(d.capabilities&&d.capabilities.some(c=>fa.has(c))||d.mode&&d.mode!=="chat"));const o={image_generation:["image_generation"],audio_tts:["audio_speech"],audio_stt:["audio_transcription"],video_generation:["video_generation"]},n={image_recognition:["vision"],image_generation:["imageGeneration"],audio_tts:["tts"],audio_stt:["stt"],video_generation:["videoGeneration"]},a=o[r],t=n[r];return s.filter(d=>!!(d.capabilities&&d.capabilities.length>0&&t&&t.some(c=>d.capabilities.includes(c))||a&&d.mode&&a.includes(d.mode)))}const Ct=[{id:"markus",label:"Markus Cloud AI",envKey:"MARKUS_SUBSCRIPTION_KEY",defaultModel:""},{id:"anthropic",label:"Anthropic",envKey:"ANTHROPIC_API_KEY",defaultModel:"claude-opus-4-6"},{id:"openai",label:"OpenAI",envKey:"OPENAI_API_KEY",defaultModel:"gpt-5.4"},{id:"google",label:"Google Gemini",envKey:"GOOGLE_API_KEY",defaultModel:"gemini-3-1-pro"},{id:"deepseek",label:"DeepSeek",envKey:"DEEPSEEK_API_KEY",baseUrl:"https://api.deepseek.com",defaultModel:"deepseek-v4-flash"},{id:"siliconflow",label:"SiliconFlow (中国)",envKey:"SILICONFLOW_API_KEY",baseUrl:"https://api.siliconflow.cn/v1",defaultModel:"Qwen/Qwen3.5-35B-A3B"},{id:"siliconflow-intl",label:"SiliconFlow (Global)",envKey:"SILICONFLOW_INTL_API_KEY",baseUrl:"https://api-st.siliconflow.cn/v1",defaultModel:"Qwen/Qwen3.5-35B-A3B"},{id:"minimax",label:"MiniMax (Global)",envKey:"MINIMAX_API_KEY",baseUrl:"https://api.minimax.io/v1",defaultModel:"MiniMax-M3"},{id:"minimax-cn",label:"MiniMax (中国)",envKey:"MINIMAX_CN_API_KEY",baseUrl:"https://api.minimaxi.com/v1",defaultModel:"MiniMax-M3"},{id:"openrouter",label:"OpenRouter",envKey:"OPENROUTER_API_KEY",baseUrl:"https://openrouter.ai/api/v1",defaultModel:"xiaomi/mimo-v2-pro:free"},{id:"zai",label:"ZAI (GLM)",envKey:"ZAI_API_KEY",baseUrl:"https://api.z.ai/api/paas/v4",defaultModel:"glm-5.1"},{id:"xai",label:"xAI (Grok)",envKey:"XAI_API_KEY",baseUrl:"https://api.x.ai/v1",defaultModel:"grok-3"},{id:"mistral",label:"Mistral AI",envKey:"MISTRAL_API_KEY",baseUrl:"https://api.mistral.ai/v1",defaultModel:"mistral-large-latest"},{id:"groq",label:"Groq",envKey:"GROQ_API_KEY",baseUrl:"https://api.groq.com/openai/v1",defaultModel:"llama-3.3-70b-versatile"},{id:"perplexity",label:"Perplexity",envKey:"PERPLEXITY_API_KEY",baseUrl:"https://api.perplexity.ai",defaultModel:"sonar-pro"},{id:"cohere",label:"Cohere",envKey:"COHERE_API_KEY",baseUrl:"https://api.cohere.ai/compatibility/v1",defaultModel:"command-r-plus"},{id:"together_ai",label:"Together AI",envKey:"TOGETHER_API_KEY",baseUrl:"https://api.together.xyz/v1",defaultModel:"meta-llama/Llama-3.3-70B-Instruct-Turbo"},{id:"fireworks_ai",label:"Fireworks AI",envKey:"FIREWORKS_API_KEY",baseUrl:"https://api.fireworks.ai/inference/v1",defaultModel:"accounts/fireworks/models/llama-v3p3-70b-instruct"},{id:"moonshot",label:"Moonshot (Kimi)",envKey:"MOONSHOT_API_KEY",baseUrl:"https://api.moonshot.cn/v1",defaultModel:"moonshot-v1-auto"},{id:"volcengine",label:"Volcengine (Doubao)",envKey:"VOLCENGINE_API_KEY",baseUrl:"https://ark.cn-beijing.volces.com/api/v3",defaultModel:"doubao-1.5-pro-32k"},{id:"dashscope",label:"DashScope (Qwen)",envKey:"DASHSCOPE_API_KEY",baseUrl:"https://dashscope.aliyuncs.com/compatible-mode/v1",defaultModel:"qwen-max"},{id:"ollama",label:"Ollama (Local)",envKey:"OLLAMA_BASE_URL",baseUrl:"http://localhost:11434/v1",defaultModel:"llama3"},{id:"atlascloud",label:"Atlas Cloud (Full-Modal)",envKey:"ATLASCLOUD_API_KEY",baseUrl:"https://api.atlascloud.ai/v1",defaultModel:"claude-sonnet-4-6"},{id:"strongly",label:"Strongly.AI (Full-Modal)",envKey:"STRONGLY_API_KEY",baseUrl:"https://api.strongly.ai/v1",defaultModel:"claude-sonnet-4-6"}];var Ye={},os,Mr;function pa(){return Mr||(Mr=1,os=function(){return typeof Promise=="function"&&Promise.prototype&&Promise.prototype.then}),os}var is={},De={},Tr;function $e(){if(Tr)return De;Tr=1;let s;const r=[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 De.getSymbolSize=function(n){if(!n)throw new Error('"version" cannot be null or undefined');if(n<1||n>40)throw new Error('"version" should be in range from 1 to 40');return n*4+17},De.getSymbolTotalCodewords=function(n){return r[n]},De.getBCHDigit=function(o){let n=0;for(;o!==0;)n++,o>>>=1;return n},De.setToSJISFunction=function(n){if(typeof n!="function")throw new Error('"toSJISFunc" is not a valid function.');s=n},De.isKanjiModeEnabled=function(){return typeof s<"u"},De.toSJIS=function(n){return s(n)},De}var ls={},Er;function _s(){return Er||(Er=1,(function(s){s.L={bit:1},s.M={bit:0},s.Q={bit:3},s.H={bit:2};function r(o){if(typeof o!="string")throw new Error("Param is not a string");switch(o.toLowerCase()){case"l":case"low":return s.L;case"m":case"medium":return s.M;case"q":case"quartile":return s.Q;case"h":case"high":return s.H;default:throw new Error("Unknown EC Level: "+o)}}s.isValid=function(n){return n&&typeof n.bit<"u"&&n.bit>=0&&n.bit<4},s.from=function(n,a){if(s.isValid(n))return n;try{return r(n)}catch{return a}}})(ls)),ls}var ds,Ir;function ha(){if(Ir)return ds;Ir=1;function s(){this.buffer=[],this.length=0}return s.prototype={get:function(r){const o=Math.floor(r/8);return(this.buffer[o]>>>7-r%8&1)===1},put:function(r,o){for(let n=0;n<o;n++)this.putBit((r>>>o-n-1&1)===1)},getLengthInBits:function(){return this.length},putBit:function(r){const o=Math.floor(this.length/8);this.buffer.length<=o&&this.buffer.push(0),r&&(this.buffer[o]|=128>>>this.length%8),this.length++}},ds=s,ds}var cs,Lr;function ba(){if(Lr)return cs;Lr=1;function s(r){if(!r||r<1)throw new Error("BitMatrix size must be defined and greater than 0");this.size=r,this.data=new Uint8Array(r*r),this.reservedBit=new Uint8Array(r*r)}return s.prototype.set=function(r,o,n,a){const t=r*this.size+o;this.data[t]=n,a&&(this.reservedBit[t]=!0)},s.prototype.get=function(r,o){return this.data[r*this.size+o]},s.prototype.xor=function(r,o,n){this.data[r*this.size+o]^=n},s.prototype.isReserved=function(r,o){return this.reservedBit[r*this.size+o]},cs=s,cs}var us={},Rr;function ya(){return Rr||(Rr=1,(function(s){const r=$e().getSymbolSize;s.getRowColCoords=function(n){if(n===1)return[];const a=Math.floor(n/7)+2,t=r(n),d=t===145?26:Math.ceil((t-13)/(2*a-2))*2,c=[t-7];for(let u=1;u<a-1;u++)c[u]=c[u-1]-d;return c.push(6),c.reverse()},s.getPositions=function(n){const a=[],t=s.getRowColCoords(n),d=t.length;for(let c=0;c<d;c++)for(let u=0;u<d;u++)c===0&&u===0||c===0&&u===d-1||c===d-1&&u===0||a.push([t[c],t[u]]);return a}})(us)),us}var xs={},Or;function va(){if(Or)return xs;Or=1;const s=$e().getSymbolSize,r=7;return xs.getPositions=function(n){const a=s(n);return[[0,0],[a-r,0],[0,a-r]]},xs}var ms={},Br;function ja(){return Br||(Br=1,(function(s){s.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};const r={N1:3,N2:3,N3:40,N4:10};s.isValid=function(a){return a!=null&&a!==""&&!isNaN(a)&&a>=0&&a<=7},s.from=function(a){return s.isValid(a)?parseInt(a,10):void 0},s.getPenaltyN1=function(a){const t=a.size;let d=0,c=0,u=0,p=null,y=null;for(let T=0;T<t;T++){c=u=0,p=y=null;for(let x=0;x<t;x++){let v=a.get(T,x);v===p?c++:(c>=5&&(d+=r.N1+(c-5)),p=v,c=1),v=a.get(x,T),v===y?u++:(u>=5&&(d+=r.N1+(u-5)),y=v,u=1)}c>=5&&(d+=r.N1+(c-5)),u>=5&&(d+=r.N1+(u-5))}return d},s.getPenaltyN2=function(a){const t=a.size;let d=0;for(let c=0;c<t-1;c++)for(let u=0;u<t-1;u++){const p=a.get(c,u)+a.get(c,u+1)+a.get(c+1,u)+a.get(c+1,u+1);(p===4||p===0)&&d++}return d*r.N2},s.getPenaltyN3=function(a){const t=a.size;let d=0,c=0,u=0;for(let p=0;p<t;p++){c=u=0;for(let y=0;y<t;y++)c=c<<1&2047|a.get(p,y),y>=10&&(c===1488||c===93)&&d++,u=u<<1&2047|a.get(y,p),y>=10&&(u===1488||u===93)&&d++}return d*r.N3},s.getPenaltyN4=function(a){let t=0;const d=a.data.length;for(let u=0;u<d;u++)t+=a.data[u];return Math.abs(Math.ceil(t*100/d/5)-10)*r.N4};function o(n,a,t){switch(n){case s.Patterns.PATTERN000:return(a+t)%2===0;case s.Patterns.PATTERN001:return a%2===0;case s.Patterns.PATTERN010:return t%3===0;case s.Patterns.PATTERN011:return(a+t)%3===0;case s.Patterns.PATTERN100:return(Math.floor(a/2)+Math.floor(t/3))%2===0;case s.Patterns.PATTERN101:return a*t%2+a*t%3===0;case s.Patterns.PATTERN110:return(a*t%2+a*t%3)%2===0;case s.Patterns.PATTERN111:return(a*t%3+(a+t)%2)%2===0;default:throw new Error("bad maskPattern:"+n)}}s.applyMask=function(a,t){const d=t.size;for(let c=0;c<d;c++)for(let u=0;u<d;u++)t.isReserved(u,c)||t.xor(u,c,o(a,u,c))},s.getBestMask=function(a,t){const d=Object.keys(s.Patterns).length;let c=0,u=1/0;for(let p=0;p<d;p++){t(p),s.applyMask(p,a);const y=s.getPenaltyN1(a)+s.getPenaltyN2(a)+s.getPenaltyN3(a)+s.getPenaltyN4(a);s.applyMask(p,a),y<u&&(u=y,c=p)}return c}})(ms)),ms}var St={},_r;function Nn(){if(_r)return St;_r=1;const s=_s(),r=[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],o=[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 St.getBlocksCount=function(a,t){switch(t){case s.L:return r[(a-1)*4+0];case s.M:return r[(a-1)*4+1];case s.Q:return r[(a-1)*4+2];case s.H:return r[(a-1)*4+3];default:return}},St.getTotalCodewordsCount=function(a,t){switch(t){case s.L:return o[(a-1)*4+0];case s.M:return o[(a-1)*4+1];case s.Q:return o[(a-1)*4+2];case s.H:return o[(a-1)*4+3];default:return}},St}var gs={},at={},Dr;function Na(){if(Dr)return at;Dr=1;const s=new Uint8Array(512),r=new Uint8Array(256);return(function(){let n=1;for(let a=0;a<255;a++)s[a]=n,r[n]=a,n<<=1,n&256&&(n^=285);for(let a=255;a<512;a++)s[a]=s[a-255]})(),at.log=function(n){if(n<1)throw new Error("log("+n+")");return r[n]},at.exp=function(n){return s[n]},at.mul=function(n,a){return n===0||a===0?0:s[r[n]+r[a]]},at}var Kr;function wa(){return Kr||(Kr=1,(function(s){const r=Na();s.mul=function(n,a){const t=new Uint8Array(n.length+a.length-1);for(let d=0;d<n.length;d++)for(let c=0;c<a.length;c++)t[d+c]^=r.mul(n[d],a[c]);return t},s.mod=function(n,a){let t=new Uint8Array(n);for(;t.length-a.length>=0;){const d=t[0];for(let u=0;u<a.length;u++)t[u]^=r.mul(a[u],d);let c=0;for(;c<t.length&&t[c]===0;)c++;t=t.slice(c)}return t},s.generateECPolynomial=function(n){let a=new Uint8Array([1]);for(let t=0;t<n;t++)a=s.mul(a,new Uint8Array([1,r.exp(t)]));return a}})(gs)),gs}var fs,Ur;function ka(){if(Ur)return fs;Ur=1;const s=wa();function r(o){this.genPoly=void 0,this.degree=o,this.degree&&this.initialize(this.degree)}return r.prototype.initialize=function(n){this.degree=n,this.genPoly=s.generateECPolynomial(this.degree)},r.prototype.encode=function(n){if(!this.genPoly)throw new Error("Encoder not initialized");const a=new Uint8Array(n.length+this.degree);a.set(n);const t=s.mod(a,this.genPoly),d=this.degree-t.length;if(d>0){const c=new Uint8Array(this.degree);return c.set(t,d),c}return t},fs=r,fs}var ps={},hs={},bs={},Fr;function wn(){return Fr||(Fr=1,bs.isValid=function(r){return!isNaN(r)&&r>=1&&r<=40}),bs}var Pe={},$r;function kn(){if($r)return Pe;$r=1;const s="[0-9]+",r="[A-Z $%*+\\-./:]+";let o="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";o=o.replace(/u/g,"\\u");const n="(?:(?![A-Z0-9 $%*+\\-./:]|"+o+`)(?:.|[\r
2
2
  ]))+`;Pe.KANJI=new RegExp(o,"g"),Pe.BYTE_KANJI=new RegExp("[^A-Z0-9 $%*+\\-./:]+","g"),Pe.BYTE=new RegExp(n,"g"),Pe.NUMERIC=new RegExp(s,"g"),Pe.ALPHANUMERIC=new RegExp(r,"g");const a=new RegExp("^"+o+"$"),t=new RegExp("^"+s+"$"),d=new RegExp("^[A-Z0-9 $%*+\\-./:]+$");return Pe.testKanji=function(u){return a.test(u)},Pe.testNumeric=function(u){return t.test(u)},Pe.testAlphanumeric=function(u){return d.test(u)},Pe}var Vr;function Ve(){return Vr||(Vr=1,(function(s){const r=wn(),o=kn();s.NUMERIC={id:"Numeric",bit:1,ccBits:[10,12,14]},s.ALPHANUMERIC={id:"Alphanumeric",bit:2,ccBits:[9,11,13]},s.BYTE={id:"Byte",bit:4,ccBits:[8,16,16]},s.KANJI={id:"Kanji",bit:8,ccBits:[8,10,12]},s.MIXED={bit:-1},s.getCharCountIndicator=function(t,d){if(!t.ccBits)throw new Error("Invalid mode: "+t);if(!r.isValid(d))throw new Error("Invalid version: "+d);return d>=1&&d<10?t.ccBits[0]:d<27?t.ccBits[1]:t.ccBits[2]},s.getBestModeForData=function(t){return o.testNumeric(t)?s.NUMERIC:o.testAlphanumeric(t)?s.ALPHANUMERIC:o.testKanji(t)?s.KANJI:s.BYTE},s.toString=function(t){if(t&&t.id)return t.id;throw new Error("Invalid mode")},s.isValid=function(t){return t&&t.bit&&t.ccBits};function n(a){if(typeof a!="string")throw new Error("Param is not a string");switch(a.toLowerCase()){case"numeric":return s.NUMERIC;case"alphanumeric":return s.ALPHANUMERIC;case"kanji":return s.KANJI;case"byte":return s.BYTE;default:throw new Error("Unknown mode: "+a)}}s.from=function(t,d){if(s.isValid(t))return t;try{return n(t)}catch{return d}}})(hs)),hs}var Hr;function Ca(){return Hr||(Hr=1,(function(s){const r=$e(),o=Nn(),n=_s(),a=Ve(),t=wn(),d=7973,c=r.getBCHDigit(d);function u(x,v,w){for(let A=1;A<=40;A++)if(v<=s.getCapacity(A,w,x))return A}function p(x,v){return a.getCharCountIndicator(x,v)+4}function y(x,v){let w=0;return x.forEach(function(A){const K=p(A.mode,v);w+=K+A.getBitsLength()}),w}function T(x,v){for(let w=1;w<=40;w++)if(y(x,w)<=s.getCapacity(w,v,a.MIXED))return w}s.from=function(v,w){return t.isValid(v)?parseInt(v,10):w},s.getCapacity=function(v,w,A){if(!t.isValid(v))throw new Error("Invalid QR Code version");typeof A>"u"&&(A=a.BYTE);const K=r.getSymbolTotalCodewords(v),j=o.getTotalCodewordsCount(v,w),S=(K-j)*8;if(A===a.MIXED)return S;const g=S-p(A,v);switch(A){case a.NUMERIC:return Math.floor(g/10*3);case a.ALPHANUMERIC:return Math.floor(g/11*2);case a.KANJI:return Math.floor(g/13);case a.BYTE:default:return Math.floor(g/8)}},s.getBestVersionForData=function(v,w){let A;const K=n.from(w,n.M);if(Array.isArray(v)){if(v.length>1)return T(v,K);if(v.length===0)return 1;A=v[0]}else A=v;return u(A.mode,A.getLength(),K)},s.getEncodedBits=function(v){if(!t.isValid(v)||v<7)throw new Error("Invalid QR Code version");let w=v<<12;for(;r.getBCHDigit(w)-c>=0;)w^=d<<r.getBCHDigit(w)-c;return v<<12|w}})(ps)),ps}var ys={},qr;function Sa(){if(qr)return ys;qr=1;const s=$e(),r=1335,o=21522,n=s.getBCHDigit(r);return ys.getEncodedBits=function(t,d){const c=t.bit<<3|d;let u=c<<10;for(;s.getBCHDigit(u)-n>=0;)u^=r<<s.getBCHDigit(u)-n;return(c<<10|u)^o},ys}var vs={},js,zr;function Pa(){if(zr)return js;zr=1;const s=Ve();function r(o){this.mode=s.NUMERIC,this.data=o.toString()}return r.getBitsLength=function(n){return 10*Math.floor(n/3)+(n%3?n%3*3+1:0)},r.prototype.getLength=function(){return this.data.length},r.prototype.getBitsLength=function(){return r.getBitsLength(this.data.length)},r.prototype.write=function(n){let a,t,d;for(a=0;a+3<=this.data.length;a+=3)t=this.data.substr(a,3),d=parseInt(t,10),n.put(d,10);const c=this.data.length-a;c>0&&(t=this.data.substr(a),d=parseInt(t,10),n.put(d,c*3+1))},js=r,js}var Ns,Wr;function Aa(){if(Wr)return Ns;Wr=1;const s=Ve(),r=["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 o(n){this.mode=s.ALPHANUMERIC,this.data=n}return o.getBitsLength=function(a){return 11*Math.floor(a/2)+6*(a%2)},o.prototype.getLength=function(){return this.data.length},o.prototype.getBitsLength=function(){return o.getBitsLength(this.data.length)},o.prototype.write=function(a){let t;for(t=0;t+2<=this.data.length;t+=2){let d=r.indexOf(this.data[t])*45;d+=r.indexOf(this.data[t+1]),a.put(d,11)}this.data.length%2&&a.put(r.indexOf(this.data[t]),6)},Ns=o,Ns}var ws,Gr;function Ma(){if(Gr)return ws;Gr=1;const s=Ve();function r(o){this.mode=s.BYTE,typeof o=="string"?this.data=new TextEncoder().encode(o):this.data=new Uint8Array(o)}return r.getBitsLength=function(n){return n*8},r.prototype.getLength=function(){return this.data.length},r.prototype.getBitsLength=function(){return r.getBitsLength(this.data.length)},r.prototype.write=function(o){for(let n=0,a=this.data.length;n<a;n++)o.put(this.data[n],8)},ws=r,ws}var ks,Yr;function Ta(){if(Yr)return ks;Yr=1;const s=Ve(),r=$e();function o(n){this.mode=s.KANJI,this.data=n}return o.getBitsLength=function(a){return a*13},o.prototype.getLength=function(){return this.data.length},o.prototype.getBitsLength=function(){return o.getBitsLength(this.data.length)},o.prototype.write=function(n){let a;for(a=0;a<this.data.length;a++){let t=r.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),n.put(t,13)}},ks=o,ks}var Cs={exports:{}},Jr;function Ea(){return Jr||(Jr=1,(function(s){var r={single_source_shortest_paths:function(o,n,a){var t={},d={};d[n]=0;var c=r.PriorityQueue.make();c.push(n,0);for(var u,p,y,T,x,v,w,A,K;!c.empty();){u=c.pop(),p=u.value,T=u.cost,x=o[p]||{};for(y in x)x.hasOwnProperty(y)&&(v=x[y],w=T+v,A=d[y],K=typeof d[y]>"u",(K||A>w)&&(d[y]=w,c.push(y,w),t[y]=p))}if(typeof a<"u"&&typeof d[a]>"u"){var j=["Could not find a path from ",n," to ",a,"."].join("");throw new Error(j)}return t},extract_shortest_path_from_predecessor_list:function(o,n){for(var a=[],t=n;t;)a.push(t),o[t],t=o[t];return a.reverse(),a},find_path:function(o,n,a){var t=r.single_source_shortest_paths(o,n,a);return r.extract_shortest_path_from_predecessor_list(t,a)},PriorityQueue:{make:function(o){var n=r.PriorityQueue,a={},t;o=o||{};for(t in n)n.hasOwnProperty(t)&&(a[t]=n[t]);return a.queue=[],a.sorter=o.sorter||n.default_sorter,a},default_sorter:function(o,n){return o.cost-n.cost},push:function(o,n){var a={value:o,cost:n};this.queue.push(a),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return this.queue.length===0}}};s.exports=r})(Cs)),Cs.exports}var Qr;function Ia(){return Qr||(Qr=1,(function(s){const r=Ve(),o=Pa(),n=Aa(),a=Ma(),t=Ta(),d=kn(),c=$e(),u=Ea();function p(j){return unescape(encodeURIComponent(j)).length}function y(j,S,g){const h=[];let N;for(;(N=j.exec(g))!==null;)h.push({data:N[0],index:N.index,mode:S,length:N[0].length});return h}function T(j){const S=y(d.NUMERIC,r.NUMERIC,j),g=y(d.ALPHANUMERIC,r.ALPHANUMERIC,j);let h,N;return c.isKanjiModeEnabled()?(h=y(d.BYTE,r.BYTE,j),N=y(d.KANJI,r.KANJI,j)):(h=y(d.BYTE_KANJI,r.BYTE,j),N=[]),S.concat(g,h,N).sort(function(O,U){return O.index-U.index}).map(function(O){return{data:O.data,mode:O.mode,length:O.length}})}function x(j,S){switch(S){case r.NUMERIC:return o.getBitsLength(j);case r.ALPHANUMERIC:return n.getBitsLength(j);case r.KANJI:return t.getBitsLength(j);case r.BYTE:return a.getBitsLength(j)}}function v(j){return j.reduce(function(S,g){const h=S.length-1>=0?S[S.length-1]:null;return h&&h.mode===g.mode?(S[S.length-1].data+=g.data,S):(S.push(g),S)},[])}function w(j){const S=[];for(let g=0;g<j.length;g++){const h=j[g];switch(h.mode){case r.NUMERIC:S.push([h,{data:h.data,mode:r.ALPHANUMERIC,length:h.length},{data:h.data,mode:r.BYTE,length:h.length}]);break;case r.ALPHANUMERIC:S.push([h,{data:h.data,mode:r.BYTE,length:h.length}]);break;case r.KANJI:S.push([h,{data:h.data,mode:r.BYTE,length:p(h.data)}]);break;case r.BYTE:S.push([{data:h.data,mode:r.BYTE,length:p(h.data)}])}}return S}function A(j,S){const g={},h={start:{}};let N=["start"];for(let E=0;E<j.length;E++){const O=j[E],U=[];for(let _=0;_<O.length;_++){const D=O[_],R=""+E+_;U.push(R),g[R]={node:D,lastCount:0},h[R]={};for(let P=0;P<N.length;P++){const f=N[P];g[f]&&g[f].node.mode===D.mode?(h[f][R]=x(g[f].lastCount+D.length,D.mode)-x(g[f].lastCount,D.mode),g[f].lastCount+=D.length):(g[f]&&(g[f].lastCount=D.length),h[f][R]=x(D.length,D.mode)+4+r.getCharCountIndicator(D.mode,S))}}N=U}for(let E=0;E<N.length;E++)h[N[E]].end=0;return{map:h,table:g}}function K(j,S){let g;const h=r.getBestModeForData(j);if(g=r.from(S,h),g!==r.BYTE&&g.bit<h.bit)throw new Error('"'+j+'" cannot be encoded with mode '+r.toString(g)+`.
4
4
  Suggested mode is: `+r.toString(h));switch(g===r.KANJI&&!c.isKanjiModeEnabled()&&(g=r.BYTE),g){case r.NUMERIC:return new o(j);case r.ALPHANUMERIC:return new n(j);case r.KANJI:return new t(j);case r.BYTE:return new a(j)}}s.fromArray=function(S){return S.reduce(function(g,h){return typeof h=="string"?g.push(K(h,null)):h.data&&g.push(K(h.data,h.mode)),g},[])},s.fromString=function(S,g){const h=T(S,c.isKanjiModeEnabled()),N=w(h),E=A(N,g),O=u.find_path(E.map,"start","end"),U=[];for(let _=1;_<O.length-1;_++)U.push(E.table[O[_]].node);return s.fromArray(v(U))},s.rawSplit=function(S){return s.fromArray(T(S,c.isKanjiModeEnabled()))}})(vs)),vs}var Xr;function La(){if(Xr)return is;Xr=1;const s=$e(),r=_s(),o=ha(),n=ba(),a=ya(),t=va(),d=ja(),c=Nn(),u=ka(),p=Ca(),y=Sa(),T=Ve(),x=Ia();function v(E,O){const U=E.size,_=t.getPositions(O);for(let D=0;D<_.length;D++){const R=_[D][0],P=_[D][1];for(let f=-1;f<=7;f++)if(!(R+f<=-1||U<=R+f))for(let k=-1;k<=7;k++)P+k<=-1||U<=P+k||(f>=0&&f<=6&&(k===0||k===6)||k>=0&&k<=6&&(f===0||f===6)||f>=2&&f<=4&&k>=2&&k<=4?E.set(R+f,P+k,!0,!0):E.set(R+f,P+k,!1,!0))}}function w(E){const O=E.size;for(let U=8;U<O-8;U++){const _=U%2===0;E.set(U,6,_,!0),E.set(6,U,_,!0)}}function A(E,O){const U=a.getPositions(O);for(let _=0;_<U.length;_++){const D=U[_][0],R=U[_][1];for(let P=-2;P<=2;P++)for(let f=-2;f<=2;f++)P===-2||P===2||f===-2||f===2||P===0&&f===0?E.set(D+P,R+f,!0,!0):E.set(D+P,R+f,!1,!0)}}function K(E,O){const U=E.size,_=p.getEncodedBits(O);let D,R,P;for(let f=0;f<18;f++)D=Math.floor(f/3),R=f%3+U-8-3,P=(_>>f&1)===1,E.set(D,R,P,!0),E.set(R,D,P,!0)}function j(E,O,U){const _=E.size,D=y.getEncodedBits(O,U);let R,P;for(R=0;R<15;R++)P=(D>>R&1)===1,R<6?E.set(R,8,P,!0):R<8?E.set(R+1,8,P,!0):E.set(_-15+R,8,P,!0),R<8?E.set(8,_-R-1,P,!0):R<9?E.set(8,15-R-1+1,P,!0):E.set(8,15-R-1,P,!0);E.set(_-8,8,1,!0)}function S(E,O){const U=E.size;let _=-1,D=U-1,R=7,P=0;for(let f=U-1;f>0;f-=2)for(f===6&&f--;;){for(let k=0;k<2;k++)if(!E.isReserved(D,f-k)){let $=!1;P<O.length&&($=(O[P]>>>R&1)===1),E.set(D,f-k,$),R--,R===-1&&(P++,R=7)}if(D+=_,D<0||U<=D){D-=_,_=-_;break}}}function g(E,O,U){const _=new o;U.forEach(function(k){_.put(k.mode.bit,4),_.put(k.getLength(),T.getCharCountIndicator(k.mode,E)),k.write(_)});const D=s.getSymbolTotalCodewords(E),R=c.getTotalCodewordsCount(E,O),P=(D-R)*8;for(_.getLengthInBits()+4<=P&&_.put(0,4);_.getLengthInBits()%8!==0;)_.putBit(0);const f=(P-_.getLengthInBits())/8;for(let k=0;k<f;k++)_.put(k%2?17:236,8);return h(_,E,O)}function h(E,O,U){const _=s.getSymbolTotalCodewords(O),D=c.getTotalCodewordsCount(O,U),R=_-D,P=c.getBlocksCount(O,U),f=_%P,k=P-f,$=Math.floor(_/P),J=Math.floor(R/P),Z=J+1,ne=$-J,I=new u(ne);let H=0;const q=new Array(P),m=new Array(P);let L=0;const V=new Uint8Array(E.buffer);for(let le=0;le<P;le++){const Ee=le<k?J:Z;q[le]=V.slice(H,H+Ee),m[le]=I.encode(q[le]),H+=Ee,L=Math.max(L,Ee)}const X=new Uint8Array(_);let ee=0,Q,Y;for(Q=0;Q<L;Q++)for(Y=0;Y<P;Y++)Q<q[Y].length&&(X[ee++]=q[Y][Q]);for(Q=0;Q<ne;Q++)for(Y=0;Y<P;Y++)X[ee++]=m[Y][Q];return X}function N(E,O,U,_){let D;if(Array.isArray(E))D=x.fromArray(E);else if(typeof E=="string"){let $=O;if(!$){const J=x.rawSplit(E);$=p.getBestVersionForData(J,U)}D=x.fromString(E,$||40)}else throw new Error("Invalid data");const R=p.getBestVersionForData(D,U);if(!R)throw new Error("The amount of data is too big to be stored in a QR Code");if(!O)O=R;else if(O<R)throw new Error(`
@@ -1 +1 @@
1
- import{u as y,r as d,a as S,b as T,j as e,S as N,T as L,c as _,d as M,I as E,h as z,i as D}from"./index-BVZKeNvh.js";const k=[{id:"discover"},{id:"agents"},{id:"teams"},{id:"skills"},{id:"installed"}],I={agent:"agents",team:"teams",skill:"skills",connector:"skills"},C={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 b(a){return a==="discover"||a==="agents"||a==="teams"||a==="skills"||a==="installed"}function w(){const a=localStorage.getItem("markus_nav_installItem"),i=localStorage.getItem("markus_nav_storeTab");if(a)return{tab:b(i)?i:"agents",installId:a};const x=new URLSearchParams(window.location.search),s=x.get("install");if(s){const n=x.get("type");return{tab:n&&I[n]||"agents",installId:s}}return{tab:b(i)?i:"discover",installId:null}}function j(){localStorage.removeItem("markus_nav_installItem"),localStorage.removeItem("markus_nav_storeTab");const a=new URLSearchParams(window.location.search);if(a.has("install")||a.has("type")){a.delete("install"),a.delete("type");const i=a.toString();window.history.replaceState(null,"",window.location.pathname+(i?`?${i}`:"")+window.location.hash)}}function H({itemId:a,onDismiss:i,onInstalled:x}){const{t:s}=y(["store","common"]),[n,g]=d.useState(null),[h,o]=d.useState("loading"),[c,p]=d.useState(!1),[m,u]=d.useState("");d.useEffect(()=>{let r=!1;return o("loading"),g(null),u(""),z.getItem(a).then(({item:l})=>{r||(l?(g(l),o("ready")):o("missing"))}).catch(()=>{r||o("missing")}),()=>{r=!0}},[a]);const t=async()=>{if(!(!n||c)){p(!0),u("");try{await D(n),u(s("deepLink.installed")),x()}catch(r){const l=r instanceof Error?r.message:"";u(l.includes("402")||l.includes("Purchase")?s("deepLink.purchaseRequired"):s("deepLink.failed"))}finally{p(!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")}),h==="loading"&&e.jsx("p",{className:"text-sm text-fg-secondary",children:s("deepLink.loading")}),h==="missing"&&e.jsx("p",{className:"text-sm text-rose-300",children:s("deepLink.missing")}),h==="ready"&&n&&e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-sm font-semibold text-fg-primary truncate",children:n.name}),n.description&&e.jsx("p",{className:"text-xs text-fg-tertiary line-clamp-2 mt-0.5",children:n.description}),m&&e.jsx("p",{className:"text-xs mt-1 text-brand-300",children:m})]})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[h==="ready"&&n&&e.jsx("button",{type:"button",disabled:c,onClick:()=>{t()},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(c?"deepLink.installing":"deepLink.install")}),e.jsx("button",{type:"button",onClick:i,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 P({authUser:a}){const{t:i}=y(["store","common"]),[x]=d.useState(w),[s,n]=d.useState(x.tab),g=S(),h=T(k,s,n),[o,c]=d.useState(x.installId);d.useEffect(()=>{const t=w();t.installId&&(c(t.installId),b(t.tab)&&n(t.tab),j())},[]),d.useEffect(()=>{const t=r=>{const l=r.detail;if(l.page==="store"||l.page==="explore"){const f=l.params?.storeTab??localStorage.getItem("markus_nav_storeTab"),v=l.params?.installItem??localStorage.getItem("markus_nav_installItem");f&&b(f)&&n(f),v&&c(v),(f||v)&&j()}};return window.addEventListener("markus:navigate",t),()=>window.removeEventListener("markus:navigate",t)},[]);const p=(t,r)=>{const l=I[t]??"agents";r&&c(r),n(l)},m=()=>c(null),u=()=>e.jsxs(e.Fragment,{children:[o&&e.jsx(H,{itemId:o,onDismiss:m,onInstalled:m}),s==="discover"&&e.jsx(N,{onOpenType:p}),s==="agents"&&e.jsx(L,{authUser:a,highlightItemId:o,onHighlightDone:m}),s==="teams"&&e.jsx(_,{highlightItemId:o,onHighlightDone:m}),s==="skills"&&e.jsx(M,{highlightItemId:o,onHighlightDone:m}),s==="installed"&&e.jsx(E,{})]});return g?e.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",onTouchStart:h.onTouchStart,onTouchEnd:h.onTouchEnd,children:[e.jsx("div",{className:"flex shrink-0 overflow-x-auto scrollbar-hide",children:k.map(t=>e.jsx("button",{onClick:()=>n(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:i(`tabs.${t.id}`)},t.id))}),e.jsx("div",{className:"flex-1 overflow-hidden flex flex-col",children:u()})]}):e.jsxs("div",{className:"flex-1 overflow-hidden flex flex-row",children:[e.jsxs("nav",{className:"w-36 shrink-0 bg-surface-secondary rounded-xl m-1 mr-0 flex flex-col py-4 px-2 gap-1",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:i("title")})}),k.map(t=>e.jsxs("button",{onClick:()=>n(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?"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:C[t.id]})}),i(`tabs.${t.id}`)]},t.id))]}),e.jsx("div",{className:"flex-1 overflow-hidden flex flex-col",children:u()})]})}export{P as StorePage};
1
+ import{u as y,r as d,a as S,b as T,j as e,S as N,T as L,c as _,d as M,I as E,h as z,i as D}from"./index-lNtr_En-.js";const k=[{id:"discover"},{id:"agents"},{id:"teams"},{id:"skills"},{id:"installed"}],I={agent:"agents",team:"teams",skill:"skills",connector:"skills"},C={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 b(a){return a==="discover"||a==="agents"||a==="teams"||a==="skills"||a==="installed"}function w(){const a=localStorage.getItem("markus_nav_installItem"),i=localStorage.getItem("markus_nav_storeTab");if(a)return{tab:b(i)?i:"agents",installId:a};const x=new URLSearchParams(window.location.search),s=x.get("install");if(s){const n=x.get("type");return{tab:n&&I[n]||"agents",installId:s}}return{tab:b(i)?i:"discover",installId:null}}function j(){localStorage.removeItem("markus_nav_installItem"),localStorage.removeItem("markus_nav_storeTab");const a=new URLSearchParams(window.location.search);if(a.has("install")||a.has("type")){a.delete("install"),a.delete("type");const i=a.toString();window.history.replaceState(null,"",window.location.pathname+(i?`?${i}`:"")+window.location.hash)}}function H({itemId:a,onDismiss:i,onInstalled:x}){const{t:s}=y(["store","common"]),[n,g]=d.useState(null),[h,o]=d.useState("loading"),[c,p]=d.useState(!1),[m,u]=d.useState("");d.useEffect(()=>{let r=!1;return o("loading"),g(null),u(""),z.getItem(a).then(({item:l})=>{r||(l?(g(l),o("ready")):o("missing"))}).catch(()=>{r||o("missing")}),()=>{r=!0}},[a]);const t=async()=>{if(!(!n||c)){p(!0),u("");try{await D(n),u(s("deepLink.installed")),x()}catch(r){const l=r instanceof Error?r.message:"";u(l.includes("402")||l.includes("Purchase")?s("deepLink.purchaseRequired"):s("deepLink.failed"))}finally{p(!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")}),h==="loading"&&e.jsx("p",{className:"text-sm text-fg-secondary",children:s("deepLink.loading")}),h==="missing"&&e.jsx("p",{className:"text-sm text-rose-300",children:s("deepLink.missing")}),h==="ready"&&n&&e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-sm font-semibold text-fg-primary truncate",children:n.name}),n.description&&e.jsx("p",{className:"text-xs text-fg-tertiary line-clamp-2 mt-0.5",children:n.description}),m&&e.jsx("p",{className:"text-xs mt-1 text-brand-300",children:m})]})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[h==="ready"&&n&&e.jsx("button",{type:"button",disabled:c,onClick:()=>{t()},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(c?"deepLink.installing":"deepLink.install")}),e.jsx("button",{type:"button",onClick:i,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 P({authUser:a}){const{t:i}=y(["store","common"]),[x]=d.useState(w),[s,n]=d.useState(x.tab),g=S(),h=T(k,s,n),[o,c]=d.useState(x.installId);d.useEffect(()=>{const t=w();t.installId&&(c(t.installId),b(t.tab)&&n(t.tab),j())},[]),d.useEffect(()=>{const t=r=>{const l=r.detail;if(l.page==="store"||l.page==="explore"){const f=l.params?.storeTab??localStorage.getItem("markus_nav_storeTab"),v=l.params?.installItem??localStorage.getItem("markus_nav_installItem");f&&b(f)&&n(f),v&&c(v),(f||v)&&j()}};return window.addEventListener("markus:navigate",t),()=>window.removeEventListener("markus:navigate",t)},[]);const p=(t,r)=>{const l=I[t]??"agents";r&&c(r),n(l)},m=()=>c(null),u=()=>e.jsxs(e.Fragment,{children:[o&&e.jsx(H,{itemId:o,onDismiss:m,onInstalled:m}),s==="discover"&&e.jsx(N,{onOpenType:p}),s==="agents"&&e.jsx(L,{authUser:a,highlightItemId:o,onHighlightDone:m}),s==="teams"&&e.jsx(_,{highlightItemId:o,onHighlightDone:m}),s==="skills"&&e.jsx(M,{highlightItemId:o,onHighlightDone:m}),s==="installed"&&e.jsx(E,{})]});return g?e.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",onTouchStart:h.onTouchStart,onTouchEnd:h.onTouchEnd,children:[e.jsx("div",{className:"flex shrink-0 overflow-x-auto scrollbar-hide",children:k.map(t=>e.jsx("button",{onClick:()=>n(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:i(`tabs.${t.id}`)},t.id))}),e.jsx("div",{className:"flex-1 overflow-hidden flex flex-col",children:u()})]}):e.jsxs("div",{className:"flex-1 overflow-hidden flex flex-row",children:[e.jsxs("nav",{className:"w-36 shrink-0 bg-surface-secondary rounded-xl m-1 mr-0 flex flex-col py-4 px-2 gap-1",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:i("title")})}),k.map(t=>e.jsxs("button",{onClick:()=>n(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?"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:C[t.id]})}),i(`tabs.${t.id}`)]},t.id))]}),e.jsx("div",{className:"flex-1 overflow-hidden flex flex-col",children:u()})]})}export{P as StorePage};