@wandox/sdk 0.1.16 → 0.1.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (94) hide show
  1. package/dist/{arc-DfJUxbRA.js → arc-BiIwGanw.js} +1 -1
  2. package/dist/{arc-CsfzO29z.cjs → arc-CpouD8oe.cjs} +1 -1
  3. package/dist/{architectureDiagram-3BPJPVTR-CMlOFrx1.cjs → architectureDiagram-3BPJPVTR-CWQiVWwK.cjs} +1 -1
  4. package/dist/{architectureDiagram-3BPJPVTR-BgQfE0_8.js → architectureDiagram-3BPJPVTR-D2tFvqRm.js} +3 -3
  5. package/dist/{blockDiagram-GPEHLZMM-CaKCyKq-.cjs → blockDiagram-GPEHLZMM-CMEX761j.cjs} +1 -1
  6. package/dist/{blockDiagram-GPEHLZMM-C8sJbcZl.js → blockDiagram-GPEHLZMM-iA5NKv8O.js} +3 -3
  7. package/dist/{c4Diagram-AAUBKEIU-DCqDuv3p.cjs → c4Diagram-AAUBKEIU-DoNMxR6D.cjs} +1 -1
  8. package/dist/{c4Diagram-AAUBKEIU-BOeKZHef.js → c4Diagram-AAUBKEIU-IGkIhqfq.js} +2 -2
  9. package/dist/{channel-DeCWxwwz.cjs → channel-D_GHpxeV.cjs} +1 -1
  10. package/dist/{channel-BQFQZzg5.js → channel-yCpYeMG1.js} +1 -1
  11. package/dist/{chunk-2J33WTMH-Cg4XDDXO.js → chunk-2J33WTMH-CxBRFh-l.js} +1 -1
  12. package/dist/{chunk-2J33WTMH-D1REk2hS.cjs → chunk-2J33WTMH-P6wbOwWu.cjs} +1 -1
  13. package/dist/{chunk-4BX2VUAB-DW0S1iT3.js → chunk-4BX2VUAB-B_fowtP3.js} +1 -1
  14. package/dist/{chunk-4BX2VUAB-DY2E1yZ1.cjs → chunk-4BX2VUAB-CyF61UQO.cjs} +1 -1
  15. package/dist/{chunk-55IACEB6-ChYF6IRK.js → chunk-55IACEB6-BNlcSWeb.js} +1 -1
  16. package/dist/{chunk-55IACEB6-DyIRT7DP.cjs → chunk-55IACEB6-CJ3XI1YQ.cjs} +1 -1
  17. package/dist/{chunk-727SXJPM-du4yfJFK.cjs → chunk-727SXJPM-ByMxyBrS.cjs} +1 -1
  18. package/dist/{chunk-727SXJPM-DmNQfVSE.js → chunk-727SXJPM-DGAZasiz.js} +5 -5
  19. package/dist/{chunk-AQP2D5EJ-DSTxpRdH.cjs → chunk-AQP2D5EJ-5hubGj8C.cjs} +1 -1
  20. package/dist/{chunk-AQP2D5EJ-vb0Qn1D_.js → chunk-AQP2D5EJ-mmzP1GN7.js} +3 -3
  21. package/dist/{chunk-FMBD7UC4-CLoKM2E6.cjs → chunk-FMBD7UC4-BDl5ML14.cjs} +1 -1
  22. package/dist/{chunk-FMBD7UC4-DEAePuQA.js → chunk-FMBD7UC4-BKJ7DC1A.js} +1 -1
  23. package/dist/{chunk-ND2GUHAM-69hoJhWg.cjs → chunk-ND2GUHAM-CdHu8FUh.cjs} +1 -1
  24. package/dist/{chunk-ND2GUHAM-Dh5AR5X5.js → chunk-ND2GUHAM-DLyT8rfH.js} +1 -1
  25. package/dist/{chunk-QZHKN3VN-cyxpV0XX.js → chunk-QZHKN3VN-B4mrca-B.js} +1 -1
  26. package/dist/{chunk-QZHKN3VN-BfSnC2oN.cjs → chunk-QZHKN3VN-CQo7mRWq.cjs} +1 -1
  27. package/dist/{classDiagram-4FO5ZUOK-wB8m_z6V.js → classDiagram-4FO5ZUOK-C3s5cQvr.js} +2 -2
  28. package/dist/{classDiagram-4FO5ZUOK-CYC9CFWP.cjs → classDiagram-4FO5ZUOK-DASEFnts.cjs} +1 -1
  29. package/dist/{classDiagram-v2-Q7XG4LA2-CYC9CFWP.cjs → classDiagram-v2-Q7XG4LA2-DASEFnts.cjs} +1 -1
  30. package/dist/{classDiagram-v2-Q7XG4LA2-DUejWI0X.js → classDiagram-v2-Q7XG4LA2-DYLg0Zzv.js} +2 -2
  31. package/dist/{cose-bilkent-S5V4N54A-DdfSVwnX.js → cose-bilkent-S5V4N54A-CQPiZZ_u.js} +2 -2
  32. package/dist/{cose-bilkent-S5V4N54A-XaJyoVCi.cjs → cose-bilkent-S5V4N54A-ChOvvRNP.cjs} +1 -1
  33. package/dist/{dagre-BM42HDAG-ISroSaT1.js → dagre-BM42HDAG-Cb0Yf9S8.js} +1 -1
  34. package/dist/{dagre-BM42HDAG-CiSRHlhW.cjs → dagre-BM42HDAG-Chh0F3M-.cjs} +1 -1
  35. package/dist/{diagram-2AECGRRQ-Dt8m3e8V.cjs → diagram-2AECGRRQ-CDM19xUc.cjs} +1 -1
  36. package/dist/{diagram-2AECGRRQ-XLfqRckY.js → diagram-2AECGRRQ-DVBoWnA6.js} +2 -2
  37. package/dist/{diagram-5GNKFQAL-CS0rqFc1.cjs → diagram-5GNKFQAL-2ZHO1nxu.cjs} +1 -1
  38. package/dist/{diagram-5GNKFQAL-BPiQ2I-I.js → diagram-5GNKFQAL-BCbuyVew.js} +3 -3
  39. package/dist/{diagram-KO2AKTUF-BCYMR8SH.cjs → diagram-KO2AKTUF-BVZiY9Tx.cjs} +1 -1
  40. package/dist/{diagram-KO2AKTUF-C6TEUHLx.js → diagram-KO2AKTUF-YkENd2j0.js} +2 -2
  41. package/dist/{diagram-LMA3HP47-CYETpN-A.cjs → diagram-LMA3HP47-0oBGHRYM.cjs} +1 -1
  42. package/dist/{diagram-LMA3HP47-B-7ywAei.js → diagram-LMA3HP47-MHVa6XzT.js} +2 -2
  43. package/dist/{diagram-OG6HWLK6-B0lLbhYD.cjs → diagram-OG6HWLK6-CObv6Bof.cjs} +1 -1
  44. package/dist/{diagram-OG6HWLK6-BUhVHyW5.js → diagram-OG6HWLK6-Dv2R59H6.js} +3 -3
  45. package/dist/{erDiagram-TEJ5UH35-v70Ltqvn.js → erDiagram-TEJ5UH35-BAyT4JR0.js} +4 -4
  46. package/dist/{erDiagram-TEJ5UH35-DFzn0ZbT.cjs → erDiagram-TEJ5UH35-DktGB2-s.cjs} +1 -1
  47. package/dist/{flowDiagram-I6XJVG4X-DY28mikx.js → flowDiagram-I6XJVG4X-BexZcx3p.js} +6 -6
  48. package/dist/{flowDiagram-I6XJVG4X-Pcfu3vuJ.cjs → flowDiagram-I6XJVG4X-CB1eW0F-.cjs} +1 -1
  49. package/dist/{ganttDiagram-6RSMTGT7-Cx8jcCuI.js → ganttDiagram-6RSMTGT7-OiAIyumu.js} +3 -3
  50. package/dist/{ganttDiagram-6RSMTGT7-CfVc0o67.cjs → ganttDiagram-6RSMTGT7-ehtQ-GRp.cjs} +1 -1
  51. package/dist/{gitGraphDiagram-PVQCEYII-Bkn7-zgB.js → gitGraphDiagram-PVQCEYII-C3NN83BU.js} +3 -3
  52. package/dist/{gitGraphDiagram-PVQCEYII-ix51FBNd.cjs → gitGraphDiagram-PVQCEYII-DEoCUQw7.cjs} +1 -1
  53. package/dist/{index-rRdnxhHQ.cjs → index-BuPvvTGV.cjs} +3 -3
  54. package/dist/{index-BfHrdDcA.js → index-D1uRHSwz.js} +50 -36
  55. package/dist/{infoDiagram-5YYISTIA-BPtSFQxX.cjs → infoDiagram-5YYISTIA-De67pSa6.cjs} +1 -1
  56. package/dist/{infoDiagram-5YYISTIA-BXIxXQr4.js → infoDiagram-5YYISTIA-YCgZxujL.js} +1 -1
  57. package/dist/{ishikawaDiagram-YF4QCWOH-B9ck1yv0.cjs → ishikawaDiagram-YF4QCWOH-CWWwP8UD.cjs} +1 -1
  58. package/dist/{ishikawaDiagram-YF4QCWOH-vxyfmU_G.js → ishikawaDiagram-YF4QCWOH-DoGl2Irx.js} +1 -1
  59. package/dist/{journeyDiagram-JHISSGLW-CPLe2wSN.js → journeyDiagram-JHISSGLW-BgrZ5o3n.js} +4 -4
  60. package/dist/{journeyDiagram-JHISSGLW-ClbMu06t.cjs → journeyDiagram-JHISSGLW-CtpyScSO.cjs} +1 -1
  61. package/dist/{kanban-definition-UN3LZRKU-B6QyGMMK.cjs → kanban-definition-UN3LZRKU-BElOkeDR.cjs} +1 -1
  62. package/dist/{kanban-definition-UN3LZRKU-C3CozqON.js → kanban-definition-UN3LZRKU-cqLHsYAi.js} +2 -2
  63. package/dist/{linear-Bux2KGCG.cjs → linear-CqwOOQ-Z.cjs} +1 -1
  64. package/dist/{linear-D5P2O-Rc.js → linear-Jsa4RQAc.js} +1 -1
  65. package/dist/{mermaid.core-BUjL8Puw.js → mermaid.core-BHydGcM6.js} +35 -35
  66. package/dist/{mermaid.core-BTWv8WFQ.cjs → mermaid.core-Dt-c0mRU.cjs} +3 -3
  67. package/dist/{mindmap-definition-RKZ34NQL-CVZioQjg.js → mindmap-definition-RKZ34NQL-CNKxNhQe.js} +3 -3
  68. package/dist/{mindmap-definition-RKZ34NQL-gCRQhqPj.cjs → mindmap-definition-RKZ34NQL-Cz4lirxX.cjs} +1 -1
  69. package/dist/{pieDiagram-4H26LBE5-CIFwb_0b.cjs → pieDiagram-4H26LBE5-Cff2v5R6.cjs} +1 -1
  70. package/dist/{pieDiagram-4H26LBE5-C9Y_Wd2w.js → pieDiagram-4H26LBE5-DQ5Qhvce.js} +3 -3
  71. package/dist/{quadrantDiagram-W4KKPZXB-CdPK68Sn.cjs → quadrantDiagram-W4KKPZXB-D-Ly3obl.cjs} +1 -1
  72. package/dist/{quadrantDiagram-W4KKPZXB-NfJym4V2.js → quadrantDiagram-W4KKPZXB-DYrihjnq.js} +2 -2
  73. package/dist/{requirementDiagram-4Y6WPE33-kt9SkbEy.cjs → requirementDiagram-4Y6WPE33-CuvutjiA.cjs} +1 -1
  74. package/dist/{requirementDiagram-4Y6WPE33-CHRIoEJ1.js → requirementDiagram-4Y6WPE33-Dv3qQK0a.js} +3 -3
  75. package/dist/{sankeyDiagram-5OEKKPKP-D53U_THX.js → sankeyDiagram-5OEKKPKP-CQQBvZ-V.js} +1 -1
  76. package/dist/{sankeyDiagram-5OEKKPKP-CnvbIXk1.cjs → sankeyDiagram-5OEKKPKP-D9iFv1rX.cjs} +1 -1
  77. package/dist/{sequenceDiagram-3UESZ5HK-Dm9kvFL_.cjs → sequenceDiagram-3UESZ5HK-DSJdFQst.cjs} +1 -1
  78. package/dist/{sequenceDiagram-3UESZ5HK-BKtlr7hf.js → sequenceDiagram-3UESZ5HK-DzTEX_rH.js} +3 -3
  79. package/dist/{stateDiagram-AJRCARHV-CSJjeeq3.js → stateDiagram-AJRCARHV-C0N6zPsb.js} +2 -2
  80. package/dist/{stateDiagram-AJRCARHV-21KZR5HQ.cjs → stateDiagram-AJRCARHV-s8Js59xn.cjs} +1 -1
  81. package/dist/{stateDiagram-v2-BHNVJYJU-J4jbmeTz.js → stateDiagram-v2-BHNVJYJU-BAMO2o3s.js} +2 -2
  82. package/dist/{stateDiagram-v2-BHNVJYJU-DzNKivd1.cjs → stateDiagram-v2-BHNVJYJU-Be-x2UAT.cjs} +1 -1
  83. package/dist/{timeline-definition-PNZ67QCA-s6X4cslm.js → timeline-definition-PNZ67QCA-B7-vXASh.js} +2 -2
  84. package/dist/{timeline-definition-PNZ67QCA-G2DGR5Yw.cjs → timeline-definition-PNZ67QCA-hXWwj2q1.cjs} +1 -1
  85. package/dist/{vennDiagram-CIIHVFJN-DQylqjL1.cjs → vennDiagram-CIIHVFJN-DgtuTXoe.cjs} +1 -1
  86. package/dist/{vennDiagram-CIIHVFJN-3XAI0_zh.js → vennDiagram-CIIHVFJN-RXPsvQwU.js} +1 -1
  87. package/dist/wandox.cjs +1 -1
  88. package/dist/wandox.js +1 -1
  89. package/dist/wandox.umd.js +1 -1
  90. package/dist/{wardleyDiagram-YWT4CUSO-DfYgCV3H.js → wardleyDiagram-YWT4CUSO-BO3XRNid.js} +2 -2
  91. package/dist/{wardleyDiagram-YWT4CUSO-BNLAbDUn.cjs → wardleyDiagram-YWT4CUSO-JNb2YN_-.cjs} +1 -1
  92. package/dist/{xychartDiagram-2RQKCTM6-CqeoB69k.js → xychartDiagram-2RQKCTM6-BIg7ZGzM.js} +2 -2
  93. package/dist/{xychartDiagram-2RQKCTM6-wl6VMh2w.cjs → xychartDiagram-2RQKCTM6-D9skeBOL.cjs} +1 -1
  94. package/package.json +1 -1
@@ -765,7 +765,7 @@ $3`).replace(/(\*\*[^*\n]+:\*\*)-/g,`$1
765
765
  `),De=Qe.slice(we+1),Ne=De.lastIndexOf("@");if(Ne!==-1&&((Ne>0?De[Ne-1]:" ")===" "||Ne===0)){const Je=De.slice(Ne+1);if(!Je.includes(" ")&&!Je.includes(`
766
766
  `)){G(we+1+Ne),H(Je),V(!0);return}}V(!1)},Pe=Le=>{if(B&&q.length>0){if(Le.key==="ArrowDown"){Le.preventDefault(),X(rt=>rt<q.length-1?rt+1:0);return}if(Le.key==="ArrowUp"){Le.preventDefault(),X(rt=>rt>0?rt-1:q.length-1);return}if(Le.key==="Enter"||Le.key==="Tab"){Le.preventDefault(),Oe(q[K]);return}if(Le.key==="Escape"){Le.preventDefault(),V(!1);return}}if(Le.key==="Enter"&&!Le.shiftKey&&!n){if(!w.trim()&&$&&r&&P.length===0){Le.preventDefault(),O();return}(w.trim()||P.length>0)&&(Le.preventDefault(),Ze())}if(Le.key===" "&&!n&&!w.trim()&&$&&r&&P.length===0){Le.preventDefault(),O();return}},Oe=async Le=>{var Fe;const rt=String(Le.playbook_id||"").trim();if(!rt){V(!1),Promise.resolve().then(()=>GO).then(({message:Je})=>Je.error("剧本参数加载失败,请稍后重试"));return}if(J.current)return;const Ee=++re.current,Qe=be.current,we=w,De=W,Ne=z;J.current=rt,pe.current=Qe,Q(rt),V(!1);try{const{data:Je}=await zA({playbook_id:rt});if(Ee!==re.current||Qe!==be.current)return;if(!Je||typeof Je!="object"||Array.isArray(Je))throw new Error("剧本详情为空");const Ge=_0t(Le,Je);if(!((Fe=Ge.input_fields)!=null&&Fe.length)){S(""),ne(null),A(!0),s(Ge.name,Ge.playbook_id);return}const Ke=we.slice(0,De),_e=we.slice(De+1+Ne.length);if(g){S(`${Ke}${_e}`),g(Ge);return}ne(Ge);const pt=Ge.input_fields.map(Ye=>`${Ye.label}: `).join(`
767
767
  `),dt=`${Ke}${Ge.name},请提供以下参数:
768
- ${pt}${_e}`,vt=dt.indexOf(": ")+2;S(dt),setTimeout(()=>{var Ye;if(_.current){_.current.focus();const st=(Ye=_.current.resizableTextArea)==null?void 0:Ye.textArea;st==null||st.setSelectionRange(vt,vt)}},0)}catch{if(Ee!==re.current||Qe!==be.current)return;V(!0),Promise.resolve().then(()=>GO).then(({message:Ge})=>Ge.error("剧本参数加载失败,请稍后重试"))}finally{Ee===re.current&&pe.current===Qe&&(pe.current="",J.current="",Q(""))}},Be=()=>{ne(null),S("")},Ze=async()=>{if(!w.trim()&&P.length===0||n||J.current)return;let Le=[];if(P.length>0){Le=await ve();for(const Qe of P)URL.revokeObjectURL(Qe.previewUrl);N([])}const rt=w.trim(),Ee=le==null?void 0:le.playbook_id;S(""),ne(null),xe.clear(),A(!0),s(rt,Ee,Le.length>0?Le:void 0)};return k.jsxs("div",{className:"wandox-chat-input",style:{position:"relative"},onDragEnter:te,onDragLeave:fe,onDragOver:ce,onDrop:he,children:[R&&k.jsx("div",{className:"wandox-chat-input-drag-overlay",children:k.jsxs("div",{className:"wandox-chat-input-drag-content",children:[k.jsx(hTr,{style:{fontSize:32,marginBottom:8}}),k.jsx("div",{children:"释放以发送图片"})]})}),k.jsx("input",{ref:D,type:"file",accept:"image/png,image/jpeg,image/jpg,image/gif,image/webp,image/bmp",multiple:!0,style:{display:"none"},onChange:$e}),B&&q.length>0&&k.jsx("div",{className:"wandox-mention-list",ref:T,children:k.jsx("div",{className:"wandox-mention-items",children:q.map((Le,rt)=>k.jsxs("div",{className:`wandox-mention-item ${rt===K?"wandox-mention-item--active":""}`,onClick:()=>Oe(Le),onKeyDown:()=>{},onMouseEnter:()=>X(rt),children:[k.jsx("div",{className:"wandox-mention-item-icon",children:"📋"}),k.jsxs("div",{className:"wandox-mention-item-content",children:[k.jsxs("div",{className:"wandox-mention-item-name",children:[Le.name,Le.input_fields&&Le.input_fields.length>0&&k.jsx("span",{className:"wandox-mention-item-tag",children:t("recommendation.params")})]}),Le.description&&k.jsx("div",{className:"wandox-mention-item-desc",children:Le.description})]})]},Le.playbook_id))})}),B&&q.length===0&&oe.length>0&&k.jsx("div",{className:"wandox-mention-list",ref:T,children:k.jsx("div",{className:"wandox-mention-empty",children:t("chatInput.noMatchingScenarios")})}),B&&oe.length===0&&k.jsx("div",{className:"wandox-mention-list",ref:T,children:k.jsx("div",{className:"wandox-mention-empty",children:t("chatInput.noAvailableScenarios")})}),k.jsx(T0t,{open:E&&!B&&!n&&!ee,rewrittenQuestion:xe.rewrittenQuestion,questions:xe.questions,loading:xe.loading,placement:"top",onSelectRewrite:Le=>{var rt;S(Le),xe.clear(),(rt=_.current)==null||rt.focus()},onSelectQuestion:Le=>{S(""),ne(null),A(!0),xe.clear(),s(Le.title)}}),ee&&k.jsx("output",{className:"wandox-chat-input-tag","aria-live":"polite",children:k.jsxs(as,{color:"blue",children:[k.jsx(yh,{spin:!0})," 正在读取剧本参数"]})}),le&&k.jsx("div",{className:"wandox-chat-input-tag",children:k.jsx(as,{color:"blue",closable:!0,onClose:Be,closeIcon:k.jsx(Ao,{}),children:le.name})}),$&&r&&!n&&!ee&&k.jsx("button",{className:"wandox-search-suggestion",onClick:O,onKeyDown:F,type:"button",style:{position:"absolute",top:"30px",left:"38px",color:"#999",cursor:"pointer",fontSize:"14px",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",maxWidth:"calc(100% - 80px)",zIndex:1,transition:"color 0.2s ease",background:"none",border:"none",padding:0,textAlign:"left"},onMouseEnter:Le=>{Le.currentTarget.style.color="#1890ff"},onMouseLeave:Le=>{Le.currentTarget.style.color="#999"},children:r}),P.length>0&&k.jsx("div",{className:"wandox-chat-input-previews",children:P.map(Le=>k.jsxs("div",{className:"wandox-chat-input-preview-item",children:[k.jsx("img",{src:Le.previewUrl,alt:Le.file.name,className:"wandox-chat-input-preview-img"}),k.jsx("button",{type:"button",className:"wandox-chat-input-preview-remove",onClick:()=>de(Le.id),title:"删除",children:k.jsx(Ao,{})})]},Le.id))}),k.jsx(Brn,{ref:_,placeholder:$&&r&&!n?"":o||t("chat.input.placeholder"),value:w,disabled:n||ee,onChange:He,onKeyDown:Pe,onPaste:ae,onFocus:()=>I(!0),onBlur:()=>window.setTimeout(()=>I(!1),120),autoSize:{minRows:1,maxRows:6},className:"wandox-chat-textarea",style:{position:"relative",zIndex:2,background:"transparent"}}),k.jsxs("div",{className:"wandox-chat-input-actions",children:[k.jsx("button",{type:"button",className:"wandox-chat-input-icon-btn",title:"上传图片",disabled:n||ee,onClick:Ie,children:k.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[k.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2",stroke:"currentColor",strokeWidth:"2"}),k.jsx("circle",{cx:"8.5",cy:"8.5",r:"1.5",fill:"currentColor"}),k.jsx("polyline",{points:"21 15 16 10 5 21",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]})}),k.jsx("button",{type:"button",className:`wandox-chat-input-icon-btn wandox-chat-input-send-btn${n?" wandox-chat-input-stop-btn":""}`,disabled:ee||(n?i||!a:!w.trim()&&P.length===0),onClick:n?a:Ze,title:n?i?"正在停止":"停止":t("chat.send"),children:n?k.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[k.jsx("circle",{cx:"12",cy:"12",r:"8",stroke:"currentColor",strokeWidth:"2"}),k.jsx("rect",{x:"9",y:"9",width:"6",height:"6",rx:"1",fill:"currentColor"})]}):k.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:k.jsx("path",{d:"M12 19V5M12 5L5 12M12 5L19 12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})]})]})}const L9=[{id:"robot",name:"机器人",description:"紫色渐变机器人头像",component:k.jsxs("svg",{viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[k.jsxs("g",{clipPath:"url(#clip0_2019_548)",children:[k.jsx("path",{d:"M36 0H12C5.37258 0 0 5.37258 0 12V36C0 42.6274 5.37258 48 12 48H36C42.6274 48 48 42.6274 48 36V12C48 5.37258 42.6274 0 36 0Z",fill:"url(#paint0_linear_2019_548)"}),k.jsx("path",{d:"M24 12L28 16L24 20L20 16L24 12Z",fill:"white",fillOpacity:"0.95"}),k.jsx("path",{d:"M24 30C27.3137 30 30 27.3137 30 24C30 20.6863 27.3137 18 24 18C20.6863 18 18 20.6863 18 24C18 27.3137 20.6863 30 24 30Z",fill:"white",fillOpacity:"0.95"}),k.jsx("path",{d:"M16 28L12 24L16 20L20 24L16 28Z",fill:"white",fillOpacity:"0.8"}),k.jsx("path",{d:"M32 28L28 24L32 20L36 24L32 28Z",fill:"white",fillOpacity:"0.8"}),k.jsx("path",{d:"M24 36L20 32L24 28L28 32L24 36Z",fill:"white",fillOpacity:"0.8"})]}),k.jsxs("defs",{children:[k.jsxs("linearGradient",{id:"paint0_linear_2019_548",x1:"0",y1:"0",x2:"48",y2:"48",gradientUnits:"userSpaceOnUse",children:[k.jsx("stop",{stopColor:"#8B5CF6"}),k.jsx("stop",{offset:"1",stopColor:"#6366F1"})]}),k.jsx("clipPath",{id:"clip0_2019_548",children:k.jsx("rect",{width:"48",height:"48",fill:"white"})})]})]},"icon-robot")},{id:"amazon",name:"亚马逊",description:"橙色渐变亚马逊图标",component:k.jsxs("svg",{viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[k.jsx("path",{d:"M36 0H12C5.37258 0 0 5.37258 0 12V36C0 42.6274 5.37258 48 12 48H36C42.6274 48 48 42.6274 48 36V12C48 5.37258 42.6274 0 36 0Z",fill:"url(#paint0_linear_2026_532)"}),k.jsx("path",{d:"M14.7195 25.2724C14.7195 29.2324 17.217 31.2124 20.4345 31.2124C23.157 31.2124 24.6195 30.5824 26.712 28.4449C27.4095 29.4574 27.6345 29.9299 28.8945 30.9874C29.187 31.1449 29.547 31.1224 29.7945 30.8974C30.5595 30.2224 31.932 29.0074 32.7195 28.3549C33.0345 28.1074 32.967 27.6799 32.742 27.3424C32.0445 26.3749 31.302 25.5874 31.302 23.8099V17.8699C31.302 15.3499 31.482 13.0324 29.6145 11.2999C28.1745 9.90491 25.7445 9.40991 23.877 9.40991C20.2545 9.40991 16.2045 10.7599 15.3495 15.2599C15.2595 15.7324 15.6195 15.9799 15.9345 16.0474L19.6245 16.4524C19.962 16.4299 20.232 16.0924 20.277 15.7549C20.592 14.2024 21.897 13.4599 23.337 13.4599C24.1245 13.4599 25.0245 13.7524 25.4745 14.4499C26.0145 15.2374 25.947 16.3174 25.947 17.2174V17.7124C23.742 17.9599 20.862 18.1174 18.792 19.0399C16.3845 20.0749 14.7195 22.1674 14.7195 25.2724ZM25.947 20.7724V21.6049C25.947 23.0899 25.992 24.3274 25.227 25.6549C24.6195 26.7349 23.652 27.3874 22.5945 27.3874C21.132 27.3874 20.277 26.2624 20.277 24.6199C20.277 21.3574 23.202 20.7724 25.947 20.7724ZM33.9795 32.6749C30.762 34.0474 27.2745 34.6999 24.102 34.6999C19.3995 34.6999 14.832 33.4174 11.1645 31.2574C10.8495 31.0774 10.602 31.3924 10.872 31.6399C14.4197 34.8374 19.0336 36.5947 23.8095 36.5674C27.387 36.5674 31.527 35.4424 34.407 33.3274C34.8795 32.9899 34.4745 32.4724 33.9795 32.6749Z",fill:"white",fillOpacity:"0.95"}),k.jsx("path",{d:"M36.8146 31.0551C36.4996 30.6726 33.8221 30.3351 32.1796 31.4826C31.9321 31.6626 31.9771 31.9101 32.2471 31.8651C33.1696 31.7526 35.2171 31.5051 35.5996 31.9776C35.9596 32.4501 35.1946 34.3851 34.8571 35.2401C34.7446 35.5101 34.9696 35.6001 35.2171 35.3976C36.7246 34.1376 37.1296 31.4376 36.8146 31.0551Z",fill:"white",fillOpacity:"0.8"}),k.jsx("defs",{children:k.jsxs("linearGradient",{id:"paint0_linear_2026_532",x1:"0",y1:"0",x2:"48",y2:"48",gradientUnits:"userSpaceOnUse",children:[k.jsx("stop",{stopColor:"#FF6B35"}),k.jsx("stop",{offset:"1",stopColor:"#F7931E"})]})})]},"icon-amazon")},{id:"star",name:"星星",description:"绿色渐变星星图标",component:k.jsxs("svg",{viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[k.jsxs("g",{clipPath:"url(#clip0_2019_574)",children:[k.jsx("path",{d:"M36 0H12C5.37258 0 0 5.37258 0 12V36C0 42.6274 5.37258 48 12 48H36C42.6274 48 48 42.6274 48 36V12C48 5.37258 42.6274 0 36 0Z",fill:"url(#paint0_linear_2019_574)"}),k.jsx("path",{d:"M18 14H14C12.8954 14 12 14.8954 12 16V20C12 21.1046 12.8954 22 14 22H18C19.1046 22 20 21.1046 20 20V16C20 14.8954 19.1046 14 18 14Z",fill:"white",fillOpacity:"0.95"}),k.jsx("path",{d:"M34 14H30C28.8954 14 28 14.8954 28 16V20C28 21.1046 28.8954 22 30 22H34C35.1046 22 36 21.1046 36 20V16C36 14.8954 35.1046 14 34 14Z",fill:"white",fillOpacity:"0.95"}),k.jsx("path",{d:"M26 26H22C20.8954 26 20 26.8954 20 28V32C20 33.1046 20.8954 34 22 34H26C27.1046 34 28 33.1046 28 32V28C28 26.8954 27.1046 26 26 26Z",fill:"white",fillOpacity:"0.95"}),k.jsx("path",{d:"M16 22V26H20M32 22V26H28M24 26V22",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeOpacity:"0.8"}),k.jsx("path",{d:"M18 30L14 34M30 30L34 34M24 34V36",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeOpacity:"0.8"}),k.jsx("path",{d:"M14 36C15.1046 36 16 35.1046 16 34C16 32.8954 15.1046 32 14 32C12.8954 32 12 32.8954 12 34C12 35.1046 12.8954 36 14 36Z",fill:"white",fillOpacity:"0.7"}),k.jsx("path",{d:"M34 36C35.1046 36 36 35.1046 36 34C36 32.8954 35.1046 32 34 32C32.8954 32 32 32.8954 32 34C32 35.1046 32.8954 36 34 36Z",fill:"white",fillOpacity:"0.7"}),k.jsx("path",{d:"M24 40C25.1046 40 26 39.1046 26 38C26 36.8954 25.1046 36 24 36C22.8954 36 22 36.8954 22 38C22 39.1046 22.8954 40 24 40Z",fill:"white",fillOpacity:"0.7"})]}),k.jsxs("defs",{children:[k.jsxs("linearGradient",{id:"paint0_linear_2019_574",x1:"0",y1:"0",x2:"48",y2:"48",gradientUnits:"userSpaceOnUse",children:[k.jsx("stop",{stopColor:"#10B981"}),k.jsx("stop",{offset:"1",stopColor:"#059669"})]}),k.jsx("clipPath",{id:"clip0_2019_574",children:k.jsx("rect",{width:"48",height:"48",fill:"white"})})]})]},"icon-star")},{id:"gear",name:"齿轮",description:"绿色渐变齿轮图标",component:k.jsxs("svg",{viewBox:"0 0 40 40",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[k.jsx("defs",{children:k.jsxs("linearGradient",{id:"grad4",x1:"0%",y1:"0%",x2:"100%",y2:"100%",children:[k.jsx("stop",{offset:"0%",stopColor:"#14B8A6"}),k.jsx("stop",{offset:"100%",stopColor:"#0891B2"})]})}),k.jsx("rect",{width:"40",height:"40",rx:"12",fill:"url(#grad4)"}),k.jsx("circle",{cx:"20",cy:"20",r:"5",stroke:"white",strokeWidth:"2.5",fill:"none",strokeOpacity:"0.95"}),k.jsx("path",{d:"M20 8V12M20 28V32M8 20H12M28 20H32M11.5 11.5L14.5 14.5M25.5 25.5L28.5 28.5M28.5 11.5L25.5 14.5M14.5 25.5L11.5 28.5",stroke:"white",strokeWidth:"2.5",strokeLinecap:"round",strokeOpacity:"0.8"})]},"icon-gear")},{id:"magic",name:"魔法棒",description:"粉色渐变魔法棒图标",component:k.jsxs("svg",{viewBox:"0 0 40 40",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[k.jsx("defs",{children:k.jsxs("linearGradient",{id:"grad5",x1:"0%",y1:"0%",x2:"100%",y2:"100%",children:[k.jsx("stop",{offset:"0%",stopColor:"#EC4899"}),k.jsx("stop",{offset:"100%",stopColor:"#A855F7"})]})}),k.jsx("rect",{width:"40",height:"40",rx:"12",fill:"url(#grad5)"}),k.jsx("path",{d:"M10 30L26 14L30 18L14 34L10 30Z",fill:"white",fillOpacity:"0.95"}),k.jsx("circle",{cx:"28",cy:"12",r:"2",fill:"white",fillOpacity:"0.8"}),k.jsx("circle",{cx:"32",cy:"18",r:"1.5",fill:"white",fillOpacity:"0.7"}),k.jsx("circle",{cx:"24",cy:"8",r:"1.5",fill:"white",fillOpacity:"0.7"})]},"icon-magic")},{id:"rocket",name:"火箭",description:"青色渐变火箭图标",component:k.jsxs("svg",{viewBox:"0 0 40 40",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[k.jsx("defs",{children:k.jsxs("linearGradient",{id:"grad6",x1:"0%",y1:"0%",x2:"100%",y2:"100%",children:[k.jsx("stop",{offset:"0%",stopColor:"#06B6D4"}),k.jsx("stop",{offset:"100%",stopColor:"#3B82F6"})]})}),k.jsx("rect",{width:"40",height:"40",rx:"12",fill:"url(#grad6)"}),k.jsx("path",{d:"M20 8C20 8 28 12 28 22L24 26L20 24L16 26L12 22C12 12 20 8 20 8Z",fill:"white",fillOpacity:"0.95"}),k.jsx("circle",{cx:"20",cy:"17",r:"2.5",fill:"url(#grad6)"}),k.jsx("path",{d:"M16 28L14 32L18 30L16 28Z",fill:"white",fillOpacity:"0.8"}),k.jsx("path",{d:"M24 28L26 32L22 30L24 28Z",fill:"white",fillOpacity:"0.8"})]},"icon-rocket")},{id:"music",name:"音乐",description:"粉紫渐变音乐图标",component:k.jsxs("svg",{viewBox:"0 0 40 40",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[k.jsx("defs",{children:k.jsxs("linearGradient",{id:"grad7",x1:"0%",y1:"0%",x2:"100%",y2:"100%",children:[k.jsx("stop",{offset:"0%",stopColor:"#EC4899"}),k.jsx("stop",{offset:"100%",stopColor:"#8B5CF6"})]})}),k.jsx("rect",{width:"40",height:"40",rx:"12",fill:"url(#grad7)"}),k.jsx("path",{d:"M26 8L14 11v11.2c-.8-.3-1.6-.5-2.5-.5-2.9 0-5.3 1.6-5.3 3.6s2.4 3.6 5.3 3.6 5.3-1.6 5.3-3.6V14.4l8.7-2.5v5.7c-.8-.3-1.6-.5-2.5-.5-2.9 0-5.3 1.6-5.3 3.6s2.4 3.6 5.3 3.6 5.3-1.6 5.3-3.6V8z",fill:"white",fillOpacity:"0.95"})]},"icon-music")},{id:"sports",name:"运动",description:"蓝绿渐变运动图标",component:k.jsxs("svg",{viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[k.jsx("defs",{children:k.jsxs("linearGradient",{id:"grad8",x1:"0%",y1:"0%",x2:"100%",y2:"100%",children:[k.jsx("stop",{offset:"0%",stopColor:"#06B6D4"}),k.jsx("stop",{offset:"100%",stopColor:"#10B981"})]})}),k.jsx("rect",{width:"48",height:"48",rx:"12",fill:"url(#grad8)"}),k.jsx("circle",{cx:"24",cy:"24",r:"12",stroke:"white",strokeWidth:"2",fill:"none",strokeOpacity:"0.95"}),k.jsx("path",{d:"M24 12L30 18L24 24L18 18L24 12Z",fill:"white",fillOpacity:"0.8"}),k.jsx("path",{d:"M24 24L30 30L24 36L18 30L24 24Z",fill:"white",fillOpacity:"0.8"}),k.jsx("path",{d:"M12 24L18 30L24 24L18 18L12 24Z",fill:"white",fillOpacity:"0.7"}),k.jsx("path",{d:"M24 24L30 18L36 24L30 30L24 24Z",fill:"white",fillOpacity:"0.7"})]},"icon-sports")},{id:"games",name:"游戏",description:"红橙渐变游戏图标",component:k.jsxs("svg",{viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[k.jsx("defs",{children:k.jsxs("linearGradient",{id:"grad9",x1:"0%",y1:"0%",x2:"100%",y2:"100%",children:[k.jsx("stop",{offset:"0%",stopColor:"#EF4444"}),k.jsx("stop",{offset:"100%",stopColor:"#F97316"})]})}),k.jsx("rect",{width:"48",height:"48",rx:"12",fill:"url(#grad9)"}),k.jsx("rect",{x:"12",y:"16",width:"8",height:"8",rx:"2",fill:"white",fillOpacity:"0.95"}),k.jsx("rect",{x:"28",y:"16",width:"8",height:"8",rx:"2",fill:"white",fillOpacity:"0.95"}),k.jsx("rect",{x:"20",y:"24",width:"8",height:"8",rx:"2",fill:"white",fillOpacity:"0.8"}),k.jsx("rect",{x:"12",y:"32",width:"8",height:"4",rx:"1",fill:"white",fillOpacity:"0.7"}),k.jsx("rect",{x:"28",y:"32",width:"8",height:"4",rx:"1",fill:"white",fillOpacity:"0.7"})]},"icon-games")},{id:"expenses",name:"财务",description:"金黄渐变财务图标",component:k.jsxs("svg",{viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[k.jsx("defs",{children:k.jsxs("linearGradient",{id:"grad10",x1:"0%",y1:"0%",x2:"100%",y2:"100%",children:[k.jsx("stop",{offset:"0%",stopColor:"#F59E0B"}),k.jsx("stop",{offset:"100%",stopColor:"#EAB308"})]})}),k.jsx("rect",{width:"48",height:"48",rx:"12",fill:"url(#grad10)"}),k.jsx("path",{d:"M24 12C18 12 13 17 13 23c0 4 2 7 5 9v2c0 2 2 4 4 4h4c2 0 4-2 4-4v-2c3-2 5-5 5-9 0-6-5-11-11-11z",fill:"white",fillOpacity:"0.95"}),k.jsx("rect",{x:"20",y:"34",width:"8",height:"2",rx:"1",fill:"white",fillOpacity:"0.8"}),k.jsx("circle",{cx:"21",cy:"20",r:"1.5",fill:"url(#grad10)"}),k.jsx("circle",{cx:"27",cy:"20",r:"1.5",fill:"url(#grad10)"})]},"icon-expenses")},{id:"sciences",name:"科学",description:"青蓝渐变科学图标",component:k.jsxs("svg",{viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[k.jsx("defs",{children:k.jsxs("linearGradient",{id:"grad11",x1:"0%",y1:"0%",x2:"100%",y2:"100%",children:[k.jsx("stop",{offset:"0%",stopColor:"#0EA5E9"}),k.jsx("stop",{offset:"100%",stopColor:"#3B82F6"})]})}),k.jsx("rect",{width:"48",height:"48",rx:"12",fill:"url(#grad11)"}),k.jsx("path",{d:"M12 36L20 28L28 36L36 28",stroke:"white",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",strokeOpacity:"0.95"}),k.jsx("circle",{cx:"24",cy:"16",r:"4",fill:"white",fillOpacity:"0.8"}),k.jsx("path",{d:"M24 20V28",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeOpacity:"0.7"}),k.jsx("circle",{cx:"16",cy:"32",r:"2",fill:"white",fillOpacity:"0.7"}),k.jsx("circle",{cx:"32",cy:"32",r:"2",fill:"white",fillOpacity:"0.7"})]},"icon-sciences")},{id:"magic-wand",name:"魔法",description:"紫粉渐变魔法图标",component:k.jsxs("svg",{viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[k.jsx("defs",{children:k.jsxs("linearGradient",{id:"grad12",x1:"0%",y1:"0%",x2:"100%",y2:"100%",children:[k.jsx("stop",{offset:"0%",stopColor:"#8B5CF6"}),k.jsx("stop",{offset:"100%",stopColor:"#EC4899"})]})}),k.jsx("rect",{width:"48",height:"48",rx:"12",fill:"url(#grad12)"}),k.jsx("path",{d:"M12 36L24 24L36 36L24 48L12 36Z",fill:"white",fillOpacity:"0.95"}),k.jsx("circle",{cx:"28",cy:"12",r:"2",fill:"white",fillOpacity:"0.8"}),k.jsx("circle",{cx:"36",cy:"20",r:"1.5",fill:"white",fillOpacity:"0.7"}),k.jsx("circle",{cx:"20",cy:"8",r:"1.5",fill:"white",fillOpacity:"0.7"}),k.jsx("circle",{cx:"32",cy:"4",r:"1",fill:"white",fillOpacity:"0.6"})]},"icon-magic-wand")},{id:"animals",name:"动物",description:"绿棕渐变动物图标",component:k.jsxs("svg",{viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[k.jsx("defs",{children:k.jsxs("linearGradient",{id:"grad13",x1:"0%",y1:"0%",x2:"100%",y2:"100%",children:[k.jsx("stop",{offset:"0%",stopColor:"#10B981"}),k.jsx("stop",{offset:"100%",stopColor:"#92400E"})]})}),k.jsx("rect",{width:"48",height:"48",rx:"12",fill:"url(#grad13)"}),k.jsx("ellipse",{cx:"24",cy:"28",rx:"10",ry:"8",fill:"white",fillOpacity:"0.95"}),k.jsx("circle",{cx:"20",cy:"26",r:"2",fill:"url(#grad13)"}),k.jsx("circle",{cx:"28",cy:"26",r:"2",fill:"url(#grad13)"}),k.jsx("path",{d:"M24 30C22 32 20 33 18 33",stroke:"white",strokeWidth:"1.5",strokeLinecap:"round",strokeOpacity:"0.8"}),k.jsx("circle",{cx:"18",cy:"18",r:"4",fill:"white",fillOpacity:"0.8"}),k.jsx("circle",{cx:"30",cy:"18",r:"4",fill:"white",fillOpacity:"0.8"})]},"icon-animals")},{id:"travel",name:"旅行",description:"天蓝渐变旅行图标",component:k.jsxs("svg",{viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[k.jsx("defs",{children:k.jsxs("linearGradient",{id:"grad14",x1:"0%",y1:"0%",x2:"100%",y2:"100%",children:[k.jsx("stop",{offset:"0%",stopColor:"#0EA5E9"}),k.jsx("stop",{offset:"100%",stopColor:"#06B6D4"})]})}),k.jsx("rect",{width:"48",height:"48",rx:"12",fill:"url(#grad14)"}),k.jsx("path",{d:"M8 32L16 16L32 16L40 32L32 40L16 40L8 32Z",fill:"white",fillOpacity:"0.95"}),k.jsx("circle",{cx:"24",cy:"24",r:"3",fill:"url(#grad14)"}),k.jsx("path",{d:"M24 28V32",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeOpacity:"0.8"}),k.jsx("rect",{x:"12",y:"36",width:"4",height:"2",rx:"1",fill:"white",fillOpacity:"0.7"}),k.jsx("rect",{x:"32",y:"36",width:"4",height:"2",rx:"1",fill:"white",fillOpacity:"0.7"})]},"icon-travel")},{id:"nature",name:"自然",description:"绿色渐变自然图标",component:k.jsxs("svg",{viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[k.jsx("defs",{children:k.jsxs("linearGradient",{id:"grad15",x1:"0%",y1:"0%",x2:"100%",y2:"100%",children:[k.jsx("stop",{offset:"0%",stopColor:"#22C55E"}),k.jsx("stop",{offset:"100%",stopColor:"#10B981"})]})}),k.jsx("rect",{width:"48",height:"48",rx:"12",fill:"url(#grad15)"}),k.jsx("path",{d:"M24 12C20 12 16 16 16 20C16 24 18 27 20 28V36C20 38 22 40 24 40C26 40 28 38 28 36V28C30 27 32 24 32 20C32 16 28 12 24 12Z",fill:"white",fillOpacity:"0.95"}),k.jsx("path",{d:"M24 12V20",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeOpacity:"0.8"}),k.jsx("path",{d:"M24 20L20 16M24 20L28 16",stroke:"white",strokeWidth:"1.5",strokeLinecap:"round",strokeOpacity:"0.7"})]},"icon-nature")},{id:"education",name:"教育",description:"深蓝渐变教育图标",component:k.jsxs("svg",{viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[k.jsx("defs",{children:k.jsxs("linearGradient",{id:"grad16",x1:"0%",y1:"0%",x2:"100%",y2:"100%",children:[k.jsx("stop",{offset:"0%",stopColor:"#1E40AF"}),k.jsx("stop",{offset:"100%",stopColor:"#3B82F6"})]})}),k.jsx("rect",{width:"48",height:"48",rx:"12",fill:"url(#grad16)"}),k.jsx("path",{d:"M24 8L8 16V24C8 32 14 38 24 40C34 38 40 32 40 24V16L24 8Z",fill:"white",fillOpacity:"0.95"}),k.jsx("circle",{cx:"24",cy:"22",r:"4",fill:"url(#grad16)"}),k.jsx("path",{d:"M24 26V30",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeOpacity:"0.8"}),k.jsx("path",{d:"M16 36L12 40L8 36",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",strokeOpacity:"0.7"})]},"icon-education")},{id:"health",name:"健康",description:"红色渐变健康图标",component:k.jsxs("svg",{viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[k.jsx("defs",{children:k.jsxs("linearGradient",{id:"grad17",x1:"0%",y1:"0%",x2:"100%",y2:"100%",children:[k.jsx("stop",{offset:"0%",stopColor:"#EF4444"}),k.jsx("stop",{offset:"100%",stopColor:"#DC2626"})]})}),k.jsx("rect",{width:"48",height:"48",rx:"12",fill:"url(#grad17)"}),k.jsx("rect",{x:"20",y:"12",width:"8",height:"24",rx:"4",fill:"white",fillOpacity:"0.95"}),k.jsx("rect",{x:"12",y:"20",width:"24",height:"8",rx:"4",fill:"white",fillOpacity:"0.95"}),k.jsx("circle",{cx:"24",cy:"24",r:"2",fill:"url(#grad17)"})]},"icon-health")},{id:"food",name:"美食",description:"橙色渐变美食图标",component:k.jsxs("svg",{viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[k.jsx("defs",{children:k.jsxs("linearGradient",{id:"grad18",x1:"0%",y1:"0%",x2:"100%",y2:"100%",children:[k.jsx("stop",{offset:"0%",stopColor:"#FB923C"}),k.jsx("stop",{offset:"100%",stopColor:"#F97316"})]})}),k.jsx("rect",{width:"48",height:"48",rx:"12",fill:"url(#grad18)"}),k.jsx("path",{d:"M16 16C16 12 20 8 24 8C28 8 32 12 32 16V32C32 36 28 40 24 40C20 40 16 36 16 32V16Z",fill:"white",fillOpacity:"0.95"}),k.jsx("circle",{cx:"20",cy:"20",r:"1.5",fill:"url(#grad18)"}),k.jsx("circle",{cx:"28",cy:"20",r:"1.5",fill:"url(#grad18)"}),k.jsx("path",{d:"M24 24C22 26 20 27 18 27",stroke:"white",strokeWidth:"1.5",strokeLinecap:"round",strokeOpacity:"0.8"}),k.jsx("path",{d:"M12 32L8 36L12 40",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",strokeOpacity:"0.7"})]},"icon-food")}],Frn="robot",D_=e=>{if(!e){const r=L9.find(n=>n.id===Frn);return(r==null?void 0:r.component)||L9[0].component}const t=L9.find(r=>r.id===e);return(t==null?void 0:t.component)||L9[0].component},zrn=new Map(L9.map(e=>[e.id,e]));function jrn({active:e,agents:t,collapsed:r,onToggle:n,className:i,activeView:a="chat",onViewChange:s,onToolboxOpen:o,showLogout:l,onLogout:u,sidebarAgentMode:d=!1,onToggleSidebarMode:h,onAgentSelect:f}){const p=localStorage.getItem("sso_domain")||"",g=[{key:"chat",icon:k.jsx(mXe,{}),title:"对话"},...["maiduo","eccang"].includes(p)?[{key:"plan",icon:k.jsx(Y_r,{}),title:"自动化Beta"}]:[],{key:"professional",icon:k.jsx(hXe,{}),title:"专业智能体"}],v=[...p==="yunduo"?[]:[{key:"toolbox",icon:k.jsx(LTr,{}),label:"工具箱"},{key:"goals",icon:k.jsx(v_r,{}),label:"目标追踪"}],{key:"settings",icon:k.jsx(zme,{}),label:"通知配置"}];return k.jsx("div",{className:"wandox-aside-wrap",children:k.jsxs("div",{className:`wandox-aside ${r?"wandox-aside--collapsed":""} ${i||""}`,"aria-hidden":r,children:[k.jsxs("div",{className:"wandox-aside-header",children:[k.jsx("span",{className:"wandox-aside-header__title",children:"AI 智能体"}),n&&k.jsx("button",{type:"button",className:"wandox-aside-header-toggle",onClick:n,"aria-label":r?"展开侧边栏":"收起侧边栏",title:r?"展开侧边栏":"收起侧边栏",children:k.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",fill:"none",viewBox:"0 0 24 24",children:[k.jsx("title",{children:r?"展开侧边栏":"收起侧边栏"}),k.jsx("path",{fill:"currentColor",d:"M21 5H11v14h10zM3 5h6v14H3zm0-2a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h18a2 2 0 0 0 2-2V5a2 2 0 0 0-2-2zm2 4.25a.75.75 0 0 0 0 1.5h2a.75.75 0 0 0 0-1.5zm-.75 3.5A.75.75 0 0 1 5 10h2a.75.75 0 0 1 0 1.5H5a.75.75 0 0 1-.75-.75m.75 2a.75.75 0 0 0 0 1.5h2a.75.75 0 0 0 0-1.5z"})]})})]}),k.jsx("div",{className:"wandox-aside-main-nav",children:k.jsx("div",{className:"wandox-aside-nav-list",children:g.map(y=>{const x=a===y.key,b=y.key==="professional";return k.jsxs("div",{children:[k.jsxs("div",{className:`wandox-aside-nav-item-wrap${x?" wandox-aside-nav-item-wrap--active":""}`,children:[k.jsxs("button",{type:"button",onClick:()=>s==null?void 0:s(y.key),className:`wandox-aside-nav-item${x?" wandox-aside-nav-item--active":""}`,children:[k.jsx("span",{className:"wandox-aside-nav-icon",children:y.icon}),k.jsx("span",{className:"wandox-aside-nav-title",children:y.title})]}),b&&!r&&h&&k.jsx(Ci,{title:d?"收起列表":"展开列表",placement:"right",children:k.jsx("button",{type:"button",className:`wandox-aside-mode-toggle${d?" wandox-aside-mode-toggle--active":""}`,onClick:w=>{w.stopPropagation(),h()},children:d?k.jsx(sme,{style:{fontSize:11}}):k.jsx(wA,{style:{fontSize:11}})})})]}),b&&(d||r)&&k.jsx("div",{className:"wandox-aside-agent-list",children:t.map(w=>{const S=w.agent_id;if(!S)return null;const _=e===S&&a==="professional";return k.jsx(Ci,{title:w.name,placement:"right",children:k.jsxs("button",{type:"button",className:`wandox-aside-agent-item${_?" wandox-aside-agent-item--active":""}`,onClick:()=>{f==null||f(S),a!=="professional"&&(s==null||s("professional"))},children:[k.jsx("span",{className:"wandox-aside-agent-icon",children:D_(w.icon)}),k.jsx("span",{className:"wandox-aside-agent-name",children:w.name})]})},S)})})]},y.key)})})}),k.jsxs("div",{className:"wandox-aside-bottom",children:[k.jsx("p",{className:"wandox-aside-group-label",children:"系统功能"}),k.jsxs("div",{className:"wandox-aside-nav-list wandox-aside-nav-list--bottom",children:[v.map(y=>{const x=y.key!=="toolbox"&&a===y.key;return k.jsxs("button",{type:"button",onClick:()=>{if(y.key==="toolbox"){o==null||o();return}s==null||s(y.key)},className:`wandox-aside-nav-item${x?" wandox-aside-nav-item--active":""}`,children:[k.jsx("span",{className:"wandox-aside-nav-icon",children:y.icon}),k.jsx("span",{className:"wandox-aside-nav-title",children:y.label})]},y.key)}),l&&k.jsxs("button",{type:"button",onClick:u,className:"wandox-aside-nav-item wandox-aside-nav-item--logout",children:[k.jsx("span",{className:"wandox-aside-nav-icon",children:k.jsx(vTr,{})}),k.jsx("span",{className:"wandox-aside-nav-title",children:"退出登录"})]})]}),k.jsx("div",{style:{height:8}})]})]})})}function E0t({title:e="正在进入指定智能体",description:t="正在加载智能体与剧本信息..."}){return k.jsxs("output",{className:"wandox-initial-route-loading","aria-label":e,children:[k.jsxs("div",{className:"wandox-initial-route-loading-aura","aria-hidden":"true",children:[Array.from({length:12},(r,n)=>({angle:n*30,delay:n*.08})).map(({angle:r,delay:n})=>k.jsx("span",{className:"wandox-chat-history-ray",style:{"--ray-angle":`${r}deg`,"--ray-delay":`${n}s`}},r)),k.jsx("div",{className:"wandox-chat-empty-icon",children:k.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[k.jsx("path",{d:"M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z"}),k.jsx("path",{d:"M20 2v4"}),k.jsx("path",{d:"M22 4h-4"}),k.jsx("circle",{cx:"4",cy:"20",r:"2"})]})})]}),k.jsx("div",{className:"wandox-initial-route-loading-title",children:e}),k.jsx("div",{className:"wandox-initial-route-loading-text",children:t})]})}function Vrn(e){const{children:t}=e;return k.jsx("div",{className:"wandox-layout wandox-root",children:k.jsx("main",{className:"wandox-layout-content",style:{padding:0},children:t})})}const Hrn="wandox_use_map_tree_goals_v2",Wrn=/^\?+$/;function Grn(e){return`${Hrn}:${e||"all"}`}function k0t(e){const t=e,r=Array.isArray(t==null?void 0:t.roles)?t:t==null?void 0:t.data;return Array.isArray(r==null?void 0:r.roles)?r.roles.map(n=>{const i=(n.goals||[]).filter(a=>a.playbook!==null).map(a=>({...a,icon:A0t(a.icon),items:(a.items||[]).filter(s=>s.playbook_id)})).filter(a=>{var s;return(a.items||[]).length>0||!!(a.playbook_id||(s=a.playbook)!=null&&s.playbook_id)});return{...n,icon:A0t(n.icon),goals:i,goal_count:i.length}}).filter(n=>(n.goals||[]).length>0):[]}function A0t(e){const t=String(e||"").trim();if(!(!t||Wrn.test(t)))return t}function Urn({agentId:e,onPlaybookClick:t,onSelectPlaybook:r,expanded:n,onExpandedChange:i}){const[a,s]=C.useState(!1),[o,l]=C.useState(!1),[u,d]=C.useState(!1),[h,f]=C.useState([]),[p,g]=C.useState(""),[m,v]=C.useState(""),y=C.useMemo(()=>e==null?"":String(e).trim(),[e]),x=n??a,b=C.useMemo(()=>h.find(_=>_.role_code===p)||h[0],[h,p]);C.useEffect(()=>{d(!1),f([]),g(""),v("")},[y]),C.useEffect(()=>{if(!x||u)return;let _=!1;const T=Grn(y);return(async()=>{l(!0),v("");try{const I=window.localStorage.getItem(T);if(I)try{const P=k0t(JSON.parse(I));P.length>0&&(f(P),g(P[0].role_code))}catch{window.localStorage.removeItem(T)}const $=await E4r({agent_id:y,role_id:null});if(_)return;const A=k0t($.data);f(A),g(P=>{var N;return P||((N=A[0])==null?void 0:N.role_code)||""}),window.localStorage.setItem(T,JSON.stringify($.data||{roles:[]}))}catch{_||v("使用地图加载失败")}finally{_||(d(!0),l(!1))}})(),()=>{_=!0}},[x,u,y]);const w=_=>{var $,A;const T=_.playbook_id||(($=_.playbook)==null?void 0:$.playbook_id),E=((A=_.playbook)==null?void 0:A.name)||_.title||_.name||"执行";if(!T)return;if(s(!1),i==null||i(!1),o_e(_).length>0&&r){r(Krn(_),E);return}t({message:E,playbook_id:T})},S=()=>{const _=!x;s(_),i==null||i(_)};return k.jsxs("div",{className:`wandox-use-map${x?" wandox-use-map--expanded":""}`,children:[k.jsx("div",{className:"wandox-use-map-toolbar",children:k.jsxs("button",{type:"button",className:"wandox-use-map-toggle",onClick:S,"aria-expanded":x,children:[k.jsx("span",{className:"wandox-scene-tab-mark wandox-scene-tab-mark--use-map","aria-hidden":"true",children:k.jsx(uXe,{})}),k.jsx("span",{className:"wandox-use-map-toggle-text",children:"使用地图"}),k.jsx("span",{className:"wandox-use-map-toggle-arrow","aria-hidden":"true",children:"⌄"})]})}),x&&k.jsx("div",{className:`wandox-use-map-panel${h.length===0?" wandox-use-map-panel--compact":""}`,children:(!u||o)&&h.length===0?k.jsxs("div",{className:"wandox-use-map-loading",children:[k.jsx("span",{className:"wandox-heartbeat-loader","aria-hidden":"true",children:k.jsx("svg",{width:"48",height:"24",viewBox:"0 0 48 24",fill:"none",children:k.jsx("path",{d:"M0 12 L8 12 L10 8 L12 16 L14 4 L16 12 L20 12 L22 10 L24 14 L26 10 L28 12 L48 12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}),k.jsx("span",{children:"正在加载使用地图"})]}):m?k.jsxs("div",{className:"wandox-use-map-empty",children:[k.jsx("div",{className:"wandox-use-map-empty-title",children:m}),k.jsx("button",{type:"button",className:"wandox-use-map-retry",onClick:()=>d(!1),children:"重新加载"})]}):h.length===0?k.jsxs("div",{className:"wandox-use-map-empty",children:[k.jsx("div",{className:"wandox-use-map-empty-title",children:"暂无使用地图"}),k.jsx("div",{className:"wandox-use-map-empty-desc",children:"当前智能体还没有配置岗位目标剧本"})]}):k.jsxs(k.Fragment,{children:[k.jsx("div",{className:"wandox-use-map-roles",role:"tablist","aria-label":"岗位",children:h.map(_=>{var T;return k.jsxs("button",{type:"button",role:"tab","aria-selected":(b==null?void 0:b.role_code)===_.role_code,className:`wandox-use-map-role${(b==null?void 0:b.role_code)===_.role_code?" active":""}`,onClick:()=>g(_.role_code),children:[k.jsx("span",{className:"wandox-use-map-role-icon",children:_.icon||"◎"}),k.jsx("span",{className:"wandox-use-map-role-name",children:_.name}),k.jsx("span",{className:"wandox-use-map-role-count",children:_.goal_count||((T=_.goals)==null?void 0:T.length)||0})]},_.id)})}),k.jsx("div",{className:"wandox-use-map-goals",children:((b==null?void 0:b.goals)||[]).map(_=>{var T;return k.jsxs("section",{className:"wandox-use-map-goal-group",children:[k.jsxs("div",{className:"wandox-use-map-goal-group-head",children:[k.jsx("span",{className:"wandox-use-map-goal-group-icon",children:_.icon||"◇"}),k.jsx("span",{className:"wandox-use-map-goal-group-name",children:_.name}),k.jsxs("span",{className:"wandox-use-map-goal-group-count",children:[((T=_.items)==null?void 0:T.length)||0," 个剧本"]}),(_.description||_.subtitle)&&k.jsxs("span",{className:"wandox-use-map-goal-group-desc",children:["· ",_.description||_.subtitle]})]}),k.jsx("div",{className:"wandox-use-map-goal-items",children:(_.items||[]).map(E=>{var A,P,N;const I=o_e(E).length>0,$=qrn(E.tags);return k.jsxs("button",{type:"button",className:`wandox-use-map-playbook-card${E.is_featured?" wandox-use-map-playbook-card--featured":""}`,onClick:()=>w(E),children:[k.jsx("div",{className:"wandox-use-map-playbook-title",children:k.jsx("span",{className:"wandox-use-map-playbook-name",children:E.title||E.name||((A=E.playbook)==null?void 0:A.name)||"未命名剧本"})}),(E.is_featured||I)&&k.jsxs("div",{className:"wandox-use-map-playbook-badges",children:[E.is_featured&&k.jsx(as,{color:"gold",className:"wandox-use-map-tag wandox-use-map-featured-tag",children:"精品"}),I&&k.jsx("span",{className:"wandox-use-map-param-badge",children:"参数"})]}),(E.subtitle||E.description||((P=E.playbook)==null?void 0:P.description))&&k.jsx("div",{className:"wandox-use-map-playbook-desc",children:E.subtitle||E.description||((N=E.playbook)==null?void 0:N.description)}),$.length>0&&k.jsx("div",{className:"wandox-use-map-playbook-tags",children:$.map((R,L)=>k.jsx(as,{color:R.variant==="soft"?void 0:R.color,className:"wandox-use-map-tag",style:Yrn(R),children:R.name},`${R.name}-${L}`))})]},`${_.id}-${E.id||E.playbook_id}`)})})]},_.id)})})]})})]})}function o_e(e){var t;return e.input_fields||((t=e.playbook)==null?void 0:t.input_fields)||[]}function qrn(e){return Array.isArray(e)?e.reduce((t,r)=>{const n=typeof(r==null?void 0:r.name)=="string"?r.name.trim():"";return n&&t.push({...r,name:n}),t},[]):[]}function Yrn(e){if(!(e.variant!=="soft"||!e.color))return{color:e.color,borderColor:I0t(e.color,.28),backgroundColor:I0t(e.color,.08)}}function I0t(e,t){const r=e.trim().replace("#","");if(!/^[0-9a-fA-F]{6}$/.test(r))return e;const n=Number.parseInt(r.slice(0,2),16),i=Number.parseInt(r.slice(2,4),16),a=Number.parseInt(r.slice(4,6),16);return`rgba(${n}, ${i}, ${a}, ${t})`}function Krn(e){var r;const t=e.playbook||e;return{category:e.category??null,category_name:e.category_name,description:e.description||e.subtitle||t.description,domain:e.domain||"",id:Number(e.id||0),name:((r=e.playbook)==null?void 0:r.name)||e.title||e.name||"未命名剧本",playbook_id:e.playbook_id||t.playbook_id||"",scope:"",status:e.status||t.status||"",sub_category:null,tags:null,type:e.type||"",version:"",input_fields:o_e(e),video_url:e.video_url||t.video_url||void 0,video_duration:e.video_duration||t.video_duration,view_count:e.view_count,badge:e.badge||t.badge||null}}const O_=e=>String(e.playbook_id||e.code||e.name);function Xrn({label:e}){return k.jsxs("output",{className:"wandox-scene-list-loading","aria-label":e,children:[k.jsx("span",{className:"wandox-heartbeat-loader","aria-hidden":"true",children:k.jsx("svg",{width:"48",height:"24",viewBox:"0 0 48 24",fill:"none",children:k.jsx("path",{d:"M0 12 L8 12 L10 8 L12 16 L14 4 L16 12 L20 12 L22 10 L24 14 L26 10 L28 12 L48 12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}),k.jsx("span",{children:e})]})}function $0t({playbooks:e,playbookLoading:t,onPlaybookClick:r,onSelectPlaybook:n,recommendations:i=[],userPlaybooks:a=[],userPlaybooksLoading:s=!1,onLoadUserPlaybooks:o,agentId:l,recentRefreshKey:u=0}){const[d,h]=C.useState("playbooks"),[f,p]=C.useState(!1),[g,m]=C.useState(!1),[v,y]=C.useState("全部"),[x,b]=C.useState(""),[w,S]=C.useState(null),[_,T]=C.useState(""),[E,I]=C.useState(!1),[$,A]=C.useState([]),[P,N]=C.useState(!1),[R,L]=C.useState(""),D=C.useRef(!1),M=C.useRef(new Map),O=C.useMemo(()=>d==="recommendations"?t&&i.length===0:d==="user"?s:P||t&&e.length===0,[t,P,d,e.length,i.length,s]),F=C.useMemo(()=>l==null?"":String(l).trim(),[l]);C.useEffect(()=>{if(!F){A([]),N(!1);return}let ee=!1;return(async()=>{N(!0);try{const le=await Ukr({limit:8,agent_id:F});ee||A(le.data||[])}catch{ee||A([])}finally{ee||N(!1)}})(),()=>{ee=!0}},[F,u]);const B=C.useRef(null),[V,z]=C.useState(5),H=C.useCallback(()=>{if(!B.current)return;const ee=B.current.offsetWidth;if(ee===0)return;const le=Math.floor(ee/(200+12));z(Math.max(2,le))},[]);C.useEffect(()=>{const ee=setTimeout(H,100);return()=>clearTimeout(ee)},[H,d,f]),C.useEffect(()=>{d==="recommendations"&&i.length===0&&h("playbooks")},[i.length,d]),C.useEffect(()=>{d!=="user"||!F||o==null||o()},[d,F,o]),C.useEffect(()=>{if(!B.current)return;const ee=new ResizeObserver(()=>{H()});return ee.observe(B.current),()=>ee.disconnect()},[H]);const W=C.useMemo(()=>new Set($.map(O_)),[$]),G=C.useMemo(()=>new Set(a.map(O_)),[a]),q=C.useMemo(()=>{const ee=new Map;for(const se of $.filter(ue=>!G.has(O_(ue))))ee.set(O_(se),se);for(const se of e){const ue=O_(se);ee.has(ue)||ee.set(ue,se)}return Array.from(ee.values())},[e,$,G]),Y=d==="playbooks"?q:d==="recommendations"?i:a,K=d==="playbooks"?e:Y,X=Y.length>(V??5)&&K.length>0,Z=C.useMemo(()=>{const ee=new Map;ee.set("全部",K.length);for(const se of K){const ue=se.category_name||"未分类";ee.set(ue,(ee.get(ue)||0)+1)}return Array.from(ee.entries()).map(([se,ue])=>({name:se,count:ue}))},[K]),Q=C.useMemo(()=>{let ee=K;if(v!=="全部"&&(ee=ee.filter(se=>(se.category_name||"未分类")===v)),x.trim()){const se=x.trim().toLowerCase();ee=ee.filter(ue=>{var le;return ue.name.toLowerCase().includes(se)||((le=ue.description)==null?void 0:le.toLowerCase().includes(se))})}return ee},[K,v,x]),J=C.useCallback(ee=>{const se=String(ee.playbook_id||"").trim();if(!se)return Promise.reject(new Error("缺少 playbook_id"));const ue=M.current.get(se);if(ue)return ue;const le=zA({playbook_id:se}).then(({data:ne})=>_0t(ee,ne)).finally(()=>{M.current.delete(se)});return M.current.set(se,le),le},[]),re=C.useCallback(async(ee,se=!1)=>{var ue;if(!D.current){D.current=!0,L(ee.playbook_id);try{const le=await J(ee);if(se&&(m(!1),y("全部"),b("")),(ue=le.input_fields)!=null&&ue.length&&n){n(le,le.name);return}r({message:le.name,playbook_id:le.playbook_id})}catch{$t.error("剧本参数加载失败,请稍后重试")}finally{D.current=!1,L("")}}},[J,r,n]);return k.jsxs("div",{className:"wandox-pro-scenes-panel",children:[k.jsxs("div",{className:"wandox-hub-section-header",children:[k.jsxs("div",{className:"wandox-scene-tabs",children:[k.jsxs("button",{type:"button",className:`wandox-scene-tab${!f&&d==="playbooks"?" active":""}`,onClick:()=>{h("playbooks"),p(!1)},children:[k.jsx("span",{className:"wandox-scene-tab-mark wandox-scene-tab-mark--playbooks","aria-hidden":"true",children:k.jsx(dXe,{})}),k.jsx("span",{children:"默认场景"})]}),i.length>0&&k.jsxs("button",{type:"button",className:`wandox-scene-tab${!f&&d==="recommendations"?" active":""}`,onClick:()=>{h("recommendations"),p(!1)},children:[k.jsx("span",{className:"wandox-scene-tab-mark wandox-scene-tab-mark--recommendations","aria-hidden":"true",children:k.jsx(hXe,{})}),k.jsx("span",{children:"推荐场景"})]}),k.jsxs("button",{type:"button",className:`wandox-scene-tab${!f&&d==="user"?" active":""}`,onClick:()=>{h("user"),p(!1)},children:[k.jsx("span",{className:"wandox-scene-tab-mark wandox-scene-tab-mark--user","aria-hidden":"true",children:k.jsx(BTr,{})}),k.jsx("span",{children:"我的场景"})]}),k.jsx(Urn,{agentId:F,onPlaybookClick:r,onSelectPlaybook:n,expanded:f,onExpandedChange:ee=>{p(ee),ee&&h("playbooks")}})]}),X&&!f&&k.jsxs("button",{type:"button",className:"wandox-scene-view-all",onClick:()=>m(!0),children:["查看全部 ",K.length," 个"]})]}),k.jsx("div",{className:"wandox-tab-content",children:!f&&k.jsx("div",{className:"wandox-hub-section",children:O?k.jsx(Xrn,{label:d==="user"?"正在加载我的场景":d==="recommendations"?"正在匹配推荐场景":"正在加载场景"}):Y.length>0?k.jsxs("div",{className:"wandox-scroll-row",ref:B,children:[Y.slice(0,V??5).map(ee=>{const se=R===ee.playbook_id,ue=()=>void re(ee),le=d==="playbooks"&&W.has(O_(ee)),ne=d==="user"?"用户":le?"近期":ee.badge==="new"?"New":ee.badge==="recommend"?"推荐":ee.badge==="featured"?"精选":ee.category_name||ee.type||"推荐",oe=ee.video_duration?`${Math.floor(ee.video_duration/60)}:${String(ee.video_duration%60).padStart(2,"0")}`:"",Se=async xe=>{var Re;xe.stopPropagation(),S(ee),I(!0);try{const Ce=await GZe({playbook_id:ee.playbook_id});T(((Re=Ce.data)==null?void 0:Re.video_url)||ee.video_url||"")}catch{T(ee.video_url||"")}finally{I(!1)}},ie={daily:"每日",weekly:"每周",monthly:"每月"},be=ee.is_subscribed?`🔔订阅${ee.execution_frequency&&ee.execution_frequency!=="none"?`·${ie[ee.execution_frequency]}自动跑`:""}`:"",pe=[ee.description,be].filter(Boolean).join(" ");return k.jsxs("div",{className:"wandox-card",children:[k.jsxs("div",{className:"wandox-card-corner",children:[k.jsx("span",{className:"wandox-card-tag",children:ne}),ee.video_url&&k.jsxs("button",{type:"button",className:"wandox-card-video",onClick:Se,children:["▶ ",oe?` ${oe}`:"0:00"," 演示"]})]}),k.jsxs("button",{type:"button",className:"wandox-card-main",onClick:ue,disabled:se,"aria-busy":se,children:[k.jsx("div",{className:"wandox-card-title",children:ee.name}),k.jsx("div",{className:"wandox-card-desc",children:se?"正在加载参数...":pe})]})]},O_(ee))}),X&&k.jsxs("button",{type:"button",className:"wandox-card wandox-card-more",onClick:()=>m(!0),children:[k.jsxs("div",{className:"wandox-card-more-title",children:["查看全部 ",K.length," 个"]}),k.jsx("div",{className:"wandox-card-more-desc",children:"按场景浏览"})]})]}):k.jsx("div",{className:"wandox-empty-slot",children:k.jsxs("div",{className:"wandox-empty",children:[k.jsx("div",{className:"wandox-empty-text",children:d==="playbooks"?"暂无默认场景":d==="recommendations"?"暂无推荐场景":"暂无我的场景"}),k.jsx("div",{className:"wandox-empty-desc",children:d==="playbooks"?"请联系管理员添加场景剧本":d==="recommendations"?"系统会根据情况推荐相关场景":"我创建的场景会显示在这里"})]})})})}),k.jsx(_i,{open:g,onCancel:()=>{m(!1),y("全部"),b("")},footer:null,width:900,closable:!1,centered:!0,styles:{container:{padding:0,overflow:"hidden"},body:{height:"90vh"}},zIndex:1e4,children:k.jsxs("div",{className:"wandox-playbook-browser",children:[k.jsxs("div",{className:"wandox-playbook-sidebar",children:[k.jsx("div",{className:"wandox-playbook-sidebar-title",children:"场景分类"}),k.jsx("div",{className:"wandox-playbook-categories",children:Z.map(ee=>k.jsxs("button",{type:"button",className:`wandox-playbook-category-item${v===ee.name?" active":""}`,onClick:()=>y(ee.name),children:[k.jsx("span",{className:"wandox-playbook-category-name",children:ee.name}),k.jsx("span",{className:"wandox-playbook-category-count",children:ee.count})]},ee.name))})]}),k.jsxs("div",{className:"wandox-playbook-main",children:[k.jsx("div",{className:"wandox-playbook-search",children:k.jsx(zr,{placeholder:"搜索场景名称或描述...",prefix:k.jsx(uS,{style:{color:"#9ca3af"}}),value:x,onChange:ee=>b(ee.target.value),allowClear:!0})}),k.jsx("div",{className:"wandox-playbook-list",children:Q.length===0?k.jsx(is,{description:"暂无剧本",style:{marginTop:80}}):Q.map(ee=>{const se=ee.input_fields&&ee.input_fields.length>0,ue=R===ee.playbook_id,le=!!ee.video_url,ne=()=>void re(ee,!0),oe=ee.video_duration?`${Math.floor(ee.video_duration/60)}:${String(ee.video_duration%60).padStart(2,"0")}`:"",Se=async()=>{var ie;S(ee),I(!0);try{const be=await GZe({playbook_id:ee.playbook_id});T(((ie=be.data)==null?void 0:ie.video_url)||ee.video_url||"")}catch{$t.error("视频加载失败"),T(ee.video_url||"")}finally{I(!1)}};return k.jsx("div",{className:"wandox-playbook-list-item",children:k.jsxs("div",{className:"wandox-playbook-list-item-content",children:[k.jsx("div",{className:"wandox-playbook-list-item-icon",children:le?k.jsx("button",{className:"wandox-playbook-video-icon",title:"包含演示视频",onClick:Se,type:"button",children:k.jsx(Yp,{})}):k.jsx("div",{className:"wandox-playbook-no-video-icon",children:k.jsx(Yqe,{})})}),k.jsxs("div",{className:"wandox-playbook-list-item-body",children:[k.jsx("div",{className:"wandox-playbook-list-item-header",children:k.jsxs("div",{className:"wandox-playbook-list-item-title",children:[ee.name,ee.badge&&k.jsx("span",{className:`wandox-scene-badge wandox-scene-badge--${ee.badge}`,children:ee.badge==="new"?"New":ee.badge==="recommend"?"推荐":"精选"})]})}),ee.description&&k.jsx("div",{className:"wandox-playbook-list-item-desc",children:ee.description}),ee.last_execution_remark&&k.jsxs("div",{className:"wandox-playbook-list-item-remark",children:[k.jsx("span",{className:"wandox-playbook-list-item-remark-icon",children:"💡"}),k.jsxs("span",{children:["上次:",ee.last_execution_remark]})]})]}),k.jsxs("div",{className:"wandox-playbook-list-item-actions",children:[k.jsx("button",{type:"button",className:"wandox-playbook-list-item-btn",onClick:ne,disabled:ue,"aria-busy":ue,children:ue?"加载中":se?"参数":"运行"}),le&&k.jsxs("button",{type:"button",className:"wandox-playbook-demo-link",onClick:Se,children:["看演示",oe?` ${oe}`:""]})]})]})},ee.playbook_id)})})]})]})}),w&&k.jsx(_i,{open:!0,onCancel:()=>{S(null),T("")},footer:null,centered:!0,width:800,title:k.jsxs("span",{children:[k.jsx(Yp,{style:{marginRight:8,color:"#7c3aed"}}),w.name," · 演示视频",w.video_duration&&k.jsxs("span",{style:{marginLeft:12,fontSize:13,color:"#9ca3af",fontWeight:"normal"},children:["时长 ",Math.floor(w.video_duration/60),":",String(w.video_duration%60).padStart(2,"0")]}),w.view_count!==void 0&&k.jsxs("span",{style:{marginLeft:12,fontSize:13,color:"#9ca3af",fontWeight:"normal"},children:["👁 ",w.view_count," 次播放"]})]}),styles:{body:{padding:"12px 0 0"}},zIndex:10001,children:E?k.jsx("div",{style:{height:400,display:"flex",alignItems:"center",justifyContent:"center",background:"#000",borderRadius:8},children:k.jsx(so.Node,{active:!0,style:{width:200,height:200}})}):k.jsx("video",{src:_,controls:!0,autoPlay:!0,style:{width:"100%",borderRadius:8,display:"block",maxHeight:"70vh",background:"#000"},children:k.jsx("track",{kind:"captions"})})})]})}const R0t=[{name:"country",label:"国家/地区"},{name:"state",label:"州/省"},{name:"province",label:"省"},{name:"city",label:"城市"},{name:"postal_code",label:"邮政编码"},{name:"address_line1",label:"地址"}],Zrn=Object.fromEntries(R0t.map(e=>[e.name,e.label]));function P9(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function R5(e){return typeof e=="string"?e.trim():String(e??"").trim()}function Qrn(e,t){return!P9(e)||!Array.isArray(e[t])?[]:e[t].map(String).filter(Boolean)}function Jrn(e,t){if(!P9(e)||!P9(e.postal_code_patterns))return;const r=e.postal_code_patterns[t];return typeof r=="string"?r:void 0}function $Q(e){const t=String(e.type||"").toLowerCase(),r=String(e.widget||"").toLowerCase();return t==="address"||r==="address"}function enn(){return[...R0t]}function N0t(e,t){if(!P9(e))return"请输入有效地址";const r=Qrn(t,"required_fields"),n=r.length>0?r:["country","city","postal_code","address_line1"];for(const l of n)if(!R5(e[l]))return`请填写${Zrn[l]||`地址字段 ${l}`}`;if(r.length===0&&!R5(e.state)&&!R5(e.province))return"请填写州/省";const i=R5(e.country).toUpperCase(),a=R5(e.postal_code),s=Jrn(t,i);if(a&&s)try{if(!new RegExp(s).test(a))return"邮政编码格式不正确"}catch{return"地址邮编规则配置无效"}const o=P9(t)&&typeof t.max_length=="number"?t.max_length:200;return R5(e.address_line1).length>o?`地址行不能超过 ${o} 个字符`:""}var L0t={exports:{}};(function(e,t){(function(r,n){e.exports=n()})(ka,function(){var r="month",n="quarter";return function(i,a){var s=a.prototype;s.quarter=function(u){return this.$utils().u(u)?Math.ceil((this.month()+1)/3):this.month(this.month()%3+3*(u-1))};var o=s.add;s.add=function(u,d){return u=Number(u),this.$utils().p(d)===n?this.add(3*u,r):o.bind(this)(u,d)};var l=s.startOf;s.startOf=function(u,d){var h=this.$utils(),f=!!h.u(d)||d;if(h.p(u)===n){var p=this.quarter()-1;return f?this.month(3*p).startOf(r).startOf("day"):this.month(3*p+2).endOf(r).endOf("day")}return l.bind(this)(u,d)}}})})(L0t);var tnn=L0t.exports;const rnn=Ds(tnn);Yr.extend(yfe),Yr.extend(rnn),Yr.extend(SWe);const nnn={date:"YYYY-MM-DD",daterange:"YYYY-MM-DD",datetime:"YYYY-MM-DD HH:mm:ss",datetimerange:"YYYY-MM-DD HH:mm:ss",time:"HH:mm:ss",timerange:"HH:mm:ss"};function M9(e){const t=String(e||"").trim().toLowerCase().replace(/[_-]/g,"");return t==="date"?"date":t==="daterange"?"daterange":t==="datetime"?"datetime":t==="datetimerange"?"datetimerange":t==="time"?"time":t==="timerange"?"timerange":null}function t0(e){var r;const t=M9(e.type);if(t)return(r=e.format)!=null&&r.trim()?e.format.trim():D9(e)==="time"?"HH:mm:ss":l_e(e)?"YYYY-MM-DD HH:mm:ss":e.picker==="year"?"YYYY":e.picker==="month"?"YYYY-MM":e.picker==="week"?"YYYY-wo":e.picker==="quarter"?"YYYY-[Q]Q":nnn[t]}function D9(e){const t=M9(e.type);return t?t==="time"||t==="timerange"?"time":"date":null}function N5(e){const t=M9(e.type);return e.range??(t==="daterange"||t==="datetimerange"||t==="timerange")}function l_e(e){const t=M9(e.type);return e.show_time??(t==="datetime"||t==="datetimerange")}function L5(e,t){return["date","week","month","quarter","year"].includes(t||"")?t:e==="YYYY"?"year":e==="YYYY-MM"?"month":"date"}function B_(e){return e!=null&&e.includes("ss")?"HH:mm:ss":"HH:mm"}function F_(e,t,r){if(e==null||e===""||typeof e!="string"&&typeof e!="number"&&!(e instanceof Date)&&!Yr.isDayjs(e))return null;let n;if(typeof e=="string"&&/^\d{1,2}:\d{2}(?::\d{2})?$/.test(e))n=Yr(`2000-01-01 ${e}`);else if(typeof e=="string"&&r==="quarter"){const i=e.match(/^(\d{4}).*?Q([1-4])/i);n=i?Yr(`${i[1]}-01-01`).quarter(Number(i[2])):Yr(e)}else if(typeof e=="string"&&r==="week"){const i=e.match(/^(\d{4})\D+(\d{1,2})/);n=i?Yr(`${i[1]}-01-01`).week(Number(i[2])):Yr(e)}else typeof e=="string"&&t?(n=Yr(e,t,!0),n.isValid()||(n=Yr(e))):n=Yr(e);return n.isValid()?n:null}function O9(e,t,r){return!Array.isArray(e)||e.length!==2?null:[F_(e[0],t,r),F_(e[1],t,r)]}function c_e({field:e,value:t,size:r,disabled:n=!1,readOnly:i=!1,status:a,onChange:s}){const o=D9(e),l=t0(e),u=N5(e),d={size:r,style:{width:"100%"},format:l,disabled:n,allowClear:!i,inputReadOnly:i,open:i?!1:void 0,status:a};if(o==="date"){const h=l_e(e),f=L5(l,e.picker),p=h?"日期时间":"日期",g={...d,picker:f,showTime:h?{format:B_(l)}:!1};return u?k.jsx(Es.RangePicker,{...g,value:O9(t,l,f),placeholder:[`请选择开始${p}`,`请选择结束${p}`],onChange:(m,v)=>s(v)}):k.jsx(Es,{...g,value:F_(t,l,f),placeholder:e.placeholder||`请选择${p}`,onChange:(m,v)=>s(v)})}return o==="time"?u?k.jsx(tc.RangePicker,{...d,value:O9(t,l),placeholder:["请选择开始时间","请选择结束时间"],onChange:(h,f)=>s(f)}):k.jsx(tc,{...d,value:F_(t,l),placeholder:e.placeholder||"请选择时间",onChange:(h,f)=>s(f)}):null}function P0t(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function B9(e){return["array","list","tags","multi_select","multiselect"].includes(String(e||"").toLowerCase())}function M0t(e){return(e==null?void 0:e.includes("image"))??!1}function RQ(e){const t=(e.ui_component||e.widget||e.type||"string").toLowerCase();return M9(t)||t}function D0t(e){return RQ(e)==="segmented"||e.type.toLowerCase()==="segmented"}function O0t(e){var t;return(t=e.options)!=null&&t.length?e.options:(e.enum||[]).map(r=>({value:r,label:r}))}function inn(e){return e==null?"":typeof e=="string"||typeof e=="number"||typeof e=="bigint"?e:String(e)}function ann(e){if(typeof e=="number"&&Number.isFinite(e))return e;if(typeof e=="string"&&e.trim()){const t=Number(e);return Number.isFinite(t)?t:void 0}}function u_e(e){if(Array.isArray(e))return e.map(t=>String(t));if(e==null||e==="")return[];if(typeof e=="string"){const t=e.trim();if(t.startsWith("[")&&t.endsWith("]"))try{const r=JSON.parse(t);if(Array.isArray(r))return r.map(n=>String(n))}catch{}}return[String(e)]}function xy(e){return e==null||e===""||Array.isArray(e)&&e.length===0}function P5(e,t={}){const r={};for(const n of e){const i=t[n.name];i!==void 0&&i!==""?r[n.name]=B9(n.type)?u_e(i):i:n.default!==void 0&&n.default!==""?r[n.name]=B9(n.type)?u_e(n.default):n.default:n.type.toLowerCase()==="boolean"?r[n.name]=!1:["number","integer","float"].includes(n.type.toLowerCase())?r[n.name]=void 0:B9(n.type)?r[n.name]=[]:r[n.name]=""}return r}function F9(e,t){return Array.isArray(e)?e.some(r=>F9(r,t)):String(e??"")===String(t??"")}function snn(e){return Array.isArray(e)?e.filter(P0t):P0t(e)?"field"in e||"name"in e||"param"in e?[e]:Object.entries(e).map(([t,r])=>({field:t,equals:r})):[]}function onn(e,t){const r=String(e.field??e.name??e.param??"");if(!r)return!0;const n=t[r],i=e.equals!==void 0||e.value!==void 0,a=e.equals??e.value;return!(i&&!F9(n,a)||e.not_equals!==void 0&&F9(n,e.not_equals)||Array.isArray(e.in)&&!e.in.some(s=>F9(n,s))||Array.isArray(e.not_in)&&e.not_in.some(s=>F9(n,s))||e.truthy===!0&&!n||e.empty===!0&&!xy(n)||e.empty===!1&&xy(n))}function z9(e,t){return e.filter(r=>{const n=snn(r.visible_when);return n.length===0||n.every(i=>onn(i,t))})}function B0t(e,t){return e.reduce((r,n)=>(r[n.name]=t[n.name],r),{})}function lnn(e){return Array.isArray(e)?e.map(t=>String(t)):e?[String(e)]:[]}function d_e(e){return e!=null&&e!==""}function cnn(e,t){const r=B9(e.type),n=u_e(t),i=d_e(t)?String(t):void 0;return{isMulti:r,selectValue:r?n:i,isEmptySelect:r?n.length===0:i===void 0,hasCurrentSelection:r?n.length>0:i!==void 0}}function h_e({field:e,value:t,readOnly:r=!1,size:n,uploading:i=!1,imageUploadMode:a="picture",fileNameMap:s={},getOptionState:o,onChange:l,onUpload:u,onDownloadTemplate:d,draftValue:h,onDraftChange:f,onDraftCommit:p,selectSearchValue:g,onSelectSearchChange:m,onSelectAllowEmptySearch:v}){var _,T,E,I;const y=h??String(inn(t)),x=RQ(e),b={...e,type:x},w=$=>l(e.name,$),S=()=>{var B,V;const $=o(e),A=e.options_from_skill?$.options:O0t(e),P=!!(e.options_from_skill||(B=e.enum)!=null&&B.length||(V=e.options)!=null&&V.length),N=$.waitingForDependencies?"请先选择关联参数":$.placeholder||e.placeholder||"请选择",{isMulti:R,selectValue:L,isEmptySelect:D,hasCurrentSelection:M}=cnn(e,t),O=m!==void 0,F=()=>{v==null||v(e.name),g&&(m==null||m(e.name,""))};return k.jsx(wn,{allowClear:!r,showSearch:!r,size:n,autoClearSearchValue:!O,optionFilterProp:"label",filterOption:(z,H)=>{const W=z.trim().toLowerCase();return W?String((H==null?void 0:H.label)??(H==null?void 0:H.value)??"").toLowerCase().includes(W):!0},mode:R?P?"multiple":"tags":void 0,value:L,searchValue:r||!O?void 0:g,placeholder:D?N:void 0,options:A,loading:!r&&$.loading,disabled:!r&&$.waitingForDependencies,open:r?!1:void 0,tabIndex:r?-1:void 0,"aria-readonly":r,tokenSeparators:R&&!P?[","]:void 0,notFoundContent:$.loading?k.jsx(Yi,{size:"small"}):$.error||null,onInputKeyDown:z=>{["Backspace","Delete","Escape"].includes(z.key)&&(v==null||v(e.name))},onSearch:O?z=>m(e.name,z):void 0,onChange:z=>{w(z);const H=Array.isArray(z)?z.length>0:d_e(z);(M||H)&&F()},onClear:F,onBlur:F})};if(D0t(e)){const $=O0t(e);return $.length===0?S():k.jsx(bU,{className:"wandox-agent-input-field-control__segmented",options:$,value:d_e(t)?String(t):void 0,disabled:r,onChange:w})}if($Q(e)){const $=t&&typeof t=="object"&&!Array.isArray(t)?t:{},A=(P,N)=>{r||w({...$,[P]:N})};return k.jsxs("div",{className:"wandox-agent-input-field-control__address",children:[enn().map(({name:P,label:N})=>k.jsx(zr,{size:n,value:String($[P]??""),readOnly:r,placeholder:N,onChange:R=>A(P,R.target.value)},P)),k.jsx(zr,{size:n,value:String($.address_line2??""),readOnly:r,placeholder:"地址补充",onChange:P=>A("address_line2",P.target.value)})]})}if(D9(b))return k.jsx(c_e,{field:b,value:t,size:n,readOnly:r,disabled:r,onChange:w});switch(x){case"file":{const $=e.max_files??1,A=lnn(t),P=A.length<$,N=R=>{w($<=1?"":A.filter((L,D)=>D!==R))};if(a==="picture"&&M0t(e.file_type)){const R=A.map((L,D)=>({uid:String(D),name:s[L]||L.split("/").pop()||`image_${D+1}`,status:"done",url:L}));return k.jsx(qp,{className:"wandox-agent-input-field-control__picture",accept:e.file_type||void 0,listType:"picture-card",fileList:R,customRequest:r?void 0:u(e.name,$),onRemove:r?void 0:L=>(N(Number(L.uid)),!0),disabled:r||i,maxCount:$,showUploadList:{showRemoveIcon:!r},children:P&&!r&&k.jsxs("div",{children:[i?k.jsx(Yi,{size:"small"}):k.jsx(xu,{}),k.jsx("div",{className:"wandox-agent-input-field-control__upload-text",children:"上传图片"})]})})}return k.jsxs("div",{className:"wandox-agent-input-field-control__files",children:[A.map((R,L)=>k.jsxs("div",{className:"wandox-agent-input-field-control__file",children:[k.jsx("span",{children:s[R]||R.split("/").pop()||R}),!r&&k.jsx(ur,{type:"text",size:"small",danger:!0,"aria-label":"移除文件",icon:k.jsx(Mv,{}),onClick:()=>N(L)})]},R)),e.file_templates&&e.file_templates.length>0&&k.jsxs("div",{className:"wandox-agent-input-field-control__templates",children:[k.jsx("span",{children:"模板文件"}),e.file_templates.map((R,L)=>k.jsx(ur,{size:"small",onClick:()=>d==null?void 0:d(R),children:R.name||"下载模板"},`${R.path}-${R.name||L}`))]}),P&&!r&&k.jsxs(qp.Dragger,{accept:e.file_type||void 0,showUploadList:!1,customRequest:u(e.name,$),disabled:i,children:[k.jsx("p",{className:"ant-upload-drag-icon",children:i?k.jsx(Yi,{size:"small"}):k.jsx(qO,{})}),k.jsx("p",{className:"ant-upload-text",children:i?"上传中...":"点击或拖拽文件上传"}),$>1&&k.jsxs("p",{className:"ant-upload-hint",children:["已上传 ",A.length,"/",$]})]})]})}case"boolean":return k.jsx(Dc,{size:n==="small"?"small":"default",checked:!!t,disabled:r,onChange:w});case"number":case"integer":case"float":return k.jsx(wu,{size:n,value:ann(t),readOnly:r,placeholder:e.placeholder||"请输入",onChange:w});case"select":case"array":case"list":case"tags":case"multi_select":case"multiselect":return S();case"string":return(_=e.enum)!=null&&_.length||(T=e.options)!=null&&T.length||e.options_from_skill?S():k.jsx(zr,{size:n,value:y,readOnly:r,placeholder:e.placeholder||"请输入",onChange:r?void 0:$=>f?f(e.name,$.target.value):w($.target.value),onBlur:r?void 0:$=>p==null?void 0:p(e.name,$.target.value)});default:return(E=e.enum)!=null&&E.length||(I=e.options)!=null&&I.length||e.options_from_skill?S():k.jsx(zr.TextArea,{value:y,readOnly:r,autoSize:{minRows:2,maxRows:8},placeholder:e.placeholder||"请输入",onChange:r?void 0:$=>f?f(e.name,$.target.value):w($.target.value),onBlur:r?void 0:$=>p==null?void 0:p(e.name,$.target.value)})}}const F0t=/\$\{\s*\{?\s*params\.([a-zA-Z0-9_.-]+)\s*\}?\s*\}/g,unn=/^\$\{\s*\{?\s*params\.([a-zA-Z0-9_.-]+)\s*\}?\s*\}$/;function z_(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function f_e(e,t){return t.split(".").reduce((r,n)=>{if(z_(r))return r[n]},e)}function dnn(e){return e==null||e===""}function hnn(e){const t=new Set,r=n=>{if(typeof n=="string"){for(const i of n.matchAll(F0t))i[1]&&t.add(i[1]);return}if(Array.isArray(n)){n.forEach(r);return}z_(n)&&Object.values(n).forEach(r)};return r(e),Array.from(t)}function fnn(e,t){const r=e.split(".")[0],n=t.find(i=>i.name===e||i.name===r);return n?!!n.required:!0}function p_e(e,t){if(typeof e=="string"){const r=e.match(unn);return r!=null&&r[1]?f_e(t,r[1]):e.replace(F0t,(n,i)=>{const a=f_e(t,i);return a==null?"":String(a)})}return Array.isArray(e)?e.map(r=>p_e(r,t)):z_(e)?Object.fromEntries(Object.entries(e).map(([r,n])=>[r,p_e(n,t)])):e}function pnn(e){const t=z_(e)&&"data"in e?e.data:e,r=[t];z_(t)&&(r.push(t.output_data,t.options,t.items,t.data,t.result,t.results,t.list),z_(t.output)&&r.push(t.output.output_data,t.output.options,t.output.items,t.output.data));for(const n of r)if(Array.isArray(n))return n;return[]}function gnn(e){let t;return{options:pnn(e).map(n=>{if(typeof n=="string"||typeof n=="number"||typeof n=="boolean")return{value:String(n),label:String(n)};if(!z_(n))return null;const i=n.value??n.key??n.code??n.id??n.name??n.label;if(i==null)return null;const a=n.label??n.name??n.title??n.text??n.value??i;if(String(i)===""){const s=String(a||"");return s&&!t&&(t=s),null}return{value:String(i),label:String(a)}}).filter(n=>!!n),placeholder:t}}function mnn(e){return(e.enum||[]).map(t=>({value:t,label:t}))}function NQ(e,t,r){const[n,i]=C.useState({}),a=C.useRef({}),s=C.useRef({}),o=C.useMemo(()=>e.filter(l=>!!l.options_from_skill),[e]);return C.useEffect(()=>{const l=new Set(o.map(u=>u.name));for(const u of Object.keys(a.current))l.has(u)||(delete a.current[u],delete s.current[u]);i(u=>{const d=Object.fromEntries(Object.entries(u).filter(([h])=>l.has(h)));return Object.keys(d).length===Object.keys(u).length?u:d})},[o]),C.useEffect(()=>{for(const l of o){if(!l.options_from_skill)continue;const d=hnn(l.options_params).filter(m=>fnn(m,e)&&dnn(f_e(t,m))),h=p_e(l.options_params||{},t),f=JSON.stringify({skill_id:l.options_from_skill,params:h,missing:d});if(a.current[l.name]===f)continue;const p=a.current[l.name]!==void 0||d.length>0;a.current[l.name]=f,s.current[l.name]=(s.current[l.name]||0)+1;const g=s.current[l.name];if(p&&r(m=>m[l.name]===void 0||m[l.name]===""?m:{...m,[l.name]:void 0}),d.length>0){i(m=>({...m,[l.name]:{options:[],loading:!1,waitingForDependencies:!0}}));continue}i(m=>{var v,y;return{...m,[l.name]:{options:((v=m[l.name])==null?void 0:v.options)||[],loading:!0,placeholder:(y=m[l.name])==null?void 0:y.placeholder,waitingForDependencies:!1}}}),KZe({},{skill_id:l.options_from_skill,params:h}).then(m=>{if(s.current[l.name]!==g)return;const v=gnn(m);i(y=>({...y,[l.name]:{options:v.options,loading:!1,placeholder:v.placeholder,waitingForDependencies:!1}}))}).catch(m=>{if(s.current[l.name]!==g)return;const v=m instanceof Error?m.message:"动态选项加载失败";i(y=>({...y,[l.name]:{options:[],loading:!1,error:v,waitingForDependencies:!1}}))})}},[o,e,t,r]),{getFieldState(l){return l.options_from_skill?n[l.name]||{options:[],loading:!1,waitingForDependencies:!1}:{options:mnn(l),loading:!1,waitingForDependencies:!1}}}}function M5(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function j_(e,t=""){return typeof e=="string"?e:e==null?t:String(e)}function fg(e){return typeof e=="string"?e:void 0}const vnn=["date","week","month","quarter","year"];function ynn(e){return typeof e=="string"&&vnn.includes(e)}function z0t(e){if(typeof e=="number"&&Number.isFinite(e))return e;if(typeof e=="string"&&e.trim()){const t=Number(e);return Number.isFinite(t)?t:void 0}}function bnn(e){if(!Array.isArray(e))return;const t=e.map(r=>{if(!M5(r))return null;const n=j_(r.path);return n?{name:j_(r.name,n.split("/").pop()||n),path:n}:null}).filter(r=>!!r);return t.length>0?t:void 0}function xnn(e){if(!Array.isArray(e))return;const t=e.map(r=>{if(typeof r=="string"||typeof r=="number"||typeof r=="boolean")return{value:String(r),label:String(r)};if(!M5(r))return null;const n=r.value??r.key??r.code??r.id??r.name??r.label;return n==null||n===""?null:{value:String(n),label:j_(r.label??r.title??r.text??r.name??n,String(n))}}).filter(r=>!!r);return t.length>0?t:void 0}function g_e(e){const t=M5(e)?e:{};return{name:j_(t.name),label:j_(t.label,j_(t.name)),type:j_(t.type,"string"),required:typeof t.required=="boolean"?t.required:!0,default:t.default,mock:t.mock,format:fg(t.format),picker:ynn(t.picker)?t.picker:void 0,show_time:typeof t.show_time=="boolean"?t.show_time:void 0,range:typeof t.range=="boolean"?t.range:void 0,enum:Array.isArray(t.enum)?t.enum.map(r=>String(r)):void 0,options:xnn(t.options),placeholder:fg(t.placeholder),options_from_skill:fg(t.options_from_skill),options_params:M5(t.options_params)?t.options_params:void 0,file_type:fg(t.file_type),max_files:z0t(t.max_files),description:fg(t.description),hint:fg(t.hint??t.label_hint??t.helper_text),file_templates:bnn(t.file_templates),group:fg(t.group??t.group_key??t.form_group),group_label:fg(t.group_label??t.group_title),group_description:fg(t.group_description??t.group_subtitle),ui_component:fg(t.ui_component??t.component??t.render_as),widget:fg(t.widget),address_validation:t.address_validation??t.addressValidation,span:z0t(t.span??t.col_span??t.column_span),visible_when:t.visible_when??t.visibleWhen}}function m_e(e){return Array.isArray(e)?e.map(g_e).filter(t=>!!t.name):M5(e)?Object.entries(e).map(([t,r])=>M5(r)?g_e({...r,name:r.name??t}):g_e({name:t,label:t,type:"string",default:r})).filter(t=>!!t.name):[]}function wnn(e){return e instanceof Error?e.message:"上传失败"}function Snn({open:e,playbook:t,onClose:r,onSubmit:n}){const i=C.useMemo(()=>m_e(t==null?void 0:t.input_fields),[t]),[a,s]=C.useState({}),[o,l]=C.useState({}),[u,d]=C.useState({}),h=NQ(i,a,s),f=C.useMemo(()=>z9(i,a),[i,a]);C.useEffect(()=>{e&&(s(P5(i,(t==null?void 0:t.initial_params)??{})),l({}),d({}))},[i,e,t==null?void 0:t.initial_params]);const p=C.useCallback((v,y)=>{s(x=>({...x,[v]:y}))},[]),g=C.useCallback((v,y)=>async({file:x,onSuccess:b,onError:w})=>{var S,_;l(T=>({...T,[v]:!0}));try{const T=x,E=await WS(T),I=(S=E==null?void 0:E.data)==null?void 0:S.url,$=((_=E==null?void 0:E.data)==null?void 0:_.name)||T.name;if(!I)throw new Error("上传结果缺少文件地址");d(A=>({...A,[I]:$})),s(A=>{if(y<=1)return{...A,[v]:I};const P=Array.isArray(A[v])?A[v]:A[v]?[A[v]]:[];return{...A,[v]:[...P,I]}}),b==null||b(E),$t.success("上传成功")}catch(T){const E=T instanceof Error?T:new Error(wnn(T));w==null||w(E),$t.error(E.message)}finally{l(T=>({...T,[v]:!1}))}},[]),m=()=>{if(!t)return;const v=f.filter(y=>y.required&&xy(a[y.name]));if(v.length>0){$t.warning(`请填写必填参数:${v.map(y=>y.label).join("、")}`);return}n(t,a)};return k.jsxs(dA,{className:"wandox-playbook-params-drawer",title:k.jsxs("div",{className:"wandox-playbook-params-drawer__title",children:[k.jsx("span",{className:"wandox-playbook-params-drawer__title-main",children:"填写执行参数"}),k.jsx("span",{className:"wandox-playbook-params-drawer__title-sub",children:t==null?void 0:t.name})]}),open:e,width:640,destroyOnHidden:!0,maskClosable:!1,onClose:r,footer:k.jsx("div",{className:"wandox-playbook-params-drawer__footer",children:k.jsxs(il,{children:[k.jsx(ur,{onClick:r,children:"取消"}),k.jsx(ur,{type:"primary",onClick:m,children:"开始执行"})]})}),children:[k.jsxs("div",{className:"wandox-playbook-params-drawer__intro",children:[k.jsx("span",{children:"填写本次运行需要的参数"}),k.jsxs("span",{children:[f.length," 项"]})]}),k.jsxs(Sn,{layout:"vertical",className:"wandox-playbook-params-drawer__form",children:[f.map(v=>k.jsx(Sn.Item,{required:v.required,label:k.jsxs("span",{className:"wandox-playbook-params-drawer__label",children:[v.label,v.description||v.hint?k.jsx(Ci,{title:v.description||v.hint,children:k.jsx(hA,{"aria-label":`${v.label}说明`})}):null]}),children:k.jsx(h_e,{field:v,value:a[v.name],uploading:!!o[v.name],fileNameMap:u,getOptionState:h.getFieldState,onChange:p,onUpload:g,onDownloadTemplate:y=>window.open(y.path,"_blank","noopener,noreferrer")})},v.name)),f.length===0?k.jsxs("div",{className:"wandox-playbook-params-drawer__empty",children:[k.jsx(Yi,{size:"small"})," 正在读取参数配置"]}):null]})]})}function Cnn({playbooks:e,onPlaybookClick:t,onPlaybookDelete:r,activePlaybookId:n}){const{t:i}=Fv(),[a,s]=C.useState(""),[o,l]=C.useState(!1),[u,d]=C.useState(null),[h,f]=C.useState(!1),p=e.filter(y=>{var x;return y.name.toLowerCase().includes(a.toLowerCase())||((x=y.description)==null?void 0:x.toLowerCase().includes(a.toLowerCase()))}),g=(y,x)=>{x.stopPropagation(),d(y),l(!0)},m=async()=>{if(u){f(!0);try{await Wkr(u.playbook_id),r==null||r(u.playbook_id),l(!1),d(null)}catch{}finally{f(!1)}}},v=()=>{l(!1),d(null)};return k.jsxs("div",{className:"wandox-solidified-list",children:[k.jsx("div",{className:"wandox-solidified-list-search",children:k.jsx(zr.Search,{placeholder:"搜索",value:a,onChange:y=>s(y.target.value),allowClear:!0,enterButton:!1})}),k.jsx("div",{className:"wandox-solidified-list-content",children:p.length===0?k.jsx(is,{description:i(a?"noData":"solidified.empty"),image:is.PRESENTED_IMAGE_SIMPLE}):k.jsx("div",{className:"wandox-solidified-list-grid",children:p.map(y=>k.jsxs("div",{className:`wandox-solidified-card ${n===y.playbook_id?"active":""}`,onClick:()=>t==null?void 0:t(y.playbook_id),onKeyDown:x=>{(x.key==="Enter"||x.key===" ")&&(t==null||t(y.playbook_id))},role:"button",tabIndex:0,children:[k.jsx("div",{className:"wandox-solidified-card-icon",children:k.jsxs("svg",{viewBox:"0 0 24 24",width:"24",height:"24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[k.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",stroke:"currentColor",strokeWidth:"2",fill:"none"}),k.jsx("path",{d:"M9 3v18M15 3v18M3 9h18M3 15h18",stroke:"currentColor",strokeWidth:"1.5"}),k.jsx("circle",{cx:"12",cy:"12",r:"2",fill:"currentColor"})]})}),k.jsxs("div",{className:"wandox-solidified-card-content",children:[k.jsx("div",{className:"wandox-solidified-card-name",children:y.name}),y.description&&k.jsx("div",{className:"wandox-solidified-card-desc",children:y.description})]}),k.jsx("button",{type:"button",className:"wandox-solidified-card-delete",onClick:x=>g(y,x),title:i("solidified.delete"),children:k.jsx("svg",{viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:k.jsx("path",{d:"M6 7v12a2 2 0 002 2h8a2 2 0 002-2V7M4 7h16M10 11v6M14 11v6M9 7V4a1 1 0 011-1h4a1 1 0 011 1v3",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})]},y.playbook_id))})}),k.jsx(_i,{title:i("solidified.deleteConfirm"),open:o,onOk:m,onCancel:v,okText:i("confirm"),cancelText:i("cancel"),okButtonProps:{danger:!0,loading:h},children:k.jsxs("p",{children:[i("solidified.deleteConfirm")," 「",u==null?void 0:u.name,"」?"]})})]})}function _nn({inputParams:e,onSearch:t,loading:r=!1}){const[n]=Sn.useForm();C.useEffect(()=>{const s={};for(const o of e)o.default!==void 0&&o.default!==null&&o.default!==""&&(s[o.name]=o.default);n.setFieldsValue(s)},[e,n]);const i=()=>{n.validateFields().then(s=>{const o={};for(const l of Object.keys(s)){const u=s[l];u!=null&&u!==""&&(o[l]=u)}t(o)})},a=s=>{const{name:o,type:l,description:u}=s,d={placeholder:u||`请输入${o}`};switch(l){case"integer":return k.jsx(wu,{...d,style:{width:"100%"}});case"array":return k.jsx(zr,{...d});case"boolean":return k.jsx(zr,{...d});case"string":default:return k.jsx(zr,{...d})}};return k.jsx("div",{className:"wandox-solidify-params-form",children:k.jsxs(Sn,{form:n,layout:"inline",onFinish:i,style:{marginBottom:16},children:[e.map(s=>k.jsx(Sn.Item,{name:s.name,label:s.description||s.name,rules:[{required:s.required,message:`请输入${s.description||s.name}`}],style:{marginBottom:8},children:a(s)},s.name)),k.jsx(Sn.Item,{style:{marginBottom:8},children:k.jsx(ur,{type:"primary",htmlType:"submit",loading:r,children:"查询"})})]})})}const D5={fontSize:13,fontWeight:600,color:"#374151",marginBottom:6};function Tnn({open:e,onClose:t,onSuccess:r,editingSchedule:n,webhooks:i}){const a=!n,[s,o]=C.useState(""),[l,u]=C.useState(!0),[d,h]=C.useState(""),[f,p]=C.useState(0),[g,m]=C.useState(""),[v,y]=C.useState(""),[x,b]=C.useState(""),[w,S]=C.useState([]),[_,T]=C.useState({}),[E,I]=C.useState(!1),[$,A]=C.useState({}),[P,N]=C.useState({}),[R,L]=C.useState([]),[D,M]=C.useState([]),[O,F]=C.useState(!1),[B,V]=C.useState(!1),z=C.useCallback(async(K,X)=>{var Z;if(!K){S([]),T({});return}I(!0);try{const{data:Q}=await zA({playbook_id:K}),J=((Z=Q==null?void 0:Q.content)==null?void 0:Z.yaml_content)||"";let re=[];if(J)try{const ee=n8.parse(J),se=ee==null?void 0:ee.params;Array.isArray(se)&&se.length>0?re=se:se&&typeof se=="object"&&(re=Object.values(se))}catch{}if(S(re),re.length>0){const ee={};for(const se of re){const ue=X==null?void 0:X[se.name];ue!==void 0?ee[se.name]=ue:se.default!==void 0&&se.default!==null&&(ee[se.name]=se.default)}T(ee)}else T({})}catch{S([])}I(!1)},[]),H=C.useCallback(async()=>{var K,X;F(!0);try{const[Z,Q]=await Promise.all([Vkr({page:1,page_size:200}),eve({page:1,page_size:100})]),J=((K=Z==null?void 0:Z.data)==null?void 0:K.items)??(Array.isArray(Z==null?void 0:Z.data)?Z==null?void 0:Z.data:[]),re=((X=Q==null?void 0:Q.data)==null?void 0:X.items)??(Array.isArray(Q==null?void 0:Q.data)?Q==null?void 0:Q.data:[]);L(J.map(ee=>({value:ee.playbook_id??String(ee.id),label:ee.name}))),M(re.map(ee=>({value:String(ee.id),label:ee.name})))}catch{}F(!1)},[]);C.useEffect(()=>{if(e)if(p(K=>K+1),A({}),N({}),n){o(n.name||""),u(n.is_active),h(n.cron_expression||"");const K=n.playbook_params||{};T(K),z(n.playbook_id||"",K)}else o(""),u(!0),h(""),m(""),y(""),b(""),S([]),T({}),H()},[e,n,z,H]),C.useEffect(()=>{a&&(g?z(g):(S([]),T({})))},[g,a,z]);const W=(K,X)=>{T(Z=>({...Z,[K]:X}))},G=K=>async({file:X,onSuccess:Z,onError:Q})=>{var J,re;A(ee=>({...ee,[K.name]:!0}));try{const ee=X,se=await WS(ee),ue=(J=se==null?void 0:se.data)==null?void 0:J.url,le=((re=se==null?void 0:se.data)==null?void 0:re.name)||ee.name||(ue==null?void 0:ue.split("/").pop())||"未知文件";if(!ue)throw new Error("上传失败");N(oe=>({...oe,[ue]:le})),(K.max_files??1)<=1?W(K.name,ue):T(oe=>{const Se=Array.isArray(oe[K.name])?oe[K.name]:oe[K.name]?[oe[K.name]]:[];return{...oe,[K.name]:[...Se,ue]}}),Z==null||Z(se),$t.success("上传成功")}catch(ee){Q==null||Q(ee instanceof Error?ee:new Error("文件上传失败")),$t.error(ee instanceof Error?ee.message:"文件上传失败")}finally{A(ee=>({...ee,[K.name]:!1}))}},q=K=>{const X=_[K.name];if(D9(K))return k.jsx(c_e,{field:K,value:X,onChange:Z=>W(K.name,Z)});switch(K.type){case"string":return k.jsx(zr.TextArea,{value:X??"",onChange:Z=>W(K.name,Z.target.value),autoSize:{minRows:1,maxRows:4},placeholder:K.description||""});case"number":case"integer":case"float":return k.jsx(wu,{style:{width:"100%"},value:X,onChange:Z=>W(K.name,Z),placeholder:K.description||"",precision:K.type==="integer"?0:void 0,size:"small"});case"boolean":return k.jsx(Dc,{size:"small",checked:!!X,onChange:Z=>W(K.name,Z)});case"array":case"object":return k.jsx(zr.TextArea,{value:typeof X=="string"?X:X!=null?JSON.stringify(X):"",onChange:Z=>W(K.name,Z.target.value),autoSize:{minRows:1,maxRows:4},placeholder:K.description||"JSON 格式"});case"file":{const Z=K.max_files??1,Q=Array.isArray(X)?X.map(String):X?[String(X)]:[],J=Q.length<Z,re=ee=>{Z<=1?W(K.name,""):W(K.name,Q.filter((se,ue)=>ue!==ee))};return k.jsxs("div",{children:[Q.length>0&&k.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6,marginBottom:8},children:Q.map((ee,se)=>k.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,minHeight:30,padding:"4px 8px",border:"1px solid #e5e7eb",borderRadius:6,background:"#fff"},children:[k.jsx("span",{style:{flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontSize:12},children:P[ee]||ee.split("/").pop()||ee}),k.jsx(ur,{type:"text",size:"small",danger:!0,onClick:()=>re(se),children:"删除"})]},ee))}),J&&k.jsx(qp,{accept:K.file_type||void 0,showUploadList:!1,customRequest:G(K),disabled:!!$[K.name],children:k.jsx(ur,{size:"small",icon:k.jsx(qO,{}),loading:!!$[K.name],children:$[K.name]?"上传中...":"点击上传"})})]})}default:return k.jsx(zr,{value:X??"",onChange:Z=>W(K.name,Z.target.value),placeholder:K.description||"",size:"small"})}},Y=async()=>{if(!s.trim()){$t.warning("请输入任务名称");return}if(!d.trim()){$t.warning("请配置调度频率");return}if(a&&!g){$t.warning("请选择剧本");return}const K=w.length>0?_:void 0;V(!0);try{n?(await JZe(n.schedule_id,{},{name:s,cron_expression:d,schedule_type:"custom",is_active:l,playbook_params:K}),$t.success("更新成功")):(await ZZe({},{name:s,agent_id:v,playbook_id:g,webhook_id:x,cron_expression:d,schedule_type:"custom",playbook_params:K}),$t.success("创建成功")),r(),t()}catch(X){$t.error((X==null?void 0:X.message)||"操作失败")}finally{V(!1)}};return k.jsxs(_i,{title:null,open:e,onOk:Y,onCancel:t,okText:"保存",cancelText:"取消",width:540,confirmLoading:B,closable:!1,children:[k.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:20},children:[k.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[k.jsx(No,{style:{fontSize:20,color:"#722ed1"}}),k.jsx("span",{style:{fontSize:16,fontWeight:600,color:"#111827"},children:a?"新增定时任务":"编辑定时任务"})]}),k.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[k.jsx("span",{style:{fontSize:13,color:l?"#111827":"#9ca3af"},children:l?"已启用":"已禁用"}),k.jsx(Dc,{checked:l,onChange:u})]})]}),k.jsxs("div",{style:{marginBottom:16},children:[k.jsxs("div",{style:D5,children:["任务名称 ",k.jsx("span",{style:{color:"#ef4444"},children:"*"})]}),k.jsx(zr,{value:s,onChange:K=>o(K.target.value),placeholder:"请输入任务名称",style:{borderRadius:8}})]}),a&&k.jsxs(Yi,{spinning:O,children:[k.jsxs("div",{style:{marginBottom:16},children:[k.jsxs("div",{style:D5,children:["剧本 ",k.jsx("span",{style:{color:"#ef4444"},children:"*"})]}),k.jsx(wn,{style:{width:"100%"},value:g||void 0,onChange:K=>m(K),options:R,placeholder:"请选择剧本",showSearch:!0,filterOption:(K,X)=>{var Z;return(Z=X==null?void 0:X.label)==null?void 0:Z.toLowerCase().includes(K.toLowerCase())}})]}),k.jsxs("div",{style:{marginBottom:16},children:[k.jsx("div",{style:D5,children:"智能体"}),k.jsx(wn,{style:{width:"100%"},value:v||void 0,onChange:K=>y(K),options:D,placeholder:"请选择智能体(可选)",showSearch:!0,allowClear:!0,filterOption:(K,X)=>{var Z;return(Z=X==null?void 0:X.label)==null?void 0:Z.toLowerCase().includes(K.toLowerCase())}})]}),k.jsxs("div",{style:{marginBottom:16},children:[k.jsx("div",{style:D5,children:"通知 Webhook"}),k.jsx(wn,{style:{width:"100%"},value:x||void 0,onChange:K=>b(K),options:i.map(K=>({value:K.webhook_id,label:K.name})),placeholder:"请选择 Webhook(可选)",allowClear:!0})]})]}),k.jsxs("div",{style:{marginBottom:16},children:[k.jsx("div",{style:D5,children:"调度频率"}),k.jsx(n_e,{defaultValue:n==null?void 0:n.cron_expression,onChange:K=>h(K)},f)]}),E&&k.jsxs("div",{style:{textAlign:"center",padding:"12px 0"},children:[k.jsx(Yi,{size:"small"}),k.jsx("span",{style:{marginLeft:8,fontSize:12,color:"#9ca3af"},children:"加载参数配置..."})]}),!E&&w.length>0&&k.jsxs("div",{style:{marginBottom:16},children:[k.jsx("div",{style:D5,children:"执行参数"}),k.jsx("div",{style:{background:"#f9fafb",border:"1px solid #e5e7eb",borderRadius:8,padding:"12px 16px"},children:w.map(K=>k.jsxs("div",{style:{marginBottom:12},children:[k.jsxs("div",{style:{fontSize:12,fontWeight:500,color:"#374151",marginBottom:4},children:[K.label||K.name,K.required&&k.jsx("span",{style:{color:"#ef4444",marginLeft:2},children:"*"})]}),K.description&&k.jsx("div",{style:{fontSize:11,color:"#9ca3af",marginBottom:4},children:K.description}),q(K)]},K.name))})]})]})}const Enn={daily:"每天",weekly:"每周",monthly:"每月",workday:"工作日",custom:"自定义"},knn={1:"周一",2:"周二",3:"周三",4:"周四",5:"周五",6:"周六",7:"周日",0:"周日"};function Ann(e){const t=CQ(e),r=`${String(t.hour).padStart(2,"0")}:${String(t.minute).padStart(2,"0")}`;switch(t.unit){case"hour":return t.interval===1?`每小时第 ${t.minute} 分`:`每 ${t.interval} 小时`;case"week":return`每${t.weekDays.map(i=>knn[i]||"").filter(Boolean).join("、")} ${r}`;case"month":return t.interval===1?`每月 ${t.monthDay} 号 ${r}`:`每 ${t.interval} 月 ${t.monthDay} 号 ${r}`;case"year":return`每年 ${t.yearMonth} 月 ${t.yearDay} 日 ${r}`;case"day":return t.interval===1?`每天 ${r}`:`每 ${t.interval} 天 ${r}`;case"custom":return t.customCron.trim()?`自定义:${t.customCron.trim()}`:e;default:return e}}const Inn=({className:e})=>{const[t,r]=C.useState([]),[n,i]=C.useState(!1),[a,s]=C.useState(!1),[o,l]=C.useState(null),[u]=Sn.useForm(),[d,h]=C.useState(),[f,p]=C.useState([]),[g,m]=C.useState(!1),[v,y]=C.useState(!1),[x,b]=C.useState(null);C.useEffect(()=>{S(),P()},[]);const w=[{label:"钉钉",value:"dingtalk"},{label:"飞书",value:"feishu"},{label:"企业微信",value:"wecom"}],S=async()=>{try{i(!0);const M=await jq({});M!=null&&M.data&&r(M.data)}catch(M){$t.error((M==null?void 0:M.message)||"加载失败")}finally{i(!1)}},_=()=>{l(null),u.resetFields(),h(void 0),s(!0)},T=async M=>{try{i(!0);const O=await Zkr(M.webhook_id,{}),F=(O==null?void 0:O.data)||M;l(F),h(F.platform),u.setFieldsValue({...F,notify_time:F.notify_start_time&&F.notify_end_time?[Yr(F.notify_start_time,"HH:mm:ss"),Yr(F.notify_end_time,"HH:mm:ss")]:void 0}),s(!0)}catch(O){$t.error((O==null?void 0:O.message)||"获取详情失败")}finally{i(!1)}},E=async M=>{try{i(!0),await e4r(M.webhook_id,{}),$t.success("测试消息发送成功")}catch(O){$t.error((O==null?void 0:O.message)||"测试失败")}finally{i(!1)}},I=M=>{_i.confirm({title:"确认删除",content:`确定要删除 Webhook "${M.name}" 吗?`,okText:"确定",cancelText:"取消",onOk:async()=>{try{await Jkr(M.webhook_id,{}),$t.success("删除成功"),S()}catch(O){$t.error((O==null?void 0:O.message)||"删除失败")}}})},$=async()=>{var M,O,F,B;try{const V=await u.validateFields();i(!0);const z={name:V.name,description:V.description,platform:V.platform,webhook_url:V.webhook_url,secret:V.secret,notify_start_time:(O=(M=V.notify_time)==null?void 0:M[0])==null?void 0:O.format("HH:mm:ss"),notify_end_time:(B=(F=V.notify_time)==null?void 0:F[1])==null?void 0:B.format("HH:mm:ss"),is_active:V.is_active,is_default:V.is_default};o?(await Qkr(o.webhook_id,{},z),$t.success("更新成功")):(await XZe({},z),$t.success("创建成功")),s(!1),u.resetFields(),S()}catch(V){$t.error((V==null?void 0:V.message)||"操作失败")}finally{i(!1)}},A=[{title:"名称",dataIndex:"name",key:"name",width:150,render:(M,O)=>{const F={dingtalk:k.jsx(Z_r,{style:{color:"#1677ff"}}),feishu:k.jsx(mXe,{style:{color:"#1677ff"}}),wecom:k.jsx(WTr,{style:{color:"#1677ff"}})};return k.jsxs(il,{size:4,children:[F[O.platform],k.jsx("span",{children:M})]})}},{title:"描述",dataIndex:"description",key:"description",ellipsis:!0},{title:"通知时段",key:"notify_time",width:150,render:(M,O)=>!O.notify_start_time||!O.notify_end_time?"全天":`${O.notify_start_time} ~ ${O.notify_end_time}`},{title:"状态",dataIndex:"is_active",key:"is_active",width:88,render:M=>k.jsx(as,{color:M?"success":"default",bordered:!1,children:M?"已启用":"已停用"})},{title:"默认渠道",dataIndex:"is_default",key:"is_default",width:96,render:M=>M?k.jsx(as,{color:"blue",bordered:!1,children:"默认"}):k.jsx("span",{className:"wandox-notification-muted",children:"—"})},{title:"操作",key:"action",width:210,render:(M,O)=>k.jsxs(il,{size:0,children:[k.jsx(ur,{type:"link",size:"small",icon:k.jsx(HO,{}),onClick:()=>T(O),className:"wandox-webhook-action-btn",children:k.jsx("span",{className:"wandox-webhook-action-text",children:"编辑"})}),k.jsx(ur,{type:"link",size:"small",icon:k.jsx(o0e,{}),onClick:()=>E(O),className:"wandox-webhook-action-btn",children:k.jsx("span",{className:"wandox-webhook-action-text",children:"测试"})}),k.jsx(ur,{type:"link",size:"small",danger:!0,icon:k.jsx(Mv,{}),onClick:()=>I(O),className:"wandox-webhook-action-btn",children:k.jsx("span",{className:"wandox-webhook-action-text",children:"删除"})})]})}],P=async()=>{try{m(!0);const M=await QZe({});if(M!=null&&M.data){const O=Array.isArray(M.data)?M.data:M.data.items||[];p(O)}}catch{}finally{m(!1)}},N=M=>{if(M.cron_expression)return Ann(M.cron_expression);const O=Enn[M.schedule_type]||M.schedule_type,F=M.schedule_time||"--:--";return`${O} ${F}`},R=M=>{b(M),y(!0)},L=M=>{_i.confirm({title:"确认删除",content:`确定要删除定时任务「${M.name}」吗?`,okText:"确定",cancelText:"取消",onOk:async()=>{try{await eQe(M.schedule_id,{}),$t.success("删除成功"),P()}catch(O){$t.error((O==null?void 0:O.message)||"删除失败")}}})},D=[{title:"任务名称",dataIndex:"name",key:"name",width:150,render:M=>k.jsxs(il,{size:4,children:[k.jsx(No,{style:{color:"#722ed1"}}),k.jsx("span",{children:M})]})},{title:"调度规则",key:"schedule_desc",width:180,render:(M,O)=>k.jsx("span",{style:{fontFamily:"monospace",fontSize:12},children:N(O)})},{title:"通知渠道",dataIndex:"webhook_name",key:"agent_name",width:120,ellipsis:!0,render:M=>M||"-"},{title:"状态",dataIndex:"is_active",key:"is_active",width:70,render:M=>k.jsx(as,{color:M?"green":"default",children:M?"启用":"禁用"})},{title:"操作",key:"action",width:140,render:(M,O)=>k.jsxs(il,{size:0,children:[k.jsx(ur,{type:"link",size:"small",icon:k.jsx(HO,{}),onClick:()=>R(O),className:"wandox-webhook-action-btn",children:k.jsx("span",{className:"wandox-webhook-action-text",children:"编辑"})}),k.jsx(ur,{type:"link",size:"small",danger:!0,icon:k.jsx(Mv,{}),onClick:()=>L(O),className:"wandox-webhook-action-btn",children:k.jsx("span",{className:"wandox-webhook-action-text",children:"删除"})})]})}];return k.jsxs("div",{className:`wandox-webhook-management ${e||""}`,children:[k.jsxs("div",{className:"wandox-notification-overview",children:[k.jsxs("article",{className:"wandox-notification-stat",children:[k.jsx("span",{className:"wandox-notification-stat__icon wandox-notification-stat__icon--primary",children:k.jsx(zme,{})}),k.jsxs("div",{children:[k.jsx("strong",{children:t.length}),k.jsx("span",{children:"通知渠道"})]})]}),k.jsxs("article",{className:"wandox-notification-stat",children:[k.jsx("span",{className:"wandox-notification-stat__icon wandox-notification-stat__icon--success",children:k.jsx(lq,{})}),k.jsxs("div",{children:[k.jsx("strong",{children:t.filter(M=>M.is_active).length}),k.jsx("span",{children:"已启用渠道"})]})]}),k.jsxs("article",{className:"wandox-notification-stat",children:[k.jsx("span",{className:"wandox-notification-stat__icon wandox-notification-stat__icon--purple",children:k.jsx(No,{})}),k.jsxs("div",{children:[k.jsx("strong",{children:f.filter(M=>M.is_active).length}),k.jsx("span",{children:"启用中的定时任务"})]})]})]}),k.jsxs("section",{className:"wandox-notification-section",children:[k.jsxs("header",{className:"wandox-notification-section__header",children:[k.jsxs("div",{className:"wandox-notification-section__heading",children:[k.jsx("span",{className:"wandox-notification-section__icon",children:k.jsx(zme,{})}),k.jsxs("div",{children:[k.jsxs("div",{className:"wandox-notification-section__title-row",children:[k.jsx("h2",{children:"通知渠道"}),k.jsx("span",{children:t.length})]}),k.jsx("p",{children:"管理钉钉、飞书和企业微信的消息接收地址"})]})]}),k.jsx(ur,{type:"primary",icon:k.jsx(xu,{}),onClick:_,children:"新增通知渠道"})]}),k.jsx("div",{className:"wandox-notification-section__body",children:k.jsx(Su,{size:"middle",columns:A,dataSource:t,rowKey:"webhook_id",loading:n,pagination:t.length>10?{pageSize:10,showSizeChanger:!0,showTotal:M=>`共 ${M} 条`}:!1,scroll:{x:820}})})]}),k.jsxs("section",{className:"wandox-notification-section",children:[k.jsx("header",{className:"wandox-notification-section__header",children:k.jsxs("div",{className:"wandox-notification-section__heading",children:[k.jsx("span",{className:"wandox-notification-section__icon wandox-notification-section__icon--purple",children:k.jsx(No,{})}),k.jsxs("div",{children:[k.jsxs("div",{className:"wandox-notification-section__title-row",children:[k.jsx("h2",{children:"定时任务"}),k.jsx("span",{children:f.length})]}),k.jsx("p",{children:"查看和维护通过通知渠道触发的周期任务"})]})]})}),k.jsx("div",{className:"wandox-notification-section__body",children:k.jsx(Su,{size:"middle",columns:D,dataSource:f,rowKey:"schedule_id",loading:g,pagination:f.length>10?{pageSize:10,showSizeChanger:!0,showTotal:M=>`共 ${M} 条`}:!1,scroll:{x:780}})})]}),k.jsx(_i,{title:o?"编辑 Webhook":"新增 Webhook",open:a,onOk:$,onCancel:()=>{s(!1),u.resetFields()},width:600,confirmLoading:n,okText:"确定",cancelText:"取消",children:k.jsxs(Sn,{form:u,layout:"horizontal",initialValues:{is_active:!0,is_default:!1},labelCol:{flex:"0 0 80px"},style:{paddingTop:16},children:[k.jsx(Sn.Item,{label:"名称",name:"name",rules:[{required:!0,message:"请输入名称"}],children:k.jsx(zr,{placeholder:"请输入 Webhook 名称"})}),k.jsx(Sn.Item,{label:"描述",name:"description",children:k.jsx(zr.TextArea,{rows:2,placeholder:"请输入描述(可选)"})}),k.jsx(Sn.Item,{label:"平台",name:"platform",rules:[{required:!0,message:"请选择平台"}],children:k.jsx(wn,{options:w,placeholder:"请选择平台",onChange:M=>h(M)})}),k.jsx(Sn.Item,{label:"URL",name:"webhook_url",rules:[{required:!0,message:"请输入 Webhook URL"},{type:"url",message:"请输入有效的 URL"}],children:k.jsx(zr,{placeholder:"https://...",autoComplete:"off"})}),d!=="wecom"&&k.jsx(Sn.Item,{label:"签名密钥",name:"secret",rules:[{required:d==="dingtalk"||d==="feishu",message:"请输入签名密钥"}],children:k.jsx(zr.Password,{placeholder:"请输入签名密钥",autoComplete:"new-password"})}),k.jsx(Sn.Item,{label:"通知时段",name:"notify_time",children:k.jsx(tc.RangePicker,{format:"HH:mm",placeholder:["开始时间","结束时间"],style:{width:"100%"}})}),k.jsx(Sn.Item,{label:"启用",name:"is_active",valuePropName:"checked",children:k.jsx(Dc,{})}),k.jsx(Sn.Item,{label:"设为默认",name:"is_default",valuePropName:"checked",children:k.jsx(Dc,{})})]})}),k.jsx(Tnn,{open:v,onClose:()=>{y(!1),b(null)},onSuccess:P,editingSchedule:x,webhooks:t})]})},{RangePicker:jfi}=Es;function $nn({open:e,loading:t,playbooks:r,activePlaybookId:n,onClose:i,onPlaybookClick:a,onPlaybookDelete:s}){return k.jsx(dA,{title:"工具箱",placement:"right",size:"min(440px, 100vw)",open:e,loading:t,onClose:i,getContainer:!1,rootClassName:"wandox-toolbox-drawer",styles:{body:{padding:0,overflow:"hidden"}},children:k.jsx(Cnn,{playbooks:r,onPlaybookClick:a,onPlaybookDelete:s,activePlaybookId:n})})}const Rnn=["智能体对话","非 ASIN 查询场景","巡检机器人定时任务"];function j9(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function wy(e){return e==null?!1:typeof e=="string"?e.trim().length>0:!0}function j0t(e){if(Array.isArray(e)){if(e.length===0)return null;const t=e.find(r=>j9(r)?Object.keys(r).length>0:wy(r));return j9(t)?t:wy(t)?{value:t}:null}return j9(e)?Object.keys(e).length>0?e:null:wy(e)?{value:e}:null}function Ph(e,t,r=0){if(e){for(const n of t){const i=e[n];if(wy(i))return i}if(!(r>=2))for(const n of Object.values(e)){if(j9(n)){const i=Ph(n,t,r+1);if(wy(i))return i}if(Array.isArray(n))for(const i of n){if(!j9(i))continue;const a=Ph(i,t,r+1);if(wy(a))return a}}}}function qx(e){if(wy(e))return String(e).trim()}function Nnn(e){return Array.from(e).slice(0,4).join("")}function O5(e){const t=qx(e);if(!t)return;const r=t.match(/^(\d{4}-\d{2}-\d{2})/);return(r==null?void 0:r[1])||t}function Lnn(e){return Array.isArray(e)?e.map(t=>qx(t)).filter(t=>!!t):[]}function Pnn(e){const t=qx(e);if(!(!t||!/^#[\da-f]{3}([\da-f]{3})?$/i.test(t)))return t}function Mnn(e){const t=e.slice(1),r=t.length===3?t.split("").map(o=>`${o}${o}`).join(""):t,n=Number.parseInt(r.slice(0,2),16),i=Number.parseInt(r.slice(2,4),16),a=Number.parseInt(r.slice(4,6),16);return(n*299+i*587+a*114)/1e3>=160?"#1f1f1f":"#ffffff"}function v_e(e){if(!wy(e))return;if(typeof e=="number"&&Number.isFinite(e))return new Intl.NumberFormat("en-US").format(e);const t=String(e).trim(),r=t.replace(/,/g,""),n=Number(r);return r&&Number.isFinite(n)?new Intl.NumberFormat("en-US").format(n):t}function V0t(e,t){if(!wy(e))return t;const r=String(e).trim();return["infinite","unlimited","∞"].includes(r.toLowerCase())?"∞ 无限":v_e(e)||t}function Dnn(e){const t=qx(e==null?void 0:e.package_name);if(!(!t||t==="无限算力年卡"))return t}function Onn(e){const t=qx(Ph(e,["asin_usage","asin_usage_text","asin_used_display","usage_text"]));if(t)return t;const r=v_e(Ph(e,["used_asin","asin_used","used_asin_count","asin_used_count","asin_used_num","asin_num_by_use","used_count","used_num","used","consumed_asin","query_used_count"])),n=v_e(Ph(e,["total_asin","asin_total","total_asin_count","asin_total_count","asin_limit","asin_quota","asin_num","total_count","total_num","limit","quota","total"]));if(!(!r&&!n))return`${r||"-"} / ${n||"-"}`}function Bnn(e){const t=Ph(e,["used_asin","asin_used","used_asin_count","asin_used_count","asin_used_num","asin_num_by_use","used_count","used_num","used","consumed_asin","query_used_count"]),r=Ph(e,["total_asin","asin_total","total_asin_count","asin_total_count","asin_limit","asin_quota","asin_num","total_count","total_num","limit","quota","total"]),n=Number(String(t??"").replace(/,/g,"")),i=Number(String(r??"").replace(/,/g,""));if(!(!Number.isFinite(n)||!Number.isFinite(i)||i<=0))return Math.min(Math.round(n/i*100),100)}function y_e(e){var a,s,o;if(!e)return null;const t=j0t(e.competitive_asin_info);if(t)return{kind:"competitiveAsin",badgeText:"包年权益",badgeColor:"#9444f5",badgeTextColor:"#ffffff",packageName:qx(Ph(t,["package_name","packageName","plan_name","benefit_name","name","title","package_type"]))||Dnn(e.package_info)||"竞品智能体包年权益",subtitle:"竞品智能体专属权益",remainingLabel:"剩余算力(非ASIN查询):",remainingValue:V0t(Ph(t,["token_num","tokenNum","remaining_token","token_remaining","remaining_power","power_remaining"])??((a=e.package_info)==null?void 0:a.token_num),"∞ 无限"),asinUsage:Onn(t),asinUsagePercent:Bnn(t),endTime:O5(Ph(t,["end_time","endTime","expire_time","expired_at","expires_at","end_date","package_end_time"]))||O5((s=e.package_info)==null?void 0:s.end_time)||"-",startTime:O5(Ph(t,["start_time","startTime","open_time","opened_at","started_at","start_date","package_start_time"]))||O5((o=e.package_info)==null?void 0:o.start_time)||"-",coverageTitle:"无限算力覆盖范围",coverageItems:Rnn};const r=j0t(e.package_info);if(!r)return null;const n=qx(Ph(r,["package_name","packageName"]))||"套餐权益",i=Pnn(Ph(r,["package_color","packageColor"]))||"#9444f5";return{kind:"free",badgeText:Nnn(n),badgeColor:i,badgeTextColor:Mnn(i),packageName:n,remainingLabel:"剩余算力:",remainingValue:V0t(r.token_num,"-"),endTime:O5(r.end_time)||"-",startTime:O5(r.start_time)||"-",coverageTitle:qx(r.detail_title)||"套餐权益",coverageItems:Lnn(r.detail_ul)}}const Fnn=[{label:"钉钉",value:"dingtalk"},{label:"飞书",value:"feishu"},{label:"企业微信",value:"wecom"}];function H0t({open:e,onClose:t,onSuccess:r}){const{t:n}=Fv(),[i]=Sn.useForm(),[a,s]=C.useState(!1),[o,l]=C.useState(),u=async()=>{try{const h=await i.validateFields();s(!0);const f={name:h.name,platform:h.platform,webhook_url:h.webhook_url,secret:h.secret||void 0},p=await XZe({},f);p!=null&&p.data?($t.success(n("webhook.createSuccess")),r({webhook_id:p.data.webhook_id||p.data.id,name:h.name,platform:h.platform}),i.resetFields(),t()):$t.error(n("webhook.createFailed"))}catch(h){h instanceof Error&&$t.error(h.message||n("webhook.createFailed"))}finally{s(!1)}},d=()=>{i.resetFields(),l(void 0),t()};return k.jsx(_i,{title:n("webhook.quickAdd"),open:e,onOk:u,onCancel:d,confirmLoading:a,width:480,destroyOnHidden:!0,zIndex:1e4,children:k.jsxs(Sn,{form:i,layout:"vertical",preserve:!1,children:[k.jsx(Sn.Item,{label:n("webhook.name"),name:"name",rules:[{required:!0,message:n("webhook.nameRequired")}],children:k.jsx(zr,{placeholder:n("webhook.namePlaceholder")})}),k.jsx(Sn.Item,{label:n("webhook.platform"),name:"platform",rules:[{required:!0,message:n("webhook.platformRequired")}],children:k.jsx(wn,{options:Fnn,placeholder:n("webhook.platformPlaceholder"),onChange:h=>l(h)})}),k.jsx(Sn.Item,{label:"Webhook URL",name:"webhook_url",rules:[{required:!0,message:n("webhook.urlRequired")},{type:"url",message:n("webhook.urlInvalid")}],children:k.jsx(zr,{placeholder:"https://...",autoComplete:"off"})}),o!=="wecom"&&k.jsx(Sn.Item,{label:n("webhook.secret"),name:"secret",rules:[{required:o==="dingtalk"||o==="feishu",message:n("webhook.secretRequired")}],children:k.jsx(zr.Password,{placeholder:n("webhook.secretPlaceholder"),autoComplete:"new-password"})})]})})}const znn="https://ai.maiduox.com/#/aitools/operation/product";function jnn(e){const{title:t,widgets:r,ssoDomain:n,ssoToken:i,ssoCompany:a,onExecuteComplete:s,activeAgent:o,agents:l,childAgents:u,externalRobotName:d,externalShowPanel:h,agentSwitcher:f}=e;e.onWidgetsUpdate,e.count,Fv();const[p,g]=C.useState(!1),[m,v]=C.useState(!1),[y,x]=C.useState(null),[b,w]=C.useState(null),[S,_]=C.useState("results"),[T,E]=C.useState(!1),[I,$]=C.useState([]),[A,P]=C.useState(null),[N,R]=C.useState({}),[L,D]=C.useState([]),[M,O]=C.useState(!1),[F,B]=C.useState(null),[V,z]=C.useState(void 0),[H,W]=C.useState(!1),[G,q]=C.useState(!1),Y=C.useMemo(()=>(u||[]).map(me=>me.name),[u]),K=C.useMemo(()=>!o||o==="default"?null:(l==null?void 0:l.find(ye=>ye.agent_id===o||ye.agent_code===o))||null,[o,l]),X=C.useMemo(()=>y_e(K),[K]);C.useEffect(()=>{w(null)},[o]),C.useEffect(()=>{Z(),u&&u.length>0&&Q()},[u]),C.useEffect(()=>{if(h&&(g(!0),d)){const me=Y.find(ye=>ye===d);me?w(me):Y.length>0}},[h,d,Y]);const Z=async()=>{try{const me=await jq({});me!=null&&me.data&&D(me.data.map(ye=>({webhook_id:ye.webhook_id,name:ye.name,platform:ye.platform})))}catch{}},Q=async()=>{try{const me={};await Promise.all(u.map(async ye=>{var de;try{const ve=await r4r(ye.agent_id,{});(de=ve==null?void 0:ve.data)!=null&&de.webhook_id&&(me[ye.agent_id]=ve.data.webhook_id)}catch{}})),R(me)}catch{}},J=C.useMemo(()=>b?r.filter(me=>{var ve;const ye=(ve=me.title)==null?void 0:ve.match(/^(.+?)\s*巡检结果$/);return(ye?ye[1]:me.agent_name)===b}):r,[r,b]),re=C.useMemo(()=>{if(!b)return"";const me=(u||[]).find(ye=>ye.name===b);return(me==null?void 0:me.agent_id)||""},[b,u]),ee=n==="maiduo"&&b==="差评监控",se=me=>{const ye=b===me?null:me;w(ye),ye&&g(!0)},ue=me=>{B(me),z(N[me.agent_id]),O(!0)},le=C.useCallback(async me=>{if(me){E(!0);try{const ye=await zkr({agent_id:me,limit:50});if(ye!=null&&ye.data&&Array.isArray(ye.data)){const de=ye.data.map((ve,te)=>({id:ve.id||ve.execute_id||`record_${te}`,action_name:ve.action_name||ve.display_name||"未知动作",action_id:ve.action_id||"",status:ve.status||"pending",created_at:ve.created_at||"",completed_at:ve.completed_at,action_params:ve.action_params,output_type:ve.output_type,output_data:ve.output_data,outputs:ve.outputs,error:ve.error})).sort((ve,te)=>new Date(te.created_at).getTime()-new Date(ve.created_at).getTime());$(de)}else $([])}catch{$([])}finally{E(!1)}}},[]),ne=me=>{if(!me)return"";try{const ye=new Date(me),de=ye.toLocaleDateString("zh-CN",{year:"numeric",month:"2-digit",day:"2-digit"}),ve=ye.toLocaleTimeString("zh-CN",{hour:"2-digit",minute:"2-digit"});return`${de} ${ve}`}catch{return me}},oe=me=>({pending:"等待中",running:"执行中",success:"成功",failed:"失败"})[me]||me,Se=me=>({pending:"wandox-exec-status--pending",running:"wandox-exec-status--running",success:"wandox-exec-status--success",failed:"wandox-exec-status--failed"})[me]||"";C.useEffect(()=>{S==="history"&&re&&le(re)},[S,re,le]);const ie=async()=>{if(!F||!V){$t.warning("请选择 Webhook");return}try{W(!0),await t4r({},{agent_id:F.agent_id,webhook_id:V}),$t.success("绑定成功"),O(!1),Q()}catch(me){$t.error((me==null?void 0:me.message)||"绑定失败")}finally{W(!1)}},be=async()=>{if(F)try{W(!0),await n4r(F.agent_id,{}),$t.success("解绑成功"),O(!1),z(void 0),Q()}catch(me){$t.error((me==null?void 0:me.message)||"解绑失败")}finally{W(!1)}},pe=me=>{x(me),v(!0)},xe=()=>{v(!1),x(null)},Re=me=>{if(!me)return"";try{const ye=new Date(me),de=ye.toLocaleDateString("zh-CN",{year:"numeric",month:"2-digit",day:"2-digit"}),ve=ye.toLocaleTimeString("zh-CN",{hour:"2-digit",minute:"2-digit"});return`${de}
768
+ ${pt}${_e}`,vt=dt.indexOf(": ")+2;S(dt),setTimeout(()=>{var Ye;if(_.current){_.current.focus();const st=(Ye=_.current.resizableTextArea)==null?void 0:Ye.textArea;st==null||st.setSelectionRange(vt,vt)}},0)}catch{if(Ee!==re.current||Qe!==be.current)return;V(!0),Promise.resolve().then(()=>GO).then(({message:Ge})=>Ge.error("剧本参数加载失败,请稍后重试"))}finally{Ee===re.current&&pe.current===Qe&&(pe.current="",J.current="",Q(""))}},Be=()=>{ne(null),S("")},Ze=async()=>{if(!w.trim()&&P.length===0||n||J.current)return;let Le=[];if(P.length>0){Le=await ve();for(const Qe of P)URL.revokeObjectURL(Qe.previewUrl);N([])}const rt=w.trim(),Ee=le==null?void 0:le.playbook_id;S(""),ne(null),xe.clear(),A(!0),s(rt,Ee,Le.length>0?Le:void 0)};return k.jsxs("div",{className:"wandox-chat-input",style:{position:"relative"},onDragEnter:te,onDragLeave:fe,onDragOver:ce,onDrop:he,children:[R&&k.jsx("div",{className:"wandox-chat-input-drag-overlay",children:k.jsxs("div",{className:"wandox-chat-input-drag-content",children:[k.jsx(hTr,{style:{fontSize:32,marginBottom:8}}),k.jsx("div",{children:"释放以发送图片"})]})}),k.jsx("input",{ref:D,type:"file",accept:"image/png,image/jpeg,image/jpg,image/gif,image/webp,image/bmp",multiple:!0,style:{display:"none"},onChange:$e}),B&&q.length>0&&k.jsx("div",{className:"wandox-mention-list",ref:T,children:k.jsx("div",{className:"wandox-mention-items",children:q.map((Le,rt)=>k.jsxs("div",{className:`wandox-mention-item ${rt===K?"wandox-mention-item--active":""}`,onClick:()=>Oe(Le),onKeyDown:()=>{},onMouseEnter:()=>X(rt),children:[k.jsx("div",{className:"wandox-mention-item-icon",children:"📋"}),k.jsxs("div",{className:"wandox-mention-item-content",children:[k.jsxs("div",{className:"wandox-mention-item-name",children:[Le.name,Le.input_fields&&Le.input_fields.length>0&&k.jsx("span",{className:"wandox-mention-item-tag",children:t("recommendation.params")})]}),Le.description&&k.jsx("div",{className:"wandox-mention-item-desc",children:Le.description})]})]},Le.playbook_id))})}),B&&q.length===0&&oe.length>0&&k.jsx("div",{className:"wandox-mention-list",ref:T,children:k.jsx("div",{className:"wandox-mention-empty",children:t("chatInput.noMatchingScenarios")})}),B&&oe.length===0&&k.jsx("div",{className:"wandox-mention-list",ref:T,children:k.jsx("div",{className:"wandox-mention-empty",children:t("chatInput.noAvailableScenarios")})}),k.jsx(T0t,{open:E&&!B&&!n&&!ee,rewrittenQuestion:xe.rewrittenQuestion,questions:xe.questions,loading:xe.loading,placement:"top",onSelectRewrite:Le=>{var rt;S(Le),xe.clear(),(rt=_.current)==null||rt.focus()},onSelectQuestion:Le=>{S(""),ne(null),A(!0),xe.clear(),s(Le.title)}}),ee&&k.jsx("output",{className:"wandox-chat-input-tag","aria-live":"polite",children:k.jsxs(as,{color:"blue",children:[k.jsx(yh,{spin:!0})," 正在读取剧本参数"]})}),le&&k.jsx("div",{className:"wandox-chat-input-tag",children:k.jsx(as,{color:"blue",closable:!0,onClose:Be,closeIcon:k.jsx(Ao,{}),children:le.name})}),$&&r&&!n&&!ee&&k.jsx("button",{className:"wandox-search-suggestion",onClick:O,onKeyDown:F,type:"button",style:{position:"absolute",top:"30px",left:"38px",color:"#999",cursor:"pointer",fontSize:"14px",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",maxWidth:"calc(100% - 80px)",zIndex:1,transition:"color 0.2s ease",background:"none",border:"none",padding:0,textAlign:"left"},onMouseEnter:Le=>{Le.currentTarget.style.color="#1890ff"},onMouseLeave:Le=>{Le.currentTarget.style.color="#999"},children:r}),P.length>0&&k.jsx("div",{className:"wandox-chat-input-previews",children:P.map(Le=>k.jsxs("div",{className:"wandox-chat-input-preview-item",children:[k.jsx("img",{src:Le.previewUrl,alt:Le.file.name,className:"wandox-chat-input-preview-img"}),k.jsx("button",{type:"button",className:"wandox-chat-input-preview-remove",onClick:()=>de(Le.id),title:"删除",children:k.jsx(Ao,{})})]},Le.id))}),k.jsx(Brn,{ref:_,placeholder:$&&r&&!n?"":o||t("chat.input.placeholder"),value:w,disabled:n||ee,onChange:He,onKeyDown:Pe,onPaste:ae,onFocus:()=>I(!0),onBlur:()=>window.setTimeout(()=>I(!1),120),autoSize:{minRows:1,maxRows:6},className:"wandox-chat-textarea",style:{position:"relative",zIndex:2,background:"transparent"}}),k.jsxs("div",{className:"wandox-chat-input-actions",children:[k.jsx("button",{type:"button",className:"wandox-chat-input-icon-btn",title:"上传图片",disabled:n||ee,onClick:Ie,children:k.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[k.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2",stroke:"currentColor",strokeWidth:"2"}),k.jsx("circle",{cx:"8.5",cy:"8.5",r:"1.5",fill:"currentColor"}),k.jsx("polyline",{points:"21 15 16 10 5 21",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]})}),k.jsx("button",{type:"button",className:`wandox-chat-input-icon-btn wandox-chat-input-send-btn${n?" wandox-chat-input-stop-btn":""}`,disabled:ee||(n?i||!a:!w.trim()&&P.length===0),onClick:n?a:Ze,title:n?i?"正在停止":"停止":t("chat.send"),children:n?k.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[k.jsx("circle",{cx:"12",cy:"12",r:"8",stroke:"currentColor",strokeWidth:"2"}),k.jsx("rect",{x:"9",y:"9",width:"6",height:"6",rx:"1",fill:"currentColor"})]}):k.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:k.jsx("path",{d:"M12 19V5M12 5L5 12M12 5L19 12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})]})]})}const L9=[{id:"robot",name:"机器人",description:"紫色渐变机器人头像",component:k.jsxs("svg",{viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[k.jsxs("g",{clipPath:"url(#clip0_2019_548)",children:[k.jsx("path",{d:"M36 0H12C5.37258 0 0 5.37258 0 12V36C0 42.6274 5.37258 48 12 48H36C42.6274 48 48 42.6274 48 36V12C48 5.37258 42.6274 0 36 0Z",fill:"url(#paint0_linear_2019_548)"}),k.jsx("path",{d:"M24 12L28 16L24 20L20 16L24 12Z",fill:"white",fillOpacity:"0.95"}),k.jsx("path",{d:"M24 30C27.3137 30 30 27.3137 30 24C30 20.6863 27.3137 18 24 18C20.6863 18 18 20.6863 18 24C18 27.3137 20.6863 30 24 30Z",fill:"white",fillOpacity:"0.95"}),k.jsx("path",{d:"M16 28L12 24L16 20L20 24L16 28Z",fill:"white",fillOpacity:"0.8"}),k.jsx("path",{d:"M32 28L28 24L32 20L36 24L32 28Z",fill:"white",fillOpacity:"0.8"}),k.jsx("path",{d:"M24 36L20 32L24 28L28 32L24 36Z",fill:"white",fillOpacity:"0.8"})]}),k.jsxs("defs",{children:[k.jsxs("linearGradient",{id:"paint0_linear_2019_548",x1:"0",y1:"0",x2:"48",y2:"48",gradientUnits:"userSpaceOnUse",children:[k.jsx("stop",{stopColor:"#8B5CF6"}),k.jsx("stop",{offset:"1",stopColor:"#6366F1"})]}),k.jsx("clipPath",{id:"clip0_2019_548",children:k.jsx("rect",{width:"48",height:"48",fill:"white"})})]})]},"icon-robot")},{id:"amazon",name:"亚马逊",description:"橙色渐变亚马逊图标",component:k.jsxs("svg",{viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[k.jsx("path",{d:"M36 0H12C5.37258 0 0 5.37258 0 12V36C0 42.6274 5.37258 48 12 48H36C42.6274 48 48 42.6274 48 36V12C48 5.37258 42.6274 0 36 0Z",fill:"url(#paint0_linear_2026_532)"}),k.jsx("path",{d:"M14.7195 25.2724C14.7195 29.2324 17.217 31.2124 20.4345 31.2124C23.157 31.2124 24.6195 30.5824 26.712 28.4449C27.4095 29.4574 27.6345 29.9299 28.8945 30.9874C29.187 31.1449 29.547 31.1224 29.7945 30.8974C30.5595 30.2224 31.932 29.0074 32.7195 28.3549C33.0345 28.1074 32.967 27.6799 32.742 27.3424C32.0445 26.3749 31.302 25.5874 31.302 23.8099V17.8699C31.302 15.3499 31.482 13.0324 29.6145 11.2999C28.1745 9.90491 25.7445 9.40991 23.877 9.40991C20.2545 9.40991 16.2045 10.7599 15.3495 15.2599C15.2595 15.7324 15.6195 15.9799 15.9345 16.0474L19.6245 16.4524C19.962 16.4299 20.232 16.0924 20.277 15.7549C20.592 14.2024 21.897 13.4599 23.337 13.4599C24.1245 13.4599 25.0245 13.7524 25.4745 14.4499C26.0145 15.2374 25.947 16.3174 25.947 17.2174V17.7124C23.742 17.9599 20.862 18.1174 18.792 19.0399C16.3845 20.0749 14.7195 22.1674 14.7195 25.2724ZM25.947 20.7724V21.6049C25.947 23.0899 25.992 24.3274 25.227 25.6549C24.6195 26.7349 23.652 27.3874 22.5945 27.3874C21.132 27.3874 20.277 26.2624 20.277 24.6199C20.277 21.3574 23.202 20.7724 25.947 20.7724ZM33.9795 32.6749C30.762 34.0474 27.2745 34.6999 24.102 34.6999C19.3995 34.6999 14.832 33.4174 11.1645 31.2574C10.8495 31.0774 10.602 31.3924 10.872 31.6399C14.4197 34.8374 19.0336 36.5947 23.8095 36.5674C27.387 36.5674 31.527 35.4424 34.407 33.3274C34.8795 32.9899 34.4745 32.4724 33.9795 32.6749Z",fill:"white",fillOpacity:"0.95"}),k.jsx("path",{d:"M36.8146 31.0551C36.4996 30.6726 33.8221 30.3351 32.1796 31.4826C31.9321 31.6626 31.9771 31.9101 32.2471 31.8651C33.1696 31.7526 35.2171 31.5051 35.5996 31.9776C35.9596 32.4501 35.1946 34.3851 34.8571 35.2401C34.7446 35.5101 34.9696 35.6001 35.2171 35.3976C36.7246 34.1376 37.1296 31.4376 36.8146 31.0551Z",fill:"white",fillOpacity:"0.8"}),k.jsx("defs",{children:k.jsxs("linearGradient",{id:"paint0_linear_2026_532",x1:"0",y1:"0",x2:"48",y2:"48",gradientUnits:"userSpaceOnUse",children:[k.jsx("stop",{stopColor:"#FF6B35"}),k.jsx("stop",{offset:"1",stopColor:"#F7931E"})]})})]},"icon-amazon")},{id:"star",name:"星星",description:"绿色渐变星星图标",component:k.jsxs("svg",{viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[k.jsxs("g",{clipPath:"url(#clip0_2019_574)",children:[k.jsx("path",{d:"M36 0H12C5.37258 0 0 5.37258 0 12V36C0 42.6274 5.37258 48 12 48H36C42.6274 48 48 42.6274 48 36V12C48 5.37258 42.6274 0 36 0Z",fill:"url(#paint0_linear_2019_574)"}),k.jsx("path",{d:"M18 14H14C12.8954 14 12 14.8954 12 16V20C12 21.1046 12.8954 22 14 22H18C19.1046 22 20 21.1046 20 20V16C20 14.8954 19.1046 14 18 14Z",fill:"white",fillOpacity:"0.95"}),k.jsx("path",{d:"M34 14H30C28.8954 14 28 14.8954 28 16V20C28 21.1046 28.8954 22 30 22H34C35.1046 22 36 21.1046 36 20V16C36 14.8954 35.1046 14 34 14Z",fill:"white",fillOpacity:"0.95"}),k.jsx("path",{d:"M26 26H22C20.8954 26 20 26.8954 20 28V32C20 33.1046 20.8954 34 22 34H26C27.1046 34 28 33.1046 28 32V28C28 26.8954 27.1046 26 26 26Z",fill:"white",fillOpacity:"0.95"}),k.jsx("path",{d:"M16 22V26H20M32 22V26H28M24 26V22",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeOpacity:"0.8"}),k.jsx("path",{d:"M18 30L14 34M30 30L34 34M24 34V36",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeOpacity:"0.8"}),k.jsx("path",{d:"M14 36C15.1046 36 16 35.1046 16 34C16 32.8954 15.1046 32 14 32C12.8954 32 12 32.8954 12 34C12 35.1046 12.8954 36 14 36Z",fill:"white",fillOpacity:"0.7"}),k.jsx("path",{d:"M34 36C35.1046 36 36 35.1046 36 34C36 32.8954 35.1046 32 34 32C32.8954 32 32 32.8954 32 34C32 35.1046 32.8954 36 34 36Z",fill:"white",fillOpacity:"0.7"}),k.jsx("path",{d:"M24 40C25.1046 40 26 39.1046 26 38C26 36.8954 25.1046 36 24 36C22.8954 36 22 36.8954 22 38C22 39.1046 22.8954 40 24 40Z",fill:"white",fillOpacity:"0.7"})]}),k.jsxs("defs",{children:[k.jsxs("linearGradient",{id:"paint0_linear_2019_574",x1:"0",y1:"0",x2:"48",y2:"48",gradientUnits:"userSpaceOnUse",children:[k.jsx("stop",{stopColor:"#10B981"}),k.jsx("stop",{offset:"1",stopColor:"#059669"})]}),k.jsx("clipPath",{id:"clip0_2019_574",children:k.jsx("rect",{width:"48",height:"48",fill:"white"})})]})]},"icon-star")},{id:"gear",name:"齿轮",description:"绿色渐变齿轮图标",component:k.jsxs("svg",{viewBox:"0 0 40 40",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[k.jsx("defs",{children:k.jsxs("linearGradient",{id:"grad4",x1:"0%",y1:"0%",x2:"100%",y2:"100%",children:[k.jsx("stop",{offset:"0%",stopColor:"#14B8A6"}),k.jsx("stop",{offset:"100%",stopColor:"#0891B2"})]})}),k.jsx("rect",{width:"40",height:"40",rx:"12",fill:"url(#grad4)"}),k.jsx("circle",{cx:"20",cy:"20",r:"5",stroke:"white",strokeWidth:"2.5",fill:"none",strokeOpacity:"0.95"}),k.jsx("path",{d:"M20 8V12M20 28V32M8 20H12M28 20H32M11.5 11.5L14.5 14.5M25.5 25.5L28.5 28.5M28.5 11.5L25.5 14.5M14.5 25.5L11.5 28.5",stroke:"white",strokeWidth:"2.5",strokeLinecap:"round",strokeOpacity:"0.8"})]},"icon-gear")},{id:"magic",name:"魔法棒",description:"粉色渐变魔法棒图标",component:k.jsxs("svg",{viewBox:"0 0 40 40",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[k.jsx("defs",{children:k.jsxs("linearGradient",{id:"grad5",x1:"0%",y1:"0%",x2:"100%",y2:"100%",children:[k.jsx("stop",{offset:"0%",stopColor:"#EC4899"}),k.jsx("stop",{offset:"100%",stopColor:"#A855F7"})]})}),k.jsx("rect",{width:"40",height:"40",rx:"12",fill:"url(#grad5)"}),k.jsx("path",{d:"M10 30L26 14L30 18L14 34L10 30Z",fill:"white",fillOpacity:"0.95"}),k.jsx("circle",{cx:"28",cy:"12",r:"2",fill:"white",fillOpacity:"0.8"}),k.jsx("circle",{cx:"32",cy:"18",r:"1.5",fill:"white",fillOpacity:"0.7"}),k.jsx("circle",{cx:"24",cy:"8",r:"1.5",fill:"white",fillOpacity:"0.7"})]},"icon-magic")},{id:"rocket",name:"火箭",description:"青色渐变火箭图标",component:k.jsxs("svg",{viewBox:"0 0 40 40",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[k.jsx("defs",{children:k.jsxs("linearGradient",{id:"grad6",x1:"0%",y1:"0%",x2:"100%",y2:"100%",children:[k.jsx("stop",{offset:"0%",stopColor:"#06B6D4"}),k.jsx("stop",{offset:"100%",stopColor:"#3B82F6"})]})}),k.jsx("rect",{width:"40",height:"40",rx:"12",fill:"url(#grad6)"}),k.jsx("path",{d:"M20 8C20 8 28 12 28 22L24 26L20 24L16 26L12 22C12 12 20 8 20 8Z",fill:"white",fillOpacity:"0.95"}),k.jsx("circle",{cx:"20",cy:"17",r:"2.5",fill:"url(#grad6)"}),k.jsx("path",{d:"M16 28L14 32L18 30L16 28Z",fill:"white",fillOpacity:"0.8"}),k.jsx("path",{d:"M24 28L26 32L22 30L24 28Z",fill:"white",fillOpacity:"0.8"})]},"icon-rocket")},{id:"music",name:"音乐",description:"粉紫渐变音乐图标",component:k.jsxs("svg",{viewBox:"0 0 40 40",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[k.jsx("defs",{children:k.jsxs("linearGradient",{id:"grad7",x1:"0%",y1:"0%",x2:"100%",y2:"100%",children:[k.jsx("stop",{offset:"0%",stopColor:"#EC4899"}),k.jsx("stop",{offset:"100%",stopColor:"#8B5CF6"})]})}),k.jsx("rect",{width:"40",height:"40",rx:"12",fill:"url(#grad7)"}),k.jsx("path",{d:"M26 8L14 11v11.2c-.8-.3-1.6-.5-2.5-.5-2.9 0-5.3 1.6-5.3 3.6s2.4 3.6 5.3 3.6 5.3-1.6 5.3-3.6V14.4l8.7-2.5v5.7c-.8-.3-1.6-.5-2.5-.5-2.9 0-5.3 1.6-5.3 3.6s2.4 3.6 5.3 3.6 5.3-1.6 5.3-3.6V8z",fill:"white",fillOpacity:"0.95"})]},"icon-music")},{id:"sports",name:"运动",description:"蓝绿渐变运动图标",component:k.jsxs("svg",{viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[k.jsx("defs",{children:k.jsxs("linearGradient",{id:"grad8",x1:"0%",y1:"0%",x2:"100%",y2:"100%",children:[k.jsx("stop",{offset:"0%",stopColor:"#06B6D4"}),k.jsx("stop",{offset:"100%",stopColor:"#10B981"})]})}),k.jsx("rect",{width:"48",height:"48",rx:"12",fill:"url(#grad8)"}),k.jsx("circle",{cx:"24",cy:"24",r:"12",stroke:"white",strokeWidth:"2",fill:"none",strokeOpacity:"0.95"}),k.jsx("path",{d:"M24 12L30 18L24 24L18 18L24 12Z",fill:"white",fillOpacity:"0.8"}),k.jsx("path",{d:"M24 24L30 30L24 36L18 30L24 24Z",fill:"white",fillOpacity:"0.8"}),k.jsx("path",{d:"M12 24L18 30L24 24L18 18L12 24Z",fill:"white",fillOpacity:"0.7"}),k.jsx("path",{d:"M24 24L30 18L36 24L30 30L24 24Z",fill:"white",fillOpacity:"0.7"})]},"icon-sports")},{id:"games",name:"游戏",description:"红橙渐变游戏图标",component:k.jsxs("svg",{viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[k.jsx("defs",{children:k.jsxs("linearGradient",{id:"grad9",x1:"0%",y1:"0%",x2:"100%",y2:"100%",children:[k.jsx("stop",{offset:"0%",stopColor:"#EF4444"}),k.jsx("stop",{offset:"100%",stopColor:"#F97316"})]})}),k.jsx("rect",{width:"48",height:"48",rx:"12",fill:"url(#grad9)"}),k.jsx("rect",{x:"12",y:"16",width:"8",height:"8",rx:"2",fill:"white",fillOpacity:"0.95"}),k.jsx("rect",{x:"28",y:"16",width:"8",height:"8",rx:"2",fill:"white",fillOpacity:"0.95"}),k.jsx("rect",{x:"20",y:"24",width:"8",height:"8",rx:"2",fill:"white",fillOpacity:"0.8"}),k.jsx("rect",{x:"12",y:"32",width:"8",height:"4",rx:"1",fill:"white",fillOpacity:"0.7"}),k.jsx("rect",{x:"28",y:"32",width:"8",height:"4",rx:"1",fill:"white",fillOpacity:"0.7"})]},"icon-games")},{id:"expenses",name:"财务",description:"金黄渐变财务图标",component:k.jsxs("svg",{viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[k.jsx("defs",{children:k.jsxs("linearGradient",{id:"grad10",x1:"0%",y1:"0%",x2:"100%",y2:"100%",children:[k.jsx("stop",{offset:"0%",stopColor:"#F59E0B"}),k.jsx("stop",{offset:"100%",stopColor:"#EAB308"})]})}),k.jsx("rect",{width:"48",height:"48",rx:"12",fill:"url(#grad10)"}),k.jsx("path",{d:"M24 12C18 12 13 17 13 23c0 4 2 7 5 9v2c0 2 2 4 4 4h4c2 0 4-2 4-4v-2c3-2 5-5 5-9 0-6-5-11-11-11z",fill:"white",fillOpacity:"0.95"}),k.jsx("rect",{x:"20",y:"34",width:"8",height:"2",rx:"1",fill:"white",fillOpacity:"0.8"}),k.jsx("circle",{cx:"21",cy:"20",r:"1.5",fill:"url(#grad10)"}),k.jsx("circle",{cx:"27",cy:"20",r:"1.5",fill:"url(#grad10)"})]},"icon-expenses")},{id:"sciences",name:"科学",description:"青蓝渐变科学图标",component:k.jsxs("svg",{viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[k.jsx("defs",{children:k.jsxs("linearGradient",{id:"grad11",x1:"0%",y1:"0%",x2:"100%",y2:"100%",children:[k.jsx("stop",{offset:"0%",stopColor:"#0EA5E9"}),k.jsx("stop",{offset:"100%",stopColor:"#3B82F6"})]})}),k.jsx("rect",{width:"48",height:"48",rx:"12",fill:"url(#grad11)"}),k.jsx("path",{d:"M12 36L20 28L28 36L36 28",stroke:"white",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",strokeOpacity:"0.95"}),k.jsx("circle",{cx:"24",cy:"16",r:"4",fill:"white",fillOpacity:"0.8"}),k.jsx("path",{d:"M24 20V28",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeOpacity:"0.7"}),k.jsx("circle",{cx:"16",cy:"32",r:"2",fill:"white",fillOpacity:"0.7"}),k.jsx("circle",{cx:"32",cy:"32",r:"2",fill:"white",fillOpacity:"0.7"})]},"icon-sciences")},{id:"magic-wand",name:"魔法",description:"紫粉渐变魔法图标",component:k.jsxs("svg",{viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[k.jsx("defs",{children:k.jsxs("linearGradient",{id:"grad12",x1:"0%",y1:"0%",x2:"100%",y2:"100%",children:[k.jsx("stop",{offset:"0%",stopColor:"#8B5CF6"}),k.jsx("stop",{offset:"100%",stopColor:"#EC4899"})]})}),k.jsx("rect",{width:"48",height:"48",rx:"12",fill:"url(#grad12)"}),k.jsx("path",{d:"M12 36L24 24L36 36L24 48L12 36Z",fill:"white",fillOpacity:"0.95"}),k.jsx("circle",{cx:"28",cy:"12",r:"2",fill:"white",fillOpacity:"0.8"}),k.jsx("circle",{cx:"36",cy:"20",r:"1.5",fill:"white",fillOpacity:"0.7"}),k.jsx("circle",{cx:"20",cy:"8",r:"1.5",fill:"white",fillOpacity:"0.7"}),k.jsx("circle",{cx:"32",cy:"4",r:"1",fill:"white",fillOpacity:"0.6"})]},"icon-magic-wand")},{id:"animals",name:"动物",description:"绿棕渐变动物图标",component:k.jsxs("svg",{viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[k.jsx("defs",{children:k.jsxs("linearGradient",{id:"grad13",x1:"0%",y1:"0%",x2:"100%",y2:"100%",children:[k.jsx("stop",{offset:"0%",stopColor:"#10B981"}),k.jsx("stop",{offset:"100%",stopColor:"#92400E"})]})}),k.jsx("rect",{width:"48",height:"48",rx:"12",fill:"url(#grad13)"}),k.jsx("ellipse",{cx:"24",cy:"28",rx:"10",ry:"8",fill:"white",fillOpacity:"0.95"}),k.jsx("circle",{cx:"20",cy:"26",r:"2",fill:"url(#grad13)"}),k.jsx("circle",{cx:"28",cy:"26",r:"2",fill:"url(#grad13)"}),k.jsx("path",{d:"M24 30C22 32 20 33 18 33",stroke:"white",strokeWidth:"1.5",strokeLinecap:"round",strokeOpacity:"0.8"}),k.jsx("circle",{cx:"18",cy:"18",r:"4",fill:"white",fillOpacity:"0.8"}),k.jsx("circle",{cx:"30",cy:"18",r:"4",fill:"white",fillOpacity:"0.8"})]},"icon-animals")},{id:"travel",name:"旅行",description:"天蓝渐变旅行图标",component:k.jsxs("svg",{viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[k.jsx("defs",{children:k.jsxs("linearGradient",{id:"grad14",x1:"0%",y1:"0%",x2:"100%",y2:"100%",children:[k.jsx("stop",{offset:"0%",stopColor:"#0EA5E9"}),k.jsx("stop",{offset:"100%",stopColor:"#06B6D4"})]})}),k.jsx("rect",{width:"48",height:"48",rx:"12",fill:"url(#grad14)"}),k.jsx("path",{d:"M8 32L16 16L32 16L40 32L32 40L16 40L8 32Z",fill:"white",fillOpacity:"0.95"}),k.jsx("circle",{cx:"24",cy:"24",r:"3",fill:"url(#grad14)"}),k.jsx("path",{d:"M24 28V32",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeOpacity:"0.8"}),k.jsx("rect",{x:"12",y:"36",width:"4",height:"2",rx:"1",fill:"white",fillOpacity:"0.7"}),k.jsx("rect",{x:"32",y:"36",width:"4",height:"2",rx:"1",fill:"white",fillOpacity:"0.7"})]},"icon-travel")},{id:"nature",name:"自然",description:"绿色渐变自然图标",component:k.jsxs("svg",{viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[k.jsx("defs",{children:k.jsxs("linearGradient",{id:"grad15",x1:"0%",y1:"0%",x2:"100%",y2:"100%",children:[k.jsx("stop",{offset:"0%",stopColor:"#22C55E"}),k.jsx("stop",{offset:"100%",stopColor:"#10B981"})]})}),k.jsx("rect",{width:"48",height:"48",rx:"12",fill:"url(#grad15)"}),k.jsx("path",{d:"M24 12C20 12 16 16 16 20C16 24 18 27 20 28V36C20 38 22 40 24 40C26 40 28 38 28 36V28C30 27 32 24 32 20C32 16 28 12 24 12Z",fill:"white",fillOpacity:"0.95"}),k.jsx("path",{d:"M24 12V20",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeOpacity:"0.8"}),k.jsx("path",{d:"M24 20L20 16M24 20L28 16",stroke:"white",strokeWidth:"1.5",strokeLinecap:"round",strokeOpacity:"0.7"})]},"icon-nature")},{id:"education",name:"教育",description:"深蓝渐变教育图标",component:k.jsxs("svg",{viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[k.jsx("defs",{children:k.jsxs("linearGradient",{id:"grad16",x1:"0%",y1:"0%",x2:"100%",y2:"100%",children:[k.jsx("stop",{offset:"0%",stopColor:"#1E40AF"}),k.jsx("stop",{offset:"100%",stopColor:"#3B82F6"})]})}),k.jsx("rect",{width:"48",height:"48",rx:"12",fill:"url(#grad16)"}),k.jsx("path",{d:"M24 8L8 16V24C8 32 14 38 24 40C34 38 40 32 40 24V16L24 8Z",fill:"white",fillOpacity:"0.95"}),k.jsx("circle",{cx:"24",cy:"22",r:"4",fill:"url(#grad16)"}),k.jsx("path",{d:"M24 26V30",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeOpacity:"0.8"}),k.jsx("path",{d:"M16 36L12 40L8 36",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",strokeOpacity:"0.7"})]},"icon-education")},{id:"health",name:"健康",description:"红色渐变健康图标",component:k.jsxs("svg",{viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[k.jsx("defs",{children:k.jsxs("linearGradient",{id:"grad17",x1:"0%",y1:"0%",x2:"100%",y2:"100%",children:[k.jsx("stop",{offset:"0%",stopColor:"#EF4444"}),k.jsx("stop",{offset:"100%",stopColor:"#DC2626"})]})}),k.jsx("rect",{width:"48",height:"48",rx:"12",fill:"url(#grad17)"}),k.jsx("rect",{x:"20",y:"12",width:"8",height:"24",rx:"4",fill:"white",fillOpacity:"0.95"}),k.jsx("rect",{x:"12",y:"20",width:"24",height:"8",rx:"4",fill:"white",fillOpacity:"0.95"}),k.jsx("circle",{cx:"24",cy:"24",r:"2",fill:"url(#grad17)"})]},"icon-health")},{id:"food",name:"美食",description:"橙色渐变美食图标",component:k.jsxs("svg",{viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[k.jsx("defs",{children:k.jsxs("linearGradient",{id:"grad18",x1:"0%",y1:"0%",x2:"100%",y2:"100%",children:[k.jsx("stop",{offset:"0%",stopColor:"#FB923C"}),k.jsx("stop",{offset:"100%",stopColor:"#F97316"})]})}),k.jsx("rect",{width:"48",height:"48",rx:"12",fill:"url(#grad18)"}),k.jsx("path",{d:"M16 16C16 12 20 8 24 8C28 8 32 12 32 16V32C32 36 28 40 24 40C20 40 16 36 16 32V16Z",fill:"white",fillOpacity:"0.95"}),k.jsx("circle",{cx:"20",cy:"20",r:"1.5",fill:"url(#grad18)"}),k.jsx("circle",{cx:"28",cy:"20",r:"1.5",fill:"url(#grad18)"}),k.jsx("path",{d:"M24 24C22 26 20 27 18 27",stroke:"white",strokeWidth:"1.5",strokeLinecap:"round",strokeOpacity:"0.8"}),k.jsx("path",{d:"M12 32L8 36L12 40",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",strokeOpacity:"0.7"})]},"icon-food")}],Frn="robot",D_=e=>{if(!e){const r=L9.find(n=>n.id===Frn);return(r==null?void 0:r.component)||L9[0].component}const t=L9.find(r=>r.id===e);return(t==null?void 0:t.component)||L9[0].component},zrn=new Map(L9.map(e=>[e.id,e]));function jrn({active:e,agents:t,collapsed:r,onToggle:n,className:i,activeView:a="chat",onViewChange:s,onToolboxOpen:o,showLogout:l,onLogout:u,sidebarAgentMode:d=!1,onToggleSidebarMode:h,onAgentSelect:f}){const p=localStorage.getItem("sso_domain")||"",g=[{key:"chat",icon:k.jsx(mXe,{}),title:"对话"},...["maiduo","eccang"].includes(p)?[{key:"plan",icon:k.jsx(Y_r,{}),title:"自动化Beta"}]:[],{key:"professional",icon:k.jsx(hXe,{}),title:"专业智能体"}],v=[...p==="yunduo"?[]:[{key:"toolbox",icon:k.jsx(LTr,{}),label:"工具箱"},{key:"goals",icon:k.jsx(v_r,{}),label:"目标追踪"}],{key:"settings",icon:k.jsx(zme,{}),label:"通知配置"}];return k.jsx("div",{className:"wandox-aside-wrap",children:k.jsxs("div",{className:`wandox-aside ${r?"wandox-aside--collapsed":""} ${i||""}`,"aria-hidden":r,children:[k.jsxs("div",{className:"wandox-aside-header",children:[k.jsx("span",{className:"wandox-aside-header__title",children:"AI 智能体"}),n&&k.jsx("button",{type:"button",className:"wandox-aside-header-toggle",onClick:n,"aria-label":r?"展开侧边栏":"收起侧边栏",title:r?"展开侧边栏":"收起侧边栏",children:k.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",fill:"none",viewBox:"0 0 24 24",children:[k.jsx("title",{children:r?"展开侧边栏":"收起侧边栏"}),k.jsx("path",{fill:"currentColor",d:"M21 5H11v14h10zM3 5h6v14H3zm0-2a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h18a2 2 0 0 0 2-2V5a2 2 0 0 0-2-2zm2 4.25a.75.75 0 0 0 0 1.5h2a.75.75 0 0 0 0-1.5zm-.75 3.5A.75.75 0 0 1 5 10h2a.75.75 0 0 1 0 1.5H5a.75.75 0 0 1-.75-.75m.75 2a.75.75 0 0 0 0 1.5h2a.75.75 0 0 0 0-1.5z"})]})})]}),k.jsx("div",{className:"wandox-aside-main-nav",children:k.jsx("div",{className:"wandox-aside-nav-list",children:g.map(y=>{const x=a===y.key,b=y.key==="professional";return k.jsxs("div",{children:[k.jsxs("div",{className:`wandox-aside-nav-item-wrap${x?" wandox-aside-nav-item-wrap--active":""}`,children:[k.jsxs("button",{type:"button",onClick:()=>s==null?void 0:s(y.key),className:`wandox-aside-nav-item${x?" wandox-aside-nav-item--active":""}`,children:[k.jsx("span",{className:"wandox-aside-nav-icon",children:y.icon}),k.jsx("span",{className:"wandox-aside-nav-title",children:y.title})]}),b&&!r&&h&&k.jsx(Ci,{title:d?"收起列表":"展开列表",placement:"right",children:k.jsx("button",{type:"button",className:`wandox-aside-mode-toggle${d?" wandox-aside-mode-toggle--active":""}`,onClick:w=>{w.stopPropagation(),h()},children:d?k.jsx(sme,{style:{fontSize:11}}):k.jsx(wA,{style:{fontSize:11}})})})]}),b&&(d||r)&&k.jsx("div",{className:"wandox-aside-agent-list",children:t.map(w=>{const S=w.agent_id;if(!S)return null;const _=e===S&&a==="professional";return k.jsx(Ci,{title:w.name,placement:"right",children:k.jsxs("button",{type:"button",className:`wandox-aside-agent-item${_?" wandox-aside-agent-item--active":""}`,onClick:()=>{f==null||f(S),a!=="professional"&&(s==null||s("professional"))},children:[k.jsx("span",{className:"wandox-aside-agent-icon",children:D_(w.icon)}),k.jsx("span",{className:"wandox-aside-agent-name",children:w.name})]})},S)})})]},y.key)})})}),k.jsxs("div",{className:"wandox-aside-bottom",children:[k.jsx("p",{className:"wandox-aside-group-label",children:"系统功能"}),k.jsxs("div",{className:"wandox-aside-nav-list wandox-aside-nav-list--bottom",children:[v.map(y=>{const x=y.key!=="toolbox"&&a===y.key;return k.jsxs("button",{type:"button",onClick:()=>{if(y.key==="toolbox"){o==null||o();return}s==null||s(y.key)},className:`wandox-aside-nav-item${x?" wandox-aside-nav-item--active":""}`,children:[k.jsx("span",{className:"wandox-aside-nav-icon",children:y.icon}),k.jsx("span",{className:"wandox-aside-nav-title",children:y.label})]},y.key)}),l&&k.jsxs("button",{type:"button",onClick:u,className:"wandox-aside-nav-item wandox-aside-nav-item--logout",children:[k.jsx("span",{className:"wandox-aside-nav-icon",children:k.jsx(vTr,{})}),k.jsx("span",{className:"wandox-aside-nav-title",children:"退出登录"})]})]}),k.jsx("div",{style:{height:8}})]})]})})}function E0t({title:e="正在进入指定智能体",description:t="正在加载智能体与剧本信息..."}){return k.jsxs("output",{className:"wandox-initial-route-loading","aria-label":e,children:[k.jsxs("div",{className:"wandox-initial-route-loading-aura","aria-hidden":"true",children:[Array.from({length:12},(r,n)=>({angle:n*30,delay:n*.08})).map(({angle:r,delay:n})=>k.jsx("span",{className:"wandox-chat-history-ray",style:{"--ray-angle":`${r}deg`,"--ray-delay":`${n}s`}},r)),k.jsx("div",{className:"wandox-chat-empty-icon",children:k.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[k.jsx("path",{d:"M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z"}),k.jsx("path",{d:"M20 2v4"}),k.jsx("path",{d:"M22 4h-4"}),k.jsx("circle",{cx:"4",cy:"20",r:"2"})]})})]}),k.jsx("div",{className:"wandox-initial-route-loading-title",children:e}),k.jsx("div",{className:"wandox-initial-route-loading-text",children:t})]})}function Vrn(e){const{children:t}=e;return k.jsx("div",{className:"wandox-layout wandox-root",children:k.jsx("main",{className:"wandox-layout-content",style:{padding:0},children:t})})}const Hrn="wandox_use_map_tree_goals_v2",Wrn=/^\?+$/;function Grn(e){return`${Hrn}:${e||"all"}`}function k0t(e){const t=e,r=Array.isArray(t==null?void 0:t.roles)?t:t==null?void 0:t.data;return Array.isArray(r==null?void 0:r.roles)?r.roles.map(n=>{const i=(n.goals||[]).filter(a=>a.playbook!==null).map(a=>({...a,icon:A0t(a.icon),items:(a.items||[]).filter(s=>s.playbook_id)})).filter(a=>{var s;return(a.items||[]).length>0||!!(a.playbook_id||(s=a.playbook)!=null&&s.playbook_id)});return{...n,icon:A0t(n.icon),goals:i,goal_count:i.length}}).filter(n=>(n.goals||[]).length>0):[]}function A0t(e){const t=String(e||"").trim();if(!(!t||Wrn.test(t)))return t}function Urn({agentId:e,onPlaybookClick:t,onSelectPlaybook:r,expanded:n,onExpandedChange:i}){const[a,s]=C.useState(!1),[o,l]=C.useState(!1),[u,d]=C.useState(!1),[h,f]=C.useState([]),[p,g]=C.useState(""),[m,v]=C.useState(""),y=C.useMemo(()=>e==null?"":String(e).trim(),[e]),x=n??a,b=C.useMemo(()=>h.find(_=>_.role_code===p)||h[0],[h,p]);C.useEffect(()=>{d(!1),f([]),g(""),v("")},[y]),C.useEffect(()=>{if(!x||u)return;let _=!1;const T=Grn(y);return(async()=>{l(!0),v("");try{const I=window.localStorage.getItem(T);if(I)try{const P=k0t(JSON.parse(I));P.length>0&&(f(P),g(P[0].role_code))}catch{window.localStorage.removeItem(T)}const $=await E4r({agent_id:y,role_id:null});if(_)return;const A=k0t($.data);f(A),g(P=>{var N;return P||((N=A[0])==null?void 0:N.role_code)||""}),window.localStorage.setItem(T,JSON.stringify($.data||{roles:[]}))}catch{_||v("使用地图加载失败")}finally{_||(d(!0),l(!1))}})(),()=>{_=!0}},[x,u,y]);const w=_=>{var $,A;const T=_.playbook_id||(($=_.playbook)==null?void 0:$.playbook_id),E=((A=_.playbook)==null?void 0:A.name)||_.title||_.name||"执行";if(!T)return;if(s(!1),i==null||i(!1),o_e(_).length>0&&r){r(Krn(_),E);return}t({message:E,playbook_id:T})},S=()=>{const _=!x;s(_),i==null||i(_)};return k.jsxs("div",{className:`wandox-use-map${x?" wandox-use-map--expanded":""}`,children:[k.jsx("div",{className:"wandox-use-map-toolbar",children:k.jsxs("button",{type:"button",className:"wandox-use-map-toggle",onClick:S,"aria-expanded":x,children:[k.jsx("span",{className:"wandox-scene-tab-mark wandox-scene-tab-mark--use-map","aria-hidden":"true",children:k.jsx(uXe,{})}),k.jsx("span",{className:"wandox-use-map-toggle-text",children:"使用地图"}),k.jsx("span",{className:"wandox-use-map-toggle-arrow","aria-hidden":"true",children:"⌄"})]})}),x&&k.jsx("div",{className:`wandox-use-map-panel${h.length===0?" wandox-use-map-panel--compact":""}`,children:(!u||o)&&h.length===0?k.jsxs("div",{className:"wandox-use-map-loading",children:[k.jsx("span",{className:"wandox-heartbeat-loader","aria-hidden":"true",children:k.jsx("svg",{width:"48",height:"24",viewBox:"0 0 48 24",fill:"none",children:k.jsx("path",{d:"M0 12 L8 12 L10 8 L12 16 L14 4 L16 12 L20 12 L22 10 L24 14 L26 10 L28 12 L48 12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}),k.jsx("span",{children:"正在加载使用地图"})]}):m?k.jsxs("div",{className:"wandox-use-map-empty",children:[k.jsx("div",{className:"wandox-use-map-empty-title",children:m}),k.jsx("button",{type:"button",className:"wandox-use-map-retry",onClick:()=>d(!1),children:"重新加载"})]}):h.length===0?k.jsxs("div",{className:"wandox-use-map-empty",children:[k.jsx("div",{className:"wandox-use-map-empty-title",children:"暂无使用地图"}),k.jsx("div",{className:"wandox-use-map-empty-desc",children:"当前智能体还没有配置岗位目标剧本"})]}):k.jsxs(k.Fragment,{children:[k.jsx("div",{className:"wandox-use-map-roles",role:"tablist","aria-label":"岗位",children:h.map(_=>{var T;return k.jsxs("button",{type:"button",role:"tab","aria-selected":(b==null?void 0:b.role_code)===_.role_code,className:`wandox-use-map-role${(b==null?void 0:b.role_code)===_.role_code?" active":""}`,onClick:()=>g(_.role_code),children:[k.jsx("span",{className:"wandox-use-map-role-icon",children:_.icon||"◎"}),k.jsx("span",{className:"wandox-use-map-role-name",children:_.name}),k.jsx("span",{className:"wandox-use-map-role-count",children:_.goal_count||((T=_.goals)==null?void 0:T.length)||0})]},_.id)})}),k.jsx("div",{className:"wandox-use-map-goals",children:((b==null?void 0:b.goals)||[]).map(_=>{var T;return k.jsxs("section",{className:"wandox-use-map-goal-group",children:[k.jsxs("div",{className:"wandox-use-map-goal-group-head",children:[k.jsx("span",{className:"wandox-use-map-goal-group-icon",children:_.icon||"◇"}),k.jsx("span",{className:"wandox-use-map-goal-group-name",children:_.name}),k.jsxs("span",{className:"wandox-use-map-goal-group-count",children:[((T=_.items)==null?void 0:T.length)||0," 个剧本"]}),(_.description||_.subtitle)&&k.jsxs("span",{className:"wandox-use-map-goal-group-desc",children:["· ",_.description||_.subtitle]})]}),k.jsx("div",{className:"wandox-use-map-goal-items",children:(_.items||[]).map(E=>{var A,P,N;const I=o_e(E).length>0,$=qrn(E.tags);return k.jsxs("button",{type:"button",className:`wandox-use-map-playbook-card${E.is_featured?" wandox-use-map-playbook-card--featured":""}`,onClick:()=>w(E),children:[k.jsx("div",{className:"wandox-use-map-playbook-title",children:k.jsx("span",{className:"wandox-use-map-playbook-name",children:E.title||E.name||((A=E.playbook)==null?void 0:A.name)||"未命名剧本"})}),(E.is_featured||I)&&k.jsxs("div",{className:"wandox-use-map-playbook-badges",children:[E.is_featured&&k.jsx(as,{color:"gold",className:"wandox-use-map-tag wandox-use-map-featured-tag",children:"精品"}),I&&k.jsx("span",{className:"wandox-use-map-param-badge",children:"参数"})]}),(E.subtitle||E.description||((P=E.playbook)==null?void 0:P.description))&&k.jsx("div",{className:"wandox-use-map-playbook-desc",children:E.subtitle||E.description||((N=E.playbook)==null?void 0:N.description)}),$.length>0&&k.jsx("div",{className:"wandox-use-map-playbook-tags",children:$.map((R,L)=>k.jsx(as,{color:R.variant==="soft"?void 0:R.color,className:"wandox-use-map-tag",style:Yrn(R),children:R.name},`${R.name}-${L}`))})]},`${_.id}-${E.id||E.playbook_id}`)})})]},_.id)})})]})})]})}function o_e(e){var t;return e.input_fields||((t=e.playbook)==null?void 0:t.input_fields)||[]}function qrn(e){return Array.isArray(e)?e.reduce((t,r)=>{const n=typeof(r==null?void 0:r.name)=="string"?r.name.trim():"";return n&&t.push({...r,name:n}),t},[]):[]}function Yrn(e){if(!(e.variant!=="soft"||!e.color))return{color:e.color,borderColor:I0t(e.color,.28),backgroundColor:I0t(e.color,.08)}}function I0t(e,t){const r=e.trim().replace("#","");if(!/^[0-9a-fA-F]{6}$/.test(r))return e;const n=Number.parseInt(r.slice(0,2),16),i=Number.parseInt(r.slice(2,4),16),a=Number.parseInt(r.slice(4,6),16);return`rgba(${n}, ${i}, ${a}, ${t})`}function Krn(e){var r;const t=e.playbook||e;return{category:e.category??null,category_name:e.category_name,description:e.description||e.subtitle||t.description,domain:e.domain||"",id:Number(e.id||0),name:((r=e.playbook)==null?void 0:r.name)||e.title||e.name||"未命名剧本",playbook_id:e.playbook_id||t.playbook_id||"",scope:"",status:e.status||t.status||"",sub_category:null,tags:null,type:e.type||"",version:"",input_fields:o_e(e),video_url:e.video_url||t.video_url||void 0,video_duration:e.video_duration||t.video_duration,view_count:e.view_count,badge:e.badge||t.badge||null}}const O_=e=>String(e.playbook_id||e.code||e.name);function Xrn({label:e}){return k.jsxs("output",{className:"wandox-scene-list-loading","aria-label":e,children:[k.jsx("span",{className:"wandox-heartbeat-loader","aria-hidden":"true",children:k.jsx("svg",{width:"48",height:"24",viewBox:"0 0 48 24",fill:"none",children:k.jsx("path",{d:"M0 12 L8 12 L10 8 L12 16 L14 4 L16 12 L20 12 L22 10 L24 14 L26 10 L28 12 L48 12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}),k.jsx("span",{children:e})]})}function $0t({playbooks:e,playbookLoading:t,onPlaybookClick:r,onSelectPlaybook:n,recommendations:i=[],userPlaybooks:a=[],userPlaybooksLoading:s=!1,onLoadUserPlaybooks:o,agentId:l,recentRefreshKey:u=0}){const[d,h]=C.useState("playbooks"),[f,p]=C.useState(!1),[g,m]=C.useState(!1),[v,y]=C.useState("全部"),[x,b]=C.useState(""),[w,S]=C.useState(null),[_,T]=C.useState(""),[E,I]=C.useState(!1),[$,A]=C.useState([]),[P,N]=C.useState(!1),[R,L]=C.useState(""),D=C.useRef(!1),M=C.useRef(new Map),O=C.useMemo(()=>d==="recommendations"?t&&i.length===0:d==="user"?s:P||t&&e.length===0,[t,P,d,e.length,i.length,s]),F=C.useMemo(()=>l==null?"":String(l).trim(),[l]);C.useEffect(()=>{if(!F){A([]),N(!1);return}let ee=!1;return(async()=>{N(!0);try{const le=await Ukr({limit:8,agent_id:F});ee||A(le.data||[])}catch{ee||A([])}finally{ee||N(!1)}})(),()=>{ee=!0}},[F,u]);const B=C.useRef(null),[V,z]=C.useState(5),H=C.useCallback(()=>{if(!B.current)return;const ee=B.current.offsetWidth;if(ee===0)return;const le=Math.floor(ee/(200+12));z(Math.max(2,le))},[]);C.useEffect(()=>{const ee=setTimeout(H,100);return()=>clearTimeout(ee)},[H,d,f]),C.useEffect(()=>{d==="recommendations"&&i.length===0&&h("playbooks")},[i.length,d]),C.useEffect(()=>{d!=="user"||!F||o==null||o()},[d,F,o]),C.useEffect(()=>{if(!B.current)return;const ee=new ResizeObserver(()=>{H()});return ee.observe(B.current),()=>ee.disconnect()},[H]);const W=C.useMemo(()=>new Set($.map(O_)),[$]),G=C.useMemo(()=>new Set(a.map(O_)),[a]),q=C.useMemo(()=>{const ee=new Map;for(const se of $.filter(ue=>!G.has(O_(ue))))ee.set(O_(se),se);for(const se of e){const ue=O_(se);ee.has(ue)||ee.set(ue,se)}return Array.from(ee.values())},[e,$,G]),Y=d==="playbooks"?q:d==="recommendations"?i:a,K=d==="playbooks"?e:Y,X=Y.length>(V??5)&&K.length>0,Z=C.useMemo(()=>{const ee=new Map;ee.set("全部",K.length);for(const se of K){const ue=se.category_name||"未分类";ee.set(ue,(ee.get(ue)||0)+1)}return Array.from(ee.entries()).map(([se,ue])=>({name:se,count:ue}))},[K]),Q=C.useMemo(()=>{let ee=K;if(v!=="全部"&&(ee=ee.filter(se=>(se.category_name||"未分类")===v)),x.trim()){const se=x.trim().toLowerCase();ee=ee.filter(ue=>{var le;return ue.name.toLowerCase().includes(se)||((le=ue.description)==null?void 0:le.toLowerCase().includes(se))})}return ee},[K,v,x]),J=C.useCallback(ee=>{const se=String(ee.playbook_id||"").trim();if(!se)return Promise.reject(new Error("缺少 playbook_id"));const ue=M.current.get(se);if(ue)return ue;const le=zA({playbook_id:se}).then(({data:ne})=>_0t(ee,ne)).finally(()=>{M.current.delete(se)});return M.current.set(se,le),le},[]),re=C.useCallback(async(ee,se=!1)=>{var ue;if(!D.current){D.current=!0,L(ee.playbook_id);try{const le=await J(ee);if(se&&(m(!1),y("全部"),b("")),(ue=le.input_fields)!=null&&ue.length&&n){n(le,le.name);return}r({message:le.name,playbook_id:le.playbook_id})}catch{$t.error("剧本参数加载失败,请稍后重试")}finally{D.current=!1,L("")}}},[J,r,n]);return k.jsxs("div",{className:"wandox-pro-scenes-panel",children:[k.jsxs("div",{className:"wandox-hub-section-header",children:[k.jsxs("div",{className:"wandox-scene-tabs",children:[k.jsxs("button",{type:"button",className:`wandox-scene-tab${!f&&d==="playbooks"?" active":""}`,onClick:()=>{h("playbooks"),p(!1)},children:[k.jsx("span",{className:"wandox-scene-tab-mark wandox-scene-tab-mark--playbooks","aria-hidden":"true",children:k.jsx(dXe,{})}),k.jsx("span",{children:"默认场景"})]}),i.length>0&&k.jsxs("button",{type:"button",className:`wandox-scene-tab${!f&&d==="recommendations"?" active":""}`,onClick:()=>{h("recommendations"),p(!1)},children:[k.jsx("span",{className:"wandox-scene-tab-mark wandox-scene-tab-mark--recommendations","aria-hidden":"true",children:k.jsx(hXe,{})}),k.jsx("span",{children:"推荐场景"})]}),k.jsxs("button",{type:"button",className:`wandox-scene-tab${!f&&d==="user"?" active":""}`,onClick:()=>{h("user"),p(!1)},children:[k.jsx("span",{className:"wandox-scene-tab-mark wandox-scene-tab-mark--user","aria-hidden":"true",children:k.jsx(BTr,{})}),k.jsx("span",{children:"我的场景"})]}),k.jsx(Urn,{agentId:F,onPlaybookClick:r,onSelectPlaybook:n,expanded:f,onExpandedChange:ee=>{p(ee),ee&&h("playbooks")}})]}),X&&!f&&k.jsxs("button",{type:"button",className:"wandox-scene-view-all",onClick:()=>m(!0),children:["查看全部 ",K.length," 个"]})]}),k.jsx("div",{className:"wandox-tab-content",children:!f&&k.jsx("div",{className:"wandox-hub-section",children:O?k.jsx(Xrn,{label:d==="user"?"正在加载我的场景":d==="recommendations"?"正在匹配推荐场景":"正在加载场景"}):Y.length>0?k.jsxs("div",{className:"wandox-scroll-row",ref:B,children:[Y.slice(0,V??5).map(ee=>{const se=R===ee.playbook_id,ue=()=>void re(ee),le=d==="playbooks"&&W.has(O_(ee)),ne=d==="user"?"用户":le?"近期":ee.badge==="new"?"New":ee.badge==="recommend"?"推荐":ee.badge==="featured"?"精选":ee.category_name||ee.type||"推荐",oe=ee.video_duration?`${Math.floor(ee.video_duration/60)}:${String(ee.video_duration%60).padStart(2,"0")}`:"",Se=async xe=>{var Re;xe.stopPropagation(),S(ee),I(!0);try{const Ce=await GZe({playbook_id:ee.playbook_id});T(((Re=Ce.data)==null?void 0:Re.video_url)||ee.video_url||"")}catch{T(ee.video_url||"")}finally{I(!1)}},ie={daily:"每日",weekly:"每周",monthly:"每月"},be=ee.is_subscribed?`🔔订阅${ee.execution_frequency&&ee.execution_frequency!=="none"?`·${ie[ee.execution_frequency]}自动跑`:""}`:"",pe=[ee.description,be].filter(Boolean).join(" ");return k.jsxs("div",{className:"wandox-card",children:[k.jsxs("div",{className:"wandox-card-corner",children:[k.jsx("span",{className:"wandox-card-tag",children:ne}),ee.video_url&&k.jsxs("button",{type:"button",className:"wandox-card-video",onClick:Se,children:["▶ ",oe?` ${oe}`:"0:00"," 演示"]})]}),k.jsxs("button",{type:"button",className:"wandox-card-main",onClick:ue,disabled:se,"aria-busy":se,children:[k.jsx("div",{className:"wandox-card-title",children:ee.name}),k.jsx("div",{className:"wandox-card-desc",children:se?"正在加载参数...":pe})]})]},O_(ee))}),X&&k.jsxs("button",{type:"button",className:"wandox-card wandox-card-more",onClick:()=>m(!0),children:[k.jsxs("div",{className:"wandox-card-more-title",children:["查看全部 ",K.length," 个"]}),k.jsx("div",{className:"wandox-card-more-desc",children:"按场景浏览"})]})]}):k.jsx("div",{className:"wandox-empty-slot",children:k.jsxs("div",{className:"wandox-empty",children:[k.jsx("div",{className:"wandox-empty-text",children:d==="playbooks"?"暂无默认场景":d==="recommendations"?"暂无推荐场景":"暂无我的场景"}),k.jsx("div",{className:"wandox-empty-desc",children:d==="playbooks"?"请联系管理员添加场景剧本":d==="recommendations"?"系统会根据情况推荐相关场景":"我创建的场景会显示在这里"})]})})})}),k.jsx(_i,{open:g,onCancel:()=>{m(!1),y("全部"),b("")},footer:null,width:900,closable:!1,centered:!0,styles:{container:{padding:0,overflow:"hidden"},body:{height:"90vh"}},zIndex:1e4,children:k.jsxs("div",{className:"wandox-playbook-browser",children:[k.jsxs("div",{className:"wandox-playbook-sidebar",children:[k.jsx("div",{className:"wandox-playbook-sidebar-title",children:"场景分类"}),k.jsx("div",{className:"wandox-playbook-categories",children:Z.map(ee=>k.jsxs("button",{type:"button",className:`wandox-playbook-category-item${v===ee.name?" active":""}`,onClick:()=>y(ee.name),children:[k.jsx("span",{className:"wandox-playbook-category-name",children:ee.name}),k.jsx("span",{className:"wandox-playbook-category-count",children:ee.count})]},ee.name))})]}),k.jsxs("div",{className:"wandox-playbook-main",children:[k.jsx("div",{className:"wandox-playbook-search",children:k.jsx(zr,{placeholder:"搜索场景名称或描述...",prefix:k.jsx(uS,{style:{color:"#9ca3af"}}),value:x,onChange:ee=>b(ee.target.value),allowClear:!0})}),k.jsx("div",{className:"wandox-playbook-list",children:Q.length===0?k.jsx(is,{description:"暂无剧本",style:{marginTop:80}}):Q.map(ee=>{const se=ee.input_fields&&ee.input_fields.length>0,ue=R===ee.playbook_id,le=!!ee.video_url,ne=()=>void re(ee,!0),oe=ee.video_duration?`${Math.floor(ee.video_duration/60)}:${String(ee.video_duration%60).padStart(2,"0")}`:"",Se=async()=>{var ie;S(ee),I(!0);try{const be=await GZe({playbook_id:ee.playbook_id});T(((ie=be.data)==null?void 0:ie.video_url)||ee.video_url||"")}catch{$t.error("视频加载失败"),T(ee.video_url||"")}finally{I(!1)}};return k.jsx("div",{className:"wandox-playbook-list-item",children:k.jsxs("div",{className:"wandox-playbook-list-item-content",children:[k.jsx("div",{className:"wandox-playbook-list-item-icon",children:le?k.jsx("button",{className:"wandox-playbook-video-icon",title:"包含演示视频",onClick:Se,type:"button",children:k.jsx(Yp,{})}):k.jsx("div",{className:"wandox-playbook-no-video-icon",children:k.jsx(Yqe,{})})}),k.jsxs("div",{className:"wandox-playbook-list-item-body",children:[k.jsx("div",{className:"wandox-playbook-list-item-header",children:k.jsxs("div",{className:"wandox-playbook-list-item-title",children:[ee.name,ee.badge&&k.jsx("span",{className:`wandox-scene-badge wandox-scene-badge--${ee.badge}`,children:ee.badge==="new"?"New":ee.badge==="recommend"?"推荐":"精选"})]})}),ee.description&&k.jsx("div",{className:"wandox-playbook-list-item-desc",children:ee.description}),ee.last_execution_remark&&k.jsxs("div",{className:"wandox-playbook-list-item-remark",children:[k.jsx("span",{className:"wandox-playbook-list-item-remark-icon",children:"💡"}),k.jsxs("span",{children:["上次:",ee.last_execution_remark]})]})]}),k.jsxs("div",{className:"wandox-playbook-list-item-actions",children:[k.jsx("button",{type:"button",className:"wandox-playbook-list-item-btn",onClick:ne,disabled:ue,"aria-busy":ue,children:ue?"加载中":se?"参数":"运行"}),le&&k.jsxs("button",{type:"button",className:"wandox-playbook-demo-link",onClick:Se,children:["看演示",oe?` ${oe}`:""]})]})]})},ee.playbook_id)})})]})]})}),w&&k.jsx(_i,{open:!0,onCancel:()=>{S(null),T("")},footer:null,centered:!0,width:800,title:k.jsxs("span",{children:[k.jsx(Yp,{style:{marginRight:8,color:"#7c3aed"}}),w.name," · 演示视频",w.video_duration&&k.jsxs("span",{style:{marginLeft:12,fontSize:13,color:"#9ca3af",fontWeight:"normal"},children:["时长 ",Math.floor(w.video_duration/60),":",String(w.video_duration%60).padStart(2,"0")]}),w.view_count!==void 0&&k.jsxs("span",{style:{marginLeft:12,fontSize:13,color:"#9ca3af",fontWeight:"normal"},children:["👁 ",w.view_count," 次播放"]})]}),styles:{body:{padding:"12px 0 0"}},zIndex:10001,children:E?k.jsx("div",{style:{height:400,display:"flex",alignItems:"center",justifyContent:"center",background:"#000",borderRadius:8},children:k.jsx(so.Node,{active:!0,style:{width:200,height:200}})}):k.jsx("video",{src:_,controls:!0,autoPlay:!0,style:{width:"100%",borderRadius:8,display:"block",maxHeight:"70vh",background:"#000"},children:k.jsx("track",{kind:"captions"})})})]})}const R0t=[{name:"country",label:"国家/地区"},{name:"state",label:"州/省"},{name:"province",label:"省"},{name:"city",label:"城市"},{name:"postal_code",label:"邮政编码"},{name:"address_line1",label:"地址"}],Zrn=Object.fromEntries(R0t.map(e=>[e.name,e.label]));function P9(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function R5(e){return typeof e=="string"?e.trim():String(e??"").trim()}function Qrn(e,t){return!P9(e)||!Array.isArray(e[t])?[]:e[t].map(String).filter(Boolean)}function Jrn(e,t){if(!P9(e)||!P9(e.postal_code_patterns))return;const r=e.postal_code_patterns[t];return typeof r=="string"?r:void 0}function $Q(e){const t=String(e.type||"").toLowerCase(),r=String(e.widget||"").toLowerCase();return t==="address"||r==="address"}function enn(){return[...R0t]}function N0t(e,t){if(!P9(e))return"请输入有效地址";const r=Qrn(t,"required_fields"),n=r.length>0?r:["country","city","postal_code","address_line1"];for(const l of n)if(!R5(e[l]))return`请填写${Zrn[l]||`地址字段 ${l}`}`;if(r.length===0&&!R5(e.state)&&!R5(e.province))return"请填写州/省";const i=R5(e.country).toUpperCase(),a=R5(e.postal_code),s=Jrn(t,i);if(a&&s)try{if(!new RegExp(s).test(a))return"邮政编码格式不正确"}catch{return"地址邮编规则配置无效"}const o=P9(t)&&typeof t.max_length=="number"?t.max_length:200;return R5(e.address_line1).length>o?`地址行不能超过 ${o} 个字符`:""}var L0t={exports:{}};(function(e,t){(function(r,n){e.exports=n()})(ka,function(){var r="month",n="quarter";return function(i,a){var s=a.prototype;s.quarter=function(u){return this.$utils().u(u)?Math.ceil((this.month()+1)/3):this.month(this.month()%3+3*(u-1))};var o=s.add;s.add=function(u,d){return u=Number(u),this.$utils().p(d)===n?this.add(3*u,r):o.bind(this)(u,d)};var l=s.startOf;s.startOf=function(u,d){var h=this.$utils(),f=!!h.u(d)||d;if(h.p(u)===n){var p=this.quarter()-1;return f?this.month(3*p).startOf(r).startOf("day"):this.month(3*p+2).endOf(r).endOf("day")}return l.bind(this)(u,d)}}})})(L0t);var tnn=L0t.exports;const rnn=Ds(tnn);Yr.extend(yfe),Yr.extend(rnn),Yr.extend(SWe);const nnn={date:"YYYY-MM-DD",daterange:"YYYY-MM-DD",datetime:"YYYY-MM-DD HH:mm:ss",datetimerange:"YYYY-MM-DD HH:mm:ss",time:"HH:mm:ss",timerange:"HH:mm:ss"};function M9(e){const t=String(e||"").trim().toLowerCase().replace(/[_-]/g,"");return t==="date"?"date":t==="daterange"?"daterange":t==="datetime"?"datetime":t==="datetimerange"?"datetimerange":t==="time"?"time":t==="timerange"?"timerange":null}function t0(e){var r;const t=M9(e.type);if(t)return(r=e.format)!=null&&r.trim()?e.format.trim():D9(e)==="time"?"HH:mm:ss":l_e(e)?"YYYY-MM-DD HH:mm:ss":e.picker==="year"?"YYYY":e.picker==="month"?"YYYY-MM":e.picker==="week"?"YYYY-wo":e.picker==="quarter"?"YYYY-[Q]Q":nnn[t]}function D9(e){const t=M9(e.type);return t?t==="time"||t==="timerange"?"time":"date":null}function N5(e){const t=M9(e.type);return e.range??(t==="daterange"||t==="datetimerange"||t==="timerange")}function l_e(e){const t=M9(e.type);return e.show_time??(t==="datetime"||t==="datetimerange")}function L5(e,t){return["date","week","month","quarter","year"].includes(t||"")?t:e==="YYYY"?"year":e==="YYYY-MM"?"month":"date"}function B_(e){return e!=null&&e.includes("ss")?"HH:mm:ss":"HH:mm"}function F_(e,t,r){if(e==null||e===""||typeof e!="string"&&typeof e!="number"&&!(e instanceof Date)&&!Yr.isDayjs(e))return null;let n;if(typeof e=="string"&&/^\d{1,2}:\d{2}(?::\d{2})?$/.test(e))n=Yr(`2000-01-01 ${e}`);else if(typeof e=="string"&&r==="quarter"){const i=e.match(/^(\d{4}).*?Q([1-4])/i);n=i?Yr(`${i[1]}-01-01`).quarter(Number(i[2])):Yr(e)}else if(typeof e=="string"&&r==="week"){const i=e.match(/^(\d{4})\D+(\d{1,2})/);n=i?Yr(`${i[1]}-01-01`).week(Number(i[2])):Yr(e)}else typeof e=="string"&&t?(n=Yr(e,t,!0),n.isValid()||(n=Yr(e))):n=Yr(e);return n.isValid()?n:null}function O9(e,t,r){return!Array.isArray(e)||e.length!==2?null:[F_(e[0],t,r),F_(e[1],t,r)]}function c_e({field:e,value:t,size:r,disabled:n=!1,readOnly:i=!1,status:a,onChange:s}){const o=D9(e),l=t0(e),u=N5(e),d={size:r,style:{width:"100%"},format:l,disabled:n,allowClear:!i,inputReadOnly:i,open:i?!1:void 0,status:a};if(o==="date"){const h=l_e(e),f=L5(l,e.picker),p=h?"日期时间":"日期",g={...d,picker:f,showTime:h?{format:B_(l)}:!1};return u?k.jsx(Es.RangePicker,{...g,value:O9(t,l,f),placeholder:[`请选择开始${p}`,`请选择结束${p}`],onChange:(m,v)=>s(v)}):k.jsx(Es,{...g,value:F_(t,l,f),placeholder:e.placeholder||`请选择${p}`,onChange:(m,v)=>s(v)})}return o==="time"?u?k.jsx(tc.RangePicker,{...d,value:O9(t,l),placeholder:["请选择开始时间","请选择结束时间"],onChange:(h,f)=>s(f)}):k.jsx(tc,{...d,value:F_(t,l),placeholder:e.placeholder||"请选择时间",onChange:(h,f)=>s(f)}):null}function P0t(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function B9(e){return["array","list","tags","multi_select","multiselect"].includes(String(e||"").toLowerCase())}function M0t(e){return(e==null?void 0:e.includes("image"))??!1}function RQ(e){const t=(e.ui_component||e.widget||e.type||"string").toLowerCase();return M9(t)||t}function D0t(e){return RQ(e)==="segmented"||e.type.toLowerCase()==="segmented"}function O0t(e){var t;return(t=e.options)!=null&&t.length?e.options:(e.enum||[]).map(r=>({value:r,label:r}))}function inn(e){return e==null?"":typeof e=="string"||typeof e=="number"||typeof e=="bigint"?e:String(e)}function ann(e){if(typeof e=="number"&&Number.isFinite(e))return e;if(typeof e=="string"&&e.trim()){const t=Number(e);return Number.isFinite(t)?t:void 0}}function u_e(e){if(Array.isArray(e))return e.map(t=>String(t));if(e==null||e==="")return[];if(typeof e=="string"){const t=e.trim();if(t.startsWith("[")&&t.endsWith("]"))try{const r=JSON.parse(t);if(Array.isArray(r))return r.map(n=>String(n))}catch{}}return[String(e)]}function xy(e){return e==null||e===""||Array.isArray(e)&&e.length===0}function P5(e,t={}){const r={};for(const n of e){const i=t[n.name];i!==void 0&&i!==""?r[n.name]=B9(n.type)?u_e(i):i:n.default!==void 0&&n.default!==""?r[n.name]=B9(n.type)?u_e(n.default):n.default:n.type.toLowerCase()==="boolean"?r[n.name]=!1:["number","integer","float"].includes(n.type.toLowerCase())?r[n.name]=void 0:B9(n.type)?r[n.name]=[]:r[n.name]=""}return r}function F9(e,t){return Array.isArray(e)?e.some(r=>F9(r,t)):String(e??"")===String(t??"")}function snn(e){return Array.isArray(e)?e.filter(P0t):P0t(e)?"field"in e||"name"in e||"param"in e?[e]:Object.entries(e).map(([t,r])=>({field:t,equals:r})):[]}function onn(e,t){const r=String(e.field??e.name??e.param??"");if(!r)return!0;const n=t[r],i=e.equals!==void 0||e.value!==void 0,a=e.equals??e.value;return!(i&&!F9(n,a)||e.not_equals!==void 0&&F9(n,e.not_equals)||Array.isArray(e.in)&&!e.in.some(s=>F9(n,s))||Array.isArray(e.not_in)&&e.not_in.some(s=>F9(n,s))||e.truthy===!0&&!n||e.empty===!0&&!xy(n)||e.empty===!1&&xy(n))}function z9(e,t){return e.filter(r=>{const n=snn(r.visible_when);return n.length===0||n.every(i=>onn(i,t))})}function B0t(e,t){return e.reduce((r,n)=>(r[n.name]=t[n.name],r),{})}function lnn(e){return Array.isArray(e)?e.map(t=>String(t)):e?[String(e)]:[]}function d_e(e){return e!=null&&e!==""}function cnn(e,t){const r=B9(e.type),n=u_e(t),i=d_e(t)?String(t):void 0;return{isMulti:r,selectValue:r?n:i,isEmptySelect:r?n.length===0:i===void 0,hasCurrentSelection:r?n.length>0:i!==void 0}}function h_e({field:e,value:t,readOnly:r=!1,size:n,uploading:i=!1,imageUploadMode:a="picture",fileNameMap:s={},getOptionState:o,onChange:l,onUpload:u,onDownloadTemplate:d,draftValue:h,onDraftChange:f,onDraftCommit:p,selectSearchValue:g,onSelectSearchChange:m,onSelectAllowEmptySearch:v}){var _,T,E,I;const y=h??String(inn(t)),x=RQ(e),b={...e,type:x},w=$=>l(e.name,$),S=()=>{var B,V;const $=o(e),A=e.options_from_skill?$.options:O0t(e),P=!!(e.options_from_skill||(B=e.enum)!=null&&B.length||(V=e.options)!=null&&V.length),N=$.waitingForDependencies?"请先选择关联参数":$.placeholder||e.placeholder||"请选择",{isMulti:R,selectValue:L,isEmptySelect:D,hasCurrentSelection:M}=cnn(e,t),O=m!==void 0,F=()=>{v==null||v(e.name),g&&(m==null||m(e.name,""))};return k.jsx(wn,{allowClear:!r,showSearch:!r,size:n,autoClearSearchValue:!O,optionFilterProp:"label",filterOption:(z,H)=>{const W=z.trim().toLowerCase();return W?String((H==null?void 0:H.label)??(H==null?void 0:H.value)??"").toLowerCase().includes(W):!0},mode:R?P?"multiple":"tags":void 0,value:L,searchValue:r||!O?void 0:g,placeholder:D?N:void 0,options:A,loading:!r&&$.loading,disabled:!r&&$.waitingForDependencies,open:r?!1:void 0,tabIndex:r?-1:void 0,"aria-readonly":r,tokenSeparators:R&&!P?[","]:void 0,notFoundContent:$.loading?k.jsx(Yi,{size:"small"}):$.error||null,onInputKeyDown:z=>{["Backspace","Delete","Escape"].includes(z.key)&&(v==null||v(e.name))},onSearch:O?z=>m(e.name,z):void 0,onChange:z=>{w(z);const H=Array.isArray(z)?z.length>0:d_e(z);(M||H)&&F()},onClear:F,onBlur:F})};if(D0t(e)){const $=O0t(e);return $.length===0?S():k.jsx(bU,{className:"wandox-agent-input-field-control__segmented",options:$,value:d_e(t)?String(t):void 0,disabled:r,onChange:w})}if($Q(e)){const $=t&&typeof t=="object"&&!Array.isArray(t)?t:{},A=(P,N)=>{r||w({...$,[P]:N})};return k.jsxs("div",{className:"wandox-agent-input-field-control__address",children:[enn().map(({name:P,label:N})=>k.jsx(zr,{size:n,value:String($[P]??""),readOnly:r,placeholder:N,onChange:R=>A(P,R.target.value)},P)),k.jsx(zr,{size:n,value:String($.address_line2??""),readOnly:r,placeholder:"地址补充",onChange:P=>A("address_line2",P.target.value)})]})}if(D9(b))return k.jsx(c_e,{field:b,value:t,size:n,readOnly:r,disabled:r,onChange:w});switch(x){case"file":{const $=e.max_files??1,A=lnn(t),P=A.length<$,N=R=>{w($<=1?"":A.filter((L,D)=>D!==R))};if(a==="picture"&&M0t(e.file_type)){const R=A.map((L,D)=>({uid:String(D),name:s[L]||L.split("/").pop()||`image_${D+1}`,status:"done",url:L}));return k.jsx(qp,{className:"wandox-agent-input-field-control__picture",accept:e.file_type||void 0,listType:"picture-card",fileList:R,customRequest:r?void 0:u(e.name,$),onRemove:r?void 0:L=>(N(Number(L.uid)),!0),disabled:r||i,maxCount:$,showUploadList:{showRemoveIcon:!r},children:P&&!r&&k.jsxs("div",{children:[i?k.jsx(Yi,{size:"small"}):k.jsx(xu,{}),k.jsx("div",{className:"wandox-agent-input-field-control__upload-text",children:"上传图片"})]})})}return k.jsxs("div",{className:"wandox-agent-input-field-control__files",children:[A.map((R,L)=>k.jsxs("div",{className:"wandox-agent-input-field-control__file",children:[k.jsx("span",{children:s[R]||R.split("/").pop()||R}),!r&&k.jsx(ur,{type:"text",size:"small",danger:!0,"aria-label":"移除文件",icon:k.jsx(Mv,{}),onClick:()=>N(L)})]},R)),e.file_templates&&e.file_templates.length>0&&k.jsxs("div",{className:"wandox-agent-input-field-control__templates",children:[k.jsx("span",{children:"模板文件"}),e.file_templates.map((R,L)=>k.jsx(ur,{size:"small",onClick:()=>d==null?void 0:d(R),children:R.name||"下载模板"},`${R.path}-${R.name||L}`))]}),P&&!r&&k.jsxs(qp.Dragger,{accept:e.file_type||void 0,showUploadList:!1,customRequest:u(e.name,$),disabled:i,children:[k.jsx("p",{className:"ant-upload-drag-icon",children:i?k.jsx(Yi,{size:"small"}):k.jsx(qO,{})}),k.jsx("p",{className:"ant-upload-text",children:i?"上传中...":"点击或拖拽文件上传"}),$>1&&k.jsxs("p",{className:"ant-upload-hint",children:["已上传 ",A.length,"/",$]})]})]})}case"boolean":return k.jsx(Dc,{size:n==="small"?"small":"default",checked:!!t,disabled:r,onChange:w});case"number":case"integer":case"float":return k.jsx(wu,{size:n,value:ann(t),readOnly:r,placeholder:e.placeholder||"请输入",onChange:w});case"select":case"array":case"list":case"tags":case"multi_select":case"multiselect":return S();case"string":return(_=e.enum)!=null&&_.length||(T=e.options)!=null&&T.length||e.options_from_skill?S():k.jsx(zr,{size:n,value:y,readOnly:r,placeholder:e.placeholder||"请输入",onChange:r?void 0:$=>f?f(e.name,$.target.value):w($.target.value),onBlur:r?void 0:$=>p==null?void 0:p(e.name,$.target.value)});default:return(E=e.enum)!=null&&E.length||(I=e.options)!=null&&I.length||e.options_from_skill?S():k.jsx(zr.TextArea,{value:y,readOnly:r,autoSize:{minRows:2,maxRows:8},placeholder:e.placeholder||"请输入",onChange:r?void 0:$=>f?f(e.name,$.target.value):w($.target.value),onBlur:r?void 0:$=>p==null?void 0:p(e.name,$.target.value)})}}const F0t=/\$\{\s*\{?\s*params\.([a-zA-Z0-9_.-]+)\s*\}?\s*\}/g,unn=/^\$\{\s*\{?\s*params\.([a-zA-Z0-9_.-]+)\s*\}?\s*\}$/;function z_(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function f_e(e,t){return t.split(".").reduce((r,n)=>{if(z_(r))return r[n]},e)}function dnn(e){return e==null||e===""}function hnn(e){const t=new Set,r=n=>{if(typeof n=="string"){for(const i of n.matchAll(F0t))i[1]&&t.add(i[1]);return}if(Array.isArray(n)){n.forEach(r);return}z_(n)&&Object.values(n).forEach(r)};return r(e),Array.from(t)}function fnn(e,t){const r=e.split(".")[0],n=t.find(i=>i.name===e||i.name===r);return n?!!n.required:!0}function p_e(e,t){if(typeof e=="string"){const r=e.match(unn);return r!=null&&r[1]?f_e(t,r[1]):e.replace(F0t,(n,i)=>{const a=f_e(t,i);return a==null?"":String(a)})}return Array.isArray(e)?e.map(r=>p_e(r,t)):z_(e)?Object.fromEntries(Object.entries(e).map(([r,n])=>[r,p_e(n,t)])):e}function pnn(e){const t=z_(e)&&"data"in e?e.data:e,r=[t];z_(t)&&(r.push(t.output_data,t.options,t.items,t.data,t.result,t.results,t.list),z_(t.output)&&r.push(t.output.output_data,t.output.options,t.output.items,t.output.data));for(const n of r)if(Array.isArray(n))return n;return[]}function gnn(e){let t;return{options:pnn(e).map(n=>{if(typeof n=="string"||typeof n=="number"||typeof n=="boolean")return{value:String(n),label:String(n)};if(!z_(n))return null;const i=n.value??n.key??n.code??n.id??n.name??n.label;if(i==null)return null;const a=n.label??n.name??n.title??n.text??n.value??i;if(String(i)===""){const s=String(a||"");return s&&!t&&(t=s),null}return{value:String(i),label:String(a)}}).filter(n=>!!n),placeholder:t}}function mnn(e){return(e.enum||[]).map(t=>({value:t,label:t}))}function NQ(e,t,r){const[n,i]=C.useState({}),a=C.useRef({}),s=C.useRef({}),o=C.useMemo(()=>e.filter(l=>!!l.options_from_skill),[e]);return C.useEffect(()=>{const l=new Set(o.map(u=>u.name));for(const u of Object.keys(a.current))l.has(u)||(delete a.current[u],delete s.current[u]);i(u=>{const d=Object.fromEntries(Object.entries(u).filter(([h])=>l.has(h)));return Object.keys(d).length===Object.keys(u).length?u:d})},[o]),C.useEffect(()=>{for(const l of o){if(!l.options_from_skill)continue;const d=hnn(l.options_params).filter(m=>fnn(m,e)&&dnn(f_e(t,m))),h=p_e(l.options_params||{},t),f=JSON.stringify({skill_id:l.options_from_skill,params:h,missing:d});if(a.current[l.name]===f)continue;const p=a.current[l.name]!==void 0||d.length>0;a.current[l.name]=f,s.current[l.name]=(s.current[l.name]||0)+1;const g=s.current[l.name];if(p&&r(m=>m[l.name]===void 0||m[l.name]===""?m:{...m,[l.name]:void 0}),d.length>0){i(m=>({...m,[l.name]:{options:[],loading:!1,waitingForDependencies:!0}}));continue}i(m=>{var v,y;return{...m,[l.name]:{options:((v=m[l.name])==null?void 0:v.options)||[],loading:!0,placeholder:(y=m[l.name])==null?void 0:y.placeholder,waitingForDependencies:!1}}}),KZe({},{skill_id:l.options_from_skill,params:h}).then(m=>{if(s.current[l.name]!==g)return;const v=gnn(m);i(y=>({...y,[l.name]:{options:v.options,loading:!1,placeholder:v.placeholder,waitingForDependencies:!1}}))}).catch(m=>{if(s.current[l.name]!==g)return;const v=m instanceof Error?m.message:"动态选项加载失败";i(y=>({...y,[l.name]:{options:[],loading:!1,error:v,waitingForDependencies:!1}}))})}},[o,e,t,r]),{getFieldState(l){return l.options_from_skill?n[l.name]||{options:[],loading:!1,waitingForDependencies:!1}:{options:mnn(l),loading:!1,waitingForDependencies:!1}}}}function M5(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function j_(e,t=""){return typeof e=="string"?e:e==null?t:String(e)}function fg(e){return typeof e=="string"?e:void 0}const vnn=["date","week","month","quarter","year"];function ynn(e){return typeof e=="string"&&vnn.includes(e)}function z0t(e){if(typeof e=="number"&&Number.isFinite(e))return e;if(typeof e=="string"&&e.trim()){const t=Number(e);return Number.isFinite(t)?t:void 0}}function bnn(e){if(!Array.isArray(e))return;const t=e.map(r=>{if(!M5(r))return null;const n=j_(r.path);return n?{name:j_(r.name,n.split("/").pop()||n),path:n}:null}).filter(r=>!!r);return t.length>0?t:void 0}function xnn(e){if(!Array.isArray(e))return;const t=e.map(r=>{if(typeof r=="string"||typeof r=="number"||typeof r=="boolean")return{value:String(r),label:String(r)};if(!M5(r))return null;const n=r.value??r.key??r.code??r.id??r.name??r.label;return n==null||n===""?null:{value:String(n),label:j_(r.label??r.title??r.text??r.name??n,String(n))}}).filter(r=>!!r);return t.length>0?t:void 0}function g_e(e){const t=M5(e)?e:{};return{name:j_(t.name),label:j_(t.label,j_(t.name)),type:j_(t.type,"string"),required:typeof t.required=="boolean"?t.required:!0,default:t.default,mock:t.mock,format:fg(t.format),picker:ynn(t.picker)?t.picker:void 0,show_time:typeof t.show_time=="boolean"?t.show_time:void 0,range:typeof t.range=="boolean"?t.range:void 0,enum:Array.isArray(t.enum)?t.enum.map(r=>String(r)):void 0,options:xnn(t.options),placeholder:fg(t.placeholder),options_from_skill:fg(t.options_from_skill),options_params:M5(t.options_params)?t.options_params:void 0,file_type:fg(t.file_type),max_files:z0t(t.max_files),description:fg(t.description),hint:fg(t.hint??t.label_hint??t.helper_text),file_templates:bnn(t.file_templates),group:fg(t.group??t.group_key??t.form_group),group_label:fg(t.group_label??t.group_title),group_description:fg(t.group_description??t.group_subtitle),ui_component:fg(t.ui_component??t.component??t.render_as),widget:fg(t.widget),address_validation:t.address_validation??t.addressValidation,span:z0t(t.span??t.col_span??t.column_span),visible_when:t.visible_when??t.visibleWhen}}function m_e(e){return Array.isArray(e)?e.map(g_e).filter(t=>!!t.name):M5(e)?Object.entries(e).map(([t,r])=>M5(r)?g_e({...r,name:r.name??t}):g_e({name:t,label:t,type:"string",default:r})).filter(t=>!!t.name):[]}function wnn(e){return e instanceof Error?e.message:"上传失败"}function Snn({open:e,playbook:t,onClose:r,onSubmit:n}){const i=C.useMemo(()=>m_e(t==null?void 0:t.input_fields),[t]),[a,s]=C.useState({}),[o,l]=C.useState({}),[u,d]=C.useState({}),h=NQ(i,a,s),f=C.useMemo(()=>z9(i,a),[i,a]);C.useEffect(()=>{e&&(s(P5(i,(t==null?void 0:t.initial_params)??{})),l({}),d({}))},[i,e,t==null?void 0:t.initial_params]);const p=C.useCallback((v,y)=>{s(x=>({...x,[v]:y}))},[]),g=C.useCallback((v,y)=>async({file:x,onSuccess:b,onError:w})=>{var S,_;l(T=>({...T,[v]:!0}));try{const T=x,E=await WS(T),I=(S=E==null?void 0:E.data)==null?void 0:S.url,$=((_=E==null?void 0:E.data)==null?void 0:_.name)||T.name;if(!I)throw new Error("上传结果缺少文件地址");d(A=>({...A,[I]:$})),s(A=>{if(y<=1)return{...A,[v]:I};const P=Array.isArray(A[v])?A[v]:A[v]?[A[v]]:[];return{...A,[v]:[...P,I]}}),b==null||b(E),$t.success("上传成功")}catch(T){const E=T instanceof Error?T:new Error(wnn(T));w==null||w(E),$t.error(E.message)}finally{l(T=>({...T,[v]:!1}))}},[]),m=()=>{if(!t)return;const v=f.filter(y=>y.required&&xy(a[y.name]));if(v.length>0){$t.warning(`请填写必填参数:${v.map(y=>y.label).join("、")}`);return}n(t,a)};return k.jsxs(dA,{className:"wandox-playbook-params-drawer",title:k.jsxs("div",{className:"wandox-playbook-params-drawer__title",children:[k.jsx("span",{className:"wandox-playbook-params-drawer__title-main",children:"填写执行参数"}),k.jsx("span",{className:"wandox-playbook-params-drawer__title-sub",children:t==null?void 0:t.name})]}),open:e,width:640,destroyOnHidden:!0,maskClosable:!1,onClose:r,footer:k.jsx("div",{className:"wandox-playbook-params-drawer__footer",children:k.jsxs(il,{children:[k.jsx(ur,{onClick:r,children:"取消"}),k.jsx(ur,{type:"primary",onClick:m,children:"开始执行"})]})}),children:[k.jsxs("div",{className:"wandox-playbook-params-drawer__intro",children:[k.jsx("span",{children:"填写本次运行需要的参数"}),k.jsxs("span",{children:[f.length," 项"]})]}),k.jsxs(Sn,{layout:"vertical",className:"wandox-playbook-params-drawer__form",children:[f.map(v=>k.jsx(Sn.Item,{required:v.required,label:k.jsxs("span",{className:"wandox-playbook-params-drawer__label",children:[v.label,v.description||v.hint?k.jsx(Ci,{title:v.description||v.hint,children:k.jsx(hA,{"aria-label":`${v.label}说明`})}):null]}),children:k.jsx(h_e,{field:v,value:a[v.name],uploading:!!o[v.name],fileNameMap:u,getOptionState:h.getFieldState,onChange:p,onUpload:g,onDownloadTemplate:y=>window.open(y.path,"_blank","noopener,noreferrer")})},v.name)),f.length===0?k.jsxs("div",{className:"wandox-playbook-params-drawer__empty",children:[k.jsx(Yi,{size:"small"})," 正在读取参数配置"]}):null]})]})}function Cnn({playbooks:e,onPlaybookClick:t,onPlaybookDelete:r,activePlaybookId:n}){const{t:i}=Fv(),[a,s]=C.useState(""),[o,l]=C.useState(!1),[u,d]=C.useState(null),[h,f]=C.useState(!1),p=e.filter(y=>{var x;return y.name.toLowerCase().includes(a.toLowerCase())||((x=y.description)==null?void 0:x.toLowerCase().includes(a.toLowerCase()))}),g=(y,x)=>{x.stopPropagation(),d(y),l(!0)},m=async()=>{if(u){f(!0);try{await Wkr(u.playbook_id),r==null||r(u.playbook_id),l(!1),d(null)}catch{}finally{f(!1)}}},v=()=>{l(!1),d(null)};return k.jsxs("div",{className:"wandox-solidified-list",children:[k.jsx("div",{className:"wandox-solidified-list-search",children:k.jsx(zr.Search,{placeholder:"搜索",value:a,onChange:y=>s(y.target.value),allowClear:!0,enterButton:!1})}),k.jsx("div",{className:"wandox-solidified-list-content",children:p.length===0?k.jsx(is,{description:i(a?"noData":"solidified.empty"),image:is.PRESENTED_IMAGE_SIMPLE}):k.jsx("div",{className:"wandox-solidified-list-grid",children:p.map(y=>k.jsxs("div",{className:`wandox-solidified-card ${n===y.playbook_id?"active":""}`,onClick:()=>t==null?void 0:t(y.playbook_id),onKeyDown:x=>{(x.key==="Enter"||x.key===" ")&&(t==null||t(y.playbook_id))},role:"button",tabIndex:0,children:[k.jsx("div",{className:"wandox-solidified-card-icon",children:k.jsxs("svg",{viewBox:"0 0 24 24",width:"24",height:"24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[k.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",stroke:"currentColor",strokeWidth:"2",fill:"none"}),k.jsx("path",{d:"M9 3v18M15 3v18M3 9h18M3 15h18",stroke:"currentColor",strokeWidth:"1.5"}),k.jsx("circle",{cx:"12",cy:"12",r:"2",fill:"currentColor"})]})}),k.jsxs("div",{className:"wandox-solidified-card-content",children:[k.jsx("div",{className:"wandox-solidified-card-name",children:y.name}),y.description&&k.jsx("div",{className:"wandox-solidified-card-desc",children:y.description})]}),k.jsx("button",{type:"button",className:"wandox-solidified-card-delete",onClick:x=>g(y,x),title:i("solidified.delete"),children:k.jsx("svg",{viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:k.jsx("path",{d:"M6 7v12a2 2 0 002 2h8a2 2 0 002-2V7M4 7h16M10 11v6M14 11v6M9 7V4a1 1 0 011-1h4a1 1 0 011 1v3",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})]},y.playbook_id))})}),k.jsx(_i,{title:i("solidified.deleteConfirm"),open:o,onOk:m,onCancel:v,okText:i("confirm"),cancelText:i("cancel"),okButtonProps:{danger:!0,loading:h},children:k.jsxs("p",{children:[i("solidified.deleteConfirm")," 「",u==null?void 0:u.name,"」?"]})})]})}function _nn({inputParams:e,onSearch:t,loading:r=!1}){const[n]=Sn.useForm();C.useEffect(()=>{const s={};for(const o of e)o.default!==void 0&&o.default!==null&&o.default!==""&&(s[o.name]=o.default);n.setFieldsValue(s)},[e,n]);const i=()=>{n.validateFields().then(s=>{const o={};for(const l of Object.keys(s)){const u=s[l];u!=null&&u!==""&&(o[l]=u)}t(o)})},a=s=>{const{name:o,type:l,description:u}=s,d={placeholder:u||`请输入${o}`};switch(l){case"integer":return k.jsx(wu,{...d,style:{width:"100%"}});case"array":return k.jsx(zr,{...d});case"boolean":return k.jsx(zr,{...d});case"string":default:return k.jsx(zr,{...d})}};return k.jsx("div",{className:"wandox-solidify-params-form",children:k.jsxs(Sn,{form:n,layout:"inline",onFinish:i,style:{marginBottom:16},children:[e.map(s=>k.jsx(Sn.Item,{name:s.name,label:s.description||s.name,rules:[{required:s.required,message:`请输入${s.description||s.name}`}],style:{marginBottom:8},children:a(s)},s.name)),k.jsx(Sn.Item,{style:{marginBottom:8},children:k.jsx(ur,{type:"primary",htmlType:"submit",loading:r,children:"查询"})})]})})}const D5={fontSize:13,fontWeight:600,color:"#374151",marginBottom:6};function Tnn({open:e,onClose:t,onSuccess:r,editingSchedule:n,webhooks:i}){const a=!n,[s,o]=C.useState(""),[l,u]=C.useState(!0),[d,h]=C.useState(""),[f,p]=C.useState(0),[g,m]=C.useState(""),[v,y]=C.useState(""),[x,b]=C.useState(""),[w,S]=C.useState([]),[_,T]=C.useState({}),[E,I]=C.useState(!1),[$,A]=C.useState({}),[P,N]=C.useState({}),[R,L]=C.useState([]),[D,M]=C.useState([]),[O,F]=C.useState(!1),[B,V]=C.useState(!1),z=C.useCallback(async(K,X)=>{var Z;if(!K){S([]),T({});return}I(!0);try{const{data:Q}=await zA({playbook_id:K}),J=((Z=Q==null?void 0:Q.content)==null?void 0:Z.yaml_content)||"";let re=[];if(J)try{const ee=n8.parse(J),se=ee==null?void 0:ee.params;Array.isArray(se)&&se.length>0?re=se:se&&typeof se=="object"&&(re=Object.values(se))}catch{}if(S(re),re.length>0){const ee={};for(const se of re){const ue=X==null?void 0:X[se.name];ue!==void 0?ee[se.name]=ue:se.default!==void 0&&se.default!==null&&(ee[se.name]=se.default)}T(ee)}else T({})}catch{S([])}I(!1)},[]),H=C.useCallback(async()=>{var K,X;F(!0);try{const[Z,Q]=await Promise.all([Vkr({page:1,page_size:200}),eve({page:1,page_size:100})]),J=((K=Z==null?void 0:Z.data)==null?void 0:K.items)??(Array.isArray(Z==null?void 0:Z.data)?Z==null?void 0:Z.data:[]),re=((X=Q==null?void 0:Q.data)==null?void 0:X.items)??(Array.isArray(Q==null?void 0:Q.data)?Q==null?void 0:Q.data:[]);L(J.map(ee=>({value:ee.playbook_id??String(ee.id),label:ee.name}))),M(re.map(ee=>({value:String(ee.id),label:ee.name})))}catch{}F(!1)},[]);C.useEffect(()=>{if(e)if(p(K=>K+1),A({}),N({}),n){o(n.name||""),u(n.is_active),b(n.webhook_id||""),h(n.cron_expression||"");const K=n.playbook_params||{};T(K),z(n.playbook_id||"",K)}else o(""),u(!0),h(""),m(""),y(""),b(""),S([]),T({}),H()},[e,n,z,H]),C.useEffect(()=>{a&&(g?z(g):(S([]),T({})))},[g,a,z]);const W=(K,X)=>{T(Z=>({...Z,[K]:X}))},G=K=>async({file:X,onSuccess:Z,onError:Q})=>{var J,re;A(ee=>({...ee,[K.name]:!0}));try{const ee=X,se=await WS(ee),ue=(J=se==null?void 0:se.data)==null?void 0:J.url,le=((re=se==null?void 0:se.data)==null?void 0:re.name)||ee.name||(ue==null?void 0:ue.split("/").pop())||"未知文件";if(!ue)throw new Error("上传失败");N(oe=>({...oe,[ue]:le})),(K.max_files??1)<=1?W(K.name,ue):T(oe=>{const Se=Array.isArray(oe[K.name])?oe[K.name]:oe[K.name]?[oe[K.name]]:[];return{...oe,[K.name]:[...Se,ue]}}),Z==null||Z(se),$t.success("上传成功")}catch(ee){Q==null||Q(ee instanceof Error?ee:new Error("文件上传失败")),$t.error(ee instanceof Error?ee.message:"文件上传失败")}finally{A(ee=>({...ee,[K.name]:!1}))}},q=K=>{const X=_[K.name];if(D9(K))return k.jsx(c_e,{field:K,value:X,onChange:Z=>W(K.name,Z)});switch(K.type){case"string":return k.jsx(zr.TextArea,{value:X??"",onChange:Z=>W(K.name,Z.target.value),autoSize:{minRows:1,maxRows:4},placeholder:K.description||""});case"number":case"integer":case"float":return k.jsx(wu,{style:{width:"100%"},value:X,onChange:Z=>W(K.name,Z),placeholder:K.description||"",precision:K.type==="integer"?0:void 0,size:"small"});case"boolean":return k.jsx(Dc,{size:"small",checked:!!X,onChange:Z=>W(K.name,Z)});case"array":case"object":return k.jsx(zr.TextArea,{value:typeof X=="string"?X:X!=null?JSON.stringify(X):"",onChange:Z=>W(K.name,Z.target.value),autoSize:{minRows:1,maxRows:4},placeholder:K.description||"JSON 格式"});case"file":{const Z=K.max_files??1,Q=Array.isArray(X)?X.map(String):X?[String(X)]:[],J=Q.length<Z,re=ee=>{Z<=1?W(K.name,""):W(K.name,Q.filter((se,ue)=>ue!==ee))};return k.jsxs("div",{children:[Q.length>0&&k.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6,marginBottom:8},children:Q.map((ee,se)=>k.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,minHeight:30,padding:"4px 8px",border:"1px solid #e5e7eb",borderRadius:6,background:"#fff"},children:[k.jsx("span",{style:{flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontSize:12},children:P[ee]||ee.split("/").pop()||ee}),k.jsx(ur,{type:"text",size:"small",danger:!0,onClick:()=>re(se),children:"删除"})]},ee))}),J&&k.jsx(qp,{accept:K.file_type||void 0,showUploadList:!1,customRequest:G(K),disabled:!!$[K.name],children:k.jsx(ur,{size:"small",icon:k.jsx(qO,{}),loading:!!$[K.name],children:$[K.name]?"上传中...":"点击上传"})})]})}default:return k.jsx(zr,{value:X??"",onChange:Z=>W(K.name,Z.target.value),placeholder:K.description||"",size:"small"})}},Y=async()=>{if(!s.trim()){$t.warning("请输入任务名称");return}if(!x){$t.warning("请选择通知地址");return}if(!d.trim()){$t.warning("请配置调度频率");return}if(a&&!g){$t.warning("请选择剧本");return}const K=w.length>0?_:void 0;V(!0);try{if(n){const X={name:s,webhook_id:x,cron_expression:d,schedule_type:"custom",is_active:l,playbook_params:K};await JZe(n.schedule_id,{},X),$t.success("更新成功")}else await ZZe({},{name:s,agent_id:v,playbook_id:g,webhook_id:x,cron_expression:d,schedule_type:"custom",playbook_params:K}),$t.success("创建成功");r(),t()}catch(X){$t.error((X==null?void 0:X.message)||"操作失败")}finally{V(!1)}};return k.jsxs(_i,{title:null,open:e,onOk:Y,onCancel:t,okText:"保存",cancelText:"取消",width:540,confirmLoading:B,closable:!1,children:[k.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:20},children:[k.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[k.jsx(No,{style:{fontSize:20,color:"#722ed1"}}),k.jsx("span",{style:{fontSize:16,fontWeight:600,color:"#111827"},children:a?"新增定时任务":"编辑定时任务"})]}),k.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[k.jsx("span",{style:{fontSize:13,color:l?"#111827":"#9ca3af"},children:l?"已启用":"已禁用"}),k.jsx(Dc,{checked:l,onChange:u})]})]}),k.jsxs("div",{style:{marginBottom:16},children:[k.jsxs("div",{style:D5,children:["任务名称 ",k.jsx("span",{style:{color:"#ef4444"},children:"*"})]}),k.jsx(zr,{value:s,onChange:K=>o(K.target.value),placeholder:"请输入任务名称",style:{borderRadius:8}})]}),k.jsxs("div",{style:{marginBottom:16},children:[k.jsxs("div",{style:D5,children:["通知地址 ",k.jsx("span",{style:{color:"#ef4444"},children:"*"})]}),k.jsx(wn,{style:{width:"100%"},value:x||void 0,onChange:K=>b(K),options:i.map(K=>({value:K.webhook_id,label:K.name})),placeholder:"请选择通知地址",showSearch:!0,optionFilterProp:"label"})]}),a&&k.jsxs(Yi,{spinning:O,children:[k.jsxs("div",{style:{marginBottom:16},children:[k.jsxs("div",{style:D5,children:["剧本 ",k.jsx("span",{style:{color:"#ef4444"},children:"*"})]}),k.jsx(wn,{style:{width:"100%"},value:g||void 0,onChange:K=>m(K),options:R,placeholder:"请选择剧本",showSearch:!0,filterOption:(K,X)=>{var Z;return(Z=X==null?void 0:X.label)==null?void 0:Z.toLowerCase().includes(K.toLowerCase())}})]}),k.jsxs("div",{style:{marginBottom:16},children:[k.jsx("div",{style:D5,children:"智能体"}),k.jsx(wn,{style:{width:"100%"},value:v||void 0,onChange:K=>y(K),options:D,placeholder:"请选择智能体(可选)",showSearch:!0,allowClear:!0,filterOption:(K,X)=>{var Z;return(Z=X==null?void 0:X.label)==null?void 0:Z.toLowerCase().includes(K.toLowerCase())}})]})]}),k.jsxs("div",{style:{marginBottom:16},children:[k.jsx("div",{style:D5,children:"调度频率"}),k.jsx(n_e,{defaultValue:n==null?void 0:n.cron_expression,onChange:K=>h(K)},f)]}),E&&k.jsxs("div",{style:{textAlign:"center",padding:"12px 0"},children:[k.jsx(Yi,{size:"small"}),k.jsx("span",{style:{marginLeft:8,fontSize:12,color:"#9ca3af"},children:"加载参数配置..."})]}),!E&&w.length>0&&k.jsxs("div",{style:{marginBottom:16},children:[k.jsx("div",{style:D5,children:"执行参数"}),k.jsx("div",{style:{background:"#f9fafb",border:"1px solid #e5e7eb",borderRadius:8,padding:"12px 16px"},children:w.map(K=>k.jsxs("div",{style:{marginBottom:12},children:[k.jsxs("div",{style:{fontSize:12,fontWeight:500,color:"#374151",marginBottom:4},children:[K.label||K.name,K.required&&k.jsx("span",{style:{color:"#ef4444",marginLeft:2},children:"*"})]}),K.description&&k.jsx("div",{style:{fontSize:11,color:"#9ca3af",marginBottom:4},children:K.description}),q(K)]},K.name))})]})]})}const Enn={daily:"每天",weekly:"每周",monthly:"每月",workday:"工作日",custom:"自定义"},knn={1:"周一",2:"周二",3:"周三",4:"周四",5:"周五",6:"周六",7:"周日",0:"周日"};function Ann(e){const t=CQ(e),r=`${String(t.hour).padStart(2,"0")}:${String(t.minute).padStart(2,"0")}`;switch(t.unit){case"hour":return t.interval===1?`每小时第 ${t.minute} 分`:`每 ${t.interval} 小时`;case"week":return`每${t.weekDays.map(i=>knn[i]||"").filter(Boolean).join("、")} ${r}`;case"month":return t.interval===1?`每月 ${t.monthDay} 号 ${r}`:`每 ${t.interval} 月 ${t.monthDay} 号 ${r}`;case"year":return`每年 ${t.yearMonth} 月 ${t.yearDay} 日 ${r}`;case"day":return t.interval===1?`每天 ${r}`:`每 ${t.interval} 天 ${r}`;case"custom":return t.customCron.trim()?`自定义:${t.customCron.trim()}`:e;default:return e}}const Inn=({className:e})=>{const[t,r]=C.useState([]),[n,i]=C.useState(!1),[a,s]=C.useState(!1),[o,l]=C.useState(null),[u]=Sn.useForm(),[d,h]=C.useState(),[f,p]=C.useState([]),[g,m]=C.useState(!1),[v,y]=C.useState(!1),[x,b]=C.useState(null);C.useEffect(()=>{S(),P()},[]);const w=[{label:"钉钉",value:"dingtalk"},{label:"飞书",value:"feishu"},{label:"企业微信",value:"wecom"}],S=async()=>{try{i(!0);const M=await jq({});M!=null&&M.data&&r(M.data)}catch(M){$t.error((M==null?void 0:M.message)||"加载失败")}finally{i(!1)}},_=()=>{l(null),u.resetFields(),h(void 0),s(!0)},T=async M=>{try{i(!0);const O=await Zkr(M.webhook_id,{}),F=(O==null?void 0:O.data)||M;l(F),h(F.platform),u.setFieldsValue({...F,notify_time:F.notify_start_time&&F.notify_end_time?[Yr(F.notify_start_time,"HH:mm:ss"),Yr(F.notify_end_time,"HH:mm:ss")]:void 0}),s(!0)}catch(O){$t.error((O==null?void 0:O.message)||"获取详情失败")}finally{i(!1)}},E=async M=>{try{i(!0),await e4r(M.webhook_id,{}),$t.success("测试消息发送成功")}catch(O){$t.error((O==null?void 0:O.message)||"测试失败")}finally{i(!1)}},I=M=>{_i.confirm({title:"确认删除",content:`确定要删除 Webhook "${M.name}" 吗?`,okText:"确定",cancelText:"取消",onOk:async()=>{try{await Jkr(M.webhook_id,{}),$t.success("删除成功"),S()}catch(O){$t.error((O==null?void 0:O.message)||"删除失败")}}})},$=async()=>{var M,O,F,B;try{const V=await u.validateFields();i(!0);const z={name:V.name,description:V.description,platform:V.platform,webhook_url:V.webhook_url,secret:V.secret,notify_start_time:(O=(M=V.notify_time)==null?void 0:M[0])==null?void 0:O.format("HH:mm:ss"),notify_end_time:(B=(F=V.notify_time)==null?void 0:F[1])==null?void 0:B.format("HH:mm:ss"),is_active:V.is_active,is_default:V.is_default};o?(await Qkr(o.webhook_id,{},z),$t.success("更新成功")):(await XZe({},z),$t.success("创建成功")),s(!1),u.resetFields(),S()}catch(V){$t.error((V==null?void 0:V.message)||"操作失败")}finally{i(!1)}},A=[{title:"名称",dataIndex:"name",key:"name",width:150,render:(M,O)=>{const F={dingtalk:k.jsx(Z_r,{style:{color:"#1677ff"}}),feishu:k.jsx(mXe,{style:{color:"#1677ff"}}),wecom:k.jsx(WTr,{style:{color:"#1677ff"}})};return k.jsxs(il,{size:4,children:[F[O.platform],k.jsx("span",{children:M})]})}},{title:"描述",dataIndex:"description",key:"description",ellipsis:!0},{title:"通知时段",key:"notify_time",width:150,render:(M,O)=>!O.notify_start_time||!O.notify_end_time?"全天":`${O.notify_start_time} ~ ${O.notify_end_time}`},{title:"状态",dataIndex:"is_active",key:"is_active",width:88,render:M=>k.jsx(as,{color:M?"success":"default",bordered:!1,children:M?"已启用":"已停用"})},{title:"默认渠道",dataIndex:"is_default",key:"is_default",width:96,render:M=>M?k.jsx(as,{color:"blue",bordered:!1,children:"默认"}):k.jsx("span",{className:"wandox-notification-muted",children:"—"})},{title:"操作",key:"action",width:210,render:(M,O)=>k.jsxs(il,{size:0,children:[k.jsx(ur,{type:"link",size:"small",icon:k.jsx(HO,{}),onClick:()=>T(O),className:"wandox-webhook-action-btn",children:k.jsx("span",{className:"wandox-webhook-action-text",children:"编辑"})}),k.jsx(ur,{type:"link",size:"small",icon:k.jsx(o0e,{}),onClick:()=>E(O),className:"wandox-webhook-action-btn",children:k.jsx("span",{className:"wandox-webhook-action-text",children:"测试"})}),k.jsx(ur,{type:"link",size:"small",danger:!0,icon:k.jsx(Mv,{}),onClick:()=>I(O),className:"wandox-webhook-action-btn",children:k.jsx("span",{className:"wandox-webhook-action-text",children:"删除"})})]})}],P=async()=>{try{m(!0);const M=await QZe({});if(M!=null&&M.data){const O=Array.isArray(M.data)?M.data:M.data.items||[];p(O)}}catch{}finally{m(!1)}},N=M=>{if(M.cron_expression)return Ann(M.cron_expression);const O=Enn[M.schedule_type]||M.schedule_type,F=M.schedule_time||"--:--";return`${O} ${F}`},R=M=>{b(M),y(!0)},L=M=>{_i.confirm({title:"确认删除",content:`确定要删除定时任务「${M.name}」吗?`,okText:"确定",cancelText:"取消",onOk:async()=>{try{await eQe(M.schedule_id,{}),$t.success("删除成功"),P()}catch(O){$t.error((O==null?void 0:O.message)||"删除失败")}}})},D=[{title:"任务名称",dataIndex:"name",key:"name",width:150,render:M=>k.jsxs(il,{size:4,children:[k.jsx(No,{style:{color:"#722ed1"}}),k.jsx("span",{children:M})]})},{title:"调度规则",key:"schedule_desc",width:180,render:(M,O)=>k.jsx("span",{style:{fontFamily:"monospace",fontSize:12},children:N(O)})},{title:"通知渠道",dataIndex:"webhook_name",key:"agent_name",width:120,ellipsis:!0,render:M=>M||"-"},{title:"状态",dataIndex:"is_active",key:"is_active",width:70,render:M=>k.jsx(as,{color:M?"green":"default",children:M?"启用":"禁用"})},{title:"操作",key:"action",width:140,render:(M,O)=>k.jsxs(il,{size:0,children:[k.jsx(ur,{type:"link",size:"small",icon:k.jsx(HO,{}),onClick:()=>R(O),className:"wandox-webhook-action-btn",children:k.jsx("span",{className:"wandox-webhook-action-text",children:"编辑"})}),k.jsx(ur,{type:"link",size:"small",danger:!0,icon:k.jsx(Mv,{}),onClick:()=>L(O),className:"wandox-webhook-action-btn",children:k.jsx("span",{className:"wandox-webhook-action-text",children:"删除"})})]})}];return k.jsxs("div",{className:`wandox-webhook-management ${e||""}`,children:[k.jsxs("div",{className:"wandox-notification-overview",children:[k.jsxs("article",{className:"wandox-notification-stat",children:[k.jsx("span",{className:"wandox-notification-stat__icon wandox-notification-stat__icon--primary",children:k.jsx(zme,{})}),k.jsxs("div",{children:[k.jsx("strong",{children:t.length}),k.jsx("span",{children:"通知渠道"})]})]}),k.jsxs("article",{className:"wandox-notification-stat",children:[k.jsx("span",{className:"wandox-notification-stat__icon wandox-notification-stat__icon--success",children:k.jsx(lq,{})}),k.jsxs("div",{children:[k.jsx("strong",{children:t.filter(M=>M.is_active).length}),k.jsx("span",{children:"已启用渠道"})]})]}),k.jsxs("article",{className:"wandox-notification-stat",children:[k.jsx("span",{className:"wandox-notification-stat__icon wandox-notification-stat__icon--purple",children:k.jsx(No,{})}),k.jsxs("div",{children:[k.jsx("strong",{children:f.filter(M=>M.is_active).length}),k.jsx("span",{children:"启用中的定时任务"})]})]})]}),k.jsxs("section",{className:"wandox-notification-section",children:[k.jsxs("header",{className:"wandox-notification-section__header",children:[k.jsxs("div",{className:"wandox-notification-section__heading",children:[k.jsx("span",{className:"wandox-notification-section__icon",children:k.jsx(zme,{})}),k.jsxs("div",{children:[k.jsxs("div",{className:"wandox-notification-section__title-row",children:[k.jsx("h2",{children:"通知渠道"}),k.jsx("span",{children:t.length})]}),k.jsx("p",{children:"管理钉钉、飞书和企业微信的消息接收地址"})]})]}),k.jsx(ur,{type:"primary",icon:k.jsx(xu,{}),onClick:_,children:"新增通知渠道"})]}),k.jsx("div",{className:"wandox-notification-section__body",children:k.jsx(Su,{size:"middle",columns:A,dataSource:t,rowKey:"webhook_id",loading:n,pagination:t.length>10?{pageSize:10,showSizeChanger:!0,showTotal:M=>`共 ${M} 条`}:!1,scroll:{x:820}})})]}),k.jsxs("section",{className:"wandox-notification-section",children:[k.jsx("header",{className:"wandox-notification-section__header",children:k.jsxs("div",{className:"wandox-notification-section__heading",children:[k.jsx("span",{className:"wandox-notification-section__icon wandox-notification-section__icon--purple",children:k.jsx(No,{})}),k.jsxs("div",{children:[k.jsxs("div",{className:"wandox-notification-section__title-row",children:[k.jsx("h2",{children:"定时任务"}),k.jsx("span",{children:f.length})]}),k.jsx("p",{children:"查看和维护通过通知渠道触发的周期任务"})]})]})}),k.jsx("div",{className:"wandox-notification-section__body",children:k.jsx(Su,{size:"middle",columns:D,dataSource:f,rowKey:"schedule_id",loading:g,pagination:f.length>10?{pageSize:10,showSizeChanger:!0,showTotal:M=>`共 ${M} 条`}:!1,scroll:{x:780}})})]}),k.jsx(_i,{title:o?"编辑 Webhook":"新增 Webhook",open:a,onOk:$,onCancel:()=>{s(!1),u.resetFields()},width:600,confirmLoading:n,okText:"确定",cancelText:"取消",children:k.jsxs(Sn,{form:u,layout:"horizontal",initialValues:{is_active:!0,is_default:!1},labelCol:{flex:"0 0 80px"},style:{paddingTop:16},children:[k.jsx(Sn.Item,{label:"名称",name:"name",rules:[{required:!0,message:"请输入名称"}],children:k.jsx(zr,{placeholder:"请输入 Webhook 名称"})}),k.jsx(Sn.Item,{label:"描述",name:"description",children:k.jsx(zr.TextArea,{rows:2,placeholder:"请输入描述(可选)"})}),k.jsx(Sn.Item,{label:"平台",name:"platform",rules:[{required:!0,message:"请选择平台"}],children:k.jsx(wn,{options:w,placeholder:"请选择平台",onChange:M=>h(M)})}),k.jsx(Sn.Item,{label:"URL",name:"webhook_url",rules:[{required:!0,message:"请输入 Webhook URL"},{type:"url",message:"请输入有效的 URL"}],children:k.jsx(zr,{placeholder:"https://...",autoComplete:"off"})}),d!=="wecom"&&k.jsx(Sn.Item,{label:"签名密钥",name:"secret",rules:[{required:d==="dingtalk"||d==="feishu",message:"请输入签名密钥"}],children:k.jsx(zr.Password,{placeholder:"请输入签名密钥",autoComplete:"new-password"})}),k.jsx(Sn.Item,{label:"通知时段",name:"notify_time",children:k.jsx(tc.RangePicker,{format:"HH:mm",placeholder:["开始时间","结束时间"],style:{width:"100%"}})}),k.jsx(Sn.Item,{label:"启用",name:"is_active",valuePropName:"checked",children:k.jsx(Dc,{})}),k.jsx(Sn.Item,{label:"设为默认",name:"is_default",valuePropName:"checked",children:k.jsx(Dc,{})})]})}),k.jsx(Tnn,{open:v,onClose:()=>{y(!1),b(null)},onSuccess:P,editingSchedule:x,webhooks:t})]})},{RangePicker:jfi}=Es;function $nn({open:e,loading:t,playbooks:r,activePlaybookId:n,onClose:i,onPlaybookClick:a,onPlaybookDelete:s}){return k.jsx(dA,{title:"工具箱",placement:"right",size:"min(440px, 100vw)",open:e,loading:t,onClose:i,getContainer:!1,rootClassName:"wandox-toolbox-drawer",styles:{body:{padding:0,overflow:"hidden"}},children:k.jsx(Cnn,{playbooks:r,onPlaybookClick:a,onPlaybookDelete:s,activePlaybookId:n})})}const Rnn=["智能体对话","非 ASIN 查询场景","巡检机器人定时任务"];function j9(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function wy(e){return e==null?!1:typeof e=="string"?e.trim().length>0:!0}function j0t(e){if(Array.isArray(e)){if(e.length===0)return null;const t=e.find(r=>j9(r)?Object.keys(r).length>0:wy(r));return j9(t)?t:wy(t)?{value:t}:null}return j9(e)?Object.keys(e).length>0?e:null:wy(e)?{value:e}:null}function Ph(e,t,r=0){if(e){for(const n of t){const i=e[n];if(wy(i))return i}if(!(r>=2))for(const n of Object.values(e)){if(j9(n)){const i=Ph(n,t,r+1);if(wy(i))return i}if(Array.isArray(n))for(const i of n){if(!j9(i))continue;const a=Ph(i,t,r+1);if(wy(a))return a}}}}function qx(e){if(wy(e))return String(e).trim()}function Nnn(e){return Array.from(e).slice(0,4).join("")}function O5(e){const t=qx(e);if(!t)return;const r=t.match(/^(\d{4}-\d{2}-\d{2})/);return(r==null?void 0:r[1])||t}function Lnn(e){return Array.isArray(e)?e.map(t=>qx(t)).filter(t=>!!t):[]}function Pnn(e){const t=qx(e);if(!(!t||!/^#[\da-f]{3}([\da-f]{3})?$/i.test(t)))return t}function Mnn(e){const t=e.slice(1),r=t.length===3?t.split("").map(o=>`${o}${o}`).join(""):t,n=Number.parseInt(r.slice(0,2),16),i=Number.parseInt(r.slice(2,4),16),a=Number.parseInt(r.slice(4,6),16);return(n*299+i*587+a*114)/1e3>=160?"#1f1f1f":"#ffffff"}function v_e(e){if(!wy(e))return;if(typeof e=="number"&&Number.isFinite(e))return new Intl.NumberFormat("en-US").format(e);const t=String(e).trim(),r=t.replace(/,/g,""),n=Number(r);return r&&Number.isFinite(n)?new Intl.NumberFormat("en-US").format(n):t}function V0t(e,t){if(!wy(e))return t;const r=String(e).trim();return["infinite","unlimited","∞"].includes(r.toLowerCase())?"∞ 无限":v_e(e)||t}function Dnn(e){const t=qx(e==null?void 0:e.package_name);if(!(!t||t==="无限算力年卡"))return t}function Onn(e){const t=qx(Ph(e,["asin_usage","asin_usage_text","asin_used_display","usage_text"]));if(t)return t;const r=v_e(Ph(e,["used_asin","asin_used","used_asin_count","asin_used_count","asin_used_num","asin_num_by_use","used_count","used_num","used","consumed_asin","query_used_count"])),n=v_e(Ph(e,["total_asin","asin_total","total_asin_count","asin_total_count","asin_limit","asin_quota","asin_num","total_count","total_num","limit","quota","total"]));if(!(!r&&!n))return`${r||"-"} / ${n||"-"}`}function Bnn(e){const t=Ph(e,["used_asin","asin_used","used_asin_count","asin_used_count","asin_used_num","asin_num_by_use","used_count","used_num","used","consumed_asin","query_used_count"]),r=Ph(e,["total_asin","asin_total","total_asin_count","asin_total_count","asin_limit","asin_quota","asin_num","total_count","total_num","limit","quota","total"]),n=Number(String(t??"").replace(/,/g,"")),i=Number(String(r??"").replace(/,/g,""));if(!(!Number.isFinite(n)||!Number.isFinite(i)||i<=0))return Math.min(Math.round(n/i*100),100)}function y_e(e){var a,s,o;if(!e)return null;const t=j0t(e.competitive_asin_info);if(t)return{kind:"competitiveAsin",badgeText:"包年权益",badgeColor:"#9444f5",badgeTextColor:"#ffffff",packageName:qx(Ph(t,["package_name","packageName","plan_name","benefit_name","name","title","package_type"]))||Dnn(e.package_info)||"竞品智能体包年权益",subtitle:"竞品智能体专属权益",remainingLabel:"剩余算力(非ASIN查询):",remainingValue:V0t(Ph(t,["token_num","tokenNum","remaining_token","token_remaining","remaining_power","power_remaining"])??((a=e.package_info)==null?void 0:a.token_num),"∞ 无限"),asinUsage:Onn(t),asinUsagePercent:Bnn(t),endTime:O5(Ph(t,["end_time","endTime","expire_time","expired_at","expires_at","end_date","package_end_time"]))||O5((s=e.package_info)==null?void 0:s.end_time)||"-",startTime:O5(Ph(t,["start_time","startTime","open_time","opened_at","started_at","start_date","package_start_time"]))||O5((o=e.package_info)==null?void 0:o.start_time)||"-",coverageTitle:"无限算力覆盖范围",coverageItems:Rnn};const r=j0t(e.package_info);if(!r)return null;const n=qx(Ph(r,["package_name","packageName"]))||"套餐权益",i=Pnn(Ph(r,["package_color","packageColor"]))||"#9444f5";return{kind:"free",badgeText:Nnn(n),badgeColor:i,badgeTextColor:Mnn(i),packageName:n,remainingLabel:"剩余算力:",remainingValue:V0t(r.token_num,"-"),endTime:O5(r.end_time)||"-",startTime:O5(r.start_time)||"-",coverageTitle:qx(r.detail_title)||"套餐权益",coverageItems:Lnn(r.detail_ul)}}const Fnn=[{label:"钉钉",value:"dingtalk"},{label:"飞书",value:"feishu"},{label:"企业微信",value:"wecom"}];function H0t({open:e,onClose:t,onSuccess:r}){const{t:n}=Fv(),[i]=Sn.useForm(),[a,s]=C.useState(!1),[o,l]=C.useState(),u=async()=>{try{const h=await i.validateFields();s(!0);const f={name:h.name,platform:h.platform,webhook_url:h.webhook_url,secret:h.secret||void 0},p=await XZe({},f);p!=null&&p.data?($t.success(n("webhook.createSuccess")),r({webhook_id:p.data.webhook_id||p.data.id,name:h.name,platform:h.platform}),i.resetFields(),t()):$t.error(n("webhook.createFailed"))}catch(h){h instanceof Error&&$t.error(h.message||n("webhook.createFailed"))}finally{s(!1)}},d=()=>{i.resetFields(),l(void 0),t()};return k.jsx(_i,{title:n("webhook.quickAdd"),open:e,onOk:u,onCancel:d,confirmLoading:a,width:480,destroyOnHidden:!0,zIndex:1e4,children:k.jsxs(Sn,{form:i,layout:"vertical",preserve:!1,children:[k.jsx(Sn.Item,{label:n("webhook.name"),name:"name",rules:[{required:!0,message:n("webhook.nameRequired")}],children:k.jsx(zr,{placeholder:n("webhook.namePlaceholder")})}),k.jsx(Sn.Item,{label:n("webhook.platform"),name:"platform",rules:[{required:!0,message:n("webhook.platformRequired")}],children:k.jsx(wn,{options:Fnn,placeholder:n("webhook.platformPlaceholder"),onChange:h=>l(h)})}),k.jsx(Sn.Item,{label:"Webhook URL",name:"webhook_url",rules:[{required:!0,message:n("webhook.urlRequired")},{type:"url",message:n("webhook.urlInvalid")}],children:k.jsx(zr,{placeholder:"https://...",autoComplete:"off"})}),o!=="wecom"&&k.jsx(Sn.Item,{label:n("webhook.secret"),name:"secret",rules:[{required:o==="dingtalk"||o==="feishu",message:n("webhook.secretRequired")}],children:k.jsx(zr.Password,{placeholder:n("webhook.secretPlaceholder"),autoComplete:"new-password"})})]})})}const znn="https://ai.maiduox.com/#/aitools/operation/product";function jnn(e){const{title:t,widgets:r,ssoDomain:n,ssoToken:i,ssoCompany:a,onExecuteComplete:s,activeAgent:o,agents:l,childAgents:u,externalRobotName:d,externalShowPanel:h,agentSwitcher:f}=e;e.onWidgetsUpdate,e.count,Fv();const[p,g]=C.useState(!1),[m,v]=C.useState(!1),[y,x]=C.useState(null),[b,w]=C.useState(null),[S,_]=C.useState("results"),[T,E]=C.useState(!1),[I,$]=C.useState([]),[A,P]=C.useState(null),[N,R]=C.useState({}),[L,D]=C.useState([]),[M,O]=C.useState(!1),[F,B]=C.useState(null),[V,z]=C.useState(void 0),[H,W]=C.useState(!1),[G,q]=C.useState(!1),Y=C.useMemo(()=>(u||[]).map(me=>me.name),[u]),K=C.useMemo(()=>!o||o==="default"?null:(l==null?void 0:l.find(ye=>ye.agent_id===o||ye.agent_code===o))||null,[o,l]),X=C.useMemo(()=>y_e(K),[K]);C.useEffect(()=>{w(null)},[o]),C.useEffect(()=>{Z(),u&&u.length>0&&Q()},[u]),C.useEffect(()=>{if(h&&(g(!0),d)){const me=Y.find(ye=>ye===d);me?w(me):Y.length>0}},[h,d,Y]);const Z=async()=>{try{const me=await jq({});me!=null&&me.data&&D(me.data.map(ye=>({webhook_id:ye.webhook_id,name:ye.name,platform:ye.platform})))}catch{}},Q=async()=>{try{const me={};await Promise.all(u.map(async ye=>{var de;try{const ve=await r4r(ye.agent_id,{});(de=ve==null?void 0:ve.data)!=null&&de.webhook_id&&(me[ye.agent_id]=ve.data.webhook_id)}catch{}})),R(me)}catch{}},J=C.useMemo(()=>b?r.filter(me=>{var ve;const ye=(ve=me.title)==null?void 0:ve.match(/^(.+?)\s*巡检结果$/);return(ye?ye[1]:me.agent_name)===b}):r,[r,b]),re=C.useMemo(()=>{if(!b)return"";const me=(u||[]).find(ye=>ye.name===b);return(me==null?void 0:me.agent_id)||""},[b,u]),ee=n==="maiduo"&&b==="差评监控",se=me=>{const ye=b===me?null:me;w(ye),ye&&g(!0)},ue=me=>{B(me),z(N[me.agent_id]),O(!0)},le=C.useCallback(async me=>{if(me){E(!0);try{const ye=await zkr({agent_id:me,limit:50});if(ye!=null&&ye.data&&Array.isArray(ye.data)){const de=ye.data.map((ve,te)=>({id:ve.id||ve.execute_id||`record_${te}`,action_name:ve.action_name||ve.display_name||"未知动作",action_id:ve.action_id||"",status:ve.status||"pending",created_at:ve.created_at||"",completed_at:ve.completed_at,action_params:ve.action_params,output_type:ve.output_type,output_data:ve.output_data,outputs:ve.outputs,error:ve.error})).sort((ve,te)=>new Date(te.created_at).getTime()-new Date(ve.created_at).getTime());$(de)}else $([])}catch{$([])}finally{E(!1)}}},[]),ne=me=>{if(!me)return"";try{const ye=new Date(me),de=ye.toLocaleDateString("zh-CN",{year:"numeric",month:"2-digit",day:"2-digit"}),ve=ye.toLocaleTimeString("zh-CN",{hour:"2-digit",minute:"2-digit"});return`${de} ${ve}`}catch{return me}},oe=me=>({pending:"等待中",running:"执行中",success:"成功",failed:"失败"})[me]||me,Se=me=>({pending:"wandox-exec-status--pending",running:"wandox-exec-status--running",success:"wandox-exec-status--success",failed:"wandox-exec-status--failed"})[me]||"";C.useEffect(()=>{S==="history"&&re&&le(re)},[S,re,le]);const ie=async()=>{if(!F||!V){$t.warning("请选择 Webhook");return}try{W(!0),await t4r({},{agent_id:F.agent_id,webhook_id:V}),$t.success("绑定成功"),O(!1),Q()}catch(me){$t.error((me==null?void 0:me.message)||"绑定失败")}finally{W(!1)}},be=async()=>{if(F)try{W(!0),await n4r(F.agent_id,{}),$t.success("解绑成功"),O(!1),z(void 0),Q()}catch(me){$t.error((me==null?void 0:me.message)||"解绑失败")}finally{W(!1)}},pe=me=>{x(me),v(!0)},xe=()=>{v(!1),x(null)},Re=me=>{if(!me)return"";try{const ye=new Date(me),de=ye.toLocaleDateString("zh-CN",{year:"numeric",month:"2-digit",day:"2-digit"}),ve=ye.toLocaleTimeString("zh-CN",{hour:"2-digit",minute:"2-digit"});return`${de}
769
769
  ${ve}`}catch{return me}},Ce=(me,ye)=>{const de={high:"#ff4d4f",medium:"#faad14",low:"#52c41a"};return k.jsxs("div",{className:"wandox-timeline-item",children:[k.jsxs("div",{className:"wandox-timeline-dot-wrapper",children:[k.jsx("span",{className:"wandox-timeline-time",style:{whiteSpace:"pre-line"},children:Re(me.timestamp||"")}),k.jsx("div",{className:"wandox-timeline-dot",style:{background:de[me.priority]}}),!ye&&k.jsx("div",{className:"wandox-timeline-line"})]}),k.jsxs("div",{className:"wandox-widget-card",children:[k.jsx("div",{className:"wandox-widget-title",children:me.title}),me.ui_payload&&k.jsx("div",{className:"wandox-widget-content wandox-markdown-content",children:k.jsx(hl,{payload:me.ui_payload})}),me.actions&&me.actions.length>0&&k.jsx("div",{className:"wandox-widget-actions",children:k.jsxs("button",{type:"button",className:"wandox-widget-view-detail-btn",onClick:()=>pe(me),children:[k.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",role:"img",children:[k.jsx("title",{children:"快速执行"}),k.jsx("path",{d:"M13 2L3 14H12L11 22L21 10H12L13 2Z",fill:"currentColor"})]}),"快速执行 (",me.actions.length,")"]})})]})]},me.id||`${me.type}_${me.title}_${me.timestamp}`)};return k.jsxs("div",{className:"wandox-widget-section",children:[k.jsxs("div",{className:"wandox-section-header",children:[k.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[f??k.jsx("span",{className:"wandox-widget-section-title",children:t}),X&&k.jsx(Y4,{title:k.jsx("div",{style:{paddingBottom:"8px",borderBottom:"1px solid #f0f0f0"},children:k.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:"8px"},children:[k.jsxs("div",{children:[k.jsx("strong",{children:X.packageName}),X.subtitle&&k.jsx("div",{style:{color:"#999",fontSize:"11px",fontWeight:400},children:X.subtitle})]}),k.jsx(dS,{count:"生效中",style:{backgroundColor:"#52c41a",fontSize:"10px",lineHeight:"18px",height:"18px",minWidth:"50px"}})]})}),content:k.jsxs("div",{style:{fontSize:"12px",lineHeight:"1.6",minWidth:"280px"},children:[k.jsxs("div",{style:{marginBottom:"8px",display:"flex",justifyContent:"space-between"},children:[k.jsx("div",{style:{color:"#999"},children:"套餐类型:"}),k.jsx("strong",{children:X.packageName})]}),X.asinUsage&&k.jsxs("div",{style:{marginBottom:X.asinUsagePercent!=null?"4px":"8px",display:"flex",justifyContent:"space-between",gap:"16px"},children:[k.jsx("div",{style:{color:"#999"},children:"ASIN 已用:"}),k.jsx("strong",{style:{color:"#9444f5"},children:X.asinUsage})]}),X.asinUsagePercent!=null&&k.jsx("div",{style:{marginBottom:"8px"},children:k.jsx("div",{style:{height:"6px",borderRadius:"3px",background:"#f0eaff",overflow:"hidden"},children:k.jsx("div",{style:{height:"100%",width:`${X.asinUsagePercent}%`,borderRadius:"3px",background:"linear-gradient(90deg, #9444f5, #b47aff)",transition:"width 0.3s ease"}})})}),k.jsxs("div",{style:{marginBottom:"8px",display:"flex",justifyContent:"space-between"},children:[k.jsx("div",{style:{color:"#999"},children:X.remainingLabel}),k.jsx("strong",{style:{color:"#9444f5",fontWeight:"bold"},children:X.remainingValue})]}),k.jsxs("div",{style:{marginBottom:"8px",display:"flex",justifyContent:"space-between"},children:[k.jsx("div",{style:{color:"#999"},children:"到期时间:"}),k.jsx("strong",{children:X.endTime})]}),k.jsxs("div",{style:{marginBottom:"8px",display:"flex",justifyContent:"space-between"},children:[k.jsx("div",{style:{color:"#999"},children:"开通时间:"}),k.jsx("strong",{children:X.startTime})]}),X.coverageItems.length>0&&k.jsxs("div",{style:{padding:"8px 12px",background:"#faf8ff",borderRadius:"8px"},children:[k.jsx("div",{style:{marginBottom:"4px",color:"#9444f5",fontSize:"13px",fontWeight:"bold"},children:X.coverageTitle}),k.jsx("div",{style:{fontSize:"11px",color:"#666",lineHeight:"2"},children:X.coverageItems.map(me=>k.jsxs("div",{children:[k.jsx($v,{style:{marginRight:"6px",color:"#9444f5"}}),me]},me))})]})]}),placement:"bottom",trigger:"hover",children:k.jsx(dS,{count:X.badgeText,style:{backgroundColor:X.badgeColor,color:X.badgeTextColor,cursor:"pointer"}})})]}),k.jsx("div",{className:"wandox-inspection-controls",children:k.jsxs("button",{type:"button",className:`wandox-inspection-agent-btn ${p?"wandox-inspection-agent-btn--expanded":""}`,onClick:()=>{p?(g(!1),w(null)):g(!0)},children:[k.jsxs("span",{className:"wandox-inspection-agent-icon",children:[k.jsxs("svg",{viewBox:"0 0 24 24",width:"14",height:"14",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[k.jsx("circle",{cx:"12",cy:"12",r:"4",stroke:"currentColor",strokeWidth:"1.5"}),k.jsx("circle",{cx:"12",cy:"12",r:"1.5",fill:"currentColor"})]}),k.jsx("span",{className:"wandox-orbit-dot wandox-orbit-dot-1"}),k.jsx("span",{className:"wandox-orbit-dot wandox-orbit-dot-2"}),k.jsx("span",{className:"wandox-orbit-dot wandox-orbit-dot-3"})]}),k.jsxs("span",{className:"wandox-inspection-agent-text",children:["巡检机器人(",Y.length,")"]})]})})]}),p&&k.jsxs("div",{className:"wandox-timeline-list",children:[k.jsxs("div",{className:"wandox-agent-filter-row wandox-agent-filter-row--with-close",children:[k.jsxs("div",{className:"wandox-agent-filter-chips",children:[u.length>0&&k.jsx("button",{type:"button",className:`wandox-agent-filter-chip ${b===null?"active":""}`,onClick:()=>w(null),children:"全部"}),u.map(me=>{const ye=!!N[me.agent_id];return k.jsxs("div",{className:`wandox-agent-filter-chip-compound ${b===me.name?"active":""}`,children:[k.jsx("button",{type:"button",className:"wandox-agent-filter-chip-name",onClick:()=>se(me.name),children:me.name}),k.jsx("button",{type:"button",className:`wandox-agent-filter-chip-webhook ${ye?"bound":""}`,onClick:()=>ue(me),title:ye?"已绑定 Webhook,点击修改":"绑定 Webhook 通知",children:ye?k.jsxs(k.Fragment,{children:[k.jsx("span",{className:"wandox-webhook-dot","aria-hidden":"true"}),k.jsx("span",{className:"wandox-webhook-label",children:"已通知"})]}):k.jsxs(k.Fragment,{children:[k.jsx("span",{className:"wandox-webhook-plus","aria-hidden":"true",children:"+"}),k.jsx("span",{className:"wandox-webhook-label",children:"通知"})]})})]},me.agent_id)})]}),k.jsx("button",{type:"button",className:"wandox-timeline-list-close",onClick:()=>{g(!1),w(null),_("results")},title:"关闭",children:"✕"})]}),ee&&k.jsxs("div",{className:"wandox-negative-review-notice",children:[k.jsx("span",{className:"wandox-negative-review-notice-icon","aria-hidden":"true",children:"ℹ️"}),k.jsxs("span",{children:["差评监控需要先设置需要监控的ASIN,请前往AI工具》",k.jsx("a",{href:znn,target:"_blank",rel:"noreferrer",className:"wandox-negative-review-notice-link",children:"新老诊断"}),"进行设置。每个asin每一次都需要0.01算力。"]})]}),k.jsx("div",{className:"wandox-timeline-tabs-header",children:k.jsxs("div",{className:"wandox-timeline-tabs-nav",children:[k.jsxs("button",{type:"button",className:`wandox-timeline-tab-btn ${S==="results"?"active":""}`,onClick:()=>_("results"),children:["巡检结果",J.length>0&&k.jsx("span",{className:"wandox-timeline-tab-badge",children:J.length})]}),k.jsx("button",{type:"button",className:`wandox-timeline-tab-btn ${S==="history"?"active":""}`,onClick:()=>_("history"),children:"执行记录"})]})}),S==="results"?k.jsx("div",{className:"wandox-timeline-list-content",children:J.length>0?J.sort((me,ye)=>{const de=me.timestamp?new Date(me.timestamp).getTime():0;return(ye.timestamp?new Date(ye.timestamp).getTime():0)-de}).map((me,ye,de)=>Ce(me,ye===de.length-1)):k.jsxs("div",{className:"wandox-empty-state",children:[k.jsx("div",{className:"wandox-empty-icon",children:"�"}),k.jsx("div",{className:"wandox-empty-text",children:b?"没有符合筛选条件的数据":"暂无工作区数据"}),k.jsx("div",{className:"wandox-empty-desc",children:b?"请调整筛选条件":"工作区数据将在这里显示"})]})}):k.jsx("div",{className:"wandox-timeline-list-content wandox-history-panel",children:b?T?k.jsxs("div",{className:"wandox-loading-state",children:[k.jsx("span",{className:"wandox-spinner wandox-spinner--small"}),k.jsx("span",{children:"加载中..."})]}):I.length===0?k.jsx("div",{className:"wandox-empty-state",children:k.jsx("div",{className:"wandox-empty-text",children:"暂无执行记录"})}):k.jsx("div",{className:"wandox-exec-history-list",children:I.map(me=>k.jsxs("div",{className:"wandox-exec-history-item",children:[k.jsxs("div",{className:"wandox-exec-history-header",onClick:()=>P(A===me.id?null:me.id),onKeyDown:ye=>ye.key==="Enter"&&P(A===me.id?null:me.id),role:"button",tabIndex:0,children:[k.jsxs("div",{className:"wandox-exec-history-info",children:[k.jsx("span",{className:"wandox-exec-history-name",children:me.action_name}),k.jsx("span",{className:"wandox-exec-history-time",children:ne(me.created_at)})]}),k.jsxs("div",{className:"wandox-exec-history-status-wrapper",children:[k.jsx("span",{className:`wandox-exec-status ${Se(me.status)}`,children:oe(me.status)}),k.jsx("span",{className:"wandox-exec-history-arrow","aria-hidden":"true",children:A===me.id?"▼":"▶"})]})]}),A===me.id&&k.jsxs("div",{className:"wandox-exec-history-detail",children:[me.action_params&&Object.keys(me.action_params).length>0&&k.jsxs("div",{className:"wandox-exec-params",children:[k.jsx("div",{className:"wandox-exec-section-label",children:"执行参数"}),k.jsx("div",{className:"wandox-exec-params-list",children:Object.entries(me.action_params).map(([ye,de])=>k.jsxs("div",{className:"wandox-exec-param-item",children:[k.jsxs("span",{className:"wandox-exec-param-key",children:[ye,":"]}),k.jsx("span",{className:"wandox-exec-param-value",children:typeof de=="object"?JSON.stringify(de):String(de)})]},ye))})]}),me.error?k.jsxs("div",{className:"wandox-exec-error",children:[k.jsx("span",{className:"wandox-exec-error-label",children:"错误信息:"}),k.jsx("span",{className:"wandox-exec-error-msg",children:me.error})]}):me.output_type&&me.output_data?k.jsxs("div",{className:"wandox-exec-outputs",children:[k.jsx("div",{className:"wandox-exec-section-label",children:"执行结果"}),k.jsx(hl,{payload:{type:me.output_type,...me.output_data}})]}):me.outputs?k.jsxs("div",{className:"wandox-exec-outputs",children:[k.jsx("div",{className:"wandox-exec-section-label",children:"执行结果"}),k.jsx(hl,{payload:me.outputs})]}):k.jsx("div",{className:"wandox-exec-no-output",children:"暂无输出结果"})]})]},me.id))}):k.jsxs("div",{className:"wandox-empty-state",children:[k.jsx("div",{className:"wandox-empty-icon",children:"🤖"}),k.jsx("div",{className:"wandox-empty-text",children:"请先选择机器人"}),k.jsx("div",{className:"wandox-empty-desc",children:"在上方选择一个机器人查看执行记录"})]})})]}),k.jsx(Kmt,{open:m,title:(y==null?void 0:y.title)||"动作详情",actions:(y==null?void 0:y.actions)||[],widgetId:y==null?void 0:y.id,ssoToken:i,ssoDomain:n,ssoCompany:a,onClose:xe,onExecuteComplete:s}),k.jsx(_i,{title:k.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[k.jsxs("svg",{viewBox:"0 0 24 24",width:"20",height:"20",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:[k.jsx("path",{d:"M12 22C10.8954 22 10 21.1046 10 20V14C10 12.8954 10.8954 12 12 12C13.1046 12 14 12.8954 14 14V20C14 21.1046 13.1046 22 12 22Z"}),k.jsx("path",{d:"M18 16C16.8954 16 16 15.1046 16 14V10C16 8.89543 16.8954 8 18 8C19.1046 8 20 8.89543 20 10V14C20 15.1046 19.1046 16 18 16Z"}),k.jsx("path",{d:"M6 16C4.89543 16 4 15.1046 4 14V10C4 8.89543 4.89543 8 6 8C7.10457 8 8 8.89543 8 10V14C8 15.1046 7.10457 16 6 16Z"}),k.jsx("path",{d:"M10.5 4C10.5 2.61929 11.6193 1.5 13 1.5H13.5C14.8807 1.5 16 2.61929 16 4V6H10.5V4Z"})]}),k.jsx("span",{children:"配置 Webhook 通知"})]}),open:M,onCancel:()=>{O(!1),B(null),z(void 0)},width:520,footer:null,centered:!0,children:k.jsxs("div",{style:{padding:"8px 0"},children:[k.jsxs("div",{style:{marginBottom:"20px",padding:"12px 16px",background:"#f5f7fa",borderRadius:"8px",border:"1px solid #e8eaed"},children:[k.jsx("div",{style:{fontSize:"13px",color:"#666",marginBottom:"4px"},children:"智能体"}),k.jsx("div",{style:{fontSize:"15px",color:"#1a1a1a",fontWeight:500},children:F==null?void 0:F.name})]}),k.jsxs("div",{style:{marginBottom:"20px"},children:[k.jsx("div",{style:{marginBottom:"8px",fontSize:"14px",color:"#333",fontWeight:500},children:"选择 通知地址"}),k.jsx(wn,{style:{width:"100%"},size:"large",placeholder:"请选择 通知地址",value:V,onChange:z,options:L.map(me=>({label:`${me.name} (${me.platform==="dingtalk"?"钉钉":me.platform==="feishu"?"飞书":"企业微信"})`,value:me.webhook_id})),disabled:H,popupRender:me=>k.jsxs(k.Fragment,{children:[me,k.jsx(fqe,{style:{margin:"8px 0"}}),k.jsx(il,{style:{padding:"0 8px 4px"},children:k.jsx(ur,{type:"text",icon:k.jsx("span",{children:"+"}),onClick:()=>q(!0),children:"添加新的通知地址"})})]})}),L.length===0&&k.jsxs("div",{style:{marginTop:"8px",padding:"8px 12px",background:"#fff7e6",border:"1px solid #ffd591",borderRadius:"4px",fontSize:"13px",color:"#d46b08",display:"flex",alignItems:"center",gap:"6px"},children:[k.jsx("span",{children:"⚠️"}),k.jsx("span",{children:'暂无可用的 通知地址,请先在"通知配置"中创建'})]})]}),k.jsxs("div",{style:{padding:"12px 16px",background:"#f0f9ff",borderRadius:"8px",border:"1px solid #bae7ff",marginBottom:"20px"},children:[k.jsx("div",{style:{fontSize:"13px",color:"#0958d9",fontWeight:500,marginBottom:"8px"},children:"💡 功能说明"}),k.jsxs("div",{style:{fontSize:"13px",color:"#096dd9",lineHeight:"1.8"},children:[k.jsx("div",{children:"• 绑定后,该智能体执行完成时会自动发送通知"}),k.jsx("div",{children:"• 通知内容包含执行结果和相关信息"}),k.jsx("div",{children:"• 可随时修改或解除绑定"})]})]}),k.jsxs("div",{style:{display:"flex",gap:"12px",justifyContent:"flex-end"},children:[N[(F==null?void 0:F.agent_id)||""]&&k.jsx("button",{type:"button",onClick:be,disabled:H,style:{marginRight:"auto",padding:"8px 20px",border:"1px solid #ff4d4f",borderRadius:"6px",background:"#fff",color:"#ff4d4f",cursor:H?"not-allowed":"pointer",fontSize:"14px",fontWeight:500,transition:"all 0.2s",opacity:H?.6:1},onMouseEnter:me=>{H||(me.currentTarget.style.background="#fff1f0")},onMouseLeave:me=>{me.currentTarget.style.background="#fff"},children:"解除绑定"}),k.jsx("button",{type:"button",onClick:()=>{O(!1),B(null),z(void 0)},disabled:H,style:{padding:"8px 24px",border:"1px solid #d9d9d9",borderRadius:"6px",background:"#fff",color:"#333",cursor:H?"not-allowed":"pointer",fontSize:"14px",fontWeight:500,transition:"all 0.2s",opacity:H?.6:1},onMouseEnter:me=>{H||(me.currentTarget.style.background="#fafafa")},onMouseLeave:me=>{me.currentTarget.style.background="#fff"},children:"取消"}),k.jsx("button",{type:"button",onClick:ie,disabled:H||!V,style:{padding:"8px 24px",border:"none",borderRadius:"6px",background:H||!V?"#d9d9d9":"#1890ff",color:"#fff",cursor:H||!V?"not-allowed":"pointer",fontSize:"14px",fontWeight:500,transition:"all 0.2s"},onMouseEnter:me=>{!H&&V&&(me.currentTarget.style.background="#40a9ff")},onMouseLeave:me=>{!H&&V&&(me.currentTarget.style.background="#1890ff")},children:H?"保存中...":"保存"})]})]})}),k.jsx(H0t,{open:G,onClose:()=>q(!1),onSuccess:me=>{D(ye=>[...ye,me]),z(me.webhook_id)}})]})}function V_(e,t){return e.role!=="assistant"?!1:t.message_id&&e.message_id?e.message_id===t.message_id:e.id===t.id}function W0t(e){return e.role!=="user"?!1:!!(e.outputs||e.ui_payload||e.actions&&e.actions.length>0)&&/^\s*⏳\s*Step\d+/i.test(e.content||"")}const G0t=new Set(["completed","failed","stopped"]),Vnn=new Set(["thinking","recommend"]),LQ={running:0,completed:1,failed:2,stopped:3};function b_e(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function x_e(e){const t=typeof e=="number"?e:Number(e);return Number.isFinite(t)&&t>=0?t:void 0}function Hnn(e){const t=String(e||"").toLowerCase();return t==="running"||t==="failed"||t==="stopped"?t:"completed"}function U0t(e,t){if(!b_e(e))return;const r=typeof e.type=="string"&&e.type.trim()?e.type.trim():void 0;if(!r)return;const n=x_e(e.sequence),i=b_e(e.data)?e.data:{};return{...typeof e.event_id=="string"&&e.event_id?{event_id:e.event_id}:{},type:r,sequence:n===void 0?t:n,...typeof e.timestamp=="string"&&e.timestamp?{timestamp:e.timestamp}:{},...typeof e.execution_id=="string"&&e.execution_id?{execution_id:e.execution_id}:{},...typeof e.execution_type=="string"&&e.execution_type?{execution_type:e.execution_type}:{},...typeof e.source=="string"&&e.source?{source:e.source}:{},data:i}}function B5(e){return e==null?"":String(e).trim()}function Wnn(e,t){const r=B5(e.data.task_id),n=B5(t.data.task_id);if(r&&n)return r===n;const i=B5(e.data.step_index),a=B5(t.data.step_index);if(i&&a)return i===a;const s=B5(e.data.step_name||e.data.title),o=B5(t.data.step_name||t.data.title);return!!(s&&o&&s===o)}function q0t(e){return e.reduce((t,r)=>{if(r.type!=="output")return t.push(r),t;let n=-1;for(let a=t.length-1;a>=0;a-=1)if(t[a].type==="step"&&Wnn(r,t[a])){n=a;break}if(n<0)return t.push(r),t;const i=t[n];return t[n]={...i,...r,event_id:i.event_id||r.event_id,type:"step",sequence:i.sequence,data:{...i.data,...r.data}},t},[])}function w_e(e){if(!b_e(e))return;const t=q0t((Array.isArray(e.events)?e.events:[]).map((s,o)=>U0t(s,o+1)).filter(s=>!!s).sort((s,o)=>s.sequence-o.sequence)),r=Hnn(e.status),n=e.duration_ms===null?null:x_e(e.duration_ms),i=typeof e.started_at=="string"&&e.started_at.trim().length>0;if(t.length===0&&r!=="running"&&n==null&&!i)return;const a=x_e(e.total);return{status:r,...e.origin==="live"||e.origin==="history"?{origin:e.origin}:{},duration_ms:n,total:a===void 0?t.length:a,truncated:e.truncated===!0,events:t,...i?{started_at:e.started_at}:{}}}function PQ(e=new Date().toISOString()){return{status:"running",origin:"live",duration_ms:0,total:0,truncated:!1,events:[],started_at:e}}function V9(e,t,r=Date.now()){const n=w_e(e.process)??PQ(e.timestamp||new Date(r).toISOString());if(G0t.has(n.status))return e;const i=n.events.reduce((d,h)=>Math.max(d,h.sequence),0)+1,a=U0t({...t,sequence:t.sequence??i,timestamp:t.timestamp||new Date(r).toISOString()},i);if(!a)return e;let s=[...n.events];const o=a.event_id?s.findIndex(d=>d.event_id===a.event_id):-1;o>=0?s[o]={...s[o],...a,sequence:s[o].sequence}:(s.push(a),s.sort((d,h)=>d.sequence-h.sequence)),s=q0t(s);const l=Date.parse(n.started_at||e.timestamp),u=Number.isFinite(l)?Math.max(n.duration_ms||0,r-l):n.duration_ms;return{...e,process:{...n,status:"running",duration_ms:u,total:s.length,events:s}}}function Yx(e,t,r=Date.now()){const n=w_e(e.process);if(!n||G0t.has(n.status)&&LQ[n.status]>=LQ[t])return e;const i=n.events.filter(u=>!Vnn.has(u.type)),a=Date.parse(n.started_at||e.timestamp),s=Number.isFinite(a)?Math.max(0,r-a):void 0,o=n.duration_ms==null?s:s===void 0?n.duration_ms:Math.max(n.duration_ms,s),l=LQ[n.status]>LQ[t]?n.status:t;return{...e,process:{...n,status:l,duration_ms:o,total:i.length,events:i}}}function S_e(e,t){return{...e,content:"",ui_payload:{type:"markdown",content:t,streaming:!0},stream_content_received:!0}}function C_e(e,t){var n;const r={message_id:t.messageId||e.message_id,execution_id:t.executionId??e.execution_id,actions:(n=t.actions)!=null&&n.length?t.actions:void 0,execution_status:"completed"};return e.stream_content_received?{...e,...r,content:"",ui_payload:e.ui_payload?{...e.ui_payload,streaming:!1}:e.ui_payload}:{...e,...r,content:t.payload?"":t.content||"执行完成",ui_payload:t.payload}}function Gnn(e){const t=String(e??"").trim().toLowerCase();return!t||["pending","running","executing","stopping","pending_async","awaiting_async"].includes(t)}function H9(e){if(Array.isArray(e))return e.map(H9);if(!e||typeof e!="object")return e;const t=e,r={...t};return Array.isArray(t.children)&&(r.children=t.children.map(H9)),(t.type==="step"||t.status!==void 0)&&Gnn(t.status)&&(r.status="stopped",t.message||(r.message="任务已停止")),r}function W9(e,t,r){var s;const n=t==="stopped"?"stopped":"error",a=((s=e.process)==null?void 0:s.events.some(o=>o.type===n&&o.data.message===r))?e:V9(e,{type:n,data:{message:r,status:t}});return Yx(a,t)}function Unn(e,t,r){return S_e(e,t)}function __e(e){const{activeAgent:t,ssoToken:r,ssoDomain:n,ssoCompany:i,defaultParams:a,onMessagesUpdate:s,onRecommendationsUpdate:o}=e,[l,u]=C.useState(!1),[d,h]=C.useState(!1),[f,p]=C.useState(null),g=C.useRef(!1),m=C.useRef(null),v=C.useRef(null),y=C.useRef(null),x=C.useRef(null),b=C.useCallback(()=>!r||!n||!i?($t.warning("请先登录 SSO"),!1):!0,[r,n,i]),w=C.useCallback((A,P)=>({id:`msg_${Date.now()}_${Math.random()}`,role:A,content:P,timestamp:new Date().toISOString()}),[]),S=C.useCallback(async A=>{if(!b())return;if(g.current){m.current=A;return}g.current=!0;const{userMsg:P,assistantMsgId:N,assistantMsg:R}=(()=>{var z;const O=Date.now(),F={id:`msg_${O}`,role:"user",content:A.message||"",timestamp:new Date().toISOString(),...(z=A.attachments)!=null&&z.length?{attachments:A.attachments}:{}},B=`msg_${O+1}`,V={id:B,role:"assistant",content:"⏳ 正在思考...",timestamp:new Date().toISOString(),playbook_id:A.playbook_id,execution_status:"executing",process:PQ()};return{userMsg:F,assistantMsgId:B,assistantMsg:V}})(),L=A._hideUserMessage===!0;s(O=>L?[...O,R]:[...O,P,R]),u(!0),x.current={assistantMsgId:N};const D=new AbortController;y.current=D;const M=()=>{var O;return y.current===D&&((O=x.current)==null?void 0:O.assistantMsgId)===N};try{const O={...A,agent_id:t,stream:!0,playbook_params:{...A.playbook_params||{}},message:A.message||"",...a||{}},{_hideUserMessage:F,...B}=O,V=await fetch(`${Ss()}/api/v1/agents/chat`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${r}`,"X-Tenant-ID":i,"X-Domain":n},body:JSON.stringify(B),signal:D.signal});if(!V.ok)throw new Error(`HTTP ${V.status}`);await R9(V,{assistantMsgId:N,onMessageId:z=>{if(!M())return;const H=x.current;H&&(H.anchorMessageId=z)},onQueue:z=>{M()&&(p(z),z.status==="waiting"?s(H=>H.map(W=>W.id===N?{...W,content:`⏳ ${z.message}`}:W)):z.status==="ready"&&(p(null),s(H=>H.map(W=>W.id===N?{...W,content:`⏳ ${z.message}`}:W))))},onProgress:z=>{M()&&(p(null),s(H=>H.map(W=>W.id===N?{...W,content:`⏳ ${z}`}:W)))},onProcessEvent:z=>{M()&&s(H=>H.map(W=>W.id===N?V9(W,z):W))},onContent:z=>{M()&&s(H=>H.map(W=>W.id===N?S_e(W,z):W))},onComplete:(z,H,W,G,q)=>{M()&&s(Y=>Y.map(K=>{var X,Z;return K.id!==N||((X=K.process)==null?void 0:X.status)==="failed"||((Z=K.process)==null?void 0:Z.status)==="stopped"?K:Yx(C_e(K,{content:z,payload:H,actions:W,messageId:G,executionId:q}),"completed")}))},onError:(z,H)=>{M()&&s(W=>{const G=(H==null?void 0:H.cancelled)===!0,q=G?"任务已停止":`❌ ${z}`;return W.map(Y=>Y.id===N?W9({...Y,content:Y.content.startsWith("❌")?Y.content:q,execution_status:G?"stopped":"failed",outputs:G&&Y.outputs?H9(Y.outputs):Y.outputs},G?"stopped":"failed",G?"任务已停止":z):Y)})},onRecommend:z=>{M()&&o(z)},onProposal:z=>{if(!M())return;const H={proposal_id:z.proposal_id,scene:z.scene,message:z.message,options:z.options||[],params:z.params,actions:z.actions};s(W=>W.map(G=>G.id===N?Yx({...G,content:"",proposal:H,execution_status:"completed"},"completed"):G))}})}catch(O){(O==null?void 0:O.name)!=="AbortError"&&M()&&s(F=>F.map(B=>B.id===N?W9({...B,content:`❌ 执行出错: ${O.message||"未知错误"}`,execution_status:"failed"},"failed",O.message||"未知错误"):B))}finally{if(y.current===D&&(y.current=null,x.current=null,g.current=!1,u(!1),h(!1),m.current)){const O=m.current;m.current=null,setTimeout(()=>{var F;return(F=v.current)==null?void 0:F.call(v,O)},0)}}},[t,r,n,i,b,w,s,o]);v.current=S;const _=C.useCallback(()=>{m.current=null,p(null);const A=y.current;y.current=null,x.current=null,g.current=!1,u(!1),h(!1),A&&!A.signal.aborted&&A.abort()},[]),T=C.useCallback(async()=>{const A=y.current,P=x.current;if(!A||!P)return;const N=P.assistantMsgId,R=P.anchorMessageId,L=()=>{var D;return y.current===A&&((D=x.current)==null?void 0:D.assistantMsgId)===N};if(!R){$t.warning("任务编号尚未就绪,请稍后再试");return}if(L()){h(!0),s(D=>D.map(M=>M.id===N?{...M,execution_status:"stopping",content:"正在停止..."}:M));try{const D=await fetch(`${Ss()}/api/v1/agents/chat/stop`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${r}`,"X-Tenant-ID":i,"X-Domain":n},body:JSON.stringify({message_id:R})});if(!L())return;if(!D.ok)throw new Error(`HTTP ${D.status}`);const M=await D.json().catch(()=>null);if(!L())return;if(M&&M.success===!1)throw new Error(M.message||"停止失败");if(s(O=>O.map(F=>{var B;return F.id===N?W9({...F,message_id:(M==null?void 0:M.stopped_message_id)||((B=M==null?void 0:M.data)==null?void 0:B.stopped_message_id)||F.message_id,execution_status:"stopped",content:"任务已停止",outputs:F.outputs?H9(F.outputs):F.outputs},"stopped","任务已停止"):F})),!L())return;_()}catch(D){if(!L())return;h(!1),s(M=>M.map(O=>O.id===N?{...O,execution_status:"executing"}:O)),$t.error(`停止失败:${D instanceof Error?D.message:"未知错误"}`)}}},[_,s,i,n,r]),E=C.useCallback(async A=>{const P=A.message_id;if(!P||g.current)return;g.current=!0,u(!0);const N=new Date().toISOString();x.current={assistantMsgId:A.id,anchorMessageId:P};const R=new AbortController;y.current=R;const L=()=>{var D;return y.current===R&&((D=x.current)==null?void 0:D.assistantMsgId)===A.id};s(D=>D.map(M=>V_(M,A)?{...M,content:"",outputs:void 0,ui_payload:void 0,actions:void 0,execution_status:"executing",retrigger_status:"executing",retrigger_error:void 0,stream_content_received:void 0,process:PQ(N)}:M));try{const D=await fetch(`${Ss()}/api/v1/agents/chat/retrigger`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${r}`,"X-Tenant-ID":i,"X-Domain":n},body:JSON.stringify({message_id:P,stream:!0}),signal:R.signal});if(!D.ok){const M=await D.json().catch(()=>null),O=[M==null?void 0:M.message,M==null?void 0:M.detail,M==null?void 0:M.error].find(F=>typeof F=="string"&&F.trim());throw D.status===409?new Error(O||"任务仍在执行,请先停止"):D.status>=500?new Error(O||"服务暂时无法完成请求,请稍后重试"):new Error(O||`请求失败(HTTP ${D.status})`)}await R9(D,{assistantMsgId:A.id,onMessageId:M=>{if(!L())return;const O=x.current;O&&(O.anchorMessageId=M)},onProgress:M=>{L()&&s(O=>O.map(F=>V_(F,A)?{...F,content:M}:F))},onProcessEvent:M=>{L()&&s(O=>O.map(F=>V_(F,A)?V9(F,M):F))},onContent:M=>{L()&&s(O=>O.map(F=>V_(F,A)?S_e(F,M):F))},onComplete:(M,O,F,B,V)=>{L()&&s(z=>z.map(H=>{var W,G;return!V_(H,A)||((W=H.process)==null?void 0:W.status)==="failed"||((G=H.process)==null?void 0:G.status)==="stopped"?H:Yx({...C_e(H,{content:M,payload:O,actions:F,messageId:B,executionId:V}),retrigger_status:void 0,retrigger_error:void 0},"completed")}))},onError:(M,O)=>{L()&&s(F=>F.map(B=>{if(!V_(B,A))return B;const V=(O==null?void 0:O.cancelled)===!0;return W9({...B,content:V?"任务已停止":"",execution_status:V?"stopped":"failed",retrigger_status:V?void 0:"failed",retrigger_error:V?void 0:M,outputs:V&&B.outputs?H9(B.outputs):B.outputs},V?"stopped":"failed",V?"任务已停止":M)}))},onRecommend:M=>{L()&&o(M)}})}catch(D){if(L()&&!(D instanceof DOMException&&D.name==="AbortError")){const M=D instanceof Error?D.message:"未知错误";s(O=>O.map(F=>V_(F,A)?{...W9(F,"failed",M),content:"",execution_status:"failed",retrigger_status:"failed",retrigger_error:M}:F))}}finally{y.current===R&&(y.current=null,x.current=null,g.current=!1,u(!1),h(!1))}},[s,o,i,n,r]),I=C.useCallback(async(A,P,N)=>{if(!A.trim()&&(!N||N.length===0)){$t.error("请输入消息");return}await S({message:A||"",playbook_id:P,...N!=null&&N.length?{attachments:N}:{}})},[S]),$=C.useCallback(async A=>{const{proposal_id:P,proposal_action:N,selected_option_id:R,filled_params:L,messageId:D,proposalMessage:M,optionTitle:O}=A;s(V=>V.map(z=>z.id===D?{...z,proposal_status:N==="confirm"?"confirmed":"rejected"}:z));let F="";if(N==="confirm"){const V=[];if(M&&V.push(M),O&&V.push(`${O}确认执行`),L&&Object.keys(L).length>0){const z=Object.entries(L).map(([H,W])=>`${H}: ${Array.isArray(W)?W.join(","):W}`).join(", ");V.push(`参数{${z}}`)}F=V.join(",")}const B={message:F,agent_id:t,stream:!0,proposal_id:P,proposal_action:N,_hideUserMessage:!0,...a||{}};N==="confirm"&&(B.selected_option_id=R,B.filled_params=L||{}),await S(B)},[t,a,S,s]);return{executing:l,stopping:d,executingRef:g,queueStatus:f,sendMessage:I,executePlaybook:S,respondToProposal:$,stopCurrent:T,retrigger:E,abort:_}}function Y0t(e){var o;const t=e.role==="assistant"?w_e(e.process):void 0,r={...e,process:t?{...t,origin:"history"}:void 0},n=r.execution_id??((o=r.meta_content)==null?void 0:o.execution_id),i=r.meta_content;if(!i||i.response_type!=="proposal")return n===void 0?r:{...r,execution_id:n};const a={proposal_id:i.proposal_id||"",scene:i.scene||"playbook_select",message:"",options:(i.options||[]).map(l=>({id:l.id,playbook_code:l.playbook_code,title:l.title,description:l.description||"",selected:l.id===i.selected_option_id,params:l.params||[]})),params:i.params||[],actions:{confirm:{label:"确认执行",style:"primary"},reject:{label:"都不需要",style:"secondary"}}},s=i.proposal_status==="confirmed"?"confirmed":i.proposal_status==="rejected"?"rejected":void 0;return{...r,execution_id:n,proposal:a,proposal_status:s}}function Qf(e,t){return e.activeAgent===t.activeAgent&&e.webhookId===t.webhookId&&e.ssoToken===t.ssoToken&&e.ssoDomain===t.ssoDomain&&e.ssoCompany===t.ssoCompany}function K0t(e){const t=`${e.ssoDomain}\0${e.ssoCompany}\0${e.ssoToken}`;let r=2166136261;for(let n=0;n<t.length;n+=1)r^=t.charCodeAt(n),r=Math.imul(r,16777619);return(r>>>0).toString(36)}function X0t(e){const{activeAgent:t,pageSize:r=Ztn,webhookId:n,executePlaybook:i,isExecutingRef:a,ssoToken:s="",ssoDomain:o="",ssoCompany:l=""}=e,[u,d]=C.useState([]),[h,f]=C.useState(0),[p,g]=C.useState(1),[m,v]=C.useState(!1),y=C.useRef(t),x=C.useRef({activeAgent:t,webhookId:n||"",ssoToken:s,ssoDomain:o,ssoCompany:l});C.useEffect(()=>{y.current=t,x.current={activeAgent:t,webhookId:n||"",ssoToken:s,ssoDomain:o,ssoCompany:l},d([]),f(0),g(1),v(!1)},[t,n,s,o,l]);const b=C.useCallback(()=>{const $=new Date;return`${$.getFullYear()}-${String($.getMonth()+1).padStart(2,"0")}-${String($.getDate()).padStart(2,"0")}`},[]),w=C.useCallback($=>{const A=b(),N=`wandox_daily_report_${K0t({ssoToken:s,ssoDomain:o,ssoCompany:l})}_${A}`,R=localStorage.getItem(N);if(!R)return!1;try{return JSON.parse(R).includes($)}catch{return!1}},[b,s,o,l]),S=C.useCallback($=>{const A=b(),N=`wandox_daily_report_${K0t({ssoToken:s,ssoDomain:o,ssoCompany:l})}_${A}`,R=localStorage.getItem(N);let L=[];if(R)try{L=JSON.parse(R)}catch{L=[]}L.includes($)||(L.push($),localStorage.setItem(N,JSON.stringify(L)))},[b,s,o,l]),_=C.useCallback(async()=>{const $=t,A={activeAgent:t,webhookId:n||"",ssoToken:s,ssoDomain:o,ssoCompany:l};if(Qf(x.current,A)&&!(a!=null&&a.current)){d([]),v(!0);try{const{data:P}=await WZe({agent_id:t,page:1,page_size:r,webhook_id:n,include_process:!0});if(a!=null&&a.current||y.current!==$||!Qf(x.current,A))return;const N=(P==null?void 0:P.items)||[];d([...N].reverse().map(Y0t).filter(R=>!W0t(R))),g(1),f((P==null?void 0:P.total)||0)}catch{}finally{Qf(x.current,A)&&v(!1)}}},[t,r,n,a,s,o,l]),T=C.useCallback(async()=>{if(u.length>=h)return;const $={activeAgent:t,webhookId:n||"",ssoToken:s,ssoDomain:o,ssoCompany:l};if(!Qf(x.current,$))return;const A=p+1;v(!0);try{const{data:P}=await WZe({agent_id:t,page:A,page_size:r,webhook_id:n,include_process:!0});if(!Qf(x.current,$))return;const N=(P==null?void 0:P.items)||[];if(N.length>0){const R=[...N].reverse().map(Y0t).filter(L=>!W0t(L));d(L=>[...R,...L]),g(A),f((P==null?void 0:P.total)||0)}}catch(P){throw P}finally{Qf(x.current,$)&&v(!1)}},[t,r,n,u.length,h,p,s,o,l]),E=C.useCallback(async()=>{var P,N,R;if(!t||t==="default")return!1;const $=t,A={activeAgent:t,webhookId:n||"",ssoToken:s,ssoDomain:o,ssoCompany:l};if(!Qf(x.current,A))return!1;try{const L=await Bkr({agent_id:t});if(a!=null&&a.current||y.current!==$||!Qf(x.current,A))return!1;if(L!=null&&L.data){const D=L.data;if(D.outputs){let M=null;D.outputs.type==="card"&&((N=(P=D.outputs.content)==null?void 0:P.data)!=null&&N.content)?M=D.outputs.content.data.content:(R=D.outputs.content)!=null&&R.content?M=D.outputs.content.content:D.outputs.content?M=D.outputs.content:M=D.outputs;const O={id:D.playbook_id||"daily-report",role:"assistant",content:"",timestamp:new Date().toISOString(),ui_payload:M};return d(F=>{const B=F.filter(V=>V.id!=="daily-report");return[O,...B]}),!0}D.playbook_id&&D.playbook_name&&(i==null||i({message:D.playbook_name,playbook_id:D.playbook_id}))}return!1}catch{return!1}},[t,n,i,a,s,o,l]),I=C.useCallback(async()=>{const $={activeAgent:t,webhookId:n||"",ssoToken:s,ssoDomain:o,ssoCompany:l};if(Qf(x.current,$)&&t){if(v(!0),t==="default"){try{await _()}finally{Qf(x.current,$)&&v(!1)}return}try{if(w(t)){await _();return}await E()?Qf(x.current,$)&&S(t):await _()}catch{await _()}finally{Qf(x.current,$)&&v(!1)}}},[t,n,_,E,w,S,s,o,l]);return{messages:u,setMessages:d,messagesTotal:h,messagesPage:p,loading:m,setLoading:v,loadMessages:_,loadMoreMessages:T,loadDailyReport:E,loadMessagesAndDailyReport:I}}function hn(e){return e==null?"":String(e).trim()}function MQ(e,t){const r=hn(e),n=hn(t);return!!(r&&r===n)}function Mh(e,t){const r=hn(t);return r?MQ(e.agent_id,r)||MQ(e.agent_code,r):!1}function G9(e,t){return e.find(r=>Mh(r,t))}function qnn(e,t,r){const n=G9(e,r);return n?Mh(n,t):MQ(t,r)}function Kx(e){return hn(e==null?void 0:e.agent_id)||hn(e==null?void 0:e.agent_code)}function Z0t(e,t){return MQ(e.playbook_id,t)}function Q0t(e){const t=[],r=new Set,n=i=>{if(Array.isArray(i))for(const a of i){const s=hn(a==null?void 0:a.playbook_id);!s||r.has(s)||(r.add(s),t.push(a))}};if(n(e==null?void 0:e.playbooks),Array.isArray(e==null?void 0:e.playbook_groups))for(const i of e.playbook_groups)n(i.playbooks);return t}function Ynn({open:e,onClose:t,ssoToken:r,ssoDomain:n,ssoCompany:i,initialAgentId:a,initialPlaybookId:s,initialPlaybookParams:o,initialMessage:l,triggerOnce:u=!1,enableCustomerService:d=!1,onReady:h}){const[f,p]=C.useState(""),[g,m]=C.useState([]),[v,y]=C.useState([]),[x,b]=C.useState([]),[w,S]=C.useState(!1),[_,T]=C.useState(!1),[E,I]=C.useState(null),[$,A]=C.useState("1x"),[P,N]=C.useState(!1),[R,L]=C.useState(""),[D,M]=C.useState(""),[O,F]=C.useState(null),B=C.useRef(""),V=C.useMemo(()=>f&&g.find(xe=>Mh(xe,f))||null,[f,g]),z=C.useMemo(()=>y_e(V),[V]),H=C.useCallback(xe=>{I(()=>xe)},[]),{executing:W,executingRef:G,sendMessage:q,executePlaybook:Y,respondToProposal:K,abort:X}=__e({activeAgent:f,ssoToken:r,ssoDomain:n,ssoCompany:i,defaultParams:o,onMessagesUpdate:xe=>Q(xe),onRecommendationsUpdate:b}),{messages:Z,setMessages:Q,messagesTotal:J,loading:re,loadMessages:ee,loadMoreMessages:se}=X0t({activeAgent:f,isExecutingRef:G,ssoToken:r,ssoDomain:n,ssoCompany:i}),ue=C.useCallback(()=>{X(),Q([]),b([]),M(""),F(null)},[X,Q]),le=C.useMemo(()=>JSON.stringify({agentId:hn(a),playbookId:hn(s),playbookParams:o??null,message:l??null}),[a,s,o,l]),ne=C.useRef(""),oe=C.useCallback(()=>{X(),T(!1),t()},[X,t]),Se=C.useCallback(()=>{const xe=`https://ecsapi.ecgtool.com/login/sso-login?token=${encodeURIComponent(r)}&menuName=AI智能体`;window.open(xe,"_blank","noopener,noreferrer")},[r]);C.useEffect(()=>{e&&be()},[e]),C.useEffect(()=>{e||(X(),T(!1))},[e,X]),C.useEffect(()=>{e&&(ne.current&&ne.current!==le&&X(),ne.current=le)},[e,le,X]),C.useEffect(()=>{if(!e||!a||g.length===0)return;const xe=G9(g,a);if(!xe){const Ce=hn(a);B.current!==Ce&&($t.error("指定的智能体不存在,已切换到默认智能体"),B.current=Ce);const me=Kx(g[0]);me&&hn(f)!==me&&(ue(),p(me));return}if(B.current="",Mh(xe,f))return;const Re=Kx(xe);Re&&(ue(),p(Re))},[e,a,g,f,ue]),C.useEffect(()=>{f&&(L(""),pe())},[f]),C.useEffect(()=>{!e||!f||ee()},[e,f,ee]),C.useEffect(()=>{N(!1)},[e,a,s,o,l]),C.useEffect(()=>{!e||!f||s||l&&(P||(q(l),N(!0)))},[e,f,l,s,u,P,q]);const ie=C.useMemo(()=>!!o&&Object.keys(o).length>0,[o]);C.useEffect(()=>{var Re;if(!e||!f||!s||P||a&&!g.some(me=>Mh(me,f)&&Mh(me,a))||!R||R!==f)return;const xe=v.find(Ce=>Z0t(Ce,s));if(!xe){$t.error("指定的剧本不存在,已切换到智能体界面"),N(!0);return}if((((Re=xe.input_fields)==null?void 0:Re.length)??0)>0&&!ie){F(xe);const Ce=(xe.input_fields??[]).map(me=>`${me.label}: `).join(`
770
770
  `);M(`${xe.name},请提供以下参数:
771
771
  ${Ce}`)}else Y({message:l||xe.name||"",playbook_id:s,...o?{playbook_params:o}:{}});N(!0)},[e,f,R,v,a,g,s,o,ie,l,P,Y]),C.useEffect(()=>{h&&h({clearMessages:()=>Q([]),getMessages:()=>Z,abort:X,showInspectionResults:xe=>{}})},[h,Z,X,Q]);const be=async()=>{S(!0);try{const{data:xe}=await zq({page:1,page_size:99}),Re=xe||[];if(m(Re),!a){const Ce=Kx(Re[0]);Ce&&p(Ce)}}catch{}S(!1)},pe=async()=>{const xe=f;S(!0);try{const{data:Re}=await J0e({agent_id:xe});y(Q0t(Re))}catch{}finally{S(!1),L(xe)}};return e?k.jsxs(k.Fragment,{children:[k.jsx("div",{className:"wandox-floating-drawer-mask",onClick:oe,onKeyDown:xe=>xe.key==="Escape"&&oe(),role:"button",tabIndex:0,"aria-label":"关闭抽屉"}),k.jsxs("div",{className:`wandox-floating-drawer wandox-floating-drawer-${$}`,children:[k.jsxs("div",{className:"wandox-floating-drawer-header",children:[k.jsxs("div",{className:"wandox-floating-drawer-title-group",children:[k.jsx("div",{className:"wandox-floating-drawer-title",children:(V==null?void 0:V.name)||"AI 助手"}),d&&k.jsxs("button",{type:"button",className:"wandox-floating-drawer-service",onClick:Se,title:"联系客服","aria-label":"联系客服",children:[k.jsx(G_r,{}),k.jsx("span",{children:"人工客服"})]}),z&&k.jsx(Y4,{title:k.jsx("div",{style:{fontWeight:"bold"},children:k.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[k.jsx("span",{children:z.packageName}),k.jsx(dS,{count:"生效中",style:{backgroundColor:"#52c41a",fontSize:"10px",lineHeight:"18px",height:"18px",minWidth:"50px"}})]})}),content:k.jsxs("div",{style:{fontSize:"12px",lineHeight:"1.6",minWidth:"280px"},children:[k.jsxs("div",{style:{marginBottom:"8px"},children:[k.jsx("strong",{children:"套餐类型:"}),z.packageName]}),z.subtitle&&k.jsx("div",{style:{color:"#999",fontSize:"11px",marginTop:"-4px",marginBottom:"8px"},children:z.subtitle}),z.asinUsage&&k.jsxs("div",{style:{marginBottom:z.asinUsagePercent!=null?"4px":"8px"},children:[k.jsx("strong",{children:"ASIN 已用:"}),k.jsx("span",{style:{color:"#9444f5",fontWeight:"bold"},children:z.asinUsage})]}),z.asinUsagePercent!=null&&k.jsx("div",{style:{marginBottom:"8px"},children:k.jsx("div",{style:{height:"6px",borderRadius:"3px",background:"#f0eaff",overflow:"hidden"},children:k.jsx("div",{style:{height:"100%",width:`${z.asinUsagePercent}%`,borderRadius:"3px",background:"linear-gradient(90deg, #9444f5, #b47aff)",transition:"width 0.3s ease"}})})}),k.jsxs("div",{style:{marginBottom:"8px"},children:[k.jsx("strong",{children:z.remainingLabel}),k.jsx("span",{style:{color:"#52c41a",fontWeight:"bold"},children:z.remainingValue})]}),k.jsxs("div",{style:{marginBottom:"8px"},children:[k.jsx("strong",{children:"到期时间:"}),z.endTime]}),k.jsxs("div",{children:[k.jsx("strong",{children:"开通时间:"}),z.startTime]}),z.coverageItems.length>0&&k.jsxs("div",{style:{marginTop:"12px",paddingTop:"8px",borderTop:"1px solid #f0f0f0"},children:[k.jsx("div",{style:{fontSize:"11px",color:"#666",marginBottom:"4px"},children:k.jsxs("strong",{children:[z.coverageTitle,":"]})}),k.jsx("div",{style:{fontSize:"11px",color:"#666",lineHeight:"1.4"},children:z.coverageItems.map(xe=>k.jsxs("div",{children:["• ",xe]},xe))})]})]}),placement:"bottomLeft",trigger:"hover",children:k.jsx(dS,{count:z.badgeText,style:{backgroundColor:z.badgeColor,color:z.badgeTextColor,fontSize:"10px",lineHeight:"18px",height:"18px",minWidth:"60px",cursor:"pointer"}})})]}),k.jsxs("div",{className:"wandox-floating-drawer-actions",children:[k.jsxs("div",{className:"wandox-floating-drawer-size-group",children:[k.jsx("button",{type:"button",className:`wandox-floating-drawer-size-btn ${$==="1x"?"active":""}`,onClick:()=>A("1x"),title:"1倍大小",children:"1x"}),k.jsx("button",{type:"button",className:`wandox-floating-drawer-size-btn ${$==="2x"?"active":""}`,onClick:()=>A("2x"),title:"2倍大小",children:"2x"}),k.jsx("button",{type:"button",className:`wandox-floating-drawer-size-btn ${$==="fullscreen"?"active":""}`,onClick:()=>A("fullscreen"),title:"全屏",children:k.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"currentColor",children:[k.jsx("title",{children:"全屏"}),k.jsx("path",{d:"M1.5 1a.5.5 0 0 0-.5.5v4a.5.5 0 0 1-1 0v-4A1.5 1.5 0 0 1 1.5 0h4a.5.5 0 0 1 0 1h-4zM10 .5a.5.5 0 0 1 .5-.5h4A1.5 1.5 0 0 1 16 1.5v4a.5.5 0 0 1-1 0v-4a.5.5 0 0 0-.5-.5h-4a.5.5 0 0 1-.5-.5zM.5 10a.5.5 0 0 1 .5.5v4a.5.5 0 0 0 .5.5h4a.5.5 0 0 1 0 1h-4A1.5 1.5 0 0 1 0 14.5v-4a.5.5 0 0 1 .5-.5zm15 0a.5.5 0 0 1 .5.5v4a1.5 1.5 0 0 1-1.5 1.5h-4a.5.5 0 0 1 0-1h4a.5.5 0 0 0 .5-.5v-4a.5.5 0 0 1 .5-.5z"})]})})]}),k.jsx("button",{type:"button",className:"wandox-floating-drawer-close",onClick:oe,"aria-label":"关闭",children:k.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"currentColor",children:[k.jsx("title",{children:"关闭"}),k.jsx("path",{d:"M14 1.41L12.59 0L7 5.59L1.41 0L0 1.41L5.59 7L0 12.59L1.41 14L7 8.41L12.59 14L14 12.59L8.41 7L14 1.41Z"})]})})]})]}),k.jsxs("div",{className:"wandox-floating-drawer-body wandox-root",children:[k.jsx(d0t,{messages:Z,playbooks:v,messagesTotal:J,loadMoreMessages:se,loading:w||re,executing:W,activeAgent:Kx(V)||f,onExecutePlaybook:Y,onFillPlaybookParams:xe=>{var ye;const Re={playbook_id:xe.playbookId,name:xe.playbookName,input_fields:xe.inputFields};F(Re);const Ce=((ye=xe.inputFields)==null?void 0:ye.map(de=>`${de.label}: `).join(`