aitu-app 0.6.63 → 0.6.64
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/README.md +3 -3
- package/assets/{CanvasAudioPlayer-Du5kXrAd.js → CanvasAudioPlayer-B2W5__ni.js} +1 -1
- package/assets/{ChatDrawer-CqZHx7x_.js → ChatDrawer-M1q92KNU.js} +2 -2
- package/assets/{ChatMessagesArea-AG3RXe34.js → ChatMessagesArea-D9LNDmbK.js} +2 -2
- package/assets/{DeferredAIInputBar-CNAPl6C2.js → DeferredAIInputBar-CKhI8Jhd.js} +2 -2
- package/assets/{DrawnixDeferredFeatures-BrhbEEBa.js → DrawnixDeferredFeatures-DxyxvT2y.js} +1 -1
- package/assets/{KnowledgeBaseContent-3hE8vBra.js → KnowledgeBaseContent-C_JxGQXg.js} +3 -3
- package/assets/{MVCreator-2NIxaaSL.js → MVCreator-DOt6pxq2.js} +1 -1
- package/assets/{ModelBenchmarkWorkbench-CacNyFbi.js → ModelBenchmarkWorkbench-3j77ocpe.js} +1 -1
- package/assets/{ModelDropdown-3MjTl1AO.js → ModelDropdown-CHYgRb1r.js} +1 -1
- package/assets/{MusicAnalyzer-Mmu92A4Y.js → MusicAnalyzer-BTXks5oV.js} +1 -1
- package/assets/{MusicAnalyzer-Drf2j8jn.js → MusicAnalyzer-Dr-DPePj.js} +1 -1
- package/assets/{ResizableDivider-B_67th7H.js → ResizableDivider-P1jpoJ3i.js} +1 -1
- package/assets/{TaskQueuePanel-VfjKIooN.js → TaskQueuePanel-D6NtMAbm.js} +1 -1
- package/assets/{VideoAnalyzer-DNWjNcIx.js → VideoAnalyzer-BHZMqLIa.js} +1 -1
- package/assets/{ai-generation-preferences-service-Ch1XhjkZ.js → ai-generation-preferences-service-CabuQA69.js} +1 -1
- package/assets/{arc-DE4qRd9D.js → arc-BajUk0_Z.js} +1 -1
- package/assets/{arc-DJ5Mb9x1.js → arc-Z9PGo_2L.js} +1 -1
- package/assets/{batch-image-generation-Bk8HSFol.js → batch-image-generation-RKz5tz-Y.js} +1 -1
- package/assets/{blockDiagram-38ab4fdb-B62iB8ti.js → blockDiagram-38ab4fdb-BsEJDcLK.js} +1 -1
- package/assets/{blockDiagram-38ab4fdb-D2MnfN1Q.js → blockDiagram-38ab4fdb-Cfmk3_6A.js} +1 -1
- package/assets/{c4Diagram-3d4e48cf-CgUaipiZ.js → c4Diagram-3d4e48cf-D2OyfHpd.js} +1 -1
- package/assets/{c4Diagram-3d4e48cf-DHV35ltP.js → c4Diagram-3d4e48cf-K-ewbsK1.js} +1 -1
- package/assets/{canvas-insertion-ZEZkcXvB.js → canvas-insertion-CYbFgP4L.js} +1 -1
- package/assets/channel-6DAc0JPc.js +1 -0
- package/assets/channel-WrMsNCbC.js +1 -0
- package/assets/{classDiagram-70f12bd4-C6X-VZXt.js → classDiagram-70f12bd4-BGEF352u.js} +1 -1
- package/assets/{classDiagram-70f12bd4-OH5sF1K-.js → classDiagram-70f12bd4-Gn3MZjEL.js} +1 -1
- package/assets/{classDiagram-v2-f2320105-otk4V9KH.js → classDiagram-v2-f2320105-C_aAfIgL.js} +1 -1
- package/assets/{classDiagram-v2-f2320105-D1I5s2af.js → classDiagram-v2-f2320105-DYPMFlcT.js} +1 -1
- package/assets/{clipper-BWlMmsTH.js → clipper-ByL4oIbZ.js} +1 -1
- package/assets/clone-keJVIubx.js +1 -0
- package/assets/{createText-2e5e7dd3-DuiUpOXV.js → createText-2e5e7dd3-C0UgSBh5.js} +1 -1
- package/assets/{createText-2e5e7dd3-D78Dn_q8.js → createText-2e5e7dd3-CoA6JNKB.js} +1 -1
- package/assets/{edges-e0da2a9e-Br3GgeJK.js → edges-e0da2a9e-DmyL0L_b.js} +1 -1
- package/assets/{edges-e0da2a9e-Dio4S9-4.js → edges-e0da2a9e-qdTreft0.js} +1 -1
- package/assets/{erDiagram-9861fffd-BYkBBs0M.js → erDiagram-9861fffd-Bjyf78Da.js} +1 -1
- package/assets/{erDiagram-9861fffd-DuZccGHy.js → erDiagram-9861fffd-DYWtVkXG.js} +1 -1
- package/assets/{flowDb-956e92f1-BvHxN76x.js → flowDb-956e92f1-Clfuqh48.js} +1 -1
- package/assets/{flowDb-956e92f1-D6cTY_st.js → flowDb-956e92f1-vnfymslR.js} +1 -1
- package/assets/{flowDiagram-66a62f08-Bh5LanWu.js → flowDiagram-66a62f08-54OX2XOH.js} +1 -1
- package/assets/{flowDiagram-66a62f08-rCNbZEwY.js → flowDiagram-66a62f08-lS8fOa4T.js} +1 -1
- package/assets/flowDiagram-v2-96b9c2cf-Bw7qAcFu.js +1 -0
- package/assets/flowDiagram-v2-96b9c2cf-DGyrUMgR.js +1 -0
- package/assets/{flowchart-elk-definition-4a651766-llVLlxyE.js → flowchart-elk-definition-4a651766-CXdElD40.js} +1 -1
- package/assets/{flowchart-elk-definition-4a651766-CIShIr5E.js → flowchart-elk-definition-4a651766-D4UghemK.js} +1 -1
- package/assets/{ganttDiagram-c361ad54-j2pPvoOi.js → ganttDiagram-c361ad54-Bl7rQCLW.js} +1 -1
- package/assets/{ganttDiagram-c361ad54-CUtUP4cJ.js → ganttDiagram-c361ad54-CwAjbWcn.js} +1 -1
- package/assets/{gitGraphDiagram-72cf32ee-hQmVrZTT.js → gitGraphDiagram-72cf32ee-B-ykaDuR.js} +1 -1
- package/assets/{gitGraphDiagram-72cf32ee-BijhDF7a.js → gitGraphDiagram-72cf32ee-ChvlaDvG.js} +1 -1
- package/assets/{graph-CVdXivUk.js → graph-Bq1HvHkL.js} +1 -1
- package/assets/{graph-iERr38Mn.js → graph-DM094zt_.js} +1 -1
- package/assets/{index-3862675e-BCU8UapW.js → index-3862675e-CA0xjB9W.js} +1 -1
- package/assets/{index-3862675e-BdD6mhWW.js → index-3862675e-DGrSmeWu.js} +1 -1
- package/assets/{index-CxqCKbLy.js → index-AFp_qpAI.js} +1 -1
- package/assets/{index-q02ppfIX.js → index-B4dceFKj.js} +1 -1
- package/assets/{index-BmNN2uGW.js → index-B67KSDhv.js} +1 -1
- package/assets/{index-ByxyNkwM.js → index-BC221_MJ.js} +1 -1
- package/assets/{index-nPSeKWRU.js → index-BGFWA6Zt.js} +1 -1
- package/assets/{index-DCjrDHEd.js → index-BH3jS3gm.js} +1 -1
- package/assets/{index-B-bas2QJ.js → index-BKTLxghO.js} +1 -1
- package/assets/{index-CW9BeyEu.js → index-Bks4xBST.js} +1 -1
- package/assets/{index-CvlBHvN3.js → index-BmEFRKV7.js} +1 -1
- package/assets/{index-DuFyvKRm.js → index-C3h-b0UN.js} +1 -1
- package/assets/{index-CmOEsqBQ.js → index-C5Onm0uO.js} +1 -1
- package/assets/{index-DYtXgeSz.js → index-CGelrSXy.js} +1 -1
- package/assets/{index-vw8fjMik.js → index-CKBsqCzR.js} +1 -1
- package/assets/{index-DjGrNkrV.js → index-CKjzms_e.js} +1 -1
- package/assets/{index-CxUWaNUo.js → index-CMLI8gQy.js} +1 -1
- package/assets/{index-CkjuY786.js → index-CVEllvWf.js} +1 -1
- package/assets/{index-BUZUbTWS.js → index-CW_ala_3.js} +1 -1
- package/assets/{index-BxdH1-er.js → index-Ci5Z3DWY.js} +1 -1
- package/assets/{index-BeRhCeQu.js → index-CtNjfEqK.js} +1 -1
- package/assets/{index-BakDREx4.js → index-CvbEsbIE.js} +1 -1
- package/assets/{index-BnaNWg7x.js → index-DM-iV9Y8.js} +2 -2
- package/assets/{index-DMfHKITi.js → index-DTqVJVfv.js} +1 -1
- package/assets/{index-BdSFouqR.js → index-DZtf3zC8.js} +1 -1
- package/assets/{index-ByECpktB.js → index-D_LadtY8.js} +1 -1
- package/assets/{index-UeGDfQIX.js → index-DiSWR48t.js} +1 -1
- package/assets/{index-D0O0qYML.js → index-DsFroXrj.js} +1 -1
- package/assets/{index-BN7eABQE.js → index-DxqCsnoj.js} +1 -1
- package/assets/{index-B_eFETCZ.js → index-Jvh12pKI.js} +1 -1
- package/assets/{index-CMQMxwMb.js → index-gHdnUGOu.js} +3 -3
- package/assets/{index-CE0NChcB.js → index-kKjFXTNL.js} +1 -1
- package/assets/{index-D4R9cQ86.js → index-v1v0x1ci.js} +3 -3
- package/assets/{infoDiagram-f8f76790-Cmv7jbWa.js → infoDiagram-f8f76790-C-wYgjah.js} +1 -1
- package/assets/{infoDiagram-f8f76790-D0DSz5Ue.js → infoDiagram-f8f76790-Cu-3eq4R.js} +1 -1
- package/assets/{journeyDiagram-49397b02-D6HU8bXU.js → journeyDiagram-49397b02-BG8aYQK6.js} +1 -1
- package/assets/{journeyDiagram-49397b02-Db00D03K.js → journeyDiagram-49397b02-DXPaY9vn.js} +1 -1
- package/assets/{layout-CPj4wl_r.js → layout-DvIBYRXu.js} +1 -1
- package/assets/{layout-DGJFFi9s.js → layout-SoDWNnQD.js} +1 -1
- package/assets/{line-D_WC7vRh.js → line-Bxc-zIvZ.js} +1 -1
- package/assets/{line-CpXi5g86.js → line-CFFXuH78.js} +1 -1
- package/assets/{linear-n85WiAhX.js → linear-BF0xIQKP.js} +1 -1
- package/assets/{linear-UpmxQM2f.js → linear-DQ3XkjOP.js} +1 -1
- package/assets/{main-DX4kRYQX.js → main-8GBlYJSO.js} +8 -8
- package/assets/{mermaid.core-N7WwfYcf.js → mermaid.core-BGyfnsLl.js} +3 -3
- package/assets/{mindmap-definition-fc14e90a-C8U6pdZ2.js → mindmap-definition-fc14e90a-CrYWIUXi.js} +1 -1
- package/assets/{mindmap-definition-fc14e90a-D2hbUBx2.js → mindmap-definition-fc14e90a-DOkI3ebm.js} +1 -1
- package/assets/{model-benchmark-launcher-BrOG9Vlm.js → model-benchmark-launcher-DtJmU6Wc.js} +1 -1
- package/assets/{model-benchmark-service-DDklUBjC.js → model-benchmark-service-B0QCqInK.js} +1 -1
- package/assets/{model-selection-BaH65gMK.js → model-selection-CbzU26xQ.js} +1 -1
- package/assets/{photo-wall-splitter-QuaIbsZ1.js → photo-wall-splitter-BPzdMtA1.js} +1 -1
- package/assets/{pieDiagram-8a3498a8-BPHw5PxR.js → pieDiagram-8a3498a8-ChLZxjKv.js} +1 -1
- package/assets/{pieDiagram-8a3498a8-DKV5uwrs.js → pieDiagram-8a3498a8-DAWd9-jL.js} +1 -1
- package/assets/{quadrantDiagram-120e2f19-pe-wI-U4.js → quadrantDiagram-120e2f19-CBBovNE2.js} +1 -1
- package/assets/{quadrantDiagram-120e2f19-DQdaeBYM.js → quadrantDiagram-120e2f19-DSvfgE7I.js} +1 -1
- package/assets/{requirementDiagram-deff3bca-DYepoptc.js → requirementDiagram-deff3bca-De51fyhT.js} +1 -1
- package/assets/{requirementDiagram-deff3bca-QX4OaNTO.js → requirementDiagram-deff3bca-ke6SiEw1.js} +1 -1
- package/assets/{sankeyDiagram-04a897e0-DJkKTFXr.js → sankeyDiagram-04a897e0-BxiqkhtK.js} +1 -1
- package/assets/{sankeyDiagram-04a897e0-1bYf2R8i.js → sankeyDiagram-04a897e0-Clr8_HiZ.js} +1 -1
- package/assets/{sequenceDiagram-704730f1-B52OA1Y3.js → sequenceDiagram-704730f1-Bc8zPHLG.js} +1 -1
- package/assets/{sequenceDiagram-704730f1-B4QsYTCd.js → sequenceDiagram-704730f1-BfBUJmAu.js} +1 -1
- package/assets/{settings-dialog-Bueh6yYA.js → settings-dialog-C9BMj8Zj.js} +1 -1
- package/assets/{skill-dsl-parser-CPpdtdC1.js → skill-dsl-parser-BxkJ9Ixc.js} +1 -1
- package/assets/{stateDiagram-587899a1-D221rMST.js → stateDiagram-587899a1-DAil8S_m.js} +1 -1
- package/assets/{stateDiagram-587899a1-X7bhoHKe.js → stateDiagram-587899a1-Vop8VRn5.js} +1 -1
- package/assets/{stateDiagram-v2-d93cdb3a-D9VdRPIN.js → stateDiagram-v2-d93cdb3a-8b1lkei5.js} +1 -1
- package/assets/{stateDiagram-v2-d93cdb3a-CGMASaM9.js → stateDiagram-v2-d93cdb3a-BHm8pPuv.js} +1 -1
- package/assets/{styles-6aaf32cf-D_xcN1dm.js → styles-6aaf32cf-BlD8JxQr.js} +1 -1
- package/assets/{styles-6aaf32cf-DHTzglnJ.js → styles-6aaf32cf-C4CEUYqK.js} +1 -1
- package/assets/{styles-9a916d00-w5Yn3LRO.js → styles-9a916d00-C6tkW5rH.js} +1 -1
- package/assets/{styles-9a916d00-BVoYXPeR.js → styles-9a916d00-Oss0YMv5.js} +1 -1
- package/assets/{styles-c10674c1-xX_gtHzZ.js → styles-c10674c1-D4YQTLGD.js} +1 -1
- package/assets/{styles-c10674c1-C3cgfc7I.js → styles-c10674c1-D6N_fge5.js} +1 -1
- package/assets/{svgDrawCommon-08f97a94-DFof-iml.js → svgDrawCommon-08f97a94-BOSx1sQS.js} +1 -1
- package/assets/{svgDrawCommon-08f97a94-DxU2UGYh.js → svgDrawCommon-08f97a94-RZvmFGZL.js} +1 -1
- package/assets/{timeline-definition-85554ec2-CzV_JohE.js → timeline-definition-85554ec2-BL5y0l6c.js} +1 -1
- package/assets/{timeline-definition-85554ec2-FPml3o0r.js → timeline-definition-85554ec2-BY6Jx-ZP.js} +1 -1
- package/assets/{tool-windows-hjm6YiPY.js → tool-windows-C4D0lII2.js} +137 -137
- package/assets/{ttd-dialog-CqISZ7cy.js → ttd-dialog-qD0QkDID.js} +4 -4
- package/assets/{use-runtime-models-C0uyCfar.js → use-runtime-models-BLwgp0M1.js} +1 -1
- package/assets/{useCharacters-BGdX9007.js → useCharacters-945b6dqW.js} +1 -1
- package/assets/{useWorkflowSubmission-BmFQdWt3.js → useWorkflowSubmission-Z0u0KCNN.js} +2 -2
- package/assets/{video-analyze-DszumYAr.js → video-analyze-Co9na7Gr.js} +1 -1
- package/assets/{video-generation-DEL-kJgF.js → video-generation-x2UMMPYg.js} +1 -1
- package/assets/{video-recovery-service-C9y_bfU1.js → video-recovery-service-BsV5nlEP.js} +1 -1
- package/assets/{workflow-generation-utils-Da12qXTb.js → workflow-generation-utils-CZULSJWQ.js} +2 -2
- package/assets/{workflow-submission-service-BuFuRV_m.js → workflow-submission-service-C-eCWm_8.js} +1 -1
- package/assets/{xychartDiagram-e933f94c-C41tCiSk.js → xychartDiagram-e933f94c-CNjZprqQ.js} +1 -1
- package/assets/{xychartDiagram-e933f94c-HanO46iU.js → xychartDiagram-e933f94c-DjIBec-i.js} +1 -1
- package/changelog.json +16 -0
- package/idle-prefetch-manifest.json +6 -6
- package/manifest.json +3 -3
- package/package.json +1 -1
- package/precache-manifest.json +304 -304
- package/sw.js +5 -5
- package/version.json +7 -3
- package/assets/channel-B5QZCgOy.js +0 -1
- package/assets/channel-CU3dhzIS.js +0 -1
- package/assets/clone-BAOxFbud.js +0 -1
- package/assets/flowDiagram-v2-96b9c2cf-BEdEe3Ip.js +0 -1
- package/assets/flowDiagram-v2-96b9c2cf-CVItVSoD.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{iI as jt,r as u,iJ as yt,y as e,iy as Nt,iz as bt,bW as Ls,iK as zs,bw as Vs,hj as Mt,bV as ve,iL as Us,aI as St,iM as wt,iN as Ns,al as V,i8 as It,bL as Pt,bm as Ct,eP as Et,iO as T,iP as ee,iQ as Pe,it as oe,hd as Ce,hf as pe,hg as de,he as re,hx as ce,gP as ke,iR as At,iS as bs,iA as kt,iT as Dt,iU as Rt,iV as Ot,cV as Tt,iW as Lt,iX as Me,iY as Ee,iZ as me,fI as Ms,i_ as Ss,i$ as Fe,j0 as De,j1 as zt,j2 as Vt,j3 as Ut,j4 as We,j5 as F,hv as ue,j6 as $t,j7 as Kt,j8 as Bt,j9 as Gt}from"./tool-windows-hjm6YiPY.js";import{ja as ki,jb as Di}from"./tool-windows-hjm6YiPY.js";import{D as $s,g as Te,a as Ks,b as Bs,c as Ft,d as Wt,e as Re,f as Zt,h as Yt}from"./use-runtime-models-C0uyCfar.js";import{M as Qt}from"./ModelDropdown-3MjTl1AO.js";import{o as Xt}from"./model-benchmark-launcher-BrOG9Vlm.js";import{m as Ht}from"./model-benchmark-service-DDklUBjC.js";const ws={all:"全部",image:"图片",video:"视频",audio:"音频",text:"文本"},Jt={image:"图片",video:"视频",audio:"音频",text:"文本"},qt={image:"图",video:"视",audio:"音",text:"文"},Is=["text","image","video","audio"];function ei(t,o){const n=o.trim().toLowerCase();return n?[t.id,t.label,t.shortLabel,t.shortCode,t.description,t.sourceProfileName,Te(t.vendor)].filter(Boolean).some(g=>g==null?void 0:g.toLowerCase().includes(n)):!0}function si(t){return jt(t)}function Ps(t,o){const n=new Map;for(const j of t){const v=n.get(j.vendor)||{vendor:j.vendor,models:[],counts:{image:0,video:0,audio:0,text:0},selectedCount:0};v.models.push(j),v.counts[j.type]+=1,o.has(j.id)&&(v.selectedCount+=1),n.set(j.vendor,v)}const g=new Map($s.map((j,v)=>[j,v]));return Array.from(n.values()).sort((j,v)=>{const $=g.get(j.vendor)??Number.MAX_SAFE_INTEGER,Y=g.get(v.vendor)??Number.MAX_SAFE_INTEGER;return $!==Y?$-Y:v.models.length-j.models.length})}function ti(t){return["image","video","audio","text"].filter(o=>t.counts[o]>0).map(o=>({type:o,models:si(t.models.filter(n=>n.type===o))})).sort((o,n)=>n.models.length!==o.models.length?n.models.length-o.models.length:Is.indexOf(o.type)-Is.indexOf(n.type))}const ii=({open:t,container:o,models:n,selectedModelIds:g,onClose:j,onConfirm:v,onTestModel:$})=>{const[Y,_e]=u.useState(""),[H,xe]=u.useState("all"),[K,M]=u.useState(g),[k,U]=u.useState({});u.useEffect(()=>{var O,Z;if(!t)return;_e(""),xe("all"),M(g);const d=new Set(g),b=Ps(n,d),y=((O=b.find(B=>B.selectedCount>0))==null?void 0:O.vendor)||((Z=b[0])==null?void 0:Z.vendor)||null,A={};b.forEach(B=>{A[B.vendor]=B.vendor===y}),U(A)},[n,t,g]);const se=u.useMemo(()=>({all:n.length,image:n.filter(d=>d.type==="image").length,video:n.filter(d=>d.type==="video").length,audio:n.filter(d=>d.type==="audio").length,text:n.filter(d=>d.type==="text").length}),[n]),G=u.useMemo(()=>{const d=Y.trim(),b=H==="all"?n:n.filter(y=>y.type===H);return d?b.filter(y=>ei(y,d)):b},[H,n,Y]),x=u.useMemo(()=>new Set(K),[K]),R=u.useMemo(()=>Ps(G,x),[x,G]),E=K.length,W=u.useMemo(()=>({image:n.filter(d=>d.type==="image"&&x.has(d.id)).length,video:n.filter(d=>d.type==="video"&&x.has(d.id)).length,text:n.filter(d=>d.type==="text"&&x.has(d.id)).length}),[n,x]),te=G.length>0&&G.every(d=>x.has(d.id)),J=u.useMemo(()=>n.filter(d=>yt(d.id)).map(d=>d.id),[n]),Se=J.length>0&&J.every(d=>x.has(d));u.useEffect(()=>{R.length===0||R.some(y=>k[y.vendor])||!Object.values(k).some(Boolean)||U(R.reduce((y,A,O)=>(y[A.vendor]=O===0,y),{}))},[k,R]);const we=d=>{M(b=>b.includes(d)?b.filter(y=>y!==d):[...b,d])},fe=()=>{const d=G.map(y=>y.id),b=d.every(y=>x.has(y));M(y=>b?y.filter(A=>!d.includes(A)):Array.from(new Set([...y,...d])))},Ie=()=>{M(d=>Array.from(new Set([...d,...J])))},ie=d=>{U(b=>{const y=!b[d],A={};return R.forEach(O=>{A[O.vendor]=O.vendor===d?y:!1}),A})};return e.jsx(Nt,{open:t,onOpenChange:d=>!d&&j(),children:e.jsxs(bt,{className:"model-discovery-dialog",container:o,"data-testid":"model-discovery-dialog",children:[e.jsxs("div",{className:"model-discovery-dialog__header",children:[e.jsxs("div",{className:"model-discovery-dialog__headline",children:[e.jsx("h3",{className:"model-discovery-dialog__title",children:"获取模型"}),e.jsxs("div",{className:"model-discovery-dialog__header-stats",children:[e.jsxs("span",{className:"model-discovery-dialog__header-pill",children:["已发现 ",n.length]}),e.jsxs("span",{className:"model-discovery-dialog__header-pill",children:["品牌 ",R.length]}),e.jsxs("span",{className:"model-discovery-dialog__header-pill model-discovery-dialog__header-pill--accent",children:["已选 ",E]})]})]}),e.jsx("button",{type:"button",className:"model-discovery-dialog__close",onClick:j,"aria-label":"关闭",children:e.jsx(Ls,{size:18})})]}),e.jsx("div",{className:"model-discovery-dialog__toolbar",children:e.jsxs("label",{className:"model-discovery-dialog__search",children:[e.jsx(zs,{size:16}),e.jsx("input",{type:"text",value:Y,onChange:d=>_e(d.target.value),placeholder:"搜索模型名称、ID 或品牌"})]})}),e.jsx("div",{className:"model-discovery-dialog__type-tabs",children:Object.keys(ws).map(d=>{const b=H===d;return e.jsxs("button",{type:"button",className:`model-discovery-dialog__type-tab ${b?"model-discovery-dialog__type-tab--active":""}`,onClick:()=>xe(d),children:[e.jsx("span",{children:ws[d]}),e.jsx("span",{className:"model-discovery-dialog__type-tab-count",children:se[d]})]},d)})}),e.jsx("div",{className:"model-discovery-dialog__body",children:R.length===0?e.jsx("div",{className:"model-discovery-dialog__empty",children:Y.trim()?"没有匹配的模型":"暂无模型"}):e.jsx("div",{className:"model-discovery-dialog__group-list",children:R.map(d=>{const b=Ks(d.vendor),y=ti(d),A=!!k[d.vendor];return e.jsxs("section",{className:`model-discovery-dialog__vendor-group ${A?"model-discovery-dialog__vendor-group--expanded":""}`,style:{"--vendor-accent":b.accent,"--vendor-surface":b.surface,"--vendor-border":b.border},children:[e.jsxs("button",{type:"button",className:"model-discovery-dialog__vendor-header",onClick:()=>ie(d.vendor),children:[e.jsxs("div",{className:"model-discovery-dialog__vendor-main",children:[e.jsx("span",{className:"model-discovery-dialog__vendor-logo-shell",children:e.jsx(Bs,{vendor:d.vendor,size:22})}),e.jsxs("div",{className:"model-discovery-dialog__vendor-copy",children:[e.jsx("span",{className:"model-discovery-dialog__vendor-name",children:Te(d.vendor)}),e.jsx("div",{className:"model-discovery-dialog__vendor-meta",children:y.map(({type:O,models:Z})=>e.jsxs("span",{className:"model-discovery-dialog__vendor-meta-pill",children:[qt[O]," ",Z.length]},`${d.vendor}-${O}`))})]})]}),e.jsx("span",{className:"model-discovery-dialog__vendor-spacer"}),e.jsxs("div",{className:"model-discovery-dialog__vendor-side",children:[d.selectedCount>0?e.jsxs("span",{className:"model-discovery-dialog__vendor-selected",children:["已选 ",d.selectedCount]}):null,e.jsx("span",{className:"model-discovery-dialog__vendor-count",children:d.models.length}),e.jsx("span",{className:`model-discovery-dialog__vendor-chevron ${A?"model-discovery-dialog__vendor-chevron--expanded":""}`,children:e.jsx(Vs,{size:16})})]})]}),A?e.jsx("div",{className:"model-discovery-dialog__vendor-body",children:y.map(({type:O,models:Z})=>e.jsxs("div",{className:"model-discovery-dialog__type-section",children:[e.jsxs("div",{className:"model-discovery-dialog__type-section-header",children:[e.jsx("span",{className:"model-discovery-dialog__type-section-title",children:Jt[O]}),e.jsx("span",{className:"model-discovery-dialog__type-section-count",children:Z.length})]}),e.jsx("div",{className:"model-discovery-dialog__model-stack",children:Z.map(B=>{const ae=x.has(B.id);return e.jsxs("label",{className:`model-discovery-dialog__item ${ae?"model-discovery-dialog__item--checked":""}`,children:[e.jsx("input",{type:"checkbox",className:"model-discovery-dialog__checkbox",checked:ae,onChange:()=>we(B.id)}),e.jsx("span",{className:"model-discovery-dialog__checkmark",children:ae?e.jsx(Mt,{size:12}):null}),e.jsx("div",{className:"model-discovery-dialog__item-body",children:e.jsx("div",{className:`model-discovery-dialog__item-id ${ae?"model-discovery-dialog__item-id--checked":""}`,children:B.id})}),$?e.jsx(ve,{content:"测试此模型",showArrow:!1,children:e.jsx("button",{type:"button",className:"model-discovery-dialog__item-test",onClick:he=>{he.preventDefault(),he.stopPropagation(),$(B.id)},children:e.jsx(Us,{size:13})})}):null]},B.id)})})]},`${d.vendor}-${O}`))}):null]},d.vendor)})})}),e.jsxs("div",{className:"model-discovery-dialog__footer",children:[e.jsxs("span",{className:"model-discovery-dialog__selection-count",children:["已选 ",E," 个 · 图 ",W.image," / 视"," ",W.video," / 文 ",W.text]}),e.jsxs("div",{className:"model-discovery-dialog__footer-bulk",children:[e.jsx("button",{type:"button",className:"model-discovery-dialog__ghost-button",onClick:fe,disabled:G.length===0,children:te?"取消当前筛选":"全选"}),e.jsx("button",{type:"button",className:"model-discovery-dialog__ghost-button",onClick:Ie,disabled:J.length===0||Se,children:"选中推荐模型"}),e.jsx("button",{type:"button",className:"model-discovery-dialog__ghost-button model-discovery-dialog__ghost-button--muted",onClick:()=>M([]),disabled:K.length===0,children:"清空"})]}),e.jsxs("div",{className:"model-discovery-dialog__actions",children:[e.jsx("button",{type:"button",className:"model-discovery-dialog__button model-discovery-dialog__button--secondary",onClick:j,children:"取消"}),e.jsx("button",{type:"button",className:"model-discovery-dialog__button model-discovery-dialog__button--primary",onClick:()=>v(K),children:"添加模型"})]})]})]})})},ai=St.memo(({profile:t,onUpdateProfile:o})=>{const[n,g]=u.useState(!1),j=Ft(t.id),v=wt(t),$=(v==null?void 0:v.pricingUrl)||"",Y=(v==null?void 0:v.cnyPerUsd)??1,_e=(v==null?void 0:v.pricingGroup)||"default",H=u.useCallback(async()=>{if(v){g(!0);try{await Ns.fetchAndCache(t.id,v.pricingUrl,t.apiKey,v.pricingGroup,v.cnyPerUsd,{force:!0,promoteToAutoRefresh:!0}),V.success("价格信息已同步")}catch(M){V.error(`获取价格失败: ${M instanceof Error?M.message:"未知错误"}`)}finally{g(!1)}}},[v,t.id,t.apiKey]),xe=u.useCallback(async M=>{const k=String(M);if(o(U=>({...U,pricingGroup:k})),!!v){g(!0);try{await Ns.fetchAndCache(t.id,v.pricingUrl,t.apiKey,k,v.cnyPerUsd)}catch{}finally{g(!1)}}},[o,v,t.id,t.apiKey]),K=j.map(M=>({label:M.displayName||M.name,value:M.name}));return e.jsxs("div",{className:"settings-dialog__pricing-group",children:[e.jsxs("div",{className:"settings-dialog__pricing-row",children:[e.jsxs("div",{className:"settings-dialog__field settings-dialog__field--column",style:{flex:1,minWidth:0},children:[e.jsx("label",{className:"settings-dialog__label settings-dialog__label--stacked",children:"模型价格 URL"}),e.jsx("input",{type:"text",className:"settings-dialog__input",value:$,onChange:M=>o(k=>({...k,pricingUrl:M.target.value})),placeholder:"如 https://api.tu-zi.com/api/pricing"})]}),e.jsxs("div",{className:"settings-dialog__field settings-dialog__field--column",style:{width:110,flexShrink:0},children:[e.jsx("label",{className:"settings-dialog__label settings-dialog__label--stacked",children:"¥/1USD"}),e.jsx("input",{type:"number",className:"settings-dialog__input",value:Y,step:.01,min:0,onChange:M=>o(k=>({...k,cnyPerUsd:parseFloat(M.target.value)||0}))})]})]}),e.jsxs("div",{className:"settings-dialog__pricing-row",children:[K.length>0?e.jsxs("div",{className:"settings-dialog__field settings-dialog__field--column",style:{flex:1,minWidth:0},children:[e.jsx("label",{className:"settings-dialog__label settings-dialog__label--stacked",children:"当前分组"}),e.jsx(It,{value:_e,options:K,onChange:M=>xe(M),style:{width:"100%"}})]}):null,e.jsx("button",{type:"button",className:"settings-dialog__button settings-dialog__button--fetch",style:{alignSelf:"flex-end",height:32,flexShrink:0},onClick:H,disabled:n||!$,children:n?"同步中":"获取价格"})]})]})}),Cs="aitu:settings:provider-nav",ni=980,li=[{value:"providers",label:"供应商"},{value:"presets",label:"模型预设"},{value:"canvas",label:"画布显示"},{value:"speech",label:"语音播放"}],oi=["openai-compatible","gemini-compatible","custom"],Es={image:"图片",video:"视频",audio:"音频",text:"文本"},di={image:"图片模型",video:"视频模型",audio:"音频模型",text:"文本模型"},ri=u.memo(function({profileId:o,modelId:n}){const g=Yt(o,n);return g?e.jsx("span",{className:"settings-dialog__model-price",children:g}):null}),ci=u.memo(function({profileId:o,modelId:n}){const g=Zt(o,n);return g!=null&&g.description?e.jsx(ve,{content:g.description,placement:"top",children:e.jsx("span",{className:"settings-dialog__model-type-item-id settings-dialog__model-type-item-id--has-desc",children:n})}):e.jsx("span",{className:"settings-dialog__model-type-item-id",children:n})});function gi(t,o,n,g){return o===0&&n===0?null:g===0&&n>0?`已清空 ${t} 的已添加模型`:o>0&&n>0?`已更新 ${t} 的模型(新增 ${o} 个,移除 ${n} 个)`:o>0?`已为 ${t} 添加 ${o} 个模型`:`已从 ${t} 移除 ${n} 个模型`}const mi=["text","image","video","audio"],Ze={"openai-compatible":{label:"OpenAI 兼容"},"gemini-compatible":{label:"Gemini 兼容"},custom:{label:"自定义接入"}},As=["amber","sky","mint","rose","violet"];function ks(t){return t.reduce((o,n)=>(o[n.type]+=1,o),{image:0,video:0,audio:0,text:0})}function ui(t,o){const n=o.trim().toLowerCase();return n?[t.id,t.label,t.shortLabel,t.shortCode,t.description,t.sourceProfileName,Te(t.vendor)].filter(Boolean).some(g=>g==null?void 0:g.toLowerCase().includes(n)):!0}function _i(t){const o=new Set,n=[];return t.forEach(g=>{const j=`${g.type}:${g.id}`;o.has(j)||(o.add(j),n.push(g))}),n}function Ds(t){return t?["image","video","audio","text"].filter(o=>!!F(t[o])).length:0}function Rs(t,o){const n=o.find(g=>g.id===t.id);return n?Ni(n,t)?"saved":"dirty":"new"}function Oe(t){return JSON.stringify(t)}function hi(t){return typeof t.iconUrl!="string"?null:t.iconUrl.trim()||null}function pi(t){var g;const o=t.trim();if(!o)return"供";const n=o.match(/[A-Za-z0-9]+/g);return n!=null&&n[0]?n[0][0].toUpperCase():((g=Array.from(o)[0])==null?void 0:g.toUpperCase())||"供"}function vi(t){const o=Array.from(`${t.id}-${t.providerType}-${t.name}`).reduce((n,g,j)=>n+g.charCodeAt(0)*(j+1),0);return As[o%As.length]}function ge(t){return JSON.parse(JSON.stringify(t))}function Xe(t){return`${t}-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}function Os(t){return{id:Xe("profile"),name:`供应商 ${t}`,iconUrl:"",providerType:"openai-compatible",baseUrl:"",apiKey:"",authType:Qe(),enabled:!0,capabilities:{supportsModelsEndpoint:!0,supportsText:!0,supportsImage:!0,supportsVideo:!0,supportsAudio:!0,supportsTools:!0}}}function xi(){if(typeof window>"u")return null;const t=window.__aituPendingProviderNavigationIntent||null;return window.__aituPendingProviderNavigationIntent=void 0,t}function Qe(t){return"bearer"}function Ye(t){return t===T||t===Dt||t===Rt||t===Ot}const Ts=({profile:t,size:o="regular"})=>{const n=hi(t),[g,j]=u.useState(n);u.useEffect(()=>{j(n)},[n]);const v=vi(t),$=pi(t.name);return e.jsx("span",{className:`settings-dialog__provider-avatar settings-dialog__provider-avatar--${v} ${o==="large"?"settings-dialog__provider-avatar--large":""}`,"aria-hidden":"true",children:g?e.jsx("img",{src:g,alt:`${t.name} 图标`,className:"settings-dialog__provider-avatar-image",loading:"lazy",onError:()=>j(null)}):e.jsx("span",{className:"settings-dialog__provider-avatar-text",children:$})})};function fi(t,o){return{id:Xe("preset"),name:"新预设",text:me(ue(t,o.text||null)),image:me(ue(t,o.image||null)),video:me(ue(t,o.video||null)),audio:me(ue(t,o.audio||null))}}function ji(t,o,n){const g=t[o],j=n.defaultModelRef!==void 0?n.defaultModelRef:ue(n.profileId!==void 0?n.profileId:Ee(g),n.defaultModelId!==void 0?n.defaultModelId:F(g));return{...t,[o]:me(j)}}function yi(t,o){const n={...t};return["image","video","audio","text"].forEach(g=>{Ee(n[g])===o&&(n[g]=me(null))}),n}function Ni(t,o){return JSON.stringify(t)===JSON.stringify(o)}function bi(t){return t.flatMap(({profile:o,models:n})=>n.map(g=>({...g,sourceProfileId:o.id,sourceProfileName:o.name,selectionKey:g.selectionKey||`${o.id}::${g.id}`})))}const Ci=({container:t})=>{const{appState:o,setAppState:n}=Pt(),{confirm:g,confirmDialog:j}=Ct({container:t}),{isMobile:v,viewportWidth:$,viewportHeight:Y}=Et(),_e=u.useRef(null),[H,xe]=u.useState(0),[K,M]=u.useState("providers"),[k,U]=u.useState(T),[se,G]=u.useState(ee),[x,R]=u.useState([]),[E,W]=u.useState([]),[te,J]=u.useState(ee),[Se,we]=u.useState([]),[fe,Ie]=u.useState(""),[ie,d]=u.useState(""),[b,y]=u.useState(""),[A,O]=u.useState(""),[Z,B]=u.useState(!0),[ae,he]=u.useState(""),[He,Ae]=u.useState(!1),[Gs,Le]=u.useState(""),[Je,qe]=u.useState(!1),[Fs,ne]=u.useState("catalog"),[Ws,je]=u.useState("catalog"),[Zs,Ys]=u.useState(new Set),Qs=s=>{Ys(i=>{const l=new Set(i);return l.has(s)?l.delete(s):l.add(s),l})},m=x.find(s=>s.id===k)||x[0]||null,L=E.find(s=>s.id===se)||E[0]||null,z=Wt((m==null?void 0:m.id)||T),Xs=u.useDeferredValue(ae),es=Re(T,"image"),Hs=Re(T,"audio"),ss=Re(T,"video"),ts=Re(T,"text"),Js=x.filter(s=>s.enabled),h=v||$<=ni,is=h&&(H>0?H<600:$<600),ze=!!m&&!!m.apiKey.trim(),qs=Oe({profiles:x,presets:E,activePresetId:te,audioModelName:fe,imageModelName:ie,videoModelName:b,textModelName:A,showWorkZoneCard:Z}),as=o.openSettings&&qs!==Gs;u.useEffect(()=>{const s=_e.current;if(!s||typeof ResizeObserver>"u")return;const i=new ResizeObserver(l=>{var c;const a=(c=l[0])==null?void 0:c.contentRect.width;a&&xe(r=>Math.abs(r-a)<1?r:a)});return i.observe(s),()=>{i.disconnect()}},[o.openSettings]);const et=s=>{M(s),h&&(s==="providers"&&ne("catalog"),s==="presets"&&je("catalog"))},st=s=>{U(s),h&&ne("detail")},tt=s=>{G(s),h&&je("detail")},it=()=>{try{return localStorage.getItem(ke.WORKZONE_CARD_VISIBLE)!=="false"}catch{return!0}},Ve=()=>{const s=ge(Pe.get()),i=ge(oe.get()),l=oe.getActivePresetId()||ee,a=Ce.get(),c=it();we(s),Le(Oe({profiles:s,presets:i,activePresetId:l,audioModelName:a.audioModelName||pe(),imageModelName:a.imageModelName||de(),videoModelName:a.videoModelName||re(),textModelName:a.textModelName||ce(),showWorkZoneCard:c}))};u.useEffect(()=>{var f;if(!o.openSettings)return;const s=ge(Pe.get()),i=ge(oe.get()),l=oe.getActivePresetId()||ee,a=Ce.get();let c=!0;const r=xi(),_=(r==null?void 0:r.action)==="select"&&s.some(N=>N.id===r.profileId)?r.profileId:((f=s[0])==null?void 0:f.id)||T;R(s),W(i),we(s),J(l),U(N=>{var w;return r?_:s.some(P=>P.id===N)?N:((w=s[0])==null?void 0:w.id)||T}),G(N=>{var w;return i.some(P=>P.id===N)?N:((w=i[0])==null?void 0:w.id)||ee}),Ie(a.audioModelName||pe()),d(a.imageModelName||de()),y(a.videoModelName||re()),O(a.textModelName||ce());try{c=localStorage.getItem(ke.WORKZONE_CARD_VISIBLE)!=="false"}catch{c=!0}B(c),M("providers"),ne(r&&h?"detail":"catalog"),je("catalog"),he(""),Ae(!1),Le(Oe({profiles:s,presets:i,activePresetId:l,audioModelName:a.audioModelName||pe(),imageModelName:a.imageModelName||de(),videoModelName:a.videoModelName||re(),textModelName:a.textModelName||ce(),showWorkZoneCard:c})),(r==null?void 0:r.action)==="create"&&ls(r,s)},[o.openSettings]),u.useEffect(()=>{if(!k&&x[0]){U(x[0].id);return}k&&x.length>0&&!x.some(s=>s.id===k)&&U(x[0].id)},[x,k]),u.useEffect(()=>{if(!se&&E[0]){G(E[0].id);return}se&&E.length>0&&!E.some(s=>s.id===se)&&G(E[0].id)},[E,se]),u.useEffect(()=>{he("")},[k,K]);const ye=(s,i)=>{R(l=>l.map(a=>a.id===s?i(a):a))},at=(s,i)=>{W(l=>l.map(a=>a.id===s?i(a):a))},ns=async(s,i)=>{var l,a;try{const c=Ce.get(),r=((l=s.find(I=>I.id===i))==null?void 0:l.id)||((a=s[0])==null?void 0:a.id)||ee,_=s.find(I=>I.id===r)||s[0]||null,f=F(_==null?void 0:_.audio)||c.audioModelName||pe(),N=F(_==null?void 0:_.image)||c.imageModelName||de(),w=F(_==null?void 0:_.video)||c.videoModelName||re(),P=F(_==null?void 0:_.text)||c.textModelName||c.chatModel||ce();return await oe.update(ge(s)),await oe.setActivePresetId(r),await Ce.update({audioModelName:f,imageModelName:N,videoModelName:w,textModelName:P,chatModel:P}),W(s),J(r),Ie(f),d(N),y(w),O(P),Ve(),!0}catch(c){return console.error("Failed to persist preset configuration:",c),V.error("预设保存失败,请重试"),!1}},nt=async(s,i)=>{if(R(l=>l.map(a=>a.id===s?{...a,enabled:i}:a)),!!Se.some(l=>l.id===s))try{await Pe.update(ge(Pe.get()).map(l=>l.id===s?{...l,enabled:i}:l)),Ve()}catch(l){console.error("Failed to persist provider enabled state:",l),R(a=>a.map(c=>c.id===s?{...c,enabled:!i}:c)),V.error("供应商状态保存失败,请重试")}},lt=async s=>{B(s);try{localStorage.setItem(ke.WORKZONE_CARD_VISIBLE,String(s)),window.dispatchEvent(new CustomEvent("workzone-visibility-changed")),Ve()}catch(i){console.error("Failed to persist canvas visibility state:",i),B(!s),V.error("画布显示配置保存失败,请重试")}},ls=(s,i)=>{var r;const l=i||x;if(M("providers"),h&&ne("detail"),s.action==="select"){const _=l.some(f=>f.id===s.profileId)?s.profileId:((r=l[l.length-1])==null?void 0:r.id)||T;return U(_),l}const a=Os(l.length+1),c=[...l,a];return R(c),U(a.id),c},os=()=>{const s=Os(x.length+1);R(i=>[...i,s]),U(s.id),M("providers"),h&&ne("detail")};u.useEffect(()=>{if(!o.openSettings)return;const s=i=>{const l=i.detail;l&&ls(l)};return window.addEventListener(Cs,s),()=>{window.removeEventListener(Cs,s)}},[o.openSettings,h,x]);const ds=async s=>{var c;if(Ye(s))return;const i=x.find(r=>r.id===s);if(!await g({title:"确认删除供应商",description:`确定要删除供应商「${(i==null?void 0:i.name)||"未命名供应商"}」吗?相关预设里的路由会被清空。`,confirmText:"删除",cancelText:"取消",danger:!0}))return;const a=x.filter(r=>r.id!==s);R(a),W(r=>r.map(_=>yi(_,s))),k===s&&U(((c=a[0])==null?void 0:c.id)||T),h&&ne("catalog")},rs=u.useCallback(s=>{const i=x.find(a=>a.id===s);if(!i)return;const l={...ge(i),id:Xe("profile"),name:`${i.name} (副本)`};R(a=>[...a,l]),U(l.id),M("providers"),h&&ne("detail")},[x,h]),Ue=At(),ot=u.useCallback(s=>{const i=[{key:"clone",label:"克隆",icon:e.jsx(Tt,{size:14}),onSelect:rs}];return Ye(s)||i.push({key:"divider",type:"divider"},{key:"delete",label:"删除",icon:e.jsx(bs,{size:14}),danger:!0,onSelect:ds}),i},[rs]),cs=()=>{var l;const s=((l=Js[0])==null?void 0:l.id)||null,i=fi(s,{audio:fe||pe(),image:ie||de(),video:b||re(),text:A||ce()});W(a=>[...a,i]),G(i.id),M("presets"),h&&je("detail")},dt=async s=>{var c,r;if(E.length<=1)return;const i=E.find(_=>_.id===s);if(!await g({title:"确认删除预设",description:`确定要删除预设「${(i==null?void 0:i.name)||"未命名预设"}」吗?此操作不可撤销。`,confirmText:"删除",cancelText:"取消",danger:!0}))return;const a=E.filter(_=>_.id!==s);W(a),te===s&&J(((c=a[0])==null?void 0:c.id)||ee),se===s&&G(((r=a[0])==null?void 0:r.id)||ee),h&&je("catalog")},gs=(s,i)=>{if(!L)return;const l=E.map(a=>a.id===L.id?ji(a,s,{defaultModelRef:i}):a);W(l),ns(l,te)},rt=async()=>{if(!m){V.warning("请先选择供应商配置");return}if(as){const l=V.loading("正在保存当前配置...",0),a=await _s(!1);if(V.close(l),!a)return}const s=m.apiKey.trim(),i=We(m.baseUrl.trim()||De);if(!s){V.warning("请先填写 API Key");return}try{await Me.discover(m.id,i,s),Ae(!0)}catch(l){const a=l instanceof Error?l.message:"模型同步失败";Me.setError(m.id,a),V.error({content:a,duration:3600})}},ms=(s,i)=>{var r,_,f;if(!m)return;const l=Me.applySelection(m.id,s),a=l.models;if(m.id===T){const N=a.filter(p=>p.type==="image"),w=a.filter(p=>p.type==="video"),P=a.filter(p=>p.type==="text"),I=z.discoveredModels.filter(p=>p.type==="image").map(p=>p.id),Q=z.discoveredModels.filter(p=>p.type==="video").map(p=>p.id),C=z.discoveredModels.filter(p=>p.type==="text").map(p=>p.id);!N.some(p=>p.id===ie)&&I.includes(ie)&&d(((r=N[0])==null?void 0:r.id)||de()),!w.some(p=>p.id===b)&&Q.includes(b)&&y(((_=w[0])==null?void 0:_.id)||re()),!P.some(p=>p.id===A)&&C.includes(A)&&O(((f=P[0])==null?void 0:f.id)||ce())}const c=(i==null?void 0:i.successMessage)||gi(m.name,l.addedModelIds.length,l.removedModelIds.length,a.length);c&&V.success(c),Ae(!1)},ct=s=>{if(!m)return;if(!z.selectedModelIds.includes(s)){V.warning("该模型不是当前分组动态添加的模型,无法在此移除");return}const i=z.selectedModelIds.filter(l=>l!==s);ms(i)},us=()=>{n(s=>({...s,openSettings:!1}))},_s=async(s=!1)=>{var i,l,a,c,r,_;if(Je)return!1;qe(!0);try{const f=x.map(S=>{var be;const Ne=S.baseUrl.trim()?We(S.baseUrl):"";return{...S,name:S.name.trim()||"未命名供应商",iconUrl:((be=S.iconUrl)==null?void 0:be.trim())||void 0,baseUrl:Ne,apiKey:S.apiKey.trim()}}),N=new Set(f.map(S=>S.id)),w=E.map(S=>{const Ne={...S,name:S.name.trim()||"未命名预设",audio:{...S.audio},image:{...S.image},video:{...S.video},text:{...S.text}};return["image","video","audio","text"].forEach(be=>{const js=Ne[be],Ge=Ee(js),ys=F(js);if(Ge&&!N.has(Ge)){Ne[be]=me(ue(null,ys));return}Ne[be]=me(ue(Ge,ys))}),Ne}),P=((i=w.find(S=>S.id===te))==null?void 0:i.id)||((l=w[0])==null?void 0:l.id)||ee,I=w.find(S=>S.id===P)||w[0]||null,Q=f.find(S=>S.id===T)||f[0],C=We((Q==null?void 0:Q.baseUrl)||De),p=fe.trim()||((a=Hs[0])==null?void 0:a.id)||pe(),q=ie.trim()||((c=es[0])==null?void 0:c.id)||de(),D=b.trim()||((r=ss[0])==null?void 0:r.id)||re(),X=A.trim()||((_=ts[0])==null?void 0:_.id)||ce(),Be=F(I==null?void 0:I.image)||q,le=F(I==null?void 0:I.video)||D,xt=F(I==null?void 0:I.audio)||p,ft=F(I==null?void 0:I.text)||X;f.forEach(S=>{Me.invalidateIfConfigChanged(S.id,S.baseUrl||De,S.apiKey||"")}),await Ce.update({apiKey:(Q==null?void 0:Q.apiKey)||"",baseUrl:C,audioModelName:xt,imageModelName:Be,videoModelName:le,textModelName:ft}),await Pe.update(f),await $t.update(Me.getCatalogs().filter(S=>N.has(S.profileId))),await oe.update(w),await oe.setActivePresetId(P);try{localStorage.setItem(ke.WORKZONE_CARD_VISIBLE,String(Z)),window.dispatchEvent(new CustomEvent("workzone-visibility-changed"))}catch{}return R(f),we(ge(f)),W(w),J(P),Ie(p),d(q),y(D),O(X),Le(Oe({profiles:f,presets:w,activePresetId:P,audioModelName:p,imageModelName:q,videoModelName:D,textModelName:X,showWorkZoneCard:Z})),s&&us(),!0}catch(f){return console.error("Failed to persist settings drafts:",f),V.error("设置保存失败,请稍后重试"),!1}finally{qe(!1)}},gt=()=>{if(!as){us();return}(async()=>{const s=V.loading("正在保存设置...",0),i=await _s(!0);V.close(s),i||V.warning("设置尚未保存,请检查后重试")})()},mt=()=>{He||Je||gt()},hs=()=>e.jsxs("div",{className:"settings-dialog__sidebar-shell settings-dialog__sidebar-shell--catalog",children:[e.jsxs("div",{className:"settings-dialog__sidebar-summary",children:[e.jsxs("div",{className:"settings-dialog__sidebar-summary-row",children:[e.jsx("span",{className:"settings-dialog__sidebar-summary-title",children:"供应商目录"}),h?e.jsx("button",{type:"button",className:"settings-dialog__sidebar-summary-action",onClick:os,children:"新增供应商"}):null]}),h?e.jsx("span",{className:"settings-dialog__sidebar-summary-text",children:"先从列表里选择供应商,再进入对应的配置页面。"}):null]}),e.jsx("div",{className:"settings-dialog__sidebar-list",children:x.map(s=>{const i=s.id===(m==null?void 0:m.id);return e.jsxs("div",{className:`settings-dialog__provider-row ${i?"settings-dialog__provider-row--active":""} ${s.enabled?"":"settings-dialog__provider-row--disabled"}`,onContextMenu:l=>{l.preventDefault(),Ue.open(l,s.id)},children:[e.jsxs("button",{type:"button",className:"settings-dialog__provider-select",onClick:()=>st(s.id),"aria-pressed":i,children:[e.jsxs("span",{className:"settings-dialog__provider-select-main",children:[e.jsx(Ts,{profile:s}),e.jsxs("span",{className:"settings-dialog__provider-copy",children:[e.jsxs("span",{className:"settings-dialog__provider-name-row",children:[e.jsx("span",{className:"settings-dialog__provider-name",children:s.name}),s.id===T?e.jsx("span",{className:"settings-dialog__provider-tag",children:"默认"}):null]}),h?e.jsxs("span",{className:"settings-dialog__provider-meta",children:[e.jsx("span",{children:Ze[s.providerType].label}),e.jsx("span",{children:s.enabled?"启用":"停用"})]}):null]})]}),h?e.jsx(Fe,{size:16,className:"settings-dialog__provider-arrow","aria-hidden":"true"}):null]}),e.jsxs("div",{className:"settings-dialog__provider-switch",children:[e.jsx("span",{className:"settings-dialog__provider-switch-copy",children:s.enabled?"启用":"停用"}),e.jsx(Ms,{size:"small",value:s.enabled,disabled:s.id===T,onChange:l=>void nt(s.id,l)})]})]},s.id)})}),e.jsx(Ut,{state:Ue.contextMenu,items:ot,onClose:Ue.close,zIndex:2e4}),h?null:e.jsxs("button",{type:"button",className:"settings-dialog__sidebar-add",onClick:os,children:[e.jsx("span",{className:"settings-dialog__sidebar-add-icon",children:"+"}),e.jsx("span",{children:"新增供应商"})]})]}),ps=()=>e.jsxs("div",{className:"settings-dialog__sidebar-shell",children:[e.jsxs("div",{className:"settings-dialog__sidebar-summary",children:[e.jsxs("div",{className:"settings-dialog__sidebar-summary-row",children:[e.jsx("span",{className:"settings-dialog__sidebar-summary-title",children:"默认模型"}),h?e.jsx("button",{type:"button",className:"settings-dialog__sidebar-summary-action",onClick:cs,children:"新增预设"}):null]}),h?e.jsx("span",{className:"settings-dialog__sidebar-summary-text",children:"先选中一个预设,再进入详情页调整默认路由。"}):null]}),e.jsx("div",{className:"settings-dialog__sidebar-list",children:E.map(s=>{const i=s.id===(L==null?void 0:L.id),l=s.id===te,a=Ds(s);return e.jsxs("button",{type:"button",className:`settings-dialog__sidebar-item ${i?"settings-dialog__sidebar-item--active":""}`,onClick:()=>tt(s.id),children:[e.jsxs("div",{className:"settings-dialog__sidebar-item-head",children:[e.jsxs("div",{className:"settings-dialog__sidebar-item-top",children:[e.jsx("span",{children:s.name}),l?e.jsx("span",{className:"settings-dialog__sidebar-badge settings-dialog__sidebar-badge--accent",children:"当前"}):null]}),h?e.jsx(Fe,{size:16,className:"settings-dialog__sidebar-item-arrow","aria-hidden":"true"}):null]}),e.jsxs("div",{className:"settings-dialog__sidebar-item-meta",children:[e.jsxs("span",{children:[a,"/3 已配置"]}),h?e.jsx("span",{children:l?"正在生效":"点击查看详情"}):null]})]},s.id)})}),h?null:e.jsxs("button",{type:"button",className:"settings-dialog__sidebar-add",onClick:cs,children:[e.jsx("span",{className:"settings-dialog__sidebar-add-icon",children:"+"}),e.jsx("span",{children:"新增预设"})]})]}),vs=(s,i)=>e.jsx("div",{className:"settings-dialog__workspace settings-dialog__workspace--single",children:e.jsx("div",{className:"settings-dialog__content-panel settings-dialog__content-panel--compact",children:e.jsx("div",{className:"settings-dialog__mobile-stage",children:i},s)})}),xs=(s=!1)=>{if(!m)return e.jsx("div",{className:"settings-dialog__empty-panel",children:"请选择一个供应商。"});const i=ks(z.models),l=Rs(m,Se),a=i.image+i.video+i.text;return e.jsxs("div",{className:`settings-dialog__content-panel settings-dialog__content-panel--providers ${s?"settings-dialog__content-panel--detail":""}`,children:[s?e.jsxs("div",{className:"settings-dialog__compact-stage-header",children:[e.jsxs("button",{type:"button",className:"settings-dialog__compact-back",onClick:()=>ne("catalog"),children:[e.jsx(Ss,{size:16}),e.jsx("span",{children:"返回供应商目录"})]}),e.jsxs("div",{className:"settings-dialog__compact-stage-copy",children:[e.jsx("span",{className:"settings-dialog__compact-stage-eyebrow",children:"供应商配置"}),e.jsx("p",{className:"settings-dialog__compact-stage-text",children:"进入详情后再编辑接口信息、密钥和模型同步配置。"})]})]}):null,e.jsx("div",{className:"settings-dialog__section settings-dialog__section--compact",children:e.jsxs("div",{className:"settings-dialog__panel-header",children:[e.jsxs("div",{className:"settings-dialog__profile-hero",children:[e.jsx(Ts,{profile:m,size:"large"}),e.jsxs("div",{children:[e.jsx("h3",{className:"settings-dialog__section-title",children:m.name}),e.jsxs("div",{className:"settings-dialog__inline-meta",children:[e.jsx("span",{children:Ze[m.providerType].label}),e.jsx("span",{children:m.enabled?"启用":"停用"}),e.jsxs("span",{children:[a," 个模型"]}),e.jsx("span",{children:l==="saved"?"已保存":"未保存"})]})]})]}),Ye(m.id)?null:e.jsx("button",{type:"button",className:"settings-dialog__danger-button",onClick:()=>ds(m.id),children:"删除"})]})}),e.jsxs("div",{className:"settings-dialog__section",children:[e.jsx("div",{className:"settings-dialog__section-header",children:e.jsx("div",{children:e.jsx("h3",{className:"settings-dialog__section-title",children:"基础配置"})})}),e.jsxs("div",{className:"settings-dialog__grid",children:[e.jsxs("div",{className:"settings-dialog__field settings-dialog__field--column",children:[e.jsx("label",{className:"settings-dialog__label settings-dialog__label--stacked",children:"名称"}),e.jsx("input",{type:"text",className:"settings-dialog__input",value:m.name,onChange:c=>ye(m.id,r=>({...r,name:c.target.value}))})]}),e.jsxs("div",{className:"settings-dialog__field settings-dialog__field--column",children:[e.jsx("label",{className:"settings-dialog__label settings-dialog__label--stacked",children:"接口类型"}),e.jsx("select",{className:"settings-dialog__select",value:m.providerType,onChange:c=>ye(m.id,r=>{const _=c.target.value,f=Qe(r.providerType),N=Qe();return{...r,providerType:_,authType:r.authType===f?N:r.authType}}),children:oi.map(c=>e.jsx("option",{value:c,children:Ze[c].label},c))})]}),e.jsxs("div",{className:"settings-dialog__field settings-dialog__field--column settings-dialog__field--full",children:[e.jsx("label",{className:"settings-dialog__label settings-dialog__label--stacked",children:"图标 URL"}),e.jsx("input",{type:"url",className:"settings-dialog__input",value:m.iconUrl||"",onChange:c=>ye(m.id,r=>({...r,iconUrl:c.target.value})),placeholder:"可选,留空时自动生成默认图标"}),e.jsx("span",{className:"settings-dialog__field-hint",children:"支持填写远程图片地址;未填写时将根据供应商名称生成默认图标。"})]}),e.jsxs("div",{className:"settings-dialog__field settings-dialog__field--column settings-dialog__field--full",children:[e.jsx("label",{className:"settings-dialog__label settings-dialog__label--stacked",children:"API 地址"}),e.jsx("input",{type:"text",className:"settings-dialog__input",value:m.baseUrl,onChange:c=>ye(m.id,r=>({...r,baseUrl:c.target.value})),placeholder:De})]}),e.jsxs("div",{className:"settings-dialog__field settings-dialog__field--column settings-dialog__field--full",children:[e.jsxs("div",{className:"settings-dialog__label-with-tooltip settings-dialog__label-with-tooltip--left",children:[e.jsx("label",{className:"settings-dialog__label settings-dialog__label--stacked",children:"API Key"}),e.jsx(ve,{content:e.jsxs("div",{style:{maxWidth:480},children:["您可以从以下地址获取 API Key:",e.jsx("br",{}),e.jsx("a",{href:"https://api.tu-zi.com/token",target:"_blank",rel:"noopener noreferrer",style:{color:"#F39C12",textDecoration:"none",display:"inline-block",marginBottom:8},children:"api.tu-zi.com/token"}),e.jsx("div",{style:{position:"relative",width:"100%",paddingTop:"56.25%",marginTop:8,borderRadius:8,overflow:"hidden",backgroundColor:"#000",boxShadow:"0 4px 16px rgba(0,0,0,0.2)"},children:e.jsx("iframe",{title:"Bilibili tutorial video",src:"//player.bilibili.com/player.html?isOutside=true&aid=116171584049629&bvid=BV1k4PqzPEKz&cid=36455319822&p=1",allowFullScreen:!0,style:{position:"absolute",top:0,left:0,width:"100%",height:"100%",border:0}})})]}),placement:"top",theme:"light",showArrow:!1,overlayStyle:{maxWidth:"none"},children:e.jsx(zt,{className:"settings-dialog__tooltip-icon"})})]}),e.jsxs("div",{style:{display:"flex",gap:"8px",alignItems:"center",width:"100%",flexDirection:h?"column":"row"},children:[e.jsx("input",{type:"password",className:"settings-dialog__input",style:{flex:h?"none":1,width:"100%"},value:m.apiKey,onChange:c=>ye(m.id,r=>({...r,apiKey:c.target.value})),autoComplete:"off"}),e.jsx("button",{type:"button",className:"settings-dialog__button settings-dialog__button--fetch",style:{whiteSpace:"nowrap",height:h?"42px":"32px",width:h?"100%":"auto"},onClick:rt,disabled:!ze||z.status==="loading",children:z.status==="loading"?e.jsxs(e.Fragment,{children:[e.jsx(Vt,{size:15,className:"settings-dialog__button-spinner"}),"同步中"]}):"获取模型"})]})]})]})]}),e.jsx(ai,{profile:m,onUpdateProfile:c=>ye(m.id,c)}),m.id===T?e.jsx("div",{className:"settings-dialog__section settings-dialog__section--compact",children:e.jsxs("div",{className:"settings-dialog__compat-card",children:[e.jsx("div",{className:"settings-dialog__compat-title",children:"兼容默认模型"}),e.jsxs("div",{className:"settings-dialog__compat-meta",children:[e.jsxs("span",{children:["图片:",ie||de()]}),e.jsxs("span",{children:["视频:",b||re()]}),e.jsxs("span",{children:["音频:",fe||pe()]}),e.jsxs("span",{children:["文本:",A||ce()]})]})]})}):null,ut()]},s?`provider-detail-${m.id}`:void 0)},$e=u.useCallback(s=>{s.profileId&&Xt({profileId:s.profileId,modelId:s.modelId,modality:s.modality,compareMode:s.compareMode})},[n]),ut=()=>{const s=m?Rs(m,Se):"saved",i=!!(m!=null&&m.apiKey.trim())&&s==="saved"&&z.status!=="loading",l=(m==null?void 0:m.id)===T,a=_i(z.models),c=new Map($s.map((C,p)=>[C,p])),r=Xs.trim(),_=ks(a),f=a.filter(C=>ui(C,r)),N=mi.map(C=>({type:C,models:f.filter(p=>p.type===C).sort((p,q)=>{const D=c.get(p.vendor)??Number.MAX_SAFE_INTEGER,X=c.get(q.vendor)??Number.MAX_SAFE_INTEGER;return D!==X?D-X:Kt(p,q)})})).filter(C=>C.models.length>0),w=ze||a.length>0,P=a.length>0&&f.length===0&&!!r,I=z.status==="error"&&a.length===0,Q=!ze&&a.length===0;return e.jsxs("div",{className:"settings-dialog__section",children:[e.jsx("div",{className:"settings-dialog__section-header",children:e.jsxs("div",{children:[e.jsx("h3",{className:"settings-dialog__section-title",children:"模型"}),e.jsxs("div",{className:"settings-dialog__inline-meta",children:[e.jsxs("span",{children:["已添加 ",a.length," 个"]}),e.jsxs("span",{children:["图 ",_.image]}),e.jsxs("span",{children:["视 ",_.video]}),e.jsxs("span",{children:["音 ",_.audio]}),e.jsxs("span",{children:["文 ",_.text]})]})]})}),w?e.jsx("div",{className:"settings-dialog__model-toolbar",children:e.jsxs("label",{className:`settings-dialog__model-search ${a.length===0?"settings-dialog__model-search--disabled":""}`,children:[e.jsx(zs,{size:15}),e.jsx("input",{type:"text",value:ae,onChange:C=>he(C.target.value),placeholder:a.length>0?"搜索模型 ID、名称或品牌":"获取模型后可搜索",disabled:a.length===0}),ae?e.jsx("button",{type:"button",className:"settings-dialog__model-search-clear",onClick:()=>he(""),"aria-label":"清空搜索",children:e.jsx(Ls,{size:14})}):null]})}):null,N.length>0?e.jsx("div",{className:"settings-dialog__model-type-groups",children:N.map(({type:C,models:p})=>{const q=Zs.has(C);return e.jsxs("div",{className:"settings-dialog__model-type-group",children:[e.jsxs("div",{className:"settings-dialog__model-type-header",style:{cursor:"pointer"},onClick:()=>Qs(C),children:[e.jsxs("div",{className:"settings-dialog__model-type-meta",children:[q?e.jsx(Fe,{size:16,className:"settings-dialog__model-type-toggle"}):e.jsx(Vs,{size:16,className:"settings-dialog__model-type-toggle"}),e.jsx("span",{className:"settings-dialog__model-type-title",children:di[C]}),e.jsx("span",{className:"settings-dialog__model-type-count",children:p.length})]}),e.jsx("button",{type:"button",className:"settings-dialog__model-group-test",onClick:D=>{D.stopPropagation(),m&&$e({profileId:m.id,modality:C,compareMode:"cross-model"})},disabled:!i,title:i?"测试当前供应商这一组模型":"请先保存供应商配置并确保 API Key 可用",children:"测试本组"})]}),!q&&e.jsx("div",{className:"settings-dialog__model-type-list",children:p.map(D=>{const X=Ks(D.vendor),Be=!l||z.selectedModelIds.includes(D.id);return e.jsxs("div",{className:"settings-dialog__model-type-item",style:{"--model-brand-accent":X.accent,"--model-brand-surface":X.surface,"--model-brand-border":X.border},children:[e.jsx("span",{className:"settings-dialog__model-type-item-logo",children:e.jsx(Bs,{vendor:D.vendor,size:16})}),e.jsxs("div",{className:"settings-dialog__model-type-item-copy",children:[e.jsx(ci,{profileId:m.id,modelId:D.id}),e.jsx("span",{className:"settings-dialog__model-type-item-vendor",children:Te(D.vendor)}),e.jsx(ri,{profileId:m.id,modelId:D.id})]}),e.jsxs("div",{className:"settings-dialog__model-type-item-btns",children:[(()=>{const le=Ht.getLatestEntryStatus(m.id,D.id);return le==="completed"?e.jsx(ve,{content:"上次测试成功",showArrow:!1,children:e.jsx("span",{className:"settings-dialog__model-tip-trigger",children:e.jsx("span",{className:"settings-dialog__model-status settings-dialog__model-status--ok"})})}):le==="failed"?e.jsx(ve,{content:"上次测试失败",showArrow:!1,children:e.jsx("span",{className:"settings-dialog__model-tip-trigger",children:e.jsx("span",{className:"settings-dialog__model-status settings-dialog__model-status--fail"})})}):null})(),e.jsx(ve,{content:i?"测试":"请先保存供应商配置并确保 API Key 可用",showArrow:!1,children:e.jsx("span",{className:"settings-dialog__model-tip-trigger",children:e.jsx("button",{type:"button",className:"settings-dialog__model-icon-btn settings-dialog__model-icon-btn--test",onClick:le=>{le.stopPropagation(),m&&$e({profileId:m.id,modality:C,modelId:D.id,compareMode:"cross-provider"})},disabled:!i,children:e.jsx(Us,{size:14})})})}),Be?e.jsx(ve,{content:"移除此模型",showArrow:!1,children:e.jsx("span",{className:"settings-dialog__model-tip-trigger",children:e.jsx("button",{type:"button",className:"settings-dialog__model-icon-btn settings-dialog__model-icon-btn--delete",onClick:le=>{le.stopPropagation(),ct(D.id)},children:e.jsx(bs,{size:14})})})}):null]})]},D.id)})})]},C)})}):P?e.jsx("div",{className:"settings-dialog__model-empty",children:"没有匹配的模型,试试搜索品牌名或更完整的模型 ID。"}):I?e.jsxs("div",{className:"settings-dialog__model-empty settings-dialog__model-empty--error",children:[e.jsx(Bt,{size:16}),e.jsx("span",{children:z.error||"模型获取失败,请稍后重试"})]}):Q?e.jsx("div",{className:"settings-dialog__model-empty",children:"填写 API Key 后即可获取模型,获取完成后可在这里检索和浏览。"}):e.jsx("div",{className:"settings-dialog__model-empty",children:"还没有已添加的模型"})]})},_t=(s,i,l)=>{const a=Ee(l),c=F(l);return x.filter(r=>r.id===a||r.enabled&&r.capabilities[i]).map(r=>{const f=(r.id===T?s==="image"?es:s==="video"?ss:ts:Me.getState(r.id).models.filter(N=>N.type===s)).filter((N,w,P)=>P.findIndex(I=>I.id===N.id)===w);return r.id===a&&c&&!f.some(N=>N.id===c)&&f.unshift({id:c,label:c,shortLabel:c,type:s,vendor:Gt.OTHER}),{profile:r,models:f}}).filter(r=>r.models.length>0)},Ke=(s,i,l)=>{var w;const a=_t(s,l,i),c=Ee(i),r=F(i),_=((w=x.find(P=>P.id===c))==null?void 0:w.name)||"未配置",f=bi(a),N=c&&r?`${c}::${r}`:r||void 0;return e.jsxs("div",{className:`settings-dialog__route-card settings-dialog__route-card--${s}`,children:[e.jsx("div",{className:"settings-dialog__route-card-top",children:e.jsx("div",{className:"settings-dialog__route-card-title",children:Es[s]})}),e.jsxs("div",{className:"settings-dialog__stack",children:[e.jsxs("div",{className:"settings-dialog__field settings-dialog__field--column",children:[e.jsx("label",{className:"settings-dialog__label settings-dialog__label--stacked",children:"默认模型"}),e.jsxs("div",{className:"settings-dialog__route-model-picker",children:[e.jsx(Qt,{variant:"form",selectedModel:r||"",selectedSelectionKey:N,models:f,providerProfilesOverride:x,placement:"down",placeholder:`搜索${Es[s]}模型或供应商`,allowCustomValue:!1,showProviderAction:!1,onSelect:(P,I)=>{gs(s,I||ue(null,P))},disabled:f.length===0}),r?e.jsx("button",{type:"button",className:"settings-dialog__route-clear",onClick:()=>gs(s,null),children:"清空"}):null]})]}),e.jsxs("div",{className:"settings-dialog__route-meta",children:[e.jsx("span",{children:_}),e.jsx("span",{children:r||"未选择模型"}),a.length===0?e.jsx("span",{children:"暂无可选模型"}):null]})]})]})},fs=(s=!1)=>{if(!L)return e.jsx("div",{className:"settings-dialog__empty-panel",children:"请选择一个默认模型预设。"});const i=Ds(L),l=L.id===te;return e.jsxs("div",{className:`settings-dialog__content-panel ${s?"settings-dialog__content-panel--detail":""}`,children:[s?e.jsxs("div",{className:"settings-dialog__compact-stage-header",children:[e.jsxs("button",{type:"button",className:"settings-dialog__compact-back",onClick:()=>je("catalog"),children:[e.jsx(Ss,{size:16}),e.jsx("span",{children:"返回模型预设"})]}),e.jsxs("div",{className:"settings-dialog__compact-stage-copy",children:[e.jsx("span",{className:"settings-dialog__compact-stage-eyebrow",children:"模型预设"}),e.jsx("p",{className:"settings-dialog__compact-stage-text",children:"在这里设置图片、视频和文本模型的默认路由。"})]})]}):null,e.jsxs("div",{className:"settings-dialog__section",children:[e.jsxs("div",{className:"settings-dialog__panel-header",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"settings-dialog__section-title",children:L.name}),e.jsxs("div",{className:"settings-dialog__inline-meta",children:[e.jsx("span",{children:l?"当前预设":"未激活"}),e.jsxs("span",{children:[i,"/3 已配置"]})]})]}),e.jsxs("div",{className:"settings-dialog__inline-row",children:[e.jsx("button",{type:"button",className:"settings-dialog__ghost-button",onClick:()=>{ns(E,L.id)},children:"设为当前预设"}),e.jsx("button",{type:"button",className:"settings-dialog__danger-button",onClick:()=>dt(L.id),disabled:E.length<=1,children:"删除预设"})]})]}),e.jsx("div",{className:"settings-dialog__grid",children:e.jsxs("div",{className:"settings-dialog__field settings-dialog__field--column settings-dialog__field--full",children:[e.jsx("label",{className:"settings-dialog__label settings-dialog__label--stacked",children:"预设名称"}),e.jsx("input",{type:"text",className:"settings-dialog__input",value:L.name,onChange:a=>at(L.id,c=>({...c,name:a.target.value}))})]})})]}),e.jsxs("div",{className:"settings-dialog__routes",children:[Ke("image",L.image,"supportsImage"),Ke("video",L.video,"supportsVideo"),Ke("text",L.text,"supportsText")]})]},s?`preset-detail-${L.id}`:void 0)},ht=()=>e.jsx("div",{className:"settings-dialog__workspace settings-dialog__workspace--single",children:e.jsxs("div",{className:"settings-dialog__content-panel settings-dialog__content-panel--canvas",children:[h?e.jsx("div",{className:"settings-dialog__compact-stage-header",children:e.jsxs("div",{className:"settings-dialog__compact-stage-copy",children:[e.jsx("span",{className:"settings-dialog__compact-stage-eyebrow",children:"画布显示"}),e.jsx("p",{className:"settings-dialog__compact-stage-text",children:"手机上会以更集中的卡片形式展示,方便快速切换画布相关开关。"})]})}):null,e.jsxs("div",{className:"settings-dialog__section settings-dialog__section--canvas-card",children:[e.jsx("div",{className:"settings-dialog__section-header",children:e.jsx("div",{children:e.jsx("h3",{className:"settings-dialog__section-title",children:"画布显示配置"})})}),e.jsxs("div",{className:"settings-dialog__preference settings-dialog__preference--panel",children:[e.jsxs("div",{className:"settings-dialog__toggle-copy",children:[e.jsx("span",{className:"settings-dialog__toggle-title",children:"任务进度卡片"}),e.jsx("span",{className:"settings-dialog__toggle-desc",children:"在画布中显示任务进度卡片,便于追踪当前生成状态。"})]}),e.jsx(Ms,{size:"small",value:Z,onChange:s=>void lt(s)})]})]})]})}),pt=()=>e.jsx("aside",{className:"settings-dialog__nav",children:e.jsx("div",{className:"settings-dialog__nav-shell",children:e.jsx("div",{className:"settings-dialog__nav-list",children:li.map(s=>e.jsx("button",{type:"button",className:`settings-dialog__nav-item ${K===s.value?"settings-dialog__nav-item--active":""}`,onClick:()=>et(s.value),children:e.jsx("span",{className:"settings-dialog__nav-item-title",children:s.label})},s.value))})})}),vt=()=>K==="canvas"?ht():K==="speech"?e.jsx(Lt,{}):K==="presets"?is?Ws==="catalog"?vs("presets-catalog",ps()):fs(!0):e.jsxs("div",{className:`settings-dialog__workspace ${h?"settings-dialog__workspace--show-sidebar":""}`,children:[e.jsx("aside",{className:"settings-dialog__sidebar",children:ps()}),fs(!1)]}):is?Fs==="catalog"?vs("providers-catalog",hs()):xs(!0):e.jsxs("div",{className:`settings-dialog__workspace ${h?"settings-dialog__workspace--show-sidebar":""}`,children:[e.jsx("aside",{className:"settings-dialog__sidebar",children:hs()}),xs(!1)]});return e.jsxs(e.Fragment,{children:[e.jsx(kt,{id:"settings-dialog",visible:o.openSettings,title:"设置",onClose:mt,width:h?"100%":"88%",height:h?"100%":"88%",minWidth:h?Math.max(320,Math.min($-16,640)):1080,minHeight:h?Math.max(520,Math.min(Y-16,820)):680,x:"center",y:"center",maximizable:!0,minimizable:!1,resizable:!h,movable:!h,modal:!1,className:"winbox-ai-generation winbox-tool-window winbox-settings-window",container:t,background:"#ffffff",children:e.jsx("div",{ref:_e,className:`settings-dialog ${h?"settings-dialog--compact":""}`,"data-testid":"settings-dialog",children:e.jsxs("div",{className:"settings-dialog__layout",children:[pt(),e.jsx("div",{className:"settings-dialog__main",children:vt()})]})})}),e.jsx(ii,{open:He,container:t,models:z.discoveredModels,selectedModelIds:z.selectedModelIds,onClose:()=>Ae(!1),onConfirm:ms,onTestModel:s=>{if(!m)return;const i=z.discoveredModels.find(l=>l.id===s);$e({profileId:m.id,modelId:s,modality:(i==null?void 0:i.type)||"image",compareMode:"cross-provider"})}}),j]})};export{ki as IMAGE_MODEL_GROUPED_OPTIONS,Ci as SettingsDialog,Di as VIDEO_MODEL_OPTIONS};
|
|
1
|
+
import{iI as jt,r as u,iJ as yt,y as e,iy as Nt,iz as bt,bW as Ls,iK as zs,bw as Vs,hj as Mt,bV as ve,iL as Us,aI as St,iM as wt,iN as Ns,al as V,i8 as It,bL as Pt,bm as Ct,eP as Et,iO as T,iP as ee,iQ as Pe,it as oe,hd as Ce,hf as pe,hg as de,he as re,hx as ce,gP as ke,iR as At,iS as bs,iA as kt,iT as Dt,iU as Rt,iV as Ot,cV as Tt,iW as Lt,iX as Me,iY as Ee,iZ as me,fI as Ms,i_ as Ss,i$ as Fe,j0 as De,j1 as zt,j2 as Vt,j3 as Ut,j4 as We,j5 as F,hv as ue,j6 as $t,j7 as Kt,j8 as Bt,j9 as Gt}from"./tool-windows-C4D0lII2.js";import{ja as ki,jb as Di}from"./tool-windows-C4D0lII2.js";import{D as $s,g as Te,a as Ks,b as Bs,c as Ft,d as Wt,e as Re,f as Zt,h as Yt}from"./use-runtime-models-BLwgp0M1.js";import{M as Qt}from"./ModelDropdown-CHYgRb1r.js";import{o as Xt}from"./model-benchmark-launcher-DtJmU6Wc.js";import{m as Ht}from"./model-benchmark-service-B0QCqInK.js";const ws={all:"全部",image:"图片",video:"视频",audio:"音频",text:"文本"},Jt={image:"图片",video:"视频",audio:"音频",text:"文本"},qt={image:"图",video:"视",audio:"音",text:"文"},Is=["text","image","video","audio"];function ei(t,o){const n=o.trim().toLowerCase();return n?[t.id,t.label,t.shortLabel,t.shortCode,t.description,t.sourceProfileName,Te(t.vendor)].filter(Boolean).some(g=>g==null?void 0:g.toLowerCase().includes(n)):!0}function si(t){return jt(t)}function Ps(t,o){const n=new Map;for(const j of t){const v=n.get(j.vendor)||{vendor:j.vendor,models:[],counts:{image:0,video:0,audio:0,text:0},selectedCount:0};v.models.push(j),v.counts[j.type]+=1,o.has(j.id)&&(v.selectedCount+=1),n.set(j.vendor,v)}const g=new Map($s.map((j,v)=>[j,v]));return Array.from(n.values()).sort((j,v)=>{const $=g.get(j.vendor)??Number.MAX_SAFE_INTEGER,Y=g.get(v.vendor)??Number.MAX_SAFE_INTEGER;return $!==Y?$-Y:v.models.length-j.models.length})}function ti(t){return["image","video","audio","text"].filter(o=>t.counts[o]>0).map(o=>({type:o,models:si(t.models.filter(n=>n.type===o))})).sort((o,n)=>n.models.length!==o.models.length?n.models.length-o.models.length:Is.indexOf(o.type)-Is.indexOf(n.type))}const ii=({open:t,container:o,models:n,selectedModelIds:g,onClose:j,onConfirm:v,onTestModel:$})=>{const[Y,_e]=u.useState(""),[H,xe]=u.useState("all"),[K,M]=u.useState(g),[k,U]=u.useState({});u.useEffect(()=>{var O,Z;if(!t)return;_e(""),xe("all"),M(g);const d=new Set(g),b=Ps(n,d),y=((O=b.find(B=>B.selectedCount>0))==null?void 0:O.vendor)||((Z=b[0])==null?void 0:Z.vendor)||null,A={};b.forEach(B=>{A[B.vendor]=B.vendor===y}),U(A)},[n,t,g]);const se=u.useMemo(()=>({all:n.length,image:n.filter(d=>d.type==="image").length,video:n.filter(d=>d.type==="video").length,audio:n.filter(d=>d.type==="audio").length,text:n.filter(d=>d.type==="text").length}),[n]),G=u.useMemo(()=>{const d=Y.trim(),b=H==="all"?n:n.filter(y=>y.type===H);return d?b.filter(y=>ei(y,d)):b},[H,n,Y]),x=u.useMemo(()=>new Set(K),[K]),R=u.useMemo(()=>Ps(G,x),[x,G]),E=K.length,W=u.useMemo(()=>({image:n.filter(d=>d.type==="image"&&x.has(d.id)).length,video:n.filter(d=>d.type==="video"&&x.has(d.id)).length,text:n.filter(d=>d.type==="text"&&x.has(d.id)).length}),[n,x]),te=G.length>0&&G.every(d=>x.has(d.id)),J=u.useMemo(()=>n.filter(d=>yt(d.id)).map(d=>d.id),[n]),Se=J.length>0&&J.every(d=>x.has(d));u.useEffect(()=>{R.length===0||R.some(y=>k[y.vendor])||!Object.values(k).some(Boolean)||U(R.reduce((y,A,O)=>(y[A.vendor]=O===0,y),{}))},[k,R]);const we=d=>{M(b=>b.includes(d)?b.filter(y=>y!==d):[...b,d])},fe=()=>{const d=G.map(y=>y.id),b=d.every(y=>x.has(y));M(y=>b?y.filter(A=>!d.includes(A)):Array.from(new Set([...y,...d])))},Ie=()=>{M(d=>Array.from(new Set([...d,...J])))},ie=d=>{U(b=>{const y=!b[d],A={};return R.forEach(O=>{A[O.vendor]=O.vendor===d?y:!1}),A})};return e.jsx(Nt,{open:t,onOpenChange:d=>!d&&j(),children:e.jsxs(bt,{className:"model-discovery-dialog",container:o,"data-testid":"model-discovery-dialog",children:[e.jsxs("div",{className:"model-discovery-dialog__header",children:[e.jsxs("div",{className:"model-discovery-dialog__headline",children:[e.jsx("h3",{className:"model-discovery-dialog__title",children:"获取模型"}),e.jsxs("div",{className:"model-discovery-dialog__header-stats",children:[e.jsxs("span",{className:"model-discovery-dialog__header-pill",children:["已发现 ",n.length]}),e.jsxs("span",{className:"model-discovery-dialog__header-pill",children:["品牌 ",R.length]}),e.jsxs("span",{className:"model-discovery-dialog__header-pill model-discovery-dialog__header-pill--accent",children:["已选 ",E]})]})]}),e.jsx("button",{type:"button",className:"model-discovery-dialog__close",onClick:j,"aria-label":"关闭",children:e.jsx(Ls,{size:18})})]}),e.jsx("div",{className:"model-discovery-dialog__toolbar",children:e.jsxs("label",{className:"model-discovery-dialog__search",children:[e.jsx(zs,{size:16}),e.jsx("input",{type:"text",value:Y,onChange:d=>_e(d.target.value),placeholder:"搜索模型名称、ID 或品牌"})]})}),e.jsx("div",{className:"model-discovery-dialog__type-tabs",children:Object.keys(ws).map(d=>{const b=H===d;return e.jsxs("button",{type:"button",className:`model-discovery-dialog__type-tab ${b?"model-discovery-dialog__type-tab--active":""}`,onClick:()=>xe(d),children:[e.jsx("span",{children:ws[d]}),e.jsx("span",{className:"model-discovery-dialog__type-tab-count",children:se[d]})]},d)})}),e.jsx("div",{className:"model-discovery-dialog__body",children:R.length===0?e.jsx("div",{className:"model-discovery-dialog__empty",children:Y.trim()?"没有匹配的模型":"暂无模型"}):e.jsx("div",{className:"model-discovery-dialog__group-list",children:R.map(d=>{const b=Ks(d.vendor),y=ti(d),A=!!k[d.vendor];return e.jsxs("section",{className:`model-discovery-dialog__vendor-group ${A?"model-discovery-dialog__vendor-group--expanded":""}`,style:{"--vendor-accent":b.accent,"--vendor-surface":b.surface,"--vendor-border":b.border},children:[e.jsxs("button",{type:"button",className:"model-discovery-dialog__vendor-header",onClick:()=>ie(d.vendor),children:[e.jsxs("div",{className:"model-discovery-dialog__vendor-main",children:[e.jsx("span",{className:"model-discovery-dialog__vendor-logo-shell",children:e.jsx(Bs,{vendor:d.vendor,size:22})}),e.jsxs("div",{className:"model-discovery-dialog__vendor-copy",children:[e.jsx("span",{className:"model-discovery-dialog__vendor-name",children:Te(d.vendor)}),e.jsx("div",{className:"model-discovery-dialog__vendor-meta",children:y.map(({type:O,models:Z})=>e.jsxs("span",{className:"model-discovery-dialog__vendor-meta-pill",children:[qt[O]," ",Z.length]},`${d.vendor}-${O}`))})]})]}),e.jsx("span",{className:"model-discovery-dialog__vendor-spacer"}),e.jsxs("div",{className:"model-discovery-dialog__vendor-side",children:[d.selectedCount>0?e.jsxs("span",{className:"model-discovery-dialog__vendor-selected",children:["已选 ",d.selectedCount]}):null,e.jsx("span",{className:"model-discovery-dialog__vendor-count",children:d.models.length}),e.jsx("span",{className:`model-discovery-dialog__vendor-chevron ${A?"model-discovery-dialog__vendor-chevron--expanded":""}`,children:e.jsx(Vs,{size:16})})]})]}),A?e.jsx("div",{className:"model-discovery-dialog__vendor-body",children:y.map(({type:O,models:Z})=>e.jsxs("div",{className:"model-discovery-dialog__type-section",children:[e.jsxs("div",{className:"model-discovery-dialog__type-section-header",children:[e.jsx("span",{className:"model-discovery-dialog__type-section-title",children:Jt[O]}),e.jsx("span",{className:"model-discovery-dialog__type-section-count",children:Z.length})]}),e.jsx("div",{className:"model-discovery-dialog__model-stack",children:Z.map(B=>{const ae=x.has(B.id);return e.jsxs("label",{className:`model-discovery-dialog__item ${ae?"model-discovery-dialog__item--checked":""}`,children:[e.jsx("input",{type:"checkbox",className:"model-discovery-dialog__checkbox",checked:ae,onChange:()=>we(B.id)}),e.jsx("span",{className:"model-discovery-dialog__checkmark",children:ae?e.jsx(Mt,{size:12}):null}),e.jsx("div",{className:"model-discovery-dialog__item-body",children:e.jsx("div",{className:`model-discovery-dialog__item-id ${ae?"model-discovery-dialog__item-id--checked":""}`,children:B.id})}),$?e.jsx(ve,{content:"测试此模型",showArrow:!1,children:e.jsx("button",{type:"button",className:"model-discovery-dialog__item-test",onClick:he=>{he.preventDefault(),he.stopPropagation(),$(B.id)},children:e.jsx(Us,{size:13})})}):null]},B.id)})})]},`${d.vendor}-${O}`))}):null]},d.vendor)})})}),e.jsxs("div",{className:"model-discovery-dialog__footer",children:[e.jsxs("span",{className:"model-discovery-dialog__selection-count",children:["已选 ",E," 个 · 图 ",W.image," / 视"," ",W.video," / 文 ",W.text]}),e.jsxs("div",{className:"model-discovery-dialog__footer-bulk",children:[e.jsx("button",{type:"button",className:"model-discovery-dialog__ghost-button",onClick:fe,disabled:G.length===0,children:te?"取消当前筛选":"全选"}),e.jsx("button",{type:"button",className:"model-discovery-dialog__ghost-button",onClick:Ie,disabled:J.length===0||Se,children:"选中推荐模型"}),e.jsx("button",{type:"button",className:"model-discovery-dialog__ghost-button model-discovery-dialog__ghost-button--muted",onClick:()=>M([]),disabled:K.length===0,children:"清空"})]}),e.jsxs("div",{className:"model-discovery-dialog__actions",children:[e.jsx("button",{type:"button",className:"model-discovery-dialog__button model-discovery-dialog__button--secondary",onClick:j,children:"取消"}),e.jsx("button",{type:"button",className:"model-discovery-dialog__button model-discovery-dialog__button--primary",onClick:()=>v(K),children:"添加模型"})]})]})]})})},ai=St.memo(({profile:t,onUpdateProfile:o})=>{const[n,g]=u.useState(!1),j=Ft(t.id),v=wt(t),$=(v==null?void 0:v.pricingUrl)||"",Y=(v==null?void 0:v.cnyPerUsd)??1,_e=(v==null?void 0:v.pricingGroup)||"default",H=u.useCallback(async()=>{if(v){g(!0);try{await Ns.fetchAndCache(t.id,v.pricingUrl,t.apiKey,v.pricingGroup,v.cnyPerUsd,{force:!0,promoteToAutoRefresh:!0}),V.success("价格信息已同步")}catch(M){V.error(`获取价格失败: ${M instanceof Error?M.message:"未知错误"}`)}finally{g(!1)}}},[v,t.id,t.apiKey]),xe=u.useCallback(async M=>{const k=String(M);if(o(U=>({...U,pricingGroup:k})),!!v){g(!0);try{await Ns.fetchAndCache(t.id,v.pricingUrl,t.apiKey,k,v.cnyPerUsd)}catch{}finally{g(!1)}}},[o,v,t.id,t.apiKey]),K=j.map(M=>({label:M.displayName||M.name,value:M.name}));return e.jsxs("div",{className:"settings-dialog__pricing-group",children:[e.jsxs("div",{className:"settings-dialog__pricing-row",children:[e.jsxs("div",{className:"settings-dialog__field settings-dialog__field--column",style:{flex:1,minWidth:0},children:[e.jsx("label",{className:"settings-dialog__label settings-dialog__label--stacked",children:"模型价格 URL"}),e.jsx("input",{type:"text",className:"settings-dialog__input",value:$,onChange:M=>o(k=>({...k,pricingUrl:M.target.value})),placeholder:"如 https://api.tu-zi.com/api/pricing"})]}),e.jsxs("div",{className:"settings-dialog__field settings-dialog__field--column",style:{width:110,flexShrink:0},children:[e.jsx("label",{className:"settings-dialog__label settings-dialog__label--stacked",children:"¥/1USD"}),e.jsx("input",{type:"number",className:"settings-dialog__input",value:Y,step:.01,min:0,onChange:M=>o(k=>({...k,cnyPerUsd:parseFloat(M.target.value)||0}))})]})]}),e.jsxs("div",{className:"settings-dialog__pricing-row",children:[K.length>0?e.jsxs("div",{className:"settings-dialog__field settings-dialog__field--column",style:{flex:1,minWidth:0},children:[e.jsx("label",{className:"settings-dialog__label settings-dialog__label--stacked",children:"当前分组"}),e.jsx(It,{value:_e,options:K,onChange:M=>xe(M),style:{width:"100%"}})]}):null,e.jsx("button",{type:"button",className:"settings-dialog__button settings-dialog__button--fetch",style:{alignSelf:"flex-end",height:32,flexShrink:0},onClick:H,disabled:n||!$,children:n?"同步中":"获取价格"})]})]})}),Cs="aitu:settings:provider-nav",ni=980,li=[{value:"providers",label:"供应商"},{value:"presets",label:"模型预设"},{value:"canvas",label:"画布显示"},{value:"speech",label:"语音播放"}],oi=["openai-compatible","gemini-compatible","custom"],Es={image:"图片",video:"视频",audio:"音频",text:"文本"},di={image:"图片模型",video:"视频模型",audio:"音频模型",text:"文本模型"},ri=u.memo(function({profileId:o,modelId:n}){const g=Yt(o,n);return g?e.jsx("span",{className:"settings-dialog__model-price",children:g}):null}),ci=u.memo(function({profileId:o,modelId:n}){const g=Zt(o,n);return g!=null&&g.description?e.jsx(ve,{content:g.description,placement:"top",children:e.jsx("span",{className:"settings-dialog__model-type-item-id settings-dialog__model-type-item-id--has-desc",children:n})}):e.jsx("span",{className:"settings-dialog__model-type-item-id",children:n})});function gi(t,o,n,g){return o===0&&n===0?null:g===0&&n>0?`已清空 ${t} 的已添加模型`:o>0&&n>0?`已更新 ${t} 的模型(新增 ${o} 个,移除 ${n} 个)`:o>0?`已为 ${t} 添加 ${o} 个模型`:`已从 ${t} 移除 ${n} 个模型`}const mi=["text","image","video","audio"],Ze={"openai-compatible":{label:"OpenAI 兼容"},"gemini-compatible":{label:"Gemini 兼容"},custom:{label:"自定义接入"}},As=["amber","sky","mint","rose","violet"];function ks(t){return t.reduce((o,n)=>(o[n.type]+=1,o),{image:0,video:0,audio:0,text:0})}function ui(t,o){const n=o.trim().toLowerCase();return n?[t.id,t.label,t.shortLabel,t.shortCode,t.description,t.sourceProfileName,Te(t.vendor)].filter(Boolean).some(g=>g==null?void 0:g.toLowerCase().includes(n)):!0}function _i(t){const o=new Set,n=[];return t.forEach(g=>{const j=`${g.type}:${g.id}`;o.has(j)||(o.add(j),n.push(g))}),n}function Ds(t){return t?["image","video","audio","text"].filter(o=>!!F(t[o])).length:0}function Rs(t,o){const n=o.find(g=>g.id===t.id);return n?Ni(n,t)?"saved":"dirty":"new"}function Oe(t){return JSON.stringify(t)}function hi(t){return typeof t.iconUrl!="string"?null:t.iconUrl.trim()||null}function pi(t){var g;const o=t.trim();if(!o)return"供";const n=o.match(/[A-Za-z0-9]+/g);return n!=null&&n[0]?n[0][0].toUpperCase():((g=Array.from(o)[0])==null?void 0:g.toUpperCase())||"供"}function vi(t){const o=Array.from(`${t.id}-${t.providerType}-${t.name}`).reduce((n,g,j)=>n+g.charCodeAt(0)*(j+1),0);return As[o%As.length]}function ge(t){return JSON.parse(JSON.stringify(t))}function Xe(t){return`${t}-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}function Os(t){return{id:Xe("profile"),name:`供应商 ${t}`,iconUrl:"",providerType:"openai-compatible",baseUrl:"",apiKey:"",authType:Qe(),enabled:!0,capabilities:{supportsModelsEndpoint:!0,supportsText:!0,supportsImage:!0,supportsVideo:!0,supportsAudio:!0,supportsTools:!0}}}function xi(){if(typeof window>"u")return null;const t=window.__aituPendingProviderNavigationIntent||null;return window.__aituPendingProviderNavigationIntent=void 0,t}function Qe(t){return"bearer"}function Ye(t){return t===T||t===Dt||t===Rt||t===Ot}const Ts=({profile:t,size:o="regular"})=>{const n=hi(t),[g,j]=u.useState(n);u.useEffect(()=>{j(n)},[n]);const v=vi(t),$=pi(t.name);return e.jsx("span",{className:`settings-dialog__provider-avatar settings-dialog__provider-avatar--${v} ${o==="large"?"settings-dialog__provider-avatar--large":""}`,"aria-hidden":"true",children:g?e.jsx("img",{src:g,alt:`${t.name} 图标`,className:"settings-dialog__provider-avatar-image",loading:"lazy",onError:()=>j(null)}):e.jsx("span",{className:"settings-dialog__provider-avatar-text",children:$})})};function fi(t,o){return{id:Xe("preset"),name:"新预设",text:me(ue(t,o.text||null)),image:me(ue(t,o.image||null)),video:me(ue(t,o.video||null)),audio:me(ue(t,o.audio||null))}}function ji(t,o,n){const g=t[o],j=n.defaultModelRef!==void 0?n.defaultModelRef:ue(n.profileId!==void 0?n.profileId:Ee(g),n.defaultModelId!==void 0?n.defaultModelId:F(g));return{...t,[o]:me(j)}}function yi(t,o){const n={...t};return["image","video","audio","text"].forEach(g=>{Ee(n[g])===o&&(n[g]=me(null))}),n}function Ni(t,o){return JSON.stringify(t)===JSON.stringify(o)}function bi(t){return t.flatMap(({profile:o,models:n})=>n.map(g=>({...g,sourceProfileId:o.id,sourceProfileName:o.name,selectionKey:g.selectionKey||`${o.id}::${g.id}`})))}const Ci=({container:t})=>{const{appState:o,setAppState:n}=Pt(),{confirm:g,confirmDialog:j}=Ct({container:t}),{isMobile:v,viewportWidth:$,viewportHeight:Y}=Et(),_e=u.useRef(null),[H,xe]=u.useState(0),[K,M]=u.useState("providers"),[k,U]=u.useState(T),[se,G]=u.useState(ee),[x,R]=u.useState([]),[E,W]=u.useState([]),[te,J]=u.useState(ee),[Se,we]=u.useState([]),[fe,Ie]=u.useState(""),[ie,d]=u.useState(""),[b,y]=u.useState(""),[A,O]=u.useState(""),[Z,B]=u.useState(!0),[ae,he]=u.useState(""),[He,Ae]=u.useState(!1),[Gs,Le]=u.useState(""),[Je,qe]=u.useState(!1),[Fs,ne]=u.useState("catalog"),[Ws,je]=u.useState("catalog"),[Zs,Ys]=u.useState(new Set),Qs=s=>{Ys(i=>{const l=new Set(i);return l.has(s)?l.delete(s):l.add(s),l})},m=x.find(s=>s.id===k)||x[0]||null,L=E.find(s=>s.id===se)||E[0]||null,z=Wt((m==null?void 0:m.id)||T),Xs=u.useDeferredValue(ae),es=Re(T,"image"),Hs=Re(T,"audio"),ss=Re(T,"video"),ts=Re(T,"text"),Js=x.filter(s=>s.enabled),h=v||$<=ni,is=h&&(H>0?H<600:$<600),ze=!!m&&!!m.apiKey.trim(),qs=Oe({profiles:x,presets:E,activePresetId:te,audioModelName:fe,imageModelName:ie,videoModelName:b,textModelName:A,showWorkZoneCard:Z}),as=o.openSettings&&qs!==Gs;u.useEffect(()=>{const s=_e.current;if(!s||typeof ResizeObserver>"u")return;const i=new ResizeObserver(l=>{var c;const a=(c=l[0])==null?void 0:c.contentRect.width;a&&xe(r=>Math.abs(r-a)<1?r:a)});return i.observe(s),()=>{i.disconnect()}},[o.openSettings]);const et=s=>{M(s),h&&(s==="providers"&&ne("catalog"),s==="presets"&&je("catalog"))},st=s=>{U(s),h&&ne("detail")},tt=s=>{G(s),h&&je("detail")},it=()=>{try{return localStorage.getItem(ke.WORKZONE_CARD_VISIBLE)!=="false"}catch{return!0}},Ve=()=>{const s=ge(Pe.get()),i=ge(oe.get()),l=oe.getActivePresetId()||ee,a=Ce.get(),c=it();we(s),Le(Oe({profiles:s,presets:i,activePresetId:l,audioModelName:a.audioModelName||pe(),imageModelName:a.imageModelName||de(),videoModelName:a.videoModelName||re(),textModelName:a.textModelName||ce(),showWorkZoneCard:c}))};u.useEffect(()=>{var f;if(!o.openSettings)return;const s=ge(Pe.get()),i=ge(oe.get()),l=oe.getActivePresetId()||ee,a=Ce.get();let c=!0;const r=xi(),_=(r==null?void 0:r.action)==="select"&&s.some(N=>N.id===r.profileId)?r.profileId:((f=s[0])==null?void 0:f.id)||T;R(s),W(i),we(s),J(l),U(N=>{var w;return r?_:s.some(P=>P.id===N)?N:((w=s[0])==null?void 0:w.id)||T}),G(N=>{var w;return i.some(P=>P.id===N)?N:((w=i[0])==null?void 0:w.id)||ee}),Ie(a.audioModelName||pe()),d(a.imageModelName||de()),y(a.videoModelName||re()),O(a.textModelName||ce());try{c=localStorage.getItem(ke.WORKZONE_CARD_VISIBLE)!=="false"}catch{c=!0}B(c),M("providers"),ne(r&&h?"detail":"catalog"),je("catalog"),he(""),Ae(!1),Le(Oe({profiles:s,presets:i,activePresetId:l,audioModelName:a.audioModelName||pe(),imageModelName:a.imageModelName||de(),videoModelName:a.videoModelName||re(),textModelName:a.textModelName||ce(),showWorkZoneCard:c})),(r==null?void 0:r.action)==="create"&&ls(r,s)},[o.openSettings]),u.useEffect(()=>{if(!k&&x[0]){U(x[0].id);return}k&&x.length>0&&!x.some(s=>s.id===k)&&U(x[0].id)},[x,k]),u.useEffect(()=>{if(!se&&E[0]){G(E[0].id);return}se&&E.length>0&&!E.some(s=>s.id===se)&&G(E[0].id)},[E,se]),u.useEffect(()=>{he("")},[k,K]);const ye=(s,i)=>{R(l=>l.map(a=>a.id===s?i(a):a))},at=(s,i)=>{W(l=>l.map(a=>a.id===s?i(a):a))},ns=async(s,i)=>{var l,a;try{const c=Ce.get(),r=((l=s.find(I=>I.id===i))==null?void 0:l.id)||((a=s[0])==null?void 0:a.id)||ee,_=s.find(I=>I.id===r)||s[0]||null,f=F(_==null?void 0:_.audio)||c.audioModelName||pe(),N=F(_==null?void 0:_.image)||c.imageModelName||de(),w=F(_==null?void 0:_.video)||c.videoModelName||re(),P=F(_==null?void 0:_.text)||c.textModelName||c.chatModel||ce();return await oe.update(ge(s)),await oe.setActivePresetId(r),await Ce.update({audioModelName:f,imageModelName:N,videoModelName:w,textModelName:P,chatModel:P}),W(s),J(r),Ie(f),d(N),y(w),O(P),Ve(),!0}catch(c){return console.error("Failed to persist preset configuration:",c),V.error("预设保存失败,请重试"),!1}},nt=async(s,i)=>{if(R(l=>l.map(a=>a.id===s?{...a,enabled:i}:a)),!!Se.some(l=>l.id===s))try{await Pe.update(ge(Pe.get()).map(l=>l.id===s?{...l,enabled:i}:l)),Ve()}catch(l){console.error("Failed to persist provider enabled state:",l),R(a=>a.map(c=>c.id===s?{...c,enabled:!i}:c)),V.error("供应商状态保存失败,请重试")}},lt=async s=>{B(s);try{localStorage.setItem(ke.WORKZONE_CARD_VISIBLE,String(s)),window.dispatchEvent(new CustomEvent("workzone-visibility-changed")),Ve()}catch(i){console.error("Failed to persist canvas visibility state:",i),B(!s),V.error("画布显示配置保存失败,请重试")}},ls=(s,i)=>{var r;const l=i||x;if(M("providers"),h&&ne("detail"),s.action==="select"){const _=l.some(f=>f.id===s.profileId)?s.profileId:((r=l[l.length-1])==null?void 0:r.id)||T;return U(_),l}const a=Os(l.length+1),c=[...l,a];return R(c),U(a.id),c},os=()=>{const s=Os(x.length+1);R(i=>[...i,s]),U(s.id),M("providers"),h&&ne("detail")};u.useEffect(()=>{if(!o.openSettings)return;const s=i=>{const l=i.detail;l&&ls(l)};return window.addEventListener(Cs,s),()=>{window.removeEventListener(Cs,s)}},[o.openSettings,h,x]);const ds=async s=>{var c;if(Ye(s))return;const i=x.find(r=>r.id===s);if(!await g({title:"确认删除供应商",description:`确定要删除供应商「${(i==null?void 0:i.name)||"未命名供应商"}」吗?相关预设里的路由会被清空。`,confirmText:"删除",cancelText:"取消",danger:!0}))return;const a=x.filter(r=>r.id!==s);R(a),W(r=>r.map(_=>yi(_,s))),k===s&&U(((c=a[0])==null?void 0:c.id)||T),h&&ne("catalog")},rs=u.useCallback(s=>{const i=x.find(a=>a.id===s);if(!i)return;const l={...ge(i),id:Xe("profile"),name:`${i.name} (副本)`};R(a=>[...a,l]),U(l.id),M("providers"),h&&ne("detail")},[x,h]),Ue=At(),ot=u.useCallback(s=>{const i=[{key:"clone",label:"克隆",icon:e.jsx(Tt,{size:14}),onSelect:rs}];return Ye(s)||i.push({key:"divider",type:"divider"},{key:"delete",label:"删除",icon:e.jsx(bs,{size:14}),danger:!0,onSelect:ds}),i},[rs]),cs=()=>{var l;const s=((l=Js[0])==null?void 0:l.id)||null,i=fi(s,{audio:fe||pe(),image:ie||de(),video:b||re(),text:A||ce()});W(a=>[...a,i]),G(i.id),M("presets"),h&&je("detail")},dt=async s=>{var c,r;if(E.length<=1)return;const i=E.find(_=>_.id===s);if(!await g({title:"确认删除预设",description:`确定要删除预设「${(i==null?void 0:i.name)||"未命名预设"}」吗?此操作不可撤销。`,confirmText:"删除",cancelText:"取消",danger:!0}))return;const a=E.filter(_=>_.id!==s);W(a),te===s&&J(((c=a[0])==null?void 0:c.id)||ee),se===s&&G(((r=a[0])==null?void 0:r.id)||ee),h&&je("catalog")},gs=(s,i)=>{if(!L)return;const l=E.map(a=>a.id===L.id?ji(a,s,{defaultModelRef:i}):a);W(l),ns(l,te)},rt=async()=>{if(!m){V.warning("请先选择供应商配置");return}if(as){const l=V.loading("正在保存当前配置...",0),a=await _s(!1);if(V.close(l),!a)return}const s=m.apiKey.trim(),i=We(m.baseUrl.trim()||De);if(!s){V.warning("请先填写 API Key");return}try{await Me.discover(m.id,i,s),Ae(!0)}catch(l){const a=l instanceof Error?l.message:"模型同步失败";Me.setError(m.id,a),V.error({content:a,duration:3600})}},ms=(s,i)=>{var r,_,f;if(!m)return;const l=Me.applySelection(m.id,s),a=l.models;if(m.id===T){const N=a.filter(p=>p.type==="image"),w=a.filter(p=>p.type==="video"),P=a.filter(p=>p.type==="text"),I=z.discoveredModels.filter(p=>p.type==="image").map(p=>p.id),Q=z.discoveredModels.filter(p=>p.type==="video").map(p=>p.id),C=z.discoveredModels.filter(p=>p.type==="text").map(p=>p.id);!N.some(p=>p.id===ie)&&I.includes(ie)&&d(((r=N[0])==null?void 0:r.id)||de()),!w.some(p=>p.id===b)&&Q.includes(b)&&y(((_=w[0])==null?void 0:_.id)||re()),!P.some(p=>p.id===A)&&C.includes(A)&&O(((f=P[0])==null?void 0:f.id)||ce())}const c=(i==null?void 0:i.successMessage)||gi(m.name,l.addedModelIds.length,l.removedModelIds.length,a.length);c&&V.success(c),Ae(!1)},ct=s=>{if(!m)return;if(!z.selectedModelIds.includes(s)){V.warning("该模型不是当前分组动态添加的模型,无法在此移除");return}const i=z.selectedModelIds.filter(l=>l!==s);ms(i)},us=()=>{n(s=>({...s,openSettings:!1}))},_s=async(s=!1)=>{var i,l,a,c,r,_;if(Je)return!1;qe(!0);try{const f=x.map(S=>{var be;const Ne=S.baseUrl.trim()?We(S.baseUrl):"";return{...S,name:S.name.trim()||"未命名供应商",iconUrl:((be=S.iconUrl)==null?void 0:be.trim())||void 0,baseUrl:Ne,apiKey:S.apiKey.trim()}}),N=new Set(f.map(S=>S.id)),w=E.map(S=>{const Ne={...S,name:S.name.trim()||"未命名预设",audio:{...S.audio},image:{...S.image},video:{...S.video},text:{...S.text}};return["image","video","audio","text"].forEach(be=>{const js=Ne[be],Ge=Ee(js),ys=F(js);if(Ge&&!N.has(Ge)){Ne[be]=me(ue(null,ys));return}Ne[be]=me(ue(Ge,ys))}),Ne}),P=((i=w.find(S=>S.id===te))==null?void 0:i.id)||((l=w[0])==null?void 0:l.id)||ee,I=w.find(S=>S.id===P)||w[0]||null,Q=f.find(S=>S.id===T)||f[0],C=We((Q==null?void 0:Q.baseUrl)||De),p=fe.trim()||((a=Hs[0])==null?void 0:a.id)||pe(),q=ie.trim()||((c=es[0])==null?void 0:c.id)||de(),D=b.trim()||((r=ss[0])==null?void 0:r.id)||re(),X=A.trim()||((_=ts[0])==null?void 0:_.id)||ce(),Be=F(I==null?void 0:I.image)||q,le=F(I==null?void 0:I.video)||D,xt=F(I==null?void 0:I.audio)||p,ft=F(I==null?void 0:I.text)||X;f.forEach(S=>{Me.invalidateIfConfigChanged(S.id,S.baseUrl||De,S.apiKey||"")}),await Ce.update({apiKey:(Q==null?void 0:Q.apiKey)||"",baseUrl:C,audioModelName:xt,imageModelName:Be,videoModelName:le,textModelName:ft}),await Pe.update(f),await $t.update(Me.getCatalogs().filter(S=>N.has(S.profileId))),await oe.update(w),await oe.setActivePresetId(P);try{localStorage.setItem(ke.WORKZONE_CARD_VISIBLE,String(Z)),window.dispatchEvent(new CustomEvent("workzone-visibility-changed"))}catch{}return R(f),we(ge(f)),W(w),J(P),Ie(p),d(q),y(D),O(X),Le(Oe({profiles:f,presets:w,activePresetId:P,audioModelName:p,imageModelName:q,videoModelName:D,textModelName:X,showWorkZoneCard:Z})),s&&us(),!0}catch(f){return console.error("Failed to persist settings drafts:",f),V.error("设置保存失败,请稍后重试"),!1}finally{qe(!1)}},gt=()=>{if(!as){us();return}(async()=>{const s=V.loading("正在保存设置...",0),i=await _s(!0);V.close(s),i||V.warning("设置尚未保存,请检查后重试")})()},mt=()=>{He||Je||gt()},hs=()=>e.jsxs("div",{className:"settings-dialog__sidebar-shell settings-dialog__sidebar-shell--catalog",children:[e.jsxs("div",{className:"settings-dialog__sidebar-summary",children:[e.jsxs("div",{className:"settings-dialog__sidebar-summary-row",children:[e.jsx("span",{className:"settings-dialog__sidebar-summary-title",children:"供应商目录"}),h?e.jsx("button",{type:"button",className:"settings-dialog__sidebar-summary-action",onClick:os,children:"新增供应商"}):null]}),h?e.jsx("span",{className:"settings-dialog__sidebar-summary-text",children:"先从列表里选择供应商,再进入对应的配置页面。"}):null]}),e.jsx("div",{className:"settings-dialog__sidebar-list",children:x.map(s=>{const i=s.id===(m==null?void 0:m.id);return e.jsxs("div",{className:`settings-dialog__provider-row ${i?"settings-dialog__provider-row--active":""} ${s.enabled?"":"settings-dialog__provider-row--disabled"}`,onContextMenu:l=>{l.preventDefault(),Ue.open(l,s.id)},children:[e.jsxs("button",{type:"button",className:"settings-dialog__provider-select",onClick:()=>st(s.id),"aria-pressed":i,children:[e.jsxs("span",{className:"settings-dialog__provider-select-main",children:[e.jsx(Ts,{profile:s}),e.jsxs("span",{className:"settings-dialog__provider-copy",children:[e.jsxs("span",{className:"settings-dialog__provider-name-row",children:[e.jsx("span",{className:"settings-dialog__provider-name",children:s.name}),s.id===T?e.jsx("span",{className:"settings-dialog__provider-tag",children:"默认"}):null]}),h?e.jsxs("span",{className:"settings-dialog__provider-meta",children:[e.jsx("span",{children:Ze[s.providerType].label}),e.jsx("span",{children:s.enabled?"启用":"停用"})]}):null]})]}),h?e.jsx(Fe,{size:16,className:"settings-dialog__provider-arrow","aria-hidden":"true"}):null]}),e.jsxs("div",{className:"settings-dialog__provider-switch",children:[e.jsx("span",{className:"settings-dialog__provider-switch-copy",children:s.enabled?"启用":"停用"}),e.jsx(Ms,{size:"small",value:s.enabled,disabled:s.id===T,onChange:l=>void nt(s.id,l)})]})]},s.id)})}),e.jsx(Ut,{state:Ue.contextMenu,items:ot,onClose:Ue.close,zIndex:2e4}),h?null:e.jsxs("button",{type:"button",className:"settings-dialog__sidebar-add",onClick:os,children:[e.jsx("span",{className:"settings-dialog__sidebar-add-icon",children:"+"}),e.jsx("span",{children:"新增供应商"})]})]}),ps=()=>e.jsxs("div",{className:"settings-dialog__sidebar-shell",children:[e.jsxs("div",{className:"settings-dialog__sidebar-summary",children:[e.jsxs("div",{className:"settings-dialog__sidebar-summary-row",children:[e.jsx("span",{className:"settings-dialog__sidebar-summary-title",children:"默认模型"}),h?e.jsx("button",{type:"button",className:"settings-dialog__sidebar-summary-action",onClick:cs,children:"新增预设"}):null]}),h?e.jsx("span",{className:"settings-dialog__sidebar-summary-text",children:"先选中一个预设,再进入详情页调整默认路由。"}):null]}),e.jsx("div",{className:"settings-dialog__sidebar-list",children:E.map(s=>{const i=s.id===(L==null?void 0:L.id),l=s.id===te,a=Ds(s);return e.jsxs("button",{type:"button",className:`settings-dialog__sidebar-item ${i?"settings-dialog__sidebar-item--active":""}`,onClick:()=>tt(s.id),children:[e.jsxs("div",{className:"settings-dialog__sidebar-item-head",children:[e.jsxs("div",{className:"settings-dialog__sidebar-item-top",children:[e.jsx("span",{children:s.name}),l?e.jsx("span",{className:"settings-dialog__sidebar-badge settings-dialog__sidebar-badge--accent",children:"当前"}):null]}),h?e.jsx(Fe,{size:16,className:"settings-dialog__sidebar-item-arrow","aria-hidden":"true"}):null]}),e.jsxs("div",{className:"settings-dialog__sidebar-item-meta",children:[e.jsxs("span",{children:[a,"/3 已配置"]}),h?e.jsx("span",{children:l?"正在生效":"点击查看详情"}):null]})]},s.id)})}),h?null:e.jsxs("button",{type:"button",className:"settings-dialog__sidebar-add",onClick:cs,children:[e.jsx("span",{className:"settings-dialog__sidebar-add-icon",children:"+"}),e.jsx("span",{children:"新增预设"})]})]}),vs=(s,i)=>e.jsx("div",{className:"settings-dialog__workspace settings-dialog__workspace--single",children:e.jsx("div",{className:"settings-dialog__content-panel settings-dialog__content-panel--compact",children:e.jsx("div",{className:"settings-dialog__mobile-stage",children:i},s)})}),xs=(s=!1)=>{if(!m)return e.jsx("div",{className:"settings-dialog__empty-panel",children:"请选择一个供应商。"});const i=ks(z.models),l=Rs(m,Se),a=i.image+i.video+i.text;return e.jsxs("div",{className:`settings-dialog__content-panel settings-dialog__content-panel--providers ${s?"settings-dialog__content-panel--detail":""}`,children:[s?e.jsxs("div",{className:"settings-dialog__compact-stage-header",children:[e.jsxs("button",{type:"button",className:"settings-dialog__compact-back",onClick:()=>ne("catalog"),children:[e.jsx(Ss,{size:16}),e.jsx("span",{children:"返回供应商目录"})]}),e.jsxs("div",{className:"settings-dialog__compact-stage-copy",children:[e.jsx("span",{className:"settings-dialog__compact-stage-eyebrow",children:"供应商配置"}),e.jsx("p",{className:"settings-dialog__compact-stage-text",children:"进入详情后再编辑接口信息、密钥和模型同步配置。"})]})]}):null,e.jsx("div",{className:"settings-dialog__section settings-dialog__section--compact",children:e.jsxs("div",{className:"settings-dialog__panel-header",children:[e.jsxs("div",{className:"settings-dialog__profile-hero",children:[e.jsx(Ts,{profile:m,size:"large"}),e.jsxs("div",{children:[e.jsx("h3",{className:"settings-dialog__section-title",children:m.name}),e.jsxs("div",{className:"settings-dialog__inline-meta",children:[e.jsx("span",{children:Ze[m.providerType].label}),e.jsx("span",{children:m.enabled?"启用":"停用"}),e.jsxs("span",{children:[a," 个模型"]}),e.jsx("span",{children:l==="saved"?"已保存":"未保存"})]})]})]}),Ye(m.id)?null:e.jsx("button",{type:"button",className:"settings-dialog__danger-button",onClick:()=>ds(m.id),children:"删除"})]})}),e.jsxs("div",{className:"settings-dialog__section",children:[e.jsx("div",{className:"settings-dialog__section-header",children:e.jsx("div",{children:e.jsx("h3",{className:"settings-dialog__section-title",children:"基础配置"})})}),e.jsxs("div",{className:"settings-dialog__grid",children:[e.jsxs("div",{className:"settings-dialog__field settings-dialog__field--column",children:[e.jsx("label",{className:"settings-dialog__label settings-dialog__label--stacked",children:"名称"}),e.jsx("input",{type:"text",className:"settings-dialog__input",value:m.name,onChange:c=>ye(m.id,r=>({...r,name:c.target.value}))})]}),e.jsxs("div",{className:"settings-dialog__field settings-dialog__field--column",children:[e.jsx("label",{className:"settings-dialog__label settings-dialog__label--stacked",children:"接口类型"}),e.jsx("select",{className:"settings-dialog__select",value:m.providerType,onChange:c=>ye(m.id,r=>{const _=c.target.value,f=Qe(r.providerType),N=Qe();return{...r,providerType:_,authType:r.authType===f?N:r.authType}}),children:oi.map(c=>e.jsx("option",{value:c,children:Ze[c].label},c))})]}),e.jsxs("div",{className:"settings-dialog__field settings-dialog__field--column settings-dialog__field--full",children:[e.jsx("label",{className:"settings-dialog__label settings-dialog__label--stacked",children:"图标 URL"}),e.jsx("input",{type:"url",className:"settings-dialog__input",value:m.iconUrl||"",onChange:c=>ye(m.id,r=>({...r,iconUrl:c.target.value})),placeholder:"可选,留空时自动生成默认图标"}),e.jsx("span",{className:"settings-dialog__field-hint",children:"支持填写远程图片地址;未填写时将根据供应商名称生成默认图标。"})]}),e.jsxs("div",{className:"settings-dialog__field settings-dialog__field--column settings-dialog__field--full",children:[e.jsx("label",{className:"settings-dialog__label settings-dialog__label--stacked",children:"API 地址"}),e.jsx("input",{type:"text",className:"settings-dialog__input",value:m.baseUrl,onChange:c=>ye(m.id,r=>({...r,baseUrl:c.target.value})),placeholder:De})]}),e.jsxs("div",{className:"settings-dialog__field settings-dialog__field--column settings-dialog__field--full",children:[e.jsxs("div",{className:"settings-dialog__label-with-tooltip settings-dialog__label-with-tooltip--left",children:[e.jsx("label",{className:"settings-dialog__label settings-dialog__label--stacked",children:"API Key"}),e.jsx(ve,{content:e.jsxs("div",{style:{maxWidth:480},children:["您可以从以下地址获取 API Key:",e.jsx("br",{}),e.jsx("a",{href:"https://api.tu-zi.com/token",target:"_blank",rel:"noopener noreferrer",style:{color:"#F39C12",textDecoration:"none",display:"inline-block",marginBottom:8},children:"api.tu-zi.com/token"}),e.jsx("div",{style:{position:"relative",width:"100%",paddingTop:"56.25%",marginTop:8,borderRadius:8,overflow:"hidden",backgroundColor:"#000",boxShadow:"0 4px 16px rgba(0,0,0,0.2)"},children:e.jsx("iframe",{title:"Bilibili tutorial video",src:"//player.bilibili.com/player.html?isOutside=true&aid=116171584049629&bvid=BV1k4PqzPEKz&cid=36455319822&p=1",allowFullScreen:!0,style:{position:"absolute",top:0,left:0,width:"100%",height:"100%",border:0}})})]}),placement:"top",theme:"light",showArrow:!1,overlayStyle:{maxWidth:"none"},children:e.jsx(zt,{className:"settings-dialog__tooltip-icon"})})]}),e.jsxs("div",{style:{display:"flex",gap:"8px",alignItems:"center",width:"100%",flexDirection:h?"column":"row"},children:[e.jsx("input",{type:"password",className:"settings-dialog__input",style:{flex:h?"none":1,width:"100%"},value:m.apiKey,onChange:c=>ye(m.id,r=>({...r,apiKey:c.target.value})),autoComplete:"off"}),e.jsx("button",{type:"button",className:"settings-dialog__button settings-dialog__button--fetch",style:{whiteSpace:"nowrap",height:h?"42px":"32px",width:h?"100%":"auto"},onClick:rt,disabled:!ze||z.status==="loading",children:z.status==="loading"?e.jsxs(e.Fragment,{children:[e.jsx(Vt,{size:15,className:"settings-dialog__button-spinner"}),"同步中"]}):"获取模型"})]})]})]})]}),e.jsx(ai,{profile:m,onUpdateProfile:c=>ye(m.id,c)}),m.id===T?e.jsx("div",{className:"settings-dialog__section settings-dialog__section--compact",children:e.jsxs("div",{className:"settings-dialog__compat-card",children:[e.jsx("div",{className:"settings-dialog__compat-title",children:"兼容默认模型"}),e.jsxs("div",{className:"settings-dialog__compat-meta",children:[e.jsxs("span",{children:["图片:",ie||de()]}),e.jsxs("span",{children:["视频:",b||re()]}),e.jsxs("span",{children:["音频:",fe||pe()]}),e.jsxs("span",{children:["文本:",A||ce()]})]})]})}):null,ut()]},s?`provider-detail-${m.id}`:void 0)},$e=u.useCallback(s=>{s.profileId&&Xt({profileId:s.profileId,modelId:s.modelId,modality:s.modality,compareMode:s.compareMode})},[n]),ut=()=>{const s=m?Rs(m,Se):"saved",i=!!(m!=null&&m.apiKey.trim())&&s==="saved"&&z.status!=="loading",l=(m==null?void 0:m.id)===T,a=_i(z.models),c=new Map($s.map((C,p)=>[C,p])),r=Xs.trim(),_=ks(a),f=a.filter(C=>ui(C,r)),N=mi.map(C=>({type:C,models:f.filter(p=>p.type===C).sort((p,q)=>{const D=c.get(p.vendor)??Number.MAX_SAFE_INTEGER,X=c.get(q.vendor)??Number.MAX_SAFE_INTEGER;return D!==X?D-X:Kt(p,q)})})).filter(C=>C.models.length>0),w=ze||a.length>0,P=a.length>0&&f.length===0&&!!r,I=z.status==="error"&&a.length===0,Q=!ze&&a.length===0;return e.jsxs("div",{className:"settings-dialog__section",children:[e.jsx("div",{className:"settings-dialog__section-header",children:e.jsxs("div",{children:[e.jsx("h3",{className:"settings-dialog__section-title",children:"模型"}),e.jsxs("div",{className:"settings-dialog__inline-meta",children:[e.jsxs("span",{children:["已添加 ",a.length," 个"]}),e.jsxs("span",{children:["图 ",_.image]}),e.jsxs("span",{children:["视 ",_.video]}),e.jsxs("span",{children:["音 ",_.audio]}),e.jsxs("span",{children:["文 ",_.text]})]})]})}),w?e.jsx("div",{className:"settings-dialog__model-toolbar",children:e.jsxs("label",{className:`settings-dialog__model-search ${a.length===0?"settings-dialog__model-search--disabled":""}`,children:[e.jsx(zs,{size:15}),e.jsx("input",{type:"text",value:ae,onChange:C=>he(C.target.value),placeholder:a.length>0?"搜索模型 ID、名称或品牌":"获取模型后可搜索",disabled:a.length===0}),ae?e.jsx("button",{type:"button",className:"settings-dialog__model-search-clear",onClick:()=>he(""),"aria-label":"清空搜索",children:e.jsx(Ls,{size:14})}):null]})}):null,N.length>0?e.jsx("div",{className:"settings-dialog__model-type-groups",children:N.map(({type:C,models:p})=>{const q=Zs.has(C);return e.jsxs("div",{className:"settings-dialog__model-type-group",children:[e.jsxs("div",{className:"settings-dialog__model-type-header",style:{cursor:"pointer"},onClick:()=>Qs(C),children:[e.jsxs("div",{className:"settings-dialog__model-type-meta",children:[q?e.jsx(Fe,{size:16,className:"settings-dialog__model-type-toggle"}):e.jsx(Vs,{size:16,className:"settings-dialog__model-type-toggle"}),e.jsx("span",{className:"settings-dialog__model-type-title",children:di[C]}),e.jsx("span",{className:"settings-dialog__model-type-count",children:p.length})]}),e.jsx("button",{type:"button",className:"settings-dialog__model-group-test",onClick:D=>{D.stopPropagation(),m&&$e({profileId:m.id,modality:C,compareMode:"cross-model"})},disabled:!i,title:i?"测试当前供应商这一组模型":"请先保存供应商配置并确保 API Key 可用",children:"测试本组"})]}),!q&&e.jsx("div",{className:"settings-dialog__model-type-list",children:p.map(D=>{const X=Ks(D.vendor),Be=!l||z.selectedModelIds.includes(D.id);return e.jsxs("div",{className:"settings-dialog__model-type-item",style:{"--model-brand-accent":X.accent,"--model-brand-surface":X.surface,"--model-brand-border":X.border},children:[e.jsx("span",{className:"settings-dialog__model-type-item-logo",children:e.jsx(Bs,{vendor:D.vendor,size:16})}),e.jsxs("div",{className:"settings-dialog__model-type-item-copy",children:[e.jsx(ci,{profileId:m.id,modelId:D.id}),e.jsx("span",{className:"settings-dialog__model-type-item-vendor",children:Te(D.vendor)}),e.jsx(ri,{profileId:m.id,modelId:D.id})]}),e.jsxs("div",{className:"settings-dialog__model-type-item-btns",children:[(()=>{const le=Ht.getLatestEntryStatus(m.id,D.id);return le==="completed"?e.jsx(ve,{content:"上次测试成功",showArrow:!1,children:e.jsx("span",{className:"settings-dialog__model-tip-trigger",children:e.jsx("span",{className:"settings-dialog__model-status settings-dialog__model-status--ok"})})}):le==="failed"?e.jsx(ve,{content:"上次测试失败",showArrow:!1,children:e.jsx("span",{className:"settings-dialog__model-tip-trigger",children:e.jsx("span",{className:"settings-dialog__model-status settings-dialog__model-status--fail"})})}):null})(),e.jsx(ve,{content:i?"测试":"请先保存供应商配置并确保 API Key 可用",showArrow:!1,children:e.jsx("span",{className:"settings-dialog__model-tip-trigger",children:e.jsx("button",{type:"button",className:"settings-dialog__model-icon-btn settings-dialog__model-icon-btn--test",onClick:le=>{le.stopPropagation(),m&&$e({profileId:m.id,modality:C,modelId:D.id,compareMode:"cross-provider"})},disabled:!i,children:e.jsx(Us,{size:14})})})}),Be?e.jsx(ve,{content:"移除此模型",showArrow:!1,children:e.jsx("span",{className:"settings-dialog__model-tip-trigger",children:e.jsx("button",{type:"button",className:"settings-dialog__model-icon-btn settings-dialog__model-icon-btn--delete",onClick:le=>{le.stopPropagation(),ct(D.id)},children:e.jsx(bs,{size:14})})})}):null]})]},D.id)})})]},C)})}):P?e.jsx("div",{className:"settings-dialog__model-empty",children:"没有匹配的模型,试试搜索品牌名或更完整的模型 ID。"}):I?e.jsxs("div",{className:"settings-dialog__model-empty settings-dialog__model-empty--error",children:[e.jsx(Bt,{size:16}),e.jsx("span",{children:z.error||"模型获取失败,请稍后重试"})]}):Q?e.jsx("div",{className:"settings-dialog__model-empty",children:"填写 API Key 后即可获取模型,获取完成后可在这里检索和浏览。"}):e.jsx("div",{className:"settings-dialog__model-empty",children:"还没有已添加的模型"})]})},_t=(s,i,l)=>{const a=Ee(l),c=F(l);return x.filter(r=>r.id===a||r.enabled&&r.capabilities[i]).map(r=>{const f=(r.id===T?s==="image"?es:s==="video"?ss:ts:Me.getState(r.id).models.filter(N=>N.type===s)).filter((N,w,P)=>P.findIndex(I=>I.id===N.id)===w);return r.id===a&&c&&!f.some(N=>N.id===c)&&f.unshift({id:c,label:c,shortLabel:c,type:s,vendor:Gt.OTHER}),{profile:r,models:f}}).filter(r=>r.models.length>0)},Ke=(s,i,l)=>{var w;const a=_t(s,l,i),c=Ee(i),r=F(i),_=((w=x.find(P=>P.id===c))==null?void 0:w.name)||"未配置",f=bi(a),N=c&&r?`${c}::${r}`:r||void 0;return e.jsxs("div",{className:`settings-dialog__route-card settings-dialog__route-card--${s}`,children:[e.jsx("div",{className:"settings-dialog__route-card-top",children:e.jsx("div",{className:"settings-dialog__route-card-title",children:Es[s]})}),e.jsxs("div",{className:"settings-dialog__stack",children:[e.jsxs("div",{className:"settings-dialog__field settings-dialog__field--column",children:[e.jsx("label",{className:"settings-dialog__label settings-dialog__label--stacked",children:"默认模型"}),e.jsxs("div",{className:"settings-dialog__route-model-picker",children:[e.jsx(Qt,{variant:"form",selectedModel:r||"",selectedSelectionKey:N,models:f,providerProfilesOverride:x,placement:"down",placeholder:`搜索${Es[s]}模型或供应商`,allowCustomValue:!1,showProviderAction:!1,onSelect:(P,I)=>{gs(s,I||ue(null,P))},disabled:f.length===0}),r?e.jsx("button",{type:"button",className:"settings-dialog__route-clear",onClick:()=>gs(s,null),children:"清空"}):null]})]}),e.jsxs("div",{className:"settings-dialog__route-meta",children:[e.jsx("span",{children:_}),e.jsx("span",{children:r||"未选择模型"}),a.length===0?e.jsx("span",{children:"暂无可选模型"}):null]})]})]})},fs=(s=!1)=>{if(!L)return e.jsx("div",{className:"settings-dialog__empty-panel",children:"请选择一个默认模型预设。"});const i=Ds(L),l=L.id===te;return e.jsxs("div",{className:`settings-dialog__content-panel ${s?"settings-dialog__content-panel--detail":""}`,children:[s?e.jsxs("div",{className:"settings-dialog__compact-stage-header",children:[e.jsxs("button",{type:"button",className:"settings-dialog__compact-back",onClick:()=>je("catalog"),children:[e.jsx(Ss,{size:16}),e.jsx("span",{children:"返回模型预设"})]}),e.jsxs("div",{className:"settings-dialog__compact-stage-copy",children:[e.jsx("span",{className:"settings-dialog__compact-stage-eyebrow",children:"模型预设"}),e.jsx("p",{className:"settings-dialog__compact-stage-text",children:"在这里设置图片、视频和文本模型的默认路由。"})]})]}):null,e.jsxs("div",{className:"settings-dialog__section",children:[e.jsxs("div",{className:"settings-dialog__panel-header",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"settings-dialog__section-title",children:L.name}),e.jsxs("div",{className:"settings-dialog__inline-meta",children:[e.jsx("span",{children:l?"当前预设":"未激活"}),e.jsxs("span",{children:[i,"/3 已配置"]})]})]}),e.jsxs("div",{className:"settings-dialog__inline-row",children:[e.jsx("button",{type:"button",className:"settings-dialog__ghost-button",onClick:()=>{ns(E,L.id)},children:"设为当前预设"}),e.jsx("button",{type:"button",className:"settings-dialog__danger-button",onClick:()=>dt(L.id),disabled:E.length<=1,children:"删除预设"})]})]}),e.jsx("div",{className:"settings-dialog__grid",children:e.jsxs("div",{className:"settings-dialog__field settings-dialog__field--column settings-dialog__field--full",children:[e.jsx("label",{className:"settings-dialog__label settings-dialog__label--stacked",children:"预设名称"}),e.jsx("input",{type:"text",className:"settings-dialog__input",value:L.name,onChange:a=>at(L.id,c=>({...c,name:a.target.value}))})]})})]}),e.jsxs("div",{className:"settings-dialog__routes",children:[Ke("image",L.image,"supportsImage"),Ke("video",L.video,"supportsVideo"),Ke("text",L.text,"supportsText")]})]},s?`preset-detail-${L.id}`:void 0)},ht=()=>e.jsx("div",{className:"settings-dialog__workspace settings-dialog__workspace--single",children:e.jsxs("div",{className:"settings-dialog__content-panel settings-dialog__content-panel--canvas",children:[h?e.jsx("div",{className:"settings-dialog__compact-stage-header",children:e.jsxs("div",{className:"settings-dialog__compact-stage-copy",children:[e.jsx("span",{className:"settings-dialog__compact-stage-eyebrow",children:"画布显示"}),e.jsx("p",{className:"settings-dialog__compact-stage-text",children:"手机上会以更集中的卡片形式展示,方便快速切换画布相关开关。"})]})}):null,e.jsxs("div",{className:"settings-dialog__section settings-dialog__section--canvas-card",children:[e.jsx("div",{className:"settings-dialog__section-header",children:e.jsx("div",{children:e.jsx("h3",{className:"settings-dialog__section-title",children:"画布显示配置"})})}),e.jsxs("div",{className:"settings-dialog__preference settings-dialog__preference--panel",children:[e.jsxs("div",{className:"settings-dialog__toggle-copy",children:[e.jsx("span",{className:"settings-dialog__toggle-title",children:"任务进度卡片"}),e.jsx("span",{className:"settings-dialog__toggle-desc",children:"在画布中显示任务进度卡片,便于追踪当前生成状态。"})]}),e.jsx(Ms,{size:"small",value:Z,onChange:s=>void lt(s)})]})]})]})}),pt=()=>e.jsx("aside",{className:"settings-dialog__nav",children:e.jsx("div",{className:"settings-dialog__nav-shell",children:e.jsx("div",{className:"settings-dialog__nav-list",children:li.map(s=>e.jsx("button",{type:"button",className:`settings-dialog__nav-item ${K===s.value?"settings-dialog__nav-item--active":""}`,onClick:()=>et(s.value),children:e.jsx("span",{className:"settings-dialog__nav-item-title",children:s.label})},s.value))})})}),vt=()=>K==="canvas"?ht():K==="speech"?e.jsx(Lt,{}):K==="presets"?is?Ws==="catalog"?vs("presets-catalog",ps()):fs(!0):e.jsxs("div",{className:`settings-dialog__workspace ${h?"settings-dialog__workspace--show-sidebar":""}`,children:[e.jsx("aside",{className:"settings-dialog__sidebar",children:ps()}),fs(!1)]}):is?Fs==="catalog"?vs("providers-catalog",hs()):xs(!0):e.jsxs("div",{className:`settings-dialog__workspace ${h?"settings-dialog__workspace--show-sidebar":""}`,children:[e.jsx("aside",{className:"settings-dialog__sidebar",children:hs()}),xs(!1)]});return e.jsxs(e.Fragment,{children:[e.jsx(kt,{id:"settings-dialog",visible:o.openSettings,title:"设置",onClose:mt,width:h?"100%":"88%",height:h?"100%":"88%",minWidth:h?Math.max(320,Math.min($-16,640)):1080,minHeight:h?Math.max(520,Math.min(Y-16,820)):680,x:"center",y:"center",maximizable:!0,minimizable:!1,resizable:!h,movable:!h,modal:!1,className:"winbox-ai-generation winbox-tool-window winbox-settings-window",container:t,background:"#ffffff",children:e.jsx("div",{ref:_e,className:`settings-dialog ${h?"settings-dialog--compact":""}`,"data-testid":"settings-dialog",children:e.jsxs("div",{className:"settings-dialog__layout",children:[pt(),e.jsx("div",{className:"settings-dialog__main",children:vt()})]})})}),e.jsx(ii,{open:He,container:t,models:z.discoveredModels,selectedModelIds:z.selectedModelIds,onClose:()=>Ae(!1),onConfirm:ms,onTestModel:s=>{if(!m)return;const i=z.discoveredModels.find(l=>l.id===s);$e({profileId:m.id,modelId:s,modality:(i==null?void 0:i.type)||"image",compareMode:"cross-provider"})}}),j]})};export{ki as IMAGE_MODEL_GROUPED_OPTIONS,Ci as SettingsDialog,Di as VIDEO_MODEL_OPTIONS};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{hK as h}from"./tool-windows-
|
|
1
|
+
import{hK as h}from"./tool-windows-C4D0lII2.js";const o="system",A="external",M="auto",R="__external_skill__:",y=[{id:"generate_inspiration_board",name:"灵感图",mcpTool:"generate_inspiration_board",description:`灵感图
|
|
2
2
|
|
|
3
3
|
生成创意灵感拼贴图,将多张图片以不规则分割的方式拼合,以散落的横向布局插入画布,营造富有创意感的视觉效果。
|
|
4
4
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{s as P,d as N,p as W}from"./styles-6aaf32cf-D_xcN1dm.js";import{g as t,d as H,l as b,e as R,k as T,an as v,A as U}from"./mermaid.core-N7WwfYcf.js";import{G as C}from"./graph-CVdXivUk.js";import{l as F}from"./layout-DGJFFi9s.js";import{l as $}from"./line-CpXi5g86.js";import"./tool-windows-hjm6YiPY.js";import"./array-B5oSNiGi.js";import"./path-CY0bYimO.js";const O=e=>e.append("circle").attr("class","start-state").attr("r",t().state.sizeUnit).attr("cx",t().state.padding+t().state.sizeUnit).attr("cy",t().state.padding+t().state.sizeUnit),X=e=>e.append("line").style("stroke","grey").style("stroke-dasharray","3").attr("x1",t().state.textHeight).attr("class","divider").attr("x2",t().state.textHeight*2).attr("y1",0).attr("y2",0),J=(e,i)=>{const o=e.append("text").attr("x",2*t().state.padding).attr("y",t().state.textHeight+2*t().state.padding).attr("font-size",t().state.fontSize).attr("class","state-title").text(i.id),c=o.node().getBBox();return e.insert("rect",":first-child").attr("x",t().state.padding).attr("y",t().state.padding).attr("width",c.width+2*t().state.padding).attr("height",c.height+2*t().state.padding).attr("rx",t().state.radius),o},Y=(e,i)=>{const o=function(l,m,w){const E=l.append("tspan").attr("x",2*t().state.padding).text(m);w||E.attr("dy",t().state.textHeight)},s=e.append("text").attr("x",2*t().state.padding).attr("y",t().state.textHeight+1.3*t().state.padding).attr("font-size",t().state.fontSize).attr("class","state-title").text(i.descriptions[0]).node().getBBox(),g=s.height,p=e.append("text").attr("x",t().state.padding).attr("y",g+t().state.padding*.4+t().state.dividerMargin+t().state.textHeight).attr("class","state-description");let a=!0,r=!0;i.descriptions.forEach(function(l){a||(o(p,l,r),r=!1),a=!1});const y=e.append("line").attr("x1",t().state.padding).attr("y1",t().state.padding+g+t().state.dividerMargin/2).attr("y2",t().state.padding+g+t().state.dividerMargin/2).attr("class","descr-divider"),x=p.node().getBBox(),d=Math.max(x.width,s.width);return y.attr("x2",d+3*t().state.padding),e.insert("rect",":first-child").attr("x",t().state.padding).attr("y",t().state.padding).attr("width",d+2*t().state.padding).attr("height",x.height+g+2*t().state.padding).attr("rx",t().state.radius),e},I=(e,i,o)=>{const c=t().state.padding,s=2*t().state.padding,g=e.node().getBBox(),p=g.width,a=g.x,r=e.append("text").attr("x",0).attr("y",t().state.titleShift).attr("font-size",t().state.fontSize).attr("class","state-title").text(i.id),x=r.node().getBBox().width+s;let d=Math.max(x,p);d===p&&(d=d+s);let l;const m=e.node().getBBox();i.doc,l=a-c,x>p&&(l=(p-d)/2+c),Math.abs(a-m.x)<c&&x>p&&(l=a-(x-p)/2);const w=1-t().state.textHeight;return e.insert("rect",":first-child").attr("x",l).attr("y",w).attr("class",o?"alt-composit":"composit").attr("width",d).attr("height",m.height+t().state.textHeight+t().state.titleShift+1).attr("rx","0"),r.attr("x",l+c),x<=p&&r.attr("x",a+(d-s)/2-x/2+c),e.insert("rect",":first-child").attr("x",l).attr("y",t().state.titleShift-t().state.textHeight-t().state.padding).attr("width",d).attr("height",t().state.textHeight*3).attr("rx",t().state.radius),e.insert("rect",":first-child").attr("x",l).attr("y",t().state.titleShift-t().state.textHeight-t().state.padding).attr("width",d).attr("height",m.height+3+2*t().state.textHeight).attr("rx",t().state.radius),e},_=e=>(e.append("circle").attr("class","end-state-outer").attr("r",t().state.sizeUnit+t().state.miniPadding).attr("cx",t().state.padding+t().state.sizeUnit+t().state.miniPadding).attr("cy",t().state.padding+t().state.sizeUnit+t().state.miniPadding),e.append("circle").attr("class","end-state-inner").attr("r",t().state.sizeUnit).attr("cx",t().state.padding+t().state.sizeUnit+2).attr("cy",t().state.padding+t().state.sizeUnit+2)),q=(e,i)=>{let o=t().state.forkWidth,c=t().state.forkHeight;if(i.parentId){let s=o;o=c,c=s}return e.append("rect").style("stroke","black").style("fill","black").attr("width",o).attr("height",c).attr("x",t().state.padding).attr("y",t().state.padding)},Z=(e,i,o,c)=>{let s=0;const g=c.append("text");g.style("text-anchor","start"),g.attr("class","noteText");let p=e.replace(/\r\n/g,"<br/>");p=p.replace(/\n/g,"<br/>");const a=p.split(T.lineBreakRegex);let r=1.25*t().state.noteMargin;for(const y of a){const x=y.trim();if(x.length>0){const d=g.append("tspan");if(d.text(x),r===0){const l=d.node().getBBox();r+=l.height}s+=r,d.attr("x",i+t().state.noteMargin),d.attr("y",o+s+1.25*t().state.noteMargin)}}return{textWidth:g.node().getBBox().width,textHeight:s}},K=(e,i)=>{i.attr("class","state-note");const o=i.append("rect").attr("x",0).attr("y",t().state.padding),c=i.append("g"),{textWidth:s,textHeight:g}=Z(e,0,0,c);return o.attr("height",g+2*t().state.noteMargin),o.attr("width",s+t().state.noteMargin*2),o},L=function(e,i){const o=i.id,c={id:o,label:i.id,width:0,height:0},s=e.append("g").attr("id",o).attr("class","stateGroup");i.type==="start"&&O(s),i.type==="end"&&_(s),(i.type==="fork"||i.type==="join")&&q(s,i),i.type==="note"&&K(i.note.text,s),i.type==="divider"&&X(s),i.type==="default"&&i.descriptions.length===0&&J(s,i),i.type==="default"&&i.descriptions.length>0&&Y(s,i);const g=s.node().getBBox();return c.width=g.width+2*t().state.padding,c.height=g.height+2*t().state.padding,c};let A=0;const Q=function(e,i,o){const c=function(r){switch(r){case N.relationType.AGGREGATION:return"aggregation";case N.relationType.EXTENSION:return"extension";case N.relationType.COMPOSITION:return"composition";case N.relationType.DEPENDENCY:return"dependency"}};i.points=i.points.filter(r=>!Number.isNaN(r.y));const s=i.points,g=$().x(function(r){return r.x}).y(function(r){return r.y}).curve(v),p=e.append("path").attr("d",g(s)).attr("id","edge"+A).attr("class","transition");let a="";if(t().state.arrowMarkerAbsolute&&(a=window.location.protocol+"//"+window.location.host+window.location.pathname+window.location.search,a=a.replace(/\(/g,"\\("),a=a.replace(/\)/g,"\\)")),p.attr("marker-end","url("+a+"#"+c(N.relationType.DEPENDENCY)+"End)"),o.title!==void 0){const r=e.append("g").attr("class","stateLabel"),{x:y,y:x}=U.calcLabelPosition(i.points),d=T.getRows(o.title);let l=0;const m=[];let w=0,E=0;for(let u=0;u<=d.length;u++){const h=r.append("text").attr("text-anchor","middle").text(d[u]).attr("x",y).attr("y",x+l),f=h.node().getBBox();w=Math.max(w,f.width),E=Math.min(E,f.x),b.info(f.x,y,x+l),l===0&&(l=h.node().getBBox().height,b.info("Title height",l,x)),m.push(h)}let k=l*d.length;if(d.length>1){const u=(d.length-1)*l*.5;m.forEach((h,f)=>h.attr("y",x+f*l-u)),k=l*d.length}const n=r.node().getBBox();r.insert("rect",":first-child").attr("class","box").attr("x",y-w/2-t().state.padding/2).attr("y",x-k/2-t().state.padding/2-3.5).attr("width",w+t().state.padding).attr("height",k+t().state.padding),b.info(n)}A++};let B;const z={},V=function(){},j=function(e){e.append("defs").append("marker").attr("id","dependencyEnd").attr("refX",19).attr("refY",7).attr("markerWidth",20).attr("markerHeight",28).attr("orient","auto").append("path").attr("d","M 19,7 L9,13 L14,7 L9,1 Z")},D=function(e,i,o,c){B=t().state;const s=t().securityLevel;let g;s==="sandbox"&&(g=H("#i"+i));const p=s==="sandbox"?H(g.nodes()[0].contentDocument.body):H("body"),a=s==="sandbox"?g.nodes()[0].contentDocument:document;b.debug("Rendering diagram "+e);const r=p.select(`[id='${i}']`);j(r);const y=c.db.getRootDoc();G(y,r,void 0,!1,p,a,c);const x=B.padding,d=r.node().getBBox(),l=d.width+x*2,m=d.height+x*2,w=l*1.75;R(r,m,w,B.useMaxWidth),r.attr("viewBox",`${d.x-B.padding} ${d.y-B.padding} `+l+" "+m)},tt=e=>e?e.length*B.fontSizeFactor:1,G=(e,i,o,c,s,g,p)=>{const a=new C({compound:!0,multigraph:!0});let r,y=!0;for(r=0;r<e.length;r++)if(e[r].stmt==="relation"){y=!1;break}o?a.setGraph({rankdir:"LR",multigraph:!0,compound:!0,ranker:"tight-tree",ranksep:y?1:B.edgeLengthFactor,nodeSep:y?1:50,isMultiGraph:!0}):a.setGraph({rankdir:"TB",multigraph:!0,compound:!0,ranksep:y?1:B.edgeLengthFactor,nodeSep:y?1:50,ranker:"tight-tree",isMultiGraph:!0}),a.setDefaultEdgeLabel(function(){return{}}),p.db.extract(e);const x=p.db.getStates(),d=p.db.getRelations(),l=Object.keys(x);for(const n of l){const u=x[n];o&&(u.parentId=o);let h;if(u.doc){let f=i.append("g").attr("id",u.id).attr("class","stateGroup");h=G(u.doc,f,u.id,!c,s,g,p);{f=I(f,u,c);let S=f.node().getBBox();h.width=S.width,h.height=S.height+B.padding/2,z[u.id]={y:B.compositTitleSize}}}else h=L(i,u);if(u.note){const f={descriptions:[],id:u.id+"-note",note:u.note,type:"note"},S=L(i,f);u.note.position==="left of"?(a.setNode(h.id+"-note",S),a.setNode(h.id,h)):(a.setNode(h.id,h),a.setNode(h.id+"-note",S)),a.setParent(h.id,h.id+"-group"),a.setParent(h.id+"-note",h.id+"-group")}else a.setNode(h.id,h)}b.debug("Count=",a.nodeCount(),a);let m=0;d.forEach(function(n){m++,b.debug("Setting edge",n),a.setEdge(n.id1,n.id2,{relation:n,width:tt(n.title),height:B.labelHeight*T.getRows(n.title).length,labelpos:"c"},"id"+m)}),F(a),b.debug("Graph after layout",a.nodes());const w=i.node();a.nodes().forEach(function(n){n!==void 0&&a.node(n)!==void 0?(b.warn("Node "+n+": "+JSON.stringify(a.node(n))),s.select("#"+w.id+" #"+n).attr("transform","translate("+(a.node(n).x-a.node(n).width/2)+","+(a.node(n).y+(z[n]?z[n].y:0)-a.node(n).height/2)+" )"),s.select("#"+w.id+" #"+n).attr("data-x-shift",a.node(n).x-a.node(n).width/2),g.querySelectorAll("#"+w.id+" #"+n+" .divider").forEach(h=>{const f=h.parentElement;let S=0,M=0;f&&(f.parentElement&&(S=f.parentElement.getBBox().width),M=parseInt(f.getAttribute("data-x-shift"),10),Number.isNaN(M)&&(M=0)),h.setAttribute("x1",0-M+8),h.setAttribute("x2",S-M-8)})):b.debug("No Node "+n+": "+JSON.stringify(a.node(n)))});let E=w.getBBox();a.edges().forEach(function(n){n!==void 0&&a.edge(n)!==void 0&&(b.debug("Edge "+n.v+" -> "+n.w+": "+JSON.stringify(a.edge(n))),Q(i,a.edge(n),a.edge(n).relation))}),E=w.getBBox();const k={id:o||"root",label:o||"root",width:0,height:0};return k.width=E.width+2*B.padding,k.height=E.height+2*B.padding,b.debug("Doc rendered",k,a),k},et={setConf:V,draw:D},lt={parser:W,db:N,renderer:et,styles:P,init:e=>{e.state||(e.state={}),e.state.arrowMarkerAbsolute=e.arrowMarkerAbsolute,N.clear()}};export{lt as diagram};
|
|
1
|
+
import{s as P,d as N,p as W}from"./styles-6aaf32cf-BlD8JxQr.js";import{g as t,d as H,l as b,e as R,k as T,an as v,A as U}from"./mermaid.core-BGyfnsLl.js";import{G as C}from"./graph-Bq1HvHkL.js";import{l as F}from"./layout-SoDWNnQD.js";import{l as $}from"./line-CFFXuH78.js";import"./tool-windows-C4D0lII2.js";import"./array-B5oSNiGi.js";import"./path-CY0bYimO.js";const O=e=>e.append("circle").attr("class","start-state").attr("r",t().state.sizeUnit).attr("cx",t().state.padding+t().state.sizeUnit).attr("cy",t().state.padding+t().state.sizeUnit),X=e=>e.append("line").style("stroke","grey").style("stroke-dasharray","3").attr("x1",t().state.textHeight).attr("class","divider").attr("x2",t().state.textHeight*2).attr("y1",0).attr("y2",0),J=(e,i)=>{const o=e.append("text").attr("x",2*t().state.padding).attr("y",t().state.textHeight+2*t().state.padding).attr("font-size",t().state.fontSize).attr("class","state-title").text(i.id),c=o.node().getBBox();return e.insert("rect",":first-child").attr("x",t().state.padding).attr("y",t().state.padding).attr("width",c.width+2*t().state.padding).attr("height",c.height+2*t().state.padding).attr("rx",t().state.radius),o},Y=(e,i)=>{const o=function(l,m,w){const E=l.append("tspan").attr("x",2*t().state.padding).text(m);w||E.attr("dy",t().state.textHeight)},s=e.append("text").attr("x",2*t().state.padding).attr("y",t().state.textHeight+1.3*t().state.padding).attr("font-size",t().state.fontSize).attr("class","state-title").text(i.descriptions[0]).node().getBBox(),g=s.height,p=e.append("text").attr("x",t().state.padding).attr("y",g+t().state.padding*.4+t().state.dividerMargin+t().state.textHeight).attr("class","state-description");let a=!0,r=!0;i.descriptions.forEach(function(l){a||(o(p,l,r),r=!1),a=!1});const y=e.append("line").attr("x1",t().state.padding).attr("y1",t().state.padding+g+t().state.dividerMargin/2).attr("y2",t().state.padding+g+t().state.dividerMargin/2).attr("class","descr-divider"),x=p.node().getBBox(),d=Math.max(x.width,s.width);return y.attr("x2",d+3*t().state.padding),e.insert("rect",":first-child").attr("x",t().state.padding).attr("y",t().state.padding).attr("width",d+2*t().state.padding).attr("height",x.height+g+2*t().state.padding).attr("rx",t().state.radius),e},I=(e,i,o)=>{const c=t().state.padding,s=2*t().state.padding,g=e.node().getBBox(),p=g.width,a=g.x,r=e.append("text").attr("x",0).attr("y",t().state.titleShift).attr("font-size",t().state.fontSize).attr("class","state-title").text(i.id),x=r.node().getBBox().width+s;let d=Math.max(x,p);d===p&&(d=d+s);let l;const m=e.node().getBBox();i.doc,l=a-c,x>p&&(l=(p-d)/2+c),Math.abs(a-m.x)<c&&x>p&&(l=a-(x-p)/2);const w=1-t().state.textHeight;return e.insert("rect",":first-child").attr("x",l).attr("y",w).attr("class",o?"alt-composit":"composit").attr("width",d).attr("height",m.height+t().state.textHeight+t().state.titleShift+1).attr("rx","0"),r.attr("x",l+c),x<=p&&r.attr("x",a+(d-s)/2-x/2+c),e.insert("rect",":first-child").attr("x",l).attr("y",t().state.titleShift-t().state.textHeight-t().state.padding).attr("width",d).attr("height",t().state.textHeight*3).attr("rx",t().state.radius),e.insert("rect",":first-child").attr("x",l).attr("y",t().state.titleShift-t().state.textHeight-t().state.padding).attr("width",d).attr("height",m.height+3+2*t().state.textHeight).attr("rx",t().state.radius),e},_=e=>(e.append("circle").attr("class","end-state-outer").attr("r",t().state.sizeUnit+t().state.miniPadding).attr("cx",t().state.padding+t().state.sizeUnit+t().state.miniPadding).attr("cy",t().state.padding+t().state.sizeUnit+t().state.miniPadding),e.append("circle").attr("class","end-state-inner").attr("r",t().state.sizeUnit).attr("cx",t().state.padding+t().state.sizeUnit+2).attr("cy",t().state.padding+t().state.sizeUnit+2)),q=(e,i)=>{let o=t().state.forkWidth,c=t().state.forkHeight;if(i.parentId){let s=o;o=c,c=s}return e.append("rect").style("stroke","black").style("fill","black").attr("width",o).attr("height",c).attr("x",t().state.padding).attr("y",t().state.padding)},Z=(e,i,o,c)=>{let s=0;const g=c.append("text");g.style("text-anchor","start"),g.attr("class","noteText");let p=e.replace(/\r\n/g,"<br/>");p=p.replace(/\n/g,"<br/>");const a=p.split(T.lineBreakRegex);let r=1.25*t().state.noteMargin;for(const y of a){const x=y.trim();if(x.length>0){const d=g.append("tspan");if(d.text(x),r===0){const l=d.node().getBBox();r+=l.height}s+=r,d.attr("x",i+t().state.noteMargin),d.attr("y",o+s+1.25*t().state.noteMargin)}}return{textWidth:g.node().getBBox().width,textHeight:s}},K=(e,i)=>{i.attr("class","state-note");const o=i.append("rect").attr("x",0).attr("y",t().state.padding),c=i.append("g"),{textWidth:s,textHeight:g}=Z(e,0,0,c);return o.attr("height",g+2*t().state.noteMargin),o.attr("width",s+t().state.noteMargin*2),o},L=function(e,i){const o=i.id,c={id:o,label:i.id,width:0,height:0},s=e.append("g").attr("id",o).attr("class","stateGroup");i.type==="start"&&O(s),i.type==="end"&&_(s),(i.type==="fork"||i.type==="join")&&q(s,i),i.type==="note"&&K(i.note.text,s),i.type==="divider"&&X(s),i.type==="default"&&i.descriptions.length===0&&J(s,i),i.type==="default"&&i.descriptions.length>0&&Y(s,i);const g=s.node().getBBox();return c.width=g.width+2*t().state.padding,c.height=g.height+2*t().state.padding,c};let A=0;const Q=function(e,i,o){const c=function(r){switch(r){case N.relationType.AGGREGATION:return"aggregation";case N.relationType.EXTENSION:return"extension";case N.relationType.COMPOSITION:return"composition";case N.relationType.DEPENDENCY:return"dependency"}};i.points=i.points.filter(r=>!Number.isNaN(r.y));const s=i.points,g=$().x(function(r){return r.x}).y(function(r){return r.y}).curve(v),p=e.append("path").attr("d",g(s)).attr("id","edge"+A).attr("class","transition");let a="";if(t().state.arrowMarkerAbsolute&&(a=window.location.protocol+"//"+window.location.host+window.location.pathname+window.location.search,a=a.replace(/\(/g,"\\("),a=a.replace(/\)/g,"\\)")),p.attr("marker-end","url("+a+"#"+c(N.relationType.DEPENDENCY)+"End)"),o.title!==void 0){const r=e.append("g").attr("class","stateLabel"),{x:y,y:x}=U.calcLabelPosition(i.points),d=T.getRows(o.title);let l=0;const m=[];let w=0,E=0;for(let u=0;u<=d.length;u++){const h=r.append("text").attr("text-anchor","middle").text(d[u]).attr("x",y).attr("y",x+l),f=h.node().getBBox();w=Math.max(w,f.width),E=Math.min(E,f.x),b.info(f.x,y,x+l),l===0&&(l=h.node().getBBox().height,b.info("Title height",l,x)),m.push(h)}let k=l*d.length;if(d.length>1){const u=(d.length-1)*l*.5;m.forEach((h,f)=>h.attr("y",x+f*l-u)),k=l*d.length}const n=r.node().getBBox();r.insert("rect",":first-child").attr("class","box").attr("x",y-w/2-t().state.padding/2).attr("y",x-k/2-t().state.padding/2-3.5).attr("width",w+t().state.padding).attr("height",k+t().state.padding),b.info(n)}A++};let B;const z={},V=function(){},j=function(e){e.append("defs").append("marker").attr("id","dependencyEnd").attr("refX",19).attr("refY",7).attr("markerWidth",20).attr("markerHeight",28).attr("orient","auto").append("path").attr("d","M 19,7 L9,13 L14,7 L9,1 Z")},D=function(e,i,o,c){B=t().state;const s=t().securityLevel;let g;s==="sandbox"&&(g=H("#i"+i));const p=s==="sandbox"?H(g.nodes()[0].contentDocument.body):H("body"),a=s==="sandbox"?g.nodes()[0].contentDocument:document;b.debug("Rendering diagram "+e);const r=p.select(`[id='${i}']`);j(r);const y=c.db.getRootDoc();G(y,r,void 0,!1,p,a,c);const x=B.padding,d=r.node().getBBox(),l=d.width+x*2,m=d.height+x*2,w=l*1.75;R(r,m,w,B.useMaxWidth),r.attr("viewBox",`${d.x-B.padding} ${d.y-B.padding} `+l+" "+m)},tt=e=>e?e.length*B.fontSizeFactor:1,G=(e,i,o,c,s,g,p)=>{const a=new C({compound:!0,multigraph:!0});let r,y=!0;for(r=0;r<e.length;r++)if(e[r].stmt==="relation"){y=!1;break}o?a.setGraph({rankdir:"LR",multigraph:!0,compound:!0,ranker:"tight-tree",ranksep:y?1:B.edgeLengthFactor,nodeSep:y?1:50,isMultiGraph:!0}):a.setGraph({rankdir:"TB",multigraph:!0,compound:!0,ranksep:y?1:B.edgeLengthFactor,nodeSep:y?1:50,ranker:"tight-tree",isMultiGraph:!0}),a.setDefaultEdgeLabel(function(){return{}}),p.db.extract(e);const x=p.db.getStates(),d=p.db.getRelations(),l=Object.keys(x);for(const n of l){const u=x[n];o&&(u.parentId=o);let h;if(u.doc){let f=i.append("g").attr("id",u.id).attr("class","stateGroup");h=G(u.doc,f,u.id,!c,s,g,p);{f=I(f,u,c);let S=f.node().getBBox();h.width=S.width,h.height=S.height+B.padding/2,z[u.id]={y:B.compositTitleSize}}}else h=L(i,u);if(u.note){const f={descriptions:[],id:u.id+"-note",note:u.note,type:"note"},S=L(i,f);u.note.position==="left of"?(a.setNode(h.id+"-note",S),a.setNode(h.id,h)):(a.setNode(h.id,h),a.setNode(h.id+"-note",S)),a.setParent(h.id,h.id+"-group"),a.setParent(h.id+"-note",h.id+"-group")}else a.setNode(h.id,h)}b.debug("Count=",a.nodeCount(),a);let m=0;d.forEach(function(n){m++,b.debug("Setting edge",n),a.setEdge(n.id1,n.id2,{relation:n,width:tt(n.title),height:B.labelHeight*T.getRows(n.title).length,labelpos:"c"},"id"+m)}),F(a),b.debug("Graph after layout",a.nodes());const w=i.node();a.nodes().forEach(function(n){n!==void 0&&a.node(n)!==void 0?(b.warn("Node "+n+": "+JSON.stringify(a.node(n))),s.select("#"+w.id+" #"+n).attr("transform","translate("+(a.node(n).x-a.node(n).width/2)+","+(a.node(n).y+(z[n]?z[n].y:0)-a.node(n).height/2)+" )"),s.select("#"+w.id+" #"+n).attr("data-x-shift",a.node(n).x-a.node(n).width/2),g.querySelectorAll("#"+w.id+" #"+n+" .divider").forEach(h=>{const f=h.parentElement;let S=0,M=0;f&&(f.parentElement&&(S=f.parentElement.getBBox().width),M=parseInt(f.getAttribute("data-x-shift"),10),Number.isNaN(M)&&(M=0)),h.setAttribute("x1",0-M+8),h.setAttribute("x2",S-M-8)})):b.debug("No Node "+n+": "+JSON.stringify(a.node(n)))});let E=w.getBBox();a.edges().forEach(function(n){n!==void 0&&a.edge(n)!==void 0&&(b.debug("Edge "+n.v+" -> "+n.w+": "+JSON.stringify(a.edge(n))),Q(i,a.edge(n),a.edge(n).relation))}),E=w.getBBox();const k={id:o||"root",label:o||"root",width:0,height:0};return k.width=E.width+2*B.padding,k.height=E.height+2*B.padding,b.debug("Doc rendered",k,a),k},et={setConf:V,draw:D},lt={parser:W,db:N,renderer:et,styles:P,init:e=>{e.state||(e.state={}),e.state.arrowMarkerAbsolute=e.arrowMarkerAbsolute,N.clear()}};export{lt as diagram};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{s as P,d as N,p as W}from"./styles-6aaf32cf-DHTzglnJ.js";import{g as t,d as H,l as b,e as R,k as T,F as v,A as U}from"./index-CMQMxwMb.js";import{G as C}from"./graph-iERr38Mn.js";import{l as F}from"./layout-CPj4wl_r.js";import{l as $}from"./line-D_WC7vRh.js";import"./tool-windows-hjm6YiPY.js";import"./array-BKyUJesY.js";import"./path-CbwjOpE9.js";const O=e=>e.append("circle").attr("class","start-state").attr("r",t().state.sizeUnit).attr("cx",t().state.padding+t().state.sizeUnit).attr("cy",t().state.padding+t().state.sizeUnit),X=e=>e.append("line").style("stroke","grey").style("stroke-dasharray","3").attr("x1",t().state.textHeight).attr("class","divider").attr("x2",t().state.textHeight*2).attr("y1",0).attr("y2",0),J=(e,i)=>{const o=e.append("text").attr("x",2*t().state.padding).attr("y",t().state.textHeight+2*t().state.padding).attr("font-size",t().state.fontSize).attr("class","state-title").text(i.id),c=o.node().getBBox();return e.insert("rect",":first-child").attr("x",t().state.padding).attr("y",t().state.padding).attr("width",c.width+2*t().state.padding).attr("height",c.height+2*t().state.padding).attr("rx",t().state.radius),o},Y=(e,i)=>{const o=function(l,m,w){const E=l.append("tspan").attr("x",2*t().state.padding).text(m);w||E.attr("dy",t().state.textHeight)},s=e.append("text").attr("x",2*t().state.padding).attr("y",t().state.textHeight+1.3*t().state.padding).attr("font-size",t().state.fontSize).attr("class","state-title").text(i.descriptions[0]).node().getBBox(),g=s.height,p=e.append("text").attr("x",t().state.padding).attr("y",g+t().state.padding*.4+t().state.dividerMargin+t().state.textHeight).attr("class","state-description");let a=!0,r=!0;i.descriptions.forEach(function(l){a||(o(p,l,r),r=!1),a=!1});const y=e.append("line").attr("x1",t().state.padding).attr("y1",t().state.padding+g+t().state.dividerMargin/2).attr("y2",t().state.padding+g+t().state.dividerMargin/2).attr("class","descr-divider"),x=p.node().getBBox(),d=Math.max(x.width,s.width);return y.attr("x2",d+3*t().state.padding),e.insert("rect",":first-child").attr("x",t().state.padding).attr("y",t().state.padding).attr("width",d+2*t().state.padding).attr("height",x.height+g+2*t().state.padding).attr("rx",t().state.radius),e},I=(e,i,o)=>{const c=t().state.padding,s=2*t().state.padding,g=e.node().getBBox(),p=g.width,a=g.x,r=e.append("text").attr("x",0).attr("y",t().state.titleShift).attr("font-size",t().state.fontSize).attr("class","state-title").text(i.id),x=r.node().getBBox().width+s;let d=Math.max(x,p);d===p&&(d=d+s);let l;const m=e.node().getBBox();i.doc,l=a-c,x>p&&(l=(p-d)/2+c),Math.abs(a-m.x)<c&&x>p&&(l=a-(x-p)/2);const w=1-t().state.textHeight;return e.insert("rect",":first-child").attr("x",l).attr("y",w).attr("class",o?"alt-composit":"composit").attr("width",d).attr("height",m.height+t().state.textHeight+t().state.titleShift+1).attr("rx","0"),r.attr("x",l+c),x<=p&&r.attr("x",a+(d-s)/2-x/2+c),e.insert("rect",":first-child").attr("x",l).attr("y",t().state.titleShift-t().state.textHeight-t().state.padding).attr("width",d).attr("height",t().state.textHeight*3).attr("rx",t().state.radius),e.insert("rect",":first-child").attr("x",l).attr("y",t().state.titleShift-t().state.textHeight-t().state.padding).attr("width",d).attr("height",m.height+3+2*t().state.textHeight).attr("rx",t().state.radius),e},_=e=>(e.append("circle").attr("class","end-state-outer").attr("r",t().state.sizeUnit+t().state.miniPadding).attr("cx",t().state.padding+t().state.sizeUnit+t().state.miniPadding).attr("cy",t().state.padding+t().state.sizeUnit+t().state.miniPadding),e.append("circle").attr("class","end-state-inner").attr("r",t().state.sizeUnit).attr("cx",t().state.padding+t().state.sizeUnit+2).attr("cy",t().state.padding+t().state.sizeUnit+2)),q=(e,i)=>{let o=t().state.forkWidth,c=t().state.forkHeight;if(i.parentId){let s=o;o=c,c=s}return e.append("rect").style("stroke","black").style("fill","black").attr("width",o).attr("height",c).attr("x",t().state.padding).attr("y",t().state.padding)},Z=(e,i,o,c)=>{let s=0;const g=c.append("text");g.style("text-anchor","start"),g.attr("class","noteText");let p=e.replace(/\r\n/g,"<br/>");p=p.replace(/\n/g,"<br/>");const a=p.split(T.lineBreakRegex);let r=1.25*t().state.noteMargin;for(const y of a){const x=y.trim();if(x.length>0){const d=g.append("tspan");if(d.text(x),r===0){const l=d.node().getBBox();r+=l.height}s+=r,d.attr("x",i+t().state.noteMargin),d.attr("y",o+s+1.25*t().state.noteMargin)}}return{textWidth:g.node().getBBox().width,textHeight:s}},K=(e,i)=>{i.attr("class","state-note");const o=i.append("rect").attr("x",0).attr("y",t().state.padding),c=i.append("g"),{textWidth:s,textHeight:g}=Z(e,0,0,c);return o.attr("height",g+2*t().state.noteMargin),o.attr("width",s+t().state.noteMargin*2),o},L=function(e,i){const o=i.id,c={id:o,label:i.id,width:0,height:0},s=e.append("g").attr("id",o).attr("class","stateGroup");i.type==="start"&&O(s),i.type==="end"&&_(s),(i.type==="fork"||i.type==="join")&&q(s,i),i.type==="note"&&K(i.note.text,s),i.type==="divider"&&X(s),i.type==="default"&&i.descriptions.length===0&&J(s,i),i.type==="default"&&i.descriptions.length>0&&Y(s,i);const g=s.node().getBBox();return c.width=g.width+2*t().state.padding,c.height=g.height+2*t().state.padding,c};let A=0;const Q=function(e,i,o){const c=function(r){switch(r){case N.relationType.AGGREGATION:return"aggregation";case N.relationType.EXTENSION:return"extension";case N.relationType.COMPOSITION:return"composition";case N.relationType.DEPENDENCY:return"dependency"}};i.points=i.points.filter(r=>!Number.isNaN(r.y));const s=i.points,g=$().x(function(r){return r.x}).y(function(r){return r.y}).curve(v),p=e.append("path").attr("d",g(s)).attr("id","edge"+A).attr("class","transition");let a="";if(t().state.arrowMarkerAbsolute&&(a=window.location.protocol+"//"+window.location.host+window.location.pathname+window.location.search,a=a.replace(/\(/g,"\\("),a=a.replace(/\)/g,"\\)")),p.attr("marker-end","url("+a+"#"+c(N.relationType.DEPENDENCY)+"End)"),o.title!==void 0){const r=e.append("g").attr("class","stateLabel"),{x:y,y:x}=U.calcLabelPosition(i.points),d=T.getRows(o.title);let l=0;const m=[];let w=0,E=0;for(let u=0;u<=d.length;u++){const h=r.append("text").attr("text-anchor","middle").text(d[u]).attr("x",y).attr("y",x+l),f=h.node().getBBox();w=Math.max(w,f.width),E=Math.min(E,f.x),b.info(f.x,y,x+l),l===0&&(l=h.node().getBBox().height,b.info("Title height",l,x)),m.push(h)}let k=l*d.length;if(d.length>1){const u=(d.length-1)*l*.5;m.forEach((h,f)=>h.attr("y",x+f*l-u)),k=l*d.length}const n=r.node().getBBox();r.insert("rect",":first-child").attr("class","box").attr("x",y-w/2-t().state.padding/2).attr("y",x-k/2-t().state.padding/2-3.5).attr("width",w+t().state.padding).attr("height",k+t().state.padding),b.info(n)}A++};let B;const z={},V=function(){},j=function(e){e.append("defs").append("marker").attr("id","dependencyEnd").attr("refX",19).attr("refY",7).attr("markerWidth",20).attr("markerHeight",28).attr("orient","auto").append("path").attr("d","M 19,7 L9,13 L14,7 L9,1 Z")},D=function(e,i,o,c){B=t().state;const s=t().securityLevel;let g;s==="sandbox"&&(g=H("#i"+i));const p=s==="sandbox"?H(g.nodes()[0].contentDocument.body):H("body"),a=s==="sandbox"?g.nodes()[0].contentDocument:document;b.debug("Rendering diagram "+e);const r=p.select(`[id='${i}']`);j(r);const y=c.db.getRootDoc();G(y,r,void 0,!1,p,a,c);const x=B.padding,d=r.node().getBBox(),l=d.width+x*2,m=d.height+x*2,w=l*1.75;R(r,m,w,B.useMaxWidth),r.attr("viewBox",`${d.x-B.padding} ${d.y-B.padding} `+l+" "+m)},tt=e=>e?e.length*B.fontSizeFactor:1,G=(e,i,o,c,s,g,p)=>{const a=new C({compound:!0,multigraph:!0});let r,y=!0;for(r=0;r<e.length;r++)if(e[r].stmt==="relation"){y=!1;break}o?a.setGraph({rankdir:"LR",multigraph:!0,compound:!0,ranker:"tight-tree",ranksep:y?1:B.edgeLengthFactor,nodeSep:y?1:50,isMultiGraph:!0}):a.setGraph({rankdir:"TB",multigraph:!0,compound:!0,ranksep:y?1:B.edgeLengthFactor,nodeSep:y?1:50,ranker:"tight-tree",isMultiGraph:!0}),a.setDefaultEdgeLabel(function(){return{}}),p.db.extract(e);const x=p.db.getStates(),d=p.db.getRelations(),l=Object.keys(x);for(const n of l){const u=x[n];o&&(u.parentId=o);let h;if(u.doc){let f=i.append("g").attr("id",u.id).attr("class","stateGroup");h=G(u.doc,f,u.id,!c,s,g,p);{f=I(f,u,c);let S=f.node().getBBox();h.width=S.width,h.height=S.height+B.padding/2,z[u.id]={y:B.compositTitleSize}}}else h=L(i,u);if(u.note){const f={descriptions:[],id:u.id+"-note",note:u.note,type:"note"},S=L(i,f);u.note.position==="left of"?(a.setNode(h.id+"-note",S),a.setNode(h.id,h)):(a.setNode(h.id,h),a.setNode(h.id+"-note",S)),a.setParent(h.id,h.id+"-group"),a.setParent(h.id+"-note",h.id+"-group")}else a.setNode(h.id,h)}b.debug("Count=",a.nodeCount(),a);let m=0;d.forEach(function(n){m++,b.debug("Setting edge",n),a.setEdge(n.id1,n.id2,{relation:n,width:tt(n.title),height:B.labelHeight*T.getRows(n.title).length,labelpos:"c"},"id"+m)}),F(a),b.debug("Graph after layout",a.nodes());const w=i.node();a.nodes().forEach(function(n){n!==void 0&&a.node(n)!==void 0?(b.warn("Node "+n+": "+JSON.stringify(a.node(n))),s.select("#"+w.id+" #"+n).attr("transform","translate("+(a.node(n).x-a.node(n).width/2)+","+(a.node(n).y+(z[n]?z[n].y:0)-a.node(n).height/2)+" )"),s.select("#"+w.id+" #"+n).attr("data-x-shift",a.node(n).x-a.node(n).width/2),g.querySelectorAll("#"+w.id+" #"+n+" .divider").forEach(h=>{const f=h.parentElement;let S=0,M=0;f&&(f.parentElement&&(S=f.parentElement.getBBox().width),M=parseInt(f.getAttribute("data-x-shift"),10),Number.isNaN(M)&&(M=0)),h.setAttribute("x1",0-M+8),h.setAttribute("x2",S-M-8)})):b.debug("No Node "+n+": "+JSON.stringify(a.node(n)))});let E=w.getBBox();a.edges().forEach(function(n){n!==void 0&&a.edge(n)!==void 0&&(b.debug("Edge "+n.v+" -> "+n.w+": "+JSON.stringify(a.edge(n))),Q(i,a.edge(n),a.edge(n).relation))}),E=w.getBBox();const k={id:o||"root",label:o||"root",width:0,height:0};return k.width=E.width+2*B.padding,k.height=E.height+2*B.padding,b.debug("Doc rendered",k,a),k},et={setConf:V,draw:D},lt={parser:W,db:N,renderer:et,styles:P,init:e=>{e.state||(e.state={}),e.state.arrowMarkerAbsolute=e.arrowMarkerAbsolute,N.clear()}};export{lt as diagram};
|
|
1
|
+
import{s as P,d as N,p as W}from"./styles-6aaf32cf-C4CEUYqK.js";import{g as t,d as H,l as b,e as R,k as T,F as v,A as U}from"./index-gHdnUGOu.js";import{G as C}from"./graph-DM094zt_.js";import{l as F}from"./layout-DvIBYRXu.js";import{l as $}from"./line-Bxc-zIvZ.js";import"./tool-windows-C4D0lII2.js";import"./array-BKyUJesY.js";import"./path-CbwjOpE9.js";const O=e=>e.append("circle").attr("class","start-state").attr("r",t().state.sizeUnit).attr("cx",t().state.padding+t().state.sizeUnit).attr("cy",t().state.padding+t().state.sizeUnit),X=e=>e.append("line").style("stroke","grey").style("stroke-dasharray","3").attr("x1",t().state.textHeight).attr("class","divider").attr("x2",t().state.textHeight*2).attr("y1",0).attr("y2",0),J=(e,i)=>{const o=e.append("text").attr("x",2*t().state.padding).attr("y",t().state.textHeight+2*t().state.padding).attr("font-size",t().state.fontSize).attr("class","state-title").text(i.id),c=o.node().getBBox();return e.insert("rect",":first-child").attr("x",t().state.padding).attr("y",t().state.padding).attr("width",c.width+2*t().state.padding).attr("height",c.height+2*t().state.padding).attr("rx",t().state.radius),o},Y=(e,i)=>{const o=function(l,m,w){const E=l.append("tspan").attr("x",2*t().state.padding).text(m);w||E.attr("dy",t().state.textHeight)},s=e.append("text").attr("x",2*t().state.padding).attr("y",t().state.textHeight+1.3*t().state.padding).attr("font-size",t().state.fontSize).attr("class","state-title").text(i.descriptions[0]).node().getBBox(),g=s.height,p=e.append("text").attr("x",t().state.padding).attr("y",g+t().state.padding*.4+t().state.dividerMargin+t().state.textHeight).attr("class","state-description");let a=!0,r=!0;i.descriptions.forEach(function(l){a||(o(p,l,r),r=!1),a=!1});const y=e.append("line").attr("x1",t().state.padding).attr("y1",t().state.padding+g+t().state.dividerMargin/2).attr("y2",t().state.padding+g+t().state.dividerMargin/2).attr("class","descr-divider"),x=p.node().getBBox(),d=Math.max(x.width,s.width);return y.attr("x2",d+3*t().state.padding),e.insert("rect",":first-child").attr("x",t().state.padding).attr("y",t().state.padding).attr("width",d+2*t().state.padding).attr("height",x.height+g+2*t().state.padding).attr("rx",t().state.radius),e},I=(e,i,o)=>{const c=t().state.padding,s=2*t().state.padding,g=e.node().getBBox(),p=g.width,a=g.x,r=e.append("text").attr("x",0).attr("y",t().state.titleShift).attr("font-size",t().state.fontSize).attr("class","state-title").text(i.id),x=r.node().getBBox().width+s;let d=Math.max(x,p);d===p&&(d=d+s);let l;const m=e.node().getBBox();i.doc,l=a-c,x>p&&(l=(p-d)/2+c),Math.abs(a-m.x)<c&&x>p&&(l=a-(x-p)/2);const w=1-t().state.textHeight;return e.insert("rect",":first-child").attr("x",l).attr("y",w).attr("class",o?"alt-composit":"composit").attr("width",d).attr("height",m.height+t().state.textHeight+t().state.titleShift+1).attr("rx","0"),r.attr("x",l+c),x<=p&&r.attr("x",a+(d-s)/2-x/2+c),e.insert("rect",":first-child").attr("x",l).attr("y",t().state.titleShift-t().state.textHeight-t().state.padding).attr("width",d).attr("height",t().state.textHeight*3).attr("rx",t().state.radius),e.insert("rect",":first-child").attr("x",l).attr("y",t().state.titleShift-t().state.textHeight-t().state.padding).attr("width",d).attr("height",m.height+3+2*t().state.textHeight).attr("rx",t().state.radius),e},_=e=>(e.append("circle").attr("class","end-state-outer").attr("r",t().state.sizeUnit+t().state.miniPadding).attr("cx",t().state.padding+t().state.sizeUnit+t().state.miniPadding).attr("cy",t().state.padding+t().state.sizeUnit+t().state.miniPadding),e.append("circle").attr("class","end-state-inner").attr("r",t().state.sizeUnit).attr("cx",t().state.padding+t().state.sizeUnit+2).attr("cy",t().state.padding+t().state.sizeUnit+2)),q=(e,i)=>{let o=t().state.forkWidth,c=t().state.forkHeight;if(i.parentId){let s=o;o=c,c=s}return e.append("rect").style("stroke","black").style("fill","black").attr("width",o).attr("height",c).attr("x",t().state.padding).attr("y",t().state.padding)},Z=(e,i,o,c)=>{let s=0;const g=c.append("text");g.style("text-anchor","start"),g.attr("class","noteText");let p=e.replace(/\r\n/g,"<br/>");p=p.replace(/\n/g,"<br/>");const a=p.split(T.lineBreakRegex);let r=1.25*t().state.noteMargin;for(const y of a){const x=y.trim();if(x.length>0){const d=g.append("tspan");if(d.text(x),r===0){const l=d.node().getBBox();r+=l.height}s+=r,d.attr("x",i+t().state.noteMargin),d.attr("y",o+s+1.25*t().state.noteMargin)}}return{textWidth:g.node().getBBox().width,textHeight:s}},K=(e,i)=>{i.attr("class","state-note");const o=i.append("rect").attr("x",0).attr("y",t().state.padding),c=i.append("g"),{textWidth:s,textHeight:g}=Z(e,0,0,c);return o.attr("height",g+2*t().state.noteMargin),o.attr("width",s+t().state.noteMargin*2),o},L=function(e,i){const o=i.id,c={id:o,label:i.id,width:0,height:0},s=e.append("g").attr("id",o).attr("class","stateGroup");i.type==="start"&&O(s),i.type==="end"&&_(s),(i.type==="fork"||i.type==="join")&&q(s,i),i.type==="note"&&K(i.note.text,s),i.type==="divider"&&X(s),i.type==="default"&&i.descriptions.length===0&&J(s,i),i.type==="default"&&i.descriptions.length>0&&Y(s,i);const g=s.node().getBBox();return c.width=g.width+2*t().state.padding,c.height=g.height+2*t().state.padding,c};let A=0;const Q=function(e,i,o){const c=function(r){switch(r){case N.relationType.AGGREGATION:return"aggregation";case N.relationType.EXTENSION:return"extension";case N.relationType.COMPOSITION:return"composition";case N.relationType.DEPENDENCY:return"dependency"}};i.points=i.points.filter(r=>!Number.isNaN(r.y));const s=i.points,g=$().x(function(r){return r.x}).y(function(r){return r.y}).curve(v),p=e.append("path").attr("d",g(s)).attr("id","edge"+A).attr("class","transition");let a="";if(t().state.arrowMarkerAbsolute&&(a=window.location.protocol+"//"+window.location.host+window.location.pathname+window.location.search,a=a.replace(/\(/g,"\\("),a=a.replace(/\)/g,"\\)")),p.attr("marker-end","url("+a+"#"+c(N.relationType.DEPENDENCY)+"End)"),o.title!==void 0){const r=e.append("g").attr("class","stateLabel"),{x:y,y:x}=U.calcLabelPosition(i.points),d=T.getRows(o.title);let l=0;const m=[];let w=0,E=0;for(let u=0;u<=d.length;u++){const h=r.append("text").attr("text-anchor","middle").text(d[u]).attr("x",y).attr("y",x+l),f=h.node().getBBox();w=Math.max(w,f.width),E=Math.min(E,f.x),b.info(f.x,y,x+l),l===0&&(l=h.node().getBBox().height,b.info("Title height",l,x)),m.push(h)}let k=l*d.length;if(d.length>1){const u=(d.length-1)*l*.5;m.forEach((h,f)=>h.attr("y",x+f*l-u)),k=l*d.length}const n=r.node().getBBox();r.insert("rect",":first-child").attr("class","box").attr("x",y-w/2-t().state.padding/2).attr("y",x-k/2-t().state.padding/2-3.5).attr("width",w+t().state.padding).attr("height",k+t().state.padding),b.info(n)}A++};let B;const z={},V=function(){},j=function(e){e.append("defs").append("marker").attr("id","dependencyEnd").attr("refX",19).attr("refY",7).attr("markerWidth",20).attr("markerHeight",28).attr("orient","auto").append("path").attr("d","M 19,7 L9,13 L14,7 L9,1 Z")},D=function(e,i,o,c){B=t().state;const s=t().securityLevel;let g;s==="sandbox"&&(g=H("#i"+i));const p=s==="sandbox"?H(g.nodes()[0].contentDocument.body):H("body"),a=s==="sandbox"?g.nodes()[0].contentDocument:document;b.debug("Rendering diagram "+e);const r=p.select(`[id='${i}']`);j(r);const y=c.db.getRootDoc();G(y,r,void 0,!1,p,a,c);const x=B.padding,d=r.node().getBBox(),l=d.width+x*2,m=d.height+x*2,w=l*1.75;R(r,m,w,B.useMaxWidth),r.attr("viewBox",`${d.x-B.padding} ${d.y-B.padding} `+l+" "+m)},tt=e=>e?e.length*B.fontSizeFactor:1,G=(e,i,o,c,s,g,p)=>{const a=new C({compound:!0,multigraph:!0});let r,y=!0;for(r=0;r<e.length;r++)if(e[r].stmt==="relation"){y=!1;break}o?a.setGraph({rankdir:"LR",multigraph:!0,compound:!0,ranker:"tight-tree",ranksep:y?1:B.edgeLengthFactor,nodeSep:y?1:50,isMultiGraph:!0}):a.setGraph({rankdir:"TB",multigraph:!0,compound:!0,ranksep:y?1:B.edgeLengthFactor,nodeSep:y?1:50,ranker:"tight-tree",isMultiGraph:!0}),a.setDefaultEdgeLabel(function(){return{}}),p.db.extract(e);const x=p.db.getStates(),d=p.db.getRelations(),l=Object.keys(x);for(const n of l){const u=x[n];o&&(u.parentId=o);let h;if(u.doc){let f=i.append("g").attr("id",u.id).attr("class","stateGroup");h=G(u.doc,f,u.id,!c,s,g,p);{f=I(f,u,c);let S=f.node().getBBox();h.width=S.width,h.height=S.height+B.padding/2,z[u.id]={y:B.compositTitleSize}}}else h=L(i,u);if(u.note){const f={descriptions:[],id:u.id+"-note",note:u.note,type:"note"},S=L(i,f);u.note.position==="left of"?(a.setNode(h.id+"-note",S),a.setNode(h.id,h)):(a.setNode(h.id,h),a.setNode(h.id+"-note",S)),a.setParent(h.id,h.id+"-group"),a.setParent(h.id+"-note",h.id+"-group")}else a.setNode(h.id,h)}b.debug("Count=",a.nodeCount(),a);let m=0;d.forEach(function(n){m++,b.debug("Setting edge",n),a.setEdge(n.id1,n.id2,{relation:n,width:tt(n.title),height:B.labelHeight*T.getRows(n.title).length,labelpos:"c"},"id"+m)}),F(a),b.debug("Graph after layout",a.nodes());const w=i.node();a.nodes().forEach(function(n){n!==void 0&&a.node(n)!==void 0?(b.warn("Node "+n+": "+JSON.stringify(a.node(n))),s.select("#"+w.id+" #"+n).attr("transform","translate("+(a.node(n).x-a.node(n).width/2)+","+(a.node(n).y+(z[n]?z[n].y:0)-a.node(n).height/2)+" )"),s.select("#"+w.id+" #"+n).attr("data-x-shift",a.node(n).x-a.node(n).width/2),g.querySelectorAll("#"+w.id+" #"+n+" .divider").forEach(h=>{const f=h.parentElement;let S=0,M=0;f&&(f.parentElement&&(S=f.parentElement.getBBox().width),M=parseInt(f.getAttribute("data-x-shift"),10),Number.isNaN(M)&&(M=0)),h.setAttribute("x1",0-M+8),h.setAttribute("x2",S-M-8)})):b.debug("No Node "+n+": "+JSON.stringify(a.node(n)))});let E=w.getBBox();a.edges().forEach(function(n){n!==void 0&&a.edge(n)!==void 0&&(b.debug("Edge "+n.v+" -> "+n.w+": "+JSON.stringify(a.edge(n))),Q(i,a.edge(n),a.edge(n).relation))}),E=w.getBBox();const k={id:o||"root",label:o||"root",width:0,height:0};return k.width=E.width+2*B.padding,k.height=E.height+2*B.padding,b.debug("Doc rendered",k,a),k},et={setConf:V,draw:D},lt={parser:W,db:N,renderer:et,styles:P,init:e=>{e.state||(e.state={}),e.state.arrowMarkerAbsolute=e.arrowMarkerAbsolute,N.clear()}};export{lt as diagram};
|
package/assets/{stateDiagram-v2-d93cdb3a-D9VdRPIN.js → stateDiagram-v2-d93cdb3a-8b1lkei5.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{s as J,d as B,p as Q,D as X,a as H,b as Z,S as F,c as I}from"./styles-6aaf32cf-
|
|
1
|
+
import{s as J,d as B,p as Q,D as X,a as H,b as Z,S as F,c as I}from"./styles-6aaf32cf-C4CEUYqK.js";import{G as tt}from"./graph-DM094zt_.js";import{l as E,g,d as x,A as et,e as ot,k as w}from"./index-gHdnUGOu.js";import{r as st}from"./index-3862675e-CA0xjB9W.js";import"./layout-DvIBYRXu.js";import"./tool-windows-C4D0lII2.js";import"./edges-e0da2a9e-qdTreft0.js";import"./createText-2e5e7dd3-C0UgSBh5.js";import"./index-DI_5V2-m.js";import"./index.dom-C3-224fz.js";import"./line-Bxc-zIvZ.js";import"./array-BKyUJesY.js";import"./path-CbwjOpE9.js";const h="rect",C="rectWithTitle",nt="start",it="end",ct="divider",rt="roundedWithTitle",lt="note",at="noteGroup",_="statediagram",dt="state",Et=`${_}-${dt}`,U="transition",St="note",Tt="note-edge",pt=`${U} ${Tt}`,_t=`${_}-${St}`,ut="cluster",Dt=`${_}-${ut}`,bt="cluster-alt",ft=`${_}-${bt}`,V="parent",m="note",At="state",N="----",ht=`${N}${m}`,M=`${N}${V}`,Y="fill:none",W="fill: #333",z="c",q="text",K="normal";let y={},d=0;const yt=function(t){const n=Object.keys(t);for(const e of n)t[e]},gt=function(t,n){return n.db.extract(n.db.getRootDocV2()),n.db.getClasses()};function $t(t){return t==null?"":t.classes?t.classes.join(" "):""}function R(t="",n=0,e="",i=N){const c=e!==null&&e.length>0?`${i}${e}`:"";return`${At}-${t}${c}-${n}`}const A=(t,n,e,i,c,r)=>{const o=e.id,u=$t(i[o]);if(o!=="root"){let T=h;e.start===!0&&(T=nt),e.start===!1&&(T=it),e.type!==H&&(T=e.type),y[o]||(y[o]={id:o,shape:T,description:w.sanitizeText(o,g()),classes:`${u} ${Et}`});const s=y[o];e.description&&(Array.isArray(s.description)?(s.shape=C,s.description.push(e.description)):s.description.length>0?(s.shape=C,s.description===o?s.description=[e.description]:s.description=[s.description,e.description]):(s.shape=h,s.description=e.description),s.description=w.sanitizeTextOrArray(s.description,g())),s.description.length===1&&s.shape===C&&(s.shape=h),!s.type&&e.doc&&(E.info("Setting cluster for ",o,G(e)),s.type="group",s.dir=G(e),s.shape=e.type===Z?ct:rt,s.classes=s.classes+" "+Dt+" "+(r?ft:""));const p={labelStyle:"",shape:s.shape,labelText:s.description,classes:s.classes,style:"",id:o,dir:s.dir,domId:R(o,d),type:s.type,padding:15};if(p.centerLabel=!0,e.note){const l={labelStyle:"",shape:lt,labelText:e.note.text,classes:_t,style:"",id:o+ht+"-"+d,domId:R(o,d,m),type:s.type,padding:15},a={labelStyle:"",shape:at,labelText:e.note.text,classes:s.classes,style:"",id:o+M,domId:R(o,d,V),type:"group",padding:0};d++;const D=o+M;t.setNode(D,a),t.setNode(l.id,l),t.setNode(o,p),t.setParent(o,D),t.setParent(l.id,D);let S=o,b=l.id;e.note.position==="left of"&&(S=l.id,b=o),t.setEdge(S,b,{arrowhead:"none",arrowType:"",style:Y,labelStyle:"",classes:pt,arrowheadStyle:W,labelpos:z,labelType:q,thickness:K})}else t.setNode(o,p)}n&&n.id!=="root"&&(E.trace("Setting node ",o," to be child of its parent ",n.id),t.setParent(o,n.id)),e.doc&&(E.trace("Adding nodes children "),xt(t,e,e.doc,i,c,!r))},xt=(t,n,e,i,c,r)=>{E.trace("items",e),e.forEach(o=>{switch(o.stmt){case I:A(t,n,o,i,c,r);break;case H:A(t,n,o,i,c,r);break;case F:{A(t,n,o.state1,i,c,r),A(t,n,o.state2,i,c,r);const u={id:"edge"+d,arrowhead:"normal",arrowTypeEnd:"arrow_barb",style:Y,labelStyle:"",label:w.sanitizeText(o.description,g()),arrowheadStyle:W,labelpos:z,labelType:q,thickness:K,classes:U};t.setEdge(o.state1.id,o.state2.id,u,d),d++}break}})},G=(t,n=X)=>{let e=n;if(t.doc)for(let i=0;i<t.doc.length;i++){const c=t.doc[i];c.stmt==="dir"&&(e=c.value)}return e},Ct=async function(t,n,e,i){E.info("Drawing state diagram (v2)",n),y={},i.db.getDirection();const{securityLevel:c,state:r}=g(),o=r.nodeSpacing||50,u=r.rankSpacing||50;E.info(i.db.getRootDocV2()),i.db.extract(i.db.getRootDocV2()),E.info(i.db.getRootDocV2());const T=i.db.getStates(),s=new tt({multigraph:!0,compound:!0}).setGraph({rankdir:G(i.db.getRootDocV2()),nodesep:o,ranksep:u,marginx:8,marginy:8}).setDefaultEdgeLabel(function(){return{}});A(s,void 0,i.db.getRootDocV2(),T,i.db,!0);let p;c==="sandbox"&&(p=x("#i"+n));const l=c==="sandbox"?x(p.nodes()[0].contentDocument.body):x("body"),a=l.select(`[id="${n}"]`),D=l.select("#"+n+" g");await st(D,s,["barb"],_,n);const S=8;et.insertTitle(a,"statediagramTitleText",r.titleTopMargin,i.db.getDiagramTitle());const b=a.node().getBBox(),L=b.width+S*2,P=b.height+S*2;a.attr("class",_);const O=a.node().getBBox();ot(a,P,L,r.useMaxWidth);const k=`${O.x-S} ${O.y-S} ${L} ${P}`;E.debug(`viewBox ${k}`),a.attr("viewBox",k);const j=document.querySelectorAll('[id="'+n+'"] .edgeLabel .label');for(const $ of j){const v=$.getBBox(),f=document.createElementNS("http://www.w3.org/2000/svg",h);f.setAttribute("rx",0),f.setAttribute("ry",0),f.setAttribute("width",v.width),f.setAttribute("height",v.height),$.insertBefore(f,$.firstChild)}},Rt={setConf:yt,getClasses:gt,draw:Ct},mt={parser:Q,db:B,renderer:Rt,styles:J,init:t=>{t.state||(t.state={}),t.state.arrowMarkerAbsolute=t.arrowMarkerAbsolute,B.clear()}};export{mt as diagram};
|
package/assets/{stateDiagram-v2-d93cdb3a-CGMASaM9.js → stateDiagram-v2-d93cdb3a-BHm8pPuv.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{s as J,d as B,p as Q,D as X,a as H,b as Z,S as F,c as I}from"./styles-6aaf32cf-
|
|
1
|
+
import{s as J,d as B,p as Q,D as X,a as H,b as Z,S as F,c as I}from"./styles-6aaf32cf-BlD8JxQr.js";import{G as tt}from"./graph-Bq1HvHkL.js";import{l as E,g,d as x,A as et,e as ot,k as w}from"./mermaid.core-BGyfnsLl.js";import{r as st}from"./index-3862675e-DGrSmeWu.js";import"./layout-SoDWNnQD.js";import"./tool-windows-C4D0lII2.js";import"./clone-keJVIubx.js";import"./edges-e0da2a9e-DmyL0L_b.js";import"./createText-2e5e7dd3-CoA6JNKB.js";import"./line-CFFXuH78.js";import"./array-B5oSNiGi.js";import"./path-CY0bYimO.js";const h="rect",C="rectWithTitle",nt="start",it="end",ct="divider",rt="roundedWithTitle",lt="note",at="noteGroup",_="statediagram",dt="state",Et=`${_}-${dt}`,U="transition",St="note",Tt="note-edge",pt=`${U} ${Tt}`,_t=`${_}-${St}`,ut="cluster",Dt=`${_}-${ut}`,bt="cluster-alt",ft=`${_}-${bt}`,V="parent",Y="note",At="state",N="----",ht=`${N}${Y}`,M=`${N}${V}`,m="fill:none",W="fill: #333",z="c",q="text",K="normal";let y={},d=0;const yt=function(t){const n=Object.keys(t);for(const e of n)t[e]},gt=function(t,n){return n.db.extract(n.db.getRootDocV2()),n.db.getClasses()};function $t(t){return t==null?"":t.classes?t.classes.join(" "):""}function R(t="",n=0,e="",i=N){const c=e!==null&&e.length>0?`${i}${e}`:"";return`${At}-${t}${c}-${n}`}const A=(t,n,e,i,c,r)=>{const o=e.id,u=$t(i[o]);if(o!=="root"){let T=h;e.start===!0&&(T=nt),e.start===!1&&(T=it),e.type!==H&&(T=e.type),y[o]||(y[o]={id:o,shape:T,description:w.sanitizeText(o,g()),classes:`${u} ${Et}`});const s=y[o];e.description&&(Array.isArray(s.description)?(s.shape=C,s.description.push(e.description)):s.description.length>0?(s.shape=C,s.description===o?s.description=[e.description]:s.description=[s.description,e.description]):(s.shape=h,s.description=e.description),s.description=w.sanitizeTextOrArray(s.description,g())),s.description.length===1&&s.shape===C&&(s.shape=h),!s.type&&e.doc&&(E.info("Setting cluster for ",o,G(e)),s.type="group",s.dir=G(e),s.shape=e.type===Z?ct:rt,s.classes=s.classes+" "+Dt+" "+(r?ft:""));const p={labelStyle:"",shape:s.shape,labelText:s.description,classes:s.classes,style:"",id:o,dir:s.dir,domId:R(o,d),type:s.type,padding:15};if(p.centerLabel=!0,e.note){const l={labelStyle:"",shape:lt,labelText:e.note.text,classes:_t,style:"",id:o+ht+"-"+d,domId:R(o,d,Y),type:s.type,padding:15},a={labelStyle:"",shape:at,labelText:e.note.text,classes:s.classes,style:"",id:o+M,domId:R(o,d,V),type:"group",padding:0};d++;const D=o+M;t.setNode(D,a),t.setNode(l.id,l),t.setNode(o,p),t.setParent(o,D),t.setParent(l.id,D);let S=o,b=l.id;e.note.position==="left of"&&(S=l.id,b=o),t.setEdge(S,b,{arrowhead:"none",arrowType:"",style:m,labelStyle:"",classes:pt,arrowheadStyle:W,labelpos:z,labelType:q,thickness:K})}else t.setNode(o,p)}n&&n.id!=="root"&&(E.trace("Setting node ",o," to be child of its parent ",n.id),t.setParent(o,n.id)),e.doc&&(E.trace("Adding nodes children "),xt(t,e,e.doc,i,c,!r))},xt=(t,n,e,i,c,r)=>{E.trace("items",e),e.forEach(o=>{switch(o.stmt){case I:A(t,n,o,i,c,r);break;case H:A(t,n,o,i,c,r);break;case F:{A(t,n,o.state1,i,c,r),A(t,n,o.state2,i,c,r);const u={id:"edge"+d,arrowhead:"normal",arrowTypeEnd:"arrow_barb",style:m,labelStyle:"",label:w.sanitizeText(o.description,g()),arrowheadStyle:W,labelpos:z,labelType:q,thickness:K,classes:U};t.setEdge(o.state1.id,o.state2.id,u,d),d++}break}})},G=(t,n=X)=>{let e=n;if(t.doc)for(let i=0;i<t.doc.length;i++){const c=t.doc[i];c.stmt==="dir"&&(e=c.value)}return e},Ct=async function(t,n,e,i){E.info("Drawing state diagram (v2)",n),y={},i.db.getDirection();const{securityLevel:c,state:r}=g(),o=r.nodeSpacing||50,u=r.rankSpacing||50;E.info(i.db.getRootDocV2()),i.db.extract(i.db.getRootDocV2()),E.info(i.db.getRootDocV2());const T=i.db.getStates(),s=new tt({multigraph:!0,compound:!0}).setGraph({rankdir:G(i.db.getRootDocV2()),nodesep:o,ranksep:u,marginx:8,marginy:8}).setDefaultEdgeLabel(function(){return{}});A(s,void 0,i.db.getRootDocV2(),T,i.db,!0);let p;c==="sandbox"&&(p=x("#i"+n));const l=c==="sandbox"?x(p.nodes()[0].contentDocument.body):x("body"),a=l.select(`[id="${n}"]`),D=l.select("#"+n+" g");await st(D,s,["barb"],_,n);const S=8;et.insertTitle(a,"statediagramTitleText",r.titleTopMargin,i.db.getDiagramTitle());const b=a.node().getBBox(),L=b.width+S*2,P=b.height+S*2;a.attr("class",_);const O=a.node().getBBox();ot(a,P,L,r.useMaxWidth);const k=`${O.x-S} ${O.y-S} ${L} ${P}`;E.debug(`viewBox ${k}`),a.attr("viewBox",k);const j=document.querySelectorAll('[id="'+n+'"] .edgeLabel .label');for(const $ of j){const v=$.getBBox(),f=document.createElementNS("http://www.w3.org/2000/svg",h);f.setAttribute("rx",0),f.setAttribute("ry",0),f.setAttribute("width",v.width),f.setAttribute("height",v.height),$.insertBefore(f,$.firstChild)}},Rt={setConf:yt,getClasses:gt,draw:Ct},Vt={parser:Q,db:B,renderer:Rt,styles:J,init:t=>{t.state||(t.state={}),t.state.arrowMarkerAbsolute=t.arrowMarkerAbsolute,B.clear()}};export{Vt as diagram};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{v as Ut,x as zt,s as Mt,a as Ht,c as Xt,b as Kt,g as Y,k as ot,l as D,z as Wt,b1 as Jt}from"./mermaid.core-
|
|
1
|
+
import{v as Ut,x as zt,s as Mt,a as Ht,c as Xt,b as Kt,g as Y,k as ot,l as D,z as Wt,b1 as Jt}from"./mermaid.core-BGyfnsLl.js";var gt=(function(){var t=function(C,r,n,i){for(n=n||{},i=C.length;i--;n[C[i]]=r);return n},s=[1,2],a=[1,3],h=[1,4],f=[2,4],d=[1,9],y=[1,11],k=[1,15],u=[1,16],E=[1,17],T=[1,18],R=[1,30],G=[1,19],j=[1,20],U=[1,21],z=[1,22],M=[1,23],H=[1,25],X=[1,26],K=[1,27],W=[1,28],J=[1,29],q=[1,32],Q=[1,33],Z=[1,34],tt=[1,35],w=[1,31],c=[1,4,5,15,16,18,20,21,23,24,25,26,27,28,32,34,36,37,41,44,45,46,47,50],et=[1,4,5,13,14,15,16,18,20,21,23,24,25,26,27,28,32,34,36,37,41,44,45,46,47,50],Dt=[4,5,15,16,18,20,21,23,24,25,26,27,28,32,34,36,37,41,44,45,46,47,50],ht={trace:function(){},yy:{},symbols_:{error:2,start:3,SPACE:4,NL:5,SD:6,document:7,line:8,statement:9,classDefStatement:10,cssClassStatement:11,idStatement:12,DESCR:13,"-->":14,HIDE_EMPTY:15,scale:16,WIDTH:17,COMPOSIT_STATE:18,STRUCT_START:19,STRUCT_STOP:20,STATE_DESCR:21,AS:22,ID:23,FORK:24,JOIN:25,CHOICE:26,CONCURRENT:27,note:28,notePosition:29,NOTE_TEXT:30,direction:31,acc_title:32,acc_title_value:33,acc_descr:34,acc_descr_value:35,acc_descr_multiline_value:36,classDef:37,CLASSDEF_ID:38,CLASSDEF_STYLEOPTS:39,DEFAULT:40,class:41,CLASSENTITY_IDS:42,STYLECLASS:43,direction_tb:44,direction_bt:45,direction_rl:46,direction_lr:47,eol:48,";":49,EDGE_STATE:50,STYLE_SEPARATOR:51,left_of:52,right_of:53,$accept:0,$end:1},terminals_:{2:"error",4:"SPACE",5:"NL",6:"SD",13:"DESCR",14:"-->",15:"HIDE_EMPTY",16:"scale",17:"WIDTH",18:"COMPOSIT_STATE",19:"STRUCT_START",20:"STRUCT_STOP",21:"STATE_DESCR",22:"AS",23:"ID",24:"FORK",25:"JOIN",26:"CHOICE",27:"CONCURRENT",28:"note",30:"NOTE_TEXT",32:"acc_title",33:"acc_title_value",34:"acc_descr",35:"acc_descr_value",36:"acc_descr_multiline_value",37:"classDef",38:"CLASSDEF_ID",39:"CLASSDEF_STYLEOPTS",40:"DEFAULT",41:"class",42:"CLASSENTITY_IDS",43:"STYLECLASS",44:"direction_tb",45:"direction_bt",46:"direction_rl",47:"direction_lr",49:";",50:"EDGE_STATE",51:"STYLE_SEPARATOR",52:"left_of",53:"right_of"},productions_:[0,[3,2],[3,2],[3,2],[7,0],[7,2],[8,2],[8,1],[8,1],[9,1],[9,1],[9,1],[9,2],[9,3],[9,4],[9,1],[9,2],[9,1],[9,4],[9,3],[9,6],[9,1],[9,1],[9,1],[9,1],[9,4],[9,4],[9,1],[9,2],[9,2],[9,1],[10,3],[10,3],[11,3],[31,1],[31,1],[31,1],[31,1],[48,1],[48,1],[12,1],[12,1],[12,3],[12,3],[29,1],[29,1]],performAction:function(r,n,i,o,p,e,$){var l=e.length-1;switch(p){case 3:return o.setRootDoc(e[l]),e[l];case 4:this.$=[];break;case 5:e[l]!="nl"&&(e[l-1].push(e[l]),this.$=e[l-1]);break;case 6:case 7:this.$=e[l];break;case 8:this.$="nl";break;case 11:this.$=e[l];break;case 12:const B=e[l-1];B.description=o.trimColon(e[l]),this.$=B;break;case 13:this.$={stmt:"relation",state1:e[l-2],state2:e[l]};break;case 14:const ft=o.trimColon(e[l]);this.$={stmt:"relation",state1:e[l-3],state2:e[l-1],description:ft};break;case 18:this.$={stmt:"state",id:e[l-3],type:"default",description:"",doc:e[l-1]};break;case 19:var v=e[l],O=e[l-2].trim();if(e[l].match(":")){var st=e[l].split(":");v=st[0],O=[O,st[1]]}this.$={stmt:"state",id:v,type:"default",description:O};break;case 20:this.$={stmt:"state",id:e[l-3],type:"default",description:e[l-5],doc:e[l-1]};break;case 21:this.$={stmt:"state",id:e[l],type:"fork"};break;case 22:this.$={stmt:"state",id:e[l],type:"join"};break;case 23:this.$={stmt:"state",id:e[l],type:"choice"};break;case 24:this.$={stmt:"state",id:o.getDividerId(),type:"divider"};break;case 25:this.$={stmt:"state",id:e[l-1].trim(),note:{position:e[l-2].trim(),text:e[l].trim()}};break;case 28:this.$=e[l].trim(),o.setAccTitle(this.$);break;case 29:case 30:this.$=e[l].trim(),o.setAccDescription(this.$);break;case 31:case 32:this.$={stmt:"classDef",id:e[l-1].trim(),classes:e[l].trim()};break;case 33:this.$={stmt:"applyClass",id:e[l-1].trim(),styleClass:e[l].trim()};break;case 34:o.setDirection("TB"),this.$={stmt:"dir",value:"TB"};break;case 35:o.setDirection("BT"),this.$={stmt:"dir",value:"BT"};break;case 36:o.setDirection("RL"),this.$={stmt:"dir",value:"RL"};break;case 37:o.setDirection("LR"),this.$={stmt:"dir",value:"LR"};break;case 40:case 41:this.$={stmt:"state",id:e[l].trim(),type:"default",description:""};break;case 42:this.$={stmt:"state",id:e[l-2].trim(),classes:[e[l].trim()],type:"default",description:""};break;case 43:this.$={stmt:"state",id:e[l-2].trim(),classes:[e[l].trim()],type:"default",description:""};break}},table:[{3:1,4:s,5:a,6:h},{1:[3]},{3:5,4:s,5:a,6:h},{3:6,4:s,5:a,6:h},t([1,4,5,15,16,18,21,23,24,25,26,27,28,32,34,36,37,41,44,45,46,47,50],f,{7:7}),{1:[2,1]},{1:[2,2]},{1:[2,3],4:d,5:y,8:8,9:10,10:12,11:13,12:14,15:k,16:u,18:E,21:T,23:R,24:G,25:j,26:U,27:z,28:M,31:24,32:H,34:X,36:K,37:W,41:J,44:q,45:Q,46:Z,47:tt,50:w},t(c,[2,5]),{9:36,10:12,11:13,12:14,15:k,16:u,18:E,21:T,23:R,24:G,25:j,26:U,27:z,28:M,31:24,32:H,34:X,36:K,37:W,41:J,44:q,45:Q,46:Z,47:tt,50:w},t(c,[2,7]),t(c,[2,8]),t(c,[2,9]),t(c,[2,10]),t(c,[2,11],{13:[1,37],14:[1,38]}),t(c,[2,15]),{17:[1,39]},t(c,[2,17],{19:[1,40]}),{22:[1,41]},t(c,[2,21]),t(c,[2,22]),t(c,[2,23]),t(c,[2,24]),{29:42,30:[1,43],52:[1,44],53:[1,45]},t(c,[2,27]),{33:[1,46]},{35:[1,47]},t(c,[2,30]),{38:[1,48],40:[1,49]},{42:[1,50]},t(et,[2,40],{51:[1,51]}),t(et,[2,41],{51:[1,52]}),t(c,[2,34]),t(c,[2,35]),t(c,[2,36]),t(c,[2,37]),t(c,[2,6]),t(c,[2,12]),{12:53,23:R,50:w},t(c,[2,16]),t(Dt,f,{7:54}),{23:[1,55]},{23:[1,56]},{22:[1,57]},{23:[2,44]},{23:[2,45]},t(c,[2,28]),t(c,[2,29]),{39:[1,58]},{39:[1,59]},{43:[1,60]},{23:[1,61]},{23:[1,62]},t(c,[2,13],{13:[1,63]}),{4:d,5:y,8:8,9:10,10:12,11:13,12:14,15:k,16:u,18:E,20:[1,64],21:T,23:R,24:G,25:j,26:U,27:z,28:M,31:24,32:H,34:X,36:K,37:W,41:J,44:q,45:Q,46:Z,47:tt,50:w},t(c,[2,19],{19:[1,65]}),{30:[1,66]},{23:[1,67]},t(c,[2,31]),t(c,[2,32]),t(c,[2,33]),t(et,[2,42]),t(et,[2,43]),t(c,[2,14]),t(c,[2,18]),t(Dt,f,{7:68}),t(c,[2,25]),t(c,[2,26]),{4:d,5:y,8:8,9:10,10:12,11:13,12:14,15:k,16:u,18:E,20:[1,69],21:T,23:R,24:G,25:j,26:U,27:z,28:M,31:24,32:H,34:X,36:K,37:W,41:J,44:q,45:Q,46:Z,47:tt,50:w},t(c,[2,20])],defaultActions:{5:[2,1],6:[2,2],44:[2,44],45:[2,45]},parseError:function(r,n){if(n.recoverable)this.trace(r);else{var i=new Error(r);throw i.hash=n,i}},parse:function(r){var n=this,i=[0],o=[],p=[null],e=[],$=this.table,l="",v=0,O=0,st=2,B=1,ft=e.slice.call(arguments,1),S=Object.create(this.lexer),A={yy:{}};for(var dt in this.yy)Object.prototype.hasOwnProperty.call(this.yy,dt)&&(A.yy[dt]=this.yy[dt]);S.setInput(r,A.yy),A.yy.lexer=S,A.yy.parser=this,typeof S.yylloc>"u"&&(S.yylloc={});var yt=S.yylloc;e.push(yt);var Gt=S.options&&S.options.ranges;typeof A.yy.parseError=="function"?this.parseError=A.yy.parseError:this.parseError=Object.getPrototypeOf(this).parseError;function jt(){var x;return x=o.pop()||S.lex()||B,typeof x!="number"&&(x instanceof Array&&(o=x,x=o.pop()),x=n.symbols_[x]||x),x}for(var _,L,m,pt,N={},it,b,Ct,rt;;){if(L=i[i.length-1],this.defaultActions[L]?m=this.defaultActions[L]:((_===null||typeof _>"u")&&(_=jt()),m=$[L]&&$[L][_]),typeof m>"u"||!m.length||!m[0]){var St="";rt=[];for(it in $[L])this.terminals_[it]&&it>st&&rt.push("'"+this.terminals_[it]+"'");S.showPosition?St="Parse error on line "+(v+1)+`:
|
|
2
2
|
`+S.showPosition()+`
|
|
3
3
|
Expecting `+rt.join(", ")+", got '"+(this.terminals_[_]||_)+"'":St="Parse error on line "+(v+1)+": Unexpected "+(_==B?"end of input":"'"+(this.terminals_[_]||_)+"'"),this.parseError(St,{text:S.match,token:this.terminals_[_]||_,line:S.yylineno,loc:yt,expected:rt})}if(m[0]instanceof Array&&m.length>1)throw new Error("Parse Error: multiple actions possible at state: "+L+", token: "+_);switch(m[0]){case 1:i.push(_),p.push(S.yytext),e.push(S.yylloc),i.push(m[1]),_=null,O=S.yyleng,l=S.yytext,v=S.yylineno,yt=S.yylloc;break;case 2:if(b=this.productions_[m[1]][1],N.$=p[p.length-b],N._$={first_line:e[e.length-(b||1)].first_line,last_line:e[e.length-1].last_line,first_column:e[e.length-(b||1)].first_column,last_column:e[e.length-1].last_column},Gt&&(N._$.range=[e[e.length-(b||1)].range[0],e[e.length-1].range[1]]),pt=this.performAction.apply(N,[l,O,v,A.yy,m[1],p,e].concat(ft)),typeof pt<"u")return pt;b&&(i=i.slice(0,-1*b*2),p=p.slice(0,-1*b),e=e.slice(0,-1*b)),i.push(this.productions_[m[1]][0]),p.push(N.$),e.push(N._$),Ct=$[i[i.length-2]][i[i.length-1]],i.push(Ct);break;case 3:return!0}}return!0}},Yt=(function(){var C={EOF:1,parseError:function(n,i){if(this.yy.parser)this.yy.parser.parseError(n,i);else throw new Error(n)},setInput:function(r,n){return this.yy=n||this.yy||{},this._input=r,this._more=this._backtrack=this.done=!1,this.yylineno=this.yyleng=0,this.yytext=this.matched=this.match="",this.conditionStack=["INITIAL"],this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0},this.options.ranges&&(this.yylloc.range=[0,0]),this.offset=0,this},input:function(){var r=this._input[0];this.yytext+=r,this.yyleng++,this.offset++,this.match+=r,this.matched+=r;var n=r.match(/(?:\r\n?|\n).*/g);return n?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),r},unput:function(r){var n=r.length,i=r.split(/(?:\r\n?|\n)/g);this._input=r+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-n),this.offset-=n;var o=this.match.split(/(?:\r\n?|\n)/g);this.match=this.match.substr(0,this.match.length-1),this.matched=this.matched.substr(0,this.matched.length-1),i.length-1&&(this.yylineno-=i.length-1);var p=this.yylloc.range;return this.yylloc={first_line:this.yylloc.first_line,last_line:this.yylineno+1,first_column:this.yylloc.first_column,last_column:i?(i.length===o.length?this.yylloc.first_column:0)+o[o.length-i.length].length-i[0].length:this.yylloc.first_column-n},this.options.ranges&&(this.yylloc.range=[p[0],p[0]+this.yyleng-n]),this.yyleng=this.yytext.length,this},more:function(){return this._more=!0,this},reject:function(){if(this.options.backtrack_lexer)this._backtrack=!0;else return this.parseError("Lexical error on line "+(this.yylineno+1)+`. You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).
|
|
4
4
|
`+this.showPosition(),{text:"",token:null,line:this.yylineno});return this},less:function(r){this.unput(this.match.slice(r))},pastInput:function(){var r=this.matched.substr(0,this.matched.length-this.match.length);return(r.length>20?"...":"")+r.substr(-20).replace(/\n/g,"")},upcomingInput:function(){var r=this.match;return r.length<20&&(r+=this._input.substr(0,20-r.length)),(r.substr(0,20)+(r.length>20?"...":"")).replace(/\n/g,"")},showPosition:function(){var r=this.pastInput(),n=new Array(r.length+1).join("-");return r+this.upcomingInput()+`
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{v as Ut,x as zt,s as Mt,a as Ht,c as Xt,b as Kt,g as Y,k as ot,l as D,z as Wt,al as Jt}from"./index-
|
|
1
|
+
import{v as Ut,x as zt,s as Mt,a as Ht,c as Xt,b as Kt,g as Y,k as ot,l as D,z as Wt,al as Jt}from"./index-gHdnUGOu.js";var gt=(function(){var t=function(C,r,n,i){for(n=n||{},i=C.length;i--;n[C[i]]=r);return n},s=[1,2],a=[1,3],h=[1,4],f=[2,4],d=[1,9],y=[1,11],k=[1,15],u=[1,16],E=[1,17],T=[1,18],R=[1,30],G=[1,19],j=[1,20],U=[1,21],z=[1,22],M=[1,23],H=[1,25],X=[1,26],K=[1,27],W=[1,28],J=[1,29],q=[1,32],Q=[1,33],Z=[1,34],tt=[1,35],w=[1,31],c=[1,4,5,15,16,18,20,21,23,24,25,26,27,28,32,34,36,37,41,44,45,46,47,50],et=[1,4,5,13,14,15,16,18,20,21,23,24,25,26,27,28,32,34,36,37,41,44,45,46,47,50],Dt=[4,5,15,16,18,20,21,23,24,25,26,27,28,32,34,36,37,41,44,45,46,47,50],ht={trace:function(){},yy:{},symbols_:{error:2,start:3,SPACE:4,NL:5,SD:6,document:7,line:8,statement:9,classDefStatement:10,cssClassStatement:11,idStatement:12,DESCR:13,"-->":14,HIDE_EMPTY:15,scale:16,WIDTH:17,COMPOSIT_STATE:18,STRUCT_START:19,STRUCT_STOP:20,STATE_DESCR:21,AS:22,ID:23,FORK:24,JOIN:25,CHOICE:26,CONCURRENT:27,note:28,notePosition:29,NOTE_TEXT:30,direction:31,acc_title:32,acc_title_value:33,acc_descr:34,acc_descr_value:35,acc_descr_multiline_value:36,classDef:37,CLASSDEF_ID:38,CLASSDEF_STYLEOPTS:39,DEFAULT:40,class:41,CLASSENTITY_IDS:42,STYLECLASS:43,direction_tb:44,direction_bt:45,direction_rl:46,direction_lr:47,eol:48,";":49,EDGE_STATE:50,STYLE_SEPARATOR:51,left_of:52,right_of:53,$accept:0,$end:1},terminals_:{2:"error",4:"SPACE",5:"NL",6:"SD",13:"DESCR",14:"-->",15:"HIDE_EMPTY",16:"scale",17:"WIDTH",18:"COMPOSIT_STATE",19:"STRUCT_START",20:"STRUCT_STOP",21:"STATE_DESCR",22:"AS",23:"ID",24:"FORK",25:"JOIN",26:"CHOICE",27:"CONCURRENT",28:"note",30:"NOTE_TEXT",32:"acc_title",33:"acc_title_value",34:"acc_descr",35:"acc_descr_value",36:"acc_descr_multiline_value",37:"classDef",38:"CLASSDEF_ID",39:"CLASSDEF_STYLEOPTS",40:"DEFAULT",41:"class",42:"CLASSENTITY_IDS",43:"STYLECLASS",44:"direction_tb",45:"direction_bt",46:"direction_rl",47:"direction_lr",49:";",50:"EDGE_STATE",51:"STYLE_SEPARATOR",52:"left_of",53:"right_of"},productions_:[0,[3,2],[3,2],[3,2],[7,0],[7,2],[8,2],[8,1],[8,1],[9,1],[9,1],[9,1],[9,2],[9,3],[9,4],[9,1],[9,2],[9,1],[9,4],[9,3],[9,6],[9,1],[9,1],[9,1],[9,1],[9,4],[9,4],[9,1],[9,2],[9,2],[9,1],[10,3],[10,3],[11,3],[31,1],[31,1],[31,1],[31,1],[48,1],[48,1],[12,1],[12,1],[12,3],[12,3],[29,1],[29,1]],performAction:function(r,n,i,o,p,e,$){var l=e.length-1;switch(p){case 3:return o.setRootDoc(e[l]),e[l];case 4:this.$=[];break;case 5:e[l]!="nl"&&(e[l-1].push(e[l]),this.$=e[l-1]);break;case 6:case 7:this.$=e[l];break;case 8:this.$="nl";break;case 11:this.$=e[l];break;case 12:const B=e[l-1];B.description=o.trimColon(e[l]),this.$=B;break;case 13:this.$={stmt:"relation",state1:e[l-2],state2:e[l]};break;case 14:const ft=o.trimColon(e[l]);this.$={stmt:"relation",state1:e[l-3],state2:e[l-1],description:ft};break;case 18:this.$={stmt:"state",id:e[l-3],type:"default",description:"",doc:e[l-1]};break;case 19:var v=e[l],O=e[l-2].trim();if(e[l].match(":")){var st=e[l].split(":");v=st[0],O=[O,st[1]]}this.$={stmt:"state",id:v,type:"default",description:O};break;case 20:this.$={stmt:"state",id:e[l-3],type:"default",description:e[l-5],doc:e[l-1]};break;case 21:this.$={stmt:"state",id:e[l],type:"fork"};break;case 22:this.$={stmt:"state",id:e[l],type:"join"};break;case 23:this.$={stmt:"state",id:e[l],type:"choice"};break;case 24:this.$={stmt:"state",id:o.getDividerId(),type:"divider"};break;case 25:this.$={stmt:"state",id:e[l-1].trim(),note:{position:e[l-2].trim(),text:e[l].trim()}};break;case 28:this.$=e[l].trim(),o.setAccTitle(this.$);break;case 29:case 30:this.$=e[l].trim(),o.setAccDescription(this.$);break;case 31:case 32:this.$={stmt:"classDef",id:e[l-1].trim(),classes:e[l].trim()};break;case 33:this.$={stmt:"applyClass",id:e[l-1].trim(),styleClass:e[l].trim()};break;case 34:o.setDirection("TB"),this.$={stmt:"dir",value:"TB"};break;case 35:o.setDirection("BT"),this.$={stmt:"dir",value:"BT"};break;case 36:o.setDirection("RL"),this.$={stmt:"dir",value:"RL"};break;case 37:o.setDirection("LR"),this.$={stmt:"dir",value:"LR"};break;case 40:case 41:this.$={stmt:"state",id:e[l].trim(),type:"default",description:""};break;case 42:this.$={stmt:"state",id:e[l-2].trim(),classes:[e[l].trim()],type:"default",description:""};break;case 43:this.$={stmt:"state",id:e[l-2].trim(),classes:[e[l].trim()],type:"default",description:""};break}},table:[{3:1,4:s,5:a,6:h},{1:[3]},{3:5,4:s,5:a,6:h},{3:6,4:s,5:a,6:h},t([1,4,5,15,16,18,21,23,24,25,26,27,28,32,34,36,37,41,44,45,46,47,50],f,{7:7}),{1:[2,1]},{1:[2,2]},{1:[2,3],4:d,5:y,8:8,9:10,10:12,11:13,12:14,15:k,16:u,18:E,21:T,23:R,24:G,25:j,26:U,27:z,28:M,31:24,32:H,34:X,36:K,37:W,41:J,44:q,45:Q,46:Z,47:tt,50:w},t(c,[2,5]),{9:36,10:12,11:13,12:14,15:k,16:u,18:E,21:T,23:R,24:G,25:j,26:U,27:z,28:M,31:24,32:H,34:X,36:K,37:W,41:J,44:q,45:Q,46:Z,47:tt,50:w},t(c,[2,7]),t(c,[2,8]),t(c,[2,9]),t(c,[2,10]),t(c,[2,11],{13:[1,37],14:[1,38]}),t(c,[2,15]),{17:[1,39]},t(c,[2,17],{19:[1,40]}),{22:[1,41]},t(c,[2,21]),t(c,[2,22]),t(c,[2,23]),t(c,[2,24]),{29:42,30:[1,43],52:[1,44],53:[1,45]},t(c,[2,27]),{33:[1,46]},{35:[1,47]},t(c,[2,30]),{38:[1,48],40:[1,49]},{42:[1,50]},t(et,[2,40],{51:[1,51]}),t(et,[2,41],{51:[1,52]}),t(c,[2,34]),t(c,[2,35]),t(c,[2,36]),t(c,[2,37]),t(c,[2,6]),t(c,[2,12]),{12:53,23:R,50:w},t(c,[2,16]),t(Dt,f,{7:54}),{23:[1,55]},{23:[1,56]},{22:[1,57]},{23:[2,44]},{23:[2,45]},t(c,[2,28]),t(c,[2,29]),{39:[1,58]},{39:[1,59]},{43:[1,60]},{23:[1,61]},{23:[1,62]},t(c,[2,13],{13:[1,63]}),{4:d,5:y,8:8,9:10,10:12,11:13,12:14,15:k,16:u,18:E,20:[1,64],21:T,23:R,24:G,25:j,26:U,27:z,28:M,31:24,32:H,34:X,36:K,37:W,41:J,44:q,45:Q,46:Z,47:tt,50:w},t(c,[2,19],{19:[1,65]}),{30:[1,66]},{23:[1,67]},t(c,[2,31]),t(c,[2,32]),t(c,[2,33]),t(et,[2,42]),t(et,[2,43]),t(c,[2,14]),t(c,[2,18]),t(Dt,f,{7:68}),t(c,[2,25]),t(c,[2,26]),{4:d,5:y,8:8,9:10,10:12,11:13,12:14,15:k,16:u,18:E,20:[1,69],21:T,23:R,24:G,25:j,26:U,27:z,28:M,31:24,32:H,34:X,36:K,37:W,41:J,44:q,45:Q,46:Z,47:tt,50:w},t(c,[2,20])],defaultActions:{5:[2,1],6:[2,2],44:[2,44],45:[2,45]},parseError:function(r,n){if(n.recoverable)this.trace(r);else{var i=new Error(r);throw i.hash=n,i}},parse:function(r){var n=this,i=[0],o=[],p=[null],e=[],$=this.table,l="",v=0,O=0,st=2,B=1,ft=e.slice.call(arguments,1),S=Object.create(this.lexer),A={yy:{}};for(var dt in this.yy)Object.prototype.hasOwnProperty.call(this.yy,dt)&&(A.yy[dt]=this.yy[dt]);S.setInput(r,A.yy),A.yy.lexer=S,A.yy.parser=this,typeof S.yylloc>"u"&&(S.yylloc={});var yt=S.yylloc;e.push(yt);var Gt=S.options&&S.options.ranges;typeof A.yy.parseError=="function"?this.parseError=A.yy.parseError:this.parseError=Object.getPrototypeOf(this).parseError;function jt(){var x;return x=o.pop()||S.lex()||B,typeof x!="number"&&(x instanceof Array&&(o=x,x=o.pop()),x=n.symbols_[x]||x),x}for(var _,L,m,pt,N={},it,b,Ct,rt;;){if(L=i[i.length-1],this.defaultActions[L]?m=this.defaultActions[L]:((_===null||typeof _>"u")&&(_=jt()),m=$[L]&&$[L][_]),typeof m>"u"||!m.length||!m[0]){var St="";rt=[];for(it in $[L])this.terminals_[it]&&it>st&&rt.push("'"+this.terminals_[it]+"'");S.showPosition?St="Parse error on line "+(v+1)+`:
|
|
2
2
|
`+S.showPosition()+`
|
|
3
3
|
Expecting `+rt.join(", ")+", got '"+(this.terminals_[_]||_)+"'":St="Parse error on line "+(v+1)+": Unexpected "+(_==B?"end of input":"'"+(this.terminals_[_]||_)+"'"),this.parseError(St,{text:S.match,token:this.terminals_[_]||_,line:S.yylineno,loc:yt,expected:rt})}if(m[0]instanceof Array&&m.length>1)throw new Error("Parse Error: multiple actions possible at state: "+L+", token: "+_);switch(m[0]){case 1:i.push(_),p.push(S.yytext),e.push(S.yylloc),i.push(m[1]),_=null,O=S.yyleng,l=S.yytext,v=S.yylineno,yt=S.yylloc;break;case 2:if(b=this.productions_[m[1]][1],N.$=p[p.length-b],N._$={first_line:e[e.length-(b||1)].first_line,last_line:e[e.length-1].last_line,first_column:e[e.length-(b||1)].first_column,last_column:e[e.length-1].last_column},Gt&&(N._$.range=[e[e.length-(b||1)].range[0],e[e.length-1].range[1]]),pt=this.performAction.apply(N,[l,O,v,A.yy,m[1],p,e].concat(ft)),typeof pt<"u")return pt;b&&(i=i.slice(0,-1*b*2),p=p.slice(0,-1*b),e=e.slice(0,-1*b)),i.push(this.productions_[m[1]][0]),p.push(N.$),e.push(N._$),Ct=$[i[i.length-2]][i[i.length-1]],i.push(Ct);break;case 3:return!0}}return!0}},Yt=(function(){var C={EOF:1,parseError:function(n,i){if(this.yy.parser)this.yy.parser.parseError(n,i);else throw new Error(n)},setInput:function(r,n){return this.yy=n||this.yy||{},this._input=r,this._more=this._backtrack=this.done=!1,this.yylineno=this.yyleng=0,this.yytext=this.matched=this.match="",this.conditionStack=["INITIAL"],this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0},this.options.ranges&&(this.yylloc.range=[0,0]),this.offset=0,this},input:function(){var r=this._input[0];this.yytext+=r,this.yyleng++,this.offset++,this.match+=r,this.matched+=r;var n=r.match(/(?:\r\n?|\n).*/g);return n?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),r},unput:function(r){var n=r.length,i=r.split(/(?:\r\n?|\n)/g);this._input=r+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-n),this.offset-=n;var o=this.match.split(/(?:\r\n?|\n)/g);this.match=this.match.substr(0,this.match.length-1),this.matched=this.matched.substr(0,this.matched.length-1),i.length-1&&(this.yylineno-=i.length-1);var p=this.yylloc.range;return this.yylloc={first_line:this.yylloc.first_line,last_line:this.yylineno+1,first_column:this.yylloc.first_column,last_column:i?(i.length===o.length?this.yylloc.first_column:0)+o[o.length-i.length].length-i[0].length:this.yylloc.first_column-n},this.options.ranges&&(this.yylloc.range=[p[0],p[0]+this.yyleng-n]),this.yyleng=this.yytext.length,this},more:function(){return this._more=!0,this},reject:function(){if(this.options.backtrack_lexer)this._backtrack=!0;else return this.parseError("Lexical error on line "+(this.yylineno+1)+`. You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).
|
|
4
4
|
`+this.showPosition(),{text:"",token:null,line:this.yylineno});return this},less:function(r){this.unput(this.match.slice(r))},pastInput:function(){var r=this.matched.substr(0,this.matched.length-this.match.length);return(r.length>20?"...":"")+r.substr(-20).replace(/\n/g,"")},upcomingInput:function(){var r=this.match;return r.length<20&&(r+=this._input.substr(0,20-r.length)),(r.substr(0,20)+(r.length>20?"...":"")).replace(/\n/g,"")},showPosition:function(){var r=this.pastInput(),n=new Array(r.length+1).join("-");return r+this.upcomingInput()+`
|