@markus-global/cli 0.11.0-rc.1 → 0.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/dist/web-ui/assets/{CommentInput-D4udF3ci.js → CommentInput-DD_rURUZ.js} +1 -1
  2. package/dist/web-ui/assets/{ContentRenderer-CY0moVGG.js → ContentRenderer-DL4CN5a7.js} +2 -2
  3. package/dist/web-ui/assets/{DeliverableShareModal-Kw_PwtaD.js → DeliverableShareModal-CA94fQ6t.js} +1 -1
  4. package/dist/web-ui/assets/{Deliverables-B6Fo0RuB.js → Deliverables-CVXKnarN.js} +1 -1
  5. package/dist/web-ui/assets/{Notifications-DsP8Z0a3.js → Notifications-BSIjXIB2.js} +1 -1
  6. package/dist/web-ui/assets/{Search-CLSRxUnd.js → Search-CHu38tSq.js} +1 -1
  7. package/dist/web-ui/assets/{Settings-_kkGsvr2.js → Settings-dRGc1-cI.js} +1 -1
  8. package/dist/web-ui/assets/{Store-BOV3Thkl.js → Store-COP7-vkU.js} +1 -1
  9. package/dist/web-ui/assets/{Team-mz_JWJwM.js → Team-D3bZCMAY.js} +42 -42
  10. package/dist/web-ui/assets/{Work-DaY25Zvg.js → Work-CgX3_06k.js} +1 -1
  11. package/dist/web-ui/assets/{arc-DppCSfqA.js → arc-Bg5CJocT.js} +1 -1
  12. package/dist/web-ui/assets/{architectureDiagram-3BPJPVTR-Cqxc4BLx.js → architectureDiagram-3BPJPVTR-DawJCAej.js} +1 -1
  13. package/dist/web-ui/assets/{blockDiagram-GPEHLZMM-Bnoj-Has.js → blockDiagram-GPEHLZMM-ZqMoGvfv.js} +1 -1
  14. package/dist/web-ui/assets/{c4Diagram-AAUBKEIU-BwigdMy_.js → c4Diagram-AAUBKEIU-J4ibZgWS.js} +1 -1
  15. package/dist/web-ui/assets/channel-Dpx2_w7L.js +1 -0
  16. package/dist/web-ui/assets/{chunk-2J33WTMH-BY8hN7e1.js → chunk-2J33WTMH-ChOj8jk6.js} +1 -1
  17. package/dist/web-ui/assets/{chunk-4BX2VUAB-BeLkwvuM.js → chunk-4BX2VUAB-Dir-D5hS.js} +1 -1
  18. package/dist/web-ui/assets/{chunk-55IACEB6-C1IrH2YD.js → chunk-55IACEB6-C18FzAkt.js} +1 -1
  19. package/dist/web-ui/assets/{chunk-727SXJPM-jJXbcC5A.js → chunk-727SXJPM-DU4-VKO-.js} +1 -1
  20. package/dist/web-ui/assets/{chunk-AQP2D5EJ-6QZflhse.js → chunk-AQP2D5EJ-Dl-u5apY.js} +1 -1
  21. package/dist/web-ui/assets/{chunk-FMBD7UC4-CE8BtseF.js → chunk-FMBD7UC4-lI8cDDzS.js} +1 -1
  22. package/dist/web-ui/assets/{chunk-ND2GUHAM-JYpnGzBS.js → chunk-ND2GUHAM-CVITQFgK.js} +1 -1
  23. package/dist/web-ui/assets/{chunk-QZHKN3VN-ChBjEb5B.js → chunk-QZHKN3VN-DT0Z-Y7D.js} +1 -1
  24. package/dist/web-ui/assets/classDiagram-4FO5ZUOK-DrvFH67-.js +1 -0
  25. package/dist/web-ui/assets/classDiagram-v2-Q7XG4LA2-DrvFH67-.js +1 -0
  26. package/dist/web-ui/assets/{cose-bilkent-S5V4N54A-DC3PvBlT.js → cose-bilkent-S5V4N54A-e0DTysr0.js} +1 -1
  27. package/dist/web-ui/assets/{dagre-BM42HDAG-CHs1tyq2.js → dagre-BM42HDAG-B7SXE46x.js} +1 -1
  28. package/dist/web-ui/assets/{diagram-2AECGRRQ-CKFu3DHI.js → diagram-2AECGRRQ-D18E4VJp.js} +1 -1
  29. package/dist/web-ui/assets/{diagram-5GNKFQAL-B83ktWF9.js → diagram-5GNKFQAL-BV5eG_wQ.js} +1 -1
  30. package/dist/web-ui/assets/{diagram-KO2AKTUF-Cd_0fmGt.js → diagram-KO2AKTUF-DcghAM6V.js} +1 -1
  31. package/dist/web-ui/assets/{diagram-LMA3HP47-CF4idZdP.js → diagram-LMA3HP47-Bucs338Z.js} +1 -1
  32. package/dist/web-ui/assets/{diagram-OG6HWLK6-D1_l8wLK.js → diagram-OG6HWLK6-CsBqS8rc.js} +1 -1
  33. package/dist/web-ui/assets/{docx-preview-BLbI_SCu.js → docx-preview-COrTZlTm.js} +1 -1
  34. package/dist/web-ui/assets/{erDiagram-TEJ5UH35-D8rK_F87.js → erDiagram-TEJ5UH35-CkTtYa1F.js} +1 -1
  35. package/dist/web-ui/assets/{flowDiagram-I6XJVG4X-ZoPp1kJi.js → flowDiagram-I6XJVG4X-BGu3cWC4.js} +1 -1
  36. package/dist/web-ui/assets/{ganttDiagram-6RSMTGT7-uligSftG.js → ganttDiagram-6RSMTGT7-Bja9GKgP.js} +1 -1
  37. package/dist/web-ui/assets/{gitGraphDiagram-PVQCEYII-DY0gAjmH.js → gitGraphDiagram-PVQCEYII-CCcnEeV5.js} +1 -1
  38. package/dist/web-ui/assets/{index-gob1iLha.js → index-Cfoh0Mcj.js} +49 -49
  39. package/dist/web-ui/assets/{infoDiagram-5YYISTIA-Bj9ByigZ.js → infoDiagram-5YYISTIA-BE95DmBY.js} +1 -1
  40. package/dist/web-ui/assets/{ishikawaDiagram-YF4QCWOH-CP7f_i4P.js → ishikawaDiagram-YF4QCWOH-BlqFOGrb.js} +1 -1
  41. package/dist/web-ui/assets/{journeyDiagram-JHISSGLW-Br7sCfe4.js → journeyDiagram-JHISSGLW-cmEbyfXZ.js} +1 -1
  42. package/dist/web-ui/assets/{kanban-definition-UN3LZRKU-MroLrnqj.js → kanban-definition-UN3LZRKU-CF310DyR.js} +1 -1
  43. package/dist/web-ui/assets/{mermaid.core-DbFRJGs8.js → mermaid.core-BHixne0g.js} +5 -5
  44. package/dist/web-ui/assets/{mindmap-definition-RKZ34NQL-Bus39q04.js → mindmap-definition-RKZ34NQL-AhUT5u2O.js} +1 -1
  45. package/dist/web-ui/assets/{pieDiagram-4H26LBE5-SO5RJs--.js → pieDiagram-4H26LBE5-BTMsfIc7.js} +1 -1
  46. package/dist/web-ui/assets/{quadrantDiagram-W4KKPZXB-xBzLY7eN.js → quadrantDiagram-W4KKPZXB-BUX6sxIv.js} +1 -1
  47. package/dist/web-ui/assets/{requirementDiagram-4Y6WPE33-CDYrNQvD.js → requirementDiagram-4Y6WPE33-OlQTxuLJ.js} +1 -1
  48. package/dist/web-ui/assets/{sankeyDiagram-5OEKKPKP-D6MRbXJQ.js → sankeyDiagram-5OEKKPKP-DESVEkFB.js} +1 -1
  49. package/dist/web-ui/assets/{sequenceDiagram-3UESZ5HK-1EcHUnVa.js → sequenceDiagram-3UESZ5HK-_55AKRLt.js} +1 -1
  50. package/dist/web-ui/assets/{stateDiagram-AJRCARHV-Bxr9KAun.js → stateDiagram-AJRCARHV-DWoVTo_b.js} +1 -1
  51. package/dist/web-ui/assets/stateDiagram-v2-BHNVJYJU-DylgAjTF.js +1 -0
  52. package/dist/web-ui/assets/{timeline-definition-PNZ67QCA-BJ82e_G9.js → timeline-definition-PNZ67QCA-Cfzp_g3K.js} +1 -1
  53. package/dist/web-ui/assets/{vennDiagram-CIIHVFJN-DlbfUUC7.js → vennDiagram-CIIHVFJN-D7bha1C9.js} +1 -1
  54. package/dist/web-ui/assets/{wardley-L42UT6IY-DIyuDPl5.js → wardley-L42UT6IY-B1fPVVfR.js} +1 -1
  55. package/dist/web-ui/assets/{wardleyDiagram-YWT4CUSO-J-XhaGPJ.js → wardleyDiagram-YWT4CUSO-D4g5vAsu.js} +1 -1
  56. package/dist/web-ui/assets/{xychartDiagram-2RQKCTM6-BJv3cUEO.js → xychartDiagram-2RQKCTM6-BLPxDXtu.js} +1 -1
  57. package/dist/web-ui/index.html +1 -1
  58. package/package.json +1 -1
  59. package/dist/web-ui/assets/channel-CDQp_KCp.js +0 -1
  60. package/dist/web-ui/assets/classDiagram-4FO5ZUOK-BvMC7FQO.js +0 -1
  61. package/dist/web-ui/assets/classDiagram-v2-Q7XG4LA2-BvMC7FQO.js +0 -1
  62. package/dist/web-ui/assets/stateDiagram-v2-BHNVJYJU-CYQuSdFg.js +0 -1
@@ -1,4 +1,4 @@
1
- import{u as ve,r as i,j as e,F as Ks,l as V,x as ka,k as Ca,a as Sa,b as Pa,c as Ma,Z as Hr,n as ms,$ as Aa,a0 as Wr,P as Jr,h as Ve,i as Ea,a1 as Un,w as Ta,o as fs,t as zs,_ as La}from"./index-gob1iLha.js";import{i as Ia}from"./modelCapabilities-DDtCBZ6o.js";function Ra(s,r){for(var l=0;l<r.length;l++){const o=r[l];if(typeof o!="string"&&!Array.isArray(o)){for(const a in o)if(a!=="default"&&!(a in s)){const t=Object.getOwnPropertyDescriptor(o,a);t&&Object.defineProperty(s,a,t.get?t:{enumerable:!0,get:()=>o[a]})}}}return Object.freeze(Object.defineProperty(s,Symbol.toStringTag,{value:"Module"}))}function Ba(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 Da(s){return s.maxInputTokens>0||s.inputCostPer1MTokens>0||s.outputCostPer1MTokens>0}function gs(s){if(s.tier)return s.tier;const r=s.id.toLowerCase(),l=/opus|5\.4|o3-(?!mini)|o1-(?!mini)|gemini.*ultra|sonnet-4-20/,o=/haiku|flash|nano|lite|small|fast|free|8b|7b|1b|3b/;return/o4-mini|o3-mini|o1-mini|gpt-4o-mini/.test(r)?"pro":l.test(r)?"max":o.test(r)?"base":"pro"}const Gr={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 $n({models:s,selectedModel:r,onSelect:l,loading:o,compact:a,maxVisible:t,showTiers:c}){const{t:u}=ve("settings"),[x,h]=i.useState(""),[y,A]=i.useState(!1),[g,C]=i.useState(""),N=i.useMemo(()=>{let m=s;if(x){const w=x.toLowerCase();m=m.filter(R=>R.id.toLowerCase().includes(w))}return g&&(m=m.filter(w=>gs(w)===g)),m},[s,x,g]),b=i.useMemo(()=>{const m={max:0,pro:0,base:0};for(const w of s)m[gs(w)]++;return m},[s]),S=t??(a?5:10),f=y?N:N.slice(0,S),v=N.length>S;return o?e.jsxs("div",{className:"flex items-center gap-2 py-4 text-sm text-fg-tertiary",children:[e.jsx("div",{className:"w-4 h-4 border-2 border-brand-500 border-t-transparent rounded-full animate-spin"}),u("modelPicker.loading")]}):s.length===0?e.jsx("div",{className:"py-3 text-sm text-fg-tertiary",children:u("modelPicker.empty")}):e.jsxs("div",{className:"space-y-2",children:[c&&s.length>3&&e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("button",{onClick:()=>C(""),className:`px-2 py-0.5 rounded text-[10px] transition-colors ${g?"bg-surface-overlay text-fg-tertiary hover:text-fg-secondary":"bg-brand-500/20 text-brand-500"}`,children:u("modelPicker.allCount",{count:s.length})}),["max","pro","base"].filter(m=>b[m]>0).map(m=>e.jsx("button",{onClick:()=>C(g===m?"":m),className:`px-2 py-0.5 rounded text-[10px] font-medium uppercase transition-colors border ${g===m?Gr[m]:"border-transparent bg-surface-overlay text-fg-tertiary hover:text-fg-secondary"}`,children:u("modelPicker.tierCount",{tier:u(`modelRouting.tier.${m}`),count:b[m]})},m))]}),s.length>5&&e.jsx("input",{type:"text",value:x,onChange:m=>{h(m.target.value),A(!1)},placeholder:u("modelPicker.filterPlaceholder"),className:"w-full px-3 py-1.5 bg-surface-overlay border border-border-default rounded-lg text-xs text-fg-primary placeholder:text-fg-tertiary focus:outline-none focus:border-brand-500"}),e.jsx("div",{className:`space-y-1 ${a?"max-h-[280px] overflow-y-auto":""}`,children:f.map(m=>{const w=m.id===r,R=gs(m);return e.jsxs("button",{type:"button",onClick:()=>l(m.id),className:`w-full text-left px-3 py-2 rounded-lg transition-colors ${w?"bg-brand-500/10 border border-brand-500/30":"hover:bg-surface-overlay border border-transparent"}`,children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:`w-3 h-3 rounded-full border-2 flex items-center justify-center ${w?"border-brand-500":"border-border-default"}`,children:w&&e.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-brand-500"})}),e.jsx("span",{className:`text-xs font-medium ${w?"text-brand-500":"text-fg-primary"}`,children:m.id}),c&&e.jsx("span",{className:`px-1.5 py-0.5 rounded text-[9px] font-semibold uppercase border ${Gr[R]}`,children:u(`modelRouting.tier.${R}`)})]}),e.jsx("div",{className:"flex items-center gap-2",children:w&&e.jsx("span",{className:"text-[10px] text-brand-500 font-medium",children:u("modelPicker.active")})})]}),Da(m)&&m.maxInputTokens>0&&e.jsx("div",{className:"ml-5 mt-0.5 flex items-center gap-2 text-[10px] text-fg-tertiary flex-wrap",children:e.jsxs("span",{children:[Ba(m.maxInputTokens)," ",u("modelPicker.ctx")]})}),!a&&e.jsxs("div",{className:"ml-5 mt-1 flex items-center gap-1.5 flex-wrap",children:[m.capabilities.functionCalling&&e.jsx(dt,{label:u("modelPicker.capabilities.tools")}),m.capabilities.vision&&e.jsx(dt,{label:u("modelPicker.capabilities.vision")}),m.capabilities.reasoning&&e.jsx(dt,{label:u("modelPicker.capabilities.reasoning")}),m.capabilities.promptCaching&&e.jsx(dt,{label:u("modelPicker.capabilities.caching")}),m.capabilities.webSearch&&e.jsx(dt,{label:u("modelPicker.capabilities.search")})]})]},m.id)})}),v&&!y&&e.jsx("button",{type:"button",onClick:()=>A(!0),className:"text-xs text-brand-500 hover:text-brand-400 px-3",children:u("modelPicker.showAll",{count:N.length})}),y&&v&&e.jsx("button",{type:"button",onClick:()=>A(!1),className:"text-xs text-fg-tertiary hover:text-fg-secondary px-3",children:u("modelPicker.showLess")})]})}function dt({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 mt({value:s,options:r,placeholder:l,onChange:o}){const{t:a}=ve("settings"),[t,c]=i.useState(!1),[u,x]=i.useState(""),h=i.useRef(null),y=i.useRef(null),A=i.useRef(null),[g,C]=i.useState(-1);i.useEffect(()=>{function m(w){h.current&&!h.current.contains(w.target)&&c(!1)}return document.addEventListener("mousedown",m),()=>document.removeEventListener("mousedown",m)},[]),i.useEffect(()=>{t&&y.current&&y.current.focus()},[t]);const N=i.useMemo(()=>{if(!u.trim())return r;const m=u.toLowerCase();return r.filter(w=>w.modelId.toLowerCase().includes(m)||w.modelName.toLowerCase().includes(m)||w.provider.toLowerCase().includes(m)||w.providerLabel.toLowerCase().includes(m)||w.tier&&w.tier.toLowerCase().includes(m))},[r,u]),b=i.useMemo(()=>{const m=new Map;for(const R of N){const I=R.providerLabel;m.has(I)||m.set(I,[]),m.get(I).push(R)}const w={max:0,pro:1,base:2};for(const R of m.values())R.sort((I,F)=>(w[I.tier??"base"]??9)-(w[F.tier??"base"]??9));return m},[N]),S=i.useMemo(()=>{const m=[];for(const w of b.values())m.push(...w);return m},[b]),f=i.useMemo(()=>{if(!s)return l??a("modelRouting.auto");const m=r.find(w=>`${w.provider}/${w.modelId}`===s);return m?`${m.providerLabel}/${m.modelName}`:s},[s,r,l,a]);function v(m){if(!t){(m.key==="Enter"||m.key===" ")&&(m.preventDefault(),c(!0));return}switch(m.key){case"ArrowDown":m.preventDefault(),C(w=>Math.min(w+1,S.length-1));break;case"ArrowUp":m.preventDefault(),C(w=>Math.max(w-1,-1));break;case"Enter":m.preventDefault(),g===-1?o(""):S[g]&&o(`${S[g].provider}/${S[g].modelId}`),c(!1),x("");break;case"Escape":c(!1),x("");break}}return i.useEffect(()=>{A.current&&g>=0&&A.current.querySelector(`[data-focus-index="${g}"]`)?.scrollIntoView({block:"nearest"})},[g]),e.jsxs("div",{ref:h,className:"relative",onKeyDown:v,children:[e.jsx("button",{type:"button",onClick:()=>{c(!t),x(""),C(-1)},className:"w-full px-2 py-1 bg-surface-overlay border border-border-default rounded text-xs text-fg-primary text-left truncate focus:outline-none focus:border-brand-500",children:f}),t&&e.jsxs("div",{className:"absolute z-50 mt-1 w-full min-w-[240px] max-h-[280px] bg-surface-elevated border border-border-default rounded-lg shadow-xl overflow-hidden flex flex-col",children:[e.jsx("div",{className:"p-1.5 border-b border-border-default",children:e.jsx("input",{ref:y,type:"text",value:u,onChange:m=>{x(m.target.value),C(-1)},placeholder:a("modelPicker.searchPlaceholder")||"Search models...",className:"w-full px-2 py-1 bg-surface-overlay border border-border-default rounded text-xs text-fg-primary focus:outline-none focus:border-brand-500"})}),e.jsxs("div",{ref:A,className:"overflow-y-auto flex-1",children:[e.jsx("div",{className:`px-3 py-1.5 text-xs cursor-pointer ${g===-1?"bg-brand-500/20 text-brand-500":"text-fg-secondary hover:bg-surface-overlay"}`,onClick:()=>{o(""),c(!1),x("")},children:l??a("modelRouting.auto")}),[...b.entries()].map(([m,w])=>e.jsxs("div",{children:[e.jsx("div",{className:"px-3 py-1 text-[10px] font-semibold text-fg-tertiary uppercase tracking-wider bg-surface-overlay/50 sticky top-0",children:m}),w.map(R=>{const I=S.indexOf(R),F=`${R.provider}/${R.modelId}`===s;return e.jsxs("div",{"data-focus-index":I,className:`px-3 py-1.5 text-xs cursor-pointer flex items-center gap-2 ${I===g?"bg-brand-500/20":F?"bg-surface-overlay":"hover:bg-surface-overlay/50"}`,onClick:()=>{o(`${R.provider}/${R.modelId}`),c(!1),x("")},children:[e.jsx("span",{className:"flex-1 truncate text-fg-primary",children:R.modelName}),R.tier&&e.jsx(Oa,{tier:R.tier}),R.costTier&&e.jsx("span",{className:"text-[9px] text-fg-tertiary",children:R.costTier})]},`${R.provider}/${R.modelId}`)})]},m)),S.length===0&&e.jsx("div",{className:"px-3 py-3 text-xs text-fg-tertiary text-center",children:a("modelPicker.empty")})]})]})]})}function Oa({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 Fa=500,Qr=[{groupKey:"image",capabilities:["image_recognition","image_generation"]},{groupKey:"audio",capabilities:["audio_tts","audio_stt"]},{groupKey:"video",capabilities:["video_generation"]}];function _a({onSave:s,configuredProviders:r}){const{t:l}=ve(["settings","common"]),[o,a]=i.useState({}),[t,c]=i.useState(null),[u,x]=i.useState(!1),[h,y]=i.useState(null),[A,g]=i.useState(!0),[C,N]=i.useState("idle"),[b,S]=i.useState(null),[f,v]=i.useState({}),[m,w]=i.useState(!1),[R,I]=i.useState("idle"),[F,$]=i.useState(null),[P,D]=i.useState(!1),L=i.useRef(null),U=i.useRef(null),_=i.useMemo(()=>r.map(d=>d.name).sort().join(","),[r]);i.useEffect(()=>{fetch("/api/settings/llm/routing",{credentials:"include"}).then(d=>{if(!d.ok)throw new Error(`HTTP ${d.status}`);return d.json()}).then(d=>{a(d.capabilityRouting?.assignments??{}),c(d.routingDefaultModel??null),x(!0)}).catch(d=>{y(String(d)),x(!0)})},[_]),i.useEffect(()=>{let d=!1;return g(!0),fetch("/api/models/routing-candidates",{credentials:"include"}).then(k=>{if(!k.ok)throw new Error(`HTTP ${k.status}`);return k.json()}).then(k=>{if(d)return;const O=[];for(const z of k.providers)for(const J of z.models)O.push({provider:z.provider,providerLabel:z.displayName,modelId:J.id,modelName:J.name,mode:J.mode,tier:J.tier,costTier:J.costTier,capabilities:J.capabilities});S(O)}).catch(()=>{d||S(null)}).finally(()=>{d||g(!1)}),()=>{d=!0}},[_]),i.useEffect(()=>{fetch("/api/models/suggested-assignments",{credentials:"include"}).then(d=>{if(!d.ok)throw new Error(`HTTP ${d.status}`);return d.json()}).then(d=>{v(d.suggestions),w(!0)}).catch(()=>w(!0))},[_]);const K=i.useCallback(d=>{N("saving"),s(d).then(()=>{N("saved"),setTimeout(()=>N(k=>k==="saved"?"idle":k),2e3)}).catch(()=>{N("error"),setTimeout(()=>N(k=>k==="error"?"idle":k),3e3)})},[s]),H=i.useCallback((d,k)=>{U.current={capabilityRouting:d!==void 0?{assignments:d}:U.current?.capabilityRouting,routingDefaultModel:k!==void 0?k:U.current?.routingDefaultModel},L.current&&clearTimeout(L.current),L.current=setTimeout(()=>{const O=U.current;U.current=null,O&&K(O)},Fa)},[K]),T=i.useMemo(()=>r.flatMap(d=>(d.models??[{id:d.model,name:d.model}]).map(k=>({provider:d.name,providerLabel:d.displayName??d.name,modelId:k.id,modelName:k.name}))),[r]),B=b??T,ee=i.useMemo(()=>Object.entries(o).map(([d,k])=>`${d}:${k?.provider??""}/${k?.model??""}`).sort().join("|"),[o]);i.useEffect(()=>{!u||!b||b.length===0||b.some(d=>!!d.modelId)&&(a(d=>{let k=!1;const O={...d};for(const z of Qr)for(const J of z.capabilities){const se=O[J];if(!se?.model)continue;const Z=Vn(b,J);if(Z.length===0)continue;Z.some(Ne=>Ne.provider===se.provider&&Ne.modelId===se.model)||(delete O[J],k=!0)}return k?(H(O),O):d}),c(d=>{if(!d?.model||b.some(J=>J.provider===d.provider&&J.modelId===d.model))return d;const O=b.find(J=>J.provider==="markus"),z=O?{provider:O.provider,model:O.modelId}:{provider:b[0].provider,model:b[0].modelId};return s({routingDefaultModel:z}),z}))},[u,b,_,H,ee]);const ie=i.useCallback(()=>{fetch("/api/settings/llm/routing",{credentials:"include"}).then(d=>{if(!d.ok)throw new Error(`HTTP ${d.status}`);return d.json()}).then(d=>{a(d.capabilityRouting?.assignments??{}),c(d.routingDefaultModel??null)}).catch(()=>{}),g(!0),fetch("/api/models/routing-candidates",{credentials:"include"}).then(d=>{if(!d.ok)throw new Error(`HTTP ${d.status}`);return d.json()}).then(d=>{const k=[];for(const O of d.providers)for(const z of O.models)k.push({provider:O.provider,providerLabel:O.displayName,modelId:z.id,modelName:z.name,mode:z.mode,tier:z.tier,costTier:z.costTier,capabilities:z.capabilities});S(k)}).catch(()=>{}).finally(()=>g(!1))},[]),de=i.useCallback(async()=>{if(R!=="working"){I("working"),$(null);try{const d=await fetch("/api/settings/llm/restore-recommended",{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"}}),k=await d.json().catch(()=>({}));if(!d.ok||!k.ok)throw new Error(k.error??`HTTP ${d.status}`);k.capabilityRouting&&a(k.capabilityRouting.assignments??{}),k.routingDefaultModel!==void 0&&c(k.routingDefaultModel),ie(),I("idle"),N("saved"),setTimeout(()=>N(O=>O==="saved"?"idle":O),2e3)}catch(d){I("error"),$(d instanceof Error?d.message:String(d)),setTimeout(()=>I("idle"),4e3)}}},[R,ie]),re=B.length>0;return u?h?e.jsx("div",{className:"bg-red-500/10 border border-red-500/30 rounded-xl p-4 text-xs text-red-400",children:l("modelRouting.loadError",{error:h})}):A&&!re?e.jsx("div",{className:"space-y-4",children:e.jsx("div",{className:"bg-surface-elevated rounded-xl p-5",children:e.jsxs("div",{className:"flex items-center gap-2 text-xs text-fg-secondary",children:[e.jsxs("svg",{className:"w-4 h-4 animate-spin text-brand-500",fill:"none",viewBox:"0 0 24 24",children:[e.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),e.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8v4a4 4 0 00-4 4H4z"})]}),e.jsx("span",{children:l("modelRouting.loadingModels")})]})})}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx(Va,{status:C,t:l}),e.jsxs("div",{className:"flex flex-col items-end gap-1",children:[e.jsx("button",{type:"button",onClick:()=>D(!0),disabled:R==="working",className:"text-xs px-3 py-1.5 rounded-lg border border-border-default text-fg-secondary hover:text-fg-primary hover:border-brand-500/40 disabled:opacity-50 transition-colors",children:l(R==="working"?"modelRouting.restoreWorking":"modelRouting.restoreRecommended")}),F&&e.jsx("span",{className:"text-[10px] text-red-400 max-w-xs text-right",children:F})]})]}),e.jsxs("div",{className:"bg-surface-elevated rounded-xl p-5 space-y-3",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-semibold text-fg-primary",children:l("modelRouting.defaultModelTitle")}),e.jsx("p",{className:"text-xs text-fg-tertiary mt-1",children:l("modelRouting.defaultModelDesc")})]}),e.jsx("div",{className:"max-w-md",children:e.jsx(mt,{value:t?`${t.provider}/${t.model}`:"",options:B,placeholder:l("modelRouting.defaultModelPlaceholder"),onChange:d=>{if(!d)c(null),H(void 0,null);else{const[k,...O]=d.split("/"),z={provider:k,model:O.join("/")};if(c(z),o.text){const J={...o};delete J.text,a(J),H(J,z)}else H(void 0,z)}}})})]}),e.jsxs("div",{className:"bg-surface-elevated rounded-xl p-5 space-y-4",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-semibold text-fg-primary",children:l("modelRouting.capabilityAssignTitle")}),e.jsx("p",{className:"text-xs text-fg-tertiary mt-1",children:l("modelRouting.capabilityAssignDesc")})]}),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:l("modelRouting.noProvidersHint")}),r.length>0&&e.jsx("div",{className:"space-y-4",children:Qr.map(d=>e.jsx(Ua,{groupKey:d.groupKey,capabilities:d.capabilities,assignments:o,suggestions:f,allModels:B,configuredProviderNames:new Set(r.map(k=>k.name)),t:l,onAssign:(k,O)=>{const z={...o};O?z[k]=O:delete z[k],a(z),H(z)}},d.groupKey))})]}),P&&e.jsx(Ks,{variant:"primary",title:l("modelRouting.restoreRecommended"),message:l("modelRouting.restoreConfirm"),confirmLabel:l("common:confirm"),onConfirm:()=>{D(!1),de()},onCancel:()=>D(!1)})]}):e.jsx("div",{className:"space-y-4",children:e.jsxs("div",{className:"bg-surface-elevated rounded-xl p-5 animate-pulse",children:[e.jsx("div",{className:"h-4 bg-surface-overlay rounded w-1/3 mb-3"}),e.jsx("div",{className:"h-3 bg-surface-overlay rounded w-2/3 mb-4"}),e.jsx("div",{className:"space-y-2",children:[1,2,3,4,5].map(d=>e.jsx("div",{className:"h-10 bg-surface-overlay rounded-lg"},d))})]})})}function Ua({groupKey:s,capabilities:r,assignments:l,suggestions:o,allModels:a,configuredProviderNames:t,t:c,onAssign:u}){return e.jsxs("div",{children:[e.jsx("div",{className:"text-[10px] font-semibold text-fg-tertiary uppercase tracking-wider mb-2 px-1",children:c(`modelRouting.capabilityGroups.${s}`)}),e.jsx("div",{className:"space-y-1",children:r.map(x=>{const h=l[x],y=o[x],A=h?`${h.provider}/${h.model}`:"",g=Vn(a,x),C=y?g.find(v=>v.provider===y.provider&&v.modelId===y.model)?.modelName??y.model:void 0,N=g.length>0,b=h?$a(a,h.provider,h.model):void 0,S=h&&!t.has(h.provider),f=!!(h&&N&&x!=="text"&&!g.some(v=>v.provider===h.provider&&v.modelId===h.model));return e.jsxs("div",{className:`flex items-center gap-3 px-3 py-2 rounded-lg ${f?"bg-red-500/10 border border-red-500/30":S?"bg-yellow-500/10 border border-yellow-500/30":!N&&!h?"bg-amber-500/5 border border-amber-500/20":"bg-surface-overlay/40"}`,children:[e.jsx("div",{className:"w-28 shrink-0",children:e.jsx("span",{className:"text-xs text-fg-primary",children:c(`modelRouting.capabilities.${x}`)})}),e.jsx("div",{className:"flex-1 min-w-0",children:f?e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsxs("span",{className:"text-xs text-red-400",children:["⚠ ",h.model]}),e.jsx("span",{className:"text-[10px] text-red-400/70",children:c("modelRouting.mismatchHint")})]}),e.jsx(mt,{value:"",options:g,placeholder:c("modelRouting.selectModel"),onChange:v=>{if(!v)u(x,null);else{const[m,...w]=v.split("/");u(x,{provider:m,model:w.join("/")})}}})]}):N?e.jsx(mt,{value:A,options:g,placeholder:C?`${C} (${c("modelRouting.suggested")})`:c("modelRouting.selectModel"),onChange:v=>{if(!v)u(x,null);else{const[m,...w]=v.split("/");u(x,{provider:m,model:w.join("/")})}}}):e.jsxs("span",{className:"text-xs text-amber-400",children:[c("modelRouting.noModelAvailable"),e.jsxs("span",{className:"text-fg-tertiary ml-1",children:["— ",c("modelRouting.addProviderHint")]})]})}),e.jsxs("div",{className:"w-14 shrink-0 flex justify-end",children:[f&&e.jsx("span",{className:"text-[10px] text-red-400 font-medium",title:c("modelRouting.mismatchHint"),children:"⚠"}),!f&&S&&e.jsx("span",{className:"text-[10px] text-yellow-400 font-medium",title:c("modelRouting.staleProvider"),children:"⚠"}),!f&&!S&&b&&e.jsx(Yr,{tier:b}),!f&&!S&&!b&&h&&e.jsx(Yr,{tier:"unknown"})]}),e.jsx("div",{className:"w-8 shrink-0 flex justify-end",children:h&&e.jsx("button",{onClick:()=>u(x,null),className:"text-fg-tertiary hover:text-red-400 transition-colors",title:c("modelRouting.clear"),children:e.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})})]},x)})})]})}function $a(s,r,l){return s.find(a=>a.provider===r&&a.modelId===l)?.tier}function Va({status:s,t:r}){if(s==="idle")return null;const l={idle:"",saving:"text-fg-tertiary",saved:"text-green-400",error:"text-red-400"},o={idle:"",saving:r("modelRouting.saving"),saved:r("modelRouting.saved"),error:r("modelRouting.saveError")};return e.jsx("div",{className:`text-xs font-medium transition-opacity ${l[s]}`,children:o[s]})}function Yr({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})}function Vn(s,r){if(r==="text")return s.filter(c=>Ia(c));const l={image_generation:["image_generation"],audio_tts:["audio_speech"],audio_stt:["audio_transcription"],video_generation:["video_generation"]},o={image_recognition:["vision"],image_generation:["imageGeneration"],audio_tts:["tts"],audio_stt:["stt"],video_generation:["videoGeneration"]},a=l[r],t=o[r];return s.filter(c=>!!(c.capabilities&&c.capabilities.length>0&&t&&t.some(u=>c.capabilities.includes(u))||a&&c.mode&&a.includes(c.mode)))}function Ka({configuredProviders:s}){const{t:r}=ve("settings"),[l,o]=i.useState(null),[a,t]=i.useState([]),[c,u]=i.useState(null),[x,h]=i.useState(null),y=i.useMemo(()=>s.map(b=>`${b.name}:${b.models?.length??0}`).sort().join(","),[s]),A=i.useCallback(async()=>{u(null);try{const[{agents:b},S]=await Promise.all([V.agents.list(),V.teams.list()]),f=S.teams.map(m=>({id:m.id,name:m.name}));t(f);const v=await Promise.all(b.map(async m=>{try{const R=(await V.agents.get(m.id)).config?.llmConfig;return{id:m.id,name:m.name||m.id,teamId:m.teamId,override:R?.modelMode==="custom"&&R.primary&&R.defaultModel?`${R.primary}/${R.defaultModel}`:null,llmConfig:{modelMode:R?.modelMode,primary:R?.primary??"",defaultModel:R?.defaultModel}}}catch{return{id:m.id,name:m.name||m.id,teamId:m.teamId,override:null,llmConfig:{modelMode:"default",primary:"",defaultModel:void 0}}}}));o(b.length?v:null)}catch(b){u(String(b))}},[y]);i.useEffect(()=>{A()},[A,y]);const g=i.useMemo(()=>{const b=[];for(const S of s)for(const f of S.models??[])b.push({provider:S.name,providerLabel:S.displayName??S.name,modelId:f.id,modelName:f.name??f.id});return b},[s]),C=async(b,S)=>{h(b),u(null);try{if(S){const[f,v]=[S.slice(0,S.lastIndexOf("/")),S.slice(S.lastIndexOf("/")+1)];await V.agents.updateConfig(b,{llmConfig:{modelMode:"custom",primary:f,defaultModel:v}})}else await V.agents.updateConfig(b,{llmConfig:{modelMode:"default",primary:"",defaultModel:void 0}});o(f=>f?.map(v=>v.id===b?{...v,override:S}:v)??f)}catch(f){u(String(f))}finally{h(null)}},N=i.useMemo(()=>{if(!l)return[];const b=new Map,S=[];for(const v of l)if(v.teamId){const m=b.get(v.teamId)??[];m.push(v),b.set(v.teamId,m)}else S.push(v);const f=[];S.length&&f.push({key:"ungrouped",label:r("perAgentModel.ungrouped",{defaultValue:"Ungrouped"}),rows:S});for(const v of a){const m=b.get(v.id);m?.length&&f.push({key:`team:${v.id}`,label:v.name,rows:m})}for(const[v,m]of b)a.some(w=>w.id===v)||f.push({key:`team:${v}`,label:v,rows:m});return f},[l,a,r]);return l===null&&!c?e.jsx("div",{className:"bg-surface-elevated rounded-xl p-5 text-sm text-fg-tertiary",children:r("common:loading",{defaultValue:"Loading…"})}):e.jsxs("div",{className:"bg-surface-elevated rounded-xl p-5 space-y-4",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium",children:r("perAgentModel.title",{defaultValue:"Per-agent default model"})}),e.jsx("div",{className:"text-xs text-fg-tertiary mt-0.5",children:r("perAgentModel.desc",{defaultValue:'Bind a specific provider+model to an agent, or leave it following the global default. This is what the composer "Apply to current agent" writes.'})})]})}),c&&e.jsx("div",{className:"text-xs text-red-500",children:c}),(!l||l.length===0)&&!c&&e.jsx("div",{className:"text-xs text-fg-tertiary",children:r("perAgentModel.noAgents",{defaultValue:"No agents available."})}),l&&l.length>0&&e.jsx("div",{className:"space-y-5",children:N.map(b=>e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wider text-fg-tertiary truncate",children:b.label}),e.jsx("span",{className:"text-[10px] text-fg-tertiary/70 tabular-nums shrink-0",children:b.rows.length})]}),e.jsx("div",{className:"space-y-2",children:b.rows.map(S=>e.jsxs("div",{className:"flex items-center justify-between gap-3 text-sm",children:[e.jsxs("div",{className:"flex-1 truncate",children:[e.jsx("span",{className:"font-medium",children:S.name}),e.jsx("span",{className:"text-xs text-fg-tertiary ml-2 truncate",children:S.id})]}),e.jsxs("div",{className:"flex items-center gap-2 w-[320px]",children:[S.override?e.jsxs(e.Fragment,{children:[e.jsx(mt,{value:S.override,options:g,placeholder:r("perAgentModel.followGlobal",{defaultValue:"Follow global"}),onChange:f=>{C(S.id,f||null)}}),e.jsx("button",{type:"button",disabled:x===S.id,onClick:()=>{C(S.id,null)},className:"shrink-0 px-2.5 py-1.5 text-xs border border-border-default rounded-lg hover:bg-surface-base disabled:opacity-40 transition-colors",children:r("perAgentModel.reset",{defaultValue:"Reset"})})]}):e.jsx(mt,{value:"",options:g,placeholder:r("perAgentModel.followGlobal",{defaultValue:"Follow global"}),onChange:f=>{C(S.id,f||null)}}),x===S.id&&e.jsx("span",{className:"shrink-0 text-[10px] text-fg-tertiary",children:r("common:loading",{defaultValue:"…"})})]})]},S.id))})]},b.key))})]})}let It=[],Et=null;async function za(){return Et||(Et=(async()=>{try{It=(await V.modelCatalog.providerCatalog()).providers??[]}catch{It=[]}return It})(),Et)}function qa(){const[s,r]=i.useState(It);return i.useEffect(()=>{let l=!0;return za().then(o=>{l&&r(o)}),()=>{l=!1}},[]),s}var Ze={},ps,Zr;function Ha(){return Zr||(Zr=1,ps=function(){return typeof Promise=="function"&&Promise.prototype&&Promise.prototype.then}),ps}var hs={},Fe={},Xr;function Ke(){if(Xr)return Fe;Xr=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 Fe.getSymbolSize=function(o){if(!o)throw new Error('"version" cannot be null or undefined');if(o<1||o>40)throw new Error('"version" should be in range from 1 to 40');return o*4+17},Fe.getSymbolTotalCodewords=function(o){return r[o]},Fe.getBCHDigit=function(l){let o=0;for(;l!==0;)o++,l>>>=1;return o},Fe.setToSJISFunction=function(o){if(typeof o!="function")throw new Error('"toSJISFunc" is not a valid function.');s=o},Fe.isKanjiModeEnabled=function(){return typeof s<"u"},Fe.toSJIS=function(o){return s(o)},Fe}var bs={},en;function qs(){return en||(en=1,(function(s){s.L={bit:1},s.M={bit:0},s.Q={bit:3},s.H={bit:2};function r(l){if(typeof l!="string")throw new Error("Param is not a string");switch(l.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: "+l)}}s.isValid=function(o){return o&&typeof o.bit<"u"&&o.bit>=0&&o.bit<4},s.from=function(o,a){if(s.isValid(o))return o;try{return r(o)}catch{return a}}})(bs)),bs}var ys,tn;function Wa(){if(tn)return ys;tn=1;function s(){this.buffer=[],this.length=0}return s.prototype={get:function(r){const l=Math.floor(r/8);return(this.buffer[l]>>>7-r%8&1)===1},put:function(r,l){for(let o=0;o<l;o++)this.putBit((r>>>l-o-1&1)===1)},getLengthInBits:function(){return this.length},putBit:function(r){const l=Math.floor(this.length/8);this.buffer.length<=l&&this.buffer.push(0),r&&(this.buffer[l]|=128>>>this.length%8),this.length++}},ys=s,ys}var vs,sn;function Ja(){if(sn)return vs;sn=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,l,o,a){const t=r*this.size+l;this.data[t]=o,a&&(this.reservedBit[t]=!0)},s.prototype.get=function(r,l){return this.data[r*this.size+l]},s.prototype.xor=function(r,l,o){this.data[r*this.size+l]^=o},s.prototype.isReserved=function(r,l){return this.reservedBit[r*this.size+l]},vs=s,vs}var js={},rn;function Ga(){return rn||(rn=1,(function(s){const r=Ke().getSymbolSize;s.getRowColCoords=function(o){if(o===1)return[];const a=Math.floor(o/7)+2,t=r(o),c=t===145?26:Math.ceil((t-13)/(2*a-2))*2,u=[t-7];for(let x=1;x<a-1;x++)u[x]=u[x-1]-c;return u.push(6),u.reverse()},s.getPositions=function(o){const a=[],t=s.getRowColCoords(o),c=t.length;for(let u=0;u<c;u++)for(let x=0;x<c;x++)u===0&&x===0||u===0&&x===c-1||u===c-1&&x===0||a.push([t[u],t[x]]);return a}})(js)),js}var ws={},nn;function Qa(){if(nn)return ws;nn=1;const s=Ke().getSymbolSize,r=7;return ws.getPositions=function(o){const a=s(o);return[[0,0],[a-r,0],[0,a-r]]},ws}var Ns={},an;function Ya(){return an||(an=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 c=0,u=0,x=0,h=null,y=null;for(let A=0;A<t;A++){u=x=0,h=y=null;for(let g=0;g<t;g++){let C=a.get(A,g);C===h?u++:(u>=5&&(c+=r.N1+(u-5)),h=C,u=1),C=a.get(g,A),C===y?x++:(x>=5&&(c+=r.N1+(x-5)),y=C,x=1)}u>=5&&(c+=r.N1+(u-5)),x>=5&&(c+=r.N1+(x-5))}return c},s.getPenaltyN2=function(a){const t=a.size;let c=0;for(let u=0;u<t-1;u++)for(let x=0;x<t-1;x++){const h=a.get(u,x)+a.get(u,x+1)+a.get(u+1,x)+a.get(u+1,x+1);(h===4||h===0)&&c++}return c*r.N2},s.getPenaltyN3=function(a){const t=a.size;let c=0,u=0,x=0;for(let h=0;h<t;h++){u=x=0;for(let y=0;y<t;y++)u=u<<1&2047|a.get(h,y),y>=10&&(u===1488||u===93)&&c++,x=x<<1&2047|a.get(y,h),y>=10&&(x===1488||x===93)&&c++}return c*r.N3},s.getPenaltyN4=function(a){let t=0;const c=a.data.length;for(let x=0;x<c;x++)t+=a.data[x];return Math.abs(Math.ceil(t*100/c/5)-10)*r.N4};function l(o,a,t){switch(o){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:"+o)}}s.applyMask=function(a,t){const c=t.size;for(let u=0;u<c;u++)for(let x=0;x<c;x++)t.isReserved(x,u)||t.xor(x,u,l(a,x,u))},s.getBestMask=function(a,t){const c=Object.keys(s.Patterns).length;let u=0,x=1/0;for(let h=0;h<c;h++){t(h),s.applyMask(h,a);const y=s.getPenaltyN1(a)+s.getPenaltyN2(a)+s.getPenaltyN3(a)+s.getPenaltyN4(a);s.applyMask(h,a),y<x&&(x=y,u=h)}return u}})(Ns)),Ns}var Tt={},on;function Kn(){if(on)return Tt;on=1;const s=qs(),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],l=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];return Tt.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}},Tt.getTotalCodewordsCount=function(a,t){switch(t){case s.L:return l[(a-1)*4+0];case s.M:return l[(a-1)*4+1];case s.Q:return l[(a-1)*4+2];case s.H:return l[(a-1)*4+3];default:return}},Tt}var ks={},ct={},ln;function Za(){if(ln)return ct;ln=1;const s=new Uint8Array(512),r=new Uint8Array(256);return(function(){let o=1;for(let a=0;a<255;a++)s[a]=o,r[o]=a,o<<=1,o&256&&(o^=285);for(let a=255;a<512;a++)s[a]=s[a-255]})(),ct.log=function(o){if(o<1)throw new Error("log("+o+")");return r[o]},ct.exp=function(o){return s[o]},ct.mul=function(o,a){return o===0||a===0?0:s[r[o]+r[a]]},ct}var dn;function Xa(){return dn||(dn=1,(function(s){const r=Za();s.mul=function(o,a){const t=new Uint8Array(o.length+a.length-1);for(let c=0;c<o.length;c++)for(let u=0;u<a.length;u++)t[c+u]^=r.mul(o[c],a[u]);return t},s.mod=function(o,a){let t=new Uint8Array(o);for(;t.length-a.length>=0;){const c=t[0];for(let x=0;x<a.length;x++)t[x]^=r.mul(a[x],c);let u=0;for(;u<t.length&&t[u]===0;)u++;t=t.slice(u)}return t},s.generateECPolynomial=function(o){let a=new Uint8Array([1]);for(let t=0;t<o;t++)a=s.mul(a,new Uint8Array([1,r.exp(t)]));return a}})(ks)),ks}var Cs,cn;function eo(){if(cn)return Cs;cn=1;const s=Xa();function r(l){this.genPoly=void 0,this.degree=l,this.degree&&this.initialize(this.degree)}return r.prototype.initialize=function(o){this.degree=o,this.genPoly=s.generateECPolynomial(this.degree)},r.prototype.encode=function(o){if(!this.genPoly)throw new Error("Encoder not initialized");const a=new Uint8Array(o.length+this.degree);a.set(o);const t=s.mod(a,this.genPoly),c=this.degree-t.length;if(c>0){const u=new Uint8Array(this.degree);return u.set(t,c),u}return t},Cs=r,Cs}var Ss={},Ps={},Ms={},un;function zn(){return un||(un=1,Ms.isValid=function(r){return!isNaN(r)&&r>=1&&r<=40}),Ms}var Ae={},xn;function qn(){if(xn)return Ae;xn=1;const s="[0-9]+",r="[A-Z $%*+\\-./:]+";let l="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";l=l.replace(/u/g,"\\u");const o="(?:(?![A-Z0-9 $%*+\\-./:]|"+l+`)(?:.|[\r
1
+ import{u as ve,r as i,j as e,F as Ks,l as V,x as ka,k as Ca,a as Sa,b as Pa,c as Ma,Z as Hr,n as ms,$ as Aa,a0 as Wr,P as Jr,h as Ve,i as Ea,a1 as Un,w as Ta,o as fs,t as zs,_ as La}from"./index-Cfoh0Mcj.js";import{i as Ia}from"./modelCapabilities-DDtCBZ6o.js";function Ra(s,r){for(var l=0;l<r.length;l++){const o=r[l];if(typeof o!="string"&&!Array.isArray(o)){for(const a in o)if(a!=="default"&&!(a in s)){const t=Object.getOwnPropertyDescriptor(o,a);t&&Object.defineProperty(s,a,t.get?t:{enumerable:!0,get:()=>o[a]})}}}return Object.freeze(Object.defineProperty(s,Symbol.toStringTag,{value:"Module"}))}function Ba(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 Da(s){return s.maxInputTokens>0||s.inputCostPer1MTokens>0||s.outputCostPer1MTokens>0}function gs(s){if(s.tier)return s.tier;const r=s.id.toLowerCase(),l=/opus|5\.4|o3-(?!mini)|o1-(?!mini)|gemini.*ultra|sonnet-4-20/,o=/haiku|flash|nano|lite|small|fast|free|8b|7b|1b|3b/;return/o4-mini|o3-mini|o1-mini|gpt-4o-mini/.test(r)?"pro":l.test(r)?"max":o.test(r)?"base":"pro"}const Gr={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 $n({models:s,selectedModel:r,onSelect:l,loading:o,compact:a,maxVisible:t,showTiers:c}){const{t:u}=ve("settings"),[x,h]=i.useState(""),[y,A]=i.useState(!1),[g,C]=i.useState(""),N=i.useMemo(()=>{let m=s;if(x){const w=x.toLowerCase();m=m.filter(R=>R.id.toLowerCase().includes(w))}return g&&(m=m.filter(w=>gs(w)===g)),m},[s,x,g]),b=i.useMemo(()=>{const m={max:0,pro:0,base:0};for(const w of s)m[gs(w)]++;return m},[s]),S=t??(a?5:10),f=y?N:N.slice(0,S),v=N.length>S;return o?e.jsxs("div",{className:"flex items-center gap-2 py-4 text-sm text-fg-tertiary",children:[e.jsx("div",{className:"w-4 h-4 border-2 border-brand-500 border-t-transparent rounded-full animate-spin"}),u("modelPicker.loading")]}):s.length===0?e.jsx("div",{className:"py-3 text-sm text-fg-tertiary",children:u("modelPicker.empty")}):e.jsxs("div",{className:"space-y-2",children:[c&&s.length>3&&e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("button",{onClick:()=>C(""),className:`px-2 py-0.5 rounded text-[10px] transition-colors ${g?"bg-surface-overlay text-fg-tertiary hover:text-fg-secondary":"bg-brand-500/20 text-brand-500"}`,children:u("modelPicker.allCount",{count:s.length})}),["max","pro","base"].filter(m=>b[m]>0).map(m=>e.jsx("button",{onClick:()=>C(g===m?"":m),className:`px-2 py-0.5 rounded text-[10px] font-medium uppercase transition-colors border ${g===m?Gr[m]:"border-transparent bg-surface-overlay text-fg-tertiary hover:text-fg-secondary"}`,children:u("modelPicker.tierCount",{tier:u(`modelRouting.tier.${m}`),count:b[m]})},m))]}),s.length>5&&e.jsx("input",{type:"text",value:x,onChange:m=>{h(m.target.value),A(!1)},placeholder:u("modelPicker.filterPlaceholder"),className:"w-full px-3 py-1.5 bg-surface-overlay border border-border-default rounded-lg text-xs text-fg-primary placeholder:text-fg-tertiary focus:outline-none focus:border-brand-500"}),e.jsx("div",{className:`space-y-1 ${a?"max-h-[280px] overflow-y-auto":""}`,children:f.map(m=>{const w=m.id===r,R=gs(m);return e.jsxs("button",{type:"button",onClick:()=>l(m.id),className:`w-full text-left px-3 py-2 rounded-lg transition-colors ${w?"bg-brand-500/10 border border-brand-500/30":"hover:bg-surface-overlay border border-transparent"}`,children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:`w-3 h-3 rounded-full border-2 flex items-center justify-center ${w?"border-brand-500":"border-border-default"}`,children:w&&e.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-brand-500"})}),e.jsx("span",{className:`text-xs font-medium ${w?"text-brand-500":"text-fg-primary"}`,children:m.id}),c&&e.jsx("span",{className:`px-1.5 py-0.5 rounded text-[9px] font-semibold uppercase border ${Gr[R]}`,children:u(`modelRouting.tier.${R}`)})]}),e.jsx("div",{className:"flex items-center gap-2",children:w&&e.jsx("span",{className:"text-[10px] text-brand-500 font-medium",children:u("modelPicker.active")})})]}),Da(m)&&m.maxInputTokens>0&&e.jsx("div",{className:"ml-5 mt-0.5 flex items-center gap-2 text-[10px] text-fg-tertiary flex-wrap",children:e.jsxs("span",{children:[Ba(m.maxInputTokens)," ",u("modelPicker.ctx")]})}),!a&&e.jsxs("div",{className:"ml-5 mt-1 flex items-center gap-1.5 flex-wrap",children:[m.capabilities.functionCalling&&e.jsx(dt,{label:u("modelPicker.capabilities.tools")}),m.capabilities.vision&&e.jsx(dt,{label:u("modelPicker.capabilities.vision")}),m.capabilities.reasoning&&e.jsx(dt,{label:u("modelPicker.capabilities.reasoning")}),m.capabilities.promptCaching&&e.jsx(dt,{label:u("modelPicker.capabilities.caching")}),m.capabilities.webSearch&&e.jsx(dt,{label:u("modelPicker.capabilities.search")})]})]},m.id)})}),v&&!y&&e.jsx("button",{type:"button",onClick:()=>A(!0),className:"text-xs text-brand-500 hover:text-brand-400 px-3",children:u("modelPicker.showAll",{count:N.length})}),y&&v&&e.jsx("button",{type:"button",onClick:()=>A(!1),className:"text-xs text-fg-tertiary hover:text-fg-secondary px-3",children:u("modelPicker.showLess")})]})}function dt({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 mt({value:s,options:r,placeholder:l,onChange:o}){const{t:a}=ve("settings"),[t,c]=i.useState(!1),[u,x]=i.useState(""),h=i.useRef(null),y=i.useRef(null),A=i.useRef(null),[g,C]=i.useState(-1);i.useEffect(()=>{function m(w){h.current&&!h.current.contains(w.target)&&c(!1)}return document.addEventListener("mousedown",m),()=>document.removeEventListener("mousedown",m)},[]),i.useEffect(()=>{t&&y.current&&y.current.focus()},[t]);const N=i.useMemo(()=>{if(!u.trim())return r;const m=u.toLowerCase();return r.filter(w=>w.modelId.toLowerCase().includes(m)||w.modelName.toLowerCase().includes(m)||w.provider.toLowerCase().includes(m)||w.providerLabel.toLowerCase().includes(m)||w.tier&&w.tier.toLowerCase().includes(m))},[r,u]),b=i.useMemo(()=>{const m=new Map;for(const R of N){const I=R.providerLabel;m.has(I)||m.set(I,[]),m.get(I).push(R)}const w={max:0,pro:1,base:2};for(const R of m.values())R.sort((I,F)=>(w[I.tier??"base"]??9)-(w[F.tier??"base"]??9));return m},[N]),S=i.useMemo(()=>{const m=[];for(const w of b.values())m.push(...w);return m},[b]),f=i.useMemo(()=>{if(!s)return l??a("modelRouting.auto");const m=r.find(w=>`${w.provider}/${w.modelId}`===s);return m?`${m.providerLabel}/${m.modelName}`:s},[s,r,l,a]);function v(m){if(!t){(m.key==="Enter"||m.key===" ")&&(m.preventDefault(),c(!0));return}switch(m.key){case"ArrowDown":m.preventDefault(),C(w=>Math.min(w+1,S.length-1));break;case"ArrowUp":m.preventDefault(),C(w=>Math.max(w-1,-1));break;case"Enter":m.preventDefault(),g===-1?o(""):S[g]&&o(`${S[g].provider}/${S[g].modelId}`),c(!1),x("");break;case"Escape":c(!1),x("");break}}return i.useEffect(()=>{A.current&&g>=0&&A.current.querySelector(`[data-focus-index="${g}"]`)?.scrollIntoView({block:"nearest"})},[g]),e.jsxs("div",{ref:h,className:"relative",onKeyDown:v,children:[e.jsx("button",{type:"button",onClick:()=>{c(!t),x(""),C(-1)},className:"w-full px-2 py-1 bg-surface-overlay border border-border-default rounded text-xs text-fg-primary text-left truncate focus:outline-none focus:border-brand-500",children:f}),t&&e.jsxs("div",{className:"absolute z-50 mt-1 w-full min-w-[240px] max-h-[280px] bg-surface-elevated border border-border-default rounded-lg shadow-xl overflow-hidden flex flex-col",children:[e.jsx("div",{className:"p-1.5 border-b border-border-default",children:e.jsx("input",{ref:y,type:"text",value:u,onChange:m=>{x(m.target.value),C(-1)},placeholder:a("modelPicker.searchPlaceholder")||"Search models...",className:"w-full px-2 py-1 bg-surface-overlay border border-border-default rounded text-xs text-fg-primary focus:outline-none focus:border-brand-500"})}),e.jsxs("div",{ref:A,className:"overflow-y-auto flex-1",children:[e.jsx("div",{className:`px-3 py-1.5 text-xs cursor-pointer ${g===-1?"bg-brand-500/20 text-brand-500":"text-fg-secondary hover:bg-surface-overlay"}`,onClick:()=>{o(""),c(!1),x("")},children:l??a("modelRouting.auto")}),[...b.entries()].map(([m,w])=>e.jsxs("div",{children:[e.jsx("div",{className:"px-3 py-1 text-[10px] font-semibold text-fg-tertiary uppercase tracking-wider bg-surface-overlay/50 sticky top-0",children:m}),w.map(R=>{const I=S.indexOf(R),F=`${R.provider}/${R.modelId}`===s;return e.jsxs("div",{"data-focus-index":I,className:`px-3 py-1.5 text-xs cursor-pointer flex items-center gap-2 ${I===g?"bg-brand-500/20":F?"bg-surface-overlay":"hover:bg-surface-overlay/50"}`,onClick:()=>{o(`${R.provider}/${R.modelId}`),c(!1),x("")},children:[e.jsx("span",{className:"flex-1 truncate text-fg-primary",children:R.modelName}),R.tier&&e.jsx(Oa,{tier:R.tier}),R.costTier&&e.jsx("span",{className:"text-[9px] text-fg-tertiary",children:R.costTier})]},`${R.provider}/${R.modelId}`)})]},m)),S.length===0&&e.jsx("div",{className:"px-3 py-3 text-xs text-fg-tertiary text-center",children:a("modelPicker.empty")})]})]})]})}function Oa({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 Fa=500,Qr=[{groupKey:"image",capabilities:["image_recognition","image_generation"]},{groupKey:"audio",capabilities:["audio_tts","audio_stt"]},{groupKey:"video",capabilities:["video_generation"]}];function _a({onSave:s,configuredProviders:r}){const{t:l}=ve(["settings","common"]),[o,a]=i.useState({}),[t,c]=i.useState(null),[u,x]=i.useState(!1),[h,y]=i.useState(null),[A,g]=i.useState(!0),[C,N]=i.useState("idle"),[b,S]=i.useState(null),[f,v]=i.useState({}),[m,w]=i.useState(!1),[R,I]=i.useState("idle"),[F,$]=i.useState(null),[P,D]=i.useState(!1),L=i.useRef(null),U=i.useRef(null),_=i.useMemo(()=>r.map(d=>d.name).sort().join(","),[r]);i.useEffect(()=>{fetch("/api/settings/llm/routing",{credentials:"include"}).then(d=>{if(!d.ok)throw new Error(`HTTP ${d.status}`);return d.json()}).then(d=>{a(d.capabilityRouting?.assignments??{}),c(d.routingDefaultModel??null),x(!0)}).catch(d=>{y(String(d)),x(!0)})},[_]),i.useEffect(()=>{let d=!1;return g(!0),fetch("/api/models/routing-candidates",{credentials:"include"}).then(k=>{if(!k.ok)throw new Error(`HTTP ${k.status}`);return k.json()}).then(k=>{if(d)return;const O=[];for(const z of k.providers)for(const J of z.models)O.push({provider:z.provider,providerLabel:z.displayName,modelId:J.id,modelName:J.name,mode:J.mode,tier:J.tier,costTier:J.costTier,capabilities:J.capabilities});S(O)}).catch(()=>{d||S(null)}).finally(()=>{d||g(!1)}),()=>{d=!0}},[_]),i.useEffect(()=>{fetch("/api/models/suggested-assignments",{credentials:"include"}).then(d=>{if(!d.ok)throw new Error(`HTTP ${d.status}`);return d.json()}).then(d=>{v(d.suggestions),w(!0)}).catch(()=>w(!0))},[_]);const K=i.useCallback(d=>{N("saving"),s(d).then(()=>{N("saved"),setTimeout(()=>N(k=>k==="saved"?"idle":k),2e3)}).catch(()=>{N("error"),setTimeout(()=>N(k=>k==="error"?"idle":k),3e3)})},[s]),H=i.useCallback((d,k)=>{U.current={capabilityRouting:d!==void 0?{assignments:d}:U.current?.capabilityRouting,routingDefaultModel:k!==void 0?k:U.current?.routingDefaultModel},L.current&&clearTimeout(L.current),L.current=setTimeout(()=>{const O=U.current;U.current=null,O&&K(O)},Fa)},[K]),T=i.useMemo(()=>r.flatMap(d=>(d.models??[{id:d.model,name:d.model}]).map(k=>({provider:d.name,providerLabel:d.displayName??d.name,modelId:k.id,modelName:k.name}))),[r]),B=b??T,ee=i.useMemo(()=>Object.entries(o).map(([d,k])=>`${d}:${k?.provider??""}/${k?.model??""}`).sort().join("|"),[o]);i.useEffect(()=>{!u||!b||b.length===0||b.some(d=>!!d.modelId)&&(a(d=>{let k=!1;const O={...d};for(const z of Qr)for(const J of z.capabilities){const se=O[J];if(!se?.model)continue;const Z=Vn(b,J);if(Z.length===0)continue;Z.some(Ne=>Ne.provider===se.provider&&Ne.modelId===se.model)||(delete O[J],k=!0)}return k?(H(O),O):d}),c(d=>{if(!d?.model||b.some(J=>J.provider===d.provider&&J.modelId===d.model))return d;const O=b.find(J=>J.provider==="markus"),z=O?{provider:O.provider,model:O.modelId}:{provider:b[0].provider,model:b[0].modelId};return s({routingDefaultModel:z}),z}))},[u,b,_,H,ee]);const ie=i.useCallback(()=>{fetch("/api/settings/llm/routing",{credentials:"include"}).then(d=>{if(!d.ok)throw new Error(`HTTP ${d.status}`);return d.json()}).then(d=>{a(d.capabilityRouting?.assignments??{}),c(d.routingDefaultModel??null)}).catch(()=>{}),g(!0),fetch("/api/models/routing-candidates",{credentials:"include"}).then(d=>{if(!d.ok)throw new Error(`HTTP ${d.status}`);return d.json()}).then(d=>{const k=[];for(const O of d.providers)for(const z of O.models)k.push({provider:O.provider,providerLabel:O.displayName,modelId:z.id,modelName:z.name,mode:z.mode,tier:z.tier,costTier:z.costTier,capabilities:z.capabilities});S(k)}).catch(()=>{}).finally(()=>g(!1))},[]),de=i.useCallback(async()=>{if(R!=="working"){I("working"),$(null);try{const d=await fetch("/api/settings/llm/restore-recommended",{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"}}),k=await d.json().catch(()=>({}));if(!d.ok||!k.ok)throw new Error(k.error??`HTTP ${d.status}`);k.capabilityRouting&&a(k.capabilityRouting.assignments??{}),k.routingDefaultModel!==void 0&&c(k.routingDefaultModel),ie(),I("idle"),N("saved"),setTimeout(()=>N(O=>O==="saved"?"idle":O),2e3)}catch(d){I("error"),$(d instanceof Error?d.message:String(d)),setTimeout(()=>I("idle"),4e3)}}},[R,ie]),re=B.length>0;return u?h?e.jsx("div",{className:"bg-red-500/10 border border-red-500/30 rounded-xl p-4 text-xs text-red-400",children:l("modelRouting.loadError",{error:h})}):A&&!re?e.jsx("div",{className:"space-y-4",children:e.jsx("div",{className:"bg-surface-elevated rounded-xl p-5",children:e.jsxs("div",{className:"flex items-center gap-2 text-xs text-fg-secondary",children:[e.jsxs("svg",{className:"w-4 h-4 animate-spin text-brand-500",fill:"none",viewBox:"0 0 24 24",children:[e.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),e.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8v4a4 4 0 00-4 4H4z"})]}),e.jsx("span",{children:l("modelRouting.loadingModels")})]})})}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx(Va,{status:C,t:l}),e.jsxs("div",{className:"flex flex-col items-end gap-1",children:[e.jsx("button",{type:"button",onClick:()=>D(!0),disabled:R==="working",className:"text-xs px-3 py-1.5 rounded-lg border border-border-default text-fg-secondary hover:text-fg-primary hover:border-brand-500/40 disabled:opacity-50 transition-colors",children:l(R==="working"?"modelRouting.restoreWorking":"modelRouting.restoreRecommended")}),F&&e.jsx("span",{className:"text-[10px] text-red-400 max-w-xs text-right",children:F})]})]}),e.jsxs("div",{className:"bg-surface-elevated rounded-xl p-5 space-y-3",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-semibold text-fg-primary",children:l("modelRouting.defaultModelTitle")}),e.jsx("p",{className:"text-xs text-fg-tertiary mt-1",children:l("modelRouting.defaultModelDesc")})]}),e.jsx("div",{className:"max-w-md",children:e.jsx(mt,{value:t?`${t.provider}/${t.model}`:"",options:B,placeholder:l("modelRouting.defaultModelPlaceholder"),onChange:d=>{if(!d)c(null),H(void 0,null);else{const[k,...O]=d.split("/"),z={provider:k,model:O.join("/")};if(c(z),o.text){const J={...o};delete J.text,a(J),H(J,z)}else H(void 0,z)}}})})]}),e.jsxs("div",{className:"bg-surface-elevated rounded-xl p-5 space-y-4",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-semibold text-fg-primary",children:l("modelRouting.capabilityAssignTitle")}),e.jsx("p",{className:"text-xs text-fg-tertiary mt-1",children:l("modelRouting.capabilityAssignDesc")})]}),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:l("modelRouting.noProvidersHint")}),r.length>0&&e.jsx("div",{className:"space-y-4",children:Qr.map(d=>e.jsx(Ua,{groupKey:d.groupKey,capabilities:d.capabilities,assignments:o,suggestions:f,allModels:B,configuredProviderNames:new Set(r.map(k=>k.name)),t:l,onAssign:(k,O)=>{const z={...o};O?z[k]=O:delete z[k],a(z),H(z)}},d.groupKey))})]}),P&&e.jsx(Ks,{variant:"primary",title:l("modelRouting.restoreRecommended"),message:l("modelRouting.restoreConfirm"),confirmLabel:l("common:confirm"),onConfirm:()=>{D(!1),de()},onCancel:()=>D(!1)})]}):e.jsx("div",{className:"space-y-4",children:e.jsxs("div",{className:"bg-surface-elevated rounded-xl p-5 animate-pulse",children:[e.jsx("div",{className:"h-4 bg-surface-overlay rounded w-1/3 mb-3"}),e.jsx("div",{className:"h-3 bg-surface-overlay rounded w-2/3 mb-4"}),e.jsx("div",{className:"space-y-2",children:[1,2,3,4,5].map(d=>e.jsx("div",{className:"h-10 bg-surface-overlay rounded-lg"},d))})]})})}function Ua({groupKey:s,capabilities:r,assignments:l,suggestions:o,allModels:a,configuredProviderNames:t,t:c,onAssign:u}){return e.jsxs("div",{children:[e.jsx("div",{className:"text-[10px] font-semibold text-fg-tertiary uppercase tracking-wider mb-2 px-1",children:c(`modelRouting.capabilityGroups.${s}`)}),e.jsx("div",{className:"space-y-1",children:r.map(x=>{const h=l[x],y=o[x],A=h?`${h.provider}/${h.model}`:"",g=Vn(a,x),C=y?g.find(v=>v.provider===y.provider&&v.modelId===y.model)?.modelName??y.model:void 0,N=g.length>0,b=h?$a(a,h.provider,h.model):void 0,S=h&&!t.has(h.provider),f=!!(h&&N&&x!=="text"&&!g.some(v=>v.provider===h.provider&&v.modelId===h.model));return e.jsxs("div",{className:`flex items-center gap-3 px-3 py-2 rounded-lg ${f?"bg-red-500/10 border border-red-500/30":S?"bg-yellow-500/10 border border-yellow-500/30":!N&&!h?"bg-amber-500/5 border border-amber-500/20":"bg-surface-overlay/40"}`,children:[e.jsx("div",{className:"w-28 shrink-0",children:e.jsx("span",{className:"text-xs text-fg-primary",children:c(`modelRouting.capabilities.${x}`)})}),e.jsx("div",{className:"flex-1 min-w-0",children:f?e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsxs("span",{className:"text-xs text-red-400",children:["⚠ ",h.model]}),e.jsx("span",{className:"text-[10px] text-red-400/70",children:c("modelRouting.mismatchHint")})]}),e.jsx(mt,{value:"",options:g,placeholder:c("modelRouting.selectModel"),onChange:v=>{if(!v)u(x,null);else{const[m,...w]=v.split("/");u(x,{provider:m,model:w.join("/")})}}})]}):N?e.jsx(mt,{value:A,options:g,placeholder:C?`${C} (${c("modelRouting.suggested")})`:c("modelRouting.selectModel"),onChange:v=>{if(!v)u(x,null);else{const[m,...w]=v.split("/");u(x,{provider:m,model:w.join("/")})}}}):e.jsxs("span",{className:"text-xs text-amber-400",children:[c("modelRouting.noModelAvailable"),e.jsxs("span",{className:"text-fg-tertiary ml-1",children:["— ",c("modelRouting.addProviderHint")]})]})}),e.jsxs("div",{className:"w-14 shrink-0 flex justify-end",children:[f&&e.jsx("span",{className:"text-[10px] text-red-400 font-medium",title:c("modelRouting.mismatchHint"),children:"⚠"}),!f&&S&&e.jsx("span",{className:"text-[10px] text-yellow-400 font-medium",title:c("modelRouting.staleProvider"),children:"⚠"}),!f&&!S&&b&&e.jsx(Yr,{tier:b}),!f&&!S&&!b&&h&&e.jsx(Yr,{tier:"unknown"})]}),e.jsx("div",{className:"w-8 shrink-0 flex justify-end",children:h&&e.jsx("button",{onClick:()=>u(x,null),className:"text-fg-tertiary hover:text-red-400 transition-colors",title:c("modelRouting.clear"),children:e.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})})]},x)})})]})}function $a(s,r,l){return s.find(a=>a.provider===r&&a.modelId===l)?.tier}function Va({status:s,t:r}){if(s==="idle")return null;const l={idle:"",saving:"text-fg-tertiary",saved:"text-green-400",error:"text-red-400"},o={idle:"",saving:r("modelRouting.saving"),saved:r("modelRouting.saved"),error:r("modelRouting.saveError")};return e.jsx("div",{className:`text-xs font-medium transition-opacity ${l[s]}`,children:o[s]})}function Yr({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})}function Vn(s,r){if(r==="text")return s.filter(c=>Ia(c));const l={image_generation:["image_generation"],audio_tts:["audio_speech"],audio_stt:["audio_transcription"],video_generation:["video_generation"]},o={image_recognition:["vision"],image_generation:["imageGeneration"],audio_tts:["tts"],audio_stt:["stt"],video_generation:["videoGeneration"]},a=l[r],t=o[r];return s.filter(c=>!!(c.capabilities&&c.capabilities.length>0&&t&&t.some(u=>c.capabilities.includes(u))||a&&c.mode&&a.includes(c.mode)))}function Ka({configuredProviders:s}){const{t:r}=ve("settings"),[l,o]=i.useState(null),[a,t]=i.useState([]),[c,u]=i.useState(null),[x,h]=i.useState(null),y=i.useMemo(()=>s.map(b=>`${b.name}:${b.models?.length??0}`).sort().join(","),[s]),A=i.useCallback(async()=>{u(null);try{const[{agents:b},S]=await Promise.all([V.agents.list(),V.teams.list()]),f=S.teams.map(m=>({id:m.id,name:m.name}));t(f);const v=await Promise.all(b.map(async m=>{try{const R=(await V.agents.get(m.id)).config?.llmConfig;return{id:m.id,name:m.name||m.id,teamId:m.teamId,override:R?.modelMode==="custom"&&R.primary&&R.defaultModel?`${R.primary}/${R.defaultModel}`:null,llmConfig:{modelMode:R?.modelMode,primary:R?.primary??"",defaultModel:R?.defaultModel}}}catch{return{id:m.id,name:m.name||m.id,teamId:m.teamId,override:null,llmConfig:{modelMode:"default",primary:"",defaultModel:void 0}}}}));o(b.length?v:null)}catch(b){u(String(b))}},[y]);i.useEffect(()=>{A()},[A,y]);const g=i.useMemo(()=>{const b=[];for(const S of s)for(const f of S.models??[])b.push({provider:S.name,providerLabel:S.displayName??S.name,modelId:f.id,modelName:f.name??f.id});return b},[s]),C=async(b,S)=>{h(b),u(null);try{if(S){const[f,v]=[S.slice(0,S.lastIndexOf("/")),S.slice(S.lastIndexOf("/")+1)];await V.agents.updateConfig(b,{llmConfig:{modelMode:"custom",primary:f,defaultModel:v}})}else await V.agents.updateConfig(b,{llmConfig:{modelMode:"default",primary:"",defaultModel:void 0}});o(f=>f?.map(v=>v.id===b?{...v,override:S}:v)??f)}catch(f){u(String(f))}finally{h(null)}},N=i.useMemo(()=>{if(!l)return[];const b=new Map,S=[];for(const v of l)if(v.teamId){const m=b.get(v.teamId)??[];m.push(v),b.set(v.teamId,m)}else S.push(v);const f=[];S.length&&f.push({key:"ungrouped",label:r("perAgentModel.ungrouped",{defaultValue:"Ungrouped"}),rows:S});for(const v of a){const m=b.get(v.id);m?.length&&f.push({key:`team:${v.id}`,label:v.name,rows:m})}for(const[v,m]of b)a.some(w=>w.id===v)||f.push({key:`team:${v}`,label:v,rows:m});return f},[l,a,r]);return l===null&&!c?e.jsx("div",{className:"bg-surface-elevated rounded-xl p-5 text-sm text-fg-tertiary",children:r("common:loading",{defaultValue:"Loading…"})}):e.jsxs("div",{className:"bg-surface-elevated rounded-xl p-5 space-y-4",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium",children:r("perAgentModel.title",{defaultValue:"Per-agent default model"})}),e.jsx("div",{className:"text-xs text-fg-tertiary mt-0.5",children:r("perAgentModel.desc",{defaultValue:'Bind a specific provider+model to an agent, or leave it following the global default. This is what the composer "Apply to current agent" writes.'})})]})}),c&&e.jsx("div",{className:"text-xs text-red-500",children:c}),(!l||l.length===0)&&!c&&e.jsx("div",{className:"text-xs text-fg-tertiary",children:r("perAgentModel.noAgents",{defaultValue:"No agents available."})}),l&&l.length>0&&e.jsx("div",{className:"space-y-5",children:N.map(b=>e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wider text-fg-tertiary truncate",children:b.label}),e.jsx("span",{className:"text-[10px] text-fg-tertiary/70 tabular-nums shrink-0",children:b.rows.length})]}),e.jsx("div",{className:"space-y-2",children:b.rows.map(S=>e.jsxs("div",{className:"flex items-center justify-between gap-3 text-sm",children:[e.jsxs("div",{className:"flex-1 truncate",children:[e.jsx("span",{className:"font-medium",children:S.name}),e.jsx("span",{className:"text-xs text-fg-tertiary ml-2 truncate",children:S.id})]}),e.jsxs("div",{className:"flex items-center gap-2 w-[320px]",children:[S.override?e.jsxs(e.Fragment,{children:[e.jsx(mt,{value:S.override,options:g,placeholder:r("perAgentModel.followGlobal",{defaultValue:"Follow global"}),onChange:f=>{C(S.id,f||null)}}),e.jsx("button",{type:"button",disabled:x===S.id,onClick:()=>{C(S.id,null)},className:"shrink-0 px-2.5 py-1.5 text-xs border border-border-default rounded-lg hover:bg-surface-base disabled:opacity-40 transition-colors",children:r("perAgentModel.reset",{defaultValue:"Reset"})})]}):e.jsx(mt,{value:"",options:g,placeholder:r("perAgentModel.followGlobal",{defaultValue:"Follow global"}),onChange:f=>{C(S.id,f||null)}}),x===S.id&&e.jsx("span",{className:"shrink-0 text-[10px] text-fg-tertiary",children:r("common:loading",{defaultValue:"…"})})]})]},S.id))})]},b.key))})]})}let It=[],Et=null;async function za(){return Et||(Et=(async()=>{try{It=(await V.modelCatalog.providerCatalog()).providers??[]}catch{It=[]}return It})(),Et)}function qa(){const[s,r]=i.useState(It);return i.useEffect(()=>{let l=!0;return za().then(o=>{l&&r(o)}),()=>{l=!1}},[]),s}var Ze={},ps,Zr;function Ha(){return Zr||(Zr=1,ps=function(){return typeof Promise=="function"&&Promise.prototype&&Promise.prototype.then}),ps}var hs={},Fe={},Xr;function Ke(){if(Xr)return Fe;Xr=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 Fe.getSymbolSize=function(o){if(!o)throw new Error('"version" cannot be null or undefined');if(o<1||o>40)throw new Error('"version" should be in range from 1 to 40');return o*4+17},Fe.getSymbolTotalCodewords=function(o){return r[o]},Fe.getBCHDigit=function(l){let o=0;for(;l!==0;)o++,l>>>=1;return o},Fe.setToSJISFunction=function(o){if(typeof o!="function")throw new Error('"toSJISFunc" is not a valid function.');s=o},Fe.isKanjiModeEnabled=function(){return typeof s<"u"},Fe.toSJIS=function(o){return s(o)},Fe}var bs={},en;function qs(){return en||(en=1,(function(s){s.L={bit:1},s.M={bit:0},s.Q={bit:3},s.H={bit:2};function r(l){if(typeof l!="string")throw new Error("Param is not a string");switch(l.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: "+l)}}s.isValid=function(o){return o&&typeof o.bit<"u"&&o.bit>=0&&o.bit<4},s.from=function(o,a){if(s.isValid(o))return o;try{return r(o)}catch{return a}}})(bs)),bs}var ys,tn;function Wa(){if(tn)return ys;tn=1;function s(){this.buffer=[],this.length=0}return s.prototype={get:function(r){const l=Math.floor(r/8);return(this.buffer[l]>>>7-r%8&1)===1},put:function(r,l){for(let o=0;o<l;o++)this.putBit((r>>>l-o-1&1)===1)},getLengthInBits:function(){return this.length},putBit:function(r){const l=Math.floor(this.length/8);this.buffer.length<=l&&this.buffer.push(0),r&&(this.buffer[l]|=128>>>this.length%8),this.length++}},ys=s,ys}var vs,sn;function Ja(){if(sn)return vs;sn=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,l,o,a){const t=r*this.size+l;this.data[t]=o,a&&(this.reservedBit[t]=!0)},s.prototype.get=function(r,l){return this.data[r*this.size+l]},s.prototype.xor=function(r,l,o){this.data[r*this.size+l]^=o},s.prototype.isReserved=function(r,l){return this.reservedBit[r*this.size+l]},vs=s,vs}var js={},rn;function Ga(){return rn||(rn=1,(function(s){const r=Ke().getSymbolSize;s.getRowColCoords=function(o){if(o===1)return[];const a=Math.floor(o/7)+2,t=r(o),c=t===145?26:Math.ceil((t-13)/(2*a-2))*2,u=[t-7];for(let x=1;x<a-1;x++)u[x]=u[x-1]-c;return u.push(6),u.reverse()},s.getPositions=function(o){const a=[],t=s.getRowColCoords(o),c=t.length;for(let u=0;u<c;u++)for(let x=0;x<c;x++)u===0&&x===0||u===0&&x===c-1||u===c-1&&x===0||a.push([t[u],t[x]]);return a}})(js)),js}var ws={},nn;function Qa(){if(nn)return ws;nn=1;const s=Ke().getSymbolSize,r=7;return ws.getPositions=function(o){const a=s(o);return[[0,0],[a-r,0],[0,a-r]]},ws}var Ns={},an;function Ya(){return an||(an=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 c=0,u=0,x=0,h=null,y=null;for(let A=0;A<t;A++){u=x=0,h=y=null;for(let g=0;g<t;g++){let C=a.get(A,g);C===h?u++:(u>=5&&(c+=r.N1+(u-5)),h=C,u=1),C=a.get(g,A),C===y?x++:(x>=5&&(c+=r.N1+(x-5)),y=C,x=1)}u>=5&&(c+=r.N1+(u-5)),x>=5&&(c+=r.N1+(x-5))}return c},s.getPenaltyN2=function(a){const t=a.size;let c=0;for(let u=0;u<t-1;u++)for(let x=0;x<t-1;x++){const h=a.get(u,x)+a.get(u,x+1)+a.get(u+1,x)+a.get(u+1,x+1);(h===4||h===0)&&c++}return c*r.N2},s.getPenaltyN3=function(a){const t=a.size;let c=0,u=0,x=0;for(let h=0;h<t;h++){u=x=0;for(let y=0;y<t;y++)u=u<<1&2047|a.get(h,y),y>=10&&(u===1488||u===93)&&c++,x=x<<1&2047|a.get(y,h),y>=10&&(x===1488||x===93)&&c++}return c*r.N3},s.getPenaltyN4=function(a){let t=0;const c=a.data.length;for(let x=0;x<c;x++)t+=a.data[x];return Math.abs(Math.ceil(t*100/c/5)-10)*r.N4};function l(o,a,t){switch(o){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:"+o)}}s.applyMask=function(a,t){const c=t.size;for(let u=0;u<c;u++)for(let x=0;x<c;x++)t.isReserved(x,u)||t.xor(x,u,l(a,x,u))},s.getBestMask=function(a,t){const c=Object.keys(s.Patterns).length;let u=0,x=1/0;for(let h=0;h<c;h++){t(h),s.applyMask(h,a);const y=s.getPenaltyN1(a)+s.getPenaltyN2(a)+s.getPenaltyN3(a)+s.getPenaltyN4(a);s.applyMask(h,a),y<x&&(x=y,u=h)}return u}})(Ns)),Ns}var Tt={},on;function Kn(){if(on)return Tt;on=1;const s=qs(),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],l=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];return Tt.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}},Tt.getTotalCodewordsCount=function(a,t){switch(t){case s.L:return l[(a-1)*4+0];case s.M:return l[(a-1)*4+1];case s.Q:return l[(a-1)*4+2];case s.H:return l[(a-1)*4+3];default:return}},Tt}var ks={},ct={},ln;function Za(){if(ln)return ct;ln=1;const s=new Uint8Array(512),r=new Uint8Array(256);return(function(){let o=1;for(let a=0;a<255;a++)s[a]=o,r[o]=a,o<<=1,o&256&&(o^=285);for(let a=255;a<512;a++)s[a]=s[a-255]})(),ct.log=function(o){if(o<1)throw new Error("log("+o+")");return r[o]},ct.exp=function(o){return s[o]},ct.mul=function(o,a){return o===0||a===0?0:s[r[o]+r[a]]},ct}var dn;function Xa(){return dn||(dn=1,(function(s){const r=Za();s.mul=function(o,a){const t=new Uint8Array(o.length+a.length-1);for(let c=0;c<o.length;c++)for(let u=0;u<a.length;u++)t[c+u]^=r.mul(o[c],a[u]);return t},s.mod=function(o,a){let t=new Uint8Array(o);for(;t.length-a.length>=0;){const c=t[0];for(let x=0;x<a.length;x++)t[x]^=r.mul(a[x],c);let u=0;for(;u<t.length&&t[u]===0;)u++;t=t.slice(u)}return t},s.generateECPolynomial=function(o){let a=new Uint8Array([1]);for(let t=0;t<o;t++)a=s.mul(a,new Uint8Array([1,r.exp(t)]));return a}})(ks)),ks}var Cs,cn;function eo(){if(cn)return Cs;cn=1;const s=Xa();function r(l){this.genPoly=void 0,this.degree=l,this.degree&&this.initialize(this.degree)}return r.prototype.initialize=function(o){this.degree=o,this.genPoly=s.generateECPolynomial(this.degree)},r.prototype.encode=function(o){if(!this.genPoly)throw new Error("Encoder not initialized");const a=new Uint8Array(o.length+this.degree);a.set(o);const t=s.mod(a,this.genPoly),c=this.degree-t.length;if(c>0){const u=new Uint8Array(this.degree);return u.set(t,c),u}return t},Cs=r,Cs}var Ss={},Ps={},Ms={},un;function zn(){return un||(un=1,Ms.isValid=function(r){return!isNaN(r)&&r>=1&&r<=40}),Ms}var Ae={},xn;function qn(){if(xn)return Ae;xn=1;const s="[0-9]+",r="[A-Z $%*+\\-./:]+";let l="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";l=l.replace(/u/g,"\\u");const o="(?:(?![A-Z0-9 $%*+\\-./:]|"+l+`)(?:.|[\r
2
2
  ]))+`;Ae.KANJI=new RegExp(l,"g"),Ae.BYTE_KANJI=new RegExp("[^A-Z0-9 $%*+\\-./:]+","g"),Ae.BYTE=new RegExp(o,"g"),Ae.NUMERIC=new RegExp(s,"g"),Ae.ALPHANUMERIC=new RegExp(r,"g");const a=new RegExp("^"+l+"$"),t=new RegExp("^"+s+"$"),c=new RegExp("^[A-Z0-9 $%*+\\-./:]+$");return Ae.testKanji=function(x){return a.test(x)},Ae.testNumeric=function(x){return t.test(x)},Ae.testAlphanumeric=function(x){return c.test(x)},Ae}var mn;function ze(){return mn||(mn=1,(function(s){const r=zn(),l=qn();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,c){if(!t.ccBits)throw new Error("Invalid mode: "+t);if(!r.isValid(c))throw new Error("Invalid version: "+c);return c>=1&&c<10?t.ccBits[0]:c<27?t.ccBits[1]:t.ccBits[2]},s.getBestModeForData=function(t){return l.testNumeric(t)?s.NUMERIC:l.testAlphanumeric(t)?s.ALPHANUMERIC:l.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 o(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,c){if(s.isValid(t))return t;try{return o(t)}catch{return c}}})(Ps)),Ps}var fn;function to(){return fn||(fn=1,(function(s){const r=Ke(),l=Kn(),o=qs(),a=ze(),t=zn(),c=7973,u=r.getBCHDigit(c);function x(g,C,N){for(let b=1;b<=40;b++)if(C<=s.getCapacity(b,N,g))return b}function h(g,C){return a.getCharCountIndicator(g,C)+4}function y(g,C){let N=0;return g.forEach(function(b){const S=h(b.mode,C);N+=S+b.getBitsLength()}),N}function A(g,C){for(let N=1;N<=40;N++)if(y(g,N)<=s.getCapacity(N,C,a.MIXED))return N}s.from=function(C,N){return t.isValid(C)?parseInt(C,10):N},s.getCapacity=function(C,N,b){if(!t.isValid(C))throw new Error("Invalid QR Code version");typeof b>"u"&&(b=a.BYTE);const S=r.getSymbolTotalCodewords(C),f=l.getTotalCodewordsCount(C,N),v=(S-f)*8;if(b===a.MIXED)return v;const m=v-h(b,C);switch(b){case a.NUMERIC:return Math.floor(m/10*3);case a.ALPHANUMERIC:return Math.floor(m/11*2);case a.KANJI:return Math.floor(m/13);case a.BYTE:default:return Math.floor(m/8)}},s.getBestVersionForData=function(C,N){let b;const S=o.from(N,o.M);if(Array.isArray(C)){if(C.length>1)return A(C,S);if(C.length===0)return 1;b=C[0]}else b=C;return x(b.mode,b.getLength(),S)},s.getEncodedBits=function(C){if(!t.isValid(C)||C<7)throw new Error("Invalid QR Code version");let N=C<<12;for(;r.getBCHDigit(N)-u>=0;)N^=c<<r.getBCHDigit(N)-u;return C<<12|N}})(Ss)),Ss}var As={},gn;function so(){if(gn)return As;gn=1;const s=Ke(),r=1335,l=21522,o=s.getBCHDigit(r);return As.getEncodedBits=function(t,c){const u=t.bit<<3|c;let x=u<<10;for(;s.getBCHDigit(x)-o>=0;)x^=r<<s.getBCHDigit(x)-o;return(u<<10|x)^l},As}var Es={},Ts,pn;function ro(){if(pn)return Ts;pn=1;const s=ze();function r(l){this.mode=s.NUMERIC,this.data=l.toString()}return r.getBitsLength=function(o){return 10*Math.floor(o/3)+(o%3?o%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(o){let a,t,c;for(a=0;a+3<=this.data.length;a+=3)t=this.data.substr(a,3),c=parseInt(t,10),o.put(c,10);const u=this.data.length-a;u>0&&(t=this.data.substr(a),c=parseInt(t,10),o.put(c,u*3+1))},Ts=r,Ts}var Ls,hn;function no(){if(hn)return Ls;hn=1;const s=ze(),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 l(o){this.mode=s.ALPHANUMERIC,this.data=o}return l.getBitsLength=function(a){return 11*Math.floor(a/2)+6*(a%2)},l.prototype.getLength=function(){return this.data.length},l.prototype.getBitsLength=function(){return l.getBitsLength(this.data.length)},l.prototype.write=function(a){let t;for(t=0;t+2<=this.data.length;t+=2){let c=r.indexOf(this.data[t])*45;c+=r.indexOf(this.data[t+1]),a.put(c,11)}this.data.length%2&&a.put(r.indexOf(this.data[t]),6)},Ls=l,Ls}var Is,bn;function ao(){if(bn)return Is;bn=1;const s=ze();function r(l){this.mode=s.BYTE,typeof l=="string"?this.data=new TextEncoder().encode(l):this.data=new Uint8Array(l)}return r.getBitsLength=function(o){return o*8},r.prototype.getLength=function(){return this.data.length},r.prototype.getBitsLength=function(){return r.getBitsLength(this.data.length)},r.prototype.write=function(l){for(let o=0,a=this.data.length;o<a;o++)l.put(this.data[o],8)},Is=r,Is}var Rs,yn;function oo(){if(yn)return Rs;yn=1;const s=ze(),r=Ke();function l(o){this.mode=s.KANJI,this.data=o}return l.getBitsLength=function(a){return a*13},l.prototype.getLength=function(){return this.data.length},l.prototype.getBitsLength=function(){return l.getBitsLength(this.data.length)},l.prototype.write=function(o){let a;for(a=0;a<this.data.length;a++){let t=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),o.put(t,13)}},Rs=l,Rs}var Bs={exports:{}},vn;function io(){return vn||(vn=1,(function(s){var r={single_source_shortest_paths:function(l,o,a){var t={},c={};c[o]=0;var u=r.PriorityQueue.make();u.push(o,0);for(var x,h,y,A,g,C,N,b,S;!u.empty();){x=u.pop(),h=x.value,A=x.cost,g=l[h]||{};for(y in g)g.hasOwnProperty(y)&&(C=g[y],N=A+C,b=c[y],S=typeof c[y]>"u",(S||b>N)&&(c[y]=N,u.push(y,N),t[y]=h))}if(typeof a<"u"&&typeof c[a]>"u"){var f=["Could not find a path from ",o," to ",a,"."].join("");throw new Error(f)}return t},extract_shortest_path_from_predecessor_list:function(l,o){for(var a=[],t=o;t;)a.push(t),l[t],t=l[t];return a.reverse(),a},find_path:function(l,o,a){var t=r.single_source_shortest_paths(l,o,a);return r.extract_shortest_path_from_predecessor_list(t,a)},PriorityQueue:{make:function(l){var o=r.PriorityQueue,a={},t;l=l||{};for(t in o)o.hasOwnProperty(t)&&(a[t]=o[t]);return a.queue=[],a.sorter=l.sorter||o.default_sorter,a},default_sorter:function(l,o){return l.cost-o.cost},push:function(l,o){var a={value:l,cost:o};this.queue.push(a),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return this.queue.length===0}}};s.exports=r})(Bs)),Bs.exports}var jn;function lo(){return jn||(jn=1,(function(s){const r=ze(),l=ro(),o=no(),a=ao(),t=oo(),c=qn(),u=Ke(),x=io();function h(f){return unescape(encodeURIComponent(f)).length}function y(f,v,m){const w=[];let R;for(;(R=f.exec(m))!==null;)w.push({data:R[0],index:R.index,mode:v,length:R[0].length});return w}function A(f){const v=y(c.NUMERIC,r.NUMERIC,f),m=y(c.ALPHANUMERIC,r.ALPHANUMERIC,f);let w,R;return u.isKanjiModeEnabled()?(w=y(c.BYTE,r.BYTE,f),R=y(c.KANJI,r.KANJI,f)):(w=y(c.BYTE_KANJI,r.BYTE,f),R=[]),v.concat(m,w,R).sort(function(F,$){return F.index-$.index}).map(function(F){return{data:F.data,mode:F.mode,length:F.length}})}function g(f,v){switch(v){case r.NUMERIC:return l.getBitsLength(f);case r.ALPHANUMERIC:return o.getBitsLength(f);case r.KANJI:return t.getBitsLength(f);case r.BYTE:return a.getBitsLength(f)}}function C(f){return f.reduce(function(v,m){const w=v.length-1>=0?v[v.length-1]:null;return w&&w.mode===m.mode?(v[v.length-1].data+=m.data,v):(v.push(m),v)},[])}function N(f){const v=[];for(let m=0;m<f.length;m++){const w=f[m];switch(w.mode){case r.NUMERIC:v.push([w,{data:w.data,mode:r.ALPHANUMERIC,length:w.length},{data:w.data,mode:r.BYTE,length:w.length}]);break;case r.ALPHANUMERIC:v.push([w,{data:w.data,mode:r.BYTE,length:w.length}]);break;case r.KANJI:v.push([w,{data:w.data,mode:r.BYTE,length:h(w.data)}]);break;case r.BYTE:v.push([{data:w.data,mode:r.BYTE,length:h(w.data)}])}}return v}function b(f,v){const m={},w={start:{}};let R=["start"];for(let I=0;I<f.length;I++){const F=f[I],$=[];for(let P=0;P<F.length;P++){const D=F[P],L=""+I+P;$.push(L),m[L]={node:D,lastCount:0},w[L]={};for(let U=0;U<R.length;U++){const _=R[U];m[_]&&m[_].node.mode===D.mode?(w[_][L]=g(m[_].lastCount+D.length,D.mode)-g(m[_].lastCount,D.mode),m[_].lastCount+=D.length):(m[_]&&(m[_].lastCount=D.length),w[_][L]=g(D.length,D.mode)+4+r.getCharCountIndicator(D.mode,v))}}R=$}for(let I=0;I<R.length;I++)w[R[I]].end=0;return{map:w,table:m}}function S(f,v){let m;const w=r.getBestModeForData(f);if(m=r.from(v,w),m!==r.BYTE&&m.bit<w.bit)throw new Error('"'+f+'" cannot be encoded with mode '+r.toString(m)+`.
4
4
  Suggested mode is: `+r.toString(w));switch(m===r.KANJI&&!u.isKanjiModeEnabled()&&(m=r.BYTE),m){case r.NUMERIC:return new l(f);case r.ALPHANUMERIC:return new o(f);case r.KANJI:return new t(f);case r.BYTE:return new a(f)}}s.fromArray=function(v){return v.reduce(function(m,w){return typeof w=="string"?m.push(S(w,null)):w.data&&m.push(S(w.data,w.mode)),m},[])},s.fromString=function(v,m){const w=A(v,u.isKanjiModeEnabled()),R=N(w),I=b(R,m),F=x.find_path(I.map,"start","end"),$=[];for(let P=1;P<F.length-1;P++)$.push(I.table[F[P]].node);return s.fromArray(C($))},s.rawSplit=function(v){return s.fromArray(A(v,u.isKanjiModeEnabled()))}})(Es)),Es}var wn;function co(){if(wn)return hs;wn=1;const s=Ke(),r=qs(),l=Wa(),o=Ja(),a=Ga(),t=Qa(),c=Ya(),u=Kn(),x=eo(),h=to(),y=so(),A=ze(),g=lo();function C(I,F){const $=I.size,P=t.getPositions(F);for(let D=0;D<P.length;D++){const L=P[D][0],U=P[D][1];for(let _=-1;_<=7;_++)if(!(L+_<=-1||$<=L+_))for(let K=-1;K<=7;K++)U+K<=-1||$<=U+K||(_>=0&&_<=6&&(K===0||K===6)||K>=0&&K<=6&&(_===0||_===6)||_>=2&&_<=4&&K>=2&&K<=4?I.set(L+_,U+K,!0,!0):I.set(L+_,U+K,!1,!0))}}function N(I){const F=I.size;for(let $=8;$<F-8;$++){const P=$%2===0;I.set($,6,P,!0),I.set(6,$,P,!0)}}function b(I,F){const $=a.getPositions(F);for(let P=0;P<$.length;P++){const D=$[P][0],L=$[P][1];for(let U=-2;U<=2;U++)for(let _=-2;_<=2;_++)U===-2||U===2||_===-2||_===2||U===0&&_===0?I.set(D+U,L+_,!0,!0):I.set(D+U,L+_,!1,!0)}}function S(I,F){const $=I.size,P=h.getEncodedBits(F);let D,L,U;for(let _=0;_<18;_++)D=Math.floor(_/3),L=_%3+$-8-3,U=(P>>_&1)===1,I.set(D,L,U,!0),I.set(L,D,U,!0)}function f(I,F,$){const P=I.size,D=y.getEncodedBits(F,$);let L,U;for(L=0;L<15;L++)U=(D>>L&1)===1,L<6?I.set(L,8,U,!0):L<8?I.set(L+1,8,U,!0):I.set(P-15+L,8,U,!0),L<8?I.set(8,P-L-1,U,!0):L<9?I.set(8,15-L-1+1,U,!0):I.set(8,15-L-1,U,!0);I.set(P-8,8,1,!0)}function v(I,F){const $=I.size;let P=-1,D=$-1,L=7,U=0;for(let _=$-1;_>0;_-=2)for(_===6&&_--;;){for(let K=0;K<2;K++)if(!I.isReserved(D,_-K)){let H=!1;U<F.length&&(H=(F[U]>>>L&1)===1),I.set(D,_-K,H),L--,L===-1&&(U++,L=7)}if(D+=P,D<0||$<=D){D-=P,P=-P;break}}}function m(I,F,$){const P=new l;$.forEach(function(K){P.put(K.mode.bit,4),P.put(K.getLength(),A.getCharCountIndicator(K.mode,I)),K.write(P)});const D=s.getSymbolTotalCodewords(I),L=u.getTotalCodewordsCount(I,F),U=(D-L)*8;for(P.getLengthInBits()+4<=U&&P.put(0,4);P.getLengthInBits()%8!==0;)P.putBit(0);const _=(U-P.getLengthInBits())/8;for(let K=0;K<_;K++)P.put(K%2?17:236,8);return w(P,I,F)}function w(I,F,$){const P=s.getSymbolTotalCodewords(F),D=u.getTotalCodewordsCount(F,$),L=P-D,U=u.getBlocksCount(F,$),_=P%U,K=U-_,H=Math.floor(P/U),T=Math.floor(L/U),B=T+1,ee=H-T,ie=new x(ee);let de=0;const re=new Array(U),d=new Array(U);let k=0;const O=new Uint8Array(I.buffer);for(let ce=0;ce<U;ce++){const Ne=ce<K?T:B;re[ce]=O.slice(de,de+Ne),d[ce]=ie.encode(re[ce]),de+=Ne,k=Math.max(k,Ne)}const z=new Uint8Array(P);let J=0,se,Z;for(se=0;se<k;se++)for(Z=0;Z<U;Z++)se<re[Z].length&&(z[J++]=re[Z][se]);for(se=0;se<ee;se++)for(Z=0;Z<U;Z++)z[J++]=d[Z][se];return z}function R(I,F,$,P){let D;if(Array.isArray(I))D=g.fromArray(I);else if(typeof I=="string"){let H=F;if(!H){const T=g.rawSplit(I);H=h.getBestVersionForData(T,$)}D=g.fromString(I,H||40)}else throw new Error("Invalid data");const L=h.getBestVersionForData(D,$);if(!L)throw new Error("The amount of data is too big to be stored in a QR Code");if(!F)F=L;else if(F<L)throw new Error(`
@@ -1 +1 @@
1
- import{u as E,r as d,a as M,b as A,c as D,d as C,j as e,P as L,i as R,S as z,T as H,e as K,f as $,I as O,h as q,g as B}from"./index-gob1iLha.js";const v=[{id:"discover"},{id:"agents"},{id:"teams"},{id:"skills"},{id:"installed"}],P={agent:"agents",team:"teams",skill:"skills",connector:"skills"},F={discover:"M12 2l2.4 6.9L21 9l-5.4 4 2 7-5.6-4.1L6.4 20l2-7L3 9l6.6-.1z",agents:"M12 2a5 5 0 015 5v1a5 5 0 01-10 0V7a5 5 0 015-5zM4 21a8 8 0 0116 0z",teams:"M16 11a4 4 0 10-4-4 4 4 0 004 4zM8 13a3 3 0 10-3-3 3 3 0 003 3zm0 2c-2.7 0-5 1.3-5 3v2h7v-2c0-.7.2-1.3.6-1.9A7.6 7.6 0 008 15zm8 0c-3 0-6 1.5-6 3.5V21h12v-2.5c0-2-3-3.5-6-3.5z",skills:"M13 2L3 14h7l-1 8 10-12h-7z",installed:"M12 3v12m0 0l-4-4m4 4l4-4M5 21h14"};function I(n){return n==="discover"||n==="agents"||n==="teams"||n==="skills"||n==="installed"}function T(){const n=localStorage.getItem("markus_nav_installItem"),o=localStorage.getItem("markus_nav_storeTab");if(n)return{tab:I(o)?o:"agents",installId:n};const f=new URLSearchParams(window.location.search),s=f.get("install");if(s){const a=f.get("type");return{tab:a&&P[a]||"agents",installId:s}}return{tab:I(o)?o:"discover",installId:null}}function N(){localStorage.removeItem("markus_nav_installItem"),localStorage.removeItem("markus_nav_storeTab");const n=new URLSearchParams(window.location.search);if(n.has("install")||n.has("type")){n.delete("install"),n.delete("type");const o=n.toString();window.history.replaceState(null,"",window.location.pathname+(o?`?${o}`:"")+window.location.hash)}}function V({itemId:n,onDismiss:o,onInstalled:f}){const{t:s}=E(["store","common"]),[a,p]=d.useState(null),[g,l]=d.useState("loading"),[b,k]=d.useState(!1),[u,m]=d.useState("");d.useEffect(()=>{let x=!1;return l("loading"),p(null),m(""),q.getItem(n).then(({item:c})=>{x||(c?(p(c),l("ready")):l("missing"))}).catch(()=>{x||l("missing")}),()=>{x=!0}},[n]);const w=async()=>{if(!(!a||b)){k(!0),m("");try{await B(a),m(s("deepLink.installed")),f()}catch(x){const c=x instanceof Error?x.message:"";m(c.includes("402")||c.includes("Purchase")?s("deepLink.purchaseRequired"):s("deepLink.failed"))}finally{k(!1)}}};return e.jsxs("div",{className:"shrink-0 mx-3 mt-3 mb-1 rounded-xl border border-brand-500/30 bg-brand-600/10 px-4 py-3 flex flex-col sm:flex-row sm:items-center gap-3",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-wider text-brand-400/90 mb-0.5",children:s("deepLink.fromHub")}),g==="loading"&&e.jsx("p",{className:"text-sm text-fg-secondary",children:s("deepLink.loading")}),g==="missing"&&e.jsx("p",{className:"text-sm text-rose-300",children:s("deepLink.missing")}),g==="ready"&&a&&e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-sm font-semibold text-fg-primary truncate",children:a.name}),a.description&&e.jsx("p",{className:"text-xs text-fg-tertiary line-clamp-2 mt-0.5",children:a.description}),u&&e.jsx("p",{className:"text-xs mt-1 text-brand-300",children:u})]})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[g==="ready"&&a&&e.jsx("button",{type:"button",disabled:b,onClick:()=>{w()},className:"px-3.5 py-2 rounded-lg text-xs font-semibold bg-brand-600 hover:bg-brand-500 text-white disabled:opacity-60",children:s(b?"deepLink.installing":"deepLink.install")}),e.jsx("button",{type:"button",onClick:o,className:"px-2.5 py-2 rounded-lg text-xs text-fg-tertiary hover:text-fg-secondary hover:bg-surface-elevated/60",children:s("deepLink.dismiss")})]})]})}function G({authUser:n}){const{t:o}=E(["store","common"]),[f]=d.useState(T),[s,a]=d.useState(f.tab),p=M(),g=A(L.STORE),l=D(),b=l?.keyboardPane??"content",k=C(v,s,a),[u,m]=d.useState(f.installId),w=d.useRef(s);w.current=s,d.useEffect(()=>{if(p||!g)return;const t=r=>{if(l?.keyboardPane==="l0"||r.metaKey||r.ctrlKey||r.altKey||R(r.target))return;const i=r.key.length===1?r.key.toLowerCase():r.key;if(i==="h"||i==="ArrowLeft"){r.preventDefault(),l?.setL0FocusPageId(L.STORE),l?.setLeftCollapsed(!1),l?.setKeyboardPane("l0");return}if(i==="l"||i==="ArrowRight"){r.preventDefault(),l?.keyboardPane!=="l1"&&l?.setKeyboardPane("l1");return}const h=i==="j"||i==="ArrowDown"?1:i==="k"||i==="ArrowUp"?-1:0;if(!h)return;r.preventDefault(),l?.setKeyboardPane("l1");const y=v.findIndex(_=>_.id===w.current),S=v[Math.max(0,Math.min(v.length-1,y+h))];a(S.id),requestAnimationFrame(()=>{document.querySelector(`[data-store-tab-id="${S.id}"]`)?.scrollIntoView({block:"nearest"})})};return document.addEventListener("keydown",t,!0),()=>document.removeEventListener("keydown",t,!0)},[p,g,l]),d.useEffect(()=>{const t=T();t.installId&&(m(t.installId),I(t.tab)&&a(t.tab),N())},[]),d.useEffect(()=>{const t=r=>{const i=r.detail;if(i.page==="store"||i.page==="explore"){const h=i.params?.storeTab??localStorage.getItem("markus_nav_storeTab"),y=i.params?.installItem??localStorage.getItem("markus_nav_installItem");h&&I(h)&&a(h),y&&m(y),(h||y)&&N()}};return window.addEventListener("markus:navigate",t),()=>window.removeEventListener("markus:navigate",t)},[]);const x=(t,r)=>{const i=P[t]??"agents";r&&m(r),a(i)},c=()=>m(null),j=()=>e.jsxs(e.Fragment,{children:[u&&e.jsx(V,{itemId:u,onDismiss:c,onInstalled:c}),s==="discover"&&e.jsx(z,{onOpenType:x}),s==="agents"&&e.jsx(H,{authUser:n,highlightItemId:u,onHighlightDone:c}),s==="teams"&&e.jsx(K,{highlightItemId:u,onHighlightDone:c}),s==="skills"&&e.jsx($,{highlightItemId:u,onHighlightDone:c}),s==="installed"&&e.jsx(O,{})]});return p?e.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",onTouchStart:k.onTouchStart,onTouchEnd:k.onTouchEnd,children:[e.jsx("div",{className:"flex shrink-0 overflow-x-auto scrollbar-hide",children:v.map(t=>e.jsx("button",{onClick:()=>a(t.id),className:`flex-1 min-w-fit px-4 py-3 text-sm font-medium text-center whitespace-nowrap transition-colors border-b-2 ${s===t.id?"border-brand-500 text-brand-500":"border-transparent text-fg-tertiary hover:text-fg-secondary"}`,children:o(`tabs.${t.id}`)},t.id))}),e.jsx("div",{className:"flex-1 overflow-hidden flex flex-col",children:j()})]}):e.jsxs("div",{className:"flex-1 overflow-hidden flex flex-row",children:[e.jsxs("nav",{"data-keyboard-pane":"l1",className:`w-36 shrink-0 bg-surface-secondary rounded-xl m-1 mr-0 flex flex-col py-4 px-2 gap-1 ${b==="l1"?"ring-1 ring-inset ring-brand-500/30":""}`,children:[e.jsx("div",{className:"px-3 pb-3 mb-1",children:e.jsx("h2",{className:"text-xs font-semibold text-fg-tertiary uppercase tracking-wider",children:o("title")})}),v.map(t=>e.jsxs("button",{"data-store-tab-id":t.id,onClick:()=>a(t.id),className:`flex items-center gap-2.5 px-3 py-2.5 rounded-lg text-sm font-medium transition-all ${s===t.id?b==="l1"?"bg-brand-500/25 text-brand-400 ring-1 ring-inset ring-brand-500/40":"bg-brand-600/15 text-brand-400 shadow-sm shadow-brand-500/10":"text-fg-tertiary hover:text-fg-secondary hover:bg-surface-elevated/50"}`,children:[e.jsx("svg",{className:"w-4 h-4 shrink-0",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:e.jsx("path",{d:F[t.id]})}),o(`tabs.${t.id}`)]},t.id))]}),e.jsx("div",{className:"flex-1 overflow-hidden flex flex-col",children:j()})]})}export{G as StorePage};
1
+ import{u as E,r as d,a as M,b as A,c as D,d as C,j as e,P as L,i as R,S as z,T as H,e as K,f as $,I as O,h as q,g as B}from"./index-Cfoh0Mcj.js";const v=[{id:"discover"},{id:"agents"},{id:"teams"},{id:"skills"},{id:"installed"}],P={agent:"agents",team:"teams",skill:"skills",connector:"skills"},F={discover:"M12 2l2.4 6.9L21 9l-5.4 4 2 7-5.6-4.1L6.4 20l2-7L3 9l6.6-.1z",agents:"M12 2a5 5 0 015 5v1a5 5 0 01-10 0V7a5 5 0 015-5zM4 21a8 8 0 0116 0z",teams:"M16 11a4 4 0 10-4-4 4 4 0 004 4zM8 13a3 3 0 10-3-3 3 3 0 003 3zm0 2c-2.7 0-5 1.3-5 3v2h7v-2c0-.7.2-1.3.6-1.9A7.6 7.6 0 008 15zm8 0c-3 0-6 1.5-6 3.5V21h12v-2.5c0-2-3-3.5-6-3.5z",skills:"M13 2L3 14h7l-1 8 10-12h-7z",installed:"M12 3v12m0 0l-4-4m4 4l4-4M5 21h14"};function I(n){return n==="discover"||n==="agents"||n==="teams"||n==="skills"||n==="installed"}function T(){const n=localStorage.getItem("markus_nav_installItem"),o=localStorage.getItem("markus_nav_storeTab");if(n)return{tab:I(o)?o:"agents",installId:n};const f=new URLSearchParams(window.location.search),s=f.get("install");if(s){const a=f.get("type");return{tab:a&&P[a]||"agents",installId:s}}return{tab:I(o)?o:"discover",installId:null}}function N(){localStorage.removeItem("markus_nav_installItem"),localStorage.removeItem("markus_nav_storeTab");const n=new URLSearchParams(window.location.search);if(n.has("install")||n.has("type")){n.delete("install"),n.delete("type");const o=n.toString();window.history.replaceState(null,"",window.location.pathname+(o?`?${o}`:"")+window.location.hash)}}function V({itemId:n,onDismiss:o,onInstalled:f}){const{t:s}=E(["store","common"]),[a,p]=d.useState(null),[g,l]=d.useState("loading"),[b,k]=d.useState(!1),[u,m]=d.useState("");d.useEffect(()=>{let x=!1;return l("loading"),p(null),m(""),q.getItem(n).then(({item:c})=>{x||(c?(p(c),l("ready")):l("missing"))}).catch(()=>{x||l("missing")}),()=>{x=!0}},[n]);const w=async()=>{if(!(!a||b)){k(!0),m("");try{await B(a),m(s("deepLink.installed")),f()}catch(x){const c=x instanceof Error?x.message:"";m(c.includes("402")||c.includes("Purchase")?s("deepLink.purchaseRequired"):s("deepLink.failed"))}finally{k(!1)}}};return e.jsxs("div",{className:"shrink-0 mx-3 mt-3 mb-1 rounded-xl border border-brand-500/30 bg-brand-600/10 px-4 py-3 flex flex-col sm:flex-row sm:items-center gap-3",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-wider text-brand-400/90 mb-0.5",children:s("deepLink.fromHub")}),g==="loading"&&e.jsx("p",{className:"text-sm text-fg-secondary",children:s("deepLink.loading")}),g==="missing"&&e.jsx("p",{className:"text-sm text-rose-300",children:s("deepLink.missing")}),g==="ready"&&a&&e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-sm font-semibold text-fg-primary truncate",children:a.name}),a.description&&e.jsx("p",{className:"text-xs text-fg-tertiary line-clamp-2 mt-0.5",children:a.description}),u&&e.jsx("p",{className:"text-xs mt-1 text-brand-300",children:u})]})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[g==="ready"&&a&&e.jsx("button",{type:"button",disabled:b,onClick:()=>{w()},className:"px-3.5 py-2 rounded-lg text-xs font-semibold bg-brand-600 hover:bg-brand-500 text-white disabled:opacity-60",children:s(b?"deepLink.installing":"deepLink.install")}),e.jsx("button",{type:"button",onClick:o,className:"px-2.5 py-2 rounded-lg text-xs text-fg-tertiary hover:text-fg-secondary hover:bg-surface-elevated/60",children:s("deepLink.dismiss")})]})]})}function G({authUser:n}){const{t:o}=E(["store","common"]),[f]=d.useState(T),[s,a]=d.useState(f.tab),p=M(),g=A(L.STORE),l=D(),b=l?.keyboardPane??"content",k=C(v,s,a),[u,m]=d.useState(f.installId),w=d.useRef(s);w.current=s,d.useEffect(()=>{if(p||!g)return;const t=r=>{if(l?.keyboardPane==="l0"||r.metaKey||r.ctrlKey||r.altKey||R(r.target))return;const i=r.key.length===1?r.key.toLowerCase():r.key;if(i==="h"||i==="ArrowLeft"){r.preventDefault(),l?.setL0FocusPageId(L.STORE),l?.setLeftCollapsed(!1),l?.setKeyboardPane("l0");return}if(i==="l"||i==="ArrowRight"){r.preventDefault(),l?.keyboardPane!=="l1"&&l?.setKeyboardPane("l1");return}const h=i==="j"||i==="ArrowDown"?1:i==="k"||i==="ArrowUp"?-1:0;if(!h)return;r.preventDefault(),l?.setKeyboardPane("l1");const y=v.findIndex(_=>_.id===w.current),S=v[Math.max(0,Math.min(v.length-1,y+h))];a(S.id),requestAnimationFrame(()=>{document.querySelector(`[data-store-tab-id="${S.id}"]`)?.scrollIntoView({block:"nearest"})})};return document.addEventListener("keydown",t,!0),()=>document.removeEventListener("keydown",t,!0)},[p,g,l]),d.useEffect(()=>{const t=T();t.installId&&(m(t.installId),I(t.tab)&&a(t.tab),N())},[]),d.useEffect(()=>{const t=r=>{const i=r.detail;if(i.page==="store"||i.page==="explore"){const h=i.params?.storeTab??localStorage.getItem("markus_nav_storeTab"),y=i.params?.installItem??localStorage.getItem("markus_nav_installItem");h&&I(h)&&a(h),y&&m(y),(h||y)&&N()}};return window.addEventListener("markus:navigate",t),()=>window.removeEventListener("markus:navigate",t)},[]);const x=(t,r)=>{const i=P[t]??"agents";r&&m(r),a(i)},c=()=>m(null),j=()=>e.jsxs(e.Fragment,{children:[u&&e.jsx(V,{itemId:u,onDismiss:c,onInstalled:c}),s==="discover"&&e.jsx(z,{onOpenType:x}),s==="agents"&&e.jsx(H,{authUser:n,highlightItemId:u,onHighlightDone:c}),s==="teams"&&e.jsx(K,{highlightItemId:u,onHighlightDone:c}),s==="skills"&&e.jsx($,{highlightItemId:u,onHighlightDone:c}),s==="installed"&&e.jsx(O,{})]});return p?e.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",onTouchStart:k.onTouchStart,onTouchEnd:k.onTouchEnd,children:[e.jsx("div",{className:"flex shrink-0 overflow-x-auto scrollbar-hide",children:v.map(t=>e.jsx("button",{onClick:()=>a(t.id),className:`flex-1 min-w-fit px-4 py-3 text-sm font-medium text-center whitespace-nowrap transition-colors border-b-2 ${s===t.id?"border-brand-500 text-brand-500":"border-transparent text-fg-tertiary hover:text-fg-secondary"}`,children:o(`tabs.${t.id}`)},t.id))}),e.jsx("div",{className:"flex-1 overflow-hidden flex flex-col",children:j()})]}):e.jsxs("div",{className:"flex-1 overflow-hidden flex flex-row",children:[e.jsxs("nav",{"data-keyboard-pane":"l1",className:`w-36 shrink-0 bg-surface-secondary rounded-xl m-1 mr-0 flex flex-col py-4 px-2 gap-1 ${b==="l1"?"ring-1 ring-inset ring-brand-500/30":""}`,children:[e.jsx("div",{className:"px-3 pb-3 mb-1",children:e.jsx("h2",{className:"text-xs font-semibold text-fg-tertiary uppercase tracking-wider",children:o("title")})}),v.map(t=>e.jsxs("button",{"data-store-tab-id":t.id,onClick:()=>a(t.id),className:`flex items-center gap-2.5 px-3 py-2.5 rounded-lg text-sm font-medium transition-all ${s===t.id?b==="l1"?"bg-brand-500/25 text-brand-400 ring-1 ring-inset ring-brand-500/40":"bg-brand-600/15 text-brand-400 shadow-sm shadow-brand-500/10":"text-fg-tertiary hover:text-fg-secondary hover:bg-surface-elevated/50"}`,children:[e.jsx("svg",{className:"w-4 h-4 shrink-0",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:e.jsx("path",{d:F[t.id]})}),o(`tabs.${t.id}`)]},t.id))]}),e.jsx("div",{className:"flex-1 overflow-hidden flex flex-col",children:j()})]})}export{G as StorePage};