@wandox/sdk 0.1.24 → 0.1.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{arc-D59Tl-Uv.js → arc-0h4y7KuY.js} +1 -1
- package/dist/{arc-BtzDZLiE.cjs → arc-CwvutYs5.cjs} +1 -1
- package/dist/{architectureDiagram-3BPJPVTR-BBWBoejI.cjs → architectureDiagram-3BPJPVTR-COnNlZD_.cjs} +1 -1
- package/dist/{architectureDiagram-3BPJPVTR-p0txBfyb.js → architectureDiagram-3BPJPVTR-DN799MQi.js} +3 -3
- package/dist/{blockDiagram-GPEHLZMM-CKR5ux0j.cjs → blockDiagram-GPEHLZMM-CQLDpQMA.cjs} +1 -1
- package/dist/{blockDiagram-GPEHLZMM-DnH0-rb3.js → blockDiagram-GPEHLZMM-Col7-74r.js} +3 -3
- package/dist/{c4Diagram-AAUBKEIU-z_DdM-5l.cjs → c4Diagram-AAUBKEIU-8Z4W_5C6.cjs} +1 -1
- package/dist/{c4Diagram-AAUBKEIU-Dr72QAXS.js → c4Diagram-AAUBKEIU-DgixOFmD.js} +2 -2
- package/dist/{channel-CrmLOJTk.cjs → channel-B4k1DftY.cjs} +1 -1
- package/dist/{channel-Csgr__2Y.js → channel-kHPjzi0k.js} +1 -1
- package/dist/{chunk-2J33WTMH-DSlIMykq.cjs → chunk-2J33WTMH-CmADfzwS.cjs} +1 -1
- package/dist/{chunk-2J33WTMH-B8SBv6We.js → chunk-2J33WTMH-Dsgt3Rd5.js} +1 -1
- package/dist/{chunk-4BX2VUAB-Bm63cYAz.js → chunk-4BX2VUAB-DaAwWkRf.js} +1 -1
- package/dist/{chunk-4BX2VUAB-D41oWc1f.cjs → chunk-4BX2VUAB-ZTZr53nT.cjs} +1 -1
- package/dist/{chunk-55IACEB6-AvIdj1YW.cjs → chunk-55IACEB6-DPI3Wokd.cjs} +1 -1
- package/dist/{chunk-55IACEB6-ElYLtjCk.js → chunk-55IACEB6-qMHrGt60.js} +1 -1
- package/dist/{chunk-727SXJPM-B-ENi8fl.js → chunk-727SXJPM-BL-CDi_X.js} +5 -5
- package/dist/{chunk-727SXJPM-C7-5wJb9.cjs → chunk-727SXJPM-F9dsspZ6.cjs} +1 -1
- package/dist/{chunk-AQP2D5EJ-D-kNiJR0.js → chunk-AQP2D5EJ-BYmwTYmB.js} +3 -3
- package/dist/{chunk-AQP2D5EJ-B5f4tukH.cjs → chunk-AQP2D5EJ-R_PnHjHM.cjs} +1 -1
- package/dist/{chunk-FMBD7UC4-BeyBcakk.cjs → chunk-FMBD7UC4-5T-Vcw3W.cjs} +1 -1
- package/dist/{chunk-FMBD7UC4-C_7WCNks.js → chunk-FMBD7UC4-Sm_AkLW9.js} +1 -1
- package/dist/{chunk-ND2GUHAM-CpBYWS2C.cjs → chunk-ND2GUHAM-CP-wlVzK.cjs} +1 -1
- package/dist/{chunk-ND2GUHAM-CI13jBiX.js → chunk-ND2GUHAM-mnE5F1pW.js} +1 -1
- package/dist/{chunk-QZHKN3VN-Bkbmkx3H.cjs → chunk-QZHKN3VN-D0ziKibo.cjs} +1 -1
- package/dist/{chunk-QZHKN3VN-oJ3TEpzJ.js → chunk-QZHKN3VN-j-aC-kZr.js} +1 -1
- package/dist/{classDiagram-4FO5ZUOK-C7aIcieL.js → classDiagram-4FO5ZUOK-k7t6Gr3D.js} +2 -2
- package/dist/{classDiagram-4FO5ZUOK-Dzv4LYsj.cjs → classDiagram-4FO5ZUOK-xJ4fGO32.cjs} +1 -1
- package/dist/{classDiagram-v2-Q7XG4LA2-eTwYQHTU.js → classDiagram-v2-Q7XG4LA2-B4xLR701.js} +2 -2
- package/dist/{classDiagram-v2-Q7XG4LA2-Dzv4LYsj.cjs → classDiagram-v2-Q7XG4LA2-xJ4fGO32.cjs} +1 -1
- package/dist/{cose-bilkent-S5V4N54A-C1Anrkp6.js → cose-bilkent-S5V4N54A-CjKn2T1H.js} +2 -2
- package/dist/{cose-bilkent-S5V4N54A-CLxSCX8h.cjs → cose-bilkent-S5V4N54A-DFs1fWfl.cjs} +1 -1
- package/dist/{dagre-BM42HDAG-DxhJ1vSo.cjs → dagre-BM42HDAG-C8Ck_Pfv.cjs} +1 -1
- package/dist/{dagre-BM42HDAG-B1DU5Kad.js → dagre-BM42HDAG-CzUFXwWK.js} +1 -1
- package/dist/{diagram-2AECGRRQ-D4lOsI9n.cjs → diagram-2AECGRRQ-BSYpFICH.cjs} +1 -1
- package/dist/{diagram-2AECGRRQ-Br7f-D8l.js → diagram-2AECGRRQ-DrlOq2kv.js} +2 -2
- package/dist/{diagram-5GNKFQAL-Deer5V1g.js → diagram-5GNKFQAL-CnY3oBJS.js} +3 -3
- package/dist/{diagram-5GNKFQAL-Dohg6nOW.cjs → diagram-5GNKFQAL-D5ndgf0K.cjs} +1 -1
- package/dist/{diagram-KO2AKTUF-Bo-nZWN2.cjs → diagram-KO2AKTUF-1jUn-5Z0.cjs} +1 -1
- package/dist/{diagram-KO2AKTUF-DDtQjpzf.js → diagram-KO2AKTUF-vaOKC_pY.js} +2 -2
- package/dist/{diagram-LMA3HP47-D_A8nxkb.js → diagram-LMA3HP47-CgEKSnJt.js} +2 -2
- package/dist/{diagram-LMA3HP47-B9OkbewX.cjs → diagram-LMA3HP47-CmreP635.cjs} +1 -1
- package/dist/{diagram-OG6HWLK6-DpXfaG1K.cjs → diagram-OG6HWLK6-BXZD0X4o.cjs} +1 -1
- package/dist/{diagram-OG6HWLK6-Dwosn1GM.js → diagram-OG6HWLK6-DEUd1QAG.js} +3 -3
- package/dist/{erDiagram-TEJ5UH35-D0HUwryT.cjs → erDiagram-TEJ5UH35-0ibK3tg0.cjs} +1 -1
- package/dist/{erDiagram-TEJ5UH35-WA5llhAH.js → erDiagram-TEJ5UH35-DNf_I8fF.js} +4 -4
- package/dist/{flowDiagram-I6XJVG4X-94u0gEwb.js → flowDiagram-I6XJVG4X-CoJf81gq.js} +6 -6
- package/dist/{flowDiagram-I6XJVG4X-C-h-ZoOe.cjs → flowDiagram-I6XJVG4X-DuZsDzsx.cjs} +1 -1
- package/dist/{ganttDiagram-6RSMTGT7-d1Uy8_vn.js → ganttDiagram-6RSMTGT7-BFdjCNd2.js} +3 -3
- package/dist/{ganttDiagram-6RSMTGT7-DWXi25p_.cjs → ganttDiagram-6RSMTGT7-D1K9Z774.cjs} +1 -1
- package/dist/{gitGraphDiagram-PVQCEYII-BlXUUOig.js → gitGraphDiagram-PVQCEYII-BJNzzW_q.js} +3 -3
- package/dist/{gitGraphDiagram-PVQCEYII-gA56rv_c.cjs → gitGraphDiagram-PVQCEYII-BxptxuC6.cjs} +1 -1
- package/dist/{index-U6s680UT.js → index-BJ9RqdJQ.js} +8 -8
- package/dist/{index-K-aACUJ_.cjs → index-CX-KO4IP.cjs} +3 -3
- package/dist/{infoDiagram-5YYISTIA-DpCuKob6.js → infoDiagram-5YYISTIA-BopFAmKF.js} +1 -1
- package/dist/{infoDiagram-5YYISTIA-DnnWatvd.cjs → infoDiagram-5YYISTIA-scXkqh7u.cjs} +1 -1
- package/dist/{ishikawaDiagram-YF4QCWOH-F4-7gx9N.js → ishikawaDiagram-YF4QCWOH-CEqVd8H9.js} +1 -1
- package/dist/{ishikawaDiagram-YF4QCWOH-CuEkWqFK.cjs → ishikawaDiagram-YF4QCWOH-P6JvFuup.cjs} +1 -1
- package/dist/{journeyDiagram-JHISSGLW-CSzt7HoB.cjs → journeyDiagram-JHISSGLW-CjB-fsPJ.cjs} +1 -1
- package/dist/{journeyDiagram-JHISSGLW-DxmbAS1M.js → journeyDiagram-JHISSGLW-OsQEjaQ-.js} +4 -4
- package/dist/{kanban-definition-UN3LZRKU-DyfZw7Og.js → kanban-definition-UN3LZRKU-Bl4PdgYd.js} +2 -2
- package/dist/{kanban-definition-UN3LZRKU-CtV4z9aq.cjs → kanban-definition-UN3LZRKU-BsXut2Z4.cjs} +1 -1
- package/dist/{linear-Ck3kYah_.js → linear-DP00tMQj.js} +1 -1
- package/dist/{linear--MtaF27I.cjs → linear-oxDeeLJP.cjs} +1 -1
- package/dist/{mermaid.core-BqkZ5dsa.js → mermaid.core-BKDyw1Oq.js} +35 -35
- package/dist/{mermaid.core-vFe7_p3_.cjs → mermaid.core-qZdgGTsr.cjs} +3 -3
- package/dist/{mindmap-definition-RKZ34NQL-Cbb9zlpZ.cjs → mindmap-definition-RKZ34NQL-CbJTrw92.cjs} +1 -1
- package/dist/{mindmap-definition-RKZ34NQL-DaGHEuOp.js → mindmap-definition-RKZ34NQL-CmmVq06-.js} +3 -3
- package/dist/{pieDiagram-4H26LBE5-DwuEqZTD.js → pieDiagram-4H26LBE5-BlNBWljZ.js} +3 -3
- package/dist/{pieDiagram-4H26LBE5-COSQWSh1.cjs → pieDiagram-4H26LBE5-DEv1fnSt.cjs} +1 -1
- package/dist/{quadrantDiagram-W4KKPZXB-CxMD1Iwl.cjs → quadrantDiagram-W4KKPZXB-BiEge3Z_.cjs} +1 -1
- package/dist/{quadrantDiagram-W4KKPZXB-DRT1jVex.js → quadrantDiagram-W4KKPZXB-CCqtUBoZ.js} +2 -2
- package/dist/{requirementDiagram-4Y6WPE33-BA_qhqSA.cjs → requirementDiagram-4Y6WPE33-CIrLsdpL.cjs} +1 -1
- package/dist/{requirementDiagram-4Y6WPE33-DBqfK03K.js → requirementDiagram-4Y6WPE33-FLvpKT00.js} +3 -3
- package/dist/{sankeyDiagram-5OEKKPKP-C9aKlDBV.js → sankeyDiagram-5OEKKPKP-1Xs6vWfq.js} +1 -1
- package/dist/{sankeyDiagram-5OEKKPKP-Cudl-1T0.cjs → sankeyDiagram-5OEKKPKP-BwTdoHCC.cjs} +1 -1
- package/dist/{sequenceDiagram-3UESZ5HK-B5TKeSRE.js → sequenceDiagram-3UESZ5HK-CNbmuyiN.js} +3 -3
- package/dist/{sequenceDiagram-3UESZ5HK-DPk_LJ09.cjs → sequenceDiagram-3UESZ5HK-CUj-9ovQ.cjs} +1 -1
- package/dist/{stateDiagram-AJRCARHV-n04asezX.js → stateDiagram-AJRCARHV-BL9xPd8C.js} +2 -2
- package/dist/{stateDiagram-AJRCARHV-BiznFGJA.cjs → stateDiagram-AJRCARHV-qjHpp4Ls.cjs} +1 -1
- package/dist/{stateDiagram-v2-BHNVJYJU-Ck3-5kZk.cjs → stateDiagram-v2-BHNVJYJU-CesUb7uQ.cjs} +1 -1
- package/dist/{stateDiagram-v2-BHNVJYJU-BeYI9vlJ.js → stateDiagram-v2-BHNVJYJU-D8nRBXPu.js} +2 -2
- package/dist/{timeline-definition-PNZ67QCA-Ce8dHkth.js → timeline-definition-PNZ67QCA-3KkYsQBp.js} +2 -2
- package/dist/{timeline-definition-PNZ67QCA-Bf_TsTGx.cjs → timeline-definition-PNZ67QCA-OaxTE4qU.cjs} +1 -1
- package/dist/{vennDiagram-CIIHVFJN-BsVGddgE.cjs → vennDiagram-CIIHVFJN-BF5TI0bz.cjs} +1 -1
- package/dist/{vennDiagram-CIIHVFJN-BkQnMyZM.js → vennDiagram-CIIHVFJN-DPvbSwDz.js} +1 -1
- package/dist/wandox.cjs +1 -1
- package/dist/wandox.js +1 -1
- package/dist/wandox.umd.js +1 -1
- package/dist/{wardleyDiagram-YWT4CUSO-CpV_J1af.js → wardleyDiagram-YWT4CUSO-6ClMSIRz.js} +2 -2
- package/dist/{wardleyDiagram-YWT4CUSO-D2453j6C.cjs → wardleyDiagram-YWT4CUSO-B2ccymu8.cjs} +1 -1
- package/dist/{xychartDiagram-2RQKCTM6-CoKtXP48.cjs → xychartDiagram-2RQKCTM6-Da1s62KI.cjs} +1 -1
- package/dist/{xychartDiagram-2RQKCTM6-B1Ukre0L.js → xychartDiagram-2RQKCTM6-DflsMViu.js} +2 -2
- package/package.json +1 -1
package/dist/wandox.umd.js
CHANGED
|
@@ -766,7 +766,7 @@ $3`).replace(/(\*\*[^*\n]+:\*\*)-/g,`$1
|
|
|
766
766
|
`)){G(we+1+Ne),H(Je),j(!0);return}}j(!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(),j(!1);return}}if(Le.key==="Enter"&&!Le.shiftKey&&!n){if(!w.trim()&&$&&r&&P.length===0){Le.preventDefault(),D();return}(w.trim()||P.length>0)&&(Le.preventDefault(),Ze())}if(Le.key===" "&&!n&&!w.trim()&&$&&r&&P.length===0){Le.preventDefault(),D();return}},Oe=async Le=>{var Fe;const rt=String(Le.playbook_id||"").trim();if(!rt){j(!1),Promise.resolve().then(()=>GO).then(({message:Je})=>Je.error("剧本参数加载失败,请稍后重试"));return}if(J.current)return;const Ee=++re.current,Qe=Re.current,we=w,De=W,Ne=z;J.current=rt,Te.current=Qe,Q(rt),j(!1);try{const{data:Je}=await j3({playbook_id:rt});if(Ee!==re.current||Qe!==Re.current)return;if(!Je||typeof Je!="object"||Array.isArray(Je))throw new Error("剧本详情为空");const Ge=N0t(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),Ce=we.slice(De+1+Ne.length);if(g){S(`${Ke}${Ce}`),g(Ge);return}ne(Ge);const pt=Ge.input_fields.map(Ye=>`${Ye.label}: `).join(`
|
|
767
767
|
`),dt=`${Ke}${Ge.name},请提供以下参数:
|
|
768
768
|
${pt}${Ce}`,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!==Re.current)return;j(!0),Promise.resolve().then(()=>GO).then(({message:Ge})=>Ge.error("剧本参数加载失败,请稍后重试"))}finally{Ee===re.current&&Te.current===Qe&&(Te.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 ye();for(const Qe of P)URL.revokeObjectURL(Qe.previewUrl);N([])}const rt=w.trim(),Ee=oe==null?void 0:oe.playbook_id;S(""),ne(null),he.clear(),A(!0),s(rt,Ee,Le.length>0?Le:void 0)};return E.jsxs("div",{className:"wandox-chat-input",style:{position:"relative"},onDragEnter:te,onDragLeave:fe,onDragOver:se,onDrop:de,children:[R&&E.jsx("div",{className:"wandox-chat-input-drag-overlay",children:E.jsxs("div",{className:"wandox-chat-input-drag-content",children:[E.jsx(LTr,{style:{fontSize:32,marginBottom:8}}),E.jsx("div",{children:"释放以发送图片"})]})}),E.jsx("input",{ref:M,type:"file",accept:"image/png,image/jpeg,image/jpg,image/gif,image/webp,image/bmp",multiple:!0,style:{display:"none"},onChange:Ae}),B&&q.length>0&&E.jsx("div",{className:"wandox-mention-list",ref:T,children:E.jsx("div",{className:"wandox-mention-items",children:q.map((Le,rt)=>E.jsxs("div",{className:`wandox-mention-item ${rt===K?"wandox-mention-item--active":""}`,onClick:()=>Oe(Le),onKeyDown:()=>{},onMouseEnter:()=>X(rt),children:[E.jsx("div",{className:"wandox-mention-item-icon",children:"📋"}),E.jsxs("div",{className:"wandox-mention-item-content",children:[E.jsxs("div",{className:"wandox-mention-item-name",children:[Le.name,Le.input_fields&&Le.input_fields.length>0&&E.jsx("span",{className:"wandox-mention-item-tag",children:t("recommendation.params")})]}),Le.description&&E.jsx("div",{className:"wandox-mention-item-desc",children:Le.description})]})]},Le.playbook_id))})}),B&&q.length===0&&le.length>0&&E.jsx("div",{className:"wandox-mention-list",ref:T,children:E.jsx("div",{className:"wandox-mention-empty",children:t("chatInput.noMatchingScenarios")})}),B&&le.length===0&&E.jsx("div",{className:"wandox-mention-list",ref:T,children:E.jsx("div",{className:"wandox-mention-empty",children:t("chatInput.noAvailableScenarios")})}),E.jsx(L0t,{open:k&&!B&&!n&&!ee,rewrittenQuestion:he.rewrittenQuestion,questions:he.questions,loading:he.loading,placement:"top",onSelectRewrite:Le=>{var rt;S(Le),he.clear(),(rt=_.current)==null||rt.focus()},onSelectQuestion:Le=>{S(""),ne(null),A(!0),he.clear(),s(Le.title)}}),ee&&E.jsx("output",{className:"wandox-chat-input-tag","aria-live":"polite",children:E.jsxs(as,{color:"blue",children:[E.jsx(yh,{spin:!0})," 正在读取剧本参数"]})}),oe&&E.jsx("div",{className:"wandox-chat-input-tag",children:E.jsx(as,{color:"blue",closable:!0,onClose:Be,closeIcon:E.jsx(so,{}),children:oe.name})}),$&&r&&!n&&!ee&&E.jsx("button",{className:"wandox-search-suggestion",onClick:D,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&&E.jsx("div",{className:"wandox-chat-input-previews",children:P.map(Le=>E.jsxs("div",{className:"wandox-chat-input-preview-item",children:[E.jsx("img",{src:Le.previewUrl,alt:Le.file.name,className:"wandox-chat-input-preview-img"}),E.jsx("button",{type:"button",className:"wandox-chat-input-preview-remove",onClick:()=>ce(Le.id),title:"删除",children:E.jsx(so,{})})]},Le.id))}),E.jsx(fnn,{ref:_,placeholder:$&&r&&!n?"":o||t("chat.input.placeholder"),value:w,disabled:n||ee,onChange:He,onKeyDown:Pe,onPaste:ie,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"}}),E.jsxs("div",{className:"wandox-chat-input-actions",children:[E.jsx("button",{type:"button",className:"wandox-chat-input-icon-btn",title:"上传图片",disabled:n||ee,onClick:Ie,children:E.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[E.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2",stroke:"currentColor",strokeWidth:"2"}),E.jsx("circle",{cx:"8.5",cy:"8.5",r:"1.5",fill:"currentColor"}),E.jsx("polyline",{points:"21 15 16 10 5 21",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]})}),E.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?E.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[E.jsx("circle",{cx:"12",cy:"12",r:"8",stroke:"currentColor",strokeWidth:"2"}),E.jsx("rect",{x:"9",y:"9",width:"6",height:"6",rx:"1",fill:"currentColor"})]}):E.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:E.jsx("path",{d:"M12 19V5M12 5L5 12M12 5L19 12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})]})]})}const L9=[{id:"robot",name:"机器人",description:"紫色渐变机器人头像",component:E.jsxs("svg",{viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[E.jsxs("g",{clipPath:"url(#clip0_2019_548)",children:[E.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)"}),E.jsx("path",{d:"M24 12L28 16L24 20L20 16L24 12Z",fill:"white",fillOpacity:"0.95"}),E.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"}),E.jsx("path",{d:"M16 28L12 24L16 20L20 24L16 28Z",fill:"white",fillOpacity:"0.8"}),E.jsx("path",{d:"M32 28L28 24L32 20L36 24L32 28Z",fill:"white",fillOpacity:"0.8"}),E.jsx("path",{d:"M24 36L20 32L24 28L28 32L24 36Z",fill:"white",fillOpacity:"0.8"})]}),E.jsxs("defs",{children:[E.jsxs("linearGradient",{id:"paint0_linear_2019_548",x1:"0",y1:"0",x2:"48",y2:"48",gradientUnits:"userSpaceOnUse",children:[E.jsx("stop",{stopColor:"#8B5CF6"}),E.jsx("stop",{offset:"1",stopColor:"#6366F1"})]}),E.jsx("clipPath",{id:"clip0_2019_548",children:E.jsx("rect",{width:"48",height:"48",fill:"white"})})]})]},"icon-robot")},{id:"amazon",name:"亚马逊",description:"橙色渐变亚马逊图标",component:E.jsxs("svg",{viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[E.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)"}),E.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"}),E.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"}),E.jsx("defs",{children:E.jsxs("linearGradient",{id:"paint0_linear_2026_532",x1:"0",y1:"0",x2:"48",y2:"48",gradientUnits:"userSpaceOnUse",children:[E.jsx("stop",{stopColor:"#FF6B35"}),E.jsx("stop",{offset:"1",stopColor:"#F7931E"})]})})]},"icon-amazon")},{id:"star",name:"星星",description:"绿色渐变星星图标",component:E.jsxs("svg",{viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[E.jsxs("g",{clipPath:"url(#clip0_2019_574)",children:[E.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)"}),E.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"}),E.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"}),E.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"}),E.jsx("path",{d:"M16 22V26H20M32 22V26H28M24 26V22",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeOpacity:"0.8"}),E.jsx("path",{d:"M18 30L14 34M30 30L34 34M24 34V36",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeOpacity:"0.8"}),E.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"}),E.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"}),E.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"})]}),E.jsxs("defs",{children:[E.jsxs("linearGradient",{id:"paint0_linear_2019_574",x1:"0",y1:"0",x2:"48",y2:"48",gradientUnits:"userSpaceOnUse",children:[E.jsx("stop",{stopColor:"#10B981"}),E.jsx("stop",{offset:"1",stopColor:"#059669"})]}),E.jsx("clipPath",{id:"clip0_2019_574",children:E.jsx("rect",{width:"48",height:"48",fill:"white"})})]})]},"icon-star")},{id:"gear",name:"齿轮",description:"绿色渐变齿轮图标",component:E.jsxs("svg",{viewBox:"0 0 40 40",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[E.jsx("defs",{children:E.jsxs("linearGradient",{id:"grad4",x1:"0%",y1:"0%",x2:"100%",y2:"100%",children:[E.jsx("stop",{offset:"0%",stopColor:"#14B8A6"}),E.jsx("stop",{offset:"100%",stopColor:"#0891B2"})]})}),E.jsx("rect",{width:"40",height:"40",rx:"12",fill:"url(#grad4)"}),E.jsx("circle",{cx:"20",cy:"20",r:"5",stroke:"white",strokeWidth:"2.5",fill:"none",strokeOpacity:"0.95"}),E.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:E.jsxs("svg",{viewBox:"0 0 40 40",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[E.jsx("defs",{children:E.jsxs("linearGradient",{id:"grad5",x1:"0%",y1:"0%",x2:"100%",y2:"100%",children:[E.jsx("stop",{offset:"0%",stopColor:"#EC4899"}),E.jsx("stop",{offset:"100%",stopColor:"#A855F7"})]})}),E.jsx("rect",{width:"40",height:"40",rx:"12",fill:"url(#grad5)"}),E.jsx("path",{d:"M10 30L26 14L30 18L14 34L10 30Z",fill:"white",fillOpacity:"0.95"}),E.jsx("circle",{cx:"28",cy:"12",r:"2",fill:"white",fillOpacity:"0.8"}),E.jsx("circle",{cx:"32",cy:"18",r:"1.5",fill:"white",fillOpacity:"0.7"}),E.jsx("circle",{cx:"24",cy:"8",r:"1.5",fill:"white",fillOpacity:"0.7"})]},"icon-magic")},{id:"rocket",name:"火箭",description:"青色渐变火箭图标",component:E.jsxs("svg",{viewBox:"0 0 40 40",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[E.jsx("defs",{children:E.jsxs("linearGradient",{id:"grad6",x1:"0%",y1:"0%",x2:"100%",y2:"100%",children:[E.jsx("stop",{offset:"0%",stopColor:"#06B6D4"}),E.jsx("stop",{offset:"100%",stopColor:"#3B82F6"})]})}),E.jsx("rect",{width:"40",height:"40",rx:"12",fill:"url(#grad6)"}),E.jsx("path",{d:"M20 8C20 8 28 12 28 22L24 26L20 24L16 26L12 22C12 12 20 8 20 8Z",fill:"white",fillOpacity:"0.95"}),E.jsx("circle",{cx:"20",cy:"17",r:"2.5",fill:"url(#grad6)"}),E.jsx("path",{d:"M16 28L14 32L18 30L16 28Z",fill:"white",fillOpacity:"0.8"}),E.jsx("path",{d:"M24 28L26 32L22 30L24 28Z",fill:"white",fillOpacity:"0.8"})]},"icon-rocket")},{id:"music",name:"音乐",description:"粉紫渐变音乐图标",component:E.jsxs("svg",{viewBox:"0 0 40 40",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[E.jsx("defs",{children:E.jsxs("linearGradient",{id:"grad7",x1:"0%",y1:"0%",x2:"100%",y2:"100%",children:[E.jsx("stop",{offset:"0%",stopColor:"#EC4899"}),E.jsx("stop",{offset:"100%",stopColor:"#8B5CF6"})]})}),E.jsx("rect",{width:"40",height:"40",rx:"12",fill:"url(#grad7)"}),E.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:E.jsxs("svg",{viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[E.jsx("defs",{children:E.jsxs("linearGradient",{id:"grad8",x1:"0%",y1:"0%",x2:"100%",y2:"100%",children:[E.jsx("stop",{offset:"0%",stopColor:"#06B6D4"}),E.jsx("stop",{offset:"100%",stopColor:"#10B981"})]})}),E.jsx("rect",{width:"48",height:"48",rx:"12",fill:"url(#grad8)"}),E.jsx("circle",{cx:"24",cy:"24",r:"12",stroke:"white",strokeWidth:"2",fill:"none",strokeOpacity:"0.95"}),E.jsx("path",{d:"M24 12L30 18L24 24L18 18L24 12Z",fill:"white",fillOpacity:"0.8"}),E.jsx("path",{d:"M24 24L30 30L24 36L18 30L24 24Z",fill:"white",fillOpacity:"0.8"}),E.jsx("path",{d:"M12 24L18 30L24 24L18 18L12 24Z",fill:"white",fillOpacity:"0.7"}),E.jsx("path",{d:"M24 24L30 18L36 24L30 30L24 24Z",fill:"white",fillOpacity:"0.7"})]},"icon-sports")},{id:"games",name:"游戏",description:"红橙渐变游戏图标",component:E.jsxs("svg",{viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[E.jsx("defs",{children:E.jsxs("linearGradient",{id:"grad9",x1:"0%",y1:"0%",x2:"100%",y2:"100%",children:[E.jsx("stop",{offset:"0%",stopColor:"#EF4444"}),E.jsx("stop",{offset:"100%",stopColor:"#F97316"})]})}),E.jsx("rect",{width:"48",height:"48",rx:"12",fill:"url(#grad9)"}),E.jsx("rect",{x:"12",y:"16",width:"8",height:"8",rx:"2",fill:"white",fillOpacity:"0.95"}),E.jsx("rect",{x:"28",y:"16",width:"8",height:"8",rx:"2",fill:"white",fillOpacity:"0.95"}),E.jsx("rect",{x:"20",y:"24",width:"8",height:"8",rx:"2",fill:"white",fillOpacity:"0.8"}),E.jsx("rect",{x:"12",y:"32",width:"8",height:"4",rx:"1",fill:"white",fillOpacity:"0.7"}),E.jsx("rect",{x:"28",y:"32",width:"8",height:"4",rx:"1",fill:"white",fillOpacity:"0.7"})]},"icon-games")},{id:"expenses",name:"财务",description:"金黄渐变财务图标",component:E.jsxs("svg",{viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[E.jsx("defs",{children:E.jsxs("linearGradient",{id:"grad10",x1:"0%",y1:"0%",x2:"100%",y2:"100%",children:[E.jsx("stop",{offset:"0%",stopColor:"#F59E0B"}),E.jsx("stop",{offset:"100%",stopColor:"#EAB308"})]})}),E.jsx("rect",{width:"48",height:"48",rx:"12",fill:"url(#grad10)"}),E.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"}),E.jsx("rect",{x:"20",y:"34",width:"8",height:"2",rx:"1",fill:"white",fillOpacity:"0.8"}),E.jsx("circle",{cx:"21",cy:"20",r:"1.5",fill:"url(#grad10)"}),E.jsx("circle",{cx:"27",cy:"20",r:"1.5",fill:"url(#grad10)"})]},"icon-expenses")},{id:"sciences",name:"科学",description:"青蓝渐变科学图标",component:E.jsxs("svg",{viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[E.jsx("defs",{children:E.jsxs("linearGradient",{id:"grad11",x1:"0%",y1:"0%",x2:"100%",y2:"100%",children:[E.jsx("stop",{offset:"0%",stopColor:"#0EA5E9"}),E.jsx("stop",{offset:"100%",stopColor:"#3B82F6"})]})}),E.jsx("rect",{width:"48",height:"48",rx:"12",fill:"url(#grad11)"}),E.jsx("path",{d:"M12 36L20 28L28 36L36 28",stroke:"white",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",strokeOpacity:"0.95"}),E.jsx("circle",{cx:"24",cy:"16",r:"4",fill:"white",fillOpacity:"0.8"}),E.jsx("path",{d:"M24 20V28",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeOpacity:"0.7"}),E.jsx("circle",{cx:"16",cy:"32",r:"2",fill:"white",fillOpacity:"0.7"}),E.jsx("circle",{cx:"32",cy:"32",r:"2",fill:"white",fillOpacity:"0.7"})]},"icon-sciences")},{id:"magic-wand",name:"魔法",description:"紫粉渐变魔法图标",component:E.jsxs("svg",{viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[E.jsx("defs",{children:E.jsxs("linearGradient",{id:"grad12",x1:"0%",y1:"0%",x2:"100%",y2:"100%",children:[E.jsx("stop",{offset:"0%",stopColor:"#8B5CF6"}),E.jsx("stop",{offset:"100%",stopColor:"#EC4899"})]})}),E.jsx("rect",{width:"48",height:"48",rx:"12",fill:"url(#grad12)"}),E.jsx("path",{d:"M12 36L24 24L36 36L24 48L12 36Z",fill:"white",fillOpacity:"0.95"}),E.jsx("circle",{cx:"28",cy:"12",r:"2",fill:"white",fillOpacity:"0.8"}),E.jsx("circle",{cx:"36",cy:"20",r:"1.5",fill:"white",fillOpacity:"0.7"}),E.jsx("circle",{cx:"20",cy:"8",r:"1.5",fill:"white",fillOpacity:"0.7"}),E.jsx("circle",{cx:"32",cy:"4",r:"1",fill:"white",fillOpacity:"0.6"})]},"icon-magic-wand")},{id:"animals",name:"动物",description:"绿棕渐变动物图标",component:E.jsxs("svg",{viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[E.jsx("defs",{children:E.jsxs("linearGradient",{id:"grad13",x1:"0%",y1:"0%",x2:"100%",y2:"100%",children:[E.jsx("stop",{offset:"0%",stopColor:"#10B981"}),E.jsx("stop",{offset:"100%",stopColor:"#92400E"})]})}),E.jsx("rect",{width:"48",height:"48",rx:"12",fill:"url(#grad13)"}),E.jsx("ellipse",{cx:"24",cy:"28",rx:"10",ry:"8",fill:"white",fillOpacity:"0.95"}),E.jsx("circle",{cx:"20",cy:"26",r:"2",fill:"url(#grad13)"}),E.jsx("circle",{cx:"28",cy:"26",r:"2",fill:"url(#grad13)"}),E.jsx("path",{d:"M24 30C22 32 20 33 18 33",stroke:"white",strokeWidth:"1.5",strokeLinecap:"round",strokeOpacity:"0.8"}),E.jsx("circle",{cx:"18",cy:"18",r:"4",fill:"white",fillOpacity:"0.8"}),E.jsx("circle",{cx:"30",cy:"18",r:"4",fill:"white",fillOpacity:"0.8"})]},"icon-animals")},{id:"travel",name:"旅行",description:"天蓝渐变旅行图标",component:E.jsxs("svg",{viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[E.jsx("defs",{children:E.jsxs("linearGradient",{id:"grad14",x1:"0%",y1:"0%",x2:"100%",y2:"100%",children:[E.jsx("stop",{offset:"0%",stopColor:"#0EA5E9"}),E.jsx("stop",{offset:"100%",stopColor:"#06B6D4"})]})}),E.jsx("rect",{width:"48",height:"48",rx:"12",fill:"url(#grad14)"}),E.jsx("path",{d:"M8 32L16 16L32 16L40 32L32 40L16 40L8 32Z",fill:"white",fillOpacity:"0.95"}),E.jsx("circle",{cx:"24",cy:"24",r:"3",fill:"url(#grad14)"}),E.jsx("path",{d:"M24 28V32",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeOpacity:"0.8"}),E.jsx("rect",{x:"12",y:"36",width:"4",height:"2",rx:"1",fill:"white",fillOpacity:"0.7"}),E.jsx("rect",{x:"32",y:"36",width:"4",height:"2",rx:"1",fill:"white",fillOpacity:"0.7"})]},"icon-travel")},{id:"nature",name:"自然",description:"绿色渐变自然图标",component:E.jsxs("svg",{viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[E.jsx("defs",{children:E.jsxs("linearGradient",{id:"grad15",x1:"0%",y1:"0%",x2:"100%",y2:"100%",children:[E.jsx("stop",{offset:"0%",stopColor:"#22C55E"}),E.jsx("stop",{offset:"100%",stopColor:"#10B981"})]})}),E.jsx("rect",{width:"48",height:"48",rx:"12",fill:"url(#grad15)"}),E.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"}),E.jsx("path",{d:"M24 12V20",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeOpacity:"0.8"}),E.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:E.jsxs("svg",{viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[E.jsx("defs",{children:E.jsxs("linearGradient",{id:"grad16",x1:"0%",y1:"0%",x2:"100%",y2:"100%",children:[E.jsx("stop",{offset:"0%",stopColor:"#1E40AF"}),E.jsx("stop",{offset:"100%",stopColor:"#3B82F6"})]})}),E.jsx("rect",{width:"48",height:"48",rx:"12",fill:"url(#grad16)"}),E.jsx("path",{d:"M24 8L8 16V24C8 32 14 38 24 40C34 38 40 32 40 24V16L24 8Z",fill:"white",fillOpacity:"0.95"}),E.jsx("circle",{cx:"24",cy:"22",r:"4",fill:"url(#grad16)"}),E.jsx("path",{d:"M24 26V30",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeOpacity:"0.8"}),E.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:E.jsxs("svg",{viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[E.jsx("defs",{children:E.jsxs("linearGradient",{id:"grad17",x1:"0%",y1:"0%",x2:"100%",y2:"100%",children:[E.jsx("stop",{offset:"0%",stopColor:"#EF4444"}),E.jsx("stop",{offset:"100%",stopColor:"#DC2626"})]})}),E.jsx("rect",{width:"48",height:"48",rx:"12",fill:"url(#grad17)"}),E.jsx("rect",{x:"20",y:"12",width:"8",height:"24",rx:"4",fill:"white",fillOpacity:"0.95"}),E.jsx("rect",{x:"12",y:"20",width:"24",height:"8",rx:"4",fill:"white",fillOpacity:"0.95"}),E.jsx("circle",{cx:"24",cy:"24",r:"2",fill:"url(#grad17)"})]},"icon-health")},{id:"food",name:"美食",description:"橙色渐变美食图标",component:E.jsxs("svg",{viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[E.jsx("defs",{children:E.jsxs("linearGradient",{id:"grad18",x1:"0%",y1:"0%",x2:"100%",y2:"100%",children:[E.jsx("stop",{offset:"0%",stopColor:"#FB923C"}),E.jsx("stop",{offset:"100%",stopColor:"#F97316"})]})}),E.jsx("rect",{width:"48",height:"48",rx:"12",fill:"url(#grad18)"}),E.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"}),E.jsx("circle",{cx:"20",cy:"20",r:"1.5",fill:"url(#grad18)"}),E.jsx("circle",{cx:"28",cy:"20",r:"1.5",fill:"url(#grad18)"}),E.jsx("path",{d:"M24 24C22 26 20 27 18 27",stroke:"white",strokeWidth:"1.5",strokeLinecap:"round",strokeOpacity:"0.8"}),E.jsx("path",{d:"M12 32L8 36L12 40",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",strokeOpacity:"0.7"})]},"icon-food")}],pnn="robot",D_=e=>{if(!e){const r=L9.find(n=>n.id===pnn);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},gnn=new Map(L9.map(e=>[e.id,e]));function mnn({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:E.jsx(CXe,{}),title:"对话"},...["maiduo","eccang"].includes(p)?[{key:"plan",icon:E.jsx(nTr,{}),title:"自动化Beta"}]:[],{key:"professional",icon:E.jsx(bXe,{}),title:"专业智能体"}],v=[...p==="yunduo"?[]:[{key:"toolbox",icon:E.jsx(eEr,{}),label:"工具箱"},{key:"goals",icon:E.jsx(E_r,{}),label:"目标追踪"}],{key:"settings",icon:E.jsx(Vme,{}),label:"通知配置"}];return E.jsx("div",{className:"wandox-aside-wrap",children:E.jsxs("div",{className:`wandox-aside ${r?"wandox-aside--collapsed":""} ${i||""}`,"aria-hidden":r,children:[E.jsxs("div",{className:"wandox-aside-header",children:[E.jsx("span",{className:"wandox-aside-header__title",children:"AI 智能体"}),n&&E.jsx("button",{type:"button",className:"wandox-aside-header-toggle",onClick:n,"aria-label":r?"展开侧边栏":"收起侧边栏",title:r?"展开侧边栏":"收起侧边栏",children:E.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",fill:"none",viewBox:"0 0 24 24",children:[E.jsx("title",{children:r?"展开侧边栏":"收起侧边栏"}),E.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"})]})})]}),E.jsx("div",{className:"wandox-aside-main-nav",children:E.jsx("div",{className:"wandox-aside-nav-list",children:g.map(y=>{const x=a===y.key,b=y.key==="professional";return E.jsxs("div",{children:[E.jsxs("div",{className:`wandox-aside-nav-item-wrap${x?" wandox-aside-nav-item-wrap--active":""}`,children:[E.jsxs("button",{type:"button",onClick:()=>s==null?void 0:s(y.key),className:`wandox-aside-nav-item${x?" wandox-aside-nav-item--active":""}`,children:[E.jsx("span",{className:"wandox-aside-nav-icon",children:y.icon}),E.jsx("span",{className:"wandox-aside-nav-title",children:y.title})]}),b&&!r&&h&&E.jsx(fi,{title:d?"收起列表":"展开列表",placement:"right",children:E.jsx("button",{type:"button",className:`wandox-aside-mode-toggle${d?" wandox-aside-mode-toggle--active":""}`,onClick:w=>{w.stopPropagation(),h()},children:d?E.jsx(lme,{style:{fontSize:11}}):E.jsx(S3,{style:{fontSize:11}})})})]}),b&&(d||r)&&E.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 E.jsx(fi,{title:w.name,placement:"right",children:E.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:[E.jsx("span",{className:"wandox-aside-agent-icon",children:D_(w.icon)}),E.jsx("span",{className:"wandox-aside-agent-name",children:w.name})]})},S)})})]},y.key)})})}),E.jsxs("div",{className:"wandox-aside-bottom",children:[E.jsx("p",{className:"wandox-aside-group-label",children:"系统功能"}),E.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 E.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:[E.jsx("span",{className:"wandox-aside-nav-icon",children:y.icon}),E.jsx("span",{className:"wandox-aside-nav-title",children:y.label})]},y.key)}),l&&E.jsxs("button",{type:"button",onClick:u,className:"wandox-aside-nav-item wandox-aside-nav-item--logout",children:[E.jsx("span",{className:"wandox-aside-nav-icon",children:E.jsx(BTr,{})}),E.jsx("span",{className:"wandox-aside-nav-title",children:"退出登录"})]})]}),E.jsx("div",{style:{height:8}})]})]})})}function P0t({title:e="正在进入指定智能体",description:t="正在加载智能体与剧本信息..."}){return E.jsxs("output",{className:"wandox-initial-route-loading","aria-label":e,children:[E.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})=>E.jsx("span",{className:"wandox-chat-history-ray",style:{"--ray-angle":`${r}deg`,"--ray-delay":`${n}s`}},r)),E.jsx("div",{className:"wandox-chat-empty-icon",children:E.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:[E.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"}),E.jsx("path",{d:"M20 2v4"}),E.jsx("path",{d:"M22 4h-4"}),E.jsx("circle",{cx:"4",cy:"20",r:"2"})]})})]}),E.jsx("div",{className:"wandox-initial-route-loading-title",children:e}),E.jsx("div",{className:"wandox-initial-route-loading-text",children:t})]})}function vnn(e){const{children:t}=e;return E.jsx("div",{className:"wandox-layout wandox-root",children:E.jsx("main",{className:"wandox-layout-content",style:{padding:0},children:t})})}const ynn="wandox_use_map_tree_goals_v2",bnn=/^\?+$/;function xnn(e){return`${ynn}:${e||"all"}`}function M0t(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:D0t(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:D0t(n.icon),goals:i,goal_count:i.length}}).filter(n=>(n.goals||[]).length>0):[]}function D0t(e){const t=String(e||"").trim();if(!(!t||bnn.test(t)))return t}function wnn({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=xnn(y);return(async()=>{l(!0),v("");try{const I=window.localStorage.getItem(T);if(I)try{const P=M0t(JSON.parse(I));P.length>0&&(f(P),g(P[0].role_code))}catch{window.localStorage.removeItem(T)}const $=await Y4r({agent_id:y,role_id:null});if(_)return;const A=M0t($.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),k=((A=_.playbook)==null?void 0:A.name)||_.title||_.name||"执行";if(!T)return;if(s(!1),i==null||i(!1),p_e(_).length>0&&r){r(_nn(_),k);return}t({message:k,playbook_id:T})},S=()=>{const _=!x;s(_),i==null||i(_)};return E.jsxs("div",{className:`wandox-use-map${x?" wandox-use-map--expanded":""}`,children:[E.jsx("div",{className:"wandox-use-map-toolbar",children:E.jsxs("button",{type:"button",className:"wandox-use-map-toggle",onClick:S,"aria-expanded":x,children:[E.jsx("span",{className:"wandox-scene-tab-mark wandox-scene-tab-mark--use-map","aria-hidden":"true",children:E.jsx(vXe,{})}),E.jsx("span",{className:"wandox-use-map-toggle-text",children:"使用地图"}),E.jsx("span",{className:"wandox-use-map-toggle-arrow","aria-hidden":"true",children:"⌄"})]})}),x&&E.jsx("div",{className:`wandox-use-map-panel${h.length===0?" wandox-use-map-panel--compact":""}`,children:(!u||o)&&h.length===0?E.jsxs("div",{className:"wandox-use-map-loading",children:[E.jsx("span",{className:"wandox-heartbeat-loader","aria-hidden":"true",children:E.jsx("svg",{width:"48",height:"24",viewBox:"0 0 48 24",fill:"none",children:E.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"})})}),E.jsx("span",{children:"正在加载使用地图"})]}):m?E.jsxs("div",{className:"wandox-use-map-empty",children:[E.jsx("div",{className:"wandox-use-map-empty-title",children:m}),E.jsx("button",{type:"button",className:"wandox-use-map-retry",onClick:()=>d(!1),children:"重新加载"})]}):h.length===0?E.jsxs("div",{className:"wandox-use-map-empty",children:[E.jsx("div",{className:"wandox-use-map-empty-title",children:"暂无使用地图"}),E.jsx("div",{className:"wandox-use-map-empty-desc",children:"当前智能体还没有配置岗位目标剧本"})]}):E.jsxs(E.Fragment,{children:[E.jsx("div",{className:"wandox-use-map-roles",role:"tablist","aria-label":"岗位",children:h.map(_=>{var T;return E.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:[E.jsx("span",{className:"wandox-use-map-role-icon",children:_.icon||"◎"}),E.jsx("span",{className:"wandox-use-map-role-name",children:_.name}),E.jsx("span",{className:"wandox-use-map-role-count",children:_.goal_count||((T=_.goals)==null?void 0:T.length)||0})]},_.id)})}),E.jsx("div",{className:"wandox-use-map-goals",children:((b==null?void 0:b.goals)||[]).map(_=>{var T;return E.jsxs("section",{className:"wandox-use-map-goal-group",children:[E.jsxs("div",{className:"wandox-use-map-goal-group-head",children:[E.jsx("span",{className:"wandox-use-map-goal-group-icon",children:_.icon||"◇"}),E.jsx("span",{className:"wandox-use-map-goal-group-name",children:_.name}),E.jsxs("span",{className:"wandox-use-map-goal-group-count",children:[((T=_.items)==null?void 0:T.length)||0," 个剧本"]}),(_.description||_.subtitle)&&E.jsxs("span",{className:"wandox-use-map-goal-group-desc",children:["· ",_.description||_.subtitle]})]}),E.jsx("div",{className:"wandox-use-map-goal-items",children:(_.items||[]).map(k=>{var A,P,N;const I=p_e(k).length>0,$=Snn(k.tags);return E.jsxs("button",{type:"button",className:`wandox-use-map-playbook-card${k.is_featured?" wandox-use-map-playbook-card--featured":""}`,onClick:()=>w(k),children:[E.jsx("div",{className:"wandox-use-map-playbook-title",children:E.jsx("span",{className:"wandox-use-map-playbook-name",children:k.title||k.name||((A=k.playbook)==null?void 0:A.name)||"未命名剧本"})}),(k.is_featured||I)&&E.jsxs("div",{className:"wandox-use-map-playbook-badges",children:[k.is_featured&&E.jsx(as,{color:"gold",className:"wandox-use-map-tag wandox-use-map-featured-tag",children:"精品"}),I&&E.jsx("span",{className:"wandox-use-map-param-badge",children:"参数"})]}),(k.subtitle||k.description||((P=k.playbook)==null?void 0:P.description))&&E.jsx("div",{className:"wandox-use-map-playbook-desc",children:k.subtitle||k.description||((N=k.playbook)==null?void 0:N.description)}),$.length>0&&E.jsx("div",{className:"wandox-use-map-playbook-tags",children:$.map((R,L)=>E.jsx(as,{color:R.variant==="soft"?void 0:R.color,className:"wandox-use-map-tag",style:Cnn(R),children:R.name},`${R.name}-${L}`))})]},`${_.id}-${k.id||k.playbook_id}`)})})]},_.id)})})]})})]})}function p_e(e){var t;return e.input_fields||((t=e.playbook)==null?void 0:t.input_fields)||[]}function Snn(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 Cnn(e){if(!(e.variant!=="soft"||!e.color))return{color:e.color,borderColor:O0t(e.color,.28),backgroundColor:O0t(e.color,.08)}}function O0t(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 _nn(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:p_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 Tnn({label:e}){return E.jsxs("output",{className:"wandox-scene-list-loading","aria-label":e,children:[E.jsx("span",{className:"wandox-heartbeat-loader","aria-hidden":"true",children:E.jsx("svg",{width:"48",height:"24",viewBox:"0 0 48 24",fill:"none",children:E.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"})})}),E.jsx("span",{children:e})]})}function B0t({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(""),[k,I]=C.useState(!1),[$,A]=C.useState([]),[P,N]=C.useState(!1),[R,L]=C.useState(""),M=C.useRef(!1),O=C.useRef(new Map),D=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 oe=await p4r({limit:8,agent_id:F});ee||A(oe.data||[])}catch{ee||A([])}finally{ee||N(!1)}})(),()=>{ee=!0}},[F,u]);const B=C.useRef(null),[j,z]=C.useState(5),H=C.useCallback(()=>{if(!B.current)return;const ee=B.current.offsetWidth;if(ee===0)return;const oe=Math.floor(ee/(200+12));z(Math.max(2,oe))},[]);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 ae of $.filter(ue=>!G.has(O_(ue))))ee.set(O_(ae),ae);for(const ae of e){const ue=O_(ae);ee.has(ue)||ee.set(ue,ae)}return Array.from(ee.values())},[e,$,G]),Y=d==="playbooks"?q:d==="recommendations"?i:a,K=d==="playbooks"?e:Y,X=Y.length>(j??5)&&K.length>0,Z=C.useMemo(()=>{const ee=new Map;ee.set("全部",K.length);for(const ae of K){const ue=ae.category_name||"未分类";ee.set(ue,(ee.get(ue)||0)+1)}return Array.from(ee.entries()).map(([ae,ue])=>({name:ae,count:ue}))},[K]),Q=C.useMemo(()=>{let ee=K;if(v!=="全部"&&(ee=ee.filter(ae=>(ae.category_name||"未分类")===v)),x.trim()){const ae=x.trim().toLowerCase();ee=ee.filter(ue=>{var oe;return ue.name.toLowerCase().includes(ae)||((oe=ue.description)==null?void 0:oe.toLowerCase().includes(ae))})}return ee},[K,v,x]),J=C.useCallback(ee=>{const ae=String(ee.playbook_id||"").trim();if(!ae)return Promise.reject(new Error("缺少 playbook_id"));const ue=O.current.get(ae);if(ue)return ue;const oe=j3({playbook_id:ae}).then(({data:ne})=>N0t(ee,ne)).finally(()=>{O.current.delete(ae)});return O.current.set(ae,oe),oe},[]),re=C.useCallback(async(ee,ae=!1)=>{var ue;if(!M.current){M.current=!0,L(ee.playbook_id);try{const oe=await J(ee);if(ae&&(m(!1),y("全部"),b("")),(ue=oe.input_fields)!=null&&ue.length&&n){n(oe,oe.name);return}r({message:oe.name,playbook_id:oe.playbook_id})}catch{$t.error("剧本参数加载失败,请稍后重试")}finally{M.current=!1,L("")}}},[J,r,n]);return E.jsxs("div",{className:"wandox-pro-scenes-panel",children:[E.jsxs("div",{className:"wandox-hub-section-header",children:[E.jsxs("div",{className:"wandox-scene-tabs",children:[E.jsxs("button",{type:"button",className:`wandox-scene-tab${!f&&d==="playbooks"?" active":""}`,onClick:()=>{h("playbooks"),p(!1)},children:[E.jsx("span",{className:"wandox-scene-tab-mark wandox-scene-tab-mark--playbooks","aria-hidden":"true",children:E.jsx(yXe,{})}),E.jsx("span",{children:"默认场景"})]}),i.length>0&&E.jsxs("button",{type:"button",className:`wandox-scene-tab${!f&&d==="recommendations"?" active":""}`,onClick:()=>{h("recommendations"),p(!1)},children:[E.jsx("span",{className:"wandox-scene-tab-mark wandox-scene-tab-mark--recommendations","aria-hidden":"true",children:E.jsx(bXe,{})}),E.jsx("span",{children:"推荐场景"})]}),E.jsxs("button",{type:"button",className:`wandox-scene-tab${!f&&d==="user"?" active":""}`,onClick:()=>{h("user"),p(!1)},children:[E.jsx("span",{className:"wandox-scene-tab-mark wandox-scene-tab-mark--user","aria-hidden":"true",children:E.jsx(aEr,{})}),E.jsx("span",{children:"我的场景"})]}),E.jsx(wnn,{agentId:F,onPlaybookClick:r,onSelectPlaybook:n,expanded:f,onExpandedChange:ee=>{p(ee),ee&&h("playbooks")}})]}),X&&!f&&E.jsxs("button",{type:"button",className:"wandox-scene-view-all",onClick:()=>m(!0),children:["查看全部 ",K.length," 个"]})]}),E.jsx("div",{className:"wandox-tab-content",children:!f&&E.jsx("div",{className:"wandox-hub-section",children:D?E.jsx(Tnn,{label:d==="user"?"正在加载我的场景":d==="recommendations"?"正在匹配推荐场景":"正在加载场景"}):Y.length>0?E.jsxs("div",{className:"wandox-scroll-row",ref:B,children:[Y.slice(0,j??5).map(ee=>{const ae=R===ee.playbook_id,ue=()=>void re(ee),oe=d==="playbooks"&&W.has(O_(ee)),ne=d==="user"?"用户":oe?"近期":ee.badge==="new"?"New":ee.badge==="recommend"?"推荐":ee.badge==="featured"?"精选":ee.category_name||ee.type||"推荐",le=ee.video_duration?`${Math.floor(ee.video_duration/60)}:${String(ee.video_duration%60).padStart(2,"0")}`:"",Se=async he=>{var xe;he.stopPropagation(),S(ee),I(!0);try{const ge=await ZZe({playbook_id:ee.playbook_id});T(((xe=ge.data)==null?void 0:xe.video_url)||ee.video_url||"")}catch{T(ee.video_url||"")}finally{I(!1)}},ve={daily:"每日",weekly:"每周",monthly:"每月"},Re=ee.is_subscribed?`🔔订阅${ee.execution_frequency&&ee.execution_frequency!=="none"?`·${ve[ee.execution_frequency]}自动跑`:""}`:"",Te=[ee.description,Re].filter(Boolean).join(" ");return E.jsxs("div",{className:"wandox-card",children:[E.jsxs("div",{className:"wandox-card-corner",children:[E.jsx("span",{className:"wandox-card-tag",children:ne}),ee.video_url&&E.jsxs("button",{type:"button",className:"wandox-card-video",onClick:Se,children:["▶ ",le?` ${le}`:"0:00"," 演示"]})]}),E.jsxs("button",{type:"button",className:"wandox-card-main",onClick:ue,disabled:ae,"aria-busy":ae,children:[E.jsx("div",{className:"wandox-card-title",children:ee.name}),E.jsx("div",{className:"wandox-card-desc",children:ae?"正在加载参数...":Te})]})]},O_(ee))}),X&&E.jsxs("button",{type:"button",className:"wandox-card wandox-card-more",onClick:()=>m(!0),children:[E.jsxs("div",{className:"wandox-card-more-title",children:["查看全部 ",K.length," 个"]}),E.jsx("div",{className:"wandox-card-more-desc",children:"按场景浏览"})]})]}):E.jsx("div",{className:"wandox-empty-slot",children:E.jsxs("div",{className:"wandox-empty",children:[E.jsx("div",{className:"wandox-empty-text",children:d==="playbooks"?"暂无默认场景":d==="recommendations"?"暂无推荐场景":"暂无我的场景"}),E.jsx("div",{className:"wandox-empty-desc",children:d==="playbooks"?"请联系管理员添加场景剧本":d==="recommendations"?"系统会根据情况推荐相关场景":"我创建的场景会显示在这里"})]})})})}),E.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:E.jsxs("div",{className:"wandox-playbook-browser",children:[E.jsxs("div",{className:"wandox-playbook-sidebar",children:[E.jsx("div",{className:"wandox-playbook-sidebar-title",children:"场景分类"}),E.jsx("div",{className:"wandox-playbook-categories",children:Z.map(ee=>E.jsxs("button",{type:"button",className:`wandox-playbook-category-item${v===ee.name?" active":""}`,onClick:()=>y(ee.name),children:[E.jsx("span",{className:"wandox-playbook-category-name",children:ee.name}),E.jsx("span",{className:"wandox-playbook-category-count",children:ee.count})]},ee.name))})]}),E.jsxs("div",{className:"wandox-playbook-main",children:[E.jsx("div",{className:"wandox-playbook-search",children:E.jsx(Fr,{placeholder:"搜索场景名称或描述...",prefix:E.jsx(uS,{style:{color:"#9ca3af"}}),value:x,onChange:ee=>b(ee.target.value),allowClear:!0})}),E.jsx("div",{className:"wandox-playbook-list",children:Q.length===0?E.jsx(is,{description:"暂无剧本",style:{marginTop:80}}):Q.map(ee=>{const ae=ee.input_fields&&ee.input_fields.length>0,ue=R===ee.playbook_id,oe=!!ee.video_url,ne=()=>void re(ee,!0),le=ee.video_duration?`${Math.floor(ee.video_duration/60)}:${String(ee.video_duration%60).padStart(2,"0")}`:"",Se=async()=>{var ve;S(ee),I(!0);try{const Re=await ZZe({playbook_id:ee.playbook_id});T(((ve=Re.data)==null?void 0:ve.video_url)||ee.video_url||"")}catch{$t.error("视频加载失败"),T(ee.video_url||"")}finally{I(!1)}};return E.jsx("div",{className:"wandox-playbook-list-item",children:E.jsxs("div",{className:"wandox-playbook-list-item-content",children:[E.jsx("div",{className:"wandox-playbook-list-item-icon",children:oe?E.jsx("button",{className:"wandox-playbook-video-icon",title:"包含演示视频",onClick:Se,type:"button",children:E.jsx(Yp,{})}):E.jsx("div",{className:"wandox-playbook-no-video-icon",children:E.jsx(tYe,{})})}),E.jsxs("div",{className:"wandox-playbook-list-item-body",children:[E.jsx("div",{className:"wandox-playbook-list-item-header",children:E.jsxs("div",{className:"wandox-playbook-list-item-title",children:[ee.name,ee.badge&&E.jsx("span",{className:`wandox-scene-badge wandox-scene-badge--${ee.badge}`,children:ee.badge==="new"?"New":ee.badge==="recommend"?"推荐":"精选"})]})}),ee.description&&E.jsx("div",{className:"wandox-playbook-list-item-desc",children:ee.description}),ee.last_execution_remark&&E.jsxs("div",{className:"wandox-playbook-list-item-remark",children:[E.jsx("span",{className:"wandox-playbook-list-item-remark-icon",children:"💡"}),E.jsxs("span",{children:["上次:",ee.last_execution_remark]})]})]}),E.jsxs("div",{className:"wandox-playbook-list-item-actions",children:[E.jsx("button",{type:"button",className:"wandox-playbook-list-item-btn",onClick:ne,disabled:ue,"aria-busy":ue,children:ue?"加载中":ae?"参数":"运行"}),oe&&E.jsxs("button",{type:"button",className:"wandox-playbook-demo-link",onClick:Se,children:["看演示",le?` ${le}`:""]})]})]})},ee.playbook_id)})})]})]})}),w&&E.jsx(_i,{open:!0,onCancel:()=>{S(null),T("")},footer:null,centered:!0,width:800,title:E.jsxs("span",{children:[E.jsx(Yp,{style:{marginRight:8,color:"#7c3aed"}}),w.name," · 演示视频",w.video_duration&&E.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&&E.jsxs("span",{style:{marginLeft:12,fontSize:13,color:"#9ca3af",fontWeight:"normal"},children:["👁 ",w.view_count," 次播放"]})]}),styles:{body:{padding:"12px 0 0"}},zIndex:10001,children:k?E.jsx("div",{style:{height:400,display:"flex",alignItems:"center",justifyContent:"center",background:"#000",borderRadius:8},children:E.jsx(oo.Node,{active:!0,style:{width:200,height:200}})}):E.jsx("video",{src:_,controls:!0,autoPlay:!0,style:{width:"100%",borderRadius:8,display:"block",maxHeight:"70vh",background:"#000"},children:E.jsx("track",{kind:"captions"})})})]})}const F0t=[{name:"country",label:"国家/地区"},{name:"state",label:"州/省"},{name:"province",label:"省"},{name:"city",label:"城市"},{name:"postal_code",label:"邮政编码"},{name:"address_line1",label:"地址"}],Enn=Object.fromEntries(F0t.map(e=>[e.name,e.label]));function P9(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function N5(e){return typeof e=="string"?e.trim():String(e??"").trim()}function knn(e,t){return!P9(e)||!Array.isArray(e[t])?[]:e[t].map(String).filter(Boolean)}function Ann(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 RQ(e){const t=String(e.type||"").toLowerCase(),r=String(e.widget||"").toLowerCase();return t==="address"||r==="address"}function Inn(){return[...F0t]}function z0t(e,t){if(!P9(e))return"请输入有效地址";const r=knn(t,"required_fields"),n=r.length>0?r:["country","city","postal_code","address_line1"];for(const l of n)if(!N5(e[l]))return`请填写${Enn[l]||`地址字段 ${l}`}`;if(r.length===0&&!N5(e.state)&&!N5(e.province))return"请填写州/省";const i=N5(e.country).toUpperCase(),a=N5(e.postal_code),s=Ann(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 N5(e.address_line1).length>o?`地址行不能超过 ${o} 个字符`:""}var j0t={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)}}})})(j0t);var $nn=j0t.exports;const Rnn=Ds($nn);Yr.extend(xfe),Yr.extend(Rnn),Yr.extend(IWe);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":g_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 L5(e){const t=M9(e.type);return e.range??(t==="daterange"||t==="datetimerange"||t==="timerange")}function g_e(e){const t=M9(e.type);return e.show_time??(t==="datetime"||t==="datetimerange")}function P5(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 m_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=L5(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=g_e(e),f=P5(l,e.picker),p=h?"日期时间":"日期",g={...d,picker:f,showTime:h?{format:B_(l)}:!1};return u?E.jsx(Es.RangePicker,{...g,value:O9(t,l,f),placeholder:[`请选择开始${p}`,`请选择结束${p}`],onChange:(m,v)=>s(v)}):E.jsx(Es,{...g,value:F_(t,l,f),placeholder:e.placeholder||`请选择${p}`,onChange:(m,v)=>s(v)})}return o==="time"?u?E.jsx(tc.RangePicker,{...d,value:O9(t,l),placeholder:["请选择开始时间","请选择结束时间"],onChange:(h,f)=>s(f)}):E.jsx(tc,{...d,value:F_(t,l),placeholder:e.placeholder||"请选择时间",onChange:(h,f)=>s(f)}):null}function V0t(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 H0t(e){return(e==null?void 0:e.includes("image"))??!1}function NQ(e){const t=(e.ui_component||e.widget||e.type||"string").toLowerCase();return M9(t)||t}function W0t(e){return NQ(e)==="segmented"||e.type.toLowerCase()==="segmented"}function G0t(e){var t;return(t=e.options)!=null&&t.length?e.options:(e.enum||[]).map(r=>({value:r,label:r}))}function Lnn(e){return e==null?"":typeof e=="string"||typeof e=="number"||typeof e=="bigint"?e:String(e)}function Pnn(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 v_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 M5(e,t={}){const r={};for(const n of e){const i=t[n.name];i!==void 0&&i!==""?r[n.name]=B9(n.type)?v_e(i):i:n.default!==void 0&&n.default!==""?r[n.name]=B9(n.type)?v_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 Mnn(e){return Array.isArray(e)?e.filter(V0t):V0t(e)?"field"in e||"name"in e||"param"in e?[e]:Object.entries(e).map(([t,r])=>({field:t,equals:r})):[]}function Dnn(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=Mnn(r.visible_when);return n.length===0||n.every(i=>Dnn(i,t))})}function U0t(e,t){return e.reduce((r,n)=>(r[n.name]=t[n.name],r),{})}function Onn(e){return Array.isArray(e)?e.map(t=>String(t)):e?[String(e)]:[]}function y_e(e){return e!=null&&e!==""}function Bnn(e,t){const r=B9(e.type),n=v_e(t),i=y_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 b_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,k,I;const y=h??String(Lnn(t)),x=NQ(e),b={...e,type:x},w=$=>l(e.name,$),S=()=>{var B,j;const $=o(e),A=e.options_from_skill?$.options:G0t(e),P=!!(e.options_from_skill||(B=e.enum)!=null&&B.length||(j=e.options)!=null&&j.length),N=$.waitingForDependencies?"请先选择关联参数":$.placeholder||e.placeholder||"请选择",{isMulti:R,selectValue:L,isEmptySelect:M,hasCurrentSelection:O}=Bnn(e,t),D=m!==void 0,F=()=>{v==null||v(e.name),g&&(m==null||m(e.name,""))};return E.jsx(wn,{allowClear:!r,showSearch:!r,size:n,autoClearSearchValue:!D,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||!D?void 0:g,placeholder:M?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?E.jsx(Yi,{size:"small"}):$.error||null,onInputKeyDown:z=>{["Backspace","Delete","Escape"].includes(z.key)&&(v==null||v(e.name))},onSearch:D?z=>m(e.name,z):void 0,onChange:z=>{w(z);const H=Array.isArray(z)?z.length>0:y_e(z);(O||H)&&F()},onClear:F,onBlur:F})};if(W0t(e)){const $=G0t(e);return $.length===0?S():E.jsx(bU,{className:"wandox-agent-input-field-control__segmented",options:$,value:y_e(t)?String(t):void 0,disabled:r,onChange:w})}if(RQ(e)){const $=t&&typeof t=="object"&&!Array.isArray(t)?t:{},A=(P,N)=>{r||w({...$,[P]:N})};return E.jsxs("div",{className:"wandox-agent-input-field-control__address",children:[Inn().map(({name:P,label:N})=>E.jsx(Fr,{size:n,value:String($[P]??""),readOnly:r,placeholder:N,onChange:R=>A(P,R.target.value)},P)),E.jsx(Fr,{size:n,value:String($.address_line2??""),readOnly:r,placeholder:"地址补充",onChange:P=>A("address_line2",P.target.value)})]})}if(D9(b))return E.jsx(m_e,{field:b,value:t,size:n,readOnly:r,disabled:r,onChange:w});switch(x){case"file":{const $=e.max_files??1,A=Onn(t),P=A.length<$,N=R=>{w($<=1?"":A.filter((L,M)=>M!==R))};if(a==="picture"&&H0t(e.file_type)){const R=A.map((L,M)=>({uid:String(M),name:s[L]||L.split("/").pop()||`image_${M+1}`,status:"done",url:L}));return E.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&&E.jsxs("div",{children:[i?E.jsx(Yi,{size:"small"}):E.jsx(xu,{}),E.jsx("div",{className:"wandox-agent-input-field-control__upload-text",children:"上传图片"})]})})}return E.jsxs("div",{className:"wandox-agent-input-field-control__files",children:[A.map((R,L)=>E.jsxs("div",{className:"wandox-agent-input-field-control__file",children:[E.jsx("span",{children:s[R]||R.split("/").pop()||R}),!r&&E.jsx(or,{type:"text",size:"small",danger:!0,"aria-label":"移除文件",icon:E.jsx(Mv,{}),onClick:()=>N(L)})]},R)),e.file_templates&&e.file_templates.length>0&&E.jsxs("div",{className:"wandox-agent-input-field-control__templates",children:[E.jsx("span",{children:"模板文件"}),e.file_templates.map((R,L)=>E.jsx(or,{size:"small",onClick:()=>d==null?void 0:d(R),children:R.name||"下载模板"},`${R.path}-${R.name||L}`))]}),P&&!r&&E.jsxs(qp.Dragger,{accept:e.file_type||void 0,showUploadList:!1,customRequest:u(e.name,$),disabled:i,children:[E.jsx("p",{className:"ant-upload-drag-icon",children:i?E.jsx(Yi,{size:"small"}):E.jsx(qO,{})}),E.jsx("p",{className:"ant-upload-text",children:i?"上传中...":"点击或拖拽文件上传"}),$>1&&E.jsxs("p",{className:"ant-upload-hint",children:["已上传 ",A.length,"/",$]})]})]})}case"boolean":return E.jsx(Dc,{size:n==="small"?"small":"default",checked:!!t,disabled:r,onChange:w});case"number":case"integer":case"float":return E.jsx(wu,{size:n,value:Pnn(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():E.jsx(Fr,{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(k=e.enum)!=null&&k.length||(I=e.options)!=null&&I.length||e.options_from_skill?S():E.jsx(Fr.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 q0t=/\$\{\s*\{?\s*params\.([a-zA-Z0-9_.-]+)\s*\}?\s*\}/g,Fnn=/^\$\{\s*\{?\s*params\.([a-zA-Z0-9_.-]+)\s*\}?\s*\}$/;function z_(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function x_e(e,t){return t.split(".").reduce((r,n)=>{if(z_(r))return r[n]},e)}function znn(e){return e==null||e===""}function jnn(e){const t=new Set,r=n=>{if(typeof n=="string"){for(const i of n.matchAll(q0t))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 Vnn(e,t){const r=e.split(".")[0],n=t.find(i=>i.name===e||i.name===r);return n?!!n.required:!0}function w_e(e,t){if(typeof e=="string"){const r=e.match(Fnn);return r!=null&&r[1]?x_e(t,r[1]):e.replace(q0t,(n,i)=>{const a=x_e(t,i);return a==null?"":String(a)})}return Array.isArray(e)?e.map(r=>w_e(r,t)):z_(e)?Object.fromEntries(Object.entries(e).map(([r,n])=>[r,w_e(n,t)])):e}function Hnn(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 Wnn(e){let t;return{options:Hnn(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 Gnn(e){return(e.enum||[]).map(t=>({value:t,label:t}))}function LQ(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=jnn(l.options_params).filter(m=>Vnn(m,e)&&znn(x_e(t,m))),h=w_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}}}),tQe({},{skill_id:l.options_from_skill,params:h}).then(m=>{if(s.current[l.name]!==g)return;const v=Wnn(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:Gnn(l),loading:!1,waitingForDependencies:!1}}}}function D5(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 Unn=["date","week","month","quarter","year"];function qnn(e){return typeof e=="string"&&Unn.includes(e)}function Y0t(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 Ynn(e){if(!Array.isArray(e))return;const t=e.map(r=>{if(!D5(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 Knn(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(!D5(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 S_e(e){const t=D5(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:qnn(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:Knn(t.options),placeholder:fg(t.placeholder),options_from_skill:fg(t.options_from_skill),options_params:D5(t.options_params)?t.options_params:void 0,file_type:fg(t.file_type),max_files:Y0t(t.max_files),description:fg(t.description),hint:fg(t.hint??t.label_hint??t.helper_text),file_templates:Ynn(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:Y0t(t.span??t.col_span??t.column_span),visible_when:t.visible_when??t.visibleWhen}}function C_e(e){return Array.isArray(e)?e.map(S_e).filter(t=>!!t.name):D5(e)?Object.entries(e).map(([t,r])=>D5(r)?S_e({...r,name:r.name??t}):S_e({name:t,label:t,type:"string",default:r})).filter(t=>!!t.name):[]}function Xnn(e){return e instanceof Error?e.message:"上传失败"}function Znn({open:e,playbook:t,onClose:r,onSubmit:n}){const i=C.useMemo(()=>C_e(t==null?void 0:t.input_fields),[t]),[a,s]=C.useState({}),[o,l]=C.useState({}),[u,d]=C.useState({}),h=LQ(i,a,s),f=C.useMemo(()=>z9(i,a),[i,a]);C.useEffect(()=>{e&&(s(M5(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,k=await WS(T),I=(S=k==null?void 0:k.data)==null?void 0:S.url,$=((_=k==null?void 0:k.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(k),$t.success("上传成功")}catch(T){const k=T instanceof Error?T:new Error(Xnn(T));w==null||w(k),$t.error(k.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 E.jsxs(h3,{className:"wandox-playbook-params-drawer",title:E.jsxs("div",{className:"wandox-playbook-params-drawer__title",children:[E.jsx("span",{className:"wandox-playbook-params-drawer__title-main",children:"填写执行参数"}),E.jsx("span",{className:"wandox-playbook-params-drawer__title-sub",children:t==null?void 0:t.name})]}),open:e,size:640,destroyOnHidden:!0,maskClosable:!1,onClose:r,footer:E.jsx("div",{className:"wandox-playbook-params-drawer__footer",children:E.jsxs(al,{children:[E.jsx(or,{onClick:r,children:"取消"}),E.jsx(or,{type:"primary",onClick:m,children:"开始执行"})]})}),children:[E.jsxs("div",{className:"wandox-playbook-params-drawer__intro",children:[E.jsx("span",{children:"填写本次运行需要的参数"}),E.jsxs("span",{children:[f.length," 项"]})]}),E.jsxs(Sn,{layout:"vertical",className:"wandox-playbook-params-drawer__form",children:[f.map(v=>E.jsx(Sn.Item,{required:v.required,label:E.jsxs("span",{className:"wandox-playbook-params-drawer__label",children:[v.label,v.description||v.hint?E.jsx(fi,{title:v.description||v.hint,children:E.jsx(f3,{"aria-label":`${v.label}说明`})}):null]}),children:E.jsx(b_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?E.jsxs("div",{className:"wandox-playbook-params-drawer__empty",children:[E.jsx(Yi,{size:"small"})," 正在读取参数配置"]}):null]})]})}function Qnn({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 h4r(u.playbook_id),r==null||r(u.playbook_id),l(!1),d(null)}catch{}finally{f(!1)}}},v=()=>{l(!1),d(null)};return E.jsxs("div",{className:"wandox-solidified-list",children:[E.jsx("div",{className:"wandox-solidified-list-search",children:E.jsx(Fr.Search,{placeholder:"搜索",value:a,onChange:y=>s(y.target.value),allowClear:!0,enterButton:!1})}),E.jsx("div",{className:"wandox-solidified-list-content",children:p.length===0?E.jsx(is,{description:i(a?"noData":"solidified.empty"),image:is.PRESENTED_IMAGE_SIMPLE}):E.jsx("div",{className:"wandox-solidified-list-grid",children:p.map(y=>E.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:[E.jsx("div",{className:"wandox-solidified-card-icon",children:E.jsxs("svg",{viewBox:"0 0 24 24",width:"24",height:"24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[E.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",stroke:"currentColor",strokeWidth:"2",fill:"none"}),E.jsx("path",{d:"M9 3v18M15 3v18M3 9h18M3 15h18",stroke:"currentColor",strokeWidth:"1.5"}),E.jsx("circle",{cx:"12",cy:"12",r:"2",fill:"currentColor"})]})}),E.jsxs("div",{className:"wandox-solidified-card-content",children:[E.jsx("div",{className:"wandox-solidified-card-name",children:y.name}),y.description&&E.jsx("div",{className:"wandox-solidified-card-desc",children:y.description})]}),E.jsx("button",{type:"button",className:"wandox-solidified-card-delete",onClick:x=>g(y,x),title:i("solidified.delete"),children:E.jsx("svg",{viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:E.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))})}),E.jsx(_i,{title:i("solidified.deleteConfirm"),open:o,onOk:m,onCancel:v,okText:i("confirm"),cancelText:i("cancel"),okButtonProps:{danger:!0,loading:h},children:E.jsxs("p",{children:[i("solidified.deleteConfirm")," 「",u==null?void 0:u.name,"」?"]})})]})}function Jnn({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 E.jsx(wu,{...d,style:{width:"100%"}});case"array":return E.jsx(Fr,{...d});case"boolean":return E.jsx(Fr,{...d});case"string":default:return E.jsx(Fr,{...d})}};return E.jsx("div",{className:"wandox-solidify-params-form",children:E.jsxs(Sn,{form:n,layout:"inline",onFinish:i,style:{marginBottom:16},children:[e.map(s=>E.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)),E.jsx(Sn.Item,{style:{marginBottom:8},children:E.jsx(or,{type:"primary",htmlType:"submit",loading:r,children:"查询"})})]})})}const O5={fontSize:13,fontWeight:600,color:"#374151",marginBottom:6};function ein({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({}),[k,I]=C.useState(!1),[$,A]=C.useState({}),[P,N]=C.useState({}),[R,L]=C.useState([]),[M,O]=C.useState([]),[D,F]=C.useState(!1),[B,j]=C.useState(!1),z=C.useCallback(async(K,X)=>{var Z;if(!K){S([]),T({});return}I(!0);try{const{data:Q}=await j3({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),ae=ee==null?void 0:ee.params;Array.isArray(ae)&&ae.length>0?re=ae:ae&&typeof ae=="object"&&(re=Object.values(ae))}catch{}if(S(re),re.length>0){const ee={};for(const ae of re){const ue=X==null?void 0:X[ae.name];ue!==void 0?ee[ae.name]=ue:ae.default!==void 0&&ae.default!==null&&(ee[ae.name]=ae.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([u4r({page:1,page_size:200}),ove({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}))),O(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,ae=await WS(ee),ue=(J=ae==null?void 0:ae.data)==null?void 0:J.url,oe=((re=ae==null?void 0:ae.data)==null?void 0:re.name)||ee.name||(ue==null?void 0:ue.split("/").pop())||"未知文件";if(!ue)throw new Error("上传失败");N(le=>({...le,[ue]:oe})),(K.max_files??1)<=1?W(K.name,ue):T(le=>{const Se=Array.isArray(le[K.name])?le[K.name]:le[K.name]?[le[K.name]]:[];return{...le,[K.name]:[...Se,ue]}}),Z==null||Z(ae),$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 E.jsx(m_e,{field:K,value:X,onChange:Z=>W(K.name,Z)});switch(K.type){case"string":return E.jsx(Fr.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 E.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 E.jsx(Dc,{size:"small",checked:!!X,onChange:Z=>W(K.name,Z)});case"array":case"object":return E.jsx(Fr.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((ae,ue)=>ue!==ee))};return E.jsxs("div",{children:[Q.length>0&&E.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6,marginBottom:8},children:Q.map((ee,ae)=>E.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,minHeight:30,padding:"4px 8px",border:"1px solid #e5e7eb",borderRadius:6,background:"#fff"},children:[E.jsx("span",{style:{flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontSize:12},children:P[ee]||ee.split("/").pop()||ee}),E.jsx(or,{type:"text",size:"small",danger:!0,onClick:()=>re(ae),children:"删除"})]},ee))}),J&&E.jsx(qp,{accept:K.file_type||void 0,showUploadList:!1,customRequest:G(K),disabled:!!$[K.name],children:E.jsx(or,{size:"small",icon:E.jsx(qO,{}),loading:!!$[K.name],children:$[K.name]?"上传中...":"点击上传"})})]})}default:return E.jsx(Fr,{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;j(!0);try{if(n){const X={name:s,webhook_id:x,cron_expression:d,schedule_type:"custom",is_active:l,playbook_params:K};await aQe(n.schedule_id,{},X),$t.success("更新成功")}else await nQe({},{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{j(!1)}};return E.jsxs(_i,{title:null,open:e,onOk:Y,onCancel:t,okText:"保存",cancelText:"取消",width:540,confirmLoading:B,closable:!1,children:[E.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:20},children:[E.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[E.jsx(No,{style:{fontSize:20,color:"#722ed1"}}),E.jsx("span",{style:{fontSize:16,fontWeight:600,color:"#111827"},children:a?"新增定时任务":"编辑定时任务"})]}),E.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[E.jsx("span",{style:{fontSize:13,color:l?"#111827":"#9ca3af"},children:l?"已启用":"已禁用"}),E.jsx(Dc,{checked:l,onChange:u})]})]}),E.jsxs("div",{style:{marginBottom:16},children:[E.jsxs("div",{style:O5,children:["任务名称 ",E.jsx("span",{style:{color:"#ef4444"},children:"*"})]}),E.jsx(Fr,{value:s,onChange:K=>o(K.target.value),placeholder:"请输入任务名称",style:{borderRadius:8}})]}),E.jsxs("div",{style:{marginBottom:16},children:[E.jsxs("div",{style:O5,children:["通知地址 ",E.jsx("span",{style:{color:"#ef4444"},children:"*"})]}),E.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&&E.jsxs(Yi,{spinning:D,children:[E.jsxs("div",{style:{marginBottom:16},children:[E.jsxs("div",{style:O5,children:["剧本 ",E.jsx("span",{style:{color:"#ef4444"},children:"*"})]}),E.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())}})]}),E.jsxs("div",{style:{marginBottom:16},children:[E.jsx("div",{style:O5,children:"智能体"}),E.jsx(wn,{style:{width:"100%"},value:v||void 0,onChange:K=>y(K),options:M,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())}})]})]}),E.jsxs("div",{style:{marginBottom:16},children:[E.jsx("div",{style:O5,children:"调度频率"}),E.jsx(u_e,{defaultValue:n==null?void 0:n.cron_expression,onChange:K=>h(K)},f)]}),k&&E.jsxs("div",{style:{textAlign:"center",padding:"12px 0"},children:[E.jsx(Yi,{size:"small"}),E.jsx("span",{style:{marginLeft:8,fontSize:12,color:"#9ca3af"},children:"加载参数配置..."})]}),!k&&w.length>0&&E.jsxs("div",{style:{marginBottom:16},children:[E.jsx("div",{style:O5,children:"执行参数"}),E.jsx("div",{style:{background:"#f9fafb",border:"1px solid #e5e7eb",borderRadius:8,padding:"12px 16px"},children:w.map(K=>E.jsxs("div",{style:{marginBottom:12},children:[E.jsxs("div",{style:{fontSize:12,fontWeight:500,color:"#374151",marginBottom:4},children:[K.label||K.name,K.required&&E.jsx("span",{style:{color:"#ef4444",marginLeft:2},children:"*"})]}),K.description&&E.jsx("div",{style:{fontSize:11,color:"#9ca3af",marginBottom:4},children:K.description}),q(K)]},K.name))})]})]})}const tin={daily:"每天",weekly:"每周",monthly:"每月",workday:"工作日",custom:"自定义"},rin={1:"周一",2:"周二",3:"周三",4:"周四",5:"周五",6:"周六",7:"周日",0:"周日"};function nin(e){const t=_Q(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=>rin[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 iin=({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),[w,S]=C.useState(1),[_,T]=C.useState(10);C.useEffect(()=>{I(),M()},[]),C.useEffect(()=>{const j=Math.max(1,Math.ceil(f.length/_));w>j&&S(j)},[w,_,f.length]);const k=[{label:"钉钉",value:"dingtalk"},{label:"飞书",value:"feishu"},{label:"企业微信",value:"wecom"}],I=async()=>{try{i(!0);const j=await jq({});j!=null&&j.data&&r(j.data)}catch(j){$t.error((j==null?void 0:j.message)||"加载失败")}finally{i(!1)}},$=()=>{l(null),u.resetFields(),h(void 0),s(!0)},A=async j=>{try{i(!0);const z=await b4r(j.webhook_id,{}),H=(z==null?void 0:z.data)||j;l(H),h(H.platform),u.setFieldsValue({...H,notify_time:H.notify_start_time&&H.notify_end_time?[Yr(H.notify_start_time,"HH:mm:ss"),Yr(H.notify_end_time,"HH:mm:ss")]:void 0}),s(!0)}catch(z){$t.error((z==null?void 0:z.message)||"获取详情失败")}finally{i(!1)}},P=async j=>{try{i(!0),await S4r(j.webhook_id,{}),$t.success("测试消息发送成功")}catch(z){$t.error((z==null?void 0:z.message)||"测试失败")}finally{i(!1)}},N=j=>{_i.confirm({title:"确认删除",content:`确定要删除 Webhook "${j.name}" 吗?`,okText:"确定",cancelText:"取消",onOk:async()=>{try{await w4r(j.webhook_id,{}),$t.success("删除成功"),I()}catch(z){$t.error((z==null?void 0:z.message)||"删除失败")}}})},R=async()=>{var j,z,H,W;try{const G=await u.validateFields();i(!0);const q={name:G.name,description:G.description,platform:G.platform,webhook_url:G.webhook_url,secret:G.secret,notify_start_time:(z=(j=G.notify_time)==null?void 0:j[0])==null?void 0:z.format("HH:mm:ss"),notify_end_time:(W=(H=G.notify_time)==null?void 0:H[1])==null?void 0:W.format("HH:mm:ss"),is_active:G.is_active,is_default:G.is_default};o?(await x4r(o.webhook_id,{},q),$t.success("更新成功")):(await rQe({},q),$t.success("创建成功")),s(!1),u.resetFields(),I()}catch(G){$t.error((G==null?void 0:G.message)||"操作失败")}finally{i(!1)}},L=[{title:"名称",dataIndex:"name",key:"name",width:150,render:(j,z)=>{const H={dingtalk:E.jsx(sTr,{style:{color:"#1677ff"}}),feishu:E.jsx(CXe,{style:{color:"#1677ff"}}),wecom:E.jsx(dEr,{style:{color:"#1677ff"}})};return E.jsxs(al,{size:4,children:[H[z.platform],E.jsx("span",{children:j})]})}},{title:"描述",dataIndex:"description",key:"description",ellipsis:!0},{title:"通知时段",key:"notify_time",width:150,render:(j,z)=>!z.notify_start_time||!z.notify_end_time?"全天":`${z.notify_start_time} ~ ${z.notify_end_time}`},{title:"状态",dataIndex:"is_active",key:"is_active",width:88,render:j=>E.jsx(as,{color:j?"success":"default",bordered:!1,children:j?"已启用":"已停用"})},{title:"默认渠道",dataIndex:"is_default",key:"is_default",width:96,render:j=>j?E.jsx(as,{color:"blue",bordered:!1,children:"默认"}):E.jsx("span",{className:"wandox-notification-muted",children:"—"})},{title:"操作",key:"action",width:210,render:(j,z)=>E.jsxs(al,{size:0,children:[E.jsx(or,{type:"link",size:"small",icon:E.jsx(HO,{}),onClick:()=>A(z),className:"wandox-webhook-action-btn",children:E.jsx("span",{className:"wandox-webhook-action-text",children:"编辑"})}),E.jsx(or,{type:"link",size:"small",icon:E.jsx(f0e,{}),onClick:()=>P(z),className:"wandox-webhook-action-btn",children:E.jsx("span",{className:"wandox-webhook-action-text",children:"测试"})}),E.jsx(or,{type:"link",size:"small",danger:!0,icon:E.jsx(Mv,{}),onClick:()=>N(z),className:"wandox-webhook-action-btn",children:E.jsx("span",{className:"wandox-webhook-action-text",children:"删除"})})]})}],M=async()=>{try{m(!0);const j=await iQe({});if(j!=null&&j.data){const z=Array.isArray(j.data)?j.data:j.data.items||[];p(z)}}catch{}finally{m(!1)}},O=j=>{if(j.cron_expression)return nin(j.cron_expression);const z=tin[j.schedule_type]||j.schedule_type,H=j.schedule_time||"--:--";return`${z} ${H}`},D=j=>{b(j),y(!0)},F=j=>{_i.confirm({title:"确认删除",content:`确定要删除定时任务「${j.name}」吗?`,okText:"确定",cancelText:"取消",onOk:async()=>{try{await sQe(j.schedule_id,{}),$t.success("删除成功"),M()}catch(z){$t.error((z==null?void 0:z.message)||"删除失败")}}})},B=[{title:"任务名称",dataIndex:"name",key:"name",width:150,render:j=>E.jsxs(al,{size:4,children:[E.jsx(No,{style:{color:"#722ed1"}}),E.jsx("span",{children:j})]})},{title:"调度规则",key:"schedule_desc",width:180,render:(j,z)=>E.jsx("span",{style:{fontFamily:"monospace",fontSize:12},children:O(z)})},{title:"通知渠道",dataIndex:"webhook_name",key:"agent_name",width:120,ellipsis:!0,render:j=>j||"-"},{title:"状态",dataIndex:"is_active",key:"is_active",width:70,render:j=>E.jsx(as,{color:j?"green":"default",children:j?"启用":"禁用"})},{title:"操作",key:"action",width:140,render:(j,z)=>E.jsxs(al,{size:0,children:[E.jsx(or,{type:"link",size:"small",icon:E.jsx(HO,{}),onClick:()=>D(z),className:"wandox-webhook-action-btn",children:E.jsx("span",{className:"wandox-webhook-action-text",children:"编辑"})}),E.jsx(or,{type:"link",size:"small",danger:!0,icon:E.jsx(Mv,{}),onClick:()=>F(z),className:"wandox-webhook-action-btn",children:E.jsx("span",{className:"wandox-webhook-action-text",children:"删除"})})]})}];return E.jsxs("div",{className:`wandox-webhook-management ${e||""}`,children:[E.jsxs("div",{className:"wandox-notification-overview",children:[E.jsxs("article",{className:"wandox-notification-stat",children:[E.jsx("span",{className:"wandox-notification-stat__icon wandox-notification-stat__icon--primary",children:E.jsx(Vme,{})}),E.jsxs("div",{children:[E.jsx("strong",{children:t.length}),E.jsx("span",{children:"通知渠道"})]})]}),E.jsxs("article",{className:"wandox-notification-stat",children:[E.jsx("span",{className:"wandox-notification-stat__icon wandox-notification-stat__icon--success",children:E.jsx(lq,{})}),E.jsxs("div",{children:[E.jsx("strong",{children:t.filter(j=>j.is_active).length}),E.jsx("span",{children:"已启用渠道"})]})]}),E.jsxs("article",{className:"wandox-notification-stat",children:[E.jsx("span",{className:"wandox-notification-stat__icon wandox-notification-stat__icon--purple",children:E.jsx(No,{})}),E.jsxs("div",{children:[E.jsx("strong",{children:f.filter(j=>j.is_active).length}),E.jsx("span",{children:"启用中的定时任务"})]})]})]}),E.jsxs("section",{className:"wandox-notification-section",children:[E.jsxs("header",{className:"wandox-notification-section__header",children:[E.jsxs("div",{className:"wandox-notification-section__heading",children:[E.jsx("span",{className:"wandox-notification-section__icon",children:E.jsx(Vme,{})}),E.jsxs("div",{children:[E.jsxs("div",{className:"wandox-notification-section__title-row",children:[E.jsx("h2",{children:"通知渠道"}),E.jsx("span",{children:t.length})]}),E.jsx("p",{children:"管理钉钉、飞书和企业微信的消息接收地址"})]})]}),E.jsx(or,{type:"primary",icon:E.jsx(xu,{}),onClick:$,children:"新增通知渠道"})]}),E.jsx("div",{className:"wandox-notification-section__body",children:E.jsx(Su,{size:"middle",columns:L,dataSource:t,rowKey:"webhook_id",loading:n,pagination:t.length>10?{pageSize:10,showSizeChanger:!0,showTotal:j=>`共 ${j} 条`}:!1,scroll:{x:820}})})]}),E.jsxs("section",{className:"wandox-notification-section",children:[E.jsx("header",{className:"wandox-notification-section__header",children:E.jsxs("div",{className:"wandox-notification-section__heading",children:[E.jsx("span",{className:"wandox-notification-section__icon wandox-notification-section__icon--purple",children:E.jsx(No,{})}),E.jsxs("div",{children:[E.jsxs("div",{className:"wandox-notification-section__title-row",children:[E.jsx("h2",{children:"定时任务"}),E.jsx("span",{children:f.length})]}),E.jsx("p",{children:"查看和维护通过通知渠道触发的周期任务"})]})]})}),E.jsx("div",{className:"wandox-notification-section__body",children:E.jsx(Su,{size:"middle",columns:B,dataSource:f,rowKey:"schedule_id",loading:g,pagination:f.length>10?{current:w,pageSize:_,total:f.length,showSizeChanger:!0,showTotal:j=>`共 ${j} 条`,onChange:(j,z)=>{T(z),S(z===_?j:1)}}:!1,scroll:{x:780}})})]}),E.jsx(_i,{title:o?"编辑 Webhook":"新增 Webhook",open:a,onOk:R,onCancel:()=>{s(!1),u.resetFields()},width:600,confirmLoading:n,okText:"确定",cancelText:"取消",children:E.jsxs(Sn,{form:u,layout:"horizontal",initialValues:{is_active:!0,is_default:!1},labelCol:{flex:"0 0 80px"},style:{paddingTop:16},children:[E.jsx(Sn.Item,{label:"名称",name:"name",rules:[{required:!0,message:"请输入名称"}],children:E.jsx(Fr,{placeholder:"请输入 Webhook 名称"})}),E.jsx(Sn.Item,{label:"描述",name:"description",children:E.jsx(Fr.TextArea,{rows:2,placeholder:"请输入描述(可选)"})}),E.jsx(Sn.Item,{label:"平台",name:"platform",rules:[{required:!0,message:"请选择平台"}],children:E.jsx(wn,{options:k,placeholder:"请选择平台",onChange:j=>h(j)})}),E.jsx(Sn.Item,{label:"URL",name:"webhook_url",rules:[{required:!0,message:"请输入 Webhook URL"},{type:"url",message:"请输入有效的 URL"}],children:E.jsx(Fr,{placeholder:"https://...",autoComplete:"off"})}),d!=="wecom"&&E.jsx(Sn.Item,{label:"签名密钥",name:"secret",rules:[{required:d==="dingtalk"||d==="feishu",message:"请输入签名密钥"}],children:E.jsx(Fr.Password,{placeholder:"请输入签名密钥",autoComplete:"new-password"})}),E.jsx(Sn.Item,{label:"通知时段",name:"notify_time",children:E.jsx(tc.RangePicker,{format:"HH:mm",placeholder:["开始时间","结束时间"],style:{width:"100%"}})}),E.jsx(Sn.Item,{label:"启用",name:"is_active",valuePropName:"checked",children:E.jsx(Dc,{})}),E.jsx(Sn.Item,{label:"设为默认",name:"is_default",valuePropName:"checked",children:E.jsx(Dc,{})})]})}),E.jsx(ein,{open:v,onClose:()=>{y(!1),b(null)},onSuccess:M,editingSchedule:x,webhooks:t})]})},{RangePicker:mpi}=Es;function ain({open:e,loading:t,playbooks:r,activePlaybookId:n,onClose:i,onPlaybookClick:a,onPlaybookDelete:s}){return E.jsx(h3,{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:E.jsx(Qnn,{playbooks:r,onPlaybookClick:a,onPlaybookDelete:s,activePlaybookId:n})})}const sin=["智能体对话","非 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 K0t(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 oin(e){return Array.from(e).slice(0,4).join("")}function B5(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 lin(e){return Array.isArray(e)?e.map(t=>qx(t)).filter(t=>!!t):[]}function cin(e){const t=qx(e);if(!(!t||!/^#[\da-f]{3}([\da-f]{3})?$/i.test(t)))return t}function uin(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 __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 X0t(e,t){if(!wy(e))return t;const r=String(e).trim();return["infinite","unlimited","∞"].includes(r.toLowerCase())?"∞ 无限":__e(e)||t}function din(e){const t=qx(e==null?void 0:e.package_name);if(!(!t||t==="无限算力年卡"))return t}function hin(e){const t=qx(Ph(e,["asin_usage","asin_usage_text","asin_used_display","usage_text"]));if(t)return t;const r=__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=__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 fin(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 T_e(e){var a,s,o;if(!e)return null;const t=K0t(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"]))||din(e.package_info)||"竞品智能体包年权益",subtitle:"竞品智能体专属权益",remainingLabel:"剩余算力(非ASIN查询):",remainingValue:X0t(Ph(t,["token_num","tokenNum","remaining_token","token_remaining","remaining_power","power_remaining"])??((a=e.package_info)==null?void 0:a.token_num),"∞ 无限"),asinUsage:hin(t),asinUsagePercent:fin(t),endTime:B5(Ph(t,["end_time","endTime","expire_time","expired_at","expires_at","end_date","package_end_time"]))||B5((s=e.package_info)==null?void 0:s.end_time)||"-",startTime:B5(Ph(t,["start_time","startTime","open_time","opened_at","started_at","start_date","package_start_time"]))||B5((o=e.package_info)==null?void 0:o.start_time)||"-",coverageTitle:"无限算力覆盖范围",coverageItems:sin};const r=K0t(e.package_info);if(!r)return null;const n=qx(Ph(r,["package_name","packageName"]))||"套餐权益",i=cin(Ph(r,["package_color","packageColor"]))||"#9444f5";return{kind:"free",badgeText:oin(n),badgeColor:i,badgeTextColor:uin(i),packageName:n,remainingLabel:"剩余算力:",remainingValue:X0t(r.token_num,"-"),endTime:B5(r.end_time)||"-",startTime:B5(r.start_time)||"-",coverageTitle:qx(r.detail_title)||"套餐权益",coverageItems:lin(r.detail_ul)}}const pin=[{label:"钉钉",value:"dingtalk"},{label:"飞书",value:"feishu"},{label:"企业微信",value:"wecom"}];function Z0t({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 rQe({},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 E.jsx(_i,{title:n("webhook.quickAdd"),open:e,onOk:u,onCancel:d,confirmLoading:a,width:480,destroyOnHidden:!0,zIndex:1e4,children:E.jsxs(Sn,{form:i,layout:"vertical",preserve:!1,children:[E.jsx(Sn.Item,{label:n("webhook.name"),name:"name",rules:[{required:!0,message:n("webhook.nameRequired")}],children:E.jsx(Fr,{placeholder:n("webhook.namePlaceholder")})}),E.jsx(Sn.Item,{label:n("webhook.platform"),name:"platform",rules:[{required:!0,message:n("webhook.platformRequired")}],children:E.jsx(wn,{options:pin,placeholder:n("webhook.platformPlaceholder"),onChange:h=>l(h)})}),E.jsx(Sn.Item,{label:"Webhook URL",name:"webhook_url",rules:[{required:!0,message:n("webhook.urlRequired")},{type:"url",message:n("webhook.urlInvalid")}],children:E.jsx(Fr,{placeholder:"https://...",autoComplete:"off"})}),o!=="wecom"&&E.jsx(Sn.Item,{label:n("webhook.secret"),name:"secret",rules:[{required:o==="dingtalk"||o==="feishu",message:n("webhook.secretRequired")}],children:E.jsx(Fr.Password,{placeholder:n("webhook.secretPlaceholder"),autoComplete:"new-password"})})]})})}const gin="https://ai.maiduox.com/#/aitools/operation/product";function min(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,k]=C.useState(!1),[I,$]=C.useState([]),[A,P]=C.useState(null),[N,R]=C.useState({}),[L,M]=C.useState([]),[O,D]=C.useState(!1),[F,B]=C.useState(null),[j,z]=C.useState(void 0),[H,W]=C.useState(!1),[G,q]=C.useState(!1),Y=C.useMemo(()=>(u||[]).map(pe=>pe.name),[u]),K=C.useMemo(()=>!o||o==="default"?null:(l==null?void 0:l.find(be=>be.agent_id===o||be.agent_code===o))||null,[o,l]),X=C.useMemo(()=>T_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 pe=Y.find(be=>be===d);pe?w(pe):Y.length>0}},[h,d,Y]);const Z=async()=>{try{const pe=await jq({});pe!=null&&pe.data&&M(pe.data.map(be=>({webhook_id:be.webhook_id,name:be.name,platform:be.platform})))}catch{}},Q=async()=>{try{const pe={};await Promise.all(u.map(async be=>{var ce;try{const ye=await _4r(be.agent_id,{});(ce=ye==null?void 0:ye.data)!=null&&ce.webhook_id&&(pe[be.agent_id]=ye.data.webhook_id)}catch{}})),R(pe)}catch{}},J=C.useMemo(()=>b?r.filter(pe=>{var ye;const be=(ye=pe.title)==null?void 0:ye.match(/^(.+?)\s*巡检结果$/);return(be?be[1]:pe.agent_name)===b}):r,[r,b]),re=C.useMemo(()=>{if(!b)return"";const pe=(u||[]).find(be=>be.name===b);return(pe==null?void 0:pe.agent_id)||""},[b,u]),ee=n==="maiduo"&&b==="差评监控",ae=pe=>{const be=b===pe?null:pe;w(be),be&&g(!0)},ue=pe=>{B(pe),z(N[pe.agent_id]),D(!0)},oe=C.useCallback(async pe=>{if(pe){k(!0);try{const be=await l4r({agent_id:pe,limit:50});if(be!=null&&be.data&&Array.isArray(be.data)){const ce=be.data.map((ye,te)=>({id:ye.id||ye.execute_id||`record_${te}`,action_name:ye.action_name||ye.display_name||"未知动作",action_id:ye.action_id||"",status:ye.status||"pending",created_at:ye.created_at||"",completed_at:ye.completed_at,action_params:ye.action_params,output_type:ye.output_type,output_data:ye.output_data,outputs:ye.outputs,error:ye.error})).sort((ye,te)=>new Date(te.created_at).getTime()-new Date(ye.created_at).getTime());$(ce)}else $([])}catch{$([])}finally{k(!1)}}},[]),ne=pe=>{if(!pe)return"";try{const be=new Date(pe),ce=be.toLocaleDateString("zh-CN",{year:"numeric",month:"2-digit",day:"2-digit"}),ye=be.toLocaleTimeString("zh-CN",{hour:"2-digit",minute:"2-digit"});return`${ce} ${ye}`}catch{return pe}},le=pe=>({pending:"等待中",running:"执行中",success:"成功",failed:"失败"})[pe]||pe,Se=pe=>({pending:"wandox-exec-status--pending",running:"wandox-exec-status--running",success:"wandox-exec-status--success",failed:"wandox-exec-status--failed"})[pe]||"";C.useEffect(()=>{S==="history"&&re&&oe(re)},[S,re,oe]);const ve=async()=>{if(!F||!j){$t.warning("请选择 Webhook");return}try{W(!0),await C4r({},{agent_id:F.agent_id,webhook_id:j}),$t.success("绑定成功"),D(!1),Q()}catch(pe){$t.error((pe==null?void 0:pe.message)||"绑定失败")}finally{W(!1)}},Re=async()=>{if(F)try{W(!0),await T4r(F.agent_id,{}),$t.success("解绑成功"),D(!1),z(void 0),Q()}catch(pe){$t.error((pe==null?void 0:pe.message)||"解绑失败")}finally{W(!1)}},Te=pe=>{x(pe),v(!0)},he=()=>{v(!1),x(null)},xe=pe=>{if(!pe)return"";try{const be=new Date(pe),ce=be.toLocaleDateString("zh-CN",{year:"numeric",month:"2-digit",day:"2-digit"}),ye=be.toLocaleTimeString("zh-CN",{hour:"2-digit",minute:"2-digit"});return`${ce}
|
|
769
|
-
${ye}`}catch{return pe}},ge=(pe,be)=>{const ce={high:"#ff4d4f",medium:"#faad14",low:"#52c41a"};return E.jsxs("div",{className:"wandox-timeline-item",children:[E.jsxs("div",{className:"wandox-timeline-dot-wrapper",children:[E.jsx("span",{className:"wandox-timeline-time",style:{whiteSpace:"pre-line"},children:xe(pe.timestamp||"")}),E.jsx("div",{className:"wandox-timeline-dot",style:{background:ce[pe.priority]}}),!be&&E.jsx("div",{className:"wandox-timeline-line"})]}),E.jsxs("div",{className:"wandox-widget-card",children:[E.jsx("div",{className:"wandox-widget-title",children:pe.title}),pe.ui_payload&&E.jsx("div",{className:"wandox-widget-content wandox-markdown-content",children:E.jsx(jo,{payload:pe.ui_payload})}),pe.actions&&pe.actions.length>0&&E.jsx("div",{className:"wandox-widget-actions",children:E.jsxs("button",{type:"button",className:"wandox-widget-view-detail-btn",onClick:()=>Te(pe),children:[E.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",role:"img",children:[E.jsx("title",{children:"快速执行"}),E.jsx("path",{d:"M13 2L3 14H12L11 22L21 10H12L13 2Z",fill:"currentColor"})]}),"快速执行 (",pe.actions.length,")"]})})]})]},pe.id||`${pe.type}_${pe.title}_${pe.timestamp}`)};return E.jsxs("div",{className:"wandox-widget-section",children:[E.jsxs("div",{className:"wandox-section-header",children:[E.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[f??E.jsx("span",{className:"wandox-widget-section-title",children:t}),X&&E.jsx(K4,{title:E.jsx("div",{style:{paddingBottom:"8px",borderBottom:"1px solid #f0f0f0"},children:E.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:"8px"},children:[E.jsxs("div",{children:[E.jsx("strong",{children:X.packageName}),X.subtitle&&E.jsx("div",{style:{color:"#999",fontSize:"11px",fontWeight:400},children:X.subtitle})]}),E.jsx(dS,{count:"生效中",style:{backgroundColor:"#52c41a",fontSize:"10px",lineHeight:"18px",height:"18px",minWidth:"50px"}})]})}),content:E.jsxs("div",{style:{fontSize:"12px",lineHeight:"1.6",minWidth:"280px"},children:[E.jsxs("div",{style:{marginBottom:"8px",display:"flex",justifyContent:"space-between"},children:[E.jsx("div",{style:{color:"#999"},children:"套餐类型:"}),E.jsx("strong",{children:X.packageName})]}),X.asinUsage&&E.jsxs("div",{style:{marginBottom:X.asinUsagePercent!=null?"4px":"8px",display:"flex",justifyContent:"space-between",gap:"16px"},children:[E.jsx("div",{style:{color:"#999"},children:"ASIN 已用:"}),E.jsx("strong",{style:{color:"#9444f5"},children:X.asinUsage})]}),X.asinUsagePercent!=null&&E.jsx("div",{style:{marginBottom:"8px"},children:E.jsx("div",{style:{height:"6px",borderRadius:"3px",background:"#f0eaff",overflow:"hidden"},children:E.jsx("div",{style:{height:"100%",width:`${X.asinUsagePercent}%`,borderRadius:"3px",background:"linear-gradient(90deg, #9444f5, #b47aff)",transition:"width 0.3s ease"}})})}),E.jsxs("div",{style:{marginBottom:"8px",display:"flex",justifyContent:"space-between"},children:[E.jsx("div",{style:{color:"#999"},children:X.remainingLabel}),E.jsx("strong",{style:{color:"#9444f5",fontWeight:"bold"},children:X.remainingValue})]}),E.jsxs("div",{style:{marginBottom:"8px",display:"flex",justifyContent:"space-between"},children:[E.jsx("div",{style:{color:"#999"},children:"到期时间:"}),E.jsx("strong",{children:X.endTime})]}),E.jsxs("div",{style:{marginBottom:"8px",display:"flex",justifyContent:"space-between"},children:[E.jsx("div",{style:{color:"#999"},children:"开通时间:"}),E.jsx("strong",{children:X.startTime})]}),X.coverageItems.length>0&&E.jsxs("div",{style:{padding:"8px 12px",background:"#faf8ff",borderRadius:"8px"},children:[E.jsx("div",{style:{marginBottom:"4px",color:"#9444f5",fontSize:"13px",fontWeight:"bold"},children:X.coverageTitle}),E.jsx("div",{style:{fontSize:"11px",color:"#666",lineHeight:"2"},children:X.coverageItems.map(pe=>E.jsxs("div",{children:[E.jsx($v,{style:{marginRight:"6px",color:"#9444f5"}}),pe]},pe))})]})]}),placement:"bottom",trigger:"hover",children:E.jsx(dS,{count:X.badgeText,style:{backgroundColor:X.badgeColor,color:X.badgeTextColor,cursor:"pointer"}})})]}),E.jsx("div",{className:"wandox-inspection-controls",children:E.jsxs("button",{type:"button",className:`wandox-inspection-agent-btn ${p?"wandox-inspection-agent-btn--expanded":""}`,onClick:()=>{p?(g(!1),w(null)):g(!0)},children:[E.jsxs("span",{className:"wandox-inspection-agent-icon",children:[E.jsxs("svg",{viewBox:"0 0 24 24",width:"14",height:"14",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[E.jsx("circle",{cx:"12",cy:"12",r:"4",stroke:"currentColor",strokeWidth:"1.5"}),E.jsx("circle",{cx:"12",cy:"12",r:"1.5",fill:"currentColor"})]}),E.jsx("span",{className:"wandox-orbit-dot wandox-orbit-dot-1"}),E.jsx("span",{className:"wandox-orbit-dot wandox-orbit-dot-2"}),E.jsx("span",{className:"wandox-orbit-dot wandox-orbit-dot-3"})]}),E.jsxs("span",{className:"wandox-inspection-agent-text",children:["巡检机器人(",Y.length,")"]})]})})]}),p&&E.jsxs("div",{className:"wandox-timeline-list",children:[E.jsxs("div",{className:"wandox-agent-filter-row wandox-agent-filter-row--with-close",children:[E.jsxs("div",{className:"wandox-agent-filter-chips",children:[u.length>0&&E.jsx("button",{type:"button",className:`wandox-agent-filter-chip ${b===null?"active":""}`,onClick:()=>w(null),children:"全部"}),u.map(pe=>{const be=!!N[pe.agent_id];return E.jsxs("div",{className:`wandox-agent-filter-chip-compound ${b===pe.name?"active":""}`,children:[E.jsx("button",{type:"button",className:"wandox-agent-filter-chip-name",onClick:()=>ae(pe.name),children:pe.name}),E.jsx("button",{type:"button",className:`wandox-agent-filter-chip-webhook ${be?"bound":""}`,onClick:()=>ue(pe),title:be?"已绑定 Webhook,点击修改":"绑定 Webhook 通知",children:be?E.jsxs(E.Fragment,{children:[E.jsx("span",{className:"wandox-webhook-dot","aria-hidden":"true"}),E.jsx("span",{className:"wandox-webhook-label",children:"已通知"})]}):E.jsxs(E.Fragment,{children:[E.jsx("span",{className:"wandox-webhook-plus","aria-hidden":"true",children:"+"}),E.jsx("span",{className:"wandox-webhook-label",children:"通知"})]})})]},pe.agent_id)})]}),E.jsx("button",{type:"button",className:"wandox-timeline-list-close",onClick:()=>{g(!1),w(null),_("results")},title:"关闭",children:"✕"})]}),ee&&E.jsxs("div",{className:"wandox-negative-review-notice",children:[E.jsx("span",{className:"wandox-negative-review-notice-icon","aria-hidden":"true",children:"ℹ️"}),E.jsxs("span",{children:["差评监控需要先设置需要监控的ASIN,请前往AI工具》",E.jsx("a",{href:gin,target:"_blank",rel:"noreferrer",className:"wandox-negative-review-notice-link",children:"新老诊断"}),"进行设置。每个asin每一次都需要0.01算力。"]})]}),E.jsx("div",{className:"wandox-timeline-tabs-header",children:E.jsxs("div",{className:"wandox-timeline-tabs-nav",children:[E.jsxs("button",{type:"button",className:`wandox-timeline-tab-btn ${S==="results"?"active":""}`,onClick:()=>_("results"),children:["巡检结果",J.length>0&&E.jsx("span",{className:"wandox-timeline-tab-badge",children:J.length})]}),E.jsx("button",{type:"button",className:`wandox-timeline-tab-btn ${S==="history"?"active":""}`,onClick:()=>_("history"),children:"执行记录"})]})}),S==="results"?E.jsx("div",{className:"wandox-timeline-list-content",children:J.length>0?J.sort((pe,be)=>{const ce=pe.timestamp?new Date(pe.timestamp).getTime():0;return(be.timestamp?new Date(be.timestamp).getTime():0)-ce}).map((pe,be,ce)=>ge(pe,be===ce.length-1)):E.jsxs("div",{className:"wandox-empty-state",children:[E.jsx("div",{className:"wandox-empty-icon",children:"�"}),E.jsx("div",{className:"wandox-empty-text",children:b?"没有符合筛选条件的数据":"暂无工作区数据"}),E.jsx("div",{className:"wandox-empty-desc",children:b?"请调整筛选条件":"工作区数据将在这里显示"})]})}):E.jsx("div",{className:"wandox-timeline-list-content wandox-history-panel",children:b?T?E.jsxs("div",{className:"wandox-loading-state",children:[E.jsx("span",{className:"wandox-spinner wandox-spinner--small"}),E.jsx("span",{children:"加载中..."})]}):I.length===0?E.jsx("div",{className:"wandox-empty-state",children:E.jsx("div",{className:"wandox-empty-text",children:"暂无执行记录"})}):E.jsx("div",{className:"wandox-exec-history-list",children:I.map(pe=>E.jsxs("div",{className:"wandox-exec-history-item",children:[E.jsxs("div",{className:"wandox-exec-history-header",onClick:()=>P(A===pe.id?null:pe.id),onKeyDown:be=>be.key==="Enter"&&P(A===pe.id?null:pe.id),role:"button",tabIndex:0,children:[E.jsxs("div",{className:"wandox-exec-history-info",children:[E.jsx("span",{className:"wandox-exec-history-name",children:pe.action_name}),E.jsx("span",{className:"wandox-exec-history-time",children:ne(pe.created_at)})]}),E.jsxs("div",{className:"wandox-exec-history-status-wrapper",children:[E.jsx("span",{className:`wandox-exec-status ${Se(pe.status)}`,children:le(pe.status)}),E.jsx("span",{className:"wandox-exec-history-arrow","aria-hidden":"true",children:A===pe.id?"▼":"▶"})]})]}),A===pe.id&&E.jsxs("div",{className:"wandox-exec-history-detail",children:[pe.action_params&&Object.keys(pe.action_params).length>0&&E.jsxs("div",{className:"wandox-exec-params",children:[E.jsx("div",{className:"wandox-exec-section-label",children:"执行参数"}),E.jsx("div",{className:"wandox-exec-params-list",children:Object.entries(pe.action_params).map(([be,ce])=>E.jsxs("div",{className:"wandox-exec-param-item",children:[E.jsxs("span",{className:"wandox-exec-param-key",children:[be,":"]}),E.jsx("span",{className:"wandox-exec-param-value",children:typeof ce=="object"?JSON.stringify(ce):String(ce)})]},be))})]}),pe.error?E.jsxs("div",{className:"wandox-exec-error",children:[E.jsx("span",{className:"wandox-exec-error-label",children:"错误信息:"}),E.jsx("span",{className:"wandox-exec-error-msg",children:pe.error})]}):pe.output_type&&pe.output_data?E.jsxs("div",{className:"wandox-exec-outputs",children:[E.jsx("div",{className:"wandox-exec-section-label",children:"执行结果"}),E.jsx(jo,{payload:{type:pe.output_type,...pe.output_data}})]}):pe.outputs?E.jsxs("div",{className:"wandox-exec-outputs",children:[E.jsx("div",{className:"wandox-exec-section-label",children:"执行结果"}),E.jsx(jo,{payload:pe.outputs})]}):E.jsx("div",{className:"wandox-exec-no-output",children:"暂无输出结果"})]})]},pe.id))}):E.jsxs("div",{className:"wandox-empty-state",children:[E.jsx("div",{className:"wandox-empty-icon",children:"🤖"}),E.jsx("div",{className:"wandox-empty-text",children:"请先选择机器人"}),E.jsx("div",{className:"wandox-empty-desc",children:"在上方选择一个机器人查看执行记录"})]})})]}),E.jsx(n0t,{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:he,onExecuteComplete:s}),E.jsx(_i,{title:E.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[E.jsxs("svg",{viewBox:"0 0 24 24",width:"20",height:"20",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:[E.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"}),E.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"}),E.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"}),E.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"})]}),E.jsx("span",{children:"配置 Webhook 通知"})]}),open:O,onCancel:()=>{D(!1),B(null),z(void 0)},width:520,footer:null,centered:!0,children:E.jsxs("div",{style:{padding:"8px 0"},children:[E.jsxs("div",{style:{marginBottom:"20px",padding:"12px 16px",background:"#f5f7fa",borderRadius:"8px",border:"1px solid #e8eaed"},children:[E.jsx("div",{style:{fontSize:"13px",color:"#666",marginBottom:"4px"},children:"智能体"}),E.jsx("div",{style:{fontSize:"15px",color:"#1a1a1a",fontWeight:500},children:F==null?void 0:F.name})]}),E.jsxs("div",{style:{marginBottom:"20px"},children:[E.jsx("div",{style:{marginBottom:"8px",fontSize:"14px",color:"#333",fontWeight:500},children:"选择 通知地址"}),E.jsx(wn,{style:{width:"100%"},size:"large",placeholder:"请选择 通知地址",value:j,onChange:z,options:L.map(pe=>({label:`${pe.name} (${pe.platform==="dingtalk"?"钉钉":pe.platform==="feishu"?"飞书":"企业微信"})`,value:pe.webhook_id})),disabled:H,popupRender:pe=>E.jsxs(E.Fragment,{children:[pe,E.jsx(xqe,{style:{margin:"8px 0"}}),E.jsx(al,{style:{padding:"0 8px 4px"},children:E.jsx(or,{type:"text",icon:E.jsx("span",{children:"+"}),onClick:()=>q(!0),children:"添加新的通知地址"})})]})}),L.length===0&&E.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:[E.jsx("span",{children:"⚠️"}),E.jsx("span",{children:'暂无可用的 通知地址,请先在"通知配置"中创建'})]})]}),E.jsxs("div",{style:{padding:"12px 16px",background:"#f0f9ff",borderRadius:"8px",border:"1px solid #bae7ff",marginBottom:"20px"},children:[E.jsx("div",{style:{fontSize:"13px",color:"#0958d9",fontWeight:500,marginBottom:"8px"},children:"💡 功能说明"}),E.jsxs("div",{style:{fontSize:"13px",color:"#096dd9",lineHeight:"1.8"},children:[E.jsx("div",{children:"• 绑定后,该智能体执行完成时会自动发送通知"}),E.jsx("div",{children:"• 通知内容包含执行结果和相关信息"}),E.jsx("div",{children:"• 可随时修改或解除绑定"})]})]}),E.jsxs("div",{style:{display:"flex",gap:"12px",justifyContent:"flex-end"},children:[N[(F==null?void 0:F.agent_id)||""]&&E.jsx("button",{type:"button",onClick:Re,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:pe=>{H||(pe.currentTarget.style.background="#fff1f0")},onMouseLeave:pe=>{pe.currentTarget.style.background="#fff"},children:"解除绑定"}),E.jsx("button",{type:"button",onClick:()=>{D(!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:pe=>{H||(pe.currentTarget.style.background="#fafafa")},onMouseLeave:pe=>{pe.currentTarget.style.background="#fff"},children:"取消"}),E.jsx("button",{type:"button",onClick:ve,disabled:H||!j,style:{padding:"8px 24px",border:"none",borderRadius:"6px",background:H||!j?"#d9d9d9":"#1890ff",color:"#fff",cursor:H||!j?"not-allowed":"pointer",fontSize:"14px",fontWeight:500,transition:"all 0.2s"},onMouseEnter:pe=>{!H&&j&&(pe.currentTarget.style.background="#40a9ff")},onMouseLeave:pe=>{!H&&j&&(pe.currentTarget.style.background="#1890ff")},children:H?"保存中...":"保存"})]})]})}),E.jsx(Z0t,{open:G,onClose:()=>q(!1),onSuccess:pe=>{M(be=>[...be,pe]),z(pe.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 Q0t(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 J0t=new Set(["completed","failed","stopped"]),vin=new Set(["thinking","recommend"]),PQ={running:0,completed:1,failed:2,stopped:3};function E_e(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function k_e(e){const t=typeof e=="number"?e:Number(e);return Number.isFinite(t)&&t>=0?t:void 0}function yin(e){const t=String(e||"").toLowerCase();return t==="running"||t==="failed"||t==="stopped"?t:"completed"}function evt(e,t){if(!E_e(e))return;const r=typeof e.type=="string"&&e.type.trim()?e.type.trim():void 0;if(!r)return;const n=k_e(e.sequence),i=E_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 F5(e){return e==null?"":String(e).trim()}function bin(e,t){const r=F5(e.data.task_id),n=F5(t.data.task_id);if(r&&n)return r===n;const i=F5(e.data.step_index),a=F5(t.data.step_index);if(i&&a)return i===a;const s=F5(e.data.step_name||e.data.title),o=F5(t.data.step_name||t.data.title);return!!(s&&o&&s===o)}function tvt(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"&&bin(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 A_e(e){if(!E_e(e))return;const t=tvt((Array.isArray(e.events)?e.events:[]).map((s,o)=>evt(s,o+1)).filter(s=>!!s).sort((s,o)=>s.sequence-o.sequence)),r=yin(e.status),n=e.duration_ms===null?null:k_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=k_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 MQ(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=A_e(e.process)??MQ(e.timestamp||new Date(r).toISOString());if(J0t.has(n.status))return e;const i=n.events.reduce((d,h)=>Math.max(d,h.sequence),0)+1,a=evt({...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=tvt(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=A_e(e.process);if(!n||J0t.has(n.status)&&PQ[n.status]>=PQ[t])return e;const i=n.events.filter(u=>!vin.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=PQ[n.status]>PQ[t]?n.status:t;return{...e,process:{...n,status:l,duration_ms:o,total:i.length,events:i}}}function I_e(e,t){return{...e,content:"",ui_payload:{type:"markdown",content:t,streaming:!0},stream_content_received:!0}}function $_e(e,t){var a;const r=Array.isArray(t.payload),n=r?e.ui_payload:t.payload,i={message_id:t.messageId||e.message_id,execution_id:t.executionId??e.execution_id,actions:(a=t.actions)!=null&&a.length?t.actions:void 0,execution_status:"completed",outputs:r?t.payload:e.outputs};return e.stream_content_received?{...e,...i,content:"",ui_payload:e.ui_payload?{...e.ui_payload,streaming:!1}:e.ui_payload}:{...e,...i,content:t.payload?"":t.content||"执行完成",ui_payload:n}}function xin(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)&&xin(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 win(e,t,r){return I_e(e,t)}function R_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 D=Date.now(),F={id:`msg_${D}`,role:"user",content:A.message||"",timestamp:new Date().toISOString(),...(z=A.attachments)!=null&&z.length?{attachments:A.attachments}:{}},B=`msg_${D+1}`,j={id:B,role:"assistant",content:"⏳ 正在思考...",timestamp:new Date().toISOString(),playbook_id:A.playbook_id,execution_status:"executing",process:MQ()};return{userMsg:F,assistantMsgId:B,assistantMsg:j}})(),L=A._hideUserMessage===!0;s(D=>L?[...D,R]:[...D,P,R]),u(!0),x.current={assistantMsgId:N};const M=new AbortController;y.current=M;const O=()=>{var D;return y.current===M&&((D=x.current)==null?void 0:D.assistantMsgId)===N};try{const D={...A,agent_id:t,stream:!0,playbook_params:{...A.playbook_params||{}},message:A.message||"",...a||{}},{_hideUserMessage:F,...B}=D,j=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:M.signal});if(!j.ok)throw new Error(`HTTP ${j.status}`);await R9(j,{assistantMsgId:N,onMessageId:z=>{if(!O())return;const H=x.current;H&&(H.anchorMessageId=z)},onQueue:z=>{O()&&(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=>{O()&&(p(null),s(H=>H.map(W=>W.id===N?{...W,content:`⏳ ${z}`}:W)))},onProcessEvent:z=>{O()&&s(H=>H.map(W=>W.id===N?V9(W,z):W))},onContent:z=>{O()&&s(H=>H.map(W=>W.id===N?I_e(W,z):W))},onComplete:(z,H,W,G,q)=>{O()&&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($_e(K,{content:z,payload:H,actions:W,messageId:G,executionId:q}),"completed")}))},onError:(z,H)=>{O()&&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=>{O()&&o(z)},onProposal:z=>{if(!O())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(D){(D==null?void 0:D.name)!=="AbortError"&&O()&&s(F=>F.map(B=>B.id===N?W9({...B,content:`❌ 执行出错: ${D.message||"未知错误"}`,execution_status:"failed"},"failed",D.message||"未知错误"):B))}finally{if(y.current===M&&(y.current=null,x.current=null,g.current=!1,u(!1),h(!1),m.current)){const D=m.current;m.current=null,setTimeout(()=>{var F;return(F=v.current)==null?void 0:F.call(v,D)},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 M;return y.current===A&&((M=x.current)==null?void 0:M.assistantMsgId)===N};if(!R){$t.warning("任务编号尚未就绪,请稍后再试");return}if(L()){h(!0),s(M=>M.map(O=>O.id===N?{...O,execution_status:"stopping",content:"正在停止..."}:O));try{const M=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(!M.ok)throw new Error(`HTTP ${M.status}`);const O=await M.json().catch(()=>null);if(!L())return;if(O&&O.success===!1)throw new Error(O.message||"停止失败");if(s(D=>D.map(F=>{var B;return F.id===N?W9({...F,message_id:(O==null?void 0:O.stopped_message_id)||((B=O==null?void 0:O.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(M){if(!L())return;h(!1),s(O=>O.map(D=>D.id===N?{...D,execution_status:"executing"}:D)),$t.error(`停止失败:${M instanceof Error?M.message:"未知错误"}`)}}},[_,s,i,n,r]),k=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 M;return y.current===R&&((M=x.current)==null?void 0:M.assistantMsgId)===A.id};s(M=>M.map(O=>V_(O,A)?{...O,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:MQ(N)}:O));try{const M=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(!M.ok){const O=await M.json().catch(()=>null),D=[O==null?void 0:O.message,O==null?void 0:O.detail,O==null?void 0:O.error].find(F=>typeof F=="string"&&F.trim());throw M.status===409?new Error(D||"任务仍在执行,请先停止"):M.status>=500?new Error(D||"服务暂时无法完成请求,请稍后重试"):new Error(D||`请求失败(HTTP ${M.status})`)}await R9(M,{assistantMsgId:A.id,onMessageId:O=>{if(!L())return;const D=x.current;D&&(D.anchorMessageId=O)},onProgress:O=>{L()&&s(D=>D.map(F=>V_(F,A)?{...F,content:O}:F))},onProcessEvent:O=>{L()&&s(D=>D.map(F=>V_(F,A)?V9(F,O):F))},onContent:O=>{L()&&s(D=>D.map(F=>V_(F,A)?I_e(F,O):F))},onComplete:(O,D,F,B,j)=>{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({...$_e(H,{content:O,payload:D,actions:F,messageId:B,executionId:j}),retrigger_status:void 0,retrigger_error:void 0},"completed")}))},onError:(O,D)=>{L()&&s(F=>F.map(B=>{if(!V_(B,A))return B;const j=(D==null?void 0:D.cancelled)===!0;return W9({...B,content:j?"任务已停止":"",execution_status:j?"stopped":"failed",retrigger_status:j?void 0:"failed",retrigger_error:j?void 0:O,outputs:j&&B.outputs?H9(B.outputs):B.outputs},j?"stopped":"failed",j?"任务已停止":O)}))},onRecommend:O=>{L()&&o(O)}})}catch(M){if(L()&&!(M instanceof DOMException&&M.name==="AbortError")){const O=M instanceof Error?M.message:"未知错误";s(D=>D.map(F=>V_(F,A)?{...W9(F,"failed",O),content:"",execution_status:"failed",retrigger_status:"failed",retrigger_error:O}: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:M,proposalMessage:O,optionTitle:D}=A;s(j=>j.map(z=>z.id===M?{...z,proposal_status:N==="confirm"?"confirmed":"rejected"}:z));let F="";if(N==="confirm"){const j=[];if(O&&j.push(O),D&&j.push(`${D}确认执行`),L&&Object.keys(L).length>0){const z=Object.entries(L).map(([H,W])=>`${H}: ${Array.isArray(W)?W.join(","):W}`).join(", ");j.push(`参数{${z}}`)}F=j.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:k,abort:_}}function rvt(e){var u;const t=e.role==="assistant"?A_e(e.process):void 0,r={...e,process:t?{...t,origin:"history"}:void 0},n=e.role==="assistant"?Sin(r):r.outputs,i=n?{...r,outputs:n}:r,a=i.execution_id??((u=i.meta_content)==null?void 0:u.execution_id),s=i.meta_content;if(!s||s.response_type!=="proposal")return a===void 0?i:{...i,execution_id:a};const o={proposal_id:s.proposal_id||"",scene:s.scene||"playbook_select",message:"",options:(s.options||[]).map(d=>({id:d.id,playbook_code:d.playbook_code,title:d.title,description:d.description||"",selected:d.id===s.selected_option_id,params:d.params||[]})),params:s.params||[],actions:{confirm:{label:"确认执行",style:"primary"},reject:{label:"都不需要",style:"secondary"}}},l=s.proposal_status==="confirmed"?"confirmed":s.proposal_status==="rejected"?"rejected":void 0;return{...i,execution_id:a,proposal:o,proposal_status:l}}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 Sin(e){if(e.outputs)return e.outputs;const t=e.meta_content;if(Array.isArray(t==null?void 0:t.outputs_array))return t.outputs_array;if(Array.isArray(t==null?void 0:t.outputs)||t!=null&&t.outputs)return t.outputs;const r=t==null?void 0:t.output_data;if(r!=null)return{type:typeof(t==null?void 0:t.output_type)=="string"?t.output_type:"card",content:r,fields_map:Array.isArray(t==null?void 0:t.output_fields_map)?t.output_fields_map:void 0}}function nvt(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 ivt(e){const{activeAgent:t,pageSize:r=Trn,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_${nvt({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_${nvt({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 XZe({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(rvt).filter(R=>!Q0t(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 XZe({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(rvt).filter(L=>!Q0t(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]),k=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 s4r({agent_id:t});if(a!=null&&a.current||y.current!==$||!Qf(x.current,A))return!1;if(L!=null&&L.data){const M=L.data;if(M.outputs){let O=null;M.outputs.type==="card"&&((N=(P=M.outputs.content)==null?void 0:P.data)!=null&&N.content)?O=M.outputs.content.data.content:(R=M.outputs.content)!=null&&R.content?O=M.outputs.content.content:M.outputs.content?O=M.outputs.content:O=M.outputs;const D={id:M.playbook_id||"daily-report",role:"assistant",content:"",timestamp:new Date().toISOString(),ui_payload:O};return d(F=>{const B=F.filter(j=>j.id!=="daily-report");return[D,...B]}),!0}M.playbook_id&&M.playbook_name&&(i==null||i({message:M.playbook_name,playbook_id:M.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 k()?Qf(x.current,$)&&S(t):await _()}catch{await _()}finally{Qf(x.current,$)&&v(!1)}}},[t,n,_,k,w,S,s,o,l]);return{messages:u,setMessages:d,messagesTotal:h,messagesPage:p,loading:m,setLoading:v,loadMessages:_,loadMoreMessages:T,loadDailyReport:k,loadMessagesAndDailyReport:I}}function hn(e){return e==null?"":String(e).trim()}function DQ(e,t){const r=hn(e),n=hn(t);return!!(r&&r===n)}function Mh(e,t){const r=hn(t);return r?DQ(e.agent_id,r)||DQ(e.agent_code,r):!1}function G9(e,t){return e.find(r=>Mh(r,t))}function Cin(e,t,r){const n=G9(e,r);return n?Mh(n,t):DQ(t,r)}function Kx(e){return hn(e==null?void 0:e.agent_id)||hn(e==null?void 0:e.agent_code)}function avt(e,t){return DQ(e.playbook_id,t)}function svt(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 _in({open:e,onClose:t,ssoToken:r,ssoDomain:n,ssoCompany:i,initialAgentId:a,initialPlaybookId:s,initialPlaybookParams:o,initialMessage:l,triggerOnce:u=!1,enableCustomerService:d=!1,customerServiceUrl:h,onReady:f}){const[p,g]=C.useState(""),[m,v]=C.useState([]),[y,x]=C.useState([]),[b,w]=C.useState([]),[S,_]=C.useState(!1),[T,k]=C.useState(!1),[I,$]=C.useState(null),[A,P]=C.useState("1x"),[N,R]=C.useState(!1),[L,M]=C.useState(""),[O,D]=C.useState(""),[F,B]=C.useState(null),j=C.useRef(""),z=C.useMemo(()=>p&&m.find(xe=>Mh(xe,p))||null,[p,m]),H=C.useMemo(()=>T_e(z),[z]),W=C.useCallback(xe=>{$(()=>xe)},[]),{executing:G,executingRef:q,sendMessage:Y,executePlaybook:K,respondToProposal:X,abort:Z}=R_e({activeAgent:p,ssoToken:r,ssoDomain:n,ssoCompany:i,defaultParams:o,onMessagesUpdate:xe=>J(xe),onRecommendationsUpdate:w}),{messages:Q,setMessages:J,messagesTotal:re,loading:ee,loadMessages:ae,loadMoreMessages:ue}=ivt({activeAgent:p,isExecutingRef:q,ssoToken:r,ssoDomain:n,ssoCompany:i}),oe=C.useCallback(()=>{Z(),J([]),w([]),D(""),B(null)},[Z,J]),ne=C.useMemo(()=>JSON.stringify({agentId:hn(a),playbookId:hn(s),playbookParams:o??null,message:l??null}),[a,s,o,l]),le=C.useRef(""),Se=C.useCallback(()=>{Z(),k(!1),t()},[Z,t]),ve=C.useCallback(()=>{const ge=`${h||"https://ecsapi.ecgtool.com/login/sso-login"}?token=${encodeURIComponent(r)}&menuName=AI智能体`;window.open(ge,"_blank","noopener,noreferrer")},[r,h]);C.useEffect(()=>{e&&Te()},[e]),C.useEffect(()=>{e||(Z(),k(!1))},[e,Z]),C.useEffect(()=>{e&&(le.current&&le.current!==ne&&Z(),le.current=ne)},[e,ne,Z]),C.useEffect(()=>{if(!e||!a||m.length===0)return;const xe=G9(m,a);if(!xe){const pe=hn(a);j.current!==pe&&($t.error("指定的智能体不存在,已切换到默认智能体"),j.current=pe);const be=Kx(m[0]);be&&hn(p)!==be&&(oe(),g(be));return}if(j.current="",Mh(xe,p))return;const ge=Kx(xe);ge&&(oe(),g(ge))},[e,a,m,p,oe]),C.useEffect(()=>{p&&(M(""),he())},[p]),C.useEffect(()=>{!e||!p||ae()},[e,p,ae]),C.useEffect(()=>{R(!1)},[e,a,s,o,l]),C.useEffect(()=>{!e||!p||s||l&&(N||(Y(l),R(!0)))},[e,p,l,s,u,N,Y]);const Re=C.useMemo(()=>!!o&&Object.keys(o).length>0,[o]);C.useEffect(()=>{var ge;if(!e||!p||!s||N||a&&!m.some(be=>Mh(be,p)&&Mh(be,a))||!L||L!==p)return;const xe=y.find(pe=>avt(pe,s));if(!xe){$t.error("指定的剧本不存在,已切换到智能体界面"),R(!0);return}if((((ge=xe.input_fields)==null?void 0:ge.length)??0)>0&&!Re){B(xe);const pe=(xe.input_fields??[]).map(be=>`${be.label}: `).join(`
|
|
769
|
+
${ye}`}catch{return pe}},ge=(pe,be)=>{const ce={high:"#ff4d4f",medium:"#faad14",low:"#52c41a"};return E.jsxs("div",{className:"wandox-timeline-item",children:[E.jsxs("div",{className:"wandox-timeline-dot-wrapper",children:[E.jsx("span",{className:"wandox-timeline-time",style:{whiteSpace:"pre-line"},children:xe(pe.timestamp||"")}),E.jsx("div",{className:"wandox-timeline-dot",style:{background:ce[pe.priority]}}),!be&&E.jsx("div",{className:"wandox-timeline-line"})]}),E.jsxs("div",{className:"wandox-widget-card",children:[E.jsx("div",{className:"wandox-widget-title",children:pe.title}),pe.ui_payload&&E.jsx("div",{className:"wandox-widget-content wandox-markdown-content",children:E.jsx(jo,{payload:pe.ui_payload})}),pe.actions&&pe.actions.length>0&&E.jsx("div",{className:"wandox-widget-actions",children:E.jsxs("button",{type:"button",className:"wandox-widget-view-detail-btn",onClick:()=>Te(pe),children:[E.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",role:"img",children:[E.jsx("title",{children:"快速执行"}),E.jsx("path",{d:"M13 2L3 14H12L11 22L21 10H12L13 2Z",fill:"currentColor"})]}),"快速执行 (",pe.actions.length,")"]})})]})]},pe.id||`${pe.type}_${pe.title}_${pe.timestamp}`)};return E.jsxs("div",{className:"wandox-widget-section",children:[E.jsxs("div",{className:"wandox-section-header",children:[E.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[f??E.jsx("span",{className:"wandox-widget-section-title",children:t}),X&&E.jsx(K4,{title:E.jsx("div",{style:{paddingBottom:"8px",borderBottom:"1px solid #f0f0f0"},children:E.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:"8px"},children:[E.jsxs("div",{children:[E.jsx("strong",{children:X.packageName}),X.subtitle&&E.jsx("div",{style:{color:"#999",fontSize:"11px",fontWeight:400},children:X.subtitle})]}),E.jsx(dS,{count:"生效中",style:{backgroundColor:"#52c41a",fontSize:"10px",lineHeight:"18px",height:"18px",minWidth:"50px"}})]})}),content:E.jsxs("div",{style:{fontSize:"12px",lineHeight:"1.6",minWidth:"280px"},children:[E.jsxs("div",{style:{marginBottom:"8px",display:"flex",justifyContent:"space-between"},children:[E.jsx("div",{style:{color:"#999"},children:"套餐类型:"}),E.jsx("strong",{children:X.packageName})]}),X.asinUsage&&E.jsxs("div",{style:{marginBottom:X.asinUsagePercent!=null?"4px":"8px",display:"flex",justifyContent:"space-between",gap:"16px"},children:[E.jsx("div",{style:{color:"#999"},children:"ASIN 已用:"}),E.jsx("strong",{style:{color:"#9444f5"},children:X.asinUsage})]}),X.asinUsagePercent!=null&&E.jsx("div",{style:{marginBottom:"8px"},children:E.jsx("div",{style:{height:"6px",borderRadius:"3px",background:"#f0eaff",overflow:"hidden"},children:E.jsx("div",{style:{height:"100%",width:`${X.asinUsagePercent}%`,borderRadius:"3px",background:"linear-gradient(90deg, #9444f5, #b47aff)",transition:"width 0.3s ease"}})})}),E.jsxs("div",{style:{marginBottom:"8px",display:"flex",justifyContent:"space-between"},children:[E.jsx("div",{style:{color:"#999"},children:X.remainingLabel}),E.jsx("strong",{style:{color:"#9444f5",fontWeight:"bold"},children:X.remainingValue})]}),E.jsxs("div",{style:{marginBottom:"8px",display:"flex",justifyContent:"space-between"},children:[E.jsx("div",{style:{color:"#999"},children:"到期时间:"}),E.jsx("strong",{children:X.endTime})]}),E.jsxs("div",{style:{marginBottom:"8px",display:"flex",justifyContent:"space-between"},children:[E.jsx("div",{style:{color:"#999"},children:"开通时间:"}),E.jsx("strong",{children:X.startTime})]}),X.coverageItems.length>0&&E.jsxs("div",{style:{padding:"8px 12px",background:"#faf8ff",borderRadius:"8px"},children:[E.jsx("div",{style:{marginBottom:"4px",color:"#9444f5",fontSize:"13px",fontWeight:"bold"},children:X.coverageTitle}),E.jsx("div",{style:{fontSize:"11px",color:"#666",lineHeight:"2"},children:X.coverageItems.map(pe=>E.jsxs("div",{children:[E.jsx($v,{style:{marginRight:"6px",color:"#9444f5"}}),pe]},pe))})]})]}),placement:"bottom",trigger:"hover",children:E.jsx(dS,{count:X.badgeText,style:{backgroundColor:X.badgeColor,color:X.badgeTextColor,cursor:"pointer"}})})]}),E.jsx("div",{className:"wandox-inspection-controls",children:E.jsxs("button",{type:"button",className:`wandox-inspection-agent-btn ${p?"wandox-inspection-agent-btn--expanded":""}`,onClick:()=>{p?(g(!1),w(null)):g(!0)},children:[E.jsxs("span",{className:"wandox-inspection-agent-icon",children:[E.jsxs("svg",{viewBox:"0 0 24 24",width:"14",height:"14",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[E.jsx("circle",{cx:"12",cy:"12",r:"4",stroke:"currentColor",strokeWidth:"1.5"}),E.jsx("circle",{cx:"12",cy:"12",r:"1.5",fill:"currentColor"})]}),E.jsx("span",{className:"wandox-orbit-dot wandox-orbit-dot-1"}),E.jsx("span",{className:"wandox-orbit-dot wandox-orbit-dot-2"}),E.jsx("span",{className:"wandox-orbit-dot wandox-orbit-dot-3"})]}),E.jsxs("span",{className:"wandox-inspection-agent-text",children:["巡检机器人(",Y.length,")"]})]})})]}),p&&E.jsxs("div",{className:"wandox-timeline-list",children:[E.jsxs("div",{className:"wandox-agent-filter-row wandox-agent-filter-row--with-close",children:[E.jsxs("div",{className:"wandox-agent-filter-chips",children:[u.length>0&&E.jsx("button",{type:"button",className:`wandox-agent-filter-chip ${b===null?"active":""}`,onClick:()=>w(null),children:"全部"}),u.map(pe=>{const be=!!N[pe.agent_id];return E.jsxs("div",{className:`wandox-agent-filter-chip-compound ${b===pe.name?"active":""}`,children:[E.jsx("button",{type:"button",className:"wandox-agent-filter-chip-name",onClick:()=>ae(pe.name),children:pe.name}),E.jsx("button",{type:"button",className:`wandox-agent-filter-chip-webhook ${be?"bound":""}`,onClick:()=>ue(pe),title:be?"已绑定 Webhook,点击修改":"绑定 Webhook 通知",children:be?E.jsxs(E.Fragment,{children:[E.jsx("span",{className:"wandox-webhook-dot","aria-hidden":"true"}),E.jsx("span",{className:"wandox-webhook-label",children:"已通知"})]}):E.jsxs(E.Fragment,{children:[E.jsx("span",{className:"wandox-webhook-plus","aria-hidden":"true",children:"+"}),E.jsx("span",{className:"wandox-webhook-label",children:"通知"})]})})]},pe.agent_id)})]}),E.jsx("button",{type:"button",className:"wandox-timeline-list-close",onClick:()=>{g(!1),w(null),_("results")},title:"关闭",children:"✕"})]}),ee&&E.jsxs("div",{className:"wandox-negative-review-notice",children:[E.jsx("span",{className:"wandox-negative-review-notice-icon","aria-hidden":"true",children:"ℹ️"}),E.jsxs("span",{children:["差评监控需要先设置需要监控的ASIN,请前往AI工具》",E.jsx("a",{href:gin,target:"_blank",rel:"noreferrer",className:"wandox-negative-review-notice-link",children:"新老诊断"}),"进行设置。每个asin每一次都需要0.01算力。"]})]}),E.jsx("div",{className:"wandox-timeline-tabs-header",children:E.jsxs("div",{className:"wandox-timeline-tabs-nav",children:[E.jsxs("button",{type:"button",className:`wandox-timeline-tab-btn ${S==="results"?"active":""}`,onClick:()=>_("results"),children:["巡检结果",J.length>0&&E.jsx("span",{className:"wandox-timeline-tab-badge",children:J.length})]}),E.jsx("button",{type:"button",className:`wandox-timeline-tab-btn ${S==="history"?"active":""}`,onClick:()=>_("history"),children:"执行记录"})]})}),S==="results"?E.jsx("div",{className:"wandox-timeline-list-content",children:J.length>0?J.sort((pe,be)=>{const ce=pe.timestamp?new Date(pe.timestamp).getTime():0;return(be.timestamp?new Date(be.timestamp).getTime():0)-ce}).map((pe,be,ce)=>ge(pe,be===ce.length-1)):E.jsxs("div",{className:"wandox-empty-state",children:[E.jsx("div",{className:"wandox-empty-icon",children:"�"}),E.jsx("div",{className:"wandox-empty-text",children:b?"没有符合筛选条件的数据":"暂无工作区数据"}),E.jsx("div",{className:"wandox-empty-desc",children:b?"请调整筛选条件":"工作区数据将在这里显示"})]})}):E.jsx("div",{className:"wandox-timeline-list-content wandox-history-panel",children:b?T?E.jsxs("div",{className:"wandox-loading-state",children:[E.jsx("span",{className:"wandox-spinner wandox-spinner--small"}),E.jsx("span",{children:"加载中..."})]}):I.length===0?E.jsx("div",{className:"wandox-empty-state",children:E.jsx("div",{className:"wandox-empty-text",children:"暂无执行记录"})}):E.jsx("div",{className:"wandox-exec-history-list",children:I.map(pe=>E.jsxs("div",{className:"wandox-exec-history-item",children:[E.jsxs("div",{className:"wandox-exec-history-header",onClick:()=>P(A===pe.id?null:pe.id),onKeyDown:be=>be.key==="Enter"&&P(A===pe.id?null:pe.id),role:"button",tabIndex:0,children:[E.jsxs("div",{className:"wandox-exec-history-info",children:[E.jsx("span",{className:"wandox-exec-history-name",children:pe.action_name}),E.jsx("span",{className:"wandox-exec-history-time",children:ne(pe.created_at)})]}),E.jsxs("div",{className:"wandox-exec-history-status-wrapper",children:[E.jsx("span",{className:`wandox-exec-status ${Se(pe.status)}`,children:le(pe.status)}),E.jsx("span",{className:"wandox-exec-history-arrow","aria-hidden":"true",children:A===pe.id?"▼":"▶"})]})]}),A===pe.id&&E.jsxs("div",{className:"wandox-exec-history-detail",children:[pe.action_params&&Object.keys(pe.action_params).length>0&&E.jsxs("div",{className:"wandox-exec-params",children:[E.jsx("div",{className:"wandox-exec-section-label",children:"执行参数"}),E.jsx("div",{className:"wandox-exec-params-list",children:Object.entries(pe.action_params).map(([be,ce])=>E.jsxs("div",{className:"wandox-exec-param-item",children:[E.jsxs("span",{className:"wandox-exec-param-key",children:[be,":"]}),E.jsx("span",{className:"wandox-exec-param-value",children:typeof ce=="object"?JSON.stringify(ce):String(ce)})]},be))})]}),pe.error?E.jsxs("div",{className:"wandox-exec-error",children:[E.jsx("span",{className:"wandox-exec-error-label",children:"错误信息:"}),E.jsx("span",{className:"wandox-exec-error-msg",children:pe.error})]}):pe.output_type&&pe.output_data?E.jsxs("div",{className:"wandox-exec-outputs",children:[E.jsx("div",{className:"wandox-exec-section-label",children:"执行结果"}),E.jsx(jo,{payload:{type:pe.output_type,...pe.output_data}})]}):pe.outputs?E.jsxs("div",{className:"wandox-exec-outputs",children:[E.jsx("div",{className:"wandox-exec-section-label",children:"执行结果"}),E.jsx(jo,{payload:pe.outputs})]}):E.jsx("div",{className:"wandox-exec-no-output",children:"暂无输出结果"})]})]},pe.id))}):E.jsxs("div",{className:"wandox-empty-state",children:[E.jsx("div",{className:"wandox-empty-icon",children:"🤖"}),E.jsx("div",{className:"wandox-empty-text",children:"请先选择机器人"}),E.jsx("div",{className:"wandox-empty-desc",children:"在上方选择一个机器人查看执行记录"})]})})]}),E.jsx(n0t,{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:he,onExecuteComplete:s}),E.jsx(_i,{title:E.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[E.jsxs("svg",{viewBox:"0 0 24 24",width:"20",height:"20",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:[E.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"}),E.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"}),E.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"}),E.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"})]}),E.jsx("span",{children:"配置 Webhook 通知"})]}),open:O,onCancel:()=>{D(!1),B(null),z(void 0)},width:520,footer:null,centered:!0,children:E.jsxs("div",{style:{padding:"8px 0"},children:[E.jsxs("div",{style:{marginBottom:"20px",padding:"12px 16px",background:"#f5f7fa",borderRadius:"8px",border:"1px solid #e8eaed"},children:[E.jsx("div",{style:{fontSize:"13px",color:"#666",marginBottom:"4px"},children:"智能体"}),E.jsx("div",{style:{fontSize:"15px",color:"#1a1a1a",fontWeight:500},children:F==null?void 0:F.name})]}),E.jsxs("div",{style:{marginBottom:"20px"},children:[E.jsx("div",{style:{marginBottom:"8px",fontSize:"14px",color:"#333",fontWeight:500},children:"选择 通知地址"}),E.jsx(wn,{style:{width:"100%"},size:"large",placeholder:"请选择 通知地址",value:j,onChange:z,options:L.map(pe=>({label:`${pe.name} (${pe.platform==="dingtalk"?"钉钉":pe.platform==="feishu"?"飞书":"企业微信"})`,value:pe.webhook_id})),disabled:H,popupRender:pe=>E.jsxs(E.Fragment,{children:[pe,E.jsx(xqe,{style:{margin:"8px 0"}}),E.jsx(al,{style:{padding:"0 8px 4px"},children:E.jsx(or,{type:"text",icon:E.jsx("span",{children:"+"}),onClick:()=>q(!0),children:"添加新的通知地址"})})]})}),L.length===0&&E.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:[E.jsx("span",{children:"⚠️"}),E.jsx("span",{children:'暂无可用的 通知地址,请先在"通知配置"中创建'})]})]}),E.jsxs("div",{style:{padding:"12px 16px",background:"#f0f9ff",borderRadius:"8px",border:"1px solid #bae7ff",marginBottom:"20px"},children:[E.jsx("div",{style:{fontSize:"13px",color:"#0958d9",fontWeight:500,marginBottom:"8px"},children:"💡 功能说明"}),E.jsxs("div",{style:{fontSize:"13px",color:"#096dd9",lineHeight:"1.8"},children:[E.jsx("div",{children:"• 绑定后,该智能体执行完成时会自动发送通知"}),E.jsx("div",{children:"• 通知内容包含执行结果和相关信息"}),E.jsx("div",{children:"• 可随时修改或解除绑定"})]})]}),E.jsxs("div",{style:{display:"flex",gap:"12px",justifyContent:"flex-end"},children:[N[(F==null?void 0:F.agent_id)||""]&&E.jsx("button",{type:"button",onClick:Re,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:pe=>{H||(pe.currentTarget.style.background="#fff1f0")},onMouseLeave:pe=>{pe.currentTarget.style.background="#fff"},children:"解除绑定"}),E.jsx("button",{type:"button",onClick:()=>{D(!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:pe=>{H||(pe.currentTarget.style.background="#fafafa")},onMouseLeave:pe=>{pe.currentTarget.style.background="#fff"},children:"取消"}),E.jsx("button",{type:"button",onClick:ve,disabled:H||!j,style:{padding:"8px 24px",border:"none",borderRadius:"6px",background:H||!j?"#d9d9d9":"#1890ff",color:"#fff",cursor:H||!j?"not-allowed":"pointer",fontSize:"14px",fontWeight:500,transition:"all 0.2s"},onMouseEnter:pe=>{!H&&j&&(pe.currentTarget.style.background="#40a9ff")},onMouseLeave:pe=>{!H&&j&&(pe.currentTarget.style.background="#1890ff")},children:H?"保存中...":"保存"})]})]})}),E.jsx(Z0t,{open:G,onClose:()=>q(!1),onSuccess:pe=>{M(be=>[...be,pe]),z(pe.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 Q0t(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 J0t=new Set(["completed","failed","stopped"]),vin=new Set(["thinking","recommend"]),PQ={running:0,completed:1,failed:2,stopped:3};function E_e(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function k_e(e){const t=typeof e=="number"?e:Number(e);return Number.isFinite(t)&&t>=0?t:void 0}function yin(e){const t=String(e||"").toLowerCase();return t==="running"||t==="failed"||t==="stopped"?t:"completed"}function evt(e,t){if(!E_e(e))return;const r=typeof e.type=="string"&&e.type.trim()?e.type.trim():void 0;if(!r)return;const n=k_e(e.sequence),i=E_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 F5(e){return e==null?"":String(e).trim()}function bin(e,t){const r=F5(e.data.task_id),n=F5(t.data.task_id);if(r&&n)return r===n;const i=F5(e.data.step_index),a=F5(t.data.step_index);if(i&&a)return i===a;const s=F5(e.data.step_name||e.data.title),o=F5(t.data.step_name||t.data.title);return!!(s&&o&&s===o)}function tvt(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"&&bin(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 A_e(e){if(!E_e(e))return;const t=tvt((Array.isArray(e.events)?e.events:[]).map((s,o)=>evt(s,o+1)).filter(s=>!!s).sort((s,o)=>s.sequence-o.sequence)),r=yin(e.status),n=e.duration_ms===null?null:k_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=k_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 MQ(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=A_e(e.process)??MQ(e.timestamp||new Date(r).toISOString());if(J0t.has(n.status))return e;const i=n.events.reduce((d,h)=>Math.max(d,h.sequence),0)+1,a=evt({...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=tvt(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=A_e(e.process);if(!n||J0t.has(n.status)&&PQ[n.status]>=PQ[t])return e;const i=n.events.filter(u=>!vin.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=PQ[n.status]>PQ[t]?n.status:t;return{...e,process:{...n,status:l,duration_ms:o,total:i.length,events:i}}}function I_e(e,t){return{...e,content:"",ui_payload:{type:"markdown",content:t,streaming:!0},stream_content_received:!0}}function $_e(e,t){var s;const r=Array.isArray(t.payload),n=t.payload!==void 0&&t.payload!==null,i=r?void 0:t.payload,a={message_id:t.messageId||e.message_id,execution_id:t.executionId??e.execution_id,actions:(s=t.actions)!=null&&s.length?t.actions:void 0,execution_status:"completed",outputs:r?t.payload:e.outputs};return e.stream_content_received?{...e,...a,content:"",ui_payload:n?i:e.ui_payload?{...e.ui_payload,streaming:!1}:e.ui_payload}:{...e,...a,content:t.payload?"":t.content||"执行完成",ui_payload:i}}function xin(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)&&xin(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 win(e,t,r){return I_e(e,t)}function R_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 D=Date.now(),F={id:`msg_${D}`,role:"user",content:A.message||"",timestamp:new Date().toISOString(),...(z=A.attachments)!=null&&z.length?{attachments:A.attachments}:{}},B=`msg_${D+1}`,j={id:B,role:"assistant",content:"⏳ 正在思考...",timestamp:new Date().toISOString(),playbook_id:A.playbook_id,execution_status:"executing",process:MQ()};return{userMsg:F,assistantMsgId:B,assistantMsg:j}})(),L=A._hideUserMessage===!0;s(D=>L?[...D,R]:[...D,P,R]),u(!0),x.current={assistantMsgId:N};const M=new AbortController;y.current=M;const O=()=>{var D;return y.current===M&&((D=x.current)==null?void 0:D.assistantMsgId)===N};try{const D={...A,agent_id:t,stream:!0,playbook_params:{...A.playbook_params||{}},message:A.message||"",...a||{}},{_hideUserMessage:F,...B}=D,j=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:M.signal});if(!j.ok)throw new Error(`HTTP ${j.status}`);await R9(j,{assistantMsgId:N,onMessageId:z=>{if(!O())return;const H=x.current;H&&(H.anchorMessageId=z)},onQueue:z=>{O()&&(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=>{O()&&(p(null),s(H=>H.map(W=>W.id===N?{...W,content:`⏳ ${z}`}:W)))},onProcessEvent:z=>{O()&&s(H=>H.map(W=>W.id===N?V9(W,z):W))},onContent:z=>{O()&&s(H=>H.map(W=>W.id===N?I_e(W,z):W))},onComplete:(z,H,W,G,q)=>{O()&&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($_e(K,{content:z,payload:H,actions:W,messageId:G,executionId:q}),"completed")}))},onError:(z,H)=>{O()&&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=>{O()&&o(z)},onProposal:z=>{if(!O())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(D){(D==null?void 0:D.name)!=="AbortError"&&O()&&s(F=>F.map(B=>B.id===N?W9({...B,content:`❌ 执行出错: ${D.message||"未知错误"}`,execution_status:"failed"},"failed",D.message||"未知错误"):B))}finally{if(y.current===M&&(y.current=null,x.current=null,g.current=!1,u(!1),h(!1),m.current)){const D=m.current;m.current=null,setTimeout(()=>{var F;return(F=v.current)==null?void 0:F.call(v,D)},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 M;return y.current===A&&((M=x.current)==null?void 0:M.assistantMsgId)===N};if(!R){$t.warning("任务编号尚未就绪,请稍后再试");return}if(L()){h(!0),s(M=>M.map(O=>O.id===N?{...O,execution_status:"stopping",content:"正在停止..."}:O));try{const M=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(!M.ok)throw new Error(`HTTP ${M.status}`);const O=await M.json().catch(()=>null);if(!L())return;if(O&&O.success===!1)throw new Error(O.message||"停止失败");if(s(D=>D.map(F=>{var B;return F.id===N?W9({...F,message_id:(O==null?void 0:O.stopped_message_id)||((B=O==null?void 0:O.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(M){if(!L())return;h(!1),s(O=>O.map(D=>D.id===N?{...D,execution_status:"executing"}:D)),$t.error(`停止失败:${M instanceof Error?M.message:"未知错误"}`)}}},[_,s,i,n,r]),k=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 M;return y.current===R&&((M=x.current)==null?void 0:M.assistantMsgId)===A.id};s(M=>M.map(O=>V_(O,A)?{...O,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:MQ(N)}:O));try{const M=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(!M.ok){const O=await M.json().catch(()=>null),D=[O==null?void 0:O.message,O==null?void 0:O.detail,O==null?void 0:O.error].find(F=>typeof F=="string"&&F.trim());throw M.status===409?new Error(D||"任务仍在执行,请先停止"):M.status>=500?new Error(D||"服务暂时无法完成请求,请稍后重试"):new Error(D||`请求失败(HTTP ${M.status})`)}await R9(M,{assistantMsgId:A.id,onMessageId:O=>{if(!L())return;const D=x.current;D&&(D.anchorMessageId=O)},onProgress:O=>{L()&&s(D=>D.map(F=>V_(F,A)?{...F,content:O}:F))},onProcessEvent:O=>{L()&&s(D=>D.map(F=>V_(F,A)?V9(F,O):F))},onContent:O=>{L()&&s(D=>D.map(F=>V_(F,A)?I_e(F,O):F))},onComplete:(O,D,F,B,j)=>{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({...$_e(H,{content:O,payload:D,actions:F,messageId:B,executionId:j}),retrigger_status:void 0,retrigger_error:void 0},"completed")}))},onError:(O,D)=>{L()&&s(F=>F.map(B=>{if(!V_(B,A))return B;const j=(D==null?void 0:D.cancelled)===!0;return W9({...B,content:j?"任务已停止":"",execution_status:j?"stopped":"failed",retrigger_status:j?void 0:"failed",retrigger_error:j?void 0:O,outputs:j&&B.outputs?H9(B.outputs):B.outputs},j?"stopped":"failed",j?"任务已停止":O)}))},onRecommend:O=>{L()&&o(O)}})}catch(M){if(L()&&!(M instanceof DOMException&&M.name==="AbortError")){const O=M instanceof Error?M.message:"未知错误";s(D=>D.map(F=>V_(F,A)?{...W9(F,"failed",O),content:"",execution_status:"failed",retrigger_status:"failed",retrigger_error:O}: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:M,proposalMessage:O,optionTitle:D}=A;s(j=>j.map(z=>z.id===M?{...z,proposal_status:N==="confirm"?"confirmed":"rejected"}:z));let F="";if(N==="confirm"){const j=[];if(O&&j.push(O),D&&j.push(`${D}确认执行`),L&&Object.keys(L).length>0){const z=Object.entries(L).map(([H,W])=>`${H}: ${Array.isArray(W)?W.join(","):W}`).join(", ");j.push(`参数{${z}}`)}F=j.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:k,abort:_}}function rvt(e){var u;const t=e.role==="assistant"?A_e(e.process):void 0,r={...e,process:t?{...t,origin:"history"}:void 0},n=e.role==="assistant"?Sin(r):r.outputs,i=n?{...r,outputs:n}:r,a=i.execution_id??((u=i.meta_content)==null?void 0:u.execution_id),s=i.meta_content;if(!s||s.response_type!=="proposal")return a===void 0?i:{...i,execution_id:a};const o={proposal_id:s.proposal_id||"",scene:s.scene||"playbook_select",message:"",options:(s.options||[]).map(d=>({id:d.id,playbook_code:d.playbook_code,title:d.title,description:d.description||"",selected:d.id===s.selected_option_id,params:d.params||[]})),params:s.params||[],actions:{confirm:{label:"确认执行",style:"primary"},reject:{label:"都不需要",style:"secondary"}}},l=s.proposal_status==="confirmed"?"confirmed":s.proposal_status==="rejected"?"rejected":void 0;return{...i,execution_id:a,proposal:o,proposal_status:l}}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 Sin(e){if(e.outputs)return e.outputs;const t=e.meta_content;if(Array.isArray(t==null?void 0:t.outputs_array))return t.outputs_array;if(Array.isArray(t==null?void 0:t.outputs)||t!=null&&t.outputs)return t.outputs;const r=t==null?void 0:t.output_data;if(r!=null)return{type:typeof(t==null?void 0:t.output_type)=="string"?t.output_type:"card",content:r,fields_map:Array.isArray(t==null?void 0:t.output_fields_map)?t.output_fields_map:void 0}}function nvt(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 ivt(e){const{activeAgent:t,pageSize:r=Trn,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_${nvt({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_${nvt({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 XZe({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(rvt).filter(R=>!Q0t(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 XZe({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(rvt).filter(L=>!Q0t(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]),k=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 s4r({agent_id:t});if(a!=null&&a.current||y.current!==$||!Qf(x.current,A))return!1;if(L!=null&&L.data){const M=L.data;if(M.outputs){let O=null;M.outputs.type==="card"&&((N=(P=M.outputs.content)==null?void 0:P.data)!=null&&N.content)?O=M.outputs.content.data.content:(R=M.outputs.content)!=null&&R.content?O=M.outputs.content.content:M.outputs.content?O=M.outputs.content:O=M.outputs;const D={id:M.playbook_id||"daily-report",role:"assistant",content:"",timestamp:new Date().toISOString(),ui_payload:O};return d(F=>{const B=F.filter(j=>j.id!=="daily-report");return[D,...B]}),!0}M.playbook_id&&M.playbook_name&&(i==null||i({message:M.playbook_name,playbook_id:M.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 k()?Qf(x.current,$)&&S(t):await _()}catch{await _()}finally{Qf(x.current,$)&&v(!1)}}},[t,n,_,k,w,S,s,o,l]);return{messages:u,setMessages:d,messagesTotal:h,messagesPage:p,loading:m,setLoading:v,loadMessages:_,loadMoreMessages:T,loadDailyReport:k,loadMessagesAndDailyReport:I}}function hn(e){return e==null?"":String(e).trim()}function DQ(e,t){const r=hn(e),n=hn(t);return!!(r&&r===n)}function Mh(e,t){const r=hn(t);return r?DQ(e.agent_id,r)||DQ(e.agent_code,r):!1}function G9(e,t){return e.find(r=>Mh(r,t))}function Cin(e,t,r){const n=G9(e,r);return n?Mh(n,t):DQ(t,r)}function Kx(e){return hn(e==null?void 0:e.agent_id)||hn(e==null?void 0:e.agent_code)}function avt(e,t){return DQ(e.playbook_id,t)}function svt(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 _in({open:e,onClose:t,ssoToken:r,ssoDomain:n,ssoCompany:i,initialAgentId:a,initialPlaybookId:s,initialPlaybookParams:o,initialMessage:l,triggerOnce:u=!1,enableCustomerService:d=!1,customerServiceUrl:h,onReady:f}){const[p,g]=C.useState(""),[m,v]=C.useState([]),[y,x]=C.useState([]),[b,w]=C.useState([]),[S,_]=C.useState(!1),[T,k]=C.useState(!1),[I,$]=C.useState(null),[A,P]=C.useState("1x"),[N,R]=C.useState(!1),[L,M]=C.useState(""),[O,D]=C.useState(""),[F,B]=C.useState(null),j=C.useRef(""),z=C.useMemo(()=>p&&m.find(xe=>Mh(xe,p))||null,[p,m]),H=C.useMemo(()=>T_e(z),[z]),W=C.useCallback(xe=>{$(()=>xe)},[]),{executing:G,executingRef:q,sendMessage:Y,executePlaybook:K,respondToProposal:X,abort:Z}=R_e({activeAgent:p,ssoToken:r,ssoDomain:n,ssoCompany:i,defaultParams:o,onMessagesUpdate:xe=>J(xe),onRecommendationsUpdate:w}),{messages:Q,setMessages:J,messagesTotal:re,loading:ee,loadMessages:ae,loadMoreMessages:ue}=ivt({activeAgent:p,isExecutingRef:q,ssoToken:r,ssoDomain:n,ssoCompany:i}),oe=C.useCallback(()=>{Z(),J([]),w([]),D(""),B(null)},[Z,J]),ne=C.useMemo(()=>JSON.stringify({agentId:hn(a),playbookId:hn(s),playbookParams:o??null,message:l??null}),[a,s,o,l]),le=C.useRef(""),Se=C.useCallback(()=>{Z(),k(!1),t()},[Z,t]),ve=C.useCallback(()=>{const ge=`${h||"https://ecsapi.ecgtool.com/login/sso-login"}?token=${encodeURIComponent(r)}&menuName=AI智能体`;window.open(ge,"_blank","noopener,noreferrer")},[r,h]);C.useEffect(()=>{e&&Te()},[e]),C.useEffect(()=>{e||(Z(),k(!1))},[e,Z]),C.useEffect(()=>{e&&(le.current&&le.current!==ne&&Z(),le.current=ne)},[e,ne,Z]),C.useEffect(()=>{if(!e||!a||m.length===0)return;const xe=G9(m,a);if(!xe){const pe=hn(a);j.current!==pe&&($t.error("指定的智能体不存在,已切换到默认智能体"),j.current=pe);const be=Kx(m[0]);be&&hn(p)!==be&&(oe(),g(be));return}if(j.current="",Mh(xe,p))return;const ge=Kx(xe);ge&&(oe(),g(ge))},[e,a,m,p,oe]),C.useEffect(()=>{p&&(M(""),he())},[p]),C.useEffect(()=>{!e||!p||ae()},[e,p,ae]),C.useEffect(()=>{R(!1)},[e,a,s,o,l]),C.useEffect(()=>{!e||!p||s||l&&(N||(Y(l),R(!0)))},[e,p,l,s,u,N,Y]);const Re=C.useMemo(()=>!!o&&Object.keys(o).length>0,[o]);C.useEffect(()=>{var ge;if(!e||!p||!s||N||a&&!m.some(be=>Mh(be,p)&&Mh(be,a))||!L||L!==p)return;const xe=y.find(pe=>avt(pe,s));if(!xe){$t.error("指定的剧本不存在,已切换到智能体界面"),R(!0);return}if((((ge=xe.input_fields)==null?void 0:ge.length)??0)>0&&!Re){B(xe);const pe=(xe.input_fields??[]).map(be=>`${be.label}: `).join(`
|
|
770
770
|
`);D(`${xe.name},请提供以下参数:
|
|
771
771
|
${pe}`)}else K({message:l||xe.name||"",playbook_id:s,...o?{playbook_params:o}:{}});R(!0)},[e,p,L,y,a,m,s,o,Re,l,N,K]),C.useEffect(()=>{f&&f({clearMessages:()=>J([]),getMessages:()=>Q,abort:Z,showInspectionResults:xe=>{}})},[f,Q,Z,J]);const Te=async()=>{_(!0);try{const{data:xe}=await zq({page:1,page_size:99}),ge=xe||[];if(v(ge),!a){const pe=Kx(ge[0]);pe&&g(pe)}}catch{}_(!1)},he=async()=>{const xe=p;_(!0);try{const{data:ge}=await sve({agent_id:xe});x(svt(ge))}catch{}finally{_(!1),M(xe)}};return e?E.jsxs(E.Fragment,{children:[E.jsx("div",{className:"wandox-floating-drawer-mask",onClick:Se,onKeyDown:xe=>xe.key==="Escape"&&Se(),role:"button",tabIndex:0,"aria-label":"关闭抽屉"}),E.jsxs("div",{className:`wandox-floating-drawer wandox-floating-drawer-${A}`,children:[E.jsxs("div",{className:"wandox-floating-drawer-header",children:[E.jsxs("div",{className:"wandox-floating-drawer-title-group",children:[E.jsx("div",{className:"wandox-floating-drawer-title",children:(z==null?void 0:z.name)||"AI 助手"}),d&&E.jsxs("button",{type:"button",className:"wandox-floating-drawer-service",onClick:ve,title:"联系客服","aria-label":"联系客服",children:[E.jsx(eTr,{}),E.jsx("span",{children:"人工客服"})]}),H&&E.jsx(K4,{title:E.jsx("div",{style:{fontWeight:"bold"},children:E.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[E.jsx("span",{children:H.packageName}),E.jsx(dS,{count:"生效中",style:{backgroundColor:"#52c41a",fontSize:"10px",lineHeight:"18px",height:"18px",minWidth:"50px"}})]})}),content:E.jsxs("div",{style:{fontSize:"12px",lineHeight:"1.6",minWidth:"280px"},children:[E.jsxs("div",{style:{marginBottom:"8px"},children:[E.jsx("strong",{children:"套餐类型:"}),H.packageName]}),H.subtitle&&E.jsx("div",{style:{color:"#999",fontSize:"11px",marginTop:"-4px",marginBottom:"8px"},children:H.subtitle}),H.asinUsage&&E.jsxs("div",{style:{marginBottom:H.asinUsagePercent!=null?"4px":"8px"},children:[E.jsx("strong",{children:"ASIN 已用:"}),E.jsx("span",{style:{color:"#9444f5",fontWeight:"bold"},children:H.asinUsage})]}),H.asinUsagePercent!=null&&E.jsx("div",{style:{marginBottom:"8px"},children:E.jsx("div",{style:{height:"6px",borderRadius:"3px",background:"#f0eaff",overflow:"hidden"},children:E.jsx("div",{style:{height:"100%",width:`${H.asinUsagePercent}%`,borderRadius:"3px",background:"linear-gradient(90deg, #9444f5, #b47aff)",transition:"width 0.3s ease"}})})}),E.jsxs("div",{style:{marginBottom:"8px"},children:[E.jsx("strong",{children:H.remainingLabel}),E.jsx("span",{style:{color:"#52c41a",fontWeight:"bold"},children:H.remainingValue})]}),E.jsxs("div",{style:{marginBottom:"8px"},children:[E.jsx("strong",{children:"到期时间:"}),H.endTime]}),E.jsxs("div",{children:[E.jsx("strong",{children:"开通时间:"}),H.startTime]}),H.coverageItems.length>0&&E.jsxs("div",{style:{marginTop:"12px",paddingTop:"8px",borderTop:"1px solid #f0f0f0"},children:[E.jsx("div",{style:{fontSize:"11px",color:"#666",marginBottom:"4px"},children:E.jsxs("strong",{children:[H.coverageTitle,":"]})}),E.jsx("div",{style:{fontSize:"11px",color:"#666",lineHeight:"1.4"},children:H.coverageItems.map(xe=>E.jsxs("div",{children:["• ",xe]},xe))})]})]}),placement:"bottomLeft",trigger:"hover",children:E.jsx(dS,{count:H.badgeText,style:{backgroundColor:H.badgeColor,color:H.badgeTextColor,fontSize:"10px",lineHeight:"18px",height:"18px",minWidth:"60px",cursor:"pointer"}})})]}),E.jsxs("div",{className:"wandox-floating-drawer-actions",children:[E.jsxs("div",{className:"wandox-floating-drawer-size-group",children:[E.jsx("button",{type:"button",className:`wandox-floating-drawer-size-btn ${A==="1x"?"active":""}`,onClick:()=>P("1x"),title:"1倍大小",children:"1x"}),E.jsx("button",{type:"button",className:`wandox-floating-drawer-size-btn ${A==="2x"?"active":""}`,onClick:()=>P("2x"),title:"2倍大小",children:"2x"}),E.jsx("button",{type:"button",className:`wandox-floating-drawer-size-btn ${A==="fullscreen"?"active":""}`,onClick:()=>P("fullscreen"),title:"全屏",children:E.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"currentColor",children:[E.jsx("title",{children:"全屏"}),E.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"})]})})]}),E.jsx("button",{type:"button",className:"wandox-floating-drawer-close",onClick:Se,"aria-label":"关闭",children:E.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"currentColor",children:[E.jsx("title",{children:"关闭"}),E.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"})]})})]})]}),E.jsxs("div",{className:"wandox-floating-drawer-body wandox-root",children:[E.jsx(b0t,{messages:Q,playbooks:y,messagesTotal:re,loadMoreMessages:ue,loading:S||ee,executing:G,activeAgent:Kx(z)||p,onExecutePlaybook:K,onFillPlaybookParams:xe=>{var ce;const ge={playbook_id:xe.playbookId,name:xe.playbookName,input_fields:xe.inputFields};B(ge);const pe=((ce=xe.inputFields)==null?void 0:ce.map(ye=>`${ye.label}: `).join(`
|
|
772
772
|
`))||"",be=`${xe.playbookName},请提供以下参数:
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a$ as zt, $ as Lt, a3 as Tt, b2 as At, a0 as Xt, b0 as Et, b as y, ac as Yt, a1 as It, s as Q, aB as et, a_ as Bt, E as Ft, t as Rt, a2 as V } from "./mermaid.core-
|
|
2
|
-
import { p as Ot } from "./chunk-4BX2VUAB-
|
|
1
|
+
import { a$ as zt, $ as Lt, a3 as Tt, b2 as At, a0 as Xt, b0 as Et, b as y, ac as Yt, a1 as It, s as Q, aB as et, a_ as Bt, E as Ft, t as Rt, a2 as V } from "./mermaid.core-BKDyw1Oq.js";
|
|
2
|
+
import { p as Ot } from "./chunk-4BX2VUAB-DaAwWkRf.js";
|
|
3
3
|
import { p as Wt } from "./wardley-L42UT6IY-DUnkyH_z.js";
|
|
4
4
|
var G = /* @__PURE__ */ y((a, o) => {
|
|
5
5
|
const e = a <= 1 ? a * 100 : a;
|