@oneworks/client 0.1.0-alpha.0 → 0.1.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/ActionSearchToolbar-8q-bk3mu.js +1 -0
- package/dist/assets/ActionSearchToolbar-CMBns0Zm.css +1 -0
- package/dist/assets/AgentRoomRoute-DfSI_dFH.js +1 -0
- package/dist/assets/AgentRoomSessionRoute-DH9PdjZm.js +3 -0
- package/dist/assets/ArchiveRoute-E9-htB4H.js +1 -0
- package/dist/assets/{AuthenticatedApp-BTs4l2pB.js → AuthenticatedApp-CgBrvMuc.js} +236 -224
- package/dist/assets/AuthenticatedApp-scWyvbOf.css +1 -0
- package/dist/assets/AutomationRoute-Bw2xw5bx.js +1 -0
- package/dist/assets/BenchmarkRoute-3VS17jHr.js +21 -0
- package/dist/assets/ChatRoute-CBQ3j4Je.js +2 -0
- package/dist/assets/Collapse-B-oCiEx4.js +10 -0
- package/dist/assets/{ComposerLanding-Cl6zfbOm.js → ComposerLanding-SZn_zRGX.js} +4 -4
- package/dist/assets/ConfigEditors-BuDavOAj.css +1 -0
- package/dist/assets/ConfigRoute-Dv-7BRGG.js +28 -0
- package/dist/assets/ConfigRoute-TW2qRRNP.css +1 -0
- package/dist/assets/InteractionStructureRoute-FDl9jRvT.js +1 -0
- package/dist/assets/KnowledgeRoute-C5em_VSL.js +1 -0
- package/dist/assets/LauncherApp-olYmK_zO.js +2 -0
- package/dist/assets/LauncherRoute-NsK8KCzb.css +1 -0
- package/dist/assets/LauncherRoute-Qt8dQkIk.js +2 -0
- package/dist/assets/MobileAwareSelect-BmK6WApn.js +37 -0
- package/dist/assets/MobileAwareSelect-BySpAJpa.css +1 -0
- package/dist/assets/{ModuleManagementRoute-DQACRan1.js → ModuleManagementRoute-B1I_8JKc.js} +3 -3
- package/dist/assets/NotFoundRoute-Bj6_YY3I.js +1 -0
- package/dist/assets/PluginStoreRoute-B847PAZ5.js +1 -0
- package/dist/assets/PluginStoreRoute-Cfalv335.css +1 -0
- package/dist/assets/RouteContainerPanelTabs-BnIptVwq.js +11 -0
- package/dist/assets/RouteContainerPanelTabs-DAjUmk7i.css +1 -0
- package/dist/assets/SchemaObjectEditor-B9fPfDyT.js +1 -0
- package/dist/assets/StandaloneMobileDebugRoute-BR4w_LeM.js +1 -0
- package/dist/assets/StandaloneMobileDebugRoute-DuOLjUb9.css +1 -0
- package/dist/assets/WorkspaceApp-BNmtIdn4.js +9 -0
- package/dist/assets/agent-room-session-paths-CYMSFD9m.css +32 -0
- package/dist/assets/agent-room-session-paths-Dca8S6NN.js +537 -0
- package/dist/assets/{arc-BXsvCKst.js → arc-JBUpUV6M.js} +1 -1
- package/dist/assets/azure-C6wcxVWu.ico +0 -0
- package/dist/assets/{blockDiagram-c4efeb88-hc-xNCrG.js → blockDiagram-c4efeb88-DKhNwgEQ.js} +2 -2
- package/dist/assets/{c4Diagram-c83219d4-DVHTOuVr.js → c4Diagram-c83219d4-CWODEGms.js} +2 -2
- package/dist/assets/channel-BsuHYNQO.js +1 -0
- package/dist/assets/classDiagram-beda092f-DlghsOqF.js +2 -0
- package/dist/assets/classDiagram-v2-2358418a-CrSR8gWz.js +2 -0
- package/dist/assets/client-build-info-bcijLdfD.js +1 -0
- package/dist/assets/clone-BKV6leIk.js +1 -0
- package/dist/assets/{createText-1719965b-x3Mhf0Jh.js → createText-1719965b-CLlPr73k.js} +1 -1
- package/dist/assets/cssMode-Bt_74RVV.js +1 -0
- package/dist/assets/customParseFormat-DwjB960X.js +1 -0
- package/dist/assets/dockPanelConstants-4XXOUD0A.css +1 -0
- package/dist/assets/dockPanelConstants-BWuu_DJp.js +8 -0
- package/dist/assets/{edges-96097737-COVuSxRY.js → edges-96097737-L_gy1fky.js} +1 -1
- package/dist/assets/{erDiagram-0228fc6a-WcgqCWce.js → erDiagram-0228fc6a-X1QMD6me.js} +2 -2
- package/dist/assets/{flowDb-c6c81e3f-nYly38YN.js → flowDb-c6c81e3f-DNdWK0Po.js} +1 -1
- package/dist/assets/{flowDiagram-50d868cf-DLYALlBY.js → flowDiagram-50d868cf-C2khStgw.js} +2 -2
- package/dist/assets/flowDiagram-v2-4f6560a1-DW5hyUju.js +1 -0
- package/dist/assets/{flowchart-elk-definition-6af322e1-Da8rP8k4.js → flowchart-elk-definition-6af322e1-C89sxd2D.js} +2 -2
- package/dist/assets/{freemarker2-OWISI6Bb.js → freemarker2-DZ1XIuHj.js} +2 -2
- package/dist/assets/ganttDiagram-a2739b55-Ba3rPNKd.js +257 -0
- package/dist/assets/gemini-B9inYaVW.png +0 -0
- package/dist/assets/{gitGraphDiagram-82fe8481-DCk8Jny9.js → gitGraphDiagram-82fe8481-DTEFHHtN.js} +2 -2
- package/dist/assets/{graph-DvFQr_wY.js → graph-BPujwFoF.js} +1 -1
- package/dist/assets/handlebars-lOgsnnQw.js +1 -0
- package/dist/assets/html-DLHadu9L.js +1 -0
- package/dist/assets/htmlMode-VeiQ-IsQ.js +1 -0
- package/dist/assets/{index-5325376f-CRF6GGjL.js → index-5325376f-Cx2RM6pk.js} +1 -1
- package/dist/assets/{index-BnZLa3J3.js → index-CBFCjoHv.js} +2 -2
- package/dist/assets/index-CJEVYkL9.js +1 -0
- package/dist/assets/index-CWmEuVWV.js +36 -0
- package/dist/assets/index-Cp4GfHnF.js +727 -0
- package/dist/assets/index-D4eelxQF.js +13 -0
- package/dist/assets/index-DBUG8CzV.js +3 -0
- package/dist/assets/index-jfuA2A4w.css +1 -0
- package/dist/assets/index-sFqkb8xv.js +13 -0
- package/dist/assets/{infoDiagram-8eee0895-dVa2Kh9_.js → infoDiagram-8eee0895-Bj9hWnDg.js} +2 -2
- package/dist/assets/interaction-panel-mobile-debug-pages-1Gdivksn.js +113 -0
- package/dist/assets/interaction-panel-mobile-debug-pages-8AAd4Csf.css +1 -0
- package/dist/assets/javascript-CXJw-bvU.js +1 -0
- package/dist/assets/{journeyDiagram-c64418c1-BJCT1TJ7.js → journeyDiagram-c64418c1-BXAycrrn.js} +2 -2
- package/dist/assets/{jsonMode-RsjNGxUQ.js → jsonMode-DmUNJfpX.js} +4 -4
- package/dist/assets/{layout-BMZRkCUf.js → layout-Bp8GVMnq.js} +1 -1
- package/dist/assets/{line-C99msl9T.js → line-olpPNgnh.js} +1 -1
- package/dist/assets/{linear-CJHB38BG.js → linear-flh_7ux_.js} +1 -1
- package/dist/assets/liquid-BiVpRgBP.js +1 -0
- package/dist/assets/{lspLanguageFeatures-D8zjArb3.js → lspLanguageFeatures-olWF83eX.js} +1 -1
- package/dist/assets/mdx-B5dr7YB-.js +1 -0
- package/dist/assets/{mermaid.core-DWzpZH_g.js → mermaid.core-NVIiXnRA.js} +4 -4
- package/dist/assets/micu-dUcmmgZZ.png +0 -0
- package/dist/assets/{mindmap-definition-8da855dc-DulNL_Ks.js → mindmap-definition-8da855dc-BOCh8K8K.js} +2 -2
- package/dist/assets/minimax-B5WRVrUt.png +0 -0
- package/dist/assets/openai-ABb0YGGa.svg +71 -0
- package/dist/assets/openrouter-CsJ_bD5Q.ico +0 -0
- package/dist/assets/{pieDiagram-a8764435-CHfubQBm.js → pieDiagram-a8764435-CCitKBQK.js} +3 -3
- package/dist/assets/project-file-tree-icons-DXkdVC0r.css +1 -0
- package/dist/assets/project-file-tree-icons-DqqhgvoI.js +2 -0
- package/dist/assets/python-BkEOPIle.js +1 -0
- package/dist/assets/{quadrantDiagram-1e28029f-CFHca9nu.js → quadrantDiagram-1e28029f-C_FvcHzZ.js} +2 -2
- package/dist/assets/qwen-Cla2cGrM.svg +107 -0
- package/dist/assets/razor-BCMQgdis.js +1 -0
- package/dist/assets/requesty-DAzbbw8F.ico +0 -0
- package/dist/assets/{requirementDiagram-08caed73-ClrFG92W.js → requirementDiagram-08caed73-B001ugYd.js} +2 -2
- package/dist/assets/route-plugin-chrome-B-Goj3vG.js +1 -0
- package/dist/assets/sankeyDiagram-a04cb91d-BnkC9YW5.js +8 -0
- package/dist/assets/{sequenceDiagram-c5b8d532-ZoeuLa-n.js → sequenceDiagram-c5b8d532-BGiFCs5z.js} +2 -2
- package/dist/assets/shortcutUtils-20iqPDwh.js +27 -0
- package/dist/assets/stateDiagram-1ecb1508-Uk4XxTkP.js +1 -0
- package/dist/assets/stateDiagram-v2-c2b004d7-Db6Ouywh.js +1 -0
- package/dist/assets/{styles-b4e223ce-0VFG2Z9W.js → styles-b4e223ce-CfG45yIm.js} +1 -1
- package/dist/assets/{styles-ca3715f6-DaJIsB-N.js → styles-ca3715f6-BGGbMvKc.js} +1 -1
- package/dist/assets/{styles-d45a18b0-DT8DH24o.js → styles-d45a18b0-mHteeqS2.js} +1 -1
- package/dist/assets/{svgDrawCommon-b86b1483-DxTZXiLW.js → svgDrawCommon-b86b1483-BAMR2PsF.js} +1 -1
- package/dist/assets/{timeline-definition-faaaa080-lu3ppiNq.js → timeline-definition-faaaa080-DLBoPuJD.js} +2 -2
- package/dist/assets/{tsMode-B6pOKC1l.js → tsMode-BTzZ8Zos.js} +2 -2
- package/dist/assets/typescript-_rLmAd51.js +1 -0
- package/dist/assets/use-app-preferences-gyulV-hA.js +1 -0
- package/dist/assets/use-chat-session-actions-DDZ5KCua.js +2 -0
- package/dist/assets/{vendor-react-BNJ5yonH.js → vendor-react-CnooHTJc.js} +1 -1
- package/dist/assets/vendor-state-BYwEPTaO.js +1 -0
- package/dist/assets/worker-BZxxbL_z.js +1 -0
- package/dist/assets/workspace-file-openers-BwZ5cSeq.js +1 -0
- package/dist/assets/workspace-file-openers-fM4AQXug.css +1 -0
- package/dist/assets/xml-BAU8TJ-c.js +1 -0
- package/dist/assets/{xychartDiagram-f5964ef8-DvmrNK0s.js → xychartDiagram-f5964ef8-CNfcxTsi.js} +2 -2
- package/dist/assets/yaml-_cphTIn0.js +1 -0
- package/dist/assets/yunwu-C0h7koCA.png +0 -0
- package/dist/assets/zhipu-CWmkm5qz.png +0 -0
- package/dist/index.html +4 -4
- package/dist/sw.js +5 -3
- package/package.json +20 -15
- package/dist/assets/AgentRoomRoute-rNmmPMvh.js +0 -1
- package/dist/assets/AgentRoomSessionRoute-Dg8yQRY_.js +0 -1
- package/dist/assets/ArchiveRoute-BWE_JVjl.js +0 -1
- package/dist/assets/AuthenticatedApp-Bop-GglJ.css +0 -1
- package/dist/assets/AutomationRoute-CoJ8YGK2.js +0 -1
- package/dist/assets/BenchmarkRoute-BcRZ1AFC.js +0 -21
- package/dist/assets/ChatRoute-DBN4uo7j.js +0 -1
- package/dist/assets/Collapse-DDrFhfKr.js +0 -8
- package/dist/assets/ConfigEditors-jcXiTWRg.css +0 -1
- package/dist/assets/ConfigRoute-D5zxs-kv.css +0 -1
- package/dist/assets/ConfigRoute-z5Dj1ihn.js +0 -2
- package/dist/assets/ConfigSectionPanel-DHIwutHm.js +0 -13
- package/dist/assets/DockPanel-DuxVeJzf.js +0 -11
- package/dist/assets/DockPanel-HEMeJ1MR.css +0 -1
- package/dist/assets/InteractionStructureRoute-B8yJdycA.js +0 -1
- package/dist/assets/KnowledgeRoute-BPYnBocT.js +0 -1
- package/dist/assets/LauncherApp-BqKOigOK.js +0 -2
- package/dist/assets/LauncherRoute-C1g-gjbs.js +0 -2
- package/dist/assets/LauncherRoute-DtjtKtXc.css +0 -1
- package/dist/assets/PluginStoreRoute-Bny2x-oC.css +0 -1
- package/dist/assets/PluginStoreRoute-CGIBez_4.js +0 -3
- package/dist/assets/SchemaObjectEditor-BdzgIkYh.js +0 -1
- package/dist/assets/WorkspaceApp-DGL3CHCp.js +0 -46
- package/dist/assets/agent-room-session-paths-Bl0JdX79.js +0 -153
- package/dist/assets/agent-room-session-paths-CCE5rS0K.css +0 -32
- package/dist/assets/channel-X7k9544o.js +0 -1
- package/dist/assets/classDiagram-beda092f-C--_J0De.js +0 -2
- package/dist/assets/classDiagram-v2-2358418a-VLoB_o-4.js +0 -2
- package/dist/assets/client-build-info-CUyezPn4.js +0 -37
- package/dist/assets/client-build-info-CgBKDSmG.css +0 -1
- package/dist/assets/clone-BsR4Dtrm.js +0 -1
- package/dist/assets/copy-OJ_6Pvs2.js +0 -28
- package/dist/assets/cssMode-Dg95dCSS.js +0 -1
- package/dist/assets/flowDiagram-v2-4f6560a1-DZXqc8d3.js +0 -1
- package/dist/assets/ganttDiagram-a2739b55-SFoaaNUl.js +0 -257
- package/dist/assets/handlebars-DvhbIeVz.js +0 -1
- package/dist/assets/html-B6ANaoGC.js +0 -1
- package/dist/assets/htmlMode-CA_KA1J8.js +0 -1
- package/dist/assets/index-BfLbHhFR.js +0 -13
- package/dist/assets/index-C9FQLbWu.js +0 -1
- package/dist/assets/index-DA1kZA8X.css +0 -1
- package/dist/assets/index-Dn-Bbs_z.js +0 -705
- package/dist/assets/javascript-qaeO24NX.js +0 -1
- package/dist/assets/liquid-yYJuHMAu.js +0 -1
- package/dist/assets/mdx-CrAkCLhE.js +0 -1
- package/dist/assets/python-h0Aqhxqi.js +0 -1
- package/dist/assets/razor-DalkOWO-.js +0 -1
- package/dist/assets/sankeyDiagram-a04cb91d-C9DgEVjM.js +0 -8
- package/dist/assets/stateDiagram-1ecb1508-DDRxhJDf.js +0 -1
- package/dist/assets/stateDiagram-v2-c2b004d7-CIob4OCF.js +0 -1
- package/dist/assets/typescript-Bn-lx_lA.js +0 -1
- package/dist/assets/use-app-preferences-B4K999VJ.js +0 -1
- package/dist/assets/use-chat-session-actions-5N-NQ9my.js +0 -2
- package/dist/assets/use-project-theme-preview-sources-5CPt1X2N.js +0 -1
- package/dist/assets/vendor-state-CBVXPiKY.js +0 -1
- package/dist/assets/workspace-file-openers-DAuX65xw.js +0 -1
- package/dist/assets/workspace-file-openers-erSFu-UO.css +0 -1
- package/dist/assets/xml-C1SO5DSd.js +0 -1
- package/dist/assets/yaml-DihjE03_.js +0 -1
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import{j as e,r as w}from"./vendor-react-CnooHTJc.js";import{m as Si,o as ts,p as ls,S as as,C as rs}from"./workspace-file-openers-BwZ5cSeq.js";import{e as Vn,u as ki}from"./vendor-state-BYwEPTaO.js";import{bs as Ci,bt as ii,P as Fn,bu as qn,H as cs,I as Pi,L as En,T as ds}from"./AuthenticatedApp-CgBrvMuc.js";import{ax as Ge,ay as Re,aI as pn,B as L,aD as cn,u as ms}from"./index-Cp4GfHnF.js";import{D as us,n as fs,r as ps,S as Ai}from"./shortcutUtils-20iqPDwh.js";import{E as dn,T as ne,M as De}from"./MobileAwareSelect-BmK6WApn.js";import{i as gs,b as nn,d as kn,F as le,e as ae,f as Mi,g as Pe,S as Cn,s as Fe,h as Ii,j as vs,k as Dn,C as mn,r as Ti,t as $i}from"./SchemaObjectEditor-B9fPfDyT.js";import{S as Vi,M as Fi}from"./WorkspaceApp-BNmtIdn4.js";import{I as re}from"./index-CWmEuVWV.js";import{k as Bn,l as Xn,m as Di,h as Bi,e as Ei,o as Oi,r as Ki,S as Ye}from"./project-file-tree-icons-DqqhgvoI.js";import{T as Pn}from"./index-sFqkb8xv.js";import{T as si}from"./index-DBUG8CzV.js";import{C as On,A as oi}from"./Collapse-B-oCiEx4.js";import{S as hs}from"./index-D4eelxQF.js";const We=n=>({...(n==null?void 0:n.service)!=null?{service:n.service}:{},...(n==null?void 0:n.source)!=null?{source:n.source}:{}}),_s=(n,i)=>Ge(`/api/model-services/${encodeURIComponent(n)}/models/list`,{method:"POST",headers:Re,body:JSON.stringify(We(i))},"[api] list model service models failed:"),Li=(n,i)=>Ge(`/api/model-services/${encodeURIComponent(n)}/balance`,{method:"POST",headers:Re,body:JSON.stringify(We(i))},"[api] get model service balance failed:"),xs=(n,i)=>Ge(`/api/model-services/${encodeURIComponent(n)}/status`,{method:"POST",headers:Re,body:JSON.stringify(We(i))},"[api] get model service status failed:"),ys=(n,i)=>Ge(`/api/model-services/${encodeURIComponent(n)}/secrets`,{method:"POST",headers:Re,body:JSON.stringify(We(i))},"[api] create model service secret failed:"),js=(n,i)=>Ge(`/api/model-services/${encodeURIComponent(n)}/management`,{method:"POST",headers:Re,body:JSON.stringify(We(i))},"[api] get model service management snapshot failed:"),bs=(n,i,s)=>Ge(`/api/model-services/${encodeURIComponent(n)}/management/tokens`,{method:"POST",headers:Re,body:JSON.stringify({...We(s),input:i})},"[api] create model service management token failed:"),ws=(n,i,s,t)=>Ge(`/api/model-services/${encodeURIComponent(n)}/management/tokens/${encodeURIComponent(i)}`,{method:"PUT",headers:Re,body:JSON.stringify({...We(t),input:s})},"[api] update model service management token failed:"),Ns=(n,i,s)=>Ge(`/api/model-services/${encodeURIComponent(n)}/management/tokens/${encodeURIComponent(i)}`,{method:"DELETE",headers:Re,body:JSON.stringify(We(s))},"[api] delete model service management token failed:"),ti=(n,i,s)=>Ge(`/api/model-services/${encodeURIComponent(n)}/management/tokens/${encodeURIComponent(i)}/profile`,{method:"POST",headers:Re,body:JSON.stringify(We(s))},"[api] get model service management token profile failed:"),Nn=({value:n,sectionKey:i,path:s=[],t})=>gs(n)?e.jsx(dn,{description:t("common.noData"),image:null}):Array.isArray(n)?n.some(c=>c!=null&&typeof c=="object")?e.jsx("span",{className:"config-view__pill",children:t("config.editor.complexValue")}):e.jsx("div",{className:"config-view__display-pill",children:n.map((c,m)=>e.jsx("span",{className:"config-view__pill",children:String(c)},`${m}-${String(c)}`))}):n!=null&&typeof n=="object"?e.jsx("div",{className:"config-view__field-list",children:Object.entries(n).map(([o,c])=>{const m=nn(t,i,[...s,o],o),u=kn(t,i,[...s,o]);return e.jsx(le,{title:m,description:u,icon:ae(Mi(c)),children:e.jsx(Nn,{value:c,sectionKey:i,path:[...s,o],t})},o)})}):e.jsx("span",{className:"config-view__pill",children:String(n)}),ei=n=>n!=null&&typeof n=="object"&&!Array.isArray(n),zi={add:"person_add",refresh:"refresh",remove:"delete"},Kn={ready:"check_circle",missing:"warning",error:"error"},Ui=n=>{const i=Pe(n,["accounts"]);return ei(i)?i:{}},Ss=(n,i)=>{const s=Ui(n)[i];return ei(s)?s:{}},ks=(n,i,s)=>Fe(n,["accounts",i],s),Cs=(n,i)=>{switch(n){case"missing":return{label:i("config.accounts.status.missing"),color:"default",icon:Kn.missing};case"error":return{label:i("config.accounts.status.error"),color:"error",icon:Kn.error};case"ready":default:return{label:i("config.accounts.status.ready"),color:"success",icon:Kn.ready}}},Gn=(n,i)=>i(`config.accounts.actions.${n.key}.label`,{defaultValue:n.label}),qi=(n,i)=>i(`config.accounts.actions.${n.key}.description`,{defaultValue:n.description??n.label}),An=n=>(n==null?void 0:n.trim().toLowerCase())??"",Ps=n=>{if(n==null)return;const i=n.trim();if(!i.endsWith("%"))return;const s=Number(i.slice(0,-1));if(Number.isFinite(s))return Math.min(100,Math.max(0,s))},As=n=>n>=85?"var(--error-color, #ff4d4f)":n>=60?"var(--warning-color, #faad14)":"var(--success-color, #52c41a)",Ms=(n,i)=>{if(n.isDefault===!0&&i.isDefault!==!0)return-1;if(i.isDefault===!0&&n.isDefault!==!0)return 1;if(n.status!==i.status){if(n.status==="ready")return-1;if(i.status==="ready")return 1}const s=An(n.title).localeCompare(An(i.title));return s!==0?s:n.key.localeCompare(i.key)},Mn=(n,i)=>{const s=i==null?void 0:i.trim();return s==null||s===""||s===n?n:e.jsxs("div",{className:"adapter-account-manager__tooltip",children:[e.jsx("div",{className:"adapter-account-manager__tooltip-title",children:n}),e.jsx("div",{className:"adapter-account-manager__tooltip-description",children:s})]})},li=({color:n,icon:i,label:s,description:t})=>{const o=n==="success"?{color:"var(--success-color, #52c41a)"}:n==="error"?{color:"var(--error-color, #ff4d4f)"}:void 0;return e.jsx(ne,{title:Mn(s,t),children:e.jsx("span",{className:"adapter-account-manager__icon-tag",style:o,"aria-label":s,children:e.jsx("span",{className:"material-symbols-rounded","aria-hidden":"true",children:i})})})},Is=({actions:n,loadingAction:i,onRunAction:s,t})=>n.length===0?null:e.jsx("div",{className:"adapter-account-manager__actions",children:n.map(o=>{const c=Gn(o,t),m=qi(o,t),u=zi[o.key];return o.key==="remove"?e.jsx(Fn,{title:t("config.accounts.deleteConfirmTitle",{defaultValue:"Delete the stored snapshot for {{account}}?",account:c}),okText:t("common.confirm"),cancelText:t("common.cancel"),onConfirm:async()=>{await s(o)},children:e.jsx(ne,{title:Mn(c,m),children:e.jsx(L,{type:"default",size:"small",danger:!0,loading:i===o.key,"aria-label":c,className:"adapter-account-manager__icon-button adapter-account-manager__header-action",icon:e.jsx("span",{className:"material-symbols-rounded",children:u})})})},o.key):e.jsx(ne,{title:Mn(c,m),children:e.jsx(L,{type:"default",size:"small",loading:i===o.key,"aria-label":c,className:"adapter-account-manager__icon-button adapter-account-manager__header-action",icon:e.jsx("span",{className:"material-symbols-rounded",children:u}),onClick:async()=>{await s(o)}})},o.key)})}),Gi=(n,i,s)=>{const t=new Map;return Object.entries(n).forEach(([o,c])=>{const m=ei(c)?c:{},u=typeof m.title=="string"?m.title.trim():"",p=typeof m.description=="string"?m.description.trim():"";t.set(o,{key:o,title:u!==""?u:o,...p!==""?{description:p}:{},status:"missing"})}),i.forEach(o=>{const c=t.get(o.key);t.set(o.key,{...c,...o})}),[...t.values()].map(o=>({...o,isDefault:s!=null&&s!==""?o.key===s:o.isDefault})).sort(Ms)},Ts=({adapterKey:n,accountKey:i,accountItemSchema:s,value:t,onChange:o,t:c})=>{if(s==null||s.fields.length===0)return null;const m={...s,fields:s.fields.map(p=>p.path.length===1&&p.path[0]==="description"?{...p,type:"multiline"}:p)},u=`~/.oneworks/projects/<project-key>/.local/adapters/${n}/accounts/${i}/auth.json`;return e.jsxs("div",{className:"adapter-account-manager__editor",children:[e.jsxs("div",{className:"adapter-account-manager__section-title",children:[e.jsx("span",{className:"material-symbols-rounded",children:"tune"}),e.jsx("span",{children:c("config.accounts.settingsTitle",{defaultValue:"Account settings"})})]}),e.jsx(Cn,{value:Ss(t,i),schema:m,onChange:p=>o(ks(t,i,p)),t:c,resolveFieldLabel:(p,a)=>nn(c,"adapterAccount",p.path,a),resolveFieldDescription:(p,a)=>{const g=kn(c,"adapterAccount",p.path),l=g!==""?g:a;if(p.path.length===1&&p.path[0]==="authFile"){const f=c("config.accounts.authFileDefaultLookup",{defaultValue:"Leave empty to use {{path}}.",path:u});return[l,f].map(h=>h.trim()).filter(h=>h!=="").join(" ")}return l}})]})},$s=({adapterKey:n,accountKey:i,accountItemSchema:s,value:t,onChange:o,onChanged:c,onRemoved:m,t:u})=>{var C,Q;const{message:p}=pn.useApp(),{data:a,isLoading:g,mutate:l}=Vn(`/api/adapters/${n}/accounts/${i}`,()=>ii(n,i)),[f,h]=w.useState(),x=a==null?void 0:a.account,j=Cs(x==null?void 0:x.status,u),_=((x==null?void 0:x.actions)??[]).filter(P=>P.key!=="refresh"),d=((Q=(C=x==null?void 0:x.quota)==null?void 0:C.metrics)==null?void 0:Q.filter(P=>typeof P.value=="string"?P.value.trim()!=="":P.value!=null))??[],N=async P=>{h(P.key);try{const A=await qn(n,{action:P.key,account:i,refresh:P.key==="refresh"});if(await c(),P.key==="remove"){p.success(A.message??u("config.accounts.actionSuccess.remove")),m();return}if(A.account!=null)await l({account:A.account},{revalidate:!1});else{const Y=await ii(n,i,{refresh:!0});await l(Y,{revalidate:!1})}p.success(A.message??u(`config.accounts.actionSuccess.${P.key}`))}catch(A){p.error(cn(A,u(`config.accounts.actionFailed.${P.key}`)))}finally{h(void 0)}};return e.jsxs("div",{className:"adapter-account-manager__detail",children:[g&&e.jsx("div",{className:"adapter-account-manager__state",children:e.jsx(Vi,{size:"small"})}),!g&&x==null&&e.jsx(dn,{image:null,description:u("config.accounts.detailMissing")}),x!=null&&e.jsxs("div",{className:"adapter-account-manager__detail-body",children:[e.jsx("div",{className:"adapter-account-manager__hero",children:e.jsx("div",{className:"adapter-account-manager__hero-body",children:e.jsxs("div",{className:"adapter-account-manager__hero-title-row",children:[e.jsx("div",{className:"adapter-account-manager__hero-title",children:x.title}),e.jsxs("div",{className:"adapter-account-manager__hero-meta",children:[e.jsxs("div",{className:"adapter-account-manager__hero-badges",children:[e.jsx(li,{color:j.color,icon:j.icon,label:j.label}),x.isDefault===!0&&e.jsx(li,{icon:"star",label:u("config.accounts.default")})]}),_.length>0&&e.jsx(Is,{actions:_,loadingAction:f,onRunAction:N,t:u})]})]})})}),d.length>0&&e.jsxs("div",{className:"adapter-account-manager__section",children:[e.jsxs("div",{className:"adapter-account-manager__section-title",children:[e.jsx("span",{className:"material-symbols-rounded",children:"query_stats"}),e.jsx("span",{children:u("config.accounts.quotaTitle",{defaultValue:"Quota"})})]}),e.jsx("div",{className:"adapter-account-manager__metrics",children:d.map(P=>e.jsxs("div",{className:"adapter-account-manager__metric",children:[e.jsx("div",{className:"adapter-account-manager__metric-label",children:P.label}),e.jsxs("div",{className:"adapter-account-manager__metric-value",children:[P.value??"-",(()=>{const A=Ps(P.value);return A==null?null:e.jsx("span",{className:"adapter-account-manager__metric-ring","aria-hidden":"true",style:{background:`conic-gradient(${As(A)} ${A}%, color-mix(in srgb, var(--border-color) 72%, transparent) 0)`},children:e.jsx("span",{className:"adapter-account-manager__metric-ring-inner"})})})()]}),P.description!=null&&P.description.trim()!==""&&e.jsx("div",{className:"adapter-account-manager__metric-description",children:P.description})]},P.id))})]}),e.jsx(Ts,{adapterKey:n,accountKey:i,accountItemSchema:s,value:t,onChange:o,t:u})]})]})},Vs=({accounts:n,onOpenAccounts:i,t:s})=>{const t=n.filter(c=>c.status!=="missing"&&c.status!=="error").length,o=n.find(c=>c.isDefault===!0);return e.jsx("div",{className:"adapter-account-manager__overview",children:e.jsxs("button",{type:"button",className:"adapter-account-manager__overview-card config-view__field-row",onClick:i,children:[e.jsxs("div",{className:"config-view__field-meta",children:[e.jsx("span",{className:"material-symbols-rounded config-view__field-icon",children:"manage_accounts"}),e.jsxs("div",{className:"config-view__field-text",children:[e.jsx("div",{className:"config-view__field-title",children:s("config.accounts.title")}),e.jsxs("div",{className:"config-view__field-desc adapter-account-manager__overview-meta",children:[e.jsx("span",{children:s("config.accounts.count",{count:n.length})}),e.jsx("span",{children:s("config.accounts.readyCount",{count:t})}),o!=null&&e.jsx("span",{children:s("config.accounts.defaultHint",{account:o.title})})]})]})]}),e.jsx("div",{className:"config-view__field-control adapter-account-manager__overview-control",children:e.jsx("span",{className:"material-symbols-rounded adapter-account-manager__overview-arrow",children:"chevron_right"})})]})})},Fs=({accounts:n,actions:i,loadingAction:s,onOpenAccount:t,onRunAction:o,currentDefaultAccount:c,deletingAccountKey:m,onToggleDefaultAccount:u,onDeleteAccount:p,t:a})=>{const[g,l]=w.useState(""),f=An(g),h=i.find(j=>j.key==="add"),x=w.useMemo(()=>f===""?n:n.filter(j=>{var d;return[j.title,j.key,j.description,(d=j.quota)==null?void 0:d.summary].some(N=>An(N).includes(f))}),[n,f]);return e.jsxs("div",{className:"adapter-account-manager",children:[e.jsxs("div",{className:"adapter-account-manager__header",children:[e.jsx(re,{allowClear:!0,value:g,onChange:j=>l(j.target.value),className:"adapter-account-manager__search",placeholder:a("config.accounts.searchPlaceholder",{defaultValue:"Search accounts"}),prefix:e.jsx("span",{className:"material-symbols-rounded",children:"search"})}),h!=null&&e.jsx(ne,{title:Mn(Gn(h,a),qi(h,a)),children:e.jsx(L,{size:"small",type:"default",loading:s===h.key,"aria-label":Gn(h,a),className:"adapter-account-manager__icon-button adapter-account-manager__header-action",icon:e.jsx("span",{className:"material-symbols-rounded",children:zi[h.key]}),onClick:()=>o(h)})})]}),x.length===0&&e.jsx(dn,{image:null,description:n.length===0?a("config.accounts.empty"):a("config.accounts.searchEmpty",{defaultValue:"No matching accounts"})}),x.length>0&&e.jsx("div",{className:"adapter-account-manager__list",children:x.map(j=>{var N;const _=c===j.key||j.isDefault===!0,d=j.status!=="missing";return e.jsxs("div",{className:"adapter-account-manager__item",children:[e.jsx("button",{type:"button",className:"adapter-account-manager__item-trigger",onClick:()=>t(j.key),children:e.jsxs("div",{className:"adapter-account-manager__item-main",children:[e.jsx("div",{className:"adapter-account-manager__item-title",children:j.title}),((N=j.quota)==null?void 0:N.summary)!=null&&j.quota.summary!==""&&e.jsxs("div",{className:"adapter-account-manager__item-description",children:[e.jsx("span",{className:"material-symbols-rounded",children:"speed"}),e.jsx("span",{children:j.quota.summary})]})]})}),e.jsxs("div",{className:"adapter-account-manager__item-actions",children:[e.jsx(ne,{title:_?a("config.accounts.rowActions.clearDefault",{defaultValue:"Clear default account"}):a("config.accounts.rowActions.setDefault",{defaultValue:"Set as default account"}),children:e.jsx(L,{type:"text",size:"small","aria-label":_?a("config.accounts.rowActions.clearDefault",{defaultValue:"Clear default account"}):a("config.accounts.rowActions.setDefault",{defaultValue:"Set as default account"}),className:`adapter-account-manager__row-action ${_?"adapter-account-manager__row-action--active":""}`,icon:e.jsx("span",{className:"material-symbols-rounded",children:"star"}),onClick:C=>{C.stopPropagation(),u(j.key)}})}),d&&e.jsx(Fn,{title:a("config.accounts.deleteConfirmTitle",{defaultValue:"Delete the stored snapshot for {{account}}?",account:j.title}),okText:a("common.confirm"),cancelText:a("common.cancel"),onConfirm:async C=>{var Q;(Q=C==null?void 0:C.stopPropagation)==null||Q.call(C),await p(j.key)},children:e.jsx(L,{type:"text",size:"small",danger:!0,loading:m===j.key,"aria-label":a("config.accounts.rowActions.delete",{defaultValue:"Delete account snapshot"}),className:"adapter-account-manager__row-action",icon:e.jsx("span",{className:"material-symbols-rounded",children:"delete"}),onClick:C=>{C.stopPropagation()}})})]})]},j.key)})})]})},ai=({adapterKey:n,value:i,accountItemSchema:s,nestedPath:t=[],onChange:o,onOpenNestedPath:c,t:m})=>{const{message:u}=pn.useApp(),p=typeof i.defaultAccount=="string"&&i.defaultAccount.trim()!==""?i.defaultAccount.trim():void 0,{data:a,isLoading:g,mutate:l}=Vn(`/api/adapters/${n}/accounts`,()=>Ci(n)),[f,h]=w.useState(),[x,j]=w.useState(),_=w.useMemo(()=>Ui(i),[i]),d=w.useMemo(()=>Gi(_,(a==null?void 0:a.accounts)??[],p),[_,p,a==null?void 0:a.accounts]),N=(a==null?void 0:a.actions)??[],C=t[0]==="accounts",Q=C?t[1]:void 0,P=async()=>{await l()},A=G=>{const B={...i};p===G?delete B.defaultAccount:B.defaultAccount=G,o(B)},Y=async G=>{if(G.key==="add"){h(G.key);try{const B=await qn(n,{action:"add"});await P(),u.success(B.message??m("config.accounts.actionSuccess.add")),B.accountKey!=null&&B.accountKey.trim()!==""?c(["accounts",B.accountKey]):c(["accounts"])}catch(B){u.error(cn(B,m("config.accounts.actionFailed.add")))}finally{h(void 0)}}},I=async G=>{j(G);try{const B=await qn(n,{action:"remove",account:G,refresh:!0});await P(),u.success(B.message??m("config.accounts.actionSuccess.remove"))}catch(B){u.error(cn(B,m("config.accounts.actionFailed.remove")))}finally{j(void 0)}};return g&&d.length===0?e.jsx("div",{className:"adapter-account-manager__state",children:e.jsx(Vi,{size:"small"})}):C&&Q!=null&&Q!==""?e.jsx($s,{adapterKey:n,accountKey:Q,accountItemSchema:s,value:i,onChange:o,onChanged:P,onRemoved:()=>c(["accounts"]),t:m}):C?e.jsx(Fs,{accounts:d,actions:N,loadingAction:f,onOpenAccount:G=>c(["accounts",G]),onRunAction:Y,currentDefaultAccount:p,deletingAccountKey:x,onToggleDefaultAccount:A,onDeleteAccount:I,t:m}):e.jsx(Vs,{accounts:d,onOpenAccounts:()=>c(["accounts"]),t:m})},Ds=({index:n,itemCount:i,onMove:s,onRemove:t,t:o})=>e.jsxs("div",{className:"config-view__record-actions",children:[s!=null&&e.jsxs(e.Fragment,{children:[e.jsx(ne,{title:o("config.editor.moveUp"),children:e.jsx(L,{size:"small",type:"text",className:"config-view__icon-button config-view__icon-button--compact","aria-label":o("config.editor.moveUp"),icon:e.jsx("span",{className:"material-symbols-rounded",children:"keyboard_arrow_up"}),disabled:n===0,onClick:()=>s(-1)})}),e.jsx(ne,{title:o("config.editor.moveDown"),children:e.jsx(L,{size:"small",type:"text",className:"config-view__icon-button config-view__icon-button--compact","aria-label":o("config.editor.moveDown"),icon:e.jsx("span",{className:"material-symbols-rounded",children:"keyboard_arrow_down"}),disabled:n===i-1,onClick:()=>s(1)})})]}),e.jsx(Fn,{title:o("config.editor.removeItemConfirmTitle"),okText:o("common.confirm"),cancelText:o("common.cancel"),onConfirm:t,children:e.jsx(ne,{title:o("config.editor.remove"),children:e.jsx(L,{size:"small",type:"text",danger:!0,className:"config-view__icon-button config-view__icon-button--compact","aria-label":o("config.editor.remove"),icon:e.jsx("span",{className:"material-symbols-rounded",children:"delete"})})})})]}),ni=n=>n!=null&&typeof n=="object"&&!Array.isArray(n)?n:{apiKey:""},Ri=(n,i)=>({canQueryModels:i&&((n==null?void 0:n.listModels)==="api"||(n==null?void 0:n.listModels)==="static"),canQueryBalance:i&&(n==null?void 0:n.balance)==="api",canQueryStatus:i&&(n==null?void 0:n.status)==="api",canCreateSecret:i&&((n==null?void 0:n.secrets)==="api"||(n==null?void 0:n.secrets)==="manual")}),Wi=(n,i,s)=>{var t,o,c,m,u,p,a;return[n,i,s.provider,s.apiBaseUrl,s.apiKey,(t=s.management)==null?void 0:t.apiKey,(o=s.management)==null?void 0:o.baseUrl,(c=s.management)==null?void 0:c.endpointKind,JSON.stringify(((m=s.management)==null?void 0:m.headers)??{}),(u=s.management)==null?void 0:u.organizationId,(p=s.management)==null?void 0:p.projectId,(a=s.management)==null?void 0:a.userId].join(`
|
|
2
|
+
`)},un=n=>{if(!(typeof n!="string"||n.trim()===""))try{const i=new URL(n.trim());return i.protocol==="https:"||i.protocol==="http:"&&(i.hostname==="localhost"||i.hostname==="127.0.0.1"||i.hostname==="[::1]")?i.toString():void 0}catch{return}},Hi=async n=>{var s;const i=un(n);if(i==null)throw new Error("Invalid model service portal URL.");if(((s=window.oneworksDesktop)==null?void 0:s.openExternalUrl)!=null){await window.oneworksDesktop.openExternalUrl(i);return}window.open(i,"_blank","noopener,noreferrer")},Ji=n=>Array.from(new Set(n.map(i=>i.id.trim()).filter(Boolean))),Bs={CNY:"¥",USD:"$"},In=(n,i)=>{const s=n==null?void 0:Bs[n.toUpperCase()];return s==null?[n,i].filter(Boolean).join(" "):`${i} ${s}`},Rn=(n,i)=>{var t;if(n==null)return;if(n.kind==="unsupported")return n.reason;if(n.kind==="quota"){if(n.unlimited===!0)return i("config.modelServices.results.unlimitedQuota");const o=i("config.modelServices.results.amountUnknown"),c=n.remaining==null||n.limit==null?n.remaining??n.limit??o:`${n.remaining}/${n.limit}`,m=typeof c=="number"||typeof c=="string"&&c!==o?In(n.currency,String(c)):c,u=n.resetTime==null?void 0:i("config.modelServices.results.resetsAt",{time:n.resetTime}),p=(t=n.windows)==null?void 0:t[0],a=(p==null?void 0:p.remaining)==null||p.limit==null?void 0:i("config.modelServices.results.windowQuota",{amount:`${p.remaining}/${p.limit}`,duration:[p.duration,p.timeUnit].filter(Boolean).join(" ")}),g=n.parallelLimit==null?void 0:i("config.modelServices.results.parallelLimit",{count:n.parallelLimit});return[m,u,a,g].filter(Boolean).join(" · ")}if(n.kind==="cost"){const o=n.amount==null?i("config.modelServices.results.amountUnknown"):String(n.amount);return[n.currency,o,n.period].filter(Boolean).join(" ")}const s=n.available==null?i("config.modelServices.results.amountUnknown"):String(n.available);return In(n.currency,s)},Es=(n,i)=>n.kind==="quota"?i("config.modelServices.results.quota"):i("config.modelServices.results.balance"),Os=(n,i)=>{if(n!=null)return n.description??i(`config.modelServices.status.${n.indicator}`,{defaultValue:n.indicator})},Ks=n=>`config-view__model-service-status config-view__model-service-status--${n??"unknown"}`,Qi=(n,i,s)=>s==null?void 0:n(`config.modelServices.plan.${i}.${s}`,{defaultValue:s}),Ls=n=>{const i=new Set;return n.flatMap(s=>{const t=un(s.url);return t==null||i.has(t)?[]:(i.add(t),[{...s,url:t}])})},vn=({currency:n,limit:i,remaining:s,t,unit:o,unlimited:c})=>{if(c===!0)return t("config.modelServices.results.unlimitedQuota");if(o==="percent"){const l=s??i;return typeof l=="number"?t("config.modelServices.plan.quotaProgress.percentValue",{value:l}):t("config.modelServices.results.amountUnknown")}const m=t("config.modelServices.results.amountUnknown"),u=l=>In(n,String(l)),p=Qi(t,"quotaUnit",o)??o,a=s==null||i==null?s??i??m:`${s} / ${i}`;return[typeof a=="number"||typeof a=="string"&&a!==m?u(a):a,p].filter(Boolean).join(" ")},ri=(n,i,s)=>{if(n==null)return i("config.modelServices.plan.labels.window");if(s==="minute"&&n%60===0)return i("config.modelServices.plan.duration.hours",{count:n/60});const t=s==null?void 0:i(`config.modelServices.plan.timeUnit.${s}`,{defaultValue:s});return t==null?String(n):i("config.modelServices.plan.duration.generic",{count:n,unit:t})},hn=(n,i)=>{if(!(i==null||i<=0||n==null))return Math.max(0,Math.min(100,Math.round(n/i*100)))},Yi=n=>{const i=(n==null?void 0:n.quotaWindows)??[];return i.includes("weekly")?"weekly":i.includes("monthly")?"monthly":void 0},ci=(n,i)=>{const s=Yi(n);return s==null?i("config.modelServices.plan.labels.periodQuota"):i(`config.modelServices.plan.quotaProgress.${s}`)},zs=n=>((n==null?void 0:n.quotaWindows)??[]).filter(i=>i!==Yi(n)),di=(n,i)=>{const s=Qi(i,"quotaWindow",n)??n;return i("config.modelServices.plan.quotaProgress.window",{duration:s})},Us=(n,i)=>i==="5h"?n.find(s=>s.timeUnit==="minute"&&s.duration===300):void 0,_n=(n,i)=>{if(n==null||n.trim()==="")return;const s=new Date(n),t=Number.isNaN(s.getTime())?n:s.toLocaleString();return i("config.modelServices.plan.quotaProgress.resetAt",{time:t})},Zi=({accountError:n,accountStatus:i,canQueryBalance:s=!1,loadingBalance:t=!1,service:o,t:c})=>{const m=Xn(o),u=Bn(o);if(!(u!=null||(m==null?void 0:m.kind)!=null||s||i!=null))return[];const a=(()=>{if(t||s&&i==null&&n==null)return c("config.modelServices.plan.liveQuota.loading");if(n!=null)return n})(),g=(()=>{if(a!=null)return a;if(i!=null)return Rn(i,c)})(),l=(i==null?void 0:i.kind)==="cost"?c("config.modelServices.results.cost"):(i==null?void 0:i.kind)==="balance"||u==null&&(m==null?void 0:m.kind)==null?c("config.modelServices.results.balance"):c("config.modelServices.plan.labels.liveQuota");return(()=>{if((i==null?void 0:i.kind)==="balance"||(i==null?void 0:i.kind)==="cost")return[{key:"balance",label:i.kind==="cost"?c("config.modelServices.results.cost"):c("config.modelServices.results.balance"),value:Rn(i,c)}];const f=zs(m);if((i==null?void 0:i.kind)==="quota"){if(u==null&&(m==null?void 0:m.kind)==null&&f.length===0)return[{key:"quota",label:c("config.modelServices.results.quota"),percent:hn(i.remaining,i.limit),resetTime:_n(i.resetTime,c),showProgress:i.unlimited!==!0&&i.limit!=null,value:vn({currency:i.currency,limit:i.limit,remaining:i.remaining,t:c,unit:i.unit,unlimited:i.unlimited})}];const h=i.windows??[],x=(m==null?void 0:m.quotaUnit)??i.unit;return[...f.length>0?f.map(_=>{const d=Us(h,_);return{key:`window-${_}`,label:d==null?di(_,c):c("config.modelServices.plan.quotaProgress.window",{duration:ri(d.duration,c,d.timeUnit)}),percent:hn(d==null?void 0:d.remaining,d==null?void 0:d.limit),resetTime:_n(d==null?void 0:d.resetTime,c),showProgress:!0,value:vn({limit:d==null?void 0:d.limit,remaining:d==null?void 0:d.remaining,t:c,unit:x,unlimited:i.unlimited})}}):h.map((_,d)=>({key:`window-${d}`,label:c("config.modelServices.plan.quotaProgress.window",{duration:ri(_.duration,c,_.timeUnit)}),percent:hn(_.remaining,_.limit),resetTime:_n(_.resetTime,c),showProgress:!0,value:vn({limit:_.limit,remaining:_.remaining,t:c,unit:x,unlimited:i.unlimited})})),{key:"period",label:ci(m,c),percent:hn(i.remaining,i.limit),resetTime:_n(i.resetTime,c),showProgress:!0,value:vn({limit:i.limit,remaining:i.remaining,t:c,unit:x,unlimited:i.unlimited})}]}return a!=null&&f.length>0?[...f.map(h=>({key:`window-${h}`,label:di(h,c),percent:void 0,showProgress:!0,value:a})),{key:"period",label:ci(m,c),percent:void 0,showProgress:!0,value:a}]:[{key:"fallback",label:l,percent:void 0,showProgress:u!=null||(m==null?void 0:m.kind)!=null,value:g}].filter(h=>h.value!=null&&h.value!=="")})()},qs=({accountError:n,accountStatus:i,canQueryBalance:s=!1,loadingBalance:t=!1,service:o,t:c})=>{const m=Zi({accountError:n,accountStatus:i,canQueryBalance:s,loadingBalance:t,service:o,t:c});return m.length===0?null:e.jsx("div",{className:"config-view__model-service-plan",children:e.jsx("div",{className:"config-view__model-service-quota-list",children:m.map(u=>{const p=u.showProgress??u.percent!=null;return e.jsxs("div",{className:"config-view__model-service-quota-row",children:[e.jsxs("div",{className:"config-view__model-service-quota-head",children:[e.jsx("span",{children:u.label}),u.value!=null&&u.value!==""&&e.jsx("strong",{children:u.value})]}),p&&e.jsx("div",{className:"config-view__model-service-quota-progress",role:u.percent==null?void 0:"progressbar","aria-valuemin":u.percent==null?void 0:0,"aria-valuemax":u.percent==null?void 0:100,"aria-valuenow":u.percent,"aria-label":[u.label,u.value].filter(Boolean).join(" "),children:e.jsx("span",{style:{width:`${u.percent??0}%`}})}),u.resetTime!=null&&e.jsx("div",{className:"config-view__model-service-quota-meta",children:u.resetTime})]},u.key)})})})},Gs=({service:n,t:i})=>{const s=Bn(n);return Ls([{label:i("config.modelServices.plan.links.purchase"),url:s==null?void 0:s.planHomeUrl},{label:i("config.modelServices.plan.links.key"),url:s==null?void 0:s.keyHomeUrl},{label:i("config.modelServices.plan.links.docs"),url:s==null?void 0:s.docsUrl}])},Rs=6e4,Ws=5*6e4,Wn=new Map,Hs=n=>n.kind==="balance"||n.kind==="cost"?Ws:Rs,rn=n=>{const i=Wn.get(n);return i==null?null:i.expiresAt<=Date.now()?(Wn.delete(n),null):i.value},Xi=(n,i)=>{Wn.set(n,{expiresAt:Date.now()+Hs(i),value:i})},Js=new Set(["coding_plan","token_plan","relay_coding_plan"]),Hn=7,xn=2*Math.PI*Hn,mi=90,Qs=n=>n.replace(/^5\s*(?:小时|hour)s?(?:额度| quota)?$/i,"5 h").replace(/^1\s*(?:周|week)(?:额度| quota)?$/i,"1 w").replace(/\s*quota$/i,"").replace(/额度$/,""),Ys=({item:n,serviceKey:i,source:s,t})=>{var Y;const o=w.useMemo(()=>ni(n),[n]),c=Di(o),m=c.provider==null?void 0:Bi(c.provider),u=Xn(o),p=Bn(o),a=((Y=o.management)==null?void 0:Y.enabled)!==!1,g=Ri(m==null?void 0:m.capabilities,a),l=Wi(i,s,o),h=(p!=null||Js.has((u==null?void 0:u.kind)??""))&&g.canQueryBalance,x=w.useRef(null),[j,_]=w.useState(()=>rn(l)),[d,N]=w.useState(null),[C,Q]=w.useState(!1);w.useEffect(()=>{_(rn(l)),N(null),Q(!1)},[l]);const P=w.useCallback(async()=>{N(null),Q(!0);try{const I=await Li(i,{service:o,source:s});Xi(l,I.account),_(I.account)}catch{N(t("config.modelServices.plan.liveQuota.failed"))}finally{Q(!1)}},[o,l,i,s,t]);if(w.useEffect(()=>{if(!h)return;const I=rn(l);if(I!=null){_(I),N(null);return}x.current!==l&&(x.current=l,P())},[h,P,l]),!h)return null;const A=Zi({accountError:d,accountStatus:j,canQueryBalance:g.canQueryBalance,loadingBalance:C,service:o,t}).slice(0,2);return A.length===0?null:e.jsx("div",{className:"config-view__model-service-list-quota","aria-label":t("config.modelServices.plan.labels.liveQuota"),children:A.map(I=>{const G=Qs(I.label),B=Math.max(0,Math.min(100,I.percent??0)),T=B>mi&&B<100?mi:B,Z=xn*(1-T/100),$=I.percent==null&&d==null&&(C||j==null),je=I.percent==null&&d!=null,te=["config-view__model-service-list-quota-circle",$?"is-loading":"",je?"is-error":"",I.percent==null&&!$&&!je?"is-empty":""].filter(Boolean).join(" "),Ie=$?{strokeDasharray:`${xn*.32} ${xn}`,strokeDashoffset:0}:{strokeDasharray:xn,strokeDashoffset:Z};return e.jsxs("div",{className:"config-view__model-service-list-quota-row",children:[e.jsx(ne,{title:[I.label,I.value].filter(Boolean).join(" "),children:e.jsx("div",{className:te,"aria-busy":$||void 0,role:I.percent==null?void 0:"progressbar","aria-valuemin":I.percent==null?void 0:0,"aria-valuemax":I.percent==null?void 0:100,"aria-valuenow":I.percent,"aria-label":[I.label,I.value].filter(Boolean).join(" "),children:e.jsxs("svg",{className:"config-view__model-service-list-quota-svg",viewBox:"0 0 20 20","aria-hidden":"true",focusable:"false",children:[e.jsx("circle",{className:"config-view__model-service-list-quota-track",cx:"10",cy:"10",r:Hn}),e.jsx("circle",{className:"config-view__model-service-list-quota-progress",cx:"10",cy:"10",r:Hn,style:Ie})]})})}),e.jsx("div",{className:"config-view__model-service-list-quota-label",children:G})]},I.key)})})},Te=n=>n!=null&&typeof n=="object"&&!Array.isArray(n),Zs=(n,i)=>n.length===i.length&&n.every((s,t)=>s===i[t]),yn=(n,i)=>JSON.stringify(n)===JSON.stringify(i),es=(n,i)=>i??Si[n]??[],Jn=({field:n,value:i,resolvedValue:s})=>{const t=n.detailCollection;if(n.type!=="detailCollection"||t==null)return[];if(t.collectionKind==="list"){const m=Array.isArray(i)?i.filter(Te):[],u=Array.isArray(s)?s.filter(Te):m,p=t.getMergeKey;if(p!=null){const f=new Map;m.forEach((j,_)=>{const d=p(j);if(d==null||d==="")return;const N=f.get(d)??[];N.push(_),f.set(d,N)});const h=new Set,x=u.map((j,_)=>{var Q;const d=p(j),N=d!=null?(Q=f.get(d))==null?void 0:Q.shift():void 0;if(N==null)return{key:String(_),item:j,index:_,resolvedIndex:_,source:"inherited",resolvedItem:j,hasResolvedOverlay:!1};const C=m[N];return h.add(N),{key:String(_),item:C,index:_,localIndex:N,resolvedIndex:_,source:"local",localItem:C,resolvedItem:j,hasResolvedOverlay:!yn(C,j)}});return m.forEach((j,_)=>{if(h.has(_))return;const d=x.length;x.push({key:String(d),item:j,index:d,localIndex:_,source:"local",localItem:j,resolvedItem:j,hasResolvedOverlay:!1})}),x}const a=Math.max(u.length-m.length,0),g=u.slice(0,a).map((f,h)=>({key:String(h),item:f,index:h,resolvedIndex:h,source:"inherited",resolvedItem:f,hasResolvedOverlay:!1})),l=m.map((f,h)=>{const x=a+h,j=u[x],_=Te(j)?j:f;return{key:String(x),item:f,index:x,localIndex:h,resolvedIndex:x,source:"local",localItem:f,resolvedItem:_,hasResolvedOverlay:!yn(f,_)}});return[...g,...l]}if(t.collectionKind==="recordMap"){const m=Te(i)?i:{},u=Te(s)?s:m,a=Object.keys(u).map((l,f)=>{var d;const h=m[l],x=Te(h)?h:void 0,j=u[l],_=Te(j)?j:((d=t.createItem)==null?void 0:d.call(t,l))??{};return x==null?{key:l,item:_,index:f,resolvedIndex:f,source:"inherited",resolvedItem:_,hasResolvedOverlay:!1}:{key:l,item:x,index:f,resolvedIndex:f,source:"local",localItem:x,resolvedItem:_,hasResolvedOverlay:!yn(x,_)}}),g=Object.keys(m).filter(l=>!Object.hasOwn(u,l)).map((l,f)=>{var j;const h=m[l],x=Te(h)?h:((j=t.createItem)==null?void 0:j.call(t,l))??{};return{key:l,item:x,index:a.length+f,source:"local",localItem:x,resolvedItem:x,hasResolvedOverlay:!1}});return[...a,...g]}const o=Te(i)?i:{},c=Te(s)?s:o;return t.itemKeys.map((m,u)=>{var f;const p=o[m],a=c[m],g=Te(p)?p:void 0,l=Te(a)?a:((f=t.createItem)==null?void 0:f.call(t,m))??{};return{key:m,item:g??l,index:u,resolvedIndex:u,source:g!=null?"local":"inherited",localItem:g,resolvedItem:l,hasResolvedOverlay:g!=null&&!yn(g,l)}})},Xs=(n,i)=>n.find(s=>Zs(s.path,i)),eo=({field:n,sectionKey:i,t:s})=>n.labelKey!=null?s(n.labelKey):nn(s,i,n.path,n.path.at(-1)??i),no=n=>n==null?"root":`${n.kind}:${n.fieldPath.join(".")}:${n.itemKey}:${(n.nestedPath??[]).join("/")}`,on=n=>n==null?"":[...n.fieldPath,n.itemKey,...n.nestedPath??[]].map(i=>encodeURIComponent(i)).join("/"),io=({fields:n,raw:i})=>{const s=i.trim();if(s==="")return null;const o=(()=>{try{return decodeURIComponent(s)}catch{return s}})().split("/").map(m=>m.trim()).filter(m=>m!=="");if(o.length<1)return null;const c=n.filter(m=>m.type==="detailCollection"&&m.detailCollection!=null).sort((m,u)=>u.path.length-m.path.length).find(m=>{var p;if(o.length<m.path.length+1||!m.path.every((a,g)=>a===o[g]))return!1;const u=o[m.path.length]??"";return u===""?!1:((p=m.detailCollection)==null?void 0:p.collectionKind)==="list"?/^\d+$/.test(u):!0});return c==null?null:{kind:"detailCollectionItem",fieldPath:c.path,itemKey:o[c.path.length],...o.length>c.path.length+1?{nestedPath:o.slice(c.path.length+1)}:{}}},ns=({sectionKey:n,fields:i,value:s,resolvedValue:t,route:o,detailContext:c,t:m})=>{var h,x;if(o==null||o.kind!=="detailCollectionItem")return null;const u=es(n,i),p=Xs(u,o.fieldPath);if((p==null?void 0:p.type)!=="detailCollection"||p.detailCollection==null)return null;const g=Jn({field:p,value:Pe(s,p.path),resolvedValue:Pe(t??s,p.path)}).find(j=>j.key===o.itemKey);if(g==null)return null;const l=eo({field:p,sectionKey:n,t:m}),f=((x=(h=p.detailCollection).getBreadcrumbLabel)==null?void 0:x.call(h,g.item,g.key,g.index,c))??p.detailCollection.getItemTitle(g.item,g.key,g.index,c);return{field:p,fieldLabel:l,item:g.item,resolvedItem:g.resolvedItem,itemLabel:f,itemKey:g.key,itemIndex:g.index,localItemIndex:g.localIndex,resolvedItemIndex:g.resolvedIndex,itemSource:g.source,hasResolvedOverlay:g.hasResolvedOverlay}},ui=({mode:n,serviceKey:i,source:s})=>`${s}:modelServices:${n}:${i??"new"}`,is=n=>n==null||n.trim()===""||n.trim().toLowerCase().startsWith("zh")?"zh":"en",Qn=n=>Array.isArray(n)?n.map(Qn):n==null||typeof n!="object"?n:Object.fromEntries(Object.entries(n).map(([i,s])=>[i,/key|token|secret|password/i.test(i)?"<redacted>":Qn(s)])),Yn=(n,i,s="zh")=>{const t=typeof(i==null?void 0:i.title)=="string"?i.title.trim():"";return t!==""?t:(n==null?void 0:n.trim())||(s==="en"?"new model service":"新模型服务")},tt=(n,i={})=>{const s=is(i.language);if(n.mode==="create")return s==="en"?"Add model service config":"新增模型服务配置";const t=Yn(n.serviceKey,n.service,s);return s==="en"?`Update model service: ${t}`:`修改模型服务:${t}`},so=(n,i={})=>{const s=is(i.language),t=n.mode==="create"?s==="en"?"add a model service config":"新增一个模型服务配置":s==="en"?`update model service \`${n.serviceKey??Yn(n.serviceKey,n.service,s)}\``:`修改模型服务 \`${n.serviceKey??Yn(n.serviceKey,n.service,s)}\``,o=n.service==null?void 0:JSON.stringify(Qn(n.service),null,2),c=n.source==="global"?i.globalConfigPath:n.source==="project"?i.projectConfigPath:i.userConfigPath;return s==="en"?[`Please help me ${t}.`,"","Requirements:",`- Current config source: \`${n.source}\`.${c!=null?` Target config file: \`${c}\`.`:""}`,"- Do not expose API keys, secrets, tokens, or other sensitive fields in the reply.","- For official providers, prefer the provider registry defaults for homepage, apiBaseUrl, models, and management/status capabilities. Only write override fields when the user explicitly asks for them.","- Use the built-in `oneworks-model-services` skill/documentation as the user-facing provider guide for provider ids, default API base URLs, portal links, model/balance/status capabilities, and setup workflow. Do not cite local repository paths or RFC files to the user.","- When provider details are needed, read the built-in skill content instead of embedding or inventing a separate provider catalog in the conversation.","- By default, account/API key configuration belongs in global config, not the project directory, unless the user explicitly asks for a project/user override.","- Follow existing config source writeback semantics; do not infer the write target from merged config.","- When UI verification is needed, use browser:control-in-app-browser to inspect the local config page and provider portal.","",n.mode==="update"&&o!=null?["Current service config snapshot (sensitive fields redacted):","```json",o,"```"].join(`
|
|
3
|
+
`):["When adding a service, first confirm the provider, API key, whether to use the official default API base, whether model/balance/status capabilities are needed, and whether built-in model metadata is needed.","When useful, guide the user to open the provider portal to log in, top up, create a secret, and then return to the config."].join(`
|
|
4
|
+
`)].join(`
|
|
5
|
+
`):[`请帮我${t}。`,"","要求:",`- 当前配置来源是 \`${n.source}\`。${c!=null?`目标配置文件:\`${c}\`。`:""}`,"- 模型服务的 API key、secret、token 等敏感字段不要在回复里明文展示。","- 如果是官方服务商,优先复用 provider registry 里的默认 homepage、apiBaseUrl、models、management/status 能力;只有用户明确要覆盖时才写覆盖字段。","- 使用内置 `oneworks-model-services` 文档/skill 作为面向用户的平台接入指南,里面维护 provider id、默认 API 地址、后台入口、模型/余额/状态能力和配置流程;不要向用户引用本地仓库路径或 RFC 文件。","- 需要平台细节时读取内置 skill 内容,不要在会话里额外塞一份平台目录,也不要临时编造。","- 默认把账号/API key 类配置放到 global,不要写进项目目录;除非用户明确要求 project/user override。","- 按现有 config source 写回语义操作,不要从 merged config 反推写回 source 文件。","- 需要验证界面时,使用 browser:control-in-app-browser 检查本地配置页和服务商后台入口。","",n.mode==="update"&&o!=null?["当前服务配置快照(敏感字段已脱敏):","```json",o,"```"].join(`
|
|
6
|
+
`):["新增时请先确认:服务商、API key、是否使用官方默认 API base、是否需要查询模型/余额/状态能力、是否需要内置模型元数据。","可以在需要时引导用户打开对应服务商主页完成登录、充值、创建 secret,再回到配置。"].join(`
|
|
7
|
+
`)].join(`
|
|
8
|
+
`)},lt=(n,i={})=>[{type:"text",text:so(n,i)}],Zn=n=>typeof n=="string"&&n.trim()!==""?n.trim():"",oo=n=>n.replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/[-_]+/g," ").split(/\s+/).filter(Boolean).map(i=>i.charAt(0).toUpperCase()+i.slice(1)).join(" "),to=n=>{const i=Pi(n),s=Zn(i.title);return s!==""&&s!==n?s:oo(n)},lo=({item:n,fallbackSubtitle:i,t:s})=>{const t=[],o=Zn(n.defaultModel),c=Zn(n.defaultAccount);return o!==""&&t.push(`${s("config.fields.adapters.defaultModel.label")}: ${o}`),c!==""&&t.push(`${s("config.fields.adapters.defaultAccount.label")}: ${c}`),t.length>0?t.join(" · "):i},ao=({sectionKey:n,field:i,value:s,resolvedValue:t,source:o="project",onChange:c,onOpenDetail:m,mergedModelServices:u,mergedAdapters:p,uiSection:a,creatingModelServiceSessionKey:g,onCreateModelServiceSession:l,t:f})=>{var we,Ne;const{resolvedThemeMode:h}=ms(),[x,j]=w.useState(""),[_,d]=w.useState((a==null?void 0:a.kind)==="recordMap"?((Ne=(we=a.recordMap.entryKinds)==null?void 0:we[0])==null?void 0:Ne.key)??"":""),N=i.detailCollection;if(N==null)return null;const C=Jn({field:i,value:s,resolvedValue:t}),Q={mergedModelServices:u,mergedAdapters:p,t:f},P=i.labelKey!=null?f(i.labelKey):nn(f,n,i.path,i.path.at(-1)??n),A=N.collectionKind==="list",Y=N.collectionKind==="recordMap",I=Y&&(a==null?void 0:a.kind)==="recordMap"&&a.recordMap.mode==="discriminated",G=N.collectionKind==="recordMap"?N.keyPlaceholderKey!=null?f(N.keyPlaceholderKey):f("config.editor.fieldKey"):"",B=w.useMemo(()=>(a==null?void 0:a.kind)==="recordMap"?(a.recordMap.entryKinds??[]).map(S=>({value:S.key,label:S.label??S.key})):[],[a]),T=A&&Array.isArray(s)?s.filter(S=>S!=null&&typeof S=="object"&&!Array.isArray(S)):[],Z=ui({mode:"create",source:o}),$=(S,V)=>{c(Fe(s,[S],V))},je=S=>{c(S)},te=(S,V)=>{if(!A)return;const H=S+V;if(H<0||H>=T.length)return;const E=[...T],[ue]=E.splice(S,1);ue!=null&&(E.splice(H,0,ue),je(E))},Ie=S=>{A&&je(T.filter((V,H)=>H!==S))},he=S=>{if(!Y)return;const V=s!=null&&typeof s=="object"&&!Array.isArray(s)?{...s}:{};delete V[S],c(V)},be=S=>{m({kind:"detailCollectionItem",fieldPath:i.path,itemKey:S})},_e=({item:S,itemKey:V,title:H,localIndex:E,source:ue})=>{var W;return ue!=="local"||(((W=N.summaryControls)==null?void 0:W.length)??0)===0?null:e.jsx("div",{className:"config-view__detail-summary-controls",onClick:X=>X.stopPropagation(),children:N.summaryControls.map(X=>{if(X.kind!=="boolean")return null;const pe=X.checkedValue??!0,Ae=!!Pe(S,X.path)===pe,Be=X.labelKey!=null?f(X.labelKey):H;return e.jsx(Ye,{size:"small",checked:Ae,"aria-label":Be,onChange:Ee=>{const Oe=Fe(S,X.path,Ee?pe:!pe);if(A){if(E==null)return;const Ke=[...T];Ke[E]=Oe,je(Ke);return}$(V,Oe)}},`${V}:${X.path.join(".")}`)})})},v=()=>{var H;if(!Y)return;const S=x.trim();if(S===""||C.some(E=>E.key===S))return;let V;if((a==null?void 0:a.kind)==="recordMap"){const E=a.recordMap.mode==="discriminated"?a.recordMap.schemas[_]??a.recordMap.unknownSchema:a.recordMap.schemas[S]??a.recordMap.unknownSchema;if(V=Ii(E),a.recordMap.mode==="discriminated"){const ue=a.recordMap.discriminatorField??"type";V=Fe(V,[ue],_)}}else V=((H=N.createItem)==null?void 0:H.call(N,S,_))??{};$(S,V),j(""),be(S)};return e.jsxs("div",{className:"config-view__detail-list",children:[C.map(({item:S,key:V,index:H,localIndex:E,source:ue,hasResolvedOverlay:W})=>{var k,O;const X=N.getItemTitle(S,V,H,Q),pe=(k=N.getItemSubtitle)==null?void 0:k.call(N,S,V,H,Q),$e=(O=N.getItemDescription)==null?void 0:O.call(N,S,V,H,Q),Ae=n==="adapters"?Pi(V):void 0,Be=Ae==null?void 0:cs(Ae,h),Ee=n==="modelServices"?Ei(S):void 0,Oe=n==="modelServices"?un(Oi(S)):void 0,Ke=ui({mode:"update",serviceKey:V,source:o}),He=n==="adapters"?to(V):X,Ue=n==="adapters"?lo({item:S,fallbackSubtitle:pe,t:f}):pe,Je=_e({item:S,itemKey:V,title:He,localIndex:E,source:ue}),r=(A||Y)&&ue==="local"?e.jsx(Ds,{index:E??0,itemCount:A?T.length:C.filter(q=>q.source==="local").length,onMove:A?q=>{E!=null&&te(E,q)}:void 0,onRemove:()=>{if(A){if(E==null)return;Ie(E);return}he(V)},t:f}):null,b=n==="modelServices"?e.jsxs(e.Fragment,{children:[l!=null&&e.jsx(ne,{title:f("config.actions.configureModelServiceWithSession"),children:e.jsx(L,{type:"text",size:"small",className:"config-view__icon-button config-view__icon-button--compact config-view__detail-action-btn","aria-label":f("config.actions.configureModelServiceWithSession"),loading:g===Ke,disabled:g!=null&&g!==Ke,icon:e.jsx("span",{className:"material-symbols-rounded",children:"forum"}),onClick:()=>void l({mode:"update",service:S,serviceKey:V,source:o})})}),Oe!=null&&e.jsx(ne,{title:f("config.actions.openModelServiceHomepage",{defaultValue:"打开管理主页"}),children:e.jsx(L,{type:"text",size:"small",className:"config-view__icon-button config-view__icon-button--compact config-view__detail-action-btn","aria-label":f("config.actions.openModelServiceHomepage",{defaultValue:"打开管理主页"}),icon:e.jsx("span",{className:"material-symbols-rounded",children:"open_in_new"}),onClick:()=>void Hi(Oe)})}),Je,r]}):null;return e.jsx("div",{className:`config-view__record-card${ue==="inherited"?" config-view__record-card--readonly":""}`,children:e.jsxs("div",{className:"config-view__detail-list-row",children:[e.jsx("button",{type:"button",className:"config-view__detail-list-main",onClick:()=>be(V),children:e.jsxs("div",{className:`config-view__record-heading${Be!=null||Ee!=null?" has-adapter-icon":""}`,children:[Ae!=null&&e.jsx("div",{className:"config-view__adapter-icon-wrap","aria-hidden":"true",children:Be!=null?e.jsx("img",{className:"config-view__adapter-icon",src:Be,alt:""}):e.jsx("span",{className:"config-view__adapter-icon-fallback material-symbols-rounded",children:"deployed_code"})}),Ee!=null&&e.jsx("div",{className:"config-view__adapter-icon-wrap","aria-hidden":"true",children:Ki({icon:Ee,imageClassName:"config-view__adapter-icon",symbolClassName:"config-view__adapter-icon-fallback"})}),e.jsxs("div",{className:"config-view__record-heading-text",children:[e.jsxs("div",{className:"config-view__detail-list-title",children:[e.jsx("span",{children:He}),(ue==="inherited"||W)&&e.jsx("span",{className:`config-view__detail-badge${ue==="inherited"?" config-view__detail-badge--readonly":" config-view__detail-badge--override"}`,children:f(ue==="inherited"?"config.detail.inheritedBadge":"config.detail.overrideBadge")})]}),Ue!=null&&Ue!==""&&e.jsx("div",{className:"config-view__record-subtitle",children:Ue}),$e!=null&&$e!==""&&e.jsx("div",{className:"config-view__record-desc",children:$e})]})]})}),n==="modelServices"?e.jsxs("div",{className:"config-view__model-service-list-tray",children:[e.jsx(Ys,{item:S,serviceKey:V,source:o,t:f}),b!=null&&e.jsx("div",{className:"config-view__model-service-list-actions",children:b})]}):e.jsxs(e.Fragment,{children:[Je,r]})]})},`${i.path.join(".")}:${V}:${X}`)}),A&&C.length===0&&e.jsxs("div",{className:"config-view__detail-list-empty",children:[e.jsx("div",{className:"config-view__detail-list-empty-title",children:P}),e.jsx("div",{className:"config-view__detail-list-empty-desc",children:f("common.noData")})]}),A&&e.jsx("div",{className:"config-view__record-add",children:e.jsx(ne,{title:f("config.editor.addItem"),children:e.jsx(L,{size:"small",type:"primary",className:"config-view__icon-button config-view__icon-button--full","aria-label":f("config.editor.addItem"),icon:e.jsx("span",{className:"material-symbols-rounded",children:"add"}),onClick:()=>{const S=[...T,N.createItem()];je(S);const H=Jn({field:i,value:S,resolvedValue:t}).find(E=>E.localIndex===S.length-1);be((H==null?void 0:H.key)??String(S.length-1))}})})}),Y&&e.jsx("div",{className:"config-view__record-add",children:e.jsxs("div",{className:"config-view__record-add-inputs",children:[e.jsx(re,{value:x,placeholder:G,onChange:S=>j(S.target.value)}),I&&e.jsx(De,{value:_,options:B,onChange:S=>d(S)}),e.jsx(ne,{title:f("common.confirm"),children:e.jsx(L,{size:"small",type:"primary",className:"config-view__icon-button","aria-label":f("common.confirm"),icon:e.jsx("span",{className:"material-symbols-rounded",children:"check"}),disabled:x.trim()===""||C.some(S=>S.key===x.trim())||I&&_.trim()==="",onClick:v})}),n==="modelServices"&&l!=null&&e.jsx(ne,{title:f("config.actions.createModelServiceWithSession"),children:e.jsx(L,{size:"small",type:"text",className:"config-view__icon-button","aria-label":f("config.actions.createModelServiceWithSession"),loading:g===Z,disabled:g!=null&&g!==Z,icon:e.jsx("span",{className:"material-symbols-rounded",children:"forum"}),onClick:()=>void l({mode:"create",source:o})})})]})})]})},ro=({value:n,onChange:i,t:s,keyPlaceholder:t})=>{const[o,c]=w.useState(""),m=Object.entries(n);return e.jsxs("div",{className:"config-view__record-list",children:[m.map(([u,p])=>e.jsxs("div",{className:"config-view__record-row",children:[e.jsx("div",{className:"config-view__record-key",children:u}),e.jsx(Ye,{checked:!!p,onChange:a=>{i({...n,[u]:a})}}),e.jsx(ne,{title:s("config.editor.remove"),children:e.jsx(L,{size:"small",type:"text",danger:!0,className:"config-view__icon-button config-view__icon-button--compact","aria-label":s("config.editor.remove"),icon:e.jsx("span",{className:"material-symbols-rounded",children:"delete"}),onClick:()=>{const a={...n};delete a[u],i(a)}})})]},u)),e.jsx("div",{className:"config-view__record-add",children:e.jsxs("div",{className:"config-view__record-add-inputs",children:[e.jsx(re,{value:o,placeholder:t,onChange:u=>c(u.target.value)}),e.jsx(ne,{title:s("common.confirm"),children:e.jsx(L,{size:"small",type:"primary",className:"config-view__icon-button","aria-label":s("common.confirm"),icon:e.jsx("span",{className:"material-symbols-rounded",children:"check"}),disabled:o.trim()===""||Object.hasOwn(n,o),onClick:()=>{i({...n,[o]:!0}),c("")}})})]})})]})},fn=({value:n,onChange:i,t:s,keyPlaceholder:t})=>{const[o,c]=w.useState(""),[m,u]=w.useState(""),p=Object.entries(n);return e.jsxs("div",{className:"config-view__array-list",children:[p.map(([a,g])=>e.jsxs("div",{className:"config-view__array-item",children:[e.jsx("div",{className:"config-view__record-key",children:a}),vs(a)?e.jsx(re.Password,{value:g,onChange:l=>{i({...n,[a]:l.target.value})},placeholder:s("config.editor.fieldValue")}):e.jsx(re,{value:g,onChange:l=>{i({...n,[a]:l.target.value})},placeholder:s("config.editor.fieldValue")}),e.jsx(ne,{title:s("config.editor.remove"),children:e.jsx(L,{size:"small",type:"text",danger:!0,className:"config-view__icon-button config-view__icon-button--compact","aria-label":s("config.editor.remove"),icon:e.jsx("span",{className:"material-symbols-rounded",children:"delete"}),onClick:()=>{const l={...n};delete l[a],i(l)}})})]},a)),e.jsx("div",{className:"config-view__array-add",children:e.jsxs("div",{className:"config-view__array-add-inputs",children:[e.jsx(re,{value:o,placeholder:t,onChange:a=>c(a.target.value)}),e.jsx(re,{value:m,placeholder:s("config.editor.fieldValue"),onChange:a=>u(a.target.value)}),e.jsx(ne,{title:s("common.confirm"),children:e.jsx(L,{size:"small",type:"primary",className:"config-view__icon-button","aria-label":s("common.confirm"),icon:e.jsx("span",{className:"material-symbols-rounded",children:"check"}),disabled:o.trim()===""||Object.hasOwn(n,o),onClick:()=>{const a={...n,[o]:m};i(a),c(""),u("")}})})]})})]})},co=({value:n,onChange:i,t:s,keyPlaceholder:t})=>{const[o,c]=w.useState(""),m=w.useMemo(()=>Object.entries(n),[n]),[u,p]=w.useState(()=>Object.fromEntries(m.map(([a])=>[a,!0])));return w.useEffect(()=>{p(a=>{const g={};for(const[l]of m)g[l]=a[l]??!0;return g})},[m]),e.jsxs("div",{className:"config-view__record-list",children:[m.map(([a,g])=>{const l=g!=null&&typeof g=="object"?g:{},f=typeof l.type=="string"?l.type:"command",h=l.env!=null&&typeof l.env=="object"?l.env:{},x=l.headers!=null&&typeof l.headers=="object"?l.headers:{},j=Array.isArray(l.args)?l.args.filter(N=>typeof N=="string"):[],_=N=>{i({...n,[a]:N})},d=u[a]===!0;return e.jsxs("div",{className:`config-view__record-card${d?" config-view__record-card--collapsed":""}`,children:[e.jsxs("div",{className:"config-view__record-title",children:[e.jsxs("div",{className:"config-view__record-title-left",children:[e.jsx(ne,{title:s(d?"config.editor.expand":"config.editor.collapse"),children:e.jsx(L,{size:"small",type:"text",className:"config-view__icon-button config-view__icon-button--compact","aria-label":s(d?"config.editor.expand":"config.editor.collapse"),icon:e.jsx("span",{className:"material-symbols-rounded",children:d?"chevron_right":"expand_more"}),onClick:()=>{p(N=>({...N,[a]:!d}))}})}),e.jsx("span",{children:a})]}),e.jsx(ne,{title:s("config.editor.remove"),children:e.jsx(L,{size:"small",type:"text",danger:!0,className:"config-view__icon-button config-view__icon-button--compact","aria-label":s("config.editor.remove"),icon:e.jsx("span",{className:"material-symbols-rounded",children:"delete"}),onClick:()=>{const N={...n};delete N[a],i(N)}})})]}),e.jsx("div",{className:"config-view__record-body",children:e.jsxs("div",{className:"config-view__record-fields",children:[e.jsx(le,{title:s("config.fields.mcpServer.enabled.label"),description:s("config.fields.mcpServer.enabled.desc"),icon:ae("boolean"),children:e.jsx(Ye,{checked:!!l.enabled,onChange:N=>{_({...l,enabled:N})}})}),e.jsx(le,{title:s("config.fields.mcpServer.type.label"),description:s("config.fields.mcpServer.type.desc"),icon:ae("string"),children:e.jsx(De,{value:f,options:[{value:"command",label:s("config.options.mcp.command")},{value:"sse",label:s("config.options.mcp.sse")},{value:"http",label:s("config.options.mcp.http")}],onChange:N=>{const C={...l};N==="command"?(delete C.type,C.command==null&&(C.command=""),C.args==null&&(C.args=[]),delete C.url,delete C.headers):(C.type=N,C.url==null&&(C.url=""),C.headers==null&&(C.headers={}),delete C.command,delete C.args),_(C)}})}),f==="command"&&e.jsxs(e.Fragment,{children:[e.jsx(le,{title:s("config.fields.mcpServer.command.label"),description:s("config.fields.mcpServer.command.desc"),icon:ae("string"),children:e.jsx(re,{value:typeof l.command=="string"?l.command:"",onChange:N=>{_({...l,command:N.target.value})},placeholder:s("config.editor.commandPlaceholder")})}),e.jsx(le,{title:s("config.fields.mcpServer.args.label"),description:s("config.fields.mcpServer.args.desc"),icon:ae("array"),layout:"stacked",children:e.jsx(Dn,{value:j,onChange:N=>{_({...l,args:N})},t:s})})]}),f!=="command"&&e.jsxs(e.Fragment,{children:[e.jsx(le,{title:s("config.fields.mcpServer.url.label"),description:s("config.fields.mcpServer.url.desc"),icon:ae("string"),children:e.jsx(re,{value:typeof l.url=="string"?l.url:"",onChange:N=>{_({...l,url:N.target.value})},placeholder:s("config.editor.urlPlaceholder")})}),e.jsx(le,{title:s("config.fields.mcpServer.headers.label"),description:s("config.fields.mcpServer.headers.desc"),icon:ae("object"),layout:"stacked",children:e.jsx(fn,{value:x,onChange:N=>{_({...l,headers:N})},t:s,keyPlaceholder:s("config.editor.newHeaderName")})})]}),e.jsx(le,{title:s("config.fields.mcpServer.env.label"),description:s("config.fields.mcpServer.env.desc"),icon:ae("object"),layout:"stacked",children:e.jsx(fn,{value:h,onChange:N=>{_({...l,env:N})},t:s,keyPlaceholder:s("config.editor.newEnvVarName")})})]})})]},a)}),e.jsx("div",{className:"config-view__record-add",children:e.jsxs("div",{className:"config-view__record-add-inputs",children:[e.jsx(re,{value:o,placeholder:t,onChange:a=>c(a.target.value)}),e.jsx(ne,{title:s("common.confirm"),children:e.jsx(L,{size:"small",type:"primary",className:"config-view__icon-button","aria-label":s("common.confirm"),icon:e.jsx("span",{className:"material-symbols-rounded",children:"check"}),disabled:o.trim()===""||Object.hasOwn(n,o),onClick:()=>{i({...n,[o]:{enabled:!0,command:"",args:[]}}),c("")}})})]})})]})},mo=({value:n,onChange:i,t:s,keyPlaceholder:t})=>{const[o,c]=w.useState(""),m=w.useMemo(()=>Object.entries(n),[n]),[u,p]=w.useState(()=>Object.fromEntries(m.map(([a])=>[a,!0])));return w.useEffect(()=>{p(a=>{const g={};for(const[l]of m)g[l]=a[l]??!0;return g})},[m]),e.jsxs("div",{className:"config-view__record-list",children:[m.map(([a,g])=>{const l=g!=null&&typeof g=="object"?g:{},f=typeof l.title=="string"?l.title:"",h=typeof l.description=="string"?l.description:"",x=f.trim()!==""?f:a,j=Array.isArray(l.models)?l.models.filter(d=>typeof d=="string"):[],_=u[a]===!0;return e.jsxs("div",{className:`config-view__record-card${_?" config-view__record-card--collapsed":""}`,children:[e.jsxs("div",{className:"config-view__record-title",children:[e.jsxs("div",{className:"config-view__record-title-left",children:[e.jsx(ne,{title:s(_?"config.editor.expand":"config.editor.collapse"),children:e.jsx(L,{size:"small",type:"text",className:"config-view__icon-button config-view__icon-button--compact","aria-label":s(_?"config.editor.expand":"config.editor.collapse"),icon:e.jsx("span",{className:"material-symbols-rounded",children:_?"chevron_right":"expand_more"}),onClick:()=>{p(d=>({...d,[a]:!_}))}})}),e.jsxs("div",{className:"config-view__record-heading",children:[e.jsx("div",{children:x}),x!==a&&e.jsx("div",{className:"config-view__record-subtitle",children:a}),h!==""&&e.jsx("div",{className:"config-view__record-desc",children:h})]})]}),e.jsx(ne,{title:s("config.editor.remove"),children:e.jsx(L,{size:"small",type:"text",danger:!0,className:"config-view__icon-button config-view__icon-button--compact","aria-label":s("config.editor.remove"),icon:e.jsx("span",{className:"material-symbols-rounded",children:"delete"}),onClick:()=>{const d={...n};delete d[a],i(d)}})})]}),e.jsx("div",{className:"config-view__record-body",children:e.jsxs("div",{className:"config-view__record-fields",children:[e.jsx(le,{title:s("config.fields.modelServices.item.title.label"),description:s("config.fields.modelServices.item.title.desc"),icon:ae("string"),children:e.jsx(re,{value:f,onChange:d=>{i({...n,[a]:{...l,title:d.target.value}})},placeholder:s("config.editor.titlePlaceholder")})}),e.jsx(le,{title:s("config.fields.modelServices.item.description.label"),description:s("config.fields.modelServices.item.description.desc"),icon:ae("string"),layout:"stacked",children:e.jsx(re.TextArea,{value:h,onChange:d=>{i({...n,[a]:{...l,description:d.target.value}})},autoSize:{minRows:2},placeholder:s("config.editor.descriptionPlaceholder")})}),e.jsx(le,{title:s("config.fields.modelServices.item.apiBaseUrl.label"),description:s("config.fields.modelServices.item.apiBaseUrl.desc"),icon:ae("string"),children:e.jsx(re,{value:typeof l.apiBaseUrl=="string"?l.apiBaseUrl:"",onChange:d=>{i({...n,[a]:{...l,apiBaseUrl:d.target.value}})}})}),e.jsx(le,{title:s("config.fields.modelServices.item.apiKey.label"),description:s("config.fields.modelServices.item.apiKey.desc"),icon:ae("string"),children:e.jsx(re.Password,{value:typeof l.apiKey=="string"?l.apiKey:"",onChange:d=>{i({...n,[a]:{...l,apiKey:d.target.value}})},placeholder:s("config.editor.secretPlaceholder")})}),e.jsx(le,{title:s("config.fields.modelServices.item.models.label"),description:s("config.fields.modelServices.item.models.desc"),icon:ae("array"),layout:"stacked",children:e.jsx(Dn,{value:j,onChange:d=>{i({...n,[a]:{...l,models:d}})},t:s})}),e.jsx(le,{title:s("config.fields.modelServices.item.timeoutMs.label"),description:s("config.fields.modelServices.item.timeoutMs.desc"),icon:ae("number"),children:e.jsx(Pn,{min:1,step:1e3,value:typeof l.timeoutMs=="number"?l.timeoutMs:void 0,onChange:d=>{i({...n,[a]:{...l,...typeof d=="number"?{timeoutMs:d}:{timeoutMs:void 0}}})}})}),e.jsx(le,{title:s("config.fields.modelServices.item.maxOutputTokens.label"),description:s("config.fields.modelServices.item.maxOutputTokens.desc"),icon:ae("number"),children:e.jsx(Pn,{min:1,step:256,value:typeof l.maxOutputTokens=="number"?l.maxOutputTokens:void 0,onChange:d=>{i({...n,[a]:{...l,...typeof d=="number"?{maxOutputTokens:d}:{maxOutputTokens:void 0}}})}})}),e.jsx(le,{title:s("config.fields.modelServices.item.extra.label"),description:s("config.fields.modelServices.item.extra.desc"),icon:ae("object"),layout:"stacked",children:e.jsx(mn,{value:l.extra??{},onChange:d=>{i({...n,[a]:{...l,extra:d}})}})})]})})]},a)}),e.jsx("div",{className:"config-view__record-add",children:e.jsxs("div",{className:"config-view__record-add-inputs",children:[e.jsx(re,{value:o,placeholder:t,onChange:a=>c(a.target.value)}),e.jsx(ne,{title:s("common.confirm"),children:e.jsx(L,{size:"small",type:"primary",className:"config-view__icon-button","aria-label":s("common.confirm"),icon:e.jsx("span",{className:"material-symbols-rounded",children:"check"}),disabled:o.trim()===""||Object.hasOwn(n,o),onClick:()=>{i({...n,[o]:{title:"",description:"",apiKey:"",timeoutMs:void 0,maxOutputTokens:void 0,extra:{}}}),c("")}})})]})})]})},Ln=({value:n,onChange:i,highlightedKey:s,t,keyPlaceholder:o})=>{const[c,m]=w.useState(""),u=w.useMemo(()=>Object.entries(n),[n]),p=w.useRef({}),[a,g]=w.useState(()=>Object.fromEntries(u.map(([l])=>[l,!0])));return w.useEffect(()=>{g(l=>{const f={};for(const[h]of u)f[h]=l[h]??!0;return f})},[u]),w.useEffect(()=>{if(s==null||s.trim()===""||!Object.hasOwn(n,s))return;g(f=>f[s]===!1?f:{...f,[s]:!1});const l=window.requestAnimationFrame(()=>{var f;(f=p.current[s])==null||f.scrollIntoView({block:"center",behavior:"smooth"})});return()=>window.cancelAnimationFrame(l)},[s,n]),e.jsxs("div",{className:"config-view__record-list",children:[u.map(([l,f])=>{const h=a[l]===!0;return e.jsxs("div",{ref:x=>{p.current[l]=x},className:["config-view__record-card",h?"config-view__record-card--collapsed":"",s===l?"config-view__record-card--highlighted":""].filter(Boolean).join(" "),children:[e.jsxs("div",{className:"config-view__record-title",children:[e.jsxs("div",{className:"config-view__record-title-left",children:[e.jsx(ne,{title:t(h?"config.editor.expand":"config.editor.collapse"),children:e.jsx(L,{size:"small",type:"text",className:"config-view__icon-button config-view__icon-button--compact","aria-label":t(h?"config.editor.expand":"config.editor.collapse"),icon:e.jsx("span",{className:"material-symbols-rounded",children:h?"chevron_right":"expand_more"}),onClick:()=>{g(x=>({...x,[l]:!h}))}})}),e.jsx("span",{children:l})]}),e.jsx(ne,{title:t("config.editor.remove"),children:e.jsx(L,{size:"small",type:"text",danger:!0,className:"config-view__icon-button config-view__icon-button--compact","aria-label":t("config.editor.remove"),icon:e.jsx("span",{className:"material-symbols-rounded",children:"delete"}),onClick:()=>{const x={...n};delete x[l],i(x)}})})]}),e.jsx("div",{className:"config-view__record-body",children:e.jsx(mn,{value:f,onChange:x=>{i({...n,[l]:x})}})})]},l)}),e.jsx("div",{className:"config-view__record-add",children:e.jsxs("div",{className:"config-view__record-add-inputs",children:[e.jsx(re,{value:c,placeholder:o,onChange:l=>m(l.target.value)}),e.jsx(ne,{title:t("common.confirm"),children:e.jsx(L,{size:"small",type:"primary",className:"config-view__icon-button","aria-label":t("common.confirm"),icon:e.jsx("span",{className:"material-symbols-rounded",children:"check"}),disabled:c.trim()===""||Object.hasOwn(n,c),onClick:()=>{i({...n,[c]:{}}),m("")}})})]})})]})},uo=({value:n,schema:i,onChange:s,t,keyPlaceholder:o})=>{var f,h;const[c,m]=w.useState(""),[u,p]=w.useState(((h=(f=i.entryKinds)==null?void 0:f[0])==null?void 0:h.key)??""),a=w.useMemo(()=>Object.entries(n),[n]),[g,l]=w.useState(()=>Object.fromEntries(a.map(([x])=>[x,!0])));return w.useEffect(()=>{l(x=>{const j={};for(const[_]of a)j[_]=x[_]??!0;return j})},[a]),e.jsxs("div",{className:"config-view__record-list",children:[a.map(([x,j])=>{var I,G;const _=j!=null&&typeof j=="object"?j:{},{itemSchema:d,isKnownEntry:N}=Ti({schema:i,entryKey:x,entryValue:_}),C=g[x]===!0,Q=i.discriminatorField??"type",P=i.mode==="discriminated"?Pe(_,[Q]):void 0,A=!N&&i.unknownEditor==="json",Y=typeof P=="string"?(I=i.entryKinds)==null?void 0:I.find(B=>B.key===P):(G=i.entryKinds)==null?void 0:G.find(B=>B.key===x);return e.jsxs("div",{className:`config-view__record-card${C?" config-view__record-card--collapsed":""}`,children:[e.jsxs("div",{className:"config-view__record-title",children:[e.jsxs("div",{className:"config-view__record-title-left",children:[e.jsx(ne,{title:t(C?"config.editor.expand":"config.editor.collapse"),children:e.jsx(L,{size:"small",type:"text",className:"config-view__icon-button config-view__icon-button--compact","aria-label":t(C?"config.editor.expand":"config.editor.collapse"),icon:e.jsx("span",{className:"material-symbols-rounded",children:C?"chevron_right":"expand_more"}),onClick:()=>{l(B=>({...B,[x]:!C}))}})}),e.jsxs("div",{className:"config-view__record-heading",children:[e.jsx("div",{children:x}),(Y==null?void 0:Y.label)!=null&&Y.label!==x&&e.jsx("div",{className:"config-view__record-subtitle",children:Y.label}),(Y==null?void 0:Y.description)!=null&&Y.description!==""&&e.jsx("div",{className:"config-view__record-desc",children:Y.description})]})]}),e.jsx(ne,{title:t("config.editor.remove"),children:e.jsx(L,{size:"small",type:"text",danger:!0,className:"config-view__icon-button config-view__icon-button--compact","aria-label":t("config.editor.remove"),icon:e.jsx("span",{className:"material-symbols-rounded",children:"delete"}),onClick:()=>{const B={...n};delete B[x],s(B)}})})]}),e.jsxs("div",{className:"config-view__record-body",children:[!A&&d!=null&&e.jsx(Cn,{value:_,schema:d,onChange:B=>{s({...n,[x]:B})},t,hideFieldPaths:N&&i.mode==="discriminated"?[[Q]]:void 0}),A&&e.jsx(mn,{value:_,onChange:B=>{s({...n,[x]:B})}})]})]},x)}),e.jsx("div",{className:"config-view__record-add",children:e.jsxs("div",{className:"config-view__record-add-inputs",children:[e.jsx(re,{value:c,placeholder:o,onChange:x=>m(x.target.value)}),i.mode==="discriminated"&&e.jsx(De,{value:u,options:(i.entryKinds??[]).map(x=>({value:x.key,label:x.label??x.key})),onChange:x=>p(x)}),e.jsx(ne,{title:t("common.confirm"),children:e.jsx(L,{size:"small",type:"primary",className:"config-view__icon-button","aria-label":t("common.confirm"),icon:e.jsx("span",{className:"material-symbols-rounded",children:"check"}),disabled:c.trim()===""||Object.hasOwn(n,c)||i.mode==="discriminated"&&u.trim()==="",onClick:()=>{const x=i.mode==="discriminated"?i.schemas[u]??i.unknownSchema:i.schemas[c]??i.unknownSchema,j=Ii(x);if(i.mode==="discriminated"){const _=i.discriminatorField??"type";Object.assign(j,Fe(j,[_],u))}s({...n,[c]:j}),m("")}})})]})})]})},fo=({value:n,onChange:i,t:s})=>{const t=typeof n.type=="string"?n.type:"command",o=n.env!=null&&typeof n.env=="object"?n.env:{},c=n.headers!=null&&typeof n.headers=="object"?n.headers:{},m=Array.isArray(n.args)?n.args.filter(u=>typeof u=="string"):[];return e.jsxs("div",{className:"config-view__field-stack",children:[e.jsx(le,{title:s("config.fields.mcpServer.enabled.label"),description:s("config.fields.mcpServer.enabled.desc"),icon:ae("boolean"),children:e.jsx(Ye,{checked:!!n.enabled,onChange:u=>{i({...n,enabled:u})}})}),e.jsx(le,{title:s("config.fields.mcpServer.type.label"),description:s("config.fields.mcpServer.type.desc"),icon:ae("string"),children:e.jsx(De,{value:t,options:[{value:"command",label:s("config.options.mcp.command")},{value:"sse",label:s("config.options.mcp.sse")},{value:"http",label:s("config.options.mcp.http")}],onChange:u=>{const p={...n};u==="command"?(delete p.type,p.command==null&&(p.command=""),p.args==null&&(p.args=[]),delete p.url,delete p.headers):(p.type=u,p.url==null&&(p.url=""),p.headers==null&&(p.headers={}),delete p.command,delete p.args),i(p)}})}),t==="command"&&e.jsxs(e.Fragment,{children:[e.jsx(le,{title:s("config.fields.mcpServer.command.label"),description:s("config.fields.mcpServer.command.desc"),icon:ae("string"),children:e.jsx(re,{value:typeof n.command=="string"?n.command:"",onChange:u=>{i({...n,command:u.target.value})},placeholder:s("config.editor.commandPlaceholder")})}),e.jsx(le,{title:s("config.fields.mcpServer.args.label"),description:s("config.fields.mcpServer.args.desc"),icon:ae("array"),layout:"stacked",children:e.jsx(Dn,{value:m,onChange:u=>{i({...n,args:u})},t:s})})]}),t!=="command"&&e.jsxs(e.Fragment,{children:[e.jsx(le,{title:s("config.fields.mcpServer.url.label"),description:s("config.fields.mcpServer.url.desc"),icon:ae("string"),children:e.jsx(re,{value:typeof n.url=="string"?n.url:"",onChange:u=>{i({...n,url:u.target.value})},placeholder:s("config.editor.urlPlaceholder")})}),e.jsx(le,{title:s("config.fields.mcpServer.headers.label"),description:s("config.fields.mcpServer.headers.desc"),icon:ae("object"),layout:"stacked",children:e.jsx(fn,{value:c,onChange:u=>{i({...n,headers:u})},t:s,keyPlaceholder:s("config.editor.newHeaderName")})})]}),e.jsx(le,{title:s("config.fields.mcpServer.env.label"),description:s("config.fields.mcpServer.env.desc"),icon:ae("object"),layout:"stacked",children:e.jsx(fn,{value:o,onChange:u=>{i({...n,env:u})},t:s,keyPlaceholder:s("config.editor.newEnvVarName")})})]})},Tn=(...n)=>n.filter(Boolean).join(" "),ss=n=>e.jsx(ne,{title:n.title,children:e.jsx(L,{size:"small",type:n.type??"text",danger:n.danger,className:"config-view__icon-button config-view__icon-button--compact config-view__detail-action-btn","aria-label":n.ariaLabel,icon:n.icon,loading:n.loading,disabled:n.disabled,onClick:n.onClick})},n.key),po=({actions:n})=>n.length===0?null:e.jsx("div",{className:"config-view__record-actions",children:n.map(ss)}),go=({children:n,className:i})=>e.jsx("div",{className:Tn("config-view__record-list",i),children:n}),vo=({actions:n,className:i,disabled:s,hint:t,onSubmit:o,onValueChange:c,placeholder:m,value:u})=>e.jsxs("div",{className:"config-view__record-add",children:[e.jsxs("div",{className:Tn("config-view__record-add-inputs",i),children:[e.jsx(re,{value:u,disabled:s,onChange:p=>c(p.target.value),placeholder:m,onPressEnter:o}),n.map(ss)]}),t]}),fi=({actions:n=[],className:i,descriptions:s=[],icon:t,onClick:o,rightSlot:c,subtitle:m,title:u})=>{const p=e.jsxs("div",{className:Tn("config-view__record-heading",t!=null&&"has-adapter-icon"),children:[t,e.jsxs("div",{className:"config-view__record-heading-text",children:[e.jsx("div",{className:"config-view__record-title",children:u}),m!=null&&m!==""&&e.jsx("div",{className:"config-view__record-subtitle",children:m}),s.map((a,g)=>a==null||a===""?null:e.jsx("div",{className:"config-view__record-desc",children:a},g))]})]});return e.jsx("div",{className:Tn("config-view__record-card",i),children:e.jsxs("div",{className:"config-view__detail-list-row",children:[o==null?e.jsx("div",{className:"config-view__detail-list-main",children:p}):e.jsx("button",{type:"button",className:"config-view__detail-list-main",onClick:o,children:p}),c,e.jsx(po,{actions:n})]})})},Qe=n=>typeof n=="string"&&n.trim()!==""?n.trim():void 0,ze=n=>n!=null&&typeof n=="object"&&!Array.isArray(n),ho=n=>{const i=n.trim().toLowerCase().replace(/[^a-z0-9]+/gu,"-").replace(/^-+|-+$/gu,"");return i===""?"token":i},_o=(n,i,s)=>{const t=ho(n);if(i[t]==null&&s[t]==null)return t;for(let o=2;o<100;o+=1){const c=`${t}-${o}`;if(i[c]==null&&s[c]==null)return c}return`${t}-${Date.now()}`},pi=(n,i,s)=>n==null?s("config.modelServices.management.unknown",{defaultValue:"-"}):In(i,String(n)),gi=(n,i)=>n===1?i("config.modelServices.management.tokenStatus.enabled",{defaultValue:"启用"}):n===2?i("config.modelServices.management.tokenStatus.disabled",{defaultValue:"停用"}):n===3?i("config.modelServices.management.tokenStatus.expired",{defaultValue:"过期"}):i("config.modelServices.management.tokenStatus.unknown",{defaultValue:"未知"}),xo=(n,i)=>{const s=new Set;for(const t of n)s.add(t.id);for(const t of i){const o=Qe(t.group);o!=null&&s.add(o)}return Array.from(s).map(t=>({label:t,value:t}))},vi=(n,i,s)=>{if(!ze(n))return s==="title"?i:"";const t=n[s];return typeof t=="string"&&t.trim()!==""?t.trim():s==="title"?i:""},yo=n=>{if(!(!ze(n)||!ze(n.extra)))return Qe(n.extra.newapiTokenId)??Qe(n.extra.tokenId)},hi=(n,i)=>{const s=ze(n.extra)?n.extra:{};return{...n,extra:{...s,...i.group==null?{}:{group:i.group},newapiTokenId:i.id}}},jn=({onOpenApiKey:n,onOpenApiKeysTab:i,onOpenProfile:s,onProfilesChange:t,profileKey:o,profiles:c,readOnly:m,resolvedProfiles:u,service:p,serviceKey:a,source:g,t:l,tokenId:f,view:h="profiles"})=>{var He,Ue,Je;const{message:x}=pn.useApp(),j=w.useMemo(()=>ni(p),[p]),[_,d]=w.useState(),[N,C]=w.useState(""),[Q,P]=w.useState(!1),[A,Y]=w.useState(""),[I,G]=w.useState({name:"",quota:null,unlimited:!0}),{data:B,isLoading:T,mutate:Z}=Vn(["model-service-management",a,g,j],([,r,b,k])=>js(r,{service:k,source:b}),{keepPreviousData:!0,revalidateOnFocus:!1}),$=(B==null?void 0:B.management)??null,je=($==null?void 0:$.groups)??[],te=($==null?void 0:$.tokens)??[],Ie=w.useMemo(()=>xo(je,te),[je,te]),he=((He=$==null?void 0:$.account)==null?void 0:He.kind)==="balance"?$.account:void 0,be=w.useMemo(()=>Array.from(new Set([...Object.keys(u),...Object.keys(c)])).sort((b,k)=>b.localeCompare(k)).map(b=>{const k=c[b],O=u[b],q=ze(k)?k:O;return{description:vi(q,b,"description"),isLocal:ze(k),key:b,title:vi(q,b,"title"),tokenId:yo(q)}}),[c,u]),_e=w.useMemo(()=>{const r=be.filter(b=>b.tokenId!=null).map(b=>[b.tokenId,b.key]);return new Map(r)},[be]),v=w.useMemo(()=>new Map(be.map(r=>[r.key,r])),[be]),we=w.useMemo(()=>new Map(te.map(r=>[r.id,r])),[te]),Ne=w.useMemo(()=>te.map(r=>({label:r.name??r.key??r.id,value:r.id})),[te]),S=te[0],V=((Ue=je[0])==null?void 0:Ue.id)??te.map(r=>Qe(r.group)).find(Boolean),H=o==null?void 0:v.get(o),E=f==null?void 0:we.get(f),ue=h==="profiles"?be:[],W=h==="apiKeys"?te:[],X=w.useCallback(async(r,b)=>{d(r);try{return await b()}catch(k){x.error(cn(k,l("config.modelServices.management.actionFailed",{defaultValue:"平台管理操作失败"})));return}finally{d(void 0)}},[x,l]);w.useEffect(()=>{E!=null&&G({group:E.group,name:E.name??E.id,quota:E.quota??E.remaining??null,status:E.status,unlimited:E.unlimited===!0})},[E]);const pe=async r=>{var k;if(r==="")return;const b=await X("create-token",()=>bs(a,{group:V,name:r,unlimited:!0},{service:j,source:g}));b!=null&&(x.success(l("config.modelServices.management.createApiKeySuccess",{defaultValue:"令牌已创建"})),await Z(),((k=b.result.token)==null?void 0:k.id)!=null&&(n==null||n(b.result.token.id)))},$e=async r=>{if(r==="")return;if(S==null){x.warning(l("config.modelServices.management.noApiKeyForProfile",{defaultValue:"请先创建远端令牌。"})),i==null||i();return}const b=await X(`create-profile:${S.id}`,()=>ti(a,S.id,{service:j,source:g}));if(b==null)return;const k={...hi(b.profile,S),title:r},O=_o(r,c,u);t({...c,[O]:k}),C(""),x.success(l("config.modelServices.management.createSuccess",{defaultValue:"配置档案已创建"})),s(O)},Ae=async r=>{const b=r.trim();b!==""&&(h==="apiKeys"?await pe(b):await $e(b),C(""),Y(""),P(!1))},Be=async(r,b)=>{const k=we.get(b);if(k==null)return;const O=await X(`bind-profile:${r}:${k.id}`,()=>ti(a,k.id,{service:j,source:g}));if(O==null)return;const q=c[r],ie=u[r],xe=ze(q)?q:ze(ie)?ie:{},ge=hi(O.profile,k),se=ze(ge.extra)?ge.extra:{},ee=ze(xe.extra)?xe.extra:{},me={...ge,...xe,apiKey:ge.apiKey,extra:{...se,...ee,...k.group==null?{}:{group:k.group},newapiTokenId:k.id}};t({...c,[r]:me}),x.success(l("config.modelServices.management.bindSuccess",{defaultValue:"远端令牌已绑定"}))},Ee=async()=>{if(E==null)return;const r=Qe(I.name);await X(`update-token:${E.id}`,()=>ws(a,E.id,{group:Qe(I.group),name:r,quota:I.unlimited?void 0:I.quota??void 0,status:I.status,unlimited:I.unlimited},{service:j,source:g}))!=null&&(x.success(l("config.modelServices.management.updateSuccess",{defaultValue:"令牌已更新"})),await Z())},Oe=async r=>{if(await X(`delete-token:${r.id}`,()=>Ns(a,r.id,{service:j,source:g}))==null)return;const k=_e.get(r.id);if(k!=null&&c[k]!=null){const O={...c};delete O[k],t(O)}x.success(l("config.modelServices.management.deleteApiKeySuccess",{defaultValue:"令牌已删除"})),await Z()},Ke=r=>{const b={...c};delete b[r],t(b)};return h==="profileDetail"?e.jsx("div",{className:"config-view__newapi-management",children:e.jsxs("div",{className:"config-view__field-list",children:[e.jsxs("div",{className:"config-view__field-row",children:[e.jsxs("div",{className:"config-view__field-meta",children:[e.jsx("span",{className:"material-symbols-rounded config-view__field-icon",children:"vpn_key"}),e.jsxs("div",{className:"config-view__field-text",children:[e.jsx("div",{className:"config-view__field-title",children:l("config.modelServices.management.selectApiKey",{defaultValue:"选择远端令牌"})}),e.jsx("div",{className:"config-view__field-desc",children:(H==null?void 0:H.tokenId)==null?l("config.modelServices.management.unboundProfile",{defaultValue:"未选择远端令牌"}):l("config.modelServices.management.boundProfile",{defaultValue:"远端令牌:{{key}}",key:((Je=we.get(H.tokenId))==null?void 0:Je.name)??H.tokenId})})]})]}),e.jsx("div",{className:"config-view__field-control",children:Ne.length>0?e.jsx(De,{options:Ne,value:H==null?void 0:H.tokenId,disabled:m||o==null,placeholder:l("config.modelServices.management.selectApiKey",{defaultValue:"选择远端令牌"}),onChange:r=>{const b=Qe(r);o!=null&&b!=null&&Be(o,b)}}):e.jsx(L,{size:"small",onClick:i,disabled:m,children:l("config.modelServices.management.createApiKeyFirst",{defaultValue:"创建令牌"})})})]}),o!=null&&c[o]!=null&&!m&&e.jsxs("div",{className:"config-view__field-row",children:[e.jsxs("div",{className:"config-view__field-meta",children:[e.jsx("span",{className:"material-symbols-rounded config-view__field-icon",children:"delete"}),e.jsxs("div",{className:"config-view__field-text",children:[e.jsx("div",{className:"config-view__field-title",children:l("common.delete")}),e.jsx("div",{className:"config-view__field-desc",children:l("config.modelServices.management.deleteProfileDesc",{defaultValue:"删除这个本地配置档案,不会删除远端令牌。"})})]})]}),e.jsx("div",{className:"config-view__field-control",children:e.jsx(L,{danger:!0,size:"small",onClick:()=>Ke(o),children:l("common.delete")})})]})]})}):h==="apiKeyDetail"?E==null?e.jsx("div",{className:"config-view__detail-list-empty",children:e.jsx("div",{className:"config-view__detail-list-empty-title",children:T?l("config.modelServices.management.loading",{defaultValue:"正在加载平台数据"}):l("common.noData")})}):e.jsx("div",{className:"config-view__newapi-management",children:e.jsxs("div",{className:"config-view__field-list",children:[e.jsxs("div",{className:"config-view__field-row",children:[e.jsxs("div",{className:"config-view__field-meta",children:[e.jsx("span",{className:"material-symbols-rounded config-view__field-icon",children:"badge"}),e.jsxs("div",{className:"config-view__field-text",children:[e.jsx("div",{className:"config-view__field-title",children:l("config.modelServices.management.name",{defaultValue:"名称"})}),e.jsx("div",{className:"config-view__field-desc",children:E.key})]})]}),e.jsx("div",{className:"config-view__field-control",children:e.jsx(re,{value:I.name,disabled:m,onChange:r=>G(b=>({...b,name:r.target.value}))})})]}),e.jsxs("div",{className:"config-view__field-row",children:[e.jsxs("div",{className:"config-view__field-meta",children:[e.jsx("span",{className:"material-symbols-rounded config-view__field-icon",children:"groups"}),e.jsxs("div",{className:"config-view__field-text",children:[e.jsx("div",{className:"config-view__field-title",children:l("config.modelServices.management.groups",{defaultValue:"分组"})}),e.jsx("div",{className:"config-view__field-desc",children:l("config.modelServices.management.groupDesc",{defaultValue:"令牌使用的 New API 分组。"})})]})]}),e.jsx("div",{className:"config-view__field-control",children:e.jsx(De,{allowClear:!0,options:Ie,value:I.group,disabled:m,placeholder:l("config.modelServices.management.groupPlaceholder",{defaultValue:"分组"}),onChange:r=>G(b=>({...b,group:Qe(r)}))})})]}),e.jsxs("div",{className:"config-view__field-row",children:[e.jsxs("div",{className:"config-view__field-meta",children:[e.jsx("span",{className:"material-symbols-rounded config-view__field-icon",children:"account_balance_wallet"}),e.jsxs("div",{className:"config-view__field-text",children:[e.jsx("div",{className:"config-view__field-title",children:l("config.modelServices.management.quotaPlaceholder",{defaultValue:"额度"})}),e.jsx("div",{className:"config-view__field-desc",children:I.unlimited?l("config.modelServices.management.unlimited",{defaultValue:"不限额"}):pi(I.quota??void 0,he==null?void 0:he.currency,l)})]})]}),e.jsxs("div",{className:"config-view__field-control config-view__newapi-management-inline-control",children:[e.jsx(Ye,{size:"small",checked:I.unlimited,disabled:m,onChange:r=>G(b=>({...b,unlimited:r}))}),e.jsx(Pn,{min:0,precision:2,value:I.quota,disabled:m||I.unlimited,placeholder:l("config.modelServices.management.quotaPlaceholder",{defaultValue:"额度"}),onChange:r=>G(b=>({...b,quota:typeof r=="number"?r:null}))})]})]}),e.jsxs("div",{className:"config-view__field-row",children:[e.jsxs("div",{className:"config-view__field-meta",children:[e.jsx("span",{className:"material-symbols-rounded config-view__field-icon",children:"toggle_on"}),e.jsxs("div",{className:"config-view__field-text",children:[e.jsx("div",{className:"config-view__field-title",children:l("config.modelServices.management.status",{defaultValue:"状态"})}),e.jsx("div",{className:"config-view__field-desc",children:gi(I.status,l)})]})]}),e.jsx("div",{className:"config-view__field-control",children:e.jsx(De,{value:I.status,disabled:m,options:[{label:l("config.modelServices.management.tokenStatus.enabled",{defaultValue:"启用"}),value:1},{label:l("config.modelServices.management.tokenStatus.disabled",{defaultValue:"停用"}),value:2}],onChange:r=>G(b=>({...b,status:r}))})})]}),!m&&e.jsxs("div",{className:"config-view__newapi-management-detail-actions",children:[e.jsx(L,{type:"primary",size:"small",loading:_===`update-token:${E.id}`,onClick:()=>void Ee(),children:l("config.actions.save")}),e.jsx(Fn,{title:l("config.modelServices.management.deleteApiKeyConfirm",{defaultValue:"删除这个远端令牌?"}),okText:l("common.delete"),cancelText:l("common.cancel"),onConfirm:()=>void Oe(E),children:e.jsx(L,{danger:!0,size:"small",loading:_===`delete-token:${E.id}`,children:l("common.delete")})})]})]})}):e.jsxs("div",{className:"config-view__newapi-management",children:[!m&&e.jsx(vo,{value:N,onValueChange:C,placeholder:l(h==="apiKeys"?"config.modelServices.management.newApiKeyName":"config.modelServices.management.newTokenName",{defaultValue:h==="apiKeys"?"新建令牌名称":"新建配置档案名称"}),className:"config-view__newapi-management-create",onSubmit:()=>void Ae(N),actions:[{ariaLabel:l("config.modelServices.management.dialogCreate",{defaultValue:"对话创建"}),disabled:h==="profiles"&&te.length===0,icon:e.jsx("span",{className:"material-symbols-rounded",children:"edit_square"}),key:"dialog-create",onClick:()=>{Y(N.trim()),P(!0)},title:l("config.modelServices.management.dialogCreate",{defaultValue:"对话创建"})},{ariaLabel:l("config.editor.addItem"),disabled:N.trim()===""||h==="profiles"&&te.length===0,icon:e.jsx("span",{className:"material-symbols-rounded",children:"add"}),key:"create",loading:_==="create-token"||(_==null?void 0:_.startsWith("create-profile:"))===!0,onClick:()=>void Ae(N),title:l("config.editor.addItem"),type:"primary"}],hint:h==="profiles"&&te.length===0&&e.jsxs("div",{className:"config-view__newapi-management-create-hint",children:[l("config.modelServices.management.noApiKeyForProfile",{defaultValue:"请先创建远端令牌。"}),e.jsx(L,{type:"link",size:"small",onClick:i,children:l("config.modelServices.management.createApiKeyFirst",{defaultValue:"创建令牌"})})]})}),e.jsxs(go,{children:[W.length===0&&ue.length===0?e.jsxs("div",{className:"config-view__detail-list-empty",children:[e.jsx("div",{className:"config-view__detail-list-empty-title",children:T?l("config.modelServices.management.loading",{defaultValue:"正在加载平台数据"}):l("common.noData")}),e.jsx("div",{className:"config-view__detail-list-empty-desc",children:l("config.modelServices.management.empty",{defaultValue:"暂无配置档案。"})})]}):W.map(r=>e.jsx(fi,{icon:e.jsx("span",{className:"material-symbols-rounded config-view__record-icon",children:"vpn_key"}),title:r.name??r.id,subtitle:[r.key,gi(r.status,l)].filter(Boolean).join(" · "),descriptions:[[r.group==null?void 0:l("config.modelServices.management.tokenGroup",{defaultValue:"分组:{{group}}",group:r.group}),r.unlimited===!0?l("config.modelServices.management.unlimited",{defaultValue:"不限额"}):l("config.modelServices.management.tokenQuota",{amount:pi(r.remaining,he==null?void 0:he.currency,l),defaultValue:"额度:{{amount}}"})].filter(Boolean).join(" · ")],onClick:()=>n==null?void 0:n(r.id)},r.id)),ue.map(r=>{var b;return e.jsx(fi,{icon:e.jsx("span",{className:"material-symbols-rounded config-view__record-icon",children:"account_tree"}),title:r.title,subtitle:r.key,descriptions:[r.description,r.tokenId==null?l("config.modelServices.management.unboundProfile",{defaultValue:"未选择远端令牌"}):l("config.modelServices.management.boundProfile",{defaultValue:"远端令牌:{{key}}",key:((b=we.get(r.tokenId))==null?void 0:b.name)??r.tokenId})],onClick:()=>s(r.key)},`profile:${r.key}`)})]}),e.jsx(Fi,{open:Q,title:l(h==="apiKeys"?"config.modelServices.management.createApiKeyTitle":"config.modelServices.management.createProfileTitle",{defaultValue:h==="apiKeys"?"创建令牌":"创建配置档案"}),okText:l("common.confirm"),cancelText:l("common.cancel"),confirmLoading:_==="create-token"||(_==null?void 0:_.startsWith("create-profile:"))===!0,okButtonProps:{disabled:A.trim()===""||h==="profiles"&&te.length===0},onCancel:()=>P(!1),onOk:()=>void Ae(A),children:e.jsx(re,{value:A,placeholder:l(h==="apiKeys"?"config.modelServices.management.newApiKeyName":"config.modelServices.management.newTokenName",{defaultValue:h==="apiKeys"?"新建令牌名称":"新建配置档案名称"}),onChange:r=>Y(r.target.value),onPressEnter:()=>void Ae(A)})})]})},jo=({headerActions:n,moreActions:i=[],providerTitle:s,service:t,serviceStatus:o,t:c})=>{const m=i.map(u=>({icon:e.jsx("span",{className:"material-symbols-rounded",children:u.icon}),key:u.key,label:u.label}));return e.jsxs("div",{className:"config-view__model-service-action-header",children:[e.jsxs("div",{className:"config-view__model-service-action-title",children:[Ki({icon:Ei(t),imageClassName:"config-view__model-service-action-icon",symbolClassName:"config-view__model-service-action-icon"}),e.jsx("div",{className:"config-view__model-service-action-title-text",children:e.jsx("div",{children:s})})]}),e.jsxs("div",{className:"config-view__model-service-action-header-actions",children:[n,o!=null&&e.jsx("span",{className:Ks(o.indicator),children:c(`config.modelServices.status.${o.indicator}`,{defaultValue:o.indicator})}),i.length>0&&e.jsx(ne,{title:c("config.modelServices.actions.more"),children:e.jsx(us,{trigger:["click"],placement:"bottomRight",menu:{items:m,onClick:({key:u})=>{var p;(p=i.find(a=>a.key===u))==null||p.onClick()}},children:e.jsx(L,{className:"config-view__model-service-more-button",size:"small",type:"text","aria-label":c("config.modelServices.actions.more"),icon:e.jsx("span",{className:"material-symbols-rounded",children:"more_horiz"})})})})]})]})},bo=({canCreateSecret:n,homepageUrl:i,loadingAction:s,onHomepage:t,onSecret:o,secretActionLabel:c,t:m})=>i==null&&!n?null:e.jsxs("div",{className:"config-view__model-service-action-buttons",children:[i!=null&&e.jsx(ne,{title:m("config.modelServices.actions.openHomepage"),children:e.jsx(L,{size:"small","aria-label":m("config.modelServices.actions.openHomepage"),icon:e.jsx("span",{className:"material-symbols-rounded",children:"web_asset"}),onClick:()=>t(i)})}),n&&e.jsx(ne,{title:c,children:e.jsx(L,{size:"small","aria-label":c,icon:e.jsx("span",{className:"material-symbols-rounded",children:"vpn_key"}),loading:s==="secret",onClick:o})})]}),wo=({accountStatus:n,identity:i,models:s,serviceStatus:t,t:o})=>{var m,u;const c=Ji(s);return n==null&&t==null&&c.length===0&&!((m=i.warnings)!=null&&m.length)?null:e.jsxs("div",{className:"config-view__model-service-action-results",children:[n!=null&&e.jsxs("div",{className:"config-view__model-service-result",children:[e.jsx("span",{children:Es(n,o)}),e.jsx("strong",{children:Rn(n,o)})]}),t!=null&&e.jsxs("div",{className:"config-view__model-service-result",children:[e.jsx("span",{children:o("config.modelServices.results.status")}),e.jsx("strong",{children:Os(t,o)})]}),c.length>0&&e.jsxs("div",{className:"config-view__model-service-models",children:[e.jsx("span",{children:o("config.modelServices.results.models",{count:c.length})}),e.jsxs("div",{className:"config-view__model-service-model-list",children:[c.slice(0,12).map(p=>e.jsx("code",{children:p},p)),c.length>12&&e.jsx("span",{children:o("config.modelServices.results.modelsMore",{count:c.length-12})})]})]}),(u=i.warnings)==null?void 0:u.map(p=>e.jsx("div",{className:"config-view__model-service-warning",children:p},p))]})},No=({item:n,onOpenPortal:i,serviceKey:s,source:t,t:o})=>{var H,E,ue;const{message:c}=pn.useApp(),m=w.useMemo(()=>ni(n),[n]),u=Di(m),p=u.provider==null?void 0:Bi(u.provider),a=(p==null?void 0:p.title)??u.provider??o("config.options.modelProviders.custom"),g=un(Oi(m)),l=Xn(m),f=Bn(m),h=((H=m.management)==null?void 0:H.enabled)!==!1,x=p==null?void 0:p.capabilities,j=Ri(x,h),_=(((E=f==null?void 0:f.defaultModels)==null?void 0:E.length)??0)>0||(((ue=p==null?void 0:p.defaultModels)==null?void 0:ue.length)??0)>0,d=(x==null?void 0:x.secrets)==="manual"?o("config.modelServices.actions.openApiKeys"):o("config.modelServices.actions.createSecret"),[N,C]=w.useState(),[Q,P]=w.useState([]),[A,Y]=w.useState(null),[I,G]=w.useState(null),[B,T]=w.useState(null),Z=w.useRef(null);w.useMemo(()=>Ji(Q),[Q]);const $=Wi(s,t,m),te=f!=null||(l==null?void 0:l.kind)!=null||j.canQueryBalance,Ie=te&&j.canQueryBalance;w.useEffect(()=>{const W=rn($);P([]),Y(W),G(null),T(null)},[$]);const he=w.useCallback(async(W,X,pe)=>{C(W);try{return await X()}catch($e){(pe==null?void 0:pe.silent)!==!0&&c.error(cn($e,o("config.modelServices.results.actionFailed")));return}finally{C(void 0)}},[c,o]),be=w.useCallback(async W=>await he("external",async()=>Hi(W)),[he]),_e=w.useCallback((W,X=a)=>{const pe=un(W);pe!=null&&(i==null||i({title:X,url:pe}))},[i,a]),v=async()=>{const W=await he("models",()=>_s(s,{service:m,source:t}));if(W!=null)return P(W.models),c.success(o("config.modelServices.results.modelsLoaded",{count:W.models.length})),W.models},we=w.useCallback(async W=>{G(null);const X=await he("balance",()=>Li(s,{service:m,source:t}),W);if(X==null){G(o("config.modelServices.plan.liveQuota.failed"));return}Xi($,X.account),Y(X.account)},[he,m,$,s,t,o]),Ne=async()=>{const W=await he("status",()=>xs(s,{service:m,source:t}));W!=null&&T(W.status)},S=async()=>{var pe;const W=await he("secret",()=>ys(s,{service:m,source:t}));if(W==null)return;const X=W.secret;if(X.kind==="console"){_e(X.url,o("config.modelServices.portal.secretTitle",{provider:a}));return}if(X.kind==="created"){(pe=navigator.clipboard)==null||pe.writeText(X.value),c.success(o("config.modelServices.results.secretCreated"));return}c.info(X.reason)};w.useEffect(()=>{if(!Ie)return;const W=rn($);if(W!=null){Y(W),G(null);return}Z.current!==$&&(Z.current=$,we({silent:!0}))},[Ie,we,$]);const V=[...!te&&j.canQueryBalance?[{icon:"account_balance_wallet",key:"balance",label:o("config.modelServices.actions.queryBalance"),onClick:()=>void we()}]:[],...j.canQueryStatus?[{icon:"cloud_sync",key:"status",label:o("config.modelServices.actions.queryStatus"),onClick:()=>void Ne()}]:[],...!_&&j.canQueryModels?[{icon:"view_list",key:"models",label:o("config.modelServices.actions.queryModels"),onClick:()=>void v()}]:[],...Gs({service:m,t:o}).map(W=>({icon:"open_in_browser",key:`plan:${W.url}`,label:W.label,onClick:()=>_e(W.url,W.label)})),...g==null?[]:[{icon:"open_in_new",key:`external:${g}`,label:o("config.modelServices.actions.openExternal"),onClick:()=>void be(g)}]];return e.jsxs("div",{className:"config-view__model-service-actions",children:[e.jsx(jo,{headerActions:e.jsx(bo,{canCreateSecret:j.canCreateSecret,homepageUrl:g,loadingAction:N,onHomepage:_e,onSecret:()=>void S(),secretActionLabel:d,t:o}),moreActions:V,providerTitle:a,service:m,serviceStatus:B,t:o}),e.jsx(qs,{accountError:I,accountStatus:A,canQueryBalance:j.canQueryBalance,loadingBalance:N==="balance",service:m,t:o}),e.jsx(wo,{accountStatus:te?null:A,identity:u,models:Q,serviceStatus:B,t:o})]})},zn=n=>n!=null&&typeof n=="object"&&!Array.isArray(n),So=({value:n,onChange:i,mergedModelServices:s,t})=>{const o=zn(n)?n:{},c=typeof o.service=="string"?o.service:void 0,m=Object.entries(s).map(([g,l])=>{const f=zn(l)?l:{},h=typeof f.title=="string"&&f.title.trim()!==""?f.title:g;return{value:g,label:h}}),u=c!=null&&zn(s[c])?s[c]:void 0,p=Array.isArray(u==null?void 0:u.models)?u.models.filter(g=>typeof g=="string"):[],a=g=>{i({...o,...g})};return e.jsxs("div",{className:"config-view__field-stack",children:[e.jsx(le,{title:t("config.fields.general.recommendedModels.item.service.label"),description:t("config.fields.general.recommendedModels.item.service.desc"),icon:ae("string"),children:e.jsx(De,{value:c,options:m,onChange:g=>{a({service:g,model:void 0})},allowClear:!0,placeholder:t("config.editor.defaultModelServicePlaceholder")})}),e.jsx(le,{title:t("config.fields.general.recommendedModels.item.model.label"),description:t("config.fields.general.recommendedModels.item.model.desc"),icon:ae("string"),children:p.length>0?e.jsx(De,{value:typeof o.model=="string"&&o.model!==""?o.model:void 0,options:p.map(g=>({value:g,label:g})),onChange:g=>a({model:g}),allowClear:!0,placeholder:t("config.editor.defaultModelPlaceholder")}):e.jsx(re,{value:typeof o.model=="string"?o.model:"",onChange:g=>a({model:g.target.value}),placeholder:t("config.editor.defaultModelPlaceholder")})}),e.jsx(le,{title:t("config.fields.general.recommendedModels.item.title.label"),description:t("config.fields.general.recommendedModels.item.title.desc"),icon:ae("string"),children:e.jsx(re,{value:typeof o.title=="string"?o.title:"",onChange:g=>a({title:g.target.value}),placeholder:t("config.editor.titlePlaceholder")})}),e.jsx(le,{title:t("config.fields.general.recommendedModels.item.description.label"),description:t("config.fields.general.recommendedModels.item.description.desc"),icon:ae("string"),layout:"stacked",children:e.jsx(re.TextArea,{value:typeof o.description=="string"?o.description:"",onChange:g=>a({description:g.target.value}),autoSize:{minRows:4},placeholder:t("config.editor.descriptionPlaceholder")})}),e.jsx(le,{title:t("config.fields.general.recommendedModels.item.placement.label"),description:t("config.fields.general.recommendedModels.item.placement.desc"),icon:ae("string"),children:e.jsx(De,{value:o.placement,options:[{value:"modelSelector",label:t("config.options.recommendedModels.modelSelector")}],onChange:g=>a({placement:g}),allowClear:!0})})]})},_i=new Set(["models"]),ko=new Set(["modelServices","channels","adapters"]),xi=new Set(["shortcuts"]),Co=["base","permissions","env","items","default"],Se=n=>n!=null&&typeof n=="object"&&!Array.isArray(n),Ce=(n,i)=>n.length===1&&n[0]===i,Sn=n=>n.path.join("."),Po=new Set(["apiBaseUrl","apiKey","models","profiles","timeoutMs","maxOutputTokens","extra"]),yi=new Set(["provider","title","description"]),Ao=new Set(["title","description","apiBaseUrl","apiKey","models","timeoutMs","maxOutputTokens","extra"]),Un=n=>({...n,group:"default",resolveGroup:void 0,collapse:void 0}),$n=n=>{if(!Se(n))return{};const i=Pe(n,["profiles"]);if(Se(i))return i;const s=Pe(n,["services"]);return Se(s)?s:{}},ji=n=>Se(n)&&typeof n.provider=="string"&&n.provider.trim()!=="",bn=(n,i)=>{const s=Pe(n,i);return typeof s=="string"&&s.trim()!==""?s.trim():void 0},Mo=(n,i)=>{const s=bn(n,["management","endpointKind"])??bn(i,["management","endpointKind"]),t=bn(n,["provider"])??bn(i,["provider"]);return s==="newapi"||t==="micu"},Io=(n,i)=>{const s=Se(n)?n:{},t=Se(i)?i:{};return s.kind==="collection"||t.kind==="collection"||Object.keys($n(s)).length>0||Object.keys($n(t)).length>0},To=(n,i)=>{const s=Se(n)?{...n}:{};return s.profiles=i,delete s.services,s},bi=(n,i,s)=>{if(!Se(n))return s==="title"?i:"";const t=n[s];return typeof t=="string"&&t.trim()!==""?t.trim():s==="title"?i:""},$o={advanced:["advanced"],apiKeys:["api-keys"],profiles:["profiles"],service:[]},Vo={access:["access"],advanced:["advanced"],display:["display"],models:["models"],plan:["plan"],service:[]},Fo=n=>{const i=n==null?void 0:n[0];return i==="profiles"?"profiles":i==="api-keys"?"apiKeys":i==="advanced"?"advanced":"service"},Do=n=>{const i=n==null?void 0:n[0];return i==="access"?"access":i==="advanced"?"advanced":i==="display"?"display":i==="models"?"models":i==="plan"?"plan":"service"},Bo=(n,i,s)=>{var t;return n.hidden!==!0&&((t=n.visible)==null?void 0:t.call(n,{currentValue:i,currentResolvedValue:s}))!==!1},Eo=(n,i,s)=>{var c;if(Sn(n)==="kind")return"advanced";const o=((c=n.resolveGroup)==null?void 0:c.call(n,{currentValue:i,currentResolvedValue:s}))??n.group??"default";if(o==="profile")return"service";if(o==="access"||o==="providerAccess")return"access";if(o==="customization")return"display";if(o==="models")return"models";if(o!=="management"){if(o==="plan")return"plan";if(o==="advanced"||o==="default")return"advanced"}},tn=(n,i)=>e.jsxs("span",{className:"config-view__collection-tab-label",children:[e.jsx("span",{className:"material-symbols-rounded",children:n}),e.jsx("span",{children:i})]}),Oo=({sectionKey:n,fields:i,uiSection:s,value:t,resolvedValue:o,source:c="project",onChange:m,mergedModelServices:u,mergedAdapters:p,selectedModelService:a,worktreeEnvironmentOptions:g,workspaceFileOpenerOptions:l,detailRoute:f=null,onOpenDetailRoute:h,onOpenModelServicePortal:x,creatingModelServiceSessionKey:j,onCreateModelServiceSession:_,t:d})=>{var V,H,E,ue,W,X,pe,$e,Ae,Be,Ee,Oe,Ke,He,Ue,Je;const N=i??Si[n]??[],[C,Q]=w.useState(""),P={mergedModelServices:u,mergedAdapters:p,t:d},A=r=>(b,k)=>nn(d,r,b.path,k),Y=r=>(b,k)=>{const O=kn(d,r,b.path);return O!==""?O:k},I=({body:r,title:b,collapsible:k=!1,defaultExpanded:O=!0,collapseKey:q="section"})=>k?e.jsx(On,{className:"config-view__subsection-collapse",ghost:!0,expandIconPosition:"end",expandIcon:({isActive:ie})=>e.jsx("span",{className:`material-symbols-rounded config-view__subsection-expand-icon${ie?" is-active":""}`,children:"chevron_right"}),defaultActiveKey:O?[q]:[],items:[{key:q,label:e.jsx("div",{className:"config-view__subsection-title",children:b}),children:r}]}):e.jsxs("div",{className:"config-view__subsection",children:[b!=null&&b!==""&&e.jsx("div",{className:"config-view__subsection-title",children:b}),r]}),G=({schema:r,currentValue:b,onCurrentValueChange:k,visibleFieldPaths:O,title:q,collapsible:ie=!1,defaultExpanded:xe=!0,collapseKey:ge,resolveFieldOptions:se})=>O.length===0?null:I({title:q,collapsible:ie,defaultExpanded:xe,collapseKey:ge,body:e.jsx("div",{className:"config-view__subsection-body",children:e.jsx(Cn,{value:b,schema:r,onChange:k,t:d,visibleFieldPaths:O,resolveFieldLabel:A("adapters"),resolveFieldDescription:Y("adapters"),resolveFieldOptions:se})})}),B=({schema:r,currentValue:b,onCurrentValueChange:k,modelSection:O,advancedSections:q})=>{const ie=q.filter(se=>se.visibleFieldPaths.length>0),xe=O!=null&&O.visibleFieldPaths.length>0;if(!xe&&ie.length===0)return null;const ge=!xe&&ie.length>0;return e.jsxs("div",{className:"config-view__field-stack",children:[xe&&G({schema:r,currentValue:b,onCurrentValueChange:k,visibleFieldPaths:O.visibleFieldPaths,title:O.title,collapsible:!0,defaultExpanded:!0,collapseKey:"models"}),ie.length>0&&I({title:d("config.sectionGroups.advanced"),collapsible:!0,defaultExpanded:ge,collapseKey:"advanced",body:e.jsx("div",{className:"config-view__subsection-body",children:e.jsx("div",{className:"config-view__field-stack",children:ie.map(se=>e.jsx(w.Fragment,{children:G({schema:r,currentValue:b,onCurrentValueChange:k,visibleFieldPaths:se.visibleFieldPaths,title:se.title})},se.key))})})})]})};if((s==null?void 0:s.kind)==="recordMap"&&N.length===0){const r=t!=null&&typeof t=="object"?t:{};return s.recordMap.mode==="discriminated"&&(((V=s.recordMap.entryKinds)==null?void 0:V.length)??0)===0?e.jsx(Ln,{value:r,onChange:m,t:d,keyPlaceholder:d("config.editor.fieldKey")}):e.jsx(uo,{value:r,schema:s.recordMap,onChange:m,t:d,keyPlaceholder:s.recordMap.keyPlaceholder??d("config.editor.fieldKey")})}if(N.length===0)return e.jsx(dn,{description:d("common.noData"),image:null});const Z=Object.entries(u).map(([r,b])=>{const k=b!=null&&typeof b=="object"?b:{},O=typeof k.title=="string"&&k.title.trim()!==""?k.title:r,q=typeof k.description=="string"?k.description:"";return{value:r,label:e.jsxs("div",{className:"config-view__option",children:[e.jsx("div",{className:"config-view__option-title",children:O}),q!==""&&e.jsx("div",{className:"config-view__option-desc",children:q})]})}}),$=a?u[a]:void 0,je=$!=null&&typeof $=="object"?$.models:void 0,te=Array.isArray(je)?je.filter(r=>typeof r=="string").map(r=>({value:r,label:e.jsx("span",{children:r})})):[],Ie=Object.keys(p).map(r=>({value:r,label:e.jsx("span",{children:r})})),he=({fieldValue:r,fieldPath:b,onOverride:k})=>e.jsxs("div",{className:"config-view__field-readonly",children:[e.jsx("div",{className:"config-view__field-readonly-value",children:e.jsx(Nn,{value:r,sectionKey:n,path:b,t:d})}),k!=null&&e.jsx(L,{size:"small",onClick:k,children:d("config.detail.override")})]}),be=({field:r,currentValue:b,currentResolvedValue:k,onCurrentValueChange:O,keyPrefix:q,readOnly:ie=!1})=>{const xe=Pe(b,r.path),ge=Pe(k,r.path),se=xe!==void 0,ee=ge!==void 0,me=!se&&ee,ke=r.type==="string"||r.type==="multiline"||r.type==="number"||r.type==="boolean"||r.type==="select"||r.type==="shortcut",K=se?xe:ee&&ke?ge:r.defaultValue,F=r.labelKey?d(r.labelKey):nn(d,n,r.path,r.path[r.path.length-1]??""),z=r.descriptionKey?d(r.descriptionKey):kn(d,n,r.path),ce=r.icon??ae(Mi(K)),J=M=>{if(r.unsetWhenEmpty===!0){if(M===""){O(Fe(b,r.path,void 0));return}if(Array.isArray(M)&&M.length===0){O(Fe(b,r.path,void 0));return}}O(Fe(b,r.path,M))};let R=null;const oe=["multiline","json","record","string[]","detailCollection"].includes(r.type),ye=()=>{ee&&J(ge)};if(ie)R=e.jsx(Nn,{value:ee?ge:xe??r.defaultValue,sectionKey:n,path:r.path,t:d});else if(r.type==="detailCollection")R=e.jsx(ao,{sectionKey:n,field:r,value:xe,resolvedValue:ge,source:c,onChange:M=>J(M),onOpenDetail:M=>h==null?void 0:h(M),mergedModelServices:u,mergedAdapters:p,uiSection:s,creatingModelServiceSessionKey:j,onCreateModelServiceSession:_,t:d});else if(me&&!ke)R=he({fieldValue:ge,fieldPath:r.path,onOverride:ye});else if(r.type==="string"){const M=r.placeholderKey?d(r.placeholderKey):void 0;r.sensitive===!0?R=e.jsx(re.Password,{value:typeof K=="string"?K:"",onChange:y=>J(y.target.value),placeholder:d("config.editor.secretPlaceholder")}):R=e.jsx(re,{value:typeof K=="string"?K:"",onChange:y=>J(y.target.value),placeholder:M})}else if(r.type==="multiline"){const M=typeof K=="string"?K:"",y=r.placeholderKey?d(r.placeholderKey):d("config.editor.multilinePlaceholder");R=e.jsx("div",{className:"config-view__multiline",children:e.jsx(re.TextArea,{className:"config-view__multiline-input",value:M,onChange:de=>J(de.target.value),autoSize:{minRows:3},placeholder:y})})}else if(r.type==="number")if(r.path.join(".")==="notifications.volume"){const y=typeof K=="number"?K:0;R=e.jsx(hs,{className:"config-view__slider",min:0,max:100,step:1,value:y,onChange:de=>J(typeof de=="number"?de:0)})}else R=e.jsx(Pn,{value:typeof K=="number"?K:0,onChange:y=>J(typeof y=="number"?y:0)});else if(r.type==="boolean")R=e.jsx(Ye,{checked:!!K,onChange:M=>J(M)});else if(r.type==="string[]"){const M=Array.isArray(K)?K.filter(y=>typeof y=="string"):[];R=e.jsx(Dn,{value:M,onChange:y=>J(y),t:d})}else if(r.type==="select"){const M=n==="general"&&r.path.join(".")==="defaultAdapter",y=n==="general"&&r.path.join(".")==="defaultModelService",de=n==="general"&&r.path.join(".")==="defaultModel",U=n==="general"&&r.path.join(".")==="messageLinks.workspaceFileOpener",fe=n==="conversation"&&r.path.join(".")==="worktreeEnvironment",Le=n==="voice"&&r.path.join(".")==="speechToText.defaultServiceId",qe=Pe(b,["speechToText","services"]),gn=Pe(k,["speechToText","services"]),D=Se(qe)?qe:{},Ze={...Se(gn)?gn:{},...D},Xe=Object.keys(Ze).length>0?Object.entries(Ze).map(([Me,Ve])=>{const os=Ve!=null&&typeof Ve=="object"&&!Array.isArray(Ve)&&typeof Ve.label=="string"&&Ve.label.trim()!==""?Ve.label.trim():Me;return{value:Me,label:e.jsx("span",{children:os})}}):[],sn=y?Z:de?te:M?Ie:Le?Xe:U?l??[]:fe?g??[]:(r.options??[]).map(Me=>({value:Me.value,label:e.jsx("span",{children:d(Me.label)})}));R=e.jsx(De,{value:typeof K=="string"&&K!==""?K:void 0,options:sn,onChange:Me=>J(Me),allowClear:!0,disabled:de&&te.length===0,placeholder:d(M?"config.editor.defaultAdapterPlaceholder":y?"config.editor.defaultModelServicePlaceholder":U?"config.editor.workspaceFileOpenerPlaceholder":fe?"config.editor.worktreeEnvironmentPlaceholder":r.placeholderKey!=null?r.placeholderKey:"config.editor.defaultModelPlaceholder")})}else if(r.type==="json")R=e.jsx(mn,{value:K,onChange:J});else if(r.type==="record"){const M=K!=null&&typeof K=="object"?K:{};r.recordKind==="modelServices"?R=e.jsx(mo,{value:M,onChange:J,t:d,keyPlaceholder:en(n,r,d)}):r.recordKind==="channels"?R=e.jsx(Ln,{value:M,onChange:J,t:d,keyPlaceholder:en(n,r,d)}):r.recordKind==="mcpServers"?R=e.jsx(co,{value:M,onChange:J,t:d,keyPlaceholder:en(n,r,d)}):r.recordKind==="keyValue"?R=e.jsx(fn,{value:M,onChange:J,t:d,keyPlaceholder:en(n,r,d)}):r.recordKind==="boolean"?R=e.jsx(ro,{value:M,onChange:J,t:d,keyPlaceholder:en(n,r,d)}):R=e.jsx(Ln,{value:M,onChange:J,t:d,keyPlaceholder:en(n,r,d)})}else if(r.type==="shortcut"){const M=navigator.platform.includes("Mac"),y=typeof K=="string"?K:"",de=r.shortcutKind==="sendMessage";R=e.jsx(as,{value:y,displayValue:de?ps(y,M):void 0,onChange:U=>J(U),placeholder:d("config.editor.shortcutPlaceholder"),normalizeShortcut:de?U=>fs(U,M):void 0,isMac:M,t:d})}return _i.has(n)&&r.type==="record"?e.jsx("div",{children:R},`${q}:${r.path.join(".")}:${r.type}:${r.recordKind??""}`):ko.has(n)&&r.type==="detailCollection"&&r.path.length===0?e.jsx("div",{children:R},`${q}:${r.path.join(".")}:${r.type}`):e.jsx(le,{title:F,description:z,icon:ce,layout:oe?"stacked":"inline",children:R},`${q}:${r.path.join(".")}:${r.type}:${r.labelKey??""}:${r.recordKind??""}`)},_e=({currentFields:r,currentValue:b,currentResolvedValue:k,onCurrentValueChange:O,keyPrefix:q,readOnly:ie=!1})=>{const xe=F=>F.path.length>1?F.path[0]:void 0,ge=F=>F.map(z=>be({field:z,currentValue:b,currentResolvedValue:k,onCurrentValueChange:O,keyPrefix:q,readOnly:ie})),se=r.filter(F=>{var z;return F.hidden!==!0&&((z=F.visible)==null?void 0:z.call(F,{currentValue:b,currentResolvedValue:k}))!==!1}),ee=F=>{var J;const z=[];let ce=0;for(;ce<F.length;){const R=F[ce];if(R==null){ce+=1;continue}const oe=xe(R);if(oe==null){z.push(...ge([R])),ce+=1;continue}const ye=[];for(;ce<F.length;){const M=F[ce];if(M==null||xe(M)!==oe)break;ye.push(M),ce+=1}ye.length>1?z.push(e.jsx("div",{className:"config-view__field-list config-view__field-list--grouped",children:ge(ye)},`${q}:related:${oe}:${(J=ye[0])==null?void 0:J.path.join(".")}`)):z.push(...ge(ye))}return z},me=se.reduce((F,z)=>{var J;const ce=((J=z.resolveGroup)==null?void 0:J.call(z,{currentValue:b,currentResolvedValue:k}))??z.group??"default";return F[ce]||(F[ce]=[]),F[ce].push(z),F},{}),ke=(ts[n]??Co).filter(F=>{var z;return(z=me[F])==null?void 0:z.length}),K=ke.length>1;return e.jsx("div",{className:"config-view__field-stack",children:ke.map(F=>{var de;const z=me[F]??[];if(F==="default"){if(_i.has(n))return e.jsx("div",{children:z.map(fe=>be({field:fe,currentValue:b,currentResolvedValue:k,onCurrentValueChange:O,keyPrefix:q,readOnly:ie}))},`${q}:${F}`);const U=["config-view__field-list",xi.has(n)?"config-view__field-list--grouped":""].filter(Boolean).join(" ");return e.jsx("div",{className:U,children:xi.has(n)?ge(z):ee(z)},`${q}:${F}`)}const ce=(de=ls[n])==null?void 0:de[F],J=(()=>{const U=ce==null?void 0:ce.labelKey;return d(U||(F==="base"?"config.sectionGroups.base":F==="models"?"config.sectionGroups.models":F==="advanced"?"config.sectionGroups.advanced":F==="permissions"?"config.sectionGroups.permissions":F==="env"?"config.sectionGroups.env":n==="plugins"?"config.sectionGroups.plugins":"config.sectionGroups.items"))})(),R=z.filter(U=>U.collapse!=null),oe=z.filter(U=>U.collapse==null),ye=R.reduce((U,fe)=>{const Le=fe.collapse;if(!Le)return U;const qe=U.get(Le.key);return qe?qe.fields.push(fe):U.set(Le.key,{meta:Le,fields:[fe]}),U},new Map),M=Array.from(ye.values()).map(U=>({key:U.meta.key,collapsible:"header",label:e.jsxs("div",{className:"config-view__collapse-header",children:[e.jsxs("div",{className:"config-view__collapse-header-main",children:[e.jsx("div",{className:"config-view__collapse-title",children:d(U.meta.labelKey)}),U.meta.descKey&&e.jsx("div",{className:"config-view__collapse-desc",children:d(U.meta.descKey)})]}),U.meta.togglePath&&e.jsx(Ye,{checked:!Pe(b,U.meta.togglePath),onChange:fe=>{O(Fe(b,U.meta.togglePath,!fe))},disabled:ie,onClick:(fe,Le)=>{Le.stopPropagation()}})]}),children:e.jsx("div",{className:"config-view__field-list config-view__field-list--grouped",children:U.fields.map(fe=>be({field:fe,currentValue:b,currentResolvedValue:k,onCurrentValueChange:O,keyPrefix:q,readOnly:ie}))})})),y=e.jsxs("div",{className:"config-view__subsection-body",children:[oe.length>0&&e.jsx("div",{className:"config-view__field-list",children:ee(oe)}),M.length>0&&e.jsx(On,{className:"config-view__collapse-group config-view__field-row",ghost:!0,items:M})]});return(ce==null?void 0:ce.collapsible)===!0&&K?e.jsx(On,{className:"config-view__subsection-collapse",ghost:!0,expandIconPosition:"end",expandIcon:({isActive:U})=>e.jsx("span",{className:`material-symbols-rounded config-view__subsection-expand-icon${U?" is-active":""}`,children:"chevron_right"}),defaultActiveKey:ce.defaultExpanded===!1?[]:[F],items:[{key:F,label:e.jsx("div",{className:"config-view__subsection-title",children:J}),children:y}]},`${q}:${F}`):e.jsxs("div",{className:"config-view__subsection",children:[K&&e.jsx("div",{className:"config-view__subsection-title",children:J}),y]},`${q}:${F}`)})})},v=ns({sectionKey:n,fields:N,value:t,resolvedValue:o,route:f,detailContext:P,t:d}),we=n==="adapters"&&(s==null?void 0:s.kind)==="recordMap"&&(v==null?void 0:v.field.path.length)===0?v.itemKey:null,{data:Ne}=Vn(we!=null?`/api/adapters/${we}/accounts`:null,()=>Ci(we)),S=w.useMemo(()=>{if(we==null||!Se(v==null?void 0:v.item))return;const r=typeof v.item.defaultAccount=="string"&&v.item.defaultAccount.trim()!==""?v.item.defaultAccount.trim():void 0,b=Pe(v.item,["accounts"]),k=Se(b)?{...b}:{};return r!=null&&k[r]==null&&(k[r]={title:r}),Gi(k,(Ne==null?void 0:Ne.accounts)??[],r).map(O=>({value:O.key,label:O.title===O.key?O.key:`${O.title} (${O.key})`}))},[Ne==null?void 0:Ne.accounts,we,v==null?void 0:v.item]);if(v!=null){const r=v.field.detailCollection,b=r!=null&&(r.collectionKind!=="list"||r.getMergeKey!=null),k=se=>{if(v.field.type!=="detailCollection"||v.field.detailCollection==null)return;const ee=se!=null&&typeof se=="object"&&!Array.isArray(se)?se:{};if(v.field.detailCollection.collectionKind==="list"){const me=Pe(t,v.field.path),K=[...Array.isArray(me)?me.filter(F=>F!=null&&typeof F=="object"&&!Array.isArray(F)):[]];v.localItemIndex==null?K.push(ee):K[v.localItemIndex]=ee,m(Fe(t,v.field.path,K));return}m(Fe(t,[...v.field.path,v.itemKey],ee))},O=()=>{b&&k(v.resolvedItem)},q=n==="modelServices"&&v.field.path.length===0?e.jsx(No,{serviceKey:v.itemKey,source:c,item:v.itemSource==="inherited"?v.resolvedItem:v.item,onOpenPortal:x,t:d},`${c}:${v.itemKey}:${v.itemSource}`):null,ie=v.itemSource==="inherited"?e.jsxs("div",{className:"config-view__detail-notice",children:[e.jsx("div",{className:"config-view__detail-notice-text",children:d(b?"config.detail.inheritedReadonly":"config.detail.inheritedAppendOnly")}),b&&e.jsx(L,{size:"small",type:"primary",onClick:O,children:d("config.detail.override")})]}):v.hasResolvedOverlay?e.jsx("div",{className:"config-view__detail-notice",children:e.jsx("div",{className:"config-view__detail-notice-text",children:d("config.detail.partialOverride")})}):null,xe=n==="modelServices"&&v.field.path.length===0;if(xe&&Io(v.item,v.resolvedItem)){const se=((H=v.field.detailCollection)==null?void 0:H.itemFields)??[],ee=$n(v.item),me=$n(v.resolvedItem),ke=Array.from(new Set([...Object.keys(me),...Object.keys(ee)])).sort((D,ve)=>D.localeCompare(ve)),K=((E=f==null?void 0:f.nestedPath)==null?void 0:E[0])==="profiles"?f.nestedPath[1]:void 0,F=((ue=f==null?void 0:f.nestedPath)==null?void 0:ue[0])==="api-keys"?f.nestedPath[1]:void 0,z=v.itemSource==="inherited",ce=se.filter(D=>yi.has(Sn(D))).map(Un),J=se.filter(D=>{const ve=Sn(D);return!Po.has(ve)&&!yi.has(ve)}).map(Un),R=ji(v.item)||ji(v.resolvedItem),oe=Mo(v.item,v.resolvedItem),ye=se.filter(D=>{const ve=Sn(D);return R&&ve==="apiBaseUrl"||oe&&(ve==="apiKey"||ve==="extra")?!1:Ao.has(ve)}),M=D=>{k(To(v.item,D))},y=D=>{h==null||h({kind:(f==null?void 0:f.kind)??"detailCollectionItem",fieldPath:v.field.path,itemKey:v.itemKey,nestedPath:["profiles",D]})},de=D=>{h==null||h({kind:(f==null?void 0:f.kind)??"detailCollectionItem",fieldPath:v.field.path,itemKey:v.itemKey,nestedPath:["api-keys",D]})},U=D=>{h==null||h({kind:(f==null?void 0:f.kind)??"detailCollectionItem",fieldPath:v.field.path,itemKey:v.itemKey,nestedPath:[...$o[D]]})},fe=Fo(f==null?void 0:f.nestedPath),Le=e.jsxs("div",{className:"config-view__field-list",children:[ke.length>0?ke.map(D=>{const ve=ee[D],Ze=me[D],Xe=Se(ve)?ve:Ze,sn=bi(Xe,D,"title"),Me=bi(Xe,D,"description");return e.jsx("div",{className:"config-view__record-card",children:e.jsxs("div",{className:"config-view__detail-list-row",children:[e.jsx("button",{type:"button",className:"config-view__detail-list-main",onClick:()=>y(D),children:e.jsxs("div",{className:"config-view__record-heading",children:[e.jsx("span",{className:"material-symbols-rounded config-view__record-icon",children:"account_tree"}),e.jsxs("div",{className:"config-view__record-heading-text",children:[e.jsx("div",{className:"config-view__record-title",children:sn}),e.jsx("div",{className:"config-view__record-subtitle",children:D}),Me!==""&&e.jsx("div",{className:"config-view__record-desc",children:Me})]})]})}),!z&&e.jsx("div",{className:"config-view__record-actions",children:e.jsx(L,{size:"small",type:"text",className:"config-view__icon-button config-view__detail-action-btn","aria-label":d("common.delete"),icon:e.jsx("span",{className:"material-symbols-rounded",children:"delete"}),onClick:()=>{const Ve={...ee};delete Ve[D],M(Ve)}})})]})},D)}):e.jsxs("div",{className:"config-view__detail-list-empty",children:[e.jsx("div",{className:"config-view__detail-list-empty-title",children:d("common.noData")}),e.jsx("div",{className:"config-view__detail-list-empty-desc",children:d("config.fields.modelServices.item.profiles.desc")})]}),!z&&e.jsx("div",{className:"config-view__record-add",children:e.jsxs("div",{className:"config-view__record-add-inputs",children:[e.jsx(re,{value:C,onChange:D=>Q(D.target.value),placeholder:d("config.editor.newModelServiceName"),onPressEnter:()=>{const D=C.trim();if(D===""||ee[D]!=null||me[D]!=null)return;const ve={title:D};M({...ee,[D]:ve}),Q(""),y(D)}}),e.jsx(L,{size:"small",className:"config-view__icon-button",icon:e.jsx("span",{className:"material-symbols-rounded",children:"check"}),onClick:()=>{const D=C.trim();if(D===""||ee[D]!=null||me[D]!=null)return;const ve={title:D};M({...ee,[D]:ve}),Q(""),y(D)},disabled:C.trim()===""})]})})]});if(K!=null){const D=ee[K],ve=me[K],Ze=Se(D)?D:Se(ve)&&z?void 0:{},Xe=Se(ve)?ve:void 0,sn=Me=>{const Ve=Se(Me)?Me:{};M({...ee,[K]:Ve})};return e.jsxs("div",{className:"config-view__detail-panel",children:[ie,oe&&e.jsx(jn,{view:"profileDetail",onOpenApiKey:de,onOpenApiKeysTab:()=>U("apiKeys"),onOpenProfile:y,onProfilesChange:M,profileKey:K,profiles:ee,readOnly:z,resolvedProfiles:me,service:v.item,serviceKey:v.itemKey,source:c,t:d}),_e({currentFields:ye,currentValue:Ze,currentResolvedValue:Xe,onCurrentValueChange:sn,keyPrefix:`detail:${v.itemKey}:profile:${K}`,readOnly:z})]})}if(F!=null&&oe)return e.jsxs("div",{className:"config-view__detail-panel",children:[ie,e.jsx(jn,{view:"apiKeyDetail",onOpenApiKey:de,onOpenApiKeysTab:()=>U("apiKeys"),onOpenProfile:y,onProfilesChange:M,profiles:ee,readOnly:z,resolvedProfiles:me,service:v.item,serviceKey:v.itemKey,source:c,t:d,tokenId:F})]});const qe=[{key:"service",label:tn("info",d("config.modelServices.collectionTabs.service",{defaultValue:"服务信息"})),children:e.jsx("div",{className:"config-view__subsection-body",children:_e({currentFields:ce,currentValue:z?void 0:v.item,currentResolvedValue:v.resolvedItem,onCurrentValueChange:k,keyPrefix:`detail:${v.field.path.join(".")}:${v.itemKey}:service`,readOnly:z})})},{key:"profiles",label:tn("account_tree",d("config.modelServices.collectionTabs.profiles",{defaultValue:"本地档案"})),children:oe?e.jsx(jn,{view:"profiles",onOpenApiKey:de,onOpenApiKeysTab:()=>U("apiKeys"),onOpenProfile:y,onProfilesChange:M,profiles:ee,readOnly:z,resolvedProfiles:me,service:v.item,serviceKey:v.itemKey,source:c,t:d}):Le},...oe?[{key:"apiKeys",label:tn("vpn_key",d("config.modelServices.collectionTabs.apiKeys",{defaultValue:"令牌管理"})),children:e.jsx(jn,{view:"apiKeys",onOpenApiKey:de,onOpenApiKeysTab:()=>U("apiKeys"),onOpenProfile:y,onProfilesChange:M,profiles:ee,readOnly:z,resolvedProfiles:me,service:v.item,serviceKey:v.itemKey,source:c,t:d})}]:[],...J.length>0?[{key:"advanced",label:tn("tune",d("config.modelServices.collectionTabs.advanced",{defaultValue:"高级配置"})),children:e.jsx("div",{className:"config-view__subsection-body",children:_e({currentFields:J,currentValue:z?void 0:v.item,currentResolvedValue:v.resolvedItem,onCurrentValueChange:k,keyPrefix:`detail:${v.field.path.join(".")}:${v.itemKey}:advanced`,readOnly:z})})}]:[]],gn=qe.some(D=>D.key===fe)?fe:(W=qe[0])==null?void 0:W.key;return e.jsxs("div",{className:"config-view__detail-panel",children:[ie,q,e.jsx(si,{className:"config-view__collection-tabs",activeKey:gn,onChange:D=>U(D),items:qe})]})}if(xe){const se=((X=v.field.detailCollection)==null?void 0:X.itemFields)??[],ee=v.itemSource==="inherited",me=ee?void 0:v.item,ke=v.resolvedItem,K=se.reduce((oe,ye)=>{const M=Eo(ye,me,ke);return M==null||oe[M].push(Un(ye)),oe},{access:[],advanced:[],display:[],models:[],plan:[],service:[]}),F=oe=>{h==null||h({kind:(f==null?void 0:f.kind)??"detailCollectionItem",fieldPath:v.field.path,itemKey:v.itemKey,nestedPath:[...Vo[oe]]})},z=Do(f==null?void 0:f.nestedPath),J=[{key:"service",icon:"info",label:d("config.modelServices.collectionTabs.service",{defaultValue:"服务信息"})},{key:"access",icon:"key",label:d("config.sectionGroups.access",{defaultValue:"接入配置"})},{key:"models",icon:"view_list",label:d("config.sectionGroups.models",{defaultValue:"模型配置"})},{key:"display",icon:"palette",label:d("config.sectionGroups.customization",{defaultValue:"展示与链接"})},{key:"plan",icon:"workspace_premium",label:d("config.sectionGroups.plan",{defaultValue:"套餐信息"})},{key:"advanced",icon:"tune",label:d("config.modelServices.collectionTabs.advanced",{defaultValue:"高级配置"})}].filter(({key:oe})=>K[oe].some(ye=>Bo(ye,me,ke))).map(({key:oe,icon:ye,label:M})=>({key:oe,label:tn(ye,M),children:e.jsx("div",{className:"config-view__subsection-body",children:_e({currentFields:K[oe],currentValue:me,currentResolvedValue:ke,onCurrentValueChange:ee?()=>{}:k,keyPrefix:`detail:${v.field.path.join(".")}:${v.itemKey}:${oe}`,readOnly:ee})})})),R=J.some(oe=>oe.key===z)?z:(pe=J[0])==null?void 0:pe.key;if(J.length>0)return e.jsxs("div",{className:"config-view__detail-panel",children:[ie,q,e.jsx(si,{className:"config-view__collection-tabs",activeKey:R,onChange:oe=>F(oe),items:J})]})}if(v.itemSource==="inherited")return(((Ae=($e=v.field.detailCollection)==null?void 0:$e.itemFields)==null?void 0:Ae.length)??0)>0?e.jsxs("div",{className:"config-view__detail-panel",children:[ie,q,_e({currentFields:v.field.detailCollection.itemFields,currentValue:void 0,currentResolvedValue:v.resolvedItem,onCurrentValueChange:()=>{},keyPrefix:`detail:${v.field.path.join(".")}:${v.itemKey}`,readOnly:!0})]}):e.jsxs("div",{className:"config-view__detail-panel",children:[ie,q,e.jsx(Nn,{value:v.resolvedItem,sectionKey:n,path:v.field.path,t:d})]});if(((Be=v.field.detailCollection)==null?void 0:Be.detailKind)==="recommendedModels")return e.jsxs("div",{className:"config-view__detail-panel",children:[ie,q,e.jsx(So,{value:v.item,onChange:k,mergedModelServices:u,t:d})]});if(((Ee=v.field.detailCollection)==null?void 0:Ee.detailKind)==="mcpServer")return e.jsxs("div",{className:"config-view__detail-panel",children:[ie,q,e.jsx(fo,{value:v.item,onChange:k,t:d})]});if((s==null?void 0:s.kind)==="recordMap"&&v.field.path.length===0){const{itemSchema:se,isKnownEntry:ee}=Ti({schema:s.recordMap,entryKey:v.itemKey,entryValue:v.item}),me=!ee&&s.recordMap.unknownEditor==="json",ke=s.recordMap.discriminatorField??"type";if(me)return e.jsxs("div",{className:"config-view__detail-panel",children:[ie,q,e.jsx(mn,{value:v.item,onChange:K=>k(K??{})})]});if(se!=null){if(n==="adapters"){const K=(Ke=(Oe=se.recordFields)==null?void 0:Oe.accounts)==null?void 0:Ke.itemSchema,F=((He=f==null?void 0:f.nestedPath)==null?void 0:He[0])==="accounts",z=[...ee&&s.recordMap.mode==="discriminated"?[[ke]]:[],["accounts"]],ce=se.fields.filter(y=>!z.some(de=>y.path.length===de.length&&y.path.every((U,fe)=>U===de[fe]))),J=ce.filter(y=>y.path.length===1&&y.path[0]==="defaultAccount").map(y=>y.path),R=ce.filter(y=>y.path.length===1&&(y.path[0]==="includeModels"||y.path[0]==="excludeModels"||y.path[0]==="experimentalApi"||y.path[0]==="maxOutputTokens")||y.type==="json"||y.type==="multiline"||y.type==="string[]"),oe=ce.filter(y=>!J.some(de=>y.path.length===de.length&&y.path.every((U,fe)=>U===de[fe]))).filter(y=>!R.some(de=>y.path.length===de.path.length&&y.path.every((U,fe)=>U===de.path[fe]))).map(y=>y.path),ye={title:d("config.sectionGroups.models"),visibleFieldPaths:R.filter(y=>Ce(y.path,"includeModels")||Ce(y.path,"excludeModels")).map(y=>y.path)},M=[{key:"runtime",title:d("config.sectionGroups.advancedRuntime"),visibleFieldPaths:R.filter(y=>Ce(y.path,"experimentalApi")||Ce(y.path,"maxOutputTokens")).map(y=>y.path)},{key:"sandbox",title:d("config.sectionGroups.advancedSandbox"),visibleFieldPaths:R.filter(y=>Ce(y.path,"sandboxPolicy")).map(y=>y.path)},{key:"client",title:d("config.sectionGroups.advancedClient"),visibleFieldPaths:R.filter(y=>Ce(y.path,"clientInfo")).map(y=>y.path)},{key:"overrides",title:d("config.sectionGroups.advancedOverrides"),visibleFieldPaths:R.filter(y=>Ce(y.path,"configOverrides")||Ce(y.path,"features")).map(y=>y.path)},{key:"misc",title:d("config.sectionGroups.advancedMisc"),visibleFieldPaths:R.filter(y=>!(Ce(y.path,"includeModels")||Ce(y.path,"excludeModels")||Ce(y.path,"experimentalApi")||Ce(y.path,"maxOutputTokens")||Ce(y.path,"sandboxPolicy")||Ce(y.path,"clientInfo")||Ce(y.path,"configOverrides")||Ce(y.path,"features"))).map(y=>y.path)}];return F?e.jsxs("div",{className:"config-view__detail-panel",children:[ie,e.jsx(ai,{adapterKey:v.itemKey,value:v.item,accountItemSchema:K,onChange:k,nestedPath:f==null?void 0:f.nestedPath,onOpenNestedPath:y=>{h==null||h({kind:(f==null?void 0:f.kind)??"detailCollectionItem",fieldPath:v.field.path,itemKey:v.itemKey,nestedPath:y})},t:d})]}):e.jsxs("div",{className:"config-view__detail-panel",children:[ie,e.jsxs("div",{className:"config-view__field-stack",children:[G({schema:se,currentValue:v.item,onCurrentValueChange:k,visibleFieldPaths:oe,title:d("config.sectionGroups.base"),collapsible:!0,defaultExpanded:!0,collapseKey:"base"}),G({schema:se,currentValue:v.item,onCurrentValueChange:k,visibleFieldPaths:J,title:void 0,resolveFieldOptions:y=>y.path.length===1&&y.path[0]==="defaultAccount"?S??[]:void 0}),e.jsx(ai,{adapterKey:v.itemKey,value:v.item,accountItemSchema:K,onChange:k,nestedPath:f==null?void 0:f.nestedPath,onOpenNestedPath:y=>{h==null||h({kind:(f==null?void 0:f.kind)??"detailCollectionItem",fieldPath:v.field.path,itemKey:v.itemKey,nestedPath:y})},t:d}),B({schema:se,currentValue:v.item,onCurrentValueChange:k,modelSection:ye,advancedSections:M})]})]})}return e.jsxs("div",{className:"config-view__detail-panel",children:[ie,e.jsx(Cn,{value:v.item,schema:se,onChange:k,t:d,hideFieldPaths:ee&&s.recordMap.mode==="discriminated"?[[ke]]:void 0})]})}}return(((Je=(Ue=v.field.detailCollection)==null?void 0:Ue.itemFields)==null?void 0:Je.length)??0)>0?e.jsxs("div",{className:"config-view__detail-panel",children:[ie,q,_e({currentFields:v.field.detailCollection.itemFields,currentValue:v.item,currentResolvedValue:v.resolvedItem,onCurrentValueChange:k,keyPrefix:`detail:${v.field.path.join(".")}:${v.itemKey}`})]}):e.jsxs("div",{className:"config-view__detail-panel",children:[ie,e.jsx(dn,{description:d("common.noData"),image:null})]})}return _e({currentFields:N,currentValue:t,currentResolvedValue:o,onCurrentValueChange:m,keyPrefix:n})},en=(n,i,s)=>n==="models"?s("config.editor.newModelSelectorName"):n==="modelServices"?s("config.editor.newModelServiceName"):n==="channels"?s("config.editor.newChannelName"):n==="adapters"?s("config.editor.newAdapterName"):n==="plugins"?s("config.editor.newPluginName"):n==="mcp"?s("config.editor.newMcpServerName"):n==="general"&&i.path.join(".")==="env"?s("config.editor.newEnvVarName"):s("config.editor.fieldKey"),ln=n=>n!=null&&typeof n=="object"&&!Array.isArray(n),wi=(n,i)=>{if(!ln(n))return;const s=n.profiles;if(ln(s)&&ln(s[i]))return s[i];const t=n.services;if(ln(t)&&ln(t[i]))return t[i]},Ko=(n,i,s)=>{const t=wi(n,s)??wi(i,s),o=t==null?void 0:t.title;return typeof o=="string"&&o.trim()!==""?o.trim():$i(s)};function at({sectionKey:n,title:i,icon:s,headerLeading:t,fields:o,uiSection:c,value:m,resolvedValue:u,source:p="project",onChange:a,mergedModelServices:g,mergedAdapters:l,selectedModelService:f,worktreeEnvironmentOptions:h,workspaceFileOpenerOptions:x,detailQuery:j="",onDetailQueryChange:_,onOpenModelServicePortal:d,creatingModelServiceSessionKey:N,onCreateModelServiceSession:C,headerExtra:Q,showHeader:P=!0,t:A,className:Y}){const I=i!=null||s!=null,G=w.useRef(null),B=w.useRef({}),T=es(n,o),Z=io({fields:T,raw:j}),$=ns({sectionKey:n,fields:T,value:m,resolvedValue:u,route:Z,detailContext:{mergedModelServices:g,mergedAdapters:l,t:A},t:A}),je=no(Z),te=()=>{const S=G.current;S!=null&&(B.current[je]=S.scrollTop)},Ie=S=>{te(),_==null||_(on(S))},he=()=>{var S,V,H;if(te(),((S=Z==null?void 0:Z.nestedPath)==null?void 0:S[0])==="profiles"&&Z.nestedPath.length===1){_==null||_(on({...Z,nestedPath:[]}));return}if((((V=Z==null?void 0:Z.nestedPath)==null?void 0:V.length)??0)>0&&Z!=null){_==null||_(on({...Z,nestedPath:((H=Z.nestedPath)==null?void 0:H.slice(0,-1))??[]}));return}_==null||_("")},be=(Z==null?void 0:Z.nestedPath)??[],_e=be.length===1&&be[0]==="profiles"?[]:be,v=_e.map((S,V)=>{const H=V===0&&S==="accounts"?A("config.accounts.title"):V===0&&S==="profiles"?A("config.sectionGroups.profiles"):V===1&&_e[0]==="profiles"&&n==="modelServices"&&$!=null?Ko($.item,$.resolvedItem,S):$i(S),E=V===_e.length-1;return{key:`${S}:${V}`,label:H,isCurrent:E,onClick:E?void 0:()=>{Z!=null&&(te(),_==null||_(on({...Z,nestedPath:_e.slice(0,V+1)})))}}}),we=$==null?[]:[...[{key:"section",label:i},{key:"item",label:$.itemLabel,isCurrent:v.length===0,...v.length>0?{onClick:()=>{te(),_==null||_(on({...Z,nestedPath:[]}))}}:{}}],...v];w.useLayoutEffect(()=>{const S=G.current;S!=null&&(S.scrollTop=B.current[je]??0)},[je]);const Ne=I?$==null?void 0:e.jsxs("div",{className:"config-view__detail-trail",children:[t,e.jsx(ne,{title:A("config.detail.back"),children:e.jsx(L,{size:"small",type:"text",className:"config-view__detail-back","aria-label":A("config.detail.back"),icon:e.jsx("span",{className:"material-symbols-rounded",children:"chevron_left"}),onClick:he})}),e.jsx("div",{className:"config-view__detail-breadcrumb",children:we.map((S,V)=>e.jsxs("span",{className:"config-view__detail-breadcrumb-item",children:[V>0&&e.jsx("span",{className:"config-view__detail-separator","aria-hidden":"true",children:e.jsx("span",{className:"material-symbols-rounded",children:"chevron_right"})}),e.jsx("span",{className:`config-view__detail-crumb ${S.isCurrent===!0?"config-view__detail-crumb--current":"config-view__detail-crumb--static"}`,children:S.label})]},S.key))})]}):null;return e.jsx(rs,{ref:G,className:Y,headerContent:P?Ne:void 0,headerExtra:P?Q:void 0,headerLeading:P&&Ne==null?t:void 0,icon:P&&Ne==null?s:void 0,title:P&&Ne==null?i:void 0,children:e.jsx(Oo,{sectionKey:n,fields:T,uiSection:c,value:m,resolvedValue:u,source:p,onChange:a,mergedModelServices:g,mergedAdapters:l,selectedModelService:f,worktreeEnvironmentOptions:h,workspaceFileOpenerOptions:x,detailRoute:Z,onOpenDetailRoute:Ie,onOpenModelServicePortal:d,creatingModelServiceSessionKey:N,onCreateModelServiceSession:C,t:A})})}function Lo({dataSource:n,loading:i}){return e.jsx(En,{bordered:!0,loading:i,dataSource:n,renderItem:s=>e.jsx(En.Item,{actions:[s.action],children:e.jsx(En.Item.Meta,{avatar:e.jsx("span",{className:"material-symbols-rounded",children:s.icon}),title:e.jsxs(Ai,{size:8,children:[e.jsx("span",{children:s.title}),e.jsx(ds,{children:s.status})]}),description:s.description})})})}const zo=n=>typeof n!="string"?n:e.jsx("span",{className:"material-symbols-rounded","aria-hidden":"true",children:n}),an=w.forwardRef(({children:n,className:i,htmlType:s="button",icon:t,size:o="small",tone:c="default",...m},u)=>{const p=["oneworks-inline-action-button",c==="danger"?"is-danger":"",i].filter(Boolean).join(" ");return e.jsx(L,{...m,ref:u,className:p,htmlType:s,icon:zo(t),size:o,type:"text",children:n})});an.displayName="InlineActionButton";const Ni={icon:"public",id:"google-chrome",name:"Google Chrome",profiles:0},wn={authenticator:{total:0},savedPasswords:{total:0}};function Uo({canImportAuthenticator:n,importingAuthenticator:i,importingPasswordCsv:s,importingPasswordSourceId:t,onImportAuthenticator:o,onImportPasswordCsv:c,onImportPasswords:m,state:u,visiblePasswordSources:p}){const{t:a}=ki();return w.useMemo(()=>[{action:e.jsx(an,{loading:s,icon:"upload_file",onClick:c,children:a("browserDataSync.actions.chooseFile")}),description:a("browserDataSync.savedPasswords.csvDescription"),icon:"file_upload",status:a("browserDataSync.status.available"),title:a("browserDataSync.savedPasswords.csvTitle")},...p.map(g=>({action:e.jsx(an,{loading:t===g.id,disabled:t!=null&&t!==g.id,icon:"sync",onClick:()=>m(g),children:a("browserDataSync.actions.sync")}),description:a(g.profiles>0?"browserDataSync.savedPasswords.sourceDescription":"browserDataSync.savedPasswords.sourceFallbackDescription",{profiles:g.profiles,source:g.name}),icon:g.icon,status:a("browserDataSync.status.available"),title:a("browserDataSync.savedPasswords.sourceTitle",{source:g.name})})),{action:e.jsx(an,{icon:"hourglass_empty",disabled:!0,children:a("browserDataSync.actions.comingSoon")}),description:a("browserDataSync.passwordManagerExtensions.description"),icon:"extension",status:a("browserDataSync.status.planned"),title:a("browserDataSync.passwordManagerExtensions.title")},{action:e.jsx(an,{loading:i,disabled:!n,icon:"upload_file",onClick:o,children:a("browserDataSync.actions.importBackup")}),description:a("browserDataSync.authenticator.description",{count:u.authenticator.total}),icon:"pin",status:a("browserDataSync.status.available"),title:a("browserDataSync.authenticator.title")}],[n,i,s,t,o,c,m,u.authenticator.total,a,p])}function rt({onClose:n,open:i}){const{message:s}=pn.useApp(),{t}=ki(),o=window.oneworksDesktop,[c,m]=w.useState(wn),[u,p]=w.useState(!1),[a,g]=w.useState([]),[l,f]=w.useState(!1),[h,x]=w.useState(!1),[j,_]=w.useState(null),d=(o==null?void 0:o.importAuthenticatorBackup)!=null,N=(o==null?void 0:o.importBrowserPasswords)!=null||(o==null?void 0:o.importChromePasswords)!=null,C=(o==null?void 0:o.importPasswordCsv)!=null,Q=w.useMemo(()=>a.some(T=>T.id===Ni.id)?a:[Ni,...a],[a]),P=w.useCallback(()=>{if((o==null?void 0:o.getBrowserDataSyncState)==null){m(wn);return}p(!0),o.getBrowserDataSyncState().then(T=>m(T??wn)).catch(T=>{console.error("[browser-data-sync] failed to load state",T),m(wn)}).finally(()=>p(!1))},[o]),A=w.useCallback(()=>{if((o==null?void 0:o.listBrowserPasswordImportSources)==null){g([]);return}o.listBrowserPasswordImportSources().then(T=>g(T??[])).catch(T=>{console.error("[browser-data-sync] failed to load browser password sources",T),g([])})},[o]);w.useEffect(()=>{i&&(P(),A())},[A,P,i]);const Y=w.useCallback(()=>{if(!d||(o==null?void 0:o.importAuthenticatorBackup)==null){s.warning(t("common.notSupportedYet"));return}f(!0),o.importAuthenticatorBackup().then(T=>{T.canceled||(s.success(t("browserDataSync.authenticator.importSuccess",{imported:T.imported,skipped:T.skipped,updated:T.updated})),P())}).catch(T=>{console.error("[browser-data-sync] failed to import authenticator backup",T),s.error(t("browserDataSync.authenticator.importFailed"))}).finally(()=>f(!1))},[d,o,P,s,t]),I=w.useCallback(T=>{if(!N||o==null||o.importBrowserPasswords==null&&o.importChromePasswords==null){s.warning(t("browserDataSync.savedPasswords.desktopRestartRequired"));return}_(T.id),(o.importBrowserPasswords==null?o.importChromePasswords():o.importBrowserPasswords({sourceId:T.id})).then($=>{$.canceled||(s.success(t("browserDataSync.savedPasswords.importSourceSuccess",{duplicates:$.duplicates,failed:$.failed,imported:$.imported,profiles:$.profiles,source:$.sourceName??T.name,skipped:$.skipped,updated:$.updated})),P(),A())}).catch($=>{console.error("[browser-data-sync] failed to import browser passwords",$),s.error(t("browserDataSync.savedPasswords.importSourceFailed",{source:T.name}))}).finally(()=>_(null))},[N,o,A,P,s,t]),G=w.useCallback(()=>{if(!C||(o==null?void 0:o.importPasswordCsv)==null){s.warning(t("browserDataSync.savedPasswords.desktopRestartRequired"));return}x(!0),o.importPasswordCsv().then(T=>{T.canceled||(s.success(t("browserDataSync.savedPasswords.importCsvSuccess",{duplicates:T.duplicates,imported:T.imported,skipped:T.skipped,updated:T.updated})),P(),A())}).catch(T=>{console.error("[browser-data-sync] failed to import password CSV",T),s.error(t("browserDataSync.savedPasswords.importCsvFailed"))}).finally(()=>x(!1))},[C,o,A,P,s,t]),B=Uo({canImportAuthenticator:d,importingAuthenticator:l,importingPasswordCsv:h,importingPasswordSourceId:j,onImportAuthenticator:Y,onImportPasswordCsv:G,onImportPasswords:I,state:c,visiblePasswordSources:Q});return e.jsx(Fi,{destroyOnClose:!0,open:i,title:t("browserDataSync.title"),width:640,footer:[e.jsx(L,{onClick:n,children:t("common.close")},"close")],onCancel:n,children:e.jsxs(Ai,{direction:"vertical",size:14,style:{width:"100%"},children:[e.jsx(oi,{showIcon:!0,type:"info",message:t("browserDataSync.summaryTitle"),description:t("browserDataSync.summaryDescription")}),e.jsx(Lo,{loading:u,dataSource:B}),e.jsx(oi,{showIcon:!0,type:"warning",message:t("browserDataSync.securityTitle"),description:t("browserDataSync.securityDescription")})]})})}const ct="calc(var(--app-chrome-icon-size, 18px) + var(--route-container-header-padding-block, 10px) + var(--route-container-header-padding-block, 10px) + var(--route-container-header-border-width, var(--app-chrome-border-width, 1px)))";export{rt as B,at as C,ct as D,an as I,lt as a,tt as b,ui as c,Nn as d,es as g,un as n,Hi as o,io as p,ns as r,on as s};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{l as g,an as lt,g as b,t as H,d as E,A as j,i as Q,ao as V}from"./mermaid.core-DWzpZH_g.js";import{c as st}from"./createText-1719965b-x3Mhf0Jh.js";import{l as ct}from"./line-C99msl9T.js";const ht=(a,t,e,i)=>{t.forEach(l=>{wt[l](a,e,i)})},ot=(a,t,e)=>{g.trace("Making markers for ",e),a.append("defs").append("marker").attr("id",e+"_"+t+"-extensionStart").attr("class","marker extension "+t).attr("refX",18).attr("refY",7).attr("markerWidth",190).attr("markerHeight",240).attr("orient","auto").append("path").attr("d","M 1,7 L18,13 V 1 Z"),a.append("defs").append("marker").attr("id",e+"_"+t+"-extensionEnd").attr("class","marker extension "+t).attr("refX",1).attr("refY",7).attr("markerWidth",20).attr("markerHeight",28).attr("orient","auto").append("path").attr("d","M 1,1 V 13 L18,7 Z")},yt=(a,t,e)=>{a.append("defs").append("marker").attr("id",e+"_"+t+"-compositionStart").attr("class","marker composition "+t).attr("refX",18).attr("refY",7).attr("markerWidth",190).attr("markerHeight",240).attr("orient","auto").append("path").attr("d","M 18,7 L9,13 L1,7 L9,1 Z"),a.append("defs").append("marker").attr("id",e+"_"+t+"-compositionEnd").attr("class","marker composition "+t).attr("refX",1).attr("refY",7).attr("markerWidth",20).attr("markerHeight",28).attr("orient","auto").append("path").attr("d","M 18,7 L9,13 L1,7 L9,1 Z")},pt=(a,t,e)=>{a.append("defs").append("marker").attr("id",e+"_"+t+"-aggregationStart").attr("class","marker aggregation "+t).attr("refX",18).attr("refY",7).attr("markerWidth",190).attr("markerHeight",240).attr("orient","auto").append("path").attr("d","M 18,7 L9,13 L1,7 L9,1 Z"),a.append("defs").append("marker").attr("id",e+"_"+t+"-aggregationEnd").attr("class","marker aggregation "+t).attr("refX",1).attr("refY",7).attr("markerWidth",20).attr("markerHeight",28).attr("orient","auto").append("path").attr("d","M 18,7 L9,13 L1,7 L9,1 Z")},ft=(a,t,e)=>{a.append("defs").append("marker").attr("id",e+"_"+t+"-dependencyStart").attr("class","marker dependency "+t).attr("refX",6).attr("refY",7).attr("markerWidth",190).attr("markerHeight",240).attr("orient","auto").append("path").attr("d","M 5,7 L9,13 L1,7 L9,1 Z"),a.append("defs").append("marker").attr("id",e+"_"+t+"-dependencyEnd").attr("class","marker dependency "+t).attr("refX",13).attr("refY",7).attr("markerWidth",20).attr("markerHeight",28).attr("orient","auto").append("path").attr("d","M 18,7 L9,13 L14,7 L9,1 Z")},xt=(a,t,e)=>{a.append("defs").append("marker").attr("id",e+"_"+t+"-lollipopStart").attr("class","marker lollipop "+t).attr("refX",13).attr("refY",7).attr("markerWidth",190).attr("markerHeight",240).attr("orient","auto").append("circle").attr("stroke","black").attr("fill","transparent").attr("cx",7).attr("cy",7).attr("r",6),a.append("defs").append("marker").attr("id",e+"_"+t+"-lollipopEnd").attr("class","marker lollipop "+t).attr("refX",1).attr("refY",7).attr("markerWidth",190).attr("markerHeight",240).attr("orient","auto").append("circle").attr("stroke","black").attr("fill","transparent").attr("cx",7).attr("cy",7).attr("r",6)},dt=(a,t,e)=>{a.append("marker").attr("id",e+"_"+t+"-pointEnd").attr("class","marker "+t).attr("viewBox","0 0 10 10").attr("refX",6).attr("refY",5).attr("markerUnits","userSpaceOnUse").attr("markerWidth",12).attr("markerHeight",12).attr("orient","auto").append("path").attr("d","M 0 0 L 10 5 L 0 10 z").attr("class","arrowMarkerPath").style("stroke-width",1).style("stroke-dasharray","1,0"),a.append("marker").attr("id",e+"_"+t+"-pointStart").attr("class","marker "+t).attr("viewBox","0 0 10 10").attr("refX",4.5).attr("refY",5).attr("markerUnits","userSpaceOnUse").attr("markerWidth",12).attr("markerHeight",12).attr("orient","auto").append("path").attr("d","M 0 5 L 10 10 L 10 0 z").attr("class","arrowMarkerPath").style("stroke-width",1).style("stroke-dasharray","1,0")},gt=(a,t,e)=>{a.append("marker").attr("id",e+"_"+t+"-circleEnd").attr("class","marker "+t).attr("viewBox","0 0 10 10").attr("refX",11).attr("refY",5).attr("markerUnits","userSpaceOnUse").attr("markerWidth",11).attr("markerHeight",11).attr("orient","auto").append("circle").attr("cx","5").attr("cy","5").attr("r","5").attr("class","arrowMarkerPath").style("stroke-width",1).style("stroke-dasharray","1,0"),a.append("marker").attr("id",e+"_"+t+"-circleStart").attr("class","marker "+t).attr("viewBox","0 0 10 10").attr("refX",-1).attr("refY",5).attr("markerUnits","userSpaceOnUse").attr("markerWidth",11).attr("markerHeight",11).attr("orient","auto").append("circle").attr("cx","5").attr("cy","5").attr("r","5").attr("class","arrowMarkerPath").style("stroke-width",1).style("stroke-dasharray","1,0")},ut=(a,t,e)=>{a.append("marker").attr("id",e+"_"+t+"-crossEnd").attr("class","marker cross "+t).attr("viewBox","0 0 11 11").attr("refX",12).attr("refY",5.2).attr("markerUnits","userSpaceOnUse").attr("markerWidth",11).attr("markerHeight",11).attr("orient","auto").append("path").attr("d","M 1,1 l 9,9 M 10,1 l -9,9").attr("class","arrowMarkerPath").style("stroke-width",2).style("stroke-dasharray","1,0"),a.append("marker").attr("id",e+"_"+t+"-crossStart").attr("class","marker cross "+t).attr("viewBox","0 0 11 11").attr("refX",-1).attr("refY",5.2).attr("markerUnits","userSpaceOnUse").attr("markerWidth",11).attr("markerHeight",11).attr("orient","auto").append("path").attr("d","M 1,1 l 9,9 M 10,1 l -9,9").attr("class","arrowMarkerPath").style("stroke-width",2).style("stroke-dasharray","1,0")},bt=(a,t,e)=>{a.append("defs").append("marker").attr("id",e+"_"+t+"-barbEnd").attr("refX",19).attr("refY",7).attr("markerWidth",20).attr("markerHeight",14).attr("markerUnits","strokeWidth").attr("orient","auto").append("path").attr("d","M 19,7 L9,13 L14,7 L9,1 Z")},wt={extension:ot,composition:yt,aggregation:pt,dependency:ft,lollipop:xt,point:dt,circle:gt,cross:ut,barb:bt},hr=ht;function mt(a,t){t&&a.attr("style",t)}function kt(a,t){const e=E(document.createElementNS("http://www.w3.org/2000/svg","foreignObject")),i=e.append("xhtml:div"),l=a.label,r=a.isNode?"nodeLabel":"edgeLabel";return i.html(Q('<span class="'+r+'" '+(a.labelStyle?'style="'+a.labelStyle+'"':"")+">"+l+"</span>",t)),mt(i,a.labelStyle),i.style("display","inline-block"),i.style("white-space","nowrap"),i.attr("xmlns","http://www.w3.org/1999/xhtml"),e.node()}const vt=(a,t,e,i)=>{let l=a||"";typeof l=="object"&&(l=l[0]);const r=b();if(H(r.flowchart.htmlLabels)){l=l.replace(/\\n|\n/g,"<br />"),g.debug("vertexText"+l);const s={isNode:i,label:V(l).replace(/fa[blrs]?:fa-[\w-]+/g,c=>`<i class='${c.replace(":"," ")}'></i>`),labelStyle:t.replace("fill:","color:")};return kt(s,r)}else{const s=document.createElementNS("http://www.w3.org/2000/svg","text");s.setAttribute("style",t.replace("color:","fill:"));let n=[];typeof l=="string"?n=l.split(/\\n|\n|<br\s*\/?>/gi):Array.isArray(l)?n=l:n=[];for(const c of n){const o=document.createElementNS("http://www.w3.org/2000/svg","tspan");o.setAttributeNS("http://www.w3.org/XML/1998/namespace","xml:space","preserve"),o.setAttribute("dy","1em"),o.setAttribute("x","0"),e?o.setAttribute("class","title-row"):o.setAttribute("class","row"),o.textContent=c.trim(),s.appendChild(o)}return s}},R=vt,M=async(a,t,e,i)=>{let l;const r=t.useHtmlLabels||H(b().flowchart.htmlLabels);e?l=e:l="node default";const s=a.insert("g").attr("class",l).attr("id",t.domId||t.id),n=s.insert("g").attr("class","label").attr("style",t.labelStyle);let c;t.labelText===void 0?c="":c=typeof t.labelText=="string"?t.labelText:t.labelText[0];const o=n.node();let h;t.labelType==="markdown"?h=st(n,Q(V(c),b()),{useHtmlLabels:r,width:t.width||b().flowchart.wrappingWidth,classes:"markdown-node-label"}):h=o.appendChild(R(Q(V(c),b()),t.labelStyle,!1,i));let y=h.getBBox();const f=t.padding/2;if(H(b().flowchart.htmlLabels)){const p=h.children[0],d=E(h),k=p.getElementsByTagName("img");if(k){const x=c.replace(/<img[^>]*>/g,"").trim()==="";await Promise.all([...k].map(u=>new Promise(S=>{function B(){if(u.style.display="flex",u.style.flexDirection="column",x){const C=b().fontSize?b().fontSize:window.getComputedStyle(document.body).fontSize,A=parseInt(C,10)*5+"px";u.style.minWidth=A,u.style.maxWidth=A}else u.style.width="100%";S(u)}setTimeout(()=>{u.complete&&B()}),u.addEventListener("error",B),u.addEventListener("load",B)})))}y=p.getBoundingClientRect(),d.attr("width",y.width),d.attr("height",y.height)}return r?n.attr("transform","translate("+-y.width/2+", "+-y.height/2+")"):n.attr("transform","translate(0, "+-y.height/2+")"),t.centerLabel&&n.attr("transform","translate("+-y.width/2+", "+-y.height/2+")"),n.insert("rect",":first-child"),{shapeSvg:s,bbox:y,halfPadding:f,label:n}},m=(a,t)=>{const e=t.node().getBBox();a.width=e.width,a.height=e.height};function I(a,t,e,i){return a.insert("polygon",":first-child").attr("points",i.map(function(l){return l.x+","+l.y}).join(" ")).attr("class","label-container").attr("transform","translate("+-t/2+","+e/2+")")}function Lt(a,t){return a.intersect(t)}function it(a,t,e,i){var l=a.x,r=a.y,s=l-i.x,n=r-i.y,c=Math.sqrt(t*t*n*n+e*e*s*s),o=Math.abs(t*e*s/c);i.x<l&&(o=-o);var h=Math.abs(t*e*n/c);return i.y<r&&(h=-h),{x:l+o,y:r+h}}function St(a,t,e){return it(a,t,t,e)}function Mt(a,t,e,i){var l,r,s,n,c,o,h,y,f,p,d,k,x,u,S;if(l=t.y-a.y,s=a.x-t.x,c=t.x*a.y-a.x*t.y,f=l*e.x+s*e.y+c,p=l*i.x+s*i.y+c,!(f!==0&&p!==0&&J(f,p))&&(r=i.y-e.y,n=e.x-i.x,o=i.x*e.y-e.x*i.y,h=r*a.x+n*a.y+o,y=r*t.x+n*t.y+o,!(h!==0&&y!==0&&J(h,y))&&(d=l*n-r*s,d!==0)))return k=Math.abs(d/2),x=s*o-n*c,u=x<0?(x-k)/d:(x+k)/d,x=r*c-l*o,S=x<0?(x-k)/d:(x+k)/d,{x:u,y:S}}function J(a,t){return a*t>0}function Tt(a,t,e){var i=a.x,l=a.y,r=[],s=Number.POSITIVE_INFINITY,n=Number.POSITIVE_INFINITY;typeof t.forEach=="function"?t.forEach(function(d){s=Math.min(s,d.x),n=Math.min(n,d.y)}):(s=Math.min(s,t.x),n=Math.min(n,t.y));for(var c=i-a.width/2-s,o=l-a.height/2-n,h=0;h<t.length;h++){var y=t[h],f=t[h<t.length-1?h+1:0],p=Mt(a,e,{x:c+y.x,y:o+y.y},{x:c+f.x,y:o+f.y});p&&r.push(p)}return r.length?(r.length>1&&r.sort(function(d,k){var x=d.x-e.x,u=d.y-e.y,S=Math.sqrt(x*x+u*u),B=k.x-e.x,C=k.y-e.y,X=Math.sqrt(B*B+C*C);return S<X?-1:S===X?0:1}),r[0]):a}const Bt=(a,t)=>{var e=a.x,i=a.y,l=t.x-e,r=t.y-i,s=a.width/2,n=a.height/2,c,o;return Math.abs(r)*s>Math.abs(l)*n?(r<0&&(n=-n),c=r===0?0:n*l/r,o=n):(l<0&&(s=-s),c=s,o=l===0?0:s*r/l),{x:e+c,y:i+o}},Et=Bt,w={node:Lt,circle:St,ellipse:it,polygon:Tt,rect:Et},Ct=async(a,t)=>{t.useHtmlLabels||b().flowchart.htmlLabels||(t.centerLabel=!0);const{shapeSvg:i,bbox:l,halfPadding:r}=await M(a,t,"node "+t.classes,!0);g.info("Classes = ",t.classes);const s=i.insert("rect",":first-child");return s.attr("rx",t.rx).attr("ry",t.ry).attr("x",-l.width/2-r).attr("y",-l.height/2-r).attr("width",l.width+t.padding).attr("height",l.height+t.padding),m(t,s),t.intersect=function(n){return w.rect(t,n)},i},$t=Ct,_t=a=>{const t=new Set;for(const e of a)switch(e){case"x":t.add("right"),t.add("left");break;case"y":t.add("up"),t.add("down");break;default:t.add(e);break}return t},Rt=(a,t,e)=>{const i=_t(a),l=2,r=t.height+2*e.padding,s=r/l,n=t.width+2*s+e.padding,c=e.padding/2;return i.has("right")&&i.has("left")&&i.has("up")&&i.has("down")?[{x:0,y:0},{x:s,y:0},{x:n/2,y:2*c},{x:n-s,y:0},{x:n,y:0},{x:n,y:-r/3},{x:n+2*c,y:-r/2},{x:n,y:-2*r/3},{x:n,y:-r},{x:n-s,y:-r},{x:n/2,y:-r-2*c},{x:s,y:-r},{x:0,y:-r},{x:0,y:-2*r/3},{x:-2*c,y:-r/2},{x:0,y:-r/3}]:i.has("right")&&i.has("left")&&i.has("up")?[{x:s,y:0},{x:n-s,y:0},{x:n,y:-r/2},{x:n-s,y:-r},{x:s,y:-r},{x:0,y:-r/2}]:i.has("right")&&i.has("left")&&i.has("down")?[{x:0,y:0},{x:s,y:-r},{x:n-s,y:-r},{x:n,y:0}]:i.has("right")&&i.has("up")&&i.has("down")?[{x:0,y:0},{x:n,y:-s},{x:n,y:-r+s},{x:0,y:-r}]:i.has("left")&&i.has("up")&&i.has("down")?[{x:n,y:0},{x:0,y:-s},{x:0,y:-r+s},{x:n,y:-r}]:i.has("right")&&i.has("left")?[{x:s,y:0},{x:s,y:-c},{x:n-s,y:-c},{x:n-s,y:0},{x:n,y:-r/2},{x:n-s,y:-r},{x:n-s,y:-r+c},{x:s,y:-r+c},{x:s,y:-r},{x:0,y:-r/2}]:i.has("up")&&i.has("down")?[{x:n/2,y:0},{x:0,y:-c},{x:s,y:-c},{x:s,y:-r+c},{x:0,y:-r+c},{x:n/2,y:-r},{x:n,y:-r+c},{x:n-s,y:-r+c},{x:n-s,y:-c},{x:n,y:-c}]:i.has("right")&&i.has("up")?[{x:0,y:0},{x:n,y:-s},{x:0,y:-r}]:i.has("right")&&i.has("down")?[{x:0,y:0},{x:n,y:0},{x:0,y:-r}]:i.has("left")&&i.has("up")?[{x:n,y:0},{x:0,y:-s},{x:n,y:-r}]:i.has("left")&&i.has("down")?[{x:n,y:0},{x:0,y:0},{x:n,y:-r}]:i.has("right")?[{x:s,y:-c},{x:s,y:-c},{x:n-s,y:-c},{x:n-s,y:0},{x:n,y:-r/2},{x:n-s,y:-r},{x:n-s,y:-r+c},{x:s,y:-r+c},{x:s,y:-r+c}]:i.has("left")?[{x:s,y:0},{x:s,y:-c},{x:n-s,y:-c},{x:n-s,y:-r+c},{x:s,y:-r+c},{x:s,y:-r},{x:0,y:-r/2}]:i.has("up")?[{x:s,y:-c},{x:s,y:-r+c},{x:0,y:-r+c},{x:n/2,y:-r},{x:n,y:-r+c},{x:n-s,y:-r+c},{x:n-s,y:-c}]:i.has("down")?[{x:n/2,y:0},{x:0,y:-c},{x:s,y:-c},{x:s,y:-r+c},{x:n-s,y:-r+c},{x:n-s,y:-c},{x:n,y:-c}]:[{x:0,y:0}]},K=a=>a?" "+a:"",_=(a,t)=>`node default${K(a.classes)} ${K(a.class)}`,P=async(a,t)=>{const{shapeSvg:e,bbox:i}=await M(a,t,_(t),!0),l=i.width+t.padding,r=i.height+t.padding,s=l+r,n=[{x:s/2,y:0},{x:s,y:-s/2},{x:s/2,y:-s},{x:0,y:-s/2}];g.info("Question main (Circle)");const c=I(e,s,s,n);return c.attr("style",t.style),m(t,c),t.intersect=function(o){return g.warn("Intersect called"),w.polygon(t,n,o)},e},Ht=(a,t)=>{const e=a.insert("g").attr("class","node default").attr("id",t.domId||t.id),i=28,l=[{x:0,y:i/2},{x:i/2,y:0},{x:0,y:-i/2},{x:-i/2,y:0}];return e.insert("polygon",":first-child").attr("points",l.map(function(s){return s.x+","+s.y}).join(" ")).attr("class","state-start").attr("r",7).attr("width",28).attr("height",28),t.width=28,t.height=28,t.intersect=function(s){return w.circle(t,14,s)},e},It=async(a,t)=>{const{shapeSvg:e,bbox:i}=await M(a,t,_(t),!0),l=4,r=i.height+t.padding,s=r/l,n=i.width+2*s+t.padding,c=[{x:s,y:0},{x:n-s,y:0},{x:n,y:-r/2},{x:n-s,y:-r},{x:s,y:-r},{x:0,y:-r/2}],o=I(e,n,r,c);return o.attr("style",t.style),m(t,o),t.intersect=function(h){return w.polygon(t,c,h)},e},Nt=async(a,t)=>{const{shapeSvg:e,bbox:i}=await M(a,t,void 0,!0),l=2,r=i.height+2*t.padding,s=r/l,n=i.width+2*s+t.padding,c=Rt(t.directions,i,t),o=I(e,n,r,c);return o.attr("style",t.style),m(t,o),t.intersect=function(h){return w.polygon(t,c,h)},e},Ot=async(a,t)=>{const{shapeSvg:e,bbox:i}=await M(a,t,_(t),!0),l=i.width+t.padding,r=i.height+t.padding,s=[{x:-r/2,y:0},{x:l,y:0},{x:l,y:-r},{x:-r/2,y:-r},{x:0,y:-r/2}];return I(e,l,r,s).attr("style",t.style),t.width=l+r,t.height=r,t.intersect=function(c){return w.polygon(t,s,c)},e},Wt=async(a,t)=>{const{shapeSvg:e,bbox:i}=await M(a,t,_(t),!0),l=i.width+t.padding,r=i.height+t.padding,s=[{x:-2*r/6,y:0},{x:l-r/6,y:0},{x:l+2*r/6,y:-r},{x:r/6,y:-r}],n=I(e,l,r,s);return n.attr("style",t.style),m(t,n),t.intersect=function(c){return w.polygon(t,s,c)},e},Xt=async(a,t)=>{const{shapeSvg:e,bbox:i}=await M(a,t,_(t),!0),l=i.width+t.padding,r=i.height+t.padding,s=[{x:2*r/6,y:0},{x:l+r/6,y:0},{x:l-2*r/6,y:-r},{x:-r/6,y:-r}],n=I(e,l,r,s);return n.attr("style",t.style),m(t,n),t.intersect=function(c){return w.polygon(t,s,c)},e},Yt=async(a,t)=>{const{shapeSvg:e,bbox:i}=await M(a,t,_(t),!0),l=i.width+t.padding,r=i.height+t.padding,s=[{x:-2*r/6,y:0},{x:l+2*r/6,y:0},{x:l-r/6,y:-r},{x:r/6,y:-r}],n=I(e,l,r,s);return n.attr("style",t.style),m(t,n),t.intersect=function(c){return w.polygon(t,s,c)},e},At=async(a,t)=>{const{shapeSvg:e,bbox:i}=await M(a,t,_(t),!0),l=i.width+t.padding,r=i.height+t.padding,s=[{x:r/6,y:0},{x:l-r/6,y:0},{x:l+2*r/6,y:-r},{x:-2*r/6,y:-r}],n=I(e,l,r,s);return n.attr("style",t.style),m(t,n),t.intersect=function(c){return w.polygon(t,s,c)},e},Dt=async(a,t)=>{const{shapeSvg:e,bbox:i}=await M(a,t,_(t),!0),l=i.width+t.padding,r=i.height+t.padding,s=[{x:0,y:0},{x:l+r/2,y:0},{x:l,y:-r/2},{x:l+r/2,y:-r},{x:0,y:-r}],n=I(e,l,r,s);return n.attr("style",t.style),m(t,n),t.intersect=function(c){return w.polygon(t,s,c)},e},jt=async(a,t)=>{const{shapeSvg:e,bbox:i}=await M(a,t,_(t),!0),l=i.width+t.padding,r=l/2,s=r/(2.5+l/50),n=i.height+s+t.padding,c="M 0,"+s+" a "+r+","+s+" 0,0,0 "+l+" 0 a "+r+","+s+" 0,0,0 "+-l+" 0 l 0,"+n+" a "+r+","+s+" 0,0,0 "+l+" 0 l 0,"+-n,o=e.attr("label-offset-y",s).insert("path",":first-child").attr("style",t.style).attr("d",c).attr("transform","translate("+-l/2+","+-(n/2+s)+")");return m(t,o),t.intersect=function(h){const y=w.rect(t,h),f=y.x-t.x;if(r!=0&&(Math.abs(f)<t.width/2||Math.abs(f)==t.width/2&&Math.abs(y.y-t.y)>t.height/2-s)){let p=s*s*(1-f*f/(r*r));p!=0&&(p=Math.sqrt(p)),p=s-p,h.y-t.y>0&&(p=-p),y.y+=p}return y},e},Ut=async(a,t)=>{const{shapeSvg:e,bbox:i,halfPadding:l}=await M(a,t,"node "+t.classes+" "+t.class,!0),r=e.insert("rect",":first-child"),s=t.positioned?t.width:i.width+t.padding,n=t.positioned?t.height:i.height+t.padding,c=t.positioned?-s/2:-i.width/2-l,o=t.positioned?-n/2:-i.height/2-l;if(r.attr("class","basic label-container").attr("style",t.style).attr("rx",t.rx).attr("ry",t.ry).attr("x",c).attr("y",o).attr("width",s).attr("height",n),t.props){const h=new Set(Object.keys(t.props));t.props.borders&&(q(r,t.props.borders,s,n),h.delete("borders")),h.forEach(y=>{g.warn(`Unknown node property ${y}`)})}return m(t,r),t.intersect=function(h){return w.rect(t,h)},e},zt=async(a,t)=>{const{shapeSvg:e,bbox:i,halfPadding:l}=await M(a,t,"node "+t.classes,!0),r=e.insert("rect",":first-child"),s=t.positioned?t.width:i.width+t.padding,n=t.positioned?t.height:i.height+t.padding,c=t.positioned?-s/2:-i.width/2-l,o=t.positioned?-n/2:-i.height/2-l;if(r.attr("class","basic cluster composite label-container").attr("style",t.style).attr("rx",t.rx).attr("ry",t.ry).attr("x",c).attr("y",o).attr("width",s).attr("height",n),t.props){const h=new Set(Object.keys(t.props));t.props.borders&&(q(r,t.props.borders,s,n),h.delete("borders")),h.forEach(y=>{g.warn(`Unknown node property ${y}`)})}return m(t,r),t.intersect=function(h){return w.rect(t,h)},e},Zt=async(a,t)=>{const{shapeSvg:e}=await M(a,t,"label",!0);g.trace("Classes = ",t.class);const i=e.insert("rect",":first-child"),l=0,r=0;if(i.attr("width",l).attr("height",r),e.attr("class","label edgeLabel"),t.props){const s=new Set(Object.keys(t.props));t.props.borders&&(q(i,t.props.borders,l,r),s.delete("borders")),s.forEach(n=>{g.warn(`Unknown node property ${n}`)})}return m(t,i),t.intersect=function(s){return w.rect(t,s)},e};function q(a,t,e,i){const l=[],r=n=>{l.push(n,0)},s=n=>{l.push(0,n)};t.includes("t")?(g.debug("add top border"),r(e)):s(e),t.includes("r")?(g.debug("add right border"),r(i)):s(i),t.includes("b")?(g.debug("add bottom border"),r(e)):s(e),t.includes("l")?(g.debug("add left border"),r(i)):s(i),a.attr("stroke-dasharray",l.join(" "))}const Gt=(a,t)=>{let e;t.classes?e="node "+t.classes:e="node default";const i=a.insert("g").attr("class",e).attr("id",t.domId||t.id),l=i.insert("rect",":first-child"),r=i.insert("line"),s=i.insert("g").attr("class","label"),n=t.labelText.flat?t.labelText.flat():t.labelText;let c="";typeof n=="object"?c=n[0]:c=n,g.info("Label text abc79",c,n,typeof n=="object");const o=s.node().appendChild(R(c,t.labelStyle,!0,!0));let h={width:0,height:0};if(H(b().flowchart.htmlLabels)){const k=o.children[0],x=E(o);h=k.getBoundingClientRect(),x.attr("width",h.width),x.attr("height",h.height)}g.info("Text 2",n);const y=n.slice(1,n.length);let f=o.getBBox();const p=s.node().appendChild(R(y.join?y.join("<br/>"):y,t.labelStyle,!0,!0));if(H(b().flowchart.htmlLabels)){const k=p.children[0],x=E(p);h=k.getBoundingClientRect(),x.attr("width",h.width),x.attr("height",h.height)}const d=t.padding/2;return E(p).attr("transform","translate( "+(h.width>f.width?0:(f.width-h.width)/2)+", "+(f.height+d+5)+")"),E(o).attr("transform","translate( "+(h.width<f.width?0:-(f.width-h.width)/2)+", 0)"),h=s.node().getBBox(),s.attr("transform","translate("+-h.width/2+", "+(-h.height/2-d+3)+")"),l.attr("class","outer title-state").attr("x",-h.width/2-d).attr("y",-h.height/2-d).attr("width",h.width+t.padding).attr("height",h.height+t.padding),r.attr("class","divider").attr("x1",-h.width/2-d).attr("x2",h.width/2+d).attr("y1",-h.height/2-d+f.height+d).attr("y2",-h.height/2-d+f.height+d),m(t,l),t.intersect=function(k){return w.rect(t,k)},i},Ft=async(a,t)=>{const{shapeSvg:e,bbox:i}=await M(a,t,_(t),!0),l=i.height+t.padding,r=i.width+l/4+t.padding,s=e.insert("rect",":first-child").attr("style",t.style).attr("rx",l/2).attr("ry",l/2).attr("x",-r/2).attr("y",-l/2).attr("width",r).attr("height",l);return m(t,s),t.intersect=function(n){return w.rect(t,n)},e},Qt=async(a,t)=>{const{shapeSvg:e,bbox:i,halfPadding:l}=await M(a,t,_(t),!0),r=e.insert("circle",":first-child");return r.attr("style",t.style).attr("rx",t.rx).attr("ry",t.ry).attr("r",i.width/2+l).attr("width",i.width+t.padding).attr("height",i.height+t.padding),g.info("Circle main"),m(t,r),t.intersect=function(s){return g.info("Circle intersect",t,i.width/2+l,s),w.circle(t,i.width/2+l,s)},e},Vt=async(a,t)=>{const{shapeSvg:e,bbox:i,halfPadding:l}=await M(a,t,_(t),!0),r=5,s=e.insert("g",":first-child"),n=s.insert("circle"),c=s.insert("circle");return s.attr("class",t.class),n.attr("style",t.style).attr("rx",t.rx).attr("ry",t.ry).attr("r",i.width/2+l+r).attr("width",i.width+t.padding+r*2).attr("height",i.height+t.padding+r*2),c.attr("style",t.style).attr("rx",t.rx).attr("ry",t.ry).attr("r",i.width/2+l).attr("width",i.width+t.padding).attr("height",i.height+t.padding),g.info("DoubleCircle main"),m(t,n),t.intersect=function(o){return g.info("DoubleCircle intersect",t,i.width/2+l+r,o),w.circle(t,i.width/2+l+r,o)},e},qt=async(a,t)=>{const{shapeSvg:e,bbox:i}=await M(a,t,_(t),!0),l=i.width+t.padding,r=i.height+t.padding,s=[{x:0,y:0},{x:l,y:0},{x:l,y:-r},{x:0,y:-r},{x:0,y:0},{x:-8,y:0},{x:l+8,y:0},{x:l+8,y:-r},{x:-8,y:-r},{x:-8,y:0}],n=I(e,l,r,s);return n.attr("style",t.style),m(t,n),t.intersect=function(c){return w.polygon(t,s,c)},e},Jt=(a,t)=>{const e=a.insert("g").attr("class","node default").attr("id",t.domId||t.id),i=e.insert("circle",":first-child");return i.attr("class","state-start").attr("r",7).attr("width",14).attr("height",14),m(t,i),t.intersect=function(l){return w.circle(t,7,l)},e},tt=(a,t,e)=>{const i=a.insert("g").attr("class","node default").attr("id",t.domId||t.id);let l=70,r=10;e==="LR"&&(l=10,r=70);const s=i.append("rect").attr("x",-1*l/2).attr("y",-1*r/2).attr("width",l).attr("height",r).attr("class","fork-join");return m(t,s),t.height=t.height+t.padding/2,t.width=t.width+t.padding/2,t.intersect=function(n){return w.rect(t,n)},i},Kt=(a,t)=>{const e=a.insert("g").attr("class","node default").attr("id",t.domId||t.id),i=e.insert("circle",":first-child"),l=e.insert("circle",":first-child");return l.attr("class","state-start").attr("r",7).attr("width",14).attr("height",14),i.attr("class","state-end").attr("r",5).attr("width",10).attr("height",10),m(t,l),t.intersect=function(r){return w.circle(t,7,r)},e},Pt=(a,t)=>{const e=t.padding/2,i=4,l=8;let r;t.classes?r="node "+t.classes:r="node default";const s=a.insert("g").attr("class",r).attr("id",t.domId||t.id),n=s.insert("rect",":first-child"),c=s.insert("line"),o=s.insert("line");let h=0,y=i;const f=s.insert("g").attr("class","label");let p=0;const d=t.classData.annotations&&t.classData.annotations[0],k=t.classData.annotations[0]?"«"+t.classData.annotations[0]+"»":"",x=f.node().appendChild(R(k,t.labelStyle,!0,!0));let u=x.getBBox();if(H(b().flowchart.htmlLabels)){const v=x.children[0],L=E(x);u=v.getBoundingClientRect(),L.attr("width",u.width),L.attr("height",u.height)}t.classData.annotations[0]&&(y+=u.height+i,h+=u.width);let S=t.classData.label;t.classData.type!==void 0&&t.classData.type!==""&&(b().flowchart.htmlLabels?S+="<"+t.classData.type+">":S+="<"+t.classData.type+">");const B=f.node().appendChild(R(S,t.labelStyle,!0,!0));E(B).attr("class","classTitle");let C=B.getBBox();if(H(b().flowchart.htmlLabels)){const v=B.children[0],L=E(B);C=v.getBoundingClientRect(),L.attr("width",C.width),L.attr("height",C.height)}y+=C.height+i,C.width>h&&(h=C.width);const X=[];t.classData.members.forEach(v=>{const L=v.getDisplayDetails();let W=L.displayText;b().flowchart.htmlLabels&&(W=W.replace(/</g,"<").replace(/>/g,">"));const N=f.node().appendChild(R(W,L.cssStyle?L.cssStyle:t.labelStyle,!0,!0));let $=N.getBBox();if(H(b().flowchart.htmlLabels)){const F=N.children[0],D=E(N);$=F.getBoundingClientRect(),D.attr("width",$.width),D.attr("height",$.height)}$.width>h&&(h=$.width),y+=$.height+i,X.push(N)}),y+=l;const A=[];if(t.classData.methods.forEach(v=>{const L=v.getDisplayDetails();let W=L.displayText;b().flowchart.htmlLabels&&(W=W.replace(/</g,"<").replace(/>/g,">"));const N=f.node().appendChild(R(W,L.cssStyle?L.cssStyle:t.labelStyle,!0,!0));let $=N.getBBox();if(H(b().flowchart.htmlLabels)){const F=N.children[0],D=E(N);$=F.getBoundingClientRect(),D.attr("width",$.width),D.attr("height",$.height)}$.width>h&&(h=$.width),y+=$.height+i,A.push(N)}),y+=l,d){let v=(h-u.width)/2;E(x).attr("transform","translate( "+(-1*h/2+v)+", "+-1*y/2+")"),p=u.height+i}let nt=(h-C.width)/2;return E(B).attr("transform","translate( "+(-1*h/2+nt)+", "+(-1*y/2+p)+")"),p+=C.height+i,c.attr("class","divider").attr("x1",-h/2-e).attr("x2",h/2+e).attr("y1",-y/2-e+l+p).attr("y2",-y/2-e+l+p),p+=l,X.forEach(v=>{E(v).attr("transform","translate( "+-h/2+", "+(-1*y/2+p+l/2)+")");const L=v==null?void 0:v.getBBox();p+=((L==null?void 0:L.height)??0)+i}),p+=l,o.attr("class","divider").attr("x1",-h/2-e).attr("x2",h/2+e).attr("y1",-y/2-e+l+p).attr("y2",-y/2-e+l+p),p+=l,A.forEach(v=>{E(v).attr("transform","translate( "+-h/2+", "+(-1*y/2+p)+")");const L=v==null?void 0:v.getBBox();p+=((L==null?void 0:L.height)??0)+i}),n.attr("style",t.style).attr("class","outer title-state").attr("x",-h/2-e).attr("y",-(y/2)-e).attr("width",h+t.padding).attr("height",y+t.padding),m(t,n),t.intersect=function(v){return w.rect(t,v)},s},rt={rhombus:P,composite:zt,question:P,rect:Ut,labelRect:Zt,rectWithTitle:Gt,choice:Ht,circle:Qt,doublecircle:Vt,stadium:Ft,hexagon:It,block_arrow:Nt,rect_left_inv_arrow:Ot,lean_right:Wt,lean_left:Xt,trapezoid:Yt,inv_trapezoid:At,rect_right_inv_arrow:Dt,cylinder:jt,start:Jt,end:Kt,note:$t,subroutine:qt,fork:tt,join:tt,class_box:Pt};let Y={};const or=async(a,t,e)=>{let i,l;if(t.link){let r;b().securityLevel==="sandbox"?r="_top":t.linkTarget&&(r=t.linkTarget||"_blank"),i=a.insert("svg:a").attr("xlink:href",t.link).attr("target",r),l=await rt[t.shape](i,t,e)}else l=await rt[t.shape](a,t,e),i=l;return t.tooltip&&l.attr("title",t.tooltip),t.class&&l.attr("class","node default "+t.class),i.attr("data-node","true"),i.attr("data-id",t.id),Y[t.id]=i,t.haveCallback&&Y[t.id].attr("class",Y[t.id].attr("class")+" clickable"),i},yr=(a,t)=>{Y[t.id]=a},pr=()=>{Y={}},fr=a=>{const t=Y[a.id];g.trace("Transforming node",a.diff,a,"translate("+(a.x-a.width/2-5)+", "+a.width/2+")");const e=8,i=a.diff||0;return a.clusterNode?t.attr("transform","translate("+(a.x+i-a.width/2)+", "+(a.y-a.height/2-e)+")"):t.attr("transform","translate("+a.x+", "+a.y+")"),i},tr=({flowchart:a})=>{var t,e;const i=((t=a==null?void 0:a.subGraphTitleMargin)==null?void 0:t.top)??0,l=((e=a==null?void 0:a.subGraphTitleMargin)==null?void 0:e.bottom)??0,r=i+l;return{subGraphTitleTopMargin:i,subGraphTitleBottomMargin:l,subGraphTitleTotalMargin:r}},O={aggregation:18,extension:18,composition:18,dependency:6,lollipop:13.5,arrow_point:5.3};function U(a,t){if(a===void 0||t===void 0)return{angle:0,deltaX:0,deltaY:0};a=Z(a),t=Z(t);const[e,i]=[a.x,a.y],[l,r]=[t.x,t.y],s=l-e,n=r-i;return{angle:Math.atan(n/s),deltaX:s,deltaY:n}}const Z=a=>Array.isArray(a)?{x:a[0],y:a[1]}:a,rr=a=>({x:function(t,e,i){let l=0;if(e===0&&Object.hasOwn(O,a.arrowTypeStart)){const{angle:r,deltaX:s}=U(i[0],i[1]);l=O[a.arrowTypeStart]*Math.cos(r)*(s>=0?1:-1)}else if(e===i.length-1&&Object.hasOwn(O,a.arrowTypeEnd)){const{angle:r,deltaX:s}=U(i[i.length-1],i[i.length-2]);l=O[a.arrowTypeEnd]*Math.cos(r)*(s>=0?1:-1)}return Z(t).x+l},y:function(t,e,i){let l=0;if(e===0&&Object.hasOwn(O,a.arrowTypeStart)){const{angle:r,deltaY:s}=U(i[0],i[1]);l=O[a.arrowTypeStart]*Math.abs(Math.sin(r))*(s>=0?1:-1)}else if(e===i.length-1&&Object.hasOwn(O,a.arrowTypeEnd)){const{angle:r,deltaY:s}=U(i[i.length-1],i[i.length-2]);l=O[a.arrowTypeEnd]*Math.abs(Math.sin(r))*(s>=0?1:-1)}return Z(t).y+l}}),ar=(a,t,e,i,l)=>{t.arrowTypeStart&&at(a,"start",t.arrowTypeStart,e,i,l),t.arrowTypeEnd&&at(a,"end",t.arrowTypeEnd,e,i,l)},er={arrow_cross:"cross",arrow_point:"point",arrow_barb:"barb",arrow_circle:"circle",aggregation:"aggregation",extension:"extension",composition:"composition",dependency:"dependency",lollipop:"lollipop"},at=(a,t,e,i,l,r)=>{const s=er[e];if(!s){g.warn(`Unknown arrow type: ${e}`);return}const n=t==="start"?"Start":"End";a.attr(`marker-${t}`,`url(${i}#${l}_${r}-${s}${n})`)};let G={},T={};const xr=()=>{G={},T={}},dr=(a,t)=>{const e=H(b().flowchart.htmlLabels),i=t.labelType==="markdown"?st(a,t.label,{style:t.labelStyle,useHtmlLabels:e,addSvgBackground:!0}):R(t.label,t.labelStyle),l=a.insert("g").attr("class","edgeLabel"),r=l.insert("g").attr("class","label");r.node().appendChild(i);let s=i.getBBox();if(e){const c=i.children[0],o=E(i);s=c.getBoundingClientRect(),o.attr("width",s.width),o.attr("height",s.height)}r.attr("transform","translate("+-s.width/2+", "+-s.height/2+")"),G[t.id]=l,t.width=s.width,t.height=s.height;let n;if(t.startLabelLeft){const c=R(t.startLabelLeft,t.labelStyle),o=a.insert("g").attr("class","edgeTerminals"),h=o.insert("g").attr("class","inner");n=h.node().appendChild(c);const y=c.getBBox();h.attr("transform","translate("+-y.width/2+", "+-y.height/2+")"),T[t.id]||(T[t.id]={}),T[t.id].startLeft=o,z(n,t.startLabelLeft)}if(t.startLabelRight){const c=R(t.startLabelRight,t.labelStyle),o=a.insert("g").attr("class","edgeTerminals"),h=o.insert("g").attr("class","inner");n=o.node().appendChild(c),h.node().appendChild(c);const y=c.getBBox();h.attr("transform","translate("+-y.width/2+", "+-y.height/2+")"),T[t.id]||(T[t.id]={}),T[t.id].startRight=o,z(n,t.startLabelRight)}if(t.endLabelLeft){const c=R(t.endLabelLeft,t.labelStyle),o=a.insert("g").attr("class","edgeTerminals"),h=o.insert("g").attr("class","inner");n=h.node().appendChild(c);const y=c.getBBox();h.attr("transform","translate("+-y.width/2+", "+-y.height/2+")"),o.node().appendChild(c),T[t.id]||(T[t.id]={}),T[t.id].endLeft=o,z(n,t.endLabelLeft)}if(t.endLabelRight){const c=R(t.endLabelRight,t.labelStyle),o=a.insert("g").attr("class","edgeTerminals"),h=o.insert("g").attr("class","inner");n=h.node().appendChild(c);const y=c.getBBox();h.attr("transform","translate("+-y.width/2+", "+-y.height/2+")"),o.node().appendChild(c),T[t.id]||(T[t.id]={}),T[t.id].endRight=o,z(n,t.endLabelRight)}return i};function z(a,t){b().flowchart.htmlLabels&&a&&(a.style.width=t.length*9+"px",a.style.height="12px")}const gr=(a,t)=>{g.debug("Moving label abc88 ",a.id,a.label,G[a.id],t);let e=t.updatedPath?t.updatedPath:t.originalPath;const i=b(),{subGraphTitleTotalMargin:l}=tr(i);if(a.label){const r=G[a.id];let s=a.x,n=a.y;if(e){const c=j.calcLabelPosition(e);g.debug("Moving label "+a.label+" from (",s,",",n,") to (",c.x,",",c.y,") abc88"),t.updatedPath&&(s=c.x,n=c.y)}r.attr("transform",`translate(${s}, ${n+l/2})`)}if(a.startLabelLeft){const r=T[a.id].startLeft;let s=a.x,n=a.y;if(e){const c=j.calcTerminalLabelPosition(a.arrowTypeStart?10:0,"start_left",e);s=c.x,n=c.y}r.attr("transform",`translate(${s}, ${n})`)}if(a.startLabelRight){const r=T[a.id].startRight;let s=a.x,n=a.y;if(e){const c=j.calcTerminalLabelPosition(a.arrowTypeStart?10:0,"start_right",e);s=c.x,n=c.y}r.attr("transform",`translate(${s}, ${n})`)}if(a.endLabelLeft){const r=T[a.id].endLeft;let s=a.x,n=a.y;if(e){const c=j.calcTerminalLabelPosition(a.arrowTypeEnd?10:0,"end_left",e);s=c.x,n=c.y}r.attr("transform",`translate(${s}, ${n})`)}if(a.endLabelRight){const r=T[a.id].endRight;let s=a.x,n=a.y;if(e){const c=j.calcTerminalLabelPosition(a.arrowTypeEnd?10:0,"end_right",e);s=c.x,n=c.y}r.attr("transform",`translate(${s}, ${n})`)}},sr=(a,t)=>{const e=a.x,i=a.y,l=Math.abs(t.x-e),r=Math.abs(t.y-i),s=a.width/2,n=a.height/2;return l>=s||r>=n},ir=(a,t,e)=>{g.debug(`intersection calc abc89:
|
|
1
|
+
import{l as g,an as lt,g as b,t as H,d as E,A as j,i as Q,ao as V}from"./mermaid.core-NVIiXnRA.js";import{c as st}from"./createText-1719965b-CLlPr73k.js";import{l as ct}from"./line-olpPNgnh.js";const ht=(a,t,e,i)=>{t.forEach(l=>{wt[l](a,e,i)})},ot=(a,t,e)=>{g.trace("Making markers for ",e),a.append("defs").append("marker").attr("id",e+"_"+t+"-extensionStart").attr("class","marker extension "+t).attr("refX",18).attr("refY",7).attr("markerWidth",190).attr("markerHeight",240).attr("orient","auto").append("path").attr("d","M 1,7 L18,13 V 1 Z"),a.append("defs").append("marker").attr("id",e+"_"+t+"-extensionEnd").attr("class","marker extension "+t).attr("refX",1).attr("refY",7).attr("markerWidth",20).attr("markerHeight",28).attr("orient","auto").append("path").attr("d","M 1,1 V 13 L18,7 Z")},yt=(a,t,e)=>{a.append("defs").append("marker").attr("id",e+"_"+t+"-compositionStart").attr("class","marker composition "+t).attr("refX",18).attr("refY",7).attr("markerWidth",190).attr("markerHeight",240).attr("orient","auto").append("path").attr("d","M 18,7 L9,13 L1,7 L9,1 Z"),a.append("defs").append("marker").attr("id",e+"_"+t+"-compositionEnd").attr("class","marker composition "+t).attr("refX",1).attr("refY",7).attr("markerWidth",20).attr("markerHeight",28).attr("orient","auto").append("path").attr("d","M 18,7 L9,13 L1,7 L9,1 Z")},pt=(a,t,e)=>{a.append("defs").append("marker").attr("id",e+"_"+t+"-aggregationStart").attr("class","marker aggregation "+t).attr("refX",18).attr("refY",7).attr("markerWidth",190).attr("markerHeight",240).attr("orient","auto").append("path").attr("d","M 18,7 L9,13 L1,7 L9,1 Z"),a.append("defs").append("marker").attr("id",e+"_"+t+"-aggregationEnd").attr("class","marker aggregation "+t).attr("refX",1).attr("refY",7).attr("markerWidth",20).attr("markerHeight",28).attr("orient","auto").append("path").attr("d","M 18,7 L9,13 L1,7 L9,1 Z")},ft=(a,t,e)=>{a.append("defs").append("marker").attr("id",e+"_"+t+"-dependencyStart").attr("class","marker dependency "+t).attr("refX",6).attr("refY",7).attr("markerWidth",190).attr("markerHeight",240).attr("orient","auto").append("path").attr("d","M 5,7 L9,13 L1,7 L9,1 Z"),a.append("defs").append("marker").attr("id",e+"_"+t+"-dependencyEnd").attr("class","marker dependency "+t).attr("refX",13).attr("refY",7).attr("markerWidth",20).attr("markerHeight",28).attr("orient","auto").append("path").attr("d","M 18,7 L9,13 L14,7 L9,1 Z")},xt=(a,t,e)=>{a.append("defs").append("marker").attr("id",e+"_"+t+"-lollipopStart").attr("class","marker lollipop "+t).attr("refX",13).attr("refY",7).attr("markerWidth",190).attr("markerHeight",240).attr("orient","auto").append("circle").attr("stroke","black").attr("fill","transparent").attr("cx",7).attr("cy",7).attr("r",6),a.append("defs").append("marker").attr("id",e+"_"+t+"-lollipopEnd").attr("class","marker lollipop "+t).attr("refX",1).attr("refY",7).attr("markerWidth",190).attr("markerHeight",240).attr("orient","auto").append("circle").attr("stroke","black").attr("fill","transparent").attr("cx",7).attr("cy",7).attr("r",6)},dt=(a,t,e)=>{a.append("marker").attr("id",e+"_"+t+"-pointEnd").attr("class","marker "+t).attr("viewBox","0 0 10 10").attr("refX",6).attr("refY",5).attr("markerUnits","userSpaceOnUse").attr("markerWidth",12).attr("markerHeight",12).attr("orient","auto").append("path").attr("d","M 0 0 L 10 5 L 0 10 z").attr("class","arrowMarkerPath").style("stroke-width",1).style("stroke-dasharray","1,0"),a.append("marker").attr("id",e+"_"+t+"-pointStart").attr("class","marker "+t).attr("viewBox","0 0 10 10").attr("refX",4.5).attr("refY",5).attr("markerUnits","userSpaceOnUse").attr("markerWidth",12).attr("markerHeight",12).attr("orient","auto").append("path").attr("d","M 0 5 L 10 10 L 10 0 z").attr("class","arrowMarkerPath").style("stroke-width",1).style("stroke-dasharray","1,0")},gt=(a,t,e)=>{a.append("marker").attr("id",e+"_"+t+"-circleEnd").attr("class","marker "+t).attr("viewBox","0 0 10 10").attr("refX",11).attr("refY",5).attr("markerUnits","userSpaceOnUse").attr("markerWidth",11).attr("markerHeight",11).attr("orient","auto").append("circle").attr("cx","5").attr("cy","5").attr("r","5").attr("class","arrowMarkerPath").style("stroke-width",1).style("stroke-dasharray","1,0"),a.append("marker").attr("id",e+"_"+t+"-circleStart").attr("class","marker "+t).attr("viewBox","0 0 10 10").attr("refX",-1).attr("refY",5).attr("markerUnits","userSpaceOnUse").attr("markerWidth",11).attr("markerHeight",11).attr("orient","auto").append("circle").attr("cx","5").attr("cy","5").attr("r","5").attr("class","arrowMarkerPath").style("stroke-width",1).style("stroke-dasharray","1,0")},ut=(a,t,e)=>{a.append("marker").attr("id",e+"_"+t+"-crossEnd").attr("class","marker cross "+t).attr("viewBox","0 0 11 11").attr("refX",12).attr("refY",5.2).attr("markerUnits","userSpaceOnUse").attr("markerWidth",11).attr("markerHeight",11).attr("orient","auto").append("path").attr("d","M 1,1 l 9,9 M 10,1 l -9,9").attr("class","arrowMarkerPath").style("stroke-width",2).style("stroke-dasharray","1,0"),a.append("marker").attr("id",e+"_"+t+"-crossStart").attr("class","marker cross "+t).attr("viewBox","0 0 11 11").attr("refX",-1).attr("refY",5.2).attr("markerUnits","userSpaceOnUse").attr("markerWidth",11).attr("markerHeight",11).attr("orient","auto").append("path").attr("d","M 1,1 l 9,9 M 10,1 l -9,9").attr("class","arrowMarkerPath").style("stroke-width",2).style("stroke-dasharray","1,0")},bt=(a,t,e)=>{a.append("defs").append("marker").attr("id",e+"_"+t+"-barbEnd").attr("refX",19).attr("refY",7).attr("markerWidth",20).attr("markerHeight",14).attr("markerUnits","strokeWidth").attr("orient","auto").append("path").attr("d","M 19,7 L9,13 L14,7 L9,1 Z")},wt={extension:ot,composition:yt,aggregation:pt,dependency:ft,lollipop:xt,point:dt,circle:gt,cross:ut,barb:bt},hr=ht;function mt(a,t){t&&a.attr("style",t)}function kt(a,t){const e=E(document.createElementNS("http://www.w3.org/2000/svg","foreignObject")),i=e.append("xhtml:div"),l=a.label,r=a.isNode?"nodeLabel":"edgeLabel";return i.html(Q('<span class="'+r+'" '+(a.labelStyle?'style="'+a.labelStyle+'"':"")+">"+l+"</span>",t)),mt(i,a.labelStyle),i.style("display","inline-block"),i.style("white-space","nowrap"),i.attr("xmlns","http://www.w3.org/1999/xhtml"),e.node()}const vt=(a,t,e,i)=>{let l=a||"";typeof l=="object"&&(l=l[0]);const r=b();if(H(r.flowchart.htmlLabels)){l=l.replace(/\\n|\n/g,"<br />"),g.debug("vertexText"+l);const s={isNode:i,label:V(l).replace(/fa[blrs]?:fa-[\w-]+/g,c=>`<i class='${c.replace(":"," ")}'></i>`),labelStyle:t.replace("fill:","color:")};return kt(s,r)}else{const s=document.createElementNS("http://www.w3.org/2000/svg","text");s.setAttribute("style",t.replace("color:","fill:"));let n=[];typeof l=="string"?n=l.split(/\\n|\n|<br\s*\/?>/gi):Array.isArray(l)?n=l:n=[];for(const c of n){const o=document.createElementNS("http://www.w3.org/2000/svg","tspan");o.setAttributeNS("http://www.w3.org/XML/1998/namespace","xml:space","preserve"),o.setAttribute("dy","1em"),o.setAttribute("x","0"),e?o.setAttribute("class","title-row"):o.setAttribute("class","row"),o.textContent=c.trim(),s.appendChild(o)}return s}},R=vt,M=async(a,t,e,i)=>{let l;const r=t.useHtmlLabels||H(b().flowchart.htmlLabels);e?l=e:l="node default";const s=a.insert("g").attr("class",l).attr("id",t.domId||t.id),n=s.insert("g").attr("class","label").attr("style",t.labelStyle);let c;t.labelText===void 0?c="":c=typeof t.labelText=="string"?t.labelText:t.labelText[0];const o=n.node();let h;t.labelType==="markdown"?h=st(n,Q(V(c),b()),{useHtmlLabels:r,width:t.width||b().flowchart.wrappingWidth,classes:"markdown-node-label"}):h=o.appendChild(R(Q(V(c),b()),t.labelStyle,!1,i));let y=h.getBBox();const f=t.padding/2;if(H(b().flowchart.htmlLabels)){const p=h.children[0],d=E(h),k=p.getElementsByTagName("img");if(k){const x=c.replace(/<img[^>]*>/g,"").trim()==="";await Promise.all([...k].map(u=>new Promise(S=>{function B(){if(u.style.display="flex",u.style.flexDirection="column",x){const C=b().fontSize?b().fontSize:window.getComputedStyle(document.body).fontSize,A=parseInt(C,10)*5+"px";u.style.minWidth=A,u.style.maxWidth=A}else u.style.width="100%";S(u)}setTimeout(()=>{u.complete&&B()}),u.addEventListener("error",B),u.addEventListener("load",B)})))}y=p.getBoundingClientRect(),d.attr("width",y.width),d.attr("height",y.height)}return r?n.attr("transform","translate("+-y.width/2+", "+-y.height/2+")"):n.attr("transform","translate(0, "+-y.height/2+")"),t.centerLabel&&n.attr("transform","translate("+-y.width/2+", "+-y.height/2+")"),n.insert("rect",":first-child"),{shapeSvg:s,bbox:y,halfPadding:f,label:n}},m=(a,t)=>{const e=t.node().getBBox();a.width=e.width,a.height=e.height};function I(a,t,e,i){return a.insert("polygon",":first-child").attr("points",i.map(function(l){return l.x+","+l.y}).join(" ")).attr("class","label-container").attr("transform","translate("+-t/2+","+e/2+")")}function Lt(a,t){return a.intersect(t)}function it(a,t,e,i){var l=a.x,r=a.y,s=l-i.x,n=r-i.y,c=Math.sqrt(t*t*n*n+e*e*s*s),o=Math.abs(t*e*s/c);i.x<l&&(o=-o);var h=Math.abs(t*e*n/c);return i.y<r&&(h=-h),{x:l+o,y:r+h}}function St(a,t,e){return it(a,t,t,e)}function Mt(a,t,e,i){var l,r,s,n,c,o,h,y,f,p,d,k,x,u,S;if(l=t.y-a.y,s=a.x-t.x,c=t.x*a.y-a.x*t.y,f=l*e.x+s*e.y+c,p=l*i.x+s*i.y+c,!(f!==0&&p!==0&&J(f,p))&&(r=i.y-e.y,n=e.x-i.x,o=i.x*e.y-e.x*i.y,h=r*a.x+n*a.y+o,y=r*t.x+n*t.y+o,!(h!==0&&y!==0&&J(h,y))&&(d=l*n-r*s,d!==0)))return k=Math.abs(d/2),x=s*o-n*c,u=x<0?(x-k)/d:(x+k)/d,x=r*c-l*o,S=x<0?(x-k)/d:(x+k)/d,{x:u,y:S}}function J(a,t){return a*t>0}function Tt(a,t,e){var i=a.x,l=a.y,r=[],s=Number.POSITIVE_INFINITY,n=Number.POSITIVE_INFINITY;typeof t.forEach=="function"?t.forEach(function(d){s=Math.min(s,d.x),n=Math.min(n,d.y)}):(s=Math.min(s,t.x),n=Math.min(n,t.y));for(var c=i-a.width/2-s,o=l-a.height/2-n,h=0;h<t.length;h++){var y=t[h],f=t[h<t.length-1?h+1:0],p=Mt(a,e,{x:c+y.x,y:o+y.y},{x:c+f.x,y:o+f.y});p&&r.push(p)}return r.length?(r.length>1&&r.sort(function(d,k){var x=d.x-e.x,u=d.y-e.y,S=Math.sqrt(x*x+u*u),B=k.x-e.x,C=k.y-e.y,X=Math.sqrt(B*B+C*C);return S<X?-1:S===X?0:1}),r[0]):a}const Bt=(a,t)=>{var e=a.x,i=a.y,l=t.x-e,r=t.y-i,s=a.width/2,n=a.height/2,c,o;return Math.abs(r)*s>Math.abs(l)*n?(r<0&&(n=-n),c=r===0?0:n*l/r,o=n):(l<0&&(s=-s),c=s,o=l===0?0:s*r/l),{x:e+c,y:i+o}},Et=Bt,w={node:Lt,circle:St,ellipse:it,polygon:Tt,rect:Et},Ct=async(a,t)=>{t.useHtmlLabels||b().flowchart.htmlLabels||(t.centerLabel=!0);const{shapeSvg:i,bbox:l,halfPadding:r}=await M(a,t,"node "+t.classes,!0);g.info("Classes = ",t.classes);const s=i.insert("rect",":first-child");return s.attr("rx",t.rx).attr("ry",t.ry).attr("x",-l.width/2-r).attr("y",-l.height/2-r).attr("width",l.width+t.padding).attr("height",l.height+t.padding),m(t,s),t.intersect=function(n){return w.rect(t,n)},i},$t=Ct,_t=a=>{const t=new Set;for(const e of a)switch(e){case"x":t.add("right"),t.add("left");break;case"y":t.add("up"),t.add("down");break;default:t.add(e);break}return t},Rt=(a,t,e)=>{const i=_t(a),l=2,r=t.height+2*e.padding,s=r/l,n=t.width+2*s+e.padding,c=e.padding/2;return i.has("right")&&i.has("left")&&i.has("up")&&i.has("down")?[{x:0,y:0},{x:s,y:0},{x:n/2,y:2*c},{x:n-s,y:0},{x:n,y:0},{x:n,y:-r/3},{x:n+2*c,y:-r/2},{x:n,y:-2*r/3},{x:n,y:-r},{x:n-s,y:-r},{x:n/2,y:-r-2*c},{x:s,y:-r},{x:0,y:-r},{x:0,y:-2*r/3},{x:-2*c,y:-r/2},{x:0,y:-r/3}]:i.has("right")&&i.has("left")&&i.has("up")?[{x:s,y:0},{x:n-s,y:0},{x:n,y:-r/2},{x:n-s,y:-r},{x:s,y:-r},{x:0,y:-r/2}]:i.has("right")&&i.has("left")&&i.has("down")?[{x:0,y:0},{x:s,y:-r},{x:n-s,y:-r},{x:n,y:0}]:i.has("right")&&i.has("up")&&i.has("down")?[{x:0,y:0},{x:n,y:-s},{x:n,y:-r+s},{x:0,y:-r}]:i.has("left")&&i.has("up")&&i.has("down")?[{x:n,y:0},{x:0,y:-s},{x:0,y:-r+s},{x:n,y:-r}]:i.has("right")&&i.has("left")?[{x:s,y:0},{x:s,y:-c},{x:n-s,y:-c},{x:n-s,y:0},{x:n,y:-r/2},{x:n-s,y:-r},{x:n-s,y:-r+c},{x:s,y:-r+c},{x:s,y:-r},{x:0,y:-r/2}]:i.has("up")&&i.has("down")?[{x:n/2,y:0},{x:0,y:-c},{x:s,y:-c},{x:s,y:-r+c},{x:0,y:-r+c},{x:n/2,y:-r},{x:n,y:-r+c},{x:n-s,y:-r+c},{x:n-s,y:-c},{x:n,y:-c}]:i.has("right")&&i.has("up")?[{x:0,y:0},{x:n,y:-s},{x:0,y:-r}]:i.has("right")&&i.has("down")?[{x:0,y:0},{x:n,y:0},{x:0,y:-r}]:i.has("left")&&i.has("up")?[{x:n,y:0},{x:0,y:-s},{x:n,y:-r}]:i.has("left")&&i.has("down")?[{x:n,y:0},{x:0,y:0},{x:n,y:-r}]:i.has("right")?[{x:s,y:-c},{x:s,y:-c},{x:n-s,y:-c},{x:n-s,y:0},{x:n,y:-r/2},{x:n-s,y:-r},{x:n-s,y:-r+c},{x:s,y:-r+c},{x:s,y:-r+c}]:i.has("left")?[{x:s,y:0},{x:s,y:-c},{x:n-s,y:-c},{x:n-s,y:-r+c},{x:s,y:-r+c},{x:s,y:-r},{x:0,y:-r/2}]:i.has("up")?[{x:s,y:-c},{x:s,y:-r+c},{x:0,y:-r+c},{x:n/2,y:-r},{x:n,y:-r+c},{x:n-s,y:-r+c},{x:n-s,y:-c}]:i.has("down")?[{x:n/2,y:0},{x:0,y:-c},{x:s,y:-c},{x:s,y:-r+c},{x:n-s,y:-r+c},{x:n-s,y:-c},{x:n,y:-c}]:[{x:0,y:0}]},K=a=>a?" "+a:"",_=(a,t)=>`node default${K(a.classes)} ${K(a.class)}`,P=async(a,t)=>{const{shapeSvg:e,bbox:i}=await M(a,t,_(t),!0),l=i.width+t.padding,r=i.height+t.padding,s=l+r,n=[{x:s/2,y:0},{x:s,y:-s/2},{x:s/2,y:-s},{x:0,y:-s/2}];g.info("Question main (Circle)");const c=I(e,s,s,n);return c.attr("style",t.style),m(t,c),t.intersect=function(o){return g.warn("Intersect called"),w.polygon(t,n,o)},e},Ht=(a,t)=>{const e=a.insert("g").attr("class","node default").attr("id",t.domId||t.id),i=28,l=[{x:0,y:i/2},{x:i/2,y:0},{x:0,y:-i/2},{x:-i/2,y:0}];return e.insert("polygon",":first-child").attr("points",l.map(function(s){return s.x+","+s.y}).join(" ")).attr("class","state-start").attr("r",7).attr("width",28).attr("height",28),t.width=28,t.height=28,t.intersect=function(s){return w.circle(t,14,s)},e},It=async(a,t)=>{const{shapeSvg:e,bbox:i}=await M(a,t,_(t),!0),l=4,r=i.height+t.padding,s=r/l,n=i.width+2*s+t.padding,c=[{x:s,y:0},{x:n-s,y:0},{x:n,y:-r/2},{x:n-s,y:-r},{x:s,y:-r},{x:0,y:-r/2}],o=I(e,n,r,c);return o.attr("style",t.style),m(t,o),t.intersect=function(h){return w.polygon(t,c,h)},e},Nt=async(a,t)=>{const{shapeSvg:e,bbox:i}=await M(a,t,void 0,!0),l=2,r=i.height+2*t.padding,s=r/l,n=i.width+2*s+t.padding,c=Rt(t.directions,i,t),o=I(e,n,r,c);return o.attr("style",t.style),m(t,o),t.intersect=function(h){return w.polygon(t,c,h)},e},Ot=async(a,t)=>{const{shapeSvg:e,bbox:i}=await M(a,t,_(t),!0),l=i.width+t.padding,r=i.height+t.padding,s=[{x:-r/2,y:0},{x:l,y:0},{x:l,y:-r},{x:-r/2,y:-r},{x:0,y:-r/2}];return I(e,l,r,s).attr("style",t.style),t.width=l+r,t.height=r,t.intersect=function(c){return w.polygon(t,s,c)},e},Wt=async(a,t)=>{const{shapeSvg:e,bbox:i}=await M(a,t,_(t),!0),l=i.width+t.padding,r=i.height+t.padding,s=[{x:-2*r/6,y:0},{x:l-r/6,y:0},{x:l+2*r/6,y:-r},{x:r/6,y:-r}],n=I(e,l,r,s);return n.attr("style",t.style),m(t,n),t.intersect=function(c){return w.polygon(t,s,c)},e},Xt=async(a,t)=>{const{shapeSvg:e,bbox:i}=await M(a,t,_(t),!0),l=i.width+t.padding,r=i.height+t.padding,s=[{x:2*r/6,y:0},{x:l+r/6,y:0},{x:l-2*r/6,y:-r},{x:-r/6,y:-r}],n=I(e,l,r,s);return n.attr("style",t.style),m(t,n),t.intersect=function(c){return w.polygon(t,s,c)},e},Yt=async(a,t)=>{const{shapeSvg:e,bbox:i}=await M(a,t,_(t),!0),l=i.width+t.padding,r=i.height+t.padding,s=[{x:-2*r/6,y:0},{x:l+2*r/6,y:0},{x:l-r/6,y:-r},{x:r/6,y:-r}],n=I(e,l,r,s);return n.attr("style",t.style),m(t,n),t.intersect=function(c){return w.polygon(t,s,c)},e},At=async(a,t)=>{const{shapeSvg:e,bbox:i}=await M(a,t,_(t),!0),l=i.width+t.padding,r=i.height+t.padding,s=[{x:r/6,y:0},{x:l-r/6,y:0},{x:l+2*r/6,y:-r},{x:-2*r/6,y:-r}],n=I(e,l,r,s);return n.attr("style",t.style),m(t,n),t.intersect=function(c){return w.polygon(t,s,c)},e},Dt=async(a,t)=>{const{shapeSvg:e,bbox:i}=await M(a,t,_(t),!0),l=i.width+t.padding,r=i.height+t.padding,s=[{x:0,y:0},{x:l+r/2,y:0},{x:l,y:-r/2},{x:l+r/2,y:-r},{x:0,y:-r}],n=I(e,l,r,s);return n.attr("style",t.style),m(t,n),t.intersect=function(c){return w.polygon(t,s,c)},e},jt=async(a,t)=>{const{shapeSvg:e,bbox:i}=await M(a,t,_(t),!0),l=i.width+t.padding,r=l/2,s=r/(2.5+l/50),n=i.height+s+t.padding,c="M 0,"+s+" a "+r+","+s+" 0,0,0 "+l+" 0 a "+r+","+s+" 0,0,0 "+-l+" 0 l 0,"+n+" a "+r+","+s+" 0,0,0 "+l+" 0 l 0,"+-n,o=e.attr("label-offset-y",s).insert("path",":first-child").attr("style",t.style).attr("d",c).attr("transform","translate("+-l/2+","+-(n/2+s)+")");return m(t,o),t.intersect=function(h){const y=w.rect(t,h),f=y.x-t.x;if(r!=0&&(Math.abs(f)<t.width/2||Math.abs(f)==t.width/2&&Math.abs(y.y-t.y)>t.height/2-s)){let p=s*s*(1-f*f/(r*r));p!=0&&(p=Math.sqrt(p)),p=s-p,h.y-t.y>0&&(p=-p),y.y+=p}return y},e},Ut=async(a,t)=>{const{shapeSvg:e,bbox:i,halfPadding:l}=await M(a,t,"node "+t.classes+" "+t.class,!0),r=e.insert("rect",":first-child"),s=t.positioned?t.width:i.width+t.padding,n=t.positioned?t.height:i.height+t.padding,c=t.positioned?-s/2:-i.width/2-l,o=t.positioned?-n/2:-i.height/2-l;if(r.attr("class","basic label-container").attr("style",t.style).attr("rx",t.rx).attr("ry",t.ry).attr("x",c).attr("y",o).attr("width",s).attr("height",n),t.props){const h=new Set(Object.keys(t.props));t.props.borders&&(q(r,t.props.borders,s,n),h.delete("borders")),h.forEach(y=>{g.warn(`Unknown node property ${y}`)})}return m(t,r),t.intersect=function(h){return w.rect(t,h)},e},zt=async(a,t)=>{const{shapeSvg:e,bbox:i,halfPadding:l}=await M(a,t,"node "+t.classes,!0),r=e.insert("rect",":first-child"),s=t.positioned?t.width:i.width+t.padding,n=t.positioned?t.height:i.height+t.padding,c=t.positioned?-s/2:-i.width/2-l,o=t.positioned?-n/2:-i.height/2-l;if(r.attr("class","basic cluster composite label-container").attr("style",t.style).attr("rx",t.rx).attr("ry",t.ry).attr("x",c).attr("y",o).attr("width",s).attr("height",n),t.props){const h=new Set(Object.keys(t.props));t.props.borders&&(q(r,t.props.borders,s,n),h.delete("borders")),h.forEach(y=>{g.warn(`Unknown node property ${y}`)})}return m(t,r),t.intersect=function(h){return w.rect(t,h)},e},Zt=async(a,t)=>{const{shapeSvg:e}=await M(a,t,"label",!0);g.trace("Classes = ",t.class);const i=e.insert("rect",":first-child"),l=0,r=0;if(i.attr("width",l).attr("height",r),e.attr("class","label edgeLabel"),t.props){const s=new Set(Object.keys(t.props));t.props.borders&&(q(i,t.props.borders,l,r),s.delete("borders")),s.forEach(n=>{g.warn(`Unknown node property ${n}`)})}return m(t,i),t.intersect=function(s){return w.rect(t,s)},e};function q(a,t,e,i){const l=[],r=n=>{l.push(n,0)},s=n=>{l.push(0,n)};t.includes("t")?(g.debug("add top border"),r(e)):s(e),t.includes("r")?(g.debug("add right border"),r(i)):s(i),t.includes("b")?(g.debug("add bottom border"),r(e)):s(e),t.includes("l")?(g.debug("add left border"),r(i)):s(i),a.attr("stroke-dasharray",l.join(" "))}const Gt=(a,t)=>{let e;t.classes?e="node "+t.classes:e="node default";const i=a.insert("g").attr("class",e).attr("id",t.domId||t.id),l=i.insert("rect",":first-child"),r=i.insert("line"),s=i.insert("g").attr("class","label"),n=t.labelText.flat?t.labelText.flat():t.labelText;let c="";typeof n=="object"?c=n[0]:c=n,g.info("Label text abc79",c,n,typeof n=="object");const o=s.node().appendChild(R(c,t.labelStyle,!0,!0));let h={width:0,height:0};if(H(b().flowchart.htmlLabels)){const k=o.children[0],x=E(o);h=k.getBoundingClientRect(),x.attr("width",h.width),x.attr("height",h.height)}g.info("Text 2",n);const y=n.slice(1,n.length);let f=o.getBBox();const p=s.node().appendChild(R(y.join?y.join("<br/>"):y,t.labelStyle,!0,!0));if(H(b().flowchart.htmlLabels)){const k=p.children[0],x=E(p);h=k.getBoundingClientRect(),x.attr("width",h.width),x.attr("height",h.height)}const d=t.padding/2;return E(p).attr("transform","translate( "+(h.width>f.width?0:(f.width-h.width)/2)+", "+(f.height+d+5)+")"),E(o).attr("transform","translate( "+(h.width<f.width?0:-(f.width-h.width)/2)+", 0)"),h=s.node().getBBox(),s.attr("transform","translate("+-h.width/2+", "+(-h.height/2-d+3)+")"),l.attr("class","outer title-state").attr("x",-h.width/2-d).attr("y",-h.height/2-d).attr("width",h.width+t.padding).attr("height",h.height+t.padding),r.attr("class","divider").attr("x1",-h.width/2-d).attr("x2",h.width/2+d).attr("y1",-h.height/2-d+f.height+d).attr("y2",-h.height/2-d+f.height+d),m(t,l),t.intersect=function(k){return w.rect(t,k)},i},Ft=async(a,t)=>{const{shapeSvg:e,bbox:i}=await M(a,t,_(t),!0),l=i.height+t.padding,r=i.width+l/4+t.padding,s=e.insert("rect",":first-child").attr("style",t.style).attr("rx",l/2).attr("ry",l/2).attr("x",-r/2).attr("y",-l/2).attr("width",r).attr("height",l);return m(t,s),t.intersect=function(n){return w.rect(t,n)},e},Qt=async(a,t)=>{const{shapeSvg:e,bbox:i,halfPadding:l}=await M(a,t,_(t),!0),r=e.insert("circle",":first-child");return r.attr("style",t.style).attr("rx",t.rx).attr("ry",t.ry).attr("r",i.width/2+l).attr("width",i.width+t.padding).attr("height",i.height+t.padding),g.info("Circle main"),m(t,r),t.intersect=function(s){return g.info("Circle intersect",t,i.width/2+l,s),w.circle(t,i.width/2+l,s)},e},Vt=async(a,t)=>{const{shapeSvg:e,bbox:i,halfPadding:l}=await M(a,t,_(t),!0),r=5,s=e.insert("g",":first-child"),n=s.insert("circle"),c=s.insert("circle");return s.attr("class",t.class),n.attr("style",t.style).attr("rx",t.rx).attr("ry",t.ry).attr("r",i.width/2+l+r).attr("width",i.width+t.padding+r*2).attr("height",i.height+t.padding+r*2),c.attr("style",t.style).attr("rx",t.rx).attr("ry",t.ry).attr("r",i.width/2+l).attr("width",i.width+t.padding).attr("height",i.height+t.padding),g.info("DoubleCircle main"),m(t,n),t.intersect=function(o){return g.info("DoubleCircle intersect",t,i.width/2+l+r,o),w.circle(t,i.width/2+l+r,o)},e},qt=async(a,t)=>{const{shapeSvg:e,bbox:i}=await M(a,t,_(t),!0),l=i.width+t.padding,r=i.height+t.padding,s=[{x:0,y:0},{x:l,y:0},{x:l,y:-r},{x:0,y:-r},{x:0,y:0},{x:-8,y:0},{x:l+8,y:0},{x:l+8,y:-r},{x:-8,y:-r},{x:-8,y:0}],n=I(e,l,r,s);return n.attr("style",t.style),m(t,n),t.intersect=function(c){return w.polygon(t,s,c)},e},Jt=(a,t)=>{const e=a.insert("g").attr("class","node default").attr("id",t.domId||t.id),i=e.insert("circle",":first-child");return i.attr("class","state-start").attr("r",7).attr("width",14).attr("height",14),m(t,i),t.intersect=function(l){return w.circle(t,7,l)},e},tt=(a,t,e)=>{const i=a.insert("g").attr("class","node default").attr("id",t.domId||t.id);let l=70,r=10;e==="LR"&&(l=10,r=70);const s=i.append("rect").attr("x",-1*l/2).attr("y",-1*r/2).attr("width",l).attr("height",r).attr("class","fork-join");return m(t,s),t.height=t.height+t.padding/2,t.width=t.width+t.padding/2,t.intersect=function(n){return w.rect(t,n)},i},Kt=(a,t)=>{const e=a.insert("g").attr("class","node default").attr("id",t.domId||t.id),i=e.insert("circle",":first-child"),l=e.insert("circle",":first-child");return l.attr("class","state-start").attr("r",7).attr("width",14).attr("height",14),i.attr("class","state-end").attr("r",5).attr("width",10).attr("height",10),m(t,l),t.intersect=function(r){return w.circle(t,7,r)},e},Pt=(a,t)=>{const e=t.padding/2,i=4,l=8;let r;t.classes?r="node "+t.classes:r="node default";const s=a.insert("g").attr("class",r).attr("id",t.domId||t.id),n=s.insert("rect",":first-child"),c=s.insert("line"),o=s.insert("line");let h=0,y=i;const f=s.insert("g").attr("class","label");let p=0;const d=t.classData.annotations&&t.classData.annotations[0],k=t.classData.annotations[0]?"«"+t.classData.annotations[0]+"»":"",x=f.node().appendChild(R(k,t.labelStyle,!0,!0));let u=x.getBBox();if(H(b().flowchart.htmlLabels)){const v=x.children[0],L=E(x);u=v.getBoundingClientRect(),L.attr("width",u.width),L.attr("height",u.height)}t.classData.annotations[0]&&(y+=u.height+i,h+=u.width);let S=t.classData.label;t.classData.type!==void 0&&t.classData.type!==""&&(b().flowchart.htmlLabels?S+="<"+t.classData.type+">":S+="<"+t.classData.type+">");const B=f.node().appendChild(R(S,t.labelStyle,!0,!0));E(B).attr("class","classTitle");let C=B.getBBox();if(H(b().flowchart.htmlLabels)){const v=B.children[0],L=E(B);C=v.getBoundingClientRect(),L.attr("width",C.width),L.attr("height",C.height)}y+=C.height+i,C.width>h&&(h=C.width);const X=[];t.classData.members.forEach(v=>{const L=v.getDisplayDetails();let W=L.displayText;b().flowchart.htmlLabels&&(W=W.replace(/</g,"<").replace(/>/g,">"));const N=f.node().appendChild(R(W,L.cssStyle?L.cssStyle:t.labelStyle,!0,!0));let $=N.getBBox();if(H(b().flowchart.htmlLabels)){const F=N.children[0],D=E(N);$=F.getBoundingClientRect(),D.attr("width",$.width),D.attr("height",$.height)}$.width>h&&(h=$.width),y+=$.height+i,X.push(N)}),y+=l;const A=[];if(t.classData.methods.forEach(v=>{const L=v.getDisplayDetails();let W=L.displayText;b().flowchart.htmlLabels&&(W=W.replace(/</g,"<").replace(/>/g,">"));const N=f.node().appendChild(R(W,L.cssStyle?L.cssStyle:t.labelStyle,!0,!0));let $=N.getBBox();if(H(b().flowchart.htmlLabels)){const F=N.children[0],D=E(N);$=F.getBoundingClientRect(),D.attr("width",$.width),D.attr("height",$.height)}$.width>h&&(h=$.width),y+=$.height+i,A.push(N)}),y+=l,d){let v=(h-u.width)/2;E(x).attr("transform","translate( "+(-1*h/2+v)+", "+-1*y/2+")"),p=u.height+i}let nt=(h-C.width)/2;return E(B).attr("transform","translate( "+(-1*h/2+nt)+", "+(-1*y/2+p)+")"),p+=C.height+i,c.attr("class","divider").attr("x1",-h/2-e).attr("x2",h/2+e).attr("y1",-y/2-e+l+p).attr("y2",-y/2-e+l+p),p+=l,X.forEach(v=>{E(v).attr("transform","translate( "+-h/2+", "+(-1*y/2+p+l/2)+")");const L=v==null?void 0:v.getBBox();p+=((L==null?void 0:L.height)??0)+i}),p+=l,o.attr("class","divider").attr("x1",-h/2-e).attr("x2",h/2+e).attr("y1",-y/2-e+l+p).attr("y2",-y/2-e+l+p),p+=l,A.forEach(v=>{E(v).attr("transform","translate( "+-h/2+", "+(-1*y/2+p)+")");const L=v==null?void 0:v.getBBox();p+=((L==null?void 0:L.height)??0)+i}),n.attr("style",t.style).attr("class","outer title-state").attr("x",-h/2-e).attr("y",-(y/2)-e).attr("width",h+t.padding).attr("height",y+t.padding),m(t,n),t.intersect=function(v){return w.rect(t,v)},s},rt={rhombus:P,composite:zt,question:P,rect:Ut,labelRect:Zt,rectWithTitle:Gt,choice:Ht,circle:Qt,doublecircle:Vt,stadium:Ft,hexagon:It,block_arrow:Nt,rect_left_inv_arrow:Ot,lean_right:Wt,lean_left:Xt,trapezoid:Yt,inv_trapezoid:At,rect_right_inv_arrow:Dt,cylinder:jt,start:Jt,end:Kt,note:$t,subroutine:qt,fork:tt,join:tt,class_box:Pt};let Y={};const or=async(a,t,e)=>{let i,l;if(t.link){let r;b().securityLevel==="sandbox"?r="_top":t.linkTarget&&(r=t.linkTarget||"_blank"),i=a.insert("svg:a").attr("xlink:href",t.link).attr("target",r),l=await rt[t.shape](i,t,e)}else l=await rt[t.shape](a,t,e),i=l;return t.tooltip&&l.attr("title",t.tooltip),t.class&&l.attr("class","node default "+t.class),i.attr("data-node","true"),i.attr("data-id",t.id),Y[t.id]=i,t.haveCallback&&Y[t.id].attr("class",Y[t.id].attr("class")+" clickable"),i},yr=(a,t)=>{Y[t.id]=a},pr=()=>{Y={}},fr=a=>{const t=Y[a.id];g.trace("Transforming node",a.diff,a,"translate("+(a.x-a.width/2-5)+", "+a.width/2+")");const e=8,i=a.diff||0;return a.clusterNode?t.attr("transform","translate("+(a.x+i-a.width/2)+", "+(a.y-a.height/2-e)+")"):t.attr("transform","translate("+a.x+", "+a.y+")"),i},tr=({flowchart:a})=>{var t,e;const i=((t=a==null?void 0:a.subGraphTitleMargin)==null?void 0:t.top)??0,l=((e=a==null?void 0:a.subGraphTitleMargin)==null?void 0:e.bottom)??0,r=i+l;return{subGraphTitleTopMargin:i,subGraphTitleBottomMargin:l,subGraphTitleTotalMargin:r}},O={aggregation:18,extension:18,composition:18,dependency:6,lollipop:13.5,arrow_point:5.3};function U(a,t){if(a===void 0||t===void 0)return{angle:0,deltaX:0,deltaY:0};a=Z(a),t=Z(t);const[e,i]=[a.x,a.y],[l,r]=[t.x,t.y],s=l-e,n=r-i;return{angle:Math.atan(n/s),deltaX:s,deltaY:n}}const Z=a=>Array.isArray(a)?{x:a[0],y:a[1]}:a,rr=a=>({x:function(t,e,i){let l=0;if(e===0&&Object.hasOwn(O,a.arrowTypeStart)){const{angle:r,deltaX:s}=U(i[0],i[1]);l=O[a.arrowTypeStart]*Math.cos(r)*(s>=0?1:-1)}else if(e===i.length-1&&Object.hasOwn(O,a.arrowTypeEnd)){const{angle:r,deltaX:s}=U(i[i.length-1],i[i.length-2]);l=O[a.arrowTypeEnd]*Math.cos(r)*(s>=0?1:-1)}return Z(t).x+l},y:function(t,e,i){let l=0;if(e===0&&Object.hasOwn(O,a.arrowTypeStart)){const{angle:r,deltaY:s}=U(i[0],i[1]);l=O[a.arrowTypeStart]*Math.abs(Math.sin(r))*(s>=0?1:-1)}else if(e===i.length-1&&Object.hasOwn(O,a.arrowTypeEnd)){const{angle:r,deltaY:s}=U(i[i.length-1],i[i.length-2]);l=O[a.arrowTypeEnd]*Math.abs(Math.sin(r))*(s>=0?1:-1)}return Z(t).y+l}}),ar=(a,t,e,i,l)=>{t.arrowTypeStart&&at(a,"start",t.arrowTypeStart,e,i,l),t.arrowTypeEnd&&at(a,"end",t.arrowTypeEnd,e,i,l)},er={arrow_cross:"cross",arrow_point:"point",arrow_barb:"barb",arrow_circle:"circle",aggregation:"aggregation",extension:"extension",composition:"composition",dependency:"dependency",lollipop:"lollipop"},at=(a,t,e,i,l,r)=>{const s=er[e];if(!s){g.warn(`Unknown arrow type: ${e}`);return}const n=t==="start"?"Start":"End";a.attr(`marker-${t}`,`url(${i}#${l}_${r}-${s}${n})`)};let G={},T={};const xr=()=>{G={},T={}},dr=(a,t)=>{const e=H(b().flowchart.htmlLabels),i=t.labelType==="markdown"?st(a,t.label,{style:t.labelStyle,useHtmlLabels:e,addSvgBackground:!0}):R(t.label,t.labelStyle),l=a.insert("g").attr("class","edgeLabel"),r=l.insert("g").attr("class","label");r.node().appendChild(i);let s=i.getBBox();if(e){const c=i.children[0],o=E(i);s=c.getBoundingClientRect(),o.attr("width",s.width),o.attr("height",s.height)}r.attr("transform","translate("+-s.width/2+", "+-s.height/2+")"),G[t.id]=l,t.width=s.width,t.height=s.height;let n;if(t.startLabelLeft){const c=R(t.startLabelLeft,t.labelStyle),o=a.insert("g").attr("class","edgeTerminals"),h=o.insert("g").attr("class","inner");n=h.node().appendChild(c);const y=c.getBBox();h.attr("transform","translate("+-y.width/2+", "+-y.height/2+")"),T[t.id]||(T[t.id]={}),T[t.id].startLeft=o,z(n,t.startLabelLeft)}if(t.startLabelRight){const c=R(t.startLabelRight,t.labelStyle),o=a.insert("g").attr("class","edgeTerminals"),h=o.insert("g").attr("class","inner");n=o.node().appendChild(c),h.node().appendChild(c);const y=c.getBBox();h.attr("transform","translate("+-y.width/2+", "+-y.height/2+")"),T[t.id]||(T[t.id]={}),T[t.id].startRight=o,z(n,t.startLabelRight)}if(t.endLabelLeft){const c=R(t.endLabelLeft,t.labelStyle),o=a.insert("g").attr("class","edgeTerminals"),h=o.insert("g").attr("class","inner");n=h.node().appendChild(c);const y=c.getBBox();h.attr("transform","translate("+-y.width/2+", "+-y.height/2+")"),o.node().appendChild(c),T[t.id]||(T[t.id]={}),T[t.id].endLeft=o,z(n,t.endLabelLeft)}if(t.endLabelRight){const c=R(t.endLabelRight,t.labelStyle),o=a.insert("g").attr("class","edgeTerminals"),h=o.insert("g").attr("class","inner");n=h.node().appendChild(c);const y=c.getBBox();h.attr("transform","translate("+-y.width/2+", "+-y.height/2+")"),o.node().appendChild(c),T[t.id]||(T[t.id]={}),T[t.id].endRight=o,z(n,t.endLabelRight)}return i};function z(a,t){b().flowchart.htmlLabels&&a&&(a.style.width=t.length*9+"px",a.style.height="12px")}const gr=(a,t)=>{g.debug("Moving label abc88 ",a.id,a.label,G[a.id],t);let e=t.updatedPath?t.updatedPath:t.originalPath;const i=b(),{subGraphTitleTotalMargin:l}=tr(i);if(a.label){const r=G[a.id];let s=a.x,n=a.y;if(e){const c=j.calcLabelPosition(e);g.debug("Moving label "+a.label+" from (",s,",",n,") to (",c.x,",",c.y,") abc88"),t.updatedPath&&(s=c.x,n=c.y)}r.attr("transform",`translate(${s}, ${n+l/2})`)}if(a.startLabelLeft){const r=T[a.id].startLeft;let s=a.x,n=a.y;if(e){const c=j.calcTerminalLabelPosition(a.arrowTypeStart?10:0,"start_left",e);s=c.x,n=c.y}r.attr("transform",`translate(${s}, ${n})`)}if(a.startLabelRight){const r=T[a.id].startRight;let s=a.x,n=a.y;if(e){const c=j.calcTerminalLabelPosition(a.arrowTypeStart?10:0,"start_right",e);s=c.x,n=c.y}r.attr("transform",`translate(${s}, ${n})`)}if(a.endLabelLeft){const r=T[a.id].endLeft;let s=a.x,n=a.y;if(e){const c=j.calcTerminalLabelPosition(a.arrowTypeEnd?10:0,"end_left",e);s=c.x,n=c.y}r.attr("transform",`translate(${s}, ${n})`)}if(a.endLabelRight){const r=T[a.id].endRight;let s=a.x,n=a.y;if(e){const c=j.calcTerminalLabelPosition(a.arrowTypeEnd?10:0,"end_right",e);s=c.x,n=c.y}r.attr("transform",`translate(${s}, ${n})`)}},sr=(a,t)=>{const e=a.x,i=a.y,l=Math.abs(t.x-e),r=Math.abs(t.y-i),s=a.width/2,n=a.height/2;return l>=s||r>=n},ir=(a,t,e)=>{g.debug(`intersection calc abc89:
|
|
2
2
|
outsidePoint: ${JSON.stringify(t)}
|
|
3
3
|
insidePoint : ${JSON.stringify(e)}
|
|
4
4
|
node : x:${a.x} y:${a.y} w:${a.width} h:${a.height}`);const i=a.x,l=a.y,r=Math.abs(i-e.x),s=a.width/2;let n=e.x<t.x?s-r:s+r;const c=a.height/2,o=Math.abs(t.y-e.y),h=Math.abs(t.x-e.x);if(Math.abs(l-t.y)*s>Math.abs(i-t.x)*c){let y=e.y<t.y?t.y-c-l:l-c-t.y;n=h*y/o;const f={x:e.x<t.x?e.x+n:e.x-h+n,y:e.y<t.y?e.y+o-y:e.y-o+y};return n===0&&(f.x=t.x,f.y=t.y),h===0&&(f.x=t.x),o===0&&(f.y=t.y),g.debug(`abc89 topp/bott calc, Q ${o}, q ${y}, R ${h}, r ${n}`,f),f}else{e.x<t.x?n=t.x-s-i:n=i-s-t.x;let y=o*n/h,f=e.x<t.x?e.x+h-n:e.x-h+n,p=e.y<t.y?e.y+y:e.y-y;return g.debug(`sides calc abc89, Q ${o}, q ${y}, R ${h}, r ${n}`,{_x:f,_y:p}),n===0&&(f=t.x,p=t.y),h===0&&(f=t.x),o===0&&(p=t.y),{x:f,y:p}}},et=(a,t)=>{g.debug("abc88 cutPathAtIntersect",a,t);let e=[],i=a[0],l=!1;return a.forEach(r=>{if(!sr(t,r)&&!l){const s=ir(t,i,r);let n=!1;e.forEach(c=>{n=n||c.x===s.x&&c.y===s.y}),e.some(c=>c.x===s.x&&c.y===s.y)||e.push(s),l=!0}else i=r,l||e.push(r)}),e},ur=function(a,t,e,i,l,r,s){let n=e.points;g.debug("abc88 InsertEdge: edge=",e,"e=",t);let c=!1;const o=r.node(t.v);var h=r.node(t.w);h!=null&&h.intersect&&(o!=null&&o.intersect)&&(n=n.slice(1,e.points.length-1),n.unshift(o.intersect(n[0])),n.push(h.intersect(n[n.length-1]))),e.toCluster&&(g.debug("to cluster abc88",i[e.toCluster]),n=et(e.points,i[e.toCluster].node),c=!0),e.fromCluster&&(g.debug("from cluster abc88",i[e.fromCluster]),n=et(n.reverse(),i[e.fromCluster].node).reverse(),c=!0);const y=n.filter(C=>!Number.isNaN(C.y));let f=lt;e.curve&&(l==="graph"||l==="flowchart")&&(f=e.curve);const{x:p,y:d}=rr(e),k=ct().x(p).y(d).curve(f);let x;switch(e.thickness){case"normal":x="edge-thickness-normal";break;case"thick":x="edge-thickness-thick";break;case"invisible":x="edge-thickness-thick";break;default:x=""}switch(e.pattern){case"solid":x+=" edge-pattern-solid";break;case"dotted":x+=" edge-pattern-dotted";break;case"dashed":x+=" edge-pattern-dashed";break}const u=a.append("path").attr("d",k(y)).attr("id",e.id).attr("class"," "+x+(e.classes?" "+e.classes:"")).attr("style",e.style);let S="";(b().flowchart.arrowMarkerAbsolute||b().state.arrowMarkerAbsolute)&&(S=window.location.protocol+"//"+window.location.host+window.location.pathname+window.location.search,S=S.replace(/\(/g,"\\("),S=S.replace(/\)/g,"\\)")),ar(u,e,S,s,l);let B={};return c&&(B.updatedPath=n),B.originalPath=e.points,B};export{or as a,dr as b,ur as c,gr as d,Et as e,R as f,tr as g,pr as h,hr as i,xr as j,rr as k,M as l,ar as m,fr as p,yr as s,m as u};
|